summaryrefslogtreecommitdiff
authorchicken <chicken>2004-03-01 16:53:58 (UTC)
committer chicken <chicken>2004-03-01 16:53:58 (UTC)
commit8de0eea414192d758746a5f3950b9765e9709bf9 (patch) (unidiff)
tree75f7c619ba161f395c058691af152226992d20a7
parent49615014f281a58bd9bde5543692ffddab052755 (diff)
downloadopie-8de0eea414192d758746a5f3950b9765e9709bf9.zip
opie-8de0eea414192d758746a5f3950b9765e9709bf9.tar.gz
opie-8de0eea414192d758746a5f3950b9765e9709bf9.tar.bz2
fix includes
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,262 +1,261 @@
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);
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,261 +1,252 @@
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")
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,226 +1,221 @@
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.
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,270 +1,267 @@
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();
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
@@ -224,483 +224,482 @@ void KeytabReader::getSymbol()
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,262 +1,241 @@
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) :
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,245 +1,223 @@
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 ) {
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,216 +1,212 @@
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
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,243 +1,225 @@
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 );