-rw-r--r-- | noncore/apps/opie-console/common.h | 10 | ||||
-rw-r--r-- | noncore/apps/opie-console/emulation_layer.cpp | 48 | ||||
-rw-r--r-- | noncore/apps/opie-console/emulation_layer.h | 6 | ||||
-rw-r--r-- | noncore/apps/opie-console/screen.cpp | 22 | ||||
-rw-r--r-- | noncore/apps/opie-console/screen.h | 6 | ||||
-rw-r--r-- | noncore/apps/opie-console/vt102emulation.cpp | 18 | ||||
-rw-r--r-- | noncore/apps/opie-console/vt102emulation.h | 2 | ||||
-rw-r--r-- | noncore/apps/opie-console/widget_layer.h | 11 |
8 files changed, 68 insertions, 55 deletions
diff --git a/noncore/apps/opie-console/common.h b/noncore/apps/opie-console/common.h index 979c2bd..a621ff5 100644 --- a/noncore/apps/opie-console/common.h +++ b/noncore/apps/opie-console/common.h @@ -1,9 +1,9 @@ /* -------------------------------------------------------------------------- */ /* */ -/* [TECommon.h] Common Definitions */ +/* [Common.h] Common Definitions */ /* */ /* -------------------------------------------------------------------------- */ /* */ /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ /* */ /* This file is part of Konsole - an X terminal for KDE */ @@ -13,18 +13,18 @@ /* Ported Konsole to Qt/Embedded */ /* */ /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ /* */ /* -------------------------------------------------------------------------- */ -/*! \file TECommon.h +/*! \file Common.h \brief Definitions shared between TEScreen and TEWidget. */ -#ifndef TECOMMON_H -#define TECOMMON_H +#ifndef COMMON_H +#define COMMON_H #include <qcolor.h> #ifndef BOOL typedef bool BOOL; #endif @@ -108,7 +108,7 @@ struct ColorEntry } QColor color; bool transparent; // if used on bg bool bold; // if used on fg }; -#endif // TECOMMON_H +#endif // COMMON_H diff --git a/noncore/apps/opie-console/emulation_layer.cpp b/noncore/apps/opie-console/emulation_layer.cpp index 6c420e0..5baf05c 100644 --- a/noncore/apps/opie-console/emulation_layer.cpp +++ b/noncore/apps/opie-console/emulation_layer.cpp @@ -73,13 +73,13 @@ /* FIXME - evtl. the bulk operations could be made more transparent. */ #include "emulation_layer.h" -#include "widget.h" +#include "widget_layer.h" #include "screen.h" #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <qkeycode.h> @@ -92,40 +92,40 @@ #define CNTL(c) ((c)-'@') /*! */ -EmulationLayer::EmulationLayer(Widget* gui) +EmulationLayer::EmulationLayer( WidgetLayer* gui ) : decoder((QTextDecoder*)NULL) { this->gui = gui; - screen[0] = new Screen(gui->Lines(),gui->Columns()); - screen[1] = new Screen(gui->Lines(),gui->Columns()); + screen[0] = new Screen(gui->lines(),gui->columns()); + screen[1] = new Screen(gui->lines(),gui->columns()); scr = screen[0]; bulk_nlcnt = 0; // reset bulk newline counter bulk_incnt = 0; // reset bulk counter connected = FALSE; - QObject::connect(&bulk_timer, SIGNAL(timeout()), this, SLOT(showBulk()) ); - QObject::connect(gui,SIGNAL(changedImageSizeSignal(int,int)), - this,SLOT(onImageSizeChange(int,int))); - QObject::connect(gui,SIGNAL(changedHistoryCursor(int)), - this,SLOT(onHistoryCursorChange(int))); - QObject::connect(gui,SIGNAL(keyPressedSignal(QKeyEvent*)), - this,SLOT(onKeyPress(QKeyEvent*))); - QObject::connect(gui,SIGNAL(beginSelectionSignal(const int,const int)), - this,SLOT(onSelectionBegin(const int,const int)) ); - QObject::connect(gui,SIGNAL(extendSelectionSignal(const int,const int)), - this,SLOT(onSelectionExtend(const int,const int)) ); - QObject::connect(gui,SIGNAL(endSelectionSignal(const BOOL)), - this,SLOT(setSelection(const BOOL)) ); - QObject::connect(gui,SIGNAL(clearSelectionSignal()), - this,SLOT(clearSelection()) ); + QObject::connect(&bulk_timer, SIGNAL( timeout() ), this, SLOT( showBulk() ) ); + QObject::connect(gui,SIGNAL( imageSizeChanged( int, int ) ), + this,SLOT( onImageSizeChange( int, int ) ) ); + QObject::connect(gui,SIGNAL( changedHistoryCursor( int ) ), + this,SLOT( historyCursorChange( int ) ) ); + QObject::connect(gui,SIGNAL( keyPressed( QKeyEvent* ) ), + this,SLOT( onKeyPress( QKeyEvent* ) ) ); + QObject::connect(gui,SIGNAL( selectionBegin( const int, const int) ), + this,SLOT( onSelectionBegin( const int, const int ) ) ); + QObject::connect(gui,SIGNAL( selectionExtended( const int, const int ) ), + this,SLOT( onSelectionExtend( const int,const int ) ) ); + QObject::connect(gui,SIGNAL( selectionEnd( const bool ) ), + this,SLOT( setSelection( const bool ) ) ); + QObject::connect(gui,SIGNAL( selectionCleared() ), + this,SLOT( clearSelection() ) ); } /*! */ EmulationLayer::~EmulationLayer() @@ -194,13 +194,13 @@ void EmulationLayer::onRcvChar(int c) switch (c) { case '\b' : scr->BackSpace(); break; case '\t' : scr->Tabulate(); break; case '\n' : scr->NewLine(); break; case '\r' : scr->Return(); break; - case 0x07 : gui->Bell(); break; + case 0x07 : gui->bell(); break; default : scr->ShowCharacter(c); break; }; } /* ------------------------------------------------------------------------- */ /* */ @@ -300,41 +300,41 @@ void EmulationLayer::bulkNewline() void EmulationLayer::showBulk() { bulk_nlcnt = 0; // reset bulk newline counter bulk_incnt = 0; // reset bulk counter if (connected) { - Character* image = scr->getCookedImage(); // get the image + QArray<Character> image = scr->getCookedImage(); // get the image gui->setImage(image, scr->getLines(), scr->getColumns()); // actual refresh - free(image); + delete image; //FIXME: check that we do not trigger other draw event here. gui->setScroll(scr->getHistCursor(),scr->getHistLines()); } } void EmulationLayer::bulkStart() { if (bulk_timer.isActive()) bulk_timer.stop(); } void EmulationLayer::bulkEnd() { - if ( bulk_nlcnt > gui->Lines() || bulk_incnt > 20 ) + if ( bulk_nlcnt > gui->lines() || bulk_incnt > 20 ) showBulk(); // resets bulk_??cnt to 0, too. else bulk_timer.start(BULK_TIMEOUT,TRUE); } void EmulationLayer::setConnect(bool c) { connected = c; if ( connected) { - onImageSizeChange(gui->Lines(), gui->Columns()); + onImageSizeChange(gui->lines(), gui->columns()); showBulk(); } else { scr->clearSelection(); } diff --git a/noncore/apps/opie-console/emulation_layer.h b/noncore/apps/opie-console/emulation_layer.h index 5781acc..91a4856 100644 --- a/noncore/apps/opie-console/emulation_layer.h +++ b/noncore/apps/opie-console/emulation_layer.h @@ -35,13 +35,13 @@ class EmulationLayer : public QObject { Q_OBJECT public: - EmulationLayer(Widget* gui); + EmulationLayer( WidgetLayer* gui ); ~EmulationLayer(); public: virtual void setHistory(bool on); virtual bool history(); @@ -51,13 +51,13 @@ public slots: // signals incoming from Widget virtual void onHistoryCursorChange(int cursor); virtual void onKeyPress(QKeyEvent*); virtual void clearSelection(); virtual void onSelectionBegin(const int x, const int y); virtual void onSelectionExtend(const int x, const int y); - virtual void setSelection(const BOOL preserve_line_breaks); + virtual void setSelection(const bool preserve_line_breaks); public slots: // signals incoming from data source /** * to be called, when new data arrives */ @@ -103,13 +103,13 @@ public: void setKeytrans(int no); void setKeytrans(const char * no); protected: - Widget* gui; + WidgetLayer* gui; Screen* scr; // referes to one `screen' Screen* screen[2]; // 0 = primary, 1 = alternate void setScreen(int n); // set `scr' to `screen[n]' bool connected; // communicate with widget diff --git a/noncore/apps/opie-console/screen.cpp b/noncore/apps/opie-console/screen.cpp index 8ebc47d..a796ba1 100644 --- a/noncore/apps/opie-console/screen.cpp +++ b/noncore/apps/opie-console/screen.cpp @@ -65,13 +65,13 @@ Screen::Screen(int lines, int columns) { this->lines = lines; this->columns = columns; - image = (Character*) malloc(lines*columns*sizeof(Character)); + image = QArray<Character>( lines*columns ); tabstops = NULL; initTabStops(); histCursor = 0; clearSelection(); reset(); @@ -79,13 +79,13 @@ Screen::Screen(int lines, int columns) /*! Destructor */ Screen::~Screen() { - free(image); + delete image; if (tabstops) free(tabstops); } /* ------------------------------------------------------------------------- */ /* */ /* Normalized Screen Operations */ @@ -391,13 +391,13 @@ void Screen::resizeImage(int new_lines, int new_columns) { addHistLine(); scrollUp(0,1); } } // make new image - Character* newimg = (Character*) malloc(new_lines*new_columns*sizeof(Character)); + QArray<Character> newimg = QArray<Character>( new_lines * new_columns ); clearSelection(); // clear new image for (int y = 0; y < new_lines; y++) for (int x = 0; x < new_columns; x++) @@ -415,13 +415,13 @@ void Screen::resizeImage(int new_lines, int new_columns) { newimg[y*new_columns+x].c = image[loc(x,y)].c; newimg[y*new_columns+x].f = image[loc(x,y)].f; newimg[y*new_columns+x].b = image[loc(x,y)].b; newimg[y*new_columns+x].r = image[loc(x,y)].r; } - free(image); + delete image; image = newimg; lines = new_lines; columns = new_columns; cuX = QMIN(cuX,columns-1); cuY = QMIN(cuY,lines-1); @@ -463,13 +463,13 @@ void Screen::resizeImage(int new_lines, int new_columns) (which is a font attribute) and intensive (which is a color attribute), we translate this and RE_BOLD in falls eventually appart into RE_BOLD and RE_INTENSIVE. */ -void Screen::reverseRendition(Character* p) +void Screen::reverseRendition(Character *p) { UINT8 f = p->f; UINT8 b = p->b; p->f = b; p->b = f; //p->r &= ~RE_TRANSPARENT; } void Screen::effectiveRendition() // calculate rendition @@ -501,24 +501,24 @@ void Screen::effectiveRendition() NOTE that the image returned by this function must later be freed. */ -Character* Screen::getCookedImage() +QArray<Character> Screen::getCookedImage() { int x,y; - Character* merged = (Character*) malloc(lines*columns*sizeof(Character)); + Character* merged = (Character*) malloc( lines * columns * sizeof( Character ) ); Character dft(' ',DEFAULT_FORE_COLOR,DEFAULT_BACK_COLOR,DEFAULT_RENDITION); for (y = 0; (y < lines) && (y < (hist.getLines()-histCursor)); y++) { int len = QMIN(columns,hist.getLineLen(y+histCursor)); int yp = y*columns; int yq = (y+histCursor)*columns; - hist.getCells(y+histCursor,0,len,merged+yp); + hist.getCells( y+histCursor, 0, len, merged+yp ); for (x = len; x < columns; x++) merged[yp+x] = dft; for (x = 0; x < columns; x++) { int p=x + yp; int q=x + yq; if ( ( q >= sel_TL ) && ( q <= sel_BR ) ) reverseRendition(&merged[p]); // for selection } @@ -544,13 +544,15 @@ Character* Screen::getCookedImage() { int i,n = lines*columns; for (i = 0; i < n; i++) reverseRendition(&merged[i]); // for reverse display } if (getMode(MODE_Cursor) && (cuY+(hist.getLines()-histCursor) < lines)) // cursor visible reverseRendition(&merged[loc(cuX,cuY+(hist.getLines()-histCursor))]); - return merged; + QArray<Character> res( sizeof( merged ) / sizeof( Character ) ); + res.assign( merged, sizeof( merged ) / sizeof( Character ) ); + return res; } /*! */ @@ -1156,13 +1158,13 @@ void Screen::addHistLine() { Character dft; int end = columns-1; while (end >= 0 && image[end] == dft) end -= 1; - hist.addCells(image,end+1); + hist.addCells(image.data(), end+1); hist.addLine(); // adjust history cursor histCursor += (hist.getLines()-1 == histCursor); } diff --git a/noncore/apps/opie-console/screen.h b/noncore/apps/opie-console/screen.h index cd7422a..38b84ab 100644 --- a/noncore/apps/opie-console/screen.h +++ b/noncore/apps/opie-console/screen.h @@ -133,13 +133,13 @@ public: // these are all `Screen' operations void reset(); // void ShowCharacter(unsigned short c); // void resizeImage(int new_lines, int new_columns); // - Character* getCookedImage(); + QArray<Character> getCookedImage(); /*! return the number of lines. */ int getLines() { return lines; } /*! return the number of columns. */ int getColumns() { return columns; } @@ -172,13 +172,13 @@ private: // helper void addHistLine(); void initTabStops(); void effectiveRendition(); - void reverseRendition(Character* p); + void reverseRendition( Character *p ); private: /* The state of the screen is more complex as one would expect first. The screem does really do part of the @@ -190,13 +190,13 @@ private: */ // screen image ---------------- int lines; int columns; - Character *image; // [lines][columns] + QArray<Character> image; // [lines][columns] // history buffer --------------- int histCursor; // display position relative to start of the history buffer HistoryScroll hist; diff --git a/noncore/apps/opie-console/vt102emulation.cpp b/noncore/apps/opie-console/vt102emulation.cpp index 2220f4e..7eecef3 100644 --- a/noncore/apps/opie-console/vt102emulation.cpp +++ b/noncore/apps/opie-console/vt102emulation.cpp @@ -62,13 +62,13 @@ Nothing really intesting happens here. */ /*! */ -Vt102Emulation::Vt102Emulation(Widget* gui) : EmulationLayer(gui) +Vt102Emulation::Vt102Emulation(WidgetLayer* gui) : EmulationLayer(gui) { QObject::connect(gui,SIGNAL(mouseSignal(int,int,int)), this,SLOT(onMouse(int,int,int))); initTokenizer(); reset(); } @@ -346,13 +346,13 @@ void Vt102Emulation::tau( int token, int p, int q ) case TY_CTL___('A' ) : /* SOH: ignored */ break; case TY_CTL___('B' ) : /* STX: ignored */ break; case TY_CTL___('C' ) : /* ETX: ignored */ break; case TY_CTL___('D' ) : /* EOT: ignored */ break; case TY_CTL___('E' ) : reportAnswerBack ( ); break; //VT100 case TY_CTL___('F' ) : /* ACK: ignored */ break; - case TY_CTL___('G' ) : gui->Bell ( ); break; //VT100 + case TY_CTL___('G' ) : gui->bell ( ); break; //VT100 case TY_CTL___('H' ) : scr->BackSpace ( ); break; //VT100 case TY_CTL___('I' ) : scr->Tabulate ( ); break; //VT100 case TY_CTL___('J' ) : scr->NewLine ( ); break; //VT100 case TY_CTL___('K' ) : scr->NewLine ( ); break; //VT100 case TY_CTL___('L' ) : scr->NewLine ( ); break; //VT100 case TY_CTL___('M' ) : scr->Return ( ); break; //VT100 @@ -734,17 +734,17 @@ void Vt102Emulation::onKeyPress( QKeyEvent* ev ) encodeStat(AltButton , BITS_Alt ), &cmd, &txt, &len )) //printf("cmd: %d, %s, %d\n",cmd,txt,len); { switch(cmd) // ... and execute if found. { - case CMD_emitSelection : gui->emitSelection(); return; - case CMD_scrollPageUp : gui->doScroll(-gui->Lines()/2); return; - case CMD_scrollPageDown : gui->doScroll(+gui->Lines()/2); return; - case CMD_scrollLineUp : gui->doScroll(-1 ); return; - case CMD_scrollLineDown : gui->doScroll(+1 ); return; + case CMD_emitSelection : gui->insertSelection(); return; + case CMD_scrollPageUp : gui->scroll(-gui->lines()/2); return; + case CMD_scrollPageDown : gui->scroll(+gui->lines()/2); return; + case CMD_scrollLineUp : gui->scroll(-1 ); return; + case CMD_scrollLineDown : gui->scroll(+1 ); return; case CMD_send : sendString( txt ); return; case CMD_prevSession : emit prevSession(); return; case CMD_nextSession : emit nextSession(); return; } } // fall back handling @@ -921,13 +921,13 @@ void Vt102Emulation::resetModes() void Vt102Emulation::setMode(int m) { currParm.mode[m] = TRUE; switch (m) { - case MODE_Mouse1000 : gui->setMouseMarks(FALSE); + case MODE_Mouse1000 : //gui->setMouseMarks(FALSE); break; case MODE_AppScreen : screen[1]->clearSelection(); screen[1]->clearEntireScreen(); setScreen(1); break; } @@ -940,13 +940,13 @@ void Vt102Emulation::setMode(int m) void Vt102Emulation::resetMode(int m) { currParm.mode[m] = FALSE; switch (m) { - case MODE_Mouse1000 : gui->setMouseMarks(TRUE); + case MODE_Mouse1000 : //gui->setMouseMarks(TRUE); break; case MODE_AppScreen : screen[0]->clearSelection(); setScreen(0); break; } if (m < MODES_SCREEN || m == MODE_NewLine) diff --git a/noncore/apps/opie-console/vt102emulation.h b/noncore/apps/opie-console/vt102emulation.h index a3d0ae6..de4a62f 100644 --- a/noncore/apps/opie-console/vt102emulation.h +++ b/noncore/apps/opie-console/vt102emulation.h @@ -57,13 +57,13 @@ struct CharCodes class Vt102Emulation: public EmulationLayer { Q_OBJECT public: - Vt102Emulation(Widget* gui); + Vt102Emulation(WidgetLayer* gui); ~Vt102Emulation(); public slots: // signals incoming from Widget void onKeyPress(QKeyEvent*); void onMouse(int cb, int cx, int cy); diff --git a/noncore/apps/opie-console/widget_layer.h b/noncore/apps/opie-console/widget_layer.h index 6e2e61e..5bd2ef9 100644 --- a/noncore/apps/opie-console/widget_layer.h +++ b/noncore/apps/opie-console/widget_layer.h @@ -103,12 +103,23 @@ public: /** * reload configuration */ virtual void reloadConfig() = 0; + /** + * sets the scrollbar (if implemented by successor of this class) + */ + virtual void setScroll( int cursor, int slines ); + + /** + * scrolls (if implemented, by successor of this class) + * @param int value, how much the widget should scroll up (positive value) or down (negative value) + */ + virtual void scroll( int value ); + signals: /** * key was pressed */ void keyPressed( QKeyEvent *e ); |