summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/common.h10
-rw-r--r--noncore/apps/opie-console/emulation_layer.cpp48
-rw-r--r--noncore/apps/opie-console/emulation_layer.h6
-rw-r--r--noncore/apps/opie-console/screen.cpp22
-rw-r--r--noncore/apps/opie-console/screen.h6
-rw-r--r--noncore/apps/opie-console/vt102emulation.cpp18
-rw-r--r--noncore/apps/opie-console/vt102emulation.h2
-rw-r--r--noncore/apps/opie-console/widget_layer.h11
8 files changed, 68 insertions, 55 deletions
diff --git a/noncore/apps/opie-console/common.h b/noncore/apps/opie-console/common.h
index 979c2bd..a621ff5 100644
--- a/noncore/apps/opie-console/common.h
+++ b/noncore/apps/opie-console/common.h
@@ -1,114 +1,114 @@
1/* -------------------------------------------------------------------------- */ 1/* -------------------------------------------------------------------------- */
2/* */ 2/* */
3/* [TECommon.h] Common Definitions */ 3/* [Common.h] Common Definitions */
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/*! \file TECommon.h 19/*! \file Common.h
20 \brief Definitions shared between TEScreen and TEWidget. 20 \brief Definitions shared between TEScreen and TEWidget.
21*/ 21*/
22 22
23#ifndef TECOMMON_H 23#ifndef COMMON_H
24#define TECOMMON_H 24#define COMMON_H
25 25
26#include <qcolor.h> 26#include <qcolor.h>
27 27
28#ifndef BOOL 28#ifndef BOOL
29typedef bool BOOL; 29typedef bool BOOL;
30#endif 30#endif
31 31
32#ifndef FALSE 32#ifndef FALSE
33#define FALSE 0 33#define FALSE 0
34#endif 34#endif
35 35
36#ifndef TRUE 36#ifndef TRUE
37#define TRUE 1 37#define TRUE 1
38#endif 38#endif
39 39
40#ifndef UINT8 40#ifndef UINT8
41typedef unsigned char UINT8; 41typedef unsigned char UINT8;
42#endif 42#endif
43 43
44#ifndef UINT16 44#ifndef UINT16
45typedef unsigned short UINT16; 45typedef unsigned short UINT16;
46#endif 46#endif
47 47
48// Attributed Character Representations /////////////////////////////// 48// Attributed Character Representations ///////////////////////////////
49 49
50// Colors 50// Colors
51 51
52#define BASE_COLORS (2+8) 52#define BASE_COLORS (2+8)
53#define INTENSITIES 2 53#define INTENSITIES 2
54#define TABLE_COLORS (INTENSITIES*BASE_COLORS) 54#define TABLE_COLORS (INTENSITIES*BASE_COLORS)
55 55
56#define DEFAULT_FORE_COLOR 0 56#define DEFAULT_FORE_COLOR 0
57#define DEFAULT_BACK_COLOR 1 57#define DEFAULT_BACK_COLOR 1
58 58
59#define DEFAULT_RENDITION 0 59#define DEFAULT_RENDITION 0
60#define RE_BOLD (1 << 0) 60#define RE_BOLD (1 << 0)
61#define RE_BLINK (1 << 1) 61#define RE_BLINK (1 << 1)
62#define RE_UNDERLINE (1 << 2) 62#define RE_UNDERLINE (1 << 2)
63#define RE_REVERSE (1 << 3) // Screen only 63#define RE_REVERSE (1 << 3) // Screen only
64#define RE_INTENSIVE (1 << 3) // Widget only 64#define RE_INTENSIVE (1 << 3) // Widget only
65 65
66/*! \class Character 66/*! \class Character
67 * \brief a character with rendition attributes. 67 * \brief a character with rendition attributes.
68*/ 68*/
69 69
70class Character 70class Character
71{ 71{
72public: 72public:
73 inline Character(UINT16 _c = ' ', 73 inline Character(UINT16 _c = ' ',
74 UINT8 _f = DEFAULT_FORE_COLOR, 74 UINT8 _f = DEFAULT_FORE_COLOR,
75 UINT8 _b = DEFAULT_BACK_COLOR, 75 UINT8 _b = DEFAULT_BACK_COLOR,
76 UINT8 _r = DEFAULT_RENDITION) 76 UINT8 _r = DEFAULT_RENDITION)
77 : c(_c), f(_f), b(_b), r(_r) {} 77 : c(_c), f(_f), b(_b), r(_r) {}
78public: 78public:
79 UINT16 c; // character 79 UINT16 c; // character
80 UINT8 f; // foreground color 80 UINT8 f; // foreground color
81 UINT8 b; // background color 81 UINT8 b; // background color
82 UINT8 r; // rendition 82 UINT8 r; // rendition
83public: 83public:
84 friend BOOL operator == (Character a, Character b); 84 friend BOOL operator == (Character a, Character b);
85 friend BOOL operator != (Character a, Character b); 85 friend BOOL operator != (Character a, Character b);
86}; 86};
87 87
88inline BOOL operator == (Character a, Character b) 88inline BOOL operator == (Character a, Character b)
89{ 89{
90 return a.c == b.c && a.f == b.f && a.b == b.b && a.r == b.r; 90 return a.c == b.c && a.f == b.f && a.b == b.b && a.r == b.r;
91} 91}
92 92
93inline BOOL operator != (Character a, Character b) 93inline BOOL operator != (Character a, Character b)
94{ 94{
95 return a.c != b.c || a.f != b.f || a.b != b.b || a.r != b.r; 95 return a.c != b.c || a.f != b.f || a.b != b.b || a.r != b.r;
96} 96}
97 97
98/*! 98/*!
99*/ 99*/
100struct ColorEntry 100struct ColorEntry
101{ 101{
102 ColorEntry(QColor c, bool tr, bool b) : color(c), transparent(tr), bold(b) {} 102 ColorEntry(QColor c, bool tr, bool b) : color(c), transparent(tr), bold(b) {}
103 ColorEntry() : transparent(false), bold(false) {} // default constructors 103 ColorEntry() : transparent(false), bold(false) {} // default constructors
104 void operator=(const ColorEntry& rhs) { 104 void operator=(const ColorEntry& rhs) {
105 color = rhs.color; 105 color = rhs.color;
106 transparent = rhs.transparent; 106 transparent = rhs.transparent;
107 bold = rhs.bold; 107 bold = rhs.bold;
108 } 108 }
109 QColor color; 109 QColor color;
110 bool transparent; // if used on bg 110 bool transparent; // if used on bg
111 bool bold; // if used on fg 111 bool bold; // if used on fg
112}; 112};
113 113
114#endif // TECOMMON_H 114#endif // COMMON_H
diff --git a/noncore/apps/opie-console/emulation_layer.cpp b/noncore/apps/opie-console/emulation_layer.cpp
index 6c420e0..5baf05c 100644
--- a/noncore/apps/opie-console/emulation_layer.cpp
+++ b/noncore/apps/opie-console/emulation_layer.cpp
@@ -1,372 +1,372 @@
1/* -------------------------------------------------------------------------- */ 1/* -------------------------------------------------------------------------- */
2/* */ 2/* */
3/* [emulation_layer.cpp] Terminal Emulation Decoder */ 3/* [emulation_layer.cpp] Terminal Emulation Decoder */
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/* Modified to suit opie-console */ 19/* Modified to suit opie-console */
20 /* */ 20 /* */
21/* Copyright (C) 2002 by opie developers <opie@handhelds.org> */ 21/* Copyright (C) 2002 by opie developers <opie@handhelds.org> */
22 /* */ 22 /* */
23/* -------------------------------------------------------------------------- */ 23/* -------------------------------------------------------------------------- */
24 24
25/*! \class EmulationLayer 25/*! \class EmulationLayer
26 26
27 \brief Mediator between Widget and Screen. 27 \brief Mediator between Widget and Screen.
28 28
29 This class is responsible to scan the escapes sequences of the terminal 29 This class is responsible to scan the escapes sequences of the terminal
30 emulation and to map it to their corresponding semantic complements. 30 emulation and to map it to their corresponding semantic complements.
31 Thus this module knows mainly about decoding escapes sequences and 31 Thus this module knows mainly about decoding escapes sequences and
32 is a stateless device w.r.t. the semantics. 32 is a stateless device w.r.t. the semantics.
33 33
34 It is also responsible to refresh the Widget by certain rules. 34 It is also responsible to refresh the Widget by certain rules.
35 35
36 \sa Widget \sa Screen 36 \sa Widget \sa Screen
37 37
38 \par A note on refreshing 38 \par A note on refreshing
39 39
40 Although the modifications to the current screen image could immediately 40 Although the modifications to the current screen image could immediately
41 be propagated via `Widget' to the graphical surface, we have chosen 41 be propagated via `Widget' to the graphical surface, we have chosen
42 another way here. 42 another way here.
43 43
44 The reason for doing so is twofold. 44 The reason for doing so is twofold.
45 45
46 First, experiments show that directly displaying the operation results 46 First, experiments show that directly displaying the operation results
47 in slowing down the overall performance of emulations. Displaying 47 in slowing down the overall performance of emulations. Displaying
48 individual characters using X11 creates a lot of overhead. 48 individual characters using X11 creates a lot of overhead.
49 49
50 Second, by using the following refreshing method, the screen operations 50 Second, by using the following refreshing method, the screen operations
51 can be completely separated from the displaying. This greatly simplifies 51 can be completely separated from the displaying. This greatly simplifies
52 the programmer's task of coding and maintaining the screen operations, 52 the programmer's task of coding and maintaining the screen operations,
53 since one need not worry about differential modifications on the 53 since one need not worry about differential modifications on the
54 display affecting the operation of concern. 54 display affecting the operation of concern.
55 55
56 We use a refreshing algorithm here that has been adoped from rxvt/kvt. 56 We use a refreshing algorithm here that has been adoped from rxvt/kvt.
57 57
58 By this, refreshing is driven by a timer, which is (re)started whenever 58 By this, refreshing is driven by a timer, which is (re)started whenever
59 a new bunch of data to be interpreted by the emulation arives at `onRcvBlock'. 59 a new bunch of data to be interpreted by the emulation arives at `onRcvBlock'.
60 As soon as no more data arrive for `BULK_TIMEOUT' milliseconds, we trigger 60 As soon as no more data arrive for `BULK_TIMEOUT' milliseconds, we trigger
61 refresh. This rule suits both bulk display operation as done by curses as 61 refresh. This rule suits both bulk display operation as done by curses as
62 well as individual characters typed. 62 well as individual characters typed.
63 (BULK_TIMEOUT < 1000 / max characters received from keyboard per second). 63 (BULK_TIMEOUT < 1000 / max characters received from keyboard per second).
64 64
65 Additionally, we trigger refreshing by newlines comming in to make visual 65 Additionally, we trigger refreshing by newlines comming in to make visual
66 snapshots of lists as produced by `cat', `ls' and likely programs, thereby 66 snapshots of lists as produced by `cat', `ls' and likely programs, thereby
67 producing the illusion of a permanent and immediate display operation. 67 producing the illusion of a permanent and immediate display operation.
68 68
69 As a sort of catch-all needed for cases where none of the above 69 As a sort of catch-all needed for cases where none of the above
70 conditions catch, the screen refresh is also triggered by a count 70 conditions catch, the screen refresh is also triggered by a count
71 of incoming bulks (`bulk_incnt'). 71 of incoming bulks (`bulk_incnt').
72*/ 72*/
73 73
74/* FIXME 74/* FIXME
75 - evtl. the bulk operations could be made more transparent. 75 - evtl. the bulk operations could be made more transparent.
76*/ 76*/
77 77
78#include "emulation_layer.h" 78#include "emulation_layer.h"
79#include "widget.h" 79#include "widget_layer.h"
80#include "screen.h" 80#include "screen.h"
81#include <stdio.h> 81#include <stdio.h>
82#include <stdlib.h> 82#include <stdlib.h>
83#include <unistd.h> 83#include <unistd.h>
84#include <qkeycode.h> 84#include <qkeycode.h>
85 85
86 86
87/* ------------------------------------------------------------------------- */ 87/* ------------------------------------------------------------------------- */
88/* */ 88/* */
89/* EmulationLayer */ 89/* EmulationLayer */
90/* */ 90/* */
91/* ------------------------------------------------------------------------- */ 91/* ------------------------------------------------------------------------- */
92 92
93#define CNTL(c) ((c)-'@') 93#define CNTL(c) ((c)-'@')
94 94
95/*! 95/*!
96*/ 96*/
97 97
98EmulationLayer::EmulationLayer(Widget* gui) 98EmulationLayer::EmulationLayer( WidgetLayer* gui )
99: decoder((QTextDecoder*)NULL) 99: decoder((QTextDecoder*)NULL)
100{ 100{
101 this->gui = gui; 101 this->gui = gui;
102 102
103 screen[0] = new Screen(gui->Lines(),gui->Columns()); 103 screen[0] = new Screen(gui->lines(),gui->columns());
104 screen[1] = new Screen(gui->Lines(),gui->Columns()); 104 screen[1] = new Screen(gui->lines(),gui->columns());
105 scr = screen[0]; 105 scr = screen[0];
106 106
107 bulk_nlcnt = 0; // reset bulk newline counter 107 bulk_nlcnt = 0; // reset bulk newline counter
108 bulk_incnt = 0; // reset bulk counter 108 bulk_incnt = 0; // reset bulk counter
109 connected = FALSE; 109 connected = FALSE;
110 110
111 QObject::connect(&bulk_timer, SIGNAL(timeout()), this, SLOT(showBulk()) ); 111 QObject::connect(&bulk_timer, SIGNAL( timeout() ), this, SLOT( showBulk() ) );
112 QObject::connect(gui,SIGNAL(changedImageSizeSignal(int,int)), 112 QObject::connect(gui,SIGNAL( imageSizeChanged( int, int ) ),
113 this,SLOT(onImageSizeChange(int,int))); 113 this,SLOT( onImageSizeChange( int, int ) ) );
114 QObject::connect(gui,SIGNAL(changedHistoryCursor(int)), 114 QObject::connect(gui,SIGNAL( changedHistoryCursor( int ) ),
115 this,SLOT(onHistoryCursorChange(int))); 115 this,SLOT( historyCursorChange( int ) ) );
116 QObject::connect(gui,SIGNAL(keyPressedSignal(QKeyEvent*)), 116 QObject::connect(gui,SIGNAL( keyPressed( QKeyEvent* ) ),
117 this,SLOT(onKeyPress(QKeyEvent*))); 117 this,SLOT( onKeyPress( QKeyEvent* ) ) );
118 QObject::connect(gui,SIGNAL(beginSelectionSignal(const int,const int)), 118 QObject::connect(gui,SIGNAL( selectionBegin( const int, const int) ),
119 this,SLOT(onSelectionBegin(const int,const int)) ); 119 this,SLOT( onSelectionBegin( const int, const int ) ) );
120 QObject::connect(gui,SIGNAL(extendSelectionSignal(const int,const int)), 120 QObject::connect(gui,SIGNAL( selectionExtended( const int, const int ) ),
121 this,SLOT(onSelectionExtend(const int,const int)) ); 121 this,SLOT( onSelectionExtend( const int,const int ) ) );
122 QObject::connect(gui,SIGNAL(endSelectionSignal(const BOOL)), 122 QObject::connect(gui,SIGNAL( selectionEnd( const bool ) ),
123 this,SLOT(setSelection(const BOOL)) ); 123 this,SLOT( setSelection( const bool ) ) );
124 QObject::connect(gui,SIGNAL(clearSelectionSignal()), 124 QObject::connect(gui,SIGNAL( selectionCleared() ),
125 this,SLOT(clearSelection()) ); 125 this,SLOT( clearSelection() ) );
126} 126}
127 127
128/*! 128/*!
129*/ 129*/
130 130
131EmulationLayer::~EmulationLayer() 131EmulationLayer::~EmulationLayer()
132{ 132{
133 delete screen[0]; 133 delete screen[0];
134 delete screen[1]; 134 delete screen[1];
135 bulk_timer.stop(); 135 bulk_timer.stop();
136} 136}
137 137
138/*! change between primary and alternate screen 138/*! change between primary and alternate screen
139*/ 139*/
140 140
141void EmulationLayer::setScreen(int n) 141void EmulationLayer::setScreen(int n)
142{ 142{
143 scr = screen[n&1]; 143 scr = screen[n&1];
144} 144}
145 145
146void EmulationLayer::setHistory(bool on) 146void EmulationLayer::setHistory(bool on)
147{ 147{
148 screen[0]->setScroll(on); 148 screen[0]->setScroll(on);
149 if (!connected) return; 149 if (!connected) return;
150 showBulk(); 150 showBulk();
151} 151}
152 152
153bool EmulationLayer::history() 153bool EmulationLayer::history()
154{ 154{
155 return screen[0]->hasScroll(); 155 return screen[0]->hasScroll();
156} 156}
157 157
158void EmulationLayer::setCodec(int c) 158void EmulationLayer::setCodec(int c)
159{ 159{
160 //FIXME: check whether we have to free codec 160 //FIXME: check whether we have to free codec
161 codec = c ? QTextCodec::codecForName("utf8") 161 codec = c ? QTextCodec::codecForName("utf8")
162 : QTextCodec::codecForLocale(); 162 : QTextCodec::codecForLocale();
163 if (decoder) delete decoder; 163 if (decoder) delete decoder;
164 decoder = codec->makeDecoder(); 164 decoder = codec->makeDecoder();
165} 165}
166 166
167void EmulationLayer::setKeytrans(int no) 167void EmulationLayer::setKeytrans(int no)
168{ 168{
169 keytrans = KeyTrans::find(no); 169 keytrans = KeyTrans::find(no);
170} 170}
171 171
172void EmulationLayer::setKeytrans(const char * no) 172void EmulationLayer::setKeytrans(const char * no)
173{ 173{
174 keytrans = KeyTrans::find(no); 174 keytrans = KeyTrans::find(no);
175} 175}
176 176
177// Interpreting Codes --------------------------------------------------------- 177// Interpreting Codes ---------------------------------------------------------
178 178
179/* 179/*
180 This section deals with decoding the incoming character stream. 180 This section deals with decoding the incoming character stream.
181 Decoding means here, that the stream is first seperated into `tokens' 181 Decoding means here, that the stream is first seperated into `tokens'
182 which are then mapped to a `meaning' provided as operations by the 182 which are then mapped to a `meaning' provided as operations by the
183 `Screen' class. 183 `Screen' class.
184*/ 184*/
185 185
186/*! 186/*!
187*/ 187*/
188 188
189void EmulationLayer::onRcvChar(int c) 189void EmulationLayer::onRcvChar(int c)
190// process application unicode input to terminal 190// process application unicode input to terminal
191// this is a trivial scanner 191// this is a trivial scanner
192{ 192{
193 c &= 0xff; 193 c &= 0xff;
194 switch (c) 194 switch (c)
195 { 195 {
196 case '\b' : scr->BackSpace(); break; 196 case '\b' : scr->BackSpace(); break;
197 case '\t' : scr->Tabulate(); break; 197 case '\t' : scr->Tabulate(); break;
198 case '\n' : scr->NewLine(); break; 198 case '\n' : scr->NewLine(); break;
199 case '\r' : scr->Return(); break; 199 case '\r' : scr->Return(); break;
200 case 0x07 : gui->Bell(); break; 200 case 0x07 : gui->bell(); break;
201 default : scr->ShowCharacter(c); break; 201 default : scr->ShowCharacter(c); break;
202 }; 202 };
203} 203}
204 204
205/* ------------------------------------------------------------------------- */ 205/* ------------------------------------------------------------------------- */
206/* */ 206/* */
207/* Keyboard Handling */ 207/* Keyboard Handling */
208/* */ 208/* */
209/* ------------------------------------------------------------------------- */ 209/* ------------------------------------------------------------------------- */
210 210
211/*! 211/*!
212*/ 212*/
213 213
214void EmulationLayer::onKeyPress( QKeyEvent* ev ) 214void EmulationLayer::onKeyPress( QKeyEvent* ev )
215{ 215{
216 if (!connected) return; // someone else gets the keys 216 if (!connected) return; // someone else gets the keys
217 if (scr->getHistCursor() != scr->getHistLines()); 217 if (scr->getHistCursor() != scr->getHistLines());
218 scr->setHistCursor(scr->getHistLines()); 218 scr->setHistCursor(scr->getHistLines());
219 if (!ev->text().isEmpty()) 219 if (!ev->text().isEmpty())
220 { // A block of text 220 { // A block of text
221 // Note that the text is proper unicode. 221 // Note that the text is proper unicode.
222 // We should do a conversion here, but since this 222 // We should do a conversion here, but since this
223 // routine will never be used, we simply emit plain ascii. 223 // routine will never be used, we simply emit plain ascii.
224 sendString( ev->text().ascii() ); //,ev->text().length()); 224 sendString( ev->text().ascii() ); //,ev->text().length());
225 } 225 }
226 else if (ev->ascii()>0) 226 else if (ev->ascii()>0)
227 { 227 {
228 QByteArray c = QByteArray( 1 ); 228 QByteArray c = QByteArray( 1 );
229 c.at( 0 ) = ev->ascii(); 229 c.at( 0 ) = ev->ascii();
230 // ibot: qbytearray is emited not char* 230 // ibot: qbytearray is emited not char*
231 emit sndBlock( (QByteArray) c ); 231 emit sndBlock( (QByteArray) c );
232 } 232 }
233} 233}
234 234
235// Unblocking, Byte to Unicode translation --------------------------------- -- 235// Unblocking, Byte to Unicode translation --------------------------------- --
236 236
237/* 237/*
238 We are doing code conversion from locale to unicode first. 238 We are doing code conversion from locale to unicode first.
239*/ 239*/
240 240
241void EmulationLayer::onRcvBlock(const QByteArray &s ) 241void EmulationLayer::onRcvBlock(const QByteArray &s )
242{ 242{
243 bulkStart(); 243 bulkStart();
244 bulk_incnt += 1; 244 bulk_incnt += 1;
245 for (int i = 0; i < s.size(); i++) 245 for (int i = 0; i < s.size(); i++)
246 { 246 {
247 //TODO: ibot: maybe decoding qbytearray to unicode in io_layer? 247 //TODO: ibot: maybe decoding qbytearray to unicode in io_layer?
248 QString result = decoder->toUnicode(&s[i],1); 248 QString result = decoder->toUnicode(&s[i],1);
249 int reslen = result.length(); 249 int reslen = result.length();
250 for (int j = 0; j < reslen; j++) 250 for (int j = 0; j < reslen; j++)
251 onRcvChar(result[j].unicode()); 251 onRcvChar(result[j].unicode());
252 if (s[i] == '\n') bulkNewline(); 252 if (s[i] == '\n') bulkNewline();
253 } 253 }
254 bulkEnd(); 254 bulkEnd();
255} 255}
256 256
257// Selection --------------------------------------------------------------- -- 257// Selection --------------------------------------------------------------- --
258 258
259void EmulationLayer::onSelectionBegin(const int x, const int y) { 259void EmulationLayer::onSelectionBegin(const int x, const int y) {
260 if (!connected) return; 260 if (!connected) return;
261 scr->setSelBeginXY(x,y); 261 scr->setSelBeginXY(x,y);
262 showBulk(); 262 showBulk();
263} 263}
264 264
265void EmulationLayer::onSelectionExtend(const int x, const int y) { 265void EmulationLayer::onSelectionExtend(const int x, const int y) {
266 if (!connected) return; 266 if (!connected) return;
267 scr->setSelExtentXY(x,y); 267 scr->setSelExtentXY(x,y);
268 showBulk(); 268 showBulk();
269} 269}
270 270
271void EmulationLayer::setSelection(const BOOL preserve_line_breaks) { 271void EmulationLayer::setSelection(const BOOL preserve_line_breaks) {
272 if (!connected) return; 272 if (!connected) return;
273 QString t = scr->getSelText(preserve_line_breaks); 273 QString t = scr->getSelText(preserve_line_breaks);
274 if (!t.isNull()) gui->setSelection(t); 274 if (!t.isNull()) gui->setSelection(t);
275} 275}
276 276
277void EmulationLayer::clearSelection() { 277void EmulationLayer::clearSelection() {
278 if (!connected) return; 278 if (!connected) return;
279 scr->clearSelection(); 279 scr->clearSelection();
280 showBulk(); 280 showBulk();
281} 281}
282 282
283// Refreshing -------------------------------------------------------------- -- 283// Refreshing -------------------------------------------------------------- --
284 284
285#define BULK_TIMEOUT 20 285#define BULK_TIMEOUT 20
286 286
287/*! 287/*!
288 called when \n comes in. Evtl. triggers showBulk at endBulk 288 called when \n comes in. Evtl. triggers showBulk at endBulk
289*/ 289*/
290 290
291void EmulationLayer::bulkNewline() 291void EmulationLayer::bulkNewline()
292{ 292{
293 bulk_nlcnt += 1; 293 bulk_nlcnt += 1;
294 bulk_incnt = 0; // reset bulk counter since `nl' rule applies 294 bulk_incnt = 0; // reset bulk counter since `nl' rule applies
295} 295}
296 296
297/*! 297/*!
298*/ 298*/
299 299
300void EmulationLayer::showBulk() 300void EmulationLayer::showBulk()
301{ 301{
302 bulk_nlcnt = 0; // reset bulk newline counter 302 bulk_nlcnt = 0; // reset bulk newline counter
303 bulk_incnt = 0; // reset bulk counter 303 bulk_incnt = 0; // reset bulk counter
304 if (connected) 304 if (connected)
305 { 305 {
306 Character* image = scr->getCookedImage(); // get the image 306 QArray<Character> image = scr->getCookedImage(); // get the image
307 gui->setImage(image, 307 gui->setImage(image,
308 scr->getLines(), 308 scr->getLines(),
309 scr->getColumns()); // actual refresh 309 scr->getColumns()); // actual refresh
310 free(image); 310 delete image;
311 //FIXME: check that we do not trigger other draw event here. 311 //FIXME: check that we do not trigger other draw event here.
312 gui->setScroll(scr->getHistCursor(),scr->getHistLines()); 312 gui->setScroll(scr->getHistCursor(),scr->getHistLines());
313 } 313 }
314} 314}
315 315
316void EmulationLayer::bulkStart() 316void EmulationLayer::bulkStart()
317{ 317{
318 if (bulk_timer.isActive()) bulk_timer.stop(); 318 if (bulk_timer.isActive()) bulk_timer.stop();
319} 319}
320 320
321void EmulationLayer::bulkEnd() 321void EmulationLayer::bulkEnd()
322{ 322{
323 if ( bulk_nlcnt > gui->Lines() || bulk_incnt > 20 ) 323 if ( bulk_nlcnt > gui->lines() || bulk_incnt > 20 )
324 showBulk(); // resets bulk_??cnt to 0, too. 324 showBulk(); // resets bulk_??cnt to 0, too.
325 else 325 else
326 bulk_timer.start(BULK_TIMEOUT,TRUE); 326 bulk_timer.start(BULK_TIMEOUT,TRUE);
327} 327}
328 328
329void EmulationLayer::setConnect(bool c) 329void EmulationLayer::setConnect(bool c)
330{ 330{
331 connected = c; 331 connected = c;
332 if ( connected) 332 if ( connected)
333 { 333 {
334 onImageSizeChange(gui->Lines(), gui->Columns()); 334 onImageSizeChange(gui->lines(), gui->columns());
335 showBulk(); 335 showBulk();
336 } 336 }
337 else 337 else
338 { 338 {
339 scr->clearSelection(); 339 scr->clearSelection();
340 } 340 }
341} 341}
342 342
343// --------------------------------------------------------------------------- 343// ---------------------------------------------------------------------------
344 344
345/*! triggered by image size change of the Widget `gui'. 345/*! triggered by image size change of the Widget `gui'.
346 346
347 This event is simply propagated to the attached screens 347 This event is simply propagated to the attached screens
348 and to the related serial line. 348 and to the related serial line.
349*/ 349*/
350 350
351void EmulationLayer::onImageSizeChange(int lines, int columns) 351void EmulationLayer::onImageSizeChange(int lines, int columns)
352{ 352{
353 if (!connected) return; 353 if (!connected) return;
354 screen[0]->resizeImage(lines,columns); 354 screen[0]->resizeImage(lines,columns);
355 screen[1]->resizeImage(lines,columns); 355 screen[1]->resizeImage(lines,columns);
356 showBulk(); 356 showBulk();
357 emit ImageSizeChanged(lines,columns); // propagate event to serial line 357 emit ImageSizeChanged(lines,columns); // propagate event to serial line
358} 358}
359 359
360void EmulationLayer::onHistoryCursorChange(int cursor) 360void EmulationLayer::onHistoryCursorChange(int cursor)
361{ 361{
362 if (!connected) return; 362 if (!connected) return;
363 scr->setHistCursor(cursor); 363 scr->setHistCursor(cursor);
364 showBulk(); 364 showBulk();
365} 365}
366 366
367void EmulationLayer::setColumns(int columns) 367void EmulationLayer::setColumns(int columns)
368{ 368{
369 //FIXME: this goes strange ways. 369 //FIXME: this goes strange ways.
370 // Can we put this straight or explain it at least? 370 // Can we put this straight or explain it at least?
371 emit changeColumns(columns); 371 emit changeColumns(columns);
372} 372}
diff --git a/noncore/apps/opie-console/emulation_layer.h b/noncore/apps/opie-console/emulation_layer.h
index 5781acc..91a4856 100644
--- a/noncore/apps/opie-console/emulation_layer.h
+++ b/noncore/apps/opie-console/emulation_layer.h
@@ -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_layer.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( WidgetLayer* 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 WidgetLayer* 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/screen.cpp b/noncore/apps/opie-console/screen.cpp
index 8ebc47d..a796ba1 100644
--- a/noncore/apps/opie-console/screen.cpp
+++ b/noncore/apps/opie-console/screen.cpp
@@ -1,1197 +1,1199 @@
1/* -------------------------------------------------------------------------- */ 1/* -------------------------------------------------------------------------- */
2/* */ 2/* */
3/* [screen.C] Screen Data Type */ 3/* [screen.C] Screen Data Type */
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/*! \file 19/*! \file
20*/ 20*/
21 21
22/*! \class Screen 22/*! \class Screen
23 23
24 \brief The image manipulated by the emulation. 24 \brief The image manipulated by the emulation.
25 25
26 This class implements the operations of the terminal emulation framework. 26 This class implements the operations of the terminal emulation framework.
27 It is a complete passive device, driven by the emulation decoder 27 It is a complete passive device, driven by the emulation decoder
28 (TEmuVT102). By this it forms in fact an ADT, that defines operations 28 (TEmuVT102). By this it forms in fact an ADT, that defines operations
29 on a rectangular image. 29 on a rectangular image.
30 30
31 It does neither know how to display its image nor about escape sequences. 31 It does neither know how to display its image nor about escape sequences.
32 It is further independent of the underlying toolkit. By this, one can even 32 It is further independent of the underlying toolkit. By this, one can even
33 use this module for an ordinary text surface. 33 use this module for an ordinary text surface.
34 34
35 Since the operations are called by a specific emulation decoder, one may 35 Since the operations are called by a specific emulation decoder, one may
36 collect their different operations here. 36 collect their different operations here.
37 37
38 The state manipulated by the operations is mainly kept in `image', though 38 The state manipulated by the operations is mainly kept in `image', though
39 it is a little more complex bejond this. See the header file of the class. 39 it is a little more complex bejond this. See the header file of the class.
40 40
41 \sa TEWidget \sa VT102Emulation 41 \sa TEWidget \sa VT102Emulation
42*/ 42*/
43 43
44#include <stdio.h> 44#include <stdio.h>
45#include <stdlib.h> 45#include <stdlib.h>
46#include <unistd.h> 46#include <unistd.h>
47// #include <kdebug.h> 47// #include <kdebug.h>
48 48
49#include <assert.h> 49#include <assert.h>
50#include <string.h> 50#include <string.h>
51#include <ctype.h> 51#include <ctype.h>
52 52
53#include "screen.h" 53#include "screen.h"
54 54
55#define HERE printf("%s(%d): here\n",__FILE__,__LINE__) 55#define HERE printf("%s(%d): here\n",__FILE__,__LINE__)
56 56
57//FIXME: this is emulation specific. Use FALSE for xterm, TRUE for ANSI. 57//FIXME: this is emulation specific. Use FALSE for xterm, TRUE for ANSI.
58//FIXME: see if we can get this from terminfo. 58//FIXME: see if we can get this from terminfo.
59#define BS_CLEARS FALSE 59#define BS_CLEARS FALSE
60 60
61#define loc(X,Y) ((Y)*columns+(X)) 61#define loc(X,Y) ((Y)*columns+(X))
62 62
63/*! creates a `Screen' of `lines' lines and `columns' columns. 63/*! creates a `Screen' of `lines' lines and `columns' columns.
64*/ 64*/
65 65
66Screen::Screen(int lines, int columns) 66Screen::Screen(int lines, int columns)
67{ 67{
68 this->lines = lines; 68 this->lines = lines;
69 this->columns = columns; 69 this->columns = columns;
70 70
71 image = (Character*) malloc(lines*columns*sizeof(Character)); 71 image = QArray<Character>( lines*columns );
72 tabstops = NULL; initTabStops(); 72 tabstops = NULL; initTabStops();
73 73
74 histCursor = 0; 74 histCursor = 0;
75 75
76 clearSelection(); 76 clearSelection();
77 reset(); 77 reset();
78} 78}
79 79
80/*! Destructor 80/*! Destructor
81*/ 81*/
82 82
83Screen::~Screen() 83Screen::~Screen()
84{ 84{
85 free(image); 85 delete image;
86 if (tabstops) free(tabstops); 86 if (tabstops) free(tabstops);
87} 87}
88 88
89/* ------------------------------------------------------------------------- */ 89/* ------------------------------------------------------------------------- */
90/* */ 90/* */
91/* Normalized Screen Operations */ 91/* Normalized Screen Operations */
92/* */ 92/* */
93/* ------------------------------------------------------------------------- */ 93/* ------------------------------------------------------------------------- */
94 94
95// Cursor Setting -------------------------------------------------------------- 95// Cursor Setting --------------------------------------------------------------
96 96
97/*! \section Cursor 97/*! \section Cursor
98 98
99 The `cursor' is a location within the screen that is implicitely used in 99 The `cursor' is a location within the screen that is implicitely used in
100 many operations. The operations within this section allow to manipulate 100 many operations. The operations within this section allow to manipulate
101 the cursor explicitly and to obtain it's value. 101 the cursor explicitly and to obtain it's value.
102 102
103 The position of the cursor is guarantied to be between (including) 0 and 103 The position of the cursor is guarantied to be between (including) 0 and
104 `columns-1' and `lines-1'. 104 `columns-1' and `lines-1'.
105*/ 105*/
106 106
107/*! 107/*!
108 Move the cursor up. 108 Move the cursor up.
109 109
110 The cursor will not be moved beyond the top margin. 110 The cursor will not be moved beyond the top margin.
111*/ 111*/
112 112
113void Screen::cursorUp(int n) 113void Screen::cursorUp(int n)
114//=CUU 114//=CUU
115{ 115{
116 if (n == 0) n = 1; // Default 116 if (n == 0) n = 1; // Default
117 int stop = cuY < tmargin ? 0 : tmargin; 117 int stop = cuY < tmargin ? 0 : tmargin;
118 cuX = QMIN(columns-1,cuX); // nowrap! 118 cuX = QMIN(columns-1,cuX); // nowrap!
119 cuY = QMAX(stop,cuY-n); 119 cuY = QMAX(stop,cuY-n);
120} 120}
121 121
122/*! 122/*!
123 Move the cursor down. 123 Move the cursor down.
124 124
125 The cursor will not be moved beyond the bottom margin. 125 The cursor will not be moved beyond the bottom margin.
126*/ 126*/
127 127
128void Screen::cursorDown(int n) 128void Screen::cursorDown(int n)
129//=CUD 129//=CUD
130{ 130{
131 if (n == 0) n = 1; // Default 131 if (n == 0) n = 1; // Default
132 int stop = cuY > bmargin ? lines-1 : bmargin; 132 int stop = cuY > bmargin ? lines-1 : bmargin;
133 cuX = QMIN(columns-1,cuX); // nowrap! 133 cuX = QMIN(columns-1,cuX); // nowrap!
134 cuY = QMIN(stop,cuY+n); 134 cuY = QMIN(stop,cuY+n);
135} 135}
136 136
137/*! 137/*!
138 Move the cursor left. 138 Move the cursor left.
139 139
140 The cursor will not move beyond the first column. 140 The cursor will not move beyond the first column.
141*/ 141*/
142 142
143void Screen::cursorLeft(int n) 143void Screen::cursorLeft(int n)
144//=CUB 144//=CUB
145{ 145{
146 if (n == 0) n = 1; // Default 146 if (n == 0) n = 1; // Default
147 cuX = QMIN(columns-1,cuX); // nowrap! 147 cuX = QMIN(columns-1,cuX); // nowrap!
148 cuX = QMAX(0,cuX-n); 148 cuX = QMAX(0,cuX-n);
149} 149}
150 150
151/*! 151/*!
152 Move the cursor left. 152 Move the cursor left.
153 153
154 The cursor will not move beyond the rightmost column. 154 The cursor will not move beyond the rightmost column.
155*/ 155*/
156 156
157void Screen::cursorRight(int n) 157void Screen::cursorRight(int n)
158//=CUF 158//=CUF
159{ 159{
160 if (n == 0) n = 1; // Default 160 if (n == 0) n = 1; // Default
161 cuX = QMIN(columns-1,cuX+n); 161 cuX = QMIN(columns-1,cuX+n);
162} 162}
163 163
164/*! 164/*!
165 Set top and bottom margin. 165 Set top and bottom margin.
166*/ 166*/
167 167
168void Screen::setMargins(int top, int bot) 168void Screen::setMargins(int top, int bot)
169//=STBM 169//=STBM
170{ 170{
171 if (top == 0) top = 1; // Default 171 if (top == 0) top = 1; // Default
172 if (bot == 0) bot = lines; // Default 172 if (bot == 0) bot = lines; // Default
173 top = top - 1; // Adjust to internal lineno 173 top = top - 1; // Adjust to internal lineno
174 bot = bot - 1; // Adjust to internal lineno 174 bot = bot - 1; // Adjust to internal lineno
175 if ( !( 0 <= top && top < bot && bot < lines ) ) 175 if ( !( 0 <= top && top < bot && bot < lines ) )
176 { fprintf(stderr,"%s(%d) : setRegion(%d,%d) : bad range.\n", 176 { fprintf(stderr,"%s(%d) : setRegion(%d,%d) : bad range.\n",
177 __FILE__,__LINE__,top,bot); 177 __FILE__,__LINE__,top,bot);
178 return; // Default error action: ignore 178 return; // Default error action: ignore
179 } 179 }
180 tmargin = top; 180 tmargin = top;
181 bmargin = bot; 181 bmargin = bot;
182 cuX = 0; 182 cuX = 0;
183 cuY = getMode(MODE_Origin) ? top : 0; 183 cuY = getMode(MODE_Origin) ? top : 0;
184} 184}
185 185
186/*! 186/*!
187 Move the cursor down one line. 187 Move the cursor down one line.
188 188
189 If cursor is on bottom margin, the region between the 189 If cursor is on bottom margin, the region between the
190 actual top and bottom margin is scrolled up instead. 190 actual top and bottom margin is scrolled up instead.
191*/ 191*/
192 192
193void Screen::index() 193void Screen::index()
194//=IND 194//=IND
195{ 195{
196 if (cuY == bmargin) 196 if (cuY == bmargin)
197 { 197 {
198 if (tmargin == 0 && bmargin == lines-1) addHistLine(); // hist.history 198 if (tmargin == 0 && bmargin == lines-1) addHistLine(); // hist.history
199 scrollUp(tmargin,1); 199 scrollUp(tmargin,1);
200 } 200 }
201 else if (cuY < lines-1) 201 else if (cuY < lines-1)
202 cuY += 1; 202 cuY += 1;
203} 203}
204 204
205/*! 205/*!
206 Move the cursor up one line. 206 Move the cursor up one line.
207 207
208 If cursor is on the top margin, the region between the 208 If cursor is on the top margin, the region between the
209 actual top and bottom margin is scrolled down instead. 209 actual top and bottom margin is scrolled down instead.
210*/ 210*/
211 211
212void Screen::reverseIndex() 212void Screen::reverseIndex()
213//=RI 213//=RI
214{ 214{
215 if (cuY == tmargin) 215 if (cuY == tmargin)
216 scrollDown(tmargin,1); 216 scrollDown(tmargin,1);
217 else if (cuY > 0) 217 else if (cuY > 0)
218 cuY -= 1; 218 cuY -= 1;
219} 219}
220 220
221/*! 221/*!
222 Move the cursor to the begin of the next line. 222 Move the cursor to the begin of the next line.
223 223
224 If cursor is on bottom margin, the region between the 224 If cursor is on bottom margin, the region between the
225 actual top and bottom margin is scrolled up. 225 actual top and bottom margin is scrolled up.
226*/ 226*/
227 227
228void Screen::NextLine() 228void Screen::NextLine()
229//=NEL 229//=NEL
230{ 230{
231 Return(); index(); 231 Return(); index();
232} 232}
233 233
234// Line Editing ---------------------------------------------------------------- 234// Line Editing ----------------------------------------------------------------
235 235
236/*! \section inserting / deleting characters 236/*! \section inserting / deleting characters
237*/ 237*/
238 238
239/*! erase `n' characters starting from (including) the cursor position. 239/*! erase `n' characters starting from (including) the cursor position.
240 240
241 The line is filled in from the right with spaces. 241 The line is filled in from the right with spaces.
242*/ 242*/
243 243
244void Screen::eraseChars(int n) 244void Screen::eraseChars(int n)
245{ 245{
246 if (n == 0) n = 1; // Default 246 if (n == 0) n = 1; // Default
247 int p = QMAX(0,QMIN(cuX+n-1,columns-1)); 247 int p = QMAX(0,QMIN(cuX+n-1,columns-1));
248 clearImage(loc(cuX,cuY),loc(p,cuY),' '); 248 clearImage(loc(cuX,cuY),loc(p,cuY),' ');
249} 249}
250 250
251/*! delete `n' characters starting from (including) the cursor position. 251/*! delete `n' characters starting from (including) the cursor position.
252 252
253 The line is filled in from the right with spaces. 253 The line is filled in from the right with spaces.
254*/ 254*/
255 255
256void Screen::deleteChars(int n) 256void Screen::deleteChars(int n)
257{ 257{
258 if (n == 0) n = 1; // Default 258 if (n == 0) n = 1; // Default
259 int p = QMAX(0,QMIN(cuX+n,columns-1)); 259 int p = QMAX(0,QMIN(cuX+n,columns-1));
260 moveImage(loc(cuX,cuY),loc(p,cuY),loc(columns-1,cuY)); 260 moveImage(loc(cuX,cuY),loc(p,cuY),loc(columns-1,cuY));
261 clearImage(loc(columns-n,cuY),loc(columns-1,cuY),' '); 261 clearImage(loc(columns-n,cuY),loc(columns-1,cuY),' ');
262} 262}
263 263
264/*! insert `n' spaces at the cursor position. 264/*! insert `n' spaces at the cursor position.
265 265
266 The cursor is not moved by the operation. 266 The cursor is not moved by the operation.
267*/ 267*/
268 268
269void Screen::insertChars(int n) 269void Screen::insertChars(int n)
270{ 270{
271 if (n == 0) n = 1; // Default 271 if (n == 0) n = 1; // Default
272 int p = QMAX(0,QMIN(columns-1-n,columns-1)); 272 int p = QMAX(0,QMIN(columns-1-n,columns-1));
273 int q = QMAX(0,QMIN(cuX+n,columns-1)); 273 int q = QMAX(0,QMIN(cuX+n,columns-1));
274 moveImage(loc(q,cuY),loc(cuX,cuY),loc(p,cuY)); 274 moveImage(loc(q,cuY),loc(cuX,cuY),loc(p,cuY));
275 clearImage(loc(cuX,cuY),loc(q-1,cuY),' '); 275 clearImage(loc(cuX,cuY),loc(q-1,cuY),' ');
276} 276}
277 277
278/*! delete `n' lines starting from (including) the cursor position. 278/*! delete `n' lines starting from (including) the cursor position.
279 279
280 The cursor is not moved by the operation. 280 The cursor is not moved by the operation.
281*/ 281*/
282 282
283void Screen::deleteLines(int n) 283void Screen::deleteLines(int n)
284{ 284{
285 if (n == 0) n = 1; // Default 285 if (n == 0) n = 1; // Default
286 scrollUp(cuY,n); 286 scrollUp(cuY,n);
287} 287}
288 288
289/*! insert `n' lines at the cursor position. 289/*! insert `n' lines at the cursor position.
290 290
291 The cursor is not moved by the operation. 291 The cursor is not moved by the operation.
292*/ 292*/
293 293
294void Screen::insertLines(int n) 294void Screen::insertLines(int n)
295{ 295{
296 if (n == 0) n = 1; // Default 296 if (n == 0) n = 1; // Default
297 scrollDown(cuY,n); 297 scrollDown(cuY,n);
298} 298}
299 299
300// Mode Operations ----------------------------------------------------------- 300// Mode Operations -----------------------------------------------------------
301 301
302/*! Set a specific mode. */ 302/*! Set a specific mode. */
303 303
304void Screen::setMode(int m) 304void Screen::setMode(int m)
305{ 305{
306 currParm.mode[m] = TRUE; 306 currParm.mode[m] = TRUE;
307 switch(m) 307 switch(m)
308 { 308 {
309 case MODE_Origin : cuX = 0; cuY = tmargin; break; //FIXME: home 309 case MODE_Origin : cuX = 0; cuY = tmargin; break; //FIXME: home
310 } 310 }
311} 311}
312 312
313/*! Reset a specific mode. */ 313/*! Reset a specific mode. */
314 314
315void Screen::resetMode(int m) 315void Screen::resetMode(int m)
316{ 316{
317 currParm.mode[m] = FALSE; 317 currParm.mode[m] = FALSE;
318 switch(m) 318 switch(m)
319 { 319 {
320 case MODE_Origin : cuX = 0; cuY = 0; break; //FIXME: home 320 case MODE_Origin : cuX = 0; cuY = 0; break; //FIXME: home
321 } 321 }
322} 322}
323 323
324/*! Save a specific mode. */ 324/*! Save a specific mode. */
325 325
326void Screen::saveMode(int m) 326void Screen::saveMode(int m)
327{ 327{
328 saveParm.mode[m] = currParm.mode[m]; 328 saveParm.mode[m] = currParm.mode[m];
329} 329}
330 330
331/*! Restore a specific mode. */ 331/*! Restore a specific mode. */
332 332
333void Screen::restoreMode(int m) 333void Screen::restoreMode(int m)
334{ 334{
335 currParm.mode[m] = saveParm.mode[m]; 335 currParm.mode[m] = saveParm.mode[m];
336} 336}
337 337
338//NOTE: this is a helper function 338//NOTE: this is a helper function
339/*! Return the setting a specific mode. */ 339/*! Return the setting a specific mode. */
340BOOL Screen::getMode(int m) 340BOOL Screen::getMode(int m)
341{ 341{
342 return currParm.mode[m]; 342 return currParm.mode[m];
343} 343}
344 344
345/*! Save the cursor position and the rendition attribute settings. */ 345/*! Save the cursor position and the rendition attribute settings. */
346 346
347void Screen::saveCursor() 347void Screen::saveCursor()
348{ 348{
349 sa_cuX = cuX; 349 sa_cuX = cuX;
350 sa_cuY = cuY; 350 sa_cuY = cuY;
351 sa_cu_re = cu_re; 351 sa_cu_re = cu_re;
352 sa_cu_fg = cu_fg; 352 sa_cu_fg = cu_fg;
353 sa_cu_bg = cu_bg; 353 sa_cu_bg = cu_bg;
354} 354}
355 355
356/*! Restore the cursor position and the rendition attribute settings. */ 356/*! Restore the cursor position and the rendition attribute settings. */
357 357
358void Screen::restoreCursor() 358void Screen::restoreCursor()
359{ 359{
360 cuX = QMIN(sa_cuX,columns-1); 360 cuX = QMIN(sa_cuX,columns-1);
361 cuY = QMIN(sa_cuY,lines-1); 361 cuY = QMIN(sa_cuY,lines-1);
362 cu_re = sa_cu_re; 362 cu_re = sa_cu_re;
363 cu_fg = sa_cu_fg; 363 cu_fg = sa_cu_fg;
364 cu_bg = sa_cu_bg; 364 cu_bg = sa_cu_bg;
365 effectiveRendition(); 365 effectiveRendition();
366} 366}
367 367
368/* ------------------------------------------------------------------------- */ 368/* ------------------------------------------------------------------------- */
369/* */ 369/* */
370/* Screen Operations */ 370/* Screen Operations */
371/* */ 371/* */
372/* ------------------------------------------------------------------------- */ 372/* ------------------------------------------------------------------------- */
373 373
374/*! Assing a new size to the screen. 374/*! Assing a new size to the screen.
375 375
376 The topmost left position is maintained, while lower lines 376 The topmost left position is maintained, while lower lines
377 or right hand side columns might be removed or filled with 377 or right hand side columns might be removed or filled with
378 spaces to fit the new size. 378 spaces to fit the new size.
379 379
380 The region setting is reset to the whole screen and the 380 The region setting is reset to the whole screen and the
381 tab positions reinitialized. 381 tab positions reinitialized.
382*/ 382*/
383 383
384void Screen::resizeImage(int new_lines, int new_columns) 384void Screen::resizeImage(int new_lines, int new_columns)
385{ 385{
386 386
387 if (cuY > new_lines-1) 387 if (cuY > new_lines-1)
388 { // attempt to preserve focus and lines 388 { // attempt to preserve focus and lines
389 bmargin = lines-1; //FIXME: margin lost 389 bmargin = lines-1; //FIXME: margin lost
390 for (int i = 0; i < cuY-(new_lines-1); i++) 390 for (int i = 0; i < cuY-(new_lines-1); i++)
391 { 391 {
392 addHistLine(); scrollUp(0,1); 392 addHistLine(); scrollUp(0,1);
393 } 393 }
394 } 394 }
395 395
396 // make new image 396 // make new image
397 Character* newimg = (Character*) malloc(new_lines*new_columns*sizeof(Character)); 397 QArray<Character> newimg = QArray<Character>( new_lines * new_columns );
398 398
399 clearSelection(); 399 clearSelection();
400 400
401 // clear new image 401 // clear new image
402 for (int y = 0; y < new_lines; y++) 402 for (int y = 0; y < new_lines; y++)
403 for (int x = 0; x < new_columns; x++) 403 for (int x = 0; x < new_columns; x++)
404 { 404 {
405 newimg[y*new_columns+x].c = ' '; 405 newimg[y*new_columns+x].c = ' ';
406 newimg[y*new_columns+x].f = DEFAULT_FORE_COLOR; 406 newimg[y*new_columns+x].f = DEFAULT_FORE_COLOR;
407 newimg[y*new_columns+x].b = DEFAULT_BACK_COLOR; 407 newimg[y*new_columns+x].b = DEFAULT_BACK_COLOR;
408 newimg[y*new_columns+x].r = DEFAULT_RENDITION; 408 newimg[y*new_columns+x].r = DEFAULT_RENDITION;
409 } 409 }
410 int cpy_lines = QMIN(new_lines, lines); 410 int cpy_lines = QMIN(new_lines, lines);
411 int cpy_columns = QMIN(new_columns,columns); 411 int cpy_columns = QMIN(new_columns,columns);
412 // copy to new image 412 // copy to new image
413 for (int y = 0; y < cpy_lines; y++) 413 for (int y = 0; y < cpy_lines; y++)
414 for (int x = 0; x < cpy_columns; x++) 414 for (int x = 0; x < cpy_columns; x++)
415 { 415 {
416 newimg[y*new_columns+x].c = image[loc(x,y)].c; 416 newimg[y*new_columns+x].c = image[loc(x,y)].c;
417 newimg[y*new_columns+x].f = image[loc(x,y)].f; 417 newimg[y*new_columns+x].f = image[loc(x,y)].f;
418 newimg[y*new_columns+x].b = image[loc(x,y)].b; 418 newimg[y*new_columns+x].b = image[loc(x,y)].b;
419 newimg[y*new_columns+x].r = image[loc(x,y)].r; 419 newimg[y*new_columns+x].r = image[loc(x,y)].r;
420 } 420 }
421 free(image); 421 delete image;
422 image = newimg; 422 image = newimg;
423 lines = new_lines; 423 lines = new_lines;
424 columns = new_columns; 424 columns = new_columns;
425 cuX = QMIN(cuX,columns-1); 425 cuX = QMIN(cuX,columns-1);
426 cuY = QMIN(cuY,lines-1); 426 cuY = QMIN(cuY,lines-1);
427 427
428 // FIXME: try to keep values, evtl. 428 // FIXME: try to keep values, evtl.
429 tmargin=0; 429 tmargin=0;
430 bmargin=lines-1; 430 bmargin=lines-1;
431 initTabStops(); 431 initTabStops();
432 clearSelection(); 432 clearSelection();
433} 433}
434 434
435/* 435/*
436 Clarifying rendition here and in TEWidget. 436 Clarifying rendition here and in TEWidget.
437 437
438 currently, TEWidget's color table is 438 currently, TEWidget's color table is
439 0 1 2 .. 9 10 .. 17 439 0 1 2 .. 9 10 .. 17
440 dft_fg, dft_bg, dim 0..7, intensive 0..7 440 dft_fg, dft_bg, dim 0..7, intensive 0..7
441 441
442 cu_fg, cu_bg contain values 0..8; 442 cu_fg, cu_bg contain values 0..8;
443 - 0 = default color 443 - 0 = default color
444 - 1..8 = ansi specified color 444 - 1..8 = ansi specified color
445 445
446 re_fg, re_bg contain values 0..17 446 re_fg, re_bg contain values 0..17
447 due to the TEWidget's color table 447 due to the TEWidget's color table
448 448
449 rendition attributes are 449 rendition attributes are
450 450
451 attr widget screen 451 attr widget screen
452 -------------- ------ ------ 452 -------------- ------ ------
453 RE_UNDERLINE XX XX affects foreground only 453 RE_UNDERLINE XX XX affects foreground only
454 RE_BLINK XX XX affects foreground only 454 RE_BLINK XX XX affects foreground only
455 RE_BOLD XX XX affects foreground only 455 RE_BOLD XX XX affects foreground only
456 RE_REVERSE -- XX 456 RE_REVERSE -- XX
457 RE_TRANSPARENT XX -- affects background only 457 RE_TRANSPARENT XX -- affects background only
458 RE_INTENSIVE XX -- affects foreground only 458 RE_INTENSIVE XX -- affects foreground only
459 459
460 Note that RE_BOLD is used in both widget 460 Note that RE_BOLD is used in both widget
461 and screen rendition. Since xterm/vt102 461 and screen rendition. Since xterm/vt102
462 is to poor to distinguish between bold 462 is to poor to distinguish between bold
463 (which is a font attribute) and intensive 463 (which is a font attribute) and intensive
464 (which is a color attribute), we translate 464 (which is a color attribute), we translate
465 this and RE_BOLD in falls eventually appart 465 this and RE_BOLD in falls eventually appart
466 into RE_BOLD and RE_INTENSIVE. 466 into RE_BOLD and RE_INTENSIVE.
467*/ 467*/
468 468
469void Screen::reverseRendition(Character* p) 469void Screen::reverseRendition(Character *p)
470{ UINT8 f = p->f; UINT8 b = p->b; 470{ UINT8 f = p->f; UINT8 b = p->b;
471 p->f = b; p->b = f; //p->r &= ~RE_TRANSPARENT; 471 p->f = b; p->b = f; //p->r &= ~RE_TRANSPARENT;
472} 472}
473 473
474void Screen::effectiveRendition() 474void Screen::effectiveRendition()
475// calculate rendition 475// calculate rendition
476{ 476{
477 ef_re = cu_re & (RE_UNDERLINE | RE_BLINK); 477 ef_re = cu_re & (RE_UNDERLINE | RE_BLINK);
478 if (cu_re & RE_REVERSE) 478 if (cu_re & RE_REVERSE)
479 { 479 {
480 ef_fg = cu_bg; 480 ef_fg = cu_bg;
481 ef_bg = cu_fg; 481 ef_bg = cu_fg;
482 } 482 }
483 else 483 else
484 { 484 {
485 ef_fg = cu_fg; 485 ef_fg = cu_fg;
486 ef_bg = cu_bg; 486 ef_bg = cu_bg;
487 } 487 }
488 if (cu_re & RE_BOLD) 488 if (cu_re & RE_BOLD)
489 { 489 {
490 if (ef_fg < BASE_COLORS) 490 if (ef_fg < BASE_COLORS)
491 ef_fg += BASE_COLORS; 491 ef_fg += BASE_COLORS;
492 else 492 else
493 ef_fg -= BASE_COLORS; 493 ef_fg -= BASE_COLORS;
494 } 494 }
495} 495}
496 496
497/*! 497/*!
498 returns the image. 498 returns the image.
499 499
500 Get the size of the image by \sa getLines and \sa getColumns. 500 Get the size of the image by \sa getLines and \sa getColumns.
501 501
502 NOTE that the image returned by this function must later be 502 NOTE that the image returned by this function must later be
503 freed. 503 freed.
504 504
505*/ 505*/
506 506
507Character* Screen::getCookedImage() 507QArray<Character> Screen::getCookedImage()
508{ int x,y; 508{ int x,y;
509 Character* merged = (Character*) malloc(lines*columns*sizeof(Character)); 509 Character* merged = (Character*) malloc( lines * columns * sizeof( Character ) );
510 Character dft(' ',DEFAULT_FORE_COLOR,DEFAULT_BACK_COLOR,DEFAULT_RENDITION); 510 Character dft(' ',DEFAULT_FORE_COLOR,DEFAULT_BACK_COLOR,DEFAULT_RENDITION);
511 511
512 for (y = 0; (y < lines) && (y < (hist.getLines()-histCursor)); y++) 512 for (y = 0; (y < lines) && (y < (hist.getLines()-histCursor)); y++)
513 { 513 {
514 int len = QMIN(columns,hist.getLineLen(y+histCursor)); 514 int len = QMIN(columns,hist.getLineLen(y+histCursor));
515 int yp = y*columns; 515 int yp = y*columns;
516 int yq = (y+histCursor)*columns; 516 int yq = (y+histCursor)*columns;
517 517
518 hist.getCells(y+histCursor,0,len,merged+yp); 518 hist.getCells( y+histCursor, 0, len, merged+yp );
519 for (x = len; x < columns; x++) merged[yp+x] = dft; 519 for (x = len; x < columns; x++) merged[yp+x] = dft;
520 for (x = 0; x < columns; x++) 520 for (x = 0; x < columns; x++)
521 { int p=x + yp; int q=x + yq; 521 { int p=x + yp; int q=x + yq;
522 if ( ( q >= sel_TL ) && ( q <= sel_BR ) ) 522 if ( ( q >= sel_TL ) && ( q <= sel_BR ) )
523 reverseRendition(&merged[p]); // for selection 523 reverseRendition(&merged[p]); // for selection
524 } 524 }
525 } 525 }
526 if (lines >= hist.getLines()-histCursor) 526 if (lines >= hist.getLines()-histCursor)
527 { 527 {
528 for (y = (hist.getLines()-histCursor); y < lines ; y++) 528 for (y = (hist.getLines()-histCursor); y < lines ; y++)
529 { 529 {
530 int yp = y*columns; 530 int yp = y*columns;
531 int yq = (y+histCursor)*columns; 531 int yq = (y+histCursor)*columns;
532 int yr = (y-hist.getLines()+histCursor)*columns; 532 int yr = (y-hist.getLines()+histCursor)*columns;
533 for (x = 0; x < columns; x++) 533 for (x = 0; x < columns; x++)
534 { int p = x + yp; int q = x + yq; int r = x + yr; 534 { int p = x + yp; int q = x + yq; int r = x + yr;
535 merged[p] = image[r]; 535 merged[p] = image[r];
536 if ( q >= sel_TL && q <= sel_BR ) 536 if ( q >= sel_TL && q <= sel_BR )
537 reverseRendition(&merged[p]); // for selection 537 reverseRendition(&merged[p]); // for selection
538 } 538 }
539 539
540 } 540 }
541 } 541 }
542 // evtl. inverse display 542 // evtl. inverse display
543 if (getMode(MODE_Screen)) 543 if (getMode(MODE_Screen))
544 { int i,n = lines*columns; 544 { int i,n = lines*columns;
545 for (i = 0; i < n; i++) 545 for (i = 0; i < n; i++)
546 reverseRendition(&merged[i]); // for reverse display 546 reverseRendition(&merged[i]); // for reverse display
547 } 547 }
548 if (getMode(MODE_Cursor) && (cuY+(hist.getLines()-histCursor) < lines)) // cursor visible 548 if (getMode(MODE_Cursor) && (cuY+(hist.getLines()-histCursor) < lines)) // cursor visible
549 reverseRendition(&merged[loc(cuX,cuY+(hist.getLines()-histCursor))]); 549 reverseRendition(&merged[loc(cuX,cuY+(hist.getLines()-histCursor))]);
550 return merged; 550 QArray<Character> res( sizeof( merged ) / sizeof( Character ) );
551 res.assign( merged, sizeof( merged ) / sizeof( Character ) );
552 return res;
551} 553}
552 554
553 555
554/*! 556/*!
555*/ 557*/
556 558
557void Screen::reset() 559void Screen::reset()
558{ 560{
559 setMode(MODE_Wrap ); saveMode(MODE_Wrap ); // wrap at end of margin 561 setMode(MODE_Wrap ); saveMode(MODE_Wrap ); // wrap at end of margin
560 resetMode(MODE_Origin); saveMode(MODE_Origin); // position refere to [1,1] 562 resetMode(MODE_Origin); saveMode(MODE_Origin); // position refere to [1,1]
561 resetMode(MODE_Insert); saveMode(MODE_Insert); // overstroke 563 resetMode(MODE_Insert); saveMode(MODE_Insert); // overstroke
562 setMode(MODE_Cursor); // cursor visible 564 setMode(MODE_Cursor); // cursor visible
563 resetMode(MODE_Screen); // screen not inverse 565 resetMode(MODE_Screen); // screen not inverse
564 resetMode(MODE_NewLine); 566 resetMode(MODE_NewLine);
565 567
566 tmargin=0; 568 tmargin=0;
567 bmargin=lines-1; 569 bmargin=lines-1;
568 570
569 setDefaultRendition(); 571 setDefaultRendition();
570 saveCursor(); 572 saveCursor();
571 573
572 clear(); 574 clear();
573} 575}
574 576
575/*! Clear the entire screen and home the cursor. 577/*! Clear the entire screen and home the cursor.
576*/ 578*/
577 579
578void Screen::clear() 580void Screen::clear()
579{ 581{
580 clearEntireScreen(); 582 clearEntireScreen();
581 home(); 583 home();
582} 584}
583 585
584/*! Moves the cursor left one column. 586/*! Moves the cursor left one column.
585*/ 587*/
586 588
587void Screen::BackSpace() 589void Screen::BackSpace()
588{ 590{
589 cuX = QMAX(0,cuX-1); 591 cuX = QMAX(0,cuX-1);
590 if (BS_CLEARS) image[loc(cuX,cuY)].c = ' '; 592 if (BS_CLEARS) image[loc(cuX,cuY)].c = ' ';
591} 593}
592 594
593/*! 595/*!
594*/ 596*/
595 597
596void Screen::Tabulate() 598void Screen::Tabulate()
597{ 599{
598 // note that TAB is a format effector (does not write ' '); 600 // note that TAB is a format effector (does not write ' ');
599 cursorRight(1); while(cuX < columns-1 && !tabstops[cuX]) cursorRight(1); 601 cursorRight(1); while(cuX < columns-1 && !tabstops[cuX]) cursorRight(1);
600} 602}
601 603
602void Screen::clearTabStops() 604void Screen::clearTabStops()
603{ 605{
604 for (int i = 0; i < columns; i++) tabstops[i-1] = FALSE; 606 for (int i = 0; i < columns; i++) tabstops[i-1] = FALSE;
605} 607}
606 608
607void Screen::changeTabStop(bool set) 609void Screen::changeTabStop(bool set)
608{ 610{
609 if (cuX >= columns) return; 611 if (cuX >= columns) return;
610 tabstops[cuX] = set; 612 tabstops[cuX] = set;
611} 613}
612 614
613void Screen::initTabStops() 615void Screen::initTabStops()
614{ 616{
615 if (tabstops) free(tabstops); 617 if (tabstops) free(tabstops);
616 tabstops = (bool*)malloc(columns*sizeof(bool)); 618 tabstops = (bool*)malloc(columns*sizeof(bool));
617 // Arrg! The 1st tabstop has to be one longer than the other. 619 // Arrg! The 1st tabstop has to be one longer than the other.
618 // i.e. the kids start counting from 0 instead of 1. 620 // i.e. the kids start counting from 0 instead of 1.
619 // Other programs might behave correctly. Be aware. 621 // Other programs might behave correctly. Be aware.
620 for (int i = 0; i < columns; i++) tabstops[i] = (i%8 == 0 && i != 0); 622 for (int i = 0; i < columns; i++) tabstops[i] = (i%8 == 0 && i != 0);
621} 623}
622 624
623/*! 625/*!
624 This behaves either as IND (Screen::Index) or as NEL (Screen::NextLine) 626 This behaves either as IND (Screen::Index) or as NEL (Screen::NextLine)
625 depending on the NewLine Mode (LNM). This mode also 627 depending on the NewLine Mode (LNM). This mode also
626 affects the key sequence returned for newline ([CR]LF). 628 affects the key sequence returned for newline ([CR]LF).
627*/ 629*/
628 630
629void Screen::NewLine() 631void Screen::NewLine()
630{ 632{
631 if (getMode(MODE_NewLine)) Return(); 633 if (getMode(MODE_NewLine)) Return();
632 index(); 634 index();
633} 635}
634 636
635/*! put `c' literally onto the screen at the current cursor position. 637/*! put `c' literally onto the screen at the current cursor position.
636 638
637 VT100 uses the convention to produce an automatic newline (am) 639 VT100 uses the convention to produce an automatic newline (am)
638 with the *first* character that would fall onto the next line (xenl). 640 with the *first* character that would fall onto the next line (xenl).
639*/ 641*/
640 642
641void Screen::checkSelection(int from, int to) 643void Screen::checkSelection(int from, int to)
642{ 644{
643 if (sel_begin == -1) return; 645 if (sel_begin == -1) return;
644 int scr_TL = loc(0, hist.getLines()); 646 int scr_TL = loc(0, hist.getLines());
645 //Clear entire selection if it overlaps region [from, to] 647 //Clear entire selection if it overlaps region [from, to]
646 if ( (sel_BR > (from+scr_TL) )&&(sel_TL < (to+scr_TL)) ) 648 if ( (sel_BR > (from+scr_TL) )&&(sel_TL < (to+scr_TL)) )
647 { 649 {
648 clearSelection(); 650 clearSelection();
649 } 651 }
650} 652}
651 653
652void Screen::ShowCharacter(unsigned short c) 654void Screen::ShowCharacter(unsigned short c)
653{ 655{
654 // Note that VT100 does wrapping BEFORE putting the character. 656 // Note that VT100 does wrapping BEFORE putting the character.
655 // This has impact on the assumption of valid cursor positions. 657 // This has impact on the assumption of valid cursor positions.
656 // We indicate the fact that a newline has to be triggered by 658 // We indicate the fact that a newline has to be triggered by
657 // putting the cursor one right to the last column of the screen. 659 // putting the cursor one right to the last column of the screen.
658 660
659 if (cuX >= columns) 661 if (cuX >= columns)
660 { 662 {
661 if (getMode(MODE_Wrap)) NextLine(); else cuX = columns-1; 663 if (getMode(MODE_Wrap)) NextLine(); else cuX = columns-1;
662 } 664 }
663 665
664 if (getMode(MODE_Insert)) insertChars(1); 666 if (getMode(MODE_Insert)) insertChars(1);
665 667
666 int i = loc(cuX,cuY); 668 int i = loc(cuX,cuY);
667 669
668 checkSelection(i, i); // check if selection is still valid. 670 checkSelection(i, i); // check if selection is still valid.
669 671
670 image[i].c = c; 672 image[i].c = c;
671 image[i].f = ef_fg; 673 image[i].f = ef_fg;
672 image[i].b = ef_bg; 674 image[i].b = ef_bg;
673 image[i].r = ef_re; 675 image[i].r = ef_re;
674 676
675 cuX += 1; 677 cuX += 1;
676} 678}
677 679
678// Region commands ------------------------------------------------------------- 680// Region commands -------------------------------------------------------------
679 681
680 682
681/*! scroll up `n' lines within current region. 683/*! scroll up `n' lines within current region.
682 The `n' new lines are cleared. 684 The `n' new lines are cleared.
683 \sa setRegion \sa scrollDown 685 \sa setRegion \sa scrollDown
684*/ 686*/
685 687
686void Screen::scrollUp(int from, int n) 688void Screen::scrollUp(int from, int n)
687{ 689{
688 if (n <= 0 || from + n > bmargin) return; 690 if (n <= 0 || from + n > bmargin) return;
689 //FIXME: make sure `tmargin', `bmargin', `from', `n' is in bounds. 691 //FIXME: make sure `tmargin', `bmargin', `from', `n' is in bounds.
690 moveImage(loc(0,from),loc(0,from+n),loc(columns-1,bmargin)); 692 moveImage(loc(0,from),loc(0,from+n),loc(columns-1,bmargin));
691 clearImage(loc(0,bmargin-n+1),loc(columns-1,bmargin),' '); 693 clearImage(loc(0,bmargin-n+1),loc(columns-1,bmargin),' ');
692} 694}
693 695
694/*! scroll down `n' lines within current region. 696/*! scroll down `n' lines within current region.
695 The `n' new lines are cleared. 697 The `n' new lines are cleared.
696 \sa setRegion \sa scrollUp 698 \sa setRegion \sa scrollUp
697*/ 699*/
698 700
699void Screen::scrollDown(int from, int n) 701void Screen::scrollDown(int from, int n)
700{ 702{
701//FIXME: make sure `tmargin', `bmargin', `from', `n' is in bounds. 703//FIXME: make sure `tmargin', `bmargin', `from', `n' is in bounds.
702 if (n <= 0) return; 704 if (n <= 0) return;
703 if (from > bmargin) return; 705 if (from > bmargin) return;
704 if (from + n > bmargin) n = bmargin - from; 706 if (from + n > bmargin) n = bmargin - from;
705 moveImage(loc(0,from+n),loc(0,from),loc(columns-1,bmargin-n)); 707 moveImage(loc(0,from+n),loc(0,from),loc(columns-1,bmargin-n));
706 clearImage(loc(0,from),loc(columns-1,from+n-1),' '); 708 clearImage(loc(0,from),loc(columns-1,from+n-1),' ');
707} 709}
708 710
709/*! position the cursor to a specific line and column. */ 711/*! position the cursor to a specific line and column. */
710void Screen::setCursorYX(int y, int x) 712void Screen::setCursorYX(int y, int x)
711{ 713{
712 setCursorY(y); setCursorX(x); 714 setCursorY(y); setCursorX(x);
713} 715}
714 716
715/*! Set the cursor to x-th line. */ 717/*! Set the cursor to x-th line. */
716 718
717void Screen::setCursorX(int x) 719void Screen::setCursorX(int x)
718{ 720{
719 if (x == 0) x = 1; // Default 721 if (x == 0) x = 1; // Default
720 x -= 1; // Adjust 722 x -= 1; // Adjust
721 cuX = QMAX(0,QMIN(columns-1, x)); 723 cuX = QMAX(0,QMIN(columns-1, x));
722} 724}
723 725
724/*! Set the cursor to y-th line. */ 726/*! Set the cursor to y-th line. */
725 727
726void Screen::setCursorY(int y) 728void Screen::setCursorY(int y)
727{ 729{
728 if (y == 0) y = 1; // Default 730 if (y == 0) y = 1; // Default
729 y -= 1; // Adjust 731 y -= 1; // Adjust
730 cuY = QMAX(0,QMIN(lines -1, y + (getMode(MODE_Origin) ? tmargin : 0) )); 732 cuY = QMAX(0,QMIN(lines -1, y + (getMode(MODE_Origin) ? tmargin : 0) ));
731} 733}
732 734
733/*! set cursor to the `left upper' corner of the screen (1,1). 735/*! set cursor to the `left upper' corner of the screen (1,1).
734*/ 736*/
735 737
736void Screen::home() 738void Screen::home()
737{ 739{
738 cuX = 0; 740 cuX = 0;
739 cuY = 0; 741 cuY = 0;
740} 742}
741 743
742/*! set cursor to the begin of the current line. 744/*! set cursor to the begin of the current line.
743*/ 745*/
744 746
745void Screen::Return() 747void Screen::Return()
746{ 748{
747 cuX = 0; 749 cuX = 0;
748} 750}
749 751
750/*! returns the current cursor columns. 752/*! returns the current cursor columns.
751*/ 753*/
752 754
753int Screen::getCursorX() 755int Screen::getCursorX()
754{ 756{
755 return cuX; 757 return cuX;
756} 758}
757 759
758/*! returns the current cursor line. 760/*! returns the current cursor line.
759*/ 761*/
760 762
761int Screen::getCursorY() 763int Screen::getCursorY()
762{ 764{
763 return cuY; 765 return cuY;
764} 766}
765 767
766// Erasing --------------------------------------------------------------------- 768// Erasing ---------------------------------------------------------------------
767 769
768/*! \section Erasing 770/*! \section Erasing
769 771
770 This group of operations erase parts of the screen contents by filling 772 This group of operations erase parts of the screen contents by filling
771 it with spaces colored due to the current rendition settings. 773 it with spaces colored due to the current rendition settings.
772 774
773 Althought the cursor position is involved in most of these operations, 775 Althought the cursor position is involved in most of these operations,
774 it is never modified by them. 776 it is never modified by them.
775*/ 777*/
776 778
777/*! fill screen between (including) `loca' and `loce' with spaces. 779/*! fill screen between (including) `loca' and `loce' with spaces.
778 780
779 This is an internal helper functions. The parameter types are internal 781 This is an internal helper functions. The parameter types are internal
780 addresses of within the screen image and make use of the way how the 782 addresses of within the screen image and make use of the way how the
781 screen matrix is mapped to the image vector. 783 screen matrix is mapped to the image vector.
782*/ 784*/
783 785
784void Screen::clearImage(int loca, int loce, char c) 786void Screen::clearImage(int loca, int loce, char c)
785{ int i; 787{ int i;
786 int scr_TL=loc(0,hist.getLines()); 788 int scr_TL=loc(0,hist.getLines());
787 //FIXME: check positions 789 //FIXME: check positions
788 790
789 //Clear entire selection if it overlaps region to be moved... 791 //Clear entire selection if it overlaps region to be moved...
790 if ( (sel_BR > (loca+scr_TL) )&&(sel_TL < (loce+scr_TL)) ) 792 if ( (sel_BR > (loca+scr_TL) )&&(sel_TL < (loce+scr_TL)) )
791 { 793 {
792 clearSelection(); 794 clearSelection();
793 } 795 }
794 for (i = loca; i <= loce; i++) 796 for (i = loca; i <= loce; i++)
795 { 797 {
796 image[i].c = c; 798 image[i].c = c;
797 image[i].f = ef_fg; //DEFAULT_FORE_COLOR; //FIXME: xterm and linux/ansi 799 image[i].f = ef_fg; //DEFAULT_FORE_COLOR; //FIXME: xterm and linux/ansi
798 image[i].b = ef_bg; //DEFAULT_BACK_COLOR; // many have different 800 image[i].b = ef_bg; //DEFAULT_BACK_COLOR; // many have different
799 image[i].r = ef_re; //DEFAULT_RENDITION; // ideas here. 801 image[i].r = ef_re; //DEFAULT_RENDITION; // ideas here.
800 } 802 }
801} 803}
802 804
803/*! move image between (including) `loca' and `loce' to 'dst'. 805/*! move image between (including) `loca' and `loce' to 'dst'.
804 806
805 This is an internal helper functions. The parameter types are internal 807 This is an internal helper functions. The parameter types are internal
806 addresses of within the screen image and make use of the way how the 808 addresses of within the screen image and make use of the way how the
807 screen matrix is mapped to the image vector. 809 screen matrix is mapped to the image vector.
808*/ 810*/
809 811
810void Screen::moveImage(int dst, int loca, int loce) 812void Screen::moveImage(int dst, int loca, int loce)
811{ 813{
812//FIXME: check positions 814//FIXME: check positions
813 if (loce < loca) { 815 if (loce < loca) {
814 // kdDebug() << "WARNING!!! call to Screen:moveImage with loce < loca!" << endl; 816 // kdDebug() << "WARNING!!! call to Screen:moveImage with loce < loca!" << endl;
815 return; 817 return;
816 } 818 }
817 memmove(&image[dst],&image[loca],(loce-loca+1)*sizeof(Character)); 819 memmove(&image[dst],&image[loca],(loce-loca+1)*sizeof(Character));
818} 820}
819 821
820/*! clear from (including) current cursor position to end of screen. 822/*! clear from (including) current cursor position to end of screen.
821*/ 823*/
822 824
823void Screen::clearToEndOfScreen() 825void Screen::clearToEndOfScreen()
824{ 826{
825 clearImage(loc(cuX,cuY),loc(columns-1,lines-1),' '); 827 clearImage(loc(cuX,cuY),loc(columns-1,lines-1),' ');
826} 828}
827 829
828/*! clear from begin of screen to (including) current cursor position. 830/*! clear from begin of screen to (including) current cursor position.
829*/ 831*/
830 832
831void Screen::clearToBeginOfScreen() 833void Screen::clearToBeginOfScreen()
832{ 834{
833 clearImage(loc(0,0),loc(cuX,cuY),' '); 835 clearImage(loc(0,0),loc(cuX,cuY),' ');
834} 836}
835 837
836/*! clear the entire screen. 838/*! clear the entire screen.
837*/ 839*/
838 840
839void Screen::clearEntireScreen() 841void Screen::clearEntireScreen()
840{ 842{
841 clearImage(loc(0,0),loc(columns-1,lines-1),' '); 843 clearImage(loc(0,0),loc(columns-1,lines-1),' ');
842} 844}
843 845
844/*! fill screen with 'E' 846/*! fill screen with 'E'
845 This is to aid screen alignment 847 This is to aid screen alignment
846*/ 848*/
847 849
848void Screen::helpAlign() 850void Screen::helpAlign()
849{ 851{
850 clearImage(loc(0,0),loc(columns-1,lines-1),'E'); 852 clearImage(loc(0,0),loc(columns-1,lines-1),'E');
851} 853}
852 854
853/*! clear from (including) current cursor position to end of current cursor line. 855/*! clear from (including) current cursor position to end of current cursor line.
854*/ 856*/
855 857
856void Screen::clearToEndOfLine() 858void Screen::clearToEndOfLine()
857{ 859{
858 clearImage(loc(cuX,cuY),loc(columns-1,cuY),' '); 860 clearImage(loc(cuX,cuY),loc(columns-1,cuY),' ');
859} 861}
860 862
861/*! clear from begin of current cursor line to (including) current cursor position. 863/*! clear from begin of current cursor line to (including) current cursor position.
862*/ 864*/
863 865
864void Screen::clearToBeginOfLine() 866void Screen::clearToBeginOfLine()
865{ 867{
866 clearImage(loc(0,cuY),loc(cuX,cuY),' '); 868 clearImage(loc(0,cuY),loc(cuX,cuY),' ');
867} 869}
868 870
869/*! clears entire current cursor line 871/*! clears entire current cursor line
870*/ 872*/
871 873
872void Screen::clearEntireLine() 874void Screen::clearEntireLine()
873{ 875{
874 clearImage(loc(0,cuY),loc(columns-1,cuY),' '); 876 clearImage(loc(0,cuY),loc(columns-1,cuY),' ');
875} 877}
876 878
877// Rendition ------------------------------------------------------------------ 879// Rendition ------------------------------------------------------------------
878 880
879/*! 881/*!
880 set rendition mode 882 set rendition mode
881*/ 883*/
882 884
883void Screen::setRendition(int re) 885void Screen::setRendition(int re)
884{ 886{
885 cu_re |= re; 887 cu_re |= re;
886 effectiveRendition(); 888 effectiveRendition();
887} 889}
888 890
889/*! 891/*!
890 reset rendition mode 892 reset rendition mode
891*/ 893*/
892 894
893void Screen::resetRendition(int re) 895void Screen::resetRendition(int re)
894{ 896{
895 cu_re &= ~re; 897 cu_re &= ~re;
896 effectiveRendition(); 898 effectiveRendition();
897} 899}
898 900
899/*! 901/*!
900*/ 902*/
901 903
902void Screen::setDefaultRendition() 904void Screen::setDefaultRendition()
903{ 905{
904 setForeColorToDefault(); 906 setForeColorToDefault();
905 setBackColorToDefault(); 907 setBackColorToDefault();
906 cu_re = DEFAULT_RENDITION; 908 cu_re = DEFAULT_RENDITION;
907 effectiveRendition(); 909 effectiveRendition();
908} 910}
909 911
910/*! 912/*!
911*/ 913*/
912 914
913void Screen::setForeColor(int fgcolor) 915void Screen::setForeColor(int fgcolor)
914{ 916{
915 cu_fg = (fgcolor&7)+((fgcolor&8) ? 4+8 : 2); 917 cu_fg = (fgcolor&7)+((fgcolor&8) ? 4+8 : 2);
916 effectiveRendition(); 918 effectiveRendition();
917} 919}
918 920
919/*! 921/*!
920*/ 922*/
921 923
922void Screen::setBackColor(int bgcolor) 924void Screen::setBackColor(int bgcolor)
923{ 925{
924 cu_bg = (bgcolor&7)+((bgcolor&8) ? 4+8 : 2); 926 cu_bg = (bgcolor&7)+((bgcolor&8) ? 4+8 : 2);
925 effectiveRendition(); 927 effectiveRendition();
926} 928}
927 929
928/*! 930/*!
929*/ 931*/
930 932
931void Screen::setBackColorToDefault() 933void Screen::setBackColorToDefault()
932{ 934{
933 cu_bg = DEFAULT_BACK_COLOR; 935 cu_bg = DEFAULT_BACK_COLOR;
934 effectiveRendition(); 936 effectiveRendition();
935} 937}
936 938
937/*! 939/*!
938*/ 940*/
939 941
940void Screen::setForeColorToDefault() 942void Screen::setForeColorToDefault()
941{ 943{
942 cu_fg = DEFAULT_FORE_COLOR; 944 cu_fg = DEFAULT_FORE_COLOR;
943 effectiveRendition(); 945 effectiveRendition();
944} 946}
945 947
946/* ------------------------------------------------------------------------- */ 948/* ------------------------------------------------------------------------- */
947/* */ 949/* */
948/* Marking & Selection */ 950/* Marking & Selection */
949/* */ 951/* */
950/* ------------------------------------------------------------------------- */ 952/* ------------------------------------------------------------------------- */
951 953
952void Screen::clearSelection() 954void Screen::clearSelection()
953{ 955{
954 sel_BR = -1; 956 sel_BR = -1;
955 sel_TL = -1; 957 sel_TL = -1;
956 sel_begin = -1; 958 sel_begin = -1;
957} 959}
958 960
959void Screen::setSelBeginXY(const int x, const int y) 961void Screen::setSelBeginXY(const int x, const int y)
960{ 962{
961 sel_begin = loc(x,y+histCursor) ; 963 sel_begin = loc(x,y+histCursor) ;
962 sel_BR = sel_begin; 964 sel_BR = sel_begin;
963 sel_TL = sel_begin; 965 sel_TL = sel_begin;
964} 966}
965 967
966void Screen::setSelExtentXY(const int x, const int y) 968void Screen::setSelExtentXY(const int x, const int y)
967{ 969{
968 if (sel_begin == -1) return; 970 if (sel_begin == -1) return;
969 int l = loc(x,y + histCursor); 971 int l = loc(x,y + histCursor);
970 972
971 if (l < sel_begin) 973 if (l < sel_begin)
972 { 974 {
973 sel_TL = l; 975 sel_TL = l;
974 sel_BR = sel_begin; 976 sel_BR = sel_begin;
975 } 977 }
976 else 978 else
977 { 979 {
978 /* FIXME, HACK to correct for x too far to the right... */ 980 /* FIXME, HACK to correct for x too far to the right... */
979 if (( x == columns )|| (x == 0)) l--; 981 if (( x == columns )|| (x == 0)) l--;
980 982
981 sel_TL = sel_begin; 983 sel_TL = sel_begin;
982 sel_BR = l; 984 sel_BR = l;
983 } 985 }
984} 986}
985 987
986QString Screen::getSelText(const BOOL preserve_line_breaks) 988QString Screen::getSelText(const BOOL preserve_line_breaks)
987{ 989{
988 if (sel_begin == -1) 990 if (sel_begin == -1)
989 return QString::null; // Selection got clear while selecting. 991 return QString::null; // Selection got clear while selecting.
990 992
991 int *m; // buffer to fill. 993 int *m; // buffer to fill.
992 int s, d; // source index, dest. index. 994 int s, d; // source index, dest. index.
993 int hist_BR = loc(0, hist.getLines()); 995 int hist_BR = loc(0, hist.getLines());
994 int hY = sel_TL / columns; 996 int hY = sel_TL / columns;
995 int hX = sel_TL % columns; 997 int hX = sel_TL % columns;
996 int eol; // end of line 998 int eol; // end of line
997 999
998 s = sel_TL; // tracks copy in source. 1000 s = sel_TL; // tracks copy in source.
999 1001
1000 // allocate buffer for maximum 1002 // allocate buffer for maximum
1001 // possible size... 1003 // possible size...
1002 d = (sel_BR - sel_TL) / columns + 1; 1004 d = (sel_BR - sel_TL) / columns + 1;
1003 m = new int[d * (columns + 1) + 2]; 1005 m = new int[d * (columns + 1) + 2];
1004 d = 0; 1006 d = 0;
1005 1007
1006 while (s <= sel_BR) 1008 while (s <= sel_BR)
1007 { 1009 {
1008 if (s < hist_BR) 1010 if (s < hist_BR)
1009 { // get lines from hist.history 1011 { // get lines from hist.history
1010 // buffer. 1012 // buffer.
1011 eol = hist.getLineLen(hY); 1013 eol = hist.getLineLen(hY);
1012 1014
1013 if ((hY == (sel_BR / columns)) && 1015 if ((hY == (sel_BR / columns)) &&
1014 (eol >= (sel_BR % columns))) 1016 (eol >= (sel_BR % columns)))
1015 { 1017 {
1016 eol = sel_BR % columns + 1; 1018 eol = sel_BR % columns + 1;
1017 } 1019 }
1018 1020
1019 while (hX < eol) 1021 while (hX < eol)
1020 { 1022 {
1021 m[d++] = hist.getCell(hY, hX++).c; 1023 m[d++] = hist.getCell(hY, hX++).c;
1022 s++; 1024 s++;
1023 } 1025 }
1024 1026
1025 if (s <= sel_BR) 1027 if (s <= sel_BR)
1026 { 1028 {
1027 // The line break handling 1029 // The line break handling
1028 // It's different from the screen 1030 // It's different from the screen
1029 // image case! 1031 // image case!
1030 if (eol % columns == 0) 1032 if (eol % columns == 0)
1031 { 1033 {
1032 // That's either a completely filled 1034 // That's either a completely filled
1033 // line or an empty line 1035 // line or an empty line
1034 if (eol == 0) 1036 if (eol == 0)
1035 { 1037 {
1036 m[d++] = '\n'; 1038 m[d++] = '\n';
1037 } 1039 }
1038 else 1040 else
1039 { 1041 {
1040 // We have a full line. 1042 // We have a full line.
1041 // FIXME: How can we handle newlines 1043 // FIXME: How can we handle newlines
1042 // at this position?! 1044 // at this position?!
1043 } 1045 }
1044 } 1046 }
1045 else if ((eol + 1) % columns == 0) 1047 else if ((eol + 1) % columns == 0)
1046 { 1048 {
1047 // FIXME: We don't know if this was a 1049 // FIXME: We don't know if this was a
1048 // space at the last position or a 1050 // space at the last position or a
1049 // short line!! 1051 // short line!!
1050 m[d++] = ' '; 1052 m[d++] = ' ';
1051 } 1053 }
1052 else 1054 else
1053 { 1055 {
1054 // We have a short line here. Put a 1056 // We have a short line here. Put a
1055 // newline or a space into the 1057 // newline or a space into the
1056 // buffer. 1058 // buffer.
1057 m[d++] = preserve_line_breaks ? '\n' : ' '; 1059 m[d++] = preserve_line_breaks ? '\n' : ' ';
1058 } 1060 }
1059 } 1061 }
1060 1062
1061 hY++; 1063 hY++;
1062 hX = 0; 1064 hX = 0;
1063 s = hY * columns; 1065 s = hY * columns;
1064 } 1066 }
1065 else 1067 else
1066 { // or from screen image. 1068 { // or from screen image.
1067 eol = (s / columns + 1) * columns - 1; 1069 eol = (s / columns + 1) * columns - 1;
1068 1070
1069 if (eol < sel_BR) 1071 if (eol < sel_BR)
1070 { 1072 {
1071 while ((eol > s) && 1073 while ((eol > s) &&
1072 isspace(image[eol - hist_BR].c)) 1074 isspace(image[eol - hist_BR].c))
1073 { 1075 {
1074 eol--; 1076 eol--;
1075 } 1077 }
1076 } 1078 }
1077 else 1079 else
1078 { 1080 {
1079 eol = sel_BR; 1081 eol = sel_BR;
1080 } 1082 }
1081 1083
1082 while (s <= eol) 1084 while (s <= eol)
1083 { 1085 {
1084 m[d++] = image[s++ - hist_BR].c; 1086 m[d++] = image[s++ - hist_BR].c;
1085 } 1087 }
1086 1088
1087 if (eol < sel_BR) 1089 if (eol < sel_BR)
1088 { 1090 {
1089 // eol processing see below ... 1091 // eol processing see below ...
1090 if ((eol + 1) % columns == 0) 1092 if ((eol + 1) % columns == 0)
1091 { 1093 {
1092 if (image[eol - hist_BR].c == ' ') 1094 if (image[eol - hist_BR].c == ' ')
1093 { 1095 {
1094 m[d++] = ' '; 1096 m[d++] = ' ';
1095 } 1097 }
1096 } 1098 }
1097 else 1099 else
1098 { 1100 {
1099 m[d++] = ((preserve_line_breaks || 1101 m[d++] = ((preserve_line_breaks ||
1100 ((eol % columns) == 0)) ? 1102 ((eol % columns) == 0)) ?
1101 '\n' : ' '); 1103 '\n' : ' ');
1102 } 1104 }
1103 } 1105 }
1104 1106
1105 s = (eol / columns + 1) * columns; 1107 s = (eol / columns + 1) * columns;
1106 } 1108 }
1107 } 1109 }
1108 1110
1109 QChar* qc = new QChar[d]; 1111 QChar* qc = new QChar[d];
1110 1112
1111 for (int i = 0; i < d; i++) 1113 for (int i = 0; i < d; i++)
1112 { 1114 {
1113 qc[i] = m[i]; 1115 qc[i] = m[i];
1114 } 1116 }
1115 1117
1116 QString res(qc, d); 1118 QString res(qc, d);
1117 1119
1118 delete m; 1120 delete m;
1119 delete qc; 1121 delete qc;
1120 1122
1121 return res; 1123 return res;
1122} 1124}
1123/* above ... end of line processing for selection -- psilva 1125/* above ... end of line processing for selection -- psilva
1124cases: 1126cases:
1125 1127
11261) (eol+1)%columns == 0 --> the whole line is filled. 11281) (eol+1)%columns == 0 --> the whole line is filled.
1127 If the last char is a space, insert (preserve) space. otherwise 1129 If the last char is a space, insert (preserve) space. otherwise
1128 leave the text alone, so that words that are broken by linewrap 1130 leave the text alone, so that words that are broken by linewrap
1129 are preserved. 1131 are preserved.
1130 1132
1131FIXME: 1133FIXME:
1132 * this suppresses \n for command output that is 1134 * this suppresses \n for command output that is
1133 sized to the exact column width of the screen. 1135 sized to the exact column width of the screen.
1134 1136
11352) eol%columns == 0 --> blank line. 11372) eol%columns == 0 --> blank line.
1136 insert a \n unconditionally. 1138 insert a \n unconditionally.
1137 Do it either you would because you are in preserve_line_break mode, 1139 Do it either you would because you are in preserve_line_break mode,
1138 or because it's an ASCII paragraph delimiter, so even when 1140 or because it's an ASCII paragraph delimiter, so even when
1139 not preserving line_breaks, you want to preserve paragraph breaks. 1141 not preserving line_breaks, you want to preserve paragraph breaks.
1140 1142
1141 3) else --> partially filled line 1143 3) else --> partially filled line
1142 insert a \n in preserve line break mode, else a space 1144 insert a \n in preserve line break mode, else a space
1143 The space prevents concatenation of the last word of one 1145 The space prevents concatenation of the last word of one
1144 line with the first of the next. 1146 line with the first of the next.
1145 1147
1146*/ 1148*/
1147 1149
1148void Screen::addHistLine() 1150void Screen::addHistLine()
1149{ 1151{
1150 assert(hasScroll() || histCursor == 0); 1152 assert(hasScroll() || histCursor == 0);
1151 1153
1152 // add to hist buffer 1154 // add to hist buffer
1153 // we have to take care about scrolling, too... 1155 // we have to take care about scrolling, too...
1154 1156
1155 if (hasScroll()) 1157 if (hasScroll())
1156 { Character dft; 1158 { Character dft;
1157 1159
1158 int end = columns-1; 1160 int end = columns-1;
1159 while (end >= 0 && image[end] == dft) 1161 while (end >= 0 && image[end] == dft)
1160 end -= 1; 1162 end -= 1;
1161 1163
1162 hist.addCells(image,end+1); 1164 hist.addCells(image.data(), end+1);
1163 hist.addLine(); 1165 hist.addLine();
1164 1166
1165 // adjust history cursor 1167 // adjust history cursor
1166 histCursor += (hist.getLines()-1 == histCursor); 1168 histCursor += (hist.getLines()-1 == histCursor);
1167 } 1169 }
1168 1170
1169 if (!hasScroll()) histCursor = 0; //FIXME: a poor workaround 1171 if (!hasScroll()) histCursor = 0; //FIXME: a poor workaround
1170} 1172}
1171 1173
1172void Screen::setHistCursor(int cursor) 1174void Screen::setHistCursor(int cursor)
1173{ 1175{
1174 histCursor = cursor; //FIXME:rangecheck 1176 histCursor = cursor; //FIXME:rangecheck
1175} 1177}
1176 1178
1177int Screen::getHistCursor() 1179int Screen::getHistCursor()
1178{ 1180{
1179 return histCursor; 1181 return histCursor;
1180} 1182}
1181 1183
1182int Screen::getHistLines() 1184int Screen::getHistLines()
1183{ 1185{
1184 return hist.getLines(); 1186 return hist.getLines();
1185} 1187}
1186 1188
1187void Screen::setScroll(bool on) 1189void Screen::setScroll(bool on)
1188{ 1190{
1189 histCursor = 0; 1191 histCursor = 0;
1190 clearSelection(); 1192 clearSelection();
1191 hist.setScroll(on); 1193 hist.setScroll(on);
1192} 1194}
1193 1195
1194bool Screen::hasScroll() 1196bool Screen::hasScroll()
1195{ 1197{
1196 return hist.hasScroll(); 1198 return hist.hasScroll();
1197} 1199}
diff --git a/noncore/apps/opie-console/screen.h b/noncore/apps/opie-console/screen.h
index cd7422a..38b84ab 100644
--- a/noncore/apps/opie-console/screen.h
+++ b/noncore/apps/opie-console/screen.h
@@ -1,259 +1,259 @@
1/* -------------------------------------------------------------------------- */ 1/* -------------------------------------------------------------------------- */
2/* */ 2/* */
3/* [screen.h] Screen Data Type */ 3/* [screen.h] Screen Data Type */
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#ifndef SCREEN_H 19#ifndef SCREEN_H
20#define SCREEN_H 20#define SCREEN_H
21 21
22/*! \file 22/*! \file
23*/ 23*/
24 24
25#include "common.h" 25#include "common.h"
26#include "history.h" 26#include "history.h"
27 27
28#define MODE_Origin 0 28#define MODE_Origin 0
29#define MODE_Wrap 1 29#define MODE_Wrap 1
30#define MODE_Insert 2 30#define MODE_Insert 2
31#define MODE_Screen 3 31#define MODE_Screen 3
32#define MODE_Cursor 4 32#define MODE_Cursor 4
33#define MODE_NewLine 5 33#define MODE_NewLine 5
34#define MODES_SCREEN 6 34#define MODES_SCREEN 6
35 35
36/*! 36/*!
37*/ 37*/
38struct ScreenParm 38struct ScreenParm
39{ 39{
40 int mode[MODES_SCREEN]; 40 int mode[MODES_SCREEN];
41}; 41};
42 42
43 43
44class Screen 44class Screen
45{ 45{
46public: 46public:
47 Screen(int lines, int columns); 47 Screen(int lines, int columns);
48 ~Screen(); 48 ~Screen();
49 49
50public: // these are all `Screen' operations 50public: // these are all `Screen' operations
51 // 51 //
52 // VT100/2 Operations ------------------ 52 // VT100/2 Operations ------------------
53 // 53 //
54 // Cursor Movement 54 // Cursor Movement
55 // 55 //
56 void cursorUp (int n); 56 void cursorUp (int n);
57 void cursorDown (int n); 57 void cursorDown (int n);
58 void cursorLeft (int n); 58 void cursorLeft (int n);
59 void cursorRight (int n); 59 void cursorRight (int n);
60 void setCursorY (int y); 60 void setCursorY (int y);
61 void setCursorX (int x); 61 void setCursorX (int x);
62 void setCursorYX (int y, int x); 62 void setCursorYX (int y, int x);
63 void setMargins (int t, int b); 63 void setMargins (int t, int b);
64 // 64 //
65 // Cursor Movement with Scrolling 65 // Cursor Movement with Scrolling
66 // 66 //
67 void NewLine (); 67 void NewLine ();
68 void NextLine (); 68 void NextLine ();
69 void index (); 69 void index ();
70 void reverseIndex(); 70 void reverseIndex();
71 // 71 //
72 void Return (); 72 void Return ();
73 void BackSpace (); 73 void BackSpace ();
74 void Tabulate (); 74 void Tabulate ();
75 // 75 //
76 // Editing 76 // Editing
77 // 77 //
78 void eraseChars (int n); 78 void eraseChars (int n);
79 void deleteChars (int n); 79 void deleteChars (int n);
80 void insertChars (int n); 80 void insertChars (int n);
81 void deleteLines (int n); 81 void deleteLines (int n);
82 void insertLines (int n); 82 void insertLines (int n);
83 // 83 //
84 // ------------------------------------- 84 // -------------------------------------
85 // 85 //
86 void clearTabStops(); 86 void clearTabStops();
87 void changeTabStop(bool set); 87 void changeTabStop(bool set);
88 // 88 //
89 void resetMode (int n); 89 void resetMode (int n);
90 void setMode (int n); 90 void setMode (int n);
91 void saveMode (int n); 91 void saveMode (int n);
92 void restoreMode (int n); 92 void restoreMode (int n);
93 // 93 //
94 void saveCursor (); 94 void saveCursor ();
95 void restoreCursor(); 95 void restoreCursor();
96 // 96 //
97 // ------------------------------------- 97 // -------------------------------------
98 // 98 //
99 void clearEntireScreen(); 99 void clearEntireScreen();
100 void clearToEndOfScreen(); 100 void clearToEndOfScreen();
101 void clearToBeginOfScreen(); 101 void clearToBeginOfScreen();
102 // 102 //
103 void clearEntireLine(); 103 void clearEntireLine();
104 void clearToEndOfLine(); 104 void clearToEndOfLine();
105 void clearToBeginOfLine(); 105 void clearToBeginOfLine();
106 // 106 //
107 void helpAlign (); 107 void helpAlign ();
108 // 108 //
109 // ------------------------------------- 109 // -------------------------------------
110 // 110 //
111 void setRendition (int rendition); 111 void setRendition (int rendition);
112 void resetRendition(int rendition); 112 void resetRendition(int rendition);
113 void setForeColor (int fgcolor); 113 void setForeColor (int fgcolor);
114 void setBackColor (int bgcolor); 114 void setBackColor (int bgcolor);
115 // 115 //
116 void setDefaultRendition(); 116 void setDefaultRendition();
117 void setForeColorToDefault(); 117 void setForeColorToDefault();
118 void setBackColorToDefault(); 118 void setBackColorToDefault();
119 // 119 //
120 // ------------------------------------- 120 // -------------------------------------
121 // 121 //
122 BOOL getMode (int n); 122 BOOL getMode (int n);
123 // 123 //
124 // only for report cursor position 124 // only for report cursor position
125 // 125 //
126 int getCursorX(); 126 int getCursorX();
127 int getCursorY(); 127 int getCursorY();
128 // 128 //
129 // ------------------------------------- 129 // -------------------------------------
130 // 130 //
131 void clear(); 131 void clear();
132 void home(); 132 void home();
133 void reset(); 133 void reset();
134 // 134 //
135 void ShowCharacter(unsigned short c); 135 void ShowCharacter(unsigned short c);
136 // 136 //
137 void resizeImage(int new_lines, int new_columns); 137 void resizeImage(int new_lines, int new_columns);
138 // 138 //
139 Character* getCookedImage(); 139 QArray<Character> getCookedImage();
140 140
141 /*! return the number of lines. */ 141 /*! return the number of lines. */
142 int getLines() { return lines; } 142 int getLines() { return lines; }
143 /*! return the number of columns. */ 143 /*! return the number of columns. */
144 int getColumns() { return columns; } 144 int getColumns() { return columns; }
145 145
146 /*! set the position of the history cursor. */ 146 /*! set the position of the history cursor. */
147 void setHistCursor(int cursor); 147 void setHistCursor(int cursor);
148 /*! return the position of the history cursor. */ 148 /*! return the position of the history cursor. */
149 int getHistCursor(); 149 int getHistCursor();
150 150
151 int getHistLines (); 151 int getHistLines ();
152 void setScroll(bool on); 152 void setScroll(bool on);
153 bool hasScroll(); 153 bool hasScroll();
154 154
155 // 155 //
156 // Selection 156 // Selection
157 // 157 //
158 void setSelBeginXY(const int x, const int y); 158 void setSelBeginXY(const int x, const int y);
159 void setSelExtentXY(const int x, const int y); 159 void setSelExtentXY(const int x, const int y);
160 void clearSelection(); 160 void clearSelection();
161 QString getSelText(const BOOL preserve_line_breaks); 161 QString getSelText(const BOOL preserve_line_breaks);
162 162
163 void checkSelection(int from, int to); 163 void checkSelection(int from, int to);
164 164
165private: // helper 165private: // helper
166 166
167 void clearImage(int loca, int loce, char c); 167 void clearImage(int loca, int loce, char c);
168 void moveImage(int dst, int loca, int loce); 168 void moveImage(int dst, int loca, int loce);
169 169
170 void scrollUp(int from, int i); 170 void scrollUp(int from, int i);
171 void scrollDown(int from, int i); 171 void scrollDown(int from, int i);
172 172
173 void addHistLine(); 173 void addHistLine();
174 174
175 void initTabStops(); 175 void initTabStops();
176 176
177 void effectiveRendition(); 177 void effectiveRendition();
178 void reverseRendition(Character* p); 178 void reverseRendition( Character *p );
179 179
180private: 180private:
181 181
182 /* 182 /*
183 The state of the screen is more complex as one would 183 The state of the screen is more complex as one would
184 expect first. The screem does really do part of the 184 expect first. The screem does really do part of the
185 emulation providing state informations in form of modes, 185 emulation providing state informations in form of modes,
186 margins, tabulators, cursor etc. 186 margins, tabulators, cursor etc.
187 187
188 Even more unexpected are variables to save and restore 188 Even more unexpected are variables to save and restore
189 parts of the state. 189 parts of the state.
190 */ 190 */
191 191
192 // screen image ---------------- 192 // screen image ----------------
193 193
194 int lines; 194 int lines;
195 int columns; 195 int columns;
196 Character *image; // [lines][columns] 196 QArray<Character> image; // [lines][columns]
197 197
198 // history buffer --------------- 198 // history buffer ---------------
199 199
200 int histCursor; // display position relative to start of the history buffer 200 int histCursor; // display position relative to start of the history buffer
201 HistoryScroll hist; 201 HistoryScroll hist;
202 202
203 // cursor location 203 // cursor location
204 204
205 int cuX; 205 int cuX;
206 int cuY; 206 int cuY;
207 207
208 // cursor color and rendition info 208 // cursor color and rendition info
209 209
210 UINT8 cu_fg; // foreground 210 UINT8 cu_fg; // foreground
211 UINT8 cu_bg; // background 211 UINT8 cu_bg; // background
212 UINT8 cu_re; // rendition 212 UINT8 cu_re; // rendition
213 213
214 // margins ---------------- 214 // margins ----------------
215 215
216 int tmargin; // top margin 216 int tmargin; // top margin
217 int bmargin; // bottom margin 217 int bmargin; // bottom margin
218 218
219 // states ---------------- 219 // states ----------------
220 220
221 ScreenParm currParm; 221 ScreenParm currParm;
222 222
223 // ---------------------------- 223 // ----------------------------
224 224
225 bool* tabstops; 225 bool* tabstops;
226 226
227 // selection ------------------- 227 // selection -------------------
228 228
229 int sel_begin; // The first location selected. 229 int sel_begin; // The first location selected.
230 int sel_TL; // TopLeft Location. 230 int sel_TL; // TopLeft Location.
231 int sel_BR; // Bottom Right Location. 231 int sel_BR; // Bottom Right Location.
232 232
233 // effective colors and rendition ------------ 233 // effective colors and rendition ------------
234 234
235 UINT8 ef_fg; // These are derived from 235 UINT8 ef_fg; // These are derived from
236 UINT8 ef_bg; // the cu_* variables above 236 UINT8 ef_bg; // the cu_* variables above
237 UINT8 ef_re; // to speed up operation 237 UINT8 ef_re; // to speed up operation
238 238
239 // 239 //
240 // save cursor, rendition & states ------------ 240 // save cursor, rendition & states ------------
241 // 241 //
242 242
243 // cursor location 243 // cursor location
244 244
245 int sa_cuX; 245 int sa_cuX;
246 int sa_cuY; 246 int sa_cuY;
247 247
248 // rendition info 248 // rendition info
249 249
250 UINT8 sa_cu_re; 250 UINT8 sa_cu_re;
251 UINT8 sa_cu_fg; 251 UINT8 sa_cu_fg;
252 UINT8 sa_cu_bg; 252 UINT8 sa_cu_bg;
253 253
254 // modes 254 // modes
255 255
256 ScreenParm saveParm; 256 ScreenParm saveParm;
257}; 257};
258 258
259#endif // TESCREEN_H 259#endif // TESCREEN_H
diff --git a/noncore/apps/opie-console/vt102emulation.cpp b/noncore/apps/opie-console/vt102emulation.cpp
index 2220f4e..7eecef3 100644
--- a/noncore/apps/opie-console/vt102emulation.cpp
+++ b/noncore/apps/opie-console/vt102emulation.cpp
@@ -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(WidgetLayer* 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->insertSelection(); return;
741 case CMD_scrollPageUp : gui->doScroll(-gui->Lines()/2); return; 741 case CMD_scrollPageUp : gui->scroll(-gui->lines()/2); return;
742 case CMD_scrollPageDown : gui->doScroll(+gui->Lines()/2); return; 742 case CMD_scrollPageDown : gui->scroll(+gui->lines()/2); return;
743 case CMD_scrollLineUp : gui->doScroll(-1 ); return; 743 case CMD_scrollLineUp : gui->scroll(-1 ); return;
744 case CMD_scrollLineDown : gui->doScroll(+1 ); return; 744 case CMD_scrollLineDown : gui->scroll(+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 a3d0ae6..de4a62f 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(WidgetLayer* 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
diff --git a/noncore/apps/opie-console/widget_layer.h b/noncore/apps/opie-console/widget_layer.h
index 6e2e61e..5bd2ef9 100644
--- a/noncore/apps/opie-console/widget_layer.h
+++ b/noncore/apps/opie-console/widget_layer.h
@@ -1,243 +1,254 @@
1/* -------------------------------------------------------------------------- */ 1/* -------------------------------------------------------------------------- */
2/* */ 2/* */
3/* [widget_layer.h] Widget Layer */ 3/* [widget_layer.h] Widget Layer */
4/* */ 4/* */
5/* -------------------------------------------------------------------------- */ 5/* -------------------------------------------------------------------------- */
6 6
7// proposal of a widget Layer in opie-console 7// proposal of a widget Layer in opie-console
8// 8//
9// fellow devels: 9// fellow devels:
10// just mail me (ibotty@web.de), what you additionally need from the main widget 10// just mail me (ibotty@web.de), what you additionally need from the main widget
11// (or say in chat) 11// (or say in chat)
12 12
13#ifndef WIDGET_LAYER_H 13#ifndef WIDGET_LAYER_H
14#define WIDGET_LAYER_H 14#define WIDGET_LAYER_H
15 15
16// qt includes 16// qt includes
17#include <qapplication.h> 17#include <qapplication.h>
18#include <qframe.h> 18#include <qframe.h>
19#include <qarray.h> 19#include <qarray.h>
20#include <qtimer.h> 20#include <qtimer.h>
21#include <qkeycode.h> 21#include <qkeycode.h>
22#include <qclipboard.h> 22#include <qclipboard.h>
23 23
24 24
25// opie-console includes 25// opie-console includes
26#include "session.h" 26#include "session.h"
27#include "common.h" 27#include "common.h"
28#include "profile.h" 28#include "profile.h"
29/* 29/*
30 * given a pseudo location ( column, line ), 30 * given a pseudo location ( column, line ),
31 * returns the actual index, in the QArray<Character> 31 * returns the actual index, in the QArray<Character>
32 */ 32 */
33#define loc(X,Y) ((Y)*m_columns+(X)) 33#define loc(X,Y) ((Y)*m_columns+(X))
34 34
35 35
36 36
37 37
38class WidgetLayer : public QFrame 38class WidgetLayer : public QFrame
39{ Q_OBJECT 39{ Q_OBJECT
40 40
41public: 41public:
42 42
43 /** 43 /**
44 * constructor 44 * constructor
45 * @param const Profile &config, the configuration for this widget 45 * @param const Profile &config, the configuration for this widget
46 * @param QWidget *parent, the parent widget 46 * @param QWidget *parent, the parent widget
47 * @param const char *name, the name of the widget, defaults to "" 47 * @param const char *name, the name of the widget, defaults to ""
48 */ 48 */
49 WidgetLayer( const Profile& config, QWidget *parent=0, const char *name=0 ); 49 WidgetLayer( const Profile& config, QWidget *parent=0, const char *name=0 );
50 50
51 /** 51 /**
52 * destructor 52 * destructor
53 */ 53 */
54 virtual ~WidgetLayer(); 54 virtual ~WidgetLayer();
55 55
56public: 56public:
57 /** 57 /**
58 * sets the image 58 * sets the image
59 * @param QArray<Character> const newimg, the new image 59 * @param QArray<Character> const newimg, the new image
60 * @param int lines, lines count of newimg 60 * @param int lines, lines count of newimg
61 * @param int columns, columns count of newimg 61 * @param int columns, columns count of newimg
62 */ 62 */
63 virtual void setImage( QArray<Character> const newimg, int lines, int colums ) = 0; 63 virtual void setImage( QArray<Character> const newimg, int lines, int colums ) = 0;
64 64
65 /** 65 /**
66 * annoy the user 66 * annoy the user
67 */ 67 */
68 void bell(); 68 void bell();
69 69
70 /** 70 /**
71 * @return int m_lines, the lines count 71 * @return int m_lines, the lines count
72 */ 72 */
73 int lines(){ return m_lines; } 73 int lines(){ return m_lines; }
74 74
75 /** 75 /**
76 * @return int m_columns, the columns count 76 * @return int m_columns, the columns count
77 */ 77 */
78 int columns(){ return m_columns; } 78 int columns(){ return m_columns; }
79 79
80 /** 80 /**
81 * insert current selection (currently this is only the clipboard) 81 * insert current selection (currently this is only the clipboard)
82 */ 82 */
83 void insertSelection(); 83 void insertSelection();
84 84
85 /** 85 /**
86 * insert text 86 * insert text
87 * @param QString text, the text to be inserted 87 * @param QString text, the text to be inserted
88 */ 88 */
89 void insertText( QString text ); 89 void insertText( QString text );
90 90
91 /** 91 /**
92 * set selection (clipboard) to text 92 * set selection (clipboard) to text
93 * @param const QString &text, the text to be selected 93 * @param const QString &text, the text to be selected
94 */ 94 */
95 void setSelection( const QString &text ); 95 void setSelection( const QString &text );
96 96
97 /** 97 /**
98 * paste content of clipboard 98 * paste content of clipboard
99 */ 99 */
100 void pasteClipboard(); 100 void pasteClipboard();
101 101
102 102
103 /** 103 /**
104 * reload configuration 104 * reload configuration
105 */ 105 */
106 virtual void reloadConfig() = 0; 106 virtual void reloadConfig() = 0;
107 107
108 108
109 /**
110 * sets the scrollbar (if implemented by successor of this class)
111 */
112 virtual void setScroll( int cursor, int slines );
113
114 /**
115 * scrolls (if implemented, by successor of this class)
116 * @param int value, how much the widget should scroll up (positive value) or down (negative value)
117 */
118 virtual void scroll( int value );
119
109signals: 120signals:
110 121
111 /** 122 /**
112 * key was pressed 123 * key was pressed
113 */ 124 */
114 void keyPressed( QKeyEvent *e ); 125 void keyPressed( QKeyEvent *e );
115 126
116 /** 127 /**
117 * whenever Mouse selects something 128 * whenever Mouse selects something
118 * @param int button, the button that us pressed : 129 * @param int button, the button that us pressed :
119 * 0left Button 130 * 0left Button
120 * 3Button released 131 * 3Button released
121 * @param int x, x position 132 * @param int x, x position
122 * @param int y, y position 133 * @param int y, y position
123 * 134 *
124 * // numbering due to layout in old TEWidget 135 * // numbering due to layout in old TEWidget
125 */ 136 */
126 void mousePressed( int button, int x, int y ); 137 void mousePressed( int button, int x, int y );
127 138
128 /** 139 /**
129 * size of image changed 140 * size of image changed
130 * @param int lines, line count of new size 141 * @param int lines, line count of new size
131 * @param int columns, column count of new size 142 * @param int columns, column count of new size
132 */ 143 */
133 void imageSizeChanged( int lines, int columns ); 144 void imageSizeChanged( int lines, int columns );
134 145
135 /** 146 /**
136 * cursor in history changed 147 * cursor in history changed
137 * @param int value, value of history cursor 148 * @param int value, value of history cursor
138 */ 149 */
139 void historyCursorChanged( int value ); 150 void historyCursorChanged( int value );
140 151
141 /** 152 /**
142 * selection should be cleared 153 * selection should be cleared
143 */ 154 */
144 void selectionCleared(); 155 void selectionCleared();
145 156
146 /** 157 /**
147 * selection begin 158 * selection begin
148 * @param const int x, x position 159 * @param const int x, x position
149 * @param const int y, y position 160 * @param const int y, y position
150 */ 161 */
151 void selectionBegin( const int x, const int y ); 162 void selectionBegin( const int x, const int y );
152 163
153 /** 164 /**
154 * selection extended 165 * selection extended
155 * (from begin (s.a.) to x, y) 166 * (from begin (s.a.) to x, y)
156 * @param const int x, x position 167 * @param const int x, x position
157 * @param const int y, y position 168 * @param const int y, y position
158 */ 169 */
159 void selectionExtended( const int x, const int y ); 170 void selectionExtended( const int x, const int y );
160 171
161 /** 172 /**
162 * selection end 173 * selection end
163 * @param const bool lineBreakPreserve, preserve line breaks in selection 174 * @param const bool lineBreakPreserve, preserve line breaks in selection
164 */ 175 */
165 void selectionEnd( const bool lineBreakPreserve ); 176 void selectionEnd( const bool lineBreakPreserve );
166 177
167 178
168 179
169// protected methods 180// protected methods
170protected: 181protected:
171 182
172 // image operations 183 // image operations
173 184
174 /** 185 /**
175 * changes image, to suit new size 186 * changes image, to suit new size
176 * TODO: find meaningful name! 187 * TODO: find meaningful name!
177 */ 188 */
178 void propagateSize(); 189 void propagateSize();
179 190
180 /** 191 /**
181 *determines count of lines and columns 192 *determines count of lines and columns
182 */ 193 */
183 virtual void calcGeometry() = 0; 194 virtual void calcGeometry() = 0;
184 195
185 /** 196 /**
186 * makes an empty image 197 * makes an empty image
187 */ 198 */
188 void makeImage(); 199 void makeImage();
189 200
190 /** 201 /**
191 * clears the image 202 * clears the image
192 */ 203 */
193 void clearImage(); 204 void clearImage();
194 205
195protected slots: 206protected slots:
196 207
197 /** 208 /**
198 * clear selection 209 * clear selection
199 */ 210 */
200 void onClearSelection(); 211 void onClearSelection();
201 212
202 213
203// protected vars 214// protected vars
204protected: 215protected:
205 216
206 /** 217 /**
207 * current Session 218 * current Session
208 */ 219 */
209 Session *m_session; 220 Session *m_session;
210 221
211 /** 222 /**
212 * current character image 223 * current character image
213 * 224 *
214 * a Character at loc( column, line ) 225 * a Character at loc( column, line )
215 * has the actual index: 226 * has the actual index:
216 * ix = line * m_columns + column; 227 * ix = line * m_columns + column;
217 * 228 *
218 * use loc( x, y ) macro to access. 229 * use loc( x, y ) macro to access.
219 */ 230 */
220 QArray<Character> m_image; 231 QArray<Character> m_image;
221 232
222 /** 233 /**
223 * lines count 234 * lines count
224 */ 235 */
225 int m_lines; 236 int m_lines;
226 237
227 /** 238 /**
228 * columns count 239 * columns count
229 */ 240 */
230 int m_columns; 241 int m_columns;
231 242
232 /** 243 /**
233 * clipboard 244 * clipboard
234 */ 245 */
235 QClipboard* m_clipboard; 246 QClipboard* m_clipboard;
236 247
237 /** 248 /**
238 * whether widget is resizing 249 * whether widget is resizing
239 */ 250 */
240 bool m_resizing; 251 bool m_resizing;
241}; 252};
242 253
243#endif // WIDGET_LAYER_H 254#endif // WIDGET_LAYER_H