-rw-r--r-- | noncore/apps/opie-console/vt102emulation.cpp | 2 | ||||
-rw-r--r-- | noncore/apps/opie-console/vt102emulation.h | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/noncore/apps/opie-console/vt102emulation.cpp b/noncore/apps/opie-console/vt102emulation.cpp index 7eecef3..0ebefa0 100644 --- a/noncore/apps/opie-console/vt102emulation.cpp +++ b/noncore/apps/opie-console/vt102emulation.cpp @@ -1,219 +1,219 @@ /* ------------------------------------------------------------------------- */ /* */ /* [vt102emulation.cpp] VT102 Terminal Emulation */ /* */ /* ------------------------------------------------------------------------- */ /* */ /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ /* */ /* This file is part of Konsole - an X terminal for KDE */ /* */ /* ------------------------------------------------------------------------- */ /* */ /* Ported Konsole to Qt/Embedded */ /* */ /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ /* */ /* -------------------------------------------------------------------------- */ /*! \class Vt102Emulation \brief Actual Emulation for Konsole \sa Widget \sa Screen \sa EmulationLayer */ #include "vt102emulation.h" -#include "widget.h" +#include "widget_layer.h" #include "screen.h" #include "keytrans.h" #include <stdio.h> #include <unistd.h> #include <qkeycode.h> #include <qtextcodec.h> /* VT102 Terminal Emulation This class puts together the screens, the pty and the widget to a complete terminal emulation. Beside combining it's componentes, it handles the emulations's protocol. This module consists of the following sections: - Constructor/Destructor - Incoming Bytes Event pipeline - Outgoing Bytes - Mouse Events - Keyboard Events - Modes and Charset State - Diagnostics */ /* ------------------------------------------------------------------------- */ /* */ /* Constructor / Destructor */ /* */ /* ------------------------------------------------------------------------- */ /* Nothing really intesting happens here. */ /*! */ Vt102Emulation::Vt102Emulation(WidgetLayer* gui) : EmulationLayer(gui) { QObject::connect(gui,SIGNAL(mouseSignal(int,int,int)), this,SLOT(onMouse(int,int,int))); initTokenizer(); reset(); } /*! */ Vt102Emulation::~Vt102Emulation() { } /*! */ void Vt102Emulation::reset() { resetToken(); resetModes(); resetCharset(0); screen[0]->reset(); resetCharset(1); screen[0]->reset(); setCodec(0); setKeytrans("linux.keytab"); } /* ------------------------------------------------------------------------- */ /* */ /* Processing the incoming byte stream */ /* */ /* ------------------------------------------------------------------------- */ /* Incoming Bytes Event pipeline This section deals with decoding the incoming character stream. Decoding means here, that the stream is first seperated into `tokens' which are then mapped to a `meaning' provided as operations by the `TEScreen' class or by the emulation class itself. The pipeline proceeds as follows: - Tokenizing the ESC codes (onRcvChar) - VT100 code page translation of plain characters (applyCharset) - Interpretation of ESC codes (tau) The escape codes and their meaning are described in the technical reference of this program. */ // Tokens ------------------------------------------------------------------ -- /* Since the tokens are the central notion if this section, we've put them in front. They provide the syntactical elements used to represent the terminals operations as byte sequences. They are encodes here into a single machine word, so that we can later switch over them easily. Depending on the token itself, additional argument variables are filled with parameter values. The tokens are defined below: - CHR - Printable characters (32..255 but DEL (=127)) - CTL - Control characters (0..31 but ESC (= 27), DEL) - ESC - Escape codes of the form <ESC><CHR but `[]()+*#'> - ESC_DE - Escape codes of the form <ESC><any of `()+*#%'> C - CSI_PN - Escape codes of the form <ESC>'[' {Pn} ';' {Pn} C - CSI_PS - Escape codes of the form <ESC>'[' {Pn} ';' ... C - CSI_PR - Escape codes of the form <ESC>'[' '?' {Pn} ';' ... C - VT52 - VT52 escape codes - <ESC><Chr> - <ESC>'Y'{Pc}{Pc} - XTE_HA - Xterm hacks <ESC>`]' {Pn} `;' {Text} <BEL> note that this is handled differently The last two forms allow list of arguments. Since the elements of the lists are treated individually the same way, they are passed as individual tokens to the interpretation. Further, because the meaning of the parameters are names (althought represented as numbers), they are includes within the token ('N'). */ #define TY_CONSTR(T,A,N) ( ((((int)N) & 0xffff) << 16) | ((((int)A) & 0xff) << 8) | (((int)T) & 0xff) ) #define TY_CHR___( ) TY_CONSTR(0,0,0) #define TY_CTL___(A ) TY_CONSTR(1,A,0) #define TY_ESC___(A ) TY_CONSTR(2,A,0) #define TY_ESC_CS(A,B) TY_CONSTR(3,A,B) #define TY_ESC_DE(A ) TY_CONSTR(4,A,0) #define TY_CSI_PS(A,N) TY_CONSTR(5,A,N) #define TY_CSI_PN(A ) TY_CONSTR(6,A,0) #define TY_CSI_PR(A,N) TY_CONSTR(7,A,N) #define TY_VT52__(A ) TY_CONSTR(8,A,0) // Tokenizer --------------------------------------------------------------- -- /* The tokenizers state The state is represented by the buffer (pbuf, ppos), and accompanied by decoded arguments kept in (argv,argc). Note that they are kept internal in the tokenizer. */ void Vt102Emulation::resetToken() { ppos = 0; argc = 0; argv[0] = 0; argv[1] = 0; } void Vt102Emulation::addDigit(int dig) { argv[argc] = 10*argv[argc] + dig; } void Vt102Emulation::addArgument() { argc = QMIN(argc+1,MAXARGS-1); argv[argc] = 0; } void Vt102Emulation::pushToToken(int cc) { pbuf[ppos] = cc; ppos = QMIN(ppos+1,MAXPBUF-1); } // Character Classes used while decoding #define CTL 1 #define CHR 2 #define CPN 4 #define DIG 8 #define SCS 16 #define GRP 32 void Vt102Emulation::initTokenizer() { int i; UINT8* s; for(i = 0; i < 256; i++) tbl[ i] = 0; for(i = 0; i < 32; i++) tbl[ i] |= CTL; for(i = 32; i < 256; i++) tbl[ i] |= CHR; for(s = (UINT8*)"@ABCDGHLMPXcdfry"; *s; s++) tbl[*s] |= CPN; for(s = (UINT8*)"0123456789" ; *s; s++) tbl[*s] |= DIG; for(s = (UINT8*)"()+*%" ; *s; s++) tbl[*s] |= SCS; for(s = (UINT8*)"()+*#[]%" ; *s; s++) tbl[*s] |= GRP; resetToken(); } /* Ok, here comes the nasty part of the decoder. diff --git a/noncore/apps/opie-console/vt102emulation.h b/noncore/apps/opie-console/vt102emulation.h index de4a62f..17ab449 100644 --- a/noncore/apps/opie-console/vt102emulation.h +++ b/noncore/apps/opie-console/vt102emulation.h @@ -1,153 +1,153 @@ /* -------------------------------------------------------------------------- */ /* */ /* [TEmuVt102.h] X Terminal Emulation */ /* */ /* -------------------------------------------------------------------------- */ /* */ /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ /* */ /* This file is part of Konsole - an X terminal for KDE */ /* */ /* -------------------------------------------------------------------------- */ /* */ /* Ported Konsole to Qt/Embedded */ /* */ /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ /* */ /* -------------------------------------------------------------------------- */ /* Ported embedded-konsole to opie-terminal */ /* */ /* Copyright (C) 2002 by opie developers <opie@handhelds.org> */ /* */ /* -------------------------------------------------------------------------- */ #ifndef VT102EMU_H #define VT102EMU_H -#include "widget.h" +#include "widget_layer.h" #include "screen.h" #include "emulation_layer.h" #include <qtimer.h> #include <stdio.h> // #define MODE_AppScreen (MODES_SCREEN+0) #define MODE_AppCuKeys (MODES_SCREEN+1) #define MODE_AppKeyPad (MODES_SCREEN+2) #define MODE_Mouse1000 (MODES_SCREEN+3) #define MODE_Ansi (MODES_SCREEN+4) #define MODE_total (MODES_SCREEN+5) struct DECpar { BOOL mode[MODE_total]; }; struct CharCodes { // coding info char charset[4]; // int cu_cs; // actual charset. bool graphic; // Some VT100 tricks bool pound ; // Some VT100 tricks bool sa_graphic; // saved graphic bool sa_pound; // saved pound }; class Vt102Emulation: public EmulationLayer { Q_OBJECT public: Vt102Emulation(WidgetLayer* gui); ~Vt102Emulation(); public slots: // signals incoming from Widget void onKeyPress(QKeyEvent*); void onMouse(int cb, int cx, int cy); signals: void changeTitle(int,const QString&); void prevSession(); void nextSession(); public: void reset(); /** * receive a char from IOLayer */ void onRcvChar(int cc); /** * sends a list of bytes to the IOLayer */ void sendString(const QByteArray&); /** * @deprecated use QByteArray instead * see sendString() above */ void sendString(const char *); public: BOOL getMode (int m); void setMode (int m); void resetMode (int m); void saveMode (int m); void restoreMode(int m); void resetModes(); void setConnect(bool r); private: void resetToken(); #define MAXPBUF 80 void pushToToken(int cc); int pbuf[MAXPBUF]; //FIXME: overflow? int ppos; #define MAXARGS 15 void addDigit(int dig); void addArgument(); int argv[MAXARGS]; int argc; void initTokenizer(); int tbl[256]; void scan_buffer_report(); //FIXME: rename void ReportErrorToken(); //FIXME: rename void tau(int code, int p, int q); void XtermHack(); // void reportTerminalType(); void reportStatus(); void reportAnswerBack(); void reportCursorPosition(); void reportTerminalParms(int p); protected: unsigned short applyCharset(unsigned short c); void setCharset(int n, int cs); void useCharset(int n); void setAndUseCharset(int n, int cs); void saveCursor(); void restoreCursor(); void resetCharset(int scrno); CharCodes charset[2]; DECpar currParm; DECpar saveParm; }; #endif // ifndef ANSIEMU_H |