summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/PLANS12
-rw-r--r--noncore/apps/opie-console/default.cpp7
-rw-r--r--noncore/apps/opie-console/default.h4
-rw-r--r--noncore/apps/opie-console/emulation_layer.h2
-rw-r--r--noncore/apps/opie-console/keytrans.cpp3
-rw-r--r--noncore/apps/opie-console/mainwindow.cpp48
-rw-r--r--noncore/apps/opie-console/mainwindow.h4
-rw-r--r--noncore/apps/opie-console/metafactory.cpp25
-rw-r--r--noncore/apps/opie-console/metafactory.h21
-rw-r--r--noncore/apps/opie-console/profilemanager.cpp44
-rw-r--r--noncore/apps/opie-console/profilemanager.h2
-rw-r--r--noncore/apps/opie-console/session.cpp49
-rw-r--r--noncore/apps/opie-console/session.h38
-rw-r--r--noncore/apps/opie-console/tabwidget.cpp21
-rw-r--r--noncore/apps/opie-console/tabwidget.h5
-rw-r--r--noncore/apps/opie-console/vt102emulation.cpp2
-rw-r--r--noncore/apps/opie-console/vt102emulation.h2
17 files changed, 248 insertions, 41 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 @@
1can we please get a working serial connection for now? if that works 1can we please get a working serial connection for now? if that works
2i can test file transfers and stuff. -hash 2i can test file transfers and stuff. -hash
3sure. I finished the ConfigDialog and now doing the Profile->Session
4stuff. Then you just need to click Open -zecke
3 5
4From a UNIX point of view we want to do something like minicom 6From a UNIX point of view we want to do something like minicom
5with a better GUI. 7with a better GUI.
6It should feature some terminal emulation vt100/102, ansi, 8It should feature some terminal emulation vt100/102, ansi,
7filetransfer via {x,y,z}modem, and some sort of session management. 9filetransfer via {x,y,z}modem, and some sort of session management.
8Besides this requirement we would like to be able to execute 'scripts' 10Besides this requirement we would like to be able to execute 'scripts'
9in a session. 11in a session.
10A script would just write to the TEmulation and then be sent via 12A script would just write to the TEmulation and then be sent via
11an IOlayer. 13an IOlayer.
12Then we would like to send keys? Do we want that? 14Then we would like to send keys? Do we want that?
13 15
14We want a modular architecture which might support plugins in 16We want a modular architecture which might support plugins in
15the future 17the future
16 18
17(Almost) DONE: 19(Almost) DONE:
18Framework 20Framework
19Serial IOLayer 21Serial IOLayer
20Saving and Restoring Profiles 22Saving and Restoring Profiles
23ConfigDialog Framework
24FilesendingLayer - hash
21 25
22TASKS in progress: 26TASKS in progress:
23Profile->Session and MainWidget --- Harlekin 27Profile->Session and MainWidget --- Harlekin
24FilesendingLayer - hash
25IOLayer - wazlaf 28IOLayer - wazlaf
26Configuration - josef
27TE - ibotty 29TE - ibotty
28
29OPEN tasks:
30Session->Profile - hash 30Session->Profile - hash
31Scripting - wazlaf 31Scripting - wazlaf
32
33OPEN tasks:
34Irda ConfigWidget
35BT ConfigWidget
32Keys - open 36Keys - open
33IRDA-Layer - open 37IRDA-Layer - open
34Bluetooth-Layer - open 38Bluetooth-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 @@
1#include "io_serial.h" 1#include "io_serial.h"
2#include "sz_transfer.h" 2#include "sz_transfer.h"
3#include "serialconfigwidget.h" 3#include "serialconfigwidget.h"
4#include "terminalwidget.h" 4#include "terminalwidget.h"
5#include "vt102emulation.h"
5 6
6#include "default.h" 7#include "default.h"
7 8
8extern "C" { 9extern "C" {
9 // FILE Transfer Stuff 10 // FILE Transfer Stuff
10 FileTransferLayer* newSZTransfer(IOLayer* lay) { 11 FileTransferLayer* newSZTransfer(IOLayer* lay) {
11 return new SzTransfer( SzTransfer::SZ, lay ); 12 return new SzTransfer( SzTransfer::SZ, lay );
12 } 13 }
13 FileTransferLayer* newSYTransfer(IOLayer* lay) { 14 FileTransferLayer* newSYTransfer(IOLayer* lay) {
14 return new SzTransfer( SzTransfer::SY, lay ); 15 return new SzTransfer( SzTransfer::SY, lay );
15 } 16 }
16 FileTransferLayer* newSXTransfer(IOLayer* lay) { 17 FileTransferLayer* newSXTransfer(IOLayer* lay) {
17 return new SzTransfer( SzTransfer::SX, lay ); 18 return new SzTransfer( SzTransfer::SX, lay );
18 } 19 }
19 20
20 // Layer stuff 21 // Layer stuff
21 IOLayer* newSerialLayer( const Profile& prof) { 22 IOLayer* newSerialLayer( const Profile& prof) {
22 return new IOSerial( prof ); 23 return new IOSerial( prof );
23 } 24 }
24 IOLayer* newBTLayer( const Profile& ) { 25 IOLayer* newBTLayer( const Profile& ) {
25 return 0l; 26 return 0l;
26 } 27 }
27 IOLayer* newIrDaLayer( const Profile& ) { 28 IOLayer* newIrDaLayer( const Profile& ) {
28 return 0l; 29 return 0l;
29 } 30 }
30 31
31 // Connection Widgets 32 // Connection Widgets
32 ProfileDialogWidget* newSerialWidget(const QString& str, QWidget* wid) { 33 ProfileDialogWidget* newSerialWidget(const QString& str, QWidget* wid) {
33 return new SerialConfigWidget(str, wid ); 34 return new SerialConfigWidget(str, wid );
34 } 35 }
35 ProfileDialogWidget* newIrDaWidget( const QString& str, QWidget* wid) { 36 ProfileDialogWidget* newIrDaWidget( const QString& str, QWidget* wid) {
36 return newSerialWidget(str, wid); 37 return newSerialWidget(str, wid);
37 } 38 }
38 ProfileDialogWidget* newBTWidget( const QString& str, QWidget* wid) { 39 ProfileDialogWidget* newBTWidget( const QString& str, QWidget* wid) {
39 return newSerialWidget(str, wid ); 40 return newSerialWidget(str, wid );
40 } 41 }
41 42
42 // Terminal Widget(s) 43 // Terminal Widget(s)
43 ProfileDialogWidget* newTerminalWidget(const QString& na, QWidget* wid) { 44 ProfileDialogWidget* newTerminalWidget(const QString& na, QWidget* wid) {
44 return new TerminalWidget(na, wid,0 ); 45 return new TerminalWidget(na, wid,0 );
45 } 46 }
46 47
48 // VT Emulations
49 EmulationLayer* newVT102( Widget* wid ) {
50 return new Vt102Emulation( wid );
51 }
52
47}; 53};
48 54
49Default::Default( MetaFactory* fact ) { 55Default::Default( MetaFactory* fact ) {
50 fact->addFileTransferLayer( "SZ", QObject::tr("Z-Modem"), newSZTransfer ); 56 fact->addFileTransferLayer( "SZ", QObject::tr("Z-Modem"), newSZTransfer );
51 fact->addFileTransferLayer( "SY", QObject::tr("Y-Modem"), newSYTransfer ); 57 fact->addFileTransferLayer( "SY", QObject::tr("Y-Modem"), newSYTransfer );
52 fact->addFileTransferLayer( "SX", QObject::tr("X-Modem"), newSXTransfer ); 58 fact->addFileTransferLayer( "SX", QObject::tr("X-Modem"), newSXTransfer );
53 59
54 fact->addIOLayerFactory( "serial", QObject::tr("Serial"), newSerialLayer ); 60 fact->addIOLayerFactory( "serial", QObject::tr("Serial"), newSerialLayer );
55 fact->addIOLayerFactory( "irda", QObject::tr("Infrared"), newIrDaLayer ); 61 fact->addIOLayerFactory( "irda", QObject::tr("Infrared"), newIrDaLayer );
56 fact->addIOLayerFactory( "bt", QObject::tr("Bluetooth"), newBTLayer ); 62 fact->addIOLayerFactory( "bt", QObject::tr("Bluetooth"), newBTLayer );
57 63
58 fact->addConnectionWidgetFactory( "serial", QObject::tr("Serial"), newSerialWidget ); 64 fact->addConnectionWidgetFactory( "serial", QObject::tr("Serial"), newSerialWidget );
59 fact->addConnectionWidgetFactory( "irda", QObject::tr("Infrared"), newIrDaWidget ); 65 fact->addConnectionWidgetFactory( "irda", QObject::tr("Infrared"), newIrDaWidget );
60 fact->addConnectionWidgetFactory( "bt", QObject::tr("Bluetooth"), newBTWidget ); 66 fact->addConnectionWidgetFactory( "bt", QObject::tr("Bluetooth"), newBTWidget );
61 67
62 fact->addTerminalWidgetFactory( "default", QObject::tr("Default Terminal"), newTerminalWidget ); 68 fact->addTerminalWidgetFactory( "default", QObject::tr("Default Terminal"), newTerminalWidget );
63 69
70 fact->addEmulationLayer( "default", QObject::tr("Default Terminal"), newVT102 );
64} 71}
65Default::~Default() { 72Default::~Default() {
66 73
67} 74}
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 @@
1#ifndef OPIE_DEFAULT_H 1#ifndef OPIE_DEFAULT_H
2#define OPIE_DEFAULT_H 2#define OPIE_DEFAULT_H
3 3
4#include "metafactory.h" 4#include "metafactory.h"
5 5
6class Widget;
7
6extern "C" { 8extern "C" {
7 FileTransferLayer* newSZTransfer(IOLayer*); 9 FileTransferLayer* newSZTransfer(IOLayer*);
8 FileTransferLayer* newSYTransfer(IOLayer*); 10 FileTransferLayer* newSYTransfer(IOLayer*);
9 FileTransferLayer* newSXTransfer(IOLayer*); 11 FileTransferLayer* newSXTransfer(IOLayer*);
10 12
11 IOLayer* newSerialLayer(const Profile&); 13 IOLayer* newSerialLayer(const Profile&);
12 IOLayer* newBTLayer(const Profile& ); 14 IOLayer* newBTLayer(const Profile& );
13 IOLayer* newIrDaLayer(const Profile& ); 15 IOLayer* newIrDaLayer(const Profile& );
14 16
15 ProfileDialogWidget* newSerialWidget(const QString&, QWidget* ); 17 ProfileDialogWidget* newSerialWidget(const QString&, QWidget* );
16 ProfileDialogWidget* newIrDaWidget (const QString&, QWidget* ); 18 ProfileDialogWidget* newIrDaWidget (const QString&, QWidget* );
17 ProfileDialogWidget* newBTWidget (const QString&, QWidget* ); 19 ProfileDialogWidget* newBTWidget (const QString&, QWidget* );
18 20
19 ProfileDialogWidget* newTerminalWidget(const QString&, QWidget* ); 21 ProfileDialogWidget* newTerminalWidget(const QString&, QWidget* );
22
23 EmulationLayer* newVT102( Widget* );
20}; 24};
21 25
22class MetaFactory; 26class MetaFactory;
23struct Default { 27struct Default {
24public: 28public:
25 Default(MetaFactory* ); 29 Default(MetaFactory* );
26 ~Default(); 30 ~Default();
27}; 31};
28 32
29 33
30#endif 34#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 @@
1/* -------------------------------------------------------------------------- */ 1/* -------------------------------------------------------------------------- */
2/* */ 2/* */
3/* [emulation.h] Fundamental Terminal Emulation */ 3/* [emulation.h] Fundamental Terminal Emulation */
4/* */ 4/* */
5/* -------------------------------------------------------------------------- */ 5/* -------------------------------------------------------------------------- */
6/* */ 6/* */
7/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ 7/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */
8/* */ 8/* */
9/* This file is part of Konsole - an X terminal for KDE */ 9/* This file is part of Konsole - an X terminal for KDE */
10/* */ 10/* */
11/* -------------------------------------------------------------------------- */ 11/* -------------------------------------------------------------------------- */
12 /* */ 12 /* */
13/* Ported Konsole to Qt/Embedded */ 13/* Ported Konsole to Qt/Embedded */
14 /* */ 14 /* */
15/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ 15/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */
16 /* */ 16 /* */
17/* -------------------------------------------------------------------------- */ 17/* -------------------------------------------------------------------------- */
18/* -------------------------------------------------------------------------- */ 18/* -------------------------------------------------------------------------- */
19 /* */ 19 /* */
20/* made to a layer between io_layer and widget */ 20/* made to a layer between io_layer and widget */
21 /* */ 21 /* */
22/* Copyright (C) 2002 by opie developers <opie@handhelds.org> */ 22/* Copyright (C) 2002 by opie developers <opie@handhelds.org> */
23 /* */ 23 /* */
24/* -------------------------------------------------------------------------- */ 24/* -------------------------------------------------------------------------- */
25 25
26#ifndef EMULATION_LAYER_H 26#ifndef EMULATION_LAYER_H
27#define EMULATION_LAYER_H 27#define EMULATION_LAYER_H
28 28
29#include "widget.h" 29#include "widget_layer.h"
30#include "screen.h" 30#include "screen.h"
31#include <qtimer.h> 31#include <qtimer.h>
32#include <stdio.h> 32#include <stdio.h>
33#include <qtextcodec.h> 33#include <qtextcodec.h>
34#include "keytrans.h" 34#include "keytrans.h"
35 35
36class EmulationLayer : public QObject 36class EmulationLayer : public QObject
37{ Q_OBJECT 37{ Q_OBJECT
38 38
39public: 39public:
40 40
41 EmulationLayer(Widget* gui); 41 EmulationLayer(Widget* gui);
42 ~EmulationLayer(); 42 ~EmulationLayer();
43 43
44public: 44public:
45 virtual void setHistory(bool on); 45 virtual void setHistory(bool on);
46 virtual bool history(); 46 virtual bool history();
47 47
48public slots: // signals incoming from Widget 48public slots: // signals incoming from Widget
49 49
50 virtual void onImageSizeChange(int lines, int columns); 50 virtual void onImageSizeChange(int lines, int columns);
51 virtual void onHistoryCursorChange(int cursor); 51 virtual void onHistoryCursorChange(int cursor);
52 virtual void onKeyPress(QKeyEvent*); 52 virtual void onKeyPress(QKeyEvent*);
53 53
54 virtual void clearSelection(); 54 virtual void clearSelection();
55 virtual void onSelectionBegin(const int x, const int y); 55 virtual void onSelectionBegin(const int x, const int y);
56 virtual void onSelectionExtend(const int x, const int y); 56 virtual void onSelectionExtend(const int x, const int y);
57 virtual void setSelection(const BOOL preserve_line_breaks); 57 virtual void setSelection(const BOOL preserve_line_breaks);
58 58
59public slots: // signals incoming from data source 59public slots: // signals incoming from data source
60 60
61 /** 61 /**
62 * to be called, when new data arrives 62 * to be called, when new data arrives
63 */ 63 */
64 void onRcvBlock(const QByteArray&); 64 void onRcvBlock(const QByteArray&);
65 65
66signals: 66signals:
67 67
68 /** 68 /**
69 * will send data, encoded to suit emulation 69 * will send data, encoded to suit emulation
70 */ 70 */
71 void sndBlock(const QByteArray&); 71 void sndBlock(const QByteArray&);
72 72
73 void ImageSizeChanged(int lines, int columns); 73 void ImageSizeChanged(int lines, int columns);
74 74
75 void changeColumns(int columns); 75 void changeColumns(int columns);
76 76
77 void changeTitle(int arg, const char* str); 77 void changeTitle(int arg, const char* str);
78 78
79 79
80public: 80public:
81 81
82 /** 82 /**
83 * process single char (decode) 83 * process single char (decode)
84 */ 84 */
85 virtual void onRcvChar(int); 85 virtual void onRcvChar(int);
86 86
87 virtual void setMode (int) = 0; 87 virtual void setMode (int) = 0;
88 virtual void resetMode(int) = 0; 88 virtual void resetMode(int) = 0;
89 89
90 /** 90 /**
91 * @deprecated use qbytearray instead 91 * @deprecated use qbytearray instead
92 */ 92 */
93 virtual void sendString(const char*) = 0; 93 virtual void sendString(const char*) = 0;
94 94
95 /** 95 /**
96 * sends a string to IOLayer 96 * sends a string to IOLayer
97 * encodes to suit emulation before 97 * encodes to suit emulation before
98 */ 98 */
99 virtual void sendString(const QByteArray&) = 0; 99 virtual void sendString(const QByteArray&) = 0;
100 100
101 virtual void setConnect(bool r); 101 virtual void setConnect(bool r);
102 void setColumns(int columns); 102 void setColumns(int columns);
103 103
104 void setKeytrans(int no); 104 void setKeytrans(int no);
105 void setKeytrans(const char * no); 105 void setKeytrans(const char * no);
106 106
107protected: 107protected:
108 108
109 Widget* gui; 109 Widget* gui;
110 Screen* scr; // referes to one `screen' 110 Screen* scr; // referes to one `screen'
111 Screen* screen[2]; // 0 = primary, 1 = alternate 111 Screen* screen[2]; // 0 = primary, 1 = alternate
112 void setScreen(int n); // set `scr' to `screen[n]' 112 void setScreen(int n); // set `scr' to `screen[n]'
113 113
114 bool connected; // communicate with widget 114 bool connected; // communicate with widget
115 115
116 void setCodec(int c); // codec number, 0 = locale, 1=utf8 116 void setCodec(int c); // codec number, 0 = locale, 1=utf8
117 117
118 QTextCodec* codec; 118 QTextCodec* codec;
119 QTextCodec* localeCodec; 119 QTextCodec* localeCodec;
120 QTextDecoder* decoder; 120 QTextDecoder* decoder;
121 121
122 KeyTrans* keytrans; 122 KeyTrans* keytrans;
123 123
124// refreshing related material. 124// refreshing related material.
125// this is localized in the class. 125// this is localized in the class.
126private slots: // triggered by timer 126private slots: // triggered by timer
127 127
128 void showBulk(); 128 void showBulk();
129 129
130private: 130private:
131 131
132 void bulkNewline(); 132 void bulkNewline();
133 void bulkStart(); 133 void bulkStart();
134 void bulkEnd(); 134 void bulkEnd();
135 135
136private: 136private:
137 137
138 QTimer bulk_timer; 138 QTimer bulk_timer;
139 int bulk_nlcnt; // bulk newline counter 139 int bulk_nlcnt; // bulk newline counter
140 char* SelectedText; 140 char* SelectedText;
141 int bulk_incnt; // bulk counter 141 int bulk_incnt; // bulk counter
142 142
143 143
144}; 144};
145 145
146#endif // ifndef EMULATION_H 146#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
@@ -1,706 +1,709 @@
1/* -------------------------------------------------------------------------- */ 1/* -------------------------------------------------------------------------- */
2/* */ 2/* */
3/* [keytrans.C] Keyboard Translation */ 3/* [keytrans.C] Keyboard Translation */
4/* */ 4/* */
5/* -------------------------------------------------------------------------- */ 5/* -------------------------------------------------------------------------- */
6/* */ 6/* */
7/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ 7/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */
8/* */ 8/* */
9/* This file is part of Konsole - an X terminal for KDE */ 9/* This file is part of Konsole - an X terminal for KDE */
10/* */ 10/* */
11/* -------------------------------------------------------------------------- */ 11/* -------------------------------------------------------------------------- */
12 /* */ 12 /* */
13/* Ported Konsole to Qt/Embedded */ 13/* Ported Konsole to Qt/Embedded */
14 /* */ 14 /* */
15/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ 15/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */
16 /* */ 16 /* */
17/* -------------------------------------------------------------------------- */ 17/* -------------------------------------------------------------------------- */
18 18
19/* 19/*
20 The keyboard translation table allows to configure konsoles behavior 20 The keyboard translation table allows to configure konsoles behavior
21 on key strokes. 21 on key strokes.
22 22
23 FIXME: some bug crept in, disallowing '\0' to be emitted. 23 FIXME: some bug crept in, disallowing '\0' to be emitted.
24*/ 24*/
25 25
26#include "keytrans.h" 26#include "keytrans.h"
27 27
28#include <qpe/qpeapplication.h> 28#include <qpe/qpeapplication.h>
29 29
30#include <qnamespace.h> 30#include <qnamespace.h>
31#include <qbuffer.h> 31#include <qbuffer.h>
32#include <qobject.h> 32#include <qobject.h>
33#include <qdict.h> 33#include <qdict.h>
34#include <qintdict.h> 34#include <qintdict.h>
35#include <qfile.h> 35#include <qfile.h>
36#include <qglobal.h> 36#include <qglobal.h>
37#include <qdir.h> 37#include <qdir.h>
38 38
39//#include <kstddirs.h> 39//#include <kstddirs.h>
40//nclude <klocale.h> 40//nclude <klocale.h>
41 41
42#include <stdio.h> 42#include <stdio.h>
43 43
44 44
45#undef USE_APPDATA_DIR 45#undef USE_APPDATA_DIR
46 46
47 47
48#define HERE printf("%s(%d): here\n",__FILE__,__LINE__) 48#define HERE printf("%s(%d): here\n",__FILE__,__LINE__)
49 49
50/* KeyEntry 50/* KeyEntry
51 51
52 instances represent the individual assignments 52 instances represent the individual assignments
53*/ 53*/
54 54
55KeyTrans::KeyEntry::KeyEntry(int _ref, int _key, int _bits, int _mask, int _cmd, QString _txt) 55KeyTrans::KeyEntry::KeyEntry(int _ref, int _key, int _bits, int _mask, int _cmd, QString _txt)
56: ref(_ref), key(_key), bits(_bits), mask(_mask), cmd(_cmd), txt(_txt) 56: ref(_ref), key(_key), bits(_bits), mask(_mask), cmd(_cmd), txt(_txt)
57{ 57{
58} 58}
59 59
60KeyTrans::KeyEntry::~KeyEntry() 60KeyTrans::KeyEntry::~KeyEntry()
61{ 61{
62} 62}
63 63
64bool KeyTrans::KeyEntry::matches(int _key, int _bits, int _mask) 64bool KeyTrans::KeyEntry::matches(int _key, int _bits, int _mask)
65{ int m = mask & _mask; 65{ int m = mask & _mask;
66 return _key == key && (bits & m) == (_bits & m); 66 return _key == key && (bits & m) == (_bits & m);
67} 67}
68 68
69QString KeyTrans::KeyEntry::text() 69QString KeyTrans::KeyEntry::text()
70{ 70{
71 return txt; 71 return txt;
72} 72}
73 73
74/* KeyTrans 74/* KeyTrans
75 75
76 combines the individual assignments to a proper map 76 combines the individual assignments to a proper map
77 Takes part in a collection themself. 77 Takes part in a collection themself.
78*/ 78*/
79 79
80KeyTrans::KeyTrans() 80KeyTrans::KeyTrans()
81{ 81{
82 path = ""; 82 path = "";
83 numb = 0; 83 numb = 0;
84} 84}
85 85
86KeyTrans::~KeyTrans() 86KeyTrans::~KeyTrans()
87{ 87{
88} 88}
89 89
90KeyTrans::KeyEntry* KeyTrans::addEntry(int ref, int key, int bits, int mask, int cmd, QString txt) 90KeyTrans::KeyEntry* KeyTrans::addEntry(int ref, int key, int bits, int mask, int cmd, QString txt)
91// returns conflicting entry 91// returns conflicting entry
92{ 92{
93 for (QListIterator<KeyEntry> it(table); it.current(); ++it) 93 for (QListIterator<KeyEntry> it(table); it.current(); ++it)
94 { 94 {
95 if (it.current()->matches(key,bits,mask)) 95 if (it.current()->matches(key,bits,mask))
96 { 96 {
97 return it.current(); 97 return it.current();
98 } 98 }
99 } 99 }
100 table.append(new KeyEntry(ref,key,bits,mask,cmd,txt)); 100 table.append(new KeyEntry(ref,key,bits,mask,cmd,txt));
101 return (KeyEntry*)NULL; 101 return (KeyEntry*)NULL;
102} 102}
103 103
104bool KeyTrans::findEntry(int key, int bits, int* cmd, const char** txt, int* len) 104bool KeyTrans::findEntry(int key, int bits, int* cmd, const char** txt, int* len)
105{ 105{
106 for (QListIterator<KeyEntry> it(table); it.current(); ++it) 106 for (QListIterator<KeyEntry> it(table); it.current(); ++it)
107 if (it.current()->matches(key,bits,0xffff)) 107 if (it.current()->matches(key,bits,0xffff))
108 { 108 {
109 *cmd = it.current()->cmd; 109 *cmd = it.current()->cmd;
110 *txt = it.current()->txt.ascii(); 110 *txt = it.current()->txt.ascii();
111 *len = it.current()->txt.length(); 111 *len = it.current()->txt.length();
112 return TRUE; 112 return TRUE;
113 } 113 }
114 return FALSE; 114 return FALSE;
115} 115}
116 116
117/* ------------------------------------------------------------------------- */ 117/* ------------------------------------------------------------------------- */
118/* */ 118/* */
119/* Scanner for keyboard configuration */ 119/* Scanner for keyboard configuration */
120/* */ 120/* */
121/* ------------------------------------------------------------------------- */ 121/* ------------------------------------------------------------------------- */
122 122
123// regular tokenizer 123// regular tokenizer
124/* Tokens 124/* Tokens
125 - Spaces 125 - Spaces
126 - Name (A-Za-z0-9)+ 126 - Name (A-Za-z0-9)+
127 - String 127 - String
128 - Opr on of +-: 128 - Opr on of +-:
129*/ 129*/
130 130
131#define SYMName 0 131#define SYMName 0
132#define SYMString 1 132#define SYMString 1
133#define SYMEol 2 133#define SYMEol 2
134#define SYMEof 3 134#define SYMEof 3
135#define SYMOpr 4 135#define SYMOpr 4
136#define SYMError 5 136#define SYMError 5
137 137
138#define inRange(L,X,H) ((L <= X) && (X <= H)) 138#define inRange(L,X,H) ((L <= X) && (X <= H))
139#define isNibble(X) (inRange('A',X,'F')||inRange('a',X,'f')||inRange('0',X,'9')) 139#define isNibble(X) (inRange('A',X,'F')||inRange('a',X,'f')||inRange('0',X,'9'))
140#define convNibble(X) (inRange('0',X,'9')?X-'0':X+10-(inRange('A',X,'F')?'A':'a')) 140#define convNibble(X) (inRange('0',X,'9')?X-'0':X+10-(inRange('A',X,'F')?'A':'a'))
141 141
142class KeytabReader 142class KeytabReader
143{ 143{
144public: 144public:
145 KeytabReader(QString p, QIODevice &d); 145 KeytabReader(QString p, QIODevice &d);
146public: 146public:
147 void getCc(); 147 void getCc();
148 void getSymbol(); 148 void getSymbol();
149 void parseTo(KeyTrans* kt); 149 void parseTo(KeyTrans* kt);
150 void ReportError(const char* msg); 150 void ReportError(const char* msg);
151 void ReportToken(); // diagnostic 151 void ReportToken(); // diagnostic
152private: 152private:
153 int sym; 153 int sym;
154 QString res; 154 QString res;
155 int len; 155 int len;
156 int slinno; 156 int slinno;
157 int scolno; 157 int scolno;
158private: 158private:
159 int cc; 159 int cc;
160 int linno; 160 int linno;
161 int colno; 161 int colno;
162 QIODevice* buf; 162 QIODevice* buf;
163 QString path; 163 QString path;
164}; 164};
165 165
166 166
167KeytabReader::KeytabReader(QString p, QIODevice &d) 167KeytabReader::KeytabReader(QString p, QIODevice &d)
168{ 168{
169 path = p; 169 path = p;
170 buf = &d; 170 buf = &d;
171 cc = 0; 171 cc = 0;
172} 172}
173 173
174void KeytabReader::getCc() 174void KeytabReader::getCc()
175{ 175{
176 if (cc == '\n') { linno += 1; colno = 0; } 176 if (cc == '\n') { linno += 1; colno = 0; }
177 if (cc < 0) return; 177 if (cc < 0) return;
178 cc = buf->getch(); 178 cc = buf->getch();
179 colno += 1; 179 colno += 1;
180} 180}
181 181
182void KeytabReader::getSymbol() 182void KeytabReader::getSymbol()
183{ 183{
184 res = ""; len = 0; sym = SYMError; 184 res = ""; len = 0; sym = SYMError;
185 while (cc == ' ') getCc(); // skip spaces 185 while (cc == ' ') getCc(); // skip spaces
186 if (cc == '#') // skip comment 186 if (cc == '#') // skip comment
187 { 187 {
188 while (cc != '\n' && cc > 0) getCc(); 188 while (cc != '\n' && cc > 0) getCc();
189 } 189 }
190 slinno = linno; 190 slinno = linno;
191 scolno = colno; 191 scolno = colno;
192 if (cc <= 0) 192 if (cc <= 0)
193 { 193 {
194 sym = SYMEof; return; // eos 194 sym = SYMEof; return; // eos
195 } 195 }
196 if (cc == '\n') 196 if (cc == '\n')
197 { 197 {
198 getCc(); 198 getCc();
199 sym = SYMEol; return; // eol 199 sym = SYMEol; return; // eol
200 } 200 }
201 if (inRange('A',cc,'Z')||inRange('a',cc,'z')||inRange('0',cc,'9')) 201 if (inRange('A',cc,'Z')||inRange('a',cc,'z')||inRange('0',cc,'9'))
202 { 202 {
203 while (inRange('A',cc,'Z') || inRange('a',cc,'z') || inRange('0',cc,'9')) 203 while (inRange('A',cc,'Z') || inRange('a',cc,'z') || inRange('0',cc,'9'))
204 { 204 {
205 res = res + (char)cc; 205 res = res + (char)cc;
206 getCc(); 206 getCc();
207 } 207 }
208 sym = SYMName; 208 sym = SYMName;
209 return; 209 return;
210 } 210 }
211 if (strchr("+-:",cc)) 211 if (strchr("+-:",cc))
212 { 212 {
213 res = ""; 213 res = "";
214 res = res + (char)cc; 214 res = res + (char)cc;
215 getCc(); 215 getCc();
216 sym = SYMOpr; return; 216 sym = SYMOpr; return;
217 } 217 }
218 if (cc == '"') 218 if (cc == '"')
219 { 219 {
220 getCc(); 220 getCc();
221 while (cc >= ' ' && cc != '"') 221 while (cc >= ' ' && cc != '"')
222 { int sc; 222 { int sc;
223 if (cc == '\\') // handle quotation 223 if (cc == '\\') // handle quotation
224 { 224 {
225 getCc(); 225 getCc();
226 switch (cc) 226 switch (cc)
227 { 227 {
228 case 'E' : sc = 27; getCc(); break; 228 case 'E' : sc = 27; getCc(); break;
229 case 'b' : sc = 8; getCc(); break; 229 case 'b' : sc = 8; getCc(); break;
230 case 'f' : sc = 12; getCc(); break; 230 case 'f' : sc = 12; getCc(); break;
231 case 't' : sc = 9; getCc(); break; 231 case 't' : sc = 9; getCc(); break;
232 case 'r' : sc = 13; getCc(); break; 232 case 'r' : sc = 13; getCc(); break;
233 case 'n' : sc = 10; getCc(); break; 233 case 'n' : sc = 10; getCc(); break;
234 case '\\' : // fall thru 234 case '\\' : // fall thru
235 case '"' : sc = cc; getCc(); break; 235 case '"' : sc = cc; getCc(); break;
236 case 'x' : getCc(); 236 case 'x' : getCc();
237 sc = 0; 237 sc = 0;
238 if (!isNibble(cc)) return; sc = 16*sc + convNibble(cc); getCc(); 238 if (!isNibble(cc)) return; sc = 16*sc + convNibble(cc); getCc();
239 if (!isNibble(cc)) return; sc = 16*sc + convNibble(cc); getCc(); 239 if (!isNibble(cc)) return; sc = 16*sc + convNibble(cc); getCc();
240 break; 240 break;
241 default : return; 241 default : return;
242 } 242 }
243 } 243 }
244 else 244 else
245 { 245 {
246 // regular char 246 // regular char
247 sc = cc; getCc(); 247 sc = cc; getCc();
248 } 248 }
249 res = res + (char)sc; 249 res = res + (char)sc;
250 len = len + 1; 250 len = len + 1;
251 } 251 }
252 if (cc != '"') return; 252 if (cc != '"') return;
253 getCc(); 253 getCc();
254 sym = SYMString; return; 254 sym = SYMString; return;
255 } 255 }
256} 256}
257 257
258void KeytabReader::ReportToken() // diagnostic 258void KeytabReader::ReportToken() // diagnostic
259{ 259{
260 printf("sym(%d): ",slinno); 260 printf("sym(%d): ",slinno);
261 switch(sym) 261 switch(sym)
262 { 262 {
263 case SYMEol : printf("End of line"); break; 263 case SYMEol : printf("End of line"); break;
264 case SYMEof : printf("End of file"); break; 264 case SYMEof : printf("End of file"); break;
265 case SYMName : printf("Name: %s",res.latin1()); break; 265 case SYMName : printf("Name: %s",res.latin1()); break;
266 case SYMOpr : printf("Opr : %s",res.latin1()); break; 266 case SYMOpr : printf("Opr : %s",res.latin1()); break;
267 case SYMString : printf("String len %d,%d ",res.length(),len); 267 case SYMString : printf("String len %d,%d ",res.length(),len);
268 for (unsigned i = 0; i < res.length(); i++) 268 for (unsigned i = 0; i < res.length(); i++)
269 printf(" %02x(%c)",res.latin1()[i],res.latin1()[i]>=' '?res.latin1()[i]:'?'); 269 printf(" %02x(%c)",res.latin1()[i],res.latin1()[i]>=' '?res.latin1()[i]:'?');
270 break; 270 break;
271 } 271 }
272 printf("\n"); 272 printf("\n");
273} 273}
274 274
275void KeytabReader::ReportError(const char* msg) // diagnostic 275void KeytabReader::ReportError(const char* msg) // diagnostic
276{ 276{
277 fprintf(stderr,"%s(%d,%d):error: %s.\n",path.ascii(),slinno,scolno,msg); 277 fprintf(stderr,"%s(%d,%d):error: %s.\n",path.ascii(),slinno,scolno,msg);
278} 278}
279 279
280// local symbol tables --------------------------------------------------------------------- 280// local symbol tables ---------------------------------------------------------------------
281 281
282class KeyTransSymbols 282class KeyTransSymbols
283{ 283{
284public: 284public:
285 KeyTransSymbols(); 285 KeyTransSymbols();
286protected: 286protected:
287 void defOprSyms(); 287 void defOprSyms();
288 void defModSyms(); 288 void defModSyms();
289 void defKeySyms(); 289 void defKeySyms();
290 void defKeySym(const char* key, int val); 290 void defKeySym(const char* key, int val);
291 void defOprSym(const char* key, int val); 291 void defOprSym(const char* key, int val);
292 void defModSym(const char* key, int val); 292 void defModSym(const char* key, int val);
293public: 293public:
294 QDict<QObject> keysyms; 294 QDict<QObject> keysyms;
295 QDict<QObject> modsyms; 295 QDict<QObject> modsyms;
296 QDict<QObject> oprsyms; 296 QDict<QObject> oprsyms;
297}; 297};
298 298
299static KeyTransSymbols * syms = 0L; 299static KeyTransSymbols * syms = 0L;
300 300
301// parser ---------------------------------------------------------------------------------- 301// parser ----------------------------------------------------------------------------------
302/* Syntax 302/* Syntax
303 - Line :: [KeyName { ("+" | "-") ModeName } ":" (String|CommandName)] "\n" 303 - Line :: [KeyName { ("+" | "-") ModeName } ":" (String|CommandName)] "\n"
304 - Comment :: '#' (any but \n)* 304 - Comment :: '#' (any but \n)*
305*/ 305*/
306 306
307KeyTrans* KeyTrans::fromDevice(QString path, QIODevice &buf) 307KeyTrans* KeyTrans::fromDevice(QString path, QIODevice &buf)
308{ 308{
309 KeyTrans* kt = new KeyTrans; 309 KeyTrans* kt = new KeyTrans;
310 kt->path = path; 310 kt->path = path;
311 KeytabReader ktr(path,buf); ktr.parseTo(kt); 311 KeytabReader ktr(path,buf); ktr.parseTo(kt);
312 return kt; 312 return kt;
313} 313}
314 314
315 315
316#define assertSyntax(Cond,Message) if (!(Cond)) { ReportError(Message); goto ERROR; } 316#define assertSyntax(Cond,Message) if (!(Cond)) { ReportError(Message); goto ERROR; }
317 317
318void KeytabReader::parseTo(KeyTrans* kt) 318void KeytabReader::parseTo(KeyTrans* kt)
319{ 319{
320 // Opening sequence 320 // Opening sequence
321 321
322 buf->open(IO_ReadOnly); 322 buf->open(IO_ReadOnly);
323 getCc(); 323 getCc();
324 linno = 1; 324 linno = 1;
325 colno = 1; 325 colno = 1;
326 getSymbol(); 326 getSymbol();
327 327
328Loop: 328Loop:
329 // syntax: ["key" KeyName { ("+" | "-") ModeName } ":" String/CommandName] ["#" Comment] 329 // syntax: ["key" KeyName { ("+" | "-") ModeName } ":" String/CommandName] ["#" Comment]
330 if (sym == SYMName && !strcmp(res.latin1(),"keyboard")) 330 if (sym == SYMName && !strcmp(res.latin1(),"keyboard"))
331 { 331 {
332 getSymbol(); assertSyntax(sym == SYMString, "Header expected") 332 getSymbol(); assertSyntax(sym == SYMString, "Header expected")
333 kt->hdr = res.latin1(); 333 kt->hdr = res.latin1();
334 getSymbol(); assertSyntax(sym == SYMEol, "Text unexpected") 334 getSymbol(); assertSyntax(sym == SYMEol, "Text unexpected")
335 getSymbol(); // eoln 335 getSymbol(); // eoln
336 goto Loop; 336 goto Loop;
337 } 337 }
338 if (sym == SYMName && !strcmp(res.latin1(),"key")) 338 if (sym == SYMName && !strcmp(res.latin1(),"key"))
339 { 339 {
340//printf("line %3d: ",startofsym); 340//printf("line %3d: ",startofsym);
341 getSymbol(); assertSyntax(sym == SYMName, "Name expected") 341 getSymbol(); assertSyntax(sym == SYMName, "Name expected")
342 assertSyntax(syms->keysyms[res], "Unknown key name") 342 assertSyntax(syms->keysyms[res], "Unknown key name")
343 int key = (int)syms->keysyms[res]-1; 343 int key = (int)syms->keysyms[res]-1;
344//printf(" key %s (%04x)",res.latin1(),(int)syms->keysyms[res]-1); 344//printf(" key %s (%04x)",res.latin1(),(int)syms->keysyms[res]-1);
345 getSymbol(); // + - : 345 getSymbol(); // + - :
346 int mode = 0; 346 int mode = 0;
347 int mask = 0; 347 int mask = 0;
348 while (sym == SYMOpr && (!strcmp(res.latin1(),"+") || !strcmp(res.latin1(),"-"))) 348 while (sym == SYMOpr && (!strcmp(res.latin1(),"+") || !strcmp(res.latin1(),"-")))
349 { 349 {
350 bool on = !strcmp(res.latin1(),"+"); 350 bool on = !strcmp(res.latin1(),"+");
351 getSymbol(); 351 getSymbol();
352 // mode name 352 // mode name
353 assertSyntax(sym == SYMName, "Name expected") 353 assertSyntax(sym == SYMName, "Name expected")
354 assertSyntax(syms->modsyms[res], "Unknown mode name") 354 assertSyntax(syms->modsyms[res], "Unknown mode name")
355 int bits = (int)syms->modsyms[res]-1; 355 int bits = (int)syms->modsyms[res]-1;
356 if (mask & (1 << bits)) 356 if (mask & (1 << bits))
357 { 357 {
358 fprintf(stderr,"%s(%d,%d): mode name used multible times.\n",path.ascii(),slinno,scolno); 358 fprintf(stderr,"%s(%d,%d): mode name used multible times.\n",path.ascii(),slinno,scolno);
359 } 359 }
360 else 360 else
361 { 361 {
362 mode |= (on << bits); 362 mode |= (on << bits);
363 mask |= (1 << bits); 363 mask |= (1 << bits);
364 } 364 }
365//printf(", mode %s(%d) %s",res.latin1(),(int)syms->modsyms[res]-1,on?"on":"off"); 365//printf(", mode %s(%d) %s",res.latin1(),(int)syms->modsyms[res]-1,on?"on":"off");
366 getSymbol(); 366 getSymbol();
367 } 367 }
368 assertSyntax(sym == SYMOpr && !strcmp(res.latin1(),":"), "':' expected") 368 assertSyntax(sym == SYMOpr && !strcmp(res.latin1(),":"), "':' expected")
369 getSymbol(); 369 getSymbol();
370 // string or command 370 // string or command
371 assertSyntax(sym == SYMName || sym == SYMString,"Command or string expected") 371 assertSyntax(sym == SYMName || sym == SYMString,"Command or string expected")
372 int cmd = 0; 372 int cmd = 0;
373 if (sym == SYMName) 373 if (sym == SYMName)
374 { 374 {
375 assertSyntax(syms->oprsyms[res], "Unknown operator name") 375 assertSyntax(syms->oprsyms[res], "Unknown operator name")
376 cmd = (int)syms->oprsyms[res]-1; 376 cmd = (int)syms->oprsyms[res]-1;
377//printf(": do %s(%d)",res.latin1(),(int)syms->oprsyms[res]-1); 377//printf(": do %s(%d)",res.latin1(),(int)syms->oprsyms[res]-1);
378 } 378 }
379 if (sym == SYMString) 379 if (sym == SYMString)
380 { 380 {
381 cmd = CMD_send; 381 cmd = CMD_send;
382//printf(": send"); 382//printf(": send");
383//for (unsigned i = 0; i < res.length(); i++) 383//for (unsigned i = 0; i < res.length(); i++)
384//printf(" %02x(%c)",res.latin1()[i],res.latin1()[i]>=' '?res.latin1()[i]:'?'); 384//printf(" %02x(%c)",res.latin1()[i],res.latin1()[i]>=' '?res.latin1()[i]:'?');
385 } 385 }
386//printf(". summary %04x,%02x,%02x,%d\n",key,mode,mask,cmd); 386//printf(". summary %04x,%02x,%02x,%d\n",key,mode,mask,cmd);
387 KeyTrans::KeyEntry* ke = kt->addEntry(slinno,key,mode,mask,cmd,res); 387 KeyTrans::KeyEntry* ke = kt->addEntry(slinno,key,mode,mask,cmd,res);
388 if (ke) 388 if (ke)
389 { 389 {
390 fprintf(stderr,"%s(%d): keystroke already assigned in line %d.\n",path.ascii(),slinno,ke->ref); 390 fprintf(stderr,"%s(%d): keystroke already assigned in line %d.\n",path.ascii(),slinno,ke->ref);
391 } 391 }
392 getSymbol(); 392 getSymbol();
393 assertSyntax(sym == SYMEol, "Unexpected text") 393 assertSyntax(sym == SYMEol, "Unexpected text")
394 goto Loop; 394 goto Loop;
395 } 395 }
396 if (sym == SYMEol) 396 if (sym == SYMEol)
397 { 397 {
398 getSymbol(); 398 getSymbol();
399 goto Loop; 399 goto Loop;
400 } 400 }
401 401
402 assertSyntax(sym == SYMEof, "Undecodable Line") 402 assertSyntax(sym == SYMEof, "Undecodable Line")
403 403
404 buf->close(); 404 buf->close();
405 return; 405 return;
406 406
407ERROR: 407ERROR:
408 while (sym != SYMEol && sym != SYMEof) getSymbol(); // eoln 408 while (sym != SYMEol && sym != SYMEof) getSymbol(); // eoln
409 goto Loop; 409 goto Loop;
410} 410}
411 411
412 412
413KeyTrans* KeyTrans::defaultKeyTrans() 413KeyTrans* KeyTrans::defaultKeyTrans()
414{ 414{
415 QCString txt = 415 QCString txt =
416#include "default.keytab.h" 416#include "default.keytab.h"
417 ; 417 ;
418 QBuffer buf(txt); 418 QBuffer buf(txt);
419 return fromDevice("[buildin]",buf); 419 return fromDevice("[buildin]",buf);
420} 420}
421 421
422KeyTrans* KeyTrans::fromFile(const char* path) 422KeyTrans* KeyTrans::fromFile(const char* path)
423{ 423{
424 QFile file(path); 424 QFile file(path);
425 return fromDevice(path,file); 425 return fromDevice(path,file);
426} 426}
427 427
428// local symbol tables --------------------------------------------------------------------- 428// local symbol tables ---------------------------------------------------------------------
429// material needed for parsing the config file. 429// material needed for parsing the config file.
430// This is incomplete work. 430// This is incomplete work.
431 431
432void KeyTransSymbols::defKeySym(const char* key, int val) 432void KeyTransSymbols::defKeySym(const char* key, int val)
433{ 433{
434 keysyms.insert(key,(QObject*)(val+1)); 434 keysyms.insert(key,(QObject*)(val+1));
435} 435}
436 436
437void KeyTransSymbols::defOprSym(const char* key, int val) 437void KeyTransSymbols::defOprSym(const char* key, int val)
438{ 438{
439 oprsyms.insert(key,(QObject*)(val+1)); 439 oprsyms.insert(key,(QObject*)(val+1));
440} 440}
441 441
442void KeyTransSymbols::defModSym(const char* key, int val) 442void KeyTransSymbols::defModSym(const char* key, int val)
443{ 443{
444 modsyms.insert(key,(QObject*)(val+1)); 444 modsyms.insert(key,(QObject*)(val+1));
445} 445}
446 446
447void KeyTransSymbols::defOprSyms() 447void KeyTransSymbols::defOprSyms()
448{ 448{
449 // Modifier 449 // Modifier
450 defOprSym("scrollLineUp", CMD_scrollLineUp ); 450 defOprSym("scrollLineUp", CMD_scrollLineUp );
451 defOprSym("scrollLineDown",CMD_scrollLineDown); 451 defOprSym("scrollLineDown",CMD_scrollLineDown);
452 defOprSym("scrollPageUp", CMD_scrollPageUp ); 452 defOprSym("scrollPageUp", CMD_scrollPageUp );
453 defOprSym("scrollPageDown",CMD_scrollPageDown); 453 defOprSym("scrollPageDown",CMD_scrollPageDown);
454 defOprSym("emitSelection", CMD_emitSelection ); 454 defOprSym("emitSelection", CMD_emitSelection );
455 defOprSym("prevSession", CMD_prevSession ); 455 defOprSym("prevSession", CMD_prevSession );
456 defOprSym("nextSession", CMD_nextSession ); 456 defOprSym("nextSession", CMD_nextSession );
457} 457}
458 458
459void KeyTransSymbols::defModSyms() 459void KeyTransSymbols::defModSyms()
460{ 460{
461 // Modifier 461 // Modifier
462 defModSym("Shift", BITS_Shift ); 462 defModSym("Shift", BITS_Shift );
463 defModSym("Control", BITS_Control ); 463 defModSym("Control", BITS_Control );
464 defModSym("Alt", BITS_Alt ); 464 defModSym("Alt", BITS_Alt );
465 // Modes 465 // Modes
466 defModSym("BsHack", BITS_BsHack ); // deprecated 466 defModSym("BsHack", BITS_BsHack ); // deprecated
467 defModSym("Ansi", BITS_Ansi ); 467 defModSym("Ansi", BITS_Ansi );
468 defModSym("NewLine", BITS_NewLine ); 468 defModSym("NewLine", BITS_NewLine );
469 defModSym("AppCuKeys", BITS_AppCuKeys ); 469 defModSym("AppCuKeys", BITS_AppCuKeys );
470} 470}
471 471
472void KeyTransSymbols::defKeySyms() 472void KeyTransSymbols::defKeySyms()
473{ 473{
474 // Grey keys 474 // Grey keys
475 defKeySym("Escape", Qt::Key_Escape ); 475 defKeySym("Escape", Qt::Key_Escape );
476 defKeySym("Tab", Qt::Key_Tab ); 476 defKeySym("Tab", Qt::Key_Tab );
477 defKeySym("Backtab", Qt::Key_Backtab ); 477 defKeySym("Backtab", Qt::Key_Backtab );
478 defKeySym("Backspace", Qt::Key_Backspace ); 478 defKeySym("Backspace", Qt::Key_Backspace );
479 defKeySym("Return", Qt::Key_Return ); 479 defKeySym("Return", Qt::Key_Return );
480 defKeySym("Enter", Qt::Key_Enter ); 480 defKeySym("Enter", Qt::Key_Enter );
481 defKeySym("Insert", Qt::Key_Insert ); 481 defKeySym("Insert", Qt::Key_Insert );
482 defKeySym("Delete", Qt::Key_Delete ); 482 defKeySym("Delete", Qt::Key_Delete );
483 defKeySym("Pause", Qt::Key_Pause ); 483 defKeySym("Pause", Qt::Key_Pause );
484 defKeySym("Print", Qt::Key_Print ); 484 defKeySym("Print", Qt::Key_Print );
485 defKeySym("SysReq", Qt::Key_SysReq ); 485 defKeySym("SysReq", Qt::Key_SysReq );
486 defKeySym("Home", Qt::Key_Home ); 486 defKeySym("Home", Qt::Key_Home );
487 defKeySym("End", Qt::Key_End ); 487 defKeySym("End", Qt::Key_End );
488 defKeySym("Left", Qt::Key_Left ); 488 defKeySym("Left", Qt::Key_Left );
489 defKeySym("Up", Qt::Key_Up ); 489 defKeySym("Up", Qt::Key_Up );
490 defKeySym("Right", Qt::Key_Right ); 490 defKeySym("Right", Qt::Key_Right );
491 defKeySym("Down", Qt::Key_Down ); 491 defKeySym("Down", Qt::Key_Down );
492 defKeySym("Prior", Qt::Key_Prior ); 492 defKeySym("Prior", Qt::Key_Prior );
493 defKeySym("Next", Qt::Key_Next ); 493 defKeySym("Next", Qt::Key_Next );
494 defKeySym("Shift", Qt::Key_Shift ); 494 defKeySym("Shift", Qt::Key_Shift );
495 defKeySym("Control", Qt::Key_Control ); 495 defKeySym("Control", Qt::Key_Control );
496 defKeySym("Meta", Qt::Key_Meta ); 496 defKeySym("Meta", Qt::Key_Meta );
497 defKeySym("Alt", Qt::Key_Alt ); 497 defKeySym("Alt", Qt::Key_Alt );
498 defKeySym("CapsLock", Qt::Key_CapsLock ); 498 defKeySym("CapsLock", Qt::Key_CapsLock );
499 defKeySym("NumLock", Qt::Key_NumLock ); 499 defKeySym("NumLock", Qt::Key_NumLock );
500 defKeySym("ScrollLock", Qt::Key_ScrollLock ); 500 defKeySym("ScrollLock", Qt::Key_ScrollLock );
501 defKeySym("F1", Qt::Key_F1 ); 501 defKeySym("F1", Qt::Key_F1 );
502 defKeySym("F2", Qt::Key_F2 ); 502 defKeySym("F2", Qt::Key_F2 );
503 defKeySym("F3", Qt::Key_F3 ); 503 defKeySym("F3", Qt::Key_F3 );
504 defKeySym("F4", Qt::Key_F4 ); 504 defKeySym("F4", Qt::Key_F4 );
505 defKeySym("F5", Qt::Key_F5 ); 505 defKeySym("F5", Qt::Key_F5 );
506 defKeySym("F6", Qt::Key_F6 ); 506 defKeySym("F6", Qt::Key_F6 );
507 defKeySym("F7", Qt::Key_F7 ); 507 defKeySym("F7", Qt::Key_F7 );
508 defKeySym("F8", Qt::Key_F8 ); 508 defKeySym("F8", Qt::Key_F8 );
509 defKeySym("F9", Qt::Key_F9 ); 509 defKeySym("F9", Qt::Key_F9 );
510 defKeySym("F10", Qt::Key_F10 ); 510 defKeySym("F10", Qt::Key_F10 );
511 defKeySym("F11", Qt::Key_F11 ); 511 defKeySym("F11", Qt::Key_F11 );
512 defKeySym("F12", Qt::Key_F12 ); 512 defKeySym("F12", Qt::Key_F12 );
513 defKeySym("F13", Qt::Key_F13 ); 513 defKeySym("F13", Qt::Key_F13 );
514 defKeySym("F14", Qt::Key_F14 ); 514 defKeySym("F14", Qt::Key_F14 );
515 defKeySym("F15", Qt::Key_F15 ); 515 defKeySym("F15", Qt::Key_F15 );
516 defKeySym("F16", Qt::Key_F16 ); 516 defKeySym("F16", Qt::Key_F16 );
517 defKeySym("F17", Qt::Key_F17 ); 517 defKeySym("F17", Qt::Key_F17 );
518 defKeySym("F18", Qt::Key_F18 ); 518 defKeySym("F18", Qt::Key_F18 );
519 defKeySym("F19", Qt::Key_F19 ); 519 defKeySym("F19", Qt::Key_F19 );
520 defKeySym("F20", Qt::Key_F20 ); 520 defKeySym("F20", Qt::Key_F20 );
521 defKeySym("F21", Qt::Key_F21 ); 521 defKeySym("F21", Qt::Key_F21 );
522 defKeySym("F22", Qt::Key_F22 ); 522 defKeySym("F22", Qt::Key_F22 );
523 defKeySym("F23", Qt::Key_F23 ); 523 defKeySym("F23", Qt::Key_F23 );
524 defKeySym("F24", Qt::Key_F24 ); 524 defKeySym("F24", Qt::Key_F24 );
525 defKeySym("F25", Qt::Key_F25 ); 525 defKeySym("F25", Qt::Key_F25 );
526 defKeySym("F26", Qt::Key_F26 ); 526 defKeySym("F26", Qt::Key_F26 );
527 defKeySym("F27", Qt::Key_F27 ); 527 defKeySym("F27", Qt::Key_F27 );
528 defKeySym("F28", Qt::Key_F28 ); 528 defKeySym("F28", Qt::Key_F28 );
529 defKeySym("F29", Qt::Key_F29 ); 529 defKeySym("F29", Qt::Key_F29 );
530 defKeySym("F30", Qt::Key_F30 ); 530 defKeySym("F30", Qt::Key_F30 );
531 defKeySym("F31", Qt::Key_F31 ); 531 defKeySym("F31", Qt::Key_F31 );
532 defKeySym("F32", Qt::Key_F32 ); 532 defKeySym("F32", Qt::Key_F32 );
533 defKeySym("F33", Qt::Key_F33 ); 533 defKeySym("F33", Qt::Key_F33 );
534 defKeySym("F34", Qt::Key_F34 ); 534 defKeySym("F34", Qt::Key_F34 );
535 defKeySym("F35", Qt::Key_F35 ); 535 defKeySym("F35", Qt::Key_F35 );
536 defKeySym("Super_L", Qt::Key_Super_L ); 536 defKeySym("Super_L", Qt::Key_Super_L );
537 defKeySym("Super_R", Qt::Key_Super_R ); 537 defKeySym("Super_R", Qt::Key_Super_R );
538 defKeySym("Menu", Qt::Key_Menu ); 538 defKeySym("Menu", Qt::Key_Menu );
539 defKeySym("Hyper_L", Qt::Key_Hyper_L ); 539 defKeySym("Hyper_L", Qt::Key_Hyper_L );
540 defKeySym("Hyper_R", Qt::Key_Hyper_R ); 540 defKeySym("Hyper_R", Qt::Key_Hyper_R );
541 541
542 // Regular keys 542 // Regular keys
543 defKeySym("Space", Qt::Key_Space ); 543 defKeySym("Space", Qt::Key_Space );
544 defKeySym("Exclam", Qt::Key_Exclam ); 544 defKeySym("Exclam", Qt::Key_Exclam );
545 defKeySym("QuoteDbl", Qt::Key_QuoteDbl ); 545 defKeySym("QuoteDbl", Qt::Key_QuoteDbl );
546 defKeySym("NumberSign", Qt::Key_NumberSign ); 546 defKeySym("NumberSign", Qt::Key_NumberSign );
547 defKeySym("Dollar", Qt::Key_Dollar ); 547 defKeySym("Dollar", Qt::Key_Dollar );
548 defKeySym("Percent", Qt::Key_Percent ); 548 defKeySym("Percent", Qt::Key_Percent );
549 defKeySym("Ampersand", Qt::Key_Ampersand ); 549 defKeySym("Ampersand", Qt::Key_Ampersand );
550 defKeySym("Apostrophe", Qt::Key_Apostrophe ); 550 defKeySym("Apostrophe", Qt::Key_Apostrophe );
551 defKeySym("ParenLeft", Qt::Key_ParenLeft ); 551 defKeySym("ParenLeft", Qt::Key_ParenLeft );
552 defKeySym("ParenRight", Qt::Key_ParenRight ); 552 defKeySym("ParenRight", Qt::Key_ParenRight );
553 defKeySym("Asterisk", Qt::Key_Asterisk ); 553 defKeySym("Asterisk", Qt::Key_Asterisk );
554 defKeySym("Plus", Qt::Key_Plus ); 554 defKeySym("Plus", Qt::Key_Plus );
555 defKeySym("Comma", Qt::Key_Comma ); 555 defKeySym("Comma", Qt::Key_Comma );
556 defKeySym("Minus", Qt::Key_Minus ); 556 defKeySym("Minus", Qt::Key_Minus );
557 defKeySym("Period", Qt::Key_Period ); 557 defKeySym("Period", Qt::Key_Period );
558 defKeySym("Slash", Qt::Key_Slash ); 558 defKeySym("Slash", Qt::Key_Slash );
559 defKeySym("0", Qt::Key_0 ); 559 defKeySym("0", Qt::Key_0 );
560 defKeySym("1", Qt::Key_1 ); 560 defKeySym("1", Qt::Key_1 );
561 defKeySym("2", Qt::Key_2 ); 561 defKeySym("2", Qt::Key_2 );
562 defKeySym("3", Qt::Key_3 ); 562 defKeySym("3", Qt::Key_3 );
563 defKeySym("4", Qt::Key_4 ); 563 defKeySym("4", Qt::Key_4 );
564 defKeySym("5", Qt::Key_5 ); 564 defKeySym("5", Qt::Key_5 );
565 defKeySym("6", Qt::Key_6 ); 565 defKeySym("6", Qt::Key_6 );
566 defKeySym("7", Qt::Key_7 ); 566 defKeySym("7", Qt::Key_7 );
567 defKeySym("8", Qt::Key_8 ); 567 defKeySym("8", Qt::Key_8 );
568 defKeySym("9", Qt::Key_9 ); 568 defKeySym("9", Qt::Key_9 );
569 defKeySym("Colon", Qt::Key_Colon ); 569 defKeySym("Colon", Qt::Key_Colon );
570 defKeySym("Semicolon", Qt::Key_Semicolon ); 570 defKeySym("Semicolon", Qt::Key_Semicolon );
571 defKeySym("Less", Qt::Key_Less ); 571 defKeySym("Less", Qt::Key_Less );
572 defKeySym("Equal", Qt::Key_Equal ); 572 defKeySym("Equal", Qt::Key_Equal );
573 defKeySym("Greater", Qt::Key_Greater ); 573 defKeySym("Greater", Qt::Key_Greater );
574 defKeySym("Question", Qt::Key_Question ); 574 defKeySym("Question", Qt::Key_Question );
575 defKeySym("At", Qt::Key_At ); 575 defKeySym("At", Qt::Key_At );
576 defKeySym("A", Qt::Key_A ); 576 defKeySym("A", Qt::Key_A );
577 defKeySym("B", Qt::Key_B ); 577 defKeySym("B", Qt::Key_B );
578 defKeySym("C", Qt::Key_C ); 578 defKeySym("C", Qt::Key_C );
579 defKeySym("D", Qt::Key_D ); 579 defKeySym("D", Qt::Key_D );
580 defKeySym("E", Qt::Key_E ); 580 defKeySym("E", Qt::Key_E );
581 defKeySym("F", Qt::Key_F ); 581 defKeySym("F", Qt::Key_F );
582 defKeySym("G", Qt::Key_G ); 582 defKeySym("G", Qt::Key_G );
583 defKeySym("H", Qt::Key_H ); 583 defKeySym("H", Qt::Key_H );
584 defKeySym("I", Qt::Key_I ); 584 defKeySym("I", Qt::Key_I );
585 defKeySym("J", Qt::Key_J ); 585 defKeySym("J", Qt::Key_J );
586 defKeySym("K", Qt::Key_K ); 586 defKeySym("K", Qt::Key_K );
587 defKeySym("L", Qt::Key_L ); 587 defKeySym("L", Qt::Key_L );
588 defKeySym("M", Qt::Key_M ); 588 defKeySym("M", Qt::Key_M );
589 defKeySym("N", Qt::Key_N ); 589 defKeySym("N", Qt::Key_N );
590 defKeySym("O", Qt::Key_O ); 590 defKeySym("O", Qt::Key_O );
591 defKeySym("P", Qt::Key_P ); 591 defKeySym("P", Qt::Key_P );
592 defKeySym("Q", Qt::Key_Q ); 592 defKeySym("Q", Qt::Key_Q );
593 defKeySym("R", Qt::Key_R ); 593 defKeySym("R", Qt::Key_R );
594 defKeySym("S", Qt::Key_S ); 594 defKeySym("S", Qt::Key_S );
595 defKeySym("T", Qt::Key_T ); 595 defKeySym("T", Qt::Key_T );
596 defKeySym("U", Qt::Key_U ); 596 defKeySym("U", Qt::Key_U );
597 defKeySym("V", Qt::Key_V ); 597 defKeySym("V", Qt::Key_V );
598 defKeySym("W", Qt::Key_W ); 598 defKeySym("W", Qt::Key_W );
599 defKeySym("X", Qt::Key_X ); 599 defKeySym("X", Qt::Key_X );
600 defKeySym("Y", Qt::Key_Y ); 600 defKeySym("Y", Qt::Key_Y );
601 defKeySym("Z", Qt::Key_Z ); 601 defKeySym("Z", Qt::Key_Z );
602 defKeySym("BracketLeft", Qt::Key_BracketLeft ); 602 defKeySym("BracketLeft", Qt::Key_BracketLeft );
603 defKeySym("Backslash", Qt::Key_Backslash ); 603 defKeySym("Backslash", Qt::Key_Backslash );
604 defKeySym("BracketRight", Qt::Key_BracketRight); 604 defKeySym("BracketRight", Qt::Key_BracketRight);
605 defKeySym("AsciiCircum", Qt::Key_AsciiCircum ); 605 defKeySym("AsciiCircum", Qt::Key_AsciiCircum );
606 defKeySym("Underscore", Qt::Key_Underscore ); 606 defKeySym("Underscore", Qt::Key_Underscore );
607 defKeySym("QuoteLeft", Qt::Key_QuoteLeft ); 607 defKeySym("QuoteLeft", Qt::Key_QuoteLeft );
608 defKeySym("BraceLeft", Qt::Key_BraceLeft ); 608 defKeySym("BraceLeft", Qt::Key_BraceLeft );
609 defKeySym("Bar", Qt::Key_Bar ); 609 defKeySym("Bar", Qt::Key_Bar );
610 defKeySym("BraceRight", Qt::Key_BraceRight ); 610 defKeySym("BraceRight", Qt::Key_BraceRight );
611 defKeySym("AsciiTilde", Qt::Key_AsciiTilde ); 611 defKeySym("AsciiTilde", Qt::Key_AsciiTilde );
612} 612}
613 613
614KeyTransSymbols::KeyTransSymbols() 614KeyTransSymbols::KeyTransSymbols()
615{ 615{
616 defModSyms(); 616 defModSyms();
617 defOprSyms(); 617 defOprSyms();
618 defKeySyms(); 618 defKeySyms();
619} 619}
620 620
621// Global material ----------------------------------------------------------- 621// Global material -----------------------------------------------------------
622 622
623static int keytab_serial = 0; //FIXME: remove,localize 623static int keytab_serial = 0; //FIXME: remove,localize
624 624
625static QIntDict<KeyTrans> * numb2keymap = 0L; 625static QIntDict<KeyTrans> * numb2keymap = 0L;
626static QDict<KeyTrans> * path2keymap = 0L; 626static QDict<KeyTrans> * path2keymap = 0L;
627 627
628KeyTrans* KeyTrans::find(int numb) 628KeyTrans* KeyTrans::find(int numb)
629{ 629{
630 loadAll();
630 KeyTrans* res = numb2keymap->find(numb); 631 KeyTrans* res = numb2keymap->find(numb);
631 return res ? res : numb2keymap->find(0); 632 return res ? res : numb2keymap->find(0);
632} 633}
633 634
634KeyTrans* KeyTrans::find(const char* path) 635KeyTrans* KeyTrans::find(const char* path)
635{ 636{
637 loadAll();
636 KeyTrans* res = path2keymap->find(path); 638 KeyTrans* res = path2keymap->find(path);
637 return res ? res : numb2keymap->find(0); 639 return res ? res : numb2keymap->find(0);
638} 640}
639 641
640int KeyTrans::count() 642int KeyTrans::count()
641{ 643{
644 loadAll();
642 return numb2keymap->count(); 645 return numb2keymap->count();
643} 646}
644 647
645void KeyTrans::addKeyTrans() 648void KeyTrans::addKeyTrans()
646{ 649{
647 this->numb = keytab_serial ++; 650 this->numb = keytab_serial ++;
648 numb2keymap->insert(numb,this); 651 numb2keymap->insert(numb,this);
649 path2keymap->insert(path,this); 652 path2keymap->insert(path,this);
650} 653}
651 654
652void KeyTrans::loadAll() 655void KeyTrans::loadAll()
653{ 656{
654 if (!numb2keymap) 657 if (!numb2keymap)
655 numb2keymap = new QIntDict<KeyTrans>; 658 numb2keymap = new QIntDict<KeyTrans>;
656 if (!path2keymap) 659 if (!path2keymap)
657 path2keymap = new QDict<KeyTrans>; 660 path2keymap = new QDict<KeyTrans>;
658 if (!syms) 661 if (!syms)
659 syms = new KeyTransSymbols; 662 syms = new KeyTransSymbols;
660 663
661 defaultKeyTrans()->addKeyTrans(); 664 defaultKeyTrans()->addKeyTrans();
662 665
663 666
664 QString path = QPEApplication::qpeDir() + "etc/keytabs"; 667 QString path = QPEApplication::qpeDir() + "etc/keytabs";
665 QDir dir(path); 668 QDir dir(path);
666 QStringList lst = dir.entryList("*.keytab"); 669 QStringList lst = dir.entryList("*.keytab");
667 670
668 for(QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) { 671 for(QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) {
669 QFile file(path + "/" + *it); 672 QFile file(path + "/" + *it);
670 KeyTrans* sc = KeyTrans::fromDevice(*it, file); 673 KeyTrans* sc = KeyTrans::fromDevice(*it, file);
671 if (sc) { 674 if (sc) {
672 sc->addKeyTrans(); 675 sc->addKeyTrans();
673 } 676 }
674 } 677 }
675 678
676} 679}
677 680
678// Debugging material ----------------------------------------------------------- 681// Debugging material -----------------------------------------------------------
679/* 682/*
680void TestTokenizer(QBuffer &buf) 683void TestTokenizer(QBuffer &buf)
681{ 684{
682 // opening sequence 685 // opening sequence
683 686
684 buf.open(IO_ReadOnly); 687 buf.open(IO_ReadOnly);
685 cc = buf.getch(); 688 cc = buf.getch();
686 lineno = 1; 689 lineno = 1;
687 690
688 // Test tokenizer 691 // Test tokenizer
689 692
690 while (getSymbol(buf)) ReportToken(); 693 while (getSymbol(buf)) ReportToken();
691 694
692 buf.close(); 695 buf.close();
693} 696}
694 697
695void test() 698void test()
696{ 699{
697 // Opening sequence 700 // Opening sequence
698 701
699 QCString txt = 702 QCString txt =
700#include "default.keytab.h" 703#include "default.keytab.h"
701 ; 704 ;
702 QBuffer buf(txt); 705 QBuffer buf(txt);
703 if (0) TestTokenizer(buf); 706 if (0) TestTokenizer(buf);
704 if (1) { KeyTrans kt; kt.scanTable(buf); } 707 if (1) { KeyTrans kt; kt.scanTable(buf); }
705} 708}
706*/ 709*/
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 @@
1 1
2#include <qaction.h> 2#include <qaction.h>
3#include <qmenubar.h> 3#include <qmenubar.h>
4#include <qlabel.h> 4#include <qlabel.h>
5#include <qpopupmenu.h> 5#include <qpopupmenu.h>
6#include <qtoolbar.h> 6#include <qtoolbar.h>
7 7
8#include "profileeditordialog.h"
8#include "configdialog.h" 9#include "configdialog.h"
9#include "default.h" 10#include "default.h"
10#include "metafactory.h" 11#include "metafactory.h"
12#include "profile.h"
11#include "profilemanager.h" 13#include "profilemanager.h"
12#include "mainwindow.h" 14#include "mainwindow.h"
13#include "tabwidget.h" 15#include "tabwidget.h"
14 16
15MainWindow::MainWindow() { 17MainWindow::MainWindow() {
16 m_factory = new MetaFactory(); 18 m_factory = new MetaFactory();
17 Default def(m_factory); 19 Default def(m_factory);
18 m_sessions.setAutoDelete( TRUE ); 20 m_sessions.setAutoDelete( TRUE );
19 m_curSession = 0; 21 m_curSession = 0;
20 m_manager = new ProfileManager( m_factory ); 22 m_manager = new ProfileManager( m_factory );
21 m_manager->load(); 23 m_manager->load();
22 24
23 initUI(); 25 initUI();
24 populateProfiles(); 26 populateProfiles();
25} 27}
26void MainWindow::initUI() { 28void MainWindow::initUI() {
27 setToolBarsMovable( FALSE ); 29 setToolBarsMovable( FALSE );
28 30
29 m_tool = new QToolBar( this ); 31 m_tool = new QToolBar( this );
30 m_tool->setHorizontalStretchable( TRUE ); 32 m_tool->setHorizontalStretchable( TRUE );
31 33
32 m_bar = new QMenuBar( m_tool ); 34 m_bar = new QMenuBar( m_tool );
33 m_console = new QPopupMenu( this ); 35 m_console = new QPopupMenu( this );
34 m_sessionsPop= new QPopupMenu( this ); 36 m_sessionsPop= new QPopupMenu( this );
35 m_settings = new QPopupMenu( this ); 37 m_settings = new QPopupMenu( this );
36 38
37 /* 39 /*
38 * new Action for new sessions 40 * new Action for new sessions
39 */ 41 */
40 QAction* a = new QAction(); 42 QAction* a = new QAction();
41 a->setText( tr("New Connection") ); 43 a->setText( tr("New Connection") );
42 a->addTo( m_console ); 44 a->addTo( m_console );
43 connect(a, SIGNAL(activated() ), 45 connect(a, SIGNAL(activated() ),
44 this, SLOT(slotNew() ) ); 46 this, SLOT(slotNew() ) );
45 47
46 /* 48 /*
47 * connect action 49 * connect action
48 */ 50 */
49 m_connect = new QAction(); 51 m_connect = new QAction();
50 m_connect->setText( tr("Connect") ); 52 m_connect->setText( tr("Connect") );
51 m_connect->addTo( m_console ); 53 m_connect->addTo( m_console );
52 connect(m_connect, SIGNAL(activated() ), 54 connect(m_connect, SIGNAL(activated() ),
53 this, SLOT(slotConnect() ) ); 55 this, SLOT(slotConnect() ) );
54 56
55 /* 57 /*
56 * disconnect action 58 * disconnect action
57 */ 59 */
58 m_disconnect = new QAction(); 60 m_disconnect = new QAction();
59 m_disconnect->setText( tr("Disconnect") ); 61 m_disconnect->setText( tr("Disconnect") );
60 m_disconnect->addTo( m_console ); 62 m_disconnect->addTo( m_console );
61 connect(m_disconnect, SIGNAL(activated() ), 63 connect(m_disconnect, SIGNAL(activated() ),
62 this, SLOT(slotDisconnect() ) ); 64 this, SLOT(slotDisconnect() ) );
63 65
64 /* 66 /*
65 * terminate action 67 * terminate action
66 */ 68 */
67 m_terminate = new QAction(); 69 m_terminate = new QAction();
68 m_terminate->setText( tr("Terminate") ); 70 m_terminate->setText( tr("Terminate") );
69 m_terminate->addTo( m_console ); 71 m_terminate->addTo( m_console );
70 connect(m_disconnect, SIGNAL(activated() ), 72 connect(m_disconnect, SIGNAL(activated() ),
71 this, SLOT(slotTerminate() ) ); 73 this, SLOT(slotTerminate() ) );
72 74
73 a = new QAction(); 75 a = new QAction();
74 a->setText( tr("Close Window") ); 76 a->setText( tr("Close Window") );
75 a->addTo( m_console ); 77 a->addTo( m_console );
76 connect(a, SIGNAL(activated() ), 78 connect(a, SIGNAL(activated() ),
77 this, SLOT(slotClose() ) ); 79 this, SLOT(slotClose() ) );
78 80
79 /* 81 /*
80 * the settings action 82 * the settings action
81 */ 83 */
82 m_setProfiles = new QAction(); 84 m_setProfiles = new QAction();
83 m_setProfiles->setText( tr("Configure Profiles") ); 85 m_setProfiles->setText( tr("Configure Profiles") );
84 m_setProfiles->addTo( m_settings ); 86 m_setProfiles->addTo( m_settings );
85 connect( m_setProfiles, SIGNAL(activated() ), 87 connect( m_setProfiles, SIGNAL(activated() ),
86 this, SLOT(slotConfigure() ) ); 88 this, SLOT(slotConfigure() ) );
87 89
88 /* insert the submenu */ 90 /* insert the submenu */
89 m_console->insertItem(tr("New from Profile"), m_sessionsPop, 91 m_console->insertItem(tr("New from Profile"), m_sessionsPop,
90 -1, 0); 92 -1, 0);
91 93
92 /* insert the connection menu */ 94 /* insert the connection menu */
93 m_bar->insertItem( tr("Connection"), m_console ); 95 m_bar->insertItem( tr("Connection"), m_console );
94 96
95 /* the settings menu */ 97 /* the settings menu */
96 m_bar->insertItem( tr("Settings"), m_settings ); 98 m_bar->insertItem( tr("Settings"), m_settings );
97 99
98 /* 100 /*
99 * connect to the menu activation 101 * connect to the menu activation
100 */ 102 */
101 connect( m_sessionsPop, SIGNAL(activated( int ) ), 103 connect( m_sessionsPop, SIGNAL(activated( int ) ),
102 this, SLOT(slotProfile( int ) ) ); 104 this, SLOT(slotProfile( int ) ) );
103 105
104 m_consoleWindow = new TabWidget( this, "blah"); 106 m_consoleWindow = new TabWidget( this, "blah");
105 setCentralWidget( m_consoleWindow ); 107 setCentralWidget( m_consoleWindow );
106 108
107} 109}
108 110
109ProfileManager* MainWindow::manager() { 111ProfileManager* MainWindow::manager() {
110 return m_manager; 112 return m_manager;
111} 113}
112 114TabWidget* MainWindow::tabWidget() {
115 return m_consoleWindow;
116}
113void MainWindow::populateProfiles() { 117void MainWindow::populateProfiles() {
114 m_sessionsPop->clear(); 118 m_sessionsPop->clear();
115 Profile::ValueList list = manager()->all(); 119 Profile::ValueList list = manager()->all();
116 for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { 120 for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) {
117 m_sessionsPop->insertItem( (*it).name() ); 121 m_sessionsPop->insertItem( (*it).name() );
118 } 122 }
119 123
120} 124}
121MainWindow::~MainWindow() { 125MainWindow::~MainWindow() {
122 delete m_factory; 126 delete m_factory;
123 manager()->save(); 127 manager()->save();
124} 128}
125 129
126MetaFactory* MainWindow::factory() { 130MetaFactory* MainWindow::factory() {
127 return m_factory; 131 return m_factory;
128} 132}
129 133
130Session* MainWindow::currentSession() { 134Session* MainWindow::currentSession() {
131 return m_curSession; 135 return m_curSession;
132} 136}
133 137
134QList<Session> MainWindow::sessions() { 138QList<Session> MainWindow::sessions() {
135 return m_sessions; 139 return m_sessions;
136} 140}
137 141
138void MainWindow::slotNew() { 142void MainWindow::slotNew() {
139 qWarning("New Connection"); 143 qWarning("New Connection");
144 ProfileEditorDialog dlg(factory() );
145 int ret = dlg.exec();
146
147 if ( ret == QDialog::Accepted ) {
148 create( dlg.profile() );
149 }
140} 150}
141 151
142void MainWindow::slotConnect() { 152void MainWindow::slotConnect() {
143 if ( currentSession() ) 153 if ( currentSession() )
144 currentSession()->layer()->open(); 154 currentSession()->layer()->open();
145} 155}
146 156
147void MainWindow::slotDisconnect() { 157void MainWindow::slotDisconnect() {
148 if ( currentSession() ) 158 if ( currentSession() )
149 currentSession()->layer()->close(); 159 currentSession()->layer()->close();
150} 160}
151 161
152void MainWindow::slotTerminate() { 162void MainWindow::slotTerminate() {
153 if ( currentSession() ) 163 if ( currentSession() )
154 currentSession()->layer()->close(); 164 currentSession()->layer()->close();
155 delete m_curSession; 165
156 m_curSession = 0l; 166 slotClose();
157 /* FIXME move to the next session */ 167 /* FIXME move to the next session */
158} 168}
159 169
160void MainWindow::slotConfigure() { 170void MainWindow::slotConfigure() {
161 qWarning("configure"); 171 qWarning("configure");
162 ConfigDialog conf( manager()->all(), factory() ); 172 ConfigDialog conf( manager()->all(), factory() );
163 conf.showMaximized(); 173 conf.showMaximized();
164 174
165 int ret = conf.exec(); 175 int ret = conf.exec();
166 176
167 if ( QDialog::Accepted == ret ) { 177 if ( QDialog::Accepted == ret ) {
168 qWarning("conf %d", conf.list().count() ); 178 qWarning("conf %d", conf.list().count() );
169 manager()->setProfiles( conf.list() ); 179 manager()->setProfiles( conf.list() );
170 populateProfiles(); 180 populateProfiles();
171 } 181 }
172} 182}
173 183/*
184 * we will remove
185 * this window from the tabwidget
186 * remove it from the list
187 * delete it
188 * and set the currentSession()
189 */
174void MainWindow::slotClose() { 190void MainWindow::slotClose() {
175} 191 if (!currentSession() )
192 return;
176 193
177void MainWindow::slotProfile( int ) { 194 tabWidget()->remove( currentSession() );
195 tabWidget()->setCurrent( m_sessions.first() );
196 m_sessions.remove( m_curSession );
197 delete m_curSession;
198 m_curSession = m_sessions.first();
199}
178 200
201/*
202 * We will get the name
203 * Then the profile
204 * and then we will make a profile
205 */
206void MainWindow::slotProfile( int id) {
207 Profile prof = manager()->profile( m_sessionsPop->text( id) );
208 create( prof );
209}
210void MainWindow::create( const Profile& prof ) {
211 Session *ses = manager()->fromProfile( prof, tabWidget() );
179 212
213 m_sessions.append( ses );
214 tabWidget()->add( ses );
215 m_curSession = ses;
180} 216}
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 @@
1#ifndef OPIE_MAIN_WINDOW_H 1#ifndef OPIE_MAIN_WINDOW_H
2#define OPIE_MAIN_WINDOW_H 2#define OPIE_MAIN_WINDOW_H
3 3
4#include <qmainwindow.h> 4#include <qmainwindow.h>
5#include <qlist.h> 5#include <qlist.h>
6 6
7#include "session.h" 7#include "session.h"
8 8
9/** 9/**
10 * this is the MainWindow of the new opie console 10 * this is the MainWindow of the new opie console
11 * it's also the dispatcher between the different 11 * it's also the dispatcher between the different
12 * actions supported by the gui 12 * actions supported by the gui
13 */ 13 */
14class QToolBar; 14class QToolBar;
15class QMenuBar; 15class QMenuBar;
16class QAction; 16class QAction;
17class MetaFactory; 17class MetaFactory;
18class TabWidget; 18class TabWidget;
19class ProfileManager; 19class ProfileManager;
20 20class Profile;
21class MainWindow : public QMainWindow { 21class MainWindow : public QMainWindow {
22 Q_OBJECT 22 Q_OBJECT
23public: 23public:
24 MainWindow(); 24 MainWindow();
25 ~MainWindow(); 25 ~MainWindow();
26 26
27 /** 27 /**
28 * our factory to generate IOLayer and so on 28 * our factory to generate IOLayer and so on
29 * 29 *
30 */ 30 */
31 MetaFactory* factory(); 31 MetaFactory* factory();
32 32
33 /** 33 /**
34 * A session contains a QWidget*, 34 * A session contains a QWidget*,
35 * an IOLayer* and some infos for us 35 * an IOLayer* and some infos for us
36 */ 36 */
37 Session* currentSession(); 37 Session* currentSession();
38 38
39 /** 39 /**
40 * the session list 40 * the session list
41 */ 41 */
42 QList<Session> sessions(); 42 QList<Session> sessions();
43 43
44 /** 44 /**
45 * 45 *
46 */ 46 */
47 ProfileManager* manager(); 47 ProfileManager* manager();
48 TabWidget* tabWidget();
48 49
49private slots: 50private slots:
50 void slotNew(); 51 void slotNew();
51 void slotConnect(); 52 void slotConnect();
52 void slotDisconnect(); 53 void slotDisconnect();
53 void slotTerminate(); 54 void slotTerminate();
54 void slotConfigure(); 55 void slotConfigure();
55 void slotClose(); 56 void slotClose();
56 void slotProfile(int); 57 void slotProfile(int);
57 58
58private: 59private:
59 void initUI(); 60 void initUI();
60 void populateProfiles(); 61 void populateProfiles();
62 void create( const Profile& );
61 /** 63 /**
62 * the current session 64 * the current session
63 */ 65 */
64 Session* m_curSession; 66 Session* m_curSession;
65 67
66 /** 68 /**
67 * the session list 69 * the session list
68 */ 70 */
69 QList<Session> m_sessions; 71 QList<Session> m_sessions;
70 72
71 /** 73 /**
72 * the metafactory 74 * the metafactory
73 */ 75 */
74 MetaFactory* m_factory; 76 MetaFactory* m_factory;
75 ProfileManager* m_manager; 77 ProfileManager* m_manager;
76 78
77 TabWidget* m_consoleWindow; 79 TabWidget* m_consoleWindow;
78 QToolBar* m_tool; 80 QToolBar* m_tool;
79 QMenuBar* m_bar; 81 QMenuBar* m_bar;
80 QPopupMenu* m_console; 82 QPopupMenu* m_console;
81 QPopupMenu* m_settings; 83 QPopupMenu* m_settings;
82 QPopupMenu* m_sessionsPop; 84 QPopupMenu* m_sessionsPop;
83 QAction* m_connect; 85 QAction* m_connect;
84 QAction* m_disconnect; 86 QAction* m_disconnect;
85 QAction* m_terminate; 87 QAction* m_terminate;
86 QAction* m_setProfiles; 88 QAction* m_setProfiles;
87 89
88}; 90};
89 91
90 92
91#endif 93#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 @@
1#include <qpe/config.h> 1#include <qpe/config.h>
2#include "metafactory.h" 2#include "metafactory.h"
3 3
4MetaFactory::MetaFactory() { 4MetaFactory::MetaFactory() {
5} 5}
6MetaFactory::~MetaFactory() { 6MetaFactory::~MetaFactory() {
7 7
8} 8}
9void MetaFactory::addConnectionWidgetFactory( const QCString& name, 9void MetaFactory::addConnectionWidgetFactory( const QCString& name,
10 const QString& str, 10 const QString& str,
11 configWidget wid) { 11 configWidget wid) {
12 m_strings.insert( str, name ); 12 m_strings.insert( str, name );
13 m_conFact.insert( str, wid ); 13 m_conFact.insert( str, wid );
14} 14}
15void MetaFactory::addTerminalWidgetFactory( const QCString& name, 15void MetaFactory::addTerminalWidgetFactory( const QCString& name,
16 const QString& str, 16 const QString& str,
17 configWidget wid ) { 17 configWidget wid ) {
18 m_strings.insert( str, name ); 18 m_strings.insert( str, name );
19 m_termFact.insert( str, wid ); 19 m_termFact.insert( str, wid );
20} 20}
21void MetaFactory::addIOLayerFactory( const QCString& name, 21void MetaFactory::addIOLayerFactory( const QCString& name,
22 const QString& str, 22 const QString& str,
23 iolayer lay) { 23 iolayer lay) {
24 m_strings.insert( str, name ); 24 m_strings.insert( str, name );
25 m_layerFact.insert( str, lay ); 25 m_layerFact.insert( str, lay );
26} 26}
27void MetaFactory::addFileTransferLayer( const QCString& name, 27void MetaFactory::addFileTransferLayer( const QCString& name,
28 const QString& str, 28 const QString& str,
29 filelayer lay) { 29 filelayer lay) {
30 m_strings.insert(str, name ); 30 m_strings.insert(str, name );
31 m_fileFact.insert( str, lay ); 31 m_fileFact.insert( str, lay );
32} 32}
33void MetaFactory::addEmulationLayer( const QCString& name,
34 const QString& str,
35 emulationLayer em) {
36 m_strings.insert(str, name );
37 m_emu.insert( str, em );
38}
33QStringList MetaFactory::ioLayers()const { 39QStringList MetaFactory::ioLayers()const {
34 QStringList list; 40 QStringList list;
35 QMap<QString, iolayer>::ConstIterator it; 41 QMap<QString, iolayer>::ConstIterator it;
36 for (it = m_layerFact.begin(); it != m_layerFact.end(); ++it ) { 42 for (it = m_layerFact.begin(); it != m_layerFact.end(); ++it ) {
37 list << it.key(); 43 list << it.key();
38 } 44 }
39 return list; 45 return list;
40} 46}
41QStringList MetaFactory::connectionWidgets()const { 47QStringList MetaFactory::connectionWidgets()const {
42 QStringList list; 48 QStringList list;
43 QMap<QString, configWidget>::ConstIterator it; 49 QMap<QString, configWidget>::ConstIterator it;
44 for ( it = m_conFact.begin(); it != m_conFact.end(); ++it ) { 50 for ( it = m_conFact.begin(); it != m_conFact.end(); ++it ) {
45 list << it.key(); 51 list << it.key();
46 } 52 }
47 return list; 53 return list;
48} 54}
49QStringList MetaFactory::terminalWidgets()const { 55QStringList MetaFactory::terminalWidgets()const {
50 QStringList list; 56 QStringList list;
51 QMap<QString, configWidget>::ConstIterator it; 57 QMap<QString, configWidget>::ConstIterator it;
52 for ( it = m_termFact.begin(); it != m_termFact.end(); ++it ) { 58 for ( it = m_termFact.begin(); it != m_termFact.end(); ++it ) {
53 list << it.key(); 59 list << it.key();
54 } 60 }
55 return list; 61 return list;
56} 62}
57QStringList MetaFactory::fileTransferLayers()const { 63QStringList MetaFactory::fileTransferLayers()const {
58 QStringList list; 64 QStringList list;
59 QMap<QString, filelayer>::ConstIterator it; 65 QMap<QString, filelayer>::ConstIterator it;
60 for ( it = m_fileFact.begin(); it != m_fileFact.end(); ++it ) { 66 for ( it = m_fileFact.begin(); it != m_fileFact.end(); ++it ) {
61 list << it.key(); 67 list << it.key();
62 } 68 }
63 return list; 69 return list;
64} 70}
71QStringList MetaFactory::emulationLayers()const {
72 QStringList list;
73 QMap<QString, emulationLayer>::ConstIterator it;
74 for ( it = m_emu.begin(); it != m_emu.end(); ++it ) {
75 list << it.key();
76 }
77 return list;
78}
65 79
66IOLayer* MetaFactory::newIOLayer( const QString& str,const Profile& prof ) { 80IOLayer* MetaFactory::newIOLayer( const QString& str,const Profile& prof ) {
67 IOLayer* lay = 0l; 81 IOLayer* lay = 0l;
68 82
69 QMap<QString, iolayer>::Iterator it; 83 QMap<QString, iolayer>::Iterator it;
70 it = m_layerFact.find( str ); 84 it = m_layerFact.find( str );
71 if ( it != m_layerFact.end() ) { 85 if ( it != m_layerFact.end() ) {
72 lay = (*(it.data()))(prof); 86 lay = (*(it.data()))(prof);
73 /* 87 /*
74 iolayer laye = it.data(); 88 iolayer laye = it.data();
75 lay = (*laye )(conf);*/ 89 lay = (*laye )(conf);*/
76 } 90 }
77 91
78 return lay; 92 return lay;
79} 93}
80 94
81ProfileDialogWidget *MetaFactory::newConnectionPlugin ( const QString& str, QWidget *parent) { 95ProfileDialogWidget *MetaFactory::newConnectionPlugin ( const QString& str, QWidget *parent) {
82 ProfileDialogWidget* wid = 0l; 96 ProfileDialogWidget* wid = 0l;
83 97
84 QMap<QString, configWidget>::Iterator it; 98 QMap<QString, configWidget>::Iterator it;
85 it = m_conFact.find( str ); 99 it = m_conFact.find( str );
86 if ( it != m_conFact.end() ) { 100 if ( it != m_conFact.end() ) {
87 wid = (*(it.data() ) )(str,parent); 101 wid = (*(it.data() ) )(str,parent);
88 } 102 }
89 return wid; 103 return wid;
90} 104}
91ProfileDialogWidget *MetaFactory::newTerminalPlugin( const QString& str, QWidget *parent) { 105ProfileDialogWidget *MetaFactory::newTerminalPlugin( const QString& str, QWidget *parent) {
92 if (str.isEmpty() ) 106 if (str.isEmpty() )
93 return 0l; 107 return 0l;
94 ProfileDialogWidget* wid = 0l; 108 ProfileDialogWidget* wid = 0l;
95 qWarning("new terminalPlugin %s %l", str.latin1(), parent ); 109 qWarning("new terminalPlugin %s %l", str.latin1(), parent );
96 110
97 QMap<QString, configWidget>::Iterator it; 111 QMap<QString, configWidget>::Iterator it;
98 it = m_termFact.find( str ); 112 it = m_termFact.find( str );
99 if ( it != m_termFact.end() ) { 113 if ( it != m_termFact.end() ) {
100 wid = (*(it.data() ) )(str,parent); 114 wid = (*(it.data() ) )(str,parent);
101 } 115 }
102 return wid; 116 return wid;
103} 117}
118EmulationLayer* MetaFactory::newEmulationLayer( const QString& str, Widget* wid) {
119 EmulationLayer* lay = 0l;
120
121 QMap<QString, emulationLayer>::Iterator it;
122 it = m_emu.find( str );
123 if ( it != m_emu.end() ) {
124 lay = (*(it.data() ) )(wid);
125 }
126
127 return lay;
128}
104QCString MetaFactory::internal( const QString& str )const { 129QCString MetaFactory::internal( const QString& str )const {
105 return m_strings[str]; 130 return m_strings[str];
106} 131}
107QString MetaFactory::external( const QCString& str )const { 132QString MetaFactory::external( const QCString& str )const {
108 QMap<QString, QCString>::ConstIterator it; 133 QMap<QString, QCString>::ConstIterator it;
109 for ( it = m_strings.begin(); it != m_strings.end(); ++it ) { 134 for ( it = m_strings.begin(); it != m_strings.end(); ++it ) {
110 if ( it.data() == str ) 135 if ( it.data() == str )
111 return it.key(); 136 return it.key();
112 } 137 }
113 return QString::null; 138 return QString::null;
114} 139}
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 @@
1#ifndef OPIE_META_FACTORY_H 1#ifndef OPIE_META_FACTORY_H
2#define OPIE_META_FACTORY_H 2#define OPIE_META_FACTORY_H
3 3
4/** 4/**
5 * The MetaFactory is used to keep track of all IOLayers, FileTransferLayers and ConfigWidgets 5 * The MetaFactory is used to keep track of all IOLayers, FileTransferLayers and ConfigWidgets
6 * and to instantiate these implementations on demand 6 * and to instantiate these implementations on demand
7 */ 7 */
8 8
9#include <qwidget.h> 9#include <qwidget.h>
10#include <qmap.h> 10#include <qmap.h>
11 11
12#include <qpe/config.h> 12#include <qpe/config.h>
13 13
14#include "io_layer.h" 14#include "io_layer.h"
15#include "file_layer.h" 15#include "file_layer.h"
16#include "profile.h" 16#include "profile.h"
17#include "profiledialogwidget.h" 17#include "profiledialogwidget.h"
18#include "emulation_layer.h"
18 19
20class Widget;
19class MetaFactory { 21class MetaFactory {
20public: 22public:
21 typedef ProfileDialogWidget* (*configWidget)(const QString&, QWidget* parent); 23 typedef ProfileDialogWidget* (*configWidget)(const QString&, QWidget* parent);
22 typedef IOLayer* (*iolayer)(const Profile& ); 24 typedef IOLayer* (*iolayer)(const Profile& );
23 typedef FileTransferLayer* (*filelayer)(IOLayer*); 25 typedef FileTransferLayer* (*filelayer)(IOLayer*);
26 typedef EmulationLayer* (*emulationLayer)(Widget* );
24 27
25 MetaFactory(); 28 MetaFactory();
26 ~MetaFactory(); 29 ~MetaFactory();
27 30
28 /** 31 /**
29 * add a ProfileDialogWidget to the factory 32 * add a ProfileDialogWidget to the factory
30 * name is the name shown to the user 33 * name is the name shown to the user
31 */ 34 */
32 void addConnectionWidgetFactory( const QCString& internalName, 35 void addConnectionWidgetFactory( const QCString& internalName,
33 const QString& uiString, 36 const QString& uiString,
34 configWidget ); 37 configWidget );
35 void addTerminalWidgetFactory ( const QCString& internalName, 38 void addTerminalWidgetFactory ( const QCString& internalName,
36 const QString& name, 39 const QString& name,
37 configWidget ); 40 configWidget );
38 41
39 /** 42 /**
40 * adds an IOLayer factory 43 * adds an IOLayer factory
41 */ 44 */
42 void addIOLayerFactory( const QCString&, 45 void addIOLayerFactory( const QCString&,
43 const QString&, 46 const QString&,
44 iolayer ); 47 iolayer );
45 48
46 /** 49 /**
47 * adds a FileTransfer Layer 50 * adds a FileTransfer Layer
48 */ 51 */
49 void addFileTransferLayer( const QCString& name, 52 void addFileTransferLayer( const QCString& name,
50 const QString&, 53 const QString&,
51 filelayer ); 54 filelayer );
52 55
56 /**
57 * adds a Factory for Emulation to the Layer..
58 */
59 void addEmulationLayer ( const QCString& name,
60 const QString& uiString,
61 emulationLayer );
62
53 /* translated UI Strings */ 63 /* translated UI Strings */
54 QStringList ioLayers()const; 64 QStringList ioLayers()const;
55 QStringList connectionWidgets()const; 65 QStringList connectionWidgets()const;
66
67 /**
68 * Terminal Configuration widgets
69 */
56 QStringList terminalWidgets()const; 70 QStringList terminalWidgets()const;
57 QStringList fileTransferLayers()const; 71 QStringList fileTransferLayers()const;
72 QStringList emulationLayers()const;
73
74 /**
75 * the generation...
76 */
58 IOLayer* newIOLayer( const QString&,const Profile& ); 77 IOLayer* newIOLayer( const QString&,const Profile& );
59 ProfileDialogWidget *newConnectionPlugin ( const QString&, QWidget* ); 78 ProfileDialogWidget *newConnectionPlugin ( const QString&, QWidget* );
60 ProfileDialogWidget* newTerminalPlugin( const QString&, QWidget* ); 79 ProfileDialogWidget* newTerminalPlugin( const QString&, QWidget* );
80 EmulationLayer* newEmulationLayer(const QString&, Widget* );
61 81
62 /* 82 /*
63 * internal takes the maybe translated 83 * internal takes the maybe translated
64 * public QString and maps it to the internal 84 * public QString and maps it to the internal
65 * not translatable QCString 85 * not translatable QCString
66 */ 86 */
67 QCString internal( const QString& )const; 87 QCString internal( const QString& )const;
68 88
69 /* 89 /*
70 * external takes the internal name 90 * external takes the internal name
71 * it returns a translated name 91 * it returns a translated name
72 */ 92 */
73 QString external( const QCString& )const; 93 QString external( const QCString& )const;
74 94
75 95
76private: 96private:
77 QMap<QString, QCString> m_strings; 97 QMap<QString, QCString> m_strings;
78 QMap<QString, configWidget> m_conFact; 98 QMap<QString, configWidget> m_conFact;
79 QMap<QString, configWidget> m_termFact; 99 QMap<QString, configWidget> m_termFact;
80 QMap<QString, iolayer> m_layerFact; 100 QMap<QString, iolayer> m_layerFact;
81 QMap<QString, filelayer> m_fileFact; 101 QMap<QString, filelayer> m_fileFact;
102 QMap<QString, emulationLayer> m_emu;
82}; 103};
83 104
84 105
85#endif 106#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 @@
1#include <stdio.h> 1#include <stdio.h>
2#include <stdlib.h> 2#include <stdlib.h>
3 3
4#include <qfile.h> 4#include <qfile.h>
5#include <qlayout.h>
6#include <qwidgetstack.h>
5 7
6#include <qpe/config.h> 8#include <qpe/config.h>
7 9
10#include "widget.h"
8#include "metafactory.h" 11#include "metafactory.h"
9#include "profileconfig.h" 12#include "profileconfig.h"
10#include "profilemanager.h" 13#include "profilemanager.h"
11 14
12ProfileManager::ProfileManager( MetaFactory* fact ) 15ProfileManager::ProfileManager( MetaFactory* fact )
13 : m_fact( fact ) 16 : m_fact( fact )
14{ 17{
15 18
16} 19}
17ProfileManager::~ProfileManager() { 20ProfileManager::~ProfileManager() {
18 21
19} 22}
20void ProfileManager::load() { 23void ProfileManager::load() {
21 m_list.clear(); 24 m_list.clear();
22 qWarning("load"); 25 qWarning("load");
23 ProfileConfig conf("opie-console-profiles"); 26 ProfileConfig conf("opie-console-profiles");
24 QStringList groups = conf.groups(); 27 QStringList groups = conf.groups();
25 QStringList::Iterator it; 28 QStringList::Iterator it;
26 29
27 /* 30 /*
28 * for each profile 31 * for each profile
29 */ 32 */
30 for ( it = groups.begin(); it != groups.end(); ++it ) { 33 for ( it = groups.begin(); it != groups.end(); ++it ) {
31 qWarning("group " + (*it) ); 34 qWarning("group " + (*it) );
32 conf.setGroup( (*it) ); 35 conf.setGroup( (*it) );
33 Profile prof; 36 Profile prof;
34 prof.setName( conf.readEntry("name") ); 37 prof.setName( conf.readEntry("name") );
35 prof.setIOLayer( conf.readEntry("iolayer").utf8() ); 38 prof.setIOLayer( conf.readEntry("iolayer").utf8() );
36 prof.setTerminalName( conf.readEntry("term").utf8() ); 39 prof.setTerminalName( conf.readEntry("term").utf8() );
37 qWarning(" %s %s", conf.readEntry("iolayer").latin1(), prof.ioLayerName().data() ); 40 qWarning(" %s %s", conf.readEntry("iolayer").latin1(), prof.ioLayerName().data() );
38 prof.setBackground( conf.readNumEntry("back") ); 41 prof.setBackground( conf.readNumEntry("back") );
39 prof.setForeground( conf.readNumEntry("fore") ); 42 prof.setForeground( conf.readNumEntry("fore") );
40 prof.setTerminal( conf.readNumEntry("terminal") ); 43 prof.setTerminal( conf.readNumEntry("terminal") );
41 prof.setConf( conf.items( (*it) ) ); 44 prof.setConf( conf.items( (*it) ) );
42 45
43 /* now add it */ 46 /* now add it */
44 m_list.append( prof ); 47 m_list.append( prof );
45 } 48 }
46 49
47} 50}
48void ProfileManager::clear() { 51void ProfileManager::clear() {
49 m_list.clear(); 52 m_list.clear();
50} 53}
51Profile::ValueList ProfileManager::all()const { 54Profile::ValueList ProfileManager::all()const {
52 return m_list; 55 return m_list;
53} 56}
54Session* ProfileManager::fromProfile( const Profile& prof) { 57/*
58 * Our goal is to create a Session
59 * We will load the the IOLayer and EmulationLayer
60 * from the factory
61 * we will generate a QWidgetStack
62 * add a dummy widget with layout
63 * add "Widget" to the layout
64 * add the dummy to the stack
65 * raise the dummy
66 * call session->connect(=
67 * this way we only need to reparent
68 * in TabWidget
69 */
70Session* ProfileManager::fromProfile( const Profile& prof, QWidget* parent) {
55 Session* session = new Session(); 71 Session* session = new Session();
56 session->setName( prof.name() ); 72 session->setName( prof.name() );
57 session->setIOLayer(m_fact->newIOLayer(prof.ioLayerName(), 73 /* translate the internal name to the external */
58 prof) ); 74 session->setIOLayer(m_fact->newIOLayer( m_fact->external(prof.ioLayerName()) ,
59 /* 75 prof) );
60 * FIXME 76
61 * load emulation 77 QWidgetStack *stack = new QWidgetStack(parent);
62 * load widget? 78 session->setWidgetStack( stack );
63 * set colors + fonts 79 QWidget* dummy = new QWidget(stack );
64 */ 80 QHBoxLayout* lay = new QHBoxLayout(dummy );
81 stack->addWidget( dummy, 0 );
82 stack->raiseWidget( 0 );
83 Widget* wid = new Widget(dummy );
84 lay->addWidget( wid );
85
86 session->setEmulationWidget( wid );
87 session->setEmulationLayer( m_fact->newEmulationLayer( m_fact->external( prof.terminalName() ),
88 wid ) );
89 session->connect();
90
65 return session; 91 return session;
66} 92}
67void ProfileManager::save( ) { 93void ProfileManager::save( ) {
68 QFile::remove( (QString(getenv("HOME") )+ "/Settings/opie-console-profiles.conf" ) ); 94 QFile::remove( (QString(getenv("HOME") )+ "/Settings/opie-console-profiles.conf" ) );
69 ProfileConfig conf("opie-console-profiles"); 95 ProfileConfig conf("opie-console-profiles");
70 Profile::ValueList::Iterator it; 96 Profile::ValueList::Iterator it;
71 for (it = m_list.begin(); it != m_list.end(); ++it ) { 97 for (it = m_list.begin(); it != m_list.end(); ++it ) {
72 conf.setGroup( (*it).name() ); 98 conf.setGroup( (*it).name() );
73 conf.writeEntry( "name", (*it).name() ); 99 conf.writeEntry( "name", (*it).name() );
74 conf.writeEntry( "iolayer", QString::fromUtf8( (*it).ioLayerName() ) ); 100 conf.writeEntry( "iolayer", QString::fromUtf8( (*it).ioLayerName() ) );
75 conf.writeEntry( "term", QString::fromUtf8( (*it).terminalName() ) ); 101 conf.writeEntry( "term", QString::fromUtf8( (*it).terminalName() ) );
76 conf.writeEntry( "back", (*it).background() ); 102 conf.writeEntry( "back", (*it).background() );
77 conf.writeEntry( "fore", (*it).foreground() ); 103 conf.writeEntry( "fore", (*it).foreground() );
78 conf.writeEntry( "terminal", (*it).terminal() ); 104 conf.writeEntry( "terminal", (*it).terminal() );
79 /* now the config stuff */ 105 /* now the config stuff */
80 QMap<QString, QString> map = (*it).conf(); 106 QMap<QString, QString> map = (*it).conf();
81 QMap<QString, QString>::Iterator it; 107 QMap<QString, QString>::Iterator it;
82 for ( it = map.begin(); it != map.end(); ++it ) { 108 for ( it = map.begin(); it != map.end(); ++it ) {
83 conf.writeEntry( it.key(), it.data() ); 109 conf.writeEntry( it.key(), it.data() );
84 } 110 }
85 } 111 }
86} 112}
87void ProfileManager::setProfiles( const Profile::ValueList& list ) { 113void ProfileManager::setProfiles( const Profile::ValueList& list ) {
88 m_list = list; 114 m_list = list;
89}; 115};
90Profile ProfileManager::profile( const QString& name )const { 116Profile ProfileManager::profile( const QString& name )const {
91 Profile prof; 117 Profile prof;
92 Profile::ValueList::ConstIterator it; 118 Profile::ValueList::ConstIterator it;
93 for ( it = m_list.begin(); it != m_list.end(); ++it ) { 119 for ( it = m_list.begin(); it != m_list.end(); ++it ) {
94 if ( name == (*it).name() ) { 120 if ( name == (*it).name() ) {
95 prof = (*it); 121 prof = (*it);
96 break; 122 break;
97 } 123 }
98 } 124 }
99 return prof; 125 return prof;
100} 126}
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 @@
1#ifndef OPIE_PROFILE_MANAGER_H 1#ifndef OPIE_PROFILE_MANAGER_H
2#define OPIE_PROFILE_MANAGER_H 2#define OPIE_PROFILE_MANAGER_H
3 3
4#include <qlist.h> 4#include <qlist.h>
5 5
6#include "session.h" 6#include "session.h"
7#include "profile.h" 7#include "profile.h"
8 8
9class MetaFactory; 9class MetaFactory;
10class ConfigWidget; 10class ConfigWidget;
11class ProfileManager { 11class ProfileManager {
12public: 12public:
13 ProfileManager(MetaFactory*); 13 ProfileManager(MetaFactory*);
14 ~ProfileManager(); 14 ~ProfileManager();
15 15
16 void load(); 16 void load();
17 Profile::ValueList all()const; 17 Profile::ValueList all()const;
18 void clear(); 18 void clear();
19 /** 19 /**
20 * also replaces the item 20 * also replaces the item
21 */ 21 */
22 void add( const Profile& prof ); 22 void add( const Profile& prof );
23 void remove( const Profile& prof ); 23 void remove( const Profile& prof );
24 Profile profile(const QString& name )const; 24 Profile profile(const QString& name )const;
25 Session* fromProfile( const Profile& ); 25 Session* fromProfile( const Profile& , QWidget* parent = 0l);
26 void setProfiles( const Profile::ValueList& ); 26 void setProfiles( const Profile::ValueList& );
27 void save(); 27 void save();
28private: 28private:
29 MetaFactory* m_fact; 29 MetaFactory* m_fact;
30 Profile::ValueList m_list; 30 Profile::ValueList m_list;
31}; 31};
32#endif 32#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 @@
1 1
2 2
3#include "io_layer.h" 3#include "io_layer.h"
4#include "file_layer.h" 4#include "file_layer.h"
5#include "widget.h"
6#include "emulation_layer.h"
5#include "session.h" 7#include "session.h"
6 8
9
7Session::Session() { 10Session::Session() {
8 m_widget = 0l; 11 m_widget = 0l;
9 m_layer = 0l; 12 m_layer = 0l;
13 m_widLay = 0l;
14 m_emLay = 0l;
10} 15}
11Session::Session( const QString& na, QWidget* widget, IOLayer* lay) 16Session::Session( const QString& na, QWidgetStack* widget, IOLayer* lay)
12 : m_name( na ), m_widget( widget ), m_layer( lay ) 17 : m_name( na ), m_widget( widget ), m_layer( lay )
13{ 18{
19 m_widLay = 0l;
20 m_emLay = 0l;
14} 21}
15Session::~Session() { 22Session::~Session() {
16 delete m_layer; 23 delete m_layer;
24 delete m_emLay;
17 delete m_widget; 25 delete m_widget;
26 /* the widget layer should be deleted by the m_widget */
18} 27}
19QString Session::name()const { 28QString Session::name()const {
20 return m_name; 29 return m_name;
21} 30}
22QWidget* Session::widget() { 31QWidgetStack* Session::widgetStack() {
23 return m_widget; 32 return m_widget;
24} 33}
25IOLayer* Session::layer() { 34IOLayer* Session::layer() {
26 return m_layer; 35 return m_layer;
27} 36}
37EmulationLayer* Session::emulationLayer() {
38 return m_emLay;
39}
40Widget* Session::emulationWidget() {
41 return m_widLay;
42}
43void Session::connect() {
44 if ( !m_layer || !m_emLay )
45 return;
46
47 QObject::connect(m_layer, SIGNAL(received(const QByteArray&) ),
48 m_emLay, SLOT(onRcvBlock(const QByteArray&) ) );
49 QObject::connect(m_emLay, SIGNAL(sndBlock(const QByteArray&) ),
50 m_layer, SLOT(send(const QByteArray&) ) );
51}
52void Session::disconnect() {
53 if ( !m_layer || !m_emLay )
54 return;
55
56 QObject::disconnect(m_layer, SIGNAL(received(const QByteArray&) ),
57 m_emLay, SLOT(onRcvBlock(const QByteArray&) ) );
58 QObject::disconnect(m_emLay, SIGNAL(sndBlock(const QByteArray&) ),
59 m_layer, SLOT(send(const QByteArray&) ) );
60}
28void Session::setName( const QString& na){ 61void Session::setName( const QString& na){
29 m_name = na; 62 m_name = na;
30} 63}
31void Session::setWidget( QWidget* wid ) { 64void Session::setWidgetStack( QWidgetStack* wid ) {
32 delete m_widget; 65 delete m_widget;
66 /* the EmulationLayer was destroyed... */
67 delete m_emLay;
33 m_widget = wid; 68 m_widget = wid;
34} 69}
35void Session::setIOLayer( IOLayer* lay ) { 70void Session::setIOLayer( IOLayer* lay ) {
36 delete m_layer; 71 delete m_layer;
37 m_layer = lay; 72 m_layer = lay;
38} 73}
74void Session::setEmulationLayer( EmulationLayer* lay ) {
75 delete m_emLay;
76 m_emLay = lay;
77}
78void Session::setEmulationWidget( Widget* lay ) {
79 delete m_widLay;
80 m_widLay = lay;
81}
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 @@
1#ifndef OPIE_SESSION_H 1#ifndef OPIE_SESSION_H
2#define OPIE_SESSION_H 2#define OPIE_SESSION_H
3 3
4#include <qwidget.h> 4#include <qwidgetstack.h>
5 5
6class IOLayer; 6class IOLayer;
7class EmulationLayer;
8class Widget;
7/** 9/**
8 * This is a Session. A session contains 10 * This is a Session. A session contains
9 * a QWidget pointer and a IOLayer 11 * a QWidget pointer and a IOLayer
10 * Imagine a session like a collection of what 12 * Imagine a session like a collection of what
11 * is needed to show your widget in a tab ;) 13 * is needed to show your widget in a tab ;)
12 */ 14 */
13class Session { 15class Session {
14public: 16public:
15 /** 17 /**
16 * c'tor with widget and layer 18 * c'tor with widget and layer
17 * ownership get's transfered 19 * ownership get's transfered
18 */ 20 */
19 Session(); 21 Session();
20 Session( const QString&, QWidget* widget, IOLayer* ); 22 Session( const QString&, QWidgetStack* widget, IOLayer* );
21 ~Session(); 23 ~Session();
22 24
23 /** 25 /**
24 * return the name of the session 26 * return the name of the session
25 */ 27 */
26 QString name()const; 28 QString name()const;
27 29
28 /** 30 /**
29 * return the widget 31 * return the widgetstack
32 * this is used to be semi modal
33 * for FileTransfer
34 *
35 * semi modal == SessionModal
30 */ 36 */
31 QWidget* widget(); 37 QWidgetStack* widgetStack();
32 38
33 /** 39 /**
34 * return the layer 40 * return the layer
35 */ 41 */
36 IOLayer* layer(); 42 IOLayer* layer();
37 void setWidget( QWidget* widget ); 43
44 EmulationLayer* emulationLayer();
45 Widget* emulationWidget();
46
47 /*
48 * connects the data flow from
49 * the IOLayer to the EmulationLayer
50 */
51 void connect();
52
53 /*
54 * disconnect the dataflow
55 * this will be done for ft
56 */
57 void disconnect();
58
59 void setWidgetStack( QWidgetStack* widget );
60 void setEmulationLayer( EmulationLayer* lay );
61 void setEmulationWidget( Widget* lay );
38 void setIOLayer( IOLayer* ); 62 void setIOLayer( IOLayer* );
39 void setName( const QString& ); 63 void setName( const QString& );
40 64
41private: 65private:
42 QString m_name; 66 QString m_name;
43 QWidget* m_widget; 67 QWidgetStack* m_widget;
44 IOLayer* m_layer; 68 IOLayer* m_layer;
69 EmulationLayer* m_emLay;
70 Widget* m_widLay;
45 71
46}; 72};
47 73
48#endif 74#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 @@
1 1
2#include "tabwidget.h" 2#include "tabwidget.h"
3 3
4TabWidget::TabWidget( QWidget* parent, const char* name ) 4TabWidget::TabWidget( QWidget* parent, const char* name )
5 : OTabWidget( parent, name ) { 5 : QTabWidget( parent, name ) {
6 connect(this, SIGNAL( currentChanged(QWidget*) ), 6 connect(this, SIGNAL( currentChanged(QWidget*) ),
7 this, SLOT( slotCurChanged(QWidget*) ) ); 7 this, SLOT( slotCurChanged(QWidget*) ) );
8} 8}
9 9
10TabWidget::~TabWidget() { 10TabWidget::~TabWidget() {
11} 11}
12 12
13void TabWidget::add( Session* ses ) { 13void TabWidget::add( Session* ses ) {
14 if ( !ses->widget() ) return; 14 if ( !ses->widgetStack() ) return;
15 addTab( ses->widget(), "console/konsole", ses->name() ); 15 qWarning("going to add it");
16 m_map.insert( ses->widget(), ses ); 16 //reparent( ses->widgetStack(), QPoint() );
17 //addTab( ses->widgetStack(), "console/konsole", ses->name() );
18 addTab( ses->widgetStack(), ses->name() );
19 m_map.insert( ses->widgetStack(), ses );
17} 20}
18 21
19void TabWidget::remove( Session* ses ) { 22void TabWidget::remove( Session* ses ) {
20 m_map.remove( ses->widget() ); 23 m_map.remove( ses->widgetStack() );
21 removePage( ses->widget() ); 24 removePage( ses->widgetStack() );
22} 25}
23 26
24void TabWidget::slotCurChanged( QWidget* wid ) { 27void TabWidget::slotCurChanged( QWidget* wid ) {
25 QMap<QWidget*, Session*>::Iterator it; 28 QMap<QWidget*, Session*>::Iterator it;
26 it = m_map.find( wid ); 29 it = m_map.find( wid );
27 if ( it == m_map.end() ) { 30 if ( it == m_map.end() ) {
28 return; 31 return;
29 } 32 }
30 33
31 emit activated( it.data() ); 34 emit activated( it.data() );
32} 35}
36void TabWidget::setCurrent( Session* ses ) {
37 if (!ses )
38 return;
39
40 showPage( ses->widgetStack() );
41}
33 42
34 43
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 @@
1#ifndef OPIE_TAB_WIDGET_H 1#ifndef OPIE_TAB_WIDGET_H
2#define OPIE_TAB_WIDGET_H 2#define OPIE_TAB_WIDGET_H
3 3
4#include <qmap.h> 4#include <qmap.h>
5#include <opie/otabwidget.h> 5#include <qtabwidget.h>
6 6
7#include "session.h" 7#include "session.h"
8/** 8/**
9 * This is our central tab widget 9 * This is our central tab widget
10 * we can add sessions here 10 * we can add sessions here
11 */ 11 */
12class TabWidget : public OTabWidget{ 12class TabWidget : public QTabWidget{
13 Q_OBJECT 13 Q_OBJECT
14public: 14public:
15 TabWidget(QWidget *parent, const char* name ); 15 TabWidget(QWidget *parent, const char* name );
16 ~TabWidget(); 16 ~TabWidget();
17 void add( Session* ); 17 void add( Session* );
18 void remove( Session* ); 18 void remove( Session* );
19 void setCurrent( Session* );
19 20
20signals: 21signals:
21 void activated(Session* ses ); 22 void activated(Session* ses );
22private slots: 23private slots:
23 void slotCurChanged( QWidget* wid ); 24 void slotCurChanged( QWidget* wid );
24private: 25private:
25 QMap<QWidget*, Session*> m_map; 26 QMap<QWidget*, Session*> m_map;
26}; 27};
27 28
28#endif 29#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
@@ -1,1029 +1,1029 @@
1/* ------------------------------------------------------------------------- */ 1/* ------------------------------------------------------------------------- */
2/* */ 2/* */
3/* [vt102emulation.cpp] VT102 Terminal Emulation */ 3/* [vt102emulation.cpp] VT102 Terminal Emulation */
4/* */ 4/* */
5/* ------------------------------------------------------------------------- */ 5/* ------------------------------------------------------------------------- */
6/* */ 6/* */
7/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ 7/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */
8/* */ 8/* */
9/* This file is part of Konsole - an X terminal for KDE */ 9/* This file is part of Konsole - an X terminal for KDE */
10/* */ 10/* */
11/* ------------------------------------------------------------------------- */ 11/* ------------------------------------------------------------------------- */
12/* */ 12/* */
13/* Ported Konsole to Qt/Embedded */ 13/* Ported Konsole to Qt/Embedded */
14/* */ 14/* */
15/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ 15/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */
16/* */ 16/* */
17/* -------------------------------------------------------------------------- */ 17/* -------------------------------------------------------------------------- */
18 18
19/*! \class Vt102Emulation 19/*! \class Vt102Emulation
20 20
21 \brief Actual Emulation for Konsole 21 \brief Actual Emulation for Konsole
22 22
23 \sa Widget \sa Screen \sa EmulationLayer 23 \sa Widget \sa Screen \sa EmulationLayer
24*/ 24*/
25 25
26#include "vt102emulation.h" 26#include "vt102emulation.h"
27#include "widget.h" 27#include "widget.h"
28#include "screen.h" 28#include "screen.h"
29#include "keytrans.h" 29#include "keytrans.h"
30 30
31#include <stdio.h> 31#include <stdio.h>
32#include <unistd.h> 32#include <unistd.h>
33#include <qkeycode.h> 33#include <qkeycode.h>
34#include <qtextcodec.h> 34#include <qtextcodec.h>
35 35
36 36
37/* VT102 Terminal Emulation 37/* VT102 Terminal Emulation
38 38
39 This class puts together the screens, the pty and the widget to a 39 This class puts together the screens, the pty and the widget to a
40 complete terminal emulation. Beside combining it's componentes, it 40 complete terminal emulation. Beside combining it's componentes, it
41 handles the emulations's protocol. 41 handles the emulations's protocol.
42 42
43 This module consists of the following sections: 43 This module consists of the following sections:
44 44
45 - Constructor/Destructor 45 - Constructor/Destructor
46 - Incoming Bytes Event pipeline 46 - Incoming Bytes Event pipeline
47 - Outgoing Bytes 47 - Outgoing Bytes
48 - Mouse Events 48 - Mouse Events
49 - Keyboard Events 49 - Keyboard Events
50 - Modes and Charset State 50 - Modes and Charset State
51 - Diagnostics 51 - Diagnostics
52*/ 52*/
53 53
54 54
55/* ------------------------------------------------------------------------- */ 55/* ------------------------------------------------------------------------- */
56/* */ 56/* */
57/* Constructor / Destructor */ 57/* Constructor / Destructor */
58/* */ 58/* */
59/* ------------------------------------------------------------------------- */ 59/* ------------------------------------------------------------------------- */
60 60
61/* 61/*
62 Nothing really intesting happens here. 62 Nothing really intesting happens here.
63*/ 63*/
64 64
65/*! 65/*!
66*/ 66*/
67 67
68Vt102Emulation::Vt102Emulation(Widget* gui) : EmulationLayer(gui) 68Vt102Emulation::Vt102Emulation(Widget* gui) : EmulationLayer(gui)
69{ 69{
70 QObject::connect(gui,SIGNAL(mouseSignal(int,int,int)), 70 QObject::connect(gui,SIGNAL(mouseSignal(int,int,int)),
71 this,SLOT(onMouse(int,int,int))); 71 this,SLOT(onMouse(int,int,int)));
72 initTokenizer(); 72 initTokenizer();
73 reset(); 73 reset();
74} 74}
75 75
76/*! 76/*!
77*/ 77*/
78 78
79Vt102Emulation::~Vt102Emulation() 79Vt102Emulation::~Vt102Emulation()
80{ 80{
81} 81}
82 82
83/*! 83/*!
84*/ 84*/
85 85
86void Vt102Emulation::reset() 86void Vt102Emulation::reset()
87{ 87{
88 resetToken(); 88 resetToken();
89 resetModes(); 89 resetModes();
90 resetCharset(0); screen[0]->reset(); 90 resetCharset(0); screen[0]->reset();
91 resetCharset(1); screen[0]->reset(); 91 resetCharset(1); screen[0]->reset();
92 setCodec(0); 92 setCodec(0);
93 setKeytrans("linux.keytab"); 93 setKeytrans("linux.keytab");
94} 94}
95 95
96/* ------------------------------------------------------------------------- */ 96/* ------------------------------------------------------------------------- */
97/* */ 97/* */
98/* Processing the incoming byte stream */ 98/* Processing the incoming byte stream */
99/* */ 99/* */
100/* ------------------------------------------------------------------------- */ 100/* ------------------------------------------------------------------------- */
101 101
102/* Incoming Bytes Event pipeline 102/* Incoming Bytes Event pipeline
103 103
104 This section deals with decoding the incoming character stream. 104 This section deals with decoding the incoming character stream.
105 Decoding means here, that the stream is first seperated into `tokens' 105 Decoding means here, that the stream is first seperated into `tokens'
106 which are then mapped to a `meaning' provided as operations by the 106 which are then mapped to a `meaning' provided as operations by the
107 `TEScreen' class or by the emulation class itself. 107 `TEScreen' class or by the emulation class itself.
108 108
109 The pipeline proceeds as follows: 109 The pipeline proceeds as follows:
110 110
111 - Tokenizing the ESC codes (onRcvChar) 111 - Tokenizing the ESC codes (onRcvChar)
112 - VT100 code page translation of plain characters (applyCharset) 112 - VT100 code page translation of plain characters (applyCharset)
113 - Interpretation of ESC codes (tau) 113 - Interpretation of ESC codes (tau)
114 114
115 The escape codes and their meaning are described in the 115 The escape codes and their meaning are described in the
116 technical reference of this program. 116 technical reference of this program.
117*/ 117*/
118 118
119// Tokens ------------------------------------------------------------------ -- 119// Tokens ------------------------------------------------------------------ --
120 120
121/* 121/*
122 Since the tokens are the central notion if this section, we've put them 122 Since the tokens are the central notion if this section, we've put them
123 in front. They provide the syntactical elements used to represent the 123 in front. They provide the syntactical elements used to represent the
124 terminals operations as byte sequences. 124 terminals operations as byte sequences.
125 125
126 They are encodes here into a single machine word, so that we can later 126 They are encodes here into a single machine word, so that we can later
127 switch over them easily. Depending on the token itself, additional 127 switch over them easily. Depending on the token itself, additional
128 argument variables are filled with parameter values. 128 argument variables are filled with parameter values.
129 129
130 The tokens are defined below: 130 The tokens are defined below:
131 131
132 - CHR - Printable characters (32..255 but DEL (=127)) 132 - CHR - Printable characters (32..255 but DEL (=127))
133 - CTL - Control characters (0..31 but ESC (= 27), DEL) 133 - CTL - Control characters (0..31 but ESC (= 27), DEL)
134 - ESC - Escape codes of the form <ESC><CHR but `[]()+*#'> 134 - ESC - Escape codes of the form <ESC><CHR but `[]()+*#'>
135 - ESC_DE - Escape codes of the form <ESC><any of `()+*#%'> C 135 - ESC_DE - Escape codes of the form <ESC><any of `()+*#%'> C
136 - CSI_PN - Escape codes of the form <ESC>'[' {Pn} ';' {Pn} C 136 - CSI_PN - Escape codes of the form <ESC>'[' {Pn} ';' {Pn} C
137 - CSI_PS - Escape codes of the form <ESC>'[' {Pn} ';' ... C 137 - CSI_PS - Escape codes of the form <ESC>'[' {Pn} ';' ... C
138 - CSI_PR - Escape codes of the form <ESC>'[' '?' {Pn} ';' ... C 138 - CSI_PR - Escape codes of the form <ESC>'[' '?' {Pn} ';' ... C
139 - VT52 - VT52 escape codes 139 - VT52 - VT52 escape codes
140 - <ESC><Chr> 140 - <ESC><Chr>
141 - <ESC>'Y'{Pc}{Pc} 141 - <ESC>'Y'{Pc}{Pc}
142 - XTE_HA - Xterm hacks <ESC>`]' {Pn} `;' {Text} <BEL> 142 - XTE_HA - Xterm hacks <ESC>`]' {Pn} `;' {Text} <BEL>
143 note that this is handled differently 143 note that this is handled differently
144 144
145 The last two forms allow list of arguments. Since the elements of 145 The last two forms allow list of arguments. Since the elements of
146 the lists are treated individually the same way, they are passed 146 the lists are treated individually the same way, they are passed
147 as individual tokens to the interpretation. Further, because the 147 as individual tokens to the interpretation. Further, because the
148 meaning of the parameters are names (althought represented as numbers), 148 meaning of the parameters are names (althought represented as numbers),
149 they are includes within the token ('N'). 149 they are includes within the token ('N').
150 150
151*/ 151*/
152 152
153#define TY_CONSTR(T,A,N) ( ((((int)N) & 0xffff) << 16) | ((((int)A) & 0xff) << 8) | (((int)T) & 0xff) ) 153#define TY_CONSTR(T,A,N) ( ((((int)N) & 0xffff) << 16) | ((((int)A) & 0xff) << 8) | (((int)T) & 0xff) )
154 154
155#define TY_CHR___( ) TY_CONSTR(0,0,0) 155#define TY_CHR___( ) TY_CONSTR(0,0,0)
156#define TY_CTL___(A ) TY_CONSTR(1,A,0) 156#define TY_CTL___(A ) TY_CONSTR(1,A,0)
157#define TY_ESC___(A ) TY_CONSTR(2,A,0) 157#define TY_ESC___(A ) TY_CONSTR(2,A,0)
158#define TY_ESC_CS(A,B) TY_CONSTR(3,A,B) 158#define TY_ESC_CS(A,B) TY_CONSTR(3,A,B)
159#define TY_ESC_DE(A ) TY_CONSTR(4,A,0) 159#define TY_ESC_DE(A ) TY_CONSTR(4,A,0)
160#define TY_CSI_PS(A,N) TY_CONSTR(5,A,N) 160#define TY_CSI_PS(A,N) TY_CONSTR(5,A,N)
161#define TY_CSI_PN(A ) TY_CONSTR(6,A,0) 161#define TY_CSI_PN(A ) TY_CONSTR(6,A,0)
162#define TY_CSI_PR(A,N) TY_CONSTR(7,A,N) 162#define TY_CSI_PR(A,N) TY_CONSTR(7,A,N)
163 163
164#define TY_VT52__(A ) TY_CONSTR(8,A,0) 164#define TY_VT52__(A ) TY_CONSTR(8,A,0)
165 165
166// Tokenizer --------------------------------------------------------------- -- 166// Tokenizer --------------------------------------------------------------- --
167 167
168/* The tokenizers state 168/* The tokenizers state
169 169
170 The state is represented by the buffer (pbuf, ppos), 170 The state is represented by the buffer (pbuf, ppos),
171 and accompanied by decoded arguments kept in (argv,argc). 171 and accompanied by decoded arguments kept in (argv,argc).
172 Note that they are kept internal in the tokenizer. 172 Note that they are kept internal in the tokenizer.
173*/ 173*/
174 174
175void Vt102Emulation::resetToken() 175void Vt102Emulation::resetToken()
176{ 176{
177 ppos = 0; argc = 0; argv[0] = 0; argv[1] = 0; 177 ppos = 0; argc = 0; argv[0] = 0; argv[1] = 0;
178} 178}
179 179
180void Vt102Emulation::addDigit(int dig) 180void Vt102Emulation::addDigit(int dig)
181{ 181{
182 argv[argc] = 10*argv[argc] + dig; 182 argv[argc] = 10*argv[argc] + dig;
183} 183}
184 184
185void Vt102Emulation::addArgument() 185void Vt102Emulation::addArgument()
186{ 186{
187 argc = QMIN(argc+1,MAXARGS-1); 187 argc = QMIN(argc+1,MAXARGS-1);
188 argv[argc] = 0; 188 argv[argc] = 0;
189} 189}
190 190
191void Vt102Emulation::pushToToken(int cc) 191void Vt102Emulation::pushToToken(int cc)
192{ 192{
193 pbuf[ppos] = cc; 193 pbuf[ppos] = cc;
194 ppos = QMIN(ppos+1,MAXPBUF-1); 194 ppos = QMIN(ppos+1,MAXPBUF-1);
195} 195}
196 196
197// Character Classes used while decoding 197// Character Classes used while decoding
198 198
199#define CTL 1 199#define CTL 1
200#define CHR 2 200#define CHR 2
201#define CPN 4 201#define CPN 4
202#define DIG 8 202#define DIG 8
203#define SCS 16 203#define SCS 16
204#define GRP 32 204#define GRP 32
205 205
206void Vt102Emulation::initTokenizer() 206void Vt102Emulation::initTokenizer()
207{ int i; UINT8* s; 207{ int i; UINT8* s;
208 for(i = 0; i < 256; i++) tbl[ i] = 0; 208 for(i = 0; i < 256; i++) tbl[ i] = 0;
209 for(i = 0; i < 32; i++) tbl[ i] |= CTL; 209 for(i = 0; i < 32; i++) tbl[ i] |= CTL;
210 for(i = 32; i < 256; i++) tbl[ i] |= CHR; 210 for(i = 32; i < 256; i++) tbl[ i] |= CHR;
211 for(s = (UINT8*)"@ABCDGHLMPXcdfry"; *s; s++) tbl[*s] |= CPN; 211 for(s = (UINT8*)"@ABCDGHLMPXcdfry"; *s; s++) tbl[*s] |= CPN;
212 for(s = (UINT8*)"0123456789" ; *s; s++) tbl[*s] |= DIG; 212 for(s = (UINT8*)"0123456789" ; *s; s++) tbl[*s] |= DIG;
213 for(s = (UINT8*)"()+*%" ; *s; s++) tbl[*s] |= SCS; 213 for(s = (UINT8*)"()+*%" ; *s; s++) tbl[*s] |= SCS;
214 for(s = (UINT8*)"()+*#[]%" ; *s; s++) tbl[*s] |= GRP; 214 for(s = (UINT8*)"()+*#[]%" ; *s; s++) tbl[*s] |= GRP;
215 resetToken(); 215 resetToken();
216} 216}
217 217
218/* Ok, here comes the nasty part of the decoder. 218/* Ok, here comes the nasty part of the decoder.
219 219
220 Instead of keeping an explicit state, we deduce it from the 220 Instead of keeping an explicit state, we deduce it from the
221 token scanned so far. It is then immediately combined with 221 token scanned so far. It is then immediately combined with
222 the current character to form a scanning decision. 222 the current character to form a scanning decision.
223 223
224 This is done by the following defines. 224 This is done by the following defines.
225 225
226 - P is the length of the token scanned so far. 226 - P is the length of the token scanned so far.
227 - L (often P-1) is the position on which contents we base a decision. 227 - L (often P-1) is the position on which contents we base a decision.
228 - C is a character or a group of characters (taken from 'tbl'). 228 - C is a character or a group of characters (taken from 'tbl').
229 229
230 Note that they need to applied in proper order. 230 Note that they need to applied in proper order.
231*/ 231*/
232 232
233#define lec(P,L,C) (p == (P) && s[(L)] == (C)) 233#define lec(P,L,C) (p == (P) && s[(L)] == (C))
234#define lun( ) (p == 1 && cc >= 32 ) 234#define lun( ) (p == 1 && cc >= 32 )
235#define les(P,L,C) (p == (P) && s[L] < 256 && (tbl[s[(L)]] & (C)) == (C)) 235#define les(P,L,C) (p == (P) && s[L] < 256 && (tbl[s[(L)]] & (C)) == (C))
236#define eec(C) (p >= 3 && cc == (C)) 236#define eec(C) (p >= 3 && cc == (C))
237#define ees(C) (p >= 3 && cc < 256 && (tbl[ cc ] & (C)) == (C)) 237#define ees(C) (p >= 3 && cc < 256 && (tbl[ cc ] & (C)) == (C))
238#define eps(C) (p >= 3 && s[2] != '?' && cc < 256 && (tbl[ cc ] & (C)) == (C)) 238#define eps(C) (p >= 3 && s[2] != '?' && cc < 256 && (tbl[ cc ] & (C)) == (C))
239#define epp( ) (p >= 3 && s[2] == '?' ) 239#define epp( ) (p >= 3 && s[2] == '?' )
240#define egt( ) (p == 3 && s[2] == '>' ) 240#define egt( ) (p == 3 && s[2] == '>' )
241#define Xpe (ppos>=2 && pbuf[1] == ']' ) 241#define Xpe (ppos>=2 && pbuf[1] == ']' )
242#define Xte (Xpe && cc == 7 ) 242#define Xte (Xpe && cc == 7 )
243#define ces(C) ( cc < 256 && (tbl[ cc ] & (C)) == (C) && !Xte) 243#define ces(C) ( cc < 256 && (tbl[ cc ] & (C)) == (C) && !Xte)
244 244
245#define ESC 27 245#define ESC 27
246#define CNTL(c) ((c)-'@') 246#define CNTL(c) ((c)-'@')
247 247
248// process an incoming unicode character 248// process an incoming unicode character
249 249
250void Vt102Emulation::onRcvChar(int cc) 250void Vt102Emulation::onRcvChar(int cc)
251{ int i; 251{ int i;
252 252
253 if (cc == 127) return; //VT100: ignore. 253 if (cc == 127) return; //VT100: ignore.
254 254
255 if (ces( CTL)) 255 if (ces( CTL))
256 { // DEC HACK ALERT! Control Characters are allowed *within* esc sequences in VT100 256 { // DEC HACK ALERT! Control Characters are allowed *within* esc sequences in VT100
257 // This means, they do neither a resetToken nor a pushToToken. Some of them, do 257 // This means, they do neither a resetToken nor a pushToToken. Some of them, do
258 // of course. Guess this originates from a weakly layered handling of the X-on 258 // of course. Guess this originates from a weakly layered handling of the X-on
259 // X-off protocol, which comes really below this level. 259 // X-off protocol, which comes really below this level.
260 if (cc == CNTL('X') || cc == CNTL('Z') || cc == ESC) resetToken(); //VT100: CAN or SUB 260 if (cc == CNTL('X') || cc == CNTL('Z') || cc == ESC) resetToken(); //VT100: CAN or SUB
261 if (cc != ESC) { tau( TY_CTL___(cc+'@' ), 0, 0); return; } 261 if (cc != ESC) { tau( TY_CTL___(cc+'@' ), 0, 0); return; }
262 } 262 }
263 263
264 pushToToken(cc); // advance the state 264 pushToToken(cc); // advance the state
265 265
266 int* s = pbuf; 266 int* s = pbuf;
267 int p = ppos; 267 int p = ppos;
268 268
269 if (getMode(MODE_Ansi)) // decide on proper action 269 if (getMode(MODE_Ansi)) // decide on proper action
270 { 270 {
271 if (lec(1,0,ESC)) { return; } 271 if (lec(1,0,ESC)) { return; }
272 if (les(2,1,GRP)) { return; } 272 if (les(2,1,GRP)) { return; }
273 if (Xte ) { XtermHack(); resetToken(); return; } 273 if (Xte ) { XtermHack(); resetToken(); return; }
274 if (Xpe ) { return; } 274 if (Xpe ) { return; }
275 if (lec(3,2,'?')) { return; } 275 if (lec(3,2,'?')) { return; }
276 if (lec(3,2,'>')) { return; } 276 if (lec(3,2,'>')) { return; }
277 if (lun( )) { tau( TY_CHR___(), applyCharset(cc), 0); resetToken(); return; } 277 if (lun( )) { tau( TY_CHR___(), applyCharset(cc), 0); resetToken(); return; }
278 if (lec(2,0,ESC)) { tau( TY_ESC___(s[1]), 0, 0); resetToken(); return; } 278 if (lec(2,0,ESC)) { tau( TY_ESC___(s[1]), 0, 0); resetToken(); return; }
279 if (les(3,1,SCS)) { tau( TY_ESC_CS(s[1],s[2]), 0, 0); resetToken(); return; } 279 if (les(3,1,SCS)) { tau( TY_ESC_CS(s[1],s[2]), 0, 0); resetToken(); return; }
280 if (lec(3,1,'#')) { tau( TY_ESC_DE(s[2]), 0, 0); resetToken(); return; } 280 if (lec(3,1,'#')) { tau( TY_ESC_DE(s[2]), 0, 0); resetToken(); return; }
281// if (egt( )) { tau( TY_CSI_PG(cc ), '>', 0); resetToken(); return; } 281// if (egt( )) { tau( TY_CSI_PG(cc ), '>', 0); resetToken(); return; }
282 if (eps( CPN)) { tau( TY_CSI_PN(cc), argv[0],argv[1]); resetToken(); return; } 282 if (eps( CPN)) { tau( TY_CSI_PN(cc), argv[0],argv[1]); resetToken(); return; }
283 if (ees( DIG)) { addDigit(cc-'0'); return; } 283 if (ees( DIG)) { addDigit(cc-'0'); return; }
284 if (eec( ';')) { addArgument(); return; } 284 if (eec( ';')) { addArgument(); return; }
285 for (i=0;i<=argc;i++) 285 for (i=0;i<=argc;i++)
286 if (epp( )) tau( TY_CSI_PR(cc,argv[i]), 0, 0); else 286 if (epp( )) tau( TY_CSI_PR(cc,argv[i]), 0, 0); else
287 tau( TY_CSI_PS(cc,argv[i]), 0, 0); 287 tau( TY_CSI_PS(cc,argv[i]), 0, 0);
288 resetToken(); 288 resetToken();
289 } 289 }
290 else // mode VT52 290 else // mode VT52
291 { 291 {
292 if (lec(1,0,ESC)) return; 292 if (lec(1,0,ESC)) return;
293 if (les(1,0,CHR)) { tau( TY_CHR___( ), s[0], 0); resetToken(); return; } 293 if (les(1,0,CHR)) { tau( TY_CHR___( ), s[0], 0); resetToken(); return; }
294 if (lec(2,1,'Y')) return; 294 if (lec(2,1,'Y')) return;
295 if (lec(3,1,'Y')) return; 295 if (lec(3,1,'Y')) return;
296 if (p < 4) { tau( TY_VT52__(s[1] ), 0, 0); resetToken(); return; } 296 if (p < 4) { tau( TY_VT52__(s[1] ), 0, 0); resetToken(); return; }
297 tau( TY_VT52__(s[1] ), s[2],s[3]); resetToken(); return; 297 tau( TY_VT52__(s[1] ), s[2],s[3]); resetToken(); return;
298 } 298 }
299} 299}
300 300
301void Vt102Emulation::XtermHack() 301void Vt102Emulation::XtermHack()
302{ int i,arg = 0; 302{ int i,arg = 0;
303 for (i = 2; i < ppos && '0'<=pbuf[i] && pbuf[i]<'9' ; i++) 303 for (i = 2; i < ppos && '0'<=pbuf[i] && pbuf[i]<'9' ; i++)
304 arg = 10*arg + (pbuf[i]-'0'); 304 arg = 10*arg + (pbuf[i]-'0');
305 if (pbuf[i] != ';') { ReportErrorToken(); return; } 305 if (pbuf[i] != ';') { ReportErrorToken(); return; }
306 QChar *str = new QChar[ppos-i-2]; 306 QChar *str = new QChar[ppos-i-2];
307 for (int j = 0; j < ppos-i-2; j++) str[j] = pbuf[i+1+j]; 307 for (int j = 0; j < ppos-i-2; j++) str[j] = pbuf[i+1+j];
308 QString unistr(str,ppos-i-2); 308 QString unistr(str,ppos-i-2);
309 // arg == 1 doesn't change the title. In XTerm it only changes the icon name 309 // arg == 1 doesn't change the title. In XTerm it only changes the icon name
310 // (btw: arg=0 changes title and icon, arg=1 only icon, arg=2 only title 310 // (btw: arg=0 changes title and icon, arg=1 only icon, arg=2 only title
311 if (arg == 0 || arg == 2) emit changeTitle(arg,unistr); 311 if (arg == 0 || arg == 2) emit changeTitle(arg,unistr);
312 delete [] str; 312 delete [] str;
313} 313}
314 314
315// Interpreting Codes --------------------------------------------------------- 315// Interpreting Codes ---------------------------------------------------------
316 316
317/* 317/*
318 Now that the incoming character stream is properly tokenized, 318 Now that the incoming character stream is properly tokenized,
319 meaning is assigned to them. These are either operations of 319 meaning is assigned to them. These are either operations of
320 the current screen, or of the emulation class itself. 320 the current screen, or of the emulation class itself.
321 321
322 The token to be interpreteted comes in as a machine word 322 The token to be interpreteted comes in as a machine word
323 possibly accompanied by two parameters. 323 possibly accompanied by two parameters.
324 324
325 Likewise, the operations assigned to, come with up to two 325 Likewise, the operations assigned to, come with up to two
326 arguments. One could consider to make up a proper table 326 arguments. One could consider to make up a proper table
327 from the function below. 327 from the function below.
328 328
329 The technical reference manual provides more informations 329 The technical reference manual provides more informations
330 about this mapping. 330 about this mapping.
331*/ 331*/
332 332
333void Vt102Emulation::tau( int token, int p, int q ) 333void Vt102Emulation::tau( int token, int p, int q )
334{ 334{
335//scan_buffer_report(); 335//scan_buffer_report();
336//if (token == TY_CHR___()) printf("%c",p); else 336//if (token == TY_CHR___()) printf("%c",p); else
337//printf("tau(%d,%d,%d, %d,%d)\n",(token>>0)&0xff,(token>>8)&0xff,(token>>16)&0xffff,p,q); 337//printf("tau(%d,%d,%d, %d,%d)\n",(token>>0)&0xff,(token>>8)&0xff,(token>>16)&0xffff,p,q);
338 switch (token) 338 switch (token)
339 { 339 {
340 340
341 case TY_CHR___( ) : scr->ShowCharacter (p ); break; //UTF16 341 case TY_CHR___( ) : scr->ShowCharacter (p ); break; //UTF16
342 342
343 // 127 DEL : ignored on input 343 // 127 DEL : ignored on input
344 344
345 case TY_CTL___('@' ) : /* NUL: ignored */ break; 345 case TY_CTL___('@' ) : /* NUL: ignored */ break;
346 case TY_CTL___('A' ) : /* SOH: ignored */ break; 346 case TY_CTL___('A' ) : /* SOH: ignored */ break;
347 case TY_CTL___('B' ) : /* STX: ignored */ break; 347 case TY_CTL___('B' ) : /* STX: ignored */ break;
348 case TY_CTL___('C' ) : /* ETX: ignored */ break; 348 case TY_CTL___('C' ) : /* ETX: ignored */ break;
349 case TY_CTL___('D' ) : /* EOT: ignored */ break; 349 case TY_CTL___('D' ) : /* EOT: ignored */ break;
350 case TY_CTL___('E' ) : reportAnswerBack ( ); break; //VT100 350 case TY_CTL___('E' ) : reportAnswerBack ( ); break; //VT100
351 case TY_CTL___('F' ) : /* ACK: ignored */ break; 351 case TY_CTL___('F' ) : /* ACK: ignored */ break;
352 case TY_CTL___('G' ) : gui->Bell ( ); break; //VT100 352 case TY_CTL___('G' ) : gui->Bell ( ); break; //VT100
353 case TY_CTL___('H' ) : scr->BackSpace ( ); break; //VT100 353 case TY_CTL___('H' ) : scr->BackSpace ( ); break; //VT100
354 case TY_CTL___('I' ) : scr->Tabulate ( ); break; //VT100 354 case TY_CTL___('I' ) : scr->Tabulate ( ); break; //VT100
355 case TY_CTL___('J' ) : scr->NewLine ( ); break; //VT100 355 case TY_CTL___('J' ) : scr->NewLine ( ); break; //VT100
356 case TY_CTL___('K' ) : scr->NewLine ( ); break; //VT100 356 case TY_CTL___('K' ) : scr->NewLine ( ); break; //VT100
357 case TY_CTL___('L' ) : scr->NewLine ( ); break; //VT100 357 case TY_CTL___('L' ) : scr->NewLine ( ); break; //VT100
358 case TY_CTL___('M' ) : scr->Return ( ); break; //VT100 358 case TY_CTL___('M' ) : scr->Return ( ); break; //VT100
359 359
360 case TY_CTL___('N' ) : useCharset ( 1); break; //VT100 360 case TY_CTL___('N' ) : useCharset ( 1); break; //VT100
361 case TY_CTL___('O' ) : useCharset ( 0); break; //VT100 361 case TY_CTL___('O' ) : useCharset ( 0); break; //VT100
362 362
363 case TY_CTL___('P' ) : /* DLE: ignored */ break; 363 case TY_CTL___('P' ) : /* DLE: ignored */ break;
364 case TY_CTL___('Q' ) : /* DC1: XON continue */ break; //VT100 364 case TY_CTL___('Q' ) : /* DC1: XON continue */ break; //VT100
365 case TY_CTL___('R' ) : /* DC2: ignored */ break; 365 case TY_CTL___('R' ) : /* DC2: ignored */ break;
366 case TY_CTL___('S' ) : /* DC3: XOFF halt */ break; //VT100 366 case TY_CTL___('S' ) : /* DC3: XOFF halt */ break; //VT100
367 case TY_CTL___('T' ) : /* DC4: ignored */ break; 367 case TY_CTL___('T' ) : /* DC4: ignored */ break;
368 case TY_CTL___('U' ) : /* NAK: ignored */ break; 368 case TY_CTL___('U' ) : /* NAK: ignored */ break;
369 case TY_CTL___('V' ) : /* SYN: ignored */ break; 369 case TY_CTL___('V' ) : /* SYN: ignored */ break;
370 case TY_CTL___('W' ) : /* ETB: ignored */ break; 370 case TY_CTL___('W' ) : /* ETB: ignored */ break;
371 case TY_CTL___('X' ) : scr->ShowCharacter ( 0x2592); break; //VT100 371 case TY_CTL___('X' ) : scr->ShowCharacter ( 0x2592); break; //VT100
372 case TY_CTL___('Y' ) : /* EM : ignored */ break; 372 case TY_CTL___('Y' ) : /* EM : ignored */ break;
373 case TY_CTL___('Z' ) : scr->ShowCharacter ( 0x2592); break; //VT100 373 case TY_CTL___('Z' ) : scr->ShowCharacter ( 0x2592); break; //VT100
374 case TY_CTL___('[' ) : /* ESC: cannot be seen here. */ break; 374 case TY_CTL___('[' ) : /* ESC: cannot be seen here. */ break;
375 case TY_CTL___('\\' ) : /* FS : ignored */ break; 375 case TY_CTL___('\\' ) : /* FS : ignored */ break;
376 case TY_CTL___(']' ) : /* GS : ignored */ break; 376 case TY_CTL___(']' ) : /* GS : ignored */ break;
377 case TY_CTL___('^' ) : /* RS : ignored */ break; 377 case TY_CTL___('^' ) : /* RS : ignored */ break;
378 case TY_CTL___('_' ) : /* US : ignored */ break; 378 case TY_CTL___('_' ) : /* US : ignored */ break;
379 379
380 case TY_ESC___('D' ) : scr->index ( ); break; //VT100 380 case TY_ESC___('D' ) : scr->index ( ); break; //VT100
381 case TY_ESC___('E' ) : scr->NextLine ( ); break; //VT100 381 case TY_ESC___('E' ) : scr->NextLine ( ); break; //VT100
382 case TY_ESC___('H' ) : scr->changeTabStop (TRUE ); break; //VT100 382 case TY_ESC___('H' ) : scr->changeTabStop (TRUE ); break; //VT100
383 case TY_ESC___('M' ) : scr->reverseIndex ( ); break; //VT100 383 case TY_ESC___('M' ) : scr->reverseIndex ( ); break; //VT100
384 case TY_ESC___('Z' ) : reportTerminalType ( ); break; 384 case TY_ESC___('Z' ) : reportTerminalType ( ); break;
385 case TY_ESC___('c' ) : reset ( ); break; 385 case TY_ESC___('c' ) : reset ( ); break;
386 386
387 case TY_ESC___('n' ) : useCharset ( 2); break; 387 case TY_ESC___('n' ) : useCharset ( 2); break;
388 case TY_ESC___('o' ) : useCharset ( 3); break; 388 case TY_ESC___('o' ) : useCharset ( 3); break;
389 case TY_ESC___('7' ) : saveCursor ( ); break; 389 case TY_ESC___('7' ) : saveCursor ( ); break;
390 case TY_ESC___('8' ) : restoreCursor ( ); break; 390 case TY_ESC___('8' ) : restoreCursor ( ); break;
391 391
392 case TY_ESC___('=' ) : setMode (MODE_AppKeyPad); break; 392 case TY_ESC___('=' ) : setMode (MODE_AppKeyPad); break;
393 case TY_ESC___('>' ) : resetMode (MODE_AppKeyPad); break; 393 case TY_ESC___('>' ) : resetMode (MODE_AppKeyPad); break;
394 case TY_ESC___('<' ) : setMode (MODE_Ansi ); break; //VT100 394 case TY_ESC___('<' ) : setMode (MODE_Ansi ); break; //VT100
395 395
396 case TY_ESC_CS('(', '0') : setCharset (0, '0'); break; //VT100 396 case TY_ESC_CS('(', '0') : setCharset (0, '0'); break; //VT100
397 case TY_ESC_CS('(', 'A') : setCharset (0, 'A'); break; //VT100 397 case TY_ESC_CS('(', 'A') : setCharset (0, 'A'); break; //VT100
398 case TY_ESC_CS('(', 'B') : setCharset (0, 'B'); break; //VT100 398 case TY_ESC_CS('(', 'B') : setCharset (0, 'B'); break; //VT100
399 399
400 case TY_ESC_CS(')', '0') : setCharset (1, '0'); break; //VT100 400 case TY_ESC_CS(')', '0') : setCharset (1, '0'); break; //VT100
401 case TY_ESC_CS(')', 'A') : setCharset (1, 'A'); break; //VT100 401 case TY_ESC_CS(')', 'A') : setCharset (1, 'A'); break; //VT100
402 case TY_ESC_CS(')', 'B') : setCharset (1, 'B'); break; //VT100 402 case TY_ESC_CS(')', 'B') : setCharset (1, 'B'); break; //VT100
403 403
404 case TY_ESC_CS('*', '0') : setCharset (2, '0'); break; //VT100 404 case TY_ESC_CS('*', '0') : setCharset (2, '0'); break; //VT100
405 case TY_ESC_CS('*', 'A') : setCharset (2, 'A'); break; //VT100 405 case TY_ESC_CS('*', 'A') : setCharset (2, 'A'); break; //VT100
406 case TY_ESC_CS('*', 'B') : setCharset (2, 'B'); break; //VT100 406 case TY_ESC_CS('*', 'B') : setCharset (2, 'B'); break; //VT100
407 407
408 case TY_ESC_CS('+', '0') : setCharset (3, '0'); break; //VT100 408 case TY_ESC_CS('+', '0') : setCharset (3, '0'); break; //VT100
409 case TY_ESC_CS('+', 'A') : setCharset (3, 'A'); break; //VT100 409 case TY_ESC_CS('+', 'A') : setCharset (3, 'A'); break; //VT100
410 case TY_ESC_CS('+', 'B') : setCharset (3, 'B'); break; //VT100 410 case TY_ESC_CS('+', 'B') : setCharset (3, 'B'); break; //VT100
411 411
412 case TY_ESC_CS('%', 'G') : setCodec (1 ); break; //LINUX 412 case TY_ESC_CS('%', 'G') : setCodec (1 ); break; //LINUX
413 case TY_ESC_CS('%', '@') : setCodec (0 ); break; //LINUX 413 case TY_ESC_CS('%', '@') : setCodec (0 ); break; //LINUX
414 414
415 case TY_ESC_DE('3' ) : /* IGNORED: double high, top half */ break; 415 case TY_ESC_DE('3' ) : /* IGNORED: double high, top half */ break;
416 case TY_ESC_DE('4' ) : /* IGNORED: double high, bottom half */ break; 416 case TY_ESC_DE('4' ) : /* IGNORED: double high, bottom half */ break;
417 case TY_ESC_DE('5' ) : /* IGNORED: single width, single high*/ break; 417 case TY_ESC_DE('5' ) : /* IGNORED: single width, single high*/ break;
418 case TY_ESC_DE('6' ) : /* IGNORED: double width, single high*/ break; 418 case TY_ESC_DE('6' ) : /* IGNORED: double width, single high*/ break;
419 case TY_ESC_DE('8' ) : scr->helpAlign ( ); break; 419 case TY_ESC_DE('8' ) : scr->helpAlign ( ); break;
420 420
421 case TY_CSI_PS('K', 0) : scr->clearToEndOfLine ( ); break; 421 case TY_CSI_PS('K', 0) : scr->clearToEndOfLine ( ); break;
422 case TY_CSI_PS('K', 1) : scr->clearToBeginOfLine ( ); break; 422 case TY_CSI_PS('K', 1) : scr->clearToBeginOfLine ( ); break;
423 case TY_CSI_PS('K', 2) : scr->clearEntireLine ( ); break; 423 case TY_CSI_PS('K', 2) : scr->clearEntireLine ( ); break;
424 case TY_CSI_PS('J', 0) : scr->clearToEndOfScreen ( ); break; 424 case TY_CSI_PS('J', 0) : scr->clearToEndOfScreen ( ); break;
425 case TY_CSI_PS('J', 1) : scr->clearToBeginOfScreen ( ); break; 425 case TY_CSI_PS('J', 1) : scr->clearToBeginOfScreen ( ); break;
426 case TY_CSI_PS('J', 2) : scr->clearEntireScreen ( ); break; 426 case TY_CSI_PS('J', 2) : scr->clearEntireScreen ( ); break;
427 case TY_CSI_PS('g', 0) : scr->changeTabStop (FALSE ); break; //VT100 427 case TY_CSI_PS('g', 0) : scr->changeTabStop (FALSE ); break; //VT100
428 case TY_CSI_PS('g', 3) : scr->clearTabStops ( ); break; //VT100 428 case TY_CSI_PS('g', 3) : scr->clearTabStops ( ); break; //VT100
429 case TY_CSI_PS('h', 4) : scr-> setMode (MODE_Insert ); break; 429 case TY_CSI_PS('h', 4) : scr-> setMode (MODE_Insert ); break;
430 case TY_CSI_PS('h', 20) : setMode (MODE_NewLine ); break; 430 case TY_CSI_PS('h', 20) : setMode (MODE_NewLine ); break;
431 case TY_CSI_PS('i', 0) : /* IGNORE: attached printer */ break; //VT100 431 case TY_CSI_PS('i', 0) : /* IGNORE: attached printer */ break; //VT100
432 case TY_CSI_PS('l', 4) : scr-> resetMode (MODE_Insert ); break; 432 case TY_CSI_PS('l', 4) : scr-> resetMode (MODE_Insert ); break;
433 case TY_CSI_PS('l', 20) : resetMode (MODE_NewLine ); break; 433 case TY_CSI_PS('l', 20) : resetMode (MODE_NewLine ); break;
434 434
435 case TY_CSI_PS('m', 0) : scr->setDefaultRendition ( ); break; 435 case TY_CSI_PS('m', 0) : scr->setDefaultRendition ( ); break;
436 case TY_CSI_PS('m', 1) : scr-> setRendition (RE_BOLD ); break; //VT100 436 case TY_CSI_PS('m', 1) : scr-> setRendition (RE_BOLD ); break; //VT100
437 case TY_CSI_PS('m', 4) : scr-> setRendition (RE_UNDERLINE); break; //VT100 437 case TY_CSI_PS('m', 4) : scr-> setRendition (RE_UNDERLINE); break; //VT100
438 case TY_CSI_PS('m', 5) : scr-> setRendition (RE_BLINK ); break; //VT100 438 case TY_CSI_PS('m', 5) : scr-> setRendition (RE_BLINK ); break; //VT100
439 case TY_CSI_PS('m', 7) : scr-> setRendition (RE_REVERSE ); break; 439 case TY_CSI_PS('m', 7) : scr-> setRendition (RE_REVERSE ); break;
440 case TY_CSI_PS('m', 10) : /* IGNORED: mapping related */ break; //LINUX 440 case TY_CSI_PS('m', 10) : /* IGNORED: mapping related */ break; //LINUX
441 case TY_CSI_PS('m', 11) : /* IGNORED: mapping related */ break; //LINUX 441 case TY_CSI_PS('m', 11) : /* IGNORED: mapping related */ break; //LINUX
442 case TY_CSI_PS('m', 12) : /* IGNORED: mapping related */ break; //LINUX 442 case TY_CSI_PS('m', 12) : /* IGNORED: mapping related */ break; //LINUX
443 case TY_CSI_PS('m', 22) : scr->resetRendition (RE_BOLD ); break; 443 case TY_CSI_PS('m', 22) : scr->resetRendition (RE_BOLD ); break;
444 case TY_CSI_PS('m', 24) : scr->resetRendition (RE_UNDERLINE); break; 444 case TY_CSI_PS('m', 24) : scr->resetRendition (RE_UNDERLINE); break;
445 case TY_CSI_PS('m', 25) : scr->resetRendition (RE_BLINK ); break; 445 case TY_CSI_PS('m', 25) : scr->resetRendition (RE_BLINK ); break;
446 case TY_CSI_PS('m', 27) : scr->resetRendition (RE_REVERSE ); break; 446 case TY_CSI_PS('m', 27) : scr->resetRendition (RE_REVERSE ); break;
447 447
448 case TY_CSI_PS('m', 30) : scr->setForeColor ( 0); break; 448 case TY_CSI_PS('m', 30) : scr->setForeColor ( 0); break;
449 case TY_CSI_PS('m', 31) : scr->setForeColor ( 1); break; 449 case TY_CSI_PS('m', 31) : scr->setForeColor ( 1); break;
450 case TY_CSI_PS('m', 32) : scr->setForeColor ( 2); break; 450 case TY_CSI_PS('m', 32) : scr->setForeColor ( 2); break;
451 case TY_CSI_PS('m', 33) : scr->setForeColor ( 3); break; 451 case TY_CSI_PS('m', 33) : scr->setForeColor ( 3); break;
452 case TY_CSI_PS('m', 34) : scr->setForeColor ( 4); break; 452 case TY_CSI_PS('m', 34) : scr->setForeColor ( 4); break;
453 case TY_CSI_PS('m', 35) : scr->setForeColor ( 5); break; 453 case TY_CSI_PS('m', 35) : scr->setForeColor ( 5); break;
454 case TY_CSI_PS('m', 36) : scr->setForeColor ( 6); break; 454 case TY_CSI_PS('m', 36) : scr->setForeColor ( 6); break;
455 case TY_CSI_PS('m', 37) : scr->setForeColor ( 7); break; 455 case TY_CSI_PS('m', 37) : scr->setForeColor ( 7); break;
456 case TY_CSI_PS('m', 39) : scr->setForeColorToDefault( ); break; 456 case TY_CSI_PS('m', 39) : scr->setForeColorToDefault( ); break;
457 457
458 case TY_CSI_PS('m', 40) : scr->setBackColor ( 0); break; 458 case TY_CSI_PS('m', 40) : scr->setBackColor ( 0); break;
459 case TY_CSI_PS('m', 41) : scr->setBackColor ( 1); break; 459 case TY_CSI_PS('m', 41) : scr->setBackColor ( 1); break;
460 case TY_CSI_PS('m', 42) : scr->setBackColor ( 2); break; 460 case TY_CSI_PS('m', 42) : scr->setBackColor ( 2); break;
461 case TY_CSI_PS('m', 43) : scr->setBackColor ( 3); break; 461 case TY_CSI_PS('m', 43) : scr->setBackColor ( 3); break;
462 case TY_CSI_PS('m', 44) : scr->setBackColor ( 4); break; 462 case TY_CSI_PS('m', 44) : scr->setBackColor ( 4); break;
463 case TY_CSI_PS('m', 45) : scr->setBackColor ( 5); break; 463 case TY_CSI_PS('m', 45) : scr->setBackColor ( 5); break;
464 case TY_CSI_PS('m', 46) : scr->setBackColor ( 6); break; 464 case TY_CSI_PS('m', 46) : scr->setBackColor ( 6); break;
465 case TY_CSI_PS('m', 47) : scr->setBackColor ( 7); break; 465 case TY_CSI_PS('m', 47) : scr->setBackColor ( 7); break;
466 case TY_CSI_PS('m', 49) : scr->setBackColorToDefault( ); break; 466 case TY_CSI_PS('m', 49) : scr->setBackColorToDefault( ); break;
467 467
468 case TY_CSI_PS('m', 90) : scr->setForeColor ( 8); break; 468 case TY_CSI_PS('m', 90) : scr->setForeColor ( 8); break;
469 case TY_CSI_PS('m', 91) : scr->setForeColor ( 9); break; 469 case TY_CSI_PS('m', 91) : scr->setForeColor ( 9); break;
470 case TY_CSI_PS('m', 92) : scr->setForeColor ( 10); break; 470 case TY_CSI_PS('m', 92) : scr->setForeColor ( 10); break;
471 case TY_CSI_PS('m', 93) : scr->setForeColor ( 11); break; 471 case TY_CSI_PS('m', 93) : scr->setForeColor ( 11); break;
472 case TY_CSI_PS('m', 94) : scr->setForeColor ( 12); break; 472 case TY_CSI_PS('m', 94) : scr->setForeColor ( 12); break;
473 case TY_CSI_PS('m', 95) : scr->setForeColor ( 13); break; 473 case TY_CSI_PS('m', 95) : scr->setForeColor ( 13); break;
474 case TY_CSI_PS('m', 96) : scr->setForeColor ( 14); break; 474 case TY_CSI_PS('m', 96) : scr->setForeColor ( 14); break;
475 case TY_CSI_PS('m', 97) : scr->setForeColor ( 15); break; 475 case TY_CSI_PS('m', 97) : scr->setForeColor ( 15); break;
476 476
477 case TY_CSI_PS('m', 100) : scr->setBackColor ( 8); break; 477 case TY_CSI_PS('m', 100) : scr->setBackColor ( 8); break;
478 case TY_CSI_PS('m', 101) : scr->setBackColor ( 9); break; 478 case TY_CSI_PS('m', 101) : scr->setBackColor ( 9); break;
479 case TY_CSI_PS('m', 102) : scr->setBackColor ( 10); break; 479 case TY_CSI_PS('m', 102) : scr->setBackColor ( 10); break;
480 case TY_CSI_PS('m', 103) : scr->setBackColor ( 11); break; 480 case TY_CSI_PS('m', 103) : scr->setBackColor ( 11); break;
481 case TY_CSI_PS('m', 104) : scr->setBackColor ( 12); break; 481 case TY_CSI_PS('m', 104) : scr->setBackColor ( 12); break;
482 case TY_CSI_PS('m', 105) : scr->setBackColor ( 13); break; 482 case TY_CSI_PS('m', 105) : scr->setBackColor ( 13); break;
483 case TY_CSI_PS('m', 106) : scr->setBackColor ( 14); break; 483 case TY_CSI_PS('m', 106) : scr->setBackColor ( 14); break;
484 case TY_CSI_PS('m', 107) : scr->setBackColor ( 15); break; 484 case TY_CSI_PS('m', 107) : scr->setBackColor ( 15); break;
485 485
486 case TY_CSI_PS('n', 5) : reportStatus ( ); break; 486 case TY_CSI_PS('n', 5) : reportStatus ( ); break;
487 case TY_CSI_PS('n', 6) : reportCursorPosition ( ); break; 487 case TY_CSI_PS('n', 6) : reportCursorPosition ( ); break;
488 case TY_CSI_PS('q', 0) : /* IGNORED: LEDs off */ break; //VT100 488 case TY_CSI_PS('q', 0) : /* IGNORED: LEDs off */ break; //VT100
489 case TY_CSI_PS('q', 1) : /* IGNORED: LED1 on */ break; //VT100 489 case TY_CSI_PS('q', 1) : /* IGNORED: LED1 on */ break; //VT100
490 case TY_CSI_PS('q', 2) : /* IGNORED: LED2 on */ break; //VT100 490 case TY_CSI_PS('q', 2) : /* IGNORED: LED2 on */ break; //VT100
491 case TY_CSI_PS('q', 3) : /* IGNORED: LED3 on */ break; //VT100 491 case TY_CSI_PS('q', 3) : /* IGNORED: LED3 on */ break; //VT100
492 case TY_CSI_PS('q', 4) : /* IGNORED: LED4 on */ break; //VT100 492 case TY_CSI_PS('q', 4) : /* IGNORED: LED4 on */ break; //VT100
493 case TY_CSI_PS('x', 0) : reportTerminalParms ( 2); break; //VT100 493 case TY_CSI_PS('x', 0) : reportTerminalParms ( 2); break; //VT100
494 case TY_CSI_PS('x', 1) : reportTerminalParms ( 3); break; //VT100 494 case TY_CSI_PS('x', 1) : reportTerminalParms ( 3); break; //VT100
495 495
496 case TY_CSI_PN('@' ) : scr->insertChars (p ); break; 496 case TY_CSI_PN('@' ) : scr->insertChars (p ); break;
497 case TY_CSI_PN('A' ) : scr->cursorUp (p ); break; //VT100 497 case TY_CSI_PN('A' ) : scr->cursorUp (p ); break; //VT100
498 case TY_CSI_PN('B' ) : scr->cursorDown (p ); break; //VT100 498 case TY_CSI_PN('B' ) : scr->cursorDown (p ); break; //VT100
499 case TY_CSI_PN('C' ) : scr->cursorRight (p ); break; //VT100 499 case TY_CSI_PN('C' ) : scr->cursorRight (p ); break; //VT100
500 case TY_CSI_PN('D' ) : scr->cursorLeft (p ); break; //VT100 500 case TY_CSI_PN('D' ) : scr->cursorLeft (p ); break; //VT100
501 case TY_CSI_PN('G' ) : scr->setCursorX (p ); break; //LINUX 501 case TY_CSI_PN('G' ) : scr->setCursorX (p ); break; //LINUX
502 case TY_CSI_PN('H' ) : scr->setCursorYX (p, q); break; //VT100 502 case TY_CSI_PN('H' ) : scr->setCursorYX (p, q); break; //VT100
503 case TY_CSI_PN('L' ) : scr->insertLines (p ); break; 503 case TY_CSI_PN('L' ) : scr->insertLines (p ); break;
504 case TY_CSI_PN('M' ) : scr->deleteLines (p ); break; 504 case TY_CSI_PN('M' ) : scr->deleteLines (p ); break;
505 case TY_CSI_PN('P' ) : scr->deleteChars (p ); break; 505 case TY_CSI_PN('P' ) : scr->deleteChars (p ); break;
506 case TY_CSI_PN('X' ) : scr->eraseChars (p ); break; 506 case TY_CSI_PN('X' ) : scr->eraseChars (p ); break;
507 case TY_CSI_PN('c' ) : reportTerminalType ( ); break; //VT100 507 case TY_CSI_PN('c' ) : reportTerminalType ( ); break; //VT100
508 case TY_CSI_PN('d' ) : scr->setCursorY (p ); break; //LINUX 508 case TY_CSI_PN('d' ) : scr->setCursorY (p ); break; //LINUX
509 case TY_CSI_PN('f' ) : scr->setCursorYX (p, q); break; //VT100 509 case TY_CSI_PN('f' ) : scr->setCursorYX (p, q); break; //VT100
510 case TY_CSI_PN('r' ) : scr->setMargins (p, q); break; //VT100 510 case TY_CSI_PN('r' ) : scr->setMargins (p, q); break; //VT100
511 case TY_CSI_PN('y' ) : /* IGNORED: Confidence test */ break; //VT100 511 case TY_CSI_PN('y' ) : /* IGNORED: Confidence test */ break; //VT100
512 512
513 case TY_CSI_PR('h', 1) : setMode (MODE_AppCuKeys); break; //VT100 513 case TY_CSI_PR('h', 1) : setMode (MODE_AppCuKeys); break; //VT100
514 case TY_CSI_PR('l', 1) : resetMode (MODE_AppCuKeys); break; //VT100 514 case TY_CSI_PR('l', 1) : resetMode (MODE_AppCuKeys); break; //VT100
515 case TY_CSI_PR('s', 1) : saveMode (MODE_AppCuKeys); break; //FIXME 515 case TY_CSI_PR('s', 1) : saveMode (MODE_AppCuKeys); break; //FIXME
516 case TY_CSI_PR('r', 1) : restoreMode (MODE_AppCuKeys); break; //FIXME 516 case TY_CSI_PR('r', 1) : restoreMode (MODE_AppCuKeys); break; //FIXME
517 517
518 case TY_CSI_PR('l', 2) : resetMode (MODE_Ansi ); break; //VT100 518 case TY_CSI_PR('l', 2) : resetMode (MODE_Ansi ); break; //VT100
519 519
520 case TY_CSI_PR('h', 3) : setColumns ( 132); break; //VT100 520 case TY_CSI_PR('h', 3) : setColumns ( 132); break; //VT100
521 case TY_CSI_PR('l', 3) : setColumns ( 80); break; //VT100 521 case TY_CSI_PR('l', 3) : setColumns ( 80); break; //VT100
522 522
523 case TY_CSI_PR('h', 4) : /* IGNORED: soft scrolling */ break; //VT100 523 case TY_CSI_PR('h', 4) : /* IGNORED: soft scrolling */ break; //VT100
524 case TY_CSI_PR('l', 4) : /* IGNORED: soft scrolling */ break; //VT100 524 case TY_CSI_PR('l', 4) : /* IGNORED: soft scrolling */ break; //VT100
525 525
526 case TY_CSI_PR('h', 5) : scr-> setMode (MODE_Screen ); break; //VT100 526 case TY_CSI_PR('h', 5) : scr-> setMode (MODE_Screen ); break; //VT100
527 case TY_CSI_PR('l', 5) : scr-> resetMode (MODE_Screen ); break; //VT100 527 case TY_CSI_PR('l', 5) : scr-> resetMode (MODE_Screen ); break; //VT100
528 528
529 case TY_CSI_PR('h', 6) : scr-> setMode (MODE_Origin ); break; //VT100 529 case TY_CSI_PR('h', 6) : scr-> setMode (MODE_Origin ); break; //VT100
530 case TY_CSI_PR('l', 6) : scr-> resetMode (MODE_Origin ); break; //VT100 530 case TY_CSI_PR('l', 6) : scr-> resetMode (MODE_Origin ); break; //VT100
531 case TY_CSI_PR('s', 6) : scr-> saveMode (MODE_Origin ); break; //FIXME 531 case TY_CSI_PR('s', 6) : scr-> saveMode (MODE_Origin ); break; //FIXME
532 case TY_CSI_PR('r', 6) : scr->restoreMode (MODE_Origin ); break; //FIXME 532 case TY_CSI_PR('r', 6) : scr->restoreMode (MODE_Origin ); break; //FIXME
533 533
534 case TY_CSI_PR('h', 7) : scr-> setMode (MODE_Wrap ); break; //VT100 534 case TY_CSI_PR('h', 7) : scr-> setMode (MODE_Wrap ); break; //VT100
535 case TY_CSI_PR('l', 7) : scr-> resetMode (MODE_Wrap ); break; //VT100 535 case TY_CSI_PR('l', 7) : scr-> resetMode (MODE_Wrap ); break; //VT100
536 case TY_CSI_PR('s', 7) : scr-> saveMode (MODE_Wrap ); break; //FIXME 536 case TY_CSI_PR('s', 7) : scr-> saveMode (MODE_Wrap ); break; //FIXME
537 case TY_CSI_PR('r', 7) : scr->restoreMode (MODE_Wrap ); break; //FIXME 537 case TY_CSI_PR('r', 7) : scr->restoreMode (MODE_Wrap ); break; //FIXME
538 538
539 case TY_CSI_PR('h', 8) : /* IGNORED: autorepeat on */ break; //VT100 539 case TY_CSI_PR('h', 8) : /* IGNORED: autorepeat on */ break; //VT100
540 case TY_CSI_PR('l', 8) : /* IGNORED: autorepeat off */ break; //VT100 540 case TY_CSI_PR('l', 8) : /* IGNORED: autorepeat off */ break; //VT100
541 541
542 case TY_CSI_PR('h', 9) : /* IGNORED: interlace */ break; //VT100 542 case TY_CSI_PR('h', 9) : /* IGNORED: interlace */ break; //VT100
543 case TY_CSI_PR('l', 9) : /* IGNORED: interlace */ break; //VT100 543 case TY_CSI_PR('l', 9) : /* IGNORED: interlace */ break; //VT100
544 544
545 case TY_CSI_PR('h', 25) : setMode (MODE_Cursor ); break; //VT100 545 case TY_CSI_PR('h', 25) : setMode (MODE_Cursor ); break; //VT100
546 case TY_CSI_PR('l', 25) : resetMode (MODE_Cursor ); break; //VT100 546 case TY_CSI_PR('l', 25) : resetMode (MODE_Cursor ); break; //VT100
547 547
548 case TY_CSI_PR('h', 41) : /* IGNORED: obsolete more(1) fix */ break; //XTERM 548 case TY_CSI_PR('h', 41) : /* IGNORED: obsolete more(1) fix */ break; //XTERM
549 case TY_CSI_PR('l', 41) : /* IGNORED: obsolete more(1) fix */ break; //XTERM 549 case TY_CSI_PR('l', 41) : /* IGNORED: obsolete more(1) fix */ break; //XTERM
550 case TY_CSI_PR('s', 41) : /* IGNORED: obsolete more(1) fix */ break; //XTERM 550 case TY_CSI_PR('s', 41) : /* IGNORED: obsolete more(1) fix */ break; //XTERM
551 case TY_CSI_PR('r', 41) : /* IGNORED: obsolete more(1) fix */ break; //XTERM 551 case TY_CSI_PR('r', 41) : /* IGNORED: obsolete more(1) fix */ break; //XTERM
552 552
553 case TY_CSI_PR('h', 47) : setMode (MODE_AppScreen); break; //VT100 553 case TY_CSI_PR('h', 47) : setMode (MODE_AppScreen); break; //VT100
554 case TY_CSI_PR('l', 47) : resetMode (MODE_AppScreen); break; //VT100 554 case TY_CSI_PR('l', 47) : resetMode (MODE_AppScreen); break; //VT100
555 555
556 case TY_CSI_PR('h', 1000) : setMode (MODE_Mouse1000); break; //XTERM 556 case TY_CSI_PR('h', 1000) : setMode (MODE_Mouse1000); break; //XTERM
557 case TY_CSI_PR('l', 1000) : resetMode (MODE_Mouse1000); break; //XTERM 557 case TY_CSI_PR('l', 1000) : resetMode (MODE_Mouse1000); break; //XTERM
558 case TY_CSI_PR('s', 1000) : saveMode (MODE_Mouse1000); break; //XTERM 558 case TY_CSI_PR('s', 1000) : saveMode (MODE_Mouse1000); break; //XTERM
559 case TY_CSI_PR('r', 1000) : restoreMode (MODE_Mouse1000); break; //XTERM 559 case TY_CSI_PR('r', 1000) : restoreMode (MODE_Mouse1000); break; //XTERM
560 560
561 case TY_CSI_PR('h', 1001) : /* IGNORED: hilite mouse tracking */ break; //XTERM 561 case TY_CSI_PR('h', 1001) : /* IGNORED: hilite mouse tracking */ break; //XTERM
562 case TY_CSI_PR('l', 1001) : /* IGNORED: hilite mouse tracking */ break; //XTERM 562 case TY_CSI_PR('l', 1001) : /* IGNORED: hilite mouse tracking */ break; //XTERM
563 case TY_CSI_PR('s', 1001) : /* IGNORED: hilite mouse tracking */ break; //XTERM 563 case TY_CSI_PR('s', 1001) : /* IGNORED: hilite mouse tracking */ break; //XTERM
564 case TY_CSI_PR('r', 1001) : /* IGNORED: hilite mouse tracking */ break; //XTERM 564 case TY_CSI_PR('r', 1001) : /* IGNORED: hilite mouse tracking */ break; //XTERM
565 565
566 case TY_CSI_PR('h', 1047) : setMode (MODE_AppScreen); break; //XTERM 566 case TY_CSI_PR('h', 1047) : setMode (MODE_AppScreen); break; //XTERM
567 case TY_CSI_PR('l', 1047) : resetMode (MODE_AppScreen); break; //XTERM 567 case TY_CSI_PR('l', 1047) : resetMode (MODE_AppScreen); break; //XTERM
568 568
569 //FIXME: Unitoken: save translations 569 //FIXME: Unitoken: save translations
570 case TY_CSI_PR('h', 1048) : saveCursor ( ); break; //XTERM 570 case TY_CSI_PR('h', 1048) : saveCursor ( ); break; //XTERM
571 case TY_CSI_PR('l', 1048) : restoreCursor ( ); break; //XTERM 571 case TY_CSI_PR('l', 1048) : restoreCursor ( ); break; //XTERM
572 572
573 //FIXME: every once new sequences like this pop up in xterm. 573 //FIXME: every once new sequences like this pop up in xterm.
574 // Here's a guess of what they could mean. 574 // Here's a guess of what they could mean.
575 case TY_CSI_PR('h', 1049) : setMode (MODE_AppScreen); break; //XTERM 575 case TY_CSI_PR('h', 1049) : setMode (MODE_AppScreen); break; //XTERM
576 case TY_CSI_PR('l', 1049) : resetMode (MODE_AppScreen); break; //XTERM 576 case TY_CSI_PR('l', 1049) : resetMode (MODE_AppScreen); break; //XTERM
577 577
578 //FIXME: when changing between vt52 and ansi mode evtl do some resetting. 578 //FIXME: when changing between vt52 and ansi mode evtl do some resetting.
579 case TY_VT52__('A' ) : scr->cursorUp ( 1); break; //VT52 579 case TY_VT52__('A' ) : scr->cursorUp ( 1); break; //VT52
580 case TY_VT52__('B' ) : scr->cursorDown ( 1); break; //VT52 580 case TY_VT52__('B' ) : scr->cursorDown ( 1); break; //VT52
581 case TY_VT52__('C' ) : scr->cursorRight ( 1); break; //VT52 581 case TY_VT52__('C' ) : scr->cursorRight ( 1); break; //VT52
582 case TY_VT52__('D' ) : scr->cursorLeft ( 1); break; //VT52 582 case TY_VT52__('D' ) : scr->cursorLeft ( 1); break; //VT52
583 583
584 case TY_VT52__('F' ) : setAndUseCharset (0, '0'); break; //VT52 584 case TY_VT52__('F' ) : setAndUseCharset (0, '0'); break; //VT52
585 case TY_VT52__('G' ) : setAndUseCharset (0, 'B'); break; //VT52 585 case TY_VT52__('G' ) : setAndUseCharset (0, 'B'); break; //VT52
586 586
587 case TY_VT52__('H' ) : scr->setCursorYX (1,1 ); break; //VT52 587 case TY_VT52__('H' ) : scr->setCursorYX (1,1 ); break; //VT52
588 case TY_VT52__('I' ) : scr->reverseIndex ( ); break; //VT52 588 case TY_VT52__('I' ) : scr->reverseIndex ( ); break; //VT52
589 case TY_VT52__('J' ) : scr->clearToEndOfScreen ( ); break; //VT52 589 case TY_VT52__('J' ) : scr->clearToEndOfScreen ( ); break; //VT52
590 case TY_VT52__('K' ) : scr->clearToEndOfLine ( ); break; //VT52 590 case TY_VT52__('K' ) : scr->clearToEndOfLine ( ); break; //VT52
591 case TY_VT52__('Y' ) : scr->setCursorYX (p-31,q-31 ); break; //VT52 591 case TY_VT52__('Y' ) : scr->setCursorYX (p-31,q-31 ); break; //VT52
592 case TY_VT52__('Z' ) : reportTerminalType ( ); break; //VT52 592 case TY_VT52__('Z' ) : reportTerminalType ( ); break; //VT52
593 case TY_VT52__('<' ) : setMode (MODE_Ansi ); break; //VT52 593 case TY_VT52__('<' ) : setMode (MODE_Ansi ); break; //VT52
594 case TY_VT52__('=' ) : setMode (MODE_AppKeyPad); break; //VT52 594 case TY_VT52__('=' ) : setMode (MODE_AppKeyPad); break; //VT52
595 case TY_VT52__('>' ) : resetMode (MODE_AppKeyPad); break; //VT52 595 case TY_VT52__('>' ) : resetMode (MODE_AppKeyPad); break; //VT52
596 596
597 default : ReportErrorToken(); break; 597 default : ReportErrorToken(); break;
598 }; 598 };
599} 599}
600 600
601/* ------------------------------------------------------------------------- */ 601/* ------------------------------------------------------------------------- */
602/* */ 602/* */
603/* Terminal to Host protocol */ 603/* Terminal to Host protocol */
604/* */ 604/* */
605/* ------------------------------------------------------------------------- */ 605/* ------------------------------------------------------------------------- */
606 606
607/* 607/*
608 Outgoing bytes originate from several sources: 608 Outgoing bytes originate from several sources:
609 609
610 - Replies to Enquieries. 610 - Replies to Enquieries.
611 - Mouse Events 611 - Mouse Events
612 - Keyboard Events 612 - Keyboard Events
613*/ 613*/
614 614
615/*! 615/*!
616*/ 616*/
617 617
618void Vt102Emulation::sendString(const char* s) 618void Vt102Emulation::sendString(const char* s)
619{ 619{
620 QByteArray tmp; 620 QByteArray tmp;
621 tmp.setRawData( s, strlen( s )); 621 tmp.setRawData( s, strlen( s ));
622 emit sndBlock( tmp); 622 emit sndBlock( tmp);
623} 623}
624 624
625void Vt102Emulation::sendString(const QByteArray s) 625void Vt102Emulation::sendString(const QByteArray& s)
626{ 626{
627 emit sndBlock( s ); 627 emit sndBlock( s );
628} 628}
629 629
630// Replies ----------------------------------------------------------------- -- 630// Replies ----------------------------------------------------------------- --
631 631
632// This section copes with replies send as response to an enquiery control code. 632// This section copes with replies send as response to an enquiery control code.
633 633
634/*! 634/*!
635*/ 635*/
636 636
637void Vt102Emulation::reportCursorPosition() 637void Vt102Emulation::reportCursorPosition()
638{ char tmp[20]; 638{ char tmp[20];
639 sprintf(tmp,"\033[%d;%dR",scr->getCursorY()+1,scr->getCursorX()+1); 639 sprintf(tmp,"\033[%d;%dR",scr->getCursorY()+1,scr->getCursorX()+1);
640 sendString(tmp); 640 sendString(tmp);
641} 641}
642 642
643/* 643/*
644 What follows here is rather obsolete and faked stuff. 644 What follows here is rather obsolete and faked stuff.
645 The correspondent enquieries are neverthenless issued. 645 The correspondent enquieries are neverthenless issued.
646*/ 646*/
647 647
648/*! 648/*!
649*/ 649*/
650 650
651void Vt102Emulation::reportTerminalType() 651void Vt102Emulation::reportTerminalType()
652{ 652{
653//FIXME: should change? 653//FIXME: should change?
654 if (getMode(MODE_Ansi)) 654 if (getMode(MODE_Ansi))
655// sendString("\033[?1;2c"); // I'm a VT100 with AP0 //FIXME: send only in response to ^[[0c 655// sendString("\033[?1;2c"); // I'm a VT100 with AP0 //FIXME: send only in response to ^[[0c
656 sendString("\033[>0;115;0c"); // I'm a VT220 //FIXME: send only in response to ^[[>c 656 sendString("\033[>0;115;0c"); // I'm a VT220 //FIXME: send only in response to ^[[>c
657 else 657 else
658 sendString("\033/Z"); // I'm a VT52 658 sendString("\033/Z"); // I'm a VT52
659} 659}
660 660
661void Vt102Emulation::reportTerminalParms(int p) 661void Vt102Emulation::reportTerminalParms(int p)
662// DECREPTPARM 662// DECREPTPARM
663{ char tmp[100]; 663{ char tmp[100];
664 sprintf(tmp,"\033[%d;1;1;112;112;1;0x",p); // not really true. 664 sprintf(tmp,"\033[%d;1;1;112;112;1;0x",p); // not really true.
665 sendString(tmp); 665 sendString(tmp);
666} 666}
667 667
668/*! 668/*!
669*/ 669*/
670 670
671void Vt102Emulation::reportStatus() 671void Vt102Emulation::reportStatus()
672{ 672{
673 sendString("\033[0n"); //VT100. Device status report. 0 = Ready. 673 sendString("\033[0n"); //VT100. Device status report. 0 = Ready.
674} 674}
675 675
676/*! 676/*!
677*/ 677*/
678 678
679#define ANSWER_BACK "" // This is really obsolete VT100 stuff. 679#define ANSWER_BACK "" // This is really obsolete VT100 stuff.
680 680
681void Vt102Emulation::reportAnswerBack() 681void Vt102Emulation::reportAnswerBack()
682{ 682{
683 sendString(ANSWER_BACK); 683 sendString(ANSWER_BACK);
684} 684}
685 685
686// Mouse Handling ---------------------------------------------------------- -- 686// Mouse Handling ---------------------------------------------------------- --
687 687
688/*! 688/*!
689 Mouse clicks are possibly reported to the client 689 Mouse clicks are possibly reported to the client
690 application if it has issued interest in them. 690 application if it has issued interest in them.
691 They are normally consumed by the widget for copy 691 They are normally consumed by the widget for copy
692 and paste, but may be propagated from the widget 692 and paste, but may be propagated from the widget
693 when gui->setMouseMarks is set via setMode(MODE_Mouse1000). 693 when gui->setMouseMarks is set via setMode(MODE_Mouse1000).
694 694
695 `x',`y' are 1-based. 695 `x',`y' are 1-based.
696 `ev' (event) indicates the button pressed (0-2) 696 `ev' (event) indicates the button pressed (0-2)
697 or a general mouse release (3). 697 or a general mouse release (3).
698*/ 698*/
699 699
700void Vt102Emulation::onMouse( int cb, int cx, int cy ) 700void Vt102Emulation::onMouse( int cb, int cx, int cy )
701{ char tmp[20]; 701{ char tmp[20];
702 if (!connected) return; 702 if (!connected) return;
703 sprintf(tmp,"\033[M%c%c%c",cb+040,cx+040,cy+040); 703 sprintf(tmp,"\033[M%c%c%c",cb+040,cx+040,cy+040);
704 sendString(tmp); 704 sendString(tmp);
705} 705}
706 706
707// Keyboard Handling ------------------------------------------------------- -- 707// Keyboard Handling ------------------------------------------------------- --
708 708
709#define encodeMode(M,B) BITS(B,getMode(M)) 709#define encodeMode(M,B) BITS(B,getMode(M))
710#define encodeStat(M,B) BITS(B,((ev->state() & (M)) == (M))) 710#define encodeStat(M,B) BITS(B,((ev->state() & (M)) == (M)))
711 711
712/* 712/*
713 Keyboard event handling has been simplified somewhat by pushing 713 Keyboard event handling has been simplified somewhat by pushing
714 the complications towards a configuration file [see KeyTrans class]. 714 the complications towards a configuration file [see KeyTrans class].
715*/ 715*/
716 716
717void Vt102Emulation::onKeyPress( QKeyEvent* ev ) 717void Vt102Emulation::onKeyPress( QKeyEvent* ev )
718{ 718{
719 if (!connected) return; // someone else gets the keys 719 if (!connected) return; // someone else gets the keys
720 720
721//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); 721//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);
722 722
723 // revert to non-history when typing 723 // revert to non-history when typing
724 if (scr->getHistCursor() != scr->getHistLines()); 724 if (scr->getHistCursor() != scr->getHistLines());
725 scr->setHistCursor(scr->getHistLines()); 725 scr->setHistCursor(scr->getHistLines());
726 726
727 // lookup in keyboard translation table ... 727 // lookup in keyboard translation table ...
728 int cmd; const char* txt; int len; 728 int cmd; const char* txt; int len;
729 if (keytrans->findEntry(ev->key(), encodeMode(MODE_NewLine , BITS_NewLine ) + // OLD, 729 if (keytrans->findEntry(ev->key(), encodeMode(MODE_NewLine , BITS_NewLine ) + // OLD,
730 encodeMode(MODE_Ansi , BITS_Ansi ) + // OBSOLETE, 730 encodeMode(MODE_Ansi , BITS_Ansi ) + // OBSOLETE,
731 encodeMode(MODE_AppCuKeys, BITS_AppCuKeys ) + // VT100 stuff 731 encodeMode(MODE_AppCuKeys, BITS_AppCuKeys ) + // VT100 stuff
732 encodeStat(ControlButton , BITS_Control ) + 732 encodeStat(ControlButton , BITS_Control ) +
733 encodeStat(ShiftButton , BITS_Shift ) + 733 encodeStat(ShiftButton , BITS_Shift ) +
734 encodeStat(AltButton , BITS_Alt ), 734 encodeStat(AltButton , BITS_Alt ),
735 &cmd, &txt, &len )) 735 &cmd, &txt, &len ))
736//printf("cmd: %d, %s, %d\n",cmd,txt,len); 736//printf("cmd: %d, %s, %d\n",cmd,txt,len);
737 { 737 {
738 switch(cmd) // ... and execute if found. 738 switch(cmd) // ... and execute if found.
739 { 739 {
740 case CMD_emitSelection : gui->emitSelection(); return; 740 case CMD_emitSelection : gui->emitSelection(); return;
741 case CMD_scrollPageUp : gui->doScroll(-gui->Lines()/2); return; 741 case CMD_scrollPageUp : gui->doScroll(-gui->Lines()/2); return;
742 case CMD_scrollPageDown : gui->doScroll(+gui->Lines()/2); return; 742 case CMD_scrollPageDown : gui->doScroll(+gui->Lines()/2); return;
743 case CMD_scrollLineUp : gui->doScroll(-1 ); return; 743 case CMD_scrollLineUp : gui->doScroll(-1 ); return;
744 case CMD_scrollLineDown : gui->doScroll(+1 ); return; 744 case CMD_scrollLineDown : gui->doScroll(+1 ); return;
745 case CMD_send : sendString( txt ); return; 745 case CMD_send : sendString( txt ); return;
746 case CMD_prevSession : emit prevSession(); return; 746 case CMD_prevSession : emit prevSession(); return;
747 case CMD_nextSession : emit nextSession(); return; 747 case CMD_nextSession : emit nextSession(); return;
748 } 748 }
749 } 749 }
750 // fall back handling 750 // fall back handling
751 if (!ev->text().isEmpty()) 751 if (!ev->text().isEmpty())
752 { 752 {
753 if (ev->state() & AltButton) sendString("\033"); // ESC, this is the ALT prefix 753 if (ev->state() & AltButton) sendString("\033"); // ESC, this is the ALT prefix
754 /// very hacky 754 /// very hacky
755 if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='A')) sendString("\01"); 755 if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='A')) sendString("\01");
756 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='B')) sendString("\02"); 756 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='B')) sendString("\02");
757 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='C')) sendString("\03"); 757 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='C')) sendString("\03");
758 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='D')) sendString("\04"); 758 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='D')) sendString("\04");
759 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='E')) sendString("\05"); 759 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='E')) sendString("\05");
760 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='F')) sendString("\06"); 760 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='F')) sendString("\06");
761 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='G')) sendString("\07"); 761 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='G')) sendString("\07");
762 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='H')) sendString("\010"); 762 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='H')) sendString("\010");
763 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='I')) sendString("\011"); 763 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='I')) sendString("\011");
764 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='J')) sendString("\012"); 764 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='J')) sendString("\012");
765 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='K')) sendString("\013"); 765 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='K')) sendString("\013");
766 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='L')) sendString("\014"); 766 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='L')) sendString("\014");
767 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='M')) sendString("\015"); 767 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='M')) sendString("\015");
768 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='N')) sendString("\016"); 768 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='N')) sendString("\016");
769 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='O')) sendString("\017"); 769 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='O')) sendString("\017");
770 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='P')) sendString("\020"); 770 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='P')) sendString("\020");
771 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='Q')) sendString("\021"); 771 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='Q')) sendString("\021");
772 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='R')) sendString("\022"); 772 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='R')) sendString("\022");
773 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='S')) sendString("\023"); 773 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='S')) sendString("\023");
774 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='T')) sendString("\024"); 774 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='T')) sendString("\024");
775 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='U')) sendString("\025"); 775 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='U')) sendString("\025");
776 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='V')) sendString("\026"); 776 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='V')) sendString("\026");
777 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='W')) sendString("\027"); 777 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='W')) sendString("\027");
778 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='X')) sendString("\030"); 778 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='X')) sendString("\030");
779 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='Y')) sendString("\031"); 779 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='Y')) sendString("\031");
780 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='Z')) sendString("\032"); 780 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='Z')) sendString("\032");
781 else 781 else
782 { 782 {
783 QCString s = codec->fromUnicode(ev->text()); // encode for application 783 QCString s = codec->fromUnicode(ev->text()); // encode for application
784 sendString( s ); // we may well have s.length() > 1 784 sendString( s ); // we may well have s.length() > 1
785 } 785 }
786 return; 786 return;
787 } 787 }
788} 788}
789 789
790/* ------------------------------------------------------------------------- */ 790/* ------------------------------------------------------------------------- */
791/* */ 791/* */
792/* VT100 Charsets */ 792/* VT100 Charsets */
793/* */ 793/* */
794/* ------------------------------------------------------------------------- */ 794/* ------------------------------------------------------------------------- */
795 795
796// Character Set Conversion ------------------------------------------------ -- 796// Character Set Conversion ------------------------------------------------ --
797 797
798/* 798/*
799 The processing contains a VT100 specific code translation layer. 799 The processing contains a VT100 specific code translation layer.
800 It's still in use and mainly responsible for the line drawing graphics. 800 It's still in use and mainly responsible for the line drawing graphics.
801 801
802 These and some other glyphs are assigned to codes (0x5f-0xfe) 802 These and some other glyphs are assigned to codes (0x5f-0xfe)
803 normally occupied by the latin letters. Since this codes also 803 normally occupied by the latin letters. Since this codes also
804 appear within control sequences, the extra code conversion 804 appear within control sequences, the extra code conversion
805 does not permute with the tokenizer and is placed behind it 805 does not permute with the tokenizer and is placed behind it
806 in the pipeline. It only applies to tokens, which represent 806 in the pipeline. It only applies to tokens, which represent
807 plain characters. 807 plain characters.
808 808
809 This conversion it eventually continued in TEWidget.C, since 809 This conversion it eventually continued in TEWidget.C, since
810 it might involve VT100 enhanced fonts, which have these 810 it might involve VT100 enhanced fonts, which have these
811 particular glyphs allocated in (0x00-0x1f) in their code page. 811 particular glyphs allocated in (0x00-0x1f) in their code page.
812*/ 812*/
813 813
814#define CHARSET charset[scr==screen[1]] 814#define CHARSET charset[scr==screen[1]]
815 815
816// Apply current character map. 816// Apply current character map.
817 817
818unsigned short Vt102Emulation::applyCharset(unsigned short c) 818unsigned short Vt102Emulation::applyCharset(unsigned short c)
819{ 819{
820 if (CHARSET.graphic && 0x5f <= c && c <= 0x7e) return vt100_graphics[c-0x5f]; 820 if (CHARSET.graphic && 0x5f <= c && c <= 0x7e) return vt100_graphics[c-0x5f];
821 if (CHARSET.pound && c == '#' ) return 0xa3; //This mode is obsolete 821 if (CHARSET.pound && c == '#' ) return 0xa3; //This mode is obsolete
822 return c; 822 return c;
823} 823}
824 824
825/* 825/*
826 "Charset" related part of the emulation state. 826 "Charset" related part of the emulation state.
827 This configures the VT100 charset filter. 827 This configures the VT100 charset filter.
828 828
829 While most operation work on the current screen, 829 While most operation work on the current screen,
830 the following two are different. 830 the following two are different.
831*/ 831*/
832 832
833void Vt102Emulation::resetCharset(int scrno) 833void Vt102Emulation::resetCharset(int scrno)
834{ 834{
835 charset[scrno].cu_cs = 0; 835 charset[scrno].cu_cs = 0;
836 strncpy(charset[scrno].charset,"BBBB",4); 836 strncpy(charset[scrno].charset,"BBBB",4);
837 charset[scrno].sa_graphic = FALSE; 837 charset[scrno].sa_graphic = FALSE;
838 charset[scrno].sa_pound = FALSE; 838 charset[scrno].sa_pound = FALSE;
839 charset[scrno].graphic = FALSE; 839 charset[scrno].graphic = FALSE;
840 charset[scrno].pound = FALSE; 840 charset[scrno].pound = FALSE;
841} 841}
842 842
843/*! 843/*!
844*/ 844*/
845 845
846void Vt102Emulation::setCharset(int n, int cs) // on both screens. 846void Vt102Emulation::setCharset(int n, int cs) // on both screens.
847{ 847{
848 charset[0].charset[n&3] = cs; useCharset(charset[0].cu_cs); 848 charset[0].charset[n&3] = cs; useCharset(charset[0].cu_cs);
849 charset[1].charset[n&3] = cs; useCharset(charset[1].cu_cs); 849 charset[1].charset[n&3] = cs; useCharset(charset[1].cu_cs);
850} 850}
851 851
852/*! 852/*!
853*/ 853*/
854 854
855void Vt102Emulation::setAndUseCharset(int n, int cs) 855void Vt102Emulation::setAndUseCharset(int n, int cs)
856{ 856{
857 CHARSET.charset[n&3] = cs; 857 CHARSET.charset[n&3] = cs;
858 useCharset(n&3); 858 useCharset(n&3);
859} 859}
860 860
861/*! 861/*!
862*/ 862*/
863 863
864void Vt102Emulation::useCharset(int n) 864void Vt102Emulation::useCharset(int n)
865{ 865{
866 CHARSET.cu_cs = n&3; 866 CHARSET.cu_cs = n&3;
867 CHARSET.graphic = (CHARSET.charset[n&3] == '0'); 867 CHARSET.graphic = (CHARSET.charset[n&3] == '0');
868 CHARSET.pound = (CHARSET.charset[n&3] == 'A'); //This mode is obsolete 868 CHARSET.pound = (CHARSET.charset[n&3] == 'A'); //This mode is obsolete
869} 869}
870 870
871/*! Save the cursor position and the rendition attribute settings. */ 871/*! Save the cursor position and the rendition attribute settings. */
872 872
873void Vt102Emulation::saveCursor() 873void Vt102Emulation::saveCursor()
874{ 874{
875 CHARSET.sa_graphic = CHARSET.graphic; 875 CHARSET.sa_graphic = CHARSET.graphic;
876 CHARSET.sa_pound = CHARSET.pound; //This mode is obsolete 876 CHARSET.sa_pound = CHARSET.pound; //This mode is obsolete
877 // we are not clear about these 877 // we are not clear about these
878 //sa_charset = charsets[cScreen->charset]; 878 //sa_charset = charsets[cScreen->charset];
879 //sa_charset_num = cScreen->charset; 879 //sa_charset_num = cScreen->charset;
880 scr->saveCursor(); 880 scr->saveCursor();
881} 881}
882 882
883/*! Restore the cursor position and the rendition attribute settings. */ 883/*! Restore the cursor position and the rendition attribute settings. */
884 884
885void Vt102Emulation::restoreCursor() 885void Vt102Emulation::restoreCursor()
886{ 886{
887 CHARSET.graphic = CHARSET.sa_graphic; 887 CHARSET.graphic = CHARSET.sa_graphic;
888 CHARSET.pound = CHARSET.sa_pound; //This mode is obsolete 888 CHARSET.pound = CHARSET.sa_pound; //This mode is obsolete
889 scr->restoreCursor(); 889 scr->restoreCursor();
890} 890}
891 891
892/* ------------------------------------------------------------------------- */ 892/* ------------------------------------------------------------------------- */
893/* */ 893/* */
894/* Mode Operations */ 894/* Mode Operations */
895/* */ 895/* */
896/* ------------------------------------------------------------------------- */ 896/* ------------------------------------------------------------------------- */
897 897
898/* 898/*
899 Some of the emulations state is either added to the state of the screens. 899 Some of the emulations state is either added to the state of the screens.
900 900
901 This causes some scoping problems, since different emulations choose to 901 This causes some scoping problems, since different emulations choose to
902 located the mode either to the current screen or to both. 902 located the mode either to the current screen or to both.
903 903
904 For strange reasons, the extend of the rendition attributes ranges over 904 For strange reasons, the extend of the rendition attributes ranges over
905 all screens and not over the actual screen. 905 all screens and not over the actual screen.
906 906
907 We decided on the precise precise extend, somehow. 907 We decided on the precise precise extend, somehow.
908*/ 908*/
909 909
910// "Mode" related part of the state. These are all booleans. 910// "Mode" related part of the state. These are all booleans.
911 911
912void Vt102Emulation::resetModes() 912void Vt102Emulation::resetModes()
913{ 913{
914 resetMode(MODE_Mouse1000); saveMode(MODE_Mouse1000); 914 resetMode(MODE_Mouse1000); saveMode(MODE_Mouse1000);
915 resetMode(MODE_AppScreen); saveMode(MODE_AppScreen); 915 resetMode(MODE_AppScreen); saveMode(MODE_AppScreen);
916 // here come obsolete modes 916 // here come obsolete modes
917 resetMode(MODE_AppCuKeys); saveMode(MODE_AppCuKeys); 917 resetMode(MODE_AppCuKeys); saveMode(MODE_AppCuKeys);
918 resetMode(MODE_NewLine ); 918 resetMode(MODE_NewLine );
919 setMode(MODE_Ansi ); 919 setMode(MODE_Ansi );
920} 920}
921 921
922void Vt102Emulation::setMode(int m) 922void Vt102Emulation::setMode(int m)
923{ 923{
924 currParm.mode[m] = TRUE; 924 currParm.mode[m] = TRUE;
925 switch (m) 925 switch (m)
926 { 926 {
927 case MODE_Mouse1000 : gui->setMouseMarks(FALSE); 927 case MODE_Mouse1000 : gui->setMouseMarks(FALSE);
928 break; 928 break;
929 case MODE_AppScreen : screen[1]->clearSelection(); 929 case MODE_AppScreen : screen[1]->clearSelection();
930 screen[1]->clearEntireScreen(); 930 screen[1]->clearEntireScreen();
931 setScreen(1); 931 setScreen(1);
932 break; 932 break;
933 } 933 }
934 if (m < MODES_SCREEN || m == MODE_NewLine) 934 if (m < MODES_SCREEN || m == MODE_NewLine)
935 { 935 {
936 screen[0]->setMode(m); 936 screen[0]->setMode(m);
937 screen[1]->setMode(m); 937 screen[1]->setMode(m);
938 } 938 }
939} 939}
940 940
941void Vt102Emulation::resetMode(int m) 941void Vt102Emulation::resetMode(int m)
942{ 942{
943 currParm.mode[m] = FALSE; 943 currParm.mode[m] = FALSE;
944 switch (m) 944 switch (m)
945 { 945 {
946 case MODE_Mouse1000 : gui->setMouseMarks(TRUE); 946 case MODE_Mouse1000 : gui->setMouseMarks(TRUE);
947 break; 947 break;
948 case MODE_AppScreen : screen[0]->clearSelection(); 948 case MODE_AppScreen : screen[0]->clearSelection();
949 setScreen(0); 949 setScreen(0);
950 break; 950 break;
951 } 951 }
952 if (m < MODES_SCREEN || m == MODE_NewLine) 952 if (m < MODES_SCREEN || m == MODE_NewLine)
953 { 953 {
954 screen[0]->resetMode(m); 954 screen[0]->resetMode(m);
955 screen[1]->resetMode(m); 955 screen[1]->resetMode(m);
956 } 956 }
957} 957}
958 958
959void Vt102Emulation::saveMode(int m) 959void Vt102Emulation::saveMode(int m)
960{ 960{
961 saveParm.mode[m] = currParm.mode[m]; 961 saveParm.mode[m] = currParm.mode[m];
962} 962}
963 963
964void Vt102Emulation::restoreMode(int m) 964void Vt102Emulation::restoreMode(int m)
965{ 965{
966 if(saveParm.mode[m]) setMode(m); else resetMode(m); 966 if(saveParm.mode[m]) setMode(m); else resetMode(m);
967} 967}
968 968
969BOOL Vt102Emulation::getMode(int m) 969BOOL Vt102Emulation::getMode(int m)
970{ 970{
971 return currParm.mode[m]; 971 return currParm.mode[m];
972} 972}
973 973
974void Vt102Emulation::setConnect(bool c) 974void Vt102Emulation::setConnect(bool c)
975{ 975{
976 EmulationLayer::setConnect(c); 976 EmulationLayer::setConnect(c);
977 if (c) 977 if (c)
978 { // refresh mouse mode 978 { // refresh mouse mode
979 if (getMode(MODE_Mouse1000)) 979 if (getMode(MODE_Mouse1000))
980 setMode(MODE_Mouse1000); 980 setMode(MODE_Mouse1000);
981 else 981 else
982 resetMode(MODE_Mouse1000); 982 resetMode(MODE_Mouse1000);
983 } 983 }
984} 984}
985 985
986/* ------------------------------------------------------------------------- */ 986/* ------------------------------------------------------------------------- */
987/* */ 987/* */
988/* Diagnostic */ 988/* Diagnostic */
989/* */ 989/* */
990/* ------------------------------------------------------------------------- */ 990/* ------------------------------------------------------------------------- */
991 991
992/*! shows the contents of the scan buffer. 992/*! shows the contents of the scan buffer.
993 993
994 This functions is used for diagnostics. It is called by \e ReportErrorToken 994 This functions is used for diagnostics. It is called by \e ReportErrorToken
995 to inform about strings that cannot be decoded or handled by the emulation. 995 to inform about strings that cannot be decoded or handled by the emulation.
996 996
997 \sa ReportErrorToken 997 \sa ReportErrorToken
998*/ 998*/
999 999
1000/*! 1000/*!
1001*/ 1001*/
1002 1002
1003static void hexdump(int* s, int len) 1003static void hexdump(int* s, int len)
1004{ int i; 1004{ int i;
1005 for (i = 0; i < len; i++) 1005 for (i = 0; i < len; i++)
1006 { 1006 {
1007 if (s[i] == '\\') 1007 if (s[i] == '\\')
1008 printf("\\\\"); 1008 printf("\\\\");
1009 else 1009 else
1010 if ((s[i]) > 32 && s[i] < 127) 1010 if ((s[i]) > 32 && s[i] < 127)
1011 printf("%c",s[i]); 1011 printf("%c",s[i]);
1012 else 1012 else
1013 printf("\\%04x(hex)",s[i]); 1013 printf("\\%04x(hex)",s[i]);
1014 } 1014 }
1015} 1015}
1016 1016
1017void Vt102Emulation::scan_buffer_report() 1017void Vt102Emulation::scan_buffer_report()
1018{ 1018{
1019 if (ppos == 0 || ppos == 1 && (pbuf[0] & 0xff) >= 32) return; 1019 if (ppos == 0 || ppos == 1 && (pbuf[0] & 0xff) >= 32) return;
1020 printf("token: "); hexdump(pbuf,ppos); printf("\n"); 1020 printf("token: "); hexdump(pbuf,ppos); printf("\n");
1021} 1021}
1022 1022
1023/*! 1023/*!
1024*/ 1024*/
1025 1025
1026void Vt102Emulation::ReportErrorToken() 1026void Vt102Emulation::ReportErrorToken()
1027{ 1027{
1028 printf("undecodable "); scan_buffer_report(); 1028 printf("undecodable "); scan_buffer_report();
1029} 1029}
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 @@
1/* -------------------------------------------------------------------------- */ 1/* -------------------------------------------------------------------------- */
2/* */ 2/* */
3/* [TEmuVt102.h] X Terminal Emulation */ 3/* [TEmuVt102.h] X Terminal Emulation */
4/* */ 4/* */
5/* -------------------------------------------------------------------------- */ 5/* -------------------------------------------------------------------------- */
6/* */ 6/* */
7/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ 7/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */
8/* */ 8/* */
9/* This file is part of Konsole - an X terminal for KDE */ 9/* This file is part of Konsole - an X terminal for KDE */
10/* */ 10/* */
11/* -------------------------------------------------------------------------- */ 11/* -------------------------------------------------------------------------- */
12 /* */ 12 /* */
13/* Ported Konsole to Qt/Embedded */ 13/* Ported Konsole to Qt/Embedded */
14 /* */ 14 /* */
15/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ 15/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */
16 /* */ 16 /* */
17/* -------------------------------------------------------------------------- */ 17/* -------------------------------------------------------------------------- */
18/* Ported embedded-konsole to opie-terminal */ 18/* Ported embedded-konsole to opie-terminal */
19 /* */ 19 /* */
20/* Copyright (C) 2002 by opie developers <opie@handhelds.org> */ 20/* Copyright (C) 2002 by opie developers <opie@handhelds.org> */
21 /* */ 21 /* */
22/* -------------------------------------------------------------------------- */ 22/* -------------------------------------------------------------------------- */
23 23
24#ifndef VT102EMU_H 24#ifndef VT102EMU_H
25#define VT102EMU_H 25#define VT102EMU_H
26 26
27#include "widget.h" 27#include "widget.h"
28#include "screen.h" 28#include "screen.h"
29#include "emulation_layer.h" 29#include "emulation_layer.h"
30#include <qtimer.h> 30#include <qtimer.h>
31#include <stdio.h> 31#include <stdio.h>
32 32
33// 33//
34 34
35#define MODE_AppScreen (MODES_SCREEN+0) 35#define MODE_AppScreen (MODES_SCREEN+0)
36#define MODE_AppCuKeys (MODES_SCREEN+1) 36#define MODE_AppCuKeys (MODES_SCREEN+1)
37#define MODE_AppKeyPad (MODES_SCREEN+2) 37#define MODE_AppKeyPad (MODES_SCREEN+2)
38#define MODE_Mouse1000 (MODES_SCREEN+3) 38#define MODE_Mouse1000 (MODES_SCREEN+3)
39#define MODE_Ansi (MODES_SCREEN+4) 39#define MODE_Ansi (MODES_SCREEN+4)
40#define MODE_total (MODES_SCREEN+5) 40#define MODE_total (MODES_SCREEN+5)
41 41
42struct DECpar 42struct DECpar
43{ 43{
44 BOOL mode[MODE_total]; 44 BOOL mode[MODE_total];
45}; 45};
46 46
47struct CharCodes 47struct CharCodes
48{ 48{
49 // coding info 49 // coding info
50 char charset[4]; // 50 char charset[4]; //
51 int cu_cs; // actual charset. 51 int cu_cs; // actual charset.
52 bool graphic; // Some VT100 tricks 52 bool graphic; // Some VT100 tricks
53 bool pound ; // Some VT100 tricks 53 bool pound ; // Some VT100 tricks
54 bool sa_graphic; // saved graphic 54 bool sa_graphic; // saved graphic
55 bool sa_pound; // saved pound 55 bool sa_pound; // saved pound
56}; 56};
57 57
58class Vt102Emulation: public EmulationLayer 58class Vt102Emulation: public EmulationLayer
59{ Q_OBJECT 59{ Q_OBJECT
60 60
61public: 61public:
62 62
63 Vt102Emulation(Widget* gui); 63 Vt102Emulation(Widget* gui);
64 ~Vt102Emulation(); 64 ~Vt102Emulation();
65 65
66public slots: // signals incoming from Widget 66public slots: // signals incoming from Widget
67 67
68 void onKeyPress(QKeyEvent*); 68 void onKeyPress(QKeyEvent*);
69 void onMouse(int cb, int cx, int cy); 69 void onMouse(int cb, int cx, int cy);
70 70
71signals: 71signals:
72 72
73 void changeTitle(int,const QString&); 73 void changeTitle(int,const QString&);
74 void prevSession(); 74 void prevSession();
75 void nextSession(); 75 void nextSession();
76 76
77public: 77public:
78 78
79 void reset(); 79 void reset();
80 80
81 /** 81 /**
82 * receive a char from IOLayer 82 * receive a char from IOLayer
83 */ 83 */
84 void onRcvChar(int cc); 84 void onRcvChar(int cc);
85 85
86 /** 86 /**
87 * sends a list of bytes to the IOLayer 87 * sends a list of bytes to the IOLayer
88 */ 88 */
89 void sendString(const QByteArray); 89 void sendString(const QByteArray&);
90 90
91 /** 91 /**
92 * @deprecated use QByteArray instead 92 * @deprecated use QByteArray instead
93 * see sendString() above 93 * see sendString() above
94 */ 94 */
95 void sendString(const char *); 95 void sendString(const char *);
96 96
97public: 97public:
98 98
99 BOOL getMode (int m); 99 BOOL getMode (int m);
100 100
101 void setMode (int m); 101 void setMode (int m);
102 void resetMode (int m); 102 void resetMode (int m);
103 void saveMode (int m); 103 void saveMode (int m);
104 void restoreMode(int m); 104 void restoreMode(int m);
105 void resetModes(); 105 void resetModes();
106 106
107 void setConnect(bool r); 107 void setConnect(bool r);
108 108
109private: 109private:
110 110
111 void resetToken(); 111 void resetToken();
112#define MAXPBUF 80 112#define MAXPBUF 80
113 void pushToToken(int cc); 113 void pushToToken(int cc);
114 int pbuf[MAXPBUF]; //FIXME: overflow? 114 int pbuf[MAXPBUF]; //FIXME: overflow?
115 int ppos; 115 int ppos;
116#define MAXARGS 15 116#define MAXARGS 15
117 void addDigit(int dig); 117 void addDigit(int dig);
118 void addArgument(); 118 void addArgument();
119 int argv[MAXARGS]; 119 int argv[MAXARGS];
120 int argc; 120 int argc;
121 void initTokenizer(); 121 void initTokenizer();
122 int tbl[256]; 122 int tbl[256];
123 123
124 void scan_buffer_report(); //FIXME: rename 124 void scan_buffer_report(); //FIXME: rename
125 void ReportErrorToken(); //FIXME: rename 125 void ReportErrorToken(); //FIXME: rename
126 126
127 void tau(int code, int p, int q); 127 void tau(int code, int p, int q);
128 void XtermHack(); 128 void XtermHack();
129 129
130 // 130 //
131 131
132 void reportTerminalType(); 132 void reportTerminalType();
133 void reportStatus(); 133 void reportStatus();
134 void reportAnswerBack(); 134 void reportAnswerBack();
135 void reportCursorPosition(); 135 void reportCursorPosition();
136 void reportTerminalParms(int p); 136 void reportTerminalParms(int p);
137 137
138protected: 138protected:
139 139
140 unsigned short applyCharset(unsigned short c); 140 unsigned short applyCharset(unsigned short c);
141 void setCharset(int n, int cs); 141 void setCharset(int n, int cs);
142 void useCharset(int n); 142 void useCharset(int n);
143 void setAndUseCharset(int n, int cs); 143 void setAndUseCharset(int n, int cs);
144 void saveCursor(); 144 void saveCursor();
145 void restoreCursor(); 145 void restoreCursor();
146 void resetCharset(int scrno); 146 void resetCharset(int scrno);
147 CharCodes charset[2]; 147 CharCodes charset[2];
148 148
149 DECpar currParm; 149 DECpar currParm;
150 DECpar saveParm; 150 DECpar saveParm;
151}; 151};
152 152
153#endif // ifndef ANSIEMU_H 153#endif // ifndef ANSIEMU_H