summaryrefslogtreecommitdiff
authorharlekin <harlekin>2004-02-01 12:52:08 (UTC)
committer harlekin <harlekin>2004-02-01 12:52:08 (UTC)
commit29220ef88ff2f93cef17695e3733da62c16d89ca (patch) (unidiff)
treec98007f673dfcf3480ac7e1a61746ce7d68c5b45
parentda02269f0d59e4cc932b9dbc7294374e3398ecad (diff)
downloadopie-29220ef88ff2f93cef17695e3733da62c16d89ca.zip
opie-29220ef88ff2f93cef17695e3733da62c16d89ca.tar.gz
opie-29220ef88ff2f93cef17695e3733da62c16d89ca.tar.bz2
less includes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/MyPty.cpp2
-rw-r--r--noncore/apps/opie-console/TEWidget.cpp8
-rw-r--r--noncore/apps/opie-console/TEmuVt102.cpp5
-rw-r--r--noncore/apps/opie-console/TEmulation.cpp3
-rw-r--r--noncore/apps/opie-console/configdialog.cpp3
-rw-r--r--noncore/apps/opie-console/consoleconfigwidget.cpp2
-rw-r--r--noncore/apps/opie-console/default.cpp1
-rw-r--r--noncore/apps/opie-console/dialdialog.cpp3
-rw-r--r--noncore/apps/opie-console/emulation_handler.cpp3
-rw-r--r--noncore/apps/opie-console/emulation_layer.cpp3
-rw-r--r--noncore/apps/opie-console/emulation_widget.cpp8
-rw-r--r--noncore/apps/opie-console/file_layer.cpp1
-rw-r--r--noncore/apps/opie-console/filetransfer.cpp1
-rw-r--r--noncore/apps/opie-console/function_keyboard.cpp8
-rw-r--r--noncore/apps/opie-console/iolayerbase.cpp2
-rw-r--r--noncore/apps/opie-console/main.cpp1
-rw-r--r--noncore/apps/opie-console/mainwindow.cpp10
-rw-r--r--noncore/apps/opie-console/metafactory.cpp1
-rw-r--r--noncore/apps/opie-console/modemconfigwidget.cpp2
-rw-r--r--noncore/apps/opie-console/profileeditordialog.cpp1
-rw-r--r--noncore/apps/opie-console/profilemanager.cpp5
-rw-r--r--noncore/apps/opie-console/receive_layer.cpp3
-rw-r--r--noncore/apps/opie-console/script.cpp1
-rw-r--r--noncore/apps/opie-console/session.cpp2
-rw-r--r--noncore/apps/opie-console/terminalwidget.cpp4
-rw-r--r--noncore/apps/opie-console/transferdialog.cpp2
-rw-r--r--noncore/apps/opie-console/vt102emulation.cpp5
-rw-r--r--noncore/apps/opie-console/widget.cpp8
-rw-r--r--noncore/apps/opie-console/widget_layer.cpp4
29 files changed, 0 insertions, 102 deletions
diff --git a/noncore/apps/opie-console/MyPty.cpp b/noncore/apps/opie-console/MyPty.cpp
index b2f6a74..a37f980 100644
--- a/noncore/apps/opie-console/MyPty.cpp
+++ b/noncore/apps/opie-console/MyPty.cpp
@@ -1,368 +1,366 @@
1/* -------------------------------------------------------------------------- */ 1/* -------------------------------------------------------------------------- */
2/* */ 2/* */
3/* [MyPty.C] Pseudo Terminal Device */ 3/* [MyPty.C] Pseudo Terminal Device */
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/* Ported Konsole to Qt/Embedded */ 12/* Ported Konsole to Qt/Embedded */
13 /* */ 13 /* */
14/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ 14/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */
15 /* */ 15 /* */
16/* -------------------------------------------------------------------------- */ 16/* -------------------------------------------------------------------------- */
17 17
18/* If you're compiling konsole on non-Linux platforms and find 18/* If you're compiling konsole on non-Linux platforms and find
19 problems that you can track down to this file, please have 19 problems that you can track down to this file, please have
20 a look into ../README.ports, too. 20 a look into ../README.ports, too.
21*/ 21*/
22 22
23/*! \file 23/*! \file
24*/ 24*/
25 25
26/*! \class TEPty 26/*! \class TEPty
27 27
28 \brief Ptys provide a pseudo terminal connection to a program. 28 \brief Ptys provide a pseudo terminal connection to a program.
29 29
30 Although closely related to pipes, these pseudo terminal connections have 30 Although closely related to pipes, these pseudo terminal connections have
31 some ability, that makes it nessesary to uses them. Most importent, they 31 some ability, that makes it nessesary to uses them. Most importent, they
32 know about changing screen sizes and UNIX job control. 32 know about changing screen sizes and UNIX job control.
33 33
34 Within the terminal emulation framework, this class represents the 34 Within the terminal emulation framework, this class represents the
35 host side of the terminal together with the connecting serial line. 35 host side of the terminal together with the connecting serial line.
36 36
37 One can create many instances of this class within a program. 37 One can create many instances of this class within a program.
38 As a side effect of using this class, a signal(2) handler is 38 As a side effect of using this class, a signal(2) handler is
39 installed on SIGCHLD. 39 installed on SIGCHLD.
40 40
41 \par FIXME 41 \par FIXME
42 42
43 [NOTE: much of the technical stuff below will be replaced by forkpty.] 43 [NOTE: much of the technical stuff below will be replaced by forkpty.]
44 44
45 publish the SIGCHLD signal if not related to an instance. 45 publish the SIGCHLD signal if not related to an instance.
46 46
47 clearify TEPty::done vs. TEPty::~TEPty semantics. 47 clearify TEPty::done vs. TEPty::~TEPty semantics.
48 check if pty is restartable via run after done. 48 check if pty is restartable via run after done.
49 49
50 \par Pseudo terminals 50 \par Pseudo terminals
51 51
52 Pseudo terminals are a unique feature of UNIX, and always come in form of 52 Pseudo terminals are a unique feature of UNIX, and always come in form of
53 pairs of devices (/dev/ptyXX and /dev/ttyXX), which are connected to each 53 pairs of devices (/dev/ptyXX and /dev/ttyXX), which are connected to each
54 other by the operating system. One may think of them as two serial devices 54 other by the operating system. One may think of them as two serial devices
55 linked by a null-modem cable. Being based on devices the number of 55 linked by a null-modem cable. Being based on devices the number of
56 simultanous instances of this class is (globally) limited by the number of 56 simultanous instances of this class is (globally) limited by the number of
57 those device pairs, which is 256. 57 those device pairs, which is 256.
58 58
59 Another technic are UNIX 98 PTY's. These are supported also, and prefered 59 Another technic are UNIX 98 PTY's. These are supported also, and prefered
60 over the (obsolete) predecessor. 60 over the (obsolete) predecessor.
61 61
62 There's a sinister ioctl(2), signal(2) and job control stuff 62 There's a sinister ioctl(2), signal(2) and job control stuff
63 nessesary to make everything work as it should. 63 nessesary to make everything work as it should.
64*/ 64*/
65 65
66 66
67#include <qapplication.h>
68#include <qsocketnotifier.h> 67#include <qsocketnotifier.h>
69#include <qstring.h>
70#include <qfile.h> 68#include <qfile.h>
71 69
72#include <stdlib.h> 70#include <stdlib.h>
73#include <stdio.h> 71#include <stdio.h>
74#include <signal.h> 72#include <signal.h>
75#include <fcntl.h> 73#include <fcntl.h>
76#include <unistd.h> 74#include <unistd.h>
77#include <termios.h> 75#include <termios.h>
78#include <sys/types.h> 76#include <sys/types.h>
79#include <sys/ioctl.h> 77#include <sys/ioctl.h>
80#include <sys/wait.h> 78#include <sys/wait.h>
81 79
82#ifdef HAVE_OPENPTY 80#ifdef HAVE_OPENPTY
83#include <pty.h> 81#include <pty.h>
84#endif 82#endif
85 83
86#include "procctl.h" 84#include "procctl.h"
87#include "MyPty.h" 85#include "MyPty.h"
88 86
89 87
90#undef VERBOSE_DEBUG 88#undef VERBOSE_DEBUG
91 89
92 90
93/* -------------------------------------------------------------------------- */ 91/* -------------------------------------------------------------------------- */
94 92
95/*! 93/*!
96 Informs the client program about the 94 Informs the client program about the
97 actual size of the window. 95 actual size of the window.
98*/ 96*/
99 97
100void MyPty::setSize(int lines, int columns) 98void MyPty::setSize(int lines, int columns)
101{ 99{
102 qWarning("setting size"); 100 qWarning("setting size");
103 struct winsize wsize; 101 struct winsize wsize;
104 wsize.ws_row = (unsigned short)lines; 102 wsize.ws_row = (unsigned short)lines;
105 wsize.ws_col = (unsigned short)columns; 103 wsize.ws_col = (unsigned short)columns;
106 if(m_fd < 0) return; 104 if(m_fd < 0) return;
107 ioctl(m_fd,TIOCSWINSZ,(char *)&wsize); 105 ioctl(m_fd,TIOCSWINSZ,(char *)&wsize);
108} 106}
109 107
110 108
111void MyPty::donePty() 109void MyPty::donePty()
112{ 110{
113 // This is code from the Qt DumbTerminal example 111 // This is code from the Qt DumbTerminal example
114 112
115 ::close(m_fd); 113 ::close(m_fd);
116 114
117 if (m_cpid) { 115 if (m_cpid) {
118 kill(m_cpid, SIGHUP); 116 kill(m_cpid, SIGHUP);
119 //waitpid(m_cpid, &status, 0); 117 //waitpid(m_cpid, &status, 0);
120 delete m_sn_e; 118 delete m_sn_e;
121 delete m_sn_r; 119 delete m_sn_r;
122 m_sn_e = 0l; 120 m_sn_e = 0l;
123 m_sn_r = 0l; 121 m_sn_r = 0l;
124 } 122 }
125 123
126 m_cpid = 0; 124 m_cpid = 0;
127 m_fd = -1; 125 m_fd = -1;
128// emit done(status); 126// emit done(status);
129} 127}
130 128
131 129
132const char* MyPty::deviceName() 130const char* MyPty::deviceName()
133{ 131{
134 return m_ttynam; 132 return m_ttynam;
135} 133}
136 134
137 135
138void MyPty::error() 136void MyPty::error()
139{ 137{
140 // This is code from the Qt DumbTerminal example 138 // This is code from the Qt DumbTerminal example
141 donePty(); 139 donePty();
142} 140}
143 141
144void MyPty::start() { 142void MyPty::start() {
145 QStrList lis; 143 QStrList lis;
146 int r =run(m_cmd.latin1(), lis, 0, 0); 144 int r =run(m_cmd.latin1(), lis, 0, 0);
147 r = r; 145 r = r;
148} 146}
149/*! 147/*!
150 start the client program. 148 start the client program.
151*/ 149*/
152int MyPty::run(const char* cmd, QStrList &, const char*, int) 150int MyPty::run(const char* cmd, QStrList &, const char*, int)
153{ 151{
154 // This is code from the Qt DumbTerminal example 152 // This is code from the Qt DumbTerminal example
155 m_cpid = fork(); 153 m_cpid = fork();
156 154
157 if ( !m_cpid ) { 155 if ( !m_cpid ) {
158 // child - exec shell on tty 156 // child - exec shell on tty
159 for (int sig = 1; sig < NSIG; sig++) signal(sig,SIG_DFL); 157 for (int sig = 1; sig < NSIG; sig++) signal(sig,SIG_DFL);
160 int ttyfd = ::open(m_ttynam, O_RDWR); 158 int ttyfd = ::open(m_ttynam, O_RDWR);
161 dup2(ttyfd, STDIN_FILENO); 159 dup2(ttyfd, STDIN_FILENO);
162 dup2(ttyfd, STDOUT_FILENO); 160 dup2(ttyfd, STDOUT_FILENO);
163 dup2(ttyfd, STDERR_FILENO); 161 dup2(ttyfd, STDERR_FILENO);
164 // should be done with tty, so close it 162 // should be done with tty, so close it
165 ::close(ttyfd); 163 ::close(ttyfd);
166 static struct termios ttmode; 164 static struct termios ttmode;
167 if ( setsid() < 0 ) 165 if ( setsid() < 0 )
168 perror( "failed to set process group" ); 166 perror( "failed to set process group" );
169#if defined (TIOCSCTTY) 167#if defined (TIOCSCTTY)
170 // grabbed from APUE by Stevens 168 // grabbed from APUE by Stevens
171 ioctl(STDIN_FILENO, TIOCSCTTY, 0); 169 ioctl(STDIN_FILENO, TIOCSCTTY, 0);
172#endif 170#endif
173 tcgetattr( STDIN_FILENO, &ttmode ); 171 tcgetattr( STDIN_FILENO, &ttmode );
174 ttmode.c_cc[VINTR] = 3; 172 ttmode.c_cc[VINTR] = 3;
175 ttmode.c_cc[VERASE] = 8; 173 ttmode.c_cc[VERASE] = 8;
176 tcsetattr( STDIN_FILENO, TCSANOW, &ttmode ); 174 tcsetattr( STDIN_FILENO, TCSANOW, &ttmode );
177 setenv("TERM",m_term,1); 175 setenv("TERM",m_term,1);
178 setenv("COLORTERM","0",1); 176 setenv("COLORTERM","0",1);
179 EnvironmentMap::Iterator it; 177 EnvironmentMap::Iterator it;
180 for (it = m_env.begin(); it != m_env.end(); it++) { 178 for (it = m_env.begin(); it != m_env.end(); it++) {
181 setenv(it.key().latin1(), it.data().latin1(), 1); 179 setenv(it.key().latin1(), it.data().latin1(), 1);
182 } 180 }
183 if (getuid() == 0) { 181 if (getuid() == 0) {
184 char msg[] = "WARNING: You are running this shell as root!\n"; 182 char msg[] = "WARNING: You are running this shell as root!\n";
185 write(ttyfd, msg, sizeof(msg)); 183 write(ttyfd, msg, sizeof(msg));
186 } 184 }
187 execl(cmd, cmd, 0); 185 execl(cmd, cmd, 0);
188 186
189 donePty(); 187 donePty();
190 exit(-1); 188 exit(-1);
191 } 189 }
192 190
193 // parent - continue as a widget 191 // parent - continue as a widget
194 delete m_sn_r; 192 delete m_sn_r;
195 m_sn_r = new QSocketNotifier(m_fd,QSocketNotifier::Read,this); 193 m_sn_r = new QSocketNotifier(m_fd,QSocketNotifier::Read,this);
196 delete m_sn_e; 194 delete m_sn_e;
197 m_sn_e = new QSocketNotifier(m_fd,QSocketNotifier::Exception,this); 195 m_sn_e = new QSocketNotifier(m_fd,QSocketNotifier::Exception,this);
198 connect(m_sn_r,SIGNAL(activated(int)),this,SLOT(readPty())); 196 connect(m_sn_r,SIGNAL(activated(int)),this,SLOT(readPty()));
199 connect(m_sn_e,SIGNAL(activated(int)),this,SLOT(error())); 197 connect(m_sn_e,SIGNAL(activated(int)),this,SLOT(error()));
200 198
201 return 0; 199 return 0;
202} 200}
203 201
204int MyPty::openPty() 202int MyPty::openPty()
205{ 203{
206 // This is code from the Qt DumbTerminal example 204 // This is code from the Qt DumbTerminal example
207 int ptyfd = -1; 205 int ptyfd = -1;
208 206
209#ifdef HAVE_OPENPTY 207#ifdef HAVE_OPENPTY
210 int ttyfd; 208 int ttyfd;
211 if ( openpty(&ptyfd,&ttyfd,m_ttynam,0,0) ) 209 if ( openpty(&ptyfd,&ttyfd,m_ttynam,0,0) )
212 ptyfd = -1; 210 ptyfd = -1;
213 else 211 else
214 ::close(ttyfd); // we open the ttynam ourselves. 212 ::close(ttyfd); // we open the ttynam ourselves.
215#else 213#else
216 for (const char* c0 = "pqrstuvwxyzabcde"; ptyfd < 0 && *c0 != 0; c0++) { 214 for (const char* c0 = "pqrstuvwxyzabcde"; ptyfd < 0 && *c0 != 0; c0++) {
217 for (const char* c1 = "0123456789abcdef"; ptyfd < 0 && *c1 != 0; c1++) { 215 for (const char* c1 = "0123456789abcdef"; ptyfd < 0 && *c1 != 0; c1++) {
218 sprintf(m_ptynam,"/dev/pty%c%c",*c0,*c1); 216 sprintf(m_ptynam,"/dev/pty%c%c",*c0,*c1);
219 sprintf(m_ttynam,"/dev/tty%c%c",*c0,*c1); 217 sprintf(m_ttynam,"/dev/tty%c%c",*c0,*c1);
220 if ((ptyfd = ::open(m_ptynam,O_RDWR)) >= 0) { 218 if ((ptyfd = ::open(m_ptynam,O_RDWR)) >= 0) {
221 if (geteuid() != 0 && !access(m_ttynam,R_OK|W_OK) == 0) { 219 if (geteuid() != 0 && !access(m_ttynam,R_OK|W_OK) == 0) {
222 ::close(ptyfd); 220 ::close(ptyfd);
223 ptyfd = -1; 221 ptyfd = -1;
224 } 222 }
225 } 223 }
226 } 224 }
227 } 225 }
228#endif 226#endif
229 227
230 if ( ptyfd < 0 ) { 228 if ( ptyfd < 0 ) {
231 //qApp->exit(1); 229 //qApp->exit(1);
232 return -1; 230 return -1;
233 } 231 }
234 232
235 return ptyfd; 233 return ptyfd;
236} 234}
237 235
238/*! 236/*!
239 Create an instance. 237 Create an instance.
240*/ 238*/
241MyPty::MyPty(const Profile& prof) : m_cpid(0) 239MyPty::MyPty(const Profile& prof) : m_cpid(0)
242{ 240{
243 241
244 int term = prof.readNumEntry("Terminal", Profile::VT100 ); 242 int term = prof.readNumEntry("Terminal", Profile::VT100 );
245 switch( term ) { 243 switch( term ) {
246 default: 244 default:
247 case Profile::VT100: 245 case Profile::VT100:
248 case Profile::VT102: 246 case Profile::VT102:
249 m_term = "vt100"; 247 m_term = "vt100";
250 break; 248 break;
251 case Profile::Linux: 249 case Profile::Linux:
252 m_term = "linux"; 250 m_term = "linux";
253 break; 251 break;
254 case Profile::XTerm: 252 case Profile::XTerm:
255 m_term = "xterm"; 253 m_term = "xterm";
256 break; 254 break;
257 } 255 }
258 m_sn_e = 0l; 256 m_sn_e = 0l;
259 m_sn_r = 0l; 257 m_sn_r = 0l;
260 m_fd = openPty(); 258 m_fd = openPty();
261 ProcCtl* ctl = ProcCtl::self(); 259 ProcCtl* ctl = ProcCtl::self();
262 Q_UNUSED(ctl); 260 Q_UNUSED(ctl);
263 reload(prof); 261 reload(prof);
264} 262}
265 263
266/*! 264/*!
267 Destructor. 265 Destructor.
268 Note that the related client program is not killed 266 Note that the related client program is not killed
269 (yet) when a instance is deleted. 267 (yet) when a instance is deleted.
270*/ 268*/
271MyPty::~MyPty() 269MyPty::~MyPty()
272{ 270{
273 donePty(); 271 donePty();
274} 272}
275QString MyPty::identifier()const { 273QString MyPty::identifier()const {
276 return QString::fromLatin1("term"); 274 return QString::fromLatin1("term");
277} 275}
278QString MyPty::name()const{ 276QString MyPty::name()const{
279 return identifier(); 277 return identifier();
280} 278}
281bool MyPty::open() { 279bool MyPty::open() {
282 if (m_fd < 0) 280 if (m_fd < 0)
283 m_fd = openPty(); 281 m_fd = openPty();
284 282
285 start(); 283 start();
286 return true; 284 return true;
287} 285}
288void MyPty::close() { 286void MyPty::close() {
289 donePty(); 287 donePty();
290 m_fd = openPty(); 288 m_fd = openPty();
291} 289}
292void MyPty::reload( const Profile& prof) { 290void MyPty::reload( const Profile& prof) {
293 m_env.clear(); 291 m_env.clear();
294 m_cmd = prof.readEntry("Command", "/bin/sh"); 292 m_cmd = prof.readEntry("Command", "/bin/sh");
295 293
296 /* 294 /*
297 * Lets check if m_cmd actually 295 * Lets check if m_cmd actually
298 * exists.... 296 * exists....
299 * we try to use bin/bash and if 297 * we try to use bin/bash and if
300 * this fails we 298 * this fails we
301 * will fallback to /bin/sh 299 * will fallback to /bin/sh
302 * which should be there 100% 300 * which should be there 100%
303 */ 301 */
304 if ( m_cmd.stripWhiteSpace() == "/bin/bash" && !QFile::exists(QFile::encodeName(m_cmd) ) ) 302 if ( m_cmd.stripWhiteSpace() == "/bin/bash" && !QFile::exists(QFile::encodeName(m_cmd) ) )
305 m_cmd = "/bin/sh"; 303 m_cmd = "/bin/sh";
306 304
307 305
308 int envcount = prof.readNumEntry("EnvVars", 0); 306 int envcount = prof.readNumEntry("EnvVars", 0);
309 for (int i=0; i<envcount; i++) { 307 for (int i=0; i<envcount; i++) {
310 QString name = prof.readEntry("Env_Name_" + QString::number(i), ""); 308 QString name = prof.readEntry("Env_Name_" + QString::number(i), "");
311 QString value = prof.readEntry("Env_Value_" + QString::number(i), ""); 309 QString value = prof.readEntry("Env_Value_" + QString::number(i), "");
312 if (!(name.isEmpty() || value.isEmpty())) { 310 if (!(name.isEmpty() || value.isEmpty())) {
313 m_env.insert(name, value); 311 m_env.insert(name, value);
314 } 312 }
315 } 313 }
316} 314}
317/*! sends len bytes through the line */ 315/*! sends len bytes through the line */
318void MyPty::send(const QByteArray& ar) 316void MyPty::send(const QByteArray& ar)
319{ 317{
320#ifdef VERBOSE_DEBUG 318#ifdef VERBOSE_DEBUG
321 // verbose debug 319 // verbose debug
322 printf("sending bytes:\n"); 320 printf("sending bytes:\n");
323 for (uint i = 0; i < ar.count(); i++) 321 for (uint i = 0; i < ar.count(); i++)
324 printf("%c", ar[i]); 322 printf("%c", ar[i]);
325 printf("\n"); 323 printf("\n");
326#endif 324#endif
327 325
328 ::write(m_fd, ar.data(), ar.count()); 326 ::write(m_fd, ar.data(), ar.count());
329} 327}
330 328
331/*! indicates that a block of data is received */ 329/*! indicates that a block of data is received */
332void MyPty::readPty() 330void MyPty::readPty()
333{ 331{
334 QByteArray buf(4096); 332 QByteArray buf(4096);
335 333
336 int len = ::read( m_fd, buf.data(), 4096 ); 334 int len = ::read( m_fd, buf.data(), 4096 );
337 335
338 if (len == -1 || len == 0) { 336 if (len == -1 || len == 0) {
339 donePty(); 337 donePty();
340 return; 338 return;
341 } 339 }
342 340
343 if (len < 0) 341 if (len < 0)
344 return; 342 return;
345 343
346 344
347 buf.resize(len); 345 buf.resize(len);
348 emit received(buf); 346 emit received(buf);
349 347
350#ifdef VERBOSE_DEBUG 348#ifdef VERBOSE_DEBUG
351 // verbose debug 349 // verbose debug
352 printf("read bytes:\n"); 350 printf("read bytes:\n");
353 for (uint i = 0; i < buf.count(); i++) 351 for (uint i = 0; i < buf.count(); i++)
354 printf("%c", buf[i]); 352 printf("%c", buf[i]);
355 printf("\n"); 353 printf("\n");
356#endif 354#endif
357 355
358} 356}
359QBitArray MyPty::supports()const { 357QBitArray MyPty::supports()const {
360 QBitArray ar(3); 358 QBitArray ar(3);
361 //autoconnect 359 //autoconnect
362 ar[0] = 1; 360 ar[0] = 1;
363 // 361 //
364 ar[1] = 0; 362 ar[1] = 0;
365 ar[2] = 0; 363 ar[2] = 0;
366 364
367 return ar; 365 return ar;
368} 366}
diff --git a/noncore/apps/opie-console/TEWidget.cpp b/noncore/apps/opie-console/TEWidget.cpp
index 444924b..e535296 100644
--- a/noncore/apps/opie-console/TEWidget.cpp
+++ b/noncore/apps/opie-console/TEWidget.cpp
@@ -1,831 +1,823 @@
1/* ------------------------------------------------------------------------ */ 1/* ------------------------------------------------------------------------ */
2/* */ 2/* */
3/* [TEWidget.C] Terminal Emulation Widget */ 3/* [TEWidget.C] Terminal Emulation Widget */
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/*! \class TEWidget 18/*! \class TEWidget
19 19
20 \brief Visible screen contents 20 \brief Visible screen contents
21 21
22 This class is responsible to map the `image' of a terminal emulation to the 22 This class is responsible to map the `image' of a terminal emulation to the
23 display. All the dependency of the emulation to a specific GUI or toolkit is 23 display. All the dependency of the emulation to a specific GUI or toolkit is
24 localized here. Further, this widget has no knowledge about being part of an 24 localized here. Further, this widget has no knowledge about being part of an
25 emulation, it simply work within the terminal emulation framework by exposing 25 emulation, it simply work within the terminal emulation framework by exposing
26 size and key events and by being ordered to show a new image. 26 size and key events and by being ordered to show a new image.
27 27
28 <ul> 28 <ul>
29 <li> The internal image has the size of the widget (evtl. rounded up) 29 <li> The internal image has the size of the widget (evtl. rounded up)
30 <li> The external image used in setImage can have any size. 30 <li> The external image used in setImage can have any size.
31 <li> (internally) the external image is simply copied to the internal 31 <li> (internally) the external image is simply copied to the internal
32 when a setImage happens. During a resizeEvent no painting is done 32 when a setImage happens. During a resizeEvent no painting is done
33 a paintEvent is expected to follow anyway. 33 a paintEvent is expected to follow anyway.
34 </ul> 34 </ul>
35 35
36 \sa TEScreen \sa Emulation 36 \sa TEScreen \sa Emulation
37*/ 37*/
38 38
39/* FIXME: 39/* FIXME:
40 - 'image' may also be used uninitialized (it isn't in fact) in resizeEvent 40 - 'image' may also be used uninitialized (it isn't in fact) in resizeEvent
41 - 'font_a' not used in mouse events 41 - 'font_a' not used in mouse events
42 - add destructor 42 - add destructor
43*/ 43*/
44 44
45/* TODO 45/* TODO
46 - evtl. be sensitive to `paletteChange' while using default colors. 46 - evtl. be sensitive to `paletteChange' while using default colors.
47 - set different 'rounding' styles? I.e. have a mode to show clipped chars? 47 - set different 'rounding' styles? I.e. have a mode to show clipped chars?
48*/ 48*/
49 49
50// #include "config.h" 50// #include "config.h"
51#include "TEWidget.h" 51#include "TEWidget.h"
52#include "session.h"
53#include <qpe/config.h> 52#include <qpe/config.h>
54 53
55#include <qapplication.h> 54#include <qapplication.h>
56#include <qcursor.h>
57#include <qregexp.h>
58#include <qpainter.h>
59#include <qclipboard.h> 55#include <qclipboard.h>
60#include <qstyle.h>
61#include <qfile.h>
62#include <qdragobject.h>
63#include <qvbox.h>
64 56
65#include <stdio.h> 57#include <stdio.h>
66#include <stdlib.h> 58#include <stdlib.h>
67#include <unistd.h> 59#include <unistd.h>
68#include <ctype.h> 60#include <ctype.h>
69#include <sys/stat.h> 61#include <sys/stat.h>
70#include <sys/types.h> 62#include <sys/types.h>
71#include <signal.h> 63#include <signal.h>
72 64
73#include <assert.h> 65#include <assert.h>
74 66
75 67
76 68
77// #include "TEWidget.moc" 69// #include "TEWidget.moc"
78//#include <kapp.h> 70//#include <kapp.h>
79//#include <kcursor.h> 71//#include <kcursor.h>
80//#include <kurl.h> 72//#include <kurl.h>
81//#include <kdebug.h> 73//#include <kdebug.h>
82//#include <klocale.h> 74//#include <klocale.h>
83 75
84#define HERE printf("%s(%d): %s\n",__FILE__,__LINE__,__FUNCTION__) 76#define HERE printf("%s(%d): %s\n",__FILE__,__LINE__,__FUNCTION__)
85#define HCNT(Name) // { static int cnt = 1; printf("%s(%d): %s %d\n",__FILE__,__LINE__,Name,cnt++); } 77#define HCNT(Name) // { static int cnt = 1; printf("%s(%d): %s %d\n",__FILE__,__LINE__,Name,cnt++); }
86 78
87#define loc(X,Y) ((Y)*columns+(X)) 79#define loc(X,Y) ((Y)*columns+(X))
88 80
89//FIXME: the rim should normally be 1, 0 only when running in full screen mode. 81//FIXME: the rim should normally be 1, 0 only when running in full screen mode.
90#define rimX 0 // left/right rim width 82#define rimX 0 // left/right rim width
91#define rimY 0 // top/bottom rim high 83#define rimY 0 // top/bottom rim high
92 84
93#define yMouseScroll 1 85#define yMouseScroll 1
94// scroll increment used when dragging selection at top/bottom of window. 86// scroll increment used when dragging selection at top/bottom of window.
95 87
96/* Button XPM */ 88/* Button XPM */
97namespace { 89namespace {
98static char * menu_xpm[] = { 90static char * menu_xpm[] = {
99"12 12 5 1", 91"12 12 5 1",
100 " c None", 92 " c None",
101 ".c #000000", 93 ".c #000000",
102 "+c #FFFDAD", 94 "+c #FFFDAD",
103 "@c #FFFF00", 95 "@c #FFFF00",
104 "#c #E5E100", 96 "#c #E5E100",
105" ", 97" ",
106" ", 98" ",
107" ......... ", 99" ......... ",
108" .+++++++. ", 100" .+++++++. ",
109" .+@@@@#. ", 101" .+@@@@#. ",
110" .+@@@#. ", 102" .+@@@#. ",
111" .+@@#. ", 103" .+@@#. ",
112" .+@#. ", 104" .+@#. ",
113" .+#. ", 105" .+#. ",
114" .+. ", 106" .+. ",
115" .. ", 107" .. ",
116" "}; 108" "};
117 109
118} 110}
119 111
120 112
121/* ------------------------------------------------------------------------- */ 113/* ------------------------------------------------------------------------- */
122/* */ 114/* */
123/* Colors */ 115/* Colors */
124/* */ 116/* */
125/* ------------------------------------------------------------------------- */ 117/* ------------------------------------------------------------------------- */
126 118
127//FIXME: the default color table is in session.C now. 119//FIXME: the default color table is in session.C now.
128// We need a way to get rid of this one, here. 120// We need a way to get rid of this one, here.
129static const ColorEntry base_color_table[TABLE_COLORS] = 121static const ColorEntry base_color_table[TABLE_COLORS] =
130// The following are almost IBM standard color codes, with some slight 122// The following are almost IBM standard color codes, with some slight
131// gamma correction for the dim colors to compensate for bright X screens. 123// gamma correction for the dim colors to compensate for bright X screens.
132// It contains the 8 ansiterm/xterm colors in 2 intensities. 124// It contains the 8 ansiterm/xterm colors in 2 intensities.
133{ 125{
134 // Fixme: could add faint colors here, also. 126 // Fixme: could add faint colors here, also.
135 // normal 127 // normal
136 ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 1, 0 ), // Dfore, Dback 128 ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 1, 0 ), // Dfore, Dback
137 ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0x18), 0, 0 ), // Black, Red 129 ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0x18), 0, 0 ), // Black, Red
138 ColorEntry(QColor(0x18,0xB2,0x18), 0, 0 ), ColorEntry( QColor(0xB2,0x68,0x18), 0, 0 ), // Green, Yellow 130 ColorEntry(QColor(0x18,0xB2,0x18), 0, 0 ), ColorEntry( QColor(0xB2,0x68,0x18), 0, 0 ), // Green, Yellow
139 ColorEntry(QColor(0x18,0x18,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), // Blue, Magenta 131 ColorEntry(QColor(0x18,0x18,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), // Blue, Magenta
140 ColorEntry(QColor(0x18,0xB2,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 0, 0 ), // Cyan, White 132 ColorEntry(QColor(0x18,0xB2,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 0, 0 ), // Cyan, White
141 // intensiv 133 // intensiv
142 ColorEntry(QColor(0x00,0x00,0x00), 0, 1 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 1, 0 ), 134 ColorEntry(QColor(0x00,0x00,0x00), 0, 1 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 1, 0 ),
143 ColorEntry(QColor(0x68,0x68,0x68), 0, 0 ), ColorEntry( QColor(0xFF,0x54,0x54), 0, 0 ), 135 ColorEntry(QColor(0x68,0x68,0x68), 0, 0 ), ColorEntry( QColor(0xFF,0x54,0x54), 0, 0 ),
144 ColorEntry(QColor(0x54,0xFF,0x54), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0x54), 0, 0 ), 136 ColorEntry(QColor(0x54,0xFF,0x54), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0x54), 0, 0 ),
145 ColorEntry(QColor(0x54,0x54,0xFF), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), 137 ColorEntry(QColor(0x54,0x54,0xFF), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ),
146 ColorEntry(QColor(0x54,0xFF,0xFF), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 0, 0 ) 138 ColorEntry(QColor(0x54,0xFF,0xFF), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 0, 0 )
147}; 139};
148 140
149/* Note that we use ANSI color order (bgr), while IBMPC color order is (rgb) 141/* Note that we use ANSI color order (bgr), while IBMPC color order is (rgb)
150 142
151 Code 0 1 2 3 4 5 6 7 143 Code 0 1 2 3 4 5 6 7
152 ----------- ------- ------- ------- ------- ------- ------- ------- ------- 144 ----------- ------- ------- ------- ------- ------- ------- ------- -------
153 ANSI (bgr) Black Red Green Yellow Blue Magenta Cyan White 145 ANSI (bgr) Black Red Green Yellow Blue Magenta Cyan White
154 IBMPC (rgb) Black Blue Green Cyan Red Magenta Yellow White 146 IBMPC (rgb) Black Blue Green Cyan Red Magenta Yellow White
155*/ 147*/
156 148
157QColor TEWidget::getDefaultBackColor() 149QColor TEWidget::getDefaultBackColor()
158{ 150{
159 return color_table[DEFAULT_BACK_COLOR].color; 151 return color_table[DEFAULT_BACK_COLOR].color;
160} 152}
161 153
162const ColorEntry* TEWidget::getColorTable() const 154const ColorEntry* TEWidget::getColorTable() const
163{ 155{
164 return color_table; 156 return color_table;
165} 157}
166 158
167const ColorEntry* TEWidget::getdefaultColorTable() const 159const ColorEntry* TEWidget::getdefaultColorTable() const
168{ 160{
169 return base_color_table; 161 return base_color_table;
170} 162}
171 163
172 164
173const QPixmap *TEWidget::backgroundPixmap() 165const QPixmap *TEWidget::backgroundPixmap()
174{ 166{
175 static QPixmap *bg = new QPixmap("~/qpim/main/pics/faded_bg.xpm"); 167 static QPixmap *bg = new QPixmap("~/qpim/main/pics/faded_bg.xpm");
176 const QPixmap *pm = bg; 168 const QPixmap *pm = bg;
177 return pm; 169 return pm;
178} 170}
179 171
180void TEWidget::setColorTable(const ColorEntry table[]) 172void TEWidget::setColorTable(const ColorEntry table[])
181{ 173{
182 for (int i = 0; i < TABLE_COLORS; i++) color_table[i] = table[i]; 174 for (int i = 0; i < TABLE_COLORS; i++) color_table[i] = table[i];
183 175
184 const QPixmap* pm = backgroundPixmap(); 176 const QPixmap* pm = backgroundPixmap();
185 if (!pm) setBackgroundColor(color_table[DEFAULT_BACK_COLOR].color); 177 if (!pm) setBackgroundColor(color_table[DEFAULT_BACK_COLOR].color);
186 update(); 178 update();
187} 179}
188 180
189//FIXME: add backgroundPixmapChanged. 181//FIXME: add backgroundPixmapChanged.
190 182
191/* ------------------------------------------------------------------------- */ 183/* ------------------------------------------------------------------------- */
192/* */ 184/* */
193/* Font */ 185/* Font */
194/* */ 186/* */
195/* ------------------------------------------------------------------------- */ 187/* ------------------------------------------------------------------------- */
196 188
197/* 189/*
198 The VT100 has 32 special graphical characters. The usual vt100 extended 190 The VT100 has 32 special graphical characters. The usual vt100 extended
199 xterm fonts have these at 0x00..0x1f. 191 xterm fonts have these at 0x00..0x1f.
200 192
201 QT's iso mapping leaves 0x00..0x7f without any changes. But the graphicals 193 QT's iso mapping leaves 0x00..0x7f without any changes. But the graphicals
202 come in here as proper unicode characters. 194 come in here as proper unicode characters.
203 195
204 We treat non-iso10646 fonts as VT100 extended and do the requiered mapping 196 We treat non-iso10646 fonts as VT100 extended and do the requiered mapping
205 from unicode to 0x00..0x1f. The remaining translation is then left to the 197 from unicode to 0x00..0x1f. The remaining translation is then left to the
206 QCodec. 198 QCodec.
207*/ 199*/
208 200
209// assert for i in [0..31] : vt100extended(vt100_graphics[i]) == i. 201// assert for i in [0..31] : vt100extended(vt100_graphics[i]) == i.
210 202
211unsigned short vt100_graphics[32] = 203unsigned short vt100_graphics[32] =
212{ // 0/8 1/9 2/10 3/11 4/12 5/13 6/14 7/15 204{ // 0/8 1/9 2/10 3/11 4/12 5/13 6/14 7/15
213 0x0020, 0x25C6, 0x2592, 0x2409, 0x240c, 0x240d, 0x240a, 0x00b0, 205 0x0020, 0x25C6, 0x2592, 0x2409, 0x240c, 0x240d, 0x240a, 0x00b0,
214 0x00b1, 0x2424, 0x240b, 0x2518, 0x2510, 0x250c, 0x2514, 0x253c, 206 0x00b1, 0x2424, 0x240b, 0x2518, 0x2510, 0x250c, 0x2514, 0x253c,
215 0xF800, 0xF801, 0x2500, 0xF803, 0xF804, 0x251c, 0x2524, 0x2534, 207 0xF800, 0xF801, 0x2500, 0xF803, 0xF804, 0x251c, 0x2524, 0x2534,
216 0x252c, 0x2502, 0x2264, 0x2265, 0x03C0, 0x2260, 0x00A3, 0x00b7 208 0x252c, 0x2502, 0x2264, 0x2265, 0x03C0, 0x2260, 0x00A3, 0x00b7
217}; 209};
218 210
219static QChar vt100extended(QChar c) 211static QChar vt100extended(QChar c)
220{ 212{
221 switch (c.unicode()) 213 switch (c.unicode())
222 { 214 {
223 case 0x25c6 : return 1; 215 case 0x25c6 : return 1;
224 case 0x2592 : return 2; 216 case 0x2592 : return 2;
225 case 0x2409 : return 3; 217 case 0x2409 : return 3;
226 case 0x240c : return 4; 218 case 0x240c : return 4;
227 case 0x240d : return 5; 219 case 0x240d : return 5;
228 case 0x240a : return 6; 220 case 0x240a : return 6;
229 case 0x00b0 : return 7; 221 case 0x00b0 : return 7;
230 case 0x00b1 : return 8; 222 case 0x00b1 : return 8;
231 case 0x2424 : return 9; 223 case 0x2424 : return 9;
232 case 0x240b : return 10; 224 case 0x240b : return 10;
233 case 0x2518 : return 11; 225 case 0x2518 : return 11;
234 case 0x2510 : return 12; 226 case 0x2510 : return 12;
235 case 0x250c : return 13; 227 case 0x250c : return 13;
236 case 0x2514 : return 14; 228 case 0x2514 : return 14;
237 case 0x253c : return 15; 229 case 0x253c : return 15;
238 case 0xf800 : return 16; 230 case 0xf800 : return 16;
239 case 0xf801 : return 17; 231 case 0xf801 : return 17;
240 case 0x2500 : return 18; 232 case 0x2500 : return 18;
241 case 0xf803 : return 19; 233 case 0xf803 : return 19;
242 case 0xf804 : return 20; 234 case 0xf804 : return 20;
243 case 0x251c : return 21; 235 case 0x251c : return 21;
244 case 0x2524 : return 22; 236 case 0x2524 : return 22;
245 case 0x2534 : return 23; 237 case 0x2534 : return 23;
246 case 0x252c : return 24; 238 case 0x252c : return 24;
247 case 0x2502 : return 25; 239 case 0x2502 : return 25;
248 case 0x2264 : return 26; 240 case 0x2264 : return 26;
249 case 0x2265 : return 27; 241 case 0x2265 : return 27;
250 case 0x03c0 : return 28; 242 case 0x03c0 : return 28;
251 case 0x2260 : return 29; 243 case 0x2260 : return 29;
252 case 0x00a3 : return 30; 244 case 0x00a3 : return 30;
253 case 0x00b7 : return 31; 245 case 0x00b7 : return 31;
254 } 246 }
255 return c; 247 return c;
256} 248}
257 249
258static QChar identicalMap(QChar c) 250static QChar identicalMap(QChar c)
259{ 251{
260 return c; 252 return c;
261} 253}
262 254
263void TEWidget::fontChange(const QFont &) 255void TEWidget::fontChange(const QFont &)
264{ 256{
265 QFontMetrics fm(font()); 257 QFontMetrics fm(font());
266 font_h = fm.height(); 258 font_h = fm.height();
267 font_w = fm.maxWidth(); 259 font_w = fm.maxWidth();
268 font_a = fm.ascent(); 260 font_a = fm.ascent();
269//printf("font_h: %d\n",font_h); 261//printf("font_h: %d\n",font_h);
270//printf("font_w: %d\n",font_w); 262//printf("font_w: %d\n",font_w);
271//printf("font_a: %d\n",font_a); 263//printf("font_a: %d\n",font_a);
272//printf("charset: %s\n",QFont::encodingName(font().charSet()).ascii()); 264//printf("charset: %s\n",QFont::encodingName(font().charSet()).ascii());
273//printf("rawname: %s\n",font().rawName().ascii()); 265//printf("rawname: %s\n",font().rawName().ascii());
274 fontMap = 266 fontMap =
275#if QT_VERSION < 300 267#if QT_VERSION < 300
276 strcmp(QFont::encodingName(font().charSet()).ascii(),"iso10646") 268 strcmp(QFont::encodingName(font().charSet()).ascii(),"iso10646")
277 ? vt100extended 269 ? vt100extended
278 : 270 :
279#endif 271#endif
280 identicalMap; 272 identicalMap;
281 propagateSize(); 273 propagateSize();
282 update(); 274 update();
283} 275}
284 276
285void TEWidget::setVTFont(const QFont& f) 277void TEWidget::setVTFont(const QFont& f)
286{ 278{
287 QFrame::setFont(f); 279 QFrame::setFont(f);
288} 280}
289 281
290QFont TEWidget::getVTFont() { 282QFont TEWidget::getVTFont() {
291 return font(); 283 return font();
292} 284}
293 285
294void TEWidget::setFont(const QFont &) 286void TEWidget::setFont(const QFont &)
295{ 287{
296 // ignore font change request if not coming from konsole itself 288 // ignore font change request if not coming from konsole itself
297} 289}
298 290
299/* ------------------------------------------------------------------------- */ 291/* ------------------------------------------------------------------------- */
300/* */ 292/* */
301/* Constructor / Destructor */ 293/* Constructor / Destructor */
302/* */ 294/* */
303/* ----------------------------------------------------------------------- */ 295/* ----------------------------------------------------------------------- */
304 296
305 297
306 298
307TEWidget::TEWidget(QWidget *parent, const char *name) : QFrame(parent,name) 299TEWidget::TEWidget(QWidget *parent, const char *name) : QFrame(parent,name)
308{ 300{
309#ifndef QT_NO_CLIPBOARD 301#ifndef QT_NO_CLIPBOARD
310 cb = QApplication::clipboard(); 302 cb = QApplication::clipboard();
311 QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), 303 QObject::connect( (QObject*)cb, SIGNAL(dataChanged()),
312 this, SLOT(onClearSelection()) ); 304 this, SLOT(onClearSelection()) );
313#endif 305#endif
314 306
315 307
316 scrollbar = new QScrollBar( this ); 308 scrollbar = new QScrollBar( this );
317 scrollbar->setCursor( arrowCursor ); 309 scrollbar->setCursor( arrowCursor );
318 connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); 310 connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int)));
319 311
320 hscrollbar = new QScrollBar( Qt::Horizontal, this ); 312 hscrollbar = new QScrollBar( Qt::Horizontal, this );
321 hscrollbar->setCursor( arrowCursor ); 313 hscrollbar->setCursor( arrowCursor );
322 connect(hscrollbar, SIGNAL(valueChanged(int)), this, SLOT(hscrollChanged(int))); 314 connect(hscrollbar, SIGNAL(valueChanged(int)), this, SLOT(hscrollChanged(int)));
323 315
324 m_cornerButton = new QPushButton( this ); 316 m_cornerButton = new QPushButton( this );
325 m_cornerButton->setPixmap( QPixmap( (const char**)menu_xpm ) ); 317 m_cornerButton->setPixmap( QPixmap( (const char**)menu_xpm ) );
326 m_cornerButton->setMaximumSize( 14, 14 ); 318 m_cornerButton->setMaximumSize( 14, 14 );
327 m_cornerButton->hide(); 319 m_cornerButton->hide();
328 320
329 Config cfg("Konsole"); 321 Config cfg("Konsole");
330 cfg.setGroup("ScrollBar"); 322 cfg.setGroup("ScrollBar");
331 switch( cfg.readNumEntry("Position",2)){ 323 switch( cfg.readNumEntry("Position",2)){
332 case 0: 324 case 0:
333 scrollLoc = SCRNONE; 325 scrollLoc = SCRNONE;
334 break; 326 break;
335 case 1: 327 case 1:
336 scrollLoc = SCRLEFT; 328 scrollLoc = SCRLEFT;
337 break; 329 break;
338 case 2: 330 case 2:
339 scrollLoc = SCRRIGHT; 331 scrollLoc = SCRRIGHT;
340 break; 332 break;
341 }; 333 };
342 334
343 blinkT = new QTimer(this); 335 blinkT = new QTimer(this);
344 connect(blinkT, SIGNAL(timeout()), this, SLOT(blinkEvent())); 336 connect(blinkT, SIGNAL(timeout()), this, SLOT(blinkEvent()));
345 // blinking = FALSE; 337 // blinking = FALSE;
346 blinking = TRUE; 338 blinking = TRUE;
347 339
348 resizing = FALSE; 340 resizing = FALSE;
349 actSel = 0; 341 actSel = 0;
350 image = 0; 342 image = 0;
351 lines = 1; 343 lines = 1;
352 columns = 1; 344 columns = 1;
353 font_w = 1; 345 font_w = 1;
354 font_h = 1; 346 font_h = 1;
355 font_a = 1; 347 font_a = 1;
356 word_selection_mode = FALSE; 348 word_selection_mode = FALSE;
357 vcolumns = 0; 349 vcolumns = 0;
358 hposition = 0; 350 hposition = 0;
359 351
360 setMouseMarks(TRUE); 352 setMouseMarks(TRUE);
361 setVTFont( QFont("fixed") ); 353 setVTFont( QFont("fixed") );
362 setColorTable(base_color_table); // init color table 354 setColorTable(base_color_table); // init color table
363 355
364 qApp->installEventFilter( this ); //FIXME: see below 356 qApp->installEventFilter( this ); //FIXME: see below
365// KCursor::setAutoHideCursor( this, true ); 357// KCursor::setAutoHideCursor( this, true );
366 358
367 // Init DnD //////////////////////////////////////////////////////////////// 359 // Init DnD ////////////////////////////////////////////////////////////////
368 currentSession = NULL; 360 currentSession = NULL;
369// setAcceptDrops(true); // attempt 361// setAcceptDrops(true); // attempt
370// m_drop = new QPopupMenu(this); 362// m_drop = new QPopupMenu(this);
371// m_drop->insertItem( QString("Paste"), 0); 363// m_drop->insertItem( QString("Paste"), 0);
372// m_drop->insertItem( QString("cd"), 1); 364// m_drop->insertItem( QString("cd"), 1);
373// connect(m_drop, SIGNAL(activated(int)), SLOT(drop_menu_activated(int))); 365// connect(m_drop, SIGNAL(activated(int)), SLOT(drop_menu_activated(int)));
374 366
375 // we need focus so that the auto-hide cursor feature works 367 // we need focus so that the auto-hide cursor feature works
376 setFocus(); 368 setFocus();
377 setFocusPolicy( WheelFocus ); 369 setFocusPolicy( WheelFocus );
378} 370}
379 371
380//FIXME: make proper destructor 372//FIXME: make proper destructor
381// Here's a start (David) 373// Here's a start (David)
382TEWidget::~TEWidget() 374TEWidget::~TEWidget()
383{ 375{
384 qApp->removeEventFilter( this ); 376 qApp->removeEventFilter( this );
385 if (image) free(image); 377 if (image) free(image);
386} 378}
387 379
388/* ------------------------------------------------------------------------- */ 380/* ------------------------------------------------------------------------- */
389/* */ 381/* */
390/* Display Operations */ 382/* Display Operations */
391/* */ 383/* */
392/* ------------------------------------------------------------------------- */ 384/* ------------------------------------------------------------------------- */
393 385
394/*! 386/*!
395 attributed string draw primitive 387 attributed string draw primitive
396*/ 388*/
397 389
398void TEWidget::drawAttrStr(QPainter &paint, QRect rect, 390void TEWidget::drawAttrStr(QPainter &paint, QRect rect,
399 QString& str, ca attr, BOOL pm, BOOL clear) 391 QString& str, ca attr, BOOL pm, BOOL clear)
400{ 392{
401 if (pm && color_table[attr.b].transparent) 393 if (pm && color_table[attr.b].transparent)
402 { 394 {
403 paint.setBackgroundMode( TransparentMode ); 395 paint.setBackgroundMode( TransparentMode );
404 if (clear) erase(rect); 396 if (clear) erase(rect);
405 } 397 }
406 else 398 else
407 { 399 {
408 if (blinking) 400 if (blinking)
409 paint.fillRect(rect, color_table[attr.b].color); 401 paint.fillRect(rect, color_table[attr.b].color);
410 else 402 else
411 { 403 {
412 paint.setBackgroundMode( OpaqueMode ); 404 paint.setBackgroundMode( OpaqueMode );
413 paint.setBackgroundColor( color_table[attr.b].color ); 405 paint.setBackgroundColor( color_table[attr.b].color );
414 } 406 }
415 } 407 }
416 408
417 if (color_table[attr.f].bold) 409 if (color_table[attr.f].bold)
418 paint.setPen(QColor( 0x8F, 0x00, 0x00 )); 410 paint.setPen(QColor( 0x8F, 0x00, 0x00 ));
419 else 411 else
420 paint.setPen(color_table[attr.f].color); 412 paint.setPen(color_table[attr.f].color);
421 413
422 paint.drawText(rect.x(),rect.y()+font_a, str); 414 paint.drawText(rect.x(),rect.y()+font_a, str);
423 415
424 if (attr.r & RE_UNDERLINE) 416 if (attr.r & RE_UNDERLINE)
425 paint.drawLine(rect.left(), rect.y()+font_a+1, rect.right(),rect.y()+font_a+1 ); 417 paint.drawLine(rect.left(), rect.y()+font_a+1, rect.right(),rect.y()+font_a+1 );
426} 418}
427 419
428/*! 420/*!
429 The image can only be set completely. 421 The image can only be set completely.
430 422
431 The size of the new image may or may not match the size of the widget. 423 The size of the new image may or may not match the size of the widget.
432*/ 424*/
433 425
434void TEWidget::setImage(const ca* const newimg, int lines, int columns) 426void TEWidget::setImage(const ca* const newimg, int lines, int columns)
435{ int y,x,len; 427{ int y,x,len;
436 const QPixmap* pm = backgroundPixmap(); 428 const QPixmap* pm = backgroundPixmap();
437 QPainter paint; 429 QPainter paint;
438 setUpdatesEnabled(FALSE); 430 setUpdatesEnabled(FALSE);
439 paint.begin( this ); 431 paint.begin( this );
440HCNT("setImage"); 432HCNT("setImage");
441 433
442 QPoint tL = contentsRect().topLeft(); 434 QPoint tL = contentsRect().topLeft();
443 int tLx = tL.x(); 435 int tLx = tL.x();
444 int tLy = tL.y(); 436 int tLy = tL.y();
445 hasBlinker = FALSE; 437 hasBlinker = FALSE;
446 438
447 int cf = -1; // undefined 439 int cf = -1; // undefined
448 int cb = -1; // undefined 440 int cb = -1; // undefined
449 int cr = -1; // undefined 441 int cr = -1; // undefined
450 442
451 int lins = QMIN(this->lines, QMAX(0,lines )); 443 int lins = QMIN(this->lines, QMAX(0,lines ));
452 int cols = QMIN(this->columns,QMAX(0,columns)); 444 int cols = QMIN(this->columns,QMAX(0,columns));
453 QChar *disstrU = new QChar[cols]; 445 QChar *disstrU = new QChar[cols];
454 446
455//{ static int cnt = 0; printf("setImage %d\n",cnt++); } 447//{ static int cnt = 0; printf("setImage %d\n",cnt++); }
456 for (y = 0; y < lins; y++) 448 for (y = 0; y < lins; y++)
457 { 449 {
458 const ca* lcl = &image[y*this->columns]; 450 const ca* lcl = &image[y*this->columns];
459 const ca* const ext = &newimg[y*columns]; 451 const ca* const ext = &newimg[y*columns];
460 if (!resizing) // not while resizing, we're expecting a paintEvent 452 if (!resizing) // not while resizing, we're expecting a paintEvent
461 for (x = 0; x < cols; x++) 453 for (x = 0; x < cols; x++)
462 { 454 {
463 hasBlinker |= (ext[x].r & RE_BLINK); 455 hasBlinker |= (ext[x].r & RE_BLINK);
464 if (ext[x] != lcl[x]) 456 if (ext[x] != lcl[x])
465 { 457 {
466 cr = ext[x].r; 458 cr = ext[x].r;
467 cb = ext[x].b; 459 cb = ext[x].b;
468 if (ext[x].f != cf) cf = ext[x].f; 460 if (ext[x].f != cf) cf = ext[x].f;
469 int lln = cols - x; 461 int lln = cols - x;
470 disstrU[0] = fontMap(ext[x+0].c); 462 disstrU[0] = fontMap(ext[x+0].c);
471 for (len = 1; len < lln; len++) 463 for (len = 1; len < lln; len++)
472 { 464 {
473 if (ext[x+len].f != cf || ext[x+len].b != cb || ext[x+len].r != cr || 465 if (ext[x+len].f != cf || ext[x+len].b != cb || ext[x+len].r != cr ||
474 ext[x+len] == lcl[x+len] ) 466 ext[x+len] == lcl[x+len] )
475 break; 467 break;
476 disstrU[len] = fontMap(ext[x+len].c); 468 disstrU[len] = fontMap(ext[x+len].c);
477 } 469 }
478 QString unistr(disstrU,len); 470 QString unistr(disstrU,len);
479 drawAttrStr(paint, 471 drawAttrStr(paint,
480 QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h), 472 QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h),
481 unistr, ext[x], pm != NULL, true); 473 unistr, ext[x], pm != NULL, true);
482 x += len - 1; 474 x += len - 1;
483 } 475 }
484 } 476 }
485 // finally, make `image' become `newimg'. 477 // finally, make `image' become `newimg'.
486 memcpy((void*)lcl,(const void*)ext,cols*sizeof(ca)); 478 memcpy((void*)lcl,(const void*)ext,cols*sizeof(ca));
487 } 479 }
488 drawFrame( &paint ); 480 drawFrame( &paint );
489 paint.end(); 481 paint.end();
490 setUpdatesEnabled(TRUE); 482 setUpdatesEnabled(TRUE);
491 if ( hasBlinker && !blinkT->isActive()) blinkT->start(1000); // 1000 ms 483 if ( hasBlinker && !blinkT->isActive()) blinkT->start(1000); // 1000 ms
492 if (!hasBlinker && blinkT->isActive()) { blinkT->stop(); blinking = FALSE; } 484 if (!hasBlinker && blinkT->isActive()) { blinkT->stop(); blinking = FALSE; }
493 delete [] disstrU; 485 delete [] disstrU;
494} 486}
495 487
496// paint Event //////////////////////////////////////////////////// 488// paint Event ////////////////////////////////////////////////////
497 489
498/*! 490/*!
499 The difference of this routine vs. the `setImage' is, 491 The difference of this routine vs. the `setImage' is,
500 that the drawing does not include a difference analysis 492 that the drawing does not include a difference analysis
501 between the old and the new image. Instead, the internal 493 between the old and the new image. Instead, the internal
502 image is used and the painting bound by the PaintEvent box. 494 image is used and the painting bound by the PaintEvent box.
503*/ 495*/
504 496
505void TEWidget::paintEvent( QPaintEvent* pe ) 497void TEWidget::paintEvent( QPaintEvent* pe )
506{ 498{
507 499
508//{ static int cnt = 0; printf("paint %d\n",cnt++); } 500//{ static int cnt = 0; printf("paint %d\n",cnt++); }
509 const QPixmap* pm = backgroundPixmap(); 501 const QPixmap* pm = backgroundPixmap();
510 QPainter paint; 502 QPainter paint;
511 setUpdatesEnabled(FALSE); 503 setUpdatesEnabled(FALSE);
512 paint.begin( this ); 504 paint.begin( this );
513 paint.setBackgroundMode( TransparentMode ); 505 paint.setBackgroundMode( TransparentMode );
514HCNT("paintEvent"); 506HCNT("paintEvent");
515 507
516 // Note that the actual widget size can be slightly larger 508 // Note that the actual widget size can be slightly larger
517 // that the image (the size is truncated towards the smaller 509 // that the image (the size is truncated towards the smaller
518 // number of characters in `resizeEvent'. The paint rectangle 510 // number of characters in `resizeEvent'. The paint rectangle
519 // can thus be larger than the image, but less then the size 511 // can thus be larger than the image, but less then the size
520 // of one character. 512 // of one character.
521 513
522 QRect rect = pe->rect().intersect(contentsRect()); 514 QRect rect = pe->rect().intersect(contentsRect());
523 515
524 QPoint tL = contentsRect().topLeft(); 516 QPoint tL = contentsRect().topLeft();
525 int tLx = tL.x(); 517 int tLx = tL.x();
526 int tLy = tL.y(); 518 int tLy = tL.y();
527 519
528 int lux = QMIN(columns-1, QMAX(0,(rect.left() - tLx - blX ) / font_w)); 520 int lux = QMIN(columns-1, QMAX(0,(rect.left() - tLx - blX ) / font_w));
529 int luy = QMIN(lines-1, QMAX(0,(rect.top() - tLy - bY ) / font_h)); 521 int luy = QMIN(lines-1, QMAX(0,(rect.top() - tLy - bY ) / font_h));
530 int rlx = QMIN(columns-1, QMAX(0,(rect.right() - tLx - blX ) / font_w)); 522 int rlx = QMIN(columns-1, QMAX(0,(rect.right() - tLx - blX ) / font_w));
531 int rly = QMIN(lines-1, QMAX(0,(rect.bottom() - tLy - bY ) / font_h)); 523 int rly = QMIN(lines-1, QMAX(0,(rect.bottom() - tLy - bY ) / font_h));
532 524
533 /* 525 /*
534 printf("paintEvent: %d..%d, %d..%d (%d..%d, %d..%d)\n",lux,rlx,luy,rly, 526 printf("paintEvent: %d..%d, %d..%d (%d..%d, %d..%d)\n",lux,rlx,luy,rly,
535 rect.left(), rect.right(), rect.top(), rect.bottom()); 527 rect.left(), rect.right(), rect.top(), rect.bottom());
536 */ 528 */
537 529
538 // if (pm != NULL && color_table[image->b].transparent) 530 // if (pm != NULL && color_table[image->b].transparent)
539 // erase(rect); 531 // erase(rect);
540 // BL: I have no idea why we need this, and it breaks the refresh. 532 // BL: I have no idea why we need this, and it breaks the refresh.
541 533
542 QChar *disstrU = new QChar[columns]; 534 QChar *disstrU = new QChar[columns];
543 for (int y = luy; y <= rly; y++) 535 for (int y = luy; y <= rly; y++)
544 for (int x = lux; x <= rlx; x++) 536 for (int x = lux; x <= rlx; x++)
545 { 537 {
546 int len = 1; 538 int len = 1;
547 disstrU[0] = fontMap(image[loc(x,y)].c); 539 disstrU[0] = fontMap(image[loc(x,y)].c);
548 int cf = image[loc(x,y)].f; 540 int cf = image[loc(x,y)].f;
549 int cb = image[loc(x,y)].b; 541 int cb = image[loc(x,y)].b;
550 int cr = image[loc(x,y)].r; 542 int cr = image[loc(x,y)].r;
551 while (x+len <= rlx && 543 while (x+len <= rlx &&
552 image[loc(x+len,y)].f == cf && 544 image[loc(x+len,y)].f == cf &&
553 image[loc(x+len,y)].b == cb && 545 image[loc(x+len,y)].b == cb &&
554 image[loc(x+len,y)].r == cr ) 546 image[loc(x+len,y)].r == cr )
555 { 547 {
556 disstrU[len] = fontMap(image[loc(x+len,y)].c); 548 disstrU[len] = fontMap(image[loc(x+len,y)].c);
557 len += 1; 549 len += 1;
558 } 550 }
559 QString unistr(disstrU,len); 551 QString unistr(disstrU,len);
560 drawAttrStr(paint, 552 drawAttrStr(paint,
561 QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h), 553 QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h),
562 unistr, image[loc(x,y)], pm != NULL, false); 554 unistr, image[loc(x,y)], pm != NULL, false);
563 x += len - 1; 555 x += len - 1;
564 } 556 }
565 delete [] disstrU; 557 delete [] disstrU;
566 drawFrame( &paint ); 558 drawFrame( &paint );
567 paint.end(); 559 paint.end();
568 setUpdatesEnabled(TRUE); 560 setUpdatesEnabled(TRUE);
569} 561}
570 562
571void TEWidget::blinkEvent() 563void TEWidget::blinkEvent()
572{ 564{
573 blinking = !blinking; 565 blinking = !blinking;
574 repaint(FALSE); 566 repaint(FALSE);
575} 567}
576 568
577/* ------------------------------------------------------------------------- */ 569/* ------------------------------------------------------------------------- */
578/* */ 570/* */
579/* Resizing */ 571/* Resizing */
580/* */ 572/* */
581/* ------------------------------------------------------------------------- */ 573/* ------------------------------------------------------------------------- */
582 574
583void TEWidget::resizeEvent(QResizeEvent* ev) 575void TEWidget::resizeEvent(QResizeEvent* ev)
584{ 576{
585// printf("resize: %d,%d\n",ev->size().width(),ev->size().height()); 577// printf("resize: %d,%d\n",ev->size().width(),ev->size().height());
586 //printf("approx: %d,%d\n",ev->size().width()/font_w,ev->size().height()/font_h); 578 //printf("approx: %d,%d\n",ev->size().width()/font_w,ev->size().height()/font_h);
587 //printf("leaves: %d,%d\n",ev->size().width()%font_w,ev->size().height()%font_h); 579 //printf("leaves: %d,%d\n",ev->size().width()%font_w,ev->size().height()%font_h);
588 //printf("curren: %d,%d\n",width(),height()); 580 //printf("curren: %d,%d\n",width(),height());
589HCNT("resizeEvent"); 581HCNT("resizeEvent");
590 582
591 // see comment in `paintEvent' concerning the rounding. 583 // see comment in `paintEvent' concerning the rounding.
592 //FIXME: could make a routine here; check width(),height() 584 //FIXME: could make a routine here; check width(),height()
593 assert(ev->size().width() == width()); 585 assert(ev->size().width() == width());
594 assert(ev->size().height() == height()); 586 assert(ev->size().height() == height());
595 587
596 propagateSize(); 588 propagateSize();
597} 589}
598 590
599void TEWidget::propagateSize() 591void TEWidget::propagateSize()
600{ 592{
601 ca* oldimg = image; 593 ca* oldimg = image;
602 int oldlin = lines; 594 int oldlin = lines;
603 int oldcol = columns; 595 int oldcol = columns;
604 makeImage(); 596 makeImage();
605 // we copy the old image to reduce flicker 597 // we copy the old image to reduce flicker
606 int lins = QMIN(oldlin,lines); 598 int lins = QMIN(oldlin,lines);
607 int cols = QMIN(oldcol,columns); 599 int cols = QMIN(oldcol,columns);
608 if (oldimg) 600 if (oldimg)
609 { 601 {
610 for (int lin = 0; lin < lins; lin++) 602 for (int lin = 0; lin < lins; lin++)
611 memcpy((void*)&image[columns*lin], 603 memcpy((void*)&image[columns*lin],
612 (void*)&oldimg[oldcol*lin],cols*sizeof(ca)); 604 (void*)&oldimg[oldcol*lin],cols*sizeof(ca));
613 free(oldimg); //FIXME: try new,delete 605 free(oldimg); //FIXME: try new,delete
614 } 606 }
615 else 607 else
616 clearImage(); 608 clearImage();
617 609
618 //NOTE: control flows from the back through the chest right into the eye. 610 //NOTE: control flows from the back through the chest right into the eye.
619 // `emu' will call back via `setImage'. 611 // `emu' will call back via `setImage'.
620 612
621 resizing = TRUE; 613 resizing = TRUE;
622 emit changedImageSizeSignal(lines, columns); // expose resizeEvent 614 emit changedImageSizeSignal(lines, columns); // expose resizeEvent
623 resizing = FALSE; 615 resizing = FALSE;
624} 616}
625 617
626/* ------------------------------------------------------------------------- */ 618/* ------------------------------------------------------------------------- */
627/* */ 619/* */
628/* Scrollbar */ 620/* Scrollbar */
629/* */ 621/* */
630/* ------------------------------------------------------------------------- */ 622/* ------------------------------------------------------------------------- */
631 623
632void TEWidget::scrollChanged(int) 624void TEWidget::scrollChanged(int)
633{ 625{
634 emit changedHistoryCursor(scrollbar->value()); //expose 626 emit changedHistoryCursor(scrollbar->value()); //expose
635} 627}
636 628
637void TEWidget::hscrollChanged(int loc) 629void TEWidget::hscrollChanged(int loc)
638{ 630{
639 hposition = loc; 631 hposition = loc;
640 propagateSize(); 632 propagateSize();
641 update(); 633 update();
642} 634}
643 635
644void TEWidget::setScroll(int cursor, int slines) 636void TEWidget::setScroll(int cursor, int slines)
645{ 637{
646 disconnect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); 638 disconnect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int)));
647 scrollbar->setRange(0,slines); 639 scrollbar->setRange(0,slines);
648 scrollbar->setSteps(1,lines); 640 scrollbar->setSteps(1,lines);
649 scrollbar->setValue(cursor); 641 scrollbar->setValue(cursor);
650 connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); 642 connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int)));
651} 643}
652 644
653void TEWidget::setScrollbarLocation(int loc) 645void TEWidget::setScrollbarLocation(int loc)
654{ 646{
655 if (scrollLoc == loc) return; // quickly 647 if (scrollLoc == loc) return; // quickly
656 scrollLoc = loc; 648 scrollLoc = loc;
657 propagateSize(); 649 propagateSize();
658 update(); 650 update();
659} 651}
660 652
661/* ------------------------------------------------------------------------- */ 653/* ------------------------------------------------------------------------- */
662/* */ 654/* */
663/* Mouse */ 655/* Mouse */
664/* */ 656/* */
665/* ------------------------------------------------------------------------- */ 657/* ------------------------------------------------------------------------- */
666 658
667/*! 659/*!
668 Three different operations can be performed using the mouse, and the 660 Three different operations can be performed using the mouse, and the
669 routines in this section serve all of them: 661 routines in this section serve all of them:
670 662
671 1) The press/release events are exposed to the application 663 1) The press/release events are exposed to the application
672 2) Marking (press and move left button) and Pasting (press middle button) 664 2) Marking (press and move left button) and Pasting (press middle button)
673 3) The right mouse button is used from the configuration menu 665 3) The right mouse button is used from the configuration menu
674 666
675 NOTE: During the marking process we attempt to keep the cursor within 667 NOTE: During the marking process we attempt to keep the cursor within
676 the bounds of the text as being displayed by setting the mouse position 668 the bounds of the text as being displayed by setting the mouse position
677 whenever the mouse has left the text area. 669 whenever the mouse has left the text area.
678 670
679 Two reasons to do so: 671 Two reasons to do so:
680 1) QT does not allow the `grabMouse' to confine-to the TEWidget. 672 1) QT does not allow the `grabMouse' to confine-to the TEWidget.
681 Thus a `XGrapPointer' would have to be used instead. 673 Thus a `XGrapPointer' would have to be used instead.
682 2) Even if so, this would not help too much, since the text area 674 2) Even if so, this would not help too much, since the text area
683 of the TEWidget is normally not identical with it's bounds. 675 of the TEWidget is normally not identical with it's bounds.
684 676
685 The disadvantage of the current handling is, that the mouse can visibly 677 The disadvantage of the current handling is, that the mouse can visibly
686 leave the bounds of the widget and is then moved back. Because of the 678 leave the bounds of the widget and is then moved back. Because of the
687 current construction, and the reasons mentioned above, we cannot do better 679 current construction, and the reasons mentioned above, we cannot do better
688 without changing the overall construction. 680 without changing the overall construction.
689*/ 681*/
690 682
691/*! 683/*!
692*/ 684*/
693 685
694void TEWidget::mousePressEvent(QMouseEvent* ev) 686void TEWidget::mousePressEvent(QMouseEvent* ev)
695{ 687{
696//printf("press [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button()); 688//printf("press [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button());
697 if ( !contentsRect().contains(ev->pos()) ) return; 689 if ( !contentsRect().contains(ev->pos()) ) return;
698 QPoint tL = contentsRect().topLeft(); 690 QPoint tL = contentsRect().topLeft();
699 int tLx = tL.x(); 691 int tLx = tL.x();
700 int tLy = tL.y(); 692 int tLy = tL.y();
701 693
702 word_selection_mode = FALSE; 694 word_selection_mode = FALSE;
703 695
704//printf("press top left [%d,%d] by=%d\n",tLx,tLy, bY); 696//printf("press top left [%d,%d] by=%d\n",tLx,tLy, bY);
705 if ( ev->button() == LeftButton) 697 if ( ev->button() == LeftButton)
706 { 698 {
707 QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); 699 QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h);
708 700
709 if ( ev->state() & ControlButton ) preserve_line_breaks = FALSE ; 701 if ( ev->state() & ControlButton ) preserve_line_breaks = FALSE ;
710 702
711 if (mouse_marks || (ev->state() & ShiftButton)) 703 if (mouse_marks || (ev->state() & ShiftButton))
712 { 704 {
713 emit clearSelectionSignal(); 705 emit clearSelectionSignal();
714 iPntSel = pntSel = pos; 706 iPntSel = pntSel = pos;
715 actSel = 1; // left mouse button pressed but nothing selected yet. 707 actSel = 1; // left mouse button pressed but nothing selected yet.
716 grabMouse( /*crossCursor*/ ); // handle with care! 708 grabMouse( /*crossCursor*/ ); // handle with care!
717 } 709 }
718 else 710 else
719 { 711 {
720 emit mouseSignal( 0, pos.x() + 1, pos.y() + 1 ); // left button 712 emit mouseSignal( 0, pos.x() + 1, pos.y() + 1 ); // left button
721 } 713 }
722 } 714 }
723 if ( ev->button() == MidButton ) 715 if ( ev->button() == MidButton )
724 { 716 {
725 emitSelection(); 717 emitSelection();
726 } 718 }
727 if ( ev->button() == RightButton ) // Configure 719 if ( ev->button() == RightButton ) // Configure
728 { 720 {
729 emit configureRequest( this, ev->state()&(ShiftButton|ControlButton), ev->x(), ev->y() ); 721 emit configureRequest( this, ev->state()&(ShiftButton|ControlButton), ev->x(), ev->y() );
730 } 722 }
731} 723}
732 724
733void TEWidget::mouseMoveEvent(QMouseEvent* ev) 725void TEWidget::mouseMoveEvent(QMouseEvent* ev)
734{ 726{
735 // for auto-hiding the cursor, we need mouseTracking 727 // for auto-hiding the cursor, we need mouseTracking
736 if (ev->state() == NoButton ) return; 728 if (ev->state() == NoButton ) return;
737 729
738 if (actSel == 0) return; 730 if (actSel == 0) return;
739 731
740 // don't extend selection while pasting 732 // don't extend selection while pasting
741 if (ev->state() & MidButton) return; 733 if (ev->state() & MidButton) return;
742 734
743 //if ( !contentsRect().contains(ev->pos()) ) return; 735 //if ( !contentsRect().contains(ev->pos()) ) return;
744 QPoint tL = contentsRect().topLeft(); 736 QPoint tL = contentsRect().topLeft();
745 int tLx = tL.x(); 737 int tLx = tL.x();
746 int tLy = tL.y(); 738 int tLy = tL.y();
747 int scroll = scrollbar->value(); 739 int scroll = scrollbar->value();
748 740
749 // we're in the process of moving the mouse with the left button pressed 741 // we're in the process of moving the mouse with the left button pressed
750 // the mouse cursor will kept catched within the bounds of the text in 742 // the mouse cursor will kept catched within the bounds of the text in
751 // this widget. 743 // this widget.
752 744
753 // Adjust position within text area bounds. See FIXME above. 745 // Adjust position within text area bounds. See FIXME above.
754 QPoint pos = ev->pos(); 746 QPoint pos = ev->pos();
755 if ( pos.x() < tLx+blX ) pos.setX( tLx+blX ); 747 if ( pos.x() < tLx+blX ) pos.setX( tLx+blX );
756 if ( pos.x() > tLx+blX+columns*font_w-1 ) pos.setX( tLx+blX+columns*font_w ); 748 if ( pos.x() > tLx+blX+columns*font_w-1 ) pos.setX( tLx+blX+columns*font_w );
757 if ( pos.y() < tLy+bY ) pos.setY( tLy+bY ); 749 if ( pos.y() < tLy+bY ) pos.setY( tLy+bY );
758 if ( pos.y() > tLy+bY+lines*font_h-1 ) pos.setY( tLy+bY+lines*font_h-1 ); 750 if ( pos.y() > tLy+bY+lines*font_h-1 ) pos.setY( tLy+bY+lines*font_h-1 );
759 // check if we produce a mouse move event by this 751 // check if we produce a mouse move event by this
760 if ( pos != ev->pos() ) cursor().setPos(mapToGlobal(pos)); 752 if ( pos != ev->pos() ) cursor().setPos(mapToGlobal(pos));
761 753
762 if ( pos.y() == tLy+bY+lines*font_h-1 ) 754 if ( pos.y() == tLy+bY+lines*font_h-1 )
763 { 755 {
764 scrollbar->setValue(scrollbar->value()+yMouseScroll); // scrollforward 756 scrollbar->setValue(scrollbar->value()+yMouseScroll); // scrollforward
765 } 757 }
766 if ( pos.y() == tLy+bY ) 758 if ( pos.y() == tLy+bY )
767 { 759 {
768 scrollbar->setValue(scrollbar->value()-yMouseScroll); // scrollback 760 scrollbar->setValue(scrollbar->value()-yMouseScroll); // scrollback
769 } 761 }
770 762
771 QPoint here = QPoint((pos.x()-tLx-blX)/font_w,(pos.y()-tLy-bY)/font_h); 763 QPoint here = QPoint((pos.x()-tLx-blX)/font_w,(pos.y()-tLy-bY)/font_h);
772 QPoint ohere; 764 QPoint ohere;
773 bool swapping = FALSE; 765 bool swapping = FALSE;
774 766
775 if ( word_selection_mode ) 767 if ( word_selection_mode )
776 { 768 {
777 // Extend to word boundaries 769 // Extend to word boundaries
778 int i; 770 int i;
779 int selClass; 771 int selClass;
780 772
781 bool left_not_right = ( here.y() < iPntSel.y() || 773 bool left_not_right = ( here.y() < iPntSel.y() ||
782 here.y() == iPntSel.y() && here.x() < iPntSel.x() ); 774 here.y() == iPntSel.y() && here.x() < iPntSel.x() );
783 bool old_left_not_right = ( pntSel.y() < iPntSel.y() || 775 bool old_left_not_right = ( pntSel.y() < iPntSel.y() ||
784 pntSel.y() == iPntSel.y() && pntSel.x() < iPntSel.x() ); 776 pntSel.y() == iPntSel.y() && pntSel.x() < iPntSel.x() );
785 swapping = left_not_right != old_left_not_right; 777 swapping = left_not_right != old_left_not_right;
786 778
787 // Find left (left_not_right ? from here : from start) 779 // Find left (left_not_right ? from here : from start)
788 QPoint left = left_not_right ? here : iPntSel; 780 QPoint left = left_not_right ? here : iPntSel;
789 i = loc(left.x(),left.y()); 781 i = loc(left.x(),left.y());
790 selClass = charClass(image[i].c); 782 selClass = charClass(image[i].c);
791 while ( left.x() > 0 && charClass(image[i-1].c) == selClass ) 783 while ( left.x() > 0 && charClass(image[i-1].c) == selClass )
792 { i--; left.rx()--; } 784 { i--; left.rx()--; }
793 785
794 // Find left (left_not_right ? from start : from here) 786 // Find left (left_not_right ? from start : from here)
795 QPoint right = left_not_right ? iPntSel : here; 787 QPoint right = left_not_right ? iPntSel : here;
796 i = loc(right.x(),right.y()); 788 i = loc(right.x(),right.y());
797 selClass = charClass(image[i].c); 789 selClass = charClass(image[i].c);
798 while ( right.x() < columns-1 && charClass(image[i+1].c) == selClass ) 790 while ( right.x() < columns-1 && charClass(image[i+1].c) == selClass )
799 { i++; right.rx()++; } 791 { i++; right.rx()++; }
800 792
801 // Pick which is start (ohere) and which is extension (here) 793 // Pick which is start (ohere) and which is extension (here)
802 if ( left_not_right ) 794 if ( left_not_right )
803 { 795 {
804 here = left; ohere = right; 796 here = left; ohere = right;
805 } 797 }
806 else 798 else
807 { 799 {
808 here = right; ohere = left; 800 here = right; ohere = left;
809 } 801 }
810 } 802 }
811 803
812 if (here == pntSel && scroll == scrollbar->value()) return; // not moved 804 if (here == pntSel && scroll == scrollbar->value()) return; // not moved
813 805
814 if ( word_selection_mode ) { 806 if ( word_selection_mode ) {
815 if ( actSel < 2 || swapping ) { 807 if ( actSel < 2 || swapping ) {
816 emit beginSelectionSignal( ohere.x(), ohere.y() ); 808 emit beginSelectionSignal( ohere.x(), ohere.y() );
817 } 809 }
818 } else if ( actSel < 2 ) { 810 } else if ( actSel < 2 ) {
819 emit beginSelectionSignal( pntSel.x(), pntSel.y() ); 811 emit beginSelectionSignal( pntSel.x(), pntSel.y() );
820 } 812 }
821 813
822 actSel = 2; // within selection 814 actSel = 2; // within selection
823 pntSel = here; 815 pntSel = here;
824 emit extendSelectionSignal( here.x(), here.y() ); 816 emit extendSelectionSignal( here.x(), here.y() );
825} 817}
826 818
827void TEWidget::mouseReleaseEvent(QMouseEvent* ev) 819void TEWidget::mouseReleaseEvent(QMouseEvent* ev)
828{ 820{
829//printf("release [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button()); 821//printf("release [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button());
830 if ( ev->button() == LeftButton) 822 if ( ev->button() == LeftButton)
831 { 823 {
diff --git a/noncore/apps/opie-console/TEmuVt102.cpp b/noncore/apps/opie-console/TEmuVt102.cpp
index 275c18d..0d6aef5 100644
--- a/noncore/apps/opie-console/TEmuVt102.cpp
+++ b/noncore/apps/opie-console/TEmuVt102.cpp
@@ -1,802 +1,797 @@
1/* ------------------------------------------------------------------------- */ 1/* ------------------------------------------------------------------------- */
2/* */ 2/* */
3/* [TEmuVt102.C] VT102 Terminal Emulation */ 3/* [TEmuVt102.C] 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 TEmuVt102 19/*! \class TEmuVt102
20 20
21 \brief Actual Emulation for Konsole 21 \brief Actual Emulation for Konsole
22 22
23 \sa TEWidget \sa TEScreen 23 \sa TEWidget \sa TEScreen
24*/ 24*/
25 25
26#include "TEmuVt102.h" 26#include "TEmuVt102.h"
27#include "TEWidget.h"
28#include "TEScreen.h"
29#include "keytrans.h"
30 27
31#include <stdio.h> 28#include <stdio.h>
32#include <unistd.h> 29#include <unistd.h>
33#include <qkeycode.h>
34#include <qtextcodec.h>
35 30
36 31
37/* VT102 Terminal Emulation 32/* VT102 Terminal Emulation
38 33
39 This class puts together the screens, the pty and the widget to a 34 This class puts together the screens, the pty and the widget to a
40 complete terminal emulation. Beside combining it's componentes, it 35 complete terminal emulation. Beside combining it's componentes, it
41 handles the emulations's protocol. 36 handles the emulations's protocol.
42 37
43 This module consists of the following sections: 38 This module consists of the following sections:
44 39
45 - Constructor/Destructor 40 - Constructor/Destructor
46 - Incoming Bytes Event pipeline 41 - Incoming Bytes Event pipeline
47 - Outgoing Bytes 42 - Outgoing Bytes
48 - Mouse Events 43 - Mouse Events
49 - Keyboard Events 44 - Keyboard Events
50 - Modes and Charset State 45 - Modes and Charset State
51 - Diagnostics 46 - Diagnostics
52*/ 47*/
53 48
54 49
55/* ------------------------------------------------------------------------- */ 50/* ------------------------------------------------------------------------- */
56/* */ 51/* */
57/* Constructor / Destructor */ 52/* Constructor / Destructor */
58/* */ 53/* */
59/* ------------------------------------------------------------------------- */ 54/* ------------------------------------------------------------------------- */
60 55
61/* 56/*
62 Nothing really intesting happens here. 57 Nothing really intesting happens here.
63*/ 58*/
64 59
65/*! 60/*!
66*/ 61*/
67 62
68TEmuVt102::TEmuVt102(TEWidget* gui) : TEmulation(gui) 63TEmuVt102::TEmuVt102(TEWidget* gui) : TEmulation(gui)
69{ 64{
70 QObject::connect(gui,SIGNAL(mouseSignal(int,int,int)), 65 QObject::connect(gui,SIGNAL(mouseSignal(int,int,int)),
71 this,SLOT(onMouse(int,int,int))); 66 this,SLOT(onMouse(int,int,int)));
72 initTokenizer(); 67 initTokenizer();
73 reset(); 68 reset();
74} 69}
75 70
76/*! 71/*!
77*/ 72*/
78 73
79TEmuVt102::~TEmuVt102() 74TEmuVt102::~TEmuVt102()
80{ 75{
81} 76}
82 77
83/*! 78/*!
84*/ 79*/
85 80
86void TEmuVt102::reset() 81void TEmuVt102::reset()
87{ 82{
88 resetToken(); 83 resetToken();
89 resetModes(); 84 resetModes();
90 resetCharset(0); screen[0]->reset(); 85 resetCharset(0); screen[0]->reset();
91 resetCharset(1); screen[0]->reset(); 86 resetCharset(1); screen[0]->reset();
92 setCodec(0); 87 setCodec(0);
93 setKeytrans("linux.keytab"); 88 setKeytrans("linux.keytab");
94} 89}
95 90
96/* ------------------------------------------------------------------------- */ 91/* ------------------------------------------------------------------------- */
97/* */ 92/* */
98/* Processing the incoming byte stream */ 93/* Processing the incoming byte stream */
99/* */ 94/* */
100/* ------------------------------------------------------------------------- */ 95/* ------------------------------------------------------------------------- */
101 96
102/* Incoming Bytes Event pipeline 97/* Incoming Bytes Event pipeline
103 98
104 This section deals with decoding the incoming character stream. 99 This section deals with decoding the incoming character stream.
105 Decoding means here, that the stream is first seperated into `tokens' 100 Decoding means here, that the stream is first seperated into `tokens'
106 which are then mapped to a `meaning' provided as operations by the 101 which are then mapped to a `meaning' provided as operations by the
107 `TEScreen' class or by the emulation class itself. 102 `TEScreen' class or by the emulation class itself.
108 103
109 The pipeline proceeds as follows: 104 The pipeline proceeds as follows:
110 105
111 - Tokenizing the ESC codes (onRcvChar) 106 - Tokenizing the ESC codes (onRcvChar)
112 - VT100 code page translation of plain characters (applyCharset) 107 - VT100 code page translation of plain characters (applyCharset)
113 - Interpretation of ESC codes (tau) 108 - Interpretation of ESC codes (tau)
114 109
115 The escape codes and their meaning are described in the 110 The escape codes and their meaning are described in the
116 technical reference of this program. 111 technical reference of this program.
117*/ 112*/
118 113
119// Tokens ------------------------------------------------------------------ -- 114// Tokens ------------------------------------------------------------------ --
120 115
121/* 116/*
122 Since the tokens are the central notion if this section, we've put them 117 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 118 in front. They provide the syntactical elements used to represent the
124 terminals operations as byte sequences. 119 terminals operations as byte sequences.
125 120
126 They are encodes here into a single machine word, so that we can later 121 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 122 switch over them easily. Depending on the token itself, additional
128 argument variables are filled with parameter values. 123 argument variables are filled with parameter values.
129 124
130 The tokens are defined below: 125 The tokens are defined below:
131 126
132 - CHR - Printable characters (32..255 but DEL (=127)) 127 - CHR - Printable characters (32..255 but DEL (=127))
133 - CTL - Control characters (0..31 but ESC (= 27), DEL) 128 - CTL - Control characters (0..31 but ESC (= 27), DEL)
134 - ESC - Escape codes of the form <ESC><CHR but `[]()+*#'> 129 - ESC - Escape codes of the form <ESC><CHR but `[]()+*#'>
135 - ESC_DE - Escape codes of the form <ESC><any of `()+*#%'> C 130 - ESC_DE - Escape codes of the form <ESC><any of `()+*#%'> C
136 - CSI_PN - Escape codes of the form <ESC>'[' {Pn} ';' {Pn} C 131 - CSI_PN - Escape codes of the form <ESC>'[' {Pn} ';' {Pn} C
137 - CSI_PS - Escape codes of the form <ESC>'[' {Pn} ';' ... C 132 - CSI_PS - Escape codes of the form <ESC>'[' {Pn} ';' ... C
138 - CSI_PR - Escape codes of the form <ESC>'[' '?' {Pn} ';' ... C 133 - CSI_PR - Escape codes of the form <ESC>'[' '?' {Pn} ';' ... C
139 - VT52 - VT52 escape codes 134 - VT52 - VT52 escape codes
140 - <ESC><Chr> 135 - <ESC><Chr>
141 - <ESC>'Y'{Pc}{Pc} 136 - <ESC>'Y'{Pc}{Pc}
142 - XTE_HA - Xterm hacks <ESC>`]' {Pn} `;' {Text} <BEL> 137 - XTE_HA - Xterm hacks <ESC>`]' {Pn} `;' {Text} <BEL>
143 note that this is handled differently 138 note that this is handled differently
144 139
145 The last two forms allow list of arguments. Since the elements of 140 The last two forms allow list of arguments. Since the elements of
146 the lists are treated individually the same way, they are passed 141 the lists are treated individually the same way, they are passed
147 as individual tokens to the interpretation. Further, because the 142 as individual tokens to the interpretation. Further, because the
148 meaning of the parameters are names (althought represented as numbers), 143 meaning of the parameters are names (althought represented as numbers),
149 they are includes within the token ('N'). 144 they are includes within the token ('N').
150 145
151*/ 146*/
152 147
153#define TY_CONSTR(T,A,N) ( ((((int)N) & 0xffff) << 16) | ((((int)A) & 0xff) << 8) | (((int)T) & 0xff) ) 148#define TY_CONSTR(T,A,N) ( ((((int)N) & 0xffff) << 16) | ((((int)A) & 0xff) << 8) | (((int)T) & 0xff) )
154 149
155#define TY_CHR___( ) TY_CONSTR(0,0,0) 150#define TY_CHR___( ) TY_CONSTR(0,0,0)
156#define TY_CTL___(A ) TY_CONSTR(1,A,0) 151#define TY_CTL___(A ) TY_CONSTR(1,A,0)
157#define TY_ESC___(A ) TY_CONSTR(2,A,0) 152#define TY_ESC___(A ) TY_CONSTR(2,A,0)
158#define TY_ESC_CS(A,B) TY_CONSTR(3,A,B) 153#define TY_ESC_CS(A,B) TY_CONSTR(3,A,B)
159#define TY_ESC_DE(A ) TY_CONSTR(4,A,0) 154#define TY_ESC_DE(A ) TY_CONSTR(4,A,0)
160#define TY_CSI_PS(A,N) TY_CONSTR(5,A,N) 155#define TY_CSI_PS(A,N) TY_CONSTR(5,A,N)
161#define TY_CSI_PN(A ) TY_CONSTR(6,A,0) 156#define TY_CSI_PN(A ) TY_CONSTR(6,A,0)
162#define TY_CSI_PR(A,N) TY_CONSTR(7,A,N) 157#define TY_CSI_PR(A,N) TY_CONSTR(7,A,N)
163 158
164#define TY_VT52__(A ) TY_CONSTR(8,A,0) 159#define TY_VT52__(A ) TY_CONSTR(8,A,0)
165 160
166// Tokenizer --------------------------------------------------------------- -- 161// Tokenizer --------------------------------------------------------------- --
167 162
168/* The tokenizers state 163/* The tokenizers state
169 164
170 The state is represented by the buffer (pbuf, ppos), 165 The state is represented by the buffer (pbuf, ppos),
171 and accompanied by decoded arguments kept in (argv,argc). 166 and accompanied by decoded arguments kept in (argv,argc).
172 Note that they are kept internal in the tokenizer. 167 Note that they are kept internal in the tokenizer.
173*/ 168*/
174 169
175void TEmuVt102::resetToken() 170void TEmuVt102::resetToken()
176{ 171{
177 ppos = 0; argc = 0; argv[0] = 0; argv[1] = 0; 172 ppos = 0; argc = 0; argv[0] = 0; argv[1] = 0;
178} 173}
179 174
180void TEmuVt102::addDigit(int dig) 175void TEmuVt102::addDigit(int dig)
181{ 176{
182 argv[argc] = 10*argv[argc] + dig; 177 argv[argc] = 10*argv[argc] + dig;
183} 178}
184 179
185void TEmuVt102::addArgument() 180void TEmuVt102::addArgument()
186{ 181{
187 argc = QMIN(argc+1,MAXARGS-1); 182 argc = QMIN(argc+1,MAXARGS-1);
188 argv[argc] = 0; 183 argv[argc] = 0;
189} 184}
190 185
191void TEmuVt102::pushToToken(int cc) 186void TEmuVt102::pushToToken(int cc)
192{ 187{
193 pbuf[ppos] = cc; 188 pbuf[ppos] = cc;
194 ppos = QMIN(ppos+1,MAXPBUF-1); 189 ppos = QMIN(ppos+1,MAXPBUF-1);
195} 190}
196 191
197// Character Classes used while decoding 192// Character Classes used while decoding
198 193
199#define CTL 1 194#define CTL 1
200#define CHR 2 195#define CHR 2
201#define CPN 4 196#define CPN 4
202#define DIG 8 197#define DIG 8
203#define SCS 16 198#define SCS 16
204#define GRP 32 199#define GRP 32
205 200
206void TEmuVt102::initTokenizer() 201void TEmuVt102::initTokenizer()
207{ int i; UINT8* s; 202{ int i; UINT8* s;
208 for(i = 0; i < 256; i++) tbl[ i] = 0; 203 for(i = 0; i < 256; i++) tbl[ i] = 0;
209 for(i = 0; i < 32; i++) tbl[ i] |= CTL; 204 for(i = 0; i < 32; i++) tbl[ i] |= CTL;
210 for(i = 32; i < 256; i++) tbl[ i] |= CHR; 205 for(i = 32; i < 256; i++) tbl[ i] |= CHR;
211 for(s = (UINT8*)"@ABCDGHLMPXcdfry"; *s; s++) tbl[*s] |= CPN; 206 for(s = (UINT8*)"@ABCDGHLMPXcdfry"; *s; s++) tbl[*s] |= CPN;
212 for(s = (UINT8*)"0123456789" ; *s; s++) tbl[*s] |= DIG; 207 for(s = (UINT8*)"0123456789" ; *s; s++) tbl[*s] |= DIG;
213 for(s = (UINT8*)"()+*%" ; *s; s++) tbl[*s] |= SCS; 208 for(s = (UINT8*)"()+*%" ; *s; s++) tbl[*s] |= SCS;
214 for(s = (UINT8*)"()+*#[]%" ; *s; s++) tbl[*s] |= GRP; 209 for(s = (UINT8*)"()+*#[]%" ; *s; s++) tbl[*s] |= GRP;
215 resetToken(); 210 resetToken();
216} 211}
217 212
218/* Ok, here comes the nasty part of the decoder. 213/* Ok, here comes the nasty part of the decoder.
219 214
220 Instead of keeping an explicit state, we deduce it from the 215 Instead of keeping an explicit state, we deduce it from the
221 token scanned so far. It is then immediately combined with 216 token scanned so far. It is then immediately combined with
222 the current character to form a scanning decision. 217 the current character to form a scanning decision.
223 218
224 This is done by the following defines. 219 This is done by the following defines.
225 220
226 - P is the length of the token scanned so far. 221 - 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. 222 - 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'). 223 - C is a character or a group of characters (taken from 'tbl').
229 224
230 Note that they need to applied in proper order. 225 Note that they need to applied in proper order.
231*/ 226*/
232 227
233#define lec(P,L,C) (p == (P) && s[(L)] == (C)) 228#define lec(P,L,C) (p == (P) && s[(L)] == (C))
234#define lun( ) (p == 1 && cc >= 32 ) 229#define lun( ) (p == 1 && cc >= 32 )
235#define les(P,L,C) (p == (P) && s[L] < 256 && (tbl[s[(L)]] & (C)) == (C)) 230#define les(P,L,C) (p == (P) && s[L] < 256 && (tbl[s[(L)]] & (C)) == (C))
236#define eec(C) (p >= 3 && cc == (C)) 231#define eec(C) (p >= 3 && cc == (C))
237#define ees(C) (p >= 3 && cc < 256 && (tbl[ cc ] & (C)) == (C)) 232#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)) 233#define eps(C) (p >= 3 && s[2] != '?' && cc < 256 && (tbl[ cc ] & (C)) == (C))
239#define epp( ) (p >= 3 && s[2] == '?' ) 234#define epp( ) (p >= 3 && s[2] == '?' )
240#define egt( ) (p == 3 && s[2] == '>' ) 235#define egt( ) (p == 3 && s[2] == '>' )
241#define Xpe (ppos>=2 && pbuf[1] == ']' ) 236#define Xpe (ppos>=2 && pbuf[1] == ']' )
242#define Xte (Xpe && cc == 7 ) 237#define Xte (Xpe && cc == 7 )
243#define ces(C) ( cc < 256 && (tbl[ cc ] & (C)) == (C) && !Xte) 238#define ces(C) ( cc < 256 && (tbl[ cc ] & (C)) == (C) && !Xte)
244 239
245#define ESC 27 240#define ESC 27
246#define CNTL(c) ((c)-'@') 241#define CNTL(c) ((c)-'@')
247 242
248// process an incoming unicode character 243// process an incoming unicode character
249 244
250void TEmuVt102::onRcvChar(int cc) 245void TEmuVt102::onRcvChar(int cc)
251{ int i; 246{ int i;
252 247
253 if (cc == 127) return; //VT100: ignore. 248 if (cc == 127) return; //VT100: ignore.
254 249
255 if (ces( CTL)) 250 if (ces( CTL))
256 { // DEC HACK ALERT! Control Characters are allowed *within* esc sequences in VT100 251 { // 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 252 // 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 253 // of course. Guess this originates from a weakly layered handling of the X-on
259 // X-off protocol, which comes really below this level. 254 // X-off protocol, which comes really below this level.
260 if (cc == CNTL('X') || cc == CNTL('Z') || cc == ESC) resetToken(); //VT100: CAN or SUB 255 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; } 256 if (cc != ESC) { tau( TY_CTL___(cc+'@' ), 0, 0); return; }
262 } 257 }
263 258
264 pushToToken(cc); // advance the state 259 pushToToken(cc); // advance the state
265 260
266 int* s = pbuf; 261 int* s = pbuf;
267 int p = ppos; 262 int p = ppos;
268 263
269 if (getMode(MODE_Ansi)) // decide on proper action 264 if (getMode(MODE_Ansi)) // decide on proper action
270 { 265 {
271 if (lec(1,0,ESC)) { return; } 266 if (lec(1,0,ESC)) { return; }
272 if (les(2,1,GRP)) { return; } 267 if (les(2,1,GRP)) { return; }
273 if (Xte ) { XtermHack(); resetToken(); return; } 268 if (Xte ) { XtermHack(); resetToken(); return; }
274 if (Xpe ) { return; } 269 if (Xpe ) { return; }
275 if (lec(3,2,'?')) { return; } 270 if (lec(3,2,'?')) { return; }
276 if (lec(3,2,'>')) { return; } 271 if (lec(3,2,'>')) { return; }
277 if (lun( )) { tau( TY_CHR___(), applyCharset(cc), 0); resetToken(); return; } 272 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; } 273 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; } 274 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; } 275 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; } 276// 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; } 277 if (eps( CPN)) { tau( TY_CSI_PN(cc), argv[0],argv[1]); resetToken(); return; }
283 if (ees( DIG)) { addDigit(cc-'0'); return; } 278 if (ees( DIG)) { addDigit(cc-'0'); return; }
284 if (eec( ';')) { addArgument(); return; } 279 if (eec( ';')) { addArgument(); return; }
285 for (i=0;i<=argc;i++) 280 for (i=0;i<=argc;i++)
286 if (epp( )) tau( TY_CSI_PR(cc,argv[i]), 0, 0); else 281 if (epp( )) tau( TY_CSI_PR(cc,argv[i]), 0, 0); else
287 tau( TY_CSI_PS(cc,argv[i]), 0, 0); 282 tau( TY_CSI_PS(cc,argv[i]), 0, 0);
288 resetToken(); 283 resetToken();
289 } 284 }
290 else // mode VT52 285 else // mode VT52
291 { 286 {
292 if (lec(1,0,ESC)) return; 287 if (lec(1,0,ESC)) return;
293 if (les(1,0,CHR)) { tau( TY_CHR___( ), s[0], 0); resetToken(); return; } 288 if (les(1,0,CHR)) { tau( TY_CHR___( ), s[0], 0); resetToken(); return; }
294 if (lec(2,1,'Y')) return; 289 if (lec(2,1,'Y')) return;
295 if (lec(3,1,'Y')) return; 290 if (lec(3,1,'Y')) return;
296 if (p < 4) { tau( TY_VT52__(s[1] ), 0, 0); resetToken(); return; } 291 if (p < 4) { tau( TY_VT52__(s[1] ), 0, 0); resetToken(); return; }
297 tau( TY_VT52__(s[1] ), s[2],s[3]); resetToken(); return; 292 tau( TY_VT52__(s[1] ), s[2],s[3]); resetToken(); return;
298 } 293 }
299} 294}
300 295
301void TEmuVt102::XtermHack() 296void TEmuVt102::XtermHack()
302{ int i,arg = 0; 297{ int i,arg = 0;
303 for (i = 2; i < ppos && '0'<=pbuf[i] && pbuf[i]<'9' ; i++) 298 for (i = 2; i < ppos && '0'<=pbuf[i] && pbuf[i]<'9' ; i++)
304 arg = 10*arg + (pbuf[i]-'0'); 299 arg = 10*arg + (pbuf[i]-'0');
305 if (pbuf[i] != ';') { ReportErrorToken(); return; } 300 if (pbuf[i] != ';') { ReportErrorToken(); return; }
306 QChar *str = new QChar[ppos-i-2]; 301 QChar *str = new QChar[ppos-i-2];
307 for (int j = 0; j < ppos-i-2; j++) str[j] = pbuf[i+1+j]; 302 for (int j = 0; j < ppos-i-2; j++) str[j] = pbuf[i+1+j];
308 QString unistr(str,ppos-i-2); 303 QString unistr(str,ppos-i-2);
309 // arg == 1 doesn't change the title. In XTerm it only changes the icon name 304 // 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 305 // (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); 306 if (arg == 0 || arg == 2) emit changeTitle(arg,unistr);
312 delete [] str; 307 delete [] str;
313} 308}
314 309
315// Interpreting Codes --------------------------------------------------------- 310// Interpreting Codes ---------------------------------------------------------
316 311
317/* 312/*
318 Now that the incoming character stream is properly tokenized, 313 Now that the incoming character stream is properly tokenized,
319 meaning is assigned to them. These are either operations of 314 meaning is assigned to them. These are either operations of
320 the current screen, or of the emulation class itself. 315 the current screen, or of the emulation class itself.
321 316
322 The token to be interpreteted comes in as a machine word 317 The token to be interpreteted comes in as a machine word
323 possibly accompanied by two parameters. 318 possibly accompanied by two parameters.
324 319
325 Likewise, the operations assigned to, come with up to two 320 Likewise, the operations assigned to, come with up to two
326 arguments. One could consider to make up a proper table 321 arguments. One could consider to make up a proper table
327 from the function below. 322 from the function below.
328 323
329 The technical reference manual provides more informations 324 The technical reference manual provides more informations
330 about this mapping. 325 about this mapping.
331*/ 326*/
332 327
333void TEmuVt102::tau( int token, int p, int q ) 328void TEmuVt102::tau( int token, int p, int q )
334{ 329{
335//scan_buffer_report(); 330//scan_buffer_report();
336//if (token == TY_CHR___()) printf("%c",p); else 331//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); 332//printf("tau(%d,%d,%d, %d,%d)\n",(token>>0)&0xff,(token>>8)&0xff,(token>>16)&0xffff,p,q);
338 switch (token) 333 switch (token)
339 { 334 {
340 335
341 case TY_CHR___( ) : scr->ShowCharacter (p ); break; //UTF16 336 case TY_CHR___( ) : scr->ShowCharacter (p ); break; //UTF16
342 337
343 // 127 DEL : ignored on input 338 // 127 DEL : ignored on input
344 339
345 case TY_CTL___('@' ) : /* NUL: ignored */ break; 340 case TY_CTL___('@' ) : /* NUL: ignored */ break;
346 case TY_CTL___('A' ) : /* SOH: ignored */ break; 341 case TY_CTL___('A' ) : /* SOH: ignored */ break;
347 case TY_CTL___('B' ) : /* STX: ignored */ break; 342 case TY_CTL___('B' ) : /* STX: ignored */ break;
348 case TY_CTL___('C' ) : /* ETX: ignored */ break; 343 case TY_CTL___('C' ) : /* ETX: ignored */ break;
349 case TY_CTL___('D' ) : /* EOT: ignored */ break; 344 case TY_CTL___('D' ) : /* EOT: ignored */ break;
350 case TY_CTL___('E' ) : reportAnswerBack ( ); break; //VT100 345 case TY_CTL___('E' ) : reportAnswerBack ( ); break; //VT100
351 case TY_CTL___('F' ) : /* ACK: ignored */ break; 346 case TY_CTL___('F' ) : /* ACK: ignored */ break;
352 case TY_CTL___('G' ) : gui->Bell ( ); break; //VT100 347 case TY_CTL___('G' ) : gui->Bell ( ); break; //VT100
353 case TY_CTL___('H' ) : scr->BackSpace ( ); break; //VT100 348 case TY_CTL___('H' ) : scr->BackSpace ( ); break; //VT100
354 case TY_CTL___('I' ) : scr->Tabulate ( ); break; //VT100 349 case TY_CTL___('I' ) : scr->Tabulate ( ); break; //VT100
355 case TY_CTL___('J' ) : scr->NewLine ( ); break; //VT100 350 case TY_CTL___('J' ) : scr->NewLine ( ); break; //VT100
356 case TY_CTL___('K' ) : scr->NewLine ( ); break; //VT100 351 case TY_CTL___('K' ) : scr->NewLine ( ); break; //VT100
357 case TY_CTL___('L' ) : scr->NewLine ( ); break; //VT100 352 case TY_CTL___('L' ) : scr->NewLine ( ); break; //VT100
358 case TY_CTL___('M' ) : scr->Return ( ); break; //VT100 353 case TY_CTL___('M' ) : scr->Return ( ); break; //VT100
359 354
360 case TY_CTL___('N' ) : useCharset ( 1); break; //VT100 355 case TY_CTL___('N' ) : useCharset ( 1); break; //VT100
361 case TY_CTL___('O' ) : useCharset ( 0); break; //VT100 356 case TY_CTL___('O' ) : useCharset ( 0); break; //VT100
362 357
363 case TY_CTL___('P' ) : /* DLE: ignored */ break; 358 case TY_CTL___('P' ) : /* DLE: ignored */ break;
364 case TY_CTL___('Q' ) : /* DC1: XON continue */ break; //VT100 359 case TY_CTL___('Q' ) : /* DC1: XON continue */ break; //VT100
365 case TY_CTL___('R' ) : /* DC2: ignored */ break; 360 case TY_CTL___('R' ) : /* DC2: ignored */ break;
366 case TY_CTL___('S' ) : /* DC3: XOFF halt */ break; //VT100 361 case TY_CTL___('S' ) : /* DC3: XOFF halt */ break; //VT100
367 case TY_CTL___('T' ) : /* DC4: ignored */ break; 362 case TY_CTL___('T' ) : /* DC4: ignored */ break;
368 case TY_CTL___('U' ) : /* NAK: ignored */ break; 363 case TY_CTL___('U' ) : /* NAK: ignored */ break;
369 case TY_CTL___('V' ) : /* SYN: ignored */ break; 364 case TY_CTL___('V' ) : /* SYN: ignored */ break;
370 case TY_CTL___('W' ) : /* ETB: ignored */ break; 365 case TY_CTL___('W' ) : /* ETB: ignored */ break;
371 case TY_CTL___('X' ) : scr->ShowCharacter ( 0x2592); break; //VT100 366 case TY_CTL___('X' ) : scr->ShowCharacter ( 0x2592); break; //VT100
372 case TY_CTL___('Y' ) : /* EM : ignored */ break; 367 case TY_CTL___('Y' ) : /* EM : ignored */ break;
373 case TY_CTL___('Z' ) : scr->ShowCharacter ( 0x2592); break; //VT100 368 case TY_CTL___('Z' ) : scr->ShowCharacter ( 0x2592); break; //VT100
374 case TY_CTL___('[' ) : /* ESC: cannot be seen here. */ break; 369 case TY_CTL___('[' ) : /* ESC: cannot be seen here. */ break;
375 case TY_CTL___('\\' ) : /* FS : ignored */ break; 370 case TY_CTL___('\\' ) : /* FS : ignored */ break;
376 case TY_CTL___(']' ) : /* GS : ignored */ break; 371 case TY_CTL___(']' ) : /* GS : ignored */ break;
377 case TY_CTL___('^' ) : /* RS : ignored */ break; 372 case TY_CTL___('^' ) : /* RS : ignored */ break;
378 case TY_CTL___('_' ) : /* US : ignored */ break; 373 case TY_CTL___('_' ) : /* US : ignored */ break;
379 374
380 case TY_ESC___('D' ) : scr->index ( ); break; //VT100 375 case TY_ESC___('D' ) : scr->index ( ); break; //VT100
381 case TY_ESC___('E' ) : scr->NextLine ( ); break; //VT100 376 case TY_ESC___('E' ) : scr->NextLine ( ); break; //VT100
382 case TY_ESC___('H' ) : scr->changeTabStop (TRUE ); break; //VT100 377 case TY_ESC___('H' ) : scr->changeTabStop (TRUE ); break; //VT100
383 case TY_ESC___('M' ) : scr->reverseIndex ( ); break; //VT100 378 case TY_ESC___('M' ) : scr->reverseIndex ( ); break; //VT100
384 case TY_ESC___('Z' ) : reportTerminalType ( ); break; 379 case TY_ESC___('Z' ) : reportTerminalType ( ); break;
385 case TY_ESC___('c' ) : reset ( ); break; 380 case TY_ESC___('c' ) : reset ( ); break;
386 381
387 case TY_ESC___('n' ) : useCharset ( 2); break; 382 case TY_ESC___('n' ) : useCharset ( 2); break;
388 case TY_ESC___('o' ) : useCharset ( 3); break; 383 case TY_ESC___('o' ) : useCharset ( 3); break;
389 case TY_ESC___('7' ) : saveCursor ( ); break; 384 case TY_ESC___('7' ) : saveCursor ( ); break;
390 case TY_ESC___('8' ) : restoreCursor ( ); break; 385 case TY_ESC___('8' ) : restoreCursor ( ); break;
391 386
392 case TY_ESC___('=' ) : setMode (MODE_AppKeyPad); break; 387 case TY_ESC___('=' ) : setMode (MODE_AppKeyPad); break;
393 case TY_ESC___('>' ) : resetMode (MODE_AppKeyPad); break; 388 case TY_ESC___('>' ) : resetMode (MODE_AppKeyPad); break;
394 case TY_ESC___('<' ) : setMode (MODE_Ansi ); break; //VT100 389 case TY_ESC___('<' ) : setMode (MODE_Ansi ); break; //VT100
395 390
396 case TY_ESC_CS('(', '0') : setCharset (0, '0'); break; //VT100 391 case TY_ESC_CS('(', '0') : setCharset (0, '0'); break; //VT100
397 case TY_ESC_CS('(', 'A') : setCharset (0, 'A'); break; //VT100 392 case TY_ESC_CS('(', 'A') : setCharset (0, 'A'); break; //VT100
398 case TY_ESC_CS('(', 'B') : setCharset (0, 'B'); break; //VT100 393 case TY_ESC_CS('(', 'B') : setCharset (0, 'B'); break; //VT100
399 394
400 case TY_ESC_CS(')', '0') : setCharset (1, '0'); break; //VT100 395 case TY_ESC_CS(')', '0') : setCharset (1, '0'); break; //VT100
401 case TY_ESC_CS(')', 'A') : setCharset (1, 'A'); break; //VT100 396 case TY_ESC_CS(')', 'A') : setCharset (1, 'A'); break; //VT100
402 case TY_ESC_CS(')', 'B') : setCharset (1, 'B'); break; //VT100 397 case TY_ESC_CS(')', 'B') : setCharset (1, 'B'); break; //VT100
403 398
404 case TY_ESC_CS('*', '0') : setCharset (2, '0'); break; //VT100 399 case TY_ESC_CS('*', '0') : setCharset (2, '0'); break; //VT100
405 case TY_ESC_CS('*', 'A') : setCharset (2, 'A'); break; //VT100 400 case TY_ESC_CS('*', 'A') : setCharset (2, 'A'); break; //VT100
406 case TY_ESC_CS('*', 'B') : setCharset (2, 'B'); break; //VT100 401 case TY_ESC_CS('*', 'B') : setCharset (2, 'B'); break; //VT100
407 402
408 case TY_ESC_CS('+', '0') : setCharset (3, '0'); break; //VT100 403 case TY_ESC_CS('+', '0') : setCharset (3, '0'); break; //VT100
409 case TY_ESC_CS('+', 'A') : setCharset (3, 'A'); break; //VT100 404 case TY_ESC_CS('+', 'A') : setCharset (3, 'A'); break; //VT100
410 case TY_ESC_CS('+', 'B') : setCharset (3, 'B'); break; //VT100 405 case TY_ESC_CS('+', 'B') : setCharset (3, 'B'); break; //VT100
411 406
412 case TY_ESC_CS('%', 'G') : setCodec (1 ); break; //LINUX 407 case TY_ESC_CS('%', 'G') : setCodec (1 ); break; //LINUX
413 case TY_ESC_CS('%', '@') : setCodec (0 ); break; //LINUX 408 case TY_ESC_CS('%', '@') : setCodec (0 ); break; //LINUX
414 409
415 case TY_ESC_DE('3' ) : /* IGNORED: double high, top half */ break; 410 case TY_ESC_DE('3' ) : /* IGNORED: double high, top half */ break;
416 case TY_ESC_DE('4' ) : /* IGNORED: double high, bottom half */ break; 411 case TY_ESC_DE('4' ) : /* IGNORED: double high, bottom half */ break;
417 case TY_ESC_DE('5' ) : /* IGNORED: single width, single high*/ break; 412 case TY_ESC_DE('5' ) : /* IGNORED: single width, single high*/ break;
418 case TY_ESC_DE('6' ) : /* IGNORED: double width, single high*/ break; 413 case TY_ESC_DE('6' ) : /* IGNORED: double width, single high*/ break;
419 case TY_ESC_DE('8' ) : scr->helpAlign ( ); break; 414 case TY_ESC_DE('8' ) : scr->helpAlign ( ); break;
420 415
421 case TY_CSI_PS('K', 0) : scr->clearToEndOfLine ( ); break; 416 case TY_CSI_PS('K', 0) : scr->clearToEndOfLine ( ); break;
422 case TY_CSI_PS('K', 1) : scr->clearToBeginOfLine ( ); break; 417 case TY_CSI_PS('K', 1) : scr->clearToBeginOfLine ( ); break;
423 case TY_CSI_PS('K', 2) : scr->clearEntireLine ( ); break; 418 case TY_CSI_PS('K', 2) : scr->clearEntireLine ( ); break;
424 case TY_CSI_PS('J', 0) : scr->clearToEndOfScreen ( ); break; 419 case TY_CSI_PS('J', 0) : scr->clearToEndOfScreen ( ); break;
425 case TY_CSI_PS('J', 1) : scr->clearToBeginOfScreen ( ); break; 420 case TY_CSI_PS('J', 1) : scr->clearToBeginOfScreen ( ); break;
426 case TY_CSI_PS('J', 2) : scr->clearEntireScreen ( ); break; 421 case TY_CSI_PS('J', 2) : scr->clearEntireScreen ( ); break;
427 case TY_CSI_PS('g', 0) : scr->changeTabStop (FALSE ); break; //VT100 422 case TY_CSI_PS('g', 0) : scr->changeTabStop (FALSE ); break; //VT100
428 case TY_CSI_PS('g', 3) : scr->clearTabStops ( ); break; //VT100 423 case TY_CSI_PS('g', 3) : scr->clearTabStops ( ); break; //VT100
429 case TY_CSI_PS('h', 4) : scr-> setMode (MODE_Insert ); break; 424 case TY_CSI_PS('h', 4) : scr-> setMode (MODE_Insert ); break;
430 case TY_CSI_PS('h', 20) : setMode (MODE_NewLine ); break; 425 case TY_CSI_PS('h', 20) : setMode (MODE_NewLine ); break;
431 case TY_CSI_PS('i', 0) : /* IGNORE: attached printer */ break; //VT100 426 case TY_CSI_PS('i', 0) : /* IGNORE: attached printer */ break; //VT100
432 case TY_CSI_PS('l', 4) : scr-> resetMode (MODE_Insert ); break; 427 case TY_CSI_PS('l', 4) : scr-> resetMode (MODE_Insert ); break;
433 case TY_CSI_PS('l', 20) : resetMode (MODE_NewLine ); break; 428 case TY_CSI_PS('l', 20) : resetMode (MODE_NewLine ); break;
434 429
435 case TY_CSI_PS('m', 0) : scr->setDefaultRendition ( ); break; 430 case TY_CSI_PS('m', 0) : scr->setDefaultRendition ( ); break;
436 case TY_CSI_PS('m', 1) : scr-> setRendition (RE_BOLD ); break; //VT100 431 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 432 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 433 case TY_CSI_PS('m', 5) : scr-> setRendition (RE_BLINK ); break; //VT100
439 case TY_CSI_PS('m', 7) : scr-> setRendition (RE_REVERSE ); break; 434 case TY_CSI_PS('m', 7) : scr-> setRendition (RE_REVERSE ); break;
440 case TY_CSI_PS('m', 10) : /* IGNORED: mapping related */ break; //LINUX 435 case TY_CSI_PS('m', 10) : /* IGNORED: mapping related */ break; //LINUX
441 case TY_CSI_PS('m', 11) : /* IGNORED: mapping related */ break; //LINUX 436 case TY_CSI_PS('m', 11) : /* IGNORED: mapping related */ break; //LINUX
442 case TY_CSI_PS('m', 12) : /* IGNORED: mapping related */ break; //LINUX 437 case TY_CSI_PS('m', 12) : /* IGNORED: mapping related */ break; //LINUX
443 case TY_CSI_PS('m', 22) : scr->resetRendition (RE_BOLD ); break; 438 case TY_CSI_PS('m', 22) : scr->resetRendition (RE_BOLD ); break;
444 case TY_CSI_PS('m', 24) : scr->resetRendition (RE_UNDERLINE); break; 439 case TY_CSI_PS('m', 24) : scr->resetRendition (RE_UNDERLINE); break;
445 case TY_CSI_PS('m', 25) : scr->resetRendition (RE_BLINK ); break; 440 case TY_CSI_PS('m', 25) : scr->resetRendition (RE_BLINK ); break;
446 case TY_CSI_PS('m', 27) : scr->resetRendition (RE_REVERSE ); break; 441 case TY_CSI_PS('m', 27) : scr->resetRendition (RE_REVERSE ); break;
447 442
448 case TY_CSI_PS('m', 30) : scr->setForeColor ( 0); break; 443 case TY_CSI_PS('m', 30) : scr->setForeColor ( 0); break;
449 case TY_CSI_PS('m', 31) : scr->setForeColor ( 1); break; 444 case TY_CSI_PS('m', 31) : scr->setForeColor ( 1); break;
450 case TY_CSI_PS('m', 32) : scr->setForeColor ( 2); break; 445 case TY_CSI_PS('m', 32) : scr->setForeColor ( 2); break;
451 case TY_CSI_PS('m', 33) : scr->setForeColor ( 3); break; 446 case TY_CSI_PS('m', 33) : scr->setForeColor ( 3); break;
452 case TY_CSI_PS('m', 34) : scr->setForeColor ( 4); break; 447 case TY_CSI_PS('m', 34) : scr->setForeColor ( 4); break;
453 case TY_CSI_PS('m', 35) : scr->setForeColor ( 5); break; 448 case TY_CSI_PS('m', 35) : scr->setForeColor ( 5); break;
454 case TY_CSI_PS('m', 36) : scr->setForeColor ( 6); break; 449 case TY_CSI_PS('m', 36) : scr->setForeColor ( 6); break;
455 case TY_CSI_PS('m', 37) : scr->setForeColor ( 7); break; 450 case TY_CSI_PS('m', 37) : scr->setForeColor ( 7); break;
456 case TY_CSI_PS('m', 39) : scr->setForeColorToDefault( ); break; 451 case TY_CSI_PS('m', 39) : scr->setForeColorToDefault( ); break;
457 452
458 case TY_CSI_PS('m', 40) : scr->setBackColor ( 0); break; 453 case TY_CSI_PS('m', 40) : scr->setBackColor ( 0); break;
459 case TY_CSI_PS('m', 41) : scr->setBackColor ( 1); break; 454 case TY_CSI_PS('m', 41) : scr->setBackColor ( 1); break;
460 case TY_CSI_PS('m', 42) : scr->setBackColor ( 2); break; 455 case TY_CSI_PS('m', 42) : scr->setBackColor ( 2); break;
461 case TY_CSI_PS('m', 43) : scr->setBackColor ( 3); break; 456 case TY_CSI_PS('m', 43) : scr->setBackColor ( 3); break;
462 case TY_CSI_PS('m', 44) : scr->setBackColor ( 4); break; 457 case TY_CSI_PS('m', 44) : scr->setBackColor ( 4); break;
463 case TY_CSI_PS('m', 45) : scr->setBackColor ( 5); break; 458 case TY_CSI_PS('m', 45) : scr->setBackColor ( 5); break;
464 case TY_CSI_PS('m', 46) : scr->setBackColor ( 6); break; 459 case TY_CSI_PS('m', 46) : scr->setBackColor ( 6); break;
465 case TY_CSI_PS('m', 47) : scr->setBackColor ( 7); break; 460 case TY_CSI_PS('m', 47) : scr->setBackColor ( 7); break;
466 case TY_CSI_PS('m', 49) : scr->setBackColorToDefault( ); break; 461 case TY_CSI_PS('m', 49) : scr->setBackColorToDefault( ); break;
467 462
468 case TY_CSI_PS('m', 90) : scr->setForeColor ( 8); break; 463 case TY_CSI_PS('m', 90) : scr->setForeColor ( 8); break;
469 case TY_CSI_PS('m', 91) : scr->setForeColor ( 9); break; 464 case TY_CSI_PS('m', 91) : scr->setForeColor ( 9); break;
470 case TY_CSI_PS('m', 92) : scr->setForeColor ( 10); break; 465 case TY_CSI_PS('m', 92) : scr->setForeColor ( 10); break;
471 case TY_CSI_PS('m', 93) : scr->setForeColor ( 11); break; 466 case TY_CSI_PS('m', 93) : scr->setForeColor ( 11); break;
472 case TY_CSI_PS('m', 94) : scr->setForeColor ( 12); break; 467 case TY_CSI_PS('m', 94) : scr->setForeColor ( 12); break;
473 case TY_CSI_PS('m', 95) : scr->setForeColor ( 13); break; 468 case TY_CSI_PS('m', 95) : scr->setForeColor ( 13); break;
474 case TY_CSI_PS('m', 96) : scr->setForeColor ( 14); break; 469 case TY_CSI_PS('m', 96) : scr->setForeColor ( 14); break;
475 case TY_CSI_PS('m', 97) : scr->setForeColor ( 15); break; 470 case TY_CSI_PS('m', 97) : scr->setForeColor ( 15); break;
476 471
477 case TY_CSI_PS('m', 100) : scr->setBackColor ( 8); break; 472 case TY_CSI_PS('m', 100) : scr->setBackColor ( 8); break;
478 case TY_CSI_PS('m', 101) : scr->setBackColor ( 9); break; 473 case TY_CSI_PS('m', 101) : scr->setBackColor ( 9); break;
479 case TY_CSI_PS('m', 102) : scr->setBackColor ( 10); break; 474 case TY_CSI_PS('m', 102) : scr->setBackColor ( 10); break;
480 case TY_CSI_PS('m', 103) : scr->setBackColor ( 11); break; 475 case TY_CSI_PS('m', 103) : scr->setBackColor ( 11); break;
481 case TY_CSI_PS('m', 104) : scr->setBackColor ( 12); break; 476 case TY_CSI_PS('m', 104) : scr->setBackColor ( 12); break;
482 case TY_CSI_PS('m', 105) : scr->setBackColor ( 13); break; 477 case TY_CSI_PS('m', 105) : scr->setBackColor ( 13); break;
483 case TY_CSI_PS('m', 106) : scr->setBackColor ( 14); break; 478 case TY_CSI_PS('m', 106) : scr->setBackColor ( 14); break;
484 case TY_CSI_PS('m', 107) : scr->setBackColor ( 15); break; 479 case TY_CSI_PS('m', 107) : scr->setBackColor ( 15); break;
485 480
486 case TY_CSI_PS('n', 5) : reportStatus ( ); break; 481 case TY_CSI_PS('n', 5) : reportStatus ( ); break;
487 case TY_CSI_PS('n', 6) : reportCursorPosition ( ); break; 482 case TY_CSI_PS('n', 6) : reportCursorPosition ( ); break;
488 case TY_CSI_PS('q', 0) : /* IGNORED: LEDs off */ break; //VT100 483 case TY_CSI_PS('q', 0) : /* IGNORED: LEDs off */ break; //VT100
489 case TY_CSI_PS('q', 1) : /* IGNORED: LED1 on */ break; //VT100 484 case TY_CSI_PS('q', 1) : /* IGNORED: LED1 on */ break; //VT100
490 case TY_CSI_PS('q', 2) : /* IGNORED: LED2 on */ break; //VT100 485 case TY_CSI_PS('q', 2) : /* IGNORED: LED2 on */ break; //VT100
491 case TY_CSI_PS('q', 3) : /* IGNORED: LED3 on */ break; //VT100 486 case TY_CSI_PS('q', 3) : /* IGNORED: LED3 on */ break; //VT100
492 case TY_CSI_PS('q', 4) : /* IGNORED: LED4 on */ break; //VT100 487 case TY_CSI_PS('q', 4) : /* IGNORED: LED4 on */ break; //VT100
493 case TY_CSI_PS('x', 0) : reportTerminalParms ( 2); break; //VT100 488 case TY_CSI_PS('x', 0) : reportTerminalParms ( 2); break; //VT100
494 case TY_CSI_PS('x', 1) : reportTerminalParms ( 3); break; //VT100 489 case TY_CSI_PS('x', 1) : reportTerminalParms ( 3); break; //VT100
495 490
496 case TY_CSI_PN('@' ) : scr->insertChars (p ); break; 491 case TY_CSI_PN('@' ) : scr->insertChars (p ); break;
497 case TY_CSI_PN('A' ) : scr->cursorUp (p ); break; //VT100 492 case TY_CSI_PN('A' ) : scr->cursorUp (p ); break; //VT100
498 case TY_CSI_PN('B' ) : scr->cursorDown (p ); break; //VT100 493 case TY_CSI_PN('B' ) : scr->cursorDown (p ); break; //VT100
499 case TY_CSI_PN('C' ) : scr->cursorRight (p ); break; //VT100 494 case TY_CSI_PN('C' ) : scr->cursorRight (p ); break; //VT100
500 case TY_CSI_PN('D' ) : scr->cursorLeft (p ); break; //VT100 495 case TY_CSI_PN('D' ) : scr->cursorLeft (p ); break; //VT100
501 case TY_CSI_PN('G' ) : scr->setCursorX (p ); break; //LINUX 496 case TY_CSI_PN('G' ) : scr->setCursorX (p ); break; //LINUX
502 case TY_CSI_PN('H' ) : scr->setCursorYX (p, q); break; //VT100 497 case TY_CSI_PN('H' ) : scr->setCursorYX (p, q); break; //VT100
503 case TY_CSI_PN('L' ) : scr->insertLines (p ); break; 498 case TY_CSI_PN('L' ) : scr->insertLines (p ); break;
504 case TY_CSI_PN('M' ) : scr->deleteLines (p ); break; 499 case TY_CSI_PN('M' ) : scr->deleteLines (p ); break;
505 case TY_CSI_PN('P' ) : scr->deleteChars (p ); break; 500 case TY_CSI_PN('P' ) : scr->deleteChars (p ); break;
506 case TY_CSI_PN('X' ) : scr->eraseChars (p ); break; 501 case TY_CSI_PN('X' ) : scr->eraseChars (p ); break;
507 case TY_CSI_PN('c' ) : reportTerminalType ( ); break; //VT100 502 case TY_CSI_PN('c' ) : reportTerminalType ( ); break; //VT100
508 case TY_CSI_PN('d' ) : scr->setCursorY (p ); break; //LINUX 503 case TY_CSI_PN('d' ) : scr->setCursorY (p ); break; //LINUX
509 case TY_CSI_PN('f' ) : scr->setCursorYX (p, q); break; //VT100 504 case TY_CSI_PN('f' ) : scr->setCursorYX (p, q); break; //VT100
510 case TY_CSI_PN('r' ) : scr->setMargins (p, q); break; //VT100 505 case TY_CSI_PN('r' ) : scr->setMargins (p, q); break; //VT100
511 case TY_CSI_PN('y' ) : /* IGNORED: Confidence test */ break; //VT100 506 case TY_CSI_PN('y' ) : /* IGNORED: Confidence test */ break; //VT100
512 507
513 case TY_CSI_PR('h', 1) : setMode (MODE_AppCuKeys); break; //VT100 508 case TY_CSI_PR('h', 1) : setMode (MODE_AppCuKeys); break; //VT100
514 case TY_CSI_PR('l', 1) : resetMode (MODE_AppCuKeys); break; //VT100 509 case TY_CSI_PR('l', 1) : resetMode (MODE_AppCuKeys); break; //VT100
515 case TY_CSI_PR('s', 1) : saveMode (MODE_AppCuKeys); break; //FIXME 510 case TY_CSI_PR('s', 1) : saveMode (MODE_AppCuKeys); break; //FIXME
516 case TY_CSI_PR('r', 1) : restoreMode (MODE_AppCuKeys); break; //FIXME 511 case TY_CSI_PR('r', 1) : restoreMode (MODE_AppCuKeys); break; //FIXME
517 512
518 case TY_CSI_PR('l', 2) : resetMode (MODE_Ansi ); break; //VT100 513 case TY_CSI_PR('l', 2) : resetMode (MODE_Ansi ); break; //VT100
519 514
520 case TY_CSI_PR('h', 3) : setColumns ( 132); break; //VT100 515 case TY_CSI_PR('h', 3) : setColumns ( 132); break; //VT100
521 case TY_CSI_PR('l', 3) : setColumns ( 80); break; //VT100 516 case TY_CSI_PR('l', 3) : setColumns ( 80); break; //VT100
522 517
523 case TY_CSI_PR('h', 4) : /* IGNORED: soft scrolling */ break; //VT100 518 case TY_CSI_PR('h', 4) : /* IGNORED: soft scrolling */ break; //VT100
524 case TY_CSI_PR('l', 4) : /* IGNORED: soft scrolling */ break; //VT100 519 case TY_CSI_PR('l', 4) : /* IGNORED: soft scrolling */ break; //VT100
525 520
526 case TY_CSI_PR('h', 5) : scr-> setMode (MODE_Screen ); break; //VT100 521 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 522 case TY_CSI_PR('l', 5) : scr-> resetMode (MODE_Screen ); break; //VT100
528 523
529 case TY_CSI_PR('h', 6) : scr-> setMode (MODE_Origin ); break; //VT100 524 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 525 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 526 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 527 case TY_CSI_PR('r', 6) : scr->restoreMode (MODE_Origin ); break; //FIXME
533 528
534 case TY_CSI_PR('h', 7) : scr-> setMode (MODE_Wrap ); break; //VT100 529 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 530 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 531 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 532 case TY_CSI_PR('r', 7) : scr->restoreMode (MODE_Wrap ); break; //FIXME
538 533
539 case TY_CSI_PR('h', 8) : /* IGNORED: autorepeat on */ break; //VT100 534 case TY_CSI_PR('h', 8) : /* IGNORED: autorepeat on */ break; //VT100
540 case TY_CSI_PR('l', 8) : /* IGNORED: autorepeat off */ break; //VT100 535 case TY_CSI_PR('l', 8) : /* IGNORED: autorepeat off */ break; //VT100
541 536
542 case TY_CSI_PR('h', 9) : /* IGNORED: interlace */ break; //VT100 537 case TY_CSI_PR('h', 9) : /* IGNORED: interlace */ break; //VT100
543 case TY_CSI_PR('l', 9) : /* IGNORED: interlace */ break; //VT100 538 case TY_CSI_PR('l', 9) : /* IGNORED: interlace */ break; //VT100
544 539
545 case TY_CSI_PR('h', 25) : setMode (MODE_Cursor ); break; //VT100 540 case TY_CSI_PR('h', 25) : setMode (MODE_Cursor ); break; //VT100
546 case TY_CSI_PR('l', 25) : resetMode (MODE_Cursor ); break; //VT100 541 case TY_CSI_PR('l', 25) : resetMode (MODE_Cursor ); break; //VT100
547 542
548 case TY_CSI_PR('h', 41) : /* IGNORED: obsolete more(1) fix */ break; //XTERM 543 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 544 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 545 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 546 case TY_CSI_PR('r', 41) : /* IGNORED: obsolete more(1) fix */ break; //XTERM
552 547
553 case TY_CSI_PR('h', 47) : setMode (MODE_AppScreen); break; //VT100 548 case TY_CSI_PR('h', 47) : setMode (MODE_AppScreen); break; //VT100
554 case TY_CSI_PR('l', 47) : resetMode (MODE_AppScreen); break; //VT100 549 case TY_CSI_PR('l', 47) : resetMode (MODE_AppScreen); break; //VT100
555 550
556 case TY_CSI_PR('h', 1000) : setMode (MODE_Mouse1000); break; //XTERM 551 case TY_CSI_PR('h', 1000) : setMode (MODE_Mouse1000); break; //XTERM
557 case TY_CSI_PR('l', 1000) : resetMode (MODE_Mouse1000); break; //XTERM 552 case TY_CSI_PR('l', 1000) : resetMode (MODE_Mouse1000); break; //XTERM
558 case TY_CSI_PR('s', 1000) : saveMode (MODE_Mouse1000); break; //XTERM 553 case TY_CSI_PR('s', 1000) : saveMode (MODE_Mouse1000); break; //XTERM
559 case TY_CSI_PR('r', 1000) : restoreMode (MODE_Mouse1000); break; //XTERM 554 case TY_CSI_PR('r', 1000) : restoreMode (MODE_Mouse1000); break; //XTERM
560 555
561 case TY_CSI_PR('h', 1001) : /* IGNORED: hilite mouse tracking */ break; //XTERM 556 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 557 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 558 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 559 case TY_CSI_PR('r', 1001) : /* IGNORED: hilite mouse tracking */ break; //XTERM
565 560
566 case TY_CSI_PR('h', 1047) : setMode (MODE_AppScreen); break; //XTERM 561 case TY_CSI_PR('h', 1047) : setMode (MODE_AppScreen); break; //XTERM
567 case TY_CSI_PR('l', 1047) : resetMode (MODE_AppScreen); break; //XTERM 562 case TY_CSI_PR('l', 1047) : resetMode (MODE_AppScreen); break; //XTERM
568 563
569 //FIXME: Unitoken: save translations 564 //FIXME: Unitoken: save translations
570 case TY_CSI_PR('h', 1048) : saveCursor ( ); break; //XTERM 565 case TY_CSI_PR('h', 1048) : saveCursor ( ); break; //XTERM
571 case TY_CSI_PR('l', 1048) : restoreCursor ( ); break; //XTERM 566 case TY_CSI_PR('l', 1048) : restoreCursor ( ); break; //XTERM
572 567
573 //FIXME: every once new sequences like this pop up in xterm. 568 //FIXME: every once new sequences like this pop up in xterm.
574 // Here's a guess of what they could mean. 569 // Here's a guess of what they could mean.
575 case TY_CSI_PR('h', 1049) : setMode (MODE_AppScreen); break; //XTERM 570 case TY_CSI_PR('h', 1049) : setMode (MODE_AppScreen); break; //XTERM
576 case TY_CSI_PR('l', 1049) : resetMode (MODE_AppScreen); break; //XTERM 571 case TY_CSI_PR('l', 1049) : resetMode (MODE_AppScreen); break; //XTERM
577 572
578 //FIXME: when changing between vt52 and ansi mode evtl do some resetting. 573 //FIXME: when changing between vt52 and ansi mode evtl do some resetting.
579 case TY_VT52__('A' ) : scr->cursorUp ( 1); break; //VT52 574 case TY_VT52__('A' ) : scr->cursorUp ( 1); break; //VT52
580 case TY_VT52__('B' ) : scr->cursorDown ( 1); break; //VT52 575 case TY_VT52__('B' ) : scr->cursorDown ( 1); break; //VT52
581 case TY_VT52__('C' ) : scr->cursorRight ( 1); break; //VT52 576 case TY_VT52__('C' ) : scr->cursorRight ( 1); break; //VT52
582 case TY_VT52__('D' ) : scr->cursorLeft ( 1); break; //VT52 577 case TY_VT52__('D' ) : scr->cursorLeft ( 1); break; //VT52
583 578
584 case TY_VT52__('F' ) : setAndUseCharset (0, '0'); break; //VT52 579 case TY_VT52__('F' ) : setAndUseCharset (0, '0'); break; //VT52
585 case TY_VT52__('G' ) : setAndUseCharset (0, 'B'); break; //VT52 580 case TY_VT52__('G' ) : setAndUseCharset (0, 'B'); break; //VT52
586 581
587 case TY_VT52__('H' ) : scr->setCursorYX (1,1 ); break; //VT52 582 case TY_VT52__('H' ) : scr->setCursorYX (1,1 ); break; //VT52
588 case TY_VT52__('I' ) : scr->reverseIndex ( ); break; //VT52 583 case TY_VT52__('I' ) : scr->reverseIndex ( ); break; //VT52
589 case TY_VT52__('J' ) : scr->clearToEndOfScreen ( ); break; //VT52 584 case TY_VT52__('J' ) : scr->clearToEndOfScreen ( ); break; //VT52
590 case TY_VT52__('K' ) : scr->clearToEndOfLine ( ); break; //VT52 585 case TY_VT52__('K' ) : scr->clearToEndOfLine ( ); break; //VT52
591 case TY_VT52__('Y' ) : scr->setCursorYX (p-31,q-31 ); break; //VT52 586 case TY_VT52__('Y' ) : scr->setCursorYX (p-31,q-31 ); break; //VT52
592 case TY_VT52__('Z' ) : reportTerminalType ( ); break; //VT52 587 case TY_VT52__('Z' ) : reportTerminalType ( ); break; //VT52
593 case TY_VT52__('<' ) : setMode (MODE_Ansi ); break; //VT52 588 case TY_VT52__('<' ) : setMode (MODE_Ansi ); break; //VT52
594 case TY_VT52__('=' ) : setMode (MODE_AppKeyPad); break; //VT52 589 case TY_VT52__('=' ) : setMode (MODE_AppKeyPad); break; //VT52
595 case TY_VT52__('>' ) : resetMode (MODE_AppKeyPad); break; //VT52 590 case TY_VT52__('>' ) : resetMode (MODE_AppKeyPad); break; //VT52
596 591
597 default : ReportErrorToken(); break; 592 default : ReportErrorToken(); break;
598 }; 593 };
599} 594}
600 595
601/* ------------------------------------------------------------------------- */ 596/* ------------------------------------------------------------------------- */
602/* */ 597/* */
603/* Terminal to Host protocol */ 598/* Terminal to Host protocol */
604/* */ 599/* */
605/* ------------------------------------------------------------------------- */ 600/* ------------------------------------------------------------------------- */
606 601
607/* 602/*
608 Outgoing bytes originate from several sources: 603 Outgoing bytes originate from several sources:
609 604
610 - Replies to Enquieries. 605 - Replies to Enquieries.
611 - Mouse Events 606 - Mouse Events
612 - Keyboard Events 607 - Keyboard Events
613*/ 608*/
614 609
615/*! 610/*!
616*/ 611*/
617 612
618void TEmuVt102::sendString(const char* s) 613void TEmuVt102::sendString(const char* s)
619{ 614{
620 emit sndBlock(s,strlen(s)); 615 emit sndBlock(s,strlen(s));
621} 616}
622 617
623// Replies ----------------------------------------------------------------- -- 618// Replies ----------------------------------------------------------------- --
624 619
625// This section copes with replies send as response to an enquiery control code. 620// This section copes with replies send as response to an enquiery control code.
626 621
627/*! 622/*!
628*/ 623*/
629 624
630void TEmuVt102::reportCursorPosition() 625void TEmuVt102::reportCursorPosition()
631{ char tmp[20]; 626{ char tmp[20];
632 sprintf(tmp,"\033[%d;%dR",scr->getCursorY()+1,scr->getCursorX()+1); 627 sprintf(tmp,"\033[%d;%dR",scr->getCursorY()+1,scr->getCursorX()+1);
633 sendString(tmp); 628 sendString(tmp);
634} 629}
635 630
636/* 631/*
637 What follows here is rather obsolete and faked stuff. 632 What follows here is rather obsolete and faked stuff.
638 The correspondent enquieries are neverthenless issued. 633 The correspondent enquieries are neverthenless issued.
639*/ 634*/
640 635
641/*! 636/*!
642*/ 637*/
643 638
644void TEmuVt102::reportTerminalType() 639void TEmuVt102::reportTerminalType()
645{ 640{
646//FIXME: should change? 641//FIXME: should change?
647 if (getMode(MODE_Ansi)) 642 if (getMode(MODE_Ansi))
648// sendString("\033[?1;2c"); // I'm a VT100 with AP0 //FIXME: send only in response to ^[[0c 643// sendString("\033[?1;2c"); // I'm a VT100 with AP0 //FIXME: send only in response to ^[[0c
649 sendString("\033[>0;115;0c"); // I'm a VT220 //FIXME: send only in response to ^[[>c 644 sendString("\033[>0;115;0c"); // I'm a VT220 //FIXME: send only in response to ^[[>c
650 else 645 else
651 sendString("\033/Z"); // I'm a VT52 646 sendString("\033/Z"); // I'm a VT52
652} 647}
653 648
654void TEmuVt102::reportTerminalParms(int p) 649void TEmuVt102::reportTerminalParms(int p)
655// DECREPTPARM 650// DECREPTPARM
656{ char tmp[100]; 651{ char tmp[100];
657 sprintf(tmp,"\033[%d;1;1;112;112;1;0x",p); // not really true. 652 sprintf(tmp,"\033[%d;1;1;112;112;1;0x",p); // not really true.
658 sendString(tmp); 653 sendString(tmp);
659} 654}
660 655
661/*! 656/*!
662*/ 657*/
663 658
664void TEmuVt102::reportStatus() 659void TEmuVt102::reportStatus()
665{ 660{
666 sendString("\033[0n"); //VT100. Device status report. 0 = Ready. 661 sendString("\033[0n"); //VT100. Device status report. 0 = Ready.
667} 662}
668 663
669/*! 664/*!
670*/ 665*/
671 666
672#define ANSWER_BACK "" // This is really obsolete VT100 stuff. 667#define ANSWER_BACK "" // This is really obsolete VT100 stuff.
673 668
674void TEmuVt102::reportAnswerBack() 669void TEmuVt102::reportAnswerBack()
675{ 670{
676 sendString(ANSWER_BACK); 671 sendString(ANSWER_BACK);
677} 672}
678 673
679// Mouse Handling ---------------------------------------------------------- -- 674// Mouse Handling ---------------------------------------------------------- --
680 675
681/*! 676/*!
682 Mouse clicks are possibly reported to the client 677 Mouse clicks are possibly reported to the client
683 application if it has issued interest in them. 678 application if it has issued interest in them.
684 They are normally consumed by the widget for copy 679 They are normally consumed by the widget for copy
685 and paste, but may be propagated from the widget 680 and paste, but may be propagated from the widget
686 when gui->setMouseMarks is set via setMode(MODE_Mouse1000). 681 when gui->setMouseMarks is set via setMode(MODE_Mouse1000).
687 682
688 `x',`y' are 1-based. 683 `x',`y' are 1-based.
689 `ev' (event) indicates the button pressed (0-2) 684 `ev' (event) indicates the button pressed (0-2)
690 or a general mouse release (3). 685 or a general mouse release (3).
691*/ 686*/
692 687
693void TEmuVt102::onMouse( int cb, int cx, int cy ) 688void TEmuVt102::onMouse( int cb, int cx, int cy )
694{ char tmp[20]; 689{ char tmp[20];
695 if (!connected) return; 690 if (!connected) return;
696 sprintf(tmp,"\033[M%c%c%c",cb+040,cx+040,cy+040); 691 sprintf(tmp,"\033[M%c%c%c",cb+040,cx+040,cy+040);
697 sendString(tmp); 692 sendString(tmp);
698} 693}
699 694
700// Keyboard Handling ------------------------------------------------------- -- 695// Keyboard Handling ------------------------------------------------------- --
701 696
702#define encodeMode(M,B) BITS(B,getMode(M)) 697#define encodeMode(M,B) BITS(B,getMode(M))
703#define encodeStat(M,B) BITS(B,((ev->state() & (M)) == (M))) 698#define encodeStat(M,B) BITS(B,((ev->state() & (M)) == (M)))
704 699
705/* 700/*
706 Keyboard event handling has been simplified somewhat by pushing 701 Keyboard event handling has been simplified somewhat by pushing
707 the complications towards a configuration file [see KeyTrans class]. 702 the complications towards a configuration file [see KeyTrans class].
708*/ 703*/
709 704
710void TEmuVt102::onKeyPress( QKeyEvent* ev ) 705void TEmuVt102::onKeyPress( QKeyEvent* ev )
711{ 706{
712 if (!connected) return; // someone else gets the keys 707 if (!connected) return; // someone else gets the keys
713 708
714//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); 709//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);
715 710
716 // revert to non-history when typing 711 // revert to non-history when typing
717 if (scr->getHistCursor() != scr->getHistLines()); 712 if (scr->getHistCursor() != scr->getHistLines());
718 scr->setHistCursor(scr->getHistLines()); 713 scr->setHistCursor(scr->getHistLines());
719 714
720 // lookup in keyboard translation table ... 715 // lookup in keyboard translation table ...
721 int cmd; const char* txt; int len; 716 int cmd; const char* txt; int len;
722 if (keytrans->findEntry(ev->key(), encodeMode(MODE_NewLine , BITS_NewLine ) + // OLD, 717 if (keytrans->findEntry(ev->key(), encodeMode(MODE_NewLine , BITS_NewLine ) + // OLD,
723 encodeMode(MODE_Ansi , BITS_Ansi ) + // OBSOLETE, 718 encodeMode(MODE_Ansi , BITS_Ansi ) + // OBSOLETE,
724 encodeMode(MODE_AppCuKeys, BITS_AppCuKeys ) + // VT100 stuff 719 encodeMode(MODE_AppCuKeys, BITS_AppCuKeys ) + // VT100 stuff
725 encodeStat(ControlButton , BITS_Control ) + 720 encodeStat(ControlButton , BITS_Control ) +
726 encodeStat(ShiftButton , BITS_Shift ) + 721 encodeStat(ShiftButton , BITS_Shift ) +
727 encodeStat(AltButton , BITS_Alt ), 722 encodeStat(AltButton , BITS_Alt ),
728 &cmd, &txt, &len )) 723 &cmd, &txt, &len ))
729//printf("cmd: %d, %s, %d\n",cmd,txt,len); 724//printf("cmd: %d, %s, %d\n",cmd,txt,len);
730 switch(cmd) // ... and execute if found. 725 switch(cmd) // ... and execute if found.
731 { 726 {
732 case CMD_emitSelection : gui->emitSelection(); return; 727 case CMD_emitSelection : gui->emitSelection(); return;
733 case CMD_scrollPageUp : gui->doScroll(-gui->Lines()/2); return; 728 case CMD_scrollPageUp : gui->doScroll(-gui->Lines()/2); return;
734 case CMD_scrollPageDown : gui->doScroll(+gui->Lines()/2); return; 729 case CMD_scrollPageDown : gui->doScroll(+gui->Lines()/2); return;
735 case CMD_scrollLineUp : gui->doScroll(-1 ); return; 730 case CMD_scrollLineUp : gui->doScroll(-1 ); return;
736 case CMD_scrollLineDown : gui->doScroll(+1 ); return; 731 case CMD_scrollLineDown : gui->doScroll(+1 ); return;
737 case CMD_send : emit sndBlock(txt,len); return; 732 case CMD_send : emit sndBlock(txt,len); return;
738 case CMD_prevSession : emit prevSession(); return; 733 case CMD_prevSession : emit prevSession(); return;
739 case CMD_nextSession : emit nextSession(); return; 734 case CMD_nextSession : emit nextSession(); return;
740 } 735 }
741 736
742 // fall back handling 737 // fall back handling
743 if (!ev->text().isEmpty()) 738 if (!ev->text().isEmpty())
744 { 739 {
745 if (ev->state() & AltButton) sendString("\033"); // ESC, this is the ALT prefix 740 if (ev->state() & AltButton) sendString("\033"); // ESC, this is the ALT prefix
746 /// very hacky 741 /// very hacky
747 if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='A')) sendString("\01"); 742 if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='A')) sendString("\01");
748 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='B')) sendString("\02"); 743 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='B')) sendString("\02");
749 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='C')) sendString("\03"); 744 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='C')) sendString("\03");
750 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='D')) sendString("\04"); 745 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='D')) sendString("\04");
751 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='E')) sendString("\05"); 746 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='E')) sendString("\05");
752 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='F')) sendString("\06"); 747 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='F')) sendString("\06");
753 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='G')) sendString("\07"); 748 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='G')) sendString("\07");
754 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='H')) sendString("\010"); 749 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='H')) sendString("\010");
755 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='I')) sendString("\011"); 750 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='I')) sendString("\011");
756 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='J')) sendString("\012"); 751 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='J')) sendString("\012");
757 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='K')) sendString("\013"); 752 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='K')) sendString("\013");
758 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='L')) sendString("\014"); 753 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='L')) sendString("\014");
759 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='M')) sendString("\015"); 754 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='M')) sendString("\015");
760 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='N')) sendString("\016"); 755 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='N')) sendString("\016");
761 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='O')) sendString("\017"); 756 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='O')) sendString("\017");
762 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='P')) sendString("\020"); 757 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='P')) sendString("\020");
763 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='Q')) sendString("\021"); 758 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='Q')) sendString("\021");
764 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='R')) sendString("\022"); 759 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='R')) sendString("\022");
765 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='S')) sendString("\023"); 760 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='S')) sendString("\023");
766 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='T')) sendString("\024"); 761 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='T')) sendString("\024");
767 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='U')) sendString("\025"); 762 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='U')) sendString("\025");
768 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='V')) sendString("\026"); 763 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='V')) sendString("\026");
769 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='W')) sendString("\027"); 764 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='W')) sendString("\027");
770 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='X')) sendString("\030"); 765 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='X')) sendString("\030");
771 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='Y')) sendString("\031"); 766 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='Y')) sendString("\031");
772 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='Z')) sendString("\032"); 767 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='Z')) sendString("\032");
773 else { 768 else {
774 QCString s = codec->fromUnicode(ev->text()); // encode for application 769 QCString s = codec->fromUnicode(ev->text()); // encode for application
775 emit sndBlock(s.data(),s.length()); // we may well have s.length() > 1 770 emit sndBlock(s.data(),s.length()); // we may well have s.length() > 1
776 } 771 }
777 return; 772 return;
778 } 773 }
779} 774}
780 775
781/* ------------------------------------------------------------------------- */ 776/* ------------------------------------------------------------------------- */
782/* */ 777/* */
783/* VT100 Charsets */ 778/* VT100 Charsets */
784/* */ 779/* */
785/* ------------------------------------------------------------------------- */ 780/* ------------------------------------------------------------------------- */
786 781
787// Character Set Conversion ------------------------------------------------ -- 782// Character Set Conversion ------------------------------------------------ --
788 783
789/* 784/*
790 The processing contains a VT100 specific code translation layer. 785 The processing contains a VT100 specific code translation layer.
791 It's still in use and mainly responsible for the line drawing graphics. 786 It's still in use and mainly responsible for the line drawing graphics.
792 787
793 These and some other glyphs are assigned to codes (0x5f-0xfe) 788 These and some other glyphs are assigned to codes (0x5f-0xfe)
794 normally occupied by the latin letters. Since this codes also 789 normally occupied by the latin letters. Since this codes also
795 appear within control sequences, the extra code conversion 790 appear within control sequences, the extra code conversion
796 does not permute with the tokenizer and is placed behind it 791 does not permute with the tokenizer and is placed behind it
797 in the pipeline. It only applies to tokens, which represent 792 in the pipeline. It only applies to tokens, which represent
798 plain characters. 793 plain characters.
799 794
800 This conversion it eventually continued in TEWidget.C, since 795 This conversion it eventually continued in TEWidget.C, since
801 it might involve VT100 enhanced fonts, which have these 796 it might involve VT100 enhanced fonts, which have these
802 particular glyphs allocated in (0x00-0x1f) in their code page. 797 particular glyphs allocated in (0x00-0x1f) in their code page.
diff --git a/noncore/apps/opie-console/TEmulation.cpp b/noncore/apps/opie-console/TEmulation.cpp
index 3b1b9e1..d0169d7 100644
--- a/noncore/apps/opie-console/TEmulation.cpp
+++ b/noncore/apps/opie-console/TEmulation.cpp
@@ -1,366 +1,363 @@
1/* -------------------------------------------------------------------------- */ 1/* -------------------------------------------------------------------------- */
2/* */ 2/* */
3/* [TEmulation.cpp] Terminal Emulation Decoder */ 3/* [TEmulation.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/*! \class TEmulation 19/*! \class TEmulation
20 20
21 \brief Mediator between TEWidget and TEScreen. 21 \brief Mediator between TEWidget and TEScreen.
22 22
23 This class is responsible to scan the escapes sequences of the terminal 23 This class is responsible to scan the escapes sequences of the terminal
24 emulation and to map it to their corresponding semantic complements. 24 emulation and to map it to their corresponding semantic complements.
25 Thus this module knows mainly about decoding escapes sequences and 25 Thus this module knows mainly about decoding escapes sequences and
26 is a stateless device w.r.t. the semantics. 26 is a stateless device w.r.t. the semantics.
27 27
28 It is also responsible to refresh the TEWidget by certain rules. 28 It is also responsible to refresh the TEWidget by certain rules.
29 29
30 \sa TEWidget \sa TEScreen 30 \sa TEWidget \sa TEScreen
31 31
32 \par A note on refreshing 32 \par A note on refreshing
33 33
34 Although the modifications to the current screen image could immediately 34 Although the modifications to the current screen image could immediately
35 be propagated via `TEWidget' to the graphical surface, we have chosen 35 be propagated via `TEWidget' to the graphical surface, we have chosen
36 another way here. 36 another way here.
37 37
38 The reason for doing so is twofold. 38 The reason for doing so is twofold.
39 39
40 First, experiments show that directly displaying the operation results 40 First, experiments show that directly displaying the operation results
41 in slowing down the overall performance of emulations. Displaying 41 in slowing down the overall performance of emulations. Displaying
42 individual characters using X11 creates a lot of overhead. 42 individual characters using X11 creates a lot of overhead.
43 43
44 Second, by using the following refreshing method, the screen operations 44 Second, by using the following refreshing method, the screen operations
45 can be completely separated from the displaying. This greatly simplifies 45 can be completely separated from the displaying. This greatly simplifies
46 the programmer's task of coding and maintaining the screen operations, 46 the programmer's task of coding and maintaining the screen operations,
47 since one need not worry about differential modifications on the 47 since one need not worry about differential modifications on the
48 display affecting the operation of concern. 48 display affecting the operation of concern.
49 49
50 We use a refreshing algorithm here that has been adoped from rxvt/kvt. 50 We use a refreshing algorithm here that has been adoped from rxvt/kvt.
51 51
52 By this, refreshing is driven by a timer, which is (re)started whenever 52 By this, refreshing is driven by a timer, which is (re)started whenever
53 a new bunch of data to be interpreted by the emulation arives at `onRcvBlock'. 53 a new bunch of data to be interpreted by the emulation arives at `onRcvBlock'.
54 As soon as no more data arrive for `BULK_TIMEOUT' milliseconds, we trigger 54 As soon as no more data arrive for `BULK_TIMEOUT' milliseconds, we trigger
55 refresh. This rule suits both bulk display operation as done by curses as 55 refresh. This rule suits both bulk display operation as done by curses as
56 well as individual characters typed. 56 well as individual characters typed.
57 (BULK_TIMEOUT < 1000 / max characters received from keyboard per second). 57 (BULK_TIMEOUT < 1000 / max characters received from keyboard per second).
58 58
59 Additionally, we trigger refreshing by newlines comming in to make visual 59 Additionally, we trigger refreshing by newlines comming in to make visual
60 snapshots of lists as produced by `cat', `ls' and likely programs, thereby 60 snapshots of lists as produced by `cat', `ls' and likely programs, thereby
61 producing the illusion of a permanent and immediate display operation. 61 producing the illusion of a permanent and immediate display operation.
62 62
63 As a sort of catch-all needed for cases where none of the above 63 As a sort of catch-all needed for cases where none of the above
64 conditions catch, the screen refresh is also triggered by a count 64 conditions catch, the screen refresh is also triggered by a count
65 of incoming bulks (`bulk_incnt'). 65 of incoming bulks (`bulk_incnt').
66*/ 66*/
67 67
68/* FIXME 68/* FIXME
69 - evtl. the bulk operations could be made more transparent. 69 - evtl. the bulk operations could be made more transparent.
70*/ 70*/
71 71
72#include "TEmulation.h" 72#include "TEmulation.h"
73#include "TEWidget.h"
74#include "TEScreen.h"
75#include <stdio.h> 73#include <stdio.h>
76#include <stdlib.h> 74#include <stdlib.h>
77#include <unistd.h> 75#include <unistd.h>
78#include <qkeycode.h>
79 76
80 77
81/* ------------------------------------------------------------------------- */ 78/* ------------------------------------------------------------------------- */
82/* */ 79/* */
83/* TEmulation */ 80/* TEmulation */
84/* */ 81/* */
85/* ------------------------------------------------------------------------- */ 82/* ------------------------------------------------------------------------- */
86 83
87#define CNTL(c) ((c)-'@') 84#define CNTL(c) ((c)-'@')
88 85
89/*! 86/*!
90*/ 87*/
91 88
92TEmulation::TEmulation(TEWidget* gui) 89TEmulation::TEmulation(TEWidget* gui)
93: decoder((QTextDecoder*)NULL) 90: decoder((QTextDecoder*)NULL)
94{ 91{
95 this->gui = gui; 92 this->gui = gui;
96 93
97 screen[0] = new TEScreen(gui->Lines(),gui->Columns()); 94 screen[0] = new TEScreen(gui->Lines(),gui->Columns());
98 screen[1] = new TEScreen(gui->Lines(),gui->Columns()); 95 screen[1] = new TEScreen(gui->Lines(),gui->Columns());
99 scr = screen[0]; 96 scr = screen[0];
100 97
101 bulk_nlcnt = 0; // reset bulk newline counter 98 bulk_nlcnt = 0; // reset bulk newline counter
102 bulk_incnt = 0; // reset bulk counter 99 bulk_incnt = 0; // reset bulk counter
103 connected = FALSE; 100 connected = FALSE;
104 101
105 QObject::connect(&bulk_timer, SIGNAL(timeout()), this, SLOT(showBulk()) ); 102 QObject::connect(&bulk_timer, SIGNAL(timeout()), this, SLOT(showBulk()) );
106 QObject::connect(gui,SIGNAL(changedImageSizeSignal(int,int)), 103 QObject::connect(gui,SIGNAL(changedImageSizeSignal(int,int)),
107 this,SLOT(onImageSizeChange(int,int))); 104 this,SLOT(onImageSizeChange(int,int)));
108 QObject::connect(gui,SIGNAL(changedHistoryCursor(int)), 105 QObject::connect(gui,SIGNAL(changedHistoryCursor(int)),
109 this,SLOT(onHistoryCursorChange(int))); 106 this,SLOT(onHistoryCursorChange(int)));
110 QObject::connect(gui,SIGNAL(keyPressedSignal(QKeyEvent*)), 107 QObject::connect(gui,SIGNAL(keyPressedSignal(QKeyEvent*)),
111 this,SLOT(onKeyPress(QKeyEvent*))); 108 this,SLOT(onKeyPress(QKeyEvent*)));
112 QObject::connect(gui,SIGNAL(beginSelectionSignal(const int,const int)), 109 QObject::connect(gui,SIGNAL(beginSelectionSignal(const int,const int)),
113 this,SLOT(onSelectionBegin(const int,const int)) ); 110 this,SLOT(onSelectionBegin(const int,const int)) );
114 QObject::connect(gui,SIGNAL(extendSelectionSignal(const int,const int)), 111 QObject::connect(gui,SIGNAL(extendSelectionSignal(const int,const int)),
115 this,SLOT(onSelectionExtend(const int,const int)) ); 112 this,SLOT(onSelectionExtend(const int,const int)) );
116 QObject::connect(gui,SIGNAL(endSelectionSignal(const BOOL)), 113 QObject::connect(gui,SIGNAL(endSelectionSignal(const BOOL)),
117 this,SLOT(setSelection(const BOOL)) ); 114 this,SLOT(setSelection(const BOOL)) );
118 QObject::connect(gui,SIGNAL(clearSelectionSignal()), 115 QObject::connect(gui,SIGNAL(clearSelectionSignal()),
119 this,SLOT(clearSelection()) ); 116 this,SLOT(clearSelection()) );
120} 117}
121 118
122/*! 119/*!
123*/ 120*/
124 121
125TEmulation::~TEmulation() 122TEmulation::~TEmulation()
126{ 123{
127 delete screen[0]; 124 delete screen[0];
128 delete screen[1]; 125 delete screen[1];
129 bulk_timer.stop(); 126 bulk_timer.stop();
130} 127}
131 128
132/*! change between primary and alternate screen 129/*! change between primary and alternate screen
133*/ 130*/
134 131
135void TEmulation::setScreen(int n) 132void TEmulation::setScreen(int n)
136{ 133{
137 scr = screen[n&1]; 134 scr = screen[n&1];
138} 135}
139 136
140void TEmulation::setHistory(bool on) 137void TEmulation::setHistory(bool on)
141{ 138{
142 screen[0]->setScroll(on); 139 screen[0]->setScroll(on);
143 if (!connected) return; 140 if (!connected) return;
144 showBulk(); 141 showBulk();
145} 142}
146 143
147bool TEmulation::history() 144bool TEmulation::history()
148{ 145{
149 return screen[0]->hasScroll(); 146 return screen[0]->hasScroll();
150} 147}
151 148
152void TEmulation::setCodec(int c) 149void TEmulation::setCodec(int c)
153{ 150{
154 //FIXME: check whether we have to free codec 151 //FIXME: check whether we have to free codec
155 codec = c ? QTextCodec::codecForName("utf8") 152 codec = c ? QTextCodec::codecForName("utf8")
156 : QTextCodec::codecForLocale(); 153 : QTextCodec::codecForLocale();
157 if (decoder) delete decoder; 154 if (decoder) delete decoder;
158 decoder = codec->makeDecoder(); 155 decoder = codec->makeDecoder();
159} 156}
160 157
161void TEmulation::setKeytrans(int no) 158void TEmulation::setKeytrans(int no)
162{ 159{
163 keytrans = KeyTrans::find(no); 160 keytrans = KeyTrans::find(no);
164} 161}
165 162
166void TEmulation::setKeytrans(const char * no) 163void TEmulation::setKeytrans(const char * no)
167{ 164{
168 keytrans = KeyTrans::find(no); 165 keytrans = KeyTrans::find(no);
169} 166}
170 167
171// Interpreting Codes --------------------------------------------------------- 168// Interpreting Codes ---------------------------------------------------------
172 169
173/* 170/*
174 This section deals with decoding the incoming character stream. 171 This section deals with decoding the incoming character stream.
175 Decoding means here, that the stream is first seperated into `tokens' 172 Decoding means here, that the stream is first seperated into `tokens'
176 which are then mapped to a `meaning' provided as operations by the 173 which are then mapped to a `meaning' provided as operations by the
177 `Screen' class. 174 `Screen' class.
178*/ 175*/
179 176
180/*! 177/*!
181*/ 178*/
182 179
183void TEmulation::onRcvChar(int c) 180void TEmulation::onRcvChar(int c)
184// process application unicode input to terminal 181// process application unicode input to terminal
185// this is a trivial scanner 182// this is a trivial scanner
186{ 183{
187 c &= 0xff; 184 c &= 0xff;
188 switch (c) 185 switch (c)
189 { 186 {
190 case '\b' : scr->BackSpace(); break; 187 case '\b' : scr->BackSpace(); break;
191 case '\t' : scr->Tabulate(); break; 188 case '\t' : scr->Tabulate(); break;
192 case '\n' : scr->NewLine(); break; 189 case '\n' : scr->NewLine(); break;
193 case '\r' : scr->Return(); break; 190 case '\r' : scr->Return(); break;
194 case 0x07 : gui->Bell(); break; 191 case 0x07 : gui->Bell(); break;
195 default : scr->ShowCharacter(c); break; 192 default : scr->ShowCharacter(c); break;
196 }; 193 };
197} 194}
198 195
199/* ------------------------------------------------------------------------- */ 196/* ------------------------------------------------------------------------- */
200/* */ 197/* */
201/* Keyboard Handling */ 198/* Keyboard Handling */
202/* */ 199/* */
203/* ------------------------------------------------------------------------- */ 200/* ------------------------------------------------------------------------- */
204 201
205/*! 202/*!
206*/ 203*/
207 204
208void TEmulation::onKeyPress( QKeyEvent* ev ) 205void TEmulation::onKeyPress( QKeyEvent* ev )
209{ 206{
210 qWarning("onKeyPress,...."); 207 qWarning("onKeyPress,....");
211 if (!connected) return; // someone else gets the keys 208 if (!connected) return; // someone else gets the keys
212 if (scr->getHistCursor() != scr->getHistLines()); 209 if (scr->getHistCursor() != scr->getHistLines());
213 scr->setHistCursor(scr->getHistLines()); 210 scr->setHistCursor(scr->getHistLines());
214 if (!ev->text().isEmpty()) 211 if (!ev->text().isEmpty())
215 { // A block of text 212 { // A block of text
216 // Note that the text is proper unicode. 213 // Note that the text is proper unicode.
217 // We should do a conversion here, but since this 214 // We should do a conversion here, but since this
218 // routine will never be used, we simply emit plain ascii. 215 // routine will never be used, we simply emit plain ascii.
219 emit sndBlock(ev->text().ascii(),ev->text().length()); 216 emit sndBlock(ev->text().ascii(),ev->text().length());
220 } 217 }
221 else if (ev->ascii()>0) 218 else if (ev->ascii()>0)
222 { unsigned char c[1]; 219 { unsigned char c[1];
223 c[0] = ev->ascii(); 220 c[0] = ev->ascii();
224 emit sndBlock((char*)c,1); 221 emit sndBlock((char*)c,1);
225 } 222 }
226} 223}
227 224
228// Unblocking, Byte to Unicode translation --------------------------------- -- 225// Unblocking, Byte to Unicode translation --------------------------------- --
229 226
230/* 227/*
231 We are doing code conversion from locale to unicode first. 228 We are doing code conversion from locale to unicode first.
232*/ 229*/
233 230
234void TEmulation::onRcvBlock(const char *s, int len) 231void TEmulation::onRcvBlock(const char *s, int len)
235{ 232{
236 bulkStart(); 233 bulkStart();
237 bulk_incnt += 1; 234 bulk_incnt += 1;
238 for (int i = 0; i < len; i++) 235 for (int i = 0; i < len; i++)
239 { 236 {
240 QString result = decoder->toUnicode(&s[i],1); 237 QString result = decoder->toUnicode(&s[i],1);
241 int reslen = result.length(); 238 int reslen = result.length();
242 for (int j = 0; j < reslen; j++) 239 for (int j = 0; j < reslen; j++)
243 onRcvChar(result[j].unicode()); 240 onRcvChar(result[j].unicode());
244 if (s[i] == '\n') bulkNewline(); 241 if (s[i] == '\n') bulkNewline();
245 } 242 }
246 bulkEnd(); 243 bulkEnd();
247} 244}
248 245
249// Selection --------------------------------------------------------------- -- 246// Selection --------------------------------------------------------------- --
250 247
251void TEmulation::onSelectionBegin(const int x, const int y) { 248void TEmulation::onSelectionBegin(const int x, const int y) {
252 if (!connected) return; 249 if (!connected) return;
253 scr->setSelBeginXY(x,y); 250 scr->setSelBeginXY(x,y);
254 showBulk(); 251 showBulk();
255} 252}
256 253
257void TEmulation::onSelectionExtend(const int x, const int y) { 254void TEmulation::onSelectionExtend(const int x, const int y) {
258 if (!connected) return; 255 if (!connected) return;
259 scr->setSelExtentXY(x,y); 256 scr->setSelExtentXY(x,y);
260 showBulk(); 257 showBulk();
261} 258}
262 259
263void TEmulation::setSelection(const BOOL preserve_line_breaks) { 260void TEmulation::setSelection(const BOOL preserve_line_breaks) {
264 if (!connected) return; 261 if (!connected) return;
265 QString t = scr->getSelText(preserve_line_breaks); 262 QString t = scr->getSelText(preserve_line_breaks);
266 if (!t.isNull()) gui->setSelection(t); 263 if (!t.isNull()) gui->setSelection(t);
267} 264}
268 265
269void TEmulation::clearSelection() { 266void TEmulation::clearSelection() {
270 if (!connected) return; 267 if (!connected) return;
271 scr->clearSelection(); 268 scr->clearSelection();
272 showBulk(); 269 showBulk();
273} 270}
274void TEmulation::streamHistory(QTextStream* stream) { 271void TEmulation::streamHistory(QTextStream* stream) {
275 *stream << scr->getHistory(); 272 *stream << scr->getHistory();
276} 273}
277// Refreshing -------------------------------------------------------------- -- 274// Refreshing -------------------------------------------------------------- --
278 275
279#define BULK_TIMEOUT 20 276#define BULK_TIMEOUT 20
280 277
281/*! 278/*!
282 called when \n comes in. Evtl. triggers showBulk at endBulk 279 called when \n comes in. Evtl. triggers showBulk at endBulk
283*/ 280*/
284 281
285void TEmulation::bulkNewline() 282void TEmulation::bulkNewline()
286{ 283{
287 bulk_nlcnt += 1; 284 bulk_nlcnt += 1;
288 bulk_incnt = 0; // reset bulk counter since `nl' rule applies 285 bulk_incnt = 0; // reset bulk counter since `nl' rule applies
289} 286}
290 287
291/*! 288/*!
292*/ 289*/
293 290
294void TEmulation::showBulk() 291void TEmulation::showBulk()
295{ 292{
296 bulk_nlcnt = 0; // reset bulk newline counter 293 bulk_nlcnt = 0; // reset bulk newline counter
297 bulk_incnt = 0; // reset bulk counter 294 bulk_incnt = 0; // reset bulk counter
298 if (connected) 295 if (connected)
299 { 296 {
300 ca* image = scr->getCookedImage(); // get the image 297 ca* image = scr->getCookedImage(); // get the image
301 gui->setImage(image, 298 gui->setImage(image,
302 scr->getLines(), 299 scr->getLines(),
303 scr->getColumns()); // actual refresh 300 scr->getColumns()); // actual refresh
304 free(image); 301 free(image);
305 //FIXME: check that we do not trigger other draw event here. 302 //FIXME: check that we do not trigger other draw event here.
306 gui->setScroll(scr->getHistCursor(),scr->getHistLines()); 303 gui->setScroll(scr->getHistCursor(),scr->getHistLines());
307 } 304 }
308} 305}
309 306
310void TEmulation::bulkStart() 307void TEmulation::bulkStart()
311{ 308{
312 if (bulk_timer.isActive()) bulk_timer.stop(); 309 if (bulk_timer.isActive()) bulk_timer.stop();
313} 310}
314 311
315void TEmulation::bulkEnd() 312void TEmulation::bulkEnd()
316{ 313{
317 if ( bulk_nlcnt > gui->Lines() || bulk_incnt > 20 ) 314 if ( bulk_nlcnt > gui->Lines() || bulk_incnt > 20 )
318 showBulk(); // resets bulk_??cnt to 0, too. 315 showBulk(); // resets bulk_??cnt to 0, too.
319 else 316 else
320 bulk_timer.start(BULK_TIMEOUT,TRUE); 317 bulk_timer.start(BULK_TIMEOUT,TRUE);
321} 318}
322 319
323void TEmulation::setConnect(bool c) 320void TEmulation::setConnect(bool c)
324{ 321{
325 connected = c; 322 connected = c;
326 if ( connected) 323 if ( connected)
327 { 324 {
328 onImageSizeChange(gui->Lines(), gui->Columns()); 325 onImageSizeChange(gui->Lines(), gui->Columns());
329 showBulk(); 326 showBulk();
330 } 327 }
331 else 328 else
332 { 329 {
333 scr->clearSelection(); 330 scr->clearSelection();
334 } 331 }
335} 332}
336 333
337// --------------------------------------------------------------------------- 334// ---------------------------------------------------------------------------
338 335
339/*! triggered by image size change of the TEWidget `gui'. 336/*! triggered by image size change of the TEWidget `gui'.
340 337
341 This event is simply propagated to the attached screens 338 This event is simply propagated to the attached screens
342 and to the related serial line. 339 and to the related serial line.
343*/ 340*/
344 341
345void TEmulation::onImageSizeChange(int lines, int columns) 342void TEmulation::onImageSizeChange(int lines, int columns)
346{ 343{
347 if (!connected) return; 344 if (!connected) return;
348 screen[0]->resizeImage(lines,columns); 345 screen[0]->resizeImage(lines,columns);
349 screen[1]->resizeImage(lines,columns); 346 screen[1]->resizeImage(lines,columns);
350 showBulk(); 347 showBulk();
351 emit ImageSizeChanged(lines,columns); // propagate event to serial line 348 emit ImageSizeChanged(lines,columns); // propagate event to serial line
352} 349}
353 350
354void TEmulation::onHistoryCursorChange(int cursor) 351void TEmulation::onHistoryCursorChange(int cursor)
355{ 352{
356 if (!connected) return; 353 if (!connected) return;
357 scr->setHistCursor(cursor); 354 scr->setHistCursor(cursor);
358 showBulk(); 355 showBulk();
359} 356}
360 357
361void TEmulation::setColumns(int columns) 358void TEmulation::setColumns(int columns)
362{ 359{
363 //FIXME: this goes strange ways. 360 //FIXME: this goes strange ways.
364 // Can we put this straight or explain it at least? 361 // Can we put this straight or explain it at least?
365 emit changeColumns(columns); 362 emit changeColumns(columns);
366} 363}
diff --git a/noncore/apps/opie-console/configdialog.cpp b/noncore/apps/opie-console/configdialog.cpp
index 53b3853..b23f4d0 100644
--- a/noncore/apps/opie-console/configdialog.cpp
+++ b/noncore/apps/opie-console/configdialog.cpp
@@ -1,114 +1,111 @@
1#include <qdialog.h>
2#include <qlistview.h> 1#include <qlistview.h>
3 2
4 3
5#include "profile.h"
6#include "configdialog.h" 4#include "configdialog.h"
7#include "metafactory.h"
8#include "profileeditordialog.h" 5#include "profileeditordialog.h"
9 6
10class ConfigListItem : public QListViewItem { 7class ConfigListItem : public QListViewItem {
11public: 8public:
12 ConfigListItem( QListView* item, const Profile& ); 9 ConfigListItem( QListView* item, const Profile& );
13 ~ConfigListItem(); 10 ~ConfigListItem();
14 Profile profile()const; 11 Profile profile()const;
15 12
16private: 13private:
17 Profile m_prof; 14 Profile m_prof;
18}; 15};
19ConfigListItem::ConfigListItem( QListView* item, const Profile& prof ) 16ConfigListItem::ConfigListItem( QListView* item, const Profile& prof )
20 : QListViewItem( item ), m_prof( prof ) 17 : QListViewItem( item ), m_prof( prof )
21{ 18{
22 setText(0, prof.name() ); 19 setText(0, prof.name() );
23} 20}
24ConfigListItem::~ConfigListItem() { 21ConfigListItem::~ConfigListItem() {
25 22
26} 23}
27Profile ConfigListItem::profile()const { 24Profile ConfigListItem::profile()const {
28 return m_prof; 25 return m_prof;
29} 26}
30 27
31/* Dialog */ 28/* Dialog */
32 29
33ConfigDialog::ConfigDialog( const Profile::ValueList& lis, MetaFactory* fa, 30ConfigDialog::ConfigDialog( const Profile::ValueList& lis, MetaFactory* fa,
34 QWidget* parent ) 31 QWidget* parent )
35 : ConfigureBase( parent, 0, TRUE ), m_fact( fa ) 32 : ConfigureBase( parent, 0, TRUE ), m_fact( fa )
36{ 33{
37 //init(); 34 //init();
38 { 35 {
39 Profile::ValueList::ConstIterator it; 36 Profile::ValueList::ConstIterator it;
40 for (it = lis.begin(); it != lis.end(); ++it ) { 37 for (it = lis.begin(); it != lis.end(); ++it ) {
41 new ConfigListItem( lstView, (*it) ); 38 new ConfigListItem( lstView, (*it) );
42 } 39 }
43 } 40 }
44} 41}
45ConfigDialog::~ConfigDialog() { 42ConfigDialog::~ConfigDialog() {
46 43
47} 44}
48Profile::ValueList ConfigDialog::list()const { 45Profile::ValueList ConfigDialog::list()const {
49/* iterate over the list */ 46/* iterate over the list */
50 Profile::ValueList lst; 47 Profile::ValueList lst;
51 QListViewItemIterator it(lstView); 48 QListViewItemIterator it(lstView);
52 for ( ; it.current(); ++it ) { 49 for ( ; it.current(); ++it ) {
53 ConfigListItem* item = (ConfigListItem*)it.current(); 50 ConfigListItem* item = (ConfigListItem*)it.current();
54 lst.append( item->profile() ); 51 lst.append( item->profile() );
55 } 52 }
56 return lst; 53 return lst;
57} 54}
58/* our slots */ 55/* our slots */
59void ConfigDialog::slotRemove() { 56void ConfigDialog::slotRemove() {
60 ConfigListItem* item = (ConfigListItem*)lstView->currentItem(); 57 ConfigListItem* item = (ConfigListItem*)lstView->currentItem();
61 if (!item ) 58 if (!item )
62 return; 59 return;
63 60
64 lstView->takeItem( item ); 61 lstView->takeItem( item );
65 delete item; 62 delete item;
66} 63}
67 64
68void ConfigDialog::slotEdit() { 65void ConfigDialog::slotEdit() {
69 Profile p; 66 Profile p;
70 67
71 if(!lstView->currentItem()) return; 68 if(!lstView->currentItem()) return;
72 69
73 // Load profile 70 // Load profile
74 p = ((ConfigListItem*)lstView->currentItem())->profile(); 71 p = ((ConfigListItem*)lstView->currentItem())->profile();
75 72
76 ProfileEditorDialog dlg(m_fact, p); 73 ProfileEditorDialog dlg(m_fact, p);
77 74
78 dlg.setCaption(tr("Edit Connection Profile")); 75 dlg.setCaption(tr("Edit Connection Profile"));
79 dlg.showMaximized(); 76 dlg.showMaximized();
80 int ret = dlg.exec(); 77 int ret = dlg.exec();
81 78
82 if(ret == QDialog::Accepted) 79 if(ret == QDialog::Accepted)
83 { 80 {
84 if(lstView->currentItem()) delete lstView->currentItem(); 81 if(lstView->currentItem()) delete lstView->currentItem();
85 82
86 // use dlg.terminal()! 83 // use dlg.terminal()!
87 Profile p = dlg.profile(); 84 Profile p = dlg.profile();
88 85
89 new ConfigListItem(lstView, p); 86 new ConfigListItem(lstView, p);
90 } 87 }
91} 88}
92 89
93 90
94void ConfigDialog::slotAdd() { 91void ConfigDialog::slotAdd() {
95 ProfileEditorDialog dlg(m_fact); 92 ProfileEditorDialog dlg(m_fact);
96 93
97 dlg.setCaption(tr("New Connection")); 94 dlg.setCaption(tr("New Connection"));
98 dlg.showMaximized(); 95 dlg.showMaximized();
99 int ret = dlg.exec(); 96 int ret = dlg.exec();
100 97
101 if(ret == QDialog::Accepted) 98 if(ret == QDialog::Accepted)
102 { 99 {
103 // TODO: Move into general profile save part 100 // TODO: Move into general profile save part
104 // assignments 101 // assignments
105 //QString type = dlg.term_type(); 102 //QString type = dlg.term_type();
106 //if(type == "VT102") profile = Profile::VT102; 103 //if(type == "VT102") profile = Profile::VT102;
107 104
108 // get profile from editor 105 // get profile from editor
109 Profile p = dlg.profile(); 106 Profile p = dlg.profile();
110 107
111 new ConfigListItem(lstView, p); 108 new ConfigListItem(lstView, p);
112 } 109 }
113} 110}
114 111
diff --git a/noncore/apps/opie-console/consoleconfigwidget.cpp b/noncore/apps/opie-console/consoleconfigwidget.cpp
index faedc58..a6ad8d2 100644
--- a/noncore/apps/opie-console/consoleconfigwidget.cpp
+++ b/noncore/apps/opie-console/consoleconfigwidget.cpp
@@ -1,111 +1,109 @@
1#include <qlabel.h> 1#include <qlabel.h>
2#include <qlayout.h> 2#include <qlayout.h>
3#include <qcombobox.h>
4#include <qlineedit.h> 3#include <qlineedit.h>
5#include <qpushbutton.h> 4#include <qpushbutton.h>
6#include <qlistview.h> 5#include <qlistview.h>
7#include <qhbox.h> 6#include <qhbox.h>
8#include <qregexp.h>
9#include <stdio.h> 7#include <stdio.h>
10 8
11#include <pwd.h> 9#include <pwd.h>
12#include <sys/types.h> 10#include <sys/types.h>
13 11
14 12
15#include "consoleconfigwidget.h" 13#include "consoleconfigwidget.h"
16 14
17ConsoleConfigWidget::ConsoleConfigWidget( const QString& name, QWidget* parent, 15ConsoleConfigWidget::ConsoleConfigWidget( const QString& name, QWidget* parent,
18 const char* na ) 16 const char* na )
19 : ProfileDialogConnectionWidget( name, parent, na ) { 17 : ProfileDialogConnectionWidget( name, parent, na ) {
20 m_lay = new QVBoxLayout( this ); 18 m_lay = new QVBoxLayout( this );
21 QLabel *label = new QLabel(tr("Command to execute"), this); 19 QLabel *label = new QLabel(tr("Command to execute"), this);
22 m_lay->addWidget(label); 20 m_lay->addWidget(label);
23 m_cmd = new QLineEdit(this); 21 m_cmd = new QLineEdit(this);
24 m_lay->addWidget(m_cmd); 22 m_lay->addWidget(m_cmd);
25 label = new QLabel(tr("Environment Variables"), this); 23 label = new QLabel(tr("Environment Variables"), this);
26 m_lay->addWidget(label); 24 m_lay->addWidget(label);
27 m_env = new QListView(this); 25 m_env = new QListView(this);
28 m_env->addColumn(tr("Name")); 26 m_env->addColumn(tr("Name"));
29 m_env->addColumn(tr("Value")); 27 m_env->addColumn(tr("Value"));
30 m_lay->addWidget(m_env); 28 m_lay->addWidget(m_env);
31 29
32 QHBox *hbox = new QHBox(this); 30 QHBox *hbox = new QHBox(this);
33 label = new QLabel(tr("Name :"), hbox); 31 label = new QLabel(tr("Name :"), hbox);
34 m_name = new QLineEdit(hbox); 32 m_name = new QLineEdit(hbox);
35 m_lay->addWidget(hbox); 33 m_lay->addWidget(hbox);
36 34
37 hbox = new QHBox(this); 35 hbox = new QHBox(this);
38 label = new QLabel(tr("Value :"), hbox); 36 label = new QLabel(tr("Value :"), hbox);
39 m_value = new QLineEdit(hbox); 37 m_value = new QLineEdit(hbox);
40 m_lay->addWidget(hbox); 38 m_lay->addWidget(hbox);
41 39
42 hbox = new QHBox(this); 40 hbox = new QHBox(this);
43 hbox->setSpacing(10); 41 hbox->setSpacing(10);
44 m_remove = new QPushButton(tr("Remove"), hbox); 42 m_remove = new QPushButton(tr("Remove"), hbox);
45 connect(m_remove, SIGNAL(clicked()), this, SLOT(slotRemove())); 43 connect(m_remove, SIGNAL(clicked()), this, SLOT(slotRemove()));
46 m_add = new QPushButton(tr("Add"), hbox); 44 m_add = new QPushButton(tr("Add"), hbox);
47 connect(m_add, SIGNAL(clicked()), this, SLOT(slotAdd())); 45 connect(m_add, SIGNAL(clicked()), this, SLOT(slotAdd()));
48 m_lay->addWidget(hbox); 46 m_lay->addWidget(hbox);
49} 47}
50 48
51void ConsoleConfigWidget::slotAdd() { 49void ConsoleConfigWidget::slotAdd() {
52 if (!(m_name->text().isEmpty() || m_value->text().isEmpty())) { 50 if (!(m_name->text().isEmpty() || m_value->text().isEmpty())) {
53 QListViewItem *item = new QListViewItem(m_env); 51 QListViewItem *item = new QListViewItem(m_env);
54 item->setText(0, m_name->text()); 52 item->setText(0, m_name->text());
55 item->setText(1, m_value->text()); 53 item->setText(1, m_value->text());
56 m_env->insertItem(item); 54 m_env->insertItem(item);
57 } 55 }
58} 56}
59 57
60void ConsoleConfigWidget::slotRemove() { 58void ConsoleConfigWidget::slotRemove() {
61 QListViewItem *item = m_env->currentItem(); 59 QListViewItem *item = m_env->currentItem();
62 if (item) { 60 if (item) {
63 m_env->takeItem(item); 61 m_env->takeItem(item);
64 } 62 }
65} 63}
66 64
67ConsoleConfigWidget::~ConsoleConfigWidget() { 65ConsoleConfigWidget::~ConsoleConfigWidget() {
68} 66}
69 67
70void ConsoleConfigWidget::load( const Profile& prof ) { 68void ConsoleConfigWidget::load( const Profile& prof ) {
71 /* 69 /*
72 * default to the users default shell 70 * default to the users default shell
73 */ 71 */
74 struct passwd *ent = 0; 72 struct passwd *ent = 0;
75 char *shell = "/bin/sh"; 73 char *shell = "/bin/sh";
76 74
77 while ( (ent = getpwent()) != 0 ) { 75 while ( (ent = getpwent()) != 0 ) {
78 if (ent->pw_shell != "") { 76 if (ent->pw_shell != "") {
79 shell = ent->pw_shell; 77 shell = ent->pw_shell;
80 } 78 }
81 } 79 }
82 80
83 m_cmd->setText(prof.readEntry("Command", shell )); 81 m_cmd->setText(prof.readEntry("Command", shell ));
84 int envcount = prof.readNumEntry("EnvVars", 0); 82 int envcount = prof.readNumEntry("EnvVars", 0);
85 for (int i=0; i<envcount; i++) { 83 for (int i=0; i<envcount; i++) {
86 QString name = prof.readEntry("Env_Name_" + QString::number(i), ""); 84 QString name = prof.readEntry("Env_Name_" + QString::number(i), "");
87 QString value = prof.readEntry("Env_Value_" + QString::number(i), ""); 85 QString value = prof.readEntry("Env_Value_" + QString::number(i), "");
88 if (!(name.isEmpty() || value.isEmpty())) { 86 if (!(name.isEmpty() || value.isEmpty())) {
89 QListViewItem *item = new QListViewItem(m_env); 87 QListViewItem *item = new QListViewItem(m_env);
90 item->setText(0, name); 88 item->setText(0, name);
91 item->setText(1, value); 89 item->setText(1, value);
92 m_env->insertItem(item); 90 m_env->insertItem(item);
93 } 91 }
94 } 92 }
95} 93}
96 94
97void ConsoleConfigWidget::save( Profile& prof ) { 95void ConsoleConfigWidget::save( Profile& prof ) {
98 prof.writeEntry( "Command", m_cmd->text()); 96 prof.writeEntry( "Command", m_cmd->text());
99 QListViewItem *item = m_env->firstChild(); 97 QListViewItem *item = m_env->firstChild();
100 int counter = 0; 98 int counter = 0;
101 while (item) { 99 while (item) {
102 QString name = item->text(0); 100 QString name = item->text(0);
103 QString value = item->text(1); 101 QString value = item->text(1);
104 prof.writeEntry("Env_Name_" + QString::number(counter), name); 102 prof.writeEntry("Env_Name_" + QString::number(counter), name);
105 prof.writeEntry("Env_Value_" + QString::number(counter), value); 103 prof.writeEntry("Env_Value_" + QString::number(counter), value);
106 item = item->nextSibling(); 104 item = item->nextSibling();
107 counter++; 105 counter++;
108 } 106 }
109 prof.writeEntry("EnvVars", QString::number(counter)); 107 prof.writeEntry("EnvVars", QString::number(counter));
110} 108}
111 109
diff --git a/noncore/apps/opie-console/default.cpp b/noncore/apps/opie-console/default.cpp
index b060139..c237575 100644
--- a/noncore/apps/opie-console/default.cpp
+++ b/noncore/apps/opie-console/default.cpp
@@ -1,122 +1,121 @@
1#include "io_serial.h"
2#include "io_irda.h" 1#include "io_irda.h"
3#include "io_bt.h" 2#include "io_bt.h"
4#include "io_modem.h" 3#include "io_modem.h"
5#include "filetransfer.h" 4#include "filetransfer.h"
6#include "filereceive.h" 5#include "filereceive.h"
7#include "serialconfigwidget.h" 6#include "serialconfigwidget.h"
8#include "irdaconfigwidget.h" 7#include "irdaconfigwidget.h"
9#include "btconfigwidget.h" 8#include "btconfigwidget.h"
10#include "modemconfigwidget.h" 9#include "modemconfigwidget.h"
11#include "terminalwidget.h" 10#include "terminalwidget.h"
12#include "function_keyboard.h" 11#include "function_keyboard.h"
13#include "consoleconfigwidget.h" 12#include "consoleconfigwidget.h"
14#include "MyPty.h" 13#include "MyPty.h"
15 14
16#include "default.h" 15#include "default.h"
17 16
18extern "C" { 17extern "C" {
19 // FILE Transfer Stuff 18 // FILE Transfer Stuff
20 FileTransferLayer* newSZTransfer(IOLayer* lay) { 19 FileTransferLayer* newSZTransfer(IOLayer* lay) {
21 return new FileTransfer( FileTransfer::SZ, lay ); 20 return new FileTransfer( FileTransfer::SZ, lay );
22 } 21 }
23 FileTransferLayer* newSYTransfer(IOLayer* lay) { 22 FileTransferLayer* newSYTransfer(IOLayer* lay) {
24 return new FileTransfer( FileTransfer::SY, lay ); 23 return new FileTransfer( FileTransfer::SY, lay );
25 } 24 }
26 FileTransferLayer* newSXTransfer(IOLayer* lay) { 25 FileTransferLayer* newSXTransfer(IOLayer* lay) {
27 return new FileTransfer(FileTransfer ::SX, lay ); 26 return new FileTransfer(FileTransfer ::SX, lay );
28 } 27 }
29 28
30 // FILE Transfer Receive Stuff 29 // FILE Transfer Receive Stuff
31 ReceiveLayer* newSZReceive(IOLayer* lay) { 30 ReceiveLayer* newSZReceive(IOLayer* lay) {
32 return new FileReceive( FileReceive::SZ, lay ); 31 return new FileReceive( FileReceive::SZ, lay );
33 } 32 }
34 ReceiveLayer* newSYReceive(IOLayer* lay) { 33 ReceiveLayer* newSYReceive(IOLayer* lay) {
35 return new FileReceive( FileReceive::SY, lay ); 34 return new FileReceive( FileReceive::SY, lay );
36 } 35 }
37 ReceiveLayer* newSXReceive(IOLayer* lay) { 36 ReceiveLayer* newSXReceive(IOLayer* lay) {
38 return new FileReceive(FileReceive::SX, lay ); 37 return new FileReceive(FileReceive::SX, lay );
39 } 38 }
40 39
41 // Layer stuff 40 // Layer stuff
42 IOLayer* newSerialLayer( const Profile& prof) { 41 IOLayer* newSerialLayer( const Profile& prof) {
43 return new IOSerial( prof ); 42 return new IOSerial( prof );
44 } 43 }
45 IOLayer* newBTLayer( const Profile& prof ) { 44 IOLayer* newBTLayer( const Profile& prof ) {
46 return new IOBt( prof ); 45 return new IOBt( prof );
47 } 46 }
48 IOLayer* newIrDaLayer( const Profile& prof ) { 47 IOLayer* newIrDaLayer( const Profile& prof ) {
49 return new IOIrda( prof ); 48 return new IOIrda( prof );
50 } 49 }
51 IOLayer* newModemLayer( const Profile& prof ) { 50 IOLayer* newModemLayer( const Profile& prof ) {
52 return new IOModem( prof ); 51 return new IOModem( prof );
53 } 52 }
54 IOLayer* newConsole( const Profile& prof ) { 53 IOLayer* newConsole( const Profile& prof ) {
55 return new MyPty( prof ); 54 return new MyPty( prof );
56 } 55 }
57 56
58 // Connection Widgets 57 // Connection Widgets
59 ProfileDialogWidget* newSerialWidget( const QString& str, QWidget* wid ) { 58 ProfileDialogWidget* newSerialWidget( const QString& str, QWidget* wid ) {
60 return new SerialConfigWidget( str, wid ); 59 return new SerialConfigWidget( str, wid );
61 } 60 }
62 ProfileDialogWidget* newIrDaWidget( const QString& str, QWidget* wid ) { 61 ProfileDialogWidget* newIrDaWidget( const QString& str, QWidget* wid ) {
63 return new IrdaConfigWidget( str, wid ); 62 return new IrdaConfigWidget( str, wid );
64 } 63 }
65 ProfileDialogWidget* newModemWidget( const QString& str, QWidget* wid ) { 64 ProfileDialogWidget* newModemWidget( const QString& str, QWidget* wid ) {
66 return new ModemConfigWidget(str, wid ); 65 return new ModemConfigWidget(str, wid );
67 } 66 }
68 ProfileDialogWidget* newBTWidget( const QString& str, QWidget* wid ) { 67 ProfileDialogWidget* newBTWidget( const QString& str, QWidget* wid ) {
69 return new BTConfigWidget(str, wid ); 68 return new BTConfigWidget(str, wid );
70 } 69 }
71 ProfileDialogWidget* newConsoleWid( const QString& str, QWidget* wid ) { 70 ProfileDialogWidget* newConsoleWid( const QString& str, QWidget* wid ) {
72 return new ConsoleConfigWidget(str, wid ); 71 return new ConsoleConfigWidget(str, wid );
73 } 72 }
74 73
75 74
76 // Terminal Widget(s) 75 // Terminal Widget(s)
77 ProfileDialogWidget* newTerminalWidget(const QString& na, QWidget* wid) { 76 ProfileDialogWidget* newTerminalWidget(const QString& na, QWidget* wid) {
78 return new TerminalWidget(na, wid,0 ); 77 return new TerminalWidget(na, wid,0 );
79 } 78 }
80 79
81 // Function Keyboard Widget 80 // Function Keyboard Widget
82 ProfileDialogWidget* newKeyboardWidget(const QString& na, QWidget *wid) { 81 ProfileDialogWidget* newKeyboardWidget(const QString& na, QWidget *wid) {
83 return new FunctionKeyboardConfig(na, wid); 82 return new FunctionKeyboardConfig(na, wid);
84 } 83 }
85 84
86/* // VT Emulations 85/* // VT Emulations
87 EmulationLayer* newVT102( WidgetLayer* wid ) { 86 EmulationLayer* newVT102( WidgetLayer* wid ) {
88 return new Vt102Emulation( wid ); 87 return new Vt102Emulation( wid );
89 } 88 }
90*/ 89*/
91}; 90};
92 91
93Default::Default( MetaFactory* fact ) { 92Default::Default( MetaFactory* fact ) {
94 fact->addFileTransferLayer( "SZ", QObject::tr("Z-Modem"), newSZTransfer ); 93 fact->addFileTransferLayer( "SZ", QObject::tr("Z-Modem"), newSZTransfer );
95 fact->addFileTransferLayer( "SY", QObject::tr("Y-Modem"), newSYTransfer ); 94 fact->addFileTransferLayer( "SY", QObject::tr("Y-Modem"), newSYTransfer );
96 fact->addFileTransferLayer( "SX", QObject::tr("X-Modem"), newSXTransfer ); 95 fact->addFileTransferLayer( "SX", QObject::tr("X-Modem"), newSXTransfer );
97 96
98 fact->addReceiveLayer( "SZ", QObject::tr("Z-Modem"), newSZReceive ); 97 fact->addReceiveLayer( "SZ", QObject::tr("Z-Modem"), newSZReceive );
99 fact->addReceiveLayer( "SY", QObject::tr("Y-Modem"), newSYReceive ); 98 fact->addReceiveLayer( "SY", QObject::tr("Y-Modem"), newSYReceive );
100 fact->addReceiveLayer( "SX", QObject::tr("X-Modem"), newSXReceive ); 99 fact->addReceiveLayer( "SX", QObject::tr("X-Modem"), newSXReceive );
101 100
102 fact->addIOLayerFactory( "serial", QObject::tr("Serial"), newSerialLayer ); 101 fact->addIOLayerFactory( "serial", QObject::tr("Serial"), newSerialLayer );
103// fact->addIOLayerFactory( "irda", QObject::tr("Infrared"), newIrDaLayer ); 102// fact->addIOLayerFactory( "irda", QObject::tr("Infrared"), newIrDaLayer );
104// fact->addIOLayerFactory( "bt", QObject::tr("Bluetooth"), newBTLayer ); 103// fact->addIOLayerFactory( "bt", QObject::tr("Bluetooth"), newBTLayer );
105 fact->addIOLayerFactory( "modem", QObject::tr("Modem"), newModemLayer ); 104 fact->addIOLayerFactory( "modem", QObject::tr("Modem"), newModemLayer );
106 fact->addIOLayerFactory( "console", QObject::tr("Local Console"), newConsole ); 105 fact->addIOLayerFactory( "console", QObject::tr("Local Console"), newConsole );
107 106
108 fact->addConnectionWidgetFactory( "serial", QObject::tr("Serial"), newSerialWidget ); 107 fact->addConnectionWidgetFactory( "serial", QObject::tr("Serial"), newSerialWidget );
109// fact->addConnectionWidgetFactory( "irda", QObject::tr("Infrared"), newIrDaWidget ); 108// fact->addConnectionWidgetFactory( "irda", QObject::tr("Infrared"), newIrDaWidget );
110 fact->addConnectionWidgetFactory( "modem", QObject::tr("Modem"), newModemWidget ); 109 fact->addConnectionWidgetFactory( "modem", QObject::tr("Modem"), newModemWidget );
111// fact->addConnectionWidgetFactory( "bt", QObject::tr("Bluetooth"), newBTWidget ); 110// fact->addConnectionWidgetFactory( "bt", QObject::tr("Bluetooth"), newBTWidget );
112 fact->addConnectionWidgetFactory( "console", QObject::tr("Local Console"), newConsoleWid ); 111 fact->addConnectionWidgetFactory( "console", QObject::tr("Local Console"), newConsoleWid );
113 112
114 fact->addTerminalWidgetFactory( "default", QObject::tr("Default Terminal"), newTerminalWidget ); 113 fact->addTerminalWidgetFactory( "default", QObject::tr("Default Terminal"), newTerminalWidget );
115 fact->addKeyboardWidgetFactory( "defaultKeys", QObject::tr("Default Keyboard"), 114 fact->addKeyboardWidgetFactory( "defaultKeys", QObject::tr("Default Keyboard"),
116 newKeyboardWidget ); 115 newKeyboardWidget );
117 116
118// fact->addEmulationLayer( "default", QObject::tr("Default Terminal"), newVT102 ); 117// fact->addEmulationLayer( "default", QObject::tr("Default Terminal"), newVT102 );
119} 118}
120Default::~Default() { 119Default::~Default() {
121 120
122} 121}
diff --git a/noncore/apps/opie-console/dialdialog.cpp b/noncore/apps/opie-console/dialdialog.cpp
index b91727b..6bc1240 100644
--- a/noncore/apps/opie-console/dialdialog.cpp
+++ b/noncore/apps/opie-console/dialdialog.cpp
@@ -1,101 +1,98 @@
1 1
2 2
3#include <qlayout.h> 3#include <qlayout.h>
4#include <qlabel.h> 4#include <qlabel.h>
5#include <qcombobox.h>
6#include <qscrollview.h>
7#include <qpushbutton.h> 5#include <qpushbutton.h>
8#include <qfont.h>
9#include <qbuttongroup.h> 6#include <qbuttongroup.h>
10 7
11#include "dialdialog.h" 8#include "dialdialog.h"
12 9
13 10
14 11
15DialDialog::DialDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) 12DialDialog::DialDialog( QWidget* parent, const char* name, bool modal, WFlags fl )
16 : QDialog( parent, name, modal, fl ) { 13 : QDialog( parent, name, modal, fl ) {
17 14
18 setCaption( tr( "Enter number" ) ); 15 setCaption( tr( "Enter number" ) );
19 16
20 QVBoxLayout *mainLayout = new QVBoxLayout( this ); 17 QVBoxLayout *mainLayout = new QVBoxLayout( this );
21 18
22 QLabel *textLabel = new QLabel( this ); 19 QLabel *textLabel = new QLabel( this );
23 textLabel->setTextFormat( QLabel::RichText ); 20 textLabel->setTextFormat( QLabel::RichText );
24 textLabel->setText( tr("Enter the number you want to dial. When finished, press ok") ); 21 textLabel->setText( tr("Enter the number you want to dial. When finished, press ok") );
25 22
26 m_dialLine = new QLineEdit( this ); 23 m_dialLine = new QLineEdit( this );
27 m_dialLine->setReadOnly( true ); 24 m_dialLine->setReadOnly( true );
28 m_dialLine->setFrame( false ); 25 m_dialLine->setFrame( false );
29 m_dialLine->setAlignment( Qt::AlignLeft ); 26 m_dialLine->setAlignment( Qt::AlignLeft );
30 QFont dialLine_font( m_dialLine->font() ); 27 QFont dialLine_font( m_dialLine->font() );
31 dialLine_font.setBold( TRUE ); 28 dialLine_font.setBold( TRUE );
32 dialLine_font.setPointSize( 18 ); 29 dialLine_font.setPointSize( 18 );
33 m_dialLine->setFont( dialLine_font ); 30 m_dialLine->setFont( dialLine_font );
34 31
35 QWidget* dialWidget = new QWidget( this ); 32 QWidget* dialWidget = new QWidget( this );
36 QGridLayout *layout = new QGridLayout( dialWidget , 4, 3 ); 33 QGridLayout *layout = new QGridLayout( dialWidget , 4, 3 );
37 34
38 QButtonGroup *dialButtons = new QButtonGroup( ); 35 QButtonGroup *dialButtons = new QButtonGroup( );
39 36
40 QPushButton *number0 = new QPushButton( dialWidget ); 37 QPushButton *number0 = new QPushButton( dialWidget );
41 number0->setText( QString( "0" ) ); 38 number0->setText( QString( "0" ) );
42 QFont number0_font( number0->font() ); 39 QFont number0_font( number0->font() );
43 number0_font.setBold( TRUE ); 40 number0_font.setBold( TRUE );
44 number0->setFont( number0_font ); 41 number0->setFont( number0_font );
45 layout->addWidget( number0, 4, 1 ); 42 layout->addWidget( number0, 4, 1 );
46 dialButtons->insert( number0 ); 43 dialButtons->insert( number0 );
47 44
48 int x = 0, y = 0; 45 int x = 0, y = 0;
49 for ( int i = 0 ; i < 9; i++ ) { 46 for ( int i = 0 ; i < 9; i++ ) {
50 QPushButton *number = new QPushButton( dialWidget ); 47 QPushButton *number = new QPushButton( dialWidget );
51 number->setText( QString( "%1" ).arg( i + 1 ) ); 48 number->setText( QString( "%1" ).arg( i + 1 ) );
52 QFont number_font( number->font() ); 49 QFont number_font( number->font() );
53 number_font.setBold( TRUE ); 50 number_font.setBold( TRUE );
54 number->setFont( number_font ); 51 number->setFont( number_font );
55 52
56 dialButtons->insert( number ); 53 dialButtons->insert( number );
57 54
58 layout->addWidget( number, x, y ); 55 layout->addWidget( number, x, y );
59 56
60 if ( y < 2 ) { 57 if ( y < 2 ) {
61 y++; 58 y++;
62 } else { 59 } else {
63 x++; 60 x++;
64 y = 0; 61 y = 0;
65 } 62 }
66 } 63 }
67 64
68 connect( dialButtons, SIGNAL( clicked( int ) ), this, SLOT( slotEnterNumber( int ) ) ); 65 connect( dialButtons, SIGNAL( clicked( int ) ), this, SLOT( slotEnterNumber( int ) ) );
69 66
70 mainLayout->addStretch( 2 ); 67 mainLayout->addStretch( 2 );
71 mainLayout->addWidget( textLabel ); 68 mainLayout->addWidget( textLabel );
72 mainLayout->addStretch( 1 ); 69 mainLayout->addStretch( 1 );
73 mainLayout->addWidget( m_dialLine ); 70 mainLayout->addWidget( m_dialLine );
74 mainLayout->addStretch( 2 ); 71 mainLayout->addStretch( 2 );
75 mainLayout->addWidget( dialWidget ); 72 mainLayout->addWidget( dialWidget );
76 mainLayout->addStretch( 4 ); 73 mainLayout->addStretch( 4 );
77} 74}
78 75
79 76
80void DialDialog::slotEnterNumber( int number ) { 77void DialDialog::slotEnterNumber( int number ) {
81 78
82 // pretty stupid, just for testing .-) 79 // pretty stupid, just for testing .-)
83 80
84 m_number.append(QString("%1").arg(number)); 81 m_number.append(QString("%1").arg(number));
85 82
86 setNumber(m_number); 83 setNumber(m_number);
87} 84}
88 85
89DialDialog::~DialDialog() { 86DialDialog::~DialDialog() {
90} 87}
91 88
92QString DialDialog::number() { 89QString DialDialog::number() {
93 return m_number; 90 return m_number;
94 91
95} 92}
96 93
97void DialDialog::setNumber( QString number ) 94void DialDialog::setNumber( QString number )
98{ 95{
99 m_dialLine->setText( QString("%1").arg( number ) ); 96 m_dialLine->setText( QString("%1").arg( number ) );
100} 97}
101 98
diff --git a/noncore/apps/opie-console/emulation_handler.cpp b/noncore/apps/opie-console/emulation_handler.cpp
index 235facb..2c1d888 100644
--- a/noncore/apps/opie-console/emulation_handler.cpp
+++ b/noncore/apps/opie-console/emulation_handler.cpp
@@ -1,209 +1,206 @@
1#include <qwidget.h>
2#include <qpushbutton.h>
3 1
4#include "TEWidget.h"
5#include "TEmuVt102.h" 2#include "TEmuVt102.h"
6 3
7#include "profile.h" 4#include "profile.h"
8#include "emulation_handler.h" 5#include "emulation_handler.h"
9#include "script.h" 6#include "script.h"
10 7
11EmulationHandler::EmulationHandler( const Profile& prof, QWidget* parent,const char* name ) 8EmulationHandler::EmulationHandler( const Profile& prof, QWidget* parent,const char* name )
12 : QObject(0, name ) 9 : QObject(0, name )
13{ 10{
14 m_teWid = new TEWidget( parent, "TerminalMain"); 11 m_teWid = new TEWidget( parent, "TerminalMain");
15 // use setWrapAt(0) for classic behaviour (wrap at screen width, no scrollbar) 12 // use setWrapAt(0) for classic behaviour (wrap at screen width, no scrollbar)
16 // use setWrapAt(80) for normal console with scrollbar 13 // use setWrapAt(80) for normal console with scrollbar
17 setWrap(prof.readNumEntry("Wrap", 0) ? 0 : 80); 14 setWrap(prof.readNumEntry("Wrap", 0) ? 0 : 80);
18 m_teWid->setMinimumSize(150, 70 ); 15 m_teWid->setMinimumSize(150, 70 );
19 m_script = 0; 16 m_script = 0;
20 parent->resize( m_teWid->calcSize(80, 24 ) ); 17 parent->resize( m_teWid->calcSize(80, 24 ) );
21 m_teEmu = new TEmuVt102(m_teWid ); 18 m_teEmu = new TEmuVt102(m_teWid );
22 19
23 connect(m_teEmu,SIGNAL(ImageSizeChanged(int, int) ), 20 connect(m_teEmu,SIGNAL(ImageSizeChanged(int, int) ),
24 this, SIGNAL(changeSize(int, int) ) ); 21 this, SIGNAL(changeSize(int, int) ) );
25 connect(m_teEmu, SIGNAL(sndBlock(const char*, int) ), 22 connect(m_teEmu, SIGNAL(sndBlock(const char*, int) ),
26 this, SLOT(recvEmulation(const char*, int) ) ); 23 this, SLOT(recvEmulation(const char*, int) ) );
27 m_teEmu->setConnect( true ); 24 m_teEmu->setConnect( true );
28 m_teEmu->setHistory( TRUE ); 25 m_teEmu->setHistory( TRUE );
29 load( prof ); 26 load( prof );
30 27
31 28
32 29
33} 30}
34TEmulation* EmulationHandler::emulation() { 31TEmulation* EmulationHandler::emulation() {
35 return m_teEmu; 32 return m_teEmu;
36} 33}
37EmulationHandler::~EmulationHandler() { 34EmulationHandler::~EmulationHandler() {
38 if (isRecording()) 35 if (isRecording())
39 clearScript(); 36 clearScript();
40 delete m_teEmu; 37 delete m_teEmu;
41 delete m_teWid; 38 delete m_teWid;
42} 39}
43 40
44void EmulationHandler::load( const Profile& prof) { 41void EmulationHandler::load( const Profile& prof) {
45 m_teWid->setVTFont( font( prof.readNumEntry("Font") ) ); 42 m_teWid->setVTFont( font( prof.readNumEntry("Font") ) );
46 int num = prof.readNumEntry("Color"); 43 int num = prof.readNumEntry("Color");
47 setColor( foreColor(num), backColor(num) ); 44 setColor( foreColor(num), backColor(num) );
48 m_teWid->setBackgroundColor(backColor(num) ); 45 m_teWid->setBackgroundColor(backColor(num) );
49 46
50 int term = prof.readNumEntry("Terminal", 0) ; 47 int term = prof.readNumEntry("Terminal", 0) ;
51 switch(term) { 48 switch(term) {
52 default: 49 default:
53 case Profile::VT102: 50 case Profile::VT102:
54 case Profile::VT100: 51 case Profile::VT100:
55 m_teEmu->setKeytrans("vt100.keytab"); 52 m_teEmu->setKeytrans("vt100.keytab");
56 break; 53 break;
57 case Profile::Linux: 54 case Profile::Linux:
58 m_teEmu->setKeytrans("linux.keytab"); 55 m_teEmu->setKeytrans("linux.keytab");
59 break; 56 break;
60 case Profile::XTerm: 57 case Profile::XTerm:
61 m_teEmu->setKeytrans("default.Keytab"); 58 m_teEmu->setKeytrans("default.Keytab");
62 break; 59 break;
63 } 60 }
64} 61}
65void EmulationHandler::recv( const QByteArray& ar) { 62void EmulationHandler::recv( const QByteArray& ar) {
66 m_teEmu->onRcvBlock(ar.data(), ar.count() ); 63 m_teEmu->onRcvBlock(ar.data(), ar.count() );
67} 64}
68void EmulationHandler::recvEmulation(const char* src, int len ) { 65void EmulationHandler::recvEmulation(const char* src, int len ) {
69 QByteArray ar(len); 66 QByteArray ar(len);
70 67
71 memcpy(ar.data(), src, sizeof(char) * len ); 68 memcpy(ar.data(), src, sizeof(char) * len );
72 if (isRecording()) 69 if (isRecording())
73 m_script->append(ar); 70 m_script->append(ar);
74 emit send(ar); 71 emit send(ar);
75} 72}
76QWidget* EmulationHandler::widget() { 73QWidget* EmulationHandler::widget() {
77 return m_teWid; 74 return m_teWid;
78} 75}
79/* 76/*
80 * allocate a new table of colors 77 * allocate a new table of colors
81 */ 78 */
82void EmulationHandler::setColor( const QColor& fore, const QColor& back ) { 79void EmulationHandler::setColor( const QColor& fore, const QColor& back ) {
83 ColorEntry table[TABLE_COLORS]; 80 ColorEntry table[TABLE_COLORS];
84 const ColorEntry *defaultCt = m_teWid->getdefaultColorTable(); 81 const ColorEntry *defaultCt = m_teWid->getdefaultColorTable();
85 82
86 for (int i = 0; i < TABLE_COLORS; i++ ) { 83 for (int i = 0; i < TABLE_COLORS; i++ ) {
87 if ( i == 0 || i == 10 ) { 84 if ( i == 0 || i == 10 ) {
88 table[i].color = fore; 85 table[i].color = fore;
89 }else if ( i == 1 || i == 11 ) { 86 }else if ( i == 1 || i == 11 ) {
90 table[i].color = back; 87 table[i].color = back;
91 table[i].transparent = 0; 88 table[i].transparent = 0;
92 }else { 89 }else {
93 table[i].color = defaultCt[i].color; 90 table[i].color = defaultCt[i].color;
94 } 91 }
95 } 92 }
96 m_teWid->setColorTable(table ); 93 m_teWid->setColorTable(table );
97 m_teWid->update(); 94 m_teWid->update();
98} 95}
99QFont EmulationHandler::font( int id ) { 96QFont EmulationHandler::font( int id ) {
100 QString name; 97 QString name;
101 int size = 0; 98 int size = 0;
102 switch(id ) { 99 switch(id ) {
103 default: // fall through 100 default: // fall through
104 case 0: 101 case 0:
105 name = QString::fromLatin1("Micro"); 102 name = QString::fromLatin1("Micro");
106 size = 4; 103 size = 4;
107 break; 104 break;
108 case 1: 105 case 1:
109 name = QString::fromLatin1("Fixed"); 106 name = QString::fromLatin1("Fixed");
110 size = 7; 107 size = 7;
111 break; 108 break;
112 case 2: 109 case 2:
113 name = QString::fromLatin1("Fixed"); 110 name = QString::fromLatin1("Fixed");
114 size = 12; 111 size = 12;
115 break; 112 break;
116 } 113 }
117 QFont font(name, size, QFont::Normal ); 114 QFont font(name, size, QFont::Normal );
118 font.setFixedPitch(TRUE ); 115 font.setFixedPitch(TRUE );
119 return font; 116 return font;
120} 117}
121QColor EmulationHandler::foreColor(int col) { 118QColor EmulationHandler::foreColor(int col) {
122 QColor co; 119 QColor co;
123 /* we need to switch it */ 120 /* we need to switch it */
124 switch( col ) { 121 switch( col ) {
125 default: 122 default:
126 case Profile::White: 123 case Profile::White:
127 /* color is black */ 124 /* color is black */
128 co = Qt::white; 125 co = Qt::white;
129 break; 126 break;
130 case Profile::Black: 127 case Profile::Black:
131 co = Qt::black; 128 co = Qt::black;
132 break; 129 break;
133 case Profile::Green: 130 case Profile::Green:
134 qWarning("Foreground green"); 131 qWarning("Foreground green");
135 co = Qt::green; 132 co = Qt::green;
136 break; 133 break;
137 case Profile::Orange: 134 case Profile::Orange:
138 qWarning("Foreground orange"); 135 qWarning("Foreground orange");
139 co.setRgb( 231, 184, 98 ); 136 co.setRgb( 231, 184, 98 );
140 break; 137 break;
141 } 138 }
142 139
143 return co; 140 return co;
144} 141}
145QColor EmulationHandler::backColor(int col ) { 142QColor EmulationHandler::backColor(int col ) {
146 QColor co; 143 QColor co;
147 /* we need to switch it */ 144 /* we need to switch it */
148 switch( col ) { 145 switch( col ) {
149 default: 146 default:
150 case Profile::White: 147 case Profile::White:
151 /* color is white */ 148 /* color is white */
152 co = Qt::black; 149 co = Qt::black;
153 break; 150 break;
154 case Profile::Black: 151 case Profile::Black:
155 co = Qt::white; 152 co = Qt::white;
156 break; 153 break;
157 case Profile::Green: 154 case Profile::Green:
158 qWarning("Background black"); 155 qWarning("Background black");
159 co = Qt::black; 156 co = Qt::black;
160 break; 157 break;
161 case Profile::Orange: 158 case Profile::Orange:
162 qWarning("Background black"); 159 qWarning("Background black");
163 co = Qt::black; 160 co = Qt::black;
164 break; 161 break;
165 } 162 }
166 163
167 return co; 164 return co;
168} 165}
169 166
170QPushButton* EmulationHandler::cornerButton() { 167QPushButton* EmulationHandler::cornerButton() {
171 return m_teWid->cornerButton(); 168 return m_teWid->cornerButton();
172} 169}
173 170
174 171
175Script *EmulationHandler::script() { 172Script *EmulationHandler::script() {
176 return m_script; 173 return m_script;
177} 174}
178 175
179bool EmulationHandler::isRecording() { 176bool EmulationHandler::isRecording() {
180 return (m_script != 0); 177 return (m_script != 0);
181} 178}
182 179
183void EmulationHandler::startRecording() { 180void EmulationHandler::startRecording() {
184 if (!isRecording()) 181 if (!isRecording())
185 m_script = new Script(); 182 m_script = new Script();
186} 183}
187 184
188void EmulationHandler::clearScript() { 185void EmulationHandler::clearScript() {
189 if (isRecording()) { 186 if (isRecording()) {
190 delete m_script; 187 delete m_script;
191 m_script = 0; 188 m_script = 0;
192 } 189 }
193} 190}
194 191
195void EmulationHandler::runScript(const Script *script) { 192void EmulationHandler::runScript(const Script *script) {
196 emit send(script->script()); 193 emit send(script->script());
197} 194}
198 195
199void EmulationHandler::copy() { 196void EmulationHandler::copy() {
200 m_teWid->emitSelection(); 197 m_teWid->emitSelection();
201} 198}
202void EmulationHandler::paste() { 199void EmulationHandler::paste() {
203 m_teWid->pasteClipboard(); 200 m_teWid->pasteClipboard();
204} 201}
205 202
206void EmulationHandler::setWrap(int columns) { 203void EmulationHandler::setWrap(int columns) {
207 m_teWid->setWrapAt(columns); 204 m_teWid->setWrapAt(columns);
208} 205}
209 206
diff --git a/noncore/apps/opie-console/emulation_layer.cpp b/noncore/apps/opie-console/emulation_layer.cpp
index 6a2679e..2bef801 100644
--- a/noncore/apps/opie-console/emulation_layer.cpp
+++ b/noncore/apps/opie-console/emulation_layer.cpp
@@ -1,374 +1,371 @@
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_layer.h"
80#include "screen.h"
81#include <stdio.h> 79#include <stdio.h>
82#include <stdlib.h> 80#include <stdlib.h>
83#include <unistd.h> 81#include <unistd.h>
84#include <qkeycode.h>
85 82
86 83
87/* ------------------------------------------------------------------------- */ 84/* ------------------------------------------------------------------------- */
88/* */ 85/* */
89/* EmulationLayer */ 86/* EmulationLayer */
90/* */ 87/* */
91/* ------------------------------------------------------------------------- */ 88/* ------------------------------------------------------------------------- */
92 89
93#define CNTL(c) ((c)-'@') 90#define CNTL(c) ((c)-'@')
94 91
95/*! 92/*!
96*/ 93*/
97 94
98EmulationLayer::EmulationLayer( WidgetLayer* gui ) 95EmulationLayer::EmulationLayer( WidgetLayer* gui )
99: decoder((QTextDecoder*)NULL) 96: decoder((QTextDecoder*)NULL)
100{ 97{
101 this->gui = gui; 98 this->gui = gui;
102 99
103 screen[0] = new Screen(gui->lines(),gui->columns()); 100 screen[0] = new Screen(gui->lines(),gui->columns());
104 screen[1] = new Screen(gui->lines(),gui->columns()); 101 screen[1] = new Screen(gui->lines(),gui->columns());
105 scr = screen[0]; 102 scr = screen[0];
106 103
107 bulk_nlcnt = 0; // reset bulk newline counter 104 bulk_nlcnt = 0; // reset bulk newline counter
108 bulk_incnt = 0; // reset bulk counter 105 bulk_incnt = 0; // reset bulk counter
109 connected = FALSE; 106 connected = FALSE;
110 107
111 QObject::connect(&bulk_timer, SIGNAL( timeout() ), this, SLOT( showBulk() ) ); 108 QObject::connect(&bulk_timer, SIGNAL( timeout() ), this, SLOT( showBulk() ) );
112 QObject::connect(gui,SIGNAL( imageSizeChanged( int, int ) ), 109 QObject::connect(gui,SIGNAL( imageSizeChanged( int, int ) ),
113 this,SLOT( onImageSizeChange( int, int ) ) ); 110 this,SLOT( onImageSizeChange( int, int ) ) );
114 QObject::connect(gui,SIGNAL( changedHistoryCursor( int ) ), 111 QObject::connect(gui,SIGNAL( changedHistoryCursor( int ) ),
115 this,SLOT( historyCursorChange( int ) ) ); 112 this,SLOT( historyCursorChange( int ) ) );
116 QObject::connect(gui,SIGNAL( keyPressed( QKeyEvent* ) ), 113 QObject::connect(gui,SIGNAL( keyPressed( QKeyEvent* ) ),
117 this,SLOT( onKeyPress( QKeyEvent* ) ) ); 114 this,SLOT( onKeyPress( QKeyEvent* ) ) );
118 QObject::connect(gui,SIGNAL( selectionBegin( const int, const int) ), 115 QObject::connect(gui,SIGNAL( selectionBegin( const int, const int) ),
119 this,SLOT( onSelectionBegin( const int, const int ) ) ); 116 this,SLOT( onSelectionBegin( const int, const int ) ) );
120 QObject::connect(gui,SIGNAL( selectionExtended( const int, const int ) ), 117 QObject::connect(gui,SIGNAL( selectionExtended( const int, const int ) ),
121 this,SLOT( onSelectionExtend( const int,const int ) ) ); 118 this,SLOT( onSelectionExtend( const int,const int ) ) );
122 QObject::connect(gui,SIGNAL( selectionEnd( const bool ) ), 119 QObject::connect(gui,SIGNAL( selectionEnd( const bool ) ),
123 this,SLOT( setSelection( const bool ) ) ); 120 this,SLOT( setSelection( const bool ) ) );
124 QObject::connect(gui,SIGNAL( selectionCleared() ), 121 QObject::connect(gui,SIGNAL( selectionCleared() ),
125 this,SLOT( clearSelection() ) ); 122 this,SLOT( clearSelection() ) );
126} 123}
127 124
128/*! 125/*!
129*/ 126*/
130 127
131EmulationLayer::~EmulationLayer() 128EmulationLayer::~EmulationLayer()
132{ 129{
133 delete screen[0]; 130 delete screen[0];
134 delete screen[1]; 131 delete screen[1];
135 bulk_timer.stop(); 132 bulk_timer.stop();
136} 133}
137 134
138/*! change between primary and alternate screen 135/*! change between primary and alternate screen
139*/ 136*/
140 137
141void EmulationLayer::setScreen(int n) 138void EmulationLayer::setScreen(int n)
142{ 139{
143 scr = screen[n&1]; 140 scr = screen[n&1];
144} 141}
145 142
146void EmulationLayer::setHistory(bool on) 143void EmulationLayer::setHistory(bool on)
147{ 144{
148 screen[0]->setScroll(on); 145 screen[0]->setScroll(on);
149 if (!connected) return; 146 if (!connected) return;
150 showBulk(); 147 showBulk();
151} 148}
152 149
153bool EmulationLayer::history() 150bool EmulationLayer::history()
154{ 151{
155 return screen[0]->hasScroll(); 152 return screen[0]->hasScroll();
156} 153}
157 154
158void EmulationLayer::setCodec(int c) 155void EmulationLayer::setCodec(int c)
159{ 156{
160 //FIXME: check whether we have to free codec 157 //FIXME: check whether we have to free codec
161 codec = c ? QTextCodec::codecForName("utf8") 158 codec = c ? QTextCodec::codecForName("utf8")
162 : QTextCodec::codecForLocale(); 159 : QTextCodec::codecForLocale();
163 if (decoder) delete decoder; 160 if (decoder) delete decoder;
164 decoder = codec->makeDecoder(); 161 decoder = codec->makeDecoder();
165} 162}
166 163
167void EmulationLayer::setKeytrans(int no) 164void EmulationLayer::setKeytrans(int no)
168{ 165{
169 keytrans = KeyTrans::find(no); 166 keytrans = KeyTrans::find(no);
170} 167}
171 168
172void EmulationLayer::setKeytrans(const char * no) 169void EmulationLayer::setKeytrans(const char * no)
173{ 170{
174 keytrans = KeyTrans::find(no); 171 keytrans = KeyTrans::find(no);
175} 172}
176 173
177// Interpreting Codes --------------------------------------------------------- 174// Interpreting Codes ---------------------------------------------------------
178 175
179/* 176/*
180 This section deals with decoding the incoming character stream. 177 This section deals with decoding the incoming character stream.
181 Decoding means here, that the stream is first seperated into `tokens' 178 Decoding means here, that the stream is first seperated into `tokens'
182 which are then mapped to a `meaning' provided as operations by the 179 which are then mapped to a `meaning' provided as operations by the
183 `Screen' class. 180 `Screen' class.
184*/ 181*/
185 182
186/*! 183/*!
187*/ 184*/
188 185
189void EmulationLayer::onRcvChar(int c) 186void EmulationLayer::onRcvChar(int c)
190// process application unicode input to terminal 187// process application unicode input to terminal
191// this is a trivial scanner 188// this is a trivial scanner
192{ 189{
193 c &= 0xff; 190 c &= 0xff;
194 switch (c) 191 switch (c)
195 { 192 {
196 case '\b' : scr->BackSpace(); break; 193 case '\b' : scr->BackSpace(); break;
197 case '\t' : scr->Tabulate(); break; 194 case '\t' : scr->Tabulate(); break;
198 case '\n' : scr->NewLine(); break; 195 case '\n' : scr->NewLine(); break;
199 case '\r' : scr->Return(); break; 196 case '\r' : scr->Return(); break;
200 case 0x07 : gui->bell(); break; 197 case 0x07 : gui->bell(); break;
201 default : scr->ShowCharacter(c); break; 198 default : scr->ShowCharacter(c); break;
202 }; 199 };
203} 200}
204 201
205/* ------------------------------------------------------------------------- */ 202/* ------------------------------------------------------------------------- */
206/* */ 203/* */
207/* Keyboard Handling */ 204/* Keyboard Handling */
208/* */ 205/* */
209/* ------------------------------------------------------------------------- */ 206/* ------------------------------------------------------------------------- */
210 207
211/*! 208/*!
212*/ 209*/
213 210
214void EmulationLayer::onKeyPress( QKeyEvent* ev ) 211void EmulationLayer::onKeyPress( QKeyEvent* ev )
215{ 212{
216 if (!connected) return; // someone else gets the keys 213 if (!connected) return; // someone else gets the keys
217 if (scr->getHistCursor() != scr->getHistLines()); 214 if (scr->getHistCursor() != scr->getHistLines());
218 scr->setHistCursor(scr->getHistLines()); 215 scr->setHistCursor(scr->getHistLines());
219 if (!ev->text().isEmpty()) 216 if (!ev->text().isEmpty())
220 { // A block of text 217 { // A block of text
221 // Note that the text is proper unicode. 218 // Note that the text is proper unicode.
222 // We should do a conversion here, but since this 219 // We should do a conversion here, but since this
223 // routine will never be used, we simply emit plain ascii. 220 // routine will never be used, we simply emit plain ascii.
224 sendString( ev->text().ascii() ); //,ev->text().length()); 221 sendString( ev->text().ascii() ); //,ev->text().length());
225 } 222 }
226 else if (ev->ascii()>0) 223 else if (ev->ascii()>0)
227 { 224 {
228 QByteArray c = QByteArray( 1 ); 225 QByteArray c = QByteArray( 1 );
229 c.at( 0 ) = ev->ascii(); 226 c.at( 0 ) = ev->ascii();
230 // ibot: qbytearray is emited not char* 227 // ibot: qbytearray is emited not char*
231 228
232 emit sndBlock( (QByteArray) c ); 229 emit sndBlock( (QByteArray) c );
233 } 230 }
234} 231}
235 232
236// Unblocking, Byte to Unicode translation --------------------------------- -- 233// Unblocking, Byte to Unicode translation --------------------------------- --
237 234
238/* 235/*
239 We are doing code conversion from locale to unicode first. 236 We are doing code conversion from locale to unicode first.
240*/ 237*/
241 238
242void EmulationLayer::onRcvBlock(const QByteArray &s ) 239void EmulationLayer::onRcvBlock(const QByteArray &s )
243{ 240{
244 bulkStart(); 241 bulkStart();
245 bulk_incnt += 1; 242 bulk_incnt += 1;
246 for (int i = 0; i < s.size(); i++) 243 for (int i = 0; i < s.size(); i++)
247 { 244 {
248 //TODO: ibot: maybe decoding qbytearray to unicode in io_layer? 245 //TODO: ibot: maybe decoding qbytearray to unicode in io_layer?
249 QString result = decoder->toUnicode(&s[i],1); 246 QString result = decoder->toUnicode(&s[i],1);
250 int reslen = result.length(); 247 int reslen = result.length();
251 for (int j = 0; j < reslen; j++) 248 for (int j = 0; j < reslen; j++)
252 onRcvChar(result[j].unicode()); 249 onRcvChar(result[j].unicode());
253 if (s[i] == '\n') bulkNewline(); 250 if (s[i] == '\n') bulkNewline();
254 } 251 }
255 bulkEnd(); 252 bulkEnd();
256} 253}
257 254
258// Selection --------------------------------------------------------------- -- 255// Selection --------------------------------------------------------------- --
259 256
260void EmulationLayer::onSelectionBegin(const int x, const int y) { 257void EmulationLayer::onSelectionBegin(const int x, const int y) {
261 if (!connected) return; 258 if (!connected) return;
262 scr->setSelBeginXY(x,y); 259 scr->setSelBeginXY(x,y);
263 showBulk(); 260 showBulk();
264} 261}
265 262
266void EmulationLayer::onSelectionExtend(const int x, const int y) { 263void EmulationLayer::onSelectionExtend(const int x, const int y) {
267 if (!connected) return; 264 if (!connected) return;
268 scr->setSelExtentXY(x,y); 265 scr->setSelExtentXY(x,y);
269 showBulk(); 266 showBulk();
270} 267}
271 268
272void EmulationLayer::setSelection(const BOOL preserve_line_breaks) { 269void EmulationLayer::setSelection(const BOOL preserve_line_breaks) {
273 if (!connected) return; 270 if (!connected) return;
274 QString t = scr->getSelText(preserve_line_breaks); 271 QString t = scr->getSelText(preserve_line_breaks);
275 if (!t.isNull()) gui->setSelection(t); 272 if (!t.isNull()) gui->setSelection(t);
276} 273}
277 274
278void EmulationLayer::clearSelection() { 275void EmulationLayer::clearSelection() {
279 if (!connected) return; 276 if (!connected) return;
280 scr->clearSelection(); 277 scr->clearSelection();
281 showBulk(); 278 showBulk();
282} 279}
283 280
284// Refreshing -------------------------------------------------------------- -- 281// Refreshing -------------------------------------------------------------- --
285 282
286#define BULK_TIMEOUT 20 283#define BULK_TIMEOUT 20
287 284
288/*! 285/*!
289 called when \n comes in. Evtl. triggers showBulk at endBulk 286 called when \n comes in. Evtl. triggers showBulk at endBulk
290*/ 287*/
291 288
292void EmulationLayer::bulkNewline() 289void EmulationLayer::bulkNewline()
293{ 290{
294 bulk_nlcnt += 1; 291 bulk_nlcnt += 1;
295 bulk_incnt = 0; // reset bulk counter since `nl' rule applies 292 bulk_incnt = 0; // reset bulk counter since `nl' rule applies
296} 293}
297 294
298/*! 295/*!
299*/ 296*/
300 297
301void EmulationLayer::showBulk() 298void EmulationLayer::showBulk()
302{ 299{
303 bulk_nlcnt = 0; // reset bulk newline counter 300 bulk_nlcnt = 0; // reset bulk newline counter
304 bulk_incnt = 0; // reset bulk counter 301 bulk_incnt = 0; // reset bulk counter
305 if (connected) 302 if (connected)
306 { 303 {
307 QArray<Character> image = scr->getCookedImage(); // get the image 304 QArray<Character> image = scr->getCookedImage(); // get the image
308 gui->setImage(image, 305 gui->setImage(image,
309 scr->getLines(), 306 scr->getLines(),
310 scr->getColumns()); // actual refresh 307 scr->getColumns()); // actual refresh
311 delete image; 308 delete image;
312 //FIXME: check that we do not trigger other draw event here. 309 //FIXME: check that we do not trigger other draw event here.
313 gui->setScroll(scr->getHistCursor(),scr->getHistLines()); 310 gui->setScroll(scr->getHistCursor(),scr->getHistLines());
314 } 311 }
315} 312}
316 313
317void EmulationLayer::bulkStart() 314void EmulationLayer::bulkStart()
318{ 315{
319 if (bulk_timer.isActive()) bulk_timer.stop(); 316 if (bulk_timer.isActive()) bulk_timer.stop();
320} 317}
321 318
322void EmulationLayer::bulkEnd() 319void EmulationLayer::bulkEnd()
323{ 320{
324 if ( bulk_nlcnt > gui->lines() || bulk_incnt > 20 ) 321 if ( bulk_nlcnt > gui->lines() || bulk_incnt > 20 )
325 showBulk(); // resets bulk_??cnt to 0, too. 322 showBulk(); // resets bulk_??cnt to 0, too.
326 else 323 else
327 bulk_timer.start(BULK_TIMEOUT,TRUE); 324 bulk_timer.start(BULK_TIMEOUT,TRUE);
328} 325}
329 326
330void EmulationLayer::setConnect(bool c) 327void EmulationLayer::setConnect(bool c)
331{ 328{
332 connected = c; 329 connected = c;
333 if ( connected) 330 if ( connected)
334 { 331 {
335 onImageSizeChange(gui->lines(), gui->columns()); 332 onImageSizeChange(gui->lines(), gui->columns());
336 showBulk(); 333 showBulk();
337 } 334 }
338 else 335 else
339 { 336 {
340 scr->clearSelection(); 337 scr->clearSelection();
341 } 338 }
342} 339}
343 340
344// --------------------------------------------------------------------------- 341// ---------------------------------------------------------------------------
345 342
346/*! triggered by image size change of the Widget `gui'. 343/*! triggered by image size change of the Widget `gui'.
347 344
348 This event is simply propagated to the attached screens 345 This event is simply propagated to the attached screens
349 and to the related serial line. 346 and to the related serial line.
350*/ 347*/
351 348
352void EmulationLayer::onImageSizeChange(int lines, int columns) 349void EmulationLayer::onImageSizeChange(int lines, int columns)
353{ 350{
354 if (!connected) return; 351 if (!connected) return;
355 screen[0]->resizeImage(lines,columns); 352 screen[0]->resizeImage(lines,columns);
356 screen[1]->resizeImage(lines,columns); 353 screen[1]->resizeImage(lines,columns);
357 showBulk(); 354 showBulk();
358 emit ImageSizeChanged(lines,columns); // propagate event to serial line 355 emit ImageSizeChanged(lines,columns); // propagate event to serial line
359} 356}
360 357
361void EmulationLayer::onHistoryCursorChange(int cursor) 358void EmulationLayer::onHistoryCursorChange(int cursor)
362{ 359{
363 if (!connected) return; 360 if (!connected) return;
364 scr->setHistCursor(cursor); 361 scr->setHistCursor(cursor);
365 showBulk(); 362 showBulk();
366} 363}
367 364
368void EmulationLayer::setColumns(int columns) 365void EmulationLayer::setColumns(int columns)
369{ 366{
370 //FIXME: this goes strange ways. 367 //FIXME: this goes strange ways.
371 // Can we put this straight or explain it at least? 368 // Can we put this straight or explain it at least?
372 emit changeColumns(columns); 369 emit changeColumns(columns);
373} 370}
374 371
diff --git a/noncore/apps/opie-console/emulation_widget.cpp b/noncore/apps/opie-console/emulation_widget.cpp
index 9f95c72..ad8ecba 100644
--- a/noncore/apps/opie-console/emulation_widget.cpp
+++ b/noncore/apps/opie-console/emulation_widget.cpp
@@ -1,309 +1,301 @@
1// opie-console includes 1// opie-console includes
2#include "emulation_widget.h" 2#include "emulation_widget.h"
3#include "common.h"
4#include "widget_layer.h"
5#include "profile.h"
6 3
7// qt includes 4// qt includes
8#include <qwidget.h>
9#include <qarray.h>
10#include <qstring.h>
11#include <qpainter.h>
12#include <qrect.h>
13#include <qscrollbar.h> 5#include <qscrollbar.h>
14 6
15#define rimX 0 // left/right rim width 7#define rimX 0 // left/right rim width
16#define rimY 0 // top/bottom rim high 8#define rimY 0 // top/bottom rim high
17 9
18static const ColorEntry color_table[TABLE_COLORS] = 10static const ColorEntry color_table[TABLE_COLORS] =
19{ 11{
20 ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 1, 0 ), // Dfore, Dback 12 ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 1, 0 ), // Dfore, Dback
21 ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0x18), 0, 0 ), // Black, Red 13 ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0x18), 0, 0 ), // Black, Red
22 ColorEntry(QColor(0x18,0xB2,0x18), 0, 0 ), ColorEntry( QColor(0xB2,0x68,0x18), 0, 0 ), // Green, Yellow 14 ColorEntry(QColor(0x18,0xB2,0x18), 0, 0 ), ColorEntry( QColor(0xB2,0x68,0x18), 0, 0 ), // Green, Yellow
23 ColorEntry(QColor(0x18,0x18,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), // Blue, Magenta 15 ColorEntry(QColor(0x18,0x18,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), // Blue, Magenta
24 ColorEntry(QColor(0x18,0xB2,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 0, 0 ), // Cyan, White 16 ColorEntry(QColor(0x18,0xB2,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 0, 0 ), // Cyan, White
25 // intensiv 17 // intensiv
26 ColorEntry(QColor(0x00,0x00,0x00), 0, 1 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 1, 0 ), 18 ColorEntry(QColor(0x00,0x00,0x00), 0, 1 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 1, 0 ),
27 ColorEntry(QColor(0x68,0x68,0x68), 0, 0 ), ColorEntry( QColor(0xFF,0x54,0x54), 0, 0 ), 19 ColorEntry(QColor(0x68,0x68,0x68), 0, 0 ), ColorEntry( QColor(0xFF,0x54,0x54), 0, 0 ),
28 ColorEntry(QColor(0x54,0xFF,0x54), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0x54), 0, 0 ), 20 ColorEntry(QColor(0x54,0xFF,0x54), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0x54), 0, 0 ),
29 ColorEntry(QColor(0x54,0x54,0xFF), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), 21 ColorEntry(QColor(0x54,0x54,0xFF), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ),
30 ColorEntry(QColor(0x54,0xFF,0xFF), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 0, 0 ) 22 ColorEntry(QColor(0x54,0xFF,0xFF), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 0, 0 )
31}; 23};
32 24
33EmulationWidget::EmulationWidget( const Profile& config, QWidget *parent, const char* name ) : WidgetLayer( config, parent, name ) 25EmulationWidget::EmulationWidget( const Profile& config, QWidget *parent, const char* name ) : WidgetLayer( config, parent, name )
34{ 26{
35 27
36 // initialize font attributes 28 // initialize font attributes
37 QFontMetrics fm( font() ); 29 QFontMetrics fm( font() );
38 f_height = fm.height(); 30 f_height = fm.height();
39 f_width = fm.maxWidth(); 31 f_width = fm.maxWidth();
40 f_ascent = fm.ascent(); 32 f_ascent = fm.ascent();
41 33
42 34
43 // initialize scrollbar related vars 35 // initialize scrollbar related vars
44 m_scrollbar = new QScrollBar( this ); 36 m_scrollbar = new QScrollBar( this );
45 m_scrollbar->setCursor( arrowCursor ); 37 m_scrollbar->setCursor( arrowCursor );
46 38
47 // give reasonable defaults to m_columns, m_lines 39 // give reasonable defaults to m_columns, m_lines
48 calcGeometry(); 40 calcGeometry();
49 41
50 // load config 42 // load config
51 reloadConfig( config ); 43 reloadConfig( config );
52 44
53 m_resizing = false; 45 m_resizing = false;
54} 46}
55 47
56void EmulationWidget::reloadConfig( const Profile& config ) 48void EmulationWidget::reloadConfig( const Profile& config )
57{ 49{
58 50
59 // nothing yet 51 // nothing yet
60} 52}
61 53
62EmulationWidget::~EmulationWidget() 54EmulationWidget::~EmulationWidget()
63{ 55{
64 //clean up 56 //clean up
65} 57}
66 58
67static QChar vt100extended(QChar c) 59static QChar vt100extended(QChar c)
68{ 60{
69 switch (c.unicode()) 61 switch (c.unicode())
70 { 62 {
71 case 0x25c6 : return 1; 63 case 0x25c6 : return 1;
72 case 0x2592 : return 2; 64 case 0x2592 : return 2;
73 case 0x2409 : return 3; 65 case 0x2409 : return 3;
74 case 0x240c : return 4; 66 case 0x240c : return 4;
75 case 0x240d : return 5; 67 case 0x240d : return 5;
76 case 0x240a : return 6; 68 case 0x240a : return 6;
77 case 0x00b0 : return 7; 69 case 0x00b0 : return 7;
78 case 0x00b1 : return 8; 70 case 0x00b1 : return 8;
79 case 0x2424 : return 9; 71 case 0x2424 : return 9;
80 case 0x240b : return 10; 72 case 0x240b : return 10;
81 case 0x2518 : return 11; 73 case 0x2518 : return 11;
82 case 0x2510 : return 12; 74 case 0x2510 : return 12;
83 case 0x250c : return 13; 75 case 0x250c : return 13;
84 case 0x2514 : return 14; 76 case 0x2514 : return 14;
85 case 0x253c : return 15; 77 case 0x253c : return 15;
86 case 0xf800 : return 16; 78 case 0xf800 : return 16;
87 case 0xf801 : return 17; 79 case 0xf801 : return 17;
88 case 0x2500 : return 18; 80 case 0x2500 : return 18;
89 case 0xf803 : return 19; 81 case 0xf803 : return 19;
90 case 0xf804 : return 20; 82 case 0xf804 : return 20;
91 case 0x251c : return 21; 83 case 0x251c : return 21;
92 case 0x2524 : return 22; 84 case 0x2524 : return 22;
93 case 0x2534 : return 23; 85 case 0x2534 : return 23;
94 case 0x252c : return 24; 86 case 0x252c : return 24;
95 case 0x2502 : return 25; 87 case 0x2502 : return 25;
96 case 0x2264 : return 26; 88 case 0x2264 : return 26;
97 case 0x2265 : return 27; 89 case 0x2265 : return 27;
98 case 0x03c0 : return 28; 90 case 0x03c0 : return 28;
99 case 0x2260 : return 29; 91 case 0x2260 : return 29;
100 case 0x00a3 : return 30; 92 case 0x00a3 : return 30;
101 case 0x00b7 : return 31; 93 case 0x00b7 : return 31;
102 } 94 }
103 return c; 95 return c;
104} 96}
105 97
106 98
107QSize EmulationWidget::calcSize( int cols, int lins ) const 99QSize EmulationWidget::calcSize( int cols, int lins ) const
108{ 100{
109 int frw = width() - contentsRect().width(); 101 int frw = width() - contentsRect().width();
110 102
111 int frh = height() - contentsRect().height(); 103 int frh = height() - contentsRect().height();
112 int scw = (scrollLoc == SCRNONE? 0 : m_scrollbar->width() ); 104 int scw = (scrollLoc == SCRNONE? 0 : m_scrollbar->width() );
113 return QSize( f_width * cols + 2 * rimX + frw + scw, f_height * lins + 2 * rimY + frh ); 105 return QSize( f_width * cols + 2 * rimX + frw + scw, f_height * lins + 2 * rimY + frh );
114} 106}
115 107
116void EmulationWidget::setImage( QArray<Character> const newimg, int lines, int columns ) 108void EmulationWidget::setImage( QArray<Character> const newimg, int lines, int columns )
117{ 109{
118 const QPixmap* pm = backgroundPixmap(); 110 const QPixmap* pm = backgroundPixmap();
119 QPainter paint; 111 QPainter paint;
120 112
121 // dont allow updates, while drawing 113 // dont allow updates, while drawing
122 setUpdatesEnabled( false ); 114 setUpdatesEnabled( false );
123 115
124 paint.begin( this ); 116 paint.begin( this );
125 117
126 QPoint tL = contentsRect().topLeft(); 118 QPoint tL = contentsRect().topLeft();
127 int tLx = tL.x(); 119 int tLx = tL.x();
128 int tLy = tL.y(); 120 int tLy = tL.y();
129 //hasBlinker = false; 121 //hasBlinker = false;
130 122
131 int cf = -1; 123 int cf = -1;
132 int cb = -1; 124 int cb = -1;
133 int cr = -1; 125 int cr = -1;
134 126
135 int lins = QMIN( m_lines, QMAX( 0, lines ) ); 127 int lins = QMIN( m_lines, QMAX( 0, lines ) );
136 int cols = QMIN( m_columns, QMAX( 0, columns ) ); 128 int cols = QMIN( m_columns, QMAX( 0, columns ) );
137 QArray<QChar> disstrU = QArray<QChar>( cols ); 129 QArray<QChar> disstrU = QArray<QChar>( cols );
138 130
139 for ( int y = 0; y < lins; ++y ) 131 for ( int y = 0; y < lins; ++y )
140 {int len; 132 {int len;
141 const Character* lcl = &m_image[y * m_columns]; 133 const Character* lcl = &m_image[y * m_columns];
142 const Character* ext = &newimg[y * m_columns]; 134 const Character* ext = &newimg[y * m_columns];
143 if ( ! m_resizing ) 135 if ( ! m_resizing )
144 for ( int x = 0; x < cols; ++x ) 136 for ( int x = 0; x < cols; ++x )
145 { 137 {
146 // disable, till widget works, WITHOUT blinking 138 // disable, till widget works, WITHOUT blinking
147 //hasBlinker |= ( ext[x].r & RE_BLINK ); 139 //hasBlinker |= ( ext[x].r & RE_BLINK );
148 140
149 if ( ext[x] != lcl[x] ) 141 if ( ext[x] != lcl[x] )
150 { 142 {
151 cr = ext[x].r; 143 cr = ext[x].r;
152 cb = ext[x].b; 144 cb = ext[x].b;
153 if ( ext[x].f != cf ) cf = ext[x].f; 145 if ( ext[x].f != cf ) cf = ext[x].f;
154 int lln = cols - x; 146 int lln = cols - x;
155 disstrU[0] = vt100extended( ext[x+0].c ); 147 disstrU[0] = vt100extended( ext[x+0].c );
156 for ( len = 1; len < lln; ++len ) 148 for ( len = 1; len < lln; ++len )
157 { 149 {
158 if ( ext[x+len].f != cf || ext[x+len].b != cb || ext[x+len].r != cr || ext[x+len] == lcl[x+len] ) 150 if ( ext[x+len].f != cf || ext[x+len].b != cb || ext[x+len].r != cr || ext[x+len] == lcl[x+len] )
159 break; 151 break;
160 disstrU[len] = vt100extended( ext[x+len].c ); 152 disstrU[len] = vt100extended( ext[x+len].c );
161 } 153 }
162 QString unistr( disstrU, len ); 154 QString unistr( disstrU, len );
163 drawAttrString( unistr, paint, QRect( m_blX+tLx+f_width*x, m_bY+tLy+f_height*y, f_width*len, f_height ), ext[x], pm != NULL, true ); 155 drawAttrString( unistr, paint, QRect( m_blX+tLx+f_width*x, m_bY+tLy+f_height*y, f_width*len, f_height ), ext[x], pm != NULL, true );
164 x += len -1; 156 x += len -1;
165 } 157 }
166 } 158 }
167 // make image become newimg 159 // make image become newimg
168 memcpy( (void*) lcl, (const void*) ext, cols*sizeof( Character ) ); 160 memcpy( (void*) lcl, (const void*) ext, cols*sizeof( Character ) );
169 } 161 }
170 drawFrame( &paint ); 162 drawFrame( &paint );
171 paint.end(); 163 paint.end();
172 setUpdatesEnabled( true ); 164 setUpdatesEnabled( true );
173 165
174 /*if ( hasBlinker && !blinkT->isActive() ) 166 /*if ( hasBlinker && !blinkT->isActive() )
175 blinkT->start(1000); //ms 167 blinkT->start(1000); //ms
176 if ( ! hasBlinker && blinkT->isActive() ) 168 if ( ! hasBlinker && blinkT->isActive() )
177 { 169 {
178 blinkT->stop(); 170 blinkT->stop();
179 blinking = false; 171 blinking = false;
180 }*/ 172 }*/
181 173
182 delete [] disstrU; 174 delete [] disstrU;
183} 175}
184 176
185 177
186void EmulationWidget::paintEvent( QPaintEvent* pe ) 178void EmulationWidget::paintEvent( QPaintEvent* pe )
187{ 179{
188 QPainter painter; 180 QPainter painter;
189 const QPixmap* pm = backgroundPixmap(); 181 const QPixmap* pm = backgroundPixmap();
190 182
191 painter.begin( this ); 183 painter.begin( this );
192 painter.setBackgroundMode( TransparentMode ); 184 painter.setBackgroundMode( TransparentMode );
193 185
194 QRect rect = pe->rect().intersect( contentsRect() ); 186 QRect rect = pe->rect().intersect( contentsRect() );
195 QPoint tL = contentsRect().topLeft(); 187 QPoint tL = contentsRect().topLeft();
196 int tLx = tL.x(); 188 int tLx = tL.x();
197 int tLy = tL.y(); 189 int tLy = tL.y();
198 190
199 int lux = QMIN(m_columns-1, QMAX(0,(rect.left() - tLx - m_blX ) / f_width)); 191 int lux = QMIN(m_columns-1, QMAX(0,(rect.left() - tLx - m_blX ) / f_width));
200 int luy = QMIN(m_lines-1, QMAX(0,(rect.top() - tLy - m_bY ) / f_height)); 192 int luy = QMIN(m_lines-1, QMAX(0,(rect.top() - tLy - m_bY ) / f_height));
201 int rlx = QMIN(m_columns-1, QMAX(0,(rect.right() - tLx - m_blX ) / f_width)); 193 int rlx = QMIN(m_columns-1, QMAX(0,(rect.right() - tLx - m_blX ) / f_width));
202 int rly = QMIN(m_lines-1, QMAX(0,(rect.bottom() - tLy - m_bY ) / f_height)); 194 int rly = QMIN(m_lines-1, QMAX(0,(rect.bottom() - tLy - m_bY ) / f_height));
203 195
204 QChar *disstrU = new QChar[m_columns]; 196 QChar *disstrU = new QChar[m_columns];
205 for (int y = luy; y <= rly; y++) 197 for (int y = luy; y <= rly; y++)
206 for (int x = lux; x <= rlx; x++) 198 for (int x = lux; x <= rlx; x++)
207 { 199 {
208 int len = 1; 200 int len = 1;
209 disstrU[0] = vt100extended(m_image[loc(x,y)].c); 201 disstrU[0] = vt100extended(m_image[loc(x,y)].c);
210 int cf = m_image[loc(x,y)].f; 202 int cf = m_image[loc(x,y)].f;
211 int cb = m_image[loc(x,y)].b; 203 int cb = m_image[loc(x,y)].b;
212 int cr = m_image[loc(x,y)].r; 204 int cr = m_image[loc(x,y)].r;
213 while (x+len <= rlx && 205 while (x+len <= rlx &&
214 m_image[loc(x+len,y)].f == cf && 206 m_image[loc(x+len,y)].f == cf &&
215 m_image[loc(x+len,y)].b == cb && 207 m_image[loc(x+len,y)].b == cb &&
216 m_image[loc(x+len,y)].r == cr ) 208 m_image[loc(x+len,y)].r == cr )
217 { 209 {
218 disstrU[len] = vt100extended(m_image[loc(x+len,y)].c); 210 disstrU[len] = vt100extended(m_image[loc(x+len,y)].c);
219 len += 1; 211 len += 1;
220 } 212 }
221 QString unistr(disstrU,len); 213 QString unistr(disstrU,len);
222 214
223 drawAttrString( unistr, painter, QRect( m_blX+tLx+f_width*x,m_bY+tLy+f_height*y,f_width*len,f_height ), m_image[loc(x ,y )], pm != 0l, false ); 215 drawAttrString( unistr, painter, QRect( m_blX+tLx+f_width*x,m_bY+tLy+f_height*y,f_width*len,f_height ), m_image[loc(x ,y )], pm != 0l, false );
224 x +=len -1; 216 x +=len -1;
225 } 217 }
226 delete [] disstrU; 218 delete [] disstrU;
227 drawFrame( &painter ); 219 drawFrame( &painter );
228 painter.end(); 220 painter.end();
229} 221}
230 222
231void EmulationWidget::calcGeometry() 223void EmulationWidget::calcGeometry()
232{ 224{
233 m_scrollbar->resize(QApplication::style().scrollBarExtent().width(), contentsRect().height() ); 225 m_scrollbar->resize(QApplication::style().scrollBarExtent().width(), contentsRect().height() );
234 226
235 qDebug( QString(" TEST").arg( contentsRect().width() ) ); 227 qDebug( QString(" TEST").arg( contentsRect().width() ) );
236 qDebug( QString(" TEST").arg( contentsRect().height() ) ); 228 qDebug( QString(" TEST").arg( contentsRect().height() ) );
237 qDebug("NEUER TESTT!!!!!!!!"); 229 qDebug("NEUER TESTT!!!!!!!!");
238 230
239 switch( scrollLoc ) 231 switch( scrollLoc )
240 { 232 {
241 case SCRNONE : 233 case SCRNONE :
242 m_columns = ( contentsRect().width() -2 * rimX ) / f_width; 234 m_columns = ( contentsRect().width() -2 * rimX ) / f_width;
243 m_blX = ( contentsRect().width() - ( m_columns*f_width ) ) / 2; 235 m_blX = ( contentsRect().width() - ( m_columns*f_width ) ) / 2;
244 m_brX = m_blX; 236 m_brX = m_blX;
245 m_scrollbar->hide(); 237 m_scrollbar->hide();
246 break; 238 break;
247 case SCRLEFT : 239 case SCRLEFT :
248 m_columns = ( contentsRect().width() - 2 * rimX - m_scrollbar->width() ) / f_width; 240 m_columns = ( contentsRect().width() - 2 * rimX - m_scrollbar->width() ) / f_width;
249 m_brX = ( contentsRect().width() - ( m_columns*f_width ) - m_scrollbar->width() ) / 2; 241 m_brX = ( contentsRect().width() - ( m_columns*f_width ) - m_scrollbar->width() ) / 2;
250 m_blX = m_brX + m_scrollbar->width(); 242 m_blX = m_brX + m_scrollbar->width();
251 m_scrollbar->move( contentsRect().topLeft() ); 243 m_scrollbar->move( contentsRect().topLeft() );
252 m_scrollbar->show(); 244 m_scrollbar->show();
253 break; 245 break;
254 case SCRIGHT: 246 case SCRIGHT:
255 m_columns = ( contentsRect().width() - 2 * rimX - m_scrollbar->width() ) / f_width; 247 m_columns = ( contentsRect().width() - 2 * rimX - m_scrollbar->width() ) / f_width;
256 m_blX = ( contentsRect().width() - ( m_columns*f_width ) - m_scrollbar->width() ) / 2; 248 m_blX = ( contentsRect().width() - ( m_columns*f_width ) - m_scrollbar->width() ) / 2;
257 m_brX = m_blX; 249 m_brX = m_blX;
258 m_scrollbar->move( contentsRect().topRight() - QPoint (m_scrollbar->width()-1,0 ) ); 250 m_scrollbar->move( contentsRect().topRight() - QPoint (m_scrollbar->width()-1,0 ) );
259 m_scrollbar->show(); 251 m_scrollbar->show();
260 break; 252 break;
261 } 253 }
262 254
263 m_lines = ( contentsRect().height() - 2 * rimY ) / f_height; 255 m_lines = ( contentsRect().height() - 2 * rimY ) / f_height;
264 m_bY = ( contentsRect().height() - (m_lines * f_height ) ) / 2; 256 m_bY = ( contentsRect().height() - (m_lines * f_height ) ) / 2;
265} 257}
266 258
267void EmulationWidget::drawAttrString( QString& string, QPainter &painter, QRect rect, Character attr, bool usePixmap, bool clear ) 259void EmulationWidget::drawAttrString( QString& string, QPainter &painter, QRect rect, Character attr, bool usePixmap, bool clear )
268{ 260{
269 qWarning("Color1 %s", color_table[attr.b].color.name().latin1() ); 261 qWarning("Color1 %s", color_table[attr.b].color.name().latin1() );
270 if ( usePixmap && color_table[attr.b].transparent ) 262 if ( usePixmap && color_table[attr.b].transparent )
271 { 263 {
272 painter.setBackgroundMode( TransparentMode ); 264 painter.setBackgroundMode( TransparentMode );
273 if ( clear ) 265 if ( clear )
274 erase( rect ); 266 erase( rect );
275 } 267 }
276 else 268 else
277 { 269 {
278 if ( blinking ) 270 if ( blinking )
279 painter.fillRect( rect, color_table[attr.b].color ); 271 painter.fillRect( rect, color_table[attr.b].color );
280 else 272 else
281 { 273 {
282 painter.setBackgroundMode( OpaqueMode ); 274 painter.setBackgroundMode( OpaqueMode );
283 qWarning("Color %s", color_table[attr.b].color.name().latin1() ); 275 qWarning("Color %s", color_table[attr.b].color.name().latin1() );
284 painter.setBackgroundColor( color_table[attr.b].color ); 276 painter.setBackgroundColor( color_table[attr.b].color );
285 } 277 }
286 } 278 }
287 if ( color_table[attr.f].bold ) 279 if ( color_table[attr.f].bold )
288 painter.setPen( QColor( 0x8F, 0x00, 0x00 ) ); 280 painter.setPen( QColor( 0x8F, 0x00, 0x00 ) );
289 else 281 else
290 painter.setPen( color_table[attr.f].color ); 282 painter.setPen( color_table[attr.f].color );
291 painter.drawText( rect.x(), rect.y() + f_ascent, string ); 283 painter.drawText( rect.x(), rect.y() + f_ascent, string );
292 284
293} 285}
294 286
295 287
296/////////////////////// 288///////////////////////
297// scrollbar 289// scrollbar
298// //////////////////// 290// ////////////////////
299 291
300void EmulationWidget::scroll( int value ) 292void EmulationWidget::scroll( int value )
301{ 293{
302} 294}
303 295
304void EmulationWidget::setScroll( int cursor, int slines ) 296void EmulationWidget::setScroll( int cursor, int slines )
305{ 297{
306} 298}
307 299
308 300
309 301
diff --git a/noncore/apps/opie-console/file_layer.cpp b/noncore/apps/opie-console/file_layer.cpp
index 0c83700..9ddef80 100644
--- a/noncore/apps/opie-console/file_layer.cpp
+++ b/noncore/apps/opie-console/file_layer.cpp
@@ -1,23 +1,22 @@
1#include <qfile.h>
2#include <opie/oprocess.h> 1#include <opie/oprocess.h>
3 2
4#include "file_layer.h" 3#include "file_layer.h"
5 4
6FileTransferLayer::FileTransferLayer(IOLayer *layer) 5FileTransferLayer::FileTransferLayer(IOLayer *layer)
7 : QObject(), m_layer( layer ) 6 : QObject(), m_layer( layer )
8{ 7{
9} 8}
10 9
11FileTransferLayer::~FileTransferLayer() { 10FileTransferLayer::~FileTransferLayer() {
12} 11}
13 12
14void FileTransferLayer::sendFile(const QFile&) { 13void FileTransferLayer::sendFile(const QFile&) {
15 14
16} 15}
17 16
18void FileTransferLayer::sendFile(const QString&) { 17void FileTransferLayer::sendFile(const QString&) {
19} 18}
20 19
21IOLayer* FileTransferLayer::layer() { 20IOLayer* FileTransferLayer::layer() {
22 return m_layer; 21 return m_layer;
23} 22}
diff --git a/noncore/apps/opie-console/filetransfer.cpp b/noncore/apps/opie-console/filetransfer.cpp
index 5144941..347d6e0 100644
--- a/noncore/apps/opie-console/filetransfer.cpp
+++ b/noncore/apps/opie-console/filetransfer.cpp
@@ -1,251 +1,250 @@
1#include <stdio.h> 1#include <stdio.h>
2#include <stdlib.h> 2#include <stdlib.h>
3#include <errno.h> 3#include <errno.h>
4#include <fcntl.h> 4#include <fcntl.h>
5#include <unistd.h> 5#include <unistd.h>
6 6
7#include <qcstring.h>
8#include <qsocketnotifier.h> 7#include <qsocketnotifier.h>
9 8
10#include <opie/oprocess.h> 9#include <opie/oprocess.h>
11 10
12#include "procctl.h" 11#include "procctl.h"
13#include "filetransfer.h" 12#include "filetransfer.h"
14 13
15 14
16FileTransfer::FileTransfer( Type t, IOLayer* lay ) 15FileTransfer::FileTransfer( Type t, IOLayer* lay )
17 : FileTransferLayer( lay ), m_type( t ), m_pid ( 0 ) { 16 : FileTransferLayer( lay ), m_type( t ), m_pid ( 0 ) {
18 signal(SIGPIPE, SIG_IGN ); 17 signal(SIGPIPE, SIG_IGN );
19 18
20 m_pid = 0; 19 m_pid = 0;
21 m_not = 0l; 20 m_not = 0l;
22 m_proc = 0l; 21 m_proc = 0l;
23} 22}
24FileTransfer::~FileTransfer() { 23FileTransfer::~FileTransfer() {
25} 24}
26 25
27/** 26/**
28 * now we will send the file. 27 * now we will send the file.
29 * 28 *
30 * we request an fd. The IOLayer should be closed 29 * we request an fd. The IOLayer should be closed
31 * then we will setup a pipe for progress communication 30 * then we will setup a pipe for progress communication
32 * then we will dup2 the m_fd in the forked process 31 * then we will dup2 the m_fd in the forked process
33 * to do direct IO from and to the fd 32 * to do direct IO from and to the fd
34 */ 33 */
35void FileTransfer::sendFile( const QString& file ) { 34void FileTransfer::sendFile( const QString& file ) {
36 m_prog =-1; 35 m_prog =-1;
37 m_fd = layer()->rawIO(); 36 m_fd = layer()->rawIO();
38// 37//
39// m_fd = ::open("/dev/ttyS0", O_RDWR); 38// m_fd = ::open("/dev/ttyS0", O_RDWR);
40 39
41 m_file = file; 40 m_file = file;
42 if ( pipe( m_comm ) < 0 ) 41 if ( pipe( m_comm ) < 0 )
43 m_comm[0] = m_comm[1] = 0; 42 m_comm[0] = m_comm[1] = 0;
44 if ( pipe( m_info ) < 0 ) 43 if ( pipe( m_info ) < 0 )
45 m_info[0] = m_info[1] = 0; 44 m_info[0] = m_info[1] = 0;
46 45
47 46
48 m_pid = fork(); 47 m_pid = fork();
49 switch( m_pid ) { 48 switch( m_pid ) {
50 case -1: 49 case -1:
51 emit error( StartError, tr("Was not able to fork") ); 50 emit error( StartError, tr("Was not able to fork") );
52 slotExec(); 51 slotExec();
53 break; 52 break;
54 case 0:{ 53 case 0:{
55 setupChild(); 54 setupChild();
56 /* exec */ 55 /* exec */
57 char* verbose = "-vv"; 56 char* verbose = "-vv";
58 char* binray = "-b"; 57 char* binray = "-b";
59 58
60 59
61 char* typus; 60 char* typus;
62 switch(m_type ) { 61 switch(m_type ) {
63 default: 62 default:
64 case SZ: 63 case SZ:
65 typus = ""; 64 typus = "";
66 break; 65 break;
67 case SX: 66 case SX:
68 typus = "-X"; 67 typus = "-X";
69 break; 68 break;
70 case SY: 69 case SY:
71 typus = "--ymodem"; 70 typus = "--ymodem";
72 break; 71 break;
73 } 72 }
74 73
75 /* we should never return from here */ 74 /* we should never return from here */
76 execlp("sz", "sz", verbose, binray, file.latin1(), typus, NULL ); 75 execlp("sz", "sz", verbose, binray, file.latin1(), typus, NULL );
77 76
78 /* communication for error!*/ 77 /* communication for error!*/
79 char resultByte =1; 78 char resultByte =1;
80 if (m_info[1] ) 79 if (m_info[1] )
81 write(m_info[1], &resultByte, 1 ); 80 write(m_info[1], &resultByte, 1 );
82 _exit( -1 ); 81 _exit( -1 );
83 break; 82 break;
84 } 83 }
85 default:{ 84 default:{
86 if ( m_info[1] ) 85 if ( m_info[1] )
87 close( m_info[1] ); 86 close( m_info[1] );
88 if ( m_info[0] ) for (;;) { 87 if ( m_info[0] ) for (;;) {
89 char resultByte; int len; 88 char resultByte; int len;
90 len = read(m_info[0], &resultByte, 1 ); 89 len = read(m_info[0], &resultByte, 1 );
91 /* len == 1 start up failed */ 90 /* len == 1 start up failed */
92 if ( len == 1 ) { 91 if ( len == 1 ) {
93 emit error( StartError, tr("Could not start") ); 92 emit error( StartError, tr("Could not start") );
94 return; 93 return;
95 } 94 }
96 if ( len == -1 ) 95 if ( len == -1 )
97 if ( (errno == ECHILD ) || (errno == EINTR ) ) 96 if ( (errno == ECHILD ) || (errno == EINTR ) )
98 continue; 97 continue;
99 98
100 // len == 0 or something like this 99 // len == 0 or something like this
101 break; 100 break;
102 } 101 }
103 if ( m_info[0] ) 102 if ( m_info[0] )
104 close( m_info[0] ); 103 close( m_info[0] );
105 104
106 105
107 106
108 /* replace by QSocketNotifier!!! */ 107 /* replace by QSocketNotifier!!! */
109 m_not = new QSocketNotifier(m_comm[0], QSocketNotifier::Read ); 108 m_not = new QSocketNotifier(m_comm[0], QSocketNotifier::Read );
110 connect(m_not, SIGNAL(activated(int) ), 109 connect(m_not, SIGNAL(activated(int) ),
111 this, SLOT(slotRead() ) ); 110 this, SLOT(slotRead() ) );
112 if ( pipe(m_term) < 0 ) 111 if ( pipe(m_term) < 0 )
113 m_term[0] = m_term[1] = 0; 112 m_term[0] = m_term[1] = 0;
114 113
115 ProcCtl::self()->add(m_pid, m_term[1] ); 114 ProcCtl::self()->add(m_pid, m_term[1] );
116 m_proc = new QSocketNotifier(m_term[0], QSocketNotifier::Read ); 115 m_proc = new QSocketNotifier(m_term[0], QSocketNotifier::Read );
117 connect(m_proc, SIGNAL(activated(int) ), 116 connect(m_proc, SIGNAL(activated(int) ),
118 this, SLOT(slotExec() ) ); 117 this, SLOT(slotExec() ) );
119 118
120 } 119 }
121 break; 120 break;
122 } 121 }
123} 122}
124/* 123/*
125 * let's call the one with the filename 124 * let's call the one with the filename
126 */ 125 */
127void FileTransfer::sendFile( const QFile& file ) { 126void FileTransfer::sendFile( const QFile& file ) {
128 sendFile( file.name() ); 127 sendFile( file.name() );
129} 128}
130 129
131/* 130/*
132 * setting up communication 131 * setting up communication
133 * between parent child and ioLayer 132 * between parent child and ioLayer
134 */ 133 */
135void FileTransfer::setupChild() { 134void FileTransfer::setupChild() {
136 /* 135 /*
137 * we do not want to read from our 136 * we do not want to read from our
138 * information channel 137 * information channel
139 */ 138 */
140 if (m_info[0] ) 139 if (m_info[0] )
141 close(m_info[0] ); 140 close(m_info[0] );
142 /* 141 /*
143 * FD_CLOEXEC will close the 142 * FD_CLOEXEC will close the
144 * fd on successful exec 143 * fd on successful exec
145 */ 144 */
146 if (m_info[1] ) 145 if (m_info[1] )
147 fcntl(m_info[1], F_SETFD, FD_CLOEXEC ); 146 fcntl(m_info[1], F_SETFD, FD_CLOEXEC );
148 147
149 if (m_comm[0] ) 148 if (m_comm[0] )
150 close( m_comm[0] ); 149 close( m_comm[0] );
151 /* 150 /*
152 * now set the communication 151 * now set the communication
153 * m_fd STDIN_FILENO 152 * m_fd STDIN_FILENO
154 * STDOUT_FILENO 153 * STDOUT_FILENO
155 * STDERR_FILENO 154 * STDERR_FILENO
156 */ 155 */
157 dup2( m_fd, STDIN_FILENO ); 156 dup2( m_fd, STDIN_FILENO );
158 dup2( m_fd, STDOUT_FILENO ); 157 dup2( m_fd, STDOUT_FILENO );
159 dup2( m_comm[1], STDERR_FILENO ); 158 dup2( m_comm[1], STDERR_FILENO );
160} 159}
161 160
162/* 161/*
163 * read from the stderr of the child 162 * read from the stderr of the child
164 * process 163 * process
165 */ 164 */
166void FileTransfer::slotRead() { 165void FileTransfer::slotRead() {
167 QByteArray ar(4096); 166 QByteArray ar(4096);
168 int len = read(m_comm[0], ar.data(), 4096 ); 167 int len = read(m_comm[0], ar.data(), 4096 );
169 for (int i = 0; i < len; i++ ) { 168 for (int i = 0; i < len; i++ ) {
170 // printf("%c", ar[i] ); 169 // printf("%c", ar[i] );
171 } 170 }
172 ar.resize( len ); 171 ar.resize( len );
173 QString str( ar ); 172 QString str( ar );
174 QStringList lis = QStringList::split(' ', str ); 173 QStringList lis = QStringList::split(' ', str );
175 /* 174 /*
176 * Transfer finished.. either complete or incomplete 175 * Transfer finished.. either complete or incomplete
177 */ 176 */
178 if ( lis[0].simplifyWhiteSpace() == "Transfer" ) { 177 if ( lis[0].simplifyWhiteSpace() == "Transfer" ) {
179 return; 178 return;
180 } 179 }
181 /* 180 /*
182 * do progress reading 181 * do progress reading
183 */ 182 */
184 slotProgress( lis ); 183 slotProgress( lis );
185 184
186 185
187} 186}
188/* 187/*
189 * find the progress 188 * find the progress
190 */ 189 */
191void FileTransfer::slotProgress( const QStringList& list ) { 190void FileTransfer::slotProgress( const QStringList& list ) {
192 if ( m_type != SZ ) 191 if ( m_type != SZ )
193 return; 192 return;
194 bool complete = true; 193 bool complete = true;
195 int min, sec; 194 int min, sec;
196 int bps; 195 int bps;
197 unsigned long sent, total; 196 unsigned long sent, total;
198 197
199 min = sec = bps = -1; 198 min = sec = bps = -1;
200 sent = total = 0; 199 sent = total = 0;
201 200
202 // Data looks like this 201 // Data looks like this
203 // 0 1 2 3 4 5 202 // 0 1 2 3 4 5
204 // Bytes Sent 65536/11534336 BPS:7784 ETA 24:33 203 // Bytes Sent 65536/11534336 BPS:7784 ETA 24:33
205 QStringList progi = QStringList::split('/', list[2].simplifyWhiteSpace() ); 204 QStringList progi = QStringList::split('/', list[2].simplifyWhiteSpace() );
206 sent = progi[0].toULong(&complete ); 205 sent = progi[0].toULong(&complete );
207 if (!complete ) return; 206 if (!complete ) return;
208 207
209 total = progi[1].toULong(&complete ); 208 total = progi[1].toULong(&complete );
210 if (!complete || total == 0) { 209 if (!complete || total == 0) {
211 return; 210 return;
212 } 211 }
213 212
214 213
215 double pro = (double)sent/total; 214 double pro = (double)sent/total;
216 int prog = pro * 100; 215 int prog = pro * 100;
217 216
218 // speed 217 // speed
219 progi = QStringList::split(':', list[3].simplifyWhiteSpace() ); 218 progi = QStringList::split(':', list[3].simplifyWhiteSpace() );
220 bps = progi[1].toInt(); 219 bps = progi[1].toInt();
221 220
222 // time 221 // time
223 progi = QStringList::split(':', list[5].simplifyWhiteSpace() ); 222 progi = QStringList::split(':', list[5].simplifyWhiteSpace() );
224 min = progi[0].toInt(); 223 min = progi[0].toInt();
225 sec = progi[1].toInt(); 224 sec = progi[1].toInt();
226 225
227 226
228 if ( prog > m_prog ) { 227 if ( prog > m_prog ) {
229 m_prog = prog; 228 m_prog = prog;
230 emit progress(m_file, m_prog, bps, -1, min , sec ); 229 emit progress(m_file, m_prog, bps, -1, min , sec );
231 } 230 }
232 231
233} 232}
234void FileTransfer::cancel() { 233void FileTransfer::cancel() {
235 if(m_pid > 0) ::kill(m_pid,9 ); 234 if(m_pid > 0) ::kill(m_pid,9 );
236 235
237} 236}
238void FileTransfer::slotExec() { 237void FileTransfer::slotExec() {
239 char buf[2]; 238 char buf[2];
240 ::read(m_term[0], buf, 1 ); 239 ::read(m_term[0], buf, 1 );
241 delete m_proc; 240 delete m_proc;
242 delete m_not; 241 delete m_not;
243 m_proc = m_not = 0l; 242 m_proc = m_not = 0l;
244 close( m_term[0] ); 243 close( m_term[0] );
245 close( m_term[1] ); 244 close( m_term[1] );
246 close( m_comm[0] ); 245 close( m_comm[0] );
247 close( m_comm[1] ); 246 close( m_comm[1] );
248 layer()->closeRawIO( m_fd ); 247 layer()->closeRawIO( m_fd );
249 emit sent(); 248 emit sent();
250 m_pid = 0; 249 m_pid = 0;
251} 250}
diff --git a/noncore/apps/opie-console/function_keyboard.cpp b/noncore/apps/opie-console/function_keyboard.cpp
index 0191915..c232d89 100644
--- a/noncore/apps/opie-console/function_keyboard.cpp
+++ b/noncore/apps/opie-console/function_keyboard.cpp
@@ -1,434 +1,426 @@
1#include "function_keyboard.h" 1#include "function_keyboard.h"
2 2
3#include <qpe/resource.h>
4#include <qpe/qpeapplication.h>
5#include <qsizepolicy.h>
6#include <qevent.h>
7#include <qwindowsystem_qws.h>
8#include <qapplication.h>
9#include <qlayout.h> 3#include <qlayout.h>
10#include <qspinbox.h>
11#include <qlistbox.h> 4#include <qlistbox.h>
12#include <qlabel.h> 5#include <qlabel.h>
13#include <qcombobox.h>
14#include <qdir.h> 6#include <qdir.h>
15 7
16#define DEFAULT_ROWS 2 8#define DEFAULT_ROWS 2
17#define DEFAULT_COLS 12 9#define DEFAULT_COLS 12
18 10
19/* FunctionKeyboard {{{1 */ 11/* FunctionKeyboard {{{1 */
20 12
21FunctionKeyboard::FunctionKeyboard(QWidget *parent) : 13FunctionKeyboard::FunctionKeyboard(QWidget *parent) :
22 QFrame(parent), numRows(DEFAULT_ROWS), numCols(DEFAULT_COLS), 14 QFrame(parent), numRows(DEFAULT_ROWS), numCols(DEFAULT_COLS),
23 pressedRow(0), pressedCol(0) { 15 pressedRow(0), pressedCol(0) {
24 16
25 setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed)); 17 setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed));
26 18
27 /* 19 /*
28 * all the saving/loading is now done in a profile. downside is that you cant modify 20 * all the saving/loading is now done in a profile. downside is that you cant modify
29 * the keyboard for all profiles, but must do it on a profile-basis 21 * the keyboard for all profiles, but must do it on a profile-basis
30 * 22 *
31 23
32 Config conf("opie-console-keys"); 24 Config conf("opie-console-keys");
33 conf.setGroup("keys"); 25 conf.setGroup("keys");
34 for (uint r = 0; r < numRows; r++) 26 for (uint r = 0; r < numRows; r++)
35 for (uint c = 0; c < numCols; c++) { 27 for (uint c = 0; c < numCols; c++) {
36 28
37 QString handle = "r" + QString::number(r) + "c" + QString::number(c); 29 QString handle = "r" + QString::number(r) + "c" + QString::number(c);
38 QStringList value_list = conf.readListEntry( handle, '|'); 30 QStringList value_list = conf.readListEntry( handle, '|');
39 31
40 if (value_list.isEmpty()) continue; 32 if (value_list.isEmpty()) continue;
41 33
42 keys.insert( 34 keys.insert(
43 35
44 handle, 36 handle,
45 FKey (value_list[0], value_list[1], value_list[2].toUShort(), value_list[3].toUShort()) 37 FKey (value_list[0], value_list[1], value_list[2].toUShort(), value_list[3].toUShort())
46 ); 38 );
47 } 39 }
48 //qWarning("loaded %d keys", keys.count()); 40 //qWarning("loaded %d keys", keys.count());
49 */ 41 */
50 if (keys.isEmpty()) loadDefaults(); 42 if (keys.isEmpty()) loadDefaults();
51 43
52 44
53 45
54} 46}
55 47
56FunctionKeyboard::~FunctionKeyboard() {} 48FunctionKeyboard::~FunctionKeyboard() {}
57 49
58void FunctionKeyboard::changeRows(int r) { 50void FunctionKeyboard::changeRows(int r) {
59 51
60 numRows = r; 52 numRows = r;
61 53
62 // have to do this so the whole thing gets redrawn 54 // have to do this so the whole thing gets redrawn
63 hide(); show(); 55 hide(); show();
64} 56}
65void FunctionKeyboard::changeCols(int c) { 57void FunctionKeyboard::changeCols(int c) {
66 58
67 numCols = c; 59 numCols = c;
68 keyWidth = (double)width()/numCols; // have to reset this thing too 60 keyWidth = (double)width()/numCols; // have to reset this thing too
69 repaint(false); 61 repaint(false);
70} 62}
71void FunctionKeyboard::load (const Profile& prof) { 63void FunctionKeyboard::load (const Profile& prof) {
72 64
73 keys.clear(); 65 keys.clear();
74 66
75 numRows = prof.readNumEntry("keb_rows", 2); 67 numRows = prof.readNumEntry("keb_rows", 2);
76 numCols = prof.readNumEntry("keb_cols", 10); 68 numCols = prof.readNumEntry("keb_cols", 10);
77 keyWidth = (double)width()/numCols; // have to reset this thing too 69 keyWidth = (double)width()/numCols; // have to reset this thing too
78 70
79 /* load all the keys to the keyboard */ 71 /* load all the keys to the keyboard */
80 for (ushort i = 0; i <= numRows - 1; i++) 72 for (ushort i = 0; i <= numRows - 1; i++)
81 for (ushort j = 0; j <= numCols - 1; j++) { 73 for (ushort j = 0; j <= numCols - 1; j++) {
82 74
83 QString h = "r" + QString::number(i) + "c" + QString::number(j); 75 QString h = "r" + QString::number(i) + "c" + QString::number(j);
84 QString values = prof.readEntry("keb_" + h); 76 QString values = prof.readEntry("keb_" + h);
85 77
86 if (!values.isEmpty()) { 78 if (!values.isEmpty()) {
87 79
88 QStringList l = QStringList::split(QChar('|'), values, TRUE); 80 QStringList l = QStringList::split(QChar('|'), values, TRUE);
89 keys[h] = FKey(l[0], l[1], l[2].toInt(), l[3].toInt()); 81 keys[h] = FKey(l[0], l[1], l[2].toInt(), l[3].toInt());
90 82
91 // load pixmap if used 83 // load pixmap if used
92 if (!l[1].isEmpty()) { 84 if (!l[1].isEmpty()) {
93 85
94 keys[h].pix = new QPixmap( Resource::loadPixmap( "console/keys/" + l[1] ) ); 86 keys[h].pix = new QPixmap( Resource::loadPixmap( "console/keys/" + l[1] ) );
95 } 87 }
96 } 88 }
97 } 89 }
98 90
99 if (keys.isEmpty()) loadDefaults(); 91 if (keys.isEmpty()) loadDefaults();
100 92
101 hide(); 93 hide();
102 show(); 94 show();
103 95
104} 96}
105 97
106void FunctionKeyboard::paintEvent(QPaintEvent *e) { 98void FunctionKeyboard::paintEvent(QPaintEvent *e) {
107 99
108 QPainter p(this); 100 QPainter p(this);
109 p.setClipRect(e->rect()); 101 p.setClipRect(e->rect());
110 p.fillRect(0, 0, width(), height(), QColor(255,255,255)); 102 p.fillRect(0, 0, width(), height(), QColor(255,255,255));
111 103
112 p.setPen(QColor(0,0,0)); 104 p.setPen(QColor(0,0,0));
113 105
114 /* those decimals do count! becomes short if use plain int */ 106 /* those decimals do count! becomes short if use plain int */
115 for (double i = 0; i <= width(); i += keyWidth) { 107 for (double i = 0; i <= width(); i += keyWidth) {
116 108
117 p.drawLine((int)i, 0, (int)i, height()); 109 p.drawLine((int)i, 0, (int)i, height());
118 } 110 }
119 111
120 // sometimes the last line doesnt get drawn 112 // sometimes the last line doesnt get drawn
121 p.drawLine(width() -1, 0, width() -1, height()); 113 p.drawLine(width() -1, 0, width() -1, height());
122 114
123 for (int i = 0; i <= height(); i += keyHeight) { 115 for (int i = 0; i <= height(); i += keyHeight) {
124 116
125 p.drawLine(0, i, width(), i); 117 p.drawLine(0, i, width(), i);
126 } 118 }
127 119
128 for (uint r = 0; r < numRows; r++) { 120 for (uint r = 0; r < numRows; r++) {
129 for (uint c = 0; c < numCols; c++) { 121 for (uint c = 0; c < numCols; c++) {
130 122
131 QString handle = "r" + QString::number(r) + "c" + QString::number(c); 123 QString handle = "r" + QString::number(r) + "c" + QString::number(c);
132 if (keys.contains(handle)) { 124 if (keys.contains(handle)) {
133 125
134 if (keys[handle].pixFile.isEmpty()) 126 if (keys[handle].pixFile.isEmpty())
135 p.drawText( c * keyWidth + 1, r * keyHeight + 1, 127 p.drawText( c * keyWidth + 1, r * keyHeight + 1,
136 keyWidth, keyHeight, 128 keyWidth, keyHeight,
137 Qt::AlignHCenter | Qt::AlignVCenter, 129 Qt::AlignHCenter | Qt::AlignVCenter,
138 keys[handle].label 130 keys[handle].label
139 ); 131 );
140 else { 132 else {
141 133
142 ushort centerX = (ushort)(c *keyWidth) + (ushort)(keyWidth - keys[handle].pix->width()) / 2; 134 ushort centerX = (ushort)(c *keyWidth) + (ushort)(keyWidth - keys[handle].pix->width()) / 2;
143 ushort centerY = r * keyHeight + (keyHeight - keys[handle].pix->height()) / 2; 135 ushort centerY = r * keyHeight + (keyHeight - keys[handle].pix->height()) / 2;
144 p.drawPixmap(centerX, centerY, *keys[handle].pix); 136 p.drawPixmap(centerX, centerY, *keys[handle].pix);
145 } 137 }
146 } 138 }
147 } 139 }
148 } 140 }
149} 141}
150 142
151void FunctionKeyboard::paintKey(uint row, uint col) { 143void FunctionKeyboard::paintKey(uint row, uint col) {
152 144
153 QPainter p(this); 145 QPainter p(this);
154 146
155 p.fillRect(QRect(QPoint(col * keyWidth + 1, row * keyHeight + 1), 147 p.fillRect(QRect(QPoint(col * keyWidth + 1, row * keyHeight + 1),
156 QPoint((col + 1) * keyWidth - 1, row * keyHeight + keyHeight- 1)), 148 QPoint((col + 1) * keyWidth - 1, row * keyHeight + keyHeight- 1)),
157 (pressedRow != -1 && pressedCol != -1 ) ? QColor(97,119,155) : QColor(255,255,255)); 149 (pressedRow != -1 && pressedCol != -1 ) ? QColor(97,119,155) : QColor(255,255,255));
158 150
159 QString handle ("r" + QString::number(row) + "c" + QString::number(col)); 151 QString handle ("r" + QString::number(row) + "c" + QString::number(col));
160 if (keys[handle].pixFile.isEmpty()) 152 if (keys[handle].pixFile.isEmpty())
161 p.drawText( 153 p.drawText(
162 col * keyWidth + 1, row * keyHeight + 1, 154 col * keyWidth + 1, row * keyHeight + 1,
163 keyWidth, keyHeight, 155 keyWidth, keyHeight,
164 Qt::AlignHCenter | Qt::AlignVCenter, 156 Qt::AlignHCenter | Qt::AlignVCenter,
165 keys[handle].label 157 keys[handle].label
166 ); 158 );
167 else { 159 else {
168 160
169 ushort centerX = (ushort)(col *keyWidth) + (ushort)(keyWidth - keys[handle].pix->width()) / 2; 161 ushort centerX = (ushort)(col *keyWidth) + (ushort)(keyWidth - keys[handle].pix->width()) / 2;
170 ushort centerY = row * keyHeight + (keyHeight - keys[handle].pix->height()) / 2; 162 ushort centerY = row * keyHeight + (keyHeight - keys[handle].pix->height()) / 2;
171 p.drawPixmap(centerX, centerY, *keys[handle].pix); 163 p.drawPixmap(centerX, centerY, *keys[handle].pix);
172 } 164 }
173 165
174 if (col == numCols - 1) { 166 if (col == numCols - 1) {
175 167
176 // sometimes it doesnt draw the last line 168 // sometimes it doesnt draw the last line
177 169
178 p.drawLine((col+1) * keyWidth -1, row * keyHeight, 170 p.drawLine((col+1) * keyWidth -1, row * keyHeight,
179 (col+1) * keyWidth -1, (row + 1) * keyHeight 171 (col+1) * keyWidth -1, (row + 1) * keyHeight
180 ); 172 );
181 } 173 }
182 174
183} 175}
184 176
185void FunctionKeyboard::mousePressEvent(QMouseEvent *e) { 177void FunctionKeyboard::mousePressEvent(QMouseEvent *e) {
186 178
187 pressedRow = e->y() / keyHeight; 179 pressedRow = e->y() / keyHeight;
188 pressedCol = (int) (e->x() / keyWidth); 180 pressedCol = (int) (e->x() / keyWidth);
189 181
190 paintKey(pressedRow, pressedCol); 182 paintKey(pressedRow, pressedCol);
191 183
192 // emit that sucker! 184 // emit that sucker!
193 FKey k = keys["r" + QString::number(pressedRow) + "c" + QString::number(pressedCol)]; 185 FKey k = keys["r" + QString::number(pressedRow) + "c" + QString::number(pressedCol)];
194 emit keyPressed(k, pressedRow, pressedCol, 1); 186 emit keyPressed(k, pressedRow, pressedCol, 1);
195 187
196} 188}
197 189
198void FunctionKeyboard::mouseReleaseEvent(QMouseEvent *) { 190void FunctionKeyboard::mouseReleaseEvent(QMouseEvent *) {
199 191
200 if (pressedRow != -1 && pressedRow != -1) { 192 if (pressedRow != -1 && pressedRow != -1) {
201 193
202 int row = pressedRow; pressedRow = -1; 194 int row = pressedRow; pressedRow = -1;
203 int col = pressedCol; pressedCol = -1; 195 int col = pressedCol; pressedCol = -1;
204 paintKey(row, col); 196 paintKey(row, col);
205 197
206 FKey k = keys["r" + QString::number(row) + "c" + QString::number(col)]; 198 FKey k = keys["r" + QString::number(row) + "c" + QString::number(col)];
207 emit keyPressed(k, row, col, 0); 199 emit keyPressed(k, row, col, 0);
208 } 200 }
209 201
210} 202}
211 203
212 204
213void FunctionKeyboard::resizeEvent(QResizeEvent*) { 205void FunctionKeyboard::resizeEvent(QResizeEvent*) {
214 206
215 /* set he default font height/width */ 207 /* set he default font height/width */
216 QFontMetrics fm=fontMetrics(); 208 QFontMetrics fm=fontMetrics();
217 keyHeight = fm.lineSpacing() + 2; 209 keyHeight = fm.lineSpacing() + 2;
218 keyWidth = (double)width()/numCols; 210 keyWidth = (double)width()/numCols;
219 211
220} 212}
221 213
222QSize FunctionKeyboard::sizeHint() const { 214QSize FunctionKeyboard::sizeHint() const {
223 215
224 return QSize(width(), keyHeight * numRows + 1); 216 return QSize(width(), keyHeight * numRows + 1);
225} 217}
226 218
227void FunctionKeyboard::loadDefaults() { 219void FunctionKeyboard::loadDefaults() {
228 220
229 numRows = DEFAULT_ROWS; 221 numRows = DEFAULT_ROWS;
230 numCols = DEFAULT_COLS; 222 numCols = DEFAULT_COLS;
231 keyWidth = (double)width()/numCols; // have to reset this thing too 223 keyWidth = (double)width()/numCols; // have to reset this thing too
232 224
233 keys.insert( "r0c0", FKey ("Enter", "enter", Qt::Key_Enter, 0)); 225 keys.insert( "r0c0", FKey ("Enter", "enter", Qt::Key_Enter, 0));
234 keys.insert( "r0c1", FKey ("Space", "space", Qt::Key_Space, Qt::Key_Space)); 226 keys.insert( "r0c1", FKey ("Space", "space", Qt::Key_Space, Qt::Key_Space));
235 keys.insert( "r0c2", FKey ("Tab", "tab", Qt::Key_Tab, 0)); 227 keys.insert( "r0c2", FKey ("Tab", "tab", Qt::Key_Tab, 0));
236 keys.insert( "r0c3", FKey ("Up", "up", Qt::Key_Up, 0)); 228 keys.insert( "r0c3", FKey ("Up", "up", Qt::Key_Up, 0));
237 keys.insert( "r0c4", FKey ("Down", "down", Qt::Key_Down, 0)); 229 keys.insert( "r0c4", FKey ("Down", "down", Qt::Key_Down, 0));
238 230
239 keys.insert( "r0c7", FKey ("Ho", 0, 4112, 0)); 231 keys.insert( "r0c7", FKey ("Ho", 0, 4112, 0));
240 keys.insert( "r0c8", FKey ("End", 0, 4113, 0)); 232 keys.insert( "r0c8", FKey ("End", 0, 4113, 0));
241 keys.insert( "r0c9", FKey ("Pu", 0, 4118, 0)); 233 keys.insert( "r0c9", FKey ("Pu", 0, 4118, 0));
242 keys.insert( "r0c10", FKey ("Pd", 0, 4119, 0)); 234 keys.insert( "r0c10", FKey ("Pd", 0, 4119, 0));
243 keys.insert( "r0c11", FKey ("Esc", 0, Qt::Key_Escape, 0xfff)); 235 keys.insert( "r0c11", FKey ("Esc", 0, Qt::Key_Escape, 0xfff));
244 236
245 keys.insert( "r1c0", FKey ("F1", 0, 4144, 0)); 237 keys.insert( "r1c0", FKey ("F1", 0, 4144, 0));
246 keys.insert( "r1c1", FKey ("F2", 0, 4145, 0)); 238 keys.insert( "r1c1", FKey ("F2", 0, 4145, 0));
247 keys.insert( "r1c2", FKey ("F3", 0, 4146, 0)); 239 keys.insert( "r1c2", FKey ("F3", 0, 4146, 0));
248 keys.insert( "r1c3", FKey ("F4", 0, 4147, 0)); 240 keys.insert( "r1c3", FKey ("F4", 0, 4147, 0));
249 keys.insert( "r1c4", FKey ("F5", 0, 4148, 0)); 241 keys.insert( "r1c4", FKey ("F5", 0, 4148, 0));
250 keys.insert( "r1c5", FKey ("F6", 0, 4149, 0)); 242 keys.insert( "r1c5", FKey ("F6", 0, 4149, 0));
251 keys.insert( "r1c6", FKey ("F7", 0, 4150, 0)); 243 keys.insert( "r1c6", FKey ("F7", 0, 4150, 0));
252 keys.insert( "r1c7", FKey ("F8", 0, 4151, 0)); 244 keys.insert( "r1c7", FKey ("F8", 0, 4151, 0));
253 keys.insert( "r1c8", FKey ("F9", 0, 4152, 0)); 245 keys.insert( "r1c8", FKey ("F9", 0, 4152, 0));
254 keys.insert( "r1c9", FKey ("F10", 0, 4153, 0)); 246 keys.insert( "r1c9", FKey ("F10", 0, 4153, 0));
255 keys.insert( "r1c10", FKey ("F11", 0, 4154, 0)); 247 keys.insert( "r1c10", FKey ("F11", 0, 4154, 0));
256 keys.insert( "r1c11", FKey ("F12", 0, 4155, 0)); 248 keys.insert( "r1c11", FKey ("F12", 0, 4155, 0));
257 249
258 250
259} 251}
260 252
261/* FunctionKeyboardConfig {{{1 */ 253/* FunctionKeyboardConfig {{{1 */
262 254
263FunctionKeyboardConfig::FunctionKeyboardConfig(const QString& name, QWidget* parent, const char* na ) 255FunctionKeyboardConfig::FunctionKeyboardConfig(const QString& name, QWidget* parent, const char* na )
264 : ProfileDialogKeyWidget(name, parent, na), 256 : ProfileDialogKeyWidget(name, parent, na),
265 selectedRow(0), selectedCol(0) 257 selectedRow(0), selectedCol(0)
266{ 258{
267 qWarning("FunctionKeyboardConfig"); 259 qWarning("FunctionKeyboardConfig");
268 260
269 261
270 kb = new FunctionKeyboard(this); 262 kb = new FunctionKeyboard(this);
271 connect (kb, SIGNAL(keyPressed(FKey, ushort, ushort, bool)), 263 connect (kb, SIGNAL(keyPressed(FKey, ushort, ushort, bool)),
272 this, SLOT(slotKeyPressed(FKey, ushort, ushort, bool))); 264 this, SLOT(slotKeyPressed(FKey, ushort, ushort, bool)));
273 265
274 QGroupBox *dimentions = new QGroupBox(2, Qt::Horizontal, tr("Dimensions"), this); 266 QGroupBox *dimentions = new QGroupBox(2, Qt::Horizontal, tr("Dimensions"), this);
275 QLabel *l = new QLabel("Rows", dimentions); 267 QLabel *l = new QLabel("Rows", dimentions);
276 m_rowBox = new QSpinBox(1, 15, 1, dimentions); 268 m_rowBox = new QSpinBox(1, 15, 1, dimentions);
277 connect (m_rowBox, SIGNAL(valueChanged(int)), this, SLOT(slotChangeRows(int))); 269 connect (m_rowBox, SIGNAL(valueChanged(int)), this, SLOT(slotChangeRows(int)));
278 l = new QLabel("Columns", dimentions); 270 l = new QLabel("Columns", dimentions);
279 m_colBox = new QSpinBox(1, 15, 1, dimentions); 271 m_colBox = new QSpinBox(1, 15, 1, dimentions);
280 connect (m_colBox, SIGNAL(valueChanged(int)), this, SLOT(slotChangeCols(int))); 272 connect (m_colBox, SIGNAL(valueChanged(int)), this, SLOT(slotChangeCols(int)));
281 273
282 QGroupBox *editKey = new QGroupBox(2, Qt::Horizontal, tr("Edit Key"), this); 274 QGroupBox *editKey = new QGroupBox(2, Qt::Horizontal, tr("Edit Key"), this);
283 l = new QLabel("Label", editKey); 275 l = new QLabel("Label", editKey);
284 m_labels = new QComboBox(true, editKey); 276 m_labels = new QComboBox(true, editKey);
285 m_labels->setInsertionPolicy(QComboBox::AtCurrent); 277 m_labels->setInsertionPolicy(QComboBox::AtCurrent);
286 m_labels->insertItem(""); 278 m_labels->insertItem("");
287 279
288 QStringList files = QDir( QPEApplication::qpeDir() + "pics/console/keys/", "*.png").entryList(); 280 QStringList files = QDir( QPEApplication::qpeDir() + "pics/console/keys/", "*.png").entryList();
289 281
290 for (uint i = 0; i < files.count(); i++) { 282 for (uint i = 0; i < files.count(); i++) {
291 283
292 m_labels->insertItem( Resource::loadPixmap("console/keys/" + files[i]), files[i]); 284 m_labels->insertItem( Resource::loadPixmap("console/keys/" + files[i]), files[i]);
293 } 285 }
294 connect (m_labels, SIGNAL(activated(int)), this, SLOT(slotChangeIcon(int))); 286 connect (m_labels, SIGNAL(activated(int)), this, SLOT(slotChangeIcon(int)));
295 connect (m_labels, SIGNAL(textChanged(const QString &)), this, SLOT(slotChangeLabelText(const QString&))); 287 connect (m_labels, SIGNAL(textChanged(const QString &)), this, SLOT(slotChangeLabelText(const QString&)));
296 288
297 l = new QLabel("Q Keycode", editKey); 289 l = new QLabel("Q Keycode", editKey);
298 m_qvalues = new QComboBox(true, editKey); 290 m_qvalues = new QComboBox(true, editKey);
299 m_qvalues->setInsertionPolicy(QComboBox::AtTop); 291 m_qvalues->setInsertionPolicy(QComboBox::AtTop);
300 m_qvalues->setDuplicatesEnabled(false); 292 m_qvalues->setDuplicatesEnabled(false);
301 m_qvalues->insertItem(""); 293 m_qvalues->insertItem("");
302 connect (m_qvalues, SIGNAL(textChanged(const QString &)), this, SLOT(slotChangeQCode(const QString&))); 294 connect (m_qvalues, SIGNAL(textChanged(const QString &)), this, SLOT(slotChangeQCode(const QString&)));
303 295
304 l = new QLabel("Unicode Value", editKey); 296 l = new QLabel("Unicode Value", editKey);
305 m_uniValues = new QComboBox(true, editKey); 297 m_uniValues = new QComboBox(true, editKey);
306 m_uniValues->setInsertionPolicy(QComboBox::AtTop); 298 m_uniValues->setInsertionPolicy(QComboBox::AtTop);
307 m_uniValues->setDuplicatesEnabled(false); 299 m_uniValues->setDuplicatesEnabled(false);
308 m_uniValues->insertItem(""); 300 m_uniValues->insertItem("");
309 connect (m_uniValues, SIGNAL(textChanged(const QString &)), this, SLOT(slotChangeUnicode(const QString&))); 301 connect (m_uniValues, SIGNAL(textChanged(const QString &)), this, SLOT(slotChangeUnicode(const QString&)));
310 302
311 QVBoxLayout *root = new QVBoxLayout(this, 2); 303 QVBoxLayout *root = new QVBoxLayout(this, 2);
312 root->addWidget(kb); 304 root->addWidget(kb);
313 root->addWidget(dimentions); 305 root->addWidget(dimentions);
314 root->addWidget(editKey); 306 root->addWidget(editKey);
315} 307}
316FunctionKeyboardConfig::~FunctionKeyboardConfig() { 308FunctionKeyboardConfig::~FunctionKeyboardConfig() {
317 309
318} 310}
319void FunctionKeyboardConfig::load (const Profile& prof) { 311void FunctionKeyboardConfig::load (const Profile& prof) {
320 312
321 kb->keys.clear(); 313 kb->keys.clear();
322 kb->loadDefaults(); 314 kb->loadDefaults();
323 315
324 m_rowBox->setValue(prof.readNumEntry("keb_rows", 2)); 316 m_rowBox->setValue(prof.readNumEntry("keb_rows", 2));
325 m_colBox->setValue(prof.readNumEntry("keb_cols", 10)); 317 m_colBox->setValue(prof.readNumEntry("keb_cols", 10));
326 318
327 /* load all the keys to the keyboard */ 319 /* load all the keys to the keyboard */
328 for (int i = 0; i <= m_rowBox->value() -1; i++) 320 for (int i = 0; i <= m_rowBox->value() -1; i++)
329 for (int j = 0; j <= m_colBox->value() -1; j++) { 321 for (int j = 0; j <= m_colBox->value() -1; j++) {
330 322
331 QString h = "r" + QString::number(i) + "c" + QString::number(j); 323 QString h = "r" + QString::number(i) + "c" + QString::number(j);
332 QString values = prof.readEntry("keb_" + h); 324 QString values = prof.readEntry("keb_" + h);
333 325
334 if (!values.isEmpty()) { 326 if (!values.isEmpty()) {
335 327
336 QStringList l = QStringList::split(QChar('|'), values, TRUE); 328 QStringList l = QStringList::split(QChar('|'), values, TRUE);
337 kb->keys[h] = FKey(l[0], l[1], l[2].toInt(), l[3].toInt()); 329 kb->keys[h] = FKey(l[0], l[1], l[2].toInt(), l[3].toInt());
338 330
339 // load pixmap if used 331 // load pixmap if used
340 if (!l[1].isEmpty()) { 332 if (!l[1].isEmpty()) {
341 333
342 kb->keys[h].pix = new QPixmap( Resource::loadPixmap( "console/keys/" + l[1] ) ); 334 kb->keys[h].pix = new QPixmap( Resource::loadPixmap( "console/keys/" + l[1] ) );
343 } 335 }
344 } 336 }
345 } 337 }
346 338
347} 339}
348void FunctionKeyboardConfig::save (Profile& prof) { 340void FunctionKeyboardConfig::save (Profile& prof) {
349 341
350 prof.writeEntry("keb_rows", m_rowBox->value()); 342 prof.writeEntry("keb_rows", m_rowBox->value());
351 prof.writeEntry("keb_cols", m_colBox->value()); 343 prof.writeEntry("keb_cols", m_colBox->value());
352 344
353 QMap<QString, FKey>::Iterator it; 345 QMap<QString, FKey>::Iterator it;
354 for ( it = kb->keys.begin(); it != kb->keys.end(); it++) { 346 for ( it = kb->keys.begin(); it != kb->keys.end(); it++) {
355 347
356 FKey k = it.data(); 348 FKey k = it.data();
357 QString entry = k.label + "|" 349 QString entry = k.label + "|"
358 + k.pixFile + "|" 350 + k.pixFile + "|"
359 + QString::number(k.qcode) + "|" 351 + QString::number(k.qcode) + "|"
360 + QString::number(k.unicode); 352 + QString::number(k.unicode);
361 353
362 prof.writeEntry("keb_" + it.key(), entry); 354 prof.writeEntry("keb_" + it.key(), entry);
363 355
364 } 356 }
365 357
366} 358}
367void FunctionKeyboardConfig::slotChangeRows(int r) { 359void FunctionKeyboardConfig::slotChangeRows(int r) {
368 360
369 kb->changeRows(r); 361 kb->changeRows(r);
370 362
371} 363}
372void FunctionKeyboardConfig::slotChangeCols(int c) { 364void FunctionKeyboardConfig::slotChangeCols(int c) {
373 365
374 kb->changeCols(c); 366 kb->changeCols(c);
375} 367}
376void FunctionKeyboardConfig::slotKeyPressed(FKey k, ushort r, ushort c, bool pressed) { 368void FunctionKeyboardConfig::slotKeyPressed(FKey k, ushort r, ushort c, bool pressed) {
377 369
378 if (!pressed) return; 370 if (!pressed) return;
379 371
380 selectedHandle = "r" + QString::number(r) + 372 selectedHandle = "r" + QString::number(r) +
381 "c" + QString::number(c); 373 "c" + QString::number(c);
382 selectedRow = r; 374 selectedRow = r;
383 selectedCol = c; 375 selectedCol = c;
384 376
385 if (k.pixFile.isEmpty()) { 377 if (k.pixFile.isEmpty()) {
386 378
387 m_labels->setEditable(true); 379 m_labels->setEditable(true);
388 m_labels->setCurrentItem(0); 380 m_labels->setCurrentItem(0);
389 m_labels->changeItem(k.label, 0); 381 m_labels->changeItem(k.label, 0);
390 382
391 } else { 383 } else {
392 384
393 // any better way to select the pixmap? 385 // any better way to select the pixmap?
394 m_labels->setCurrentItem((m_labels->listBox())->index((m_labels->listBox())->findItem(kb->keys[selectedHandle].pixFile))); 386 m_labels->setCurrentItem((m_labels->listBox())->index((m_labels->listBox())->findItem(kb->keys[selectedHandle].pixFile)));
395 m_labels->setEditable(false); 387 m_labels->setEditable(false);
396 } 388 }
397 m_qvalues->changeItem(QString::number(k.qcode), 0); 389 m_qvalues->changeItem(QString::number(k.qcode), 0);
398 m_uniValues->changeItem(QString::number(k.unicode), 0); 390 m_uniValues->changeItem(QString::number(k.unicode), 0);
399} 391}
400void FunctionKeyboardConfig::slotChangeIcon(int index) { 392void FunctionKeyboardConfig::slotChangeIcon(int index) {
401 393
402 if (index == 0) { 394 if (index == 0) {
403 395
404 // is text 396 // is text
405 m_labels->setEditable(true); 397 m_labels->setEditable(true);
406 // why tf does the text get erased unless i do this? 398 // why tf does the text get erased unless i do this?
407 m_labels->changeItem(m_labels->text(0), 0); 399 m_labels->changeItem(m_labels->text(0), 0);
408 400
409 kb->keys[selectedHandle].pixFile = ""; 401 kb->keys[selectedHandle].pixFile = "";
410 delete kb->keys[selectedHandle].pix; 402 delete kb->keys[selectedHandle].pix;
411 403
412 } else { 404 } else {
413 405
414 // is a pixmap 406 // is a pixmap
415 m_labels->setEditable(false); 407 m_labels->setEditable(false);
416 kb->keys[selectedHandle].pixFile = m_labels->currentText(); 408 kb->keys[selectedHandle].pixFile = m_labels->currentText();
417 kb->keys[selectedHandle].pix = new QPixmap( Resource::loadPixmap( "console/keys/" + m_labels->currentText() ) ); 409 kb->keys[selectedHandle].pix = new QPixmap( Resource::loadPixmap( "console/keys/" + m_labels->currentText() ) );
418 } 410 }
419 kb->paintKey(selectedRow, selectedCol); 411 kb->paintKey(selectedRow, selectedCol);
420} 412}
421void FunctionKeyboardConfig::slotChangeLabelText(const QString &label) { 413void FunctionKeyboardConfig::slotChangeLabelText(const QString &label) {
422 414
423 kb->keys[selectedHandle].label = label; 415 kb->keys[selectedHandle].label = label;
424 416
425 kb->paintKey(selectedRow, selectedCol); 417 kb->paintKey(selectedRow, selectedCol);
426} 418}
427void FunctionKeyboardConfig::slotChangeQCode(const QString& qcode) { 419void FunctionKeyboardConfig::slotChangeQCode(const QString& qcode) {
428 420
429 kb->keys[selectedHandle].qcode = qcode.toUInt(); 421 kb->keys[selectedHandle].qcode = qcode.toUInt();
430} 422}
431void FunctionKeyboardConfig::slotChangeUnicode(const QString& uni) { 423void FunctionKeyboardConfig::slotChangeUnicode(const QString& uni) {
432 424
433 kb->keys[selectedHandle].unicode = uni.toUInt(); 425 kb->keys[selectedHandle].unicode = uni.toUInt();
434} 426}
diff --git a/noncore/apps/opie-console/iolayerbase.cpp b/noncore/apps/opie-console/iolayerbase.cpp
index ba7c86e..b434e66 100644
--- a/noncore/apps/opie-console/iolayerbase.cpp
+++ b/noncore/apps/opie-console/iolayerbase.cpp
@@ -1,239 +1,237 @@
1#include <qlabel.h> 1#include <qlabel.h>
2#include <qlayout.h> 2#include <qlayout.h>
3#include <qcombobox.h> 3#include <qcombobox.h>
4#include <qbuttongroup.h>
5#include <qhbuttongroup.h> 4#include <qhbuttongroup.h>
6#include <qradiobutton.h> 5#include <qradiobutton.h>
7#include <qhbox.h>
8 6
9#include "iolayerbase.h" 7#include "iolayerbase.h"
10 8
11namespace { 9namespace {
12 enum ParityIds { 10 enum ParityIds {
13 id_parity_none, 11 id_parity_none,
14 id_parity_odd, 12 id_parity_odd,
15 id_parity_even 13 id_parity_even
16 }; 14 };
17 15
18 enum FlowIds { 16 enum FlowIds {
19 id_flow_hw, 17 id_flow_hw,
20 id_flow_sw, 18 id_flow_sw,
21 id_flow_none, 19 id_flow_none,
22 }; 20 };
23 21
24 enum SpeedIds { 22 enum SpeedIds {
25 id_baud_115200, 23 id_baud_115200,
26 id_baud_57600, 24 id_baud_57600,
27 id_baud_38400, 25 id_baud_38400,
28 id_baud_19200, 26 id_baud_19200,
29 id_baud_9600 27 id_baud_9600
30 }; 28 };
31 29
32 enum DataIds { 30 enum DataIds {
33 id_data_5, 31 id_data_5,
34 id_data_6, 32 id_data_6,
35 id_data_7, 33 id_data_7,
36 id_data_8 34 id_data_8
37 }; 35 };
38 36
39 enum StopIds { 37 enum StopIds {
40 id_stop_1, 38 id_stop_1,
41 id_stop_1_5, 39 id_stop_1_5,
42 id_stop_2 40 id_stop_2
43 }; 41 };
44 42
45} 43}
46 44
47 45
48IOLayerBase::IOLayerBase( QWidget* par, const char* name ) 46IOLayerBase::IOLayerBase( QWidget* par, const char* name )
49 : QWidget( par, name ) 47 : QWidget( par, name )
50{ 48{
51 m_speedLabel = new QLabel(tr("Speed"), this ); 49 m_speedLabel = new QLabel(tr("Speed"), this );
52 m_speedBox = new QComboBox(this ); 50 m_speedBox = new QComboBox(this );
53 51
54 m_groupFlow = new QHButtonGroup(tr("Flow control"),this ); 52 m_groupFlow = new QHButtonGroup(tr("Flow control"),this );
55 m_flowHw = new QRadioButton(tr("Hardware"), m_groupFlow ); 53 m_flowHw = new QRadioButton(tr("Hardware"), m_groupFlow );
56 m_flowSw = new QRadioButton(tr("Software"), m_groupFlow ); 54 m_flowSw = new QRadioButton(tr("Software"), m_groupFlow );
57 m_flowNone = new QRadioButton( tr("None"), m_groupFlow ); 55 m_flowNone = new QRadioButton( tr("None"), m_groupFlow );
58 56
59 m_groupParity = new QHButtonGroup(tr("Parity"), this ); 57 m_groupParity = new QHButtonGroup(tr("Parity"), this );
60 m_parityNone = new QRadioButton(tr("None"), m_groupParity ); 58 m_parityNone = new QRadioButton(tr("None"), m_groupParity );
61 m_parityOdd = new QRadioButton(tr("Odd"), m_groupParity ); 59 m_parityOdd = new QRadioButton(tr("Odd"), m_groupParity );
62 m_parityEven = new QRadioButton(tr("Even"), m_groupParity ); 60 m_parityEven = new QRadioButton(tr("Even"), m_groupParity );
63 61
64 m_groupData = new QHButtonGroup(tr("Data Bits"), this); 62 m_groupData = new QHButtonGroup(tr("Data Bits"), this);
65 m_data5 = new QRadioButton(tr("5"), m_groupData ); 63 m_data5 = new QRadioButton(tr("5"), m_groupData );
66 m_data6 = new QRadioButton(tr("6"), m_groupData ); 64 m_data6 = new QRadioButton(tr("6"), m_groupData );
67 m_data7 = new QRadioButton(tr("7"), m_groupData ); 65 m_data7 = new QRadioButton(tr("7"), m_groupData );
68 m_data8 = new QRadioButton(tr("8"), m_groupData ); 66 m_data8 = new QRadioButton(tr("8"), m_groupData );
69 67
70 m_groupStop = new QHButtonGroup(tr("Stop Bits"), this ); 68 m_groupStop = new QHButtonGroup(tr("Stop Bits"), this );
71 m_stop1 = new QRadioButton(tr("1"), m_groupStop ); 69 m_stop1 = new QRadioButton(tr("1"), m_groupStop );
72 m_stop15 = new QRadioButton(tr("1.5"), m_groupStop ); 70 m_stop15 = new QRadioButton(tr("1.5"), m_groupStop );
73 m_stop2 = new QRadioButton(tr("2"), m_groupStop ); 71 m_stop2 = new QRadioButton(tr("2"), m_groupStop );
74 72
75 73
76 m_lroot = new QVBoxLayout( this ); 74 m_lroot = new QVBoxLayout( this );
77 m_lroot->add(m_speedLabel ); 75 m_lroot->add(m_speedLabel );
78 m_lroot->add(m_speedBox ); 76 m_lroot->add(m_speedBox );
79 m_lroot->add(m_groupFlow ); 77 m_lroot->add(m_groupFlow );
80 m_lroot->add(m_groupParity ); 78 m_lroot->add(m_groupParity );
81 m_lroot->add( m_groupData ); 79 m_lroot->add( m_groupData );
82 m_lroot->add( m_groupStop ); 80 m_lroot->add( m_groupStop );
83 m_lroot->addStretch(2); 81 m_lroot->addStretch(2);
84 82
85 // profiles 83 // profiles
86 m_speedBox->insertItem(tr("115200 baud"), id_baud_115200 ); 84 m_speedBox->insertItem(tr("115200 baud"), id_baud_115200 );
87 m_speedBox->insertItem(tr("57600 baud"), id_baud_57600 ); 85 m_speedBox->insertItem(tr("57600 baud"), id_baud_57600 );
88 m_speedBox->insertItem(tr("38400 baud"), id_baud_38400 ); 86 m_speedBox->insertItem(tr("38400 baud"), id_baud_38400 );
89 m_speedBox->insertItem(tr("19200 baud"), id_baud_19200 ); 87 m_speedBox->insertItem(tr("19200 baud"), id_baud_19200 );
90 m_speedBox->insertItem(tr("9600 baud"), id_baud_9600 ); 88 m_speedBox->insertItem(tr("9600 baud"), id_baud_9600 );
91 89
92}; 90};
93IOLayerBase::~IOLayerBase() { 91IOLayerBase::~IOLayerBase() {
94 92
95} 93}
96void IOLayerBase::setFlow( Flow flo ) { 94void IOLayerBase::setFlow( Flow flo ) {
97 switch ( flo ) { 95 switch ( flo ) {
98 case Software: 96 case Software:
99 m_flowSw->setChecked( true ); 97 m_flowSw->setChecked( true );
100 break; 98 break;
101 case Hardware: 99 case Hardware:
102 m_flowHw->setChecked( true ); 100 m_flowHw->setChecked( true );
103 break; 101 break;
104 case None: 102 case None:
105 m_flowNone->setChecked( true ); 103 m_flowNone->setChecked( true );
106 break; 104 break;
107 } 105 }
108} 106}
109 107
110void IOLayerBase::setParity( Parity par ) { 108void IOLayerBase::setParity( Parity par ) {
111 switch( par ) { 109 switch( par ) {
112 case NonePar: 110 case NonePar:
113 m_parityNone->setChecked( true ); 111 m_parityNone->setChecked( true );
114 break; 112 break;
115 case Odd: 113 case Odd:
116 m_parityOdd->setChecked( true ); 114 m_parityOdd->setChecked( true );
117 break; 115 break;
118 case Even: 116 case Even:
119 m_parityEven->setChecked( true ); 117 m_parityEven->setChecked( true );
120 break; 118 break;
121 } 119 }
122} 120}
123void IOLayerBase::setSpeed( Speed sp ) { 121void IOLayerBase::setSpeed( Speed sp ) {
124 int index = -1; 122 int index = -1;
125 switch( sp ) { 123 switch( sp ) {
126 case Baud_115200: 124 case Baud_115200:
127 index = id_baud_115200; 125 index = id_baud_115200;
128 break; 126 break;
129 case Baud_57600: 127 case Baud_57600:
130 index = id_baud_57600; 128 index = id_baud_57600;
131 break; 129 break;
132 case Baud_38400: 130 case Baud_38400:
133 index = id_baud_38400; 131 index = id_baud_38400;
134 break; 132 break;
135 case Baud_19200: 133 case Baud_19200:
136 index = id_baud_19200; 134 index = id_baud_19200;
137 break; 135 break;
138 default: 136 default:
139 case Baud_9600: 137 case Baud_9600:
140 index = id_baud_9600; 138 index = id_baud_9600;
141 break; 139 break;
142 } 140 }
143 m_speedBox->setCurrentItem(index ); 141 m_speedBox->setCurrentItem(index );
144} 142}
145 143
146void IOLayerBase::setData( Data data ) { 144void IOLayerBase::setData( Data data ) {
147 switch( data ) { 145 switch( data ) {
148 case Data_Five: 146 case Data_Five:
149 m_data5->setChecked( true ); 147 m_data5->setChecked( true );
150 break; 148 break;
151 case Data_Six: 149 case Data_Six:
152 m_data6->setChecked( true ); 150 m_data6->setChecked( true );
153 break; 151 break;
154 case Data_Seven: 152 case Data_Seven:
155 m_data7->setChecked( true ); 153 m_data7->setChecked( true );
156 break; 154 break;
157 default: 155 default:
158 m_data8->setChecked( true ); 156 m_data8->setChecked( true );
159 break; 157 break;
160 } 158 }
161} 159}
162 160
163 161
164void IOLayerBase::setStop( Stop stop ) { 162void IOLayerBase::setStop( Stop stop ) {
165 switch( stop ) { 163 switch( stop ) {
166 case Stop_Two: 164 case Stop_Two:
167 m_stop2->setChecked( true ); 165 m_stop2->setChecked( true );
168 break; 166 break;
169 case Stop_OnePointFive: 167 case Stop_OnePointFive:
170 m_stop15->setChecked( true ); 168 m_stop15->setChecked( true );
171 break; 169 break;
172 default: 170 default:
173 m_stop1->setChecked( true ); 171 m_stop1->setChecked( true );
174 break; 172 break;
175 } 173 }
176} 174}
177 175
178 176
179 177
180IOLayerBase::Flow IOLayerBase::flow()const { 178IOLayerBase::Flow IOLayerBase::flow()const {
181 if (m_flowHw->isChecked() ) { 179 if (m_flowHw->isChecked() ) {
182 return Hardware; 180 return Hardware;
183 }else if( m_flowSw->isChecked() ) { 181 }else if( m_flowSw->isChecked() ) {
184 return Software; 182 return Software;
185 } else { 183 } else {
186 return None; 184 return None;
187 } 185 }
188} 186}
189IOLayerBase::Parity IOLayerBase::parity()const { 187IOLayerBase::Parity IOLayerBase::parity()const {
190 if ( m_parityOdd->isChecked() ) { 188 if ( m_parityOdd->isChecked() ) {
191 return Odd; 189 return Odd;
192 } else if ( m_parityEven->isChecked() ) { 190 } else if ( m_parityEven->isChecked() ) {
193 return Even; 191 return Even;
194 } else { 192 } else {
195 return NonePar; 193 return NonePar;
196 } 194 }
197 195
198} 196}
199IOLayerBase::Speed IOLayerBase::speed()const{ 197IOLayerBase::Speed IOLayerBase::speed()const{
200 switch( m_speedBox->currentItem() ) { 198 switch( m_speedBox->currentItem() ) {
201 case id_baud_115200: 199 case id_baud_115200:
202 return Baud_115200; 200 return Baud_115200;
203 break; 201 break;
204 case id_baud_57600: 202 case id_baud_57600:
205 return Baud_57600; 203 return Baud_57600;
206 break; 204 break;
207 case id_baud_38400: 205 case id_baud_38400:
208 return Baud_38400; 206 return Baud_38400;
209 break; 207 break;
210 case id_baud_19200: 208 case id_baud_19200:
211 return Baud_19200; 209 return Baud_19200;
212 break; 210 break;
213 default: 211 default:
214 case id_baud_9600: 212 case id_baud_9600:
215 return Baud_9600; 213 return Baud_9600;
216 break; 214 break;
217 } 215 }
218} 216}
219IOLayerBase::Data IOLayerBase::data()const { 217IOLayerBase::Data IOLayerBase::data()const {
220 if ( m_data5->isChecked() ) { 218 if ( m_data5->isChecked() ) {
221 return Data_Five; 219 return Data_Five;
222 } else if ( m_data6->isChecked() ) { 220 } else if ( m_data6->isChecked() ) {
223 return Data_Six; 221 return Data_Six;
224 } else if ( m_data7->isChecked() ) { 222 } else if ( m_data7->isChecked() ) {
225 return Data_Seven; 223 return Data_Seven;
226 } else { 224 } else {
227 return Data_Eight; 225 return Data_Eight;
228 } 226 }
229} 227}
230IOLayerBase::Stop IOLayerBase::stop()const { 228IOLayerBase::Stop IOLayerBase::stop()const {
231 if ( m_stop2->isChecked() ) { 229 if ( m_stop2->isChecked() ) {
232 return Stop_Two; 230 return Stop_Two;
233 } else if ( m_stop15->isChecked() ) { 231 } else if ( m_stop15->isChecked() ) {
234 return Stop_OnePointFive; 232 return Stop_OnePointFive;
235 } else { 233 } else {
236 return Stop_One; 234 return Stop_One;
237 } 235 }
238} 236}
239 237
diff --git a/noncore/apps/opie-console/main.cpp b/noncore/apps/opie-console/main.cpp
index 228db57..dfb2f83 100644
--- a/noncore/apps/opie-console/main.cpp
+++ b/noncore/apps/opie-console/main.cpp
@@ -1,111 +1,110 @@
1#include <sys/types.h> 1#include <sys/types.h>
2 2
3#include <stdio.h> 3#include <stdio.h>
4#include <stdlib.h> 4#include <stdlib.h>
5#include <signal.h> 5#include <signal.h>
6 6
7#include <qfile.h>
8 7
9#include <qpe/qpeapplication.h> 8#include <qpe/qpeapplication.h>
10 9
11#include "mainwindow.h" 10#include "mainwindow.h"
12 11
13//#define FSCKED_DISTRIBUTION 1 12//#define FSCKED_DISTRIBUTION 1
14#ifdef FSCKED_DISTRIBUTION 13#ifdef FSCKED_DISTRIBUTION
15/* 14/*
16 * The Zaurus rom 15 * The Zaurus rom
17 */ 16 */
18class FixIt { 17class FixIt {
19public: 18public:
20 FixIt(); 19 FixIt();
21 ~FixIt(); 20 ~FixIt();
22 void fixIt(); 21 void fixIt();
23 /* no real interested in implementing it */ 22 /* no real interested in implementing it */
24 void breakIt() { 23 void breakIt() {
25 24
26 }; 25 };
27 char* m_file; 26 char* m_file;
28}; 27};
29 28
30FixIt::FixIt() { 29FixIt::FixIt() {
31 /* the new inittab */ 30 /* the new inittab */
32 m_file = "#\n# /etc/inittab" 31 m_file = "#\n# /etc/inittab"
33"#" 32"#"
34"" 33""
35"# 0 - halt (Do NOT set initdefault to this)" 34"# 0 - halt (Do NOT set initdefault to this)"
36"# 1 - Single user mode" 35"# 1 - Single user mode"
37"# 2 - Multiuser, without NFS (The same as 3, if you do not have networking)" 36"# 2 - Multiuser, without NFS (The same as 3, if you do not have networking)"
38"# 3 - Full multiuser mode" 37"# 3 - Full multiuser mode"
39"# 4 - JavaVM(Intent) developer mode" 38"# 4 - JavaVM(Intent) developer mode"
40"# 5 - JavaVM(Intent)" 39"# 5 - JavaVM(Intent)"
41"# 6 - reboot (Do NOT set initdefault to this)" 40"# 6 - reboot (Do NOT set initdefault to this)"
42"#" 41"#"
43"id:5:initdefault:" 42"id:5:initdefault:"
44"" 43""
45"# Specify things to do when starting" 44"# Specify things to do when starting"
46"si::sysinit:/etc/rc.d/rc.sysinit" 45"si::sysinit:/etc/rc.d/rc.sysinit"
47"" 46""
48"l0:0:wait:/root/etc/rc.d/rc 0" 47"l0:0:wait:/root/etc/rc.d/rc 0"
49"l1:1:wait:/etc/rc.d/rc 1" 48"l1:1:wait:/etc/rc.d/rc 1"
50"l2:2:wait:/etc/rc.d/rc 2" 49"l2:2:wait:/etc/rc.d/rc 2"
51"l3:3:wait:/etc/rc.d/rc 3" 50"l3:3:wait:/etc/rc.d/rc 3"
52"l4:4:wait:/etc/rc.d/rc 4" 51"l4:4:wait:/etc/rc.d/rc 4"
53"l5:5:wait:/etc/rc.d/rc 5" 52"l5:5:wait:/etc/rc.d/rc 5"
54"l6:6:wait:/root/etc/rc.d/rc 6" 53"l6:6:wait:/root/etc/rc.d/rc 6"
55"" 54""
56"# Specify things to do before rebooting" 55"# Specify things to do before rebooting"
57"um::ctrlaltdel:/bin/umount -a -r > /dev/null 2>&1" 56"um::ctrlaltdel:/bin/umount -a -r > /dev/null 2>&1"
58"sw::ctrlaltdel:/sbin/swapoff -a > /dev/null 2>&1" 57"sw::ctrlaltdel:/sbin/swapoff -a > /dev/null 2>&1"
59"" 58""
60"# Specify program to run on ttyS0" 59"# Specify program to run on ttyS0"
61"s0:24:respawn:/sbin/getty 9600 ttyS0" 60"s0:24:respawn:/sbin/getty 9600 ttyS0"
62"#pd:5:respawn:/etc/sync/serialctl" 61"#pd:5:respawn:/etc/sync/serialctl"
63"" 62""
64"# Specify program to run on tty1" 63"# Specify program to run on tty1"
65"1:2:respawn:/sbin/getty 9600 tty1" 64"1:2:respawn:/sbin/getty 9600 tty1"
66"ln:345:respawn:survive -l 6 /sbin/launch" 65"ln:345:respawn:survive -l 6 /sbin/launch"
67"#qt:5:respawn:/sbin/qt" 66"#qt:5:respawn:/sbin/qt"
68"" 67""
69"# collie sp." 68"# collie sp."
70"sy::respawn:/sbin/shsync\n"; 69"sy::respawn:/sbin/shsync\n";
71} 70}
72FixIt::~FixIt() { 71FixIt::~FixIt() {
73} 72}
74/* 73/*
75 * the retail Zaurus is broken in many ways 74 * the retail Zaurus is broken in many ways
76 * one is that pppd is listening on our port... 75 * one is that pppd is listening on our port...
77 * we've to stop it from that and then do kill(SIGHUP,1); 76 * we've to stop it from that and then do kill(SIGHUP,1);
78 */ 77 */
79void FixIt::fixIt() { 78void FixIt::fixIt() {
80 ::rename("/etc/inittab", QPEApplication::qpeDir() + "/etc/inittab" ); 79 ::rename("/etc/inittab", QPEApplication::qpeDir() + "/etc/inittab" );
81 QFile file( "/etc/inittab" ); 80 QFile file( "/etc/inittab" );
82 if ( file.open(IO_WriteOnly | IO_Raw ) ) { 81 if ( file.open(IO_WriteOnly | IO_Raw ) ) {
83 file.writeBlock(m_file,strlen(m_file) ); 82 file.writeBlock(m_file,strlen(m_file) );
84 } 83 }
85 file.close(); 84 file.close();
86 ::kill( SIGHUP, 1 ); 85 ::kill( SIGHUP, 1 );
87} 86}
88#endif 87#endif
89 88
90int main(int argc, char **argv) { 89int main(int argc, char **argv) {
91// too bad this gives us trouble the taskbar... argv[0]="embeddedkonsole"; 90// too bad this gives us trouble the taskbar... argv[0]="embeddedkonsole";
92 QPEApplication app( argc, argv ); 91 QPEApplication app( argc, argv );
93 92
94#ifdef FSCKED_DISTRIBUTION 93#ifdef FSCKED_DISTRIBUTION
95 qWarning("fscked"); 94 qWarning("fscked");
96 FixIt it; 95 FixIt it;
97 it.fixIt(); 96 it.fixIt();
98#endif 97#endif
99 98
100 MainWindow mw; 99 MainWindow mw;
101 mw.setCaption(QObject::tr("Opie Console") ); 100 mw.setCaption(QObject::tr("Opie Console") );
102 app.showMainWidget( &mw ); 101 app.showMainWidget( &mw );
103 102
104 int ap = app.exec(); 103 int ap = app.exec();
105 104
106#ifdef FSCKED_DISTRIBUTION 105#ifdef FSCKED_DISTRIBUTION
107 /* should add a signal handler too */ 106 /* should add a signal handler too */
108 it.breakIt(); 107 it.breakIt();
109#endif 108#endif
110 return ap; 109 return ap;
111} 110}
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp
index 3c9603c..2673335 100644
--- a/noncore/apps/opie-console/mainwindow.cpp
+++ b/noncore/apps/opie-console/mainwindow.cpp
@@ -1,739 +1,729 @@
1#include <assert.h> 1#include <assert.h>
2 2
3#include <qaction.h> 3#include <qaction.h>
4#include <qmenubar.h> 4#include <qmenubar.h>
5#include <qlabel.h>
6#include <qpopupmenu.h>
7#include <qtoolbar.h> 5#include <qtoolbar.h>
8#include <qmessagebox.h> 6#include <qmessagebox.h>
9#include <qpushbutton.h>
10#include <qwhatsthis.h> 7#include <qwhatsthis.h>
11#include <qfileinfo.h> 8#include <qfileinfo.h>
12#include <qtextstream.h>
13 9
14#include <qpe/resource.h>
15#include <qpe/qpeapplication.h>
16#include <qpe/filemanager.h> 10#include <qpe/filemanager.h>
17#include <qpe/mimetype.h>
18 11
19#include <opie/ofiledialog.h> 12#include <opie/ofiledialog.h>
20 13
21#include "TEmulation.h" 14#include "TEmulation.h"
22#include "keytrans.h"
23#include "profileeditordialog.h" 15#include "profileeditordialog.h"
24#include "configdialog.h" 16#include "configdialog.h"
25#include "default.h" 17#include "default.h"
26#include "metafactory.h"
27#include "profile.h"
28#include "profilemanager.h" 18#include "profilemanager.h"
29#include "mainwindow.h" 19#include "mainwindow.h"
30#include "tabwidget.h" 20#include "tabwidget.h"
31#include "transferdialog.h" 21#include "transferdialog.h"
32#include "function_keyboard.h" 22#include "function_keyboard.h"
33#include "emulation_handler.h" 23#include "emulation_handler.h"
34#include "script.h" 24#include "script.h"
35 25
36 26
37MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) { 27MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) {
38 KeyTrans::loadAll(); 28 KeyTrans::loadAll();
39 for (int i = 0; i < KeyTrans::count(); i++ ) { 29 for (int i = 0; i < KeyTrans::count(); i++ ) {
40 KeyTrans* s = KeyTrans::find(i ); 30 KeyTrans* s = KeyTrans::find(i );
41 assert( s ); 31 assert( s );
42 } 32 }
43 m_factory = new MetaFactory(); 33 m_factory = new MetaFactory();
44 Default def(m_factory); 34 Default def(m_factory);
45 m_sessions.setAutoDelete( TRUE ); 35 m_sessions.setAutoDelete( TRUE );
46 m_curSession = 0; 36 m_curSession = 0;
47 m_manager = new ProfileManager( m_factory ); 37 m_manager = new ProfileManager( m_factory );
48 m_manager->load(); 38 m_manager->load();
49 m_scriptsData.setAutoDelete(TRUE); 39 m_scriptsData.setAutoDelete(TRUE);
50 40
51 initUI(); 41 initUI();
52 populateProfiles(); 42 populateProfiles();
53 populateScripts(); 43 populateScripts();
54} 44}
55 45
56void MainWindow::initUI() { 46void MainWindow::initUI() {
57 47
58 setToolBarsMovable( FALSE ); 48 setToolBarsMovable( FALSE );
59 49
60 /* tool bar for the menu */ 50 /* tool bar for the menu */
61 m_tool = new QToolBar( this ); 51 m_tool = new QToolBar( this );
62 m_tool->setHorizontalStretchable( TRUE ); 52 m_tool->setHorizontalStretchable( TRUE );
63 53
64 m_bar = new QMenuBar( m_tool ); 54 m_bar = new QMenuBar( m_tool );
65 m_console = new QPopupMenu( this ); 55 m_console = new QPopupMenu( this );
66 m_scripts = new QPopupMenu( this ); 56 m_scripts = new QPopupMenu( this );
67 m_sessionsPop= new QPopupMenu( this ); 57 m_sessionsPop= new QPopupMenu( this );
68 m_scriptsPop = new QPopupMenu( this ); 58 m_scriptsPop = new QPopupMenu( this );
69 59
70 /* add a toolbar for icons */ 60 /* add a toolbar for icons */
71 m_icons = new QToolBar(this); 61 m_icons = new QToolBar(this);
72 62
73 /* 63 /*
74 * the settings action 64 * the settings action
75 */ 65 */
76 m_setProfiles = new QAction(tr("Configure Profiles"), 66 m_setProfiles = new QAction(tr("Configure Profiles"),
77 Resource::loadPixmap( "SettingsIcon" ), 67 Resource::loadPixmap( "SettingsIcon" ),
78 QString::null, 0, this, 0); 68 QString::null, 0, this, 0);
79 m_setProfiles->addTo( m_console ); 69 m_setProfiles->addTo( m_console );
80 connect( m_setProfiles, SIGNAL(activated() ), 70 connect( m_setProfiles, SIGNAL(activated() ),
81 this, SLOT(slotConfigure() ) ); 71 this, SLOT(slotConfigure() ) );
82 72
83 m_console->insertSeparator(); 73 m_console->insertSeparator();
84 /* 74 /*
85 * new Action for new sessions 75 * new Action for new sessions
86 */ 76 */
87 QAction* newCon = new QAction(tr("New Profile"), 77 QAction* newCon = new QAction(tr("New Profile"),
88 Resource::loadPixmap( "new" ), 78 Resource::loadPixmap( "new" ),
89 QString::null, 0, this, 0); 79 QString::null, 0, this, 0);
90 newCon->addTo( m_console ); 80 newCon->addTo( m_console );
91 connect( newCon, SIGNAL(activated() ), 81 connect( newCon, SIGNAL(activated() ),
92 this, SLOT(slotNew() ) ); 82 this, SLOT(slotNew() ) );
93 83
94 m_console->insertSeparator(); 84 m_console->insertSeparator();
95 85
96 QAction *saveCon = new QAction( tr("Save Profile" ), 86 QAction *saveCon = new QAction( tr("Save Profile" ),
97 Resource::loadPixmap( "save" ), QString::null, 87 Resource::loadPixmap( "save" ), QString::null,
98 0, this, 0 ); 88 0, this, 0 );
99 saveCon->addTo( m_console ); 89 saveCon->addTo( m_console );
100 connect( saveCon, SIGNAL(activated() ), 90 connect( saveCon, SIGNAL(activated() ),
101 this, SLOT(slotSaveSession() ) ); 91 this, SLOT(slotSaveSession() ) );
102 m_console->insertSeparator(); 92 m_console->insertSeparator();
103 93
104 /* 94 /*
105 * connect action 95 * connect action
106 */ 96 */
107 m_connect = new QAction( tr("Connect"), Resource::loadPixmap("console/connected"), 97 m_connect = new QAction( tr("Connect"), Resource::loadPixmap("console/connected"),
108 QString::null, 0, this, 0 ); 98 QString::null, 0, this, 0 );
109 m_connect->addTo( m_console ); 99 m_connect->addTo( m_console );
110 connect(m_connect, SIGNAL(activated() ), 100 connect(m_connect, SIGNAL(activated() ),
111 this, SLOT(slotConnect() ) ); 101 this, SLOT(slotConnect() ) );
112 102
113 /* 103 /*
114 * disconnect action 104 * disconnect action
115 */ 105 */
116 m_disconnect = new QAction( tr("Disconnect"), Resource::loadPixmap("console/notconnected"), 106 m_disconnect = new QAction( tr("Disconnect"), Resource::loadPixmap("console/notconnected"),
117 QString::null, 0, this, 0 ); 107 QString::null, 0, this, 0 );
118 m_disconnect->addTo( m_console ); 108 m_disconnect->addTo( m_console );
119 connect(m_disconnect, SIGNAL(activated() ), 109 connect(m_disconnect, SIGNAL(activated() ),
120 this, SLOT(slotDisconnect() ) ); 110 this, SLOT(slotDisconnect() ) );
121 111
122 m_console->insertSeparator(); 112 m_console->insertSeparator();
123 113
124 114
125 m_quickLaunch = new QAction( tr("QuickLaunch"), Resource::loadPixmap("console/konsole_mini"), QString::null, 0, this, 0 ); 115 m_quickLaunch = new QAction( tr("QuickLaunch"), Resource::loadPixmap("console/konsole_mini"), QString::null, 0, this, 0 );
126 m_quickLaunch->addTo( m_icons ); 116 m_quickLaunch->addTo( m_icons );
127 connect( m_quickLaunch, SIGNAL( activated() ), 117 connect( m_quickLaunch, SIGNAL( activated() ),
128 this, SLOT( slotQuickLaunch() ) ); 118 this, SLOT( slotQuickLaunch() ) );
129 119
130 QWhatsThis::add( m_icons, tr( "The shell button launches the \"default\" profile. If there is none default values are taken" ) ); 120 QWhatsThis::add( m_icons, tr( "The shell button launches the \"default\" profile. If there is none default values are taken" ) );
131 121
132 m_transfer = new QAction( tr("Transfer file..."), Resource::loadPixmap("pass") , QString::null, 122 m_transfer = new QAction( tr("Transfer file..."), Resource::loadPixmap("pass") , QString::null,
133 0, this, 0 ); 123 0, this, 0 );
134 m_transfer->addTo( m_console ); 124 m_transfer->addTo( m_console );
135 connect(m_transfer, SIGNAL(activated() ), 125 connect(m_transfer, SIGNAL(activated() ),
136 this, SLOT(slotTransfer() ) ); 126 this, SLOT(slotTransfer() ) );
137 127
138 128
139 129
140 /* 130 /*
141 * immediate change of line wrap policy 131 * immediate change of line wrap policy
142 */ 132 */
143 m_isWrapped = false; 133 m_isWrapped = false;
144 m_wrap = new QAction( tr("Line wrap"), Resource::loadPixmap( "linewrap" ), QString::null, 0, this, 0 ); 134 m_wrap = new QAction( tr("Line wrap"), Resource::loadPixmap( "linewrap" ), QString::null, 0, this, 0 );
145 m_wrap->addTo( m_console ); 135 m_wrap->addTo( m_console );
146 connect( m_wrap, SIGNAL( activated() ), SLOT( slotWrap() ) ); 136 connect( m_wrap, SIGNAL( activated() ), SLOT( slotWrap() ) );
147 137
148 /* 138 /*
149 * fullscreen 139 * fullscreen
150 */ 140 */
151 m_isFullscreen = false; 141 m_isFullscreen = false;
152 142
153 m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" ) 143 m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" )
154 , QString::null, 0, this, 0); 144 , QString::null, 0, this, 0);
155 m_fullscreen->addTo( m_console ); 145 m_fullscreen->addTo( m_console );
156 connect( m_fullscreen, SIGNAL( activated() ), 146 connect( m_fullscreen, SIGNAL( activated() ),
157 this, SLOT( slotFullscreen() ) ); 147 this, SLOT( slotFullscreen() ) );
158 148
159 m_console->insertSeparator(); 149 m_console->insertSeparator();
160 150
161 QAction *a = new QAction(); 151 QAction *a = new QAction();
162 a->setText( tr("Save history") ); 152 a->setText( tr("Save history") );
163 a->addTo( m_console ); 153 a->addTo( m_console );
164 connect(a, SIGNAL(activated() ), 154 connect(a, SIGNAL(activated() ),
165 this, SLOT(slotSaveHistory() ) ); 155 this, SLOT(slotSaveHistory() ) );
166 /* 156 /*
167 * terminate action 157 * terminate action
168 */ 158 */
169 m_terminate = new QAction(); 159 m_terminate = new QAction();
170 m_terminate->setText( tr("Terminate") ); 160 m_terminate->setText( tr("Terminate") );
171 m_terminate->addTo( m_console ); 161 m_terminate->addTo( m_console );
172 connect(m_terminate, SIGNAL(activated() ), 162 connect(m_terminate, SIGNAL(activated() ),
173 this, SLOT(slotTerminate() ) ); 163 this, SLOT(slotTerminate() ) );
174 164
175 m_closewindow = new QAction(); 165 m_closewindow = new QAction();
176 m_closewindow->setText( tr("Close Window") ); 166 m_closewindow->setText( tr("Close Window") );
177 m_closewindow->addTo( m_console ); 167 m_closewindow->addTo( m_console );
178 connect( m_closewindow, SIGNAL(activated() ), 168 connect( m_closewindow, SIGNAL(activated() ),
179 this, SLOT(slotClose() ) ); 169 this, SLOT(slotClose() ) );
180 170
181 171
182 /* 172 /*
183 * script actions 173 * script actions
184 */ 174 */
185 m_runScript_id = m_scripts->insertItem(tr("Run Script"), m_scriptsPop, -1, 0); 175 m_runScript_id = m_scripts->insertItem(tr("Run Script"), m_scriptsPop, -1, 0);
186 connect(m_scriptsPop, SIGNAL(activated(int)), this, SLOT(slotRunScript(int))); 176 connect(m_scriptsPop, SIGNAL(activated(int)), this, SLOT(slotRunScript(int)));
187 177
188 m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0); 178 m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0);
189 m_recordScript->addTo(m_scripts); 179 m_recordScript->addTo(m_scripts);
190 connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript())); 180 connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript()));
191 181
192 m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0); 182 m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0);
193 m_saveScript->addTo(m_scripts); 183 m_saveScript->addTo(m_scripts);
194 connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript())); 184 connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript()));
195 185
196 186
197 /* 187 /*
198 * action that open/closes the keyboard 188 * action that open/closes the keyboard
199 */ 189 */
200 m_openKeys = new QAction (tr("Open Keyboard..."), 190 m_openKeys = new QAction (tr("Open Keyboard..."),
201 Resource::loadPixmap( "console/keys/keyboard_icon" ), 191 Resource::loadPixmap( "console/keys/keyboard_icon" ),
202 QString::null, 0, this, 0); 192 QString::null, 0, this, 0);
203 m_openKeys->setToggleAction(true); 193 m_openKeys->setToggleAction(true);
204 connect (m_openKeys, SIGNAL(toggled(bool)), this, SLOT(slotOpenKeb(bool))); 194 connect (m_openKeys, SIGNAL(toggled(bool)), this, SLOT(slotOpenKeb(bool)));
205 195
206 /* insert the submenu */ 196 /* insert the submenu */
207 m_console->insertItem(tr("New from Profile"), m_sessionsPop, 197 m_console->insertItem(tr("New from Profile"), m_sessionsPop,
208 -1, 0); 198 -1, 0);
209 199
210 /* insert the connection menu */ 200 /* insert the connection menu */
211 m_bar->insertItem( tr("Connection"), m_console ); 201 m_bar->insertItem( tr("Connection"), m_console );
212 202
213 /* the scripts menu */ 203 /* the scripts menu */
214 m_bar->insertItem( tr("Scripts"), m_scripts ); 204 m_bar->insertItem( tr("Scripts"), m_scripts );
215 205
216 /* and the keyboard */ 206 /* and the keyboard */
217 m_keyBar = new QToolBar(this); 207 m_keyBar = new QToolBar(this);
218 addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); 208 addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE );
219 m_keyBar->setHorizontalStretchable( TRUE ); 209 m_keyBar->setHorizontalStretchable( TRUE );
220 m_keyBar->hide(); 210 m_keyBar->hide();
221 211
222 m_kb = new FunctionKeyboard(m_keyBar); 212 m_kb = new FunctionKeyboard(m_keyBar);
223 connect(m_kb, SIGNAL(keyPressed(FKey, ushort, ushort, bool)), 213 connect(m_kb, SIGNAL(keyPressed(FKey, ushort, ushort, bool)),
224 this, SLOT(slotKeyReceived(FKey, ushort, ushort, bool))); 214 this, SLOT(slotKeyReceived(FKey, ushort, ushort, bool)));
225 215
226 216
227 a = new QAction(tr("Copy"), 217 a = new QAction(tr("Copy"),
228 Resource::loadPixmap("copy"), QString::null, 218 Resource::loadPixmap("copy"), QString::null,
229 0, this, 0 ); 219 0, this, 0 );
230 //a->addTo( m_icons ); 220 //a->addTo( m_icons );
231 connect( a, SIGNAL(activated() ), 221 connect( a, SIGNAL(activated() ),
232 this, SLOT(slotCopy() ) ); 222 this, SLOT(slotCopy() ) );
233 223
234 QAction *paste = new QAction(tr("Paste"), 224 QAction *paste = new QAction(tr("Paste"),
235 Resource::loadPixmap("paste"), QString::null, 225 Resource::loadPixmap("paste"), QString::null,
236 0, this, 0 ); 226 0, this, 0 );
237 connect( paste, SIGNAL(activated() ), 227 connect( paste, SIGNAL(activated() ),
238 this, SLOT(slotPaste() ) ); 228 this, SLOT(slotPaste() ) );
239 229
240 230
241 newCon->addTo( m_icons ); 231 newCon->addTo( m_icons );
242 //m_setProfiles->addTo( m_icons ); 232 //m_setProfiles->addTo( m_icons );
243 paste->addTo( m_icons ); 233 paste->addTo( m_icons );
244 m_openKeys->addTo(m_icons); 234 m_openKeys->addTo(m_icons);
245 m_fullscreen->addTo( m_icons ); 235 m_fullscreen->addTo( m_icons );
246 236
247 m_connect->setEnabled( false ); 237 m_connect->setEnabled( false );
248 m_disconnect->setEnabled( false ); 238 m_disconnect->setEnabled( false );
249 m_terminate->setEnabled( false ); 239 m_terminate->setEnabled( false );
250 m_transfer->setEnabled( false ); 240 m_transfer->setEnabled( false );
251 m_scripts->setItemEnabled(m_runScript_id, false); 241 m_scripts->setItemEnabled(m_runScript_id, false);
252 m_recordScript->setEnabled( false ); 242 m_recordScript->setEnabled( false );
253 m_saveScript->setEnabled( false ); 243 m_saveScript->setEnabled( false );
254 m_fullscreen->setEnabled( false ); 244 m_fullscreen->setEnabled( false );
255 m_closewindow->setEnabled( false ); 245 m_closewindow->setEnabled( false );
256 m_wrap->setEnabled( false ); 246 m_wrap->setEnabled( false );
257 247
258 /* 248 /*
259 * connect to the menu activation 249 * connect to the menu activation
260 */ 250 */
261 connect( m_sessionsPop, SIGNAL(activated( int ) ), 251 connect( m_sessionsPop, SIGNAL(activated( int ) ),
262 this, SLOT(slotProfile( int ) ) ); 252 this, SLOT(slotProfile( int ) ) );
263 253
264 m_consoleWindow = new TabWidget( this, "blah"); 254 m_consoleWindow = new TabWidget( this, "blah");
265 connect(m_consoleWindow, SIGNAL(activated(Session*) ), 255 connect(m_consoleWindow, SIGNAL(activated(Session*) ),
266 this, SLOT(slotSessionChanged(Session*) ) ); 256 this, SLOT(slotSessionChanged(Session*) ) );
267 setCentralWidget( m_consoleWindow ); 257 setCentralWidget( m_consoleWindow );
268 258
269 slotQuickLaunch(); 259 slotQuickLaunch();
270} 260}
271 261
272ProfileManager* MainWindow::manager() { 262ProfileManager* MainWindow::manager() {
273 return m_manager; 263 return m_manager;
274} 264}
275TabWidget* MainWindow::tabWidget() { 265TabWidget* MainWindow::tabWidget() {
276 return m_consoleWindow; 266 return m_consoleWindow;
277} 267}
278void MainWindow::populateProfiles() { 268void MainWindow::populateProfiles() {
279 m_sessionsPop->clear(); 269 m_sessionsPop->clear();
280 Profile::ValueList list = manager()->all(); 270 Profile::ValueList list = manager()->all();
281 for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { 271 for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) {
282 m_sessionsPop->insertItem( (*it).name() ); 272 m_sessionsPop->insertItem( (*it).name() );
283 } 273 }
284 274
285} 275}
286 276
287void MainWindow::populateScripts() { 277void MainWindow::populateScripts() {
288 m_scriptsPop->clear(); 278 m_scriptsPop->clear();
289 m_scriptsData.clear(); 279 m_scriptsData.clear();
290 DocLnkSet files(QPEApplication::documentDir(), "text/plain"); 280 DocLnkSet files(QPEApplication::documentDir(), "text/plain");
291 QListIterator<DocLnk> dit(files.children()); 281 QListIterator<DocLnk> dit(files.children());
292 for (; dit.current(); ++dit) { 282 for (; dit.current(); ++dit) {
293 if (*dit && (*dit)->name().length()>0) { 283 if (*dit && (*dit)->name().length()>0) {
294 QFileInfo info((*dit)->file()); 284 QFileInfo info((*dit)->file());
295 if (info.extension(false) == "script") { 285 if (info.extension(false) == "script") {
296 m_scriptsData.append(new DocLnk(**dit)); 286 m_scriptsData.append(new DocLnk(**dit));
297 m_scriptsPop->insertItem((*dit)->name()); 287 m_scriptsPop->insertItem((*dit)->name());
298 } 288 }
299 } 289 }
300 } 290 }
301 291
302} 292}
303 293
304MainWindow::~MainWindow() { 294MainWindow::~MainWindow() {
305 delete m_factory; 295 delete m_factory;
306 manager()->save(); 296 manager()->save();
307} 297}
308 298
309MetaFactory* MainWindow::factory() { 299MetaFactory* MainWindow::factory() {
310 return m_factory; 300 return m_factory;
311} 301}
312 302
313Session* MainWindow::currentSession() { 303Session* MainWindow::currentSession() {
314 return m_curSession; 304 return m_curSession;
315} 305}
316 306
317QList<Session> MainWindow::sessions() { 307QList<Session> MainWindow::sessions() {
318 return m_sessions; 308 return m_sessions;
319} 309}
320 310
321void MainWindow::slotNew() { 311void MainWindow::slotNew() {
322 ProfileEditorDialog dlg(factory() ); 312 ProfileEditorDialog dlg(factory() );
323 dlg.showMaximized(); 313 dlg.showMaximized();
324 dlg.setCaption( tr("New Connection") ); 314 dlg.setCaption( tr("New Connection") );
325 int ret = dlg.exec(); 315 int ret = dlg.exec();
326 316
327 if ( ret == QDialog::Accepted ) { 317 if ( ret == QDialog::Accepted ) {
328 create( dlg.profile() ); 318 create( dlg.profile() );
329 } 319 }
330} 320}
331 321
332void MainWindow::slotRecordScript() { 322void MainWindow::slotRecordScript() {
333 if (currentSession()) { 323 if (currentSession()) {
334 currentSession()->emulationHandler()->startRecording(); 324 currentSession()->emulationHandler()->startRecording();
335 m_saveScript->setEnabled(true); 325 m_saveScript->setEnabled(true);
336 m_recordScript->setEnabled(false); 326 m_recordScript->setEnabled(false);
337 } 327 }
338} 328}
339 329
340void MainWindow::slotSaveScript() { 330void MainWindow::slotSaveScript() {
341 if (currentSession() && currentSession()->emulationHandler()->isRecording()) { 331 if (currentSession() && currentSession()->emulationHandler()->isRecording()) {
342 QMap<QString, QStringList> map; 332 QMap<QString, QStringList> map;
343 QStringList text; 333 QStringList text;
344 text << "text/plain"; 334 text << "text/plain";
345 map.insert(tr("Script"), text ); 335 map.insert(tr("Script"), text );
346 QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); 336 QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map);
347 if (!filename.isEmpty()) { 337 if (!filename.isEmpty()) {
348 QFileInfo info(filename); 338 QFileInfo info(filename);
349 if (info.extension(FALSE) != "script") 339 if (info.extension(FALSE) != "script")
350 filename += ".script"; 340 filename += ".script";
351 DocLnk nf; 341 DocLnk nf;
352 nf.setType("text/plain"); 342 nf.setType("text/plain");
353 nf.setFile(filename); 343 nf.setFile(filename);
354 nf.setName(info.fileName()); 344 nf.setName(info.fileName());
355 FileManager fm; 345 FileManager fm;
356 fm.saveFile(nf, currentSession()->emulationHandler()->script()->script()); 346 fm.saveFile(nf, currentSession()->emulationHandler()->script()->script());
357 currentSession()->emulationHandler()->clearScript(); 347 currentSession()->emulationHandler()->clearScript();
358 m_saveScript->setEnabled(false); 348 m_saveScript->setEnabled(false);
359 m_recordScript->setEnabled(true); 349 m_recordScript->setEnabled(true);
360 populateScripts(); 350 populateScripts();
361 } 351 }
362 } 352 }
363} 353}
364 354
365void MainWindow::slotRunScript(int id) { 355void MainWindow::slotRunScript(int id) {
366 if (currentSession()) { 356 if (currentSession()) {
367 int index = m_scriptsPop->indexOf(id); 357 int index = m_scriptsPop->indexOf(id);
368 DocLnk *lnk = m_scriptsData.at(index); 358 DocLnk *lnk = m_scriptsData.at(index);
369 QString filePath = lnk->file(); 359 QString filePath = lnk->file();
370 Script script(filePath); 360 Script script(filePath);
371 currentSession()->emulationHandler()->runScript(&script); 361 currentSession()->emulationHandler()->runScript(&script);
372 } 362 }
373} 363}
374 364
375void MainWindow::slotConnect() { 365void MainWindow::slotConnect() {
376 if ( currentSession() ) { 366 if ( currentSession() ) {
377 bool ret = currentSession()->layer()->open(); 367 bool ret = currentSession()->layer()->open();
378 if(!ret) QMessageBox::warning(currentSession()->widgetStack(), 368 if(!ret) QMessageBox::warning(currentSession()->widgetStack(),
379 QObject::tr("Failed"), 369 QObject::tr("Failed"),
380 QObject::tr("Connecting failed for this session.")); 370 QObject::tr("Connecting failed for this session."));
381 else { 371 else {
382 m_connect->setEnabled( false ); 372 m_connect->setEnabled( false );
383 m_disconnect->setEnabled( true ); 373 m_disconnect->setEnabled( true );
384 374
385 // if it does not support file transfer, disable the menu entry 375 // if it does not support file transfer, disable the menu entry
386 if ( ( m_curSession->layer() )->supports()[1] == 0 ) { 376 if ( ( m_curSession->layer() )->supports()[1] == 0 ) {
387 m_transfer->setEnabled( false ); 377 m_transfer->setEnabled( false );
388 } else { 378 } else {
389 m_transfer->setEnabled( true ); 379 m_transfer->setEnabled( true );
390 } 380 }
391 381
392 m_recordScript->setEnabled( true ); 382 m_recordScript->setEnabled( true );
393 m_scripts->setItemEnabled(m_runScript_id, true); 383 m_scripts->setItemEnabled(m_runScript_id, true);
394 } 384 }
395 } 385 }
396} 386}
397 387
398void MainWindow::slotDisconnect() { 388void MainWindow::slotDisconnect() {
399 if ( currentSession() ) { 389 if ( currentSession() ) {
400 currentSession()->layer()->close(); 390 currentSession()->layer()->close();
401 m_connect->setEnabled( true ); 391 m_connect->setEnabled( true );
402 m_disconnect->setEnabled( false ); 392 m_disconnect->setEnabled( false );
403 m_transfer->setEnabled( false ); 393 m_transfer->setEnabled( false );
404 m_recordScript->setEnabled( false); 394 m_recordScript->setEnabled( false);
405 m_saveScript->setEnabled( false ); 395 m_saveScript->setEnabled( false );
406 m_scripts->setItemEnabled(m_runScript_id, false); 396 m_scripts->setItemEnabled(m_runScript_id, false);
407 } 397 }
408} 398}
409 399
410void MainWindow::slotTerminate() { 400void MainWindow::slotTerminate() {
411 if ( currentSession() ) 401 if ( currentSession() )
412 currentSession()->layer()->close(); 402 currentSession()->layer()->close();
413 403
414 slotClose(); 404 slotClose();
415 /* FIXME move to the next session */ 405 /* FIXME move to the next session */
416} 406}
417 407
418 408
419 409
420 410
421 411
422 412
423void MainWindow::slotQuickLaunch() { 413void MainWindow::slotQuickLaunch() {
424 Profile prof = manager()->profile( "default" ); 414 Profile prof = manager()->profile( "default" );
425 if ( prof.name() == "default" ) { 415 if ( prof.name() == "default" ) {
426 create( prof ); 416 create( prof );
427 } else { 417 } else {
428 Profile newProf = Profile( "default", "console", "default" , 0, 3, 0 ); 418 Profile newProf = Profile( "default", "console", "default" , 0, 3, 0 );
429 newProf.setAutoConnect( true ); 419 newProf.setAutoConnect( true );
430 create( newProf ); 420 create( newProf );
431 slotSaveSession(); 421 slotSaveSession();
432 } 422 }
433 423
434} 424}
435 425
436void MainWindow::slotConfigure() { 426void MainWindow::slotConfigure() {
437 ConfigDialog conf( manager()->all(), factory() ); 427 ConfigDialog conf( manager()->all(), factory() );
438 conf.showMaximized(); 428 conf.showMaximized();
439 429
440 int ret = conf.exec(); 430 int ret = conf.exec();
441 431
442 if ( QDialog::Accepted == ret ) { 432 if ( QDialog::Accepted == ret ) {
443 manager()->setProfiles( conf.list() ); 433 manager()->setProfiles( conf.list() );
444 manager()->save(); 434 manager()->save();
445 populateProfiles(); 435 populateProfiles();
446 } 436 }
447} 437}
448/* 438/*
449 * we will remove 439 * we will remove
450 * this window from the tabwidget 440 * this window from the tabwidget
451 * remove it from the list 441 * remove it from the list
452 * delete it 442 * delete it
453 * and set the currentSession() 443 * and set the currentSession()
454 */ 444 */
455void MainWindow::slotClose() { 445void MainWindow::slotClose() {
456 if (!currentSession() ) 446 if (!currentSession() )
457 return; 447 return;
458 448
459 Session* ses = currentSession(); 449 Session* ses = currentSession();
460 qWarning("removing! currentSession %s", currentSession()->name().latin1() ); 450 qWarning("removing! currentSession %s", currentSession()->name().latin1() );
461 /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */ 451 /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */
462 m_curSession = NULL; 452 m_curSession = NULL;
463 tabWidget()->remove( /*currentSession()*/ses ); 453 tabWidget()->remove( /*currentSession()*/ses );
464 /*it's autodelete */ 454 /*it's autodelete */
465 m_sessions.remove( ses ); 455 m_sessions.remove( ses );
466 qWarning("after remove!!"); 456 qWarning("after remove!!");
467 457
468 if (!currentSession() ) { 458 if (!currentSession() ) {
469 m_connect->setEnabled( false ); 459 m_connect->setEnabled( false );
470 m_disconnect->setEnabled( false ); 460 m_disconnect->setEnabled( false );
471 m_terminate->setEnabled( false ); 461 m_terminate->setEnabled( false );
472 m_transfer->setEnabled( false ); 462 m_transfer->setEnabled( false );
473 m_recordScript->setEnabled( false ); 463 m_recordScript->setEnabled( false );
474 m_saveScript->setEnabled( false ); 464 m_saveScript->setEnabled( false );
475 m_scripts->setItemEnabled(m_runScript_id, false); 465 m_scripts->setItemEnabled(m_runScript_id, false);
476 m_fullscreen->setEnabled( false ); 466 m_fullscreen->setEnabled( false );
477 m_wrap->setEnabled( false ); 467 m_wrap->setEnabled( false );
478 m_closewindow->setEnabled( false ); 468 m_closewindow->setEnabled( false );
479 } 469 }
480 470
481 m_kb->loadDefaults(); 471 m_kb->loadDefaults();
482} 472}
483 473
484/* 474/*
485 * We will get the name 475 * We will get the name
486 * Then the profile 476 * Then the profile
487 * and then we will make a profile 477 * and then we will make a profile
488 */ 478 */
489void MainWindow::slotProfile( int id) { 479void MainWindow::slotProfile( int id) {
490 Profile prof = manager()->profile( m_sessionsPop->text( id) ); 480 Profile prof = manager()->profile( m_sessionsPop->text( id) );
491 create( prof ); 481 create( prof );
492} 482}
493 483
494 484
495 485
496void MainWindow::create( const Profile& prof ) { 486void MainWindow::create( const Profile& prof ) {
497 if(m_curSession) 487 if(m_curSession)
498 if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); 488 if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide();
499 489
500 Session *ses = manager()->fromProfile( prof, tabWidget() ); 490 Session *ses = manager()->fromProfile( prof, tabWidget() );
501 491
502 if((!ses) || (!ses->layer()) || (!ses->widgetStack())) 492 if((!ses) || (!ses->layer()) || (!ses->widgetStack()))
503 { 493 {
504 QMessageBox::warning(this, 494 QMessageBox::warning(this,
505 QObject::tr("Session failed"), 495 QObject::tr("Session failed"),
506 QObject::tr("<qt>Cannot open session: Not all components were found.</qt>")); 496 QObject::tr("<qt>Cannot open session: Not all components were found.</qt>"));
507 //if(ses) delete ses; 497 //if(ses) delete ses;
508 return; 498 return;
509 } 499 }
510 500
511 m_sessions.append( ses ); 501 m_sessions.append( ses );
512 tabWidget()->add( ses ); 502 tabWidget()->add( ses );
513 tabWidget()->repaint(); 503 tabWidget()->repaint();
514 m_curSession = ses; 504 m_curSession = ses;
515 505
516 // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it 506 // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it
517 m_connect->setEnabled( true ); 507 m_connect->setEnabled( true );
518 m_disconnect->setEnabled( false ); 508 m_disconnect->setEnabled( false );
519 m_terminate->setEnabled( true ); 509 m_terminate->setEnabled( true );
520 m_fullscreen->setEnabled( true ); 510 m_fullscreen->setEnabled( true );
521 m_wrap->setEnabled( true ); 511 m_wrap->setEnabled( true );
522 m_closewindow->setEnabled( true ); 512 m_closewindow->setEnabled( true );
523 m_transfer->setEnabled( false ); 513 m_transfer->setEnabled( false );
524 m_recordScript->setEnabled( false ); 514 m_recordScript->setEnabled( false );
525 m_saveScript->setEnabled( false ); 515 m_saveScript->setEnabled( false );
526 m_scripts->setItemEnabled(m_runScript_id, false); 516 m_scripts->setItemEnabled(m_runScript_id, false);
527 517
528 // is io_layer wants direct connection, then autoconnect 518 // is io_layer wants direct connection, then autoconnect
529 //if ( ( m_curSession->layer() )->supports()[0] == 1 ) { 519 //if ( ( m_curSession->layer() )->supports()[0] == 1 ) {
530 if (prof.autoConnect()) { 520 if (prof.autoConnect()) {
531 slotConnect(); 521 slotConnect();
532 } 522 }
533 523
534 524
535 QWidget *w = currentSession()->widget(); 525 QWidget *w = currentSession()->widget();
536 if(w) w->setFocus(); 526 if(w) w->setFocus();
537 527
538 if(currentSession()->profile().readNumEntry("Wrap", 80)){ 528 if(currentSession()->profile().readNumEntry("Wrap", 80)){
539 m_isWrapped = true; 529 m_isWrapped = true;
540 } else { 530 } else {
541 m_isWrapped = false; 531 m_isWrapped = false;
542 } 532 }
543 533
544 m_kb->load(currentSession()->profile()); 534 m_kb->load(currentSession()->profile());
545} 535}
546 536
547void MainWindow::slotTransfer() 537void MainWindow::slotTransfer()
548{ 538{
549 if ( currentSession() ) { 539 if ( currentSession() ) {
550 Session *mysession = currentSession(); 540 Session *mysession = currentSession();
551 TransferDialog dlg(/*mysession->widgetStack()*/this, this); 541 TransferDialog dlg(/*mysession->widgetStack()*/this, this);
552 mysession->setTransferDialog(&dlg); 542 mysession->setTransferDialog(&dlg);
553 //dlg.reparent(mysession->widgetStack(), QPoint(0, 0)); 543 //dlg.reparent(mysession->widgetStack(), QPoint(0, 0));
554 //dlg.showMaximized(); 544 //dlg.showMaximized();
555 currentSession()->widgetStack()->addWidget(&dlg, -1); 545 currentSession()->widgetStack()->addWidget(&dlg, -1);
556 dlg.show(); 546 dlg.show();
557 //dlg.exec(); 547 //dlg.exec();
558 while(dlg.isRunning()) qApp->processEvents(); 548 while(dlg.isRunning()) qApp->processEvents();
559 mysession->setTransferDialog(0l); 549 mysession->setTransferDialog(0l);
560 } 550 }
561} 551}
562 552
563 553
564void MainWindow::slotOpenKeb(bool state) { 554void MainWindow::slotOpenKeb(bool state) {
565 555
566 if (state) m_keyBar->show(); 556 if (state) m_keyBar->show();
567 else m_keyBar->hide(); 557 else m_keyBar->hide();
568 558
569} 559}
570 560
571 561
572void MainWindow::slotOpenButtons( bool state ) { 562void MainWindow::slotOpenButtons( bool state ) {
573 563
574 if ( state ) { 564 if ( state ) {
575 m_buttonBar->show(); 565 m_buttonBar->show();
576 } else { 566 } else {
577 m_buttonBar->hide(); 567 m_buttonBar->hide();
578 } 568 }
579} 569}
580 570
581 571
582 572
583void MainWindow::slotSessionChanged( Session* ses ) { 573void MainWindow::slotSessionChanged( Session* ses ) {
584 qWarning("changed!"); 574 qWarning("changed!");
585 575
586 if(m_curSession) 576 if(m_curSession)
587 if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); 577 if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide();
588 if(ses) 578 if(ses)
589 if(ses->transferDialog()) ses->transferDialog()->show(); 579 if(ses->transferDialog()) ses->transferDialog()->show();
590 580
591 if ( ses ) { 581 if ( ses ) {
592 m_curSession = ses; 582 m_curSession = ses;
593 qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) ); 583 qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) );
594 if ( m_curSession->layer()->isConnected() ) { 584 if ( m_curSession->layer()->isConnected() ) {
595 m_connect->setEnabled( false ); 585 m_connect->setEnabled( false );
596 m_disconnect->setEnabled( true ); 586 m_disconnect->setEnabled( true );
597 m_recordScript->setEnabled(!m_curSession->emulationHandler()->isRecording()); 587 m_recordScript->setEnabled(!m_curSession->emulationHandler()->isRecording());
598 m_saveScript->setEnabled(m_curSession->emulationHandler()->isRecording()); 588 m_saveScript->setEnabled(m_curSession->emulationHandler()->isRecording());
599 m_scripts->setItemEnabled(m_runScript_id, true); 589 m_scripts->setItemEnabled(m_runScript_id, true);
600 } else { 590 } else {
601 m_connect->setEnabled( true ); 591 m_connect->setEnabled( true );
602 m_disconnect->setEnabled( false ); 592 m_disconnect->setEnabled( false );
603 m_recordScript->setEnabled( false ); 593 m_recordScript->setEnabled( false );
604 m_saveScript->setEnabled( false ); 594 m_saveScript->setEnabled( false );
605 m_scripts->setItemEnabled(m_runScript_id, false); 595 m_scripts->setItemEnabled(m_runScript_id, false);
606 } 596 }
607 597
608 if ( ( m_curSession->layer() )->supports()[1] == 0 ) { 598 if ( ( m_curSession->layer() )->supports()[1] == 0 ) {
609 m_transfer->setEnabled( false ); 599 m_transfer->setEnabled( false );
610 } else { 600 } else {
611 m_transfer->setEnabled( true ); 601 m_transfer->setEnabled( true );
612 } 602 }
613 603
614 QWidget *w = m_curSession->widget(); 604 QWidget *w = m_curSession->widget();
615 if(w) w->setFocus(); 605 if(w) w->setFocus();
616 606
617 if(currentSession()->profile().readNumEntry("Wrap", 80)){ 607 if(currentSession()->profile().readNumEntry("Wrap", 80)){
618 m_isWrapped = true; 608 m_isWrapped = true;
619 } else { 609 } else {
620 m_isWrapped = false; 610 m_isWrapped = false;
621 } 611 }
622 612
623 m_kb->load(currentSession()->profile()); 613 m_kb->load(currentSession()->profile());
624 } 614 }
625} 615}
626 616
627void MainWindow::slotWrap() 617void MainWindow::slotWrap()
628{ 618{
629 if(m_curSession) 619 if(m_curSession)
630 { 620 {
631 EmulationHandler *e = m_curSession->emulationHandler(); 621 EmulationHandler *e = m_curSession->emulationHandler();
632 if(e) 622 if(e)
633 { 623 {
634 if(m_isWrapped) 624 if(m_isWrapped)
635 { 625 {
636 e->setWrap(80); 626 e->setWrap(80);
637 m_isWrapped = false; 627 m_isWrapped = false;
638 } 628 }
639 else 629 else
640 { 630 {
641 e->setWrap(0); 631 e->setWrap(0);
642 m_isWrapped = true; 632 m_isWrapped = true;
643 } 633 }
644 } 634 }
645 } 635 }
646} 636}
647 637
648void MainWindow::slotFullscreen() { 638void MainWindow::slotFullscreen() {
649 639
650 640
651 641
652 if ( m_isFullscreen ) { 642 if ( m_isFullscreen ) {
653 ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), true ); 643 ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), true );
654 ( m_curSession->widgetStack() )->resize( savedParentFullscreen->width(), savedParentFullscreen->height() ); 644 ( m_curSession->widgetStack() )->resize( savedParentFullscreen->width(), savedParentFullscreen->height() );
655 ( m_curSession->emulationHandler() )->cornerButton()->hide(); 645 ( m_curSession->emulationHandler() )->cornerButton()->hide();
656 disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); 646 disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) );
657 647
658 } else { 648 } else {
659 savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget(); 649 savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget();
660 ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); 650 ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame );
661 ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop 651 ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop
662 , QPoint(0,0), false ); 652 , QPoint(0,0), false );
663 ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() ); 653 ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() );
664 ( m_curSession->widgetStack() )->setFocus(); 654 ( m_curSession->widgetStack() )->setFocus();
665 ( m_curSession->widgetStack() )->show(); 655 ( m_curSession->widgetStack() )->show();
666 656
667 ( ( m_curSession->emulationHandler() )->cornerButton() )->show(); 657 ( ( m_curSession->emulationHandler() )->cornerButton() )->show();
668 658
669 connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); 659 connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) );
670 } 660 }
671 661
672 m_isFullscreen = !m_isFullscreen; 662 m_isFullscreen = !m_isFullscreen;
673} 663}
674 664
675 665
676void MainWindow::slotKeyReceived(FKey k, ushort, ushort, bool pressed) { 666void MainWindow::slotKeyReceived(FKey k, ushort, ushort, bool pressed) {
677 667
678 if ( m_curSession ) { 668 if ( m_curSession ) {
679 669
680 QEvent::Type state; 670 QEvent::Type state;
681 671
682 if (pressed) state = QEvent::KeyPress; 672 if (pressed) state = QEvent::KeyPress;
683 else state = QEvent::KeyRelease; 673 else state = QEvent::KeyRelease;
684 674
685 QKeyEvent ke(state, k.qcode, k.unicode, 0, QString(QChar(k.unicode))); 675 QKeyEvent ke(state, k.qcode, k.unicode, 0, QString(QChar(k.unicode)));
686 676
687 // is this the best way to do this? cant figure out any other way to work 677 // is this the best way to do this? cant figure out any other way to work
688 QApplication::sendEvent((QObject *)m_curSession->widget(), &ke); 678 QApplication::sendEvent((QObject *)m_curSession->widget(), &ke);
689 ke.ignore(); 679 ke.ignore();
690 } 680 }
691} 681}
692void MainWindow::slotCopy() { 682void MainWindow::slotCopy() {
693 if (!currentSession() ) return; 683 if (!currentSession() ) return;
694 currentSession()->emulationHandler()->copy(); 684 currentSession()->emulationHandler()->copy();
695} 685}
696void MainWindow::slotPaste() { 686void MainWindow::slotPaste() {
697 if (!currentSession() ) return; 687 if (!currentSession() ) return;
698 currentSession()->emulationHandler()->paste(); 688 currentSession()->emulationHandler()->paste();
699} 689}
700 690
701/* 691/*
702 * Save the session 692 * Save the session
703 */ 693 */
704 694
705void MainWindow::slotSaveSession() { 695void MainWindow::slotSaveSession() {
706 if (!currentSession() ) { 696 if (!currentSession() ) {
707 QMessageBox::information(this, tr("Save Connection"), 697 QMessageBox::information(this, tr("Save Connection"),
708 tr("<qt>There is no Connection.</qt>"), 1 ); 698 tr("<qt>There is no Connection.</qt>"), 1 );
709 return; 699 return;
710 } 700 }
711 manager()->add( currentSession()->profile() ); 701 manager()->add( currentSession()->profile() );
712 manager()->save(); 702 manager()->save();
713 populateProfiles(); 703 populateProfiles();
714} 704}
715void MainWindow::slotSaveHistory() { 705void MainWindow::slotSaveHistory() {
716 QMap<QString, QStringList> map; 706 QMap<QString, QStringList> map;
717 QStringList text; 707 QStringList text;
718 text << "text/plain"; 708 text << "text/plain";
719 map.insert(tr("History"), text ); 709 map.insert(tr("History"), text );
720 QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); 710 QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map);
721 if (filename.isEmpty() ) return; 711 if (filename.isEmpty() ) return;
722 712
723 QFileInfo info(filename); 713 QFileInfo info(filename);
724 714
725 DocLnk nf; 715 DocLnk nf;
726 nf.setType("text/plain"); 716 nf.setType("text/plain");
727 nf.setFile(filename); 717 nf.setFile(filename);
728 nf.setName(info.fileName()); 718 nf.setName(info.fileName());
729 719
730 720
731 QFile file(filename); 721 QFile file(filename);
732 file.open(IO_WriteOnly ); 722 file.open(IO_WriteOnly );
733 QTextStream str(&file ); 723 QTextStream str(&file );
734 if ( currentSession() ) 724 if ( currentSession() )
735 currentSession()->emulationHandler()->emulation()->streamHistory(&str); 725 currentSession()->emulationHandler()->emulation()->streamHistory(&str);
736 726
737 file.close(); 727 file.close();
738 nf.writeLink(); 728 nf.writeLink();
739} 729}
diff --git a/noncore/apps/opie-console/metafactory.cpp b/noncore/apps/opie-console/metafactory.cpp
index 24928e7..32e93ce 100644
--- a/noncore/apps/opie-console/metafactory.cpp
+++ b/noncore/apps/opie-console/metafactory.cpp
@@ -1,165 +1,164 @@
1#include <qpe/config.h>
2#include "metafactory.h" 1#include "metafactory.h"
3 2
4MetaFactory::MetaFactory() { 3MetaFactory::MetaFactory() {
5} 4}
6MetaFactory::~MetaFactory() { 5MetaFactory::~MetaFactory() {
7 6
8} 7}
9void MetaFactory::addConnectionWidgetFactory( const QCString& name, 8void MetaFactory::addConnectionWidgetFactory( const QCString& name,
10 const QString& str, 9 const QString& str,
11 configWidget wid) { 10 configWidget wid) {
12 m_strings.insert( str, name ); 11 m_strings.insert( str, name );
13 m_conFact.insert( str, wid ); 12 m_conFact.insert( str, wid );
14} 13}
15void MetaFactory::addTerminalWidgetFactory( const QCString& name, 14void MetaFactory::addTerminalWidgetFactory( const QCString& name,
16 const QString& str, 15 const QString& str,
17 configWidget wid ) { 16 configWidget wid ) {
18 m_strings.insert( str, name ); 17 m_strings.insert( str, name );
19 m_termFact.insert( str, wid ); 18 m_termFact.insert( str, wid );
20} 19}
21void MetaFactory::addKeyboardWidgetFactory( const QCString& name, 20void MetaFactory::addKeyboardWidgetFactory( const QCString& name,
22 const QString & str, 21 const QString & str,
23 configWidget wid) { 22 configWidget wid) {
24 m_strings.insert( str, name ); 23 m_strings.insert( str, name );
25 m_keyFact.insert( str, wid ); 24 m_keyFact.insert( str, wid );
26 25
27} 26}
28void MetaFactory::addIOLayerFactory( const QCString& name, 27void MetaFactory::addIOLayerFactory( const QCString& name,
29 const QString& str, 28 const QString& str,
30 iolayer lay) { 29 iolayer lay) {
31 m_strings.insert( str, name ); 30 m_strings.insert( str, name );
32 m_layerFact.insert( str, lay ); 31 m_layerFact.insert( str, lay );
33} 32}
34void MetaFactory::addFileTransferLayer( const QCString& name, 33void MetaFactory::addFileTransferLayer( const QCString& name,
35 const QString& str, 34 const QString& str,
36 filelayer lay) { 35 filelayer lay) {
37 m_strings.insert(str, name ); 36 m_strings.insert(str, name );
38 m_fileFact.insert( str, lay ); 37 m_fileFact.insert( str, lay );
39} 38}
40void MetaFactory::addReceiveLayer( const QCString& name, 39void MetaFactory::addReceiveLayer( const QCString& name,
41 const QString& str, 40 const QString& str,
42 receivelayer lay) { 41 receivelayer lay) {
43 m_strings.insert(str, name ); 42 m_strings.insert(str, name );
44 m_receiveFact.insert( str, lay ); 43 m_receiveFact.insert( str, lay );
45} 44}
46QStringList MetaFactory::ioLayers()const { 45QStringList MetaFactory::ioLayers()const {
47 QStringList list; 46 QStringList list;
48 QMap<QString, iolayer>::ConstIterator it; 47 QMap<QString, iolayer>::ConstIterator it;
49 for (it = m_layerFact.begin(); it != m_layerFact.end(); ++it ) { 48 for (it = m_layerFact.begin(); it != m_layerFact.end(); ++it ) {
50 list << it.key(); 49 list << it.key();
51 } 50 }
52 return list; 51 return list;
53} 52}
54QStringList MetaFactory::connectionWidgets()const { 53QStringList MetaFactory::connectionWidgets()const {
55 QStringList list; 54 QStringList list;
56 QMap<QString, configWidget>::ConstIterator it; 55 QMap<QString, configWidget>::ConstIterator it;
57 for ( it = m_conFact.begin(); it != m_conFact.end(); ++it ) { 56 for ( it = m_conFact.begin(); it != m_conFact.end(); ++it ) {
58 list << it.key(); 57 list << it.key();
59 } 58 }
60 return list; 59 return list;
61} 60}
62QStringList MetaFactory::terminalWidgets()const { 61QStringList MetaFactory::terminalWidgets()const {
63 QStringList list; 62 QStringList list;
64 QMap<QString, configWidget>::ConstIterator it; 63 QMap<QString, configWidget>::ConstIterator it;
65 for ( it = m_termFact.begin(); it != m_termFact.end(); ++it ) { 64 for ( it = m_termFact.begin(); it != m_termFact.end(); ++it ) {
66 list << it.key(); 65 list << it.key();
67 } 66 }
68 return list; 67 return list;
69} 68}
70QStringList MetaFactory::fileTransferLayers()const { 69QStringList MetaFactory::fileTransferLayers()const {
71 QStringList list; 70 QStringList list;
72 QMap<QString, filelayer>::ConstIterator it; 71 QMap<QString, filelayer>::ConstIterator it;
73 for ( it = m_fileFact.begin(); it != m_fileFact.end(); ++it ) { 72 for ( it = m_fileFact.begin(); it != m_fileFact.end(); ++it ) {
74 list << it.key(); 73 list << it.key();
75 } 74 }
76 return list; 75 return list;
77} 76}
78QStringList MetaFactory::receiveLayers()const { 77QStringList MetaFactory::receiveLayers()const {
79 QStringList list; 78 QStringList list;
80 QMap<QString, receivelayer>::ConstIterator it; 79 QMap<QString, receivelayer>::ConstIterator it;
81 for ( it = m_receiveFact.begin(); it != m_receiveFact.end(); ++it ) { 80 for ( it = m_receiveFact.begin(); it != m_receiveFact.end(); ++it ) {
82 list << it.key(); 81 list << it.key();
83 } 82 }
84 return list; 83 return list;
85} 84}
86 85
87IOLayer* MetaFactory::newIOLayer( const QString& str,const Profile& prof ) { 86IOLayer* MetaFactory::newIOLayer( const QString& str,const Profile& prof ) {
88 IOLayer* lay = 0l; 87 IOLayer* lay = 0l;
89 88
90 QMap<QString, iolayer>::Iterator it; 89 QMap<QString, iolayer>::Iterator it;
91 it = m_layerFact.find( str ); 90 it = m_layerFact.find( str );
92 if ( it != m_layerFact.end() ) { 91 if ( it != m_layerFact.end() ) {
93 lay = (*(it.data()))(prof); 92 lay = (*(it.data()))(prof);
94 /* 93 /*
95 iolayer laye = it.data(); 94 iolayer laye = it.data();
96 lay = (*laye )(conf);*/ 95 lay = (*laye )(conf);*/
97 } 96 }
98 97
99 return lay; 98 return lay;
100} 99}
101 100
102ProfileDialogWidget *MetaFactory::newConnectionPlugin ( const QString& str, QWidget *parent) { 101ProfileDialogWidget *MetaFactory::newConnectionPlugin ( const QString& str, QWidget *parent) {
103 ProfileDialogWidget* wid = 0l; 102 ProfileDialogWidget* wid = 0l;
104 103
105 QMap<QString, configWidget>::Iterator it; 104 QMap<QString, configWidget>::Iterator it;
106 it = m_conFact.find( str ); 105 it = m_conFact.find( str );
107 if ( it != m_conFact.end() ) { 106 if ( it != m_conFact.end() ) {
108 wid = (*(it.data() ) )(str,parent); 107 wid = (*(it.data() ) )(str,parent);
109 } 108 }
110 return wid; 109 return wid;
111} 110}
112ProfileDialogWidget *MetaFactory::newTerminalPlugin( const QString& str, QWidget *parent) { 111ProfileDialogWidget *MetaFactory::newTerminalPlugin( const QString& str, QWidget *parent) {
113 if (str.isEmpty() ) 112 if (str.isEmpty() )
114 return 0l; 113 return 0l;
115 ProfileDialogWidget* wid = 0l; 114 ProfileDialogWidget* wid = 0l;
116 115
117 QMap<QString, configWidget>::Iterator it; 116 QMap<QString, configWidget>::Iterator it;
118 it = m_termFact.find( str ); 117 it = m_termFact.find( str );
119 if ( it != m_termFact.end() ) { 118 if ( it != m_termFact.end() ) {
120 wid = (*(it.data() ) )(str,parent); 119 wid = (*(it.data() ) )(str,parent);
121 } 120 }
122 return wid; 121 return wid;
123} 122}
124ProfileDialogWidget *MetaFactory::newKeyboardPlugin( const QString& str, QWidget *parent) { 123ProfileDialogWidget *MetaFactory::newKeyboardPlugin( const QString& str, QWidget *parent) {
125 124
126 if (str.isEmpty() ) 125 if (str.isEmpty() )
127 return 0l; 126 return 0l;
128 ProfileDialogWidget* wid = 0l; 127 ProfileDialogWidget* wid = 0l;
129 128
130 QMap<QString, configWidget>::Iterator it; 129 QMap<QString, configWidget>::Iterator it;
131 it = m_keyFact.find( str ); 130 it = m_keyFact.find( str );
132 if ( it != m_keyFact.end() ) { 131 if ( it != m_keyFact.end() ) {
133 wid = (*(it.data() ) )(str,parent); 132 wid = (*(it.data() ) )(str,parent);
134 } 133 }
135 return wid; 134 return wid;
136} 135}
137FileTransferLayer* MetaFactory::newFileTransfer(const QString& str, IOLayer* lay ) { 136FileTransferLayer* MetaFactory::newFileTransfer(const QString& str, IOLayer* lay ) {
138 FileTransferLayer* file = 0l; 137 FileTransferLayer* file = 0l;
139 QMap<QString, filelayer>::Iterator it; 138 QMap<QString, filelayer>::Iterator it;
140 it = m_fileFact.find( str ); 139 it = m_fileFact.find( str );
141 if ( it != m_fileFact.end() ) { 140 if ( it != m_fileFact.end() ) {
142 file = (*(it.data() ) )(lay); 141 file = (*(it.data() ) )(lay);
143 } 142 }
144 return file; 143 return file;
145} 144}
146ReceiveLayer* MetaFactory::newReceive(const QString& str, IOLayer* lay ) { 145ReceiveLayer* MetaFactory::newReceive(const QString& str, IOLayer* lay ) {
147 ReceiveLayer* file = 0l; 146 ReceiveLayer* file = 0l;
148 QMap<QString, receivelayer>::Iterator it; 147 QMap<QString, receivelayer>::Iterator it;
149 it = m_receiveFact.find( str ); 148 it = m_receiveFact.find( str );
150 if ( it != m_receiveFact.end() ) { 149 if ( it != m_receiveFact.end() ) {
151 file = (*(it.data() ) )(lay); 150 file = (*(it.data() ) )(lay);
152 } 151 }
153 return file; 152 return file;
154} 153}
155QCString MetaFactory::internal( const QString& str )const { 154QCString MetaFactory::internal( const QString& str )const {
156 return m_strings[str]; 155 return m_strings[str];
157} 156}
158QString MetaFactory::external( const QCString& str )const { 157QString MetaFactory::external( const QCString& str )const {
159 QMap<QString, QCString>::ConstIterator it; 158 QMap<QString, QCString>::ConstIterator it;
160 for ( it = m_strings.begin(); it != m_strings.end(); ++it ) { 159 for ( it = m_strings.begin(); it != m_strings.end(); ++it ) {
161 if ( it.data() == str ) 160 if ( it.data() == str )
162 return it.key(); 161 return it.key();
163 } 162 }
164 return QString::null; 163 return QString::null;
165} 164}
diff --git a/noncore/apps/opie-console/modemconfigwidget.cpp b/noncore/apps/opie-console/modemconfigwidget.cpp
index f7fb6f3..e552990 100644
--- a/noncore/apps/opie-console/modemconfigwidget.cpp
+++ b/noncore/apps/opie-console/modemconfigwidget.cpp
@@ -1,257 +1,255 @@
1#include <qlabel.h> 1#include <qlabel.h>
2#include <qlayout.h> 2#include <qlayout.h>
3#include <qcombobox.h> 3#include <qcombobox.h>
4#include <qlineedit.h>
5#include <qpushbutton.h> 4#include <qpushbutton.h>
6#include <qhbox.h> 5#include <qhbox.h>
7#include <qregexp.h>
8 6
9#include "modemconfigwidget.h" 7#include "modemconfigwidget.h"
10#include "dialdialog.h" 8#include "dialdialog.h"
11 9
12namespace { 10namespace {
13 void setCurrent( const QString& str, QComboBox* bo ) { 11 void setCurrent( const QString& str, QComboBox* bo ) {
14 uint b = bo->count(); 12 uint b = bo->count();
15 for (int i = 0; i < bo->count(); i++ ) { 13 for (int i = 0; i < bo->count(); i++ ) {
16 if ( bo->text(i) == str ) { 14 if ( bo->text(i) == str ) {
17 bo->setCurrentItem( i ); 15 bo->setCurrentItem( i );
18 return; 16 return;
19 } 17 }
20 } 18 }
21 bo->insertItem( str ); 19 bo->insertItem( str );
22 bo->setCurrentItem( b ); 20 bo->setCurrentItem( b );
23 } 21 }
24} 22}
25 23
26ModemConfigWidget::ModemConfigWidget( const QString& name, QWidget* parent, 24ModemConfigWidget::ModemConfigWidget( const QString& name, QWidget* parent,
27 const char* na ) 25 const char* na )
28 : ProfileDialogConnectionWidget( name, parent, na ) { 26 : ProfileDialogConnectionWidget( name, parent, na ) {
29 27
30 m_lay = new QVBoxLayout( this ); 28 m_lay = new QVBoxLayout( this );
31 m_device = new QLabel(tr( "Modem is attached to:" ), this ); 29 m_device = new QLabel(tr( "Modem is attached to:" ), this );
32 m_deviceCmb = new QComboBox(this ); 30 m_deviceCmb = new QComboBox(this );
33 m_deviceCmb->setEditable( TRUE ); 31 m_deviceCmb->setEditable( TRUE );
34 32
35 QLabel* telLabel = new QLabel( this ); 33 QLabel* telLabel = new QLabel( this );
36 telLabel->setText( tr( "Enter telefon number here:" ) ); 34 telLabel->setText( tr( "Enter telefon number here:" ) );
37 QHBox *buttonBox = new QHBox( this ); 35 QHBox *buttonBox = new QHBox( this );
38 m_telNumber = new QLineEdit( buttonBox ); 36 m_telNumber = new QLineEdit( buttonBox );
39 QPushButton *atButton = new QPushButton( buttonBox ); 37 QPushButton *atButton = new QPushButton( buttonBox );
40 atButton->setText( tr( "AT commands" ) ); 38 atButton->setText( tr( "AT commands" ) );
41 connect( atButton, SIGNAL( clicked() ), this, SLOT( slotAT() ) ); 39 connect( atButton, SIGNAL( clicked() ), this, SLOT( slotAT() ) );
42 40
43 QPushButton *dialButton = new QPushButton( buttonBox ); 41 QPushButton *dialButton = new QPushButton( buttonBox );
44 dialButton->setText( tr( "Enter number" ) ); 42 dialButton->setText( tr( "Enter number" ) );
45 connect( dialButton, SIGNAL( clicked() ), this, SLOT( slotDial() ) ); 43 connect( dialButton, SIGNAL( clicked() ), this, SLOT( slotDial() ) );
46 44
47 m_base = new IOLayerBase( this, "base" ); 45 m_base = new IOLayerBase( this, "base" );
48 46
49 m_lay->addWidget( m_device ); 47 m_lay->addWidget( m_device );
50 m_lay->addWidget( m_deviceCmb ); 48 m_lay->addWidget( m_deviceCmb );
51 m_lay->addWidget( telLabel ); 49 m_lay->addWidget( telLabel );
52 m_lay->addWidget( buttonBox ); 50 m_lay->addWidget( buttonBox );
53 m_lay->addWidget( m_base ); 51 m_lay->addWidget( m_base );
54 m_lay->addStretch( 0 ); 52 m_lay->addStretch( 0 );
55 53
56 m_deviceCmb->insertItem( "/dev/ttyS0" ); 54 m_deviceCmb->insertItem( "/dev/ttyS0" );
57 m_deviceCmb->insertItem( "/dev/ttyS1" ); 55 m_deviceCmb->insertItem( "/dev/ttyS1" );
58 m_deviceCmb->insertItem( "/dev/ttyS2" ); 56 m_deviceCmb->insertItem( "/dev/ttyS2" );
59 57
60 atConf = new ATConfigDialog( this, "ATConfig", true ); 58 atConf = new ATConfigDialog( this, "ATConfig", true );
61} 59}
62 60
63ModemConfigWidget::~ModemConfigWidget() { 61ModemConfigWidget::~ModemConfigWidget() {
64 62
65} 63}
66void ModemConfigWidget::load( const Profile& prof ) { 64void ModemConfigWidget::load( const Profile& prof ) {
67 65
68 int rad_flow = prof.readNumEntry( "Flow" ); 66 int rad_flow = prof.readNumEntry( "Flow" );
69 int rad_parity = prof.readNumEntry( "Parity" ); 67 int rad_parity = prof.readNumEntry( "Parity" );
70 int speed = prof.readNumEntry( "Speed" ); 68 int speed = prof.readNumEntry( "Speed" );
71 int dbits = prof.readNumEntry("DataBits"); 69 int dbits = prof.readNumEntry("DataBits");
72 int sbits = prof.readNumEntry("StopBits"); 70 int sbits = prof.readNumEntry("StopBits");
73 QString number = prof.readEntry( "Number" ); 71 QString number = prof.readEntry( "Number" );
74 72
75 if ( !number.isEmpty() ) { 73 if ( !number.isEmpty() ) {
76 m_telNumber->setText( number ); 74 m_telNumber->setText( number );
77 } 75 }
78 76
79 if ( rad_flow == 1 ) { 77 if ( rad_flow == 1 ) {
80 m_base->setFlow( IOLayerBase::Hardware ); 78 m_base->setFlow( IOLayerBase::Hardware );
81 } else if (rad_flow == 2) { 79 } else if (rad_flow == 2) {
82 m_base->setFlow( IOLayerBase::Software ); 80 m_base->setFlow( IOLayerBase::Software );
83 } else if (rad_flow == 0) { 81 } else if (rad_flow == 0) {
84 m_base->setFlow( IOLayerBase::None ); 82 m_base->setFlow( IOLayerBase::None );
85 } 83 }
86 84
87 85
88 if ( rad_parity == 1 ) { 86 if ( rad_parity == 1 ) {
89 m_base->setParity( IOLayerBase::Even ); 87 m_base->setParity( IOLayerBase::Even );
90 } else if ( rad_parity == 2 ){ 88 } else if ( rad_parity == 2 ){
91 m_base->setParity( IOLayerBase::Odd ); 89 m_base->setParity( IOLayerBase::Odd );
92 } else { 90 } else {
93 m_base->setParity( IOLayerBase::NonePar ); 91 m_base->setParity( IOLayerBase::NonePar );
94 } 92 }
95 93
96 switch( speed ) { 94 switch( speed ) {
97 case 115200: 95 case 115200:
98 m_base->setSpeed( IOLayerBase::Baud_115200 ); 96 m_base->setSpeed( IOLayerBase::Baud_115200 );
99 break; 97 break;
100 case 57600: 98 case 57600:
101 m_base->setSpeed( IOLayerBase::Baud_57600 ); 99 m_base->setSpeed( IOLayerBase::Baud_57600 );
102 break; 100 break;
103 case 38400: 101 case 38400:
104 m_base->setSpeed( IOLayerBase::Baud_38400 ); 102 m_base->setSpeed( IOLayerBase::Baud_38400 );
105 break; 103 break;
106 case 19200: 104 case 19200:
107 m_base->setSpeed( IOLayerBase::Baud_19200 ); 105 m_base->setSpeed( IOLayerBase::Baud_19200 );
108 break; 106 break;
109 case 9600: 107 case 9600:
110 default: 108 default:
111 m_base->setSpeed( IOLayerBase::Baud_9600 ); 109 m_base->setSpeed( IOLayerBase::Baud_9600 );
112 break; 110 break;
113 } 111 }
114 112
115 113
116 if ( dbits == 5) { 114 if ( dbits == 5) {
117 m_base->setData( IOLayerBase::Data_Five ); 115 m_base->setData( IOLayerBase::Data_Five );
118 } else if (rad_flow == 6) { 116 } else if (rad_flow == 6) {
119 m_base->setData( IOLayerBase::Data_Six ); 117 m_base->setData( IOLayerBase::Data_Six );
120 } else if (rad_flow == 7) { 118 } else if (rad_flow == 7) {
121 m_base->setData( IOLayerBase::Data_Seven ); 119 m_base->setData( IOLayerBase::Data_Seven );
122 } else { 120 } else {
123 m_base->setData( IOLayerBase::Data_Eight ); 121 m_base->setData( IOLayerBase::Data_Eight );
124 } 122 }
125 123
126 if ( sbits == 2) { 124 if ( sbits == 2) {
127 m_base->setStop( IOLayerBase::Stop_Two ); 125 m_base->setStop( IOLayerBase::Stop_Two );
128 } else if ( sbits == 15 ) { 126 } else if ( sbits == 15 ) {
129 m_base->setStop( IOLayerBase::Stop_OnePointFive ); 127 m_base->setStop( IOLayerBase::Stop_OnePointFive );
130 } else { 128 } else {
131 m_base->setStop( IOLayerBase::Stop_One ); 129 m_base->setStop( IOLayerBase::Stop_One );
132 } 130 }
133 131
134 132
135 atConf->readConfig( prof ); 133 atConf->readConfig( prof );
136 if ( prof.readEntry( "Device" ).isEmpty() ) { 134 if ( prof.readEntry( "Device" ).isEmpty() ) {
137 qWarning("device empty!"); 135 qWarning("device empty!");
138 return; 136 return;
139 } 137 }
140 setCurrent( prof.readEntry( "Device" ), m_deviceCmb ); 138 setCurrent( prof.readEntry( "Device" ), m_deviceCmb );
141 139
142 140
143} 141}
144 142
145/* 143/*
146 * save speed, 144 * save speed,
147 * flow, 145 * flow,
148 * parity 146 * parity
149 */ 147 */
150void ModemConfigWidget::save( Profile& prof ) { 148void ModemConfigWidget::save( Profile& prof ) {
151 int flow, parity, speed, data, stop; 149 int flow, parity, speed, data, stop;
152 flow = parity = speed = data = stop = 0; 150 flow = parity = speed = data = stop = 0;
153 prof.writeEntry( "Device", m_deviceCmb->currentText() ); 151 prof.writeEntry( "Device", m_deviceCmb->currentText() );
154 152
155 153
156 switch( m_base->flow() ) { 154 switch( m_base->flow() ) {
157 case IOLayerBase::None: 155 case IOLayerBase::None:
158 flow = 0; 156 flow = 0;
159 break; 157 break;
160 case IOLayerBase::Software: 158 case IOLayerBase::Software:
161 flow = 2; 159 flow = 2;
162 break; 160 break;
163 case IOLayerBase::Hardware: 161 case IOLayerBase::Hardware:
164 flow = 1; 162 flow = 1;
165 break; 163 break;
166 } 164 }
167 165
168 switch( m_base->parity() ) { 166 switch( m_base->parity() ) {
169 case IOLayerBase::Odd: 167 case IOLayerBase::Odd:
170 parity = 2; 168 parity = 2;
171 break; 169 break;
172 case IOLayerBase::Even: 170 case IOLayerBase::Even:
173 parity = 1; 171 parity = 1;
174 break; 172 break;
175 case IOLayerBase::NonePar: 173 case IOLayerBase::NonePar:
176 parity = 0; 174 parity = 0;
177 break; 175 break;
178 } 176 }
179 177
180 switch( m_base->speed() ) { 178 switch( m_base->speed() ) {
181 case IOLayerBase::Baud_115200: 179 case IOLayerBase::Baud_115200:
182 speed = 115200; 180 speed = 115200;
183 break; 181 break;
184 case IOLayerBase::Baud_57600: 182 case IOLayerBase::Baud_57600:
185 speed = 57600; 183 speed = 57600;
186 break; 184 break;
187 case IOLayerBase::Baud_38400: 185 case IOLayerBase::Baud_38400:
188 speed = 38400; 186 speed = 38400;
189 break; 187 break;
190 case IOLayerBase::Baud_19200: 188 case IOLayerBase::Baud_19200:
191 speed = 19200; 189 speed = 19200;
192 break; 190 break;
193 case IOLayerBase::Baud_9600: 191 case IOLayerBase::Baud_9600:
194 speed = 9600; 192 speed = 9600;
195 break; 193 break;
196 } 194 }
197 195
198 switch( m_base->data() ) { 196 switch( m_base->data() ) {
199 case IOLayerBase::Data_Five: 197 case IOLayerBase::Data_Five:
200 data = 5; 198 data = 5;
201 break; 199 break;
202 case IOLayerBase::Data_Six: 200 case IOLayerBase::Data_Six:
203 data = 6; 201 data = 6;
204 break; 202 break;
205 case IOLayerBase::Data_Seven: 203 case IOLayerBase::Data_Seven:
206 data = 7; 204 data = 7;
207 break; 205 break;
208 case IOLayerBase::Data_Eight: 206 case IOLayerBase::Data_Eight:
209 data = 8; 207 data = 8;
210 break; 208 break;
211 } 209 }
212 210
213 switch( m_base->stop() ) { 211 switch( m_base->stop() ) {
214 case IOLayerBase::Stop_One: 212 case IOLayerBase::Stop_One:
215 stop = 1; 213 stop = 1;
216 break; 214 break;
217 case IOLayerBase::Stop_OnePointFive: 215 case IOLayerBase::Stop_OnePointFive:
218 stop = 15; 216 stop = 15;
219 break; 217 break;
220 case IOLayerBase::Stop_Two: 218 case IOLayerBase::Stop_Two:
221 stop = 2; 219 stop = 2;
222 break; 220 break;
223 } 221 }
224 222
225 prof.writeEntry( "Flow", flow ); 223 prof.writeEntry( "Flow", flow );
226 prof.writeEntry( "Parity", parity ); 224 prof.writeEntry( "Parity", parity );
227 prof.writeEntry( "Speed", speed ); 225 prof.writeEntry( "Speed", speed );
228 prof.writeEntry("DataBits", data); 226 prof.writeEntry("DataBits", data);
229 prof.writeEntry("StopBits", stop); 227 prof.writeEntry("StopBits", stop);
230 prof.writeEntry( "Number", m_telNumber->text() ); 228 prof.writeEntry( "Number", m_telNumber->text() );
231 229
232 230
233 atConf->writeConfig(prof); 231 atConf->writeConfig(prof);
234} 232}
235 233
236void ModemConfigWidget::slotAT() { 234void ModemConfigWidget::slotAT() {
237 // ATConfigDialog conf( this, "ATConfig", true ); 235 // ATConfigDialog conf( this, "ATConfig", true );
238 // josef/Max I know why don't you create the stuff on the stack 236 // josef/Max I know why don't you create the stuff on the stack
239 // but making it a TopLevel Dialog and ignoring 237 // but making it a TopLevel Dialog and ignoring
240 // cancel is not fun either... 238 // cancel is not fun either...
241 // what to do? FIXME!!! -zecke 239 // what to do? FIXME!!! -zecke
242 atConf->showMaximized(); 240 atConf->showMaximized();
243 if ( atConf->exec() != QDialog::Accepted ) { 241 if ( atConf->exec() != QDialog::Accepted ) {
244 // reload old settings 242 // reload old settings
245 } 243 }
246} 244}
247 245
248void ModemConfigWidget::slotDial() { 246void ModemConfigWidget::slotDial() {
249 DialDialog dial( this, "DialConfig", true ); 247 DialDialog dial( this, "DialConfig", true );
250 if(!m_telNumber->text().isEmpty()) { 248 if(!m_telNumber->text().isEmpty()) {
251 dial.setNumber(m_telNumber->text().replace(QRegExp("[\\-\\/\\ \\.\\,]"), "")); 249 dial.setNumber(m_telNumber->text().replace(QRegExp("[\\-\\/\\ \\.\\,]"), ""));
252 } 250 }
253 dial.showMaximized(); 251 dial.showMaximized();
254 if ( dial.exec() == QDialog::Accepted ) { 252 if ( dial.exec() == QDialog::Accepted ) {
255 m_telNumber->setText( dial.number() ); 253 m_telNumber->setText( dial.number() );
256 } 254 }
257} 255}
diff --git a/noncore/apps/opie-console/profileeditordialog.cpp b/noncore/apps/opie-console/profileeditordialog.cpp
index e2501a6..979e89d 100644
--- a/noncore/apps/opie-console/profileeditordialog.cpp
+++ b/noncore/apps/opie-console/profileeditordialog.cpp
@@ -1,242 +1,241 @@
1#include <qlayout.h> 1#include <qlayout.h>
2#include <qlineedit.h> 2#include <qlineedit.h>
3#include <qlabel.h> 3#include <qlabel.h>
4#include <qmessagebox.h> 4#include <qmessagebox.h>
5#include <qstringlist.h>
6#include <qcombobox.h> 5#include <qcombobox.h>
7#include <qcheckbox.h> 6#include <qcheckbox.h>
8#include <qscrollview.h> 7#include <qscrollview.h>
9 8
10#include "metafactory.h" 9#include "metafactory.h"
11#include "profileeditordialog.h" 10#include "profileeditordialog.h"
12 11
13namespace { 12namespace {
14 void setCurrent( const QString& str, QComboBox* bo ) { 13 void setCurrent( const QString& str, QComboBox* bo ) {
15 for (int i = 0; i < bo->count(); i++ ) { 14 for (int i = 0; i < bo->count(); i++ ) {
16 if ( bo->text(i) == str ) { 15 if ( bo->text(i) == str ) {
17 bo->setCurrentItem( i ); 16 bo->setCurrentItem( i );
18 } 17 }
19 } 18 }
20 }; 19 };
21} 20}
22 21
23ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact, 22ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact,
24 const Profile& prof ) 23 const Profile& prof )
25 : QDialog(0, 0, TRUE), m_fact( fact ), m_prof( prof ) 24 : QDialog(0, 0, TRUE), m_fact( fact ), m_prof( prof )
26{ 25{
27 initUI(); 26 initUI();
28 27
29 // Apply current profile 28 // Apply current profile
30 // plugin_plugin->load(profile); 29 // plugin_plugin->load(profile);
31 // ... (reset profile name line edit etc.) 30 // ... (reset profile name line edit etc.)
32} 31}
33 32
34ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact ) 33ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact )
35 : QDialog(0, 0, TRUE), m_fact( fact ) 34 : QDialog(0, 0, TRUE), m_fact( fact )
36{ 35{
37 // Default profile 36 // Default profile
38 m_prof = Profile(tr("New Profile"), "serial", "default", Profile::Black, Profile::White, Profile::VT102); 37 m_prof = Profile(tr("New Profile"), "serial", "default", Profile::Black, Profile::White, Profile::VT102);
39 38
40 initUI(); 39 initUI();
41 40
42 // Apply current profile 41 // Apply current profile
43 // plugin_plugin->load(profile); 42 // plugin_plugin->load(profile);
44} 43}
45 44
46Profile ProfileEditorDialog::profile() const 45Profile ProfileEditorDialog::profile() const
47{ 46{
48 return m_prof; 47 return m_prof;
49} 48}
50 49
51void ProfileEditorDialog::initUI() 50void ProfileEditorDialog::initUI()
52{ 51{
53 m_con = m_term = m_key = 0l; 52 m_con = m_term = m_key = 0l;
54 53
55 54
56 QVBoxLayout *mainLayout = new QVBoxLayout( this ); 55 QVBoxLayout *mainLayout = new QVBoxLayout( this );
57 tabWidget = new OTabWidget( this ); 56 tabWidget = new OTabWidget( this );
58 tabWidget->setTabStyle(OTabWidget::TextTab); 57 tabWidget->setTabStyle(OTabWidget::TextTab);
59 mainLayout->add(tabWidget); 58 mainLayout->add(tabWidget);
60 59
61 /* base tabs */ 60 /* base tabs */
62 tabprof = new QWidget(this); 61 tabprof = new QWidget(this);
63 m_tabTerm = new QWidget(this); 62 m_tabTerm = new QWidget(this);
64 m_tabCon = new QWidget(this); 63 m_tabCon = new QWidget(this);
65 m_tabKey = new QWidget(this); 64 m_tabKey = new QWidget(this);
66 65
67 m_svCon = new QScrollView( m_tabCon ); 66 m_svCon = new QScrollView( m_tabCon );
68 m_svCon->setResizePolicy( QScrollView::AutoOneFit ); 67 m_svCon->setResizePolicy( QScrollView::AutoOneFit );
69 //m_svCon->setHScrollBarMode( QScrollView::AlwaysOff ); 68 //m_svCon->setHScrollBarMode( QScrollView::AlwaysOff );
70 m_svCon->setFrameShape( QFrame::NoFrame ); 69 m_svCon->setFrameShape( QFrame::NoFrame );
71 m_svTerm = new QScrollView( m_tabTerm ); 70 m_svTerm = new QScrollView( m_tabTerm );
72 m_svTerm->setResizePolicy( QScrollView::AutoOneFit ); 71 m_svTerm->setResizePolicy( QScrollView::AutoOneFit );
73 //m_svTerm->setHScrollBarMode( QScrollView::AlwaysOff ); 72 //m_svTerm->setHScrollBarMode( QScrollView::AlwaysOff );
74 m_svTerm->setFrameShape( QFrame::NoFrame ); 73 m_svTerm->setFrameShape( QFrame::NoFrame );
75 74
76 /* base layout for tabs */ 75 /* base layout for tabs */
77 m_layCon = new QHBoxLayout( m_tabCon , 2 ); 76 m_layCon = new QHBoxLayout( m_tabCon , 2 );
78 m_layTerm = new QHBoxLayout( m_tabTerm, 2 ); 77 m_layTerm = new QHBoxLayout( m_tabTerm, 2 );
79 m_layKey = new QHBoxLayout( m_tabKey, 2 ); 78 m_layKey = new QHBoxLayout( m_tabKey, 2 );
80 79
81 m_layCon->addWidget( m_svCon ); 80 m_layCon->addWidget( m_svCon );
82 m_layTerm->addWidget( m_svTerm ); 81 m_layTerm->addWidget( m_svTerm );
83 82
84 // profile tab 83 // profile tab
85 84
86 QLabel *name = new QLabel(QObject::tr("Profile name"), tabprof); 85 QLabel *name = new QLabel(QObject::tr("Profile name"), tabprof);
87 m_name = new QLineEdit(tabprof); 86 m_name = new QLineEdit(tabprof);
88 QLabel *con = new QLabel(tr("Connection"), tabprof ); 87 QLabel *con = new QLabel(tr("Connection"), tabprof );
89 QLabel *term = new QLabel(tr("Terminal"), tabprof ); 88 QLabel *term = new QLabel(tr("Terminal"), tabprof );
90 m_conCmb = new QComboBox( tabprof ); 89 m_conCmb = new QComboBox( tabprof );
91 m_termCmb = new QComboBox( tabprof ); 90 m_termCmb = new QComboBox( tabprof );
92 m_autoConnect = new QCheckBox(tr("Auto connect after load"), tabprof); 91 m_autoConnect = new QCheckBox(tr("Auto connect after load"), tabprof);
93 92
94 // layouting 93 // layouting
95 QVBoxLayout *vbox3 = new QVBoxLayout(tabprof, 2); 94 QVBoxLayout *vbox3 = new QVBoxLayout(tabprof, 2);
96 vbox3->add(name); 95 vbox3->add(name);
97 vbox3->add(m_name); 96 vbox3->add(m_name);
98 vbox3->add(con ); 97 vbox3->add(con );
99 vbox3->add(m_conCmb ); 98 vbox3->add(m_conCmb );
100 vbox3->add(term ); 99 vbox3->add(term );
101 vbox3->add(m_termCmb ); 100 vbox3->add(m_termCmb );
102 vbox3->add(m_autoConnect); 101 vbox3->add(m_autoConnect);
103 vbox3->addStretch(1); 102 vbox3->addStretch(1);
104 103
105 m_showconntab = 0; 104 m_showconntab = 0;
106 tabWidget->addTab(tabprof, "", QObject::tr("Profile")); 105 tabWidget->addTab(tabprof, "", QObject::tr("Profile"));
107 tabWidget->addTab(m_tabCon, "", QObject::tr("Connection")); 106 tabWidget->addTab(m_tabCon, "", QObject::tr("Connection"));
108 tabWidget->addTab(m_tabTerm, "", QObject::tr("Terminal")); 107 tabWidget->addTab(m_tabTerm, "", QObject::tr("Terminal"));
109 tabWidget->addTab(m_tabKey, "", QObject::tr("Special Keys")); 108 tabWidget->addTab(m_tabKey, "", QObject::tr("Special Keys"));
110 tabWidget->setCurrentTab( tabprof ); 109 tabWidget->setCurrentTab( tabprof );
111 110
112 111
113 // fill the comboboxes 112 // fill the comboboxes
114 QStringList list = m_fact->connectionWidgets(); 113 QStringList list = m_fact->connectionWidgets();
115 QStringList::Iterator it; 114 QStringList::Iterator it;
116 for (it =list.begin(); it != list.end(); ++it ) { 115 for (it =list.begin(); it != list.end(); ++it ) {
117 m_conCmb->insertItem( (*it) ); 116 m_conCmb->insertItem( (*it) );
118 } 117 }
119 list = m_fact->terminalWidgets(); 118 list = m_fact->terminalWidgets();
120 for (it =list.begin(); it != list.end(); ++it ) { 119 for (it =list.begin(); it != list.end(); ++it ) {
121 m_termCmb->insertItem( (*it) ); 120 m_termCmb->insertItem( (*it) );
122 } 121 }
123 122
124 // load profile values 123 // load profile values
125 m_name->setText(m_prof.name()); 124 m_name->setText(m_prof.name());
126 slotKeyActivated( "Default Keyboard" ); 125 slotKeyActivated( "Default Keyboard" );
127 setCurrent( m_fact->external(m_prof.ioLayerName() ), m_conCmb ); 126 setCurrent( m_fact->external(m_prof.ioLayerName() ), m_conCmb );
128 setCurrent( m_fact->external(m_prof.terminalName() ), m_termCmb ); 127 setCurrent( m_fact->external(m_prof.terminalName() ), m_termCmb );
129 slotConActivated( m_fact->external(m_prof.ioLayerName() ) ); 128 slotConActivated( m_fact->external(m_prof.ioLayerName() ) );
130 slotTermActivated( m_fact->external(m_prof.terminalName() ) ); 129 slotTermActivated( m_fact->external(m_prof.terminalName() ) );
131 m_autoConnect->setChecked(m_prof.autoConnect()); 130 m_autoConnect->setChecked(m_prof.autoConnect());
132 131
133 132
134 // signal and slots 133 // signal and slots
135 connect(m_conCmb, SIGNAL(activated(const QString& ) ), 134 connect(m_conCmb, SIGNAL(activated(const QString& ) ),
136 this, SLOT(slotConActivated(const QString&) ) ); 135 this, SLOT(slotConActivated(const QString&) ) );
137 connect(m_termCmb, SIGNAL(activated(const QString& ) ), 136 connect(m_termCmb, SIGNAL(activated(const QString& ) ),
138 this, SLOT(slotTermActivated(const QString& ) ) ); 137 this, SLOT(slotTermActivated(const QString& ) ) );
139 138
140} 139}
141 140
142ProfileEditorDialog::~ProfileEditorDialog() { 141ProfileEditorDialog::~ProfileEditorDialog() {
143 142
144} 143}
145void ProfileEditorDialog::accept() 144void ProfileEditorDialog::accept()
146{ 145{
147 if(profName().isEmpty()) 146 if(profName().isEmpty())
148 { 147 {
149 QMessageBox::information(this, 148 QMessageBox::information(this,
150 QObject::tr("Invalid profile"), 149 QObject::tr("Invalid profile"),
151 QObject::tr("Please enter a profile name.")); 150 QObject::tr("Please enter a profile name."));
152 return; 151 return;
153 } 152 }
154 // Save profile and plugin profile 153 // Save profile and plugin profile
155 //if(plugin_plugin) plugin_plugin->save(); 154 //if(plugin_plugin) plugin_plugin->save();
156 155
157 // Save general values 156 // Save general values
158 m_prof.setName( profName() ); 157 m_prof.setName( profName() );
159 m_prof.setIOLayer( m_fact->internal(m_conCmb ->currentText() ) ); 158 m_prof.setIOLayer( m_fact->internal(m_conCmb ->currentText() ) );
160 m_prof.setTerminalName( m_fact->internal(m_termCmb->currentText() ) ); 159 m_prof.setTerminalName( m_fact->internal(m_termCmb->currentText() ) );
161 m_prof.setAutoConnect( m_autoConnect->isChecked() ); 160 m_prof.setAutoConnect( m_autoConnect->isChecked() );
162 161
163 if (m_con ) 162 if (m_con )
164 m_con->save( m_prof ); 163 m_con->save( m_prof );
165 if (m_term ) 164 if (m_term )
166 m_term->save( m_prof ); 165 m_term->save( m_prof );
167 if (m_key) 166 if (m_key)
168 m_key->save( m_prof ); 167 m_key->save( m_prof );
169 168
170 QDialog::accept(); 169 QDialog::accept();
171} 170}
172 171
173 172
174QString ProfileEditorDialog::profName()const 173QString ProfileEditorDialog::profName()const
175{ 174{
176 return m_name->text(); 175 return m_name->text();
177} 176}
178 177
179QCString ProfileEditorDialog::profType()const 178QCString ProfileEditorDialog::profType()const
180{ 179{
181 /*QStringList w = m_fact->configWidgets(); 180 /*QStringList w = m_fact->configWidgets();
182 for(QStringList::Iterator it = w.begin(); it != w.end(); it++) 181 for(QStringList::Iterator it = w.begin(); it != w.end(); it++)
183 if(device_box->currentText() == m_fact->name((*it))) return (*it); 182 if(device_box->currentText() == m_fact->name((*it))) return (*it);
184 */ 183 */
185 return QCString(); 184 return QCString();
186} 185}
187/* 186/*
188 * we need to switch the widget 187 * we need to switch the widget
189 */ 188 */
190void ProfileEditorDialog::slotConActivated( const QString& str ) { 189void ProfileEditorDialog::slotConActivated( const QString& str ) {
191 190
192 delete m_con; 191 delete m_con;
193 192
194 m_con = m_fact->newConnectionPlugin( str, m_svCon->viewport() ); 193 m_con = m_fact->newConnectionPlugin( str, m_svCon->viewport() );
195 194
196 if ( !m_con ) { 195 if ( !m_con ) {
197 m_con = new NoOptions( str, m_svCon->viewport(), "name"); 196 m_con = new NoOptions( str, m_svCon->viewport(), "name");
198 } 197 }
199 198
200 // FIXME ugly hack right. Right solution would be to look into the layer and see if it 199 // FIXME ugly hack right. Right solution would be to look into the layer and see if it
201 // supports auto connect and then set it as prefered 200 // supports auto connect and then set it as prefered
202 if ( m_conCmb ->currentText() == tr("Local Console") ) { 201 if ( m_conCmb ->currentText() == tr("Local Console") ) {
203 m_autoConnect->setChecked( true ); 202 m_autoConnect->setChecked( true );
204 m_prof.writeEntry("Terminal", Profile::Linux ); 203 m_prof.writeEntry("Terminal", Profile::Linux );
205 slotTermActivated( m_fact->external (m_prof.terminalName() ) ); 204 slotTermActivated( m_fact->external (m_prof.terminalName() ) );
206 } else { 205 } else {
207 m_prof.writeEntry("Terminal", Profile::VT102 ); 206 m_prof.writeEntry("Terminal", Profile::VT102 );
208 slotTermActivated( m_fact->external (m_prof.terminalName() ) ); 207 slotTermActivated( m_fact->external (m_prof.terminalName() ) );
209 m_autoConnect->setChecked( false ); 208 m_autoConnect->setChecked( false );
210 } 209 }
211 210
212 m_con->load( m_prof ); 211 m_con->load( m_prof );
213 m_svCon->addChild( m_con ); 212 m_svCon->addChild( m_con );
214} 213}
215 214
216 215
217/* 216/*
218 * we need to switch the widget 217 * we need to switch the widget
219 */ 218 */
220void ProfileEditorDialog::slotTermActivated( const QString& str ) { 219void ProfileEditorDialog::slotTermActivated( const QString& str ) {
221 220
222 delete m_term; 221 delete m_term;
223 222
224 m_term = m_fact->newTerminalPlugin( str, m_svTerm->viewport() ); 223 m_term = m_fact->newTerminalPlugin( str, m_svTerm->viewport() );
225 224
226 if ( m_term ) { 225 if ( m_term ) {
227 m_term->load( m_prof ); 226 m_term->load( m_prof );
228 m_svTerm->addChild( m_term ); 227 m_svTerm->addChild( m_term );
229 } 228 }
230} 229}
231 230
232void ProfileEditorDialog::slotKeyActivated(const QString &str) { 231void ProfileEditorDialog::slotKeyActivated(const QString &str) {
233 delete m_key; 232 delete m_key;
234 m_key = m_fact->newKeyboardPlugin( str, m_tabKey ); 233 m_key = m_fact->newKeyboardPlugin( str, m_tabKey );
235 234
236 if (m_key) { 235 if (m_key) {
237 236
238 m_key->load(m_prof); 237 m_key->load(m_prof);
239 m_layKey->addWidget(m_key); 238 m_layKey->addWidget(m_key);
240 } 239 }
241 240
242} 241}
diff --git a/noncore/apps/opie-console/profilemanager.cpp b/noncore/apps/opie-console/profilemanager.cpp
index cad2567..71188d1 100644
--- a/noncore/apps/opie-console/profilemanager.cpp
+++ b/noncore/apps/opie-console/profilemanager.cpp
@@ -1,141 +1,136 @@
1#include <stdio.h> 1#include <stdio.h>
2#include <stdlib.h> 2#include <stdlib.h>
3 3
4#include <qfile.h> 4#include <qfile.h>
5#include <qhbox.h> 5#include <qhbox.h>
6#include <qlayout.h>
7#include <qwidgetstack.h>
8 6
9#include <qpe/config.h>
10 7
11#include "emulation_handler.h" 8#include "emulation_handler.h"
12#include "widget_layer.h"
13#include "emulation_widget.h"
14#include "metafactory.h" 9#include "metafactory.h"
15#include "profileconfig.h" 10#include "profileconfig.h"
16#include "profilemanager.h" 11#include "profilemanager.h"
17 12
18ProfileManager::ProfileManager( MetaFactory* fact ) 13ProfileManager::ProfileManager( MetaFactory* fact )
19 : m_fact( fact ) 14 : m_fact( fact )
20{ 15{
21 16
22} 17}
23ProfileManager::~ProfileManager() { 18ProfileManager::~ProfileManager() {
24 19
25} 20}
26void ProfileManager::load() { 21void ProfileManager::load() {
27 m_list.clear(); 22 m_list.clear();
28 ProfileConfig conf("opie-console-profiles"); 23 ProfileConfig conf("opie-console-profiles");
29 QStringList groups = conf.groups(); 24 QStringList groups = conf.groups();
30 QStringList::Iterator it; 25 QStringList::Iterator it;
31 26
32 /* 27 /*
33 * for each profile 28 * for each profile
34 */ 29 */
35 for ( it = groups.begin(); it != groups.end(); ++it ) { 30 for ( it = groups.begin(); it != groups.end(); ++it ) {
36 conf.setGroup( (*it) ); 31 conf.setGroup( (*it) );
37 Profile prof; 32 Profile prof;
38 prof.setName( conf.readEntry("name") ); 33 prof.setName( conf.readEntry("name") );
39 prof.setIOLayer( conf.readEntry("iolayer").utf8() ); 34 prof.setIOLayer( conf.readEntry("iolayer").utf8() );
40 prof.setTerminalName( conf.readEntry("term").utf8() ); 35 prof.setTerminalName( conf.readEntry("term").utf8() );
41 prof.setAutoConnect( conf.readBoolEntry("autoConnect") ); 36 prof.setAutoConnect( conf.readBoolEntry("autoConnect") );
42 prof.setBackground( conf.readNumEntry("back") ); 37 prof.setBackground( conf.readNumEntry("back") );
43 prof.setForeground( conf.readNumEntry("fore") ); 38 prof.setForeground( conf.readNumEntry("fore") );
44 prof.setTerminal( conf.readNumEntry("terminal") ); 39 prof.setTerminal( conf.readNumEntry("terminal") );
45 40
46 // THIS is evil because all data get's reset 41 // THIS is evil because all data get's reset
47 prof.setConf( conf.items( (*it) ) ); 42 prof.setConf( conf.items( (*it) ) );
48 43
49 /* now add it */ 44 /* now add it */
50 m_list.append( prof ); 45 m_list.append( prof );
51 } 46 }
52 47
53} 48}
54void ProfileManager::clear() { 49void ProfileManager::clear() {
55 m_list.clear(); 50 m_list.clear();
56} 51}
57Profile::ValueList ProfileManager::all()const { 52Profile::ValueList ProfileManager::all()const {
58 return m_list; 53 return m_list;
59} 54}
60/* 55/*
61 * Our goal is to create a Session 56 * Our goal is to create a Session
62 * We will load the the IOLayer and EmulationLayer 57 * We will load the the IOLayer and EmulationLayer
63 * from the factory 58 * from the factory
64 * we will generate a QWidgetStack 59 * we will generate a QWidgetStack
65 * add a dummy widget with layout 60 * add a dummy widget with layout
66 * add "Widget" to the layout 61 * add "Widget" to the layout
67 * add the dummy to the stack 62 * add the dummy to the stack
68 * raise the dummy 63 * raise the dummy
69 * call session->connect(= 64 * call session->connect(=
70 * this way we only need to reparent 65 * this way we only need to reparent
71 * in TabWidget 66 * in TabWidget
72 */ 67 */
73Session* ProfileManager::fromProfile( const Profile& prof, QWidget* parent) { 68Session* ProfileManager::fromProfile( const Profile& prof, QWidget* parent) {
74/* TEST PROFILE!!! 69/* TEST PROFILE!!!
75 Profile prof; 70 Profile prof;
76 QString str = "/dev/ttyS0"; 71 QString str = "/dev/ttyS0";
77 prof.writeEntry("Device",str ); 72 prof.writeEntry("Device",str );
78 prof.writeEntry("Baud", 115200 ); 73 prof.writeEntry("Baud", 115200 );
79 prof.setIOLayer("serial"); 74 prof.setIOLayer("serial");
80 prof.setName( "test"); 75 prof.setName( "test");
81*/ 76*/
82 Session* session = new Session(); 77 Session* session = new Session();
83 session->setName( prof.name() ); 78 session->setName( prof.name() );
84 /* translate the internal name to the external */ 79 /* translate the internal name to the external */
85 session->setIOLayer(m_fact->newIOLayer( m_fact->external(prof.ioLayerName()) , 80 session->setIOLayer(m_fact->newIOLayer( m_fact->external(prof.ioLayerName()) ,
86 prof) ); 81 prof) );
87 82
88 QWidgetStack *stack = new QWidgetStack( parent ); 83 QWidgetStack *stack = new QWidgetStack( parent );
89 session->setWidgetStack( stack ); 84 session->setWidgetStack( stack );
90 QWidget* dummy = new QHBox( stack ); 85 QWidget* dummy = new QHBox( stack );
91 stack->raiseWidget( dummy ); 86 stack->raiseWidget( dummy );
92 87
93 EmulationHandler* handler = new EmulationHandler(prof,dummy ); 88 EmulationHandler* handler = new EmulationHandler(prof,dummy );
94 session->setEmulationHandler( handler ); 89 session->setEmulationHandler( handler );
95 session->connect(); 90 session->connect();
96 session->setProfile( prof ); 91 session->setProfile( prof );
97 92
98 return session; 93 return session;
99} 94}
100void ProfileManager::save( ) { 95void ProfileManager::save( ) {
101 QFile::remove( (QString(getenv("HOME") )+ "/Settings/opie-console-profiles.conf" ) ); 96 QFile::remove( (QString(getenv("HOME") )+ "/Settings/opie-console-profiles.conf" ) );
102 ProfileConfig conf("opie-console-profiles"); 97 ProfileConfig conf("opie-console-profiles");
103 Profile::ValueList::Iterator it2; 98 Profile::ValueList::Iterator it2;
104 for (it2 = m_list.begin(); it2 != m_list.end(); ++it2 ) { 99 for (it2 = m_list.begin(); it2 != m_list.end(); ++it2 ) {
105 conf.setGroup( (*it2).name() ); 100 conf.setGroup( (*it2).name() );
106 101
107 /* now the config stuff */ 102 /* now the config stuff */
108 QMap<QString, QString> map = (*it2).conf(); 103 QMap<QString, QString> map = (*it2).conf();
109 QMap<QString, QString>::Iterator confIt; 104 QMap<QString, QString>::Iterator confIt;
110 for ( confIt = map.begin(); confIt != map.end(); ++confIt ) { 105 for ( confIt = map.begin(); confIt != map.end(); ++confIt ) {
111 conf.writeEntry( confIt.key(), confIt.data() ); 106 conf.writeEntry( confIt.key(), confIt.data() );
112 } 107 }
113 108
114 conf.writeEntry( "name", (*it2).name() ); 109 conf.writeEntry( "name", (*it2).name() );
115 QString str = QString::fromUtf8( (*it2).ioLayerName() ); 110 QString str = QString::fromUtf8( (*it2).ioLayerName() );
116 111
117 conf.writeEntry( "iolayer", str ); 112 conf.writeEntry( "iolayer", str );
118 conf.writeEntry( "term", QString::fromUtf8( (*it2).terminalName() ) ); 113 conf.writeEntry( "term", QString::fromUtf8( (*it2).terminalName() ) );
119 conf.writeEntry( "autoConnect", (*it2).autoConnect()); 114 conf.writeEntry( "autoConnect", (*it2).autoConnect());
120 conf.writeEntry( "back", (*it2).background() ); 115 conf.writeEntry( "back", (*it2).background() );
121 conf.writeEntry( "fore", (*it2).foreground() ); 116 conf.writeEntry( "fore", (*it2).foreground() );
122 conf.writeEntry( "terminal", (*it2).terminal() ); 117 conf.writeEntry( "terminal", (*it2).terminal() );
123 } 118 }
124} 119}
125void ProfileManager::add( const Profile& prof) { 120void ProfileManager::add( const Profile& prof) {
126 m_list.append( prof ); 121 m_list.append( prof );
127} 122}
128void ProfileManager::setProfiles( const Profile::ValueList& list ) { 123void ProfileManager::setProfiles( const Profile::ValueList& list ) {
129 m_list = list; 124 m_list = list;
130}; 125};
131Profile ProfileManager::profile( const QString& name )const { 126Profile ProfileManager::profile( const QString& name )const {
132 Profile prof; 127 Profile prof;
133 Profile::ValueList::ConstIterator it; 128 Profile::ValueList::ConstIterator it;
134 for ( it = m_list.begin(); it != m_list.end(); ++it ) { 129 for ( it = m_list.begin(); it != m_list.end(); ++it ) {
135 if ( name == (*it).name() ) { 130 if ( name == (*it).name() ) {
136 prof = (*it); 131 prof = (*it);
137 break; 132 break;
138 } 133 }
139 } 134 }
140 return prof; 135 return prof;
141} 136}
diff --git a/noncore/apps/opie-console/receive_layer.cpp b/noncore/apps/opie-console/receive_layer.cpp
index bbde339..b255452 100644
--- a/noncore/apps/opie-console/receive_layer.cpp
+++ b/noncore/apps/opie-console/receive_layer.cpp
@@ -1,34 +1,31 @@
1#include <unistd.h> 1#include <unistd.h>
2 2
3#include <qdir.h> 3#include <qdir.h>
4#include <qstring.h>
5#include <qfile.h>
6 4
7#include "io_layer.h"
8#include "receive_layer.h" 5#include "receive_layer.h"
9 6
10ReceiveLayer::ReceiveLayer( IOLayer* lay, const QString& startDir ) 7ReceiveLayer::ReceiveLayer( IOLayer* lay, const QString& startDir )
11 : QObject(), m_curDir( startDir ), m_layer(lay ) 8 : QObject(), m_curDir( startDir ), m_layer(lay )
12{ 9{
13 10
14} 11}
15ReceiveLayer::~ReceiveLayer() { 12ReceiveLayer::~ReceiveLayer() {
16 13
17} 14}
18IOLayer* ReceiveLayer::layer() { 15IOLayer* ReceiveLayer::layer() {
19 return m_layer; 16 return m_layer;
20} 17}
21QString ReceiveLayer::currentDir()const{ 18QString ReceiveLayer::currentDir()const{
22 if (m_curDir.isEmpty() ) 19 if (m_curDir.isEmpty() )
23 return QDir::currentDirPath(); 20 return QDir::currentDirPath();
24 return m_curDir; 21 return m_curDir;
25} 22}
26void ReceiveLayer::changeDir( const QString& str) { 23void ReceiveLayer::changeDir( const QString& str) {
27 ::chdir( str.latin1() ); 24 ::chdir( str.latin1() );
28} 25}
29void ReceiveLayer::receive( const QString& dir, Mode, Features ) { 26void ReceiveLayer::receive( const QString& dir, Mode, Features ) {
30 receive( dir ); 27 receive( dir );
31} 28}
32void ReceiveLayer::cancel() { 29void ReceiveLayer::cancel() {
33 30
34} 31}
diff --git a/noncore/apps/opie-console/script.cpp b/noncore/apps/opie-console/script.cpp
index e6e9d6d..faea412 100644
--- a/noncore/apps/opie-console/script.cpp
+++ b/noncore/apps/opie-console/script.cpp
@@ -1,30 +1,29 @@
1#include <qfile.h> 1#include <qfile.h>
2#include <qtextstream.h>
3#include "script.h" 2#include "script.h"
4 3
5Script::Script() { 4Script::Script() {
6} 5}
7 6
8Script::Script(const QString fileName) { 7Script::Script(const QString fileName) {
9 QFile file(fileName); 8 QFile file(fileName);
10 file.open(IO_ReadOnly ); 9 file.open(IO_ReadOnly );
11 m_script = file.readAll(); 10 m_script = file.readAll();
12} 11}
13 12
14void Script::saveTo(const QString fileName) const { 13void Script::saveTo(const QString fileName) const {
15 QFile file(fileName); 14 QFile file(fileName);
16 file.open(IO_WriteOnly); 15 file.open(IO_WriteOnly);
17 file.writeBlock(m_script); 16 file.writeBlock(m_script);
18 file.close(); 17 file.close();
19} 18}
20 19
21 20
22void Script::append(const QByteArray &data) { 21void Script::append(const QByteArray &data) {
23 int size = m_script.size(); 22 int size = m_script.size();
24 m_script.resize(size + data.size()); 23 m_script.resize(size + data.size());
25 memcpy(m_script.data() + size, data.data(), data.size()); 24 memcpy(m_script.data() + size, data.data(), data.size());
26} 25}
27 26
28QByteArray Script::script() const { 27QByteArray Script::script() const {
29 return m_script; 28 return m_script;
30} 29}
diff --git a/noncore/apps/opie-console/session.cpp b/noncore/apps/opie-console/session.cpp
index 4f52584..1034ede 100644
--- a/noncore/apps/opie-console/session.cpp
+++ b/noncore/apps/opie-console/session.cpp
@@ -1,117 +1,115 @@
1 1
2 2
3#include "profile.h"
4#include "io_layer.h"
5#include "file_layer.h" 3#include "file_layer.h"
6#include "emulation_handler.h" 4#include "emulation_handler.h"
7#include "session.h" 5#include "session.h"
8 6
9 7
10Session::Session() { 8Session::Session() {
11 m_widget = 0l; 9 m_widget = 0l;
12 m_layer = 0l; 10 m_layer = 0l;
13 m_emu = 0l; 11 m_emu = 0l;
14 m_transfer = 0l; 12 m_transfer = 0l;
15} 13}
16Session::Session( const QString& na, QWidgetStack* widget, IOLayer* lay) 14Session::Session( const QString& na, QWidgetStack* widget, IOLayer* lay)
17 : m_name( na ), m_widget( widget ), m_layer( lay ) 15 : m_name( na ), m_widget( widget ), m_layer( lay )
18{ 16{
19// m_widLay = 0l; 17// m_widLay = 0l;
20// m_emLay = 0l; 18// m_emLay = 0l;
21 m_emu = 0l; 19 m_emu = 0l;
22} 20}
23Session::~Session() { 21Session::~Session() {
24 delete m_layer; 22 delete m_layer;
25 delete m_emu; 23 delete m_emu;
26 delete m_widget; 24 delete m_widget;
27 /* the widget layer should be deleted by the m_widget */ 25 /* the widget layer should be deleted by the m_widget */
28} 26}
29QString Session::name()const { 27QString Session::name()const {
30 return m_name; 28 return m_name;
31} 29}
32QWidgetStack* Session::widgetStack() { 30QWidgetStack* Session::widgetStack() {
33 return m_widget; 31 return m_widget;
34} 32}
35IOLayer* Session::layer() { 33IOLayer* Session::layer() {
36 return m_layer; 34 return m_layer;
37} 35}
38EmulationHandler* Session::emulationHandler() { 36EmulationHandler* Session::emulationHandler() {
39 return m_emu; 37 return m_emu;
40} 38}
41QWidget* Session::widget() { 39QWidget* Session::widget() {
42 if (!m_emu ) 40 if (!m_emu )
43 return 0l; 41 return 0l;
44 42
45 return m_emu->widget(); 43 return m_emu->widget();
46} 44}
47Profile Session::profile()const { 45Profile Session::profile()const {
48 return m_prof; 46 return m_prof;
49} 47}
50/* 48/*
51WidgetLayer* Session::emulationWidget() { 49WidgetLayer* Session::emulationWidget() {
52 return m_widLay; 50 return m_widLay;
53} 51}
54*/ 52*/
55void Session::connect() { 53void Session::connect() {
56 if ( !m_layer || !m_emu ) 54 if ( !m_layer || !m_emu )
57 return; 55 return;
58 56
59 QObject::connect(m_layer, SIGNAL(received(const QByteArray&) ), 57 QObject::connect(m_layer, SIGNAL(received(const QByteArray&) ),
60 m_emu, SLOT(recv(const QByteArray&) ) ); 58 m_emu, SLOT(recv(const QByteArray&) ) );
61 QObject::connect(m_emu, SIGNAL(send(const QByteArray&) ), 59 QObject::connect(m_emu, SIGNAL(send(const QByteArray&) ),
62 m_layer, SLOT(send(const QByteArray&) ) ); 60 m_layer, SLOT(send(const QByteArray&) ) );
63 QObject::connect(m_emu, SIGNAL(changeSize(int, int) ), 61 QObject::connect(m_emu, SIGNAL(changeSize(int, int) ),
64 m_layer, SLOT(setSize(int, int) ) ); 62 m_layer, SLOT(setSize(int, int) ) );
65} 63}
66 64
67void Session::disconnect() { 65void Session::disconnect() {
68 66
69 if ( !m_layer || !m_emu ) 67 if ( !m_layer || !m_emu )
70 return; 68 return;
71 69
72 QObject::disconnect(m_layer, SIGNAL(received(const QByteArray&) ), 70 QObject::disconnect(m_layer, SIGNAL(received(const QByteArray&) ),
73 m_emu, SLOT(recv(const QByteArray&) ) ); 71 m_emu, SLOT(recv(const QByteArray&) ) );
74 QObject::disconnect(m_emu, SIGNAL(send(const QByteArray&) ), 72 QObject::disconnect(m_emu, SIGNAL(send(const QByteArray&) ),
75 m_layer, SLOT(send(const QByteArray&) ) ); 73 m_layer, SLOT(send(const QByteArray&) ) );
76} 74}
77 75
78void Session::setName( const QString& na){ 76void Session::setName( const QString& na){
79 m_name = na; 77 m_name = na;
80} 78}
81 79
82void Session::setWidgetStack( QWidgetStack* wid ) { 80void Session::setWidgetStack( QWidgetStack* wid ) {
83 delete m_emu; 81 delete m_emu;
84 m_emu = 0l; 82 m_emu = 0l;
85 delete m_widget; 83 delete m_widget;
86 /* the EmulationLayer was destroyed... */ 84 /* the EmulationLayer was destroyed... */
87 85
88 m_widget = wid; 86 m_widget = wid;
89} 87}
90void Session::setIOLayer( IOLayer* lay ) { 88void Session::setIOLayer( IOLayer* lay ) {
91 delete m_layer; 89 delete m_layer;
92 m_layer = lay; 90 m_layer = lay;
93} 91}
94 92
95void Session::setEmulationHandler( EmulationHandler* lay ) { 93void Session::setEmulationHandler( EmulationHandler* lay ) {
96 delete m_emu; 94 delete m_emu;
97 m_emu = lay; 95 m_emu = lay;
98} 96}
99void Session::setProfile( const Profile& prof ) { 97void Session::setProfile( const Profile& prof ) {
100 m_prof = prof; 98 m_prof = prof;
101} 99}
102/* 100/*
103void Session::setEmulationWidget( WidgetLayer* lay ) { 101void Session::setEmulationWidget( WidgetLayer* lay ) {
104 delete m_widLay; 102 delete m_widLay;
105 m_widLay = lay; 103 m_widLay = lay;
106} 104}
107*/ 105*/
108void Session::setTransferDialog(QWidget *d) 106void Session::setTransferDialog(QWidget *d)
109{ 107{
110 m_transfer = d; 108 m_transfer = d;
111} 109}
112 110
113QWidget *Session::transferDialog() 111QWidget *Session::transferDialog()
114{ 112{
115 return m_transfer; 113 return m_transfer;
116} 114}
117 115
diff --git a/noncore/apps/opie-console/terminalwidget.cpp b/noncore/apps/opie-console/terminalwidget.cpp
index 70f7c9b..6870487 100644
--- a/noncore/apps/opie-console/terminalwidget.cpp
+++ b/noncore/apps/opie-console/terminalwidget.cpp
@@ -1,225 +1,221 @@
1#include <qbuttongroup.h>
2#include <qlabel.h> 1#include <qlabel.h>
3#include <qcheckbox.h> 2#include <qcheckbox.h>
4#include <qcombobox.h> 3#include <qcombobox.h>
5#include <qradiobutton.h> 4#include <qradiobutton.h>
6#include <qgroupbox.h>
7#include <qvbox.h>
8#include <qhgroupbox.h> 5#include <qhgroupbox.h>
9#include <qhbuttongroup.h> 6#include <qhbuttongroup.h>
10#include <qlayout.h> 7#include <qlayout.h>
11#include <qhbox.h>
12 8
13#include "terminalwidget.h" 9#include "terminalwidget.h"
14 10
15namespace { 11namespace {
16 enum TermIds { 12 enum TermIds {
17 id_term_vt100 = 0, 13 id_term_vt100 = 0,
18 id_term_vt102, 14 id_term_vt102,
19 id_term_linux, 15 id_term_linux,
20 id_term_xterm 16 id_term_xterm
21 }; 17 };
22 18
23 enum ColourIds { 19 enum ColourIds {
24 id_term_black, 20 id_term_black,
25 id_term_white, 21 id_term_white,
26 id_term_green, 22 id_term_green,
27 id_term_orange 23 id_term_orange
28 }; 24 };
29 25
30 enum FontIds { 26 enum FontIds {
31 id_size_small, 27 id_size_small,
32 id_size_medium, 28 id_size_medium,
33 id_size_large 29 id_size_large
34 }; 30 };
35}; 31};
36 32
37TerminalWidget::TerminalWidget( const QString& name, QWidget* parent, 33TerminalWidget::TerminalWidget( const QString& name, QWidget* parent,
38 const char* na ) 34 const char* na )
39 : ProfileDialogTerminalWidget( name, parent, na ) { 35 : ProfileDialogTerminalWidget( name, parent, na ) {
40 36
41 m_terminal = new QLabel(tr("Terminal Type"), this ); 37 m_terminal = new QLabel(tr("Terminal Type"), this );
42 m_terminalBox = new QComboBox(this); 38 m_terminalBox = new QComboBox(this);
43 m_colorLabel = new QLabel(tr("Color scheme"), this); 39 m_colorLabel = new QLabel(tr("Color scheme"), this);
44 m_colorCmb = new QComboBox(this ); 40 m_colorCmb = new QComboBox(this );
45 41
46 m_groupSize = new QHButtonGroup(tr("Font size"), this ); 42 m_groupSize = new QHButtonGroup(tr("Font size"), this );
47 m_sizeSmall = new QRadioButton(tr("small"), m_groupSize ); 43 m_sizeSmall = new QRadioButton(tr("small"), m_groupSize );
48 m_sizeMedium = new QRadioButton(tr("medium"), m_groupSize ); 44 m_sizeMedium = new QRadioButton(tr("medium"), m_groupSize );
49 m_sizeLarge = new QRadioButton(tr("large"), m_groupSize ); 45 m_sizeLarge = new QRadioButton(tr("large"), m_groupSize );
50 46
51 m_groupConv = new QHGroupBox( tr("Line-break conversions"), this ); 47 m_groupConv = new QHGroupBox( tr("Line-break conversions"), this );
52 m_convInbound = new QCheckBox( tr("Inbound"), m_groupConv ); 48 m_convInbound = new QCheckBox( tr("Inbound"), m_groupConv );
53 m_convOutbound = new QCheckBox( tr("Outbound"), m_groupConv ); 49 m_convOutbound = new QCheckBox( tr("Outbound"), m_groupConv );
54 50
55 m_groupOptions = new QHGroupBox( tr("Options"), this ); 51 m_groupOptions = new QHGroupBox( tr("Options"), this );
56 m_optionEcho = new QCheckBox( tr("Local echo"), m_groupOptions ); 52 m_optionEcho = new QCheckBox( tr("Local echo"), m_groupOptions );
57 m_optionWrap = new QCheckBox( tr("Line wrap"), m_groupOptions ); 53 m_optionWrap = new QCheckBox( tr("Line wrap"), m_groupOptions );
58 54
59 m_lroot = new QVBoxLayout( this ); 55 m_lroot = new QVBoxLayout( this );
60 m_typeBox = new QVBoxLayout( m_lroot ); 56 m_typeBox = new QVBoxLayout( m_lroot );
61 m_colorBox = new QVBoxLayout( m_lroot ); 57 m_colorBox = new QVBoxLayout( m_lroot );
62 58
63 // Layout 59 // Layout
64 m_typeBox->add( m_terminal ); 60 m_typeBox->add( m_terminal );
65 m_typeBox->add( m_terminalBox ); 61 m_typeBox->add( m_terminalBox );
66 m_lroot->add( m_groupSize ); 62 m_lroot->add( m_groupSize );
67 63
68 m_colorBox->add( m_colorLabel ); 64 m_colorBox->add( m_colorLabel );
69 m_colorBox->add( m_colorCmb ); 65 m_colorBox->add( m_colorCmb );
70 66
71 m_lroot->add( m_groupConv ); 67 m_lroot->add( m_groupConv );
72 m_lroot->add( m_groupOptions ); 68 m_lroot->add( m_groupOptions );
73 m_lroot->addStretch( 0 ); 69 m_lroot->addStretch( 0 );
74 70
75 // Fill in some options 71 // Fill in some options
76 qWarning("Options for terminal box"); 72 qWarning("Options for terminal box");
77 m_terminalBox->insertItem( tr("VT 100"), 0 ); // /*, id_term_vt100*/ ); 73 m_terminalBox->insertItem( tr("VT 100"), 0 ); // /*, id_term_vt100*/ );
78 m_terminalBox->insertItem( tr("VT 102"), 1 ); // /* , id_term_vt102 */); 74 m_terminalBox->insertItem( tr("VT 102"), 1 ); // /* , id_term_vt102 */);
79 m_terminalBox->insertItem( tr("Linux Console"), 2 ); //, id_term_linux ); 75 m_terminalBox->insertItem( tr("Linux Console"), 2 ); //, id_term_linux );
80 m_terminalBox->insertItem( tr("X-Terminal"), 3 ); //, id_term_xterm ); 76 m_terminalBox->insertItem( tr("X-Terminal"), 3 ); //, id_term_xterm );
81 //m_terminalBox->insertItem( tr("ANSI"), id_term_ansi ); 77 //m_terminalBox->insertItem( tr("ANSI"), id_term_ansi );
82 78
83 m_colorCmb->insertItem( tr("black on white"), id_term_black ); 79 m_colorCmb->insertItem( tr("black on white"), id_term_black );
84 m_colorCmb->insertItem( tr("white on black"), id_term_white ); 80 m_colorCmb->insertItem( tr("white on black"), id_term_white );
85 m_colorCmb->insertItem( tr("green on black"), id_term_green ); 81 m_colorCmb->insertItem( tr("green on black"), id_term_green );
86 m_colorCmb->insertItem( tr("orange on black"), id_term_orange ); 82 m_colorCmb->insertItem( tr("orange on black"), id_term_orange );
87 83
88 // signals + slots 84 // signals + slots
89 /* 85 /*
90 connect(m_terminalBox, SIGNAL(activated(int) ), 86 connect(m_terminalBox, SIGNAL(activated(int) ),
91 this, SLOT(slotTermTerm(int) ) ); 87 this, SLOT(slotTermTerm(int) ) );
92 connect(m_colorBox, SIGNAL(activated(int) ), 88 connect(m_colorBox, SIGNAL(activated(int) ),
93 tis, SLOT(slotTermColor(int) ) ); 89 tis, SLOT(slotTermColor(int) ) );
94 connect(m_groupSize, SIGNAL(activated(int) ), 90 connect(m_groupSize, SIGNAL(activated(int) ),
95 this, SLOT(slotTermFont(int) ) ); 91 this, SLOT(slotTermFont(int) ) );
96 92
97 connect(m_optionEcho, SIGNAL(toggled(bool) ), 93 connect(m_optionEcho, SIGNAL(toggled(bool) ),
98 this, SLOT(slotTermEcho(bool) ) ); 94 this, SLOT(slotTermEcho(bool) ) );
99 connect(m_optionWrap, SIGNAL(toggled(bool) ), 95 connect(m_optionWrap, SIGNAL(toggled(bool) ),
100 this, SLOT(slotTermWrap(bool) ) ); 96 this, SLOT(slotTermWrap(bool) ) );
101 connect(m_convInbound, SIGNAL(toggled(bool) ), 97 connect(m_convInbound, SIGNAL(toggled(bool) ),
102 this, SLOT(slotTermInbound(bool) ) ); 98 this, SLOT(slotTermInbound(bool) ) );
103 connect(m_convOutbound, SIGNAL(toggled(bool) ), 99 connect(m_convOutbound, SIGNAL(toggled(bool) ),
104 this, SLOT(slotTermOutbound(bool) ) ); 100 this, SLOT(slotTermOutbound(bool) ) );
105*/ 101*/
106} 102}
107TerminalWidget::~TerminalWidget() { 103TerminalWidget::~TerminalWidget() {
108} 104}
109void TerminalWidget::load( const Profile& prof ) { 105void TerminalWidget::load( const Profile& prof ) {
110 int term = prof.readNumEntry("Terminal"); 106 int term = prof.readNumEntry("Terminal");
111 int color = prof.readNumEntry("Color"); 107 int color = prof.readNumEntry("Color");
112 int fontsize = prof.readNumEntry("Font"); 108 int fontsize = prof.readNumEntry("Font");
113 int opt_echo = prof.readNumEntry("Echo"); 109 int opt_echo = prof.readNumEntry("Echo");
114 int opt_wrap = prof.readNumEntry("Wrap"); 110 int opt_wrap = prof.readNumEntry("Wrap");
115 int opt_inbound = prof.readNumEntry("Inbound"); 111 int opt_inbound = prof.readNumEntry("Inbound");
116 int opt_outbound = prof.readNumEntry("Outbound"); 112 int opt_outbound = prof.readNumEntry("Outbound");
117 113
118 switch( term ) { 114 switch( term ) {
119 case Profile::VT100: 115 case Profile::VT100:
120 m_terminalBox->setCurrentItem(id_term_vt100 ); 116 m_terminalBox->setCurrentItem(id_term_vt100 );
121 break; 117 break;
122 case Profile::VT102: 118 case Profile::VT102:
123 m_terminalBox->setCurrentItem(id_term_vt102 ); 119 m_terminalBox->setCurrentItem(id_term_vt102 );
124 break; 120 break;
125 case Profile::Linux: 121 case Profile::Linux:
126 m_terminalBox->setCurrentItem(id_term_linux ); 122 m_terminalBox->setCurrentItem(id_term_linux );
127 break; 123 break;
128 case Profile::XTerm: 124 case Profile::XTerm:
129 m_terminalBox->setCurrentItem(id_term_xterm ); 125 m_terminalBox->setCurrentItem(id_term_xterm );
130 break; 126 break;
131 default: 127 default:
132 m_terminalBox->setCurrentItem(id_term_vt102 ); 128 m_terminalBox->setCurrentItem(id_term_vt102 );
133 break; 129 break;
134 }; 130 };
135 131
136 switch( color ) { 132 switch( color ) {
137 case Profile::Black: 133 case Profile::Black:
138 m_colorCmb->setCurrentItem(id_term_black ); 134 m_colorCmb->setCurrentItem(id_term_black );
139 break; 135 break;
140 case Profile::White: 136 case Profile::White:
141 m_colorCmb->setCurrentItem(id_term_white ); 137 m_colorCmb->setCurrentItem(id_term_white );
142 break; 138 break;
143 case Profile::Green: 139 case Profile::Green:
144 m_colorCmb->setCurrentItem(id_term_green ); 140 m_colorCmb->setCurrentItem(id_term_green );
145 break; 141 break;
146 case Profile::Orange: 142 case Profile::Orange:
147 m_colorCmb->setCurrentItem(id_term_orange ); 143 m_colorCmb->setCurrentItem(id_term_orange );
148 break; 144 break;
149 default: 145 default:
150 break; 146 break;
151 }; 147 };
152 148
153 switch( fontsize ) { 149 switch( fontsize ) {
154 case Profile::Micro: 150 case Profile::Micro:
155 m_sizeSmall->setChecked(true ); 151 m_sizeSmall->setChecked(true );
156 break; 152 break;
157 case Profile::Small: 153 case Profile::Small:
158 m_sizeMedium->setChecked(true ); 154 m_sizeMedium->setChecked(true );
159 break; 155 break;
160 case Profile::Medium: 156 case Profile::Medium:
161 m_sizeLarge->setChecked( true ); 157 m_sizeLarge->setChecked( true );
162 break; 158 break;
163 default: 159 default:
164 m_sizeMedium->setChecked(true ); 160 m_sizeMedium->setChecked(true );
165 break; 161 break;
166 }; 162 };
167 163
168 if (opt_echo) m_optionEcho->setChecked( true ); 164 if (opt_echo) m_optionEcho->setChecked( true );
169 if (opt_wrap) m_optionWrap->setChecked( true ); 165 if (opt_wrap) m_optionWrap->setChecked( true );
170 if (opt_inbound) m_convInbound->setChecked( true ); 166 if (opt_inbound) m_convInbound->setChecked( true );
171 if (opt_outbound) m_convOutbound->setChecked( true ); 167 if (opt_outbound) m_convOutbound->setChecked( true );
172 168
173} 169}
174void TerminalWidget::save( Profile& profile ) { 170void TerminalWidget::save( Profile& profile ) {
175 switch(m_terminalBox->currentItem() ) { 171 switch(m_terminalBox->currentItem() ) {
176 case id_term_vt100: 172 case id_term_vt100:
177 profile.writeEntry("Terminal", Profile::VT100 ); 173 profile.writeEntry("Terminal", Profile::VT100 );
178 break; 174 break;
179 case id_term_vt102: 175 case id_term_vt102:
180 profile.writeEntry("Terminal", Profile::VT102 ); 176 profile.writeEntry("Terminal", Profile::VT102 );
181 break; 177 break;
182 case id_term_linux: 178 case id_term_linux:
183 profile.writeEntry("Terminal", Profile::Linux ); 179 profile.writeEntry("Terminal", Profile::Linux );
184 break; 180 break;
185 case id_term_xterm: 181 case id_term_xterm:
186 profile.writeEntry("Terminal", Profile::XTerm ); 182 profile.writeEntry("Terminal", Profile::XTerm );
187 break; 183 break;
188 //case id_term_ansi: 184 //case id_term_ansi:
189 // profile.writeEntry("Terminal", Profile::VT102 ); 185 // profile.writeEntry("Terminal", Profile::VT102 );
190 // break; 186 // break;
191 default: 187 default:
192 break; 188 break;
193 }; 189 };
194 190
195 // color 191 // color
196 switch(m_colorCmb->currentItem() ) { 192 switch(m_colorCmb->currentItem() ) {
197 case id_term_black: 193 case id_term_black:
198 profile.writeEntry("Color", Profile::Black ); 194 profile.writeEntry("Color", Profile::Black );
199 break; 195 break;
200 case id_term_white: 196 case id_term_white:
201 profile.writeEntry("Color", Profile::White ); 197 profile.writeEntry("Color", Profile::White );
202 break; 198 break;
203 case id_term_green: 199 case id_term_green:
204 profile.writeEntry("Color", Profile::Green ); 200 profile.writeEntry("Color", Profile::Green );
205 break; 201 break;
206 case id_term_orange: 202 case id_term_orange:
207 profile.writeEntry("Color", Profile::Orange ); 203 profile.writeEntry("Color", Profile::Orange );
208 break; 204 break;
209 default: 205 default:
210 break; 206 break;
211 }; 207 };
212 208
213 if (m_sizeSmall->isChecked() ) { 209 if (m_sizeSmall->isChecked() ) {
214 profile.writeEntry("Font", Profile::Micro ); 210 profile.writeEntry("Font", Profile::Micro );
215 }else if (m_sizeMedium->isChecked() ) { 211 }else if (m_sizeMedium->isChecked() ) {
216 profile.writeEntry("Font", Profile::Small ); 212 profile.writeEntry("Font", Profile::Small );
217 }else { 213 }else {
218 profile.writeEntry("Font", Profile::Medium ); 214 profile.writeEntry("Font", Profile::Medium );
219 } 215 }
220 216
221 profile.writeEntry("Echo", m_optionEcho->isChecked() ); 217 profile.writeEntry("Echo", m_optionEcho->isChecked() );
222 profile.writeEntry("Wrap", m_optionWrap->isChecked() ); 218 profile.writeEntry("Wrap", m_optionWrap->isChecked() );
223 profile.writeEntry("Inbound", m_convInbound->isChecked() ); 219 profile.writeEntry("Inbound", m_convInbound->isChecked() );
224 profile.writeEntry("Outbound",m_convOutbound->isChecked() ); 220 profile.writeEntry("Outbound",m_convOutbound->isChecked() );
225} 221}
diff --git a/noncore/apps/opie-console/transferdialog.cpp b/noncore/apps/opie-console/transferdialog.cpp
index 0af1911..55dd748 100644
--- a/noncore/apps/opie-console/transferdialog.cpp
+++ b/noncore/apps/opie-console/transferdialog.cpp
@@ -1,277 +1,275 @@
1#include <qlayout.h> 1#include <qlayout.h>
2#include <qcombobox.h> 2#include <qcombobox.h>
3#include <qlabel.h> 3#include <qlabel.h>
4#include <qlineedit.h> 4#include <qlineedit.h>
5#include <qpushbutton.h> 5#include <qpushbutton.h>
6#include <qmessagebox.h> 6#include <qmessagebox.h>
7#include <qprogressbar.h> 7#include <qprogressbar.h>
8#include <qradiobutton.h> 8#include <qradiobutton.h>
9#include <qbuttongroup.h> 9#include <qbuttongroup.h>
10 10
11#include <opie/ofiledialog.h> 11#include <opie/ofiledialog.h>
12 12
13#include "file_layer.h"
14#include "receive_layer.h"
15#include "metafactory.h" 13#include "metafactory.h"
16#include "mainwindow.h" 14#include "mainwindow.h"
17 15
18#include "transferdialog.h" 16#include "transferdialog.h"
19 17
20TransferDialog::TransferDialog(QWidget *parent, MainWindow *mainwindow, const char *) 18TransferDialog::TransferDialog(QWidget *parent, MainWindow *mainwindow, const char *)
21: QDialog(parent, 0l, false), m_win(mainwindow) 19: QDialog(parent, 0l, false), m_win(mainwindow)
22{ 20{
23 m_lay = 0l; 21 m_lay = 0l;
24 m_recvlay = 0l; 22 m_recvlay = 0l;
25 QVBoxLayout *vbox, *vbox2; 23 QVBoxLayout *vbox, *vbox2;
26 QHBoxLayout *hbox, *hbox2, *hbox3; 24 QHBoxLayout *hbox, *hbox2, *hbox3;
27 QLabel *file, *mode, *progress, *status; 25 QLabel *file, *mode, *progress, *status;
28 QButtonGroup *group; 26 QButtonGroup *group;
29 QRadioButton *mode_send, *mode_receive; 27 QRadioButton *mode_send, *mode_receive;
30 28
31 m_autocleanup = 0; 29 m_autocleanup = 0;
32 m_running = true; 30 m_running = true;
33 31
34 group = new QButtonGroup(QObject::tr("Transfer mode"), this); 32 group = new QButtonGroup(QObject::tr("Transfer mode"), this);
35 mode_send = new QRadioButton(QObject::tr("Send"), group); 33 mode_send = new QRadioButton(QObject::tr("Send"), group);
36 mode_receive = new QRadioButton(QObject::tr("Receive"), group); 34 mode_receive = new QRadioButton(QObject::tr("Receive"), group);
37 group->insert(mode_send, id_send); 35 group->insert(mode_send, id_send);
38 group->insert(mode_receive, id_receive); 36 group->insert(mode_receive, id_receive);
39 vbox2 = new QVBoxLayout(group, 2); 37 vbox2 = new QVBoxLayout(group, 2);
40 vbox2->addSpacing(10); 38 vbox2->addSpacing(10);
41 hbox3 = new QHBoxLayout(vbox2, 2); 39 hbox3 = new QHBoxLayout(vbox2, 2);
42 hbox3->add(mode_send); 40 hbox3->add(mode_send);
43 hbox3->add(mode_receive); 41 hbox3->add(mode_receive);
44 mode_send->setChecked(true); 42 mode_send->setChecked(true);
45 m_transfermode = id_send; 43 m_transfermode = id_send;
46 44
47 file = new QLabel(QObject::tr("Send file"), this); 45 file = new QLabel(QObject::tr("Send file"), this);
48 mode = new QLabel(QObject::tr("Transfer protocol"), this); 46 mode = new QLabel(QObject::tr("Transfer protocol"), this);
49 progress = new QLabel(QObject::tr("Progress"), this); 47 progress = new QLabel(QObject::tr("Progress"), this);
50 status = new QLabel(QObject::tr("Status"), this); 48 status = new QLabel(QObject::tr("Status"), this);
51 49
52 statusbar = new QLabel(QObject::tr("Ready"), this); 50 statusbar = new QLabel(QObject::tr("Ready"), this);
53 statusbar->setFrameStyle(QFrame::Panel | QFrame::Sunken); 51 statusbar->setFrameStyle(QFrame::Panel | QFrame::Sunken);
54 52
55 protocol = new QComboBox(this); 53 protocol = new QComboBox(this);
56 QStringList list = m_win->factory()->fileTransferLayers(); 54 QStringList list = m_win->factory()->fileTransferLayers();
57 for (QStringList::Iterator it = list.begin(); it != list.end(); ++it) 55 for (QStringList::Iterator it = list.begin(); it != list.end(); ++it)
58 protocol->insertItem((*it)); 56 protocol->insertItem((*it));
59 57
60 filename = new QLineEdit(this); 58 filename = new QLineEdit(this);
61 59
62 progressbar = new QProgressBar(this); 60 progressbar = new QProgressBar(this);
63 progressbar->setProgress(0); 61 progressbar->setProgress(0);
64 62
65 selector = new QPushButton("...", this); 63 selector = new QPushButton("...", this);
66 ok = new QPushButton(QObject::tr("Start transfer"), this); 64 ok = new QPushButton(QObject::tr("Start transfer"), this);
67 cancel = new QPushButton(QObject::tr("Cancel"), this); 65 cancel = new QPushButton(QObject::tr("Cancel"), this);
68 66
69 vbox = new QVBoxLayout(this, 2); 67 vbox = new QVBoxLayout(this, 2);
70 vbox->add(group); 68 vbox->add(group);
71 vbox->add(file); 69 vbox->add(file);
72 hbox = new QHBoxLayout(vbox, 0); 70 hbox = new QHBoxLayout(vbox, 0);
73 hbox->add(filename); 71 hbox->add(filename);
74 hbox->add(selector); 72 hbox->add(selector);
75 vbox->add(mode); 73 vbox->add(mode);
76 vbox->add(protocol); 74 vbox->add(protocol);
77 vbox->add(progress); 75 vbox->add(progress);
78 vbox->add(progressbar); 76 vbox->add(progressbar);
79 vbox->add(status); 77 vbox->add(status);
80 vbox->add(statusbar); 78 vbox->add(statusbar);
81 vbox->addStretch(1); 79 vbox->addStretch(1);
82 hbox2 = new QHBoxLayout(vbox, 2); 80 hbox2 = new QHBoxLayout(vbox, 2);
83 hbox2->add(ok); 81 hbox2->add(ok);
84 hbox2->add(cancel); 82 hbox2->add(cancel);
85 83
86 setCaption(QObject::tr("File transfer")); 84 setCaption(QObject::tr("File transfer"));
87 show(); 85 show();
88 86
89 connect(selector, SIGNAL(clicked()), SLOT(slotFilename())); 87 connect(selector, SIGNAL(clicked()), SLOT(slotFilename()));
90 connect(ok, SIGNAL(clicked()), SLOT(slotTransfer())); 88 connect(ok, SIGNAL(clicked()), SLOT(slotTransfer()));
91 connect(cancel, SIGNAL(clicked()), SLOT(slotCancel())); 89 connect(cancel, SIGNAL(clicked()), SLOT(slotCancel()));
92 connect(group, SIGNAL(clicked(int)), SLOT(slotMode(int))); 90 connect(group, SIGNAL(clicked(int)), SLOT(slotMode(int)));
93} 91}
94 92
95TransferDialog::~TransferDialog() 93TransferDialog::~TransferDialog()
96{ 94{
97} 95}
98 96
99void TransferDialog::slotFilename() 97void TransferDialog::slotFilename()
100{ 98{
101 QString f; 99 QString f;
102 100
103 f = OFileDialog::getOpenFileName(0); 101 f = OFileDialog::getOpenFileName(0);
104 if(!f.isNull()) filename->setText(f); 102 if(!f.isNull()) filename->setText(f);
105} 103}
106 104
107void TransferDialog::slotTransfer() 105void TransferDialog::slotTransfer()
108{ 106{
109 if((m_transfermode == id_send) && (filename->text().isEmpty())) 107 if((m_transfermode == id_send) && (filename->text().isEmpty()))
110 { 108 {
111 QMessageBox::information(this, 109 QMessageBox::information(this,
112 QObject::tr("Attention"), 110 QObject::tr("Attention"),
113 QObject::tr("No file has been specified.")); 111 QObject::tr("No file has been specified."));
114 return; 112 return;
115 } 113 }
116 114
117 ok->setEnabled(false); 115 ok->setEnabled(false);
118 116
119 cleanup(); 117 cleanup();
120 m_autocleanup = 0; 118 m_autocleanup = 0;
121 119
122 if(m_transfermode == id_send) statusbar->setText(QObject::tr("Sending...")); 120 if(m_transfermode == id_send) statusbar->setText(QObject::tr("Sending..."));
123 else statusbar->setText(QObject::tr("Receiving...")); 121 else statusbar->setText(QObject::tr("Receiving..."));
124 122
125 if(m_transfermode == id_send) 123 if(m_transfermode == id_send)
126 { 124 {
127 m_lay = m_win->factory()->newFileTransfer(protocol->currentText(), m_win->currentSession()->layer()); 125 m_lay = m_win->factory()->newFileTransfer(protocol->currentText(), m_win->currentSession()->layer());
128 m_lay->sendFile(filename->text()); 126 m_lay->sendFile(filename->text());
129 127
130 connect(m_lay, SIGNAL(progress(const QString&, int, int, int, int, int)), 128 connect(m_lay, SIGNAL(progress(const QString&, int, int, int, int, int)),
131 SLOT(slotProgress(const QString&, int, int, int, int, int))); 129 SLOT(slotProgress(const QString&, int, int, int, int, int)));
132 connect(m_lay, SIGNAL(error(int, const QString&)), SLOT(slotError(int, const QString&))); 130 connect(m_lay, SIGNAL(error(int, const QString&)), SLOT(slotError(int, const QString&)));
133 connect(m_lay, SIGNAL(sent()), SLOT(slotSent())); 131 connect(m_lay, SIGNAL(sent()), SLOT(slotSent()));
134 } 132 }
135 else 133 else
136 { 134 {
137 m_recvlay = m_win->factory()->newReceive(protocol->currentText(), m_win->currentSession()->layer()); 135 m_recvlay = m_win->factory()->newReceive(protocol->currentText(), m_win->currentSession()->layer());
138 m_recvlay->receive(); 136 m_recvlay->receive();
139 137
140 connect(m_recvlay, SIGNAL(progress(const QString&, int, int, int, int, int)), 138 connect(m_recvlay, SIGNAL(progress(const QString&, int, int, int, int, int)),
141 SLOT(slotProgress(const QString&, int, int, int, int, int))); 139 SLOT(slotProgress(const QString&, int, int, int, int, int)));
142 connect(m_recvlay, SIGNAL(error(int, const QString&)), SLOT(slotError(int, const QString&))); 140 connect(m_recvlay, SIGNAL(error(int, const QString&)), SLOT(slotError(int, const QString&)));
143 connect(m_recvlay, SIGNAL(received(const QString&)), SLOT(slotReceived(const QString&))); 141 connect(m_recvlay, SIGNAL(received(const QString&)), SLOT(slotReceived(const QString&)));
144 } 142 }
145} 143}
146 144
147void TransferDialog::cleanup() 145void TransferDialog::cleanup()
148{ 146{
149 if(m_lay) 147 if(m_lay)
150 { 148 {
151 m_lay->cancel(); 149 m_lay->cancel();
152 delete m_lay; 150 delete m_lay;
153 m_lay = 0l; 151 m_lay = 0l;
154 } 152 }
155 if(m_recvlay) 153 if(m_recvlay)
156 { 154 {
157 m_recvlay->cancel(); 155 m_recvlay->cancel();
158 delete m_recvlay; 156 delete m_recvlay;
159 m_recvlay = 0l; 157 m_recvlay = 0l;
160 } 158 }
161} 159}
162 160
163void TransferDialog::slotCancel() 161void TransferDialog::slotCancel()
164{ 162{
165 ok->setEnabled(true); 163 ok->setEnabled(true);
166 statusbar->setText(QObject::tr("Ready")); 164 statusbar->setText(QObject::tr("Ready"));
167 165
168 if((m_lay) || (m_recvlay)) 166 if((m_lay) || (m_recvlay))
169 { 167 {
170 cleanup(); 168 cleanup();
171 if(m_autocleanup) 169 if(m_autocleanup)
172 { 170 {
173 m_running = false; 171 m_running = false;
174 close(); 172 close();
175 } 173 }
176 else 174 else
177 { 175 {
178 QMessageBox::information(this, 176 QMessageBox::information(this,
179 QObject::tr("Cancelled"), 177 QObject::tr("Cancelled"),
180 QObject::tr("The file transfer has been cancelled.")); 178 QObject::tr("The file transfer has been cancelled."));
181 } 179 }
182 } 180 }
183 else 181 else
184 { 182 {
185 m_running = false; 183 m_running = false;
186 close(); 184 close();
187 } 185 }
188} 186}
189 187
190void TransferDialog::slotProgress(const QString& , int progress, int , int , int, int ) 188void TransferDialog::slotProgress(const QString& , int progress, int , int , int, int )
191{ 189{
192 progressbar->setProgress(progress); 190 progressbar->setProgress(progress);
193} 191}
194 192
195void TransferDialog::slotError(int error, const QString& ) 193void TransferDialog::slotError(int error, const QString& )
196{ 194{
197 statusbar->setText(QObject::tr("Ready")); 195 statusbar->setText(QObject::tr("Ready"));
198 196
199 switch(error) 197 switch(error)
200 { 198 {
201 case FileTransferLayer::NotSupported: 199 case FileTransferLayer::NotSupported:
202 QMessageBox::critical(this, 200 QMessageBox::critical(this,
203 QObject::tr("Error"), 201 QObject::tr("Error"),
204 QObject::tr("Operation not supported.")); 202 QObject::tr("Operation not supported."));
205 break; 203 break;
206 case FileTransferLayer::StartError: 204 case FileTransferLayer::StartError:
207 QMessageBox::critical(this, 205 QMessageBox::critical(this,
208 QObject::tr("Error"), 206 QObject::tr("Error"),
209 QObject::tr("Transfer could not be started.")); 207 QObject::tr("Transfer could not be started."));
210 break; 208 break;
211 case FileTransferLayer::NoError: 209 case FileTransferLayer::NoError:
212 QMessageBox::critical(this, 210 QMessageBox::critical(this,
213 QObject::tr("Error"), 211 QObject::tr("Error"),
214 QObject::tr("No error.")); 212 QObject::tr("No error."));
215 break; 213 break;
216 case FileTransferLayer::Undefined: 214 case FileTransferLayer::Undefined:
217 QMessageBox::critical(this, 215 QMessageBox::critical(this,
218 QObject::tr("Error"), 216 QObject::tr("Error"),
219 QObject::tr("Undefined error occured.")); 217 QObject::tr("Undefined error occured."));
220 break; 218 break;
221 case FileTransferLayer::Incomplete: 219 case FileTransferLayer::Incomplete:
222 QMessageBox::critical(this, 220 QMessageBox::critical(this,
223 QObject::tr("Error"), 221 QObject::tr("Error"),
224 QObject::tr("Incomplete transfer.")); 222 QObject::tr("Incomplete transfer."));
225 break; 223 break;
226 case FileTransferLayer::Unknown: 224 case FileTransferLayer::Unknown:
227 default: 225 default:
228 QMessageBox::critical(this, 226 QMessageBox::critical(this,
229 QObject::tr("Error"), 227 QObject::tr("Error"),
230 QObject::tr("Unknown error occured.")); 228 QObject::tr("Unknown error occured."));
231 break; 229 break;
232 } 230 }
233 231
234 m_autocleanup = 1; 232 m_autocleanup = 1;
235} 233}
236 234
237void TransferDialog::slotSent() 235void TransferDialog::slotSent()
238{ 236{
239 progressbar->setProgress(100); 237 progressbar->setProgress(100);
240 QMessageBox::information(this, QObject::tr("Sent"), QObject::tr("File has been sent.")); 238 QMessageBox::information(this, QObject::tr("Sent"), QObject::tr("File has been sent."));
241 ok->setEnabled(true); 239 ok->setEnabled(true);
242 progressbar->setProgress(0); 240 progressbar->setProgress(0);
243 statusbar->setText(QObject::tr("Ready")); 241 statusbar->setText(QObject::tr("Ready"));
244 m_autocleanup = 1; 242 m_autocleanup = 1;
245} 243}
246 244
247void TransferDialog::slotReceived(const QString& ) 245void TransferDialog::slotReceived(const QString& )
248{ 246{
249 progressbar->setProgress(100); 247 progressbar->setProgress(100);
250 QMessageBox::information(this, QObject::tr("Received"), QObject::tr("File has been received.")); 248 QMessageBox::information(this, QObject::tr("Received"), QObject::tr("File has been received."));
251 //QMessageBox::information(this, QObject::tr("Sent"), QObject::tr("File has been received as %1.").arg(file)); 249 //QMessageBox::information(this, QObject::tr("Sent"), QObject::tr("File has been received as %1.").arg(file));
252 ok->setEnabled(true); 250 ok->setEnabled(true);
253 progressbar->setProgress(0); 251 progressbar->setProgress(0);
254 statusbar->setText(QObject::tr("Ready")); 252 statusbar->setText(QObject::tr("Ready"));
255 m_autocleanup = 1; 253 m_autocleanup = 1;
256} 254}
257 255
258void TransferDialog::slotMode(int id) 256void TransferDialog::slotMode(int id)
259{ 257{
260 if(id == id_send) 258 if(id == id_send)
261 { 259 {
262 selector->setEnabled(true); 260 selector->setEnabled(true);
263 filename->setEnabled(true); 261 filename->setEnabled(true);
264 } 262 }
265 else 263 else
266 { 264 {
267 selector->setEnabled(false); 265 selector->setEnabled(false);
268 filename->setEnabled(false); 266 filename->setEnabled(false);
269 } 267 }
270 m_transfermode = id; 268 m_transfermode = id;
271} 269}
272 270
273bool TransferDialog::isRunning() 271bool TransferDialog::isRunning()
274{ 272{
275 return m_running; 273 return m_running;
276} 274}
277 275
diff --git a/noncore/apps/opie-console/vt102emulation.cpp b/noncore/apps/opie-console/vt102emulation.cpp
index 0ebefa0..35b789c 100644
--- a/noncore/apps/opie-console/vt102emulation.cpp
+++ b/noncore/apps/opie-console/vt102emulation.cpp
@@ -1,802 +1,797 @@
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_layer.h"
28#include "screen.h"
29#include "keytrans.h"
30 27
31#include <stdio.h> 28#include <stdio.h>
32#include <unistd.h> 29#include <unistd.h>
33#include <qkeycode.h>
34#include <qtextcodec.h>
35 30
36 31
37/* VT102 Terminal Emulation 32/* VT102 Terminal Emulation
38 33
39 This class puts together the screens, the pty and the widget to a 34 This class puts together the screens, the pty and the widget to a
40 complete terminal emulation. Beside combining it's componentes, it 35 complete terminal emulation. Beside combining it's componentes, it
41 handles the emulations's protocol. 36 handles the emulations's protocol.
42 37
43 This module consists of the following sections: 38 This module consists of the following sections:
44 39
45 - Constructor/Destructor 40 - Constructor/Destructor
46 - Incoming Bytes Event pipeline 41 - Incoming Bytes Event pipeline
47 - Outgoing Bytes 42 - Outgoing Bytes
48 - Mouse Events 43 - Mouse Events
49 - Keyboard Events 44 - Keyboard Events
50 - Modes and Charset State 45 - Modes and Charset State
51 - Diagnostics 46 - Diagnostics
52*/ 47*/
53 48
54 49
55/* ------------------------------------------------------------------------- */ 50/* ------------------------------------------------------------------------- */
56/* */ 51/* */
57/* Constructor / Destructor */ 52/* Constructor / Destructor */
58/* */ 53/* */
59/* ------------------------------------------------------------------------- */ 54/* ------------------------------------------------------------------------- */
60 55
61/* 56/*
62 Nothing really intesting happens here. 57 Nothing really intesting happens here.
63*/ 58*/
64 59
65/*! 60/*!
66*/ 61*/
67 62
68Vt102Emulation::Vt102Emulation(WidgetLayer* gui) : EmulationLayer(gui) 63Vt102Emulation::Vt102Emulation(WidgetLayer* gui) : EmulationLayer(gui)
69{ 64{
70 QObject::connect(gui,SIGNAL(mouseSignal(int,int,int)), 65 QObject::connect(gui,SIGNAL(mouseSignal(int,int,int)),
71 this,SLOT(onMouse(int,int,int))); 66 this,SLOT(onMouse(int,int,int)));
72 initTokenizer(); 67 initTokenizer();
73 reset(); 68 reset();
74} 69}
75 70
76/*! 71/*!
77*/ 72*/
78 73
79Vt102Emulation::~Vt102Emulation() 74Vt102Emulation::~Vt102Emulation()
80{ 75{
81} 76}
82 77
83/*! 78/*!
84*/ 79*/
85 80
86void Vt102Emulation::reset() 81void Vt102Emulation::reset()
87{ 82{
88 resetToken(); 83 resetToken();
89 resetModes(); 84 resetModes();
90 resetCharset(0); screen[0]->reset(); 85 resetCharset(0); screen[0]->reset();
91 resetCharset(1); screen[0]->reset(); 86 resetCharset(1); screen[0]->reset();
92 setCodec(0); 87 setCodec(0);
93 setKeytrans("linux.keytab"); 88 setKeytrans("linux.keytab");
94} 89}
95 90
96/* ------------------------------------------------------------------------- */ 91/* ------------------------------------------------------------------------- */
97/* */ 92/* */
98/* Processing the incoming byte stream */ 93/* Processing the incoming byte stream */
99/* */ 94/* */
100/* ------------------------------------------------------------------------- */ 95/* ------------------------------------------------------------------------- */
101 96
102/* Incoming Bytes Event pipeline 97/* Incoming Bytes Event pipeline
103 98
104 This section deals with decoding the incoming character stream. 99 This section deals with decoding the incoming character stream.
105 Decoding means here, that the stream is first seperated into `tokens' 100 Decoding means here, that the stream is first seperated into `tokens'
106 which are then mapped to a `meaning' provided as operations by the 101 which are then mapped to a `meaning' provided as operations by the
107 `TEScreen' class or by the emulation class itself. 102 `TEScreen' class or by the emulation class itself.
108 103
109 The pipeline proceeds as follows: 104 The pipeline proceeds as follows:
110 105
111 - Tokenizing the ESC codes (onRcvChar) 106 - Tokenizing the ESC codes (onRcvChar)
112 - VT100 code page translation of plain characters (applyCharset) 107 - VT100 code page translation of plain characters (applyCharset)
113 - Interpretation of ESC codes (tau) 108 - Interpretation of ESC codes (tau)
114 109
115 The escape codes and their meaning are described in the 110 The escape codes and their meaning are described in the
116 technical reference of this program. 111 technical reference of this program.
117*/ 112*/
118 113
119// Tokens ------------------------------------------------------------------ -- 114// Tokens ------------------------------------------------------------------ --
120 115
121/* 116/*
122 Since the tokens are the central notion if this section, we've put them 117 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 118 in front. They provide the syntactical elements used to represent the
124 terminals operations as byte sequences. 119 terminals operations as byte sequences.
125 120
126 They are encodes here into a single machine word, so that we can later 121 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 122 switch over them easily. Depending on the token itself, additional
128 argument variables are filled with parameter values. 123 argument variables are filled with parameter values.
129 124
130 The tokens are defined below: 125 The tokens are defined below:
131 126
132 - CHR - Printable characters (32..255 but DEL (=127)) 127 - CHR - Printable characters (32..255 but DEL (=127))
133 - CTL - Control characters (0..31 but ESC (= 27), DEL) 128 - CTL - Control characters (0..31 but ESC (= 27), DEL)
134 - ESC - Escape codes of the form <ESC><CHR but `[]()+*#'> 129 - ESC - Escape codes of the form <ESC><CHR but `[]()+*#'>
135 - ESC_DE - Escape codes of the form <ESC><any of `()+*#%'> C 130 - ESC_DE - Escape codes of the form <ESC><any of `()+*#%'> C
136 - CSI_PN - Escape codes of the form <ESC>'[' {Pn} ';' {Pn} C 131 - CSI_PN - Escape codes of the form <ESC>'[' {Pn} ';' {Pn} C
137 - CSI_PS - Escape codes of the form <ESC>'[' {Pn} ';' ... C 132 - CSI_PS - Escape codes of the form <ESC>'[' {Pn} ';' ... C
138 - CSI_PR - Escape codes of the form <ESC>'[' '?' {Pn} ';' ... C 133 - CSI_PR - Escape codes of the form <ESC>'[' '?' {Pn} ';' ... C
139 - VT52 - VT52 escape codes 134 - VT52 - VT52 escape codes
140 - <ESC><Chr> 135 - <ESC><Chr>
141 - <ESC>'Y'{Pc}{Pc} 136 - <ESC>'Y'{Pc}{Pc}
142 - XTE_HA - Xterm hacks <ESC>`]' {Pn} `;' {Text} <BEL> 137 - XTE_HA - Xterm hacks <ESC>`]' {Pn} `;' {Text} <BEL>
143 note that this is handled differently 138 note that this is handled differently
144 139
145 The last two forms allow list of arguments. Since the elements of 140 The last two forms allow list of arguments. Since the elements of
146 the lists are treated individually the same way, they are passed 141 the lists are treated individually the same way, they are passed
147 as individual tokens to the interpretation. Further, because the 142 as individual tokens to the interpretation. Further, because the
148 meaning of the parameters are names (althought represented as numbers), 143 meaning of the parameters are names (althought represented as numbers),
149 they are includes within the token ('N'). 144 they are includes within the token ('N').
150 145
151*/ 146*/
152 147
153#define TY_CONSTR(T,A,N) ( ((((int)N) & 0xffff) << 16) | ((((int)A) & 0xff) << 8) | (((int)T) & 0xff) ) 148#define TY_CONSTR(T,A,N) ( ((((int)N) & 0xffff) << 16) | ((((int)A) & 0xff) << 8) | (((int)T) & 0xff) )
154 149
155#define TY_CHR___( ) TY_CONSTR(0,0,0) 150#define TY_CHR___( ) TY_CONSTR(0,0,0)
156#define TY_CTL___(A ) TY_CONSTR(1,A,0) 151#define TY_CTL___(A ) TY_CONSTR(1,A,0)
157#define TY_ESC___(A ) TY_CONSTR(2,A,0) 152#define TY_ESC___(A ) TY_CONSTR(2,A,0)
158#define TY_ESC_CS(A,B) TY_CONSTR(3,A,B) 153#define TY_ESC_CS(A,B) TY_CONSTR(3,A,B)
159#define TY_ESC_DE(A ) TY_CONSTR(4,A,0) 154#define TY_ESC_DE(A ) TY_CONSTR(4,A,0)
160#define TY_CSI_PS(A,N) TY_CONSTR(5,A,N) 155#define TY_CSI_PS(A,N) TY_CONSTR(5,A,N)
161#define TY_CSI_PN(A ) TY_CONSTR(6,A,0) 156#define TY_CSI_PN(A ) TY_CONSTR(6,A,0)
162#define TY_CSI_PR(A,N) TY_CONSTR(7,A,N) 157#define TY_CSI_PR(A,N) TY_CONSTR(7,A,N)
163 158
164#define TY_VT52__(A ) TY_CONSTR(8,A,0) 159#define TY_VT52__(A ) TY_CONSTR(8,A,0)
165 160
166// Tokenizer --------------------------------------------------------------- -- 161// Tokenizer --------------------------------------------------------------- --
167 162
168/* The tokenizers state 163/* The tokenizers state
169 164
170 The state is represented by the buffer (pbuf, ppos), 165 The state is represented by the buffer (pbuf, ppos),
171 and accompanied by decoded arguments kept in (argv,argc). 166 and accompanied by decoded arguments kept in (argv,argc).
172 Note that they are kept internal in the tokenizer. 167 Note that they are kept internal in the tokenizer.
173*/ 168*/
174 169
175void Vt102Emulation::resetToken() 170void Vt102Emulation::resetToken()
176{ 171{
177 ppos = 0; argc = 0; argv[0] = 0; argv[1] = 0; 172 ppos = 0; argc = 0; argv[0] = 0; argv[1] = 0;
178} 173}
179 174
180void Vt102Emulation::addDigit(int dig) 175void Vt102Emulation::addDigit(int dig)
181{ 176{
182 argv[argc] = 10*argv[argc] + dig; 177 argv[argc] = 10*argv[argc] + dig;
183} 178}
184 179
185void Vt102Emulation::addArgument() 180void Vt102Emulation::addArgument()
186{ 181{
187 argc = QMIN(argc+1,MAXARGS-1); 182 argc = QMIN(argc+1,MAXARGS-1);
188 argv[argc] = 0; 183 argv[argc] = 0;
189} 184}
190 185
191void Vt102Emulation::pushToToken(int cc) 186void Vt102Emulation::pushToToken(int cc)
192{ 187{
193 pbuf[ppos] = cc; 188 pbuf[ppos] = cc;
194 ppos = QMIN(ppos+1,MAXPBUF-1); 189 ppos = QMIN(ppos+1,MAXPBUF-1);
195} 190}
196 191
197// Character Classes used while decoding 192// Character Classes used while decoding
198 193
199#define CTL 1 194#define CTL 1
200#define CHR 2 195#define CHR 2
201#define CPN 4 196#define CPN 4
202#define DIG 8 197#define DIG 8
203#define SCS 16 198#define SCS 16
204#define GRP 32 199#define GRP 32
205 200
206void Vt102Emulation::initTokenizer() 201void Vt102Emulation::initTokenizer()
207{ int i; UINT8* s; 202{ int i; UINT8* s;
208 for(i = 0; i < 256; i++) tbl[ i] = 0; 203 for(i = 0; i < 256; i++) tbl[ i] = 0;
209 for(i = 0; i < 32; i++) tbl[ i] |= CTL; 204 for(i = 0; i < 32; i++) tbl[ i] |= CTL;
210 for(i = 32; i < 256; i++) tbl[ i] |= CHR; 205 for(i = 32; i < 256; i++) tbl[ i] |= CHR;
211 for(s = (UINT8*)"@ABCDGHLMPXcdfry"; *s; s++) tbl[*s] |= CPN; 206 for(s = (UINT8*)"@ABCDGHLMPXcdfry"; *s; s++) tbl[*s] |= CPN;
212 for(s = (UINT8*)"0123456789" ; *s; s++) tbl[*s] |= DIG; 207 for(s = (UINT8*)"0123456789" ; *s; s++) tbl[*s] |= DIG;
213 for(s = (UINT8*)"()+*%" ; *s; s++) tbl[*s] |= SCS; 208 for(s = (UINT8*)"()+*%" ; *s; s++) tbl[*s] |= SCS;
214 for(s = (UINT8*)"()+*#[]%" ; *s; s++) tbl[*s] |= GRP; 209 for(s = (UINT8*)"()+*#[]%" ; *s; s++) tbl[*s] |= GRP;
215 resetToken(); 210 resetToken();
216} 211}
217 212
218/* Ok, here comes the nasty part of the decoder. 213/* Ok, here comes the nasty part of the decoder.
219 214
220 Instead of keeping an explicit state, we deduce it from the 215 Instead of keeping an explicit state, we deduce it from the
221 token scanned so far. It is then immediately combined with 216 token scanned so far. It is then immediately combined with
222 the current character to form a scanning decision. 217 the current character to form a scanning decision.
223 218
224 This is done by the following defines. 219 This is done by the following defines.
225 220
226 - P is the length of the token scanned so far. 221 - 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. 222 - 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'). 223 - C is a character or a group of characters (taken from 'tbl').
229 224
230 Note that they need to applied in proper order. 225 Note that they need to applied in proper order.
231*/ 226*/
232 227
233#define lec(P,L,C) (p == (P) && s[(L)] == (C)) 228#define lec(P,L,C) (p == (P) && s[(L)] == (C))
234#define lun( ) (p == 1 && cc >= 32 ) 229#define lun( ) (p == 1 && cc >= 32 )
235#define les(P,L,C) (p == (P) && s[L] < 256 && (tbl[s[(L)]] & (C)) == (C)) 230#define les(P,L,C) (p == (P) && s[L] < 256 && (tbl[s[(L)]] & (C)) == (C))
236#define eec(C) (p >= 3 && cc == (C)) 231#define eec(C) (p >= 3 && cc == (C))
237#define ees(C) (p >= 3 && cc < 256 && (tbl[ cc ] & (C)) == (C)) 232#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)) 233#define eps(C) (p >= 3 && s[2] != '?' && cc < 256 && (tbl[ cc ] & (C)) == (C))
239#define epp( ) (p >= 3 && s[2] == '?' ) 234#define epp( ) (p >= 3 && s[2] == '?' )
240#define egt( ) (p == 3 && s[2] == '>' ) 235#define egt( ) (p == 3 && s[2] == '>' )
241#define Xpe (ppos>=2 && pbuf[1] == ']' ) 236#define Xpe (ppos>=2 && pbuf[1] == ']' )
242#define Xte (Xpe && cc == 7 ) 237#define Xte (Xpe && cc == 7 )
243#define ces(C) ( cc < 256 && (tbl[ cc ] & (C)) == (C) && !Xte) 238#define ces(C) ( cc < 256 && (tbl[ cc ] & (C)) == (C) && !Xte)
244 239
245#define ESC 27 240#define ESC 27
246#define CNTL(c) ((c)-'@') 241#define CNTL(c) ((c)-'@')
247 242
248// process an incoming unicode character 243// process an incoming unicode character
249 244
250void Vt102Emulation::onRcvChar(int cc) 245void Vt102Emulation::onRcvChar(int cc)
251{ int i; 246{ int i;
252 247
253 if (cc == 127) return; //VT100: ignore. 248 if (cc == 127) return; //VT100: ignore.
254 249
255 if (ces( CTL)) 250 if (ces( CTL))
256 { // DEC HACK ALERT! Control Characters are allowed *within* esc sequences in VT100 251 { // 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 252 // 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 253 // of course. Guess this originates from a weakly layered handling of the X-on
259 // X-off protocol, which comes really below this level. 254 // X-off protocol, which comes really below this level.
260 if (cc == CNTL('X') || cc == CNTL('Z') || cc == ESC) resetToken(); //VT100: CAN or SUB 255 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; } 256 if (cc != ESC) { tau( TY_CTL___(cc+'@' ), 0, 0); return; }
262 } 257 }
263 258
264 pushToToken(cc); // advance the state 259 pushToToken(cc); // advance the state
265 260
266 int* s = pbuf; 261 int* s = pbuf;
267 int p = ppos; 262 int p = ppos;
268 263
269 if (getMode(MODE_Ansi)) // decide on proper action 264 if (getMode(MODE_Ansi)) // decide on proper action
270 { 265 {
271 if (lec(1,0,ESC)) { return; } 266 if (lec(1,0,ESC)) { return; }
272 if (les(2,1,GRP)) { return; } 267 if (les(2,1,GRP)) { return; }
273 if (Xte ) { XtermHack(); resetToken(); return; } 268 if (Xte ) { XtermHack(); resetToken(); return; }
274 if (Xpe ) { return; } 269 if (Xpe ) { return; }
275 if (lec(3,2,'?')) { return; } 270 if (lec(3,2,'?')) { return; }
276 if (lec(3,2,'>')) { return; } 271 if (lec(3,2,'>')) { return; }
277 if (lun( )) { tau( TY_CHR___(), applyCharset(cc), 0); resetToken(); return; } 272 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; } 273 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; } 274 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; } 275 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; } 276// 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; } 277 if (eps( CPN)) { tau( TY_CSI_PN(cc), argv[0],argv[1]); resetToken(); return; }
283 if (ees( DIG)) { addDigit(cc-'0'); return; } 278 if (ees( DIG)) { addDigit(cc-'0'); return; }
284 if (eec( ';')) { addArgument(); return; } 279 if (eec( ';')) { addArgument(); return; }
285 for (i=0;i<=argc;i++) 280 for (i=0;i<=argc;i++)
286 if (epp( )) tau( TY_CSI_PR(cc,argv[i]), 0, 0); else 281 if (epp( )) tau( TY_CSI_PR(cc,argv[i]), 0, 0); else
287 tau( TY_CSI_PS(cc,argv[i]), 0, 0); 282 tau( TY_CSI_PS(cc,argv[i]), 0, 0);
288 resetToken(); 283 resetToken();
289 } 284 }
290 else // mode VT52 285 else // mode VT52
291 { 286 {
292 if (lec(1,0,ESC)) return; 287 if (lec(1,0,ESC)) return;
293 if (les(1,0,CHR)) { tau( TY_CHR___( ), s[0], 0); resetToken(); return; } 288 if (les(1,0,CHR)) { tau( TY_CHR___( ), s[0], 0); resetToken(); return; }
294 if (lec(2,1,'Y')) return; 289 if (lec(2,1,'Y')) return;
295 if (lec(3,1,'Y')) return; 290 if (lec(3,1,'Y')) return;
296 if (p < 4) { tau( TY_VT52__(s[1] ), 0, 0); resetToken(); return; } 291 if (p < 4) { tau( TY_VT52__(s[1] ), 0, 0); resetToken(); return; }
297 tau( TY_VT52__(s[1] ), s[2],s[3]); resetToken(); return; 292 tau( TY_VT52__(s[1] ), s[2],s[3]); resetToken(); return;
298 } 293 }
299} 294}
300 295
301void Vt102Emulation::XtermHack() 296void Vt102Emulation::XtermHack()
302{ int i,arg = 0; 297{ int i,arg = 0;
303 for (i = 2; i < ppos && '0'<=pbuf[i] && pbuf[i]<'9' ; i++) 298 for (i = 2; i < ppos && '0'<=pbuf[i] && pbuf[i]<'9' ; i++)
304 arg = 10*arg + (pbuf[i]-'0'); 299 arg = 10*arg + (pbuf[i]-'0');
305 if (pbuf[i] != ';') { ReportErrorToken(); return; } 300 if (pbuf[i] != ';') { ReportErrorToken(); return; }
306 QChar *str = new QChar[ppos-i-2]; 301 QChar *str = new QChar[ppos-i-2];
307 for (int j = 0; j < ppos-i-2; j++) str[j] = pbuf[i+1+j]; 302 for (int j = 0; j < ppos-i-2; j++) str[j] = pbuf[i+1+j];
308 QString unistr(str,ppos-i-2); 303 QString unistr(str,ppos-i-2);
309 // arg == 1 doesn't change the title. In XTerm it only changes the icon name 304 // 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 305 // (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); 306 if (arg == 0 || arg == 2) emit changeTitle(arg,unistr);
312 delete [] str; 307 delete [] str;
313} 308}
314 309
315// Interpreting Codes --------------------------------------------------------- 310// Interpreting Codes ---------------------------------------------------------
316 311
317/* 312/*
318 Now that the incoming character stream is properly tokenized, 313 Now that the incoming character stream is properly tokenized,
319 meaning is assigned to them. These are either operations of 314 meaning is assigned to them. These are either operations of
320 the current screen, or of the emulation class itself. 315 the current screen, or of the emulation class itself.
321 316
322 The token to be interpreteted comes in as a machine word 317 The token to be interpreteted comes in as a machine word
323 possibly accompanied by two parameters. 318 possibly accompanied by two parameters.
324 319
325 Likewise, the operations assigned to, come with up to two 320 Likewise, the operations assigned to, come with up to two
326 arguments. One could consider to make up a proper table 321 arguments. One could consider to make up a proper table
327 from the function below. 322 from the function below.
328 323
329 The technical reference manual provides more informations 324 The technical reference manual provides more informations
330 about this mapping. 325 about this mapping.
331*/ 326*/
332 327
333void Vt102Emulation::tau( int token, int p, int q ) 328void Vt102Emulation::tau( int token, int p, int q )
334{ 329{
335//scan_buffer_report(); 330//scan_buffer_report();
336//if (token == TY_CHR___()) printf("%c",p); else 331//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); 332//printf("tau(%d,%d,%d, %d,%d)\n",(token>>0)&0xff,(token>>8)&0xff,(token>>16)&0xffff,p,q);
338 switch (token) 333 switch (token)
339 { 334 {
340 335
341 case TY_CHR___( ) : scr->ShowCharacter (p ); break; //UTF16 336 case TY_CHR___( ) : scr->ShowCharacter (p ); break; //UTF16
342 337
343 // 127 DEL : ignored on input 338 // 127 DEL : ignored on input
344 339
345 case TY_CTL___('@' ) : /* NUL: ignored */ break; 340 case TY_CTL___('@' ) : /* NUL: ignored */ break;
346 case TY_CTL___('A' ) : /* SOH: ignored */ break; 341 case TY_CTL___('A' ) : /* SOH: ignored */ break;
347 case TY_CTL___('B' ) : /* STX: ignored */ break; 342 case TY_CTL___('B' ) : /* STX: ignored */ break;
348 case TY_CTL___('C' ) : /* ETX: ignored */ break; 343 case TY_CTL___('C' ) : /* ETX: ignored */ break;
349 case TY_CTL___('D' ) : /* EOT: ignored */ break; 344 case TY_CTL___('D' ) : /* EOT: ignored */ break;
350 case TY_CTL___('E' ) : reportAnswerBack ( ); break; //VT100 345 case TY_CTL___('E' ) : reportAnswerBack ( ); break; //VT100
351 case TY_CTL___('F' ) : /* ACK: ignored */ break; 346 case TY_CTL___('F' ) : /* ACK: ignored */ break;
352 case TY_CTL___('G' ) : gui->bell ( ); break; //VT100 347 case TY_CTL___('G' ) : gui->bell ( ); break; //VT100
353 case TY_CTL___('H' ) : scr->BackSpace ( ); break; //VT100 348 case TY_CTL___('H' ) : scr->BackSpace ( ); break; //VT100
354 case TY_CTL___('I' ) : scr->Tabulate ( ); break; //VT100 349 case TY_CTL___('I' ) : scr->Tabulate ( ); break; //VT100
355 case TY_CTL___('J' ) : scr->NewLine ( ); break; //VT100 350 case TY_CTL___('J' ) : scr->NewLine ( ); break; //VT100
356 case TY_CTL___('K' ) : scr->NewLine ( ); break; //VT100 351 case TY_CTL___('K' ) : scr->NewLine ( ); break; //VT100
357 case TY_CTL___('L' ) : scr->NewLine ( ); break; //VT100 352 case TY_CTL___('L' ) : scr->NewLine ( ); break; //VT100
358 case TY_CTL___('M' ) : scr->Return ( ); break; //VT100 353 case TY_CTL___('M' ) : scr->Return ( ); break; //VT100
359 354
360 case TY_CTL___('N' ) : useCharset ( 1); break; //VT100 355 case TY_CTL___('N' ) : useCharset ( 1); break; //VT100
361 case TY_CTL___('O' ) : useCharset ( 0); break; //VT100 356 case TY_CTL___('O' ) : useCharset ( 0); break; //VT100
362 357
363 case TY_CTL___('P' ) : /* DLE: ignored */ break; 358 case TY_CTL___('P' ) : /* DLE: ignored */ break;
364 case TY_CTL___('Q' ) : /* DC1: XON continue */ break; //VT100 359 case TY_CTL___('Q' ) : /* DC1: XON continue */ break; //VT100
365 case TY_CTL___('R' ) : /* DC2: ignored */ break; 360 case TY_CTL___('R' ) : /* DC2: ignored */ break;
366 case TY_CTL___('S' ) : /* DC3: XOFF halt */ break; //VT100 361 case TY_CTL___('S' ) : /* DC3: XOFF halt */ break; //VT100
367 case TY_CTL___('T' ) : /* DC4: ignored */ break; 362 case TY_CTL___('T' ) : /* DC4: ignored */ break;
368 case TY_CTL___('U' ) : /* NAK: ignored */ break; 363 case TY_CTL___('U' ) : /* NAK: ignored */ break;
369 case TY_CTL___('V' ) : /* SYN: ignored */ break; 364 case TY_CTL___('V' ) : /* SYN: ignored */ break;
370 case TY_CTL___('W' ) : /* ETB: ignored */ break; 365 case TY_CTL___('W' ) : /* ETB: ignored */ break;
371 case TY_CTL___('X' ) : scr->ShowCharacter ( 0x2592); break; //VT100 366 case TY_CTL___('X' ) : scr->ShowCharacter ( 0x2592); break; //VT100
372 case TY_CTL___('Y' ) : /* EM : ignored */ break; 367 case TY_CTL___('Y' ) : /* EM : ignored */ break;
373 case TY_CTL___('Z' ) : scr->ShowCharacter ( 0x2592); break; //VT100 368 case TY_CTL___('Z' ) : scr->ShowCharacter ( 0x2592); break; //VT100
374 case TY_CTL___('[' ) : /* ESC: cannot be seen here. */ break; 369 case TY_CTL___('[' ) : /* ESC: cannot be seen here. */ break;
375 case TY_CTL___('\\' ) : /* FS : ignored */ break; 370 case TY_CTL___('\\' ) : /* FS : ignored */ break;
376 case TY_CTL___(']' ) : /* GS : ignored */ break; 371 case TY_CTL___(']' ) : /* GS : ignored */ break;
377 case TY_CTL___('^' ) : /* RS : ignored */ break; 372 case TY_CTL___('^' ) : /* RS : ignored */ break;
378 case TY_CTL___('_' ) : /* US : ignored */ break; 373 case TY_CTL___('_' ) : /* US : ignored */ break;
379 374
380 case TY_ESC___('D' ) : scr->index ( ); break; //VT100 375 case TY_ESC___('D' ) : scr->index ( ); break; //VT100
381 case TY_ESC___('E' ) : scr->NextLine ( ); break; //VT100 376 case TY_ESC___('E' ) : scr->NextLine ( ); break; //VT100
382 case TY_ESC___('H' ) : scr->changeTabStop (TRUE ); break; //VT100 377 case TY_ESC___('H' ) : scr->changeTabStop (TRUE ); break; //VT100
383 case TY_ESC___('M' ) : scr->reverseIndex ( ); break; //VT100 378 case TY_ESC___('M' ) : scr->reverseIndex ( ); break; //VT100
384 case TY_ESC___('Z' ) : reportTerminalType ( ); break; 379 case TY_ESC___('Z' ) : reportTerminalType ( ); break;
385 case TY_ESC___('c' ) : reset ( ); break; 380 case TY_ESC___('c' ) : reset ( ); break;
386 381
387 case TY_ESC___('n' ) : useCharset ( 2); break; 382 case TY_ESC___('n' ) : useCharset ( 2); break;
388 case TY_ESC___('o' ) : useCharset ( 3); break; 383 case TY_ESC___('o' ) : useCharset ( 3); break;
389 case TY_ESC___('7' ) : saveCursor ( ); break; 384 case TY_ESC___('7' ) : saveCursor ( ); break;
390 case TY_ESC___('8' ) : restoreCursor ( ); break; 385 case TY_ESC___('8' ) : restoreCursor ( ); break;
391 386
392 case TY_ESC___('=' ) : setMode (MODE_AppKeyPad); break; 387 case TY_ESC___('=' ) : setMode (MODE_AppKeyPad); break;
393 case TY_ESC___('>' ) : resetMode (MODE_AppKeyPad); break; 388 case TY_ESC___('>' ) : resetMode (MODE_AppKeyPad); break;
394 case TY_ESC___('<' ) : setMode (MODE_Ansi ); break; //VT100 389 case TY_ESC___('<' ) : setMode (MODE_Ansi ); break; //VT100
395 390
396 case TY_ESC_CS('(', '0') : setCharset (0, '0'); break; //VT100 391 case TY_ESC_CS('(', '0') : setCharset (0, '0'); break; //VT100
397 case TY_ESC_CS('(', 'A') : setCharset (0, 'A'); break; //VT100 392 case TY_ESC_CS('(', 'A') : setCharset (0, 'A'); break; //VT100
398 case TY_ESC_CS('(', 'B') : setCharset (0, 'B'); break; //VT100 393 case TY_ESC_CS('(', 'B') : setCharset (0, 'B'); break; //VT100
399 394
400 case TY_ESC_CS(')', '0') : setCharset (1, '0'); break; //VT100 395 case TY_ESC_CS(')', '0') : setCharset (1, '0'); break; //VT100
401 case TY_ESC_CS(')', 'A') : setCharset (1, 'A'); break; //VT100 396 case TY_ESC_CS(')', 'A') : setCharset (1, 'A'); break; //VT100
402 case TY_ESC_CS(')', 'B') : setCharset (1, 'B'); break; //VT100 397 case TY_ESC_CS(')', 'B') : setCharset (1, 'B'); break; //VT100
403 398
404 case TY_ESC_CS('*', '0') : setCharset (2, '0'); break; //VT100 399 case TY_ESC_CS('*', '0') : setCharset (2, '0'); break; //VT100
405 case TY_ESC_CS('*', 'A') : setCharset (2, 'A'); break; //VT100 400 case TY_ESC_CS('*', 'A') : setCharset (2, 'A'); break; //VT100
406 case TY_ESC_CS('*', 'B') : setCharset (2, 'B'); break; //VT100 401 case TY_ESC_CS('*', 'B') : setCharset (2, 'B'); break; //VT100
407 402
408 case TY_ESC_CS('+', '0') : setCharset (3, '0'); break; //VT100 403 case TY_ESC_CS('+', '0') : setCharset (3, '0'); break; //VT100
409 case TY_ESC_CS('+', 'A') : setCharset (3, 'A'); break; //VT100 404 case TY_ESC_CS('+', 'A') : setCharset (3, 'A'); break; //VT100
410 case TY_ESC_CS('+', 'B') : setCharset (3, 'B'); break; //VT100 405 case TY_ESC_CS('+', 'B') : setCharset (3, 'B'); break; //VT100
411 406
412 case TY_ESC_CS('%', 'G') : setCodec (1 ); break; //LINUX 407 case TY_ESC_CS('%', 'G') : setCodec (1 ); break; //LINUX
413 case TY_ESC_CS('%', '@') : setCodec (0 ); break; //LINUX 408 case TY_ESC_CS('%', '@') : setCodec (0 ); break; //LINUX
414 409
415 case TY_ESC_DE('3' ) : /* IGNORED: double high, top half */ break; 410 case TY_ESC_DE('3' ) : /* IGNORED: double high, top half */ break;
416 case TY_ESC_DE('4' ) : /* IGNORED: double high, bottom half */ break; 411 case TY_ESC_DE('4' ) : /* IGNORED: double high, bottom half */ break;
417 case TY_ESC_DE('5' ) : /* IGNORED: single width, single high*/ break; 412 case TY_ESC_DE('5' ) : /* IGNORED: single width, single high*/ break;
418 case TY_ESC_DE('6' ) : /* IGNORED: double width, single high*/ break; 413 case TY_ESC_DE('6' ) : /* IGNORED: double width, single high*/ break;
419 case TY_ESC_DE('8' ) : scr->helpAlign ( ); break; 414 case TY_ESC_DE('8' ) : scr->helpAlign ( ); break;
420 415
421 case TY_CSI_PS('K', 0) : scr->clearToEndOfLine ( ); break; 416 case TY_CSI_PS('K', 0) : scr->clearToEndOfLine ( ); break;
422 case TY_CSI_PS('K', 1) : scr->clearToBeginOfLine ( ); break; 417 case TY_CSI_PS('K', 1) : scr->clearToBeginOfLine ( ); break;
423 case TY_CSI_PS('K', 2) : scr->clearEntireLine ( ); break; 418 case TY_CSI_PS('K', 2) : scr->clearEntireLine ( ); break;
424 case TY_CSI_PS('J', 0) : scr->clearToEndOfScreen ( ); break; 419 case TY_CSI_PS('J', 0) : scr->clearToEndOfScreen ( ); break;
425 case TY_CSI_PS('J', 1) : scr->clearToBeginOfScreen ( ); break; 420 case TY_CSI_PS('J', 1) : scr->clearToBeginOfScreen ( ); break;
426 case TY_CSI_PS('J', 2) : scr->clearEntireScreen ( ); break; 421 case TY_CSI_PS('J', 2) : scr->clearEntireScreen ( ); break;
427 case TY_CSI_PS('g', 0) : scr->changeTabStop (FALSE ); break; //VT100 422 case TY_CSI_PS('g', 0) : scr->changeTabStop (FALSE ); break; //VT100
428 case TY_CSI_PS('g', 3) : scr->clearTabStops ( ); break; //VT100 423 case TY_CSI_PS('g', 3) : scr->clearTabStops ( ); break; //VT100
429 case TY_CSI_PS('h', 4) : scr-> setMode (MODE_Insert ); break; 424 case TY_CSI_PS('h', 4) : scr-> setMode (MODE_Insert ); break;
430 case TY_CSI_PS('h', 20) : setMode (MODE_NewLine ); break; 425 case TY_CSI_PS('h', 20) : setMode (MODE_NewLine ); break;
431 case TY_CSI_PS('i', 0) : /* IGNORE: attached printer */ break; //VT100 426 case TY_CSI_PS('i', 0) : /* IGNORE: attached printer */ break; //VT100
432 case TY_CSI_PS('l', 4) : scr-> resetMode (MODE_Insert ); break; 427 case TY_CSI_PS('l', 4) : scr-> resetMode (MODE_Insert ); break;
433 case TY_CSI_PS('l', 20) : resetMode (MODE_NewLine ); break; 428 case TY_CSI_PS('l', 20) : resetMode (MODE_NewLine ); break;
434 429
435 case TY_CSI_PS('m', 0) : scr->setDefaultRendition ( ); break; 430 case TY_CSI_PS('m', 0) : scr->setDefaultRendition ( ); break;
436 case TY_CSI_PS('m', 1) : scr-> setRendition (RE_BOLD ); break; //VT100 431 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 432 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 433 case TY_CSI_PS('m', 5) : scr-> setRendition (RE_BLINK ); break; //VT100
439 case TY_CSI_PS('m', 7) : scr-> setRendition (RE_REVERSE ); break; 434 case TY_CSI_PS('m', 7) : scr-> setRendition (RE_REVERSE ); break;
440 case TY_CSI_PS('m', 10) : /* IGNORED: mapping related */ break; //LINUX 435 case TY_CSI_PS('m', 10) : /* IGNORED: mapping related */ break; //LINUX
441 case TY_CSI_PS('m', 11) : /* IGNORED: mapping related */ break; //LINUX 436 case TY_CSI_PS('m', 11) : /* IGNORED: mapping related */ break; //LINUX
442 case TY_CSI_PS('m', 12) : /* IGNORED: mapping related */ break; //LINUX 437 case TY_CSI_PS('m', 12) : /* IGNORED: mapping related */ break; //LINUX
443 case TY_CSI_PS('m', 22) : scr->resetRendition (RE_BOLD ); break; 438 case TY_CSI_PS('m', 22) : scr->resetRendition (RE_BOLD ); break;
444 case TY_CSI_PS('m', 24) : scr->resetRendition (RE_UNDERLINE); break; 439 case TY_CSI_PS('m', 24) : scr->resetRendition (RE_UNDERLINE); break;
445 case TY_CSI_PS('m', 25) : scr->resetRendition (RE_BLINK ); break; 440 case TY_CSI_PS('m', 25) : scr->resetRendition (RE_BLINK ); break;
446 case TY_CSI_PS('m', 27) : scr->resetRendition (RE_REVERSE ); break; 441 case TY_CSI_PS('m', 27) : scr->resetRendition (RE_REVERSE ); break;
447 442
448 case TY_CSI_PS('m', 30) : scr->setForeColor ( 0); break; 443 case TY_CSI_PS('m', 30) : scr->setForeColor ( 0); break;
449 case TY_CSI_PS('m', 31) : scr->setForeColor ( 1); break; 444 case TY_CSI_PS('m', 31) : scr->setForeColor ( 1); break;
450 case TY_CSI_PS('m', 32) : scr->setForeColor ( 2); break; 445 case TY_CSI_PS('m', 32) : scr->setForeColor ( 2); break;
451 case TY_CSI_PS('m', 33) : scr->setForeColor ( 3); break; 446 case TY_CSI_PS('m', 33) : scr->setForeColor ( 3); break;
452 case TY_CSI_PS('m', 34) : scr->setForeColor ( 4); break; 447 case TY_CSI_PS('m', 34) : scr->setForeColor ( 4); break;
453 case TY_CSI_PS('m', 35) : scr->setForeColor ( 5); break; 448 case TY_CSI_PS('m', 35) : scr->setForeColor ( 5); break;
454 case TY_CSI_PS('m', 36) : scr->setForeColor ( 6); break; 449 case TY_CSI_PS('m', 36) : scr->setForeColor ( 6); break;
455 case TY_CSI_PS('m', 37) : scr->setForeColor ( 7); break; 450 case TY_CSI_PS('m', 37) : scr->setForeColor ( 7); break;
456 case TY_CSI_PS('m', 39) : scr->setForeColorToDefault( ); break; 451 case TY_CSI_PS('m', 39) : scr->setForeColorToDefault( ); break;
457 452
458 case TY_CSI_PS('m', 40) : scr->setBackColor ( 0); break; 453 case TY_CSI_PS('m', 40) : scr->setBackColor ( 0); break;
459 case TY_CSI_PS('m', 41) : scr->setBackColor ( 1); break; 454 case TY_CSI_PS('m', 41) : scr->setBackColor ( 1); break;
460 case TY_CSI_PS('m', 42) : scr->setBackColor ( 2); break; 455 case TY_CSI_PS('m', 42) : scr->setBackColor ( 2); break;
461 case TY_CSI_PS('m', 43) : scr->setBackColor ( 3); break; 456 case TY_CSI_PS('m', 43) : scr->setBackColor ( 3); break;
462 case TY_CSI_PS('m', 44) : scr->setBackColor ( 4); break; 457 case TY_CSI_PS('m', 44) : scr->setBackColor ( 4); break;
463 case TY_CSI_PS('m', 45) : scr->setBackColor ( 5); break; 458 case TY_CSI_PS('m', 45) : scr->setBackColor ( 5); break;
464 case TY_CSI_PS('m', 46) : scr->setBackColor ( 6); break; 459 case TY_CSI_PS('m', 46) : scr->setBackColor ( 6); break;
465 case TY_CSI_PS('m', 47) : scr->setBackColor ( 7); break; 460 case TY_CSI_PS('m', 47) : scr->setBackColor ( 7); break;
466 case TY_CSI_PS('m', 49) : scr->setBackColorToDefault( ); break; 461 case TY_CSI_PS('m', 49) : scr->setBackColorToDefault( ); break;
467 462
468 case TY_CSI_PS('m', 90) : scr->setForeColor ( 8); break; 463 case TY_CSI_PS('m', 90) : scr->setForeColor ( 8); break;
469 case TY_CSI_PS('m', 91) : scr->setForeColor ( 9); break; 464 case TY_CSI_PS('m', 91) : scr->setForeColor ( 9); break;
470 case TY_CSI_PS('m', 92) : scr->setForeColor ( 10); break; 465 case TY_CSI_PS('m', 92) : scr->setForeColor ( 10); break;
471 case TY_CSI_PS('m', 93) : scr->setForeColor ( 11); break; 466 case TY_CSI_PS('m', 93) : scr->setForeColor ( 11); break;
472 case TY_CSI_PS('m', 94) : scr->setForeColor ( 12); break; 467 case TY_CSI_PS('m', 94) : scr->setForeColor ( 12); break;
473 case TY_CSI_PS('m', 95) : scr->setForeColor ( 13); break; 468 case TY_CSI_PS('m', 95) : scr->setForeColor ( 13); break;
474 case TY_CSI_PS('m', 96) : scr->setForeColor ( 14); break; 469 case TY_CSI_PS('m', 96) : scr->setForeColor ( 14); break;
475 case TY_CSI_PS('m', 97) : scr->setForeColor ( 15); break; 470 case TY_CSI_PS('m', 97) : scr->setForeColor ( 15); break;
476 471
477 case TY_CSI_PS('m', 100) : scr->setBackColor ( 8); break; 472 case TY_CSI_PS('m', 100) : scr->setBackColor ( 8); break;
478 case TY_CSI_PS('m', 101) : scr->setBackColor ( 9); break; 473 case TY_CSI_PS('m', 101) : scr->setBackColor ( 9); break;
479 case TY_CSI_PS('m', 102) : scr->setBackColor ( 10); break; 474 case TY_CSI_PS('m', 102) : scr->setBackColor ( 10); break;
480 case TY_CSI_PS('m', 103) : scr->setBackColor ( 11); break; 475 case TY_CSI_PS('m', 103) : scr->setBackColor ( 11); break;
481 case TY_CSI_PS('m', 104) : scr->setBackColor ( 12); break; 476 case TY_CSI_PS('m', 104) : scr->setBackColor ( 12); break;
482 case TY_CSI_PS('m', 105) : scr->setBackColor ( 13); break; 477 case TY_CSI_PS('m', 105) : scr->setBackColor ( 13); break;
483 case TY_CSI_PS('m', 106) : scr->setBackColor ( 14); break; 478 case TY_CSI_PS('m', 106) : scr->setBackColor ( 14); break;
484 case TY_CSI_PS('m', 107) : scr->setBackColor ( 15); break; 479 case TY_CSI_PS('m', 107) : scr->setBackColor ( 15); break;
485 480
486 case TY_CSI_PS('n', 5) : reportStatus ( ); break; 481 case TY_CSI_PS('n', 5) : reportStatus ( ); break;
487 case TY_CSI_PS('n', 6) : reportCursorPosition ( ); break; 482 case TY_CSI_PS('n', 6) : reportCursorPosition ( ); break;
488 case TY_CSI_PS('q', 0) : /* IGNORED: LEDs off */ break; //VT100 483 case TY_CSI_PS('q', 0) : /* IGNORED: LEDs off */ break; //VT100
489 case TY_CSI_PS('q', 1) : /* IGNORED: LED1 on */ break; //VT100 484 case TY_CSI_PS('q', 1) : /* IGNORED: LED1 on */ break; //VT100
490 case TY_CSI_PS('q', 2) : /* IGNORED: LED2 on */ break; //VT100 485 case TY_CSI_PS('q', 2) : /* IGNORED: LED2 on */ break; //VT100
491 case TY_CSI_PS('q', 3) : /* IGNORED: LED3 on */ break; //VT100 486 case TY_CSI_PS('q', 3) : /* IGNORED: LED3 on */ break; //VT100
492 case TY_CSI_PS('q', 4) : /* IGNORED: LED4 on */ break; //VT100 487 case TY_CSI_PS('q', 4) : /* IGNORED: LED4 on */ break; //VT100
493 case TY_CSI_PS('x', 0) : reportTerminalParms ( 2); break; //VT100 488 case TY_CSI_PS('x', 0) : reportTerminalParms ( 2); break; //VT100
494 case TY_CSI_PS('x', 1) : reportTerminalParms ( 3); break; //VT100 489 case TY_CSI_PS('x', 1) : reportTerminalParms ( 3); break; //VT100
495 490
496 case TY_CSI_PN('@' ) : scr->insertChars (p ); break; 491 case TY_CSI_PN('@' ) : scr->insertChars (p ); break;
497 case TY_CSI_PN('A' ) : scr->cursorUp (p ); break; //VT100 492 case TY_CSI_PN('A' ) : scr->cursorUp (p ); break; //VT100
498 case TY_CSI_PN('B' ) : scr->cursorDown (p ); break; //VT100 493 case TY_CSI_PN('B' ) : scr->cursorDown (p ); break; //VT100
499 case TY_CSI_PN('C' ) : scr->cursorRight (p ); break; //VT100 494 case TY_CSI_PN('C' ) : scr->cursorRight (p ); break; //VT100
500 case TY_CSI_PN('D' ) : scr->cursorLeft (p ); break; //VT100 495 case TY_CSI_PN('D' ) : scr->cursorLeft (p ); break; //VT100
501 case TY_CSI_PN('G' ) : scr->setCursorX (p ); break; //LINUX 496 case TY_CSI_PN('G' ) : scr->setCursorX (p ); break; //LINUX
502 case TY_CSI_PN('H' ) : scr->setCursorYX (p, q); break; //VT100 497 case TY_CSI_PN('H' ) : scr->setCursorYX (p, q); break; //VT100
503 case TY_CSI_PN('L' ) : scr->insertLines (p ); break; 498 case TY_CSI_PN('L' ) : scr->insertLines (p ); break;
504 case TY_CSI_PN('M' ) : scr->deleteLines (p ); break; 499 case TY_CSI_PN('M' ) : scr->deleteLines (p ); break;
505 case TY_CSI_PN('P' ) : scr->deleteChars (p ); break; 500 case TY_CSI_PN('P' ) : scr->deleteChars (p ); break;
506 case TY_CSI_PN('X' ) : scr->eraseChars (p ); break; 501 case TY_CSI_PN('X' ) : scr->eraseChars (p ); break;
507 case TY_CSI_PN('c' ) : reportTerminalType ( ); break; //VT100 502 case TY_CSI_PN('c' ) : reportTerminalType ( ); break; //VT100
508 case TY_CSI_PN('d' ) : scr->setCursorY (p ); break; //LINUX 503 case TY_CSI_PN('d' ) : scr->setCursorY (p ); break; //LINUX
509 case TY_CSI_PN('f' ) : scr->setCursorYX (p, q); break; //VT100 504 case TY_CSI_PN('f' ) : scr->setCursorYX (p, q); break; //VT100
510 case TY_CSI_PN('r' ) : scr->setMargins (p, q); break; //VT100 505 case TY_CSI_PN('r' ) : scr->setMargins (p, q); break; //VT100
511 case TY_CSI_PN('y' ) : /* IGNORED: Confidence test */ break; //VT100 506 case TY_CSI_PN('y' ) : /* IGNORED: Confidence test */ break; //VT100
512 507
513 case TY_CSI_PR('h', 1) : setMode (MODE_AppCuKeys); break; //VT100 508 case TY_CSI_PR('h', 1) : setMode (MODE_AppCuKeys); break; //VT100
514 case TY_CSI_PR('l', 1) : resetMode (MODE_AppCuKeys); break; //VT100 509 case TY_CSI_PR('l', 1) : resetMode (MODE_AppCuKeys); break; //VT100
515 case TY_CSI_PR('s', 1) : saveMode (MODE_AppCuKeys); break; //FIXME 510 case TY_CSI_PR('s', 1) : saveMode (MODE_AppCuKeys); break; //FIXME
516 case TY_CSI_PR('r', 1) : restoreMode (MODE_AppCuKeys); break; //FIXME 511 case TY_CSI_PR('r', 1) : restoreMode (MODE_AppCuKeys); break; //FIXME
517 512
518 case TY_CSI_PR('l', 2) : resetMode (MODE_Ansi ); break; //VT100 513 case TY_CSI_PR('l', 2) : resetMode (MODE_Ansi ); break; //VT100
519 514
520 case TY_CSI_PR('h', 3) : setColumns ( 132); break; //VT100 515 case TY_CSI_PR('h', 3) : setColumns ( 132); break; //VT100
521 case TY_CSI_PR('l', 3) : setColumns ( 80); break; //VT100 516 case TY_CSI_PR('l', 3) : setColumns ( 80); break; //VT100
522 517
523 case TY_CSI_PR('h', 4) : /* IGNORED: soft scrolling */ break; //VT100 518 case TY_CSI_PR('h', 4) : /* IGNORED: soft scrolling */ break; //VT100
524 case TY_CSI_PR('l', 4) : /* IGNORED: soft scrolling */ break; //VT100 519 case TY_CSI_PR('l', 4) : /* IGNORED: soft scrolling */ break; //VT100
525 520
526 case TY_CSI_PR('h', 5) : scr-> setMode (MODE_Screen ); break; //VT100 521 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 522 case TY_CSI_PR('l', 5) : scr-> resetMode (MODE_Screen ); break; //VT100
528 523
529 case TY_CSI_PR('h', 6) : scr-> setMode (MODE_Origin ); break; //VT100 524 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 525 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 526 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 527 case TY_CSI_PR('r', 6) : scr->restoreMode (MODE_Origin ); break; //FIXME
533 528
534 case TY_CSI_PR('h', 7) : scr-> setMode (MODE_Wrap ); break; //VT100 529 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 530 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 531 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 532 case TY_CSI_PR('r', 7) : scr->restoreMode (MODE_Wrap ); break; //FIXME
538 533
539 case TY_CSI_PR('h', 8) : /* IGNORED: autorepeat on */ break; //VT100 534 case TY_CSI_PR('h', 8) : /* IGNORED: autorepeat on */ break; //VT100
540 case TY_CSI_PR('l', 8) : /* IGNORED: autorepeat off */ break; //VT100 535 case TY_CSI_PR('l', 8) : /* IGNORED: autorepeat off */ break; //VT100
541 536
542 case TY_CSI_PR('h', 9) : /* IGNORED: interlace */ break; //VT100 537 case TY_CSI_PR('h', 9) : /* IGNORED: interlace */ break; //VT100
543 case TY_CSI_PR('l', 9) : /* IGNORED: interlace */ break; //VT100 538 case TY_CSI_PR('l', 9) : /* IGNORED: interlace */ break; //VT100
544 539
545 case TY_CSI_PR('h', 25) : setMode (MODE_Cursor ); break; //VT100 540 case TY_CSI_PR('h', 25) : setMode (MODE_Cursor ); break; //VT100
546 case TY_CSI_PR('l', 25) : resetMode (MODE_Cursor ); break; //VT100 541 case TY_CSI_PR('l', 25) : resetMode (MODE_Cursor ); break; //VT100
547 542
548 case TY_CSI_PR('h', 41) : /* IGNORED: obsolete more(1) fix */ break; //XTERM 543 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 544 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 545 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 546 case TY_CSI_PR('r', 41) : /* IGNORED: obsolete more(1) fix */ break; //XTERM
552 547
553 case TY_CSI_PR('h', 47) : setMode (MODE_AppScreen); break; //VT100 548 case TY_CSI_PR('h', 47) : setMode (MODE_AppScreen); break; //VT100
554 case TY_CSI_PR('l', 47) : resetMode (MODE_AppScreen); break; //VT100 549 case TY_CSI_PR('l', 47) : resetMode (MODE_AppScreen); break; //VT100
555 550
556 case TY_CSI_PR('h', 1000) : setMode (MODE_Mouse1000); break; //XTERM 551 case TY_CSI_PR('h', 1000) : setMode (MODE_Mouse1000); break; //XTERM
557 case TY_CSI_PR('l', 1000) : resetMode (MODE_Mouse1000); break; //XTERM 552 case TY_CSI_PR('l', 1000) : resetMode (MODE_Mouse1000); break; //XTERM
558 case TY_CSI_PR('s', 1000) : saveMode (MODE_Mouse1000); break; //XTERM 553 case TY_CSI_PR('s', 1000) : saveMode (MODE_Mouse1000); break; //XTERM
559 case TY_CSI_PR('r', 1000) : restoreMode (MODE_Mouse1000); break; //XTERM 554 case TY_CSI_PR('r', 1000) : restoreMode (MODE_Mouse1000); break; //XTERM
560 555
561 case TY_CSI_PR('h', 1001) : /* IGNORED: hilite mouse tracking */ break; //XTERM 556 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 557 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 558 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 559 case TY_CSI_PR('r', 1001) : /* IGNORED: hilite mouse tracking */ break; //XTERM
565 560
566 case TY_CSI_PR('h', 1047) : setMode (MODE_AppScreen); break; //XTERM 561 case TY_CSI_PR('h', 1047) : setMode (MODE_AppScreen); break; //XTERM
567 case TY_CSI_PR('l', 1047) : resetMode (MODE_AppScreen); break; //XTERM 562 case TY_CSI_PR('l', 1047) : resetMode (MODE_AppScreen); break; //XTERM
568 563
569 //FIXME: Unitoken: save translations 564 //FIXME: Unitoken: save translations
570 case TY_CSI_PR('h', 1048) : saveCursor ( ); break; //XTERM 565 case TY_CSI_PR('h', 1048) : saveCursor ( ); break; //XTERM
571 case TY_CSI_PR('l', 1048) : restoreCursor ( ); break; //XTERM 566 case TY_CSI_PR('l', 1048) : restoreCursor ( ); break; //XTERM
572 567
573 //FIXME: every once new sequences like this pop up in xterm. 568 //FIXME: every once new sequences like this pop up in xterm.
574 // Here's a guess of what they could mean. 569 // Here's a guess of what they could mean.
575 case TY_CSI_PR('h', 1049) : setMode (MODE_AppScreen); break; //XTERM 570 case TY_CSI_PR('h', 1049) : setMode (MODE_AppScreen); break; //XTERM
576 case TY_CSI_PR('l', 1049) : resetMode (MODE_AppScreen); break; //XTERM 571 case TY_CSI_PR('l', 1049) : resetMode (MODE_AppScreen); break; //XTERM
577 572
578 //FIXME: when changing between vt52 and ansi mode evtl do some resetting. 573 //FIXME: when changing between vt52 and ansi mode evtl do some resetting.
579 case TY_VT52__('A' ) : scr->cursorUp ( 1); break; //VT52 574 case TY_VT52__('A' ) : scr->cursorUp ( 1); break; //VT52
580 case TY_VT52__('B' ) : scr->cursorDown ( 1); break; //VT52 575 case TY_VT52__('B' ) : scr->cursorDown ( 1); break; //VT52
581 case TY_VT52__('C' ) : scr->cursorRight ( 1); break; //VT52 576 case TY_VT52__('C' ) : scr->cursorRight ( 1); break; //VT52
582 case TY_VT52__('D' ) : scr->cursorLeft ( 1); break; //VT52 577 case TY_VT52__('D' ) : scr->cursorLeft ( 1); break; //VT52
583 578
584 case TY_VT52__('F' ) : setAndUseCharset (0, '0'); break; //VT52 579 case TY_VT52__('F' ) : setAndUseCharset (0, '0'); break; //VT52
585 case TY_VT52__('G' ) : setAndUseCharset (0, 'B'); break; //VT52 580 case TY_VT52__('G' ) : setAndUseCharset (0, 'B'); break; //VT52
586 581
587 case TY_VT52__('H' ) : scr->setCursorYX (1,1 ); break; //VT52 582 case TY_VT52__('H' ) : scr->setCursorYX (1,1 ); break; //VT52
588 case TY_VT52__('I' ) : scr->reverseIndex ( ); break; //VT52 583 case TY_VT52__('I' ) : scr->reverseIndex ( ); break; //VT52
589 case TY_VT52__('J' ) : scr->clearToEndOfScreen ( ); break; //VT52 584 case TY_VT52__('J' ) : scr->clearToEndOfScreen ( ); break; //VT52
590 case TY_VT52__('K' ) : scr->clearToEndOfLine ( ); break; //VT52 585 case TY_VT52__('K' ) : scr->clearToEndOfLine ( ); break; //VT52
591 case TY_VT52__('Y' ) : scr->setCursorYX (p-31,q-31 ); break; //VT52 586 case TY_VT52__('Y' ) : scr->setCursorYX (p-31,q-31 ); break; //VT52
592 case TY_VT52__('Z' ) : reportTerminalType ( ); break; //VT52 587 case TY_VT52__('Z' ) : reportTerminalType ( ); break; //VT52
593 case TY_VT52__('<' ) : setMode (MODE_Ansi ); break; //VT52 588 case TY_VT52__('<' ) : setMode (MODE_Ansi ); break; //VT52
594 case TY_VT52__('=' ) : setMode (MODE_AppKeyPad); break; //VT52 589 case TY_VT52__('=' ) : setMode (MODE_AppKeyPad); break; //VT52
595 case TY_VT52__('>' ) : resetMode (MODE_AppKeyPad); break; //VT52 590 case TY_VT52__('>' ) : resetMode (MODE_AppKeyPad); break; //VT52
596 591
597 default : ReportErrorToken(); break; 592 default : ReportErrorToken(); break;
598 }; 593 };
599} 594}
600 595
601/* ------------------------------------------------------------------------- */ 596/* ------------------------------------------------------------------------- */
602/* */ 597/* */
603/* Terminal to Host protocol */ 598/* Terminal to Host protocol */
604/* */ 599/* */
605/* ------------------------------------------------------------------------- */ 600/* ------------------------------------------------------------------------- */
606 601
607/* 602/*
608 Outgoing bytes originate from several sources: 603 Outgoing bytes originate from several sources:
609 604
610 - Replies to Enquieries. 605 - Replies to Enquieries.
611 - Mouse Events 606 - Mouse Events
612 - Keyboard Events 607 - Keyboard Events
613*/ 608*/
614 609
615/*! 610/*!
616*/ 611*/
617 612
618void Vt102Emulation::sendString(const char* s) 613void Vt102Emulation::sendString(const char* s)
619{ 614{
620 QByteArray tmp; 615 QByteArray tmp;
621 tmp.setRawData( s, strlen( s )); 616 tmp.setRawData( s, strlen( s ));
622 emit sndBlock( tmp); 617 emit sndBlock( tmp);
623} 618}
624 619
625void Vt102Emulation::sendString(const QByteArray& s) 620void Vt102Emulation::sendString(const QByteArray& s)
626{ 621{
627 emit sndBlock( s ); 622 emit sndBlock( s );
628} 623}
629 624
630// Replies ----------------------------------------------------------------- -- 625// Replies ----------------------------------------------------------------- --
631 626
632// This section copes with replies send as response to an enquiery control code. 627// This section copes with replies send as response to an enquiery control code.
633 628
634/*! 629/*!
635*/ 630*/
636 631
637void Vt102Emulation::reportCursorPosition() 632void Vt102Emulation::reportCursorPosition()
638{ char tmp[20]; 633{ char tmp[20];
639 sprintf(tmp,"\033[%d;%dR",scr->getCursorY()+1,scr->getCursorX()+1); 634 sprintf(tmp,"\033[%d;%dR",scr->getCursorY()+1,scr->getCursorX()+1);
640 sendString(tmp); 635 sendString(tmp);
641} 636}
642 637
643/* 638/*
644 What follows here is rather obsolete and faked stuff. 639 What follows here is rather obsolete and faked stuff.
645 The correspondent enquieries are neverthenless issued. 640 The correspondent enquieries are neverthenless issued.
646*/ 641*/
647 642
648/*! 643/*!
649*/ 644*/
650 645
651void Vt102Emulation::reportTerminalType() 646void Vt102Emulation::reportTerminalType()
652{ 647{
653//FIXME: should change? 648//FIXME: should change?
654 if (getMode(MODE_Ansi)) 649 if (getMode(MODE_Ansi))
655// sendString("\033[?1;2c"); // I'm a VT100 with AP0 //FIXME: send only in response to ^[[0c 650// 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 651 sendString("\033[>0;115;0c"); // I'm a VT220 //FIXME: send only in response to ^[[>c
657 else 652 else
658 sendString("\033/Z"); // I'm a VT52 653 sendString("\033/Z"); // I'm a VT52
659} 654}
660 655
661void Vt102Emulation::reportTerminalParms(int p) 656void Vt102Emulation::reportTerminalParms(int p)
662// DECREPTPARM 657// DECREPTPARM
663{ char tmp[100]; 658{ char tmp[100];
664 sprintf(tmp,"\033[%d;1;1;112;112;1;0x",p); // not really true. 659 sprintf(tmp,"\033[%d;1;1;112;112;1;0x",p); // not really true.
665 sendString(tmp); 660 sendString(tmp);
666} 661}
667 662
668/*! 663/*!
669*/ 664*/
670 665
671void Vt102Emulation::reportStatus() 666void Vt102Emulation::reportStatus()
672{ 667{
673 sendString("\033[0n"); //VT100. Device status report. 0 = Ready. 668 sendString("\033[0n"); //VT100. Device status report. 0 = Ready.
674} 669}
675 670
676/*! 671/*!
677*/ 672*/
678 673
679#define ANSWER_BACK "" // This is really obsolete VT100 stuff. 674#define ANSWER_BACK "" // This is really obsolete VT100 stuff.
680 675
681void Vt102Emulation::reportAnswerBack() 676void Vt102Emulation::reportAnswerBack()
682{ 677{
683 sendString(ANSWER_BACK); 678 sendString(ANSWER_BACK);
684} 679}
685 680
686// Mouse Handling ---------------------------------------------------------- -- 681// Mouse Handling ---------------------------------------------------------- --
687 682
688/*! 683/*!
689 Mouse clicks are possibly reported to the client 684 Mouse clicks are possibly reported to the client
690 application if it has issued interest in them. 685 application if it has issued interest in them.
691 They are normally consumed by the widget for copy 686 They are normally consumed by the widget for copy
692 and paste, but may be propagated from the widget 687 and paste, but may be propagated from the widget
693 when gui->setMouseMarks is set via setMode(MODE_Mouse1000). 688 when gui->setMouseMarks is set via setMode(MODE_Mouse1000).
694 689
695 `x',`y' are 1-based. 690 `x',`y' are 1-based.
696 `ev' (event) indicates the button pressed (0-2) 691 `ev' (event) indicates the button pressed (0-2)
697 or a general mouse release (3). 692 or a general mouse release (3).
698*/ 693*/
699 694
700void Vt102Emulation::onMouse( int cb, int cx, int cy ) 695void Vt102Emulation::onMouse( int cb, int cx, int cy )
701{ char tmp[20]; 696{ char tmp[20];
702 if (!connected) return; 697 if (!connected) return;
703 sprintf(tmp,"\033[M%c%c%c",cb+040,cx+040,cy+040); 698 sprintf(tmp,"\033[M%c%c%c",cb+040,cx+040,cy+040);
704 sendString(tmp); 699 sendString(tmp);
705} 700}
706 701
707// Keyboard Handling ------------------------------------------------------- -- 702// Keyboard Handling ------------------------------------------------------- --
708 703
709#define encodeMode(M,B) BITS(B,getMode(M)) 704#define encodeMode(M,B) BITS(B,getMode(M))
710#define encodeStat(M,B) BITS(B,((ev->state() & (M)) == (M))) 705#define encodeStat(M,B) BITS(B,((ev->state() & (M)) == (M)))
711 706
712/* 707/*
713 Keyboard event handling has been simplified somewhat by pushing 708 Keyboard event handling has been simplified somewhat by pushing
714 the complications towards a configuration file [see KeyTrans class]. 709 the complications towards a configuration file [see KeyTrans class].
715*/ 710*/
716 711
717void Vt102Emulation::onKeyPress( QKeyEvent* ev ) 712void Vt102Emulation::onKeyPress( QKeyEvent* ev )
718{ 713{
719 if (!connected) return; // someone else gets the keys 714 if (!connected) return; // someone else gets the keys
720 715
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); 716//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 717
723 // revert to non-history when typing 718 // revert to non-history when typing
724 if (scr->getHistCursor() != scr->getHistLines()); 719 if (scr->getHistCursor() != scr->getHistLines());
725 scr->setHistCursor(scr->getHistLines()); 720 scr->setHistCursor(scr->getHistLines());
726 721
727 // lookup in keyboard translation table ... 722 // lookup in keyboard translation table ...
728 int cmd; const char* txt; int len; 723 int cmd; const char* txt; int len;
729 if (keytrans->findEntry(ev->key(), encodeMode(MODE_NewLine , BITS_NewLine ) + // OLD, 724 if (keytrans->findEntry(ev->key(), encodeMode(MODE_NewLine , BITS_NewLine ) + // OLD,
730 encodeMode(MODE_Ansi , BITS_Ansi ) + // OBSOLETE, 725 encodeMode(MODE_Ansi , BITS_Ansi ) + // OBSOLETE,
731 encodeMode(MODE_AppCuKeys, BITS_AppCuKeys ) + // VT100 stuff 726 encodeMode(MODE_AppCuKeys, BITS_AppCuKeys ) + // VT100 stuff
732 encodeStat(ControlButton , BITS_Control ) + 727 encodeStat(ControlButton , BITS_Control ) +
733 encodeStat(ShiftButton , BITS_Shift ) + 728 encodeStat(ShiftButton , BITS_Shift ) +
734 encodeStat(AltButton , BITS_Alt ), 729 encodeStat(AltButton , BITS_Alt ),
735 &cmd, &txt, &len )) 730 &cmd, &txt, &len ))
736//printf("cmd: %d, %s, %d\n",cmd,txt,len); 731//printf("cmd: %d, %s, %d\n",cmd,txt,len);
737 { 732 {
738 switch(cmd) // ... and execute if found. 733 switch(cmd) // ... and execute if found.
739 { 734 {
740 case CMD_emitSelection : gui->insertSelection(); return; 735 case CMD_emitSelection : gui->insertSelection(); return;
741 case CMD_scrollPageUp : gui->scroll(-gui->lines()/2); return; 736 case CMD_scrollPageUp : gui->scroll(-gui->lines()/2); return;
742 case CMD_scrollPageDown : gui->scroll(+gui->lines()/2); return; 737 case CMD_scrollPageDown : gui->scroll(+gui->lines()/2); return;
743 case CMD_scrollLineUp : gui->scroll(-1 ); return; 738 case CMD_scrollLineUp : gui->scroll(-1 ); return;
744 case CMD_scrollLineDown : gui->scroll(+1 ); return; 739 case CMD_scrollLineDown : gui->scroll(+1 ); return;
745 case CMD_send : sendString( txt ); return; 740 case CMD_send : sendString( txt ); return;
746 case CMD_prevSession : emit prevSession(); return; 741 case CMD_prevSession : emit prevSession(); return;
747 case CMD_nextSession : emit nextSession(); return; 742 case CMD_nextSession : emit nextSession(); return;
748 } 743 }
749 } 744 }
750 // fall back handling 745 // fall back handling
751 if (!ev->text().isEmpty()) 746 if (!ev->text().isEmpty())
752 { 747 {
753 if (ev->state() & AltButton) sendString("\033"); // ESC, this is the ALT prefix 748 if (ev->state() & AltButton) sendString("\033"); // ESC, this is the ALT prefix
754 /// very hacky 749 /// very hacky
755 if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='A')) sendString("\01"); 750 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"); 751 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"); 752 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"); 753 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"); 754 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"); 755 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"); 756 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"); 757 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"); 758 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"); 759 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"); 760 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"); 761 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"); 762 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"); 763 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"); 764 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"); 765 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"); 766 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"); 767 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"); 768 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"); 769 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"); 770 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"); 771 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"); 772 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"); 773 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"); 774 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"); 775 else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='Z')) sendString("\032");
781 else 776 else
782 { 777 {
783 QCString s = codec->fromUnicode(ev->text()); // encode for application 778 QCString s = codec->fromUnicode(ev->text()); // encode for application
784 sendString( s ); // we may well have s.length() > 1 779 sendString( s ); // we may well have s.length() > 1
785 } 780 }
786 return; 781 return;
787 } 782 }
788} 783}
789 784
790/* ------------------------------------------------------------------------- */ 785/* ------------------------------------------------------------------------- */
791/* */ 786/* */
792/* VT100 Charsets */ 787/* VT100 Charsets */
793/* */ 788/* */
794/* ------------------------------------------------------------------------- */ 789/* ------------------------------------------------------------------------- */
795 790
796// Character Set Conversion ------------------------------------------------ -- 791// Character Set Conversion ------------------------------------------------ --
797 792
798/* 793/*
799 The processing contains a VT100 specific code translation layer. 794 The processing contains a VT100 specific code translation layer.
800 It's still in use and mainly responsible for the line drawing graphics. 795 It's still in use and mainly responsible for the line drawing graphics.
801 796
802 These and some other glyphs are assigned to codes (0x5f-0xfe) 797 These and some other glyphs are assigned to codes (0x5f-0xfe)
diff --git a/noncore/apps/opie-console/widget.cpp b/noncore/apps/opie-console/widget.cpp
index 10045c6..e17dfd4 100644
--- a/noncore/apps/opie-console/widget.cpp
+++ b/noncore/apps/opie-console/widget.cpp
@@ -1,845 +1,837 @@
1/* ------------------------------------------------------------------------ */ 1/* ------------------------------------------------------------------------ */
2/* */ 2/* */
3/* [TEWidget.C] Terminal Emulation Widget */ 3/* [TEWidget.C] Terminal Emulation Widget */
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/* ibot: 19/* ibot:
20 i changed 20 i changed
21 "currentSession->getEmulation()->sendString()" to 21 "currentSession->getEmulation()->sendString()" to
22 "currentSession->layer()->send()" 22 "currentSession->layer()->send()"
23 # this is not right! EmulationLayer should send it... 23 # this is not right! EmulationLayer should send it...
24 i changed all those to use emulationLayer()->send() instead 24 i changed all those to use emulationLayer()->send() instead
25 i had to create a QByteArray before... 25 i had to create a QByteArray before...
26 26
27TODO: 27TODO:
28alter Widget to use only QByteArray, where applicable. 28alter Widget to use only QByteArray, where applicable.
29*/ 29*/
30 30
31 31
32 32
33/*! \class Widget 33/*! \class Widget
34 34
35 \brief Visible screen contents 35 \brief Visible screen contents
36 36
37 This class is responsible to map the `image' of a terminal emulation to the 37 This class is responsible to map the `image' of a terminal emulation to the
38 display. All the dependency of the emulation to a specific GUI or toolkit is 38 display. All the dependency of the emulation to a specific GUI or toolkit is
39 localized here. Further, this widget has no knowledge about being part of an 39 localized here. Further, this widget has no knowledge about being part of an
40 emulation, it simply work within the terminal emulation framework by exposing 40 emulation, it simply work within the terminal emulation framework by exposing
41 size and key events and by being ordered to show a new image. 41 size and key events and by being ordered to show a new image.
42 42
43 <ul> 43 <ul>
44 <li> The internal image has the size of the widget (evtl. rounded up) 44 <li> The internal image has the size of the widget (evtl. rounded up)
45 <li> The external image used in setImage can have any size. 45 <li> The external image used in setImage can have any size.
46 <li> (internally) the external image is simply copied to the internal 46 <li> (internally) the external image is simply copied to the internal
47 when a setImage happens. During a resizeEvent no painting is done 47 when a setImage happens. During a resizeEvent no painting is done
48 a paintEvent is expected to follow anyway. 48 a paintEvent is expected to follow anyway.
49 </ul> 49 </ul>
50 50
51 \sa TEScreen \sa Emulation 51 \sa TEScreen \sa Emulation
52*/ 52*/
53 53
54/* FIXME: 54/* FIXME:
55 - 'image' may also be used uninitialized (it isn't in fact) in resizeEvent 55 - 'image' may also be used uninitialized (it isn't in fact) in resizeEvent
56 - 'font_a' not used in mouse events 56 - 'font_a' not used in mouse events
57 - add destructor 57 - add destructor
58*/ 58*/
59 59
60/* TODO 60/* TODO
61 - evtl. be sensitive to `paletteChange' while using default colors. 61 - evtl. be sensitive to `paletteChange' while using default colors.
62 - set different 'rounding' styles? I.e. have a mode to show clipped chars? 62 - set different 'rounding' styles? I.e. have a mode to show clipped chars?
63*/ 63*/
64 64
65// #include "config.h" 65// #include "config.h"
66#include "widget.h" 66#include "widget.h"
67#include "session.h"
68#include <qpe/config.h> 67#include <qpe/config.h>
69#include <qapplication.h>
70 68
71#include <qcursor.h>
72#include <qregexp.h>
73#include <qpainter.h>
74#include <qclipboard.h> 69#include <qclipboard.h>
75#include <qstyle.h>
76#include <qfile.h>
77#include <qdragobject.h>
78 70
79#include <stdio.h> 71#include <stdio.h>
80#include <stdlib.h> 72#include <stdlib.h>
81#include <unistd.h> 73#include <unistd.h>
82#include <ctype.h> 74#include <ctype.h>
83#include <sys/stat.h> 75#include <sys/stat.h>
84#include <sys/types.h> 76#include <sys/types.h>
85#include <signal.h> 77#include <signal.h>
86 78
87#include <assert.h> 79#include <assert.h>
88 80
89// #include "widget.moc" 81// #include "widget.moc"
90//#include <kapp.h> 82//#include <kapp.h>
91//#include <kcursor.h> 83//#include <kcursor.h>
92//#include <kurl.h> 84//#include <kurl.h>
93//#include <kdebug.h> 85//#include <kdebug.h>
94//#include <klocale.h> 86//#include <klocale.h>
95 87
96#define HERE printf("%s(%d): %s\n",__FILE__,__LINE__,__FUNCTION__) 88#define HERE printf("%s(%d): %s\n",__FILE__,__LINE__,__FUNCTION__)
97#define HCNT(Name) // { static int cnt = 1; printf("%s(%d): %s %d\n",__FILE__,__LINE__,Name,cnt++); } 89#define HCNT(Name) // { static int cnt = 1; printf("%s(%d): %s %d\n",__FILE__,__LINE__,Name,cnt++); }
98 90
99#define loc(X,Y) ((Y)*columns+(X)) 91#define loc(X,Y) ((Y)*columns+(X))
100 92
101//FIXME: the rim should normally be 1, 0 only when running in full screen mode. 93//FIXME: the rim should normally be 1, 0 only when running in full screen mode.
102#define rimX 0 // left/right rim width 94#define rimX 0 // left/right rim width
103#define rimY 0 // top/bottom rim high 95#define rimY 0 // top/bottom rim high
104 96
105#define yMouseScroll 1 97#define yMouseScroll 1
106// scroll increment used when dragging selection at top/bottom of window. 98// scroll increment used when dragging selection at top/bottom of window.
107 99
108/* ------------------------------------------------------------------------- */ 100/* ------------------------------------------------------------------------- */
109/* */ 101/* */
110/* Colors */ 102/* Colors */
111/* */ 103/* */
112/* ------------------------------------------------------------------------- */ 104/* ------------------------------------------------------------------------- */
113 105
114//FIXME: the default color table is in session.C now. 106//FIXME: the default color table is in session.C now.
115// We need a way to get rid of this one, here. 107// We need a way to get rid of this one, here.
116static const ColorEntry base_color_table[TABLE_COLORS] = 108static const ColorEntry base_color_table[TABLE_COLORS] =
117// The following are almost IBM standard color codes, with some slight 109// The following are almost IBM standard color codes, with some slight
118// gamma correction for the dim colors to compensate for bright X screens. 110// gamma correction for the dim colors to compensate for bright X screens.
119// It contains the 8 ansiterm/xterm colors in 2 intensities. 111// It contains the 8 ansiterm/xterm colors in 2 intensities.
120{ 112{
121 // Fixme: could add faint colors here, also. 113 // Fixme: could add faint colors here, also.
122 // normal 114 // normal
123 ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 1, 0 ), // Dfore, Dback 115 ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 1, 0 ), // Dfore, Dback
124 ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0x18), 0, 0 ), // Black, Red 116 ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0x18), 0, 0 ), // Black, Red
125 ColorEntry(QColor(0x18,0xB2,0x18), 0, 0 ), ColorEntry( QColor(0xB2,0x68,0x18), 0, 0 ), // Green, Yellow 117 ColorEntry(QColor(0x18,0xB2,0x18), 0, 0 ), ColorEntry( QColor(0xB2,0x68,0x18), 0, 0 ), // Green, Yellow
126 ColorEntry(QColor(0x18,0x18,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), // Blue, Magenta 118 ColorEntry(QColor(0x18,0x18,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), // Blue, Magenta
127 ColorEntry(QColor(0x18,0xB2,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 0, 0 ), // Cyan, White 119 ColorEntry(QColor(0x18,0xB2,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 0, 0 ), // Cyan, White
128 // intensiv 120 // intensiv
129 ColorEntry(QColor(0x00,0x00,0x00), 0, 1 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 1, 0 ), 121 ColorEntry(QColor(0x00,0x00,0x00), 0, 1 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 1, 0 ),
130 ColorEntry(QColor(0x68,0x68,0x68), 0, 0 ), ColorEntry( QColor(0xFF,0x54,0x54), 0, 0 ), 122 ColorEntry(QColor(0x68,0x68,0x68), 0, 0 ), ColorEntry( QColor(0xFF,0x54,0x54), 0, 0 ),
131 ColorEntry(QColor(0x54,0xFF,0x54), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0x54), 0, 0 ), 123 ColorEntry(QColor(0x54,0xFF,0x54), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0x54), 0, 0 ),
132 ColorEntry(QColor(0x54,0x54,0xFF), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), 124 ColorEntry(QColor(0x54,0x54,0xFF), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ),
133 ColorEntry(QColor(0x54,0xFF,0xFF), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 0, 0 ) 125 ColorEntry(QColor(0x54,0xFF,0xFF), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 0, 0 )
134}; 126};
135 127
136/* Note that we use ANSI color order (bgr), while IBMPC color order is (rgb) 128/* Note that we use ANSI color order (bgr), while IBMPC color order is (rgb)
137 129
138 Code 0 1 2 3 4 5 6 7 130 Code 0 1 2 3 4 5 6 7
139 ----------- ------- ------- ------- ------- ------- ------- ------- ------- 131 ----------- ------- ------- ------- ------- ------- ------- ------- -------
140 ANSI (bgr) Black Red Green Yellow Blue Magenta Cyan White 132 ANSI (bgr) Black Red Green Yellow Blue Magenta Cyan White
141 IBMPC (rgb) Black Blue Green Cyan Red Magenta Yellow White 133 IBMPC (rgb) Black Blue Green Cyan Red Magenta Yellow White
142*/ 134*/
143 135
144QColor Widget::getDefaultBackColor() 136QColor Widget::getDefaultBackColor()
145{ 137{
146 return color_table[DEFAULT_BACK_COLOR].color; 138 return color_table[DEFAULT_BACK_COLOR].color;
147} 139}
148 140
149const ColorEntry* Widget::getColorTable() const 141const ColorEntry* Widget::getColorTable() const
150{ 142{
151 return color_table; 143 return color_table;
152} 144}
153 145
154const ColorEntry* Widget::getdefaultColorTable() const 146const ColorEntry* Widget::getdefaultColorTable() const
155{ 147{
156 return base_color_table; 148 return base_color_table;
157} 149}
158 150
159 151
160const QPixmap *Widget::backgroundPixmap() 152const QPixmap *Widget::backgroundPixmap()
161{ 153{
162 static QPixmap *bg = new QPixmap("~/qpim/main/pics/faded_bg.xpm"); 154 static QPixmap *bg = new QPixmap("~/qpim/main/pics/faded_bg.xpm");
163 const QPixmap *pm = bg; 155 const QPixmap *pm = bg;
164 return pm; 156 return pm;
165} 157}
166 158
167void Widget::setColorTable(const ColorEntry table[]) 159void Widget::setColorTable(const ColorEntry table[])
168{ 160{
169 for (int i = 0; i < TABLE_COLORS; i++) color_table[i] = table[i]; 161 for (int i = 0; i < TABLE_COLORS; i++) color_table[i] = table[i];
170 162
171 const QPixmap* pm = backgroundPixmap(); 163 const QPixmap* pm = backgroundPixmap();
172 if (!pm) setBackgroundColor(color_table[DEFAULT_BACK_COLOR].color); 164 if (!pm) setBackgroundColor(color_table[DEFAULT_BACK_COLOR].color);
173 update(); 165 update();
174} 166}
175 167
176//FIXME: add backgroundPixmapChanged. 168//FIXME: add backgroundPixmapChanged.
177 169
178/* ------------------------------------------------------------------------- */ 170/* ------------------------------------------------------------------------- */
179/* */ 171/* */
180/* Font */ 172/* Font */
181/* */ 173/* */
182/* ------------------------------------------------------------------------- */ 174/* ------------------------------------------------------------------------- */
183 175
184/* 176/*
185 The VT100 has 32 special graphical characters. The usual vt100 extended 177 The VT100 has 32 special graphical characters. The usual vt100 extended
186 xterm fonts have these at 0x00..0x1f. 178 xterm fonts have these at 0x00..0x1f.
187 179
188 QT's iso mapping leaves 0x00..0x7f without any changes. But the graphicals 180 QT's iso mapping leaves 0x00..0x7f without any changes. But the graphicals
189 come in here as proper unicode characters. 181 come in here as proper unicode characters.
190 182
191 We treat non-iso10646 fonts as VT100 extended and do the requiered mapping 183 We treat non-iso10646 fonts as VT100 extended and do the requiered mapping
192 from unicode to 0x00..0x1f. The remaining translation is then left to the 184 from unicode to 0x00..0x1f. The remaining translation is then left to the
193 QCodec. 185 QCodec.
194*/ 186*/
195 187
196// assert for i in [0..31] : vt100extended(vt100_graphics[i]) == i. 188// assert for i in [0..31] : vt100extended(vt100_graphics[i]) == i.
197 189
198unsigned short vt100_graphics[32] = 190unsigned short vt100_graphics[32] =
199{ // 0/8 1/9 2/10 3/11 4/12 5/13 6/14 7/15 191{ // 0/8 1/9 2/10 3/11 4/12 5/13 6/14 7/15
200 0x0020, 0x25C6, 0x2592, 0x2409, 0x240c, 0x240d, 0x240a, 0x00b0, 192 0x0020, 0x25C6, 0x2592, 0x2409, 0x240c, 0x240d, 0x240a, 0x00b0,
201 0x00b1, 0x2424, 0x240b, 0x2518, 0x2510, 0x250c, 0x2514, 0x253c, 193 0x00b1, 0x2424, 0x240b, 0x2518, 0x2510, 0x250c, 0x2514, 0x253c,
202 0xF800, 0xF801, 0x2500, 0xF803, 0xF804, 0x251c, 0x2524, 0x2534, 194 0xF800, 0xF801, 0x2500, 0xF803, 0xF804, 0x251c, 0x2524, 0x2534,
203 0x252c, 0x2502, 0x2264, 0x2265, 0x03C0, 0x2260, 0x00A3, 0x00b7 195 0x252c, 0x2502, 0x2264, 0x2265, 0x03C0, 0x2260, 0x00A3, 0x00b7
204}; 196};
205 197
206static QChar vt100extended(QChar c) 198static QChar vt100extended(QChar c)
207{ 199{
208 switch (c.unicode()) 200 switch (c.unicode())
209 { 201 {
210 case 0x25c6 : return 1; 202 case 0x25c6 : return 1;
211 case 0x2592 : return 2; 203 case 0x2592 : return 2;
212 case 0x2409 : return 3; 204 case 0x2409 : return 3;
213 case 0x240c : return 4; 205 case 0x240c : return 4;
214 case 0x240d : return 5; 206 case 0x240d : return 5;
215 case 0x240a : return 6; 207 case 0x240a : return 6;
216 case 0x00b0 : return 7; 208 case 0x00b0 : return 7;
217 case 0x00b1 : return 8; 209 case 0x00b1 : return 8;
218 case 0x2424 : return 9; 210 case 0x2424 : return 9;
219 case 0x240b : return 10; 211 case 0x240b : return 10;
220 case 0x2518 : return 11; 212 case 0x2518 : return 11;
221 case 0x2510 : return 12; 213 case 0x2510 : return 12;
222 case 0x250c : return 13; 214 case 0x250c : return 13;
223 case 0x2514 : return 14; 215 case 0x2514 : return 14;
224 case 0x253c : return 15; 216 case 0x253c : return 15;
225 case 0xf800 : return 16; 217 case 0xf800 : return 16;
226 case 0xf801 : return 17; 218 case 0xf801 : return 17;
227 case 0x2500 : return 18; 219 case 0x2500 : return 18;
228 case 0xf803 : return 19; 220 case 0xf803 : return 19;
229 case 0xf804 : return 20; 221 case 0xf804 : return 20;
230 case 0x251c : return 21; 222 case 0x251c : return 21;
231 case 0x2524 : return 22; 223 case 0x2524 : return 22;
232 case 0x2534 : return 23; 224 case 0x2534 : return 23;
233 case 0x252c : return 24; 225 case 0x252c : return 24;
234 case 0x2502 : return 25; 226 case 0x2502 : return 25;
235 case 0x2264 : return 26; 227 case 0x2264 : return 26;
236 case 0x2265 : return 27; 228 case 0x2265 : return 27;
237 case 0x03c0 : return 28; 229 case 0x03c0 : return 28;
238 case 0x2260 : return 29; 230 case 0x2260 : return 29;
239 case 0x00a3 : return 30; 231 case 0x00a3 : return 30;
240 case 0x00b7 : return 31; 232 case 0x00b7 : return 31;
241 } 233 }
242 return c; 234 return c;
243} 235}
244 236
245static QChar identicalMap(QChar c) 237static QChar identicalMap(QChar c)
246{ 238{
247 return c; 239 return c;
248} 240}
249 241
250void Widget::fontChange(const QFont &) 242void Widget::fontChange(const QFont &)
251{ 243{
252 QFontMetrics fm(font()); 244 QFontMetrics fm(font());
253 font_h = fm.height(); 245 font_h = fm.height();
254 font_w = fm.maxWidth(); 246 font_w = fm.maxWidth();
255 font_a = fm.ascent(); 247 font_a = fm.ascent();
256//printf("font_h: %d\n",font_h); 248//printf("font_h: %d\n",font_h);
257//printf("font_w: %d\n",font_w); 249//printf("font_w: %d\n",font_w);
258//printf("font_a: %d\n",font_a); 250//printf("font_a: %d\n",font_a);
259//printf("charset: %s\n",QFont::encodingName(font().charSet()).ascii()); 251//printf("charset: %s\n",QFont::encodingName(font().charSet()).ascii());
260//printf("rawname: %s\n",font().rawName().ascii()); 252//printf("rawname: %s\n",font().rawName().ascii());
261 fontMap = 253 fontMap =
262#if QT_VERSION < 300 254#if QT_VERSION < 300
263 strcmp(QFont::encodingName(font().charSet()).ascii(),"iso10646") 255 strcmp(QFont::encodingName(font().charSet()).ascii(),"iso10646")
264 ? vt100extended 256 ? vt100extended
265 : 257 :
266#endif 258#endif
267 identicalMap; 259 identicalMap;
268 propagateSize(); 260 propagateSize();
269 update(); 261 update();
270} 262}
271 263
272void Widget::setVTFont(const QFont& f) 264void Widget::setVTFont(const QFont& f)
273{ 265{
274 QFrame::setFont(f); 266 QFrame::setFont(f);
275} 267}
276 268
277QFont Widget::getVTFont() { 269QFont Widget::getVTFont() {
278 return font(); 270 return font();
279} 271}
280 272
281void Widget::setFont(const QFont &) 273void Widget::setFont(const QFont &)
282{ 274{
283 // ignore font change request if not coming from konsole itself 275 // ignore font change request if not coming from konsole itself
284} 276}
285 277
286/* ------------------------------------------------------------------------- */ 278/* ------------------------------------------------------------------------- */
287/* */ 279/* */
288/* Constructor / Destructor */ 280/* Constructor / Destructor */
289/* */ 281/* */
290/* ------------------------------------------------------------------------- */ 282/* ------------------------------------------------------------------------- */
291 283
292Widget::Widget(QWidget *parent, const char *name) : QFrame(parent,name) 284Widget::Widget(QWidget *parent, const char *name) : QFrame(parent,name)
293{ 285{
294#ifndef QT_NO_CLIPBOARD 286#ifndef QT_NO_CLIPBOARD
295 cb = QApplication::clipboard(); 287 cb = QApplication::clipboard();
296 QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), 288 QObject::connect( (QObject*)cb, SIGNAL(dataChanged()),
297 this, SLOT(onClearSelection()) ); 289 this, SLOT(onClearSelection()) );
298#endif 290#endif
299 291
300 scrollbar = new QScrollBar(this); 292 scrollbar = new QScrollBar(this);
301 scrollbar->setCursor( arrowCursor ); 293 scrollbar->setCursor( arrowCursor );
302 connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); 294 connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int)));
303 295
304 Config cfg("Konsole"); 296 Config cfg("Konsole");
305 cfg.setGroup("ScrollBar"); 297 cfg.setGroup("ScrollBar");
306 switch( cfg.readNumEntry("Position",2)){ 298 switch( cfg.readNumEntry("Position",2)){
307 case 0: 299 case 0:
308 scrollLoc = SCRNONE; 300 scrollLoc = SCRNONE;
309 break; 301 break;
310 case 1: 302 case 1:
311 scrollLoc = SCRLEFT; 303 scrollLoc = SCRLEFT;
312 break; 304 break;
313 case 2: 305 case 2:
314 scrollLoc = SCRRIGHT; 306 scrollLoc = SCRRIGHT;
315 break; 307 break;
316 }; 308 };
317 309
318 blinkT = new QTimer(this); 310 blinkT = new QTimer(this);
319 connect(blinkT, SIGNAL(timeout()), this, SLOT(blinkEvent())); 311 connect(blinkT, SIGNAL(timeout()), this, SLOT(blinkEvent()));
320 // blinking = FALSE; 312 // blinking = FALSE;
321 blinking = TRUE; 313 blinking = TRUE;
322 314
323 resizing = FALSE; 315 resizing = FALSE;
324 actSel = 0; 316 actSel = 0;
325 image = 0; 317 image = 0;
326 lines = 1; 318 lines = 1;
327 columns = 1; 319 columns = 1;
328 font_w = 1; 320 font_w = 1;
329 font_h = 1; 321 font_h = 1;
330 font_a = 1; 322 font_a = 1;
331 word_selection_mode = FALSE; 323 word_selection_mode = FALSE;
332 324
333 setMouseMarks(TRUE); 325 setMouseMarks(TRUE);
334 setVTFont( QFont("fixed") ); 326 setVTFont( QFont("fixed") );
335 setColorTable(base_color_table); // init color table 327 setColorTable(base_color_table); // init color table
336 328
337 qApp->installEventFilter( this ); //FIXME: see below 329 qApp->installEventFilter( this ); //FIXME: see below
338// KCursor::setAutoHideCursor( this, true ); 330// KCursor::setAutoHideCursor( this, true );
339 331
340 // Init DnD //////////////////////////////////////////////////////////////// 332 // Init DnD ////////////////////////////////////////////////////////////////
341 currentSession = NULL; 333 currentSession = NULL;
342// setAcceptDrops(true); // attempt 334// setAcceptDrops(true); // attempt
343// m_drop = new QPopupMenu(this); 335// m_drop = new QPopupMenu(this);
344// m_drop->insertItem( QString("Paste"), 0); 336// m_drop->insertItem( QString("Paste"), 0);
345// m_drop->insertItem( QString("cd"), 1); 337// m_drop->insertItem( QString("cd"), 1);
346// connect(m_drop, SIGNAL(activated(int)), SLOT(drop_menu_activated(int))); 338// connect(m_drop, SIGNAL(activated(int)), SLOT(drop_menu_activated(int)));
347 339
348 // we need focus so that the auto-hide cursor feature works 340 // we need focus so that the auto-hide cursor feature works
349 setFocus(); 341 setFocus();
350 setFocusPolicy( WheelFocus ); 342 setFocusPolicy( WheelFocus );
351} 343}
352 344
353//FIXME: make proper destructor 345//FIXME: make proper destructor
354// Here's a start (David) 346// Here's a start (David)
355Widget::~Widget() 347Widget::~Widget()
356{ 348{
357 qApp->removeEventFilter( this ); 349 qApp->removeEventFilter( this );
358 if (image) free(image); 350 if (image) free(image);
359} 351}
360 352
361/* ------------------------------------------------------------------------- */ 353/* ------------------------------------------------------------------------- */
362/* */ 354/* */
363/* Display Operations */ 355/* Display Operations */
364/* */ 356/* */
365/* ------------------------------------------------------------------------- */ 357/* ------------------------------------------------------------------------- */
366 358
367/*! 359/*!
368 attributed string draw primitive 360 attributed string draw primitive
369*/ 361*/
370 362
371void Widget::drawAttrStr(QPainter &paint, QRect rect, 363void Widget::drawAttrStr(QPainter &paint, QRect rect,
372 QString& str, Character attr, BOOL pm, BOOL clear) 364 QString& str, Character attr, BOOL pm, BOOL clear)
373{ 365{
374 if (pm && color_table[attr.b].transparent) 366 if (pm && color_table[attr.b].transparent)
375 { 367 {
376 paint.setBackgroundMode( TransparentMode ); 368 paint.setBackgroundMode( TransparentMode );
377 if (clear) erase(rect); 369 if (clear) erase(rect);
378 } 370 }
379 else 371 else
380 { 372 {
381 if (blinking) 373 if (blinking)
382 paint.fillRect(rect, color_table[attr.b].color); 374 paint.fillRect(rect, color_table[attr.b].color);
383 else 375 else
384 { 376 {
385 paint.setBackgroundMode( OpaqueMode ); 377 paint.setBackgroundMode( OpaqueMode );
386 paint.setBackgroundColor( color_table[attr.b].color ); 378 paint.setBackgroundColor( color_table[attr.b].color );
387 } 379 }
388 } 380 }
389 381
390 if (color_table[attr.f].bold) 382 if (color_table[attr.f].bold)
391 paint.setPen(QColor( 0x8F, 0x00, 0x00 )); 383 paint.setPen(QColor( 0x8F, 0x00, 0x00 ));
392 else 384 else
393 paint.setPen(color_table[attr.f].color); 385 paint.setPen(color_table[attr.f].color);
394 386
395 paint.drawText(rect.x(),rect.y()+font_a, str); 387 paint.drawText(rect.x(),rect.y()+font_a, str);
396 388
397 if (attr.r & RE_UNDERLINE) 389 if (attr.r & RE_UNDERLINE)
398 paint.drawLine(rect.left(), rect.y()+font_a+1, rect.right(),rect.y()+font_a+1 ); 390 paint.drawLine(rect.left(), rect.y()+font_a+1, rect.right(),rect.y()+font_a+1 );
399} 391}
400 392
401/*! 393/*!
402 The image can only be set completely. 394 The image can only be set completely.
403 395
404 The size of the new image may or may not match the size of the widget. 396 The size of the new image may or may not match the size of the widget.
405*/ 397*/
406 398
407void Widget::setImage(const Character* const newimg, int lines, int columns) 399void Widget::setImage(const Character* const newimg, int lines, int columns)
408{ int y,x,len; 400{ int y,x,len;
409 const QPixmap* pm = backgroundPixmap(); 401 const QPixmap* pm = backgroundPixmap();
410 QPainter paint; 402 QPainter paint;
411 setUpdatesEnabled(FALSE); 403 setUpdatesEnabled(FALSE);
412 paint.begin( this ); 404 paint.begin( this );
413HCNT("setImage"); 405HCNT("setImage");
414 406
415 QPoint tL = contentsRect().topLeft(); 407 QPoint tL = contentsRect().topLeft();
416 int tLx = tL.x(); 408 int tLx = tL.x();
417 int tLy = tL.y(); 409 int tLy = tL.y();
418 hasBlinker = FALSE; 410 hasBlinker = FALSE;
419 411
420 int cf = -1; // undefined 412 int cf = -1; // undefined
421 int cb = -1; // undefined 413 int cb = -1; // undefined
422 int cr = -1; // undefined 414 int cr = -1; // undefined
423 415
424 int lins = QMIN(this->lines, QMAX(0,lines )); 416 int lins = QMIN(this->lines, QMAX(0,lines ));
425 int cols = QMIN(this->columns,QMAX(0,columns)); 417 int cols = QMIN(this->columns,QMAX(0,columns));
426 QChar *disstrU = new QChar[cols]; 418 QChar *disstrU = new QChar[cols];
427 419
428//{ static int cnt = 0; printf("setImage %d\n",cnt++); } 420//{ static int cnt = 0; printf("setImage %d\n",cnt++); }
429 for (y = 0; y < lins; y++) 421 for (y = 0; y < lins; y++)
430 { 422 {
431 const Character* lcl = &image[y*this->columns]; 423 const Character* lcl = &image[y*this->columns];
432 const Character* const ext = &newimg[y*columns]; 424 const Character* const ext = &newimg[y*columns];
433 if (!resizing) // not while resizing, we're expecting a paintEvent 425 if (!resizing) // not while resizing, we're expecting a paintEvent
434 for (x = 0; x < cols; x++) 426 for (x = 0; x < cols; x++)
435 { 427 {
436 hasBlinker |= (ext[x].r & RE_BLINK); 428 hasBlinker |= (ext[x].r & RE_BLINK);
437 if (ext[x] != lcl[x]) 429 if (ext[x] != lcl[x])
438 { 430 {
439 cr = ext[x].r; 431 cr = ext[x].r;
440 cb = ext[x].b; 432 cb = ext[x].b;
441 if (ext[x].f != cf) cf = ext[x].f; 433 if (ext[x].f != cf) cf = ext[x].f;
442 int lln = cols - x; 434 int lln = cols - x;
443 disstrU[0] = fontMap(ext[x+0].c); 435 disstrU[0] = fontMap(ext[x+0].c);
444 for (len = 1; len < lln; len++) 436 for (len = 1; len < lln; len++)
445 { 437 {
446 if (ext[x+len].f != cf || ext[x+len].b != cb || ext[x+len].r != cr || 438 if (ext[x+len].f != cf || ext[x+len].b != cb || ext[x+len].r != cr ||
447 ext[x+len] == lcl[x+len] ) 439 ext[x+len] == lcl[x+len] )
448 break; 440 break;
449 disstrU[len] = fontMap(ext[x+len].c); 441 disstrU[len] = fontMap(ext[x+len].c);
450 } 442 }
451 QString unistr(disstrU,len); 443 QString unistr(disstrU,len);
452 drawAttrStr(paint, 444 drawAttrStr(paint,
453 QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h), 445 QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h),
454 unistr, ext[x], pm != NULL, true); 446 unistr, ext[x], pm != NULL, true);
455 x += len - 1; 447 x += len - 1;
456 } 448 }
457 } 449 }
458 // finally, make `image' become `newimg'. 450 // finally, make `image' become `newimg'.
459 memcpy((void*)lcl,(const void*)ext,cols*sizeof(Character)); 451 memcpy((void*)lcl,(const void*)ext,cols*sizeof(Character));
460 } 452 }
461 drawFrame( &paint ); 453 drawFrame( &paint );
462 paint.end(); 454 paint.end();
463 setUpdatesEnabled(TRUE); 455 setUpdatesEnabled(TRUE);
464 if ( hasBlinker && !blinkT->isActive()) blinkT->start(1000); // 1000 ms 456 if ( hasBlinker && !blinkT->isActive()) blinkT->start(1000); // 1000 ms
465 if (!hasBlinker && blinkT->isActive()) { blinkT->stop(); blinking = FALSE; } 457 if (!hasBlinker && blinkT->isActive()) { blinkT->stop(); blinking = FALSE; }
466 delete [] disstrU; 458 delete [] disstrU;
467} 459}
468 460
469// paint Event //////////////////////////////////////////////////// 461// paint Event ////////////////////////////////////////////////////
470 462
471/*! 463/*!
472 The difference of this routine vs. the `setImage' is, 464 The difference of this routine vs. the `setImage' is,
473 that the drawing does not include a difference analysis 465 that the drawing does not include a difference analysis
474 between the old and the new image. Instead, the internal 466 between the old and the new image. Instead, the internal
475 image is used and the painting bound by the PaintEvent box. 467 image is used and the painting bound by the PaintEvent box.
476*/ 468*/
477 469
478void Widget::paintEvent( QPaintEvent* pe ) 470void Widget::paintEvent( QPaintEvent* pe )
479{ 471{
480 472
481//{ static int cnt = 0; printf("paint %d\n",cnt++); } 473//{ static int cnt = 0; printf("paint %d\n",cnt++); }
482 const QPixmap* pm = backgroundPixmap(); 474 const QPixmap* pm = backgroundPixmap();
483 QPainter paint; 475 QPainter paint;
484 setUpdatesEnabled(FALSE); 476 setUpdatesEnabled(FALSE);
485 paint.begin( this ); 477 paint.begin( this );
486 paint.setBackgroundMode( TransparentMode ); 478 paint.setBackgroundMode( TransparentMode );
487HCNT("paintEvent"); 479HCNT("paintEvent");
488 480
489 // Note that the actual widget size can be slightly larger 481 // Note that the actual widget size can be slightly larger
490 // that the image (the size is truncated towards the smaller 482 // that the image (the size is truncated towards the smaller
491 // number of characters in `resizeEvent'. The paint rectangle 483 // number of characters in `resizeEvent'. The paint rectangle
492 // can thus be larger than the image, but less then the size 484 // can thus be larger than the image, but less then the size
493 // of one character. 485 // of one character.
494 486
495 QRect rect = pe->rect().intersect(contentsRect()); 487 QRect rect = pe->rect().intersect(contentsRect());
496 488
497 QPoint tL = contentsRect().topLeft(); 489 QPoint tL = contentsRect().topLeft();
498 int tLx = tL.x(); 490 int tLx = tL.x();
499 int tLy = tL.y(); 491 int tLy = tL.y();
500 492
501 int lux = QMIN(columns-1, QMAX(0,(rect.left() - tLx - blX ) / font_w)); 493 int lux = QMIN(columns-1, QMAX(0,(rect.left() - tLx - blX ) / font_w));
502 int luy = QMIN(lines-1, QMAX(0,(rect.top() - tLy - bY ) / font_h)); 494 int luy = QMIN(lines-1, QMAX(0,(rect.top() - tLy - bY ) / font_h));
503 int rlx = QMIN(columns-1, QMAX(0,(rect.right() - tLx - blX ) / font_w)); 495 int rlx = QMIN(columns-1, QMAX(0,(rect.right() - tLx - blX ) / font_w));
504 int rly = QMIN(lines-1, QMAX(0,(rect.bottom() - tLy - bY ) / font_h)); 496 int rly = QMIN(lines-1, QMAX(0,(rect.bottom() - tLy - bY ) / font_h));
505 497
506 /* 498 /*
507 printf("paintEvent: %d..%d, %d..%d (%d..%d, %d..%d)\n",lux,rlx,luy,rly, 499 printf("paintEvent: %d..%d, %d..%d (%d..%d, %d..%d)\n",lux,rlx,luy,rly,
508 rect.left(), rect.right(), rect.top(), rect.bottom()); 500 rect.left(), rect.right(), rect.top(), rect.bottom());
509 */ 501 */
510 502
511 // if (pm != NULL && color_table[image->b].transparent) 503 // if (pm != NULL && color_table[image->b].transparent)
512 // erase(rect); 504 // erase(rect);
513 // BL: I have no idea why we need this, and it breaks the refresh. 505 // BL: I have no idea why we need this, and it breaks the refresh.
514 506
515 QChar *disstrU = new QChar[columns]; 507 QChar *disstrU = new QChar[columns];
516 for (int y = luy; y <= rly; y++) 508 for (int y = luy; y <= rly; y++)
517 for (int x = lux; x <= rlx; x++) 509 for (int x = lux; x <= rlx; x++)
518 { 510 {
519 int len = 1; 511 int len = 1;
520 disstrU[0] = fontMap(image[loc(x,y)].c); 512 disstrU[0] = fontMap(image[loc(x,y)].c);
521 int cf = image[loc(x,y)].f; 513 int cf = image[loc(x,y)].f;
522 int cb = image[loc(x,y)].b; 514 int cb = image[loc(x,y)].b;
523 int cr = image[loc(x,y)].r; 515 int cr = image[loc(x,y)].r;
524 while (x+len <= rlx && 516 while (x+len <= rlx &&
525 image[loc(x+len,y)].f == cf && 517 image[loc(x+len,y)].f == cf &&
526 image[loc(x+len,y)].b == cb && 518 image[loc(x+len,y)].b == cb &&
527 image[loc(x+len,y)].r == cr ) 519 image[loc(x+len,y)].r == cr )
528 { 520 {
529 disstrU[len] = fontMap(image[loc(x+len,y)].c); 521 disstrU[len] = fontMap(image[loc(x+len,y)].c);
530 len += 1; 522 len += 1;
531 } 523 }
532 QString unistr(disstrU,len); 524 QString unistr(disstrU,len);
533 drawAttrStr(paint, 525 drawAttrStr(paint,
534 QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h), 526 QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h),
535 unistr, image[loc(x,y)], pm != NULL, false); 527 unistr, image[loc(x,y)], pm != NULL, false);
536 x += len - 1; 528 x += len - 1;
537 } 529 }
538 delete [] disstrU; 530 delete [] disstrU;
539 drawFrame( &paint ); 531 drawFrame( &paint );
540 paint.end(); 532 paint.end();
541 setUpdatesEnabled(TRUE); 533 setUpdatesEnabled(TRUE);
542} 534}
543 535
544void Widget::blinkEvent() 536void Widget::blinkEvent()
545{ 537{
546 blinking = !blinking; 538 blinking = !blinking;
547 repaint(FALSE); 539 repaint(FALSE);
548} 540}
549 541
550/* ------------------------------------------------------------------------- */ 542/* ------------------------------------------------------------------------- */
551/* */ 543/* */
552/* Resizing */ 544/* Resizing */
553/* */ 545/* */
554/* ------------------------------------------------------------------------- */ 546/* ------------------------------------------------------------------------- */
555 547
556void Widget::resizeEvent(QResizeEvent* ev) 548void Widget::resizeEvent(QResizeEvent* ev)
557{ 549{
558// printf("resize: %d,%d\n",ev->size().width(),ev->size().height()); 550// printf("resize: %d,%d\n",ev->size().width(),ev->size().height());
559 //printf("approx: %d,%d\n",ev->size().width()/font_w,ev->size().height()/font_h); 551 //printf("approx: %d,%d\n",ev->size().width()/font_w,ev->size().height()/font_h);
560 //printf("leaves: %d,%d\n",ev->size().width()%font_w,ev->size().height()%font_h); 552 //printf("leaves: %d,%d\n",ev->size().width()%font_w,ev->size().height()%font_h);
561 //printf("curren: %d,%d\n",width(),height()); 553 //printf("curren: %d,%d\n",width(),height());
562HCNT("resizeEvent"); 554HCNT("resizeEvent");
563 555
564 // see comment in `paintEvent' concerning the rounding. 556 // see comment in `paintEvent' concerning the rounding.
565 //FIXME: could make a routine here; check width(),height() 557 //FIXME: could make a routine here; check width(),height()
566 assert(ev->size().width() == width()); 558 assert(ev->size().width() == width());
567 assert(ev->size().height() == height()); 559 assert(ev->size().height() == height());
568 560
569 propagateSize(); 561 propagateSize();
570} 562}
571 563
572void Widget::propagateSize() 564void Widget::propagateSize()
573{ 565{
574 Character* oldimg = image; 566 Character* oldimg = image;
575 int oldlin = lines; 567 int oldlin = lines;
576 int oldcol = columns; 568 int oldcol = columns;
577 makeImage(); 569 makeImage();
578 // we copy the old image to reduce flicker 570 // we copy the old image to reduce flicker
579 int lins = QMIN(oldlin,lines); 571 int lins = QMIN(oldlin,lines);
580 int cols = QMIN(oldcol,columns); 572 int cols = QMIN(oldcol,columns);
581 if (oldimg) 573 if (oldimg)
582 { 574 {
583 for (int lin = 0; lin < lins; lin++) 575 for (int lin = 0; lin < lins; lin++)
584 memcpy((void*)&image[columns*lin], 576 memcpy((void*)&image[columns*lin],
585 (void*)&oldimg[oldcol*lin],cols*sizeof(Character)); 577 (void*)&oldimg[oldcol*lin],cols*sizeof(Character));
586 free(oldimg); //FIXME: try new,delete 578 free(oldimg); //FIXME: try new,delete
587 } 579 }
588 else 580 else
589 clearImage(); 581 clearImage();
590 582
591 //NOTE: control flows from the back through the chest right into the eye. 583 //NOTE: control flows from the back through the chest right into the eye.
592 // `emu' will call back via `setImage'. 584 // `emu' will call back via `setImage'.
593 585
594 resizing = TRUE; 586 resizing = TRUE;
595 emit changedImageSizeSignal(lines, columns); // expose resizeEvent 587 emit changedImageSizeSignal(lines, columns); // expose resizeEvent
596 resizing = FALSE; 588 resizing = FALSE;
597} 589}
598 590
599/* ------------------------------------------------------------------------- */ 591/* ------------------------------------------------------------------------- */
600/* */ 592/* */
601/* Scrollbar */ 593/* Scrollbar */
602/* */ 594/* */
603/* ------------------------------------------------------------------------- */ 595/* ------------------------------------------------------------------------- */
604 596
605void Widget::scrollChanged(int) 597void Widget::scrollChanged(int)
606{ 598{
607 emit changedHistoryCursor(scrollbar->value()); //expose 599 emit changedHistoryCursor(scrollbar->value()); //expose
608} 600}
609 601
610void Widget::setScroll(int cursor, int slines) 602void Widget::setScroll(int cursor, int slines)
611{ 603{
612 disconnect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); 604 disconnect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int)));
613 scrollbar->setRange(0,slines); 605 scrollbar->setRange(0,slines);
614 scrollbar->setSteps(1,lines); 606 scrollbar->setSteps(1,lines);
615 scrollbar->setValue(cursor); 607 scrollbar->setValue(cursor);
616 connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); 608 connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int)));
617} 609}
618 610
619void Widget::setScrollbarLocation(int loc) 611void Widget::setScrollbarLocation(int loc)
620{ 612{
621 if (scrollLoc == loc) return; // quickly 613 if (scrollLoc == loc) return; // quickly
622 scrollLoc = loc; 614 scrollLoc = loc;
623 propagateSize(); 615 propagateSize();
624 update(); 616 update();
625} 617}
626 618
627/* ------------------------------------------------------------------------- */ 619/* ------------------------------------------------------------------------- */
628/* */ 620/* */
629/* Mouse */ 621/* Mouse */
630/* */ 622/* */
631/* ------------------------------------------------------------------------- */ 623/* ------------------------------------------------------------------------- */
632 624
633/*! 625/*!
634 Three different operations can be performed using the mouse, and the 626 Three different operations can be performed using the mouse, and the
635 routines in this section serve all of them: 627 routines in this section serve all of them:
636 628
637 1) The press/release events are exposed to the application 629 1) The press/release events are exposed to the application
638 2) Marking (press and move left button) and Pasting (press middle button) 630 2) Marking (press and move left button) and Pasting (press middle button)
639 3) The right mouse button is used from the configuration menu 631 3) The right mouse button is used from the configuration menu
640 632
641 NOTE: During the marking process we attempt to keep the cursor within 633 NOTE: During the marking process we attempt to keep the cursor within
642 the bounds of the text as being displayed by setting the mouse position 634 the bounds of the text as being displayed by setting the mouse position
643 whenever the mouse has left the text area. 635 whenever the mouse has left the text area.
644 636
645 Two reasons to do so: 637 Two reasons to do so:
646 1) QT does not allow the `grabMouse' to confine-to the Widget. 638 1) QT does not allow the `grabMouse' to confine-to the Widget.
647 Thus a `XGrapPointer' would have to be used instead. 639 Thus a `XGrapPointer' would have to be used instead.
648 2) Even if so, this would not help too much, since the text area 640 2) Even if so, this would not help too much, since the text area
649 of the Widget is normally not identical with it's bounds. 641 of the Widget is normally not identical with it's bounds.
650 642
651 The disadvantage of the current handling is, that the mouse can visibly 643 The disadvantage of the current handling is, that the mouse can visibly
652 leave the bounds of the widget and is then moved back. Because of the 644 leave the bounds of the widget and is then moved back. Because of the
653 current construction, and the reasons mentioned above, we cannot do better 645 current construction, and the reasons mentioned above, we cannot do better
654 without changing the overall construction. 646 without changing the overall construction.
655*/ 647*/
656 648
657/*! 649/*!
658*/ 650*/
659 651
660void Widget::mousePressEvent(QMouseEvent* ev) 652void Widget::mousePressEvent(QMouseEvent* ev)
661{ 653{
662//printf("press [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button()); 654//printf("press [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button());
663 if ( !contentsRect().contains(ev->pos()) ) return; 655 if ( !contentsRect().contains(ev->pos()) ) return;
664 QPoint tL = contentsRect().topLeft(); 656 QPoint tL = contentsRect().topLeft();
665 int tLx = tL.x(); 657 int tLx = tL.x();
666 int tLy = tL.y(); 658 int tLy = tL.y();
667 659
668 word_selection_mode = FALSE; 660 word_selection_mode = FALSE;
669 661
670//printf("press top left [%d,%d] by=%d\n",tLx,tLy, bY); 662//printf("press top left [%d,%d] by=%d\n",tLx,tLy, bY);
671 if ( ev->button() == LeftButton) 663 if ( ev->button() == LeftButton)
672 { 664 {
673 QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); 665 QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h);
674 666
675 if ( ev->state() & ControlButton ) preserve_line_breaks = FALSE ; 667 if ( ev->state() & ControlButton ) preserve_line_breaks = FALSE ;
676 668
677 if (mouse_marks || (ev->state() & ShiftButton)) 669 if (mouse_marks || (ev->state() & ShiftButton))
678 { 670 {
679 emit clearSelectionSignal(); 671 emit clearSelectionSignal();
680 iPntSel = pntSel = pos; 672 iPntSel = pntSel = pos;
681 actSel = 1; // left mouse button pressed but nothing selected yet. 673 actSel = 1; // left mouse button pressed but nothing selected yet.
682 grabMouse( /*crossCursor*/ ); // handle with care! 674 grabMouse( /*crossCursor*/ ); // handle with care!
683 } 675 }
684 else 676 else
685 { 677 {
686 emit mouseSignal( 0, pos.x() + 1, pos.y() + 1 ); // left button 678 emit mouseSignal( 0, pos.x() + 1, pos.y() + 1 ); // left button
687 } 679 }
688 } 680 }
689 if ( ev->button() == MidButton ) 681 if ( ev->button() == MidButton )
690 { 682 {
691 emitSelection(); 683 emitSelection();
692 } 684 }
693 if ( ev->button() == RightButton ) // Configure 685 if ( ev->button() == RightButton ) // Configure
694 { 686 {
695 emit configureRequest( this, ev->state()&(ShiftButton|ControlButton), ev->x(), ev->y() ); 687 emit configureRequest( this, ev->state()&(ShiftButton|ControlButton), ev->x(), ev->y() );
696 } 688 }
697} 689}
698 690
699void Widget::mouseMoveEvent(QMouseEvent* ev) 691void Widget::mouseMoveEvent(QMouseEvent* ev)
700{ 692{
701 // for auto-hiding the cursor, we need mouseTracking 693 // for auto-hiding the cursor, we need mouseTracking
702 if (ev->state() == NoButton ) return; 694 if (ev->state() == NoButton ) return;
703 695
704 if (actSel == 0) return; 696 if (actSel == 0) return;
705 697
706 // don't extend selection while pasting 698 // don't extend selection while pasting
707 if (ev->state() & MidButton) return; 699 if (ev->state() & MidButton) return;
708 700
709 //if ( !contentsRect().contains(ev->pos()) ) return; 701 //if ( !contentsRect().contains(ev->pos()) ) return;
710 QPoint tL = contentsRect().topLeft(); 702 QPoint tL = contentsRect().topLeft();
711 int tLx = tL.x(); 703 int tLx = tL.x();
712 int tLy = tL.y(); 704 int tLy = tL.y();
713 int scroll = scrollbar->value(); 705 int scroll = scrollbar->value();
714 706
715 // we're in the process of moving the mouse with the left button pressed 707 // we're in the process of moving the mouse with the left button pressed
716 // the mouse cursor will kept catched within the bounds of the text in 708 // the mouse cursor will kept catched within the bounds of the text in
717 // this widget. 709 // this widget.
718 710
719 // Adjust position within text area bounds. See FIXME above. 711 // Adjust position within text area bounds. See FIXME above.
720 QPoint pos = ev->pos(); 712 QPoint pos = ev->pos();
721 if ( pos.x() < tLx+blX ) pos.setX( tLx+blX ); 713 if ( pos.x() < tLx+blX ) pos.setX( tLx+blX );
722 if ( pos.x() > tLx+blX+columns*font_w-1 ) pos.setX( tLx+blX+columns*font_w ); 714 if ( pos.x() > tLx+blX+columns*font_w-1 ) pos.setX( tLx+blX+columns*font_w );
723 if ( pos.y() < tLy+bY ) pos.setY( tLy+bY ); 715 if ( pos.y() < tLy+bY ) pos.setY( tLy+bY );
724 if ( pos.y() > tLy+bY+lines*font_h-1 ) pos.setY( tLy+bY+lines*font_h-1 ); 716 if ( pos.y() > tLy+bY+lines*font_h-1 ) pos.setY( tLy+bY+lines*font_h-1 );
725 // check if we produce a mouse move event by this 717 // check if we produce a mouse move event by this
726 if ( pos != ev->pos() ) cursor().setPos(mapToGlobal(pos)); 718 if ( pos != ev->pos() ) cursor().setPos(mapToGlobal(pos));
727 719
728 if ( pos.y() == tLy+bY+lines*font_h-1 ) 720 if ( pos.y() == tLy+bY+lines*font_h-1 )
729 { 721 {
730 scrollbar->setValue(scrollbar->value()+yMouseScroll); // scrollforward 722 scrollbar->setValue(scrollbar->value()+yMouseScroll); // scrollforward
731 } 723 }
732 if ( pos.y() == tLy+bY ) 724 if ( pos.y() == tLy+bY )
733 { 725 {
734 scrollbar->setValue(scrollbar->value()-yMouseScroll); // scrollback 726 scrollbar->setValue(scrollbar->value()-yMouseScroll); // scrollback
735 } 727 }
736 728
737 QPoint here = QPoint((pos.x()-tLx-blX)/font_w,(pos.y()-tLy-bY)/font_h); 729 QPoint here = QPoint((pos.x()-tLx-blX)/font_w,(pos.y()-tLy-bY)/font_h);
738 QPoint ohere; 730 QPoint ohere;
739 bool swapping = FALSE; 731 bool swapping = FALSE;
740 732
741 if ( word_selection_mode ) 733 if ( word_selection_mode )
742 { 734 {
743 // Extend to word boundaries 735 // Extend to word boundaries
744 int i; 736 int i;
745 int selClass; 737 int selClass;
746 738
747 bool left_not_right = ( here.y() < iPntSel.y() || 739 bool left_not_right = ( here.y() < iPntSel.y() ||
748 here.y() == iPntSel.y() && here.x() < iPntSel.x() ); 740 here.y() == iPntSel.y() && here.x() < iPntSel.x() );
749 bool old_left_not_right = ( pntSel.y() < iPntSel.y() || 741 bool old_left_not_right = ( pntSel.y() < iPntSel.y() ||
750 pntSel.y() == iPntSel.y() && pntSel.x() < iPntSel.x() ); 742 pntSel.y() == iPntSel.y() && pntSel.x() < iPntSel.x() );
751 swapping = left_not_right != old_left_not_right; 743 swapping = left_not_right != old_left_not_right;
752 744
753 // Find left (left_not_right ? from here : from start) 745 // Find left (left_not_right ? from here : from start)
754 QPoint left = left_not_right ? here : iPntSel; 746 QPoint left = left_not_right ? here : iPntSel;
755 i = loc(left.x(),left.y()); 747 i = loc(left.x(),left.y());
756 selClass = charClass(image[i].c); 748 selClass = charClass(image[i].c);
757 while ( left.x() > 0 && charClass(image[i-1].c) == selClass ) 749 while ( left.x() > 0 && charClass(image[i-1].c) == selClass )
758 { i--; left.rx()--; } 750 { i--; left.rx()--; }
759 751
760 // Find left (left_not_right ? from start : from here) 752 // Find left (left_not_right ? from start : from here)
761 QPoint right = left_not_right ? iPntSel : here; 753 QPoint right = left_not_right ? iPntSel : here;
762 i = loc(right.x(),right.y()); 754 i = loc(right.x(),right.y());
763 selClass = charClass(image[i].c); 755 selClass = charClass(image[i].c);
764 while ( right.x() < columns-1 && charClass(image[i+1].c) == selClass ) 756 while ( right.x() < columns-1 && charClass(image[i+1].c) == selClass )
765 { i++; right.rx()++; } 757 { i++; right.rx()++; }
766 758
767 // Pick which is start (ohere) and which is extension (here) 759 // Pick which is start (ohere) and which is extension (here)
768 if ( left_not_right ) 760 if ( left_not_right )
769 { 761 {
770 here = left; ohere = right; 762 here = left; ohere = right;
771 } 763 }
772 else 764 else
773 { 765 {
774 here = right; ohere = left; 766 here = right; ohere = left;
775 } 767 }
776 } 768 }
777 769
778 if (here == pntSel && scroll == scrollbar->value()) return; // not moved 770 if (here == pntSel && scroll == scrollbar->value()) return; // not moved
779 771
780 if ( word_selection_mode ) { 772 if ( word_selection_mode ) {
781 if ( actSel < 2 || swapping ) { 773 if ( actSel < 2 || swapping ) {
782 emit beginSelectionSignal( ohere.x(), ohere.y() ); 774 emit beginSelectionSignal( ohere.x(), ohere.y() );
783 } 775 }
784 } else if ( actSel < 2 ) { 776 } else if ( actSel < 2 ) {
785 emit beginSelectionSignal( pntSel.x(), pntSel.y() ); 777 emit beginSelectionSignal( pntSel.x(), pntSel.y() );
786 } 778 }
787 779
788 actSel = 2; // within selection 780 actSel = 2; // within selection
789 pntSel = here; 781 pntSel = here;
790 emit extendSelectionSignal( here.x(), here.y() ); 782 emit extendSelectionSignal( here.x(), here.y() );
791} 783}
792 784
793void Widget::mouseReleaseEvent(QMouseEvent* ev) 785void Widget::mouseReleaseEvent(QMouseEvent* ev)
794{ 786{
795//printf("release [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button()); 787//printf("release [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button());
796 if ( ev->button() == LeftButton) 788 if ( ev->button() == LeftButton)
797 { 789 {
798 if ( actSel > 1 ) emit endSelectionSignal(preserve_line_breaks); 790 if ( actSel > 1 ) emit endSelectionSignal(preserve_line_breaks);
799 preserve_line_breaks = TRUE; 791 preserve_line_breaks = TRUE;
800 actSel = 0; 792 actSel = 0;
801 793
802 //FIXME: emits a release event even if the mouse is 794 //FIXME: emits a release event even if the mouse is
803 // outside the range. The procedure used in `mouseMoveEvent' 795 // outside the range. The procedure used in `mouseMoveEvent'
804 // applies here, too. 796 // applies here, too.
805 797
806 QPoint tL = contentsRect().topLeft(); 798 QPoint tL = contentsRect().topLeft();
807 int tLx = tL.x(); 799 int tLx = tL.x();
808 int tLy = tL.y(); 800 int tLy = tL.y();
809 801
810 if (!mouse_marks && !(ev->state() & ShiftButton)) 802 if (!mouse_marks && !(ev->state() & ShiftButton))
811 emit mouseSignal( 3, // release 803 emit mouseSignal( 3, // release
812 (ev->x()-tLx-blX)/font_w + 1, 804 (ev->x()-tLx-blX)/font_w + 1,
813 (ev->y()-tLy-bY)/font_h + 1 ); 805 (ev->y()-tLy-bY)/font_h + 1 );
814 releaseMouse(); 806 releaseMouse();
815 } 807 }
816} 808}
817 809
818void Widget::mouseDoubleClickEvent(QMouseEvent* ev) 810void Widget::mouseDoubleClickEvent(QMouseEvent* ev)
819{ 811{
820 if ( ev->button() != LeftButton) return; 812 if ( ev->button() != LeftButton) return;
821 813
822 QPoint tL = contentsRect().topLeft(); 814 QPoint tL = contentsRect().topLeft();
823 int tLx = tL.x(); 815 int tLx = tL.x();
824 int tLy = tL.y(); 816 int tLy = tL.y();
825 QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); 817 QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h);
826 818
827 // pass on double click as two clicks. 819 // pass on double click as two clicks.
828 if (!mouse_marks && !(ev->state() & ShiftButton)) 820 if (!mouse_marks && !(ev->state() & ShiftButton))
829 { 821 {
830 emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button 822 emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button
831 emit mouseSignal( 3, pos.x()+1, pos.y()+1 ); // release 823 emit mouseSignal( 3, pos.x()+1, pos.y()+1 ); // release
832 emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button 824 emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button
833 return; 825 return;
834 } 826 }
835 827
836 828
837 emit clearSelectionSignal(); 829 emit clearSelectionSignal();
838 QPoint bgnSel = pos; 830 QPoint bgnSel = pos;
839 QPoint endSel = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); 831 QPoint endSel = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h);
840 int i = loc(bgnSel.x(),bgnSel.y()); 832 int i = loc(bgnSel.x(),bgnSel.y());
841 iPntSel = bgnSel; 833 iPntSel = bgnSel;
842 834
843 word_selection_mode = TRUE; 835 word_selection_mode = TRUE;
844 836
845 // find word boundaries... 837 // find word boundaries...
diff --git a/noncore/apps/opie-console/widget_layer.cpp b/noncore/apps/opie-console/widget_layer.cpp
index ac84f8b..96dda1c 100644
--- a/noncore/apps/opie-console/widget_layer.cpp
+++ b/noncore/apps/opie-console/widget_layer.cpp
@@ -1,249 +1,245 @@
1/* ------------------------------------------------------------------------- */ 1/* ------------------------------------------------------------------------- */
2/* */ 2/* */
3/* widget_layer.cpp Widget Layer */ 3/* widget_layer.cpp Widget Layer */
4/* */ 4/* */
5/* opie developers <opie@handhelds.org> */ 5/* opie developers <opie@handhelds.org> */
6/* */ 6/* */
7/* ------------------------------------------------------------------------- */ 7/* ------------------------------------------------------------------------- */
8 8
9 9
10 10
11#include "widget_layer.h" 11#include "widget_layer.h"
12 12
13#include <qclipboard.h>
14#include <qregexp.h>
15#include <qglobal.h>
16 13
17#include <string.h> 14#include <string.h>
18//#include < 15//#include <
19 16
20#include "common.h"
21 17
22 18
23 19
24WidgetLayer::WidgetLayer( const Profile &config, QWidget *parent, const char *name ) : QFrame( parent, name ) 20WidgetLayer::WidgetLayer( const Profile &config, QWidget *parent, const char *name ) : QFrame( parent, name )
25{ 21{
26 // get the clipboard 22 // get the clipboard
27 m_clipboard = QApplication::clipboard(); 23 m_clipboard = QApplication::clipboard();
28 24
29 // when data on clipboard changes, clear selection 25 // when data on clipboard changes, clear selection
30 QObject::connect( (QObject*) m_clipboard, SIGNAL( dataChanged() ), 26 QObject::connect( (QObject*) m_clipboard, SIGNAL( dataChanged() ),
31 (QObject*)this, SLOT( onClearSelection() ) ); 27 (QObject*)this, SLOT( onClearSelection() ) );
32 28
33 // initialize vars: 29 // initialize vars:
34 m_lines = 1; 30 m_lines = 1;
35 m_columns = 1; 31 m_columns = 1;
36 m_resizing = false; 32 m_resizing = false;
37 33
38 // just for demonstrating 34 // just for demonstrating
39 //m_image = QArray<Character>( m_lines * m_columns ); 35 //m_image = QArray<Character>( m_lines * m_columns );
40 m_image = QArray<Character>( 1 ); 36 m_image = QArray<Character>( 1 );
41 37
42 // we need to install an event filter, 38 // we need to install an event filter,
43 // to emit keypresses. 39 // to emit keypresses.
44 qApp->installEventFilter( this ); 40 qApp->installEventFilter( this );
45 41
46} 42}
47 43
48 44
49WidgetLayer::~WidgetLayer() 45WidgetLayer::~WidgetLayer()
50{ 46{
51 // clean up 47 // clean up
52 delete m_image; 48 delete m_image;
53} 49}
54 50
55 51
56QSize WidgetLayer::sizeHint() 52QSize WidgetLayer::sizeHint()
57{ 53{
58 return size(); 54 return size();
59} 55}
60 56
61 57
62/* --------------------------------- audio ---------------------------------- */ 58/* --------------------------------- audio ---------------------------------- */
63 59
64void WidgetLayer::bell() 60void WidgetLayer::bell()
65{ 61{
66 QApplication::beep(); 62 QApplication::beep();
67} 63}
68 64
69bool WidgetLayer::eventFilter( QObject *obj, QEvent *e ) 65bool WidgetLayer::eventFilter( QObject *obj, QEvent *e )
70{ 66{
71 if ( (e->type() == QEvent::Accel || 67 if ( (e->type() == QEvent::Accel ||
72 e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) { 68 e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) {
73 static_cast<QKeyEvent *>( e )->ignore(); 69 static_cast<QKeyEvent *>( e )->ignore();
74 return true; 70 return true;
75 } 71 }
76 if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ ) 72 if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ )
77 return false; // not us 73 return false; // not us
78 74
79#ifdef FAKE_CTRL_AND_ALT 75#ifdef FAKE_CTRL_AND_ALT
80 static bool control = false; 76 static bool control = false;
81 static bool alt = false; 77 static bool alt = false;
82// qDebug(" Has a keyboard with no CTRL and ALT keys, but we fake it:"); 78// qDebug(" Has a keyboard with no CTRL and ALT keys, but we fake it:");
83 bool dele = false; 79 bool dele = false;
84 if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { 80 if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) {
85 QKeyEvent* ke = (QKeyEvent*)e; 81 QKeyEvent* ke = (QKeyEvent*)e;
86 bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat(); 82 bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat();
87 switch (ke->key()) { 83 switch (ke->key()) {
88 case Key_F9: // let this be "Control" 84 case Key_F9: // let this be "Control"
89 control = keydown; 85 control = keydown;
90 e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state()); 86 e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state());
91 dele=TRUE; 87 dele=TRUE;
92 break; 88 break;
93 case Key_F13: // let this be "Alt" 89 case Key_F13: // let this be "Alt"
94 alt = keydown; 90 alt = keydown;
95 e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state()); 91 e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state());
96 dele=TRUE; 92 dele=TRUE;
97 break; 93 break;
98 default: 94 default:
99 if ( control ) { 95 if ( control ) {
100 int a = toupper(ke->ascii())-64; 96 int a = toupper(ke->ascii())-64;
101 if ( a >= 0 && a < ' ' ) { 97 if ( a >= 0 && a < ' ' ) {
102 e = new QKeyEvent(e->type(), ke->key(), 98 e = new QKeyEvent(e->type(), ke->key(),
103 a, ke->state()|ControlButton, 99 a, ke->state()|ControlButton,
104QChar(a,0)); 100QChar(a,0));
105 dele=TRUE; 101 dele=TRUE;
106 } 102 }
107 } 103 }
108 if ( alt ) { 104 if ( alt ) {
109 e = new QKeyEvent(e->type(), ke->key(), 105 e = new QKeyEvent(e->type(), ke->key(),
110 ke->ascii(), ke->state()|AltButton, ke->text()); 106 ke->ascii(), ke->state()|AltButton, ke->text());
111 dele=TRUE; 107 dele=TRUE;
112 } 108 }
113 } 109 }
114 } 110 }
115#endif 111#endif
116 112
117 if ( e->type() == QEvent::KeyPress ) { 113 if ( e->type() == QEvent::KeyPress ) {
118 QKeyEvent* ke = (QKeyEvent*)e; 114 QKeyEvent* ke = (QKeyEvent*)e;
119 //actSel=0; // Key stroke implies a screen update, so Widget won't 115 //actSel=0; // Key stroke implies a screen update, so Widget won't
120 // know where the current selection is. 116 // know where the current selection is.
121 117
122// qDebug("key pressed is 0x%x",ke->key()); 118// qDebug("key pressed is 0x%x",ke->key());
123 119
124 if( ke->state() == ShiftButton && ke->key() == Key_Tab) { //lets hardcode this sucker 120 if( ke->state() == ShiftButton && ke->key() == Key_Tab) { //lets hardcode this sucker
125 insertText("\\"); // expose 121 insertText("\\"); // expose
126 } else 122 } else
127 emit keyPressed( ke ); // expose 123 emit keyPressed( ke ); // expose
128 ke->accept(); 124 ke->accept();
129#ifdef FAKE_CTRL_AND_ALT 125#ifdef FAKE_CTRL_AND_ALT
130 if ( dele ) delete e; 126 if ( dele ) delete e;
131#endif 127#endif
132 return true; // stop the event 128 return true; // stop the event
133 } 129 }
134 return QFrame::eventFilter( obj, e ); 130 return QFrame::eventFilter( obj, e );
135} 131}
136 132
137 133
138/* --------------------------------- screen --------------------------------- */ 134/* --------------------------------- screen --------------------------------- */
139 135
140 136
141void WidgetLayer::propagateSize() 137void WidgetLayer::propagateSize()
142{ 138{
143 QArray<Character> oldimage = m_image.copy(); 139 QArray<Character> oldimage = m_image.copy();
144 int oldlines = m_lines; 140 int oldlines = m_lines;
145 int oldcolumns = m_columns; 141 int oldcolumns = m_columns;
146 142
147 makeImage(); 143 makeImage();
148 144
149 // copy old image, to reduce flicker 145 // copy old image, to reduce flicker
150 if ( ! oldimage.isEmpty() ) 146 if ( ! oldimage.isEmpty() )
151 { 147 {
152 int lins = QMIN( oldlines, m_lines ); 148 int lins = QMIN( oldlines, m_lines );
153 int cols = QMIN( oldcolumns, m_columns ); 149 int cols = QMIN( oldcolumns, m_columns );
154 for ( int lin = 0; lin < lins; ++lin ) 150 for ( int lin = 0; lin < lins; ++lin )
155 { 151 {
156 memcpy( (void*) &m_image[m_columns*lin], 152 memcpy( (void*) &m_image[m_columns*lin],
157 (void*) &oldimage[oldcolumns*lin], 153 (void*) &oldimage[oldcolumns*lin],
158 cols*sizeof( Character ) ); 154 cols*sizeof( Character ) );
159 } 155 }
160 } 156 }
161 else 157 else
162 clearImage(); 158 clearImage();
163 159
164 delete oldimage; 160 delete oldimage;
165 161
166 m_resizing = true; 162 m_resizing = true;
167 emit imageSizeChanged( m_lines, m_columns ); 163 emit imageSizeChanged( m_lines, m_columns );
168 m_resizing = false; 164 m_resizing = false;
169} 165}
170 166
171void WidgetLayer::makeImage() 167void WidgetLayer::makeImage()
172{ 168{
173 calcGeometry(); 169 calcGeometry();
174 m_image = QArray<Character>( m_columns * m_lines ); 170 m_image = QArray<Character>( m_columns * m_lines );
175 clearImage(); 171 clearImage();
176} 172}
177 173
178void WidgetLayer::clearImage() 174void WidgetLayer::clearImage()
179{ 175{
180 //should this belong here?? 176 //should this belong here??
181 for ( int y = 0; y < m_lines; y++ ) 177 for ( int y = 0; y < m_lines; y++ )
182 for ( int x = 0; x < m_columns; x++ ) 178 for ( int x = 0; x < m_columns; x++ )
183 { 179 {
184 m_image[loc(x,y)].c = 0xff; 180 m_image[loc(x,y)].c = 0xff;
185 m_image[loc(x,y)].f = 0xff; 181 m_image[loc(x,y)].f = 0xff;
186 m_image[loc(x,y)].b = 0xff; 182 m_image[loc(x,y)].b = 0xff;
187 m_image[loc(x,y)].r = 0xff; 183 m_image[loc(x,y)].r = 0xff;
188 } 184 }
189} 185}
190 186
191/* --------------------------------- selection ------------------------------ */ 187/* --------------------------------- selection ------------------------------ */
192 188
193void WidgetLayer::pasteClipboard() 189void WidgetLayer::pasteClipboard()
194{ 190{
195 insertSelection(); 191 insertSelection();
196} 192}
197 193
198 194
199void WidgetLayer::insertSelection() 195void WidgetLayer::insertSelection()
200{ 196{
201 QString text = QApplication::clipboard()->text(); 197 QString text = QApplication::clipboard()->text();
202 if ( ! text.isNull() ) 198 if ( ! text.isNull() )
203 { 199 {
204 text.replace( QRegExp( "\n" ), "\r" ); 200 text.replace( QRegExp( "\n" ), "\r" );
205 insertText( text ); 201 insertText( text );
206 // selection should be unselected 202 // selection should be unselected
207 emit selectionCleared(); 203 emit selectionCleared();
208 } 204 }
209} 205}
210 206
211void WidgetLayer::insertText( QString text ) 207void WidgetLayer::insertText( QString text )
212{ 208{
213 // text is inserted as key event 209 // text is inserted as key event
214 QKeyEvent e( QEvent::KeyPress, 0, -1, 0, text); 210 QKeyEvent e( QEvent::KeyPress, 0, -1, 0, text);
215 emit keyPressed( &e ); 211 emit keyPressed( &e );
216} 212}
217 213
218void WidgetLayer::onClearSelection() 214void WidgetLayer::onClearSelection()
219{ 215{
220 emit selectionCleared(); 216 emit selectionCleared();
221} 217}
222 218
223void WidgetLayer::setSelection( const QString& text ) 219void WidgetLayer::setSelection( const QString& text )
224{ 220{
225 // why get the clipboard, we have it as instance var... 221 // why get the clipboard, we have it as instance var...
226 QObject *m_clipboard = QApplication::clipboard(); 222 QObject *m_clipboard = QApplication::clipboard();
227 223
228 // we know, that cliboard changes, when we change clipboard 224 // we know, that cliboard changes, when we change clipboard
229 QObject::disconnect( (QObject*) m_clipboard, SIGNAL( dataChanged() ), 225 QObject::disconnect( (QObject*) m_clipboard, SIGNAL( dataChanged() ),
230 (QObject*) this, SLOT( selectionCleared() ) ); 226 (QObject*) this, SLOT( selectionCleared() ) );
231 227
232 QApplication::clipboard()->setText( text ); 228 QApplication::clipboard()->setText( text );
233 229
234 QObject::connect( (QObject*) m_clipboard, SIGNAL( dataChanged() ), 230 QObject::connect( (QObject*) m_clipboard, SIGNAL( dataChanged() ),
235 (QObject*) this, SLOT( selectionCleared() ) ); 231 (QObject*) this, SLOT( selectionCleared() ) );
236} 232}
237 233
238 234
239///////// 235/////////
240// special font characters 236// special font characters
241///////// 237/////////
242unsigned short vt100_graphics[32] = 238unsigned short vt100_graphics[32] =
243{ // 0/8 1/9 2/10 3/11 4/12 5/13 6/14 7/15 239{ // 0/8 1/9 2/10 3/11 4/12 5/13 6/14 7/15
244 0x0020, 0x25C6, 0x2592, 0x2409, 0x240c, 0x240d, 0x240a, 0x00b0, 240 0x0020, 0x25C6, 0x2592, 0x2409, 0x240c, 0x240d, 0x240a, 0x00b0,
245 0x00b1, 0x2424, 0x240b, 0x2518, 0x2510, 0x250c, 0x2514, 0x253c, 241 0x00b1, 0x2424, 0x240b, 0x2518, 0x2510, 0x250c, 0x2514, 0x253c,
246 0xF800, 0xF801, 0x2500, 0xF803, 0xF804, 0x251c, 0x2524, 0x2534, 242 0xF800, 0xF801, 0x2500, 0xF803, 0xF804, 0x251c, 0x2524, 0x2534,
247 0x252c, 0x2502, 0x2264, 0x2265, 0x03C0, 0x2260, 0x00A3, 0x00b7 243 0x252c, 0x2502, 0x2264, 0x2265, 0x03C0, 0x2260, 0x00A3, 0x00b7
248}; 244};
249 245