-rw-r--r-- | core/apps/embeddedkonsole/MyPty.cpp | 1 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/TEWidget.cpp | 9 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/TEmuVt102.cpp | 5 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/TEmulation.cpp | 3 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/commandeditdialog.cpp | 8 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/commandeditwidget.cpp | 4 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/keytrans.cpp | 3 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/konsole.cpp | 21 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/playlistselection.cpp | 7 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/session.cpp | 1 | ||||
-rw-r--r-- | core/apps/helpbrowser/helpbrowser.cpp | 24 | ||||
-rw-r--r-- | core/apps/helpbrowser/magictextbrowser.cpp | 2 | ||||
-rw-r--r-- | core/apps/oapp/oappplugin.cpp | 3 | ||||
-rw-r--r-- | core/apps/qcop/main.cpp | 2 | ||||
-rw-r--r-- | core/apps/taboapp/main.cpp | 1 | ||||
-rw-r--r-- | core/apps/textedit/filePermissions.cpp | 4 | ||||
-rw-r--r-- | core/apps/textedit/textedit.cpp | 18 |
17 files changed, 2 insertions, 114 deletions
diff --git a/core/apps/embeddedkonsole/MyPty.cpp b/core/apps/embeddedkonsole/MyPty.cpp index 5a8519a..d05e31e 100644 --- a/core/apps/embeddedkonsole/MyPty.cpp +++ b/core/apps/embeddedkonsole/MyPty.cpp | |||
@@ -1,289 +1,288 @@ | |||
1 | /* -------------------------------------------------------------------------- */ | 1 | /* -------------------------------------------------------------------------- */ |
2 | /* */ | 2 | /* */ |
3 | /* [MyPty.C] Pseudo Terminal Device */ | 3 | /* [MyPty.C] Pseudo Terminal Device */ |
4 | /* */ | 4 | /* */ |
5 | /* -------------------------------------------------------------------------- */ | 5 | /* -------------------------------------------------------------------------- */ |
6 | /* */ | 6 | /* */ |
7 | /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ | 7 | /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ |
8 | /* */ | 8 | /* */ |
9 | /* This file is part of Konsole - an X terminal for KDE */ | 9 | /* This file is part of Konsole - an X terminal for KDE */ |
10 | /* -------------------------------------------------------------------------- */ | 10 | /* -------------------------------------------------------------------------- */ |
11 | /* */ | 11 | /* */ |
12 | /* Ported Konsole to Qt/Embedded */ | 12 | /* Ported Konsole to Qt/Embedded */ |
13 | /* */ | 13 | /* */ |
14 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ | 14 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ |
15 | /* */ | 15 | /* */ |
16 | /* -------------------------------------------------------------------------- */ | 16 | /* -------------------------------------------------------------------------- */ |
17 | 17 | ||
18 | /* If you're compiling konsole on non-Linux platforms and find | 18 | /* If you're compiling konsole on non-Linux platforms and find |
19 | problems that you can track down to this file, please have | 19 | problems that you can track down to this file, please have |
20 | a look into ../README.ports, too. | 20 | a look into ../README.ports, too. |
21 | */ | 21 | */ |
22 | 22 | ||
23 | /*! \file | 23 | /*! \file |
24 | */ | 24 | */ |
25 | 25 | ||
26 | /*! \class TEPty | 26 | /*! \class TEPty |
27 | 27 | ||
28 | \brief Ptys provide a pseudo terminal connection to a program. | 28 | \brief Ptys provide a pseudo terminal connection to a program. |
29 | 29 | ||
30 | Although closely related to pipes, these pseudo terminal connections have | 30 | Although closely related to pipes, these pseudo terminal connections have |
31 | some ability, that makes it nessesary to uses them. Most importent, they | 31 | some ability, that makes it nessesary to uses them. Most importent, they |
32 | know about changing screen sizes and UNIX job control. | 32 | know about changing screen sizes and UNIX job control. |
33 | 33 | ||
34 | Within the terminal emulation framework, this class represents the | 34 | Within the terminal emulation framework, this class represents the |
35 | host side of the terminal together with the connecting serial line. | 35 | host side of the terminal together with the connecting serial line. |
36 | 36 | ||
37 | One can create many instances of this class within a program. | 37 | One can create many instances of this class within a program. |
38 | As a side effect of using this class, a signal(2) handler is | 38 | As a side effect of using this class, a signal(2) handler is |
39 | installed on SIGCHLD. | 39 | installed on SIGCHLD. |
40 | 40 | ||
41 | \par FIXME | 41 | \par FIXME |
42 | 42 | ||
43 | [NOTE: much of the technical stuff below will be replaced by forkpty.] | 43 | [NOTE: much of the technical stuff below will be replaced by forkpty.] |
44 | 44 | ||
45 | publish the SIGCHLD signal if not related to an instance. | 45 | publish the SIGCHLD signal if not related to an instance. |
46 | 46 | ||
47 | clearify TEPty::done vs. TEPty::~TEPty semantics. | 47 | clearify TEPty::done vs. TEPty::~TEPty semantics. |
48 | check if pty is restartable via run after done. | 48 | check if pty is restartable via run after done. |
49 | 49 | ||
50 | \par Pseudo terminals | 50 | \par Pseudo terminals |
51 | 51 | ||
52 | Pseudo terminals are a unique feature of UNIX, and always come in form of | 52 | Pseudo terminals are a unique feature of UNIX, and always come in form of |
53 | pairs of devices (/dev/ptyXX and /dev/ttyXX), which are connected to each | 53 | pairs of devices (/dev/ptyXX and /dev/ttyXX), which are connected to each |
54 | other by the operating system. One may think of them as two serial devices | 54 | other by the operating system. One may think of them as two serial devices |
55 | linked by a null-modem cable. Being based on devices the number of | 55 | linked by a null-modem cable. Being based on devices the number of |
56 | simultanous instances of this class is (globally) limited by the number of | 56 | simultanous instances of this class is (globally) limited by the number of |
57 | those device pairs, which is 256. | 57 | those device pairs, which is 256. |
58 | 58 | ||
59 | Another technic are UNIX 98 PTY's. These are supported also, and prefered | 59 | Another technic are UNIX 98 PTY's. These are supported also, and prefered |
60 | over the (obsolete) predecessor. | 60 | over the (obsolete) predecessor. |
61 | 61 | ||
62 | There's a sinister ioctl(2), signal(2) and job control stuff | 62 | There's a sinister ioctl(2), signal(2) and job control stuff |
63 | nessesary to make everything work as it should. | 63 | nessesary to make everything work as it should. |
64 | */ | 64 | */ |
65 | 65 | ||
66 | 66 | ||
67 | #include <qfileinfo.h> | 67 | #include <qfileinfo.h> |
68 | #include <qapplication.h> | 68 | #include <qapplication.h> |
69 | #include <qsocketnotifier.h> | 69 | #include <qsocketnotifier.h> |
70 | #include <qstring.h> | ||
71 | 70 | ||
72 | #include <stdlib.h> | 71 | #include <stdlib.h> |
73 | #include <stdio.h> | 72 | #include <stdio.h> |
74 | #include <signal.h> | 73 | #include <signal.h> |
75 | #include <fcntl.h> | 74 | #include <fcntl.h> |
76 | #include <unistd.h> | 75 | #include <unistd.h> |
77 | #include <termios.h> | 76 | #include <termios.h> |
78 | #include <sys/types.h> | 77 | #include <sys/types.h> |
79 | #include <sys/ioctl.h> | 78 | #include <sys/ioctl.h> |
80 | #include <sys/wait.h> | 79 | #include <sys/wait.h> |
81 | 80 | ||
82 | #ifdef HAVE_OPENPTY | 81 | #ifdef HAVE_OPENPTY |
83 | #include <pty.h> | 82 | #include <pty.h> |
84 | #endif | 83 | #endif |
85 | 84 | ||
86 | #include "MyPty.h" | 85 | #include "MyPty.h" |
87 | 86 | ||
88 | 87 | ||
89 | #undef VERBOSE_DEBUG | 88 | #undef VERBOSE_DEBUG |
90 | 89 | ||
91 | 90 | ||
92 | /* -------------------------------------------------------------------------- */ | 91 | /* -------------------------------------------------------------------------- */ |
93 | 92 | ||
94 | /*! | 93 | /*! |
95 | Informs the client program about the | 94 | Informs the client program about the |
96 | actual size of the window. | 95 | actual size of the window. |
97 | */ | 96 | */ |
98 | 97 | ||
99 | void MyPty::setSize(int lines, int columns) | 98 | void 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 | ||
109 | void MyPty::donePty() | 108 | void 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 | ||
125 | const char* MyPty::deviceName() | 124 | const char* MyPty::deviceName() |
126 | { | 125 | { |
127 | return ttynam; | 126 | return ttynam; |
128 | } | 127 | } |
129 | 128 | ||
130 | 129 | ||
131 | void MyPty::error() | 130 | void 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 | */ |
141 | int MyPty::run(const char* cmd, QStrList &, const char*, int) | 140 | int 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 | ||
197 | int MyPty::openPty() | 196 | int 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 | */ |
234 | MyPty::MyPty() : cpid(0) | 233 | MyPty::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 | */ |
244 | MyPty::~MyPty() | 243 | MyPty::~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 */ |
251 | void MyPty::send_bytes(const char* s, int len) | 250 | void MyPty::send_bytes(const char* s, int len) |
252 | { | 251 | { |
253 | 252 | ||
254 | #ifdef VERBOSE_DEBUG | 253 | #ifdef VERBOSE_DEBUG |
255 | // verbose debug | 254 | // verbose debug |
256 | printf("sending bytes:\n"); | 255 | printf("sending bytes:\n"); |
257 | for (int i = 0; i < len; i++) | 256 | for (int i = 0; i < len; i++) |
258 | printf("%c", s[i]); | 257 | printf("%c", s[i]); |
259 | printf("\n"); | 258 | printf("\n"); |
260 | #endif | 259 | #endif |
261 | 260 | ||
262 | ::write(fd, s, len); | 261 | ::write(fd, s, len); |
263 | } | 262 | } |
264 | 263 | ||
265 | /*! indicates that a block of data is received */ | 264 | /*! indicates that a block of data is received */ |
266 | void MyPty::readPty() | 265 | void MyPty::readPty() |
267 | { | 266 | { |
268 | char buf[4096]; | 267 | char buf[4096]; |
269 | 268 | ||
270 | int len = ::read( fd, buf, 4096 ); | 269 | int len = ::read( fd, buf, 4096 ); |
271 | 270 | ||
272 | if (len == -1) | 271 | if (len == -1) |
273 | donePty(); | 272 | donePty(); |
274 | 273 | ||
275 | if (len < 0) | 274 | if (len < 0) |
276 | return; | 275 | return; |
277 | 276 | ||
278 | emit block_in(buf,len); | 277 | emit block_in(buf,len); |
279 | 278 | ||
280 | #ifdef VERBOSE_DEBUG | 279 | #ifdef VERBOSE_DEBUG |
281 | // verbose debug | 280 | // verbose debug |
282 | printf("read bytes:\n"); | 281 | printf("read bytes:\n"); |
283 | for (int i = 0; i < len; i++) | 282 | for (int i = 0; i < len; i++) |
284 | printf("%c", buf[i]); | 283 | printf("%c", buf[i]); |
285 | printf("\n"); | 284 | printf("\n"); |
286 | #endif | 285 | #endif |
287 | 286 | ||
288 | } | 287 | } |
289 | 288 | ||
diff --git a/core/apps/embeddedkonsole/TEWidget.cpp b/core/apps/embeddedkonsole/TEWidget.cpp index de5e585..8206e4b 100644 --- a/core/apps/embeddedkonsole/TEWidget.cpp +++ b/core/apps/embeddedkonsole/TEWidget.cpp | |||
@@ -1,837 +1,828 @@ | |||
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. |
110 | static const ColorEntry base_color_table[TABLE_COLORS] = | 101 | static 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 | ||
138 | QColor TEWidget::getDefaultBackColor() | 129 | QColor TEWidget::getDefaultBackColor() |
139 | { | 130 | { |
140 | return color_table[DEFAULT_BACK_COLOR].color; | 131 | return color_table[DEFAULT_BACK_COLOR].color; |
141 | } | 132 | } |
142 | 133 | ||
143 | const ColorEntry* TEWidget::getColorTable() const | 134 | const ColorEntry* TEWidget::getColorTable() const |
144 | { | 135 | { |
145 | return color_table; | 136 | return color_table; |
146 | } | 137 | } |
147 | 138 | ||
148 | const ColorEntry* TEWidget::getdefaultColorTable() const | 139 | const ColorEntry* TEWidget::getdefaultColorTable() const |
149 | { | 140 | { |
150 | return base_color_table; | 141 | return base_color_table; |
151 | } | 142 | } |
152 | 143 | ||
153 | 144 | ||
154 | const QPixmap *TEWidget::backgroundPixmap() | 145 | const 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 | ||
161 | void TEWidget::setColorTable(const ColorEntry table[]) | 152 | void 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 | ||
192 | unsigned short vt100_graphics[32] = | 183 | unsigned 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 | ||
200 | static QChar vt100extended(QChar c) | 191 | static 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 | ||
239 | static QChar identicalMap(QChar c) | 230 | static QChar identicalMap(QChar c) |
240 | { | 231 | { |
241 | return c; | 232 | return c; |
242 | } | 233 | } |
243 | 234 | ||
244 | void TEWidget::fontChange(const QFont &) | 235 | void TEWidget::fontChange(const QFont &) |
245 | { | 236 | { |
246 | QFontMetrics fm(font()); | 237 | QFontMetrics fm(font()); |
247 | font_h = fm.height(); | 238 | font_h = fm.height(); |
248 | // font_w = fm.maxWidth(); | 239 | // font_w = fm.maxWidth(); |
249 | font_w = fm.width("m"); | 240 | font_w = fm.width("m"); |
250 | font_a = fm.ascent(); | 241 | font_a = fm.ascent(); |
251 | printf("font h=%d max_width=%d width_m=%d assent=%d\n", font_h, | 242 | printf("font h=%d max_width=%d width_m=%d assent=%d\n", font_h, |
252 | fm.maxWidth(), font_w, font_a); | 243 | fm.maxWidth(), font_w, font_a); |
253 | 244 | ||
254 | //printf("font_h: %d\n",font_h); | 245 | //printf("font_h: %d\n",font_h); |
255 | //printf("font_w: %d\n",font_w); | 246 | //printf("font_w: %d\n",font_w); |
256 | //printf("font_a: %d\n",font_a); | 247 | //printf("font_a: %d\n",font_a); |
257 | //printf("charset: %s\n",QFont::encodingName(font().charSet()).ascii()); | 248 | //printf("charset: %s\n",QFont::encodingName(font().charSet()).ascii()); |
258 | //printf("rawname: %s\n",font().rawName().ascii()); | 249 | //printf("rawname: %s\n",font().rawName().ascii()); |
259 | fontMap = | 250 | fontMap = |
260 | #if QT_VERSION < 300 | 251 | #if QT_VERSION < 300 |
261 | strcmp(QFont::encodingName(font().charSet()).ascii(),"iso10646") | 252 | strcmp(QFont::encodingName(font().charSet()).ascii(),"iso10646") |
262 | ? vt100extended | 253 | ? vt100extended |
263 | : | 254 | : |
264 | #endif | 255 | #endif |
265 | identicalMap; | 256 | identicalMap; |
266 | propagateSize(); | 257 | propagateSize(); |
267 | update(); | 258 | update(); |
268 | } | 259 | } |
269 | 260 | ||
270 | void TEWidget::setVTFont(const QFont& f) | 261 | void TEWidget::setVTFont(const QFont& f) |
271 | { | 262 | { |
272 | QFrame::setFont(f); | 263 | QFrame::setFont(f); |
273 | } | 264 | } |
274 | 265 | ||
275 | QFont TEWidget::getVTFont() { | 266 | QFont TEWidget::getVTFont() { |
276 | return font(); | 267 | return font(); |
277 | } | 268 | } |
278 | 269 | ||
279 | void TEWidget::setFont(const QFont &) | 270 | void TEWidget::setFont(const QFont &) |
280 | { | 271 | { |
281 | // ignore font change request if not coming from konsole itself | 272 | // ignore font change request if not coming from konsole itself |
282 | } | 273 | } |
283 | 274 | ||
284 | /* ------------------------------------------------------------------------- */ | 275 | /* ------------------------------------------------------------------------- */ |
285 | /* */ | 276 | /* */ |
286 | /* Constructor / Destructor */ | 277 | /* Constructor / Destructor */ |
287 | /* */ | 278 | /* */ |
288 | /* ------------------------------------------------------------------------- */ | 279 | /* ------------------------------------------------------------------------- */ |
289 | 280 | ||
290 | TEWidget::TEWidget(QWidget *parent, const char *name) : QFrame(parent,name) | 281 | TEWidget::TEWidget(QWidget *parent, const char *name) : QFrame(parent,name) |
291 | { | 282 | { |
292 | #ifndef QT_NO_CLIPBOARD | 283 | #ifndef QT_NO_CLIPBOARD |
293 | cb = QApplication::clipboard(); | 284 | cb = QApplication::clipboard(); |
294 | QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), | 285 | QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), |
295 | this, SLOT(onClearSelection()) ); | 286 | this, SLOT(onClearSelection()) ); |
296 | #endif | 287 | #endif |
297 | 288 | ||
298 | scrollbar = new QScrollBar(this); | 289 | scrollbar = new QScrollBar(this); |
299 | scrollbar->setCursor( arrowCursor ); | 290 | scrollbar->setCursor( arrowCursor ); |
300 | connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); | 291 | connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); |
301 | 292 | ||
302 | hScrollbar = new QScrollBar(this); | 293 | hScrollbar = new QScrollBar(this); |
303 | hScrollbar->setCursor( arrowCursor ); | 294 | hScrollbar->setCursor( arrowCursor ); |
304 | hScrollbar->setOrientation(QScrollBar::Horizontal); | 295 | hScrollbar->setOrientation(QScrollBar::Horizontal); |
305 | // hScrollbar->setMaximumHeight(16); | 296 | // hScrollbar->setMaximumHeight(16); |
306 | 297 | ||
307 | connect( hScrollbar, SIGNAL(valueChanged(int)), this, SLOT( hScrollChanged(int))); | 298 | connect( hScrollbar, SIGNAL(valueChanged(int)), this, SLOT( hScrollChanged(int))); |
308 | 299 | ||
309 | Config cfg( "Konsole" ); | 300 | Config cfg( "Konsole" ); |
310 | cfg.setGroup("ScrollBar"); | 301 | cfg.setGroup("ScrollBar"); |
311 | switch( cfg.readNumEntry("Position",2)){ | 302 | switch( cfg.readNumEntry("Position",2)){ |
312 | case 0: | 303 | case 0: |
313 | scrollLoc = SCRNONE; | 304 | scrollLoc = SCRNONE; |
314 | break; | 305 | break; |
315 | case 1: | 306 | case 1: |
316 | scrollLoc = SCRLEFT; | 307 | scrollLoc = SCRLEFT; |
317 | break; | 308 | break; |
318 | case 2: | 309 | case 2: |
319 | scrollLoc = SCRRIGHT; | 310 | scrollLoc = SCRRIGHT; |
320 | break; | 311 | break; |
321 | }; | 312 | }; |
322 | 313 | ||
323 | useHorzScroll=cfg.readBoolEntry("HorzScroll",0); | 314 | useHorzScroll=cfg.readBoolEntry("HorzScroll",0); |
324 | 315 | ||
325 | blinkT = new QTimer(this); | 316 | blinkT = new QTimer(this); |
326 | connect(blinkT, SIGNAL(timeout()), this, SLOT(blinkEvent())); | 317 | connect(blinkT, SIGNAL(timeout()), this, SLOT(blinkEvent())); |
327 | // blinking = FALSE; | 318 | // blinking = FALSE; |
328 | blinking = TRUE; | 319 | blinking = TRUE; |
329 | 320 | ||
330 | resizing = FALSE; | 321 | resizing = FALSE; |
331 | actSel = 0; | 322 | actSel = 0; |
332 | image = 0; | 323 | image = 0; |
333 | lines = 1; | 324 | lines = 1; |
334 | columns = 1; | 325 | columns = 1; |
335 | font_w = 1; | 326 | font_w = 1; |
336 | font_h = 1; | 327 | font_h = 1; |
337 | font_a = 1; | 328 | font_a = 1; |
338 | word_selection_mode = FALSE; | 329 | word_selection_mode = FALSE; |
339 | hposition = 0; | 330 | hposition = 0; |
340 | vcolumns = 0; | 331 | vcolumns = 0; |
341 | useBeep = true; | 332 | useBeep = true; |
342 | 333 | ||
343 | setMouseMarks(TRUE); | 334 | setMouseMarks(TRUE); |
344 | setVTFont( QFont("fixed") ); | 335 | setVTFont( QFont("fixed") ); |
345 | setColorTable(base_color_table); // init color table | 336 | setColorTable(base_color_table); // init color table |
346 | 337 | ||
347 | qApp->installEventFilter( this ); //FIXME: see below | 338 | qApp->installEventFilter( this ); //FIXME: see below |
348 | // KCursor::setAutoHideCursor( this, true ); | 339 | // KCursor::setAutoHideCursor( this, true ); |
349 | 340 | ||
350 | // Init DnD //////////////////////////////////////////////////////////////// | 341 | // Init DnD //////////////////////////////////////////////////////////////// |
351 | currentSession = NULL; | 342 | currentSession = NULL; |
352 | // setAcceptDrops(true); // attempt | 343 | // setAcceptDrops(true); // attempt |
353 | // m_drop = new QPopupMenu(this); | 344 | // m_drop = new QPopupMenu(this); |
354 | // m_drop->insertItem( QString("Paste"), 0); | 345 | // m_drop->insertItem( QString("Paste"), 0); |
355 | // m_drop->insertItem( QString("cd"), 1); | 346 | // m_drop->insertItem( QString("cd"), 1); |
356 | // connect(m_drop, SIGNAL(activated(int)), SLOT(drop_menu_activated(int))); | 347 | // connect(m_drop, SIGNAL(activated(int)), SLOT(drop_menu_activated(int))); |
357 | 348 | ||
358 | // we need focus so that the auto-hide cursor feature works | 349 | // we need focus so that the auto-hide cursor feature works |
359 | setFocus(); | 350 | setFocus(); |
360 | setFocusPolicy( WheelFocus ); | 351 | setFocusPolicy( WheelFocus ); |
361 | } | 352 | } |
362 | 353 | ||
363 | //FIXME: make proper destructor | 354 | //FIXME: make proper destructor |
364 | // Here's a start (David) | 355 | // Here's a start (David) |
365 | TEWidget::~TEWidget() | 356 | TEWidget::~TEWidget() |
366 | { | 357 | { |
367 | qApp->removeEventFilter( this ); | 358 | qApp->removeEventFilter( this ); |
368 | if (image) free(image); | 359 | if (image) free(image); |
369 | } | 360 | } |
370 | 361 | ||
371 | /* ------------------------------------------------------------------------- */ | 362 | /* ------------------------------------------------------------------------- */ |
372 | /* */ | 363 | /* */ |
373 | /* Display Operations */ | 364 | /* Display Operations */ |
374 | /* */ | 365 | /* */ |
375 | /* ------------------------------------------------------------------------- */ | 366 | /* ------------------------------------------------------------------------- */ |
376 | 367 | ||
377 | /*! | 368 | /*! |
378 | attributed string draw primitive | 369 | attributed string draw primitive |
379 | */ | 370 | */ |
380 | 371 | ||
381 | void TEWidget::drawAttrStr(QPainter &paint, QRect rect, | 372 | void TEWidget::drawAttrStr(QPainter &paint, QRect rect, |
382 | QString& str, ca attr, BOOL pm, BOOL clear) | 373 | QString& str, ca attr, BOOL pm, BOOL clear) |
383 | { | 374 | { |
384 | if (pm && color_table[attr.b].transparent) | 375 | if (pm && color_table[attr.b].transparent) |
385 | { | 376 | { |
386 | paint.setBackgroundMode( TransparentMode ); | 377 | paint.setBackgroundMode( TransparentMode ); |
387 | if (clear) erase(rect); | 378 | if (clear) erase(rect); |
388 | } | 379 | } |
389 | else | 380 | else |
390 | { | 381 | { |
391 | if (blinking) | 382 | if (blinking) |
392 | paint.fillRect(rect, color_table[attr.b].color); | 383 | paint.fillRect(rect, color_table[attr.b].color); |
393 | else | 384 | else |
394 | { | 385 | { |
395 | paint.setBackgroundMode( OpaqueMode ); | 386 | paint.setBackgroundMode( OpaqueMode ); |
396 | paint.setBackgroundColor( color_table[attr.b].color ); | 387 | paint.setBackgroundColor( color_table[attr.b].color ); |
397 | } | 388 | } |
398 | } | 389 | } |
399 | 390 | ||
400 | if (color_table[attr.f].bold) | 391 | if (color_table[attr.f].bold) |
401 | paint.setPen(QColor( 0x8F, 0x00, 0x00 )); | 392 | paint.setPen(QColor( 0x8F, 0x00, 0x00 )); |
402 | else | 393 | else |
403 | paint.setPen(color_table[attr.f].color); | 394 | paint.setPen(color_table[attr.f].color); |
404 | 395 | ||
405 | paint.drawText(rect.x(),rect.y()+font_a, str); | 396 | paint.drawText(rect.x(),rect.y()+font_a, str); |
406 | 397 | ||
407 | if (attr.r & RE_UNDERLINE) | 398 | if (attr.r & RE_UNDERLINE) |
408 | paint.drawLine(rect.left(), rect.y()+font_a+1, rect.right(),rect.y()+font_a+1 ); | 399 | paint.drawLine(rect.left(), rect.y()+font_a+1, rect.right(),rect.y()+font_a+1 ); |
409 | } | 400 | } |
410 | 401 | ||
411 | /*! | 402 | /*! |
412 | The image can only be set completely. | 403 | The image can only be set completely. |
413 | 404 | ||
414 | The size of the new image may or may not match the size of the widget. | 405 | The size of the new image may or may not match the size of the widget. |
415 | */ | 406 | */ |
416 | 407 | ||
417 | void TEWidget::setImage(const ca* const newimg, int lines, int columns) | 408 | void TEWidget::setImage(const ca* const newimg, int lines, int columns) |
418 | { int y,x,len; | 409 | { int y,x,len; |
419 | const QPixmap* pm = backgroundPixmap(); | 410 | const QPixmap* pm = backgroundPixmap(); |
420 | QPainter paint; | 411 | QPainter paint; |
421 | setUpdatesEnabled(FALSE); | 412 | setUpdatesEnabled(FALSE); |
422 | paint.begin( this ); | 413 | paint.begin( this ); |
423 | HCNT("setImage"); | 414 | HCNT("setImage"); |
424 | 415 | ||
425 | QPoint tL = contentsRect().topLeft(); | 416 | QPoint tL = contentsRect().topLeft(); |
426 | int tLx = tL.x(); | 417 | int tLx = tL.x(); |
427 | int tLy = tL.y(); | 418 | int tLy = tL.y(); |
428 | hasBlinker = FALSE; | 419 | hasBlinker = FALSE; |
429 | 420 | ||
430 | int cf = -1; // undefined | 421 | int cf = -1; // undefined |
431 | int cb = -1; // undefined | 422 | int cb = -1; // undefined |
432 | int cr = -1; // undefined | 423 | int cr = -1; // undefined |
433 | 424 | ||
434 | int lins = QMIN(this->lines, QMAX(0,lines )); | 425 | int lins = QMIN(this->lines, QMAX(0,lines )); |
435 | int cols = QMIN(this->columns,QMAX(0,columns)); | 426 | int cols = QMIN(this->columns,QMAX(0,columns)); |
436 | QChar *disstrU = new QChar[cols]; | 427 | QChar *disstrU = new QChar[cols]; |
437 | for (y = 0; y < lins; y++) { | 428 | for (y = 0; y < lins; y++) { |
438 | const ca* lcl = &image[y*this->columns]; | 429 | const ca* lcl = &image[y*this->columns]; |
439 | const ca* const ext = &newimg[y*columns]; | 430 | const ca* const ext = &newimg[y*columns]; |
440 | if (!resizing) // not while resizing, we're expecting a paintEvent | 431 | if (!resizing) // not while resizing, we're expecting a paintEvent |
441 | for (x = 0; x < cols; x++) | 432 | for (x = 0; x < cols; x++) |
442 | { | 433 | { |
443 | hasBlinker |= (ext[x].r & RE_BLINK); | 434 | hasBlinker |= (ext[x].r & RE_BLINK); |
444 | if (ext[x] != lcl[x]) | 435 | if (ext[x] != lcl[x]) |
445 | { | 436 | { |
446 | cr = ext[x].r; | 437 | cr = ext[x].r; |
447 | cb = ext[x].b; | 438 | cb = ext[x].b; |
448 | if (ext[x].f != cf) cf = ext[x].f; | 439 | if (ext[x].f != cf) cf = ext[x].f; |
449 | int lln = cols - x; | 440 | int lln = cols - x; |
450 | disstrU[0] = fontMap(ext[x+0].c); | 441 | disstrU[0] = fontMap(ext[x+0].c); |
451 | for (len = 1; len < lln; len++) | 442 | for (len = 1; len < lln; len++) |
452 | { | 443 | { |
453 | if (ext[x+len].f != cf || ext[x+len].b != cb || ext[x+len].r != cr || | 444 | if (ext[x+len].f != cf || ext[x+len].b != cb || ext[x+len].r != cr || |
454 | ext[x+len] == lcl[x+len] ) | 445 | ext[x+len] == lcl[x+len] ) |
455 | break; | 446 | break; |
456 | disstrU[len] = fontMap(ext[x+len].c); | 447 | disstrU[len] = fontMap(ext[x+len].c); |
457 | } | 448 | } |
458 | QString unistr(disstrU,len); | 449 | QString unistr(disstrU,len); |
459 | drawAttrStr(paint, | 450 | drawAttrStr(paint, |
460 | QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h), | 451 | QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h), |
461 | unistr, ext[x], pm != NULL, true); | 452 | unistr, ext[x], pm != NULL, true); |
462 | x += len - 1; | 453 | x += len - 1; |
463 | } | 454 | } |
464 | } | 455 | } |
465 | // finally, make `image' become `newimg'. | 456 | // finally, make `image' become `newimg'. |
466 | memcpy((void*)lcl,(const void*)ext,cols*sizeof(ca)); | 457 | memcpy((void*)lcl,(const void*)ext,cols*sizeof(ca)); |
467 | } | 458 | } |
468 | drawFrame( &paint ); | 459 | drawFrame( &paint ); |
469 | paint.end(); | 460 | paint.end(); |
470 | setUpdatesEnabled(TRUE); | 461 | setUpdatesEnabled(TRUE); |
471 | if ( hasBlinker && !blinkT->isActive()) blinkT->start(1000); // 1000 ms | 462 | if ( hasBlinker && !blinkT->isActive()) blinkT->start(1000); // 1000 ms |
472 | if (!hasBlinker && blinkT->isActive()) { blinkT->stop(); blinking = FALSE; } | 463 | if (!hasBlinker && blinkT->isActive()) { blinkT->stop(); blinking = FALSE; } |
473 | delete [] disstrU; | 464 | delete [] disstrU; |
474 | } | 465 | } |
475 | 466 | ||
476 | // paint Event //////////////////////////////////////////////////// | 467 | // paint Event //////////////////////////////////////////////////// |
477 | 468 | ||
478 | /*! | 469 | /*! |
479 | The difference of this routine vs. the `setImage' is, | 470 | The difference of this routine vs. the `setImage' is, |
480 | that the drawing does not include a difference analysis | 471 | that the drawing does not include a difference analysis |
481 | between the old and the new image. Instead, the internal | 472 | between the old and the new image. Instead, the internal |
482 | image is used and the painting bound by the PaintEvent box. | 473 | image is used and the painting bound by the PaintEvent box. |
483 | */ | 474 | */ |
484 | 475 | ||
485 | void TEWidget::paintEvent( QPaintEvent* pe ) | 476 | void TEWidget::paintEvent( QPaintEvent* pe ) |
486 | { | 477 | { |
487 | 478 | ||
488 | //{ static int cnt = 0; printf("paint %d\n",cnt++); } | 479 | //{ static int cnt = 0; printf("paint %d\n",cnt++); } |
489 | const QPixmap* pm = backgroundPixmap(); | 480 | const QPixmap* pm = backgroundPixmap(); |
490 | QPainter paint; | 481 | QPainter paint; |
491 | setUpdatesEnabled(FALSE); | 482 | setUpdatesEnabled(FALSE); |
492 | paint.begin( this ); | 483 | paint.begin( this ); |
493 | paint.setBackgroundMode( TransparentMode ); | 484 | paint.setBackgroundMode( TransparentMode ); |
494 | HCNT("paintEvent"); | 485 | HCNT("paintEvent"); |
495 | 486 | ||
496 | // Note that the actual widget size can be slightly larger | 487 | // Note that the actual widget size can be slightly larger |
497 | // that the image (the size is truncated towards the smaller | 488 | // that the image (the size is truncated towards the smaller |
498 | // number of characters in `resizeEvent'. The paint rectangle | 489 | // number of characters in `resizeEvent'. The paint rectangle |
499 | // can thus be larger than the image, but less then the size | 490 | // can thus be larger than the image, but less then the size |
500 | // of one character. | 491 | // of one character. |
501 | 492 | ||
502 | QRect rect = pe->rect().intersect(contentsRect()); | 493 | QRect rect = pe->rect().intersect(contentsRect()); |
503 | 494 | ||
504 | QPoint tL = contentsRect().topLeft(); | 495 | QPoint tL = contentsRect().topLeft(); |
505 | int tLx = tL.x(); | 496 | int tLx = tL.x(); |
506 | int tLy = tL.y(); | 497 | int tLy = tL.y(); |
507 | 498 | ||
508 | int lux = QMIN(columns-1, QMAX(0,(rect.left() - tLx - blX ) / font_w)); | 499 | int lux = QMIN(columns-1, QMAX(0,(rect.left() - tLx - blX ) / font_w)); |
509 | int luy = QMIN(lines-1, QMAX(0,(rect.top() - tLy - bY ) / font_h)); | 500 | int luy = QMIN(lines-1, QMAX(0,(rect.top() - tLy - bY ) / font_h)); |
510 | int rlx = QMIN(columns-1, QMAX(0,(rect.right() - tLx - blX ) / font_w)); | 501 | int rlx = QMIN(columns-1, QMAX(0,(rect.right() - tLx - blX ) / font_w)); |
511 | int rly = QMIN(lines-1, QMAX(0,(rect.bottom() - tLy - bY ) / font_h)); | 502 | int rly = QMIN(lines-1, QMAX(0,(rect.bottom() - tLy - bY ) / font_h)); |
512 | 503 | ||
513 | /* | 504 | /* |
514 | printf("paintEvent: %d..%d, %d..%d (%d..%d, %d..%d)\n",lux,rlx,luy,rly, | 505 | printf("paintEvent: %d..%d, %d..%d (%d..%d, %d..%d)\n",lux,rlx,luy,rly, |
515 | rect.left(), rect.right(), rect.top(), rect.bottom()); | 506 | rect.left(), rect.right(), rect.top(), rect.bottom()); |
516 | */ | 507 | */ |
517 | 508 | ||
518 | // if (pm != NULL && color_table[image->b].transparent) | 509 | // if (pm != NULL && color_table[image->b].transparent) |
519 | // erase(rect); | 510 | // erase(rect); |
520 | // BL: I have no idea why we need this, and it breaks the refresh. | 511 | // BL: I have no idea why we need this, and it breaks the refresh. |
521 | 512 | ||
522 | QChar *disstrU = new QChar[columns]; | 513 | QChar *disstrU = new QChar[columns]; |
523 | for (int y = luy; y <= rly; y++) | 514 | for (int y = luy; y <= rly; y++) |
524 | for (int x = lux; x <= rlx; x++) | 515 | for (int x = lux; x <= rlx; x++) |
525 | { | 516 | { |
526 | int len = 1; | 517 | int len = 1; |
527 | disstrU[0] = fontMap(image[loc(x,y)].c); | 518 | disstrU[0] = fontMap(image[loc(x,y)].c); |
528 | int cf = image[loc(x,y)].f; | 519 | int cf = image[loc(x,y)].f; |
529 | int cb = image[loc(x,y)].b; | 520 | int cb = image[loc(x,y)].b; |
530 | int cr = image[loc(x,y)].r; | 521 | int cr = image[loc(x,y)].r; |
531 | while (x+len <= rlx && | 522 | while (x+len <= rlx && |
532 | image[loc(x+len,y)].f == cf && | 523 | image[loc(x+len,y)].f == cf && |
533 | image[loc(x+len,y)].b == cb && | 524 | image[loc(x+len,y)].b == cb && |
534 | image[loc(x+len,y)].r == cr ) | 525 | image[loc(x+len,y)].r == cr ) |
535 | { | 526 | { |
536 | disstrU[len] = fontMap(image[loc(x+len,y)].c); | 527 | disstrU[len] = fontMap(image[loc(x+len,y)].c); |
537 | len += 1; | 528 | len += 1; |
538 | } | 529 | } |
539 | QString unistr(disstrU,len); | 530 | QString unistr(disstrU,len); |
540 | drawAttrStr(paint, | 531 | drawAttrStr(paint, |
541 | QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h), | 532 | QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h), |
542 | unistr, image[loc(x,y)], pm != NULL, false); | 533 | unistr, image[loc(x,y)], pm != NULL, false); |
543 | x += len - 1; | 534 | x += len - 1; |
544 | } | 535 | } |
545 | delete [] disstrU; | 536 | delete [] disstrU; |
546 | drawFrame( &paint ); | 537 | drawFrame( &paint ); |
547 | paint.end(); | 538 | paint.end(); |
548 | setUpdatesEnabled(TRUE); | 539 | setUpdatesEnabled(TRUE); |
549 | } | 540 | } |
550 | 541 | ||
551 | void TEWidget::blinkEvent() | 542 | void TEWidget::blinkEvent() |
552 | { | 543 | { |
553 | blinking = !blinking; | 544 | blinking = !blinking; |
554 | repaint(FALSE); | 545 | repaint(FALSE); |
555 | } | 546 | } |
556 | 547 | ||
557 | /* ------------------------------------------------------------------------- */ | 548 | /* ------------------------------------------------------------------------- */ |
558 | /* */ | 549 | /* */ |
559 | /* Resizing */ | 550 | /* Resizing */ |
560 | /* */ | 551 | /* */ |
561 | /* ------------------------------------------------------------------------- */ | 552 | /* ------------------------------------------------------------------------- */ |
562 | 553 | ||
563 | void TEWidget::resizeEvent(QResizeEvent* ev) | 554 | void TEWidget::resizeEvent(QResizeEvent* ev) |
564 | { | 555 | { |
565 | // printf("resize: %d,%d\n",ev->size().width(),ev->size().height()); | 556 | // printf("resize: %d,%d\n",ev->size().width(),ev->size().height()); |
566 | //printf("approx: %d,%d\n",ev->size().width()/font_w,ev->size().height()/font_h); | 557 | //printf("approx: %d,%d\n",ev->size().width()/font_w,ev->size().height()/font_h); |
567 | //printf("leaves: %d,%d\n",ev->size().width()%font_w,ev->size().height()%font_h); | 558 | //printf("leaves: %d,%d\n",ev->size().width()%font_w,ev->size().height()%font_h); |
568 | //printf("curren: %d,%d\n",width(),height()); | 559 | //printf("curren: %d,%d\n",width(),height()); |
569 | HCNT("resizeEvent"); | 560 | HCNT("resizeEvent"); |
570 | 561 | ||
571 | // see comment in `paintEvent' concerning the rounding. | 562 | // see comment in `paintEvent' concerning the rounding. |
572 | //FIXME: could make a routine here; check width(),height() | 563 | //FIXME: could make a routine here; check width(),height() |
573 | assert(ev->size().width() == width()); | 564 | assert(ev->size().width() == width()); |
574 | assert(ev->size().height() == height()); | 565 | assert(ev->size().height() == height()); |
575 | 566 | ||
576 | propagateSize(); | 567 | propagateSize(); |
577 | } | 568 | } |
578 | 569 | ||
579 | void TEWidget::propagateSize() | 570 | void TEWidget::propagateSize() |
580 | { | 571 | { |
581 | ca* oldimg = image; | 572 | ca* oldimg = image; |
582 | int oldlin = lines; | 573 | int oldlin = lines; |
583 | int oldcol = columns; | 574 | int oldcol = columns; |
584 | makeImage(); | 575 | makeImage(); |
585 | // we copy the old image to reduce flicker | 576 | // we copy the old image to reduce flicker |
586 | int lins = QMIN(oldlin,lines); | 577 | int lins = QMIN(oldlin,lines); |
587 | int cols = QMIN(oldcol,columns); | 578 | int cols = QMIN(oldcol,columns); |
588 | if (oldimg) | 579 | if (oldimg) |
589 | { | 580 | { |
590 | for (int lin = 0; lin < lins; lin++) | 581 | for (int lin = 0; lin < lins; lin++) |
591 | memcpy((void*)&image[columns*lin], | 582 | memcpy((void*)&image[columns*lin], |
592 | (void*)&oldimg[oldcol*lin],cols*sizeof(ca)); | 583 | (void*)&oldimg[oldcol*lin],cols*sizeof(ca)); |
593 | free(oldimg); //FIXME: try new,delete | 584 | free(oldimg); //FIXME: try new,delete |
594 | } | 585 | } |
595 | else | 586 | else |
596 | clearImage(); | 587 | clearImage(); |
597 | 588 | ||
598 | //NOTE: control flows from the back through the chest right into the eye. | 589 | //NOTE: control flows from the back through the chest right into the eye. |
599 | // `emu' will call back via `setImage'. | 590 | // `emu' will call back via `setImage'. |
600 | 591 | ||
601 | resizing = TRUE; | 592 | resizing = TRUE; |
602 | emit changedImageSizeSignal(lines, columns); // expose resizeEvent | 593 | emit changedImageSizeSignal(lines, columns); // expose resizeEvent |
603 | resizing = FALSE; | 594 | resizing = FALSE; |
604 | } | 595 | } |
605 | 596 | ||
606 | /* ------------------------------------------------------------------------- */ | 597 | /* ------------------------------------------------------------------------- */ |
607 | /* */ | 598 | /* */ |
608 | /* Scrollbar */ | 599 | /* Scrollbar */ |
609 | /* */ | 600 | /* */ |
610 | /* ------------------------------------------------------------------------- */ | 601 | /* ------------------------------------------------------------------------- */ |
611 | 602 | ||
612 | void TEWidget::scrollChanged(int) { | 603 | void TEWidget::scrollChanged(int) { |
613 | emit changedHistoryCursor(scrollbar->value()); //expose | 604 | emit changedHistoryCursor(scrollbar->value()); //expose |
614 | } | 605 | } |
615 | 606 | ||
616 | void TEWidget::hScrollChanged(int loc) { | 607 | void TEWidget::hScrollChanged(int loc) { |
617 | hposition = loc; | 608 | hposition = loc; |
618 | propagateSize(); | 609 | propagateSize(); |
619 | update(); | 610 | update(); |
620 | 611 | ||
621 | // emit changedHorzCursor( hScrollbar->value()); //expose | 612 | // emit changedHorzCursor( hScrollbar->value()); //expose |
622 | } | 613 | } |
623 | 614 | ||
624 | void TEWidget::setScroll(int cursor, int slines) | 615 | void TEWidget::setScroll(int cursor, int slines) |
625 | { | 616 | { |
626 | disconnect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); | 617 | disconnect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); |
627 | scrollbar->setRange(0,slines); | 618 | scrollbar->setRange(0,slines); |
628 | scrollbar->setSteps(1,lines); | 619 | scrollbar->setSteps(1,lines); |
629 | scrollbar->setValue(cursor); | 620 | scrollbar->setValue(cursor); |
630 | connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); | 621 | connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); |
631 | } | 622 | } |
632 | 623 | ||
633 | void TEWidget::setScrollbarLocation(int loc) | 624 | void TEWidget::setScrollbarLocation(int loc) |
634 | { | 625 | { |
635 | if (scrollLoc == loc) return; // quickly | 626 | if (scrollLoc == loc) return; // quickly |
636 | scrollLoc = loc; | 627 | scrollLoc = loc; |
637 | propagateSize(); | 628 | propagateSize(); |
638 | update(); | 629 | update(); |
639 | } | 630 | } |
640 | 631 | ||
641 | /* ------------------------------------------------------------------------- */ | 632 | /* ------------------------------------------------------------------------- */ |
642 | /* */ | 633 | /* */ |
643 | /* Mouse */ | 634 | /* Mouse */ |
644 | /* */ | 635 | /* */ |
645 | /* ------------------------------------------------------------------------- */ | 636 | /* ------------------------------------------------------------------------- */ |
646 | 637 | ||
647 | /*! | 638 | /*! |
648 | Three different operations can be performed using the mouse, and the | 639 | Three different operations can be performed using the mouse, and the |
649 | routines in this section serve all of them: | 640 | routines in this section serve all of them: |
650 | 641 | ||
651 | 1) The press/release events are exposed to the application | 642 | 1) The press/release events are exposed to the application |
652 | 2) Marking (press and move left button) and Pasting (press middle button) | 643 | 2) Marking (press and move left button) and Pasting (press middle button) |
653 | 3) The right mouse button is used from the configuration menu | 644 | 3) The right mouse button is used from the configuration menu |
654 | 645 | ||
655 | NOTE: During the marking process we attempt to keep the cursor within | 646 | NOTE: During the marking process we attempt to keep the cursor within |
656 | the bounds of the text as being displayed by setting the mouse position | 647 | the bounds of the text as being displayed by setting the mouse position |
657 | whenever the mouse has left the text area. | 648 | whenever the mouse has left the text area. |
658 | 649 | ||
659 | Two reasons to do so: | 650 | Two reasons to do so: |
660 | 1) QT does not allow the `grabMouse' to confine-to the TEWidget. | 651 | 1) QT does not allow the `grabMouse' to confine-to the TEWidget. |
661 | Thus a `XGrapPointer' would have to be used instead. | 652 | Thus a `XGrapPointer' would have to be used instead. |
662 | 2) Even if so, this would not help too much, since the text area | 653 | 2) Even if so, this would not help too much, since the text area |
663 | of the TEWidget is normally not identical with it's bounds. | 654 | of the TEWidget is normally not identical with it's bounds. |
664 | 655 | ||
665 | The disadvantage of the current handling is, that the mouse can visibly | 656 | The disadvantage of the current handling is, that the mouse can visibly |
666 | leave the bounds of the widget and is then moved back. Because of the | 657 | leave the bounds of the widget and is then moved back. Because of the |
667 | current construction, and the reasons mentioned above, we cannot do better | 658 | current construction, and the reasons mentioned above, we cannot do better |
668 | without changing the overall construction. | 659 | without changing the overall construction. |
669 | */ | 660 | */ |
670 | 661 | ||
671 | /*! | 662 | /*! |
672 | */ | 663 | */ |
673 | 664 | ||
674 | void TEWidget::mousePressEvent(QMouseEvent* ev) | 665 | void TEWidget::mousePressEvent(QMouseEvent* ev) |
675 | { | 666 | { |
676 | //printf("press [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button()); | 667 | //printf("press [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button()); |
677 | if ( !contentsRect().contains(ev->pos()) ) return; | 668 | if ( !contentsRect().contains(ev->pos()) ) return; |
678 | QPoint tL = contentsRect().topLeft(); | 669 | QPoint tL = contentsRect().topLeft(); |
679 | int tLx = tL.x(); | 670 | int tLx = tL.x(); |
680 | int tLy = tL.y(); | 671 | int tLy = tL.y(); |
681 | 672 | ||
682 | mouse_down_x = ev->x(); | 673 | mouse_down_x = ev->x(); |
683 | mouse_down_y = ev->y(); | 674 | mouse_down_y = ev->y(); |
684 | 675 | ||
685 | //printf("press top left [%d,%d] by=%d\n",tLx,tLy, bY); | 676 | //printf("press top left [%d,%d] by=%d\n",tLx,tLy, bY); |
686 | if ( ev->button() == LeftButton) | 677 | if ( ev->button() == LeftButton) |
687 | { | 678 | { |
688 | QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); | 679 | QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); |
689 | 680 | ||
690 | word_selection_mode = (ev->state() & ShiftButton); | 681 | word_selection_mode = (ev->state() & ShiftButton); |
691 | 682 | ||
692 | if ( ev->state() & ControlButton ) preserve_line_breaks = FALSE ; | 683 | if ( ev->state() & ControlButton ) preserve_line_breaks = FALSE ; |
693 | 684 | ||
694 | if (mouse_marks || (ev->state() & ShiftButton)) | 685 | if (mouse_marks || (ev->state() & ShiftButton)) |
695 | { | 686 | { |
696 | emit clearSelectionSignal(); | 687 | emit clearSelectionSignal(); |
697 | iPntSel = pntSel = pos; | 688 | iPntSel = pntSel = pos; |
698 | actSel = 1; // left mouse button pressed but nothing selected yet. | 689 | actSel = 1; // left mouse button pressed but nothing selected yet. |
699 | grabMouse( /*crossCursor*/ ); // handle with care! | 690 | grabMouse( /*crossCursor*/ ); // handle with care! |
700 | } | 691 | } |
701 | else | 692 | else |
702 | { | 693 | { |
703 | emit mouseSignal( 0, pos.x() + 1, pos.y() + 1 ); // left button | 694 | emit mouseSignal( 0, pos.x() + 1, pos.y() + 1 ); // left button |
704 | } | 695 | } |
705 | } | 696 | } |
706 | if ( ev->button() == MidButton ) | 697 | if ( ev->button() == MidButton ) |
707 | { | 698 | { |
708 | emitSelection(); | 699 | emitSelection(); |
709 | } | 700 | } |
710 | if ( ev->button() == RightButton ) // Configure | 701 | if ( ev->button() == RightButton ) // Configure |
711 | { | 702 | { |
712 | emit configureRequest( this, ev->state()&(ShiftButton|ControlButton), ev->x(), ev->y() ); | 703 | emit configureRequest( this, ev->state()&(ShiftButton|ControlButton), ev->x(), ev->y() ); |
713 | } | 704 | } |
714 | } | 705 | } |
715 | 706 | ||
716 | void TEWidget::mouseMoveEvent(QMouseEvent* ev) | 707 | void TEWidget::mouseMoveEvent(QMouseEvent* ev) |
717 | { | 708 | { |
718 | // for auto-hiding the cursor, we need mouseTracking | 709 | // for auto-hiding the cursor, we need mouseTracking |
719 | if (ev->state() == NoButton ) return; | 710 | if (ev->state() == NoButton ) return; |
720 | 711 | ||
721 | if (actSel == 0) return; | 712 | if (actSel == 0) return; |
722 | 713 | ||
723 | // don't extend selection while pasting | 714 | // don't extend selection while pasting |
724 | if (ev->state() & MidButton) return; | 715 | if (ev->state() & MidButton) return; |
725 | 716 | ||
726 | //if ( !contentsRect().contains(ev->pos()) ) return; | 717 | //if ( !contentsRect().contains(ev->pos()) ) return; |
727 | QPoint tL = contentsRect().topLeft(); | 718 | QPoint tL = contentsRect().topLeft(); |
728 | int tLx = tL.x(); | 719 | int tLx = tL.x(); |
729 | int tLy = tL.y(); | 720 | int tLy = tL.y(); |
730 | int scroll = scrollbar->value(); | 721 | int scroll = scrollbar->value(); |
731 | // int hScroll = hScrollbar->value(); | 722 | // int hScroll = hScrollbar->value(); |
732 | 723 | ||
733 | // we're in the process of moving the mouse with the left button pressed | 724 | // we're in the process of moving the mouse with the left button pressed |
734 | // the mouse cursor will kept catched within the bounds of the text in | 725 | // the mouse cursor will kept catched within the bounds of the text in |
735 | // this widget. | 726 | // this widget. |
736 | 727 | ||
737 | // Adjust position within text area bounds. See FIXME above. | 728 | // Adjust position within text area bounds. See FIXME above. |
738 | QPoint pos = ev->pos(); | 729 | QPoint pos = ev->pos(); |
739 | if ( pos.x() < tLx+blX ) pos.setX( tLx+blX ); | 730 | if ( pos.x() < tLx+blX ) pos.setX( tLx+blX ); |
740 | if ( pos.x() > tLx+blX+columns*font_w-1 ) pos.setX( tLx+blX+columns*font_w ); | 731 | if ( pos.x() > tLx+blX+columns*font_w-1 ) pos.setX( tLx+blX+columns*font_w ); |
741 | if ( pos.y() < tLy+bY ) pos.setY( tLy+bY ); | 732 | if ( pos.y() < tLy+bY ) pos.setY( tLy+bY ); |
742 | if ( pos.y() > tLy+bY+lines*font_h-1 ) pos.setY( tLy+bY+lines*font_h-1 ); | 733 | if ( pos.y() > tLy+bY+lines*font_h-1 ) pos.setY( tLy+bY+lines*font_h-1 ); |
743 | // check if we produce a mouse move event by this | 734 | // check if we produce a mouse move event by this |
744 | if ( pos != ev->pos() ) cursor().setPos(mapToGlobal(pos)); | 735 | if ( pos != ev->pos() ) cursor().setPos(mapToGlobal(pos)); |
745 | 736 | ||
746 | if ( pos.y() == tLy+bY+lines*font_h-1 ) | 737 | if ( pos.y() == tLy+bY+lines*font_h-1 ) |
747 | { | 738 | { |
748 | scrollbar->setValue(scrollbar->value()+yMouseScroll); // scrollforward | 739 | scrollbar->setValue(scrollbar->value()+yMouseScroll); // scrollforward |
749 | } | 740 | } |
750 | if ( pos.y() == tLy+bY ) | 741 | if ( pos.y() == tLy+bY ) |
751 | { | 742 | { |
752 | scrollbar->setValue(scrollbar->value()-yMouseScroll); // scrollback | 743 | scrollbar->setValue(scrollbar->value()-yMouseScroll); // scrollback |
753 | } | 744 | } |
754 | 745 | ||
755 | QPoint here = QPoint((pos.x()-tLx-blX)/font_w,(pos.y()-tLy-bY)/font_h); | 746 | QPoint here = QPoint((pos.x()-tLx-blX)/font_w,(pos.y()-tLy-bY)/font_h); |
756 | QPoint ohere; | 747 | QPoint ohere; |
757 | bool swapping = FALSE; | 748 | bool swapping = FALSE; |
758 | 749 | ||
759 | if ( word_selection_mode ) | 750 | if ( word_selection_mode ) |
760 | { | 751 | { |
761 | // Extend to word boundaries | 752 | // Extend to word boundaries |
762 | int i; | 753 | int i; |
763 | int selClass; | 754 | int selClass; |
764 | 755 | ||
765 | bool left_not_right = ( here.y() < iPntSel.y() || | 756 | bool left_not_right = ( here.y() < iPntSel.y() || |
766 | here.y() == iPntSel.y() && here.x() < iPntSel.x() ); | 757 | here.y() == iPntSel.y() && here.x() < iPntSel.x() ); |
767 | bool old_left_not_right = ( pntSel.y() < iPntSel.y() || | 758 | bool old_left_not_right = ( pntSel.y() < iPntSel.y() || |
768 | pntSel.y() == iPntSel.y() && pntSel.x() < iPntSel.x() ); | 759 | pntSel.y() == iPntSel.y() && pntSel.x() < iPntSel.x() ); |
769 | swapping = left_not_right != old_left_not_right; | 760 | swapping = left_not_right != old_left_not_right; |
770 | 761 | ||
771 | // Find left (left_not_right ? from here : from start) | 762 | // Find left (left_not_right ? from here : from start) |
772 | QPoint left = left_not_right ? here : iPntSel; | 763 | QPoint left = left_not_right ? here : iPntSel; |
773 | i = loc(left.x(),left.y()); | 764 | i = loc(left.x(),left.y()); |
774 | selClass = charClass(image[i].c); | 765 | selClass = charClass(image[i].c); |
775 | while ( left.x() > 0 && charClass(image[i-1].c) == selClass ) | 766 | while ( left.x() > 0 && charClass(image[i-1].c) == selClass ) |
776 | { i--; left.rx()--; } | 767 | { i--; left.rx()--; } |
777 | 768 | ||
778 | // Find left (left_not_right ? from start : from here) | 769 | // Find left (left_not_right ? from start : from here) |
779 | QPoint right = left_not_right ? iPntSel : here; | 770 | QPoint right = left_not_right ? iPntSel : here; |
780 | i = loc(right.x(),right.y()); | 771 | i = loc(right.x(),right.y()); |
781 | selClass = charClass(image[i].c); | 772 | selClass = charClass(image[i].c); |
782 | while ( right.x() < columns-1 && charClass(image[i+1].c) == selClass ) | 773 | while ( right.x() < columns-1 && charClass(image[i+1].c) == selClass ) |
783 | { i++; right.rx()++; } | 774 | { i++; right.rx()++; } |
784 | 775 | ||
785 | // Pick which is start (ohere) and which is extension (here) | 776 | // Pick which is start (ohere) and which is extension (here) |
786 | if ( left_not_right ) | 777 | if ( left_not_right ) |
787 | { | 778 | { |
788 | here = left; ohere = right; | 779 | here = left; ohere = right; |
789 | } | 780 | } |
790 | else | 781 | else |
791 | { | 782 | { |
792 | here = right; ohere = left; | 783 | here = right; ohere = left; |
793 | } | 784 | } |
794 | } | 785 | } |
795 | 786 | ||
796 | if (here == pntSel && scroll == scrollbar->value()) return; // not moved | 787 | if (here == pntSel && scroll == scrollbar->value()) return; // not moved |
797 | 788 | ||
798 | if ( word_selection_mode ) { | 789 | if ( word_selection_mode ) { |
799 | if ( actSel < 2 || swapping ) { | 790 | if ( actSel < 2 || swapping ) { |
800 | emit beginSelectionSignal( ohere.x(), ohere.y() ); | 791 | emit beginSelectionSignal( ohere.x(), ohere.y() ); |
801 | } | 792 | } |
802 | } else if ( actSel < 2 ) { | 793 | } else if ( actSel < 2 ) { |
803 | emit beginSelectionSignal( pntSel.x(), pntSel.y() ); | 794 | emit beginSelectionSignal( pntSel.x(), pntSel.y() ); |
804 | } | 795 | } |
805 | 796 | ||
806 | actSel = 2; // within selection | 797 | actSel = 2; // within selection |
807 | pntSel = here; | 798 | pntSel = here; |
808 | emit extendSelectionSignal( here.x(), here.y() ); | 799 | emit extendSelectionSignal( here.x(), here.y() ); |
809 | } | 800 | } |
810 | 801 | ||
811 | void TEWidget::mouseReleaseEvent(QMouseEvent* ev) | 802 | void TEWidget::mouseReleaseEvent(QMouseEvent* ev) |
812 | { | 803 | { |
813 | //printf("release [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button()); | 804 | //printf("release [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button()); |
814 | if ( ev->button() == LeftButton) | 805 | if ( ev->button() == LeftButton) |
815 | { | 806 | { |
816 | if (QABS(ev->x() - mouse_down_x) < 3 | 807 | if (QABS(ev->x() - mouse_down_x) < 3 |
817 | && QABS(ev->y() - mouse_down_y) < 3 | 808 | && QABS(ev->y() - mouse_down_y) < 3 |
818 | && ev->y() < qApp->desktop()->height()/8) { | 809 | && ev->y() < qApp->desktop()->height()/8) { |
819 | emit setFullScreen(false); | 810 | emit setFullScreen(false); |
820 | } | 811 | } |
821 | 812 | ||
822 | if ( actSel > 1 ) emit endSelectionSignal(preserve_line_breaks); | 813 | if ( actSel > 1 ) emit endSelectionSignal(preserve_line_breaks); |
823 | preserve_line_breaks = TRUE; | 814 | preserve_line_breaks = TRUE; |
824 | actSel = 0; | 815 | actSel = 0; |
825 | 816 | ||
826 | //FIXME: emits a release event even if the mouse is | 817 | //FIXME: emits a release event even if the mouse is |
827 | // outside the range. The procedure used in `mouseMoveEvent' | 818 | // outside the range. The procedure used in `mouseMoveEvent' |
828 | // applies here, too. | 819 | // applies here, too. |
829 | 820 | ||
830 | QPoint tL = contentsRect().topLeft(); | 821 | QPoint tL = contentsRect().topLeft(); |
831 | int tLx = tL.x(); | 822 | int tLx = tL.x(); |
832 | int tLy = tL.y(); | 823 | int tLy = tL.y(); |
833 | 824 | ||
834 | if (!mouse_marks && !(ev->state() & ShiftButton)) | 825 | if (!mouse_marks && !(ev->state() & ShiftButton)) |
835 | emit mouseSignal( 3, // release | 826 | emit mouseSignal( 3, // release |
836 | (ev->x()-tLx-blX)/font_w + 1, | 827 | (ev->x()-tLx-blX)/font_w + 1, |
837 | (ev->y()-tLy-bY)/font_h + 1 ); | 828 | (ev->y()-tLy-bY)/font_h + 1 ); |
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,802 +1,797 @@ | |||
1 | /* ------------------------------------------------------------------------- */ | 1 | /* ------------------------------------------------------------------------- */ |
2 | /* */ | 2 | /* */ |
3 | /* [TEmuVt102.C] VT102 Terminal Emulation */ | 3 | /* [TEmuVt102.C] VT102 Terminal Emulation */ |
4 | /* */ | 4 | /* */ |
5 | /* ------------------------------------------------------------------------- */ | 5 | /* ------------------------------------------------------------------------- */ |
6 | /* */ | 6 | /* */ |
7 | /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ | 7 | /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ |
8 | /* */ | 8 | /* */ |
9 | /* This file is part of Konsole - an X terminal for KDE */ | 9 | /* This file is part of Konsole - an X terminal for KDE */ |
10 | /* */ | 10 | /* */ |
11 | /* ------------------------------------------------------------------------- */ | 11 | /* ------------------------------------------------------------------------- */ |
12 | /* */ | 12 | /* */ |
13 | /* Ported Konsole to Qt/Embedded */ | 13 | /* Ported Konsole to Qt/Embedded */ |
14 | /* */ | 14 | /* */ |
15 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ | 15 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ |
16 | /* */ | 16 | /* */ |
17 | /* -------------------------------------------------------------------------- */ | 17 | /* -------------------------------------------------------------------------- */ |
18 | 18 | ||
19 | /*! \class TEmuVt102 | 19 | /*! \class TEmuVt102 |
20 | 20 | ||
21 | \brief Actual Emulation for Konsole | 21 | \brief Actual Emulation for Konsole |
22 | 22 | ||
23 | \sa TEWidget \sa TEScreen | 23 | \sa TEWidget \sa TEScreen |
24 | */ | 24 | */ |
25 | 25 | ||
26 | #include "TEmuVt102.h" | 26 | #include "TEmuVt102.h" |
27 | #include "TEWidget.h" | ||
28 | #include "TEScreen.h" | ||
29 | #include "keytrans.h" | ||
30 | 27 | ||
31 | #include <stdio.h> | 28 | #include <stdio.h> |
32 | #include <unistd.h> | 29 | #include <unistd.h> |
33 | #include <qkeycode.h> | ||
34 | #include <qtextcodec.h> | ||
35 | 30 | ||
36 | 31 | ||
37 | /* VT102 Terminal Emulation | 32 | /* VT102 Terminal Emulation |
38 | 33 | ||
39 | This class puts together the screens, the pty and the widget to a | 34 | This class puts together the screens, the pty and the widget to a |
40 | complete terminal emulation. Beside combining it's componentes, it | 35 | complete terminal emulation. Beside combining it's componentes, it |
41 | handles the emulations's protocol. | 36 | handles the emulations's protocol. |
42 | 37 | ||
43 | This module consists of the following sections: | 38 | This module consists of the following sections: |
44 | 39 | ||
45 | - Constructor/Destructor | 40 | - Constructor/Destructor |
46 | - Incoming Bytes Event pipeline | 41 | - Incoming Bytes Event pipeline |
47 | - Outgoing Bytes | 42 | - Outgoing Bytes |
48 | - Mouse Events | 43 | - Mouse Events |
49 | - Keyboard Events | 44 | - Keyboard Events |
50 | - Modes and Charset State | 45 | - Modes and Charset State |
51 | - Diagnostics | 46 | - Diagnostics |
52 | */ | 47 | */ |
53 | 48 | ||
54 | 49 | ||
55 | /* ------------------------------------------------------------------------- */ | 50 | /* ------------------------------------------------------------------------- */ |
56 | /* */ | 51 | /* */ |
57 | /* Constructor / Destructor */ | 52 | /* Constructor / Destructor */ |
58 | /* */ | 53 | /* */ |
59 | /* ------------------------------------------------------------------------- */ | 54 | /* ------------------------------------------------------------------------- */ |
60 | 55 | ||
61 | /* | 56 | /* |
62 | Nothing really intesting happens here. | 57 | Nothing really intesting happens here. |
63 | */ | 58 | */ |
64 | 59 | ||
65 | /*! | 60 | /*! |
66 | */ | 61 | */ |
67 | 62 | ||
68 | TEmuVt102::TEmuVt102(TEWidget* gui) : TEmulation(gui) | 63 | TEmuVt102::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 | ||
79 | TEmuVt102::~TEmuVt102() | 74 | TEmuVt102::~TEmuVt102() |
80 | { | 75 | { |
81 | } | 76 | } |
82 | 77 | ||
83 | /*! | 78 | /*! |
84 | */ | 79 | */ |
85 | 80 | ||
86 | void TEmuVt102::reset() | 81 | void 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 | ||
175 | void TEmuVt102::resetToken() | 170 | void 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 | ||
180 | void TEmuVt102::addDigit(int dig) | 175 | void TEmuVt102::addDigit(int dig) |
181 | { | 176 | { |
182 | argv[argc] = 10*argv[argc] + dig; | 177 | argv[argc] = 10*argv[argc] + dig; |
183 | } | 178 | } |
184 | 179 | ||
185 | void TEmuVt102::addArgument() | 180 | void 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 | ||
191 | void TEmuVt102::pushToToken(int cc) | 186 | void 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 | ||
206 | void TEmuVt102::initTokenizer() | 201 | void TEmuVt102::initTokenizer() |
207 | { int i; UINT8* s; | 202 | { int i; UINT8* s; |
208 | for(i = 0; i < 256; i++) tbl[ i] = 0; | 203 | for(i = 0; i < 256; i++) tbl[ i] = 0; |
209 | for(i = 0; i < 32; i++) tbl[ i] |= CTL; | 204 | for(i = 0; i < 32; i++) tbl[ i] |= CTL; |
210 | for(i = 32; i < 256; i++) tbl[ i] |= CHR; | 205 | for(i = 32; i < 256; i++) tbl[ i] |= CHR; |
211 | for(s = (UINT8*)"@ABCDGHLMPXcdfry"; *s; s++) tbl[*s] |= CPN; | 206 | for(s = (UINT8*)"@ABCDGHLMPXcdfry"; *s; s++) tbl[*s] |= CPN; |
212 | for(s = (UINT8*)"0123456789" ; *s; s++) tbl[*s] |= DIG; | 207 | for(s = (UINT8*)"0123456789" ; *s; s++) tbl[*s] |= DIG; |
213 | for(s = (UINT8*)"()+*%" ; *s; s++) tbl[*s] |= SCS; | 208 | for(s = (UINT8*)"()+*%" ; *s; s++) tbl[*s] |= SCS; |
214 | for(s = (UINT8*)"()+*#[]%" ; *s; s++) tbl[*s] |= GRP; | 209 | for(s = (UINT8*)"()+*#[]%" ; *s; s++) tbl[*s] |= GRP; |
215 | resetToken(); | 210 | resetToken(); |
216 | } | 211 | } |
217 | 212 | ||
218 | /* Ok, here comes the nasty part of the decoder. | 213 | /* Ok, here comes the nasty part of the decoder. |
219 | 214 | ||
220 | Instead of keeping an explicit state, we deduce it from the | 215 | Instead of keeping an explicit state, we deduce it from the |
221 | token scanned so far. It is then immediately combined with | 216 | token scanned so far. It is then immediately combined with |
222 | the current character to form a scanning decision. | 217 | the current character to form a scanning decision. |
223 | 218 | ||
224 | This is done by the following defines. | 219 | This is done by the following defines. |
225 | 220 | ||
226 | - P is the length of the token scanned so far. | 221 | - P is the length of the token scanned so far. |
227 | - L (often P-1) is the position on which contents we base a decision. | 222 | - L (often P-1) is the position on which contents we base a decision. |
228 | - C is a character or a group of characters (taken from 'tbl'). | 223 | - C is a character or a group of characters (taken from 'tbl'). |
229 | 224 | ||
230 | Note that they need to applied in proper order. | 225 | Note that they need to applied in proper order. |
231 | */ | 226 | */ |
232 | 227 | ||
233 | #define lec(P,L,C) (p == (P) && s[(L)] == (C)) | 228 | #define lec(P,L,C) (p == (P) && s[(L)] == (C)) |
234 | #define lun( ) (p == 1 && cc >= 32 ) | 229 | #define lun( ) (p == 1 && cc >= 32 ) |
235 | #define les(P,L,C) (p == (P) && s[L] < 256 && (tbl[s[(L)]] & (C)) == (C)) | 230 | #define les(P,L,C) (p == (P) && s[L] < 256 && (tbl[s[(L)]] & (C)) == (C)) |
236 | #define eec(C) (p >= 3 && cc == (C)) | 231 | #define eec(C) (p >= 3 && cc == (C)) |
237 | #define ees(C) (p >= 3 && cc < 256 && (tbl[ cc ] & (C)) == (C)) | 232 | #define ees(C) (p >= 3 && cc < 256 && (tbl[ cc ] & (C)) == (C)) |
238 | #define eps(C) (p >= 3 && s[2] != '?' && cc < 256 && (tbl[ cc ] & (C)) == (C)) | 233 | #define eps(C) (p >= 3 && s[2] != '?' && cc < 256 && (tbl[ cc ] & (C)) == (C)) |
239 | #define epp( ) (p >= 3 && s[2] == '?' ) | 234 | #define epp( ) (p >= 3 && s[2] == '?' ) |
240 | #define egt( ) (p == 3 && s[2] == '>' ) | 235 | #define egt( ) (p == 3 && s[2] == '>' ) |
241 | #define Xpe (ppos>=2 && pbuf[1] == ']' ) | 236 | #define Xpe (ppos>=2 && pbuf[1] == ']' ) |
242 | #define Xte (Xpe && cc == 7 ) | 237 | #define Xte (Xpe && cc == 7 ) |
243 | #define ces(C) ( cc < 256 && (tbl[ cc ] & (C)) == (C) && !Xte) | 238 | #define ces(C) ( cc < 256 && (tbl[ cc ] & (C)) == (C) && !Xte) |
244 | 239 | ||
245 | #define ESC 27 | 240 | #define ESC 27 |
246 | #define CNTL(c) ((c)-'@') | 241 | #define CNTL(c) ((c)-'@') |
247 | 242 | ||
248 | // process an incoming unicode character | 243 | // process an incoming unicode character |
249 | 244 | ||
250 | void TEmuVt102::onRcvChar(int cc) | 245 | void TEmuVt102::onRcvChar(int cc) |
251 | { int i; | 246 | { int i; |
252 | 247 | ||
253 | if (cc == 127) return; //VT100: ignore. | 248 | if (cc == 127) return; //VT100: ignore. |
254 | 249 | ||
255 | if (ces( CTL)) | 250 | if (ces( CTL)) |
256 | { // DEC HACK ALERT! Control Characters are allowed *within* esc sequences in VT100 | 251 | { // DEC HACK ALERT! Control Characters are allowed *within* esc sequences in VT100 |
257 | // This means, they do neither a resetToken nor a pushToToken. Some of them, do | 252 | // This means, they do neither a resetToken nor a pushToToken. Some of them, do |
258 | // of course. Guess this originates from a weakly layered handling of the X-on | 253 | // of course. Guess this originates from a weakly layered handling of the X-on |
259 | // X-off protocol, which comes really below this level. | 254 | // X-off protocol, which comes really below this level. |
260 | if (cc == CNTL('X') || cc == CNTL('Z') || cc == ESC) resetToken(); //VT100: CAN or SUB | 255 | if (cc == CNTL('X') || cc == CNTL('Z') || cc == ESC) resetToken(); //VT100: CAN or SUB |
261 | if (cc != ESC) { tau( TY_CTL___(cc+'@' ), 0, 0); return; } | 256 | if (cc != ESC) { tau( TY_CTL___(cc+'@' ), 0, 0); return; } |
262 | } | 257 | } |
263 | 258 | ||
264 | pushToToken(cc); // advance the state | 259 | pushToToken(cc); // advance the state |
265 | 260 | ||
266 | int* s = pbuf; | 261 | int* s = pbuf; |
267 | int p = ppos; | 262 | int p = ppos; |
268 | 263 | ||
269 | if (getMode(MODE_Ansi)) // decide on proper action | 264 | if (getMode(MODE_Ansi)) // decide on proper action |
270 | { | 265 | { |
271 | if (lec(1,0,ESC)) { return; } | 266 | if (lec(1,0,ESC)) { return; } |
272 | if (les(2,1,GRP)) { return; } | 267 | if (les(2,1,GRP)) { return; } |
273 | if (Xte ) { XtermHack(); resetToken(); return; } | 268 | if (Xte ) { XtermHack(); resetToken(); return; } |
274 | if (Xpe ) { return; } | 269 | if (Xpe ) { return; } |
275 | if (lec(3,2,'?')) { return; } | 270 | if (lec(3,2,'?')) { return; } |
276 | if (lec(3,2,'>')) { return; } | 271 | if (lec(3,2,'>')) { return; } |
277 | if (lun( )) { tau( TY_CHR___(), applyCharset(cc), 0); resetToken(); return; } | 272 | if (lun( )) { tau( TY_CHR___(), applyCharset(cc), 0); resetToken(); return; } |
278 | if (lec(2,0,ESC)) { tau( TY_ESC___(s[1]), 0, 0); resetToken(); return; } | 273 | if (lec(2,0,ESC)) { tau( TY_ESC___(s[1]), 0, 0); resetToken(); return; } |
279 | if (les(3,1,SCS)) { tau( TY_ESC_CS(s[1],s[2]), 0, 0); resetToken(); return; } | 274 | if (les(3,1,SCS)) { tau( TY_ESC_CS(s[1],s[2]), 0, 0); resetToken(); return; } |
280 | if (lec(3,1,'#')) { tau( TY_ESC_DE(s[2]), 0, 0); resetToken(); return; } | 275 | if (lec(3,1,'#')) { tau( TY_ESC_DE(s[2]), 0, 0); resetToken(); return; } |
281 | // if (egt( )) { tau( TY_CSI_PG(cc ), '>', 0); resetToken(); return; } | 276 | // if (egt( )) { tau( TY_CSI_PG(cc ), '>', 0); resetToken(); return; } |
282 | if (eps( CPN)) { tau( TY_CSI_PN(cc), argv[0],argv[1]); resetToken(); return; } | 277 | if (eps( CPN)) { tau( TY_CSI_PN(cc), argv[0],argv[1]); resetToken(); return; } |
283 | if (ees( DIG)) { addDigit(cc-'0'); return; } | 278 | if (ees( DIG)) { addDigit(cc-'0'); return; } |
284 | if (eec( ';')) { addArgument(); return; } | 279 | if (eec( ';')) { addArgument(); return; } |
285 | for (i=0;i<=argc;i++) | 280 | for (i=0;i<=argc;i++) |
286 | if (epp( )) tau( TY_CSI_PR(cc,argv[i]), 0, 0); else | 281 | if (epp( )) tau( TY_CSI_PR(cc,argv[i]), 0, 0); else |
287 | tau( TY_CSI_PS(cc,argv[i]), 0, 0); | 282 | tau( TY_CSI_PS(cc,argv[i]), 0, 0); |
288 | resetToken(); | 283 | resetToken(); |
289 | } | 284 | } |
290 | else // mode VT52 | 285 | else // mode VT52 |
291 | { | 286 | { |
292 | if (lec(1,0,ESC)) return; | 287 | if (lec(1,0,ESC)) return; |
293 | if (les(1,0,CHR)) { tau( TY_CHR___( ), s[0], 0); resetToken(); return; } | 288 | if (les(1,0,CHR)) { tau( TY_CHR___( ), s[0], 0); resetToken(); return; } |
294 | if (lec(2,1,'Y')) return; | 289 | if (lec(2,1,'Y')) return; |
295 | if (lec(3,1,'Y')) return; | 290 | if (lec(3,1,'Y')) return; |
296 | if (p < 4) { tau( TY_VT52__(s[1] ), 0, 0); resetToken(); return; } | 291 | if (p < 4) { tau( TY_VT52__(s[1] ), 0, 0); resetToken(); return; } |
297 | tau( TY_VT52__(s[1] ), s[2],s[3]); resetToken(); return; | 292 | tau( TY_VT52__(s[1] ), s[2],s[3]); resetToken(); return; |
298 | } | 293 | } |
299 | } | 294 | } |
300 | 295 | ||
301 | void TEmuVt102::XtermHack() | 296 | void TEmuVt102::XtermHack() |
302 | { int i,arg = 0; | 297 | { int i,arg = 0; |
303 | for (i = 2; i < ppos && '0'<=pbuf[i] && pbuf[i]<'9' ; i++) | 298 | for (i = 2; i < ppos && '0'<=pbuf[i] && pbuf[i]<'9' ; i++) |
304 | arg = 10*arg + (pbuf[i]-'0'); | 299 | arg = 10*arg + (pbuf[i]-'0'); |
305 | if (pbuf[i] != ';') { ReportErrorToken(); return; } | 300 | if (pbuf[i] != ';') { ReportErrorToken(); return; } |
306 | QChar *str = new QChar[ppos-i-2]; | 301 | QChar *str = new QChar[ppos-i-2]; |
307 | for (int j = 0; j < ppos-i-2; j++) str[j] = pbuf[i+1+j]; | 302 | for (int j = 0; j < ppos-i-2; j++) str[j] = pbuf[i+1+j]; |
308 | QString unistr(str,ppos-i-2); | 303 | QString unistr(str,ppos-i-2); |
309 | // arg == 1 doesn't change the title. In XTerm it only changes the icon name | 304 | // arg == 1 doesn't change the title. In XTerm it only changes the icon name |
310 | // (btw: arg=0 changes title and icon, arg=1 only icon, arg=2 only title | 305 | // (btw: arg=0 changes title and icon, arg=1 only icon, arg=2 only title |
311 | if (arg == 0 || arg == 2) emit changeTitle(arg,unistr); | 306 | if (arg == 0 || arg == 2) emit changeTitle(arg,unistr); |
312 | delete [] str; | 307 | delete [] str; |
313 | } | 308 | } |
314 | 309 | ||
315 | // Interpreting Codes --------------------------------------------------------- | 310 | // Interpreting Codes --------------------------------------------------------- |
316 | 311 | ||
317 | /* | 312 | /* |
318 | Now that the incoming character stream is properly tokenized, | 313 | Now that the incoming character stream is properly tokenized, |
319 | meaning is assigned to them. These are either operations of | 314 | meaning is assigned to them. These are either operations of |
320 | the current screen, or of the emulation class itself. | 315 | the current screen, or of the emulation class itself. |
321 | 316 | ||
322 | The token to be interpreteted comes in as a machine word | 317 | The token to be interpreteted comes in as a machine word |
323 | possibly accompanied by two parameters. | 318 | possibly accompanied by two parameters. |
324 | 319 | ||
325 | Likewise, the operations assigned to, come with up to two | 320 | Likewise, the operations assigned to, come with up to two |
326 | arguments. One could consider to make up a proper table | 321 | arguments. One could consider to make up a proper table |
327 | from the function below. | 322 | from the function below. |
328 | 323 | ||
329 | The technical reference manual provides more informations | 324 | The technical reference manual provides more informations |
330 | about this mapping. | 325 | about this mapping. |
331 | */ | 326 | */ |
332 | 327 | ||
333 | void TEmuVt102::tau( int token, int p, int q ) | 328 | void TEmuVt102::tau( int token, int p, int q ) |
334 | { | 329 | { |
335 | //scan_buffer_report(); | 330 | //scan_buffer_report(); |
336 | //if (token == TY_CHR___()) printf("%c",p); else | 331 | //if (token == TY_CHR___()) printf("%c",p); else |
337 | //printf("tau(%d,%d,%d, %d,%d)\n",(token>>0)&0xff,(token>>8)&0xff,(token>>16)&0xffff,p,q); | 332 | //printf("tau(%d,%d,%d, %d,%d)\n",(token>>0)&0xff,(token>>8)&0xff,(token>>16)&0xffff,p,q); |
338 | switch (token) | 333 | switch (token) |
339 | { | 334 | { |
340 | 335 | ||
341 | case TY_CHR___( ) : scr->ShowCharacter (p ); break; //UTF16 | 336 | case TY_CHR___( ) : scr->ShowCharacter (p ); break; //UTF16 |
342 | 337 | ||
343 | // 127 DEL : ignored on input | 338 | // 127 DEL : ignored on input |
344 | 339 | ||
345 | case TY_CTL___('@' ) : /* NUL: ignored */ break; | 340 | case TY_CTL___('@' ) : /* NUL: ignored */ break; |
346 | case TY_CTL___('A' ) : /* SOH: ignored */ break; | 341 | case TY_CTL___('A' ) : /* SOH: ignored */ break; |
347 | case TY_CTL___('B' ) : /* STX: ignored */ break; | 342 | case TY_CTL___('B' ) : /* STX: ignored */ break; |
348 | case TY_CTL___('C' ) : /* ETX: ignored */ break; | 343 | case TY_CTL___('C' ) : /* ETX: ignored */ break; |
349 | case TY_CTL___('D' ) : /* EOT: ignored */ break; | 344 | case TY_CTL___('D' ) : /* EOT: ignored */ break; |
350 | case TY_CTL___('E' ) : reportAnswerBack ( ); break; //VT100 | 345 | case TY_CTL___('E' ) : reportAnswerBack ( ); break; //VT100 |
351 | case TY_CTL___('F' ) : /* ACK: ignored */ break; | 346 | case TY_CTL___('F' ) : /* ACK: ignored */ break; |
352 | case TY_CTL___('G' ) : gui->Bell ( ); break; //VT100 | 347 | case TY_CTL___('G' ) : gui->Bell ( ); break; //VT100 |
353 | case TY_CTL___('H' ) : scr->BackSpace ( ); break; //VT100 | 348 | case TY_CTL___('H' ) : scr->BackSpace ( ); break; //VT100 |
354 | case TY_CTL___('I' ) : scr->Tabulate ( ); break; //VT100 | 349 | case TY_CTL___('I' ) : scr->Tabulate ( ); break; //VT100 |
355 | case TY_CTL___('J' ) : scr->NewLine ( ); break; //VT100 | 350 | case TY_CTL___('J' ) : scr->NewLine ( ); break; //VT100 |
356 | case TY_CTL___('K' ) : scr->NewLine ( ); break; //VT100 | 351 | case TY_CTL___('K' ) : scr->NewLine ( ); break; //VT100 |
357 | case TY_CTL___('L' ) : scr->NewLine ( ); break; //VT100 | 352 | case TY_CTL___('L' ) : scr->NewLine ( ); break; //VT100 |
358 | case TY_CTL___('M' ) : scr->Return ( ); break; //VT100 | 353 | case TY_CTL___('M' ) : scr->Return ( ); break; //VT100 |
359 | 354 | ||
360 | case TY_CTL___('N' ) : useCharset ( 1); break; //VT100 | 355 | case TY_CTL___('N' ) : useCharset ( 1); break; //VT100 |
361 | case TY_CTL___('O' ) : useCharset ( 0); break; //VT100 | 356 | case TY_CTL___('O' ) : useCharset ( 0); break; //VT100 |
362 | 357 | ||
363 | case TY_CTL___('P' ) : /* DLE: ignored */ break; | 358 | case TY_CTL___('P' ) : /* DLE: ignored */ break; |
364 | case TY_CTL___('Q' ) : /* DC1: XON continue */ break; //VT100 | 359 | case TY_CTL___('Q' ) : /* DC1: XON continue */ break; //VT100 |
365 | case TY_CTL___('R' ) : /* DC2: ignored */ break; | 360 | case TY_CTL___('R' ) : /* DC2: ignored */ break; |
366 | case TY_CTL___('S' ) : /* DC3: XOFF halt */ break; //VT100 | 361 | case TY_CTL___('S' ) : /* DC3: XOFF halt */ break; //VT100 |
367 | case TY_CTL___('T' ) : /* DC4: ignored */ break; | 362 | case TY_CTL___('T' ) : /* DC4: ignored */ break; |
368 | case TY_CTL___('U' ) : /* NAK: ignored */ break; | 363 | case TY_CTL___('U' ) : /* NAK: ignored */ break; |
369 | case TY_CTL___('V' ) : /* SYN: ignored */ break; | 364 | case TY_CTL___('V' ) : /* SYN: ignored */ break; |
370 | case TY_CTL___('W' ) : /* ETB: ignored */ break; | 365 | case TY_CTL___('W' ) : /* ETB: ignored */ break; |
371 | case TY_CTL___('X' ) : scr->ShowCharacter ( 0x2592); break; //VT100 | 366 | case TY_CTL___('X' ) : scr->ShowCharacter ( 0x2592); break; //VT100 |
372 | case TY_CTL___('Y' ) : /* EM : ignored */ break; | 367 | case TY_CTL___('Y' ) : /* EM : ignored */ break; |
373 | case TY_CTL___('Z' ) : scr->ShowCharacter ( 0x2592); break; //VT100 | 368 | case TY_CTL___('Z' ) : scr->ShowCharacter ( 0x2592); break; //VT100 |
374 | case TY_CTL___('[' ) : /* ESC: cannot be seen here. */ break; | 369 | case TY_CTL___('[' ) : /* ESC: cannot be seen here. */ break; |
375 | case TY_CTL___('\\' ) : /* FS : ignored */ break; | 370 | case TY_CTL___('\\' ) : /* FS : ignored */ break; |
376 | case TY_CTL___(']' ) : /* GS : ignored */ break; | 371 | case TY_CTL___(']' ) : /* GS : ignored */ break; |
377 | case TY_CTL___('^' ) : /* RS : ignored */ break; | 372 | case TY_CTL___('^' ) : /* RS : ignored */ break; |
378 | case TY_CTL___('_' ) : /* US : ignored */ break; | 373 | case TY_CTL___('_' ) : /* US : ignored */ break; |
379 | 374 | ||
380 | case TY_ESC___('D' ) : scr->index ( ); break; //VT100 | 375 | case TY_ESC___('D' ) : scr->index ( ); break; //VT100 |
381 | case TY_ESC___('E' ) : scr->NextLine ( ); break; //VT100 | 376 | case TY_ESC___('E' ) : scr->NextLine ( ); break; //VT100 |
382 | case TY_ESC___('H' ) : scr->changeTabStop (TRUE ); break; //VT100 | 377 | case TY_ESC___('H' ) : scr->changeTabStop (TRUE ); break; //VT100 |
383 | case TY_ESC___('M' ) : scr->reverseIndex ( ); break; //VT100 | 378 | case TY_ESC___('M' ) : scr->reverseIndex ( ); break; //VT100 |
384 | case TY_ESC___('Z' ) : reportTerminalType ( ); break; | 379 | case TY_ESC___('Z' ) : reportTerminalType ( ); break; |
385 | case TY_ESC___('c' ) : reset ( ); break; | 380 | case TY_ESC___('c' ) : reset ( ); break; |
386 | 381 | ||
387 | case TY_ESC___('n' ) : useCharset ( 2); break; | 382 | case TY_ESC___('n' ) : useCharset ( 2); break; |
388 | case TY_ESC___('o' ) : useCharset ( 3); break; | 383 | case TY_ESC___('o' ) : useCharset ( 3); break; |
389 | case TY_ESC___('7' ) : saveCursor ( ); break; | 384 | case TY_ESC___('7' ) : saveCursor ( ); break; |
390 | case TY_ESC___('8' ) : restoreCursor ( ); break; | 385 | case TY_ESC___('8' ) : restoreCursor ( ); break; |
391 | 386 | ||
392 | case TY_ESC___('=' ) : setMode (MODE_AppKeyPad); break; | 387 | case TY_ESC___('=' ) : setMode (MODE_AppKeyPad); break; |
393 | case TY_ESC___('>' ) : resetMode (MODE_AppKeyPad); break; | 388 | case TY_ESC___('>' ) : resetMode (MODE_AppKeyPad); break; |
394 | case TY_ESC___('<' ) : setMode (MODE_Ansi ); break; //VT100 | 389 | case TY_ESC___('<' ) : setMode (MODE_Ansi ); break; //VT100 |
395 | 390 | ||
396 | case TY_ESC_CS('(', '0') : setCharset (0, '0'); break; //VT100 | 391 | case TY_ESC_CS('(', '0') : setCharset (0, '0'); break; //VT100 |
397 | case TY_ESC_CS('(', 'A') : setCharset (0, 'A'); break; //VT100 | 392 | case TY_ESC_CS('(', 'A') : setCharset (0, 'A'); break; //VT100 |
398 | case TY_ESC_CS('(', 'B') : setCharset (0, 'B'); break; //VT100 | 393 | case TY_ESC_CS('(', 'B') : setCharset (0, 'B'); break; //VT100 |
399 | 394 | ||
400 | case TY_ESC_CS(')', '0') : setCharset (1, '0'); break; //VT100 | 395 | case TY_ESC_CS(')', '0') : setCharset (1, '0'); break; //VT100 |
401 | case TY_ESC_CS(')', 'A') : setCharset (1, 'A'); break; //VT100 | 396 | case TY_ESC_CS(')', 'A') : setCharset (1, 'A'); break; //VT100 |
402 | case TY_ESC_CS(')', 'B') : setCharset (1, 'B'); break; //VT100 | 397 | case TY_ESC_CS(')', 'B') : setCharset (1, 'B'); break; //VT100 |
403 | 398 | ||
404 | case TY_ESC_CS('*', '0') : setCharset (2, '0'); break; //VT100 | 399 | case TY_ESC_CS('*', '0') : setCharset (2, '0'); break; //VT100 |
405 | case TY_ESC_CS('*', 'A') : setCharset (2, 'A'); break; //VT100 | 400 | case TY_ESC_CS('*', 'A') : setCharset (2, 'A'); break; //VT100 |
406 | case TY_ESC_CS('*', 'B') : setCharset (2, 'B'); break; //VT100 | 401 | case TY_ESC_CS('*', 'B') : setCharset (2, 'B'); break; //VT100 |
407 | 402 | ||
408 | case TY_ESC_CS('+', '0') : setCharset (3, '0'); break; //VT100 | 403 | case TY_ESC_CS('+', '0') : setCharset (3, '0'); break; //VT100 |
409 | case TY_ESC_CS('+', 'A') : setCharset (3, 'A'); break; //VT100 | 404 | case TY_ESC_CS('+', 'A') : setCharset (3, 'A'); break; //VT100 |
410 | case TY_ESC_CS('+', 'B') : setCharset (3, 'B'); break; //VT100 | 405 | case TY_ESC_CS('+', 'B') : setCharset (3, 'B'); break; //VT100 |
411 | 406 | ||
412 | case TY_ESC_CS('%', 'G') : setCodec (1 ); break; //LINUX | 407 | case TY_ESC_CS('%', 'G') : setCodec (1 ); break; //LINUX |
413 | case TY_ESC_CS('%', '@') : setCodec (0 ); break; //LINUX | 408 | case TY_ESC_CS('%', '@') : setCodec (0 ); break; //LINUX |
414 | 409 | ||
415 | case TY_ESC_DE('3' ) : /* IGNORED: double high, top half */ break; | 410 | case TY_ESC_DE('3' ) : /* IGNORED: double high, top half */ break; |
416 | case TY_ESC_DE('4' ) : /* IGNORED: double high, bottom half */ break; | 411 | case TY_ESC_DE('4' ) : /* IGNORED: double high, bottom half */ break; |
417 | case TY_ESC_DE('5' ) : /* IGNORED: single width, single high*/ break; | 412 | case TY_ESC_DE('5' ) : /* IGNORED: single width, single high*/ break; |
418 | case TY_ESC_DE('6' ) : /* IGNORED: double width, single high*/ break; | 413 | case TY_ESC_DE('6' ) : /* IGNORED: double width, single high*/ break; |
419 | case TY_ESC_DE('8' ) : scr->helpAlign ( ); break; | 414 | case TY_ESC_DE('8' ) : scr->helpAlign ( ); break; |
420 | 415 | ||
421 | case TY_CSI_PS('K', 0) : scr->clearToEndOfLine ( ); break; | 416 | case TY_CSI_PS('K', 0) : scr->clearToEndOfLine ( ); break; |
422 | case TY_CSI_PS('K', 1) : scr->clearToBeginOfLine ( ); break; | 417 | case TY_CSI_PS('K', 1) : scr->clearToBeginOfLine ( ); break; |
423 | case TY_CSI_PS('K', 2) : scr->clearEntireLine ( ); break; | 418 | case TY_CSI_PS('K', 2) : scr->clearEntireLine ( ); break; |
424 | case TY_CSI_PS('J', 0) : scr->clearToEndOfScreen ( ); break; | 419 | case TY_CSI_PS('J', 0) : scr->clearToEndOfScreen ( ); break; |
425 | case TY_CSI_PS('J', 1) : scr->clearToBeginOfScreen ( ); break; | 420 | case TY_CSI_PS('J', 1) : scr->clearToBeginOfScreen ( ); break; |
426 | case TY_CSI_PS('J', 2) : scr->clearEntireScreen ( ); break; | 421 | case TY_CSI_PS('J', 2) : scr->clearEntireScreen ( ); break; |
427 | case TY_CSI_PS('g', 0) : scr->changeTabStop (FALSE ); break; //VT100 | 422 | case TY_CSI_PS('g', 0) : scr->changeTabStop (FALSE ); break; //VT100 |
428 | case TY_CSI_PS('g', 3) : scr->clearTabStops ( ); break; //VT100 | 423 | case TY_CSI_PS('g', 3) : scr->clearTabStops ( ); break; //VT100 |
429 | case TY_CSI_PS('h', 4) : scr-> setMode (MODE_Insert ); break; | 424 | case TY_CSI_PS('h', 4) : scr-> setMode (MODE_Insert ); break; |
430 | case TY_CSI_PS('h', 20) : setMode (MODE_NewLine ); break; | 425 | case TY_CSI_PS('h', 20) : setMode (MODE_NewLine ); break; |
431 | case TY_CSI_PS('i', 0) : /* IGNORE: attached printer */ break; //VT100 | 426 | case TY_CSI_PS('i', 0) : /* IGNORE: attached printer */ break; //VT100 |
432 | case TY_CSI_PS('l', 4) : scr-> resetMode (MODE_Insert ); break; | 427 | case TY_CSI_PS('l', 4) : scr-> resetMode (MODE_Insert ); break; |
433 | case TY_CSI_PS('l', 20) : resetMode (MODE_NewLine ); break; | 428 | case TY_CSI_PS('l', 20) : resetMode (MODE_NewLine ); break; |
434 | 429 | ||
435 | case TY_CSI_PS('m', 0) : scr->setDefaultRendition ( ); break; | 430 | case TY_CSI_PS('m', 0) : scr->setDefaultRendition ( ); break; |
436 | case TY_CSI_PS('m', 1) : scr-> setRendition (RE_BOLD ); break; //VT100 | 431 | case TY_CSI_PS('m', 1) : scr-> setRendition (RE_BOLD ); break; //VT100 |
437 | case TY_CSI_PS('m', 4) : scr-> setRendition (RE_UNDERLINE); break; //VT100 | 432 | case TY_CSI_PS('m', 4) : scr-> setRendition (RE_UNDERLINE); break; //VT100 |
438 | case TY_CSI_PS('m', 5) : scr-> setRendition (RE_BLINK ); break; //VT100 | 433 | case TY_CSI_PS('m', 5) : scr-> setRendition (RE_BLINK ); break; //VT100 |
439 | case TY_CSI_PS('m', 7) : scr-> setRendition (RE_REVERSE ); break; | 434 | case TY_CSI_PS('m', 7) : scr-> setRendition (RE_REVERSE ); break; |
440 | case TY_CSI_PS('m', 10) : /* IGNORED: mapping related */ break; //LINUX | 435 | case TY_CSI_PS('m', 10) : /* IGNORED: mapping related */ break; //LINUX |
441 | case TY_CSI_PS('m', 11) : /* IGNORED: mapping related */ break; //LINUX | 436 | case TY_CSI_PS('m', 11) : /* IGNORED: mapping related */ break; //LINUX |
442 | case TY_CSI_PS('m', 12) : /* IGNORED: mapping related */ break; //LINUX | 437 | case TY_CSI_PS('m', 12) : /* IGNORED: mapping related */ break; //LINUX |
443 | case TY_CSI_PS('m', 22) : scr->resetRendition (RE_BOLD ); break; | 438 | case TY_CSI_PS('m', 22) : scr->resetRendition (RE_BOLD ); break; |
444 | case TY_CSI_PS('m', 24) : scr->resetRendition (RE_UNDERLINE); break; | 439 | case TY_CSI_PS('m', 24) : scr->resetRendition (RE_UNDERLINE); break; |
445 | case TY_CSI_PS('m', 25) : scr->resetRendition (RE_BLINK ); break; | 440 | case TY_CSI_PS('m', 25) : scr->resetRendition (RE_BLINK ); break; |
446 | case TY_CSI_PS('m', 27) : scr->resetRendition (RE_REVERSE ); break; | 441 | case TY_CSI_PS('m', 27) : scr->resetRendition (RE_REVERSE ); break; |
447 | 442 | ||
448 | case TY_CSI_PS('m', 30) : scr->setForeColor ( 0); break; | 443 | case TY_CSI_PS('m', 30) : scr->setForeColor ( 0); break; |
449 | case TY_CSI_PS('m', 31) : scr->setForeColor ( 1); break; | 444 | case TY_CSI_PS('m', 31) : scr->setForeColor ( 1); break; |
450 | case TY_CSI_PS('m', 32) : scr->setForeColor ( 2); break; | 445 | case TY_CSI_PS('m', 32) : scr->setForeColor ( 2); break; |
451 | case TY_CSI_PS('m', 33) : scr->setForeColor ( 3); break; | 446 | case TY_CSI_PS('m', 33) : scr->setForeColor ( 3); break; |
452 | case TY_CSI_PS('m', 34) : scr->setForeColor ( 4); break; | 447 | case TY_CSI_PS('m', 34) : scr->setForeColor ( 4); break; |
453 | case TY_CSI_PS('m', 35) : scr->setForeColor ( 5); break; | 448 | case TY_CSI_PS('m', 35) : scr->setForeColor ( 5); break; |
454 | case TY_CSI_PS('m', 36) : scr->setForeColor ( 6); break; | 449 | case TY_CSI_PS('m', 36) : scr->setForeColor ( 6); break; |
455 | case TY_CSI_PS('m', 37) : scr->setForeColor ( 7); break; | 450 | case TY_CSI_PS('m', 37) : scr->setForeColor ( 7); break; |
456 | case TY_CSI_PS('m', 39) : scr->setForeColorToDefault( ); break; | 451 | case TY_CSI_PS('m', 39) : scr->setForeColorToDefault( ); break; |
457 | 452 | ||
458 | case TY_CSI_PS('m', 40) : scr->setBackColor ( 0); break; | 453 | case TY_CSI_PS('m', 40) : scr->setBackColor ( 0); break; |
459 | case TY_CSI_PS('m', 41) : scr->setBackColor ( 1); break; | 454 | case TY_CSI_PS('m', 41) : scr->setBackColor ( 1); break; |
460 | case TY_CSI_PS('m', 42) : scr->setBackColor ( 2); break; | 455 | case TY_CSI_PS('m', 42) : scr->setBackColor ( 2); break; |
461 | case TY_CSI_PS('m', 43) : scr->setBackColor ( 3); break; | 456 | case TY_CSI_PS('m', 43) : scr->setBackColor ( 3); break; |
462 | case TY_CSI_PS('m', 44) : scr->setBackColor ( 4); break; | 457 | case TY_CSI_PS('m', 44) : scr->setBackColor ( 4); break; |
463 | case TY_CSI_PS('m', 45) : scr->setBackColor ( 5); break; | 458 | case TY_CSI_PS('m', 45) : scr->setBackColor ( 5); break; |
464 | case TY_CSI_PS('m', 46) : scr->setBackColor ( 6); break; | 459 | case TY_CSI_PS('m', 46) : scr->setBackColor ( 6); break; |
465 | case TY_CSI_PS('m', 47) : scr->setBackColor ( 7); break; | 460 | case TY_CSI_PS('m', 47) : scr->setBackColor ( 7); break; |
466 | case TY_CSI_PS('m', 49) : scr->setBackColorToDefault( ); break; | 461 | case TY_CSI_PS('m', 49) : scr->setBackColorToDefault( ); break; |
467 | 462 | ||
468 | case TY_CSI_PS('m', 90) : scr->setForeColor ( 8); break; | 463 | case TY_CSI_PS('m', 90) : scr->setForeColor ( 8); break; |
469 | case TY_CSI_PS('m', 91) : scr->setForeColor ( 9); break; | 464 | case TY_CSI_PS('m', 91) : scr->setForeColor ( 9); break; |
470 | case TY_CSI_PS('m', 92) : scr->setForeColor ( 10); break; | 465 | case TY_CSI_PS('m', 92) : scr->setForeColor ( 10); break; |
471 | case TY_CSI_PS('m', 93) : scr->setForeColor ( 11); break; | 466 | case TY_CSI_PS('m', 93) : scr->setForeColor ( 11); break; |
472 | case TY_CSI_PS('m', 94) : scr->setForeColor ( 12); break; | 467 | case TY_CSI_PS('m', 94) : scr->setForeColor ( 12); break; |
473 | case TY_CSI_PS('m', 95) : scr->setForeColor ( 13); break; | 468 | case TY_CSI_PS('m', 95) : scr->setForeColor ( 13); break; |
474 | case TY_CSI_PS('m', 96) : scr->setForeColor ( 14); break; | 469 | case TY_CSI_PS('m', 96) : scr->setForeColor ( 14); break; |
475 | case TY_CSI_PS('m', 97) : scr->setForeColor ( 15); break; | 470 | case TY_CSI_PS('m', 97) : scr->setForeColor ( 15); break; |
476 | 471 | ||
477 | case TY_CSI_PS('m', 100) : scr->setBackColor ( 8); break; | 472 | case TY_CSI_PS('m', 100) : scr->setBackColor ( 8); break; |
478 | case TY_CSI_PS('m', 101) : scr->setBackColor ( 9); break; | 473 | case TY_CSI_PS('m', 101) : scr->setBackColor ( 9); break; |
479 | case TY_CSI_PS('m', 102) : scr->setBackColor ( 10); break; | 474 | case TY_CSI_PS('m', 102) : scr->setBackColor ( 10); break; |
480 | case TY_CSI_PS('m', 103) : scr->setBackColor ( 11); break; | 475 | case TY_CSI_PS('m', 103) : scr->setBackColor ( 11); break; |
481 | case TY_CSI_PS('m', 104) : scr->setBackColor ( 12); break; | 476 | case TY_CSI_PS('m', 104) : scr->setBackColor ( 12); break; |
482 | case TY_CSI_PS('m', 105) : scr->setBackColor ( 13); break; | 477 | case TY_CSI_PS('m', 105) : scr->setBackColor ( 13); break; |
483 | case TY_CSI_PS('m', 106) : scr->setBackColor ( 14); break; | 478 | case TY_CSI_PS('m', 106) : scr->setBackColor ( 14); break; |
484 | case TY_CSI_PS('m', 107) : scr->setBackColor ( 15); break; | 479 | case TY_CSI_PS('m', 107) : scr->setBackColor ( 15); break; |
485 | 480 | ||
486 | case TY_CSI_PS('n', 5) : reportStatus ( ); break; | 481 | case TY_CSI_PS('n', 5) : reportStatus ( ); break; |
487 | case TY_CSI_PS('n', 6) : reportCursorPosition ( ); break; | 482 | case TY_CSI_PS('n', 6) : reportCursorPosition ( ); break; |
488 | case TY_CSI_PS('q', 0) : /* IGNORED: LEDs off */ break; //VT100 | 483 | case TY_CSI_PS('q', 0) : /* IGNORED: LEDs off */ break; //VT100 |
489 | case TY_CSI_PS('q', 1) : /* IGNORED: LED1 on */ break; //VT100 | 484 | case TY_CSI_PS('q', 1) : /* IGNORED: LED1 on */ break; //VT100 |
490 | case TY_CSI_PS('q', 2) : /* IGNORED: LED2 on */ break; //VT100 | 485 | case TY_CSI_PS('q', 2) : /* IGNORED: LED2 on */ break; //VT100 |
491 | case TY_CSI_PS('q', 3) : /* IGNORED: LED3 on */ break; //VT100 | 486 | case TY_CSI_PS('q', 3) : /* IGNORED: LED3 on */ break; //VT100 |
492 | case TY_CSI_PS('q', 4) : /* IGNORED: LED4 on */ break; //VT100 | 487 | case TY_CSI_PS('q', 4) : /* IGNORED: LED4 on */ break; //VT100 |
493 | case TY_CSI_PS('x', 0) : reportTerminalParms ( 2); break; //VT100 | 488 | case TY_CSI_PS('x', 0) : reportTerminalParms ( 2); break; //VT100 |
494 | case TY_CSI_PS('x', 1) : reportTerminalParms ( 3); break; //VT100 | 489 | case TY_CSI_PS('x', 1) : reportTerminalParms ( 3); break; //VT100 |
495 | 490 | ||
496 | case TY_CSI_PN('@' ) : scr->insertChars (p ); break; | 491 | case TY_CSI_PN('@' ) : scr->insertChars (p ); break; |
497 | case TY_CSI_PN('A' ) : scr->cursorUp (p ); break; //VT100 | 492 | case TY_CSI_PN('A' ) : scr->cursorUp (p ); break; //VT100 |
498 | case TY_CSI_PN('B' ) : scr->cursorDown (p ); break; //VT100 | 493 | case TY_CSI_PN('B' ) : scr->cursorDown (p ); break; //VT100 |
499 | case TY_CSI_PN('C' ) : scr->cursorRight (p ); break; //VT100 | 494 | case TY_CSI_PN('C' ) : scr->cursorRight (p ); break; //VT100 |
500 | case TY_CSI_PN('D' ) : scr->cursorLeft (p ); break; //VT100 | 495 | case TY_CSI_PN('D' ) : scr->cursorLeft (p ); break; //VT100 |
501 | case TY_CSI_PN('G' ) : scr->setCursorX (p ); break; //LINUX | 496 | case TY_CSI_PN('G' ) : scr->setCursorX (p ); break; //LINUX |
502 | case TY_CSI_PN('H' ) : scr->setCursorYX (p, q); break; //VT100 | 497 | case TY_CSI_PN('H' ) : scr->setCursorYX (p, q); break; //VT100 |
503 | case TY_CSI_PN('L' ) : scr->insertLines (p ); break; | 498 | case TY_CSI_PN('L' ) : scr->insertLines (p ); break; |
504 | case TY_CSI_PN('M' ) : scr->deleteLines (p ); break; | 499 | case TY_CSI_PN('M' ) : scr->deleteLines (p ); break; |
505 | case TY_CSI_PN('P' ) : scr->deleteChars (p ); break; | 500 | case TY_CSI_PN('P' ) : scr->deleteChars (p ); break; |
506 | case TY_CSI_PN('X' ) : scr->eraseChars (p ); break; | 501 | case TY_CSI_PN('X' ) : scr->eraseChars (p ); break; |
507 | case TY_CSI_PN('c' ) : reportTerminalType ( ); break; //VT100 | 502 | case TY_CSI_PN('c' ) : reportTerminalType ( ); break; //VT100 |
508 | case TY_CSI_PN('d' ) : scr->setCursorY (p ); break; //LINUX | 503 | case TY_CSI_PN('d' ) : scr->setCursorY (p ); break; //LINUX |
509 | case TY_CSI_PN('f' ) : scr->setCursorYX (p, q); break; //VT100 | 504 | case TY_CSI_PN('f' ) : scr->setCursorYX (p, q); break; //VT100 |
510 | case TY_CSI_PN('r' ) : scr->setMargins (p, q); break; //VT100 | 505 | case TY_CSI_PN('r' ) : scr->setMargins (p, q); break; //VT100 |
511 | case TY_CSI_PN('y' ) : /* IGNORED: Confidence test */ break; //VT100 | 506 | case TY_CSI_PN('y' ) : /* IGNORED: Confidence test */ break; //VT100 |
512 | 507 | ||
513 | case TY_CSI_PR('h', 1) : setMode (MODE_AppCuKeys); break; //VT100 | 508 | case TY_CSI_PR('h', 1) : setMode (MODE_AppCuKeys); break; //VT100 |
514 | case TY_CSI_PR('l', 1) : resetMode (MODE_AppCuKeys); break; //VT100 | 509 | case TY_CSI_PR('l', 1) : resetMode (MODE_AppCuKeys); break; //VT100 |
515 | case TY_CSI_PR('s', 1) : saveMode (MODE_AppCuKeys); break; //FIXME | 510 | case TY_CSI_PR('s', 1) : saveMode (MODE_AppCuKeys); break; //FIXME |
516 | case TY_CSI_PR('r', 1) : restoreMode (MODE_AppCuKeys); break; //FIXME | 511 | case TY_CSI_PR('r', 1) : restoreMode (MODE_AppCuKeys); break; //FIXME |
517 | 512 | ||
518 | case TY_CSI_PR('l', 2) : resetMode (MODE_Ansi ); break; //VT100 | 513 | case TY_CSI_PR('l', 2) : resetMode (MODE_Ansi ); break; //VT100 |
519 | 514 | ||
520 | case TY_CSI_PR('h', 3) : setColumns ( 132); break; //VT100 | 515 | case TY_CSI_PR('h', 3) : setColumns ( 132); break; //VT100 |
521 | case TY_CSI_PR('l', 3) : setColumns ( 80); break; //VT100 | 516 | case TY_CSI_PR('l', 3) : setColumns ( 80); break; //VT100 |
522 | 517 | ||
523 | case TY_CSI_PR('h', 4) : /* IGNORED: soft scrolling */ break; //VT100 | 518 | case TY_CSI_PR('h', 4) : /* IGNORED: soft scrolling */ break; //VT100 |
524 | case TY_CSI_PR('l', 4) : /* IGNORED: soft scrolling */ break; //VT100 | 519 | case TY_CSI_PR('l', 4) : /* IGNORED: soft scrolling */ break; //VT100 |
525 | 520 | ||
526 | case TY_CSI_PR('h', 5) : scr-> setMode (MODE_Screen ); break; //VT100 | 521 | case TY_CSI_PR('h', 5) : scr-> setMode (MODE_Screen ); break; //VT100 |
527 | case TY_CSI_PR('l', 5) : scr-> resetMode (MODE_Screen ); break; //VT100 | 522 | case TY_CSI_PR('l', 5) : scr-> resetMode (MODE_Screen ); break; //VT100 |
528 | 523 | ||
529 | case TY_CSI_PR('h', 6) : scr-> setMode (MODE_Origin ); break; //VT100 | 524 | case TY_CSI_PR('h', 6) : scr-> setMode (MODE_Origin ); break; //VT100 |
530 | case TY_CSI_PR('l', 6) : scr-> resetMode (MODE_Origin ); break; //VT100 | 525 | case TY_CSI_PR('l', 6) : scr-> resetMode (MODE_Origin ); break; //VT100 |
531 | case TY_CSI_PR('s', 6) : scr-> saveMode (MODE_Origin ); break; //FIXME | 526 | case TY_CSI_PR('s', 6) : scr-> saveMode (MODE_Origin ); break; //FIXME |
532 | case TY_CSI_PR('r', 6) : scr->restoreMode (MODE_Origin ); break; //FIXME | 527 | case TY_CSI_PR('r', 6) : scr->restoreMode (MODE_Origin ); break; //FIXME |
533 | 528 | ||
534 | case TY_CSI_PR('h', 7) : scr-> setMode (MODE_Wrap ); break; //VT100 | 529 | case TY_CSI_PR('h', 7) : scr-> setMode (MODE_Wrap ); break; //VT100 |
535 | case TY_CSI_PR('l', 7) : scr-> resetMode (MODE_Wrap ); break; //VT100 | 530 | case TY_CSI_PR('l', 7) : scr-> resetMode (MODE_Wrap ); break; //VT100 |
536 | case TY_CSI_PR('s', 7) : scr-> saveMode (MODE_Wrap ); break; //FIXME | 531 | case TY_CSI_PR('s', 7) : scr-> saveMode (MODE_Wrap ); break; //FIXME |
537 | case TY_CSI_PR('r', 7) : scr->restoreMode (MODE_Wrap ); break; //FIXME | 532 | case TY_CSI_PR('r', 7) : scr->restoreMode (MODE_Wrap ); break; //FIXME |
538 | 533 | ||
539 | case TY_CSI_PR('h', 8) : /* IGNORED: autorepeat on */ break; //VT100 | 534 | case TY_CSI_PR('h', 8) : /* IGNORED: autorepeat on */ break; //VT100 |
540 | case TY_CSI_PR('l', 8) : /* IGNORED: autorepeat off */ break; //VT100 | 535 | case TY_CSI_PR('l', 8) : /* IGNORED: autorepeat off */ break; //VT100 |
541 | 536 | ||
542 | case TY_CSI_PR('h', 9) : /* IGNORED: interlace */ break; //VT100 | 537 | case TY_CSI_PR('h', 9) : /* IGNORED: interlace */ break; //VT100 |
543 | case TY_CSI_PR('l', 9) : /* IGNORED: interlace */ break; //VT100 | 538 | case TY_CSI_PR('l', 9) : /* IGNORED: interlace */ break; //VT100 |
544 | 539 | ||
545 | case TY_CSI_PR('h', 25) : setMode (MODE_Cursor ); break; //VT100 | 540 | case TY_CSI_PR('h', 25) : setMode (MODE_Cursor ); break; //VT100 |
546 | case TY_CSI_PR('l', 25) : resetMode (MODE_Cursor ); break; //VT100 | 541 | case TY_CSI_PR('l', 25) : resetMode (MODE_Cursor ); break; //VT100 |
547 | 542 | ||
548 | case TY_CSI_PR('h', 41) : /* IGNORED: obsolete more(1) fix */ break; //XTERM | 543 | case TY_CSI_PR('h', 41) : /* IGNORED: obsolete more(1) fix */ break; //XTERM |
549 | case TY_CSI_PR('l', 41) : /* IGNORED: obsolete more(1) fix */ break; //XTERM | 544 | case TY_CSI_PR('l', 41) : /* IGNORED: obsolete more(1) fix */ break; //XTERM |
550 | case TY_CSI_PR('s', 41) : /* IGNORED: obsolete more(1) fix */ break; //XTERM | 545 | case TY_CSI_PR('s', 41) : /* IGNORED: obsolete more(1) fix */ break; //XTERM |
551 | case TY_CSI_PR('r', 41) : /* IGNORED: obsolete more(1) fix */ break; //XTERM | 546 | case TY_CSI_PR('r', 41) : /* IGNORED: obsolete more(1) fix */ break; //XTERM |
552 | 547 | ||
553 | case TY_CSI_PR('h', 47) : setMode (MODE_AppScreen); break; //VT100 | 548 | case TY_CSI_PR('h', 47) : setMode (MODE_AppScreen); break; //VT100 |
554 | case TY_CSI_PR('l', 47) : resetMode (MODE_AppScreen); break; //VT100 | 549 | case TY_CSI_PR('l', 47) : resetMode (MODE_AppScreen); break; //VT100 |
555 | 550 | ||
556 | case TY_CSI_PR('h', 1000) : setMode (MODE_Mouse1000); break; //XTERM | 551 | case TY_CSI_PR('h', 1000) : setMode (MODE_Mouse1000); break; //XTERM |
557 | case TY_CSI_PR('l', 1000) : resetMode (MODE_Mouse1000); break; //XTERM | 552 | case TY_CSI_PR('l', 1000) : resetMode (MODE_Mouse1000); break; //XTERM |
558 | case TY_CSI_PR('s', 1000) : saveMode (MODE_Mouse1000); break; //XTERM | 553 | case TY_CSI_PR('s', 1000) : saveMode (MODE_Mouse1000); break; //XTERM |
559 | case TY_CSI_PR('r', 1000) : restoreMode (MODE_Mouse1000); break; //XTERM | 554 | case TY_CSI_PR('r', 1000) : restoreMode (MODE_Mouse1000); break; //XTERM |
560 | 555 | ||
561 | case TY_CSI_PR('h', 1001) : /* IGNORED: hilite mouse tracking */ break; //XTERM | 556 | case TY_CSI_PR('h', 1001) : /* IGNORED: hilite mouse tracking */ break; //XTERM |
562 | case TY_CSI_PR('l', 1001) : /* IGNORED: hilite mouse tracking */ break; //XTERM | 557 | case TY_CSI_PR('l', 1001) : /* IGNORED: hilite mouse tracking */ break; //XTERM |
563 | case TY_CSI_PR('s', 1001) : /* IGNORED: hilite mouse tracking */ break; //XTERM | 558 | case TY_CSI_PR('s', 1001) : /* IGNORED: hilite mouse tracking */ break; //XTERM |
564 | case TY_CSI_PR('r', 1001) : /* IGNORED: hilite mouse tracking */ break; //XTERM | 559 | case TY_CSI_PR('r', 1001) : /* IGNORED: hilite mouse tracking */ break; //XTERM |
565 | 560 | ||
566 | case TY_CSI_PR('h', 1047) : setMode (MODE_AppScreen); break; //XTERM | 561 | case TY_CSI_PR('h', 1047) : setMode (MODE_AppScreen); break; //XTERM |
567 | case TY_CSI_PR('l', 1047) : resetMode (MODE_AppScreen); break; //XTERM | 562 | case TY_CSI_PR('l', 1047) : resetMode (MODE_AppScreen); break; //XTERM |
568 | 563 | ||
569 | //FIXME: Unitoken: save translations | 564 | //FIXME: Unitoken: save translations |
570 | case TY_CSI_PR('h', 1048) : saveCursor ( ); break; //XTERM | 565 | case TY_CSI_PR('h', 1048) : saveCursor ( ); break; //XTERM |
571 | case TY_CSI_PR('l', 1048) : restoreCursor ( ); break; //XTERM | 566 | case TY_CSI_PR('l', 1048) : restoreCursor ( ); break; //XTERM |
572 | 567 | ||
573 | //FIXME: every once new sequences like this pop up in xterm. | 568 | //FIXME: every once new sequences like this pop up in xterm. |
574 | // Here's a guess of what they could mean. | 569 | // Here's a guess of what they could mean. |
575 | case TY_CSI_PR('h', 1049) : setMode (MODE_AppScreen); break; //XTERM | 570 | case TY_CSI_PR('h', 1049) : setMode (MODE_AppScreen); break; //XTERM |
576 | case TY_CSI_PR('l', 1049) : resetMode (MODE_AppScreen); break; //XTERM | 571 | case TY_CSI_PR('l', 1049) : resetMode (MODE_AppScreen); break; //XTERM |
577 | 572 | ||
578 | //FIXME: when changing between vt52 and ansi mode evtl do some resetting. | 573 | //FIXME: when changing between vt52 and ansi mode evtl do some resetting. |
579 | case TY_VT52__('A' ) : scr->cursorUp ( 1); break; //VT52 | 574 | case TY_VT52__('A' ) : scr->cursorUp ( 1); break; //VT52 |
580 | case TY_VT52__('B' ) : scr->cursorDown ( 1); break; //VT52 | 575 | case TY_VT52__('B' ) : scr->cursorDown ( 1); break; //VT52 |
581 | case TY_VT52__('C' ) : scr->cursorRight ( 1); break; //VT52 | 576 | case TY_VT52__('C' ) : scr->cursorRight ( 1); break; //VT52 |
582 | case TY_VT52__('D' ) : scr->cursorLeft ( 1); break; //VT52 | 577 | case TY_VT52__('D' ) : scr->cursorLeft ( 1); break; //VT52 |
583 | 578 | ||
584 | case TY_VT52__('F' ) : setAndUseCharset (0, '0'); break; //VT52 | 579 | case TY_VT52__('F' ) : setAndUseCharset (0, '0'); break; //VT52 |
585 | case TY_VT52__('G' ) : setAndUseCharset (0, 'B'); break; //VT52 | 580 | case TY_VT52__('G' ) : setAndUseCharset (0, 'B'); break; //VT52 |
586 | 581 | ||
587 | case TY_VT52__('H' ) : scr->setCursorYX (1,1 ); break; //VT52 | 582 | case TY_VT52__('H' ) : scr->setCursorYX (1,1 ); break; //VT52 |
588 | case TY_VT52__('I' ) : scr->reverseIndex ( ); break; //VT52 | 583 | case TY_VT52__('I' ) : scr->reverseIndex ( ); break; //VT52 |
589 | case TY_VT52__('J' ) : scr->clearToEndOfScreen ( ); break; //VT52 | 584 | case TY_VT52__('J' ) : scr->clearToEndOfScreen ( ); break; //VT52 |
590 | case TY_VT52__('K' ) : scr->clearToEndOfLine ( ); break; //VT52 | 585 | case TY_VT52__('K' ) : scr->clearToEndOfLine ( ); break; //VT52 |
591 | case TY_VT52__('Y' ) : scr->setCursorYX (p-31,q-31 ); break; //VT52 | 586 | case TY_VT52__('Y' ) : scr->setCursorYX (p-31,q-31 ); break; //VT52 |
592 | case TY_VT52__('Z' ) : reportTerminalType ( ); break; //VT52 | 587 | case TY_VT52__('Z' ) : reportTerminalType ( ); break; //VT52 |
593 | case TY_VT52__('<' ) : setMode (MODE_Ansi ); break; //VT52 | 588 | case TY_VT52__('<' ) : setMode (MODE_Ansi ); break; //VT52 |
594 | case TY_VT52__('=' ) : setMode (MODE_AppKeyPad); break; //VT52 | 589 | case TY_VT52__('=' ) : setMode (MODE_AppKeyPad); break; //VT52 |
595 | case TY_VT52__('>' ) : resetMode (MODE_AppKeyPad); break; //VT52 | 590 | case TY_VT52__('>' ) : resetMode (MODE_AppKeyPad); break; //VT52 |
596 | 591 | ||
597 | default : ReportErrorToken(); break; | 592 | default : ReportErrorToken(); break; |
598 | }; | 593 | }; |
599 | } | 594 | } |
600 | 595 | ||
601 | /* ------------------------------------------------------------------------- */ | 596 | /* ------------------------------------------------------------------------- */ |
602 | /* */ | 597 | /* */ |
603 | /* Terminal to Host protocol */ | 598 | /* Terminal to Host protocol */ |
604 | /* */ | 599 | /* */ |
605 | /* ------------------------------------------------------------------------- */ | 600 | /* ------------------------------------------------------------------------- */ |
606 | 601 | ||
607 | /* | 602 | /* |
608 | Outgoing bytes originate from several sources: | 603 | Outgoing bytes originate from several sources: |
609 | 604 | ||
610 | - Replies to Enquieries. | 605 | - Replies to Enquieries. |
611 | - Mouse Events | 606 | - Mouse Events |
612 | - Keyboard Events | 607 | - Keyboard Events |
613 | */ | 608 | */ |
614 | 609 | ||
615 | /*! | 610 | /*! |
616 | */ | 611 | */ |
617 | 612 | ||
618 | void TEmuVt102::sendString(const char* s) | 613 | void TEmuVt102::sendString(const char* s) |
619 | { | 614 | { |
620 | emit sndBlock(s,strlen(s)); | 615 | emit sndBlock(s,strlen(s)); |
621 | } | 616 | } |
622 | 617 | ||
623 | // Replies ----------------------------------------------------------------- -- | 618 | // Replies ----------------------------------------------------------------- -- |
624 | 619 | ||
625 | // This section copes with replies send as response to an enquiery control code. | 620 | // This section copes with replies send as response to an enquiery control code. |
626 | 621 | ||
627 | /*! | 622 | /*! |
628 | */ | 623 | */ |
629 | 624 | ||
630 | void TEmuVt102::reportCursorPosition() | 625 | void TEmuVt102::reportCursorPosition() |
631 | { char tmp[20]; | 626 | { char tmp[20]; |
632 | sprintf(tmp,"\033[%d;%dR",scr->getCursorY()+1,scr->getCursorX()+1); | 627 | sprintf(tmp,"\033[%d;%dR",scr->getCursorY()+1,scr->getCursorX()+1); |
633 | sendString(tmp); | 628 | sendString(tmp); |
634 | } | 629 | } |
635 | 630 | ||
636 | /* | 631 | /* |
637 | What follows here is rather obsolete and faked stuff. | 632 | What follows here is rather obsolete and faked stuff. |
638 | The correspondent enquieries are neverthenless issued. | 633 | The correspondent enquieries are neverthenless issued. |
639 | */ | 634 | */ |
640 | 635 | ||
641 | /*! | 636 | /*! |
642 | */ | 637 | */ |
643 | 638 | ||
644 | void TEmuVt102::reportTerminalType() | 639 | void TEmuVt102::reportTerminalType() |
645 | { | 640 | { |
646 | //FIXME: should change? | 641 | //FIXME: should change? |
647 | if (getMode(MODE_Ansi)) | 642 | if (getMode(MODE_Ansi)) |
648 | // sendString("\033[?1;2c"); // I'm a VT100 with AP0 //FIXME: send only in response to ^[[0c | 643 | // sendString("\033[?1;2c"); // I'm a VT100 with AP0 //FIXME: send only in response to ^[[0c |
649 | sendString("\033[>0;115;0c"); // I'm a VT220 //FIXME: send only in response to ^[[>c | 644 | sendString("\033[>0;115;0c"); // I'm a VT220 //FIXME: send only in response to ^[[>c |
650 | else | 645 | else |
651 | sendString("\033/Z"); // I'm a VT52 | 646 | sendString("\033/Z"); // I'm a VT52 |
652 | } | 647 | } |
653 | 648 | ||
654 | void TEmuVt102::reportTerminalParms(int p) | 649 | void TEmuVt102::reportTerminalParms(int p) |
655 | // DECREPTPARM | 650 | // DECREPTPARM |
656 | { char tmp[100]; | 651 | { char tmp[100]; |
657 | sprintf(tmp,"\033[%d;1;1;112;112;1;0x",p); // not really true. | 652 | sprintf(tmp,"\033[%d;1;1;112;112;1;0x",p); // not really true. |
658 | sendString(tmp); | 653 | sendString(tmp); |
659 | } | 654 | } |
660 | 655 | ||
661 | /*! | 656 | /*! |
662 | */ | 657 | */ |
663 | 658 | ||
664 | void TEmuVt102::reportStatus() | 659 | void TEmuVt102::reportStatus() |
665 | { | 660 | { |
666 | sendString("\033[0n"); //VT100. Device status report. 0 = Ready. | 661 | sendString("\033[0n"); //VT100. Device status report. 0 = Ready. |
667 | } | 662 | } |
668 | 663 | ||
669 | /*! | 664 | /*! |
670 | */ | 665 | */ |
671 | 666 | ||
672 | #define ANSWER_BACK "" // This is really obsolete VT100 stuff. | 667 | #define ANSWER_BACK "" // This is really obsolete VT100 stuff. |
673 | 668 | ||
674 | void TEmuVt102::reportAnswerBack() | 669 | void TEmuVt102::reportAnswerBack() |
675 | { | 670 | { |
676 | sendString(ANSWER_BACK); | 671 | sendString(ANSWER_BACK); |
677 | } | 672 | } |
678 | 673 | ||
679 | // Mouse Handling ---------------------------------------------------------- -- | 674 | // Mouse Handling ---------------------------------------------------------- -- |
680 | 675 | ||
681 | /*! | 676 | /*! |
682 | Mouse clicks are possibly reported to the client | 677 | Mouse clicks are possibly reported to the client |
683 | application if it has issued interest in them. | 678 | application if it has issued interest in them. |
684 | They are normally consumed by the widget for copy | 679 | They are normally consumed by the widget for copy |
685 | and paste, but may be propagated from the widget | 680 | and paste, but may be propagated from the widget |
686 | when gui->setMouseMarks is set via setMode(MODE_Mouse1000). | 681 | when gui->setMouseMarks is set via setMode(MODE_Mouse1000). |
687 | 682 | ||
688 | `x',`y' are 1-based. | 683 | `x',`y' are 1-based. |
689 | `ev' (event) indicates the button pressed (0-2) | 684 | `ev' (event) indicates the button pressed (0-2) |
690 | or a general mouse release (3). | 685 | or a general mouse release (3). |
691 | */ | 686 | */ |
692 | 687 | ||
693 | void TEmuVt102::onMouse( int cb, int cx, int cy ) | 688 | void TEmuVt102::onMouse( int cb, int cx, int cy ) |
694 | { char tmp[20]; | 689 | { char tmp[20]; |
695 | if (!connected) return; | 690 | if (!connected) return; |
696 | sprintf(tmp,"\033[M%c%c%c",cb+040,cx+040,cy+040); | 691 | sprintf(tmp,"\033[M%c%c%c",cb+040,cx+040,cy+040); |
697 | sendString(tmp); | 692 | sendString(tmp); |
698 | } | 693 | } |
699 | 694 | ||
700 | // Keyboard Handling ------------------------------------------------------- -- | 695 | // Keyboard Handling ------------------------------------------------------- -- |
701 | 696 | ||
702 | #define encodeMode(M,B) BITS(B,getMode(M)) | 697 | #define encodeMode(M,B) BITS(B,getMode(M)) |
703 | #define encodeStat(M,B) BITS(B,((ev->state() & (M)) == (M))) | 698 | #define encodeStat(M,B) BITS(B,((ev->state() & (M)) == (M))) |
704 | 699 | ||
705 | /* | 700 | /* |
706 | Keyboard event handling has been simplified somewhat by pushing | 701 | Keyboard event handling has been simplified somewhat by pushing |
707 | the complications towards a configuration file [see KeyTrans class]. | 702 | the complications towards a configuration file [see KeyTrans class]. |
708 | */ | 703 | */ |
709 | 704 | ||
710 | void TEmuVt102::onKeyPress( QKeyEvent* ev ) | 705 | void TEmuVt102::onKeyPress( QKeyEvent* ev ) |
711 | { | 706 | { |
712 | if (!connected) return; // someone else gets the keys | 707 | if (!connected) return; // someone else gets the keys |
713 | 708 | ||
714 | //printf("State/Key: 0x%04x 0x%04x (%d,%d)\n",ev->state(),ev->key(),ev->text().length(),ev->text().length()?ev->text().ascii()[0]:0); | 709 | //printf("State/Key: 0x%04x 0x%04x (%d,%d)\n",ev->state(),ev->key(),ev->text().length(),ev->text().length()?ev->text().ascii()[0]:0); |
715 | 710 | ||
716 | // revert to non-history when typing | 711 | // revert to non-history when typing |
717 | if (scr->getHistCursor() != scr->getHistLines()); | 712 | if (scr->getHistCursor() != scr->getHistLines()); |
718 | scr->setHistCursor(scr->getHistLines()); | 713 | scr->setHistCursor(scr->getHistLines()); |
719 | 714 | ||
720 | // lookup in keyboard translation table ... | 715 | // lookup in keyboard translation table ... |
721 | int cmd; const char* txt; int len; | 716 | int cmd; const char* txt; int len; |
722 | if (keytrans->findEntry(ev->key(), encodeMode(MODE_NewLine , BITS_NewLine ) + // OLD, | 717 | if (keytrans->findEntry(ev->key(), encodeMode(MODE_NewLine , BITS_NewLine ) + // OLD, |
723 | encodeMode(MODE_Ansi , BITS_Ansi ) + // OBSOLETE, | 718 | encodeMode(MODE_Ansi , BITS_Ansi ) + // OBSOLETE, |
724 | encodeMode(MODE_AppCuKeys, BITS_AppCuKeys ) + // VT100 stuff | 719 | encodeMode(MODE_AppCuKeys, BITS_AppCuKeys ) + // VT100 stuff |
725 | encodeStat(ControlButton , BITS_Control ) + | 720 | encodeStat(ControlButton , BITS_Control ) + |
726 | encodeStat(ShiftButton , BITS_Shift ) + | 721 | encodeStat(ShiftButton , BITS_Shift ) + |
727 | encodeStat(AltButton , BITS_Alt ), | 722 | encodeStat(AltButton , BITS_Alt ), |
728 | &cmd, &txt, &len )) | 723 | &cmd, &txt, &len )) |
729 | //printf("cmd: %d, %s, %d\n",cmd,txt,len); | 724 | //printf("cmd: %d, %s, %d\n",cmd,txt,len); |
730 | switch(cmd) // ... and execute if found. | 725 | switch(cmd) // ... and execute if found. |
731 | { | 726 | { |
732 | case CMD_emitSelection : gui->emitSelection(); return; | 727 | case CMD_emitSelection : gui->emitSelection(); return; |
733 | case CMD_scrollPageUp : gui->doScroll(-gui->Lines()/2); return; | 728 | case CMD_scrollPageUp : gui->doScroll(-gui->Lines()/2); return; |
734 | case CMD_scrollPageDown : gui->doScroll(+gui->Lines()/2); return; | 729 | case CMD_scrollPageDown : gui->doScroll(+gui->Lines()/2); return; |
735 | case CMD_scrollLineUp : gui->doScroll(-1 ); return; | 730 | case CMD_scrollLineUp : gui->doScroll(-1 ); return; |
736 | case CMD_scrollLineDown : gui->doScroll(+1 ); return; | 731 | case CMD_scrollLineDown : gui->doScroll(+1 ); return; |
737 | case CMD_send : emit sndBlock(txt,len); return; | 732 | case CMD_send : emit sndBlock(txt,len); return; |
738 | case CMD_prevSession : emit prevSession(); return; | 733 | case CMD_prevSession : emit prevSession(); return; |
739 | case CMD_nextSession : emit nextSession(); return; | 734 | case CMD_nextSession : emit nextSession(); return; |
740 | } | 735 | } |
741 | 736 | ||
742 | // fall back handling | 737 | // fall back handling |
743 | if (!ev->text().isEmpty()) | 738 | if (!ev->text().isEmpty()) |
744 | { | 739 | { |
745 | if (ev->state() & AltButton) sendString("\033"); // ESC, this is the ALT prefix | 740 | if (ev->state() & AltButton) sendString("\033"); // ESC, this is the ALT prefix |
746 | /// very hacky | 741 | /// very hacky |
747 | if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='A')) sendString("\01"); | 742 | if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='A')) sendString("\01"); |
748 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='B')) sendString("\02"); | 743 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='B')) sendString("\02"); |
749 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='C')) sendString("\03"); | 744 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='C')) sendString("\03"); |
750 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='D')) sendString("\04"); | 745 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='D')) sendString("\04"); |
751 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='E')) sendString("\05"); | 746 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='E')) sendString("\05"); |
752 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='F')) sendString("\06"); | 747 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='F')) sendString("\06"); |
753 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='G')) sendString("\07"); | 748 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='G')) sendString("\07"); |
754 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='H')) sendString("\010"); | 749 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='H')) sendString("\010"); |
755 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='I')) sendString("\011"); | 750 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='I')) sendString("\011"); |
756 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='J')) sendString("\012"); | 751 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='J')) sendString("\012"); |
757 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='K')) sendString("\013"); | 752 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='K')) sendString("\013"); |
758 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='L')) sendString("\014"); | 753 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='L')) sendString("\014"); |
759 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='M')) sendString("\015"); | 754 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='M')) sendString("\015"); |
760 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='N')) sendString("\016"); | 755 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='N')) sendString("\016"); |
761 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='O')) sendString("\017"); | 756 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='O')) sendString("\017"); |
762 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='P')) sendString("\020"); | 757 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='P')) sendString("\020"); |
763 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='Q')) sendString("\021"); | 758 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='Q')) sendString("\021"); |
764 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='R')) sendString("\022"); | 759 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='R')) sendString("\022"); |
765 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='S')) sendString("\023"); | 760 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='S')) sendString("\023"); |
766 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='T')) sendString("\024"); | 761 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='T')) sendString("\024"); |
767 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='U')) sendString("\025"); | 762 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='U')) sendString("\025"); |
768 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='V')) sendString("\026"); | 763 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='V')) sendString("\026"); |
769 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='W')) sendString("\027"); | 764 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='W')) sendString("\027"); |
770 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='X')) sendString("\030"); | 765 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='X')) sendString("\030"); |
771 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='Y')) sendString("\031"); | 766 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='Y')) sendString("\031"); |
772 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='Z')) sendString("\032"); | 767 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='Z')) sendString("\032"); |
773 | else { | 768 | else { |
774 | QCString s = codec->fromUnicode(ev->text()); // encode for application | 769 | QCString s = codec->fromUnicode(ev->text()); // encode for application |
775 | emit sndBlock(s.data(),s.length()); // we may well have s.length() > 1 | 770 | emit sndBlock(s.data(),s.length()); // we may well have s.length() > 1 |
776 | } | 771 | } |
777 | return; | 772 | return; |
778 | } | 773 | } |
779 | } | 774 | } |
780 | 775 | ||
781 | /* ------------------------------------------------------------------------- */ | 776 | /* ------------------------------------------------------------------------- */ |
782 | /* */ | 777 | /* */ |
783 | /* VT100 Charsets */ | 778 | /* VT100 Charsets */ |
784 | /* */ | 779 | /* */ |
785 | /* ------------------------------------------------------------------------- */ | 780 | /* ------------------------------------------------------------------------- */ |
786 | 781 | ||
787 | // Character Set Conversion ------------------------------------------------ -- | 782 | // Character Set Conversion ------------------------------------------------ -- |
788 | 783 | ||
789 | /* | 784 | /* |
790 | The processing contains a VT100 specific code translation layer. | 785 | The processing contains a VT100 specific code translation layer. |
791 | It's still in use and mainly responsible for the line drawing graphics. | 786 | It's still in use and mainly responsible for the line drawing graphics. |
792 | 787 | ||
793 | These and some other glyphs are assigned to codes (0x5f-0xfe) | 788 | These and some other glyphs are assigned to codes (0x5f-0xfe) |
794 | normally occupied by the latin letters. Since this codes also | 789 | normally occupied by the latin letters. Since this codes also |
795 | appear within control sequences, the extra code conversion | 790 | appear within control sequences, the extra code conversion |
796 | does not permute with the tokenizer and is placed behind it | 791 | does not permute with the tokenizer and is placed behind it |
797 | in the pipeline. It only applies to tokens, which represent | 792 | in the pipeline. It only applies to tokens, which represent |
798 | plain characters. | 793 | plain characters. |
799 | 794 | ||
800 | This conversion it eventually continued in TEWidget.C, since | 795 | This conversion it eventually continued in TEWidget.C, since |
801 | it might involve VT100 enhanced fonts, which have these | 796 | it might involve VT100 enhanced fonts, which have these |
802 | particular glyphs allocated in (0x00-0x1f) in their code page. | 797 | particular glyphs allocated in (0x00-0x1f) in their code page. |
diff --git a/core/apps/embeddedkonsole/TEmulation.cpp b/core/apps/embeddedkonsole/TEmulation.cpp index a539757..54f408e 100644 --- a/core/apps/embeddedkonsole/TEmulation.cpp +++ b/core/apps/embeddedkonsole/TEmulation.cpp | |||
@@ -1,379 +1,376 @@ | |||
1 | /* -------------------------------------------------------------------------- */ | 1 | /* -------------------------------------------------------------------------- */ |
2 | /* */ | 2 | /* */ |
3 | /* [TEmulation.cpp] Terminal Emulation Decoder */ | 3 | /* [TEmulation.cpp] Terminal Emulation Decoder */ |
4 | /* */ | 4 | /* */ |
5 | /* -------------------------------------------------------------------------- */ | 5 | /* -------------------------------------------------------------------------- */ |
6 | /* */ | 6 | /* */ |
7 | /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ | 7 | /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ |
8 | /* */ | 8 | /* */ |
9 | /* This file is part of Konsole - an X terminal for KDE */ | 9 | /* This file is part of Konsole - an X terminal for KDE */ |
10 | /* */ | 10 | /* */ |
11 | /* -------------------------------------------------------------------------- */ | 11 | /* -------------------------------------------------------------------------- */ |
12 | /* */ | 12 | /* */ |
13 | /* Ported Konsole to Qt/Embedded */ | 13 | /* Ported Konsole to Qt/Embedded */ |
14 | /* */ | 14 | /* */ |
15 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ | 15 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ |
16 | /* */ | 16 | /* */ |
17 | /* -------------------------------------------------------------------------- */ | 17 | /* -------------------------------------------------------------------------- */ |
18 | 18 | ||
19 | /*! \class TEmulation | 19 | /*! \class TEmulation |
20 | 20 | ||
21 | \brief Mediator between TEWidget and TEScreen. | 21 | \brief Mediator between TEWidget and TEScreen. |
22 | 22 | ||
23 | This class is responsible to scan the escapes sequences of the terminal | 23 | This class is responsible to scan the escapes sequences of the terminal |
24 | emulation and to map it to their corresponding semantic complements. | 24 | emulation and to map it to their corresponding semantic complements. |
25 | Thus this module knows mainly about decoding escapes sequences and | 25 | Thus this module knows mainly about decoding escapes sequences and |
26 | is a stateless device w.r.t. the semantics. | 26 | is a stateless device w.r.t. the semantics. |
27 | 27 | ||
28 | It is also responsible to refresh the TEWidget by certain rules. | 28 | It is also responsible to refresh the TEWidget by certain rules. |
29 | 29 | ||
30 | \sa TEWidget \sa TEScreen | 30 | \sa TEWidget \sa TEScreen |
31 | 31 | ||
32 | \par A note on refreshing | 32 | \par A note on refreshing |
33 | 33 | ||
34 | Although the modifications to the current screen image could immediately | 34 | Although the modifications to the current screen image could immediately |
35 | be propagated via `TEWidget' to the graphical surface, we have chosen | 35 | be propagated via `TEWidget' to the graphical surface, we have chosen |
36 | another way here. | 36 | another way here. |
37 | 37 | ||
38 | The reason for doing so is twofold. | 38 | The reason for doing so is twofold. |
39 | 39 | ||
40 | First, experiments show that directly displaying the operation results | 40 | First, experiments show that directly displaying the operation results |
41 | in slowing down the overall performance of emulations. Displaying | 41 | in slowing down the overall performance of emulations. Displaying |
42 | individual characters using X11 creates a lot of overhead. | 42 | individual characters using X11 creates a lot of overhead. |
43 | 43 | ||
44 | Second, by using the following refreshing method, the screen operations | 44 | Second, by using the following refreshing method, the screen operations |
45 | can be completely separated from the displaying. This greatly simplifies | 45 | can be completely separated from the displaying. This greatly simplifies |
46 | the programmer's task of coding and maintaining the screen operations, | 46 | the programmer's task of coding and maintaining the screen operations, |
47 | since one need not worry about differential modifications on the | 47 | since one need not worry about differential modifications on the |
48 | display affecting the operation of concern. | 48 | display affecting the operation of concern. |
49 | 49 | ||
50 | We use a refreshing algorithm here that has been adoped from rxvt/kvt. | 50 | We use a refreshing algorithm here that has been adoped from rxvt/kvt. |
51 | 51 | ||
52 | By this, refreshing is driven by a timer, which is (re)started whenever | 52 | By this, refreshing is driven by a timer, which is (re)started whenever |
53 | a new bunch of data to be interpreted by the emulation arives at `onRcvBlock'. | 53 | a new bunch of data to be interpreted by the emulation arives at `onRcvBlock'. |
54 | As soon as no more data arrive for `BULK_TIMEOUT' milliseconds, we trigger | 54 | As soon as no more data arrive for `BULK_TIMEOUT' milliseconds, we trigger |
55 | refresh. This rule suits both bulk display operation as done by curses as | 55 | refresh. This rule suits both bulk display operation as done by curses as |
56 | well as individual characters typed. | 56 | well as individual characters typed. |
57 | (BULK_TIMEOUT < 1000 / max characters received from keyboard per second). | 57 | (BULK_TIMEOUT < 1000 / max characters received from keyboard per second). |
58 | 58 | ||
59 | Additionally, we trigger refreshing by newlines comming in to make visual | 59 | Additionally, we trigger refreshing by newlines comming in to make visual |
60 | snapshots of lists as produced by `cat', `ls' and likely programs, thereby | 60 | snapshots of lists as produced by `cat', `ls' and likely programs, thereby |
61 | producing the illusion of a permanent and immediate display operation. | 61 | producing the illusion of a permanent and immediate display operation. |
62 | 62 | ||
63 | As a sort of catch-all needed for cases where none of the above | 63 | As a sort of catch-all needed for cases where none of the above |
64 | conditions catch, the screen refresh is also triggered by a count | 64 | conditions catch, the screen refresh is also triggered by a count |
65 | of incoming bulks (`bulk_incnt'). | 65 | of incoming bulks (`bulk_incnt'). |
66 | */ | 66 | */ |
67 | 67 | ||
68 | /* FIXME | 68 | /* FIXME |
69 | - evtl. the bulk operations could be made more transparent. | 69 | - evtl. the bulk operations could be made more transparent. |
70 | */ | 70 | */ |
71 | 71 | ||
72 | #include "TEmulation.h" | 72 | #include "TEmulation.h" |
73 | #include "TEWidget.h" | ||
74 | #include "TEScreen.h" | ||
75 | #include <stdio.h> | 73 | #include <stdio.h> |
76 | #include <stdlib.h> | 74 | #include <stdlib.h> |
77 | #include <unistd.h> | 75 | #include <unistd.h> |
78 | #include <qkeycode.h> | ||
79 | 76 | ||
80 | 77 | ||
81 | /* ------------------------------------------------------------------------- */ | 78 | /* ------------------------------------------------------------------------- */ |
82 | /* */ | 79 | /* */ |
83 | /* TEmulation */ | 80 | /* TEmulation */ |
84 | /* */ | 81 | /* */ |
85 | /* ------------------------------------------------------------------------- */ | 82 | /* ------------------------------------------------------------------------- */ |
86 | 83 | ||
87 | #define CNTL(c) ((c)-'@') | 84 | #define CNTL(c) ((c)-'@') |
88 | 85 | ||
89 | /*! | 86 | /*! |
90 | */ | 87 | */ |
91 | 88 | ||
92 | TEmulation::TEmulation(TEWidget* gui) | 89 | TEmulation::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 | ||
135 | TEmulation::~TEmulation() | 132 | TEmulation::~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 | ||
145 | void TEmulation::setScreen(int n) | 142 | void TEmulation::setScreen(int n) |
146 | { | 143 | { |
147 | scr = screen[n&1]; | 144 | scr = screen[n&1]; |
148 | } | 145 | } |
149 | 146 | ||
150 | void TEmulation::setHistory(bool on) | 147 | void 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 | ||
157 | bool TEmulation::history() | 154 | bool TEmulation::history() |
158 | { | 155 | { |
159 | return screen[0]->hasScroll(); | 156 | return screen[0]->hasScroll(); |
160 | } | 157 | } |
161 | 158 | ||
162 | void TEmulation::setCodec(int c) | 159 | void 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 | ||
171 | void TEmulation::setKeytrans(int no) | 168 | void TEmulation::setKeytrans(int no) |
172 | { | 169 | { |
173 | keytrans = KeyTrans::find(no); | 170 | keytrans = KeyTrans::find(no); |
174 | } | 171 | } |
175 | 172 | ||
176 | void TEmulation::setKeytrans(const char * no) | 173 | void 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 | ||
193 | void TEmulation::onRcvChar(int c) | 190 | void 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 | ||
219 | void TEmulation::onKeyPress( QKeyEvent* ev ) | 216 | void 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 | ||
244 | void TEmulation::onRcvBlock(const char *s, int len) | 241 | void 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 | ||
261 | void TEmulation::onSelectionBegin(const int x, const int y) { | 258 | void 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 | ||
267 | void TEmulation::onSelectionExtend(const int x, const int y) { | 264 | void TEmulation::onSelectionExtend(const int x, const int y) { |
268 | if (!connected) return; | 265 | if (!connected) return; |
269 | scr->setSelExtentXY(x,y); | 266 | scr->setSelExtentXY(x,y); |
270 | showBulk(); | 267 | showBulk(); |
271 | } | 268 | } |
272 | 269 | ||
273 | void TEmulation::setSelection(const BOOL preserve_line_breaks) { | 270 | void TEmulation::setSelection(const BOOL preserve_line_breaks) { |
274 | if (!connected) return; | 271 | if (!connected) return; |
275 | QString t = scr->getSelText(preserve_line_breaks); | 272 | QString t = scr->getSelText(preserve_line_breaks); |
276 | if (!t.isNull()) gui->setSelection(t); | 273 | if (!t.isNull()) gui->setSelection(t); |
277 | } | 274 | } |
278 | 275 | ||
279 | void TEmulation::clearSelection() { | 276 | void TEmulation::clearSelection() { |
280 | if (!connected) return; | 277 | if (!connected) return; |
281 | scr->clearSelection(); | 278 | scr->clearSelection(); |
282 | showBulk(); | 279 | showBulk(); |
283 | } | 280 | } |
284 | 281 | ||
285 | // Refreshing -------------------------------------------------------------- -- | 282 | // Refreshing -------------------------------------------------------------- -- |
286 | 283 | ||
287 | #define BULK_TIMEOUT 20 | 284 | #define BULK_TIMEOUT 20 |
288 | 285 | ||
289 | /*! | 286 | /*! |
290 | called when \n comes in. Evtl. triggers showBulk at endBulk | 287 | called when \n comes in. Evtl. triggers showBulk at endBulk |
291 | */ | 288 | */ |
292 | 289 | ||
293 | void TEmulation::bulkNewline() | 290 | void TEmulation::bulkNewline() |
294 | { | 291 | { |
295 | bulk_nlcnt += 1; | 292 | bulk_nlcnt += 1; |
296 | bulk_incnt = 0; // reset bulk counter since `nl' rule applies | 293 | bulk_incnt = 0; // reset bulk counter since `nl' rule applies |
297 | } | 294 | } |
298 | 295 | ||
299 | /*! | 296 | /*! |
300 | */ | 297 | */ |
301 | 298 | ||
302 | void TEmulation::showBulk() | 299 | void TEmulation::showBulk() |
303 | { | 300 | { |
304 | bulk_nlcnt = 0; // reset bulk newline counter | 301 | bulk_nlcnt = 0; // reset bulk newline counter |
305 | bulk_incnt = 0; // reset bulk counter | 302 | bulk_incnt = 0; // reset bulk counter |
306 | if (connected) | 303 | if (connected) |
307 | { | 304 | { |
308 | ca* image = scr->getCookedImage(); // get the image | 305 | ca* image = scr->getCookedImage(); // get the image |
309 | gui->setImage(image, | 306 | gui->setImage(image, |
310 | scr->getLines(), | 307 | scr->getLines(), |
311 | scr->getColumns()); // actual refresh | 308 | scr->getColumns()); // actual refresh |
312 | free(image); | 309 | free(image); |
313 | 310 | ||
314 | //FIXME: check that we do not trigger other draw event here. | 311 | //FIXME: check that we do not trigger other draw event here. |
315 | gui->setScroll(scr->getHistCursor(),scr->getHistLines()); | 312 | gui->setScroll(scr->getHistCursor(),scr->getHistLines()); |
316 | 313 | ||
317 | } | 314 | } |
318 | } | 315 | } |
319 | 316 | ||
320 | void TEmulation::bulkStart() | 317 | void TEmulation::bulkStart() |
321 | { | 318 | { |
322 | if (bulk_timer.isActive()) bulk_timer.stop(); | 319 | if (bulk_timer.isActive()) bulk_timer.stop(); |
323 | } | 320 | } |
324 | 321 | ||
325 | void TEmulation::bulkEnd() | 322 | void TEmulation::bulkEnd() |
326 | { | 323 | { |
327 | if ( bulk_nlcnt > gui->Lines() || bulk_incnt > 20 ) | 324 | if ( bulk_nlcnt > gui->Lines() || bulk_incnt > 20 ) |
328 | showBulk(); // resets bulk_??cnt to 0, too. | 325 | showBulk(); // resets bulk_??cnt to 0, too. |
329 | else | 326 | else |
330 | bulk_timer.start(BULK_TIMEOUT,TRUE); | 327 | bulk_timer.start(BULK_TIMEOUT,TRUE); |
331 | } | 328 | } |
332 | 329 | ||
333 | void TEmulation::setConnect(bool c) | 330 | void TEmulation::setConnect(bool c) |
334 | { | 331 | { |
335 | connected = c; | 332 | connected = c; |
336 | if ( connected) | 333 | if ( connected) |
337 | { | 334 | { |
338 | onImageSizeChange(gui->Lines(), gui->Columns()); | 335 | onImageSizeChange(gui->Lines(), gui->Columns()); |
339 | showBulk(); | 336 | showBulk(); |
340 | } | 337 | } |
341 | else | 338 | else |
342 | { | 339 | { |
343 | scr->clearSelection(); | 340 | scr->clearSelection(); |
344 | } | 341 | } |
345 | } | 342 | } |
346 | 343 | ||
347 | // --------------------------------------------------------------------------- | 344 | // --------------------------------------------------------------------------- |
348 | 345 | ||
349 | /*! triggered by image size change of the TEWidget `gui'. | 346 | /*! triggered by image size change of the TEWidget `gui'. |
350 | 347 | ||
351 | This event is simply propagated to the attached screens | 348 | This event is simply propagated to the attached screens |
352 | and to the related serial line. | 349 | and to the related serial line. |
353 | */ | 350 | */ |
354 | 351 | ||
355 | void TEmulation::onImageSizeChange(int lines, int columns) { | 352 | void TEmulation::onImageSizeChange(int lines, int columns) { |
356 | if (!connected) return; | 353 | if (!connected) return; |
357 | screen[0]->resizeImage(lines,columns); | 354 | screen[0]->resizeImage(lines,columns); |
358 | screen[1]->resizeImage(lines,columns); | 355 | screen[1]->resizeImage(lines,columns); |
359 | showBulk(); | 356 | showBulk(); |
360 | emit ImageSizeChanged(lines,columns); // propagate event to serial line | 357 | emit ImageSizeChanged(lines,columns); // propagate event to serial line |
361 | } | 358 | } |
362 | 359 | ||
363 | void TEmulation::onHistoryCursorChange(int cursor) { | 360 | void TEmulation::onHistoryCursorChange(int cursor) { |
364 | if (!connected) return; | 361 | if (!connected) return; |
365 | scr->setHistCursor(cursor); | 362 | scr->setHistCursor(cursor); |
366 | showBulk(); | 363 | showBulk(); |
367 | } | 364 | } |
368 | 365 | ||
369 | void TEmulation::onHorzCursorChange(int cursor) { | 366 | void TEmulation::onHorzCursorChange(int cursor) { |
370 | if (!connected) return; | 367 | if (!connected) return; |
371 | scr->setHorzCursor(cursor); | 368 | scr->setHorzCursor(cursor); |
372 | showBulk(); | 369 | showBulk(); |
373 | } | 370 | } |
374 | 371 | ||
375 | void TEmulation::setColumns(int columns) { | 372 | void TEmulation::setColumns(int columns) { |
376 | //FIXME: this goes strange ways. | 373 | //FIXME: this goes strange ways. |
377 | // Can we put this straight or explain it at least? | 374 | // Can we put this straight or explain it at least? |
378 | emit changeColumns(columns); | 375 | emit changeColumns(columns); |
379 | } | 376 | } |
diff --git a/core/apps/embeddedkonsole/commandeditdialog.cpp b/core/apps/embeddedkonsole/commandeditdialog.cpp index e4255f3..c0066d8 100644 --- a/core/apps/embeddedkonsole/commandeditdialog.cpp +++ b/core/apps/embeddedkonsole/commandeditdialog.cpp | |||
@@ -1,199 +1,191 @@ | |||
1 | //comandeditdialog.cpp | 1 | //comandeditdialog.cpp |
2 | 2 | ||
3 | #include "commandeditdialog.h" | 3 | #include "commandeditdialog.h" |
4 | #include "playlistselection.h" | 4 | #include "playlistselection.h" |
5 | #include <qstring.h> | ||
6 | #include <qpe/config.h> | 5 | #include <qpe/config.h> |
7 | #include <qtoolbar.h> | ||
8 | #include <qwidget.h> | ||
9 | #include <qmenubar.h> | ||
10 | #include <qpe/resource.h> | 6 | #include <qpe/resource.h> |
11 | #include <qlist.h> | ||
12 | #include <qtoolbutton.h> | 7 | #include <qtoolbutton.h> |
13 | #include <qvbox.h> | ||
14 | #include <qlistview.h> | ||
15 | #include <qlineedit.h> | 8 | #include <qlineedit.h> |
16 | #include <qheader.h> | 9 | #include <qheader.h> |
17 | #include <qlabel.h> | 10 | #include <qlabel.h> |
18 | #include <qmessagebox.h> | ||
19 | #include "smallcommandeditdialogbase.h" | 11 | #include "smallcommandeditdialogbase.h" |
20 | 12 | ||
21 | CommandEditDialog::CommandEditDialog(QWidget *parent, const char* name, WFlags fl ) | 13 | CommandEditDialog::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 | ||
95 | connect(ToolButton5,SIGNAL(clicked()),m_PlayListSelection,SLOT(moveSelectedDown())); | 87 | connect(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 | ||
116 | m_PlayListSelection->addStringToSelection("ls "); | 108 | m_PlayListSelection->addStringToSelection("ls "); |
117 | m_PlayListSelection->addStringToSelection("cardctl eject"); | 109 | m_PlayListSelection->addStringToSelection("cardctl eject"); |
118 | m_PlayListSelection->addStringToSelection("cat "); | 110 | m_PlayListSelection->addStringToSelection("cat "); |
119 | m_PlayListSelection->addStringToSelection("cd "); | 111 | m_PlayListSelection->addStringToSelection("cd "); |
120 | m_PlayListSelection->addStringToSelection("chmod "); | 112 | m_PlayListSelection->addStringToSelection("chmod "); |
121 | m_PlayListSelection->addStringToSelection("cp "); | 113 | m_PlayListSelection->addStringToSelection("cp "); |
122 | m_PlayListSelection->addStringToSelection("dc "); | 114 | m_PlayListSelection->addStringToSelection("dc "); |
123 | m_PlayListSelection->addStringToSelection("df "); | 115 | m_PlayListSelection->addStringToSelection("df "); |
124 | m_PlayListSelection->addStringToSelection("dmesg"); | 116 | m_PlayListSelection->addStringToSelection("dmesg"); |
125 | m_PlayListSelection->addStringToSelection("echo "); | 117 | m_PlayListSelection->addStringToSelection("echo "); |
126 | m_PlayListSelection->addStringToSelection("env"); | 118 | m_PlayListSelection->addStringToSelection("env"); |
127 | m_PlayListSelection->addStringToSelection("find "); | 119 | m_PlayListSelection->addStringToSelection("find "); |
128 | m_PlayListSelection->addStringToSelection("free"); | 120 | m_PlayListSelection->addStringToSelection("free"); |
129 | m_PlayListSelection->addStringToSelection("grep "); | 121 | m_PlayListSelection->addStringToSelection("grep "); |
130 | m_PlayListSelection->addStringToSelection("ifconfig "); | 122 | m_PlayListSelection->addStringToSelection("ifconfig "); |
131 | m_PlayListSelection->addStringToSelection("ipkg "); | 123 | m_PlayListSelection->addStringToSelection("ipkg "); |
132 | m_PlayListSelection->addStringToSelection("mkdir "); | 124 | m_PlayListSelection->addStringToSelection("mkdir "); |
133 | m_PlayListSelection->addStringToSelection("mv "); | 125 | m_PlayListSelection->addStringToSelection("mv "); |
134 | m_PlayListSelection->addStringToSelection("nc localhost 7776"); | 126 | m_PlayListSelection->addStringToSelection("nc localhost 7776"); |
135 | m_PlayListSelection->addStringToSelection("nc localhost 7777"); | 127 | m_PlayListSelection->addStringToSelection("nc localhost 7777"); |
136 | m_PlayListSelection->addStringToSelection("nslookup "); | 128 | m_PlayListSelection->addStringToSelection("nslookup "); |
137 | m_PlayListSelection->addStringToSelection("ping "); | 129 | m_PlayListSelection->addStringToSelection("ping "); |
138 | m_PlayListSelection->addStringToSelection("ps aux"); | 130 | m_PlayListSelection->addStringToSelection("ps aux"); |
139 | m_PlayListSelection->addStringToSelection("pwd "); | 131 | m_PlayListSelection->addStringToSelection("pwd "); |
140 | m_PlayListSelection->addStringToSelection("rm "); | 132 | m_PlayListSelection->addStringToSelection("rm "); |
141 | m_PlayListSelection->addStringToSelection("rmdir "); | 133 | m_PlayListSelection->addStringToSelection("rmdir "); |
142 | m_PlayListSelection->addStringToSelection("route "); | 134 | m_PlayListSelection->addStringToSelection("route "); |
143 | m_PlayListSelection->addStringToSelection("set "); | 135 | m_PlayListSelection->addStringToSelection("set "); |
144 | m_PlayListSelection->addStringToSelection("traceroute"); | 136 | m_PlayListSelection->addStringToSelection("traceroute"); |
145 | 137 | ||
146 | } | 138 | } |
147 | } | 139 | } |
148 | CommandEditDialog::~CommandEditDialog() | 140 | CommandEditDialog::~CommandEditDialog() |
149 | { | 141 | { |
150 | } | 142 | } |
151 | 143 | ||
152 | void CommandEditDialog::accept() | 144 | void CommandEditDialog::accept() |
153 | { | 145 | { |
154 | int i = 0; | 146 | int 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 | ||
179 | void CommandEditDialog::showEditDialog() | 171 | void CommandEditDialog::showEditDialog() |
180 | { | 172 | { |
181 | editCommandBase *d = new editCommandBase(this,"smalleditdialog", TRUE); | 173 | editCommandBase *d = new editCommandBase(this,"smalleditdialog", TRUE); |
182 | d->setCaption("Edit command"); | 174 | d->setCaption("Edit command"); |
183 | d->TextLabel->setText("Edit command:"); | 175 | d->TextLabel->setText("Edit command:"); |
184 | d->commandEdit->setText(m_PlayListSelection->currentItem()->text(0)); | 176 | d->commandEdit->setText(m_PlayListSelection->currentItem()->text(0)); |
185 | int i = d->exec(); | 177 | int i = d->exec(); |
186 | if ((i==1) && (!(d->commandEdit->text()).isEmpty())) | 178 | if ((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 | ||
190 | void CommandEditDialog::showAddDialog() | 182 | void CommandEditDialog::showAddDialog() |
191 | { | 183 | { |
192 | 184 | ||
193 | editCommandBase *d = new editCommandBase(this,"smalleditdialog", TRUE); | 185 | editCommandBase *d = new editCommandBase(this,"smalleditdialog", TRUE); |
194 | int i = d->exec(); | 186 | int i = d->exec(); |
195 | if ((i==1) && (!(d->commandEdit->text()).isEmpty())) | 187 | if ((i==1) && (!(d->commandEdit->text()).isEmpty())) |
196 | m_PlayListSelection->addStringToSelection(d->commandEdit->text()); | 188 | m_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 | */ |
43 | Form1::Form1( QWidget* parent, const char* name, WFlags fl ) | 39 | Form1::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 | */ |
60 | Form1::~Form1() | 56 | Form1::~Form1() |
61 | { | 57 | { |
62 | // no need to delete child widgets, Qt does it all for us | 58 | // no need to delete child widgets, Qt does it all for us |
63 | } | 59 | } |
64 | 60 | ||
diff --git a/core/apps/embeddedkonsole/keytrans.cpp b/core/apps/embeddedkonsole/keytrans.cpp index d569ae0..45a7960 100644 --- a/core/apps/embeddedkonsole/keytrans.cpp +++ b/core/apps/embeddedkonsole/keytrans.cpp | |||
@@ -1,706 +1,705 @@ | |||
1 | /* -------------------------------------------------------------------------- */ | 1 | /* -------------------------------------------------------------------------- */ |
2 | /* */ | 2 | /* */ |
3 | /* [keytrans.C] Keyboard Translation */ | 3 | /* [keytrans.C] Keyboard Translation */ |
4 | /* */ | 4 | /* */ |
5 | /* -------------------------------------------------------------------------- */ | 5 | /* -------------------------------------------------------------------------- */ |
6 | /* */ | 6 | /* */ |
7 | /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ | 7 | /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ |
8 | /* */ | 8 | /* */ |
9 | /* This file is part of Konsole - an X terminal for KDE */ | 9 | /* This file is part of Konsole - an X terminal for KDE */ |
10 | /* */ | 10 | /* */ |
11 | /* -------------------------------------------------------------------------- */ | 11 | /* -------------------------------------------------------------------------- */ |
12 | /* */ | 12 | /* */ |
13 | /* Ported Konsole to Qt/Embedded */ | 13 | /* Ported Konsole to Qt/Embedded */ |
14 | /* */ | 14 | /* */ |
15 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ | 15 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ |
16 | /* */ | 16 | /* */ |
17 | /* -------------------------------------------------------------------------- */ | 17 | /* -------------------------------------------------------------------------- */ |
18 | 18 | ||
19 | /* | 19 | /* |
20 | The keyboard translation table allows to configure konsoles behavior | 20 | The keyboard translation table allows to configure konsoles behavior |
21 | on key strokes. | 21 | on key strokes. |
22 | 22 | ||
23 | FIXME: some bug crept in, disallowing '\0' to be emitted. | 23 | FIXME: some bug crept in, disallowing '\0' to be emitted. |
24 | */ | 24 | */ |
25 | 25 | ||
26 | #include "keytrans.h" | 26 | #include "keytrans.h" |
27 | 27 | ||
28 | #include <qpe/qpeapplication.h> | 28 | #include <qpe/qpeapplication.h> |
29 | 29 | ||
30 | #include <qnamespace.h> | 30 | #include <qnamespace.h> |
31 | #include <qbuffer.h> | 31 | #include <qbuffer.h> |
32 | #include <qobject.h> | 32 | #include <qobject.h> |
33 | #include <qdict.h> | 33 | #include <qdict.h> |
34 | #include <qintdict.h> | 34 | #include <qintdict.h> |
35 | #include <qfile.h> | 35 | #include <qfile.h> |
36 | #include <qglobal.h> | 36 | #include <qglobal.h> |
37 | #include <qdir.h> | 37 | #include <qdir.h> |
38 | 38 | ||
39 | //#include <kstddirs.h> | 39 | //#include <kstddirs.h> |
40 | //nclude <klocale.h> | 40 | //nclude <klocale.h> |
41 | 41 | ||
42 | #include <stdio.h> | 42 | #include <stdio.h> |
43 | 43 | ||
44 | 44 | ||
45 | #undef USE_APPDATA_DIR | 45 | #undef USE_APPDATA_DIR |
46 | 46 | ||
47 | 47 | ||
48 | #define HERE printf("%s(%d): here\n",__FILE__,__LINE__) | 48 | #define HERE printf("%s(%d): here\n",__FILE__,__LINE__) |
49 | 49 | ||
50 | /* KeyEntry | 50 | /* KeyEntry |
51 | 51 | ||
52 | instances represent the individual assignments | 52 | instances represent the individual assignments |
53 | */ | 53 | */ |
54 | 54 | ||
55 | KeyTrans::KeyEntry::KeyEntry(int _ref, int _key, int _bits, int _mask, int _cmd, QString _txt) | 55 | KeyTrans::KeyEntry::KeyEntry(int _ref, int _key, int _bits, int _mask, int _cmd, QString _txt) |
56 | : ref(_ref), key(_key), bits(_bits), mask(_mask), cmd(_cmd), txt(_txt) | 56 | : ref(_ref), key(_key), bits(_bits), mask(_mask), cmd(_cmd), txt(_txt) |
57 | { | 57 | { |
58 | } | 58 | } |
59 | 59 | ||
60 | KeyTrans::KeyEntry::~KeyEntry() | 60 | KeyTrans::KeyEntry::~KeyEntry() |
61 | { | 61 | { |
62 | } | 62 | } |
63 | 63 | ||
64 | bool KeyTrans::KeyEntry::matches(int _key, int _bits, int _mask) | 64 | bool KeyTrans::KeyEntry::matches(int _key, int _bits, int _mask) |
65 | { int m = mask & _mask; | 65 | { int m = mask & _mask; |
66 | return _key == key && (bits & m) == (_bits & m); | 66 | return _key == key && (bits & m) == (_bits & m); |
67 | } | 67 | } |
68 | 68 | ||
69 | QString KeyTrans::KeyEntry::text() | 69 | QString KeyTrans::KeyEntry::text() |
70 | { | 70 | { |
71 | return txt; | 71 | return txt; |
72 | } | 72 | } |
73 | 73 | ||
74 | /* KeyTrans | 74 | /* KeyTrans |
75 | 75 | ||
76 | combines the individual assignments to a proper map | 76 | combines the individual assignments to a proper map |
77 | Takes part in a collection themself. | 77 | Takes part in a collection themself. |
78 | */ | 78 | */ |
79 | 79 | ||
80 | KeyTrans::KeyTrans() | 80 | KeyTrans::KeyTrans() |
81 | { | 81 | { |
82 | path = ""; | 82 | path = ""; |
83 | numb = 0; | 83 | numb = 0; |
84 | } | 84 | } |
85 | 85 | ||
86 | KeyTrans::~KeyTrans() | 86 | KeyTrans::~KeyTrans() |
87 | { | 87 | { |
88 | } | 88 | } |
89 | 89 | ||
90 | KeyTrans::KeyEntry* KeyTrans::addEntry(int ref, int key, int bits, int mask, int cmd, QString txt) | 90 | KeyTrans::KeyEntry* KeyTrans::addEntry(int ref, int key, int bits, int mask, int cmd, QString txt) |
91 | // returns conflicting entry | 91 | // returns conflicting entry |
92 | { | 92 | { |
93 | for (QListIterator<KeyEntry> it(table); it.current(); ++it) | 93 | for (QListIterator<KeyEntry> it(table); it.current(); ++it) |
94 | { | 94 | { |
95 | if (it.current()->matches(key,bits,mask)) | 95 | if (it.current()->matches(key,bits,mask)) |
96 | { | 96 | { |
97 | return it.current(); | 97 | return it.current(); |
98 | } | 98 | } |
99 | } | 99 | } |
100 | table.append(new KeyEntry(ref,key,bits,mask,cmd,txt)); | 100 | table.append(new KeyEntry(ref,key,bits,mask,cmd,txt)); |
101 | return (KeyEntry*)NULL; | 101 | return (KeyEntry*)NULL; |
102 | } | 102 | } |
103 | 103 | ||
104 | bool KeyTrans::findEntry(int key, int bits, int* cmd, const char** txt, int* len) | 104 | bool KeyTrans::findEntry(int key, int bits, int* cmd, const char** txt, int* len) |
105 | { | 105 | { |
106 | for (QListIterator<KeyEntry> it(table); it.current(); ++it) | 106 | for (QListIterator<KeyEntry> it(table); it.current(); ++it) |
107 | if (it.current()->matches(key,bits,0xffff)) | 107 | if (it.current()->matches(key,bits,0xffff)) |
108 | { | 108 | { |
109 | *cmd = it.current()->cmd; | 109 | *cmd = it.current()->cmd; |
110 | *txt = it.current()->txt.ascii(); | 110 | *txt = it.current()->txt.ascii(); |
111 | *len = it.current()->txt.length(); | 111 | *len = it.current()->txt.length(); |
112 | return TRUE; | 112 | return TRUE; |
113 | } | 113 | } |
114 | return FALSE; | 114 | return FALSE; |
115 | } | 115 | } |
116 | 116 | ||
117 | /* ------------------------------------------------------------------------- */ | 117 | /* ------------------------------------------------------------------------- */ |
118 | /* */ | 118 | /* */ |
119 | /* Scanner for keyboard configuration */ | 119 | /* Scanner for keyboard configuration */ |
120 | /* */ | 120 | /* */ |
121 | /* ------------------------------------------------------------------------- */ | 121 | /* ------------------------------------------------------------------------- */ |
122 | 122 | ||
123 | // regular tokenizer | 123 | // regular tokenizer |
124 | /* Tokens | 124 | /* Tokens |
125 | - Spaces | 125 | - Spaces |
126 | - Name (A-Za-z0-9)+ | 126 | - Name (A-Za-z0-9)+ |
127 | - String | 127 | - String |
128 | - Opr on of +-: | 128 | - Opr on of +-: |
129 | */ | 129 | */ |
130 | 130 | ||
131 | #define SYMName 0 | 131 | #define SYMName 0 |
132 | #define SYMString 1 | 132 | #define SYMString 1 |
133 | #define SYMEol 2 | 133 | #define SYMEol 2 |
134 | #define SYMEof 3 | 134 | #define SYMEof 3 |
135 | #define SYMOpr 4 | 135 | #define SYMOpr 4 |
136 | #define SYMError 5 | 136 | #define SYMError 5 |
137 | 137 | ||
138 | #define inRange(L,X,H) ((L <= X) && (X <= H)) | 138 | #define inRange(L,X,H) ((L <= X) && (X <= H)) |
139 | #define isNibble(X) (inRange('A',X,'F')||inRange('a',X,'f')||inRange('0',X,'9')) | 139 | #define isNibble(X) (inRange('A',X,'F')||inRange('a',X,'f')||inRange('0',X,'9')) |
140 | #define convNibble(X) (inRange('0',X,'9')?X-'0':X+10-(inRange('A',X,'F')?'A':'a')) | 140 | #define convNibble(X) (inRange('0',X,'9')?X-'0':X+10-(inRange('A',X,'F')?'A':'a')) |
141 | 141 | ||
142 | class KeytabReader | 142 | class KeytabReader |
143 | { | 143 | { |
144 | public: | 144 | public: |
145 | KeytabReader(QString p, QIODevice &d); | 145 | KeytabReader(QString p, QIODevice &d); |
146 | public: | 146 | public: |
147 | void getCc(); | 147 | void getCc(); |
148 | void getSymbol(); | 148 | void getSymbol(); |
149 | void parseTo(KeyTrans* kt); | 149 | void parseTo(KeyTrans* kt); |
150 | void ReportError(const char* msg); | 150 | void ReportError(const char* msg); |
151 | void ReportToken(); // diagnostic | 151 | void ReportToken(); // diagnostic |
152 | private: | 152 | private: |
153 | int sym; | 153 | int sym; |
154 | QString res; | 154 | QString res; |
155 | int len; | 155 | int len; |
156 | int slinno; | 156 | int slinno; |
157 | int scolno; | 157 | int scolno; |
158 | private: | 158 | private: |
159 | int cc; | 159 | int cc; |
160 | int linno; | 160 | int linno; |
161 | int colno; | 161 | int colno; |
162 | QIODevice* buf; | 162 | QIODevice* buf; |
163 | QString path; | 163 | QString path; |
164 | }; | 164 | }; |
165 | 165 | ||
166 | 166 | ||
167 | KeytabReader::KeytabReader(QString p, QIODevice &d) | 167 | KeytabReader::KeytabReader(QString p, QIODevice &d) |
168 | { | 168 | { |
169 | path = p; | 169 | path = p; |
170 | buf = &d; | 170 | buf = &d; |
171 | cc = 0; | 171 | cc = 0; |
172 | } | 172 | } |
173 | 173 | ||
174 | void KeytabReader::getCc() | 174 | void KeytabReader::getCc() |
175 | { | 175 | { |
176 | if (cc == '\n') { linno += 1; colno = 0; } | 176 | if (cc == '\n') { linno += 1; colno = 0; } |
177 | if (cc < 0) return; | 177 | if (cc < 0) return; |
178 | cc = buf->getch(); | 178 | cc = buf->getch(); |
179 | colno += 1; | 179 | colno += 1; |
180 | } | 180 | } |
181 | 181 | ||
182 | void KeytabReader::getSymbol() | 182 | void KeytabReader::getSymbol() |
183 | { | 183 | { |
184 | res = ""; len = 0; sym = SYMError; | 184 | res = ""; len = 0; sym = SYMError; |
185 | while (cc == ' ') getCc(); // skip spaces | 185 | while (cc == ' ') getCc(); // skip spaces |
186 | if (cc == '#') // skip comment | 186 | if (cc == '#') // skip comment |
187 | { | 187 | { |
188 | while (cc != '\n' && cc > 0) getCc(); | 188 | while (cc != '\n' && cc > 0) getCc(); |
189 | } | 189 | } |
190 | slinno = linno; | 190 | slinno = linno; |
191 | scolno = colno; | 191 | scolno = colno; |
192 | if (cc <= 0) | 192 | if (cc <= 0) |
193 | { | 193 | { |
194 | sym = SYMEof; return; // eos | 194 | sym = SYMEof; return; // eos |
195 | } | 195 | } |
196 | if (cc == '\n') | 196 | if (cc == '\n') |
197 | { | 197 | { |
198 | getCc(); | 198 | getCc(); |
199 | sym = SYMEol; return; // eol | 199 | sym = SYMEol; return; // eol |
200 | } | 200 | } |
201 | if (inRange('A',cc,'Z')||inRange('a',cc,'z')||inRange('0',cc,'9')) | 201 | if (inRange('A',cc,'Z')||inRange('a',cc,'z')||inRange('0',cc,'9')) |
202 | { | 202 | { |
203 | while (inRange('A',cc,'Z') || inRange('a',cc,'z') || inRange('0',cc,'9')) | 203 | while (inRange('A',cc,'Z') || inRange('a',cc,'z') || inRange('0',cc,'9')) |
204 | { | 204 | { |
205 | res = res + (char)cc; | 205 | res = res + (char)cc; |
206 | getCc(); | 206 | getCc(); |
207 | } | 207 | } |
208 | sym = SYMName; | 208 | sym = SYMName; |
209 | return; | 209 | return; |
210 | } | 210 | } |
211 | if (strchr("+-:",cc)) | 211 | if (strchr("+-:",cc)) |
212 | { | 212 | { |
213 | res = ""; | 213 | res = ""; |
214 | res = res + (char)cc; | 214 | res = res + (char)cc; |
215 | getCc(); | 215 | getCc(); |
216 | sym = SYMOpr; return; | 216 | sym = SYMOpr; return; |
217 | } | 217 | } |
218 | if (cc == '"') | 218 | if (cc == '"') |
219 | { | 219 | { |
220 | getCc(); | 220 | getCc(); |
221 | while (cc >= ' ' && cc != '"') | 221 | while (cc >= ' ' && cc != '"') |
222 | { int sc; | 222 | { int sc; |
223 | if (cc == '\\') // handle quotation | 223 | if (cc == '\\') // handle quotation |
224 | { | 224 | { |
225 | getCc(); | 225 | getCc(); |
226 | switch (cc) | 226 | switch (cc) |
227 | { | 227 | { |
228 | case 'E' : sc = 27; getCc(); break; | 228 | case 'E' : sc = 27; getCc(); break; |
229 | case 'b' : sc = 8; getCc(); break; | 229 | case 'b' : sc = 8; getCc(); break; |
230 | case 'f' : sc = 12; getCc(); break; | 230 | case 'f' : sc = 12; getCc(); break; |
231 | case 't' : sc = 9; getCc(); break; | 231 | case 't' : sc = 9; getCc(); break; |
232 | case 'r' : sc = 13; getCc(); break; | 232 | case 'r' : sc = 13; getCc(); break; |
233 | case 'n' : sc = 10; getCc(); break; | 233 | case 'n' : sc = 10; getCc(); break; |
234 | case '\\' : // fall thru | 234 | case '\\' : // fall thru |
235 | case '"' : sc = cc; getCc(); break; | 235 | case '"' : sc = cc; getCc(); break; |
236 | case 'x' : getCc(); | 236 | case 'x' : getCc(); |
237 | sc = 0; | 237 | sc = 0; |
238 | if (!isNibble(cc)) return; sc = 16*sc + convNibble(cc); getCc(); | 238 | if (!isNibble(cc)) return; sc = 16*sc + convNibble(cc); getCc(); |
239 | if (!isNibble(cc)) return; sc = 16*sc + convNibble(cc); getCc(); | 239 | if (!isNibble(cc)) return; sc = 16*sc + convNibble(cc); getCc(); |
240 | break; | 240 | break; |
241 | default : return; | 241 | default : return; |
242 | } | 242 | } |
243 | } | 243 | } |
244 | else | 244 | else |
245 | { | 245 | { |
246 | // regular char | 246 | // regular char |
247 | sc = cc; getCc(); | 247 | sc = cc; getCc(); |
248 | } | 248 | } |
249 | res = res + (char)sc; | 249 | res = res + (char)sc; |
250 | len = len + 1; | 250 | len = len + 1; |
251 | } | 251 | } |
252 | if (cc != '"') return; | 252 | if (cc != '"') return; |
253 | getCc(); | 253 | getCc(); |
254 | sym = SYMString; return; | 254 | sym = SYMString; return; |
255 | } | 255 | } |
256 | } | 256 | } |
257 | 257 | ||
258 | void KeytabReader::ReportToken() // diagnostic | 258 | void 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 | ||
275 | void KeytabReader::ReportError(const char* msg) // diagnostic | 275 | void 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 | ||
282 | class KeyTransSymbols | 282 | class KeyTransSymbols |
283 | { | 283 | { |
284 | public: | 284 | public: |
285 | KeyTransSymbols(); | 285 | KeyTransSymbols(); |
286 | protected: | 286 | protected: |
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); |
293 | public: | 293 | public: |
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 | ||
299 | static KeyTransSymbols * syms = 0L; | 299 | static 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 | ||
307 | KeyTrans* KeyTrans::fromDevice(QString path, QIODevice &buf) | 307 | KeyTrans* 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 | ||
318 | void KeytabReader::parseTo(KeyTrans* kt) | 318 | void 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 | ||
328 | Loop: | 328 | Loop: |
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 | ||
407 | ERROR: | 407 | ERROR: |
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 | ||
413 | KeyTrans* KeyTrans::defaultKeyTrans() | 413 | KeyTrans* 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 | ||
422 | KeyTrans* KeyTrans::fromFile(const char* path) | 422 | KeyTrans* 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 | ||
432 | void KeyTransSymbols::defKeySym(const char* key, int val) | 432 | void 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 | ||
437 | void KeyTransSymbols::defOprSym(const char* key, int val) | 437 | void 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 | ||
442 | void KeyTransSymbols::defModSym(const char* key, int val) | 442 | void 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 | ||
447 | void KeyTransSymbols::defOprSyms() | 447 | void 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 | ||
459 | void KeyTransSymbols::defModSyms() | 459 | void 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 | ||
472 | void KeyTransSymbols::defKeySyms() | 472 | void 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 | ||
614 | KeyTransSymbols::KeyTransSymbols() | 614 | KeyTransSymbols::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 | ||
623 | static int keytab_serial = 0; //FIXME: remove,localize | 623 | static int keytab_serial = 0; //FIXME: remove,localize |
624 | 624 | ||
625 | static QIntDict<KeyTrans> * numb2keymap = 0L; | 625 | static QIntDict<KeyTrans> * numb2keymap = 0L; |
626 | static QDict<KeyTrans> * path2keymap = 0L; | 626 | static QDict<KeyTrans> * path2keymap = 0L; |
627 | 627 | ||
628 | KeyTrans* KeyTrans::find(int numb) | 628 | KeyTrans* 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 | ||
634 | KeyTrans* KeyTrans::find(const char* path) | 634 | KeyTrans* 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 | ||
640 | int KeyTrans::count() | 640 | int KeyTrans::count() |
641 | { | 641 | { |
642 | return numb2keymap->count(); | 642 | return numb2keymap->count(); |
643 | } | 643 | } |
644 | 644 | ||
645 | void KeyTrans::addKeyTrans() | 645 | void 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 | ||
652 | void KeyTrans::loadAll() | 652 | void 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 | /* |
680 | void TestTokenizer(QBuffer &buf) | 680 | void 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 | ||
695 | void test() | 695 | void 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,838 +1,817 @@ | |||
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 | ||
73 | class EKNumTabBar : public QTabBar | 52 | class EKNumTabBar : public QTabBar |
74 | { | 53 | { |
75 | public: | 54 | public: |
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 | ||
130 | class EKNumTabWidget : public QTabWidget | 109 | class EKNumTabWidget : public QTabWidget |
131 | { | 110 | { |
132 | public: | 111 | public: |
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 |
160 | static const char *commonCmds[] = | 139 | static 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 | ||
226 | static void konsoleInit(const char** shell) { | 205 | static 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 | ||
262 | Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) : | 241 | Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) : |
263 | QMainWindow(parent, name, fl) | 242 | QMainWindow(parent, name, fl) |
264 | { | 243 | { |
265 | QStrList tmp; const char* shell; | 244 | QStrList tmp; const char* shell; |
266 | 245 | ||
267 | konsoleInit( &shell); | 246 | konsoleInit( &shell); |
268 | init(shell,tmp); | 247 | init(shell,tmp); |
269 | } | 248 | } |
270 | 249 | ||
271 | Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int) | 250 | Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int) |
272 | : QMainWindow(0, name) | 251 | : QMainWindow(0, name) |
273 | { | 252 | { |
274 | init(_pgm,_args); | 253 | init(_pgm,_args); |
275 | } | 254 | } |
276 | 255 | ||
277 | struct HistoryItem | 256 | struct HistoryItem |
278 | { | 257 | { |
279 | HistoryItem(int c, const QString &l) | 258 | HistoryItem(int c, const QString &l) |
280 | { | 259 | { |
281 | count = c; | 260 | count = c; |
282 | line = l; | 261 | line = l; |
283 | } | 262 | } |
284 | int count; | 263 | int count; |
285 | QString line; | 264 | QString line; |
286 | }; | 265 | }; |
287 | 266 | ||
288 | class HistoryList : public QList<HistoryItem> | 267 | class HistoryList : public QList<HistoryItem> |
289 | { | 268 | { |
290 | virtual int compareItems( QCollection::Item item1, QCollection::Item item2) | 269 | virtual int compareItems( QCollection::Item item1, QCollection::Item item2) |
291 | { | 270 | { |
292 | int c1 = ((HistoryItem*)item1)->count; | 271 | int c1 = ((HistoryItem*)item1)->count; |
293 | int c2 = ((HistoryItem*)item2)->count; | 272 | int c2 = ((HistoryItem*)item2)->count; |
294 | if (c1 > c2) | 273 | if (c1 > c2) |
295 | return(1); | 274 | return(1); |
296 | if (c1 < c2) | 275 | if (c1 < c2) |
297 | return(-1); | 276 | return(-1); |
298 | return(0); | 277 | return(0); |
299 | } | 278 | } |
300 | }; | 279 | }; |
301 | 280 | ||
302 | void Konsole::initCommandList() | 281 | void Konsole::initCommandList() |
303 | { | 282 | { |
304 | // qDebug("Konsole::initCommandList"); | 283 | // qDebug("Konsole::initCommandList"); |
305 | Config cfg( "Konsole" ); | 284 | Config cfg( "Konsole" ); |
306 | cfg.setGroup("Commands"); | 285 | cfg.setGroup("Commands"); |
307 | // commonCombo->setInsertionPolicy(QComboBox::AtCurrent); | 286 | // commonCombo->setInsertionPolicy(QComboBox::AtCurrent); |
308 | commonCombo->clear(); | 287 | commonCombo->clear(); |
309 | 288 | ||
310 | if (cfg.readEntry("ShellHistory","TRUE") == "TRUE") | 289 | if (cfg.readEntry("ShellHistory","TRUE") == "TRUE") |
311 | { | 290 | { |
312 | QString histfilename = QString(getenv("HOME")) + "/.bash_history"; | 291 | QString histfilename = QString(getenv("HOME")) + "/.bash_history"; |
313 | histfilename = cfg.readEntry("ShellHistoryPath",histfilename); | 292 | histfilename = cfg.readEntry("ShellHistoryPath",histfilename); |
314 | QFile histfile(histfilename); | 293 | QFile histfile(histfilename); |
315 | // note: compiler barfed on: | 294 | // note: compiler barfed on: |
316 | // QFile histfile(QString(getenv("HOME")) + "/.bash_history"); | 295 | // QFile histfile(QString(getenv("HOME")) + "/.bash_history"); |
317 | if (histfile.open( IO_ReadOnly )) | 296 | if (histfile.open( IO_ReadOnly )) |
318 | { | 297 | { |
319 | QString line; | 298 | QString line; |
320 | uint i; | 299 | uint i; |
321 | HistoryList items; | 300 | HistoryList items; |
322 | 301 | ||
323 | int lineno = 0; | 302 | int lineno = 0; |
324 | while(!histfile.atEnd()) | 303 | while(!histfile.atEnd()) |
325 | { | 304 | { |
326 | if (histfile.readLine(line, 200) < 0) | 305 | if (histfile.readLine(line, 200) < 0) |
327 | { | 306 | { |
328 | break; | 307 | break; |
329 | } | 308 | } |
330 | line = line.left(line.length()-1); | 309 | line = line.left(line.length()-1); |
331 | lineno++; | 310 | lineno++; |
332 | 311 | ||
333 | for(i=0; i<items.count(); i++) | 312 | for(i=0; i<items.count(); i++) |
334 | { | 313 | { |
335 | if (line == items.at(i)->line) | 314 | if (line == items.at(i)->line) |
336 | { | 315 | { |
337 | // weight recent commands & repeated commands more | 316 | // weight recent commands & repeated commands more |
338 | // by adding up the index of each command | 317 | // by adding up the index of each command |
339 | items.at(i)->count += lineno; | 318 | items.at(i)->count += lineno; |
340 | break; | 319 | break; |
341 | } | 320 | } |
342 | } | 321 | } |
343 | if (i >= items.count()) | 322 | if (i >= items.count()) |
344 | { | 323 | { |
345 | items.append(new HistoryItem(lineno, line)); | 324 | items.append(new HistoryItem(lineno, line)); |
346 | } | 325 | } |
347 | } | 326 | } |
348 | items.sort(); | 327 | items.sort(); |
349 | int n = items.count(); | 328 | int n = items.count(); |
350 | if (n > 40) | 329 | if (n > 40) |
351 | { | 330 | { |
352 | n = 40; | 331 | n = 40; |
353 | } | 332 | } |
354 | for(int i=0; i<n; i++) | 333 | for(int i=0; i<n; i++) |
355 | { | 334 | { |
356 | // should insert start of command, but keep whole thing | 335 | // should insert start of command, but keep whole thing |
357 | if (items.at(items.count()-i-1)->line.length() < 30) | 336 | if (items.at(items.count()-i-1)->line.length() < 30) |
358 | { | 337 | { |
359 | commonCombo->insertItem(items.at(items.count()-i-1)->line); | 338 | commonCombo->insertItem(items.at(items.count()-i-1)->line); |
360 | } | 339 | } |
361 | } | 340 | } |
362 | histfile.close(); | 341 | histfile.close(); |
363 | } | 342 | } |
364 | } | 343 | } |
365 | if (cfg.readEntry("Commands Set","FALSE") == "FALSE") | 344 | if (cfg.readEntry("Commands Set","FALSE") == "FALSE") |
366 | { | 345 | { |
367 | for (int i = 0; commonCmds[i] != NULL; i++) | 346 | for (int i = 0; commonCmds[i] != NULL; i++) |
368 | { | 347 | { |
369 | commonCombo->insertItem(commonCmds[i]); | 348 | commonCombo->insertItem(commonCmds[i]); |
370 | } | 349 | } |
371 | } | 350 | } |
372 | else | 351 | else |
373 | { | 352 | { |
374 | for (int i = 0; i < 100; i++) | 353 | for (int i = 0; i < 100; i++) |
375 | { | 354 | { |
376 | if (!(cfg.readEntry( QString::number(i),"")).isEmpty()) | 355 | if (!(cfg.readEntry( QString::number(i),"")).isEmpty()) |
377 | commonCombo->insertItem(cfg.readEntry( QString::number(i),"")); | 356 | commonCombo->insertItem(cfg.readEntry( QString::number(i),"")); |
378 | } | 357 | } |
379 | } | 358 | } |
380 | 359 | ||
381 | 360 | ||
382 | } | 361 | } |
383 | 362 | ||
384 | static void sig_handler(int x) | 363 | static void sig_handler(int x) |
385 | { | 364 | { |
386 | printf("got signal %d\n",x); | 365 | printf("got signal %d\n",x); |
387 | } | 366 | } |
388 | 367 | ||
389 | void Konsole::init(const char* _pgm, QStrList & _args) | 368 | void Konsole::init(const char* _pgm, QStrList & _args) |
390 | { | 369 | { |
391 | 370 | ||
392 | #if 0 | 371 | #if 0 |
393 | for(int i=1; i<=31; i++) | 372 | for(int i=1; i<=31; i++) |
394 | { | 373 | { |
395 | if (i != SIGPIPE && i != SIGPROF && i != SIGSEGV | 374 | if (i != SIGPIPE && i != SIGPROF && i != SIGSEGV |
396 | && i != SIGINT && i != SIGILL && i != SIGTERM | 375 | && i != SIGINT && i != SIGILL && i != SIGTERM |
397 | && i != SIGBUS) | 376 | && i != SIGBUS) |
398 | signal(i,sig_handler); | 377 | signal(i,sig_handler); |
399 | } | 378 | } |
400 | #endif | 379 | #endif |
401 | signal(SIGSTOP, sig_handler); | 380 | signal(SIGSTOP, sig_handler); |
402 | signal(SIGCONT, sig_handler); | 381 | signal(SIGCONT, sig_handler); |
403 | signal(SIGTSTP, sig_handler); | 382 | signal(SIGTSTP, sig_handler); |
404 | 383 | ||
405 | b_scroll = TRUE; // histon; | 384 | b_scroll = TRUE; // histon; |
406 | n_keytab = 0; | 385 | n_keytab = 0; |
407 | n_render = 0; | 386 | n_render = 0; |
408 | startUp=0; | 387 | startUp=0; |
409 | fromMenu = FALSE; | 388 | fromMenu = FALSE; |
410 | fullscreen = false; | 389 | fullscreen = false; |
411 | 390 | ||
412 | setCaption( tr( "Konsole" ) ); | 391 | setCaption( tr( "Konsole" ) ); |
413 | setIcon( Resource::loadPixmap( "konsole/Terminal" ) ); | 392 | setIcon( Resource::loadPixmap( "konsole/Terminal" ) ); |
414 | 393 | ||
415 | Config cfg( "Konsole" ); | 394 | Config cfg( "Konsole" ); |
416 | cfg.setGroup("Font"); | 395 | cfg.setGroup("Font"); |
417 | QString tmp; | 396 | QString tmp; |
418 | 397 | ||
419 | // initialize the list of allowed fonts /////////////////////////////////// | 398 | // initialize the list of allowed fonts /////////////////////////////////// |
420 | 399 | ||
421 | QString cfgFontName = cfg.readEntry("FontName","Lcfont"); | 400 | QString cfgFontName = cfg.readEntry("FontName","Lcfont"); |
422 | int cfgFontSize = cfg.readNumEntry("FontSize",18); | 401 | int cfgFontSize = cfg.readNumEntry("FontSize",18); |
423 | 402 | ||
424 | cfont = -1; | 403 | cfont = -1; |
425 | 404 | ||
426 | // this code causes repeated access to all the font files | 405 | // this code causes repeated access to all the font files |
427 | // which does slow down startup | 406 | // which does slow down startup |
428 | QFontDatabase fontDB; | 407 | QFontDatabase fontDB; |
429 | QStringList familyNames; | 408 | QStringList familyNames; |
430 | familyNames = fontDB.families( FALSE ); | 409 | familyNames = fontDB.families( FALSE ); |
431 | QString s; | 410 | QString s; |
432 | int fontIndex = 0; | 411 | int fontIndex = 0; |
433 | int familyNum = 0; | 412 | int familyNum = 0; |
434 | fontList = new QPopupMenu( this ); | 413 | fontList = new QPopupMenu( this ); |
435 | 414 | ||
436 | for(uint j = 0; j < (uint)familyNames.count(); j++) | 415 | for(uint j = 0; j < (uint)familyNames.count(); j++) |
437 | { | 416 | { |
438 | s = familyNames[j]; | 417 | s = familyNames[j]; |
439 | if ( s.contains('-') ) | 418 | if ( s.contains('-') ) |
440 | { | 419 | { |
441 | int i = s.find('-'); | 420 | int i = s.find('-'); |
442 | s = s.right( s.length() - i - 1 ) + " [" + s.left( i ) + "]"; | 421 | s = s.right( s.length() - i - 1 ) + " [" + s.left( i ) + "]"; |
443 | } | 422 | } |
444 | s[0] = s[0].upper(); | 423 | s[0] = s[0].upper(); |
445 | 424 | ||
446 | QValueList<int> sizes = fontDB.pointSizes( familyNames[j] ); | 425 | QValueList<int> sizes = fontDB.pointSizes( familyNames[j] ); |
447 | 426 | ||
448 | printf("family[%d] = %s with %d sizes\n", j, familyNames[j].latin1(), | 427 | printf("family[%d] = %s with %d sizes\n", j, familyNames[j].latin1(), |
449 | sizes.count()); | 428 | sizes.count()); |
450 | 429 | ||
451 | if (sizes.count() > 0) | 430 | if (sizes.count() > 0) |
452 | { | 431 | { |
453 | QPopupMenu *sizeMenu; | 432 | QPopupMenu *sizeMenu; |
454 | QFont f; | 433 | QFont f; |
455 | int last_width = -1; | 434 | int last_width = -1; |
456 | sizeMenu = NULL; | 435 | sizeMenu = NULL; |
457 | 436 | ||
458 | for(uint i = 0; i < (uint)sizes.count() + 4; i++) | 437 | for(uint i = 0; i < (uint)sizes.count() + 4; i++) |
459 | { | 438 | { |
460 | // printf("family %s size %d ", familyNames[j].latin1(), sizes[i]); | 439 | // printf("family %s size %d ", familyNames[j].latin1(), sizes[i]); |
461 | // need to divide by 10 on the Z, but not otherwise | 440 | // need to divide by 10 on the Z, but not otherwise |
462 | int size; | 441 | int size; |
463 | 442 | ||
464 | if (i >= (uint)sizes.count()) | 443 | if (i >= (uint)sizes.count()) |
465 | { | 444 | { |
466 | // try for expandable fonts | 445 | // try for expandable fonts |
467 | size = sizes[sizes.count()-1] + 2 * (i - sizes.count() + 1); | 446 | size = sizes[sizes.count()-1] + 2 * (i - sizes.count() + 1); |
468 | } | 447 | } |
469 | else | 448 | else |
470 | { | 449 | { |
471 | printf("sizes[%d] = %d\n", i, sizes[i]); | 450 | printf("sizes[%d] = %d\n", i, sizes[i]); |
472 | size = sizes[i]; | 451 | size = sizes[i]; |
473 | } | 452 | } |
474 | 453 | ||
475 | f = QFont(familyNames[j], size); | 454 | f = QFont(familyNames[j], size); |
476 | f.setFixedPitch(true); | 455 | f.setFixedPitch(true); |
477 | QFontMetrics fm(f); | 456 | QFontMetrics fm(f); |
478 | // don't trust f.fixedPitch() or f.exactMatch(), they lie!! | 457 | // don't trust f.fixedPitch() or f.exactMatch(), they lie!! |
479 | if (fm.width("l") == fm.width("m") | 458 | if (fm.width("l") == fm.width("m") |
480 | && (i < (uint)sizes.count() | 459 | && (i < (uint)sizes.count() |
481 | || fm.width("m") > last_width)) | 460 | || fm.width("m") > last_width)) |
482 | { | 461 | { |
483 | if (i < (uint)sizes.count()) | 462 | if (i < (uint)sizes.count()) |
484 | { | 463 | { |
485 | last_width = fm.width("m"); | 464 | last_width = fm.width("m"); |
486 | } | 465 | } |
487 | if (sizeMenu == NULL) | 466 | if (sizeMenu == NULL) |
488 | { | 467 | { |
489 | sizeMenu = new QPopupMenu(); | 468 | sizeMenu = new QPopupMenu(); |
490 | } | 469 | } |
491 | int id = sizeMenu->insertItem(QString("%1").arg(size), fontIndex); | 470 | int id = sizeMenu->insertItem(QString("%1").arg(size), fontIndex); |
492 | sizeMenu->setItemParameter(id, fontIndex); | 471 | sizeMenu->setItemParameter(id, fontIndex); |
493 | sizeMenu->connectItem(id, this, SLOT(setFont(int))); | 472 | sizeMenu->connectItem(id, this, SLOT(setFont(int))); |
494 | QString name = s + " " + QString::number(size); | 473 | QString name = s + " " + QString::number(size); |
495 | fonts.append(new VTFont(name, f, familyNames[j], familyNum, size)); | 474 | fonts.append(new VTFont(name, f, familyNames[j], familyNum, size)); |
496 | if (familyNames[j] == cfgFontName && size == cfgFontSize) | 475 | if (familyNames[j] == cfgFontName && size == cfgFontSize) |
497 | { | 476 | { |
498 | cfont = fontIndex; | 477 | cfont = fontIndex; |
499 | } | 478 | } |
500 | printf("FOUND: %s family %s size %d\n", name.latin1(), familyNames[j].latin1(), size); | 479 | printf("FOUND: %s family %s size %d\n", name.latin1(), familyNames[j].latin1(), size); |
501 | fontIndex++; | 480 | fontIndex++; |
502 | } | 481 | } |
503 | } | 482 | } |
504 | if (sizeMenu) | 483 | if (sizeMenu) |
505 | { | 484 | { |
506 | fontList->insertItem(s, sizeMenu, familyNum + 1000); | 485 | fontList->insertItem(s, sizeMenu, familyNum + 1000); |
507 | 486 | ||
508 | familyNum++; | 487 | familyNum++; |
509 | } | 488 | } |
510 | } | 489 | } |
511 | 490 | ||
512 | } | 491 | } |
513 | 492 | ||
514 | if (cfont < 0 || cfont >= (int)fonts.count()) | 493 | if (cfont < 0 || cfont >= (int)fonts.count()) |
515 | { | 494 | { |
516 | cfont = 0; | 495 | cfont = 0; |
517 | } | 496 | } |
518 | 497 | ||
519 | // create terminal emulation framework //////////////////////////////////// | 498 | // create terminal emulation framework //////////////////////////////////// |
520 | nsessions = 0; | 499 | nsessions = 0; |
521 | 500 | ||
522 | tab = new EKNumTabWidget(this); | 501 | tab = new EKNumTabWidget(this); |
523 | // tab->setMargin(tab->margin()-5); | 502 | // tab->setMargin(tab->margin()-5); |
524 | connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*))); | 503 | connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*))); |
525 | 504 | ||
526 | // create terminal toolbar //////////////////////////////////////////////// | 505 | // create terminal toolbar //////////////////////////////////////////////// |
527 | setToolBarsMovable( FALSE ); | 506 | setToolBarsMovable( FALSE ); |
528 | menuToolBar = new QToolBar( this ); | 507 | menuToolBar = new QToolBar( this ); |
529 | menuToolBar->setHorizontalStretchable( TRUE ); | 508 | menuToolBar->setHorizontalStretchable( TRUE ); |
530 | 509 | ||
531 | QMenuBar *menuBar = new QMenuBar( menuToolBar ); | 510 | QMenuBar *menuBar = new QMenuBar( menuToolBar ); |
532 | 511 | ||
533 | bool c7xx = false; | 512 | bool c7xx = false; |
534 | if (qApp->desktop()->width() > 600 || qApp->desktop()->height() > 600) | 513 | if (qApp->desktop()->width() > 600 || qApp->desktop()->height() > 600) |
535 | { | 514 | { |
536 | c7xx = true; | 515 | c7xx = true; |
537 | } | 516 | } |
538 | QFont menuFont; | 517 | QFont menuFont; |
539 | menuFont.setPointSize(c7xx? 18 : 10); | 518 | menuFont.setPointSize(c7xx? 18 : 10); |
540 | qApp->setFont(menuFont, true); | 519 | qApp->setFont(menuFont, true); |
541 | 520 | ||
542 | setFont(cfont); | 521 | setFont(cfont); |
543 | 522 | ||
544 | configMenu = new QPopupMenu( this); | 523 | configMenu = new QPopupMenu( this); |
545 | colorMenu = new QPopupMenu( this); | 524 | colorMenu = new QPopupMenu( this); |
546 | scrollMenu = new QPopupMenu( this); | 525 | scrollMenu = new QPopupMenu( this); |
547 | editCommandListMenu = new QPopupMenu( this); | 526 | editCommandListMenu = new QPopupMenu( this); |
548 | 527 | ||
549 | configMenu->insertItem(tr("Command List"), editCommandListMenu); | 528 | configMenu->insertItem(tr("Command List"), editCommandListMenu); |
550 | 529 | ||
551 | bool listHidden; | 530 | bool listHidden; |
552 | cfg.setGroup("Menubar"); | 531 | cfg.setGroup("Menubar"); |
553 | if( cfg.readEntry("Hidden","FALSE") == "TRUE") | 532 | if( cfg.readEntry("Hidden","FALSE") == "TRUE") |
554 | { | 533 | { |
555 | ec_cmdlist = editCommandListMenu->insertItem( tr( "Show command list" )); | 534 | ec_cmdlist = editCommandListMenu->insertItem( tr( "Show command list" )); |
556 | listHidden=TRUE; | 535 | listHidden=TRUE; |
557 | } | 536 | } |
558 | else | 537 | else |
559 | { | 538 | { |
560 | ec_cmdlist = editCommandListMenu->insertItem( tr( "Hide command list" )); | 539 | ec_cmdlist = editCommandListMenu->insertItem( tr( "Hide command list" )); |
561 | listHidden=FALSE; | 540 | listHidden=FALSE; |
562 | } | 541 | } |
563 | 542 | ||
564 | cfg.setGroup("Tabs"); | 543 | cfg.setGroup("Tabs"); |
565 | 544 | ||
566 | tabMenu = new QPopupMenu(this); | 545 | tabMenu = new QPopupMenu(this); |
567 | tm_bottom = tabMenu->insertItem(tr("Bottom" )); | 546 | tm_bottom = tabMenu->insertItem(tr("Bottom" )); |
568 | tm_top = tabMenu->insertItem(tr("Top")); | 547 | tm_top = tabMenu->insertItem(tr("Top")); |
569 | tm_hidden = tabMenu->insertItem(tr("Hidden")); | 548 | tm_hidden = tabMenu->insertItem(tr("Hidden")); |
570 | 549 | ||
571 | configMenu->insertItem(tr("Tabs"), tabMenu); | 550 | configMenu->insertItem(tr("Tabs"), tabMenu); |
572 | 551 | ||
573 | tmp=cfg.readEntry("Position","Top"); | 552 | tmp=cfg.readEntry("Position","Top"); |
574 | if(tmp=="Top") | 553 | if(tmp=="Top") |
575 | { | 554 | { |
576 | tab->setTabPosition(QTabWidget::Top); | 555 | tab->setTabPosition(QTabWidget::Top); |
577 | tab->getTabBar()->show(); | 556 | tab->getTabBar()->show(); |
578 | tabPos = tm_top; | 557 | tabPos = tm_top; |
579 | } | 558 | } |
580 | else if (tmp=="Bottom") | 559 | else if (tmp=="Bottom") |
581 | { | 560 | { |
582 | tab->setTabPosition(QTabWidget::Bottom); | 561 | tab->setTabPosition(QTabWidget::Bottom); |
583 | tab->getTabBar()->show(); | 562 | tab->getTabBar()->show(); |
584 | tabPos = tm_bottom; | 563 | tabPos = tm_bottom; |
585 | } | 564 | } |
586 | else | 565 | else |
587 | { | 566 | { |
588 | tab->getTabBar()->hide(); | 567 | tab->getTabBar()->hide(); |
589 | tab->setMargin(tab->margin()); | 568 | tab->setMargin(tab->margin()); |
590 | tabPos = tm_hidden; | 569 | tabPos = tm_hidden; |
591 | } | 570 | } |
592 | 571 | ||
593 | cm_bw = colorMenu->insertItem(tr( "Black on White")); | 572 | cm_bw = colorMenu->insertItem(tr( "Black on White")); |
594 | cm_wb = colorMenu->insertItem(tr( "White on Black")); | 573 | cm_wb = colorMenu->insertItem(tr( "White on Black")); |
595 | cm_gb = colorMenu->insertItem(tr( "Green on Black")); | 574 | cm_gb = colorMenu->insertItem(tr( "Green on Black")); |
596 | // cm_bt = colorMenu->insertItem(tr( "Black on Transparent")); | 575 | // cm_bt = colorMenu->insertItem(tr( "Black on Transparent")); |
597 | cm_br = colorMenu->insertItem(tr( "Black on Pink")); | 576 | cm_br = colorMenu->insertItem(tr( "Black on Pink")); |
598 | cm_rb = colorMenu->insertItem(tr( "Pink on Black")); | 577 | cm_rb = colorMenu->insertItem(tr( "Pink on Black")); |
599 | cm_gy = colorMenu->insertItem(tr( "Green on Yellow")); | 578 | cm_gy = colorMenu->insertItem(tr( "Green on Yellow")); |
600 | cm_bm = colorMenu->insertItem(tr( "Blue on Magenta")); | 579 | cm_bm = colorMenu->insertItem(tr( "Blue on Magenta")); |
601 | cm_mb = colorMenu->insertItem(tr( "Magenta on Blue")); | 580 | cm_mb = colorMenu->insertItem(tr( "Magenta on Blue")); |
602 | cm_cw = colorMenu->insertItem(tr( "Cyan on White")); | 581 | cm_cw = colorMenu->insertItem(tr( "Cyan on White")); |
603 | cm_wc = colorMenu->insertItem(tr( "White on Cyan")); | 582 | cm_wc = colorMenu->insertItem(tr( "White on Cyan")); |
604 | cm_bb = colorMenu->insertItem(tr( "Blue on Black")); | 583 | cm_bb = colorMenu->insertItem(tr( "Blue on Black")); |
605 | cm_ab = colorMenu->insertItem(tr( "Amber on Black")); | 584 | cm_ab = colorMenu->insertItem(tr( "Amber on Black")); |
606 | cm_default = colorMenu->insertItem(tr("default")); | 585 | cm_default = colorMenu->insertItem(tr("default")); |
607 | 586 | ||
608 | #ifdef QT_QWS_OPIE | 587 | #ifdef QT_QWS_OPIE |
609 | 588 | ||
610 | colorMenu->insertItem(tr( "Custom")); | 589 | colorMenu->insertItem(tr( "Custom")); |
611 | #endif | 590 | #endif |
612 | 591 | ||
613 | configMenu->insertItem(tr( "Colors") ,colorMenu); | 592 | configMenu->insertItem(tr( "Colors") ,colorMenu); |
614 | 593 | ||
615 | sessionList = new QPopupMenu(this); | 594 | sessionList = new QPopupMenu(this); |
616 | sessionList-> insertItem ( Resource::loadPixmap ( "konsole/Terminal" ), tr( "new session" ), this, | 595 | sessionList-> insertItem ( Resource::loadPixmap ( "konsole/Terminal" ), tr( "new session" ), this, |
617 | SLOT(newSession()) ); | 596 | SLOT(newSession()) ); |
618 | 597 | ||
619 | // connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) )); | 598 | // connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) )); |
620 | connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) )); | 599 | connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) )); |
621 | connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuIsSelected(int) )); | 600 | connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuIsSelected(int) )); |
622 | connect( tabMenu, SIGNAL( activated(int) ), this, SLOT( tabMenuSelected(int) )); | 601 | connect( tabMenu, SIGNAL( activated(int) ), this, SLOT( tabMenuSelected(int) )); |
623 | connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int))); | 602 | connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int))); |
624 | connect( editCommandListMenu,SIGNAL(activated(int)),this,SLOT(editCommandListMenuSelected(int))); | 603 | connect( editCommandListMenu,SIGNAL(activated(int)),this,SLOT(editCommandListMenuSelected(int))); |
625 | connect( sessionList, SIGNAL(activated(int)), this, SLOT( sessionListSelected(int) ) ); | 604 | connect( sessionList, SIGNAL(activated(int)), this, SLOT( sessionListSelected(int) ) ); |
626 | 605 | ||
627 | menuBar->insertItem( tr("View"), configMenu ); | 606 | menuBar->insertItem( tr("View"), configMenu ); |
628 | menuBar->insertItem( tr("Fonts"), fontList ); | 607 | menuBar->insertItem( tr("Fonts"), fontList ); |
629 | menuBar->insertItem( tr("Sessions"), sessionList ); | 608 | menuBar->insertItem( tr("Sessions"), sessionList ); |
630 | 609 | ||
631 | toolBar = new QToolBar( this ); | 610 | toolBar = new QToolBar( this ); |
632 | 611 | ||
633 | QAction *a; | 612 | QAction *a; |
634 | 613 | ||
635 | // Button Commands | 614 | // Button Commands |
636 | a = new QAction( tr("New"), Resource::loadPixmap( "konsole/Terminal" ), QString::null, 0, this, 0 ); | 615 | a = new QAction( tr("New"), Resource::loadPixmap( "konsole/Terminal" ), QString::null, 0, this, 0 ); |
637 | connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); | 616 | connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); |
638 | a->addTo( toolBar ); | 617 | a->addTo( toolBar ); |
639 | 618 | ||
640 | a = new QAction( tr("Full Screen"), Resource::loadPixmap( "fullscreen" ), QString::null, 0, this, 0 ); | 619 | a = new QAction( tr("Full Screen"), Resource::loadPixmap( "fullscreen" ), QString::null, 0, this, 0 ); |
641 | connect( a, SIGNAL( activated() ), this, SLOT( toggleFullScreen() ) ); | 620 | connect( a, SIGNAL( activated() ), this, SLOT( toggleFullScreen() ) ); |
642 | a->addTo( toolBar ); | 621 | a->addTo( toolBar ); |
643 | 622 | ||
644 | a = new QAction( tr("Zoom"), Resource::loadPixmap( "zoom" ), QString::null, 0, this, 0 ); | 623 | a = new QAction( tr("Zoom"), Resource::loadPixmap( "zoom" ), QString::null, 0, this, 0 ); |
645 | connect( a, SIGNAL( activated() ), this, SLOT( cycleZoom() ) ); | 624 | connect( a, SIGNAL( activated() ), this, SLOT( cycleZoom() ) ); |
646 | a->addTo( toolBar ); | 625 | a->addTo( toolBar ); |
647 | 626 | ||
648 | 627 | ||
649 | /* | 628 | /* |
650 | a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 ); | 629 | a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 ); |
651 | connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolBar ); | 630 | connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolBar ); |
652 | a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 ); | 631 | a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 ); |
653 | connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolBar ); | 632 | connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolBar ); |
654 | a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 ); | 633 | a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 ); |
655 | connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolBar ); | 634 | connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolBar ); |
656 | */ | 635 | */ |
657 | /* | 636 | /* |
658 | a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 ); | 637 | a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 ); |
659 | connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolBar ); | 638 | connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolBar ); |
660 | a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 ); | 639 | a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 ); |
661 | connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolBar ); | 640 | connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolBar ); |
662 | */ | 641 | */ |
663 | a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); | 642 | a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); |
664 | connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); | 643 | connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); |
665 | a->addTo( toolBar ); | 644 | a->addTo( toolBar ); |
666 | 645 | ||
667 | secondToolBar = new QToolBar( this ); | 646 | secondToolBar = new QToolBar( this ); |
668 | secondToolBar->setHorizontalStretchable( TRUE ); | 647 | secondToolBar->setHorizontalStretchable( TRUE ); |
669 | 648 | ||
670 | commonCombo = new QComboBox( secondToolBar ); | 649 | commonCombo = new QComboBox( secondToolBar ); |
671 | // commonCombo->setMaximumWidth(236); | 650 | // commonCombo->setMaximumWidth(236); |
672 | 651 | ||
673 | ec_quick = editCommandListMenu->insertItem( tr( "Quick Edit" ) ); | 652 | ec_quick = editCommandListMenu->insertItem( tr( "Quick Edit" ) ); |
674 | if( listHidden) | 653 | if( listHidden) |
675 | { | 654 | { |
676 | secondToolBar->hide(); | 655 | secondToolBar->hide(); |
677 | editCommandListMenu->setItemEnabled(ec_quick ,FALSE); | 656 | editCommandListMenu->setItemEnabled(ec_quick ,FALSE); |
678 | } | 657 | } |
679 | ec_edit = editCommandListMenu->insertItem(tr( "Edit..." ) ); | 658 | ec_edit = editCommandListMenu->insertItem(tr( "Edit..." ) ); |
680 | 659 | ||
681 | cfg.setGroup("Commands"); | 660 | cfg.setGroup("Commands"); |
682 | commonCombo->setInsertionPolicy(QComboBox::AtCurrent); | 661 | commonCombo->setInsertionPolicy(QComboBox::AtCurrent); |
683 | 662 | ||
684 | initCommandList(); | 663 | initCommandList(); |
685 | // for (int i = 0; commonCmds[i] != NULL; i++) { | 664 | // for (int i = 0; commonCmds[i] != NULL; i++) { |
686 | // commonCombo->insertItem( commonCmds[i], i ); | 665 | // commonCombo->insertItem( commonCmds[i], i ); |
687 | // tmp = cfg.readEntry( QString::number(i),""); | 666 | // tmp = cfg.readEntry( QString::number(i),""); |
688 | // if(tmp != "") | 667 | // if(tmp != "") |
689 | // commonCombo->changeItem( tmp,i ); | 668 | // commonCombo->changeItem( tmp,i ); |
690 | // } | 669 | // } |
691 | 670 | ||
692 | connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) )); | 671 | connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) )); |
693 | 672 | ||
694 | sm_none = scrollMenu->insertItem(tr( "None" )); | 673 | sm_none = scrollMenu->insertItem(tr( "None" )); |
695 | sm_left = scrollMenu->insertItem(tr( "Left" )); | 674 | sm_left = scrollMenu->insertItem(tr( "Left" )); |
696 | sm_right = scrollMenu->insertItem(tr( "Right" )); | 675 | sm_right = scrollMenu->insertItem(tr( "Right" )); |
697 | // scrollMenu->insertSeparator(4); | 676 | // scrollMenu->insertSeparator(4); |
698 | // scrollMenu->insertItem(tr( "Horizontal" )); | 677 | // scrollMenu->insertItem(tr( "Horizontal" )); |
699 | 678 | ||
700 | configMenu->insertItem(tr( "ScrollBar" ),scrollMenu); | 679 | configMenu->insertItem(tr( "ScrollBar" ),scrollMenu); |
701 | 680 | ||
702 | configMenu->insertItem(tr( "History..." ), this, SLOT(historyDialog())); | 681 | configMenu->insertItem(tr( "History..." ), this, SLOT(historyDialog())); |
703 | 682 | ||
704 | cm_wrap = configMenu->insertItem(tr( "Wrap" )); | 683 | cm_wrap = configMenu->insertItem(tr( "Wrap" )); |
705 | cfg.setGroup("ScrollBar"); | 684 | cfg.setGroup("ScrollBar"); |
706 | configMenu->setItemChecked(cm_wrap, cfg.readBoolEntry("HorzScroll",0)); | 685 | configMenu->setItemChecked(cm_wrap, cfg.readBoolEntry("HorzScroll",0)); |
707 | 686 | ||
708 | cm_beep = configMenu->insertItem(tr( "Use Beep" )); | 687 | cm_beep = configMenu->insertItem(tr( "Use Beep" )); |
709 | cfg.setGroup("Menubar"); | 688 | cfg.setGroup("Menubar"); |
710 | configMenu->setItemChecked(cm_beep, cfg.readBoolEntry("useBeep",0)); | 689 | configMenu->setItemChecked(cm_beep, cfg.readBoolEntry("useBeep",0)); |
711 | 690 | ||
712 | fullscreen_msg = new QLabel(this); | 691 | fullscreen_msg = new QLabel(this); |
713 | fullscreen_msg-> setAlignment ( AlignCenter | SingleLine ); | 692 | fullscreen_msg-> setAlignment ( AlignCenter | SingleLine ); |
714 | fullscreen_msg-> hide(); | 693 | fullscreen_msg-> hide(); |
715 | fullscreen_msg-> setSizePolicy ( QSizePolicy ( QSizePolicy::Expanding, QSizePolicy::Expanding )); | 694 | fullscreen_msg-> setSizePolicy ( QSizePolicy ( QSizePolicy::Expanding, QSizePolicy::Expanding )); |
716 | fullscreen_msg-> setAutoResize(true); | 695 | fullscreen_msg-> setAutoResize(true); |
717 | fullscreen_msg-> setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 696 | fullscreen_msg-> setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
718 | fullscreen_msg-> setText(tr("To exit fullscreen, tap here.")); | 697 | fullscreen_msg-> setText(tr("To exit fullscreen, tap here.")); |
719 | 698 | ||
720 | fullscreen_timer = new QTimer(this); | 699 | fullscreen_timer = new QTimer(this); |
721 | connect(fullscreen_timer, SIGNAL(timeout()), | 700 | connect(fullscreen_timer, SIGNAL(timeout()), |
722 | this, SLOT(fullscreenTimeout())); | 701 | this, SLOT(fullscreenTimeout())); |
723 | show_fullscreen_msg = true; | 702 | show_fullscreen_msg = true; |
724 | 703 | ||
725 | //scrollMenuSelected(-29); | 704 | //scrollMenuSelected(-29); |
726 | // cfg.setGroup("ScrollBar"); | 705 | // cfg.setGroup("ScrollBar"); |
727 | // if(cfg.readBoolEntry("HorzScroll",0)) { | 706 | // if(cfg.readBoolEntry("HorzScroll",0)) { |
728 | // if(cfg.readNumEntry("Position",2) == 0) | 707 | // if(cfg.readNumEntry("Position",2) == 0) |
729 | // te->setScrollbarLocation(1); | 708 | // te->setScrollbarLocation(1); |
730 | // else | 709 | // else |
731 | // te->setScrollbarLocation(0); | 710 | // te->setScrollbarLocation(0); |
732 | // te->setScrollbarLocation( cfg.readNumEntry("Position",2)); | 711 | // te->setScrollbarLocation( cfg.readNumEntry("Position",2)); |
733 | // te->setWrapAt(120); | 712 | // te->setWrapAt(120); |
734 | // } | 713 | // } |
735 | // create applications ///////////////////////////////////////////////////// | 714 | // create applications ///////////////////////////////////////////////////// |
736 | setCentralWidget(tab); | 715 | setCentralWidget(tab); |
737 | 716 | ||
738 | // load keymaps //////////////////////////////////////////////////////////// | 717 | // load keymaps //////////////////////////////////////////////////////////// |
739 | KeyTrans::loadAll(); | 718 | KeyTrans::loadAll(); |
740 | for (int i = 0; i < KeyTrans::count(); i++) | 719 | for (int i = 0; i < KeyTrans::count(); i++) |
741 | { | 720 | { |
742 | KeyTrans* s = KeyTrans::find(i); | 721 | KeyTrans* s = KeyTrans::find(i); |
743 | assert( s ); | 722 | assert( s ); |
744 | } | 723 | } |
745 | 724 | ||
746 | se_pgm = _pgm; | 725 | se_pgm = _pgm; |
747 | se_args = _args; | 726 | se_args = _args; |
748 | 727 | ||
749 | cfg.setGroup("CommandLine"); | 728 | cfg.setGroup("CommandLine"); |
750 | 729 | ||
751 | if (cfg.hasKey("shell_args")) | 730 | if (cfg.hasKey("shell_args")) |
752 | { | 731 | { |
753 | QStringList se_args_list = cfg.readListEntry("shell_args",'|'); | 732 | QStringList se_args_list = cfg.readListEntry("shell_args",'|'); |
754 | for(uint i = 0; i < se_args_list.count(); i++) | 733 | for(uint i = 0; i < se_args_list.count(); i++) |
755 | { | 734 | { |
756 | se_args.prepend(se_args_list[se_args_list.count() - i - 1].latin1()); | 735 | se_args.prepend(se_args_list[se_args_list.count() - i - 1].latin1()); |
757 | } | 736 | } |
758 | } | 737 | } |
759 | else | 738 | else |
760 | { | 739 | { |
761 | se_args.prepend("--login"); | 740 | se_args.prepend("--login"); |
762 | } | 741 | } |
763 | 742 | ||
764 | se_pgm = cfg.readEntry("shell_bin", QString(se_pgm)); | 743 | se_pgm = cfg.readEntry("shell_bin", QString(se_pgm)); |
765 | 744 | ||
766 | // this is the "documentation" for those who know to look | 745 | // this is the "documentation" for those who know to look |
767 | if (! cfg.hasKey("shell_args")) | 746 | if (! cfg.hasKey("shell_args")) |
768 | { | 747 | { |
769 | cfg.writeEntry("shell_args",QStringList::fromStrList(se_args),'|'); | 748 | cfg.writeEntry("shell_args",QStringList::fromStrList(se_args),'|'); |
770 | } | 749 | } |
771 | if (! cfg.hasKey("shell_bin")) | 750 | if (! cfg.hasKey("shell_bin")) |
772 | { | 751 | { |
773 | cfg.writeEntry("shell_bin",QString(se_pgm)); | 752 | cfg.writeEntry("shell_bin",QString(se_pgm)); |
774 | } | 753 | } |
775 | 754 | ||
776 | parseCommandLine(); | 755 | parseCommandLine(); |
777 | 756 | ||
778 | // read and apply default values /////////////////////////////////////////// | 757 | // read and apply default values /////////////////////////////////////////// |
779 | resize(321, 321); // Dummy. | 758 | resize(321, 321); // Dummy. |
780 | QSize currentSize = size(); | 759 | QSize currentSize = size(); |
781 | if (currentSize != size()) | 760 | if (currentSize != size()) |
782 | defaultSize = size(); | 761 | defaultSize = size(); |
783 | 762 | ||
784 | 763 | ||
785 | /* allows us to catch cancel/escape */ | 764 | /* allows us to catch cancel/escape */ |
786 | reparent ( 0, WStyle_Customize | WStyle_NoBorder, | 765 | reparent ( 0, WStyle_Customize | WStyle_NoBorder, |
787 | QPoint ( 0, 0 )); | 766 | QPoint ( 0, 0 )); |
788 | } | 767 | } |
789 | 768 | ||
790 | void Konsole::show() | 769 | void Konsole::show() |
791 | { | 770 | { |
792 | if ( !nsessions ) | 771 | if ( !nsessions ) |
793 | { | 772 | { |
794 | newSession(); | 773 | newSession(); |
795 | } | 774 | } |
796 | QMainWindow::show(); | 775 | QMainWindow::show(); |
797 | 776 | ||
798 | } | 777 | } |
799 | 778 | ||
800 | void Konsole::initSession(const char*, QStrList &) | 779 | void Konsole::initSession(const char*, QStrList &) |
801 | { | 780 | { |
802 | QMainWindow::show(); | 781 | QMainWindow::show(); |
803 | } | 782 | } |
804 | 783 | ||
805 | Konsole::~Konsole() | 784 | Konsole::~Konsole() |
806 | { | 785 | { |
807 | while (nsessions > 0) | 786 | while (nsessions > 0) |
808 | { | 787 | { |
809 | doneSession(getTe(), 0); | 788 | doneSession(getTe(), 0); |
810 | } | 789 | } |
811 | } | 790 | } |
812 | 791 | ||
813 | void | 792 | void |
814 | Konsole::historyDialog() | 793 | Konsole::historyDialog() |
815 | { | 794 | { |
816 | QDialog *d = new QDialog ( this, "histdlg", true ); | 795 | QDialog *d = new QDialog ( this, "histdlg", true ); |
817 | // d-> setCaption ( tr( "History" )); | 796 | // d-> setCaption ( tr( "History" )); |
818 | 797 | ||
819 | QBoxLayout *lay = new QVBoxLayout ( d, 4, 4 ); | 798 | QBoxLayout *lay = new QVBoxLayout ( d, 4, 4 ); |
820 | 799 | ||
821 | QLabel *l = new QLabel ( tr( "History Lines:" ), d ); | 800 | QLabel *l = new QLabel ( tr( "History Lines:" ), d ); |
822 | lay-> addWidget ( l ); | 801 | lay-> addWidget ( l ); |
823 | 802 | ||
824 | Config cfg( "Konsole" ); | 803 | Config cfg( "Konsole" ); |
825 | cfg.setGroup("History"); | 804 | cfg.setGroup("History"); |
826 | int hist = cfg.readNumEntry("history_lines",300); | 805 | int hist = cfg.readNumEntry("history_lines",300); |
827 | int avg_line = cfg.readNumEntry("avg_line_length",60); | 806 | int avg_line = cfg.readNumEntry("avg_line_length",60); |
828 | 807 | ||
829 | QSpinBox *spin = new QSpinBox ( 1, 100000, 20, d ); | 808 | QSpinBox *spin = new QSpinBox ( 1, 100000, 20, d ); |
830 | spin-> setValue ( hist ); | 809 | spin-> setValue ( hist ); |
831 | spin-> setWrapping ( true ); | 810 | spin-> setWrapping ( true ); |
832 | spin-> setButtonSymbols ( QSpinBox::PlusMinus ); | 811 | spin-> setButtonSymbols ( QSpinBox::PlusMinus ); |
833 | lay-> addWidget ( spin ); | 812 | lay-> addWidget ( spin ); |
834 | 813 | ||
835 | if ( d-> exec ( ) == QDialog::Accepted ) | 814 | if ( d-> exec ( ) == QDialog::Accepted ) |
836 | { | 815 | { |
837 | cfg.writeEntry("history_lines", spin->value()); | 816 | cfg.writeEntry("history_lines", spin->value()); |
838 | cfg.writeEntry("avg_line_length", avg_line); | 817 | cfg.writeEntry("avg_line_length", avg_line); |
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 | ||
37 | PlayListSelection::PlayListSelection( QWidget *parent, const char *name ) | 30 | PlayListSelection::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 | ||
47 | PlayListSelection::~PlayListSelection() { | 40 | PlayListSelection::~PlayListSelection() { |
48 | } | 41 | } |
49 | 42 | ||
50 | 43 | ||
51 | 44 | ||
52 | void PlayListSelection::contentsMouseMoveEvent( QMouseEvent *event ) { | 45 | void 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 | ||
64 | const QString *PlayListSelection::current() { | 57 | const 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 | ||
72 | void PlayListSelection::addToSelection( QListViewItem *lnk ) { | 65 | void PlayListSelection::addToSelection( QListViewItem *lnk ) { |
73 | PlayListSelectionItem *item = new PlayListSelectionItem( this, new QString( lnk->text(0) ) ); | 66 | PlayListSelectionItem *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 | ||
81 | void PlayListSelection::addStringToSelection (const QString & lnk) { | 74 | void 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 | } |
90 | void PlayListSelection::removeSelected() { | 83 | void 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 | ||
100 | void PlayListSelection::moveSelectedUp() { | 93 | void 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 | ||
108 | void PlayListSelection::moveSelectedDown() { | 101 | void 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 | ||
116 | bool PlayListSelection::prev() { | 109 | bool 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 | ||
127 | bool PlayListSelection::next() { | 120 | bool 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 | ||
138 | bool PlayListSelection::first() { | 131 | bool 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 | ||
149 | bool PlayListSelection::last() { | 142 | bool 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 | ||
26 | TESession::TESession(QMainWindow* main, TEWidget* _te, const char* _pgm, QStrList & _args, const char *_term) : schema_no(0), font_no(3), pgm(_pgm), args(_args) | 25 | TESession::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 | ||
63 | void TESession::run() | 62 | void 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 | ||
69 | void TESession::kill(int ) // signal) | 68 | void TESession::kill(int ) // signal) |
70 | { | 69 | { |
71 | // sh->kill(signal); | 70 | // sh->kill(signal); |
72 | } | 71 | } |
73 | 72 | ||
74 | TESession::~TESession() | 73 | TESession::~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 | ||
82 | void TESession::setConnect(bool c) | 81 | void TESession::setConnect(bool c) |
83 | { | 82 | { |
84 | em->setConnect(c); | 83 | em->setConnect(c); |
85 | } | 84 | } |
86 | 85 | ||
87 | void TESession::done(int status) | 86 | void TESession::done(int status) |
88 | { | 87 | { |
89 | emit done(te,status); | 88 | emit done(te,status); |
90 | } | 89 | } |
91 | 90 | ||
92 | void TESession::terminate() | 91 | void TESession::terminate() |
93 | { | 92 | { |
94 | delete this; | 93 | delete this; |
95 | } | 94 | } |
96 | 95 | ||
97 | TEmulation* TESession::getEmulation() | 96 | TEmulation* 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 | ||
104 | int TESession::schemaNo() | 103 | int TESession::schemaNo() |
105 | { | 104 | { |
106 | return schema_no; | 105 | return schema_no; |
107 | } | 106 | } |
108 | 107 | ||
109 | int TESession::keymap() | 108 | int TESession::keymap() |
110 | { | 109 | { |
111 | return keymap_no; | 110 | return keymap_no; |
112 | } | 111 | } |
113 | 112 | ||
114 | int TESession::fontNo() | 113 | int TESession::fontNo() |
115 | { | 114 | { |
116 | return font_no; | 115 | return font_no; |
117 | } | 116 | } |
118 | 117 | ||
119 | const char* TESession::emuName() | 118 | const char* TESession::emuName() |
120 | { | 119 | { |
121 | return term.data(); | 120 | return term.data(); |
122 | } | 121 | } |
123 | 122 | ||
124 | void TESession::setSchemaNo(int sn) | 123 | void TESession::setSchemaNo(int sn) |
125 | { | 124 | { |
126 | schema_no = sn; | 125 | schema_no = sn; |
127 | } | 126 | } |
128 | 127 | ||
129 | void TESession::setKeymapNo(int kn) | 128 | void 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 | ||
135 | void TESession::setFontNo(int fn) | 134 | void TESession::setFontNo(int fn) |
136 | { | 135 | { |
137 | font_no = fn; | 136 | font_no = fn; |
138 | } | 137 | } |
139 | 138 | ||
140 | void TESession::changeTitle(int, const QString& title) | 139 | void 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 | ||
146 | const QString& TESession::Title() | 145 | const QString& TESession::Title() |
147 | { | 146 | { |
148 | return title; | 147 | return title; |
149 | } | 148 | } |
150 | 149 | ||
151 | void TESession::setHistory(bool on) | 150 | void TESession::setHistory(bool on) |
152 | { | 151 | { |
153 | em->setHistory( on ); | 152 | em->setHistory( on ); |
154 | } | 153 | } |
155 | 154 | ||
156 | bool TESession::history() | 155 | bool TESession::history() |
157 | { | 156 | { |
158 | return em->history(); | 157 | return em->history(); |
159 | } | 158 | } |
160 | 159 | ||
161 | // #include "session.moc" | 160 | // #include "session.moc" |
diff --git a/core/apps/helpbrowser/helpbrowser.cpp b/core/apps/helpbrowser/helpbrowser.cpp index 6f84ae2..8fb0161 100644 --- a/core/apps/helpbrowser/helpbrowser.cpp +++ b/core/apps/helpbrowser/helpbrowser.cpp | |||
@@ -1,250 +1,228 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #define QTOPIA_INTERNAL_LANGLIST | 21 | #define QTOPIA_INTERNAL_LANGLIST |
22 | 22 | ||
23 | #include "helpbrowser.h" | 23 | #include "helpbrowser.h" |
24 | 24 | ||
25 | #include <qpe/qpeapplication.h> | 25 | #include <qpe/qpeapplication.h> |
26 | #include <qpe/resource.h> | 26 | #include <qpe/resource.h> |
27 | #include <qpe/mimetype.h> | 27 | |
28 | #include <qpe/applnk.h> | ||
29 | #include <qpe/global.h> | ||
30 | |||
31 | #include <qstatusbar.h> | ||
32 | #include <qdragobject.h> | ||
33 | #include <qpixmap.h> | ||
34 | #include <qpopupmenu.h> | ||
35 | #include <qmenubar.h> | 28 | #include <qmenubar.h> |
36 | #include <qtoolbar.h> | 29 | #include <qtoolbar.h> |
37 | #include <qpe/qcopenvelope_qws.h> | 30 | #include <qpe/qcopenvelope_qws.h> |
38 | #include <qtoolbutton.h> | ||
39 | #include <qiconset.h> | ||
40 | #include <qfile.h> | ||
41 | #include <qtextstream.h> | ||
42 | #include <qstylesheet.h> | ||
43 | #include <qmessagebox.h> | ||
44 | #include <qfiledialog.h> | ||
45 | #include <qevent.h> | ||
46 | #include <qlineedit.h> | ||
47 | #include <qobjectlist.h> | ||
48 | #include <qfileinfo.h> | 31 | #include <qfileinfo.h> |
49 | #include <qfile.h> | ||
50 | #include <qdatastream.h> | ||
51 | #include <qprinter.h> | ||
52 | #include <qsimplerichtext.h> | ||
53 | #include <qpaintdevicemetrics.h> | ||
54 | #include <qaction.h> | 32 | #include <qaction.h> |
55 | 33 | ||
56 | #include <cctype> | 34 | #include <cctype> |
57 | 35 | ||
58 | #include "magictextbrowser.h" | 36 | #include "magictextbrowser.h" |
59 | 37 | ||
60 | HelpBrowser::HelpBrowser( QWidget* parent, const char *name, WFlags f ) | 38 | HelpBrowser::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 | ||
69 | void HelpBrowser::init( const QString& _home ) | 47 | void 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 | ||
140 | void HelpBrowser::appMessage(const QCString& msg, const QByteArray& data) | 118 | void 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 | ||
157 | void HelpBrowser::setDocument( const QString &doc ) | 135 | void 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 | ||
165 | void HelpBrowser::textChanged() | 143 | void 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 | ||
175 | HelpBrowser::~HelpBrowser() | 153 | HelpBrowser::~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 | ||
190 | void HelpBrowser::pathSelected( const QString &_path ) | 168 | void HelpBrowser::pathSelected( const QString &_path ) |
191 | { | 169 | { |
192 | browser->setSource( _path ); | 170 | browser->setSource( _path ); |
193 | } | 171 | } |
194 | 172 | ||
195 | void HelpBrowser::readBookmarks() | 173 | void 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 | ||
220 | void HelpBrowser::bookmChosen( int i ) | 198 | void 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 | ||
226 | void HelpBrowser::addBookmark() | 204 | void 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 | ||
240 | void HelpBrowser::removeBookmark() | 218 | void HelpBrowser::removeBookmark() |
241 | { | 219 | { |
242 | QString file = browser->source(); | 220 | QString file = browser->source(); |
243 | QMap<int, Bookmark>::Iterator it = mBookmarks.begin(); | 221 | QMap<int, Bookmark>::Iterator it = mBookmarks.begin(); |
244 | for( ; it != mBookmarks.end(); ++it ) | 222 | for( ; it != mBookmarks.end(); ++it ) |
245 | if ( (*it).file == file ) { | 223 | if ( (*it).file == file ) { |
246 | bookm->removeItem( it.key() ); | 224 | bookm->removeItem( it.key() ); |
247 | mBookmarks.remove( it ); | 225 | mBookmarks.remove( it ); |
248 | break; | 226 | break; |
249 | } | 227 | } |
250 | } | 228 | } |
diff --git a/core/apps/helpbrowser/magictextbrowser.cpp b/core/apps/helpbrowser/magictextbrowser.cpp index 8ce0325..80495c9 100644 --- a/core/apps/helpbrowser/magictextbrowser.cpp +++ b/core/apps/helpbrowser/magictextbrowser.cpp | |||
@@ -1,99 +1,97 @@ | |||
1 | #include <qfile.h> | 1 | #include <qfile.h> |
2 | #include <qstring.h> | ||
3 | #include <qdragobject.h> | 2 | #include <qdragobject.h> |
4 | #include <qregexp.h> | ||
5 | 3 | ||
6 | /* need to get Global::helpPath() */ | 4 | /* need to get Global::helpPath() */ |
7 | #define QTOPIA_INTERNAL_LANGLIST | 5 | #define QTOPIA_INTERNAL_LANGLIST |
8 | 6 | ||
9 | #include <qtopia/global.h> | 7 | #include <qtopia/global.h> |
10 | #include <qtopia/mimetype.h> | 8 | #include <qtopia/mimetype.h> |
11 | #include <qtopia/applnk.h> | 9 | #include <qtopia/applnk.h> |
12 | 10 | ||
13 | #include "magictextbrowser.h" | 11 | #include "magictextbrowser.h" |
14 | 12 | ||
15 | 13 | ||
16 | 14 | ||
17 | MagicTextBrowser::MagicTextBrowser(QWidget* parent) : | 15 | MagicTextBrowser::MagicTextBrowser(QWidget* parent) : |
18 | QTextBrowser(parent){ | 16 | QTextBrowser(parent){ |
19 | } | 17 | } |
20 | 18 | ||
21 | void MagicTextBrowser::setSource( const QString& source ) { | 19 | void 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 | ||
31 | bool MagicTextBrowser::magicQpe(const QString& source, const QString& name) { | 29 | bool 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 | } |
51 | bool MagicTextBrowser::magicOpe( const QString& source, const QString& name ) { | 49 | bool 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 | } |
71 | QString MagicTextBrowser::generateOpe(const QString& name)const { | 69 | QString 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 | ||
80 | QString MagicTextBrowser::generateQpe(const QString& name) const { | 78 | QString 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 | ||
7 | OAppPlugin::OAppPlugin(OAppPos pos) | 4 | OAppPlugin::OAppPlugin(OAppPos pos) |
8 | { | 5 | { |
9 | m_position = pos; | 6 | m_position = pos; |
10 | }; | 7 | }; |
11 | 8 | ||
12 | OAppPlugin::OAppPlugin(QWidget *widget, OAppPos pos) | 9 | OAppPlugin::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 | ||
18 | OAppPlugin::~OAppPlugin() | 15 | OAppPlugin::~OAppPlugin() |
19 | { | 16 | { |
20 | }; | 17 | }; |
21 | 18 | ||
22 | QList<QWidget> OAppPlugin::widgets() | 19 | QList<QWidget> OAppPlugin::widgets() |
23 | { | 20 | { |
24 | return m_widgets; | 21 | return m_widgets; |
25 | }; | 22 | }; |
26 | 23 | ||
27 | OAppPos OAppPlugin::position() const | 24 | OAppPos OAppPlugin::position() const |
28 | { | 25 | { |
29 | return m_position; | 26 | return m_position; |
30 | } | 27 | } |
31 | 28 | ||
32 | QRESULT OAppPlugin::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) | 29 | QRESULT 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 | ||
31 | static void usage() | 29 | static 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 | ||
36 | static void syntax( const QString &where, const QString &what ) | 34 | static 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 | ||
42 | int main( int argc, char *argv[] ) | 40 | int 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 | ||
11 | int main( int argc, char **argv ) | 10 | int main( int argc, char **argv ) |
12 | { | 11 | { |
13 | QPEApplication a( argc, argv ); | 12 | QPEApplication a( argc, argv ); |
14 | 13 | ||
15 | OTabWidget *tabwidget = new OTabWidget(0, "tab widget"); | 14 | OTabWidget *tabwidget = new OTabWidget(0, "tab widget"); |
16 | 15 | ||
17 | QString path = QPEApplication::qpeDir() + "/plugins/app"; | 16 | QString path = QPEApplication::qpeDir() + "/plugins/app"; |
18 | QDir dir( path, "lib*.so" ); | 17 | QDir dir( path, "lib*.so" ); |
19 | 18 | ||
20 | QStringList list = dir.entryList(); | 19 | QStringList list = dir.entryList(); |
21 | QStringList::Iterator it; | 20 | QStringList::Iterator it; |
22 | 21 | ||
23 | QInterfacePtr<OAppInterface> iface; | 22 | QInterfacePtr<OAppInterface> iface; |
24 | for ( it = list.begin(); it != list.end(); ++it ) { | 23 | for ( it = list.begin(); it != list.end(); ++it ) { |
25 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 24 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
26 | 25 | ||
27 | qDebug( "querying: %s", QString( path + "/" + *it ).latin1() ); | 26 | qDebug( "querying: %s", QString( path + "/" + *it ).latin1() ); |
28 | if ( lib->queryInterface( IID_OAppInterface, (QUnknownInterface**)&iface ) == QS_OK ) { | 27 | if ( lib->queryInterface( IID_OAppInterface, (QUnknownInterface**)&iface ) == QS_OK ) { |
29 | qDebug( "accepted: %s", QString( path + "/" + *it ).latin1() ); | 28 | qDebug( "accepted: %s", QString( path + "/" + *it ).latin1() ); |
30 | 29 | ||
31 | QList<QWidget> list = iface->widgets(); | 30 | QList<QWidget> list = iface->widgets(); |
32 | QWidget *widget; | 31 | QWidget *widget; |
33 | for ( widget = list.first(); widget != 0; widget = list.next() ) | 32 | for ( widget = list.first(); widget != 0; widget = list.next() ) |
34 | tabwidget->addTab(widget, QString(*it), QString(*it)); | 33 | tabwidget->addTab(widget, QString(*it), QString(*it)); |
35 | 34 | ||
36 | QString lang = getenv( "LANG" ); | 35 | QString lang = getenv( "LANG" ); |
37 | if (lang.isNull()) | 36 | if (lang.isNull()) |
38 | lang = "en"; | 37 | lang = "en"; |
39 | QTranslator *trans = new QTranslator(qApp); | 38 | QTranslator *trans = new QTranslator(qApp); |
40 | QString type = (*it).left( (*it).find(".") ); | 39 | QString type = (*it).left( (*it).find(".") ); |
41 | if (type.left(3) == "lib") | 40 | if (type.left(3) == "lib") |
42 | type = type.mid(3); | 41 | type = type.mid(3); |
43 | type = type.right( type.find("lib") ); | 42 | type = type.right( type.find("lib") ); |
44 | QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm"; | 43 | QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm"; |
45 | if ( trans->load( tfn )) | 44 | if ( trans->load( tfn )) |
46 | qApp->installTranslator( trans ); | 45 | qApp->installTranslator( trans ); |
47 | else | 46 | else |
48 | delete trans; | 47 | delete trans; |
49 | } | 48 | } |
50 | } | 49 | } |
51 | 50 | ||
52 | a.showMainDocumentWidget(tabwidget); | 51 | a.showMainDocumentWidget(tabwidget); |
53 | return a.exec(); | 52 | return a.exec(); |
54 | } | 53 | } |
diff --git a/core/apps/textedit/filePermissions.cpp b/core/apps/textedit/filePermissions.cpp index f1c78a1..db353a9 100644 --- a/core/apps/textedit/filePermissions.cpp +++ b/core/apps/textedit/filePermissions.cpp | |||
@@ -1,274 +1,270 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** copyright 2002 ljp ljp@llornkcor.com | 2 | ** copyright 2002 ljp ljp@llornkcor.com |
3 | ** Created: Sat Feb 23 19:44:40 2002 L.J. Potter | 3 | ** Created: Sat Feb 23 19:44:40 2002 L.J. Potter |
4 | ** | 4 | ** |
5 | ** This file may be distributed and/or modified under the terms of the | 5 | ** This file may be distributed and/or modified under the terms of the |
6 | ** GNU General Public License version 2 as published by the Free Software | 6 | ** GNU General Public License version 2 as published by the Free Software |
7 | ** Foundation and appearing in the file LICENSE.GPL included in the | 7 | ** Foundation and appearing in the file LICENSE.GPL included in the |
8 | ** packaging of this file. | 8 | ** packaging of this file. |
9 | ** | 9 | ** |
10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
12 | ** | 12 | ** |
13 | ****************************************************************************/ | 13 | ****************************************************************************/ |
14 | #include "filePermissions.h" | 14 | #include "filePermissions.h" |
15 | 15 | ||
16 | #include <qfile.h> | ||
17 | #include <qfileinfo.h> | 16 | #include <qfileinfo.h> |
18 | 17 | ||
19 | #include <qcheckbox.h> | 18 | #include <qcheckbox.h> |
20 | #include <qlabel.h> | 19 | #include <qlabel.h> |
21 | #include <qlineedit.h> | 20 | #include <qlineedit.h> |
22 | #include <qlayout.h> | ||
23 | #include <qvariant.h> | ||
24 | #include <qtooltip.h> | ||
25 | #include <qmessagebox.h> | 21 | #include <qmessagebox.h> |
26 | 22 | ||
27 | #include <unistd.h> | 23 | #include <unistd.h> |
28 | #include <sys/stat.h> | 24 | #include <sys/stat.h> |
29 | #include <stdlib.h> | 25 | #include <stdlib.h> |
30 | #include <sys/types.h> | 26 | #include <sys/types.h> |
31 | #include <pwd.h> | 27 | #include <pwd.h> |
32 | #include <grp.h> | 28 | #include <grp.h> |
33 | 29 | ||
34 | filePermissions::filePermissions( QWidget* parent, const char* name, bool modal, WFlags fl, const QString &fileName ) | 30 | filePermissions::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 | */ |
165 | filePermissions::~filePermissions() | 161 | filePermissions::~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??? |
171 | void filePermissions::ownReadCheck() { | 167 | void 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 | ||
179 | void filePermissions::ownWriteCheck() { | 175 | void 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 | ||
187 | void filePermissions::ownExeCheck() { | 183 | void 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 | ||
195 | void filePermissions::grpReadCheck() { | 191 | void 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 | ||
203 | void filePermissions::grpWriteCheck() { | 199 | void 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 | ||
211 | void filePermissions::grpExeCheck() { | 207 | void filePermissions::grpExeCheck() { |
212 | if(CheckBox1_6->isChecked()) { i_mode +=10; } | 208 | if(CheckBox1_6->isChecked()) { i_mode +=10; } |
213 | else i_mode -=10; | 209 | else i_mode -=10; |
214 | modeStr.sprintf("0%d",i_mode); | 210 | modeStr.sprintf("0%d",i_mode); |
215 | ModeLine->setText(modeStr); | 211 | ModeLine->setText(modeStr); |
216 | // 0010 | 212 | // 0010 |
217 | } | 213 | } |
218 | 214 | ||
219 | void filePermissions::wrldReadCheck() { | 215 | void filePermissions::wrldReadCheck() { |
220 | if(CheckBox1_7->isChecked()) { i_mode +=4; } | 216 | if(CheckBox1_7->isChecked()) { i_mode +=4; } |
221 | else i_mode -=4; | 217 | else i_mode -=4; |
222 | modeStr.sprintf("0%d",i_mode); | 218 | modeStr.sprintf("0%d",i_mode); |
223 | ModeLine->setText(modeStr); | 219 | ModeLine->setText(modeStr); |
224 | // 0004 | 220 | // 0004 |
225 | } | 221 | } |
226 | 222 | ||
227 | void filePermissions::wrldWriteCheck() { | 223 | void filePermissions::wrldWriteCheck() { |
228 | if(CheckBox1_8->isChecked()) { i_mode +=2; } | 224 | if(CheckBox1_8->isChecked()) { i_mode +=2; } |
229 | else i_mode -=2; | 225 | else i_mode -=2; |
230 | modeStr.sprintf("0%d",i_mode); | 226 | modeStr.sprintf("0%d",i_mode); |
231 | ModeLine->setText(modeStr); | 227 | ModeLine->setText(modeStr); |
232 | // 0002 | 228 | // 0002 |
233 | } | 229 | } |
234 | 230 | ||
235 | void filePermissions::wrldExeCheck() { | 231 | void filePermissions::wrldExeCheck() { |
236 | if(CheckBox1_8_2->isChecked()) { i_mode +=1; } | 232 | if(CheckBox1_8_2->isChecked()) { i_mode +=1; } |
237 | else i_mode -=1; | 233 | else i_mode -=1; |
238 | modeStr.sprintf("0%d",i_mode); | 234 | modeStr.sprintf("0%d",i_mode); |
239 | ModeLine->setText(modeStr); | 235 | ModeLine->setText(modeStr); |
240 | // 0001 | 236 | // 0001 |
241 | } | 237 | } |
242 | 238 | ||
243 | void filePermissions::accept() { | 239 | void filePermissions::accept() { |
244 | 240 | ||
245 | QFileInfo fi(file); | 241 | QFileInfo fi(file); |
246 | struct passwd *pwd=0; | 242 | struct passwd *pwd=0; |
247 | struct group *grp=0; | 243 | struct group *grp=0; |
248 | pwd = getpwnam(OwnerLineEdit->text().latin1() ); | 244 | pwd = getpwnam(OwnerLineEdit->text().latin1() ); |
249 | if(pwd == NULL) { | 245 | if(pwd == NULL) { |
250 | perror("getpwnam"); | 246 | perror("getpwnam"); |
251 | QMessageBox::warning(this,tr("Warning"),tr("Error- no user")); | 247 | QMessageBox::warning(this,tr("Warning"),tr("Error- no user")); |
252 | return; | 248 | return; |
253 | } else { | 249 | } else { |
254 | grp = getgrnam(GroupLineEdit->text().latin1()); | 250 | grp = getgrnam(GroupLineEdit->text().latin1()); |
255 | if(grp==NULL) { | 251 | if(grp==NULL) { |
256 | perror("getgrnam"); | 252 | perror("getgrnam"); |
257 | QMessageBox::warning(this,tr("Warning"),tr("Error- no group")); | 253 | QMessageBox::warning(this,tr("Warning"),tr("Error- no group")); |
258 | return; | 254 | return; |
259 | } | 255 | } |
260 | if( chown( file.latin1(), pwd->pw_uid, grp->gr_gid) <0) { | 256 | if( chown( file.latin1(), pwd->pw_uid, grp->gr_gid) <0) { |
261 | perror("chown"); | 257 | perror("chown"); |
262 | QMessageBox::warning(this,tr("Warning"),tr("Error setting ownership or group")); | 258 | QMessageBox::warning(this,tr("Warning"),tr("Error setting ownership or group")); |
263 | return; | 259 | return; |
264 | } | 260 | } |
265 | bool ok; | 261 | bool ok; |
266 | uint moder = modeStr.toUInt(&ok,8); | 262 | uint moder = modeStr.toUInt(&ok,8); |
267 | if( chmod( file.latin1(), moder) < 0) { | 263 | if( chmod( file.latin1(), moder) < 0) { |
268 | perror("chmod"); | 264 | perror("chmod"); |
269 | QMessageBox::warning(this,tr("Warning"),tr("Error setting mode")); | 265 | QMessageBox::warning(this,tr("Warning"),tr("Error setting mode")); |
270 | return; | 266 | return; |
271 | } | 267 | } |
272 | } | 268 | } |
273 | close(); | 269 | close(); |
274 | } | 270 | } |
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index 8e106bf..55725cc 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp | |||
@@ -1,819 +1,801 @@ | |||
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 | ||
58 | using Opie::OFileDialog; | 40 | using Opie::OFileDialog; |
59 | using Opie::OFileSelector; | 41 | using Opie::OFileSelector; |
60 | using Opie::OFontSelector; | 42 | using Opie::OFontSelector; |
61 | 43 | ||
62 | #if QT_VERSION < 300 | 44 | #if QT_VERSION < 300 |
63 | 45 | ||
64 | class QpeEditor : public QMultiLineEdit | 46 | class QpeEditor : public QMultiLineEdit |
65 | { | 47 | { |
66 | 48 | ||
67 | public: | 49 | public: |
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 ); |
76 | protected: | 58 | protected: |
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 | /* |
84 | signals: | 66 | signals: |
85 | void notFound(); | 67 | void notFound(); |
86 | void searchWrapped(); | 68 | void searchWrapped(); |
87 | */ | 69 | */ |
88 | 70 | ||
89 | private: | 71 | private: |
90 | 72 | ||
91 | }; | 73 | }; |
92 | 74 | ||
93 | void QpeEditor::mousePressEvent( QMouseEvent *e ) { | 75 | void 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 | ||
117 | void QpeEditor::mouseReleaseEvent( QMouseEvent * ) { | 99 | void 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 | ||
126 | void QpeEditor::find ( const QString &txt, bool caseSensitive, | 108 | void 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 | ||
170 | static const int nfontsizes = 6; | 152 | static const int nfontsizes = 6; |
171 | static const int fontsize[nfontsizes] = {8,10,12,14,18,24}; | 153 | static const int fontsize[nfontsizes] = {8,10,12,14,18,24}; |
172 | 154 | ||
173 | TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) | 155 | TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) |
174 | : QMainWindow( parent, name, f ), bFromDocView( false ) | 156 | : QMainWindow( parent, name, f ), bFromDocView( false ) |
175 | { | 157 | { |
176 | doc = 0; | 158 | doc = 0; |
177 | edited=false; | 159 | edited=false; |
178 | fromSetDocument=false; | 160 | fromSetDocument=false; |
179 | 161 | ||
180 | setToolBarsMovable( false ); | 162 | setToolBarsMovable( false ); |
181 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 163 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
182 | 164 | ||
183 | channel = new QCopChannel( "QPE/Application/textedit", this ); | 165 | channel = new QCopChannel( "QPE/Application/textedit", this ); |
184 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 166 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), |
185 | this, SLOT(receive(const QCString&, const QByteArray&)) ); | 167 | this, SLOT(receive(const QCString&, const QByteArray&)) ); |
186 | 168 | ||
187 | setIcon( Resource::loadPixmap( "TextEditor" ) ); | 169 | setIcon( Resource::loadPixmap( "TextEditor" ) ); |
188 | 170 | ||
189 | QToolBar *bar = new QToolBar( this ); | 171 | QToolBar *bar = new QToolBar( this ); |
190 | bar->setHorizontalStretchable( true ); | 172 | bar->setHorizontalStretchable( true ); |
191 | menu = bar; | 173 | menu = bar; |
192 | 174 | ||
193 | QMenuBar *mb = new QMenuBar( bar ); | 175 | QMenuBar *mb = new QMenuBar( bar ); |
194 | QPopupMenu *file = new QPopupMenu( this ); | 176 | QPopupMenu *file = new QPopupMenu( this ); |
195 | QPopupMenu *edit = new QPopupMenu( this ); | 177 | QPopupMenu *edit = new QPopupMenu( this ); |
196 | QPopupMenu *advancedMenu = new QPopupMenu(this); | 178 | QPopupMenu *advancedMenu = new QPopupMenu(this); |
197 | 179 | ||
198 | font = new QPopupMenu( this ); | 180 | font = new QPopupMenu( this ); |
199 | 181 | ||
200 | bar = new QToolBar( this ); | 182 | bar = new QToolBar( this ); |
201 | editBar = bar; | 183 | editBar = bar; |
202 | 184 | ||
203 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), | 185 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), |
204 | QString::null, 0, this, 0 ); | 186 | QString::null, 0, this, 0 ); |
205 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); | 187 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); |
206 | // a->addTo( bar ); | 188 | // a->addTo( bar ); |
207 | a->addTo( file ); | 189 | a->addTo( file ); |
208 | 190 | ||
209 | a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), | 191 | a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), |
210 | QString::null, 0, this, 0 ); | 192 | QString::null, 0, this, 0 ); |
211 | connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); | 193 | connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); |
212 | a->addTo( bar ); | 194 | a->addTo( bar ); |
213 | a->addTo( file ); | 195 | a->addTo( file ); |
214 | 196 | ||
215 | a = new QAction( tr( "Save" ), Resource::loadPixmap("save") , | 197 | a = new QAction( tr( "Save" ), Resource::loadPixmap("save") , |
216 | QString::null, 0, this, 0 ); | 198 | QString::null, 0, this, 0 ); |
217 | connect( a, SIGNAL( activated() ), this, SLOT( save() ) ); | 199 | connect( a, SIGNAL( activated() ), this, SLOT( save() ) ); |
218 | file->insertSeparator(); | 200 | file->insertSeparator(); |
219 | a->addTo( bar ); | 201 | a->addTo( bar ); |
220 | a->addTo( file ); | 202 | a->addTo( file ); |
221 | 203 | ||
222 | a = new QAction( tr( "Save As" ), Resource::loadPixmap("save") , | 204 | a = new QAction( tr( "Save As" ), Resource::loadPixmap("save") , |
223 | QString::null, 0, this, 0 ); | 205 | QString::null, 0, this, 0 ); |
224 | connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) ); | 206 | connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) ); |
225 | a->addTo( file ); | 207 | a->addTo( file ); |
226 | 208 | ||
227 | a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), | 209 | a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), |
228 | QString::null, 0, this, 0 ); | 210 | QString::null, 0, this, 0 ); |
229 | connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); | 211 | connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); |
230 | a->addTo( editBar ); | 212 | a->addTo( editBar ); |
231 | a->addTo( edit ); | 213 | a->addTo( edit ); |
232 | 214 | ||
233 | a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), | 215 | a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), |
234 | QString::null, 0, this, 0 ); | 216 | QString::null, 0, this, 0 ); |
235 | connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); | 217 | connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); |
236 | a->addTo( editBar ); | 218 | a->addTo( editBar ); |
237 | a->addTo( edit ); | 219 | a->addTo( edit ); |
238 | 220 | ||
239 | a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), | 221 | a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), |
240 | QString::null, 0, this, 0 ); | 222 | QString::null, 0, this, 0 ); |
241 | connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); | 223 | connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); |
242 | a->addTo( editBar ); | 224 | a->addTo( editBar ); |
243 | a->addTo( edit ); | 225 | a->addTo( edit ); |
244 | 226 | ||
245 | 227 | ||
246 | #ifndef QT_NO_CLIPBOARD | 228 | #ifndef QT_NO_CLIPBOARD |
247 | a = new QAction( tr( "Insert Time and Date" ), Resource::loadPixmap( "paste" ), | 229 | a = new QAction( tr( "Insert Time and Date" ), Resource::loadPixmap( "paste" ), |
248 | QString::null, 0, this, 0 ); | 230 | QString::null, 0, this, 0 ); |
249 | connect( a, SIGNAL( activated() ), this, SLOT( editPasteTimeDate() ) ); | 231 | connect( a, SIGNAL( activated() ), this, SLOT( editPasteTimeDate() ) ); |
250 | a->addTo( edit ); | 232 | a->addTo( edit ); |
251 | #endif | 233 | #endif |
252 | 234 | ||
253 | a = new QAction( tr( "Goto Line..." ), Resource::loadPixmap( "find" ), | 235 | a = new QAction( tr( "Goto Line..." ), Resource::loadPixmap( "find" ), |
254 | QString::null, 0, this, 0 ); | 236 | QString::null, 0, this, 0 ); |
255 | connect( a, SIGNAL( activated() ), this, SLOT( gotoLine() ) ); | 237 | connect( a, SIGNAL( activated() ), this, SLOT( gotoLine() ) ); |
256 | edit->insertSeparator(); | 238 | edit->insertSeparator(); |
257 | a->addTo( edit ); | 239 | a->addTo( edit ); |
258 | 240 | ||
259 | a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), | 241 | a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), |
260 | QString::null, 0, this, 0 ); | 242 | QString::null, 0, this, 0 ); |
261 | connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); | 243 | connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); |
262 | a->addTo( bar ); | 244 | a->addTo( bar ); |
263 | a->addTo( edit ); | 245 | a->addTo( edit ); |
264 | 246 | ||
265 | zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 ); | 247 | zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 ); |
266 | connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) ); | 248 | connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) ); |
267 | zin->addTo( font ); | 249 | zin->addTo( font ); |
268 | 250 | ||
269 | zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 ); | 251 | zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 ); |
270 | connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) ); | 252 | connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) ); |
271 | zout->addTo( font ); | 253 | zout->addTo( font ); |
272 | 254 | ||
273 | font->insertSeparator(); | 255 | font->insertSeparator(); |
274 | 256 | ||
275 | font->insertItem(tr("Font"), this, SLOT(changeFont()) ); | 257 | font->insertItem(tr("Font"), this, SLOT(changeFont()) ); |
276 | 258 | ||
277 | font->insertSeparator(); | 259 | font->insertSeparator(); |
278 | font->insertItem(tr("Advanced Features"), advancedMenu); | 260 | font->insertItem(tr("Advanced Features"), advancedMenu); |
279 | 261 | ||
280 | QAction *wa = new QAction( tr("Wrap lines"), | 262 | QAction *wa = new QAction( tr("Wrap lines"), |
281 | QString::null, 0, this, 0 ); | 263 | QString::null, 0, this, 0 ); |
282 | connect( wa, SIGNAL( toggled(bool) ), | 264 | connect( wa, SIGNAL( toggled(bool) ), |
283 | this, SLOT( setWordWrap(bool) ) ); | 265 | this, SLOT( setWordWrap(bool) ) ); |
284 | wa->setToggleAction(true); | 266 | wa->setToggleAction(true); |
285 | wa->addTo( advancedMenu); | 267 | wa->addTo( advancedMenu); |
286 | 268 | ||
287 | nStart = new QAction( tr("Start with new file"), | 269 | nStart = new QAction( tr("Start with new file"), |
288 | QString::null, 0, this, 0 ); | 270 | QString::null, 0, this, 0 ); |
289 | connect( nStart, SIGNAL( toggled(bool) ), | 271 | connect( nStart, SIGNAL( toggled(bool) ), |
290 | this, SLOT( changeStartConfig(bool) ) ); | 272 | this, SLOT( changeStartConfig(bool) ) ); |
291 | nStart->setToggleAction(true); | 273 | nStart->setToggleAction(true); |
292 | nStart->addTo( advancedMenu ); | 274 | nStart->addTo( advancedMenu ); |
293 | nStart->setEnabled(false); | 275 | nStart->setEnabled(false); |
294 | 276 | ||
295 | nAdvanced = new QAction( tr("Prompt on Exit"), | 277 | nAdvanced = new QAction( tr("Prompt on Exit"), |
296 | QString::null, 0, this, 0 ); | 278 | QString::null, 0, this, 0 ); |
297 | connect( nAdvanced, SIGNAL( toggled(bool) ), | 279 | connect( nAdvanced, SIGNAL( toggled(bool) ), |
298 | this, SLOT( doPrompt(bool) ) ); | 280 | this, SLOT( doPrompt(bool) ) ); |
299 | nAdvanced->setToggleAction(true); | 281 | nAdvanced->setToggleAction(true); |
300 | nAdvanced->addTo( advancedMenu ); | 282 | nAdvanced->addTo( advancedMenu ); |
301 | 283 | ||
302 | desktopAction = new QAction( tr("Always open linked file"), | 284 | desktopAction = new QAction( tr("Always open linked file"), |
303 | QString::null, 0, this, 0 ); | 285 | QString::null, 0, this, 0 ); |
304 | connect( desktopAction, SIGNAL( toggled(bool) ), | 286 | connect( desktopAction, SIGNAL( toggled(bool) ), |
305 | this, SLOT( doDesktop(bool) ) ); | 287 | this, SLOT( doDesktop(bool) ) ); |
306 | desktopAction->setToggleAction(true); | 288 | desktopAction->setToggleAction(true); |
307 | desktopAction->addTo( advancedMenu); | 289 | desktopAction->addTo( advancedMenu); |
308 | 290 | ||
309 | filePermAction = new QAction( tr("File Permissions"), | 291 | filePermAction = new QAction( tr("File Permissions"), |
310 | QString::null, 0, this, 0 ); | 292 | QString::null, 0, this, 0 ); |
311 | connect( filePermAction, SIGNAL( toggled(bool) ), | 293 | connect( filePermAction, SIGNAL( toggled(bool) ), |
312 | this, SLOT( doFilePerms(bool) ) ); | 294 | this, SLOT( doFilePerms(bool) ) ); |
313 | filePermAction->setToggleAction(true); | 295 | filePermAction->setToggleAction(true); |
314 | filePermAction->addTo( advancedMenu); | 296 | filePermAction->addTo( advancedMenu); |
315 | 297 | ||
316 | searchBarAction = new QAction( tr("Search Bar Open"), | 298 | searchBarAction = new QAction( tr("Search Bar Open"), |
317 | QString::null, 0, this, 0 ); | 299 | QString::null, 0, this, 0 ); |
318 | connect( searchBarAction, SIGNAL( toggled(bool) ), | 300 | connect( searchBarAction, SIGNAL( toggled(bool) ), |
319 | this, SLOT( setSearchBar(bool) ) ); | 301 | this, SLOT( setSearchBar(bool) ) ); |
320 | searchBarAction->setToggleAction(true); | 302 | searchBarAction->setToggleAction(true); |
321 | searchBarAction->addTo( advancedMenu); | 303 | searchBarAction->addTo( advancedMenu); |
322 | 304 | ||
323 | nAutoSave = new QAction( tr("Auto Save 5 min."), | 305 | nAutoSave = new QAction( tr("Auto Save 5 min."), |
324 | QString::null, 0, this, 0 ); | 306 | QString::null, 0, this, 0 ); |
325 | connect( nAutoSave, SIGNAL( toggled(bool) ), | 307 | connect( nAutoSave, SIGNAL( toggled(bool) ), |
326 | this, SLOT( doTimer(bool) ) ); | 308 | this, SLOT( doTimer(bool) ) ); |
327 | nAutoSave->setToggleAction(true); | 309 | nAutoSave->setToggleAction(true); |
328 | nAutoSave->addTo( advancedMenu); | 310 | nAutoSave->addTo( advancedMenu); |
329 | 311 | ||
330 | 312 | ||
331 | //font->insertSeparator(); | 313 | //font->insertSeparator(); |
332 | 314 | ||
333 | //font->insertItem(tr("About"), this, SLOT( doAbout()) ); | 315 | //font->insertItem(tr("About"), this, SLOT( doAbout()) ); |
334 | 316 | ||
335 | mb->insertItem( tr( "File" ), file ); | 317 | mb->insertItem( tr( "File" ), file ); |
336 | mb->insertItem( tr( "Edit" ), edit ); | 318 | mb->insertItem( tr( "Edit" ), edit ); |
337 | mb->insertItem( tr( "View" ), font ); | 319 | mb->insertItem( tr( "View" ), font ); |
338 | 320 | ||
339 | searchBar = new QToolBar(this); | 321 | searchBar = new QToolBar(this); |
340 | addToolBar( searchBar, "Search", QMainWindow::Top, true ); | 322 | addToolBar( searchBar, "Search", QMainWindow::Top, true ); |
341 | 323 | ||
342 | searchBar->setHorizontalStretchable( true ); | 324 | searchBar->setHorizontalStretchable( true ); |
343 | 325 | ||
344 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); | 326 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); |
345 | searchBar->setStretchableWidget( searchEdit ); | 327 | searchBar->setStretchableWidget( searchEdit ); |
346 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), | 328 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), |
347 | this, SLOT( search() ) ); | 329 | this, SLOT( search() ) ); |
348 | 330 | ||
349 | a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), | 331 | a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), |
350 | QString::null, 0, this, 0 ); | 332 | QString::null, 0, this, 0 ); |
351 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); | 333 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); |
352 | a->addTo( searchBar ); | 334 | a->addTo( searchBar ); |
353 | a->addTo( edit ); | 335 | a->addTo( edit ); |
354 | 336 | ||
355 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), | 337 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), |
356 | QString::null, 0, this, 0 ); | 338 | QString::null, 0, this, 0 ); |
357 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); | 339 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); |
358 | a->addTo( searchBar ); | 340 | a->addTo( searchBar ); |
359 | 341 | ||
360 | edit->insertSeparator(); | 342 | edit->insertSeparator(); |
361 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), | 343 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), |
362 | QString::null, 0, this, 0 ); | 344 | QString::null, 0, this, 0 ); |
363 | connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); | 345 | connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); |
364 | a->addTo( edit ); | 346 | a->addTo( edit ); |
365 | 347 | ||
366 | searchBar->hide(); | 348 | searchBar->hide(); |
367 | 349 | ||
368 | editor = new QpeEditor( this ); | 350 | editor = new QpeEditor( this ); |
369 | setCentralWidget( editor ); | 351 | setCentralWidget( editor ); |
370 | editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 352 | editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
371 | connect( editor, SIGNAL( textChanged() ), | 353 | connect( editor, SIGNAL( textChanged() ), |
372 | this, SLOT( editorChanged() ) ); | 354 | this, SLOT( editorChanged() ) ); |
373 | 355 | ||
374 | QPEApplication::setStylusOperation( editor, QPEApplication::RightOnHold); | 356 | QPEApplication::setStylusOperation( editor, QPEApplication::RightOnHold); |
375 | 357 | ||
376 | Config cfg("TextEdit"); | 358 | Config cfg("TextEdit"); |
377 | cfg. setGroup ( "Font" ); | 359 | cfg. setGroup ( "Font" ); |
378 | 360 | ||
379 | QFont defaultFont = editor-> font ( ); | 361 | QFont defaultFont = editor-> font ( ); |
380 | 362 | ||
381 | QString family = cfg. readEntry ( "Family", defaultFont. family ( )); | 363 | QString family = cfg. readEntry ( "Family", defaultFont. family ( )); |
382 | int size = cfg. readNumEntry ( "Size", defaultFont. pointSize ( )); | 364 | int size = cfg. readNumEntry ( "Size", defaultFont. pointSize ( )); |
383 | int weight = cfg. readNumEntry ( "Weight", defaultFont. weight ( )); | 365 | int weight = cfg. readNumEntry ( "Weight", defaultFont. weight ( )); |
384 | bool italic = cfg. readBoolEntry ( "Italic", defaultFont. italic ( )); | 366 | bool italic = cfg. readBoolEntry ( "Italic", defaultFont. italic ( )); |
385 | 367 | ||
386 | defaultFont = QFont ( family, size, weight, italic ); | 368 | defaultFont = QFont ( family, size, weight, italic ); |
387 | editor-> setFont ( defaultFont ); | 369 | editor-> setFont ( defaultFont ); |
388 | // updateCaption(); | 370 | // updateCaption(); |
389 | 371 | ||
390 | cfg.setGroup ( "View" ); | 372 | cfg.setGroup ( "View" ); |
391 | 373 | ||
392 | promptExit = cfg.readBoolEntry ( "PromptExit", false ); | 374 | promptExit = cfg.readBoolEntry ( "PromptExit", false ); |
393 | openDesktop = cfg.readBoolEntry ( "OpenDesktop", true ); | 375 | openDesktop = cfg.readBoolEntry ( "OpenDesktop", true ); |
394 | filePerms = cfg.readBoolEntry ( "FilePermissions", false ); | 376 | filePerms = cfg.readBoolEntry ( "FilePermissions", false ); |
395 | useSearchBar = cfg.readBoolEntry ( "SearchBar", false ); | 377 | useSearchBar = cfg.readBoolEntry ( "SearchBar", false ); |
396 | startWithNew = cfg.readBoolEntry ( "startNew", true); | 378 | startWithNew = cfg.readBoolEntry ( "startNew", true); |
397 | featureAutoSave = cfg.readBoolEntry( "autosave", false); | 379 | featureAutoSave = cfg.readBoolEntry( "autosave", false); |
398 | 380 | ||
399 | if(useSearchBar) searchBarAction->setOn(true); | 381 | if(useSearchBar) searchBarAction->setOn(true); |
400 | if(promptExit) nAdvanced->setOn( true ); | 382 | if(promptExit) nAdvanced->setOn( true ); |
401 | if(openDesktop) desktopAction->setOn( true ); | 383 | if(openDesktop) desktopAction->setOn( true ); |
402 | if(filePerms) filePermAction->setOn( true ); | 384 | if(filePerms) filePermAction->setOn( true ); |
403 | if(startWithNew) nStart->setOn( true ); | 385 | if(startWithNew) nStart->setOn( true ); |
404 | if(featureAutoSave) nAutoSave->setOn(true); | 386 | if(featureAutoSave) nAutoSave->setOn(true); |
405 | 387 | ||
406 | // { | 388 | // { |
407 | // doTimer(true); | 389 | // doTimer(true); |
408 | // } | 390 | // } |
409 | 391 | ||
410 | bool wrap = cfg. readBoolEntry ( "Wrap", true ); | 392 | bool wrap = cfg. readBoolEntry ( "Wrap", true ); |
411 | wa-> setOn ( wrap ); | 393 | wa-> setOn ( wrap ); |
412 | setWordWrap ( wrap ); | 394 | setWordWrap ( wrap ); |
413 | 395 | ||
414 | ///////////////// | 396 | ///////////////// |
415 | if( qApp->argc() > 1) { | 397 | if( qApp->argc() > 1) { |
416 | currentFileName=qApp->argv()[1]; | 398 | currentFileName=qApp->argv()[1]; |
417 | 399 | ||
418 | QFileInfo fi(currentFileName); | 400 | QFileInfo fi(currentFileName); |
419 | 401 | ||
420 | if(fi.baseName().left(1) == "") { | 402 | if(fi.baseName().left(1) == "") { |
421 | openDotFile(currentFileName); | 403 | openDotFile(currentFileName); |
422 | } else { | 404 | } else { |
423 | openFile(currentFileName); | 405 | openFile(currentFileName); |
424 | } | 406 | } |
425 | } else { | 407 | } else { |
426 | edited1=false; | 408 | edited1=false; |
427 | openDotFile(""); | 409 | openDotFile(""); |
428 | } | 410 | } |
429 | 411 | ||
430 | viewSelection = cfg.readNumEntry( "FileView", 0 ); | 412 | viewSelection = cfg.readNumEntry( "FileView", 0 ); |
431 | } | 413 | } |
432 | 414 | ||
433 | TextEdit::~TextEdit() { | 415 | TextEdit::~TextEdit() { |
434 | qWarning("textedit d'tor"); | 416 | qWarning("textedit d'tor"); |
435 | delete editor; | 417 | delete editor; |
436 | } | 418 | } |
437 | 419 | ||
438 | void TextEdit::closeEvent(QCloseEvent *) { | 420 | void TextEdit::closeEvent(QCloseEvent *) { |
439 | if( edited1 && promptExit) | 421 | if( edited1 && promptExit) |
440 | { | 422 | { |
441 | switch( savePrompt() ) | 423 | switch( savePrompt() ) |
442 | { | 424 | { |
443 | case 1: | 425 | case 1: |
444 | { | 426 | { |
445 | saveAs(); | 427 | saveAs(); |
446 | qApp->quit(); | 428 | qApp->quit(); |
447 | } | 429 | } |
448 | break; | 430 | break; |
449 | 431 | ||
450 | case 2: | 432 | case 2: |
451 | { | 433 | { |
452 | qApp->quit(); | 434 | qApp->quit(); |
453 | } | 435 | } |
454 | break; | 436 | break; |
455 | 437 | ||
456 | case -1: | 438 | case -1: |
457 | break; | 439 | break; |
458 | }; | 440 | }; |
459 | } | 441 | } |
460 | else | 442 | else |
461 | qApp->quit(); | 443 | qApp->quit(); |
462 | 444 | ||
463 | } | 445 | } |
464 | 446 | ||
465 | void TextEdit::cleanUp() { | 447 | void TextEdit::cleanUp() { |
466 | 448 | ||
467 | Config cfg ( "TextEdit" ); | 449 | Config cfg ( "TextEdit" ); |
468 | cfg. setGroup ( "Font" ); | 450 | cfg. setGroup ( "Font" ); |
469 | QFont f = editor->font(); | 451 | QFont f = editor->font(); |
470 | cfg.writeEntry ( "Family", f. family ( )); | 452 | cfg.writeEntry ( "Family", f. family ( )); |
471 | cfg.writeEntry ( "Size", f. pointSize ( )); | 453 | cfg.writeEntry ( "Size", f. pointSize ( )); |
472 | cfg.writeEntry ( "Weight", f. weight ( )); | 454 | cfg.writeEntry ( "Weight", f. weight ( )); |
473 | cfg.writeEntry ( "Italic", f. italic ( )); | 455 | cfg.writeEntry ( "Italic", f. italic ( )); |
474 | 456 | ||
475 | cfg.setGroup ( "View" ); | 457 | cfg.setGroup ( "View" ); |
476 | cfg.writeEntry ( "Wrap", editor->wordWrap() == QMultiLineEdit::WidgetWidth ); | 458 | cfg.writeEntry ( "Wrap", editor->wordWrap() == QMultiLineEdit::WidgetWidth ); |
477 | cfg.writeEntry ( "FileView", viewSelection ); | 459 | cfg.writeEntry ( "FileView", viewSelection ); |
478 | 460 | ||
479 | cfg.writeEntry ( "PromptExit", promptExit ); | 461 | cfg.writeEntry ( "PromptExit", promptExit ); |
480 | cfg.writeEntry ( "OpenDesktop", openDesktop ); | 462 | cfg.writeEntry ( "OpenDesktop", openDesktop ); |
481 | cfg.writeEntry ( "FilePermissions", filePerms ); | 463 | cfg.writeEntry ( "FilePermissions", filePerms ); |
482 | cfg.writeEntry ( "SearchBar", useSearchBar ); | 464 | cfg.writeEntry ( "SearchBar", useSearchBar ); |
483 | cfg.writeEntry ( "startNew", startWithNew ); | 465 | cfg.writeEntry ( "startNew", startWithNew ); |
484 | 466 | ||
485 | } | 467 | } |
486 | 468 | ||
487 | 469 | ||
488 | void TextEdit::accept() { | 470 | void TextEdit::accept() { |
489 | if( edited1) | 471 | if( edited1) |
490 | saveAs(); | 472 | saveAs(); |
491 | qApp->quit(); | 473 | qApp->quit(); |
492 | } | 474 | } |
493 | 475 | ||
494 | void TextEdit::zoomIn() { | 476 | void TextEdit::zoomIn() { |
495 | setFontSize(editor->font().pointSize()+1,false); | 477 | setFontSize(editor->font().pointSize()+1,false); |
496 | } | 478 | } |
497 | 479 | ||
498 | void TextEdit::zoomOut() { | 480 | void TextEdit::zoomOut() { |
499 | setFontSize(editor->font().pointSize()-1,true); | 481 | setFontSize(editor->font().pointSize()-1,true); |
500 | } | 482 | } |
501 | 483 | ||
502 | 484 | ||
503 | void TextEdit::setFontSize(int sz, bool round_down_not_up) { | 485 | void TextEdit::setFontSize(int sz, bool round_down_not_up) { |
504 | int s=10; | 486 | int s=10; |
505 | for (int i=0; i<nfontsizes; i++) { | 487 | for (int i=0; i<nfontsizes; i++) { |
506 | if ( fontsize[i] == sz ) { | 488 | if ( fontsize[i] == sz ) { |
507 | s = sz; | 489 | s = sz; |
508 | break; | 490 | break; |
509 | } else if ( round_down_not_up ) { | 491 | } else if ( round_down_not_up ) { |
510 | if ( fontsize[i] < sz ) | 492 | if ( fontsize[i] < sz ) |
511 | s = fontsize[i]; | 493 | s = fontsize[i]; |
512 | } else { | 494 | } else { |
513 | if ( fontsize[i] > sz ) { | 495 | if ( fontsize[i] > sz ) { |
514 | s = fontsize[i]; | 496 | s = fontsize[i]; |
515 | break; | 497 | break; |
516 | } | 498 | } |
517 | } | 499 | } |
518 | } | 500 | } |
519 | 501 | ||
520 | QFont f = editor->font(); | 502 | QFont f = editor->font(); |
521 | f.setPointSize(s); | 503 | f.setPointSize(s); |
522 | editor->setFont(f); | 504 | editor->setFont(f); |
523 | 505 | ||
524 | zin->setEnabled(s != fontsize[nfontsizes-1]); | 506 | zin->setEnabled(s != fontsize[nfontsizes-1]); |
525 | zout->setEnabled(s != fontsize[0]); | 507 | zout->setEnabled(s != fontsize[0]); |
526 | } | 508 | } |
527 | 509 | ||
528 | void TextEdit::setBold(bool y) { | 510 | void TextEdit::setBold(bool y) { |
529 | QFont f = editor->font(); | 511 | QFont f = editor->font(); |
530 | f.setBold(y); | 512 | f.setBold(y); |
531 | editor->setFont(f); | 513 | editor->setFont(f); |
532 | } | 514 | } |
533 | 515 | ||
534 | void TextEdit::setItalic(bool y) { | 516 | void TextEdit::setItalic(bool y) { |
535 | QFont f = editor->font(); | 517 | QFont f = editor->font(); |
536 | f.setItalic(y); | 518 | f.setItalic(y); |
537 | editor->setFont(f); | 519 | editor->setFont(f); |
538 | } | 520 | } |
539 | 521 | ||
540 | void TextEdit::setWordWrap(bool y) { | 522 | void TextEdit::setWordWrap(bool y) { |
541 | bool state = editor->edited(); | 523 | bool state = editor->edited(); |
542 | QString captionStr = caption(); | 524 | QString captionStr = caption(); |
543 | bool b1 = edited1; | 525 | bool b1 = edited1; |
544 | bool b2 = edited; | 526 | bool b2 = edited; |
545 | 527 | ||
546 | editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); | 528 | editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); |
547 | editor->setEdited( state ); | 529 | editor->setEdited( state ); |
548 | edited1=b1; | 530 | edited1=b1; |
549 | edited=b2; | 531 | edited=b2; |
550 | setCaption(captionStr); | 532 | setCaption(captionStr); |
551 | } | 533 | } |
552 | 534 | ||
553 | void TextEdit::setSearchBar(bool b) { | 535 | void TextEdit::setSearchBar(bool b) { |
554 | useSearchBar=b; | 536 | useSearchBar=b; |
555 | Config cfg("TextEdit"); | 537 | Config cfg("TextEdit"); |
556 | cfg.setGroup("View"); | 538 | cfg.setGroup("View"); |
557 | cfg.writeEntry ( "SearchBar", b ); | 539 | cfg.writeEntry ( "SearchBar", b ); |
558 | searchBarAction->setOn(b); | 540 | searchBarAction->setOn(b); |
559 | if(b) | 541 | if(b) |
560 | searchBar->show(); | 542 | searchBar->show(); |
561 | else | 543 | else |
562 | searchBar->hide(); | 544 | searchBar->hide(); |
563 | editor->setFocus(); | 545 | editor->setFocus(); |
564 | } | 546 | } |
565 | 547 | ||
566 | void TextEdit::fileNew() { | 548 | void TextEdit::fileNew() { |
567 | // if( !bFromDocView ) { | 549 | // if( !bFromDocView ) { |
568 | // saveAs(); | 550 | // saveAs(); |
569 | // } | 551 | // } |
570 | newFile(DocLnk()); | 552 | newFile(DocLnk()); |
571 | } | 553 | } |
572 | 554 | ||
573 | void TextEdit::fileOpen() { | 555 | void TextEdit::fileOpen() { |
574 | Config cfg("TextEdit"); | 556 | Config cfg("TextEdit"); |
575 | cfg. setGroup ( "View" ); | 557 | cfg. setGroup ( "View" ); |
576 | QMap<QString, QStringList> map; | 558 | QMap<QString, QStringList> map; |
577 | map.insert(tr("All"), QStringList() ); | 559 | map.insert(tr("All"), QStringList() ); |
578 | QStringList text; | 560 | QStringList text; |
579 | text << "text/*"; | 561 | text << "text/*"; |
580 | map.insert(tr("Text"), text ); | 562 | map.insert(tr("Text"), text ); |
581 | text << "*"; | 563 | text << "*"; |
582 | map.insert(tr("All"), text ); | 564 | map.insert(tr("All"), text ); |
583 | QString str = OFileDialog::getOpenFileName( 2, | 565 | QString str = OFileDialog::getOpenFileName( 2, |
584 | QString::null , | 566 | QString::null , |
585 | QString::null, map); | 567 | QString::null, map); |
586 | if( !str.isEmpty() && QFile(str).exists() && !QFileInfo(str).isDir() ) | 568 | if( !str.isEmpty() && QFile(str).exists() && !QFileInfo(str).isDir() ) |
587 | { | 569 | { |
588 | openFile( str ); | 570 | openFile( str ); |
589 | } | 571 | } |
590 | else | 572 | else |
591 | updateCaption(); | 573 | updateCaption(); |
592 | } | 574 | } |
593 | 575 | ||
594 | void TextEdit::doSearchBar() { | 576 | void TextEdit::doSearchBar() { |
595 | if(!useSearchBar) | 577 | if(!useSearchBar) |
596 | searchBar->hide(); | 578 | searchBar->hide(); |
597 | else | 579 | else |
598 | searchBar->show(); | 580 | searchBar->show(); |
599 | } | 581 | } |
600 | 582 | ||
601 | #if 0 | 583 | #if 0 |
602 | void TextEdit::slotFind() { | 584 | void TextEdit::slotFind() { |
603 | FindDialog frmFind( tr("Text Editor"), this ); | 585 | FindDialog frmFind( tr("Text Editor"), this ); |
604 | connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), | 586 | connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), |
605 | editor, SLOT(slotDoFind( const QString&,bool,bool))); | 587 | editor, SLOT(slotDoFind( const QString&,bool,bool))); |
606 | 588 | ||
607 | //case sensitive, backwards, [category] | 589 | //case sensitive, backwards, [category] |
608 | 590 | ||
609 | connect( editor, SIGNAL(notFound()), | 591 | connect( editor, SIGNAL(notFound()), |
610 | &frmFind, SLOT(slotNotFound()) ); | 592 | &frmFind, SLOT(slotNotFound()) ); |
611 | connect( editor, SIGNAL(searchWrapped()), | 593 | connect( editor, SIGNAL(searchWrapped()), |
612 | &frmFind, SLOT(slotWrapAround()) ); | 594 | &frmFind, SLOT(slotWrapAround()) ); |
613 | 595 | ||
614 | frmFind.exec(); | 596 | frmFind.exec(); |
615 | 597 | ||
616 | 598 | ||
617 | } | 599 | } |
618 | #endif | 600 | #endif |
619 | 601 | ||
620 | void TextEdit::fileRevert() { | 602 | void TextEdit::fileRevert() { |
621 | clear(); | 603 | clear(); |
622 | fileOpen(); | 604 | fileOpen(); |
623 | } | 605 | } |
624 | 606 | ||
625 | void TextEdit::editCut() { | 607 | void TextEdit::editCut() { |
626 | #ifndef QT_NO_CLIPBOARD | 608 | #ifndef QT_NO_CLIPBOARD |
627 | editor->cut(); | 609 | editor->cut(); |
628 | #endif | 610 | #endif |
629 | } | 611 | } |
630 | 612 | ||
631 | void TextEdit::editCopy() { | 613 | void TextEdit::editCopy() { |
632 | #ifndef QT_NO_CLIPBOARD | 614 | #ifndef QT_NO_CLIPBOARD |
633 | editor->copy(); | 615 | editor->copy(); |
634 | #endif | 616 | #endif |
635 | } | 617 | } |
636 | 618 | ||
637 | void TextEdit::editPaste() { | 619 | void TextEdit::editPaste() { |
638 | #ifndef QT_NO_CLIPBOARD | 620 | #ifndef QT_NO_CLIPBOARD |
639 | editor->paste(); | 621 | editor->paste(); |
640 | #endif | 622 | #endif |
641 | } | 623 | } |
642 | 624 | ||
643 | void TextEdit::editFind() { | 625 | void TextEdit::editFind() { |
644 | searchBar->show(); | 626 | searchBar->show(); |
645 | searchEdit->setFocus(); | 627 | searchEdit->setFocus(); |
646 | } | 628 | } |
647 | 629 | ||
648 | void TextEdit::findNext() { | 630 | void TextEdit::findNext() { |
649 | editor->find( searchEdit->text(), false, false ); | 631 | editor->find( searchEdit->text(), false, false ); |
650 | 632 | ||
651 | } | 633 | } |
652 | 634 | ||
653 | void TextEdit::findClose() { | 635 | void TextEdit::findClose() { |
654 | searchBar->hide(); | 636 | searchBar->hide(); |
655 | } | 637 | } |
656 | 638 | ||
657 | void TextEdit::search() { | 639 | void TextEdit::search() { |
658 | editor->find( searchEdit->text(), false, false ); | 640 | editor->find( searchEdit->text(), false, false ); |
659 | } | 641 | } |
660 | 642 | ||
661 | void TextEdit::newFile( const DocLnk &f ) { | 643 | void TextEdit::newFile( const DocLnk &f ) { |
662 | DocLnk nf = f; | 644 | DocLnk nf = f; |
663 | nf.setType("text/plain"); | 645 | nf.setType("text/plain"); |
664 | clear(); | 646 | clear(); |
665 | setWState (WState_Reserved1 ); | 647 | setWState (WState_Reserved1 ); |
666 | editor->setFocus(); | 648 | editor->setFocus(); |
667 | doc = new DocLnk(nf); | 649 | doc = new DocLnk(nf); |
668 | currentFileName = "Unnamed"; | 650 | currentFileName = "Unnamed"; |
669 | qDebug("newFile "+currentFileName); | 651 | qDebug("newFile "+currentFileName); |
670 | updateCaption( currentFileName); | 652 | updateCaption( currentFileName); |
671 | // editor->setEdited( false); | 653 | // editor->setEdited( false); |
672 | } | 654 | } |
673 | 655 | ||
674 | void TextEdit::openDotFile( const QString &f ) { | 656 | void TextEdit::openDotFile( const QString &f ) { |
675 | if(!currentFileName.isEmpty()) { | 657 | if(!currentFileName.isEmpty()) { |
676 | currentFileName=f; | 658 | currentFileName=f; |
677 | 659 | ||
678 | qDebug("openFile dotfile " + currentFileName); | 660 | qDebug("openFile dotfile " + currentFileName); |
679 | QString txt; | 661 | QString txt; |
680 | QFile file(f); | 662 | QFile file(f); |
681 | file.open(IO_ReadWrite); | 663 | file.open(IO_ReadWrite); |
682 | QTextStream t(&file); | 664 | QTextStream t(&file); |
683 | while ( !t.atEnd()) { | 665 | while ( !t.atEnd()) { |
684 | txt+=t.readLine()+"\n"; | 666 | txt+=t.readLine()+"\n"; |
685 | } | 667 | } |
686 | editor->setText(txt); | 668 | editor->setText(txt); |
687 | editor->setEdited( false); | 669 | editor->setEdited( false); |
688 | edited1=false; | 670 | edited1=false; |
689 | edited=false; | 671 | edited=false; |
690 | 672 | ||
691 | 673 | ||
692 | } | 674 | } |
693 | updateCaption( currentFileName); | 675 | updateCaption( currentFileName); |
694 | } | 676 | } |
695 | 677 | ||
696 | void TextEdit::openFile( const QString &f ) { | 678 | void TextEdit::openFile( const QString &f ) { |
697 | qDebug("filename is "+ f); | 679 | qDebug("filename is "+ f); |
698 | QString filer; | 680 | QString filer; |
699 | QFileInfo fi( f); | 681 | QFileInfo fi( f); |
700 | // bFromDocView = true; | 682 | // bFromDocView = true; |
701 | if(f.find(".desktop",0,true) != -1 && !openDesktop ) | 683 | if(f.find(".desktop",0,true) != -1 && !openDesktop ) |
702 | { | 684 | { |
703 | switch ( QMessageBox::warning(this,tr("Text Editor"),tr("Text Editor has detected<BR>you selected a <B>.desktop</B>file.<BR>Open<B>.desktop</B> file or <B>linked</B> file?"),tr(".desktop File"),tr("Linked Document"),0,1,1) ) | 685 | switch ( QMessageBox::warning(this,tr("Text Editor"),tr("Text Editor has detected<BR>you selected a <B>.desktop</B>file.<BR>Open<B>.desktop</B> file or <B>linked</B> file?"),tr(".desktop File"),tr("Linked Document"),0,1,1) ) |
704 | { | 686 | { |
705 | case 0: //desktop | 687 | case 0: //desktop |
706 | filer = f; | 688 | filer = f; |
707 | break; | 689 | break; |
708 | case 1: //linked | 690 | case 1: //linked |
709 | DocLnk sf(f); | 691 | DocLnk sf(f); |
710 | filer = sf.file(); | 692 | filer = sf.file(); |
711 | break; | 693 | break; |
712 | }; | 694 | }; |
713 | } | 695 | } |
714 | else if(fi.baseName().left(1) == "") | 696 | else if(fi.baseName().left(1) == "") |
715 | { | 697 | { |
716 | qDebug("opening dotfile"); | 698 | qDebug("opening dotfile"); |
717 | currentFileName=f; | 699 | currentFileName=f; |
718 | openDotFile(currentFileName); | 700 | openDotFile(currentFileName); |
719 | return; | 701 | return; |
720 | } | 702 | } |
721 | /* | 703 | /* |
722 | * The problem is a file where Config(f).isValid() and it does not | 704 | * The problem is a file where Config(f).isValid() and it does not |
723 | * end with .desktop will be treated as desktop file | 705 | * end with .desktop will be treated as desktop file |
724 | */ | 706 | */ |
725 | else if (f.find(".desktop",0,true) != -1 ) | 707 | else if (f.find(".desktop",0,true) != -1 ) |
726 | { | 708 | { |
727 | DocLnk sf(f); | 709 | DocLnk sf(f); |
728 | filer = sf.file(); | 710 | filer = sf.file(); |
729 | if(filer.right(1) == "/") | 711 | if(filer.right(1) == "/") |
730 | filer = f; | 712 | filer = f; |
731 | 713 | ||
732 | } | 714 | } |
733 | else | 715 | else |
734 | filer = f; | 716 | filer = f; |
735 | 717 | ||
736 | DocLnk nf; | 718 | DocLnk nf; |
737 | nf.setType("text/plain"); | 719 | nf.setType("text/plain"); |
738 | nf.setFile(filer); | 720 | nf.setFile(filer); |
739 | currentFileName=filer; | 721 | currentFileName=filer; |
740 | 722 | ||
741 | nf.setName(fi.baseName()); | 723 | nf.setName(fi.baseName()); |
742 | openFile(nf); | 724 | openFile(nf); |
743 | 725 | ||
744 | qDebug("openFile string "+currentFileName); | 726 | qDebug("openFile string "+currentFileName); |
745 | 727 | ||
746 | showEditTools(); | 728 | showEditTools(); |
747 | // Show filename in caption | 729 | // Show filename in caption |
748 | QString name = filer; | 730 | QString name = filer; |
749 | int sep = name.findRev( '/' ); | 731 | int sep = name.findRev( '/' ); |
750 | if ( sep > 0 ) | 732 | if ( sep > 0 ) |
751 | name = name.mid( sep+1 ); | 733 | name = name.mid( sep+1 ); |
752 | updateCaption( name ); | 734 | updateCaption( name ); |
753 | } | 735 | } |
754 | 736 | ||
755 | void TextEdit::openFile( const DocLnk &f ) { | 737 | void TextEdit::openFile( const DocLnk &f ) { |
756 | // clear(); | 738 | // clear(); |
757 | // bFromDocView = true; | 739 | // bFromDocView = true; |
758 | FileManager fm; | 740 | FileManager fm; |
759 | QString txt; | 741 | QString txt; |
760 | currentFileName=f.file(); | 742 | currentFileName=f.file(); |
761 | qDebug("openFile doclnk " + currentFileName); | 743 | qDebug("openFile doclnk " + currentFileName); |
762 | if ( !fm.loadFile( f, txt ) ) { | 744 | if ( !fm.loadFile( f, txt ) ) { |
763 | // ####### could be a new file | 745 | // ####### could be a new file |
764 | qDebug( "Cannot open file" ); | 746 | qDebug( "Cannot open file" ); |
765 | } | 747 | } |
766 | // fileNew(); | 748 | // fileNew(); |
767 | if ( doc ) | 749 | if ( doc ) |
768 | delete doc; | 750 | delete doc; |
769 | doc = new DocLnk(f); | 751 | doc = new DocLnk(f); |
770 | editor->setText(txt); | 752 | editor->setText(txt); |
771 | editor->setEdited( false); | 753 | editor->setEdited( false); |
772 | edited1=false; | 754 | edited1=false; |
773 | edited=false; | 755 | edited=false; |
774 | 756 | ||
775 | doc->setName(currentFileName); | 757 | doc->setName(currentFileName); |
776 | updateCaption(); | 758 | updateCaption(); |
777 | setTimer(); | 759 | setTimer(); |
778 | } | 760 | } |
779 | 761 | ||
780 | void TextEdit::showEditTools() { | 762 | void TextEdit::showEditTools() { |
781 | menu->show(); | 763 | menu->show(); |
782 | editBar->show(); | 764 | editBar->show(); |
783 | if(!useSearchBar) | 765 | if(!useSearchBar) |
784 | searchBar->hide(); | 766 | searchBar->hide(); |
785 | else | 767 | else |
786 | searchBar->show(); | 768 | searchBar->show(); |
787 | setWState (WState_Reserved1 ); | 769 | setWState (WState_Reserved1 ); |
788 | } | 770 | } |
789 | 771 | ||
790 | /*! | 772 | /*! |
791 | unprompted save */ | 773 | unprompted save */ |
792 | bool TextEdit::save() { | 774 | bool TextEdit::save() { |
793 | qDebug("saveAsFile " + currentFileName); | 775 | qDebug("saveAsFile " + currentFileName); |
794 | if(currentFileName.isEmpty()) { | 776 | if(currentFileName.isEmpty()) { |
795 | saveAs(); | 777 | saveAs(); |
796 | return false; | 778 | return false; |
797 | } | 779 | } |
798 | 780 | ||
799 | QString file = doc->file(); | 781 | QString file = doc->file(); |
800 | qDebug("saver file "+file); | 782 | qDebug("saver file "+file); |
801 | QString name= doc->name(); | 783 | QString name= doc->name(); |
802 | qDebug("File named "+name); | 784 | qDebug("File named "+name); |
803 | QString rt = editor->text(); | 785 | QString rt = editor->text(); |
804 | if( !rt.isEmpty() ) { | 786 | if( !rt.isEmpty() ) { |
805 | if(name.isEmpty()) { | 787 | if(name.isEmpty()) { |
806 | saveAs(); | 788 | saveAs(); |
807 | } else { | 789 | } else { |
808 | currentFileName= name ; | 790 | currentFileName= name ; |
809 | qDebug("saveFile "+currentFileName); | 791 | qDebug("saveFile "+currentFileName); |
810 | 792 | ||
811 | struct stat buf; | 793 | struct stat buf; |
812 | mode_t mode; | 794 | mode_t mode; |
813 | stat(file.latin1(), &buf); | 795 | stat(file.latin1(), &buf); |
814 | mode = buf.st_mode; | 796 | mode = buf.st_mode; |
815 | 797 | ||
816 | if(!fileIs) { | 798 | if(!fileIs) { |
817 | doc->setName( name); | 799 | doc->setName( name); |
818 | FileManager fm; | 800 | FileManager fm; |
819 | if ( !fm.saveFile( *doc, rt ) ) { | 801 | if ( !fm.saveFile( *doc, rt ) ) { |