author | zecke <zecke> | 2002-10-09 01:22:42 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-10-09 01:22:42 (UTC) |
commit | a74bf68065b94efaacb73736c7127ccb74474645 (patch) (side-by-side diff) | |
tree | d85c40d367a4922091cc1780d8e1228d38de22c8 | |
parent | 8c353ec8b86ee8f82cc25172fb69dd5fee65e848 (diff) | |
download | opie-a74bf68065b94efaacb73736c7127ccb74474645.zip opie-a74bf68065b94efaacb73736c7127ccb74474645.tar.gz opie-a74bf68065b94efaacb73736c7127ccb74474645.tar.bz2 |
PLANS:
move around some stuff to done, open to progress...
Default
add EmulationLayer stuff (vt102)
EmulationLayer tried to use WidgetLayer but this did not work out
KeyTrans make sure to load the Q*Dict first before accessing it!
ibotty please check if this was correct
MainWindow
make generation of Sessions possible
TabWidget
go back to QTabWidget for now... this is much more testedt and I
do not have to debug it. Besides that OTabWidget is a kewl widget
and we will take it as soon as Sessions are tested enough
TabWidget also implement setCurrent for sessions
Vt102 make it compile... const QByteArray != const QByteArray&
-rw-r--r-- | noncore/apps/opie-console/PLANS | 12 | ||||
-rw-r--r-- | noncore/apps/opie-console/default.cpp | 7 | ||||
-rw-r--r-- | noncore/apps/opie-console/default.h | 4 | ||||
-rw-r--r-- | noncore/apps/opie-console/emulation_layer.h | 2 | ||||
-rw-r--r-- | noncore/apps/opie-console/keytrans.cpp | 3 | ||||
-rw-r--r-- | noncore/apps/opie-console/mainwindow.cpp | 48 | ||||
-rw-r--r-- | noncore/apps/opie-console/mainwindow.h | 4 | ||||
-rw-r--r-- | noncore/apps/opie-console/metafactory.cpp | 25 | ||||
-rw-r--r-- | noncore/apps/opie-console/metafactory.h | 21 | ||||
-rw-r--r-- | noncore/apps/opie-console/profilemanager.cpp | 42 | ||||
-rw-r--r-- | noncore/apps/opie-console/profilemanager.h | 2 | ||||
-rw-r--r-- | noncore/apps/opie-console/session.cpp | 49 | ||||
-rw-r--r-- | noncore/apps/opie-console/session.h | 38 | ||||
-rw-r--r-- | noncore/apps/opie-console/tabwidget.cpp | 21 | ||||
-rw-r--r-- | noncore/apps/opie-console/tabwidget.h | 5 | ||||
-rw-r--r-- | noncore/apps/opie-console/vt102emulation.cpp | 2 | ||||
-rw-r--r-- | noncore/apps/opie-console/vt102emulation.h | 2 |
17 files changed, 247 insertions, 40 deletions
diff --git a/noncore/apps/opie-console/PLANS b/noncore/apps/opie-console/PLANS index 8f6b807..0ec45cb 100644 --- a/noncore/apps/opie-console/PLANS +++ b/noncore/apps/opie-console/PLANS @@ -1,34 +1,38 @@ can we please get a working serial connection for now? if that works i can test file transfers and stuff. -hash +sure. I finished the ConfigDialog and now doing the Profile->Session +stuff. Then you just need to click Open -zecke From a UNIX point of view we want to do something like minicom with a better GUI. It should feature some terminal emulation vt100/102, ansi, filetransfer via {x,y,z}modem, and some sort of session management. Besides this requirement we would like to be able to execute 'scripts' in a session. A script would just write to the TEmulation and then be sent via an IOlayer. Then we would like to send keys? Do we want that? We want a modular architecture which might support plugins in the future (Almost) DONE: Framework Serial IOLayer Saving and Restoring Profiles +ConfigDialog Framework +FilesendingLayer - hash TASKS in progress: Profile->Session and MainWidget --- Harlekin -FilesendingLayer - hash IOLayer - wazlaf -Configuration - josef TE - ibotty - -OPEN tasks: Session->Profile - hash Scripting - wazlaf + +OPEN tasks: +Irda ConfigWidget +BT ConfigWidget Keys - open IRDA-Layer - open Bluetooth-Layer - open diff --git a/noncore/apps/opie-console/default.cpp b/noncore/apps/opie-console/default.cpp index d9a0557..da6f3e2 100644 --- a/noncore/apps/opie-console/default.cpp +++ b/noncore/apps/opie-console/default.cpp @@ -1,67 +1,74 @@ #include "io_serial.h" #include "sz_transfer.h" #include "serialconfigwidget.h" #include "terminalwidget.h" +#include "vt102emulation.h" #include "default.h" extern "C" { // FILE Transfer Stuff FileTransferLayer* newSZTransfer(IOLayer* lay) { return new SzTransfer( SzTransfer::SZ, lay ); } FileTransferLayer* newSYTransfer(IOLayer* lay) { return new SzTransfer( SzTransfer::SY, lay ); } FileTransferLayer* newSXTransfer(IOLayer* lay) { return new SzTransfer( SzTransfer::SX, lay ); } // Layer stuff IOLayer* newSerialLayer( const Profile& prof) { return new IOSerial( prof ); } IOLayer* newBTLayer( const Profile& ) { return 0l; } IOLayer* newIrDaLayer( const Profile& ) { return 0l; } // Connection Widgets ProfileDialogWidget* newSerialWidget(const QString& str, QWidget* wid) { return new SerialConfigWidget(str, wid ); } ProfileDialogWidget* newIrDaWidget( const QString& str, QWidget* wid) { return newSerialWidget(str, wid); } ProfileDialogWidget* newBTWidget( const QString& str, QWidget* wid) { return newSerialWidget(str, wid ); } // Terminal Widget(s) ProfileDialogWidget* newTerminalWidget(const QString& na, QWidget* wid) { return new TerminalWidget(na, wid,0 ); } + // VT Emulations + EmulationLayer* newVT102( Widget* wid ) { + return new Vt102Emulation( wid ); + } + }; Default::Default( MetaFactory* fact ) { fact->addFileTransferLayer( "SZ", QObject::tr("Z-Modem"), newSZTransfer ); fact->addFileTransferLayer( "SY", QObject::tr("Y-Modem"), newSYTransfer ); fact->addFileTransferLayer( "SX", QObject::tr("X-Modem"), newSXTransfer ); fact->addIOLayerFactory( "serial", QObject::tr("Serial"), newSerialLayer ); fact->addIOLayerFactory( "irda", QObject::tr("Infrared"), newIrDaLayer ); fact->addIOLayerFactory( "bt", QObject::tr("Bluetooth"), newBTLayer ); fact->addConnectionWidgetFactory( "serial", QObject::tr("Serial"), newSerialWidget ); fact->addConnectionWidgetFactory( "irda", QObject::tr("Infrared"), newIrDaWidget ); fact->addConnectionWidgetFactory( "bt", QObject::tr("Bluetooth"), newBTWidget ); fact->addTerminalWidgetFactory( "default", QObject::tr("Default Terminal"), newTerminalWidget ); + fact->addEmulationLayer( "default", QObject::tr("Default Terminal"), newVT102 ); } Default::~Default() { } diff --git a/noncore/apps/opie-console/default.h b/noncore/apps/opie-console/default.h index ed78986..b9af898 100644 --- a/noncore/apps/opie-console/default.h +++ b/noncore/apps/opie-console/default.h @@ -1,30 +1,34 @@ #ifndef OPIE_DEFAULT_H #define OPIE_DEFAULT_H #include "metafactory.h" +class Widget; + extern "C" { FileTransferLayer* newSZTransfer(IOLayer*); FileTransferLayer* newSYTransfer(IOLayer*); FileTransferLayer* newSXTransfer(IOLayer*); IOLayer* newSerialLayer(const Profile&); IOLayer* newBTLayer(const Profile& ); IOLayer* newIrDaLayer(const Profile& ); ProfileDialogWidget* newSerialWidget(const QString&, QWidget* ); ProfileDialogWidget* newIrDaWidget (const QString&, QWidget* ); ProfileDialogWidget* newBTWidget (const QString&, QWidget* ); ProfileDialogWidget* newTerminalWidget(const QString&, QWidget* ); + + EmulationLayer* newVT102( Widget* ); }; class MetaFactory; struct Default { public: Default(MetaFactory* ); ~Default(); }; #endif diff --git a/noncore/apps/opie-console/emulation_layer.h b/noncore/apps/opie-console/emulation_layer.h index 0f54331..5781acc 100644 --- a/noncore/apps/opie-console/emulation_layer.h +++ b/noncore/apps/opie-console/emulation_layer.h @@ -1,146 +1,146 @@ /* -------------------------------------------------------------------------- */ /* */ /* [emulation.h] Fundamental 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> */ /* */ /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ /* */ /* made to a layer between io_layer and widget */ /* */ /* Copyright (C) 2002 by opie developers <opie@handhelds.org> */ /* */ /* -------------------------------------------------------------------------- */ #ifndef EMULATION_LAYER_H #define EMULATION_LAYER_H -#include "widget.h" +#include "widget_layer.h" #include "screen.h" #include <qtimer.h> #include <stdio.h> #include <qtextcodec.h> #include "keytrans.h" class EmulationLayer : public QObject { Q_OBJECT public: EmulationLayer(Widget* gui); ~EmulationLayer(); public: virtual void setHistory(bool on); virtual bool history(); public slots: // signals incoming from Widget virtual void onImageSizeChange(int lines, int columns); 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); public slots: // signals incoming from data source /** * to be called, when new data arrives */ void onRcvBlock(const QByteArray&); signals: /** * will send data, encoded to suit emulation */ void sndBlock(const QByteArray&); void ImageSizeChanged(int lines, int columns); void changeColumns(int columns); void changeTitle(int arg, const char* str); public: /** * process single char (decode) */ virtual void onRcvChar(int); virtual void setMode (int) = 0; virtual void resetMode(int) = 0; /** * @deprecated use qbytearray instead */ virtual void sendString(const char*) = 0; /** * sends a string to IOLayer * encodes to suit emulation before */ virtual void sendString(const QByteArray&) = 0; virtual void setConnect(bool r); void setColumns(int columns); void setKeytrans(int no); void setKeytrans(const char * no); protected: Widget* 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 void setCodec(int c); // codec number, 0 = locale, 1=utf8 QTextCodec* codec; QTextCodec* localeCodec; QTextDecoder* decoder; KeyTrans* keytrans; // refreshing related material. // this is localized in the class. private slots: // triggered by timer void showBulk(); private: void bulkNewline(); void bulkStart(); void bulkEnd(); private: QTimer bulk_timer; int bulk_nlcnt; // bulk newline counter char* SelectedText; int bulk_incnt; // bulk counter }; #endif // ifndef EMULATION_H diff --git a/noncore/apps/opie-console/keytrans.cpp b/noncore/apps/opie-console/keytrans.cpp index d569ae0..5ea192e 100644 --- a/noncore/apps/opie-console/keytrans.cpp +++ b/noncore/apps/opie-console/keytrans.cpp @@ -246,461 +246,464 @@ void KeytabReader::getSymbol() // regular char sc = cc; getCc(); } res = res + (char)sc; len = len + 1; } if (cc != '"') return; getCc(); sym = SYMString; return; } } void KeytabReader::ReportToken() // diagnostic { printf("sym(%d): ",slinno); switch(sym) { case SYMEol : printf("End of line"); break; case SYMEof : printf("End of file"); break; case SYMName : printf("Name: %s",res.latin1()); break; case SYMOpr : printf("Opr : %s",res.latin1()); break; case SYMString : printf("String len %d,%d ",res.length(),len); for (unsigned i = 0; i < res.length(); i++) printf(" %02x(%c)",res.latin1()[i],res.latin1()[i]>=' '?res.latin1()[i]:'?'); break; } printf("\n"); } void KeytabReader::ReportError(const char* msg) // diagnostic { fprintf(stderr,"%s(%d,%d):error: %s.\n",path.ascii(),slinno,scolno,msg); } // local symbol tables --------------------------------------------------------------------- class KeyTransSymbols { public: KeyTransSymbols(); protected: void defOprSyms(); void defModSyms(); void defKeySyms(); void defKeySym(const char* key, int val); void defOprSym(const char* key, int val); void defModSym(const char* key, int val); public: QDict<QObject> keysyms; QDict<QObject> modsyms; QDict<QObject> oprsyms; }; static KeyTransSymbols * syms = 0L; // parser ---------------------------------------------------------------------------------- /* Syntax - Line :: [KeyName { ("+" | "-") ModeName } ":" (String|CommandName)] "\n" - Comment :: '#' (any but \n)* */ KeyTrans* KeyTrans::fromDevice(QString path, QIODevice &buf) { KeyTrans* kt = new KeyTrans; kt->path = path; KeytabReader ktr(path,buf); ktr.parseTo(kt); return kt; } #define assertSyntax(Cond,Message) if (!(Cond)) { ReportError(Message); goto ERROR; } void KeytabReader::parseTo(KeyTrans* kt) { // Opening sequence buf->open(IO_ReadOnly); getCc(); linno = 1; colno = 1; getSymbol(); Loop: // syntax: ["key" KeyName { ("+" | "-") ModeName } ":" String/CommandName] ["#" Comment] if (sym == SYMName && !strcmp(res.latin1(),"keyboard")) { getSymbol(); assertSyntax(sym == SYMString, "Header expected") kt->hdr = res.latin1(); getSymbol(); assertSyntax(sym == SYMEol, "Text unexpected") getSymbol(); // eoln goto Loop; } if (sym == SYMName && !strcmp(res.latin1(),"key")) { //printf("line %3d: ",startofsym); getSymbol(); assertSyntax(sym == SYMName, "Name expected") assertSyntax(syms->keysyms[res], "Unknown key name") int key = (int)syms->keysyms[res]-1; //printf(" key %s (%04x)",res.latin1(),(int)syms->keysyms[res]-1); getSymbol(); // + - : int mode = 0; int mask = 0; while (sym == SYMOpr && (!strcmp(res.latin1(),"+") || !strcmp(res.latin1(),"-"))) { bool on = !strcmp(res.latin1(),"+"); getSymbol(); // mode name assertSyntax(sym == SYMName, "Name expected") assertSyntax(syms->modsyms[res], "Unknown mode name") int bits = (int)syms->modsyms[res]-1; if (mask & (1 << bits)) { fprintf(stderr,"%s(%d,%d): mode name used multible times.\n",path.ascii(),slinno,scolno); } else { mode |= (on << bits); mask |= (1 << bits); } //printf(", mode %s(%d) %s",res.latin1(),(int)syms->modsyms[res]-1,on?"on":"off"); getSymbol(); } assertSyntax(sym == SYMOpr && !strcmp(res.latin1(),":"), "':' expected") getSymbol(); // string or command assertSyntax(sym == SYMName || sym == SYMString,"Command or string expected") int cmd = 0; if (sym == SYMName) { assertSyntax(syms->oprsyms[res], "Unknown operator name") cmd = (int)syms->oprsyms[res]-1; //printf(": do %s(%d)",res.latin1(),(int)syms->oprsyms[res]-1); } if (sym == SYMString) { cmd = CMD_send; //printf(": send"); //for (unsigned i = 0; i < res.length(); i++) //printf(" %02x(%c)",res.latin1()[i],res.latin1()[i]>=' '?res.latin1()[i]:'?'); } //printf(". summary %04x,%02x,%02x,%d\n",key,mode,mask,cmd); KeyTrans::KeyEntry* ke = kt->addEntry(slinno,key,mode,mask,cmd,res); if (ke) { fprintf(stderr,"%s(%d): keystroke already assigned in line %d.\n",path.ascii(),slinno,ke->ref); } getSymbol(); assertSyntax(sym == SYMEol, "Unexpected text") goto Loop; } if (sym == SYMEol) { getSymbol(); goto Loop; } assertSyntax(sym == SYMEof, "Undecodable Line") buf->close(); return; ERROR: while (sym != SYMEol && sym != SYMEof) getSymbol(); // eoln goto Loop; } KeyTrans* KeyTrans::defaultKeyTrans() { QCString txt = #include "default.keytab.h" ; QBuffer buf(txt); return fromDevice("[buildin]",buf); } KeyTrans* KeyTrans::fromFile(const char* path) { QFile file(path); return fromDevice(path,file); } // local symbol tables --------------------------------------------------------------------- // material needed for parsing the config file. // This is incomplete work. void KeyTransSymbols::defKeySym(const char* key, int val) { keysyms.insert(key,(QObject*)(val+1)); } void KeyTransSymbols::defOprSym(const char* key, int val) { oprsyms.insert(key,(QObject*)(val+1)); } void KeyTransSymbols::defModSym(const char* key, int val) { modsyms.insert(key,(QObject*)(val+1)); } void KeyTransSymbols::defOprSyms() { // Modifier defOprSym("scrollLineUp", CMD_scrollLineUp ); defOprSym("scrollLineDown",CMD_scrollLineDown); defOprSym("scrollPageUp", CMD_scrollPageUp ); defOprSym("scrollPageDown",CMD_scrollPageDown); defOprSym("emitSelection", CMD_emitSelection ); defOprSym("prevSession", CMD_prevSession ); defOprSym("nextSession", CMD_nextSession ); } void KeyTransSymbols::defModSyms() { // Modifier defModSym("Shift", BITS_Shift ); defModSym("Control", BITS_Control ); defModSym("Alt", BITS_Alt ); // Modes defModSym("BsHack", BITS_BsHack ); // deprecated defModSym("Ansi", BITS_Ansi ); defModSym("NewLine", BITS_NewLine ); defModSym("AppCuKeys", BITS_AppCuKeys ); } void KeyTransSymbols::defKeySyms() { // Grey keys defKeySym("Escape", Qt::Key_Escape ); defKeySym("Tab", Qt::Key_Tab ); defKeySym("Backtab", Qt::Key_Backtab ); defKeySym("Backspace", Qt::Key_Backspace ); defKeySym("Return", Qt::Key_Return ); defKeySym("Enter", Qt::Key_Enter ); defKeySym("Insert", Qt::Key_Insert ); defKeySym("Delete", Qt::Key_Delete ); defKeySym("Pause", Qt::Key_Pause ); defKeySym("Print", Qt::Key_Print ); defKeySym("SysReq", Qt::Key_SysReq ); defKeySym("Home", Qt::Key_Home ); defKeySym("End", Qt::Key_End ); defKeySym("Left", Qt::Key_Left ); defKeySym("Up", Qt::Key_Up ); defKeySym("Right", Qt::Key_Right ); defKeySym("Down", Qt::Key_Down ); defKeySym("Prior", Qt::Key_Prior ); defKeySym("Next", Qt::Key_Next ); defKeySym("Shift", Qt::Key_Shift ); defKeySym("Control", Qt::Key_Control ); defKeySym("Meta", Qt::Key_Meta ); defKeySym("Alt", Qt::Key_Alt ); defKeySym("CapsLock", Qt::Key_CapsLock ); defKeySym("NumLock", Qt::Key_NumLock ); defKeySym("ScrollLock", Qt::Key_ScrollLock ); defKeySym("F1", Qt::Key_F1 ); defKeySym("F2", Qt::Key_F2 ); defKeySym("F3", Qt::Key_F3 ); defKeySym("F4", Qt::Key_F4 ); defKeySym("F5", Qt::Key_F5 ); defKeySym("F6", Qt::Key_F6 ); defKeySym("F7", Qt::Key_F7 ); defKeySym("F8", Qt::Key_F8 ); defKeySym("F9", Qt::Key_F9 ); defKeySym("F10", Qt::Key_F10 ); defKeySym("F11", Qt::Key_F11 ); defKeySym("F12", Qt::Key_F12 ); defKeySym("F13", Qt::Key_F13 ); defKeySym("F14", Qt::Key_F14 ); defKeySym("F15", Qt::Key_F15 ); defKeySym("F16", Qt::Key_F16 ); defKeySym("F17", Qt::Key_F17 ); defKeySym("F18", Qt::Key_F18 ); defKeySym("F19", Qt::Key_F19 ); defKeySym("F20", Qt::Key_F20 ); defKeySym("F21", Qt::Key_F21 ); defKeySym("F22", Qt::Key_F22 ); defKeySym("F23", Qt::Key_F23 ); defKeySym("F24", Qt::Key_F24 ); defKeySym("F25", Qt::Key_F25 ); defKeySym("F26", Qt::Key_F26 ); defKeySym("F27", Qt::Key_F27 ); defKeySym("F28", Qt::Key_F28 ); defKeySym("F29", Qt::Key_F29 ); defKeySym("F30", Qt::Key_F30 ); defKeySym("F31", Qt::Key_F31 ); defKeySym("F32", Qt::Key_F32 ); defKeySym("F33", Qt::Key_F33 ); defKeySym("F34", Qt::Key_F34 ); defKeySym("F35", Qt::Key_F35 ); defKeySym("Super_L", Qt::Key_Super_L ); defKeySym("Super_R", Qt::Key_Super_R ); defKeySym("Menu", Qt::Key_Menu ); defKeySym("Hyper_L", Qt::Key_Hyper_L ); defKeySym("Hyper_R", Qt::Key_Hyper_R ); // Regular keys defKeySym("Space", Qt::Key_Space ); defKeySym("Exclam", Qt::Key_Exclam ); defKeySym("QuoteDbl", Qt::Key_QuoteDbl ); defKeySym("NumberSign", Qt::Key_NumberSign ); defKeySym("Dollar", Qt::Key_Dollar ); defKeySym("Percent", Qt::Key_Percent ); defKeySym("Ampersand", Qt::Key_Ampersand ); defKeySym("Apostrophe", Qt::Key_Apostrophe ); defKeySym("ParenLeft", Qt::Key_ParenLeft ); defKeySym("ParenRight", Qt::Key_ParenRight ); defKeySym("Asterisk", Qt::Key_Asterisk ); defKeySym("Plus", Qt::Key_Plus ); defKeySym("Comma", Qt::Key_Comma ); defKeySym("Minus", Qt::Key_Minus ); defKeySym("Period", Qt::Key_Period ); defKeySym("Slash", Qt::Key_Slash ); defKeySym("0", Qt::Key_0 ); defKeySym("1", Qt::Key_1 ); defKeySym("2", Qt::Key_2 ); defKeySym("3", Qt::Key_3 ); defKeySym("4", Qt::Key_4 ); defKeySym("5", Qt::Key_5 ); defKeySym("6", Qt::Key_6 ); defKeySym("7", Qt::Key_7 ); defKeySym("8", Qt::Key_8 ); defKeySym("9", Qt::Key_9 ); defKeySym("Colon", Qt::Key_Colon ); defKeySym("Semicolon", Qt::Key_Semicolon ); defKeySym("Less", Qt::Key_Less ); defKeySym("Equal", Qt::Key_Equal ); defKeySym("Greater", Qt::Key_Greater ); defKeySym("Question", Qt::Key_Question ); defKeySym("At", Qt::Key_At ); defKeySym("A", Qt::Key_A ); defKeySym("B", Qt::Key_B ); defKeySym("C", Qt::Key_C ); defKeySym("D", Qt::Key_D ); defKeySym("E", Qt::Key_E ); defKeySym("F", Qt::Key_F ); defKeySym("G", Qt::Key_G ); defKeySym("H", Qt::Key_H ); defKeySym("I", Qt::Key_I ); defKeySym("J", Qt::Key_J ); defKeySym("K", Qt::Key_K ); defKeySym("L", Qt::Key_L ); defKeySym("M", Qt::Key_M ); defKeySym("N", Qt::Key_N ); defKeySym("O", Qt::Key_O ); defKeySym("P", Qt::Key_P ); defKeySym("Q", Qt::Key_Q ); defKeySym("R", Qt::Key_R ); defKeySym("S", Qt::Key_S ); defKeySym("T", Qt::Key_T ); defKeySym("U", Qt::Key_U ); defKeySym("V", Qt::Key_V ); defKeySym("W", Qt::Key_W ); defKeySym("X", Qt::Key_X ); defKeySym("Y", Qt::Key_Y ); defKeySym("Z", Qt::Key_Z ); defKeySym("BracketLeft", Qt::Key_BracketLeft ); defKeySym("Backslash", Qt::Key_Backslash ); defKeySym("BracketRight", Qt::Key_BracketRight); defKeySym("AsciiCircum", Qt::Key_AsciiCircum ); defKeySym("Underscore", Qt::Key_Underscore ); defKeySym("QuoteLeft", Qt::Key_QuoteLeft ); defKeySym("BraceLeft", Qt::Key_BraceLeft ); defKeySym("Bar", Qt::Key_Bar ); defKeySym("BraceRight", Qt::Key_BraceRight ); defKeySym("AsciiTilde", Qt::Key_AsciiTilde ); } KeyTransSymbols::KeyTransSymbols() { defModSyms(); defOprSyms(); defKeySyms(); } // Global material ----------------------------------------------------------- static int keytab_serial = 0; //FIXME: remove,localize static QIntDict<KeyTrans> * numb2keymap = 0L; static QDict<KeyTrans> * path2keymap = 0L; KeyTrans* KeyTrans::find(int numb) { + loadAll(); KeyTrans* res = numb2keymap->find(numb); return res ? res : numb2keymap->find(0); } KeyTrans* KeyTrans::find(const char* path) { + loadAll(); KeyTrans* res = path2keymap->find(path); return res ? res : numb2keymap->find(0); } int KeyTrans::count() { + loadAll(); return numb2keymap->count(); } void KeyTrans::addKeyTrans() { this->numb = keytab_serial ++; numb2keymap->insert(numb,this); path2keymap->insert(path,this); } void KeyTrans::loadAll() { if (!numb2keymap) numb2keymap = new QIntDict<KeyTrans>; if (!path2keymap) path2keymap = new QDict<KeyTrans>; if (!syms) syms = new KeyTransSymbols; defaultKeyTrans()->addKeyTrans(); QString path = QPEApplication::qpeDir() + "etc/keytabs"; QDir dir(path); QStringList lst = dir.entryList("*.keytab"); for(QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) { QFile file(path + "/" + *it); KeyTrans* sc = KeyTrans::fromDevice(*it, file); if (sc) { sc->addKeyTrans(); } } } // Debugging material ----------------------------------------------------------- /* void TestTokenizer(QBuffer &buf) { // opening sequence buf.open(IO_ReadOnly); cc = buf.getch(); lineno = 1; // Test tokenizer while (getSymbol(buf)) ReportToken(); buf.close(); } void test() { // Opening sequence QCString txt = #include "default.keytab.h" ; QBuffer buf(txt); if (0) TestTokenizer(buf); if (1) { KeyTrans kt; kt.scanTable(buf); } } */ diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp index 3531478..aeb3742 100644 --- a/noncore/apps/opie-console/mainwindow.cpp +++ b/noncore/apps/opie-console/mainwindow.cpp @@ -1,180 +1,216 @@ #include <qaction.h> #include <qmenubar.h> #include <qlabel.h> #include <qpopupmenu.h> #include <qtoolbar.h> +#include "profileeditordialog.h" #include "configdialog.h" #include "default.h" #include "metafactory.h" +#include "profile.h" #include "profilemanager.h" #include "mainwindow.h" #include "tabwidget.h" MainWindow::MainWindow() { m_factory = new MetaFactory(); Default def(m_factory); m_sessions.setAutoDelete( TRUE ); m_curSession = 0; m_manager = new ProfileManager( m_factory ); m_manager->load(); initUI(); populateProfiles(); } void MainWindow::initUI() { setToolBarsMovable( FALSE ); m_tool = new QToolBar( this ); m_tool->setHorizontalStretchable( TRUE ); m_bar = new QMenuBar( m_tool ); m_console = new QPopupMenu( this ); m_sessionsPop= new QPopupMenu( this ); m_settings = new QPopupMenu( this ); /* * new Action for new sessions */ QAction* a = new QAction(); a->setText( tr("New Connection") ); a->addTo( m_console ); connect(a, SIGNAL(activated() ), this, SLOT(slotNew() ) ); /* * connect action */ m_connect = new QAction(); m_connect->setText( tr("Connect") ); m_connect->addTo( m_console ); connect(m_connect, SIGNAL(activated() ), this, SLOT(slotConnect() ) ); /* * disconnect action */ m_disconnect = new QAction(); m_disconnect->setText( tr("Disconnect") ); m_disconnect->addTo( m_console ); connect(m_disconnect, SIGNAL(activated() ), this, SLOT(slotDisconnect() ) ); /* * terminate action */ m_terminate = new QAction(); m_terminate->setText( tr("Terminate") ); m_terminate->addTo( m_console ); connect(m_disconnect, SIGNAL(activated() ), this, SLOT(slotTerminate() ) ); a = new QAction(); a->setText( tr("Close Window") ); a->addTo( m_console ); connect(a, SIGNAL(activated() ), this, SLOT(slotClose() ) ); /* * the settings action */ m_setProfiles = new QAction(); m_setProfiles->setText( tr("Configure Profiles") ); m_setProfiles->addTo( m_settings ); connect( m_setProfiles, SIGNAL(activated() ), this, SLOT(slotConfigure() ) ); /* insert the submenu */ m_console->insertItem(tr("New from Profile"), m_sessionsPop, -1, 0); /* insert the connection menu */ m_bar->insertItem( tr("Connection"), m_console ); /* the settings menu */ m_bar->insertItem( tr("Settings"), m_settings ); /* * connect to the menu activation */ connect( m_sessionsPop, SIGNAL(activated( int ) ), this, SLOT(slotProfile( int ) ) ); m_consoleWindow = new TabWidget( this, "blah"); setCentralWidget( m_consoleWindow ); } ProfileManager* MainWindow::manager() { return m_manager; } - +TabWidget* MainWindow::tabWidget() { + return m_consoleWindow; +} void MainWindow::populateProfiles() { m_sessionsPop->clear(); Profile::ValueList list = manager()->all(); for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { m_sessionsPop->insertItem( (*it).name() ); } } MainWindow::~MainWindow() { delete m_factory; manager()->save(); } MetaFactory* MainWindow::factory() { return m_factory; } Session* MainWindow::currentSession() { return m_curSession; } QList<Session> MainWindow::sessions() { return m_sessions; } void MainWindow::slotNew() { qWarning("New Connection"); + ProfileEditorDialog dlg(factory() ); + int ret = dlg.exec(); + + if ( ret == QDialog::Accepted ) { + create( dlg.profile() ); + } } void MainWindow::slotConnect() { if ( currentSession() ) currentSession()->layer()->open(); } void MainWindow::slotDisconnect() { if ( currentSession() ) currentSession()->layer()->close(); } void MainWindow::slotTerminate() { if ( currentSession() ) currentSession()->layer()->close(); - delete m_curSession; - m_curSession = 0l; + + slotClose(); /* FIXME move to the next session */ } void MainWindow::slotConfigure() { qWarning("configure"); ConfigDialog conf( manager()->all(), factory() ); conf.showMaximized(); int ret = conf.exec(); if ( QDialog::Accepted == ret ) { qWarning("conf %d", conf.list().count() ); manager()->setProfiles( conf.list() ); populateProfiles(); } } - +/* + * we will remove + * this window from the tabwidget + * remove it from the list + * delete it + * and set the currentSession() + */ void MainWindow::slotClose() { -} + if (!currentSession() ) + return; -void MainWindow::slotProfile( int ) { + tabWidget()->remove( currentSession() ); + tabWidget()->setCurrent( m_sessions.first() ); + m_sessions.remove( m_curSession ); + delete m_curSession; + m_curSession = m_sessions.first(); +} +/* + * We will get the name + * Then the profile + * and then we will make a profile + */ +void MainWindow::slotProfile( int id) { + Profile prof = manager()->profile( m_sessionsPop->text( id) ); + create( prof ); +} +void MainWindow::create( const Profile& prof ) { + Session *ses = manager()->fromProfile( prof, tabWidget() ); + m_sessions.append( ses ); + tabWidget()->add( ses ); + m_curSession = ses; } diff --git a/noncore/apps/opie-console/mainwindow.h b/noncore/apps/opie-console/mainwindow.h index 36eb3a7..7ef9c26 100644 --- a/noncore/apps/opie-console/mainwindow.h +++ b/noncore/apps/opie-console/mainwindow.h @@ -1,91 +1,93 @@ #ifndef OPIE_MAIN_WINDOW_H #define OPIE_MAIN_WINDOW_H #include <qmainwindow.h> #include <qlist.h> #include "session.h" /** * this is the MainWindow of the new opie console * it's also the dispatcher between the different * actions supported by the gui */ class QToolBar; class QMenuBar; class QAction; class MetaFactory; class TabWidget; class ProfileManager; - +class Profile; class MainWindow : public QMainWindow { Q_OBJECT public: MainWindow(); ~MainWindow(); /** * our factory to generate IOLayer and so on * */ MetaFactory* factory(); /** * A session contains a QWidget*, * an IOLayer* and some infos for us */ Session* currentSession(); /** * the session list */ QList<Session> sessions(); /** * */ ProfileManager* manager(); + TabWidget* tabWidget(); private slots: void slotNew(); void slotConnect(); void slotDisconnect(); void slotTerminate(); void slotConfigure(); void slotClose(); void slotProfile(int); private: void initUI(); void populateProfiles(); + void create( const Profile& ); /** * the current session */ Session* m_curSession; /** * the session list */ QList<Session> m_sessions; /** * the metafactory */ MetaFactory* m_factory; ProfileManager* m_manager; TabWidget* m_consoleWindow; QToolBar* m_tool; QMenuBar* m_bar; QPopupMenu* m_console; QPopupMenu* m_settings; QPopupMenu* m_sessionsPop; QAction* m_connect; QAction* m_disconnect; QAction* m_terminate; QAction* m_setProfiles; }; #endif diff --git a/noncore/apps/opie-console/metafactory.cpp b/noncore/apps/opie-console/metafactory.cpp index 4501ec2..02a9f9b 100644 --- a/noncore/apps/opie-console/metafactory.cpp +++ b/noncore/apps/opie-console/metafactory.cpp @@ -1,114 +1,139 @@ #include <qpe/config.h> #include "metafactory.h" MetaFactory::MetaFactory() { } MetaFactory::~MetaFactory() { } void MetaFactory::addConnectionWidgetFactory( const QCString& name, const QString& str, configWidget wid) { m_strings.insert( str, name ); m_conFact.insert( str, wid ); } void MetaFactory::addTerminalWidgetFactory( const QCString& name, const QString& str, configWidget wid ) { m_strings.insert( str, name ); m_termFact.insert( str, wid ); } void MetaFactory::addIOLayerFactory( const QCString& name, const QString& str, iolayer lay) { m_strings.insert( str, name ); m_layerFact.insert( str, lay ); } void MetaFactory::addFileTransferLayer( const QCString& name, const QString& str, filelayer lay) { m_strings.insert(str, name ); m_fileFact.insert( str, lay ); } +void MetaFactory::addEmulationLayer( const QCString& name, + const QString& str, + emulationLayer em) { + m_strings.insert(str, name ); + m_emu.insert( str, em ); +} QStringList MetaFactory::ioLayers()const { QStringList list; QMap<QString, iolayer>::ConstIterator it; for (it = m_layerFact.begin(); it != m_layerFact.end(); ++it ) { list << it.key(); } return list; } QStringList MetaFactory::connectionWidgets()const { QStringList list; QMap<QString, configWidget>::ConstIterator it; for ( it = m_conFact.begin(); it != m_conFact.end(); ++it ) { list << it.key(); } return list; } QStringList MetaFactory::terminalWidgets()const { QStringList list; QMap<QString, configWidget>::ConstIterator it; for ( it = m_termFact.begin(); it != m_termFact.end(); ++it ) { list << it.key(); } return list; } QStringList MetaFactory::fileTransferLayers()const { QStringList list; QMap<QString, filelayer>::ConstIterator it; for ( it = m_fileFact.begin(); it != m_fileFact.end(); ++it ) { list << it.key(); } return list; } +QStringList MetaFactory::emulationLayers()const { + QStringList list; + QMap<QString, emulationLayer>::ConstIterator it; + for ( it = m_emu.begin(); it != m_emu.end(); ++it ) { + list << it.key(); + } + return list; +} IOLayer* MetaFactory::newIOLayer( const QString& str,const Profile& prof ) { IOLayer* lay = 0l; QMap<QString, iolayer>::Iterator it; it = m_layerFact.find( str ); if ( it != m_layerFact.end() ) { lay = (*(it.data()))(prof); /* iolayer laye = it.data(); lay = (*laye )(conf);*/ } return lay; } ProfileDialogWidget *MetaFactory::newConnectionPlugin ( const QString& str, QWidget *parent) { ProfileDialogWidget* wid = 0l; QMap<QString, configWidget>::Iterator it; it = m_conFact.find( str ); if ( it != m_conFact.end() ) { wid = (*(it.data() ) )(str,parent); } return wid; } ProfileDialogWidget *MetaFactory::newTerminalPlugin( const QString& str, QWidget *parent) { if (str.isEmpty() ) return 0l; ProfileDialogWidget* wid = 0l; qWarning("new terminalPlugin %s %l", str.latin1(), parent ); QMap<QString, configWidget>::Iterator it; it = m_termFact.find( str ); if ( it != m_termFact.end() ) { wid = (*(it.data() ) )(str,parent); } return wid; } +EmulationLayer* MetaFactory::newEmulationLayer( const QString& str, Widget* wid) { + EmulationLayer* lay = 0l; + + QMap<QString, emulationLayer>::Iterator it; + it = m_emu.find( str ); + if ( it != m_emu.end() ) { + lay = (*(it.data() ) )(wid); + } + + return lay; +} QCString MetaFactory::internal( const QString& str )const { return m_strings[str]; } QString MetaFactory::external( const QCString& str )const { QMap<QString, QCString>::ConstIterator it; for ( it = m_strings.begin(); it != m_strings.end(); ++it ) { if ( it.data() == str ) return it.key(); } return QString::null; } diff --git a/noncore/apps/opie-console/metafactory.h b/noncore/apps/opie-console/metafactory.h index 3f7ddce..71c35a2 100644 --- a/noncore/apps/opie-console/metafactory.h +++ b/noncore/apps/opie-console/metafactory.h @@ -1,85 +1,106 @@ #ifndef OPIE_META_FACTORY_H #define OPIE_META_FACTORY_H /** * The MetaFactory is used to keep track of all IOLayers, FileTransferLayers and ConfigWidgets * and to instantiate these implementations on demand */ #include <qwidget.h> #include <qmap.h> #include <qpe/config.h> #include "io_layer.h" #include "file_layer.h" #include "profile.h" #include "profiledialogwidget.h" +#include "emulation_layer.h" +class Widget; class MetaFactory { public: typedef ProfileDialogWidget* (*configWidget)(const QString&, QWidget* parent); typedef IOLayer* (*iolayer)(const Profile& ); typedef FileTransferLayer* (*filelayer)(IOLayer*); + typedef EmulationLayer* (*emulationLayer)(Widget* ); MetaFactory(); ~MetaFactory(); /** * add a ProfileDialogWidget to the factory * name is the name shown to the user */ void addConnectionWidgetFactory( const QCString& internalName, const QString& uiString, configWidget ); void addTerminalWidgetFactory ( const QCString& internalName, const QString& name, configWidget ); /** * adds an IOLayer factory */ void addIOLayerFactory( const QCString&, const QString&, iolayer ); /** * adds a FileTransfer Layer */ void addFileTransferLayer( const QCString& name, const QString&, filelayer ); + /** + * adds a Factory for Emulation to the Layer.. + */ + void addEmulationLayer ( const QCString& name, + const QString& uiString, + emulationLayer ); + /* translated UI Strings */ QStringList ioLayers()const; QStringList connectionWidgets()const; + + /** + * Terminal Configuration widgets + */ QStringList terminalWidgets()const; QStringList fileTransferLayers()const; + QStringList emulationLayers()const; + + /** + * the generation... + */ IOLayer* newIOLayer( const QString&,const Profile& ); ProfileDialogWidget *newConnectionPlugin ( const QString&, QWidget* ); ProfileDialogWidget* newTerminalPlugin( const QString&, QWidget* ); + EmulationLayer* newEmulationLayer(const QString&, Widget* ); /* * internal takes the maybe translated * public QString and maps it to the internal * not translatable QCString */ QCString internal( const QString& )const; /* * external takes the internal name * it returns a translated name */ QString external( const QCString& )const; private: QMap<QString, QCString> m_strings; QMap<QString, configWidget> m_conFact; QMap<QString, configWidget> m_termFact; QMap<QString, iolayer> m_layerFact; QMap<QString, filelayer> m_fileFact; + QMap<QString, emulationLayer> m_emu; }; #endif diff --git a/noncore/apps/opie-console/profilemanager.cpp b/noncore/apps/opie-console/profilemanager.cpp index e66ebcc..dcf3cbd 100644 --- a/noncore/apps/opie-console/profilemanager.cpp +++ b/noncore/apps/opie-console/profilemanager.cpp @@ -1,100 +1,126 @@ #include <stdio.h> #include <stdlib.h> #include <qfile.h> +#include <qlayout.h> +#include <qwidgetstack.h> #include <qpe/config.h> +#include "widget.h" #include "metafactory.h" #include "profileconfig.h" #include "profilemanager.h" ProfileManager::ProfileManager( MetaFactory* fact ) : m_fact( fact ) { } ProfileManager::~ProfileManager() { } void ProfileManager::load() { m_list.clear(); qWarning("load"); ProfileConfig conf("opie-console-profiles"); QStringList groups = conf.groups(); QStringList::Iterator it; /* * for each profile */ for ( it = groups.begin(); it != groups.end(); ++it ) { qWarning("group " + (*it) ); conf.setGroup( (*it) ); Profile prof; prof.setName( conf.readEntry("name") ); prof.setIOLayer( conf.readEntry("iolayer").utf8() ); prof.setTerminalName( conf.readEntry("term").utf8() ); qWarning(" %s %s", conf.readEntry("iolayer").latin1(), prof.ioLayerName().data() ); prof.setBackground( conf.readNumEntry("back") ); prof.setForeground( conf.readNumEntry("fore") ); prof.setTerminal( conf.readNumEntry("terminal") ); prof.setConf( conf.items( (*it) ) ); /* now add it */ m_list.append( prof ); } } void ProfileManager::clear() { m_list.clear(); } Profile::ValueList ProfileManager::all()const { return m_list; } -Session* ProfileManager::fromProfile( const Profile& prof) { +/* + * Our goal is to create a Session + * We will load the the IOLayer and EmulationLayer + * from the factory + * we will generate a QWidgetStack + * add a dummy widget with layout + * add "Widget" to the layout + * add the dummy to the stack + * raise the dummy + * call session->connect(= + * this way we only need to reparent + * in TabWidget + */ +Session* ProfileManager::fromProfile( const Profile& prof, QWidget* parent) { Session* session = new Session(); session->setName( prof.name() ); - session->setIOLayer(m_fact->newIOLayer(prof.ioLayerName(), + /* translate the internal name to the external */ + session->setIOLayer(m_fact->newIOLayer( m_fact->external(prof.ioLayerName()) , prof) ); - /* - * FIXME - * load emulation - * load widget? - * set colors + fonts - */ + + QWidgetStack *stack = new QWidgetStack(parent); + session->setWidgetStack( stack ); + QWidget* dummy = new QWidget(stack ); + QHBoxLayout* lay = new QHBoxLayout(dummy ); + stack->addWidget( dummy, 0 ); + stack->raiseWidget( 0 ); + Widget* wid = new Widget(dummy ); + lay->addWidget( wid ); + + session->setEmulationWidget( wid ); + session->setEmulationLayer( m_fact->newEmulationLayer( m_fact->external( prof.terminalName() ), + wid ) ); + session->connect(); + return session; } void ProfileManager::save( ) { QFile::remove( (QString(getenv("HOME") )+ "/Settings/opie-console-profiles.conf" ) ); ProfileConfig conf("opie-console-profiles"); Profile::ValueList::Iterator it; for (it = m_list.begin(); it != m_list.end(); ++it ) { conf.setGroup( (*it).name() ); conf.writeEntry( "name", (*it).name() ); conf.writeEntry( "iolayer", QString::fromUtf8( (*it).ioLayerName() ) ); conf.writeEntry( "term", QString::fromUtf8( (*it).terminalName() ) ); conf.writeEntry( "back", (*it).background() ); conf.writeEntry( "fore", (*it).foreground() ); conf.writeEntry( "terminal", (*it).terminal() ); /* now the config stuff */ QMap<QString, QString> map = (*it).conf(); QMap<QString, QString>::Iterator it; for ( it = map.begin(); it != map.end(); ++it ) { conf.writeEntry( it.key(), it.data() ); } } } void ProfileManager::setProfiles( const Profile::ValueList& list ) { m_list = list; }; Profile ProfileManager::profile( const QString& name )const { Profile prof; Profile::ValueList::ConstIterator it; for ( it = m_list.begin(); it != m_list.end(); ++it ) { if ( name == (*it).name() ) { prof = (*it); break; } } return prof; } diff --git a/noncore/apps/opie-console/profilemanager.h b/noncore/apps/opie-console/profilemanager.h index 1387247..33b7095 100644 --- a/noncore/apps/opie-console/profilemanager.h +++ b/noncore/apps/opie-console/profilemanager.h @@ -1,32 +1,32 @@ #ifndef OPIE_PROFILE_MANAGER_H #define OPIE_PROFILE_MANAGER_H #include <qlist.h> #include "session.h" #include "profile.h" class MetaFactory; class ConfigWidget; class ProfileManager { public: ProfileManager(MetaFactory*); ~ProfileManager(); void load(); Profile::ValueList all()const; void clear(); /** * also replaces the item */ void add( const Profile& prof ); void remove( const Profile& prof ); Profile profile(const QString& name )const; - Session* fromProfile( const Profile& ); + Session* fromProfile( const Profile& , QWidget* parent = 0l); void setProfiles( const Profile::ValueList& ); void save(); private: MetaFactory* m_fact; Profile::ValueList m_list; }; #endif diff --git a/noncore/apps/opie-console/session.cpp b/noncore/apps/opie-console/session.cpp index d32b340..42b0583 100644 --- a/noncore/apps/opie-console/session.cpp +++ b/noncore/apps/opie-console/session.cpp @@ -1,38 +1,81 @@ #include "io_layer.h" #include "file_layer.h" +#include "widget.h" +#include "emulation_layer.h" #include "session.h" + Session::Session() { m_widget = 0l; m_layer = 0l; + m_widLay = 0l; + m_emLay = 0l; } -Session::Session( const QString& na, QWidget* widget, IOLayer* lay) +Session::Session( const QString& na, QWidgetStack* widget, IOLayer* lay) : m_name( na ), m_widget( widget ), m_layer( lay ) { + m_widLay = 0l; + m_emLay = 0l; } Session::~Session() { delete m_layer; + delete m_emLay; delete m_widget; + /* the widget layer should be deleted by the m_widget */ } QString Session::name()const { return m_name; } -QWidget* Session::widget() { +QWidgetStack* Session::widgetStack() { return m_widget; } IOLayer* Session::layer() { return m_layer; } +EmulationLayer* Session::emulationLayer() { + return m_emLay; +} +Widget* Session::emulationWidget() { + return m_widLay; +} +void Session::connect() { + if ( !m_layer || !m_emLay ) + return; + + QObject::connect(m_layer, SIGNAL(received(const QByteArray&) ), + m_emLay, SLOT(onRcvBlock(const QByteArray&) ) ); + QObject::connect(m_emLay, SIGNAL(sndBlock(const QByteArray&) ), + m_layer, SLOT(send(const QByteArray&) ) ); +} +void Session::disconnect() { + if ( !m_layer || !m_emLay ) + return; + + QObject::disconnect(m_layer, SIGNAL(received(const QByteArray&) ), + m_emLay, SLOT(onRcvBlock(const QByteArray&) ) ); + QObject::disconnect(m_emLay, SIGNAL(sndBlock(const QByteArray&) ), + m_layer, SLOT(send(const QByteArray&) ) ); +} void Session::setName( const QString& na){ m_name = na; } -void Session::setWidget( QWidget* wid ) { +void Session::setWidgetStack( QWidgetStack* wid ) { delete m_widget; + /* the EmulationLayer was destroyed... */ + delete m_emLay; m_widget = wid; } void Session::setIOLayer( IOLayer* lay ) { delete m_layer; m_layer = lay; } +void Session::setEmulationLayer( EmulationLayer* lay ) { + delete m_emLay; + m_emLay = lay; +} +void Session::setEmulationWidget( Widget* lay ) { + delete m_widLay; + m_widLay = lay; +} diff --git a/noncore/apps/opie-console/session.h b/noncore/apps/opie-console/session.h index 44b5fc8..c3673fc 100644 --- a/noncore/apps/opie-console/session.h +++ b/noncore/apps/opie-console/session.h @@ -1,48 +1,74 @@ #ifndef OPIE_SESSION_H #define OPIE_SESSION_H -#include <qwidget.h> +#include <qwidgetstack.h> class IOLayer; +class EmulationLayer; +class Widget; /** * This is a Session. A session contains * a QWidget pointer and a IOLayer * Imagine a session like a collection of what * is needed to show your widget in a tab ;) */ class Session { public: /** * c'tor with widget and layer * ownership get's transfered */ Session(); - Session( const QString&, QWidget* widget, IOLayer* ); + Session( const QString&, QWidgetStack* widget, IOLayer* ); ~Session(); /** * return the name of the session */ QString name()const; /** - * return the widget + * return the widgetstack + * this is used to be semi modal + * for FileTransfer + * + * semi modal == SessionModal */ - QWidget* widget(); + QWidgetStack* widgetStack(); /** * return the layer */ IOLayer* layer(); - void setWidget( QWidget* widget ); + + EmulationLayer* emulationLayer(); + Widget* emulationWidget(); + + /* + * connects the data flow from + * the IOLayer to the EmulationLayer + */ + void connect(); + + /* + * disconnect the dataflow + * this will be done for ft + */ + void disconnect(); + + void setWidgetStack( QWidgetStack* widget ); + void setEmulationLayer( EmulationLayer* lay ); + void setEmulationWidget( Widget* lay ); void setIOLayer( IOLayer* ); void setName( const QString& ); private: QString m_name; - QWidget* m_widget; + QWidgetStack* m_widget; IOLayer* m_layer; + EmulationLayer* m_emLay; + Widget* m_widLay; }; #endif diff --git a/noncore/apps/opie-console/tabwidget.cpp b/noncore/apps/opie-console/tabwidget.cpp index 783bf13..cfaef91 100644 --- a/noncore/apps/opie-console/tabwidget.cpp +++ b/noncore/apps/opie-console/tabwidget.cpp @@ -1,34 +1,43 @@ #include "tabwidget.h" TabWidget::TabWidget( QWidget* parent, const char* name ) - : OTabWidget( parent, name ) { + : QTabWidget( parent, name ) { connect(this, SIGNAL( currentChanged(QWidget*) ), this, SLOT( slotCurChanged(QWidget*) ) ); } TabWidget::~TabWidget() { } void TabWidget::add( Session* ses ) { - if ( !ses->widget() ) return; - addTab( ses->widget(), "console/konsole", ses->name() ); - m_map.insert( ses->widget(), ses ); + if ( !ses->widgetStack() ) return; + qWarning("going to add it"); + //reparent( ses->widgetStack(), QPoint() ); + //addTab( ses->widgetStack(), "console/konsole", ses->name() ); + addTab( ses->widgetStack(), ses->name() ); + m_map.insert( ses->widgetStack(), ses ); } void TabWidget::remove( Session* ses ) { - m_map.remove( ses->widget() ); - removePage( ses->widget() ); + m_map.remove( ses->widgetStack() ); + removePage( ses->widgetStack() ); } void TabWidget::slotCurChanged( QWidget* wid ) { QMap<QWidget*, Session*>::Iterator it; it = m_map.find( wid ); if ( it == m_map.end() ) { return; } emit activated( it.data() ); } +void TabWidget::setCurrent( Session* ses ) { + if (!ses ) + return; + + showPage( ses->widgetStack() ); +} diff --git a/noncore/apps/opie-console/tabwidget.h b/noncore/apps/opie-console/tabwidget.h index a701488..42a00ec 100644 --- a/noncore/apps/opie-console/tabwidget.h +++ b/noncore/apps/opie-console/tabwidget.h @@ -1,28 +1,29 @@ #ifndef OPIE_TAB_WIDGET_H #define OPIE_TAB_WIDGET_H #include <qmap.h> -#include <opie/otabwidget.h> +#include <qtabwidget.h> #include "session.h" /** * This is our central tab widget * we can add sessions here */ -class TabWidget : public OTabWidget{ +class TabWidget : public QTabWidget{ Q_OBJECT public: TabWidget(QWidget *parent, const char* name ); ~TabWidget(); void add( Session* ); void remove( Session* ); + void setCurrent( Session* ); signals: void activated(Session* ses ); private slots: void slotCurChanged( QWidget* wid ); private: QMap<QWidget*, Session*> m_map; }; #endif diff --git a/noncore/apps/opie-console/vt102emulation.cpp b/noncore/apps/opie-console/vt102emulation.cpp index dc977f5..2220f4e 100644 --- a/noncore/apps/opie-console/vt102emulation.cpp +++ b/noncore/apps/opie-console/vt102emulation.cpp @@ -241,769 +241,769 @@ void Vt102Emulation::initTokenizer() #define Xpe (ppos>=2 && pbuf[1] == ']' ) #define Xte (Xpe && cc == 7 ) #define ces(C) ( cc < 256 && (tbl[ cc ] & (C)) == (C) && !Xte) #define ESC 27 #define CNTL(c) ((c)-'@') // process an incoming unicode character void Vt102Emulation::onRcvChar(int cc) { int i; if (cc == 127) return; //VT100: ignore. if (ces( CTL)) { // DEC HACK ALERT! Control Characters are allowed *within* esc sequences in VT100 // This means, they do neither a resetToken nor a pushToToken. Some of them, do // of course. Guess this originates from a weakly layered handling of the X-on // X-off protocol, which comes really below this level. if (cc == CNTL('X') || cc == CNTL('Z') || cc == ESC) resetToken(); //VT100: CAN or SUB if (cc != ESC) { tau( TY_CTL___(cc+'@' ), 0, 0); return; } } pushToToken(cc); // advance the state int* s = pbuf; int p = ppos; if (getMode(MODE_Ansi)) // decide on proper action { if (lec(1,0,ESC)) { return; } if (les(2,1,GRP)) { return; } if (Xte ) { XtermHack(); resetToken(); return; } if (Xpe ) { return; } if (lec(3,2,'?')) { return; } if (lec(3,2,'>')) { return; } if (lun( )) { tau( TY_CHR___(), applyCharset(cc), 0); resetToken(); return; } if (lec(2,0,ESC)) { tau( TY_ESC___(s[1]), 0, 0); resetToken(); return; } if (les(3,1,SCS)) { tau( TY_ESC_CS(s[1],s[2]), 0, 0); resetToken(); return; } if (lec(3,1,'#')) { tau( TY_ESC_DE(s[2]), 0, 0); resetToken(); return; } // if (egt( )) { tau( TY_CSI_PG(cc ), '>', 0); resetToken(); return; } if (eps( CPN)) { tau( TY_CSI_PN(cc), argv[0],argv[1]); resetToken(); return; } if (ees( DIG)) { addDigit(cc-'0'); return; } if (eec( ';')) { addArgument(); return; } for (i=0;i<=argc;i++) if (epp( )) tau( TY_CSI_PR(cc,argv[i]), 0, 0); else tau( TY_CSI_PS(cc,argv[i]), 0, 0); resetToken(); } else // mode VT52 { if (lec(1,0,ESC)) return; if (les(1,0,CHR)) { tau( TY_CHR___( ), s[0], 0); resetToken(); return; } if (lec(2,1,'Y')) return; if (lec(3,1,'Y')) return; if (p < 4) { tau( TY_VT52__(s[1] ), 0, 0); resetToken(); return; } tau( TY_VT52__(s[1] ), s[2],s[3]); resetToken(); return; } } void Vt102Emulation::XtermHack() { int i,arg = 0; for (i = 2; i < ppos && '0'<=pbuf[i] && pbuf[i]<'9' ; i++) arg = 10*arg + (pbuf[i]-'0'); if (pbuf[i] != ';') { ReportErrorToken(); return; } QChar *str = new QChar[ppos-i-2]; for (int j = 0; j < ppos-i-2; j++) str[j] = pbuf[i+1+j]; QString unistr(str,ppos-i-2); // arg == 1 doesn't change the title. In XTerm it only changes the icon name // (btw: arg=0 changes title and icon, arg=1 only icon, arg=2 only title if (arg == 0 || arg == 2) emit changeTitle(arg,unistr); delete [] str; } // Interpreting Codes --------------------------------------------------------- /* Now that the incoming character stream is properly tokenized, meaning is assigned to them. These are either operations of the current screen, or of the emulation class itself. The token to be interpreteted comes in as a machine word possibly accompanied by two parameters. Likewise, the operations assigned to, come with up to two arguments. One could consider to make up a proper table from the function below. The technical reference manual provides more informations about this mapping. */ void Vt102Emulation::tau( int token, int p, int q ) { //scan_buffer_report(); //if (token == TY_CHR___()) printf("%c",p); else //printf("tau(%d,%d,%d, %d,%d)\n",(token>>0)&0xff,(token>>8)&0xff,(token>>16)&0xffff,p,q); switch (token) { case TY_CHR___( ) : scr->ShowCharacter (p ); break; //UTF16 // 127 DEL : ignored on input case TY_CTL___('@' ) : /* NUL: ignored */ break; 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___('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 case TY_CTL___('N' ) : useCharset ( 1); break; //VT100 case TY_CTL___('O' ) : useCharset ( 0); break; //VT100 case TY_CTL___('P' ) : /* DLE: ignored */ break; case TY_CTL___('Q' ) : /* DC1: XON continue */ break; //VT100 case TY_CTL___('R' ) : /* DC2: ignored */ break; case TY_CTL___('S' ) : /* DC3: XOFF halt */ break; //VT100 case TY_CTL___('T' ) : /* DC4: ignored */ break; case TY_CTL___('U' ) : /* NAK: ignored */ break; case TY_CTL___('V' ) : /* SYN: ignored */ break; case TY_CTL___('W' ) : /* ETB: ignored */ break; case TY_CTL___('X' ) : scr->ShowCharacter ( 0x2592); break; //VT100 case TY_CTL___('Y' ) : /* EM : ignored */ break; case TY_CTL___('Z' ) : scr->ShowCharacter ( 0x2592); break; //VT100 case TY_CTL___('[' ) : /* ESC: cannot be seen here. */ break; case TY_CTL___('\\' ) : /* FS : ignored */ break; case TY_CTL___(']' ) : /* GS : ignored */ break; case TY_CTL___('^' ) : /* RS : ignored */ break; case TY_CTL___('_' ) : /* US : ignored */ break; case TY_ESC___('D' ) : scr->index ( ); break; //VT100 case TY_ESC___('E' ) : scr->NextLine ( ); break; //VT100 case TY_ESC___('H' ) : scr->changeTabStop (TRUE ); break; //VT100 case TY_ESC___('M' ) : scr->reverseIndex ( ); break; //VT100 case TY_ESC___('Z' ) : reportTerminalType ( ); break; case TY_ESC___('c' ) : reset ( ); break; case TY_ESC___('n' ) : useCharset ( 2); break; case TY_ESC___('o' ) : useCharset ( 3); break; case TY_ESC___('7' ) : saveCursor ( ); break; case TY_ESC___('8' ) : restoreCursor ( ); break; case TY_ESC___('=' ) : setMode (MODE_AppKeyPad); break; case TY_ESC___('>' ) : resetMode (MODE_AppKeyPad); break; case TY_ESC___('<' ) : setMode (MODE_Ansi ); break; //VT100 case TY_ESC_CS('(', '0') : setCharset (0, '0'); break; //VT100 case TY_ESC_CS('(', 'A') : setCharset (0, 'A'); break; //VT100 case TY_ESC_CS('(', 'B') : setCharset (0, 'B'); break; //VT100 case TY_ESC_CS(')', '0') : setCharset (1, '0'); break; //VT100 case TY_ESC_CS(')', 'A') : setCharset (1, 'A'); break; //VT100 case TY_ESC_CS(')', 'B') : setCharset (1, 'B'); break; //VT100 case TY_ESC_CS('*', '0') : setCharset (2, '0'); break; //VT100 case TY_ESC_CS('*', 'A') : setCharset (2, 'A'); break; //VT100 case TY_ESC_CS('*', 'B') : setCharset (2, 'B'); break; //VT100 case TY_ESC_CS('+', '0') : setCharset (3, '0'); break; //VT100 case TY_ESC_CS('+', 'A') : setCharset (3, 'A'); break; //VT100 case TY_ESC_CS('+', 'B') : setCharset (3, 'B'); break; //VT100 case TY_ESC_CS('%', 'G') : setCodec (1 ); break; //LINUX case TY_ESC_CS('%', '@') : setCodec (0 ); break; //LINUX case TY_ESC_DE('3' ) : /* IGNORED: double high, top half */ break; case TY_ESC_DE('4' ) : /* IGNORED: double high, bottom half */ break; case TY_ESC_DE('5' ) : /* IGNORED: single width, single high*/ break; case TY_ESC_DE('6' ) : /* IGNORED: double width, single high*/ break; case TY_ESC_DE('8' ) : scr->helpAlign ( ); break; case TY_CSI_PS('K', 0) : scr->clearToEndOfLine ( ); break; case TY_CSI_PS('K', 1) : scr->clearToBeginOfLine ( ); break; case TY_CSI_PS('K', 2) : scr->clearEntireLine ( ); break; case TY_CSI_PS('J', 0) : scr->clearToEndOfScreen ( ); break; case TY_CSI_PS('J', 1) : scr->clearToBeginOfScreen ( ); break; case TY_CSI_PS('J', 2) : scr->clearEntireScreen ( ); break; case TY_CSI_PS('g', 0) : scr->changeTabStop (FALSE ); break; //VT100 case TY_CSI_PS('g', 3) : scr->clearTabStops ( ); break; //VT100 case TY_CSI_PS('h', 4) : scr-> setMode (MODE_Insert ); break; case TY_CSI_PS('h', 20) : setMode (MODE_NewLine ); break; case TY_CSI_PS('i', 0) : /* IGNORE: attached printer */ break; //VT100 case TY_CSI_PS('l', 4) : scr-> resetMode (MODE_Insert ); break; case TY_CSI_PS('l', 20) : resetMode (MODE_NewLine ); break; case TY_CSI_PS('m', 0) : scr->setDefaultRendition ( ); break; case TY_CSI_PS('m', 1) : scr-> setRendition (RE_BOLD ); break; //VT100 case TY_CSI_PS('m', 4) : scr-> setRendition (RE_UNDERLINE); break; //VT100 case TY_CSI_PS('m', 5) : scr-> setRendition (RE_BLINK ); break; //VT100 case TY_CSI_PS('m', 7) : scr-> setRendition (RE_REVERSE ); break; case TY_CSI_PS('m', 10) : /* IGNORED: mapping related */ break; //LINUX case TY_CSI_PS('m', 11) : /* IGNORED: mapping related */ break; //LINUX case TY_CSI_PS('m', 12) : /* IGNORED: mapping related */ break; //LINUX case TY_CSI_PS('m', 22) : scr->resetRendition (RE_BOLD ); break; case TY_CSI_PS('m', 24) : scr->resetRendition (RE_UNDERLINE); break; case TY_CSI_PS('m', 25) : scr->resetRendition (RE_BLINK ); break; case TY_CSI_PS('m', 27) : scr->resetRendition (RE_REVERSE ); break; case TY_CSI_PS('m', 30) : scr->setForeColor ( 0); break; case TY_CSI_PS('m', 31) : scr->setForeColor ( 1); break; case TY_CSI_PS('m', 32) : scr->setForeColor ( 2); break; case TY_CSI_PS('m', 33) : scr->setForeColor ( 3); break; case TY_CSI_PS('m', 34) : scr->setForeColor ( 4); break; case TY_CSI_PS('m', 35) : scr->setForeColor ( 5); break; case TY_CSI_PS('m', 36) : scr->setForeColor ( 6); break; case TY_CSI_PS('m', 37) : scr->setForeColor ( 7); break; case TY_CSI_PS('m', 39) : scr->setForeColorToDefault( ); break; case TY_CSI_PS('m', 40) : scr->setBackColor ( 0); break; case TY_CSI_PS('m', 41) : scr->setBackColor ( 1); break; case TY_CSI_PS('m', 42) : scr->setBackColor ( 2); break; case TY_CSI_PS('m', 43) : scr->setBackColor ( 3); break; case TY_CSI_PS('m', 44) : scr->setBackColor ( 4); break; case TY_CSI_PS('m', 45) : scr->setBackColor ( 5); break; case TY_CSI_PS('m', 46) : scr->setBackColor ( 6); break; case TY_CSI_PS('m', 47) : scr->setBackColor ( 7); break; case TY_CSI_PS('m', 49) : scr->setBackColorToDefault( ); break; case TY_CSI_PS('m', 90) : scr->setForeColor ( 8); break; case TY_CSI_PS('m', 91) : scr->setForeColor ( 9); break; case TY_CSI_PS('m', 92) : scr->setForeColor ( 10); break; case TY_CSI_PS('m', 93) : scr->setForeColor ( 11); break; case TY_CSI_PS('m', 94) : scr->setForeColor ( 12); break; case TY_CSI_PS('m', 95) : scr->setForeColor ( 13); break; case TY_CSI_PS('m', 96) : scr->setForeColor ( 14); break; case TY_CSI_PS('m', 97) : scr->setForeColor ( 15); break; case TY_CSI_PS('m', 100) : scr->setBackColor ( 8); break; case TY_CSI_PS('m', 101) : scr->setBackColor ( 9); break; case TY_CSI_PS('m', 102) : scr->setBackColor ( 10); break; case TY_CSI_PS('m', 103) : scr->setBackColor ( 11); break; case TY_CSI_PS('m', 104) : scr->setBackColor ( 12); break; case TY_CSI_PS('m', 105) : scr->setBackColor ( 13); break; case TY_CSI_PS('m', 106) : scr->setBackColor ( 14); break; case TY_CSI_PS('m', 107) : scr->setBackColor ( 15); break; case TY_CSI_PS('n', 5) : reportStatus ( ); break; case TY_CSI_PS('n', 6) : reportCursorPosition ( ); break; case TY_CSI_PS('q', 0) : /* IGNORED: LEDs off */ break; //VT100 case TY_CSI_PS('q', 1) : /* IGNORED: LED1 on */ break; //VT100 case TY_CSI_PS('q', 2) : /* IGNORED: LED2 on */ break; //VT100 case TY_CSI_PS('q', 3) : /* IGNORED: LED3 on */ break; //VT100 case TY_CSI_PS('q', 4) : /* IGNORED: LED4 on */ break; //VT100 case TY_CSI_PS('x', 0) : reportTerminalParms ( 2); break; //VT100 case TY_CSI_PS('x', 1) : reportTerminalParms ( 3); break; //VT100 case TY_CSI_PN('@' ) : scr->insertChars (p ); break; case TY_CSI_PN('A' ) : scr->cursorUp (p ); break; //VT100 case TY_CSI_PN('B' ) : scr->cursorDown (p ); break; //VT100 case TY_CSI_PN('C' ) : scr->cursorRight (p ); break; //VT100 case TY_CSI_PN('D' ) : scr->cursorLeft (p ); break; //VT100 case TY_CSI_PN('G' ) : scr->setCursorX (p ); break; //LINUX case TY_CSI_PN('H' ) : scr->setCursorYX (p, q); break; //VT100 case TY_CSI_PN('L' ) : scr->insertLines (p ); break; case TY_CSI_PN('M' ) : scr->deleteLines (p ); break; case TY_CSI_PN('P' ) : scr->deleteChars (p ); break; case TY_CSI_PN('X' ) : scr->eraseChars (p ); break; case TY_CSI_PN('c' ) : reportTerminalType ( ); break; //VT100 case TY_CSI_PN('d' ) : scr->setCursorY (p ); break; //LINUX case TY_CSI_PN('f' ) : scr->setCursorYX (p, q); break; //VT100 case TY_CSI_PN('r' ) : scr->setMargins (p, q); break; //VT100 case TY_CSI_PN('y' ) : /* IGNORED: Confidence test */ break; //VT100 case TY_CSI_PR('h', 1) : setMode (MODE_AppCuKeys); break; //VT100 case TY_CSI_PR('l', 1) : resetMode (MODE_AppCuKeys); break; //VT100 case TY_CSI_PR('s', 1) : saveMode (MODE_AppCuKeys); break; //FIXME case TY_CSI_PR('r', 1) : restoreMode (MODE_AppCuKeys); break; //FIXME case TY_CSI_PR('l', 2) : resetMode (MODE_Ansi ); break; //VT100 case TY_CSI_PR('h', 3) : setColumns ( 132); break; //VT100 case TY_CSI_PR('l', 3) : setColumns ( 80); break; //VT100 case TY_CSI_PR('h', 4) : /* IGNORED: soft scrolling */ break; //VT100 case TY_CSI_PR('l', 4) : /* IGNORED: soft scrolling */ break; //VT100 case TY_CSI_PR('h', 5) : scr-> setMode (MODE_Screen ); break; //VT100 case TY_CSI_PR('l', 5) : scr-> resetMode (MODE_Screen ); break; //VT100 case TY_CSI_PR('h', 6) : scr-> setMode (MODE_Origin ); break; //VT100 case TY_CSI_PR('l', 6) : scr-> resetMode (MODE_Origin ); break; //VT100 case TY_CSI_PR('s', 6) : scr-> saveMode (MODE_Origin ); break; //FIXME case TY_CSI_PR('r', 6) : scr->restoreMode (MODE_Origin ); break; //FIXME case TY_CSI_PR('h', 7) : scr-> setMode (MODE_Wrap ); break; //VT100 case TY_CSI_PR('l', 7) : scr-> resetMode (MODE_Wrap ); break; //VT100 case TY_CSI_PR('s', 7) : scr-> saveMode (MODE_Wrap ); break; //FIXME case TY_CSI_PR('r', 7) : scr->restoreMode (MODE_Wrap ); break; //FIXME case TY_CSI_PR('h', 8) : /* IGNORED: autorepeat on */ break; //VT100 case TY_CSI_PR('l', 8) : /* IGNORED: autorepeat off */ break; //VT100 case TY_CSI_PR('h', 9) : /* IGNORED: interlace */ break; //VT100 case TY_CSI_PR('l', 9) : /* IGNORED: interlace */ break; //VT100 case TY_CSI_PR('h', 25) : setMode (MODE_Cursor ); break; //VT100 case TY_CSI_PR('l', 25) : resetMode (MODE_Cursor ); break; //VT100 case TY_CSI_PR('h', 41) : /* IGNORED: obsolete more(1) fix */ break; //XTERM case TY_CSI_PR('l', 41) : /* IGNORED: obsolete more(1) fix */ break; //XTERM case TY_CSI_PR('s', 41) : /* IGNORED: obsolete more(1) fix */ break; //XTERM case TY_CSI_PR('r', 41) : /* IGNORED: obsolete more(1) fix */ break; //XTERM case TY_CSI_PR('h', 47) : setMode (MODE_AppScreen); break; //VT100 case TY_CSI_PR('l', 47) : resetMode (MODE_AppScreen); break; //VT100 case TY_CSI_PR('h', 1000) : setMode (MODE_Mouse1000); break; //XTERM case TY_CSI_PR('l', 1000) : resetMode (MODE_Mouse1000); break; //XTERM case TY_CSI_PR('s', 1000) : saveMode (MODE_Mouse1000); break; //XTERM case TY_CSI_PR('r', 1000) : restoreMode (MODE_Mouse1000); break; //XTERM case TY_CSI_PR('h', 1001) : /* IGNORED: hilite mouse tracking */ break; //XTERM case TY_CSI_PR('l', 1001) : /* IGNORED: hilite mouse tracking */ break; //XTERM case TY_CSI_PR('s', 1001) : /* IGNORED: hilite mouse tracking */ break; //XTERM case TY_CSI_PR('r', 1001) : /* IGNORED: hilite mouse tracking */ break; //XTERM case TY_CSI_PR('h', 1047) : setMode (MODE_AppScreen); break; //XTERM case TY_CSI_PR('l', 1047) : resetMode (MODE_AppScreen); break; //XTERM //FIXME: Unitoken: save translations case TY_CSI_PR('h', 1048) : saveCursor ( ); break; //XTERM case TY_CSI_PR('l', 1048) : restoreCursor ( ); break; //XTERM //FIXME: every once new sequences like this pop up in xterm. // Here's a guess of what they could mean. case TY_CSI_PR('h', 1049) : setMode (MODE_AppScreen); break; //XTERM case TY_CSI_PR('l', 1049) : resetMode (MODE_AppScreen); break; //XTERM //FIXME: when changing between vt52 and ansi mode evtl do some resetting. case TY_VT52__('A' ) : scr->cursorUp ( 1); break; //VT52 case TY_VT52__('B' ) : scr->cursorDown ( 1); break; //VT52 case TY_VT52__('C' ) : scr->cursorRight ( 1); break; //VT52 case TY_VT52__('D' ) : scr->cursorLeft ( 1); break; //VT52 case TY_VT52__('F' ) : setAndUseCharset (0, '0'); break; //VT52 case TY_VT52__('G' ) : setAndUseCharset (0, 'B'); break; //VT52 case TY_VT52__('H' ) : scr->setCursorYX (1,1 ); break; //VT52 case TY_VT52__('I' ) : scr->reverseIndex ( ); break; //VT52 case TY_VT52__('J' ) : scr->clearToEndOfScreen ( ); break; //VT52 case TY_VT52__('K' ) : scr->clearToEndOfLine ( ); break; //VT52 case TY_VT52__('Y' ) : scr->setCursorYX (p-31,q-31 ); break; //VT52 case TY_VT52__('Z' ) : reportTerminalType ( ); break; //VT52 case TY_VT52__('<' ) : setMode (MODE_Ansi ); break; //VT52 case TY_VT52__('=' ) : setMode (MODE_AppKeyPad); break; //VT52 case TY_VT52__('>' ) : resetMode (MODE_AppKeyPad); break; //VT52 default : ReportErrorToken(); break; }; } /* ------------------------------------------------------------------------- */ /* */ /* Terminal to Host protocol */ /* */ /* ------------------------------------------------------------------------- */ /* Outgoing bytes originate from several sources: - Replies to Enquieries. - Mouse Events - Keyboard Events */ /*! */ void Vt102Emulation::sendString(const char* s) { QByteArray tmp; tmp.setRawData( s, strlen( s )); emit sndBlock( tmp); } -void Vt102Emulation::sendString(const QByteArray s) +void Vt102Emulation::sendString(const QByteArray& s) { emit sndBlock( s ); } // Replies ----------------------------------------------------------------- -- // This section copes with replies send as response to an enquiery control code. /*! */ void Vt102Emulation::reportCursorPosition() { char tmp[20]; sprintf(tmp,"\033[%d;%dR",scr->getCursorY()+1,scr->getCursorX()+1); sendString(tmp); } /* What follows here is rather obsolete and faked stuff. The correspondent enquieries are neverthenless issued. */ /*! */ void Vt102Emulation::reportTerminalType() { //FIXME: should change? if (getMode(MODE_Ansi)) // sendString("\033[?1;2c"); // I'm a VT100 with AP0 //FIXME: send only in response to ^[[0c sendString("\033[>0;115;0c"); // I'm a VT220 //FIXME: send only in response to ^[[>c else sendString("\033/Z"); // I'm a VT52 } void Vt102Emulation::reportTerminalParms(int p) // DECREPTPARM { char tmp[100]; sprintf(tmp,"\033[%d;1;1;112;112;1;0x",p); // not really true. sendString(tmp); } /*! */ void Vt102Emulation::reportStatus() { sendString("\033[0n"); //VT100. Device status report. 0 = Ready. } /*! */ #define ANSWER_BACK "" // This is really obsolete VT100 stuff. void Vt102Emulation::reportAnswerBack() { sendString(ANSWER_BACK); } // Mouse Handling ---------------------------------------------------------- -- /*! Mouse clicks are possibly reported to the client application if it has issued interest in them. They are normally consumed by the widget for copy and paste, but may be propagated from the widget when gui->setMouseMarks is set via setMode(MODE_Mouse1000). `x',`y' are 1-based. `ev' (event) indicates the button pressed (0-2) or a general mouse release (3). */ void Vt102Emulation::onMouse( int cb, int cx, int cy ) { char tmp[20]; if (!connected) return; sprintf(tmp,"\033[M%c%c%c",cb+040,cx+040,cy+040); sendString(tmp); } // Keyboard Handling ------------------------------------------------------- -- #define encodeMode(M,B) BITS(B,getMode(M)) #define encodeStat(M,B) BITS(B,((ev->state() & (M)) == (M))) /* Keyboard event handling has been simplified somewhat by pushing the complications towards a configuration file [see KeyTrans class]. */ void Vt102Emulation::onKeyPress( QKeyEvent* ev ) { if (!connected) return; // someone else gets the keys //printf("State/Key: 0x%04x 0x%04x (%d,%d)\n",ev->state(),ev->key(),ev->text().length(),ev->text().length()?ev->text().ascii()[0]:0); // revert to non-history when typing if (scr->getHistCursor() != scr->getHistLines()); scr->setHistCursor(scr->getHistLines()); // lookup in keyboard translation table ... int cmd; const char* txt; int len; if (keytrans->findEntry(ev->key(), encodeMode(MODE_NewLine , BITS_NewLine ) + // OLD, encodeMode(MODE_Ansi , BITS_Ansi ) + // OBSOLETE, encodeMode(MODE_AppCuKeys, BITS_AppCuKeys ) + // VT100 stuff encodeStat(ControlButton , BITS_Control ) + encodeStat(ShiftButton , BITS_Shift ) + 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_send : sendString( txt ); return; case CMD_prevSession : emit prevSession(); return; case CMD_nextSession : emit nextSession(); return; } } // fall back handling if (!ev->text().isEmpty()) { if (ev->state() & AltButton) sendString("\033"); // ESC, this is the ALT prefix /// very hacky if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='A')) sendString("\01"); else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='B')) sendString("\02"); else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='C')) sendString("\03"); else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='D')) sendString("\04"); else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='E')) sendString("\05"); else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='F')) sendString("\06"); else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='G')) sendString("\07"); else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='H')) sendString("\010"); else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='I')) sendString("\011"); else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='J')) sendString("\012"); else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='K')) sendString("\013"); else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='L')) sendString("\014"); else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='M')) sendString("\015"); else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='N')) sendString("\016"); else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='O')) sendString("\017"); else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='P')) sendString("\020"); else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='Q')) sendString("\021"); else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='R')) sendString("\022"); else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='S')) sendString("\023"); else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='T')) sendString("\024"); else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='U')) sendString("\025"); else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='V')) sendString("\026"); else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='W')) sendString("\027"); else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='X')) sendString("\030"); else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='Y')) sendString("\031"); else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='Z')) sendString("\032"); else { QCString s = codec->fromUnicode(ev->text()); // encode for application sendString( s ); // we may well have s.length() > 1 } return; } } /* ------------------------------------------------------------------------- */ /* */ /* VT100 Charsets */ /* */ /* ------------------------------------------------------------------------- */ // Character Set Conversion ------------------------------------------------ -- /* The processing contains a VT100 specific code translation layer. It's still in use and mainly responsible for the line drawing graphics. These and some other glyphs are assigned to codes (0x5f-0xfe) normally occupied by the latin letters. Since this codes also appear within control sequences, the extra code conversion does not permute with the tokenizer and is placed behind it in the pipeline. It only applies to tokens, which represent plain characters. This conversion it eventually continued in TEWidget.C, since it might involve VT100 enhanced fonts, which have these particular glyphs allocated in (0x00-0x1f) in their code page. */ #define CHARSET charset[scr==screen[1]] // Apply current character map. unsigned short Vt102Emulation::applyCharset(unsigned short c) { if (CHARSET.graphic && 0x5f <= c && c <= 0x7e) return vt100_graphics[c-0x5f]; if (CHARSET.pound && c == '#' ) return 0xa3; //This mode is obsolete return c; } /* "Charset" related part of the emulation state. This configures the VT100 charset filter. While most operation work on the current screen, the following two are different. */ void Vt102Emulation::resetCharset(int scrno) { charset[scrno].cu_cs = 0; strncpy(charset[scrno].charset,"BBBB",4); charset[scrno].sa_graphic = FALSE; charset[scrno].sa_pound = FALSE; charset[scrno].graphic = FALSE; charset[scrno].pound = FALSE; } /*! */ void Vt102Emulation::setCharset(int n, int cs) // on both screens. { charset[0].charset[n&3] = cs; useCharset(charset[0].cu_cs); charset[1].charset[n&3] = cs; useCharset(charset[1].cu_cs); } /*! */ void Vt102Emulation::setAndUseCharset(int n, int cs) { CHARSET.charset[n&3] = cs; useCharset(n&3); } /*! */ void Vt102Emulation::useCharset(int n) { CHARSET.cu_cs = n&3; CHARSET.graphic = (CHARSET.charset[n&3] == '0'); CHARSET.pound = (CHARSET.charset[n&3] == 'A'); //This mode is obsolete } /*! Save the cursor position and the rendition attribute settings. */ void Vt102Emulation::saveCursor() { CHARSET.sa_graphic = CHARSET.graphic; CHARSET.sa_pound = CHARSET.pound; //This mode is obsolete // we are not clear about these //sa_charset = charsets[cScreen->charset]; //sa_charset_num = cScreen->charset; scr->saveCursor(); } /*! Restore the cursor position and the rendition attribute settings. */ void Vt102Emulation::restoreCursor() { CHARSET.graphic = CHARSET.sa_graphic; CHARSET.pound = CHARSET.sa_pound; //This mode is obsolete scr->restoreCursor(); } /* ------------------------------------------------------------------------- */ /* */ /* Mode Operations */ /* */ /* ------------------------------------------------------------------------- */ /* Some of the emulations state is either added to the state of the screens. This causes some scoping problems, since different emulations choose to located the mode either to the current screen or to both. For strange reasons, the extend of the rendition attributes ranges over all screens and not over the actual screen. We decided on the precise precise extend, somehow. */ // "Mode" related part of the state. These are all booleans. void Vt102Emulation::resetModes() { resetMode(MODE_Mouse1000); saveMode(MODE_Mouse1000); resetMode(MODE_AppScreen); saveMode(MODE_AppScreen); // here come obsolete modes resetMode(MODE_AppCuKeys); saveMode(MODE_AppCuKeys); resetMode(MODE_NewLine ); setMode(MODE_Ansi ); } void Vt102Emulation::setMode(int m) { currParm.mode[m] = TRUE; switch (m) { case MODE_Mouse1000 : gui->setMouseMarks(FALSE); break; case MODE_AppScreen : screen[1]->clearSelection(); screen[1]->clearEntireScreen(); setScreen(1); break; } if (m < MODES_SCREEN || m == MODE_NewLine) { screen[0]->setMode(m); screen[1]->setMode(m); } } void Vt102Emulation::resetMode(int m) { currParm.mode[m] = FALSE; switch (m) { case MODE_Mouse1000 : gui->setMouseMarks(TRUE); break; case MODE_AppScreen : screen[0]->clearSelection(); setScreen(0); break; } if (m < MODES_SCREEN || m == MODE_NewLine) { screen[0]->resetMode(m); screen[1]->resetMode(m); } } void Vt102Emulation::saveMode(int m) { saveParm.mode[m] = currParm.mode[m]; } void Vt102Emulation::restoreMode(int m) { if(saveParm.mode[m]) setMode(m); else resetMode(m); } BOOL Vt102Emulation::getMode(int m) { return currParm.mode[m]; } void Vt102Emulation::setConnect(bool c) { EmulationLayer::setConnect(c); if (c) { // refresh mouse mode if (getMode(MODE_Mouse1000)) setMode(MODE_Mouse1000); else resetMode(MODE_Mouse1000); } } /* ------------------------------------------------------------------------- */ /* */ /* Diagnostic */ /* */ /* ------------------------------------------------------------------------- */ /*! shows the contents of the scan buffer. This functions is used for diagnostics. It is called by \e ReportErrorToken to inform about strings that cannot be decoded or handled by the emulation. \sa ReportErrorToken */ /*! */ static void hexdump(int* s, int len) { int i; for (i = 0; i < len; i++) { if (s[i] == '\\') printf("\\\\"); else diff --git a/noncore/apps/opie-console/vt102emulation.h b/noncore/apps/opie-console/vt102emulation.h index 018835e..a3d0ae6 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 "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(Widget* 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); + 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 |