-rw-r--r-- | core/apps/embeddedkonsole/konsole.cpp | 10 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/konsole.h | 1 |
2 files changed, 9 insertions, 2 deletions
diff --git a/core/apps/embeddedkonsole/konsole.cpp b/core/apps/embeddedkonsole/konsole.cpp index 7f3ea65..f4ca0bf 100644 --- a/core/apps/embeddedkonsole/konsole.cpp +++ b/core/apps/embeddedkonsole/konsole.cpp | |||
@@ -113,1027 +113,1030 @@ class EKNumTabWidget : public QTabWidget | |||
113 | public: | 113 | public: |
114 | EKNumTabWidget(QWidget* parent) : QTabWidget(parent) | 114 | EKNumTabWidget(QWidget* parent) : QTabWidget(parent) |
115 | { | 115 | { |
116 | setTabBar(new EKNumTabBar(parent,"EKTabBar")); | 116 | setTabBar(new EKNumTabBar(parent,"EKTabBar")); |
117 | setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); | 117 | setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); |
118 | } | 118 | } |
119 | 119 | ||
120 | EKNumTabBar *getTabBar() const | 120 | EKNumTabBar *getTabBar() const |
121 | { | 121 | { |
122 | return ((EKNumTabBar*)tabBar()); | 122 | return ((EKNumTabBar*)tabBar()); |
123 | } | 123 | } |
124 | 124 | ||
125 | 125 | ||
126 | void addTab(QWidget* w) | 126 | void addTab(QWidget* w) |
127 | { | 127 | { |
128 | QTab* t = new QTab(QString::number(tabBar()->count()+1)); | 128 | QTab* t = new QTab(QString::number(tabBar()->count()+1)); |
129 | QTabWidget::addTab(w,t); | 129 | QTabWidget::addTab(w,t); |
130 | } | 130 | } |
131 | 131 | ||
132 | void removeTab(QWidget* w) | 132 | void removeTab(QWidget* w) |
133 | { | 133 | { |
134 | removePage(w); | 134 | removePage(w); |
135 | ((EKNumTabBar*)tabBar())->numberTabs(); | 135 | ((EKNumTabBar*)tabBar())->numberTabs(); |
136 | } | 136 | } |
137 | }; | 137 | }; |
138 | 138 | ||
139 | // This could be configurable or dynamicly generated from the bash history | 139 | // This could be configurable or dynamicly generated from the bash history |
140 | // file of the user | 140 | // file of the user |
141 | static const char *commonCmds[] = | 141 | static const char *commonCmds[] = |
142 | { | 142 | { |
143 | "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 |
144 | "cardctl eject", | 144 | "cardctl eject", |
145 | "cat ", | 145 | "cat ", |
146 | "cd ", | 146 | "cd ", |
147 | "chmod ", | 147 | "chmod ", |
148 | "clear", | 148 | "clear", |
149 | "cp ", | 149 | "cp ", |
150 | "dc ", | 150 | "dc ", |
151 | "df ", | 151 | "df ", |
152 | "dmesg", | 152 | "dmesg", |
153 | "echo ", | 153 | "echo ", |
154 | "env", | 154 | "env", |
155 | "find ", | 155 | "find ", |
156 | "free", | 156 | "free", |
157 | "grep ", | 157 | "grep ", |
158 | "ifconfig ", | 158 | "ifconfig ", |
159 | "ipkg ", | 159 | "ipkg ", |
160 | "mkdir ", | 160 | "mkdir ", |
161 | "mv ", | 161 | "mv ", |
162 | "nc localhost 7776", | 162 | "nc localhost 7776", |
163 | "nc localhost 7777", | 163 | "nc localhost 7777", |
164 | "netstat ", | 164 | "netstat ", |
165 | "nslookup ", | 165 | "nslookup ", |
166 | "ping ", | 166 | "ping ", |
167 | "ps aux", | 167 | "ps aux", |
168 | "pwd ", | 168 | "pwd ", |
169 | // "qcop QPE/System 'linkChanged(QString)' ''", | 169 | // "qcop QPE/System 'linkChanged(QString)' ''", |
170 | // "qcop QPE/System 'restart()'", | 170 | // "qcop QPE/System 'restart()'", |
171 | // "qcop QPE/System 'quit()'", | 171 | // "qcop QPE/System 'quit()'", |
172 | "rm ", | 172 | "rm ", |
173 | "rmdir ", | 173 | "rmdir ", |
174 | "route ", | 174 | "route ", |
175 | "set ", | 175 | "set ", |
176 | "traceroute", | 176 | "traceroute", |
177 | 177 | ||
178 | /* | 178 | /* |
179 | "gzip", | 179 | "gzip", |
180 | "gunzip", | 180 | "gunzip", |
181 | "chgrp", | 181 | "chgrp", |
182 | "chown", | 182 | "chown", |
183 | "date", | 183 | "date", |
184 | "dd", | 184 | "dd", |
185 | "df", | 185 | "df", |
186 | "dmesg", | 186 | "dmesg", |
187 | "fuser", | 187 | "fuser", |
188 | "hostname", | 188 | "hostname", |
189 | "kill", | 189 | "kill", |
190 | "killall", | 190 | "killall", |
191 | "ln", | 191 | "ln", |
192 | "ping", | 192 | "ping", |
193 | "mount", | 193 | "mount", |
194 | "more", | 194 | "more", |
195 | "sort", | 195 | "sort", |
196 | "touch", | 196 | "touch", |
197 | "umount", | 197 | "umount", |
198 | "mknod", | 198 | "mknod", |
199 | "netstat", | 199 | "netstat", |
200 | */ | 200 | */ |
201 | 201 | ||
202 | "exit", | 202 | "exit", |
203 | NULL | 203 | NULL |
204 | }; | 204 | }; |
205 | 205 | ||
206 | 206 | ||
207 | static void konsoleInit(const char** shell) { | 207 | static void konsoleInit(const char** shell) { |
208 | if(setuid(getuid()) !=0) odebug << "setuid failed" << oendl; | 208 | if(setuid(getuid()) !=0) odebug << "setuid failed" << oendl; |
209 | if(setgid(getgid()) != 0) odebug << "setgid failed" << oendl; // drop privileges | 209 | if(setgid(getgid()) != 0) odebug << "setgid failed" << oendl; // drop privileges |
210 | 210 | ||
211 | 211 | ||
212 | // QPEApplication::grabKeyboard(); // for CTRL and ALT | 212 | // QPEApplication::grabKeyboard(); // for CTRL and ALT |
213 | 213 | ||
214 | odebug << "keyboard grabbed" << oendl; | 214 | odebug << "keyboard grabbed" << oendl; |
215 | #ifdef FAKE_CTRL_AND_ALT | 215 | #ifdef FAKE_CTRL_AND_ALT |
216 | odebug << "Fake Ctrl and Alt defined" << oendl; | 216 | odebug << "Fake Ctrl and Alt defined" << oendl; |
217 | QPEApplication::grabKeyboard(); // for CTRL and ALT | 217 | QPEApplication::grabKeyboard(); // for CTRL and ALT |
218 | #endif | 218 | #endif |
219 | 219 | ||
220 | *shell = getenv("SHELL"); | 220 | *shell = getenv("SHELL"); |
221 | owarn << "SHell initially is " << *shell << "" << oendl; | 221 | owarn << "SHell initially is " << *shell << "" << oendl; |
222 | 222 | ||
223 | if (shell == NULL || *shell == '\0') { | 223 | if (shell == NULL || *shell == '\0') { |
224 | struct passwd *ent = 0; | 224 | struct passwd *ent = 0; |
225 | uid_t me = getuid(); | 225 | uid_t me = getuid(); |
226 | *shell = "/bin/sh"; | 226 | *shell = "/bin/sh"; |
227 | 227 | ||
228 | while ( (ent = getpwent()) != 0 ) { | 228 | while ( (ent = getpwent()) != 0 ) { |
229 | if (ent->pw_uid == me) { | 229 | if (ent->pw_uid == me) { |
230 | if (ent->pw_shell != "") | 230 | if (ent->pw_shell != "") |
231 | *shell = ent->pw_shell; | 231 | *shell = ent->pw_shell; |
232 | break; | 232 | break; |
233 | } | 233 | } |
234 | } | 234 | } |
235 | endpwent(); | 235 | endpwent(); |
236 | } | 236 | } |
237 | 237 | ||
238 | if( putenv((char*)"COLORTERM=") !=0) | 238 | if( putenv((char*)"COLORTERM=") !=0) |
239 | odebug << "putenv failed" << oendl; // to trigger mc's color detection | 239 | odebug << "putenv failed" << oendl; // to trigger mc's color detection |
240 | } | 240 | } |
241 | 241 | ||
242 | 242 | ||
243 | Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) : | 243 | Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) : |
244 | QMainWindow(parent, name, fl) | 244 | QMainWindow(parent, name, fl) |
245 | { | 245 | { |
246 | QStrList tmp; const char* shell; | 246 | QStrList tmp; const char* shell; |
247 | 247 | ||
248 | konsoleInit( &shell); | 248 | konsoleInit( &shell); |
249 | init(shell,tmp); | 249 | init(shell,tmp); |
250 | } | 250 | } |
251 | 251 | ||
252 | Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int) | 252 | Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int) |
253 | : QMainWindow(0, name) | 253 | : QMainWindow(0, name) |
254 | { | 254 | { |
255 | init(_pgm,_args); | 255 | init(_pgm,_args); |
256 | } | 256 | } |
257 | 257 | ||
258 | struct HistoryItem | 258 | struct HistoryItem |
259 | { | 259 | { |
260 | HistoryItem(int c, const QString &l) | 260 | HistoryItem(int c, const QString &l) |
261 | { | 261 | { |
262 | count = c; | 262 | count = c; |
263 | line = l; | 263 | line = l; |
264 | } | 264 | } |
265 | int count; | 265 | int count; |
266 | QString line; | 266 | QString line; |
267 | }; | 267 | }; |
268 | 268 | ||
269 | class HistoryList : public QList<HistoryItem> | 269 | class HistoryList : public QList<HistoryItem> |
270 | { | 270 | { |
271 | virtual int compareItems( QCollection::Item item1, QCollection::Item item2) | 271 | virtual int compareItems( QCollection::Item item1, QCollection::Item item2) |
272 | { | 272 | { |
273 | int c1 = ((HistoryItem*)item1)->count; | 273 | int c1 = ((HistoryItem*)item1)->count; |
274 | int c2 = ((HistoryItem*)item2)->count; | 274 | int c2 = ((HistoryItem*)item2)->count; |
275 | if (c1 > c2) | 275 | if (c1 > c2) |
276 | return(1); | 276 | return(1); |
277 | if (c1 < c2) | 277 | if (c1 < c2) |
278 | return(-1); | 278 | return(-1); |
279 | return(0); | 279 | return(0); |
280 | } | 280 | } |
281 | }; | 281 | }; |
282 | 282 | ||
283 | void Konsole::initCommandList() | 283 | void Konsole::initCommandList() |
284 | { | 284 | { |
285 | // odebug << "Konsole::initCommandList" << oendl; | 285 | // odebug << "Konsole::initCommandList" << oendl; |
286 | Config cfg( "Konsole" ); | 286 | Config cfg( "Konsole" ); |
287 | cfg.setGroup("Commands"); | 287 | cfg.setGroup("Commands"); |
288 | // commonCombo->setInsertionPolicy(QComboBox::AtCurrent); | 288 | // commonCombo->setInsertionPolicy(QComboBox::AtCurrent); |
289 | commonCombo->clear(); | 289 | commonCombo->clear(); |
290 | 290 | ||
291 | if (cfg.readEntry("ShellHistory","TRUE") == "FALSE") { | 291 | if (cfg.readEntry("ShellHistory","TRUE") == "FALSE") { |
292 | QString histfilename = QString(getenv("HOME")) + "/.bash_history"; | 292 | QString histfilename = QString(getenv("HOME")) + "/.bash_history"; |
293 | histfilename = cfg.readEntry("ShellHistoryPath",histfilename); | 293 | histfilename = cfg.readEntry("ShellHistoryPath",histfilename); |
294 | QFile histfile(histfilename); | 294 | QFile histfile(histfilename); |
295 | // note: compiler barfed on: | 295 | // note: compiler barfed on: |
296 | // QFile histfile(QString(getenv("HOME")) + "/.bash_history"); | 296 | // QFile histfile(QString(getenv("HOME")) + "/.bash_history"); |
297 | if (histfile.open( IO_ReadOnly )) { | 297 | if (histfile.open( IO_ReadOnly )) { |
298 | QString line; | 298 | QString line; |
299 | uint i; | 299 | uint i; |
300 | HistoryList items; | 300 | HistoryList items; |
301 | 301 | ||
302 | int lineno = 0; | 302 | int lineno = 0; |
303 | while(!histfile.atEnd()) { | 303 | while(!histfile.atEnd()) { |
304 | if (histfile.readLine(line, 200) < 0) { | 304 | if (histfile.readLine(line, 200) < 0) { |
305 | break; | 305 | break; |
306 | } | 306 | } |
307 | line = line.left(line.length()-1); | 307 | line = line.left(line.length()-1); |
308 | lineno++; | 308 | lineno++; |
309 | 309 | ||
310 | for(i=0; i<items.count(); i++) { | 310 | for(i=0; i<items.count(); i++) { |
311 | if (line == items.at(i)->line) { | 311 | if (line == items.at(i)->line) { |
312 | // weight recent commands & repeated commands more | 312 | // weight recent commands & repeated commands more |
313 | // by adding up the index of each command | 313 | // by adding up the index of each command |
314 | items.at(i)->count += lineno; | 314 | items.at(i)->count += lineno; |
315 | break; | 315 | break; |
316 | } | 316 | } |
317 | } | 317 | } |
318 | if (i >= items.count()) { | 318 | if (i >= items.count()) { |
319 | items.append(new HistoryItem(lineno, line)); | 319 | items.append(new HistoryItem(lineno, line)); |
320 | } | 320 | } |
321 | } | 321 | } |
322 | items.sort(); | 322 | items.sort(); |
323 | int n = items.count(); | 323 | int n = items.count(); |
324 | if (n > 40) { | 324 | if (n > 40) { |
325 | n = 40; | 325 | n = 40; |
326 | } | 326 | } |
327 | for(int i=0; i<n; i++) { | 327 | for(int i=0; i<n; i++) { |
328 | // should insert start of command, but keep whole thing | 328 | // should insert start of command, but keep whole thing |
329 | if (items.at(items.count()-i-1)->line.length() < 30) { | 329 | if (items.at(items.count()-i-1)->line.length() < 30) { |
330 | commonCombo->insertItem(items.at(items.count()-i-1)->line); | 330 | commonCombo->insertItem(items.at(items.count()-i-1)->line); |
331 | } | 331 | } |
332 | } | 332 | } |
333 | histfile.close(); | 333 | histfile.close(); |
334 | } | 334 | } |
335 | } | 335 | } |
336 | if (cfg.readEntry("Commands Set","FALSE") == "FALSE") { | 336 | if (cfg.readEntry("Commands Set","FALSE") == "FALSE") { |
337 | for (int i = 0; commonCmds[i] != NULL; i++) { | 337 | for (int i = 0; commonCmds[i] != NULL; i++) { |
338 | commonCombo->insertItem(commonCmds[i]); | 338 | commonCombo->insertItem(commonCmds[i]); |
339 | } | 339 | } |
340 | } else { | 340 | } else { |
341 | for (int i = 0; i < 100; i++) { | 341 | for (int i = 0; i < 100; i++) { |
342 | if (!(cfg.readEntry( QString::number(i),"")).isEmpty()) | 342 | if (!(cfg.readEntry( QString::number(i),"")).isEmpty()) |
343 | commonCombo->insertItem(cfg.readEntry( QString::number(i),"")); | 343 | commonCombo->insertItem(cfg.readEntry( QString::number(i),"")); |
344 | } | 344 | } |
345 | } | 345 | } |
346 | 346 | ||
347 | 347 | ||
348 | } | 348 | } |
349 | 349 | ||
350 | static void sig_handler(int x) | 350 | static void sig_handler(int x) |
351 | { | 351 | { |
352 | printf("got signal %d\n",x); | 352 | printf("got signal %d\n",x); |
353 | } | 353 | } |
354 | 354 | ||
355 | void Konsole::init(const char* _pgm, QStrList & _args) | 355 | void Konsole::init(const char* _pgm, QStrList & _args) |
356 | { | 356 | { |
357 | 357 | ||
358 | #if 0 | 358 | #if 0 |
359 | for(int i=1; i<=31; i++) | 359 | for(int i=1; i<=31; i++) |
360 | { | 360 | { |
361 | if (i != SIGPIPE && i != SIGPROF && i != SIGSEGV | 361 | if (i != SIGPIPE && i != SIGPROF && i != SIGSEGV |
362 | && i != SIGINT && i != SIGILL && i != SIGTERM | 362 | && i != SIGINT && i != SIGILL && i != SIGTERM |
363 | && i != SIGBUS) | 363 | && i != SIGBUS) |
364 | signal(i,sig_handler); | 364 | signal(i,sig_handler); |
365 | } | 365 | } |
366 | #endif | 366 | #endif |
367 | signal(SIGSTOP, sig_handler); | 367 | signal(SIGSTOP, sig_handler); |
368 | signal(SIGCONT, sig_handler); | 368 | signal(SIGCONT, sig_handler); |
369 | signal(SIGTSTP, sig_handler); | 369 | signal(SIGTSTP, sig_handler); |
370 | 370 | ||
371 | b_scroll = TRUE; // histon; | 371 | b_scroll = TRUE; // histon; |
372 | n_keytab = 0; | 372 | n_keytab = 0; |
373 | n_render = 0; | 373 | n_render = 0; |
374 | startUp=0; | 374 | startUp=0; |
375 | fromMenu = FALSE; | 375 | fromMenu = FALSE; |
376 | fullscreen = false; | 376 | fullscreen = false; |
377 | 377 | ||
378 | setCaption( tr( "Konsole" ) ); | 378 | setCaption( tr( "Konsole" ) ); |
379 | setIcon( Opie::Core::OResource::loadPixmap( "konsole/Terminal", Opie::Core::OResource::SmallIcon ) ); | 379 | setIcon( Opie::Core::OResource::loadPixmap( "konsole/Terminal", Opie::Core::OResource::SmallIcon ) ); |
380 | 380 | ||
381 | Config cfg( "Konsole" ); | 381 | Config cfg( "Konsole" ); |
382 | cfg.setGroup("Font"); | 382 | cfg.setGroup("Font"); |
383 | QString tmp; | 383 | QString tmp; |
384 | 384 | ||
385 | // initialize the list of allowed fonts /////////////////////////////////// | 385 | // initialize the list of allowed fonts /////////////////////////////////// |
386 | 386 | ||
387 | QString cfgFontName = cfg.readEntry("FontName","Lcfont"); | 387 | QString cfgFontName = cfg.readEntry("FontName","Lcfont"); |
388 | int cfgFontSize = cfg.readNumEntry("FontSize",18); | 388 | int cfgFontSize = cfg.readNumEntry("FontSize",18); |
389 | 389 | ||
390 | cfont = -1; | 390 | cfont = -1; |
391 | 391 | ||
392 | // this code causes repeated access to all the font files | 392 | // this code causes repeated access to all the font files |
393 | // which does slow down startup | 393 | // which does slow down startup |
394 | QFontDatabase fontDB; | 394 | QFontDatabase fontDB; |
395 | QStringList familyNames; | 395 | QStringList familyNames; |
396 | familyNames = fontDB.families( FALSE ); | 396 | familyNames = fontDB.families( FALSE ); |
397 | QString s; | 397 | QString s; |
398 | int fontIndex = 0; | 398 | int fontIndex = 0; |
399 | int familyNum = 0; | 399 | int familyNum = 0; |
400 | fontList = new QPopupMenu( this ); | 400 | fontList = new QPopupMenu( this ); |
401 | 401 | ||
402 | for(uint j = 0; j < (uint)familyNames.count(); j++) | 402 | for(uint j = 0; j < (uint)familyNames.count(); j++) |
403 | { | 403 | { |
404 | s = familyNames[j]; | 404 | s = familyNames[j]; |
405 | if ( s.contains('-') ) | 405 | if ( s.contains('-') ) |
406 | { | 406 | { |
407 | int i = s.find('-'); | 407 | int i = s.find('-'); |
408 | s = s.right( s.length() - i - 1 ) + " [" + s.left( i ) + "]"; | 408 | s = s.right( s.length() - i - 1 ) + " [" + s.left( i ) + "]"; |
409 | } | 409 | } |
410 | s[0] = s[0].upper(); | 410 | s[0] = s[0].upper(); |
411 | 411 | ||
412 | QValueList<int> sizes = fontDB.pointSizes( familyNames[j] ); | 412 | QValueList<int> sizes = fontDB.pointSizes( familyNames[j] ); |
413 | 413 | ||
414 | printf("family[%d] = %s with %d sizes\n", j, familyNames[j].latin1(), | 414 | printf("family[%d] = %s with %d sizes\n", j, familyNames[j].latin1(), |
415 | sizes.count()); | 415 | sizes.count()); |
416 | 416 | ||
417 | if (sizes.count() > 0) | 417 | if (sizes.count() > 0) |
418 | { | 418 | { |
419 | QPopupMenu *sizeMenu; | 419 | QPopupMenu *sizeMenu; |
420 | QFont f; | 420 | QFont f; |
421 | int last_width = -1; | 421 | int last_width = -1; |
422 | sizeMenu = NULL; | 422 | sizeMenu = NULL; |
423 | 423 | ||
424 | for(uint i = 0; i < (uint)sizes.count() + 4; i++) | 424 | for(uint i = 0; i < (uint)sizes.count() + 4; i++) |
425 | { | 425 | { |
426 | // printf("family %s size %d ", familyNames[j].latin1(), sizes[i]); | 426 | // printf("family %s size %d ", familyNames[j].latin1(), sizes[i]); |
427 | // need to divide by 10 on the Z, but not otherwise | 427 | // need to divide by 10 on the Z, but not otherwise |
428 | int size; | 428 | int size; |
429 | 429 | ||
430 | if (i >= (uint)sizes.count()) | 430 | if (i >= (uint)sizes.count()) |
431 | { | 431 | { |
432 | // try for expandable fonts | 432 | // try for expandable fonts |
433 | size = sizes[sizes.count()-1] + 2 * (i - sizes.count() + 1); | 433 | size = sizes[sizes.count()-1] + 2 * (i - sizes.count() + 1); |
434 | } | 434 | } |
435 | else | 435 | else |
436 | { | 436 | { |
437 | printf("sizes[%d] = %d\n", i, sizes[i]); | 437 | printf("sizes[%d] = %d\n", i, sizes[i]); |
438 | size = sizes[i]; | 438 | size = sizes[i]; |
439 | } | 439 | } |
440 | 440 | ||
441 | f = QFont(familyNames[j], size); | 441 | f = QFont(familyNames[j], size); |
442 | f.setFixedPitch(true); | 442 | f.setFixedPitch(true); |
443 | QFontMetrics fm(f); | 443 | QFontMetrics fm(f); |
444 | // don't trust f.fixedPitch() or f.exactMatch(), they lie!! | 444 | // don't trust f.fixedPitch() or f.exactMatch(), they lie!! |
445 | if (fm.width("l") == fm.width("m") | 445 | if (fm.width("l") == fm.width("m") |
446 | && (i < (uint)sizes.count() | 446 | && (i < (uint)sizes.count() |
447 | || fm.width("m") > last_width)) | 447 | || fm.width("m") > last_width)) |
448 | { | 448 | { |
449 | if (i < (uint)sizes.count()) | 449 | if (i < (uint)sizes.count()) |
450 | { | 450 | { |
451 | last_width = fm.width("m"); | 451 | last_width = fm.width("m"); |
452 | } | 452 | } |
453 | if (sizeMenu == NULL) | 453 | if (sizeMenu == NULL) |
454 | { | 454 | { |
455 | sizeMenu = new QPopupMenu(); | 455 | sizeMenu = new QPopupMenu(); |
456 | } | 456 | } |
457 | int id = sizeMenu->insertItem(QString("%1").arg(size), fontIndex); | 457 | int id = sizeMenu->insertItem(QString("%1").arg(size), fontIndex); |
458 | sizeMenu->setItemParameter(id, fontIndex); | 458 | sizeMenu->setItemParameter(id, fontIndex); |
459 | sizeMenu->connectItem(id, this, SLOT(setFont(int))); | 459 | sizeMenu->connectItem(id, this, SLOT(setFont(int))); |
460 | QString name = s + " " + QString::number(size); | 460 | QString name = s + " " + QString::number(size); |
461 | fonts.append(new VTFont(name, f, familyNames[j], familyNum, size)); | 461 | fonts.append(new VTFont(name, f, familyNames[j], familyNum, size)); |
462 | if (familyNames[j] == cfgFontName && size == cfgFontSize) | 462 | if (familyNames[j] == cfgFontName && size == cfgFontSize) |
463 | { | 463 | { |
464 | cfont = fontIndex; | 464 | cfont = fontIndex; |
465 | } | 465 | } |
466 | printf("FOUND: %s family %s size %d\n", name.latin1(), familyNames[j].latin1(), size); | 466 | printf("FOUND: %s family %s size %d\n", name.latin1(), familyNames[j].latin1(), size); |
467 | fontIndex++; | 467 | fontIndex++; |
468 | } | 468 | } |
469 | } | 469 | } |
470 | if (sizeMenu) | 470 | if (sizeMenu) |
471 | { | 471 | { |
472 | fontList->insertItem(s, sizeMenu, familyNum + 1000); | 472 | fontList->insertItem(s, sizeMenu, familyNum + 1000); |
473 | 473 | ||
474 | familyNum++; | 474 | familyNum++; |
475 | } | 475 | } |
476 | } | 476 | } |
477 | 477 | ||
478 | } | 478 | } |
479 | 479 | ||
480 | if (cfont < 0 || cfont >= (int)fonts.count()) | 480 | if (cfont < 0 || cfont >= (int)fonts.count()) |
481 | { | 481 | { |
482 | cfont = 0; | 482 | cfont = 0; |
483 | } | 483 | } |
484 | 484 | ||
485 | // create terminal emulation framework //////////////////////////////////// | 485 | // create terminal emulation framework //////////////////////////////////// |
486 | nsessions = 0; | 486 | nsessions = 0; |
487 | 487 | ||
488 | tab = new EKNumTabWidget(this); | 488 | tab = new EKNumTabWidget(this); |
489 | // tab->setMargin(tab->margin()-5); | 489 | // tab->setMargin(tab->margin()-5); |
490 | connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*))); | 490 | connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*))); |
491 | 491 | ||
492 | // create terminal toolbar //////////////////////////////////////////////// | 492 | // create terminal toolbar //////////////////////////////////////////////// |
493 | setToolBarsMovable( FALSE ); | 493 | setToolBarsMovable( FALSE ); |
494 | menuToolBar = new QToolBar( this ); | 494 | menuToolBar = new QToolBar( this ); |
495 | menuToolBar->setHorizontalStretchable( TRUE ); | 495 | menuToolBar->setHorizontalStretchable( TRUE ); |
496 | 496 | ||
497 | QMenuBar *menuBar = new QMenuBar( menuToolBar ); | 497 | QMenuBar *menuBar = new QMenuBar( menuToolBar ); |
498 | 498 | ||
499 | setFont(cfont); | 499 | setFont(cfont); |
500 | 500 | ||
501 | configMenu = new QPopupMenu( this); | 501 | configMenu = new QPopupMenu( this); |
502 | colorMenu = new QPopupMenu( this); | 502 | colorMenu = new QPopupMenu( this); |
503 | scrollMenu = new QPopupMenu( this); | 503 | scrollMenu = new QPopupMenu( this); |
504 | editCommandListMenu = new QPopupMenu( this); | 504 | editCommandListMenu = new QPopupMenu( this); |
505 | 505 | ||
506 | configMenu->insertItem(tr("Command List"), editCommandListMenu); | 506 | configMenu->insertItem(tr("Command List"), editCommandListMenu); |
507 | 507 | ||
508 | bool listHidden; | 508 | bool listHidden; |
509 | cfg.setGroup("Menubar"); | 509 | cfg.setGroup("Menubar"); |
510 | if( cfg.readEntry("Hidden","FALSE") == "TRUE") | 510 | if( cfg.readEntry("Hidden","FALSE") == "TRUE") |
511 | { | 511 | { |
512 | ec_cmdlist = editCommandListMenu->insertItem( tr( "Show command list" )); | 512 | ec_cmdlist = editCommandListMenu->insertItem( tr( "Show command list" )); |
513 | listHidden=TRUE; | 513 | listHidden=TRUE; |
514 | } | 514 | } |
515 | else | 515 | else |
516 | { | 516 | { |
517 | ec_cmdlist = editCommandListMenu->insertItem( tr( "Hide command list" )); | 517 | ec_cmdlist = editCommandListMenu->insertItem( tr( "Hide command list" )); |
518 | listHidden=FALSE; | 518 | listHidden=FALSE; |
519 | } | 519 | } |
520 | 520 | ||
521 | cfg.setGroup("Tabs"); | 521 | cfg.setGroup("Tabs"); |
522 | 522 | ||
523 | tabMenu = new QPopupMenu(this); | 523 | tabMenu = new QPopupMenu(this); |
524 | tm_bottom = tabMenu->insertItem(tr("Bottom" )); | 524 | tm_bottom = tabMenu->insertItem(tr("Bottom" )); |
525 | tm_top = tabMenu->insertItem(tr("Top")); | 525 | tm_top = tabMenu->insertItem(tr("Top")); |
526 | tm_hidden = tabMenu->insertItem(tr("Hidden")); | 526 | tm_hidden = tabMenu->insertItem(tr("Hidden")); |
527 | 527 | ||
528 | configMenu->insertItem(tr("Tabs"), tabMenu); | 528 | configMenu->insertItem(tr("Tabs"), tabMenu); |
529 | 529 | ||
530 | tmp=cfg.readEntry("Position","Top"); | 530 | tmp=cfg.readEntry("Position","Top"); |
531 | if(tmp=="Top") | 531 | if(tmp=="Top") |
532 | { | 532 | { |
533 | tab->setTabPosition(QTabWidget::Top); | 533 | tab->setTabPosition(QTabWidget::Top); |
534 | tab->getTabBar()->show(); | 534 | tab->getTabBar()->show(); |
535 | tabPos = tm_top; | 535 | tabPos = tm_top; |
536 | } | 536 | } |
537 | else if (tmp=="Bottom") | 537 | else if (tmp=="Bottom") |
538 | { | 538 | { |
539 | tab->setTabPosition(QTabWidget::Bottom); | 539 | tab->setTabPosition(QTabWidget::Bottom); |
540 | tab->getTabBar()->show(); | 540 | tab->getTabBar()->show(); |
541 | tabPos = tm_bottom; | 541 | tabPos = tm_bottom; |
542 | } | 542 | } |
543 | else | 543 | else |
544 | { | 544 | { |
545 | tab->getTabBar()->hide(); | 545 | tab->getTabBar()->hide(); |
546 | tab->setMargin(tab->margin()); | 546 | tab->setMargin(tab->margin()); |
547 | tabPos = tm_hidden; | 547 | tabPos = tm_hidden; |
548 | } | 548 | } |
549 | 549 | ||
550 | cm_bw = colorMenu->insertItem(tr( "Black on White")); | 550 | cm_bw = colorMenu->insertItem(tr( "Black on White")); |
551 | cm_wb = colorMenu->insertItem(tr( "White on Black")); | 551 | cm_wb = colorMenu->insertItem(tr( "White on Black")); |
552 | cm_gb = colorMenu->insertItem(tr( "Green on Black")); | 552 | cm_gb = colorMenu->insertItem(tr( "Green on Black")); |
553 | // cm_bt = colorMenu->insertItem(tr( "Black on Transparent")); | 553 | // cm_bt = colorMenu->insertItem(tr( "Black on Transparent")); |
554 | cm_br = colorMenu->insertItem(tr( "Black on Pink")); | 554 | cm_br = colorMenu->insertItem(tr( "Black on Pink")); |
555 | cm_rb = colorMenu->insertItem(tr( "Pink on Black")); | 555 | cm_rb = colorMenu->insertItem(tr( "Pink on Black")); |
556 | cm_gy = colorMenu->insertItem(tr( "Green on Yellow")); | 556 | cm_gy = colorMenu->insertItem(tr( "Green on Yellow")); |
557 | cm_bm = colorMenu->insertItem(tr( "Blue on Magenta")); | 557 | cm_bm = colorMenu->insertItem(tr( "Blue on Magenta")); |
558 | cm_mb = colorMenu->insertItem(tr( "Magenta on Blue")); | 558 | cm_mb = colorMenu->insertItem(tr( "Magenta on Blue")); |
559 | cm_cw = colorMenu->insertItem(tr( "Cyan on White")); | 559 | cm_cw = colorMenu->insertItem(tr( "Cyan on White")); |
560 | cm_wc = colorMenu->insertItem(tr( "White on Cyan")); | 560 | cm_wc = colorMenu->insertItem(tr( "White on Cyan")); |
561 | cm_bb = colorMenu->insertItem(tr( "Blue on Black")); | 561 | cm_bb = colorMenu->insertItem(tr( "Blue on Black")); |
562 | cm_ab = colorMenu->insertItem(tr( "Amber on Black")); | 562 | cm_ab = colorMenu->insertItem(tr( "Amber on Black")); |
563 | cm_default = colorMenu->insertItem(tr("default")); | 563 | cm_default = colorMenu->insertItem(tr("default")); |
564 | 564 | ||
565 | #ifdef QT_QWS_OPIE | 565 | #ifdef QT_QWS_OPIE |
566 | 566 | ||
567 | colorMenu->insertItem(tr( "Custom")); | 567 | colorMenu->insertItem(tr( "Custom")); |
568 | #endif | 568 | #endif |
569 | 569 | ||
570 | configMenu->insertItem(tr( "Colors") ,colorMenu); | 570 | configMenu->insertItem(tr( "Colors") ,colorMenu); |
571 | 571 | ||
572 | sessionList = new QPopupMenu(this); | 572 | sessionList = new QPopupMenu(this); |
573 | sessionList-> insertItem ( Opie::Core::OResource::loadPixmap( "konsole/Terminal", Opie::Core::OResource::SmallIcon ), | 573 | sessionList-> insertItem ( Opie::Core::OResource::loadPixmap( "konsole/Terminal", Opie::Core::OResource::SmallIcon ), |
574 | tr( "new session" ), this, SLOT(newSession()) ); | 574 | tr( "new session" ), this, SLOT(newSession()) ); |
575 | 575 | ||
576 | // connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) )); | 576 | // connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) )); |
577 | connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) )); | 577 | connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) )); |
578 | connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuIsSelected(int) )); | 578 | connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuIsSelected(int) )); |
579 | connect( tabMenu, SIGNAL( activated(int) ), this, SLOT( tabMenuSelected(int) )); | 579 | connect( tabMenu, SIGNAL( activated(int) ), this, SLOT( tabMenuSelected(int) )); |
580 | connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int))); | 580 | connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int))); |
581 | connect( editCommandListMenu,SIGNAL(activated(int)),this,SLOT(editCommandListMenuSelected(int))); | 581 | connect( editCommandListMenu,SIGNAL(activated(int)),this,SLOT(editCommandListMenuSelected(int))); |
582 | connect( sessionList, SIGNAL(activated(int)), this, SLOT( sessionListSelected(int) ) ); | 582 | connect( sessionList, SIGNAL(activated(int)), this, SLOT( sessionListSelected(int) ) ); |
583 | 583 | ||
584 | menuBar->insertItem( tr("View"), configMenu ); | 584 | menuBar->insertItem( tr("View"), configMenu ); |
585 | menuBar->insertItem( tr("Fonts"), fontList ); | 585 | menuBar->insertItem( tr("Fonts"), fontList ); |
586 | menuBar->insertItem( tr("Sessions"), sessionList ); | 586 | menuBar->insertItem( tr("Sessions"), sessionList ); |
587 | 587 | ||
588 | toolBar = new QToolBar( this ); | 588 | toolBar = new QToolBar( this ); |
589 | 589 | ||
590 | QAction *a; | 590 | QAction *a; |
591 | 591 | ||
592 | // Button Commands | 592 | // Button Commands |
593 | a = new QAction( tr("New"), Opie::Core::OResource::loadPixmap( "konsole/konsole", Opie::Core::OResource::SmallIcon ), | 593 | a = new QAction( tr("New"), Opie::Core::OResource::loadPixmap( "konsole/konsole", Opie::Core::OResource::SmallIcon ), |
594 | QString::null, 0, this, 0 ); | 594 | QString::null, 0, this, 0 ); |
595 | connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); | 595 | connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); |
596 | a->addTo( toolBar ); | 596 | a->addTo( toolBar ); |
597 | 597 | ||
598 | a = new QAction( tr("Full Screen"), Opie::Core::OResource::loadPixmap( "fullscreen", Opie::Core::OResource::SmallIcon ), | 598 | a = new QAction( tr("Full Screen"), Opie::Core::OResource::loadPixmap( "fullscreen", Opie::Core::OResource::SmallIcon ), |
599 | QString::null, 0, this, 0 ); | 599 | QString::null, 0, this, 0 ); |
600 | connect( a, SIGNAL( activated() ), this, SLOT( toggleFullScreen() ) ); | 600 | connect( a, SIGNAL( activated() ), this, SLOT( toggleFullScreen() ) ); |
601 | a->addTo( toolBar ); | 601 | a->addTo( toolBar ); |
602 | 602 | ||
603 | a = new QAction( tr("Zoom"), Opie::Core::OResource::loadPixmap( "zoom", Opie::Core::OResource::SmallIcon ), | 603 | a = new QAction( tr("Zoom"), Opie::Core::OResource::loadPixmap( "zoom", Opie::Core::OResource::SmallIcon ), |
604 | QString::null, 0, this, 0 ); | 604 | QString::null, 0, this, 0 ); |
605 | connect( a, SIGNAL( activated() ), this, SLOT( cycleZoom() ) ); | 605 | connect( a, SIGNAL( activated() ), this, SLOT( cycleZoom() ) ); |
606 | a->addTo( toolBar ); | 606 | a->addTo( toolBar ); |
607 | 607 | ||
608 | 608 | ||
609 | a = new QAction( tr("Enter"), Opie::Core::OResource::loadPixmap( "konsole/enter", Opie::Core::OResource::SmallIcon ), | 609 | a = new QAction( tr("Enter"), Opie::Core::OResource::loadPixmap( "konsole/enter", Opie::Core::OResource::SmallIcon ), |
610 | QString::null, 0, this, 0 ); | 610 | QString::null, 0, this, 0 ); |
611 | connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolBar ); | 611 | connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolBar ); |
612 | a = new QAction( tr("Space"), Opie::Core::OResource::loadPixmap( "konsole/space", Opie::Core::OResource::SmallIcon ), | 612 | a = new QAction( tr("Space"), Opie::Core::OResource::loadPixmap( "konsole/space", Opie::Core::OResource::SmallIcon ), |
613 | QString::null, 0, this, 0 ); | 613 | QString::null, 0, this, 0 ); |
614 | connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolBar ); | 614 | connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolBar ); |
615 | a = new QAction( tr("Tab"), Opie::Core::OResource::loadPixmap( "konsole/tab", Opie::Core::OResource::SmallIcon ), | 615 | a = new QAction( tr("Tab"), Opie::Core::OResource::loadPixmap( "konsole/tab", Opie::Core::OResource::SmallIcon ), |
616 | QString::null, 0, this, 0 ); | 616 | QString::null, 0, this, 0 ); |
617 | connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolBar ); | 617 | connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolBar ); |
618 | a = new QAction( tr("Up"), Opie::Core::OResource::loadPixmap( "konsole/up", Opie::Core::OResource::SmallIcon ), | 618 | a = new QAction( tr("Up"), Opie::Core::OResource::loadPixmap( "konsole/up", Opie::Core::OResource::SmallIcon ), |
619 | QString::null, 0, this, 0 ); | 619 | QString::null, 0, this, 0 ); |
620 | connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolBar ); | 620 | connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolBar ); |
621 | a = new QAction( tr("Down"), Opie::Core::OResource::loadPixmap( "konsole/down", Opie::Core::OResource::SmallIcon ), | 621 | a = new QAction( tr("Down"), Opie::Core::OResource::loadPixmap( "konsole/down", Opie::Core::OResource::SmallIcon ), |
622 | QString::null, 0, this, 0 ); | 622 | QString::null, 0, this, 0 ); |
623 | connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolBar ); | 623 | connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolBar ); |
624 | 624 | ||
625 | a = new QAction( tr("Paste"), Opie::Core::OResource::loadPixmap( "paste", Opie::Core::OResource::SmallIcon ), | 625 | a = new QAction( tr("Paste"), Opie::Core::OResource::loadPixmap( "paste", Opie::Core::OResource::SmallIcon ), QString::null, 0, this, 0 ); |
626 | QString::null, 0, this, 0 ); | ||
627 | connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); | 626 | connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); |
627 | |||
628 | a = new QAction( tr("Close"), Opie::Core::OResource::loadPixmap( "close", Opie::Core::OResource::SmallIcon ),QString::null, 0, this, 0 ); | ||
629 | connect( a, SIGNAL( activated() ), this, SLOT( closeSession() ) ); | ||
630 | |||
628 | a->addTo( toolBar ); | 631 | a->addTo( toolBar ); |
629 | 632 | ||
630 | secondToolBar = new QToolBar( this ); | 633 | secondToolBar = new QToolBar( this ); |
631 | secondToolBar->setHorizontalStretchable( TRUE ); | 634 | secondToolBar->setHorizontalStretchable( TRUE ); |
632 | 635 | ||
633 | commonCombo = new QComboBox( secondToolBar ); | 636 | commonCombo = new QComboBox( secondToolBar ); |
634 | // commonCombo->setMaximumWidth(236); | 637 | // commonCombo->setMaximumWidth(236); |
635 | 638 | ||
636 | ec_quick = editCommandListMenu->insertItem( tr( "Quick Edit" ) ); | 639 | ec_quick = editCommandListMenu->insertItem( tr( "Quick Edit" ) ); |
637 | if( listHidden) | 640 | if( listHidden) |
638 | { | 641 | { |
639 | secondToolBar->hide(); | 642 | secondToolBar->hide(); |
640 | editCommandListMenu->setItemEnabled(ec_quick ,FALSE); | 643 | editCommandListMenu->setItemEnabled(ec_quick ,FALSE); |
641 | } | 644 | } |
642 | ec_edit = editCommandListMenu->insertItem(tr( "Edit..." ) ); | 645 | ec_edit = editCommandListMenu->insertItem(tr( "Edit..." ) ); |
643 | 646 | ||
644 | cfg.setGroup("Commands"); | 647 | cfg.setGroup("Commands"); |
645 | commonCombo->setInsertionPolicy(QComboBox::AtCurrent); | 648 | commonCombo->setInsertionPolicy(QComboBox::AtCurrent); |
646 | 649 | ||
647 | initCommandList(); | 650 | initCommandList(); |
648 | // for (int i = 0; commonCmds[i] != NULL; i++) { | 651 | // for (int i = 0; commonCmds[i] != NULL; i++) { |
649 | // commonCombo->insertItem( commonCmds[i], i ); | 652 | // commonCombo->insertItem( commonCmds[i], i ); |
650 | // tmp = cfg.readEntry( QString::number(i),""); | 653 | // tmp = cfg.readEntry( QString::number(i),""); |
651 | // if(tmp != "") | 654 | // if(tmp != "") |
652 | // commonCombo->changeItem( tmp,i ); | 655 | // commonCombo->changeItem( tmp,i ); |
653 | // } | 656 | // } |
654 | 657 | ||
655 | connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) )); | 658 | connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) )); |
656 | 659 | ||
657 | sm_none = scrollMenu->insertItem(tr( "None" )); | 660 | sm_none = scrollMenu->insertItem(tr( "None" )); |
658 | sm_left = scrollMenu->insertItem(tr( "Left" )); | 661 | sm_left = scrollMenu->insertItem(tr( "Left" )); |
659 | sm_right = scrollMenu->insertItem(tr( "Right" )); | 662 | sm_right = scrollMenu->insertItem(tr( "Right" )); |
660 | // scrollMenu->insertSeparator(4); | 663 | // scrollMenu->insertSeparator(4); |
661 | // scrollMenu->insertItem(tr( "Horizontal" )); | 664 | // scrollMenu->insertItem(tr( "Horizontal" )); |
662 | 665 | ||
663 | configMenu->insertItem(tr( "ScrollBar" ),scrollMenu); | 666 | configMenu->insertItem(tr( "ScrollBar" ),scrollMenu); |
664 | 667 | ||
665 | configMenu->insertItem(tr( "History..." ), this, SLOT(historyDialog())); | 668 | configMenu->insertItem(tr( "History..." ), this, SLOT(historyDialog())); |
666 | 669 | ||
667 | cm_wrap = configMenu->insertItem(tr( "Wrap" )); | 670 | cm_wrap = configMenu->insertItem(tr( "Wrap" )); |
668 | cfg.setGroup("ScrollBar"); | 671 | cfg.setGroup("ScrollBar"); |
669 | configMenu->setItemChecked(cm_wrap, cfg.readBoolEntry("HorzScroll",0)); | 672 | configMenu->setItemChecked(cm_wrap, cfg.readBoolEntry("HorzScroll",0)); |
670 | 673 | ||
671 | cm_beep = configMenu->insertItem(tr( "Use Beep" )); | 674 | cm_beep = configMenu->insertItem(tr( "Use Beep" )); |
672 | cfg.setGroup("Menubar"); | 675 | cfg.setGroup("Menubar"); |
673 | configMenu->setItemChecked(cm_beep, cfg.readBoolEntry("useBeep",0)); | 676 | configMenu->setItemChecked(cm_beep, cfg.readBoolEntry("useBeep",0)); |
674 | 677 | ||
675 | fullscreen_msg = new QLabel(this); | 678 | fullscreen_msg = new QLabel(this); |
676 | fullscreen_msg-> setAlignment ( AlignCenter | SingleLine ); | 679 | fullscreen_msg-> setAlignment ( AlignCenter | SingleLine ); |
677 | fullscreen_msg-> hide(); | 680 | fullscreen_msg-> hide(); |
678 | fullscreen_msg-> setSizePolicy ( QSizePolicy ( QSizePolicy::Expanding, QSizePolicy::Expanding )); | 681 | fullscreen_msg-> setSizePolicy ( QSizePolicy ( QSizePolicy::Expanding, QSizePolicy::Expanding )); |
679 | fullscreen_msg-> setAutoResize(true); | 682 | fullscreen_msg-> setAutoResize(true); |
680 | fullscreen_msg-> setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 683 | fullscreen_msg-> setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
681 | fullscreen_msg-> setText(tr("To exit fullscreen, tap here.")); | 684 | fullscreen_msg-> setText(tr("To exit fullscreen, tap here.")); |
682 | 685 | ||
683 | fullscreen_timer = new QTimer(this); | 686 | fullscreen_timer = new QTimer(this); |
684 | connect(fullscreen_timer, SIGNAL(timeout()), | 687 | connect(fullscreen_timer, SIGNAL(timeout()), |
685 | this, SLOT(fullscreenTimeout())); | 688 | this, SLOT(fullscreenTimeout())); |
686 | show_fullscreen_msg = true; | 689 | show_fullscreen_msg = true; |
687 | 690 | ||
688 | //scrollMenuSelected(-29); | 691 | //scrollMenuSelected(-29); |
689 | // cfg.setGroup("ScrollBar"); | 692 | // cfg.setGroup("ScrollBar"); |
690 | // if(cfg.readBoolEntry("HorzScroll",0)) { | 693 | // if(cfg.readBoolEntry("HorzScroll",0)) { |
691 | // if(cfg.readNumEntry("Position",2) == 0) | 694 | // if(cfg.readNumEntry("Position",2) == 0) |
692 | // te->setScrollbarLocation(1); | 695 | // te->setScrollbarLocation(1); |
693 | // else | 696 | // else |
694 | // te->setScrollbarLocation(0); | 697 | // te->setScrollbarLocation(0); |
695 | // te->setScrollbarLocation( cfg.readNumEntry("Position",2)); | 698 | // te->setScrollbarLocation( cfg.readNumEntry("Position",2)); |
696 | // te->setWrapAt(120); | 699 | // te->setWrapAt(120); |
697 | // } | 700 | // } |
698 | // create applications ///////////////////////////////////////////////////// | 701 | // create applications ///////////////////////////////////////////////////// |
699 | setCentralWidget(tab); | 702 | setCentralWidget(tab); |
700 | 703 | ||
701 | // load keymaps //////////////////////////////////////////////////////////// | 704 | // load keymaps //////////////////////////////////////////////////////////// |
702 | KeyTrans::loadAll(); | 705 | KeyTrans::loadAll(); |
703 | for (int i = 0; i < KeyTrans::count(); i++) | 706 | for (int i = 0; i < KeyTrans::count(); i++) |
704 | { | 707 | { |
705 | KeyTrans* s = KeyTrans::find(i); | 708 | KeyTrans* s = KeyTrans::find(i); |
706 | assert( s ); | 709 | assert( s ); |
707 | } | 710 | } |
708 | 711 | ||
709 | se_pgm = _pgm; | 712 | se_pgm = _pgm; |
710 | se_args = _args; | 713 | se_args = _args; |
711 | 714 | ||
712 | cfg.setGroup("CommandLine"); | 715 | cfg.setGroup("CommandLine"); |
713 | 716 | ||
714 | if (cfg.hasKey("shell_args")) | 717 | if (cfg.hasKey("shell_args")) |
715 | { | 718 | { |
716 | QStringList se_args_list = cfg.readListEntry("shell_args",'|'); | 719 | QStringList se_args_list = cfg.readListEntry("shell_args",'|'); |
717 | for(uint i = 0; i < se_args_list.count(); i++) | 720 | for(uint i = 0; i < se_args_list.count(); i++) |
718 | { | 721 | { |
719 | se_args.prepend(se_args_list[se_args_list.count() - i - 1].latin1()); | 722 | se_args.prepend(se_args_list[se_args_list.count() - i - 1].latin1()); |
720 | } | 723 | } |
721 | } | 724 | } |
722 | else | 725 | else |
723 | { | 726 | { |
724 | se_args.prepend("--login"); | 727 | se_args.prepend("--login"); |
725 | } | 728 | } |
726 | 729 | ||
727 | se_pgm = cfg.readEntry("shell_bin", QString(se_pgm)); | 730 | se_pgm = cfg.readEntry("shell_bin", QString(se_pgm)); |
728 | 731 | ||
729 | // this is the "documentation" for those who know to look | 732 | // this is the "documentation" for those who know to look |
730 | if (! cfg.hasKey("shell_args")) | 733 | if (! cfg.hasKey("shell_args")) |
731 | { | 734 | { |
732 | cfg.writeEntry("shell_args",QStringList::fromStrList(se_args),'|'); | 735 | cfg.writeEntry("shell_args",QStringList::fromStrList(se_args),'|'); |
733 | } | 736 | } |
734 | if (! cfg.hasKey("shell_bin")) | 737 | if (! cfg.hasKey("shell_bin")) |
735 | { | 738 | { |
736 | cfg.writeEntry("shell_bin",QString(se_pgm)); | 739 | cfg.writeEntry("shell_bin",QString(se_pgm)); |
737 | } | 740 | } |
738 | 741 | ||
739 | parseCommandLine(); | 742 | parseCommandLine(); |
740 | 743 | ||
741 | // read and apply default values /////////////////////////////////////////// | 744 | // read and apply default values /////////////////////////////////////////// |
742 | resize(321, 321); // Dummy. | 745 | resize(321, 321); // Dummy. |
743 | QSize currentSize = size(); | 746 | QSize currentSize = size(); |
744 | if (currentSize != size()) | 747 | if (currentSize != size()) |
745 | defaultSize = size(); | 748 | defaultSize = size(); |
746 | 749 | ||
747 | 750 | ||
748 | /* allows us to catch cancel/escape */ | 751 | /* allows us to catch cancel/escape */ |
749 | reparent ( 0, WStyle_Customize | WStyle_NoBorder, | 752 | reparent ( 0, WStyle_Customize | WStyle_NoBorder, |
750 | QPoint ( 0, 0 )); | 753 | QPoint ( 0, 0 )); |
751 | } | 754 | } |
752 | 755 | ||
753 | void Konsole::show() | 756 | void Konsole::show() |
754 | { | 757 | { |
755 | if ( !nsessions ) | 758 | if ( !nsessions ) |
756 | { | 759 | { |
757 | newSession(); | 760 | newSession(); |
758 | } | 761 | } |
759 | QMainWindow::show(); | 762 | QMainWindow::show(); |
760 | 763 | ||
761 | } | 764 | } |
762 | 765 | ||
763 | void Konsole::initSession(const char*, QStrList &) | 766 | void Konsole::initSession(const char*, QStrList &) |
764 | { | 767 | { |
765 | QMainWindow::show(); | 768 | QMainWindow::show(); |
766 | } | 769 | } |
767 | 770 | ||
768 | Konsole::~Konsole() | 771 | Konsole::~Konsole() |
769 | { | 772 | { |
770 | while (nsessions > 0) | 773 | while (nsessions > 0) |
771 | { | 774 | { |
772 | doneSession(getTe(), 0); | 775 | doneSession(getTe(), 0); |
773 | } | 776 | } |
774 | } | 777 | } |
775 | 778 | ||
776 | void | 779 | void |
777 | Konsole::historyDialog() | 780 | Konsole::historyDialog() |
778 | { | 781 | { |
779 | QDialog *d = new QDialog ( this, "histdlg", true ); | 782 | QDialog *d = new QDialog ( this, "histdlg", true ); |
780 | // d-> setCaption ( tr( "History" )); | 783 | // d-> setCaption ( tr( "History" )); |
781 | 784 | ||
782 | QBoxLayout *lay = new QVBoxLayout ( d, 4, 4 ); | 785 | QBoxLayout *lay = new QVBoxLayout ( d, 4, 4 ); |
783 | 786 | ||
784 | QLabel *l = new QLabel ( tr( "History Lines:" ), d ); | 787 | QLabel *l = new QLabel ( tr( "History Lines:" ), d ); |
785 | lay-> addWidget ( l ); | 788 | lay-> addWidget ( l ); |
786 | 789 | ||
787 | Config cfg( "Konsole" ); | 790 | Config cfg( "Konsole" ); |
788 | cfg.setGroup("History"); | 791 | cfg.setGroup("History"); |
789 | int hist = cfg.readNumEntry("history_lines",300); | 792 | int hist = cfg.readNumEntry("history_lines",300); |
790 | int avg_line = cfg.readNumEntry("avg_line_length",60); | 793 | int avg_line = cfg.readNumEntry("avg_line_length",60); |
791 | 794 | ||
792 | QSpinBox *spin = new QSpinBox ( 1, 100000, 20, d ); | 795 | QSpinBox *spin = new QSpinBox ( 1, 100000, 20, d ); |
793 | spin-> setValue ( hist ); | 796 | spin-> setValue ( hist ); |
794 | spin-> setWrapping ( true ); | 797 | spin-> setWrapping ( true ); |
795 | spin-> setButtonSymbols ( QSpinBox::PlusMinus ); | 798 | spin-> setButtonSymbols ( QSpinBox::PlusMinus ); |
796 | lay-> addWidget ( spin ); | 799 | lay-> addWidget ( spin ); |
797 | 800 | ||
798 | if ( d-> exec ( ) == QDialog::Accepted ) | 801 | if ( d-> exec ( ) == QDialog::Accepted ) |
799 | { | 802 | { |
800 | cfg.writeEntry("history_lines", spin->value()); | 803 | cfg.writeEntry("history_lines", spin->value()); |
801 | cfg.writeEntry("avg_line_length", avg_line); | 804 | cfg.writeEntry("avg_line_length", avg_line); |
802 | if (getTe() != NULL) | 805 | if (getTe() != NULL) |
803 | { | 806 | { |
804 | getTe()->currentSession->setHistory(true); | 807 | getTe()->currentSession->setHistory(true); |
805 | } | 808 | } |
806 | } | 809 | } |
807 | 810 | ||
808 | delete d; | 811 | delete d; |
809 | } | 812 | } |
810 | 813 | ||
811 | 814 | ||
812 | void Konsole::cycleZoom() | 815 | void Konsole::cycleZoom() |
813 | { | 816 | { |
814 | TEWidget* te = getTe(); | 817 | TEWidget* te = getTe(); |
815 | QFont font = te->getVTFont(); | 818 | QFont font = te->getVTFont(); |
816 | int size = font.pointSize(); | 819 | int size = font.pointSize(); |
817 | changeFontSize(1); | 820 | changeFontSize(1); |
818 | font = te->getVTFont(); | 821 | font = te->getVTFont(); |
819 | if (font.pointSize() <= size) | 822 | if (font.pointSize() <= size) |
820 | { | 823 | { |
821 | do | 824 | do |
822 | { | 825 | { |
823 | font = te->getVTFont(); | 826 | font = te->getVTFont(); |
824 | size = font.pointSize(); | 827 | size = font.pointSize(); |
825 | changeFontSize(-1); | 828 | changeFontSize(-1); |
826 | font = te->getVTFont(); | 829 | font = te->getVTFont(); |
827 | } | 830 | } |
828 | while (font.pointSize() < size); | 831 | while (font.pointSize() < size); |
829 | } | 832 | } |
830 | } | 833 | } |
831 | 834 | ||
832 | void Konsole::changeFontSize(int delta) | 835 | void Konsole::changeFontSize(int delta) |
833 | { | 836 | { |
834 | // printf("delta font size %d\n", delta); | 837 | // printf("delta font size %d\n", delta); |
835 | TEWidget* te = getTe(); | 838 | TEWidget* te = getTe(); |
836 | QFont font = te->getVTFont(); | 839 | QFont font = te->getVTFont(); |
837 | int size = font.pointSize(); | 840 | int size = font.pointSize(); |
838 | int closest = delta > 0? 10000 : -10000; | 841 | int closest = delta > 0? 10000 : -10000; |
839 | int closest_font = -1; | 842 | int closest_font = -1; |
840 | for(uint i = 0; i < fonts.count(); i++) | 843 | for(uint i = 0; i < fonts.count(); i++) |
841 | { | 844 | { |
842 | if (fonts.at(i)->getFont() == font) | 845 | if (fonts.at(i)->getFont() == font) |
843 | { | 846 | { |
844 | if (delta > 0) | 847 | if (delta > 0) |
845 | { | 848 | { |
846 | if (i+1 < fonts.count() | 849 | if (i+1 < fonts.count() |
847 | && fonts.at(i+1)->getFamilyNum() == fonts.at(i)->getFamilyNum()) | 850 | && fonts.at(i+1)->getFamilyNum() == fonts.at(i)->getFamilyNum()) |
848 | { | 851 | { |
849 | setFont(i+1); | 852 | setFont(i+1); |
850 | printf("font %d\n", i+1); | 853 | printf("font %d\n", i+1); |
851 | return; | 854 | return; |
852 | } | 855 | } |
853 | } | 856 | } |
854 | else if (delta < 0) | 857 | else if (delta < 0) |
855 | { | 858 | { |
856 | if (i > 0 | 859 | if (i > 0 |
857 | && fonts.at(i-1)->getFamilyNum() == fonts.at(i)->getFamilyNum()) | 860 | && fonts.at(i-1)->getFamilyNum() == fonts.at(i)->getFamilyNum()) |
858 | { | 861 | { |
859 | setFont(i-1); | 862 | setFont(i-1); |
860 | printf("font %d\n", i-1); | 863 | printf("font %d\n", i-1); |
861 | return; | 864 | return; |
862 | } | 865 | } |
863 | } | 866 | } |
864 | } | 867 | } |
865 | int fsize = fonts.at(i)->getSize(); | 868 | int fsize = fonts.at(i)->getSize(); |
866 | printf("%d size=%d fsize=%d closest=%d\n", i, size, fsize, closest); | 869 | printf("%d size=%d fsize=%d closest=%d\n", i, size, fsize, closest); |
867 | if ((delta > 0 && fsize > size && fsize < closest) | 870 | if ((delta > 0 && fsize > size && fsize < closest) |
868 | || (delta < 0 && fsize < size && fsize > closest)) | 871 | || (delta < 0 && fsize < size && fsize > closest)) |
869 | { | 872 | { |
870 | closest = fsize; | 873 | closest = fsize; |
871 | closest_font = i; | 874 | closest_font = i; |
872 | } | 875 | } |
873 | } | 876 | } |
874 | if (closest_font >= 0) | 877 | if (closest_font >= 0) |
875 | { | 878 | { |
876 | printf("font closest %d (%d)\n", closest_font, closest); | 879 | printf("font closest %d (%d)\n", closest_font, closest); |
877 | setFont(closest_font); | 880 | setFont(closest_font); |
878 | } | 881 | } |
879 | } | 882 | } |
880 | 883 | ||
881 | int Konsole::findFont(const QString& name, int size, bool exactMatch) | 884 | int Konsole::findFont(const QString& name, int size, bool exactMatch) |
882 | { | 885 | { |
883 | for(uint i = 0; i < fonts.count(); i++) | 886 | for(uint i = 0; i < fonts.count(); i++) |
884 | { | 887 | { |
885 | if (fonts.at(i)->getName() == name | 888 | if (fonts.at(i)->getName() == name |
886 | && fonts.at(i)->getSize() == size) | 889 | && fonts.at(i)->getSize() == size) |
887 | { | 890 | { |
888 | return(i); | 891 | return(i); |
889 | } | 892 | } |
890 | } | 893 | } |
891 | if (exactMatch) | 894 | if (exactMatch) |
892 | { | 895 | { |
893 | return(-1); | 896 | return(-1); |
894 | } | 897 | } |
895 | for(uint i = 0; i < fonts.count(); i++) | 898 | for(uint i = 0; i < fonts.count(); i++) |
896 | { | 899 | { |
897 | if (fonts.at(i)->getSize() == size) | 900 | if (fonts.at(i)->getSize() == size) |
898 | { | 901 | { |
899 | return(i); | 902 | return(i); |
900 | } | 903 | } |
901 | } | 904 | } |
902 | return(-1); | 905 | return(-1); |
903 | } | 906 | } |
904 | 907 | ||
905 | void Konsole::setFont(int f) | 908 | void Konsole::setFont(int f) |
906 | { | 909 | { |
907 | VTFont* font = fonts.at(f); | 910 | VTFont* font = fonts.at(f); |
908 | if (font) | 911 | if (font) |
909 | { | 912 | { |
910 | TEWidget* te = getTe(); | 913 | TEWidget* te = getTe(); |
911 | if (te != 0) | 914 | if (te != 0) |
912 | { | 915 | { |
913 | te->setVTFont(font->getFont()); | 916 | te->setVTFont(font->getFont()); |
914 | } | 917 | } |
915 | cfont = f; | 918 | cfont = f; |
916 | 919 | ||
917 | int familyNum = font->getFamilyNum(); | 920 | int familyNum = font->getFamilyNum(); |
918 | int size = font->getSize(); | 921 | int size = font->getSize(); |
919 | printf("familyNum = %d size = %d count=%d\n", familyNum, size, | 922 | printf("familyNum = %d size = %d count=%d\n", familyNum, size, |
920 | fontList->count()); | 923 | fontList->count()); |
921 | for(int i = 0; i < (int)fontList->count(); i++) | 924 | for(int i = 0; i < (int)fontList->count(); i++) |
922 | { | 925 | { |
923 | fontList->setItemChecked(i + 1000, i == familyNum); | 926 | fontList->setItemChecked(i + 1000, i == familyNum); |
924 | } | 927 | } |
925 | for(int i = 0; i < (int)fonts.count(); i++) | 928 | for(int i = 0; i < (int)fonts.count(); i++) |
926 | { | 929 | { |
927 | fontList->setItemChecked(i, fonts.at(i)->getFamilyNum() == familyNum | 930 | fontList->setItemChecked(i, fonts.at(i)->getFamilyNum() == familyNum |
928 | && fonts.at(i)->getSize() == size); | 931 | && fonts.at(i)->getSize() == size); |
929 | } | 932 | } |
930 | Config cfg( "Konsole" ); | 933 | Config cfg( "Konsole" ); |
931 | cfg.setGroup("Font"); | 934 | cfg.setGroup("Font"); |
932 | QString ss = "Session"+ QString::number(tab->currentPageIndex()+1); | 935 | QString ss = "Session"+ QString::number(tab->currentPageIndex()+1); |
933 | if (tab->currentPageIndex() == 0) | 936 | if (tab->currentPageIndex() == 0) |
934 | { | 937 | { |
935 | cfg.writeEntry("FontName", fonts.at(cfont)->getFamily()); | 938 | cfg.writeEntry("FontName", fonts.at(cfont)->getFamily()); |
936 | cfg.writeEntry("FontSize", fonts.at(cfont)->getSize()); | 939 | cfg.writeEntry("FontSize", fonts.at(cfont)->getSize()); |
937 | } | 940 | } |
938 | cfg.writeEntry("FontName"+ss, fonts.at(cfont)->getFamily()); | 941 | cfg.writeEntry("FontName"+ss, fonts.at(cfont)->getFamily()); |
939 | cfg.writeEntry("FontSize"+ss, fonts.at(cfont)->getSize()); | 942 | cfg.writeEntry("FontSize"+ss, fonts.at(cfont)->getSize()); |
940 | } | 943 | } |
941 | } | 944 | } |
942 | 945 | ||
943 | #if 0 | 946 | #if 0 |
944 | void Konsole::fontChanged(int f) | 947 | void Konsole::fontChanged(int f) |
945 | { | 948 | { |
946 | VTFont* font = fonts.at(f); | 949 | VTFont* font = fonts.at(f); |
947 | if (font != 0) | 950 | if (font != 0) |
948 | { | 951 | { |
949 | for(uint i = 0; i < fonts.count(); i++) | 952 | for(uint i = 0; i < fonts.count(); i++) |
950 | { | 953 | { |
951 | fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE); | 954 | fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE); |
952 | } | 955 | } |
953 | 956 | ||
954 | cfont = f; | 957 | cfont = f; |
955 | 958 | ||
956 | TEWidget* te = getTe(); | 959 | TEWidget* te = getTe(); |
957 | if (te != 0) | 960 | if (te != 0) |
958 | { | 961 | { |
959 | te->setVTFont(font->getFont()); | 962 | te->setVTFont(font->getFont()); |
960 | } | 963 | } |
961 | } | 964 | } |
962 | } | 965 | } |
963 | #endif | 966 | #endif |
964 | 967 | ||
965 | 968 | ||
966 | void Konsole::enterCommand(int c) | 969 | void Konsole::enterCommand(int c) |
967 | { | 970 | { |
968 | TEWidget* te = getTe(); | 971 | TEWidget* te = getTe(); |
969 | if (te != 0) | 972 | if (te != 0) |
970 | { | 973 | { |
971 | if(!commonCombo->editable()) | 974 | if(!commonCombo->editable()) |
972 | { | 975 | { |
973 | QString text = commonCombo->text(c); //commonCmds[c]; | 976 | QString text = commonCombo->text(c); //commonCmds[c]; |
974 | te->emitText(text); | 977 | te->emitText(text); |
975 | } | 978 | } |
976 | else | 979 | else |
977 | { | 980 | { |
978 | changeCommand( commonCombo->text(c), c); | 981 | changeCommand( commonCombo->text(c), c); |
979 | } | 982 | } |
980 | } | 983 | } |
981 | } | 984 | } |
982 | 985 | ||
983 | void Konsole::hitEnter() | 986 | void Konsole::hitEnter() |
984 | { | 987 | { |
985 | TEWidget* te = getTe(); | 988 | TEWidget* te = getTe(); |
986 | if (te != 0) | 989 | if (te != 0) |
987 | { | 990 | { |
988 | te->emitText(QString("\r")); | 991 | te->emitText(QString("\r")); |
989 | } | 992 | } |
990 | } | 993 | } |
991 | 994 | ||
992 | void Konsole::hitSpace() | 995 | void Konsole::hitSpace() |
993 | { | 996 | { |
994 | TEWidget* te = getTe(); | 997 | TEWidget* te = getTe(); |
995 | if (te != 0) | 998 | if (te != 0) |
996 | { | 999 | { |
997 | te->emitText(QString(" ")); | 1000 | te->emitText(QString(" ")); |
998 | } | 1001 | } |
999 | } | 1002 | } |
1000 | 1003 | ||
1001 | void Konsole::hitTab() | 1004 | void Konsole::hitTab() |
1002 | { | 1005 | { |
1003 | TEWidget* te = getTe(); | 1006 | TEWidget* te = getTe(); |
1004 | if (te != 0) | 1007 | if (te != 0) |
1005 | { | 1008 | { |
1006 | te->emitText(QString("\t")); | 1009 | te->emitText(QString("\t")); |
1007 | } | 1010 | } |
1008 | } | 1011 | } |
1009 | 1012 | ||
1010 | void Konsole::hitPaste() | 1013 | void Konsole::hitPaste() |
1011 | { | 1014 | { |
1012 | TEWidget* te = getTe(); | 1015 | TEWidget* te = getTe(); |
1013 | if (te != 0) | 1016 | if (te != 0) |
1014 | { | 1017 | { |
1015 | te->pasteClipboard(); | 1018 | te->pasteClipboard(); |
1016 | } | 1019 | } |
1017 | } | 1020 | } |
1018 | 1021 | ||
1019 | void Konsole::hitUp() | 1022 | void Konsole::hitUp() |
1020 | { | 1023 | { |
1021 | TEWidget* te = getTe(); | 1024 | TEWidget* te = getTe(); |
1022 | if (te != 0) | 1025 | if (te != 0) |
1023 | { | 1026 | { |
1024 | QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Up, 0, 0); | 1027 | QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Up, 0, 0); |
1025 | QApplication::sendEvent( te, &ke ); | 1028 | QApplication::sendEvent( te, &ke ); |
1026 | } | 1029 | } |
1027 | } | 1030 | } |
1028 | 1031 | ||
1029 | void Konsole::hitDown() | 1032 | void Konsole::hitDown() |
1030 | { | 1033 | { |
1031 | TEWidget* te = getTe(); | 1034 | TEWidget* te = getTe(); |
1032 | if (te != 0) | 1035 | if (te != 0) |
1033 | { | 1036 | { |
1034 | QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Down, 0, 0); | 1037 | QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Down, 0, 0); |
1035 | QApplication::sendEvent( te, &ke ); | 1038 | QApplication::sendEvent( te, &ke ); |
1036 | } | 1039 | } |
1037 | } | 1040 | } |
1038 | 1041 | ||
1039 | /** | 1042 | /** |
1040 | This function calculates the size of the external widget | 1043 | This function calculates the size of the external widget |
1041 | needed for the internal widget to be | 1044 | needed for the internal widget to be |
1042 | */ | 1045 | */ |
1043 | QSize Konsole::calcSize(int columns, int lines) | 1046 | QSize Konsole::calcSize(int columns, int lines) |
1044 | { | 1047 | { |
1045 | TEWidget* te = getTe(); | 1048 | TEWidget* te = getTe(); |
1046 | if (te != 0) | 1049 | if (te != 0) |
1047 | { | 1050 | { |
1048 | QSize size = te->calcSize(columns, lines); | 1051 | QSize size = te->calcSize(columns, lines); |
1049 | return size; | 1052 | return size; |
1050 | } | 1053 | } |
1051 | else | 1054 | else |
1052 | { | 1055 | { |
1053 | QSize size; | 1056 | QSize size; |
1054 | return size; | 1057 | return size; |
1055 | } | 1058 | } |
1056 | } | 1059 | } |
1057 | 1060 | ||
1058 | /** | 1061 | /** |
1059 | sets application window to a size based on columns X lines of the te | 1062 | sets application window to a size based on columns X lines of the te |
1060 | guest widget. Call with (0,0) for setting default size. | 1063 | guest widget. Call with (0,0) for setting default size. |
1061 | */ | 1064 | */ |
1062 | 1065 | ||
1063 | void Konsole::setColLin(int columns, int lines) | 1066 | void Konsole::setColLin(int columns, int lines) |
1064 | { | 1067 | { |
1065 | odebug << "konsole::setColLin:: Columns " << columns << "" << oendl; | 1068 | odebug << "konsole::setColLin:: Columns " << columns << "" << oendl; |
1066 | 1069 | ||
1067 | if ((columns==0) || (lines==0)) | 1070 | if ((columns==0) || (lines==0)) |
1068 | { | 1071 | { |
1069 | if (defaultSize.isEmpty()) // not in config file : set default value | 1072 | if (defaultSize.isEmpty()) // not in config file : set default value |
1070 | { | 1073 | { |
1071 | defaultSize = calcSize(80,24); | 1074 | defaultSize = calcSize(80,24); |
1072 | // notifySize(24,80); // set menu items (strange arg order !) | 1075 | // notifySize(24,80); // set menu items (strange arg order !) |
1073 | } | 1076 | } |
1074 | resize(defaultSize); | 1077 | resize(defaultSize); |
1075 | } | 1078 | } |
1076 | else | 1079 | else |
1077 | { | 1080 | { |
1078 | resize(calcSize(columns, lines)); | 1081 | resize(calcSize(columns, lines)); |
1079 | // notifySize(lines,columns); // set menu items (strange arg order !) | 1082 | // notifySize(lines,columns); // set menu items (strange arg order !) |
1080 | } | 1083 | } |
1081 | } | 1084 | } |
1082 | 1085 | ||
1083 | /* | 1086 | /* |
1084 | void Konsole::setFont(int fontno) | 1087 | void Konsole::setFont(int fontno) |
1085 | { | 1088 | { |
1086 | QFont f; | 1089 | QFont f; |
1087 | if (fontno == 0) | 1090 | if (fontno == 0) |
1088 | f = defaultFont = QFont( "Helvetica", 12 ); | 1091 | f = defaultFont = QFont( "Helvetica", 12 ); |
1089 | else | 1092 | else |
1090 | if (fonts[fontno][0] == '-') | 1093 | if (fonts[fontno][0] == '-') |
1091 | f.setRawName( fonts[fontno] ); | 1094 | f.setRawName( fonts[fontno] ); |
1092 | else | 1095 | else |
1093 | { | 1096 | { |
1094 | f.setFamily(fonts[fontno]); | 1097 | f.setFamily(fonts[fontno]); |
1095 | f.setRawMode( TRUE ); | 1098 | f.setRawMode( TRUE ); |
1096 | } | 1099 | } |
1097 | if ( !f.exactMatch() && fontno != 0) | 1100 | if ( !f.exactMatch() && fontno != 0) |
1098 | { | 1101 | { |
1099 | QString msg = i18n("Font `%1' not found.\nCheck README.linux.console for help.").arg(fonts[fontno]); | 1102 | QString msg = i18n("Font `%1' not found.\nCheck README.linux.console for help.").arg(fonts[fontno]); |
1100 | QMessageBox(this, msg); | 1103 | QMessageBox(this, msg); |
1101 | return; | 1104 | return; |
1102 | } | 1105 | } |
1103 | if (se) se->setFontNo(fontno); | 1106 | if (se) se->setFontNo(fontno); |
1104 | te->setVTFont(f); | 1107 | te->setVTFont(f); |
1105 | n_font = fontno; | 1108 | n_font = fontno; |
1106 | } | 1109 | } |
1107 | */ | 1110 | */ |
1108 | 1111 | ||
1109 | // --| color selection |------------------------------------------------------- | 1112 | // --| color selection |------------------------------------------------------- |
1110 | 1113 | ||
1111 | void Konsole::changeColumns(int /*columns*/) | 1114 | void Konsole::changeColumns(int /*columns*/) |
1112 | { //FIXME this seems to cause silliness when reset command is executed | 1115 | { //FIXME this seems to cause silliness when reset command is executed |
1113 | // odebug << "change columns" << oendl; | 1116 | // odebug << "change columns" << oendl; |
1114 | // TEWidget* te = getTe(); | 1117 | // TEWidget* te = getTe(); |
1115 | // if (te != 0) { | 1118 | // if (te != 0) { |
1116 | // setColLin(columns,te->Lines()); | 1119 | // setColLin(columns,te->Lines()); |
1117 | // te->update(); | 1120 | // te->update(); |
1118 | // } | 1121 | // } |
1119 | } | 1122 | } |
1120 | 1123 | ||
1121 | //FIXME: If a child dies during session swap, | 1124 | //FIXME: If a child dies during session swap, |
1122 | // this routine might be called before | 1125 | // this routine might be called before |
1123 | // session swap is completed. | 1126 | // session swap is completed. |
1124 | 1127 | ||
1125 | void Konsole::doneSession(TEWidget* te, int ) | 1128 | void Konsole::doneSession(TEWidget* te, int ) |
1126 | { | 1129 | { |
1127 | // TEWidget *te = NULL; | 1130 | // TEWidget *te = NULL; |
1128 | // if (sess->currentSession == tab->currentPage()) { | 1131 | // if (sess->currentSession == tab->currentPage()) { |
1129 | // printf("done current session\n"); | 1132 | // printf("done current session\n"); |
1130 | // te = getTe(); | 1133 | // te = getTe(); |
1131 | // } else { | 1134 | // } else { |
1132 | // int currentPage = tab->currentPageIndex(); | 1135 | // int currentPage = tab->currentPageIndex(); |
1133 | // printf("done not current session\n"); | 1136 | // printf("done not current session\n"); |
1134 | // for(int i = 0; i < nsessions; i++) { | 1137 | // for(int i = 0; i < nsessions; i++) { |
1135 | // tab->setCurrentPage(i); | 1138 | // tab->setCurrentPage(i); |
1136 | // printf("find session %d tab page %x session %x\n", | 1139 | // printf("find session %d tab page %x session %x\n", |
1137 | // i, tab->currentPage(), sess->currentSession); | 1140 | // i, tab->currentPage(), sess->currentSession); |
1138 | // if (tab->currentPage() == sess->currentSession) { | 1141 | // if (tab->currentPage() == sess->currentSession) { |
1139 | // printf("found session %d\n", i); | 1142 | // printf("found session %d\n", i); |
@@ -1407,512 +1410,515 @@ void Konsole::colorMenuIsSelected(int iD) | |||
1407 | void Konsole::colorMenuSelected(int iD) | 1410 | void Konsole::colorMenuSelected(int iD) |
1408 | { | 1411 | { |
1409 | // this is NOT pretty, elegant or anything else besides functional | 1412 | // this is NOT pretty, elegant or anything else besides functional |
1410 | // QString temp; | 1413 | // QString temp; |
1411 | // odebug << temp.sprintf("colormenu " << iD) << "" << oendl; | 1414 | // odebug << temp.sprintf("colormenu " << iD) << "" << oendl; |
1412 | 1415 | ||
1413 | TEWidget* te = getTe(); | 1416 | TEWidget* te = getTe(); |
1414 | Config cfg( "Konsole" ); | 1417 | Config cfg( "Konsole" ); |
1415 | cfg.setGroup("Colors"); | 1418 | cfg.setGroup("Colors"); |
1416 | 1419 | ||
1417 | ColorEntry m_table[TABLE_COLORS]; | 1420 | ColorEntry m_table[TABLE_COLORS]; |
1418 | const ColorEntry * defaultCt=te->getdefaultColorTable(); | 1421 | const ColorEntry * defaultCt=te->getdefaultColorTable(); |
1419 | 1422 | ||
1420 | int i; | 1423 | int i; |
1421 | 1424 | ||
1422 | // te->color_menu_item = iD; | 1425 | // te->color_menu_item = iD; |
1423 | 1426 | ||
1424 | colorMenu->setItemChecked(cm_ab,FALSE); | 1427 | colorMenu->setItemChecked(cm_ab,FALSE); |
1425 | colorMenu->setItemChecked(cm_bb,FALSE); | 1428 | colorMenu->setItemChecked(cm_bb,FALSE); |
1426 | colorMenu->setItemChecked(cm_wc,FALSE); | 1429 | colorMenu->setItemChecked(cm_wc,FALSE); |
1427 | colorMenu->setItemChecked(cm_cw,FALSE); | 1430 | colorMenu->setItemChecked(cm_cw,FALSE); |
1428 | colorMenu->setItemChecked(cm_mb,FALSE); | 1431 | colorMenu->setItemChecked(cm_mb,FALSE); |
1429 | colorMenu->setItemChecked(cm_bm,FALSE); | 1432 | colorMenu->setItemChecked(cm_bm,FALSE); |
1430 | colorMenu->setItemChecked(cm_gy,FALSE); | 1433 | colorMenu->setItemChecked(cm_gy,FALSE); |
1431 | colorMenu->setItemChecked(cm_rb,FALSE); | 1434 | colorMenu->setItemChecked(cm_rb,FALSE); |
1432 | colorMenu->setItemChecked(cm_br,FALSE); | 1435 | colorMenu->setItemChecked(cm_br,FALSE); |
1433 | colorMenu->setItemChecked(cm_wb,FALSE); | 1436 | colorMenu->setItemChecked(cm_wb,FALSE); |
1434 | colorMenu->setItemChecked(cm_bw,FALSE); | 1437 | colorMenu->setItemChecked(cm_bw,FALSE); |
1435 | colorMenu->setItemChecked(cm_gb,FALSE); | 1438 | colorMenu->setItemChecked(cm_gb,FALSE); |
1436 | 1439 | ||
1437 | if(iD==cm_default) | 1440 | if(iD==cm_default) |
1438 | { // default default | 1441 | { // default default |
1439 | printf("default colors\n"); | 1442 | printf("default colors\n"); |
1440 | for (i = 0; i < TABLE_COLORS; i++) | 1443 | for (i = 0; i < TABLE_COLORS; i++) |
1441 | { | 1444 | { |
1442 | m_table[i].color = defaultCt[i].color; | 1445 | m_table[i].color = defaultCt[i].color; |
1443 | if(i==1 || i == 11) | 1446 | if(i==1 || i == 11) |
1444 | m_table[i].transparent=1; | 1447 | m_table[i].transparent=1; |
1445 | colorMenu->setItemChecked(cm_default,TRUE); | 1448 | colorMenu->setItemChecked(cm_default,TRUE); |
1446 | } | 1449 | } |
1447 | te->setColorTable(m_table); | 1450 | te->setColorTable(m_table); |
1448 | } | 1451 | } |
1449 | if(iD==cm_gb) | 1452 | if(iD==cm_gb) |
1450 | { // green black | 1453 | { // green black |
1451 | foreground.setRgb(100,255,100); // (0x18,255,0x18); | 1454 | foreground.setRgb(100,255,100); // (0x18,255,0x18); |
1452 | background.setRgb(0x00,0x00,0x00); | 1455 | background.setRgb(0x00,0x00,0x00); |
1453 | colorMenu->setItemChecked(cm_gb,TRUE); | 1456 | colorMenu->setItemChecked(cm_gb,TRUE); |
1454 | } | 1457 | } |
1455 | if(iD==cm_bw) | 1458 | if(iD==cm_bw) |
1456 | { // black white | 1459 | { // black white |
1457 | foreground.setRgb(0x00,0x00,0x00); | 1460 | foreground.setRgb(0x00,0x00,0x00); |
1458 | background.setRgb(0xFF,0xFF,0xFF); | 1461 | background.setRgb(0xFF,0xFF,0xFF); |
1459 | colorMenu->setItemChecked(cm_bw,TRUE); | 1462 | colorMenu->setItemChecked(cm_bw,TRUE); |
1460 | } | 1463 | } |
1461 | if(iD==cm_wb) | 1464 | if(iD==cm_wb) |
1462 | { // white black | 1465 | { // white black |
1463 | foreground.setRgb(0xFF,0xFF,0xFF); | 1466 | foreground.setRgb(0xFF,0xFF,0xFF); |
1464 | background.setRgb(0x00,0x00,0x00); | 1467 | background.setRgb(0x00,0x00,0x00); |
1465 | colorMenu->setItemChecked(cm_wb,TRUE); | 1468 | colorMenu->setItemChecked(cm_wb,TRUE); |
1466 | } | 1469 | } |
1467 | if(iD==cm_br) | 1470 | if(iD==cm_br) |
1468 | {// Black, Red | 1471 | {// Black, Red |
1469 | foreground.setRgb(0x00,0x00,0x00); | 1472 | foreground.setRgb(0x00,0x00,0x00); |
1470 | background.setRgb(255,85,85); //(0xB2,0x18,0x18); | 1473 | background.setRgb(255,85,85); //(0xB2,0x18,0x18); |
1471 | colorMenu->setItemChecked(cm_br,TRUE); | 1474 | colorMenu->setItemChecked(cm_br,TRUE); |
1472 | } | 1475 | } |
1473 | if(iD==cm_rb) | 1476 | if(iD==cm_rb) |
1474 | {// Red, Black | 1477 | {// Red, Black |
1475 | foreground.setRgb(255,85,85); | 1478 | foreground.setRgb(255,85,85); |
1476 | background.setRgb(0x00,0x00,0x00); | 1479 | background.setRgb(0x00,0x00,0x00); |
1477 | colorMenu->setItemChecked(cm_rb,TRUE); | 1480 | colorMenu->setItemChecked(cm_rb,TRUE); |
1478 | } | 1481 | } |
1479 | if(iD==cm_gy) | 1482 | if(iD==cm_gy) |
1480 | {// Green, Yellow - is ugly | 1483 | {// Green, Yellow - is ugly |
1481 | // foreground.setRgb(0x18,0xB2,0x18); | 1484 | // foreground.setRgb(0x18,0xB2,0x18); |
1482 | foreground.setRgb(15,115,0); | 1485 | foreground.setRgb(15,115,0); |
1483 | // background.setRgb(0xB2,0x68,0x18); | 1486 | // background.setRgb(0xB2,0x68,0x18); |
1484 | background.setRgb(255,255,0); | 1487 | background.setRgb(255,255,0); |
1485 | colorMenu->setItemChecked(cm_gy,TRUE); | 1488 | colorMenu->setItemChecked(cm_gy,TRUE); |
1486 | } | 1489 | } |
1487 | if(iD==cm_bm) | 1490 | if(iD==cm_bm) |
1488 | {// Blue, Magenta | 1491 | {// Blue, Magenta |
1489 | foreground.setRgb(3,24,132); | 1492 | foreground.setRgb(3,24,132); |
1490 | background.setRgb(225,2,255); | 1493 | background.setRgb(225,2,255); |
1491 | colorMenu->setItemChecked(cm_bm,TRUE); | 1494 | colorMenu->setItemChecked(cm_bm,TRUE); |
1492 | } | 1495 | } |
1493 | if(iD==cm_mb) | 1496 | if(iD==cm_mb) |
1494 | {// Magenta, Blue | 1497 | {// Magenta, Blue |
1495 | foreground.setRgb(225,2,255); | 1498 | foreground.setRgb(225,2,255); |
1496 | background.setRgb(3,24,132); | 1499 | background.setRgb(3,24,132); |
1497 | colorMenu->setItemChecked(cm_mb,TRUE); | 1500 | colorMenu->setItemChecked(cm_mb,TRUE); |
1498 | } | 1501 | } |
1499 | if(iD==cm_cw) | 1502 | if(iD==cm_cw) |
1500 | {// Cyan, White | 1503 | {// Cyan, White |
1501 | foreground.setRgb(8,91,129); | 1504 | foreground.setRgb(8,91,129); |
1502 | background.setRgb(0xFF,0xFF,0xFF); | 1505 | background.setRgb(0xFF,0xFF,0xFF); |
1503 | colorMenu->setItemChecked(cm_cw,TRUE); | 1506 | colorMenu->setItemChecked(cm_cw,TRUE); |
1504 | } | 1507 | } |
1505 | if(iD==cm_wc) | 1508 | if(iD==cm_wc) |
1506 | {// White, Cyan | 1509 | {// White, Cyan |
1507 | background.setRgb(8,91,129); | 1510 | background.setRgb(8,91,129); |
1508 | foreground.setRgb(0xFF,0xFF,0xFF); | 1511 | foreground.setRgb(0xFF,0xFF,0xFF); |
1509 | colorMenu->setItemChecked(cm_wc,TRUE); | 1512 | colorMenu->setItemChecked(cm_wc,TRUE); |
1510 | } | 1513 | } |
1511 | if(iD==cm_bb) | 1514 | if(iD==cm_bb) |
1512 | {// Black, Blue | 1515 | {// Black, Blue |
1513 | background.setRgb(0x00,0x00,0x00); | 1516 | background.setRgb(0x00,0x00,0x00); |
1514 | foreground.setRgb(127,147,225); | 1517 | foreground.setRgb(127,147,225); |
1515 | colorMenu->setItemChecked(cm_bb,TRUE); | 1518 | colorMenu->setItemChecked(cm_bb,TRUE); |
1516 | } | 1519 | } |
1517 | if(iD==cm_ab) | 1520 | if(iD==cm_ab) |
1518 | {// Black, Gold | 1521 | {// Black, Gold |
1519 | background.setRgb(0x00,0x00,0x00); | 1522 | background.setRgb(0x00,0x00,0x00); |
1520 | foreground.setRgb(255,215,105); | 1523 | foreground.setRgb(255,215,105); |
1521 | colorMenu->setItemChecked(cm_ab,TRUE); | 1524 | colorMenu->setItemChecked(cm_ab,TRUE); |
1522 | } | 1525 | } |
1523 | #ifdef QT_QWS_OPIE | 1526 | #ifdef QT_QWS_OPIE |
1524 | if(iD==-19) | 1527 | if(iD==-19) |
1525 | { | 1528 | { |
1526 | // Custom | 1529 | // Custom |
1527 | odebug << "do custom" << oendl; | 1530 | odebug << "do custom" << oendl; |
1528 | if(fromMenu) | 1531 | if(fromMenu) |
1529 | { | 1532 | { |
1530 | Opie::OColorPopupMenu* penColorPopupMenu = new Opie::OColorPopupMenu(Qt::black, this, "foreground color"); | 1533 | Opie::OColorPopupMenu* penColorPopupMenu = new Opie::OColorPopupMenu(Qt::black, this, "foreground color"); |
1531 | connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, | 1534 | connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, |
1532 | SLOT(changeForegroundColor(const QColor&))); | 1535 | SLOT(changeForegroundColor(const QColor&))); |
1533 | penColorPopupMenu->exec(); | 1536 | penColorPopupMenu->exec(); |
1534 | } | 1537 | } |
1535 | if(!fromMenu) | 1538 | if(!fromMenu) |
1536 | { | 1539 | { |
1537 | foreground.setNamedColor(cfg.readEntry("foreground","")); | 1540 | foreground.setNamedColor(cfg.readEntry("foreground","")); |
1538 | background.setNamedColor(cfg.readEntry("background","")); | 1541 | background.setNamedColor(cfg.readEntry("background","")); |
1539 | } | 1542 | } |
1540 | fromMenu=FALSE; | 1543 | fromMenu=FALSE; |
1541 | colorMenu->setItemChecked(-19,TRUE); | 1544 | colorMenu->setItemChecked(-19,TRUE); |
1542 | } | 1545 | } |
1543 | #endif | 1546 | #endif |
1544 | 1547 | ||
1545 | lastSelectedMenu = iD; | 1548 | lastSelectedMenu = iD; |
1546 | 1549 | ||
1547 | setColors(foreground, background); | 1550 | setColors(foreground, background); |
1548 | 1551 | ||
1549 | QTabBar *tabBar = tab->getTabBar(); | 1552 | QTabBar *tabBar = tab->getTabBar(); |
1550 | QString ss = QString("Session%1").arg(tabBar->currentTab()); | 1553 | QString ss = QString("Session%1").arg(tabBar->currentTab()); |
1551 | // printf("current tab = %d\n", tabBar->currentTab()); | 1554 | // printf("current tab = %d\n", tabBar->currentTab()); |
1552 | 1555 | ||
1553 | if (tabBar->currentTab() == 0) | 1556 | if (tabBar->currentTab() == 0) |
1554 | { | 1557 | { |
1555 | cfg.writeEntry("foregroundRed",QString::number(foreground.red())); | 1558 | cfg.writeEntry("foregroundRed",QString::number(foreground.red())); |
1556 | cfg.writeEntry("foregroundGreen",QString::number(foreground.green())); | 1559 | cfg.writeEntry("foregroundGreen",QString::number(foreground.green())); |
1557 | cfg.writeEntry("foregroundBlue",QString::number(foreground.blue())); | 1560 | cfg.writeEntry("foregroundBlue",QString::number(foreground.blue())); |
1558 | cfg.writeEntry("backgroundRed",QString::number(background.red())); | 1561 | cfg.writeEntry("backgroundRed",QString::number(background.red())); |
1559 | cfg.writeEntry("backgroundGreen",QString::number(background.green())); | 1562 | cfg.writeEntry("backgroundGreen",QString::number(background.green())); |
1560 | cfg.writeEntry("backgroundBlue",QString::number(background.blue())); | 1563 | cfg.writeEntry("backgroundBlue",QString::number(background.blue())); |
1561 | } | 1564 | } |
1562 | cfg.writeEntry("foregroundRed"+ss,QString::number(foreground.red())); | 1565 | cfg.writeEntry("foregroundRed"+ss,QString::number(foreground.red())); |
1563 | cfg.writeEntry("foregroundGreen"+ss,QString::number(foreground.green())); | 1566 | cfg.writeEntry("foregroundGreen"+ss,QString::number(foreground.green())); |
1564 | cfg.writeEntry("foregroundBlue"+ss,QString::number(foreground.blue())); | 1567 | cfg.writeEntry("foregroundBlue"+ss,QString::number(foreground.blue())); |
1565 | cfg.writeEntry("backgroundRed"+ss,QString::number(background.red())); | 1568 | cfg.writeEntry("backgroundRed"+ss,QString::number(background.red())); |
1566 | cfg.writeEntry("backgroundGreen"+ss,QString::number(background.green())); | 1569 | cfg.writeEntry("backgroundGreen"+ss,QString::number(background.green())); |
1567 | cfg.writeEntry("backgroundBlue"+ss,QString::number(background.blue())); | 1570 | cfg.writeEntry("backgroundBlue"+ss,QString::number(background.blue())); |
1568 | 1571 | ||
1569 | update(); | 1572 | update(); |
1570 | } | 1573 | } |
1571 | 1574 | ||
1572 | void Konsole::setColors(QColor foreground, QColor background) | 1575 | void Konsole::setColors(QColor foreground, QColor background) |
1573 | { | 1576 | { |
1574 | int i; | 1577 | int i; |
1575 | ColorEntry m_table[TABLE_COLORS]; | 1578 | ColorEntry m_table[TABLE_COLORS]; |
1576 | TEWidget* te = getTe(); | 1579 | TEWidget* te = getTe(); |
1577 | const ColorEntry * defaultCt=te->getdefaultColorTable(); | 1580 | const ColorEntry * defaultCt=te->getdefaultColorTable(); |
1578 | 1581 | ||
1579 | for (i = 0; i < TABLE_COLORS; i++) | 1582 | for (i = 0; i < TABLE_COLORS; i++) |
1580 | { | 1583 | { |
1581 | if(i==0 || i == 10) | 1584 | if(i==0 || i == 10) |
1582 | { | 1585 | { |
1583 | m_table[i].color = foreground; | 1586 | m_table[i].color = foreground; |
1584 | } | 1587 | } |
1585 | else if(i==1 || i == 11) | 1588 | else if(i==1 || i == 11) |
1586 | { | 1589 | { |
1587 | m_table[i].color = background; | 1590 | m_table[i].color = background; |
1588 | m_table[i].transparent=0; | 1591 | m_table[i].transparent=0; |
1589 | } | 1592 | } |
1590 | else | 1593 | else |
1591 | m_table[i].color = defaultCt[i].color; | 1594 | m_table[i].color = defaultCt[i].color; |
1592 | } | 1595 | } |
1593 | te->setColorTable(m_table); | 1596 | te->setColorTable(m_table); |
1594 | } | 1597 | } |
1595 | 1598 | ||
1596 | void Konsole::tabMenuSelected(int id) | 1599 | void Konsole::tabMenuSelected(int id) |
1597 | { | 1600 | { |
1598 | Config cfg( "Konsole" ); | 1601 | Config cfg( "Konsole" ); |
1599 | cfg.setGroup("Tabs"); | 1602 | cfg.setGroup("Tabs"); |
1600 | tabMenu->setItemChecked(tabPos, false); | 1603 | tabMenu->setItemChecked(tabPos, false); |
1601 | if (id == tm_bottom) | 1604 | if (id == tm_bottom) |
1602 | { | 1605 | { |
1603 | printf("set bottom tab\n"); | 1606 | printf("set bottom tab\n"); |
1604 | tab->getTabBar()->show(); | 1607 | tab->getTabBar()->show(); |
1605 | tab->setTabPosition(QTabWidget::Bottom); | 1608 | tab->setTabPosition(QTabWidget::Bottom); |
1606 | tab->getTabBar()->show(); | 1609 | tab->getTabBar()->show(); |
1607 | cfg.writeEntry("Position","Bottom"); | 1610 | cfg.writeEntry("Position","Bottom"); |
1608 | } | 1611 | } |
1609 | else if (id == tm_top) | 1612 | else if (id == tm_top) |
1610 | { | 1613 | { |
1611 | printf("set top tab\n"); | 1614 | printf("set top tab\n"); |
1612 | tab->getTabBar()->show(); | 1615 | tab->getTabBar()->show(); |
1613 | tab->setTabPosition(QTabWidget::Bottom); | 1616 | tab->setTabPosition(QTabWidget::Bottom); |
1614 | tab->setTabPosition(QTabWidget::Top); | 1617 | tab->setTabPosition(QTabWidget::Top); |
1615 | tab->getTabBar()->show(); | 1618 | tab->getTabBar()->show(); |
1616 | cfg.writeEntry("Position","Top"); | 1619 | cfg.writeEntry("Position","Top"); |
1617 | } | 1620 | } |
1618 | else if (id == tm_hidden) | 1621 | else if (id == tm_hidden) |
1619 | { | 1622 | { |
1620 | tab->getTabBar()->hide(); | 1623 | tab->getTabBar()->hide(); |
1621 | tab->setMargin(tab->margin()); | 1624 | tab->setMargin(tab->margin()); |
1622 | cfg.writeEntry("Position","Hidden"); | 1625 | cfg.writeEntry("Position","Hidden"); |
1623 | } | 1626 | } |
1624 | tabMenu->setItemChecked(id, true); | 1627 | tabMenu->setItemChecked(id, true); |
1625 | tabPos = id; | 1628 | tabPos = id; |
1626 | } | 1629 | } |
1627 | 1630 | ||
1628 | 1631 | ||
1629 | void Konsole::configMenuSelected(int iD) | 1632 | void Konsole::configMenuSelected(int iD) |
1630 | { | 1633 | { |
1631 | // QString temp; | 1634 | // QString temp; |
1632 | // odebug << temp.sprintf("configmenu " << iD) << "" << oendl; | 1635 | // odebug << temp.sprintf("configmenu " << iD) << "" << oendl; |
1633 | 1636 | ||
1634 | TEWidget* te = getTe(); | 1637 | TEWidget* te = getTe(); |
1635 | Config cfg( "Konsole" ); | 1638 | Config cfg( "Konsole" ); |
1636 | cfg.setGroup("Menubar"); | 1639 | cfg.setGroup("Menubar"); |
1637 | if(iD == cm_wrap) | 1640 | if(iD == cm_wrap) |
1638 | { | 1641 | { |
1639 | cfg.setGroup("ScrollBar"); | 1642 | cfg.setGroup("ScrollBar"); |
1640 | bool b=cfg.readBoolEntry("HorzScroll",0); | 1643 | bool b=cfg.readBoolEntry("HorzScroll",0); |
1641 | b=!b; | 1644 | b=!b; |
1642 | cfg.writeEntry("HorzScroll", b ); | 1645 | cfg.writeEntry("HorzScroll", b ); |
1643 | cfg.write(); | 1646 | cfg.write(); |
1644 | doWrap(); | 1647 | doWrap(); |
1645 | if(cfg.readNumEntry("Position",2) == 0) | 1648 | if(cfg.readNumEntry("Position",2) == 0) |
1646 | { | 1649 | { |
1647 | te->setScrollbarLocation(1); | 1650 | te->setScrollbarLocation(1); |
1648 | } | 1651 | } |
1649 | else | 1652 | else |
1650 | { | 1653 | { |
1651 | te->setScrollbarLocation(0); | 1654 | te->setScrollbarLocation(0); |
1652 | } | 1655 | } |
1653 | te->setScrollbarLocation( cfg.readNumEntry("Position",2)); | 1656 | te->setScrollbarLocation( cfg.readNumEntry("Position",2)); |
1654 | } | 1657 | } |
1655 | if(iD == cm_beep) | 1658 | if(iD == cm_beep) |
1656 | { | 1659 | { |
1657 | cfg.setGroup("Menubar"); | 1660 | cfg.setGroup("Menubar"); |
1658 | bool b=cfg.readBoolEntry("useBeep",0); | 1661 | bool b=cfg.readBoolEntry("useBeep",0); |
1659 | b=!b; | 1662 | b=!b; |
1660 | cfg.writeEntry("useBeep", b ); | 1663 | cfg.writeEntry("useBeep", b ); |
1661 | cfg.write(); | 1664 | cfg.write(); |
1662 | configMenu->setItemChecked(cm_beep,b); | 1665 | configMenu->setItemChecked(cm_beep,b); |
1663 | te->useBeep=b; | 1666 | te->useBeep=b; |
1664 | } | 1667 | } |
1665 | } | 1668 | } |
1666 | 1669 | ||
1667 | void Konsole::changeCommand(const QString &text, int c) | 1670 | void Konsole::changeCommand(const QString &text, int c) |
1668 | { | 1671 | { |
1669 | Config cfg( "Konsole" ); | 1672 | Config cfg( "Konsole" ); |
1670 | cfg.setGroup("Commands"); | 1673 | cfg.setGroup("Commands"); |
1671 | if(commonCmds[c] != text) | 1674 | if(commonCmds[c] != text) |
1672 | { | 1675 | { |
1673 | cfg.writeEntry(QString::number(c),text); | 1676 | cfg.writeEntry(QString::number(c),text); |
1674 | commonCombo->clearEdit(); | 1677 | commonCombo->clearEdit(); |
1675 | commonCombo->setCurrentItem(c); | 1678 | commonCombo->setCurrentItem(c); |
1676 | } | 1679 | } |
1677 | } | 1680 | } |
1678 | 1681 | ||
1679 | void Konsole::setColor(int sess) | 1682 | void Konsole::setColor(int sess) |
1680 | { | 1683 | { |
1681 | Config cfg( "Konsole" ); | 1684 | Config cfg( "Konsole" ); |
1682 | cfg.setGroup("Colors"); | 1685 | cfg.setGroup("Colors"); |
1683 | QColor foreground, background; | 1686 | QColor foreground, background; |
1684 | QString ss = QString("Session") + QString::number(sess); | 1687 | QString ss = QString("Session") + QString::number(sess); |
1685 | foreground.setRgb(cfg.readNumEntry("foregroundRed"+ss, | 1688 | foreground.setRgb(cfg.readNumEntry("foregroundRed"+ss, |
1686 | cfg.readNumEntry("foregroundRed",0xff)), | 1689 | cfg.readNumEntry("foregroundRed",0xff)), |
1687 | cfg.readNumEntry("foregroundGreen"+ss, | 1690 | cfg.readNumEntry("foregroundGreen"+ss, |
1688 | cfg.readNumEntry("foregroundGreen",0xff)), | 1691 | cfg.readNumEntry("foregroundGreen",0xff)), |
1689 | cfg.readNumEntry("foregroundBlue"+ss, | 1692 | cfg.readNumEntry("foregroundBlue"+ss, |
1690 | cfg.readNumEntry("foregroundBlue",0xff))); | 1693 | cfg.readNumEntry("foregroundBlue",0xff))); |
1691 | background.setRgb(cfg.readNumEntry("backgroundRed"+ss, | 1694 | background.setRgb(cfg.readNumEntry("backgroundRed"+ss, |
1692 | cfg.readNumEntry("backgroundRed",0)), | 1695 | cfg.readNumEntry("backgroundRed",0)), |
1693 | cfg.readNumEntry("backgroundGreen"+ss, | 1696 | cfg.readNumEntry("backgroundGreen"+ss, |
1694 | cfg.readNumEntry("backgroundGreen",0)), | 1697 | cfg.readNumEntry("backgroundGreen",0)), |
1695 | cfg.readNumEntry("backgroundBlue"+ss, | 1698 | cfg.readNumEntry("backgroundBlue"+ss, |
1696 | cfg.readNumEntry("backgroundBlue",0))); | 1699 | cfg.readNumEntry("backgroundBlue",0))); |
1697 | setColors(foreground, background); | 1700 | setColors(foreground, background); |
1698 | } | 1701 | } |
1699 | 1702 | ||
1700 | void Konsole::scrollMenuSelected(int index) | 1703 | void Konsole::scrollMenuSelected(int index) |
1701 | { | 1704 | { |
1702 | // odebug << "scrollbar menu " << index << "" << oendl; | 1705 | // odebug << "scrollbar menu " << index << "" << oendl; |
1703 | 1706 | ||
1704 | TEWidget* te = getTe(); | 1707 | TEWidget* te = getTe(); |
1705 | Config cfg( "Konsole" ); | 1708 | Config cfg( "Konsole" ); |
1706 | cfg.setGroup("ScrollBar"); | 1709 | cfg.setGroup("ScrollBar"); |
1707 | 1710 | ||
1708 | if(index == sm_none) | 1711 | if(index == sm_none) |
1709 | { | 1712 | { |
1710 | te->setScrollbarLocation(0); | 1713 | te->setScrollbarLocation(0); |
1711 | cfg.writeEntry("Position",0); | 1714 | cfg.writeEntry("Position",0); |
1712 | } | 1715 | } |
1713 | else if(index == sm_left) | 1716 | else if(index == sm_left) |
1714 | { | 1717 | { |
1715 | te->setScrollbarLocation(1); | 1718 | te->setScrollbarLocation(1); |
1716 | cfg.writeEntry("Position",1); | 1719 | cfg.writeEntry("Position",1); |
1717 | } | 1720 | } |
1718 | else if(index == sm_right) | 1721 | else if(index == sm_right) |
1719 | { | 1722 | { |
1720 | te->setScrollbarLocation(2); | 1723 | te->setScrollbarLocation(2); |
1721 | cfg.writeEntry("Position",2); | 1724 | cfg.writeEntry("Position",2); |
1722 | } | 1725 | } |
1723 | scrollMenu->setItemChecked(sm_none, index == sm_none); | 1726 | scrollMenu->setItemChecked(sm_none, index == sm_none); |
1724 | scrollMenu->setItemChecked(sm_left, index == sm_left); | 1727 | scrollMenu->setItemChecked(sm_left, index == sm_left); |
1725 | scrollMenu->setItemChecked(sm_right, index == sm_right); | 1728 | scrollMenu->setItemChecked(sm_right, index == sm_right); |
1726 | } | 1729 | } |
1727 | 1730 | ||
1728 | // case -29: { | 1731 | // case -29: { |
1729 | // bool b=cfg.readBoolEntry("HorzScroll",0); | 1732 | // bool b=cfg.readBoolEntry("HorzScroll",0); |
1730 | // cfg.writeEntry("HorzScroll", !b ); | 1733 | // cfg.writeEntry("HorzScroll", !b ); |
1731 | // cfg.write(); | 1734 | // cfg.write(); |
1732 | // if(cfg.readNumEntry("Position",2) == 0) { | 1735 | // if(cfg.readNumEntry("Position",2) == 0) { |
1733 | // te->setScrollbarLocation(1); | 1736 | // te->setScrollbarLocation(1); |
1734 | // te->setWrapAt(0); | 1737 | // te->setWrapAt(0); |
1735 | // } else { | 1738 | // } else { |
1736 | // te->setScrollbarLocation(0); | 1739 | // te->setScrollbarLocation(0); |
1737 | // te->setWrapAt(120); | 1740 | // te->setWrapAt(120); |
1738 | // } | 1741 | // } |
1739 | // te->setScrollbarLocation( cfg.readNumEntry("Position",2)); | 1742 | // te->setScrollbarLocation( cfg.readNumEntry("Position",2)); |
1740 | // } | 1743 | // } |
1741 | // break; | 1744 | // break; |
1742 | 1745 | ||
1743 | void Konsole::editCommandListMenuSelected(int iD) | 1746 | void Konsole::editCommandListMenuSelected(int iD) |
1744 | { | 1747 | { |
1745 | // QString temp; | 1748 | // QString temp; |
1746 | // odebug << temp.sprintf("edit command list " << iD) << "" << oendl; | 1749 | // odebug << temp.sprintf("edit command list " << iD) << "" << oendl; |
1747 | 1750 | ||
1748 | // FIXME: more cleanup needed here | 1751 | // FIXME: more cleanup needed here |
1749 | 1752 | ||
1750 | 1753 | ||
1751 | TEWidget* te = getTe(); | 1754 | TEWidget* te = getTe(); |
1752 | Config cfg( "Konsole" ); | 1755 | Config cfg( "Konsole" ); |
1753 | cfg.setGroup("Menubar"); | 1756 | cfg.setGroup("Menubar"); |
1754 | if( iD == ec_cmdlist) | 1757 | if( iD == ec_cmdlist) |
1755 | { | 1758 | { |
1756 | if(!secondToolBar->isHidden()) | 1759 | if(!secondToolBar->isHidden()) |
1757 | { | 1760 | { |
1758 | secondToolBar->hide(); | 1761 | secondToolBar->hide(); |
1759 | configMenu->changeItem( iD,tr( "Show Command List" )); | 1762 | configMenu->changeItem( iD,tr( "Show Command List" )); |
1760 | cfg.writeEntry("Hidden","TRUE"); | 1763 | cfg.writeEntry("Hidden","TRUE"); |
1761 | configMenu->setItemEnabled(ec_edit ,FALSE); | 1764 | configMenu->setItemEnabled(ec_edit ,FALSE); |
1762 | configMenu->setItemEnabled(ec_quick ,FALSE); | 1765 | configMenu->setItemEnabled(ec_quick ,FALSE); |
1763 | } | 1766 | } |
1764 | else | 1767 | else |
1765 | { | 1768 | { |
1766 | secondToolBar->show(); | 1769 | secondToolBar->show(); |
1767 | configMenu->changeItem( iD,tr( "Hide Command List" )); | 1770 | configMenu->changeItem( iD,tr( "Hide Command List" )); |
1768 | cfg.writeEntry("Hidden","FALSE"); | 1771 | cfg.writeEntry("Hidden","FALSE"); |
1769 | configMenu->setItemEnabled(ec_edit ,TRUE); | 1772 | configMenu->setItemEnabled(ec_edit ,TRUE); |
1770 | configMenu->setItemEnabled(ec_quick ,TRUE); | 1773 | configMenu->setItemEnabled(ec_quick ,TRUE); |
1771 | 1774 | ||
1772 | if(cfg.readEntry("EditEnabled","FALSE")=="TRUE") | 1775 | if(cfg.readEntry("EditEnabled","FALSE")=="TRUE") |
1773 | { | 1776 | { |
1774 | configMenu->setItemChecked(ec_edit,TRUE); | 1777 | configMenu->setItemChecked(ec_edit,TRUE); |
1775 | commonCombo->setEditable( TRUE ); | 1778 | commonCombo->setEditable( TRUE ); |
1776 | } | 1779 | } |
1777 | else | 1780 | else |
1778 | { | 1781 | { |
1779 | configMenu->setItemChecked(ec_edit,FALSE); | 1782 | configMenu->setItemChecked(ec_edit,FALSE); |
1780 | commonCombo->setEditable( FALSE ); | 1783 | commonCombo->setEditable( FALSE ); |
1781 | } | 1784 | } |
1782 | } | 1785 | } |
1783 | } | 1786 | } |
1784 | if( iD == ec_quick) | 1787 | if( iD == ec_quick) |
1785 | { | 1788 | { |
1786 | cfg.setGroup("Commands"); | 1789 | cfg.setGroup("Commands"); |
1787 | // odebug << "enableCommandEdit" << oendl; | 1790 | // odebug << "enableCommandEdit" << oendl; |
1788 | if( !configMenu->isItemChecked(iD) ) | 1791 | if( !configMenu->isItemChecked(iD) ) |
1789 | { | 1792 | { |
1790 | commonCombo->setEditable( TRUE ); | 1793 | commonCombo->setEditable( TRUE ); |
1791 | configMenu->setItemChecked(iD,TRUE); | 1794 | configMenu->setItemChecked(iD,TRUE); |
1792 | commonCombo->setCurrentItem(0); | 1795 | commonCombo->setCurrentItem(0); |
1793 | cfg.writeEntry("EditEnabled","TRUE"); | 1796 | cfg.writeEntry("EditEnabled","TRUE"); |
1794 | } | 1797 | } |
1795 | else | 1798 | else |
1796 | { | 1799 | { |
1797 | commonCombo->setEditable( FALSE ); | 1800 | commonCombo->setEditable( FALSE ); |
1798 | configMenu->setItemChecked(iD,FALSE); | 1801 | configMenu->setItemChecked(iD,FALSE); |
1799 | cfg.writeEntry("EditEnabled","FALSE"); | 1802 | cfg.writeEntry("EditEnabled","FALSE"); |
1800 | commonCombo->setFocusPolicy(QWidget::NoFocus); | 1803 | commonCombo->setFocusPolicy(QWidget::NoFocus); |
1801 | te->setFocus(); | 1804 | te->setFocus(); |
1802 | } | 1805 | } |
1803 | } | 1806 | } |
1804 | if(iD == ec_edit) | 1807 | if(iD == ec_edit) |
1805 | { | 1808 | { |
1806 | // "edit commands" | 1809 | // "edit commands" |
1807 | CommandEditDialog *m = new CommandEditDialog(this); | 1810 | CommandEditDialog *m = new CommandEditDialog(this); |
1808 | connect(m,SIGNAL(commandsEdited()),this,SLOT(initCommandList())); | 1811 | connect(m,SIGNAL(commandsEdited()),this,SLOT(initCommandList())); |
1809 | m->showMaximized(); | 1812 | m->showMaximized(); |
1810 | } | 1813 | } |
1811 | 1814 | ||
1812 | } | 1815 | } |
1813 | 1816 | ||
1814 | // $QPEDIR/bin/qcop QPE/Application/embeddedkonsole 'setDocument(QString)' 'ssh -V' | 1817 | // $QPEDIR/bin/qcop QPE/Application/embeddedkonsole 'setDocument(QString)' 'ssh -V' |
1815 | void Konsole::setDocument( const QString &cmd) | 1818 | void Konsole::setDocument( const QString &cmd) |
1816 | { | 1819 | { |
1817 | newSession(); | 1820 | newSession(); |
1818 | TEWidget* te = getTe(); | 1821 | TEWidget* te = getTe(); |
1819 | if(cmd.find("-e", 0, TRUE) != -1) | 1822 | if(cmd.find("-e", 0, TRUE) != -1) |
1820 | { | 1823 | { |
1821 | QString cmd2; | 1824 | QString cmd2; |
1822 | cmd2=cmd.right(cmd.length()-3)+" &"; | 1825 | cmd2=cmd.right(cmd.length()-3)+" &"; |
1823 | system(cmd2.latin1()); | 1826 | system(cmd2.latin1()); |
1824 | if(startUp <= 1 && nsessions < 2) | 1827 | if(startUp <= 1 && nsessions < 2) |
1825 | { | 1828 | { |
1826 | doneSession(getTe(), 0); | 1829 | doneSession(getTe(), 0); |
1827 | exit(0); | 1830 | exit(0); |
1828 | } | 1831 | } |
1829 | else | 1832 | else |
1830 | doneSession(getTe(), 0); | 1833 | doneSession(getTe(), 0); |
1831 | } | 1834 | } |
1832 | else | 1835 | else |
1833 | { | 1836 | { |
1834 | if (te != 0) | 1837 | if (te != 0) |
1835 | { | 1838 | { |
1836 | te->emitText(cmd+"\r"); | 1839 | te->emitText(cmd+"\r"); |
1837 | } | 1840 | } |
1838 | } | 1841 | } |
1839 | startUp++; | 1842 | startUp++; |
1840 | } | 1843 | } |
1841 | 1844 | ||
1842 | 1845 | ||
1843 | // what is the point of this when you can just | 1846 | // what is the point of this when you can just |
1844 | // run commands by using the shell directly?? | 1847 | // run commands by using the shell directly?? |
1845 | void Konsole::parseCommandLine() | 1848 | void Konsole::parseCommandLine() |
1846 | { | 1849 | { |
1847 | QString cmd; | 1850 | QString cmd; |
1848 | // newSession(); | 1851 | // newSession(); |
1849 | for (int i=1;i< qApp->argc();i++) | 1852 | for (int i=1;i< qApp->argc();i++) |
1850 | { | 1853 | { |
1851 | if( QString(qApp->argv()[i]) == "-e") | 1854 | if( QString(qApp->argv()[i]) == "-e") |
1852 | { | 1855 | { |
1853 | i++; | 1856 | i++; |
1854 | for ( int j=i;j< qApp->argc();j++) | 1857 | for ( int j=i;j< qApp->argc();j++) |
1855 | { | 1858 | { |
1856 | cmd+=QString(qApp->argv()[j])+" "; | 1859 | cmd+=QString(qApp->argv()[j])+" "; |
1857 | } | 1860 | } |
1858 | cmd.stripWhiteSpace(); | 1861 | cmd.stripWhiteSpace(); |
1859 | system(cmd.latin1()); | 1862 | system(cmd.latin1()); |
1860 | exit(0);//close(); | 1863 | exit(0);//close(); |
1861 | } // end -e switch | 1864 | } // end -e switch |
1862 | } | 1865 | } |
1863 | startUp++; | 1866 | startUp++; |
1864 | } | 1867 | } |
1865 | 1868 | ||
1866 | void Konsole::changeForegroundColor(const QColor &color) | 1869 | void Konsole::changeForegroundColor(const QColor &color) |
1867 | { | 1870 | { |
1868 | Config cfg( "Konsole" ); | 1871 | Config cfg( "Konsole" ); |
1869 | cfg.setGroup("Colors"); | 1872 | cfg.setGroup("Colors"); |
1870 | int r, g, b; | 1873 | int r, g, b; |
1871 | color.rgb(&r,&g,&b); | 1874 | color.rgb(&r,&g,&b); |
1872 | foreground.setRgb(r,g,b); | 1875 | foreground.setRgb(r,g,b); |
1873 | 1876 | ||
1874 | cfg.writeEntry("foreground",color.name()); | 1877 | cfg.writeEntry("foreground",color.name()); |
1875 | odebug << "foreground "+color.name() << oendl; | 1878 | odebug << "foreground "+color.name() << oendl; |
1876 | cfg.write(); | 1879 | cfg.write(); |
1877 | 1880 | ||
1878 | odebug << "do other dialog" << oendl; | 1881 | odebug << "do other dialog" << oendl; |
1879 | #ifdef QT_QWS_OPIE | 1882 | #ifdef QT_QWS_OPIE |
1880 | 1883 | ||
1881 | Opie::OColorPopupMenu* penColorPopupMenu2 = new Opie::OColorPopupMenu(Qt::black, this,"background color"); | 1884 | Opie::OColorPopupMenu* penColorPopupMenu2 = new Opie::OColorPopupMenu(Qt::black, this,"background color"); |
1882 | connect(penColorPopupMenu2, SIGNAL(colorSelected(const QColor&)), this, | 1885 | connect(penColorPopupMenu2, SIGNAL(colorSelected(const QColor&)), this, |
1883 | SLOT(changeBackgroundColor(const QColor&))); | 1886 | SLOT(changeBackgroundColor(const QColor&))); |
1884 | penColorPopupMenu2->exec(); | 1887 | penColorPopupMenu2->exec(); |
1885 | #endif | 1888 | #endif |
1886 | } | 1889 | } |
1887 | 1890 | ||
1888 | void Konsole::changeBackgroundColor(const QColor &color) | 1891 | void Konsole::changeBackgroundColor(const QColor &color) |
1889 | { | 1892 | { |
1890 | 1893 | ||
1891 | odebug << "Change background" << oendl; | 1894 | odebug << "Change background" << oendl; |
1892 | Config cfg( "Konsole" ); | 1895 | Config cfg( "Konsole" ); |
1893 | cfg.setGroup("Colors"); | 1896 | cfg.setGroup("Colors"); |
1894 | int r, g, b; | 1897 | int r, g, b; |
1895 | color.rgb(&r,&g,&b); | 1898 | color.rgb(&r,&g,&b); |
1896 | background.setRgb(r,g,b); | 1899 | background.setRgb(r,g,b); |
1897 | cfg.writeEntry("background",color.name()); | 1900 | cfg.writeEntry("background",color.name()); |
1898 | odebug << "background "+color.name() << oendl; | 1901 | odebug << "background "+color.name() << oendl; |
1899 | cfg.write(); | 1902 | cfg.write(); |
1900 | } | 1903 | } |
1901 | 1904 | ||
1902 | void Konsole::doWrap() | 1905 | void Konsole::doWrap() |
1903 | { | 1906 | { |
1904 | Config cfg( "Konsole" ); | 1907 | Config cfg( "Konsole" ); |
1905 | cfg.setGroup("ScrollBar"); | 1908 | cfg.setGroup("ScrollBar"); |
1906 | TEWidget* te = getTe(); | 1909 | TEWidget* te = getTe(); |
1907 | if( !cfg.readBoolEntry("HorzScroll",0)) | 1910 | if( !cfg.readBoolEntry("HorzScroll",0)) |
1908 | { | 1911 | { |
1909 | te->setWrapAt(0); | 1912 | te->setWrapAt(0); |
1910 | configMenu->setItemChecked( cm_wrap,TRUE); | 1913 | configMenu->setItemChecked( cm_wrap,TRUE); |
1911 | } | 1914 | } |
1912 | else | 1915 | else |
1913 | { | 1916 | { |
1914 | // te->setWrapAt(90); | 1917 | // te->setWrapAt(90); |
1915 | te->setWrapAt(120); | 1918 | te->setWrapAt(120); |
1916 | configMenu->setItemChecked( cm_wrap,FALSE); | 1919 | configMenu->setItemChecked( cm_wrap,FALSE); |
1917 | } | 1920 | } |
1918 | } | 1921 | } |
1922 | void Konsole::closeSession() { | ||
1923 | doneSession(getTe(), 0); | ||
1924 | } | ||
diff --git a/core/apps/embeddedkonsole/konsole.h b/core/apps/embeddedkonsole/konsole.h index e163cb8..40f5284 100644 --- a/core/apps/embeddedkonsole/konsole.h +++ b/core/apps/embeddedkonsole/konsole.h | |||
@@ -1,206 +1,207 @@ | |||
1 | /* ----------------------------------------------------------------------- */ | 1 | /* ----------------------------------------------------------------------- */ |
2 | /* */ | 2 | /* */ |
3 | /* [konsole.h] Konsole */ | 3 | /* [konsole.h] 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 | #ifndef KONSOLE_H | 22 | #ifndef KONSOLE_H |
23 | #define KONSOLE_H | 23 | #define KONSOLE_H |
24 | 24 | ||
25 | 25 | ||
26 | #include <qmainwindow.h> | 26 | #include <qmainwindow.h> |
27 | #include <qaction.h> | 27 | #include <qaction.h> |
28 | #include <qpopupmenu.h> | 28 | #include <qpopupmenu.h> |
29 | #include <qstrlist.h> | 29 | #include <qstrlist.h> |
30 | #include <qintdict.h> | 30 | #include <qintdict.h> |
31 | #include <qptrdict.h> | 31 | #include <qptrdict.h> |
32 | #include <qtabwidget.h> | 32 | #include <qtabwidget.h> |
33 | #include <qtoolbar.h> | 33 | #include <qtoolbar.h> |
34 | #include <qcombobox.h> | 34 | #include <qcombobox.h> |
35 | #include <qcolor.h> | 35 | #include <qcolor.h> |
36 | 36 | ||
37 | #include "MyPty.h" | 37 | #include "MyPty.h" |
38 | #include "TEWidget.h" | 38 | #include "TEWidget.h" |
39 | #include "TEmuVt102.h" | 39 | #include "TEmuVt102.h" |
40 | #include "session.h" | 40 | #include "session.h" |
41 | 41 | ||
42 | class EKNumTabWidget; | 42 | class EKNumTabWidget; |
43 | 43 | ||
44 | class Konsole : public QMainWindow | 44 | class Konsole : public QMainWindow |
45 | { | 45 | { |
46 | Q_OBJECT | 46 | Q_OBJECT |
47 | 47 | ||
48 | public: | 48 | public: |
49 | 49 | ||
50 | static QString appName() | 50 | static QString appName() |
51 | { | 51 | { |
52 | return QString::fromLatin1("embeddedkonsole"); | 52 | return QString::fromLatin1("embeddedkonsole"); |
53 | } | 53 | } |
54 | 54 | ||
55 | Konsole(QWidget* parent = 0, const char* name = 0, WFlags fl = 0); | 55 | Konsole(QWidget* parent = 0, const char* name = 0, WFlags fl = 0); |
56 | Konsole(const char * name, const char* pgm, QStrList & _args, int histon); | 56 | Konsole(const char * name, const char* pgm, QStrList & _args, int histon); |
57 | ~Konsole(); | 57 | ~Konsole(); |
58 | void setColLin(int columns, int lines); | 58 | void setColLin(int columns, int lines); |
59 | QToolBar *secondToolBar; | 59 | QToolBar *secondToolBar; |
60 | void show(); | 60 | void show(); |
61 | void setColor(int); | 61 | void setColor(int); |
62 | int lastSelectedMenu; | 62 | int lastSelectedMenu; |
63 | int startUp; | 63 | int startUp; |
64 | 64 | ||
65 | public slots: | 65 | public slots: |
66 | void changeFontSize(int); | 66 | void changeFontSize(int); |
67 | void toggleFullScreen(); | 67 | void toggleFullScreen(); |
68 | void setFullScreen(bool); | 68 | void setFullScreen(bool); |
69 | void changeSession(int); | 69 | void changeSession(int); |
70 | void cycleZoom(); | 70 | void cycleZoom(); |
71 | void newSession(); | 71 | void newSession(); |
72 | 72 | ||
73 | private slots: | 73 | private slots: |
74 | void setDocument(const QString &); | 74 | void setDocument(const QString &); |
75 | void doneSession(TEWidget*,int); | 75 | void doneSession(TEWidget*,int); |
76 | void changeTitle(TEWidget*, const QString&); | 76 | void changeTitle(TEWidget*, const QString&); |
77 | void changeColumns(int); | 77 | void changeColumns(int); |
78 | void setFont(int); | 78 | void setFont(int); |
79 | // void fontChanged(int); | 79 | // void fontChanged(int); |
80 | void configMenuSelected(int ); | 80 | void configMenuSelected(int ); |
81 | void colorMenuSelected(int); | 81 | void colorMenuSelected(int); |
82 | void colorMenuIsSelected(int); | 82 | void colorMenuIsSelected(int); |
83 | void tabMenuSelected(int); | 83 | void tabMenuSelected(int); |
84 | void sessionListSelected(int); | 84 | void sessionListSelected(int); |
85 | 85 | ||
86 | void enterCommand(int); | 86 | void enterCommand(int); |
87 | void hitEnter(); | 87 | void hitEnter(); |
88 | void hitSpace(); | 88 | void hitSpace(); |
89 | void hitTab(); | 89 | void hitTab(); |
90 | void hitPaste(); | 90 | void hitPaste(); |
91 | void hitUp(); | 91 | void hitUp(); |
92 | void hitDown(); | 92 | void hitDown(); |
93 | void switchSession(QWidget *); | 93 | void switchSession(QWidget *); |
94 | void changeCommand(const QString &, int); | 94 | void changeCommand(const QString &, int); |
95 | void initCommandList(); | 95 | void initCommandList(); |
96 | void scrollMenuSelected(int); | 96 | void scrollMenuSelected(int); |
97 | void editCommandListMenuSelected(int); | 97 | void editCommandListMenuSelected(int); |
98 | void parseCommandLine(); | 98 | void parseCommandLine(); |
99 | void changeForegroundColor(const QColor &); | 99 | void changeForegroundColor(const QColor &); |
100 | void changeBackgroundColor(const QColor &); | 100 | void changeBackgroundColor(const QColor &); |
101 | 101 | ||
102 | void historyDialog(); | 102 | void historyDialog(); |
103 | void fullscreenTimeout(); | 103 | void fullscreenTimeout(); |
104 | void closeSession(); | ||
104 | 105 | ||
105 | private: | 106 | private: |
106 | void doWrap(); | 107 | void doWrap(); |
107 | void init(const char* _pgm, QStrList & _args); | 108 | void init(const char* _pgm, QStrList & _args); |
108 | void initSession(const char* _pgm, QStrList & _args); | 109 | void initSession(const char* _pgm, QStrList & _args); |
109 | void runSession(TESession* s); | 110 | void runSession(TESession* s); |
110 | void setColorPixmaps(); | 111 | void setColorPixmaps(); |
111 | void setHistory(bool); | 112 | void setHistory(bool); |
112 | void setColors(QColor foreground, QColor background); | 113 | void setColors(QColor foreground, QColor background); |
113 | int findFont(const QString& name, int size, bool exact = false); | 114 | int findFont(const QString& name, int size, bool exact = false); |
114 | QSize calcSize(int columns, int lines); | 115 | QSize calcSize(int columns, int lines); |
115 | TEWidget* getTe(); | 116 | TEWidget* getTe(); |
116 | QStringList commands; | 117 | QStringList commands; |
117 | QLabel * msgLabel; | 118 | QLabel * msgLabel; |
118 | QColor foreground, background; | 119 | QColor foreground, background; |
119 | bool fromMenu; | 120 | bool fromMenu; |
120 | 121 | ||
121 | bool fullscreen; | 122 | bool fullscreen; |
122 | 123 | ||
123 | private: | 124 | private: |
124 | class VTFont | 125 | class VTFont |
125 | { | 126 | { |
126 | public: | 127 | public: |
127 | VTFont(const QString& name, QFont& font, const QString& family, int familyNum, int size) | 128 | VTFont(const QString& name, QFont& font, const QString& family, int familyNum, int size) |
128 | { | 129 | { |
129 | this->name = name; | 130 | this->name = name; |
130 | this->font = font; | 131 | this->font = font; |
131 | this->family = family; | 132 | this->family = family; |
132 | this->size = size; | 133 | this->size = size; |
133 | this->familyNum = familyNum; | 134 | this->familyNum = familyNum; |
134 | } | 135 | } |
135 | 136 | ||
136 | QFont& getFont() | 137 | QFont& getFont() |
137 | { | 138 | { |
138 | return font; | 139 | return font; |
139 | } | 140 | } |
140 | QString getName() | 141 | QString getName() |
141 | { | 142 | { |
142 | return name; | 143 | return name; |
143 | } | 144 | } |
144 | int getSize() | 145 | int getSize() |
145 | { | 146 | { |
146 | return(size); | 147 | return(size); |
147 | } | 148 | } |
148 | QString getFamily() | 149 | QString getFamily() |
149 | { | 150 | { |
150 | return(family); | 151 | return(family); |
151 | } | 152 | } |
152 | int getFamilyNum() | 153 | int getFamilyNum() |
153 | { | 154 | { |
154 | return(familyNum); | 155 | return(familyNum); |
155 | } | 156 | } |
156 | 157 | ||
157 | private: | 158 | private: |
158 | QFont font; | 159 | QFont font; |
159 | QString name; | 160 | QString name; |
160 | QString family; | 161 | QString family; |
161 | int familyNum; | 162 | int familyNum; |
162 | int size; | 163 | int size; |
163 | }; | 164 | }; |
164 | 165 | ||
165 | EKNumTabWidget* tab; | 166 | EKNumTabWidget* tab; |
166 | int tabPos; | 167 | int tabPos; |
167 | int nsessions; | 168 | int nsessions; |
168 | QList<VTFont> fonts; | 169 | QList<VTFont> fonts; |
169 | int cfont; | 170 | int cfont; |
170 | QCString se_pgm; | 171 | QCString se_pgm; |
171 | QStrList se_args; | 172 | QStrList se_args; |
172 | 173 | ||
173 | QToolBar *menuToolBar; | 174 | QToolBar *menuToolBar; |
174 | QToolBar *toolBar; | 175 | QToolBar *toolBar; |
175 | QComboBox *commonCombo; | 176 | QComboBox *commonCombo; |
176 | 177 | ||
177 | QPopupMenu *fontList,*configMenu,*colorMenu,*scrollMenu,*editCommandListMenu; | 178 | QPopupMenu *fontList,*configMenu,*colorMenu,*scrollMenu,*editCommandListMenu; |
178 | QPopupMenu *sessionList, *tabMenu; | 179 | QPopupMenu *sessionList, *tabMenu; |
179 | 180 | ||
180 | int sm_none, sm_left, sm_right; | 181 | int sm_none, sm_left, sm_right; |
181 | int cm_beep, cm_wrap; | 182 | int cm_beep, cm_wrap; |
182 | int cm_default; | 183 | int cm_default; |
183 | int cm_bw, cm_wb, cm_gb, cm_bt, cm_br, cm_rb, cm_gy, cm_bm, cm_mb, cm_cw, cm_wc, cm_bb, cm_ab; | 184 | int cm_bw, cm_wb, cm_gb, cm_bt, cm_br, cm_rb, cm_gy, cm_bm, cm_mb, cm_cw, cm_wc, cm_bb, cm_ab; |
184 | int tm_top, tm_bottom, tm_hidden; | 185 | int tm_top, tm_bottom, tm_hidden; |
185 | int ec_edit, ec_cmdlist, ec_quick; | 186 | int ec_edit, ec_cmdlist, ec_quick; |
186 | 187 | ||
187 | bool show_fullscreen_msg; | 188 | bool show_fullscreen_msg; |
188 | QTimer *fullscreen_timer; | 189 | QTimer *fullscreen_timer; |
189 | QLabel *fullscreen_msg; | 190 | QLabel *fullscreen_msg; |
190 | 191 | ||
191 | 192 | ||
192 | // history scrolling I think | 193 | // history scrolling I think |
193 | bool b_scroll; | 194 | bool b_scroll; |
194 | 195 | ||
195 | int n_keytab; | 196 | int n_keytab; |
196 | int n_scroll; | 197 | int n_scroll; |
197 | int n_render; | 198 | int n_render; |
198 | QString pmPath; // pixmap path | 199 | QString pmPath; // pixmap path |
199 | QString dropText; | 200 | QString dropText; |
200 | QFont defaultFont; | 201 | QFont defaultFont; |
201 | QSize defaultSize; | 202 | QSize defaultSize; |
202 | 203 | ||
203 | }; | 204 | }; |
204 | 205 | ||
205 | #endif | 206 | #endif |
206 | 207 | ||