-rw-r--r-- | core/apps/embeddedkonsole/konsole.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/core/apps/embeddedkonsole/konsole.cpp b/core/apps/embeddedkonsole/konsole.cpp index 7812e4c..b8f009d 100644 --- a/core/apps/embeddedkonsole/konsole.cpp +++ b/core/apps/embeddedkonsole/konsole.cpp | |||
@@ -259,792 +259,792 @@ class HistoryList : public QList<HistoryItem> | |||
259 | } | 259 | } |
260 | }; | 260 | }; |
261 | 261 | ||
262 | void Konsole::initCommandList() | 262 | void Konsole::initCommandList() |
263 | { | 263 | { |
264 | // qDebug("Konsole::initCommandList"); | 264 | // qDebug("Konsole::initCommandList"); |
265 | Config cfg( "Konsole" ); | 265 | Config cfg( "Konsole" ); |
266 | cfg.setGroup("Commands"); | 266 | cfg.setGroup("Commands"); |
267 | // commonCombo->setInsertionPolicy(QComboBox::AtCurrent); | 267 | // commonCombo->setInsertionPolicy(QComboBox::AtCurrent); |
268 | commonCombo->clear(); | 268 | commonCombo->clear(); |
269 | 269 | ||
270 | if (cfg.readEntry("ShellHistory","TRUE") == "TRUE") | 270 | if (cfg.readEntry("ShellHistory","TRUE") == "TRUE") |
271 | { | 271 | { |
272 | QString histfilename = QString(getenv("HOME")) + "/.bash_history"; | 272 | QString histfilename = QString(getenv("HOME")) + "/.bash_history"; |
273 | histfilename = cfg.readEntry("ShellHistoryPath",histfilename); | 273 | histfilename = cfg.readEntry("ShellHistoryPath",histfilename); |
274 | QFile histfile(histfilename); | 274 | QFile histfile(histfilename); |
275 | // note: compiler barfed on: | 275 | // note: compiler barfed on: |
276 | // QFile histfile(QString(getenv("HOME")) + "/.bash_history"); | 276 | // QFile histfile(QString(getenv("HOME")) + "/.bash_history"); |
277 | if (histfile.open( IO_ReadOnly )) | 277 | if (histfile.open( IO_ReadOnly )) |
278 | { | 278 | { |
279 | QString line; | 279 | QString line; |
280 | uint i; | 280 | uint i; |
281 | HistoryList items; | 281 | HistoryList items; |
282 | 282 | ||
283 | int lineno = 0; | 283 | int lineno = 0; |
284 | while(!histfile.atEnd()) | 284 | while(!histfile.atEnd()) |
285 | { | 285 | { |
286 | if (histfile.readLine(line, 200) < 0) | 286 | if (histfile.readLine(line, 200) < 0) |
287 | { | 287 | { |
288 | break; | 288 | break; |
289 | } | 289 | } |
290 | line = line.left(line.length()-1); | 290 | line = line.left(line.length()-1); |
291 | lineno++; | 291 | lineno++; |
292 | 292 | ||
293 | for(i=0; i<items.count(); i++) | 293 | for(i=0; i<items.count(); i++) |
294 | { | 294 | { |
295 | if (line == items.at(i)->line) | 295 | if (line == items.at(i)->line) |
296 | { | 296 | { |
297 | // weight recent commands & repeated commands more | 297 | // weight recent commands & repeated commands more |
298 | // by adding up the index of each command | 298 | // by adding up the index of each command |
299 | items.at(i)->count += lineno; | 299 | items.at(i)->count += lineno; |
300 | break; | 300 | break; |
301 | } | 301 | } |
302 | } | 302 | } |
303 | if (i >= items.count()) | 303 | if (i >= items.count()) |
304 | { | 304 | { |
305 | items.append(new HistoryItem(lineno, line)); | 305 | items.append(new HistoryItem(lineno, line)); |
306 | } | 306 | } |
307 | } | 307 | } |
308 | items.sort(); | 308 | items.sort(); |
309 | int n = items.count(); | 309 | int n = items.count(); |
310 | if (n > 40) | 310 | if (n > 40) |
311 | { | 311 | { |
312 | n = 40; | 312 | n = 40; |
313 | } | 313 | } |
314 | for(int i=0; i<n; i++) | 314 | for(int i=0; i<n; i++) |
315 | { | 315 | { |
316 | // should insert start of command, but keep whole thing | 316 | // should insert start of command, but keep whole thing |
317 | if (items.at(items.count()-i-1)->line.length() < 30) | 317 | if (items.at(items.count()-i-1)->line.length() < 30) |
318 | { | 318 | { |
319 | commonCombo->insertItem(items.at(items.count()-i-1)->line); | 319 | commonCombo->insertItem(items.at(items.count()-i-1)->line); |
320 | } | 320 | } |
321 | } | 321 | } |
322 | histfile.close(); | 322 | histfile.close(); |
323 | } | 323 | } |
324 | } | 324 | } |
325 | if (cfg.readEntry("Commands Set","FALSE") == "FALSE") | 325 | if (cfg.readEntry("Commands Set","FALSE") == "FALSE") |
326 | { | 326 | { |
327 | for (int i = 0; commonCmds[i] != NULL; i++) | 327 | for (int i = 0; commonCmds[i] != NULL; i++) |
328 | { | 328 | { |
329 | commonCombo->insertItem(commonCmds[i]); | 329 | commonCombo->insertItem(commonCmds[i]); |
330 | } | 330 | } |
331 | } | 331 | } |
332 | else | 332 | else |
333 | { | 333 | { |
334 | for (int i = 0; i < 100; i++) | 334 | for (int i = 0; i < 100; i++) |
335 | { | 335 | { |
336 | if (!(cfg.readEntry( QString::number(i),"")).isEmpty()) | 336 | if (!(cfg.readEntry( QString::number(i),"")).isEmpty()) |
337 | commonCombo->insertItem(cfg.readEntry( QString::number(i),"")); | 337 | commonCombo->insertItem(cfg.readEntry( QString::number(i),"")); |
338 | } | 338 | } |
339 | } | 339 | } |
340 | 340 | ||
341 | 341 | ||
342 | } | 342 | } |
343 | 343 | ||
344 | static void sig_handler(int x) | 344 | static void sig_handler(int x) |
345 | { | 345 | { |
346 | printf("got signal %d\n",x); | 346 | printf("got signal %d\n",x); |
347 | } | 347 | } |
348 | 348 | ||
349 | void Konsole::init(const char* _pgm, QStrList & _args) | 349 | void Konsole::init(const char* _pgm, QStrList & _args) |
350 | { | 350 | { |
351 | 351 | ||
352 | #if 0 | 352 | #if 0 |
353 | for(int i=1; i<=31; i++) | 353 | for(int i=1; i<=31; i++) |
354 | { | 354 | { |
355 | if (i != SIGPIPE && i != SIGPROF && i != SIGSEGV | 355 | if (i != SIGPIPE && i != SIGPROF && i != SIGSEGV |
356 | && i != SIGINT && i != SIGILL && i != SIGTERM | 356 | && i != SIGINT && i != SIGILL && i != SIGTERM |
357 | && i != SIGBUS) | 357 | && i != SIGBUS) |
358 | signal(i,sig_handler); | 358 | signal(i,sig_handler); |
359 | } | 359 | } |
360 | #endif | 360 | #endif |
361 | signal(SIGSTOP, sig_handler); | 361 | signal(SIGSTOP, sig_handler); |
362 | signal(SIGCONT, sig_handler); | 362 | signal(SIGCONT, sig_handler); |
363 | signal(SIGTSTP, sig_handler); | 363 | signal(SIGTSTP, sig_handler); |
364 | 364 | ||
365 | b_scroll = TRUE; // histon; | 365 | b_scroll = TRUE; // histon; |
366 | n_keytab = 0; | 366 | n_keytab = 0; |
367 | n_render = 0; | 367 | n_render = 0; |
368 | startUp=0; | 368 | startUp=0; |
369 | fromMenu = FALSE; | 369 | fromMenu = FALSE; |
370 | fullscreen = false; | 370 | fullscreen = false; |
371 | 371 | ||
372 | setCaption( "Konsole" ); | 372 | setCaption( "Konsole" ); |
373 | setIcon( Resource::loadPixmap( "qkonsole/qkonsole" ) ); | 373 | setIcon( Resource::loadPixmap( "qkonsole/qkonsole" ) ); |
374 | 374 | ||
375 | Config cfg( "Konsole" ); | 375 | Config cfg( "Konsole" ); |
376 | cfg.setGroup("Font"); | 376 | cfg.setGroup("Font"); |
377 | QString tmp; | 377 | QString tmp; |
378 | 378 | ||
379 | // initialize the list of allowed fonts /////////////////////////////////// | 379 | // initialize the list of allowed fonts /////////////////////////////////// |
380 | 380 | ||
381 | QString cfgFontName = cfg.readEntry("FontName","Lcfont"); | 381 | QString cfgFontName = cfg.readEntry("FontName","Lcfont"); |
382 | int cfgFontSize = cfg.readNumEntry("FontSize",18); | 382 | int cfgFontSize = cfg.readNumEntry("FontSize",18); |
383 | 383 | ||
384 | cfont = -1; | 384 | cfont = -1; |
385 | 385 | ||
386 | // this code causes repeated access to all the font files | 386 | // this code causes repeated access to all the font files |
387 | // which does slow down startup | 387 | // which does slow down startup |
388 | QFontDatabase fontDB; | 388 | QFontDatabase fontDB; |
389 | QStringList familyNames; | 389 | QStringList familyNames; |
390 | familyNames = fontDB.families( FALSE ); | 390 | familyNames = fontDB.families( FALSE ); |
391 | QString s; | 391 | QString s; |
392 | int fontIndex = 0; | 392 | int fontIndex = 0; |
393 | int familyNum = 0; | 393 | int familyNum = 0; |
394 | fontList = new QPopupMenu( this ); | 394 | fontList = new QPopupMenu( this ); |
395 | 395 | ||
396 | for(uint j = 0; j < (uint)familyNames.count(); j++) | 396 | for(uint j = 0; j < (uint)familyNames.count(); j++) |
397 | { | 397 | { |
398 | s = familyNames[j]; | 398 | s = familyNames[j]; |
399 | if ( s.contains('-') ) | 399 | if ( s.contains('-') ) |
400 | { | 400 | { |
401 | int i = s.find('-'); | 401 | int i = s.find('-'); |
402 | s = s.right( s.length() - i - 1 ) + " [" + s.left( i ) + "]"; | 402 | s = s.right( s.length() - i - 1 ) + " [" + s.left( i ) + "]"; |
403 | } | 403 | } |
404 | s[0] = s[0].upper(); | 404 | s[0] = s[0].upper(); |
405 | 405 | ||
406 | QValueList<int> sizes = fontDB.pointSizes( familyNames[j] ); | 406 | QValueList<int> sizes = fontDB.pointSizes( familyNames[j] ); |
407 | 407 | ||
408 | printf("family[%d] = %s with %d sizes\n", j, familyNames[j].latin1(), | 408 | printf("family[%d] = %s with %d sizes\n", j, familyNames[j].latin1(), |
409 | sizes.count()); | 409 | sizes.count()); |
410 | 410 | ||
411 | if (sizes.count() > 0) | 411 | if (sizes.count() > 0) |
412 | { | 412 | { |
413 | QPopupMenu *sizeMenu; | 413 | QPopupMenu *sizeMenu; |
414 | QFont f; | 414 | QFont f; |
415 | int last_width = -1; | 415 | int last_width = -1; |
416 | sizeMenu = NULL; | 416 | sizeMenu = NULL; |
417 | 417 | ||
418 | for(uint i = 0; i < (uint)sizes.count() + 4; i++) | 418 | for(uint i = 0; i < (uint)sizes.count() + 4; i++) |
419 | { | 419 | { |
420 | // printf("family %s size %d ", familyNames[j].latin1(), sizes[i]); | 420 | // printf("family %s size %d ", familyNames[j].latin1(), sizes[i]); |
421 | // need to divide by 10 on the Z, but not otherwise | 421 | // need to divide by 10 on the Z, but not otherwise |
422 | int size; | 422 | int size; |
423 | 423 | ||
424 | if (i >= (uint)sizes.count()) | 424 | if (i >= (uint)sizes.count()) |
425 | { | 425 | { |
426 | // try for expandable fonts | 426 | // try for expandable fonts |
427 | size = sizes[sizes.count()-1] + 2 * (i - sizes.count() + 1); | 427 | size = sizes[sizes.count()-1] + 2 * (i - sizes.count() + 1); |
428 | } | 428 | } |
429 | else | 429 | else |
430 | { | 430 | { |
431 | printf("sizes[%d] = %d\n", i, sizes[i]); | 431 | printf("sizes[%d] = %d\n", i, sizes[i]); |
432 | size = sizes[i]; | 432 | size = sizes[i]; |
433 | } | 433 | } |
434 | #ifndef __i386__ | 434 | #ifndef __i386__ |
435 | // a hack, sizes on Z seem to be points*10 | 435 | // a hack, sizes on Z seem to be points*10 |
436 | size /= 10; | 436 | size /= 10; |
437 | #endif | 437 | #endif |
438 | 438 | ||
439 | f = QFont(familyNames[j], size); | 439 | f = QFont(familyNames[j], size); |
440 | f.setFixedPitch(true); | 440 | f.setFixedPitch(true); |
441 | QFontMetrics fm(f); | 441 | QFontMetrics fm(f); |
442 | // don't trust f.fixedPitch() or f.exactMatch(), they lie!! | 442 | // don't trust f.fixedPitch() or f.exactMatch(), they lie!! |
443 | if (fm.width("l") == fm.width("m") | 443 | if (fm.width("l") == fm.width("m") |
444 | && (i < (uint)sizes.count() | 444 | && (i < (uint)sizes.count() |
445 | || fm.width("m") > last_width)) | 445 | || fm.width("m") > last_width)) |
446 | { | 446 | { |
447 | if (i < (uint)sizes.count()) | 447 | if (i < (uint)sizes.count()) |
448 | { | 448 | { |
449 | last_width = fm.width("m"); | 449 | last_width = fm.width("m"); |
450 | } | 450 | } |
451 | if (sizeMenu == NULL) | 451 | if (sizeMenu == NULL) |
452 | { | 452 | { |
453 | sizeMenu = new QPopupMenu(); | 453 | sizeMenu = new QPopupMenu(); |
454 | } | 454 | } |
455 | int id = sizeMenu->insertItem(QString("%1").arg(size), fontIndex); | 455 | int id = sizeMenu->insertItem(QString("%1").arg(size), fontIndex); |
456 | sizeMenu->setItemParameter(id, fontIndex); | 456 | sizeMenu->setItemParameter(id, fontIndex); |
457 | sizeMenu->connectItem(id, this, SLOT(setFont(int))); | 457 | sizeMenu->connectItem(id, this, SLOT(setFont(int))); |
458 | QString name = s + " " + QString::number(size); | 458 | QString name = s + " " + QString::number(size); |
459 | fonts.append(new VTFont(name, f, familyNames[j], familyNum, size)); | 459 | fonts.append(new VTFont(name, f, familyNames[j], familyNum, size)); |
460 | if (familyNames[j] == cfgFontName && size == cfgFontSize) | 460 | if (familyNames[j] == cfgFontName && size == cfgFontSize) |
461 | { | 461 | { |
462 | cfont = fontIndex; | 462 | cfont = fontIndex; |
463 | } | 463 | } |
464 | printf("FOUND: %s family %s size %d\n", name.latin1(), familyNames[j].latin1(), size); | 464 | printf("FOUND: %s family %s size %d\n", name.latin1(), familyNames[j].latin1(), size); |
465 | fontIndex++; | 465 | fontIndex++; |
466 | } | 466 | } |
467 | } | 467 | } |
468 | if (sizeMenu) | 468 | if (sizeMenu) |
469 | { | 469 | { |
470 | fontList->insertItem(s, sizeMenu, familyNum + 1000); | 470 | fontList->insertItem(s, sizeMenu, familyNum + 1000); |
471 | 471 | ||
472 | familyNum++; | 472 | familyNum++; |
473 | } | 473 | } |
474 | } | 474 | } |
475 | 475 | ||
476 | } | 476 | } |
477 | 477 | ||
478 | if (cfont < 0 || cfont >= (int)fonts.count()) | 478 | if (cfont < 0 || cfont >= (int)fonts.count()) |
479 | { | 479 | { |
480 | cfont = 0; | 480 | cfont = 0; |
481 | } | 481 | } |
482 | 482 | ||
483 | // create terminal emulation framework //////////////////////////////////// | 483 | // create terminal emulation framework //////////////////////////////////// |
484 | nsessions = 0; | 484 | nsessions = 0; |
485 | 485 | ||
486 | tab = new EKNumTabWidget(this); | 486 | tab = new EKNumTabWidget(this); |
487 | // tab->setMargin(tab->margin()-5); | 487 | // tab->setMargin(tab->margin()-5); |
488 | connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*))); | 488 | connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*))); |
489 | 489 | ||
490 | // create terminal toolbar //////////////////////////////////////////////// | 490 | // create terminal toolbar //////////////////////////////////////////////// |
491 | setToolBarsMovable( FALSE ); | 491 | setToolBarsMovable( FALSE ); |
492 | menuToolBar = new QToolBar( this ); | 492 | menuToolBar = new QToolBar( this ); |
493 | menuToolBar->setHorizontalStretchable( TRUE ); | 493 | menuToolBar->setHorizontalStretchable( TRUE ); |
494 | 494 | ||
495 | QMenuBar *menuBar = new QMenuBar( menuToolBar ); | 495 | QMenuBar *menuBar = new QMenuBar( menuToolBar ); |
496 | 496 | ||
497 | bool c7xx = false; | 497 | bool c7xx = false; |
498 | if (qApp->desktop()->width() > 600 || qApp->desktop()->height() > 600) | 498 | if (qApp->desktop()->width() > 600 || qApp->desktop()->height() > 600) |
499 | { | 499 | { |
500 | c7xx = true; | 500 | c7xx = true; |
501 | } | 501 | } |
502 | QFont menuFont; | 502 | QFont menuFont; |
503 | menuFont.setPointSize(c7xx? 18 : 10); | 503 | menuFont.setPointSize(c7xx? 18 : 10); |
504 | qApp->setFont(menuFont, true); | 504 | qApp->setFont(menuFont, true); |
505 | 505 | ||
506 | setFont(cfont); | 506 | setFont(cfont); |
507 | 507 | ||
508 | configMenu = new QPopupMenu( this); | 508 | configMenu = new QPopupMenu( this); |
509 | colorMenu = new QPopupMenu( this); | 509 | colorMenu = new QPopupMenu( this); |
510 | scrollMenu = new QPopupMenu( this); | 510 | scrollMenu = new QPopupMenu( this); |
511 | editCommandListMenu = new QPopupMenu( this); | 511 | editCommandListMenu = new QPopupMenu( this); |
512 | 512 | ||
513 | configMenu->insertItem(tr("Command List"), editCommandListMenu); | 513 | configMenu->insertItem(tr("Command List"), editCommandListMenu); |
514 | 514 | ||
515 | bool listHidden; | 515 | bool listHidden; |
516 | cfg.setGroup("Menubar"); | 516 | cfg.setGroup("Menubar"); |
517 | if( cfg.readEntry("Hidden","FALSE") == "TRUE") | 517 | if( cfg.readEntry("Hidden","FALSE") == "TRUE") |
518 | { | 518 | { |
519 | ec_cmdlist = editCommandListMenu->insertItem( tr( "Show command list" )); | 519 | ec_cmdlist = editCommandListMenu->insertItem( tr( "Show command list" )); |
520 | listHidden=TRUE; | 520 | listHidden=TRUE; |
521 | } | 521 | } |
522 | else | 522 | else |
523 | { | 523 | { |
524 | ec_cmdlist = editCommandListMenu->insertItem( tr( "Hide command list" )); | 524 | ec_cmdlist = editCommandListMenu->insertItem( tr( "Hide command list" )); |
525 | listHidden=FALSE; | 525 | listHidden=FALSE; |
526 | } | 526 | } |
527 | 527 | ||
528 | cfg.setGroup("Tabs"); | 528 | cfg.setGroup("Tabs"); |
529 | 529 | ||
530 | tabMenu = new QPopupMenu(this); | 530 | tabMenu = new QPopupMenu(this); |
531 | tm_bottom = tabMenu->insertItem(tr("Bottom" )); | 531 | tm_bottom = tabMenu->insertItem(tr("Bottom" )); |
532 | tm_top = tabMenu->insertItem(tr("Top")); | 532 | tm_top = tabMenu->insertItem(tr("Top")); |
533 | tm_hidden = tabMenu->insertItem(tr("Hidden")); | 533 | tm_hidden = tabMenu->insertItem(tr("Hidden")); |
534 | 534 | ||
535 | configMenu->insertItem(tr("Tabs"), tabMenu); | 535 | configMenu->insertItem(tr("Tabs"), tabMenu); |
536 | 536 | ||
537 | tmp=cfg.readEntry("Position","Top"); | 537 | tmp=cfg.readEntry("Position","Top"); |
538 | if(tmp=="Top") | 538 | if(tmp=="Top") |
539 | { | 539 | { |
540 | tab->setTabPosition(QTabWidget::Top); | 540 | tab->setTabPosition(QTabWidget::Top); |
541 | tab->getTabBar()->show(); | 541 | tab->getTabBar()->show(); |
542 | tabPos = tm_top; | 542 | tabPos = tm_top; |
543 | } | 543 | } |
544 | else if (tmp=="Bottom") | 544 | else if (tmp=="Bottom") |
545 | { | 545 | { |
546 | tab->setTabPosition(QTabWidget::Bottom); | 546 | tab->setTabPosition(QTabWidget::Bottom); |
547 | tab->getTabBar()->show(); | 547 | tab->getTabBar()->show(); |
548 | tabPos = tm_bottom; | 548 | tabPos = tm_bottom; |
549 | } | 549 | } |
550 | else | 550 | else |
551 | { | 551 | { |
552 | tab->getTabBar()->hide(); | 552 | tab->getTabBar()->hide(); |
553 | tab->setMargin(tab->margin()); | 553 | tab->setMargin(tab->margin()); |
554 | tabPos = tm_hidden; | 554 | tabPos = tm_hidden; |
555 | } | 555 | } |
556 | 556 | ||
557 | cm_bw = colorMenu->insertItem(tr( "Black on White")); | 557 | cm_bw = colorMenu->insertItem(tr( "Black on White")); |
558 | cm_wb = colorMenu->insertItem(tr( "White on Black")); | 558 | cm_wb = colorMenu->insertItem(tr( "White on Black")); |
559 | cm_gb = colorMenu->insertItem(tr( "Green on Black")); | 559 | cm_gb = colorMenu->insertItem(tr( "Green on Black")); |
560 | // cm_bt = colorMenu->insertItem(tr( "Black on Transparent")); | 560 | // cm_bt = colorMenu->insertItem(tr( "Black on Transparent")); |
561 | cm_br = colorMenu->insertItem(tr( "Black on Pink")); | 561 | cm_br = colorMenu->insertItem(tr( "Black on Pink")); |
562 | cm_rb = colorMenu->insertItem(tr( "Pink on Black")); | 562 | cm_rb = colorMenu->insertItem(tr( "Pink on Black")); |
563 | cm_gy = colorMenu->insertItem(tr( "Green on Yellow")); | 563 | cm_gy = colorMenu->insertItem(tr( "Green on Yellow")); |
564 | cm_bm = colorMenu->insertItem(tr( "Blue on Magenta")); | 564 | cm_bm = colorMenu->insertItem(tr( "Blue on Magenta")); |
565 | cm_mb = colorMenu->insertItem(tr( "Magenta on Blue")); | 565 | cm_mb = colorMenu->insertItem(tr( "Magenta on Blue")); |
566 | cm_cw = colorMenu->insertItem(tr( "Cyan on White")); | 566 | cm_cw = colorMenu->insertItem(tr( "Cyan on White")); |
567 | cm_wc = colorMenu->insertItem(tr( "White on Cyan")); | 567 | cm_wc = colorMenu->insertItem(tr( "White on Cyan")); |
568 | cm_bb = colorMenu->insertItem(tr( "Blue on Black")); | 568 | cm_bb = colorMenu->insertItem(tr( "Blue on Black")); |
569 | cm_ab = colorMenu->insertItem(tr( "Amber on Black")); | 569 | cm_ab = colorMenu->insertItem(tr( "Amber on Black")); |
570 | cm_default = colorMenu->insertItem(tr("default")); | 570 | cm_default = colorMenu->insertItem(tr("default")); |
571 | 571 | ||
572 | #ifdef QT_QWS_OPIE | 572 | #ifdef QT_QWS_OPIE |
573 | 573 | ||
574 | colorMenu->insertItem(tr( "Custom")); | 574 | colorMenu->insertItem(tr( "Custom")); |
575 | #endif | 575 | #endif |
576 | 576 | ||
577 | configMenu->insertItem(tr( "Colors") ,colorMenu); | 577 | configMenu->insertItem(tr( "Colors") ,colorMenu); |
578 | 578 | ||
579 | sessionList = new QPopupMenu(this); | 579 | sessionList = new QPopupMenu(this); |
580 | sessionList-> insertItem ( Resource::loadPixmap ( "qkonsole/qkonsole" ), tr( "new session" ), this, | 580 | sessionList-> insertItem ( Resource::loadPixmap ( "qkonsole/qkonsole" ), tr( "new session" ), this, |
581 | SLOT(newSession()) ); | 581 | SLOT(newSession()) ); |
582 | 582 | ||
583 | // connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) )); | 583 | // connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) )); |
584 | connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) )); | 584 | connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) )); |
585 | connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuIsSelected(int) )); | 585 | connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuIsSelected(int) )); |
586 | connect( tabMenu, SIGNAL( activated(int) ), this, SLOT( tabMenuSelected(int) )); | 586 | connect( tabMenu, SIGNAL( activated(int) ), this, SLOT( tabMenuSelected(int) )); |
587 | connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int))); | 587 | connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int))); |
588 | connect( editCommandListMenu,SIGNAL(activated(int)),this,SLOT(editCommandListMenuSelected(int))); | 588 | connect( editCommandListMenu,SIGNAL(activated(int)),this,SLOT(editCommandListMenuSelected(int))); |
589 | connect( sessionList, SIGNAL(activated(int)), this, SLOT( sessionListSelected(int) ) ); | 589 | connect( sessionList, SIGNAL(activated(int)), this, SLOT( sessionListSelected(int) ) ); |
590 | 590 | ||
591 | menuBar->insertItem( tr("View"), configMenu ); | 591 | menuBar->insertItem( tr("View"), configMenu ); |
592 | menuBar->insertItem( tr("Fonts"), fontList ); | 592 | menuBar->insertItem( tr("Fonts"), fontList ); |
593 | menuBar->insertItem( tr("Sessions"), sessionList ); | 593 | menuBar->insertItem( tr("Sessions"), sessionList ); |
594 | 594 | ||
595 | toolBar = new QToolBar( this ); | 595 | toolBar = new QToolBar( this ); |
596 | 596 | ||
597 | QAction *a; | 597 | QAction *a; |
598 | 598 | ||
599 | // Button Commands | 599 | // Button Commands |
600 | a = new QAction( tr("New"), Resource::loadPixmap( "konsole/Terminal" ), QString::null, 0, this, 0 ); | 600 | a = new QAction( tr("New"), Resource::loadPixmap( "konsole/Terminal" ), QString::null, 0, this, 0 ); |
601 | connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); | 601 | connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); |
602 | a->addTo( toolBar ); | 602 | a->addTo( toolBar ); |
603 | 603 | ||
604 | a = new QAction( tr("Full Screen"), Resource::loadPixmap( "fullscreen" ), QString::null, 0, this, 0 ); | 604 | a = new QAction( tr("Full Screen"), Resource::loadPixmap( "fullscreen" ), QString::null, 0, this, 0 ); |
605 | connect( a, SIGNAL( activated() ), this, SLOT( toggleFullScreen() ) ); | 605 | connect( a, SIGNAL( activated() ), this, SLOT( toggleFullScreen() ) ); |
606 | a->addTo( toolBar ); | 606 | a->addTo( toolBar ); |
607 | 607 | ||
608 | a = new QAction( tr("Zoom"), Resource::loadPixmap( "zoom" ), QString::null, 0, this, 0 ); | 608 | a = new QAction( tr("Zoom"), Resource::loadPixmap( "zoom" ), QString::null, 0, this, 0 ); |
609 | connect( a, SIGNAL( activated() ), this, SLOT( cycleZoom() ) ); | 609 | connect( a, SIGNAL( activated() ), this, SLOT( cycleZoom() ) ); |
610 | a->addTo( toolBar ); | 610 | a->addTo( toolBar ); |
611 | 611 | ||
612 | 612 | ||
613 | /* | 613 | /* |
614 | a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 ); | 614 | a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 ); |
615 | connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolBar ); | 615 | connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolBar ); |
616 | a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 ); | 616 | a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 ); |
617 | connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolBar ); | 617 | connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolBar ); |
618 | a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 ); | 618 | a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 ); |
619 | connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolBar ); | 619 | connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolBar ); |
620 | */ | 620 | */ |
621 | /* | 621 | /* |
622 | a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 ); | 622 | a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 ); |
623 | connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolBar ); | 623 | connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolBar ); |
624 | a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 ); | 624 | a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 ); |
625 | connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolBar ); | 625 | connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolBar ); |
626 | */ | 626 | */ |
627 | a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); | 627 | a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); |
628 | connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); | 628 | connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); |
629 | a->addTo( toolBar ); | 629 | a->addTo( toolBar ); |
630 | 630 | ||
631 | secondToolBar = new QToolBar( this ); | 631 | secondToolBar = new QToolBar( this ); |
632 | secondToolBar->setHorizontalStretchable( TRUE ); | 632 | secondToolBar->setHorizontalStretchable( TRUE ); |
633 | 633 | ||
634 | commonCombo = new QComboBox( secondToolBar ); | 634 | commonCombo = new QComboBox( secondToolBar ); |
635 | // commonCombo->setMaximumWidth(236); | 635 | // commonCombo->setMaximumWidth(236); |
636 | 636 | ||
637 | ec_quick = editCommandListMenu->insertItem( tr( "Quick Edit" ) ); | 637 | ec_quick = editCommandListMenu->insertItem( tr( "Quick Edit" ) ); |
638 | if( listHidden) | 638 | if( listHidden) |
639 | { | 639 | { |
640 | secondToolBar->hide(); | 640 | secondToolBar->hide(); |
641 | editCommandListMenu->setItemEnabled(ec_quick ,FALSE); | 641 | editCommandListMenu->setItemEnabled(ec_quick ,FALSE); |
642 | } | 642 | } |
643 | ec_edit = editCommandListMenu->insertItem(tr( "Edit" ) ); | 643 | ec_edit = editCommandListMenu->insertItem(tr( "Edit..." ) ); |
644 | 644 | ||
645 | cfg.setGroup("Commands"); | 645 | cfg.setGroup("Commands"); |
646 | commonCombo->setInsertionPolicy(QComboBox::AtCurrent); | 646 | commonCombo->setInsertionPolicy(QComboBox::AtCurrent); |
647 | 647 | ||
648 | initCommandList(); | 648 | initCommandList(); |
649 | // for (int i = 0; commonCmds[i] != NULL; i++) { | 649 | // for (int i = 0; commonCmds[i] != NULL; i++) { |
650 | // commonCombo->insertItem( commonCmds[i], i ); | 650 | // commonCombo->insertItem( commonCmds[i], i ); |
651 | // tmp = cfg.readEntry( QString::number(i),""); | 651 | // tmp = cfg.readEntry( QString::number(i),""); |
652 | // if(tmp != "") | 652 | // if(tmp != "") |
653 | // commonCombo->changeItem( tmp,i ); | 653 | // commonCombo->changeItem( tmp,i ); |
654 | // } | 654 | // } |
655 | 655 | ||
656 | connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) )); | 656 | connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) )); |
657 | 657 | ||
658 | sm_none = scrollMenu->insertItem(tr( "None" )); | 658 | sm_none = scrollMenu->insertItem(tr( "None" )); |
659 | sm_left = scrollMenu->insertItem(tr( "Left" )); | 659 | sm_left = scrollMenu->insertItem(tr( "Left" )); |
660 | sm_right = scrollMenu->insertItem(tr( "Right" )); | 660 | sm_right = scrollMenu->insertItem(tr( "Right" )); |
661 | // scrollMenu->insertSeparator(4); | 661 | // scrollMenu->insertSeparator(4); |
662 | // scrollMenu->insertItem(tr( "Horizontal" )); | 662 | // scrollMenu->insertItem(tr( "Horizontal" )); |
663 | 663 | ||
664 | configMenu->insertItem(tr( "ScrollBar" ),scrollMenu); | 664 | configMenu->insertItem(tr( "ScrollBar" ),scrollMenu); |
665 | 665 | ||
666 | configMenu->insertItem(tr( "History" ), this, SLOT(historyDialog())); | 666 | configMenu->insertItem(tr( "History..." ), this, SLOT(historyDialog())); |
667 | 667 | ||
668 | cm_wrap = configMenu->insertItem(tr( "Wrap" )); | 668 | cm_wrap = configMenu->insertItem(tr( "Wrap" )); |
669 | cfg.setGroup("ScrollBar"); | 669 | cfg.setGroup("ScrollBar"); |
670 | configMenu->setItemChecked(cm_wrap, cfg.readBoolEntry("HorzScroll",0)); | 670 | configMenu->setItemChecked(cm_wrap, cfg.readBoolEntry("HorzScroll",0)); |
671 | 671 | ||
672 | cm_beep = configMenu->insertItem(tr( "Use Beep" )); | 672 | cm_beep = configMenu->insertItem(tr( "Use Beep" )); |
673 | cfg.setGroup("Menubar"); | 673 | cfg.setGroup("Menubar"); |
674 | configMenu->setItemChecked(cm_beep, cfg.readBoolEntry("useBeep",0)); | 674 | configMenu->setItemChecked(cm_beep, cfg.readBoolEntry("useBeep",0)); |
675 | 675 | ||
676 | fullscreen_msg = new QLabel(this); | 676 | fullscreen_msg = new QLabel(this); |
677 | fullscreen_msg-> setAlignment ( AlignCenter | SingleLine ); | 677 | fullscreen_msg-> setAlignment ( AlignCenter | SingleLine ); |
678 | fullscreen_msg-> hide(); | 678 | fullscreen_msg-> hide(); |
679 | fullscreen_msg-> setSizePolicy ( QSizePolicy ( QSizePolicy::Expanding, QSizePolicy::Expanding )); | 679 | fullscreen_msg-> setSizePolicy ( QSizePolicy ( QSizePolicy::Expanding, QSizePolicy::Expanding )); |
680 | fullscreen_msg-> setAutoResize(true); | 680 | fullscreen_msg-> setAutoResize(true); |
681 | fullscreen_msg-> setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 681 | fullscreen_msg-> setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
682 | fullscreen_msg-> setText(tr("To exit fullscreen, tap here.")); | 682 | fullscreen_msg-> setText(tr("To exit fullscreen, tap here.")); |
683 | 683 | ||
684 | fullscreen_timer = new QTimer(this); | 684 | fullscreen_timer = new QTimer(this); |
685 | connect(fullscreen_timer, SIGNAL(timeout()), | 685 | connect(fullscreen_timer, SIGNAL(timeout()), |
686 | this, SLOT(fullscreenTimeout())); | 686 | this, SLOT(fullscreenTimeout())); |
687 | show_fullscreen_msg = true; | 687 | show_fullscreen_msg = true; |
688 | 688 | ||
689 | //scrollMenuSelected(-29); | 689 | //scrollMenuSelected(-29); |
690 | // cfg.setGroup("ScrollBar"); | 690 | // cfg.setGroup("ScrollBar"); |
691 | // if(cfg.readBoolEntry("HorzScroll",0)) { | 691 | // if(cfg.readBoolEntry("HorzScroll",0)) { |
692 | // if(cfg.readNumEntry("Position",2) == 0) | 692 | // if(cfg.readNumEntry("Position",2) == 0) |
693 | // te->setScrollbarLocation(1); | 693 | // te->setScrollbarLocation(1); |
694 | // else | 694 | // else |
695 | // te->setScrollbarLocation(0); | 695 | // te->setScrollbarLocation(0); |
696 | // te->setScrollbarLocation( cfg.readNumEntry("Position",2)); | 696 | // te->setScrollbarLocation( cfg.readNumEntry("Position",2)); |
697 | // te->setWrapAt(120); | 697 | // te->setWrapAt(120); |
698 | // } | 698 | // } |
699 | // create applications ///////////////////////////////////////////////////// | 699 | // create applications ///////////////////////////////////////////////////// |
700 | setCentralWidget(tab); | 700 | setCentralWidget(tab); |
701 | 701 | ||
702 | // load keymaps //////////////////////////////////////////////////////////// | 702 | // load keymaps //////////////////////////////////////////////////////////// |
703 | KeyTrans::loadAll(); | 703 | KeyTrans::loadAll(); |
704 | for (int i = 0; i < KeyTrans::count(); i++) | 704 | for (int i = 0; i < KeyTrans::count(); i++) |
705 | { | 705 | { |
706 | KeyTrans* s = KeyTrans::find(i); | 706 | KeyTrans* s = KeyTrans::find(i); |
707 | assert( s ); | 707 | assert( s ); |
708 | } | 708 | } |
709 | 709 | ||
710 | se_pgm = _pgm; | 710 | se_pgm = _pgm; |
711 | se_args = _args; | 711 | se_args = _args; |
712 | 712 | ||
713 | cfg.setGroup("CommandLine"); | 713 | cfg.setGroup("CommandLine"); |
714 | 714 | ||
715 | if (cfg.hasKey("shell_args")) | 715 | if (cfg.hasKey("shell_args")) |
716 | { | 716 | { |
717 | QStringList se_args_list = cfg.readListEntry("shell_args",'|'); | 717 | QStringList se_args_list = cfg.readListEntry("shell_args",'|'); |
718 | for(uint i = 0; i < se_args_list.count(); i++) | 718 | for(uint i = 0; i < se_args_list.count(); i++) |
719 | { | 719 | { |
720 | se_args.prepend(se_args_list[se_args_list.count() - i - 1].latin1()); | 720 | se_args.prepend(se_args_list[se_args_list.count() - i - 1].latin1()); |
721 | } | 721 | } |
722 | } | 722 | } |
723 | else | 723 | else |
724 | { | 724 | { |
725 | se_args.prepend("--login"); | 725 | se_args.prepend("--login"); |
726 | } | 726 | } |
727 | 727 | ||
728 | se_pgm = cfg.readEntry("shell_bin", QString(se_pgm)); | 728 | se_pgm = cfg.readEntry("shell_bin", QString(se_pgm)); |
729 | 729 | ||
730 | // this is the "documentation" for those who know to look | 730 | // this is the "documentation" for those who know to look |
731 | if (! cfg.hasKey("shell_args")) | 731 | if (! cfg.hasKey("shell_args")) |
732 | { | 732 | { |
733 | cfg.writeEntry("shell_args",QStringList::fromStrList(se_args),'|'); | 733 | cfg.writeEntry("shell_args",QStringList::fromStrList(se_args),'|'); |
734 | } | 734 | } |
735 | if (! cfg.hasKey("shell_bin")) | 735 | if (! cfg.hasKey("shell_bin")) |
736 | { | 736 | { |
737 | cfg.writeEntry("shell_bin",QString(se_pgm)); | 737 | cfg.writeEntry("shell_bin",QString(se_pgm)); |
738 | } | 738 | } |
739 | 739 | ||
740 | parseCommandLine(); | 740 | parseCommandLine(); |
741 | 741 | ||
742 | // read and apply default values /////////////////////////////////////////// | 742 | // read and apply default values /////////////////////////////////////////// |
743 | resize(321, 321); // Dummy. | 743 | resize(321, 321); // Dummy. |
744 | QSize currentSize = size(); | 744 | QSize currentSize = size(); |
745 | if (currentSize != size()) | 745 | if (currentSize != size()) |
746 | defaultSize = size(); | 746 | defaultSize = size(); |
747 | 747 | ||
748 | 748 | ||
749 | /* allows us to catch cancel/escape */ | 749 | /* allows us to catch cancel/escape */ |
750 | reparent ( 0, WStyle_Customize | WStyle_NoBorder, | 750 | reparent ( 0, WStyle_Customize | WStyle_NoBorder, |
751 | QPoint ( 0, 0 )); | 751 | QPoint ( 0, 0 )); |
752 | } | 752 | } |
753 | 753 | ||
754 | void Konsole::show() | 754 | void Konsole::show() |
755 | { | 755 | { |
756 | if ( !nsessions ) | 756 | if ( !nsessions ) |
757 | { | 757 | { |
758 | newSession(); | 758 | newSession(); |
759 | } | 759 | } |
760 | QMainWindow::show(); | 760 | QMainWindow::show(); |
761 | 761 | ||
762 | } | 762 | } |
763 | 763 | ||
764 | void Konsole::initSession(const char*, QStrList &) | 764 | void Konsole::initSession(const char*, QStrList &) |
765 | { | 765 | { |
766 | QMainWindow::show(); | 766 | QMainWindow::show(); |
767 | } | 767 | } |
768 | 768 | ||
769 | Konsole::~Konsole() | 769 | Konsole::~Konsole() |
770 | { | 770 | { |
771 | while (nsessions > 0) | 771 | while (nsessions > 0) |
772 | { | 772 | { |
773 | doneSession(getTe(), 0); | 773 | doneSession(getTe(), 0); |
774 | } | 774 | } |
775 | } | 775 | } |
776 | 776 | ||
777 | void | 777 | void |
778 | Konsole::historyDialog() | 778 | Konsole::historyDialog() |
779 | { | 779 | { |
780 | QDialog *d = new QDialog ( this, "histdlg", true ); | 780 | QDialog *d = new QDialog ( this, "histdlg", true ); |
781 | // d-> setCaption ( tr( "History" )); | 781 | // d-> setCaption ( tr( "History" )); |
782 | 782 | ||
783 | QBoxLayout *lay = new QVBoxLayout ( d, 4, 4 ); | 783 | QBoxLayout *lay = new QVBoxLayout ( d, 4, 4 ); |
784 | 784 | ||
785 | QLabel *l = new QLabel ( tr( "History Lines:" ), d ); | 785 | QLabel *l = new QLabel ( tr( "History Lines:" ), d ); |
786 | lay-> addWidget ( l ); | 786 | lay-> addWidget ( l ); |
787 | 787 | ||
788 | Config cfg( "Konsole" ); | 788 | Config cfg( "Konsole" ); |
789 | cfg.setGroup("History"); | 789 | cfg.setGroup("History"); |
790 | int hist = cfg.readNumEntry("history_lines",300); | 790 | int hist = cfg.readNumEntry("history_lines",300); |
791 | int avg_line = cfg.readNumEntry("avg_line_length",60); | 791 | int avg_line = cfg.readNumEntry("avg_line_length",60); |
792 | 792 | ||
793 | QSpinBox *spin = new QSpinBox ( 1, 100000, 20, d ); | 793 | QSpinBox *spin = new QSpinBox ( 1, 100000, 20, d ); |
794 | spin-> setValue ( hist ); | 794 | spin-> setValue ( hist ); |
795 | spin-> setWrapping ( true ); | 795 | spin-> setWrapping ( true ); |
796 | spin-> setButtonSymbols ( QSpinBox::PlusMinus ); | 796 | spin-> setButtonSymbols ( QSpinBox::PlusMinus ); |
797 | lay-> addWidget ( spin ); | 797 | lay-> addWidget ( spin ); |
798 | 798 | ||
799 | if ( d-> exec ( ) == QDialog::Accepted ) | 799 | if ( d-> exec ( ) == QDialog::Accepted ) |
800 | { | 800 | { |
801 | cfg.writeEntry("history_lines", spin->value()); | 801 | cfg.writeEntry("history_lines", spin->value()); |
802 | cfg.writeEntry("avg_line_length", avg_line); | 802 | cfg.writeEntry("avg_line_length", avg_line); |
803 | if (getTe() != NULL) | 803 | if (getTe() != NULL) |
804 | { | 804 | { |
805 | getTe()->currentSession->setHistory(true); | 805 | getTe()->currentSession->setHistory(true); |
806 | } | 806 | } |
807 | } | 807 | } |
808 | 808 | ||
809 | delete d; | 809 | delete d; |
810 | } | 810 | } |
811 | 811 | ||
812 | 812 | ||
813 | void Konsole::cycleZoom() | 813 | void Konsole::cycleZoom() |
814 | { | 814 | { |
815 | TEWidget* te = getTe(); | 815 | TEWidget* te = getTe(); |
816 | QFont font = te->getVTFont(); | 816 | QFont font = te->getVTFont(); |
817 | int size = font.pointSize(); | 817 | int size = font.pointSize(); |
818 | changeFontSize(1); | 818 | changeFontSize(1); |
819 | font = te->getVTFont(); | 819 | font = te->getVTFont(); |
820 | if (font.pointSize() <= size) | 820 | if (font.pointSize() <= size) |
821 | { | 821 | { |
822 | do | 822 | do |
823 | { | 823 | { |
824 | font = te->getVTFont(); | 824 | font = te->getVTFont(); |
825 | size = font.pointSize(); | 825 | size = font.pointSize(); |
826 | changeFontSize(-1); | 826 | changeFontSize(-1); |
827 | font = te->getVTFont(); | 827 | font = te->getVTFont(); |
828 | } | 828 | } |
829 | while (font.pointSize() < size); | 829 | while (font.pointSize() < size); |
830 | } | 830 | } |
831 | } | 831 | } |
832 | 832 | ||
833 | void Konsole::changeFontSize(int delta) | 833 | void Konsole::changeFontSize(int delta) |
834 | { | 834 | { |
835 | // printf("delta font size %d\n", delta); | 835 | // printf("delta font size %d\n", delta); |
836 | TEWidget* te = getTe(); | 836 | TEWidget* te = getTe(); |
837 | QFont font = te->getVTFont(); | 837 | QFont font = te->getVTFont(); |
838 | int size = font.pointSize(); | 838 | int size = font.pointSize(); |
839 | int closest = delta > 0? 10000 : -10000; | 839 | int closest = delta > 0? 10000 : -10000; |
840 | int closest_font = -1; | 840 | int closest_font = -1; |
841 | for(uint i = 0; i < fonts.count(); i++) | 841 | for(uint i = 0; i < fonts.count(); i++) |
842 | { | 842 | { |
843 | if (fonts.at(i)->getFont() == font) | 843 | if (fonts.at(i)->getFont() == font) |
844 | { | 844 | { |
845 | if (delta > 0) | 845 | if (delta > 0) |
846 | { | 846 | { |
847 | if (i+1 < fonts.count() | 847 | if (i+1 < fonts.count() |
848 | && fonts.at(i+1)->getFamilyNum() == fonts.at(i)->getFamilyNum()) | 848 | && fonts.at(i+1)->getFamilyNum() == fonts.at(i)->getFamilyNum()) |
849 | { | 849 | { |
850 | setFont(i+1); | 850 | setFont(i+1); |
851 | printf("font %d\n", i+1); | 851 | printf("font %d\n", i+1); |
852 | return; | 852 | return; |
853 | } | 853 | } |
854 | } | 854 | } |
855 | else if (delta < 0) | 855 | else if (delta < 0) |
856 | { | 856 | { |
857 | if (i > 0 | 857 | if (i > 0 |
858 | && fonts.at(i-1)->getFamilyNum() == fonts.at(i)->getFamilyNum()) | 858 | && fonts.at(i-1)->getFamilyNum() == fonts.at(i)->getFamilyNum()) |
859 | { | 859 | { |
860 | setFont(i-1); | 860 | setFont(i-1); |
861 | printf("font %d\n", i-1); | 861 | printf("font %d\n", i-1); |
862 | return; | 862 | return; |
863 | } | 863 | } |
864 | } | 864 | } |
865 | } | 865 | } |
866 | int fsize = fonts.at(i)->getSize(); | 866 | int fsize = fonts.at(i)->getSize(); |
867 | printf("%d size=%d fsize=%d closest=%d\n", i, size, fsize, closest); | 867 | printf("%d size=%d fsize=%d closest=%d\n", i, size, fsize, closest); |
868 | if ((delta > 0 && fsize > size && fsize < closest) | 868 | if ((delta > 0 && fsize > size && fsize < closest) |
869 | || (delta < 0 && fsize < size && fsize > closest)) | 869 | || (delta < 0 && fsize < size && fsize > closest)) |
870 | { | 870 | { |
871 | closest = fsize; | 871 | closest = fsize; |
872 | closest_font = i; | 872 | closest_font = i; |
873 | } | 873 | } |
874 | } | 874 | } |
875 | if (closest_font >= 0) | 875 | if (closest_font >= 0) |
876 | { | 876 | { |
877 | printf("font closest %d (%d)\n", closest_font, closest); | 877 | printf("font closest %d (%d)\n", closest_font, closest); |
878 | setFont(closest_font); | 878 | setFont(closest_font); |
879 | } | 879 | } |
880 | } | 880 | } |
881 | 881 | ||
882 | int Konsole::findFont(QString name, int size, bool exactMatch) | 882 | int Konsole::findFont(QString name, int size, bool exactMatch) |
883 | { | 883 | { |
884 | for(uint i = 0; i < fonts.count(); i++) | 884 | for(uint i = 0; i < fonts.count(); i++) |
885 | { | 885 | { |
886 | if (fonts.at(i)->getName() == name | 886 | if (fonts.at(i)->getName() == name |
887 | && fonts.at(i)->getSize() == size) | 887 | && fonts.at(i)->getSize() == size) |
888 | { | 888 | { |
889 | return(i); | 889 | return(i); |
890 | } | 890 | } |
891 | } | 891 | } |
892 | if (exactMatch) | 892 | if (exactMatch) |
893 | { | 893 | { |
894 | return(-1); | 894 | return(-1); |
895 | } | 895 | } |
896 | for(uint i = 0; i < fonts.count(); i++) | 896 | for(uint i = 0; i < fonts.count(); i++) |
897 | { | 897 | { |
898 | if (fonts.at(i)->getSize() == size) | 898 | if (fonts.at(i)->getSize() == size) |
899 | { | 899 | { |
900 | return(i); | 900 | return(i); |
901 | } | 901 | } |
902 | } | 902 | } |
903 | return(-1); | 903 | return(-1); |
904 | } | 904 | } |
905 | 905 | ||
906 | void Konsole::setFont(int f) | 906 | void Konsole::setFont(int f) |
907 | { | 907 | { |
908 | VTFont* font = fonts.at(f); | 908 | VTFont* font = fonts.at(f); |
909 | if (font) | 909 | if (font) |
910 | { | 910 | { |
911 | TEWidget* te = getTe(); | 911 | TEWidget* te = getTe(); |
912 | if (te != 0) | 912 | if (te != 0) |
913 | { | 913 | { |
914 | te->setVTFont(font->getFont()); | 914 | te->setVTFont(font->getFont()); |
915 | } | 915 | } |
916 | cfont = f; | 916 | cfont = f; |
917 | 917 | ||
918 | int familyNum = font->getFamilyNum(); | 918 | int familyNum = font->getFamilyNum(); |
919 | int size = font->getSize(); | 919 | int size = font->getSize(); |
920 | printf("familyNum = %d size = %d count=%d\n", familyNum, size, | 920 | printf("familyNum = %d size = %d count=%d\n", familyNum, size, |
921 | fontList->count()); | 921 | fontList->count()); |
922 | for(int i = 0; i < (int)fontList->count(); i++) | 922 | for(int i = 0; i < (int)fontList->count(); i++) |
923 | { | 923 | { |
924 | fontList->setItemChecked(i + 1000, i == familyNum); | 924 | fontList->setItemChecked(i + 1000, i == familyNum); |
925 | } | 925 | } |
926 | for(int i = 0; i < (int)fonts.count(); i++) | 926 | for(int i = 0; i < (int)fonts.count(); i++) |
927 | { | 927 | { |
928 | fontList->setItemChecked(i, fonts.at(i)->getFamilyNum() == familyNum | 928 | fontList->setItemChecked(i, fonts.at(i)->getFamilyNum() == familyNum |
929 | && fonts.at(i)->getSize() == size); | 929 | && fonts.at(i)->getSize() == size); |
930 | } | 930 | } |
931 | Config cfg( "Konsole" ); | 931 | Config cfg( "Konsole" ); |
932 | cfg.setGroup("Font"); | 932 | cfg.setGroup("Font"); |
933 | QString ss = "Session"+ QString::number(tab->currentPageIndex()+1); | 933 | QString ss = "Session"+ QString::number(tab->currentPageIndex()+1); |
934 | if (tab->currentPageIndex() == 0) | 934 | if (tab->currentPageIndex() == 0) |
935 | { | 935 | { |
936 | cfg.writeEntry("FontName", fonts.at(cfont)->getFamily()); | 936 | cfg.writeEntry("FontName", fonts.at(cfont)->getFamily()); |
937 | cfg.writeEntry("FontSize", fonts.at(cfont)->getSize()); | 937 | cfg.writeEntry("FontSize", fonts.at(cfont)->getSize()); |
938 | } | 938 | } |
939 | cfg.writeEntry("FontName"+ss, fonts.at(cfont)->getFamily()); | 939 | cfg.writeEntry("FontName"+ss, fonts.at(cfont)->getFamily()); |
940 | cfg.writeEntry("FontSize"+ss, fonts.at(cfont)->getSize()); | 940 | cfg.writeEntry("FontSize"+ss, fonts.at(cfont)->getSize()); |
941 | } | 941 | } |
942 | } | 942 | } |
943 | 943 | ||
944 | #if 0 | 944 | #if 0 |
945 | void Konsole::fontChanged(int f) | 945 | void Konsole::fontChanged(int f) |
946 | { | 946 | { |
947 | VTFont* font = fonts.at(f); | 947 | VTFont* font = fonts.at(f); |
948 | if (font != 0) | 948 | if (font != 0) |
949 | { | 949 | { |
950 | for(uint i = 0; i < fonts.count(); i++) | 950 | for(uint i = 0; i < fonts.count(); i++) |
951 | { | 951 | { |
952 | fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE); | 952 | fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE); |
953 | } | 953 | } |
954 | 954 | ||
955 | cfont = f; | 955 | cfont = f; |
956 | 956 | ||
957 | TEWidget* te = getTe(); | 957 | TEWidget* te = getTe(); |
958 | if (te != 0) | 958 | if (te != 0) |
959 | { | 959 | { |
960 | te->setVTFont(font->getFont()); | 960 | te->setVTFont(font->getFont()); |
961 | } | 961 | } |
962 | } | 962 | } |
963 | } | 963 | } |
964 | #endif | 964 | #endif |
965 | 965 | ||
966 | 966 | ||
967 | void Konsole::enterCommand(int c) | 967 | void Konsole::enterCommand(int c) |
968 | { | 968 | { |
969 | TEWidget* te = getTe(); | 969 | TEWidget* te = getTe(); |
970 | if (te != 0) | 970 | if (te != 0) |
971 | { | 971 | { |
972 | if(!commonCombo->editable()) | 972 | if(!commonCombo->editable()) |
973 | { | 973 | { |
974 | QString text = commonCombo->text(c); //commonCmds[c]; | 974 | QString text = commonCombo->text(c); //commonCmds[c]; |
975 | te->emitText(text); | 975 | te->emitText(text); |
976 | } | 976 | } |
977 | else | 977 | else |
978 | { | 978 | { |
979 | changeCommand( commonCombo->text(c), c); | 979 | changeCommand( commonCombo->text(c), c); |
980 | } | 980 | } |
981 | } | 981 | } |
982 | } | 982 | } |
983 | 983 | ||
984 | void Konsole::hitEnter() | 984 | void Konsole::hitEnter() |
985 | { | 985 | { |
986 | TEWidget* te = getTe(); | 986 | TEWidget* te = getTe(); |
987 | if (te != 0) | 987 | if (te != 0) |
988 | { | 988 | { |
989 | te->emitText(QString("\r")); | 989 | te->emitText(QString("\r")); |
990 | } | 990 | } |
991 | } | 991 | } |
992 | 992 | ||
993 | void Konsole::hitSpace() | 993 | void Konsole::hitSpace() |
994 | { | 994 | { |
995 | TEWidget* te = getTe(); | 995 | TEWidget* te = getTe(); |
996 | if (te != 0) | 996 | if (te != 0) |
997 | { | 997 | { |
998 | te->emitText(QString(" ")); | 998 | te->emitText(QString(" ")); |
999 | } | 999 | } |
1000 | } | 1000 | } |
1001 | 1001 | ||
1002 | void Konsole::hitTab() | 1002 | void Konsole::hitTab() |
1003 | { | 1003 | { |
1004 | TEWidget* te = getTe(); | 1004 | TEWidget* te = getTe(); |
1005 | if (te != 0) | 1005 | if (te != 0) |
1006 | { | 1006 | { |
1007 | te->emitText(QString("\t")); | 1007 | te->emitText(QString("\t")); |
1008 | } | 1008 | } |
1009 | } | 1009 | } |
1010 | 1010 | ||
1011 | void Konsole::hitPaste() | 1011 | void Konsole::hitPaste() |
1012 | { | 1012 | { |
1013 | TEWidget* te = getTe(); | 1013 | TEWidget* te = getTe(); |
1014 | if (te != 0) | 1014 | if (te != 0) |
1015 | { | 1015 | { |
1016 | te->pasteClipboard(); | 1016 | te->pasteClipboard(); |
1017 | } | 1017 | } |
1018 | } | 1018 | } |
1019 | 1019 | ||
1020 | void Konsole::hitUp() | 1020 | void Konsole::hitUp() |
1021 | { | 1021 | { |
1022 | TEWidget* te = getTe(); | 1022 | TEWidget* te = getTe(); |
1023 | if (te != 0) | 1023 | if (te != 0) |
1024 | { | 1024 | { |
1025 | QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Up, 0, 0); | 1025 | QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Up, 0, 0); |
1026 | QApplication::sendEvent( te, &ke ); | 1026 | QApplication::sendEvent( te, &ke ); |
1027 | } | 1027 | } |
1028 | } | 1028 | } |
1029 | 1029 | ||
1030 | void Konsole::hitDown() | 1030 | void Konsole::hitDown() |
1031 | { | 1031 | { |
1032 | TEWidget* te = getTe(); | 1032 | TEWidget* te = getTe(); |
1033 | if (te != 0) | 1033 | if (te != 0) |
1034 | { | 1034 | { |
1035 | QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Down, 0, 0); | 1035 | QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Down, 0, 0); |
1036 | QApplication::sendEvent( te, &ke ); | 1036 | QApplication::sendEvent( te, &ke ); |
1037 | } | 1037 | } |
1038 | } | 1038 | } |
1039 | 1039 | ||
1040 | /** | 1040 | /** |
1041 | This function calculates the size of the external widget | 1041 | This function calculates the size of the external widget |
1042 | needed for the internal widget to be | 1042 | needed for the internal widget to be |
1043 | */ | 1043 | */ |
1044 | QSize Konsole::calcSize(int columns, int lines) | 1044 | QSize Konsole::calcSize(int columns, int lines) |
1045 | { | 1045 | { |
1046 | TEWidget* te = getTe(); | 1046 | TEWidget* te = getTe(); |
1047 | if (te != 0) | 1047 | if (te != 0) |
1048 | { | 1048 | { |
1049 | QSize size = te->calcSize(columns, lines); | 1049 | QSize size = te->calcSize(columns, lines); |
1050 | return size; | 1050 | return size; |