-rw-r--r-- | noncore/apps/opie-console/MyPty.cpp | 2 | ||||
-rw-r--r-- | noncore/apps/opie-console/TEWidget.cpp | 27 | ||||
-rw-r--r-- | noncore/apps/opie-console/TEWidget.h | 20 | ||||
-rw-r--r-- | noncore/apps/opie-console/emulation_handler.cpp | 6 | ||||
-rw-r--r-- | noncore/apps/opie-console/emulation_handler.h | 4 | ||||
-rw-r--r-- | noncore/apps/opie-console/file_layer.cpp | 4 | ||||
-rw-r--r-- | noncore/apps/opie-console/io_bt.cpp | 7 | ||||
-rw-r--r-- | noncore/apps/opie-console/io_irda.cpp | 5 | ||||
-rw-r--r-- | noncore/apps/opie-console/mainwindow.cpp | 49 | ||||
-rw-r--r-- | noncore/apps/opie-console/mainwindow.h | 7 | ||||
-rw-r--r-- | noncore/apps/opie-console/opie-console.control | 2 | ||||
-rw-r--r-- | noncore/apps/opie-console/profilemanager.cpp | 4 | ||||
-rw-r--r-- | noncore/apps/opie-console/receive_layer.cpp | 3 | ||||
-rw-r--r-- | noncore/apps/opie-console/session.cpp | 7 | ||||
-rw-r--r-- | noncore/apps/opie-console/session.h | 7 |
15 files changed, 123 insertions, 31 deletions
diff --git a/noncore/apps/opie-console/MyPty.cpp b/noncore/apps/opie-console/MyPty.cpp index 16bb5ff..984e347 100644 --- a/noncore/apps/opie-console/MyPty.cpp +++ b/noncore/apps/opie-console/MyPty.cpp | |||
@@ -1,342 +1,342 @@ | |||
1 | /* -------------------------------------------------------------------------- */ | 1 | /* -------------------------------------------------------------------------- */ |
2 | /* */ | 2 | /* */ |
3 | /* [MyPty.C] Pseudo Terminal Device */ | 3 | /* [MyPty.C] Pseudo Terminal Device */ |
4 | /* */ | 4 | /* */ |
5 | /* -------------------------------------------------------------------------- */ | 5 | /* -------------------------------------------------------------------------- */ |
6 | /* */ | 6 | /* */ |
7 | /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ | 7 | /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ |
8 | /* */ | 8 | /* */ |
9 | /* This file is part of Konsole - an X terminal for KDE */ | 9 | /* This file is part of Konsole - an X terminal for KDE */ |
10 | /* -------------------------------------------------------------------------- */ | 10 | /* -------------------------------------------------------------------------- */ |
11 | /* */ | 11 | /* */ |
12 | /* Ported Konsole to Qt/Embedded */ | 12 | /* Ported Konsole to Qt/Embedded */ |
13 | /* */ | 13 | /* */ |
14 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ | 14 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ |
15 | /* */ | 15 | /* */ |
16 | /* -------------------------------------------------------------------------- */ | 16 | /* -------------------------------------------------------------------------- */ |
17 | 17 | ||
18 | /* If you're compiling konsole on non-Linux platforms and find | 18 | /* If you're compiling konsole on non-Linux platforms and find |
19 | problems that you can track down to this file, please have | 19 | problems that you can track down to this file, please have |
20 | a look into ../README.ports, too. | 20 | a look into ../README.ports, too. |
21 | */ | 21 | */ |
22 | 22 | ||
23 | /*! \file | 23 | /*! \file |
24 | */ | 24 | */ |
25 | 25 | ||
26 | /*! \class TEPty | 26 | /*! \class TEPty |
27 | 27 | ||
28 | \brief Ptys provide a pseudo terminal connection to a program. | 28 | \brief Ptys provide a pseudo terminal connection to a program. |
29 | 29 | ||
30 | Although closely related to pipes, these pseudo terminal connections have | 30 | Although closely related to pipes, these pseudo terminal connections have |
31 | some ability, that makes it nessesary to uses them. Most importent, they | 31 | some ability, that makes it nessesary to uses them. Most importent, they |
32 | know about changing screen sizes and UNIX job control. | 32 | know about changing screen sizes and UNIX job control. |
33 | 33 | ||
34 | Within the terminal emulation framework, this class represents the | 34 | Within the terminal emulation framework, this class represents the |
35 | host side of the terminal together with the connecting serial line. | 35 | host side of the terminal together with the connecting serial line. |
36 | 36 | ||
37 | One can create many instances of this class within a program. | 37 | One can create many instances of this class within a program. |
38 | As a side effect of using this class, a signal(2) handler is | 38 | As a side effect of using this class, a signal(2) handler is |
39 | installed on SIGCHLD. | 39 | installed on SIGCHLD. |
40 | 40 | ||
41 | \par FIXME | 41 | \par FIXME |
42 | 42 | ||
43 | [NOTE: much of the technical stuff below will be replaced by forkpty.] | 43 | [NOTE: much of the technical stuff below will be replaced by forkpty.] |
44 | 44 | ||
45 | publish the SIGCHLD signal if not related to an instance. | 45 | publish the SIGCHLD signal if not related to an instance. |
46 | 46 | ||
47 | clearify TEPty::done vs. TEPty::~TEPty semantics. | 47 | clearify TEPty::done vs. TEPty::~TEPty semantics. |
48 | check if pty is restartable via run after done. | 48 | check if pty is restartable via run after done. |
49 | 49 | ||
50 | \par Pseudo terminals | 50 | \par Pseudo terminals |
51 | 51 | ||
52 | Pseudo terminals are a unique feature of UNIX, and always come in form of | 52 | Pseudo terminals are a unique feature of UNIX, and always come in form of |
53 | pairs of devices (/dev/ptyXX and /dev/ttyXX), which are connected to each | 53 | pairs of devices (/dev/ptyXX and /dev/ttyXX), which are connected to each |
54 | other by the operating system. One may think of them as two serial devices | 54 | other by the operating system. One may think of them as two serial devices |
55 | linked by a null-modem cable. Being based on devices the number of | 55 | linked by a null-modem cable. Being based on devices the number of |
56 | simultanous instances of this class is (globally) limited by the number of | 56 | simultanous instances of this class is (globally) limited by the number of |
57 | those device pairs, which is 256. | 57 | those device pairs, which is 256. |
58 | 58 | ||
59 | Another technic are UNIX 98 PTY's. These are supported also, and prefered | 59 | Another technic are UNIX 98 PTY's. These are supported also, and prefered |
60 | over the (obsolete) predecessor. | 60 | over the (obsolete) predecessor. |
61 | 61 | ||
62 | There's a sinister ioctl(2), signal(2) and job control stuff | 62 | There's a sinister ioctl(2), signal(2) and job control stuff |
63 | nessesary to make everything work as it should. | 63 | nessesary to make everything work as it should. |
64 | */ | 64 | */ |
65 | 65 | ||
66 | 66 | ||
67 | #include <qapplication.h> | 67 | #include <qapplication.h> |
68 | #include <qsocketnotifier.h> | 68 | #include <qsocketnotifier.h> |
69 | #include <qstring.h> | 69 | #include <qstring.h> |
70 | 70 | ||
71 | #include <stdlib.h> | 71 | #include <stdlib.h> |
72 | #include <stdio.h> | 72 | #include <stdio.h> |
73 | #include <signal.h> | 73 | #include <signal.h> |
74 | #include <fcntl.h> | 74 | #include <fcntl.h> |
75 | #include <unistd.h> | 75 | #include <unistd.h> |
76 | #include <termios.h> | 76 | #include <termios.h> |
77 | #include <sys/types.h> | 77 | #include <sys/types.h> |
78 | #include <sys/ioctl.h> | 78 | #include <sys/ioctl.h> |
79 | #include <sys/wait.h> | 79 | #include <sys/wait.h> |
80 | 80 | ||
81 | #ifdef HAVE_OPENPTY | 81 | #ifdef HAVE_OPENPTY |
82 | #include <pty.h> | 82 | #include <pty.h> |
83 | #endif | 83 | #endif |
84 | 84 | ||
85 | #include "procctl.h" | 85 | #include "procctl.h" |
86 | #include "MyPty.h" | 86 | #include "MyPty.h" |
87 | 87 | ||
88 | 88 | ||
89 | #undef VERBOSE_DEBUG | 89 | #undef VERBOSE_DEBUG |
90 | 90 | ||
91 | 91 | ||
92 | /* -------------------------------------------------------------------------- */ | 92 | /* -------------------------------------------------------------------------- */ |
93 | 93 | ||
94 | /*! | 94 | /*! |
95 | Informs the client program about the | 95 | Informs the client program about the |
96 | actual size of the window. | 96 | actual size of the window. |
97 | */ | 97 | */ |
98 | 98 | ||
99 | void MyPty::setSize(int lines, int columns) | 99 | void MyPty::setSize(int lines, int columns) |
100 | { | 100 | { |
101 | qWarning("setting size"); | 101 | qWarning("setting size"); |
102 | struct winsize wsize; | 102 | struct winsize wsize; |
103 | wsize.ws_row = (unsigned short)lines; | 103 | wsize.ws_row = (unsigned short)lines; |
104 | wsize.ws_col = (unsigned short)columns; | 104 | wsize.ws_col = (unsigned short)columns; |
105 | if(m_fd < 0) return; | 105 | if(m_fd < 0) return; |
106 | ioctl(m_fd,TIOCSWINSZ,(char *)&wsize); | 106 | ioctl(m_fd,TIOCSWINSZ,(char *)&wsize); |
107 | } | 107 | } |
108 | 108 | ||
109 | 109 | ||
110 | void MyPty::donePty() | 110 | void MyPty::donePty() |
111 | { | 111 | { |
112 | // This is code from the Qt DumbTerminal example | 112 | // This is code from the Qt DumbTerminal example |
113 | int status = 0; | ||
114 | 113 | ||
115 | ::close(m_fd); | 114 | ::close(m_fd); |
116 | 115 | ||
117 | if (m_cpid) { | 116 | if (m_cpid) { |
118 | kill(m_cpid, SIGHUP); | 117 | kill(m_cpid, SIGHUP); |
119 | //waitpid(m_cpid, &status, 0); | 118 | //waitpid(m_cpid, &status, 0); |
120 | delete m_sn_e; | 119 | delete m_sn_e; |
121 | delete m_sn_r; | 120 | delete m_sn_r; |
122 | m_sn_e = 0l; | 121 | m_sn_e = 0l; |
123 | m_sn_r = 0l; | 122 | m_sn_r = 0l; |
124 | } | 123 | } |
125 | 124 | ||
126 | m_cpid = 0; | 125 | m_cpid = 0; |
127 | m_fd = -1; | 126 | m_fd = -1; |
128 | // emit done(status); | 127 | // emit done(status); |
129 | } | 128 | } |
130 | 129 | ||
131 | 130 | ||
132 | const char* MyPty::deviceName() | 131 | const char* MyPty::deviceName() |
133 | { | 132 | { |
134 | return m_ttynam; | 133 | return m_ttynam; |
135 | } | 134 | } |
136 | 135 | ||
137 | 136 | ||
138 | void MyPty::error() | 137 | void MyPty::error() |
139 | { | 138 | { |
140 | // This is code from the Qt DumbTerminal example | 139 | // This is code from the Qt DumbTerminal example |
141 | donePty(); | 140 | donePty(); |
142 | } | 141 | } |
143 | 142 | ||
144 | void MyPty::start() { | 143 | void MyPty::start() { |
145 | char* cmd = "/bin/sh"; | 144 | char* cmd = "/bin/sh"; |
146 | QStrList lis; | 145 | QStrList lis; |
147 | int r =run(cmd, lis, 0, 0); | 146 | int r =run(cmd, lis, 0, 0); |
148 | r = r; | 147 | r = r; |
149 | } | 148 | } |
150 | /*! | 149 | /*! |
151 | start the client program. | 150 | start the client program. |
152 | */ | 151 | */ |
153 | int MyPty::run(const char* cmd, QStrList &, const char*, int) | 152 | int MyPty::run(const char* cmd, QStrList &, const char*, int) |
154 | { | 153 | { |
155 | // This is code from the Qt DumbTerminal example | 154 | // This is code from the Qt DumbTerminal example |
156 | m_cpid = fork(); | 155 | m_cpid = fork(); |
157 | 156 | ||
158 | if ( !m_cpid ) { | 157 | if ( !m_cpid ) { |
159 | // child - exec shell on tty | 158 | // child - exec shell on tty |
160 | for (int sig = 1; sig < NSIG; sig++) signal(sig,SIG_DFL); | 159 | for (int sig = 1; sig < NSIG; sig++) signal(sig,SIG_DFL); |
161 | int ttyfd = ::open(m_ttynam, O_RDWR); | 160 | int ttyfd = ::open(m_ttynam, O_RDWR); |
162 | dup2(ttyfd, STDIN_FILENO); | 161 | dup2(ttyfd, STDIN_FILENO); |
163 | dup2(ttyfd, STDOUT_FILENO); | 162 | dup2(ttyfd, STDOUT_FILENO); |
164 | dup2(ttyfd, STDERR_FILENO); | 163 | dup2(ttyfd, STDERR_FILENO); |
165 | // should be done with tty, so close it | 164 | // should be done with tty, so close it |
166 | ::close(ttyfd); | 165 | ::close(ttyfd); |
167 | static struct termios ttmode; | 166 | static struct termios ttmode; |
168 | if ( setsid() < 0 ) | 167 | if ( setsid() < 0 ) |
169 | perror( "failed to set process group" ); | 168 | perror( "failed to set process group" ); |
170 | #if defined (TIOCSCTTY) | 169 | #if defined (TIOCSCTTY) |
171 | // grabbed from APUE by Stevens | 170 | // grabbed from APUE by Stevens |
172 | ioctl(STDIN_FILENO, TIOCSCTTY, 0); | 171 | ioctl(STDIN_FILENO, TIOCSCTTY, 0); |
173 | #endif | 172 | #endif |
174 | tcgetattr( STDIN_FILENO, &ttmode ); | 173 | tcgetattr( STDIN_FILENO, &ttmode ); |
175 | ttmode.c_cc[VINTR] = 3; | 174 | ttmode.c_cc[VINTR] = 3; |
176 | ttmode.c_cc[VERASE] = 8; | 175 | ttmode.c_cc[VERASE] = 8; |
177 | tcsetattr( STDIN_FILENO, TCSANOW, &ttmode ); | 176 | tcsetattr( STDIN_FILENO, TCSANOW, &ttmode ); |
178 | setenv("TERM",m_term,1); | 177 | setenv("TERM",m_term,1); |
179 | setenv("COLORTERM","0",1); | 178 | setenv("COLORTERM","0",1); |
180 | 179 | ||
181 | if (getuid() == 0) { | 180 | if (getuid() == 0) { |
182 | char msg[] = "WARNING: You are running this shell as root!\n"; | 181 | char msg[] = "WARNING: You are running this shell as root!\n"; |
183 | write(ttyfd, msg, sizeof(msg)); | 182 | write(ttyfd, msg, sizeof(msg)); |
184 | } | 183 | } |
185 | execl(cmd, cmd, 0); | 184 | execl(cmd, cmd, 0); |
186 | 185 | ||
187 | donePty(); | 186 | donePty(); |
188 | exit(-1); | 187 | exit(-1); |
189 | } | 188 | } |
190 | 189 | ||
191 | // parent - continue as a widget | 190 | // parent - continue as a widget |
192 | delete m_sn_r; | 191 | delete m_sn_r; |
193 | m_sn_r = new QSocketNotifier(m_fd,QSocketNotifier::Read,this); | 192 | m_sn_r = new QSocketNotifier(m_fd,QSocketNotifier::Read,this); |
194 | delete m_sn_e; | 193 | delete m_sn_e; |
195 | m_sn_e = new QSocketNotifier(m_fd,QSocketNotifier::Exception,this); | 194 | m_sn_e = new QSocketNotifier(m_fd,QSocketNotifier::Exception,this); |
196 | connect(m_sn_r,SIGNAL(activated(int)),this,SLOT(readPty())); | 195 | connect(m_sn_r,SIGNAL(activated(int)),this,SLOT(readPty())); |
197 | connect(m_sn_e,SIGNAL(activated(int)),this,SLOT(error())); | 196 | connect(m_sn_e,SIGNAL(activated(int)),this,SLOT(error())); |
198 | 197 | ||
199 | return 0; | 198 | return 0; |
200 | } | 199 | } |
201 | 200 | ||
202 | int MyPty::openPty() | 201 | int MyPty::openPty() |
203 | { | 202 | { |
204 | // This is code from the Qt DumbTerminal example | 203 | // This is code from the Qt DumbTerminal example |
205 | int ptyfd = -1; | 204 | int ptyfd = -1; |
206 | 205 | ||
207 | #ifdef HAVE_OPENPTY | 206 | #ifdef HAVE_OPENPTY |
208 | int ttyfd; | 207 | int ttyfd; |
209 | if ( openpty(&ptyfd,&ttyfd,ttynam,0,0) ) | 208 | if ( openpty(&ptyfd,&ttyfd,ttynam,0,0) ) |
210 | ptyfd = -1; | 209 | ptyfd = -1; |
211 | else | 210 | else |
212 | close(ttyfd); // we open the ttynam ourselves. | 211 | close(ttyfd); // we open the ttynam ourselves. |
213 | #else | 212 | #else |
214 | for (const char* c0 = "pqrstuvwxyzabcde"; ptyfd < 0 && *c0 != 0; c0++) { | 213 | for (const char* c0 = "pqrstuvwxyzabcde"; ptyfd < 0 && *c0 != 0; c0++) { |
215 | for (const char* c1 = "0123456789abcdef"; ptyfd < 0 && *c1 != 0; c1++) { | 214 | for (const char* c1 = "0123456789abcdef"; ptyfd < 0 && *c1 != 0; c1++) { |
216 | sprintf(m_ptynam,"/dev/pty%c%c",*c0,*c1); | 215 | sprintf(m_ptynam,"/dev/pty%c%c",*c0,*c1); |
217 | sprintf(m_ttynam,"/dev/tty%c%c",*c0,*c1); | 216 | sprintf(m_ttynam,"/dev/tty%c%c",*c0,*c1); |
218 | if ((ptyfd = ::open(m_ptynam,O_RDWR)) >= 0) { | 217 | if ((ptyfd = ::open(m_ptynam,O_RDWR)) >= 0) { |
219 | if (geteuid() != 0 && !access(m_ttynam,R_OK|W_OK) == 0) { | 218 | if (geteuid() != 0 && !access(m_ttynam,R_OK|W_OK) == 0) { |
220 | ::close(ptyfd); | 219 | ::close(ptyfd); |
221 | ptyfd = -1; | 220 | ptyfd = -1; |
222 | } | 221 | } |
223 | } | 222 | } |
224 | } | 223 | } |
225 | } | 224 | } |
226 | #endif | 225 | #endif |
227 | 226 | ||
228 | if ( ptyfd < 0 ) { | 227 | if ( ptyfd < 0 ) { |
229 | //qApp->exit(1); | 228 | //qApp->exit(1); |
230 | return -1; | 229 | return -1; |
231 | } | 230 | } |
232 | 231 | ||
233 | return ptyfd; | 232 | return ptyfd; |
234 | } | 233 | } |
235 | 234 | ||
236 | /*! | 235 | /*! |
237 | Create an instance. | 236 | Create an instance. |
238 | */ | 237 | */ |
239 | MyPty::MyPty(const Profile& prof) : m_cpid(0) | 238 | MyPty::MyPty(const Profile& prof) : m_cpid(0) |
240 | { | 239 | { |
241 | 240 | ||
242 | int term = prof.readNumEntry("Terminal", Profile::VT100 ); | 241 | int term = prof.readNumEntry("Terminal", Profile::VT100 ); |
243 | switch( term ) { | 242 | switch( term ) { |
244 | default: | 243 | default: |
245 | case Profile::VT100: | 244 | case Profile::VT100: |
246 | case Profile::VT102: | 245 | case Profile::VT102: |
247 | m_term = "vt100"; | 246 | m_term = "vt100"; |
248 | break; | 247 | break; |
249 | case Profile::Linux: | 248 | case Profile::Linux: |
250 | m_term = "linux"; | 249 | m_term = "linux"; |
251 | break; | 250 | break; |
252 | case Profile::XTerm: | 251 | case Profile::XTerm: |
253 | m_term = "xterm"; | 252 | m_term = "xterm"; |
254 | break; | 253 | break; |
255 | } | 254 | } |
256 | m_sn_e = 0l; | 255 | m_sn_e = 0l; |
257 | m_sn_r = 0l; | 256 | m_sn_r = 0l; |
258 | m_fd = openPty(); | 257 | m_fd = openPty(); |
259 | ProcCtl* ctl = ProcCtl::self(); | 258 | ProcCtl* ctl = ProcCtl::self(); |
259 | Q_UNUSED(ctl); | ||
260 | } | 260 | } |
261 | 261 | ||
262 | /*! | 262 | /*! |
263 | Destructor. | 263 | Destructor. |
264 | Note that the related client program is not killed | 264 | Note that the related client program is not killed |
265 | (yet) when a instance is deleted. | 265 | (yet) when a instance is deleted. |
266 | */ | 266 | */ |
267 | MyPty::~MyPty() | 267 | MyPty::~MyPty() |
268 | { | 268 | { |
269 | donePty(); | 269 | donePty(); |
270 | } | 270 | } |
271 | QString MyPty::identifier()const { | 271 | QString MyPty::identifier()const { |
272 | return QString::fromLatin1("term"); | 272 | return QString::fromLatin1("term"); |
273 | } | 273 | } |
274 | QString MyPty::name()const{ | 274 | QString MyPty::name()const{ |
275 | return identifier(); | 275 | return identifier(); |
276 | } | 276 | } |
277 | bool MyPty::open() { | 277 | bool MyPty::open() { |
278 | if (m_fd < 0) | 278 | if (m_fd < 0) |
279 | m_fd = openPty(); | 279 | m_fd = openPty(); |
280 | 280 | ||
281 | start(); | 281 | start(); |
282 | return true; | 282 | return true; |
283 | } | 283 | } |
284 | void MyPty::close() { | 284 | void MyPty::close() { |
285 | donePty(); | 285 | donePty(); |
286 | m_fd = openPty(); | 286 | m_fd = openPty(); |
287 | } | 287 | } |
288 | void MyPty::reload( const Profile& ) { | 288 | void MyPty::reload( const Profile& ) { |
289 | 289 | ||
290 | } | 290 | } |
291 | /*! sends len bytes through the line */ | 291 | /*! sends len bytes through the line */ |
292 | void MyPty::send(const QByteArray& ar) | 292 | void MyPty::send(const QByteArray& ar) |
293 | { | 293 | { |
294 | #ifdef VERBOSE_DEBUG | 294 | #ifdef VERBOSE_DEBUG |
295 | // verbose debug | 295 | // verbose debug |
296 | printf("sending bytes:\n"); | 296 | printf("sending bytes:\n"); |
297 | for (uint i = 0; i < ar.count(); i++) | 297 | for (uint i = 0; i < ar.count(); i++) |
298 | printf("%c", ar[i]); | 298 | printf("%c", ar[i]); |
299 | printf("\n"); | 299 | printf("\n"); |
300 | #endif | 300 | #endif |
301 | 301 | ||
302 | ::write(m_fd, ar.data(), ar.count()); | 302 | ::write(m_fd, ar.data(), ar.count()); |
303 | } | 303 | } |
304 | 304 | ||
305 | /*! indicates that a block of data is received */ | 305 | /*! indicates that a block of data is received */ |
306 | void MyPty::readPty() | 306 | void MyPty::readPty() |
307 | { | 307 | { |
308 | QByteArray buf(4096); | 308 | QByteArray buf(4096); |
309 | 309 | ||
310 | int len = ::read( m_fd, buf.data(), 4096 ); | 310 | int len = ::read( m_fd, buf.data(), 4096 ); |
311 | 311 | ||
312 | if (len == -1 || len == 0) { | 312 | if (len == -1 || len == 0) { |
313 | donePty(); | 313 | donePty(); |
314 | return; | 314 | return; |
315 | } | 315 | } |
316 | 316 | ||
317 | if (len < 0) | 317 | if (len < 0) |
318 | return; | 318 | return; |
319 | 319 | ||
320 | 320 | ||
321 | buf.resize(len); | 321 | buf.resize(len); |
322 | emit received(buf); | 322 | emit received(buf); |
323 | 323 | ||
324 | #ifdef VERBOSE_DEBUG | 324 | #ifdef VERBOSE_DEBUG |
325 | // verbose debug | 325 | // verbose debug |
326 | printf("read bytes:\n"); | 326 | printf("read bytes:\n"); |
327 | for (uint i = 0; i < buf.count(); i++) | 327 | for (uint i = 0; i < buf.count(); i++) |
328 | printf("%c", buf[i]); | 328 | printf("%c", buf[i]); |
329 | printf("\n"); | 329 | printf("\n"); |
330 | #endif | 330 | #endif |
331 | 331 | ||
332 | } | 332 | } |
333 | QBitArray MyPty::supports()const { | 333 | QBitArray MyPty::supports()const { |
334 | QBitArray ar(3); | 334 | QBitArray ar(3); |
335 | //autoconnect | 335 | //autoconnect |
336 | ar[0] = 1; | 336 | ar[0] = 1; |
337 | // | 337 | // |
338 | ar[1] = 0; | 338 | ar[1] = 0; |
339 | ar[2] = 0; | 339 | ar[2] = 0; |
340 | 340 | ||
341 | return ar; | 341 | return ar; |
342 | } | 342 | } |
diff --git a/noncore/apps/opie-console/TEWidget.cpp b/noncore/apps/opie-console/TEWidget.cpp index f3f462f..e4415dc 100644 --- a/noncore/apps/opie-console/TEWidget.cpp +++ b/noncore/apps/opie-console/TEWidget.cpp | |||
@@ -1,1278 +1,1303 @@ | |||
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 <qapplication.h> | 55 | #include <qapplication.h> |
56 | #include <qcursor.h> | 56 | #include <qcursor.h> |
57 | #include <qregexp.h> | 57 | #include <qregexp.h> |
58 | #include <qpainter.h> | 58 | #include <qpainter.h> |
59 | #include <qclipboard.h> | 59 | #include <qclipboard.h> |
60 | #include <qstyle.h> | 60 | #include <qstyle.h> |
61 | #include <qfile.h> | 61 | #include <qfile.h> |
62 | #include <qdragobject.h> | 62 | #include <qdragobject.h> |
63 | #include <qvbox.h> | 63 | #include <qvbox.h> |
64 | 64 | ||
65 | #include <stdio.h> | 65 | #include <stdio.h> |
66 | #include <stdlib.h> | 66 | #include <stdlib.h> |
67 | #include <unistd.h> | 67 | #include <unistd.h> |
68 | #include <ctype.h> | 68 | #include <ctype.h> |
69 | #include <sys/stat.h> | 69 | #include <sys/stat.h> |
70 | #include <sys/types.h> | 70 | #include <sys/types.h> |
71 | #include <signal.h> | 71 | #include <signal.h> |
72 | 72 | ||
73 | #include <assert.h> | 73 | #include <assert.h> |
74 | 74 | ||
75 | 75 | ||
76 | 76 | ||
77 | // #include "TEWidget.moc" | 77 | // #include "TEWidget.moc" |
78 | //#include <kapp.h> | 78 | //#include <kapp.h> |
79 | //#include <kcursor.h> | 79 | //#include <kcursor.h> |
80 | //#include <kurl.h> | 80 | //#include <kurl.h> |
81 | //#include <kdebug.h> | 81 | //#include <kdebug.h> |
82 | //#include <klocale.h> | 82 | //#include <klocale.h> |
83 | 83 | ||
84 | #define HERE printf("%s(%d): %s\n",__FILE__,__LINE__,__FUNCTION__) | 84 | #define HERE printf("%s(%d): %s\n",__FILE__,__LINE__,__FUNCTION__) |
85 | #define HCNT(Name) // { static int cnt = 1; printf("%s(%d): %s %d\n",__FILE__,__LINE__,Name,cnt++); } | 85 | #define HCNT(Name) // { static int cnt = 1; printf("%s(%d): %s %d\n",__FILE__,__LINE__,Name,cnt++); } |
86 | 86 | ||
87 | #define loc(X,Y) ((Y)*columns+(X)) | 87 | #define loc(X,Y) ((Y)*columns+(X)) |
88 | 88 | ||
89 | //FIXME: the rim should normally be 1, 0 only when running in full screen mode. | 89 | //FIXME: the rim should normally be 1, 0 only when running in full screen mode. |
90 | #define rimX 0 // left/right rim width | 90 | #define rimX 0 // left/right rim width |
91 | #define rimY 0 // top/bottom rim high | 91 | #define rimY 0 // top/bottom rim high |
92 | 92 | ||
93 | #define SCRWIDTH 16 // width of the scrollbar | 93 | #define SCRWIDTH 16 // width of the scrollbar |
94 | 94 | ||
95 | #define yMouseScroll 1 | 95 | #define yMouseScroll 1 |
96 | // scroll increment used when dragging selection at top/bottom of window. | 96 | // scroll increment used when dragging selection at top/bottom of window. |
97 | 97 | ||
98 | /* Button XPM */ | ||
99 | namespace { | ||
100 | static char * menu_xpm[] = { | ||
101 | "12 12 5 1", | ||
102 | " c None", | ||
103 | ".c #000000", | ||
104 | "+c #FFFDAD", | ||
105 | "@c #FFFF00", | ||
106 | "#c #E5E100", | ||
107 | " ", | ||
108 | " ", | ||
109 | " ......... ", | ||
110 | " .+++++++. ", | ||
111 | " .+@@@@#. ", | ||
112 | " .+@@@#. ", | ||
113 | " .+@@#. ", | ||
114 | " .+@#. ", | ||
115 | " .+#. ", | ||
116 | " .+. ", | ||
117 | " .. ", | ||
118 | " "}; | ||
119 | |||
120 | } | ||
121 | |||
122 | |||
98 | /* ------------------------------------------------------------------------- */ | 123 | /* ------------------------------------------------------------------------- */ |
99 | /* */ | 124 | /* */ |
100 | /* Colors */ | 125 | /* Colors */ |
101 | /* */ | 126 | /* */ |
102 | /* ------------------------------------------------------------------------- */ | 127 | /* ------------------------------------------------------------------------- */ |
103 | 128 | ||
104 | //FIXME: the default color table is in session.C now. | 129 | //FIXME: the default color table is in session.C now. |
105 | // We need a way to get rid of this one, here. | 130 | // We need a way to get rid of this one, here. |
106 | static const ColorEntry base_color_table[TABLE_COLORS] = | 131 | static const ColorEntry base_color_table[TABLE_COLORS] = |
107 | // The following are almost IBM standard color codes, with some slight | 132 | // The following are almost IBM standard color codes, with some slight |
108 | // gamma correction for the dim colors to compensate for bright X screens. | 133 | // gamma correction for the dim colors to compensate for bright X screens. |
109 | // It contains the 8 ansiterm/xterm colors in 2 intensities. | 134 | // It contains the 8 ansiterm/xterm colors in 2 intensities. |
110 | { | 135 | { |
111 | // Fixme: could add faint colors here, also. | 136 | // Fixme: could add faint colors here, also. |
112 | // normal | 137 | // normal |
113 | ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 1, 0 ), // Dfore, Dback | 138 | ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 1, 0 ), // Dfore, Dback |
114 | ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0x18), 0, 0 ), // Black, Red | 139 | ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0x18), 0, 0 ), // Black, Red |
115 | ColorEntry(QColor(0x18,0xB2,0x18), 0, 0 ), ColorEntry( QColor(0xB2,0x68,0x18), 0, 0 ), // Green, Yellow | 140 | ColorEntry(QColor(0x18,0xB2,0x18), 0, 0 ), ColorEntry( QColor(0xB2,0x68,0x18), 0, 0 ), // Green, Yellow |
116 | ColorEntry(QColor(0x18,0x18,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), // Blue, Magenta | 141 | ColorEntry(QColor(0x18,0x18,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), // Blue, Magenta |
117 | ColorEntry(QColor(0x18,0xB2,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 0, 0 ), // Cyan, White | 142 | ColorEntry(QColor(0x18,0xB2,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 0, 0 ), // Cyan, White |
118 | // intensiv | 143 | // intensiv |
119 | ColorEntry(QColor(0x00,0x00,0x00), 0, 1 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 1, 0 ), | 144 | ColorEntry(QColor(0x00,0x00,0x00), 0, 1 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 1, 0 ), |
120 | ColorEntry(QColor(0x68,0x68,0x68), 0, 0 ), ColorEntry( QColor(0xFF,0x54,0x54), 0, 0 ), | 145 | ColorEntry(QColor(0x68,0x68,0x68), 0, 0 ), ColorEntry( QColor(0xFF,0x54,0x54), 0, 0 ), |
121 | ColorEntry(QColor(0x54,0xFF,0x54), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0x54), 0, 0 ), | 146 | ColorEntry(QColor(0x54,0xFF,0x54), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0x54), 0, 0 ), |
122 | ColorEntry(QColor(0x54,0x54,0xFF), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), | 147 | ColorEntry(QColor(0x54,0x54,0xFF), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), |
123 | ColorEntry(QColor(0x54,0xFF,0xFF), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 0, 0 ) | 148 | ColorEntry(QColor(0x54,0xFF,0xFF), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 0, 0 ) |
124 | }; | 149 | }; |
125 | 150 | ||
126 | /* Note that we use ANSI color order (bgr), while IBMPC color order is (rgb) | 151 | /* Note that we use ANSI color order (bgr), while IBMPC color order is (rgb) |
127 | 152 | ||
128 | Code 0 1 2 3 4 5 6 7 | 153 | Code 0 1 2 3 4 5 6 7 |
129 | ----------- ------- ------- ------- ------- ------- ------- ------- ------- | 154 | ----------- ------- ------- ------- ------- ------- ------- ------- ------- |
130 | ANSI (bgr) Black Red Green Yellow Blue Magenta Cyan White | 155 | ANSI (bgr) Black Red Green Yellow Blue Magenta Cyan White |
131 | IBMPC (rgb) Black Blue Green Cyan Red Magenta Yellow White | 156 | IBMPC (rgb) Black Blue Green Cyan Red Magenta Yellow White |
132 | */ | 157 | */ |
133 | 158 | ||
134 | QColor TEWidget::getDefaultBackColor() | 159 | QColor TEWidget::getDefaultBackColor() |
135 | { | 160 | { |
136 | return color_table[DEFAULT_BACK_COLOR].color; | 161 | return color_table[DEFAULT_BACK_COLOR].color; |
137 | } | 162 | } |
138 | 163 | ||
139 | const ColorEntry* TEWidget::getColorTable() const | 164 | const ColorEntry* TEWidget::getColorTable() const |
140 | { | 165 | { |
141 | return color_table; | 166 | return color_table; |
142 | } | 167 | } |
143 | 168 | ||
144 | const ColorEntry* TEWidget::getdefaultColorTable() const | 169 | const ColorEntry* TEWidget::getdefaultColorTable() const |
145 | { | 170 | { |
146 | return base_color_table; | 171 | return base_color_table; |
147 | } | 172 | } |
148 | 173 | ||
149 | 174 | ||
150 | const QPixmap *TEWidget::backgroundPixmap() | 175 | const QPixmap *TEWidget::backgroundPixmap() |
151 | { | 176 | { |
152 | static QPixmap *bg = new QPixmap("~/qpim/main/pics/faded_bg.xpm"); | 177 | static QPixmap *bg = new QPixmap("~/qpim/main/pics/faded_bg.xpm"); |
153 | const QPixmap *pm = bg; | 178 | const QPixmap *pm = bg; |
154 | return pm; | 179 | return pm; |
155 | } | 180 | } |
156 | 181 | ||
157 | void TEWidget::setColorTable(const ColorEntry table[]) | 182 | void TEWidget::setColorTable(const ColorEntry table[]) |
158 | { | 183 | { |
159 | for (int i = 0; i < TABLE_COLORS; i++) color_table[i] = table[i]; | 184 | for (int i = 0; i < TABLE_COLORS; i++) color_table[i] = table[i]; |
160 | 185 | ||
161 | const QPixmap* pm = backgroundPixmap(); | 186 | const QPixmap* pm = backgroundPixmap(); |
162 | if (!pm) setBackgroundColor(color_table[DEFAULT_BACK_COLOR].color); | 187 | if (!pm) setBackgroundColor(color_table[DEFAULT_BACK_COLOR].color); |
163 | update(); | 188 | update(); |
164 | } | 189 | } |
165 | 190 | ||
166 | //FIXME: add backgroundPixmapChanged. | 191 | //FIXME: add backgroundPixmapChanged. |
167 | 192 | ||
168 | /* ------------------------------------------------------------------------- */ | 193 | /* ------------------------------------------------------------------------- */ |
169 | /* */ | 194 | /* */ |
170 | /* Font */ | 195 | /* Font */ |
171 | /* */ | 196 | /* */ |
172 | /* ------------------------------------------------------------------------- */ | 197 | /* ------------------------------------------------------------------------- */ |
173 | 198 | ||
174 | /* | 199 | /* |
175 | The VT100 has 32 special graphical characters. The usual vt100 extended | 200 | The VT100 has 32 special graphical characters. The usual vt100 extended |
176 | xterm fonts have these at 0x00..0x1f. | 201 | xterm fonts have these at 0x00..0x1f. |
177 | 202 | ||
178 | QT's iso mapping leaves 0x00..0x7f without any changes. But the graphicals | 203 | QT's iso mapping leaves 0x00..0x7f without any changes. But the graphicals |
179 | come in here as proper unicode characters. | 204 | come in here as proper unicode characters. |
180 | 205 | ||
181 | We treat non-iso10646 fonts as VT100 extended and do the requiered mapping | 206 | We treat non-iso10646 fonts as VT100 extended and do the requiered mapping |
182 | from unicode to 0x00..0x1f. The remaining translation is then left to the | 207 | from unicode to 0x00..0x1f. The remaining translation is then left to the |
183 | QCodec. | 208 | QCodec. |
184 | */ | 209 | */ |
185 | 210 | ||
186 | // assert for i in [0..31] : vt100extended(vt100_graphics[i]) == i. | 211 | // assert for i in [0..31] : vt100extended(vt100_graphics[i]) == i. |
187 | 212 | ||
188 | unsigned short vt100_graphics[32] = | 213 | unsigned short vt100_graphics[32] = |
189 | { // 0/8 1/9 2/10 3/11 4/12 5/13 6/14 7/15 | 214 | { // 0/8 1/9 2/10 3/11 4/12 5/13 6/14 7/15 |
190 | 0x0020, 0x25C6, 0x2592, 0x2409, 0x240c, 0x240d, 0x240a, 0x00b0, | 215 | 0x0020, 0x25C6, 0x2592, 0x2409, 0x240c, 0x240d, 0x240a, 0x00b0, |
191 | 0x00b1, 0x2424, 0x240b, 0x2518, 0x2510, 0x250c, 0x2514, 0x253c, | 216 | 0x00b1, 0x2424, 0x240b, 0x2518, 0x2510, 0x250c, 0x2514, 0x253c, |
192 | 0xF800, 0xF801, 0x2500, 0xF803, 0xF804, 0x251c, 0x2524, 0x2534, | 217 | 0xF800, 0xF801, 0x2500, 0xF803, 0xF804, 0x251c, 0x2524, 0x2534, |
193 | 0x252c, 0x2502, 0x2264, 0x2265, 0x03C0, 0x2260, 0x00A3, 0x00b7 | 218 | 0x252c, 0x2502, 0x2264, 0x2265, 0x03C0, 0x2260, 0x00A3, 0x00b7 |
194 | }; | 219 | }; |
195 | 220 | ||
196 | static QChar vt100extended(QChar c) | 221 | static QChar vt100extended(QChar c) |
197 | { | 222 | { |
198 | switch (c.unicode()) | 223 | switch (c.unicode()) |
199 | { | 224 | { |
200 | case 0x25c6 : return 1; | 225 | case 0x25c6 : return 1; |
201 | case 0x2592 : return 2; | 226 | case 0x2592 : return 2; |
202 | case 0x2409 : return 3; | 227 | case 0x2409 : return 3; |
203 | case 0x240c : return 4; | 228 | case 0x240c : return 4; |
204 | case 0x240d : return 5; | 229 | case 0x240d : return 5; |
205 | case 0x240a : return 6; | 230 | case 0x240a : return 6; |
206 | case 0x00b0 : return 7; | 231 | case 0x00b0 : return 7; |
207 | case 0x00b1 : return 8; | 232 | case 0x00b1 : return 8; |
208 | case 0x2424 : return 9; | 233 | case 0x2424 : return 9; |
209 | case 0x240b : return 10; | 234 | case 0x240b : return 10; |
210 | case 0x2518 : return 11; | 235 | case 0x2518 : return 11; |
211 | case 0x2510 : return 12; | 236 | case 0x2510 : return 12; |
212 | case 0x250c : return 13; | 237 | case 0x250c : return 13; |
213 | case 0x2514 : return 14; | 238 | case 0x2514 : return 14; |
214 | case 0x253c : return 15; | 239 | case 0x253c : return 15; |
215 | case 0xf800 : return 16; | 240 | case 0xf800 : return 16; |
216 | case 0xf801 : return 17; | 241 | case 0xf801 : return 17; |
217 | case 0x2500 : return 18; | 242 | case 0x2500 : return 18; |
218 | case 0xf803 : return 19; | 243 | case 0xf803 : return 19; |
219 | case 0xf804 : return 20; | 244 | case 0xf804 : return 20; |
220 | case 0x251c : return 21; | 245 | case 0x251c : return 21; |
221 | case 0x2524 : return 22; | 246 | case 0x2524 : return 22; |
222 | case 0x2534 : return 23; | 247 | case 0x2534 : return 23; |
223 | case 0x252c : return 24; | 248 | case 0x252c : return 24; |
224 | case 0x2502 : return 25; | 249 | case 0x2502 : return 25; |
225 | case 0x2264 : return 26; | 250 | case 0x2264 : return 26; |
226 | case 0x2265 : return 27; | 251 | case 0x2265 : return 27; |
227 | case 0x03c0 : return 28; | 252 | case 0x03c0 : return 28; |
228 | case 0x2260 : return 29; | 253 | case 0x2260 : return 29; |
229 | case 0x00a3 : return 30; | 254 | case 0x00a3 : return 30; |
230 | case 0x00b7 : return 31; | 255 | case 0x00b7 : return 31; |
231 | } | 256 | } |
232 | return c; | 257 | return c; |
233 | } | 258 | } |
234 | 259 | ||
235 | static QChar identicalMap(QChar c) | 260 | static QChar identicalMap(QChar c) |
236 | { | 261 | { |
237 | return c; | 262 | return c; |
238 | } | 263 | } |
239 | 264 | ||
240 | void TEWidget::fontChange(const QFont &) | 265 | void TEWidget::fontChange(const QFont &) |
241 | { | 266 | { |
242 | QFontMetrics fm(font()); | 267 | QFontMetrics fm(font()); |
243 | font_h = fm.height(); | 268 | font_h = fm.height(); |
244 | font_w = fm.maxWidth(); | 269 | font_w = fm.maxWidth(); |
245 | font_a = fm.ascent(); | 270 | font_a = fm.ascent(); |
246 | //printf("font_h: %d\n",font_h); | 271 | //printf("font_h: %d\n",font_h); |
247 | //printf("font_w: %d\n",font_w); | 272 | //printf("font_w: %d\n",font_w); |
248 | //printf("font_a: %d\n",font_a); | 273 | //printf("font_a: %d\n",font_a); |
249 | //printf("charset: %s\n",QFont::encodingName(font().charSet()).ascii()); | 274 | //printf("charset: %s\n",QFont::encodingName(font().charSet()).ascii()); |
250 | //printf("rawname: %s\n",font().rawName().ascii()); | 275 | //printf("rawname: %s\n",font().rawName().ascii()); |
251 | fontMap = | 276 | fontMap = |
252 | #if QT_VERSION < 300 | 277 | #if QT_VERSION < 300 |
253 | strcmp(QFont::encodingName(font().charSet()).ascii(),"iso10646") | 278 | strcmp(QFont::encodingName(font().charSet()).ascii(),"iso10646") |
254 | ? vt100extended | 279 | ? vt100extended |
255 | : | 280 | : |
256 | #endif | 281 | #endif |
257 | identicalMap; | 282 | identicalMap; |
258 | propagateSize(); | 283 | propagateSize(); |
259 | update(); | 284 | update(); |
260 | } | 285 | } |
261 | 286 | ||
262 | void TEWidget::setVTFont(const QFont& f) | 287 | void TEWidget::setVTFont(const QFont& f) |
263 | { | 288 | { |
264 | QFrame::setFont(f); | 289 | QFrame::setFont(f); |
265 | } | 290 | } |
266 | 291 | ||
267 | QFont TEWidget::getVTFont() { | 292 | QFont TEWidget::getVTFont() { |
268 | return font(); | 293 | return font(); |
269 | } | 294 | } |
270 | 295 | ||
271 | void TEWidget::setFont(const QFont &) | 296 | void TEWidget::setFont(const QFont &) |
272 | { | 297 | { |
273 | // ignore font change request if not coming from konsole itself | 298 | // ignore font change request if not coming from konsole itself |
274 | } | 299 | } |
275 | 300 | ||
276 | /* ------------------------------------------------------------------------- */ | 301 | /* ------------------------------------------------------------------------- */ |
277 | /* */ | 302 | /* */ |
278 | /* Constructor / Destructor */ | 303 | /* Constructor / Destructor */ |
279 | /* */ | 304 | /* */ |
280 | /* ----------------------------------------------------------------------- */ | 305 | /* ----------------------------------------------------------------------- */ |
281 | 306 | ||
282 | 307 | ||
283 | 308 | ||
284 | TEWidget::TEWidget(QWidget *parent, const char *name) : QFrame(parent,name) | 309 | TEWidget::TEWidget(QWidget *parent, const char *name) : QFrame(parent,name) |
285 | { | 310 | { |
286 | #ifndef QT_NO_CLIPBOARD | 311 | #ifndef QT_NO_CLIPBOARD |
287 | cb = QApplication::clipboard(); | 312 | cb = QApplication::clipboard(); |
288 | QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), | 313 | QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), |
289 | this, SLOT(onClearSelection()) ); | 314 | this, SLOT(onClearSelection()) ); |
290 | #endif | 315 | #endif |
291 | 316 | ||
292 | 317 | ||
293 | scrollbar = new QScrollBar( this ); | 318 | scrollbar = new QScrollBar( this ); |
294 | scrollbar->setCursor( arrowCursor ); | 319 | scrollbar->setCursor( arrowCursor ); |
295 | connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); | 320 | connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); |
296 | 321 | ||
297 | m_cornerButton = new QPushButton( this ); | 322 | m_cornerButton = new QPushButton( this ); |
298 | m_cornerButton->setPixmap( QPixmap( (const char**)menu_xpm ) ); | 323 | m_cornerButton->setPixmap( QPixmap( (const char**)menu_xpm ) ); |
299 | m_cornerButton->setMaximumSize( 14, 14 ); | 324 | m_cornerButton->setMaximumSize( 14, 14 ); |
300 | m_cornerButton->hide(); | 325 | m_cornerButton->hide(); |
301 | 326 | ||
302 | Config cfg("Konsole"); | 327 | Config cfg("Konsole"); |
303 | cfg.setGroup("ScrollBar"); | 328 | cfg.setGroup("ScrollBar"); |
304 | switch( cfg.readNumEntry("Position",2)){ | 329 | switch( cfg.readNumEntry("Position",2)){ |
305 | case 0: | 330 | case 0: |
306 | scrollLoc = SCRNONE; | 331 | scrollLoc = SCRNONE; |
307 | break; | 332 | break; |
308 | case 1: | 333 | case 1: |
309 | scrollLoc = SCRLEFT; | 334 | scrollLoc = SCRLEFT; |
310 | break; | 335 | break; |
311 | case 2: | 336 | case 2: |
312 | scrollLoc = SCRRIGHT; | 337 | scrollLoc = SCRRIGHT; |
313 | break; | 338 | break; |
314 | }; | 339 | }; |
315 | 340 | ||
316 | blinkT = new QTimer(this); | 341 | blinkT = new QTimer(this); |
317 | connect(blinkT, SIGNAL(timeout()), this, SLOT(blinkEvent())); | 342 | connect(blinkT, SIGNAL(timeout()), this, SLOT(blinkEvent())); |
318 | // blinking = FALSE; | 343 | // blinking = FALSE; |
319 | blinking = TRUE; | 344 | blinking = TRUE; |
320 | 345 | ||
321 | resizing = FALSE; | 346 | resizing = FALSE; |
322 | actSel = 0; | 347 | actSel = 0; |
323 | image = 0; | 348 | image = 0; |
324 | lines = 1; | 349 | lines = 1; |
325 | columns = 1; | 350 | columns = 1; |
326 | font_w = 1; | 351 | font_w = 1; |
327 | font_h = 1; | 352 | font_h = 1; |
328 | font_a = 1; | 353 | font_a = 1; |
329 | word_selection_mode = FALSE; | 354 | word_selection_mode = FALSE; |
330 | 355 | ||
331 | setMouseMarks(TRUE); | 356 | setMouseMarks(TRUE); |
332 | setVTFont( QFont("fixed") ); | 357 | setVTFont( QFont("fixed") ); |
333 | setColorTable(base_color_table); // init color table | 358 | setColorTable(base_color_table); // init color table |
334 | 359 | ||
335 | qApp->installEventFilter( this ); //FIXME: see below | 360 | qApp->installEventFilter( this ); //FIXME: see below |
336 | // KCursor::setAutoHideCursor( this, true ); | 361 | // KCursor::setAutoHideCursor( this, true ); |
337 | 362 | ||
338 | // Init DnD //////////////////////////////////////////////////////////////// | 363 | // Init DnD //////////////////////////////////////////////////////////////// |
339 | currentSession = NULL; | 364 | currentSession = NULL; |
340 | // setAcceptDrops(true); // attempt | 365 | // setAcceptDrops(true); // attempt |
341 | // m_drop = new QPopupMenu(this); | 366 | // m_drop = new QPopupMenu(this); |
342 | // m_drop->insertItem( QString("Paste"), 0); | 367 | // m_drop->insertItem( QString("Paste"), 0); |
343 | // m_drop->insertItem( QString("cd"), 1); | 368 | // m_drop->insertItem( QString("cd"), 1); |
344 | // connect(m_drop, SIGNAL(activated(int)), SLOT(drop_menu_activated(int))); | 369 | // connect(m_drop, SIGNAL(activated(int)), SLOT(drop_menu_activated(int))); |
345 | 370 | ||
346 | // we need focus so that the auto-hide cursor feature works | 371 | // we need focus so that the auto-hide cursor feature works |
347 | setFocus(); | 372 | setFocus(); |
348 | setFocusPolicy( WheelFocus ); | 373 | setFocusPolicy( WheelFocus ); |
349 | } | 374 | } |
350 | 375 | ||
351 | //FIXME: make proper destructor | 376 | //FIXME: make proper destructor |
352 | // Here's a start (David) | 377 | // Here's a start (David) |
353 | TEWidget::~TEWidget() | 378 | TEWidget::~TEWidget() |
354 | { | 379 | { |
355 | qApp->removeEventFilter( this ); | 380 | qApp->removeEventFilter( this ); |
356 | if (image) free(image); | 381 | if (image) free(image); |
357 | } | 382 | } |
358 | 383 | ||
359 | /* ------------------------------------------------------------------------- */ | 384 | /* ------------------------------------------------------------------------- */ |
360 | /* */ | 385 | /* */ |
361 | /* Display Operations */ | 386 | /* Display Operations */ |
362 | /* */ | 387 | /* */ |
363 | /* ------------------------------------------------------------------------- */ | 388 | /* ------------------------------------------------------------------------- */ |
364 | 389 | ||
365 | /*! | 390 | /*! |
366 | attributed string draw primitive | 391 | attributed string draw primitive |
367 | */ | 392 | */ |
368 | 393 | ||
369 | void TEWidget::drawAttrStr(QPainter &paint, QRect rect, | 394 | void TEWidget::drawAttrStr(QPainter &paint, QRect rect, |
370 | QString& str, ca attr, BOOL pm, BOOL clear) | 395 | QString& str, ca attr, BOOL pm, BOOL clear) |
371 | { | 396 | { |
372 | if (pm && color_table[attr.b].transparent) | 397 | if (pm && color_table[attr.b].transparent) |
373 | { | 398 | { |
374 | paint.setBackgroundMode( TransparentMode ); | 399 | paint.setBackgroundMode( TransparentMode ); |
375 | if (clear) erase(rect); | 400 | if (clear) erase(rect); |
376 | } | 401 | } |
377 | else | 402 | else |
378 | { | 403 | { |
379 | if (blinking) | 404 | if (blinking) |
380 | paint.fillRect(rect, color_table[attr.b].color); | 405 | paint.fillRect(rect, color_table[attr.b].color); |
381 | else | 406 | else |
382 | { | 407 | { |
383 | paint.setBackgroundMode( OpaqueMode ); | 408 | paint.setBackgroundMode( OpaqueMode ); |
384 | paint.setBackgroundColor( color_table[attr.b].color ); | 409 | paint.setBackgroundColor( color_table[attr.b].color ); |
385 | } | 410 | } |
386 | } | 411 | } |
387 | 412 | ||
388 | if (color_table[attr.f].bold) | 413 | if (color_table[attr.f].bold) |
389 | paint.setPen(QColor( 0x8F, 0x00, 0x00 )); | 414 | paint.setPen(QColor( 0x8F, 0x00, 0x00 )); |
390 | else | 415 | else |
391 | paint.setPen(color_table[attr.f].color); | 416 | paint.setPen(color_table[attr.f].color); |
392 | 417 | ||
393 | paint.drawText(rect.x(),rect.y()+font_a, str); | 418 | paint.drawText(rect.x(),rect.y()+font_a, str); |
394 | 419 | ||
395 | if (attr.r & RE_UNDERLINE) | 420 | if (attr.r & RE_UNDERLINE) |
396 | paint.drawLine(rect.left(), rect.y()+font_a+1, rect.right(),rect.y()+font_a+1 ); | 421 | paint.drawLine(rect.left(), rect.y()+font_a+1, rect.right(),rect.y()+font_a+1 ); |
397 | } | 422 | } |
398 | 423 | ||
399 | /*! | 424 | /*! |
400 | The image can only be set completely. | 425 | The image can only be set completely. |
401 | 426 | ||
402 | The size of the new image may or may not match the size of the widget. | 427 | The size of the new image may or may not match the size of the widget. |
403 | */ | 428 | */ |
404 | 429 | ||
405 | void TEWidget::setImage(const ca* const newimg, int lines, int columns) | 430 | void TEWidget::setImage(const ca* const newimg, int lines, int columns) |
406 | { int y,x,len; | 431 | { int y,x,len; |
407 | const QPixmap* pm = backgroundPixmap(); | 432 | const QPixmap* pm = backgroundPixmap(); |
408 | QPainter paint; | 433 | QPainter paint; |
409 | setUpdatesEnabled(FALSE); | 434 | setUpdatesEnabled(FALSE); |
410 | paint.begin( this ); | 435 | paint.begin( this ); |
411 | HCNT("setImage"); | 436 | HCNT("setImage"); |
412 | 437 | ||
413 | QPoint tL = contentsRect().topLeft(); | 438 | QPoint tL = contentsRect().topLeft(); |
414 | int tLx = tL.x(); | 439 | int tLx = tL.x(); |
415 | int tLy = tL.y(); | 440 | int tLy = tL.y(); |
416 | hasBlinker = FALSE; | 441 | hasBlinker = FALSE; |
417 | 442 | ||
418 | int cf = -1; // undefined | 443 | int cf = -1; // undefined |
419 | int cb = -1; // undefined | 444 | int cb = -1; // undefined |
420 | int cr = -1; // undefined | 445 | int cr = -1; // undefined |
421 | 446 | ||
422 | int lins = QMIN(this->lines, QMAX(0,lines )); | 447 | int lins = QMIN(this->lines, QMAX(0,lines )); |
423 | int cols = QMIN(this->columns,QMAX(0,columns)); | 448 | int cols = QMIN(this->columns,QMAX(0,columns)); |
424 | QChar *disstrU = new QChar[cols]; | 449 | QChar *disstrU = new QChar[cols]; |
425 | 450 | ||
426 | //{ static int cnt = 0; printf("setImage %d\n",cnt++); } | 451 | //{ static int cnt = 0; printf("setImage %d\n",cnt++); } |
427 | for (y = 0; y < lins; y++) | 452 | for (y = 0; y < lins; y++) |
428 | { | 453 | { |
429 | const ca* lcl = &image[y*this->columns]; | 454 | const ca* lcl = &image[y*this->columns]; |
430 | const ca* const ext = &newimg[y*columns]; | 455 | const ca* const ext = &newimg[y*columns]; |
431 | if (!resizing) // not while resizing, we're expecting a paintEvent | 456 | if (!resizing) // not while resizing, we're expecting a paintEvent |
432 | for (x = 0; x < cols; x++) | 457 | for (x = 0; x < cols; x++) |
433 | { | 458 | { |
434 | hasBlinker |= (ext[x].r & RE_BLINK); | 459 | hasBlinker |= (ext[x].r & RE_BLINK); |
435 | if (ext[x] != lcl[x]) | 460 | if (ext[x] != lcl[x]) |
436 | { | 461 | { |
437 | cr = ext[x].r; | 462 | cr = ext[x].r; |
438 | cb = ext[x].b; | 463 | cb = ext[x].b; |
439 | if (ext[x].f != cf) cf = ext[x].f; | 464 | if (ext[x].f != cf) cf = ext[x].f; |
440 | int lln = cols - x; | 465 | int lln = cols - x; |
441 | disstrU[0] = fontMap(ext[x+0].c); | 466 | disstrU[0] = fontMap(ext[x+0].c); |
442 | for (len = 1; len < lln; len++) | 467 | for (len = 1; len < lln; len++) |
443 | { | 468 | { |
444 | if (ext[x+len].f != cf || ext[x+len].b != cb || ext[x+len].r != cr || | 469 | if (ext[x+len].f != cf || ext[x+len].b != cb || ext[x+len].r != cr || |
445 | ext[x+len] == lcl[x+len] ) | 470 | ext[x+len] == lcl[x+len] ) |
446 | break; | 471 | break; |
447 | disstrU[len] = fontMap(ext[x+len].c); | 472 | disstrU[len] = fontMap(ext[x+len].c); |
448 | } | 473 | } |
449 | QString unistr(disstrU,len); | 474 | QString unistr(disstrU,len); |
450 | drawAttrStr(paint, | 475 | drawAttrStr(paint, |
451 | QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h), | 476 | QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h), |
452 | unistr, ext[x], pm != NULL, true); | 477 | unistr, ext[x], pm != NULL, true); |
453 | x += len - 1; | 478 | x += len - 1; |
454 | } | 479 | } |
455 | } | 480 | } |
456 | // finally, make `image' become `newimg'. | 481 | // finally, make `image' become `newimg'. |
457 | memcpy((void*)lcl,(const void*)ext,cols*sizeof(ca)); | 482 | memcpy((void*)lcl,(const void*)ext,cols*sizeof(ca)); |
458 | } | 483 | } |
459 | drawFrame( &paint ); | 484 | drawFrame( &paint ); |
460 | paint.end(); | 485 | paint.end(); |
461 | setUpdatesEnabled(TRUE); | 486 | setUpdatesEnabled(TRUE); |
462 | if ( hasBlinker && !blinkT->isActive()) blinkT->start(1000); // 1000 ms | 487 | if ( hasBlinker && !blinkT->isActive()) blinkT->start(1000); // 1000 ms |
463 | if (!hasBlinker && blinkT->isActive()) { blinkT->stop(); blinking = FALSE; } | 488 | if (!hasBlinker && blinkT->isActive()) { blinkT->stop(); blinking = FALSE; } |
464 | delete [] disstrU; | 489 | delete [] disstrU; |
465 | } | 490 | } |
466 | 491 | ||
467 | // paint Event //////////////////////////////////////////////////// | 492 | // paint Event //////////////////////////////////////////////////// |
468 | 493 | ||
469 | /*! | 494 | /*! |
470 | The difference of this routine vs. the `setImage' is, | 495 | The difference of this routine vs. the `setImage' is, |
471 | that the drawing does not include a difference analysis | 496 | that the drawing does not include a difference analysis |
472 | between the old and the new image. Instead, the internal | 497 | between the old and the new image. Instead, the internal |
473 | image is used and the painting bound by the PaintEvent box. | 498 | image is used and the painting bound by the PaintEvent box. |
474 | */ | 499 | */ |
475 | 500 | ||
476 | void TEWidget::paintEvent( QPaintEvent* pe ) | 501 | void TEWidget::paintEvent( QPaintEvent* pe ) |
477 | { | 502 | { |
478 | 503 | ||
479 | //{ static int cnt = 0; printf("paint %d\n",cnt++); } | 504 | //{ static int cnt = 0; printf("paint %d\n",cnt++); } |
480 | const QPixmap* pm = backgroundPixmap(); | 505 | const QPixmap* pm = backgroundPixmap(); |
481 | QPainter paint; | 506 | QPainter paint; |
482 | setUpdatesEnabled(FALSE); | 507 | setUpdatesEnabled(FALSE); |
483 | paint.begin( this ); | 508 | paint.begin( this ); |
484 | paint.setBackgroundMode( TransparentMode ); | 509 | paint.setBackgroundMode( TransparentMode ); |
485 | HCNT("paintEvent"); | 510 | HCNT("paintEvent"); |
486 | 511 | ||
487 | // Note that the actual widget size can be slightly larger | 512 | // Note that the actual widget size can be slightly larger |
488 | // that the image (the size is truncated towards the smaller | 513 | // that the image (the size is truncated towards the smaller |
489 | // number of characters in `resizeEvent'. The paint rectangle | 514 | // number of characters in `resizeEvent'. The paint rectangle |
490 | // can thus be larger than the image, but less then the size | 515 | // can thus be larger than the image, but less then the size |
491 | // of one character. | 516 | // of one character. |
492 | 517 | ||
493 | QRect rect = pe->rect().intersect(contentsRect()); | 518 | QRect rect = pe->rect().intersect(contentsRect()); |
494 | 519 | ||
495 | QPoint tL = contentsRect().topLeft(); | 520 | QPoint tL = contentsRect().topLeft(); |
496 | int tLx = tL.x(); | 521 | int tLx = tL.x(); |
497 | int tLy = tL.y(); | 522 | int tLy = tL.y(); |
498 | 523 | ||
499 | int lux = QMIN(columns-1, QMAX(0,(rect.left() - tLx - blX ) / font_w)); | 524 | int lux = QMIN(columns-1, QMAX(0,(rect.left() - tLx - blX ) / font_w)); |
500 | int luy = QMIN(lines-1, QMAX(0,(rect.top() - tLy - bY ) / font_h)); | 525 | int luy = QMIN(lines-1, QMAX(0,(rect.top() - tLy - bY ) / font_h)); |
501 | int rlx = QMIN(columns-1, QMAX(0,(rect.right() - tLx - blX ) / font_w)); | 526 | int rlx = QMIN(columns-1, QMAX(0,(rect.right() - tLx - blX ) / font_w)); |
502 | int rly = QMIN(lines-1, QMAX(0,(rect.bottom() - tLy - bY ) / font_h)); | 527 | int rly = QMIN(lines-1, QMAX(0,(rect.bottom() - tLy - bY ) / font_h)); |
503 | 528 | ||
504 | /* | 529 | /* |
505 | printf("paintEvent: %d..%d, %d..%d (%d..%d, %d..%d)\n",lux,rlx,luy,rly, | 530 | printf("paintEvent: %d..%d, %d..%d (%d..%d, %d..%d)\n",lux,rlx,luy,rly, |
506 | rect.left(), rect.right(), rect.top(), rect.bottom()); | 531 | rect.left(), rect.right(), rect.top(), rect.bottom()); |
507 | */ | 532 | */ |
508 | 533 | ||
509 | // if (pm != NULL && color_table[image->b].transparent) | 534 | // if (pm != NULL && color_table[image->b].transparent) |
510 | // erase(rect); | 535 | // erase(rect); |
511 | // BL: I have no idea why we need this, and it breaks the refresh. | 536 | // BL: I have no idea why we need this, and it breaks the refresh. |
512 | 537 | ||
513 | QChar *disstrU = new QChar[columns]; | 538 | QChar *disstrU = new QChar[columns]; |
514 | for (int y = luy; y <= rly; y++) | 539 | for (int y = luy; y <= rly; y++) |
515 | for (int x = lux; x <= rlx; x++) | 540 | for (int x = lux; x <= rlx; x++) |
516 | { | 541 | { |
517 | int len = 1; | 542 | int len = 1; |
518 | disstrU[0] = fontMap(image[loc(x,y)].c); | 543 | disstrU[0] = fontMap(image[loc(x,y)].c); |
519 | int cf = image[loc(x,y)].f; | 544 | int cf = image[loc(x,y)].f; |
520 | int cb = image[loc(x,y)].b; | 545 | int cb = image[loc(x,y)].b; |
521 | int cr = image[loc(x,y)].r; | 546 | int cr = image[loc(x,y)].r; |
522 | while (x+len <= rlx && | 547 | while (x+len <= rlx && |
523 | image[loc(x+len,y)].f == cf && | 548 | image[loc(x+len,y)].f == cf && |
524 | image[loc(x+len,y)].b == cb && | 549 | image[loc(x+len,y)].b == cb && |
525 | image[loc(x+len,y)].r == cr ) | 550 | image[loc(x+len,y)].r == cr ) |
526 | { | 551 | { |
527 | disstrU[len] = fontMap(image[loc(x+len,y)].c); | 552 | disstrU[len] = fontMap(image[loc(x+len,y)].c); |
528 | len += 1; | 553 | len += 1; |
529 | } | 554 | } |
530 | QString unistr(disstrU,len); | 555 | QString unistr(disstrU,len); |
531 | drawAttrStr(paint, | 556 | drawAttrStr(paint, |
532 | QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h), | 557 | QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h), |
533 | unistr, image[loc(x,y)], pm != NULL, false); | 558 | unistr, image[loc(x,y)], pm != NULL, false); |
534 | x += len - 1; | 559 | x += len - 1; |
535 | } | 560 | } |
536 | delete [] disstrU; | 561 | delete [] disstrU; |
537 | drawFrame( &paint ); | 562 | drawFrame( &paint ); |
538 | paint.end(); | 563 | paint.end(); |
539 | setUpdatesEnabled(TRUE); | 564 | setUpdatesEnabled(TRUE); |
540 | } | 565 | } |
541 | 566 | ||
542 | void TEWidget::blinkEvent() | 567 | void TEWidget::blinkEvent() |
543 | { | 568 | { |
544 | blinking = !blinking; | 569 | blinking = !blinking; |
545 | repaint(FALSE); | 570 | repaint(FALSE); |
546 | } | 571 | } |
547 | 572 | ||
548 | /* ------------------------------------------------------------------------- */ | 573 | /* ------------------------------------------------------------------------- */ |
549 | /* */ | 574 | /* */ |
550 | /* Resizing */ | 575 | /* Resizing */ |
551 | /* */ | 576 | /* */ |
552 | /* ------------------------------------------------------------------------- */ | 577 | /* ------------------------------------------------------------------------- */ |
553 | 578 | ||
554 | void TEWidget::resizeEvent(QResizeEvent* ev) | 579 | void TEWidget::resizeEvent(QResizeEvent* ev) |
555 | { | 580 | { |
556 | // printf("resize: %d,%d\n",ev->size().width(),ev->size().height()); | 581 | // printf("resize: %d,%d\n",ev->size().width(),ev->size().height()); |
557 | //printf("approx: %d,%d\n",ev->size().width()/font_w,ev->size().height()/font_h); | 582 | //printf("approx: %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); | 583 | //printf("leaves: %d,%d\n",ev->size().width()%font_w,ev->size().height()%font_h); |
559 | //printf("curren: %d,%d\n",width(),height()); | 584 | //printf("curren: %d,%d\n",width(),height()); |
560 | HCNT("resizeEvent"); | 585 | HCNT("resizeEvent"); |
561 | 586 | ||
562 | // see comment in `paintEvent' concerning the rounding. | 587 | // see comment in `paintEvent' concerning the rounding. |
563 | //FIXME: could make a routine here; check width(),height() | 588 | //FIXME: could make a routine here; check width(),height() |
564 | assert(ev->size().width() == width()); | 589 | assert(ev->size().width() == width()); |
565 | assert(ev->size().height() == height()); | 590 | assert(ev->size().height() == height()); |
566 | 591 | ||
567 | propagateSize(); | 592 | propagateSize(); |
568 | } | 593 | } |
569 | 594 | ||
570 | void TEWidget::propagateSize() | 595 | void TEWidget::propagateSize() |
571 | { | 596 | { |
572 | ca* oldimg = image; | 597 | ca* oldimg = image; |
573 | int oldlin = lines; | 598 | int oldlin = lines; |
574 | int oldcol = columns; | 599 | int oldcol = columns; |
575 | makeImage(); | 600 | makeImage(); |
576 | // we copy the old image to reduce flicker | 601 | // we copy the old image to reduce flicker |
577 | int lins = QMIN(oldlin,lines); | 602 | int lins = QMIN(oldlin,lines); |
578 | int cols = QMIN(oldcol,columns); | 603 | int cols = QMIN(oldcol,columns); |
579 | if (oldimg) | 604 | if (oldimg) |
580 | { | 605 | { |
581 | for (int lin = 0; lin < lins; lin++) | 606 | for (int lin = 0; lin < lins; lin++) |
582 | memcpy((void*)&image[columns*lin], | 607 | memcpy((void*)&image[columns*lin], |
583 | (void*)&oldimg[oldcol*lin],cols*sizeof(ca)); | 608 | (void*)&oldimg[oldcol*lin],cols*sizeof(ca)); |
584 | free(oldimg); //FIXME: try new,delete | 609 | free(oldimg); //FIXME: try new,delete |
585 | } | 610 | } |
586 | else | 611 | else |
587 | clearImage(); | 612 | clearImage(); |
588 | 613 | ||
589 | //NOTE: control flows from the back through the chest right into the eye. | 614 | //NOTE: control flows from the back through the chest right into the eye. |
590 | // `emu' will call back via `setImage'. | 615 | // `emu' will call back via `setImage'. |
591 | 616 | ||
592 | resizing = TRUE; | 617 | resizing = TRUE; |
593 | emit changedImageSizeSignal(lines, columns); // expose resizeEvent | 618 | emit changedImageSizeSignal(lines, columns); // expose resizeEvent |
594 | resizing = FALSE; | 619 | resizing = FALSE; |
595 | } | 620 | } |
596 | 621 | ||
597 | /* ------------------------------------------------------------------------- */ | 622 | /* ------------------------------------------------------------------------- */ |
598 | /* */ | 623 | /* */ |
599 | /* Scrollbar */ | 624 | /* Scrollbar */ |
600 | /* */ | 625 | /* */ |
601 | /* ------------------------------------------------------------------------- */ | 626 | /* ------------------------------------------------------------------------- */ |
602 | 627 | ||
603 | void TEWidget::scrollChanged(int) | 628 | void TEWidget::scrollChanged(int) |
604 | { | 629 | { |
605 | emit changedHistoryCursor(scrollbar->value()); //expose | 630 | emit changedHistoryCursor(scrollbar->value()); //expose |
606 | } | 631 | } |
607 | 632 | ||
608 | void TEWidget::setScroll(int cursor, int slines) | 633 | void TEWidget::setScroll(int cursor, int slines) |
609 | { | 634 | { |
610 | disconnect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); | 635 | disconnect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); |
611 | scrollbar->setRange(0,slines); | 636 | scrollbar->setRange(0,slines); |
612 | scrollbar->setSteps(1,lines); | 637 | scrollbar->setSteps(1,lines); |
613 | scrollbar->setValue(cursor); | 638 | scrollbar->setValue(cursor); |
614 | connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); | 639 | connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); |
615 | } | 640 | } |
616 | 641 | ||
617 | void TEWidget::setScrollbarLocation(int loc) | 642 | void TEWidget::setScrollbarLocation(int loc) |
618 | { | 643 | { |
619 | if (scrollLoc == loc) return; // quickly | 644 | if (scrollLoc == loc) return; // quickly |
620 | scrollLoc = loc; | 645 | scrollLoc = loc; |
621 | propagateSize(); | 646 | propagateSize(); |
622 | update(); | 647 | update(); |
623 | } | 648 | } |
624 | 649 | ||
625 | /* ------------------------------------------------------------------------- */ | 650 | /* ------------------------------------------------------------------------- */ |
626 | /* */ | 651 | /* */ |
627 | /* Mouse */ | 652 | /* Mouse */ |
628 | /* */ | 653 | /* */ |
629 | /* ------------------------------------------------------------------------- */ | 654 | /* ------------------------------------------------------------------------- */ |
630 | 655 | ||
631 | /*! | 656 | /*! |
632 | Three different operations can be performed using the mouse, and the | 657 | Three different operations can be performed using the mouse, and the |
633 | routines in this section serve all of them: | 658 | routines in this section serve all of them: |
634 | 659 | ||
635 | 1) The press/release events are exposed to the application | 660 | 1) The press/release events are exposed to the application |
636 | 2) Marking (press and move left button) and Pasting (press middle button) | 661 | 2) Marking (press and move left button) and Pasting (press middle button) |
637 | 3) The right mouse button is used from the configuration menu | 662 | 3) The right mouse button is used from the configuration menu |
638 | 663 | ||
639 | NOTE: During the marking process we attempt to keep the cursor within | 664 | NOTE: During the marking process we attempt to keep the cursor within |
640 | the bounds of the text as being displayed by setting the mouse position | 665 | the bounds of the text as being displayed by setting the mouse position |
641 | whenever the mouse has left the text area. | 666 | whenever the mouse has left the text area. |
642 | 667 | ||
643 | Two reasons to do so: | 668 | Two reasons to do so: |
644 | 1) QT does not allow the `grabMouse' to confine-to the TEWidget. | 669 | 1) QT does not allow the `grabMouse' to confine-to the TEWidget. |
645 | Thus a `XGrapPointer' would have to be used instead. | 670 | Thus a `XGrapPointer' would have to be used instead. |
646 | 2) Even if so, this would not help too much, since the text area | 671 | 2) Even if so, this would not help too much, since the text area |
647 | of the TEWidget is normally not identical with it's bounds. | 672 | of the TEWidget is normally not identical with it's bounds. |
648 | 673 | ||
649 | The disadvantage of the current handling is, that the mouse can visibly | 674 | The disadvantage of the current handling is, that the mouse can visibly |
650 | leave the bounds of the widget and is then moved back. Because of the | 675 | leave the bounds of the widget and is then moved back. Because of the |
651 | current construction, and the reasons mentioned above, we cannot do better | 676 | current construction, and the reasons mentioned above, we cannot do better |
652 | without changing the overall construction. | 677 | without changing the overall construction. |
653 | */ | 678 | */ |
654 | 679 | ||
655 | /*! | 680 | /*! |
656 | */ | 681 | */ |
657 | 682 | ||
658 | void TEWidget::mousePressEvent(QMouseEvent* ev) | 683 | void TEWidget::mousePressEvent(QMouseEvent* ev) |
659 | { | 684 | { |
660 | //printf("press [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button()); | 685 | //printf("press [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button()); |
661 | if ( !contentsRect().contains(ev->pos()) ) return; | 686 | if ( !contentsRect().contains(ev->pos()) ) return; |
662 | QPoint tL = contentsRect().topLeft(); | 687 | QPoint tL = contentsRect().topLeft(); |
663 | int tLx = tL.x(); | 688 | int tLx = tL.x(); |
664 | int tLy = tL.y(); | 689 | int tLy = tL.y(); |
665 | 690 | ||
666 | word_selection_mode = FALSE; | 691 | word_selection_mode = FALSE; |
667 | 692 | ||
668 | //printf("press top left [%d,%d] by=%d\n",tLx,tLy, bY); | 693 | //printf("press top left [%d,%d] by=%d\n",tLx,tLy, bY); |
669 | if ( ev->button() == LeftButton) | 694 | if ( ev->button() == LeftButton) |
670 | { | 695 | { |
671 | QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); | 696 | QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); |
672 | 697 | ||
673 | if ( ev->state() & ControlButton ) preserve_line_breaks = FALSE ; | 698 | if ( ev->state() & ControlButton ) preserve_line_breaks = FALSE ; |
674 | 699 | ||
675 | if (mouse_marks || (ev->state() & ShiftButton)) | 700 | if (mouse_marks || (ev->state() & ShiftButton)) |
676 | { | 701 | { |
677 | emit clearSelectionSignal(); | 702 | emit clearSelectionSignal(); |
678 | iPntSel = pntSel = pos; | 703 | iPntSel = pntSel = pos; |
679 | actSel = 1; // left mouse button pressed but nothing selected yet. | 704 | actSel = 1; // left mouse button pressed but nothing selected yet. |
680 | grabMouse( /*crossCursor*/ ); // handle with care! | 705 | grabMouse( /*crossCursor*/ ); // handle with care! |
681 | } | 706 | } |
682 | else | 707 | else |
683 | { | 708 | { |
684 | emit mouseSignal( 0, pos.x() + 1, pos.y() + 1 ); // left button | 709 | emit mouseSignal( 0, pos.x() + 1, pos.y() + 1 ); // left button |
685 | } | 710 | } |
686 | } | 711 | } |
687 | if ( ev->button() == MidButton ) | 712 | if ( ev->button() == MidButton ) |
688 | { | 713 | { |
689 | emitSelection(); | 714 | emitSelection(); |
690 | } | 715 | } |
691 | if ( ev->button() == RightButton ) // Configure | 716 | if ( ev->button() == RightButton ) // Configure |
692 | { | 717 | { |
693 | emit configureRequest( this, ev->state()&(ShiftButton|ControlButton), ev->x(), ev->y() ); | 718 | emit configureRequest( this, ev->state()&(ShiftButton|ControlButton), ev->x(), ev->y() ); |
694 | } | 719 | } |
695 | } | 720 | } |
696 | 721 | ||
697 | void TEWidget::mouseMoveEvent(QMouseEvent* ev) | 722 | void TEWidget::mouseMoveEvent(QMouseEvent* ev) |
698 | { | 723 | { |
699 | // for auto-hiding the cursor, we need mouseTracking | 724 | // for auto-hiding the cursor, we need mouseTracking |
700 | if (ev->state() == NoButton ) return; | 725 | if (ev->state() == NoButton ) return; |
701 | 726 | ||
702 | if (actSel == 0) return; | 727 | if (actSel == 0) return; |
703 | 728 | ||
704 | // don't extend selection while pasting | 729 | // don't extend selection while pasting |
705 | if (ev->state() & MidButton) return; | 730 | if (ev->state() & MidButton) return; |
706 | 731 | ||
707 | //if ( !contentsRect().contains(ev->pos()) ) return; | 732 | //if ( !contentsRect().contains(ev->pos()) ) return; |
708 | QPoint tL = contentsRect().topLeft(); | 733 | QPoint tL = contentsRect().topLeft(); |
709 | int tLx = tL.x(); | 734 | int tLx = tL.x(); |
710 | int tLy = tL.y(); | 735 | int tLy = tL.y(); |
711 | int scroll = scrollbar->value(); | 736 | int scroll = scrollbar->value(); |
712 | 737 | ||
713 | // we're in the process of moving the mouse with the left button pressed | 738 | // we're in the process of moving the mouse with the left button pressed |
714 | // the mouse cursor will kept catched within the bounds of the text in | 739 | // the mouse cursor will kept catched within the bounds of the text in |
715 | // this widget. | 740 | // this widget. |
716 | 741 | ||
717 | // Adjust position within text area bounds. See FIXME above. | 742 | // Adjust position within text area bounds. See FIXME above. |
718 | QPoint pos = ev->pos(); | 743 | QPoint pos = ev->pos(); |
719 | if ( pos.x() < tLx+blX ) pos.setX( tLx+blX ); | 744 | if ( pos.x() < tLx+blX ) pos.setX( tLx+blX ); |
720 | if ( pos.x() > tLx+blX+columns*font_w-1 ) pos.setX( tLx+blX+columns*font_w ); | 745 | if ( pos.x() > tLx+blX+columns*font_w-1 ) pos.setX( tLx+blX+columns*font_w ); |
721 | if ( pos.y() < tLy+bY ) pos.setY( tLy+bY ); | 746 | if ( pos.y() < tLy+bY ) pos.setY( tLy+bY ); |
722 | if ( pos.y() > tLy+bY+lines*font_h-1 ) pos.setY( tLy+bY+lines*font_h-1 ); | 747 | if ( pos.y() > tLy+bY+lines*font_h-1 ) pos.setY( tLy+bY+lines*font_h-1 ); |
723 | // check if we produce a mouse move event by this | 748 | // check if we produce a mouse move event by this |
724 | if ( pos != ev->pos() ) cursor().setPos(mapToGlobal(pos)); | 749 | if ( pos != ev->pos() ) cursor().setPos(mapToGlobal(pos)); |
725 | 750 | ||
726 | if ( pos.y() == tLy+bY+lines*font_h-1 ) | 751 | if ( pos.y() == tLy+bY+lines*font_h-1 ) |
727 | { | 752 | { |
728 | scrollbar->setValue(scrollbar->value()+yMouseScroll); // scrollforward | 753 | scrollbar->setValue(scrollbar->value()+yMouseScroll); // scrollforward |
729 | } | 754 | } |
730 | if ( pos.y() == tLy+bY ) | 755 | if ( pos.y() == tLy+bY ) |
731 | { | 756 | { |
732 | scrollbar->setValue(scrollbar->value()-yMouseScroll); // scrollback | 757 | scrollbar->setValue(scrollbar->value()-yMouseScroll); // scrollback |
733 | } | 758 | } |
734 | 759 | ||
735 | QPoint here = QPoint((pos.x()-tLx-blX)/font_w,(pos.y()-tLy-bY)/font_h); | 760 | QPoint here = QPoint((pos.x()-tLx-blX)/font_w,(pos.y()-tLy-bY)/font_h); |
736 | QPoint ohere; | 761 | QPoint ohere; |
737 | bool swapping = FALSE; | 762 | bool swapping = FALSE; |
738 | 763 | ||
739 | if ( word_selection_mode ) | 764 | if ( word_selection_mode ) |
740 | { | 765 | { |
741 | // Extend to word boundaries | 766 | // Extend to word boundaries |
742 | int i; | 767 | int i; |
743 | int selClass; | 768 | int selClass; |
744 | 769 | ||
745 | bool left_not_right = ( here.y() < iPntSel.y() || | 770 | bool left_not_right = ( here.y() < iPntSel.y() || |
746 | here.y() == iPntSel.y() && here.x() < iPntSel.x() ); | 771 | here.y() == iPntSel.y() && here.x() < iPntSel.x() ); |
747 | bool old_left_not_right = ( pntSel.y() < iPntSel.y() || | 772 | bool old_left_not_right = ( pntSel.y() < iPntSel.y() || |
748 | pntSel.y() == iPntSel.y() && pntSel.x() < iPntSel.x() ); | 773 | pntSel.y() == iPntSel.y() && pntSel.x() < iPntSel.x() ); |
749 | swapping = left_not_right != old_left_not_right; | 774 | swapping = left_not_right != old_left_not_right; |
750 | 775 | ||
751 | // Find left (left_not_right ? from here : from start) | 776 | // Find left (left_not_right ? from here : from start) |
752 | QPoint left = left_not_right ? here : iPntSel; | 777 | QPoint left = left_not_right ? here : iPntSel; |
753 | i = loc(left.x(),left.y()); | 778 | i = loc(left.x(),left.y()); |
754 | selClass = charClass(image[i].c); | 779 | selClass = charClass(image[i].c); |
755 | while ( left.x() > 0 && charClass(image[i-1].c) == selClass ) | 780 | while ( left.x() > 0 && charClass(image[i-1].c) == selClass ) |
756 | { i--; left.rx()--; } | 781 | { i--; left.rx()--; } |
757 | 782 | ||
758 | // Find left (left_not_right ? from start : from here) | 783 | // Find left (left_not_right ? from start : from here) |
759 | QPoint right = left_not_right ? iPntSel : here; | 784 | QPoint right = left_not_right ? iPntSel : here; |
760 | i = loc(right.x(),right.y()); | 785 | i = loc(right.x(),right.y()); |
761 | selClass = charClass(image[i].c); | 786 | selClass = charClass(image[i].c); |
762 | while ( right.x() < columns-1 && charClass(image[i+1].c) == selClass ) | 787 | while ( right.x() < columns-1 && charClass(image[i+1].c) == selClass ) |
763 | { i++; right.rx()++; } | 788 | { i++; right.rx()++; } |
764 | 789 | ||
765 | // Pick which is start (ohere) and which is extension (here) | 790 | // Pick which is start (ohere) and which is extension (here) |
766 | if ( left_not_right ) | 791 | if ( left_not_right ) |
767 | { | 792 | { |
768 | here = left; ohere = right; | 793 | here = left; ohere = right; |
769 | } | 794 | } |
770 | else | 795 | else |
771 | { | 796 | { |
772 | here = right; ohere = left; | 797 | here = right; ohere = left; |
773 | } | 798 | } |
774 | } | 799 | } |
775 | 800 | ||
776 | if (here == pntSel && scroll == scrollbar->value()) return; // not moved | 801 | if (here == pntSel && scroll == scrollbar->value()) return; // not moved |
777 | 802 | ||
778 | if ( word_selection_mode ) { | 803 | if ( word_selection_mode ) { |
779 | if ( actSel < 2 || swapping ) { | 804 | if ( actSel < 2 || swapping ) { |
780 | emit beginSelectionSignal( ohere.x(), ohere.y() ); | 805 | emit beginSelectionSignal( ohere.x(), ohere.y() ); |
781 | } | 806 | } |
782 | } else if ( actSel < 2 ) { | 807 | } else if ( actSel < 2 ) { |
783 | emit beginSelectionSignal( pntSel.x(), pntSel.y() ); | 808 | emit beginSelectionSignal( pntSel.x(), pntSel.y() ); |
784 | } | 809 | } |
785 | 810 | ||
786 | actSel = 2; // within selection | 811 | actSel = 2; // within selection |
787 | pntSel = here; | 812 | pntSel = here; |
788 | emit extendSelectionSignal( here.x(), here.y() ); | 813 | emit extendSelectionSignal( here.x(), here.y() ); |
789 | } | 814 | } |
790 | 815 | ||
791 | void TEWidget::mouseReleaseEvent(QMouseEvent* ev) | 816 | void TEWidget::mouseReleaseEvent(QMouseEvent* ev) |
792 | { | 817 | { |
793 | //printf("release [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button()); | 818 | //printf("release [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button()); |
794 | if ( ev->button() == LeftButton) | 819 | if ( ev->button() == LeftButton) |
795 | { | 820 | { |
796 | if ( actSel > 1 ) emit endSelectionSignal(preserve_line_breaks); | 821 | if ( actSel > 1 ) emit endSelectionSignal(preserve_line_breaks); |
797 | preserve_line_breaks = TRUE; | 822 | preserve_line_breaks = TRUE; |
798 | actSel = 0; | 823 | actSel = 0; |
799 | 824 | ||
800 | //FIXME: emits a release event even if the mouse is | 825 | //FIXME: emits a release event even if the mouse is |
801 | // outside the range. The procedure used in `mouseMoveEvent' | 826 | // outside the range. The procedure used in `mouseMoveEvent' |
802 | // applies here, too. | 827 | // applies here, too. |
803 | 828 | ||
804 | QPoint tL = contentsRect().topLeft(); | 829 | QPoint tL = contentsRect().topLeft(); |
805 | int tLx = tL.x(); | 830 | int tLx = tL.x(); |
806 | int tLy = tL.y(); | 831 | int tLy = tL.y(); |
807 | 832 | ||
808 | if (!mouse_marks && !(ev->state() & ShiftButton)) | 833 | if (!mouse_marks && !(ev->state() & ShiftButton)) |
809 | emit mouseSignal( 3, // release | 834 | emit mouseSignal( 3, // release |
810 | (ev->x()-tLx-blX)/font_w + 1, | 835 | (ev->x()-tLx-blX)/font_w + 1, |
811 | (ev->y()-tLy-bY)/font_h + 1 ); | 836 | (ev->y()-tLy-bY)/font_h + 1 ); |
812 | releaseMouse(); | 837 | releaseMouse(); |
813 | } | 838 | } |
814 | } | 839 | } |
815 | 840 | ||
816 | void TEWidget::mouseDoubleClickEvent(QMouseEvent* ev) | 841 | void TEWidget::mouseDoubleClickEvent(QMouseEvent* ev) |
817 | { | 842 | { |
818 | if ( ev->button() != LeftButton) return; | 843 | if ( ev->button() != LeftButton) return; |
819 | 844 | ||
820 | QPoint tL = contentsRect().topLeft(); | 845 | QPoint tL = contentsRect().topLeft(); |
821 | int tLx = tL.x(); | 846 | int tLx = tL.x(); |
822 | int tLy = tL.y(); | 847 | int tLy = tL.y(); |
823 | QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); | 848 | QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); |
824 | 849 | ||
825 | // pass on double click as two clicks. | 850 | // pass on double click as two clicks. |
826 | if (!mouse_marks && !(ev->state() & ShiftButton)) | 851 | if (!mouse_marks && !(ev->state() & ShiftButton)) |
827 | { | 852 | { |
828 | emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button | 853 | emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button |
829 | emit mouseSignal( 3, pos.x()+1, pos.y()+1 ); // release | 854 | emit mouseSignal( 3, pos.x()+1, pos.y()+1 ); // release |
830 | emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button | 855 | emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button |
831 | return; | 856 | return; |
832 | } | 857 | } |
833 | 858 | ||
834 | 859 | ||
835 | emit clearSelectionSignal(); | 860 | emit clearSelectionSignal(); |
836 | QPoint bgnSel = pos; | 861 | QPoint bgnSel = pos; |
837 | QPoint endSel = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); | 862 | QPoint endSel = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); |
838 | int i = loc(bgnSel.x(),bgnSel.y()); | 863 | int i = loc(bgnSel.x(),bgnSel.y()); |
839 | iPntSel = bgnSel; | 864 | iPntSel = bgnSel; |
840 | 865 | ||
841 | word_selection_mode = TRUE; | 866 | word_selection_mode = TRUE; |
842 | 867 | ||
843 | // find word boundaries... | 868 | // find word boundaries... |
844 | int selClass = charClass(image[i].c); | 869 | int selClass = charClass(image[i].c); |
845 | { | 870 | { |
846 | // set the start... | 871 | // set the start... |
847 | int x = bgnSel.x(); | 872 | int x = bgnSel.x(); |
848 | while ( x > 0 && charClass(image[i-1].c) == selClass ) | 873 | while ( x > 0 && charClass(image[i-1].c) == selClass ) |
849 | { i--; x--; } | 874 | { i--; x--; } |
850 | bgnSel.setX(x); | 875 | bgnSel.setX(x); |
851 | emit beginSelectionSignal( bgnSel.x(), bgnSel.y() ); | 876 | emit beginSelectionSignal( bgnSel.x(), bgnSel.y() ); |
852 | 877 | ||
853 | // set the end... | 878 | // set the end... |
854 | i = loc( endSel.x(), endSel.y() ); | 879 | i = loc( endSel.x(), endSel.y() ); |
855 | x = endSel.x(); | 880 | x = endSel.x(); |
856 | while( x < columns-1 && charClass(image[i+1].c) == selClass ) | 881 | while( x < columns-1 && charClass(image[i+1].c) == selClass ) |
857 | { i++; x++ ; } | 882 | { i++; x++ ; } |
858 | endSel.setX(x); | 883 | endSel.setX(x); |
859 | actSel = 2; // within selection | 884 | actSel = 2; // within selection |
860 | emit extendSelectionSignal( endSel.x(), endSel.y() ); | 885 | emit extendSelectionSignal( endSel.x(), endSel.y() ); |
861 | emit endSelectionSignal(preserve_line_breaks); | 886 | emit endSelectionSignal(preserve_line_breaks); |
862 | preserve_line_breaks = TRUE; | 887 | preserve_line_breaks = TRUE; |
863 | } | 888 | } |
864 | } | 889 | } |
865 | 890 | ||
866 | void TEWidget::focusInEvent( QFocusEvent * ) | 891 | void TEWidget::focusInEvent( QFocusEvent * ) |
867 | { | 892 | { |
868 | 893 | ||
869 | // do nothing, to prevent repainting | 894 | // do nothing, to prevent repainting |
870 | } | 895 | } |
871 | 896 | ||
872 | 897 | ||
873 | void TEWidget::focusOutEvent( QFocusEvent * ) | 898 | void TEWidget::focusOutEvent( QFocusEvent * ) |
874 | { | 899 | { |
875 | // do nothing, to prevent repainting | 900 | // do nothing, to prevent repainting |
876 | } | 901 | } |
877 | 902 | ||
878 | bool TEWidget::focusNextPrevChild( bool next ) | 903 | bool TEWidget::focusNextPrevChild( bool next ) |
879 | { | 904 | { |
880 | if (next) | 905 | if (next) |
881 | return false; // This disables changing the active part in konqueror | 906 | return false; // This disables changing the active part in konqueror |
882 | // when pressing Tab | 907 | // when pressing Tab |
883 | return QFrame::focusNextPrevChild( next ); | 908 | return QFrame::focusNextPrevChild( next ); |
884 | } | 909 | } |
885 | 910 | ||
886 | 911 | ||
887 | int TEWidget::charClass(char ch) const | 912 | int TEWidget::charClass(char ch) const |
888 | { | 913 | { |
889 | // This might seem like overkill, but imagine if ch was a Unicode | 914 | // This might seem like overkill, but imagine if ch was a Unicode |
890 | // character (Qt 2.0 QChar) - it might then be sensible to separate | 915 | // character (Qt 2.0 QChar) - it might then be sensible to separate |
891 | // the different language ranges, etc. | 916 | // the different language ranges, etc. |
892 | 917 | ||
893 | if ( isspace(ch) ) return ' '; | 918 | if ( isspace(ch) ) return ' '; |
894 | 919 | ||
895 | static const char *word_characters = ":@-./_~"; | 920 | static const char *word_characters = ":@-./_~"; |
896 | if ( isalnum(ch) || strchr(word_characters, ch) ) | 921 | if ( isalnum(ch) || strchr(word_characters, ch) ) |
897 | return 'a'; | 922 | return 'a'; |
898 | 923 | ||
899 | // Everything else is weird | 924 | // Everything else is weird |
900 | return 1; | 925 | return 1; |
901 | } | 926 | } |
902 | 927 | ||
903 | void TEWidget::setMouseMarks(bool on) | 928 | void TEWidget::setMouseMarks(bool on) |
904 | { | 929 | { |
905 | mouse_marks = on; | 930 | mouse_marks = on; |
906 | setCursor( mouse_marks ? ibeamCursor : arrowCursor ); | 931 | setCursor( mouse_marks ? ibeamCursor : arrowCursor ); |
907 | } | 932 | } |
908 | 933 | ||
909 | /* ------------------------------------------------------------------------- */ | 934 | /* ------------------------------------------------------------------------- */ |
910 | /* */ | 935 | /* */ |
911 | /* Clipboard */ | 936 | /* Clipboard */ |
912 | /* */ | 937 | /* */ |
913 | /* ------------------------------------------------------------------------- */ | 938 | /* ------------------------------------------------------------------------- */ |
914 | 939 | ||
915 | #undef KeyPress | 940 | #undef KeyPress |
916 | 941 | ||
917 | void TEWidget::emitSelection() | 942 | void TEWidget::emitSelection() |
918 | // Paste Clipboard by simulating keypress events | 943 | // Paste Clipboard by simulating keypress events |
919 | { | 944 | { |
920 | #ifndef QT_NO_CLIPBOARD | 945 | #ifndef QT_NO_CLIPBOARD |
921 | QString text = QApplication::clipboard()->text(); | 946 | QString text = QApplication::clipboard()->text(); |
922 | if ( ! text.isNull() ) | 947 | if ( ! text.isNull() ) |
923 | { | 948 | { |
924 | text.replace(QRegExp("\n"), "\r"); | 949 | text.replace(QRegExp("\n"), "\r"); |
925 | QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text); | 950 | QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text); |
926 | emit keyPressedSignal(&e); // expose as a big fat keypress event | 951 | emit keyPressedSignal(&e); // expose as a big fat keypress event |
927 | emit clearSelectionSignal(); | 952 | emit clearSelectionSignal(); |
928 | } | 953 | } |
929 | #endif | 954 | #endif |
930 | } | 955 | } |
931 | 956 | ||
932 | void TEWidget::emitText(QString text) | 957 | void TEWidget::emitText(QString text) |
933 | { | 958 | { |
934 | QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text); | 959 | QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text); |
935 | emit keyPressedSignal(&e); // expose as a big fat keypress event | 960 | emit keyPressedSignal(&e); // expose as a big fat keypress event |
936 | } | 961 | } |
937 | 962 | ||
938 | void TEWidget::pasteClipboard( ) | 963 | void TEWidget::pasteClipboard( ) |
939 | { | 964 | { |
940 | emitSelection(); | 965 | emitSelection(); |
941 | } | 966 | } |
942 | 967 | ||
943 | void TEWidget::setSelection(const QString& t) | 968 | void TEWidget::setSelection(const QString& t) |
944 | { | 969 | { |
945 | #ifndef QT_NO_CLIPBOARD | 970 | #ifndef QT_NO_CLIPBOARD |
946 | // Disconnect signal while WE set the clipboard | 971 | // Disconnect signal while WE set the clipboard |
947 | QObject *cb = QApplication::clipboard(); | 972 | QObject *cb = QApplication::clipboard(); |
948 | QObject::disconnect( cb, SIGNAL(dataChanged()), | 973 | QObject::disconnect( cb, SIGNAL(dataChanged()), |
949 | this, SLOT(onClearSelection()) ); | 974 | this, SLOT(onClearSelection()) ); |
950 | 975 | ||
951 | QApplication::clipboard()->setText(t); | 976 | QApplication::clipboard()->setText(t); |
952 | 977 | ||
953 | QObject::connect( cb, SIGNAL(dataChanged()), | 978 | QObject::connect( cb, SIGNAL(dataChanged()), |
954 | this, SLOT(onClearSelection()) ); | 979 | this, SLOT(onClearSelection()) ); |
955 | #endif | 980 | #endif |
956 | } | 981 | } |
957 | 982 | ||
958 | void TEWidget::onClearSelection() | 983 | void TEWidget::onClearSelection() |
959 | { | 984 | { |
960 | emit clearSelectionSignal(); | 985 | emit clearSelectionSignal(); |
961 | } | 986 | } |
962 | 987 | ||
963 | /* ------------------------------------------------------------------------- */ | 988 | /* ------------------------------------------------------------------------- */ |
964 | /* */ | 989 | /* */ |
965 | /* Keyboard */ | 990 | /* Keyboard */ |
966 | /* */ | 991 | /* */ |
967 | /* ------------------------------------------------------------------------- */ | 992 | /* ------------------------------------------------------------------------- */ |
968 | 993 | ||
969 | //FIXME: an `eventFilter' has been installed instead of a `keyPressEvent' | 994 | //FIXME: an `eventFilter' has been installed instead of a `keyPressEvent' |
970 | // due to a bug in `QT' or the ignorance of the author to prevent | 995 | // due to a bug in `QT' or the ignorance of the author to prevent |
971 | // repaint events being emitted to the screen whenever one leaves | 996 | // repaint events being emitted to the screen whenever one leaves |
972 | // or reenters the screen to/from another application. | 997 | // or reenters the screen to/from another application. |
973 | // | 998 | // |
974 | // Troll says one needs to change focusInEvent() and focusOutEvent(), | 999 | // Troll says one needs to change focusInEvent() and focusOutEvent(), |
975 | // which would also let you have an in-focus cursor and an out-focus | 1000 | // which would also let you have an in-focus cursor and an out-focus |
976 | // cursor like xterm does. | 1001 | // cursor like xterm does. |
977 | 1002 | ||
978 | // for the auto-hide cursor feature, I added empty focusInEvent() and | 1003 | // for the auto-hide cursor feature, I added empty focusInEvent() and |
979 | // focusOutEvent() so that update() isn't called. | 1004 | // focusOutEvent() so that update() isn't called. |
980 | // For auto-hide, we need to get keypress-events, but we only get them when | 1005 | // For auto-hide, we need to get keypress-events, but we only get them when |
981 | // we have focus. | 1006 | // we have focus. |
982 | 1007 | ||
983 | void TEWidget::doScroll(int lines) | 1008 | void TEWidget::doScroll(int lines) |
984 | { | 1009 | { |
985 | scrollbar->setValue(scrollbar->value()+lines); | 1010 | scrollbar->setValue(scrollbar->value()+lines); |
986 | } | 1011 | } |
987 | 1012 | ||
988 | bool TEWidget::eventFilter( QObject *obj, QEvent *e ) | 1013 | bool TEWidget::eventFilter( QObject *obj, QEvent *e ) |
989 | { | 1014 | { |
990 | if ( (e->type() == QEvent::Accel || | 1015 | if ( (e->type() == QEvent::Accel || |
991 | e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) { | 1016 | e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) { |
992 | static_cast<QKeyEvent *>( e )->ignore(); | 1017 | static_cast<QKeyEvent *>( e )->ignore(); |
993 | return true; | 1018 | return true; |
994 | } | 1019 | } |
995 | if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ ) | 1020 | if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ ) |
996 | return FALSE; // not us | 1021 | return FALSE; // not us |
997 | if ( e->type() == QEvent::Wheel) { | 1022 | if ( e->type() == QEvent::Wheel) { |
998 | QApplication::sendEvent(scrollbar, e); | 1023 | QApplication::sendEvent(scrollbar, e); |
999 | } | 1024 | } |
1000 | 1025 | ||
1001 | #ifdef FAKE_CTRL_AND_ALT | 1026 | #ifdef FAKE_CTRL_AND_ALT |
1002 | static bool control = FALSE; | 1027 | static bool control = FALSE; |
1003 | static bool alt = FALSE; | 1028 | static bool alt = FALSE; |
1004 | // qDebug(" Has a keyboard with no CTRL and ALT keys, but we fake it:"); | 1029 | // qDebug(" Has a keyboard with no CTRL and ALT keys, but we fake it:"); |
1005 | bool dele=FALSE; | 1030 | bool dele=FALSE; |
1006 | if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { | 1031 | if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { |
1007 | QKeyEvent* ke = (QKeyEvent*)e; | 1032 | QKeyEvent* ke = (QKeyEvent*)e; |
1008 | bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat(); | 1033 | bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat(); |
1009 | switch (ke->key()) { | 1034 | switch (ke->key()) { |
1010 | case Key_F9: // let this be "Control" | 1035 | case Key_F9: // let this be "Control" |
1011 | control = keydown; | 1036 | control = keydown; |
1012 | e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state()); | 1037 | e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state()); |
1013 | dele=TRUE; | 1038 | dele=TRUE; |
1014 | break; | 1039 | break; |
1015 | case Key_F13: // let this be "Alt" | 1040 | case Key_F13: // let this be "Alt" |
1016 | alt = keydown; | 1041 | alt = keydown; |
1017 | e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state()); | 1042 | e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state()); |
1018 | dele=TRUE; | 1043 | dele=TRUE; |
1019 | break; | 1044 | break; |
1020 | default: | 1045 | default: |
1021 | if ( control ) { | 1046 | if ( control ) { |
1022 | int a = toupper(ke->ascii())-64; | 1047 | int a = toupper(ke->ascii())-64; |
1023 | if ( a >= 0 && a < ' ' ) { | 1048 | if ( a >= 0 && a < ' ' ) { |
1024 | e = new QKeyEvent(e->type(), ke->key(), | 1049 | e = new QKeyEvent(e->type(), ke->key(), |
1025 | a, ke->state()|ControlButton, QChar(a,0)); | 1050 | a, ke->state()|ControlButton, QChar(a,0)); |
1026 | dele=TRUE; | 1051 | dele=TRUE; |
1027 | } | 1052 | } |
1028 | } | 1053 | } |
1029 | if ( alt ) { | 1054 | if ( alt ) { |
1030 | e = new QKeyEvent(e->type(), ke->key(), | 1055 | e = new QKeyEvent(e->type(), ke->key(), |
1031 | ke->ascii(), ke->state()|AltButton, ke->text()); | 1056 | ke->ascii(), ke->state()|AltButton, ke->text()); |
1032 | dele=TRUE; | 1057 | dele=TRUE; |
1033 | } | 1058 | } |
1034 | } | 1059 | } |
1035 | } | 1060 | } |
1036 | #endif | 1061 | #endif |
1037 | 1062 | ||
1038 | if ( e->type() == QEvent::KeyPress ) { | 1063 | if ( e->type() == QEvent::KeyPress ) { |
1039 | QKeyEvent* ke = (QKeyEvent*)e; | 1064 | QKeyEvent* ke = (QKeyEvent*)e; |
1040 | actSel=0; // Key stroke implies a screen update, so TEWidget won't | 1065 | actSel=0; // Key stroke implies a screen update, so TEWidget won't |
1041 | // know where the current selection is. | 1066 | // know where the current selection is. |
1042 | 1067 | ||
1043 | // qDebug("key pressed is 0x%x",ke->key()); | 1068 | // qDebug("key pressed is 0x%x",ke->key()); |
1044 | 1069 | ||
1045 | if( ke->state() == ShiftButton && ke->key() == Key_Tab) { //lets hardcode this sucker | 1070 | if( ke->state() == ShiftButton && ke->key() == Key_Tab) { //lets hardcode this sucker |
1046 | 1071 | ||
1047 | // qDebug("key pressed 2 is 0x%x",ke->key()); | 1072 | // qDebug("key pressed 2 is 0x%x",ke->key()); |
1048 | emitText("\\"); // expose | 1073 | emitText("\\"); // expose |
1049 | } else | 1074 | } else |
1050 | emit keyPressedSignal(ke); // expose | 1075 | emit keyPressedSignal(ke); // expose |
1051 | ke->accept(); | 1076 | ke->accept(); |
1052 | #ifdef FAKE_CTRL_AND_ALT | 1077 | #ifdef FAKE_CTRL_AND_ALT |
1053 | if ( dele ) delete e; | 1078 | if ( dele ) delete e; |
1054 | #endif | 1079 | #endif |
1055 | return true; // stop the event | 1080 | return true; // stop the event |
1056 | } | 1081 | } |
1057 | if ( e->type() == QEvent::Enter ) { | 1082 | if ( e->type() == QEvent::Enter ) { |
1058 | QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()), | 1083 | QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()), |
1059 | this, SLOT(onClearSelection()) ); | 1084 | this, SLOT(onClearSelection()) ); |
1060 | } | 1085 | } |
1061 | if ( e->type() == QEvent::Leave ) { | 1086 | if ( e->type() == QEvent::Leave ) { |
1062 | QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), | 1087 | QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), |
1063 | this, SLOT(onClearSelection()) ); | 1088 | this, SLOT(onClearSelection()) ); |
1064 | } | 1089 | } |
1065 | return QFrame::eventFilter( obj, e ); | 1090 | return QFrame::eventFilter( obj, e ); |
1066 | } | 1091 | } |
1067 | 1092 | ||
1068 | /* ------------------------------------------------------------------------- */ | 1093 | /* ------------------------------------------------------------------------- */ |
1069 | /* */ | 1094 | /* */ |
1070 | /* Frame */ | 1095 | /* Frame */ |
1071 | /* */ | 1096 | /* */ |
1072 | /* ------------------------------------------------------------------------- */ | 1097 | /* ------------------------------------------------------------------------- */ |
1073 | 1098 | ||
1074 | void TEWidget::frameChanged() | 1099 | void TEWidget::frameChanged() |
1075 | { | 1100 | { |
1076 | propagateSize(); | 1101 | propagateSize(); |
1077 | update(); | 1102 | update(); |
1078 | } | 1103 | } |
1079 | 1104 | ||
1080 | /* ------------------------------------------------------------------------- */ | 1105 | /* ------------------------------------------------------------------------- */ |
1081 | /* */ | 1106 | /* */ |
1082 | /* Sound */ | 1107 | /* Sound */ |
1083 | /* */ | 1108 | /* */ |
1084 | /* ------------------------------------------------------------------------- */ | 1109 | /* ------------------------------------------------------------------------- */ |
1085 | 1110 | ||
1086 | void TEWidget::Bell() | 1111 | void TEWidget::Bell() |
1087 | { | 1112 | { |
1088 | QApplication::beep(); | 1113 | QApplication::beep(); |
1089 | } | 1114 | } |
1090 | 1115 | ||
1091 | /* ------------------------------------------------------------------------- */ | 1116 | /* ------------------------------------------------------------------------- */ |
1092 | /* */ | 1117 | /* */ |
1093 | /* Auxiluary */ | 1118 | /* Auxiluary */ |
1094 | /* */ | 1119 | /* */ |
1095 | /* ------------------------------------------------------------------------- */ | 1120 | /* ------------------------------------------------------------------------- */ |
1096 | 1121 | ||
1097 | void TEWidget::clearImage() | 1122 | void TEWidget::clearImage() |
1098 | // initialize the image | 1123 | // initialize the image |
1099 | // for internal use only | 1124 | // for internal use only |
1100 | { | 1125 | { |
1101 | for (int y = 0; y < lines; y++) | 1126 | for (int y = 0; y < lines; y++) |
1102 | for (int x = 0; x < columns; x++) | 1127 | for (int x = 0; x < columns; x++) |
1103 | { | 1128 | { |
1104 | image[loc(x,y)].c = 0xff; //' '; | 1129 | image[loc(x,y)].c = 0xff; //' '; |
1105 | image[loc(x,y)].f = 0xff; //DEFAULT_FORE_COLOR; | 1130 | image[loc(x,y)].f = 0xff; //DEFAULT_FORE_COLOR; |
1106 | image[loc(x,y)].b = 0xff; //DEFAULT_BACK_COLOR; | 1131 | image[loc(x,y)].b = 0xff; //DEFAULT_BACK_COLOR; |
1107 | image[loc(x,y)].r = 0xff; //DEFAULT_RENDITION; | 1132 | image[loc(x,y)].r = 0xff; //DEFAULT_RENDITION; |
1108 | } | 1133 | } |
1109 | } | 1134 | } |
1110 | 1135 | ||
1111 | // Create Image /////////////////////////////////////////////////////// | 1136 | // Create Image /////////////////////////////////////////////////////// |
1112 | 1137 | ||
1113 | void TEWidget::calcGeometry() | 1138 | void TEWidget::calcGeometry() |
1114 | { | 1139 | { |
1115 | //FIXME: set rimX == rimY == 0 when running in full screen mode. | 1140 | //FIXME: set rimX == rimY == 0 when running in full screen mode. |
1116 | 1141 | ||
1117 | scrollbar->resize(QApplication::style().scrollBarExtent().width(), | 1142 | scrollbar->resize(QApplication::style().scrollBarExtent().width(), |
1118 | contentsRect().height()); | 1143 | contentsRect().height()); |
1119 | switch(scrollLoc) | 1144 | switch(scrollLoc) |
1120 | { | 1145 | { |
1121 | case SCRNONE : | 1146 | case SCRNONE : |
1122 | columns = ( contentsRect().width() - 2 * rimX ) / font_w; | 1147 | columns = ( contentsRect().width() - 2 * rimX ) / font_w; |
1123 | blX = (contentsRect().width() - (columns*font_w) ) / 2; | 1148 | blX = (contentsRect().width() - (columns*font_w) ) / 2; |
1124 | brX = blX; | 1149 | brX = blX; |
1125 | scrollbar->hide(); | 1150 | scrollbar->hide(); |
1126 | break; | 1151 | break; |
1127 | case SCRLEFT : | 1152 | case SCRLEFT : |
1128 | columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; | 1153 | columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; |
1129 | brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; | 1154 | brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; |
1130 | blX = brX + scrollbar->width(); | 1155 | blX = brX + scrollbar->width(); |
1131 | scrollbar->move(contentsRect().topLeft()); | 1156 | scrollbar->move(contentsRect().topLeft()); |
1132 | scrollbar->show(); | 1157 | scrollbar->show(); |
1133 | break; | 1158 | break; |
1134 | case SCRRIGHT: | 1159 | case SCRRIGHT: |
1135 | columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; | 1160 | columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; |
1136 | blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; | 1161 | blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; |
1137 | brX = blX; | 1162 | brX = blX; |
1138 | scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0)); | 1163 | scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0)); |
1139 | scrollbar->show(); | 1164 | scrollbar->show(); |
1140 | break; | 1165 | break; |
1141 | } | 1166 | } |
1142 | //FIXME: support 'rounding' styles | 1167 | //FIXME: support 'rounding' styles |
1143 | lines = ( contentsRect().height() - 2 * rimY ) / font_h; | 1168 | lines = ( contentsRect().height() - 2 * rimY ) / font_h; |
1144 | bY = (contentsRect().height() - (lines *font_h)) / 2; | 1169 | bY = (contentsRect().height() - (lines *font_h)) / 2; |
1145 | } | 1170 | } |
1146 | 1171 | ||
1147 | void TEWidget::makeImage() | 1172 | void TEWidget::makeImage() |
1148 | //FIXME: rename 'calcGeometry? | 1173 | //FIXME: rename 'calcGeometry? |
1149 | { | 1174 | { |
1150 | calcGeometry(); | 1175 | calcGeometry(); |
1151 | image = (ca*) malloc(lines*columns*sizeof(ca)); | 1176 | image = (ca*) malloc(lines*columns*sizeof(ca)); |
1152 | clearImage(); | 1177 | clearImage(); |
1153 | } | 1178 | } |
1154 | 1179 | ||
1155 | // calculate the needed size | 1180 | // calculate the needed size |
1156 | QSize TEWidget::calcSize(int cols, int lins) const | 1181 | QSize TEWidget::calcSize(int cols, int lins) const |
1157 | { | 1182 | { |
1158 | int frw = width() - contentsRect().width(); | 1183 | int frw = width() - contentsRect().width(); |
1159 | int frh = height() - contentsRect().height(); | 1184 | int frh = height() - contentsRect().height(); |
1160 | int scw = (scrollLoc==SCRNONE?0:scrollbar->width()); | 1185 | int scw = (scrollLoc==SCRNONE?0:scrollbar->width()); |
1161 | return QSize( font_w*cols + 2*rimX + frw + scw, font_h*lins + 2*rimY + frh ); | 1186 | return QSize( font_w*cols + 2*rimX + frw + scw, font_h*lins + 2*rimY + frh ); |
1162 | } | 1187 | } |
1163 | 1188 | ||
1164 | QSize TEWidget::sizeHint() const | 1189 | QSize TEWidget::sizeHint() const |
1165 | { | 1190 | { |
1166 | return size(); | 1191 | return size(); |
1167 | } | 1192 | } |
1168 | 1193 | ||
1169 | void TEWidget::styleChange(QStyle &) | 1194 | void TEWidget::styleChange(QStyle &) |
1170 | { | 1195 | { |
1171 | propagateSize(); | 1196 | propagateSize(); |
1172 | } | 1197 | } |
1173 | 1198 | ||
1174 | #ifndef QT_NO_DRAGANDDROP | 1199 | #ifndef QT_NO_DRAGANDDROP |
1175 | 1200 | ||
1176 | /* --------------------------------------------------------------------- */ | 1201 | /* --------------------------------------------------------------------- */ |
1177 | /* */ | 1202 | /* */ |
1178 | /* Drag & Drop */ | 1203 | /* Drag & Drop */ |
1179 | /* */ | 1204 | /* */ |
1180 | /* --------------------------------------------------------------------- */ | 1205 | /* --------------------------------------------------------------------- */ |
1181 | 1206 | ||
1182 | 1207 | ||
1183 | void TEWidget::dragEnterEvent(QDragEnterEvent* e) | 1208 | void TEWidget::dragEnterEvent(QDragEnterEvent* e) |
1184 | { | 1209 | { |
1185 | e->accept(QTextDrag::canDecode(e) || | 1210 | e->accept(QTextDrag::canDecode(e) || |
1186 | QUriDrag::canDecode(e)); | 1211 | QUriDrag::canDecode(e)); |
1187 | } | 1212 | } |
1188 | 1213 | ||
1189 | void TEWidget::dropEvent(QDropEvent* event) | 1214 | void TEWidget::dropEvent(QDropEvent* event) |
1190 | { | 1215 | { |
1191 | // The current behaviour when url(s) are dropped is | 1216 | // The current behaviour when url(s) are dropped is |
1192 | // * if there is only ONE url and if it's a LOCAL one, ask for paste or cd | 1217 | // * if there is only ONE url and if it's a LOCAL one, ask for paste or cd |
1193 | // * in all other cases, just paste | 1218 | // * in all other cases, just paste |
1194 | // (for non-local ones, or for a list of URLs, 'cd' is nonsense) | 1219 | // (for non-local ones, or for a list of URLs, 'cd' is nonsense) |
1195 | QStrList strlist; | 1220 | QStrList strlist; |
1196 | int file_count = 0; | 1221 | int file_count = 0; |
1197 | dropText = ""; | 1222 | dropText = ""; |
1198 | bool bPopup = true; | 1223 | bool bPopup = true; |
1199 | 1224 | ||
1200 | if(QUriDrag::decode(event, strlist)) { | 1225 | if(QUriDrag::decode(event, strlist)) { |
1201 | if (strlist.count()) { | 1226 | if (strlist.count()) { |
1202 | for(const char* p = strlist.first(); p; p = strlist.next()) { | 1227 | for(const char* p = strlist.first(); p; p = strlist.next()) { |
1203 | if(file_count++ > 0) { | 1228 | if(file_count++ > 0) { |
1204 | dropText += " "; | 1229 | dropText += " "; |
1205 | bPopup = false; // more than one file, don't popup | 1230 | bPopup = false; // more than one file, don't popup |
1206 | } | 1231 | } |
1207 | 1232 | ||
1208 | /* | 1233 | /* |
1209 | KURL url(p); | 1234 | KURL url(p); |
1210 | if (url.isLocalFile()) { | 1235 | if (url.isLocalFile()) { |
1211 | dropText += url.path(); // local URL : remove protocol | 1236 | dropText += url.path(); // local URL : remove protocol |
1212 | } | 1237 | } |
1213 | else { | 1238 | else { |
1214 | dropText += url.prettyURL(); | 1239 | dropText += url.prettyURL(); |
1215 | bPopup = false; // a non-local file, don't popup | 1240 | bPopup = false; // a non-local file, don't popup |
1216 | } | 1241 | } |
1217 | */ | 1242 | */ |
1218 | 1243 | ||
1219 | } | 1244 | } |
1220 | 1245 | ||
1221 | if (bPopup) | 1246 | if (bPopup) |
1222 | // m_drop->popup(pos() + event->pos()); | 1247 | // m_drop->popup(pos() + event->pos()); |
1223 | m_drop->popup(mapToGlobal(event->pos())); | 1248 | m_drop->popup(mapToGlobal(event->pos())); |
1224 | else | 1249 | else |
1225 | { | 1250 | { |
1226 | if (currentSession) { | 1251 | if (currentSession) { |
1227 | currentSession->getEmulation()->sendString(dropText.local8Bit()); | 1252 | currentSession->getEmulation()->sendString(dropText.local8Bit()); |
1228 | } | 1253 | } |
1229 | // kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; | 1254 | // kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; |
1230 | } | 1255 | } |
1231 | } | 1256 | } |
1232 | } | 1257 | } |
1233 | else if(QTextDrag::decode(event, dropText)) { | 1258 | else if(QTextDrag::decode(event, dropText)) { |
1234 | // kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; | 1259 | // kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; |
1235 | if (currentSession) { | 1260 | if (currentSession) { |
1236 | currentSession->getEmulation()->sendString(dropText.local8Bit()); | 1261 | currentSession->getEmulation()->sendString(dropText.local8Bit()); |
1237 | } | 1262 | } |
1238 | // Paste it | 1263 | // Paste it |
1239 | } | 1264 | } |
1240 | } | 1265 | } |
1241 | #endif | 1266 | #endif |
1242 | 1267 | ||
1243 | 1268 | ||
1244 | void TEWidget::drop_menu_activated(int item) | 1269 | void TEWidget::drop_menu_activated(int) |
1245 | { | 1270 | { |
1246 | #ifndef QT_NO_DRAGANDDROP | 1271 | #ifndef QT_NO_DRAGANDDROP |
1247 | switch (item) | 1272 | switch (item) |
1248 | { | 1273 | { |
1249 | case 0: // paste | 1274 | case 0: // paste |
1250 | currentSession->getEmulation()->sendString(dropText.local8Bit()); | 1275 | currentSession->getEmulation()->sendString(dropText.local8Bit()); |
1251 | // KWM::activate((Window)this->winId()); | 1276 | // KWM::activate((Window)this->winId()); |
1252 | break; | 1277 | break; |
1253 | case 1: // cd ... | 1278 | case 1: // cd ... |
1254 | currentSession->getEmulation()->sendString("cd "); | 1279 | currentSession->getEmulation()->sendString("cd "); |
1255 | struct stat statbuf; | 1280 | struct stat statbuf; |
1256 | if ( ::stat( QFile::encodeName( dropText ), &statbuf ) == 0 ) | 1281 | if ( ::stat( QFile::encodeName( dropText ), &statbuf ) == 0 ) |
1257 | { | 1282 | { |
1258 | if ( !S_ISDIR(statbuf.st_mode) ) | 1283 | if ( !S_ISDIR(statbuf.st_mode) ) |
1259 | { | 1284 | { |
1260 | /* | 1285 | /* |
1261 | KURL url; | 1286 | KURL url; |
1262 | url.setPath( dropText ); | 1287 | url.setPath( dropText ); |
1263 | dropText = url.directory( true, false ); // remove filename | 1288 | dropText = url.directory( true, false ); // remove filename |
1264 | */ | 1289 | */ |
1265 | } | 1290 | } |
1266 | } | 1291 | } |
1267 | dropText.replace(QRegExp(" "), "\\ "); // escape spaces | 1292 | dropText.replace(QRegExp(" "), "\\ "); // escape spaces |
1268 | currentSession->getEmulation()->sendString(dropText.local8Bit()); | 1293 | currentSession->getEmulation()->sendString(dropText.local8Bit()); |
1269 | currentSession->getEmulation()->sendString("\n"); | 1294 | currentSession->getEmulation()->sendString("\n"); |
1270 | // KWM::activate((Window)this->winId()); | 1295 | // KWM::activate((Window)this->winId()); |
1271 | break; | 1296 | break; |
1272 | } | 1297 | } |
1273 | #endif | 1298 | #endif |
1274 | } | 1299 | } |
1275 | 1300 | ||
1276 | QPushButton* TEWidget::cornerButton() { | 1301 | QPushButton* TEWidget::cornerButton() { |
1277 | return m_cornerButton; | 1302 | return m_cornerButton; |
1278 | } | 1303 | } |
diff --git a/noncore/apps/opie-console/TEWidget.h b/noncore/apps/opie-console/TEWidget.h index 1b5300f..f03a16e 100644 --- a/noncore/apps/opie-console/TEWidget.h +++ b/noncore/apps/opie-console/TEWidget.h | |||
@@ -1,228 +1,210 @@ | |||
1 | /* ----------------------------------------------------------------------- */ | 1 | /* ----------------------------------------------------------------------- */ |
2 | /* */ | 2 | /* */ |
3 | /* [te_widget.h] Terminal Emulation Widget */ | 3 | /* [te_widget.h] 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 | #ifndef TE_WIDGET_H | 18 | #ifndef TE_WIDGET_H |
19 | #define TE_WIDGET_H | 19 | #define TE_WIDGET_H |
20 | 20 | ||
21 | #include <qwidget.h> | 21 | #include <qwidget.h> |
22 | #include <qlabel.h> | 22 | #include <qlabel.h> |
23 | #include <qtimer.h> | 23 | #include <qtimer.h> |
24 | #include <qcolor.h> | 24 | #include <qcolor.h> |
25 | #include <qkeycode.h> | 25 | #include <qkeycode.h> |
26 | #include <qscrollbar.h> | 26 | #include <qscrollbar.h> |
27 | 27 | ||
28 | #include <qpopupmenu.h> | 28 | #include <qpopupmenu.h> |
29 | #include <qpushbutton.h> | 29 | #include <qpushbutton.h> |
30 | 30 | ||
31 | #include "TECommon.h" | 31 | #include "TECommon.h" |
32 | 32 | ||
33 | extern unsigned short vt100_graphics[32]; | 33 | extern unsigned short vt100_graphics[32]; |
34 | 34 | ||
35 | 35 | ||
36 | 36 | ||
37 | static char * menu_xpm[] = { | 37 | |
38 | "12 12 5 1", | ||
39 | " c None", | ||
40 | ".c #000000", | ||
41 | "+c #FFFDAD", | ||
42 | "@c #FFFF00", | ||
43 | "#c #E5E100", | ||
44 | " ", | ||
45 | " ", | ||
46 | " ......... ", | ||
47 | " .+++++++. ", | ||
48 | " .+@@@@#. ", | ||
49 | " .+@@@#. ", | ||
50 | " .+@@#. ", | ||
51 | " .+@#. ", | ||
52 | " .+#. ", | ||
53 | " .+. ", | ||
54 | " .. ", | ||
55 | " "}; | ||
56 | 38 | ||
57 | class TESession; | 39 | class TESession; |
58 | 40 | ||
59 | // class Konsole; | 41 | // class Konsole; |
60 | 42 | ||
61 | class TEWidget : public QFrame | 43 | class TEWidget : public QFrame |
62 | // a widget representing attributed text | 44 | // a widget representing attributed text |
63 | { | 45 | { |
64 | Q_OBJECT | 46 | Q_OBJECT |
65 | 47 | ||
66 | // friend class Konsole; | 48 | // friend class Konsole; |
67 | 49 | ||
68 | public: | 50 | public: |
69 | 51 | ||
70 | TEWidget(QWidget *parent=0, const char *name=0); | 52 | TEWidget(QWidget *parent=0, const char *name=0); |
71 | virtual ~TEWidget(); | 53 | virtual ~TEWidget(); |
72 | 54 | ||
73 | public: | 55 | public: |
74 | 56 | ||
75 | QColor getDefaultBackColor(); | 57 | QColor getDefaultBackColor(); |
76 | QPushButton *cornerButton(); | 58 | QPushButton *cornerButton(); |
77 | 59 | ||
78 | const ColorEntry* getColorTable() const; | 60 | const ColorEntry* getColorTable() const; |
79 | const ColorEntry* getdefaultColorTable() const; | 61 | const ColorEntry* getdefaultColorTable() const; |
80 | void setColorTable(const ColorEntry table[]); | 62 | void setColorTable(const ColorEntry table[]); |
81 | 63 | ||
82 | void setScrollbarLocation(int loc); | 64 | void setScrollbarLocation(int loc); |
83 | enum { SCRNONE=0, SCRLEFT=1, SCRRIGHT=2 }; | 65 | enum { SCRNONE=0, SCRLEFT=1, SCRRIGHT=2 }; |
84 | 66 | ||
85 | void setScroll(int cursor, int lines); | 67 | void setScroll(int cursor, int lines); |
86 | void doScroll(int lines); | 68 | void doScroll(int lines); |
87 | 69 | ||
88 | void emitSelection(); | 70 | void emitSelection(); |
89 | 71 | ||
90 | public: | 72 | public: |
91 | 73 | ||
92 | void setImage(const ca* const newimg, int lines, int columns); | 74 | void setImage(const ca* const newimg, int lines, int columns); |
93 | 75 | ||
94 | int Lines() { return lines; } | 76 | int Lines() { return lines; } |
95 | int Columns() { return columns; } | 77 | int Columns() { return columns; } |
96 | 78 | ||
97 | void calcGeometry(); | 79 | void calcGeometry(); |
98 | void propagateSize(); | 80 | void propagateSize(); |
99 | QSize calcSize(int cols, int lins) const; | 81 | QSize calcSize(int cols, int lins) const; |
100 | 82 | ||
101 | QSize sizeHint() const; | 83 | QSize sizeHint() const; |
102 | 84 | ||
103 | public: | 85 | public: |
104 | 86 | ||
105 | void Bell(); | 87 | void Bell(); |
106 | void emitText(QString text); | 88 | void emitText(QString text); |
107 | void pasteClipboard(); | 89 | void pasteClipboard(); |
108 | 90 | ||
109 | signals: | 91 | signals: |
110 | 92 | ||
111 | void keyPressedSignal(QKeyEvent *e); | 93 | void keyPressedSignal(QKeyEvent *e); |
112 | void mouseSignal(int cb, int cx, int cy); | 94 | void mouseSignal(int cb, int cx, int cy); |
113 | void changedImageSizeSignal(int lines, int columns); | 95 | void changedImageSizeSignal(int lines, int columns); |
114 | void changedHistoryCursor(int value); | 96 | void changedHistoryCursor(int value); |
115 | void configureRequest( TEWidget*, int state, int x, int y ); | 97 | void configureRequest( TEWidget*, int state, int x, int y ); |
116 | 98 | ||
117 | void clearSelectionSignal(); | 99 | void clearSelectionSignal(); |
118 | void beginSelectionSignal( const int x, const int y ); | 100 | void beginSelectionSignal( const int x, const int y ); |
119 | void extendSelectionSignal( const int x, const int y ); | 101 | void extendSelectionSignal( const int x, const int y ); |
120 | void endSelectionSignal(const BOOL preserve_line_breaks); | 102 | void endSelectionSignal(const BOOL preserve_line_breaks); |
121 | 103 | ||
122 | 104 | ||
123 | protected: | 105 | protected: |
124 | 106 | ||
125 | virtual void styleChange( QStyle& ); | 107 | virtual void styleChange( QStyle& ); |
126 | 108 | ||
127 | bool eventFilter( QObject *, QEvent * ); | 109 | bool eventFilter( QObject *, QEvent * ); |
128 | 110 | ||
129 | void drawAttrStr(QPainter &paint, QRect rect, | 111 | void drawAttrStr(QPainter &paint, QRect rect, |
130 | QString& str, ca attr, BOOL pm, BOOL clear); | 112 | QString& str, ca attr, BOOL pm, BOOL clear); |
131 | void paintEvent( QPaintEvent * ); | 113 | void paintEvent( QPaintEvent * ); |
132 | 114 | ||
133 | void resizeEvent(QResizeEvent*); | 115 | void resizeEvent(QResizeEvent*); |
134 | 116 | ||
135 | void fontChange(const QFont &font); | 117 | void fontChange(const QFont &font); |
136 | void frameChanged(); | 118 | void frameChanged(); |
137 | 119 | ||
138 | void mouseDoubleClickEvent(QMouseEvent* ev); | 120 | void mouseDoubleClickEvent(QMouseEvent* ev); |
139 | void mousePressEvent( QMouseEvent* ); | 121 | void mousePressEvent( QMouseEvent* ); |
140 | void mouseReleaseEvent( QMouseEvent* ); | 122 | void mouseReleaseEvent( QMouseEvent* ); |
141 | void mouseMoveEvent( QMouseEvent* ); | 123 | void mouseMoveEvent( QMouseEvent* ); |
142 | 124 | ||
143 | void focusInEvent( QFocusEvent * ); | 125 | void focusInEvent( QFocusEvent * ); |
144 | void focusOutEvent( QFocusEvent * ); | 126 | void focusOutEvent( QFocusEvent * ); |
145 | bool focusNextPrevChild( bool next ); | 127 | bool focusNextPrevChild( bool next ); |
146 | 128 | ||
147 | #ifndef QT_NO_DRAGANDDROP | 129 | #ifndef QT_NO_DRAGANDDROP |
148 | // Dnd | 130 | // Dnd |
149 | void dragEnterEvent(QDragEnterEvent* event); | 131 | void dragEnterEvent(QDragEnterEvent* event); |
150 | void dropEvent(QDropEvent* event); | 132 | void dropEvent(QDropEvent* event); |
151 | #endif | 133 | #endif |
152 | 134 | ||
153 | virtual int charClass(char) const; | 135 | virtual int charClass(char) const; |
154 | 136 | ||
155 | void clearImage(); | 137 | void clearImage(); |
156 | 138 | ||
157 | public: | 139 | public: |
158 | const QPixmap *backgroundPixmap(); | 140 | const QPixmap *backgroundPixmap(); |
159 | 141 | ||
160 | void setSelection(const QString &t); | 142 | void setSelection(const QString &t); |
161 | 143 | ||
162 | virtual void setFont(const QFont &); | 144 | virtual void setFont(const QFont &); |
163 | void setVTFont(const QFont &); | 145 | void setVTFont(const QFont &); |
164 | QFont getVTFont(); | 146 | QFont getVTFont(); |
165 | 147 | ||
166 | void setMouseMarks(bool on); | 148 | void setMouseMarks(bool on); |
167 | 149 | ||
168 | public slots: | 150 | public slots: |
169 | 151 | ||
170 | void onClearSelection(); | 152 | void onClearSelection(); |
171 | 153 | ||
172 | protected slots: | 154 | protected slots: |
173 | 155 | ||
174 | void scrollChanged(int value); | 156 | void scrollChanged(int value); |
175 | void blinkEvent(); | 157 | void blinkEvent(); |
176 | 158 | ||
177 | private: | 159 | private: |
178 | 160 | ||
179 | QChar (*fontMap)(QChar); // possible vt100 font extention | 161 | QChar (*fontMap)(QChar); // possible vt100 font extention |
180 | 162 | ||
181 | bool fixed_font; // has fixed pitch | 163 | bool fixed_font; // has fixed pitch |
182 | int font_h; // height | 164 | int font_h; // height |
183 | int font_w; // width | 165 | int font_w; // width |
184 | int font_a; // ascend | 166 | int font_a; // ascend |
185 | 167 | ||
186 | int blX; // actual offset (left) | 168 | int blX; // actual offset (left) |
187 | int brX; // actual offset (right) | 169 | int brX; // actual offset (right) |
188 | int bY; // actual offset | 170 | int bY; // actual offset |
189 | 171 | ||
190 | int lines; | 172 | int lines; |
191 | int columns; | 173 | int columns; |
192 | ca *image; // [lines][columns] | 174 | ca *image; // [lines][columns] |
193 | 175 | ||
194 | ColorEntry color_table[TABLE_COLORS]; | 176 | ColorEntry color_table[TABLE_COLORS]; |
195 | 177 | ||
196 | BOOL resizing; | 178 | BOOL resizing; |
197 | bool mouse_marks; | 179 | bool mouse_marks; |
198 | 180 | ||
199 | void makeImage(); | 181 | void makeImage(); |
200 | 182 | ||
201 | QPoint iPntSel; // initial selection point | 183 | QPoint iPntSel; // initial selection point |
202 | QPoint pntSel; // current selection point | 184 | QPoint pntSel; // current selection point |
203 | int actSel; // selection state | 185 | int actSel; // selection state |
204 | BOOL word_selection_mode; | 186 | BOOL word_selection_mode; |
205 | BOOL preserve_line_breaks; | 187 | BOOL preserve_line_breaks; |
206 | 188 | ||
207 | QPushButton *m_cornerButton; | 189 | QPushButton *m_cornerButton; |
208 | QClipboard* cb; | 190 | QClipboard* cb; |
209 | QScrollBar* scrollbar; | 191 | QScrollBar* scrollbar; |
210 | int scrollLoc; | 192 | int scrollLoc; |
211 | 193 | ||
212 | //#define SCRNONE 0 | 194 | //#define SCRNONE 0 |
213 | //#define SCRLEFT 1 | 195 | //#define SCRLEFT 1 |
214 | //#define SCRRIGHT 2 | 196 | //#define SCRRIGHT 2 |
215 | 197 | ||
216 | BOOL blinking; // hide text in paintEvent | 198 | BOOL blinking; // hide text in paintEvent |
217 | BOOL hasBlinker; // has characters to blink | 199 | BOOL hasBlinker; // has characters to blink |
218 | QTimer* blinkT; // active when hasBlinker | 200 | QTimer* blinkT; // active when hasBlinker |
219 | QPopupMenu* m_drop; | 201 | QPopupMenu* m_drop; |
220 | QString dropText; | 202 | QString dropText; |
221 | public: | 203 | public: |
222 | // current session in this widget | 204 | // current session in this widget |
223 | TESession *currentSession; | 205 | TESession *currentSession; |
224 | private slots: | 206 | private slots: |
225 | void drop_menu_activated(int item); | 207 | void drop_menu_activated(int item); |
226 | }; | 208 | }; |
227 | 209 | ||
228 | #endif // TE_WIDGET_H | 210 | #endif // TE_WIDGET_H |
diff --git a/noncore/apps/opie-console/emulation_handler.cpp b/noncore/apps/opie-console/emulation_handler.cpp index bdc8b43..bb3dd28 100644 --- a/noncore/apps/opie-console/emulation_handler.cpp +++ b/noncore/apps/opie-console/emulation_handler.cpp | |||
@@ -1,194 +1,200 @@ | |||
1 | #include <qwidget.h> | 1 | #include <qwidget.h> |
2 | #include <qpushbutton.h> | 2 | #include <qpushbutton.h> |
3 | 3 | ||
4 | #include "TEWidget.h" | 4 | #include "TEWidget.h" |
5 | #include "TEmuVt102.h" | 5 | #include "TEmuVt102.h" |
6 | 6 | ||
7 | #include "profile.h" | 7 | #include "profile.h" |
8 | #include "emulation_handler.h" | 8 | #include "emulation_handler.h" |
9 | #include "script.h" | 9 | #include "script.h" |
10 | 10 | ||
11 | EmulationHandler::EmulationHandler( const Profile& prof, QWidget* parent,const char* name ) | 11 | EmulationHandler::EmulationHandler( const Profile& prof, QWidget* parent,const char* name ) |
12 | : QObject(0, name ) | 12 | : QObject(0, name ) |
13 | { | 13 | { |
14 | m_teWid = new TEWidget( parent, "TerminalMain"); | 14 | m_teWid = new TEWidget( parent, "TerminalMain"); |
15 | m_teWid->setMinimumSize(150, 70 ); | 15 | m_teWid->setMinimumSize(150, 70 ); |
16 | m_script = 0; | 16 | m_script = 0; |
17 | parent->resize( m_teWid->calcSize(80, 24 ) ); | 17 | parent->resize( m_teWid->calcSize(80, 24 ) ); |
18 | m_teEmu = new TEmuVt102(m_teWid ); | 18 | m_teEmu = new TEmuVt102(m_teWid ); |
19 | 19 | ||
20 | connect(m_teEmu,SIGNAL(ImageSizeChanged(int, int) ), | 20 | connect(m_teEmu,SIGNAL(ImageSizeChanged(int, int) ), |
21 | this, SIGNAL(changeSize(int, int) ) ); | 21 | this, SIGNAL(changeSize(int, int) ) ); |
22 | connect(m_teEmu, SIGNAL(sndBlock(const char*, int) ), | 22 | connect(m_teEmu, SIGNAL(sndBlock(const char*, int) ), |
23 | this, SLOT(recvEmulation(const char*, int) ) ); | 23 | this, SLOT(recvEmulation(const char*, int) ) ); |
24 | m_teEmu->setConnect( true ); | 24 | m_teEmu->setConnect( true ); |
25 | m_teEmu->setHistory( TRUE ); | 25 | m_teEmu->setHistory( TRUE ); |
26 | load( prof ); | 26 | load( prof ); |
27 | 27 | ||
28 | 28 | ||
29 | 29 | ||
30 | } | 30 | } |
31 | EmulationHandler::~EmulationHandler() { | 31 | EmulationHandler::~EmulationHandler() { |
32 | if (isRecording()) | 32 | if (isRecording()) |
33 | clearScript(); | 33 | clearScript(); |
34 | delete m_teEmu; | 34 | delete m_teEmu; |
35 | delete m_teWid; | 35 | delete m_teWid; |
36 | } | 36 | } |
37 | 37 | ||
38 | void EmulationHandler::load( const Profile& prof) { | 38 | void EmulationHandler::load( const Profile& prof) { |
39 | m_teWid->setVTFont( font( prof.readNumEntry("Font") ) ); | 39 | m_teWid->setVTFont( font( prof.readNumEntry("Font") ) ); |
40 | int num = prof.readNumEntry("Color"); | 40 | int num = prof.readNumEntry("Color"); |
41 | setColor( foreColor(num), backColor(num) ); | 41 | setColor( foreColor(num), backColor(num) ); |
42 | m_teWid->setBackgroundColor(backColor(num) ); | 42 | m_teWid->setBackgroundColor(backColor(num) ); |
43 | 43 | ||
44 | int term = prof.readNumEntry("Terminal", 0) ; | 44 | int term = prof.readNumEntry("Terminal", 0) ; |
45 | switch(term) { | 45 | switch(term) { |
46 | default: | 46 | default: |
47 | case Profile::VT102: | 47 | case Profile::VT102: |
48 | case Profile::VT100: | 48 | case Profile::VT100: |
49 | m_teEmu->setKeytrans("vt100.keytab"); | 49 | m_teEmu->setKeytrans("vt100.keytab"); |
50 | break; | 50 | break; |
51 | case Profile::Linux: | 51 | case Profile::Linux: |
52 | m_teEmu->setKeytrans("linux.keytab"); | 52 | m_teEmu->setKeytrans("linux.keytab"); |
53 | break; | 53 | break; |
54 | case Profile::XTerm: | 54 | case Profile::XTerm: |
55 | m_teEmu->setKeytrans("default.Keytab"); | 55 | m_teEmu->setKeytrans("default.Keytab"); |
56 | break; | 56 | break; |
57 | } | 57 | } |
58 | } | 58 | } |
59 | void EmulationHandler::recv( const QByteArray& ar) { | 59 | void EmulationHandler::recv( const QByteArray& ar) { |
60 | m_teEmu->onRcvBlock(ar.data(), ar.count() ); | 60 | m_teEmu->onRcvBlock(ar.data(), ar.count() ); |
61 | } | 61 | } |
62 | void EmulationHandler::recvEmulation(const char* src, int len ) { | 62 | void EmulationHandler::recvEmulation(const char* src, int len ) { |
63 | QByteArray ar(len); | 63 | QByteArray ar(len); |
64 | 64 | ||
65 | memcpy(ar.data(), src, sizeof(char) * len ); | 65 | memcpy(ar.data(), src, sizeof(char) * len ); |
66 | 66 | ||
67 | if (isRecording()) | 67 | if (isRecording()) |
68 | m_script->append(ar); | 68 | m_script->append(ar); |
69 | emit send(ar); | 69 | emit send(ar); |
70 | } | 70 | } |
71 | QWidget* EmulationHandler::widget() { | 71 | QWidget* EmulationHandler::widget() { |
72 | return m_teWid; | 72 | return m_teWid; |
73 | } | 73 | } |
74 | /* | 74 | /* |
75 | * allocate a new table of colors | 75 | * allocate a new table of colors |
76 | */ | 76 | */ |
77 | void EmulationHandler::setColor( const QColor& fore, const QColor& back ) { | 77 | void EmulationHandler::setColor( const QColor& fore, const QColor& back ) { |
78 | ColorEntry table[TABLE_COLORS]; | 78 | ColorEntry table[TABLE_COLORS]; |
79 | const ColorEntry *defaultCt = m_teWid->getdefaultColorTable(); | 79 | const ColorEntry *defaultCt = m_teWid->getdefaultColorTable(); |
80 | 80 | ||
81 | for (int i = 0; i < TABLE_COLORS; i++ ) { | 81 | for (int i = 0; i < TABLE_COLORS; i++ ) { |
82 | if ( i == 0 || i == 10 ) { | 82 | if ( i == 0 || i == 10 ) { |
83 | table[i].color = fore; | 83 | table[i].color = fore; |
84 | }else if ( i == 1 || i == 11 ) { | 84 | }else if ( i == 1 || i == 11 ) { |
85 | table[i].color = back; | 85 | table[i].color = back; |
86 | table[i].transparent = 0; | 86 | table[i].transparent = 0; |
87 | }else { | 87 | }else { |
88 | table[i].color = defaultCt[i].color; | 88 | table[i].color = defaultCt[i].color; |
89 | } | 89 | } |
90 | } | 90 | } |
91 | m_teWid->setColorTable(table ); | 91 | m_teWid->setColorTable(table ); |
92 | m_teWid->update(); | 92 | m_teWid->update(); |
93 | } | 93 | } |
94 | QFont EmulationHandler::font( int id ) { | 94 | QFont EmulationHandler::font( int id ) { |
95 | QString name; | 95 | QString name; |
96 | int size = 0; | 96 | int size = 0; |
97 | switch(id ) { | 97 | switch(id ) { |
98 | default: // fall through | 98 | default: // fall through |
99 | case 0: | 99 | case 0: |
100 | name = QString::fromLatin1("Micro"); | 100 | name = QString::fromLatin1("Micro"); |
101 | size = 4; | 101 | size = 4; |
102 | break; | 102 | break; |
103 | case 1: | 103 | case 1: |
104 | name = QString::fromLatin1("Fixed"); | 104 | name = QString::fromLatin1("Fixed"); |
105 | size = 7; | 105 | size = 7; |
106 | break; | 106 | break; |
107 | case 2: | 107 | case 2: |
108 | name = QString::fromLatin1("Fixed"); | 108 | name = QString::fromLatin1("Fixed"); |
109 | size = 12; | 109 | size = 12; |
110 | break; | 110 | break; |
111 | } | 111 | } |
112 | QFont font(name, size, QFont::Normal ); | 112 | QFont font(name, size, QFont::Normal ); |
113 | font.setFixedPitch(TRUE ); | 113 | font.setFixedPitch(TRUE ); |
114 | return font; | 114 | return font; |
115 | } | 115 | } |
116 | QColor EmulationHandler::foreColor(int col) { | 116 | QColor EmulationHandler::foreColor(int col) { |
117 | QColor co; | 117 | QColor co; |
118 | /* we need to switch it */ | 118 | /* we need to switch it */ |
119 | switch( col ) { | 119 | switch( col ) { |
120 | default: | 120 | default: |
121 | case Profile::White: | 121 | case Profile::White: |
122 | /* color is black */ | 122 | /* color is black */ |
123 | co = Qt::white; | 123 | co = Qt::white; |
124 | break; | 124 | break; |
125 | case Profile::Black: | 125 | case Profile::Black: |
126 | co = Qt::black; | 126 | co = Qt::black; |
127 | break; | 127 | break; |
128 | case Profile::Green: | 128 | case Profile::Green: |
129 | qWarning("Foreground green"); | 129 | qWarning("Foreground green"); |
130 | co = Qt::green; | 130 | co = Qt::green; |
131 | break; | 131 | break; |
132 | case Profile::Orange: | 132 | case Profile::Orange: |
133 | qWarning("Foreground orange"); | 133 | qWarning("Foreground orange"); |
134 | // FIXME needs better color here | 134 | // FIXME needs better color here |
135 | co = Qt::darkYellow; | 135 | co = Qt::darkYellow; |
136 | break; | 136 | break; |
137 | } | 137 | } |
138 | 138 | ||
139 | return co; | 139 | return co; |
140 | } | 140 | } |
141 | QColor EmulationHandler::backColor(int col ) { | 141 | QColor EmulationHandler::backColor(int col ) { |
142 | QColor co; | 142 | QColor co; |
143 | /* we need to switch it */ | 143 | /* we need to switch it */ |
144 | switch( col ) { | 144 | switch( col ) { |
145 | default: | 145 | default: |
146 | case Profile::White: | 146 | case Profile::White: |
147 | /* color is white */ | 147 | /* color is white */ |
148 | co = Qt::black; | 148 | co = Qt::black; |
149 | break; | 149 | break; |
150 | case Profile::Black: | 150 | case Profile::Black: |
151 | co = Qt::white; | 151 | co = Qt::white; |
152 | break; | 152 | break; |
153 | case Profile::Green: | 153 | case Profile::Green: |
154 | qWarning("Background black"); | 154 | qWarning("Background black"); |
155 | co = Qt::black; | 155 | co = Qt::black; |
156 | break; | 156 | break; |
157 | case Profile::Orange: | 157 | case Profile::Orange: |
158 | qWarning("Background black"); | 158 | qWarning("Background black"); |
159 | co = Qt::black; | 159 | co = Qt::black; |
160 | break; | 160 | break; |
161 | } | 161 | } |
162 | 162 | ||
163 | return co; | 163 | return co; |
164 | } | 164 | } |
165 | 165 | ||
166 | QPushButton* EmulationHandler::cornerButton() { | 166 | QPushButton* EmulationHandler::cornerButton() { |
167 | return m_teWid->cornerButton(); | 167 | return m_teWid->cornerButton(); |
168 | } | 168 | } |
169 | 169 | ||
170 | 170 | ||
171 | Script *EmulationHandler::script() { | 171 | Script *EmulationHandler::script() { |
172 | return m_script; | 172 | return m_script; |
173 | } | 173 | } |
174 | 174 | ||
175 | bool EmulationHandler::isRecording() { | 175 | bool EmulationHandler::isRecording() { |
176 | return (m_script != 0); | 176 | return (m_script != 0); |
177 | } | 177 | } |
178 | 178 | ||
179 | void EmulationHandler::startRecording() { | 179 | void EmulationHandler::startRecording() { |
180 | if (!isRecording()) | 180 | if (!isRecording()) |
181 | m_script = new Script(); | 181 | m_script = new Script(); |
182 | } | 182 | } |
183 | 183 | ||
184 | void EmulationHandler::clearScript() { | 184 | void EmulationHandler::clearScript() { |
185 | if (isRecording()) { | 185 | if (isRecording()) { |
186 | delete m_script; | 186 | delete m_script; |
187 | m_script = 0; | 187 | m_script = 0; |
188 | } | 188 | } |
189 | } | 189 | } |
190 | 190 | ||
191 | void EmulationHandler::runScript(const Script *script) { | 191 | void EmulationHandler::runScript(const Script *script) { |
192 | emit send(script->script()); | 192 | emit send(script->script()); |
193 | } | 193 | } |
194 | 194 | ||
195 | void EmulationHandler::copy() { | ||
196 | m_teWid->emitSelection(); | ||
197 | } | ||
198 | void EmulationHandler::paste() { | ||
199 | m_teWid->pasteClipboard(); | ||
200 | } | ||
diff --git a/noncore/apps/opie-console/emulation_handler.h b/noncore/apps/opie-console/emulation_handler.h index 7ca2cf3..12abbc5 100644 --- a/noncore/apps/opie-console/emulation_handler.h +++ b/noncore/apps/opie-console/emulation_handler.h | |||
@@ -1,90 +1,92 @@ | |||
1 | #ifndef OPIE_EMULATION_HANDLER_H | 1 | #ifndef OPIE_EMULATION_HANDLER_H |
2 | #define OPIE_EMULATION_HANDLER_H | 2 | #define OPIE_EMULATION_HANDLER_H |
3 | 3 | ||
4 | #include <qobject.h> | 4 | #include <qobject.h> |
5 | #include <qcolor.h> | 5 | #include <qcolor.h> |
6 | #include <qcstring.h> | 6 | #include <qcstring.h> |
7 | 7 | ||
8 | /* | 8 | /* |
9 | * Badly ibotty lacks the time to finish | 9 | * Badly ibotty lacks the time to finish |
10 | * his widget in time.. | 10 | * his widget in time.. |
11 | * Never the less we've to have an EmulationWidget | 11 | * Never the less we've to have an EmulationWidget |
12 | * This is why I'm taking the inferior not cleaned | 12 | * This is why I'm taking the inferior not cleaned |
13 | * up TE* KDE STUFF | 13 | * up TE* KDE STUFF |
14 | */ | 14 | */ |
15 | 15 | ||
16 | /** | 16 | /** |
17 | * This is the layer above the IOLayer* | 17 | * This is the layer above the IOLayer* |
18 | * This nice QObject here will get stuff from | 18 | * This nice QObject here will get stuff from |
19 | * got a slot and a signal | 19 | * got a slot and a signal |
20 | * the signal for data | 20 | * the signal for data |
21 | * the slot for receiving | 21 | * the slot for receiving |
22 | * it'll set up the widget internally | 22 | * it'll set up the widget internally |
23 | * and manage the communication between | 23 | * and manage the communication between |
24 | * the pre QByteArray world! | 24 | * the pre QByteArray world! |
25 | */ | 25 | */ |
26 | class Profile; | 26 | class Profile; |
27 | class QWidget; | 27 | class QWidget; |
28 | class QPushButton; | 28 | class QPushButton; |
29 | class TEWidget; | 29 | class TEWidget; |
30 | class TEmulation; | 30 | class TEmulation; |
31 | class QFont; | 31 | class QFont; |
32 | class Script; | 32 | class Script; |
33 | class EmulationHandler : public QObject { | 33 | class EmulationHandler : public QObject { |
34 | Q_OBJECT | 34 | Q_OBJECT |
35 | public: | 35 | public: |
36 | /** | 36 | /** |
37 | * simple c'tor the parent of the TEWdiget | 37 | * simple c'tor the parent of the TEWdiget |
38 | * and a name | 38 | * and a name |
39 | * and a Profile | 39 | * and a Profile |
40 | */ | 40 | */ |
41 | EmulationHandler( const Profile&, QWidget* parent, const char* name = 0l ); | 41 | EmulationHandler( const Profile&, QWidget* parent, const char* name = 0l ); |
42 | 42 | ||
43 | /** | 43 | /** |
44 | * delete all components | 44 | * delete all components |
45 | */ | 45 | */ |
46 | ~EmulationHandler(); | 46 | ~EmulationHandler(); |
47 | 47 | ||
48 | void load( const Profile& ); | 48 | void load( const Profile& ); |
49 | QWidget* widget(); | 49 | QWidget* widget(); |
50 | void setColor( const QColor& fore, const QColor& back ); | 50 | void setColor( const QColor& fore, const QColor& back ); |
51 | QPushButton* cornerButton(); | 51 | QPushButton* cornerButton(); |
52 | 52 | ||
53 | /* Scripts */ | 53 | /* Scripts */ |
54 | /* Create a new script and record all typed characters */ | 54 | /* Create a new script and record all typed characters */ |
55 | void startRecording(); | 55 | void startRecording(); |
56 | 56 | ||
57 | /* Return whether we are currently recording a script */ | 57 | /* Return whether we are currently recording a script */ |
58 | bool isRecording(); | 58 | bool isRecording(); |
59 | 59 | ||
60 | /* Return the current script (or NULL) */ | 60 | /* Return the current script (or NULL) */ |
61 | Script *script(); | 61 | Script *script(); |
62 | 62 | ||
63 | /* Stop recording and remove the current script from memory */ | 63 | /* Stop recording and remove the current script from memory */ |
64 | void clearScript(); | 64 | void clearScript(); |
65 | 65 | ||
66 | /* Run a script by forwarding its keys to the EmulationLayer */ | 66 | /* Run a script by forwarding its keys to the EmulationLayer */ |
67 | void runScript(const Script *); | 67 | void runScript(const Script *); |
68 | 68 | ||
69 | signals: | 69 | signals: |
70 | void send( const QByteArray& ); | 70 | void send( const QByteArray& ); |
71 | void changeSize(int rows, int cols ); | 71 | void changeSize(int rows, int cols ); |
72 | 72 | ||
73 | 73 | ||
74 | public slots: | 74 | public slots: |
75 | void recv( const QByteArray& ); | 75 | void recv( const QByteArray& ); |
76 | void paste(); | ||
77 | void copy(); | ||
76 | 78 | ||
77 | private slots: | 79 | private slots: |
78 | void recvEmulation( const char*, int len ); | 80 | void recvEmulation( const char*, int len ); |
79 | private: | 81 | private: |
80 | QFont font( int ); | 82 | QFont font( int ); |
81 | QColor foreColor(int ); | 83 | QColor foreColor(int ); |
82 | QColor backColor(int ); | 84 | QColor backColor(int ); |
83 | 85 | ||
84 | private: | 86 | private: |
85 | TEWidget* m_teWid; | 87 | TEWidget* m_teWid; |
86 | TEmulation* m_teEmu; | 88 | TEmulation* m_teEmu; |
87 | Script * m_script; | 89 | Script * m_script; |
88 | }; | 90 | }; |
89 | 91 | ||
90 | #endif | 92 | #endif |
diff --git a/noncore/apps/opie-console/file_layer.cpp b/noncore/apps/opie-console/file_layer.cpp index 43e9c8f..0c83700 100644 --- a/noncore/apps/opie-console/file_layer.cpp +++ b/noncore/apps/opie-console/file_layer.cpp | |||
@@ -1,23 +1,23 @@ | |||
1 | #include <qfile.h> | 1 | #include <qfile.h> |
2 | #include <opie/oprocess.h> | 2 | #include <opie/oprocess.h> |
3 | 3 | ||
4 | #include "file_layer.h" | 4 | #include "file_layer.h" |
5 | 5 | ||
6 | FileTransferLayer::FileTransferLayer(IOLayer *layer) | 6 | FileTransferLayer::FileTransferLayer(IOLayer *layer) |
7 | : QObject(), m_layer( layer ) | 7 | : QObject(), m_layer( layer ) |
8 | { | 8 | { |
9 | } | 9 | } |
10 | 10 | ||
11 | FileTransferLayer::~FileTransferLayer() { | 11 | FileTransferLayer::~FileTransferLayer() { |
12 | } | 12 | } |
13 | 13 | ||
14 | void FileTransferLayer::sendFile(const QFile& file) { | 14 | void FileTransferLayer::sendFile(const QFile&) { |
15 | 15 | ||
16 | } | 16 | } |
17 | 17 | ||
18 | void FileTransferLayer::sendFile(const QString& file) { | 18 | void FileTransferLayer::sendFile(const QString&) { |
19 | } | 19 | } |
20 | 20 | ||
21 | IOLayer* FileTransferLayer::layer() { | 21 | IOLayer* FileTransferLayer::layer() { |
22 | return m_layer; | 22 | return m_layer; |
23 | } | 23 | } |
diff --git a/noncore/apps/opie-console/io_bt.cpp b/noncore/apps/opie-console/io_bt.cpp index 4486eea..8dd8151 100644 --- a/noncore/apps/opie-console/io_bt.cpp +++ b/noncore/apps/opie-console/io_bt.cpp | |||
@@ -1,77 +1,80 @@ | |||
1 | 1 | ||
2 | #include "io_bt.h" | 2 | #include "io_bt.h" |
3 | 3 | ||
4 | IOBt::IOBt( const Profile &config ) : IOSerial( config ) { | 4 | IOBt::IOBt( const Profile &config ) : IOSerial( config ) { |
5 | m_attach = 0; | 5 | m_attach = 0; |
6 | } | 6 | } |
7 | 7 | ||
8 | 8 | ||
9 | IOBt::~IOBt() { | 9 | IOBt::~IOBt() { |
10 | if ( m_attach ) { | 10 | if ( m_attach ) { |
11 | delete m_attach; | 11 | delete m_attach; |
12 | } | 12 | } |
13 | } | 13 | } |
14 | 14 | ||
15 | 15 | ||
16 | void IOBt::close() { | 16 | void IOBt::close() { |
17 | 17 | ||
18 | IOSerial::close(); | 18 | IOSerial::close(); |
19 | // still need error handling | 19 | // still need error handling |
20 | if ( m_attach ) { | 20 | if ( m_attach ) { |
21 | delete m_attach; | 21 | delete m_attach; |
22 | m_attach = 0; | 22 | m_attach = 0; |
23 | } | 23 | } |
24 | } | 24 | } |
25 | 25 | ||
26 | bool IOBt::open() { | 26 | bool IOBt::open() { |
27 | bool ret = false; | ||
27 | 28 | ||
28 | // only set up bt stuff if mac address was set, otherwise use the device set | 29 | // only set up bt stuff if mac address was set, otherwise use the device set |
29 | if ( !m_mac.isEmpty() ) { | 30 | if ( !m_mac.isEmpty() ) { |
30 | 31 | ||
31 | // now it should also be checked, if there is a connection to the device with that mac allready | 32 | // now it should also be checked, if there is a connection to the device with that mac allready |
32 | // hciattach here | 33 | // hciattach here |
33 | m_attach = new OProcess(); | 34 | m_attach = new OProcess(); |
34 | *m_attach << "hciattach /dev/ttyS2 any 57600"; | 35 | *m_attach << "hciattach /dev/ttyS2 any 57600"; |
35 | 36 | ||
36 | // then start hcid, then rcfomm handling (m_mac) | 37 | // then start hcid, then rcfomm handling (m_mac) |
37 | 38 | ||
38 | connect( m_attach, SIGNAL( processExited( OProcess* ) ), | 39 | connect( m_attach, SIGNAL( processExited( OProcess* ) ), |
39 | this, SLOT( slotExited( OProcess* ) ) ); | 40 | this, SLOT( slotExited( OProcess* ) ) ); |
40 | 41 | ||
41 | if ( m_attach->start() ) { | 42 | if ( m_attach->start() ) { |
42 | IOSerial::open(); | 43 | ret = IOSerial::open(); |
43 | } else { | 44 | } else { |
44 | qWarning("could not attach to device"); | 45 | qWarning("could not attach to device"); |
45 | delete m_attach; | 46 | delete m_attach; |
46 | m_attach = 0; | 47 | m_attach = 0; |
47 | } | 48 | } |
48 | } else { | 49 | } else { |
49 | // directly to the normal serial | 50 | // directly to the normal serial |
50 | // TODO: look first if the connection really exists. ( is set up ) | 51 | // TODO: look first if the connection really exists. ( is set up ) |
51 | 52 | ||
52 | IOSerial::open(); | 53 | ret =IOSerial::open(); |
53 | } | 54 | } |
55 | return ret; | ||
54 | } | 56 | } |
55 | 57 | ||
56 | void IOBt::reload( const Profile &config ) { | 58 | void IOBt::reload( const Profile &config ) { |
57 | m_device = config.readEntry("Device", BT_DEFAULT_DEVICE); | 59 | m_device = config.readEntry("Device", BT_DEFAULT_DEVICE); |
58 | m_mac = config.readEntry("Mac", BT_DEFAULT_MAC); | 60 | m_mac = config.readEntry("Mac", BT_DEFAULT_MAC); |
59 | m_baud = config.readNumEntry("Baud", BT_DEFAULT_BAUD); | 61 | m_baud = config.readNumEntry("Baud", BT_DEFAULT_BAUD); |
60 | m_parity = config.readNumEntry("Parity", BT_DEFAULT_PARITY); | 62 | m_parity = config.readNumEntry("Parity", BT_DEFAULT_PARITY); |
61 | m_dbits = config.readNumEntry("DataBits", BT_DEFAULT_DBITS); | 63 | m_dbits = config.readNumEntry("DataBits", BT_DEFAULT_DBITS); |
62 | m_sbits = config.readNumEntry("StopBits", BT_DEFAULT_SBITS); | 64 | m_sbits = config.readNumEntry("StopBits", BT_DEFAULT_SBITS); |
63 | m_flow = config.readNumEntry("Flow", BT_DEFAULT_FLOW); | 65 | m_flow = config.readNumEntry("Flow", BT_DEFAULT_FLOW); |
64 | } | 66 | } |
65 | 67 | ||
66 | 68 | ||
67 | QString IOBt::identifier() const { | 69 | QString IOBt::identifier() const { |
68 | return "bluetooth"; | 70 | return "bluetooth"; |
69 | } | 71 | } |
70 | 72 | ||
71 | QString IOBt::name() const { | 73 | QString IOBt::name() const { |
72 | return "BLuetooth IO Layer"; | 74 | return "BLuetooth IO Layer"; |
73 | } | 75 | } |
74 | 76 | ||
75 | void IOBt::slotExited( OProcess* proc ){ | 77 | void IOBt::slotExited( OProcess* proc ){ |
76 | close(); | 78 | close(); |
79 | delete proc; | ||
77 | } | 80 | } |
diff --git a/noncore/apps/opie-console/io_irda.cpp b/noncore/apps/opie-console/io_irda.cpp index 56a373c..b3b693f 100644 --- a/noncore/apps/opie-console/io_irda.cpp +++ b/noncore/apps/opie-console/io_irda.cpp | |||
@@ -1,62 +1,65 @@ | |||
1 | 1 | ||
2 | #include "io_irda.h" | 2 | #include "io_irda.h" |
3 | 3 | ||
4 | IOIrda::IOIrda( const Profile &config ) : IOSerial( config ) { | 4 | IOIrda::IOIrda( const Profile &config ) : IOSerial( config ) { |
5 | m_attach = 0; | 5 | m_attach = 0; |
6 | } | 6 | } |
7 | 7 | ||
8 | 8 | ||
9 | IOIrda::~IOIrda() { | 9 | IOIrda::~IOIrda() { |
10 | if ( m_attach ) { | 10 | if ( m_attach ) { |
11 | delete m_attach; | 11 | delete m_attach; |
12 | } | 12 | } |
13 | } | 13 | } |
14 | 14 | ||
15 | 15 | ||
16 | void IOIrda::close() { | 16 | void IOIrda::close() { |
17 | 17 | ||
18 | IOSerial::close(); | 18 | IOSerial::close(); |
19 | // still need error handling | 19 | // still need error handling |
20 | delete m_attach; | 20 | delete m_attach; |
21 | } | 21 | } |
22 | 22 | ||
23 | bool IOIrda::open() { | 23 | bool IOIrda::open() { |
24 | bool ret; | ||
24 | 25 | ||
25 | // irdaattach here | 26 | // irdaattach here |
26 | m_attach = new OProcess(); | 27 | m_attach = new OProcess(); |
27 | *m_attach << "irattach /dev/ttyS2 -s"; | 28 | *m_attach << "irattach /dev/ttyS2 -s"; |
28 | 29 | ||
29 | connect( m_attach, SIGNAL( processExited( OProcess* ) ), | 30 | connect( m_attach, SIGNAL( processExited( OProcess* ) ), |
30 | this, SLOT( slotExited( OProcess* ) ) ); | 31 | this, SLOT( slotExited( OProcess* ) ) ); |
31 | 32 | ||
32 | if ( m_attach->start() ) { | 33 | if ( m_attach->start() ) { |
33 | IOSerial::open(); | 34 | ret= IOSerial::open(); |
34 | } else { | 35 | } else { |
35 | // emit error!!! | 36 | // emit error!!! |
36 | qWarning("could not attach to device"); | 37 | qWarning("could not attach to device"); |
37 | delete m_attach; | 38 | delete m_attach; |
38 | m_attach = 0l; | 39 | m_attach = 0l; |
39 | } | 40 | } |
41 | return ret; | ||
40 | } | 42 | } |
41 | 43 | ||
42 | void IOIrda::reload( const Profile &config ) { | 44 | void IOIrda::reload( const Profile &config ) { |
43 | m_device = config.readEntry("Device", IRDA_DEFAULT_DEVICE); | 45 | m_device = config.readEntry("Device", IRDA_DEFAULT_DEVICE); |
44 | m_baud = config.readNumEntry("Baud", IRDA_DEFAULT_BAUD); | 46 | m_baud = config.readNumEntry("Baud", IRDA_DEFAULT_BAUD); |
45 | m_parity = config.readNumEntry("Parity", IRDA_DEFAULT_PARITY); | 47 | m_parity = config.readNumEntry("Parity", IRDA_DEFAULT_PARITY); |
46 | m_dbits = config.readNumEntry("DataBits", IRDA_DEFAULT_DBITS); | 48 | m_dbits = config.readNumEntry("DataBits", IRDA_DEFAULT_DBITS); |
47 | m_sbits = config.readNumEntry("StopBits", IRDA_DEFAULT_SBITS); | 49 | m_sbits = config.readNumEntry("StopBits", IRDA_DEFAULT_SBITS); |
48 | m_flow = config.readNumEntry("Flow", IRDA_DEFAULT_FLOW); | 50 | m_flow = config.readNumEntry("Flow", IRDA_DEFAULT_FLOW); |
49 | } | 51 | } |
50 | 52 | ||
51 | 53 | ||
52 | QString IOIrda::identifier() const { | 54 | QString IOIrda::identifier() const { |
53 | return "irda"; | 55 | return "irda"; |
54 | } | 56 | } |
55 | 57 | ||
56 | QString IOIrda::name() const { | 58 | QString IOIrda::name() const { |
57 | return "Irda IO Layer"; | 59 | return "Irda IO Layer"; |
58 | } | 60 | } |
59 | 61 | ||
60 | void IOIrda::slotExited(OProcess* proc ){ | 62 | void IOIrda::slotExited(OProcess* proc ){ |
61 | close(); | 63 | close(); |
64 | delete proc; | ||
62 | } | 65 | } |
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp index e2f4d12..02a3fa9 100644 --- a/noncore/apps/opie-console/mainwindow.cpp +++ b/noncore/apps/opie-console/mainwindow.cpp | |||
@@ -1,541 +1,588 @@ | |||
1 | #include <assert.h> | 1 | #include <assert.h> |
2 | 2 | ||
3 | #include <qaction.h> | 3 | #include <qaction.h> |
4 | #include <qmenubar.h> | 4 | #include <qmenubar.h> |
5 | #include <qlabel.h> | 5 | #include <qlabel.h> |
6 | #include <qpopupmenu.h> | 6 | #include <qpopupmenu.h> |
7 | #include <qtoolbar.h> | 7 | #include <qtoolbar.h> |
8 | #include <qmessagebox.h> | 8 | #include <qmessagebox.h> |
9 | #include <qpushbutton.h> | 9 | #include <qpushbutton.h> |
10 | #include <qwhatsthis.h> | 10 | #include <qwhatsthis.h> |
11 | 11 | ||
12 | #include <qpe/resource.h> | 12 | #include <qpe/resource.h> |
13 | 13 | ||
14 | #include <opie/ofiledialog.h> | 14 | #include <opie/ofiledialog.h> |
15 | 15 | ||
16 | #include "keytrans.h" | 16 | #include "keytrans.h" |
17 | #include "profileeditordialog.h" | 17 | #include "profileeditordialog.h" |
18 | #include "configdialog.h" | 18 | #include "configdialog.h" |
19 | #include "default.h" | 19 | #include "default.h" |
20 | #include "metafactory.h" | 20 | #include "metafactory.h" |
21 | #include "profile.h" | 21 | #include "profile.h" |
22 | #include "profilemanager.h" | 22 | #include "profilemanager.h" |
23 | #include "mainwindow.h" | 23 | #include "mainwindow.h" |
24 | #include "tabwidget.h" | 24 | #include "tabwidget.h" |
25 | #include "transferdialog.h" | 25 | #include "transferdialog.h" |
26 | #include "function_keyboard.h" | 26 | #include "function_keyboard.h" |
27 | #include "emulation_handler.h" | 27 | #include "emulation_handler.h" |
28 | #include "script.h" | 28 | #include "script.h" |
29 | #include "quick_button.h" | 29 | #include "quick_button.h" |
30 | 30 | ||
31 | 31 | ||
32 | 32 | ||
33 | MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) { | 33 | MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) { |
34 | KeyTrans::loadAll(); | 34 | KeyTrans::loadAll(); |
35 | for (int i = 0; i < KeyTrans::count(); i++ ) { | 35 | for (int i = 0; i < KeyTrans::count(); i++ ) { |
36 | KeyTrans* s = KeyTrans::find(i ); | 36 | KeyTrans* s = KeyTrans::find(i ); |
37 | assert( s ); | 37 | assert( s ); |
38 | } | 38 | } |
39 | m_factory = new MetaFactory(); | 39 | m_factory = new MetaFactory(); |
40 | Default def(m_factory); | 40 | Default def(m_factory); |
41 | m_sessions.setAutoDelete( TRUE ); | 41 | m_sessions.setAutoDelete( TRUE ); |
42 | m_curSession = 0; | 42 | m_curSession = 0; |
43 | m_manager = new ProfileManager( m_factory ); | 43 | m_manager = new ProfileManager( m_factory ); |
44 | m_manager->load(); | 44 | m_manager->load(); |
45 | 45 | ||
46 | initUI(); | 46 | initUI(); |
47 | populateProfiles(); | 47 | populateProfiles(); |
48 | } | 48 | } |
49 | void MainWindow::initUI() { | 49 | void MainWindow::initUI() { |
50 | setToolBarsMovable( FALSE ); | 50 | setToolBarsMovable( FALSE ); |
51 | 51 | ||
52 | /* tool bar for the menu */ | 52 | /* tool bar for the menu */ |
53 | m_tool = new QToolBar( this ); | 53 | m_tool = new QToolBar( this ); |
54 | m_tool->setHorizontalStretchable( TRUE ); | 54 | m_tool->setHorizontalStretchable( TRUE ); |
55 | 55 | ||
56 | m_bar = new QMenuBar( m_tool ); | 56 | m_bar = new QMenuBar( m_tool ); |
57 | m_console = new QPopupMenu( this ); | 57 | m_console = new QPopupMenu( this ); |
58 | m_scripts = new QPopupMenu( this ); | 58 | m_scripts = new QPopupMenu( this ); |
59 | m_sessionsPop= new QPopupMenu( this ); | 59 | m_sessionsPop= new QPopupMenu( this ); |
60 | //m_settings = new QPopupMenu( this ); | 60 | //m_settings = new QPopupMenu( this ); |
61 | 61 | ||
62 | /* add a toolbar for icons */ | 62 | /* add a toolbar for icons */ |
63 | m_icons = new QToolBar(this); | 63 | m_icons = new QToolBar(this); |
64 | 64 | ||
65 | 65 | ||
66 | 66 | ||
67 | 67 | ||
68 | /* | 68 | /* |
69 | * the settings action | 69 | * the settings action |
70 | */ | 70 | */ |
71 | m_setProfiles = new QAction(tr("Configure Profiles"), | 71 | m_setProfiles = new QAction(tr("Configure Profiles"), |
72 | Resource::loadPixmap( "SettingsIcon" ), | 72 | Resource::loadPixmap( "SettingsIcon" ), |
73 | QString::null, 0, this, 0); | 73 | QString::null, 0, this, 0); |
74 | // m_setProfiles->addTo( m_settings ); | 74 | // m_setProfiles->addTo( m_settings ); |
75 | m_setProfiles->addTo( m_icons ); | 75 | m_setProfiles->addTo( m_icons ); |
76 | m_setProfiles->addTo( m_console ); | 76 | m_setProfiles->addTo( m_console ); |
77 | connect( m_setProfiles, SIGNAL(activated() ), | 77 | connect( m_setProfiles, SIGNAL(activated() ), |
78 | this, SLOT(slotConfigure() ) ); | 78 | this, SLOT(slotConfigure() ) ); |
79 | 79 | ||
80 | m_console->insertSeparator(); | 80 | m_console->insertSeparator(); |
81 | /* | 81 | /* |
82 | * new Action for new sessions | 82 | * new Action for new sessions |
83 | */ | 83 | */ |
84 | QAction* a = new QAction(tr("New Connection"), | 84 | QAction* a = new QAction(tr("New Connection"), |
85 | Resource::loadPixmap( "new" ), | 85 | Resource::loadPixmap( "new" ), |
86 | QString::null, 0, this, 0); | 86 | QString::null, 0, this, 0); |
87 | a->addTo( m_console ); | 87 | a->addTo( m_console ); |
88 | a->addTo( m_icons ); | 88 | a->addTo( m_icons ); |
89 | connect(a, SIGNAL(activated() ), | 89 | connect(a, SIGNAL(activated() ), |
90 | this, SLOT(slotNew() ) ); | 90 | this, SLOT(slotNew() ) ); |
91 | 91 | ||
92 | m_console->insertSeparator(); | ||
93 | /* save icon is not available */ | ||
94 | a = new QAction(tr("Save Connection"), | ||
95 | Resource::loadPixmap("save"), QString::null, | ||
96 | 0, this, 0 ); | ||
97 | a->addTo( m_console ); | ||
98 | connect(a, SIGNAL(activated() ), | ||
99 | this, SLOT(slotSaveSession() ) ); | ||
100 | m_console->insertSeparator(); | ||
101 | |||
92 | /* | 102 | /* |
93 | * connect action | 103 | * connect action |
94 | */ | 104 | */ |
95 | m_connect = new QAction(); | 105 | m_connect = new QAction(); |
96 | m_connect->setText( tr("Connect") ); | 106 | m_connect->setText( tr("Connect") ); |
97 | m_connect->addTo( m_console ); | 107 | m_connect->addTo( m_console ); |
98 | connect(m_connect, SIGNAL(activated() ), | 108 | connect(m_connect, SIGNAL(activated() ), |
99 | this, SLOT(slotConnect() ) ); | 109 | this, SLOT(slotConnect() ) ); |
100 | 110 | ||
101 | /* | 111 | /* |
102 | * disconnect action | 112 | * disconnect action |
103 | */ | 113 | */ |
104 | m_disconnect = new QAction(); | 114 | m_disconnect = new QAction(); |
105 | m_disconnect->setText( tr("Disconnect") ); | 115 | m_disconnect->setText( tr("Disconnect") ); |
106 | m_disconnect->addTo( m_console ); | 116 | m_disconnect->addTo( m_console ); |
107 | connect(m_disconnect, SIGNAL(activated() ), | 117 | connect(m_disconnect, SIGNAL(activated() ), |
108 | this, SLOT(slotDisconnect() ) ); | 118 | this, SLOT(slotDisconnect() ) ); |
109 | 119 | ||
110 | m_console->insertSeparator(); | 120 | m_console->insertSeparator(); |
111 | 121 | ||
112 | m_transfer = new QAction(); | 122 | m_transfer = new QAction(); |
113 | m_transfer->setText( tr("Transfer file...") ); | 123 | m_transfer->setText( tr("Transfer file...") ); |
114 | m_transfer->addTo( m_console ); | 124 | m_transfer->addTo( m_console ); |
115 | connect(m_transfer, SIGNAL(activated() ), | 125 | connect(m_transfer, SIGNAL(activated() ), |
116 | this, SLOT(slotTransfer() ) ); | 126 | this, SLOT(slotTransfer() ) ); |
117 | 127 | ||
118 | 128 | ||
119 | /* | 129 | /* |
120 | * fullscreen | 130 | * fullscreen |
121 | */ | 131 | */ |
122 | m_isFullscreen = false; | 132 | m_isFullscreen = false; |
123 | 133 | ||
124 | m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" ) | 134 | m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" ) |
125 | , QString::null, 0, this, 0); | 135 | , QString::null, 0, this, 0); |
126 | m_fullscreen->addTo( m_console ); | 136 | m_fullscreen->addTo( m_console ); |
127 | m_fullscreen->addTo( m_icons ); | 137 | m_fullscreen->addTo( m_icons ); |
128 | connect( m_fullscreen, SIGNAL( activated() ), | 138 | connect( m_fullscreen, SIGNAL( activated() ), |
129 | this, SLOT( slotFullscreen() ) ); | 139 | this, SLOT( slotFullscreen() ) ); |
130 | 140 | ||
131 | m_console->insertSeparator(); | 141 | m_console->insertSeparator(); |
132 | /* | 142 | /* |
133 | * terminate action | 143 | * terminate action |
134 | */ | 144 | */ |
135 | m_terminate = new QAction(); | 145 | m_terminate = new QAction(); |
136 | m_terminate->setText( tr("Terminate") ); | 146 | m_terminate->setText( tr("Terminate") ); |
137 | m_terminate->addTo( m_console ); | 147 | m_terminate->addTo( m_console ); |
138 | connect(m_terminate, SIGNAL(activated() ), | 148 | connect(m_terminate, SIGNAL(activated() ), |
139 | this, SLOT(slotTerminate() ) ); | 149 | this, SLOT(slotTerminate() ) ); |
140 | 150 | ||
141 | m_closewindow = new QAction(); | 151 | m_closewindow = new QAction(); |
142 | m_closewindow->setText( tr("Close Window") ); | 152 | m_closewindow->setText( tr("Close Window") ); |
143 | m_closewindow->addTo( m_console ); | 153 | m_closewindow->addTo( m_console ); |
144 | connect( m_closewindow, SIGNAL(activated() ), | 154 | connect( m_closewindow, SIGNAL(activated() ), |
145 | this, SLOT(slotClose() ) ); | 155 | this, SLOT(slotClose() ) ); |
146 | 156 | ||
147 | 157 | ||
148 | /* | 158 | /* |
149 | * script actions | 159 | * script actions |
150 | */ | 160 | */ |
151 | m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0); | 161 | m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0); |
152 | m_recordScript->addTo(m_scripts); | 162 | m_recordScript->addTo(m_scripts); |
153 | connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript())); | 163 | connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript())); |
154 | 164 | ||
155 | m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0); | 165 | m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0); |
156 | m_saveScript->addTo(m_scripts); | 166 | m_saveScript->addTo(m_scripts); |
157 | connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript())); | 167 | connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript())); |
158 | 168 | ||
159 | m_runScript = new QAction(tr("Run Script"), QString::null, 0, this, 0); | 169 | m_runScript = new QAction(tr("Run Script"), QString::null, 0, this, 0); |
160 | m_runScript->addTo(m_scripts); | 170 | m_runScript->addTo(m_scripts); |
161 | connect(m_runScript, SIGNAL(activated()), this, SLOT(slotRunScript())); | 171 | connect(m_runScript, SIGNAL(activated()), this, SLOT(slotRunScript())); |
162 | 172 | ||
163 | /* | 173 | /* |
164 | * action that open/closes the keyboard | 174 | * action that open/closes the keyboard |
165 | */ | 175 | */ |
166 | m_openKeys = new QAction (tr("Open Keyboard..."), | 176 | m_openKeys = new QAction (tr("Open Keyboard..."), |
167 | Resource::loadPixmap( "down" ), | 177 | Resource::loadPixmap( "down" ), |
168 | QString::null, 0, this, 0); | 178 | QString::null, 0, this, 0); |
169 | 179 | ||
170 | m_openKeys->setToggleAction(true); | 180 | m_openKeys->setToggleAction(true); |
171 | 181 | ||
172 | connect (m_openKeys, SIGNAL(toggled(bool)), | 182 | connect (m_openKeys, SIGNAL(toggled(bool)), |
173 | this, SLOT(slotOpenKeb(bool))); | 183 | this, SLOT(slotOpenKeb(bool))); |
174 | m_openKeys->addTo(m_icons); | 184 | m_openKeys->addTo(m_icons); |
175 | 185 | ||
176 | 186 | ||
177 | /* | 187 | /* |
178 | * action that open/closes the keyboard | 188 | * action that open/closes the keyboard |
179 | 189 | ||
180 | m_openButtons = new QAction ( tr( "Open Buttons..." ), | 190 | m_openButtons = new QAction ( tr( "Open Buttons..." ), |
181 | Resource::loadPixmap( "" ), | 191 | Resource::loadPixmap( "" ), |
182 | QString::null, 0, this, 0 ); | 192 | QString::null, 0, this, 0 ); |
183 | 193 | ||
184 | m_openButtons->setToggleAction( true ); | 194 | m_openButtons->setToggleAction( true ); |
185 | 195 | ||
186 | connect ( m_openButtons, SIGNAL( toggled( bool ) ), | 196 | connect ( m_openButtons, SIGNAL( toggled( bool ) ), |
187 | this, SLOT( slotOpenButtons( bool ) ) ); | 197 | this, SLOT( slotOpenButtons( bool ) ) ); |
188 | m_openButtons->addTo( m_icons ); | 198 | m_openButtons->addTo( m_icons ); |
189 | 199 | ||
190 | */ | 200 | */ |
191 | 201 | ||
192 | /* insert the submenu */ | 202 | /* insert the submenu */ |
193 | m_console->insertItem(tr("New from Profile"), m_sessionsPop, | 203 | m_console->insertItem(tr("New from Profile"), m_sessionsPop, |
194 | -1, 0); | 204 | -1, 0); |
195 | 205 | ||
196 | /* insert the connection menu */ | 206 | /* insert the connection menu */ |
197 | m_bar->insertItem( tr("Connection"), m_console ); | 207 | m_bar->insertItem( tr("Connection"), m_console ); |
198 | 208 | ||
199 | /* the scripts menu */ | 209 | /* the scripts menu */ |
200 | m_bar->insertItem( tr("Scripts"), m_scripts ); | 210 | m_bar->insertItem( tr("Scripts"), m_scripts ); |
201 | 211 | ||
202 | /* the settings menu */ | 212 | /* the settings menu */ |
203 | // m_bar->insertItem( tr("Settings"), m_settings ); | 213 | // m_bar->insertItem( tr("Settings"), m_settings ); |
204 | 214 | ||
205 | /* and the keyboard */ | 215 | /* and the keyboard */ |
206 | m_keyBar = new QToolBar(this); | 216 | m_keyBar = new QToolBar(this); |
207 | addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); | 217 | addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); |
208 | m_keyBar->setHorizontalStretchable( TRUE ); | 218 | m_keyBar->setHorizontalStretchable( TRUE ); |
209 | m_keyBar->hide(); | 219 | m_keyBar->hide(); |
210 | 220 | ||
211 | m_kb = new FunctionKeyboard(m_keyBar); | 221 | m_kb = new FunctionKeyboard(m_keyBar); |
212 | connect(m_kb, SIGNAL(keyPressed(FKey, ushort, ushort, bool)), | 222 | connect(m_kb, SIGNAL(keyPressed(FKey, ushort, ushort, bool)), |
213 | this, SLOT(slotKeyReceived(FKey, ushort, ushort, bool))); | 223 | this, SLOT(slotKeyReceived(FKey, ushort, ushort, bool))); |
214 | 224 | ||
215 | m_buttonBar = new QToolBar( this ); | 225 | m_buttonBar = new QToolBar( this ); |
216 | addToolBar( m_buttonBar, "Buttons", QMainWindow::Top, TRUE ); | 226 | addToolBar( m_buttonBar, "Buttons", QMainWindow::Top, TRUE ); |
217 | m_buttonBar->setHorizontalStretchable( TRUE ); | 227 | m_buttonBar->setHorizontalStretchable( TRUE ); |
218 | m_buttonBar->hide(); | 228 | m_buttonBar->hide(); |
219 | 229 | ||
220 | /* | 230 | /* |
221 | m_qb = new QuickButton( m_buttonBar ); | 231 | m_qb = new QuickButton( m_buttonBar ); |
222 | connect( m_qb, SIGNAL( keyPressed( ushort, ushort, bool, bool, bool) ), | 232 | connect( m_qb, SIGNAL( keyPressed( ushort, ushort, bool, bool, bool) ), |
223 | this, SLOT( slotKeyReceived( ushort, ushort, bool, bool, bool) ) ); | 233 | this, SLOT( slotKeyReceived( ushort, ushort, bool, bool, bool) ) ); |
224 | */ | 234 | */ |
235 | /* now add the copy and paste actions */ | ||
236 | a = new QAction(tr("Copy"), | ||
237 | Resource::loadPixmap("copy"), QString::null, | ||
238 | 0, this, 0 ); | ||
239 | //a->addTo( m_icons ); | ||
240 | connect( a, SIGNAL(activated() ), | ||
241 | this, SLOT(slotCopy() ) ); | ||
242 | |||
243 | a = new QAction(tr("Paste"), | ||
244 | Resource::loadPixmap("paste"), QString::null, | ||
245 | 0, this, 0 ); | ||
246 | a->addTo( m_icons ); | ||
247 | connect( a, SIGNAL(activated() ), | ||
248 | this, SLOT(slotPaste() ) ); | ||
225 | 249 | ||
226 | 250 | ||
227 | m_connect->setEnabled( false ); | 251 | m_connect->setEnabled( false ); |
228 | m_disconnect->setEnabled( false ); | 252 | m_disconnect->setEnabled( false ); |
229 | m_terminate->setEnabled( false ); | 253 | m_terminate->setEnabled( false ); |
230 | m_transfer->setEnabled( false ); | 254 | m_transfer->setEnabled( false ); |
231 | m_recordScript->setEnabled( false ); | 255 | m_recordScript->setEnabled( false ); |
232 | m_saveScript->setEnabled( false ); | 256 | m_saveScript->setEnabled( false ); |
233 | m_runScript->setEnabled( false ); | 257 | m_runScript->setEnabled( false ); |
234 | m_fullscreen->setEnabled( false ); | 258 | m_fullscreen->setEnabled( false ); |
235 | m_closewindow->setEnabled( false ); | 259 | m_closewindow->setEnabled( false ); |
236 | 260 | ||
237 | /* | 261 | /* |
238 | * connect to the menu activation | 262 | * connect to the menu activation |
239 | */ | 263 | */ |
240 | connect( m_sessionsPop, SIGNAL(activated( int ) ), | 264 | connect( m_sessionsPop, SIGNAL(activated( int ) ), |
241 | this, SLOT(slotProfile( int ) ) ); | 265 | this, SLOT(slotProfile( int ) ) ); |
242 | 266 | ||
243 | m_consoleWindow = new TabWidget( this, "blah"); | 267 | m_consoleWindow = new TabWidget( this, "blah"); |
244 | connect(m_consoleWindow, SIGNAL(activated(Session*) ), | 268 | connect(m_consoleWindow, SIGNAL(activated(Session*) ), |
245 | this, SLOT(slotSessionChanged(Session*) ) ); | 269 | this, SLOT(slotSessionChanged(Session*) ) ); |
246 | setCentralWidget( m_consoleWindow ); | 270 | setCentralWidget( m_consoleWindow ); |
247 | 271 | ||
248 | } | 272 | } |
249 | 273 | ||
250 | ProfileManager* MainWindow::manager() { | 274 | ProfileManager* MainWindow::manager() { |
251 | return m_manager; | 275 | return m_manager; |
252 | } | 276 | } |
253 | TabWidget* MainWindow::tabWidget() { | 277 | TabWidget* MainWindow::tabWidget() { |
254 | return m_consoleWindow; | 278 | return m_consoleWindow; |
255 | } | 279 | } |
256 | void MainWindow::populateProfiles() { | 280 | void MainWindow::populateProfiles() { |
257 | m_sessionsPop->clear(); | 281 | m_sessionsPop->clear(); |
258 | Profile::ValueList list = manager()->all(); | 282 | Profile::ValueList list = manager()->all(); |
259 | for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { | 283 | for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { |
260 | m_sessionsPop->insertItem( (*it).name() ); | 284 | m_sessionsPop->insertItem( (*it).name() ); |
261 | } | 285 | } |
262 | 286 | ||
263 | } | 287 | } |
264 | MainWindow::~MainWindow() { | 288 | MainWindow::~MainWindow() { |
265 | delete m_factory; | 289 | delete m_factory; |
266 | manager()->save(); | 290 | manager()->save(); |
267 | } | 291 | } |
268 | 292 | ||
269 | MetaFactory* MainWindow::factory() { | 293 | MetaFactory* MainWindow::factory() { |
270 | return m_factory; | 294 | return m_factory; |
271 | } | 295 | } |
272 | 296 | ||
273 | Session* MainWindow::currentSession() { | 297 | Session* MainWindow::currentSession() { |
274 | return m_curSession; | 298 | return m_curSession; |
275 | } | 299 | } |
276 | 300 | ||
277 | QList<Session> MainWindow::sessions() { | 301 | QList<Session> MainWindow::sessions() { |
278 | return m_sessions; | 302 | return m_sessions; |
279 | } | 303 | } |
280 | 304 | ||
281 | void MainWindow::slotNew() { | 305 | void MainWindow::slotNew() { |
282 | ProfileEditorDialog dlg(factory() ); | 306 | ProfileEditorDialog dlg(factory() ); |
283 | dlg.showMaximized(); | 307 | dlg.showMaximized(); |
284 | int ret = dlg.exec(); | 308 | int ret = dlg.exec(); |
285 | 309 | ||
286 | if ( ret == QDialog::Accepted ) { | 310 | if ( ret == QDialog::Accepted ) { |
287 | create( dlg.profile() ); | 311 | create( dlg.profile() ); |
288 | } | 312 | } |
289 | } | 313 | } |
290 | 314 | ||
291 | void MainWindow::slotRecordScript() { | 315 | void MainWindow::slotRecordScript() { |
292 | if (currentSession()) { | 316 | if (currentSession()) { |
293 | currentSession()->emulationHandler()->startRecording(); | 317 | currentSession()->emulationHandler()->startRecording(); |
294 | } | 318 | } |
295 | } | 319 | } |
296 | 320 | ||
297 | void MainWindow::slotSaveScript() { | 321 | void MainWindow::slotSaveScript() { |
298 | if (currentSession() && currentSession()->emulationHandler()->isRecording()) { | 322 | if (currentSession() && currentSession()->emulationHandler()->isRecording()) { |
299 | MimeTypes types; | 323 | MimeTypes types; |
300 | QStringList script; | 324 | QStringList script; |
301 | script << "text/plain"; | 325 | script << "text/plain"; |
302 | script << "text/all"; | 326 | script << "text/all"; |
303 | script << "application/octet-stream"; | 327 | script << "application/octet-stream"; |
304 | types.insert("Script", script); | 328 | types.insert("Script", script); |
305 | QString filename = OFileDialog::getSaveFileName(2, "/", QString::null, types); | 329 | QString filename = OFileDialog::getSaveFileName(2, "/", QString::null, types); |
306 | if (!filename.isEmpty()) { | 330 | if (!filename.isEmpty()) { |
307 | currentSession()->emulationHandler()->script()->saveTo(filename); | 331 | currentSession()->emulationHandler()->script()->saveTo(filename); |
308 | currentSession()->emulationHandler()->clearScript(); | 332 | currentSession()->emulationHandler()->clearScript(); |
309 | } | 333 | } |
310 | } | 334 | } |
311 | } | 335 | } |
312 | 336 | ||
313 | void MainWindow::slotRunScript() { | 337 | void MainWindow::slotRunScript() { |
314 | if (currentSession()) { | 338 | if (currentSession()) { |
315 | MimeTypes types; | 339 | MimeTypes types; |
316 | QStringList script; | 340 | QStringList script; |
317 | script << "text/plain"; | 341 | script << "text/plain"; |
318 | script << "text/all"; | 342 | script << "text/all"; |
319 | script << "application/octet-stream"; | 343 | script << "application/octet-stream"; |
320 | types.insert("Script", script); | 344 | types.insert("Script", script); |
321 | QString filename = OFileDialog::getOpenFileName(2, "/", QString::null, types); | 345 | QString filename = OFileDialog::getOpenFileName(2, "/", QString::null, types); |
322 | if (!filename.isEmpty()) { | 346 | if (!filename.isEmpty()) { |
323 | Script script(DocLnk(filename).file()); | 347 | Script script(DocLnk(filename).file()); |
324 | currentSession()->emulationHandler()->runScript(&script); | 348 | currentSession()->emulationHandler()->runScript(&script); |
325 | } | 349 | } |
326 | } | 350 | } |
327 | } | 351 | } |
328 | 352 | ||
329 | void MainWindow::slotConnect() { | 353 | void MainWindow::slotConnect() { |
330 | if ( currentSession() ) { | 354 | if ( currentSession() ) { |
331 | bool ret = currentSession()->layer()->open(); | 355 | bool ret = currentSession()->layer()->open(); |
332 | if(!ret) QMessageBox::warning(currentSession()->widgetStack(), | 356 | if(!ret) QMessageBox::warning(currentSession()->widgetStack(), |
333 | QObject::tr("Failed"), | 357 | QObject::tr("Failed"), |
334 | QObject::tr("Connecting failed for this session.")); | 358 | QObject::tr("Connecting failed for this session.")); |
335 | else { | 359 | else { |
336 | m_connect->setEnabled( false ); | 360 | m_connect->setEnabled( false ); |
337 | m_disconnect->setEnabled( true ); | 361 | m_disconnect->setEnabled( true ); |
338 | } | 362 | } |
339 | } | 363 | } |
340 | } | 364 | } |
341 | 365 | ||
342 | void MainWindow::slotDisconnect() { | 366 | void MainWindow::slotDisconnect() { |
343 | if ( currentSession() ) { | 367 | if ( currentSession() ) { |
344 | currentSession()->layer()->close(); | 368 | currentSession()->layer()->close(); |
345 | m_connect->setEnabled( true ); | 369 | m_connect->setEnabled( true ); |
346 | m_disconnect->setEnabled( false ); | 370 | m_disconnect->setEnabled( false ); |
347 | } | 371 | } |
348 | } | 372 | } |
349 | 373 | ||
350 | void MainWindow::slotTerminate() { | 374 | void MainWindow::slotTerminate() { |
351 | if ( currentSession() ) | 375 | if ( currentSession() ) |
352 | currentSession()->layer()->close(); | 376 | currentSession()->layer()->close(); |
353 | 377 | ||
354 | slotClose(); | 378 | slotClose(); |
355 | /* FIXME move to the next session */ | 379 | /* FIXME move to the next session */ |
356 | } | 380 | } |
357 | 381 | ||
358 | void MainWindow::slotConfigure() { | 382 | void MainWindow::slotConfigure() { |
359 | ConfigDialog conf( manager()->all(), factory() ); | 383 | ConfigDialog conf( manager()->all(), factory() ); |
360 | conf.showMaximized(); | 384 | conf.showMaximized(); |
361 | 385 | ||
362 | int ret = conf.exec(); | 386 | int ret = conf.exec(); |
363 | 387 | ||
364 | if ( QDialog::Accepted == ret ) { | 388 | if ( QDialog::Accepted == ret ) { |
365 | manager()->setProfiles( conf.list() ); | 389 | manager()->setProfiles( conf.list() ); |
366 | manager()->save(); | 390 | manager()->save(); |
367 | populateProfiles(); | 391 | populateProfiles(); |
368 | } | 392 | } |
369 | } | 393 | } |
370 | /* | 394 | /* |
371 | * we will remove | 395 | * we will remove |
372 | * this window from the tabwidget | 396 | * this window from the tabwidget |
373 | * remove it from the list | 397 | * remove it from the list |
374 | * delete it | 398 | * delete it |
375 | * and set the currentSession() | 399 | * and set the currentSession() |
376 | */ | 400 | */ |
377 | void MainWindow::slotClose() { | 401 | void MainWindow::slotClose() { |
378 | if (!currentSession() ) | 402 | if (!currentSession() ) |
379 | return; | 403 | return; |
380 | 404 | ||
381 | Session* ses = currentSession(); | 405 | Session* ses = currentSession(); |
382 | qWarning("removing! currentSession %s", currentSession()->name().latin1() ); | 406 | qWarning("removing! currentSession %s", currentSession()->name().latin1() ); |
383 | /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */ | 407 | /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */ |
384 | m_curSession = NULL; | 408 | m_curSession = NULL; |
385 | tabWidget()->remove( /*currentSession()*/ses ); | 409 | tabWidget()->remove( /*currentSession()*/ses ); |
386 | /*it's autodelete */ | 410 | /*it's autodelete */ |
387 | m_sessions.remove( ses ); | 411 | m_sessions.remove( ses ); |
388 | qWarning("after remove!!"); | 412 | qWarning("after remove!!"); |
389 | 413 | ||
390 | if (!currentSession() ) { | 414 | if (!currentSession() ) { |
391 | m_connect->setEnabled( false ); | 415 | m_connect->setEnabled( false ); |
392 | m_disconnect->setEnabled( false ); | 416 | m_disconnect->setEnabled( false ); |
393 | m_terminate->setEnabled( false ); | 417 | m_terminate->setEnabled( false ); |
394 | m_transfer->setEnabled( false ); | 418 | m_transfer->setEnabled( false ); |
395 | m_recordScript->setEnabled( false ); | 419 | m_recordScript->setEnabled( false ); |
396 | m_saveScript->setEnabled( false ); | 420 | m_saveScript->setEnabled( false ); |
397 | m_runScript->setEnabled( false ); | 421 | m_runScript->setEnabled( false ); |
398 | m_fullscreen->setEnabled( false ); | 422 | m_fullscreen->setEnabled( false ); |
399 | m_closewindow->setEnabled( false ); | 423 | m_closewindow->setEnabled( false ); |
400 | } | 424 | } |
401 | } | 425 | } |
402 | 426 | ||
403 | /* | 427 | /* |
404 | * We will get the name | 428 | * We will get the name |
405 | * Then the profile | 429 | * Then the profile |
406 | * and then we will make a profile | 430 | * and then we will make a profile |
407 | */ | 431 | */ |
408 | void MainWindow::slotProfile( int id) { | 432 | void MainWindow::slotProfile( int id) { |
409 | Profile prof = manager()->profile( m_sessionsPop->text( id) ); | 433 | Profile prof = manager()->profile( m_sessionsPop->text( id) ); |
410 | create( prof ); | 434 | create( prof ); |
411 | } | 435 | } |
412 | void MainWindow::create( const Profile& prof ) { | 436 | void MainWindow::create( const Profile& prof ) { |
413 | Session *ses = manager()->fromProfile( prof, tabWidget() ); | 437 | Session *ses = manager()->fromProfile( prof, tabWidget() ); |
414 | 438 | ||
415 | if((!ses) || (!ses->layer()) || (!ses->widgetStack())) | 439 | if((!ses) || (!ses->layer()) || (!ses->widgetStack())) |
416 | { | 440 | { |
417 | QMessageBox::warning(this, | 441 | QMessageBox::warning(this, |
418 | QObject::tr("Session failed"), | 442 | QObject::tr("Session failed"), |
419 | QObject::tr("<qt>Cannot open session: Not all components were found.</qt>")); | 443 | QObject::tr("<qt>Cannot open session: Not all components were found.</qt>")); |
420 | //if(ses) delete ses; | 444 | //if(ses) delete ses; |
421 | return; | 445 | return; |
422 | } | 446 | } |
423 | 447 | ||
424 | m_sessions.append( ses ); | 448 | m_sessions.append( ses ); |
425 | tabWidget()->add( ses ); | 449 | tabWidget()->add( ses ); |
426 | m_curSession = ses; | 450 | m_curSession = ses; |
427 | 451 | ||
428 | // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it | 452 | // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it |
429 | m_connect->setEnabled( true ); | 453 | m_connect->setEnabled( true ); |
430 | m_disconnect->setEnabled( false ); | 454 | m_disconnect->setEnabled( false ); |
431 | m_terminate->setEnabled( true ); | 455 | m_terminate->setEnabled( true ); |
432 | m_transfer->setEnabled( true ); | 456 | m_transfer->setEnabled( true ); |
433 | m_recordScript->setEnabled( true ); | 457 | m_recordScript->setEnabled( true ); |
434 | m_saveScript->setEnabled( true ); | 458 | m_saveScript->setEnabled( true ); |
435 | m_runScript->setEnabled( true ); | 459 | m_runScript->setEnabled( true ); |
436 | m_fullscreen->setEnabled( true ); | 460 | m_fullscreen->setEnabled( true ); |
437 | m_closewindow->setEnabled( true ); | 461 | m_closewindow->setEnabled( true ); |
438 | 462 | ||
439 | 463 | ||
440 | // is io_layer wants direct connection, then autoconnect | 464 | // is io_layer wants direct connection, then autoconnect |
441 | //if ( ( m_curSession->layer() )->supports()[0] == 1 ) { | 465 | //if ( ( m_curSession->layer() )->supports()[0] == 1 ) { |
442 | if (prof.autoConnect()) { | 466 | if (prof.autoConnect()) { |
443 | slotConnect(); | 467 | slotConnect(); |
444 | } | 468 | } |
445 | 469 | ||
446 | QWidget *w = currentSession()->widget(); | 470 | QWidget *w = currentSession()->widget(); |
447 | if(w) w->setFocus(); | 471 | if(w) w->setFocus(); |
448 | } | 472 | } |
449 | 473 | ||
450 | void MainWindow::slotTransfer() | 474 | void MainWindow::slotTransfer() |
451 | { | 475 | { |
452 | if ( currentSession() ) { | 476 | if ( currentSession() ) { |
453 | TransferDialog dlg(currentSession()->widgetStack(), this); | 477 | TransferDialog dlg(currentSession()->widgetStack(), this); |
454 | dlg.showMaximized(); | 478 | dlg.showMaximized(); |
455 | //currentSession()->widgetStack()->add(dlg); | 479 | //currentSession()->widgetStack()->add(dlg); |
456 | dlg.exec(); | 480 | dlg.exec(); |
457 | } | 481 | } |
458 | } | 482 | } |
459 | 483 | ||
460 | 484 | ||
461 | void MainWindow::slotOpenKeb(bool state) { | 485 | void MainWindow::slotOpenKeb(bool state) { |
462 | 486 | ||
463 | if (state) m_keyBar->show(); | 487 | if (state) m_keyBar->show(); |
464 | else m_keyBar->hide(); | 488 | else m_keyBar->hide(); |
465 | 489 | ||
466 | } | 490 | } |
467 | 491 | ||
468 | 492 | ||
469 | void MainWindow::slotOpenButtons( bool state ) { | 493 | void MainWindow::slotOpenButtons( bool state ) { |
470 | 494 | ||
471 | if ( state ) { | 495 | if ( state ) { |
472 | m_buttonBar->show(); | 496 | m_buttonBar->show(); |
473 | } else { | 497 | } else { |
474 | m_buttonBar->hide(); | 498 | m_buttonBar->hide(); |
475 | } | 499 | } |
476 | } | 500 | } |
477 | 501 | ||
478 | 502 | ||
479 | 503 | ||
480 | void MainWindow::slotSessionChanged( Session* ses ) { | 504 | void MainWindow::slotSessionChanged( Session* ses ) { |
481 | qWarning("changed!"); | 505 | qWarning("changed!"); |
482 | if ( ses ) { | 506 | if ( ses ) { |
483 | m_curSession = ses; | 507 | m_curSession = ses; |
484 | qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) ); | 508 | qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) ); |
485 | if ( m_curSession->layer()->isConnected() ) { | 509 | if ( m_curSession->layer()->isConnected() ) { |
486 | m_connect->setEnabled( false ); | 510 | m_connect->setEnabled( false ); |
487 | m_disconnect->setEnabled( true ); | 511 | m_disconnect->setEnabled( true ); |
488 | } else { | 512 | } else { |
489 | m_connect->setEnabled( true ); | 513 | m_connect->setEnabled( true ); |
490 | m_disconnect->setEnabled( false ); | 514 | m_disconnect->setEnabled( false ); |
491 | } | 515 | } |
492 | 516 | ||
493 | QWidget *w = m_curSession->widget(); | 517 | QWidget *w = m_curSession->widget(); |
494 | if(w) w->setFocus(); | 518 | if(w) w->setFocus(); |
495 | } | 519 | } |
496 | } | 520 | } |
497 | 521 | ||
498 | void MainWindow::slotFullscreen() { | 522 | void MainWindow::slotFullscreen() { |
499 | 523 | ||
500 | 524 | ||
501 | 525 | ||
502 | if ( m_isFullscreen ) { | 526 | if ( m_isFullscreen ) { |
503 | ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), true ); | 527 | ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), true ); |
504 | ( m_curSession->widgetStack() )->resize( savedParentFullscreen->width(), savedParentFullscreen->height() ); | 528 | ( m_curSession->widgetStack() )->resize( savedParentFullscreen->width(), savedParentFullscreen->height() ); |
505 | ( m_curSession->emulationHandler() )->cornerButton()->hide(); | 529 | ( m_curSession->emulationHandler() )->cornerButton()->hide(); |
506 | disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); | 530 | disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); |
507 | 531 | ||
508 | } else { | 532 | } else { |
509 | savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget(); | 533 | savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget(); |
510 | ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); | 534 | ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); |
511 | ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop | 535 | ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop |
512 | , QPoint(0,0), false ); | 536 | , QPoint(0,0), false ); |
513 | ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() ); | 537 | ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() ); |
514 | ( m_curSession->widgetStack() )->setFocus(); | 538 | ( m_curSession->widgetStack() )->setFocus(); |
515 | ( m_curSession->widgetStack() )->show(); | 539 | ( m_curSession->widgetStack() )->show(); |
516 | 540 | ||
517 | ( ( m_curSession->emulationHandler() )->cornerButton() )->show(); | 541 | ( ( m_curSession->emulationHandler() )->cornerButton() )->show(); |
518 | 542 | ||
519 | connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); | 543 | connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); |
520 | } | 544 | } |
521 | 545 | ||
522 | m_isFullscreen = !m_isFullscreen; | 546 | m_isFullscreen = !m_isFullscreen; |
523 | } | 547 | } |
524 | 548 | ||
525 | 549 | ||
526 | void MainWindow::slotKeyReceived(FKey k, ushort, ushort, bool pressed) { | 550 | void MainWindow::slotKeyReceived(FKey k, ushort, ushort, bool pressed) { |
527 | 551 | ||
528 | if ( m_curSession ) { | 552 | if ( m_curSession ) { |
529 | 553 | ||
530 | QEvent::Type state; | 554 | QEvent::Type state; |
531 | 555 | ||
532 | if (pressed) state = QEvent::KeyPress; | 556 | if (pressed) state = QEvent::KeyPress; |
533 | else state = QEvent::KeyRelease; | 557 | else state = QEvent::KeyRelease; |
534 | 558 | ||
535 | QKeyEvent ke(state, k.qcode, k.unicode, 0, QString(QChar(k.unicode))); | 559 | QKeyEvent ke(state, k.qcode, k.unicode, 0, QString(QChar(k.unicode))); |
536 | 560 | ||
537 | // where should i send this event? doesnt work sending it here | 561 | // where should i send this event? doesnt work sending it here |
538 | QApplication::sendEvent((QObject *)m_curSession->widget(), &ke); | 562 | QApplication::sendEvent((QObject *)m_curSession->widget(), &ke); |
539 | ke.ignore(); | 563 | ke.ignore(); |
540 | } | 564 | } |
541 | } | 565 | } |
566 | void MainWindow::slotCopy() { | ||
567 | if (!currentSession() ) return; | ||
568 | currentSession()->emulationHandler()->copy(); | ||
569 | } | ||
570 | void MainWindow::slotPaste() { | ||
571 | if (!currentSession() ) return; | ||
572 | currentSession()->emulationHandler()->paste(); | ||
573 | } | ||
574 | |||
575 | /* | ||
576 | * Save the session | ||
577 | */ | ||
578 | |||
579 | void MainWindow::slotSaveSession() { | ||
580 | if (!currentSession() ) { | ||
581 | QMessageBox::information(this, tr("Save Connection"), | ||
582 | tr("<qt>There is no Connection.</qt>"), 1 ); | ||
583 | return; | ||
584 | } | ||
585 | manager()->add( currentSession()->profile() ); | ||
586 | manager()->save(); | ||
587 | populateProfiles(); | ||
588 | } | ||
diff --git a/noncore/apps/opie-console/mainwindow.h b/noncore/apps/opie-console/mainwindow.h index 0f52e76..16b6252 100644 --- a/noncore/apps/opie-console/mainwindow.h +++ b/noncore/apps/opie-console/mainwindow.h | |||
@@ -1,124 +1,131 @@ | |||
1 | #ifndef OPIE_MAIN_WINDOW_H | 1 | #ifndef OPIE_MAIN_WINDOW_H |
2 | #define OPIE_MAIN_WINDOW_H | 2 | #define OPIE_MAIN_WINDOW_H |
3 | 3 | ||
4 | #include <qmainwindow.h> | 4 | #include <qmainwindow.h> |
5 | #include <qlist.h> | 5 | #include <qlist.h> |
6 | 6 | ||
7 | #include "session.h" | 7 | #include "session.h" |
8 | 8 | ||
9 | /** | 9 | /** |
10 | * this is the MainWindow of the new opie console | 10 | * this is the MainWindow of the new opie console |
11 | * it's also the dispatcher between the different | 11 | * it's also the dispatcher between the different |
12 | * actions supported by the gui | 12 | * actions supported by the gui |
13 | */ | 13 | */ |
14 | class QToolBar; | 14 | class QToolBar; |
15 | class QToolButton; | 15 | class QToolButton; |
16 | class QMenuBar; | 16 | class QMenuBar; |
17 | class QAction; | 17 | class QAction; |
18 | class MetaFactory; | 18 | class MetaFactory; |
19 | class TabWidget; | 19 | class TabWidget; |
20 | class ProfileManager; | 20 | class ProfileManager; |
21 | class Profile; | 21 | class Profile; |
22 | class FunctionKeyboard; | 22 | class FunctionKeyboard; |
23 | class FKey; | 23 | class FKey; |
24 | class QuickButton; | 24 | class QuickButton; |
25 | 25 | ||
26 | class MainWindow : public QMainWindow { | 26 | class MainWindow : public QMainWindow { |
27 | Q_OBJECT | 27 | Q_OBJECT |
28 | public: | 28 | public: |
29 | MainWindow( QWidget *parent = 0, const char *name = 0, WFlags fl = 0 ); | 29 | MainWindow( QWidget *parent = 0, const char *name = 0, WFlags fl = 0 ); |
30 | ~MainWindow(); | 30 | ~MainWindow(); |
31 | 31 | ||
32 | /** | 32 | /** |
33 | * our factory to generate IOLayer and so on | 33 | * our factory to generate IOLayer and so on |
34 | * | 34 | * |
35 | */ | 35 | */ |
36 | MetaFactory* factory(); | 36 | MetaFactory* factory(); |
37 | 37 | ||
38 | /** | 38 | /** |
39 | * A session contains a QWidget*, | 39 | * A session contains a QWidget*, |
40 | * an IOLayer* and some infos for us | 40 | * an IOLayer* and some infos for us |
41 | */ | 41 | */ |
42 | Session* currentSession(); | 42 | Session* currentSession(); |
43 | 43 | ||
44 | /** | 44 | /** |
45 | * the session list | 45 | * the session list |
46 | */ | 46 | */ |
47 | QList<Session> sessions(); | 47 | QList<Session> sessions(); |
48 | 48 | ||
49 | /** | 49 | /** |
50 | * | 50 | * |
51 | */ | 51 | */ |
52 | ProfileManager* manager(); | 52 | ProfileManager* manager(); |
53 | TabWidget* tabWidget(); | 53 | TabWidget* tabWidget(); |
54 | 54 | ||
55 | private slots: | 55 | private slots: |
56 | void slotNew(); | 56 | void slotNew(); |
57 | void slotConnect(); | 57 | void slotConnect(); |
58 | void slotDisconnect(); | 58 | void slotDisconnect(); |
59 | void slotTerminate(); | 59 | void slotTerminate(); |
60 | void slotConfigure(); | 60 | void slotConfigure(); |
61 | void slotClose(); | 61 | void slotClose(); |
62 | void slotProfile(int); | 62 | void slotProfile(int); |
63 | void slotTransfer(); | 63 | void slotTransfer(); |
64 | void slotOpenKeb(bool); | 64 | void slotOpenKeb(bool); |
65 | void slotOpenButtons(bool); | 65 | void slotOpenButtons(bool); |
66 | void slotRecordScript(); | 66 | void slotRecordScript(); |
67 | void slotSaveScript(); | 67 | void slotSaveScript(); |
68 | void slotRunScript(); | 68 | void slotRunScript(); |
69 | void slotFullscreen(); | 69 | void slotFullscreen(); |
70 | void slotSessionChanged( Session* ); | 70 | void slotSessionChanged( Session* ); |
71 | void slotKeyReceived(FKey, ushort, ushort, bool); | 71 | void slotKeyReceived(FKey, ushort, ushort, bool); |
72 | 72 | ||
73 | /* what could these both slot do? */ | ||
74 | void slotCopy(); | ||
75 | void slotPaste(); | ||
76 | |||
77 | /* save the currentSession() to Profiles */ | ||
78 | void slotSaveSession(); | ||
79 | |||
73 | private: | 80 | private: |
74 | void initUI(); | 81 | void initUI(); |
75 | void populateProfiles(); | 82 | void populateProfiles(); |
76 | void create( const Profile& ); | 83 | void create( const Profile& ); |
77 | /** | 84 | /** |
78 | * the current session | 85 | * the current session |
79 | */ | 86 | */ |
80 | Session* m_curSession; | 87 | Session* m_curSession; |
81 | 88 | ||
82 | /** | 89 | /** |
83 | * the session list | 90 | * the session list |
84 | */ | 91 | */ |
85 | QList<Session> m_sessions; | 92 | QList<Session> m_sessions; |
86 | 93 | ||
87 | /** | 94 | /** |
88 | * the metafactory | 95 | * the metafactory |
89 | */ | 96 | */ |
90 | MetaFactory* m_factory; | 97 | MetaFactory* m_factory; |
91 | ProfileManager* m_manager; | 98 | ProfileManager* m_manager; |
92 | 99 | ||
93 | TabWidget* m_consoleWindow; | 100 | TabWidget* m_consoleWindow; |
94 | QToolBar* m_tool; | 101 | QToolBar* m_tool; |
95 | QToolBar* m_icons; | 102 | QToolBar* m_icons; |
96 | QToolBar* m_keyBar; | 103 | QToolBar* m_keyBar; |
97 | QToolBar* m_buttonBar; | 104 | QToolBar* m_buttonBar; |
98 | QMenuBar* m_bar; | 105 | QMenuBar* m_bar; |
99 | QPopupMenu* m_console; | 106 | QPopupMenu* m_console; |
100 | QPopupMenu* m_settings; | 107 | QPopupMenu* m_settings; |
101 | QPopupMenu* m_sessionsPop; | 108 | QPopupMenu* m_sessionsPop; |
102 | QPopupMenu* m_scripts; | 109 | QPopupMenu* m_scripts; |
103 | QAction* m_connect; | 110 | QAction* m_connect; |
104 | QAction* m_disconnect; | 111 | QAction* m_disconnect; |
105 | QAction* m_terminate; | 112 | QAction* m_terminate; |
106 | QAction* m_transfer; | 113 | QAction* m_transfer; |
107 | QAction* m_setProfiles; | 114 | QAction* m_setProfiles; |
108 | QAction* m_openKeys; | 115 | QAction* m_openKeys; |
109 | QAction* m_openButtons; | 116 | QAction* m_openButtons; |
110 | QAction* m_recordScript; | 117 | QAction* m_recordScript; |
111 | QAction* m_saveScript; | 118 | QAction* m_saveScript; |
112 | QAction* m_runScript; | 119 | QAction* m_runScript; |
113 | QAction* m_fullscreen; | 120 | QAction* m_fullscreen; |
114 | QAction* m_closewindow; | 121 | QAction* m_closewindow; |
115 | 122 | ||
116 | FunctionKeyboard *m_kb; | 123 | FunctionKeyboard *m_kb; |
117 | QuickButton *m_qb; | 124 | QuickButton *m_qb; |
118 | bool m_isFullscreen; | 125 | bool m_isFullscreen; |
119 | 126 | ||
120 | QWidget* savedParentFullscreen; | 127 | QWidget* savedParentFullscreen; |
121 | }; | 128 | }; |
122 | 129 | ||
123 | 130 | ||
124 | #endif | 131 | #endif |
diff --git a/noncore/apps/opie-console/opie-console.control b/noncore/apps/opie-console/opie-console.control index d41ef58..8541d22 100644 --- a/noncore/apps/opie-console/opie-console.control +++ b/noncore/apps/opie-console/opie-console.control | |||
@@ -1,10 +1,10 @@ | |||
1 | Files: bin/opie-console apps/Applications/opie-console.desktop pics/console/* etc/keytabs/default.Keytab | 1 | Files: bin/opie-console apps/Applications/opie-console.desktop pics/console/* etc/keytabs/default.Keytab bin/sz bin/rz |
2 | Priority: optional | 2 | Priority: optional |
3 | Section: opie/applications | 3 | Section: opie/applications |
4 | Maintainer: Opie team <opie@handhelds.org> | 4 | Maintainer: Opie team <opie@handhelds.org> |
5 | Architecture: arm | 5 | Architecture: arm |
6 | Version: 0.6-$SUB_VERSION | 6 | Version: 0.6-$SUB_VERSION |
7 | Depends: qpe-base ($QPE_VERSION), libopie ($QPE_VERSION), opie-console-help-en | 7 | Depends: qpe-base ($QPE_VERSION), libopie ($QPE_VERSION), opie-console-help-en |
8 | License: GPL | 8 | License: GPL |
9 | Description: Opie terminal app | 9 | Description: Opie terminal app |
10 | 10 | ||
diff --git a/noncore/apps/opie-console/profilemanager.cpp b/noncore/apps/opie-console/profilemanager.cpp index 5d39d96..cad2567 100644 --- a/noncore/apps/opie-console/profilemanager.cpp +++ b/noncore/apps/opie-console/profilemanager.cpp | |||
@@ -1,137 +1,141 @@ | |||
1 | #include <stdio.h> | 1 | #include <stdio.h> |
2 | #include <stdlib.h> | 2 | #include <stdlib.h> |
3 | 3 | ||
4 | #include <qfile.h> | 4 | #include <qfile.h> |
5 | #include <qhbox.h> | 5 | #include <qhbox.h> |
6 | #include <qlayout.h> | 6 | #include <qlayout.h> |
7 | #include <qwidgetstack.h> | 7 | #include <qwidgetstack.h> |
8 | 8 | ||
9 | #include <qpe/config.h> | 9 | #include <qpe/config.h> |
10 | 10 | ||
11 | #include "emulation_handler.h" | 11 | #include "emulation_handler.h" |
12 | #include "widget_layer.h" | 12 | #include "widget_layer.h" |
13 | #include "emulation_widget.h" | 13 | #include "emulation_widget.h" |
14 | #include "metafactory.h" | 14 | #include "metafactory.h" |
15 | #include "profileconfig.h" | 15 | #include "profileconfig.h" |
16 | #include "profilemanager.h" | 16 | #include "profilemanager.h" |
17 | 17 | ||
18 | ProfileManager::ProfileManager( MetaFactory* fact ) | 18 | ProfileManager::ProfileManager( MetaFactory* fact ) |
19 | : m_fact( fact ) | 19 | : m_fact( fact ) |
20 | { | 20 | { |
21 | 21 | ||
22 | } | 22 | } |
23 | ProfileManager::~ProfileManager() { | 23 | ProfileManager::~ProfileManager() { |
24 | 24 | ||
25 | } | 25 | } |
26 | void ProfileManager::load() { | 26 | void ProfileManager::load() { |
27 | m_list.clear(); | 27 | m_list.clear(); |
28 | ProfileConfig conf("opie-console-profiles"); | 28 | ProfileConfig conf("opie-console-profiles"); |
29 | QStringList groups = conf.groups(); | 29 | QStringList groups = conf.groups(); |
30 | QStringList::Iterator it; | 30 | QStringList::Iterator it; |
31 | 31 | ||
32 | /* | 32 | /* |
33 | * for each profile | 33 | * for each profile |
34 | */ | 34 | */ |
35 | for ( it = groups.begin(); it != groups.end(); ++it ) { | 35 | for ( it = groups.begin(); it != groups.end(); ++it ) { |
36 | conf.setGroup( (*it) ); | 36 | conf.setGroup( (*it) ); |
37 | Profile prof; | 37 | Profile prof; |
38 | prof.setName( conf.readEntry("name") ); | 38 | prof.setName( conf.readEntry("name") ); |
39 | prof.setIOLayer( conf.readEntry("iolayer").utf8() ); | 39 | prof.setIOLayer( conf.readEntry("iolayer").utf8() ); |
40 | prof.setTerminalName( conf.readEntry("term").utf8() ); | 40 | prof.setTerminalName( conf.readEntry("term").utf8() ); |
41 | prof.setAutoConnect( conf.readBoolEntry("autoConnect") ); | 41 | prof.setAutoConnect( conf.readBoolEntry("autoConnect") ); |
42 | prof.setBackground( conf.readNumEntry("back") ); | 42 | prof.setBackground( conf.readNumEntry("back") ); |
43 | prof.setForeground( conf.readNumEntry("fore") ); | 43 | prof.setForeground( conf.readNumEntry("fore") ); |
44 | prof.setTerminal( conf.readNumEntry("terminal") ); | 44 | prof.setTerminal( conf.readNumEntry("terminal") ); |
45 | 45 | ||
46 | // THIS is evil because all data get's reset | 46 | // THIS is evil because all data get's reset |
47 | prof.setConf( conf.items( (*it) ) ); | 47 | prof.setConf( conf.items( (*it) ) ); |
48 | 48 | ||
49 | /* now add it */ | 49 | /* now add it */ |
50 | m_list.append( prof ); | 50 | m_list.append( prof ); |
51 | } | 51 | } |
52 | 52 | ||
53 | } | 53 | } |
54 | void ProfileManager::clear() { | 54 | void ProfileManager::clear() { |
55 | m_list.clear(); | 55 | m_list.clear(); |
56 | } | 56 | } |
57 | Profile::ValueList ProfileManager::all()const { | 57 | Profile::ValueList ProfileManager::all()const { |
58 | return m_list; | 58 | return m_list; |
59 | } | 59 | } |
60 | /* | 60 | /* |
61 | * Our goal is to create a Session | 61 | * Our goal is to create a Session |
62 | * We will load the the IOLayer and EmulationLayer | 62 | * We will load the the IOLayer and EmulationLayer |
63 | * from the factory | 63 | * from the factory |
64 | * we will generate a QWidgetStack | 64 | * we will generate a QWidgetStack |
65 | * add a dummy widget with layout | 65 | * add a dummy widget with layout |
66 | * add "Widget" to the layout | 66 | * add "Widget" to the layout |
67 | * add the dummy to the stack | 67 | * add the dummy to the stack |
68 | * raise the dummy | 68 | * raise the dummy |
69 | * call session->connect(= | 69 | * call session->connect(= |
70 | * this way we only need to reparent | 70 | * this way we only need to reparent |
71 | * in TabWidget | 71 | * in TabWidget |
72 | */ | 72 | */ |
73 | Session* ProfileManager::fromProfile( const Profile& prof, QWidget* parent) { | 73 | Session* ProfileManager::fromProfile( const Profile& prof, QWidget* parent) { |
74 | /* TEST PROFILE!!! | 74 | /* TEST PROFILE!!! |
75 | Profile prof; | 75 | Profile prof; |
76 | QString str = "/dev/ttyS0"; | 76 | QString str = "/dev/ttyS0"; |
77 | prof.writeEntry("Device",str ); | 77 | prof.writeEntry("Device",str ); |
78 | prof.writeEntry("Baud", 115200 ); | 78 | prof.writeEntry("Baud", 115200 ); |
79 | prof.setIOLayer("serial"); | 79 | prof.setIOLayer("serial"); |
80 | prof.setName( "test"); | 80 | prof.setName( "test"); |
81 | */ | 81 | */ |
82 | Session* session = new Session(); | 82 | Session* session = new Session(); |
83 | session->setName( prof.name() ); | 83 | session->setName( prof.name() ); |
84 | /* translate the internal name to the external */ | 84 | /* translate the internal name to the external */ |
85 | session->setIOLayer(m_fact->newIOLayer( m_fact->external(prof.ioLayerName()) , | 85 | session->setIOLayer(m_fact->newIOLayer( m_fact->external(prof.ioLayerName()) , |
86 | prof) ); | 86 | prof) ); |
87 | 87 | ||
88 | QWidgetStack *stack = new QWidgetStack( parent ); | 88 | QWidgetStack *stack = new QWidgetStack( parent ); |
89 | session->setWidgetStack( stack ); | 89 | session->setWidgetStack( stack ); |
90 | QWidget* dummy = new QHBox( stack ); | 90 | QWidget* dummy = new QHBox( stack ); |
91 | stack->raiseWidget( dummy ); | 91 | stack->raiseWidget( dummy ); |
92 | 92 | ||
93 | EmulationHandler* handler = new EmulationHandler(prof,dummy ); | 93 | EmulationHandler* handler = new EmulationHandler(prof,dummy ); |
94 | session->setEmulationHandler( handler ); | 94 | session->setEmulationHandler( handler ); |
95 | session->connect(); | 95 | session->connect(); |
96 | session->setProfile( prof ); | ||
96 | 97 | ||
97 | return session; | 98 | return session; |
98 | } | 99 | } |
99 | void ProfileManager::save( ) { | 100 | void ProfileManager::save( ) { |
100 | QFile::remove( (QString(getenv("HOME") )+ "/Settings/opie-console-profiles.conf" ) ); | 101 | QFile::remove( (QString(getenv("HOME") )+ "/Settings/opie-console-profiles.conf" ) ); |
101 | ProfileConfig conf("opie-console-profiles"); | 102 | ProfileConfig conf("opie-console-profiles"); |
102 | Profile::ValueList::Iterator it2; | 103 | Profile::ValueList::Iterator it2; |
103 | for (it2 = m_list.begin(); it2 != m_list.end(); ++it2 ) { | 104 | for (it2 = m_list.begin(); it2 != m_list.end(); ++it2 ) { |
104 | conf.setGroup( (*it2).name() ); | 105 | conf.setGroup( (*it2).name() ); |
105 | 106 | ||
106 | /* now the config stuff */ | 107 | /* now the config stuff */ |
107 | QMap<QString, QString> map = (*it2).conf(); | 108 | QMap<QString, QString> map = (*it2).conf(); |
108 | QMap<QString, QString>::Iterator confIt; | 109 | QMap<QString, QString>::Iterator confIt; |
109 | for ( confIt = map.begin(); confIt != map.end(); ++confIt ) { | 110 | for ( confIt = map.begin(); confIt != map.end(); ++confIt ) { |
110 | conf.writeEntry( confIt.key(), confIt.data() ); | 111 | conf.writeEntry( confIt.key(), confIt.data() ); |
111 | } | 112 | } |
112 | 113 | ||
113 | conf.writeEntry( "name", (*it2).name() ); | 114 | conf.writeEntry( "name", (*it2).name() ); |
114 | QString str = QString::fromUtf8( (*it2).ioLayerName() ); | 115 | QString str = QString::fromUtf8( (*it2).ioLayerName() ); |
115 | 116 | ||
116 | conf.writeEntry( "iolayer", str ); | 117 | conf.writeEntry( "iolayer", str ); |
117 | conf.writeEntry( "term", QString::fromUtf8( (*it2).terminalName() ) ); | 118 | conf.writeEntry( "term", QString::fromUtf8( (*it2).terminalName() ) ); |
118 | conf.writeEntry( "autoConnect", (*it2).autoConnect()); | 119 | conf.writeEntry( "autoConnect", (*it2).autoConnect()); |
119 | conf.writeEntry( "back", (*it2).background() ); | 120 | conf.writeEntry( "back", (*it2).background() ); |
120 | conf.writeEntry( "fore", (*it2).foreground() ); | 121 | conf.writeEntry( "fore", (*it2).foreground() ); |
121 | conf.writeEntry( "terminal", (*it2).terminal() ); | 122 | conf.writeEntry( "terminal", (*it2).terminal() ); |
122 | } | 123 | } |
123 | } | 124 | } |
125 | void ProfileManager::add( const Profile& prof) { | ||
126 | m_list.append( prof ); | ||
127 | } | ||
124 | void ProfileManager::setProfiles( const Profile::ValueList& list ) { | 128 | void ProfileManager::setProfiles( const Profile::ValueList& list ) { |
125 | m_list = list; | 129 | m_list = list; |
126 | }; | 130 | }; |
127 | Profile ProfileManager::profile( const QString& name )const { | 131 | Profile ProfileManager::profile( const QString& name )const { |
128 | Profile prof; | 132 | Profile prof; |
129 | Profile::ValueList::ConstIterator it; | 133 | Profile::ValueList::ConstIterator it; |
130 | for ( it = m_list.begin(); it != m_list.end(); ++it ) { | 134 | for ( it = m_list.begin(); it != m_list.end(); ++it ) { |
131 | if ( name == (*it).name() ) { | 135 | if ( name == (*it).name() ) { |
132 | prof = (*it); | 136 | prof = (*it); |
133 | break; | 137 | break; |
134 | } | 138 | } |
135 | } | 139 | } |
136 | return prof; | 140 | return prof; |
137 | } | 141 | } |
diff --git a/noncore/apps/opie-console/receive_layer.cpp b/noncore/apps/opie-console/receive_layer.cpp index 05e2c67..bbde339 100644 --- a/noncore/apps/opie-console/receive_layer.cpp +++ b/noncore/apps/opie-console/receive_layer.cpp | |||
@@ -1,33 +1,34 @@ | |||
1 | #include <unistd.h> | 1 | #include <unistd.h> |
2 | 2 | ||
3 | #include <qdir.h> | ||
3 | #include <qstring.h> | 4 | #include <qstring.h> |
4 | #include <qfile.h> | 5 | #include <qfile.h> |
5 | 6 | ||
6 | #include "io_layer.h" | 7 | #include "io_layer.h" |
7 | #include "receive_layer.h" | 8 | #include "receive_layer.h" |
8 | 9 | ||
9 | ReceiveLayer::ReceiveLayer( IOLayer* lay, const QString& startDir ) | 10 | ReceiveLayer::ReceiveLayer( IOLayer* lay, const QString& startDir ) |
10 | : QObject(), m_curDir( startDir ), m_layer(lay ) | 11 | : QObject(), m_curDir( startDir ), m_layer(lay ) |
11 | { | 12 | { |
12 | 13 | ||
13 | } | 14 | } |
14 | ReceiveLayer::~ReceiveLayer() { | 15 | ReceiveLayer::~ReceiveLayer() { |
15 | 16 | ||
16 | } | 17 | } |
17 | IOLayer* ReceiveLayer::layer() { | 18 | IOLayer* ReceiveLayer::layer() { |
18 | return m_layer; | 19 | return m_layer; |
19 | } | 20 | } |
20 | QString ReceiveLayer::currentDir()const{ | 21 | QString ReceiveLayer::currentDir()const{ |
21 | if (m_curDir.isEmpty() ) | 22 | if (m_curDir.isEmpty() ) |
22 | return QString::fromLocal8Bit( ::getwd(NULL) ); | 23 | return QDir::currentDirPath(); |
23 | return m_curDir; | 24 | return m_curDir; |
24 | } | 25 | } |
25 | void ReceiveLayer::changeDir( const QString& str) { | 26 | void ReceiveLayer::changeDir( const QString& str) { |
26 | ::chdir( str.latin1() ); | 27 | ::chdir( str.latin1() ); |
27 | } | 28 | } |
28 | void ReceiveLayer::receive( const QString& dir, Mode, Features ) { | 29 | void ReceiveLayer::receive( const QString& dir, Mode, Features ) { |
29 | receive( dir ); | 30 | receive( dir ); |
30 | } | 31 | } |
31 | void ReceiveLayer::cancel() { | 32 | void ReceiveLayer::cancel() { |
32 | 33 | ||
33 | } | 34 | } |
diff --git a/noncore/apps/opie-console/session.cpp b/noncore/apps/opie-console/session.cpp index 03d0fcd..c166d95 100644 --- a/noncore/apps/opie-console/session.cpp +++ b/noncore/apps/opie-console/session.cpp | |||
@@ -1,100 +1,107 @@ | |||
1 | 1 | ||
2 | 2 | ||
3 | #include "profile.h" | ||
3 | #include "io_layer.h" | 4 | #include "io_layer.h" |
4 | #include "file_layer.h" | 5 | #include "file_layer.h" |
5 | #include "emulation_handler.h" | 6 | #include "emulation_handler.h" |
6 | #include "session.h" | 7 | #include "session.h" |
7 | 8 | ||
8 | 9 | ||
9 | Session::Session() { | 10 | Session::Session() { |
10 | m_widget = 0l; | 11 | m_widget = 0l; |
11 | m_layer = 0l; | 12 | m_layer = 0l; |
12 | m_emu = 0l; | 13 | m_emu = 0l; |
13 | } | 14 | } |
14 | Session::Session( const QString& na, QWidgetStack* widget, IOLayer* lay) | 15 | Session::Session( const QString& na, QWidgetStack* widget, IOLayer* lay) |
15 | : m_name( na ), m_widget( widget ), m_layer( lay ) | 16 | : m_name( na ), m_widget( widget ), m_layer( lay ) |
16 | { | 17 | { |
17 | // m_widLay = 0l; | 18 | // m_widLay = 0l; |
18 | // m_emLay = 0l; | 19 | // m_emLay = 0l; |
19 | m_emu = 0l; | 20 | m_emu = 0l; |
20 | } | 21 | } |
21 | Session::~Session() { | 22 | Session::~Session() { |
22 | delete m_layer; | 23 | delete m_layer; |
23 | delete m_emu; | 24 | delete m_emu; |
24 | delete m_widget; | 25 | delete m_widget; |
25 | /* the widget layer should be deleted by the m_widget */ | 26 | /* the widget layer should be deleted by the m_widget */ |
26 | } | 27 | } |
27 | QString Session::name()const { | 28 | QString Session::name()const { |
28 | return m_name; | 29 | return m_name; |
29 | } | 30 | } |
30 | QWidgetStack* Session::widgetStack() { | 31 | QWidgetStack* Session::widgetStack() { |
31 | return m_widget; | 32 | return m_widget; |
32 | } | 33 | } |
33 | IOLayer* Session::layer() { | 34 | IOLayer* Session::layer() { |
34 | return m_layer; | 35 | return m_layer; |
35 | } | 36 | } |
36 | EmulationHandler* Session::emulationHandler() { | 37 | EmulationHandler* Session::emulationHandler() { |
37 | return m_emu; | 38 | return m_emu; |
38 | } | 39 | } |
39 | QWidget* Session::widget() { | 40 | QWidget* Session::widget() { |
40 | if (!m_emu ) | 41 | if (!m_emu ) |
41 | return 0l; | 42 | return 0l; |
42 | 43 | ||
43 | return m_emu->widget(); | 44 | return m_emu->widget(); |
44 | } | 45 | } |
46 | Profile Session::profile()const { | ||
47 | return m_prof; | ||
48 | } | ||
45 | /* | 49 | /* |
46 | WidgetLayer* Session::emulationWidget() { | 50 | WidgetLayer* Session::emulationWidget() { |
47 | return m_widLay; | 51 | return m_widLay; |
48 | } | 52 | } |
49 | */ | 53 | */ |
50 | void Session::connect() { | 54 | void Session::connect() { |
51 | if ( !m_layer || !m_emu ) | 55 | if ( !m_layer || !m_emu ) |
52 | return; | 56 | return; |
53 | 57 | ||
54 | QObject::connect(m_layer, SIGNAL(received(const QByteArray&) ), | 58 | QObject::connect(m_layer, SIGNAL(received(const QByteArray&) ), |
55 | m_emu, SLOT(recv(const QByteArray&) ) ); | 59 | m_emu, SLOT(recv(const QByteArray&) ) ); |
56 | QObject::connect(m_emu, SIGNAL(send(const QByteArray&) ), | 60 | QObject::connect(m_emu, SIGNAL(send(const QByteArray&) ), |
57 | m_layer, SLOT(send(const QByteArray&) ) ); | 61 | m_layer, SLOT(send(const QByteArray&) ) ); |
58 | QObject::connect(m_emu, SIGNAL(changeSize(int, int) ), | 62 | QObject::connect(m_emu, SIGNAL(changeSize(int, int) ), |
59 | m_layer, SLOT(setSize(int, int) ) ); | 63 | m_layer, SLOT(setSize(int, int) ) ); |
60 | } | 64 | } |
61 | 65 | ||
62 | void Session::disconnect() { | 66 | void Session::disconnect() { |
63 | 67 | ||
64 | if ( !m_layer || !m_emu ) | 68 | if ( !m_layer || !m_emu ) |
65 | return; | 69 | return; |
66 | 70 | ||
67 | QObject::disconnect(m_layer, SIGNAL(received(const QByteArray&) ), | 71 | QObject::disconnect(m_layer, SIGNAL(received(const QByteArray&) ), |
68 | m_emu, SLOT(recv(const QByteArray&) ) ); | 72 | m_emu, SLOT(recv(const QByteArray&) ) ); |
69 | QObject::disconnect(m_emu, SIGNAL(send(const QByteArray&) ), | 73 | QObject::disconnect(m_emu, SIGNAL(send(const QByteArray&) ), |
70 | m_layer, SLOT(send(const QByteArray&) ) ); | 74 | m_layer, SLOT(send(const QByteArray&) ) ); |
71 | } | 75 | } |
72 | 76 | ||
73 | void Session::setName( const QString& na){ | 77 | void Session::setName( const QString& na){ |
74 | m_name = na; | 78 | m_name = na; |
75 | } | 79 | } |
76 | 80 | ||
77 | void Session::setWidgetStack( QWidgetStack* wid ) { | 81 | void Session::setWidgetStack( QWidgetStack* wid ) { |
78 | delete m_emu; | 82 | delete m_emu; |
79 | m_emu = 0l; | 83 | m_emu = 0l; |
80 | delete m_widget; | 84 | delete m_widget; |
81 | /* the EmulationLayer was destroyed... */ | 85 | /* the EmulationLayer was destroyed... */ |
82 | 86 | ||
83 | m_widget = wid; | 87 | m_widget = wid; |
84 | } | 88 | } |
85 | void Session::setIOLayer( IOLayer* lay ) { | 89 | void Session::setIOLayer( IOLayer* lay ) { |
86 | delete m_layer; | 90 | delete m_layer; |
87 | m_layer = lay; | 91 | m_layer = lay; |
88 | } | 92 | } |
89 | 93 | ||
90 | void Session::setEmulationHandler( EmulationHandler* lay ) { | 94 | void Session::setEmulationHandler( EmulationHandler* lay ) { |
91 | delete m_emu; | 95 | delete m_emu; |
92 | m_emu = lay; | 96 | m_emu = lay; |
93 | } | 97 | } |
98 | void Session::setProfile( const Profile& prof ) { | ||
99 | m_prof = prof; | ||
100 | } | ||
94 | /* | 101 | /* |
95 | void Session::setEmulationWidget( WidgetLayer* lay ) { | 102 | void Session::setEmulationWidget( WidgetLayer* lay ) { |
96 | delete m_widLay; | 103 | delete m_widLay; |
97 | m_widLay = lay; | 104 | m_widLay = lay; |
98 | } | 105 | } |
99 | */ | 106 | */ |
100 | 107 | ||
diff --git a/noncore/apps/opie-console/session.h b/noncore/apps/opie-console/session.h index 83b2046..f60a6c0 100644 --- a/noncore/apps/opie-console/session.h +++ b/noncore/apps/opie-console/session.h | |||
@@ -1,72 +1,77 @@ | |||
1 | #ifndef OPIE_SESSION_H | 1 | #ifndef OPIE_SESSION_H |
2 | #define OPIE_SESSION_H | 2 | #define OPIE_SESSION_H |
3 | 3 | ||
4 | #include <qwidgetstack.h> | 4 | #include <qwidgetstack.h> |
5 | 5 | ||
6 | #include "profile.h" | ||
7 | |||
6 | class IOLayer; | 8 | class IOLayer; |
7 | class EmulationHandler; | 9 | class EmulationHandler; |
8 | /** | 10 | /** |
9 | * This is a Session. A session contains | 11 | * This is a Session. A session contains |
10 | * a QWidget pointer and a IOLayer | 12 | * a QWidget pointer and a IOLayer |
11 | * Imagine a session like a collection of what | 13 | * Imagine a session like a collection of what |
12 | * is needed to show your widget in a tab ;) | 14 | * is needed to show your widget in a tab ;) |
13 | */ | 15 | */ |
14 | class Session { | 16 | class Session { |
15 | public: | 17 | public: |
16 | /** | 18 | /** |
17 | * c'tor with widget and layer | 19 | * c'tor with widget and layer |
18 | * ownership get's transfered | 20 | * ownership get's transfered |
19 | */ | 21 | */ |
20 | Session(); | 22 | Session(); |
21 | Session( const QString&, QWidgetStack* widget, IOLayer* ); | 23 | Session( const QString&, QWidgetStack* widget, IOLayer* ); |
22 | ~Session(); | 24 | ~Session(); |
23 | 25 | ||
24 | /** | 26 | /** |
25 | * return the name of the session | 27 | * return the name of the session |
26 | */ | 28 | */ |
27 | QString name()const; | 29 | QString name()const; |
28 | 30 | ||
29 | /** | 31 | /** |
30 | * return the widgetstack | 32 | * return the widgetstack |
31 | * this is used to be semi modal | 33 | * this is used to be semi modal |
32 | * for FileTransfer | 34 | * for FileTransfer |
33 | * | 35 | * |
34 | * semi modal == SessionModal | 36 | * semi modal == SessionModal |
35 | */ | 37 | */ |
36 | QWidgetStack* widgetStack(); | 38 | QWidgetStack* widgetStack(); |
37 | QWidget* widget(); | 39 | QWidget* widget(); |
38 | 40 | ||
39 | /** | 41 | /** |
40 | * return the layer | 42 | * return the layer |
41 | */ | 43 | */ |
42 | IOLayer* layer(); | 44 | IOLayer* layer(); |
43 | 45 | ||
44 | EmulationHandler* emulationHandler(); | 46 | EmulationHandler* emulationHandler(); |
47 | Profile profile()const; | ||
45 | 48 | ||
46 | /* | 49 | /* |
47 | * connects the data flow from | 50 | * connects the data flow from |
48 | * the IOLayer to the EmulationLayer | 51 | * the IOLayer to the EmulationLayer |
49 | */ | 52 | */ |
50 | void connect(); | 53 | void connect(); |
51 | 54 | ||
52 | /* | 55 | /* |
53 | * disconnect the dataflow | 56 | * disconnect the dataflow |
54 | * this will be done for ft | 57 | * this will be done for ft |
55 | */ | 58 | */ |
56 | void disconnect(); | 59 | void disconnect(); |
57 | 60 | ||
58 | void setWidgetStack( QWidgetStack* widget ); | 61 | void setWidgetStack( QWidgetStack* widget ); |
59 | void setEmulationHandler( EmulationHandler* lay ); | 62 | void setEmulationHandler( EmulationHandler* lay ); |
60 | void setIOLayer( IOLayer* ); | 63 | void setIOLayer( IOLayer* ); |
61 | void setName( const QString& ); | 64 | void setName( const QString& ); |
65 | void setProfile( const Profile& ); | ||
62 | 66 | ||
63 | private: | 67 | private: |
64 | QString m_name; | 68 | QString m_name; |
65 | QWidgetStack* m_widget; | 69 | QWidgetStack* m_widget; |
66 | IOLayer* m_layer; | 70 | IOLayer* m_layer; |
67 | EmulationHandler* m_emu; | 71 | EmulationHandler* m_emu; |
68 | bool m_connected; | 72 | bool m_connected : 1; |
73 | Profile m_prof; | ||
69 | 74 | ||
70 | }; | 75 | }; |
71 | 76 | ||
72 | #endif | 77 | #endif |