summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/embeddedkonsole/MyPty.cpp1
-rw-r--r--core/apps/embeddedkonsole/TEWidget.cpp9
-rw-r--r--core/apps/embeddedkonsole/TEmuVt102.cpp5
-rw-r--r--core/apps/embeddedkonsole/TEmulation.cpp3
-rw-r--r--core/apps/embeddedkonsole/commandeditdialog.cpp8
-rw-r--r--core/apps/embeddedkonsole/commandeditwidget.cpp4
-rw-r--r--core/apps/embeddedkonsole/keytrans.cpp3
-rw-r--r--core/apps/embeddedkonsole/konsole.cpp21
-rw-r--r--core/apps/embeddedkonsole/playlistselection.cpp7
-rw-r--r--core/apps/embeddedkonsole/session.cpp1
-rw-r--r--core/apps/helpbrowser/helpbrowser.cpp24
-rw-r--r--core/apps/helpbrowser/magictextbrowser.cpp2
-rw-r--r--core/apps/oapp/oappplugin.cpp3
-rw-r--r--core/apps/qcop/main.cpp2
-rw-r--r--core/apps/taboapp/main.cpp1
-rw-r--r--core/apps/textedit/filePermissions.cpp4
-rw-r--r--core/apps/textedit/textedit.cpp18
17 files changed, 2 insertions, 114 deletions
diff --git a/core/apps/embeddedkonsole/MyPty.cpp b/core/apps/embeddedkonsole/MyPty.cpp
index 5a8519a..d05e31e 100644
--- a/core/apps/embeddedkonsole/MyPty.cpp
+++ b/core/apps/embeddedkonsole/MyPty.cpp
@@ -1,289 +1,288 @@
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 <qfileinfo.h> 67#include <qfileinfo.h>
68#include <qapplication.h> 68#include <qapplication.h>
69#include <qsocketnotifier.h> 69#include <qsocketnotifier.h>
70#include <qstring.h>
71 70
72#include <stdlib.h> 71#include <stdlib.h>
73#include <stdio.h> 72#include <stdio.h>
74#include <signal.h> 73#include <signal.h>
75#include <fcntl.h> 74#include <fcntl.h>
76#include <unistd.h> 75#include <unistd.h>
77#include <termios.h> 76#include <termios.h>
78#include <sys/types.h> 77#include <sys/types.h>
79#include <sys/ioctl.h> 78#include <sys/ioctl.h>
80#include <sys/wait.h> 79#include <sys/wait.h>
81 80
82#ifdef HAVE_OPENPTY 81#ifdef HAVE_OPENPTY
83#include <pty.h> 82#include <pty.h>
84#endif 83#endif
85 84
86#include "MyPty.h" 85#include "MyPty.h"
87 86
88 87
89#undef VERBOSE_DEBUG 88#undef VERBOSE_DEBUG
90 89
91 90
92/* -------------------------------------------------------------------------- */ 91/* -------------------------------------------------------------------------- */
93 92
94/*! 93/*!
95 Informs the client program about the 94 Informs the client program about the
96 actual size of the window. 95 actual size of the window.
97*/ 96*/
98 97
99void MyPty::setSize(int lines, int columns) 98void MyPty::setSize(int lines, int columns)
100{ 99{
101 struct winsize wsize; 100 struct winsize wsize;
102 wsize.ws_row = (unsigned short)lines; 101 wsize.ws_row = (unsigned short)lines;
103 wsize.ws_col = (unsigned short)columns; 102 wsize.ws_col = (unsigned short)columns;
104 if(fd < 0) return; 103 if(fd < 0) return;
105 ioctl(fd,TIOCSWINSZ,(char *)&wsize); 104 ioctl(fd,TIOCSWINSZ,(char *)&wsize);
106} 105}
107 106
108 107
109void MyPty::donePty() 108void MyPty::donePty()
110{ 109{
111 // This is code from the Qt DumbTerminal example 110 // This is code from the Qt DumbTerminal example
112 int status = 0; 111 int status = 0;
113 112
114 ::close(fd); 113 ::close(fd);
115 114
116 if (cpid) { 115 if (cpid) {
117 kill(cpid, SIGHUP); 116 kill(cpid, SIGHUP);
118 waitpid(cpid, &status, 0); 117 waitpid(cpid, &status, 0);
119 } 118 }
120 119
121 emit done(status); 120 emit done(status);
122} 121}
123 122
124 123
125const char* MyPty::deviceName() 124const char* MyPty::deviceName()
126{ 125{
127 return ttynam; 126 return ttynam;
128} 127}
129 128
130 129
131void MyPty::error() 130void MyPty::error()
132{ 131{
133 // This is code from the Qt DumbTerminal example 132 // This is code from the Qt DumbTerminal example
134 donePty(); 133 donePty();
135} 134}
136 135
137 136
138/*! 137/*!
139 start the client program. 138 start the client program.
140*/ 139*/
141int MyPty::run(const char* cmd, QStrList &, const char*, int) 140int MyPty::run(const char* cmd, QStrList &, const char*, int)
142{ 141{
143 // This is code from the Qt DumbTerminal example 142 // This is code from the Qt DumbTerminal example
144 cpid = fork(); 143 cpid = fork();
145 144
146 if ( !cpid ) { 145 if ( !cpid ) {
147 // child - exec shell on tty 146 // child - exec shell on tty
148 for (int sig = 1; sig < NSIG; sig++) signal(sig,SIG_DFL); 147 for (int sig = 1; sig < NSIG; sig++) signal(sig,SIG_DFL);
149 148
150 // attempt to keep apm driver from killing us on power on/off 149 // attempt to keep apm driver from killing us on power on/off
151 signal(SIGSTOP, SIG_IGN); 150 signal(SIGSTOP, SIG_IGN);
152 signal(SIGCONT, SIG_IGN); 151 signal(SIGCONT, SIG_IGN);
153 signal(SIGTSTP, SIG_IGN); 152 signal(SIGTSTP, SIG_IGN);
154 153
155 int ttyfd = open(ttynam, O_RDWR); 154 int ttyfd = open(ttynam, O_RDWR);
156 dup2(ttyfd, STDIN_FILENO); 155 dup2(ttyfd, STDIN_FILENO);
157 dup2(ttyfd, STDOUT_FILENO); 156 dup2(ttyfd, STDOUT_FILENO);
158 dup2(ttyfd, STDERR_FILENO); 157 dup2(ttyfd, STDERR_FILENO);
159 // should be done with tty, so close it 158 // should be done with tty, so close it
160 close(ttyfd); 159 close(ttyfd);
161 static struct termios ttmode; 160 static struct termios ttmode;
162 if ( setsid() < 0 ) 161 if ( setsid() < 0 )
163 perror( "failed to set process group" ); 162 perror( "failed to set process group" );
164#if defined (TIOCSCTTY) 163#if defined (TIOCSCTTY)
165 // grabbed from APUE by Stevens 164 // grabbed from APUE by Stevens
166 ioctl(STDIN_FILENO, TIOCSCTTY, 0); 165 ioctl(STDIN_FILENO, TIOCSCTTY, 0);
167#endif 166#endif
168 tcgetattr( STDIN_FILENO, &ttmode ); 167 tcgetattr( STDIN_FILENO, &ttmode );
169 ttmode.c_cc[VINTR] = 3; 168 ttmode.c_cc[VINTR] = 3;
170 ttmode.c_cc[VERASE] = 8; 169 ttmode.c_cc[VERASE] = 8;
171 tcsetattr( STDIN_FILENO, TCSANOW, &ttmode ); 170 tcsetattr( STDIN_FILENO, TCSANOW, &ttmode );
172 setenv("TERM","vt100",1); 171 setenv("TERM","vt100",1);
173 setenv("COLORTERM","0",1); 172 setenv("COLORTERM","0",1);
174 173
175 if (getuid() == 0) { 174 if (getuid() == 0) {
176 char msg[] = "WARNING: You are running this shell as root!\n"; 175 char msg[] = "WARNING: You are running this shell as root!\n";
177 write(ttyfd, msg, sizeof(msg)); 176 write(ttyfd, msg, sizeof(msg));
178 } 177 }
179 178
180 QString ccmd = "-"+QFileInfo(cmd).fileName(); //creates a login shell 179 QString ccmd = "-"+QFileInfo(cmd).fileName(); //creates a login shell
181 180
182 execl(cmd, ccmd.latin1(), 0); 181 execl(cmd, ccmd.latin1(), 0);
183 182
184 donePty(); 183 donePty();
185 exit(-1); 184 exit(-1);
186 } 185 }
187 186
188 // parent - continue as a widget 187 // parent - continue as a widget
189 QSocketNotifier* sn_r = new QSocketNotifier(fd,QSocketNotifier::Read,this); 188 QSocketNotifier* sn_r = new QSocketNotifier(fd,QSocketNotifier::Read,this);
190 QSocketNotifier* sn_e = new QSocketNotifier(fd,QSocketNotifier::Exception,this); 189 QSocketNotifier* sn_e = new QSocketNotifier(fd,QSocketNotifier::Exception,this);
191 connect(sn_r,SIGNAL(activated(int)),this,SLOT(readPty())); 190 connect(sn_r,SIGNAL(activated(int)),this,SLOT(readPty()));
192 connect(sn_e,SIGNAL(activated(int)),this,SLOT(error())); 191 connect(sn_e,SIGNAL(activated(int)),this,SLOT(error()));
193 192
194 return 0; 193 return 0;
195} 194}
196 195
197int MyPty::openPty() 196int MyPty::openPty()
198{ 197{
199 // This is code from the Qt DumbTerminal example 198 // This is code from the Qt DumbTerminal example
200 int ptyfd = -1; 199 int ptyfd = -1;
201 200
202#ifdef HAVE_OPENPTY 201#ifdef HAVE_OPENPTY
203 int ttyfd; 202 int ttyfd;
204 if ( openpty(&ptyfd,&ttyfd,ttynam,0,0) ) 203 if ( openpty(&ptyfd,&ttyfd,ttynam,0,0) )
205 ptyfd = -1; 204 ptyfd = -1;
206 else 205 else
207 close(ttyfd); // we open the ttynam ourselves. 206 close(ttyfd); // we open the ttynam ourselves.
208#else 207#else
209 for (const char* c0 = "pqrstuvwxyzabcde"; ptyfd < 0 && *c0 != 0; c0++) { 208 for (const char* c0 = "pqrstuvwxyzabcde"; ptyfd < 0 && *c0 != 0; c0++) {
210 for (const char* c1 = "0123456789abcdef"; ptyfd < 0 && *c1 != 0; c1++) { 209 for (const char* c1 = "0123456789abcdef"; ptyfd < 0 && *c1 != 0; c1++) {
211 sprintf(ptynam,"/dev/pty%c%c",*c0,*c1); 210 sprintf(ptynam,"/dev/pty%c%c",*c0,*c1);
212 sprintf(ttynam,"/dev/tty%c%c",*c0,*c1); 211 sprintf(ttynam,"/dev/tty%c%c",*c0,*c1);
213 if ((ptyfd = ::open(ptynam,O_RDWR)) >= 0) { 212 if ((ptyfd = ::open(ptynam,O_RDWR)) >= 0) {
214 if (geteuid() != 0 && !access(ttynam,R_OK|W_OK) == 0) { 213 if (geteuid() != 0 && !access(ttynam,R_OK|W_OK) == 0) {
215 ::close(ptyfd); 214 ::close(ptyfd);
216 ptyfd = -1; 215 ptyfd = -1;
217 } 216 }
218 } 217 }
219 } 218 }
220 } 219 }
221#endif 220#endif
222 221
223 if ( ptyfd < 0 ) { 222 if ( ptyfd < 0 ) {
224 qApp->exit(1); 223 qApp->exit(1);
225 return -1; 224 return -1;
226 } 225 }
227 226
228 return ptyfd; 227 return ptyfd;
229} 228}
230 229
231/*! 230/*!
232 Create an instance. 231 Create an instance.
233*/ 232*/
234MyPty::MyPty() : cpid(0) 233MyPty::MyPty() : cpid(0)
235{ 234{
236 fd = openPty(); 235 fd = openPty();
237} 236}
238 237
239/*! 238/*!
240 Destructor. 239 Destructor.
241 Note that the related client program is not killed 240 Note that the related client program is not killed
242 (yet) when a instance is deleted. 241 (yet) when a instance is deleted.
243*/ 242*/
244MyPty::~MyPty() 243MyPty::~MyPty()
245{ 244{
246 donePty(); 245 donePty();
247} 246}
248 247
249 248
250/*! sends len bytes through the line */ 249/*! sends len bytes through the line */
251void MyPty::send_bytes(const char* s, int len) 250void MyPty::send_bytes(const char* s, int len)
252{ 251{
253 252
254#ifdef VERBOSE_DEBUG 253#ifdef VERBOSE_DEBUG
255 // verbose debug 254 // verbose debug
256 printf("sending bytes:\n"); 255 printf("sending bytes:\n");
257 for (int i = 0; i < len; i++) 256 for (int i = 0; i < len; i++)
258 printf("%c", s[i]); 257 printf("%c", s[i]);
259 printf("\n"); 258 printf("\n");
260#endif 259#endif
261 260
262 ::write(fd, s, len); 261 ::write(fd, s, len);
263} 262}
264 263
265/*! indicates that a block of data is received */ 264/*! indicates that a block of data is received */
266void MyPty::readPty() 265void MyPty::readPty()
267{ 266{
268 char buf[4096]; 267 char buf[4096];
269 268
270 int len = ::read( fd, buf, 4096 ); 269 int len = ::read( fd, buf, 4096 );
271 270
272 if (len == -1) 271 if (len == -1)
273 donePty(); 272 donePty();
274 273
275 if (len < 0) 274 if (len < 0)
276 return; 275 return;
277 276
278 emit block_in(buf,len); 277 emit block_in(buf,len);
279 278
280#ifdef VERBOSE_DEBUG 279#ifdef VERBOSE_DEBUG
281 // verbose debug 280 // verbose debug
282 printf("read bytes:\n"); 281 printf("read bytes:\n");
283 for (int i = 0; i < len; i++) 282 for (int i = 0; i < len; i++)
284 printf("%c", buf[i]); 283 printf("%c", buf[i]);
285 printf("\n"); 284 printf("\n");
286#endif 285#endif
287 286
288} 287}
289 288
diff --git a/core/apps/embeddedkonsole/TEWidget.cpp b/core/apps/embeddedkonsole/TEWidget.cpp
index de5e585..8206e4b 100644
--- a/core/apps/embeddedkonsole/TEWidget.cpp
+++ b/core/apps/embeddedkonsole/TEWidget.cpp
@@ -1,1433 +1,1424 @@
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" 52#include "session.h"
53#include <qpe/config.h> 53#include <qpe/config.h>
54 54
55#include <qpe/resource.h>
56#include <qpe/sound.h>
57 55
58#if !(QT_NO_COP) 56#if !(QT_NO_COP)
59#include <qpe/qcopenvelope_qws.h> 57#include <qpe/qcopenvelope_qws.h>
60#endif 58#endif
61 59
62#include <qcursor.h>
63#include <qregexp.h>
64#include <qpainter.h>
65#include <qclipboard.h> 60#include <qclipboard.h>
66#include <qstyle.h>
67#include <qfile.h>
68#include <qdragobject.h>
69#include <qnamespace.h>
70 61
71#include <stdio.h> 62#include <stdio.h>
72#include <stdlib.h> 63#include <stdlib.h>
73#include <unistd.h> 64#include <unistd.h>
74#include <ctype.h> 65#include <ctype.h>
75#include <sys/stat.h> 66#include <sys/stat.h>
76#include <sys/types.h> 67#include <sys/types.h>
77#include <signal.h> 68#include <signal.h>
78 69
79#include <assert.h> 70#include <assert.h>
80 71
81// #include "TEWidget.moc" 72// #include "TEWidget.moc"
82//#include <kapp.h> 73//#include <kapp.h>
83//#include <kcursor.h> 74//#include <kcursor.h>
84//#include <kurl.h> 75//#include <kurl.h>
85//#include <kdebug.h> 76//#include <kdebug.h>
86//#include <klocale.h> 77//#include <klocale.h>
87 78
88#define HERE printf("%s(%d): %s\n",__FILE__,__LINE__,__FUNCTION__) 79#define HERE printf("%s(%d): %s\n",__FILE__,__LINE__,__FUNCTION__)
89#define HCNT(Name) // { static int cnt = 1; printf("%s(%d): %s %d\n",__FILE__,__LINE__,Name,cnt++); } 80#define HCNT(Name) // { static int cnt = 1; printf("%s(%d): %s %d\n",__FILE__,__LINE__,Name,cnt++); }
90 81
91#define loc(X,Y) ((Y)*columns+(X)) 82#define loc(X,Y) ((Y)*columns+(X))
92 83
93//FIXME: the rim should normally be 1, 0 only when running in full screen mode. 84//FIXME: the rim should normally be 1, 0 only when running in full screen mode.
94#define rimX 0 // left/right rim width 85#define rimX 0 // left/right rim width
95#define rimY 0 // top/bottom rim high 86#define rimY 0 // top/bottom rim high
96 87
97#define SCRWIDTH 16 // width of the scrollbar 88#define SCRWIDTH 16 // width of the scrollbar
98 89
99#define yMouseScroll 1 90#define yMouseScroll 1
100// scroll increment used when dragging selection at top/bottom of window. 91// scroll increment used when dragging selection at top/bottom of window.
101 92
102/* ------------------------------------------------------------------------- */ 93/* ------------------------------------------------------------------------- */
103/* */ 94/* */
104/* Colors */ 95/* Colors */
105/* */ 96/* */
106/* ------------------------------------------------------------------------- */ 97/* ------------------------------------------------------------------------- */
107 98
108//FIXME: the default color table is in session.C now. 99//FIXME: the default color table is in session.C now.
109// We need a way to get rid of this one, here. 100// We need a way to get rid of this one, here.
110static const ColorEntry base_color_table[TABLE_COLORS] = 101static const ColorEntry base_color_table[TABLE_COLORS] =
111// The following are almost IBM standard color codes, with some slight 102// The following are almost IBM standard color codes, with some slight
112// gamma correction for the dim colors to compensate for bright X screens. 103// gamma correction for the dim colors to compensate for bright X screens.
113// It contains the 8 ansiterm/xterm colors in 2 intensities. 104// It contains the 8 ansiterm/xterm colors in 2 intensities.
114{ 105{
115 // Fixme: could add faint colors here, also. 106 // Fixme: could add faint colors here, also.
116 // normal 107 // normal
117 ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 1, 0 ), // Dfore, Dback 108 ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 1, 0 ), // Dfore, Dback
118 ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0x18), 0, 0 ), // Black, Red 109 ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0x18), 0, 0 ), // Black, Red
119 ColorEntry(QColor(0x18,0xB2,0x18), 0, 0 ), ColorEntry( QColor(0xB2,0x68,0x18), 0, 0 ), // Green, Yellow 110 ColorEntry(QColor(0x18,0xB2,0x18), 0, 0 ), ColorEntry( QColor(0xB2,0x68,0x18), 0, 0 ), // Green, Yellow
120 ColorEntry(QColor(0x18,0x18,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), // Blue, Magenta 111 ColorEntry(QColor(0x18,0x18,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), // Blue, Magenta
121 ColorEntry(QColor(0x18,0xB2,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 0, 0 ), // Cyan, White 112 ColorEntry(QColor(0x18,0xB2,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 0, 0 ), // Cyan, White
122 // intensiv 113 // intensiv
123 ColorEntry(QColor(0x00,0x00,0x00), 0, 1 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 1, 0 ), 114 ColorEntry(QColor(0x00,0x00,0x00), 0, 1 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 1, 0 ),
124 ColorEntry(QColor(0x68,0x68,0x68), 0, 0 ), ColorEntry( QColor(0xFF,0x54,0x54), 0, 0 ), 115 ColorEntry(QColor(0x68,0x68,0x68), 0, 0 ), ColorEntry( QColor(0xFF,0x54,0x54), 0, 0 ),
125 ColorEntry(QColor(0x54,0xFF,0x54), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0x54), 0, 0 ), 116 ColorEntry(QColor(0x54,0xFF,0x54), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0x54), 0, 0 ),
126 ColorEntry(QColor(0x54,0x54,0xFF), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), 117 ColorEntry(QColor(0x54,0x54,0xFF), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ),
127 ColorEntry(QColor(0x54,0xFF,0xFF), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 0, 0 ) 118 ColorEntry(QColor(0x54,0xFF,0xFF), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 0, 0 )
128}; 119};
129 120
130/* Note that we use ANSI color order (bgr), while IBMPC color order is (rgb) 121/* Note that we use ANSI color order (bgr), while IBMPC color order is (rgb)
131 122
132 Code 0 1 2 3 4 5 6 7 123 Code 0 1 2 3 4 5 6 7
133 ----------- ------- ------- ------- ------- ------- ------- ------- ------- 124 ----------- ------- ------- ------- ------- ------- ------- ------- -------
134 ANSI (bgr) Black Red Green Yellow Blue Magenta Cyan White 125 ANSI (bgr) Black Red Green Yellow Blue Magenta Cyan White
135 IBMPC (rgb) Black Blue Green Cyan Red Magenta Yellow White 126 IBMPC (rgb) Black Blue Green Cyan Red Magenta Yellow White
136*/ 127*/
137 128
138QColor TEWidget::getDefaultBackColor() 129QColor TEWidget::getDefaultBackColor()
139{ 130{
140 return color_table[DEFAULT_BACK_COLOR].color; 131 return color_table[DEFAULT_BACK_COLOR].color;
141} 132}
142 133
143const ColorEntry* TEWidget::getColorTable() const 134const ColorEntry* TEWidget::getColorTable() const
144{ 135{
145 return color_table; 136 return color_table;
146} 137}
147 138
148const ColorEntry* TEWidget::getdefaultColorTable() const 139const ColorEntry* TEWidget::getdefaultColorTable() const
149{ 140{
150 return base_color_table; 141 return base_color_table;
151} 142}
152 143
153 144
154const QPixmap *TEWidget::backgroundPixmap() 145const QPixmap *TEWidget::backgroundPixmap()
155{ 146{
156 static QPixmap *bg = new QPixmap("~/qpim/main/pics/faded_bg.xpm"); 147 static QPixmap *bg = new QPixmap("~/qpim/main/pics/faded_bg.xpm");
157 const QPixmap *pm = bg; 148 const QPixmap *pm = bg;
158 return pm; 149 return pm;
159} 150}
160 151
161void TEWidget::setColorTable(const ColorEntry table[]) 152void TEWidget::setColorTable(const ColorEntry table[])
162{ 153{
163 for (int i = 0; i < TABLE_COLORS; i++) color_table[i] = table[i]; 154 for (int i = 0; i < TABLE_COLORS; i++) color_table[i] = table[i];
164 155
165 const QPixmap* pm = backgroundPixmap(); 156 const QPixmap* pm = backgroundPixmap();
166 if (!pm) setBackgroundColor(color_table[DEFAULT_BACK_COLOR].color); 157 if (!pm) setBackgroundColor(color_table[DEFAULT_BACK_COLOR].color);
167 update(); 158 update();
168} 159}
169 160
170//FIXME: add backgroundPixmapChanged. 161//FIXME: add backgroundPixmapChanged.
171 162
172/* ------------------------------------------------------------------------- */ 163/* ------------------------------------------------------------------------- */
173/* */ 164/* */
174/* Font */ 165/* Font */
175/* */ 166/* */
176/* ------------------------------------------------------------------------- */ 167/* ------------------------------------------------------------------------- */
177 168
178/* 169/*
179 The VT100 has 32 special graphical characters. The usual vt100 extended 170 The VT100 has 32 special graphical characters. The usual vt100 extended
180 xterm fonts have these at 0x00..0x1f. 171 xterm fonts have these at 0x00..0x1f.
181 172
182 QT's iso mapping leaves 0x00..0x7f without any changes. But the graphicals 173 QT's iso mapping leaves 0x00..0x7f without any changes. But the graphicals
183 come in here as proper unicode characters. 174 come in here as proper unicode characters.
184 175
185 We treat non-iso10646 fonts as VT100 extended and do the requiered mapping 176 We treat non-iso10646 fonts as VT100 extended and do the requiered mapping
186 from unicode to 0x00..0x1f. The remaining translation is then left to the 177 from unicode to 0x00..0x1f. The remaining translation is then left to the
187 QCodec. 178 QCodec.
188*/ 179*/
189 180
190// assert for i in [0..31] : vt100extended(vt100_graphics[i]) == i. 181// assert for i in [0..31] : vt100extended(vt100_graphics[i]) == i.
191 182
192unsigned short vt100_graphics[32] = 183unsigned short vt100_graphics[32] =
193{ // 0/8 1/9 2/10 3/11 4/12 5/13 6/14 7/15 184{ // 0/8 1/9 2/10 3/11 4/12 5/13 6/14 7/15
194 0x0020, 0x25C6, 0x2592, 0x2409, 0x240c, 0x240d, 0x240a, 0x00b0, 185 0x0020, 0x25C6, 0x2592, 0x2409, 0x240c, 0x240d, 0x240a, 0x00b0,
195 0x00b1, 0x2424, 0x240b, 0x2518, 0x2510, 0x250c, 0x2514, 0x253c, 186 0x00b1, 0x2424, 0x240b, 0x2518, 0x2510, 0x250c, 0x2514, 0x253c,
196 0xF800, 0xF801, 0x2500, 0xF803, 0xF804, 0x251c, 0x2524, 0x2534, 187 0xF800, 0xF801, 0x2500, 0xF803, 0xF804, 0x251c, 0x2524, 0x2534,
197 0x252c, 0x2502, 0x2264, 0x2265, 0x03C0, 0x2260, 0x00A3, 0x00b7 188 0x252c, 0x2502, 0x2264, 0x2265, 0x03C0, 0x2260, 0x00A3, 0x00b7
198}; 189};
199 190
200static QChar vt100extended(QChar c) 191static QChar vt100extended(QChar c)
201{ 192{
202 switch (c.unicode()) 193 switch (c.unicode())
203 { 194 {
204 case 0x25c6 : return 1; 195 case 0x25c6 : return 1;
205 case 0x2592 : return 2; 196 case 0x2592 : return 2;
206 case 0x2409 : return 3; 197 case 0x2409 : return 3;
207 case 0x240c : return 4; 198 case 0x240c : return 4;
208 case 0x240d : return 5; 199 case 0x240d : return 5;
209 case 0x240a : return 6; 200 case 0x240a : return 6;
210 case 0x00b0 : return 7; 201 case 0x00b0 : return 7;
211 case 0x00b1 : return 8; 202 case 0x00b1 : return 8;
212 case 0x2424 : return 9; 203 case 0x2424 : return 9;
213 case 0x240b : return 10; 204 case 0x240b : return 10;
214 case 0x2518 : return 11; 205 case 0x2518 : return 11;
215 case 0x2510 : return 12; 206 case 0x2510 : return 12;
216 case 0x250c : return 13; 207 case 0x250c : return 13;
217 case 0x2514 : return 14; 208 case 0x2514 : return 14;
218 case 0x253c : return 15; 209 case 0x253c : return 15;
219 case 0xf800 : return 16; 210 case 0xf800 : return 16;
220 case 0xf801 : return 17; 211 case 0xf801 : return 17;
221 case 0x2500 : return 18; 212 case 0x2500 : return 18;
222 case 0xf803 : return 19; 213 case 0xf803 : return 19;
223 case 0xf804 : return 20; 214 case 0xf804 : return 20;
224 case 0x251c : return 21; 215 case 0x251c : return 21;
225 case 0x2524 : return 22; 216 case 0x2524 : return 22;
226 case 0x2534 : return 23; 217 case 0x2534 : return 23;
227 case 0x252c : return 24; 218 case 0x252c : return 24;
228 case 0x2502 : return 25; 219 case 0x2502 : return 25;
229 case 0x2264 : return 26; 220 case 0x2264 : return 26;
230 case 0x2265 : return 27; 221 case 0x2265 : return 27;
231 case 0x03c0 : return 28; 222 case 0x03c0 : return 28;
232 case 0x2260 : return 29; 223 case 0x2260 : return 29;
233 case 0x00a3 : return 30; 224 case 0x00a3 : return 30;
234 case 0x00b7 : return 31; 225 case 0x00b7 : return 31;
235 } 226 }
236 return c; 227 return c;
237} 228}
238 229
239static QChar identicalMap(QChar c) 230static QChar identicalMap(QChar c)
240{ 231{
241 return c; 232 return c;
242} 233}
243 234
244void TEWidget::fontChange(const QFont &) 235void TEWidget::fontChange(const QFont &)
245{ 236{
246 QFontMetrics fm(font()); 237 QFontMetrics fm(font());
247 font_h = fm.height(); 238 font_h = fm.height();
248 // font_w = fm.maxWidth(); 239 // font_w = fm.maxWidth();
249 font_w = fm.width("m"); 240 font_w = fm.width("m");
250 font_a = fm.ascent(); 241 font_a = fm.ascent();
251 printf("font h=%d max_width=%d width_m=%d assent=%d\n", font_h, 242 printf("font h=%d max_width=%d width_m=%d assent=%d\n", font_h,
252 fm.maxWidth(), font_w, font_a); 243 fm.maxWidth(), font_w, font_a);
253 244
254 //printf("font_h: %d\n",font_h); 245 //printf("font_h: %d\n",font_h);
255 //printf("font_w: %d\n",font_w); 246 //printf("font_w: %d\n",font_w);
256 //printf("font_a: %d\n",font_a); 247 //printf("font_a: %d\n",font_a);
257 //printf("charset: %s\n",QFont::encodingName(font().charSet()).ascii()); 248 //printf("charset: %s\n",QFont::encodingName(font().charSet()).ascii());
258 //printf("rawname: %s\n",font().rawName().ascii()); 249 //printf("rawname: %s\n",font().rawName().ascii());
259 fontMap = 250 fontMap =
260#if QT_VERSION < 300 251#if QT_VERSION < 300
261 strcmp(QFont::encodingName(font().charSet()).ascii(),"iso10646") 252 strcmp(QFont::encodingName(font().charSet()).ascii(),"iso10646")
262 ? vt100extended 253 ? vt100extended
263 : 254 :
264#endif 255#endif
265 identicalMap; 256 identicalMap;
266 propagateSize(); 257 propagateSize();
267 update(); 258 update();
268} 259}
269 260
270void TEWidget::setVTFont(const QFont& f) 261void TEWidget::setVTFont(const QFont& f)
271{ 262{
272 QFrame::setFont(f); 263 QFrame::setFont(f);
273} 264}
274 265
275QFont TEWidget::getVTFont() { 266QFont TEWidget::getVTFont() {
276 return font(); 267 return font();
277} 268}
278 269
279void TEWidget::setFont(const QFont &) 270void TEWidget::setFont(const QFont &)
280{ 271{
281 // ignore font change request if not coming from konsole itself 272 // ignore font change request if not coming from konsole itself
282} 273}
283 274
284/* ------------------------------------------------------------------------- */ 275/* ------------------------------------------------------------------------- */
285/* */ 276/* */
286/* Constructor / Destructor */ 277/* Constructor / Destructor */
287/* */ 278/* */
288/* ------------------------------------------------------------------------- */ 279/* ------------------------------------------------------------------------- */
289 280
290TEWidget::TEWidget(QWidget *parent, const char *name) : QFrame(parent,name) 281TEWidget::TEWidget(QWidget *parent, const char *name) : QFrame(parent,name)
291{ 282{
292#ifndef QT_NO_CLIPBOARD 283#ifndef QT_NO_CLIPBOARD
293 cb = QApplication::clipboard(); 284 cb = QApplication::clipboard();
294 QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), 285 QObject::connect( (QObject*)cb, SIGNAL(dataChanged()),
295 this, SLOT(onClearSelection()) ); 286 this, SLOT(onClearSelection()) );
296#endif 287#endif
297 288
298 scrollbar = new QScrollBar(this); 289 scrollbar = new QScrollBar(this);
299 scrollbar->setCursor( arrowCursor ); 290 scrollbar->setCursor( arrowCursor );
300 connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); 291 connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int)));
301 292
302 hScrollbar = new QScrollBar(this); 293 hScrollbar = new QScrollBar(this);
303 hScrollbar->setCursor( arrowCursor ); 294 hScrollbar->setCursor( arrowCursor );
304 hScrollbar->setOrientation(QScrollBar::Horizontal); 295 hScrollbar->setOrientation(QScrollBar::Horizontal);
305 // hScrollbar->setMaximumHeight(16); 296 // hScrollbar->setMaximumHeight(16);
306 297
307 connect( hScrollbar, SIGNAL(valueChanged(int)), this, SLOT( hScrollChanged(int))); 298 connect( hScrollbar, SIGNAL(valueChanged(int)), this, SLOT( hScrollChanged(int)));
308 299
309 Config cfg( "Konsole" ); 300 Config cfg( "Konsole" );
310 cfg.setGroup("ScrollBar"); 301 cfg.setGroup("ScrollBar");
311 switch( cfg.readNumEntry("Position",2)){ 302 switch( cfg.readNumEntry("Position",2)){
312 case 0: 303 case 0:
313 scrollLoc = SCRNONE; 304 scrollLoc = SCRNONE;
314 break; 305 break;
315 case 1: 306 case 1:
316 scrollLoc = SCRLEFT; 307 scrollLoc = SCRLEFT;
317 break; 308 break;
318 case 2: 309 case 2:
319 scrollLoc = SCRRIGHT; 310 scrollLoc = SCRRIGHT;
320 break; 311 break;
321 }; 312 };
322 313
323 useHorzScroll=cfg.readBoolEntry("HorzScroll",0); 314 useHorzScroll=cfg.readBoolEntry("HorzScroll",0);
324 315
325 blinkT = new QTimer(this); 316 blinkT = new QTimer(this);
326 connect(blinkT, SIGNAL(timeout()), this, SLOT(blinkEvent())); 317 connect(blinkT, SIGNAL(timeout()), this, SLOT(blinkEvent()));
327 // blinking = FALSE; 318 // blinking = FALSE;
328 blinking = TRUE; 319 blinking = TRUE;
329 320
330 resizing = FALSE; 321 resizing = FALSE;
331 actSel = 0; 322 actSel = 0;
332 image = 0; 323 image = 0;
333 lines = 1; 324 lines = 1;
334 columns = 1; 325 columns = 1;
335 font_w = 1; 326 font_w = 1;
336 font_h = 1; 327 font_h = 1;
337 font_a = 1; 328 font_a = 1;
338 word_selection_mode = FALSE; 329 word_selection_mode = FALSE;
339 hposition = 0; 330 hposition = 0;
340 vcolumns = 0; 331 vcolumns = 0;
341 useBeep = true; 332 useBeep = true;
342 333
343 setMouseMarks(TRUE); 334 setMouseMarks(TRUE);
344 setVTFont( QFont("fixed") ); 335 setVTFont( QFont("fixed") );
345 setColorTable(base_color_table); // init color table 336 setColorTable(base_color_table); // init color table
346 337
347 qApp->installEventFilter( this ); //FIXME: see below 338 qApp->installEventFilter( this ); //FIXME: see below
348// KCursor::setAutoHideCursor( this, true ); 339// KCursor::setAutoHideCursor( this, true );
349 340
350 // Init DnD //////////////////////////////////////////////////////////////// 341 // Init DnD ////////////////////////////////////////////////////////////////
351 currentSession = NULL; 342 currentSession = NULL;
352// setAcceptDrops(true); // attempt 343// setAcceptDrops(true); // attempt
353// m_drop = new QPopupMenu(this); 344// m_drop = new QPopupMenu(this);
354// m_drop->insertItem( QString("Paste"), 0); 345// m_drop->insertItem( QString("Paste"), 0);
355// m_drop->insertItem( QString("cd"), 1); 346// m_drop->insertItem( QString("cd"), 1);
356// connect(m_drop, SIGNAL(activated(int)), SLOT(drop_menu_activated(int))); 347// connect(m_drop, SIGNAL(activated(int)), SLOT(drop_menu_activated(int)));
357 348
358 // we need focus so that the auto-hide cursor feature works 349 // we need focus so that the auto-hide cursor feature works
359 setFocus(); 350 setFocus();
360 setFocusPolicy( WheelFocus ); 351 setFocusPolicy( WheelFocus );
361} 352}
362 353
363//FIXME: make proper destructor 354//FIXME: make proper destructor
364// Here's a start (David) 355// Here's a start (David)
365TEWidget::~TEWidget() 356TEWidget::~TEWidget()
366{ 357{
367 qApp->removeEventFilter( this ); 358 qApp->removeEventFilter( this );
368 if (image) free(image); 359 if (image) free(image);
369} 360}
370 361
371/* ------------------------------------------------------------------------- */ 362/* ------------------------------------------------------------------------- */
372/* */ 363/* */
373/* Display Operations */ 364/* Display Operations */
374/* */ 365/* */
375/* ------------------------------------------------------------------------- */ 366/* ------------------------------------------------------------------------- */
376 367
377/*! 368/*!
378 attributed string draw primitive 369 attributed string draw primitive
379*/ 370*/
380 371
381void TEWidget::drawAttrStr(QPainter &paint, QRect rect, 372void TEWidget::drawAttrStr(QPainter &paint, QRect rect,
382 QString& str, ca attr, BOOL pm, BOOL clear) 373 QString& str, ca attr, BOOL pm, BOOL clear)
383{ 374{
384 if (pm && color_table[attr.b].transparent) 375 if (pm && color_table[attr.b].transparent)
385 { 376 {
386 paint.setBackgroundMode( TransparentMode ); 377 paint.setBackgroundMode( TransparentMode );
387 if (clear) erase(rect); 378 if (clear) erase(rect);
388 } 379 }
389 else 380 else
390 { 381 {
391 if (blinking) 382 if (blinking)
392 paint.fillRect(rect, color_table[attr.b].color); 383 paint.fillRect(rect, color_table[attr.b].color);
393 else 384 else
394 { 385 {
395 paint.setBackgroundMode( OpaqueMode ); 386 paint.setBackgroundMode( OpaqueMode );
396 paint.setBackgroundColor( color_table[attr.b].color ); 387 paint.setBackgroundColor( color_table[attr.b].color );
397 } 388 }
398 } 389 }
399 390
400 if (color_table[attr.f].bold) 391 if (color_table[attr.f].bold)
401 paint.setPen(QColor( 0x8F, 0x00, 0x00 )); 392 paint.setPen(QColor( 0x8F, 0x00, 0x00 ));
402 else 393 else
403 paint.setPen(color_table[attr.f].color); 394 paint.setPen(color_table[attr.f].color);
404 395
405 paint.drawText(rect.x(),rect.y()+font_a, str); 396 paint.drawText(rect.x(),rect.y()+font_a, str);
406 397
407 if (attr.r & RE_UNDERLINE) 398 if (attr.r & RE_UNDERLINE)
408 paint.drawLine(rect.left(), rect.y()+font_a+1, rect.right(),rect.y()+font_a+1 ); 399 paint.drawLine(rect.left(), rect.y()+font_a+1, rect.right(),rect.y()+font_a+1 );
409} 400}
410 401
411/*! 402/*!
412 The image can only be set completely. 403 The image can only be set completely.
413 404
414 The size of the new image may or may not match the size of the widget. 405 The size of the new image may or may not match the size of the widget.
415*/ 406*/
416 407
417void TEWidget::setImage(const ca* const newimg, int lines, int columns) 408void TEWidget::setImage(const ca* const newimg, int lines, int columns)
418{ int y,x,len; 409{ int y,x,len;
419 const QPixmap* pm = backgroundPixmap(); 410 const QPixmap* pm = backgroundPixmap();
420 QPainter paint; 411 QPainter paint;
421 setUpdatesEnabled(FALSE); 412 setUpdatesEnabled(FALSE);
422 paint.begin( this ); 413 paint.begin( this );
423HCNT("setImage"); 414HCNT("setImage");
424 415
425 QPoint tL = contentsRect().topLeft(); 416 QPoint tL = contentsRect().topLeft();
426 int tLx = tL.x(); 417 int tLx = tL.x();
427 int tLy = tL.y(); 418 int tLy = tL.y();
428 hasBlinker = FALSE; 419 hasBlinker = FALSE;
429 420
430 int cf = -1; // undefined 421 int cf = -1; // undefined
431 int cb = -1; // undefined 422 int cb = -1; // undefined
432 int cr = -1; // undefined 423 int cr = -1; // undefined
433 424
434 int lins = QMIN(this->lines, QMAX(0,lines )); 425 int lins = QMIN(this->lines, QMAX(0,lines ));
435 int cols = QMIN(this->columns,QMAX(0,columns)); 426 int cols = QMIN(this->columns,QMAX(0,columns));
436 QChar *disstrU = new QChar[cols]; 427 QChar *disstrU = new QChar[cols];
437 for (y = 0; y < lins; y++) { 428 for (y = 0; y < lins; y++) {
438 const ca* lcl = &image[y*this->columns]; 429 const ca* lcl = &image[y*this->columns];
439 const ca* const ext = &newimg[y*columns]; 430 const ca* const ext = &newimg[y*columns];
440 if (!resizing) // not while resizing, we're expecting a paintEvent 431 if (!resizing) // not while resizing, we're expecting a paintEvent
441 for (x = 0; x < cols; x++) 432 for (x = 0; x < cols; x++)
442 { 433 {
443 hasBlinker |= (ext[x].r & RE_BLINK); 434 hasBlinker |= (ext[x].r & RE_BLINK);
444 if (ext[x] != lcl[x]) 435 if (ext[x] != lcl[x])
445 { 436 {
446 cr = ext[x].r; 437 cr = ext[x].r;
447 cb = ext[x].b; 438 cb = ext[x].b;
448 if (ext[x].f != cf) cf = ext[x].f; 439 if (ext[x].f != cf) cf = ext[x].f;
449 int lln = cols - x; 440 int lln = cols - x;
450 disstrU[0] = fontMap(ext[x+0].c); 441 disstrU[0] = fontMap(ext[x+0].c);
451 for (len = 1; len < lln; len++) 442 for (len = 1; len < lln; len++)
452 { 443 {
453 if (ext[x+len].f != cf || ext[x+len].b != cb || ext[x+len].r != cr || 444 if (ext[x+len].f != cf || ext[x+len].b != cb || ext[x+len].r != cr ||
454 ext[x+len] == lcl[x+len] ) 445 ext[x+len] == lcl[x+len] )
455 break; 446 break;
456 disstrU[len] = fontMap(ext[x+len].c); 447 disstrU[len] = fontMap(ext[x+len].c);
457 } 448 }
458 QString unistr(disstrU,len); 449 QString unistr(disstrU,len);
459 drawAttrStr(paint, 450 drawAttrStr(paint,
460 QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h), 451 QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h),
461 unistr, ext[x], pm != NULL, true); 452 unistr, ext[x], pm != NULL, true);
462 x += len - 1; 453 x += len - 1;
463 } 454 }
464 } 455 }
465 // finally, make `image' become `newimg'. 456 // finally, make `image' become `newimg'.
466 memcpy((void*)lcl,(const void*)ext,cols*sizeof(ca)); 457 memcpy((void*)lcl,(const void*)ext,cols*sizeof(ca));
467 } 458 }
468 drawFrame( &paint ); 459 drawFrame( &paint );
469 paint.end(); 460 paint.end();
470 setUpdatesEnabled(TRUE); 461 setUpdatesEnabled(TRUE);
471 if ( hasBlinker && !blinkT->isActive()) blinkT->start(1000); // 1000 ms 462 if ( hasBlinker && !blinkT->isActive()) blinkT->start(1000); // 1000 ms
472 if (!hasBlinker && blinkT->isActive()) { blinkT->stop(); blinking = FALSE; } 463 if (!hasBlinker && blinkT->isActive()) { blinkT->stop(); blinking = FALSE; }
473 delete [] disstrU; 464 delete [] disstrU;
474} 465}
475 466
476// paint Event //////////////////////////////////////////////////// 467// paint Event ////////////////////////////////////////////////////
477 468
478/*! 469/*!
479 The difference of this routine vs. the `setImage' is, 470 The difference of this routine vs. the `setImage' is,
480 that the drawing does not include a difference analysis 471 that the drawing does not include a difference analysis
481 between the old and the new image. Instead, the internal 472 between the old and the new image. Instead, the internal
482 image is used and the painting bound by the PaintEvent box. 473 image is used and the painting bound by the PaintEvent box.
483*/ 474*/
484 475
485void TEWidget::paintEvent( QPaintEvent* pe ) 476void TEWidget::paintEvent( QPaintEvent* pe )
486{ 477{
487 478
488//{ static int cnt = 0; printf("paint %d\n",cnt++); } 479//{ static int cnt = 0; printf("paint %d\n",cnt++); }
489 const QPixmap* pm = backgroundPixmap(); 480 const QPixmap* pm = backgroundPixmap();
490 QPainter paint; 481 QPainter paint;
491 setUpdatesEnabled(FALSE); 482 setUpdatesEnabled(FALSE);
492 paint.begin( this ); 483 paint.begin( this );
493 paint.setBackgroundMode( TransparentMode ); 484 paint.setBackgroundMode( TransparentMode );
494HCNT("paintEvent"); 485HCNT("paintEvent");
495 486
496 // Note that the actual widget size can be slightly larger 487 // Note that the actual widget size can be slightly larger
497 // that the image (the size is truncated towards the smaller 488 // that the image (the size is truncated towards the smaller
498 // number of characters in `resizeEvent'. The paint rectangle 489 // number of characters in `resizeEvent'. The paint rectangle
499 // can thus be larger than the image, but less then the size 490 // can thus be larger than the image, but less then the size
500 // of one character. 491 // of one character.
501 492
502 QRect rect = pe->rect().intersect(contentsRect()); 493 QRect rect = pe->rect().intersect(contentsRect());
503 494
504 QPoint tL = contentsRect().topLeft(); 495 QPoint tL = contentsRect().topLeft();
505 int tLx = tL.x(); 496 int tLx = tL.x();
506 int tLy = tL.y(); 497 int tLy = tL.y();
507 498
508 int lux = QMIN(columns-1, QMAX(0,(rect.left() - tLx - blX ) / font_w)); 499 int lux = QMIN(columns-1, QMAX(0,(rect.left() - tLx - blX ) / font_w));
509 int luy = QMIN(lines-1, QMAX(0,(rect.top() - tLy - bY ) / font_h)); 500 int luy = QMIN(lines-1, QMAX(0,(rect.top() - tLy - bY ) / font_h));
510 int rlx = QMIN(columns-1, QMAX(0,(rect.right() - tLx - blX ) / font_w)); 501 int rlx = QMIN(columns-1, QMAX(0,(rect.right() - tLx - blX ) / font_w));
511 int rly = QMIN(lines-1, QMAX(0,(rect.bottom() - tLy - bY ) / font_h)); 502 int rly = QMIN(lines-1, QMAX(0,(rect.bottom() - tLy - bY ) / font_h));
512 503
513 /* 504 /*
514 printf("paintEvent: %d..%d, %d..%d (%d..%d, %d..%d)\n",lux,rlx,luy,rly, 505 printf("paintEvent: %d..%d, %d..%d (%d..%d, %d..%d)\n",lux,rlx,luy,rly,
515 rect.left(), rect.right(), rect.top(), rect.bottom()); 506 rect.left(), rect.right(), rect.top(), rect.bottom());
516 */ 507 */
517 508
518 // if (pm != NULL && color_table[image->b].transparent) 509 // if (pm != NULL && color_table[image->b].transparent)
519 // erase(rect); 510 // erase(rect);
520 // BL: I have no idea why we need this, and it breaks the refresh. 511 // BL: I have no idea why we need this, and it breaks the refresh.
521 512
522 QChar *disstrU = new QChar[columns]; 513 QChar *disstrU = new QChar[columns];
523 for (int y = luy; y <= rly; y++) 514 for (int y = luy; y <= rly; y++)
524 for (int x = lux; x <= rlx; x++) 515 for (int x = lux; x <= rlx; x++)
525 { 516 {
526 int len = 1; 517 int len = 1;
527 disstrU[0] = fontMap(image[loc(x,y)].c); 518 disstrU[0] = fontMap(image[loc(x,y)].c);
528 int cf = image[loc(x,y)].f; 519 int cf = image[loc(x,y)].f;
529 int cb = image[loc(x,y)].b; 520 int cb = image[loc(x,y)].b;
530 int cr = image[loc(x,y)].r; 521 int cr = image[loc(x,y)].r;
531 while (x+len <= rlx && 522 while (x+len <= rlx &&
532 image[loc(x+len,y)].f == cf && 523 image[loc(x+len,y)].f == cf &&
533 image[loc(x+len,y)].b == cb && 524 image[loc(x+len,y)].b == cb &&
534 image[loc(x+len,y)].r == cr ) 525 image[loc(x+len,y)].r == cr )
535 { 526 {
536 disstrU[len] = fontMap(image[loc(x+len,y)].c); 527 disstrU[len] = fontMap(image[loc(x+len,y)].c);
537 len += 1; 528 len += 1;
538 } 529 }
539 QString unistr(disstrU,len); 530 QString unistr(disstrU,len);
540 drawAttrStr(paint, 531 drawAttrStr(paint,
541 QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h), 532 QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h),
542 unistr, image[loc(x,y)], pm != NULL, false); 533 unistr, image[loc(x,y)], pm != NULL, false);
543 x += len - 1; 534 x += len - 1;
544 } 535 }
545 delete [] disstrU; 536 delete [] disstrU;
546 drawFrame( &paint ); 537 drawFrame( &paint );
547 paint.end(); 538 paint.end();
548 setUpdatesEnabled(TRUE); 539 setUpdatesEnabled(TRUE);
549} 540}
550 541
551void TEWidget::blinkEvent() 542void TEWidget::blinkEvent()
552{ 543{
553 blinking = !blinking; 544 blinking = !blinking;
554 repaint(FALSE); 545 repaint(FALSE);
555} 546}
556 547
557/* ------------------------------------------------------------------------- */ 548/* ------------------------------------------------------------------------- */
558/* */ 549/* */
559/* Resizing */ 550/* Resizing */
560/* */ 551/* */
561/* ------------------------------------------------------------------------- */ 552/* ------------------------------------------------------------------------- */
562 553
563void TEWidget::resizeEvent(QResizeEvent* ev) 554void TEWidget::resizeEvent(QResizeEvent* ev)
564{ 555{
565// printf("resize: %d,%d\n",ev->size().width(),ev->size().height()); 556// printf("resize: %d,%d\n",ev->size().width(),ev->size().height());
566 //printf("approx: %d,%d\n",ev->size().width()/font_w,ev->size().height()/font_h); 557 //printf("approx: %d,%d\n",ev->size().width()/font_w,ev->size().height()/font_h);
567 //printf("leaves: %d,%d\n",ev->size().width()%font_w,ev->size().height()%font_h); 558 //printf("leaves: %d,%d\n",ev->size().width()%font_w,ev->size().height()%font_h);
568 //printf("curren: %d,%d\n",width(),height()); 559 //printf("curren: %d,%d\n",width(),height());
569HCNT("resizeEvent"); 560HCNT("resizeEvent");
570 561
571 // see comment in `paintEvent' concerning the rounding. 562 // see comment in `paintEvent' concerning the rounding.
572 //FIXME: could make a routine here; check width(),height() 563 //FIXME: could make a routine here; check width(),height()
573 assert(ev->size().width() == width()); 564 assert(ev->size().width() == width());
574 assert(ev->size().height() == height()); 565 assert(ev->size().height() == height());
575 566
576 propagateSize(); 567 propagateSize();
577} 568}
578 569
579void TEWidget::propagateSize() 570void TEWidget::propagateSize()
580{ 571{
581 ca* oldimg = image; 572 ca* oldimg = image;
582 int oldlin = lines; 573 int oldlin = lines;
583 int oldcol = columns; 574 int oldcol = columns;
584 makeImage(); 575 makeImage();
585 // we copy the old image to reduce flicker 576 // we copy the old image to reduce flicker
586 int lins = QMIN(oldlin,lines); 577 int lins = QMIN(oldlin,lines);
587 int cols = QMIN(oldcol,columns); 578 int cols = QMIN(oldcol,columns);
588 if (oldimg) 579 if (oldimg)
589 { 580 {
590 for (int lin = 0; lin < lins; lin++) 581 for (int lin = 0; lin < lins; lin++)
591 memcpy((void*)&image[columns*lin], 582 memcpy((void*)&image[columns*lin],
592 (void*)&oldimg[oldcol*lin],cols*sizeof(ca)); 583 (void*)&oldimg[oldcol*lin],cols*sizeof(ca));
593 free(oldimg); //FIXME: try new,delete 584 free(oldimg); //FIXME: try new,delete
594 } 585 }
595 else 586 else
596 clearImage(); 587 clearImage();
597 588
598 //NOTE: control flows from the back through the chest right into the eye. 589 //NOTE: control flows from the back through the chest right into the eye.
599 // `emu' will call back via `setImage'. 590 // `emu' will call back via `setImage'.
600 591
601 resizing = TRUE; 592 resizing = TRUE;
602 emit changedImageSizeSignal(lines, columns); // expose resizeEvent 593 emit changedImageSizeSignal(lines, columns); // expose resizeEvent
603 resizing = FALSE; 594 resizing = FALSE;
604} 595}
605 596
606/* ------------------------------------------------------------------------- */ 597/* ------------------------------------------------------------------------- */
607/* */ 598/* */
608/* Scrollbar */ 599/* Scrollbar */
609/* */ 600/* */
610/* ------------------------------------------------------------------------- */ 601/* ------------------------------------------------------------------------- */
611 602
612void TEWidget::scrollChanged(int) { 603void TEWidget::scrollChanged(int) {
613 emit changedHistoryCursor(scrollbar->value()); //expose 604 emit changedHistoryCursor(scrollbar->value()); //expose
614} 605}
615 606
616void TEWidget::hScrollChanged(int loc) { 607void TEWidget::hScrollChanged(int loc) {
617 hposition = loc; 608 hposition = loc;
618 propagateSize(); 609 propagateSize();
619 update(); 610 update();
620 611
621// emit changedHorzCursor( hScrollbar->value()); //expose 612// emit changedHorzCursor( hScrollbar->value()); //expose
622} 613}
623 614
624void TEWidget::setScroll(int cursor, int slines) 615void TEWidget::setScroll(int cursor, int slines)
625{ 616{
626 disconnect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); 617 disconnect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int)));
627 scrollbar->setRange(0,slines); 618 scrollbar->setRange(0,slines);
628 scrollbar->setSteps(1,lines); 619 scrollbar->setSteps(1,lines);
629 scrollbar->setValue(cursor); 620 scrollbar->setValue(cursor);
630 connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); 621 connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int)));
631} 622}
632 623
633void TEWidget::setScrollbarLocation(int loc) 624void TEWidget::setScrollbarLocation(int loc)
634{ 625{
635 if (scrollLoc == loc) return; // quickly 626 if (scrollLoc == loc) return; // quickly
636 scrollLoc = loc; 627 scrollLoc = loc;
637 propagateSize(); 628 propagateSize();
638 update(); 629 update();
639} 630}
640 631
641/* ------------------------------------------------------------------------- */ 632/* ------------------------------------------------------------------------- */
642/* */ 633/* */
643/* Mouse */ 634/* Mouse */
644/* */ 635/* */
645/* ------------------------------------------------------------------------- */ 636/* ------------------------------------------------------------------------- */
646 637
647/*! 638/*!
648 Three different operations can be performed using the mouse, and the 639 Three different operations can be performed using the mouse, and the
649 routines in this section serve all of them: 640 routines in this section serve all of them:
650 641
651 1) The press/release events are exposed to the application 642 1) The press/release events are exposed to the application
652 2) Marking (press and move left button) and Pasting (press middle button) 643 2) Marking (press and move left button) and Pasting (press middle button)
653 3) The right mouse button is used from the configuration menu 644 3) The right mouse button is used from the configuration menu
654 645
655 NOTE: During the marking process we attempt to keep the cursor within 646 NOTE: During the marking process we attempt to keep the cursor within
656 the bounds of the text as being displayed by setting the mouse position 647 the bounds of the text as being displayed by setting the mouse position
657 whenever the mouse has left the text area. 648 whenever the mouse has left the text area.
658 649
659 Two reasons to do so: 650 Two reasons to do so:
660 1) QT does not allow the `grabMouse' to confine-to the TEWidget. 651 1) QT does not allow the `grabMouse' to confine-to the TEWidget.
661 Thus a `XGrapPointer' would have to be used instead. 652 Thus a `XGrapPointer' would have to be used instead.
662 2) Even if so, this would not help too much, since the text area 653 2) Even if so, this would not help too much, since the text area
663 of the TEWidget is normally not identical with it's bounds. 654 of the TEWidget is normally not identical with it's bounds.
664 655
665 The disadvantage of the current handling is, that the mouse can visibly 656 The disadvantage of the current handling is, that the mouse can visibly
666 leave the bounds of the widget and is then moved back. Because of the 657 leave the bounds of the widget and is then moved back. Because of the
667 current construction, and the reasons mentioned above, we cannot do better 658 current construction, and the reasons mentioned above, we cannot do better
668 without changing the overall construction. 659 without changing the overall construction.
669*/ 660*/
670 661
671/*! 662/*!
672*/ 663*/
673 664
674void TEWidget::mousePressEvent(QMouseEvent* ev) 665void TEWidget::mousePressEvent(QMouseEvent* ev)
675{ 666{
676//printf("press [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button()); 667//printf("press [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button());
677 if ( !contentsRect().contains(ev->pos()) ) return; 668 if ( !contentsRect().contains(ev->pos()) ) return;
678 QPoint tL = contentsRect().topLeft(); 669 QPoint tL = contentsRect().topLeft();
679 int tLx = tL.x(); 670 int tLx = tL.x();
680 int tLy = tL.y(); 671 int tLy = tL.y();
681 672
682 mouse_down_x = ev->x(); 673 mouse_down_x = ev->x();
683 mouse_down_y = ev->y(); 674 mouse_down_y = ev->y();
684 675
685//printf("press top left [%d,%d] by=%d\n",tLx,tLy, bY); 676//printf("press top left [%d,%d] by=%d\n",tLx,tLy, bY);
686 if ( ev->button() == LeftButton) 677 if ( ev->button() == LeftButton)
687 { 678 {
688 QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); 679 QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h);
689 680
690 word_selection_mode = (ev->state() & ShiftButton); 681 word_selection_mode = (ev->state() & ShiftButton);
691 682
692 if ( ev->state() & ControlButton ) preserve_line_breaks = FALSE ; 683 if ( ev->state() & ControlButton ) preserve_line_breaks = FALSE ;
693 684
694 if (mouse_marks || (ev->state() & ShiftButton)) 685 if (mouse_marks || (ev->state() & ShiftButton))
695 { 686 {
696 emit clearSelectionSignal(); 687 emit clearSelectionSignal();
697 iPntSel = pntSel = pos; 688 iPntSel = pntSel = pos;
698 actSel = 1; // left mouse button pressed but nothing selected yet. 689 actSel = 1; // left mouse button pressed but nothing selected yet.
699 grabMouse( /*crossCursor*/ ); // handle with care! 690 grabMouse( /*crossCursor*/ ); // handle with care!
700 } 691 }
701 else 692 else
702 { 693 {
703 emit mouseSignal( 0, pos.x() + 1, pos.y() + 1 ); // left button 694 emit mouseSignal( 0, pos.x() + 1, pos.y() + 1 ); // left button
704 } 695 }
705 } 696 }
706 if ( ev->button() == MidButton ) 697 if ( ev->button() == MidButton )
707 { 698 {
708 emitSelection(); 699 emitSelection();
709 } 700 }
710 if ( ev->button() == RightButton ) // Configure 701 if ( ev->button() == RightButton ) // Configure
711 { 702 {
712 emit configureRequest( this, ev->state()&(ShiftButton|ControlButton), ev->x(), ev->y() ); 703 emit configureRequest( this, ev->state()&(ShiftButton|ControlButton), ev->x(), ev->y() );
713 } 704 }
714} 705}
715 706
716void TEWidget::mouseMoveEvent(QMouseEvent* ev) 707void TEWidget::mouseMoveEvent(QMouseEvent* ev)
717{ 708{
718 // for auto-hiding the cursor, we need mouseTracking 709 // for auto-hiding the cursor, we need mouseTracking
719 if (ev->state() == NoButton ) return; 710 if (ev->state() == NoButton ) return;
720 711
721 if (actSel == 0) return; 712 if (actSel == 0) return;
722 713
723 // don't extend selection while pasting 714 // don't extend selection while pasting
724 if (ev->state() & MidButton) return; 715 if (ev->state() & MidButton) return;
725 716
726 //if ( !contentsRect().contains(ev->pos()) ) return; 717 //if ( !contentsRect().contains(ev->pos()) ) return;
727 QPoint tL = contentsRect().topLeft(); 718 QPoint tL = contentsRect().topLeft();
728 int tLx = tL.x(); 719 int tLx = tL.x();
729 int tLy = tL.y(); 720 int tLy = tL.y();
730 int scroll = scrollbar->value(); 721 int scroll = scrollbar->value();
731// int hScroll = hScrollbar->value(); 722// int hScroll = hScrollbar->value();
732 723
733 // we're in the process of moving the mouse with the left button pressed 724 // we're in the process of moving the mouse with the left button pressed
734 // the mouse cursor will kept catched within the bounds of the text in 725 // the mouse cursor will kept catched within the bounds of the text in
735 // this widget. 726 // this widget.
736 727
737 // Adjust position within text area bounds. See FIXME above. 728 // Adjust position within text area bounds. See FIXME above.
738 QPoint pos = ev->pos(); 729 QPoint pos = ev->pos();
739 if ( pos.x() < tLx+blX ) pos.setX( tLx+blX ); 730 if ( pos.x() < tLx+blX ) pos.setX( tLx+blX );
740 if ( pos.x() > tLx+blX+columns*font_w-1 ) pos.setX( tLx+blX+columns*font_w ); 731 if ( pos.x() > tLx+blX+columns*font_w-1 ) pos.setX( tLx+blX+columns*font_w );
741 if ( pos.y() < tLy+bY ) pos.setY( tLy+bY ); 732 if ( pos.y() < tLy+bY ) pos.setY( tLy+bY );
742 if ( pos.y() > tLy+bY+lines*font_h-1 ) pos.setY( tLy+bY+lines*font_h-1 ); 733 if ( pos.y() > tLy+bY+lines*font_h-1 ) pos.setY( tLy+bY+lines*font_h-1 );
743 // check if we produce a mouse move event by this 734 // check if we produce a mouse move event by this
744 if ( pos != ev->pos() ) cursor().setPos(mapToGlobal(pos)); 735 if ( pos != ev->pos() ) cursor().setPos(mapToGlobal(pos));
745 736
746 if ( pos.y() == tLy+bY+lines*font_h-1 ) 737 if ( pos.y() == tLy+bY+lines*font_h-1 )
747 { 738 {
748 scrollbar->setValue(scrollbar->value()+yMouseScroll); // scrollforward 739 scrollbar->setValue(scrollbar->value()+yMouseScroll); // scrollforward
749 } 740 }
750 if ( pos.y() == tLy+bY ) 741 if ( pos.y() == tLy+bY )
751 { 742 {
752 scrollbar->setValue(scrollbar->value()-yMouseScroll); // scrollback 743 scrollbar->setValue(scrollbar->value()-yMouseScroll); // scrollback
753 } 744 }
754 745
755 QPoint here = QPoint((pos.x()-tLx-blX)/font_w,(pos.y()-tLy-bY)/font_h); 746 QPoint here = QPoint((pos.x()-tLx-blX)/font_w,(pos.y()-tLy-bY)/font_h);
756 QPoint ohere; 747 QPoint ohere;
757 bool swapping = FALSE; 748 bool swapping = FALSE;
758 749
759 if ( word_selection_mode ) 750 if ( word_selection_mode )
760 { 751 {
761 // Extend to word boundaries 752 // Extend to word boundaries
762 int i; 753 int i;
763 int selClass; 754 int selClass;
764 755
765 bool left_not_right = ( here.y() < iPntSel.y() || 756 bool left_not_right = ( here.y() < iPntSel.y() ||
766 here.y() == iPntSel.y() && here.x() < iPntSel.x() ); 757 here.y() == iPntSel.y() && here.x() < iPntSel.x() );
767 bool old_left_not_right = ( pntSel.y() < iPntSel.y() || 758 bool old_left_not_right = ( pntSel.y() < iPntSel.y() ||
768 pntSel.y() == iPntSel.y() && pntSel.x() < iPntSel.x() ); 759 pntSel.y() == iPntSel.y() && pntSel.x() < iPntSel.x() );
769 swapping = left_not_right != old_left_not_right; 760 swapping = left_not_right != old_left_not_right;
770 761
771 // Find left (left_not_right ? from here : from start) 762 // Find left (left_not_right ? from here : from start)
772 QPoint left = left_not_right ? here : iPntSel; 763 QPoint left = left_not_right ? here : iPntSel;
773 i = loc(left.x(),left.y()); 764 i = loc(left.x(),left.y());
774 selClass = charClass(image[i].c); 765 selClass = charClass(image[i].c);
775 while ( left.x() > 0 && charClass(image[i-1].c) == selClass ) 766 while ( left.x() > 0 && charClass(image[i-1].c) == selClass )
776 { i--; left.rx()--; } 767 { i--; left.rx()--; }
777 768
778 // Find left (left_not_right ? from start : from here) 769 // Find left (left_not_right ? from start : from here)
779 QPoint right = left_not_right ? iPntSel : here; 770 QPoint right = left_not_right ? iPntSel : here;
780 i = loc(right.x(),right.y()); 771 i = loc(right.x(),right.y());
781 selClass = charClass(image[i].c); 772 selClass = charClass(image[i].c);
782 while ( right.x() < columns-1 && charClass(image[i+1].c) == selClass ) 773 while ( right.x() < columns-1 && charClass(image[i+1].c) == selClass )
783 { i++; right.rx()++; } 774 { i++; right.rx()++; }
784 775
785 // Pick which is start (ohere) and which is extension (here) 776 // Pick which is start (ohere) and which is extension (here)
786 if ( left_not_right ) 777 if ( left_not_right )
787 { 778 {
788 here = left; ohere = right; 779 here = left; ohere = right;
789 } 780 }
790 else 781 else
791 { 782 {
792 here = right; ohere = left; 783 here = right; ohere = left;
793 } 784 }
794 } 785 }
795 786
796 if (here == pntSel && scroll == scrollbar->value()) return; // not moved 787 if (here == pntSel && scroll == scrollbar->value()) return; // not moved
797 788
798 if ( word_selection_mode ) { 789 if ( word_selection_mode ) {
799 if ( actSel < 2 || swapping ) { 790 if ( actSel < 2 || swapping ) {
800 emit beginSelectionSignal( ohere.x(), ohere.y() ); 791 emit beginSelectionSignal( ohere.x(), ohere.y() );
801 } 792 }
802 } else if ( actSel < 2 ) { 793 } else if ( actSel < 2 ) {
803 emit beginSelectionSignal( pntSel.x(), pntSel.y() ); 794 emit beginSelectionSignal( pntSel.x(), pntSel.y() );
804 } 795 }
805 796
806 actSel = 2; // within selection 797 actSel = 2; // within selection
807 pntSel = here; 798 pntSel = here;
808 emit extendSelectionSignal( here.x(), here.y() ); 799 emit extendSelectionSignal( here.x(), here.y() );
809} 800}
810 801
811void TEWidget::mouseReleaseEvent(QMouseEvent* ev) 802void TEWidget::mouseReleaseEvent(QMouseEvent* ev)
812{ 803{
813//printf("release [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button()); 804//printf("release [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button());
814 if ( ev->button() == LeftButton) 805 if ( ev->button() == LeftButton)
815 { 806 {
816 if (QABS(ev->x() - mouse_down_x) < 3 807 if (QABS(ev->x() - mouse_down_x) < 3
817 && QABS(ev->y() - mouse_down_y) < 3 808 && QABS(ev->y() - mouse_down_y) < 3
818 && ev->y() < qApp->desktop()->height()/8) { 809 && ev->y() < qApp->desktop()->height()/8) {
819 emit setFullScreen(false); 810 emit setFullScreen(false);
820 } 811 }
821 812
822 if ( actSel > 1 ) emit endSelectionSignal(preserve_line_breaks); 813 if ( actSel > 1 ) emit endSelectionSignal(preserve_line_breaks);
823 preserve_line_breaks = TRUE; 814 preserve_line_breaks = TRUE;
824 actSel = 0; 815 actSel = 0;
825 816
826 //FIXME: emits a release event even if the mouse is 817 //FIXME: emits a release event even if the mouse is
827 // outside the range. The procedure used in `mouseMoveEvent' 818 // outside the range. The procedure used in `mouseMoveEvent'
828 // applies here, too. 819 // applies here, too.
829 820
830 QPoint tL = contentsRect().topLeft(); 821 QPoint tL = contentsRect().topLeft();
831 int tLx = tL.x(); 822 int tLx = tL.x();
832 int tLy = tL.y(); 823 int tLy = tL.y();
833 824
834 if (!mouse_marks && !(ev->state() & ShiftButton)) 825 if (!mouse_marks && !(ev->state() & ShiftButton))
835 emit mouseSignal( 3, // release 826 emit mouseSignal( 3, // release
836 (ev->x()-tLx-blX)/font_w + 1, 827 (ev->x()-tLx-blX)/font_w + 1,
837 (ev->y()-tLy-bY)/font_h + 1 ); 828 (ev->y()-tLy-bY)/font_h + 1 );
838 releaseMouse(); 829 releaseMouse();
839 } 830 }
840} 831}
841 832
842void TEWidget::mouseDoubleClickEvent(QMouseEvent* ev) 833void TEWidget::mouseDoubleClickEvent(QMouseEvent* ev)
843{ 834{
844 if ( ev->button() != LeftButton) return; 835 if ( ev->button() != LeftButton) return;
845 836
846 QPoint tL = contentsRect().topLeft(); 837 QPoint tL = contentsRect().topLeft();
847 int tLx = tL.x(); 838 int tLx = tL.x();
848 int tLy = tL.y(); 839 int tLy = tL.y();
849 QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); 840 QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h);
850 841
851 // pass on double click as two clicks. 842 // pass on double click as two clicks.
852 if (!mouse_marks && !(ev->state() & ShiftButton)) 843 if (!mouse_marks && !(ev->state() & ShiftButton))
853 { 844 {
854 emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button 845 emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button
855 emit mouseSignal( 3, pos.x()+1, pos.y()+1 ); // release 846 emit mouseSignal( 3, pos.x()+1, pos.y()+1 ); // release
856 emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button 847 emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button
857 return; 848 return;
858 } 849 }
859 850
860 851
861 emit clearSelectionSignal(); 852 emit clearSelectionSignal();
862 QPoint bgnSel = pos; 853 QPoint bgnSel = pos;
863 QPoint endSel = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); 854 QPoint endSel = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h);
864 int i = loc(bgnSel.x(),bgnSel.y()); 855 int i = loc(bgnSel.x(),bgnSel.y());
865 iPntSel = bgnSel; 856 iPntSel = bgnSel;
866 857
867 word_selection_mode = TRUE; 858 word_selection_mode = TRUE;
868 859
869 // find word boundaries... 860 // find word boundaries...
870 int selClass = charClass(image[i].c); 861 int selClass = charClass(image[i].c);
871 { 862 {
872 // set the start... 863 // set the start...
873 int x = bgnSel.x(); 864 int x = bgnSel.x();
874 while ( x > 0 && charClass(image[i-1].c) == selClass ) 865 while ( x > 0 && charClass(image[i-1].c) == selClass )
875 { i--; x--; } 866 { i--; x--; }
876 bgnSel.setX(x); 867 bgnSel.setX(x);
877 emit beginSelectionSignal( bgnSel.x(), bgnSel.y() ); 868 emit beginSelectionSignal( bgnSel.x(), bgnSel.y() );
878 869
879 // set the end... 870 // set the end...
880 i = loc( endSel.x(), endSel.y() ); 871 i = loc( endSel.x(), endSel.y() );
881 x = endSel.x(); 872 x = endSel.x();
882 while( x < columns-1 && charClass(image[i+1].c) == selClass ) 873 while( x < columns-1 && charClass(image[i+1].c) == selClass )
883 { i++; x++ ; } 874 { i++; x++ ; }
884 endSel.setX(x); 875 endSel.setX(x);
885 actSel = 2; // within selection 876 actSel = 2; // within selection
886 emit extendSelectionSignal( endSel.x(), endSel.y() ); 877 emit extendSelectionSignal( endSel.x(), endSel.y() );
887 emit endSelectionSignal(preserve_line_breaks); 878 emit endSelectionSignal(preserve_line_breaks);
888 preserve_line_breaks = TRUE; 879 preserve_line_breaks = TRUE;
889 } 880 }
890} 881}
891 882
892void TEWidget::focusInEvent( QFocusEvent * ) 883void TEWidget::focusInEvent( QFocusEvent * )
893{ 884{
894 885
895 // do nothing, to prevent repainting 886 // do nothing, to prevent repainting
896} 887}
897 888
898 889
899void TEWidget::focusOutEvent( QFocusEvent * ) 890void TEWidget::focusOutEvent( QFocusEvent * )
900{ 891{
901 // do nothing, to prevent repainting 892 // do nothing, to prevent repainting
902} 893}
903 894
904bool TEWidget::focusNextPrevChild( bool next ) 895bool TEWidget::focusNextPrevChild( bool next )
905{ 896{
906 if (next) 897 if (next)
907 return false; // This disables changing the active part in konqueror 898 return false; // This disables changing the active part in konqueror
908 // when pressing Tab 899 // when pressing Tab
909 return QFrame::focusNextPrevChild( next ); 900 return QFrame::focusNextPrevChild( next );
910} 901}
911 902
912 903
913int TEWidget::charClass(char ch) const 904int TEWidget::charClass(char ch) const
914{ 905{
915 // This might seem like overkill, but imagine if ch was a Unicode 906 // This might seem like overkill, but imagine if ch was a Unicode
916 // character (Qt 2.0 QChar) - it might then be sensible to separate 907 // character (Qt 2.0 QChar) - it might then be sensible to separate
917 // the different language ranges, etc. 908 // the different language ranges, etc.
918 909
919 if ( isspace(ch) ) return ' '; 910 if ( isspace(ch) ) return ' ';
920 911
921 static const char *word_characters = ":@-./_~"; 912 static const char *word_characters = ":@-./_~";
922 if ( isalnum(ch) || strchr(word_characters, ch) ) 913 if ( isalnum(ch) || strchr(word_characters, ch) )
923 return 'a'; 914 return 'a';
924 915
925 // Everything else is weird 916 // Everything else is weird
926 return 1; 917 return 1;
927} 918}
928 919
929void TEWidget::setMouseMarks(bool on) 920void TEWidget::setMouseMarks(bool on)
930{ 921{
931 mouse_marks = on; 922 mouse_marks = on;
932 setCursor( mouse_marks ? ibeamCursor : arrowCursor ); 923 setCursor( mouse_marks ? ibeamCursor : arrowCursor );
933} 924}
934 925
935/* ------------------------------------------------------------------------- */ 926/* ------------------------------------------------------------------------- */
936/* */ 927/* */
937/* Clipboard */ 928/* Clipboard */
938/* */ 929/* */
939/* ------------------------------------------------------------------------- */ 930/* ------------------------------------------------------------------------- */
940 931
941#undef KeyPress 932#undef KeyPress
942 933
943void TEWidget::emitSelection() 934void TEWidget::emitSelection()
944// Paste Clipboard by simulating keypress events 935// Paste Clipboard by simulating keypress events
945{ 936{
946#ifndef QT_NO_CLIPBOARD 937#ifndef QT_NO_CLIPBOARD
947 QString text = QApplication::clipboard()->text(); 938 QString text = QApplication::clipboard()->text();
948 //qDebug(text); 939 //qDebug(text);
949 if ( ! text.isNull()) 940 if ( ! text.isNull())
950 { 941 {
951 text.replace(QRegExp("\n"), "\r"); 942 text.replace(QRegExp("\n"), "\r");
952 QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text); 943 QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text);
953 emit keyPressedSignal(&e); // expose as a big fat keypress event 944 emit keyPressedSignal(&e); // expose as a big fat keypress event
954 emit clearSelectionSignal(); 945 emit clearSelectionSignal();
955 } 946 }
956#endif 947#endif
957} 948}
958 949
959void TEWidget::emitText(QString text) 950void TEWidget::emitText(QString text)
960{ 951{
961 QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text); 952 QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text);
962 emit keyPressedSignal(&e); // expose as a big fat keypress event 953 emit keyPressedSignal(&e); // expose as a big fat keypress event
963} 954}
964 955
965void TEWidget::pasteClipboard( ) 956void TEWidget::pasteClipboard( )
966{ 957{
967 emitSelection(); 958 emitSelection();
968} 959}
969 960
970void TEWidget::setSelection(const QString& t) 961void TEWidget::setSelection(const QString& t)
971{ 962{
972#ifndef QT_NO_CLIPBOARD 963#ifndef QT_NO_CLIPBOARD
973 // Disconnect signal while WE set the clipboard 964 // Disconnect signal while WE set the clipboard
974 QObject *cb = QApplication::clipboard(); 965 QObject *cb = QApplication::clipboard();
975 QObject::disconnect( cb, SIGNAL(dataChanged()), 966 QObject::disconnect( cb, SIGNAL(dataChanged()),
976 this, SLOT(onClearSelection()) ); 967 this, SLOT(onClearSelection()) );
977 968
978 QApplication::clipboard()->setText(t); 969 QApplication::clipboard()->setText(t);
979 970
980 QObject::connect( cb, SIGNAL(dataChanged()), 971 QObject::connect( cb, SIGNAL(dataChanged()),
981 this, SLOT(onClearSelection()) ); 972 this, SLOT(onClearSelection()) );
982#endif 973#endif
983} 974}
984 975
985void TEWidget::onClearSelection() 976void TEWidget::onClearSelection()
986{ 977{
987 emit clearSelectionSignal(); 978 emit clearSelectionSignal();
988} 979}
989 980
990/* ------------------------------------------------------------------------- */ 981/* ------------------------------------------------------------------------- */
991/* */ 982/* */
992/* Keyboard */ 983/* Keyboard */
993/* */ 984/* */
994/* ------------------------------------------------------------------------- */ 985/* ------------------------------------------------------------------------- */
995 986
996//FIXME: an `eventFilter' has been installed instead of a `keyPressEvent' 987//FIXME: an `eventFilter' has been installed instead of a `keyPressEvent'
997// due to a bug in `QT' or the ignorance of the author to prevent 988// due to a bug in `QT' or the ignorance of the author to prevent
998// repaint events being emitted to the screen whenever one leaves 989// repaint events being emitted to the screen whenever one leaves
999// or reenters the screen to/from another application. 990// or reenters the screen to/from another application.
1000// 991//
1001// Troll says one needs to change focusInEvent() and focusOutEvent(), 992// Troll says one needs to change focusInEvent() and focusOutEvent(),
1002// which would also let you have an in-focus cursor and an out-focus 993// which would also let you have an in-focus cursor and an out-focus
1003// cursor like xterm does. 994// cursor like xterm does.
1004 995
1005// for the auto-hide cursor feature, I added empty focusInEvent() and 996// for the auto-hide cursor feature, I added empty focusInEvent() and
1006// focusOutEvent() so that update() isn't called. 997// focusOutEvent() so that update() isn't called.
1007// For auto-hide, we need to get keypress-events, but we only get them when 998// For auto-hide, we need to get keypress-events, but we only get them when
1008// we have focus. 999// we have focus.
1009 1000
1010void TEWidget::doScroll(int lines) 1001void TEWidget::doScroll(int lines)
1011{ 1002{
1012 scrollbar->setValue(scrollbar->value()+lines); 1003 scrollbar->setValue(scrollbar->value()+lines);
1013} 1004}
1014 1005
1015void TEWidget::doHScroll(int lines) { 1006void TEWidget::doHScroll(int lines) {
1016 hScrollbar->setValue( hScrollbar->value()+lines); 1007 hScrollbar->setValue( hScrollbar->value()+lines);
1017} 1008}
1018 1009
1019bool TEWidget::eventFilter( QObject *obj, QEvent *e ) 1010bool TEWidget::eventFilter( QObject *obj, QEvent *e )
1020{ 1011{
1021 if ( (e->type() == QEvent::Accel || 1012 if ( (e->type() == QEvent::Accel ||
1022 e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) { 1013 e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) {
1023 static_cast<QKeyEvent *>( e )->ignore(); 1014 static_cast<QKeyEvent *>( e )->ignore();
1024 return true; 1015 return true;
1025 } 1016 }
1026 if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ ) 1017 if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ )
1027 return FALSE; // not us 1018 return FALSE; // not us
1028 if ( e->type() == QEvent::Wheel) { 1019 if ( e->type() == QEvent::Wheel) {
1029 QApplication::sendEvent(scrollbar, e); 1020 QApplication::sendEvent(scrollbar, e);
1030 } 1021 }
1031 1022
1032#ifdef FAKE_CTRL_AND_ALT 1023#ifdef FAKE_CTRL_AND_ALT
1033 static bool control = FALSE; 1024 static bool control = FALSE;
1034 static bool alt = FALSE; 1025 static bool alt = FALSE;
1035// qDebug(" Has a keyboard with no CTRL and ALT keys, but we fake it:"); 1026// qDebug(" Has a keyboard with no CTRL and ALT keys, but we fake it:");
1036 bool dele=FALSE; 1027 bool dele=FALSE;
1037 if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { 1028 if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) {
1038 QKeyEvent* ke = (QKeyEvent*)e; 1029 QKeyEvent* ke = (QKeyEvent*)e;
1039 bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat(); 1030 bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat();
1040 switch (ke->key()) { 1031 switch (ke->key()) {
1041 case Key_F9: // let this be "Control" 1032 case Key_F9: // let this be "Control"
1042 control = keydown; 1033 control = keydown;
1043 e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state()); 1034 e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state());
1044 dele=TRUE; 1035 dele=TRUE;
1045 break; 1036 break;
1046 case Key_F13: // let this be "Alt" 1037 case Key_F13: // let this be "Alt"
1047 alt = keydown; 1038 alt = keydown;
1048 e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state()); 1039 e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state());
1049 dele=TRUE; 1040 dele=TRUE;
1050 break; 1041 break;
1051 default: 1042 default:
1052 if ( control ) { 1043 if ( control ) {
1053 int a = toupper(ke->ascii())-64; 1044 int a = toupper(ke->ascii())-64;
1054 if ( a >= 0 && a < ' ' ) { 1045 if ( a >= 0 && a < ' ' ) {
1055 e = new QKeyEvent(e->type(), ke->key(), 1046 e = new QKeyEvent(e->type(), ke->key(),
1056 a, ke->state()|ControlButton, QChar(a,0)); 1047 a, ke->state()|ControlButton, QChar(a,0));
1057 dele=TRUE; 1048 dele=TRUE;
1058 } 1049 }
1059 } 1050 }
1060 if ( alt ) { 1051 if ( alt ) {
1061 e = new QKeyEvent(e->type(), ke->key(), 1052 e = new QKeyEvent(e->type(), ke->key(),
1062 ke->ascii(), ke->state()|AltButton, ke->text()); 1053 ke->ascii(), ke->state()|AltButton, ke->text());
1063 dele=TRUE; 1054 dele=TRUE;
1064 } 1055 }
1065 } 1056 }
1066 } 1057 }
1067#endif 1058#endif
1068 1059
1069 if ( e->type() == QEvent::KeyPress ) { 1060 if ( e->type() == QEvent::KeyPress ) {
1070 QKeyEvent* ke = (QKeyEvent*)e; 1061 QKeyEvent* ke = (QKeyEvent*)e;
1071 actSel=0; // Key stroke implies a screen update, so TEWidget won't 1062 actSel=0; // Key stroke implies a screen update, so TEWidget won't
1072 // know where the current selection is. 1063 // know where the current selection is.
1073 1064
1074// qDebug("key pressed is 0x%x, ascii is 0x%x, state %d", ke->key(), ke->ascii(), ke->state()); 1065// qDebug("key pressed is 0x%x, ascii is 0x%x, state %d", ke->key(), ke->ascii(), ke->state());
1075 1066
1076 bool special_function = true; 1067 bool special_function = true;
1077 switch(ke->key()) { 1068 switch(ke->key()) {
1078 //case 0x201b: // fn-5 1069 //case 0x201b: // fn-5
1079 //case Key_F1: 1070 //case Key_F1:
1080 // switch sessions (?) 1071 // switch sessions (?)
1081 // emitText("\\"); // expose (??) 1072 // emitText("\\"); // expose (??)
1082 // break; 1073 // break;
1083 1074
1084 case 0x2016: // fn-p 1075 case 0x2016: // fn-p
1085 case Key_F2: 1076 case Key_F2:
1086 pasteClipboard(); 1077 pasteClipboard();
1087 break; 1078 break;
1088 1079
1089 case 0x2018: // fn-S 1080 case 0x2018: // fn-S
1090 case Key_F3: 1081 case Key_F3:
1091 emit changeSession(1); 1082 emit changeSession(1);
1092 break; 1083 break;
1093 1084
1094 case 0x2019: // fn-n 1085 case 0x2019: // fn-n
1095 emit newSession(); 1086 emit newSession();
1096 break; 1087 break;
1097 1088
1098 case Qt::Key_Tab: 1089 case Qt::Key_Tab:
1099 if (ke->state() == ControlButton) { 1090 if (ke->state() == ControlButton) {
1100 emit changeSession(1); 1091 emit changeSession(1);
1101 } else { 1092 } else {
1102 special_function = false; 1093 special_function = false;
1103 } 1094 }
1104 break; 1095 break;
1105 1096
1106#if 0 1097#if 0
1107 case Qt::Key_Left: 1098 case Qt::Key_Left:
1108 if (vcolumns == 0) { 1099 if (vcolumns == 0) {
1109 emit changeSession(-1); 1100 emit changeSession(-1);
1110 } else { 1101 } else {
1111 special_function = false; 1102 special_function = false;
1112 } 1103 }
1113 break; 1104 break;
1114 1105
1115 case Qt::Key_Right: 1106 case Qt::Key_Right:
1116 if (vcolumns == 0) { 1107 if (vcolumns == 0) {
1117 emit changeSession(1); 1108 emit changeSession(1);
1118 } else { 1109 } else {
1119 special_function = false; 1110 special_function = false;
1120 } 1111 }
1121 break; 1112 break;
1122#endif 1113#endif
1123 1114
1124 case 0x201b: // fn-5 1115 case 0x201b: // fn-5
1125 case Key_F4: 1116 case Key_F4:
1126 emit toggleFullScreen(); 1117 emit toggleFullScreen();
1127 break; 1118 break;
1128 1119
1129 case 0x200f: // fn-1 magnify minus 1120 case 0x200f: // fn-1 magnify minus
1130 case Key_F5: 1121 case Key_F5:
1131 emit changeFontSize(-1); 1122 emit changeFontSize(-1);
1132 break; 1123 break;
1133 1124
1134 case 0x2010: // fn-2 magnify plus 1125 case 0x2010: // fn-2 magnify plus
1135 case Key_F6: 1126 case Key_F6:
1136 emit changeFontSize(1); 1127 emit changeFontSize(1);
1137 break; 1128 break;
1138 1129
1139 default: 1130 default:
1140 special_function = false; 1131 special_function = false;
1141 } 1132 }
1142 if (special_function) { 1133 if (special_function) {
1143 return true; 1134 return true;
1144 } 1135 }
1145 // else if( ke->state() == ControlButton && ke->key() == Key_V) { 1136 // else if( ke->state() == ControlButton && ke->key() == Key_V) {
1146 // pasteClipboard(); 1137 // pasteClipboard();
1147 // } 1138 // }
1148 // else if( ke->state() == ControlButton && ke->key() == Key_C) { 1139 // else if( ke->state() == ControlButton && ke->key() == Key_C) {
1149 // pasteClipboard(); 1140 // pasteClipboard();
1150 // } 1141 // }
1151 emit keyPressedSignal(ke); // expose 1142 emit keyPressedSignal(ke); // expose
1152 ke->accept(); 1143 ke->accept();
1153#ifdef FAKE_CTRL_AND_ALT 1144#ifdef FAKE_CTRL_AND_ALT
1154 if ( dele ) delete e; 1145 if ( dele ) delete e;
1155#endif 1146#endif
1156 return true; // stop the event 1147 return true; // stop the event
1157 } 1148 }
1158 if ( e->type() == QEvent::Enter ) { 1149 if ( e->type() == QEvent::Enter ) {
1159 QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()), 1150 QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()),
1160 this, SLOT(onClearSelection()) ); 1151 this, SLOT(onClearSelection()) );
1161 } 1152 }
1162 if ( e->type() == QEvent::Leave ) { 1153 if ( e->type() == QEvent::Leave ) {
1163 QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), 1154 QObject::connect( (QObject*)cb, SIGNAL(dataChanged()),
1164 this, SLOT(onClearSelection()) ); 1155 this, SLOT(onClearSelection()) );
1165 } 1156 }
1166 return QFrame::eventFilter( obj, e ); 1157 return QFrame::eventFilter( obj, e );
1167} 1158}
1168 1159
1169/* ------------------------------------------------------------------------- */ 1160/* ------------------------------------------------------------------------- */
1170/* */ 1161/* */
1171/* Frame */ 1162/* Frame */
1172/* */ 1163/* */
1173/* ------------------------------------------------------------------------- */ 1164/* ------------------------------------------------------------------------- */
1174 1165
1175void TEWidget::frameChanged() 1166void TEWidget::frameChanged()
1176{ 1167{
1177 propagateSize(); 1168 propagateSize();
1178 update(); 1169 update();
1179} 1170}
1180/* ------------------------------------------------------------------------- */ 1171/* ------------------------------------------------------------------------- */
1181/* */ 1172/* */
1182/* Sound */ 1173/* Sound */
1183/* */ 1174/* */
1184/* ------------------------------------------------------------------------- */ 1175/* ------------------------------------------------------------------------- */
1185 1176
1186void TEWidget::Bell() 1177void TEWidget::Bell()
1187{ 1178{
1188//#ifdef QT_QWS_SL5XXX 1179//#ifdef QT_QWS_SL5XXX
1189//# ifndef QT_NO_COP 1180//# ifndef QT_NO_COP
1190 if(useBeep) 1181 if(useBeep)
1191 QCopEnvelope( "QPE/TaskBar", "soundAlarm()" ); 1182 QCopEnvelope( "QPE/TaskBar", "soundAlarm()" );
1192 1183
1193//# endif 1184//# endif
1194//#else 1185//#else
1195//# ifndef QT_NO_SOUND 1186//# ifndef QT_NO_SOUND
1196// QSound::play(Resource::findSound("alarm")); 1187// QSound::play(Resource::findSound("alarm"));
1197//# endif 1188//# endif
1198//#endif 1189//#endif
1199 1190
1200// QApplication::beep(); 1191// QApplication::beep();
1201} 1192}
1202 1193
1203/* ------------------------------------------------------------------------- */ 1194/* ------------------------------------------------------------------------- */
1204/* */ 1195/* */
1205/* Auxiluary */ 1196/* Auxiluary */
1206/* */ 1197/* */
1207/* ------------------------------------------------------------------------- */ 1198/* ------------------------------------------------------------------------- */
1208 1199
1209void TEWidget::clearImage() 1200void TEWidget::clearImage()
1210// initialize the image 1201// initialize the image
1211// for internal use only 1202// for internal use only
1212{ 1203{
1213 for (int y = 0; y < lines; y++) 1204 for (int y = 0; y < lines; y++)
1214 for (int x = 0; x < columns; x++) 1205 for (int x = 0; x < columns; x++)
1215 { 1206 {
1216 image[loc(x,y)].c = 0xff; //' '; 1207 image[loc(x,y)].c = 0xff; //' ';
1217 image[loc(x,y)].f = 0xff; //DEFAULT_FORE_COLOR; 1208 image[loc(x,y)].f = 0xff; //DEFAULT_FORE_COLOR;
1218 image[loc(x,y)].b = 0xff; //DEFAULT_BACK_COLOR; 1209 image[loc(x,y)].b = 0xff; //DEFAULT_BACK_COLOR;
1219 image[loc(x,y)].r = 0xff; //DEFAULT_RENDITION; 1210 image[loc(x,y)].r = 0xff; //DEFAULT_RENDITION;
1220 } 1211 }
1221} 1212}
1222 1213
1223// Create Image /////////////////////////////////////////////////////// 1214// Create Image ///////////////////////////////////////////////////////
1224 1215
1225void TEWidget::calcGeometry() 1216void TEWidget::calcGeometry()
1226{ 1217{
1227 int showhscrollbar = 1; 1218 int showhscrollbar = 1;
1228 int hwidth = 0; 1219 int hwidth = 0;
1229 int dcolumns = 0; 1220 int dcolumns = 0;
1230 Config cfg( "Konsole" ); 1221 Config cfg( "Konsole" );
1231 cfg.setGroup("ScrollBar"); 1222 cfg.setGroup("ScrollBar");
1232 useHorzScroll=cfg.readBoolEntry("HorzScroll",0); 1223 useHorzScroll=cfg.readBoolEntry("HorzScroll",0);
1233 1224
1234 if(vcolumns == 0) showhscrollbar = 0; 1225 if(vcolumns == 0) showhscrollbar = 0;
1235 if(showhscrollbar == 1) hwidth = QApplication::style().scrollBarExtent().width(); 1226 if(showhscrollbar == 1) hwidth = QApplication::style().scrollBarExtent().width();
1236 1227
1237 scrollbar->resize(QApplication::style().scrollBarExtent().width(), 1228 scrollbar->resize(QApplication::style().scrollBarExtent().width(),
1238 contentsRect().height() - hwidth); 1229 contentsRect().height() - hwidth);
1239 1230
1240 switch(scrollLoc) { 1231 switch(scrollLoc) {
1241 case SCRNONE : 1232 case SCRNONE :
1242 columns = ( contentsRect().width() - 2 * rimX ) / font_w; 1233 columns = ( contentsRect().width() - 2 * rimX ) / font_w;
1243 dcolumns = columns; 1234 dcolumns = columns;
1244 if(vcolumns) columns = vcolumns; 1235 if(vcolumns) columns = vcolumns;
1245 blX = (contentsRect().width() - (columns*font_w) ) / 2; 1236 blX = (contentsRect().width() - (columns*font_w) ) / 2;
1246 if(showhscrollbar) 1237 if(showhscrollbar)
1247 blX = -hposition * font_w; 1238 blX = -hposition * font_w;
1248 brX = blX; 1239 brX = blX;
1249 scrollbar->hide(); 1240 scrollbar->hide();
1250 break; 1241 break;
1251 case SCRLEFT : 1242 case SCRLEFT :
1252 columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; 1243 columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w;
1253 dcolumns = columns; 1244 dcolumns = columns;
1254 if(vcolumns) columns = vcolumns; 1245 if(vcolumns) columns = vcolumns;
1255 brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; 1246 brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2;
1256 if(showhscrollbar) 1247 if(showhscrollbar)
1257 brX = -hposition * font_w; 1248 brX = -hposition * font_w;
1258 blX = brX + scrollbar->width(); 1249 blX = brX + scrollbar->width();
1259 scrollbar->move(contentsRect().topLeft()); 1250 scrollbar->move(contentsRect().topLeft());
1260 scrollbar->show(); 1251 scrollbar->show();
1261 break; 1252 break;
1262 case SCRRIGHT: 1253 case SCRRIGHT:
1263 columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; 1254 columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w;
1264 dcolumns = columns; 1255 dcolumns = columns;
1265 if(vcolumns) columns = vcolumns; 1256 if(vcolumns) columns = vcolumns;
1266 blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; 1257 blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2;
1267 if(showhscrollbar) 1258 if(showhscrollbar)
1268 blX = -hposition * font_w; 1259 blX = -hposition * font_w;
1269 brX = blX; 1260 brX = blX;
1270 scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0)); 1261 scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0));
1271 scrollbar->show(); 1262 scrollbar->show();
1272 break; 1263 break;
1273 } 1264 }
1274 //FIXME: support 'rounding' styles 1265 //FIXME: support 'rounding' styles
1275 lines = ( contentsRect().height() - 2 * rimY ) / font_h; 1266 lines = ( contentsRect().height() - 2 * rimY ) / font_h;
1276 bY = (contentsRect().height() - (lines *font_h)) / 2; 1267 bY = (contentsRect().height() - (lines *font_h)) / 2;
1277 1268
1278 if(showhscrollbar == 1) { 1269 if(showhscrollbar == 1) {
1279 hScrollbar->resize(contentsRect().width() - hwidth, hwidth); 1270 hScrollbar->resize(contentsRect().width() - hwidth, hwidth);
1280 hScrollbar->setRange(0, vcolumns - dcolumns); 1271 hScrollbar->setRange(0, vcolumns - dcolumns);
1281 1272
1282 QPoint p = contentsRect().bottomLeft(); 1273 QPoint p = contentsRect().bottomLeft();
1283 if(scrollLoc == SCRLEFT) 1274 if(scrollLoc == SCRLEFT)
1284 hScrollbar->move(QPoint(p.x()+hwidth, p.y() - hwidth)); 1275 hScrollbar->move(QPoint(p.x()+hwidth, p.y() - hwidth));
1285 else 1276 else
1286 hScrollbar->move(QPoint(p.x(), p.y() - hwidth)); 1277 hScrollbar->move(QPoint(p.x(), p.y() - hwidth));
1287 1278
1288 hScrollbar->show(); 1279 hScrollbar->show();
1289 } 1280 }
1290 else hScrollbar->hide(); 1281 else hScrollbar->hide();
1291 1282
1292 if(showhscrollbar == 1) { 1283 if(showhscrollbar == 1) {
1293 lines = lines - (hwidth / font_h) - 1; 1284 lines = lines - (hwidth / font_h) - 1;
1294 if(lines < 1) lines = 1; 1285 if(lines < 1) lines = 1;
1295 } 1286 }
1296 //FIXME: support 'rounding' styles 1287 //FIXME: support 'rounding' styles
1297} 1288}
1298 1289
1299void TEWidget::makeImage() 1290void TEWidget::makeImage()
1300//FIXME: rename 'calcGeometry? 1291//FIXME: rename 'calcGeometry?
1301{ 1292{
1302 calcGeometry(); 1293 calcGeometry();
1303 image = (ca*) malloc(lines*columns*sizeof(ca)); 1294 image = (ca*) malloc(lines*columns*sizeof(ca));
1304 clearImage(); 1295 clearImage();
1305} 1296}
1306 1297
1307// calculate the needed size 1298// calculate the needed size
1308QSize TEWidget::calcSize(int cols, int lins) const 1299QSize TEWidget::calcSize(int cols, int lins) const
1309{ 1300{
1310 int frw = width() - contentsRect().width(); 1301 int frw = width() - contentsRect().width();
1311 int frh = height() - contentsRect().height(); 1302 int frh = height() - contentsRect().height();
1312 int scw = (scrollLoc==SCRNONE?0:scrollbar->width()); 1303 int scw = (scrollLoc==SCRNONE?0:scrollbar->width());
1313 return QSize( font_w*cols + 2*rimX + frw + scw, font_h*lins + 2*rimY + frh ); 1304 return QSize( font_w*cols + 2*rimX + frw + scw, font_h*lins + 2*rimY + frh );
1314} 1305}
1315 1306
1316QSize TEWidget::sizeHint() const 1307QSize TEWidget::sizeHint() const
1317{ 1308{
1318 return size(); 1309 return size();
1319} 1310}
1320 1311
1321void TEWidget::styleChange(QStyle &) 1312void TEWidget::styleChange(QStyle &)
1322{ 1313{
1323 propagateSize(); 1314 propagateSize();
1324} 1315}
1325 1316
1326#ifndef QT_NO_DRAGANDDROP 1317#ifndef QT_NO_DRAGANDDROP
1327 1318
1328/* --------------------------------------------------------------------- */ 1319/* --------------------------------------------------------------------- */
1329/* */ 1320/* */
1330/* Drag & Drop */ 1321/* Drag & Drop */
1331/* */ 1322/* */
1332/* --------------------------------------------------------------------- */ 1323/* --------------------------------------------------------------------- */
1333 1324
1334 1325
1335void TEWidget::dragEnterEvent(QDragEnterEvent* e) 1326void TEWidget::dragEnterEvent(QDragEnterEvent* e)
1336{ 1327{
1337 e->accept(QTextDrag::canDecode(e) || 1328 e->accept(QTextDrag::canDecode(e) ||
1338 QUriDrag::canDecode(e)); 1329 QUriDrag::canDecode(e));
1339} 1330}
1340 1331
1341void TEWidget::dropEvent(QDropEvent* event) 1332void TEWidget::dropEvent(QDropEvent* event)
1342{ 1333{
1343 // The current behaviour when url(s) are dropped is 1334 // The current behaviour when url(s) are dropped is
1344 // * if there is only ONE url and if it's a LOCAL one, ask for paste or cd 1335 // * if there is only ONE url and if it's a LOCAL one, ask for paste or cd
1345 // * in all other cases, just paste 1336 // * in all other cases, just paste
1346 // (for non-local ones, or for a list of URLs, 'cd' is nonsense) 1337 // (for non-local ones, or for a list of URLs, 'cd' is nonsense)
1347 QStrList strlist; 1338 QStrList strlist;
1348 int file_count = 0; 1339 int file_count = 0;
1349 dropText = ""; 1340 dropText = "";
1350 bool bPopup = true; 1341 bool bPopup = true;
1351 1342
1352 if(QUriDrag::decode(event, strlist)) { 1343 if(QUriDrag::decode(event, strlist)) {
1353 if (strlist.count()) { 1344 if (strlist.count()) {
1354 for(const char* p = strlist.first(); p; p = strlist.next()) { 1345 for(const char* p = strlist.first(); p; p = strlist.next()) {
1355 if(file_count++ > 0) { 1346 if(file_count++ > 0) {
1356 dropText += " "; 1347 dropText += " ";
1357 bPopup = false; // more than one file, don't popup 1348 bPopup = false; // more than one file, don't popup
1358 } 1349 }
1359 1350
1360/* 1351/*
1361 KURL url(p); 1352 KURL url(p);
1362 if (url.isLocalFile()) { 1353 if (url.isLocalFile()) {
1363 dropText += url.path(); // local URL : remove protocol 1354 dropText += url.path(); // local URL : remove protocol
1364 } 1355 }
1365 else { 1356 else {
1366 dropText += url.prettyURL(); 1357 dropText += url.prettyURL();
1367 bPopup = false; // a non-local file, don't popup 1358 bPopup = false; // a non-local file, don't popup
1368 } 1359 }
1369*/ 1360*/
1370 1361
1371 } 1362 }
1372 1363
1373 if (bPopup) 1364 if (bPopup)
1374 // m_drop->popup(pos() + event->pos()); 1365 // m_drop->popup(pos() + event->pos());
1375 m_drop->popup(mapToGlobal(event->pos())); 1366 m_drop->popup(mapToGlobal(event->pos()));
1376 else 1367 else
1377 { 1368 {
1378 if (currentSession) { 1369 if (currentSession) {
1379 currentSession->getEmulation()->sendString(dropText.local8Bit()); 1370 currentSession->getEmulation()->sendString(dropText.local8Bit());
1380 } 1371 }
1381// kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; 1372// kdDebug() << "Drop:" << dropText.local8Bit() << "\n";
1382 } 1373 }
1383 } 1374 }
1384 } 1375 }
1385 else if(QTextDrag::decode(event, dropText)) { 1376 else if(QTextDrag::decode(event, dropText)) {
1386// kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; 1377// kdDebug() << "Drop:" << dropText.local8Bit() << "\n";
1387 if (currentSession) { 1378 if (currentSession) {
1388 currentSession->getEmulation()->sendString(dropText.local8Bit()); 1379 currentSession->getEmulation()->sendString(dropText.local8Bit());
1389 } 1380 }
1390 // Paste it 1381 // Paste it
1391 } 1382 }
1392} 1383}
1393#endif 1384#endif
1394 1385
1395 1386
1396void TEWidget::drop_menu_activated(int item) 1387void TEWidget::drop_menu_activated(int item)
1397{ 1388{
1398#ifndef QT_NO_DRAGANDDROP 1389#ifndef QT_NO_DRAGANDDROP
1399 switch (item) 1390 switch (item)
1400 { 1391 {
1401 case 0: // paste 1392 case 0: // paste
1402 currentSession->getEmulation()->sendString(dropText.local8Bit()); 1393 currentSession->getEmulation()->sendString(dropText.local8Bit());
1403// KWM::activate((Window)this->winId()); 1394// KWM::activate((Window)this->winId());
1404 break; 1395 break;
1405 case 1: // cd ... 1396 case 1: // cd ...
1406 currentSession->getEmulation()->sendString("cd "); 1397 currentSession->getEmulation()->sendString("cd ");
1407 struct stat statbuf; 1398 struct stat statbuf;
1408 if ( ::stat( QFile::encodeName( dropText ), &statbuf ) == 0 ) 1399 if ( ::stat( QFile::encodeName( dropText ), &statbuf ) == 0 )
1409 { 1400 {
1410 if ( !S_ISDIR(statbuf.st_mode) ) 1401 if ( !S_ISDIR(statbuf.st_mode) )
1411 { 1402 {
1412/* 1403/*
1413 KURL url; 1404 KURL url;
1414 url.setPath( dropText ); 1405 url.setPath( dropText );
1415 dropText = url.directory( true, false ); // remove filename 1406 dropText = url.directory( true, false ); // remove filename
1416*/ 1407*/
1417 } 1408 }
1418 } 1409 }
1419 dropText.replace(QRegExp(" "), "\\ "); // escape spaces 1410 dropText.replace(QRegExp(" "), "\\ "); // escape spaces
1420 currentSession->getEmulation()->sendString(dropText.local8Bit()); 1411 currentSession->getEmulation()->sendString(dropText.local8Bit());
1421 currentSession->getEmulation()->sendString("\n"); 1412 currentSession->getEmulation()->sendString("\n");
1422// KWM::activate((Window)this->winId()); 1413// KWM::activate((Window)this->winId());
1423 break; 1414 break;
1424 } 1415 }
1425#endif 1416#endif
1426} 1417}
1427 1418
1428void TEWidget::setWrapAt(int columns) 1419void TEWidget::setWrapAt(int columns)
1429{ 1420{
1430 vcolumns = columns; 1421 vcolumns = columns;
1431 propagateSize(); 1422 propagateSize();
1432 update(); 1423 update();
1433} 1424}
diff --git a/core/apps/embeddedkonsole/TEmuVt102.cpp b/core/apps/embeddedkonsole/TEmuVt102.cpp
index 275c18d..0d6aef5 100644
--- a/core/apps/embeddedkonsole/TEmuVt102.cpp
+++ b/core/apps/embeddedkonsole/TEmuVt102.cpp
@@ -1,1020 +1,1015 @@
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.
803*/ 798*/
804 799
805#define CHARSET charset[scr==screen[1]] 800#define CHARSET charset[scr==screen[1]]
806 801
807// Apply current character map. 802// Apply current character map.
808 803
809unsigned short TEmuVt102::applyCharset(unsigned short c) 804unsigned short TEmuVt102::applyCharset(unsigned short c)
810{ 805{
811 if (CHARSET.graphic && 0x5f <= c && c <= 0x7e) return vt100_graphics[c-0x5f]; 806 if (CHARSET.graphic && 0x5f <= c && c <= 0x7e) return vt100_graphics[c-0x5f];
812 if (CHARSET.pound && c == '#' ) return 0xa3; //This mode is obsolete 807 if (CHARSET.pound && c == '#' ) return 0xa3; //This mode is obsolete
813 return c; 808 return c;
814} 809}
815 810
816/* 811/*
817 "Charset" related part of the emulation state. 812 "Charset" related part of the emulation state.
818 This configures the VT100 charset filter. 813 This configures the VT100 charset filter.
819 814
820 While most operation work on the current screen, 815 While most operation work on the current screen,
821 the following two are different. 816 the following two are different.
822*/ 817*/
823 818
824void TEmuVt102::resetCharset(int scrno) 819void TEmuVt102::resetCharset(int scrno)
825{ 820{
826 charset[scrno].cu_cs = 0; 821 charset[scrno].cu_cs = 0;
827 strncpy(charset[scrno].charset,"BBBB",4); 822 strncpy(charset[scrno].charset,"BBBB",4);
828 charset[scrno].sa_graphic = FALSE; 823 charset[scrno].sa_graphic = FALSE;
829 charset[scrno].sa_pound = FALSE; 824 charset[scrno].sa_pound = FALSE;
830 charset[scrno].graphic = FALSE; 825 charset[scrno].graphic = FALSE;
831 charset[scrno].pound = FALSE; 826 charset[scrno].pound = FALSE;
832} 827}
833 828
834/*! 829/*!
835*/ 830*/
836 831
837void TEmuVt102::setCharset(int n, int cs) // on both screens. 832void TEmuVt102::setCharset(int n, int cs) // on both screens.
838{ 833{
839 charset[0].charset[n&3] = cs; useCharset(charset[0].cu_cs); 834 charset[0].charset[n&3] = cs; useCharset(charset[0].cu_cs);
840 charset[1].charset[n&3] = cs; useCharset(charset[1].cu_cs); 835 charset[1].charset[n&3] = cs; useCharset(charset[1].cu_cs);
841} 836}
842 837
843/*! 838/*!
844*/ 839*/
845 840
846void TEmuVt102::setAndUseCharset(int n, int cs) 841void TEmuVt102::setAndUseCharset(int n, int cs)
847{ 842{
848 CHARSET.charset[n&3] = cs; 843 CHARSET.charset[n&3] = cs;
849 useCharset(n&3); 844 useCharset(n&3);
850} 845}
851 846
852/*! 847/*!
853*/ 848*/
854 849
855void TEmuVt102::useCharset(int n) 850void TEmuVt102::useCharset(int n)
856{ 851{
857 CHARSET.cu_cs = n&3; 852 CHARSET.cu_cs = n&3;
858 CHARSET.graphic = (CHARSET.charset[n&3] == '0'); 853 CHARSET.graphic = (CHARSET.charset[n&3] == '0');
859 CHARSET.pound = (CHARSET.charset[n&3] == 'A'); //This mode is obsolete 854 CHARSET.pound = (CHARSET.charset[n&3] == 'A'); //This mode is obsolete
860} 855}
861 856
862/*! Save the cursor position and the rendition attribute settings. */ 857/*! Save the cursor position and the rendition attribute settings. */
863 858
864void TEmuVt102::saveCursor() 859void TEmuVt102::saveCursor()
865{ 860{
866 CHARSET.sa_graphic = CHARSET.graphic; 861 CHARSET.sa_graphic = CHARSET.graphic;
867 CHARSET.sa_pound = CHARSET.pound; //This mode is obsolete 862 CHARSET.sa_pound = CHARSET.pound; //This mode is obsolete
868 // we are not clear about these 863 // we are not clear about these
869 //sa_charset = charsets[cScreen->charset]; 864 //sa_charset = charsets[cScreen->charset];
870 //sa_charset_num = cScreen->charset; 865 //sa_charset_num = cScreen->charset;
871 scr->saveCursor(); 866 scr->saveCursor();
872} 867}
873 868
874/*! Restore the cursor position and the rendition attribute settings. */ 869/*! Restore the cursor position and the rendition attribute settings. */
875 870
876void TEmuVt102::restoreCursor() 871void TEmuVt102::restoreCursor()
877{ 872{
878 CHARSET.graphic = CHARSET.sa_graphic; 873 CHARSET.graphic = CHARSET.sa_graphic;
879 CHARSET.pound = CHARSET.sa_pound; //This mode is obsolete 874 CHARSET.pound = CHARSET.sa_pound; //This mode is obsolete
880 scr->restoreCursor(); 875 scr->restoreCursor();
881} 876}
882 877
883/* ------------------------------------------------------------------------- */ 878/* ------------------------------------------------------------------------- */
884/* */ 879/* */
885/* Mode Operations */ 880/* Mode Operations */
886/* */ 881/* */
887/* ------------------------------------------------------------------------- */ 882/* ------------------------------------------------------------------------- */
888 883
889/* 884/*
890 Some of the emulations state is either added to the state of the screens. 885 Some of the emulations state is either added to the state of the screens.
891 886
892 This causes some scoping problems, since different emulations choose to 887 This causes some scoping problems, since different emulations choose to
893 located the mode either to the current screen or to both. 888 located the mode either to the current screen or to both.
894 889
895 For strange reasons, the extend of the rendition attributes ranges over 890 For strange reasons, the extend of the rendition attributes ranges over
896 all screens and not over the actual screen. 891 all screens and not over the actual screen.
897 892
898 We decided on the precise precise extend, somehow. 893 We decided on the precise precise extend, somehow.
899*/ 894*/
900 895
901// "Mode" related part of the state. These are all booleans. 896// "Mode" related part of the state. These are all booleans.
902 897
903void TEmuVt102::resetModes() 898void TEmuVt102::resetModes()
904{ 899{
905 resetMode(MODE_Mouse1000); saveMode(MODE_Mouse1000); 900 resetMode(MODE_Mouse1000); saveMode(MODE_Mouse1000);
906 resetMode(MODE_AppScreen); saveMode(MODE_AppScreen); 901 resetMode(MODE_AppScreen); saveMode(MODE_AppScreen);
907 // here come obsolete modes 902 // here come obsolete modes
908 resetMode(MODE_AppCuKeys); saveMode(MODE_AppCuKeys); 903 resetMode(MODE_AppCuKeys); saveMode(MODE_AppCuKeys);
909 resetMode(MODE_NewLine ); 904 resetMode(MODE_NewLine );
910 setMode(MODE_Ansi ); 905 setMode(MODE_Ansi );
911} 906}
912 907
913void TEmuVt102::setMode(int m) 908void TEmuVt102::setMode(int m)
914{ 909{
915 currParm.mode[m] = TRUE; 910 currParm.mode[m] = TRUE;
916 switch (m) 911 switch (m)
917 { 912 {
918 case MODE_Mouse1000 : gui->setMouseMarks(FALSE); 913 case MODE_Mouse1000 : gui->setMouseMarks(FALSE);
919 break; 914 break;
920 case MODE_AppScreen : screen[1]->clearSelection(); 915 case MODE_AppScreen : screen[1]->clearSelection();
921 screen[1]->clearEntireScreen(); 916 screen[1]->clearEntireScreen();
922 setScreen(1); 917 setScreen(1);
923 break; 918 break;
924 } 919 }
925 if (m < MODES_SCREEN || m == MODE_NewLine) 920 if (m < MODES_SCREEN || m == MODE_NewLine)
926 { 921 {
927 screen[0]->setMode(m); 922 screen[0]->setMode(m);
928 screen[1]->setMode(m); 923 screen[1]->setMode(m);
929 } 924 }
930} 925}
931 926
932void TEmuVt102::resetMode(int m) 927void TEmuVt102::resetMode(int m)
933{ 928{
934 currParm.mode[m] = FALSE; 929 currParm.mode[m] = FALSE;
935 switch (m) 930 switch (m)
936 { 931 {
937 case MODE_Mouse1000 : gui->setMouseMarks(TRUE); 932 case MODE_Mouse1000 : gui->setMouseMarks(TRUE);
938 break; 933 break;
939 case MODE_AppScreen : screen[0]->clearSelection(); 934 case MODE_AppScreen : screen[0]->clearSelection();
940 setScreen(0); 935 setScreen(0);
941 break; 936 break;
942 } 937 }
943 if (m < MODES_SCREEN || m == MODE_NewLine) 938 if (m < MODES_SCREEN || m == MODE_NewLine)
944 { 939 {
945 screen[0]->resetMode(m); 940 screen[0]->resetMode(m);
946 screen[1]->resetMode(m); 941 screen[1]->resetMode(m);
947 } 942 }
948} 943}
949 944
950void TEmuVt102::saveMode(int m) 945void TEmuVt102::saveMode(int m)
951{ 946{
952 saveParm.mode[m] = currParm.mode[m]; 947 saveParm.mode[m] = currParm.mode[m];
953} 948}
954 949
955void TEmuVt102::restoreMode(int m) 950void TEmuVt102::restoreMode(int m)
956{ 951{
957 if(saveParm.mode[m]) setMode(m); else resetMode(m); 952 if(saveParm.mode[m]) setMode(m); else resetMode(m);
958} 953}
959 954
960BOOL TEmuVt102::getMode(int m) 955BOOL TEmuVt102::getMode(int m)
961{ 956{
962 return currParm.mode[m]; 957 return currParm.mode[m];
963} 958}
964 959
965void TEmuVt102::setConnect(bool c) 960void TEmuVt102::setConnect(bool c)
966{ 961{
967 TEmulation::setConnect(c); 962 TEmulation::setConnect(c);
968 if (c) 963 if (c)
969 { // refresh mouse mode 964 { // refresh mouse mode
970 if (getMode(MODE_Mouse1000)) 965 if (getMode(MODE_Mouse1000))
971 setMode(MODE_Mouse1000); 966 setMode(MODE_Mouse1000);
972 else 967 else
973 resetMode(MODE_Mouse1000); 968 resetMode(MODE_Mouse1000);
974 } 969 }
975} 970}
976 971
977/* ------------------------------------------------------------------------- */ 972/* ------------------------------------------------------------------------- */
978/* */ 973/* */
979/* Diagnostic */ 974/* Diagnostic */
980/* */ 975/* */
981/* ------------------------------------------------------------------------- */ 976/* ------------------------------------------------------------------------- */
982 977
983/*! shows the contents of the scan buffer. 978/*! shows the contents of the scan buffer.
984 979
985 This functions is used for diagnostics. It is called by \e ReportErrorToken 980 This functions is used for diagnostics. It is called by \e ReportErrorToken
986 to inform about strings that cannot be decoded or handled by the emulation. 981 to inform about strings that cannot be decoded or handled by the emulation.
987 982
988 \sa ReportErrorToken 983 \sa ReportErrorToken
989*/ 984*/
990 985
991/*! 986/*!
992*/ 987*/
993 988
994static void hexdump(int* s, int len) 989static void hexdump(int* s, int len)
995{ int i; 990{ int i;
996 for (i = 0; i < len; i++) 991 for (i = 0; i < len; i++)
997 { 992 {
998 if (s[i] == '\\') 993 if (s[i] == '\\')
999 printf("\\\\"); 994 printf("\\\\");
1000 else 995 else
1001 if ((s[i]) > 32 && s[i] < 127) 996 if ((s[i]) > 32 && s[i] < 127)
1002 printf("%c",s[i]); 997 printf("%c",s[i]);
1003 else 998 else
1004 printf("\\%04x(hex)",s[i]); 999 printf("\\%04x(hex)",s[i]);
1005 } 1000 }
1006} 1001}
1007 1002
1008void TEmuVt102::scan_buffer_report() 1003void TEmuVt102::scan_buffer_report()
1009{ 1004{
1010 if (ppos == 0 || ppos == 1 && (pbuf[0] & 0xff) >= 32) return; 1005 if (ppos == 0 || ppos == 1 && (pbuf[0] & 0xff) >= 32) return;
1011 printf("token: "); hexdump(pbuf,ppos); printf("\n"); 1006 printf("token: "); hexdump(pbuf,ppos); printf("\n");
1012} 1007}
1013 1008
1014/*! 1009/*!
1015*/ 1010*/
1016 1011
1017void TEmuVt102::ReportErrorToken() 1012void TEmuVt102::ReportErrorToken()
1018{ 1013{
1019 printf("undecodable "); scan_buffer_report(); 1014 printf("undecodable "); scan_buffer_report();
1020} 1015}
diff --git a/core/apps/embeddedkonsole/TEmulation.cpp b/core/apps/embeddedkonsole/TEmulation.cpp
index a539757..54f408e 100644
--- a/core/apps/embeddedkonsole/TEmulation.cpp
+++ b/core/apps/embeddedkonsole/TEmulation.cpp
@@ -1,379 +1,376 @@
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 103
107 QObject::connect(gui,SIGNAL(changedImageSizeSignal(int,int)), 104 QObject::connect(gui,SIGNAL(changedImageSizeSignal(int,int)),
108 this,SLOT(onImageSizeChange(int,int))); 105 this,SLOT(onImageSizeChange(int,int)));
109 106
110 QObject::connect(gui,SIGNAL(changedHistoryCursor(int)), 107 QObject::connect(gui,SIGNAL(changedHistoryCursor(int)),
111 this,SLOT(onHistoryCursorChange(int))); 108 this,SLOT(onHistoryCursorChange(int)));
112 109
113 QObject::connect(gui,SIGNAL(changedHorzCursor(int)), 110 QObject::connect(gui,SIGNAL(changedHorzCursor(int)),
114 this,SLOT(onHorzCursorChange(int))); 111 this,SLOT(onHorzCursorChange(int)));
115 112
116 QObject::connect(gui,SIGNAL(keyPressedSignal(QKeyEvent*)), 113 QObject::connect(gui,SIGNAL(keyPressedSignal(QKeyEvent*)),
117 this,SLOT(onKeyPress(QKeyEvent*))); 114 this,SLOT(onKeyPress(QKeyEvent*)));
118 115
119 QObject::connect(gui,SIGNAL(beginSelectionSignal(const int,const int)), 116 QObject::connect(gui,SIGNAL(beginSelectionSignal(const int,const int)),
120 this,SLOT(onSelectionBegin(const int,const int)) ); 117 this,SLOT(onSelectionBegin(const int,const int)) );
121 118
122 QObject::connect(gui,SIGNAL(extendSelectionSignal(const int,const int)), 119 QObject::connect(gui,SIGNAL(extendSelectionSignal(const int,const int)),
123 this,SLOT(onSelectionExtend(const int,const int)) ); 120 this,SLOT(onSelectionExtend(const int,const int)) );
124 121
125 QObject::connect(gui,SIGNAL(endSelectionSignal(const BOOL)), 122 QObject::connect(gui,SIGNAL(endSelectionSignal(const BOOL)),
126 this,SLOT(setSelection(const BOOL)) ); 123 this,SLOT(setSelection(const BOOL)) );
127 124
128 QObject::connect(gui,SIGNAL(clearSelectionSignal()), 125 QObject::connect(gui,SIGNAL(clearSelectionSignal()),
129 this,SLOT(clearSelection()) ); 126 this,SLOT(clearSelection()) );
130} 127}
131 128
132/*! 129/*!
133*/ 130*/
134 131
135TEmulation::~TEmulation() 132TEmulation::~TEmulation()
136{ 133{
137 delete screen[0]; 134 delete screen[0];
138 delete screen[1]; 135 delete screen[1];
139 bulk_timer.stop(); 136 bulk_timer.stop();
140} 137}
141 138
142/*! change between primary and alternate screen 139/*! change between primary and alternate screen
143*/ 140*/
144 141
145void TEmulation::setScreen(int n) 142void TEmulation::setScreen(int n)
146{ 143{
147 scr = screen[n&1]; 144 scr = screen[n&1];
148} 145}
149 146
150void TEmulation::setHistory(bool on) 147void TEmulation::setHistory(bool on)
151{ 148{
152 screen[0]->setScroll(on); 149 screen[0]->setScroll(on);
153 if (!connected) return; 150 if (!connected) return;
154 showBulk(); 151 showBulk();
155} 152}
156 153
157bool TEmulation::history() 154bool TEmulation::history()
158{ 155{
159 return screen[0]->hasScroll(); 156 return screen[0]->hasScroll();
160} 157}
161 158
162void TEmulation::setCodec(int c) 159void TEmulation::setCodec(int c)
163{ 160{
164 //FIXME: check whether we have to free codec 161 //FIXME: check whether we have to free codec
165 codec = c ? QTextCodec::codecForName("utf8") 162 codec = c ? QTextCodec::codecForName("utf8")
166 : QTextCodec::codecForLocale(); 163 : QTextCodec::codecForLocale();
167 if (decoder) delete decoder; 164 if (decoder) delete decoder;
168 decoder = codec->makeDecoder(); 165 decoder = codec->makeDecoder();
169} 166}
170 167
171void TEmulation::setKeytrans(int no) 168void TEmulation::setKeytrans(int no)
172{ 169{
173 keytrans = KeyTrans::find(no); 170 keytrans = KeyTrans::find(no);
174} 171}
175 172
176void TEmulation::setKeytrans(const char * no) 173void TEmulation::setKeytrans(const char * no)
177{ 174{
178 keytrans = KeyTrans::find(no); 175 keytrans = KeyTrans::find(no);
179} 176}
180 177
181// Interpreting Codes --------------------------------------------------------- 178// Interpreting Codes ---------------------------------------------------------
182 179
183/* 180/*
184 This section deals with decoding the incoming character stream. 181 This section deals with decoding the incoming character stream.
185 Decoding means here, that the stream is first seperated into `tokens' 182 Decoding means here, that the stream is first seperated into `tokens'
186 which are then mapped to a `meaning' provided as operations by the 183 which are then mapped to a `meaning' provided as operations by the
187 `Screen' class. 184 `Screen' class.
188*/ 185*/
189 186
190/*! 187/*!
191*/ 188*/
192 189
193void TEmulation::onRcvChar(int c) 190void TEmulation::onRcvChar(int c)
194// process application unicode input to terminal 191// process application unicode input to terminal
195// this is a trivial scanner 192// this is a trivial scanner
196{ 193{
197 c &= 0xff; 194 c &= 0xff;
198 195
199 switch (c) 196 switch (c)
200 { 197 {
201 case '\b' : scr->BackSpace(); break; 198 case '\b' : scr->BackSpace(); break;
202 case '\t' : scr->Tabulate(); break; 199 case '\t' : scr->Tabulate(); break;
203 case '\n' : scr->NewLine(); break; 200 case '\n' : scr->NewLine(); break;
204 case '\r' : scr->Return(); break; 201 case '\r' : scr->Return(); break;
205 case 0x07 : gui->Bell(); break; 202 case 0x07 : gui->Bell(); break;
206 default : scr->ShowCharacter(c); break; 203 default : scr->ShowCharacter(c); break;
207 }; 204 };
208} 205}
209 206
210/* ------------------------------------------------------------------------- */ 207/* ------------------------------------------------------------------------- */
211/* */ 208/* */
212/* Keyboard Handling */ 209/* Keyboard Handling */
213/* */ 210/* */
214/* ------------------------------------------------------------------------- */ 211/* ------------------------------------------------------------------------- */
215 212
216/*! 213/*!
217*/ 214*/
218 215
219void TEmulation::onKeyPress( QKeyEvent* ev ) 216void TEmulation::onKeyPress( QKeyEvent* ev )
220{ 217{
221 if (!connected) return; // someone else gets the keys 218 if (!connected) return; // someone else gets the keys
222 if (scr->getHistCursor() != scr->getHistLines()); 219 if (scr->getHistCursor() != scr->getHistLines());
223 scr->setHistCursor(scr->getHistLines()); 220 scr->setHistCursor(scr->getHistLines());
224 if (!ev->text().isEmpty()) 221 if (!ev->text().isEmpty())
225 { // A block of text 222 { // A block of text
226 // Note that the text is proper unicode. 223 // Note that the text is proper unicode.
227 // We should do a conversion here, but since this 224 // We should do a conversion here, but since this
228 // routine will never be used, we simply emit plain ascii. 225 // routine will never be used, we simply emit plain ascii.
229 emit sndBlock(ev->text().ascii(),ev->text().length()); 226 emit sndBlock(ev->text().ascii(),ev->text().length());
230 } 227 }
231 else if (ev->ascii()>0) 228 else if (ev->ascii()>0)
232 { unsigned char c[1]; 229 { unsigned char c[1];
233 c[0] = ev->ascii(); 230 c[0] = ev->ascii();
234 emit sndBlock((char*)c,1); 231 emit sndBlock((char*)c,1);
235 } 232 }
236} 233}
237 234
238// Unblocking, Byte to Unicode translation --------------------------------- -- 235// Unblocking, Byte to Unicode translation --------------------------------- --
239 236
240/* 237/*
241 We are doing code conversion from locale to unicode first. 238 We are doing code conversion from locale to unicode first.
242*/ 239*/
243 240
244void TEmulation::onRcvBlock(const char *s, int len) 241void TEmulation::onRcvBlock(const char *s, int len)
245{ 242{
246 bulkStart(); 243 bulkStart();
247 bulk_incnt += 1; 244 bulk_incnt += 1;
248 for (int i = 0; i < len; i++) 245 for (int i = 0; i < len; i++)
249 { 246 {
250 QString result = decoder->toUnicode(&s[i],1); 247 QString result = decoder->toUnicode(&s[i],1);
251 int reslen = result.length(); 248 int reslen = result.length();
252 for (int j = 0; j < reslen; j++) 249 for (int j = 0; j < reslen; j++)
253 onRcvChar(result[j].unicode()); 250 onRcvChar(result[j].unicode());
254 if (s[i] == '\n') bulkNewline(); 251 if (s[i] == '\n') bulkNewline();
255 } 252 }
256 bulkEnd(); 253 bulkEnd();
257} 254}
258 255
259// Selection --------------------------------------------------------------- -- 256// Selection --------------------------------------------------------------- --
260 257
261void TEmulation::onSelectionBegin(const int x, const int y) { 258void TEmulation::onSelectionBegin(const int x, const int y) {
262 if (!connected) return; 259 if (!connected) return;
263 scr->setSelBeginXY(x,y); 260 scr->setSelBeginXY(x,y);
264 showBulk(); 261 showBulk();
265} 262}
266 263
267void TEmulation::onSelectionExtend(const int x, const int y) { 264void TEmulation::onSelectionExtend(const int x, const int y) {
268 if (!connected) return; 265 if (!connected) return;
269 scr->setSelExtentXY(x,y); 266 scr->setSelExtentXY(x,y);
270 showBulk(); 267 showBulk();
271} 268}
272 269
273void TEmulation::setSelection(const BOOL preserve_line_breaks) { 270void TEmulation::setSelection(const BOOL preserve_line_breaks) {
274 if (!connected) return; 271 if (!connected) return;
275 QString t = scr->getSelText(preserve_line_breaks); 272 QString t = scr->getSelText(preserve_line_breaks);
276 if (!t.isNull()) gui->setSelection(t); 273 if (!t.isNull()) gui->setSelection(t);
277} 274}
278 275
279void TEmulation::clearSelection() { 276void TEmulation::clearSelection() {
280 if (!connected) return; 277 if (!connected) return;
281 scr->clearSelection(); 278 scr->clearSelection();
282 showBulk(); 279 showBulk();
283} 280}
284 281
285// Refreshing -------------------------------------------------------------- -- 282// Refreshing -------------------------------------------------------------- --
286 283
287#define BULK_TIMEOUT 20 284#define BULK_TIMEOUT 20
288 285
289/*! 286/*!
290 called when \n comes in. Evtl. triggers showBulk at endBulk 287 called when \n comes in. Evtl. triggers showBulk at endBulk
291*/ 288*/
292 289
293void TEmulation::bulkNewline() 290void TEmulation::bulkNewline()
294{ 291{
295 bulk_nlcnt += 1; 292 bulk_nlcnt += 1;
296 bulk_incnt = 0; // reset bulk counter since `nl' rule applies 293 bulk_incnt = 0; // reset bulk counter since `nl' rule applies
297} 294}
298 295
299/*! 296/*!
300*/ 297*/
301 298
302void TEmulation::showBulk() 299void TEmulation::showBulk()
303{ 300{
304 bulk_nlcnt = 0; // reset bulk newline counter 301 bulk_nlcnt = 0; // reset bulk newline counter
305 bulk_incnt = 0; // reset bulk counter 302 bulk_incnt = 0; // reset bulk counter
306 if (connected) 303 if (connected)
307 { 304 {
308 ca* image = scr->getCookedImage(); // get the image 305 ca* image = scr->getCookedImage(); // get the image
309 gui->setImage(image, 306 gui->setImage(image,
310 scr->getLines(), 307 scr->getLines(),
311 scr->getColumns()); // actual refresh 308 scr->getColumns()); // actual refresh
312 free(image); 309 free(image);
313 310
314 //FIXME: check that we do not trigger other draw event here. 311 //FIXME: check that we do not trigger other draw event here.
315 gui->setScroll(scr->getHistCursor(),scr->getHistLines()); 312 gui->setScroll(scr->getHistCursor(),scr->getHistLines());
316 313
317 } 314 }
318} 315}
319 316
320void TEmulation::bulkStart() 317void TEmulation::bulkStart()
321{ 318{
322 if (bulk_timer.isActive()) bulk_timer.stop(); 319 if (bulk_timer.isActive()) bulk_timer.stop();
323} 320}
324 321
325void TEmulation::bulkEnd() 322void TEmulation::bulkEnd()
326{ 323{
327 if ( bulk_nlcnt > gui->Lines() || bulk_incnt > 20 ) 324 if ( bulk_nlcnt > gui->Lines() || bulk_incnt > 20 )
328 showBulk(); // resets bulk_??cnt to 0, too. 325 showBulk(); // resets bulk_??cnt to 0, too.
329 else 326 else
330 bulk_timer.start(BULK_TIMEOUT,TRUE); 327 bulk_timer.start(BULK_TIMEOUT,TRUE);
331} 328}
332 329
333void TEmulation::setConnect(bool c) 330void TEmulation::setConnect(bool c)
334{ 331{
335 connected = c; 332 connected = c;
336 if ( connected) 333 if ( connected)
337 { 334 {
338 onImageSizeChange(gui->Lines(), gui->Columns()); 335 onImageSizeChange(gui->Lines(), gui->Columns());
339 showBulk(); 336 showBulk();
340 } 337 }
341 else 338 else
342 { 339 {
343 scr->clearSelection(); 340 scr->clearSelection();
344 } 341 }
345} 342}
346 343
347// --------------------------------------------------------------------------- 344// ---------------------------------------------------------------------------
348 345
349/*! triggered by image size change of the TEWidget `gui'. 346/*! triggered by image size change of the TEWidget `gui'.
350 347
351 This event is simply propagated to the attached screens 348 This event is simply propagated to the attached screens
352 and to the related serial line. 349 and to the related serial line.
353*/ 350*/
354 351
355void TEmulation::onImageSizeChange(int lines, int columns) { 352void TEmulation::onImageSizeChange(int lines, int columns) {
356 if (!connected) return; 353 if (!connected) return;
357 screen[0]->resizeImage(lines,columns); 354 screen[0]->resizeImage(lines,columns);
358 screen[1]->resizeImage(lines,columns); 355 screen[1]->resizeImage(lines,columns);
359 showBulk(); 356 showBulk();
360 emit ImageSizeChanged(lines,columns); // propagate event to serial line 357 emit ImageSizeChanged(lines,columns); // propagate event to serial line
361} 358}
362 359
363void TEmulation::onHistoryCursorChange(int cursor) { 360void TEmulation::onHistoryCursorChange(int cursor) {
364 if (!connected) return; 361 if (!connected) return;
365 scr->setHistCursor(cursor); 362 scr->setHistCursor(cursor);
366 showBulk(); 363 showBulk();
367} 364}
368 365
369void TEmulation::onHorzCursorChange(int cursor) { 366void TEmulation::onHorzCursorChange(int cursor) {
370 if (!connected) return; 367 if (!connected) return;
371 scr->setHorzCursor(cursor); 368 scr->setHorzCursor(cursor);
372 showBulk(); 369 showBulk();
373} 370}
374 371
375void TEmulation::setColumns(int columns) { 372void TEmulation::setColumns(int columns) {
376 //FIXME: this goes strange ways. 373 //FIXME: this goes strange ways.
377 // Can we put this straight or explain it at least? 374 // Can we put this straight or explain it at least?
378 emit changeColumns(columns); 375 emit changeColumns(columns);
379} 376}
diff --git a/core/apps/embeddedkonsole/commandeditdialog.cpp b/core/apps/embeddedkonsole/commandeditdialog.cpp
index e4255f3..c0066d8 100644
--- a/core/apps/embeddedkonsole/commandeditdialog.cpp
+++ b/core/apps/embeddedkonsole/commandeditdialog.cpp
@@ -1,199 +1,191 @@
1//comandeditdialog.cpp 1//comandeditdialog.cpp
2 2
3#include "commandeditdialog.h" 3#include "commandeditdialog.h"
4#include "playlistselection.h" 4#include "playlistselection.h"
5#include <qstring.h>
6#include <qpe/config.h> 5#include <qpe/config.h>
7#include <qtoolbar.h>
8#include <qwidget.h>
9#include <qmenubar.h>
10#include <qpe/resource.h> 6#include <qpe/resource.h>
11#include <qlist.h>
12#include <qtoolbutton.h> 7#include <qtoolbutton.h>
13#include <qvbox.h>
14#include <qlistview.h>
15#include <qlineedit.h> 8#include <qlineedit.h>
16#include <qheader.h> 9#include <qheader.h>
17#include <qlabel.h> 10#include <qlabel.h>
18#include <qmessagebox.h>
19#include "smallcommandeditdialogbase.h" 11#include "smallcommandeditdialogbase.h"
20 12
21CommandEditDialog::CommandEditDialog(QWidget *parent, const char* name, WFlags fl ) 13CommandEditDialog::CommandEditDialog(QWidget *parent, const char* name, WFlags fl )
22 : CommandEditDialogBase(parent, name, TRUE, fl) 14 : CommandEditDialogBase(parent, name, TRUE, fl)
23 15
24{ 16{
25 m_SuggestedCommandList->addColumn( tr("Command Selection") ); 17 m_SuggestedCommandList->addColumn( tr("Command Selection") );
26 m_SuggestedCommandList->header()->hide(); 18 m_SuggestedCommandList->header()->hide();
27 m_SuggestedCommandList->setSorting(-1,FALSE); 19 m_SuggestedCommandList->setSorting(-1,FALSE);
28 m_SuggestedCommandList->clearSelection(); 20 m_SuggestedCommandList->clearSelection();
29 m_SuggestedCommandList->setSorting(0,TRUE); 21 m_SuggestedCommandList->setSorting(0,TRUE);
30 QListViewItem *item; 22 QListViewItem *item;
31 item = new QListViewItem( m_SuggestedCommandList,"export "); 23 item = new QListViewItem( m_SuggestedCommandList,"export ");
32 item = new QListViewItem( m_SuggestedCommandList,"ifconfig "); 24 item = new QListViewItem( m_SuggestedCommandList,"ifconfig ");
33 item = new QListViewItem( m_SuggestedCommandList,"ipkg "); 25 item = new QListViewItem( m_SuggestedCommandList,"ipkg ");
34 item = new QListViewItem( m_SuggestedCommandList,"gzip "); 26 item = new QListViewItem( m_SuggestedCommandList,"gzip ");
35 item = new QListViewItem( m_SuggestedCommandList,"gunzip "); 27 item = new QListViewItem( m_SuggestedCommandList,"gunzip ");
36 item = new QListViewItem( m_SuggestedCommandList,"chgrp "); 28 item = new QListViewItem( m_SuggestedCommandList,"chgrp ");
37 item = new QListViewItem( m_SuggestedCommandList,"chown "); 29 item = new QListViewItem( m_SuggestedCommandList,"chown ");
38 item = new QListViewItem( m_SuggestedCommandList,"date "); 30 item = new QListViewItem( m_SuggestedCommandList,"date ");
39 item = new QListViewItem( m_SuggestedCommandList,"dd "); 31 item = new QListViewItem( m_SuggestedCommandList,"dd ");
40 item = new QListViewItem( m_SuggestedCommandList,"dmesg "); 32 item = new QListViewItem( m_SuggestedCommandList,"dmesg ");
41 item = new QListViewItem( m_SuggestedCommandList,"fuser "); 33 item = new QListViewItem( m_SuggestedCommandList,"fuser ");
42 item = new QListViewItem( m_SuggestedCommandList,"hostname "); 34 item = new QListViewItem( m_SuggestedCommandList,"hostname ");
43 item = new QListViewItem( m_SuggestedCommandList,"kill "); 35 item = new QListViewItem( m_SuggestedCommandList,"kill ");
44 item = new QListViewItem( m_SuggestedCommandList,"killall "); 36 item = new QListViewItem( m_SuggestedCommandList,"killall ");
45 item = new QListViewItem( m_SuggestedCommandList,"ln "); 37 item = new QListViewItem( m_SuggestedCommandList,"ln ");
46 item = new QListViewItem( m_SuggestedCommandList,"ln -s "); 38 item = new QListViewItem( m_SuggestedCommandList,"ln -s ");
47 item = new QListViewItem( m_SuggestedCommandList,"lsmod"); 39 item = new QListViewItem( m_SuggestedCommandList,"lsmod");
48 item = new QListViewItem( m_SuggestedCommandList,"depmod -a"); 40 item = new QListViewItem( m_SuggestedCommandList,"depmod -a");
49 item = new QListViewItem( m_SuggestedCommandList,"modprobe "); 41 item = new QListViewItem( m_SuggestedCommandList,"modprobe ");
50 item = new QListViewItem( m_SuggestedCommandList,"mount "); 42 item = new QListViewItem( m_SuggestedCommandList,"mount ");
51 item = new QListViewItem( m_SuggestedCommandList,"more "); 43 item = new QListViewItem( m_SuggestedCommandList,"more ");
52 item = new QListViewItem( m_SuggestedCommandList,"sort "); 44 item = new QListViewItem( m_SuggestedCommandList,"sort ");
53 item = new QListViewItem( m_SuggestedCommandList,"touch "); 45 item = new QListViewItem( m_SuggestedCommandList,"touch ");
54 item = new QListViewItem( m_SuggestedCommandList,"umount "); 46 item = new QListViewItem( m_SuggestedCommandList,"umount ");
55 item = new QListViewItem( m_SuggestedCommandList,"mknod "); 47 item = new QListViewItem( m_SuggestedCommandList,"mknod ");
56 item = new QListViewItem( m_SuggestedCommandList,"netstat "); 48 item = new QListViewItem( m_SuggestedCommandList,"netstat ");
57 item = new QListViewItem( m_SuggestedCommandList,"route "); 49 item = new QListViewItem( m_SuggestedCommandList,"route ");
58 item = new QListViewItem( m_SuggestedCommandList,"cardctl eject "); 50 item = new QListViewItem( m_SuggestedCommandList,"cardctl eject ");
59 m_SuggestedCommandList->setSelected(m_SuggestedCommandList->firstChild(),TRUE); 51 m_SuggestedCommandList->setSelected(m_SuggestedCommandList->firstChild(),TRUE);
60 m_SuggestedCommandList->sort(); 52 m_SuggestedCommandList->sort();
61 53
62 connect( m_SuggestedCommandList, SIGNAL( clicked( QListViewItem * ) ), m_PlayListSelection, SLOT( addToSelection( QListViewItem *) ) ); 54 connect( m_SuggestedCommandList, SIGNAL( clicked( QListViewItem * ) ), m_PlayListSelection, SLOT( addToSelection( QListViewItem *) ) );
63 55
64 56
65 57
66 ToolButton1->setTextLabel("new"); 58 ToolButton1->setTextLabel("new");
67 ToolButton1->setPixmap(Resource::loadPixmap("new")); 59 ToolButton1->setPixmap(Resource::loadPixmap("new"));
68 ToolButton1->setAutoRaise(TRUE); 60 ToolButton1->setAutoRaise(TRUE);
69 ToolButton1->setFocusPolicy(QWidget::NoFocus); 61 ToolButton1->setFocusPolicy(QWidget::NoFocus);
70 connect(ToolButton1,SIGNAL(clicked()),this,SLOT(showAddDialog())); 62 connect(ToolButton1,SIGNAL(clicked()),this,SLOT(showAddDialog()));
71 63
72 ToolButton2->setTextLabel("edit"); 64 ToolButton2->setTextLabel("edit");
73 ToolButton2->setPixmap(Resource::loadPixmap("edit")); 65 ToolButton2->setPixmap(Resource::loadPixmap("edit"));
74 ToolButton2->setAutoRaise(TRUE); 66 ToolButton2->setAutoRaise(TRUE);
75 ToolButton2->setFocusPolicy(QWidget::NoFocus); 67 ToolButton2->setFocusPolicy(QWidget::NoFocus);
76 connect(ToolButton2,SIGNAL(clicked()),this,SLOT(showEditDialog())); 68 connect(ToolButton2,SIGNAL(clicked()),this,SLOT(showEditDialog()));
77 69
78 ToolButton3->setTextLabel("delete"); 70 ToolButton3->setTextLabel("delete");
79 ToolButton3->setPixmap(Resource::loadPixmap("editdelete")); 71 ToolButton3->setPixmap(Resource::loadPixmap("editdelete"));
80 ToolButton3->setAutoRaise(TRUE); 72 ToolButton3->setAutoRaise(TRUE);
81 ToolButton3->setFocusPolicy(QWidget::NoFocus); 73 ToolButton3->setFocusPolicy(QWidget::NoFocus);
82 connect(ToolButton3,SIGNAL(clicked()),m_PlayListSelection,SLOT(removeSelected())); 74 connect(ToolButton3,SIGNAL(clicked()),m_PlayListSelection,SLOT(removeSelected()));
83 75
84 ToolButton4->setTextLabel("up"); 76 ToolButton4->setTextLabel("up");
85 ToolButton4->setPixmap(Resource::loadPixmap("up")); 77 ToolButton4->setPixmap(Resource::loadPixmap("up"));
86 ToolButton4->setAutoRaise(TRUE); 78 ToolButton4->setAutoRaise(TRUE);
87 ToolButton4->setFocusPolicy(QWidget::NoFocus); 79 ToolButton4->setFocusPolicy(QWidget::NoFocus);
88 connect(ToolButton4,SIGNAL(clicked()),m_PlayListSelection,SLOT(moveSelectedUp())); 80 connect(ToolButton4,SIGNAL(clicked()),m_PlayListSelection,SLOT(moveSelectedUp()));
89 81
90 ToolButton5->setTextLabel("down"); 82 ToolButton5->setTextLabel("down");
91 ToolButton5->setPixmap(Resource::loadPixmap("down")); 83 ToolButton5->setPixmap(Resource::loadPixmap("down"));
92 ToolButton5->setAutoRaise(TRUE); 84 ToolButton5->setAutoRaise(TRUE);
93 ToolButton5->setFocusPolicy(QWidget::NoFocus); 85 ToolButton5->setFocusPolicy(QWidget::NoFocus);
94 86
95connect(ToolButton5,SIGNAL(clicked()),m_PlayListSelection,SLOT(moveSelectedDown())); 87connect(ToolButton5,SIGNAL(clicked()),m_PlayListSelection,SLOT(moveSelectedDown()));
96 88
97 89
98 90
99 91
100 QListViewItem *current = m_SuggestedCommandList->selectedItem(); 92 QListViewItem *current = m_SuggestedCommandList->selectedItem();
101 if ( current ) 93 if ( current )
102 item->moveItem( current ); 94 item->moveItem( current );
103 m_SuggestedCommandList->setSelected( item, TRUE ); 95 m_SuggestedCommandList->setSelected( item, TRUE );
104 m_SuggestedCommandList->ensureItemVisible( m_SuggestedCommandList->selectedItem() ); 96 m_SuggestedCommandList->ensureItemVisible( m_SuggestedCommandList->selectedItem() );
105 Config cfg( "Konsole" ); 97 Config cfg( "Konsole" );
106 cfg.setGroup("Commands"); 98 cfg.setGroup("Commands");
107 if (cfg.readEntry("Commands Set","FALSE") == "TRUE") { 99 if (cfg.readEntry("Commands Set","FALSE") == "TRUE") {
108 for (int i = 0; i < 100; i++) { 100 for (int i = 0; i < 100; i++) {
109 QString tmp; 101 QString tmp;
110 tmp = cfg.readEntry( QString::number(i),""); 102 tmp = cfg.readEntry( QString::number(i),"");
111 if (!tmp.isEmpty()) 103 if (!tmp.isEmpty())
112 m_PlayListSelection->addStringToSelection(tmp); 104 m_PlayListSelection->addStringToSelection(tmp);
113 } 105 }
114 } else { 106 } else {
115 107
116m_PlayListSelection->addStringToSelection("ls "); 108m_PlayListSelection->addStringToSelection("ls ");
117m_PlayListSelection->addStringToSelection("cardctl eject"); 109m_PlayListSelection->addStringToSelection("cardctl eject");
118m_PlayListSelection->addStringToSelection("cat "); 110m_PlayListSelection->addStringToSelection("cat ");
119m_PlayListSelection->addStringToSelection("cd "); 111m_PlayListSelection->addStringToSelection("cd ");
120m_PlayListSelection->addStringToSelection("chmod "); 112m_PlayListSelection->addStringToSelection("chmod ");
121m_PlayListSelection->addStringToSelection("cp "); 113m_PlayListSelection->addStringToSelection("cp ");
122m_PlayListSelection->addStringToSelection("dc "); 114m_PlayListSelection->addStringToSelection("dc ");
123m_PlayListSelection->addStringToSelection("df "); 115m_PlayListSelection->addStringToSelection("df ");
124m_PlayListSelection->addStringToSelection("dmesg"); 116m_PlayListSelection->addStringToSelection("dmesg");
125m_PlayListSelection->addStringToSelection("echo "); 117m_PlayListSelection->addStringToSelection("echo ");
126m_PlayListSelection->addStringToSelection("env"); 118m_PlayListSelection->addStringToSelection("env");
127m_PlayListSelection->addStringToSelection("find "); 119m_PlayListSelection->addStringToSelection("find ");
128m_PlayListSelection->addStringToSelection("free"); 120m_PlayListSelection->addStringToSelection("free");
129m_PlayListSelection->addStringToSelection("grep "); 121m_PlayListSelection->addStringToSelection("grep ");
130m_PlayListSelection->addStringToSelection("ifconfig "); 122m_PlayListSelection->addStringToSelection("ifconfig ");
131m_PlayListSelection->addStringToSelection("ipkg "); 123m_PlayListSelection->addStringToSelection("ipkg ");
132m_PlayListSelection->addStringToSelection("mkdir "); 124m_PlayListSelection->addStringToSelection("mkdir ");
133m_PlayListSelection->addStringToSelection("mv "); 125m_PlayListSelection->addStringToSelection("mv ");
134m_PlayListSelection->addStringToSelection("nc localhost 7776"); 126m_PlayListSelection->addStringToSelection("nc localhost 7776");
135m_PlayListSelection->addStringToSelection("nc localhost 7777"); 127m_PlayListSelection->addStringToSelection("nc localhost 7777");
136m_PlayListSelection->addStringToSelection("nslookup "); 128m_PlayListSelection->addStringToSelection("nslookup ");
137m_PlayListSelection->addStringToSelection("ping "); 129m_PlayListSelection->addStringToSelection("ping ");
138m_PlayListSelection->addStringToSelection("ps aux"); 130m_PlayListSelection->addStringToSelection("ps aux");
139m_PlayListSelection->addStringToSelection("pwd "); 131m_PlayListSelection->addStringToSelection("pwd ");
140m_PlayListSelection->addStringToSelection("rm "); 132m_PlayListSelection->addStringToSelection("rm ");
141m_PlayListSelection->addStringToSelection("rmdir "); 133m_PlayListSelection->addStringToSelection("rmdir ");
142m_PlayListSelection->addStringToSelection("route "); 134m_PlayListSelection->addStringToSelection("route ");
143m_PlayListSelection->addStringToSelection("set "); 135m_PlayListSelection->addStringToSelection("set ");
144m_PlayListSelection->addStringToSelection("traceroute"); 136m_PlayListSelection->addStringToSelection("traceroute");
145 137
146} 138}
147} 139}
148CommandEditDialog::~CommandEditDialog() 140CommandEditDialog::~CommandEditDialog()
149{ 141{
150} 142}
151 143
152void CommandEditDialog::accept() 144void CommandEditDialog::accept()
153{ 145{
154int i = 0; 146int i = 0;
155 Config *cfg = new Config("Konsole"); 147 Config *cfg = new Config("Konsole");
156 cfg->setGroup("Commands"); 148 cfg->setGroup("Commands");
157 cfg->clearGroup(); 149 cfg->clearGroup();
158 150
159 QListViewItemIterator it( m_PlayListSelection ); 151 QListViewItemIterator it( m_PlayListSelection );
160 152
161 for ( ; it.current(); ++it ) { 153 for ( ; it.current(); ++it ) {
162// qDebug(it.current()->text(0)); 154// qDebug(it.current()->text(0));
163 cfg->writeEntry(QString::number(i),it.current()->text(0)); 155 cfg->writeEntry(QString::number(i),it.current()->text(0));
164 i++; 156 i++;
165 157
166 } 158 }
167 cfg->writeEntry("Commands Set","TRUE"); 159 cfg->writeEntry("Commands Set","TRUE");
168// qDebug("CommandEditDialog::accept() - written"); 160// qDebug("CommandEditDialog::accept() - written");
169 delete cfg; 161 delete cfg;
170 emit commandsEdited(); 162 emit commandsEdited();
171 close(); 163 close();
172 164
173 165
174 166
175 167
176 168
177} 169}
178 170
179void CommandEditDialog::showEditDialog() 171void CommandEditDialog::showEditDialog()
180{ 172{
181editCommandBase *d = new editCommandBase(this,"smalleditdialog", TRUE); 173editCommandBase *d = new editCommandBase(this,"smalleditdialog", TRUE);
182d->setCaption("Edit command"); 174d->setCaption("Edit command");
183d->TextLabel->setText("Edit command:"); 175d->TextLabel->setText("Edit command:");
184d->commandEdit->setText(m_PlayListSelection->currentItem()->text(0)); 176d->commandEdit->setText(m_PlayListSelection->currentItem()->text(0));
185int i = d->exec(); 177int i = d->exec();
186if ((i==1) && (!(d->commandEdit->text()).isEmpty())) 178if ((i==1) && (!(d->commandEdit->text()).isEmpty()))
187 m_PlayListSelection->currentItem()->setText(0,(d->commandEdit->text())); 179 m_PlayListSelection->currentItem()->setText(0,(d->commandEdit->text()));
188} 180}
189 181
190void CommandEditDialog::showAddDialog() 182void CommandEditDialog::showAddDialog()
191{ 183{
192 184
193editCommandBase *d = new editCommandBase(this,"smalleditdialog", TRUE); 185editCommandBase *d = new editCommandBase(this,"smalleditdialog", TRUE);
194int i = d->exec(); 186int i = d->exec();
195if ((i==1) && (!(d->commandEdit->text()).isEmpty())) 187if ((i==1) && (!(d->commandEdit->text()).isEmpty()))
196m_PlayListSelection->addStringToSelection(d->commandEdit->text()); 188m_PlayListSelection->addStringToSelection(d->commandEdit->text());
197 189
198} 190}
199 191
diff --git a/core/apps/embeddedkonsole/commandeditwidget.cpp b/core/apps/embeddedkonsole/commandeditwidget.cpp
index 6a2c482..ed8dade 100644
--- a/core/apps/embeddedkonsole/commandeditwidget.cpp
+++ b/core/apps/embeddedkonsole/commandeditwidget.cpp
@@ -1,64 +1,60 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 3 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
4 =. 4 =.
5 .=l. 5 .=l.
6           .>+-= 6           .>+-=
7 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU General Public 9:`=1 )Y*s>-.--   : the terms of the GNU General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_. 13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 20++=   -.     .`     .: details.
21 :     =  ...= . :.=- 21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28 28
29*/ 29*/
30#include "commandeditwidget.h" 30#include "commandeditwidget.h"
31 31
32#include <qpushbutton.h>
33#include "playlistselection.h" 32#include "playlistselection.h"
34#include <qlayout.h> 33#include <qlayout.h>
35#include <qvariant.h>
36#include <qtooltip.h>
37#include <qwhatsthis.h>
38 34
39/* 35/*
40 * Constructs a Form1 which is a child of 'parent', with the 36 * Constructs a Form1 which is a child of 'parent', with the
41 * name 'name' and widget flags set to 'f' 37 * name 'name' and widget flags set to 'f'
42 */ 38 */
43Form1::Form1( QWidget* parent, const char* name, WFlags fl ) 39Form1::Form1( QWidget* parent, const char* name, WFlags fl )
44 : QWidget( parent, name, fl ) 40 : QWidget( parent, name, fl )
45{ 41{
46 if ( !name ) 42 if ( !name )
47 resize( 596, 480 ); 43 resize( 596, 480 );
48 Form1Layout = new QGridLayout( this ); 44 Form1Layout = new QGridLayout( this );
49 Form1Layout->setSpacing( 6 ); 45 Form1Layout->setSpacing( 6 );
50 Form1Layout->setMargin( 11 ); 46 Form1Layout->setMargin( 11 );
51 47
52 MyCustomWidget1 = new PlayListSelection( this, "MyCustomWidget1" ); 48 MyCustomWidget1 = new PlayListSelection( this, "MyCustomWidget1" );
53 49
54 Form1Layout->addWidget( MyCustomWidget1, 0, 0 ); 50 Form1Layout->addWidget( MyCustomWidget1, 0, 0 );
55} 51}
56 52
57/* 53/*
58 * Destroys the object and frees any allocated resources 54 * Destroys the object and frees any allocated resources
59 */ 55 */
60Form1::~Form1() 56Form1::~Form1()
61{ 57{
62 // no need to delete child widgets, Qt does it all for us 58 // no need to delete child widgets, Qt does it all for us
63} 59}
64 60
diff --git a/core/apps/embeddedkonsole/keytrans.cpp b/core/apps/embeddedkonsole/keytrans.cpp
index d569ae0..45a7960 100644
--- a/core/apps/embeddedkonsole/keytrans.cpp
+++ b/core/apps/embeddedkonsole/keytrans.cpp
@@ -1,706 +1,705 @@
1/* -------------------------------------------------------------------------- */ 1/* -------------------------------------------------------------------------- */
2/* */ 2/* */
3/* [keytrans.C] Keyboard Translation */ 3/* [keytrans.C] Keyboard Translation */
4/* */ 4/* */
5/* -------------------------------------------------------------------------- */ 5/* -------------------------------------------------------------------------- */
6/* */ 6/* */
7/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ 7/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */
8/* */ 8/* */
9/* This file is part of Konsole - an X terminal for KDE */ 9/* This file is part of Konsole - an X terminal for KDE */
10/* */ 10/* */
11/* -------------------------------------------------------------------------- */ 11/* -------------------------------------------------------------------------- */
12 /* */ 12 /* */
13/* Ported Konsole to Qt/Embedded */ 13/* Ported Konsole to Qt/Embedded */
14 /* */ 14 /* */
15/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ 15/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */
16 /* */ 16 /* */
17/* -------------------------------------------------------------------------- */ 17/* -------------------------------------------------------------------------- */
18 18
19/* 19/*
20 The keyboard translation table allows to configure konsoles behavior 20 The keyboard translation table allows to configure konsoles behavior
21 on key strokes. 21 on key strokes.
22 22
23 FIXME: some bug crept in, disallowing '\0' to be emitted. 23 FIXME: some bug crept in, disallowing '\0' to be emitted.
24*/ 24*/
25 25
26#include "keytrans.h" 26#include "keytrans.h"
27 27
28#include <qpe/qpeapplication.h> 28#include <qpe/qpeapplication.h>
29 29
30#include <qnamespace.h> 30#include <qnamespace.h>
31#include <qbuffer.h> 31#include <qbuffer.h>
32#include <qobject.h> 32#include <qobject.h>
33#include <qdict.h> 33#include <qdict.h>
34#include <qintdict.h> 34#include <qintdict.h>
35#include <qfile.h> 35#include <qfile.h>
36#include <qglobal.h> 36#include <qglobal.h>
37#include <qdir.h> 37#include <qdir.h>
38 38
39//#include <kstddirs.h> 39//#include <kstddirs.h>
40//nclude <klocale.h> 40//nclude <klocale.h>
41 41
42#include <stdio.h> 42#include <stdio.h>
43 43
44 44
45#undef USE_APPDATA_DIR 45#undef USE_APPDATA_DIR
46 46
47 47
48#define HERE printf("%s(%d): here\n",__FILE__,__LINE__) 48#define HERE printf("%s(%d): here\n",__FILE__,__LINE__)
49 49
50/* KeyEntry 50/* KeyEntry
51 51
52 instances represent the individual assignments 52 instances represent the individual assignments
53*/ 53*/
54 54
55KeyTrans::KeyEntry::KeyEntry(int _ref, int _key, int _bits, int _mask, int _cmd, QString _txt) 55KeyTrans::KeyEntry::KeyEntry(int _ref, int _key, int _bits, int _mask, int _cmd, QString _txt)
56: ref(_ref), key(_key), bits(_bits), mask(_mask), cmd(_cmd), txt(_txt) 56: ref(_ref), key(_key), bits(_bits), mask(_mask), cmd(_cmd), txt(_txt)
57{ 57{
58} 58}
59 59
60KeyTrans::KeyEntry::~KeyEntry() 60KeyTrans::KeyEntry::~KeyEntry()
61{ 61{
62} 62}
63 63
64bool KeyTrans::KeyEntry::matches(int _key, int _bits, int _mask) 64bool KeyTrans::KeyEntry::matches(int _key, int _bits, int _mask)
65{ int m = mask & _mask; 65{ int m = mask & _mask;
66 return _key == key && (bits & m) == (_bits & m); 66 return _key == key && (bits & m) == (_bits & m);
67} 67}
68 68
69QString KeyTrans::KeyEntry::text() 69QString KeyTrans::KeyEntry::text()
70{ 70{
71 return txt; 71 return txt;
72} 72}
73 73
74/* KeyTrans 74/* KeyTrans
75 75
76 combines the individual assignments to a proper map 76 combines the individual assignments to a proper map
77 Takes part in a collection themself. 77 Takes part in a collection themself.
78*/ 78*/
79 79
80KeyTrans::KeyTrans() 80KeyTrans::KeyTrans()
81{ 81{
82 path = ""; 82 path = "";
83 numb = 0; 83 numb = 0;
84} 84}
85 85
86KeyTrans::~KeyTrans() 86KeyTrans::~KeyTrans()
87{ 87{
88} 88}
89 89
90KeyTrans::KeyEntry* KeyTrans::addEntry(int ref, int key, int bits, int mask, int cmd, QString txt) 90KeyTrans::KeyEntry* KeyTrans::addEntry(int ref, int key, int bits, int mask, int cmd, QString txt)
91// returns conflicting entry 91// returns conflicting entry
92{ 92{
93 for (QListIterator<KeyEntry> it(table); it.current(); ++it) 93 for (QListIterator<KeyEntry> it(table); it.current(); ++it)
94 { 94 {
95 if (it.current()->matches(key,bits,mask)) 95 if (it.current()->matches(key,bits,mask))
96 { 96 {
97 return it.current(); 97 return it.current();
98 } 98 }
99 } 99 }
100 table.append(new KeyEntry(ref,key,bits,mask,cmd,txt)); 100 table.append(new KeyEntry(ref,key,bits,mask,cmd,txt));
101 return (KeyEntry*)NULL; 101 return (KeyEntry*)NULL;
102} 102}
103 103
104bool KeyTrans::findEntry(int key, int bits, int* cmd, const char** txt, int* len) 104bool KeyTrans::findEntry(int key, int bits, int* cmd, const char** txt, int* len)
105{ 105{
106 for (QListIterator<KeyEntry> it(table); it.current(); ++it) 106 for (QListIterator<KeyEntry> it(table); it.current(); ++it)
107 if (it.current()->matches(key,bits,0xffff)) 107 if (it.current()->matches(key,bits,0xffff))
108 { 108 {
109 *cmd = it.current()->cmd; 109 *cmd = it.current()->cmd;
110 *txt = it.current()->txt.ascii(); 110 *txt = it.current()->txt.ascii();
111 *len = it.current()->txt.length(); 111 *len = it.current()->txt.length();
112 return TRUE; 112 return TRUE;
113 } 113 }
114 return FALSE; 114 return FALSE;
115} 115}
116 116
117/* ------------------------------------------------------------------------- */ 117/* ------------------------------------------------------------------------- */
118/* */ 118/* */
119/* Scanner for keyboard configuration */ 119/* Scanner for keyboard configuration */
120/* */ 120/* */
121/* ------------------------------------------------------------------------- */ 121/* ------------------------------------------------------------------------- */
122 122
123// regular tokenizer 123// regular tokenizer
124/* Tokens 124/* Tokens
125 - Spaces 125 - Spaces
126 - Name (A-Za-z0-9)+ 126 - Name (A-Za-z0-9)+
127 - String 127 - String
128 - Opr on of +-: 128 - Opr on of +-:
129*/ 129*/
130 130
131#define SYMName 0 131#define SYMName 0
132#define SYMString 1 132#define SYMString 1
133#define SYMEol 2 133#define SYMEol 2
134#define SYMEof 3 134#define SYMEof 3
135#define SYMOpr 4 135#define SYMOpr 4
136#define SYMError 5 136#define SYMError 5
137 137
138#define inRange(L,X,H) ((L <= X) && (X <= H)) 138#define inRange(L,X,H) ((L <= X) && (X <= H))
139#define isNibble(X) (inRange('A',X,'F')||inRange('a',X,'f')||inRange('0',X,'9')) 139#define isNibble(X) (inRange('A',X,'F')||inRange('a',X,'f')||inRange('0',X,'9'))
140#define convNibble(X) (inRange('0',X,'9')?X-'0':X+10-(inRange('A',X,'F')?'A':'a')) 140#define convNibble(X) (inRange('0',X,'9')?X-'0':X+10-(inRange('A',X,'F')?'A':'a'))
141 141
142class KeytabReader 142class KeytabReader
143{ 143{
144public: 144public:
145 KeytabReader(QString p, QIODevice &d); 145 KeytabReader(QString p, QIODevice &d);
146public: 146public:
147 void getCc(); 147 void getCc();
148 void getSymbol(); 148 void getSymbol();
149 void parseTo(KeyTrans* kt); 149 void parseTo(KeyTrans* kt);
150 void ReportError(const char* msg); 150 void ReportError(const char* msg);
151 void ReportToken(); // diagnostic 151 void ReportToken(); // diagnostic
152private: 152private:
153 int sym; 153 int sym;
154 QString res; 154 QString res;
155 int len; 155 int len;
156 int slinno; 156 int slinno;
157 int scolno; 157 int scolno;
158private: 158private:
159 int cc; 159 int cc;
160 int linno; 160 int linno;
161 int colno; 161 int colno;
162 QIODevice* buf; 162 QIODevice* buf;
163 QString path; 163 QString path;
164}; 164};
165 165
166 166
167KeytabReader::KeytabReader(QString p, QIODevice &d) 167KeytabReader::KeytabReader(QString p, QIODevice &d)
168{ 168{
169 path = p; 169 path = p;
170 buf = &d; 170 buf = &d;
171 cc = 0; 171 cc = 0;
172} 172}
173 173
174void KeytabReader::getCc() 174void KeytabReader::getCc()
175{ 175{
176 if (cc == '\n') { linno += 1; colno = 0; } 176 if (cc == '\n') { linno += 1; colno = 0; }
177 if (cc < 0) return; 177 if (cc < 0) return;
178 cc = buf->getch(); 178 cc = buf->getch();
179 colno += 1; 179 colno += 1;
180} 180}
181 181
182void KeytabReader::getSymbol() 182void KeytabReader::getSymbol()
183{ 183{
184 res = ""; len = 0; sym = SYMError; 184 res = ""; len = 0; sym = SYMError;
185 while (cc == ' ') getCc(); // skip spaces 185 while (cc == ' ') getCc(); // skip spaces
186 if (cc == '#') // skip comment 186 if (cc == '#') // skip comment
187 { 187 {
188 while (cc != '\n' && cc > 0) getCc(); 188 while (cc != '\n' && cc > 0) getCc();
189 } 189 }
190 slinno = linno; 190 slinno = linno;
191 scolno = colno; 191 scolno = colno;
192 if (cc <= 0) 192 if (cc <= 0)
193 { 193 {
194 sym = SYMEof; return; // eos 194 sym = SYMEof; return; // eos
195 } 195 }
196 if (cc == '\n') 196 if (cc == '\n')
197 { 197 {
198 getCc(); 198 getCc();
199 sym = SYMEol; return; // eol 199 sym = SYMEol; return; // eol
200 } 200 }
201 if (inRange('A',cc,'Z')||inRange('a',cc,'z')||inRange('0',cc,'9')) 201 if (inRange('A',cc,'Z')||inRange('a',cc,'z')||inRange('0',cc,'9'))
202 { 202 {
203 while (inRange('A',cc,'Z') || inRange('a',cc,'z') || inRange('0',cc,'9')) 203 while (inRange('A',cc,'Z') || inRange('a',cc,'z') || inRange('0',cc,'9'))
204 { 204 {
205 res = res + (char)cc; 205 res = res + (char)cc;
206 getCc(); 206 getCc();
207 } 207 }
208 sym = SYMName; 208 sym = SYMName;
209 return; 209 return;
210 } 210 }
211 if (strchr("+-:",cc)) 211 if (strchr("+-:",cc))
212 { 212 {
213 res = ""; 213 res = "";
214 res = res + (char)cc; 214 res = res + (char)cc;
215 getCc(); 215 getCc();
216 sym = SYMOpr; return; 216 sym = SYMOpr; return;
217 } 217 }
218 if (cc == '"') 218 if (cc == '"')
219 { 219 {
220 getCc(); 220 getCc();
221 while (cc >= ' ' && cc != '"') 221 while (cc >= ' ' && cc != '"')
222 { int sc; 222 { int sc;
223 if (cc == '\\') // handle quotation 223 if (cc == '\\') // handle quotation
224 { 224 {
225 getCc(); 225 getCc();
226 switch (cc) 226 switch (cc)
227 { 227 {
228 case 'E' : sc = 27; getCc(); break; 228 case 'E' : sc = 27; getCc(); break;
229 case 'b' : sc = 8; getCc(); break; 229 case 'b' : sc = 8; getCc(); break;
230 case 'f' : sc = 12; getCc(); break; 230 case 'f' : sc = 12; getCc(); break;
231 case 't' : sc = 9; getCc(); break; 231 case 't' : sc = 9; getCc(); break;
232 case 'r' : sc = 13; getCc(); break; 232 case 'r' : sc = 13; getCc(); break;
233 case 'n' : sc = 10; getCc(); break; 233 case 'n' : sc = 10; getCc(); break;
234 case '\\' : // fall thru 234 case '\\' : // fall thru
235 case '"' : sc = cc; getCc(); break; 235 case '"' : sc = cc; getCc(); break;
236 case 'x' : getCc(); 236 case 'x' : getCc();
237 sc = 0; 237 sc = 0;
238 if (!isNibble(cc)) return; sc = 16*sc + convNibble(cc); getCc(); 238 if (!isNibble(cc)) return; sc = 16*sc + convNibble(cc); getCc();
239 if (!isNibble(cc)) return; sc = 16*sc + convNibble(cc); getCc(); 239 if (!isNibble(cc)) return; sc = 16*sc + convNibble(cc); getCc();
240 break; 240 break;
241 default : return; 241 default : return;
242 } 242 }
243 } 243 }
244 else 244 else
245 { 245 {
246 // regular char 246 // regular char
247 sc = cc; getCc(); 247 sc = cc; getCc();
248 } 248 }
249 res = res + (char)sc; 249 res = res + (char)sc;
250 len = len + 1; 250 len = len + 1;
251 } 251 }
252 if (cc != '"') return; 252 if (cc != '"') return;
253 getCc(); 253 getCc();
254 sym = SYMString; return; 254 sym = SYMString; return;
255 } 255 }
256} 256}
257 257
258void KeytabReader::ReportToken() // diagnostic 258void KeytabReader::ReportToken() // diagnostic
259{ 259{
260 printf("sym(%d): ",slinno); 260 printf("sym(%d): ",slinno);
261 switch(sym) 261 switch(sym)
262 { 262 {
263 case SYMEol : printf("End of line"); break; 263 case SYMEol : printf("End of line"); break;
264 case SYMEof : printf("End of file"); break; 264 case SYMEof : printf("End of file"); break;
265 case SYMName : printf("Name: %s",res.latin1()); break; 265 case SYMName : printf("Name: %s",res.latin1()); break;
266 case SYMOpr : printf("Opr : %s",res.latin1()); break; 266 case SYMOpr : printf("Opr : %s",res.latin1()); break;
267 case SYMString : printf("String len %d,%d ",res.length(),len); 267 case SYMString : printf("String len %d,%d ",res.length(),len);
268 for (unsigned i = 0; i < res.length(); i++) 268 for (unsigned i = 0; i < res.length(); i++)
269 printf(" %02x(%c)",res.latin1()[i],res.latin1()[i]>=' '?res.latin1()[i]:'?'); 269 printf(" %02x(%c)",res.latin1()[i],res.latin1()[i]>=' '?res.latin1()[i]:'?');
270 break; 270 break;
271 } 271 }
272 printf("\n"); 272 printf("\n");
273} 273}
274 274
275void KeytabReader::ReportError(const char* msg) // diagnostic 275void KeytabReader::ReportError(const char* msg) // diagnostic
276{ 276{
277 fprintf(stderr,"%s(%d,%d):error: %s.\n",path.ascii(),slinno,scolno,msg); 277 fprintf(stderr,"%s(%d,%d):error: %s.\n",path.ascii(),slinno,scolno,msg);
278} 278}
279 279
280// local symbol tables --------------------------------------------------------------------- 280// local symbol tables ---------------------------------------------------------------------
281 281
282class KeyTransSymbols 282class KeyTransSymbols
283{ 283{
284public: 284public:
285 KeyTransSymbols(); 285 KeyTransSymbols();
286protected: 286protected:
287 void defOprSyms(); 287 void defOprSyms();
288 void defModSyms(); 288 void defModSyms();
289 void defKeySyms(); 289 void defKeySyms();
290 void defKeySym(const char* key, int val); 290 void defKeySym(const char* key, int val);
291 void defOprSym(const char* key, int val); 291 void defOprSym(const char* key, int val);
292 void defModSym(const char* key, int val); 292 void defModSym(const char* key, int val);
293public: 293public:
294 QDict<QObject> keysyms; 294 QDict<QObject> keysyms;
295 QDict<QObject> modsyms; 295 QDict<QObject> modsyms;
296 QDict<QObject> oprsyms; 296 QDict<QObject> oprsyms;
297}; 297};
298 298
299static KeyTransSymbols * syms = 0L; 299static KeyTransSymbols * syms = 0L;
300 300
301// parser ---------------------------------------------------------------------------------- 301// parser ----------------------------------------------------------------------------------
302/* Syntax 302/* Syntax
303 - Line :: [KeyName { ("+" | "-") ModeName } ":" (String|CommandName)] "\n" 303 - Line :: [KeyName { ("+" | "-") ModeName } ":" (String|CommandName)] "\n"
304 - Comment :: '#' (any but \n)* 304 - Comment :: '#' (any but \n)*
305*/ 305*/
306 306
307KeyTrans* KeyTrans::fromDevice(QString path, QIODevice &buf) 307KeyTrans* KeyTrans::fromDevice(QString path, QIODevice &buf)
308{ 308{
309 KeyTrans* kt = new KeyTrans; 309 KeyTrans* kt = new KeyTrans;
310 kt->path = path; 310 kt->path = path;
311 KeytabReader ktr(path,buf); ktr.parseTo(kt); 311 KeytabReader ktr(path,buf); ktr.parseTo(kt);
312 return kt; 312 return kt;
313} 313}
314 314
315 315
316#define assertSyntax(Cond,Message) if (!(Cond)) { ReportError(Message); goto ERROR; } 316#define assertSyntax(Cond,Message) if (!(Cond)) { ReportError(Message); goto ERROR; }
317 317
318void KeytabReader::parseTo(KeyTrans* kt) 318void KeytabReader::parseTo(KeyTrans* kt)
319{ 319{
320 // Opening sequence 320 // Opening sequence
321 321
322 buf->open(IO_ReadOnly); 322 buf->open(IO_ReadOnly);
323 getCc(); 323 getCc();
324 linno = 1; 324 linno = 1;
325 colno = 1; 325 colno = 1;
326 getSymbol(); 326 getSymbol();
327 327
328Loop: 328Loop:
329 // syntax: ["key" KeyName { ("+" | "-") ModeName } ":" String/CommandName] ["#" Comment] 329 // syntax: ["key" KeyName { ("+" | "-") ModeName } ":" String/CommandName] ["#" Comment]
330 if (sym == SYMName && !strcmp(res.latin1(),"keyboard")) 330 if (sym == SYMName && !strcmp(res.latin1(),"keyboard"))
331 { 331 {
332 getSymbol(); assertSyntax(sym == SYMString, "Header expected") 332 getSymbol(); assertSyntax(sym == SYMString, "Header expected")
333 kt->hdr = res.latin1(); 333 kt->hdr = res.latin1();
334 getSymbol(); assertSyntax(sym == SYMEol, "Text unexpected") 334 getSymbol(); assertSyntax(sym == SYMEol, "Text unexpected")
335 getSymbol(); // eoln 335 getSymbol(); // eoln
336 goto Loop; 336 goto Loop;
337 } 337 }
338 if (sym == SYMName && !strcmp(res.latin1(),"key")) 338 if (sym == SYMName && !strcmp(res.latin1(),"key"))
339 { 339 {
340//printf("line %3d: ",startofsym); 340//printf("line %3d: ",startofsym);
341 getSymbol(); assertSyntax(sym == SYMName, "Name expected") 341 getSymbol(); assertSyntax(sym == SYMName, "Name expected")
342 assertSyntax(syms->keysyms[res], "Unknown key name") 342 assertSyntax(syms->keysyms[res], "Unknown key name")
343 int key = (int)syms->keysyms[res]-1; 343 int key = (int)syms->keysyms[res]-1;
344//printf(" key %s (%04x)",res.latin1(),(int)syms->keysyms[res]-1); 344//printf(" key %s (%04x)",res.latin1(),(int)syms->keysyms[res]-1);
345 getSymbol(); // + - : 345 getSymbol(); // + - :
346 int mode = 0; 346 int mode = 0;
347 int mask = 0; 347 int mask = 0;
348 while (sym == SYMOpr && (!strcmp(res.latin1(),"+") || !strcmp(res.latin1(),"-"))) 348 while (sym == SYMOpr && (!strcmp(res.latin1(),"+") || !strcmp(res.latin1(),"-")))
349 { 349 {
350 bool on = !strcmp(res.latin1(),"+"); 350 bool on = !strcmp(res.latin1(),"+");
351 getSymbol(); 351 getSymbol();
352 // mode name 352 // mode name
353 assertSyntax(sym == SYMName, "Name expected") 353 assertSyntax(sym == SYMName, "Name expected")
354 assertSyntax(syms->modsyms[res], "Unknown mode name") 354 assertSyntax(syms->modsyms[res], "Unknown mode name")
355 int bits = (int)syms->modsyms[res]-1; 355 int bits = (int)syms->modsyms[res]-1;
356 if (mask & (1 << bits)) 356 if (mask & (1 << bits))
357 { 357 {
358 fprintf(stderr,"%s(%d,%d): mode name used multible times.\n",path.ascii(),slinno,scolno); 358 fprintf(stderr,"%s(%d,%d): mode name used multible times.\n",path.ascii(),slinno,scolno);
359 } 359 }
360 else 360 else
361 { 361 {
362 mode |= (on << bits); 362 mode |= (on << bits);
363 mask |= (1 << bits); 363 mask |= (1 << bits);
364 } 364 }
365//printf(", mode %s(%d) %s",res.latin1(),(int)syms->modsyms[res]-1,on?"on":"off"); 365//printf(", mode %s(%d) %s",res.latin1(),(int)syms->modsyms[res]-1,on?"on":"off");
366 getSymbol(); 366 getSymbol();
367 } 367 }
368 assertSyntax(sym == SYMOpr && !strcmp(res.latin1(),":"), "':' expected") 368 assertSyntax(sym == SYMOpr && !strcmp(res.latin1(),":"), "':' expected")
369 getSymbol(); 369 getSymbol();
370 // string or command 370 // string or command
371 assertSyntax(sym == SYMName || sym == SYMString,"Command or string expected") 371 assertSyntax(sym == SYMName || sym == SYMString,"Command or string expected")
372 int cmd = 0; 372 int cmd = 0;
373 if (sym == SYMName) 373 if (sym == SYMName)
374 { 374 {
375 assertSyntax(syms->oprsyms[res], "Unknown operator name") 375 assertSyntax(syms->oprsyms[res], "Unknown operator name")
376 cmd = (int)syms->oprsyms[res]-1; 376 cmd = (int)syms->oprsyms[res]-1;
377//printf(": do %s(%d)",res.latin1(),(int)syms->oprsyms[res]-1); 377//printf(": do %s(%d)",res.latin1(),(int)syms->oprsyms[res]-1);
378 } 378 }
379 if (sym == SYMString) 379 if (sym == SYMString)
380 { 380 {
381 cmd = CMD_send; 381 cmd = CMD_send;
382//printf(": send"); 382//printf(": send");
383//for (unsigned i = 0; i < res.length(); i++) 383//for (unsigned i = 0; i < res.length(); i++)
384//printf(" %02x(%c)",res.latin1()[i],res.latin1()[i]>=' '?res.latin1()[i]:'?'); 384//printf(" %02x(%c)",res.latin1()[i],res.latin1()[i]>=' '?res.latin1()[i]:'?');
385 } 385 }
386//printf(". summary %04x,%02x,%02x,%d\n",key,mode,mask,cmd); 386//printf(". summary %04x,%02x,%02x,%d\n",key,mode,mask,cmd);
387 KeyTrans::KeyEntry* ke = kt->addEntry(slinno,key,mode,mask,cmd,res); 387 KeyTrans::KeyEntry* ke = kt->addEntry(slinno,key,mode,mask,cmd,res);
388 if (ke) 388 if (ke)
389 { 389 {
390 fprintf(stderr,"%s(%d): keystroke already assigned in line %d.\n",path.ascii(),slinno,ke->ref); 390 fprintf(stderr,"%s(%d): keystroke already assigned in line %d.\n",path.ascii(),slinno,ke->ref);
391 } 391 }
392 getSymbol(); 392 getSymbol();
393 assertSyntax(sym == SYMEol, "Unexpected text") 393 assertSyntax(sym == SYMEol, "Unexpected text")
394 goto Loop; 394 goto Loop;
395 } 395 }
396 if (sym == SYMEol) 396 if (sym == SYMEol)
397 { 397 {
398 getSymbol(); 398 getSymbol();
399 goto Loop; 399 goto Loop;
400 } 400 }
401 401
402 assertSyntax(sym == SYMEof, "Undecodable Line") 402 assertSyntax(sym == SYMEof, "Undecodable Line")
403 403
404 buf->close(); 404 buf->close();
405 return; 405 return;
406 406
407ERROR: 407ERROR:
408 while (sym != SYMEol && sym != SYMEof) getSymbol(); // eoln 408 while (sym != SYMEol && sym != SYMEof) getSymbol(); // eoln
409 goto Loop; 409 goto Loop;
410} 410}
411 411
412 412
413KeyTrans* KeyTrans::defaultKeyTrans() 413KeyTrans* KeyTrans::defaultKeyTrans()
414{ 414{
415 QCString txt = 415 QCString txt =
416#include "default.keytab.h" 416 #include "default.keytab.h"
417 ; 417 ;
418 QBuffer buf(txt); 418 QBuffer buf(txt);
419 return fromDevice("[buildin]",buf); 419 return fromDevice("[buildin]",buf);
420} 420}
421 421
422KeyTrans* KeyTrans::fromFile(const char* path) 422KeyTrans* KeyTrans::fromFile(const char* path)
423{ 423{
424 QFile file(path); 424 QFile file(path);
425 return fromDevice(path,file); 425 return fromDevice(path,file);
426} 426}
427 427
428// local symbol tables --------------------------------------------------------------------- 428// local symbol tables ---------------------------------------------------------------------
429// material needed for parsing the config file. 429// material needed for parsing the config file.
430// This is incomplete work. 430// This is incomplete work.
431 431
432void KeyTransSymbols::defKeySym(const char* key, int val) 432void KeyTransSymbols::defKeySym(const char* key, int val)
433{ 433{
434 keysyms.insert(key,(QObject*)(val+1)); 434 keysyms.insert(key,(QObject*)(val+1));
435} 435}
436 436
437void KeyTransSymbols::defOprSym(const char* key, int val) 437void KeyTransSymbols::defOprSym(const char* key, int val)
438{ 438{
439 oprsyms.insert(key,(QObject*)(val+1)); 439 oprsyms.insert(key,(QObject*)(val+1));
440} 440}
441 441
442void KeyTransSymbols::defModSym(const char* key, int val) 442void KeyTransSymbols::defModSym(const char* key, int val)
443{ 443{
444 modsyms.insert(key,(QObject*)(val+1)); 444 modsyms.insert(key,(QObject*)(val+1));
445} 445}
446 446
447void KeyTransSymbols::defOprSyms() 447void KeyTransSymbols::defOprSyms()
448{ 448{
449 // Modifier 449 // Modifier
450 defOprSym("scrollLineUp", CMD_scrollLineUp ); 450 defOprSym("scrollLineUp", CMD_scrollLineUp );
451 defOprSym("scrollLineDown",CMD_scrollLineDown); 451 defOprSym("scrollLineDown",CMD_scrollLineDown);
452 defOprSym("scrollPageUp", CMD_scrollPageUp ); 452 defOprSym("scrollPageUp", CMD_scrollPageUp );
453 defOprSym("scrollPageDown",CMD_scrollPageDown); 453 defOprSym("scrollPageDown",CMD_scrollPageDown);
454 defOprSym("emitSelection", CMD_emitSelection ); 454 defOprSym("emitSelection", CMD_emitSelection );
455 defOprSym("prevSession", CMD_prevSession ); 455 defOprSym("prevSession", CMD_prevSession );
456 defOprSym("nextSession", CMD_nextSession ); 456 defOprSym("nextSession", CMD_nextSession );
457} 457}
458 458
459void KeyTransSymbols::defModSyms() 459void KeyTransSymbols::defModSyms()
460{ 460{
461 // Modifier 461 // Modifier
462 defModSym("Shift", BITS_Shift ); 462 defModSym("Shift", BITS_Shift );
463 defModSym("Control", BITS_Control ); 463 defModSym("Control", BITS_Control );
464 defModSym("Alt", BITS_Alt ); 464 defModSym("Alt", BITS_Alt );
465 // Modes 465 // Modes
466 defModSym("BsHack", BITS_BsHack ); // deprecated 466 defModSym("BsHack", BITS_BsHack ); // deprecated
467 defModSym("Ansi", BITS_Ansi ); 467 defModSym("Ansi", BITS_Ansi );
468 defModSym("NewLine", BITS_NewLine ); 468 defModSym("NewLine", BITS_NewLine );
469 defModSym("AppCuKeys", BITS_AppCuKeys ); 469 defModSym("AppCuKeys", BITS_AppCuKeys );
470} 470}
471 471
472void KeyTransSymbols::defKeySyms() 472void KeyTransSymbols::defKeySyms()
473{ 473{
474 // Grey keys 474 // Grey keys
475 defKeySym("Escape", Qt::Key_Escape ); 475 defKeySym("Escape", Qt::Key_Escape );
476 defKeySym("Tab", Qt::Key_Tab ); 476 defKeySym("Tab", Qt::Key_Tab );
477 defKeySym("Backtab", Qt::Key_Backtab ); 477 defKeySym("Backtab", Qt::Key_Backtab );
478 defKeySym("Backspace", Qt::Key_Backspace ); 478 defKeySym("Backspace", Qt::Key_Backspace );
479 defKeySym("Return", Qt::Key_Return ); 479 defKeySym("Return", Qt::Key_Return );
480 defKeySym("Enter", Qt::Key_Enter ); 480 defKeySym("Enter", Qt::Key_Enter );
481 defKeySym("Insert", Qt::Key_Insert ); 481 defKeySym("Insert", Qt::Key_Insert );
482 defKeySym("Delete", Qt::Key_Delete ); 482 defKeySym("Delete", Qt::Key_Delete );
483 defKeySym("Pause", Qt::Key_Pause ); 483 defKeySym("Pause", Qt::Key_Pause );
484 defKeySym("Print", Qt::Key_Print ); 484 defKeySym("Print", Qt::Key_Print );
485 defKeySym("SysReq", Qt::Key_SysReq ); 485 defKeySym("SysReq", Qt::Key_SysReq );
486 defKeySym("Home", Qt::Key_Home ); 486 defKeySym("Home", Qt::Key_Home );
487 defKeySym("End", Qt::Key_End ); 487 defKeySym("End", Qt::Key_End );
488 defKeySym("Left", Qt::Key_Left ); 488 defKeySym("Left", Qt::Key_Left );
489 defKeySym("Up", Qt::Key_Up ); 489 defKeySym("Up", Qt::Key_Up );
490 defKeySym("Right", Qt::Key_Right ); 490 defKeySym("Right", Qt::Key_Right );
491 defKeySym("Down", Qt::Key_Down ); 491 defKeySym("Down", Qt::Key_Down );
492 defKeySym("Prior", Qt::Key_Prior ); 492 defKeySym("Prior", Qt::Key_Prior );
493 defKeySym("Next", Qt::Key_Next ); 493 defKeySym("Next", Qt::Key_Next );
494 defKeySym("Shift", Qt::Key_Shift ); 494 defKeySym("Shift", Qt::Key_Shift );
495 defKeySym("Control", Qt::Key_Control ); 495 defKeySym("Control", Qt::Key_Control );
496 defKeySym("Meta", Qt::Key_Meta ); 496 defKeySym("Meta", Qt::Key_Meta );
497 defKeySym("Alt", Qt::Key_Alt ); 497 defKeySym("Alt", Qt::Key_Alt );
498 defKeySym("CapsLock", Qt::Key_CapsLock ); 498 defKeySym("CapsLock", Qt::Key_CapsLock );
499 defKeySym("NumLock", Qt::Key_NumLock ); 499 defKeySym("NumLock", Qt::Key_NumLock );
500 defKeySym("ScrollLock", Qt::Key_ScrollLock ); 500 defKeySym("ScrollLock", Qt::Key_ScrollLock );
501 defKeySym("F1", Qt::Key_F1 ); 501 defKeySym("F1", Qt::Key_F1 );
502 defKeySym("F2", Qt::Key_F2 ); 502 defKeySym("F2", Qt::Key_F2 );
503 defKeySym("F3", Qt::Key_F3 ); 503 defKeySym("F3", Qt::Key_F3 );
504 defKeySym("F4", Qt::Key_F4 ); 504 defKeySym("F4", Qt::Key_F4 );
505 defKeySym("F5", Qt::Key_F5 ); 505 defKeySym("F5", Qt::Key_F5 );
506 defKeySym("F6", Qt::Key_F6 ); 506 defKeySym("F6", Qt::Key_F6 );
507 defKeySym("F7", Qt::Key_F7 ); 507 defKeySym("F7", Qt::Key_F7 );
508 defKeySym("F8", Qt::Key_F8 ); 508 defKeySym("F8", Qt::Key_F8 );
509 defKeySym("F9", Qt::Key_F9 ); 509 defKeySym("F9", Qt::Key_F9 );
510 defKeySym("F10", Qt::Key_F10 ); 510 defKeySym("F10", Qt::Key_F10 );
511 defKeySym("F11", Qt::Key_F11 ); 511 defKeySym("F11", Qt::Key_F11 );
512 defKeySym("F12", Qt::Key_F12 ); 512 defKeySym("F12", Qt::Key_F12 );
513 defKeySym("F13", Qt::Key_F13 ); 513 defKeySym("F13", Qt::Key_F13 );
514 defKeySym("F14", Qt::Key_F14 ); 514 defKeySym("F14", Qt::Key_F14 );
515 defKeySym("F15", Qt::Key_F15 ); 515 defKeySym("F15", Qt::Key_F15 );
516 defKeySym("F16", Qt::Key_F16 ); 516 defKeySym("F16", Qt::Key_F16 );
517 defKeySym("F17", Qt::Key_F17 ); 517 defKeySym("F17", Qt::Key_F17 );
518 defKeySym("F18", Qt::Key_F18 ); 518 defKeySym("F18", Qt::Key_F18 );
519 defKeySym("F19", Qt::Key_F19 ); 519 defKeySym("F19", Qt::Key_F19 );
520 defKeySym("F20", Qt::Key_F20 ); 520 defKeySym("F20", Qt::Key_F20 );
521 defKeySym("F21", Qt::Key_F21 ); 521 defKeySym("F21", Qt::Key_F21 );
522 defKeySym("F22", Qt::Key_F22 ); 522 defKeySym("F22", Qt::Key_F22 );
523 defKeySym("F23", Qt::Key_F23 ); 523 defKeySym("F23", Qt::Key_F23 );
524 defKeySym("F24", Qt::Key_F24 ); 524 defKeySym("F24", Qt::Key_F24 );
525 defKeySym("F25", Qt::Key_F25 ); 525 defKeySym("F25", Qt::Key_F25 );
526 defKeySym("F26", Qt::Key_F26 ); 526 defKeySym("F26", Qt::Key_F26 );
527 defKeySym("F27", Qt::Key_F27 ); 527 defKeySym("F27", Qt::Key_F27 );
528 defKeySym("F28", Qt::Key_F28 ); 528 defKeySym("F28", Qt::Key_F28 );
529 defKeySym("F29", Qt::Key_F29 ); 529 defKeySym("F29", Qt::Key_F29 );
530 defKeySym("F30", Qt::Key_F30 ); 530 defKeySym("F30", Qt::Key_F30 );
531 defKeySym("F31", Qt::Key_F31 ); 531 defKeySym("F31", Qt::Key_F31 );
532 defKeySym("F32", Qt::Key_F32 ); 532 defKeySym("F32", Qt::Key_F32 );
533 defKeySym("F33", Qt::Key_F33 ); 533 defKeySym("F33", Qt::Key_F33 );
534 defKeySym("F34", Qt::Key_F34 ); 534 defKeySym("F34", Qt::Key_F34 );
535 defKeySym("F35", Qt::Key_F35 ); 535 defKeySym("F35", Qt::Key_F35 );
536 defKeySym("Super_L", Qt::Key_Super_L ); 536 defKeySym("Super_L", Qt::Key_Super_L );
537 defKeySym("Super_R", Qt::Key_Super_R ); 537 defKeySym("Super_R", Qt::Key_Super_R );
538 defKeySym("Menu", Qt::Key_Menu ); 538 defKeySym("Menu", Qt::Key_Menu );
539 defKeySym("Hyper_L", Qt::Key_Hyper_L ); 539 defKeySym("Hyper_L", Qt::Key_Hyper_L );
540 defKeySym("Hyper_R", Qt::Key_Hyper_R ); 540 defKeySym("Hyper_R", Qt::Key_Hyper_R );
541 541
542 // Regular keys 542 // Regular keys
543 defKeySym("Space", Qt::Key_Space ); 543 defKeySym("Space", Qt::Key_Space );
544 defKeySym("Exclam", Qt::Key_Exclam ); 544 defKeySym("Exclam", Qt::Key_Exclam );
545 defKeySym("QuoteDbl", Qt::Key_QuoteDbl ); 545 defKeySym("QuoteDbl", Qt::Key_QuoteDbl );
546 defKeySym("NumberSign", Qt::Key_NumberSign ); 546 defKeySym("NumberSign", Qt::Key_NumberSign );
547 defKeySym("Dollar", Qt::Key_Dollar ); 547 defKeySym("Dollar", Qt::Key_Dollar );
548 defKeySym("Percent", Qt::Key_Percent ); 548 defKeySym("Percent", Qt::Key_Percent );
549 defKeySym("Ampersand", Qt::Key_Ampersand ); 549 defKeySym("Ampersand", Qt::Key_Ampersand );
550 defKeySym("Apostrophe", Qt::Key_Apostrophe ); 550 defKeySym("Apostrophe", Qt::Key_Apostrophe );
551 defKeySym("ParenLeft", Qt::Key_ParenLeft ); 551 defKeySym("ParenLeft", Qt::Key_ParenLeft );
552 defKeySym("ParenRight", Qt::Key_ParenRight ); 552 defKeySym("ParenRight", Qt::Key_ParenRight );
553 defKeySym("Asterisk", Qt::Key_Asterisk ); 553 defKeySym("Asterisk", Qt::Key_Asterisk );
554 defKeySym("Plus", Qt::Key_Plus ); 554 defKeySym("Plus", Qt::Key_Plus );
555 defKeySym("Comma", Qt::Key_Comma ); 555 defKeySym("Comma", Qt::Key_Comma );
556 defKeySym("Minus", Qt::Key_Minus ); 556 defKeySym("Minus", Qt::Key_Minus );
557 defKeySym("Period", Qt::Key_Period ); 557 defKeySym("Period", Qt::Key_Period );
558 defKeySym("Slash", Qt::Key_Slash ); 558 defKeySym("Slash", Qt::Key_Slash );
559 defKeySym("0", Qt::Key_0 ); 559 defKeySym("0", Qt::Key_0 );
560 defKeySym("1", Qt::Key_1 ); 560 defKeySym("1", Qt::Key_1 );
561 defKeySym("2", Qt::Key_2 ); 561 defKeySym("2", Qt::Key_2 );
562 defKeySym("3", Qt::Key_3 ); 562 defKeySym("3", Qt::Key_3 );
563 defKeySym("4", Qt::Key_4 ); 563 defKeySym("4", Qt::Key_4 );
564 defKeySym("5", Qt::Key_5 ); 564 defKeySym("5", Qt::Key_5 );
565 defKeySym("6", Qt::Key_6 ); 565 defKeySym("6", Qt::Key_6 );
566 defKeySym("7", Qt::Key_7 ); 566 defKeySym("7", Qt::Key_7 );
567 defKeySym("8", Qt::Key_8 ); 567 defKeySym("8", Qt::Key_8 );
568 defKeySym("9", Qt::Key_9 ); 568 defKeySym("9", Qt::Key_9 );
569 defKeySym("Colon", Qt::Key_Colon ); 569 defKeySym("Colon", Qt::Key_Colon );
570 defKeySym("Semicolon", Qt::Key_Semicolon ); 570 defKeySym("Semicolon", Qt::Key_Semicolon );
571 defKeySym("Less", Qt::Key_Less ); 571 defKeySym("Less", Qt::Key_Less );
572 defKeySym("Equal", Qt::Key_Equal ); 572 defKeySym("Equal", Qt::Key_Equal );
573 defKeySym("Greater", Qt::Key_Greater ); 573 defKeySym("Greater", Qt::Key_Greater );
574 defKeySym("Question", Qt::Key_Question ); 574 defKeySym("Question", Qt::Key_Question );
575 defKeySym("At", Qt::Key_At ); 575 defKeySym("At", Qt::Key_At );
576 defKeySym("A", Qt::Key_A ); 576 defKeySym("A", Qt::Key_A );
577 defKeySym("B", Qt::Key_B ); 577 defKeySym("B", Qt::Key_B );
578 defKeySym("C", Qt::Key_C ); 578 defKeySym("C", Qt::Key_C );
579 defKeySym("D", Qt::Key_D ); 579 defKeySym("D", Qt::Key_D );
580 defKeySym("E", Qt::Key_E ); 580 defKeySym("E", Qt::Key_E );
581 defKeySym("F", Qt::Key_F ); 581 defKeySym("F", Qt::Key_F );
582 defKeySym("G", Qt::Key_G ); 582 defKeySym("G", Qt::Key_G );
583 defKeySym("H", Qt::Key_H ); 583 defKeySym("H", Qt::Key_H );
584 defKeySym("I", Qt::Key_I ); 584 defKeySym("I", Qt::Key_I );
585 defKeySym("J", Qt::Key_J ); 585 defKeySym("J", Qt::Key_J );
586 defKeySym("K", Qt::Key_K ); 586 defKeySym("K", Qt::Key_K );
587 defKeySym("L", Qt::Key_L ); 587 defKeySym("L", Qt::Key_L );
588 defKeySym("M", Qt::Key_M ); 588 defKeySym("M", Qt::Key_M );
589 defKeySym("N", Qt::Key_N ); 589 defKeySym("N", Qt::Key_N );
590 defKeySym("O", Qt::Key_O ); 590 defKeySym("O", Qt::Key_O );
591 defKeySym("P", Qt::Key_P ); 591 defKeySym("P", Qt::Key_P );
592 defKeySym("Q", Qt::Key_Q ); 592 defKeySym("Q", Qt::Key_Q );
593 defKeySym("R", Qt::Key_R ); 593 defKeySym("R", Qt::Key_R );
594 defKeySym("S", Qt::Key_S ); 594 defKeySym("S", Qt::Key_S );
595 defKeySym("T", Qt::Key_T ); 595 defKeySym("T", Qt::Key_T );
596 defKeySym("U", Qt::Key_U ); 596 defKeySym("U", Qt::Key_U );
597 defKeySym("V", Qt::Key_V ); 597 defKeySym("V", Qt::Key_V );
598 defKeySym("W", Qt::Key_W ); 598 defKeySym("W", Qt::Key_W );
599 defKeySym("X", Qt::Key_X ); 599 defKeySym("X", Qt::Key_X );
600 defKeySym("Y", Qt::Key_Y ); 600 defKeySym("Y", Qt::Key_Y );
601 defKeySym("Z", Qt::Key_Z ); 601 defKeySym("Z", Qt::Key_Z );
602 defKeySym("BracketLeft", Qt::Key_BracketLeft ); 602 defKeySym("BracketLeft", Qt::Key_BracketLeft );
603 defKeySym("Backslash", Qt::Key_Backslash ); 603 defKeySym("Backslash", Qt::Key_Backslash );
604 defKeySym("BracketRight", Qt::Key_BracketRight); 604 defKeySym("BracketRight", Qt::Key_BracketRight);
605 defKeySym("AsciiCircum", Qt::Key_AsciiCircum ); 605 defKeySym("AsciiCircum", Qt::Key_AsciiCircum );
606 defKeySym("Underscore", Qt::Key_Underscore ); 606 defKeySym("Underscore", Qt::Key_Underscore );
607 defKeySym("QuoteLeft", Qt::Key_QuoteLeft ); 607 defKeySym("QuoteLeft", Qt::Key_QuoteLeft );
608 defKeySym("BraceLeft", Qt::Key_BraceLeft ); 608 defKeySym("BraceLeft", Qt::Key_BraceLeft );
609 defKeySym("Bar", Qt::Key_Bar ); 609 defKeySym("Bar", Qt::Key_Bar );
610 defKeySym("BraceRight", Qt::Key_BraceRight ); 610 defKeySym("BraceRight", Qt::Key_BraceRight );
611 defKeySym("AsciiTilde", Qt::Key_AsciiTilde ); 611 defKeySym("AsciiTilde", Qt::Key_AsciiTilde );
612} 612}
613 613
614KeyTransSymbols::KeyTransSymbols() 614KeyTransSymbols::KeyTransSymbols()
615{ 615{
616 defModSyms(); 616 defModSyms();
617 defOprSyms(); 617 defOprSyms();
618 defKeySyms(); 618 defKeySyms();
619} 619}
620 620
621// Global material ----------------------------------------------------------- 621// Global material -----------------------------------------------------------
622 622
623static int keytab_serial = 0; //FIXME: remove,localize 623static int keytab_serial = 0; //FIXME: remove,localize
624 624
625static QIntDict<KeyTrans> * numb2keymap = 0L; 625static QIntDict<KeyTrans> * numb2keymap = 0L;
626static QDict<KeyTrans> * path2keymap = 0L; 626static QDict<KeyTrans> * path2keymap = 0L;
627 627
628KeyTrans* KeyTrans::find(int numb) 628KeyTrans* KeyTrans::find(int numb)
629{ 629{
630 KeyTrans* res = numb2keymap->find(numb); 630 KeyTrans* res = numb2keymap->find(numb);
631 return res ? res : numb2keymap->find(0); 631 return res ? res : numb2keymap->find(0);
632} 632}
633 633
634KeyTrans* KeyTrans::find(const char* path) 634KeyTrans* KeyTrans::find(const char* path)
635{ 635{
636 KeyTrans* res = path2keymap->find(path); 636 KeyTrans* res = path2keymap->find(path);
637 return res ? res : numb2keymap->find(0); 637 return res ? res : numb2keymap->find(0);
638} 638}
639 639
640int KeyTrans::count() 640int KeyTrans::count()
641{ 641{
642 return numb2keymap->count(); 642 return numb2keymap->count();
643} 643}
644 644
645void KeyTrans::addKeyTrans() 645void KeyTrans::addKeyTrans()
646{ 646{
647 this->numb = keytab_serial ++; 647 this->numb = keytab_serial ++;
648 numb2keymap->insert(numb,this); 648 numb2keymap->insert(numb,this);
649 path2keymap->insert(path,this); 649 path2keymap->insert(path,this);
650} 650}
651 651
652void KeyTrans::loadAll() 652void KeyTrans::loadAll()
653{ 653{
654 if (!numb2keymap) 654 if (!numb2keymap)
655 numb2keymap = new QIntDict<KeyTrans>; 655 numb2keymap = new QIntDict<KeyTrans>;
656 if (!path2keymap) 656 if (!path2keymap)
657 path2keymap = new QDict<KeyTrans>; 657 path2keymap = new QDict<KeyTrans>;
658 if (!syms) 658 if (!syms)
659 syms = new KeyTransSymbols; 659 syms = new KeyTransSymbols;
660 660
661 defaultKeyTrans()->addKeyTrans(); 661 defaultKeyTrans()->addKeyTrans();
662 662
663 663
664 QString path = QPEApplication::qpeDir() + "etc/keytabs"; 664 QString path = QPEApplication::qpeDir() + "etc/keytabs";
665 QDir dir(path); 665 QDir dir(path);
666 QStringList lst = dir.entryList("*.keytab"); 666 QStringList lst = dir.entryList("*.keytab");
667 667
668 for(QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) { 668 for(QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) {
669 QFile file(path + "/" + *it); 669 QFile file(path + "/" + *it);
670 KeyTrans* sc = KeyTrans::fromDevice(*it, file); 670 KeyTrans* sc = KeyTrans::fromDevice(*it, file);
671 if (sc) { 671 if (sc) {
672 sc->addKeyTrans(); 672 sc->addKeyTrans();
673 } 673 }
674 } 674 }
675 675
676} 676}
677 677
678// Debugging material ----------------------------------------------------------- 678// Debugging material -----------------------------------------------------------
679/* 679/*
680void TestTokenizer(QBuffer &buf) 680void TestTokenizer(QBuffer &buf)
681{ 681{
682 // opening sequence 682 // opening sequence
683 683
684 buf.open(IO_ReadOnly); 684 buf.open(IO_ReadOnly);
685 cc = buf.getch(); 685 cc = buf.getch();
686 lineno = 1; 686 lineno = 1;
687 687
688 // Test tokenizer 688 // Test tokenizer
689 689
690 while (getSymbol(buf)) ReportToken(); 690 while (getSymbol(buf)) ReportToken();
691 691
692 buf.close(); 692 buf.close();
693} 693}
694 694
695void test() 695void test()
696{ 696{
697 // Opening sequence 697 // Opening sequence
698 698
699 QCString txt = 699 QCString txt =
700#include "default.keytab.h"
701 ; 700 ;
702 QBuffer buf(txt); 701 QBuffer buf(txt);
703 if (0) TestTokenizer(buf); 702 if (0) TestTokenizer(buf);
704 if (1) { KeyTrans kt; kt.scanTable(buf); } 703 if (1) { KeyTrans kt; kt.scanTable(buf); }
705} 704}
706*/ 705*/
diff --git a/core/apps/embeddedkonsole/konsole.cpp b/core/apps/embeddedkonsole/konsole.cpp
index 084c39d..281835e 100644
--- a/core/apps/embeddedkonsole/konsole.cpp
+++ b/core/apps/embeddedkonsole/konsole.cpp
@@ -1,1955 +1,1934 @@
1 1
2/* ---------------------------------------------------------------------- */ 2/* ---------------------------------------------------------------------- */
3/* */ 3/* */
4/* [main.C] Konsole */ 4/* [main.C] Konsole */
5/* */ 5/* */
6/* ---------------------------------------------------------------------- */ 6/* ---------------------------------------------------------------------- */
7/* */ 7/* */
8/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ 8/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */
9/* */ 9/* */
10/* This file is part of Konsole, an X terminal. */ 10/* This file is part of Konsole, an X terminal. */
11/* */ 11/* */
12/* The material contained in here more or less directly orginates from */ 12/* The material contained in here more or less directly orginates from */
13/* kvt, which is copyright (c) 1996 by Matthias Ettrich <ettrich@kde.org> */ 13/* kvt, which is copyright (c) 1996 by Matthias Ettrich <ettrich@kde.org> */
14/* */ 14/* */
15/* ---------------------------------------------------------------------- */ 15/* ---------------------------------------------------------------------- */
16/* */ 16/* */
17/* Ported Konsole to Qt/Embedded */ 17/* Ported Konsole to Qt/Embedded */
18/* */ 18/* */
19/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ 19/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */
20/* */ 20/* */
21/* -------------------------------------------------------------------------- */ 21/* -------------------------------------------------------------------------- */
22// enhancements added by L.J. Potter <ljp@llornkcor.com> 22// enhancements added by L.J. Potter <ljp@llornkcor.com>
23// enhancements added by Phillip Kuhn 23// enhancements added by Phillip Kuhn
24 24
25#include <stdlib.h> 25#include <stdlib.h>
26#include <sys/types.h> 26#include <sys/types.h>
27#include <pwd.h> 27#include <pwd.h>
28#include <unistd.h> 28#include <unistd.h>
29 29
30#ifdef QT_QWS_OPIE 30#ifdef QT_QWS_OPIE
31#include <opie2/ocolorpopupmenu.h> 31#include <opie2/ocolorpopupmenu.h>
32#endif 32#endif
33 33
34#include <qpe/resource.h> 34#include <qpe/resource.h>
35 35
36#include <qdir.h>
37#include <qevent.h>
38#include <qdragobject.h>
39#include <qobjectlist.h>
40#include <qtoolbutton.h>
41#include <qtoolbar.h>
42#include <qpushbutton.h>
43#include <qfontdialog.h>
44#include <qglobal.h>
45#include <qpainter.h>
46#include <qmenubar.h> 36#include <qmenubar.h>
47#include <qmessagebox.h>
48#include <qaction.h>
49#include <qapplication.h>
50#include <qfontmetrics.h>
51#include <qcombobox.h>
52#include <qevent.h>
53#include <qtabwidget.h>
54#include <qtabbar.h> 37#include <qtabbar.h>
55#include <qpe/config.h> 38#include <qpe/config.h>
56#include <qstringlist.h>
57#include <qpalette.h>
58#include <qfontdatabase.h> 39#include <qfontdatabase.h>
59#include <qfile.h> 40#include <qfile.h>
60#include <qspinbox.h> 41#include <qspinbox.h>
61#include <qlayout.h> 42#include <qlayout.h>
62#include <qvbox.h>
63 43
64#include <sys/wait.h> 44#include <sys/wait.h>
65#include <stdio.h> 45#include <stdio.h>
66#include <stdlib.h> 46#include <stdlib.h>
67#include <assert.h> 47#include <assert.h>
68 48
69#include "konsole.h" 49#include "konsole.h"
70#include "keytrans.h"
71#include "commandeditdialog.h" 50#include "commandeditdialog.h"
72 51
73class EKNumTabBar : public QTabBar 52class EKNumTabBar : public QTabBar
74{ 53{
75public: 54public:
76 EKNumTabBar(QWidget *parent = 0, const char *name = 0) : 55 EKNumTabBar(QWidget *parent = 0, const char *name = 0) :
77 QTabBar(parent, name) 56 QTabBar(parent, name)
78 {} 57 {}
79 58
80 // QList<QTab> *getTabList() { return(tabList()); } 59 // QList<QTab> *getTabList() { return(tabList()); }
81 60
82 void numberTabs() 61 void numberTabs()
83 { 62 {
84 // Yes, it really is this messy. QTabWidget needs functions 63 // Yes, it really is this messy. QTabWidget needs functions
85 // that provide acces to tabs in a sequential way. 64 // that provide acces to tabs in a sequential way.
86 int m=INT_MIN; 65 int m=INT_MIN;
87 for (int i=0; i<count(); i++) 66 for (int i=0; i<count(); i++)
88 { 67 {
89 QTab* left=0; 68 QTab* left=0;
90 QListIterator<QTab> it(*tabList()); 69 QListIterator<QTab> it(*tabList());
91 int x=INT_MAX; 70 int x=INT_MAX;
92 for( QTab* t; (t=it.current()); ++it ) 71 for( QTab* t; (t=it.current()); ++it )
93 { 72 {
94 int tx = t->rect().x(); 73 int tx = t->rect().x();
95 if ( tx<x && tx>m ) 74 if ( tx<x && tx>m )
96 { 75 {
97 x = tx; 76 x = tx;
98 left = t; 77 left = t;
99 } 78 }
100 } 79 }
101 if ( left ) 80 if ( left )
102 { 81 {
103 left->setText(QString::number(i+1)); 82 left->setText(QString::number(i+1));
104 m = left->rect().x(); 83 m = left->rect().x();
105 } 84 }
106 } 85 }
107 } 86 }
108 87
109 virtual QSize sizeHint() const 88 virtual QSize sizeHint() const
110 { 89 {
111 if (isHidden()) 90 if (isHidden())
112 { 91 {
113 return(QSize(0,0)); 92 return(QSize(0,0));
114 } 93 }
115 else 94 else
116 { 95 {
117 QSize size = QTabBar::sizeHint(); 96 QSize size = QTabBar::sizeHint();
118 int shrink = 5; 97 int shrink = 5;
119 if (qApp->desktop()->width() > 600 || qApp->desktop()->height() > 600) 98 if (qApp->desktop()->width() > 600 || qApp->desktop()->height() > 600)
120 { 99 {
121 shrink = 10; 100 shrink = 10;
122 } 101 }
123 size.setHeight(size.height() - shrink); 102 size.setHeight(size.height() - shrink);
124 return(size); 103 return(size);
125 } 104 }
126 } 105 }
127 106
128}; 107};
129 108
130class EKNumTabWidget : public QTabWidget 109class EKNumTabWidget : public QTabWidget
131{ 110{
132public: 111public:
133 EKNumTabWidget(QWidget* parent) : QTabWidget(parent) 112 EKNumTabWidget(QWidget* parent) : QTabWidget(parent)
134 { 113 {
135 setTabBar(new EKNumTabBar(parent,"EKTabBar")); 114 setTabBar(new EKNumTabBar(parent,"EKTabBar"));
136 setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); 115 setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );
137 } 116 }
138 117
139 EKNumTabBar *getTabBar() const 118 EKNumTabBar *getTabBar() const
140 { 119 {
141 return ((EKNumTabBar*)tabBar()); 120 return ((EKNumTabBar*)tabBar());
142 } 121 }
143 122
144 123
145 void addTab(QWidget* w) 124 void addTab(QWidget* w)
146 { 125 {
147 QTab* t = new QTab(QString::number(tabBar()->count()+1)); 126 QTab* t = new QTab(QString::number(tabBar()->count()+1));
148 QTabWidget::addTab(w,t); 127 QTabWidget::addTab(w,t);
149 } 128 }
150 129
151 void removeTab(QWidget* w) 130 void removeTab(QWidget* w)
152 { 131 {
153 removePage(w); 132 removePage(w);
154 ((EKNumTabBar*)tabBar())->numberTabs(); 133 ((EKNumTabBar*)tabBar())->numberTabs();
155 } 134 }
156}; 135};
157 136
158// This could be configurable or dynamicly generated from the bash history 137// This could be configurable or dynamicly generated from the bash history
159// file of the user 138// file of the user
160static const char *commonCmds[] = 139static const char *commonCmds[] =
161 { 140 {
162 "ls ", // I left this here, cause it looks better than the first alpha 141 "ls ", // I left this here, cause it looks better than the first alpha
163 "cardctl eject", 142 "cardctl eject",
164 "cat ", 143 "cat ",
165 "cd ", 144 "cd ",
166 "chmod ", 145 "chmod ",
167 "clear", 146 "clear",
168 "cp ", 147 "cp ",
169 "dc ", 148 "dc ",
170 "df ", 149 "df ",
171 "dmesg", 150 "dmesg",
172 "echo ", 151 "echo ",
173 "env", 152 "env",
174 "find ", 153 "find ",
175 "free", 154 "free",
176 "grep ", 155 "grep ",
177 "ifconfig ", 156 "ifconfig ",
178 "ipkg ", 157 "ipkg ",
179 "mkdir ", 158 "mkdir ",
180 "mv ", 159 "mv ",
181 "nc localhost 7776", 160 "nc localhost 7776",
182 "nc localhost 7777", 161 "nc localhost 7777",
183 "netstat ", 162 "netstat ",
184 "nslookup ", 163 "nslookup ",
185 "ping ", 164 "ping ",
186 "ps aux", 165 "ps aux",
187 "pwd ", 166 "pwd ",
188 "qcop QPE/System 'linkChanged(QString)' ''", 167 "qcop QPE/System 'linkChanged(QString)' ''",
189 "qcop QPE/System 'restart()'", 168 "qcop QPE/System 'restart()'",
190 "qcop QPE/System 'quit()'", 169 "qcop QPE/System 'quit()'",
191 "rm ", 170 "rm ",
192 "rmdir ", 171 "rmdir ",
193 "route ", 172 "route ",
194 "set ", 173 "set ",
195 "traceroute", 174 "traceroute",
196 175
197 /* 176 /*
198 "gzip", 177 "gzip",
199 "gunzip", 178 "gunzip",
200 "chgrp", 179 "chgrp",
201 "chown", 180 "chown",
202 "date", 181 "date",
203 "dd", 182 "dd",
204 "df", 183 "df",
205 "dmesg", 184 "dmesg",
206 "fuser", 185 "fuser",
207 "hostname", 186 "hostname",
208 "kill", 187 "kill",
209 "killall", 188 "killall",
210 "ln", 189 "ln",
211 "ping", 190 "ping",
212 "mount", 191 "mount",
213 "more", 192 "more",
214 "sort", 193 "sort",
215 "touch", 194 "touch",
216 "umount", 195 "umount",
217 "mknod", 196 "mknod",
218 "netstat", 197 "netstat",
219 */ 198 */
220 199
221 "exit", 200 "exit",
222 NULL 201 NULL
223 }; 202 };
224 203
225 204
226static void konsoleInit(const char** shell) { 205static void konsoleInit(const char** shell) {
227 if(setuid(getuid()) !=0) qDebug("setuid failed"); 206 if(setuid(getuid()) !=0) qDebug("setuid failed");
228 if(setgid(getgid()) != 0) qDebug("setgid failed"); // drop privileges 207 if(setgid(getgid()) != 0) qDebug("setgid failed"); // drop privileges
229 208
230 209
231// QPEApplication::grabKeyboard(); // for CTRL and ALT 210// QPEApplication::grabKeyboard(); // for CTRL and ALT
232 211
233 qDebug("keyboard grabbed"); 212 qDebug("keyboard grabbed");
234#ifdef FAKE_CTRL_AND_ALT 213#ifdef FAKE_CTRL_AND_ALT
235 qDebug("Fake Ctrl and Alt defined"); 214 qDebug("Fake Ctrl and Alt defined");
236 QPEApplication::grabKeyboard(); // for CTRL and ALT 215 QPEApplication::grabKeyboard(); // for CTRL and ALT
237#endif 216#endif
238 217
239 *shell = getenv("SHELL"); 218 *shell = getenv("SHELL");
240 qWarning("SHell initially is %s", *shell ); 219 qWarning("SHell initially is %s", *shell );
241 220
242 if (shell == NULL || *shell == '\0') { 221 if (shell == NULL || *shell == '\0') {
243 struct passwd *ent = 0; 222 struct passwd *ent = 0;
244 uid_t me = getuid(); 223 uid_t me = getuid();
245 *shell = "/bin/sh"; 224 *shell = "/bin/sh";
246 225
247 while ( (ent = getpwent()) != 0 ) { 226 while ( (ent = getpwent()) != 0 ) {
248 if (ent->pw_uid == me) { 227 if (ent->pw_uid == me) {
249 if (ent->pw_shell != "") 228 if (ent->pw_shell != "")
250 *shell = ent->pw_shell; 229 *shell = ent->pw_shell;
251 break; 230 break;
252 } 231 }
253 } 232 }
254 endpwent(); 233 endpwent();
255 } 234 }
256 235
257 if( putenv((char*)"COLORTERM=") !=0) 236 if( putenv((char*)"COLORTERM=") !=0)
258 qDebug("putenv failed"); // to trigger mc's color detection 237 qDebug("putenv failed"); // to trigger mc's color detection
259} 238}
260 239
261 240
262Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) : 241Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) :
263 QMainWindow(parent, name, fl) 242 QMainWindow(parent, name, fl)
264{ 243{
265 QStrList tmp; const char* shell; 244 QStrList tmp; const char* shell;
266 245
267 konsoleInit( &shell); 246 konsoleInit( &shell);
268 init(shell,tmp); 247 init(shell,tmp);
269} 248}
270 249
271Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int) 250Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int)
272 : QMainWindow(0, name) 251 : QMainWindow(0, name)
273{ 252{
274 init(_pgm,_args); 253 init(_pgm,_args);
275} 254}
276 255
277struct HistoryItem 256struct HistoryItem
278{ 257{
279 HistoryItem(int c, const QString &l) 258 HistoryItem(int c, const QString &l)
280 { 259 {
281 count = c; 260 count = c;
282 line = l; 261 line = l;
283 } 262 }
284 int count; 263 int count;
285 QString line; 264 QString line;
286}; 265};
287 266
288class HistoryList : public QList<HistoryItem> 267class HistoryList : public QList<HistoryItem>
289{ 268{
290 virtual int compareItems( QCollection::Item item1, QCollection::Item item2) 269 virtual int compareItems( QCollection::Item item1, QCollection::Item item2)
291 { 270 {
292 int c1 = ((HistoryItem*)item1)->count; 271 int c1 = ((HistoryItem*)item1)->count;
293 int c2 = ((HistoryItem*)item2)->count; 272 int c2 = ((HistoryItem*)item2)->count;
294 if (c1 > c2) 273 if (c1 > c2)
295 return(1); 274 return(1);
296 if (c1 < c2) 275 if (c1 < c2)
297 return(-1); 276 return(-1);
298 return(0); 277 return(0);
299 } 278 }
300}; 279};
301 280
302void Konsole::initCommandList() 281void Konsole::initCommandList()
303{ 282{
304 // qDebug("Konsole::initCommandList"); 283 // qDebug("Konsole::initCommandList");
305 Config cfg( "Konsole" ); 284 Config cfg( "Konsole" );
306 cfg.setGroup("Commands"); 285 cfg.setGroup("Commands");
307 // commonCombo->setInsertionPolicy(QComboBox::AtCurrent); 286 // commonCombo->setInsertionPolicy(QComboBox::AtCurrent);
308 commonCombo->clear(); 287 commonCombo->clear();
309 288
310 if (cfg.readEntry("ShellHistory","TRUE") == "TRUE") 289 if (cfg.readEntry("ShellHistory","TRUE") == "TRUE")
311 { 290 {
312 QString histfilename = QString(getenv("HOME")) + "/.bash_history"; 291 QString histfilename = QString(getenv("HOME")) + "/.bash_history";
313 histfilename = cfg.readEntry("ShellHistoryPath",histfilename); 292 histfilename = cfg.readEntry("ShellHistoryPath",histfilename);
314 QFile histfile(histfilename); 293 QFile histfile(histfilename);
315 // note: compiler barfed on: 294 // note: compiler barfed on:
316 // QFile histfile(QString(getenv("HOME")) + "/.bash_history"); 295 // QFile histfile(QString(getenv("HOME")) + "/.bash_history");
317 if (histfile.open( IO_ReadOnly )) 296 if (histfile.open( IO_ReadOnly ))
318 { 297 {
319 QString line; 298 QString line;
320 uint i; 299 uint i;
321 HistoryList items; 300 HistoryList items;
322 301
323 int lineno = 0; 302 int lineno = 0;
324 while(!histfile.atEnd()) 303 while(!histfile.atEnd())
325 { 304 {
326 if (histfile.readLine(line, 200) < 0) 305 if (histfile.readLine(line, 200) < 0)
327 { 306 {
328 break; 307 break;
329 } 308 }
330 line = line.left(line.length()-1); 309 line = line.left(line.length()-1);
331 lineno++; 310 lineno++;
332 311
333 for(i=0; i<items.count(); i++) 312 for(i=0; i<items.count(); i++)
334 { 313 {
335 if (line == items.at(i)->line) 314 if (line == items.at(i)->line)
336 { 315 {
337 // weight recent commands & repeated commands more 316 // weight recent commands & repeated commands more
338 // by adding up the index of each command 317 // by adding up the index of each command
339 items.at(i)->count += lineno; 318 items.at(i)->count += lineno;
340 break; 319 break;
341 } 320 }
342 } 321 }
343 if (i >= items.count()) 322 if (i >= items.count())
344 { 323 {
345 items.append(new HistoryItem(lineno, line)); 324 items.append(new HistoryItem(lineno, line));
346 } 325 }
347 } 326 }
348 items.sort(); 327 items.sort();
349 int n = items.count(); 328 int n = items.count();
350 if (n > 40) 329 if (n > 40)
351 { 330 {
352 n = 40; 331 n = 40;
353 } 332 }
354 for(int i=0; i<n; i++) 333 for(int i=0; i<n; i++)
355 { 334 {
356 // should insert start of command, but keep whole thing 335 // should insert start of command, but keep whole thing
357 if (items.at(items.count()-i-1)->line.length() < 30) 336 if (items.at(items.count()-i-1)->line.length() < 30)
358 { 337 {
359 commonCombo->insertItem(items.at(items.count()-i-1)->line); 338 commonCombo->insertItem(items.at(items.count()-i-1)->line);
360 } 339 }
361 } 340 }
362 histfile.close(); 341 histfile.close();
363 } 342 }
364 } 343 }
365 if (cfg.readEntry("Commands Set","FALSE") == "FALSE") 344 if (cfg.readEntry("Commands Set","FALSE") == "FALSE")
366 { 345 {
367 for (int i = 0; commonCmds[i] != NULL; i++) 346 for (int i = 0; commonCmds[i] != NULL; i++)
368 { 347 {
369 commonCombo->insertItem(commonCmds[i]); 348 commonCombo->insertItem(commonCmds[i]);
370 } 349 }
371 } 350 }
372 else 351 else
373 { 352 {
374 for (int i = 0; i < 100; i++) 353 for (int i = 0; i < 100; i++)
375 { 354 {
376 if (!(cfg.readEntry( QString::number(i),"")).isEmpty()) 355 if (!(cfg.readEntry( QString::number(i),"")).isEmpty())
377 commonCombo->insertItem(cfg.readEntry( QString::number(i),"")); 356 commonCombo->insertItem(cfg.readEntry( QString::number(i),""));
378 } 357 }
379 } 358 }
380 359
381 360
382} 361}
383 362
384static void sig_handler(int x) 363static void sig_handler(int x)
385{ 364{
386 printf("got signal %d\n",x); 365 printf("got signal %d\n",x);
387} 366}
388 367
389void Konsole::init(const char* _pgm, QStrList & _args) 368void Konsole::init(const char* _pgm, QStrList & _args)
390{ 369{
391 370
392#if 0 371#if 0
393 for(int i=1; i<=31; i++) 372 for(int i=1; i<=31; i++)
394 { 373 {
395 if (i != SIGPIPE && i != SIGPROF && i != SIGSEGV 374 if (i != SIGPIPE && i != SIGPROF && i != SIGSEGV
396 && i != SIGINT && i != SIGILL && i != SIGTERM 375 && i != SIGINT && i != SIGILL && i != SIGTERM
397 && i != SIGBUS) 376 && i != SIGBUS)
398 signal(i,sig_handler); 377 signal(i,sig_handler);
399 } 378 }
400#endif 379#endif
401 signal(SIGSTOP, sig_handler); 380 signal(SIGSTOP, sig_handler);
402 signal(SIGCONT, sig_handler); 381 signal(SIGCONT, sig_handler);
403 signal(SIGTSTP, sig_handler); 382 signal(SIGTSTP, sig_handler);
404 383
405 b_scroll = TRUE; // histon; 384 b_scroll = TRUE; // histon;
406 n_keytab = 0; 385 n_keytab = 0;
407 n_render = 0; 386 n_render = 0;
408 startUp=0; 387 startUp=0;
409 fromMenu = FALSE; 388 fromMenu = FALSE;
410 fullscreen = false; 389 fullscreen = false;
411 390
412 setCaption( tr( "Konsole" ) ); 391 setCaption( tr( "Konsole" ) );
413 setIcon( Resource::loadPixmap( "konsole/Terminal" ) ); 392 setIcon( Resource::loadPixmap( "konsole/Terminal" ) );
414 393
415 Config cfg( "Konsole" ); 394 Config cfg( "Konsole" );
416 cfg.setGroup("Font"); 395 cfg.setGroup("Font");
417 QString tmp; 396 QString tmp;
418 397
419 // initialize the list of allowed fonts /////////////////////////////////// 398 // initialize the list of allowed fonts ///////////////////////////////////
420 399
421 QString cfgFontName = cfg.readEntry("FontName","Lcfont"); 400 QString cfgFontName = cfg.readEntry("FontName","Lcfont");
422 int cfgFontSize = cfg.readNumEntry("FontSize",18); 401 int cfgFontSize = cfg.readNumEntry("FontSize",18);
423 402
424 cfont = -1; 403 cfont = -1;
425 404
426 // this code causes repeated access to all the font files 405 // this code causes repeated access to all the font files
427 // which does slow down startup 406 // which does slow down startup
428 QFontDatabase fontDB; 407 QFontDatabase fontDB;
429 QStringList familyNames; 408 QStringList familyNames;
430 familyNames = fontDB.families( FALSE ); 409 familyNames = fontDB.families( FALSE );
431 QString s; 410 QString s;
432 int fontIndex = 0; 411 int fontIndex = 0;
433 int familyNum = 0; 412 int familyNum = 0;
434 fontList = new QPopupMenu( this ); 413 fontList = new QPopupMenu( this );
435 414
436 for(uint j = 0; j < (uint)familyNames.count(); j++) 415 for(uint j = 0; j < (uint)familyNames.count(); j++)
437 { 416 {
438 s = familyNames[j]; 417 s = familyNames[j];
439 if ( s.contains('-') ) 418 if ( s.contains('-') )
440 { 419 {
441 int i = s.find('-'); 420 int i = s.find('-');
442 s = s.right( s.length() - i - 1 ) + " [" + s.left( i ) + "]"; 421 s = s.right( s.length() - i - 1 ) + " [" + s.left( i ) + "]";
443 } 422 }
444 s[0] = s[0].upper(); 423 s[0] = s[0].upper();
445 424
446 QValueList<int> sizes = fontDB.pointSizes( familyNames[j] ); 425 QValueList<int> sizes = fontDB.pointSizes( familyNames[j] );
447 426
448 printf("family[%d] = %s with %d sizes\n", j, familyNames[j].latin1(), 427 printf("family[%d] = %s with %d sizes\n", j, familyNames[j].latin1(),
449 sizes.count()); 428 sizes.count());
450 429
451 if (sizes.count() > 0) 430 if (sizes.count() > 0)
452 { 431 {
453 QPopupMenu *sizeMenu; 432 QPopupMenu *sizeMenu;
454 QFont f; 433 QFont f;
455 int last_width = -1; 434 int last_width = -1;
456 sizeMenu = NULL; 435 sizeMenu = NULL;
457 436
458 for(uint i = 0; i < (uint)sizes.count() + 4; i++) 437 for(uint i = 0; i < (uint)sizes.count() + 4; i++)
459 { 438 {
460 // printf("family %s size %d ", familyNames[j].latin1(), sizes[i]); 439 // printf("family %s size %d ", familyNames[j].latin1(), sizes[i]);
461 // need to divide by 10 on the Z, but not otherwise 440 // need to divide by 10 on the Z, but not otherwise
462 int size; 441 int size;
463 442
464 if (i >= (uint)sizes.count()) 443 if (i >= (uint)sizes.count())
465 { 444 {
466 // try for expandable fonts 445 // try for expandable fonts
467 size = sizes[sizes.count()-1] + 2 * (i - sizes.count() + 1); 446 size = sizes[sizes.count()-1] + 2 * (i - sizes.count() + 1);
468 } 447 }
469 else 448 else
470 { 449 {
471 printf("sizes[%d] = %d\n", i, sizes[i]); 450 printf("sizes[%d] = %d\n", i, sizes[i]);
472 size = sizes[i]; 451 size = sizes[i];
473 } 452 }
474 453
475 f = QFont(familyNames[j], size); 454 f = QFont(familyNames[j], size);
476 f.setFixedPitch(true); 455 f.setFixedPitch(true);
477 QFontMetrics fm(f); 456 QFontMetrics fm(f);
478 // don't trust f.fixedPitch() or f.exactMatch(), they lie!! 457 // don't trust f.fixedPitch() or f.exactMatch(), they lie!!
479 if (fm.width("l") == fm.width("m") 458 if (fm.width("l") == fm.width("m")
480 && (i < (uint)sizes.count() 459 && (i < (uint)sizes.count()
481 || fm.width("m") > last_width)) 460 || fm.width("m") > last_width))
482 { 461 {
483 if (i < (uint)sizes.count()) 462 if (i < (uint)sizes.count())
484 { 463 {
485 last_width = fm.width("m"); 464 last_width = fm.width("m");
486 } 465 }
487 if (sizeMenu == NULL) 466 if (sizeMenu == NULL)
488 { 467 {
489 sizeMenu = new QPopupMenu(); 468 sizeMenu = new QPopupMenu();
490 } 469 }
491 int id = sizeMenu->insertItem(QString("%1").arg(size), fontIndex); 470 int id = sizeMenu->insertItem(QString("%1").arg(size), fontIndex);
492 sizeMenu->setItemParameter(id, fontIndex); 471 sizeMenu->setItemParameter(id, fontIndex);
493 sizeMenu->connectItem(id, this, SLOT(setFont(int))); 472 sizeMenu->connectItem(id, this, SLOT(setFont(int)));
494 QString name = s + " " + QString::number(size); 473 QString name = s + " " + QString::number(size);
495 fonts.append(new VTFont(name, f, familyNames[j], familyNum, size)); 474 fonts.append(new VTFont(name, f, familyNames[j], familyNum, size));
496 if (familyNames[j] == cfgFontName && size == cfgFontSize) 475 if (familyNames[j] == cfgFontName && size == cfgFontSize)
497 { 476 {
498 cfont = fontIndex; 477 cfont = fontIndex;
499 } 478 }
500 printf("FOUND: %s family %s size %d\n", name.latin1(), familyNames[j].latin1(), size); 479 printf("FOUND: %s family %s size %d\n", name.latin1(), familyNames[j].latin1(), size);
501 fontIndex++; 480 fontIndex++;
502 } 481 }
503 } 482 }
504 if (sizeMenu) 483 if (sizeMenu)
505 { 484 {
506 fontList->insertItem(s, sizeMenu, familyNum + 1000); 485 fontList->insertItem(s, sizeMenu, familyNum + 1000);
507 486
508 familyNum++; 487 familyNum++;
509 } 488 }
510 } 489 }
511 490
512 } 491 }
513 492
514 if (cfont < 0 || cfont >= (int)fonts.count()) 493 if (cfont < 0 || cfont >= (int)fonts.count())
515 { 494 {
516 cfont = 0; 495 cfont = 0;
517 } 496 }
518 497
519 // create terminal emulation framework //////////////////////////////////// 498 // create terminal emulation framework ////////////////////////////////////
520 nsessions = 0; 499 nsessions = 0;
521 500
522 tab = new EKNumTabWidget(this); 501 tab = new EKNumTabWidget(this);
523 // tab->setMargin(tab->margin()-5); 502 // tab->setMargin(tab->margin()-5);
524 connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*))); 503 connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*)));
525 504
526 // create terminal toolbar //////////////////////////////////////////////// 505 // create terminal toolbar ////////////////////////////////////////////////
527 setToolBarsMovable( FALSE ); 506 setToolBarsMovable( FALSE );
528 menuToolBar = new QToolBar( this ); 507 menuToolBar = new QToolBar( this );
529 menuToolBar->setHorizontalStretchable( TRUE ); 508 menuToolBar->setHorizontalStretchable( TRUE );
530 509
531 QMenuBar *menuBar = new QMenuBar( menuToolBar ); 510 QMenuBar *menuBar = new QMenuBar( menuToolBar );
532 511
533 bool c7xx = false; 512 bool c7xx = false;
534 if (qApp->desktop()->width() > 600 || qApp->desktop()->height() > 600) 513 if (qApp->desktop()->width() > 600 || qApp->desktop()->height() > 600)
535 { 514 {
536 c7xx = true; 515 c7xx = true;
537 } 516 }
538 QFont menuFont; 517 QFont menuFont;
539 menuFont.setPointSize(c7xx? 18 : 10); 518 menuFont.setPointSize(c7xx? 18 : 10);
540 qApp->setFont(menuFont, true); 519 qApp->setFont(menuFont, true);
541 520
542 setFont(cfont); 521 setFont(cfont);
543 522
544 configMenu = new QPopupMenu( this); 523 configMenu = new QPopupMenu( this);
545 colorMenu = new QPopupMenu( this); 524 colorMenu = new QPopupMenu( this);
546 scrollMenu = new QPopupMenu( this); 525 scrollMenu = new QPopupMenu( this);
547 editCommandListMenu = new QPopupMenu( this); 526 editCommandListMenu = new QPopupMenu( this);
548 527
549 configMenu->insertItem(tr("Command List"), editCommandListMenu); 528 configMenu->insertItem(tr("Command List"), editCommandListMenu);
550 529
551 bool listHidden; 530 bool listHidden;
552 cfg.setGroup("Menubar"); 531 cfg.setGroup("Menubar");
553 if( cfg.readEntry("Hidden","FALSE") == "TRUE") 532 if( cfg.readEntry("Hidden","FALSE") == "TRUE")
554 { 533 {
555 ec_cmdlist = editCommandListMenu->insertItem( tr( "Show command list" )); 534 ec_cmdlist = editCommandListMenu->insertItem( tr( "Show command list" ));
556 listHidden=TRUE; 535 listHidden=TRUE;
557 } 536 }
558 else 537 else
559 { 538 {
560 ec_cmdlist = editCommandListMenu->insertItem( tr( "Hide command list" )); 539 ec_cmdlist = editCommandListMenu->insertItem( tr( "Hide command list" ));
561 listHidden=FALSE; 540 listHidden=FALSE;
562 } 541 }
563 542
564 cfg.setGroup("Tabs"); 543 cfg.setGroup("Tabs");
565 544
566 tabMenu = new QPopupMenu(this); 545 tabMenu = new QPopupMenu(this);
567 tm_bottom = tabMenu->insertItem(tr("Bottom" )); 546 tm_bottom = tabMenu->insertItem(tr("Bottom" ));
568 tm_top = tabMenu->insertItem(tr("Top")); 547 tm_top = tabMenu->insertItem(tr("Top"));
569 tm_hidden = tabMenu->insertItem(tr("Hidden")); 548 tm_hidden = tabMenu->insertItem(tr("Hidden"));
570 549
571 configMenu->insertItem(tr("Tabs"), tabMenu); 550 configMenu->insertItem(tr("Tabs"), tabMenu);
572 551
573 tmp=cfg.readEntry("Position","Top"); 552 tmp=cfg.readEntry("Position","Top");
574 if(tmp=="Top") 553 if(tmp=="Top")
575 { 554 {
576 tab->setTabPosition(QTabWidget::Top); 555 tab->setTabPosition(QTabWidget::Top);
577 tab->getTabBar()->show(); 556 tab->getTabBar()->show();
578 tabPos = tm_top; 557 tabPos = tm_top;
579 } 558 }
580 else if (tmp=="Bottom") 559 else if (tmp=="Bottom")
581 { 560 {
582 tab->setTabPosition(QTabWidget::Bottom); 561 tab->setTabPosition(QTabWidget::Bottom);
583 tab->getTabBar()->show(); 562 tab->getTabBar()->show();
584 tabPos = tm_bottom; 563 tabPos = tm_bottom;
585 } 564 }
586 else 565 else
587 { 566 {
588 tab->getTabBar()->hide(); 567 tab->getTabBar()->hide();
589 tab->setMargin(tab->margin()); 568 tab->setMargin(tab->margin());
590 tabPos = tm_hidden; 569 tabPos = tm_hidden;
591 } 570 }
592 571
593 cm_bw = colorMenu->insertItem(tr( "Black on White")); 572 cm_bw = colorMenu->insertItem(tr( "Black on White"));
594 cm_wb = colorMenu->insertItem(tr( "White on Black")); 573 cm_wb = colorMenu->insertItem(tr( "White on Black"));
595 cm_gb = colorMenu->insertItem(tr( "Green on Black")); 574 cm_gb = colorMenu->insertItem(tr( "Green on Black"));
596 // cm_bt = colorMenu->insertItem(tr( "Black on Transparent")); 575 // cm_bt = colorMenu->insertItem(tr( "Black on Transparent"));
597 cm_br = colorMenu->insertItem(tr( "Black on Pink")); 576 cm_br = colorMenu->insertItem(tr( "Black on Pink"));
598 cm_rb = colorMenu->insertItem(tr( "Pink on Black")); 577 cm_rb = colorMenu->insertItem(tr( "Pink on Black"));
599 cm_gy = colorMenu->insertItem(tr( "Green on Yellow")); 578 cm_gy = colorMenu->insertItem(tr( "Green on Yellow"));
600 cm_bm = colorMenu->insertItem(tr( "Blue on Magenta")); 579 cm_bm = colorMenu->insertItem(tr( "Blue on Magenta"));
601 cm_mb = colorMenu->insertItem(tr( "Magenta on Blue")); 580 cm_mb = colorMenu->insertItem(tr( "Magenta on Blue"));
602 cm_cw = colorMenu->insertItem(tr( "Cyan on White")); 581 cm_cw = colorMenu->insertItem(tr( "Cyan on White"));
603 cm_wc = colorMenu->insertItem(tr( "White on Cyan")); 582 cm_wc = colorMenu->insertItem(tr( "White on Cyan"));
604 cm_bb = colorMenu->insertItem(tr( "Blue on Black")); 583 cm_bb = colorMenu->insertItem(tr( "Blue on Black"));
605 cm_ab = colorMenu->insertItem(tr( "Amber on Black")); 584 cm_ab = colorMenu->insertItem(tr( "Amber on Black"));
606 cm_default = colorMenu->insertItem(tr("default")); 585 cm_default = colorMenu->insertItem(tr("default"));
607 586
608#ifdef QT_QWS_OPIE 587#ifdef QT_QWS_OPIE
609 588
610 colorMenu->insertItem(tr( "Custom")); 589 colorMenu->insertItem(tr( "Custom"));
611#endif 590#endif
612 591
613 configMenu->insertItem(tr( "Colors") ,colorMenu); 592 configMenu->insertItem(tr( "Colors") ,colorMenu);
614 593
615 sessionList = new QPopupMenu(this); 594 sessionList = new QPopupMenu(this);
616 sessionList-> insertItem ( Resource::loadPixmap ( "konsole/Terminal" ), tr( "new session" ), this, 595 sessionList-> insertItem ( Resource::loadPixmap ( "konsole/Terminal" ), tr( "new session" ), this,
617 SLOT(newSession()) ); 596 SLOT(newSession()) );
618 597
619 // connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) )); 598 // connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) ));
620 connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) )); 599 connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) ));
621 connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuIsSelected(int) )); 600 connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuIsSelected(int) ));
622 connect( tabMenu, SIGNAL( activated(int) ), this, SLOT( tabMenuSelected(int) )); 601 connect( tabMenu, SIGNAL( activated(int) ), this, SLOT( tabMenuSelected(int) ));
623 connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int))); 602 connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int)));
624 connect( editCommandListMenu,SIGNAL(activated(int)),this,SLOT(editCommandListMenuSelected(int))); 603 connect( editCommandListMenu,SIGNAL(activated(int)),this,SLOT(editCommandListMenuSelected(int)));
625 connect( sessionList, SIGNAL(activated(int)), this, SLOT( sessionListSelected(int) ) ); 604 connect( sessionList, SIGNAL(activated(int)), this, SLOT( sessionListSelected(int) ) );
626 605
627 menuBar->insertItem( tr("View"), configMenu ); 606 menuBar->insertItem( tr("View"), configMenu );
628 menuBar->insertItem( tr("Fonts"), fontList ); 607 menuBar->insertItem( tr("Fonts"), fontList );
629 menuBar->insertItem( tr("Sessions"), sessionList ); 608 menuBar->insertItem( tr("Sessions"), sessionList );
630 609
631 toolBar = new QToolBar( this ); 610 toolBar = new QToolBar( this );
632 611
633 QAction *a; 612 QAction *a;
634 613
635 // Button Commands 614 // Button Commands
636 a = new QAction( tr("New"), Resource::loadPixmap( "konsole/Terminal" ), QString::null, 0, this, 0 ); 615 a = new QAction( tr("New"), Resource::loadPixmap( "konsole/Terminal" ), QString::null, 0, this, 0 );
637 connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); 616 connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) );
638 a->addTo( toolBar ); 617 a->addTo( toolBar );
639 618
640 a = new QAction( tr("Full Screen"), Resource::loadPixmap( "fullscreen" ), QString::null, 0, this, 0 ); 619 a = new QAction( tr("Full Screen"), Resource::loadPixmap( "fullscreen" ), QString::null, 0, this, 0 );
641 connect( a, SIGNAL( activated() ), this, SLOT( toggleFullScreen() ) ); 620 connect( a, SIGNAL( activated() ), this, SLOT( toggleFullScreen() ) );
642 a->addTo( toolBar ); 621 a->addTo( toolBar );
643 622
644 a = new QAction( tr("Zoom"), Resource::loadPixmap( "zoom" ), QString::null, 0, this, 0 ); 623 a = new QAction( tr("Zoom"), Resource::loadPixmap( "zoom" ), QString::null, 0, this, 0 );
645 connect( a, SIGNAL( activated() ), this, SLOT( cycleZoom() ) ); 624 connect( a, SIGNAL( activated() ), this, SLOT( cycleZoom() ) );
646 a->addTo( toolBar ); 625 a->addTo( toolBar );
647 626
648 627
649 /* 628 /*
650 a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 ); 629 a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 );
651 connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolBar ); 630 connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolBar );
652 a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 ); 631 a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 );
653 connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolBar ); 632 connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolBar );
654 a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 ); 633 a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 );
655 connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolBar ); 634 connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolBar );
656 */ 635 */
657 /* 636 /*
658 a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 ); 637 a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 );
659 connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolBar ); 638 connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolBar );
660 a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 ); 639 a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 );
661 connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolBar ); 640 connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolBar );
662 */ 641 */
663 a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); 642 a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 );
664 connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); 643 connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) );
665 a->addTo( toolBar ); 644 a->addTo( toolBar );
666 645
667 secondToolBar = new QToolBar( this ); 646 secondToolBar = new QToolBar( this );
668 secondToolBar->setHorizontalStretchable( TRUE ); 647 secondToolBar->setHorizontalStretchable( TRUE );
669 648
670 commonCombo = new QComboBox( secondToolBar ); 649 commonCombo = new QComboBox( secondToolBar );
671 // commonCombo->setMaximumWidth(236); 650 // commonCombo->setMaximumWidth(236);
672 651
673 ec_quick = editCommandListMenu->insertItem( tr( "Quick Edit" ) ); 652 ec_quick = editCommandListMenu->insertItem( tr( "Quick Edit" ) );
674 if( listHidden) 653 if( listHidden)
675 { 654 {
676 secondToolBar->hide(); 655 secondToolBar->hide();
677 editCommandListMenu->setItemEnabled(ec_quick ,FALSE); 656 editCommandListMenu->setItemEnabled(ec_quick ,FALSE);
678 } 657 }
679 ec_edit = editCommandListMenu->insertItem(tr( "Edit..." ) ); 658 ec_edit = editCommandListMenu->insertItem(tr( "Edit..." ) );
680 659
681 cfg.setGroup("Commands"); 660 cfg.setGroup("Commands");
682 commonCombo->setInsertionPolicy(QComboBox::AtCurrent); 661 commonCombo->setInsertionPolicy(QComboBox::AtCurrent);
683 662
684 initCommandList(); 663 initCommandList();
685 // for (int i = 0; commonCmds[i] != NULL; i++) { 664 // for (int i = 0; commonCmds[i] != NULL; i++) {
686 // commonCombo->insertItem( commonCmds[i], i ); 665 // commonCombo->insertItem( commonCmds[i], i );
687 // tmp = cfg.readEntry( QString::number(i),""); 666 // tmp = cfg.readEntry( QString::number(i),"");
688 // if(tmp != "") 667 // if(tmp != "")
689 // commonCombo->changeItem( tmp,i ); 668 // commonCombo->changeItem( tmp,i );
690 // } 669 // }
691 670
692 connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) )); 671 connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) ));
693 672
694 sm_none = scrollMenu->insertItem(tr( "None" )); 673 sm_none = scrollMenu->insertItem(tr( "None" ));
695 sm_left = scrollMenu->insertItem(tr( "Left" )); 674 sm_left = scrollMenu->insertItem(tr( "Left" ));
696 sm_right = scrollMenu->insertItem(tr( "Right" )); 675 sm_right = scrollMenu->insertItem(tr( "Right" ));
697 // scrollMenu->insertSeparator(4); 676 // scrollMenu->insertSeparator(4);
698 // scrollMenu->insertItem(tr( "Horizontal" )); 677 // scrollMenu->insertItem(tr( "Horizontal" ));
699 678
700 configMenu->insertItem(tr( "ScrollBar" ),scrollMenu); 679 configMenu->insertItem(tr( "ScrollBar" ),scrollMenu);
701 680
702 configMenu->insertItem(tr( "History..." ), this, SLOT(historyDialog())); 681 configMenu->insertItem(tr( "History..." ), this, SLOT(historyDialog()));
703 682
704 cm_wrap = configMenu->insertItem(tr( "Wrap" )); 683 cm_wrap = configMenu->insertItem(tr( "Wrap" ));
705 cfg.setGroup("ScrollBar"); 684 cfg.setGroup("ScrollBar");
706 configMenu->setItemChecked(cm_wrap, cfg.readBoolEntry("HorzScroll",0)); 685 configMenu->setItemChecked(cm_wrap, cfg.readBoolEntry("HorzScroll",0));
707 686
708 cm_beep = configMenu->insertItem(tr( "Use Beep" )); 687 cm_beep = configMenu->insertItem(tr( "Use Beep" ));
709 cfg.setGroup("Menubar"); 688 cfg.setGroup("Menubar");
710 configMenu->setItemChecked(cm_beep, cfg.readBoolEntry("useBeep",0)); 689 configMenu->setItemChecked(cm_beep, cfg.readBoolEntry("useBeep",0));
711 690
712 fullscreen_msg = new QLabel(this); 691 fullscreen_msg = new QLabel(this);
713 fullscreen_msg-> setAlignment ( AlignCenter | SingleLine ); 692 fullscreen_msg-> setAlignment ( AlignCenter | SingleLine );
714 fullscreen_msg-> hide(); 693 fullscreen_msg-> hide();
715 fullscreen_msg-> setSizePolicy ( QSizePolicy ( QSizePolicy::Expanding, QSizePolicy::Expanding )); 694 fullscreen_msg-> setSizePolicy ( QSizePolicy ( QSizePolicy::Expanding, QSizePolicy::Expanding ));
716 fullscreen_msg-> setAutoResize(true); 695 fullscreen_msg-> setAutoResize(true);
717 fullscreen_msg-> setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 696 fullscreen_msg-> setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
718 fullscreen_msg-> setText(tr("To exit fullscreen, tap here.")); 697 fullscreen_msg-> setText(tr("To exit fullscreen, tap here."));
719 698
720 fullscreen_timer = new QTimer(this); 699 fullscreen_timer = new QTimer(this);
721 connect(fullscreen_timer, SIGNAL(timeout()), 700 connect(fullscreen_timer, SIGNAL(timeout()),
722 this, SLOT(fullscreenTimeout())); 701 this, SLOT(fullscreenTimeout()));
723 show_fullscreen_msg = true; 702 show_fullscreen_msg = true;
724 703
725 //scrollMenuSelected(-29); 704 //scrollMenuSelected(-29);
726 // cfg.setGroup("ScrollBar"); 705 // cfg.setGroup("ScrollBar");
727 // if(cfg.readBoolEntry("HorzScroll",0)) { 706 // if(cfg.readBoolEntry("HorzScroll",0)) {
728 // if(cfg.readNumEntry("Position",2) == 0) 707 // if(cfg.readNumEntry("Position",2) == 0)
729 // te->setScrollbarLocation(1); 708 // te->setScrollbarLocation(1);
730 // else 709 // else
731 // te->setScrollbarLocation(0); 710 // te->setScrollbarLocation(0);
732 // te->setScrollbarLocation( cfg.readNumEntry("Position",2)); 711 // te->setScrollbarLocation( cfg.readNumEntry("Position",2));
733 // te->setWrapAt(120); 712 // te->setWrapAt(120);
734 // } 713 // }
735 // create applications ///////////////////////////////////////////////////// 714 // create applications /////////////////////////////////////////////////////
736 setCentralWidget(tab); 715 setCentralWidget(tab);
737 716
738 // load keymaps //////////////////////////////////////////////////////////// 717 // load keymaps ////////////////////////////////////////////////////////////
739 KeyTrans::loadAll(); 718 KeyTrans::loadAll();
740 for (int i = 0; i < KeyTrans::count(); i++) 719 for (int i = 0; i < KeyTrans::count(); i++)
741 { 720 {
742 KeyTrans* s = KeyTrans::find(i); 721 KeyTrans* s = KeyTrans::find(i);
743 assert( s ); 722 assert( s );
744 } 723 }
745 724
746 se_pgm = _pgm; 725 se_pgm = _pgm;
747 se_args = _args; 726 se_args = _args;
748 727
749 cfg.setGroup("CommandLine"); 728 cfg.setGroup("CommandLine");
750 729
751 if (cfg.hasKey("shell_args")) 730 if (cfg.hasKey("shell_args"))
752 { 731 {
753 QStringList se_args_list = cfg.readListEntry("shell_args",'|'); 732 QStringList se_args_list = cfg.readListEntry("shell_args",'|');
754 for(uint i = 0; i < se_args_list.count(); i++) 733 for(uint i = 0; i < se_args_list.count(); i++)
755 { 734 {
756 se_args.prepend(se_args_list[se_args_list.count() - i - 1].latin1()); 735 se_args.prepend(se_args_list[se_args_list.count() - i - 1].latin1());
757 } 736 }
758 } 737 }
759 else 738 else
760 { 739 {
761 se_args.prepend("--login"); 740 se_args.prepend("--login");
762 } 741 }
763 742
764 se_pgm = cfg.readEntry("shell_bin", QString(se_pgm)); 743 se_pgm = cfg.readEntry("shell_bin", QString(se_pgm));
765 744
766 // this is the "documentation" for those who know to look 745 // this is the "documentation" for those who know to look
767 if (! cfg.hasKey("shell_args")) 746 if (! cfg.hasKey("shell_args"))
768 { 747 {
769 cfg.writeEntry("shell_args",QStringList::fromStrList(se_args),'|'); 748 cfg.writeEntry("shell_args",QStringList::fromStrList(se_args),'|');
770 } 749 }
771 if (! cfg.hasKey("shell_bin")) 750 if (! cfg.hasKey("shell_bin"))
772 { 751 {
773 cfg.writeEntry("shell_bin",QString(se_pgm)); 752 cfg.writeEntry("shell_bin",QString(se_pgm));
774 } 753 }
775 754
776 parseCommandLine(); 755 parseCommandLine();
777 756
778 // read and apply default values /////////////////////////////////////////// 757 // read and apply default values ///////////////////////////////////////////
779 resize(321, 321); // Dummy. 758 resize(321, 321); // Dummy.
780 QSize currentSize = size(); 759 QSize currentSize = size();
781 if (currentSize != size()) 760 if (currentSize != size())
782 defaultSize = size(); 761 defaultSize = size();
783 762
784 763
785 /* allows us to catch cancel/escape */ 764 /* allows us to catch cancel/escape */
786 reparent ( 0, WStyle_Customize | WStyle_NoBorder, 765 reparent ( 0, WStyle_Customize | WStyle_NoBorder,
787 QPoint ( 0, 0 )); 766 QPoint ( 0, 0 ));
788} 767}
789 768
790void Konsole::show() 769void Konsole::show()
791{ 770{
792 if ( !nsessions ) 771 if ( !nsessions )
793 { 772 {
794 newSession(); 773 newSession();
795 } 774 }
796 QMainWindow::show(); 775 QMainWindow::show();
797 776
798} 777}
799 778
800void Konsole::initSession(const char*, QStrList &) 779void Konsole::initSession(const char*, QStrList &)
801{ 780{
802 QMainWindow::show(); 781 QMainWindow::show();
803} 782}
804 783
805Konsole::~Konsole() 784Konsole::~Konsole()
806{ 785{
807 while (nsessions > 0) 786 while (nsessions > 0)
808 { 787 {
809 doneSession(getTe(), 0); 788 doneSession(getTe(), 0);
810 } 789 }
811} 790}
812 791
813void 792void
814Konsole::historyDialog() 793Konsole::historyDialog()
815{ 794{
816 QDialog *d = new QDialog ( this, "histdlg", true ); 795 QDialog *d = new QDialog ( this, "histdlg", true );
817 // d-> setCaption ( tr( "History" )); 796 // d-> setCaption ( tr( "History" ));
818 797
819 QBoxLayout *lay = new QVBoxLayout ( d, 4, 4 ); 798 QBoxLayout *lay = new QVBoxLayout ( d, 4, 4 );
820 799
821 QLabel *l = new QLabel ( tr( "History Lines:" ), d ); 800 QLabel *l = new QLabel ( tr( "History Lines:" ), d );
822 lay-> addWidget ( l ); 801 lay-> addWidget ( l );
823 802
824 Config cfg( "Konsole" ); 803 Config cfg( "Konsole" );
825 cfg.setGroup("History"); 804 cfg.setGroup("History");
826 int hist = cfg.readNumEntry("history_lines",300); 805 int hist = cfg.readNumEntry("history_lines",300);
827 int avg_line = cfg.readNumEntry("avg_line_length",60); 806 int avg_line = cfg.readNumEntry("avg_line_length",60);
828 807
829 QSpinBox *spin = new QSpinBox ( 1, 100000, 20, d ); 808 QSpinBox *spin = new QSpinBox ( 1, 100000, 20, d );
830 spin-> setValue ( hist ); 809 spin-> setValue ( hist );
831 spin-> setWrapping ( true ); 810 spin-> setWrapping ( true );
832 spin-> setButtonSymbols ( QSpinBox::PlusMinus ); 811 spin-> setButtonSymbols ( QSpinBox::PlusMinus );
833 lay-> addWidget ( spin ); 812 lay-> addWidget ( spin );
834 813
835 if ( d-> exec ( ) == QDialog::Accepted ) 814 if ( d-> exec ( ) == QDialog::Accepted )
836 { 815 {
837 cfg.writeEntry("history_lines", spin->value()); 816 cfg.writeEntry("history_lines", spin->value());
838 cfg.writeEntry("avg_line_length", avg_line); 817 cfg.writeEntry("avg_line_length", avg_line);
839 if (getTe() != NULL) 818 if (getTe() != NULL)
840 { 819 {
841 getTe()->currentSession->setHistory(true); 820 getTe()->currentSession->setHistory(true);
842 } 821 }
843 } 822 }
844 823
845 delete d; 824 delete d;
846} 825}
847 826
848 827
849void Konsole::cycleZoom() 828void Konsole::cycleZoom()
850{ 829{
851 TEWidget* te = getTe(); 830 TEWidget* te = getTe();
852 QFont font = te->getVTFont(); 831 QFont font = te->getVTFont();
853 int size = font.pointSize(); 832 int size = font.pointSize();
854 changeFontSize(1); 833 changeFontSize(1);
855 font = te->getVTFont(); 834 font = te->getVTFont();
856 if (font.pointSize() <= size) 835 if (font.pointSize() <= size)
857 { 836 {
858 do 837 do
859 { 838 {
860 font = te->getVTFont(); 839 font = te->getVTFont();
861 size = font.pointSize(); 840 size = font.pointSize();
862 changeFontSize(-1); 841 changeFontSize(-1);
863 font = te->getVTFont(); 842 font = te->getVTFont();
864 } 843 }
865 while (font.pointSize() < size); 844 while (font.pointSize() < size);
866 } 845 }
867} 846}
868 847
869void Konsole::changeFontSize(int delta) 848void Konsole::changeFontSize(int delta)
870{ 849{
871 // printf("delta font size %d\n", delta); 850 // printf("delta font size %d\n", delta);
872 TEWidget* te = getTe(); 851 TEWidget* te = getTe();
873 QFont font = te->getVTFont(); 852 QFont font = te->getVTFont();
874 int size = font.pointSize(); 853 int size = font.pointSize();
875 int closest = delta > 0? 10000 : -10000; 854 int closest = delta > 0? 10000 : -10000;
876 int closest_font = -1; 855 int closest_font = -1;
877 for(uint i = 0; i < fonts.count(); i++) 856 for(uint i = 0; i < fonts.count(); i++)
878 { 857 {
879 if (fonts.at(i)->getFont() == font) 858 if (fonts.at(i)->getFont() == font)
880 { 859 {
881 if (delta > 0) 860 if (delta > 0)
882 { 861 {
883 if (i+1 < fonts.count() 862 if (i+1 < fonts.count()
884 && fonts.at(i+1)->getFamilyNum() == fonts.at(i)->getFamilyNum()) 863 && fonts.at(i+1)->getFamilyNum() == fonts.at(i)->getFamilyNum())
885 { 864 {
886 setFont(i+1); 865 setFont(i+1);
887 printf("font %d\n", i+1); 866 printf("font %d\n", i+1);
888 return; 867 return;
889 } 868 }
890 } 869 }
891 else if (delta < 0) 870 else if (delta < 0)
892 { 871 {
893 if (i > 0 872 if (i > 0
894 && fonts.at(i-1)->getFamilyNum() == fonts.at(i)->getFamilyNum()) 873 && fonts.at(i-1)->getFamilyNum() == fonts.at(i)->getFamilyNum())
895 { 874 {
896 setFont(i-1); 875 setFont(i-1);
897 printf("font %d\n", i-1); 876 printf("font %d\n", i-1);
898 return; 877 return;
899 } 878 }
900 } 879 }
901 } 880 }
902 int fsize = fonts.at(i)->getSize(); 881 int fsize = fonts.at(i)->getSize();
903 printf("%d size=%d fsize=%d closest=%d\n", i, size, fsize, closest); 882 printf("%d size=%d fsize=%d closest=%d\n", i, size, fsize, closest);
904 if ((delta > 0 && fsize > size && fsize < closest) 883 if ((delta > 0 && fsize > size && fsize < closest)
905 || (delta < 0 && fsize < size && fsize > closest)) 884 || (delta < 0 && fsize < size && fsize > closest))
906 { 885 {
907 closest = fsize; 886 closest = fsize;
908 closest_font = i; 887 closest_font = i;
909 } 888 }
910 } 889 }
911 if (closest_font >= 0) 890 if (closest_font >= 0)
912 { 891 {
913 printf("font closest %d (%d)\n", closest_font, closest); 892 printf("font closest %d (%d)\n", closest_font, closest);
914 setFont(closest_font); 893 setFont(closest_font);
915 } 894 }
916} 895}
917 896
918int Konsole::findFont(const QString& name, int size, bool exactMatch) 897int Konsole::findFont(const QString& name, int size, bool exactMatch)
919{ 898{
920 for(uint i = 0; i < fonts.count(); i++) 899 for(uint i = 0; i < fonts.count(); i++)
921 { 900 {
922 if (fonts.at(i)->getName() == name 901 if (fonts.at(i)->getName() == name
923 && fonts.at(i)->getSize() == size) 902 && fonts.at(i)->getSize() == size)
924 { 903 {
925 return(i); 904 return(i);
926 } 905 }
927 } 906 }
928 if (exactMatch) 907 if (exactMatch)
929 { 908 {
930 return(-1); 909 return(-1);
931 } 910 }
932 for(uint i = 0; i < fonts.count(); i++) 911 for(uint i = 0; i < fonts.count(); i++)
933 { 912 {
934 if (fonts.at(i)->getSize() == size) 913 if (fonts.at(i)->getSize() == size)
935 { 914 {
936 return(i); 915 return(i);
937 } 916 }
938 } 917 }
939 return(-1); 918 return(-1);
940} 919}
941 920
942void Konsole::setFont(int f) 921void Konsole::setFont(int f)
943{ 922{
944 VTFont* font = fonts.at(f); 923 VTFont* font = fonts.at(f);
945 if (font) 924 if (font)
946 { 925 {
947 TEWidget* te = getTe(); 926 TEWidget* te = getTe();
948 if (te != 0) 927 if (te != 0)
949 { 928 {
950 te->setVTFont(font->getFont()); 929 te->setVTFont(font->getFont());
951 } 930 }
952 cfont = f; 931 cfont = f;
953 932
954 int familyNum = font->getFamilyNum(); 933 int familyNum = font->getFamilyNum();
955 int size = font->getSize(); 934 int size = font->getSize();
956 printf("familyNum = %d size = %d count=%d\n", familyNum, size, 935 printf("familyNum = %d size = %d count=%d\n", familyNum, size,
957 fontList->count()); 936 fontList->count());
958 for(int i = 0; i < (int)fontList->count(); i++) 937 for(int i = 0; i < (int)fontList->count(); i++)
959 { 938 {
960 fontList->setItemChecked(i + 1000, i == familyNum); 939 fontList->setItemChecked(i + 1000, i == familyNum);
961 } 940 }
962 for(int i = 0; i < (int)fonts.count(); i++) 941 for(int i = 0; i < (int)fonts.count(); i++)
963 { 942 {
964 fontList->setItemChecked(i, fonts.at(i)->getFamilyNum() == familyNum 943 fontList->setItemChecked(i, fonts.at(i)->getFamilyNum() == familyNum
965 && fonts.at(i)->getSize() == size); 944 && fonts.at(i)->getSize() == size);
966 } 945 }
967 Config cfg( "Konsole" ); 946 Config cfg( "Konsole" );
968 cfg.setGroup("Font"); 947 cfg.setGroup("Font");
969 QString ss = "Session"+ QString::number(tab->currentPageIndex()+1); 948 QString ss = "Session"+ QString::number(tab->currentPageIndex()+1);
970 if (tab->currentPageIndex() == 0) 949 if (tab->currentPageIndex() == 0)
971 { 950 {
972 cfg.writeEntry("FontName", fonts.at(cfont)->getFamily()); 951 cfg.writeEntry("FontName", fonts.at(cfont)->getFamily());
973 cfg.writeEntry("FontSize", fonts.at(cfont)->getSize()); 952 cfg.writeEntry("FontSize", fonts.at(cfont)->getSize());
974 } 953 }
975 cfg.writeEntry("FontName"+ss, fonts.at(cfont)->getFamily()); 954 cfg.writeEntry("FontName"+ss, fonts.at(cfont)->getFamily());
976 cfg.writeEntry("FontSize"+ss, fonts.at(cfont)->getSize()); 955 cfg.writeEntry("FontSize"+ss, fonts.at(cfont)->getSize());
977 } 956 }
978} 957}
979 958
980#if 0 959#if 0
981void Konsole::fontChanged(int f) 960void Konsole::fontChanged(int f)
982{ 961{
983 VTFont* font = fonts.at(f); 962 VTFont* font = fonts.at(f);
984 if (font != 0) 963 if (font != 0)
985 { 964 {
986 for(uint i = 0; i < fonts.count(); i++) 965 for(uint i = 0; i < fonts.count(); i++)
987 { 966 {
988 fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE); 967 fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE);
989 } 968 }
990 969
991 cfont = f; 970 cfont = f;
992 971
993 TEWidget* te = getTe(); 972 TEWidget* te = getTe();
994 if (te != 0) 973 if (te != 0)
995 { 974 {
996 te->setVTFont(font->getFont()); 975 te->setVTFont(font->getFont());
997 } 976 }
998 } 977 }
999} 978}
1000#endif 979#endif
1001 980
1002 981
1003void Konsole::enterCommand(int c) 982void Konsole::enterCommand(int c)
1004{ 983{
1005 TEWidget* te = getTe(); 984 TEWidget* te = getTe();
1006 if (te != 0) 985 if (te != 0)
1007 { 986 {
1008 if(!commonCombo->editable()) 987 if(!commonCombo->editable())
1009 { 988 {
1010 QString text = commonCombo->text(c); //commonCmds[c]; 989 QString text = commonCombo->text(c); //commonCmds[c];
1011 te->emitText(text); 990 te->emitText(text);
1012 } 991 }
1013 else 992 else
1014 { 993 {
1015 changeCommand( commonCombo->text(c), c); 994 changeCommand( commonCombo->text(c), c);
1016 } 995 }
1017 } 996 }
1018} 997}
1019 998
1020void Konsole::hitEnter() 999void Konsole::hitEnter()
1021{ 1000{
1022 TEWidget* te = getTe(); 1001 TEWidget* te = getTe();
1023 if (te != 0) 1002 if (te != 0)
1024 { 1003 {
1025 te->emitText(QString("\r")); 1004 te->emitText(QString("\r"));
1026 } 1005 }
1027} 1006}
1028 1007
1029void Konsole::hitSpace() 1008void Konsole::hitSpace()
1030{ 1009{
1031 TEWidget* te = getTe(); 1010 TEWidget* te = getTe();
1032 if (te != 0) 1011 if (te != 0)
1033 { 1012 {
1034 te->emitText(QString(" ")); 1013 te->emitText(QString(" "));
1035 } 1014 }
1036} 1015}
1037 1016
1038void Konsole::hitTab() 1017void Konsole::hitTab()
1039{ 1018{
1040 TEWidget* te = getTe(); 1019 TEWidget* te = getTe();
1041 if (te != 0) 1020 if (te != 0)
1042 { 1021 {
1043 te->emitText(QString("\t")); 1022 te->emitText(QString("\t"));
1044 } 1023 }
1045} 1024}
1046 1025
1047void Konsole::hitPaste() 1026void Konsole::hitPaste()
1048{ 1027{
1049 TEWidget* te = getTe(); 1028 TEWidget* te = getTe();
1050 if (te != 0) 1029 if (te != 0)
1051 { 1030 {
1052 te->pasteClipboard(); 1031 te->pasteClipboard();
1053 } 1032 }
1054} 1033}
1055 1034
1056void Konsole::hitUp() 1035void Konsole::hitUp()
1057{ 1036{
1058 TEWidget* te = getTe(); 1037 TEWidget* te = getTe();
1059 if (te != 0) 1038 if (te != 0)
1060 { 1039 {
1061 QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Up, 0, 0); 1040 QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Up, 0, 0);
1062 QApplication::sendEvent( te, &ke ); 1041 QApplication::sendEvent( te, &ke );
1063 } 1042 }
1064} 1043}
1065 1044
1066void Konsole::hitDown() 1045void Konsole::hitDown()
1067{ 1046{
1068 TEWidget* te = getTe(); 1047 TEWidget* te = getTe();
1069 if (te != 0) 1048 if (te != 0)
1070 { 1049 {
1071 QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Down, 0, 0); 1050 QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Down, 0, 0);
1072 QApplication::sendEvent( te, &ke ); 1051 QApplication::sendEvent( te, &ke );
1073 } 1052 }
1074} 1053}
1075 1054
1076/** 1055/**
1077 This function calculates the size of the external widget 1056 This function calculates the size of the external widget
1078 needed for the internal widget to be 1057 needed for the internal widget to be
1079 */ 1058 */
1080QSize Konsole::calcSize(int columns, int lines) 1059QSize Konsole::calcSize(int columns, int lines)
1081{ 1060{
1082 TEWidget* te = getTe(); 1061 TEWidget* te = getTe();
1083 if (te != 0) 1062 if (te != 0)
1084 { 1063 {
1085 QSize size = te->calcSize(columns, lines); 1064 QSize size = te->calcSize(columns, lines);
1086 return size; 1065 return size;
1087 } 1066 }
1088 else 1067 else
1089 { 1068 {
1090 QSize size; 1069 QSize size;
1091 return size; 1070 return size;
1092 } 1071 }
1093} 1072}
1094 1073
1095/** 1074/**
1096 sets application window to a size based on columns X lines of the te 1075 sets application window to a size based on columns X lines of the te
1097 guest widget. Call with (0,0) for setting default size. 1076 guest widget. Call with (0,0) for setting default size.
1098*/ 1077*/
1099 1078
1100void Konsole::setColLin(int columns, int lines) 1079void Konsole::setColLin(int columns, int lines)
1101{ 1080{
1102 qDebug("konsole::setColLin:: Columns %d", columns); 1081 qDebug("konsole::setColLin:: Columns %d", columns);
1103 1082
1104 if ((columns==0) || (lines==0)) 1083 if ((columns==0) || (lines==0))
1105 { 1084 {
1106 if (defaultSize.isEmpty()) // not in config file : set default value 1085 if (defaultSize.isEmpty()) // not in config file : set default value
1107 { 1086 {
1108 defaultSize = calcSize(80,24); 1087 defaultSize = calcSize(80,24);
1109 // notifySize(24,80); // set menu items (strange arg order !) 1088 // notifySize(24,80); // set menu items (strange arg order !)
1110 } 1089 }
1111 resize(defaultSize); 1090 resize(defaultSize);
1112 } 1091 }
1113 else 1092 else
1114 { 1093 {
1115 resize(calcSize(columns, lines)); 1094 resize(calcSize(columns, lines));
1116 // notifySize(lines,columns); // set menu items (strange arg order !) 1095 // notifySize(lines,columns); // set menu items (strange arg order !)
1117 } 1096 }
1118} 1097}
1119 1098
1120/* 1099/*
1121void Konsole::setFont(int fontno) 1100void Konsole::setFont(int fontno)
1122{ 1101{
1123 QFont f; 1102 QFont f;
1124 if (fontno == 0) 1103 if (fontno == 0)
1125 f = defaultFont = QFont( "Helvetica", 12 ); 1104 f = defaultFont = QFont( "Helvetica", 12 );
1126 else 1105 else
1127 if (fonts[fontno][0] == '-') 1106 if (fonts[fontno][0] == '-')
1128 f.setRawName( fonts[fontno] ); 1107 f.setRawName( fonts[fontno] );
1129 else 1108 else
1130 { 1109 {
1131 f.setFamily(fonts[fontno]); 1110 f.setFamily(fonts[fontno]);
1132 f.setRawMode( TRUE ); 1111 f.setRawMode( TRUE );
1133 } 1112 }
1134 if ( !f.exactMatch() && fontno != 0) 1113 if ( !f.exactMatch() && fontno != 0)
1135 { 1114 {
1136 QString msg = i18n("Font `%1' not found.\nCheck README.linux.console for help.").arg(fonts[fontno]); 1115 QString msg = i18n("Font `%1' not found.\nCheck README.linux.console for help.").arg(fonts[fontno]);
1137 QMessageBox(this, msg); 1116 QMessageBox(this, msg);
1138 return; 1117 return;
1139 } 1118 }
1140 if (se) se->setFontNo(fontno); 1119 if (se) se->setFontNo(fontno);
1141 te->setVTFont(f); 1120 te->setVTFont(f);
1142 n_font = fontno; 1121 n_font = fontno;
1143} 1122}
1144*/ 1123*/
1145 1124
1146// --| color selection |------------------------------------------------------- 1125// --| color selection |-------------------------------------------------------
1147 1126
1148void Konsole::changeColumns(int /*columns*/) 1127void Konsole::changeColumns(int /*columns*/)
1149{ //FIXME this seems to cause silliness when reset command is executed 1128{ //FIXME this seems to cause silliness when reset command is executed
1150 // qDebug("change columns"); 1129 // qDebug("change columns");
1151 // TEWidget* te = getTe(); 1130 // TEWidget* te = getTe();
1152 // if (te != 0) { 1131 // if (te != 0) {
1153 // setColLin(columns,te->Lines()); 1132 // setColLin(columns,te->Lines());
1154 // te->update(); 1133 // te->update();
1155 // } 1134 // }
1156} 1135}
1157 1136
1158//FIXME: If a child dies during session swap, 1137//FIXME: If a child dies during session swap,
1159// this routine might be called before 1138// this routine might be called before
1160// session swap is completed. 1139// session swap is completed.
1161 1140
1162void Konsole::doneSession(TEWidget* te, int ) 1141void Konsole::doneSession(TEWidget* te, int )
1163{ 1142{
1164 // TEWidget *te = NULL; 1143 // TEWidget *te = NULL;
1165 // if (sess->currentSession == tab->currentPage()) { 1144 // if (sess->currentSession == tab->currentPage()) {
1166 // printf("done current session\n"); 1145 // printf("done current session\n");
1167 // te = getTe(); 1146 // te = getTe();
1168 // } else { 1147 // } else {
1169 // int currentPage = tab->currentPageIndex(); 1148 // int currentPage = tab->currentPageIndex();
1170 // printf("done not current session\n"); 1149 // printf("done not current session\n");
1171 // for(int i = 0; i < nsessions; i++) { 1150 // for(int i = 0; i < nsessions; i++) {
1172 // tab->setCurrentPage(i); 1151 // tab->setCurrentPage(i);
1173 // printf("find session %d tab page %x session %x\n", 1152 // printf("find session %d tab page %x session %x\n",
1174 // i, tab->currentPage(), sess->currentSession); 1153 // i, tab->currentPage(), sess->currentSession);
1175 // if (tab->currentPage() == sess->currentSession) { 1154 // if (tab->currentPage() == sess->currentSession) {
1176 // printf("found session %d\n", i); 1155 // printf("found session %d\n", i);
1177 // te = tab->currentPage(); 1156 // te = tab->currentPage();
1178 // break; 1157 // break;
1179 // } 1158 // }
1180 // } 1159 // }
1181 // tab->setCurrentPage(currentPage); 1160 // tab->setCurrentPage(currentPage);
1182 // } 1161 // }
1183 if (te != 0) 1162 if (te != 0)
1184 { 1163 {
1185 te->currentSession->setConnect(FALSE); 1164 te->currentSession->setConnect(FALSE);
1186 tab->removeTab(te); 1165 tab->removeTab(te);
1187 delete te->currentSession; 1166 delete te->currentSession;
1188 delete te; 1167 delete te;
1189 sessionList->removeItem(nsessions); 1168 sessionList->removeItem(nsessions);
1190 nsessions--; 1169 nsessions--;
1191 } 1170 }
1192 if (nsessions == 0) 1171 if (nsessions == 0)
1193 { 1172 {
1194 close(); 1173 close();
1195 } 1174 }
1196} 1175}
1197 1176
1198void Konsole::changeTitle(TEWidget* te, const QString& newTitle ) 1177void Konsole::changeTitle(TEWidget* te, const QString& newTitle )
1199{ 1178{
1200 if (te == getTe()) 1179 if (te == getTe())
1201 { 1180 {
1202 setCaption( newTitle + " - " + tr( "Konsole " ) ); 1181 setCaption( newTitle + " - " + tr( "Konsole " ) );
1203 } 1182 }
1204} 1183}
1205 1184
1206 1185
1207void Konsole::newSession() 1186void Konsole::newSession()
1208{ 1187{
1209 if(nsessions < 15) 1188 if(nsessions < 15)
1210 { // seems to be something weird about 16 tabs on the Zaurus.... memory? 1189 { // seems to be something weird about 16 tabs on the Zaurus.... memory?
1211 TEWidget* te = new TEWidget(tab); 1190 TEWidget* te = new TEWidget(tab);
1212 Config cfg( "Konsole" ); 1191 Config cfg( "Konsole" );
1213 cfg.setGroup("Menubar"); 1192 cfg.setGroup("Menubar");
1214 1193
1215 // FIXME use more defaults from config file 1194 // FIXME use more defaults from config file
1216 te->useBeep=cfg.readBoolEntry("useBeep",0); 1195 te->useBeep=cfg.readBoolEntry("useBeep",0);
1217 1196
1218 // te->setBackgroundMode(PaletteBase); //we want transparent!! 1197 // te->setBackgroundMode(PaletteBase); //we want transparent!!
1219 1198
1220 cfg.setGroup("Font"); 1199 cfg.setGroup("Font");
1221 QString sn = "Session" + QString::number(nsessions+1); 1200 QString sn = "Session" + QString::number(nsessions+1);
1222 printf("read font session %s\n", sn.latin1()); 1201 printf("read font session %s\n", sn.latin1());
1223 QString fontName = cfg.readEntry("FontName"+sn, 1202 QString fontName = cfg.readEntry("FontName"+sn,
1224 cfg.readEntry("FontName", 1203 cfg.readEntry("FontName",
1225 fonts.at(cfont)->getFamily())); 1204 fonts.at(cfont)->getFamily()));
1226 int fontSize = cfg.readNumEntry("FontSize"+sn, 1205 int fontSize = cfg.readNumEntry("FontSize"+sn,
1227 cfg.readNumEntry("FontSize", 1206 cfg.readNumEntry("FontSize",
1228 fonts.at(cfont)->getSize())); 1207 fonts.at(cfont)->getSize()));
1229 cfont = findFont(fontName, fontSize, false); 1208 cfont = findFont(fontName, fontSize, false);
1230 printf("lookup font %s size %d got %d\n", fontName.latin1(), fontSize, cfont); 1209 printf("lookup font %s size %d got %d\n", fontName.latin1(), fontSize, cfont);
1231 if (cfont < 0) 1210 if (cfont < 0)
1232 cfont = 0; 1211 cfont = 0;
1233 te->setVTFont(fonts.at(cfont)->getFont()); 1212 te->setVTFont(fonts.at(cfont)->getFont());
1234 1213
1235 tab->addTab(te); 1214 tab->addTab(te);
1236 TESession* se = new TESession(this, te, se_pgm, se_args, "xterm"); 1215 TESession* se = new TESession(this, te, se_pgm, se_args, "xterm");
1237 te->currentSession = se; 1216 te->currentSession = se;
1238 connect( se, SIGNAL(done(TEWidget*,int)), this, SLOT(doneSession(TEWidget*,int)) ); 1217 connect( se, SIGNAL(done(TEWidget*,int)), this, SLOT(doneSession(TEWidget*,int)) );
1239 connect( se, SIGNAL(changeTitle(TEWidget*,const QString&)), this, 1218 connect( se, SIGNAL(changeTitle(TEWidget*,const QString&)), this,
1240 SLOT(changeTitle(TEWidget*,const QString&)) ); 1219 SLOT(changeTitle(TEWidget*,const QString&)) );
1241 connect(te, SIGNAL(changeFontSize(int)), this, SLOT(changeFontSize(int))); 1220 connect(te, SIGNAL(changeFontSize(int)), this, SLOT(changeFontSize(int)));
1242 connect(te, SIGNAL(changeSession(int)), this, SLOT(changeSession(int))); 1221 connect(te, SIGNAL(changeSession(int)), this, SLOT(changeSession(int)));
1243 connect(te, SIGNAL(newSession()), this, SLOT(newSession())); 1222 connect(te, SIGNAL(newSession()), this, SLOT(newSession()));
1244 connect(te, SIGNAL(toggleFullScreen()), this, SLOT(toggleFullScreen())); 1223 connect(te, SIGNAL(toggleFullScreen()), this, SLOT(toggleFullScreen()));
1245 connect(te, SIGNAL(setFullScreen(bool)), this, SLOT(setFullScreen(bool))); 1224 connect(te, SIGNAL(setFullScreen(bool)), this, SLOT(setFullScreen(bool)));
1246 se->run(); 1225 se->run();
1247 se->setConnect(TRUE); 1226 se->setConnect(TRUE);
1248 se->setHistory(b_scroll); 1227 se->setHistory(b_scroll);
1249 nsessions++; 1228 nsessions++;
1250 sessionList->insertItem(QString::number(nsessions), nsessions); 1229 sessionList->insertItem(QString::number(nsessions), nsessions);
1251 sessionListSelected(nsessions); 1230 sessionListSelected(nsessions);
1252 doWrap(); 1231 doWrap();
1253 setColor(nsessions-1); 1232 setColor(nsessions-1);
1254 } 1233 }
1255} 1234}
1256 1235
1257TEWidget* Konsole::getTe() 1236TEWidget* Konsole::getTe()
1258{ 1237{
1259 if (nsessions) 1238 if (nsessions)
1260 { 1239 {
1261 return (TEWidget *) tab->currentPage(); 1240 return (TEWidget *) tab->currentPage();
1262 } 1241 }
1263 else 1242 else
1264 { 1243 {
1265 return 0; 1244 return 0;
1266 } 1245 }
1267} 1246}
1268 1247
1269void Konsole::sessionListSelected(int id) 1248void Konsole::sessionListSelected(int id)
1270{ 1249{
1271 if (id < 0) 1250 if (id < 0)
1272 { 1251 {
1273 return; 1252 return;
1274 } 1253 }
1275 QString selected = sessionList->text(id); 1254 QString selected = sessionList->text(id);
1276 EKNumTabBar *tabBar = tab->getTabBar(); 1255 EKNumTabBar *tabBar = tab->getTabBar();
1277 1256
1278 int n = 0; 1257 int n = 0;
1279 for(int i = 0; n < tabBar->count(); i++) 1258 for(int i = 0; n < tabBar->count(); i++)
1280 { 1259 {
1281 if (tabBar->tab(i)) 1260 if (tabBar->tab(i))
1282 { 1261 {
1283 // printf("selected = %s tab %d = %s\n", selected.latin1(), 1262 // printf("selected = %s tab %d = %s\n", selected.latin1(),
1284 // i, tabBar->tab(i)->text().latin1()); 1263 // i, tabBar->tab(i)->text().latin1());
1285 if (tabBar->tab(i)->text() == selected) 1264 if (tabBar->tab(i)->text() == selected)
1286 { 1265 {
1287 tab->setCurrentPage(i); 1266 tab->setCurrentPage(i);
1288 break; 1267 break;
1289 } 1268 }
1290 n++; 1269 n++;
1291 } 1270 }
1292 } 1271 }
1293} 1272}
1294 1273
1295 1274
1296void Konsole::changeSession(int delta) 1275void Konsole::changeSession(int delta)
1297{ 1276{
1298 printf("delta session %d\n", delta); 1277 printf("delta session %d\n", delta);
1299 QTabBar *tabBar = tab->getTabBar(); 1278 QTabBar *tabBar = tab->getTabBar();
1300 int i = tabBar->tab(tabBar->currentTab())->text().toInt() - 1; 1279 int i = tabBar->tab(tabBar->currentTab())->text().toInt() - 1;
1301 i += delta; 1280 i += delta;
1302 if (i < 0) 1281 if (i < 0)
1303 i += tabBar->count(); 1282 i += tabBar->count();
1304 if (i >= tabBar->count()) 1283 if (i >= tabBar->count())
1305 i -= tabBar->count(); 1284 i -= tabBar->count();
1306 1285
1307 QString selected = QString::number(i+1); 1286 QString selected = QString::number(i+1);
1308 int n = 0; 1287 int n = 0;
1309 for(int i = 0; n < tabBar->count(); i++) 1288 for(int i = 0; n < tabBar->count(); i++)
1310 { 1289 {
1311 if (tabBar->tab(i)) 1290 if (tabBar->tab(i))
1312 { 1291 {
1313 printf("selected = %s tab %d = %s\n", selected.latin1(), 1292 printf("selected = %s tab %d = %s\n", selected.latin1(),
1314 i, tabBar->tab(i)->text().latin1()); 1293 i, tabBar->tab(i)->text().latin1());
1315 if (tabBar->tab(i)->text() == selected) 1294 if (tabBar->tab(i)->text() == selected)
1316 { 1295 {
1317 tab->setCurrentPage(i); 1296 tab->setCurrentPage(i);
1318 break; 1297 break;
1319 } 1298 }
1320 n++; 1299 n++;
1321 } 1300 }
1322 } 1301 }
1323} 1302}
1324 1303
1325void Konsole::switchSession(QWidget* w) 1304void Konsole::switchSession(QWidget* w)
1326{ 1305{
1327 TEWidget* te = (TEWidget *) w; 1306 TEWidget* te = (TEWidget *) w;
1328 QFont teFnt = te->getVTFont(); 1307 QFont teFnt = te->getVTFont();
1329 int familyNum = -1; 1308 int familyNum = -1;
1330 1309
1331 for(uint i = 0; i < fonts.count(); i++) 1310 for(uint i = 0; i < fonts.count(); i++)
1332 { 1311 {
1333 VTFont *fnt = fonts.at(i); 1312 VTFont *fnt = fonts.at(i);
1334 bool cf = fnt->getFont() == teFnt; 1313 bool cf = fnt->getFont() == teFnt;
1335 fontList->setItemChecked(i, cf); 1314 fontList->setItemChecked(i, cf);
1336 if (cf) 1315 if (cf)
1337 { 1316 {
1338 cfont = i; 1317 cfont = i;
1339 familyNum = fnt->getFamilyNum(); 1318 familyNum = fnt->getFamilyNum();
1340 } 1319 }
1341 } 1320 }
1342 for(int i = 0; i < (int)fontList->count(); i++) 1321 for(int i = 0; i < (int)fontList->count(); i++)
1343 { 1322 {
1344 fontList->setItemChecked(i + 1000, i == familyNum); 1323 fontList->setItemChecked(i + 1000, i == familyNum);
1345 } 1324 }
1346 if (! te->currentSession->Title().isEmpty() ) 1325 if (! te->currentSession->Title().isEmpty() )
1347 { 1326 {
1348 setCaption( te->currentSession->Title() + " - " + tr( "Konsole" ) ); 1327 setCaption( te->currentSession->Title() + " - " + tr( "Konsole" ) );
1349 } 1328 }
1350 else 1329 else
1351 { 1330 {
1352 setCaption( tr( "Konsole" ) ); 1331 setCaption( tr( "Konsole" ) );
1353 } 1332 }
1354 // colorMenuSelected(te->color_menu_item); 1333 // colorMenuSelected(te->color_menu_item);
1355} 1334}
1356 1335
1357 1336
1358void Konsole::toggleFullScreen() 1337void Konsole::toggleFullScreen()
1359{ 1338{
1360 setFullScreen(! fullscreen); 1339 setFullScreen(! fullscreen);
1361} 1340}
1362 1341
1363void Konsole::setFullScreen ( bool b ) 1342void Konsole::setFullScreen ( bool b )
1364{ 1343{
1365 static QSize normalsize; 1344 static QSize normalsize;
1366 static bool listHidden; 1345 static bool listHidden;
1367 1346
1368 if (b == fullscreen) 1347 if (b == fullscreen)
1369 { 1348 {
1370 return; 1349 return;
1371 } 1350 }
1372 1351
1373 fullscreen = b; 1352 fullscreen = b;
1374 1353
1375 if ( b ) 1354 if ( b )
1376 { 1355 {
1377 if ( !normalsize. isValid ( )) 1356 if ( !normalsize. isValid ( ))
1378 { 1357 {
1379 normalsize = size ( ); 1358 normalsize = size ( );
1380 } 1359 }
1381 1360
1382 setFixedSize ( qApp-> desktop ( )-> size ( )); 1361 setFixedSize ( qApp-> desktop ( )-> size ( ));
1383 showNormal ( ); 1362 showNormal ( );
1384 reparent ( 0, WStyle_Customize | WStyle_NoBorder, 1363 reparent ( 0, WStyle_Customize | WStyle_NoBorder,
1385 QPoint ( 0, 0 )); 1364 QPoint ( 0, 0 ));
1386 showFullScreen ( ); 1365 showFullScreen ( );
1387 1366
1388 menuToolBar->hide(); 1367 menuToolBar->hide();
1389 toolBar->hide(); 1368 toolBar->hide();
1390 listHidden = secondToolBar->isHidden(); 1369 listHidden = secondToolBar->isHidden();
1391 secondToolBar->hide(); 1370 secondToolBar->hide();
1392 // commonCombo->hide(); 1371 // commonCombo->hide();
1393 tab->getTabBar()->hide(); 1372 tab->getTabBar()->hide();
1394 tab->setMargin(tab->margin()); 1373 tab->setMargin(tab->margin());
1395 1374
1396 if (show_fullscreen_msg) 1375 if (show_fullscreen_msg)
1397 { 1376 {
1398 fullscreen_msg-> move(tab->x() + tab->width()/2 - fullscreen_msg->width()/2, 1377 fullscreen_msg-> move(tab->x() + tab->width()/2 - fullscreen_msg->width()/2,
1399 qApp->desktop()->height()/16 - fullscreen_msg->height()/2); 1378 qApp->desktop()->height()/16 - fullscreen_msg->height()/2);
1400 fullscreen_msg->show(); 1379 fullscreen_msg->show();
1401 fullscreen_timer->start(3000, true); 1380 fullscreen_timer->start(3000, true);
1402 show_fullscreen_msg = false; 1381 show_fullscreen_msg = false;
1403 } 1382 }
1404 } 1383 }
1405 else 1384 else
1406 { 1385 {
1407 showNormal ( ); 1386 showNormal ( );
1408 reparent ( 0, WStyle_Customize, QPoint ( 0, 0 )); 1387 reparent ( 0, WStyle_Customize, QPoint ( 0, 0 ));
1409 resize ( normalsize ); 1388 resize ( normalsize );
1410 showMaximized ( ); 1389 showMaximized ( );
1411 normalsize = QSize ( ); 1390 normalsize = QSize ( );
1412 1391
1413 menuToolBar->show(); 1392 menuToolBar->show();
1414 toolBar->show(); 1393 toolBar->show();
1415 if(! listHidden) 1394 if(! listHidden)
1416 { 1395 {
1417 secondToolBar->show(); 1396 secondToolBar->show();
1418 } 1397 }
1419 // commonCombo->show(); 1398 // commonCombo->show();
1420 menuToolBar->show(); 1399 menuToolBar->show();
1421 if (tabPos != tm_hidden) 1400 if (tabPos != tm_hidden)
1422 { 1401 {
1423 tab->getTabBar()->show(); 1402 tab->getTabBar()->show();
1424 } 1403 }
1425 } 1404 }
1426 tab->setMargin(tab->margin()); // cause setup to run 1405 tab->setMargin(tab->margin()); // cause setup to run
1427} 1406}
1428 1407
1429 1408
1430void Konsole::fullscreenTimeout() 1409void Konsole::fullscreenTimeout()
1431{ 1410{
1432 fullscreen_msg->hide(); 1411 fullscreen_msg->hide();
1433} 1412}
1434 1413
1435void Konsole::colorMenuIsSelected(int iD) 1414void Konsole::colorMenuIsSelected(int iD)
1436{ 1415{
1437 fromMenu = TRUE; 1416 fromMenu = TRUE;
1438 colorMenuSelected(iD); 1417 colorMenuSelected(iD);
1439} 1418}
1440 1419
1441/// ------------------------------- some new stuff by L.J. Potter 1420/// ------------------------------- some new stuff by L.J. Potter
1442 1421
1443 1422
1444void Konsole::colorMenuSelected(int iD) 1423void Konsole::colorMenuSelected(int iD)
1445{ 1424{
1446 // this is NOT pretty, elegant or anything else besides functional 1425 // this is NOT pretty, elegant or anything else besides functional
1447 // QString temp; 1426 // QString temp;
1448 // qDebug( temp.sprintf("colormenu %d", iD)); 1427 // qDebug( temp.sprintf("colormenu %d", iD));
1449 1428
1450 TEWidget* te = getTe(); 1429 TEWidget* te = getTe();
1451 Config cfg( "Konsole" ); 1430 Config cfg( "Konsole" );
1452 cfg.setGroup("Colors"); 1431 cfg.setGroup("Colors");
1453 1432
1454 ColorEntry m_table[TABLE_COLORS]; 1433 ColorEntry m_table[TABLE_COLORS];
1455 const ColorEntry * defaultCt=te->getdefaultColorTable(); 1434 const ColorEntry * defaultCt=te->getdefaultColorTable();
1456 1435
1457 int i; 1436 int i;
1458 1437
1459 // te->color_menu_item = iD; 1438 // te->color_menu_item = iD;
1460 1439
1461 colorMenu->setItemChecked(cm_ab,FALSE); 1440 colorMenu->setItemChecked(cm_ab,FALSE);
1462 colorMenu->setItemChecked(cm_bb,FALSE); 1441 colorMenu->setItemChecked(cm_bb,FALSE);
1463 colorMenu->setItemChecked(cm_wc,FALSE); 1442 colorMenu->setItemChecked(cm_wc,FALSE);
1464 colorMenu->setItemChecked(cm_cw,FALSE); 1443 colorMenu->setItemChecked(cm_cw,FALSE);
1465 colorMenu->setItemChecked(cm_mb,FALSE); 1444 colorMenu->setItemChecked(cm_mb,FALSE);
1466 colorMenu->setItemChecked(cm_bm,FALSE); 1445 colorMenu->setItemChecked(cm_bm,FALSE);
1467 colorMenu->setItemChecked(cm_gy,FALSE); 1446 colorMenu->setItemChecked(cm_gy,FALSE);
1468 colorMenu->setItemChecked(cm_rb,FALSE); 1447 colorMenu->setItemChecked(cm_rb,FALSE);
1469 colorMenu->setItemChecked(cm_br,FALSE); 1448 colorMenu->setItemChecked(cm_br,FALSE);
1470 colorMenu->setItemChecked(cm_wb,FALSE); 1449 colorMenu->setItemChecked(cm_wb,FALSE);
1471 colorMenu->setItemChecked(cm_bw,FALSE); 1450 colorMenu->setItemChecked(cm_bw,FALSE);
1472 colorMenu->setItemChecked(cm_gb,FALSE); 1451 colorMenu->setItemChecked(cm_gb,FALSE);
1473 1452
1474 if(iD==cm_default) 1453 if(iD==cm_default)
1475 { // default default 1454 { // default default
1476 printf("default colors\n"); 1455 printf("default colors\n");
1477 for (i = 0; i < TABLE_COLORS; i++) 1456 for (i = 0; i < TABLE_COLORS; i++)
1478 { 1457 {
1479 m_table[i].color = defaultCt[i].color; 1458 m_table[i].color = defaultCt[i].color;
1480 if(i==1 || i == 11) 1459 if(i==1 || i == 11)
1481 m_table[i].transparent=1; 1460 m_table[i].transparent=1;
1482 colorMenu->setItemChecked(cm_default,TRUE); 1461 colorMenu->setItemChecked(cm_default,TRUE);
1483 } 1462 }
1484 te->setColorTable(m_table); 1463 te->setColorTable(m_table);
1485 } 1464 }
1486 if(iD==cm_gb) 1465 if(iD==cm_gb)
1487 { // green black 1466 { // green black
1488 foreground.setRgb(100,255,100); // (0x18,255,0x18); 1467 foreground.setRgb(100,255,100); // (0x18,255,0x18);
1489 background.setRgb(0x00,0x00,0x00); 1468 background.setRgb(0x00,0x00,0x00);
1490 colorMenu->setItemChecked(cm_gb,TRUE); 1469 colorMenu->setItemChecked(cm_gb,TRUE);
1491 } 1470 }
1492 if(iD==cm_bw) 1471 if(iD==cm_bw)
1493 { // black white 1472 { // black white
1494 foreground.setRgb(0x00,0x00,0x00); 1473 foreground.setRgb(0x00,0x00,0x00);
1495 background.setRgb(0xFF,0xFF,0xFF); 1474 background.setRgb(0xFF,0xFF,0xFF);
1496 colorMenu->setItemChecked(cm_bw,TRUE); 1475 colorMenu->setItemChecked(cm_bw,TRUE);
1497 } 1476 }
1498 if(iD==cm_wb) 1477 if(iD==cm_wb)
1499 { // white black 1478 { // white black
1500 foreground.setRgb(0xFF,0xFF,0xFF); 1479 foreground.setRgb(0xFF,0xFF,0xFF);
1501 background.setRgb(0x00,0x00,0x00); 1480 background.setRgb(0x00,0x00,0x00);
1502 colorMenu->setItemChecked(cm_wb,TRUE); 1481 colorMenu->setItemChecked(cm_wb,TRUE);
1503 } 1482 }
1504 if(iD==cm_br) 1483 if(iD==cm_br)
1505 {// Black, Red 1484 {// Black, Red
1506 foreground.setRgb(0x00,0x00,0x00); 1485 foreground.setRgb(0x00,0x00,0x00);
1507 background.setRgb(255,85,85); //(0xB2,0x18,0x18); 1486 background.setRgb(255,85,85); //(0xB2,0x18,0x18);
1508 colorMenu->setItemChecked(cm_br,TRUE); 1487 colorMenu->setItemChecked(cm_br,TRUE);
1509 } 1488 }
1510 if(iD==cm_rb) 1489 if(iD==cm_rb)
1511 {// Red, Black 1490 {// Red, Black
1512 foreground.setRgb(255,85,85); 1491 foreground.setRgb(255,85,85);
1513 background.setRgb(0x00,0x00,0x00); 1492 background.setRgb(0x00,0x00,0x00);
1514 colorMenu->setItemChecked(cm_rb,TRUE); 1493 colorMenu->setItemChecked(cm_rb,TRUE);
1515 } 1494 }
1516 if(iD==cm_gy) 1495 if(iD==cm_gy)
1517 {// Green, Yellow - is ugly 1496 {// Green, Yellow - is ugly
1518 // foreground.setRgb(0x18,0xB2,0x18); 1497 // foreground.setRgb(0x18,0xB2,0x18);
1519 foreground.setRgb(15,115,0); 1498 foreground.setRgb(15,115,0);
1520 // background.setRgb(0xB2,0x68,0x18); 1499 // background.setRgb(0xB2,0x68,0x18);
1521 background.setRgb(255,255,0); 1500 background.setRgb(255,255,0);
1522 colorMenu->setItemChecked(cm_gy,TRUE); 1501 colorMenu->setItemChecked(cm_gy,TRUE);
1523 } 1502 }
1524 if(iD==cm_bm) 1503 if(iD==cm_bm)
1525 {// Blue, Magenta 1504 {// Blue, Magenta
1526 foreground.setRgb(3,24,132); 1505 foreground.setRgb(3,24,132);
1527 background.setRgb(225,2,255); 1506 background.setRgb(225,2,255);
1528 colorMenu->setItemChecked(cm_bm,TRUE); 1507 colorMenu->setItemChecked(cm_bm,TRUE);
1529 } 1508 }
1530 if(iD==cm_mb) 1509 if(iD==cm_mb)
1531 {// Magenta, Blue 1510 {// Magenta, Blue
1532 foreground.setRgb(225,2,255); 1511 foreground.setRgb(225,2,255);
1533 background.setRgb(3,24,132); 1512 background.setRgb(3,24,132);
1534 colorMenu->setItemChecked(cm_mb,TRUE); 1513 colorMenu->setItemChecked(cm_mb,TRUE);
1535 } 1514 }
1536 if(iD==cm_cw) 1515 if(iD==cm_cw)
1537 {// Cyan, White 1516 {// Cyan, White
1538 foreground.setRgb(8,91,129); 1517 foreground.setRgb(8,91,129);
1539 background.setRgb(0xFF,0xFF,0xFF); 1518 background.setRgb(0xFF,0xFF,0xFF);
1540 colorMenu->setItemChecked(cm_cw,TRUE); 1519 colorMenu->setItemChecked(cm_cw,TRUE);
1541 } 1520 }
1542 if(iD==cm_wc) 1521 if(iD==cm_wc)
1543 {// White, Cyan 1522 {// White, Cyan
1544 background.setRgb(8,91,129); 1523 background.setRgb(8,91,129);
1545 foreground.setRgb(0xFF,0xFF,0xFF); 1524 foreground.setRgb(0xFF,0xFF,0xFF);
1546 colorMenu->setItemChecked(cm_wc,TRUE); 1525 colorMenu->setItemChecked(cm_wc,TRUE);
1547 } 1526 }
1548 if(iD==cm_bb) 1527 if(iD==cm_bb)
1549 {// Black, Blue 1528 {// Black, Blue
1550 background.setRgb(0x00,0x00,0x00); 1529 background.setRgb(0x00,0x00,0x00);
1551 foreground.setRgb(127,147,225); 1530 foreground.setRgb(127,147,225);
1552 colorMenu->setItemChecked(cm_bb,TRUE); 1531 colorMenu->setItemChecked(cm_bb,TRUE);
1553 } 1532 }
1554 if(iD==cm_ab) 1533 if(iD==cm_ab)
1555 {// Black, Gold 1534 {// Black, Gold
1556 background.setRgb(0x00,0x00,0x00); 1535 background.setRgb(0x00,0x00,0x00);
1557 foreground.setRgb(255,215,105); 1536 foreground.setRgb(255,215,105);
1558 colorMenu->setItemChecked(cm_ab,TRUE); 1537 colorMenu->setItemChecked(cm_ab,TRUE);
1559 } 1538 }
1560#ifdef QT_QWS_OPIE 1539#ifdef QT_QWS_OPIE
1561 if(iD==-19) 1540 if(iD==-19)
1562 { 1541 {
1563 // Custom 1542 // Custom
1564 qDebug("do custom"); 1543 qDebug("do custom");
1565 if(fromMenu) 1544 if(fromMenu)
1566 { 1545 {
1567 Opie::OColorPopupMenu* penColorPopupMenu = new Opie::OColorPopupMenu(Qt::black, this, "foreground color"); 1546 Opie::OColorPopupMenu* penColorPopupMenu = new Opie::OColorPopupMenu(Qt::black, this, "foreground color");
1568 connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, 1547 connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this,
1569 SLOT(changeForegroundColor(const QColor&))); 1548 SLOT(changeForegroundColor(const QColor&)));
1570 penColorPopupMenu->exec(); 1549 penColorPopupMenu->exec();
1571 } 1550 }
1572 if(!fromMenu) 1551 if(!fromMenu)
1573 { 1552 {
1574 foreground.setNamedColor(cfg.readEntry("foreground","")); 1553 foreground.setNamedColor(cfg.readEntry("foreground",""));
1575 background.setNamedColor(cfg.readEntry("background","")); 1554 background.setNamedColor(cfg.readEntry("background",""));
1576 } 1555 }
1577 fromMenu=FALSE; 1556 fromMenu=FALSE;
1578 colorMenu->setItemChecked(-19,TRUE); 1557 colorMenu->setItemChecked(-19,TRUE);
1579 } 1558 }
1580#endif 1559#endif
1581 1560
1582 lastSelectedMenu = iD; 1561 lastSelectedMenu = iD;
1583 1562
1584 setColors(foreground, background); 1563 setColors(foreground, background);
1585 1564
1586 QTabBar *tabBar = tab->getTabBar(); 1565 QTabBar *tabBar = tab->getTabBar();
1587 QString ss = QString("Session%1").arg(tabBar->currentTab()); 1566 QString ss = QString("Session%1").arg(tabBar->currentTab());
1588 // printf("current tab = %d\n", tabBar->currentTab()); 1567 // printf("current tab = %d\n", tabBar->currentTab());
1589 1568
1590 if (tabBar->currentTab() == 0) 1569 if (tabBar->currentTab() == 0)
1591 { 1570 {
1592 cfg.writeEntry("foregroundRed",QString::number(foreground.red())); 1571 cfg.writeEntry("foregroundRed",QString::number(foreground.red()));
1593 cfg.writeEntry("foregroundGreen",QString::number(foreground.green())); 1572 cfg.writeEntry("foregroundGreen",QString::number(foreground.green()));
1594 cfg.writeEntry("foregroundBlue",QString::number(foreground.blue())); 1573 cfg.writeEntry("foregroundBlue",QString::number(foreground.blue()));
1595 cfg.writeEntry("backgroundRed",QString::number(background.red())); 1574 cfg.writeEntry("backgroundRed",QString::number(background.red()));
1596 cfg.writeEntry("backgroundGreen",QString::number(background.green())); 1575 cfg.writeEntry("backgroundGreen",QString::number(background.green()));
1597 cfg.writeEntry("backgroundBlue",QString::number(background.blue())); 1576 cfg.writeEntry("backgroundBlue",QString::number(background.blue()));
1598 } 1577 }
1599 cfg.writeEntry("foregroundRed"+ss,QString::number(foreground.red())); 1578 cfg.writeEntry("foregroundRed"+ss,QString::number(foreground.red()));
1600 cfg.writeEntry("foregroundGreen"+ss,QString::number(foreground.green())); 1579 cfg.writeEntry("foregroundGreen"+ss,QString::number(foreground.green()));
1601 cfg.writeEntry("foregroundBlue"+ss,QString::number(foreground.blue())); 1580 cfg.writeEntry("foregroundBlue"+ss,QString::number(foreground.blue()));
1602 cfg.writeEntry("backgroundRed"+ss,QString::number(background.red())); 1581 cfg.writeEntry("backgroundRed"+ss,QString::number(background.red()));
1603 cfg.writeEntry("backgroundGreen"+ss,QString::number(background.green())); 1582 cfg.writeEntry("backgroundGreen"+ss,QString::number(background.green()));
1604 cfg.writeEntry("backgroundBlue"+ss,QString::number(background.blue())); 1583 cfg.writeEntry("backgroundBlue"+ss,QString::number(background.blue()));
1605 1584
1606 update(); 1585 update();
1607} 1586}
1608 1587
1609void Konsole::setColors(QColor foreground, QColor background) 1588void Konsole::setColors(QColor foreground, QColor background)
1610{ 1589{
1611 int i; 1590 int i;
1612 ColorEntry m_table[TABLE_COLORS]; 1591 ColorEntry m_table[TABLE_COLORS];
1613 TEWidget* te = getTe(); 1592 TEWidget* te = getTe();
1614 const ColorEntry * defaultCt=te->getdefaultColorTable(); 1593 const ColorEntry * defaultCt=te->getdefaultColorTable();
1615 1594
1616 for (i = 0; i < TABLE_COLORS; i++) 1595 for (i = 0; i < TABLE_COLORS; i++)
1617 { 1596 {
1618 if(i==0 || i == 10) 1597 if(i==0 || i == 10)
1619 { 1598 {
1620 m_table[i].color = foreground; 1599 m_table[i].color = foreground;
1621 } 1600 }
1622 else if(i==1 || i == 11) 1601 else if(i==1 || i == 11)
1623 { 1602 {
1624 m_table[i].color = background; 1603 m_table[i].color = background;
1625 m_table[i].transparent=0; 1604 m_table[i].transparent=0;
1626 } 1605 }
1627 else 1606 else
1628 m_table[i].color = defaultCt[i].color; 1607 m_table[i].color = defaultCt[i].color;
1629 } 1608 }
1630 te->setColorTable(m_table); 1609 te->setColorTable(m_table);
1631} 1610}
1632 1611
1633void Konsole::tabMenuSelected(int id) 1612void Konsole::tabMenuSelected(int id)
1634{ 1613{
1635 Config cfg( "Konsole" ); 1614 Config cfg( "Konsole" );
1636 cfg.setGroup("Tabs"); 1615 cfg.setGroup("Tabs");
1637 tabMenu->setItemChecked(tabPos, false); 1616 tabMenu->setItemChecked(tabPos, false);
1638 if (id == tm_bottom) 1617 if (id == tm_bottom)
1639 { 1618 {
1640 printf("set bottom tab\n"); 1619 printf("set bottom tab\n");
1641 tab->getTabBar()->show(); 1620 tab->getTabBar()->show();
1642 tab->setTabPosition(QTabWidget::Bottom); 1621 tab->setTabPosition(QTabWidget::Bottom);
1643 tab->getTabBar()->show(); 1622 tab->getTabBar()->show();
1644 cfg.writeEntry("Position","Bottom"); 1623 cfg.writeEntry("Position","Bottom");
1645 } 1624 }
1646 else if (id == tm_top) 1625 else if (id == tm_top)
1647 { 1626 {
1648 printf("set top tab\n"); 1627 printf("set top tab\n");
1649 tab->getTabBar()->show(); 1628 tab->getTabBar()->show();
1650 tab->setTabPosition(QTabWidget::Bottom); 1629 tab->setTabPosition(QTabWidget::Bottom);
1651 tab->setTabPosition(QTabWidget::Top); 1630 tab->setTabPosition(QTabWidget::Top);
1652 tab->getTabBar()->show(); 1631 tab->getTabBar()->show();
1653 cfg.writeEntry("Position","Top"); 1632 cfg.writeEntry("Position","Top");
1654 } 1633 }
1655 else if (id == tm_hidden) 1634 else if (id == tm_hidden)
1656 { 1635 {
1657 tab->getTabBar()->hide(); 1636 tab->getTabBar()->hide();
1658 tab->setMargin(tab->margin()); 1637 tab->setMargin(tab->margin());
1659 cfg.writeEntry("Position","Hidden"); 1638 cfg.writeEntry("Position","Hidden");
1660 } 1639 }
1661 tabMenu->setItemChecked(id, true); 1640 tabMenu->setItemChecked(id, true);
1662 tabPos = id; 1641 tabPos = id;
1663} 1642}
1664 1643
1665 1644
1666void Konsole::configMenuSelected(int iD) 1645void Konsole::configMenuSelected(int iD)
1667{ 1646{
1668 // QString temp; 1647 // QString temp;
1669 // qDebug( temp.sprintf("configmenu %d",iD)); 1648 // qDebug( temp.sprintf("configmenu %d",iD));
1670 1649
1671 TEWidget* te = getTe(); 1650 TEWidget* te = getTe();
1672 Config cfg( "Konsole" ); 1651 Config cfg( "Konsole" );
1673 cfg.setGroup("Menubar"); 1652 cfg.setGroup("Menubar");
1674 if(iD == cm_wrap) 1653 if(iD == cm_wrap)
1675 { 1654 {
1676 cfg.setGroup("ScrollBar"); 1655 cfg.setGroup("ScrollBar");
1677 bool b=cfg.readBoolEntry("HorzScroll",0); 1656 bool b=cfg.readBoolEntry("HorzScroll",0);
1678 b=!b; 1657 b=!b;
1679 cfg.writeEntry("HorzScroll", b ); 1658 cfg.writeEntry("HorzScroll", b );
1680 cfg.write(); 1659 cfg.write();
1681 doWrap(); 1660 doWrap();
1682 if(cfg.readNumEntry("Position",2) == 0) 1661 if(cfg.readNumEntry("Position",2) == 0)
1683 { 1662 {
1684 te->setScrollbarLocation(1); 1663 te->setScrollbarLocation(1);
1685 } 1664 }
1686 else 1665 else
1687 { 1666 {
1688 te->setScrollbarLocation(0); 1667 te->setScrollbarLocation(0);
1689 } 1668 }
1690 te->setScrollbarLocation( cfg.readNumEntry("Position",2)); 1669 te->setScrollbarLocation( cfg.readNumEntry("Position",2));
1691 } 1670 }
1692 if(iD == cm_beep) 1671 if(iD == cm_beep)
1693 { 1672 {
1694 cfg.setGroup("Menubar"); 1673 cfg.setGroup("Menubar");
1695 bool b=cfg.readBoolEntry("useBeep",0); 1674 bool b=cfg.readBoolEntry("useBeep",0);
1696 b=!b; 1675 b=!b;
1697 cfg.writeEntry("useBeep", b ); 1676 cfg.writeEntry("useBeep", b );
1698 cfg.write(); 1677 cfg.write();
1699 configMenu->setItemChecked(cm_beep,b); 1678 configMenu->setItemChecked(cm_beep,b);
1700 te->useBeep=b; 1679 te->useBeep=b;
1701 } 1680 }
1702} 1681}
1703 1682
1704void Konsole::changeCommand(const QString &text, int c) 1683void Konsole::changeCommand(const QString &text, int c)
1705{ 1684{
1706 Config cfg( "Konsole" ); 1685 Config cfg( "Konsole" );
1707 cfg.setGroup("Commands"); 1686 cfg.setGroup("Commands");
1708 if(commonCmds[c] != text) 1687 if(commonCmds[c] != text)
1709 { 1688 {
1710 cfg.writeEntry(QString::number(c),text); 1689 cfg.writeEntry(QString::number(c),text);
1711 commonCombo->clearEdit(); 1690 commonCombo->clearEdit();
1712 commonCombo->setCurrentItem(c); 1691 commonCombo->setCurrentItem(c);
1713 } 1692 }
1714} 1693}
1715 1694
1716void Konsole::setColor(int sess) 1695void Konsole::setColor(int sess)
1717{ 1696{
1718 Config cfg( "Konsole" ); 1697 Config cfg( "Konsole" );
1719 cfg.setGroup("Colors"); 1698 cfg.setGroup("Colors");
1720 QColor foreground, background; 1699 QColor foreground, background;
1721 QString ss = QString("Session") + QString::number(sess); 1700 QString ss = QString("Session") + QString::number(sess);
1722 foreground.setRgb(cfg.readNumEntry("foregroundRed"+ss, 1701 foreground.setRgb(cfg.readNumEntry("foregroundRed"+ss,
1723 cfg.readNumEntry("foregroundRed",0xff)), 1702 cfg.readNumEntry("foregroundRed",0xff)),
1724 cfg.readNumEntry("foregroundGreen"+ss, 1703 cfg.readNumEntry("foregroundGreen"+ss,
1725 cfg.readNumEntry("foregroundGreen",0xff)), 1704 cfg.readNumEntry("foregroundGreen",0xff)),
1726 cfg.readNumEntry("foregroundBlue"+ss, 1705 cfg.readNumEntry("foregroundBlue"+ss,
1727 cfg.readNumEntry("foregroundBlue",0xff))); 1706 cfg.readNumEntry("foregroundBlue",0xff)));
1728 background.setRgb(cfg.readNumEntry("backgroundRed"+ss, 1707 background.setRgb(cfg.readNumEntry("backgroundRed"+ss,
1729 cfg.readNumEntry("backgroundRed",0)), 1708 cfg.readNumEntry("backgroundRed",0)),
1730 cfg.readNumEntry("backgroundGreen"+ss, 1709 cfg.readNumEntry("backgroundGreen"+ss,
1731 cfg.readNumEntry("backgroundGreen",0)), 1710 cfg.readNumEntry("backgroundGreen",0)),
1732 cfg.readNumEntry("backgroundBlue"+ss, 1711 cfg.readNumEntry("backgroundBlue"+ss,
1733 cfg.readNumEntry("backgroundBlue",0))); 1712 cfg.readNumEntry("backgroundBlue",0)));
1734 setColors(foreground, background); 1713 setColors(foreground, background);
1735} 1714}
1736 1715
1737void Konsole::scrollMenuSelected(int index) 1716void Konsole::scrollMenuSelected(int index)
1738{ 1717{
1739 // qDebug( "scrollbar menu %d",index); 1718 // qDebug( "scrollbar menu %d",index);
1740 1719
1741 TEWidget* te = getTe(); 1720 TEWidget* te = getTe();
1742 Config cfg( "Konsole" ); 1721 Config cfg( "Konsole" );
1743 cfg.setGroup("ScrollBar"); 1722 cfg.setGroup("ScrollBar");
1744 1723
1745 if(index == sm_none) 1724 if(index == sm_none)
1746 { 1725 {
1747 te->setScrollbarLocation(0); 1726 te->setScrollbarLocation(0);
1748 cfg.writeEntry("Position",0); 1727 cfg.writeEntry("Position",0);
1749 } 1728 }
1750 else if(index == sm_left) 1729 else if(index == sm_left)
1751 { 1730 {
1752 te->setScrollbarLocation(1); 1731 te->setScrollbarLocation(1);
1753 cfg.writeEntry("Position",1); 1732 cfg.writeEntry("Position",1);
1754 } 1733 }
1755 else if(index == sm_right) 1734 else if(index == sm_right)
1756 { 1735 {
1757 te->setScrollbarLocation(2); 1736 te->setScrollbarLocation(2);
1758 cfg.writeEntry("Position",2); 1737 cfg.writeEntry("Position",2);
1759 } 1738 }
1760 scrollMenu->setItemChecked(sm_none, index == sm_none); 1739 scrollMenu->setItemChecked(sm_none, index == sm_none);
1761 scrollMenu->setItemChecked(sm_left, index == sm_left); 1740 scrollMenu->setItemChecked(sm_left, index == sm_left);
1762 scrollMenu->setItemChecked(sm_right, index == sm_right); 1741 scrollMenu->setItemChecked(sm_right, index == sm_right);
1763} 1742}
1764 1743
1765// case -29: { 1744// case -29: {
1766// bool b=cfg.readBoolEntry("HorzScroll",0); 1745// bool b=cfg.readBoolEntry("HorzScroll",0);
1767// cfg.writeEntry("HorzScroll", !b ); 1746// cfg.writeEntry("HorzScroll", !b );
1768// cfg.write(); 1747// cfg.write();
1769// if(cfg.readNumEntry("Position",2) == 0) { 1748// if(cfg.readNumEntry("Position",2) == 0) {
1770// te->setScrollbarLocation(1); 1749// te->setScrollbarLocation(1);
1771// te->setWrapAt(0); 1750// te->setWrapAt(0);
1772// } else { 1751// } else {
1773// te->setScrollbarLocation(0); 1752// te->setScrollbarLocation(0);
1774// te->setWrapAt(120); 1753// te->setWrapAt(120);
1775// } 1754// }
1776// te->setScrollbarLocation( cfg.readNumEntry("Position",2)); 1755// te->setScrollbarLocation( cfg.readNumEntry("Position",2));
1777// } 1756// }
1778// break; 1757// break;
1779 1758
1780void Konsole::editCommandListMenuSelected(int iD) 1759void Konsole::editCommandListMenuSelected(int iD)
1781{ 1760{
1782 // QString temp; 1761 // QString temp;
1783 // qDebug( temp.sprintf("edit command list %d",iD)); 1762 // qDebug( temp.sprintf("edit command list %d",iD));
1784 1763
1785 // FIXME: more cleanup needed here 1764 // FIXME: more cleanup needed here
1786 1765
1787 1766
1788 TEWidget* te = getTe(); 1767 TEWidget* te = getTe();
1789 Config cfg( "Konsole" ); 1768 Config cfg( "Konsole" );
1790 cfg.setGroup("Menubar"); 1769 cfg.setGroup("Menubar");
1791 if( iD == ec_cmdlist) 1770 if( iD == ec_cmdlist)
1792 { 1771 {
1793 if(!secondToolBar->isHidden()) 1772 if(!secondToolBar->isHidden())
1794 { 1773 {
1795 secondToolBar->hide(); 1774 secondToolBar->hide();
1796 configMenu->changeItem( iD,tr( "Show Command List" )); 1775 configMenu->changeItem( iD,tr( "Show Command List" ));
1797 cfg.writeEntry("Hidden","TRUE"); 1776 cfg.writeEntry("Hidden","TRUE");
1798 configMenu->setItemEnabled(ec_edit ,FALSE); 1777 configMenu->setItemEnabled(ec_edit ,FALSE);
1799 configMenu->setItemEnabled(ec_quick ,FALSE); 1778 configMenu->setItemEnabled(ec_quick ,FALSE);
1800 } 1779 }
1801 else 1780 else
1802 { 1781 {
1803 secondToolBar->show(); 1782 secondToolBar->show();
1804 configMenu->changeItem( iD,tr( "Hide Command List" )); 1783 configMenu->changeItem( iD,tr( "Hide Command List" ));
1805 cfg.writeEntry("Hidden","FALSE"); 1784 cfg.writeEntry("Hidden","FALSE");
1806 configMenu->setItemEnabled(ec_edit ,TRUE); 1785 configMenu->setItemEnabled(ec_edit ,TRUE);
1807 configMenu->setItemEnabled(ec_quick ,TRUE); 1786 configMenu->setItemEnabled(ec_quick ,TRUE);
1808 1787
1809 if(cfg.readEntry("EditEnabled","FALSE")=="TRUE") 1788 if(cfg.readEntry("EditEnabled","FALSE")=="TRUE")
1810 { 1789 {
1811 configMenu->setItemChecked(ec_edit,TRUE); 1790 configMenu->setItemChecked(ec_edit,TRUE);
1812 commonCombo->setEditable( TRUE ); 1791 commonCombo->setEditable( TRUE );
1813 } 1792 }
1814 else 1793 else
1815 { 1794 {
1816 configMenu->setItemChecked(ec_edit,FALSE); 1795 configMenu->setItemChecked(ec_edit,FALSE);
1817 commonCombo->setEditable( FALSE ); 1796 commonCombo->setEditable( FALSE );
1818 } 1797 }
1819 } 1798 }
1820 } 1799 }
1821 if( iD == ec_quick) 1800 if( iD == ec_quick)
1822 { 1801 {
1823 cfg.setGroup("Commands"); 1802 cfg.setGroup("Commands");
1824 // qDebug("enableCommandEdit"); 1803 // qDebug("enableCommandEdit");
1825 if( !configMenu->isItemChecked(iD) ) 1804 if( !configMenu->isItemChecked(iD) )
1826 { 1805 {
1827 commonCombo->setEditable( TRUE ); 1806 commonCombo->setEditable( TRUE );
1828 configMenu->setItemChecked(iD,TRUE); 1807 configMenu->setItemChecked(iD,TRUE);
1829 commonCombo->setCurrentItem(0); 1808 commonCombo->setCurrentItem(0);
1830 cfg.writeEntry("EditEnabled","TRUE"); 1809 cfg.writeEntry("EditEnabled","TRUE");
1831 } 1810 }
1832 else 1811 else
1833 { 1812 {
1834 commonCombo->setEditable( FALSE ); 1813 commonCombo->setEditable( FALSE );
1835 configMenu->setItemChecked(iD,FALSE); 1814 configMenu->setItemChecked(iD,FALSE);
1836 cfg.writeEntry("EditEnabled","FALSE"); 1815 cfg.writeEntry("EditEnabled","FALSE");
1837 commonCombo->setFocusPolicy(QWidget::NoFocus); 1816 commonCombo->setFocusPolicy(QWidget::NoFocus);
1838 te->setFocus(); 1817 te->setFocus();
1839 } 1818 }
1840 } 1819 }
1841 if(iD == ec_edit) 1820 if(iD == ec_edit)
1842 { 1821 {
1843 // "edit commands" 1822 // "edit commands"
1844 CommandEditDialog *m = new CommandEditDialog(this); 1823 CommandEditDialog *m = new CommandEditDialog(this);
1845 connect(m,SIGNAL(commandsEdited()),this,SLOT(initCommandList())); 1824 connect(m,SIGNAL(commandsEdited()),this,SLOT(initCommandList()));
1846 m->showMaximized(); 1825 m->showMaximized();
1847 } 1826 }
1848 1827
1849} 1828}
1850 1829
1851// $QPEDIR/bin/qcop QPE/Application/embeddedkonsole 'setDocument(QString)' 'ssh -V' 1830// $QPEDIR/bin/qcop QPE/Application/embeddedkonsole 'setDocument(QString)' 'ssh -V'
1852void Konsole::setDocument( const QString &cmd) 1831void Konsole::setDocument( const QString &cmd)
1853{ 1832{
1854 newSession(); 1833 newSession();
1855 TEWidget* te = getTe(); 1834 TEWidget* te = getTe();
1856 if(cmd.find("-e", 0, TRUE) != -1) 1835 if(cmd.find("-e", 0, TRUE) != -1)
1857 { 1836 {
1858 QString cmd2; 1837 QString cmd2;
1859 cmd2=cmd.right(cmd.length()-3)+" &"; 1838 cmd2=cmd.right(cmd.length()-3)+" &";
1860 system(cmd2.latin1()); 1839 system(cmd2.latin1());
1861 if(startUp <= 1 && nsessions < 2) 1840 if(startUp <= 1 && nsessions < 2)
1862 { 1841 {
1863 doneSession(getTe(), 0); 1842 doneSession(getTe(), 0);
1864 exit(0); 1843 exit(0);
1865 } 1844 }
1866 else 1845 else
1867 doneSession(getTe(), 0); 1846 doneSession(getTe(), 0);
1868 } 1847 }
1869 else 1848 else
1870 { 1849 {
1871 if (te != 0) 1850 if (te != 0)
1872 { 1851 {
1873 te->emitText(cmd+"\r"); 1852 te->emitText(cmd+"\r");
1874 } 1853 }
1875 } 1854 }
1876 startUp++; 1855 startUp++;
1877} 1856}
1878 1857
1879 1858
1880// what is the point of this when you can just 1859// what is the point of this when you can just
1881// run commands by using the shell directly?? 1860// run commands by using the shell directly??
1882void Konsole::parseCommandLine() 1861void Konsole::parseCommandLine()
1883{ 1862{
1884 QString cmd; 1863 QString cmd;
1885 // newSession(); 1864 // newSession();
1886 for (int i=1;i< qApp->argc();i++) 1865 for (int i=1;i< qApp->argc();i++)
1887 { 1866 {
1888 if( QString(qApp->argv()[i]) == "-e") 1867 if( QString(qApp->argv()[i]) == "-e")
1889 { 1868 {
1890 i++; 1869 i++;
1891 for ( int j=i;j< qApp->argc();j++) 1870 for ( int j=i;j< qApp->argc();j++)
1892 { 1871 {
1893 cmd+=QString(qApp->argv()[j])+" "; 1872 cmd+=QString(qApp->argv()[j])+" ";
1894 } 1873 }
1895 cmd.stripWhiteSpace(); 1874 cmd.stripWhiteSpace();
1896 system(cmd.latin1()); 1875 system(cmd.latin1());
1897 exit(0);//close(); 1876 exit(0);//close();
1898 } // end -e switch 1877 } // end -e switch
1899 } 1878 }
1900 startUp++; 1879 startUp++;
1901} 1880}
1902 1881
1903void Konsole::changeForegroundColor(const QColor &color) 1882void Konsole::changeForegroundColor(const QColor &color)
1904{ 1883{
1905 Config cfg( "Konsole" ); 1884 Config cfg( "Konsole" );
1906 cfg.setGroup("Colors"); 1885 cfg.setGroup("Colors");
1907 int r, g, b; 1886 int r, g, b;
1908 color.rgb(&r,&g,&b); 1887 color.rgb(&r,&g,&b);
1909 foreground.setRgb(r,g,b); 1888 foreground.setRgb(r,g,b);
1910 1889
1911 cfg.writeEntry("foreground",color.name()); 1890 cfg.writeEntry("foreground",color.name());
1912 qDebug("foreground "+color.name()); 1891 qDebug("foreground "+color.name());
1913 cfg.write(); 1892 cfg.write();
1914 1893
1915 qDebug("do other dialog"); 1894 qDebug("do other dialog");
1916#ifdef QT_QWS_OPIE 1895#ifdef QT_QWS_OPIE
1917 1896
1918 Opie::OColorPopupMenu* penColorPopupMenu2 = new Opie::OColorPopupMenu(Qt::black, this,"background color"); 1897 Opie::OColorPopupMenu* penColorPopupMenu2 = new Opie::OColorPopupMenu(Qt::black, this,"background color");
1919 connect(penColorPopupMenu2, SIGNAL(colorSelected(const QColor&)), this, 1898 connect(penColorPopupMenu2, SIGNAL(colorSelected(const QColor&)), this,
1920 SLOT(changeBackgroundColor(const QColor&))); 1899 SLOT(changeBackgroundColor(const QColor&)));
1921 penColorPopupMenu2->exec(); 1900 penColorPopupMenu2->exec();
1922#endif 1901#endif
1923} 1902}
1924 1903
1925void Konsole::changeBackgroundColor(const QColor &color) 1904void Konsole::changeBackgroundColor(const QColor &color)
1926{ 1905{
1927 1906
1928 qDebug("Change background"); 1907 qDebug("Change background");
1929 Config cfg( "Konsole" ); 1908 Config cfg( "Konsole" );
1930 cfg.setGroup("Colors"); 1909 cfg.setGroup("Colors");
1931 int r, g, b; 1910 int r, g, b;
1932 color.rgb(&r,&g,&b); 1911 color.rgb(&r,&g,&b);
1933 background.setRgb(r,g,b); 1912 background.setRgb(r,g,b);
1934 cfg.writeEntry("background",color.name()); 1913 cfg.writeEntry("background",color.name());
1935 qDebug("background "+color.name()); 1914 qDebug("background "+color.name());
1936 cfg.write(); 1915 cfg.write();
1937} 1916}
1938 1917
1939void Konsole::doWrap() 1918void Konsole::doWrap()
1940{ 1919{
1941 Config cfg( "Konsole" ); 1920 Config cfg( "Konsole" );
1942 cfg.setGroup("ScrollBar"); 1921 cfg.setGroup("ScrollBar");
1943 TEWidget* te = getTe(); 1922 TEWidget* te = getTe();
1944 if( !cfg.readBoolEntry("HorzScroll",0)) 1923 if( !cfg.readBoolEntry("HorzScroll",0))
1945 { 1924 {
1946 te->setWrapAt(0); 1925 te->setWrapAt(0);
1947 configMenu->setItemChecked( cm_wrap,TRUE); 1926 configMenu->setItemChecked( cm_wrap,TRUE);
1948 } 1927 }
1949 else 1928 else
1950 { 1929 {
1951 // te->setWrapAt(90); 1930 // te->setWrapAt(90);
1952 te->setWrapAt(120); 1931 te->setWrapAt(120);
1953 configMenu->setItemChecked( cm_wrap,FALSE); 1932 configMenu->setItemChecked( cm_wrap,FALSE);
1954 } 1933 }
1955} 1934}
diff --git a/core/apps/embeddedkonsole/playlistselection.cpp b/core/apps/embeddedkonsole/playlistselection.cpp
index 4dd3126..fc5330f 100644
--- a/core/apps/embeddedkonsole/playlistselection.cpp
+++ b/core/apps/embeddedkonsole/playlistselection.cpp
@@ -1,161 +1,154 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include <qpe/applnk.h>
21#include <qpe/resource.h>
22#include <qpainter.h>
23#include <qimage.h>
24#include <qheader.h> 20#include <qheader.h>
25#include <qlistview.h>
26#include <qlist.h>
27#include <qpixmap.h>
28 21
29#include "playlistselection.h" 22#include "playlistselection.h"
30 23
31#include <stdlib.h> 24#include <stdlib.h>
32 25
33 26
34 27
35 28
36 29
37PlayListSelection::PlayListSelection( QWidget *parent, const char *name ) 30PlayListSelection::PlayListSelection( QWidget *parent, const char *name )
38 : QListView( parent, name ) 31 : QListView( parent, name )
39{ 32{
40 setAllColumnsShowFocus( TRUE ); 33 setAllColumnsShowFocus( TRUE );
41 addColumn( tr( "Command Selection" ) ); 34 addColumn( tr( "Command Selection" ) );
42 header()->hide(); 35 header()->hide();
43 setSorting( -1, FALSE ); 36 setSorting( -1, FALSE );
44} 37}
45 38
46 39
47PlayListSelection::~PlayListSelection() { 40PlayListSelection::~PlayListSelection() {
48} 41}
49 42
50 43
51 44
52void PlayListSelection::contentsMouseMoveEvent( QMouseEvent *event ) { 45void PlayListSelection::contentsMouseMoveEvent( QMouseEvent *event ) {
53 if ( event->state() == QMouseEvent::LeftButton ) { 46 if ( event->state() == QMouseEvent::LeftButton ) {
54 QListViewItem *currentItem = selectedItem(); 47 QListViewItem *currentItem = selectedItem();
55 QListViewItem *itemUnder = itemAt( QPoint( event->pos().x(), event->pos().y() - contentsY() ) ); 48 QListViewItem *itemUnder = itemAt( QPoint( event->pos().x(), event->pos().y() - contentsY() ) );
56 if ( currentItem && currentItem->itemAbove() == itemUnder ) 49 if ( currentItem && currentItem->itemAbove() == itemUnder )
57 moveSelectedUp(); 50 moveSelectedUp();
58 else if ( currentItem && currentItem->itemBelow() == itemUnder ) 51 else if ( currentItem && currentItem->itemBelow() == itemUnder )
59 moveSelectedDown(); 52 moveSelectedDown();
60 } 53 }
61} 54}
62 55
63 56
64const QString *PlayListSelection::current() { 57const QString *PlayListSelection::current() {
65 PlayListSelectionItem *item = (PlayListSelectionItem *)selectedItem(); 58 PlayListSelectionItem *item = (PlayListSelectionItem *)selectedItem();
66 if ( item ) 59 if ( item )
67 return item->file(); 60 return item->file();
68 return NULL; 61 return NULL;
69} 62}
70 63
71 64
72void PlayListSelection::addToSelection( QListViewItem *lnk ) { 65void PlayListSelection::addToSelection( QListViewItem *lnk ) {
73PlayListSelectionItem *item = new PlayListSelectionItem( this, new QString( lnk->text(0) ) ); 66PlayListSelectionItem *item = new PlayListSelectionItem( this, new QString( lnk->text(0) ) );
74 QListViewItem *current = selectedItem(); 67 QListViewItem *current = selectedItem();
75 if ( current ) 68 if ( current )
76 item->moveItem( current ); 69 item->moveItem( current );
77 setSelected( item, TRUE ); 70 setSelected( item, TRUE );
78 ensureItemVisible( selectedItem() ); 71 ensureItemVisible( selectedItem() );
79} 72}
80 73
81void PlayListSelection::addStringToSelection (const QString & lnk) { 74void PlayListSelection::addStringToSelection (const QString & lnk) {
82 PlayListSelectionItem *item = new PlayListSelectionItem( this, new QString( lnk ) ); 75 PlayListSelectionItem *item = new PlayListSelectionItem( this, new QString( lnk ) );
83 QListViewItem *current = selectedItem(); 76 QListViewItem *current = selectedItem();
84 if ( current ) 77 if ( current )
85 item->moveItem( current ); 78 item->moveItem( current );
86 setSelected( item, TRUE ); 79 setSelected( item, TRUE );
87 ensureItemVisible( selectedItem() ); 80 ensureItemVisible( selectedItem() );
88 81
89} 82}
90void PlayListSelection::removeSelected() { 83void PlayListSelection::removeSelected() {
91 qDebug("removeSelected()"); 84 qDebug("removeSelected()");
92 QListViewItem *item = selectedItem(); 85 QListViewItem *item = selectedItem();
93 if ( item ) 86 if ( item )
94 delete item; 87 delete item;
95 setSelected( currentItem(), TRUE ); 88 setSelected( currentItem(), TRUE );
96 ensureItemVisible( selectedItem() ); 89 ensureItemVisible( selectedItem() );
97} 90}
98 91
99 92
100void PlayListSelection::moveSelectedUp() { 93void PlayListSelection::moveSelectedUp() {
101 QListViewItem *item = selectedItem(); 94 QListViewItem *item = selectedItem();
102 if ( item && item->itemAbove() ) 95 if ( item && item->itemAbove() )
103 item->itemAbove()->moveItem( item ); 96 item->itemAbove()->moveItem( item );
104 ensureItemVisible( selectedItem() ); 97 ensureItemVisible( selectedItem() );
105} 98}
106 99
107 100
108void PlayListSelection::moveSelectedDown() { 101void PlayListSelection::moveSelectedDown() {
109 QListViewItem *item = selectedItem(); 102 QListViewItem *item = selectedItem();
110 if ( item && item->itemBelow() ) 103 if ( item && item->itemBelow() )
111 item->moveItem( item->itemBelow() ); 104 item->moveItem( item->itemBelow() );
112 ensureItemVisible( selectedItem() ); 105 ensureItemVisible( selectedItem() );
113} 106}
114 107
115 108
116bool PlayListSelection::prev() { 109bool PlayListSelection::prev() {
117 QListViewItem *item = selectedItem(); 110 QListViewItem *item = selectedItem();
118 if ( item && item->itemAbove() ) 111 if ( item && item->itemAbove() )
119 setSelected( item->itemAbove(), TRUE ); 112 setSelected( item->itemAbove(), TRUE );
120 else 113 else
121 return FALSE; 114 return FALSE;
122 ensureItemVisible( selectedItem() ); 115 ensureItemVisible( selectedItem() );
123 return TRUE; 116 return TRUE;
124} 117}
125 118
126 119
127bool PlayListSelection::next() { 120bool PlayListSelection::next() {
128 QListViewItem *item = selectedItem(); 121 QListViewItem *item = selectedItem();
129 if ( item && item->itemBelow() ) 122 if ( item && item->itemBelow() )
130 setSelected( item->itemBelow(), TRUE ); 123 setSelected( item->itemBelow(), TRUE );
131 else 124 else
132 return FALSE; 125 return FALSE;
133 ensureItemVisible( selectedItem() ); 126 ensureItemVisible( selectedItem() );
134 return TRUE; 127 return TRUE;
135} 128}
136 129
137 130
138bool PlayListSelection::first() { 131bool PlayListSelection::first() {
139 QListViewItem *item = firstChild(); 132 QListViewItem *item = firstChild();
140 if ( item ) 133 if ( item )
141 setSelected( item, TRUE ); 134 setSelected( item, TRUE );
142 else 135 else
143 return FALSE; 136 return FALSE;
144 ensureItemVisible( selectedItem() ); 137 ensureItemVisible( selectedItem() );
145 return TRUE; 138 return TRUE;
146} 139}
147 140
148 141
149bool PlayListSelection::last() { 142bool PlayListSelection::last() {
150 QListViewItem *prevItem = NULL; 143 QListViewItem *prevItem = NULL;
151 QListViewItem *item = firstChild(); 144 QListViewItem *item = firstChild();
152 while ( ( item = item->nextSibling() ) ) 145 while ( ( item = item->nextSibling() ) )
153 prevItem = item; 146 prevItem = item;
154 if ( prevItem ) 147 if ( prevItem )
155 setSelected( prevItem, TRUE ); 148 setSelected( prevItem, TRUE );
156 else 149 else
157 return FALSE; 150 return FALSE;
158 ensureItemVisible( selectedItem() ); 151 ensureItemVisible( selectedItem() );
159 return TRUE; 152 return TRUE;
160} 153}
161 154
diff --git a/core/apps/embeddedkonsole/session.cpp b/core/apps/embeddedkonsole/session.cpp
index 17acb8c..043b8db 100644
--- a/core/apps/embeddedkonsole/session.cpp
+++ b/core/apps/embeddedkonsole/session.cpp
@@ -1,161 +1,160 @@
1/* -------------------------------------------------------------------------- */ 1/* -------------------------------------------------------------------------- */
2 /* */ 2 /* */
3/* Ported Konsole to Qt/Embedded */ 3/* Ported Konsole to Qt/Embedded */
4 /* */ 4 /* */
5/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ 5/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */
6 /* */ 6 /* */
7/* -------------------------------------------------------------------------- */ 7/* -------------------------------------------------------------------------- */
8#include "session.h" 8#include "session.h"
9#include <qpushbutton.h>
10// #include <kdebug.h> 9// #include <kdebug.h>
11 10
12#include <stdlib.h> 11#include <stdlib.h>
13 12
14#define HERE fprintf(stderr,"%s(%d): here\n",__FILE__,__LINE__) 13#define HERE fprintf(stderr,"%s(%d): here\n",__FILE__,__LINE__)
15 14
16/*! \class TESession 15/*! \class TESession
17 16
18 Sessions are combinations of TEPTy and Emulations. 17 Sessions are combinations of TEPTy and Emulations.
19 18
20 The stuff in here does not belong to the terminal emulation framework, 19 The stuff in here does not belong to the terminal emulation framework,
21 but to main.C. It serves it's duty by providing a single reference 20 but to main.C. It serves it's duty by providing a single reference
22 to TEPTy/Emulation pairs. In fact, it is only there to demonstrate one 21 to TEPTy/Emulation pairs. In fact, it is only there to demonstrate one
23 of the abilities of the framework - multible sessions. 22 of the abilities of the framework - multible sessions.
24*/ 23*/
25 24
26TESession::TESession(QMainWindow* main, TEWidget* _te, const char* _pgm, QStrList & _args, const char *_term) : schema_no(0), font_no(3), pgm(_pgm), args(_args) 25TESession::TESession(QMainWindow* main, TEWidget* _te, const char* _pgm, QStrList & _args, const char *_term) : schema_no(0), font_no(3), pgm(_pgm), args(_args)
27{ 26{
28 te = _te; 27 te = _te;
29 term = _term; 28 term = _term;
30 29
31 // sh = new TEPty(); 30 // sh = new TEPty();
32 sh = new MyPty(); 31 sh = new MyPty();
33 em = new TEmuVt102(te); 32 em = new TEmuVt102(te);
34 33
35 sh->setSize(te->Lines(),te->Columns()); // not absolutely nessesary 34 sh->setSize(te->Lines(),te->Columns()); // not absolutely nessesary
36 QObject::connect( sh,SIGNAL(block_in(const char*,int)), 35 QObject::connect( sh,SIGNAL(block_in(const char*,int)),
37 em,SLOT(onRcvBlock(const char*,int)) ); 36 em,SLOT(onRcvBlock(const char*,int)) );
38 QObject::connect( em,SIGNAL(ImageSizeChanged(int,int)), 37 QObject::connect( em,SIGNAL(ImageSizeChanged(int,int)),
39 sh,SLOT(setSize(int,int))); 38 sh,SLOT(setSize(int,int)));
40 39
41 // 'main' should do those connects itself, somehow. 40 // 'main' should do those connects itself, somehow.
42 // These aren't KTMW's slots, but konsole's.(David) 41 // These aren't KTMW's slots, but konsole's.(David)
43 42
44/* 43/*
45 QObject::connect( em,SIGNAL(ImageSizeChanged(int,int)), 44 QObject::connect( em,SIGNAL(ImageSizeChanged(int,int)),
46 main,SLOT(notifySize(int,int))); 45 main,SLOT(notifySize(int,int)));
47*/ 46*/
48 QObject::connect( em,SIGNAL(sndBlock(const char*,int)), 47 QObject::connect( em,SIGNAL(sndBlock(const char*,int)),
49 sh,SLOT(send_bytes(const char*,int)) ); 48 sh,SLOT(send_bytes(const char*,int)) );
50 QObject::connect( em,SIGNAL(changeColumns(int)), 49 QObject::connect( em,SIGNAL(changeColumns(int)),
51 main,SLOT(changeColumns(int)) ); 50 main,SLOT(changeColumns(int)) );
52 51
53 52
54 53
55 QObject::connect( em,SIGNAL(changeTitle(int, const QString&)), 54 QObject::connect( em,SIGNAL(changeTitle(int, const QString&)),
56 this,SLOT(changeTitle(int, const QString&)) ); 55 this,SLOT(changeTitle(int, const QString&)) );
57 56
58 QObject::connect( sh,SIGNAL(done(int)), this,SLOT(done(int)) ); 57 QObject::connect( sh,SIGNAL(done(int)), this,SLOT(done(int)) );
59} 58}
60 59
61 60
62 61
63void TESession::run() 62void TESession::run()
64{ 63{
65 //kdDebug() << "Running the session!" << pgm << "\n"; 64 //kdDebug() << "Running the session!" << pgm << "\n";
66 sh->run(pgm,args,term.data(),FALSE); 65 sh->run(pgm,args,term.data(),FALSE);
67} 66}
68 67
69void TESession::kill(int ) // signal) 68void TESession::kill(int ) // signal)
70{ 69{
71// sh->kill(signal); 70// sh->kill(signal);
72} 71}
73 72
74TESession::~TESession() 73TESession::~TESession()
75{ 74{
76 QObject::disconnect( sh, SIGNAL( done( int ) ), 75 QObject::disconnect( sh, SIGNAL( done( int ) ),
77 this, SLOT( done( int ) ) ); 76 this, SLOT( done( int ) ) );
78 delete em; 77 delete em;
79 delete sh; 78 delete sh;
80} 79}
81 80
82void TESession::setConnect(bool c) 81void TESession::setConnect(bool c)
83{ 82{
84 em->setConnect(c); 83 em->setConnect(c);
85} 84}
86 85
87void TESession::done(int status) 86void TESession::done(int status)
88{ 87{
89 emit done(te,status); 88 emit done(te,status);
90} 89}
91 90
92void TESession::terminate() 91void TESession::terminate()
93{ 92{
94 delete this; 93 delete this;
95} 94}
96 95
97TEmulation* TESession::getEmulation() 96TEmulation* TESession::getEmulation()
98{ 97{
99 return em; 98 return em;
100} 99}
101 100
102// following interfaces might be misplaced /// 101// following interfaces might be misplaced ///
103 102
104int TESession::schemaNo() 103int TESession::schemaNo()
105{ 104{
106 return schema_no; 105 return schema_no;
107} 106}
108 107
109int TESession::keymap() 108int TESession::keymap()
110{ 109{
111 return keymap_no; 110 return keymap_no;
112} 111}
113 112
114int TESession::fontNo() 113int TESession::fontNo()
115{ 114{
116 return font_no; 115 return font_no;
117} 116}
118 117
119const char* TESession::emuName() 118const char* TESession::emuName()
120{ 119{
121 return term.data(); 120 return term.data();
122} 121}
123 122
124void TESession::setSchemaNo(int sn) 123void TESession::setSchemaNo(int sn)
125{ 124{
126 schema_no = sn; 125 schema_no = sn;
127} 126}
128 127
129void TESession::setKeymapNo(int kn) 128void TESession::setKeymapNo(int kn)
130{ 129{
131 keymap_no = kn; 130 keymap_no = kn;
132 em->setKeytrans(kn); 131 em->setKeytrans(kn);
133} 132}
134 133
135void TESession::setFontNo(int fn) 134void TESession::setFontNo(int fn)
136{ 135{
137 font_no = fn; 136 font_no = fn;
138} 137}
139 138
140void TESession::changeTitle(int, const QString& title) 139void TESession::changeTitle(int, const QString& title)
141{ 140{
142 this->title = title; 141 this->title = title;
143 emit changeTitle(te, title); 142 emit changeTitle(te, title);
144} 143}
145 144
146const QString& TESession::Title() 145const QString& TESession::Title()
147{ 146{
148 return title; 147 return title;
149} 148}
150 149
151void TESession::setHistory(bool on) 150void TESession::setHistory(bool on)
152{ 151{
153 em->setHistory( on ); 152 em->setHistory( on );
154} 153}
155 154
156bool TESession::history() 155bool TESession::history()
157{ 156{
158 return em->history(); 157 return em->history();
159} 158}
160 159
161// #include "session.moc" 160// #include "session.moc"
diff --git a/core/apps/helpbrowser/helpbrowser.cpp b/core/apps/helpbrowser/helpbrowser.cpp
index 6f84ae2..8fb0161 100644
--- a/core/apps/helpbrowser/helpbrowser.cpp
+++ b/core/apps/helpbrowser/helpbrowser.cpp
@@ -1,250 +1,228 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#define QTOPIA_INTERNAL_LANGLIST 21#define QTOPIA_INTERNAL_LANGLIST
22 22
23#include "helpbrowser.h" 23#include "helpbrowser.h"
24 24
25#include <qpe/qpeapplication.h> 25#include <qpe/qpeapplication.h>
26#include <qpe/resource.h> 26#include <qpe/resource.h>
27#include <qpe/mimetype.h> 27
28#include <qpe/applnk.h>
29#include <qpe/global.h>
30
31#include <qstatusbar.h>
32#include <qdragobject.h>
33#include <qpixmap.h>
34#include <qpopupmenu.h>
35#include <qmenubar.h> 28#include <qmenubar.h>
36#include <qtoolbar.h> 29#include <qtoolbar.h>
37#include <qpe/qcopenvelope_qws.h> 30#include <qpe/qcopenvelope_qws.h>
38#include <qtoolbutton.h>
39#include <qiconset.h>
40#include <qfile.h>
41#include <qtextstream.h>
42#include <qstylesheet.h>
43#include <qmessagebox.h>
44#include <qfiledialog.h>
45#include <qevent.h>
46#include <qlineedit.h>
47#include <qobjectlist.h>
48#include <qfileinfo.h> 31#include <qfileinfo.h>
49#include <qfile.h>
50#include <qdatastream.h>
51#include <qprinter.h>
52#include <qsimplerichtext.h>
53#include <qpaintdevicemetrics.h>
54#include <qaction.h> 32#include <qaction.h>
55 33
56#include <cctype> 34#include <cctype>
57 35
58#include "magictextbrowser.h" 36#include "magictextbrowser.h"
59 37
60HelpBrowser::HelpBrowser( QWidget* parent, const char *name, WFlags f ) 38HelpBrowser::HelpBrowser( QWidget* parent, const char *name, WFlags f )
61 : QMainWindow( parent, name, f ), 39 : QMainWindow( parent, name, f ),
62 selectedURL() 40 selectedURL()
63{ 41{
64 init( "index.html" ); 42 init( "index.html" );
65} 43}
66 44
67 45
68 46
69void HelpBrowser::init( const QString& _home ) 47void HelpBrowser::init( const QString& _home )
70{ 48{
71 setIcon( Resource::loadPixmap( "HelpBrowser" ) ); 49 setIcon( Resource::loadPixmap( "HelpBrowser" ) );
72 setBackgroundMode( PaletteButton ); 50 setBackgroundMode( PaletteButton );
73 51
74 browser = new MagicTextBrowser( this ); 52 browser = new MagicTextBrowser( this );
75 browser->setFrameStyle( QFrame::Panel | QFrame::Sunken ); 53 browser->setFrameStyle( QFrame::Panel | QFrame::Sunken );
76 connect( browser, SIGNAL( textChanged() ), 54 connect( browser, SIGNAL( textChanged() ),
77 this, SLOT( textChanged() ) ); 55 this, SLOT( textChanged() ) );
78 56
79 setCentralWidget( browser ); 57 setCentralWidget( browser );
80 setToolBarsMovable( FALSE ); 58 setToolBarsMovable( FALSE );
81 59
82 if ( !_home.isEmpty() ) 60 if ( !_home.isEmpty() )
83 browser->setSource( _home ); 61 browser->setSource( _home );
84 62
85 QToolBar* toolbar = new QToolBar( this ); 63 QToolBar* toolbar = new QToolBar( this );
86 toolbar->setHorizontalStretchable( TRUE ); 64 toolbar->setHorizontalStretchable( TRUE );
87 QMenuBar *menu = new QMenuBar( toolbar ); 65 QMenuBar *menu = new QMenuBar( toolbar );
88 66
89 toolbar = new QToolBar( this ); 67 toolbar = new QToolBar( this );
90 // addToolBar( toolbar, "Toolbar"); 68 // addToolBar( toolbar, "Toolbar");
91 69
92 QPopupMenu* go = new QPopupMenu( this ); 70 QPopupMenu* go = new QPopupMenu( this );
93 backAction = new QAction( tr( "Backward" ), Resource::loadIconSet( "back" ), QString::null, 0, this, 0 ); 71 backAction = new QAction( tr( "Backward" ), Resource::loadIconSet( "back" ), QString::null, 0, this, 0 );
94 connect( backAction, SIGNAL( activated() ), browser, SLOT( backward() ) ); 72 connect( backAction, SIGNAL( activated() ), browser, SLOT( backward() ) );
95 connect( browser, SIGNAL( backwardAvailable( bool ) ), 73 connect( browser, SIGNAL( backwardAvailable( bool ) ),
96 backAction, SLOT( setEnabled( bool ) ) ); 74 backAction, SLOT( setEnabled( bool ) ) );
97 backAction->addTo( go ); 75 backAction->addTo( go );
98 backAction->addTo( toolbar ); 76 backAction->addTo( toolbar );
99 backAction->setEnabled( FALSE ); 77 backAction->setEnabled( FALSE );
100 78
101 forwardAction = new QAction( tr( "Forward" ), Resource::loadIconSet( "forward" ), QString::null, 0, this, 0 ); 79 forwardAction = new QAction( tr( "Forward" ), Resource::loadIconSet( "forward" ), QString::null, 0, this, 0 );
102 connect( forwardAction, SIGNAL( activated() ), browser, SLOT( forward() ) ); 80 connect( forwardAction, SIGNAL( activated() ), browser, SLOT( forward() ) );
103 connect( browser, SIGNAL( forwardAvailable( bool ) ), 81 connect( browser, SIGNAL( forwardAvailable( bool ) ),
104 forwardAction, SLOT( setEnabled( bool ) ) ); 82 forwardAction, SLOT( setEnabled( bool ) ) );
105 forwardAction->addTo( go ); 83 forwardAction->addTo( go );
106 forwardAction->addTo( toolbar ); 84 forwardAction->addTo( toolbar );
107 forwardAction->setEnabled( FALSE ); 85 forwardAction->setEnabled( FALSE );
108 86
109 QAction *a = new QAction( tr( "Home" ), Resource::loadIconSet( "home" ), QString::null, 0, this, 0 ); 87 QAction *a = new QAction( tr( "Home" ), Resource::loadIconSet( "home" ), QString::null, 0, this, 0 );
110 connect( a, SIGNAL( activated() ), browser, SLOT( home() ) ); 88 connect( a, SIGNAL( activated() ), browser, SLOT( home() ) );
111 a->addTo( go ); 89 a->addTo( go );
112 a->addTo( toolbar ); 90 a->addTo( toolbar );
113 91
114 bookm = new QPopupMenu( this ); 92 bookm = new QPopupMenu( this );
115 bookm->insertItem( tr( "Add Bookmark" ), this, SLOT( addBookmark() ) ); 93 bookm->insertItem( tr( "Add Bookmark" ), this, SLOT( addBookmark() ) );
116 bookm->insertItem( tr( "Remove from Bookmarks" ), this, SLOT( removeBookmark() ) ); 94 bookm->insertItem( tr( "Remove from Bookmarks" ), this, SLOT( removeBookmark() ) );
117 bookm->insertSeparator(); 95 bookm->insertSeparator();
118 connect( bookm, SIGNAL( activated( int ) ), 96 connect( bookm, SIGNAL( activated( int ) ),
119 this, SLOT( bookmChosen( int ) ) ); 97 this, SLOT( bookmChosen( int ) ) );
120 98
121 readBookmarks(); 99 readBookmarks();
122 100
123 menu->insertItem( tr("Go"), go ); 101 menu->insertItem( tr("Go"), go );
124 menu->insertItem( tr( "Bookmarks" ), bookm ); 102 menu->insertItem( tr( "Bookmarks" ), bookm );
125 103
126 resize( 240, 300 ); 104 resize( 240, 300 );
127 browser->setFocus(); 105 browser->setFocus();
128 browser->setFrameStyle( QFrame::NoFrame ); 106 browser->setFrameStyle( QFrame::NoFrame );
129 107
130#if !defined(QT_NO_COP) 108#if !defined(QT_NO_COP)
131 QCopChannel *addressChannel = new QCopChannel("QPE/HelpBrowser" , this ); 109 QCopChannel *addressChannel = new QCopChannel("QPE/HelpBrowser" , this );
132 connect (addressChannel, SIGNAL( received(const QCString &, const QByteArray &)), 110 connect (addressChannel, SIGNAL( received(const QCString &, const QByteArray &)),
133 this, SLOT ( appMessage(const QCString &, const QByteArray &) ) ); 111 this, SLOT ( appMessage(const QCString &, const QByteArray &) ) );
134#endif 112#endif
135 113
136 connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)), 114 connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)),
137 this, SLOT(appMessage(const QCString&, const QByteArray&)) ); 115 this, SLOT(appMessage(const QCString&, const QByteArray&)) );
138} 116}
139 117
140void HelpBrowser::appMessage(const QCString& msg, const QByteArray& data) 118void HelpBrowser::appMessage(const QCString& msg, const QByteArray& data)
141{ 119{
142 qDebug("reached appMessage"); 120 qDebug("reached appMessage");
143 if ( msg == "showFile(QString)" ) { 121 if ( msg == "showFile(QString)" ) {
144 QDataStream ds(data,IO_ReadOnly); 122 QDataStream ds(data,IO_ReadOnly);
145 QString fn; 123 QString fn;
146 ds >> fn; 124 ds >> fn;
147 setDocument( fn ); 125 setDocument( fn );
148 126
149 QPEApplication::setKeepRunning(); 127 QPEApplication::setKeepRunning();
150 128
151 showMaximized(); 129 showMaximized();
152 setActiveWindow(); 130 setActiveWindow();
153 raise(); 131 raise();
154 } 132 }
155} 133}
156 134
157void HelpBrowser::setDocument( const QString &doc ) 135void HelpBrowser::setDocument( const QString &doc )
158{ 136{
159 if ( !doc.isEmpty() ) 137 if ( !doc.isEmpty() )
160 browser->setSource( doc ); 138 browser->setSource( doc );
161 raise(); 139 raise();
162} 140}
163 141
164 142
165void HelpBrowser::textChanged() 143void HelpBrowser::textChanged()
166{ 144{
167 if ( browser->documentTitle().isNull() ) 145 if ( browser->documentTitle().isNull() )
168 setCaption( tr("Help Browser") ); 146 setCaption( tr("Help Browser") );
169 else 147 else
170 setCaption( browser->documentTitle() ) ; 148 setCaption( browser->documentTitle() ) ;
171 149
172 selectedURL = caption(); 150 selectedURL = caption();
173} 151}
174 152
175HelpBrowser::~HelpBrowser() 153HelpBrowser::~HelpBrowser()
176{ 154{
177 QStringList bookmarks; 155 QStringList bookmarks;
178 QMap<int, Bookmark>::Iterator it2 = mBookmarks.begin(); 156 QMap<int, Bookmark>::Iterator it2 = mBookmarks.begin();
179 for ( ; it2 != mBookmarks.end(); ++it2 ) 157 for ( ; it2 != mBookmarks.end(); ++it2 )
180 bookmarks.append( (*it2).name + "=" + (*it2).file ); 158 bookmarks.append( (*it2).name + "=" + (*it2).file );
181 159
182 QFile f2( Global::applicationFileName("helpbrowser", "bookmarks") ); 160 QFile f2( Global::applicationFileName("helpbrowser", "bookmarks") );
183 if ( f2.open( IO_WriteOnly ) ) { 161 if ( f2.open( IO_WriteOnly ) ) {
184 QDataStream s2( &f2 ); 162 QDataStream s2( &f2 );
185 s2 << bookmarks; 163 s2 << bookmarks;
186 f2.close(); 164 f2.close();
187 } 165 }
188} 166}
189 167
190void HelpBrowser::pathSelected( const QString &_path ) 168void HelpBrowser::pathSelected( const QString &_path )
191{ 169{
192 browser->setSource( _path ); 170 browser->setSource( _path );
193} 171}
194 172
195void HelpBrowser::readBookmarks() 173void HelpBrowser::readBookmarks()
196{ 174{
197 QString file = Global::applicationFileName("helpbrowser", "bookmarks"); 175 QString file = Global::applicationFileName("helpbrowser", "bookmarks");
198 if ( QFile::exists( file ) ) { 176 if ( QFile::exists( file ) ) {
199 QStringList bookmarks; 177 QStringList bookmarks;
200 QFile f( file ); 178 QFile f( file );
201 if ( f.open( IO_ReadOnly ) ) { 179 if ( f.open( IO_ReadOnly ) ) {
202 QDataStream s( &f ); 180 QDataStream s( &f );
203 s >> bookmarks; 181 s >> bookmarks;
204 f.close(); 182 f.close();
205 } 183 }
206 QStringList::Iterator it = bookmarks.begin(); 184 QStringList::Iterator it = bookmarks.begin();
207 for ( ; it != bookmarks.end(); ++it ) { 185 for ( ; it != bookmarks.end(); ++it ) {
208 Bookmark b; 186 Bookmark b;
209 QString current = *it; 187 QString current = *it;
210 int equal = current.find( "=" ); 188 int equal = current.find( "=" );
211 if ( equal < 1 || equal == (int)current.length() - 1 ) 189 if ( equal < 1 || equal == (int)current.length() - 1 )
212 continue; 190 continue;
213 b.name = current.left( equal ); 191 b.name = current.left( equal );
214 b.file = current.mid( equal + 1 ); 192 b.file = current.mid( equal + 1 );
215 mBookmarks[ bookm->insertItem( b.name ) ] = b; 193 mBookmarks[ bookm->insertItem( b.name ) ] = b;
216 } 194 }
217 } 195 }
218} 196}
219 197
220void HelpBrowser::bookmChosen( int i ) 198void HelpBrowser::bookmChosen( int i )
221{ 199{
222 if ( mBookmarks.contains( i ) ) 200 if ( mBookmarks.contains( i ) )
223 browser->setSource( mBookmarks[ i ].file ); 201 browser->setSource( mBookmarks[ i ].file );
224} 202}
225 203
226void HelpBrowser::addBookmark() 204void HelpBrowser::addBookmark()
227{ 205{
228 Bookmark b; 206 Bookmark b;
229 b.name = browser->documentTitle(); 207 b.name = browser->documentTitle();
230 b.file = browser->source(); 208 b.file = browser->source();
231 if (b.name.isEmpty() ) { 209 if (b.name.isEmpty() ) {
232 b.name = b.file.left( b.file.length() - 5 ); // remove .html 210 b.name = b.file.left( b.file.length() - 5 ); // remove .html
233 } 211 }
234 QMap<int, Bookmark>::Iterator it; 212 QMap<int, Bookmark>::Iterator it;
235 for( it = mBookmarks.begin(); it != mBookmarks.end(); ++it ) 213 for( it = mBookmarks.begin(); it != mBookmarks.end(); ++it )
236 if ( (*it).file == b.file ) return; 214 if ( (*it).file == b.file ) return;
237 mBookmarks[ bookm->insertItem( b.name ) ] = b; 215 mBookmarks[ bookm->insertItem( b.name ) ] = b;
238} 216}
239 217
240void HelpBrowser::removeBookmark() 218void HelpBrowser::removeBookmark()
241{ 219{
242 QString file = browser->source(); 220 QString file = browser->source();
243 QMap<int, Bookmark>::Iterator it = mBookmarks.begin(); 221 QMap<int, Bookmark>::Iterator it = mBookmarks.begin();
244 for( ; it != mBookmarks.end(); ++it ) 222 for( ; it != mBookmarks.end(); ++it )
245 if ( (*it).file == file ) { 223 if ( (*it).file == file ) {
246 bookm->removeItem( it.key() ); 224 bookm->removeItem( it.key() );
247 mBookmarks.remove( it ); 225 mBookmarks.remove( it );
248 break; 226 break;
249 } 227 }
250} 228}
diff --git a/core/apps/helpbrowser/magictextbrowser.cpp b/core/apps/helpbrowser/magictextbrowser.cpp
index 8ce0325..80495c9 100644
--- a/core/apps/helpbrowser/magictextbrowser.cpp
+++ b/core/apps/helpbrowser/magictextbrowser.cpp
@@ -1,99 +1,97 @@
1#include <qfile.h> 1#include <qfile.h>
2#include <qstring.h>
3#include <qdragobject.h> 2#include <qdragobject.h>
4#include <qregexp.h>
5 3
6/* need to get Global::helpPath() */ 4/* need to get Global::helpPath() */
7#define QTOPIA_INTERNAL_LANGLIST 5#define QTOPIA_INTERNAL_LANGLIST
8 6
9#include <qtopia/global.h> 7#include <qtopia/global.h>
10#include <qtopia/mimetype.h> 8#include <qtopia/mimetype.h>
11#include <qtopia/applnk.h> 9#include <qtopia/applnk.h>
12 10
13#include "magictextbrowser.h" 11#include "magictextbrowser.h"
14 12
15 13
16 14
17MagicTextBrowser::MagicTextBrowser(QWidget* parent) : 15MagicTextBrowser::MagicTextBrowser(QWidget* parent) :
18 QTextBrowser(parent){ 16 QTextBrowser(parent){
19} 17}
20 18
21void MagicTextBrowser::setSource( const QString& source ) { 19void MagicTextBrowser::setSource( const QString& source ) {
22 QTextBrowser::setSource(source); 20 QTextBrowser::setSource(source);
23 if ( magicQpe(source,"applications") || magicQpe(source,"games") || magicQpe(source,"settings") || magicQpe(source, "1Pim") ) // No tr 21 if ( magicQpe(source,"applications") || magicQpe(source,"games") || magicQpe(source,"settings") || magicQpe(source, "1Pim") ) // No tr
24 return; 22 return;
25 if ( magicOpe(source, "applets") || magicOpe(source, "input") ) 23 if ( magicOpe(source, "applets") || magicOpe(source, "input") )
26 return; 24 return;
27 // Just those are magic (for now). Could do CGI here, 25 // Just those are magic (for now). Could do CGI here,
28 // or in Qtopia's mime source factory. 26 // or in Qtopia's mime source factory.
29} 27}
30 28
31bool MagicTextBrowser::magicQpe(const QString& source, const QString& name) { 29bool MagicTextBrowser::magicQpe(const QString& source, const QString& name) {
32 if ( name+".html" == source || "help/"+name+".html" == source) { 30 if ( name+".html" == source || "help/"+name+".html" == source) {
33 QString fn = mimeSourceFactory()->makeAbsolute( source, context() ); 31 QString fn = mimeSourceFactory()->makeAbsolute( source, context() );
34 const QMimeSource* m = mimeSourceFactory()->data( fn, context() ); 32 const QMimeSource* m = mimeSourceFactory()->data( fn, context() );
35 if ( m ) { 33 if ( m ) {
36 QString txt; 34 QString txt;
37 if ( QTextDrag::decode(m,txt) ) { 35 if ( QTextDrag::decode(m,txt) ) {
38 QRegExp re("<qtopia-"+name+">.*</qtopia-"+name+">"); 36 QRegExp re("<qtopia-"+name+">.*</qtopia-"+name+">");
39 int start,len; 37 int start,len;
40 if ( (start=re.match(txt,0,&len))>=0 ) { 38 if ( (start=re.match(txt,0,&len))>=0 ) {
41 QString generated = generateQpe(name); 39 QString generated = generateQpe(name);
42 txt.replace(start,len,generated); 40 txt.replace(start,len,generated);
43 setText(txt); 41 setText(txt);
44 return true; 42 return true;
45 } 43 }
46 } 44 }
47 } 45 }
48 } 46 }
49 return false; 47 return false;
50} 48}
51bool MagicTextBrowser::magicOpe( const QString& source, const QString& name ) { 49bool MagicTextBrowser::magicOpe( const QString& source, const QString& name ) {
52 if ( name+".html" != source && "help/"+name+".html" != source) return false; 50 if ( name+".html" != source && "help/"+name+".html" != source) return false;
53 51
54 QString fn = mimeSourceFactory()->makeAbsolute( source, context() ); 52 QString fn = mimeSourceFactory()->makeAbsolute( source, context() );
55 const QMimeSource* m = mimeSourceFactory()->data(fn, context() ); 53 const QMimeSource* m = mimeSourceFactory()->data(fn, context() );
56 if (!m) return false; 54 if (!m) return false;
57 55
58 QString txt; 56 QString txt;
59 if ( !QTextDrag::decode(m, txt ) ) return false; 57 if ( !QTextDrag::decode(m, txt ) ) return false;
60 58
61 QRegExp re("<opie-"+name+">.*</opie-"+name+">"); 59 QRegExp re("<opie-"+name+">.*</opie-"+name+">");
62 int start,len; 60 int start,len;
63 if ( (start=re.match(txt,0,&len))>=0 ) { 61 if ( (start=re.match(txt,0,&len))>=0 ) {
64 QString generated = generateOpe(name); 62 QString generated = generateOpe(name);
65 txt.replace(start,len,generated); 63 txt.replace(start,len,generated);
66 setText(txt); 64 setText(txt);
67 return true; 65 return true;
68 } 66 }
69 return false; 67 return false;
70} 68}
71QString MagicTextBrowser::generateOpe(const QString& name)const { 69QString MagicTextBrowser::generateOpe(const QString& name)const {
72 if ( name == QString::fromLatin1("applets") ) { 70 if ( name == QString::fromLatin1("applets") ) {
73 return QString::fromLatin1("<h3>No Applets found</h3>"); 71 return QString::fromLatin1("<h3>No Applets found</h3>");
74 }else if ( name == QString::fromLatin1("input") ) { 72 }else if ( name == QString::fromLatin1("input") ) {
75 return QString::fromLatin1("<h3>No input methods available</h3>"); 73 return QString::fromLatin1("<h3>No input methods available</h3>");
76 }else 74 }else
77 return QString::null; 75 return QString::null;
78} 76}
79 77
80QString MagicTextBrowser::generateQpe(const QString& name) const { 78QString MagicTextBrowser::generateQpe(const QString& name) const {
81 QString dir = MimeType::appsFolderName()+"/"+name[0].upper()+name.mid(1); 79 QString dir = MimeType::appsFolderName()+"/"+name[0].upper()+name.mid(1);
82 AppLnkSet lnkset(dir); 80 AppLnkSet lnkset(dir);
83 AppLnk* lnk; 81 AppLnk* lnk;
84 QString r; 82 QString r;
85 for (QListIterator<AppLnk> it(lnkset.children()); (lnk=it.current()); ++it) { 83 for (QListIterator<AppLnk> it(lnkset.children()); (lnk=it.current()); ++it) {
86 QString name = lnk->name(); 84 QString name = lnk->name();
87 QString icon = lnk->icon(); 85 QString icon = lnk->icon();
88 QString helpFile = lnk->exec()+".html"; 86 QString helpFile = lnk->exec()+".html";
89 QStringList helpPath = Global::helpPath(); 87 QStringList helpPath = Global::helpPath();
90 bool helpExists = FALSE; 88 bool helpExists = FALSE;
91 for (QStringList::ConstIterator it=helpPath.begin(); it!=helpPath.end() && !helpExists; ++it) 89 for (QStringList::ConstIterator it=helpPath.begin(); it!=helpPath.end() && !helpExists; ++it)
92 helpExists = QFile::exists( *it + "/" + helpFile ); 90 helpExists = QFile::exists( *it + "/" + helpFile );
93 91
94 if ( helpExists ) { 92 if ( helpExists ) {
95 r += "<h3><a href="+helpFile+"><img src="+icon+">"+name+"</a></h3>\n"; 93 r += "<h3><a href="+helpFile+"><img src="+icon+">"+name+"</a></h3>\n";
96 } 94 }
97 } 95 }
98 return r; 96 return r;
99} 97}
diff --git a/core/apps/oapp/oappplugin.cpp b/core/apps/oapp/oappplugin.cpp
index 934594f..82cc59b 100644
--- a/core/apps/oapp/oappplugin.cpp
+++ b/core/apps/oapp/oappplugin.cpp
@@ -1,43 +1,40 @@
1#include "oappinterface.h"
2#include "oappplugin.h" 1#include "oappplugin.h"
3#include <qlist.h>
4#include <qwidget.h> 2#include <qwidget.h>
5#include <qpe/quuid.h>
6 3
7OAppPlugin::OAppPlugin(OAppPos pos) 4OAppPlugin::OAppPlugin(OAppPos pos)
8{ 5{
9 m_position = pos; 6 m_position = pos;
10}; 7};
11 8
12OAppPlugin::OAppPlugin(QWidget *widget, OAppPos pos) 9OAppPlugin::OAppPlugin(QWidget *widget, OAppPos pos)
13{ 10{
14 m_widgets.append( widget ); 11 m_widgets.append( widget );
15 m_position = pos; 12 m_position = pos;
16}; 13};
17 14
18OAppPlugin::~OAppPlugin() 15OAppPlugin::~OAppPlugin()
19{ 16{
20}; 17};
21 18
22QList<QWidget> OAppPlugin::widgets() 19QList<QWidget> OAppPlugin::widgets()
23{ 20{
24 return m_widgets; 21 return m_widgets;
25}; 22};
26 23
27OAppPos OAppPlugin::position() const 24OAppPos OAppPlugin::position() const
28{ 25{
29 return m_position; 26 return m_position;
30} 27}
31 28
32QRESULT OAppPlugin::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) 29QRESULT OAppPlugin::queryInterface( const QUuid &uuid, QUnknownInterface **iface )
33{ 30{
34 *iface = 0; 31 *iface = 0;
35 if ( uuid == IID_QUnknown ) 32 if ( uuid == IID_QUnknown )
36 *iface = this; 33 *iface = this;
37 else if ( uuid == IID_OAppInterface ) 34 else if ( uuid == IID_OAppInterface )
38 *iface = this; 35 *iface = this;
39 36
40 if ( *iface ) 37 if ( *iface )
41 (*iface)->addRef(); 38 (*iface)->addRef();
42 return QS_OK; 39 return QS_OK;
43} 40}
diff --git a/core/apps/qcop/main.cpp b/core/apps/qcop/main.cpp
index 73db0f6..9306cbf 100644
--- a/core/apps/qcop/main.cpp
+++ b/core/apps/qcop/main.cpp
@@ -1,85 +1,83 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include <qpe/qcopenvelope_qws.h> 21#include <qpe/qcopenvelope_qws.h>
22 22
23#include <qapplication.h> 23#include <qapplication.h>
24#include <qstringlist.h>
25#include <qdatastream.h>
26#include <qtimer.h> 24#include <qtimer.h>
27 25
28#include <stdlib.h> 26#include <stdlib.h>
29#include <stdio.h> 27#include <stdio.h>
30 28
31static void usage() 29static void usage()
32{ 30{
33 fprintf( stderr, "Usage: qcop channel command [parameters]\n" ); 31 fprintf( stderr, "Usage: qcop channel command [parameters]\n" );
34} 32}
35 33
36static void syntax( const QString &where, const QString &what ) 34static void syntax( const QString &where, const QString &what )
37{ 35{
38 fprintf( stderr, "Syntax error in %s: %s\n", where.latin1(), what.latin1() ); 36 fprintf( stderr, "Syntax error in %s: %s\n", where.latin1(), what.latin1() );
39 exit(1); 37 exit(1);
40} 38}
41 39
42int main( int argc, char *argv[] ) 40int main( int argc, char *argv[] )
43{ 41{
44 QApplication app( argc, argv ); 42 QApplication app( argc, argv );
45 43
46 if ( argc < 3 ) { 44 if ( argc < 3 ) {
47 usage(); 45 usage();
48 exit(1); 46 exit(1);
49 } 47 }
50 48
51 QString channel = argv[1]; 49 QString channel = argv[1];
52 QString command = argv[2]; 50 QString command = argv[2];
53 command.stripWhiteSpace(); 51 command.stripWhiteSpace();
54 52
55 int paren = command.find( "(" ); 53 int paren = command.find( "(" );
56 if ( paren <= 0 ) 54 if ( paren <= 0 )
57 syntax( "command", command ); 55 syntax( "command", command );
58 56
59 QString params = command.mid( paren + 1 ); 57 QString params = command.mid( paren + 1 );
60 if ( params[params.length()-1] != ')' ) 58 if ( params[params.length()-1] != ')' )
61 syntax( "command", command ); 59 syntax( "command", command );
62 60
63 params.truncate( params.length()-1 ); 61 params.truncate( params.length()-1 );
64 QCopEnvelope env(channel.latin1(), command.latin1()); 62 QCopEnvelope env(channel.latin1(), command.latin1());
65 63
66 int argIdx = 3; 64 int argIdx = 3;
67 65
68 QStringList paramList = QStringList::split( ",", params ); 66 QStringList paramList = QStringList::split( ",", params );
69 QStringList::Iterator it; 67 QStringList::Iterator it;
70 for ( it = paramList.begin(); it != paramList.end(); ++it ) { 68 for ( it = paramList.begin(); it != paramList.end(); ++it ) {
71 QString arg = argv[argIdx]; 69 QString arg = argv[argIdx];
72 if ( *it == "QString" ) { 70 if ( *it == "QString" ) {
73 env << arg; 71 env << arg;
74 } else if ( *it == "int" ) { 72 } else if ( *it == "int" ) {
75 env << arg.toInt(); 73 env << arg.toInt();
76 } else { 74 } else {
77 syntax( "paramter type", *it ); 75 syntax( "paramter type", *it );
78 } 76 }
79 argIdx++; 77 argIdx++;
80 } 78 }
81 79
82 QTimer::singleShot( 0, &app, SLOT(quit()) ); 80 QTimer::singleShot( 0, &app, SLOT(quit()) );
83 return app.exec(); 81 return app.exec();
84} 82}
85 83
diff --git a/core/apps/taboapp/main.cpp b/core/apps/taboapp/main.cpp
index 4b9451e..b2703ff 100644
--- a/core/apps/taboapp/main.cpp
+++ b/core/apps/taboapp/main.cpp
@@ -1,54 +1,53 @@
1#include <qdir.h> 1#include <qdir.h>
2 2
3#include <qpe/global.h>
4#include <qpe/qpeapplication.h> 3#include <qpe/qpeapplication.h>
5#include <qpe/qlibrary.h> 4#include <qpe/qlibrary.h>
6#include <oappinterface.h> 5#include <oappinterface.h>
7#include <oappplugin.h> 6#include <oappplugin.h>
8 7
9#include <opie2/otabwidget.h> 8#include <opie2/otabwidget.h>
10 9
11int main( int argc, char **argv ) 10int main( int argc, char **argv )
12{ 11{
13 QPEApplication a( argc, argv ); 12 QPEApplication a( argc, argv );
14 13
15 OTabWidget *tabwidget = new OTabWidget(0, "tab widget"); 14 OTabWidget *tabwidget = new OTabWidget(0, "tab widget");
16 15
17 QString path = QPEApplication::qpeDir() + "/plugins/app"; 16 QString path = QPEApplication::qpeDir() + "/plugins/app";
18 QDir dir( path, "lib*.so" ); 17 QDir dir( path, "lib*.so" );
19 18
20 QStringList list = dir.entryList(); 19 QStringList list = dir.entryList();
21 QStringList::Iterator it; 20 QStringList::Iterator it;
22 21
23 QInterfacePtr<OAppInterface> iface; 22 QInterfacePtr<OAppInterface> iface;
24 for ( it = list.begin(); it != list.end(); ++it ) { 23 for ( it = list.begin(); it != list.end(); ++it ) {
25 QLibrary *lib = new QLibrary( path + "/" + *it ); 24 QLibrary *lib = new QLibrary( path + "/" + *it );
26 25
27 qDebug( "querying: %s", QString( path + "/" + *it ).latin1() ); 26 qDebug( "querying: %s", QString( path + "/" + *it ).latin1() );
28 if ( lib->queryInterface( IID_OAppInterface, (QUnknownInterface**)&iface ) == QS_OK ) { 27 if ( lib->queryInterface( IID_OAppInterface, (QUnknownInterface**)&iface ) == QS_OK ) {
29 qDebug( "accepted: %s", QString( path + "/" + *it ).latin1() ); 28 qDebug( "accepted: %s", QString( path + "/" + *it ).latin1() );
30 29
31 QList<QWidget> list = iface->widgets(); 30 QList<QWidget> list = iface->widgets();
32 QWidget *widget; 31 QWidget *widget;
33 for ( widget = list.first(); widget != 0; widget = list.next() ) 32 for ( widget = list.first(); widget != 0; widget = list.next() )
34 tabwidget->addTab(widget, QString(*it), QString(*it)); 33 tabwidget->addTab(widget, QString(*it), QString(*it));
35 34
36 QString lang = getenv( "LANG" ); 35 QString lang = getenv( "LANG" );
37 if (lang.isNull()) 36 if (lang.isNull())
38 lang = "en"; 37 lang = "en";
39 QTranslator *trans = new QTranslator(qApp); 38 QTranslator *trans = new QTranslator(qApp);
40 QString type = (*it).left( (*it).find(".") ); 39 QString type = (*it).left( (*it).find(".") );
41 if (type.left(3) == "lib") 40 if (type.left(3) == "lib")
42 type = type.mid(3); 41 type = type.mid(3);
43 type = type.right( type.find("lib") ); 42 type = type.right( type.find("lib") );
44 QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm"; 43 QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm";
45 if ( trans->load( tfn )) 44 if ( trans->load( tfn ))
46 qApp->installTranslator( trans ); 45 qApp->installTranslator( trans );
47 else 46 else
48 delete trans; 47 delete trans;
49 } 48 }
50 } 49 }
51 50
52 a.showMainDocumentWidget(tabwidget); 51 a.showMainDocumentWidget(tabwidget);
53 return a.exec(); 52 return a.exec();
54} 53}
diff --git a/core/apps/textedit/filePermissions.cpp b/core/apps/textedit/filePermissions.cpp
index f1c78a1..db353a9 100644
--- a/core/apps/textedit/filePermissions.cpp
+++ b/core/apps/textedit/filePermissions.cpp
@@ -1,274 +1,270 @@
1/**************************************************************************** 1/****************************************************************************
2** copyright 2002 ljp ljp@llornkcor.com 2** copyright 2002 ljp ljp@llornkcor.com
3** Created: Sat Feb 23 19:44:40 2002 L.J. Potter 3** Created: Sat Feb 23 19:44:40 2002 L.J. Potter
4** 4**
5** This file may be distributed and/or modified under the terms of the 5** This file may be distributed and/or modified under the terms of the
6** GNU General Public License version 2 as published by the Free Software 6** GNU General Public License version 2 as published by the Free Software
7** Foundation and appearing in the file LICENSE.GPL included in the 7** Foundation and appearing in the file LICENSE.GPL included in the
8** packaging of this file. 8** packaging of this file.
9** 9**
10** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 10** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
11** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 11** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
12** 12**
13****************************************************************************/ 13****************************************************************************/
14#include "filePermissions.h" 14#include "filePermissions.h"
15 15
16#include <qfile.h>
17#include <qfileinfo.h> 16#include <qfileinfo.h>
18 17
19#include <qcheckbox.h> 18#include <qcheckbox.h>
20#include <qlabel.h> 19#include <qlabel.h>
21#include <qlineedit.h> 20#include <qlineedit.h>
22#include <qlayout.h>
23#include <qvariant.h>
24#include <qtooltip.h>
25#include <qmessagebox.h> 21#include <qmessagebox.h>
26 22
27#include <unistd.h> 23#include <unistd.h>
28#include <sys/stat.h> 24#include <sys/stat.h>
29#include <stdlib.h> 25#include <stdlib.h>
30#include <sys/types.h> 26#include <sys/types.h>
31#include <pwd.h> 27#include <pwd.h>
32#include <grp.h> 28#include <grp.h>
33 29
34filePermissions::filePermissions( QWidget* parent, const char* name, bool modal, WFlags fl, const QString &fileName ) 30filePermissions::filePermissions( QWidget* parent, const char* name, bool modal, WFlags fl, const QString &fileName )
35 : QDialog( parent, name, modal, fl ) 31 : QDialog( parent, name, modal, fl )
36{ 32{
37 if ( !name ) 33 if ( !name )
38 setName( tr("File Permissions") ); 34 setName( tr("File Permissions") );
39// qDebug("FilePermissions "+fileName); 35// qDebug("FilePermissions "+fileName);
40 resize( 236, 210 ); 36 resize( 236, 210 );
41 setMaximumSize( QSize( 236, 210 ) ); 37 setMaximumSize( QSize( 236, 210 ) );
42 setCaption( tr( "Set File Permissions" ) ); 38 setCaption( tr( "Set File Permissions" ) );
43 39
44 TextLabel1 = new QLabel( this, "TextLabel1" ); 40 TextLabel1 = new QLabel( this, "TextLabel1" );
45 TextLabel1->setGeometry( QRect( 25, 5, 175, 20 ) ); 41 TextLabel1->setGeometry( QRect( 25, 5, 175, 20 ) );
46 TextLabel1->setText( tr( "Set file permissions for:" ) ); 42 TextLabel1->setText( tr( "Set file permissions for:" ) );
47 43
48 LineEdit1 = new QLineEdit( this, "LineEdit1" ); 44 LineEdit1 = new QLineEdit( this, "LineEdit1" );
49 LineEdit1->setGeometry( QRect( 10, 25, 218, 22 ) ); 45 LineEdit1->setGeometry( QRect( 10, 25, 218, 22 ) );
50 LineEdit1->setReadOnly(true); 46 LineEdit1->setReadOnly(true);
51 47
52 TextLabel4 = new QLabel( this, "TextLabel4" ); 48 TextLabel4 = new QLabel( this, "TextLabel4" );
53 TextLabel4->setGeometry( QRect( 5, 85, 50, 15 ) ); 49 TextLabel4->setGeometry( QRect( 5, 85, 50, 15 ) );
54 TextLabel4->setText( tr( "owner" ) ); 50 TextLabel4->setText( tr( "owner" ) );
55 51
56 TextLabel4_2 = new QLabel( this, "TextLabel4_2" ); 52 TextLabel4_2 = new QLabel( this, "TextLabel4_2" );
57 TextLabel4_2->setGeometry( QRect( 5, 105, 50, 15 ) ); 53 TextLabel4_2->setGeometry( QRect( 5, 105, 50, 15 ) );
58 TextLabel4_2->setText( tr( "group" ) ); 54 TextLabel4_2->setText( tr( "group" ) );
59 55
60 TextLabel4_3 = new QLabel( this, "TextLabel4_3" ); 56 TextLabel4_3 = new QLabel( this, "TextLabel4_3" );
61 TextLabel4_3->setGeometry( QRect( 5, 125, 50, 15 ) ); 57 TextLabel4_3->setGeometry( QRect( 5, 125, 50, 15 ) );
62 TextLabel4_3->setText( tr( "others" ) ); 58 TextLabel4_3->setText( tr( "others" ) );
63 59
64 CheckBox1 = new QCheckBox( this, "CheckBox1" ); 60 CheckBox1 = new QCheckBox( this, "CheckBox1" );
65 CheckBox1->setGeometry( QRect( 75, 85, 20, 16 ) ); 61 CheckBox1->setGeometry( QRect( 75, 85, 20, 16 ) );
66 connect(CheckBox1, SIGNAL(released()),this,SLOT(ownReadCheck())); 62 connect(CheckBox1, SIGNAL(released()),this,SLOT(ownReadCheck()));
67 63
68 CheckBox1_2 = new QCheckBox( this, "CheckBox1_2" ); 64 CheckBox1_2 = new QCheckBox( this, "CheckBox1_2" );
69 CheckBox1_2->setGeometry( QRect( 135, 85, 20, 16 ) ); 65 CheckBox1_2->setGeometry( QRect( 135, 85, 20, 16 ) );
70 connect(CheckBox1_2, SIGNAL(released()),this,SLOT(ownWriteCheck())); 66 connect(CheckBox1_2, SIGNAL(released()),this,SLOT(ownWriteCheck()));
71 67
72 CheckBox1_3 = new QCheckBox( this, "CheckBox1_3" ); 68 CheckBox1_3 = new QCheckBox( this, "CheckBox1_3" );
73 CheckBox1_3->setGeometry( QRect( 195, 85, 20, 16 ) ); 69 CheckBox1_3->setGeometry( QRect( 195, 85, 20, 16 ) );
74 connect(CheckBox1_3, SIGNAL(released()),this,SLOT(ownExeCheck())); 70 connect(CheckBox1_3, SIGNAL(released()),this,SLOT(ownExeCheck()));
75 71
76 CheckBox1_4 = new QCheckBox( this, "CheckBox1_4" ); 72 CheckBox1_4 = new QCheckBox( this, "CheckBox1_4" );
77 CheckBox1_4->setGeometry( QRect( 75, 105, 20, 16 ) ); 73 CheckBox1_4->setGeometry( QRect( 75, 105, 20, 16 ) );
78 connect(CheckBox1_4, SIGNAL(released()),this,SLOT(grpReadCheck())); 74 connect(CheckBox1_4, SIGNAL(released()),this,SLOT(grpReadCheck()));
79 75
80 CheckBox1_5 = new QCheckBox( this, "CheckBox1_5" ); 76 CheckBox1_5 = new QCheckBox( this, "CheckBox1_5" );
81 CheckBox1_5->setGeometry( QRect( 135, 105, 20, 16 ) ); 77 CheckBox1_5->setGeometry( QRect( 135, 105, 20, 16 ) );
82 connect(CheckBox1_5, SIGNAL(released()),this,SLOT(grpWriteCheck())); 78 connect(CheckBox1_5, SIGNAL(released()),this,SLOT(grpWriteCheck()));
83 79
84 CheckBox1_6 = new QCheckBox( this, "CheckBox1_6" ); 80 CheckBox1_6 = new QCheckBox( this, "CheckBox1_6" );
85 CheckBox1_6->setGeometry( QRect( 195, 105, 20, 16 ) ); 81 CheckBox1_6->setGeometry( QRect( 195, 105, 20, 16 ) );
86 connect(CheckBox1_6, SIGNAL(released()),this,SLOT(grpExeCheck())); 82 connect(CheckBox1_6, SIGNAL(released()),this,SLOT(grpExeCheck()));
87 83
88 CheckBox1_7 = new QCheckBox( this, "CheckBox1_7" ); 84 CheckBox1_7 = new QCheckBox( this, "CheckBox1_7" );
89 CheckBox1_7->setGeometry( QRect( 75, 125, 16, 16 ) ); 85 CheckBox1_7->setGeometry( QRect( 75, 125, 16, 16 ) );
90 connect(CheckBox1_7, SIGNAL(released()),this,SLOT(wrldReadCheck())); 86 connect(CheckBox1_7, SIGNAL(released()),this,SLOT(wrldReadCheck()));
91 87
92 CheckBox1_8 = new QCheckBox( this, "CheckBox1_8" ); 88 CheckBox1_8 = new QCheckBox( this, "CheckBox1_8" );
93 CheckBox1_8->setGeometry( QRect( 135, 125, 20, 16 ) ); 89 CheckBox1_8->setGeometry( QRect( 135, 125, 20, 16 ) );
94 connect(CheckBox1_8, SIGNAL(released()),this,SLOT(wrldWriteCheck())); 90 connect(CheckBox1_8, SIGNAL(released()),this,SLOT(wrldWriteCheck()));
95 91
96 CheckBox1_8_2 = new QCheckBox( this, "CheckBox1_8_2" ); 92 CheckBox1_8_2 = new QCheckBox( this, "CheckBox1_8_2" );
97 CheckBox1_8_2->setGeometry( QRect( 195, 125, 20, 16 ) ); 93 CheckBox1_8_2->setGeometry( QRect( 195, 125, 20, 16 ) );
98 connect(CheckBox1_8_2, SIGNAL(released()),this,SLOT(wrldExeCheck())); 94 connect(CheckBox1_8_2, SIGNAL(released()),this,SLOT(wrldExeCheck()));
99 95
100 GroupLineEdit = new QLineEdit( this, "GroupLineEdit" ); 96 GroupLineEdit = new QLineEdit( this, "GroupLineEdit" );
101 GroupLineEdit->setGeometry( QRect( 125, 155, 106, 22 ) ); 97 GroupLineEdit->setGeometry( QRect( 125, 155, 106, 22 ) );
102 98
103 OwnerLineEdit = new QLineEdit( this, "OwnerLineEdit" ); 99 OwnerLineEdit = new QLineEdit( this, "OwnerLineEdit" );
104 OwnerLineEdit->setGeometry( QRect( 10, 155, 106, 22 ) ); 100 OwnerLineEdit->setGeometry( QRect( 10, 155, 106, 22 ) );
105 101
106 TextLabel5 = new QLabel( this, "TextLabel5" ); 102 TextLabel5 = new QLabel( this, "TextLabel5" );
107 TextLabel5->setGeometry( QRect( 45, 180, 40, 16 ) ); 103 TextLabel5->setGeometry( QRect( 45, 180, 40, 16 ) );
108 TextLabel5->setText( tr( "Owner" ) ); 104 TextLabel5->setText( tr( "Owner" ) );
109 105
110 TextLabel5_2 = new QLabel( this, "TextLabel5_2" ); 106 TextLabel5_2 = new QLabel( this, "TextLabel5_2" );
111 TextLabel5_2->setGeometry( QRect( 155, 180, 40, 16 ) ); 107 TextLabel5_2->setGeometry( QRect( 155, 180, 40, 16 ) );
112 TextLabel5_2->setText( tr( "Group" ) ); 108 TextLabel5_2->setText( tr( "Group" ) );
113 109
114 ModeLine = new QLineEdit( this, "TextLabelMode" ); 110 ModeLine = new QLineEdit( this, "TextLabelMode" );
115 ModeLine->setGeometry( QRect( 10, 60, 40, 15 ) ); 111 ModeLine->setGeometry( QRect( 10, 60, 40, 15 ) );
116 112
117 TextLabel3_2 = new QLabel( this, "TextLabel3_2" ); 113 TextLabel3_2 = new QLabel( this, "TextLabel3_2" );
118 TextLabel3_2->setGeometry( QRect( 60, 55, 50, 20 ) ); 114 TextLabel3_2->setGeometry( QRect( 60, 55, 50, 20 ) );
119 TextLabel3_2->setText( tr( "read" ) ); 115 TextLabel3_2->setText( tr( "read" ) );
120 TextLabel3_2->setAlignment( int( QLabel::AlignBottom | QLabel::AlignHCenter ) ); 116 TextLabel3_2->setAlignment( int( QLabel::AlignBottom | QLabel::AlignHCenter ) );
121 117
122 TextLabel3_2_2 = new QLabel( this, "TextLabel3_2_2" ); 118 TextLabel3_2_2 = new QLabel( this, "TextLabel3_2_2" );
123 TextLabel3_2_2->setGeometry( QRect( 120, 55, 50, 20 ) ); 119 TextLabel3_2_2->setGeometry( QRect( 120, 55, 50, 20 ) );
124 TextLabel3_2_2->setText( tr( "write" ) ); 120 TextLabel3_2_2->setText( tr( "write" ) );
125 TextLabel3_2_2->setAlignment( int( QLabel::AlignBottom | QLabel::AlignHCenter ) ); 121 TextLabel3_2_2->setAlignment( int( QLabel::AlignBottom | QLabel::AlignHCenter ) );
126 122
127 TextLabel3 = new QLabel( this, "TextLabel3" ); 123 TextLabel3 = new QLabel( this, "TextLabel3" );
128 TextLabel3->setGeometry( QRect( 180, 55, 50, 20 ) ); 124 TextLabel3->setGeometry( QRect( 180, 55, 50, 20 ) );
129 TextLabel3->setText( tr( "execute" ) ); 125 TextLabel3->setText( tr( "execute" ) );
130 TextLabel3->setAlignment( int( QLabel::AlignBottom | QLabel::AlignHCenter ) ); 126 TextLabel3->setAlignment( int( QLabel::AlignBottom | QLabel::AlignHCenter ) );
131 127
132 struct stat buf; 128 struct stat buf;
133 mode_t mode; 129 mode_t mode;
134 file = fileName; 130 file = fileName;
135 QFileInfo fi(file); 131 QFileInfo fi(file);
136 132
137 LineEdit1->setText( file); 133 LineEdit1->setText( file);
138 OwnerLineEdit->setText( fi.owner()); 134 OwnerLineEdit->setText( fi.owner());
139 GroupLineEdit->setText( fi.group()); 135 GroupLineEdit->setText( fi.group());
140 136
141 if( fi.permission( QFileInfo::ReadUser)) { CheckBox1->setChecked(true); } 137 if( fi.permission( QFileInfo::ReadUser)) { CheckBox1->setChecked(true); }
142 if( fi.permission( QFileInfo::WriteUser)) { CheckBox1_2->setChecked(true); } 138 if( fi.permission( QFileInfo::WriteUser)) { CheckBox1_2->setChecked(true); }
143 if( fi.permission( QFileInfo::ExeUser)) { CheckBox1_3->setChecked(true); } 139 if( fi.permission( QFileInfo::ExeUser)) { CheckBox1_3->setChecked(true); }
144 140
145 if( fi.permission( QFileInfo::ReadGroup)) { CheckBox1_4->setChecked(true); } 141 if( fi.permission( QFileInfo::ReadGroup)) { CheckBox1_4->setChecked(true); }
146 if( fi.permission( QFileInfo::WriteGroup)) { CheckBox1_5->setChecked(true); } 142 if( fi.permission( QFileInfo::WriteGroup)) { CheckBox1_5->setChecked(true); }
147 if( fi.permission( QFileInfo::ExeGroup)) { CheckBox1_6->setChecked(true); } 143 if( fi.permission( QFileInfo::ExeGroup)) { CheckBox1_6->setChecked(true); }
148 144
149 if( fi.permission( QFileInfo::ReadOther)) { CheckBox1_7->setChecked(true); } 145 if( fi.permission( QFileInfo::ReadOther)) { CheckBox1_7->setChecked(true); }
150 if( fi.permission( QFileInfo::WriteOther)) { CheckBox1_8->setChecked(true); } 146 if( fi.permission( QFileInfo::WriteOther)) { CheckBox1_8->setChecked(true); }
151 if( fi.permission( QFileInfo::ExeOther)) { CheckBox1_8_2->setChecked(true); } 147 if( fi.permission( QFileInfo::ExeOther)) { CheckBox1_8_2->setChecked(true); }
152 148
153 stat(file.latin1(), &buf); 149 stat(file.latin1(), &buf);
154 mode = buf.st_mode; 150 mode = buf.st_mode;
155 modeStr.sprintf("%#o", buf.st_mode & ~(S_IFMT) ); 151 modeStr.sprintf("%#o", buf.st_mode & ~(S_IFMT) );
156 ModeLine->setText(modeStr); 152 ModeLine->setText(modeStr);
157 bool ok; 153 bool ok;
158 i_mode = modeStr.toInt(&ok,10); 154 i_mode = modeStr.toInt(&ok,10);
159 155
160} 156}
161 157
162/* 158/*
163 * Destroys the object and frees any allocated resources 159 * Destroys the object and frees any allocated resources
164 */ 160 */
165filePermissions::~filePermissions() 161filePermissions::~filePermissions()
166{ 162{
167} 163}
168 164
169 165
170// might this be better as a callback routine??? 166// might this be better as a callback routine???
171void filePermissions::ownReadCheck() { 167void filePermissions::ownReadCheck() {
172 if(CheckBox1->isChecked()) { i_mode +=400; } 168 if(CheckBox1->isChecked()) { i_mode +=400; }
173 else i_mode -=400; 169 else i_mode -=400;
174 modeStr.sprintf("0%d",i_mode); 170 modeStr.sprintf("0%d",i_mode);
175 ModeLine->setText( modeStr); 171 ModeLine->setText( modeStr);
176// 0400 172// 0400
177} 173}
178 174
179void filePermissions::ownWriteCheck() { 175void filePermissions::ownWriteCheck() {
180 if(CheckBox1_2->isChecked()) { i_mode +=200; } 176 if(CheckBox1_2->isChecked()) { i_mode +=200; }
181 else i_mode -=200; 177 else i_mode -=200;
182 modeStr.sprintf("0%d",i_mode); 178 modeStr.sprintf("0%d",i_mode);
183 ModeLine->setText(modeStr); 179 ModeLine->setText(modeStr);
184// 0200 180// 0200
185} 181}
186 182
187void filePermissions::ownExeCheck() { 183void filePermissions::ownExeCheck() {
188 if(CheckBox1_3->isChecked()) { i_mode +=100; } 184 if(CheckBox1_3->isChecked()) { i_mode +=100; }
189 else i_mode -=100; 185 else i_mode -=100;
190 modeStr.sprintf("0%d",i_mode); 186 modeStr.sprintf("0%d",i_mode);
191 ModeLine->setText(modeStr); 187 ModeLine->setText(modeStr);
192// 0100 188// 0100
193} 189}
194 190
195void filePermissions::grpReadCheck() { 191void filePermissions::grpReadCheck() {
196 if(CheckBox1_4->isChecked()) { i_mode +=40; } 192 if(CheckBox1_4->isChecked()) { i_mode +=40; }
197 else i_mode -=40; 193 else i_mode -=40;
198 modeStr.sprintf("0%d",i_mode); 194 modeStr.sprintf("0%d",i_mode);
199 ModeLine->setText(modeStr); 195 ModeLine->setText(modeStr);
200// 0040 196// 0040
201} 197}
202 198
203void filePermissions::grpWriteCheck() { 199void filePermissions::grpWriteCheck() {
204 if(CheckBox1_5->isChecked()) { i_mode +=20; } 200 if(CheckBox1_5->isChecked()) { i_mode +=20; }
205 else i_mode -=20; 201 else i_mode -=20;
206 modeStr.sprintf("0%d",i_mode); 202 modeStr.sprintf("0%d",i_mode);
207 ModeLine->setText(modeStr); 203 ModeLine->setText(modeStr);
208// 0020 204// 0020
209} 205}
210 206
211void filePermissions::grpExeCheck() { 207void filePermissions::grpExeCheck() {
212 if(CheckBox1_6->isChecked()) { i_mode +=10; } 208 if(CheckBox1_6->isChecked()) { i_mode +=10; }
213 else i_mode -=10; 209 else i_mode -=10;
214 modeStr.sprintf("0%d",i_mode); 210 modeStr.sprintf("0%d",i_mode);
215 ModeLine->setText(modeStr); 211 ModeLine->setText(modeStr);
216// 0010 212// 0010
217} 213}
218 214
219void filePermissions::wrldReadCheck() { 215void filePermissions::wrldReadCheck() {
220 if(CheckBox1_7->isChecked()) { i_mode +=4; } 216 if(CheckBox1_7->isChecked()) { i_mode +=4; }
221 else i_mode -=4; 217 else i_mode -=4;
222 modeStr.sprintf("0%d",i_mode); 218 modeStr.sprintf("0%d",i_mode);
223 ModeLine->setText(modeStr); 219 ModeLine->setText(modeStr);
224// 0004 220// 0004
225} 221}
226 222
227void filePermissions::wrldWriteCheck() { 223void filePermissions::wrldWriteCheck() {
228 if(CheckBox1_8->isChecked()) { i_mode +=2; } 224 if(CheckBox1_8->isChecked()) { i_mode +=2; }
229 else i_mode -=2; 225 else i_mode -=2;
230 modeStr.sprintf("0%d",i_mode); 226 modeStr.sprintf("0%d",i_mode);
231 ModeLine->setText(modeStr); 227 ModeLine->setText(modeStr);
232// 0002 228// 0002
233} 229}
234 230
235void filePermissions::wrldExeCheck() { 231void filePermissions::wrldExeCheck() {
236 if(CheckBox1_8_2->isChecked()) { i_mode +=1; } 232 if(CheckBox1_8_2->isChecked()) { i_mode +=1; }
237 else i_mode -=1; 233 else i_mode -=1;
238 modeStr.sprintf("0%d",i_mode); 234 modeStr.sprintf("0%d",i_mode);
239 ModeLine->setText(modeStr); 235 ModeLine->setText(modeStr);
240// 0001 236// 0001
241} 237}
242 238
243void filePermissions::accept() { 239void filePermissions::accept() {
244 240
245 QFileInfo fi(file); 241 QFileInfo fi(file);
246 struct passwd *pwd=0; 242 struct passwd *pwd=0;
247 struct group *grp=0; 243 struct group *grp=0;
248 pwd = getpwnam(OwnerLineEdit->text().latin1() ); 244 pwd = getpwnam(OwnerLineEdit->text().latin1() );
249 if(pwd == NULL) { 245 if(pwd == NULL) {
250 perror("getpwnam"); 246 perror("getpwnam");
251 QMessageBox::warning(this,tr("Warning"),tr("Error- no user")); 247 QMessageBox::warning(this,tr("Warning"),tr("Error- no user"));
252 return; 248 return;
253 } else { 249 } else {
254 grp = getgrnam(GroupLineEdit->text().latin1()); 250 grp = getgrnam(GroupLineEdit->text().latin1());
255 if(grp==NULL) { 251 if(grp==NULL) {
256 perror("getgrnam"); 252 perror("getgrnam");
257 QMessageBox::warning(this,tr("Warning"),tr("Error- no group")); 253 QMessageBox::warning(this,tr("Warning"),tr("Error- no group"));
258 return; 254 return;
259 } 255 }
260 if( chown( file.latin1(), pwd->pw_uid, grp->gr_gid) <0) { 256 if( chown( file.latin1(), pwd->pw_uid, grp->gr_gid) <0) {
261 perror("chown"); 257 perror("chown");
262 QMessageBox::warning(this,tr("Warning"),tr("Error setting ownership or group")); 258 QMessageBox::warning(this,tr("Warning"),tr("Error setting ownership or group"));
263 return; 259 return;
264 } 260 }
265 bool ok; 261 bool ok;
266 uint moder = modeStr.toUInt(&ok,8); 262 uint moder = modeStr.toUInt(&ok,8);
267 if( chmod( file.latin1(), moder) < 0) { 263 if( chmod( file.latin1(), moder) < 0) {
268 perror("chmod"); 264 perror("chmod");
269 QMessageBox::warning(this,tr("Warning"),tr("Error setting mode")); 265 QMessageBox::warning(this,tr("Warning"),tr("Error setting mode"));
270 return; 266 return;
271 } 267 }
272 } 268 }
273 close(); 269 close();
274} 270}
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp
index 8e106bf..55725cc 100644
--- a/core/apps/textedit/textedit.cpp
+++ b/core/apps/textedit/textedit.cpp
@@ -1,1215 +1,1197 @@
1/********************************************************************** 1/**********************************************************************
2// textedit.cpp 2// textedit.cpp
3** Copyright (C) 2000 Trolltech AS. All rights reserved. 3** Copyright (C) 2000 Trolltech AS. All rights reserved.
4** 4**
5** This file is part of Opie Environment. 5** This file is part of Opie Environment.
6** 6**
7** This file may be distributed and/or modified under the terms of the 7** This file may be distributed and/or modified under the terms of the
8** GNU General Public License version 2 as published by the Free Software 8** GNU General Public License version 2 as published by the Free Software
9** Foundation and appearing in the file LICENSE.GPL included in the 9** Foundation and appearing in the file LICENSE.GPL included in the
10** packaging of this file. 10** packaging of this file.
11** 11**
12**********************************************************************/ 12**********************************************************************/
13// changes added by L. J. Potter Sun 02-17-2002 21:31:31 13// changes added by L. J. Potter Sun 02-17-2002 21:31:31
14#include "textedit.h" 14#include "textedit.h"
15#include "filePermissions.h" 15#include "filePermissions.h"
16 16
17 17
18#include <opie2/ofileselector.h> 18#include <opie2/ofileselector.h>
19#include <opie2/ofiledialog.h> 19#include <opie2/ofiledialog.h>
20#include <opie2/ofontselector.h> 20#include <opie2/ofontselector.h>
21 21
22#include <qpe/fontdatabase.h>
23#include <qpe/global.h>
24#include <qpe/fileselector.h>
25#include <qpe/applnk.h>
26#include <qpe/resource.h> 22#include <qpe/resource.h>
27#include <qpe/config.h> 23#include <qpe/config.h>
28#include <qpe/qpeapplication.h> 24#include <qpe/qpeapplication.h>
29#include <qmenubar.h> 25#include <qmenubar.h>
30#include <qtoolbar.h> 26#include <qtoolbar.h>
31#include <qpe/qcopenvelope_qws.h>
32 27
33#include <qpoint.h>
34#include <qtextstream.h> 28#include <qtextstream.h>
35#include <qdatetime.h>
36#include <qclipboard.h> 29#include <qclipboard.h>
37#include <qstringlist.h>
38#include <qaction.h> 30#include <qaction.h>
39#include <qcolordialog.h>
40#include <qfileinfo.h>
41#include <qlineedit.h> 31#include <qlineedit.h>
42#include <qmessagebox.h> 32#include <qmessagebox.h>
43#include <qobjectlist.h>
44#include <qpopupmenu.h>
45#include <qspinbox.h>
46#include <qtoolbutton.h>
47#include <qwidgetstack.h>
48#include <qcheckbox.h>
49#include <qcombo.h>
50#include <qlayout.h> 33#include <qlayout.h>
51#include <qapplication.h>
52#include <qtimer.h> 34#include <qtimer.h>
53#include <qdir.h> 35#include <qdir.h>
54#include <unistd.h> 36#include <unistd.h>
55#include <sys/stat.h> 37#include <sys/stat.h>
56#include <stdlib.h> //getenv 38#include <stdlib.h> //getenv
57 39
58using Opie::OFileDialog; 40using Opie::OFileDialog;
59using Opie::OFileSelector; 41using Opie::OFileSelector;
60using Opie::OFontSelector; 42using Opie::OFontSelector;
61 43
62#if QT_VERSION < 300 44#if QT_VERSION < 300
63 45
64class QpeEditor : public QMultiLineEdit 46class QpeEditor : public QMultiLineEdit
65{ 47{
66 48
67public: 49public:
68 QpeEditor( QWidget *parent, const char * name = 0 ) 50 QpeEditor( QWidget *parent, const char * name = 0 )
69 : QMultiLineEdit( parent, name ) { 51 : QMultiLineEdit( parent, name ) {
70 clearTableFlags(); 52 clearTableFlags();
71 setTableFlags( Tbl_vScrollBar | Tbl_autoHScrollBar ); 53 setTableFlags( Tbl_vScrollBar | Tbl_autoHScrollBar );
72} 54}
73 55
74 void find( const QString &txt, bool caseSensitive, 56 void find( const QString &txt, bool caseSensitive,
75 bool backwards ); 57 bool backwards );
76protected: 58protected:
77 bool markIt; 59 bool markIt;
78 int line1, line2, col1, col2; 60 int line1, line2, col1, col2;
79 void mousePressEvent( QMouseEvent * ); 61 void mousePressEvent( QMouseEvent * );
80 void mouseReleaseEvent( QMouseEvent * ); 62 void mouseReleaseEvent( QMouseEvent * );
81 63
82//public slots: 64//public slots:
83 /* 65 /*
84signals: 66signals:
85 void notFound(); 67 void notFound();
86 void searchWrapped(); 68 void searchWrapped();
87 */ 69 */
88 70
89private: 71private:
90 72
91}; 73};
92 74
93void QpeEditor::mousePressEvent( QMouseEvent *e ) { 75void QpeEditor::mousePressEvent( QMouseEvent *e ) {
94 switch(e->button()) { 76 switch(e->button()) {
95 case RightButton: 77 case RightButton:
96 { //rediculous workaround for qt popup menu 78 { //rediculous workaround for qt popup menu
97 //and the hold right click mechanism 79 //and the hold right click mechanism
98 this->setSelection( line1, col1, line2, col2); 80 this->setSelection( line1, col1, line2, col2);
99 QMultiLineEdit::mousePressEvent( e ); 81 QMultiLineEdit::mousePressEvent( e );
100 markIt = false; 82 markIt = false;
101 } 83 }
102 break; 84 break;
103 default: 85 default:
104 { 86 {
105 if(!markIt) { 87 if(!markIt) {
106 int line, col; 88 int line, col;
107 this->getCursorPosition(&line, &col); 89 this->getCursorPosition(&line, &col);
108 line1=line2=line; 90 line1=line2=line;
109 col1=col2=col; 91 col1=col2=col;
110 } 92 }
111 QMultiLineEdit::mousePressEvent( e ); 93 QMultiLineEdit::mousePressEvent( e );
112 } 94 }
113 break; 95 break;
114 }; 96 };
115} 97}
116 98
117void QpeEditor::mouseReleaseEvent( QMouseEvent * ) { 99void QpeEditor::mouseReleaseEvent( QMouseEvent * ) {
118 if(this->hasMarkedText()) { 100 if(this->hasMarkedText()) {
119 markIt = true; 101 markIt = true;
120 this->getMarkedRegion( &line1, &col1, &line2, & col2 ); 102 this->getMarkedRegion( &line1, &col1, &line2, & col2 );
121 } else { 103 } else {
122 markIt = false; 104 markIt = false;
123 } 105 }
124} 106}
125 107
126void QpeEditor::find ( const QString &txt, bool caseSensitive, 108void QpeEditor::find ( const QString &txt, bool caseSensitive,
127 bool backwards ) 109 bool backwards )
128{ 110{
129 static bool wrap = false; 111 static bool wrap = false;
130 int line, col; 112 int line, col;
131 if ( wrap ) { 113 if ( wrap ) {
132 if ( !backwards ) 114 if ( !backwards )
133 line = col = 0; 115 line = col = 0;
134 wrap = false; 116 wrap = false;
135 // emit searchWrapped(); 117 // emit searchWrapped();
136 } else { 118 } else {
137 getCursorPosition( &line, &col ); 119 getCursorPosition( &line, &col );
138 } 120 }
139 //ignore backwards for now.... 121 //ignore backwards for now....
140 if ( !backwards ) { 122 if ( !backwards ) {
141 for ( ; ; ) { 123 for ( ; ; ) {
142 if ( line >= numLines() ) { 124 if ( line >= numLines() ) {
143 wrap = true; 125 wrap = true;
144 //emit notFound(); 126 //emit notFound();
145 break; 127 break;
146 } 128 }
147 int findCol = getString( line )->find( txt, col, caseSensitive ); 129 int findCol = getString( line )->find( txt, col, caseSensitive );
148 if ( findCol >= 0 ) { 130 if ( findCol >= 0 ) {
149 setCursorPosition( line, findCol, false ); 131 setCursorPosition( line, findCol, false );
150 col = findCol + txt.length(); 132 col = findCol + txt.length();
151 setCursorPosition( line, col, true ); 133 setCursorPosition( line, col, true );
152 134
153 //found = true; 135 //found = true;
154 break; 136 break;
155 } 137 }
156 line++; 138 line++;
157 col = 0; 139 col = 0;
158 } 140 }
159 } 141 }
160} 142}
161 143
162 144
163#else 145#else
164 146
165#error "Must make a QpeEditor that inherits QTextEdit" 147#error "Must make a QpeEditor that inherits QTextEdit"
166 148
167#endif 149#endif
168 150
169 151
170static const int nfontsizes = 6; 152static const int nfontsizes = 6;
171static const int fontsize[nfontsizes] = {8,10,12,14,18,24}; 153static const int fontsize[nfontsizes] = {8,10,12,14,18,24};
172 154
173TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) 155TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
174 : QMainWindow( parent, name, f ), bFromDocView( false ) 156 : QMainWindow( parent, name, f ), bFromDocView( false )
175{ 157{
176 doc = 0; 158 doc = 0;
177 edited=false; 159 edited=false;
178 fromSetDocument=false; 160 fromSetDocument=false;
179 161
180 setToolBarsMovable( false ); 162 setToolBarsMovable( false );
181 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 163 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
182 164
183 channel = new QCopChannel( "QPE/Application/textedit", this ); 165 channel = new QCopChannel( "QPE/Application/textedit", this );
184 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), 166 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
185 this, SLOT(receive(const QCString&, const QByteArray&)) ); 167 this, SLOT(receive(const QCString&, const QByteArray&)) );
186 168
187 setIcon( Resource::loadPixmap( "TextEditor" ) ); 169 setIcon( Resource::loadPixmap( "TextEditor" ) );
188 170
189 QToolBar *bar = new QToolBar( this ); 171 QToolBar *bar = new QToolBar( this );
190 bar->setHorizontalStretchable( true ); 172 bar->setHorizontalStretchable( true );
191 menu = bar; 173 menu = bar;
192 174
193 QMenuBar *mb = new QMenuBar( bar ); 175 QMenuBar *mb = new QMenuBar( bar );
194 QPopupMenu *file = new QPopupMenu( this ); 176 QPopupMenu *file = new QPopupMenu( this );
195 QPopupMenu *edit = new QPopupMenu( this ); 177 QPopupMenu *edit = new QPopupMenu( this );
196 QPopupMenu *advancedMenu = new QPopupMenu(this); 178 QPopupMenu *advancedMenu = new QPopupMenu(this);
197 179
198 font = new QPopupMenu( this ); 180 font = new QPopupMenu( this );
199 181
200 bar = new QToolBar( this ); 182 bar = new QToolBar( this );
201 editBar = bar; 183 editBar = bar;
202 184
203 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), 185 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ),
204 QString::null, 0, this, 0 ); 186 QString::null, 0, this, 0 );
205 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); 187 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
206// a->addTo( bar ); 188// a->addTo( bar );
207 a->addTo( file ); 189 a->addTo( file );
208 190
209 a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), 191 a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ),
210 QString::null, 0, this, 0 ); 192 QString::null, 0, this, 0 );
211 connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); 193 connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) );
212 a->addTo( bar ); 194 a->addTo( bar );
213 a->addTo( file ); 195 a->addTo( file );
214 196
215 a = new QAction( tr( "Save" ), Resource::loadPixmap("save") , 197 a = new QAction( tr( "Save" ), Resource::loadPixmap("save") ,
216 QString::null, 0, this, 0 ); 198 QString::null, 0, this, 0 );
217 connect( a, SIGNAL( activated() ), this, SLOT( save() ) ); 199 connect( a, SIGNAL( activated() ), this, SLOT( save() ) );
218 file->insertSeparator(); 200 file->insertSeparator();
219 a->addTo( bar ); 201 a->addTo( bar );
220 a->addTo( file ); 202 a->addTo( file );
221 203
222 a = new QAction( tr( "Save As" ), Resource::loadPixmap("save") , 204 a = new QAction( tr( "Save As" ), Resource::loadPixmap("save") ,
223 QString::null, 0, this, 0 ); 205 QString::null, 0, this, 0 );
224 connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) ); 206 connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) );
225 a->addTo( file ); 207 a->addTo( file );
226 208
227 a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), 209 a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ),
228 QString::null, 0, this, 0 ); 210 QString::null, 0, this, 0 );
229 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); 211 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) );
230 a->addTo( editBar ); 212 a->addTo( editBar );
231 a->addTo( edit ); 213 a->addTo( edit );
232 214
233 a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), 215 a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ),
234 QString::null, 0, this, 0 ); 216 QString::null, 0, this, 0 );
235 connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); 217 connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) );
236 a->addTo( editBar ); 218 a->addTo( editBar );
237 a->addTo( edit ); 219 a->addTo( edit );
238 220
239 a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), 221 a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ),
240 QString::null, 0, this, 0 ); 222 QString::null, 0, this, 0 );
241 connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); 223 connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) );
242 a->addTo( editBar ); 224 a->addTo( editBar );
243 a->addTo( edit ); 225 a->addTo( edit );
244 226
245 227
246#ifndef QT_NO_CLIPBOARD 228#ifndef QT_NO_CLIPBOARD
247 a = new QAction( tr( "Insert Time and Date" ), Resource::loadPixmap( "paste" ), 229 a = new QAction( tr( "Insert Time and Date" ), Resource::loadPixmap( "paste" ),
248 QString::null, 0, this, 0 ); 230 QString::null, 0, this, 0 );
249 connect( a, SIGNAL( activated() ), this, SLOT( editPasteTimeDate() ) ); 231 connect( a, SIGNAL( activated() ), this, SLOT( editPasteTimeDate() ) );
250 a->addTo( edit ); 232 a->addTo( edit );
251#endif 233#endif
252 234
253 a = new QAction( tr( "Goto Line..." ), Resource::loadPixmap( "find" ), 235 a = new QAction( tr( "Goto Line..." ), Resource::loadPixmap( "find" ),
254 QString::null, 0, this, 0 ); 236 QString::null, 0, this, 0 );
255 connect( a, SIGNAL( activated() ), this, SLOT( gotoLine() ) ); 237 connect( a, SIGNAL( activated() ), this, SLOT( gotoLine() ) );
256 edit->insertSeparator(); 238 edit->insertSeparator();
257 a->addTo( edit ); 239 a->addTo( edit );
258 240
259 a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), 241 a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ),
260 QString::null, 0, this, 0 ); 242 QString::null, 0, this, 0 );
261 connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); 243 connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) );
262 a->addTo( bar ); 244 a->addTo( bar );
263 a->addTo( edit ); 245 a->addTo( edit );
264 246
265 zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 ); 247 zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 );
266 connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) ); 248 connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) );
267 zin->addTo( font ); 249 zin->addTo( font );
268 250
269 zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 ); 251 zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 );
270 connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) ); 252 connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) );
271 zout->addTo( font ); 253 zout->addTo( font );
272 254
273 font->insertSeparator(); 255 font->insertSeparator();
274 256
275 font->insertItem(tr("Font"), this, SLOT(changeFont()) ); 257 font->insertItem(tr("Font"), this, SLOT(changeFont()) );
276 258
277 font->insertSeparator(); 259 font->insertSeparator();
278 font->insertItem(tr("Advanced Features"), advancedMenu); 260 font->insertItem(tr("Advanced Features"), advancedMenu);
279 261
280 QAction *wa = new QAction( tr("Wrap lines"), 262 QAction *wa = new QAction( tr("Wrap lines"),
281 QString::null, 0, this, 0 ); 263 QString::null, 0, this, 0 );
282 connect( wa, SIGNAL( toggled(bool) ), 264 connect( wa, SIGNAL( toggled(bool) ),
283 this, SLOT( setWordWrap(bool) ) ); 265 this, SLOT( setWordWrap(bool) ) );
284 wa->setToggleAction(true); 266 wa->setToggleAction(true);
285 wa->addTo( advancedMenu); 267 wa->addTo( advancedMenu);
286 268
287 nStart = new QAction( tr("Start with new file"), 269 nStart = new QAction( tr("Start with new file"),
288 QString::null, 0, this, 0 ); 270 QString::null, 0, this, 0 );
289 connect( nStart, SIGNAL( toggled(bool) ), 271 connect( nStart, SIGNAL( toggled(bool) ),
290 this, SLOT( changeStartConfig(bool) ) ); 272 this, SLOT( changeStartConfig(bool) ) );
291 nStart->setToggleAction(true); 273 nStart->setToggleAction(true);
292 nStart->addTo( advancedMenu ); 274 nStart->addTo( advancedMenu );
293 nStart->setEnabled(false); 275 nStart->setEnabled(false);
294 276
295 nAdvanced = new QAction( tr("Prompt on Exit"), 277 nAdvanced = new QAction( tr("Prompt on Exit"),
296 QString::null, 0, this, 0 ); 278 QString::null, 0, this, 0 );
297 connect( nAdvanced, SIGNAL( toggled(bool) ), 279 connect( nAdvanced, SIGNAL( toggled(bool) ),
298 this, SLOT( doPrompt(bool) ) ); 280 this, SLOT( doPrompt(bool) ) );
299 nAdvanced->setToggleAction(true); 281 nAdvanced->setToggleAction(true);
300 nAdvanced->addTo( advancedMenu ); 282 nAdvanced->addTo( advancedMenu );
301 283
302 desktopAction = new QAction( tr("Always open linked file"), 284 desktopAction = new QAction( tr("Always open linked file"),
303 QString::null, 0, this, 0 ); 285 QString::null, 0, this, 0 );
304 connect( desktopAction, SIGNAL( toggled(bool) ), 286 connect( desktopAction, SIGNAL( toggled(bool) ),
305 this, SLOT( doDesktop(bool) ) ); 287 this, SLOT( doDesktop(bool) ) );
306 desktopAction->setToggleAction(true); 288 desktopAction->setToggleAction(true);
307 desktopAction->addTo( advancedMenu); 289 desktopAction->addTo( advancedMenu);
308 290
309 filePermAction = new QAction( tr("File Permissions"), 291 filePermAction = new QAction( tr("File Permissions"),
310 QString::null, 0, this, 0 ); 292 QString::null, 0, this, 0 );
311 connect( filePermAction, SIGNAL( toggled(bool) ), 293 connect( filePermAction, SIGNAL( toggled(bool) ),
312 this, SLOT( doFilePerms(bool) ) ); 294 this, SLOT( doFilePerms(bool) ) );
313 filePermAction->setToggleAction(true); 295 filePermAction->setToggleAction(true);
314 filePermAction->addTo( advancedMenu); 296 filePermAction->addTo( advancedMenu);
315 297
316 searchBarAction = new QAction( tr("Search Bar Open"), 298 searchBarAction = new QAction( tr("Search Bar Open"),
317 QString::null, 0, this, 0 ); 299 QString::null, 0, this, 0 );
318 connect( searchBarAction, SIGNAL( toggled(bool) ), 300 connect( searchBarAction, SIGNAL( toggled(bool) ),
319 this, SLOT( setSearchBar(bool) ) ); 301 this, SLOT( setSearchBar(bool) ) );
320 searchBarAction->setToggleAction(true); 302 searchBarAction->setToggleAction(true);
321 searchBarAction->addTo( advancedMenu); 303 searchBarAction->addTo( advancedMenu);
322 304
323 nAutoSave = new QAction( tr("Auto Save 5 min."), 305 nAutoSave = new QAction( tr("Auto Save 5 min."),
324 QString::null, 0, this, 0 ); 306 QString::null, 0, this, 0 );
325 connect( nAutoSave, SIGNAL( toggled(bool) ), 307 connect( nAutoSave, SIGNAL( toggled(bool) ),
326 this, SLOT( doTimer(bool) ) ); 308 this, SLOT( doTimer(bool) ) );
327 nAutoSave->setToggleAction(true); 309 nAutoSave->setToggleAction(true);
328 nAutoSave->addTo( advancedMenu); 310 nAutoSave->addTo( advancedMenu);
329 311
330 312
331 //font->insertSeparator(); 313 //font->insertSeparator();
332 314
333 //font->insertItem(tr("About"), this, SLOT( doAbout()) ); 315 //font->insertItem(tr("About"), this, SLOT( doAbout()) );
334 316
335 mb->insertItem( tr( "File" ), file ); 317 mb->insertItem( tr( "File" ), file );
336 mb->insertItem( tr( "Edit" ), edit ); 318 mb->insertItem( tr( "Edit" ), edit );
337 mb->insertItem( tr( "View" ), font ); 319 mb->insertItem( tr( "View" ), font );
338 320
339 searchBar = new QToolBar(this); 321 searchBar = new QToolBar(this);
340 addToolBar( searchBar, "Search", QMainWindow::Top, true ); 322 addToolBar( searchBar, "Search", QMainWindow::Top, true );
341 323
342 searchBar->setHorizontalStretchable( true ); 324 searchBar->setHorizontalStretchable( true );
343 325
344 searchEdit = new QLineEdit( searchBar, "searchEdit" ); 326 searchEdit = new QLineEdit( searchBar, "searchEdit" );
345 searchBar->setStretchableWidget( searchEdit ); 327 searchBar->setStretchableWidget( searchEdit );
346 connect( searchEdit, SIGNAL( textChanged( const QString & ) ), 328 connect( searchEdit, SIGNAL( textChanged( const QString & ) ),
347 this, SLOT( search() ) ); 329 this, SLOT( search() ) );
348 330
349 a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), 331 a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ),
350 QString::null, 0, this, 0 ); 332 QString::null, 0, this, 0 );
351 connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); 333 connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) );
352 a->addTo( searchBar ); 334 a->addTo( searchBar );
353 a->addTo( edit ); 335 a->addTo( edit );
354 336
355 a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), 337 a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ),
356 QString::null, 0, this, 0 ); 338 QString::null, 0, this, 0 );
357 connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); 339 connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) );
358 a->addTo( searchBar ); 340 a->addTo( searchBar );
359 341
360 edit->insertSeparator(); 342 edit->insertSeparator();
361 a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), 343 a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ),
362 QString::null, 0, this, 0 ); 344 QString::null, 0, this, 0 );
363 connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); 345 connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) );
364 a->addTo( edit ); 346 a->addTo( edit );
365 347
366 searchBar->hide(); 348 searchBar->hide();
367 349
368 editor = new QpeEditor( this ); 350 editor = new QpeEditor( this );
369 setCentralWidget( editor ); 351 setCentralWidget( editor );
370 editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); 352 editor->setFrameStyle( QFrame::Panel | QFrame::Sunken );
371 connect( editor, SIGNAL( textChanged() ), 353 connect( editor, SIGNAL( textChanged() ),
372 this, SLOT( editorChanged() ) ); 354 this, SLOT( editorChanged() ) );
373 355
374 QPEApplication::setStylusOperation( editor, QPEApplication::RightOnHold); 356 QPEApplication::setStylusOperation( editor, QPEApplication::RightOnHold);
375 357
376 Config cfg("TextEdit"); 358 Config cfg("TextEdit");
377 cfg. setGroup ( "Font" ); 359 cfg. setGroup ( "Font" );
378 360
379 QFont defaultFont = editor-> font ( ); 361 QFont defaultFont = editor-> font ( );
380 362
381 QString family = cfg. readEntry ( "Family", defaultFont. family ( )); 363 QString family = cfg. readEntry ( "Family", defaultFont. family ( ));
382 int size = cfg. readNumEntry ( "Size", defaultFont. pointSize ( )); 364 int size = cfg. readNumEntry ( "Size", defaultFont. pointSize ( ));
383 int weight = cfg. readNumEntry ( "Weight", defaultFont. weight ( )); 365 int weight = cfg. readNumEntry ( "Weight", defaultFont. weight ( ));
384 bool italic = cfg. readBoolEntry ( "Italic", defaultFont. italic ( )); 366 bool italic = cfg. readBoolEntry ( "Italic", defaultFont. italic ( ));
385 367
386 defaultFont = QFont ( family, size, weight, italic ); 368 defaultFont = QFont ( family, size, weight, italic );
387 editor-> setFont ( defaultFont ); 369 editor-> setFont ( defaultFont );
388// updateCaption(); 370// updateCaption();
389 371
390 cfg.setGroup ( "View" ); 372 cfg.setGroup ( "View" );
391 373
392 promptExit = cfg.readBoolEntry ( "PromptExit", false ); 374 promptExit = cfg.readBoolEntry ( "PromptExit", false );
393 openDesktop = cfg.readBoolEntry ( "OpenDesktop", true ); 375 openDesktop = cfg.readBoolEntry ( "OpenDesktop", true );
394 filePerms = cfg.readBoolEntry ( "FilePermissions", false ); 376 filePerms = cfg.readBoolEntry ( "FilePermissions", false );
395 useSearchBar = cfg.readBoolEntry ( "SearchBar", false ); 377 useSearchBar = cfg.readBoolEntry ( "SearchBar", false );
396 startWithNew = cfg.readBoolEntry ( "startNew", true); 378 startWithNew = cfg.readBoolEntry ( "startNew", true);
397 featureAutoSave = cfg.readBoolEntry( "autosave", false); 379 featureAutoSave = cfg.readBoolEntry( "autosave", false);
398 380
399 if(useSearchBar) searchBarAction->setOn(true); 381 if(useSearchBar) searchBarAction->setOn(true);
400 if(promptExit) nAdvanced->setOn( true ); 382 if(promptExit) nAdvanced->setOn( true );
401 if(openDesktop) desktopAction->setOn( true ); 383 if(openDesktop) desktopAction->setOn( true );
402 if(filePerms) filePermAction->setOn( true ); 384 if(filePerms) filePermAction->setOn( true );
403 if(startWithNew) nStart->setOn( true ); 385 if(startWithNew) nStart->setOn( true );
404 if(featureAutoSave) nAutoSave->setOn(true); 386 if(featureAutoSave) nAutoSave->setOn(true);
405 387
406// { 388// {
407// doTimer(true); 389// doTimer(true);
408// } 390// }
409 391
410 bool wrap = cfg. readBoolEntry ( "Wrap", true ); 392 bool wrap = cfg. readBoolEntry ( "Wrap", true );
411 wa-> setOn ( wrap ); 393 wa-> setOn ( wrap );
412 setWordWrap ( wrap ); 394 setWordWrap ( wrap );
413 395
414///////////////// 396/////////////////
415 if( qApp->argc() > 1) { 397 if( qApp->argc() > 1) {
416 currentFileName=qApp->argv()[1]; 398 currentFileName=qApp->argv()[1];
417 399
418 QFileInfo fi(currentFileName); 400 QFileInfo fi(currentFileName);
419 401
420 if(fi.baseName().left(1) == "") { 402 if(fi.baseName().left(1) == "") {
421 openDotFile(currentFileName); 403 openDotFile(currentFileName);
422 } else { 404 } else {
423 openFile(currentFileName); 405 openFile(currentFileName);
424 } 406 }
425 } else { 407 } else {
426 edited1=false; 408 edited1=false;
427 openDotFile(""); 409 openDotFile("");
428 } 410 }
429 411
430 viewSelection = cfg.readNumEntry( "FileView", 0 ); 412 viewSelection = cfg.readNumEntry( "FileView", 0 );
431} 413}
432 414
433TextEdit::~TextEdit() { 415TextEdit::~TextEdit() {
434 qWarning("textedit d'tor"); 416 qWarning("textedit d'tor");
435 delete editor; 417 delete editor;
436} 418}
437 419
438void TextEdit::closeEvent(QCloseEvent *) { 420void TextEdit::closeEvent(QCloseEvent *) {
439 if( edited1 && promptExit) 421 if( edited1 && promptExit)
440 { 422 {
441 switch( savePrompt() ) 423 switch( savePrompt() )
442 { 424 {
443 case 1: 425 case 1:
444 { 426 {
445 saveAs(); 427 saveAs();
446 qApp->quit(); 428 qApp->quit();
447 } 429 }
448 break; 430 break;
449 431
450 case 2: 432 case 2:
451 { 433 {
452 qApp->quit(); 434 qApp->quit();
453 } 435 }
454 break; 436 break;
455 437
456 case -1: 438 case -1:
457 break; 439 break;
458 }; 440 };
459 } 441 }
460 else 442 else
461 qApp->quit(); 443 qApp->quit();
462 444
463} 445}
464 446
465void TextEdit::cleanUp() { 447void TextEdit::cleanUp() {
466 448
467 Config cfg ( "TextEdit" ); 449 Config cfg ( "TextEdit" );
468 cfg. setGroup ( "Font" ); 450 cfg. setGroup ( "Font" );
469 QFont f = editor->font(); 451 QFont f = editor->font();
470 cfg.writeEntry ( "Family", f. family ( )); 452 cfg.writeEntry ( "Family", f. family ( ));
471 cfg.writeEntry ( "Size", f. pointSize ( )); 453 cfg.writeEntry ( "Size", f. pointSize ( ));
472 cfg.writeEntry ( "Weight", f. weight ( )); 454 cfg.writeEntry ( "Weight", f. weight ( ));
473 cfg.writeEntry ( "Italic", f. italic ( )); 455 cfg.writeEntry ( "Italic", f. italic ( ));
474 456
475 cfg.setGroup ( "View" ); 457 cfg.setGroup ( "View" );
476 cfg.writeEntry ( "Wrap", editor->wordWrap() == QMultiLineEdit::WidgetWidth ); 458 cfg.writeEntry ( "Wrap", editor->wordWrap() == QMultiLineEdit::WidgetWidth );
477 cfg.writeEntry ( "FileView", viewSelection ); 459 cfg.writeEntry ( "FileView", viewSelection );
478 460
479 cfg.writeEntry ( "PromptExit", promptExit ); 461 cfg.writeEntry ( "PromptExit", promptExit );
480 cfg.writeEntry ( "OpenDesktop", openDesktop ); 462 cfg.writeEntry ( "OpenDesktop", openDesktop );
481 cfg.writeEntry ( "FilePermissions", filePerms ); 463 cfg.writeEntry ( "FilePermissions", filePerms );
482 cfg.writeEntry ( "SearchBar", useSearchBar ); 464 cfg.writeEntry ( "SearchBar", useSearchBar );
483 cfg.writeEntry ( "startNew", startWithNew ); 465 cfg.writeEntry ( "startNew", startWithNew );
484 466
485} 467}
486 468
487 469
488void TextEdit::accept() { 470void TextEdit::accept() {
489 if( edited1) 471 if( edited1)
490 saveAs(); 472 saveAs();
491 qApp->quit(); 473 qApp->quit();
492} 474}
493 475
494void TextEdit::zoomIn() { 476void TextEdit::zoomIn() {
495 setFontSize(editor->font().pointSize()+1,false); 477 setFontSize(editor->font().pointSize()+1,false);
496} 478}
497 479
498void TextEdit::zoomOut() { 480void TextEdit::zoomOut() {
499 setFontSize(editor->font().pointSize()-1,true); 481 setFontSize(editor->font().pointSize()-1,true);
500} 482}
501 483
502 484
503void TextEdit::setFontSize(int sz, bool round_down_not_up) { 485void TextEdit::setFontSize(int sz, bool round_down_not_up) {
504 int s=10; 486 int s=10;
505 for (int i=0; i<nfontsizes; i++) { 487 for (int i=0; i<nfontsizes; i++) {
506 if ( fontsize[i] == sz ) { 488 if ( fontsize[i] == sz ) {
507 s = sz; 489 s = sz;
508 break; 490 break;
509 } else if ( round_down_not_up ) { 491 } else if ( round_down_not_up ) {
510 if ( fontsize[i] < sz ) 492 if ( fontsize[i] < sz )
511 s = fontsize[i]; 493 s = fontsize[i];
512 } else { 494 } else {
513 if ( fontsize[i] > sz ) { 495 if ( fontsize[i] > sz ) {
514 s = fontsize[i]; 496 s = fontsize[i];
515 break; 497 break;
516 } 498 }
517 } 499 }
518 } 500 }
519 501
520 QFont f = editor->font(); 502 QFont f = editor->font();
521 f.setPointSize(s); 503 f.setPointSize(s);
522 editor->setFont(f); 504 editor->setFont(f);
523 505
524 zin->setEnabled(s != fontsize[nfontsizes-1]); 506 zin->setEnabled(s != fontsize[nfontsizes-1]);
525 zout->setEnabled(s != fontsize[0]); 507 zout->setEnabled(s != fontsize[0]);
526} 508}
527 509
528void TextEdit::setBold(bool y) { 510void TextEdit::setBold(bool y) {
529 QFont f = editor->font(); 511 QFont f = editor->font();
530 f.setBold(y); 512 f.setBold(y);
531 editor->setFont(f); 513 editor->setFont(f);
532} 514}
533 515
534void TextEdit::setItalic(bool y) { 516void TextEdit::setItalic(bool y) {
535 QFont f = editor->font(); 517 QFont f = editor->font();
536 f.setItalic(y); 518 f.setItalic(y);
537 editor->setFont(f); 519 editor->setFont(f);
538} 520}
539 521
540void TextEdit::setWordWrap(bool y) { 522void TextEdit::setWordWrap(bool y) {
541 bool state = editor->edited(); 523 bool state = editor->edited();
542 QString captionStr = caption(); 524 QString captionStr = caption();
543 bool b1 = edited1; 525 bool b1 = edited1;
544 bool b2 = edited; 526 bool b2 = edited;
545 527
546 editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); 528 editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap );
547 editor->setEdited( state ); 529 editor->setEdited( state );
548 edited1=b1; 530 edited1=b1;
549 edited=b2; 531 edited=b2;
550 setCaption(captionStr); 532 setCaption(captionStr);
551} 533}
552 534
553void TextEdit::setSearchBar(bool b) { 535void TextEdit::setSearchBar(bool b) {
554 useSearchBar=b; 536 useSearchBar=b;
555 Config cfg("TextEdit"); 537 Config cfg("TextEdit");
556 cfg.setGroup("View"); 538 cfg.setGroup("View");
557 cfg.writeEntry ( "SearchBar", b ); 539 cfg.writeEntry ( "SearchBar", b );
558 searchBarAction->setOn(b); 540 searchBarAction->setOn(b);
559 if(b) 541 if(b)
560 searchBar->show(); 542 searchBar->show();
561 else 543 else
562 searchBar->hide(); 544 searchBar->hide();
563 editor->setFocus(); 545 editor->setFocus();
564} 546}
565 547
566void TextEdit::fileNew() { 548void TextEdit::fileNew() {
567// if( !bFromDocView ) { 549// if( !bFromDocView ) {
568// saveAs(); 550// saveAs();
569// } 551// }
570 newFile(DocLnk()); 552 newFile(DocLnk());
571} 553}
572 554
573void TextEdit::fileOpen() { 555void TextEdit::fileOpen() {
574 Config cfg("TextEdit"); 556 Config cfg("TextEdit");
575 cfg. setGroup ( "View" ); 557 cfg. setGroup ( "View" );
576 QMap<QString, QStringList> map; 558 QMap<QString, QStringList> map;
577 map.insert(tr("All"), QStringList() ); 559 map.insert(tr("All"), QStringList() );
578 QStringList text; 560 QStringList text;
579 text << "text/*"; 561 text << "text/*";
580 map.insert(tr("Text"), text ); 562 map.insert(tr("Text"), text );
581 text << "*"; 563 text << "*";
582 map.insert(tr("All"), text ); 564 map.insert(tr("All"), text );
583 QString str = OFileDialog::getOpenFileName( 2, 565 QString str = OFileDialog::getOpenFileName( 2,
584 QString::null , 566 QString::null ,
585 QString::null, map); 567 QString::null, map);
586 if( !str.isEmpty() && QFile(str).exists() && !QFileInfo(str).isDir() ) 568 if( !str.isEmpty() && QFile(str).exists() && !QFileInfo(str).isDir() )
587 { 569 {
588 openFile( str ); 570 openFile( str );
589 } 571 }
590 else 572 else
591 updateCaption(); 573 updateCaption();
592} 574}
593 575
594void TextEdit::doSearchBar() { 576void TextEdit::doSearchBar() {
595 if(!useSearchBar) 577 if(!useSearchBar)
596 searchBar->hide(); 578 searchBar->hide();
597 else 579 else
598 searchBar->show(); 580 searchBar->show();
599} 581}
600 582
601#if 0 583#if 0
602void TextEdit::slotFind() { 584void TextEdit::slotFind() {
603 FindDialog frmFind( tr("Text Editor"), this ); 585 FindDialog frmFind( tr("Text Editor"), this );
604 connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), 586 connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)),
605 editor, SLOT(slotDoFind( const QString&,bool,bool))); 587 editor, SLOT(slotDoFind( const QString&,bool,bool)));
606 588
607 //case sensitive, backwards, [category] 589 //case sensitive, backwards, [category]
608 590
609 connect( editor, SIGNAL(notFound()), 591 connect( editor, SIGNAL(notFound()),
610 &frmFind, SLOT(slotNotFound()) ); 592 &frmFind, SLOT(slotNotFound()) );
611 connect( editor, SIGNAL(searchWrapped()), 593 connect( editor, SIGNAL(searchWrapped()),
612 &frmFind, SLOT(slotWrapAround()) ); 594 &frmFind, SLOT(slotWrapAround()) );
613 595
614 frmFind.exec(); 596 frmFind.exec();
615 597
616 598
617} 599}
618#endif 600#endif
619 601
620void TextEdit::fileRevert() { 602void TextEdit::fileRevert() {
621 clear(); 603 clear();
622 fileOpen(); 604 fileOpen();
623} 605}
624 606
625void TextEdit::editCut() { 607void TextEdit::editCut() {
626#ifndef QT_NO_CLIPBOARD 608#ifndef QT_NO_CLIPBOARD
627 editor->cut(); 609 editor->cut();
628#endif 610#endif
629} 611}
630 612
631void TextEdit::editCopy() { 613void TextEdit::editCopy() {
632#ifndef QT_NO_CLIPBOARD 614#ifndef QT_NO_CLIPBOARD
633 editor->copy(); 615 editor->copy();
634#endif 616#endif
635} 617}
636 618
637void TextEdit::editPaste() { 619void TextEdit::editPaste() {
638#ifndef QT_NO_CLIPBOARD 620#ifndef QT_NO_CLIPBOARD
639 editor->paste(); 621 editor->paste();
640#endif 622#endif
641} 623}
642 624
643void TextEdit::editFind() { 625void TextEdit::editFind() {
644 searchBar->show(); 626 searchBar->show();
645 searchEdit->setFocus(); 627 searchEdit->setFocus();
646} 628}
647 629
648void TextEdit::findNext() { 630void TextEdit::findNext() {
649 editor->find( searchEdit->text(), false, false ); 631 editor->find( searchEdit->text(), false, false );
650 632
651} 633}
652 634
653void TextEdit::findClose() { 635void TextEdit::findClose() {
654 searchBar->hide(); 636 searchBar->hide();
655} 637}
656 638
657void TextEdit::search() { 639void TextEdit::search() {
658 editor->find( searchEdit->text(), false, false ); 640 editor->find( searchEdit->text(), false, false );
659} 641}
660 642
661void TextEdit::newFile( const DocLnk &f ) { 643void TextEdit::newFile( const DocLnk &f ) {
662 DocLnk nf = f; 644 DocLnk nf = f;
663 nf.setType("text/plain"); 645 nf.setType("text/plain");
664 clear(); 646 clear();
665 setWState (WState_Reserved1 ); 647 setWState (WState_Reserved1 );
666 editor->setFocus(); 648 editor->setFocus();
667 doc = new DocLnk(nf); 649 doc = new DocLnk(nf);
668 currentFileName = "Unnamed"; 650 currentFileName = "Unnamed";
669 qDebug("newFile "+currentFileName); 651 qDebug("newFile "+currentFileName);
670 updateCaption( currentFileName); 652 updateCaption( currentFileName);
671// editor->setEdited( false); 653// editor->setEdited( false);
672} 654}
673 655
674void TextEdit::openDotFile( const QString &f ) { 656void TextEdit::openDotFile( const QString &f ) {
675 if(!currentFileName.isEmpty()) { 657 if(!currentFileName.isEmpty()) {
676 currentFileName=f; 658 currentFileName=f;
677 659
678 qDebug("openFile dotfile " + currentFileName); 660 qDebug("openFile dotfile " + currentFileName);
679 QString txt; 661 QString txt;
680 QFile file(f); 662 QFile file(f);
681 file.open(IO_ReadWrite); 663 file.open(IO_ReadWrite);
682 QTextStream t(&file); 664 QTextStream t(&file);
683 while ( !t.atEnd()) { 665 while ( !t.atEnd()) {
684 txt+=t.readLine()+"\n"; 666 txt+=t.readLine()+"\n";
685 } 667 }
686 editor->setText(txt); 668 editor->setText(txt);
687 editor->setEdited( false); 669 editor->setEdited( false);
688 edited1=false; 670 edited1=false;
689 edited=false; 671 edited=false;
690 672
691 673
692 } 674 }
693 updateCaption( currentFileName); 675 updateCaption( currentFileName);
694} 676}
695 677
696void TextEdit::openFile( const QString &f ) { 678void TextEdit::openFile( const QString &f ) {
697 qDebug("filename is "+ f); 679 qDebug("filename is "+ f);
698 QString filer; 680 QString filer;
699 QFileInfo fi( f); 681 QFileInfo fi( f);
700// bFromDocView = true; 682// bFromDocView = true;
701 if(f.find(".desktop",0,true) != -1 && !openDesktop ) 683 if(f.find(".desktop",0,true) != -1 && !openDesktop )
702 { 684 {
703 switch ( QMessageBox::warning(this,tr("Text Editor"),tr("Text Editor has detected<BR>you selected a <B>.desktop</B>file.<BR>Open<B>.desktop</B> file or <B>linked</B> file?"),tr(".desktop File"),tr("Linked Document"),0,1,1) ) 685 switch ( QMessageBox::warning(this,tr("Text Editor"),tr("Text Editor has detected<BR>you selected a <B>.desktop</B>file.<BR>Open<B>.desktop</B> file or <B>linked</B> file?"),tr(".desktop File"),tr("Linked Document"),0,1,1) )
704 { 686 {
705 case 0: //desktop 687 case 0: //desktop
706 filer = f; 688 filer = f;
707 break; 689 break;
708 case 1: //linked 690 case 1: //linked
709 DocLnk sf(f); 691 DocLnk sf(f);
710 filer = sf.file(); 692 filer = sf.file();
711 break; 693 break;
712 }; 694 };
713 } 695 }
714 else if(fi.baseName().left(1) == "") 696 else if(fi.baseName().left(1) == "")
715 { 697 {
716 qDebug("opening dotfile"); 698 qDebug("opening dotfile");
717 currentFileName=f; 699 currentFileName=f;
718 openDotFile(currentFileName); 700 openDotFile(currentFileName);
719 return; 701 return;
720 } 702 }
721 /* 703 /*
722 * The problem is a file where Config(f).isValid() and it does not 704 * The problem is a file where Config(f).isValid() and it does not
723 * end with .desktop will be treated as desktop file 705 * end with .desktop will be treated as desktop file
724 */ 706 */
725 else if (f.find(".desktop",0,true) != -1 ) 707 else if (f.find(".desktop",0,true) != -1 )
726 { 708 {
727 DocLnk sf(f); 709 DocLnk sf(f);
728 filer = sf.file(); 710 filer = sf.file();
729 if(filer.right(1) == "/") 711 if(filer.right(1) == "/")
730 filer = f; 712 filer = f;
731 713
732 } 714 }
733 else 715 else
734 filer = f; 716 filer = f;
735 717
736 DocLnk nf; 718 DocLnk nf;
737 nf.setType("text/plain"); 719 nf.setType("text/plain");
738 nf.setFile(filer); 720 nf.setFile(filer);
739 currentFileName=filer; 721 currentFileName=filer;
740 722
741 nf.setName(fi.baseName()); 723 nf.setName(fi.baseName());
742 openFile(nf); 724 openFile(nf);
743 725
744 qDebug("openFile string "+currentFileName); 726 qDebug("openFile string "+currentFileName);
745 727
746 showEditTools(); 728 showEditTools();
747 // Show filename in caption 729 // Show filename in caption
748 QString name = filer; 730 QString name = filer;
749 int sep = name.findRev( '/' ); 731 int sep = name.findRev( '/' );
750 if ( sep > 0 ) 732 if ( sep > 0 )
751 name = name.mid( sep+1 ); 733 name = name.mid( sep+1 );
752 updateCaption( name ); 734 updateCaption( name );
753} 735}
754 736
755void TextEdit::openFile( const DocLnk &f ) { 737void TextEdit::openFile( const DocLnk &f ) {
756// clear(); 738// clear();
757// bFromDocView = true; 739// bFromDocView = true;
758 FileManager fm; 740 FileManager fm;
759 QString txt; 741 QString txt;
760 currentFileName=f.file(); 742 currentFileName=f.file();
761 qDebug("openFile doclnk " + currentFileName); 743 qDebug("openFile doclnk " + currentFileName);
762 if ( !fm.loadFile( f, txt ) ) { 744 if ( !fm.loadFile( f, txt ) ) {
763 // ####### could be a new file 745 // ####### could be a new file
764 qDebug( "Cannot open file" ); 746 qDebug( "Cannot open file" );
765 } 747 }
766// fileNew(); 748// fileNew();
767 if ( doc ) 749 if ( doc )
768 delete doc; 750 delete doc;
769 doc = new DocLnk(f); 751 doc = new DocLnk(f);
770 editor->setText(txt); 752 editor->setText(txt);
771 editor->setEdited( false); 753 editor->setEdited( false);
772 edited1=false; 754 edited1=false;
773 edited=false; 755 edited=false;
774 756
775 doc->setName(currentFileName); 757 doc->setName(currentFileName);
776 updateCaption(); 758 updateCaption();
777 setTimer(); 759 setTimer();
778} 760}
779 761
780void TextEdit::showEditTools() { 762void TextEdit::showEditTools() {
781 menu->show(); 763 menu->show();
782 editBar->show(); 764 editBar->show();
783 if(!useSearchBar) 765 if(!useSearchBar)
784 searchBar->hide(); 766 searchBar->hide();
785 else 767 else
786 searchBar->show(); 768 searchBar->show();
787 setWState (WState_Reserved1 ); 769 setWState (WState_Reserved1 );
788} 770}
789 771
790/*! 772/*!
791 unprompted save */ 773 unprompted save */
792bool TextEdit::save() { 774bool TextEdit::save() {
793 qDebug("saveAsFile " + currentFileName); 775 qDebug("saveAsFile " + currentFileName);
794 if(currentFileName.isEmpty()) { 776 if(currentFileName.isEmpty()) {
795 saveAs(); 777 saveAs();
796 return false; 778 return false;
797 } 779 }
798 780
799 QString file = doc->file(); 781 QString file = doc->file();
800 qDebug("saver file "+file); 782 qDebug("saver file "+file);
801 QString name= doc->name(); 783 QString name= doc->name();
802 qDebug("File named "+name); 784 qDebug("File named "+name);
803 QString rt = editor->text(); 785 QString rt = editor->text();
804 if( !rt.isEmpty() ) { 786 if( !rt.isEmpty() ) {
805 if(name.isEmpty()) { 787 if(name.isEmpty()) {
806 saveAs(); 788 saveAs();
807 } else { 789 } else {
808 currentFileName= name ; 790 currentFileName= name ;
809 qDebug("saveFile "+currentFileName); 791 qDebug("saveFile "+currentFileName);
810 792
811 struct stat buf; 793 struct stat buf;
812 mode_t mode; 794 mode_t mode;
813 stat(file.latin1(), &buf); 795 stat(file.latin1(), &buf);
814 mode = buf.st_mode; 796 mode = buf.st_mode;
815 797
816 if(!fileIs) { 798 if(!fileIs) {
817 doc->setName( name); 799 doc->setName( name);
818 FileManager fm; 800 FileManager fm;
819 if ( !fm.saveFile( *doc, rt ) ) { 801 if ( !fm.saveFile( *doc, rt ) ) {
820 QMessageBox::message(tr("Text Edit"),tr("Save Failed")); 802 QMessageBox::message(tr("Text Edit"),tr("Save Failed"));
821 return false; 803 return false;
822 } 804 }
823 } else { 805 } else {
824 qDebug("regular save file"); 806 qDebug("regular save file");
825 QFile f(file); 807 QFile f(file);
826 if( f.open(IO_WriteOnly)) { 808 if( f.open(IO_WriteOnly)) {
827 QCString crt = rt.utf8(); 809 QCString crt = rt.utf8();
828 f.writeBlock(crt,crt.length()); 810 f.writeBlock(crt,crt.length());
829 } else { 811 } else {
830 QMessageBox::message(tr("Text Edit"),tr("Write Failed")); 812 QMessageBox::message(tr("Text Edit"),tr("Write Failed"));
831 return false; 813 return false;
832 } 814 }
833 815
834 } 816 }
835 editor->setEdited( false); 817 editor->setEdited( false);
836 edited1=false; 818 edited1=false;
837 edited=false; 819 edited=false;
838 if(caption().left(1)=="*") 820 if(caption().left(1)=="*")
839 setCaption(caption().right(caption().length()-1)); 821 setCaption(caption().right(caption().length()-1));
840 822
841 823
842 chmod( file.latin1(), mode); 824 chmod( file.latin1(), mode);
843 } 825 }
844 return true; 826 return true;
845 } 827 }
846 return false; 828 return false;
847} 829}
848 830
849/*! 831/*!
850 prompted save */ 832 prompted save */
851bool TextEdit::saveAs() { 833bool TextEdit::saveAs() {
852 834
853 if(caption() == tr("Text Editor")) 835 if(caption() == tr("Text Editor"))
854 return false; 836 return false;
855 qDebug("saveAsFile " + currentFileName); 837 qDebug("saveAsFile " + currentFileName);
856 // case of nothing to save... 838 // case of nothing to save...
857// if ( !doc && !currentFileName.isEmpty()) { 839// if ( !doc && !currentFileName.isEmpty()) {
858// //|| !bFromDocView) 840// //|| !bFromDocView)
859// qDebug("no doc"); 841// qDebug("no doc");
860// return true; 842// return true;
861// } 843// }
862// if ( !editor->edited() ) { 844// if ( !editor->edited() ) {
863// delete doc; 845// delete doc;
864// doc = 0; 846// doc = 0;
865// return true; 847// return true;
866// } 848// }
867 849
868 QString rt = editor->text(); 850 QString rt = editor->text();
869 qDebug(currentFileName); 851 qDebug(currentFileName);
870 852
871 if( currentFileName.isEmpty() 853 if( currentFileName.isEmpty()
872 || currentFileName == tr("Unnamed") 854 || currentFileName == tr("Unnamed")
873 || currentFileName == tr("Text Editor")) { 855 || currentFileName == tr("Text Editor")) {
874 qDebug("do silly TT filename thing"); 856 qDebug("do silly TT filename thing");
875// if ( doc && doc->name().isEmpty() ) { 857// if ( doc && doc->name().isEmpty() ) {
876 QString pt = rt.simplifyWhiteSpace(); 858 QString pt = rt.simplifyWhiteSpace();
877 int i = pt.find( ' ' ); 859 int i = pt.find( ' ' );
878 QString docname = pt; 860 QString docname = pt;
879 if ( i > 0 ) 861 if ( i > 0 )
880 docname = pt.left( i ); 862 docname = pt.left( i );
881 // remove "." at the beginning 863 // remove "." at the beginning
882 while( docname.startsWith( "." ) ) 864 while( docname.startsWith( "." ) )
883 docname = docname.mid( 1 ); 865 docname = docname.mid( 1 );
884 docname.replace( QRegExp("/"), "_" ); 866 docname.replace( QRegExp("/"), "_" );
885 // cut the length. filenames longer than that 867 // cut the length. filenames longer than that
886 //don't make sense and something goes wrong when they get too long. 868 //don't make sense and something goes wrong when they get too long.
887 if ( docname.length() > 40 ) 869 if ( docname.length() > 40 )
888 docname = docname.left(40); 870 docname = docname.left(40);
889 if ( docname.isEmpty() ) 871 if ( docname.isEmpty() )
890 docname = tr("Unnamed"); 872 docname = tr("Unnamed");
891 if(doc) doc->setName(docname); 873 if(doc) doc->setName(docname);
892 currentFileName=docname; 874 currentFileName=docname;
893// } 875// }
894// else 876// else
895// qDebug("hmmmmmm"); 877// qDebug("hmmmmmm");
896 } 878 }
897 879
898 880
899 QMap<QString, QStringList> map; 881 QMap<QString, QStringList> map;
900 map.insert(tr("All"), QStringList() ); 882 map.insert(tr("All"), QStringList() );
901 QStringList text; 883 QStringList text;
902 text << "text/*"; 884 text << "text/*";
903 map.insert(tr("Text"), text ); 885 map.insert(tr("Text"), text );
904 text << "*"; 886 text << "*";
905 map.insert(tr("All"), text ); 887 map.insert(tr("All"), text );
906 888
907 QFileInfo cuFi( currentFileName); 889 QFileInfo cuFi( currentFileName);
908 QString filee = cuFi.fileName(); 890 QString filee = cuFi.fileName();
909 QString dire = cuFi.dirPath(); 891 QString dire = cuFi.dirPath();
910 if(dire==".") 892 if(dire==".")
911 dire = QPEApplication::documentDir(); 893 dire = QPEApplication::documentDir();
912 QString str; 894 QString str;
913 if( !featureAutoSave) { 895 if( !featureAutoSave) {
914 str = OFileDialog::getSaveFileName( 2, 896 str = OFileDialog::getSaveFileName( 2,
915 dire, 897 dire,
916 filee, map); 898 filee, map);
917 } else 899 } else
918 str=currentFileName; 900 str=currentFileName;
919 901
920 if(!str.isEmpty()) { 902 if(!str.isEmpty()) {
921 QString fileNm=str; 903 QString fileNm=str;
922 904
923 qDebug("saving filename "+fileNm); 905 qDebug("saving filename "+fileNm);
924 QFileInfo fi(fileNm); 906 QFileInfo fi(fileNm);
925 currentFileName=fi.fileName(); 907 currentFileName=fi.fileName();
926 if(doc) 908 if(doc)
927// QString file = doc->file(); 909// QString file = doc->file();
928// doc->removeFiles(); 910// doc->removeFiles();
929 delete doc; 911 delete doc;
930 DocLnk nf; 912 DocLnk nf;
931 nf.setType("text/plain"); 913 nf.setType("text/plain");
932 nf.setFile( fileNm); 914 nf.setFile( fileNm);
933 doc = new DocLnk(nf); 915 doc = new DocLnk(nf);
934// editor->setText(rt); 916// editor->setText(rt);
935 qDebug("Saving file as "+currentFileName); 917 qDebug("Saving file as "+currentFileName);
936 doc->setName( currentFileName); 918 doc->setName( currentFileName);
937 updateCaption( currentFileName); 919 updateCaption( currentFileName);
938 920
939 FileManager fm; 921 FileManager fm;
940 if ( !fm.saveFile( *doc, rt ) ) { 922 if ( !fm.saveFile( *doc, rt ) ) {
941 QMessageBox::message(tr("Text Edit"),tr("Save Failed")); 923 QMessageBox::message(tr("Text Edit"),tr("Save Failed"));
942 return false; 924 return false;
943 } 925 }
944 926
945 if( filePerms ) { 927 if( filePerms ) {
946 filePermissions *filePerm; 928 filePermissions *filePerm;
947 filePerm = new filePermissions(this, 929 filePerm = new filePermissions(this,
948 tr("Permissions"),true, 930 tr("Permissions"),true,
949 0,(const QString &)fileNm); 931 0,(const QString &)fileNm);
950 QPEApplication::execDialog( filePerm ); 932 QPEApplication::execDialog( filePerm );
951 933
952 if( filePerm) 934 if( filePerm)
953 delete filePerm; 935 delete filePerm;
954 } 936 }
955// } 937// }
956 editor->setEdited( false); 938 editor->setEdited( false);
957 edited1 = false; 939 edited1 = false;
958 edited = false; 940 edited = false;
959 if(caption().left(1)=="*") 941 if(caption().left(1)=="*")
960 setCaption(caption().right(caption().length()-1)); 942 setCaption(caption().right(caption().length()-1));
961 943
962 return true; 944 return true;
963 } 945 }
964 qDebug("returning false"); 946 qDebug("returning false");
965 return false; 947 return false;
966} //end saveAs 948} //end saveAs
967 949
968void TextEdit::clear() { 950void TextEdit::clear() {
969 delete doc; 951 delete doc;
970 doc = 0; 952 doc = 0;
971 editor->clear(); 953 editor->clear();
972} 954}
973 955
974void TextEdit::updateCaption( const QString &name ) { 956void TextEdit::updateCaption( const QString &name ) {
975 957
976 if ( name.isEmpty() ) 958 if ( name.isEmpty() )
977 setCaption( tr("Text Editor") ); 959 setCaption( tr("Text Editor") );
978 else { 960 else {
979 QString s = name; 961 QString s = name;
980 if ( s.isNull() ) 962 if ( s.isNull() )
981 s = doc->name(); 963 s = doc->name();
982 if ( s.isEmpty() ) { 964 if ( s.isEmpty() ) {
983 s = tr( "Unnamed" ); 965 s = tr( "Unnamed" );
984 currentFileName=s; 966 currentFileName=s;
985 } 967 }
986// if(s.left(1) == "/") 968// if(s.left(1) == "/")
987// s = s.right(s.length()-1); 969// s = s.right(s.length()-1);
988 setCaption( tr("%1 - Text Editor").arg( s ) ); 970 setCaption( tr("%1 - Text Editor").arg( s ) );
989 } 971 }
990} 972}
991 973
992void TextEdit::setDocument(const QString& fileref) { 974void TextEdit::setDocument(const QString& fileref) {
993 if(fileref != "Unnamed") { 975 if(fileref != "Unnamed") {
994 currentFileName=fileref; 976 currentFileName=fileref;
995 qDebug("setDocument"); 977 qDebug("setDocument");
996 QFileInfo fi(currentFileName); 978 QFileInfo fi(currentFileName);
997 qDebug("basename:"+fi.baseName()+": current filenmame "+currentFileName); 979 qDebug("basename:"+fi.baseName()+": current filenmame "+currentFileName);
998 if( (fi.baseName().left(1)).isEmpty() ) { 980 if( (fi.baseName().left(1)).isEmpty() ) {
999 openDotFile(currentFileName); 981 openDotFile(currentFileName);
1000 982
1001 } else { 983 } else {
1002 qDebug("setDoc open"); 984 qDebug("setDoc open");
1003 bFromDocView = true; 985 bFromDocView = true;
1004 openFile(fileref); 986 openFile(fileref);
1005 editor->setEdited(true); 987 editor->setEdited(true);
1006 edited1=false; 988 edited1=false;
1007 edited=true; 989 edited=true;
1008 // fromSetDocument=false; 990 // fromSetDocument=false;
1009 // doSearchBar(); 991 // doSearchBar();
1010 } 992 }
1011 } 993 }
1012 updateCaption( currentFileName); 994 updateCaption( currentFileName);
1013} 995}
1014 996
1015void TextEdit::changeFont() { 997void TextEdit::changeFont() {
1016 QDialog *d = new QDialog ( this, "FontDialog", true ); 998 QDialog *d = new QDialog ( this, "FontDialog", true );
1017 d-> setCaption ( tr( "Choose font" )); 999 d-> setCaption ( tr( "Choose font" ));
1018 QBoxLayout *lay = new QVBoxLayout ( d ); 1000 QBoxLayout *lay = new QVBoxLayout ( d );
1019 OFontSelector *ofs = new OFontSelector ( true, d ); 1001 OFontSelector *ofs = new OFontSelector ( true, d );
1020 lay-> addWidget ( ofs ); 1002 lay-> addWidget ( ofs );
1021 ofs-> setSelectedFont ( editor-> font ( )); 1003 ofs-> setSelectedFont ( editor-> font ( ));
1022 1004
1023 if ( QPEApplication::execDialog( d ) == QDialog::Accepted ) 1005 if ( QPEApplication::execDialog( d ) == QDialog::Accepted )
1024 editor-> setFont ( ofs-> selectedFont ( )); 1006 editor-> setFont ( ofs-> selectedFont ( ));
1025 delete d; 1007 delete d;
1026 1008
1027} 1009}
1028 1010
1029void TextEdit::editDelete() { 1011void TextEdit::editDelete() {
1030 switch ( QMessageBox::warning(this,tr("Text Editor"), 1012 switch ( QMessageBox::warning(this,tr("Text Editor"),
1031 tr("Do you really want<BR>to <B>delete</B> " 1013 tr("Do you really want<BR>to <B>delete</B> "
1032 "the current file\nfrom the disk?<BR>This is " 1014 "the current file\nfrom the disk?<BR>This is "
1033 "<B>irreversable!</B>"), 1015 "<B>irreversable!</B>"),
1034 tr("Yes"),tr("No"),0,0,1) ) { 1016 tr("Yes"),tr("No"),0,0,1) ) {
1035 case 0: 1017 case 0:
1036 if(doc) { 1018 if(doc) {
1037 doc->removeFiles(); 1019 doc->removeFiles();
1038 clear(); 1020 clear();
1039 setCaption( tr("Text Editor") ); 1021 setCaption( tr("Text Editor") );
1040 } 1022 }
1041 break; 1023 break;
1042 case 1: 1024 case 1:
1043 // exit 1025 // exit
1044 break; 1026 break;
1045 }; 1027 };
1046} 1028}
1047 1029
1048void TextEdit::changeStartConfig( bool b ) { 1030void TextEdit::changeStartConfig( bool b ) {
1049 startWithNew=b; 1031 startWithNew=b;
1050 Config cfg("TextEdit"); 1032 Config cfg("TextEdit");
1051 cfg.setGroup("View"); 1033 cfg.setGroup("View");
1052 cfg.writeEntry("startNew",b); 1034 cfg.writeEntry("startNew",b);
1053 update(); 1035 update();
1054} 1036}
1055 1037
1056void TextEdit::editorChanged() { 1038void TextEdit::editorChanged() {
1057// qDebug("editor changed"); 1039// qDebug("editor changed");
1058 if( /*editor->edited() &&*/ /*edited && */!edited1) { 1040 if( /*editor->edited() &&*/ /*edited && */!edited1) {
1059 setCaption( "*"+caption()); 1041 setCaption( "*"+caption());
1060 edited1=true; 1042 edited1=true;
1061 } 1043 }
1062 edited=true; 1044 edited=true;
1063} 1045}
1064 1046
1065void TextEdit::receive(const QCString&msg, const QByteArray &) { 1047void TextEdit::receive(const QCString&msg, const QByteArray &) {
1066 qDebug("QCop "+msg); 1048 qDebug("QCop "+msg);
1067 if ( msg == "setDocument(QString)" ) { 1049 if ( msg == "setDocument(QString)" ) {
1068 qDebug("bugger all"); 1050 qDebug("bugger all");
1069 1051
1070 } 1052 }
1071 1053
1072} 1054}
1073 1055
1074void TextEdit::doAbout() { 1056void TextEdit::doAbout() {
1075 QMessageBox::about(0,tr("Text Edit"),tr("Text Edit is copyright<BR>" 1057 QMessageBox::about(0,tr("Text Edit"),tr("Text Edit is copyright<BR>"
1076 "2000 Trolltech AS, and<BR>" 1058 "2000 Trolltech AS, and<BR>"
1077 "2002 by <B>L. J. Potter <BR>llornkcor@handhelds.org</B><BR>" 1059 "2002 by <B>L. J. Potter <BR>llornkcor@handhelds.org</B><BR>"
1078 "and is licensed under the GPL")); 1060 "and is licensed under the GPL"));
1079} 1061}
1080 1062
1081void TextEdit::doPrompt(bool b) { 1063void TextEdit::doPrompt(bool b) {
1082 promptExit=b; 1064 promptExit=b;
1083 Config cfg("TextEdit"); 1065 Config cfg("TextEdit");
1084 cfg.setGroup ( "View" ); 1066 cfg.setGroup ( "View" );
1085 cfg.writeEntry ( "PromptExit", b); 1067 cfg.writeEntry ( "PromptExit", b);
1086} 1068}
1087 1069
1088void TextEdit::doDesktop(bool b) { 1070void TextEdit::doDesktop(bool b) {
1089 openDesktop=b; 1071 openDesktop=b;
1090 Config cfg("TextEdit"); 1072 Config cfg("TextEdit");
1091 cfg.setGroup ( "View" ); 1073 cfg.setGroup ( "View" );
1092 cfg.writeEntry ( "OpenDesktop", b); 1074 cfg.writeEntry ( "OpenDesktop", b);
1093} 1075}
1094 1076
1095void TextEdit::doFilePerms(bool b) { 1077void TextEdit::doFilePerms(bool b) {
1096 filePerms=b; 1078 filePerms=b;
1097 Config cfg("TextEdit"); 1079 Config cfg("TextEdit");
1098 cfg.setGroup ( "View" ); 1080 cfg.setGroup ( "View" );
1099 cfg.writeEntry ( "FilePermissions", b); 1081 cfg.writeEntry ( "FilePermissions", b);
1100} 1082}
1101 1083
1102void TextEdit::editPasteTimeDate() { 1084void TextEdit::editPasteTimeDate() {
1103#ifndef QT_NO_CLIPBOARD 1085#ifndef QT_NO_CLIPBOARD
1104 QClipboard *cb = QApplication::clipboard(); 1086 QClipboard *cb = QApplication::clipboard();
1105 QDateTime dt = QDateTime::currentDateTime(); 1087 QDateTime dt = QDateTime::currentDateTime();
1106 cb->setText( dt.toString()); 1088 cb->setText( dt.toString());
1107 editor->paste(); 1089 editor->paste();
1108#endif 1090#endif
1109} 1091}
1110 1092
1111int TextEdit::savePrompt() 1093int TextEdit::savePrompt()
1112{ 1094{
1113 switch( QMessageBox::information( 0, (tr("Textedit")), 1095 switch( QMessageBox::information( 0, (tr("Textedit")),
1114 (tr("Textedit detected\n" 1096 (tr("Textedit detected\n"
1115 "you have unsaved changes\n" 1097 "you have unsaved changes\n"
1116 "Go ahead and save?\n")), 1098 "Go ahead and save?\n")),
1117 (tr("Save")), (tr("Don't Save")), (tr("&Cancel")), 2, 2 ) ) 1099 (tr("Save")), (tr("Don't Save")), (tr("&Cancel")), 2, 2 ) )
1118 { 1100 {
1119 case 0: 1101 case 0:
1120 { 1102 {
1121 return 1; 1103 return 1;
1122 } 1104 }
1123 break; 1105 break;
1124 1106
1125 case 1: 1107 case 1:
1126 { 1108 {
1127 return 2; 1109 return 2;
1128 } 1110 }
1129 break; 1111 break;
1130 1112
1131 case 2: 1113 case 2:
1132 { 1114 {
1133 return -1; 1115 return -1;
1134 } 1116 }
1135 break; 1117 break;
1136 }; 1118 };
1137 1119
1138 return 0; 1120 return 0;
1139} 1121}
1140 1122
1141void TextEdit::timerCrank() 1123void TextEdit::timerCrank()
1142{ 1124{
1143 if(featureAutoSave && edited1) 1125 if(featureAutoSave && edited1)
1144 { 1126 {
1145 if(currentFileName.isEmpty()) 1127 if(currentFileName.isEmpty())
1146 { 1128 {
1147 currentFileName = QDir::homeDirPath()+"/textedit.tmp"; 1129 currentFileName = QDir::homeDirPath()+"/textedit.tmp";
1148 saveAs(); 1130 saveAs();
1149 } 1131 }
1150 else 1132 else
1151 { 1133 {
1152// qDebug("autosave"); 1134// qDebug("autosave");
1153 save(); 1135 save();
1154 } 1136 }
1155 setTimer(); 1137 setTimer();
1156 } 1138 }
1157} 1139}
1158 1140
1159void TextEdit::doTimer(bool b) 1141void TextEdit::doTimer(bool b)
1160{ 1142{
1161 Config cfg("TextEdit"); 1143 Config cfg("TextEdit");
1162 cfg.setGroup ( "View" ); 1144 cfg.setGroup ( "View" );
1163 cfg.writeEntry ( "autosave", b); 1145 cfg.writeEntry ( "autosave", b);
1164 featureAutoSave = b; 1146 featureAutoSave = b;
1165 nAutoSave->setOn(b); 1147 nAutoSave->setOn(b);
1166 if(b) 1148 if(b)
1167 { 1149 {
1168// qDebug("doTimer true"); 1150// qDebug("doTimer true");
1169 setTimer(); 1151 setTimer();
1170 } 1152 }
1171// else 1153// else
1172// qDebug("doTimer false"); 1154// qDebug("doTimer false");
1173} 1155}
1174 1156
1175void TextEdit::setTimer() 1157void TextEdit::setTimer()
1176{ 1158{
1177if(featureAutoSave) 1159if(featureAutoSave)
1178 { 1160 {
1179// qDebug("setting autosave"); 1161// qDebug("setting autosave");
1180 QTimer *timer = new QTimer(this ); 1162 QTimer *timer = new QTimer(this );
1181 connect( timer, SIGNAL(timeout()), this, SLOT(timerCrank()) ); 1163 connect( timer, SIGNAL(timeout()), this, SLOT(timerCrank()) );
1182 timer->start( 300000, true); //5 minutes 1164 timer->start( 300000, true); //5 minutes
1183 } 1165 }
1184} 1166}
1185 1167
1186void TextEdit::gotoLine() { 1168void TextEdit::gotoLine() {
1187 if( editor->length() < 1) 1169 if( editor->length() < 1)
1188 return; 1170 return;
1189 QWidget *d = QApplication::desktop(); 1171 QWidget *d = QApplication::desktop();
1190 gotoEdit = new QLineEdit( 0, "Goto line"); 1172 gotoEdit = new QLineEdit( 0, "Goto line");
1191 1173
1192 gotoEdit->move( (d->width()/2) - ( gotoEdit->width()/2) , (d->height()/2) - (gotoEdit->height()/2)); 1174 gotoEdit->move( (d->width()/2) - ( gotoEdit->width()/2) , (d->height()/2) - (gotoEdit->height()/2));
1193 gotoEdit->setFrame(true); 1175 gotoEdit->setFrame(true);
1194 gotoEdit->show(); 1176 gotoEdit->show();
1195 connect (gotoEdit,SIGNAL(returnPressed()), this, SLOT(doGoto())); 1177 connect (gotoEdit,SIGNAL(returnPressed()), this, SLOT(doGoto()));
1196} 1178}
1197 1179
1198void TextEdit::doGoto() { 1180void TextEdit::doGoto() {
1199 QString number = gotoEdit->text(); 1181 QString number = gotoEdit->text();
1200 gotoEdit->hide(); 1182 gotoEdit->hide();
1201 1183
1202 if(gotoEdit) { 1184 if(gotoEdit) {
1203 delete gotoEdit; 1185 delete gotoEdit;
1204 gotoEdit = 0; 1186 gotoEdit = 0;
1205 } 1187 }
1206 1188
1207 bool ok; 1189 bool ok;
1208 int lineNumber = number.toInt(&ok, 10); 1190 int lineNumber = number.toInt(&ok, 10);
1209 if( editor->numLines() < lineNumber) 1191 if( editor->numLines() < lineNumber)
1210 QMessageBox::message(tr("Text Edit"),tr("Not enough lines")); 1192 QMessageBox::message(tr("Text Edit"),tr("Not enough lines"));
1211 else 1193 else
1212 { 1194 {
1213 editor->setCursorPosition(lineNumber, 0, false); 1195 editor->setCursorPosition(lineNumber, 0, false);
1214 } 1196 }
1215} 1197}