author | ar <ar> | 2004-05-02 16:22:24 (UTC) |
---|---|---|
committer | ar <ar> | 2004-05-02 16:22:24 (UTC) |
commit | 34f1234b010fa80f9ca06e65f46130713f7362d9 (patch) (unidiff) | |
tree | 6ded6dcd83ed00b436f312f2403f7afc9f399435 | |
parent | 4e7ab937501b6495ce5635a7515e66a75e04d37e (diff) | |
download | opie-34f1234b010fa80f9ca06e65f46130713f7362d9.zip opie-34f1234b010fa80f9ca06e65f46130713f7362d9.tar.gz opie-34f1234b010fa80f9ca06e65f46130713f7362d9.tar.bz2 |
- convert qDebug to odebug
-rw-r--r-- | core/apps/embeddedkonsole/TEScreen.cpp | 2 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/TEWidget.cpp | 6 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/commandeditdialog.cpp | 4 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/konsole.cpp | 41 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/main.cpp | 8 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/playlistselection.cpp | 11 |
6 files changed, 38 insertions, 34 deletions
diff --git a/core/apps/embeddedkonsole/TEScreen.cpp b/core/apps/embeddedkonsole/TEScreen.cpp index 3dbcec2..8e69a88 100644 --- a/core/apps/embeddedkonsole/TEScreen.cpp +++ b/core/apps/embeddedkonsole/TEScreen.cpp | |||
@@ -1,1236 +1,1236 @@ | |||
1 | /* -------------------------------------------------------------------------- */ | 1 | /* -------------------------------------------------------------------------- */ |
2 | /* */ | 2 | /* */ |
3 | /* [TEScreen.C] Screen Data Type */ | 3 | /* [TEScreen.C] Screen Data Type */ |
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 | // enhancements added by L.J. Potter <ljp@llornkcor.com> | 18 | // enhancements added by L.J. Potter <ljp@llornkcor.com> |
19 | 19 | ||
20 | /*! \file | 20 | /*! \file |
21 | */ | 21 | */ |
22 | 22 | ||
23 | /*! \class TEScreen | 23 | /*! \class TEScreen |
24 | 24 | ||
25 | \brief The image manipulated by the emulation. | 25 | \brief The image manipulated by the emulation. |
26 | 26 | ||
27 | This class implements the operations of the terminal emulation framework. | 27 | This class implements the operations of the terminal emulation framework. |
28 | It is a complete passive device, driven by the emulation decoder | 28 | It is a complete passive device, driven by the emulation decoder |
29 | (TEmuVT102). By this it forms in fact an ADT, that defines operations | 29 | (TEmuVT102). By this it forms in fact an ADT, that defines operations |
30 | on a rectangular image. | 30 | on a rectangular image. |
31 | 31 | ||
32 | It does neither know how to display its image nor about escape sequences. | 32 | It does neither know how to display its image nor about escape sequences. |
33 | It is further independent of the underlying toolkit. By this, one can even | 33 | It is further independent of the underlying toolkit. By this, one can even |
34 | use this module for an ordinary text surface. | 34 | use this module for an ordinary text surface. |
35 | 35 | ||
36 | Since the operations are called by a specific emulation decoder, one may | 36 | Since the operations are called by a specific emulation decoder, one may |
37 | collect their different operations here. | 37 | collect their different operations here. |
38 | 38 | ||
39 | The state manipulated by the operations is mainly kept in `image', though | 39 | The state manipulated by the operations is mainly kept in `image', though |
40 | it is a little more complex bejond this. See the header file of the class. | 40 | it is a little more complex bejond this. See the header file of the class. |
41 | 41 | ||
42 | \sa TEWidget \sa VT102Emulation | 42 | \sa TEWidget \sa VT102Emulation |
43 | */ | 43 | */ |
44 | 44 | ||
45 | #include <stdio.h> | 45 | #include <stdio.h> |
46 | #include <stdlib.h> | 46 | #include <stdlib.h> |
47 | #include <unistd.h> | 47 | #include <unistd.h> |
48 | // #include <kdebug.h> | 48 | // #include <kdebug.h> |
49 | 49 | ||
50 | #include <assert.h> | 50 | #include <assert.h> |
51 | #include <string.h> | 51 | #include <string.h> |
52 | #include <ctype.h> | 52 | #include <ctype.h> |
53 | 53 | ||
54 | #include <qpe/config.h> | 54 | #include <qpe/config.h> |
55 | #include "TEScreen.h" | 55 | #include "TEScreen.h" |
56 | 56 | ||
57 | #define HERE printf("%s(%d): here\n",__FILE__,__LINE__) | 57 | #define HERE printf("%s(%d): here\n",__FILE__,__LINE__) |
58 | 58 | ||
59 | //FIXME: this is emulation specific. Use FALSE for xterm, TRUE for ANSI. | 59 | //FIXME: this is emulation specific. Use FALSE for xterm, TRUE for ANSI. |
60 | //FIXME: see if we can get this from terminfo. | 60 | //FIXME: see if we can get this from terminfo. |
61 | #define BS_CLEARS FALSE | 61 | #define BS_CLEARS FALSE |
62 | 62 | ||
63 | #define loc(X,Y) ((Y) * columns + (X)) | 63 | #define loc(X,Y) ((Y) * columns + (X)) |
64 | 64 | ||
65 | /*! creates a `TEScreen' of `lines' lines and `columns' columns. | 65 | /*! creates a `TEScreen' of `lines' lines and `columns' columns. |
66 | */ | 66 | */ |
67 | 67 | ||
68 | TEScreen::TEScreen(int lines, int columns) | 68 | TEScreen::TEScreen(int lines, int columns) |
69 | { | 69 | { |
70 | this->lines = lines; | 70 | this->lines = lines; |
71 | this->columns = columns; | 71 | this->columns = columns; |
72 | // qDebug("Columns %d", columns); | 72 | // odebug << "Columns " << columns << "" << oendl; |
73 | 73 | ||
74 | image = (ca*) malloc(lines*columns*sizeof(ca)); | 74 | image = (ca*) malloc(lines*columns*sizeof(ca)); |
75 | tabstops = NULL; initTabStops(); | 75 | tabstops = NULL; initTabStops(); |
76 | 76 | ||
77 | histCursor = 0; | 77 | histCursor = 0; |
78 | horzCursor = 0; | 78 | horzCursor = 0; |
79 | 79 | ||
80 | clearSelection(); | 80 | clearSelection(); |
81 | reset(); | 81 | reset(); |
82 | } | 82 | } |
83 | 83 | ||
84 | /*! Destructor | 84 | /*! Destructor |
85 | */ | 85 | */ |
86 | 86 | ||
87 | TEScreen::~TEScreen() | 87 | TEScreen::~TEScreen() |
88 | { | 88 | { |
89 | free(image); | 89 | free(image); |
90 | if (tabstops) free(tabstops); | 90 | if (tabstops) free(tabstops); |
91 | } | 91 | } |
92 | 92 | ||
93 | /* ------------------------------------------------------------------------- */ | 93 | /* ------------------------------------------------------------------------- */ |
94 | /* */ | 94 | /* */ |
95 | /* Normalized Screen Operations */ | 95 | /* Normalized Screen Operations */ |
96 | /* */ | 96 | /* */ |
97 | /* ------------------------------------------------------------------------- */ | 97 | /* ------------------------------------------------------------------------- */ |
98 | 98 | ||
99 | // Cursor Setting -------------------------------------------------------------- | 99 | // Cursor Setting -------------------------------------------------------------- |
100 | 100 | ||
101 | /*! \section Cursor | 101 | /*! \section Cursor |
102 | 102 | ||
103 | The `cursor' is a location within the screen that is implicitely used in | 103 | The `cursor' is a location within the screen that is implicitely used in |
104 | many operations. The operations within this section allow to manipulate | 104 | many operations. The operations within this section allow to manipulate |
105 | the cursor explicitly and to obtain it's value. | 105 | the cursor explicitly and to obtain it's value. |
106 | 106 | ||
107 | The position of the cursor is guarantied to be between (including) 0 and | 107 | The position of the cursor is guarantied to be between (including) 0 and |
108 | `columns-1' and `lines-1'. | 108 | `columns-1' and `lines-1'. |
109 | */ | 109 | */ |
110 | 110 | ||
111 | /*! | 111 | /*! |
112 | Move the cursor up. | 112 | Move the cursor up. |
113 | 113 | ||
114 | The cursor will not be moved beyond the top margin. | 114 | The cursor will not be moved beyond the top margin. |
115 | */ | 115 | */ |
116 | 116 | ||
117 | void TEScreen::cursorUp(int n) | 117 | void TEScreen::cursorUp(int n) |
118 | //=CUU | 118 | //=CUU |
119 | { | 119 | { |
120 | if (n == 0) n = 1; // Default | 120 | if (n == 0) n = 1; // Default |
121 | int stop = cuY < tmargin ? 0 : tmargin; | 121 | int stop = cuY < tmargin ? 0 : tmargin; |
122 | cuX = QMIN(columns-1,cuX); // nowrap! | 122 | cuX = QMIN(columns-1,cuX); // nowrap! |
123 | cuY = QMAX(stop,cuY-n); | 123 | cuY = QMAX(stop,cuY-n); |
124 | } | 124 | } |
125 | 125 | ||
126 | /*! | 126 | /*! |
127 | Move the cursor down. | 127 | Move the cursor down. |
128 | 128 | ||
129 | The cursor will not be moved beyond the bottom margin. | 129 | The cursor will not be moved beyond the bottom margin. |
130 | */ | 130 | */ |
131 | 131 | ||
132 | void TEScreen::cursorDown(int n) | 132 | void TEScreen::cursorDown(int n) |
133 | //=CUD | 133 | //=CUD |
134 | { | 134 | { |
135 | if (n == 0) n = 1; // Default | 135 | if (n == 0) n = 1; // Default |
136 | int stop = cuY > bmargin ? lines-1 : bmargin; | 136 | int stop = cuY > bmargin ? lines-1 : bmargin; |
137 | cuX = QMIN(columns-1,cuX); // nowrap! | 137 | cuX = QMIN(columns-1,cuX); // nowrap! |
138 | cuY = QMIN(stop,cuY+n); | 138 | cuY = QMIN(stop,cuY+n); |
139 | } | 139 | } |
140 | 140 | ||
141 | /*! | 141 | /*! |
142 | Move the cursor left. | 142 | Move the cursor left. |
143 | 143 | ||
144 | The cursor will not move beyond the first column. | 144 | The cursor will not move beyond the first column. |
145 | */ | 145 | */ |
146 | 146 | ||
147 | void TEScreen::cursorLeft(int n) | 147 | void TEScreen::cursorLeft(int n) |
148 | //=CUB | 148 | //=CUB |
149 | { | 149 | { |
150 | if (n == 0) n = 1; // Default | 150 | if (n == 0) n = 1; // Default |
151 | cuX = QMIN(columns-1,cuX); // nowrap! | 151 | cuX = QMIN(columns-1,cuX); // nowrap! |
152 | cuX = QMAX(0,cuX-n); | 152 | cuX = QMAX(0,cuX-n); |
153 | } | 153 | } |
154 | 154 | ||
155 | /*! | 155 | /*! |
156 | Move the cursor left. | 156 | Move the cursor left. |
157 | 157 | ||
158 | The cursor will not move beyond the rightmost column. | 158 | The cursor will not move beyond the rightmost column. |
159 | */ | 159 | */ |
160 | 160 | ||
161 | void TEScreen::cursorRight(int n) | 161 | void TEScreen::cursorRight(int n) |
162 | //=CUF | 162 | //=CUF |
163 | { | 163 | { |
164 | if (n == 0) n = 1; // Default | 164 | if (n == 0) n = 1; // Default |
165 | cuX = QMIN(columns-1,cuX+n); | 165 | cuX = QMIN(columns-1,cuX+n); |
166 | } | 166 | } |
167 | 167 | ||
168 | /*! | 168 | /*! |
169 | Set top and bottom margin. | 169 | Set top and bottom margin. |
170 | */ | 170 | */ |
171 | 171 | ||
172 | void TEScreen::setMargins(int top, int bot) | 172 | void TEScreen::setMargins(int top, int bot) |
173 | //=STBM | 173 | //=STBM |
174 | { | 174 | { |
175 | if (top == 0) top = 1; // Default | 175 | if (top == 0) top = 1; // Default |
176 | if (bot == 0) bot = lines; // Default | 176 | if (bot == 0) bot = lines; // Default |
177 | top = top - 1; // Adjust to internal lineno | 177 | top = top - 1; // Adjust to internal lineno |
178 | bot = bot - 1; // Adjust to internal lineno | 178 | bot = bot - 1; // Adjust to internal lineno |
179 | if ( !( 0 <= top && top < bot && bot < lines ) ) | 179 | if ( !( 0 <= top && top < bot && bot < lines ) ) |
180 | { fprintf(stderr,"%s(%d) : setRegion(%d,%d) : bad range.\n", | 180 | { fprintf(stderr,"%s(%d) : setRegion(%d,%d) : bad range.\n", |
181 | __FILE__,__LINE__,top,bot); | 181 | __FILE__,__LINE__,top,bot); |
182 | return; // Default error action: ignore | 182 | return; // Default error action: ignore |
183 | } | 183 | } |
184 | tmargin = top; | 184 | tmargin = top; |
185 | bmargin = bot; | 185 | bmargin = bot; |
186 | cuX = 0; | 186 | cuX = 0; |
187 | cuY = getMode(MODE_Origin) ? top : 0; | 187 | cuY = getMode(MODE_Origin) ? top : 0; |
188 | } | 188 | } |
189 | 189 | ||
190 | /*! | 190 | /*! |
191 | Move the cursor down one line. | 191 | Move the cursor down one line. |
192 | 192 | ||
193 | If cursor is on bottom margin, the region between the | 193 | If cursor is on bottom margin, the region between the |
194 | actual top and bottom margin is scrolled up instead. | 194 | actual top and bottom margin is scrolled up instead. |
195 | */ | 195 | */ |
196 | 196 | ||
197 | void TEScreen::index() | 197 | void TEScreen::index() |
198 | //=IND | 198 | //=IND |
199 | { | 199 | { |
200 | if (cuY == bmargin) | 200 | if (cuY == bmargin) |
201 | { | 201 | { |
202 | if (tmargin == 0 && bmargin == lines-1) addHistLine(); // hist.history | 202 | if (tmargin == 0 && bmargin == lines-1) addHistLine(); // hist.history |
203 | scrollUp(tmargin,1); | 203 | scrollUp(tmargin,1); |
204 | } | 204 | } |
205 | else if (cuY < lines-1) | 205 | else if (cuY < lines-1) |
206 | cuY += 1; | 206 | cuY += 1; |
207 | } | 207 | } |
208 | 208 | ||
209 | /*! | 209 | /*! |
210 | Move the cursor up one line. | 210 | Move the cursor up one line. |
211 | 211 | ||
212 | If cursor is on the top margin, the region between the | 212 | If cursor is on the top margin, the region between the |
213 | actual top and bottom margin is scrolled down instead. | 213 | actual top and bottom margin is scrolled down instead. |
214 | */ | 214 | */ |
215 | 215 | ||
216 | void TEScreen::reverseIndex() | 216 | void TEScreen::reverseIndex() |
217 | //=RI | 217 | //=RI |
218 | { | 218 | { |
219 | if (cuY == tmargin) | 219 | if (cuY == tmargin) |
220 | scrollDown(tmargin,1); | 220 | scrollDown(tmargin,1); |
221 | else if (cuY > 0) | 221 | else if (cuY > 0) |
222 | cuY -= 1; | 222 | cuY -= 1; |
223 | } | 223 | } |
224 | 224 | ||
225 | /*! | 225 | /*! |
226 | Move the cursor to the begin of the next line. | 226 | Move the cursor to the begin of the next line. |
227 | 227 | ||
228 | If cursor is on bottom margin, the region between the | 228 | If cursor is on bottom margin, the region between the |
229 | actual top and bottom margin is scrolled up. | 229 | actual top and bottom margin is scrolled up. |
230 | */ | 230 | */ |
231 | 231 | ||
232 | void TEScreen::NextLine() | 232 | void TEScreen::NextLine() |
233 | //=NEL | 233 | //=NEL |
234 | { | 234 | { |
235 | Return(); index(); | 235 | Return(); index(); |
236 | } | 236 | } |
237 | 237 | ||
238 | // Line Editing ---------------------------------------------------------------- | 238 | // Line Editing ---------------------------------------------------------------- |
239 | 239 | ||
240 | /*! \section inserting / deleting characters | 240 | /*! \section inserting / deleting characters |
241 | */ | 241 | */ |
242 | 242 | ||
243 | /*! erase `n' characters starting from (including) the cursor position. | 243 | /*! erase `n' characters starting from (including) the cursor position. |
244 | 244 | ||
245 | The line is filled in from the right with spaces. | 245 | The line is filled in from the right with spaces. |
246 | */ | 246 | */ |
247 | 247 | ||
248 | void TEScreen::eraseChars(int n) | 248 | void TEScreen::eraseChars(int n) |
249 | { | 249 | { |
250 | if (n == 0) n = 1; // Default | 250 | if (n == 0) n = 1; // Default |
251 | int p = QMAX(0,QMIN(cuX+n-1,columns-1)); | 251 | int p = QMAX(0,QMIN(cuX+n-1,columns-1)); |
252 | clearImage(loc(cuX,cuY),loc(p,cuY),' '); | 252 | clearImage(loc(cuX,cuY),loc(p,cuY),' '); |
253 | } | 253 | } |
254 | 254 | ||
255 | /*! delete `n' characters starting from (including) the cursor position. | 255 | /*! delete `n' characters starting from (including) the cursor position. |
256 | 256 | ||
257 | The line is filled in from the right with spaces. | 257 | The line is filled in from the right with spaces. |
258 | */ | 258 | */ |
259 | 259 | ||
260 | void TEScreen::deleteChars(int n) | 260 | void TEScreen::deleteChars(int n) |
261 | { | 261 | { |
262 | if (n == 0) n = 1; // Default | 262 | if (n == 0) n = 1; // Default |
263 | int p = QMAX(0,QMIN(cuX+n,columns-1)); | 263 | int p = QMAX(0,QMIN(cuX+n,columns-1)); |
264 | moveImage(loc(cuX,cuY),loc(p,cuY),loc(columns-1,cuY)); | 264 | moveImage(loc(cuX,cuY),loc(p,cuY),loc(columns-1,cuY)); |
265 | clearImage(loc(columns-n,cuY),loc(columns-1,cuY),' '); | 265 | clearImage(loc(columns-n,cuY),loc(columns-1,cuY),' '); |
266 | } | 266 | } |
267 | 267 | ||
268 | /*! insert `n' spaces at the cursor position. | 268 | /*! insert `n' spaces at the cursor position. |
269 | 269 | ||
270 | The cursor is not moved by the operation. | 270 | The cursor is not moved by the operation. |
271 | */ | 271 | */ |
272 | 272 | ||
273 | void TEScreen::insertChars(int n) | 273 | void TEScreen::insertChars(int n) |
274 | { | 274 | { |
275 | if (n == 0) n = 1; // Default | 275 | if (n == 0) n = 1; // Default |
276 | int p = QMAX(0,QMIN(columns-1-n,columns-1)); | 276 | int p = QMAX(0,QMIN(columns-1-n,columns-1)); |
277 | int q = QMAX(0,QMIN(cuX+n,columns-1)); | 277 | int q = QMAX(0,QMIN(cuX+n,columns-1)); |
278 | moveImage(loc(q,cuY),loc(cuX,cuY),loc(p,cuY)); | 278 | moveImage(loc(q,cuY),loc(cuX,cuY),loc(p,cuY)); |
279 | clearImage(loc(cuX,cuY),loc(q-1,cuY),' '); | 279 | clearImage(loc(cuX,cuY),loc(q-1,cuY),' '); |
280 | } | 280 | } |
281 | 281 | ||
282 | /*! delete `n' lines starting from (including) the cursor position. | 282 | /*! delete `n' lines starting from (including) the cursor position. |
283 | 283 | ||
284 | The cursor is not moved by the operation. | 284 | The cursor is not moved by the operation. |
285 | */ | 285 | */ |
286 | 286 | ||
287 | void TEScreen::deleteLines(int n) | 287 | void TEScreen::deleteLines(int n) |
288 | { | 288 | { |
289 | if (n == 0) n = 1; // Default | 289 | if (n == 0) n = 1; // Default |
290 | scrollUp(cuY,n); | 290 | scrollUp(cuY,n); |
291 | } | 291 | } |
292 | 292 | ||
293 | /*! insert `n' lines at the cursor position. | 293 | /*! insert `n' lines at the cursor position. |
294 | 294 | ||
295 | The cursor is not moved by the operation. | 295 | The cursor is not moved by the operation. |
296 | */ | 296 | */ |
297 | 297 | ||
298 | void TEScreen::insertLines(int n) | 298 | void TEScreen::insertLines(int n) |
299 | { | 299 | { |
300 | if (n == 0) n = 1; // Default | 300 | if (n == 0) n = 1; // Default |
301 | scrollDown(cuY,n); | 301 | scrollDown(cuY,n); |
302 | } | 302 | } |
303 | 303 | ||
304 | // Mode Operations ----------------------------------------------------------- | 304 | // Mode Operations ----------------------------------------------------------- |
305 | 305 | ||
306 | /*! Set a specific mode. */ | 306 | /*! Set a specific mode. */ |
307 | 307 | ||
308 | void TEScreen::setMode(int m) | 308 | void TEScreen::setMode(int m) |
309 | { | 309 | { |
310 | currParm.mode[m] = TRUE; | 310 | currParm.mode[m] = TRUE; |
311 | switch(m) | 311 | switch(m) |
312 | { | 312 | { |
313 | case MODE_Origin : cuX = 0; cuY = tmargin; break; //FIXME: home | 313 | case MODE_Origin : cuX = 0; cuY = tmargin; break; //FIXME: home |
314 | } | 314 | } |
315 | } | 315 | } |
316 | 316 | ||
317 | /*! Reset a specific mode. */ | 317 | /*! Reset a specific mode. */ |
318 | 318 | ||
319 | void TEScreen::resetMode(int m) | 319 | void TEScreen::resetMode(int m) |
320 | { | 320 | { |
321 | currParm.mode[m] = FALSE; | 321 | currParm.mode[m] = FALSE; |
322 | switch(m) | 322 | switch(m) |
323 | { | 323 | { |
324 | case MODE_Origin : cuX = 0; cuY = 0; break; //FIXME: home | 324 | case MODE_Origin : cuX = 0; cuY = 0; break; //FIXME: home |
325 | } | 325 | } |
326 | } | 326 | } |
327 | 327 | ||
328 | /*! Save a specific mode. */ | 328 | /*! Save a specific mode. */ |
329 | 329 | ||
330 | void TEScreen::saveMode(int m) | 330 | void TEScreen::saveMode(int m) |
331 | { | 331 | { |
332 | saveParm.mode[m] = currParm.mode[m]; | 332 | saveParm.mode[m] = currParm.mode[m]; |
333 | } | 333 | } |
334 | 334 | ||
335 | /*! Restore a specific mode. */ | 335 | /*! Restore a specific mode. */ |
336 | 336 | ||
337 | void TEScreen::restoreMode(int m) | 337 | void TEScreen::restoreMode(int m) |
338 | { | 338 | { |
339 | currParm.mode[m] = saveParm.mode[m]; | 339 | currParm.mode[m] = saveParm.mode[m]; |
340 | } | 340 | } |
341 | 341 | ||
342 | //NOTE: this is a helper function | 342 | //NOTE: this is a helper function |
343 | /*! Return the setting a specific mode. */ | 343 | /*! Return the setting a specific mode. */ |
344 | BOOL TEScreen::getMode(int m) | 344 | BOOL TEScreen::getMode(int m) |
345 | { | 345 | { |
346 | return currParm.mode[m]; | 346 | return currParm.mode[m]; |
347 | } | 347 | } |
348 | 348 | ||
349 | /*! Save the cursor position and the rendition attribute settings. */ | 349 | /*! Save the cursor position and the rendition attribute settings. */ |
350 | 350 | ||
351 | void TEScreen::saveCursor() | 351 | void TEScreen::saveCursor() |
352 | { | 352 | { |
353 | sa_cuX = cuX; | 353 | sa_cuX = cuX; |
354 | sa_cuY = cuY; | 354 | sa_cuY = cuY; |
355 | sa_cu_re = cu_re; | 355 | sa_cu_re = cu_re; |
356 | sa_cu_fg = cu_fg; | 356 | sa_cu_fg = cu_fg; |
357 | sa_cu_bg = cu_bg; | 357 | sa_cu_bg = cu_bg; |
358 | } | 358 | } |
359 | 359 | ||
360 | /*! Restore the cursor position and the rendition attribute settings. */ | 360 | /*! Restore the cursor position and the rendition attribute settings. */ |
361 | 361 | ||
362 | void TEScreen::restoreCursor() | 362 | void TEScreen::restoreCursor() |
363 | { | 363 | { |
364 | cuX = QMIN(sa_cuX,columns-1); | 364 | cuX = QMIN(sa_cuX,columns-1); |
365 | cuY = QMIN(sa_cuY,lines-1); | 365 | cuY = QMIN(sa_cuY,lines-1); |
366 | cu_re = sa_cu_re; | 366 | cu_re = sa_cu_re; |
367 | cu_fg = sa_cu_fg; | 367 | cu_fg = sa_cu_fg; |
368 | cu_bg = sa_cu_bg; | 368 | cu_bg = sa_cu_bg; |
369 | effectiveRendition(); | 369 | effectiveRendition(); |
370 | } | 370 | } |
371 | 371 | ||
372 | /* ------------------------------------------------------------------------- */ | 372 | /* ------------------------------------------------------------------------- */ |
373 | /* */ | 373 | /* */ |
374 | /* Screen Operations */ | 374 | /* Screen Operations */ |
375 | /* */ | 375 | /* */ |
376 | /* ------------------------------------------------------------------------- */ | 376 | /* ------------------------------------------------------------------------- */ |
377 | 377 | ||
378 | /*! Assing a new size to the screen. | 378 | /*! Assing a new size to the screen. |
379 | 379 | ||
380 | The topmost left position is maintained, while lower lines | 380 | The topmost left position is maintained, while lower lines |
381 | or right hand side columns might be removed or filled with | 381 | or right hand side columns might be removed or filled with |
382 | spaces to fit the new size. | 382 | spaces to fit the new size. |
383 | 383 | ||
384 | The region setting is reset to the whole screen and the | 384 | The region setting is reset to the whole screen and the |
385 | tab positions reinitialized. | 385 | tab positions reinitialized. |
386 | */ | 386 | */ |
387 | 387 | ||
388 | void TEScreen::resizeImage(int new_lines, int new_columns) | 388 | void TEScreen::resizeImage(int new_lines, int new_columns) |
389 | { | 389 | { |
390 | if (cuY > new_lines-1) { | 390 | if (cuY > new_lines-1) { |
391 | // attempt to preserve focus and lines | 391 | // attempt to preserve focus and lines |
392 | bmargin = lines-1; //FIXME: margin lost | 392 | bmargin = lines-1; //FIXME: margin lost |
393 | for (int i = 0; i < cuY-(new_lines-1); i++) { | 393 | for (int i = 0; i < cuY-(new_lines-1); i++) { |
394 | addHistLine(); scrollUp(horzCursor,1); | 394 | addHistLine(); scrollUp(horzCursor,1); |
395 | } | 395 | } |
396 | } | 396 | } |
397 | 397 | ||
398 | // make new image | 398 | // make new image |
399 | ca* newimg = (ca*)malloc( new_lines * new_columns * sizeof( ca)); | 399 | ca* newimg = (ca*)malloc( new_lines * new_columns * sizeof( ca)); |
400 | 400 | ||
401 | clearSelection(); | 401 | clearSelection(); |
402 | 402 | ||
403 | // clear new image | 403 | // clear new image |
404 | for (int y = 0; y < new_lines; y++) | 404 | for (int y = 0; y < new_lines; y++) |
405 | for (int x = 0; x < new_columns; x++) { | 405 | for (int x = 0; x < new_columns; x++) { |
406 | newimg[y*new_columns+x].c = ' '; | 406 | newimg[y*new_columns+x].c = ' '; |
407 | newimg[y*new_columns+x].f = DEFAULT_FORE_COLOR; | 407 | newimg[y*new_columns+x].f = DEFAULT_FORE_COLOR; |
408 | newimg[y*new_columns+x].b = DEFAULT_BACK_COLOR; | 408 | newimg[y*new_columns+x].b = DEFAULT_BACK_COLOR; |
409 | newimg[y*new_columns+x].r = DEFAULT_RENDITION; | 409 | newimg[y*new_columns+x].r = DEFAULT_RENDITION; |
410 | } | 410 | } |
411 | int cpy_lines = QMIN(new_lines, lines); | 411 | int cpy_lines = QMIN(new_lines, lines); |
412 | int cpy_columns = QMIN(new_columns,columns); | 412 | int cpy_columns = QMIN(new_columns,columns); |
413 | // copy to new image | 413 | // copy to new image |
414 | for (int y = 0; y < cpy_lines; y++) | 414 | for (int y = 0; y < cpy_lines; y++) |
415 | for (int x = 0; x < cpy_columns; x++) { | 415 | for (int x = 0; x < cpy_columns; x++) { |
416 | newimg[y*new_columns+x].c = image[loc(x,y)].c; | 416 | newimg[y*new_columns+x].c = image[loc(x,y)].c; |
417 | newimg[y*new_columns+x].f = image[loc(x,y)].f; | 417 | newimg[y*new_columns+x].f = image[loc(x,y)].f; |
418 | newimg[y*new_columns+x].b = image[loc(x,y)].b; | 418 | newimg[y*new_columns+x].b = image[loc(x,y)].b; |
419 | newimg[y*new_columns+x].r = image[loc(x,y)].r; | 419 | newimg[y*new_columns+x].r = image[loc(x,y)].r; |
420 | } | 420 | } |
421 | free(image); | 421 | free(image); |
422 | image = newimg; | 422 | image = newimg; |
423 | lines = new_lines; | 423 | lines = new_lines; |
424 | columns = new_columns; | 424 | columns = new_columns; |
425 | cuX = QMIN(cuX,columns-1); | 425 | cuX = QMIN(cuX,columns-1); |
426 | cuY = QMIN(cuY,lines-1); | 426 | cuY = QMIN(cuY,lines-1); |
427 | 427 | ||
428 | // FIXME: try to keep values, evtl. | 428 | // FIXME: try to keep values, evtl. |
429 | tmargin=0; | 429 | tmargin=0; |
430 | bmargin=lines-1; | 430 | bmargin=lines-1; |
431 | initTabStops(); | 431 | initTabStops(); |
432 | clearSelection(); | 432 | clearSelection(); |
433 | } | 433 | } |
434 | 434 | ||
435 | /* | 435 | /* |
436 | Clarifying rendition here and in TEWidget. | 436 | Clarifying rendition here and in TEWidget. |
437 | 437 | ||
438 | currently, TEWidget's color table is | 438 | currently, TEWidget's color table is |
439 | 0 1 2 .. 9 10 .. 17 | 439 | 0 1 2 .. 9 10 .. 17 |
440 | dft_fg, dft_bg, dim 0..7, intensive 0..7 | 440 | dft_fg, dft_bg, dim 0..7, intensive 0..7 |
441 | 441 | ||
442 | cu_fg, cu_bg contain values 0..8; | 442 | cu_fg, cu_bg contain values 0..8; |
443 | - 0 = default color | 443 | - 0 = default color |
444 | - 1..8 = ansi specified color | 444 | - 1..8 = ansi specified color |
445 | 445 | ||
446 | re_fg, re_bg contain values 0..17 | 446 | re_fg, re_bg contain values 0..17 |
447 | due to the TEWidget's color table | 447 | due to the TEWidget's color table |
448 | 448 | ||
449 | rendition attributes are | 449 | rendition attributes are |
450 | 450 | ||
451 | attr widget screen | 451 | attr widget screen |
452 | -------------- ------ ------ | 452 | -------------- ------ ------ |
453 | RE_UNDERLINE XX XX affects foreground only | 453 | RE_UNDERLINE XX XX affects foreground only |
454 | RE_BLINK XX XX affects foreground only | 454 | RE_BLINK XX XX affects foreground only |
455 | RE_BOLD XX XX affects foreground only | 455 | RE_BOLD XX XX affects foreground only |
456 | RE_REVERSE -- XX | 456 | RE_REVERSE -- XX |
457 | RE_TRANSPARENT XX -- affects background only | 457 | RE_TRANSPARENT XX -- affects background only |
458 | RE_INTENSIVE XX -- affects foreground only | 458 | RE_INTENSIVE XX -- affects foreground only |
459 | 459 | ||
460 | Note that RE_BOLD is used in both widget | 460 | Note that RE_BOLD is used in both widget |
461 | and screen rendition. Since xterm/vt102 | 461 | and screen rendition. Since xterm/vt102 |
462 | is to poor to distinguish between bold | 462 | is to poor to distinguish between bold |
463 | (which is a font attribute) and intensive | 463 | (which is a font attribute) and intensive |
464 | (which is a color attribute), we translate | 464 | (which is a color attribute), we translate |
465 | this and RE_BOLD in falls eventually appart | 465 | this and RE_BOLD in falls eventually appart |
466 | into RE_BOLD and RE_INTENSIVE. | 466 | into RE_BOLD and RE_INTENSIVE. |
467 | */ | 467 | */ |
468 | 468 | ||
469 | void TEScreen::reverseRendition(ca* p) | 469 | void TEScreen::reverseRendition(ca* p) |
470 | { UINT8 f = p->f; UINT8 b = p->b; | 470 | { UINT8 f = p->f; UINT8 b = p->b; |
471 | p->f = b; p->b = f; //p->r &= ~RE_TRANSPARENT; | 471 | p->f = b; p->b = f; //p->r &= ~RE_TRANSPARENT; |
472 | } | 472 | } |
473 | 473 | ||
474 | void TEScreen::effectiveRendition() | 474 | void TEScreen::effectiveRendition() |
475 | // calculate rendition | 475 | // calculate rendition |
476 | { | 476 | { |
477 | ef_re = cu_re & (RE_UNDERLINE | RE_BLINK); | 477 | ef_re = cu_re & (RE_UNDERLINE | RE_BLINK); |
478 | if (cu_re & RE_REVERSE) | 478 | if (cu_re & RE_REVERSE) |
479 | { | 479 | { |
480 | ef_fg = cu_bg; | 480 | ef_fg = cu_bg; |
481 | ef_bg = cu_fg; | 481 | ef_bg = cu_fg; |
482 | } | 482 | } |
483 | else | 483 | else |
484 | { | 484 | { |
485 | ef_fg = cu_fg; | 485 | ef_fg = cu_fg; |
486 | ef_bg = cu_bg; | 486 | ef_bg = cu_bg; |
487 | } | 487 | } |
488 | if (cu_re & RE_BOLD) | 488 | if (cu_re & RE_BOLD) |
489 | { | 489 | { |
490 | if (ef_fg < BASE_COLORS) | 490 | if (ef_fg < BASE_COLORS) |
491 | ef_fg += BASE_COLORS; | 491 | ef_fg += BASE_COLORS; |
492 | else | 492 | else |
493 | ef_fg -= BASE_COLORS; | 493 | ef_fg -= BASE_COLORS; |
494 | } | 494 | } |
495 | } | 495 | } |
496 | 496 | ||
497 | /*! | 497 | /*! |
498 | returns the image. | 498 | returns the image. |
499 | 499 | ||
500 | Get the size of the image by \sa getLines and \sa getColumns. | 500 | Get the size of the image by \sa getLines and \sa getColumns. |
501 | 501 | ||
502 | NOTE that the image returned by this function must later be | 502 | NOTE that the image returned by this function must later be |
503 | freed. | 503 | freed. |
504 | 504 | ||
505 | */ | 505 | */ |
506 | 506 | ||
507 | ca* TEScreen::getCookedImage() | 507 | ca* TEScreen::getCookedImage() |
508 | { | 508 | { |
509 | int x,y; | 509 | int x,y; |
510 | ca* merged = (ca*)malloc(lines*columns*sizeof(ca)); | 510 | ca* merged = (ca*)malloc(lines*columns*sizeof(ca)); |
511 | ca dft(' ',DEFAULT_FORE_COLOR,DEFAULT_BACK_COLOR,DEFAULT_RENDITION); | 511 | ca dft(' ',DEFAULT_FORE_COLOR,DEFAULT_BACK_COLOR,DEFAULT_RENDITION); |
512 | 512 | ||
513 | if (histCursor > hist.getLines()) { | 513 | if (histCursor > hist.getLines()) { |
514 | histCursor = hist.getLines(); | 514 | histCursor = hist.getLines(); |
515 | } | 515 | } |
516 | 516 | ||
517 | for (y = 0; (y < lines) && (y < (hist.getLines()-histCursor)); y++) | 517 | for (y = 0; (y < lines) && (y < (hist.getLines()-histCursor)); y++) |
518 | { | 518 | { |
519 | int len = QMIN(columns,hist.getLineLen(y+histCursor)); | 519 | int len = QMIN(columns,hist.getLineLen(y+histCursor)); |
520 | int yp = y*columns; | 520 | int yp = y*columns; |
521 | int yq = (y+histCursor)*columns; | 521 | int yq = (y+histCursor)*columns; |
522 | 522 | ||
523 | hist.getCells(y+histCursor,0,len,merged+yp); | 523 | hist.getCells(y+histCursor,0,len,merged+yp); |
524 | for (x = len; x < columns; x++) merged[yp+x] = dft; | 524 | for (x = len; x < columns; x++) merged[yp+x] = dft; |
525 | for (x = 0; x < columns; x++) | 525 | for (x = 0; x < columns; x++) |
526 | { int p=x + yp; int q=x + yq; | 526 | { int p=x + yp; int q=x + yq; |
527 | if ( ( q >= sel_TL ) && ( q <= sel_BR ) ) | 527 | if ( ( q >= sel_TL ) && ( q <= sel_BR ) ) |
528 | reverseRendition(&merged[p]); // for selection | 528 | reverseRendition(&merged[p]); // for selection |
529 | } | 529 | } |
530 | } | 530 | } |
531 | if (lines >= hist.getLines()-histCursor) | 531 | if (lines >= hist.getLines()-histCursor) |
532 | { | 532 | { |
533 | for (y = (hist.getLines()-histCursor); y < lines ; y++) | 533 | for (y = (hist.getLines()-histCursor); y < lines ; y++) |
534 | { | 534 | { |
535 | int yp = y*columns; | 535 | int yp = y*columns; |
536 | int yq = (y+histCursor)*columns; | 536 | int yq = (y+histCursor)*columns; |
537 | int yr = (y-hist.getLines()+histCursor)*columns; | 537 | int yr = (y-hist.getLines()+histCursor)*columns; |
538 | for (x = 0; x < columns; x++) | 538 | for (x = 0; x < columns; x++) |
539 | { int p = x + yp; int q = x + yq; int r = x + yr; | 539 | { int p = x + yp; int q = x + yq; int r = x + yr; |
540 | merged[p] = image[r]; | 540 | merged[p] = image[r]; |
541 | if ( q >= sel_TL && q <= sel_BR ) | 541 | if ( q >= sel_TL && q <= sel_BR ) |
542 | reverseRendition(&merged[p]); // for selection | 542 | reverseRendition(&merged[p]); // for selection |
543 | } | 543 | } |
544 | 544 | ||
545 | } | 545 | } |
546 | } | 546 | } |
547 | // evtl. inverse display | 547 | // evtl. inverse display |
548 | if (getMode(MODE_Screen)) | 548 | if (getMode(MODE_Screen)) |
549 | { int i,n = lines*columns; | 549 | { int i,n = lines*columns; |
550 | for (i = 0; i < n; i++) | 550 | for (i = 0; i < n; i++) |
551 | reverseRendition(&merged[i]); // for reverse display | 551 | reverseRendition(&merged[i]); // for reverse display |
552 | } | 552 | } |
553 | if (getMode(MODE_Cursor) && (cuY+(hist.getLines()-histCursor) < lines)) // cursor visible | 553 | if (getMode(MODE_Cursor) && (cuY+(hist.getLines()-histCursor) < lines)) // cursor visible |
554 | reverseRendition(&merged[loc(cuX,cuY+(hist.getLines()-histCursor))]); | 554 | reverseRendition(&merged[loc(cuX,cuY+(hist.getLines()-histCursor))]); |
555 | return merged; | 555 | return merged; |
556 | 556 | ||
557 | } | 557 | } |
558 | 558 | ||
559 | 559 | ||
560 | /*! | 560 | /*! |
561 | */ | 561 | */ |
562 | 562 | ||
563 | void TEScreen::reset() | 563 | void TEScreen::reset() |
564 | { | 564 | { |
565 | Config cfg( "Konsole" ); | 565 | Config cfg( "Konsole" ); |
566 | cfg.setGroup("ScrollBar"); | 566 | cfg.setGroup("ScrollBar"); |
567 | if( !cfg.readBoolEntry("HorzScroll",0) ) | 567 | if( !cfg.readBoolEntry("HorzScroll",0) ) |
568 | setMode(MODE_Wrap ); saveMode(MODE_Wrap ); // wrap at end of margin | 568 | setMode(MODE_Wrap ); saveMode(MODE_Wrap ); // wrap at end of margin |
569 | 569 | ||
570 | 570 | ||
571 | resetMode(MODE_Origin); saveMode(MODE_Origin); // position refere to [1,1] | 571 | resetMode(MODE_Origin); saveMode(MODE_Origin); // position refere to [1,1] |
572 | resetMode(MODE_Insert); saveMode(MODE_Insert); // overstroke | 572 | resetMode(MODE_Insert); saveMode(MODE_Insert); // overstroke |
573 | setMode(MODE_Cursor); // cursor visible | 573 | setMode(MODE_Cursor); // cursor visible |
574 | resetMode(MODE_Screen); // screen not inverse | 574 | resetMode(MODE_Screen); // screen not inverse |
575 | resetMode(MODE_NewLine); | 575 | resetMode(MODE_NewLine); |
576 | 576 | ||
577 | tmargin=0; | 577 | tmargin=0; |
578 | bmargin=lines-1; | 578 | bmargin=lines-1; |
579 | 579 | ||
580 | setDefaultRendition(); | 580 | setDefaultRendition(); |
581 | saveCursor(); | 581 | saveCursor(); |
582 | 582 | ||
583 | clear(); | 583 | clear(); |
584 | } | 584 | } |
585 | 585 | ||
586 | /*! Clear the entire screen and home the cursor. | 586 | /*! Clear the entire screen and home the cursor. |
587 | */ | 587 | */ |
588 | 588 | ||
589 | void TEScreen::clear() | 589 | void TEScreen::clear() |
590 | { | 590 | { |
591 | clearEntireScreen(); | 591 | clearEntireScreen(); |
592 | home(); | 592 | home(); |
593 | } | 593 | } |
594 | 594 | ||
595 | /*! Moves the cursor left one column. | 595 | /*! Moves the cursor left one column. |
596 | */ | 596 | */ |
597 | 597 | ||
598 | void TEScreen::BackSpace() | 598 | void TEScreen::BackSpace() |
599 | { | 599 | { |
600 | cuX = QMAX(0,cuX-1); | 600 | cuX = QMAX(0,cuX-1); |
601 | if (BS_CLEARS) image[loc(cuX,cuY)].c = ' '; | 601 | if (BS_CLEARS) image[loc(cuX,cuY)].c = ' '; |
602 | } | 602 | } |
603 | 603 | ||
604 | /*! | 604 | /*! |
605 | */ | 605 | */ |
606 | 606 | ||
607 | void TEScreen::Tabulate() | 607 | void TEScreen::Tabulate() |
608 | { | 608 | { |
609 | // note that TAB is a format effector (does not write ' '); | 609 | // note that TAB is a format effector (does not write ' '); |
610 | cursorRight(1); while(cuX < columns-1 && !tabstops[cuX]) cursorRight(1); | 610 | cursorRight(1); while(cuX < columns-1 && !tabstops[cuX]) cursorRight(1); |
611 | } | 611 | } |
612 | 612 | ||
613 | void TEScreen::clearTabStops() | 613 | void TEScreen::clearTabStops() |
614 | { | 614 | { |
615 | for (int i = 0; i < columns; i++) tabstops[i-1] = FALSE; | 615 | for (int i = 0; i < columns; i++) tabstops[i-1] = FALSE; |
616 | } | 616 | } |
617 | 617 | ||
618 | void TEScreen::changeTabStop(bool set) | 618 | void TEScreen::changeTabStop(bool set) |
619 | { | 619 | { |
620 | if (cuX >= columns) return; | 620 | if (cuX >= columns) return; |
621 | tabstops[cuX] = set; | 621 | tabstops[cuX] = set; |
622 | } | 622 | } |
623 | 623 | ||
624 | void TEScreen::initTabStops() | 624 | void TEScreen::initTabStops() |
625 | { | 625 | { |
626 | if (tabstops) free(tabstops); | 626 | if (tabstops) free(tabstops); |
627 | tabstops = (bool*)malloc(columns*sizeof(bool)); | 627 | tabstops = (bool*)malloc(columns*sizeof(bool)); |
628 | // Arrg! The 1st tabstop has to be one longer than the other. | 628 | // Arrg! The 1st tabstop has to be one longer than the other. |
629 | // i.e. the kids start counting from 0 instead of 1. | 629 | // i.e. the kids start counting from 0 instead of 1. |
630 | // Other programs might behave correctly. Be aware. | 630 | // Other programs might behave correctly. Be aware. |
631 | for (int i = 0; i < columns; i++) tabstops[i] = (i%8 == 0 && i != 0); | 631 | for (int i = 0; i < columns; i++) tabstops[i] = (i%8 == 0 && i != 0); |
632 | } | 632 | } |
633 | 633 | ||
634 | /*! | 634 | /*! |
635 | This behaves either as IND (Screen::Index) or as NEL (Screen::NextLine) | 635 | This behaves either as IND (Screen::Index) or as NEL (Screen::NextLine) |
636 | depending on the NewLine Mode (LNM). This mode also | 636 | depending on the NewLine Mode (LNM). This mode also |
637 | affects the key sequence returned for newline ([CR]LF). | 637 | affects the key sequence returned for newline ([CR]LF). |
638 | */ | 638 | */ |
639 | 639 | ||
640 | void TEScreen::NewLine() | 640 | void TEScreen::NewLine() |
641 | { | 641 | { |
642 | if (getMode(MODE_NewLine)) Return(); | 642 | if (getMode(MODE_NewLine)) Return(); |
643 | index(); | 643 | index(); |
644 | } | 644 | } |
645 | 645 | ||
646 | /*! put `c' literally onto the screen at the current cursor position. | 646 | /*! put `c' literally onto the screen at the current cursor position. |
647 | 647 | ||
648 | VT100 uses the convention to produce an automatic newline (am) | 648 | VT100 uses the convention to produce an automatic newline (am) |
649 | with the *first* character that would fall onto the next line (xenl). | 649 | with the *first* character that would fall onto the next line (xenl). |
650 | */ | 650 | */ |
651 | 651 | ||
652 | void TEScreen::checkSelection(int from, int to) | 652 | void TEScreen::checkSelection(int from, int to) |
653 | { | 653 | { |
654 | if (sel_begin == -1) return; | 654 | if (sel_begin == -1) return; |
655 | int scr_TL = loc(0, hist.getLines()); | 655 | int scr_TL = loc(0, hist.getLines()); |
656 | //Clear entire selection if it overlaps region [from, to] | 656 | //Clear entire selection if it overlaps region [from, to] |
657 | if ( (sel_BR > (from+scr_TL) )&&(sel_TL < (to+scr_TL)) ) | 657 | if ( (sel_BR > (from+scr_TL) )&&(sel_TL < (to+scr_TL)) ) |
658 | { | 658 | { |
659 | clearSelection(); | 659 | clearSelection(); |
660 | } | 660 | } |
661 | } | 661 | } |
662 | 662 | ||
663 | void TEScreen::ShowCharacter(unsigned short c) | 663 | void TEScreen::ShowCharacter(unsigned short c) |
664 | { | 664 | { |
665 | // Note that VT100 does wrapping BEFORE putting the character. | 665 | // Note that VT100 does wrapping BEFORE putting the character. |
666 | // This has impact on the assumption of valid cursor positions. | 666 | // This has impact on the assumption of valid cursor positions. |
667 | // We indicate the fact that a newline has to be triggered by | 667 | // We indicate the fact that a newline has to be triggered by |
668 | // putting the cursor one right to the last column of the screen. | 668 | // putting the cursor one right to the last column of the screen. |
669 | 669 | ||
670 | if (cuX >= columns) | 670 | if (cuX >= columns) |
671 | { | 671 | { |
672 | if (getMode(MODE_Wrap)) NextLine(); else cuX = columns - 1; | 672 | if (getMode(MODE_Wrap)) NextLine(); else cuX = columns - 1; |
673 | // comment out for no wrap | 673 | // comment out for no wrap |
674 | } | 674 | } |
675 | 675 | ||
676 | if (getMode(MODE_Insert)) insertChars(1); | 676 | if (getMode(MODE_Insert)) insertChars(1); |
677 | 677 | ||
678 | int i = loc( cuX, cuY); | 678 | int i = loc( cuX, cuY); |
679 | 679 | ||
680 | checkSelection(i, i); // check if selection is still valid. | 680 | checkSelection(i, i); // check if selection is still valid. |
681 | 681 | ||
682 | image[i].c = c; | 682 | image[i].c = c; |
683 | image[i].f = ef_fg; | 683 | image[i].f = ef_fg; |
684 | image[i].b = ef_bg; | 684 | image[i].b = ef_bg; |
685 | image[i].r = ef_re; | 685 | image[i].r = ef_re; |
686 | 686 | ||
687 | cuX += 1; | 687 | cuX += 1; |
688 | } | 688 | } |
689 | 689 | ||
690 | // Region commands ------------------------------------------------------------- | 690 | // Region commands ------------------------------------------------------------- |
691 | 691 | ||
692 | 692 | ||
693 | /*! scroll up `n' lines within current region. | 693 | /*! scroll up `n' lines within current region. |
694 | The `n' new lines are cleared. | 694 | The `n' new lines are cleared. |
695 | \sa setRegion \sa scrollDown | 695 | \sa setRegion \sa scrollDown |
696 | */ | 696 | */ |
697 | 697 | ||
698 | void TEScreen::scrollUp(int from, int n) | 698 | void TEScreen::scrollUp(int from, int n) |
699 | { | 699 | { |
700 | if (n <= 0 || from + n > bmargin) return; | 700 | if (n <= 0 || from + n > bmargin) return; |
701 | //FIXME: make sure `tmargin', `bmargin', `from', `n' is in bounds. | 701 | //FIXME: make sure `tmargin', `bmargin', `from', `n' is in bounds. |
702 | 702 | ||
703 | moveImage( loc( 0, from), loc( 0, from + n), loc( columns - 1, bmargin)); | 703 | moveImage( loc( 0, from), loc( 0, from + n), loc( columns - 1, bmargin)); |
704 | clearImage( loc( 0, bmargin - n + 1), loc( columns - 1, bmargin), ' '); | 704 | clearImage( loc( 0, bmargin - n + 1), loc( columns - 1, bmargin), ' '); |
705 | } | 705 | } |
706 | 706 | ||
707 | /*! scroll down `n' lines within current region. | 707 | /*! scroll down `n' lines within current region. |
708 | The `n' new lines are cleared. | 708 | The `n' new lines are cleared. |
709 | \sa setRegion \sa scrollUp | 709 | \sa setRegion \sa scrollUp |
710 | */ | 710 | */ |
711 | 711 | ||
712 | void TEScreen::scrollDown(int from, int n) | 712 | void TEScreen::scrollDown(int from, int n) |
713 | { | 713 | { |
714 | 714 | ||
715 | //FIXME: make sure `tmargin', `bmargin', `from', `n' is in bounds. | 715 | //FIXME: make sure `tmargin', `bmargin', `from', `n' is in bounds. |
716 | if (n <= 0) return; | 716 | if (n <= 0) return; |
717 | if (from > bmargin) return; | 717 | if (from > bmargin) return; |
718 | if (from + n > bmargin) n = bmargin - from; | 718 | if (from + n > bmargin) n = bmargin - from; |
719 | 719 | ||
720 | moveImage( loc(0,from+n), loc(0,from), loc(columns-1,bmargin-n)); | 720 | moveImage( loc(0,from+n), loc(0,from), loc(columns-1,bmargin-n)); |
721 | clearImage(loc(0,from),loc(columns-1,from+n-1),' '); | 721 | clearImage(loc(0,from),loc(columns-1,from+n-1),' '); |
722 | } | 722 | } |
723 | 723 | ||
724 | 724 | ||
725 | 725 | ||
726 | /*! position the cursor to a specific line and column. */ | 726 | /*! position the cursor to a specific line and column. */ |
727 | void TEScreen::setCursorYX(int y, int x) | 727 | void TEScreen::setCursorYX(int y, int x) |
728 | { | 728 | { |
729 | setCursorY(y); setCursorX(x); | 729 | setCursorY(y); setCursorX(x); |
730 | } | 730 | } |
731 | 731 | ||
732 | /*! Set the cursor to x-th line. */ | 732 | /*! Set the cursor to x-th line. */ |
733 | 733 | ||
734 | void TEScreen::setCursorX(int x) | 734 | void TEScreen::setCursorX(int x) |
735 | { | 735 | { |
736 | if (x == 0) x = 1; // Default | 736 | if (x == 0) x = 1; // Default |
737 | x -= 1; // Adjust | 737 | x -= 1; // Adjust |
738 | cuX = QMAX(0,QMIN(columns-1, x)); | 738 | cuX = QMAX(0,QMIN(columns-1, x)); |
739 | } | 739 | } |
740 | 740 | ||
741 | /*! Set the cursor to y-th line. */ | 741 | /*! Set the cursor to y-th line. */ |
742 | 742 | ||
743 | void TEScreen::setCursorY(int y) | 743 | void TEScreen::setCursorY(int y) |
744 | { | 744 | { |
745 | if (y == 0) y = 1; // Default | 745 | if (y == 0) y = 1; // Default |
746 | y -= 1; // Adjust | 746 | y -= 1; // Adjust |
747 | cuY = QMAX(0,QMIN(lines -1, y + (getMode(MODE_Origin) ? tmargin : 0) )); | 747 | cuY = QMAX(0,QMIN(lines -1, y + (getMode(MODE_Origin) ? tmargin : 0) )); |
748 | } | 748 | } |
749 | 749 | ||
750 | /*! set cursor to the `left upper' corner of the screen (1,1). | 750 | /*! set cursor to the `left upper' corner of the screen (1,1). |
751 | */ | 751 | */ |
752 | 752 | ||
753 | void TEScreen::home() | 753 | void TEScreen::home() |
754 | { | 754 | { |
755 | cuX = 0; | 755 | cuX = 0; |
756 | cuY = 0; | 756 | cuY = 0; |
757 | } | 757 | } |
758 | 758 | ||
759 | /*! set cursor to the begin of the current line. | 759 | /*! set cursor to the begin of the current line. |
760 | */ | 760 | */ |
761 | 761 | ||
762 | void TEScreen::Return() | 762 | void TEScreen::Return() |
763 | { | 763 | { |
764 | cuX = 0; | 764 | cuX = 0; |
765 | } | 765 | } |
766 | 766 | ||
767 | /*! returns the current cursor columns. | 767 | /*! returns the current cursor columns. |
768 | */ | 768 | */ |
769 | 769 | ||
770 | int TEScreen::getCursorX() | 770 | int TEScreen::getCursorX() |
771 | { | 771 | { |
772 | return cuX; | 772 | return cuX; |
773 | } | 773 | } |
774 | 774 | ||
775 | /*! returns the current cursor line. | 775 | /*! returns the current cursor line. |
776 | */ | 776 | */ |
777 | 777 | ||
778 | int TEScreen::getCursorY() | 778 | int TEScreen::getCursorY() |
779 | { | 779 | { |
780 | return cuY; | 780 | return cuY; |
781 | } | 781 | } |
782 | 782 | ||
783 | // Erasing --------------------------------------------------------------------- | 783 | // Erasing --------------------------------------------------------------------- |
784 | 784 | ||
785 | /*! \section Erasing | 785 | /*! \section Erasing |
786 | 786 | ||
787 | This group of operations erase parts of the screen contents by filling | 787 | This group of operations erase parts of the screen contents by filling |
788 | it with spaces colored due to the current rendition settings. | 788 | it with spaces colored due to the current rendition settings. |
789 | 789 | ||
790 | Althought the cursor position is involved in most of these operations, | 790 | Althought the cursor position is involved in most of these operations, |
791 | it is never modified by them. | 791 | it is never modified by them. |
792 | */ | 792 | */ |
793 | 793 | ||
794 | /*! fill screen between (including) `loca' and `loce' with spaces. | 794 | /*! fill screen between (including) `loca' and `loce' with spaces. |
795 | 795 | ||
796 | This is an internal helper functions. The parameter types are internal | 796 | This is an internal helper functions. The parameter types are internal |
797 | addresses of within the screen image and make use of the way how the | 797 | addresses of within the screen image and make use of the way how the |
798 | screen matrix is mapped to the image vector. | 798 | screen matrix is mapped to the image vector. |
799 | */ | 799 | */ |
800 | 800 | ||
801 | void TEScreen::clearImage(int loca, int loce, char c) | 801 | void TEScreen::clearImage(int loca, int loce, char c) |
802 | { int i; | 802 | { int i; |
803 | int scr_TL=loc(0,hist.getLines()); | 803 | int scr_TL=loc(0,hist.getLines()); |
804 | //FIXME: check positions | 804 | //FIXME: check positions |
805 | 805 | ||
806 | //Clear entire selection if it overlaps region to be moved... | 806 | //Clear entire selection if it overlaps region to be moved... |
807 | if ( (sel_BR > (loca+scr_TL) )&&(sel_TL < (loce+scr_TL)) ) | 807 | if ( (sel_BR > (loca+scr_TL) )&&(sel_TL < (loce+scr_TL)) ) |
808 | { | 808 | { |
809 | clearSelection(); | 809 | clearSelection(); |
810 | } | 810 | } |
811 | for (i = loca; i <= loce; i++) | 811 | for (i = loca; i <= loce; i++) |
812 | { | 812 | { |
813 | image[i].c = c; | 813 | image[i].c = c; |
814 | image[i].f = ef_fg; //DEFAULT_FORE_COLOR; //FIXME: xterm and linux/ansi | 814 | image[i].f = ef_fg; //DEFAULT_FORE_COLOR; //FIXME: xterm and linux/ansi |
815 | image[i].b = ef_bg; //DEFAULT_BACK_COLOR; // many have different | 815 | image[i].b = ef_bg; //DEFAULT_BACK_COLOR; // many have different |
816 | image[i].r = ef_re; //DEFAULT_RENDITION; // ideas here. | 816 | image[i].r = ef_re; //DEFAULT_RENDITION; // ideas here. |
817 | } | 817 | } |
818 | } | 818 | } |
819 | 819 | ||
820 | /*! move image between (including) `loca' and `loce' to 'dst'. | 820 | /*! move image between (including) `loca' and `loce' to 'dst'. |
821 | 821 | ||
822 | This is an internal helper functions. The parameter types are internal | 822 | This is an internal helper functions. The parameter types are internal |
823 | addresses of within the screen image and make use of the way how the | 823 | addresses of within the screen image and make use of the way how the |
824 | screen matrix is mapped to the image vector. | 824 | screen matrix is mapped to the image vector. |
825 | */ | 825 | */ |
826 | 826 | ||
827 | void TEScreen::moveImage(int dst, int loca, int loce) | 827 | void TEScreen::moveImage(int dst, int loca, int loce) |
828 | { | 828 | { |
829 | //FIXME: check positions | 829 | //FIXME: check positions |
830 | if (loce < loca) { | 830 | if (loce < loca) { |
831 | // kdDebug() << "WARNING!!! call to TEScreen:moveImage with loce < loca!" << endl; | 831 | // kdDebug() << "WARNING!!! call to TEScreen:moveImage with loce < loca!" << endl; |
832 | return; | 832 | return; |
833 | } | 833 | } |
834 | memmove(&image[dst],&image[loca],(loce-loca+1)*sizeof(ca)); | 834 | memmove(&image[dst],&image[loca],(loce-loca+1)*sizeof(ca)); |
835 | } | 835 | } |
836 | 836 | ||
837 | /*! clear from (including) current cursor position to end of screen. | 837 | /*! clear from (including) current cursor position to end of screen. |
838 | */ | 838 | */ |
839 | 839 | ||
840 | void TEScreen::clearToEndOfScreen() | 840 | void TEScreen::clearToEndOfScreen() |
841 | { | 841 | { |
842 | clearImage(loc(cuX,cuY),loc(columns-1,lines-1),' '); | 842 | clearImage(loc(cuX,cuY),loc(columns-1,lines-1),' '); |
843 | } | 843 | } |
844 | 844 | ||
845 | /*! clear from begin of screen to (including) current cursor position. | 845 | /*! clear from begin of screen to (including) current cursor position. |
846 | */ | 846 | */ |
847 | 847 | ||
848 | void TEScreen::clearToBeginOfScreen() | 848 | void TEScreen::clearToBeginOfScreen() |
849 | { | 849 | { |
850 | clearImage(loc(0,0),loc(cuX,cuY),' '); | 850 | clearImage(loc(0,0),loc(cuX,cuY),' '); |
851 | } | 851 | } |
852 | 852 | ||
853 | /*! clear the entire screen. | 853 | /*! clear the entire screen. |
854 | */ | 854 | */ |
855 | 855 | ||
856 | void TEScreen::clearEntireScreen() | 856 | void TEScreen::clearEntireScreen() |
857 | { | 857 | { |
858 | clearImage(loc(0,0),loc(columns-1,lines-1),' '); | 858 | clearImage(loc(0,0),loc(columns-1,lines-1),' '); |
859 | } | 859 | } |
860 | 860 | ||
861 | /*! fill screen with 'E' | 861 | /*! fill screen with 'E' |
862 | This is to aid screen alignment | 862 | This is to aid screen alignment |
863 | */ | 863 | */ |
864 | 864 | ||
865 | void TEScreen::helpAlign() | 865 | void TEScreen::helpAlign() |
866 | { | 866 | { |
867 | clearImage(loc(0,0),loc(columns-1,lines-1),'E'); | 867 | clearImage(loc(0,0),loc(columns-1,lines-1),'E'); |
868 | } | 868 | } |
869 | 869 | ||
870 | /*! clear from (including) current cursor position to end of current cursor line. | 870 | /*! clear from (including) current cursor position to end of current cursor line. |
871 | */ | 871 | */ |
872 | 872 | ||
873 | void TEScreen::clearToEndOfLine() | 873 | void TEScreen::clearToEndOfLine() |
874 | { | 874 | { |
875 | clearImage(loc(cuX,cuY),loc(columns-1,cuY),' '); | 875 | clearImage(loc(cuX,cuY),loc(columns-1,cuY),' '); |
876 | } | 876 | } |
877 | 877 | ||
878 | /*! clear from begin of current cursor line to (including) current cursor position. | 878 | /*! clear from begin of current cursor line to (including) current cursor position. |
879 | */ | 879 | */ |
880 | 880 | ||
881 | void TEScreen::clearToBeginOfLine() | 881 | void TEScreen::clearToBeginOfLine() |
882 | { | 882 | { |
883 | clearImage(loc(0,cuY),loc(cuX,cuY),' '); | 883 | clearImage(loc(0,cuY),loc(cuX,cuY),' '); |
884 | } | 884 | } |
885 | 885 | ||
886 | /*! clears entire current cursor line | 886 | /*! clears entire current cursor line |
887 | */ | 887 | */ |
888 | 888 | ||
889 | void TEScreen::clearEntireLine() | 889 | void TEScreen::clearEntireLine() |
890 | { | 890 | { |
891 | clearImage( loc( 0, cuY),loc( columns - 1, cuY),' '); | 891 | clearImage( loc( 0, cuY),loc( columns - 1, cuY),' '); |
892 | } | 892 | } |
893 | 893 | ||
894 | // Rendition ------------------------------------------------------------------ | 894 | // Rendition ------------------------------------------------------------------ |
895 | 895 | ||
896 | /*! | 896 | /*! |
897 | set rendition mode | 897 | set rendition mode |
898 | */ | 898 | */ |
899 | 899 | ||
900 | void TEScreen::setRendition(int re) | 900 | void TEScreen::setRendition(int re) |
901 | { | 901 | { |
902 | cu_re |= re; | 902 | cu_re |= re; |
903 | effectiveRendition(); | 903 | effectiveRendition(); |
904 | } | 904 | } |
905 | 905 | ||
906 | /*! | 906 | /*! |
907 | reset rendition mode | 907 | reset rendition mode |
908 | */ | 908 | */ |
909 | 909 | ||
910 | void TEScreen::resetRendition(int re) | 910 | void TEScreen::resetRendition(int re) |
911 | { | 911 | { |
912 | cu_re &= ~re; | 912 | cu_re &= ~re; |
913 | effectiveRendition(); | 913 | effectiveRendition(); |
914 | } | 914 | } |
915 | 915 | ||
916 | /*! | 916 | /*! |
917 | */ | 917 | */ |
918 | 918 | ||
919 | void TEScreen::setDefaultRendition() | 919 | void TEScreen::setDefaultRendition() |
920 | { | 920 | { |
921 | setForeColorToDefault(); | 921 | setForeColorToDefault(); |
922 | setBackColorToDefault(); | 922 | setBackColorToDefault(); |
923 | cu_re = DEFAULT_RENDITION; | 923 | cu_re = DEFAULT_RENDITION; |
924 | effectiveRendition(); | 924 | effectiveRendition(); |
925 | } | 925 | } |
926 | 926 | ||
927 | /*! | 927 | /*! |
928 | */ | 928 | */ |
929 | 929 | ||
930 | void TEScreen::setForeColor(int fgcolor) | 930 | void TEScreen::setForeColor(int fgcolor) |
931 | { | 931 | { |
932 | cu_fg = (fgcolor&7)+((fgcolor&8) ? 4+8 : 2); | 932 | cu_fg = (fgcolor&7)+((fgcolor&8) ? 4+8 : 2); |
933 | effectiveRendition(); | 933 | effectiveRendition(); |
934 | } | 934 | } |
935 | 935 | ||
936 | /*! | 936 | /*! |
937 | */ | 937 | */ |
938 | 938 | ||
939 | void TEScreen::setBackColor(int bgcolor) | 939 | void TEScreen::setBackColor(int bgcolor) |
940 | { | 940 | { |
941 | cu_bg = (bgcolor&7)+((bgcolor&8) ? 4+8 : 2); | 941 | cu_bg = (bgcolor&7)+((bgcolor&8) ? 4+8 : 2); |
942 | effectiveRendition(); | 942 | effectiveRendition(); |
943 | } | 943 | } |
944 | 944 | ||
945 | /*! | 945 | /*! |
946 | */ | 946 | */ |
947 | 947 | ||
948 | void TEScreen::setBackColorToDefault() | 948 | void TEScreen::setBackColorToDefault() |
949 | { | 949 | { |
950 | cu_bg = DEFAULT_BACK_COLOR; | 950 | cu_bg = DEFAULT_BACK_COLOR; |
951 | effectiveRendition(); | 951 | effectiveRendition(); |
952 | } | 952 | } |
953 | 953 | ||
954 | /*! | 954 | /*! |
955 | */ | 955 | */ |
956 | 956 | ||
957 | void TEScreen::setForeColorToDefault() | 957 | void TEScreen::setForeColorToDefault() |
958 | { | 958 | { |
959 | cu_fg = DEFAULT_FORE_COLOR; | 959 | cu_fg = DEFAULT_FORE_COLOR; |
960 | effectiveRendition(); | 960 | effectiveRendition(); |
961 | } | 961 | } |
962 | 962 | ||
963 | /* ------------------------------------------------------------------------- */ | 963 | /* ------------------------------------------------------------------------- */ |
964 | /* */ | 964 | /* */ |
965 | /* Marking & Selection */ | 965 | /* Marking & Selection */ |
966 | /* */ | 966 | /* */ |
967 | /* ------------------------------------------------------------------------- */ | 967 | /* ------------------------------------------------------------------------- */ |
968 | 968 | ||
969 | void TEScreen::clearSelection() | 969 | void TEScreen::clearSelection() |
970 | { | 970 | { |
971 | sel_BR = -1; | 971 | sel_BR = -1; |
972 | sel_TL = -1; | 972 | sel_TL = -1; |
973 | sel_begin = -1; | 973 | sel_begin = -1; |
974 | } | 974 | } |
975 | 975 | ||
976 | void TEScreen::setSelBeginXY(const int x, const int y) | 976 | void TEScreen::setSelBeginXY(const int x, const int y) |
977 | { | 977 | { |
978 | if (histCursor > hist.getLines()) { | 978 | if (histCursor > hist.getLines()) { |
979 | histCursor = hist.getLines(); | 979 | histCursor = hist.getLines(); |
980 | } | 980 | } |
981 | sel_begin = loc(x,y+histCursor) ; | 981 | sel_begin = loc(x,y+histCursor) ; |
982 | sel_BR = sel_begin; | 982 | sel_BR = sel_begin; |
983 | sel_TL = sel_begin; | 983 | sel_TL = sel_begin; |
984 | } | 984 | } |
985 | 985 | ||
986 | void TEScreen::setSelExtentXY(const int x, const int y) | 986 | void TEScreen::setSelExtentXY(const int x, const int y) |
987 | { | 987 | { |
988 | if (sel_begin == -1) return; | 988 | if (sel_begin == -1) return; |
989 | if (histCursor > hist.getLines()) { | 989 | if (histCursor > hist.getLines()) { |
990 | histCursor = hist.getLines(); | 990 | histCursor = hist.getLines(); |
991 | } | 991 | } |
992 | int l = loc(x,y + histCursor); | 992 | int l = loc(x,y + histCursor); |
993 | 993 | ||
994 | if (l < sel_begin) | 994 | if (l < sel_begin) |
995 | { | 995 | { |
996 | sel_TL = l; | 996 | sel_TL = l; |
997 | sel_BR = sel_begin; | 997 | sel_BR = sel_begin; |
998 | } | 998 | } |
999 | else | 999 | else |
1000 | { | 1000 | { |
1001 | /* FIXME, HACK to correct for x too far to the right... */ | 1001 | /* FIXME, HACK to correct for x too far to the right... */ |
1002 | if (( x == columns )|| (x == 0)) l--; | 1002 | if (( x == columns )|| (x == 0)) l--; |
1003 | 1003 | ||
1004 | sel_TL = sel_begin; | 1004 | sel_TL = sel_begin; |
1005 | sel_BR = l; | 1005 | sel_BR = l; |
1006 | } | 1006 | } |
1007 | } | 1007 | } |
1008 | 1008 | ||
1009 | QString TEScreen::getSelText(const BOOL preserve_line_breaks) | 1009 | QString TEScreen::getSelText(const BOOL preserve_line_breaks) |
1010 | { | 1010 | { |
1011 | if (sel_begin == -1) | 1011 | if (sel_begin == -1) |
1012 | return QString::null; // Selection got clear while selecting. | 1012 | return QString::null; // Selection got clear while selecting. |
1013 | 1013 | ||
1014 | int *m; // buffer to fill. | 1014 | int *m; // buffer to fill. |
1015 | int s, d; // source index, dest. index. | 1015 | int s, d; // source index, dest. index. |
1016 | int hist_BR = loc(0, hist.getLines()); | 1016 | int hist_BR = loc(0, hist.getLines()); |
1017 | int hY = sel_TL / columns; | 1017 | int hY = sel_TL / columns; |
1018 | int hX = sel_TL % columns; | 1018 | int hX = sel_TL % columns; |
1019 | int eol; // end of line | 1019 | int eol; // end of line |
1020 | 1020 | ||
1021 | s = sel_TL; // tracks copy in source. | 1021 | s = sel_TL; // tracks copy in source. |
1022 | 1022 | ||
1023 | // allocate buffer for maximum | 1023 | // allocate buffer for maximum |
1024 | // possible size... | 1024 | // possible size... |
1025 | d = (sel_BR - sel_TL) / columns + 1; | 1025 | d = (sel_BR - sel_TL) / columns + 1; |
1026 | m = new int[d * (columns + 1) + 2]; | 1026 | m = new int[d * (columns + 1) + 2]; |
1027 | d = 0; | 1027 | d = 0; |
1028 | 1028 | ||
1029 | while (s <= sel_BR) | 1029 | while (s <= sel_BR) |
1030 | { | 1030 | { |
1031 | if (s < hist_BR) | 1031 | if (s < hist_BR) |
1032 | { // get lines from hist.history | 1032 | { // get lines from hist.history |
1033 | // buffer. | 1033 | // buffer. |
1034 | eol = hist.getLineLen(hY); | 1034 | eol = hist.getLineLen(hY); |
1035 | 1035 | ||
1036 | if ((hY == (sel_BR / columns)) && | 1036 | if ((hY == (sel_BR / columns)) && |
1037 | (eol >= (sel_BR % columns))) | 1037 | (eol >= (sel_BR % columns))) |
1038 | { | 1038 | { |
1039 | eol = sel_BR % columns + 1; | 1039 | eol = sel_BR % columns + 1; |
1040 | } | 1040 | } |
1041 | 1041 | ||
1042 | while (hX < eol) | 1042 | while (hX < eol) |
1043 | { | 1043 | { |
1044 | m[d++] = hist.getCell(hY, hX++).c; | 1044 | m[d++] = hist.getCell(hY, hX++).c; |
1045 | s++; | 1045 | s++; |
1046 | } | 1046 | } |
1047 | 1047 | ||
1048 | if (s <= sel_BR) | 1048 | if (s <= sel_BR) |
1049 | { | 1049 | { |
1050 | // The line break handling | 1050 | // The line break handling |
1051 | // It's different from the screen | 1051 | // It's different from the screen |
1052 | // image case! | 1052 | // image case! |
1053 | if (eol % columns == 0) | 1053 | if (eol % columns == 0) |
1054 | { | 1054 | { |
1055 | // That's either a completely filled | 1055 | // That's either a completely filled |
1056 | // line or an empty line | 1056 | // line or an empty line |
1057 | if (eol == 0) | 1057 | if (eol == 0) |
1058 | { | 1058 | { |
1059 | m[d++] = '\n'; | 1059 | m[d++] = '\n'; |
1060 | } | 1060 | } |
1061 | else | 1061 | else |
1062 | { | 1062 | { |
1063 | // We have a full line. | 1063 | // We have a full line. |
1064 | // FIXME: How can we handle newlines | 1064 | // FIXME: How can we handle newlines |
1065 | // at this position?! | 1065 | // at this position?! |
1066 | } | 1066 | } |
1067 | } | 1067 | } |
1068 | else if ((eol + 1) % columns == 0) | 1068 | else if ((eol + 1) % columns == 0) |
1069 | { | 1069 | { |
1070 | // FIXME: We don't know if this was a | 1070 | // FIXME: We don't know if this was a |
1071 | // space at the last position or a | 1071 | // space at the last position or a |
1072 | // short line!! | 1072 | // short line!! |
1073 | m[d++] = ' '; | 1073 | m[d++] = ' '; |
1074 | } | 1074 | } |
1075 | else | 1075 | else |
1076 | { | 1076 | { |
1077 | // We have a short line here. Put a | 1077 | // We have a short line here. Put a |
1078 | // newline or a space into the | 1078 | // newline or a space into the |
1079 | // buffer. | 1079 | // buffer. |
1080 | m[d++] = preserve_line_breaks ? '\n' : ' '; | 1080 | m[d++] = preserve_line_breaks ? '\n' : ' '; |
1081 | } | 1081 | } |
1082 | } | 1082 | } |
1083 | 1083 | ||
1084 | hY++; | 1084 | hY++; |
1085 | hX = 0; | 1085 | hX = 0; |
1086 | s = hY * columns; | 1086 | s = hY * columns; |
1087 | } | 1087 | } |
1088 | else | 1088 | else |
1089 | { // or from screen image. | 1089 | { // or from screen image. |
1090 | eol = (s / columns + 1) * columns - 1; | 1090 | eol = (s / columns + 1) * columns - 1; |
1091 | 1091 | ||
1092 | if (eol < sel_BR) | 1092 | if (eol < sel_BR) |
1093 | { | 1093 | { |
1094 | while ((eol > s) && | 1094 | while ((eol > s) && |
1095 | isspace(image[eol - hist_BR].c)) | 1095 | isspace(image[eol - hist_BR].c)) |
1096 | { | 1096 | { |
1097 | eol--; | 1097 | eol--; |
1098 | } | 1098 | } |
1099 | } | 1099 | } |
1100 | else | 1100 | else |
1101 | { | 1101 | { |
1102 | eol = sel_BR; | 1102 | eol = sel_BR; |
1103 | } | 1103 | } |
1104 | 1104 | ||
1105 | while (s <= eol) | 1105 | while (s <= eol) |
1106 | { | 1106 | { |
1107 | m[d++] = image[s++ - hist_BR].c; | 1107 | m[d++] = image[s++ - hist_BR].c; |
1108 | } | 1108 | } |
1109 | 1109 | ||
1110 | if (eol < sel_BR) | 1110 | if (eol < sel_BR) |
1111 | { | 1111 | { |
1112 | // eol processing see below ... | 1112 | // eol processing see below ... |
1113 | if ((eol + 1) % columns == 0) | 1113 | if ((eol + 1) % columns == 0) |
1114 | { | 1114 | { |
1115 | if (image[eol - hist_BR].c == ' ') | 1115 | if (image[eol - hist_BR].c == ' ') |
1116 | { | 1116 | { |
1117 | m[d++] = ' '; | 1117 | m[d++] = ' '; |
1118 | } | 1118 | } |
1119 | } | 1119 | } |
1120 | else | 1120 | else |
1121 | { | 1121 | { |
1122 | m[d++] = ((preserve_line_breaks || | 1122 | m[d++] = ((preserve_line_breaks || |
1123 | ((eol % columns) == 0)) ? | 1123 | ((eol % columns) == 0)) ? |
1124 | '\n' : ' '); | 1124 | '\n' : ' '); |
1125 | } | 1125 | } |
1126 | } | 1126 | } |
1127 | 1127 | ||
1128 | s = (eol / columns + 1) * columns; | 1128 | s = (eol / columns + 1) * columns; |
1129 | } | 1129 | } |
1130 | } | 1130 | } |
1131 | 1131 | ||
1132 | QChar* qc = new QChar[d]; | 1132 | QChar* qc = new QChar[d]; |
1133 | 1133 | ||
1134 | for (int i = 0; i < d; i++) | 1134 | for (int i = 0; i < d; i++) |
1135 | { | 1135 | { |
1136 | qc[i] = m[i]; | 1136 | qc[i] = m[i]; |
1137 | } | 1137 | } |
1138 | 1138 | ||
1139 | QString res(qc, d); | 1139 | QString res(qc, d); |
1140 | 1140 | ||
1141 | delete m; | 1141 | delete m; |
1142 | delete qc; | 1142 | delete qc; |
1143 | 1143 | ||
1144 | return res; | 1144 | return res; |
1145 | } | 1145 | } |
1146 | /* above ... end of line processing for selection -- psilva | 1146 | /* above ... end of line processing for selection -- psilva |
1147 | cases: | 1147 | cases: |
1148 | 1148 | ||
1149 | 1) (eol+1)%columns == 0 --> the whole line is filled. | 1149 | 1) (eol+1)%columns == 0 --> the whole line is filled. |
1150 | If the last char is a space, insert (preserve) space. otherwise | 1150 | If the last char is a space, insert (preserve) space. otherwise |
1151 | leave the text alone, so that words that are broken by linewrap | 1151 | leave the text alone, so that words that are broken by linewrap |
1152 | are preserved. | 1152 | are preserved. |
1153 | 1153 | ||
1154 | FIXME: | 1154 | FIXME: |
1155 | * this suppresses \n for command output that is | 1155 | * this suppresses \n for command output that is |
1156 | sized to the exact column width of the screen. | 1156 | sized to the exact column width of the screen. |
1157 | 1157 | ||
1158 | 2) eol%columns == 0 --> blank line. | 1158 | 2) eol%columns == 0 --> blank line. |
1159 | insert a \n unconditionally. | 1159 | insert a \n unconditionally. |
1160 | Do it either you would because you are in preserve_line_break mode, | 1160 | Do it either you would because you are in preserve_line_break mode, |
1161 | or because it's an ASCII paragraph delimiter, so even when | 1161 | or because it's an ASCII paragraph delimiter, so even when |
1162 | not preserving line_breaks, you want to preserve paragraph breaks. | 1162 | not preserving line_breaks, you want to preserve paragraph breaks. |
1163 | 1163 | ||
1164 | 3) else --> partially filled line | 1164 | 3) else --> partially filled line |
1165 | insert a \n in preserve line break mode, else a space | 1165 | insert a \n in preserve line break mode, else a space |
1166 | The space prevents concatenation of the last word of one | 1166 | The space prevents concatenation of the last word of one |
1167 | line with the first of the next. | 1167 | line with the first of the next. |
1168 | 1168 | ||
1169 | */ | 1169 | */ |
1170 | 1170 | ||
1171 | void TEScreen::addHistLine() | 1171 | void TEScreen::addHistLine() |
1172 | { | 1172 | { |
1173 | assert(hasScroll() || histCursor == 0); | 1173 | assert(hasScroll() || histCursor == 0); |
1174 | 1174 | ||
1175 | // add to hist buffer | 1175 | // add to hist buffer |
1176 | // we have to take care about scrolling, too... | 1176 | // we have to take care about scrolling, too... |
1177 | 1177 | ||
1178 | if (hasScroll()){ | 1178 | if (hasScroll()){ |
1179 | ca dft; | 1179 | ca dft; |
1180 | 1180 | ||
1181 | int end = columns - 1; | 1181 | int end = columns - 1; |
1182 | while (end >= 0 && image[end] == dft) | 1182 | while (end >= 0 && image[end] == dft) |
1183 | end -= 1; | 1183 | end -= 1; |
1184 | 1184 | ||
1185 | hist.addCells( image, end + 1); | 1185 | hist.addCells( image, end + 1); |
1186 | hist.addLine(); | 1186 | hist.addLine(); |
1187 | 1187 | ||
1188 | // adjust history cursor | 1188 | // adjust history cursor |
1189 | histCursor += ( hist.getLines() - 1 == histCursor); | 1189 | histCursor += ( hist.getLines() - 1 == histCursor); |
1190 | } | 1190 | } |
1191 | 1191 | ||
1192 | if (!hasScroll()) histCursor = 0; //FIXME: a poor workaround | 1192 | if (!hasScroll()) histCursor = 0; //FIXME: a poor workaround |
1193 | } | 1193 | } |
1194 | 1194 | ||
1195 | void TEScreen::setHistCursor(int cursor) | 1195 | void TEScreen::setHistCursor(int cursor) |
1196 | { | 1196 | { |
1197 | histCursor = cursor; //FIXME:rangecheck | 1197 | histCursor = cursor; //FIXME:rangecheck |
1198 | if (histCursor > hist.getLines()) { | 1198 | if (histCursor > hist.getLines()) { |
1199 | histCursor = hist.getLines(); | 1199 | histCursor = hist.getLines(); |
1200 | } | 1200 | } |
1201 | if (histCursor < 0) { | 1201 | if (histCursor < 0) { |
1202 | histCursor = 0; | 1202 | histCursor = 0; |
1203 | } | 1203 | } |
1204 | } | 1204 | } |
1205 | 1205 | ||
1206 | void TEScreen::setHorzCursor(int cursor) | 1206 | void TEScreen::setHorzCursor(int cursor) |
1207 | { | 1207 | { |
1208 | horzCursor = cursor; | 1208 | horzCursor = cursor; |
1209 | } | 1209 | } |
1210 | 1210 | ||
1211 | int TEScreen::getHistCursor() | 1211 | int TEScreen::getHistCursor() |
1212 | { | 1212 | { |
1213 | return histCursor; | 1213 | return histCursor; |
1214 | } | 1214 | } |
1215 | 1215 | ||
1216 | int TEScreen::getHorzCursor() | 1216 | int TEScreen::getHorzCursor() |
1217 | { | 1217 | { |
1218 | return horzCursor; | 1218 | return horzCursor; |
1219 | } | 1219 | } |
1220 | 1220 | ||
1221 | int TEScreen::getHistLines() | 1221 | int TEScreen::getHistLines() |
1222 | { | 1222 | { |
1223 | return hist.getLines(); | 1223 | return hist.getLines(); |
1224 | } | 1224 | } |
1225 | 1225 | ||
1226 | void TEScreen::setScroll(bool on) | 1226 | void TEScreen::setScroll(bool on) |
1227 | { | 1227 | { |
1228 | histCursor = 0; | 1228 | histCursor = 0; |
1229 | clearSelection(); | 1229 | clearSelection(); |
1230 | hist.setScroll(on); | 1230 | hist.setScroll(on); |
1231 | } | 1231 | } |
1232 | 1232 | ||
1233 | bool TEScreen::hasScroll() | 1233 | bool TEScreen::hasScroll() |
1234 | { | 1234 | { |
1235 | return hist.hasScroll(); | 1235 | return hist.hasScroll(); |
1236 | } | 1236 | } |
diff --git a/core/apps/embeddedkonsole/TEWidget.cpp b/core/apps/embeddedkonsole/TEWidget.cpp index 93348f4..3cb1c0a 100644 --- a/core/apps/embeddedkonsole/TEWidget.cpp +++ b/core/apps/embeddedkonsole/TEWidget.cpp | |||
@@ -1,1429 +1,1429 @@ | |||
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 | 55 | ||
56 | #if !(QT_NO_COP) | 56 | #if !(QT_NO_COP) |
57 | #include <qpe/qcopenvelope_qws.h> | 57 | #include <qpe/qcopenvelope_qws.h> |
58 | #endif | 58 | #endif |
59 | 59 | ||
60 | #include <qclipboard.h> | 60 | #include <qclipboard.h> |
61 | 61 | ||
62 | #ifndef QT_NO_DRAGANDDROP | 62 | #ifndef QT_NO_DRAGANDDROP |
63 | #include <qdragobject.h> | 63 | #include <qdragobject.h> |
64 | #include <qfile.h> | 64 | #include <qfile.h> |
65 | #endif | 65 | #endif |
66 | 66 | ||
67 | #include <stdio.h> | 67 | #include <stdio.h> |
68 | #include <stdlib.h> | 68 | #include <stdlib.h> |
69 | #include <unistd.h> | 69 | #include <unistd.h> |
70 | #include <ctype.h> | 70 | #include <ctype.h> |
71 | #include <sys/stat.h> | 71 | #include <sys/stat.h> |
72 | #include <sys/types.h> | 72 | #include <sys/types.h> |
73 | #include <signal.h> | 73 | #include <signal.h> |
74 | 74 | ||
75 | #include <assert.h> | 75 | #include <assert.h> |
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 | /* ------------------------------------------------------------------------- */ | 98 | /* ------------------------------------------------------------------------- */ |
99 | /* */ | 99 | /* */ |
100 | /* Colors */ | 100 | /* Colors */ |
101 | /* */ | 101 | /* */ |
102 | /* ------------------------------------------------------------------------- */ | 102 | /* ------------------------------------------------------------------------- */ |
103 | 103 | ||
104 | //FIXME: the default color table is in session.C now. | 104 | //FIXME: the default color table is in session.C now. |
105 | // We need a way to get rid of this one, here. | 105 | // We need a way to get rid of this one, here. |
106 | static const ColorEntry base_color_table[TABLE_COLORS] = | 106 | static const ColorEntry base_color_table[TABLE_COLORS] = |
107 | // The following are almost IBM standard color codes, with some slight | 107 | // The following are almost IBM standard color codes, with some slight |
108 | // gamma correction for the dim colors to compensate for bright X screens. | 108 | // gamma correction for the dim colors to compensate for bright X screens. |
109 | // It contains the 8 ansiterm/xterm colors in 2 intensities. | 109 | // It contains the 8 ansiterm/xterm colors in 2 intensities. |
110 | { | 110 | { |
111 | // Fixme: could add faint colors here, also. | 111 | // Fixme: could add faint colors here, also. |
112 | // normal | 112 | // normal |
113 | ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 1, 0 ), // Dfore, Dback | 113 | 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 | 114 | 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 | 115 | 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 | 116 | 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 | 117 | ColorEntry(QColor(0x18,0xB2,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 0, 0 ), // Cyan, White |
118 | // intensiv | 118 | // intensiv |
119 | ColorEntry(QColor(0x00,0x00,0x00), 0, 1 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 1, 0 ), | 119 | 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 ), | 120 | 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 ), | 121 | 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 ), | 122 | 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 ) | 123 | ColorEntry(QColor(0x54,0xFF,0xFF), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 0, 0 ) |
124 | }; | 124 | }; |
125 | 125 | ||
126 | /* Note that we use ANSI color order (bgr), while IBMPC color order is (rgb) | 126 | /* Note that we use ANSI color order (bgr), while IBMPC color order is (rgb) |
127 | 127 | ||
128 | Code 0 1 2 3 4 5 6 7 | 128 | Code 0 1 2 3 4 5 6 7 |
129 | ----------- ------- ------- ------- ------- ------- ------- ------- ------- | 129 | ----------- ------- ------- ------- ------- ------- ------- ------- ------- |
130 | ANSI (bgr) Black Red Green Yellow Blue Magenta Cyan White | 130 | ANSI (bgr) Black Red Green Yellow Blue Magenta Cyan White |
131 | IBMPC (rgb) Black Blue Green Cyan Red Magenta Yellow White | 131 | IBMPC (rgb) Black Blue Green Cyan Red Magenta Yellow White |
132 | */ | 132 | */ |
133 | 133 | ||
134 | QColor TEWidget::getDefaultBackColor() | 134 | QColor TEWidget::getDefaultBackColor() |
135 | { | 135 | { |
136 | return color_table[DEFAULT_BACK_COLOR].color; | 136 | return color_table[DEFAULT_BACK_COLOR].color; |
137 | } | 137 | } |
138 | 138 | ||
139 | const ColorEntry* TEWidget::getColorTable() const | 139 | const ColorEntry* TEWidget::getColorTable() const |
140 | { | 140 | { |
141 | return color_table; | 141 | return color_table; |
142 | } | 142 | } |
143 | 143 | ||
144 | const ColorEntry* TEWidget::getdefaultColorTable() const | 144 | const ColorEntry* TEWidget::getdefaultColorTable() const |
145 | { | 145 | { |
146 | return base_color_table; | 146 | return base_color_table; |
147 | } | 147 | } |
148 | 148 | ||
149 | 149 | ||
150 | const QPixmap *TEWidget::backgroundPixmap() | 150 | const QPixmap *TEWidget::backgroundPixmap() |
151 | { | 151 | { |
152 | static QPixmap *bg = new QPixmap("~/qpim/main/pics/faded_bg.xpm"); | 152 | static QPixmap *bg = new QPixmap("~/qpim/main/pics/faded_bg.xpm"); |
153 | const QPixmap *pm = bg; | 153 | const QPixmap *pm = bg; |
154 | return pm; | 154 | return pm; |
155 | } | 155 | } |
156 | 156 | ||
157 | void TEWidget::setColorTable(const ColorEntry table[]) | 157 | void TEWidget::setColorTable(const ColorEntry table[]) |
158 | { | 158 | { |
159 | for (int i = 0; i < TABLE_COLORS; i++) color_table[i] = table[i]; | 159 | for (int i = 0; i < TABLE_COLORS; i++) color_table[i] = table[i]; |
160 | 160 | ||
161 | const QPixmap* pm = backgroundPixmap(); | 161 | const QPixmap* pm = backgroundPixmap(); |
162 | if (!pm) setBackgroundColor(color_table[DEFAULT_BACK_COLOR].color); | 162 | if (!pm) setBackgroundColor(color_table[DEFAULT_BACK_COLOR].color); |
163 | update(); | 163 | update(); |
164 | } | 164 | } |
165 | 165 | ||
166 | //FIXME: add backgroundPixmapChanged. | 166 | //FIXME: add backgroundPixmapChanged. |
167 | 167 | ||
168 | /* ------------------------------------------------------------------------- */ | 168 | /* ------------------------------------------------------------------------- */ |
169 | /* */ | 169 | /* */ |
170 | /* Font */ | 170 | /* Font */ |
171 | /* */ | 171 | /* */ |
172 | /* ------------------------------------------------------------------------- */ | 172 | /* ------------------------------------------------------------------------- */ |
173 | 173 | ||
174 | /* | 174 | /* |
175 | The VT100 has 32 special graphical characters. The usual vt100 extended | 175 | The VT100 has 32 special graphical characters. The usual vt100 extended |
176 | xterm fonts have these at 0x00..0x1f. | 176 | xterm fonts have these at 0x00..0x1f. |
177 | 177 | ||
178 | QT's iso mapping leaves 0x00..0x7f without any changes. But the graphicals | 178 | QT's iso mapping leaves 0x00..0x7f without any changes. But the graphicals |
179 | come in here as proper unicode characters. | 179 | come in here as proper unicode characters. |
180 | 180 | ||
181 | We treat non-iso10646 fonts as VT100 extended and do the requiered mapping | 181 | 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 | 182 | from unicode to 0x00..0x1f. The remaining translation is then left to the |
183 | QCodec. | 183 | QCodec. |
184 | */ | 184 | */ |
185 | 185 | ||
186 | // assert for i in [0..31] : vt100extended(vt100_graphics[i]) == i. | 186 | // assert for i in [0..31] : vt100extended(vt100_graphics[i]) == i. |
187 | 187 | ||
188 | unsigned short vt100_graphics[32] = | 188 | unsigned short vt100_graphics[32] = |
189 | { // 0/8 1/9 2/10 3/11 4/12 5/13 6/14 7/15 | 189 | { // 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, | 190 | 0x0020, 0x25C6, 0x2592, 0x2409, 0x240c, 0x240d, 0x240a, 0x00b0, |
191 | 0x00b1, 0x2424, 0x240b, 0x2518, 0x2510, 0x250c, 0x2514, 0x253c, | 191 | 0x00b1, 0x2424, 0x240b, 0x2518, 0x2510, 0x250c, 0x2514, 0x253c, |
192 | 0xF800, 0xF801, 0x2500, 0xF803, 0xF804, 0x251c, 0x2524, 0x2534, | 192 | 0xF800, 0xF801, 0x2500, 0xF803, 0xF804, 0x251c, 0x2524, 0x2534, |
193 | 0x252c, 0x2502, 0x2264, 0x2265, 0x03C0, 0x2260, 0x00A3, 0x00b7 | 193 | 0x252c, 0x2502, 0x2264, 0x2265, 0x03C0, 0x2260, 0x00A3, 0x00b7 |
194 | }; | 194 | }; |
195 | 195 | ||
196 | static QChar vt100extended(QChar c) | 196 | static QChar vt100extended(QChar c) |
197 | { | 197 | { |
198 | switch (c.unicode()) | 198 | switch (c.unicode()) |
199 | { | 199 | { |
200 | case 0x25c6 : return 1; | 200 | case 0x25c6 : return 1; |
201 | case 0x2592 : return 2; | 201 | case 0x2592 : return 2; |
202 | case 0x2409 : return 3; | 202 | case 0x2409 : return 3; |
203 | case 0x240c : return 4; | 203 | case 0x240c : return 4; |
204 | case 0x240d : return 5; | 204 | case 0x240d : return 5; |
205 | case 0x240a : return 6; | 205 | case 0x240a : return 6; |
206 | case 0x00b0 : return 7; | 206 | case 0x00b0 : return 7; |
207 | case 0x00b1 : return 8; | 207 | case 0x00b1 : return 8; |
208 | case 0x2424 : return 9; | 208 | case 0x2424 : return 9; |
209 | case 0x240b : return 10; | 209 | case 0x240b : return 10; |
210 | case 0x2518 : return 11; | 210 | case 0x2518 : return 11; |
211 | case 0x2510 : return 12; | 211 | case 0x2510 : return 12; |
212 | case 0x250c : return 13; | 212 | case 0x250c : return 13; |
213 | case 0x2514 : return 14; | 213 | case 0x2514 : return 14; |
214 | case 0x253c : return 15; | 214 | case 0x253c : return 15; |
215 | case 0xf800 : return 16; | 215 | case 0xf800 : return 16; |
216 | case 0xf801 : return 17; | 216 | case 0xf801 : return 17; |
217 | case 0x2500 : return 18; | 217 | case 0x2500 : return 18; |
218 | case 0xf803 : return 19; | 218 | case 0xf803 : return 19; |
219 | case 0xf804 : return 20; | 219 | case 0xf804 : return 20; |
220 | case 0x251c : return 21; | 220 | case 0x251c : return 21; |
221 | case 0x2524 : return 22; | 221 | case 0x2524 : return 22; |
222 | case 0x2534 : return 23; | 222 | case 0x2534 : return 23; |
223 | case 0x252c : return 24; | 223 | case 0x252c : return 24; |
224 | case 0x2502 : return 25; | 224 | case 0x2502 : return 25; |
225 | case 0x2264 : return 26; | 225 | case 0x2264 : return 26; |
226 | case 0x2265 : return 27; | 226 | case 0x2265 : return 27; |
227 | case 0x03c0 : return 28; | 227 | case 0x03c0 : return 28; |
228 | case 0x2260 : return 29; | 228 | case 0x2260 : return 29; |
229 | case 0x00a3 : return 30; | 229 | case 0x00a3 : return 30; |
230 | case 0x00b7 : return 31; | 230 | case 0x00b7 : return 31; |
231 | } | 231 | } |
232 | return c; | 232 | return c; |
233 | } | 233 | } |
234 | 234 | ||
235 | static QChar identicalMap(QChar c) | 235 | static QChar identicalMap(QChar c) |
236 | { | 236 | { |
237 | return c; | 237 | return c; |
238 | } | 238 | } |
239 | 239 | ||
240 | void TEWidget::fontChange(const QFont &) | 240 | void TEWidget::fontChange(const QFont &) |
241 | { | 241 | { |
242 | QFontMetrics fm(font()); | 242 | QFontMetrics fm(font()); |
243 | font_h = fm.height(); | 243 | font_h = fm.height(); |
244 | // font_w = fm.maxWidth(); | 244 | // font_w = fm.maxWidth(); |
245 | font_w = fm.width("m"); | 245 | font_w = fm.width("m"); |
246 | font_a = fm.ascent(); | 246 | font_a = fm.ascent(); |
247 | printf("font h=%d max_width=%d width_m=%d assent=%d\n", font_h, | 247 | printf("font h=%d max_width=%d width_m=%d assent=%d\n", font_h, |
248 | fm.maxWidth(), font_w, font_a); | 248 | fm.maxWidth(), font_w, font_a); |
249 | 249 | ||
250 | //printf("font_h: %d\n",font_h); | 250 | //printf("font_h: %d\n",font_h); |
251 | //printf("font_w: %d\n",font_w); | 251 | //printf("font_w: %d\n",font_w); |
252 | //printf("font_a: %d\n",font_a); | 252 | //printf("font_a: %d\n",font_a); |
253 | //printf("charset: %s\n",QFont::encodingName(font().charSet()).ascii()); | 253 | //printf("charset: %s\n",QFont::encodingName(font().charSet()).ascii()); |
254 | //printf("rawname: %s\n",font().rawName().ascii()); | 254 | //printf("rawname: %s\n",font().rawName().ascii()); |
255 | fontMap = | 255 | fontMap = |
256 | #if QT_VERSION < 300 | 256 | #if QT_VERSION < 300 |
257 | strcmp(QFont::encodingName(font().charSet()).ascii(),"iso10646") | 257 | strcmp(QFont::encodingName(font().charSet()).ascii(),"iso10646") |
258 | ? vt100extended | 258 | ? vt100extended |
259 | : | 259 | : |
260 | #endif | 260 | #endif |
261 | identicalMap; | 261 | identicalMap; |
262 | propagateSize(); | 262 | propagateSize(); |
263 | update(); | 263 | update(); |
264 | } | 264 | } |
265 | 265 | ||
266 | void TEWidget::setVTFont(const QFont& f) | 266 | void TEWidget::setVTFont(const QFont& f) |
267 | { | 267 | { |
268 | QFrame::setFont(f); | 268 | QFrame::setFont(f); |
269 | } | 269 | } |
270 | 270 | ||
271 | QFont TEWidget::getVTFont() { | 271 | QFont TEWidget::getVTFont() { |
272 | return font(); | 272 | return font(); |
273 | } | 273 | } |
274 | 274 | ||
275 | void TEWidget::setFont(const QFont &) | 275 | void TEWidget::setFont(const QFont &) |
276 | { | 276 | { |
277 | // ignore font change request if not coming from konsole itself | 277 | // ignore font change request if not coming from konsole itself |
278 | } | 278 | } |
279 | 279 | ||
280 | /* ------------------------------------------------------------------------- */ | 280 | /* ------------------------------------------------------------------------- */ |
281 | /* */ | 281 | /* */ |
282 | /* Constructor / Destructor */ | 282 | /* Constructor / Destructor */ |
283 | /* */ | 283 | /* */ |
284 | /* ------------------------------------------------------------------------- */ | 284 | /* ------------------------------------------------------------------------- */ |
285 | 285 | ||
286 | TEWidget::TEWidget(QWidget *parent, const char *name) : QFrame(parent,name) | 286 | TEWidget::TEWidget(QWidget *parent, const char *name) : QFrame(parent,name) |
287 | { | 287 | { |
288 | #ifndef QT_NO_CLIPBOARD | 288 | #ifndef QT_NO_CLIPBOARD |
289 | cb = QApplication::clipboard(); | 289 | cb = QApplication::clipboard(); |
290 | QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), | 290 | QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), |
291 | this, SLOT(onClearSelection()) ); | 291 | this, SLOT(onClearSelection()) ); |
292 | #endif | 292 | #endif |
293 | 293 | ||
294 | scrollbar = new QScrollBar(this); | 294 | scrollbar = new QScrollBar(this); |
295 | scrollbar->setCursor( arrowCursor ); | 295 | scrollbar->setCursor( arrowCursor ); |
296 | connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); | 296 | connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); |
297 | 297 | ||
298 | hScrollbar = new QScrollBar(this); | 298 | hScrollbar = new QScrollBar(this); |
299 | hScrollbar->setCursor( arrowCursor ); | 299 | hScrollbar->setCursor( arrowCursor ); |
300 | hScrollbar->setOrientation(QScrollBar::Horizontal); | 300 | hScrollbar->setOrientation(QScrollBar::Horizontal); |
301 | // hScrollbar->setMaximumHeight(16); | 301 | // hScrollbar->setMaximumHeight(16); |
302 | 302 | ||
303 | connect( hScrollbar, SIGNAL(valueChanged(int)), this, SLOT( hScrollChanged(int))); | 303 | connect( hScrollbar, SIGNAL(valueChanged(int)), this, SLOT( hScrollChanged(int))); |
304 | 304 | ||
305 | Config cfg( "Konsole" ); | 305 | Config cfg( "Konsole" ); |
306 | cfg.setGroup("ScrollBar"); | 306 | cfg.setGroup("ScrollBar"); |
307 | switch( cfg.readNumEntry("Position",2)){ | 307 | switch( cfg.readNumEntry("Position",2)){ |
308 | case 0: | 308 | case 0: |
309 | scrollLoc = SCRNONE; | 309 | scrollLoc = SCRNONE; |
310 | break; | 310 | break; |
311 | case 1: | 311 | case 1: |
312 | scrollLoc = SCRLEFT; | 312 | scrollLoc = SCRLEFT; |
313 | break; | 313 | break; |
314 | case 2: | 314 | case 2: |
315 | scrollLoc = SCRRIGHT; | 315 | scrollLoc = SCRRIGHT; |
316 | break; | 316 | break; |
317 | }; | 317 | }; |
318 | 318 | ||
319 | useHorzScroll=cfg.readBoolEntry("HorzScroll",0); | 319 | useHorzScroll=cfg.readBoolEntry("HorzScroll",0); |
320 | 320 | ||
321 | blinkT = new QTimer(this); | 321 | blinkT = new QTimer(this); |
322 | connect(blinkT, SIGNAL(timeout()), this, SLOT(blinkEvent())); | 322 | connect(blinkT, SIGNAL(timeout()), this, SLOT(blinkEvent())); |
323 | // blinking = FALSE; | 323 | // blinking = FALSE; |
324 | blinking = TRUE; | 324 | blinking = TRUE; |
325 | 325 | ||
326 | resizing = FALSE; | 326 | resizing = FALSE; |
327 | actSel = 0; | 327 | actSel = 0; |
328 | image = 0; | 328 | image = 0; |
329 | lines = 1; | 329 | lines = 1; |
330 | columns = 1; | 330 | columns = 1; |
331 | font_w = 1; | 331 | font_w = 1; |
332 | font_h = 1; | 332 | font_h = 1; |
333 | font_a = 1; | 333 | font_a = 1; |
334 | word_selection_mode = FALSE; | 334 | word_selection_mode = FALSE; |
335 | hposition = 0; | 335 | hposition = 0; |
336 | vcolumns = 0; | 336 | vcolumns = 0; |
337 | useBeep = true; | 337 | useBeep = true; |
338 | 338 | ||
339 | setMouseMarks(TRUE); | 339 | setMouseMarks(TRUE); |
340 | setVTFont( QFont("fixed") ); | 340 | setVTFont( QFont("fixed") ); |
341 | setColorTable(base_color_table); // init color table | 341 | setColorTable(base_color_table); // init color table |
342 | 342 | ||
343 | qApp->installEventFilter( this ); //FIXME: see below | 343 | qApp->installEventFilter( this ); //FIXME: see below |
344 | // KCursor::setAutoHideCursor( this, true ); | 344 | // KCursor::setAutoHideCursor( this, true ); |
345 | 345 | ||
346 | // Init DnD //////////////////////////////////////////////////////////////// | 346 | // Init DnD //////////////////////////////////////////////////////////////// |
347 | currentSession = NULL; | 347 | currentSession = NULL; |
348 | // setAcceptDrops(true); // attempt | 348 | // setAcceptDrops(true); // attempt |
349 | // m_drop = new QPopupMenu(this); | 349 | // m_drop = new QPopupMenu(this); |
350 | // m_drop->insertItem( QString("Paste"), 0); | 350 | // m_drop->insertItem( QString("Paste"), 0); |
351 | // m_drop->insertItem( QString("cd"), 1); | 351 | // m_drop->insertItem( QString("cd"), 1); |
352 | // connect(m_drop, SIGNAL(activated(int)), SLOT(drop_menu_activated(int))); | 352 | // connect(m_drop, SIGNAL(activated(int)), SLOT(drop_menu_activated(int))); |
353 | 353 | ||
354 | // we need focus so that the auto-hide cursor feature works | 354 | // we need focus so that the auto-hide cursor feature works |
355 | setFocus(); | 355 | setFocus(); |
356 | setFocusPolicy( WheelFocus ); | 356 | setFocusPolicy( WheelFocus ); |
357 | } | 357 | } |
358 | 358 | ||
359 | //FIXME: make proper destructor | 359 | //FIXME: make proper destructor |
360 | // Here's a start (David) | 360 | // Here's a start (David) |
361 | TEWidget::~TEWidget() | 361 | TEWidget::~TEWidget() |
362 | { | 362 | { |
363 | qApp->removeEventFilter( this ); | 363 | qApp->removeEventFilter( this ); |
364 | if (image) free(image); | 364 | if (image) free(image); |
365 | } | 365 | } |
366 | 366 | ||
367 | /* ------------------------------------------------------------------------- */ | 367 | /* ------------------------------------------------------------------------- */ |
368 | /* */ | 368 | /* */ |
369 | /* Display Operations */ | 369 | /* Display Operations */ |
370 | /* */ | 370 | /* */ |
371 | /* ------------------------------------------------------------------------- */ | 371 | /* ------------------------------------------------------------------------- */ |
372 | 372 | ||
373 | /*! | 373 | /*! |
374 | attributed string draw primitive | 374 | attributed string draw primitive |
375 | */ | 375 | */ |
376 | 376 | ||
377 | void TEWidget::drawAttrStr(QPainter &paint, QRect rect, | 377 | void TEWidget::drawAttrStr(QPainter &paint, QRect rect, |
378 | QString& str, ca attr, BOOL pm, BOOL clear) | 378 | QString& str, ca attr, BOOL pm, BOOL clear) |
379 | { | 379 | { |
380 | if (pm && color_table[attr.b].transparent) | 380 | if (pm && color_table[attr.b].transparent) |
381 | { | 381 | { |
382 | paint.setBackgroundMode( TransparentMode ); | 382 | paint.setBackgroundMode( TransparentMode ); |
383 | if (clear) erase(rect); | 383 | if (clear) erase(rect); |
384 | } | 384 | } |
385 | else | 385 | else |
386 | { | 386 | { |
387 | if (blinking) | 387 | if (blinking) |
388 | paint.fillRect(rect, color_table[attr.b].color); | 388 | paint.fillRect(rect, color_table[attr.b].color); |
389 | else | 389 | else |
390 | { | 390 | { |
391 | paint.setBackgroundMode( OpaqueMode ); | 391 | paint.setBackgroundMode( OpaqueMode ); |
392 | paint.setBackgroundColor( color_table[attr.b].color ); | 392 | paint.setBackgroundColor( color_table[attr.b].color ); |
393 | } | 393 | } |
394 | } | 394 | } |
395 | 395 | ||
396 | if (color_table[attr.f].bold) | 396 | if (color_table[attr.f].bold) |
397 | paint.setPen(QColor( 0x8F, 0x00, 0x00 )); | 397 | paint.setPen(QColor( 0x8F, 0x00, 0x00 )); |
398 | else | 398 | else |
399 | paint.setPen(color_table[attr.f].color); | 399 | paint.setPen(color_table[attr.f].color); |
400 | 400 | ||
401 | paint.drawText(rect.x(),rect.y()+font_a, str); | 401 | paint.drawText(rect.x(),rect.y()+font_a, str); |
402 | 402 | ||
403 | if (attr.r & RE_UNDERLINE) | 403 | if (attr.r & RE_UNDERLINE) |
404 | paint.drawLine(rect.left(), rect.y()+font_a+1, rect.right(),rect.y()+font_a+1 ); | 404 | paint.drawLine(rect.left(), rect.y()+font_a+1, rect.right(),rect.y()+font_a+1 ); |
405 | } | 405 | } |
406 | 406 | ||
407 | /*! | 407 | /*! |
408 | The image can only be set completely. | 408 | The image can only be set completely. |
409 | 409 | ||
410 | The size of the new image may or may not match the size of the widget. | 410 | The size of the new image may or may not match the size of the widget. |
411 | */ | 411 | */ |
412 | 412 | ||
413 | void TEWidget::setImage(const ca* const newimg, int lines, int columns) | 413 | void TEWidget::setImage(const ca* const newimg, int lines, int columns) |
414 | { int y,x,len; | 414 | { int y,x,len; |
415 | const QPixmap* pm = backgroundPixmap(); | 415 | const QPixmap* pm = backgroundPixmap(); |
416 | QPainter paint; | 416 | QPainter paint; |
417 | setUpdatesEnabled(FALSE); | 417 | setUpdatesEnabled(FALSE); |
418 | paint.begin( this ); | 418 | paint.begin( this ); |
419 | HCNT("setImage"); | 419 | HCNT("setImage"); |
420 | 420 | ||
421 | QPoint tL = contentsRect().topLeft(); | 421 | QPoint tL = contentsRect().topLeft(); |
422 | int tLx = tL.x(); | 422 | int tLx = tL.x(); |
423 | int tLy = tL.y(); | 423 | int tLy = tL.y(); |
424 | hasBlinker = FALSE; | 424 | hasBlinker = FALSE; |
425 | 425 | ||
426 | int cf = -1; // undefined | 426 | int cf = -1; // undefined |
427 | int cb = -1; // undefined | 427 | int cb = -1; // undefined |
428 | int cr = -1; // undefined | 428 | int cr = -1; // undefined |
429 | 429 | ||
430 | int lins = QMIN(this->lines, QMAX(0,lines )); | 430 | int lins = QMIN(this->lines, QMAX(0,lines )); |
431 | int cols = QMIN(this->columns,QMAX(0,columns)); | 431 | int cols = QMIN(this->columns,QMAX(0,columns)); |
432 | QChar *disstrU = new QChar[cols]; | 432 | QChar *disstrU = new QChar[cols]; |
433 | for (y = 0; y < lins; y++) { | 433 | for (y = 0; y < lins; y++) { |
434 | const ca* lcl = &image[y*this->columns]; | 434 | const ca* lcl = &image[y*this->columns]; |
435 | const ca* const ext = &newimg[y*columns]; | 435 | const ca* const ext = &newimg[y*columns]; |
436 | if (!resizing) // not while resizing, we're expecting a paintEvent | 436 | if (!resizing) // not while resizing, we're expecting a paintEvent |
437 | for (x = 0; x < cols; x++) | 437 | for (x = 0; x < cols; x++) |
438 | { | 438 | { |
439 | hasBlinker |= (ext[x].r & RE_BLINK); | 439 | hasBlinker |= (ext[x].r & RE_BLINK); |
440 | if (ext[x] != lcl[x]) | 440 | if (ext[x] != lcl[x]) |
441 | { | 441 | { |
442 | cr = ext[x].r; | 442 | cr = ext[x].r; |
443 | cb = ext[x].b; | 443 | cb = ext[x].b; |
444 | if (ext[x].f != cf) cf = ext[x].f; | 444 | if (ext[x].f != cf) cf = ext[x].f; |
445 | int lln = cols - x; | 445 | int lln = cols - x; |
446 | disstrU[0] = fontMap(ext[x+0].c); | 446 | disstrU[0] = fontMap(ext[x+0].c); |
447 | for (len = 1; len < lln; len++) | 447 | for (len = 1; len < lln; len++) |
448 | { | 448 | { |
449 | if (ext[x+len].f != cf || ext[x+len].b != cb || ext[x+len].r != cr || | 449 | if (ext[x+len].f != cf || ext[x+len].b != cb || ext[x+len].r != cr || |
450 | ext[x+len] == lcl[x+len] ) | 450 | ext[x+len] == lcl[x+len] ) |
451 | break; | 451 | break; |
452 | disstrU[len] = fontMap(ext[x+len].c); | 452 | disstrU[len] = fontMap(ext[x+len].c); |
453 | } | 453 | } |
454 | QString unistr(disstrU,len); | 454 | QString unistr(disstrU,len); |
455 | drawAttrStr(paint, | 455 | drawAttrStr(paint, |
456 | QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h), | 456 | QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h), |
457 | unistr, ext[x], pm != NULL, true); | 457 | unistr, ext[x], pm != NULL, true); |
458 | x += len - 1; | 458 | x += len - 1; |
459 | } | 459 | } |
460 | } | 460 | } |
461 | // finally, make `image' become `newimg'. | 461 | // finally, make `image' become `newimg'. |
462 | memcpy((void*)lcl,(const void*)ext,cols*sizeof(ca)); | 462 | memcpy((void*)lcl,(const void*)ext,cols*sizeof(ca)); |
463 | } | 463 | } |
464 | drawFrame( &paint ); | 464 | drawFrame( &paint ); |
465 | paint.end(); | 465 | paint.end(); |
466 | setUpdatesEnabled(TRUE); | 466 | setUpdatesEnabled(TRUE); |
467 | if ( hasBlinker && !blinkT->isActive()) blinkT->start(1000); // 1000 ms | 467 | if ( hasBlinker && !blinkT->isActive()) blinkT->start(1000); // 1000 ms |
468 | if (!hasBlinker && blinkT->isActive()) { blinkT->stop(); blinking = FALSE; } | 468 | if (!hasBlinker && blinkT->isActive()) { blinkT->stop(); blinking = FALSE; } |
469 | delete [] disstrU; | 469 | delete [] disstrU; |
470 | } | 470 | } |
471 | 471 | ||
472 | // paint Event //////////////////////////////////////////////////// | 472 | // paint Event //////////////////////////////////////////////////// |
473 | 473 | ||
474 | /*! | 474 | /*! |
475 | The difference of this routine vs. the `setImage' is, | 475 | The difference of this routine vs. the `setImage' is, |
476 | that the drawing does not include a difference analysis | 476 | that the drawing does not include a difference analysis |
477 | between the old and the new image. Instead, the internal | 477 | between the old and the new image. Instead, the internal |
478 | image is used and the painting bound by the PaintEvent box. | 478 | image is used and the painting bound by the PaintEvent box. |
479 | */ | 479 | */ |
480 | 480 | ||
481 | void TEWidget::paintEvent( QPaintEvent* pe ) | 481 | void TEWidget::paintEvent( QPaintEvent* pe ) |
482 | { | 482 | { |
483 | 483 | ||
484 | //{ static int cnt = 0; printf("paint %d\n",cnt++); } | 484 | //{ static int cnt = 0; printf("paint %d\n",cnt++); } |
485 | const QPixmap* pm = backgroundPixmap(); | 485 | const QPixmap* pm = backgroundPixmap(); |
486 | QPainter paint; | 486 | QPainter paint; |
487 | setUpdatesEnabled(FALSE); | 487 | setUpdatesEnabled(FALSE); |
488 | paint.begin( this ); | 488 | paint.begin( this ); |
489 | paint.setBackgroundMode( TransparentMode ); | 489 | paint.setBackgroundMode( TransparentMode ); |
490 | HCNT("paintEvent"); | 490 | HCNT("paintEvent"); |
491 | 491 | ||
492 | // Note that the actual widget size can be slightly larger | 492 | // Note that the actual widget size can be slightly larger |
493 | // that the image (the size is truncated towards the smaller | 493 | // that the image (the size is truncated towards the smaller |
494 | // number of characters in `resizeEvent'. The paint rectangle | 494 | // number of characters in `resizeEvent'. The paint rectangle |
495 | // can thus be larger than the image, but less then the size | 495 | // can thus be larger than the image, but less then the size |
496 | // of one character. | 496 | // of one character. |
497 | 497 | ||
498 | QRect rect = pe->rect().intersect(contentsRect()); | 498 | QRect rect = pe->rect().intersect(contentsRect()); |
499 | 499 | ||
500 | QPoint tL = contentsRect().topLeft(); | 500 | QPoint tL = contentsRect().topLeft(); |
501 | int tLx = tL.x(); | 501 | int tLx = tL.x(); |
502 | int tLy = tL.y(); | 502 | int tLy = tL.y(); |
503 | 503 | ||
504 | int lux = QMIN(columns-1, QMAX(0,(rect.left() - tLx - blX ) / font_w)); | 504 | int lux = QMIN(columns-1, QMAX(0,(rect.left() - tLx - blX ) / font_w)); |
505 | int luy = QMIN(lines-1, QMAX(0,(rect.top() - tLy - bY ) / font_h)); | 505 | int luy = QMIN(lines-1, QMAX(0,(rect.top() - tLy - bY ) / font_h)); |
506 | int rlx = QMIN(columns-1, QMAX(0,(rect.right() - tLx - blX ) / font_w)); | 506 | int rlx = QMIN(columns-1, QMAX(0,(rect.right() - tLx - blX ) / font_w)); |
507 | int rly = QMIN(lines-1, QMAX(0,(rect.bottom() - tLy - bY ) / font_h)); | 507 | int rly = QMIN(lines-1, QMAX(0,(rect.bottom() - tLy - bY ) / font_h)); |
508 | 508 | ||
509 | /* | 509 | /* |
510 | printf("paintEvent: %d..%d, %d..%d (%d..%d, %d..%d)\n",lux,rlx,luy,rly, | 510 | printf("paintEvent: %d..%d, %d..%d (%d..%d, %d..%d)\n",lux,rlx,luy,rly, |
511 | rect.left(), rect.right(), rect.top(), rect.bottom()); | 511 | rect.left(), rect.right(), rect.top(), rect.bottom()); |
512 | */ | 512 | */ |
513 | 513 | ||
514 | // if (pm != NULL && color_table[image->b].transparent) | 514 | // if (pm != NULL && color_table[image->b].transparent) |
515 | // erase(rect); | 515 | // erase(rect); |
516 | // BL: I have no idea why we need this, and it breaks the refresh. | 516 | // BL: I have no idea why we need this, and it breaks the refresh. |
517 | 517 | ||
518 | QChar *disstrU = new QChar[columns]; | 518 | QChar *disstrU = new QChar[columns]; |
519 | for (int y = luy; y <= rly; y++) | 519 | for (int y = luy; y <= rly; y++) |
520 | for (int x = lux; x <= rlx; x++) | 520 | for (int x = lux; x <= rlx; x++) |
521 | { | 521 | { |
522 | int len = 1; | 522 | int len = 1; |
523 | disstrU[0] = fontMap(image[loc(x,y)].c); | 523 | disstrU[0] = fontMap(image[loc(x,y)].c); |
524 | int cf = image[loc(x,y)].f; | 524 | int cf = image[loc(x,y)].f; |
525 | int cb = image[loc(x,y)].b; | 525 | int cb = image[loc(x,y)].b; |
526 | int cr = image[loc(x,y)].r; | 526 | int cr = image[loc(x,y)].r; |
527 | while (x+len <= rlx && | 527 | while (x+len <= rlx && |
528 | image[loc(x+len,y)].f == cf && | 528 | image[loc(x+len,y)].f == cf && |
529 | image[loc(x+len,y)].b == cb && | 529 | image[loc(x+len,y)].b == cb && |
530 | image[loc(x+len,y)].r == cr ) | 530 | image[loc(x+len,y)].r == cr ) |
531 | { | 531 | { |
532 | disstrU[len] = fontMap(image[loc(x+len,y)].c); | 532 | disstrU[len] = fontMap(image[loc(x+len,y)].c); |
533 | len += 1; | 533 | len += 1; |
534 | } | 534 | } |
535 | QString unistr(disstrU,len); | 535 | QString unistr(disstrU,len); |
536 | drawAttrStr(paint, | 536 | drawAttrStr(paint, |
537 | QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h), | 537 | QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h), |
538 | unistr, image[loc(x,y)], pm != NULL, false); | 538 | unistr, image[loc(x,y)], pm != NULL, false); |
539 | x += len - 1; | 539 | x += len - 1; |
540 | } | 540 | } |
541 | delete [] disstrU; | 541 | delete [] disstrU; |
542 | drawFrame( &paint ); | 542 | drawFrame( &paint ); |
543 | paint.end(); | 543 | paint.end(); |
544 | setUpdatesEnabled(TRUE); | 544 | setUpdatesEnabled(TRUE); |
545 | } | 545 | } |
546 | 546 | ||
547 | void TEWidget::blinkEvent() | 547 | void TEWidget::blinkEvent() |
548 | { | 548 | { |
549 | blinking = !blinking; | 549 | blinking = !blinking; |
550 | repaint(FALSE); | 550 | repaint(FALSE); |
551 | } | 551 | } |
552 | 552 | ||
553 | /* ------------------------------------------------------------------------- */ | 553 | /* ------------------------------------------------------------------------- */ |
554 | /* */ | 554 | /* */ |
555 | /* Resizing */ | 555 | /* Resizing */ |
556 | /* */ | 556 | /* */ |
557 | /* ------------------------------------------------------------------------- */ | 557 | /* ------------------------------------------------------------------------- */ |
558 | 558 | ||
559 | void TEWidget::resizeEvent(QResizeEvent* ev) | 559 | void TEWidget::resizeEvent(QResizeEvent* ev) |
560 | { | 560 | { |
561 | // printf("resize: %d,%d\n",ev->size().width(),ev->size().height()); | 561 | // printf("resize: %d,%d\n",ev->size().width(),ev->size().height()); |
562 | //printf("approx: %d,%d\n",ev->size().width()/font_w,ev->size().height()/font_h); | 562 | //printf("approx: %d,%d\n",ev->size().width()/font_w,ev->size().height()/font_h); |
563 | //printf("leaves: %d,%d\n",ev->size().width()%font_w,ev->size().height()%font_h); | 563 | //printf("leaves: %d,%d\n",ev->size().width()%font_w,ev->size().height()%font_h); |
564 | //printf("curren: %d,%d\n",width(),height()); | 564 | //printf("curren: %d,%d\n",width(),height()); |
565 | HCNT("resizeEvent"); | 565 | HCNT("resizeEvent"); |
566 | 566 | ||
567 | // see comment in `paintEvent' concerning the rounding. | 567 | // see comment in `paintEvent' concerning the rounding. |
568 | //FIXME: could make a routine here; check width(),height() | 568 | //FIXME: could make a routine here; check width(),height() |
569 | assert(ev->size().width() == width()); | 569 | assert(ev->size().width() == width()); |
570 | assert(ev->size().height() == height()); | 570 | assert(ev->size().height() == height()); |
571 | 571 | ||
572 | propagateSize(); | 572 | propagateSize(); |
573 | } | 573 | } |
574 | 574 | ||
575 | void TEWidget::propagateSize() | 575 | void TEWidget::propagateSize() |
576 | { | 576 | { |
577 | ca* oldimg = image; | 577 | ca* oldimg = image; |
578 | int oldlin = lines; | 578 | int oldlin = lines; |
579 | int oldcol = columns; | 579 | int oldcol = columns; |
580 | makeImage(); | 580 | makeImage(); |
581 | // we copy the old image to reduce flicker | 581 | // we copy the old image to reduce flicker |
582 | int lins = QMIN(oldlin,lines); | 582 | int lins = QMIN(oldlin,lines); |
583 | int cols = QMIN(oldcol,columns); | 583 | int cols = QMIN(oldcol,columns); |
584 | if (oldimg) | 584 | if (oldimg) |
585 | { | 585 | { |
586 | for (int lin = 0; lin < lins; lin++) | 586 | for (int lin = 0; lin < lins; lin++) |
587 | memcpy((void*)&image[columns*lin], | 587 | memcpy((void*)&image[columns*lin], |
588 | (void*)&oldimg[oldcol*lin],cols*sizeof(ca)); | 588 | (void*)&oldimg[oldcol*lin],cols*sizeof(ca)); |
589 | free(oldimg); //FIXME: try new,delete | 589 | free(oldimg); //FIXME: try new,delete |
590 | } | 590 | } |
591 | else | 591 | else |
592 | clearImage(); | 592 | clearImage(); |
593 | 593 | ||
594 | //NOTE: control flows from the back through the chest right into the eye. | 594 | //NOTE: control flows from the back through the chest right into the eye. |
595 | // `emu' will call back via `setImage'. | 595 | // `emu' will call back via `setImage'. |
596 | 596 | ||
597 | resizing = TRUE; | 597 | resizing = TRUE; |
598 | emit changedImageSizeSignal(lines, columns); // expose resizeEvent | 598 | emit changedImageSizeSignal(lines, columns); // expose resizeEvent |
599 | resizing = FALSE; | 599 | resizing = FALSE; |
600 | } | 600 | } |
601 | 601 | ||
602 | /* ------------------------------------------------------------------------- */ | 602 | /* ------------------------------------------------------------------------- */ |
603 | /* */ | 603 | /* */ |
604 | /* Scrollbar */ | 604 | /* Scrollbar */ |
605 | /* */ | 605 | /* */ |
606 | /* ------------------------------------------------------------------------- */ | 606 | /* ------------------------------------------------------------------------- */ |
607 | 607 | ||
608 | void TEWidget::scrollChanged(int) { | 608 | void TEWidget::scrollChanged(int) { |
609 | emit changedHistoryCursor(scrollbar->value()); //expose | 609 | emit changedHistoryCursor(scrollbar->value()); //expose |
610 | } | 610 | } |
611 | 611 | ||
612 | void TEWidget::hScrollChanged(int loc) { | 612 | void TEWidget::hScrollChanged(int loc) { |
613 | hposition = loc; | 613 | hposition = loc; |
614 | propagateSize(); | 614 | propagateSize(); |
615 | update(); | 615 | update(); |
616 | 616 | ||
617 | // emit changedHorzCursor( hScrollbar->value()); //expose | 617 | // emit changedHorzCursor( hScrollbar->value()); //expose |
618 | } | 618 | } |
619 | 619 | ||
620 | void TEWidget::setScroll(int cursor, int slines) | 620 | void TEWidget::setScroll(int cursor, int slines) |
621 | { | 621 | { |
622 | disconnect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); | 622 | disconnect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); |
623 | scrollbar->setRange(0,slines); | 623 | scrollbar->setRange(0,slines); |
624 | scrollbar->setSteps(1,lines); | 624 | scrollbar->setSteps(1,lines); |
625 | scrollbar->setValue(cursor); | 625 | scrollbar->setValue(cursor); |
626 | connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); | 626 | connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); |
627 | } | 627 | } |
628 | 628 | ||
629 | void TEWidget::setScrollbarLocation(int loc) | 629 | void TEWidget::setScrollbarLocation(int loc) |
630 | { | 630 | { |
631 | if (scrollLoc == loc) return; // quickly | 631 | if (scrollLoc == loc) return; // quickly |
632 | scrollLoc = loc; | 632 | scrollLoc = loc; |
633 | propagateSize(); | 633 | propagateSize(); |
634 | update(); | 634 | update(); |
635 | } | 635 | } |
636 | 636 | ||
637 | /* ------------------------------------------------------------------------- */ | 637 | /* ------------------------------------------------------------------------- */ |
638 | /* */ | 638 | /* */ |
639 | /* Mouse */ | 639 | /* Mouse */ |
640 | /* */ | 640 | /* */ |
641 | /* ------------------------------------------------------------------------- */ | 641 | /* ------------------------------------------------------------------------- */ |
642 | 642 | ||
643 | /*! | 643 | /*! |
644 | Three different operations can be performed using the mouse, and the | 644 | Three different operations can be performed using the mouse, and the |
645 | routines in this section serve all of them: | 645 | routines in this section serve all of them: |
646 | 646 | ||
647 | 1) The press/release events are exposed to the application | 647 | 1) The press/release events are exposed to the application |
648 | 2) Marking (press and move left button) and Pasting (press middle button) | 648 | 2) Marking (press and move left button) and Pasting (press middle button) |
649 | 3) The right mouse button is used from the configuration menu | 649 | 3) The right mouse button is used from the configuration menu |
650 | 650 | ||
651 | NOTE: During the marking process we attempt to keep the cursor within | 651 | NOTE: During the marking process we attempt to keep the cursor within |
652 | the bounds of the text as being displayed by setting the mouse position | 652 | the bounds of the text as being displayed by setting the mouse position |
653 | whenever the mouse has left the text area. | 653 | whenever the mouse has left the text area. |
654 | 654 | ||
655 | Two reasons to do so: | 655 | Two reasons to do so: |
656 | 1) QT does not allow the `grabMouse' to confine-to the TEWidget. | 656 | 1) QT does not allow the `grabMouse' to confine-to the TEWidget. |
657 | Thus a `XGrapPointer' would have to be used instead. | 657 | Thus a `XGrapPointer' would have to be used instead. |
658 | 2) Even if so, this would not help too much, since the text area | 658 | 2) Even if so, this would not help too much, since the text area |
659 | of the TEWidget is normally not identical with it's bounds. | 659 | of the TEWidget is normally not identical with it's bounds. |
660 | 660 | ||
661 | The disadvantage of the current handling is, that the mouse can visibly | 661 | The disadvantage of the current handling is, that the mouse can visibly |
662 | leave the bounds of the widget and is then moved back. Because of the | 662 | leave the bounds of the widget and is then moved back. Because of the |
663 | current construction, and the reasons mentioned above, we cannot do better | 663 | current construction, and the reasons mentioned above, we cannot do better |
664 | without changing the overall construction. | 664 | without changing the overall construction. |
665 | */ | 665 | */ |
666 | 666 | ||
667 | /*! | 667 | /*! |
668 | */ | 668 | */ |
669 | 669 | ||
670 | void TEWidget::mousePressEvent(QMouseEvent* ev) | 670 | void TEWidget::mousePressEvent(QMouseEvent* ev) |
671 | { | 671 | { |
672 | //printf("press [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button()); | 672 | //printf("press [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button()); |
673 | if ( !contentsRect().contains(ev->pos()) ) return; | 673 | if ( !contentsRect().contains(ev->pos()) ) return; |
674 | QPoint tL = contentsRect().topLeft(); | 674 | QPoint tL = contentsRect().topLeft(); |
675 | int tLx = tL.x(); | 675 | int tLx = tL.x(); |
676 | int tLy = tL.y(); | 676 | int tLy = tL.y(); |
677 | 677 | ||
678 | mouse_down_x = ev->x(); | 678 | mouse_down_x = ev->x(); |
679 | mouse_down_y = ev->y(); | 679 | mouse_down_y = ev->y(); |
680 | 680 | ||
681 | //printf("press top left [%d,%d] by=%d\n",tLx,tLy, bY); | 681 | //printf("press top left [%d,%d] by=%d\n",tLx,tLy, bY); |
682 | if ( ev->button() == LeftButton) | 682 | if ( ev->button() == LeftButton) |
683 | { | 683 | { |
684 | QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); | 684 | QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); |
685 | 685 | ||
686 | word_selection_mode = (ev->state() & ShiftButton); | 686 | word_selection_mode = (ev->state() & ShiftButton); |
687 | 687 | ||
688 | if ( ev->state() & ControlButton ) preserve_line_breaks = FALSE ; | 688 | if ( ev->state() & ControlButton ) preserve_line_breaks = FALSE ; |
689 | 689 | ||
690 | if (mouse_marks || (ev->state() & ShiftButton)) | 690 | if (mouse_marks || (ev->state() & ShiftButton)) |
691 | { | 691 | { |
692 | emit clearSelectionSignal(); | 692 | emit clearSelectionSignal(); |
693 | iPntSel = pntSel = pos; | 693 | iPntSel = pntSel = pos; |
694 | actSel = 1; // left mouse button pressed but nothing selected yet. | 694 | actSel = 1; // left mouse button pressed but nothing selected yet. |
695 | grabMouse( /*crossCursor*/ ); // handle with care! | 695 | grabMouse( /*crossCursor*/ ); // handle with care! |
696 | } | 696 | } |
697 | else | 697 | else |
698 | { | 698 | { |
699 | emit mouseSignal( 0, pos.x() + 1, pos.y() + 1 ); // left button | 699 | emit mouseSignal( 0, pos.x() + 1, pos.y() + 1 ); // left button |
700 | } | 700 | } |
701 | } | 701 | } |
702 | if ( ev->button() == MidButton ) | 702 | if ( ev->button() == MidButton ) |
703 | { | 703 | { |
704 | emitSelection(); | 704 | emitSelection(); |
705 | } | 705 | } |
706 | if ( ev->button() == RightButton ) // Configure | 706 | if ( ev->button() == RightButton ) // Configure |
707 | { | 707 | { |
708 | emit configureRequest( this, ev->state()&(ShiftButton|ControlButton), ev->x(), ev->y() ); | 708 | emit configureRequest( this, ev->state()&(ShiftButton|ControlButton), ev->x(), ev->y() ); |
709 | } | 709 | } |
710 | } | 710 | } |
711 | 711 | ||
712 | void TEWidget::mouseMoveEvent(QMouseEvent* ev) | 712 | void TEWidget::mouseMoveEvent(QMouseEvent* ev) |
713 | { | 713 | { |
714 | // for auto-hiding the cursor, we need mouseTracking | 714 | // for auto-hiding the cursor, we need mouseTracking |
715 | if (ev->state() == NoButton ) return; | 715 | if (ev->state() == NoButton ) return; |
716 | 716 | ||
717 | if (actSel == 0) return; | 717 | if (actSel == 0) return; |
718 | 718 | ||
719 | // don't extend selection while pasting | 719 | // don't extend selection while pasting |
720 | if (ev->state() & MidButton) return; | 720 | if (ev->state() & MidButton) return; |
721 | 721 | ||
722 | //if ( !contentsRect().contains(ev->pos()) ) return; | 722 | //if ( !contentsRect().contains(ev->pos()) ) return; |
723 | QPoint tL = contentsRect().topLeft(); | 723 | QPoint tL = contentsRect().topLeft(); |
724 | int tLx = tL.x(); | 724 | int tLx = tL.x(); |
725 | int tLy = tL.y(); | 725 | int tLy = tL.y(); |
726 | int scroll = scrollbar->value(); | 726 | int scroll = scrollbar->value(); |
727 | // int hScroll = hScrollbar->value(); | 727 | // int hScroll = hScrollbar->value(); |
728 | 728 | ||
729 | // we're in the process of moving the mouse with the left button pressed | 729 | // we're in the process of moving the mouse with the left button pressed |
730 | // the mouse cursor will kept catched within the bounds of the text in | 730 | // the mouse cursor will kept catched within the bounds of the text in |
731 | // this widget. | 731 | // this widget. |
732 | 732 | ||
733 | // Adjust position within text area bounds. See FIXME above. | 733 | // Adjust position within text area bounds. See FIXME above. |
734 | QPoint pos = ev->pos(); | 734 | QPoint pos = ev->pos(); |
735 | if ( pos.x() < tLx+blX ) pos.setX( tLx+blX ); | 735 | if ( pos.x() < tLx+blX ) pos.setX( tLx+blX ); |
736 | if ( pos.x() > tLx+blX+columns*font_w-1 ) pos.setX( tLx+blX+columns*font_w ); | 736 | if ( pos.x() > tLx+blX+columns*font_w-1 ) pos.setX( tLx+blX+columns*font_w ); |
737 | if ( pos.y() < tLy+bY ) pos.setY( tLy+bY ); | 737 | if ( pos.y() < tLy+bY ) pos.setY( tLy+bY ); |
738 | if ( pos.y() > tLy+bY+lines*font_h-1 ) pos.setY( tLy+bY+lines*font_h-1 ); | 738 | if ( pos.y() > tLy+bY+lines*font_h-1 ) pos.setY( tLy+bY+lines*font_h-1 ); |
739 | // check if we produce a mouse move event by this | 739 | // check if we produce a mouse move event by this |
740 | if ( pos != ev->pos() ) cursor().setPos(mapToGlobal(pos)); | 740 | if ( pos != ev->pos() ) cursor().setPos(mapToGlobal(pos)); |
741 | 741 | ||
742 | if ( pos.y() == tLy+bY+lines*font_h-1 ) | 742 | if ( pos.y() == tLy+bY+lines*font_h-1 ) |
743 | { | 743 | { |
744 | scrollbar->setValue(scrollbar->value()+yMouseScroll); // scrollforward | 744 | scrollbar->setValue(scrollbar->value()+yMouseScroll); // scrollforward |
745 | } | 745 | } |
746 | if ( pos.y() == tLy+bY ) | 746 | if ( pos.y() == tLy+bY ) |
747 | { | 747 | { |
748 | scrollbar->setValue(scrollbar->value()-yMouseScroll); // scrollback | 748 | scrollbar->setValue(scrollbar->value()-yMouseScroll); // scrollback |
749 | } | 749 | } |
750 | 750 | ||
751 | QPoint here = QPoint((pos.x()-tLx-blX)/font_w,(pos.y()-tLy-bY)/font_h); | 751 | QPoint here = QPoint((pos.x()-tLx-blX)/font_w,(pos.y()-tLy-bY)/font_h); |
752 | QPoint ohere; | 752 | QPoint ohere; |
753 | bool swapping = FALSE; | 753 | bool swapping = FALSE; |
754 | 754 | ||
755 | if ( word_selection_mode ) | 755 | if ( word_selection_mode ) |
756 | { | 756 | { |
757 | // Extend to word boundaries | 757 | // Extend to word boundaries |
758 | int i; | 758 | int i; |
759 | int selClass; | 759 | int selClass; |
760 | 760 | ||
761 | bool left_not_right = ( here.y() < iPntSel.y() || | 761 | bool left_not_right = ( here.y() < iPntSel.y() || |
762 | here.y() == iPntSel.y() && here.x() < iPntSel.x() ); | 762 | here.y() == iPntSel.y() && here.x() < iPntSel.x() ); |
763 | bool old_left_not_right = ( pntSel.y() < iPntSel.y() || | 763 | bool old_left_not_right = ( pntSel.y() < iPntSel.y() || |
764 | pntSel.y() == iPntSel.y() && pntSel.x() < iPntSel.x() ); | 764 | pntSel.y() == iPntSel.y() && pntSel.x() < iPntSel.x() ); |
765 | swapping = left_not_right != old_left_not_right; | 765 | swapping = left_not_right != old_left_not_right; |
766 | 766 | ||
767 | // Find left (left_not_right ? from here : from start) | 767 | // Find left (left_not_right ? from here : from start) |
768 | QPoint left = left_not_right ? here : iPntSel; | 768 | QPoint left = left_not_right ? here : iPntSel; |
769 | i = loc(left.x(),left.y()); | 769 | i = loc(left.x(),left.y()); |
770 | selClass = charClass(image[i].c); | 770 | selClass = charClass(image[i].c); |
771 | while ( left.x() > 0 && charClass(image[i-1].c) == selClass ) | 771 | while ( left.x() > 0 && charClass(image[i-1].c) == selClass ) |
772 | { i--; left.rx()--; } | 772 | { i--; left.rx()--; } |
773 | 773 | ||
774 | // Find left (left_not_right ? from start : from here) | 774 | // Find left (left_not_right ? from start : from here) |
775 | QPoint right = left_not_right ? iPntSel : here; | 775 | QPoint right = left_not_right ? iPntSel : here; |
776 | i = loc(right.x(),right.y()); | 776 | i = loc(right.x(),right.y()); |
777 | selClass = charClass(image[i].c); | 777 | selClass = charClass(image[i].c); |
778 | while ( right.x() < columns-1 && charClass(image[i+1].c) == selClass ) | 778 | while ( right.x() < columns-1 && charClass(image[i+1].c) == selClass ) |
779 | { i++; right.rx()++; } | 779 | { i++; right.rx()++; } |
780 | 780 | ||
781 | // Pick which is start (ohere) and which is extension (here) | 781 | // Pick which is start (ohere) and which is extension (here) |
782 | if ( left_not_right ) | 782 | if ( left_not_right ) |
783 | { | 783 | { |
784 | here = left; ohere = right; | 784 | here = left; ohere = right; |
785 | } | 785 | } |
786 | else | 786 | else |
787 | { | 787 | { |
788 | here = right; ohere = left; | 788 | here = right; ohere = left; |
789 | } | 789 | } |
790 | } | 790 | } |
791 | 791 | ||
792 | if (here == pntSel && scroll == scrollbar->value()) return; // not moved | 792 | if (here == pntSel && scroll == scrollbar->value()) return; // not moved |
793 | 793 | ||
794 | if ( word_selection_mode ) { | 794 | if ( word_selection_mode ) { |
795 | if ( actSel < 2 || swapping ) { | 795 | if ( actSel < 2 || swapping ) { |
796 | emit beginSelectionSignal( ohere.x(), ohere.y() ); | 796 | emit beginSelectionSignal( ohere.x(), ohere.y() ); |
797 | } | 797 | } |
798 | } else if ( actSel < 2 ) { | 798 | } else if ( actSel < 2 ) { |
799 | emit beginSelectionSignal( pntSel.x(), pntSel.y() ); | 799 | emit beginSelectionSignal( pntSel.x(), pntSel.y() ); |
800 | } | 800 | } |
801 | 801 | ||
802 | actSel = 2; // within selection | 802 | actSel = 2; // within selection |
803 | pntSel = here; | 803 | pntSel = here; |
804 | emit extendSelectionSignal( here.x(), here.y() ); | 804 | emit extendSelectionSignal( here.x(), here.y() ); |
805 | } | 805 | } |
806 | 806 | ||
807 | void TEWidget::mouseReleaseEvent(QMouseEvent* ev) | 807 | void TEWidget::mouseReleaseEvent(QMouseEvent* ev) |
808 | { | 808 | { |
809 | //printf("release [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button()); | 809 | //printf("release [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button()); |
810 | if ( ev->button() == LeftButton) | 810 | if ( ev->button() == LeftButton) |
811 | { | 811 | { |
812 | if (QABS(ev->x() - mouse_down_x) < 3 | 812 | if (QABS(ev->x() - mouse_down_x) < 3 |
813 | && QABS(ev->y() - mouse_down_y) < 3 | 813 | && QABS(ev->y() - mouse_down_y) < 3 |
814 | && ev->y() < qApp->desktop()->height()/8) { | 814 | && ev->y() < qApp->desktop()->height()/8) { |
815 | emit setFullScreen(false); | 815 | emit setFullScreen(false); |
816 | } | 816 | } |
817 | 817 | ||
818 | if ( actSel > 1 ) emit endSelectionSignal(preserve_line_breaks); | 818 | if ( actSel > 1 ) emit endSelectionSignal(preserve_line_breaks); |
819 | preserve_line_breaks = TRUE; | 819 | preserve_line_breaks = TRUE; |
820 | actSel = 0; | 820 | actSel = 0; |
821 | 821 | ||
822 | //FIXME: emits a release event even if the mouse is | 822 | //FIXME: emits a release event even if the mouse is |
823 | // outside the range. The procedure used in `mouseMoveEvent' | 823 | // outside the range. The procedure used in `mouseMoveEvent' |
824 | // applies here, too. | 824 | // applies here, too. |
825 | 825 | ||
826 | QPoint tL = contentsRect().topLeft(); | 826 | QPoint tL = contentsRect().topLeft(); |
827 | int tLx = tL.x(); | 827 | int tLx = tL.x(); |
828 | int tLy = tL.y(); | 828 | int tLy = tL.y(); |
829 | 829 | ||
830 | if (!mouse_marks && !(ev->state() & ShiftButton)) | 830 | if (!mouse_marks && !(ev->state() & ShiftButton)) |
831 | emit mouseSignal( 3, // release | 831 | emit mouseSignal( 3, // release |
832 | (ev->x()-tLx-blX)/font_w + 1, | 832 | (ev->x()-tLx-blX)/font_w + 1, |
833 | (ev->y()-tLy-bY)/font_h + 1 ); | 833 | (ev->y()-tLy-bY)/font_h + 1 ); |
834 | releaseMouse(); | 834 | releaseMouse(); |
835 | } | 835 | } |
836 | } | 836 | } |
837 | 837 | ||
838 | void TEWidget::mouseDoubleClickEvent(QMouseEvent* ev) | 838 | void TEWidget::mouseDoubleClickEvent(QMouseEvent* ev) |
839 | { | 839 | { |
840 | if ( ev->button() != LeftButton) return; | 840 | if ( ev->button() != LeftButton) return; |
841 | 841 | ||
842 | QPoint tL = contentsRect().topLeft(); | 842 | QPoint tL = contentsRect().topLeft(); |
843 | int tLx = tL.x(); | 843 | int tLx = tL.x(); |
844 | int tLy = tL.y(); | 844 | int tLy = tL.y(); |
845 | QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); | 845 | QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); |
846 | 846 | ||
847 | // pass on double click as two clicks. | 847 | // pass on double click as two clicks. |
848 | if (!mouse_marks && !(ev->state() & ShiftButton)) | 848 | if (!mouse_marks && !(ev->state() & ShiftButton)) |
849 | { | 849 | { |
850 | emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button | 850 | emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button |
851 | emit mouseSignal( 3, pos.x()+1, pos.y()+1 ); // release | 851 | emit mouseSignal( 3, pos.x()+1, pos.y()+1 ); // release |
852 | emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button | 852 | emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button |
853 | return; | 853 | return; |
854 | } | 854 | } |
855 | 855 | ||
856 | 856 | ||
857 | emit clearSelectionSignal(); | 857 | emit clearSelectionSignal(); |
858 | QPoint bgnSel = pos; | 858 | QPoint bgnSel = pos; |
859 | QPoint endSel = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); | 859 | QPoint endSel = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); |
860 | int i = loc(bgnSel.x(),bgnSel.y()); | 860 | int i = loc(bgnSel.x(),bgnSel.y()); |
861 | iPntSel = bgnSel; | 861 | iPntSel = bgnSel; |
862 | 862 | ||
863 | word_selection_mode = TRUE; | 863 | word_selection_mode = TRUE; |
864 | 864 | ||
865 | // find word boundaries... | 865 | // find word boundaries... |
866 | int selClass = charClass(image[i].c); | 866 | int selClass = charClass(image[i].c); |
867 | { | 867 | { |
868 | // set the start... | 868 | // set the start... |
869 | int x = bgnSel.x(); | 869 | int x = bgnSel.x(); |
870 | while ( x > 0 && charClass(image[i-1].c) == selClass ) | 870 | while ( x > 0 && charClass(image[i-1].c) == selClass ) |
871 | { i--; x--; } | 871 | { i--; x--; } |
872 | bgnSel.setX(x); | 872 | bgnSel.setX(x); |
873 | emit beginSelectionSignal( bgnSel.x(), bgnSel.y() ); | 873 | emit beginSelectionSignal( bgnSel.x(), bgnSel.y() ); |
874 | 874 | ||
875 | // set the end... | 875 | // set the end... |
876 | i = loc( endSel.x(), endSel.y() ); | 876 | i = loc( endSel.x(), endSel.y() ); |
877 | x = endSel.x(); | 877 | x = endSel.x(); |
878 | while( x < columns-1 && charClass(image[i+1].c) == selClass ) | 878 | while( x < columns-1 && charClass(image[i+1].c) == selClass ) |
879 | { i++; x++ ; } | 879 | { i++; x++ ; } |
880 | endSel.setX(x); | 880 | endSel.setX(x); |
881 | actSel = 2; // within selection | 881 | actSel = 2; // within selection |
882 | emit extendSelectionSignal( endSel.x(), endSel.y() ); | 882 | emit extendSelectionSignal( endSel.x(), endSel.y() ); |
883 | emit endSelectionSignal(preserve_line_breaks); | 883 | emit endSelectionSignal(preserve_line_breaks); |
884 | preserve_line_breaks = TRUE; | 884 | preserve_line_breaks = TRUE; |
885 | } | 885 | } |
886 | } | 886 | } |
887 | 887 | ||
888 | void TEWidget::focusInEvent( QFocusEvent * ) | 888 | void TEWidget::focusInEvent( QFocusEvent * ) |
889 | { | 889 | { |
890 | 890 | ||
891 | // do nothing, to prevent repainting | 891 | // do nothing, to prevent repainting |
892 | } | 892 | } |
893 | 893 | ||
894 | 894 | ||
895 | void TEWidget::focusOutEvent( QFocusEvent * ) | 895 | void TEWidget::focusOutEvent( QFocusEvent * ) |
896 | { | 896 | { |
897 | // do nothing, to prevent repainting | 897 | // do nothing, to prevent repainting |
898 | } | 898 | } |
899 | 899 | ||
900 | bool TEWidget::focusNextPrevChild( bool next ) | 900 | bool TEWidget::focusNextPrevChild( bool next ) |
901 | { | 901 | { |
902 | if (next) | 902 | if (next) |
903 | return false; // This disables changing the active part in konqueror | 903 | return false; // This disables changing the active part in konqueror |
904 | // when pressing Tab | 904 | // when pressing Tab |
905 | return QFrame::focusNextPrevChild( next ); | 905 | return QFrame::focusNextPrevChild( next ); |
906 | } | 906 | } |
907 | 907 | ||
908 | 908 | ||
909 | int TEWidget::charClass(char ch) const | 909 | int TEWidget::charClass(char ch) const |
910 | { | 910 | { |
911 | // This might seem like overkill, but imagine if ch was a Unicode | 911 | // This might seem like overkill, but imagine if ch was a Unicode |
912 | // character (Qt 2.0 QChar) - it might then be sensible to separate | 912 | // character (Qt 2.0 QChar) - it might then be sensible to separate |
913 | // the different language ranges, etc. | 913 | // the different language ranges, etc. |
914 | 914 | ||
915 | if ( isspace(ch) ) return ' '; | 915 | if ( isspace(ch) ) return ' '; |
916 | 916 | ||
917 | static const char *word_characters = ":@-./_~"; | 917 | static const char *word_characters = ":@-./_~"; |
918 | if ( isalnum(ch) || strchr(word_characters, ch) ) | 918 | if ( isalnum(ch) || strchr(word_characters, ch) ) |
919 | return 'a'; | 919 | return 'a'; |
920 | 920 | ||
921 | // Everything else is weird | 921 | // Everything else is weird |
922 | return 1; | 922 | return 1; |
923 | } | 923 | } |
924 | 924 | ||
925 | void TEWidget::setMouseMarks(bool on) | 925 | void TEWidget::setMouseMarks(bool on) |
926 | { | 926 | { |
927 | mouse_marks = on; | 927 | mouse_marks = on; |
928 | setCursor( mouse_marks ? ibeamCursor : arrowCursor ); | 928 | setCursor( mouse_marks ? ibeamCursor : arrowCursor ); |
929 | } | 929 | } |
930 | 930 | ||
931 | /* ------------------------------------------------------------------------- */ | 931 | /* ------------------------------------------------------------------------- */ |
932 | /* */ | 932 | /* */ |
933 | /* Clipboard */ | 933 | /* Clipboard */ |
934 | /* */ | 934 | /* */ |
935 | /* ------------------------------------------------------------------------- */ | 935 | /* ------------------------------------------------------------------------- */ |
936 | 936 | ||
937 | #undef KeyPress | 937 | #undef KeyPress |
938 | 938 | ||
939 | void TEWidget::emitSelection() | 939 | void TEWidget::emitSelection() |
940 | // Paste Clipboard by simulating keypress events | 940 | // Paste Clipboard by simulating keypress events |
941 | { | 941 | { |
942 | #ifndef QT_NO_CLIPBOARD | 942 | #ifndef QT_NO_CLIPBOARD |
943 | QString text = QApplication::clipboard()->text(); | 943 | QString text = QApplication::clipboard()->text(); |
944 | //qDebug(text); | 944 | //odebug << text << oendl; |
945 | if ( ! text.isNull()) | 945 | if ( ! text.isNull()) |
946 | { | 946 | { |
947 | text.replace(QRegExp("\n"), "\r"); | 947 | text.replace(QRegExp("\n"), "\r"); |
948 | QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text); | 948 | QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text); |
949 | emit keyPressedSignal(&e); // expose as a big fat keypress event | 949 | emit keyPressedSignal(&e); // expose as a big fat keypress event |
950 | emit clearSelectionSignal(); | 950 | emit clearSelectionSignal(); |
951 | } | 951 | } |
952 | #endif | 952 | #endif |
953 | } | 953 | } |
954 | 954 | ||
955 | void TEWidget::emitText(QString text) | 955 | void TEWidget::emitText(QString text) |
956 | { | 956 | { |
957 | QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text); | 957 | QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text); |
958 | emit keyPressedSignal(&e); // expose as a big fat keypress event | 958 | emit keyPressedSignal(&e); // expose as a big fat keypress event |
959 | } | 959 | } |
960 | 960 | ||
961 | void TEWidget::pasteClipboard( ) | 961 | void TEWidget::pasteClipboard( ) |
962 | { | 962 | { |
963 | emitSelection(); | 963 | emitSelection(); |
964 | } | 964 | } |
965 | 965 | ||
966 | void TEWidget::setSelection(const QString& t) | 966 | void TEWidget::setSelection(const QString& t) |
967 | { | 967 | { |
968 | #ifndef QT_NO_CLIPBOARD | 968 | #ifndef QT_NO_CLIPBOARD |
969 | // Disconnect signal while WE set the clipboard | 969 | // Disconnect signal while WE set the clipboard |
970 | QObject *cb = QApplication::clipboard(); | 970 | QObject *cb = QApplication::clipboard(); |
971 | QObject::disconnect( cb, SIGNAL(dataChanged()), | 971 | QObject::disconnect( cb, SIGNAL(dataChanged()), |
972 | this, SLOT(onClearSelection()) ); | 972 | this, SLOT(onClearSelection()) ); |
973 | 973 | ||
974 | QApplication::clipboard()->setText(t); | 974 | QApplication::clipboard()->setText(t); |
975 | 975 | ||
976 | QObject::connect( cb, SIGNAL(dataChanged()), | 976 | QObject::connect( cb, SIGNAL(dataChanged()), |
977 | this, SLOT(onClearSelection()) ); | 977 | this, SLOT(onClearSelection()) ); |
978 | #endif | 978 | #endif |
979 | } | 979 | } |
980 | 980 | ||
981 | void TEWidget::onClearSelection() | 981 | void TEWidget::onClearSelection() |
982 | { | 982 | { |
983 | emit clearSelectionSignal(); | 983 | emit clearSelectionSignal(); |
984 | } | 984 | } |
985 | 985 | ||
986 | /* ------------------------------------------------------------------------- */ | 986 | /* ------------------------------------------------------------------------- */ |
987 | /* */ | 987 | /* */ |
988 | /* Keyboard */ | 988 | /* Keyboard */ |
989 | /* */ | 989 | /* */ |
990 | /* ------------------------------------------------------------------------- */ | 990 | /* ------------------------------------------------------------------------- */ |
991 | 991 | ||
992 | //FIXME: an `eventFilter' has been installed instead of a `keyPressEvent' | 992 | //FIXME: an `eventFilter' has been installed instead of a `keyPressEvent' |
993 | // due to a bug in `QT' or the ignorance of the author to prevent | 993 | // due to a bug in `QT' or the ignorance of the author to prevent |
994 | // repaint events being emitted to the screen whenever one leaves | 994 | // repaint events being emitted to the screen whenever one leaves |
995 | // or reenters the screen to/from another application. | 995 | // or reenters the screen to/from another application. |
996 | // | 996 | // |
997 | // Troll says one needs to change focusInEvent() and focusOutEvent(), | 997 | // Troll says one needs to change focusInEvent() and focusOutEvent(), |
998 | // which would also let you have an in-focus cursor and an out-focus | 998 | // which would also let you have an in-focus cursor and an out-focus |
999 | // cursor like xterm does. | 999 | // cursor like xterm does. |
1000 | 1000 | ||
1001 | // for the auto-hide cursor feature, I added empty focusInEvent() and | 1001 | // for the auto-hide cursor feature, I added empty focusInEvent() and |
1002 | // focusOutEvent() so that update() isn't called. | 1002 | // focusOutEvent() so that update() isn't called. |
1003 | // For auto-hide, we need to get keypress-events, but we only get them when | 1003 | // For auto-hide, we need to get keypress-events, but we only get them when |
1004 | // we have focus. | 1004 | // we have focus. |
1005 | 1005 | ||
1006 | void TEWidget::doScroll(int lines) | 1006 | void TEWidget::doScroll(int lines) |
1007 | { | 1007 | { |
1008 | scrollbar->setValue(scrollbar->value()+lines); | 1008 | scrollbar->setValue(scrollbar->value()+lines); |
1009 | } | 1009 | } |
1010 | 1010 | ||
1011 | void TEWidget::doHScroll(int lines) { | 1011 | void TEWidget::doHScroll(int lines) { |
1012 | hScrollbar->setValue( hScrollbar->value()+lines); | 1012 | hScrollbar->setValue( hScrollbar->value()+lines); |
1013 | } | 1013 | } |
1014 | 1014 | ||
1015 | bool TEWidget::eventFilter( QObject *obj, QEvent *e ) | 1015 | bool TEWidget::eventFilter( QObject *obj, QEvent *e ) |
1016 | { | 1016 | { |
1017 | if ( (e->type() == QEvent::Accel || | 1017 | if ( (e->type() == QEvent::Accel || |
1018 | e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) { | 1018 | e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) { |
1019 | static_cast<QKeyEvent *>( e )->ignore(); | 1019 | static_cast<QKeyEvent *>( e )->ignore(); |
1020 | return true; | 1020 | return true; |
1021 | } | 1021 | } |
1022 | if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ ) | 1022 | if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ ) |
1023 | return FALSE; // not us | 1023 | return FALSE; // not us |
1024 | if ( e->type() == QEvent::Wheel) { | 1024 | if ( e->type() == QEvent::Wheel) { |
1025 | QApplication::sendEvent(scrollbar, e); | 1025 | QApplication::sendEvent(scrollbar, e); |
1026 | } | 1026 | } |
1027 | 1027 | ||
1028 | #ifdef FAKE_CTRL_AND_ALT | 1028 | #ifdef FAKE_CTRL_AND_ALT |
1029 | static bool control = FALSE; | 1029 | static bool control = FALSE; |
1030 | static bool alt = FALSE; | 1030 | static bool alt = FALSE; |
1031 | // qDebug(" Has a keyboard with no CTRL and ALT keys, but we fake it:"); | 1031 | // odebug << " Has a keyboard with no CTRL and ALT keys, but we fake it:" << oendl; |
1032 | bool dele=FALSE; | 1032 | bool dele=FALSE; |
1033 | if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { | 1033 | if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { |
1034 | QKeyEvent* ke = (QKeyEvent*)e; | 1034 | QKeyEvent* ke = (QKeyEvent*)e; |
1035 | bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat(); | 1035 | bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat(); |
1036 | switch (ke->key()) { | 1036 | switch (ke->key()) { |
1037 | case Key_F9: // let this be "Control" | 1037 | case Key_F9: // let this be "Control" |
1038 | control = keydown; | 1038 | control = keydown; |
1039 | e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state()); | 1039 | e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state()); |
1040 | dele=TRUE; | 1040 | dele=TRUE; |
1041 | break; | 1041 | break; |
1042 | case Key_F13: // let this be "Alt" | 1042 | case Key_F13: // let this be "Alt" |
1043 | alt = keydown; | 1043 | alt = keydown; |
1044 | e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state()); | 1044 | e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state()); |
1045 | dele=TRUE; | 1045 | dele=TRUE; |
1046 | break; | 1046 | break; |
1047 | default: | 1047 | default: |
1048 | if ( control ) { | 1048 | if ( control ) { |
1049 | int a = toupper(ke->ascii())-64; | 1049 | int a = toupper(ke->ascii())-64; |
1050 | if ( a >= 0 && a < ' ' ) { | 1050 | if ( a >= 0 && a < ' ' ) { |
1051 | e = new QKeyEvent(e->type(), ke->key(), | 1051 | e = new QKeyEvent(e->type(), ke->key(), |
1052 | a, ke->state()|ControlButton, QChar(a,0)); | 1052 | a, ke->state()|ControlButton, QChar(a,0)); |
1053 | dele=TRUE; | 1053 | dele=TRUE; |
1054 | } | 1054 | } |
1055 | } | 1055 | } |
1056 | if ( alt ) { | 1056 | if ( alt ) { |
1057 | e = new QKeyEvent(e->type(), ke->key(), | 1057 | e = new QKeyEvent(e->type(), ke->key(), |
1058 | ke->ascii(), ke->state()|AltButton, ke->text()); | 1058 | ke->ascii(), ke->state()|AltButton, ke->text()); |
1059 | dele=TRUE; | 1059 | dele=TRUE; |
1060 | } | 1060 | } |
1061 | } | 1061 | } |
1062 | } | 1062 | } |
1063 | #endif | 1063 | #endif |
1064 | 1064 | ||
1065 | if ( e->type() == QEvent::KeyPress ) { | 1065 | if ( e->type() == QEvent::KeyPress ) { |
1066 | QKeyEvent* ke = (QKeyEvent*)e; | 1066 | QKeyEvent* ke = (QKeyEvent*)e; |
1067 | actSel=0; // Key stroke implies a screen update, so TEWidget won't | 1067 | actSel=0; // Key stroke implies a screen update, so TEWidget won't |
1068 | // know where the current selection is. | 1068 | // know where the current selection is. |
1069 | 1069 | ||
1070 | // qDebug("key pressed is 0x%x, ascii is 0x%x, state %d", ke->key(), ke->ascii(), ke->state()); | 1070 | // odebug << "key pressed is 0x" << ke->key() << ", ascii is 0x" << ke->ascii() << ", state " << ke->state() << "" << oendl; |
1071 | 1071 | ||
1072 | bool special_function = true; | 1072 | bool special_function = true; |
1073 | switch(ke->key()) { | 1073 | switch(ke->key()) { |
1074 | //case 0x201b: // fn-5 | 1074 | //case 0x201b: // fn-5 |
1075 | //case Key_F1: | 1075 | //case Key_F1: |
1076 | // switch sessions (?) | 1076 | // switch sessions (?) |
1077 | // emitText("\\"); // expose (??) | 1077 | // emitText("\\"); // expose (??) |
1078 | // break; | 1078 | // break; |
1079 | 1079 | ||
1080 | case 0x2016: // fn-p | 1080 | case 0x2016: // fn-p |
1081 | case Key_F2: | 1081 | case Key_F2: |
1082 | pasteClipboard(); | 1082 | pasteClipboard(); |
1083 | break; | 1083 | break; |
1084 | 1084 | ||
1085 | case 0x2018: // fn-S | 1085 | case 0x2018: // fn-S |
1086 | case Key_F3: | 1086 | case Key_F3: |
1087 | emit changeSession(1); | 1087 | emit changeSession(1); |
1088 | break; | 1088 | break; |
1089 | 1089 | ||
1090 | case 0x2019: // fn-n | 1090 | case 0x2019: // fn-n |
1091 | emit newSession(); | 1091 | emit newSession(); |
1092 | break; | 1092 | break; |
1093 | 1093 | ||
1094 | case Qt::Key_Tab: | 1094 | case Qt::Key_Tab: |
1095 | if (ke->state() == ControlButton) { | 1095 | if (ke->state() == ControlButton) { |
1096 | emit changeSession(1); | 1096 | emit changeSession(1); |
1097 | } else { | 1097 | } else { |
1098 | special_function = false; | 1098 | special_function = false; |
1099 | } | 1099 | } |
1100 | break; | 1100 | break; |
1101 | 1101 | ||
1102 | #if 0 | 1102 | #if 0 |
1103 | case Qt::Key_Left: | 1103 | case Qt::Key_Left: |
1104 | if (vcolumns == 0) { | 1104 | if (vcolumns == 0) { |
1105 | emit changeSession(-1); | 1105 | emit changeSession(-1); |
1106 | } else { | 1106 | } else { |
1107 | special_function = false; | 1107 | special_function = false; |
1108 | } | 1108 | } |
1109 | break; | 1109 | break; |
1110 | 1110 | ||
1111 | case Qt::Key_Right: | 1111 | case Qt::Key_Right: |
1112 | if (vcolumns == 0) { | 1112 | if (vcolumns == 0) { |
1113 | emit changeSession(1); | 1113 | emit changeSession(1); |
1114 | } else { | 1114 | } else { |
1115 | special_function = false; | 1115 | special_function = false; |
1116 | } | 1116 | } |
1117 | break; | 1117 | break; |
1118 | #endif | 1118 | #endif |
1119 | 1119 | ||
1120 | case 0x201b: // fn-5 | 1120 | case 0x201b: // fn-5 |
1121 | case Key_F4: | 1121 | case Key_F4: |
1122 | emit toggleFullScreen(); | 1122 | emit toggleFullScreen(); |
1123 | break; | 1123 | break; |
1124 | 1124 | ||
1125 | case 0x200f: // fn-1 magnify minus | 1125 | case 0x200f: // fn-1 magnify minus |
1126 | case Key_F5: | 1126 | case Key_F5: |
1127 | emit changeFontSize(-1); | 1127 | emit changeFontSize(-1); |
1128 | break; | 1128 | break; |
1129 | 1129 | ||
1130 | case 0x2010: // fn-2 magnify plus | 1130 | case 0x2010: // fn-2 magnify plus |
1131 | case Key_F6: | 1131 | case Key_F6: |
1132 | emit changeFontSize(1); | 1132 | emit changeFontSize(1); |
1133 | break; | 1133 | break; |
1134 | 1134 | ||
1135 | default: | 1135 | default: |
1136 | special_function = false; | 1136 | special_function = false; |
1137 | } | 1137 | } |
1138 | if (special_function) { | 1138 | if (special_function) { |
1139 | return true; | 1139 | return true; |
1140 | } | 1140 | } |
1141 | // else if( ke->state() == ControlButton && ke->key() == Key_V) { | 1141 | // else if( ke->state() == ControlButton && ke->key() == Key_V) { |
1142 | // pasteClipboard(); | 1142 | // pasteClipboard(); |
1143 | // } | 1143 | // } |
1144 | // else if( ke->state() == ControlButton && ke->key() == Key_C) { | 1144 | // else if( ke->state() == ControlButton && ke->key() == Key_C) { |
1145 | // pasteClipboard(); | 1145 | // pasteClipboard(); |
1146 | // } | 1146 | // } |
1147 | emit keyPressedSignal(ke); // expose | 1147 | emit keyPressedSignal(ke); // expose |
1148 | ke->accept(); | 1148 | ke->accept(); |
1149 | #ifdef FAKE_CTRL_AND_ALT | 1149 | #ifdef FAKE_CTRL_AND_ALT |
1150 | if ( dele ) delete e; | 1150 | if ( dele ) delete e; |
1151 | #endif | 1151 | #endif |
1152 | return true; // stop the event | 1152 | return true; // stop the event |
1153 | } | 1153 | } |
1154 | if ( e->type() == QEvent::Enter ) { | 1154 | if ( e->type() == QEvent::Enter ) { |
1155 | QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()), | 1155 | QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()), |
1156 | this, SLOT(onClearSelection()) ); | 1156 | this, SLOT(onClearSelection()) ); |
1157 | } | 1157 | } |
1158 | if ( e->type() == QEvent::Leave ) { | 1158 | if ( e->type() == QEvent::Leave ) { |
1159 | QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), | 1159 | QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), |
1160 | this, SLOT(onClearSelection()) ); | 1160 | this, SLOT(onClearSelection()) ); |
1161 | } | 1161 | } |
1162 | return QFrame::eventFilter( obj, e ); | 1162 | return QFrame::eventFilter( obj, e ); |
1163 | } | 1163 | } |
1164 | 1164 | ||
1165 | /* ------------------------------------------------------------------------- */ | 1165 | /* ------------------------------------------------------------------------- */ |
1166 | /* */ | 1166 | /* */ |
1167 | /* Frame */ | 1167 | /* Frame */ |
1168 | /* */ | 1168 | /* */ |
1169 | /* ------------------------------------------------------------------------- */ | 1169 | /* ------------------------------------------------------------------------- */ |
1170 | 1170 | ||
1171 | void TEWidget::frameChanged() | 1171 | void TEWidget::frameChanged() |
1172 | { | 1172 | { |
1173 | propagateSize(); | 1173 | propagateSize(); |
1174 | update(); | 1174 | update(); |
1175 | } | 1175 | } |
1176 | /* ------------------------------------------------------------------------- */ | 1176 | /* ------------------------------------------------------------------------- */ |
1177 | /* */ | 1177 | /* */ |
1178 | /* Sound */ | 1178 | /* Sound */ |
1179 | /* */ | 1179 | /* */ |
1180 | /* ------------------------------------------------------------------------- */ | 1180 | /* ------------------------------------------------------------------------- */ |
1181 | 1181 | ||
1182 | void TEWidget::Bell() | 1182 | void TEWidget::Bell() |
1183 | { | 1183 | { |
1184 | //#ifdef QT_QWS_SL5XXX | 1184 | //#ifdef QT_QWS_SL5XXX |
1185 | //# ifndef QT_NO_COP | 1185 | //# ifndef QT_NO_COP |
1186 | if(useBeep) | 1186 | if(useBeep) |
1187 | QCopEnvelope( "QPE/TaskBar", "soundAlarm()" ); | 1187 | QCopEnvelope( "QPE/TaskBar", "soundAlarm()" ); |
1188 | 1188 | ||
1189 | //# endif | 1189 | //# endif |
1190 | //#else | 1190 | //#else |
1191 | //# ifndef QT_NO_SOUND | 1191 | //# ifndef QT_NO_SOUND |
1192 | // QSound::play(Resource::findSound("alarm")); | 1192 | // QSound::play(Resource::findSound("alarm")); |
1193 | //# endif | 1193 | //# endif |
1194 | //#endif | 1194 | //#endif |
1195 | 1195 | ||
1196 | // QApplication::beep(); | 1196 | // QApplication::beep(); |
1197 | } | 1197 | } |
1198 | 1198 | ||
1199 | /* ------------------------------------------------------------------------- */ | 1199 | /* ------------------------------------------------------------------------- */ |
1200 | /* */ | 1200 | /* */ |
1201 | /* Auxiluary */ | 1201 | /* Auxiluary */ |
1202 | /* */ | 1202 | /* */ |
1203 | /* ------------------------------------------------------------------------- */ | 1203 | /* ------------------------------------------------------------------------- */ |
1204 | 1204 | ||
1205 | void TEWidget::clearImage() | 1205 | void TEWidget::clearImage() |
1206 | // initialize the image | 1206 | // initialize the image |
1207 | // for internal use only | 1207 | // for internal use only |
1208 | { | 1208 | { |
1209 | for (int y = 0; y < lines; y++) | 1209 | for (int y = 0; y < lines; y++) |
1210 | for (int x = 0; x < columns; x++) | 1210 | for (int x = 0; x < columns; x++) |
1211 | { | 1211 | { |
1212 | image[loc(x,y)].c = 0xff; //' '; | 1212 | image[loc(x,y)].c = 0xff; //' '; |
1213 | image[loc(x,y)].f = 0xff; //DEFAULT_FORE_COLOR; | 1213 | image[loc(x,y)].f = 0xff; //DEFAULT_FORE_COLOR; |
1214 | image[loc(x,y)].b = 0xff; //DEFAULT_BACK_COLOR; | 1214 | image[loc(x,y)].b = 0xff; //DEFAULT_BACK_COLOR; |
1215 | image[loc(x,y)].r = 0xff; //DEFAULT_RENDITION; | 1215 | image[loc(x,y)].r = 0xff; //DEFAULT_RENDITION; |
1216 | } | 1216 | } |
1217 | } | 1217 | } |
1218 | 1218 | ||
1219 | // Create Image /////////////////////////////////////////////////////// | 1219 | // Create Image /////////////////////////////////////////////////////// |
1220 | 1220 | ||
1221 | void TEWidget::calcGeometry() | 1221 | void TEWidget::calcGeometry() |
1222 | { | 1222 | { |
1223 | int showhscrollbar = 1; | 1223 | int showhscrollbar = 1; |
1224 | int hwidth = 0; | 1224 | int hwidth = 0; |
1225 | int dcolumns = 0; | 1225 | int dcolumns = 0; |
1226 | Config cfg( "Konsole" ); | 1226 | Config cfg( "Konsole" ); |
1227 | cfg.setGroup("ScrollBar"); | 1227 | cfg.setGroup("ScrollBar"); |
1228 | useHorzScroll=cfg.readBoolEntry("HorzScroll",0); | 1228 | useHorzScroll=cfg.readBoolEntry("HorzScroll",0); |
1229 | 1229 | ||
1230 | if(vcolumns == 0) showhscrollbar = 0; | 1230 | if(vcolumns == 0) showhscrollbar = 0; |
1231 | if(showhscrollbar == 1) hwidth = QApplication::style().scrollBarExtent().width(); | 1231 | if(showhscrollbar == 1) hwidth = QApplication::style().scrollBarExtent().width(); |
1232 | 1232 | ||
1233 | scrollbar->resize(QApplication::style().scrollBarExtent().width(), | 1233 | scrollbar->resize(QApplication::style().scrollBarExtent().width(), |
1234 | contentsRect().height() - hwidth); | 1234 | contentsRect().height() - hwidth); |
1235 | 1235 | ||
1236 | switch(scrollLoc) { | 1236 | switch(scrollLoc) { |
1237 | case SCRNONE : | 1237 | case SCRNONE : |
1238 | columns = ( contentsRect().width() - 2 * rimX ) / font_w; | 1238 | columns = ( contentsRect().width() - 2 * rimX ) / font_w; |
1239 | dcolumns = columns; | 1239 | dcolumns = columns; |
1240 | if(vcolumns) columns = vcolumns; | 1240 | if(vcolumns) columns = vcolumns; |
1241 | blX = (contentsRect().width() - (columns*font_w) ) / 2; | 1241 | blX = (contentsRect().width() - (columns*font_w) ) / 2; |
1242 | if(showhscrollbar) | 1242 | if(showhscrollbar) |
1243 | blX = -hposition * font_w; | 1243 | blX = -hposition * font_w; |
1244 | brX = blX; | 1244 | brX = blX; |
1245 | scrollbar->hide(); | 1245 | scrollbar->hide(); |
1246 | break; | 1246 | break; |
1247 | case SCRLEFT : | 1247 | case SCRLEFT : |
1248 | columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; | 1248 | columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; |
1249 | dcolumns = columns; | 1249 | dcolumns = columns; |
1250 | if(vcolumns) columns = vcolumns; | 1250 | if(vcolumns) columns = vcolumns; |
1251 | brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; | 1251 | brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; |
1252 | if(showhscrollbar) | 1252 | if(showhscrollbar) |
1253 | brX = -hposition * font_w; | 1253 | brX = -hposition * font_w; |
1254 | blX = brX + scrollbar->width(); | 1254 | blX = brX + scrollbar->width(); |
1255 | scrollbar->move(contentsRect().topLeft()); | 1255 | scrollbar->move(contentsRect().topLeft()); |
1256 | scrollbar->show(); | 1256 | scrollbar->show(); |
1257 | break; | 1257 | break; |
1258 | case SCRRIGHT: | 1258 | case SCRRIGHT: |
1259 | columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; | 1259 | columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; |
1260 | dcolumns = columns; | 1260 | dcolumns = columns; |
1261 | if(vcolumns) columns = vcolumns; | 1261 | if(vcolumns) columns = vcolumns; |
1262 | blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; | 1262 | blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; |
1263 | if(showhscrollbar) | 1263 | if(showhscrollbar) |
1264 | blX = -hposition * font_w; | 1264 | blX = -hposition * font_w; |
1265 | brX = blX; | 1265 | brX = blX; |
1266 | scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0)); | 1266 | scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0)); |
1267 | scrollbar->show(); | 1267 | scrollbar->show(); |
1268 | break; | 1268 | break; |
1269 | } | 1269 | } |
1270 | //FIXME: support 'rounding' styles | 1270 | //FIXME: support 'rounding' styles |
1271 | lines = ( contentsRect().height() - 2 * rimY ) / font_h; | 1271 | lines = ( contentsRect().height() - 2 * rimY ) / font_h; |
1272 | bY = (contentsRect().height() - (lines *font_h)) / 2; | 1272 | bY = (contentsRect().height() - (lines *font_h)) / 2; |
1273 | 1273 | ||
1274 | if(showhscrollbar == 1) { | 1274 | if(showhscrollbar == 1) { |
1275 | hScrollbar->resize(contentsRect().width() - hwidth, hwidth); | 1275 | hScrollbar->resize(contentsRect().width() - hwidth, hwidth); |
1276 | hScrollbar->setRange(0, vcolumns - dcolumns); | 1276 | hScrollbar->setRange(0, vcolumns - dcolumns); |
1277 | 1277 | ||
1278 | QPoint p = contentsRect().bottomLeft(); | 1278 | QPoint p = contentsRect().bottomLeft(); |
1279 | if(scrollLoc == SCRLEFT) | 1279 | if(scrollLoc == SCRLEFT) |
1280 | hScrollbar->move(QPoint(p.x()+hwidth, p.y() - hwidth)); | 1280 | hScrollbar->move(QPoint(p.x()+hwidth, p.y() - hwidth)); |
1281 | else | 1281 | else |
1282 | hScrollbar->move(QPoint(p.x(), p.y() - hwidth)); | 1282 | hScrollbar->move(QPoint(p.x(), p.y() - hwidth)); |
1283 | 1283 | ||
1284 | hScrollbar->show(); | 1284 | hScrollbar->show(); |
1285 | } | 1285 | } |
1286 | else hScrollbar->hide(); | 1286 | else hScrollbar->hide(); |
1287 | 1287 | ||
1288 | if(showhscrollbar == 1) { | 1288 | if(showhscrollbar == 1) { |
1289 | lines = lines - (hwidth / font_h) - 1; | 1289 | lines = lines - (hwidth / font_h) - 1; |
1290 | if(lines < 1) lines = 1; | 1290 | if(lines < 1) lines = 1; |
1291 | } | 1291 | } |
1292 | //FIXME: support 'rounding' styles | 1292 | //FIXME: support 'rounding' styles |
1293 | } | 1293 | } |
1294 | 1294 | ||
1295 | void TEWidget::makeImage() | 1295 | void TEWidget::makeImage() |
1296 | //FIXME: rename 'calcGeometry? | 1296 | //FIXME: rename 'calcGeometry? |
1297 | { | 1297 | { |
1298 | calcGeometry(); | 1298 | calcGeometry(); |
1299 | image = (ca*) malloc(lines*columns*sizeof(ca)); | 1299 | image = (ca*) malloc(lines*columns*sizeof(ca)); |
1300 | clearImage(); | 1300 | clearImage(); |
1301 | } | 1301 | } |
1302 | 1302 | ||
1303 | // calculate the needed size | 1303 | // calculate the needed size |
1304 | QSize TEWidget::calcSize(int cols, int lins) const | 1304 | QSize TEWidget::calcSize(int cols, int lins) const |
1305 | { | 1305 | { |
1306 | int frw = width() - contentsRect().width(); | 1306 | int frw = width() - contentsRect().width(); |
1307 | int frh = height() - contentsRect().height(); | 1307 | int frh = height() - contentsRect().height(); |
1308 | int scw = (scrollLoc==SCRNONE?0:scrollbar->width()); | 1308 | int scw = (scrollLoc==SCRNONE?0:scrollbar->width()); |
1309 | return QSize( font_w*cols + 2*rimX + frw + scw, font_h*lins + 2*rimY + frh ); | 1309 | return QSize( font_w*cols + 2*rimX + frw + scw, font_h*lins + 2*rimY + frh ); |
1310 | } | 1310 | } |
1311 | 1311 | ||
1312 | QSize TEWidget::sizeHint() const | 1312 | QSize TEWidget::sizeHint() const |
1313 | { | 1313 | { |
1314 | return size(); | 1314 | return size(); |
1315 | } | 1315 | } |
1316 | 1316 | ||
1317 | void TEWidget::styleChange(QStyle &) | 1317 | void TEWidget::styleChange(QStyle &) |
1318 | { | 1318 | { |
1319 | propagateSize(); | 1319 | propagateSize(); |
1320 | } | 1320 | } |
1321 | 1321 | ||
1322 | #ifndef QT_NO_DRAGANDDROP | 1322 | #ifndef QT_NO_DRAGANDDROP |
1323 | 1323 | ||
1324 | /* --------------------------------------------------------------------- */ | 1324 | /* --------------------------------------------------------------------- */ |
1325 | /* */ | 1325 | /* */ |
1326 | /* Drag & Drop */ | 1326 | /* Drag & Drop */ |
1327 | /* */ | 1327 | /* */ |
1328 | /* --------------------------------------------------------------------- */ | 1328 | /* --------------------------------------------------------------------- */ |
1329 | 1329 | ||
1330 | 1330 | ||
1331 | void TEWidget::dragEnterEvent(QDragEnterEvent* e) | 1331 | void TEWidget::dragEnterEvent(QDragEnterEvent* e) |
1332 | { | 1332 | { |
1333 | e->accept(QTextDrag::canDecode(e) || | 1333 | e->accept(QTextDrag::canDecode(e) || |
1334 | QUriDrag::canDecode(e)); | 1334 | QUriDrag::canDecode(e)); |
1335 | } | 1335 | } |
1336 | 1336 | ||
1337 | void TEWidget::dropEvent(QDropEvent* event) | 1337 | void TEWidget::dropEvent(QDropEvent* event) |
1338 | { | 1338 | { |
1339 | // The current behaviour when url(s) are dropped is | 1339 | // The current behaviour when url(s) are dropped is |
1340 | // * if there is only ONE url and if it's a LOCAL one, ask for paste or cd | 1340 | // * if there is only ONE url and if it's a LOCAL one, ask for paste or cd |
1341 | // * in all other cases, just paste | 1341 | // * in all other cases, just paste |
1342 | // (for non-local ones, or for a list of URLs, 'cd' is nonsense) | 1342 | // (for non-local ones, or for a list of URLs, 'cd' is nonsense) |
1343 | QStrList strlist; | 1343 | QStrList strlist; |
1344 | int file_count = 0; | 1344 | int file_count = 0; |
1345 | dropText = ""; | 1345 | dropText = ""; |
1346 | bool bPopup = true; | 1346 | bool bPopup = true; |
1347 | 1347 | ||
1348 | if(QUriDrag::decode(event, strlist)) { | 1348 | if(QUriDrag::decode(event, strlist)) { |
1349 | if (strlist.count()) { | 1349 | if (strlist.count()) { |
1350 | for(const char* p = strlist.first(); p; p = strlist.next()) { | 1350 | for(const char* p = strlist.first(); p; p = strlist.next()) { |
1351 | if(file_count++ > 0) { | 1351 | if(file_count++ > 0) { |
1352 | dropText += " "; | 1352 | dropText += " "; |
1353 | bPopup = false; // more than one file, don't popup | 1353 | bPopup = false; // more than one file, don't popup |
1354 | } | 1354 | } |
1355 | 1355 | ||
1356 | /* | 1356 | /* |
1357 | KURL url(p); | 1357 | KURL url(p); |
1358 | if (url.isLocalFile()) { | 1358 | if (url.isLocalFile()) { |
1359 | dropText += url.path(); // local URL : remove protocol | 1359 | dropText += url.path(); // local URL : remove protocol |
1360 | } | 1360 | } |
1361 | else { | 1361 | else { |
1362 | dropText += url.prettyURL(); | 1362 | dropText += url.prettyURL(); |
1363 | bPopup = false; // a non-local file, don't popup | 1363 | bPopup = false; // a non-local file, don't popup |
1364 | } | 1364 | } |
1365 | */ | 1365 | */ |
1366 | 1366 | ||
1367 | } | 1367 | } |
1368 | 1368 | ||
1369 | if (bPopup) | 1369 | if (bPopup) |
1370 | // m_drop->popup(pos() + event->pos()); | 1370 | // m_drop->popup(pos() + event->pos()); |
1371 | m_drop->popup(mapToGlobal(event->pos())); | 1371 | m_drop->popup(mapToGlobal(event->pos())); |
1372 | else | 1372 | else |
1373 | { | 1373 | { |
1374 | if (currentSession) { | 1374 | if (currentSession) { |
1375 | currentSession->getEmulation()->sendString(dropText.local8Bit()); | 1375 | currentSession->getEmulation()->sendString(dropText.local8Bit()); |
1376 | } | 1376 | } |
1377 | // kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; | 1377 | // kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; |
1378 | } | 1378 | } |
1379 | } | 1379 | } |
1380 | } | 1380 | } |
1381 | else if(QTextDrag::decode(event, dropText)) { | 1381 | else if(QTextDrag::decode(event, dropText)) { |
1382 | // kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; | 1382 | // kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; |
1383 | if (currentSession) { | 1383 | if (currentSession) { |
1384 | currentSession->getEmulation()->sendString(dropText.local8Bit()); | 1384 | currentSession->getEmulation()->sendString(dropText.local8Bit()); |
1385 | } | 1385 | } |
1386 | // Paste it | 1386 | // Paste it |
1387 | } | 1387 | } |
1388 | } | 1388 | } |
1389 | #endif | 1389 | #endif |
1390 | 1390 | ||
1391 | 1391 | ||
1392 | void TEWidget::drop_menu_activated(int /*item*/) | 1392 | void TEWidget::drop_menu_activated(int /*item*/) |
1393 | { | 1393 | { |
1394 | #ifndef QT_NO_DRAGANDDROP | 1394 | #ifndef QT_NO_DRAGANDDROP |
1395 | switch (item) | 1395 | switch (item) |
1396 | { | 1396 | { |
1397 | case 0: // paste | 1397 | case 0: // paste |
1398 | currentSession->getEmulation()->sendString(dropText.local8Bit()); | 1398 | currentSession->getEmulation()->sendString(dropText.local8Bit()); |
1399 | // KWM::activate((Window)this->winId()); | 1399 | // KWM::activate((Window)this->winId()); |
1400 | break; | 1400 | break; |
1401 | case 1: // cd ... | 1401 | case 1: // cd ... |
1402 | currentSession->getEmulation()->sendString("cd "); | 1402 | currentSession->getEmulation()->sendString("cd "); |
1403 | struct stat statbuf; | 1403 | struct stat statbuf; |
1404 | if ( ::stat( QFile::encodeName( dropText ), &statbuf ) == 0 ) | 1404 | if ( ::stat( QFile::encodeName( dropText ), &statbuf ) == 0 ) |
1405 | { | 1405 | { |
1406 | if ( !S_ISDIR(statbuf.st_mode) ) | 1406 | if ( !S_ISDIR(statbuf.st_mode) ) |
1407 | { | 1407 | { |
1408 | /* | 1408 | /* |
1409 | KURL url; | 1409 | KURL url; |
1410 | url.setPath( dropText ); | 1410 | url.setPath( dropText ); |
1411 | dropText = url.directory( true, false ); // remove filename | 1411 | dropText = url.directory( true, false ); // remove filename |
1412 | */ | 1412 | */ |
1413 | } | 1413 | } |
1414 | } | 1414 | } |
1415 | dropText.replace(QRegExp(" "), "\\ "); // escape spaces | 1415 | dropText.replace(QRegExp(" "), "\\ "); // escape spaces |
1416 | currentSession->getEmulation()->sendString(dropText.local8Bit()); | 1416 | currentSession->getEmulation()->sendString(dropText.local8Bit()); |
1417 | currentSession->getEmulation()->sendString("\n"); | 1417 | currentSession->getEmulation()->sendString("\n"); |
1418 | // KWM::activate((Window)this->winId()); | 1418 | // KWM::activate((Window)this->winId()); |
1419 | break; | 1419 | break; |
1420 | } | 1420 | } |
1421 | #endif | 1421 | #endif |
1422 | } | 1422 | } |
1423 | 1423 | ||
1424 | void TEWidget::setWrapAt(int columns) | 1424 | void TEWidget::setWrapAt(int columns) |
1425 | { | 1425 | { |
1426 | vcolumns = columns; | 1426 | vcolumns = columns; |
1427 | propagateSize(); | 1427 | propagateSize(); |
1428 | update(); | 1428 | update(); |
1429 | } | 1429 | } |
diff --git a/core/apps/embeddedkonsole/commandeditdialog.cpp b/core/apps/embeddedkonsole/commandeditdialog.cpp index 6587b26..697bf72 100644 --- a/core/apps/embeddedkonsole/commandeditdialog.cpp +++ b/core/apps/embeddedkonsole/commandeditdialog.cpp | |||
@@ -1,191 +1,191 @@ | |||
1 | //comandeditdialog.cpp | 1 | //comandeditdialog.cpp |
2 | 2 | ||
3 | #include "commandeditdialog.h" | 3 | #include "commandeditdialog.h" |
4 | #include "playlistselection.h" | 4 | #include "playlistselection.h" |
5 | #include <qpe/config.h> | 5 | #include <qpe/config.h> |
6 | #include <qpe/resource.h> | 6 | #include <qpe/resource.h> |
7 | #include <qtoolbutton.h> | 7 | #include <qtoolbutton.h> |
8 | #include <qlineedit.h> | 8 | #include <qlineedit.h> |
9 | #include <qheader.h> | 9 | #include <qheader.h> |
10 | #include <qlabel.h> | 10 | #include <qlabel.h> |
11 | #include "smallcommandeditdialogbase.h" | 11 | #include "smallcommandeditdialogbase.h" |
12 | 12 | ||
13 | CommandEditDialog::CommandEditDialog(QWidget *parent, const char* name, WFlags fl ) | 13 | CommandEditDialog::CommandEditDialog(QWidget *parent, const char* name, WFlags fl ) |
14 | : CommandEditDialogBase(parent, name, TRUE, fl) | 14 | : CommandEditDialogBase(parent, name, TRUE, fl) |
15 | 15 | ||
16 | { | 16 | { |
17 | m_SuggestedCommandList->addColumn( tr("Command Selection") ); | 17 | m_SuggestedCommandList->addColumn( tr("Command Selection") ); |
18 | m_SuggestedCommandList->header()->hide(); | 18 | m_SuggestedCommandList->header()->hide(); |
19 | m_SuggestedCommandList->setSorting(-1,FALSE); | 19 | m_SuggestedCommandList->setSorting(-1,FALSE); |
20 | m_SuggestedCommandList->clearSelection(); | 20 | m_SuggestedCommandList->clearSelection(); |
21 | m_SuggestedCommandList->setSorting(0,TRUE); | 21 | m_SuggestedCommandList->setSorting(0,TRUE); |
22 | QListViewItem *item; | 22 | QListViewItem *item; |
23 | item = new QListViewItem( m_SuggestedCommandList,"export "); | 23 | item = new QListViewItem( m_SuggestedCommandList,"export "); |
24 | item = new QListViewItem( m_SuggestedCommandList,"ifconfig "); | 24 | item = new QListViewItem( m_SuggestedCommandList,"ifconfig "); |
25 | item = new QListViewItem( m_SuggestedCommandList,"ipkg "); | 25 | item = new QListViewItem( m_SuggestedCommandList,"ipkg "); |
26 | item = new QListViewItem( m_SuggestedCommandList,"gzip "); | 26 | item = new QListViewItem( m_SuggestedCommandList,"gzip "); |
27 | item = new QListViewItem( m_SuggestedCommandList,"gunzip "); | 27 | item = new QListViewItem( m_SuggestedCommandList,"gunzip "); |
28 | item = new QListViewItem( m_SuggestedCommandList,"chgrp "); | 28 | item = new QListViewItem( m_SuggestedCommandList,"chgrp "); |
29 | item = new QListViewItem( m_SuggestedCommandList,"chown "); | 29 | item = new QListViewItem( m_SuggestedCommandList,"chown "); |
30 | item = new QListViewItem( m_SuggestedCommandList,"date "); | 30 | item = new QListViewItem( m_SuggestedCommandList,"date "); |
31 | item = new QListViewItem( m_SuggestedCommandList,"dd "); | 31 | item = new QListViewItem( m_SuggestedCommandList,"dd "); |
32 | item = new QListViewItem( m_SuggestedCommandList,"dmesg "); | 32 | item = new QListViewItem( m_SuggestedCommandList,"dmesg "); |
33 | item = new QListViewItem( m_SuggestedCommandList,"fuser "); | 33 | item = new QListViewItem( m_SuggestedCommandList,"fuser "); |
34 | item = new QListViewItem( m_SuggestedCommandList,"hostname "); | 34 | item = new QListViewItem( m_SuggestedCommandList,"hostname "); |
35 | item = new QListViewItem( m_SuggestedCommandList,"kill "); | 35 | item = new QListViewItem( m_SuggestedCommandList,"kill "); |
36 | item = new QListViewItem( m_SuggestedCommandList,"killall "); | 36 | item = new QListViewItem( m_SuggestedCommandList,"killall "); |
37 | item = new QListViewItem( m_SuggestedCommandList,"ln "); | 37 | item = new QListViewItem( m_SuggestedCommandList,"ln "); |
38 | item = new QListViewItem( m_SuggestedCommandList,"ln -s "); | 38 | item = new QListViewItem( m_SuggestedCommandList,"ln -s "); |
39 | item = new QListViewItem( m_SuggestedCommandList,"lsmod"); | 39 | item = new QListViewItem( m_SuggestedCommandList,"lsmod"); |
40 | item = new QListViewItem( m_SuggestedCommandList,"depmod -a"); | 40 | item = new QListViewItem( m_SuggestedCommandList,"depmod -a"); |
41 | item = new QListViewItem( m_SuggestedCommandList,"modprobe "); | 41 | item = new QListViewItem( m_SuggestedCommandList,"modprobe "); |
42 | item = new QListViewItem( m_SuggestedCommandList,"mount "); | 42 | item = new QListViewItem( m_SuggestedCommandList,"mount "); |
43 | item = new QListViewItem( m_SuggestedCommandList,"more "); | 43 | item = new QListViewItem( m_SuggestedCommandList,"more "); |
44 | item = new QListViewItem( m_SuggestedCommandList,"sort "); | 44 | item = new QListViewItem( m_SuggestedCommandList,"sort "); |
45 | item = new QListViewItem( m_SuggestedCommandList,"touch "); | 45 | item = new QListViewItem( m_SuggestedCommandList,"touch "); |
46 | item = new QListViewItem( m_SuggestedCommandList,"umount "); | 46 | item = new QListViewItem( m_SuggestedCommandList,"umount "); |
47 | item = new QListViewItem( m_SuggestedCommandList,"mknod "); | 47 | item = new QListViewItem( m_SuggestedCommandList,"mknod "); |
48 | item = new QListViewItem( m_SuggestedCommandList,"netstat "); | 48 | item = new QListViewItem( m_SuggestedCommandList,"netstat "); |
49 | item = new QListViewItem( m_SuggestedCommandList,"route "); | 49 | item = new QListViewItem( m_SuggestedCommandList,"route "); |
50 | item = new QListViewItem( m_SuggestedCommandList,"cardctl eject "); | 50 | item = new QListViewItem( m_SuggestedCommandList,"cardctl eject "); |
51 | m_SuggestedCommandList->setSelected(m_SuggestedCommandList->firstChild(),TRUE); | 51 | m_SuggestedCommandList->setSelected(m_SuggestedCommandList->firstChild(),TRUE); |
52 | m_SuggestedCommandList->sort(); | 52 | m_SuggestedCommandList->sort(); |
53 | 53 | ||
54 | connect( m_SuggestedCommandList, SIGNAL( clicked(QListViewItem*) ), m_PlayListSelection, SLOT( addToSelection(QListViewItem*) ) ); | 54 | connect( m_SuggestedCommandList, SIGNAL( clicked(QListViewItem*) ), m_PlayListSelection, SLOT( addToSelection(QListViewItem*) ) ); |
55 | 55 | ||
56 | 56 | ||
57 | 57 | ||
58 | ToolButton1->setTextLabel("new"); | 58 | ToolButton1->setTextLabel("new"); |
59 | ToolButton1->setPixmap(Resource::loadPixmap("new")); | 59 | ToolButton1->setPixmap(Resource::loadPixmap("new")); |
60 | ToolButton1->setAutoRaise(TRUE); | 60 | ToolButton1->setAutoRaise(TRUE); |
61 | ToolButton1->setFocusPolicy(QWidget::NoFocus); | 61 | ToolButton1->setFocusPolicy(QWidget::NoFocus); |
62 | connect(ToolButton1,SIGNAL(clicked()),this,SLOT(showAddDialog())); | 62 | connect(ToolButton1,SIGNAL(clicked()),this,SLOT(showAddDialog())); |
63 | 63 | ||
64 | ToolButton2->setTextLabel("edit"); | 64 | ToolButton2->setTextLabel("edit"); |
65 | ToolButton2->setPixmap(Resource::loadPixmap("edit")); | 65 | ToolButton2->setPixmap(Resource::loadPixmap("edit")); |
66 | ToolButton2->setAutoRaise(TRUE); | 66 | ToolButton2->setAutoRaise(TRUE); |
67 | ToolButton2->setFocusPolicy(QWidget::NoFocus); | 67 | ToolButton2->setFocusPolicy(QWidget::NoFocus); |
68 | connect(ToolButton2,SIGNAL(clicked()),this,SLOT(showEditDialog())); | 68 | connect(ToolButton2,SIGNAL(clicked()),this,SLOT(showEditDialog())); |
69 | 69 | ||
70 | ToolButton3->setTextLabel("delete"); | 70 | ToolButton3->setTextLabel("delete"); |
71 | ToolButton3->setPixmap(Resource::loadPixmap("editdelete")); | 71 | ToolButton3->setPixmap(Resource::loadPixmap("editdelete")); |
72 | ToolButton3->setAutoRaise(TRUE); | 72 | ToolButton3->setAutoRaise(TRUE); |
73 | ToolButton3->setFocusPolicy(QWidget::NoFocus); | 73 | ToolButton3->setFocusPolicy(QWidget::NoFocus); |
74 | connect(ToolButton3,SIGNAL(clicked()),m_PlayListSelection,SLOT(removeSelected())); | 74 | connect(ToolButton3,SIGNAL(clicked()),m_PlayListSelection,SLOT(removeSelected())); |
75 | 75 | ||
76 | ToolButton4->setTextLabel("up"); | 76 | ToolButton4->setTextLabel("up"); |
77 | ToolButton4->setPixmap(Resource::loadPixmap("up")); | 77 | ToolButton4->setPixmap(Resource::loadPixmap("up")); |
78 | ToolButton4->setAutoRaise(TRUE); | 78 | ToolButton4->setAutoRaise(TRUE); |
79 | ToolButton4->setFocusPolicy(QWidget::NoFocus); | 79 | ToolButton4->setFocusPolicy(QWidget::NoFocus); |
80 | connect(ToolButton4,SIGNAL(clicked()),m_PlayListSelection,SLOT(moveSelectedUp())); | 80 | connect(ToolButton4,SIGNAL(clicked()),m_PlayListSelection,SLOT(moveSelectedUp())); |
81 | 81 | ||
82 | ToolButton5->setTextLabel("down"); | 82 | ToolButton5->setTextLabel("down"); |
83 | ToolButton5->setPixmap(Resource::loadPixmap("down")); | 83 | ToolButton5->setPixmap(Resource::loadPixmap("down")); |
84 | ToolButton5->setAutoRaise(TRUE); | 84 | ToolButton5->setAutoRaise(TRUE); |
85 | ToolButton5->setFocusPolicy(QWidget::NoFocus); | 85 | ToolButton5->setFocusPolicy(QWidget::NoFocus); |
86 | 86 | ||
87 | connect(ToolButton5,SIGNAL(clicked()),m_PlayListSelection,SLOT(moveSelectedDown())); | 87 | connect(ToolButton5,SIGNAL(clicked()),m_PlayListSelection,SLOT(moveSelectedDown())); |
88 | 88 | ||
89 | 89 | ||
90 | 90 | ||
91 | 91 | ||
92 | QListViewItem *current = m_SuggestedCommandList->selectedItem(); | 92 | QListViewItem *current = m_SuggestedCommandList->selectedItem(); |
93 | if ( current ) | 93 | if ( current ) |
94 | item->moveItem( current ); | 94 | item->moveItem( current ); |
95 | m_SuggestedCommandList->setSelected( item, TRUE ); | 95 | m_SuggestedCommandList->setSelected( item, TRUE ); |
96 | m_SuggestedCommandList->ensureItemVisible( m_SuggestedCommandList->selectedItem() ); | 96 | m_SuggestedCommandList->ensureItemVisible( m_SuggestedCommandList->selectedItem() ); |
97 | Config cfg( "Konsole" ); | 97 | Config cfg( "Konsole" ); |
98 | cfg.setGroup("Commands"); | 98 | cfg.setGroup("Commands"); |
99 | if (cfg.readEntry("Commands Set","FALSE") == "TRUE") { | 99 | if (cfg.readEntry("Commands Set","FALSE") == "TRUE") { |
100 | for (int i = 0; i < 100; i++) { | 100 | for (int i = 0; i < 100; i++) { |
101 | QString tmp; | 101 | QString tmp; |
102 | tmp = cfg.readEntry( QString::number(i),""); | 102 | tmp = cfg.readEntry( QString::number(i),""); |
103 | if (!tmp.isEmpty()) | 103 | if (!tmp.isEmpty()) |
104 | m_PlayListSelection->addStringToSelection(tmp); | 104 | m_PlayListSelection->addStringToSelection(tmp); |
105 | } | 105 | } |
106 | } else { | 106 | } else { |
107 | 107 | ||
108 | m_PlayListSelection->addStringToSelection("ls "); | 108 | m_PlayListSelection->addStringToSelection("ls "); |
109 | m_PlayListSelection->addStringToSelection("cardctl eject"); | 109 | m_PlayListSelection->addStringToSelection("cardctl eject"); |
110 | m_PlayListSelection->addStringToSelection("cat "); | 110 | m_PlayListSelection->addStringToSelection("cat "); |
111 | m_PlayListSelection->addStringToSelection("cd "); | 111 | m_PlayListSelection->addStringToSelection("cd "); |
112 | m_PlayListSelection->addStringToSelection("chmod "); | 112 | m_PlayListSelection->addStringToSelection("chmod "); |
113 | m_PlayListSelection->addStringToSelection("cp "); | 113 | m_PlayListSelection->addStringToSelection("cp "); |
114 | m_PlayListSelection->addStringToSelection("dc "); | 114 | m_PlayListSelection->addStringToSelection("dc "); |
115 | m_PlayListSelection->addStringToSelection("df "); | 115 | m_PlayListSelection->addStringToSelection("df "); |
116 | m_PlayListSelection->addStringToSelection("dmesg"); | 116 | m_PlayListSelection->addStringToSelection("dmesg"); |
117 | m_PlayListSelection->addStringToSelection("echo "); | 117 | m_PlayListSelection->addStringToSelection("echo "); |
118 | m_PlayListSelection->addStringToSelection("env"); | 118 | m_PlayListSelection->addStringToSelection("env"); |
119 | m_PlayListSelection->addStringToSelection("find "); | 119 | m_PlayListSelection->addStringToSelection("find "); |
120 | m_PlayListSelection->addStringToSelection("free"); | 120 | m_PlayListSelection->addStringToSelection("free"); |
121 | m_PlayListSelection->addStringToSelection("grep "); | 121 | m_PlayListSelection->addStringToSelection("grep "); |
122 | m_PlayListSelection->addStringToSelection("ifconfig "); | 122 | m_PlayListSelection->addStringToSelection("ifconfig "); |
123 | m_PlayListSelection->addStringToSelection("ipkg "); | 123 | m_PlayListSelection->addStringToSelection("ipkg "); |
124 | m_PlayListSelection->addStringToSelection("mkdir "); | 124 | m_PlayListSelection->addStringToSelection("mkdir "); |
125 | m_PlayListSelection->addStringToSelection("mv "); | 125 | m_PlayListSelection->addStringToSelection("mv "); |
126 | m_PlayListSelection->addStringToSelection("nc localhost 7776"); | 126 | m_PlayListSelection->addStringToSelection("nc localhost 7776"); |
127 | m_PlayListSelection->addStringToSelection("nc localhost 7777"); | 127 | m_PlayListSelection->addStringToSelection("nc localhost 7777"); |
128 | m_PlayListSelection->addStringToSelection("nslookup "); | 128 | m_PlayListSelection->addStringToSelection("nslookup "); |
129 | m_PlayListSelection->addStringToSelection("ping "); | 129 | m_PlayListSelection->addStringToSelection("ping "); |
130 | m_PlayListSelection->addStringToSelection("ps aux"); | 130 | m_PlayListSelection->addStringToSelection("ps aux"); |
131 | m_PlayListSelection->addStringToSelection("pwd "); | 131 | m_PlayListSelection->addStringToSelection("pwd "); |
132 | m_PlayListSelection->addStringToSelection("rm "); | 132 | m_PlayListSelection->addStringToSelection("rm "); |
133 | m_PlayListSelection->addStringToSelection("rmdir "); | 133 | m_PlayListSelection->addStringToSelection("rmdir "); |
134 | m_PlayListSelection->addStringToSelection("route "); | 134 | m_PlayListSelection->addStringToSelection("route "); |
135 | m_PlayListSelection->addStringToSelection("set "); | 135 | m_PlayListSelection->addStringToSelection("set "); |
136 | m_PlayListSelection->addStringToSelection("traceroute"); | 136 | m_PlayListSelection->addStringToSelection("traceroute"); |
137 | 137 | ||
138 | } | 138 | } |
139 | } | 139 | } |
140 | CommandEditDialog::~CommandEditDialog() | 140 | CommandEditDialog::~CommandEditDialog() |
141 | { | 141 | { |
142 | } | 142 | } |
143 | 143 | ||
144 | void CommandEditDialog::accept() | 144 | void CommandEditDialog::accept() |
145 | { | 145 | { |
146 | int i = 0; | 146 | int i = 0; |
147 | Config *cfg = new Config("Konsole"); | 147 | Config *cfg = new Config("Konsole"); |
148 | cfg->setGroup("Commands"); | 148 | cfg->setGroup("Commands"); |
149 | cfg->clearGroup(); | 149 | cfg->clearGroup(); |
150 | 150 | ||
151 | QListViewItemIterator it( m_PlayListSelection ); | 151 | QListViewItemIterator it( m_PlayListSelection ); |
152 | 152 | ||
153 | for ( ; it.current(); ++it ) { | 153 | for ( ; it.current(); ++it ) { |
154 | // qDebug(it.current()->text(0)); | 154 | // odebug << it.current()->text(0) << oendl; |
155 | cfg->writeEntry(QString::number(i),it.current()->text(0)); | 155 | cfg->writeEntry(QString::number(i),it.current()->text(0)); |
156 | i++; | 156 | i++; |
157 | 157 | ||
158 | } | 158 | } |
159 | cfg->writeEntry("Commands Set","TRUE"); | 159 | cfg->writeEntry("Commands Set","TRUE"); |
160 | // qDebug("CommandEditDialog::accept() - written"); | 160 | // odebug << "CommandEditDialog::accept() - written" << oendl; |
161 | delete cfg; | 161 | delete cfg; |
162 | emit commandsEdited(); | 162 | emit commandsEdited(); |
163 | close(); | 163 | close(); |
164 | 164 | ||
165 | 165 | ||
166 | 166 | ||
167 | 167 | ||
168 | 168 | ||
169 | } | 169 | } |
170 | 170 | ||
171 | void CommandEditDialog::showEditDialog() | 171 | void CommandEditDialog::showEditDialog() |
172 | { | 172 | { |
173 | editCommandBase *d = new editCommandBase(this,"smalleditdialog", TRUE); | 173 | editCommandBase *d = new editCommandBase(this,"smalleditdialog", TRUE); |
174 | d->setCaption("Edit command"); | 174 | d->setCaption("Edit command"); |
175 | d->TextLabel->setText("Edit command:"); | 175 | d->TextLabel->setText("Edit command:"); |
176 | d->commandEdit->setText(m_PlayListSelection->currentItem()->text(0)); | 176 | d->commandEdit->setText(m_PlayListSelection->currentItem()->text(0)); |
177 | int i = d->exec(); | 177 | int i = d->exec(); |
178 | if ((i==1) && (!(d->commandEdit->text()).isEmpty())) | 178 | if ((i==1) && (!(d->commandEdit->text()).isEmpty())) |
179 | m_PlayListSelection->currentItem()->setText(0,(d->commandEdit->text())); | 179 | m_PlayListSelection->currentItem()->setText(0,(d->commandEdit->text())); |
180 | } | 180 | } |
181 | 181 | ||
182 | void CommandEditDialog::showAddDialog() | 182 | void CommandEditDialog::showAddDialog() |
183 | { | 183 | { |
184 | 184 | ||
185 | editCommandBase *d = new editCommandBase(this,"smalleditdialog", TRUE); | 185 | editCommandBase *d = new editCommandBase(this,"smalleditdialog", TRUE); |
186 | int i = d->exec(); | 186 | int i = d->exec(); |
187 | if ((i==1) && (!(d->commandEdit->text()).isEmpty())) | 187 | if ((i==1) && (!(d->commandEdit->text()).isEmpty())) |
188 | m_PlayListSelection->addStringToSelection(d->commandEdit->text()); | 188 | m_PlayListSelection->addStringToSelection(d->commandEdit->text()); |
189 | 189 | ||
190 | } | 190 | } |
191 | 191 | ||
diff --git a/core/apps/embeddedkonsole/konsole.cpp b/core/apps/embeddedkonsole/konsole.cpp index 8207f23..80c8223 100644 --- a/core/apps/embeddedkonsole/konsole.cpp +++ b/core/apps/embeddedkonsole/konsole.cpp | |||
@@ -1,1923 +1,1924 @@ | |||
1 | 1 | ||
2 | /* ---------------------------------------------------------------------- */ | 2 | /* ---------------------------------------------------------------------- */ |
3 | /* */ | 3 | /* */ |
4 | /* [main.C] Konsole */ | 4 | /* [main.C] Konsole */ |
5 | /* */ | 5 | /* */ |
6 | /* ---------------------------------------------------------------------- */ | 6 | /* ---------------------------------------------------------------------- */ |
7 | /* */ | 7 | /* */ |
8 | /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ | 8 | /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ |
9 | /* */ | 9 | /* */ |
10 | /* This file is part of Konsole, an X terminal. */ | 10 | /* This file is part of Konsole, an X terminal. */ |
11 | /* */ | 11 | /* */ |
12 | /* The material contained in here more or less directly orginates from */ | 12 | /* The material contained in here more or less directly orginates from */ |
13 | /* kvt, which is copyright (c) 1996 by Matthias Ettrich <ettrich@kde.org> */ | 13 | /* kvt, which is copyright (c) 1996 by Matthias Ettrich <ettrich@kde.org> */ |
14 | /* */ | 14 | /* */ |
15 | /* ---------------------------------------------------------------------- */ | 15 | /* ---------------------------------------------------------------------- */ |
16 | /* */ | 16 | /* */ |
17 | /* Ported Konsole to Qt/Embedded */ | 17 | /* Ported Konsole to Qt/Embedded */ |
18 | /* */ | 18 | /* */ |
19 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ | 19 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ |
20 | /* */ | 20 | /* */ |
21 | /* -------------------------------------------------------------------------- */ | 21 | /* -------------------------------------------------------------------------- */ |
22 | // enhancements added by L.J. Potter <ljp@llornkcor.com> | 22 | // enhancements added by L.J. Potter <ljp@llornkcor.com> |
23 | // enhancements added by Phillip Kuhn | 23 | // enhancements added by Phillip Kuhn |
24 | 24 | ||
25 | #include <stdlib.h> | 25 | #include <stdlib.h> |
26 | #include <sys/types.h> | 26 | #include <sys/types.h> |
27 | #include <pwd.h> | 27 | #include <pwd.h> |
28 | #include <unistd.h> | 28 | #include <unistd.h> |
29 | 29 | ||
30 | #ifdef QT_QWS_OPIE | 30 | #ifdef QT_QWS_OPIE |
31 | #include <opie2/ocolorpopupmenu.h> | 31 | #include <opie2/ocolorpopupmenu.h> |
32 | #include <opie2/odebug.h> | ||
32 | using namespace Opie; | 33 | using namespace Opie; |
33 | #endif | 34 | #endif |
34 | 35 | ||
35 | #include <qpe/resource.h> | 36 | #include <qpe/resource.h> |
36 | 37 | ||
37 | #include <qmenubar.h> | 38 | #include <qmenubar.h> |
38 | #include <qtabbar.h> | 39 | #include <qtabbar.h> |
39 | #include <qpe/config.h> | 40 | #include <qpe/config.h> |
40 | #include <qfontdatabase.h> | 41 | #include <qfontdatabase.h> |
41 | #include <qfile.h> | 42 | #include <qfile.h> |
42 | #include <qspinbox.h> | 43 | #include <qspinbox.h> |
43 | #include <qlayout.h> | 44 | #include <qlayout.h> |
44 | 45 | ||
45 | #include <sys/wait.h> | 46 | #include <sys/wait.h> |
46 | #include <stdio.h> | 47 | #include <stdio.h> |
47 | #include <stdlib.h> | 48 | #include <stdlib.h> |
48 | #include <assert.h> | 49 | #include <assert.h> |
49 | 50 | ||
50 | #include "konsole.h" | 51 | #include "konsole.h" |
51 | #include "commandeditdialog.h" | 52 | #include "commandeditdialog.h" |
52 | 53 | ||
53 | class EKNumTabBar : public QTabBar | 54 | class EKNumTabBar : public QTabBar |
54 | { | 55 | { |
55 | public: | 56 | public: |
56 | EKNumTabBar(QWidget *parent = 0, const char *name = 0) : | 57 | EKNumTabBar(QWidget *parent = 0, const char *name = 0) : |
57 | QTabBar(parent, name) | 58 | QTabBar(parent, name) |
58 | {} | 59 | {} |
59 | 60 | ||
60 | // QList<QTab> *getTabList() { return(tabList()); } | 61 | // QList<QTab> *getTabList() { return(tabList()); } |
61 | 62 | ||
62 | void numberTabs() | 63 | void numberTabs() |
63 | { | 64 | { |
64 | // Yes, it really is this messy. QTabWidget needs functions | 65 | // Yes, it really is this messy. QTabWidget needs functions |
65 | // that provide acces to tabs in a sequential way. | 66 | // that provide acces to tabs in a sequential way. |
66 | int m=INT_MIN; | 67 | int m=INT_MIN; |
67 | for (int i=0; i<count(); i++) | 68 | for (int i=0; i<count(); i++) |
68 | { | 69 | { |
69 | QTab* left=0; | 70 | QTab* left=0; |
70 | QListIterator<QTab> it(*tabList()); | 71 | QListIterator<QTab> it(*tabList()); |
71 | int x=INT_MAX; | 72 | int x=INT_MAX; |
72 | for( QTab* t; (t=it.current()); ++it ) | 73 | for( QTab* t; (t=it.current()); ++it ) |
73 | { | 74 | { |
74 | int tx = t->rect().x(); | 75 | int tx = t->rect().x(); |
75 | if ( tx<x && tx>m ) | 76 | if ( tx<x && tx>m ) |
76 | { | 77 | { |
77 | x = tx; | 78 | x = tx; |
78 | left = t; | 79 | left = t; |
79 | } | 80 | } |
80 | } | 81 | } |
81 | if ( left ) | 82 | if ( left ) |
82 | { | 83 | { |
83 | left->setText(QString::number(i+1)); | 84 | left->setText(QString::number(i+1)); |
84 | m = left->rect().x(); | 85 | m = left->rect().x(); |
85 | } | 86 | } |
86 | } | 87 | } |
87 | } | 88 | } |
88 | 89 | ||
89 | virtual QSize sizeHint() const | 90 | virtual QSize sizeHint() const |
90 | { | 91 | { |
91 | if (isHidden()) | 92 | if (isHidden()) |
92 | { | 93 | { |
93 | return(QSize(0,0)); | 94 | return(QSize(0,0)); |
94 | } | 95 | } |
95 | else | 96 | else |
96 | { | 97 | { |
97 | QSize size = QTabBar::sizeHint(); | 98 | QSize size = QTabBar::sizeHint(); |
98 | int shrink = 5; | 99 | int shrink = 5; |
99 | if (qApp->desktop()->width() > 600 || qApp->desktop()->height() > 600) | 100 | if (qApp->desktop()->width() > 600 || qApp->desktop()->height() > 600) |
100 | { | 101 | { |
101 | shrink = 10; | 102 | shrink = 10; |
102 | } | 103 | } |
103 | size.setHeight(size.height() - shrink); | 104 | size.setHeight(size.height() - shrink); |
104 | return(size); | 105 | return(size); |
105 | } | 106 | } |
106 | } | 107 | } |
107 | 108 | ||
108 | }; | 109 | }; |
109 | 110 | ||
110 | class EKNumTabWidget : public QTabWidget | 111 | class EKNumTabWidget : public QTabWidget |
111 | { | 112 | { |
112 | public: | 113 | public: |
113 | EKNumTabWidget(QWidget* parent) : QTabWidget(parent) | 114 | EKNumTabWidget(QWidget* parent) : QTabWidget(parent) |
114 | { | 115 | { |
115 | setTabBar(new EKNumTabBar(parent,"EKTabBar")); | 116 | setTabBar(new EKNumTabBar(parent,"EKTabBar")); |
116 | setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); | 117 | setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); |
117 | } | 118 | } |
118 | 119 | ||
119 | EKNumTabBar *getTabBar() const | 120 | EKNumTabBar *getTabBar() const |
120 | { | 121 | { |
121 | return ((EKNumTabBar*)tabBar()); | 122 | return ((EKNumTabBar*)tabBar()); |
122 | } | 123 | } |
123 | 124 | ||
124 | 125 | ||
125 | void addTab(QWidget* w) | 126 | void addTab(QWidget* w) |
126 | { | 127 | { |
127 | QTab* t = new QTab(QString::number(tabBar()->count()+1)); | 128 | QTab* t = new QTab(QString::number(tabBar()->count()+1)); |
128 | QTabWidget::addTab(w,t); | 129 | QTabWidget::addTab(w,t); |
129 | } | 130 | } |
130 | 131 | ||
131 | void removeTab(QWidget* w) | 132 | void removeTab(QWidget* w) |
132 | { | 133 | { |
133 | removePage(w); | 134 | removePage(w); |
134 | ((EKNumTabBar*)tabBar())->numberTabs(); | 135 | ((EKNumTabBar*)tabBar())->numberTabs(); |
135 | } | 136 | } |
136 | }; | 137 | }; |
137 | 138 | ||
138 | // This could be configurable or dynamicly generated from the bash history | 139 | // This could be configurable or dynamicly generated from the bash history |
139 | // file of the user | 140 | // file of the user |
140 | static const char *commonCmds[] = | 141 | static const char *commonCmds[] = |
141 | { | 142 | { |
142 | "ls ", // I left this here, cause it looks better than the first alpha | 143 | "ls ", // I left this here, cause it looks better than the first alpha |
143 | "cardctl eject", | 144 | "cardctl eject", |
144 | "cat ", | 145 | "cat ", |
145 | "cd ", | 146 | "cd ", |
146 | "chmod ", | 147 | "chmod ", |
147 | "clear", | 148 | "clear", |
148 | "cp ", | 149 | "cp ", |
149 | "dc ", | 150 | "dc ", |
150 | "df ", | 151 | "df ", |
151 | "dmesg", | 152 | "dmesg", |
152 | "echo ", | 153 | "echo ", |
153 | "env", | 154 | "env", |
154 | "find ", | 155 | "find ", |
155 | "free", | 156 | "free", |
156 | "grep ", | 157 | "grep ", |
157 | "ifconfig ", | 158 | "ifconfig ", |
158 | "ipkg ", | 159 | "ipkg ", |
159 | "mkdir ", | 160 | "mkdir ", |
160 | "mv ", | 161 | "mv ", |
161 | "nc localhost 7776", | 162 | "nc localhost 7776", |
162 | "nc localhost 7777", | 163 | "nc localhost 7777", |
163 | "netstat ", | 164 | "netstat ", |
164 | "nslookup ", | 165 | "nslookup ", |
165 | "ping ", | 166 | "ping ", |
166 | "ps aux", | 167 | "ps aux", |
167 | "pwd ", | 168 | "pwd ", |
168 | "qcop QPE/System 'linkChanged(QString)' ''", | 169 | "qcop QPE/System 'linkChanged(QString)' ''", |
169 | "qcop QPE/System 'restart()'", | 170 | "qcop QPE/System 'restart()'", |
170 | "qcop QPE/System 'quit()'", | 171 | "qcop QPE/System 'quit()'", |
171 | "rm ", | 172 | "rm ", |
172 | "rmdir ", | 173 | "rmdir ", |
173 | "route ", | 174 | "route ", |
174 | "set ", | 175 | "set ", |
175 | "traceroute", | 176 | "traceroute", |
176 | 177 | ||
177 | /* | 178 | /* |
178 | "gzip", | 179 | "gzip", |
179 | "gunzip", | 180 | "gunzip", |
180 | "chgrp", | 181 | "chgrp", |
181 | "chown", | 182 | "chown", |
182 | "date", | 183 | "date", |
183 | "dd", | 184 | "dd", |
184 | "df", | 185 | "df", |
185 | "dmesg", | 186 | "dmesg", |
186 | "fuser", | 187 | "fuser", |
187 | "hostname", | 188 | "hostname", |
188 | "kill", | 189 | "kill", |
189 | "killall", | 190 | "killall", |
190 | "ln", | 191 | "ln", |
191 | "ping", | 192 | "ping", |
192 | "mount", | 193 | "mount", |
193 | "more", | 194 | "more", |
194 | "sort", | 195 | "sort", |
195 | "touch", | 196 | "touch", |
196 | "umount", | 197 | "umount", |
197 | "mknod", | 198 | "mknod", |
198 | "netstat", | 199 | "netstat", |
199 | */ | 200 | */ |
200 | 201 | ||
201 | "exit", | 202 | "exit", |
202 | NULL | 203 | NULL |
203 | }; | 204 | }; |
204 | 205 | ||
205 | 206 | ||
206 | static void konsoleInit(const char** shell) { | 207 | static void konsoleInit(const char** shell) { |
207 | if(setuid(getuid()) !=0) qDebug("setuid failed"); | 208 | if(setuid(getuid()) !=0) odebug << "setuid failed" << oendl; |
208 | if(setgid(getgid()) != 0) qDebug("setgid failed"); // drop privileges | 209 | if(setgid(getgid()) != 0) odebug << "setgid failed" << oendl; // drop privileges |
209 | 210 | ||
210 | 211 | ||
211 | // QPEApplication::grabKeyboard(); // for CTRL and ALT | 212 | // QPEApplication::grabKeyboard(); // for CTRL and ALT |
212 | 213 | ||
213 | qDebug("keyboard grabbed"); | 214 | odebug << "keyboard grabbed" << oendl; |
214 | #ifdef FAKE_CTRL_AND_ALT | 215 | #ifdef FAKE_CTRL_AND_ALT |
215 | qDebug("Fake Ctrl and Alt defined"); | 216 | odebug << "Fake Ctrl and Alt defined" << oendl; |
216 | QPEApplication::grabKeyboard(); // for CTRL and ALT | 217 | QPEApplication::grabKeyboard(); // for CTRL and ALT |
217 | #endif | 218 | #endif |
218 | 219 | ||
219 | *shell = getenv("SHELL"); | 220 | *shell = getenv("SHELL"); |
220 | qWarning("SHell initially is %s", *shell ); | 221 | owarn << "SHell initially is " << *shell << "" << oendl; |
221 | 222 | ||
222 | if (shell == NULL || *shell == '\0') { | 223 | if (shell == NULL || *shell == '\0') { |
223 | struct passwd *ent = 0; | 224 | struct passwd *ent = 0; |
224 | uid_t me = getuid(); | 225 | uid_t me = getuid(); |
225 | *shell = "/bin/sh"; | 226 | *shell = "/bin/sh"; |
226 | 227 | ||
227 | while ( (ent = getpwent()) != 0 ) { | 228 | while ( (ent = getpwent()) != 0 ) { |
228 | if (ent->pw_uid == me) { | 229 | if (ent->pw_uid == me) { |
229 | if (ent->pw_shell != "") | 230 | if (ent->pw_shell != "") |
230 | *shell = ent->pw_shell; | 231 | *shell = ent->pw_shell; |
231 | break; | 232 | break; |
232 | } | 233 | } |
233 | } | 234 | } |
234 | endpwent(); | 235 | endpwent(); |
235 | } | 236 | } |
236 | 237 | ||
237 | if( putenv((char*)"COLORTERM=") !=0) | 238 | if( putenv((char*)"COLORTERM=") !=0) |
238 | qDebug("putenv failed"); // to trigger mc's color detection | 239 | odebug << "putenv failed" << oendl; // to trigger mc's color detection |
239 | } | 240 | } |
240 | 241 | ||
241 | 242 | ||
242 | Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) : | 243 | Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) : |
243 | QMainWindow(parent, name, fl) | 244 | QMainWindow(parent, name, fl) |
244 | { | 245 | { |
245 | QStrList tmp; const char* shell; | 246 | QStrList tmp; const char* shell; |
246 | 247 | ||
247 | konsoleInit( &shell); | 248 | konsoleInit( &shell); |
248 | init(shell,tmp); | 249 | init(shell,tmp); |
249 | } | 250 | } |
250 | 251 | ||
251 | Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int) | 252 | Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int) |
252 | : QMainWindow(0, name) | 253 | : QMainWindow(0, name) |
253 | { | 254 | { |
254 | init(_pgm,_args); | 255 | init(_pgm,_args); |
255 | } | 256 | } |
256 | 257 | ||
257 | struct HistoryItem | 258 | struct HistoryItem |
258 | { | 259 | { |
259 | HistoryItem(int c, const QString &l) | 260 | HistoryItem(int c, const QString &l) |
260 | { | 261 | { |
261 | count = c; | 262 | count = c; |
262 | line = l; | 263 | line = l; |
263 | } | 264 | } |
264 | int count; | 265 | int count; |
265 | QString line; | 266 | QString line; |
266 | }; | 267 | }; |
267 | 268 | ||
268 | class HistoryList : public QList<HistoryItem> | 269 | class HistoryList : public QList<HistoryItem> |
269 | { | 270 | { |
270 | virtual int compareItems( QCollection::Item item1, QCollection::Item item2) | 271 | virtual int compareItems( QCollection::Item item1, QCollection::Item item2) |
271 | { | 272 | { |
272 | int c1 = ((HistoryItem*)item1)->count; | 273 | int c1 = ((HistoryItem*)item1)->count; |
273 | int c2 = ((HistoryItem*)item2)->count; | 274 | int c2 = ((HistoryItem*)item2)->count; |
274 | if (c1 > c2) | 275 | if (c1 > c2) |
275 | return(1); | 276 | return(1); |
276 | if (c1 < c2) | 277 | if (c1 < c2) |
277 | return(-1); | 278 | return(-1); |
278 | return(0); | 279 | return(0); |
279 | } | 280 | } |
280 | }; | 281 | }; |
281 | 282 | ||
282 | void Konsole::initCommandList() | 283 | void Konsole::initCommandList() |
283 | { | 284 | { |
284 | // qDebug("Konsole::initCommandList"); | 285 | // odebug << "Konsole::initCommandList" << oendl; |
285 | Config cfg( "Konsole" ); | 286 | Config cfg( "Konsole" ); |
286 | cfg.setGroup("Commands"); | 287 | cfg.setGroup("Commands"); |
287 | // commonCombo->setInsertionPolicy(QComboBox::AtCurrent); | 288 | // commonCombo->setInsertionPolicy(QComboBox::AtCurrent); |
288 | commonCombo->clear(); | 289 | commonCombo->clear(); |
289 | 290 | ||
290 | if (cfg.readEntry("ShellHistory","TRUE") == "TRUE") | 291 | if (cfg.readEntry("ShellHistory","TRUE") == "TRUE") |
291 | { | 292 | { |
292 | QString histfilename = QString(getenv("HOME")) + "/.bash_history"; | 293 | QString histfilename = QString(getenv("HOME")) + "/.bash_history"; |
293 | histfilename = cfg.readEntry("ShellHistoryPath",histfilename); | 294 | histfilename = cfg.readEntry("ShellHistoryPath",histfilename); |
294 | QFile histfile(histfilename); | 295 | QFile histfile(histfilename); |
295 | // note: compiler barfed on: | 296 | // note: compiler barfed on: |
296 | // QFile histfile(QString(getenv("HOME")) + "/.bash_history"); | 297 | // QFile histfile(QString(getenv("HOME")) + "/.bash_history"); |
297 | if (histfile.open( IO_ReadOnly )) | 298 | if (histfile.open( IO_ReadOnly )) |
298 | { | 299 | { |
299 | QString line; | 300 | QString line; |
300 | uint i; | 301 | uint i; |
301 | HistoryList items; | 302 | HistoryList items; |
302 | 303 | ||
303 | int lineno = 0; | 304 | int lineno = 0; |
304 | while(!histfile.atEnd()) | 305 | while(!histfile.atEnd()) |
305 | { | 306 | { |
306 | if (histfile.readLine(line, 200) < 0) | 307 | if (histfile.readLine(line, 200) < 0) |
307 | { | 308 | { |
308 | break; | 309 | break; |
309 | } | 310 | } |
310 | line = line.left(line.length()-1); | 311 | line = line.left(line.length()-1); |
311 | lineno++; | 312 | lineno++; |
312 | 313 | ||
313 | for(i=0; i<items.count(); i++) | 314 | for(i=0; i<items.count(); i++) |
314 | { | 315 | { |
315 | if (line == items.at(i)->line) | 316 | if (line == items.at(i)->line) |
316 | { | 317 | { |
317 | // weight recent commands & repeated commands more | 318 | // weight recent commands & repeated commands more |
318 | // by adding up the index of each command | 319 | // by adding up the index of each command |
319 | items.at(i)->count += lineno; | 320 | items.at(i)->count += lineno; |
320 | break; | 321 | break; |
321 | } | 322 | } |
322 | } | 323 | } |
323 | if (i >= items.count()) | 324 | if (i >= items.count()) |
324 | { | 325 | { |
325 | items.append(new HistoryItem(lineno, line)); | 326 | items.append(new HistoryItem(lineno, line)); |
326 | } | 327 | } |
327 | } | 328 | } |
328 | items.sort(); | 329 | items.sort(); |
329 | int n = items.count(); | 330 | int n = items.count(); |
330 | if (n > 40) | 331 | if (n > 40) |
331 | { | 332 | { |
332 | n = 40; | 333 | n = 40; |
333 | } | 334 | } |
334 | for(int i=0; i<n; i++) | 335 | for(int i=0; i<n; i++) |
335 | { | 336 | { |
336 | // should insert start of command, but keep whole thing | 337 | // should insert start of command, but keep whole thing |
337 | if (items.at(items.count()-i-1)->line.length() < 30) | 338 | if (items.at(items.count()-i-1)->line.length() < 30) |
338 | { | 339 | { |
339 | commonCombo->insertItem(items.at(items.count()-i-1)->line); | 340 | commonCombo->insertItem(items.at(items.count()-i-1)->line); |
340 | } | 341 | } |
341 | } | 342 | } |
342 | histfile.close(); | 343 | histfile.close(); |
343 | } | 344 | } |
344 | } | 345 | } |
345 | if (cfg.readEntry("Commands Set","FALSE") == "FALSE") | 346 | if (cfg.readEntry("Commands Set","FALSE") == "FALSE") |
346 | { | 347 | { |
347 | for (int i = 0; commonCmds[i] != NULL; i++) | 348 | for (int i = 0; commonCmds[i] != NULL; i++) |
348 | { | 349 | { |
349 | commonCombo->insertItem(commonCmds[i]); | 350 | commonCombo->insertItem(commonCmds[i]); |
350 | } | 351 | } |
351 | } | 352 | } |
352 | else | 353 | else |
353 | { | 354 | { |
354 | for (int i = 0; i < 100; i++) | 355 | for (int i = 0; i < 100; i++) |
355 | { | 356 | { |
356 | if (!(cfg.readEntry( QString::number(i),"")).isEmpty()) | 357 | if (!(cfg.readEntry( QString::number(i),"")).isEmpty()) |
357 | commonCombo->insertItem(cfg.readEntry( QString::number(i),"")); | 358 | commonCombo->insertItem(cfg.readEntry( QString::number(i),"")); |
358 | } | 359 | } |
359 | } | 360 | } |
360 | 361 | ||
361 | 362 | ||
362 | } | 363 | } |
363 | 364 | ||
364 | static void sig_handler(int x) | 365 | static void sig_handler(int x) |
365 | { | 366 | { |
366 | printf("got signal %d\n",x); | 367 | printf("got signal %d\n",x); |
367 | } | 368 | } |
368 | 369 | ||
369 | void Konsole::init(const char* _pgm, QStrList & _args) | 370 | void Konsole::init(const char* _pgm, QStrList & _args) |
370 | { | 371 | { |
371 | 372 | ||
372 | #if 0 | 373 | #if 0 |
373 | for(int i=1; i<=31; i++) | 374 | for(int i=1; i<=31; i++) |
374 | { | 375 | { |
375 | if (i != SIGPIPE && i != SIGPROF && i != SIGSEGV | 376 | if (i != SIGPIPE && i != SIGPROF && i != SIGSEGV |
376 | && i != SIGINT && i != SIGILL && i != SIGTERM | 377 | && i != SIGINT && i != SIGILL && i != SIGTERM |
377 | && i != SIGBUS) | 378 | && i != SIGBUS) |
378 | signal(i,sig_handler); | 379 | signal(i,sig_handler); |
379 | } | 380 | } |
380 | #endif | 381 | #endif |
381 | signal(SIGSTOP, sig_handler); | 382 | signal(SIGSTOP, sig_handler); |
382 | signal(SIGCONT, sig_handler); | 383 | signal(SIGCONT, sig_handler); |
383 | signal(SIGTSTP, sig_handler); | 384 | signal(SIGTSTP, sig_handler); |
384 | 385 | ||
385 | b_scroll = TRUE; // histon; | 386 | b_scroll = TRUE; // histon; |
386 | n_keytab = 0; | 387 | n_keytab = 0; |
387 | n_render = 0; | 388 | n_render = 0; |
388 | startUp=0; | 389 | startUp=0; |
389 | fromMenu = FALSE; | 390 | fromMenu = FALSE; |
390 | fullscreen = false; | 391 | fullscreen = false; |
391 | 392 | ||
392 | setCaption( tr( "Konsole" ) ); | 393 | setCaption( tr( "Konsole" ) ); |
393 | setIcon( Resource::loadPixmap( "konsole/Terminal" ) ); | 394 | setIcon( Resource::loadPixmap( "konsole/Terminal" ) ); |
394 | 395 | ||
395 | Config cfg( "Konsole" ); | 396 | Config cfg( "Konsole" ); |
396 | cfg.setGroup("Font"); | 397 | cfg.setGroup("Font"); |
397 | QString tmp; | 398 | QString tmp; |
398 | 399 | ||
399 | // initialize the list of allowed fonts /////////////////////////////////// | 400 | // initialize the list of allowed fonts /////////////////////////////////// |
400 | 401 | ||
401 | QString cfgFontName = cfg.readEntry("FontName","Lcfont"); | 402 | QString cfgFontName = cfg.readEntry("FontName","Lcfont"); |
402 | int cfgFontSize = cfg.readNumEntry("FontSize",18); | 403 | int cfgFontSize = cfg.readNumEntry("FontSize",18); |
403 | 404 | ||
404 | cfont = -1; | 405 | cfont = -1; |
405 | 406 | ||
406 | // this code causes repeated access to all the font files | 407 | // this code causes repeated access to all the font files |
407 | // which does slow down startup | 408 | // which does slow down startup |
408 | QFontDatabase fontDB; | 409 | QFontDatabase fontDB; |
409 | QStringList familyNames; | 410 | QStringList familyNames; |
410 | familyNames = fontDB.families( FALSE ); | 411 | familyNames = fontDB.families( FALSE ); |
411 | QString s; | 412 | QString s; |
412 | int fontIndex = 0; | 413 | int fontIndex = 0; |
413 | int familyNum = 0; | 414 | int familyNum = 0; |
414 | fontList = new QPopupMenu( this ); | 415 | fontList = new QPopupMenu( this ); |
415 | 416 | ||
416 | for(uint j = 0; j < (uint)familyNames.count(); j++) | 417 | for(uint j = 0; j < (uint)familyNames.count(); j++) |
417 | { | 418 | { |
418 | s = familyNames[j]; | 419 | s = familyNames[j]; |
419 | if ( s.contains('-') ) | 420 | if ( s.contains('-') ) |
420 | { | 421 | { |
421 | int i = s.find('-'); | 422 | int i = s.find('-'); |
422 | s = s.right( s.length() - i - 1 ) + " [" + s.left( i ) + "]"; | 423 | s = s.right( s.length() - i - 1 ) + " [" + s.left( i ) + "]"; |
423 | } | 424 | } |
424 | s[0] = s[0].upper(); | 425 | s[0] = s[0].upper(); |
425 | 426 | ||
426 | QValueList<int> sizes = fontDB.pointSizes( familyNames[j] ); | 427 | QValueList<int> sizes = fontDB.pointSizes( familyNames[j] ); |
427 | 428 | ||
428 | printf("family[%d] = %s with %d sizes\n", j, familyNames[j].latin1(), | 429 | printf("family[%d] = %s with %d sizes\n", j, familyNames[j].latin1(), |
429 | sizes.count()); | 430 | sizes.count()); |
430 | 431 | ||
431 | if (sizes.count() > 0) | 432 | if (sizes.count() > 0) |
432 | { | 433 | { |
433 | QPopupMenu *sizeMenu; | 434 | QPopupMenu *sizeMenu; |
434 | QFont f; | 435 | QFont f; |
435 | int last_width = -1; | 436 | int last_width = -1; |
436 | sizeMenu = NULL; | 437 | sizeMenu = NULL; |
437 | 438 | ||
438 | for(uint i = 0; i < (uint)sizes.count() + 4; i++) | 439 | for(uint i = 0; i < (uint)sizes.count() + 4; i++) |
439 | { | 440 | { |
440 | // printf("family %s size %d ", familyNames[j].latin1(), sizes[i]); | 441 | // printf("family %s size %d ", familyNames[j].latin1(), sizes[i]); |
441 | // need to divide by 10 on the Z, but not otherwise | 442 | // need to divide by 10 on the Z, but not otherwise |
442 | int size; | 443 | int size; |
443 | 444 | ||
444 | if (i >= (uint)sizes.count()) | 445 | if (i >= (uint)sizes.count()) |
445 | { | 446 | { |
446 | // try for expandable fonts | 447 | // try for expandable fonts |
447 | size = sizes[sizes.count()-1] + 2 * (i - sizes.count() + 1); | 448 | size = sizes[sizes.count()-1] + 2 * (i - sizes.count() + 1); |
448 | } | 449 | } |
449 | else | 450 | else |
450 | { | 451 | { |
451 | printf("sizes[%d] = %d\n", i, sizes[i]); | 452 | printf("sizes[%d] = %d\n", i, sizes[i]); |
452 | size = sizes[i]; | 453 | size = sizes[i]; |
453 | } | 454 | } |
454 | 455 | ||
455 | f = QFont(familyNames[j], size); | 456 | f = QFont(familyNames[j], size); |
456 | f.setFixedPitch(true); | 457 | f.setFixedPitch(true); |
457 | QFontMetrics fm(f); | 458 | QFontMetrics fm(f); |
458 | // don't trust f.fixedPitch() or f.exactMatch(), they lie!! | 459 | // don't trust f.fixedPitch() or f.exactMatch(), they lie!! |
459 | if (fm.width("l") == fm.width("m") | 460 | if (fm.width("l") == fm.width("m") |
460 | && (i < (uint)sizes.count() | 461 | && (i < (uint)sizes.count() |
461 | || fm.width("m") > last_width)) | 462 | || fm.width("m") > last_width)) |
462 | { | 463 | { |
463 | if (i < (uint)sizes.count()) | 464 | if (i < (uint)sizes.count()) |
464 | { | 465 | { |
465 | last_width = fm.width("m"); | 466 | last_width = fm.width("m"); |
466 | } | 467 | } |
467 | if (sizeMenu == NULL) | 468 | if (sizeMenu == NULL) |
468 | { | 469 | { |
469 | sizeMenu = new QPopupMenu(); | 470 | sizeMenu = new QPopupMenu(); |
470 | } | 471 | } |
471 | int id = sizeMenu->insertItem(QString("%1").arg(size), fontIndex); | 472 | int id = sizeMenu->insertItem(QString("%1").arg(size), fontIndex); |
472 | sizeMenu->setItemParameter(id, fontIndex); | 473 | sizeMenu->setItemParameter(id, fontIndex); |
473 | sizeMenu->connectItem(id, this, SLOT(setFont(int))); | 474 | sizeMenu->connectItem(id, this, SLOT(setFont(int))); |
474 | QString name = s + " " + QString::number(size); | 475 | QString name = s + " " + QString::number(size); |
475 | fonts.append(new VTFont(name, f, familyNames[j], familyNum, size)); | 476 | fonts.append(new VTFont(name, f, familyNames[j], familyNum, size)); |
476 | if (familyNames[j] == cfgFontName && size == cfgFontSize) | 477 | if (familyNames[j] == cfgFontName && size == cfgFontSize) |
477 | { | 478 | { |
478 | cfont = fontIndex; | 479 | cfont = fontIndex; |
479 | } | 480 | } |
480 | printf("FOUND: %s family %s size %d\n", name.latin1(), familyNames[j].latin1(), size); | 481 | printf("FOUND: %s family %s size %d\n", name.latin1(), familyNames[j].latin1(), size); |
481 | fontIndex++; | 482 | fontIndex++; |
482 | } | 483 | } |
483 | } | 484 | } |
484 | if (sizeMenu) | 485 | if (sizeMenu) |
485 | { | 486 | { |
486 | fontList->insertItem(s, sizeMenu, familyNum + 1000); | 487 | fontList->insertItem(s, sizeMenu, familyNum + 1000); |
487 | 488 | ||
488 | familyNum++; | 489 | familyNum++; |
489 | } | 490 | } |
490 | } | 491 | } |
491 | 492 | ||
492 | } | 493 | } |
493 | 494 | ||
494 | if (cfont < 0 || cfont >= (int)fonts.count()) | 495 | if (cfont < 0 || cfont >= (int)fonts.count()) |
495 | { | 496 | { |
496 | cfont = 0; | 497 | cfont = 0; |
497 | } | 498 | } |
498 | 499 | ||
499 | // create terminal emulation framework //////////////////////////////////// | 500 | // create terminal emulation framework //////////////////////////////////// |
500 | nsessions = 0; | 501 | nsessions = 0; |
501 | 502 | ||
502 | tab = new EKNumTabWidget(this); | 503 | tab = new EKNumTabWidget(this); |
503 | // tab->setMargin(tab->margin()-5); | 504 | // tab->setMargin(tab->margin()-5); |
504 | connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*))); | 505 | connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*))); |
505 | 506 | ||
506 | // create terminal toolbar //////////////////////////////////////////////// | 507 | // create terminal toolbar //////////////////////////////////////////////// |
507 | setToolBarsMovable( FALSE ); | 508 | setToolBarsMovable( FALSE ); |
508 | menuToolBar = new QToolBar( this ); | 509 | menuToolBar = new QToolBar( this ); |
509 | menuToolBar->setHorizontalStretchable( TRUE ); | 510 | menuToolBar->setHorizontalStretchable( TRUE ); |
510 | 511 | ||
511 | QMenuBar *menuBar = new QMenuBar( menuToolBar ); | 512 | QMenuBar *menuBar = new QMenuBar( menuToolBar ); |
512 | 513 | ||
513 | setFont(cfont); | 514 | setFont(cfont); |
514 | 515 | ||
515 | configMenu = new QPopupMenu( this); | 516 | configMenu = new QPopupMenu( this); |
516 | colorMenu = new QPopupMenu( this); | 517 | colorMenu = new QPopupMenu( this); |
517 | scrollMenu = new QPopupMenu( this); | 518 | scrollMenu = new QPopupMenu( this); |
518 | editCommandListMenu = new QPopupMenu( this); | 519 | editCommandListMenu = new QPopupMenu( this); |
519 | 520 | ||
520 | configMenu->insertItem(tr("Command List"), editCommandListMenu); | 521 | configMenu->insertItem(tr("Command List"), editCommandListMenu); |
521 | 522 | ||
522 | bool listHidden; | 523 | bool listHidden; |
523 | cfg.setGroup("Menubar"); | 524 | cfg.setGroup("Menubar"); |
524 | if( cfg.readEntry("Hidden","FALSE") == "TRUE") | 525 | if( cfg.readEntry("Hidden","FALSE") == "TRUE") |
525 | { | 526 | { |
526 | ec_cmdlist = editCommandListMenu->insertItem( tr( "Show command list" )); | 527 | ec_cmdlist = editCommandListMenu->insertItem( tr( "Show command list" )); |
527 | listHidden=TRUE; | 528 | listHidden=TRUE; |
528 | } | 529 | } |
529 | else | 530 | else |
530 | { | 531 | { |
531 | ec_cmdlist = editCommandListMenu->insertItem( tr( "Hide command list" )); | 532 | ec_cmdlist = editCommandListMenu->insertItem( tr( "Hide command list" )); |
532 | listHidden=FALSE; | 533 | listHidden=FALSE; |
533 | } | 534 | } |
534 | 535 | ||
535 | cfg.setGroup("Tabs"); | 536 | cfg.setGroup("Tabs"); |
536 | 537 | ||
537 | tabMenu = new QPopupMenu(this); | 538 | tabMenu = new QPopupMenu(this); |
538 | tm_bottom = tabMenu->insertItem(tr("Bottom" )); | 539 | tm_bottom = tabMenu->insertItem(tr("Bottom" )); |
539 | tm_top = tabMenu->insertItem(tr("Top")); | 540 | tm_top = tabMenu->insertItem(tr("Top")); |
540 | tm_hidden = tabMenu->insertItem(tr("Hidden")); | 541 | tm_hidden = tabMenu->insertItem(tr("Hidden")); |
541 | 542 | ||
542 | configMenu->insertItem(tr("Tabs"), tabMenu); | 543 | configMenu->insertItem(tr("Tabs"), tabMenu); |
543 | 544 | ||
544 | tmp=cfg.readEntry("Position","Top"); | 545 | tmp=cfg.readEntry("Position","Top"); |
545 | if(tmp=="Top") | 546 | if(tmp=="Top") |
546 | { | 547 | { |
547 | tab->setTabPosition(QTabWidget::Top); | 548 | tab->setTabPosition(QTabWidget::Top); |
548 | tab->getTabBar()->show(); | 549 | tab->getTabBar()->show(); |
549 | tabPos = tm_top; | 550 | tabPos = tm_top; |
550 | } | 551 | } |
551 | else if (tmp=="Bottom") | 552 | else if (tmp=="Bottom") |
552 | { | 553 | { |
553 | tab->setTabPosition(QTabWidget::Bottom); | 554 | tab->setTabPosition(QTabWidget::Bottom); |
554 | tab->getTabBar()->show(); | 555 | tab->getTabBar()->show(); |
555 | tabPos = tm_bottom; | 556 | tabPos = tm_bottom; |
556 | } | 557 | } |
557 | else | 558 | else |
558 | { | 559 | { |
559 | tab->getTabBar()->hide(); | 560 | tab->getTabBar()->hide(); |
560 | tab->setMargin(tab->margin()); | 561 | tab->setMargin(tab->margin()); |
561 | tabPos = tm_hidden; | 562 | tabPos = tm_hidden; |
562 | } | 563 | } |
563 | 564 | ||
564 | cm_bw = colorMenu->insertItem(tr( "Black on White")); | 565 | cm_bw = colorMenu->insertItem(tr( "Black on White")); |
565 | cm_wb = colorMenu->insertItem(tr( "White on Black")); | 566 | cm_wb = colorMenu->insertItem(tr( "White on Black")); |
566 | cm_gb = colorMenu->insertItem(tr( "Green on Black")); | 567 | cm_gb = colorMenu->insertItem(tr( "Green on Black")); |
567 | // cm_bt = colorMenu->insertItem(tr( "Black on Transparent")); | 568 | // cm_bt = colorMenu->insertItem(tr( "Black on Transparent")); |
568 | cm_br = colorMenu->insertItem(tr( "Black on Pink")); | 569 | cm_br = colorMenu->insertItem(tr( "Black on Pink")); |
569 | cm_rb = colorMenu->insertItem(tr( "Pink on Black")); | 570 | cm_rb = colorMenu->insertItem(tr( "Pink on Black")); |
570 | cm_gy = colorMenu->insertItem(tr( "Green on Yellow")); | 571 | cm_gy = colorMenu->insertItem(tr( "Green on Yellow")); |
571 | cm_bm = colorMenu->insertItem(tr( "Blue on Magenta")); | 572 | cm_bm = colorMenu->insertItem(tr( "Blue on Magenta")); |
572 | cm_mb = colorMenu->insertItem(tr( "Magenta on Blue")); | 573 | cm_mb = colorMenu->insertItem(tr( "Magenta on Blue")); |
573 | cm_cw = colorMenu->insertItem(tr( "Cyan on White")); | 574 | cm_cw = colorMenu->insertItem(tr( "Cyan on White")); |
574 | cm_wc = colorMenu->insertItem(tr( "White on Cyan")); | 575 | cm_wc = colorMenu->insertItem(tr( "White on Cyan")); |
575 | cm_bb = colorMenu->insertItem(tr( "Blue on Black")); | 576 | cm_bb = colorMenu->insertItem(tr( "Blue on Black")); |
576 | cm_ab = colorMenu->insertItem(tr( "Amber on Black")); | 577 | cm_ab = colorMenu->insertItem(tr( "Amber on Black")); |
577 | cm_default = colorMenu->insertItem(tr("default")); | 578 | cm_default = colorMenu->insertItem(tr("default")); |
578 | 579 | ||
579 | #ifdef QT_QWS_OPIE | 580 | #ifdef QT_QWS_OPIE |
580 | 581 | ||
581 | colorMenu->insertItem(tr( "Custom")); | 582 | colorMenu->insertItem(tr( "Custom")); |
582 | #endif | 583 | #endif |
583 | 584 | ||
584 | configMenu->insertItem(tr( "Colors") ,colorMenu); | 585 | configMenu->insertItem(tr( "Colors") ,colorMenu); |
585 | 586 | ||
586 | sessionList = new QPopupMenu(this); | 587 | sessionList = new QPopupMenu(this); |
587 | sessionList-> insertItem ( Resource::loadPixmap ( "konsole/Terminal" ), tr( "new session" ), this, | 588 | sessionList-> insertItem ( Resource::loadPixmap ( "konsole/Terminal" ), tr( "new session" ), this, |
588 | SLOT(newSession()) ); | 589 | SLOT(newSession()) ); |
589 | 590 | ||
590 | // connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) )); | 591 | // connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) )); |
591 | connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) )); | 592 | connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) )); |
592 | connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuIsSelected(int) )); | 593 | connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuIsSelected(int) )); |
593 | connect( tabMenu, SIGNAL( activated(int) ), this, SLOT( tabMenuSelected(int) )); | 594 | connect( tabMenu, SIGNAL( activated(int) ), this, SLOT( tabMenuSelected(int) )); |
594 | connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int))); | 595 | connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int))); |
595 | connect( editCommandListMenu,SIGNAL(activated(int)),this,SLOT(editCommandListMenuSelected(int))); | 596 | connect( editCommandListMenu,SIGNAL(activated(int)),this,SLOT(editCommandListMenuSelected(int))); |
596 | connect( sessionList, SIGNAL(activated(int)), this, SLOT( sessionListSelected(int) ) ); | 597 | connect( sessionList, SIGNAL(activated(int)), this, SLOT( sessionListSelected(int) ) ); |
597 | 598 | ||
598 | menuBar->insertItem( tr("View"), configMenu ); | 599 | menuBar->insertItem( tr("View"), configMenu ); |
599 | menuBar->insertItem( tr("Fonts"), fontList ); | 600 | menuBar->insertItem( tr("Fonts"), fontList ); |
600 | menuBar->insertItem( tr("Sessions"), sessionList ); | 601 | menuBar->insertItem( tr("Sessions"), sessionList ); |
601 | 602 | ||
602 | toolBar = new QToolBar( this ); | 603 | toolBar = new QToolBar( this ); |
603 | 604 | ||
604 | QAction *a; | 605 | QAction *a; |
605 | 606 | ||
606 | // Button Commands | 607 | // Button Commands |
607 | a = new QAction( tr("New"), Resource::loadPixmap( "konsole/Terminal" ), QString::null, 0, this, 0 ); | 608 | a = new QAction( tr("New"), Resource::loadPixmap( "konsole/Terminal" ), QString::null, 0, this, 0 ); |
608 | connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); | 609 | connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); |
609 | a->addTo( toolBar ); | 610 | a->addTo( toolBar ); |
610 | 611 | ||
611 | a = new QAction( tr("Full Screen"), Resource::loadPixmap( "fullscreen" ), QString::null, 0, this, 0 ); | 612 | a = new QAction( tr("Full Screen"), Resource::loadPixmap( "fullscreen" ), QString::null, 0, this, 0 ); |
612 | connect( a, SIGNAL( activated() ), this, SLOT( toggleFullScreen() ) ); | 613 | connect( a, SIGNAL( activated() ), this, SLOT( toggleFullScreen() ) ); |
613 | a->addTo( toolBar ); | 614 | a->addTo( toolBar ); |
614 | 615 | ||
615 | a = new QAction( tr("Zoom"), Resource::loadPixmap( "zoom" ), QString::null, 0, this, 0 ); | 616 | a = new QAction( tr("Zoom"), Resource::loadPixmap( "zoom" ), QString::null, 0, this, 0 ); |
616 | connect( a, SIGNAL( activated() ), this, SLOT( cycleZoom() ) ); | 617 | connect( a, SIGNAL( activated() ), this, SLOT( cycleZoom() ) ); |
617 | a->addTo( toolBar ); | 618 | a->addTo( toolBar ); |
618 | 619 | ||
619 | 620 | ||
620 | a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 ); | 621 | a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 ); |
621 | connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolBar ); | 622 | connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolBar ); |
622 | a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 ); | 623 | a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 ); |
623 | connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolBar ); | 624 | connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolBar ); |
624 | a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 ); | 625 | a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 ); |
625 | connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolBar ); | 626 | connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolBar ); |
626 | a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 ); | 627 | a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 ); |
627 | connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolBar ); | 628 | connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolBar ); |
628 | a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 ); | 629 | a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 ); |
629 | connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolBar ); | 630 | connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolBar ); |
630 | 631 | ||
631 | a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); | 632 | a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); |
632 | connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); | 633 | connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); |
633 | a->addTo( toolBar ); | 634 | a->addTo( toolBar ); |
634 | 635 | ||
635 | secondToolBar = new QToolBar( this ); | 636 | secondToolBar = new QToolBar( this ); |
636 | secondToolBar->setHorizontalStretchable( TRUE ); | 637 | secondToolBar->setHorizontalStretchable( TRUE ); |
637 | 638 | ||
638 | commonCombo = new QComboBox( secondToolBar ); | 639 | commonCombo = new QComboBox( secondToolBar ); |
639 | // commonCombo->setMaximumWidth(236); | 640 | // commonCombo->setMaximumWidth(236); |
640 | 641 | ||
641 | ec_quick = editCommandListMenu->insertItem( tr( "Quick Edit" ) ); | 642 | ec_quick = editCommandListMenu->insertItem( tr( "Quick Edit" ) ); |
642 | if( listHidden) | 643 | if( listHidden) |
643 | { | 644 | { |
644 | secondToolBar->hide(); | 645 | secondToolBar->hide(); |
645 | editCommandListMenu->setItemEnabled(ec_quick ,FALSE); | 646 | editCommandListMenu->setItemEnabled(ec_quick ,FALSE); |
646 | } | 647 | } |
647 | ec_edit = editCommandListMenu->insertItem(tr( "Edit..." ) ); | 648 | ec_edit = editCommandListMenu->insertItem(tr( "Edit..." ) ); |
648 | 649 | ||
649 | cfg.setGroup("Commands"); | 650 | cfg.setGroup("Commands"); |
650 | commonCombo->setInsertionPolicy(QComboBox::AtCurrent); | 651 | commonCombo->setInsertionPolicy(QComboBox::AtCurrent); |
651 | 652 | ||
652 | initCommandList(); | 653 | initCommandList(); |
653 | // for (int i = 0; commonCmds[i] != NULL; i++) { | 654 | // for (int i = 0; commonCmds[i] != NULL; i++) { |
654 | // commonCombo->insertItem( commonCmds[i], i ); | 655 | // commonCombo->insertItem( commonCmds[i], i ); |
655 | // tmp = cfg.readEntry( QString::number(i),""); | 656 | // tmp = cfg.readEntry( QString::number(i),""); |
656 | // if(tmp != "") | 657 | // if(tmp != "") |
657 | // commonCombo->changeItem( tmp,i ); | 658 | // commonCombo->changeItem( tmp,i ); |
658 | // } | 659 | // } |
659 | 660 | ||
660 | connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) )); | 661 | connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) )); |
661 | 662 | ||
662 | sm_none = scrollMenu->insertItem(tr( "None" )); | 663 | sm_none = scrollMenu->insertItem(tr( "None" )); |
663 | sm_left = scrollMenu->insertItem(tr( "Left" )); | 664 | sm_left = scrollMenu->insertItem(tr( "Left" )); |
664 | sm_right = scrollMenu->insertItem(tr( "Right" )); | 665 | sm_right = scrollMenu->insertItem(tr( "Right" )); |
665 | // scrollMenu->insertSeparator(4); | 666 | // scrollMenu->insertSeparator(4); |
666 | // scrollMenu->insertItem(tr( "Horizontal" )); | 667 | // scrollMenu->insertItem(tr( "Horizontal" )); |
667 | 668 | ||
668 | configMenu->insertItem(tr( "ScrollBar" ),scrollMenu); | 669 | configMenu->insertItem(tr( "ScrollBar" ),scrollMenu); |
669 | 670 | ||
670 | configMenu->insertItem(tr( "History..." ), this, SLOT(historyDialog())); | 671 | configMenu->insertItem(tr( "History..." ), this, SLOT(historyDialog())); |
671 | 672 | ||
672 | cm_wrap = configMenu->insertItem(tr( "Wrap" )); | 673 | cm_wrap = configMenu->insertItem(tr( "Wrap" )); |
673 | cfg.setGroup("ScrollBar"); | 674 | cfg.setGroup("ScrollBar"); |
674 | configMenu->setItemChecked(cm_wrap, cfg.readBoolEntry("HorzScroll",0)); | 675 | configMenu->setItemChecked(cm_wrap, cfg.readBoolEntry("HorzScroll",0)); |
675 | 676 | ||
676 | cm_beep = configMenu->insertItem(tr( "Use Beep" )); | 677 | cm_beep = configMenu->insertItem(tr( "Use Beep" )); |
677 | cfg.setGroup("Menubar"); | 678 | cfg.setGroup("Menubar"); |
678 | configMenu->setItemChecked(cm_beep, cfg.readBoolEntry("useBeep",0)); | 679 | configMenu->setItemChecked(cm_beep, cfg.readBoolEntry("useBeep",0)); |
679 | 680 | ||
680 | fullscreen_msg = new QLabel(this); | 681 | fullscreen_msg = new QLabel(this); |
681 | fullscreen_msg-> setAlignment ( AlignCenter | SingleLine ); | 682 | fullscreen_msg-> setAlignment ( AlignCenter | SingleLine ); |
682 | fullscreen_msg-> hide(); | 683 | fullscreen_msg-> hide(); |
683 | fullscreen_msg-> setSizePolicy ( QSizePolicy ( QSizePolicy::Expanding, QSizePolicy::Expanding )); | 684 | fullscreen_msg-> setSizePolicy ( QSizePolicy ( QSizePolicy::Expanding, QSizePolicy::Expanding )); |
684 | fullscreen_msg-> setAutoResize(true); | 685 | fullscreen_msg-> setAutoResize(true); |
685 | fullscreen_msg-> setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 686 | fullscreen_msg-> setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
686 | fullscreen_msg-> setText(tr("To exit fullscreen, tap here.")); | 687 | fullscreen_msg-> setText(tr("To exit fullscreen, tap here.")); |
687 | 688 | ||
688 | fullscreen_timer = new QTimer(this); | 689 | fullscreen_timer = new QTimer(this); |
689 | connect(fullscreen_timer, SIGNAL(timeout()), | 690 | connect(fullscreen_timer, SIGNAL(timeout()), |
690 | this, SLOT(fullscreenTimeout())); | 691 | this, SLOT(fullscreenTimeout())); |
691 | show_fullscreen_msg = true; | 692 | show_fullscreen_msg = true; |
692 | 693 | ||
693 | //scrollMenuSelected(-29); | 694 | //scrollMenuSelected(-29); |
694 | // cfg.setGroup("ScrollBar"); | 695 | // cfg.setGroup("ScrollBar"); |
695 | // if(cfg.readBoolEntry("HorzScroll",0)) { | 696 | // if(cfg.readBoolEntry("HorzScroll",0)) { |
696 | // if(cfg.readNumEntry("Position",2) == 0) | 697 | // if(cfg.readNumEntry("Position",2) == 0) |
697 | // te->setScrollbarLocation(1); | 698 | // te->setScrollbarLocation(1); |
698 | // else | 699 | // else |
699 | // te->setScrollbarLocation(0); | 700 | // te->setScrollbarLocation(0); |
700 | // te->setScrollbarLocation( cfg.readNumEntry("Position",2)); | 701 | // te->setScrollbarLocation( cfg.readNumEntry("Position",2)); |
701 | // te->setWrapAt(120); | 702 | // te->setWrapAt(120); |
702 | // } | 703 | // } |
703 | // create applications ///////////////////////////////////////////////////// | 704 | // create applications ///////////////////////////////////////////////////// |
704 | setCentralWidget(tab); | 705 | setCentralWidget(tab); |
705 | 706 | ||
706 | // load keymaps //////////////////////////////////////////////////////////// | 707 | // load keymaps //////////////////////////////////////////////////////////// |
707 | KeyTrans::loadAll(); | 708 | KeyTrans::loadAll(); |
708 | for (int i = 0; i < KeyTrans::count(); i++) | 709 | for (int i = 0; i < KeyTrans::count(); i++) |
709 | { | 710 | { |
710 | KeyTrans* s = KeyTrans::find(i); | 711 | KeyTrans* s = KeyTrans::find(i); |
711 | assert( s ); | 712 | assert( s ); |
712 | } | 713 | } |
713 | 714 | ||
714 | se_pgm = _pgm; | 715 | se_pgm = _pgm; |
715 | se_args = _args; | 716 | se_args = _args; |
716 | 717 | ||
717 | cfg.setGroup("CommandLine"); | 718 | cfg.setGroup("CommandLine"); |
718 | 719 | ||
719 | if (cfg.hasKey("shell_args")) | 720 | if (cfg.hasKey("shell_args")) |
720 | { | 721 | { |
721 | QStringList se_args_list = cfg.readListEntry("shell_args",'|'); | 722 | QStringList se_args_list = cfg.readListEntry("shell_args",'|'); |
722 | for(uint i = 0; i < se_args_list.count(); i++) | 723 | for(uint i = 0; i < se_args_list.count(); i++) |
723 | { | 724 | { |
724 | se_args.prepend(se_args_list[se_args_list.count() - i - 1].latin1()); | 725 | se_args.prepend(se_args_list[se_args_list.count() - i - 1].latin1()); |
725 | } | 726 | } |
726 | } | 727 | } |
727 | else | 728 | else |
728 | { | 729 | { |
729 | se_args.prepend("--login"); | 730 | se_args.prepend("--login"); |
730 | } | 731 | } |
731 | 732 | ||
732 | se_pgm = cfg.readEntry("shell_bin", QString(se_pgm)); | 733 | se_pgm = cfg.readEntry("shell_bin", QString(se_pgm)); |
733 | 734 | ||
734 | // this is the "documentation" for those who know to look | 735 | // this is the "documentation" for those who know to look |
735 | if (! cfg.hasKey("shell_args")) | 736 | if (! cfg.hasKey("shell_args")) |
736 | { | 737 | { |
737 | cfg.writeEntry("shell_args",QStringList::fromStrList(se_args),'|'); | 738 | cfg.writeEntry("shell_args",QStringList::fromStrList(se_args),'|'); |
738 | } | 739 | } |
739 | if (! cfg.hasKey("shell_bin")) | 740 | if (! cfg.hasKey("shell_bin")) |
740 | { | 741 | { |
741 | cfg.writeEntry("shell_bin",QString(se_pgm)); | 742 | cfg.writeEntry("shell_bin",QString(se_pgm)); |
742 | } | 743 | } |
743 | 744 | ||
744 | parseCommandLine(); | 745 | parseCommandLine(); |
745 | 746 | ||
746 | // read and apply default values /////////////////////////////////////////// | 747 | // read and apply default values /////////////////////////////////////////// |
747 | resize(321, 321); // Dummy. | 748 | resize(321, 321); // Dummy. |
748 | QSize currentSize = size(); | 749 | QSize currentSize = size(); |
749 | if (currentSize != size()) | 750 | if (currentSize != size()) |
750 | defaultSize = size(); | 751 | defaultSize = size(); |
751 | 752 | ||
752 | 753 | ||
753 | /* allows us to catch cancel/escape */ | 754 | /* allows us to catch cancel/escape */ |
754 | reparent ( 0, WStyle_Customize | WStyle_NoBorder, | 755 | reparent ( 0, WStyle_Customize | WStyle_NoBorder, |
755 | QPoint ( 0, 0 )); | 756 | QPoint ( 0, 0 )); |
756 | } | 757 | } |
757 | 758 | ||
758 | void Konsole::show() | 759 | void Konsole::show() |
759 | { | 760 | { |
760 | if ( !nsessions ) | 761 | if ( !nsessions ) |
761 | { | 762 | { |
762 | newSession(); | 763 | newSession(); |
763 | } | 764 | } |
764 | QMainWindow::show(); | 765 | QMainWindow::show(); |
765 | 766 | ||
766 | } | 767 | } |
767 | 768 | ||
768 | void Konsole::initSession(const char*, QStrList &) | 769 | void Konsole::initSession(const char*, QStrList &) |
769 | { | 770 | { |
770 | QMainWindow::show(); | 771 | QMainWindow::show(); |
771 | } | 772 | } |
772 | 773 | ||
773 | Konsole::~Konsole() | 774 | Konsole::~Konsole() |
774 | { | 775 | { |
775 | while (nsessions > 0) | 776 | while (nsessions > 0) |
776 | { | 777 | { |
777 | doneSession(getTe(), 0); | 778 | doneSession(getTe(), 0); |
778 | } | 779 | } |
779 | } | 780 | } |
780 | 781 | ||
781 | void | 782 | void |
782 | Konsole::historyDialog() | 783 | Konsole::historyDialog() |
783 | { | 784 | { |
784 | QDialog *d = new QDialog ( this, "histdlg", true ); | 785 | QDialog *d = new QDialog ( this, "histdlg", true ); |
785 | // d-> setCaption ( tr( "History" )); | 786 | // d-> setCaption ( tr( "History" )); |
786 | 787 | ||
787 | QBoxLayout *lay = new QVBoxLayout ( d, 4, 4 ); | 788 | QBoxLayout *lay = new QVBoxLayout ( d, 4, 4 ); |
788 | 789 | ||
789 | QLabel *l = new QLabel ( tr( "History Lines:" ), d ); | 790 | QLabel *l = new QLabel ( tr( "History Lines:" ), d ); |
790 | lay-> addWidget ( l ); | 791 | lay-> addWidget ( l ); |
791 | 792 | ||
792 | Config cfg( "Konsole" ); | 793 | Config cfg( "Konsole" ); |
793 | cfg.setGroup("History"); | 794 | cfg.setGroup("History"); |
794 | int hist = cfg.readNumEntry("history_lines",300); | 795 | int hist = cfg.readNumEntry("history_lines",300); |
795 | int avg_line = cfg.readNumEntry("avg_line_length",60); | 796 | int avg_line = cfg.readNumEntry("avg_line_length",60); |
796 | 797 | ||
797 | QSpinBox *spin = new QSpinBox ( 1, 100000, 20, d ); | 798 | QSpinBox *spin = new QSpinBox ( 1, 100000, 20, d ); |
798 | spin-> setValue ( hist ); | 799 | spin-> setValue ( hist ); |
799 | spin-> setWrapping ( true ); | 800 | spin-> setWrapping ( true ); |
800 | spin-> setButtonSymbols ( QSpinBox::PlusMinus ); | 801 | spin-> setButtonSymbols ( QSpinBox::PlusMinus ); |
801 | lay-> addWidget ( spin ); | 802 | lay-> addWidget ( spin ); |
802 | 803 | ||
803 | if ( d-> exec ( ) == QDialog::Accepted ) | 804 | if ( d-> exec ( ) == QDialog::Accepted ) |
804 | { | 805 | { |
805 | cfg.writeEntry("history_lines", spin->value()); | 806 | cfg.writeEntry("history_lines", spin->value()); |
806 | cfg.writeEntry("avg_line_length", avg_line); | 807 | cfg.writeEntry("avg_line_length", avg_line); |
807 | if (getTe() != NULL) | 808 | if (getTe() != NULL) |
808 | { | 809 | { |
809 | getTe()->currentSession->setHistory(true); | 810 | getTe()->currentSession->setHistory(true); |
810 | } | 811 | } |
811 | } | 812 | } |
812 | 813 | ||
813 | delete d; | 814 | delete d; |
814 | } | 815 | } |
815 | 816 | ||
816 | 817 | ||
817 | void Konsole::cycleZoom() | 818 | void Konsole::cycleZoom() |
818 | { | 819 | { |
819 | TEWidget* te = getTe(); | 820 | TEWidget* te = getTe(); |
820 | QFont font = te->getVTFont(); | 821 | QFont font = te->getVTFont(); |
821 | int size = font.pointSize(); | 822 | int size = font.pointSize(); |
822 | changeFontSize(1); | 823 | changeFontSize(1); |
823 | font = te->getVTFont(); | 824 | font = te->getVTFont(); |
824 | if (font.pointSize() <= size) | 825 | if (font.pointSize() <= size) |
825 | { | 826 | { |
826 | do | 827 | do |
827 | { | 828 | { |
828 | font = te->getVTFont(); | 829 | font = te->getVTFont(); |
829 | size = font.pointSize(); | 830 | size = font.pointSize(); |
830 | changeFontSize(-1); | 831 | changeFontSize(-1); |
831 | font = te->getVTFont(); | 832 | font = te->getVTFont(); |
832 | } | 833 | } |
833 | while (font.pointSize() < size); | 834 | while (font.pointSize() < size); |
834 | } | 835 | } |
835 | } | 836 | } |
836 | 837 | ||
837 | void Konsole::changeFontSize(int delta) | 838 | void Konsole::changeFontSize(int delta) |
838 | { | 839 | { |
839 | // printf("delta font size %d\n", delta); | 840 | // printf("delta font size %d\n", delta); |
840 | TEWidget* te = getTe(); | 841 | TEWidget* te = getTe(); |
841 | QFont font = te->getVTFont(); | 842 | QFont font = te->getVTFont(); |
842 | int size = font.pointSize(); | 843 | int size = font.pointSize(); |
843 | int closest = delta > 0? 10000 : -10000; | 844 | int closest = delta > 0? 10000 : -10000; |
844 | int closest_font = -1; | 845 | int closest_font = -1; |
845 | for(uint i = 0; i < fonts.count(); i++) | 846 | for(uint i = 0; i < fonts.count(); i++) |
846 | { | 847 | { |
847 | if (fonts.at(i)->getFont() == font) | 848 | if (fonts.at(i)->getFont() == font) |
848 | { | 849 | { |
849 | if (delta > 0) | 850 | if (delta > 0) |
850 | { | 851 | { |
851 | if (i+1 < fonts.count() | 852 | if (i+1 < fonts.count() |
852 | && fonts.at(i+1)->getFamilyNum() == fonts.at(i)->getFamilyNum()) | 853 | && fonts.at(i+1)->getFamilyNum() == fonts.at(i)->getFamilyNum()) |
853 | { | 854 | { |
854 | setFont(i+1); | 855 | setFont(i+1); |
855 | printf("font %d\n", i+1); | 856 | printf("font %d\n", i+1); |
856 | return; | 857 | return; |
857 | } | 858 | } |
858 | } | 859 | } |
859 | else if (delta < 0) | 860 | else if (delta < 0) |
860 | { | 861 | { |
861 | if (i > 0 | 862 | if (i > 0 |
862 | && fonts.at(i-1)->getFamilyNum() == fonts.at(i)->getFamilyNum()) | 863 | && fonts.at(i-1)->getFamilyNum() == fonts.at(i)->getFamilyNum()) |
863 | { | 864 | { |
864 | setFont(i-1); | 865 | setFont(i-1); |
865 | printf("font %d\n", i-1); | 866 | printf("font %d\n", i-1); |
866 | return; | 867 | return; |
867 | } | 868 | } |
868 | } | 869 | } |
869 | } | 870 | } |
870 | int fsize = fonts.at(i)->getSize(); | 871 | int fsize = fonts.at(i)->getSize(); |
871 | printf("%d size=%d fsize=%d closest=%d\n", i, size, fsize, closest); | 872 | printf("%d size=%d fsize=%d closest=%d\n", i, size, fsize, closest); |
872 | if ((delta > 0 && fsize > size && fsize < closest) | 873 | if ((delta > 0 && fsize > size && fsize < closest) |
873 | || (delta < 0 && fsize < size && fsize > closest)) | 874 | || (delta < 0 && fsize < size && fsize > closest)) |
874 | { | 875 | { |
875 | closest = fsize; | 876 | closest = fsize; |
876 | closest_font = i; | 877 | closest_font = i; |
877 | } | 878 | } |
878 | } | 879 | } |
879 | if (closest_font >= 0) | 880 | if (closest_font >= 0) |
880 | { | 881 | { |
881 | printf("font closest %d (%d)\n", closest_font, closest); | 882 | printf("font closest %d (%d)\n", closest_font, closest); |
882 | setFont(closest_font); | 883 | setFont(closest_font); |
883 | } | 884 | } |
884 | } | 885 | } |
885 | 886 | ||
886 | int Konsole::findFont(const QString& name, int size, bool exactMatch) | 887 | int Konsole::findFont(const QString& name, int size, bool exactMatch) |
887 | { | 888 | { |
888 | for(uint i = 0; i < fonts.count(); i++) | 889 | for(uint i = 0; i < fonts.count(); i++) |
889 | { | 890 | { |
890 | if (fonts.at(i)->getName() == name | 891 | if (fonts.at(i)->getName() == name |
891 | && fonts.at(i)->getSize() == size) | 892 | && fonts.at(i)->getSize() == size) |
892 | { | 893 | { |
893 | return(i); | 894 | return(i); |
894 | } | 895 | } |
895 | } | 896 | } |
896 | if (exactMatch) | 897 | if (exactMatch) |
897 | { | 898 | { |
898 | return(-1); | 899 | return(-1); |
899 | } | 900 | } |
900 | for(uint i = 0; i < fonts.count(); i++) | 901 | for(uint i = 0; i < fonts.count(); i++) |
901 | { | 902 | { |
902 | if (fonts.at(i)->getSize() == size) | 903 | if (fonts.at(i)->getSize() == size) |
903 | { | 904 | { |
904 | return(i); | 905 | return(i); |
905 | } | 906 | } |
906 | } | 907 | } |
907 | return(-1); | 908 | return(-1); |
908 | } | 909 | } |
909 | 910 | ||
910 | void Konsole::setFont(int f) | 911 | void Konsole::setFont(int f) |
911 | { | 912 | { |
912 | VTFont* font = fonts.at(f); | 913 | VTFont* font = fonts.at(f); |
913 | if (font) | 914 | if (font) |
914 | { | 915 | { |
915 | TEWidget* te = getTe(); | 916 | TEWidget* te = getTe(); |
916 | if (te != 0) | 917 | if (te != 0) |
917 | { | 918 | { |
918 | te->setVTFont(font->getFont()); | 919 | te->setVTFont(font->getFont()); |
919 | } | 920 | } |
920 | cfont = f; | 921 | cfont = f; |
921 | 922 | ||
922 | int familyNum = font->getFamilyNum(); | 923 | int familyNum = font->getFamilyNum(); |
923 | int size = font->getSize(); | 924 | int size = font->getSize(); |
924 | printf("familyNum = %d size = %d count=%d\n", familyNum, size, | 925 | printf("familyNum = %d size = %d count=%d\n", familyNum, size, |
925 | fontList->count()); | 926 | fontList->count()); |
926 | for(int i = 0; i < (int)fontList->count(); i++) | 927 | for(int i = 0; i < (int)fontList->count(); i++) |
927 | { | 928 | { |
928 | fontList->setItemChecked(i + 1000, i == familyNum); | 929 | fontList->setItemChecked(i + 1000, i == familyNum); |
929 | } | 930 | } |
930 | for(int i = 0; i < (int)fonts.count(); i++) | 931 | for(int i = 0; i < (int)fonts.count(); i++) |
931 | { | 932 | { |
932 | fontList->setItemChecked(i, fonts.at(i)->getFamilyNum() == familyNum | 933 | fontList->setItemChecked(i, fonts.at(i)->getFamilyNum() == familyNum |
933 | && fonts.at(i)->getSize() == size); | 934 | && fonts.at(i)->getSize() == size); |
934 | } | 935 | } |
935 | Config cfg( "Konsole" ); | 936 | Config cfg( "Konsole" ); |
936 | cfg.setGroup("Font"); | 937 | cfg.setGroup("Font"); |
937 | QString ss = "Session"+ QString::number(tab->currentPageIndex()+1); | 938 | QString ss = "Session"+ QString::number(tab->currentPageIndex()+1); |
938 | if (tab->currentPageIndex() == 0) | 939 | if (tab->currentPageIndex() == 0) |
939 | { | 940 | { |
940 | cfg.writeEntry("FontName", fonts.at(cfont)->getFamily()); | 941 | cfg.writeEntry("FontName", fonts.at(cfont)->getFamily()); |
941 | cfg.writeEntry("FontSize", fonts.at(cfont)->getSize()); | 942 | cfg.writeEntry("FontSize", fonts.at(cfont)->getSize()); |
942 | } | 943 | } |
943 | cfg.writeEntry("FontName"+ss, fonts.at(cfont)->getFamily()); | 944 | cfg.writeEntry("FontName"+ss, fonts.at(cfont)->getFamily()); |
944 | cfg.writeEntry("FontSize"+ss, fonts.at(cfont)->getSize()); | 945 | cfg.writeEntry("FontSize"+ss, fonts.at(cfont)->getSize()); |
945 | } | 946 | } |
946 | } | 947 | } |
947 | 948 | ||
948 | #if 0 | 949 | #if 0 |
949 | void Konsole::fontChanged(int f) | 950 | void Konsole::fontChanged(int f) |
950 | { | 951 | { |
951 | VTFont* font = fonts.at(f); | 952 | VTFont* font = fonts.at(f); |
952 | if (font != 0) | 953 | if (font != 0) |
953 | { | 954 | { |
954 | for(uint i = 0; i < fonts.count(); i++) | 955 | for(uint i = 0; i < fonts.count(); i++) |
955 | { | 956 | { |
956 | fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE); | 957 | fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE); |
957 | } | 958 | } |
958 | 959 | ||
959 | cfont = f; | 960 | cfont = f; |
960 | 961 | ||
961 | TEWidget* te = getTe(); | 962 | TEWidget* te = getTe(); |
962 | if (te != 0) | 963 | if (te != 0) |
963 | { | 964 | { |
964 | te->setVTFont(font->getFont()); | 965 | te->setVTFont(font->getFont()); |
965 | } | 966 | } |
966 | } | 967 | } |
967 | } | 968 | } |
968 | #endif | 969 | #endif |
969 | 970 | ||
970 | 971 | ||
971 | void Konsole::enterCommand(int c) | 972 | void Konsole::enterCommand(int c) |
972 | { | 973 | { |
973 | TEWidget* te = getTe(); | 974 | TEWidget* te = getTe(); |
974 | if (te != 0) | 975 | if (te != 0) |
975 | { | 976 | { |
976 | if(!commonCombo->editable()) | 977 | if(!commonCombo->editable()) |
977 | { | 978 | { |
978 | QString text = commonCombo->text(c); //commonCmds[c]; | 979 | QString text = commonCombo->text(c); //commonCmds[c]; |
979 | te->emitText(text); | 980 | te->emitText(text); |
980 | } | 981 | } |
981 | else | 982 | else |
982 | { | 983 | { |
983 | changeCommand( commonCombo->text(c), c); | 984 | changeCommand( commonCombo->text(c), c); |
984 | } | 985 | } |
985 | } | 986 | } |
986 | } | 987 | } |
987 | 988 | ||
988 | void Konsole::hitEnter() | 989 | void Konsole::hitEnter() |
989 | { | 990 | { |
990 | TEWidget* te = getTe(); | 991 | TEWidget* te = getTe(); |
991 | if (te != 0) | 992 | if (te != 0) |
992 | { | 993 | { |
993 | te->emitText(QString("\r")); | 994 | te->emitText(QString("\r")); |
994 | } | 995 | } |
995 | } | 996 | } |
996 | 997 | ||
997 | void Konsole::hitSpace() | 998 | void Konsole::hitSpace() |
998 | { | 999 | { |
999 | TEWidget* te = getTe(); | 1000 | TEWidget* te = getTe(); |
1000 | if (te != 0) | 1001 | if (te != 0) |
1001 | { | 1002 | { |
1002 | te->emitText(QString(" ")); | 1003 | te->emitText(QString(" ")); |
1003 | } | 1004 | } |
1004 | } | 1005 | } |
1005 | 1006 | ||
1006 | void Konsole::hitTab() | 1007 | void Konsole::hitTab() |
1007 | { | 1008 | { |
1008 | TEWidget* te = getTe(); | 1009 | TEWidget* te = getTe(); |
1009 | if (te != 0) | 1010 | if (te != 0) |
1010 | { | 1011 | { |
1011 | te->emitText(QString("\t")); | 1012 | te->emitText(QString("\t")); |
1012 | } | 1013 | } |
1013 | } | 1014 | } |
1014 | 1015 | ||
1015 | void Konsole::hitPaste() | 1016 | void Konsole::hitPaste() |
1016 | { | 1017 | { |
1017 | TEWidget* te = getTe(); | 1018 | TEWidget* te = getTe(); |
1018 | if (te != 0) | 1019 | if (te != 0) |
1019 | { | 1020 | { |
1020 | te->pasteClipboard(); | 1021 | te->pasteClipboard(); |
1021 | } | 1022 | } |
1022 | } | 1023 | } |
1023 | 1024 | ||
1024 | void Konsole::hitUp() | 1025 | void Konsole::hitUp() |
1025 | { | 1026 | { |
1026 | TEWidget* te = getTe(); | 1027 | TEWidget* te = getTe(); |
1027 | if (te != 0) | 1028 | if (te != 0) |
1028 | { | 1029 | { |
1029 | QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Up, 0, 0); | 1030 | QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Up, 0, 0); |
1030 | QApplication::sendEvent( te, &ke ); | 1031 | QApplication::sendEvent( te, &ke ); |
1031 | } | 1032 | } |
1032 | } | 1033 | } |
1033 | 1034 | ||
1034 | void Konsole::hitDown() | 1035 | void Konsole::hitDown() |
1035 | { | 1036 | { |
1036 | TEWidget* te = getTe(); | 1037 | TEWidget* te = getTe(); |
1037 | if (te != 0) | 1038 | if (te != 0) |
1038 | { | 1039 | { |
1039 | QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Down, 0, 0); | 1040 | QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Down, 0, 0); |
1040 | QApplication::sendEvent( te, &ke ); | 1041 | QApplication::sendEvent( te, &ke ); |
1041 | } | 1042 | } |
1042 | } | 1043 | } |
1043 | 1044 | ||
1044 | /** | 1045 | /** |
1045 | This function calculates the size of the external widget | 1046 | This function calculates the size of the external widget |
1046 | needed for the internal widget to be | 1047 | needed for the internal widget to be |
1047 | */ | 1048 | */ |
1048 | QSize Konsole::calcSize(int columns, int lines) | 1049 | QSize Konsole::calcSize(int columns, int lines) |
1049 | { | 1050 | { |
1050 | TEWidget* te = getTe(); | 1051 | TEWidget* te = getTe(); |
1051 | if (te != 0) | 1052 | if (te != 0) |
1052 | { | 1053 | { |
1053 | QSize size = te->calcSize(columns, lines); | 1054 | QSize size = te->calcSize(columns, lines); |
1054 | return size; | 1055 | return size; |
1055 | } | 1056 | } |
1056 | else | 1057 | else |
1057 | { | 1058 | { |
1058 | QSize size; | 1059 | QSize size; |
1059 | return size; | 1060 | return size; |
1060 | } | 1061 | } |
1061 | } | 1062 | } |
1062 | 1063 | ||
1063 | /** | 1064 | /** |
1064 | sets application window to a size based on columns X lines of the te | 1065 | sets application window to a size based on columns X lines of the te |
1065 | guest widget. Call with (0,0) for setting default size. | 1066 | guest widget. Call with (0,0) for setting default size. |
1066 | */ | 1067 | */ |
1067 | 1068 | ||
1068 | void Konsole::setColLin(int columns, int lines) | 1069 | void Konsole::setColLin(int columns, int lines) |
1069 | { | 1070 | { |
1070 | qDebug("konsole::setColLin:: Columns %d", columns); | 1071 | odebug << "konsole::setColLin:: Columns " << columns << "" << oendl; |
1071 | 1072 | ||
1072 | if ((columns==0) || (lines==0)) | 1073 | if ((columns==0) || (lines==0)) |
1073 | { | 1074 | { |
1074 | if (defaultSize.isEmpty()) // not in config file : set default value | 1075 | if (defaultSize.isEmpty()) // not in config file : set default value |
1075 | { | 1076 | { |
1076 | defaultSize = calcSize(80,24); | 1077 | defaultSize = calcSize(80,24); |
1077 | // notifySize(24,80); // set menu items (strange arg order !) | 1078 | // notifySize(24,80); // set menu items (strange arg order !) |
1078 | } | 1079 | } |
1079 | resize(defaultSize); | 1080 | resize(defaultSize); |
1080 | } | 1081 | } |
1081 | else | 1082 | else |
1082 | { | 1083 | { |
1083 | resize(calcSize(columns, lines)); | 1084 | resize(calcSize(columns, lines)); |
1084 | // notifySize(lines,columns); // set menu items (strange arg order !) | 1085 | // notifySize(lines,columns); // set menu items (strange arg order !) |
1085 | } | 1086 | } |
1086 | } | 1087 | } |
1087 | 1088 | ||
1088 | /* | 1089 | /* |
1089 | void Konsole::setFont(int fontno) | 1090 | void Konsole::setFont(int fontno) |
1090 | { | 1091 | { |
1091 | QFont f; | 1092 | QFont f; |
1092 | if (fontno == 0) | 1093 | if (fontno == 0) |
1093 | f = defaultFont = QFont( "Helvetica", 12 ); | 1094 | f = defaultFont = QFont( "Helvetica", 12 ); |
1094 | else | 1095 | else |
1095 | if (fonts[fontno][0] == '-') | 1096 | if (fonts[fontno][0] == '-') |
1096 | f.setRawName( fonts[fontno] ); | 1097 | f.setRawName( fonts[fontno] ); |
1097 | else | 1098 | else |
1098 | { | 1099 | { |
1099 | f.setFamily(fonts[fontno]); | 1100 | f.setFamily(fonts[fontno]); |
1100 | f.setRawMode( TRUE ); | 1101 | f.setRawMode( TRUE ); |
1101 | } | 1102 | } |
1102 | if ( !f.exactMatch() && fontno != 0) | 1103 | if ( !f.exactMatch() && fontno != 0) |
1103 | { | 1104 | { |
1104 | QString msg = i18n("Font `%1' not found.\nCheck README.linux.console for help.").arg(fonts[fontno]); | 1105 | QString msg = i18n("Font `%1' not found.\nCheck README.linux.console for help.").arg(fonts[fontno]); |
1105 | QMessageBox(this, msg); | 1106 | QMessageBox(this, msg); |
1106 | return; | 1107 | return; |
1107 | } | 1108 | } |
1108 | if (se) se->setFontNo(fontno); | 1109 | if (se) se->setFontNo(fontno); |
1109 | te->setVTFont(f); | 1110 | te->setVTFont(f); |
1110 | n_font = fontno; | 1111 | n_font = fontno; |
1111 | } | 1112 | } |
1112 | */ | 1113 | */ |
1113 | 1114 | ||
1114 | // --| color selection |------------------------------------------------------- | 1115 | // --| color selection |------------------------------------------------------- |
1115 | 1116 | ||
1116 | void Konsole::changeColumns(int /*columns*/) | 1117 | void Konsole::changeColumns(int /*columns*/) |
1117 | { //FIXME this seems to cause silliness when reset command is executed | 1118 | { //FIXME this seems to cause silliness when reset command is executed |
1118 | // qDebug("change columns"); | 1119 | // odebug << "change columns" << oendl; |
1119 | // TEWidget* te = getTe(); | 1120 | // TEWidget* te = getTe(); |
1120 | // if (te != 0) { | 1121 | // if (te != 0) { |
1121 | // setColLin(columns,te->Lines()); | 1122 | // setColLin(columns,te->Lines()); |
1122 | // te->update(); | 1123 | // te->update(); |
1123 | // } | 1124 | // } |
1124 | } | 1125 | } |
1125 | 1126 | ||
1126 | //FIXME: If a child dies during session swap, | 1127 | //FIXME: If a child dies during session swap, |
1127 | // this routine might be called before | 1128 | // this routine might be called before |
1128 | // session swap is completed. | 1129 | // session swap is completed. |
1129 | 1130 | ||
1130 | void Konsole::doneSession(TEWidget* te, int ) | 1131 | void Konsole::doneSession(TEWidget* te, int ) |
1131 | { | 1132 | { |
1132 | // TEWidget *te = NULL; | 1133 | // TEWidget *te = NULL; |
1133 | // if (sess->currentSession == tab->currentPage()) { | 1134 | // if (sess->currentSession == tab->currentPage()) { |
1134 | // printf("done current session\n"); | 1135 | // printf("done current session\n"); |
1135 | // te = getTe(); | 1136 | // te = getTe(); |
1136 | // } else { | 1137 | // } else { |
1137 | // int currentPage = tab->currentPageIndex(); | 1138 | // int currentPage = tab->currentPageIndex(); |
1138 | // printf("done not current session\n"); | 1139 | // printf("done not current session\n"); |
1139 | // for(int i = 0; i < nsessions; i++) { | 1140 | // for(int i = 0; i < nsessions; i++) { |
1140 | // tab->setCurrentPage(i); | 1141 | // tab->setCurrentPage(i); |
1141 | // printf("find session %d tab page %x session %x\n", | 1142 | // printf("find session %d tab page %x session %x\n", |
1142 | // i, tab->currentPage(), sess->currentSession); | 1143 | // i, tab->currentPage(), sess->currentSession); |
1143 | // if (tab->currentPage() == sess->currentSession) { | 1144 | // if (tab->currentPage() == sess->currentSession) { |
1144 | // printf("found session %d\n", i); | 1145 | // printf("found session %d\n", i); |
1145 | // te = tab->currentPage(); | 1146 | // te = tab->currentPage(); |
1146 | // break; | 1147 | // break; |
1147 | // } | 1148 | // } |
1148 | // } | 1149 | // } |
1149 | // tab->setCurrentPage(currentPage); | 1150 | // tab->setCurrentPage(currentPage); |
1150 | // } | 1151 | // } |
1151 | if (te != 0) | 1152 | if (te != 0) |
1152 | { | 1153 | { |
1153 | te->currentSession->setConnect(FALSE); | 1154 | te->currentSession->setConnect(FALSE); |
1154 | tab->removeTab(te); | 1155 | tab->removeTab(te); |
1155 | delete te->currentSession; | 1156 | delete te->currentSession; |
1156 | delete te; | 1157 | delete te; |
1157 | sessionList->removeItem(nsessions); | 1158 | sessionList->removeItem(nsessions); |
1158 | nsessions--; | 1159 | nsessions--; |
1159 | } | 1160 | } |
1160 | if (nsessions == 0) | 1161 | if (nsessions == 0) |
1161 | { | 1162 | { |
1162 | close(); | 1163 | close(); |
1163 | } | 1164 | } |
1164 | } | 1165 | } |
1165 | 1166 | ||
1166 | void Konsole::changeTitle(TEWidget* te, const QString& newTitle ) | 1167 | void Konsole::changeTitle(TEWidget* te, const QString& newTitle ) |
1167 | { | 1168 | { |
1168 | if (te == getTe()) | 1169 | if (te == getTe()) |
1169 | { | 1170 | { |
1170 | setCaption( newTitle + " - " + tr( "Konsole " ) ); | 1171 | setCaption( newTitle + " - " + tr( "Konsole " ) ); |
1171 | } | 1172 | } |
1172 | } | 1173 | } |
1173 | 1174 | ||
1174 | 1175 | ||
1175 | void Konsole::newSession() | 1176 | void Konsole::newSession() |
1176 | { | 1177 | { |
1177 | if(nsessions < 15) | 1178 | if(nsessions < 15) |
1178 | { // seems to be something weird about 16 tabs on the Zaurus.... memory? | 1179 | { // seems to be something weird about 16 tabs on the Zaurus.... memory? |
1179 | TEWidget* te = new TEWidget(tab); | 1180 | TEWidget* te = new TEWidget(tab); |
1180 | Config cfg( "Konsole" ); | 1181 | Config cfg( "Konsole" ); |
1181 | cfg.setGroup("Menubar"); | 1182 | cfg.setGroup("Menubar"); |
1182 | 1183 | ||
1183 | // FIXME use more defaults from config file | 1184 | // FIXME use more defaults from config file |
1184 | te->useBeep=cfg.readBoolEntry("useBeep",0); | 1185 | te->useBeep=cfg.readBoolEntry("useBeep",0); |
1185 | 1186 | ||
1186 | // te->setBackgroundMode(PaletteBase); //we want transparent!! | 1187 | // te->setBackgroundMode(PaletteBase); //we want transparent!! |
1187 | 1188 | ||
1188 | cfg.setGroup("Font"); | 1189 | cfg.setGroup("Font"); |
1189 | QString sn = "Session" + QString::number(nsessions+1); | 1190 | QString sn = "Session" + QString::number(nsessions+1); |
1190 | printf("read font session %s\n", sn.latin1()); | 1191 | printf("read font session %s\n", sn.latin1()); |
1191 | QString fontName = cfg.readEntry("FontName"+sn, | 1192 | QString fontName = cfg.readEntry("FontName"+sn, |
1192 | cfg.readEntry("FontName", | 1193 | cfg.readEntry("FontName", |
1193 | fonts.at(cfont)->getFamily())); | 1194 | fonts.at(cfont)->getFamily())); |
1194 | int fontSize = cfg.readNumEntry("FontSize"+sn, | 1195 | int fontSize = cfg.readNumEntry("FontSize"+sn, |
1195 | cfg.readNumEntry("FontSize", | 1196 | cfg.readNumEntry("FontSize", |
1196 | fonts.at(cfont)->getSize())); | 1197 | fonts.at(cfont)->getSize())); |
1197 | cfont = findFont(fontName, fontSize, false); | 1198 | cfont = findFont(fontName, fontSize, false); |
1198 | printf("lookup font %s size %d got %d\n", fontName.latin1(), fontSize, cfont); | 1199 | printf("lookup font %s size %d got %d\n", fontName.latin1(), fontSize, cfont); |
1199 | if (cfont < 0) | 1200 | if (cfont < 0) |
1200 | cfont = 0; | 1201 | cfont = 0; |
1201 | te->setVTFont(fonts.at(cfont)->getFont()); | 1202 | te->setVTFont(fonts.at(cfont)->getFont()); |
1202 | 1203 | ||
1203 | tab->addTab(te); | 1204 | tab->addTab(te); |
1204 | TESession* se = new TESession(this, te, se_pgm, se_args, "xterm"); | 1205 | TESession* se = new TESession(this, te, se_pgm, se_args, "xterm"); |
1205 | te->currentSession = se; | 1206 | te->currentSession = se; |
1206 | connect( se, SIGNAL(done(TEWidget*,int)), this, SLOT(doneSession(TEWidget*,int)) ); | 1207 | connect( se, SIGNAL(done(TEWidget*,int)), this, SLOT(doneSession(TEWidget*,int)) ); |
1207 | connect( se, SIGNAL(changeTitle(TEWidget*,const QString&)), this, | 1208 | connect( se, SIGNAL(changeTitle(TEWidget*,const QString&)), this, |
1208 | SLOT(changeTitle(TEWidget*,const QString&)) ); | 1209 | SLOT(changeTitle(TEWidget*,const QString&)) ); |
1209 | connect(te, SIGNAL(changeFontSize(int)), this, SLOT(changeFontSize(int))); | 1210 | connect(te, SIGNAL(changeFontSize(int)), this, SLOT(changeFontSize(int))); |
1210 | connect(te, SIGNAL(changeSession(int)), this, SLOT(changeSession(int))); | 1211 | connect(te, SIGNAL(changeSession(int)), this, SLOT(changeSession(int))); |
1211 | connect(te, SIGNAL(newSession()), this, SLOT(newSession())); | 1212 | connect(te, SIGNAL(newSession()), this, SLOT(newSession())); |
1212 | connect(te, SIGNAL(toggleFullScreen()), this, SLOT(toggleFullScreen())); | 1213 | connect(te, SIGNAL(toggleFullScreen()), this, SLOT(toggleFullScreen())); |
1213 | connect(te, SIGNAL(setFullScreen(bool)), this, SLOT(setFullScreen(bool))); | 1214 | connect(te, SIGNAL(setFullScreen(bool)), this, SLOT(setFullScreen(bool))); |
1214 | se->run(); | 1215 | se->run(); |
1215 | se->setConnect(TRUE); | 1216 | se->setConnect(TRUE); |
1216 | se->setHistory(b_scroll); | 1217 | se->setHistory(b_scroll); |
1217 | nsessions++; | 1218 | nsessions++; |
1218 | sessionList->insertItem(QString::number(nsessions), nsessions); | 1219 | sessionList->insertItem(QString::number(nsessions), nsessions); |
1219 | sessionListSelected(nsessions); | 1220 | sessionListSelected(nsessions); |
1220 | doWrap(); | 1221 | doWrap(); |
1221 | setColor(nsessions-1); | 1222 | setColor(nsessions-1); |
1222 | } | 1223 | } |
1223 | } | 1224 | } |
1224 | 1225 | ||
1225 | TEWidget* Konsole::getTe() | 1226 | TEWidget* Konsole::getTe() |
1226 | { | 1227 | { |
1227 | if (nsessions) | 1228 | if (nsessions) |
1228 | { | 1229 | { |
1229 | return (TEWidget *) tab->currentPage(); | 1230 | return (TEWidget *) tab->currentPage(); |
1230 | } | 1231 | } |
1231 | else | 1232 | else |
1232 | { | 1233 | { |
1233 | return 0; | 1234 | return 0; |
1234 | } | 1235 | } |
1235 | } | 1236 | } |
1236 | 1237 | ||
1237 | void Konsole::sessionListSelected(int id) | 1238 | void Konsole::sessionListSelected(int id) |
1238 | { | 1239 | { |
1239 | if (id < 0) | 1240 | if (id < 0) |
1240 | { | 1241 | { |
1241 | return; | 1242 | return; |
1242 | } | 1243 | } |
1243 | QString selected = sessionList->text(id); | 1244 | QString selected = sessionList->text(id); |
1244 | EKNumTabBar *tabBar = tab->getTabBar(); | 1245 | EKNumTabBar *tabBar = tab->getTabBar(); |
1245 | 1246 | ||
1246 | int n = 0; | 1247 | int n = 0; |
1247 | for(int i = 0; n < tabBar->count(); i++) | 1248 | for(int i = 0; n < tabBar->count(); i++) |
1248 | { | 1249 | { |
1249 | if (tabBar->tab(i)) | 1250 | if (tabBar->tab(i)) |
1250 | { | 1251 | { |
1251 | // printf("selected = %s tab %d = %s\n", selected.latin1(), | 1252 | // printf("selected = %s tab %d = %s\n", selected.latin1(), |
1252 | // i, tabBar->tab(i)->text().latin1()); | 1253 | // i, tabBar->tab(i)->text().latin1()); |
1253 | if (tabBar->tab(i)->text() == selected) | 1254 | if (tabBar->tab(i)->text() == selected) |
1254 | { | 1255 | { |
1255 | tab->setCurrentPage(i); | 1256 | tab->setCurrentPage(i); |
1256 | break; | 1257 | break; |
1257 | } | 1258 | } |
1258 | n++; | 1259 | n++; |
1259 | } | 1260 | } |
1260 | } | 1261 | } |
1261 | } | 1262 | } |
1262 | 1263 | ||
1263 | 1264 | ||
1264 | void Konsole::changeSession(int delta) | 1265 | void Konsole::changeSession(int delta) |
1265 | { | 1266 | { |
1266 | printf("delta session %d\n", delta); | 1267 | printf("delta session %d\n", delta); |
1267 | QTabBar *tabBar = tab->getTabBar(); | 1268 | QTabBar *tabBar = tab->getTabBar(); |
1268 | int i = tabBar->tab(tabBar->currentTab())->text().toInt() - 1; | 1269 | int i = tabBar->tab(tabBar->currentTab())->text().toInt() - 1; |
1269 | i += delta; | 1270 | i += delta; |
1270 | if (i < 0) | 1271 | if (i < 0) |
1271 | i += tabBar->count(); | 1272 | i += tabBar->count(); |
1272 | if (i >= tabBar->count()) | 1273 | if (i >= tabBar->count()) |
1273 | i -= tabBar->count(); | 1274 | i -= tabBar->count(); |
1274 | 1275 | ||
1275 | QString selected = QString::number(i+1); | 1276 | QString selected = QString::number(i+1); |
1276 | int n = 0; | 1277 | int n = 0; |
1277 | for(int i = 0; n < tabBar->count(); i++) | 1278 | for(int i = 0; n < tabBar->count(); i++) |
1278 | { | 1279 | { |
1279 | if (tabBar->tab(i)) | 1280 | if (tabBar->tab(i)) |
1280 | { | 1281 | { |
1281 | printf("selected = %s tab %d = %s\n", selected.latin1(), | 1282 | printf("selected = %s tab %d = %s\n", selected.latin1(), |
1282 | i, tabBar->tab(i)->text().latin1()); | 1283 | i, tabBar->tab(i)->text().latin1()); |
1283 | if (tabBar->tab(i)->text() == selected) | 1284 | if (tabBar->tab(i)->text() == selected) |
1284 | { | 1285 | { |
1285 | tab->setCurrentPage(i); | 1286 | tab->setCurrentPage(i); |
1286 | break; | 1287 | break; |
1287 | } | 1288 | } |
1288 | n++; | 1289 | n++; |
1289 | } | 1290 | } |
1290 | } | 1291 | } |
1291 | } | 1292 | } |
1292 | 1293 | ||
1293 | void Konsole::switchSession(QWidget* w) | 1294 | void Konsole::switchSession(QWidget* w) |
1294 | { | 1295 | { |
1295 | TEWidget* te = (TEWidget *) w; | 1296 | TEWidget* te = (TEWidget *) w; |
1296 | QFont teFnt = te->getVTFont(); | 1297 | QFont teFnt = te->getVTFont(); |
1297 | int familyNum = -1; | 1298 | int familyNum = -1; |
1298 | 1299 | ||
1299 | for(uint i = 0; i < fonts.count(); i++) | 1300 | for(uint i = 0; i < fonts.count(); i++) |
1300 | { | 1301 | { |
1301 | VTFont *fnt = fonts.at(i); | 1302 | VTFont *fnt = fonts.at(i); |
1302 | bool cf = fnt->getFont() == teFnt; | 1303 | bool cf = fnt->getFont() == teFnt; |
1303 | fontList->setItemChecked(i, cf); | 1304 | fontList->setItemChecked(i, cf); |
1304 | if (cf) | 1305 | if (cf) |
1305 | { | 1306 | { |
1306 | cfont = i; | 1307 | cfont = i; |
1307 | familyNum = fnt->getFamilyNum(); | 1308 | familyNum = fnt->getFamilyNum(); |
1308 | } | 1309 | } |
1309 | } | 1310 | } |
1310 | for(int i = 0; i < (int)fontList->count(); i++) | 1311 | for(int i = 0; i < (int)fontList->count(); i++) |
1311 | { | 1312 | { |
1312 | fontList->setItemChecked(i + 1000, i == familyNum); | 1313 | fontList->setItemChecked(i + 1000, i == familyNum); |
1313 | } | 1314 | } |
1314 | if (! te->currentSession->Title().isEmpty() ) | 1315 | if (! te->currentSession->Title().isEmpty() ) |
1315 | { | 1316 | { |
1316 | setCaption( te->currentSession->Title() + " - " + tr( "Konsole" ) ); | 1317 | setCaption( te->currentSession->Title() + " - " + tr( "Konsole" ) ); |
1317 | } | 1318 | } |
1318 | else | 1319 | else |
1319 | { | 1320 | { |
1320 | setCaption( tr( "Konsole" ) ); | 1321 | setCaption( tr( "Konsole" ) ); |
1321 | } | 1322 | } |
1322 | // colorMenuSelected(te->color_menu_item); | 1323 | // colorMenuSelected(te->color_menu_item); |
1323 | } | 1324 | } |
1324 | 1325 | ||
1325 | 1326 | ||
1326 | void Konsole::toggleFullScreen() | 1327 | void Konsole::toggleFullScreen() |
1327 | { | 1328 | { |
1328 | setFullScreen(! fullscreen); | 1329 | setFullScreen(! fullscreen); |
1329 | } | 1330 | } |
1330 | 1331 | ||
1331 | void Konsole::setFullScreen ( bool b ) | 1332 | void Konsole::setFullScreen ( bool b ) |
1332 | { | 1333 | { |
1333 | static QSize normalsize; | 1334 | static QSize normalsize; |
1334 | static bool listHidden; | 1335 | static bool listHidden; |
1335 | 1336 | ||
1336 | if (b == fullscreen) | 1337 | if (b == fullscreen) |
1337 | { | 1338 | { |
1338 | return; | 1339 | return; |
1339 | } | 1340 | } |
1340 | 1341 | ||
1341 | fullscreen = b; | 1342 | fullscreen = b; |
1342 | 1343 | ||
1343 | if ( b ) | 1344 | if ( b ) |
1344 | { | 1345 | { |
1345 | if ( !normalsize. isValid ( )) | 1346 | if ( !normalsize. isValid ( )) |
1346 | { | 1347 | { |
1347 | normalsize = size ( ); | 1348 | normalsize = size ( ); |
1348 | } | 1349 | } |
1349 | 1350 | ||
1350 | setFixedSize ( qApp-> desktop ( )-> size ( )); | 1351 | setFixedSize ( qApp-> desktop ( )-> size ( )); |
1351 | showNormal ( ); | 1352 | showNormal ( ); |
1352 | reparent ( 0, WStyle_Customize | WStyle_NoBorder, | 1353 | reparent ( 0, WStyle_Customize | WStyle_NoBorder, |
1353 | QPoint ( 0, 0 )); | 1354 | QPoint ( 0, 0 )); |
1354 | showFullScreen ( ); | 1355 | showFullScreen ( ); |
1355 | 1356 | ||
1356 | menuToolBar->hide(); | 1357 | menuToolBar->hide(); |
1357 | toolBar->hide(); | 1358 | toolBar->hide(); |
1358 | listHidden = secondToolBar->isHidden(); | 1359 | listHidden = secondToolBar->isHidden(); |
1359 | secondToolBar->hide(); | 1360 | secondToolBar->hide(); |
1360 | // commonCombo->hide(); | 1361 | // commonCombo->hide(); |
1361 | tab->getTabBar()->hide(); | 1362 | tab->getTabBar()->hide(); |
1362 | tab->setMargin(tab->margin()); | 1363 | tab->setMargin(tab->margin()); |
1363 | 1364 | ||
1364 | if (show_fullscreen_msg) | 1365 | if (show_fullscreen_msg) |
1365 | { | 1366 | { |
1366 | fullscreen_msg-> move(tab->x() + tab->width()/2 - fullscreen_msg->width()/2, | 1367 | fullscreen_msg-> move(tab->x() + tab->width()/2 - fullscreen_msg->width()/2, |
1367 | qApp->desktop()->height()/16 - fullscreen_msg->height()/2); | 1368 | qApp->desktop()->height()/16 - fullscreen_msg->height()/2); |
1368 | fullscreen_msg->show(); | 1369 | fullscreen_msg->show(); |
1369 | fullscreen_timer->start(3000, true); | 1370 | fullscreen_timer->start(3000, true); |
1370 | show_fullscreen_msg = false; | 1371 | show_fullscreen_msg = false; |
1371 | } | 1372 | } |
1372 | } | 1373 | } |
1373 | else | 1374 | else |
1374 | { | 1375 | { |
1375 | showNormal ( ); | 1376 | showNormal ( ); |
1376 | reparent ( 0, WStyle_Customize, QPoint ( 0, 0 )); | 1377 | reparent ( 0, WStyle_Customize, QPoint ( 0, 0 )); |
1377 | resize ( normalsize ); | 1378 | resize ( normalsize ); |
1378 | showMaximized ( ); | 1379 | showMaximized ( ); |
1379 | normalsize = QSize ( ); | 1380 | normalsize = QSize ( ); |
1380 | 1381 | ||
1381 | menuToolBar->show(); | 1382 | menuToolBar->show(); |
1382 | toolBar->show(); | 1383 | toolBar->show(); |
1383 | if(! listHidden) | 1384 | if(! listHidden) |
1384 | { | 1385 | { |
1385 | secondToolBar->show(); | 1386 | secondToolBar->show(); |
1386 | } | 1387 | } |
1387 | // commonCombo->show(); | 1388 | // commonCombo->show(); |
1388 | menuToolBar->show(); | 1389 | menuToolBar->show(); |
1389 | if (tabPos != tm_hidden) | 1390 | if (tabPos != tm_hidden) |
1390 | { | 1391 | { |
1391 | tab->getTabBar()->show(); | 1392 | tab->getTabBar()->show(); |
1392 | } | 1393 | } |
1393 | } | 1394 | } |
1394 | tab->setMargin(tab->margin()); // cause setup to run | 1395 | tab->setMargin(tab->margin()); // cause setup to run |
1395 | } | 1396 | } |
1396 | 1397 | ||
1397 | 1398 | ||
1398 | void Konsole::fullscreenTimeout() | 1399 | void Konsole::fullscreenTimeout() |
1399 | { | 1400 | { |
1400 | fullscreen_msg->hide(); | 1401 | fullscreen_msg->hide(); |
1401 | } | 1402 | } |
1402 | 1403 | ||
1403 | void Konsole::colorMenuIsSelected(int iD) | 1404 | void Konsole::colorMenuIsSelected(int iD) |
1404 | { | 1405 | { |
1405 | fromMenu = TRUE; | 1406 | fromMenu = TRUE; |
1406 | colorMenuSelected(iD); | 1407 | colorMenuSelected(iD); |
1407 | } | 1408 | } |
1408 | 1409 | ||
1409 | /// ------------------------------- some new stuff by L.J. Potter | 1410 | /// ------------------------------- some new stuff by L.J. Potter |
1410 | 1411 | ||
1411 | 1412 | ||
1412 | void Konsole::colorMenuSelected(int iD) | 1413 | void Konsole::colorMenuSelected(int iD) |
1413 | { | 1414 | { |
1414 | // this is NOT pretty, elegant or anything else besides functional | 1415 | // this is NOT pretty, elegant or anything else besides functional |
1415 | // QString temp; | 1416 | // QString temp; |
1416 | // qDebug( temp.sprintf("colormenu %d", iD)); | 1417 | // odebug << temp.sprintf("colormenu " << iD) << "" << oendl; |
1417 | 1418 | ||
1418 | TEWidget* te = getTe(); | 1419 | TEWidget* te = getTe(); |
1419 | Config cfg( "Konsole" ); | 1420 | Config cfg( "Konsole" ); |
1420 | cfg.setGroup("Colors"); | 1421 | cfg.setGroup("Colors"); |
1421 | 1422 | ||
1422 | ColorEntry m_table[TABLE_COLORS]; | 1423 | ColorEntry m_table[TABLE_COLORS]; |
1423 | const ColorEntry * defaultCt=te->getdefaultColorTable(); | 1424 | const ColorEntry * defaultCt=te->getdefaultColorTable(); |
1424 | 1425 | ||
1425 | int i; | 1426 | int i; |
1426 | 1427 | ||
1427 | // te->color_menu_item = iD; | 1428 | // te->color_menu_item = iD; |
1428 | 1429 | ||
1429 | colorMenu->setItemChecked(cm_ab,FALSE); | 1430 | colorMenu->setItemChecked(cm_ab,FALSE); |
1430 | colorMenu->setItemChecked(cm_bb,FALSE); | 1431 | colorMenu->setItemChecked(cm_bb,FALSE); |
1431 | colorMenu->setItemChecked(cm_wc,FALSE); | 1432 | colorMenu->setItemChecked(cm_wc,FALSE); |
1432 | colorMenu->setItemChecked(cm_cw,FALSE); | 1433 | colorMenu->setItemChecked(cm_cw,FALSE); |
1433 | colorMenu->setItemChecked(cm_mb,FALSE); | 1434 | colorMenu->setItemChecked(cm_mb,FALSE); |
1434 | colorMenu->setItemChecked(cm_bm,FALSE); | 1435 | colorMenu->setItemChecked(cm_bm,FALSE); |
1435 | colorMenu->setItemChecked(cm_gy,FALSE); | 1436 | colorMenu->setItemChecked(cm_gy,FALSE); |
1436 | colorMenu->setItemChecked(cm_rb,FALSE); | 1437 | colorMenu->setItemChecked(cm_rb,FALSE); |
1437 | colorMenu->setItemChecked(cm_br,FALSE); | 1438 | colorMenu->setItemChecked(cm_br,FALSE); |
1438 | colorMenu->setItemChecked(cm_wb,FALSE); | 1439 | colorMenu->setItemChecked(cm_wb,FALSE); |
1439 | colorMenu->setItemChecked(cm_bw,FALSE); | 1440 | colorMenu->setItemChecked(cm_bw,FALSE); |
1440 | colorMenu->setItemChecked(cm_gb,FALSE); | 1441 | colorMenu->setItemChecked(cm_gb,FALSE); |
1441 | 1442 | ||
1442 | if(iD==cm_default) | 1443 | if(iD==cm_default) |
1443 | { // default default | 1444 | { // default default |
1444 | printf("default colors\n"); | 1445 | printf("default colors\n"); |
1445 | for (i = 0; i < TABLE_COLORS; i++) | 1446 | for (i = 0; i < TABLE_COLORS; i++) |
1446 | { | 1447 | { |
1447 | m_table[i].color = defaultCt[i].color; | 1448 | m_table[i].color = defaultCt[i].color; |
1448 | if(i==1 || i == 11) | 1449 | if(i==1 || i == 11) |
1449 | m_table[i].transparent=1; | 1450 | m_table[i].transparent=1; |
1450 | colorMenu->setItemChecked(cm_default,TRUE); | 1451 | colorMenu->setItemChecked(cm_default,TRUE); |
1451 | } | 1452 | } |
1452 | te->setColorTable(m_table); | 1453 | te->setColorTable(m_table); |
1453 | } | 1454 | } |
1454 | if(iD==cm_gb) | 1455 | if(iD==cm_gb) |
1455 | { // green black | 1456 | { // green black |
1456 | foreground.setRgb(100,255,100); // (0x18,255,0x18); | 1457 | foreground.setRgb(100,255,100); // (0x18,255,0x18); |
1457 | background.setRgb(0x00,0x00,0x00); | 1458 | background.setRgb(0x00,0x00,0x00); |
1458 | colorMenu->setItemChecked(cm_gb,TRUE); | 1459 | colorMenu->setItemChecked(cm_gb,TRUE); |
1459 | } | 1460 | } |
1460 | if(iD==cm_bw) | 1461 | if(iD==cm_bw) |
1461 | { // black white | 1462 | { // black white |
1462 | foreground.setRgb(0x00,0x00,0x00); | 1463 | foreground.setRgb(0x00,0x00,0x00); |
1463 | background.setRgb(0xFF,0xFF,0xFF); | 1464 | background.setRgb(0xFF,0xFF,0xFF); |
1464 | colorMenu->setItemChecked(cm_bw,TRUE); | 1465 | colorMenu->setItemChecked(cm_bw,TRUE); |
1465 | } | 1466 | } |
1466 | if(iD==cm_wb) | 1467 | if(iD==cm_wb) |
1467 | { // white black | 1468 | { // white black |
1468 | foreground.setRgb(0xFF,0xFF,0xFF); | 1469 | foreground.setRgb(0xFF,0xFF,0xFF); |
1469 | background.setRgb(0x00,0x00,0x00); | 1470 | background.setRgb(0x00,0x00,0x00); |
1470 | colorMenu->setItemChecked(cm_wb,TRUE); | 1471 | colorMenu->setItemChecked(cm_wb,TRUE); |
1471 | } | 1472 | } |
1472 | if(iD==cm_br) | 1473 | if(iD==cm_br) |
1473 | {// Black, Red | 1474 | {// Black, Red |
1474 | foreground.setRgb(0x00,0x00,0x00); | 1475 | foreground.setRgb(0x00,0x00,0x00); |
1475 | background.setRgb(255,85,85); //(0xB2,0x18,0x18); | 1476 | background.setRgb(255,85,85); //(0xB2,0x18,0x18); |
1476 | colorMenu->setItemChecked(cm_br,TRUE); | 1477 | colorMenu->setItemChecked(cm_br,TRUE); |
1477 | } | 1478 | } |
1478 | if(iD==cm_rb) | 1479 | if(iD==cm_rb) |
1479 | {// Red, Black | 1480 | {// Red, Black |
1480 | foreground.setRgb(255,85,85); | 1481 | foreground.setRgb(255,85,85); |
1481 | background.setRgb(0x00,0x00,0x00); | 1482 | background.setRgb(0x00,0x00,0x00); |
1482 | colorMenu->setItemChecked(cm_rb,TRUE); | 1483 | colorMenu->setItemChecked(cm_rb,TRUE); |
1483 | } | 1484 | } |
1484 | if(iD==cm_gy) | 1485 | if(iD==cm_gy) |
1485 | {// Green, Yellow - is ugly | 1486 | {// Green, Yellow - is ugly |
1486 | // foreground.setRgb(0x18,0xB2,0x18); | 1487 | // foreground.setRgb(0x18,0xB2,0x18); |
1487 | foreground.setRgb(15,115,0); | 1488 | foreground.setRgb(15,115,0); |
1488 | // background.setRgb(0xB2,0x68,0x18); | 1489 | // background.setRgb(0xB2,0x68,0x18); |
1489 | background.setRgb(255,255,0); | 1490 | background.setRgb(255,255,0); |
1490 | colorMenu->setItemChecked(cm_gy,TRUE); | 1491 | colorMenu->setItemChecked(cm_gy,TRUE); |
1491 | } | 1492 | } |
1492 | if(iD==cm_bm) | 1493 | if(iD==cm_bm) |
1493 | {// Blue, Magenta | 1494 | {// Blue, Magenta |
1494 | foreground.setRgb(3,24,132); | 1495 | foreground.setRgb(3,24,132); |
1495 | background.setRgb(225,2,255); | 1496 | background.setRgb(225,2,255); |
1496 | colorMenu->setItemChecked(cm_bm,TRUE); | 1497 | colorMenu->setItemChecked(cm_bm,TRUE); |
1497 | } | 1498 | } |
1498 | if(iD==cm_mb) | 1499 | if(iD==cm_mb) |
1499 | {// Magenta, Blue | 1500 | {// Magenta, Blue |
1500 | foreground.setRgb(225,2,255); | 1501 | foreground.setRgb(225,2,255); |
1501 | background.setRgb(3,24,132); | 1502 | background.setRgb(3,24,132); |
1502 | colorMenu->setItemChecked(cm_mb,TRUE); | 1503 | colorMenu->setItemChecked(cm_mb,TRUE); |
1503 | } | 1504 | } |
1504 | if(iD==cm_cw) | 1505 | if(iD==cm_cw) |
1505 | {// Cyan, White | 1506 | {// Cyan, White |
1506 | foreground.setRgb(8,91,129); | 1507 | foreground.setRgb(8,91,129); |
1507 | background.setRgb(0xFF,0xFF,0xFF); | 1508 | background.setRgb(0xFF,0xFF,0xFF); |
1508 | colorMenu->setItemChecked(cm_cw,TRUE); | 1509 | colorMenu->setItemChecked(cm_cw,TRUE); |
1509 | } | 1510 | } |
1510 | if(iD==cm_wc) | 1511 | if(iD==cm_wc) |
1511 | {// White, Cyan | 1512 | {// White, Cyan |
1512 | background.setRgb(8,91,129); | 1513 | background.setRgb(8,91,129); |
1513 | foreground.setRgb(0xFF,0xFF,0xFF); | 1514 | foreground.setRgb(0xFF,0xFF,0xFF); |
1514 | colorMenu->setItemChecked(cm_wc,TRUE); | 1515 | colorMenu->setItemChecked(cm_wc,TRUE); |
1515 | } | 1516 | } |
1516 | if(iD==cm_bb) | 1517 | if(iD==cm_bb) |
1517 | {// Black, Blue | 1518 | {// Black, Blue |
1518 | background.setRgb(0x00,0x00,0x00); | 1519 | background.setRgb(0x00,0x00,0x00); |
1519 | foreground.setRgb(127,147,225); | 1520 | foreground.setRgb(127,147,225); |
1520 | colorMenu->setItemChecked(cm_bb,TRUE); | 1521 | colorMenu->setItemChecked(cm_bb,TRUE); |
1521 | } | 1522 | } |
1522 | if(iD==cm_ab) | 1523 | if(iD==cm_ab) |
1523 | {// Black, Gold | 1524 | {// Black, Gold |
1524 | background.setRgb(0x00,0x00,0x00); | 1525 | background.setRgb(0x00,0x00,0x00); |
1525 | foreground.setRgb(255,215,105); | 1526 | foreground.setRgb(255,215,105); |
1526 | colorMenu->setItemChecked(cm_ab,TRUE); | 1527 | colorMenu->setItemChecked(cm_ab,TRUE); |
1527 | } | 1528 | } |
1528 | #ifdef QT_QWS_OPIE | 1529 | #ifdef QT_QWS_OPIE |
1529 | if(iD==-19) | 1530 | if(iD==-19) |
1530 | { | 1531 | { |
1531 | // Custom | 1532 | // Custom |
1532 | qDebug("do custom"); | 1533 | odebug << "do custom" << oendl; |
1533 | if(fromMenu) | 1534 | if(fromMenu) |
1534 | { | 1535 | { |
1535 | Opie::OColorPopupMenu* penColorPopupMenu = new Opie::OColorPopupMenu(Qt::black, this, "foreground color"); | 1536 | Opie::OColorPopupMenu* penColorPopupMenu = new Opie::OColorPopupMenu(Qt::black, this, "foreground color"); |
1536 | connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, | 1537 | connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, |
1537 | SLOT(changeForegroundColor(const QColor&))); | 1538 | SLOT(changeForegroundColor(const QColor&))); |
1538 | penColorPopupMenu->exec(); | 1539 | penColorPopupMenu->exec(); |
1539 | } | 1540 | } |
1540 | if(!fromMenu) | 1541 | if(!fromMenu) |
1541 | { | 1542 | { |
1542 | foreground.setNamedColor(cfg.readEntry("foreground","")); | 1543 | foreground.setNamedColor(cfg.readEntry("foreground","")); |
1543 | background.setNamedColor(cfg.readEntry("background","")); | 1544 | background.setNamedColor(cfg.readEntry("background","")); |
1544 | } | 1545 | } |
1545 | fromMenu=FALSE; | 1546 | fromMenu=FALSE; |
1546 | colorMenu->setItemChecked(-19,TRUE); | 1547 | colorMenu->setItemChecked(-19,TRUE); |
1547 | } | 1548 | } |
1548 | #endif | 1549 | #endif |
1549 | 1550 | ||
1550 | lastSelectedMenu = iD; | 1551 | lastSelectedMenu = iD; |
1551 | 1552 | ||
1552 | setColors(foreground, background); | 1553 | setColors(foreground, background); |
1553 | 1554 | ||
1554 | QTabBar *tabBar = tab->getTabBar(); | 1555 | QTabBar *tabBar = tab->getTabBar(); |
1555 | QString ss = QString("Session%1").arg(tabBar->currentTab()); | 1556 | QString ss = QString("Session%1").arg(tabBar->currentTab()); |
1556 | // printf("current tab = %d\n", tabBar->currentTab()); | 1557 | // printf("current tab = %d\n", tabBar->currentTab()); |
1557 | 1558 | ||
1558 | if (tabBar->currentTab() == 0) | 1559 | if (tabBar->currentTab() == 0) |
1559 | { | 1560 | { |
1560 | cfg.writeEntry("foregroundRed",QString::number(foreground.red())); | 1561 | cfg.writeEntry("foregroundRed",QString::number(foreground.red())); |
1561 | cfg.writeEntry("foregroundGreen",QString::number(foreground.green())); | 1562 | cfg.writeEntry("foregroundGreen",QString::number(foreground.green())); |
1562 | cfg.writeEntry("foregroundBlue",QString::number(foreground.blue())); | 1563 | cfg.writeEntry("foregroundBlue",QString::number(foreground.blue())); |
1563 | cfg.writeEntry("backgroundRed",QString::number(background.red())); | 1564 | cfg.writeEntry("backgroundRed",QString::number(background.red())); |
1564 | cfg.writeEntry("backgroundGreen",QString::number(background.green())); | 1565 | cfg.writeEntry("backgroundGreen",QString::number(background.green())); |
1565 | cfg.writeEntry("backgroundBlue",QString::number(background.blue())); | 1566 | cfg.writeEntry("backgroundBlue",QString::number(background.blue())); |
1566 | } | 1567 | } |
1567 | cfg.writeEntry("foregroundRed"+ss,QString::number(foreground.red())); | 1568 | cfg.writeEntry("foregroundRed"+ss,QString::number(foreground.red())); |
1568 | cfg.writeEntry("foregroundGreen"+ss,QString::number(foreground.green())); | 1569 | cfg.writeEntry("foregroundGreen"+ss,QString::number(foreground.green())); |
1569 | cfg.writeEntry("foregroundBlue"+ss,QString::number(foreground.blue())); | 1570 | cfg.writeEntry("foregroundBlue"+ss,QString::number(foreground.blue())); |
1570 | cfg.writeEntry("backgroundRed"+ss,QString::number(background.red())); | 1571 | cfg.writeEntry("backgroundRed"+ss,QString::number(background.red())); |
1571 | cfg.writeEntry("backgroundGreen"+ss,QString::number(background.green())); | 1572 | cfg.writeEntry("backgroundGreen"+ss,QString::number(background.green())); |
1572 | cfg.writeEntry("backgroundBlue"+ss,QString::number(background.blue())); | 1573 | cfg.writeEntry("backgroundBlue"+ss,QString::number(background.blue())); |
1573 | 1574 | ||
1574 | update(); | 1575 | update(); |
1575 | } | 1576 | } |
1576 | 1577 | ||
1577 | void Konsole::setColors(QColor foreground, QColor background) | 1578 | void Konsole::setColors(QColor foreground, QColor background) |
1578 | { | 1579 | { |
1579 | int i; | 1580 | int i; |
1580 | ColorEntry m_table[TABLE_COLORS]; | 1581 | ColorEntry m_table[TABLE_COLORS]; |
1581 | TEWidget* te = getTe(); | 1582 | TEWidget* te = getTe(); |
1582 | const ColorEntry * defaultCt=te->getdefaultColorTable(); | 1583 | const ColorEntry * defaultCt=te->getdefaultColorTable(); |
1583 | 1584 | ||
1584 | for (i = 0; i < TABLE_COLORS; i++) | 1585 | for (i = 0; i < TABLE_COLORS; i++) |
1585 | { | 1586 | { |
1586 | if(i==0 || i == 10) | 1587 | if(i==0 || i == 10) |
1587 | { | 1588 | { |
1588 | m_table[i].color = foreground; | 1589 | m_table[i].color = foreground; |
1589 | } | 1590 | } |
1590 | else if(i==1 || i == 11) | 1591 | else if(i==1 || i == 11) |
1591 | { | 1592 | { |
1592 | m_table[i].color = background; | 1593 | m_table[i].color = background; |
1593 | m_table[i].transparent=0; | 1594 | m_table[i].transparent=0; |
1594 | } | 1595 | } |
1595 | else | 1596 | else |
1596 | m_table[i].color = defaultCt[i].color; | 1597 | m_table[i].color = defaultCt[i].color; |
1597 | } | 1598 | } |
1598 | te->setColorTable(m_table); | 1599 | te->setColorTable(m_table); |
1599 | } | 1600 | } |
1600 | 1601 | ||
1601 | void Konsole::tabMenuSelected(int id) | 1602 | void Konsole::tabMenuSelected(int id) |
1602 | { | 1603 | { |
1603 | Config cfg( "Konsole" ); | 1604 | Config cfg( "Konsole" ); |
1604 | cfg.setGroup("Tabs"); | 1605 | cfg.setGroup("Tabs"); |
1605 | tabMenu->setItemChecked(tabPos, false); | 1606 | tabMenu->setItemChecked(tabPos, false); |
1606 | if (id == tm_bottom) | 1607 | if (id == tm_bottom) |
1607 | { | 1608 | { |
1608 | printf("set bottom tab\n"); | 1609 | printf("set bottom tab\n"); |
1609 | tab->getTabBar()->show(); | 1610 | tab->getTabBar()->show(); |
1610 | tab->setTabPosition(QTabWidget::Bottom); | 1611 | tab->setTabPosition(QTabWidget::Bottom); |
1611 | tab->getTabBar()->show(); | 1612 | tab->getTabBar()->show(); |
1612 | cfg.writeEntry("Position","Bottom"); | 1613 | cfg.writeEntry("Position","Bottom"); |
1613 | } | 1614 | } |
1614 | else if (id == tm_top) | 1615 | else if (id == tm_top) |
1615 | { | 1616 | { |
1616 | printf("set top tab\n"); | 1617 | printf("set top tab\n"); |
1617 | tab->getTabBar()->show(); | 1618 | tab->getTabBar()->show(); |
1618 | tab->setTabPosition(QTabWidget::Bottom); | 1619 | tab->setTabPosition(QTabWidget::Bottom); |
1619 | tab->setTabPosition(QTabWidget::Top); | 1620 | tab->setTabPosition(QTabWidget::Top); |
1620 | tab->getTabBar()->show(); | 1621 | tab->getTabBar()->show(); |
1621 | cfg.writeEntry("Position","Top"); | 1622 | cfg.writeEntry("Position","Top"); |
1622 | } | 1623 | } |
1623 | else if (id == tm_hidden) | 1624 | else if (id == tm_hidden) |
1624 | { | 1625 | { |
1625 | tab->getTabBar()->hide(); | 1626 | tab->getTabBar()->hide(); |
1626 | tab->setMargin(tab->margin()); | 1627 | tab->setMargin(tab->margin()); |
1627 | cfg.writeEntry("Position","Hidden"); | 1628 | cfg.writeEntry("Position","Hidden"); |
1628 | } | 1629 | } |
1629 | tabMenu->setItemChecked(id, true); | 1630 | tabMenu->setItemChecked(id, true); |
1630 | tabPos = id; | 1631 | tabPos = id; |
1631 | } | 1632 | } |
1632 | 1633 | ||
1633 | 1634 | ||
1634 | void Konsole::configMenuSelected(int iD) | 1635 | void Konsole::configMenuSelected(int iD) |
1635 | { | 1636 | { |
1636 | // QString temp; | 1637 | // QString temp; |
1637 | // qDebug( temp.sprintf("configmenu %d",iD)); | 1638 | // odebug << temp.sprintf("configmenu " << iD) << "" << oendl; |
1638 | 1639 | ||
1639 | TEWidget* te = getTe(); | 1640 | TEWidget* te = getTe(); |
1640 | Config cfg( "Konsole" ); | 1641 | Config cfg( "Konsole" ); |
1641 | cfg.setGroup("Menubar"); | 1642 | cfg.setGroup("Menubar"); |
1642 | if(iD == cm_wrap) | 1643 | if(iD == cm_wrap) |
1643 | { | 1644 | { |
1644 | cfg.setGroup("ScrollBar"); | 1645 | cfg.setGroup("ScrollBar"); |
1645 | bool b=cfg.readBoolEntry("HorzScroll",0); | 1646 | bool b=cfg.readBoolEntry("HorzScroll",0); |
1646 | b=!b; | 1647 | b=!b; |
1647 | cfg.writeEntry("HorzScroll", b ); | 1648 | cfg.writeEntry("HorzScroll", b ); |
1648 | cfg.write(); | 1649 | cfg.write(); |
1649 | doWrap(); | 1650 | doWrap(); |
1650 | if(cfg.readNumEntry("Position",2) == 0) | 1651 | if(cfg.readNumEntry("Position",2) == 0) |
1651 | { | 1652 | { |
1652 | te->setScrollbarLocation(1); | 1653 | te->setScrollbarLocation(1); |
1653 | } | 1654 | } |
1654 | else | 1655 | else |
1655 | { | 1656 | { |
1656 | te->setScrollbarLocation(0); | 1657 | te->setScrollbarLocation(0); |
1657 | } | 1658 | } |
1658 | te->setScrollbarLocation( cfg.readNumEntry("Position",2)); | 1659 | te->setScrollbarLocation( cfg.readNumEntry("Position",2)); |
1659 | } | 1660 | } |
1660 | if(iD == cm_beep) | 1661 | if(iD == cm_beep) |
1661 | { | 1662 | { |
1662 | cfg.setGroup("Menubar"); | 1663 | cfg.setGroup("Menubar"); |
1663 | bool b=cfg.readBoolEntry("useBeep",0); | 1664 | bool b=cfg.readBoolEntry("useBeep",0); |
1664 | b=!b; | 1665 | b=!b; |
1665 | cfg.writeEntry("useBeep", b ); | 1666 | cfg.writeEntry("useBeep", b ); |
1666 | cfg.write(); | 1667 | cfg.write(); |
1667 | configMenu->setItemChecked(cm_beep,b); | 1668 | configMenu->setItemChecked(cm_beep,b); |
1668 | te->useBeep=b; | 1669 | te->useBeep=b; |
1669 | } | 1670 | } |
1670 | } | 1671 | } |
1671 | 1672 | ||
1672 | void Konsole::changeCommand(const QString &text, int c) | 1673 | void Konsole::changeCommand(const QString &text, int c) |
1673 | { | 1674 | { |
1674 | Config cfg( "Konsole" ); | 1675 | Config cfg( "Konsole" ); |
1675 | cfg.setGroup("Commands"); | 1676 | cfg.setGroup("Commands"); |
1676 | if(commonCmds[c] != text) | 1677 | if(commonCmds[c] != text) |
1677 | { | 1678 | { |
1678 | cfg.writeEntry(QString::number(c),text); | 1679 | cfg.writeEntry(QString::number(c),text); |
1679 | commonCombo->clearEdit(); | 1680 | commonCombo->clearEdit(); |
1680 | commonCombo->setCurrentItem(c); | 1681 | commonCombo->setCurrentItem(c); |
1681 | } | 1682 | } |
1682 | } | 1683 | } |
1683 | 1684 | ||
1684 | void Konsole::setColor(int sess) | 1685 | void Konsole::setColor(int sess) |
1685 | { | 1686 | { |
1686 | Config cfg( "Konsole" ); | 1687 | Config cfg( "Konsole" ); |
1687 | cfg.setGroup("Colors"); | 1688 | cfg.setGroup("Colors"); |
1688 | QColor foreground, background; | 1689 | QColor foreground, background; |
1689 | QString ss = QString("Session") + QString::number(sess); | 1690 | QString ss = QString("Session") + QString::number(sess); |
1690 | foreground.setRgb(cfg.readNumEntry("foregroundRed"+ss, | 1691 | foreground.setRgb(cfg.readNumEntry("foregroundRed"+ss, |
1691 | cfg.readNumEntry("foregroundRed",0xff)), | 1692 | cfg.readNumEntry("foregroundRed",0xff)), |
1692 | cfg.readNumEntry("foregroundGreen"+ss, | 1693 | cfg.readNumEntry("foregroundGreen"+ss, |
1693 | cfg.readNumEntry("foregroundGreen",0xff)), | 1694 | cfg.readNumEntry("foregroundGreen",0xff)), |
1694 | cfg.readNumEntry("foregroundBlue"+ss, | 1695 | cfg.readNumEntry("foregroundBlue"+ss, |
1695 | cfg.readNumEntry("foregroundBlue",0xff))); | 1696 | cfg.readNumEntry("foregroundBlue",0xff))); |
1696 | background.setRgb(cfg.readNumEntry("backgroundRed"+ss, | 1697 | background.setRgb(cfg.readNumEntry("backgroundRed"+ss, |
1697 | cfg.readNumEntry("backgroundRed",0)), | 1698 | cfg.readNumEntry("backgroundRed",0)), |
1698 | cfg.readNumEntry("backgroundGreen"+ss, | 1699 | cfg.readNumEntry("backgroundGreen"+ss, |
1699 | cfg.readNumEntry("backgroundGreen",0)), | 1700 | cfg.readNumEntry("backgroundGreen",0)), |
1700 | cfg.readNumEntry("backgroundBlue"+ss, | 1701 | cfg.readNumEntry("backgroundBlue"+ss, |
1701 | cfg.readNumEntry("backgroundBlue",0))); | 1702 | cfg.readNumEntry("backgroundBlue",0))); |
1702 | setColors(foreground, background); | 1703 | setColors(foreground, background); |
1703 | } | 1704 | } |
1704 | 1705 | ||
1705 | void Konsole::scrollMenuSelected(int index) | 1706 | void Konsole::scrollMenuSelected(int index) |
1706 | { | 1707 | { |
1707 | // qDebug( "scrollbar menu %d",index); | 1708 | // odebug << "scrollbar menu " << index << "" << oendl; |
1708 | 1709 | ||
1709 | TEWidget* te = getTe(); | 1710 | TEWidget* te = getTe(); |
1710 | Config cfg( "Konsole" ); | 1711 | Config cfg( "Konsole" ); |
1711 | cfg.setGroup("ScrollBar"); | 1712 | cfg.setGroup("ScrollBar"); |
1712 | 1713 | ||
1713 | if(index == sm_none) | 1714 | if(index == sm_none) |
1714 | { | 1715 | { |
1715 | te->setScrollbarLocation(0); | 1716 | te->setScrollbarLocation(0); |
1716 | cfg.writeEntry("Position",0); | 1717 | cfg.writeEntry("Position",0); |
1717 | } | 1718 | } |
1718 | else if(index == sm_left) | 1719 | else if(index == sm_left) |
1719 | { | 1720 | { |
1720 | te->setScrollbarLocation(1); | 1721 | te->setScrollbarLocation(1); |
1721 | cfg.writeEntry("Position",1); | 1722 | cfg.writeEntry("Position",1); |
1722 | } | 1723 | } |
1723 | else if(index == sm_right) | 1724 | else if(index == sm_right) |
1724 | { | 1725 | { |
1725 | te->setScrollbarLocation(2); | 1726 | te->setScrollbarLocation(2); |
1726 | cfg.writeEntry("Position",2); | 1727 | cfg.writeEntry("Position",2); |
1727 | } | 1728 | } |
1728 | scrollMenu->setItemChecked(sm_none, index == sm_none); | 1729 | scrollMenu->setItemChecked(sm_none, index == sm_none); |
1729 | scrollMenu->setItemChecked(sm_left, index == sm_left); | 1730 | scrollMenu->setItemChecked(sm_left, index == sm_left); |
1730 | scrollMenu->setItemChecked(sm_right, index == sm_right); | 1731 | scrollMenu->setItemChecked(sm_right, index == sm_right); |
1731 | } | 1732 | } |
1732 | 1733 | ||
1733 | // case -29: { | 1734 | // case -29: { |
1734 | // bool b=cfg.readBoolEntry("HorzScroll",0); | 1735 | // bool b=cfg.readBoolEntry("HorzScroll",0); |
1735 | // cfg.writeEntry("HorzScroll", !b ); | 1736 | // cfg.writeEntry("HorzScroll", !b ); |
1736 | // cfg.write(); | 1737 | // cfg.write(); |
1737 | // if(cfg.readNumEntry("Position",2) == 0) { | 1738 | // if(cfg.readNumEntry("Position",2) == 0) { |
1738 | // te->setScrollbarLocation(1); | 1739 | // te->setScrollbarLocation(1); |
1739 | // te->setWrapAt(0); | 1740 | // te->setWrapAt(0); |
1740 | // } else { | 1741 | // } else { |
1741 | // te->setScrollbarLocation(0); | 1742 | // te->setScrollbarLocation(0); |
1742 | // te->setWrapAt(120); | 1743 | // te->setWrapAt(120); |
1743 | // } | 1744 | // } |
1744 | // te->setScrollbarLocation( cfg.readNumEntry("Position",2)); | 1745 | // te->setScrollbarLocation( cfg.readNumEntry("Position",2)); |
1745 | // } | 1746 | // } |
1746 | // break; | 1747 | // break; |
1747 | 1748 | ||
1748 | void Konsole::editCommandListMenuSelected(int iD) | 1749 | void Konsole::editCommandListMenuSelected(int iD) |
1749 | { | 1750 | { |
1750 | // QString temp; | 1751 | // QString temp; |
1751 | // qDebug( temp.sprintf("edit command list %d",iD)); | 1752 | // odebug << temp.sprintf("edit command list " << iD) << "" << oendl; |
1752 | 1753 | ||
1753 | // FIXME: more cleanup needed here | 1754 | // FIXME: more cleanup needed here |
1754 | 1755 | ||
1755 | 1756 | ||
1756 | TEWidget* te = getTe(); | 1757 | TEWidget* te = getTe(); |
1757 | Config cfg( "Konsole" ); | 1758 | Config cfg( "Konsole" ); |
1758 | cfg.setGroup("Menubar"); | 1759 | cfg.setGroup("Menubar"); |
1759 | if( iD == ec_cmdlist) | 1760 | if( iD == ec_cmdlist) |
1760 | { | 1761 | { |
1761 | if(!secondToolBar->isHidden()) | 1762 | if(!secondToolBar->isHidden()) |
1762 | { | 1763 | { |
1763 | secondToolBar->hide(); | 1764 | secondToolBar->hide(); |
1764 | configMenu->changeItem( iD,tr( "Show Command List" )); | 1765 | configMenu->changeItem( iD,tr( "Show Command List" )); |
1765 | cfg.writeEntry("Hidden","TRUE"); | 1766 | cfg.writeEntry("Hidden","TRUE"); |
1766 | configMenu->setItemEnabled(ec_edit ,FALSE); | 1767 | configMenu->setItemEnabled(ec_edit ,FALSE); |
1767 | configMenu->setItemEnabled(ec_quick ,FALSE); | 1768 | configMenu->setItemEnabled(ec_quick ,FALSE); |
1768 | } | 1769 | } |
1769 | else | 1770 | else |
1770 | { | 1771 | { |
1771 | secondToolBar->show(); | 1772 | secondToolBar->show(); |
1772 | configMenu->changeItem( iD,tr( "Hide Command List" )); | 1773 | configMenu->changeItem( iD,tr( "Hide Command List" )); |
1773 | cfg.writeEntry("Hidden","FALSE"); | 1774 | cfg.writeEntry("Hidden","FALSE"); |
1774 | configMenu->setItemEnabled(ec_edit ,TRUE); | 1775 | configMenu->setItemEnabled(ec_edit ,TRUE); |
1775 | configMenu->setItemEnabled(ec_quick ,TRUE); | 1776 | configMenu->setItemEnabled(ec_quick ,TRUE); |
1776 | 1777 | ||
1777 | if(cfg.readEntry("EditEnabled","FALSE")=="TRUE") | 1778 | if(cfg.readEntry("EditEnabled","FALSE")=="TRUE") |
1778 | { | 1779 | { |
1779 | configMenu->setItemChecked(ec_edit,TRUE); | 1780 | configMenu->setItemChecked(ec_edit,TRUE); |
1780 | commonCombo->setEditable( TRUE ); | 1781 | commonCombo->setEditable( TRUE ); |
1781 | } | 1782 | } |
1782 | else | 1783 | else |
1783 | { | 1784 | { |
1784 | configMenu->setItemChecked(ec_edit,FALSE); | 1785 | configMenu->setItemChecked(ec_edit,FALSE); |
1785 | commonCombo->setEditable( FALSE ); | 1786 | commonCombo->setEditable( FALSE ); |
1786 | } | 1787 | } |
1787 | } | 1788 | } |
1788 | } | 1789 | } |
1789 | if( iD == ec_quick) | 1790 | if( iD == ec_quick) |
1790 | { | 1791 | { |
1791 | cfg.setGroup("Commands"); | 1792 | cfg.setGroup("Commands"); |
1792 | // qDebug("enableCommandEdit"); | 1793 | // odebug << "enableCommandEdit" << oendl; |
1793 | if( !configMenu->isItemChecked(iD) ) | 1794 | if( !configMenu->isItemChecked(iD) ) |
1794 | { | 1795 | { |
1795 | commonCombo->setEditable( TRUE ); | 1796 | commonCombo->setEditable( TRUE ); |
1796 | configMenu->setItemChecked(iD,TRUE); | 1797 | configMenu->setItemChecked(iD,TRUE); |
1797 | commonCombo->setCurrentItem(0); | 1798 | commonCombo->setCurrentItem(0); |
1798 | cfg.writeEntry("EditEnabled","TRUE"); | 1799 | cfg.writeEntry("EditEnabled","TRUE"); |
1799 | } | 1800 | } |
1800 | else | 1801 | else |
1801 | { | 1802 | { |
1802 | commonCombo->setEditable( FALSE ); | 1803 | commonCombo->setEditable( FALSE ); |
1803 | configMenu->setItemChecked(iD,FALSE); | 1804 | configMenu->setItemChecked(iD,FALSE); |
1804 | cfg.writeEntry("EditEnabled","FALSE"); | 1805 | cfg.writeEntry("EditEnabled","FALSE"); |
1805 | commonCombo->setFocusPolicy(QWidget::NoFocus); | 1806 | commonCombo->setFocusPolicy(QWidget::NoFocus); |
1806 | te->setFocus(); | 1807 | te->setFocus(); |
1807 | } | 1808 | } |
1808 | } | 1809 | } |
1809 | if(iD == ec_edit) | 1810 | if(iD == ec_edit) |
1810 | { | 1811 | { |
1811 | // "edit commands" | 1812 | // "edit commands" |
1812 | CommandEditDialog *m = new CommandEditDialog(this); | 1813 | CommandEditDialog *m = new CommandEditDialog(this); |
1813 | connect(m,SIGNAL(commandsEdited()),this,SLOT(initCommandList())); | 1814 | connect(m,SIGNAL(commandsEdited()),this,SLOT(initCommandList())); |
1814 | m->showMaximized(); | 1815 | m->showMaximized(); |
1815 | } | 1816 | } |
1816 | 1817 | ||
1817 | } | 1818 | } |
1818 | 1819 | ||
1819 | // $QPEDIR/bin/qcop QPE/Application/embeddedkonsole 'setDocument(QString)' 'ssh -V' | 1820 | // $QPEDIR/bin/qcop QPE/Application/embeddedkonsole 'setDocument(QString)' 'ssh -V' |
1820 | void Konsole::setDocument( const QString &cmd) | 1821 | void Konsole::setDocument( const QString &cmd) |
1821 | { | 1822 | { |
1822 | newSession(); | 1823 | newSession(); |
1823 | TEWidget* te = getTe(); | 1824 | TEWidget* te = getTe(); |
1824 | if(cmd.find("-e", 0, TRUE) != -1) | 1825 | if(cmd.find("-e", 0, TRUE) != -1) |
1825 | { | 1826 | { |
1826 | QString cmd2; | 1827 | QString cmd2; |
1827 | cmd2=cmd.right(cmd.length()-3)+" &"; | 1828 | cmd2=cmd.right(cmd.length()-3)+" &"; |
1828 | system(cmd2.latin1()); | 1829 | system(cmd2.latin1()); |
1829 | if(startUp <= 1 && nsessions < 2) | 1830 | if(startUp <= 1 && nsessions < 2) |
1830 | { | 1831 | { |
1831 | doneSession(getTe(), 0); | 1832 | doneSession(getTe(), 0); |
1832 | exit(0); | 1833 | exit(0); |
1833 | } | 1834 | } |
1834 | else | 1835 | else |
1835 | doneSession(getTe(), 0); | 1836 | doneSession(getTe(), 0); |
1836 | } | 1837 | } |
1837 | else | 1838 | else |
1838 | { | 1839 | { |
1839 | if (te != 0) | 1840 | if (te != 0) |
1840 | { | 1841 | { |
1841 | te->emitText(cmd+"\r"); | 1842 | te->emitText(cmd+"\r"); |
1842 | } | 1843 | } |
1843 | } | 1844 | } |
1844 | startUp++; | 1845 | startUp++; |
1845 | } | 1846 | } |
1846 | 1847 | ||
1847 | 1848 | ||
1848 | // what is the point of this when you can just | 1849 | // what is the point of this when you can just |
1849 | // run commands by using the shell directly?? | 1850 | // run commands by using the shell directly?? |
1850 | void Konsole::parseCommandLine() | 1851 | void Konsole::parseCommandLine() |
1851 | { | 1852 | { |
1852 | QString cmd; | 1853 | QString cmd; |
1853 | // newSession(); | 1854 | // newSession(); |
1854 | for (int i=1;i< qApp->argc();i++) | 1855 | for (int i=1;i< qApp->argc();i++) |
1855 | { | 1856 | { |
1856 | if( QString(qApp->argv()[i]) == "-e") | 1857 | if( QString(qApp->argv()[i]) == "-e") |
1857 | { | 1858 | { |
1858 | i++; | 1859 | i++; |
1859 | for ( int j=i;j< qApp->argc();j++) | 1860 | for ( int j=i;j< qApp->argc();j++) |
1860 | { | 1861 | { |
1861 | cmd+=QString(qApp->argv()[j])+" "; | 1862 | cmd+=QString(qApp->argv()[j])+" "; |
1862 | } | 1863 | } |
1863 | cmd.stripWhiteSpace(); | 1864 | cmd.stripWhiteSpace(); |
1864 | system(cmd.latin1()); | 1865 | system(cmd.latin1()); |
1865 | exit(0);//close(); | 1866 | exit(0);//close(); |
1866 | } // end -e switch | 1867 | } // end -e switch |
1867 | } | 1868 | } |
1868 | startUp++; | 1869 | startUp++; |
1869 | } | 1870 | } |
1870 | 1871 | ||
1871 | void Konsole::changeForegroundColor(const QColor &color) | 1872 | void Konsole::changeForegroundColor(const QColor &color) |
1872 | { | 1873 | { |
1873 | Config cfg( "Konsole" ); | 1874 | Config cfg( "Konsole" ); |
1874 | cfg.setGroup("Colors"); | 1875 | cfg.setGroup("Colors"); |
1875 | int r, g, b; | 1876 | int r, g, b; |
1876 | color.rgb(&r,&g,&b); | 1877 | color.rgb(&r,&g,&b); |
1877 | foreground.setRgb(r,g,b); | 1878 | foreground.setRgb(r,g,b); |
1878 | 1879 | ||
1879 | cfg.writeEntry("foreground",color.name()); | 1880 | cfg.writeEntry("foreground",color.name()); |
1880 | qDebug("foreground "+color.name()); | 1881 | odebug << "foreground "+color.name() << oendl; |
1881 | cfg.write(); | 1882 | cfg.write(); |
1882 | 1883 | ||
1883 | qDebug("do other dialog"); | 1884 | odebug << "do other dialog" << oendl; |
1884 | #ifdef QT_QWS_OPIE | 1885 | #ifdef QT_QWS_OPIE |
1885 | 1886 | ||
1886 | Opie::OColorPopupMenu* penColorPopupMenu2 = new Opie::OColorPopupMenu(Qt::black, this,"background color"); | 1887 | Opie::OColorPopupMenu* penColorPopupMenu2 = new Opie::OColorPopupMenu(Qt::black, this,"background color"); |
1887 | connect(penColorPopupMenu2, SIGNAL(colorSelected(const QColor&)), this, | 1888 | connect(penColorPopupMenu2, SIGNAL(colorSelected(const QColor&)), this, |
1888 | SLOT(changeBackgroundColor(const QColor&))); | 1889 | SLOT(changeBackgroundColor(const QColor&))); |
1889 | penColorPopupMenu2->exec(); | 1890 | penColorPopupMenu2->exec(); |
1890 | #endif | 1891 | #endif |
1891 | } | 1892 | } |
1892 | 1893 | ||
1893 | void Konsole::changeBackgroundColor(const QColor &color) | 1894 | void Konsole::changeBackgroundColor(const QColor &color) |
1894 | { | 1895 | { |
1895 | 1896 | ||
1896 | qDebug("Change background"); | 1897 | odebug << "Change background" << oendl; |
1897 | Config cfg( "Konsole" ); | 1898 | Config cfg( "Konsole" ); |
1898 | cfg.setGroup("Colors"); | 1899 | cfg.setGroup("Colors"); |
1899 | int r, g, b; | 1900 | int r, g, b; |
1900 | color.rgb(&r,&g,&b); | 1901 | color.rgb(&r,&g,&b); |
1901 | background.setRgb(r,g,b); | 1902 | background.setRgb(r,g,b); |
1902 | cfg.writeEntry("background",color.name()); | 1903 | cfg.writeEntry("background",color.name()); |
1903 | qDebug("background "+color.name()); | 1904 | odebug << "background "+color.name() << oendl; |
1904 | cfg.write(); | 1905 | cfg.write(); |
1905 | } | 1906 | } |
1906 | 1907 | ||
1907 | void Konsole::doWrap() | 1908 | void Konsole::doWrap() |
1908 | { | 1909 | { |
1909 | Config cfg( "Konsole" ); | 1910 | Config cfg( "Konsole" ); |
1910 | cfg.setGroup("ScrollBar"); | 1911 | cfg.setGroup("ScrollBar"); |
1911 | TEWidget* te = getTe(); | 1912 | TEWidget* te = getTe(); |
1912 | if( !cfg.readBoolEntry("HorzScroll",0)) | 1913 | if( !cfg.readBoolEntry("HorzScroll",0)) |
1913 | { | 1914 | { |
1914 | te->setWrapAt(0); | 1915 | te->setWrapAt(0); |
1915 | configMenu->setItemChecked( cm_wrap,TRUE); | 1916 | configMenu->setItemChecked( cm_wrap,TRUE); |
1916 | } | 1917 | } |
1917 | else | 1918 | else |
1918 | { | 1919 | { |
1919 | // te->setWrapAt(90); | 1920 | // te->setWrapAt(90); |
1920 | te->setWrapAt(120); | 1921 | te->setWrapAt(120); |
1921 | configMenu->setItemChecked( cm_wrap,FALSE); | 1922 | configMenu->setItemChecked( cm_wrap,FALSE); |
1922 | } | 1923 | } |
1923 | } | 1924 | } |
diff --git a/core/apps/embeddedkonsole/main.cpp b/core/apps/embeddedkonsole/main.cpp index b851d3e..131e782 100644 --- a/core/apps/embeddedkonsole/main.cpp +++ b/core/apps/embeddedkonsole/main.cpp | |||
@@ -1,85 +1,85 @@ | |||
1 | /* ---------------------------------------------------------------------- */ | 1 | /* ---------------------------------------------------------------------- */ |
2 | /* */ | 2 | /* */ |
3 | /* [main.C] Konsole */ | 3 | /* [main.C] Konsole */ |
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. */ | 9 | /* This file is part of Konsole, an X terminal. */ |
10 | /* */ | 10 | /* */ |
11 | /* The material contained in here more or less directly orginates from */ | 11 | /* The material contained in here more or less directly orginates from */ |
12 | /* kvt, which is copyright (c) 1996 by Matthias Ettrich <ettrich@kde.org> */ | 12 | /* kvt, which is copyright (c) 1996 by Matthias Ettrich <ettrich@kde.org> */ |
13 | /* */ | 13 | /* */ |
14 | /* ---------------------------------------------------------------------- */ | 14 | /* ---------------------------------------------------------------------- */ |
15 | /* */ | 15 | /* */ |
16 | /* Ported Konsole to Qt/Embedded */ | 16 | /* Ported Konsole to Qt/Embedded */ |
17 | /* */ | 17 | /* */ |
18 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ | 18 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ |
19 | /* */ | 19 | /* */ |
20 | /* -------------------------------------------------------------------------- */ | 20 | /* -------------------------------------------------------------------------- */ |
21 | 21 | ||
22 | #include "konsole.h" | 22 | #include "konsole.h" |
23 | 23 | ||
24 | #ifdef QT_QWS_OPIE | 24 | #ifdef QT_QWS_OPIE |
25 | 25 | ||
26 | #include <opie2/oapplicationfactory.h> | 26 | #include <opie2/oapplicationfactory.h> |
27 | 27 | ||
28 | /* --| main |------------------------------------------------------ */ | 28 | /* --| main |------------------------------------------------------ */ |
29 | using namespace Opie::Core; | 29 | using namespace Opie::Core; |
30 | OPIE_EXPORT_APP( OApplicationFactory<Konsole> ) | 30 | OPIE_EXPORT_APP( OApplicationFactory<Konsole> ) |
31 | 31 | ||
32 | #else //for non opie builds | 32 | #else //for non opie builds |
33 | 33 | ||
34 | #include <qpe/qpeapplication.h> | 34 | #include <qpe/qpeapplication.h> |
35 | 35 | ||
36 | #include <qfile.h> | 36 | #include <qfile.h> |
37 | 37 | ||
38 | #include <unistd.h> | 38 | #include <unistd.h> |
39 | #include <stdio.h> | 39 | #include <stdio.h> |
40 | #include <stdlib.h> | 40 | #include <stdlib.h> |
41 | 41 | ||
42 | #include <pwd.h> | 42 | #include <pwd.h> |
43 | #include <sys/types.h> | 43 | #include <sys/types.h> |
44 | 44 | ||
45 | 45 | ||
46 | /* --| main |------------------------------------------------------ */ | 46 | /* --| main |------------------------------------------------------ */ |
47 | int main(int argc, char* argv[]) { | 47 | int main(int argc, char* argv[]) { |
48 | if(setuid(getuid()) !=0) qDebug("setuid failed"); | 48 | if(setuid(getuid()) !=0) odebug << "setuid failed" << oendl; |
49 | if(setgid(getgid()) != 0) qDebug("setgid failed"); // drop privileges | 49 | if(setgid(getgid()) != 0) odebug << "setgid failed" << oendl; // drop privileges |
50 | 50 | ||
51 | QPEApplication a( argc, argv ); | 51 | QPEApplication a( argc, argv ); |
52 | #ifdef FAKE_CTRL_AND_ALT | 52 | #ifdef FAKE_CTRL_AND_ALT |
53 | qDebug("Fake Ctrl and Alt defined"); | 53 | odebug << "Fake Ctrl and Alt defined" << oendl; |
54 | QPEApplication::grabKeyboard(); // for CTRL and ALT | 54 | QPEApplication::grabKeyboard(); // for CTRL and ALT |
55 | #endif | 55 | #endif |
56 | 56 | ||
57 | QStrList tmp; | 57 | QStrList tmp; |
58 | const char* shell = getenv("SHELL"); | 58 | const char* shell = getenv("SHELL"); |
59 | 59 | ||
60 | if (shell == NULL || *shell == '\0') { | 60 | if (shell == NULL || *shell == '\0') { |
61 | struct passwd *ent = 0; | 61 | struct passwd *ent = 0; |
62 | uid_t me = getuid(); | 62 | uid_t me = getuid(); |
63 | shell = "/bin/sh"; | 63 | shell = "/bin/sh"; |
64 | 64 | ||
65 | while ( (ent = getpwent()) != 0 ) { | 65 | while ( (ent = getpwent()) != 0 ) { |
66 | if (ent->pw_uid == me) { | 66 | if (ent->pw_uid == me) { |
67 | if (ent->pw_shell != "") | 67 | if (ent->pw_shell != "") |
68 | shell = ent->pw_shell; | 68 | shell = ent->pw_shell; |
69 | break; | 69 | break; |
70 | } | 70 | } |
71 | } | 71 | } |
72 | endpwent(); | 72 | endpwent(); |
73 | } | 73 | } |
74 | 74 | ||
75 | if( putenv((char*)"COLORTERM=") !=0) | 75 | if( putenv((char*)"COLORTERM=") !=0) |
76 | qDebug("putenv failed"); // to trigger mc's color detection | 76 | odebug << "putenv failed" << oendl; // to trigger mc's color detection |
77 | 77 | ||
78 | Konsole m( "test", shell, tmp, TRUE ); | 78 | Konsole m( "test", shell, tmp, TRUE ); |
79 | m.setCaption( Konsole::tr("Terminal") ); | 79 | m.setCaption( Konsole::tr("Terminal") ); |
80 | a.showMainWidget( &m ); | 80 | a.showMainWidget( &m ); |
81 | 81 | ||
82 | return a.exec(); | 82 | return a.exec(); |
83 | } | 83 | } |
84 | 84 | ||
85 | #endif | 85 | #endif |
diff --git a/core/apps/embeddedkonsole/playlistselection.cpp b/core/apps/embeddedkonsole/playlistselection.cpp index fc5330f..096d36a 100644 --- a/core/apps/embeddedkonsole/playlistselection.cpp +++ b/core/apps/embeddedkonsole/playlistselection.cpp | |||
@@ -1,154 +1,157 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include <qheader.h> | ||
21 | 20 | ||
22 | #include "playlistselection.h" | 21 | #include "playlistselection.h" |
23 | 22 | ||
24 | #include <stdlib.h> | 23 | /* OPIE */ |
25 | 24 | #include <opie2/odebug.h> | |
26 | 25 | ||
26 | /* Qt */ | ||
27 | #include <qheader.h> | ||
27 | 28 | ||
29 | /* STD */ | ||
30 | #include <stdlib.h> | ||
28 | 31 | ||
29 | 32 | ||
30 | PlayListSelection::PlayListSelection( QWidget *parent, const char *name ) | 33 | PlayListSelection::PlayListSelection( QWidget *parent, const char *name ) |
31 | : QListView( parent, name ) | 34 | : QListView( parent, name ) |
32 | { | 35 | { |
33 | setAllColumnsShowFocus( TRUE ); | 36 | setAllColumnsShowFocus( TRUE ); |
34 | addColumn( tr( "Command Selection" ) ); | 37 | addColumn( tr( "Command Selection" ) ); |
35 | header()->hide(); | 38 | header()->hide(); |
36 | setSorting( -1, FALSE ); | 39 | setSorting( -1, FALSE ); |
37 | } | 40 | } |
38 | 41 | ||
39 | 42 | ||
40 | PlayListSelection::~PlayListSelection() { | 43 | PlayListSelection::~PlayListSelection() { |
41 | } | 44 | } |
42 | 45 | ||
43 | 46 | ||
44 | 47 | ||
45 | void PlayListSelection::contentsMouseMoveEvent( QMouseEvent *event ) { | 48 | void PlayListSelection::contentsMouseMoveEvent( QMouseEvent *event ) { |
46 | if ( event->state() == QMouseEvent::LeftButton ) { | 49 | if ( event->state() == QMouseEvent::LeftButton ) { |
47 | QListViewItem *currentItem = selectedItem(); | 50 | QListViewItem *currentItem = selectedItem(); |
48 | QListViewItem *itemUnder = itemAt( QPoint( event->pos().x(), event->pos().y() - contentsY() ) ); | 51 | QListViewItem *itemUnder = itemAt( QPoint( event->pos().x(), event->pos().y() - contentsY() ) ); |
49 | if ( currentItem && currentItem->itemAbove() == itemUnder ) | 52 | if ( currentItem && currentItem->itemAbove() == itemUnder ) |
50 | moveSelectedUp(); | 53 | moveSelectedUp(); |
51 | else if ( currentItem && currentItem->itemBelow() == itemUnder ) | 54 | else if ( currentItem && currentItem->itemBelow() == itemUnder ) |
52 | moveSelectedDown(); | 55 | moveSelectedDown(); |
53 | } | 56 | } |
54 | } | 57 | } |
55 | 58 | ||
56 | 59 | ||
57 | const QString *PlayListSelection::current() { | 60 | const QString *PlayListSelection::current() { |
58 | PlayListSelectionItem *item = (PlayListSelectionItem *)selectedItem(); | 61 | PlayListSelectionItem *item = (PlayListSelectionItem *)selectedItem(); |
59 | if ( item ) | 62 | if ( item ) |
60 | return item->file(); | 63 | return item->file(); |
61 | return NULL; | 64 | return NULL; |
62 | } | 65 | } |
63 | 66 | ||
64 | 67 | ||
65 | void PlayListSelection::addToSelection( QListViewItem *lnk ) { | 68 | void PlayListSelection::addToSelection( QListViewItem *lnk ) { |
66 | PlayListSelectionItem *item = new PlayListSelectionItem( this, new QString( lnk->text(0) ) ); | 69 | PlayListSelectionItem *item = new PlayListSelectionItem( this, new QString( lnk->text(0) ) ); |
67 | QListViewItem *current = selectedItem(); | 70 | QListViewItem *current = selectedItem(); |
68 | if ( current ) | 71 | if ( current ) |
69 | item->moveItem( current ); | 72 | item->moveItem( current ); |
70 | setSelected( item, TRUE ); | 73 | setSelected( item, TRUE ); |
71 | ensureItemVisible( selectedItem() ); | 74 | ensureItemVisible( selectedItem() ); |
72 | } | 75 | } |
73 | 76 | ||
74 | void PlayListSelection::addStringToSelection (const QString & lnk) { | 77 | void PlayListSelection::addStringToSelection (const QString & lnk) { |
75 | PlayListSelectionItem *item = new PlayListSelectionItem( this, new QString( lnk ) ); | 78 | PlayListSelectionItem *item = new PlayListSelectionItem( this, new QString( lnk ) ); |
76 | QListViewItem *current = selectedItem(); | 79 | QListViewItem *current = selectedItem(); |
77 | if ( current ) | 80 | if ( current ) |
78 | item->moveItem( current ); | 81 | item->moveItem( current ); |
79 | setSelected( item, TRUE ); | 82 | setSelected( item, TRUE ); |
80 | ensureItemVisible( selectedItem() ); | 83 | ensureItemVisible( selectedItem() ); |
81 | 84 | ||
82 | } | 85 | } |
83 | void PlayListSelection::removeSelected() { | 86 | void PlayListSelection::removeSelected() { |
84 | qDebug("removeSelected()"); | 87 | odebug << "removeSelected()" << oendl; |
85 | QListViewItem *item = selectedItem(); | 88 | QListViewItem *item = selectedItem(); |
86 | if ( item ) | 89 | if ( item ) |
87 | delete item; | 90 | delete item; |
88 | setSelected( currentItem(), TRUE ); | 91 | setSelected( currentItem(), TRUE ); |
89 | ensureItemVisible( selectedItem() ); | 92 | ensureItemVisible( selectedItem() ); |
90 | } | 93 | } |
91 | 94 | ||
92 | 95 | ||
93 | void PlayListSelection::moveSelectedUp() { | 96 | void PlayListSelection::moveSelectedUp() { |
94 | QListViewItem *item = selectedItem(); | 97 | QListViewItem *item = selectedItem(); |
95 | if ( item && item->itemAbove() ) | 98 | if ( item && item->itemAbove() ) |
96 | item->itemAbove()->moveItem( item ); | 99 | item->itemAbove()->moveItem( item ); |
97 | ensureItemVisible( selectedItem() ); | 100 | ensureItemVisible( selectedItem() ); |
98 | } | 101 | } |
99 | 102 | ||
100 | 103 | ||
101 | void PlayListSelection::moveSelectedDown() { | 104 | void PlayListSelection::moveSelectedDown() { |
102 | QListViewItem *item = selectedItem(); | 105 | QListViewItem *item = selectedItem(); |
103 | if ( item && item->itemBelow() ) | 106 | if ( item && item->itemBelow() ) |
104 | item->moveItem( item->itemBelow() ); | 107 | item->moveItem( item->itemBelow() ); |
105 | ensureItemVisible( selectedItem() ); | 108 | ensureItemVisible( selectedItem() ); |
106 | } | 109 | } |
107 | 110 | ||
108 | 111 | ||
109 | bool PlayListSelection::prev() { | 112 | bool PlayListSelection::prev() { |
110 | QListViewItem *item = selectedItem(); | 113 | QListViewItem *item = selectedItem(); |
111 | if ( item && item->itemAbove() ) | 114 | if ( item && item->itemAbove() ) |
112 | setSelected( item->itemAbove(), TRUE ); | 115 | setSelected( item->itemAbove(), TRUE ); |
113 | else | 116 | else |
114 | return FALSE; | 117 | return FALSE; |
115 | ensureItemVisible( selectedItem() ); | 118 | ensureItemVisible( selectedItem() ); |
116 | return TRUE; | 119 | return TRUE; |
117 | } | 120 | } |
118 | 121 | ||
119 | 122 | ||
120 | bool PlayListSelection::next() { | 123 | bool PlayListSelection::next() { |
121 | QListViewItem *item = selectedItem(); | 124 | QListViewItem *item = selectedItem(); |
122 | if ( item && item->itemBelow() ) | 125 | if ( item && item->itemBelow() ) |
123 | setSelected( item->itemBelow(), TRUE ); | 126 | setSelected( item->itemBelow(), TRUE ); |
124 | else | 127 | else |
125 | return FALSE; | 128 | return FALSE; |
126 | ensureItemVisible( selectedItem() ); | 129 | ensureItemVisible( selectedItem() ); |
127 | return TRUE; | 130 | return TRUE; |
128 | } | 131 | } |
129 | 132 | ||
130 | 133 | ||
131 | bool PlayListSelection::first() { | 134 | bool PlayListSelection::first() { |
132 | QListViewItem *item = firstChild(); | 135 | QListViewItem *item = firstChild(); |
133 | if ( item ) | 136 | if ( item ) |
134 | setSelected( item, TRUE ); | 137 | setSelected( item, TRUE ); |
135 | else | 138 | else |
136 | return FALSE; | 139 | return FALSE; |
137 | ensureItemVisible( selectedItem() ); | 140 | ensureItemVisible( selectedItem() ); |
138 | return TRUE; | 141 | return TRUE; |
139 | } | 142 | } |
140 | 143 | ||
141 | 144 | ||
142 | bool PlayListSelection::last() { | 145 | bool PlayListSelection::last() { |
143 | QListViewItem *prevItem = NULL; | 146 | QListViewItem *prevItem = NULL; |
144 | QListViewItem *item = firstChild(); | 147 | QListViewItem *item = firstChild(); |
145 | while ( ( item = item->nextSibling() ) ) | 148 | while ( ( item = item->nextSibling() ) ) |
146 | prevItem = item; | 149 | prevItem = item; |
147 | if ( prevItem ) | 150 | if ( prevItem ) |
148 | setSelected( prevItem, TRUE ); | 151 | setSelected( prevItem, TRUE ); |
149 | else | 152 | else |
150 | return FALSE; | 153 | return FALSE; |
151 | ensureItemVisible( selectedItem() ); | 154 | ensureItemVisible( selectedItem() ); |
152 | return TRUE; | 155 | return TRUE; |
153 | } | 156 | } |
154 | 157 | ||