-rw-r--r-- | core/apps/embeddedkonsole/konsole.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/core/apps/embeddedkonsole/konsole.cpp b/core/apps/embeddedkonsole/konsole.cpp index 70acc42..9be4674 100644 --- a/core/apps/embeddedkonsole/konsole.cpp +++ b/core/apps/embeddedkonsole/konsole.cpp | |||
@@ -315,128 +315,129 @@ void Konsole::init(const char* _pgm, QStrList & _args) | |||
315 | QAction *a; | 315 | QAction *a; |
316 | 316 | ||
317 | // Button Commands | 317 | // Button Commands |
318 | a = new QAction( tr("New"), Resource::loadPixmap( "konsole" ), QString::null, 0, this, 0 ); | 318 | a = new QAction( tr("New"), Resource::loadPixmap( "konsole" ), QString::null, 0, this, 0 ); |
319 | connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); a->addTo( toolbar ); | 319 | connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); a->addTo( toolbar ); |
320 | a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 ); | 320 | a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 ); |
321 | connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolbar ); | 321 | connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolbar ); |
322 | a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 ); | 322 | a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 ); |
323 | connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolbar ); | 323 | connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolbar ); |
324 | a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 ); | 324 | a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 ); |
325 | connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolbar ); | 325 | connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolbar ); |
326 | a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 ); | 326 | a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 ); |
327 | connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar ); | 327 | connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar ); |
328 | a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 ); | 328 | a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 ); |
329 | connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar ); | 329 | connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar ); |
330 | a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); | 330 | a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); |
331 | connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); a->addTo( toolbar ); | 331 | connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); a->addTo( toolbar ); |
332 | /* | 332 | /* |
333 | a = new QAction( tr("Up"), Resource::loadPixmap( "up" ), QString::null, 0, this, 0 ); | 333 | a = new QAction( tr("Up"), Resource::loadPixmap( "up" ), QString::null, 0, this, 0 ); |
334 | connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar ); | 334 | connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar ); |
335 | a = new QAction( tr("Down"), Resource::loadPixmap( "down" ), QString::null, 0, this, 0 ); | 335 | a = new QAction( tr("Down"), Resource::loadPixmap( "down" ), QString::null, 0, this, 0 ); |
336 | connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar ); | 336 | connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar ); |
337 | */ | 337 | */ |
338 | 338 | ||
339 | secondToolBar = new QPEToolBar( this ); | 339 | secondToolBar = new QPEToolBar( this ); |
340 | secondToolBar->setHorizontalStretchable( TRUE ); | 340 | secondToolBar->setHorizontalStretchable( TRUE ); |
341 | 341 | ||
342 | commonCombo = new QComboBox( secondToolBar ); | 342 | commonCombo = new QComboBox( secondToolBar ); |
343 | commonCombo->setMaximumWidth(236); | 343 | commonCombo->setMaximumWidth(236); |
344 | 344 | ||
345 | editCommandListMenu->insertItem( tr( "Quick Edit" ) ); | 345 | editCommandListMenu->insertItem( tr( "Quick Edit" ) ); |
346 | if( listHidden) { | 346 | if( listHidden) { |
347 | secondToolBar->hide(); | 347 | secondToolBar->hide(); |
348 | editCommandListMenu->setItemEnabled(-23 ,FALSE); | 348 | editCommandListMenu->setItemEnabled(-23 ,FALSE); |
349 | } | 349 | } |
350 | editCommandListMenu->insertItem(tr( "Edit" ) ); | 350 | editCommandListMenu->insertItem(tr( "Edit" ) ); |
351 | 351 | ||
352 | cfg.setGroup("Commands"); | 352 | cfg.setGroup("Commands"); |
353 | commonCombo->setInsertionPolicy(QComboBox::AtCurrent); | 353 | commonCombo->setInsertionPolicy(QComboBox::AtCurrent); |
354 | 354 | ||
355 | initCommandList(); | 355 | initCommandList(); |
356 | // for (int i = 0; commonCmds[i] != NULL; i++) { | 356 | // for (int i = 0; commonCmds[i] != NULL; i++) { |
357 | // commonCombo->insertItem( commonCmds[i], i ); | 357 | // commonCombo->insertItem( commonCmds[i], i ); |
358 | // tmp = cfg.readEntry( QString::number(i),""); | 358 | // tmp = cfg.readEntry( QString::number(i),""); |
359 | // if(tmp != "") | 359 | // if(tmp != "") |
360 | // commonCombo->changeItem( tmp,i ); | 360 | // commonCombo->changeItem( tmp,i ); |
361 | // } | 361 | // } |
362 | 362 | ||
363 | connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) )); | 363 | connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) )); |
364 | 364 | ||
365 | scrollMenu->insertItem(tr( "None" )); | 365 | scrollMenu->insertItem(tr( "None" )); |
366 | scrollMenu->insertItem(tr( "Left" )); | 366 | scrollMenu->insertItem(tr( "Left" )); |
367 | scrollMenu->insertItem(tr( "Right" )); | 367 | scrollMenu->insertItem(tr( "Right" )); |
368 | // scrollMenu->insertSeparator(4); | 368 | // scrollMenu->insertSeparator(4); |
369 | // scrollMenu->insertItem(tr( "Horizontal" )); | 369 | // scrollMenu->insertItem(tr( "Horizontal" )); |
370 | 370 | ||
371 | configMenu->insertItem(tr( "ScrollBar" ),scrollMenu); | 371 | configMenu->insertItem(tr( "ScrollBar" ),scrollMenu); |
372 | 372 | ||
373 | int jut = configMenu->insertItem(tr( "Wrap" )); | 373 | int jut = configMenu->insertItem(tr( "Wrap" )); |
374 | cfg.setGroup("ScrollBar"); | 374 | cfg.setGroup("ScrollBar"); |
375 | configMenu->setItemChecked(jut, cfg.readBoolEntry("HorzScroll",0)); | 375 | configMenu->setItemChecked(jut, cfg.readBoolEntry("HorzScroll",0)); |
376 | 376 | ||
377 | jut = configMenu->insertItem(tr( "Use Beep" )); | 377 | jut = configMenu->insertItem(tr( "Use Beep" )); |
378 | cfg.setGroup("Menubar"); | 378 | cfg.setGroup("Menubar"); |
379 | |||
379 | configMenu->setItemChecked(jut, cfg.readBoolEntry("useBeep",0)); | 380 | configMenu->setItemChecked(jut, cfg.readBoolEntry("useBeep",0)); |
380 | 381 | ||
381 | 382 | ||
382 | //scrollMenuSelected(-29); | 383 | //scrollMenuSelected(-29); |
383 | // cfg.setGroup("ScrollBar"); | 384 | // cfg.setGroup("ScrollBar"); |
384 | // if(cfg.readBoolEntry("HorzScroll",0)) { | 385 | // if(cfg.readBoolEntry("HorzScroll",0)) { |
385 | // if(cfg.readNumEntry("Position",2) == 0) | 386 | // if(cfg.readNumEntry("Position",2) == 0) |
386 | // te->setScrollbarLocation(1); | 387 | // te->setScrollbarLocation(1); |
387 | // else | 388 | // else |
388 | // te->setScrollbarLocation(0); | 389 | // te->setScrollbarLocation(0); |
389 | // te->setScrollbarLocation( cfg.readNumEntry("Position",2)); | 390 | // te->setScrollbarLocation( cfg.readNumEntry("Position",2)); |
390 | // te->setWrapAt(120); | 391 | // te->setWrapAt(120); |
391 | // } | 392 | // } |
392 | // create applications ///////////////////////////////////////////////////// | 393 | // create applications ///////////////////////////////////////////////////// |
393 | setCentralWidget(tab); | 394 | setCentralWidget(tab); |
394 | 395 | ||
395 | // load keymaps //////////////////////////////////////////////////////////// | 396 | // load keymaps //////////////////////////////////////////////////////////// |
396 | KeyTrans::loadAll(); | 397 | KeyTrans::loadAll(); |
397 | for (int i = 0; i < KeyTrans::count(); i++) | 398 | for (int i = 0; i < KeyTrans::count(); i++) |
398 | { KeyTrans* s = KeyTrans::find(i); | 399 | { KeyTrans* s = KeyTrans::find(i); |
399 | assert( s ); | 400 | assert( s ); |
400 | } | 401 | } |
401 | 402 | ||
402 | se_pgm = _pgm; | 403 | se_pgm = _pgm; |
403 | se_args = _args; | 404 | se_args = _args; |
404 | se_args.prepend("--login"); | 405 | se_args.prepend("--login"); |
405 | parseCommandLine(); | 406 | parseCommandLine(); |
406 | // read and apply default values /////////////////////////////////////////// | 407 | // read and apply default values /////////////////////////////////////////// |
407 | resize(321, 321); // Dummy. | 408 | resize(321, 321); // Dummy. |
408 | QSize currentSize = size(); | 409 | QSize currentSize = size(); |
409 | if (currentSize != size()) | 410 | if (currentSize != size()) |
410 | defaultSize = size(); | 411 | defaultSize = size(); |
411 | } | 412 | } |
412 | 413 | ||
413 | void Konsole::show() | 414 | void Konsole::show() |
414 | { | 415 | { |
415 | if ( !nsessions ) { | 416 | if ( !nsessions ) { |
416 | newSession(); | 417 | newSession(); |
417 | } | 418 | } |
418 | QMainWindow::show(); | 419 | QMainWindow::show(); |
419 | 420 | ||
420 | } | 421 | } |
421 | 422 | ||
422 | void Konsole::initSession(const char*, QStrList &) | 423 | void Konsole::initSession(const char*, QStrList &) |
423 | { | 424 | { |
424 | QMainWindow::show(); | 425 | QMainWindow::show(); |
425 | } | 426 | } |
426 | 427 | ||
427 | Konsole::~Konsole() | 428 | Konsole::~Konsole() |
428 | { | 429 | { |
429 | while (nsessions > 0) { | 430 | while (nsessions > 0) { |
430 | doneSession(getTe()->currentSession, 0); | 431 | doneSession(getTe()->currentSession, 0); |
431 | } | 432 | } |
432 | 433 | ||
433 | Config cfg("Konsole"); | 434 | Config cfg("Konsole"); |
434 | cfg.setGroup("Konsole"); | 435 | cfg.setGroup("Konsole"); |
435 | cfg.writeEntry("FontID", cfont); | 436 | cfg.writeEntry("FontID", cfont); |
436 | } | 437 | } |
437 | 438 | ||
438 | void Konsole::fontChanged(int f) | 439 | void Konsole::fontChanged(int f) |
439 | { | 440 | { |
440 | VTFont* font = fonts.at(f); | 441 | VTFont* font = fonts.at(f); |
441 | if (font != 0) { | 442 | if (font != 0) { |
442 | for(uint i = 0; i < fonts.count(); i++) { | 443 | for(uint i = 0; i < fonts.count(); i++) { |
@@ -554,128 +555,134 @@ void Konsole::setColLin(int columns, int lines) | |||
554 | } | 555 | } |
555 | } | 556 | } |
556 | 557 | ||
557 | /* | 558 | /* |
558 | void Konsole::setFont(int fontno) | 559 | void Konsole::setFont(int fontno) |
559 | { | 560 | { |
560 | QFont f; | 561 | QFont f; |
561 | if (fontno == 0) | 562 | if (fontno == 0) |
562 | f = defaultFont = QFont( "Helvetica", 12 ); | 563 | f = defaultFont = QFont( "Helvetica", 12 ); |
563 | else | 564 | else |
564 | if (fonts[fontno][0] == '-') | 565 | if (fonts[fontno][0] == '-') |
565 | f.setRawName( fonts[fontno] ); | 566 | f.setRawName( fonts[fontno] ); |
566 | else | 567 | else |
567 | { | 568 | { |
568 | f.setFamily(fonts[fontno]); | 569 | f.setFamily(fonts[fontno]); |
569 | f.setRawMode( TRUE ); | 570 | f.setRawMode( TRUE ); |
570 | } | 571 | } |
571 | if ( !f.exactMatch() && fontno != 0) | 572 | if ( !f.exactMatch() && fontno != 0) |
572 | { | 573 | { |
573 | QString msg = i18n("Font `%1' not found.\nCheck README.linux.console for help.").arg(fonts[fontno]); | 574 | QString msg = i18n("Font `%1' not found.\nCheck README.linux.console for help.").arg(fonts[fontno]); |
574 | QMessageBox(this, msg); | 575 | QMessageBox(this, msg); |
575 | return; | 576 | return; |
576 | } | 577 | } |
577 | if (se) se->setFontNo(fontno); | 578 | if (se) se->setFontNo(fontno); |
578 | te->setVTFont(f); | 579 | te->setVTFont(f); |
579 | n_font = fontno; | 580 | n_font = fontno; |
580 | } | 581 | } |
581 | */ | 582 | */ |
582 | 583 | ||
583 | // --| color selection |------------------------------------------------------- | 584 | // --| color selection |------------------------------------------------------- |
584 | 585 | ||
585 | void Konsole::changeColumns(int columns) | 586 | void Konsole::changeColumns(int columns) |
586 | { | 587 | { |
587 | qDebug("change columns"); | 588 | qDebug("change columns"); |
588 | TEWidget* te = getTe(); | 589 | TEWidget* te = getTe(); |
589 | if (te != 0) { | 590 | if (te != 0) { |
590 | setColLin(columns,te->Lines()); | 591 | setColLin(columns,te->Lines()); |
591 | te->update(); | 592 | te->update(); |
592 | } | 593 | } |
593 | } | 594 | } |
594 | 595 | ||
595 | //FIXME: If a child dies during session swap, | 596 | //FIXME: If a child dies during session swap, |
596 | // this routine might be called before | 597 | // this routine might be called before |
597 | // session swap is completed. | 598 | // session swap is completed. |
598 | 599 | ||
599 | void Konsole::doneSession(TESession*, int ) | 600 | void Konsole::doneSession(TESession*, int ) |
600 | { | 601 | { |
601 | TEWidget *te = getTe(); | 602 | TEWidget *te = getTe(); |
602 | if (te != 0) { | 603 | if (te != 0) { |
603 | te->currentSession->setConnect(FALSE); | 604 | te->currentSession->setConnect(FALSE); |
604 | tab->removeTab(te); | 605 | tab->removeTab(te); |
605 | delete te->currentSession; | 606 | delete te->currentSession; |
606 | delete te; | 607 | delete te; |
607 | nsessions--; | 608 | nsessions--; |
608 | } | 609 | } |
609 | 610 | ||
610 | if (nsessions == 0) { | 611 | if (nsessions == 0) { |
611 | close(); | 612 | close(); |
612 | } | 613 | } |
613 | } | 614 | } |
614 | 615 | ||
615 | void Konsole::newSession() { | 616 | void Konsole::newSession() { |
616 | if(nsessions < 15) { // seems to be something weird about 16 tabs on the Zaurus.... memory? | 617 | if(nsessions < 15) { // seems to be something weird about 16 tabs on the Zaurus.... memory? |
617 | TEWidget* te = new TEWidget(tab); | 618 | TEWidget* te = new TEWidget(tab); |
619 | if(nsessions == 0) { //set this the first time only | ||
620 | Config c("Konsole"); | ||
621 | c.setGroup("Menubar"); | ||
622 | te->useBeep=c.readBoolEntry("useBeep",0); | ||
623 | } | ||
624 | |||
618 | // te->setBackgroundMode(PaletteBase); //we want transparent!! | 625 | // te->setBackgroundMode(PaletteBase); //we want transparent!! |
619 | te->setVTFont(fonts.at(cfont)->getFont()); | 626 | te->setVTFont(fonts.at(cfont)->getFont()); |
620 | tab->addTab(te); | 627 | tab->addTab(te); |
621 | TESession* se = new TESession(this, te, se_pgm, se_args, "xterm"); | 628 | TESession* se = new TESession(this, te, se_pgm, se_args, "xterm"); |
622 | te->currentSession = se; | 629 | te->currentSession = se; |
623 | connect( se, SIGNAL(done(TESession*,int)), this, SLOT(doneSession(TESession*,int)) ); | 630 | connect( se, SIGNAL(done(TESession*,int)), this, SLOT(doneSession(TESession*,int)) ); |
624 | se->run(); | 631 | se->run(); |
625 | se->setConnect(TRUE); | 632 | se->setConnect(TRUE); |
626 | se->setHistory(b_scroll); | 633 | se->setHistory(b_scroll); |
627 | tab->setCurrentPage(nsessions); | 634 | tab->setCurrentPage(nsessions); |
628 | nsessions++; | 635 | nsessions++; |
629 | doWrap(); | 636 | doWrap(); |
630 | setColor(); | 637 | setColor(); |
631 | } | 638 | } |
632 | } | 639 | } |
633 | 640 | ||
634 | TEWidget* Konsole::getTe() { | 641 | TEWidget* Konsole::getTe() { |
635 | if (nsessions) { | 642 | if (nsessions) { |
636 | return (TEWidget *) tab->currentPage(); | 643 | return (TEWidget *) tab->currentPage(); |
637 | } else { | 644 | } else { |
638 | return 0; | 645 | return 0; |
639 | } | 646 | } |
640 | } | 647 | } |
641 | 648 | ||
642 | void Konsole::switchSession(QWidget* w) { | 649 | void Konsole::switchSession(QWidget* w) { |
643 | TEWidget* te = (TEWidget *) w; | 650 | TEWidget* te = (TEWidget *) w; |
644 | 651 | ||
645 | QFont teFnt = te->getVTFont(); | 652 | QFont teFnt = te->getVTFont(); |
646 | for(uint i = 0; i < fonts.count(); i++) { | 653 | for(uint i = 0; i < fonts.count(); i++) { |
647 | VTFont *fnt = fonts.at(i); | 654 | VTFont *fnt = fonts.at(i); |
648 | bool cf = fnt->getFont() == teFnt; | 655 | bool cf = fnt->getFont() == teFnt; |
649 | fontList->setItemChecked(i, cf); | 656 | fontList->setItemChecked(i, cf); |
650 | if (cf) { | 657 | if (cf) { |
651 | cfont = i; | 658 | cfont = i; |
652 | } | 659 | } |
653 | } | 660 | } |
654 | } | 661 | } |
655 | 662 | ||
656 | void Konsole::colorMenuIsSelected(int iD) { | 663 | void Konsole::colorMenuIsSelected(int iD) { |
657 | fromMenu = TRUE; | 664 | fromMenu = TRUE; |
658 | colorMenuSelected(iD); | 665 | colorMenuSelected(iD); |
659 | } | 666 | } |
660 | 667 | ||
661 | /// ------------------------------- some new stuff by L.J. Potter | 668 | /// ------------------------------- some new stuff by L.J. Potter |
662 | void Konsole::colorMenuSelected(int iD) | 669 | void Konsole::colorMenuSelected(int iD) |
663 | { // this is NOT pretty, elegant or anything else besides functional | 670 | { // this is NOT pretty, elegant or anything else besides functional |
664 | // QString temp; | 671 | // QString temp; |
665 | // qDebug( temp.sprintf("colormenu %d", iD)); | 672 | // qDebug( temp.sprintf("colormenu %d", iD)); |
666 | TEWidget* te = getTe(); | 673 | TEWidget* te = getTe(); |
667 | Config cfg("Konsole"); | 674 | Config cfg("Konsole"); |
668 | cfg.setGroup("Colors"); | 675 | cfg.setGroup("Colors"); |
669 | // QColor foreground; | 676 | // QColor foreground; |
670 | // QColor background; | 677 | // QColor background; |
671 | colorMenu->setItemChecked(lastSelectedMenu,FALSE); | 678 | colorMenu->setItemChecked(lastSelectedMenu,FALSE); |
672 | ColorEntry m_table[TABLE_COLORS]; | 679 | ColorEntry m_table[TABLE_COLORS]; |
673 | const ColorEntry * defaultCt=te->getdefaultColorTable(); | 680 | const ColorEntry * defaultCt=te->getdefaultColorTable(); |
674 | /////////// fore back | 681 | /////////// fore back |
675 | int i; | 682 | int i; |
676 | if(iD==-9) { // default default | 683 | if(iD==-9) { // default default |
677 | for (i = 0; i < TABLE_COLORS; i++) { | 684 | for (i = 0; i < TABLE_COLORS; i++) { |
678 | m_table[i].color = defaultCt[i].color; | 685 | m_table[i].color = defaultCt[i].color; |
679 | if(i==1 || i == 11) | 686 | if(i==1 || i == 11) |
680 | m_table[i].transparent=1; | 687 | m_table[i].transparent=1; |
681 | cfg.writeEntry("Schema","9"); | 688 | cfg.writeEntry("Schema","9"); |