summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-04-28 15:08:04 (UTC)
committer llornkcor <llornkcor>2002-04-28 15:08:04 (UTC)
commitd9a38221ea876cae8ef8b015968e14af75e202bb (patch) (unidiff)
tree624d057fa2ee702140aee1ef061713af878d92b1
parentc55ffe32ced1ecbac991ca2e85c6993cf8a04ee0 (diff)
downloadopie-d9a38221ea876cae8ef8b015968e14af75e202bb.zip
opie-d9a38221ea876cae8ef8b015968e14af75e202bb.tar.gz
opie-d9a38221ea876cae8ef8b015968e14af75e202bb.tar.bz2
harcoded Shift & Key_Tab to emit a '\' character
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/embeddedkonsole/TEWidget.cpp8
-rw-r--r--core/apps/embeddedkonsole/konsole.cpp3
2 files changed, 8 insertions, 3 deletions
diff --git a/core/apps/embeddedkonsole/TEWidget.cpp b/core/apps/embeddedkonsole/TEWidget.cpp
index dab0ea3..350ab3a 100644
--- a/core/apps/embeddedkonsole/TEWidget.cpp
+++ b/core/apps/embeddedkonsole/TEWidget.cpp
@@ -609,653 +609,657 @@ void TEWidget::setScrollbarLocation(int loc)
609 propagateSize(); 609 propagateSize();
610 update(); 610 update();
611} 611}
612 612
613/* ------------------------------------------------------------------------- */ 613/* ------------------------------------------------------------------------- */
614/* */ 614/* */
615/* Mouse */ 615/* Mouse */
616/* */ 616/* */
617/* ------------------------------------------------------------------------- */ 617/* ------------------------------------------------------------------------- */
618 618
619/*! 619/*!
620 Three different operations can be performed using the mouse, and the 620 Three different operations can be performed using the mouse, and the
621 routines in this section serve all of them: 621 routines in this section serve all of them:
622 622
623 1) The press/release events are exposed to the application 623 1) The press/release events are exposed to the application
624 2) Marking (press and move left button) and Pasting (press middle button) 624 2) Marking (press and move left button) and Pasting (press middle button)
625 3) The right mouse button is used from the configuration menu 625 3) The right mouse button is used from the configuration menu
626 626
627 NOTE: During the marking process we attempt to keep the cursor within 627 NOTE: During the marking process we attempt to keep the cursor within
628 the bounds of the text as being displayed by setting the mouse position 628 the bounds of the text as being displayed by setting the mouse position
629 whenever the mouse has left the text area. 629 whenever the mouse has left the text area.
630 630
631 Two reasons to do so: 631 Two reasons to do so:
632 1) QT does not allow the `grabMouse' to confine-to the TEWidget. 632 1) QT does not allow the `grabMouse' to confine-to the TEWidget.
633 Thus a `XGrapPointer' would have to be used instead. 633 Thus a `XGrapPointer' would have to be used instead.
634 2) Even if so, this would not help too much, since the text area 634 2) Even if so, this would not help too much, since the text area
635 of the TEWidget is normally not identical with it's bounds. 635 of the TEWidget is normally not identical with it's bounds.
636 636
637 The disadvantage of the current handling is, that the mouse can visibly 637 The disadvantage of the current handling is, that the mouse can visibly
638 leave the bounds of the widget and is then moved back. Because of the 638 leave the bounds of the widget and is then moved back. Because of the
639 current construction, and the reasons mentioned above, we cannot do better 639 current construction, and the reasons mentioned above, we cannot do better
640 without changing the overall construction. 640 without changing the overall construction.
641*/ 641*/
642 642
643/*! 643/*!
644*/ 644*/
645 645
646void TEWidget::mousePressEvent(QMouseEvent* ev) 646void TEWidget::mousePressEvent(QMouseEvent* ev)
647{ 647{
648//printf("press [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button()); 648//printf("press [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button());
649 if ( !contentsRect().contains(ev->pos()) ) return; 649 if ( !contentsRect().contains(ev->pos()) ) return;
650 QPoint tL = contentsRect().topLeft(); 650 QPoint tL = contentsRect().topLeft();
651 int tLx = tL.x(); 651 int tLx = tL.x();
652 int tLy = tL.y(); 652 int tLy = tL.y();
653 653
654 word_selection_mode = FALSE; 654 word_selection_mode = FALSE;
655 655
656//printf("press top left [%d,%d] by=%d\n",tLx,tLy, bY); 656//printf("press top left [%d,%d] by=%d\n",tLx,tLy, bY);
657 if ( ev->button() == LeftButton) 657 if ( ev->button() == LeftButton)
658 { 658 {
659 QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); 659 QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h);
660 660
661 if ( ev->state() & ControlButton ) preserve_line_breaks = FALSE ; 661 if ( ev->state() & ControlButton ) preserve_line_breaks = FALSE ;
662 662
663 if (mouse_marks || (ev->state() & ShiftButton)) 663 if (mouse_marks || (ev->state() & ShiftButton))
664 { 664 {
665 emit clearSelectionSignal(); 665 emit clearSelectionSignal();
666 iPntSel = pntSel = pos; 666 iPntSel = pntSel = pos;
667 actSel = 1; // left mouse button pressed but nothing selected yet. 667 actSel = 1; // left mouse button pressed but nothing selected yet.
668 grabMouse( /*crossCursor*/ ); // handle with care! 668 grabMouse( /*crossCursor*/ ); // handle with care!
669 } 669 }
670 else 670 else
671 { 671 {
672 emit mouseSignal( 0, pos.x() + 1, pos.y() + 1 ); // left button 672 emit mouseSignal( 0, pos.x() + 1, pos.y() + 1 ); // left button
673 } 673 }
674 } 674 }
675 if ( ev->button() == MidButton ) 675 if ( ev->button() == MidButton )
676 { 676 {
677 emitSelection(); 677 emitSelection();
678 } 678 }
679 if ( ev->button() == RightButton ) // Configure 679 if ( ev->button() == RightButton ) // Configure
680 { 680 {
681 emit configureRequest( this, ev->state()&(ShiftButton|ControlButton), ev->x(), ev->y() ); 681 emit configureRequest( this, ev->state()&(ShiftButton|ControlButton), ev->x(), ev->y() );
682 } 682 }
683} 683}
684 684
685void TEWidget::mouseMoveEvent(QMouseEvent* ev) 685void TEWidget::mouseMoveEvent(QMouseEvent* ev)
686{ 686{
687 // for auto-hiding the cursor, we need mouseTracking 687 // for auto-hiding the cursor, we need mouseTracking
688 if (ev->state() == NoButton ) return; 688 if (ev->state() == NoButton ) return;
689 689
690 if (actSel == 0) return; 690 if (actSel == 0) return;
691 691
692 // don't extend selection while pasting 692 // don't extend selection while pasting
693 if (ev->state() & MidButton) return; 693 if (ev->state() & MidButton) return;
694 694
695 //if ( !contentsRect().contains(ev->pos()) ) return; 695 //if ( !contentsRect().contains(ev->pos()) ) return;
696 QPoint tL = contentsRect().topLeft(); 696 QPoint tL = contentsRect().topLeft();
697 int tLx = tL.x(); 697 int tLx = tL.x();
698 int tLy = tL.y(); 698 int tLy = tL.y();
699 int scroll = scrollbar->value(); 699 int scroll = scrollbar->value();
700 700
701 // we're in the process of moving the mouse with the left button pressed 701 // we're in the process of moving the mouse with the left button pressed
702 // the mouse cursor will kept catched within the bounds of the text in 702 // the mouse cursor will kept catched within the bounds of the text in
703 // this widget. 703 // this widget.
704 704
705 // Adjust position within text area bounds. See FIXME above. 705 // Adjust position within text area bounds. See FIXME above.
706 QPoint pos = ev->pos(); 706 QPoint pos = ev->pos();
707 if ( pos.x() < tLx+blX ) pos.setX( tLx+blX ); 707 if ( pos.x() < tLx+blX ) pos.setX( tLx+blX );
708 if ( pos.x() > tLx+blX+columns*font_w-1 ) pos.setX( tLx+blX+columns*font_w ); 708 if ( pos.x() > tLx+blX+columns*font_w-1 ) pos.setX( tLx+blX+columns*font_w );
709 if ( pos.y() < tLy+bY ) pos.setY( tLy+bY ); 709 if ( pos.y() < tLy+bY ) pos.setY( tLy+bY );
710 if ( pos.y() > tLy+bY+lines*font_h-1 ) pos.setY( tLy+bY+lines*font_h-1 ); 710 if ( pos.y() > tLy+bY+lines*font_h-1 ) pos.setY( tLy+bY+lines*font_h-1 );
711 // check if we produce a mouse move event by this 711 // check if we produce a mouse move event by this
712 if ( pos != ev->pos() ) cursor().setPos(mapToGlobal(pos)); 712 if ( pos != ev->pos() ) cursor().setPos(mapToGlobal(pos));
713 713
714 if ( pos.y() == tLy+bY+lines*font_h-1 ) 714 if ( pos.y() == tLy+bY+lines*font_h-1 )
715 { 715 {
716 scrollbar->setValue(scrollbar->value()+yMouseScroll); // scrollforward 716 scrollbar->setValue(scrollbar->value()+yMouseScroll); // scrollforward
717 } 717 }
718 if ( pos.y() == tLy+bY ) 718 if ( pos.y() == tLy+bY )
719 { 719 {
720 scrollbar->setValue(scrollbar->value()-yMouseScroll); // scrollback 720 scrollbar->setValue(scrollbar->value()-yMouseScroll); // scrollback
721 } 721 }
722 722
723 QPoint here = QPoint((pos.x()-tLx-blX)/font_w,(pos.y()-tLy-bY)/font_h); 723 QPoint here = QPoint((pos.x()-tLx-blX)/font_w,(pos.y()-tLy-bY)/font_h);
724 QPoint ohere; 724 QPoint ohere;
725 bool swapping = FALSE; 725 bool swapping = FALSE;
726 726
727 if ( word_selection_mode ) 727 if ( word_selection_mode )
728 { 728 {
729 // Extend to word boundaries 729 // Extend to word boundaries
730 int i; 730 int i;
731 int selClass; 731 int selClass;
732 732
733 bool left_not_right = ( here.y() < iPntSel.y() || 733 bool left_not_right = ( here.y() < iPntSel.y() ||
734 here.y() == iPntSel.y() && here.x() < iPntSel.x() ); 734 here.y() == iPntSel.y() && here.x() < iPntSel.x() );
735 bool old_left_not_right = ( pntSel.y() < iPntSel.y() || 735 bool old_left_not_right = ( pntSel.y() < iPntSel.y() ||
736 pntSel.y() == iPntSel.y() && pntSel.x() < iPntSel.x() ); 736 pntSel.y() == iPntSel.y() && pntSel.x() < iPntSel.x() );
737 swapping = left_not_right != old_left_not_right; 737 swapping = left_not_right != old_left_not_right;
738 738
739 // Find left (left_not_right ? from here : from start) 739 // Find left (left_not_right ? from here : from start)
740 QPoint left = left_not_right ? here : iPntSel; 740 QPoint left = left_not_right ? here : iPntSel;
741 i = loc(left.x(),left.y()); 741 i = loc(left.x(),left.y());
742 selClass = charClass(image[i].c); 742 selClass = charClass(image[i].c);
743 while ( left.x() > 0 && charClass(image[i-1].c) == selClass ) 743 while ( left.x() > 0 && charClass(image[i-1].c) == selClass )
744 { i--; left.rx()--; } 744 { i--; left.rx()--; }
745 745
746 // Find left (left_not_right ? from start : from here) 746 // Find left (left_not_right ? from start : from here)
747 QPoint right = left_not_right ? iPntSel : here; 747 QPoint right = left_not_right ? iPntSel : here;
748 i = loc(right.x(),right.y()); 748 i = loc(right.x(),right.y());
749 selClass = charClass(image[i].c); 749 selClass = charClass(image[i].c);
750 while ( right.x() < columns-1 && charClass(image[i+1].c) == selClass ) 750 while ( right.x() < columns-1 && charClass(image[i+1].c) == selClass )
751 { i++; right.rx()++; } 751 { i++; right.rx()++; }
752 752
753 // Pick which is start (ohere) and which is extension (here) 753 // Pick which is start (ohere) and which is extension (here)
754 if ( left_not_right ) 754 if ( left_not_right )
755 { 755 {
756 here = left; ohere = right; 756 here = left; ohere = right;
757 } 757 }
758 else 758 else
759 { 759 {
760 here = right; ohere = left; 760 here = right; ohere = left;
761 } 761 }
762 } 762 }
763 763
764 if (here == pntSel && scroll == scrollbar->value()) return; // not moved 764 if (here == pntSel && scroll == scrollbar->value()) return; // not moved
765 765
766 if ( word_selection_mode ) { 766 if ( word_selection_mode ) {
767 if ( actSel < 2 || swapping ) { 767 if ( actSel < 2 || swapping ) {
768 emit beginSelectionSignal( ohere.x(), ohere.y() ); 768 emit beginSelectionSignal( ohere.x(), ohere.y() );
769 } 769 }
770 } else if ( actSel < 2 ) { 770 } else if ( actSel < 2 ) {
771 emit beginSelectionSignal( pntSel.x(), pntSel.y() ); 771 emit beginSelectionSignal( pntSel.x(), pntSel.y() );
772 } 772 }
773 773
774 actSel = 2; // within selection 774 actSel = 2; // within selection
775 pntSel = here; 775 pntSel = here;
776 emit extendSelectionSignal( here.x(), here.y() ); 776 emit extendSelectionSignal( here.x(), here.y() );
777} 777}
778 778
779void TEWidget::mouseReleaseEvent(QMouseEvent* ev) 779void TEWidget::mouseReleaseEvent(QMouseEvent* ev)
780{ 780{
781//printf("release [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button()); 781//printf("release [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button());
782 if ( ev->button() == LeftButton) 782 if ( ev->button() == LeftButton)
783 { 783 {
784 if ( actSel > 1 ) emit endSelectionSignal(preserve_line_breaks); 784 if ( actSel > 1 ) emit endSelectionSignal(preserve_line_breaks);
785 preserve_line_breaks = TRUE; 785 preserve_line_breaks = TRUE;
786 actSel = 0; 786 actSel = 0;
787 787
788 //FIXME: emits a release event even if the mouse is 788 //FIXME: emits a release event even if the mouse is
789 // outside the range. The procedure used in `mouseMoveEvent' 789 // outside the range. The procedure used in `mouseMoveEvent'
790 // applies here, too. 790 // applies here, too.
791 791
792 QPoint tL = contentsRect().topLeft(); 792 QPoint tL = contentsRect().topLeft();
793 int tLx = tL.x(); 793 int tLx = tL.x();
794 int tLy = tL.y(); 794 int tLy = tL.y();
795 795
796 if (!mouse_marks && !(ev->state() & ShiftButton)) 796 if (!mouse_marks && !(ev->state() & ShiftButton))
797 emit mouseSignal( 3, // release 797 emit mouseSignal( 3, // release
798 (ev->x()-tLx-blX)/font_w + 1, 798 (ev->x()-tLx-blX)/font_w + 1,
799 (ev->y()-tLy-bY)/font_h + 1 ); 799 (ev->y()-tLy-bY)/font_h + 1 );
800 releaseMouse(); 800 releaseMouse();
801 } 801 }
802} 802}
803 803
804void TEWidget::mouseDoubleClickEvent(QMouseEvent* ev) 804void TEWidget::mouseDoubleClickEvent(QMouseEvent* ev)
805{ 805{
806 if ( ev->button() != LeftButton) return; 806 if ( ev->button() != LeftButton) return;
807 807
808 QPoint tL = contentsRect().topLeft(); 808 QPoint tL = contentsRect().topLeft();
809 int tLx = tL.x(); 809 int tLx = tL.x();
810 int tLy = tL.y(); 810 int tLy = tL.y();
811 QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); 811 QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h);
812 812
813 // pass on double click as two clicks. 813 // pass on double click as two clicks.
814 if (!mouse_marks && !(ev->state() & ShiftButton)) 814 if (!mouse_marks && !(ev->state() & ShiftButton))
815 { 815 {
816 emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button 816 emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button
817 emit mouseSignal( 3, pos.x()+1, pos.y()+1 ); // release 817 emit mouseSignal( 3, pos.x()+1, pos.y()+1 ); // release
818 emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button 818 emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button
819 return; 819 return;
820 } 820 }
821 821
822 822
823 emit clearSelectionSignal(); 823 emit clearSelectionSignal();
824 QPoint bgnSel = pos; 824 QPoint bgnSel = pos;
825 QPoint endSel = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); 825 QPoint endSel = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h);
826 int i = loc(bgnSel.x(),bgnSel.y()); 826 int i = loc(bgnSel.x(),bgnSel.y());
827 iPntSel = bgnSel; 827 iPntSel = bgnSel;
828 828
829 word_selection_mode = TRUE; 829 word_selection_mode = TRUE;
830 830
831 // find word boundaries... 831 // find word boundaries...
832 int selClass = charClass(image[i].c); 832 int selClass = charClass(image[i].c);
833 { 833 {
834 // set the start... 834 // set the start...
835 int x = bgnSel.x(); 835 int x = bgnSel.x();
836 while ( x > 0 && charClass(image[i-1].c) == selClass ) 836 while ( x > 0 && charClass(image[i-1].c) == selClass )
837 { i--; x--; } 837 { i--; x--; }
838 bgnSel.setX(x); 838 bgnSel.setX(x);
839 emit beginSelectionSignal( bgnSel.x(), bgnSel.y() ); 839 emit beginSelectionSignal( bgnSel.x(), bgnSel.y() );
840 840
841 // set the end... 841 // set the end...
842 i = loc( endSel.x(), endSel.y() ); 842 i = loc( endSel.x(), endSel.y() );
843 x = endSel.x(); 843 x = endSel.x();
844 while( x < columns-1 && charClass(image[i+1].c) == selClass ) 844 while( x < columns-1 && charClass(image[i+1].c) == selClass )
845 { i++; x++ ; } 845 { i++; x++ ; }
846 endSel.setX(x); 846 endSel.setX(x);
847 actSel = 2; // within selection 847 actSel = 2; // within selection
848 emit extendSelectionSignal( endSel.x(), endSel.y() ); 848 emit extendSelectionSignal( endSel.x(), endSel.y() );
849 emit endSelectionSignal(preserve_line_breaks); 849 emit endSelectionSignal(preserve_line_breaks);
850 preserve_line_breaks = TRUE; 850 preserve_line_breaks = TRUE;
851 } 851 }
852} 852}
853 853
854void TEWidget::focusInEvent( QFocusEvent * ) 854void TEWidget::focusInEvent( QFocusEvent * )
855{ 855{
856 // do nothing, to prevent repainting 856 // do nothing, to prevent repainting
857} 857}
858 858
859 859
860void TEWidget::focusOutEvent( QFocusEvent * ) 860void TEWidget::focusOutEvent( QFocusEvent * )
861{ 861{
862 // do nothing, to prevent repainting 862 // do nothing, to prevent repainting
863} 863}
864 864
865bool TEWidget::focusNextPrevChild( bool next ) 865bool TEWidget::focusNextPrevChild( bool next )
866{ 866{
867 if (next) 867 if (next)
868 return false; // This disables changing the active part in konqueror 868 return false; // This disables changing the active part in konqueror
869 // when pressing Tab 869 // when pressing Tab
870 return QFrame::focusNextPrevChild( next ); 870 return QFrame::focusNextPrevChild( next );
871} 871}
872 872
873 873
874int TEWidget::charClass(char ch) const 874int TEWidget::charClass(char ch) const
875{ 875{
876 // This might seem like overkill, but imagine if ch was a Unicode 876 // This might seem like overkill, but imagine if ch was a Unicode
877 // character (Qt 2.0 QChar) - it might then be sensible to separate 877 // character (Qt 2.0 QChar) - it might then be sensible to separate
878 // the different language ranges, etc. 878 // the different language ranges, etc.
879 879
880 if ( isspace(ch) ) return ' '; 880 if ( isspace(ch) ) return ' ';
881 881
882 static const char *word_characters = ":@-./_~"; 882 static const char *word_characters = ":@-./_~";
883 if ( isalnum(ch) || strchr(word_characters, ch) ) 883 if ( isalnum(ch) || strchr(word_characters, ch) )
884 return 'a'; 884 return 'a';
885 885
886 // Everything else is weird 886 // Everything else is weird
887 return 1; 887 return 1;
888} 888}
889 889
890void TEWidget::setMouseMarks(bool on) 890void TEWidget::setMouseMarks(bool on)
891{ 891{
892 mouse_marks = on; 892 mouse_marks = on;
893 setCursor( mouse_marks ? ibeamCursor : arrowCursor ); 893 setCursor( mouse_marks ? ibeamCursor : arrowCursor );
894} 894}
895 895
896/* ------------------------------------------------------------------------- */ 896/* ------------------------------------------------------------------------- */
897/* */ 897/* */
898/* Clipboard */ 898/* Clipboard */
899/* */ 899/* */
900/* ------------------------------------------------------------------------- */ 900/* ------------------------------------------------------------------------- */
901 901
902#undef KeyPress 902#undef KeyPress
903 903
904void TEWidget::emitSelection() 904void TEWidget::emitSelection()
905// Paste Clipboard by simulating keypress events 905// Paste Clipboard by simulating keypress events
906{ 906{
907#ifndef QT_NO_CLIPBOARD 907#ifndef QT_NO_CLIPBOARD
908 QString text = QApplication::clipboard()->text(); 908 QString text = QApplication::clipboard()->text();
909 if ( ! text.isNull() ) 909 if ( ! text.isNull() )
910 { 910 {
911 text.replace(QRegExp("\n"), "\r"); 911 text.replace(QRegExp("\n"), "\r");
912 QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text); 912 QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text);
913 emit keyPressedSignal(&e); // expose as a big fat keypress event 913 emit keyPressedSignal(&e); // expose as a big fat keypress event
914 emit clearSelectionSignal(); 914 emit clearSelectionSignal();
915 } 915 }
916#endif 916#endif
917} 917}
918 918
919void TEWidget::emitText(QString text) 919void TEWidget::emitText(QString text)
920{ 920{
921 QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text); 921 QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text);
922 emit keyPressedSignal(&e); // expose as a big fat keypress event 922 emit keyPressedSignal(&e); // expose as a big fat keypress event
923} 923}
924 924
925void TEWidget::pasteClipboard( ) 925void TEWidget::pasteClipboard( )
926{ 926{
927 emitSelection(); 927 emitSelection();
928} 928}
929 929
930void TEWidget::setSelection(const QString& t) 930void TEWidget::setSelection(const QString& t)
931{ 931{
932#ifndef QT_NO_CLIPBOARD 932#ifndef QT_NO_CLIPBOARD
933 // Disconnect signal while WE set the clipboard 933 // Disconnect signal while WE set the clipboard
934 QObject *cb = QApplication::clipboard(); 934 QObject *cb = QApplication::clipboard();
935 QObject::disconnect( cb, SIGNAL(dataChanged()), 935 QObject::disconnect( cb, SIGNAL(dataChanged()),
936 this, SLOT(onClearSelection()) ); 936 this, SLOT(onClearSelection()) );
937 937
938 QApplication::clipboard()->setText(t); 938 QApplication::clipboard()->setText(t);
939 939
940 QObject::connect( cb, SIGNAL(dataChanged()), 940 QObject::connect( cb, SIGNAL(dataChanged()),
941 this, SLOT(onClearSelection()) ); 941 this, SLOT(onClearSelection()) );
942#endif 942#endif
943} 943}
944 944
945void TEWidget::onClearSelection() 945void TEWidget::onClearSelection()
946{ 946{
947 emit clearSelectionSignal(); 947 emit clearSelectionSignal();
948} 948}
949 949
950/* ------------------------------------------------------------------------- */ 950/* ------------------------------------------------------------------------- */
951/* */ 951/* */
952/* Keyboard */ 952/* Keyboard */
953/* */ 953/* */
954/* ------------------------------------------------------------------------- */ 954/* ------------------------------------------------------------------------- */
955 955
956//FIXME: an `eventFilter' has been installed instead of a `keyPressEvent' 956//FIXME: an `eventFilter' has been installed instead of a `keyPressEvent'
957// due to a bug in `QT' or the ignorance of the author to prevent 957// due to a bug in `QT' or the ignorance of the author to prevent
958// repaint events being emitted to the screen whenever one leaves 958// repaint events being emitted to the screen whenever one leaves
959// or reenters the screen to/from another application. 959// or reenters the screen to/from another application.
960// 960//
961// Troll says one needs to change focusInEvent() and focusOutEvent(), 961// Troll says one needs to change focusInEvent() and focusOutEvent(),
962// which would also let you have an in-focus cursor and an out-focus 962// which would also let you have an in-focus cursor and an out-focus
963// cursor like xterm does. 963// cursor like xterm does.
964 964
965// for the auto-hide cursor feature, I added empty focusInEvent() and 965// for the auto-hide cursor feature, I added empty focusInEvent() and
966// focusOutEvent() so that update() isn't called. 966// focusOutEvent() so that update() isn't called.
967// For auto-hide, we need to get keypress-events, but we only get them when 967// For auto-hide, we need to get keypress-events, but we only get them when
968// we have focus. 968// we have focus.
969 969
970void TEWidget::doScroll(int lines) 970void TEWidget::doScroll(int lines)
971{ 971{
972 scrollbar->setValue(scrollbar->value()+lines); 972 scrollbar->setValue(scrollbar->value()+lines);
973} 973}
974 974
975bool TEWidget::eventFilter( QObject *obj, QEvent *e ) 975bool TEWidget::eventFilter( QObject *obj, QEvent *e )
976{ 976{
977 if ( (e->type() == QEvent::Accel || 977 if ( (e->type() == QEvent::Accel ||
978 e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) 978 e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this )
979 { 979 {
980 static_cast<QKeyEvent *>( e )->ignore(); 980 static_cast<QKeyEvent *>( e )->ignore();
981 return true; 981 return true;
982 } 982 }
983 if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ ) 983 if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ )
984 return FALSE; // not us 984 return FALSE; // not us
985 if ( e->type() == QEvent::Wheel) 985 if ( e->type() == QEvent::Wheel)
986 { 986 {
987 QApplication::sendEvent(scrollbar, e); 987 QApplication::sendEvent(scrollbar, e);
988 } 988 }
989 989
990#ifdef FAKE_CTRL_AND_ALT 990#ifdef FAKE_CTRL_AND_ALT
991 static bool control = FALSE; 991 static bool control = FALSE;
992 static bool alt = FALSE; 992 static bool alt = FALSE;
993 // Has a keyboard with no CTRL and ALT keys, but we fake it: 993 qDebug(" Has a keyboard with no CTRL and ALT keys, but we fake it:");
994 bool dele=FALSE; 994 bool dele=FALSE;
995 if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { 995 if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) {
996 QKeyEvent* ke = (QKeyEvent*)e; 996 QKeyEvent* ke = (QKeyEvent*)e;
997 bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat(); 997 bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat();
998 switch (ke->key()) { 998 switch (ke->key()) {
999 case Key_F9: // let this be "Control" 999 case Key_F9: // let this be "Control"
1000 control = keydown; 1000 control = keydown;
1001 e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state()); 1001 e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state());
1002 dele=TRUE; 1002 dele=TRUE;
1003 break; 1003 break;
1004 case Key_F13: // let this be "Alt" 1004 case Key_F13: // let this be "Alt"
1005 alt = keydown; 1005 alt = keydown;
1006 e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state()); 1006 e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state());
1007 dele=TRUE; 1007 dele=TRUE;
1008 break; 1008 break;
1009 default: 1009 default:
1010 if ( control ) { 1010 if ( control ) {
1011 int a = toupper(ke->ascii())-64; 1011 int a = toupper(ke->ascii())-64;
1012 if ( a >= 0 && a < ' ' ) { 1012 if ( a >= 0 && a < ' ' ) {
1013 e = new QKeyEvent(e->type(), ke->key(), 1013 e = new QKeyEvent(e->type(), ke->key(),
1014 a, ke->state()|ControlButton, QChar(a,0)); 1014 a, ke->state()|ControlButton, QChar(a,0));
1015 dele=TRUE; 1015 dele=TRUE;
1016 } 1016 }
1017 } 1017 }
1018 if ( alt ) { 1018 if ( alt ) {
1019 e = new QKeyEvent(e->type(), ke->key(), 1019 e = new QKeyEvent(e->type(), ke->key(),
1020 ke->ascii(), ke->state()|AltButton, ke->text()); 1020 ke->ascii(), ke->state()|AltButton, ke->text());
1021 dele=TRUE; 1021 dele=TRUE;
1022 } 1022 }
1023 } 1023 }
1024 } 1024 }
1025#endif 1025#endif
1026 1026
1027 if ( e->type() == QEvent::KeyPress ) 1027 if ( e->type() == QEvent::KeyPress )
1028 { 1028 {
1029 QKeyEvent* ke = (QKeyEvent*)e; 1029 QKeyEvent* ke = (QKeyEvent*)e;
1030
1031 actSel=0; // Key stroke implies a screen update, so TEWidget won't 1030 actSel=0; // Key stroke implies a screen update, so TEWidget won't
1032 // know where the current selection is. 1031 // know where the current selection is.
1033 1032
1033// qDebug("key pressed is 0x%x",ke->key());
1034 if( ke->state() == ShiftButton && ke->key() == Key_Tab) { //lets hardcode this sucker
1035// qDebug("key pressed 2 is 0x%x",ke->key());
1036 emitText("\\"); // expose
1037 } else
1034 emit keyPressedSignal(ke); // expose 1038 emit keyPressedSignal(ke); // expose
1035 ke->accept(); 1039 ke->accept();
1036#ifdef FAKE_CTRL_AND_ALT 1040#ifdef FAKE_CTRL_AND_ALT
1037 if ( dele ) delete e; 1041 if ( dele ) delete e;
1038#endif 1042#endif
1039 return true; // stop the event 1043 return true; // stop the event
1040 } 1044 }
1041 if ( e->type() == QEvent::Enter ) 1045 if ( e->type() == QEvent::Enter )
1042 { 1046 {
1043 QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()), 1047 QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()),
1044 this, SLOT(onClearSelection()) ); 1048 this, SLOT(onClearSelection()) );
1045 } 1049 }
1046 if ( e->type() == QEvent::Leave ) 1050 if ( e->type() == QEvent::Leave )
1047 { 1051 {
1048 QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), 1052 QObject::connect( (QObject*)cb, SIGNAL(dataChanged()),
1049 this, SLOT(onClearSelection()) ); 1053 this, SLOT(onClearSelection()) );
1050 } 1054 }
1051 return QFrame::eventFilter( obj, e ); 1055 return QFrame::eventFilter( obj, e );
1052} 1056}
1053 1057
1054/* ------------------------------------------------------------------------- */ 1058/* ------------------------------------------------------------------------- */
1055/* */ 1059/* */
1056/* Frame */ 1060/* Frame */
1057/* */ 1061/* */
1058/* ------------------------------------------------------------------------- */ 1062/* ------------------------------------------------------------------------- */
1059 1063
1060void TEWidget::frameChanged() 1064void TEWidget::frameChanged()
1061{ 1065{
1062 propagateSize(); 1066 propagateSize();
1063 update(); 1067 update();
1064} 1068}
1065 1069
1066/* ------------------------------------------------------------------------- */ 1070/* ------------------------------------------------------------------------- */
1067/* */ 1071/* */
1068/* Sound */ 1072/* Sound */
1069/* */ 1073/* */
1070/* ------------------------------------------------------------------------- */ 1074/* ------------------------------------------------------------------------- */
1071 1075
1072void TEWidget::Bell() 1076void TEWidget::Bell()
1073{ 1077{
1074 QApplication::beep(); 1078 QApplication::beep();
1075} 1079}
1076 1080
1077/* ------------------------------------------------------------------------- */ 1081/* ------------------------------------------------------------------------- */
1078/* */ 1082/* */
1079/* Auxiluary */ 1083/* Auxiluary */
1080/* */ 1084/* */
1081/* ------------------------------------------------------------------------- */ 1085/* ------------------------------------------------------------------------- */
1082 1086
1083void TEWidget::clearImage() 1087void TEWidget::clearImage()
1084// initialize the image 1088// initialize the image
1085// for internal use only 1089// for internal use only
1086{ 1090{
1087 for (int y = 0; y < lines; y++) 1091 for (int y = 0; y < lines; y++)
1088 for (int x = 0; x < columns; x++) 1092 for (int x = 0; x < columns; x++)
1089 { 1093 {
1090 image[loc(x,y)].c = 0xff; //' '; 1094 image[loc(x,y)].c = 0xff; //' ';
1091 image[loc(x,y)].f = 0xff; //DEFAULT_FORE_COLOR; 1095 image[loc(x,y)].f = 0xff; //DEFAULT_FORE_COLOR;
1092 image[loc(x,y)].b = 0xff; //DEFAULT_BACK_COLOR; 1096 image[loc(x,y)].b = 0xff; //DEFAULT_BACK_COLOR;
1093 image[loc(x,y)].r = 0xff; //DEFAULT_RENDITION; 1097 image[loc(x,y)].r = 0xff; //DEFAULT_RENDITION;
1094 } 1098 }
1095} 1099}
1096 1100
1097// Create Image /////////////////////////////////////////////////////// 1101// Create Image ///////////////////////////////////////////////////////
1098 1102
1099void TEWidget::calcGeometry() 1103void TEWidget::calcGeometry()
1100{ 1104{
1101 //FIXME: set rimX == rimY == 0 when running in full screen mode. 1105 //FIXME: set rimX == rimY == 0 when running in full screen mode.
1102 1106
1103 scrollbar->resize(QApplication::style().scrollBarExtent().width(), 1107 scrollbar->resize(QApplication::style().scrollBarExtent().width(),
1104 contentsRect().height()); 1108 contentsRect().height());
1105 switch(scrollLoc) 1109 switch(scrollLoc)
1106 { 1110 {
1107 case SCRNONE : 1111 case SCRNONE :
1108 columns = ( contentsRect().width() - 2 * rimX ) / font_w; 1112 columns = ( contentsRect().width() - 2 * rimX ) / font_w;
1109 blX = (contentsRect().width() - (columns*font_w) ) / 2; 1113 blX = (contentsRect().width() - (columns*font_w) ) / 2;
1110 brX = blX; 1114 brX = blX;
1111 scrollbar->hide(); 1115 scrollbar->hide();
1112 break; 1116 break;
1113 case SCRLEFT : 1117 case SCRLEFT :
1114 columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; 1118 columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w;
1115 brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; 1119 brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2;
1116 blX = brX + scrollbar->width(); 1120 blX = brX + scrollbar->width();
1117 scrollbar->move(contentsRect().topLeft()); 1121 scrollbar->move(contentsRect().topLeft());
1118 scrollbar->show(); 1122 scrollbar->show();
1119 break; 1123 break;
1120 case SCRRIGHT: 1124 case SCRRIGHT:
1121 columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; 1125 columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w;
1122 blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; 1126 blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2;
1123 brX = blX; 1127 brX = blX;
1124 scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0)); 1128 scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0));
1125 scrollbar->show(); 1129 scrollbar->show();
1126 break; 1130 break;
1127 } 1131 }
1128 //FIXME: support 'rounding' styles 1132 //FIXME: support 'rounding' styles
1129 lines = ( contentsRect().height() - 2 * rimY ) / font_h; 1133 lines = ( contentsRect().height() - 2 * rimY ) / font_h;
1130 bY = (contentsRect().height() - (lines *font_h)) / 2; 1134 bY = (contentsRect().height() - (lines *font_h)) / 2;
1131} 1135}
1132 1136
1133void TEWidget::makeImage() 1137void TEWidget::makeImage()
1134//FIXME: rename 'calcGeometry? 1138//FIXME: rename 'calcGeometry?
1135{ 1139{
1136 calcGeometry(); 1140 calcGeometry();
1137 image = (ca*) malloc(lines*columns*sizeof(ca)); 1141 image = (ca*) malloc(lines*columns*sizeof(ca));
1138 clearImage(); 1142 clearImage();
1139} 1143}
1140 1144
1141// calculate the needed size 1145// calculate the needed size
1142QSize TEWidget::calcSize(int cols, int lins) const 1146QSize TEWidget::calcSize(int cols, int lins) const
1143{ 1147{
1144 int frw = width() - contentsRect().width(); 1148 int frw = width() - contentsRect().width();
1145 int frh = height() - contentsRect().height(); 1149 int frh = height() - contentsRect().height();
1146 int scw = (scrollLoc==SCRNONE?0:scrollbar->width()); 1150 int scw = (scrollLoc==SCRNONE?0:scrollbar->width());
1147 return QSize( font_w*cols + 2*rimX + frw + scw, font_h*lins + 2*rimY + frh ); 1151 return QSize( font_w*cols + 2*rimX + frw + scw, font_h*lins + 2*rimY + frh );
1148} 1152}
1149 1153
1150QSize TEWidget::sizeHint() const 1154QSize TEWidget::sizeHint() const
1151{ 1155{
1152 return size(); 1156 return size();
1153} 1157}
1154 1158
1155void TEWidget::styleChange(QStyle &) 1159void TEWidget::styleChange(QStyle &)
1156{ 1160{
1157 propagateSize(); 1161 propagateSize();
1158} 1162}
1159 1163
1160#ifndef QT_NO_DRAGANDDROP 1164#ifndef QT_NO_DRAGANDDROP
1161 1165
1162/* --------------------------------------------------------------------- */ 1166/* --------------------------------------------------------------------- */
1163/* */ 1167/* */
1164/* Drag & Drop */ 1168/* Drag & Drop */
1165/* */ 1169/* */
1166/* --------------------------------------------------------------------- */ 1170/* --------------------------------------------------------------------- */
1167 1171
1168 1172
1169void TEWidget::dragEnterEvent(QDragEnterEvent* e) 1173void TEWidget::dragEnterEvent(QDragEnterEvent* e)
1170{ 1174{
1171 e->accept(QTextDrag::canDecode(e) || 1175 e->accept(QTextDrag::canDecode(e) ||
1172 QUriDrag::canDecode(e)); 1176 QUriDrag::canDecode(e));
1173} 1177}
1174 1178
1175void TEWidget::dropEvent(QDropEvent* event) 1179void TEWidget::dropEvent(QDropEvent* event)
1176{ 1180{
1177 // The current behaviour when url(s) are dropped is 1181 // The current behaviour when url(s) are dropped is
1178 // * if there is only ONE url and if it's a LOCAL one, ask for paste or cd 1182 // * if there is only ONE url and if it's a LOCAL one, ask for paste or cd
1179 // * in all other cases, just paste 1183 // * in all other cases, just paste
1180 // (for non-local ones, or for a list of URLs, 'cd' is nonsense) 1184 // (for non-local ones, or for a list of URLs, 'cd' is nonsense)
1181 QStrList strlist; 1185 QStrList strlist;
1182 int file_count = 0; 1186 int file_count = 0;
1183 dropText = ""; 1187 dropText = "";
1184 bool bPopup = true; 1188 bool bPopup = true;
1185 1189
1186 if(QUriDrag::decode(event, strlist)) { 1190 if(QUriDrag::decode(event, strlist)) {
1187 if (strlist.count()) { 1191 if (strlist.count()) {
1188 for(const char* p = strlist.first(); p; p = strlist.next()) { 1192 for(const char* p = strlist.first(); p; p = strlist.next()) {
1189 if(file_count++ > 0) { 1193 if(file_count++ > 0) {
1190 dropText += " "; 1194 dropText += " ";
1191 bPopup = false; // more than one file, don't popup 1195 bPopup = false; // more than one file, don't popup
1192 } 1196 }
1193 1197
1194/* 1198/*
1195 KURL url(p); 1199 KURL url(p);
1196 if (url.isLocalFile()) { 1200 if (url.isLocalFile()) {
1197 dropText += url.path(); // local URL : remove protocol 1201 dropText += url.path(); // local URL : remove protocol
1198 } 1202 }
1199 else { 1203 else {
1200 dropText += url.prettyURL(); 1204 dropText += url.prettyURL();
1201 bPopup = false; // a non-local file, don't popup 1205 bPopup = false; // a non-local file, don't popup
1202 } 1206 }
1203*/ 1207*/
1204 1208
1205 } 1209 }
1206 1210
1207 if (bPopup) 1211 if (bPopup)
1208 // m_drop->popup(pos() + event->pos()); 1212 // m_drop->popup(pos() + event->pos());
1209 m_drop->popup(mapToGlobal(event->pos())); 1213 m_drop->popup(mapToGlobal(event->pos()));
1210 else 1214 else
1211 { 1215 {
1212 if (currentSession) { 1216 if (currentSession) {
1213 currentSession->getEmulation()->sendString(dropText.local8Bit()); 1217 currentSession->getEmulation()->sendString(dropText.local8Bit());
1214 } 1218 }
1215// kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; 1219// kdDebug() << "Drop:" << dropText.local8Bit() << "\n";
1216 } 1220 }
1217 } 1221 }
1218 } 1222 }
1219 else if(QTextDrag::decode(event, dropText)) { 1223 else if(QTextDrag::decode(event, dropText)) {
1220// kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; 1224// kdDebug() << "Drop:" << dropText.local8Bit() << "\n";
1221 if (currentSession) { 1225 if (currentSession) {
1222 currentSession->getEmulation()->sendString(dropText.local8Bit()); 1226 currentSession->getEmulation()->sendString(dropText.local8Bit());
1223 } 1227 }
1224 // Paste it 1228 // Paste it
1225 } 1229 }
1226} 1230}
1227#endif 1231#endif
1228 1232
1229 1233
1230void TEWidget::drop_menu_activated(int item) 1234void TEWidget::drop_menu_activated(int item)
1231{ 1235{
1232#ifndef QT_NO_DRAGANDDROP 1236#ifndef QT_NO_DRAGANDDROP
1233 switch (item) 1237 switch (item)
1234 { 1238 {
1235 case 0: // paste 1239 case 0: // paste
1236 currentSession->getEmulation()->sendString(dropText.local8Bit()); 1240 currentSession->getEmulation()->sendString(dropText.local8Bit());
1237// KWM::activate((Window)this->winId()); 1241// KWM::activate((Window)this->winId());
1238 break; 1242 break;
1239 case 1: // cd ... 1243 case 1: // cd ...
1240 currentSession->getEmulation()->sendString("cd "); 1244 currentSession->getEmulation()->sendString("cd ");
1241 struct stat statbuf; 1245 struct stat statbuf;
1242 if ( ::stat( QFile::encodeName( dropText ), &statbuf ) == 0 ) 1246 if ( ::stat( QFile::encodeName( dropText ), &statbuf ) == 0 )
1243 { 1247 {
1244 if ( !S_ISDIR(statbuf.st_mode) ) 1248 if ( !S_ISDIR(statbuf.st_mode) )
1245 { 1249 {
1246/* 1250/*
1247 KURL url; 1251 KURL url;
1248 url.setPath( dropText ); 1252 url.setPath( dropText );
1249 dropText = url.directory( true, false ); // remove filename 1253 dropText = url.directory( true, false ); // remove filename
1250*/ 1254*/
1251 } 1255 }
1252 } 1256 }
1253 dropText.replace(QRegExp(" "), "\\ "); // escape spaces 1257 dropText.replace(QRegExp(" "), "\\ "); // escape spaces
1254 currentSession->getEmulation()->sendString(dropText.local8Bit()); 1258 currentSession->getEmulation()->sendString(dropText.local8Bit());
1255 currentSession->getEmulation()->sendString("\n"); 1259 currentSession->getEmulation()->sendString("\n");
1256// KWM::activate((Window)this->winId()); 1260// KWM::activate((Window)this->winId());
1257 break; 1261 break;
1258 } 1262 }
1259#endif 1263#endif
1260} 1264}
1261 1265
diff --git a/core/apps/embeddedkonsole/konsole.cpp b/core/apps/embeddedkonsole/konsole.cpp
index f13d0c9..adcfb7f 100644
--- a/core/apps/embeddedkonsole/konsole.cpp
+++ b/core/apps/embeddedkonsole/konsole.cpp
@@ -1,555 +1,556 @@
1/* ---------------------------------------------------------------------- */ 1/* ---------------------------------------------------------------------- */
2/* */ 2/* */
3/* [main.C] Konsole */ 3/* [main.C] Konsole */
4/* */ 4/* */
5/* ---------------------------------------------------------------------- */ 5/* ---------------------------------------------------------------------- */
6/* */ 6/* */
7/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ 7/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */
8/* */ 8/* */
9/* This file is part of Konsole, an X terminal. */ 9/* This file is part of Konsole, an X terminal. */
10/* */ 10/* */
11/* The material contained in here more or less directly orginates from */ 11/* The material contained in here more or less directly orginates from */
12/* kvt, which is copyright (c) 1996 by Matthias Ettrich <ettrich@kde.org> */ 12/* kvt, which is copyright (c) 1996 by Matthias Ettrich <ettrich@kde.org> */
13/* */ 13/* */
14/* ---------------------------------------------------------------------- */ 14/* ---------------------------------------------------------------------- */
15/* */ 15/* */
16/* Ported Konsole to Qt/Embedded */ 16/* Ported Konsole to Qt/Embedded */
17/* */ 17/* */
18/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ 18/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */
19/* */ 19/* */
20/* -------------------------------------------------------------------------- */ 20/* -------------------------------------------------------------------------- */
21// enhancements added by L.J. Potter <ljp@llornkcor.com> 21// enhancements added by L.J. Potter <ljp@llornkcor.com>
22 22
23#include <qpe/resource.h> 23#include <qpe/resource.h>
24 24
25#include <qdir.h> 25#include <qdir.h>
26#include <qevent.h> 26#include <qevent.h>
27#include <qdragobject.h> 27#include <qdragobject.h>
28#include <qobjectlist.h> 28#include <qobjectlist.h>
29#include <qtoolbutton.h> 29#include <qtoolbutton.h>
30#include <qpe/qpetoolbar.h> 30#include <qpe/qpetoolbar.h>
31#include <qpushbutton.h> 31#include <qpushbutton.h>
32#include <qfontdialog.h> 32#include <qfontdialog.h>
33#include <qglobal.h> 33#include <qglobal.h>
34#include <qpainter.h> 34#include <qpainter.h>
35#include <qpe/qpemenubar.h> 35#include <qpe/qpemenubar.h>
36#include <qmessagebox.h> 36#include <qmessagebox.h>
37#include <qaction.h> 37#include <qaction.h>
38#include <qapplication.h> 38#include <qapplication.h>
39#include <qfontmetrics.h> 39#include <qfontmetrics.h>
40#include <qcombobox.h> 40#include <qcombobox.h>
41#include <qevent.h> 41#include <qevent.h>
42#include <qtabwidget.h> 42#include <qtabwidget.h>
43#include <qtabbar.h> 43#include <qtabbar.h>
44#include <qpe/config.h> 44#include <qpe/config.h>
45#include <qstringlist.h> 45#include <qstringlist.h>
46#include <qpalette.h> 46#include <qpalette.h>
47 47
48#include <sys/wait.h> 48#include <sys/wait.h>
49#include <stdio.h> 49#include <stdio.h>
50#include <stdlib.h> 50#include <stdlib.h>
51#include <assert.h> 51#include <assert.h>
52 52
53#include "konsole.h" 53#include "konsole.h"
54#include "keytrans.h" 54#include "keytrans.h"
55#include "commandeditdialog.h" 55#include "commandeditdialog.h"
56 56
57class EKNumTabBar : public QTabBar { 57class EKNumTabBar : public QTabBar {
58public: 58public:
59 void numberTabs() 59 void numberTabs()
60 { 60 {
61 // Yes, it really is this messy. QTabWidget needs functions 61 // Yes, it really is this messy. QTabWidget needs functions
62 // that provide acces to tabs in a sequential way. 62 // that provide acces to tabs in a sequential way.
63 int m=INT_MIN; 63 int m=INT_MIN;
64 for (int i=0; i<count(); i++) { 64 for (int i=0; i<count(); i++) {
65 QTab* left=0; 65 QTab* left=0;
66 QListIterator<QTab> it(*tabList()); 66 QListIterator<QTab> it(*tabList());
67 int x=INT_MAX; 67 int x=INT_MAX;
68 for( QTab* t; (t=it.current()); ++it ) { 68 for( QTab* t; (t=it.current()); ++it ) {
69 int tx = t->rect().x(); 69 int tx = t->rect().x();
70 if ( tx<x && tx>m ) { 70 if ( tx<x && tx>m ) {
71 x = tx; 71 x = tx;
72 left = t; 72 left = t;
73 } 73 }
74 } 74 }
75 if ( left ) { 75 if ( left ) {
76 left->setText(QString::number(i+1)); 76 left->setText(QString::number(i+1));
77 m = left->rect().x(); 77 m = left->rect().x();
78 } 78 }
79 } 79 }
80 } 80 }
81}; 81};
82 82
83class EKNumTabWidget : public QTabWidget { 83class EKNumTabWidget : public QTabWidget {
84public: 84public:
85 EKNumTabWidget(QWidget* parent) : QTabWidget(parent) 85 EKNumTabWidget(QWidget* parent) : QTabWidget(parent)
86 { 86 {
87 } 87 }
88 88
89 void addTab(QWidget* w) 89 void addTab(QWidget* w)
90 { 90 {
91 QTab* t = new QTab(QString::number(tabBar()->count()+1)); 91 QTab* t = new QTab(QString::number(tabBar()->count()+1));
92 QTabWidget::addTab(w,t); 92 QTabWidget::addTab(w,t);
93 } 93 }
94 94
95 void removeTab(QWidget* w) 95 void removeTab(QWidget* w)
96 { 96 {
97 removePage(w); 97 removePage(w);
98 ((EKNumTabBar*)tabBar())->numberTabs(); 98 ((EKNumTabBar*)tabBar())->numberTabs();
99 } 99 }
100}; 100};
101 101
102// This could be configurable or dynamicly generated from the bash history 102// This could be configurable or dynamicly generated from the bash history
103// file of the user 103// file of the user
104static const char *commonCmds[] = 104static const char *commonCmds[] =
105{ 105{
106 "ls ", // I left this here, cause it looks better than the first alpha 106 "ls ", // I left this here, cause it looks better than the first alpha
107 "cardctl eject", 107 "cardctl eject",
108 "cat ", 108 "cat ",
109 "cd ", 109 "cd ",
110 "chmod ", 110 "chmod ",
111 "clear", 111 "clear",
112 "cp ", 112 "cp ",
113 "dc ", 113 "dc ",
114 "df ", 114 "df ",
115 "dmesg", 115 "dmesg",
116 "echo ", 116 "echo ",
117 "env", 117 "env",
118 "find ", 118 "find ",
119 "free", 119 "free",
120 "grep ", 120 "grep ",
121 "ifconfig ", 121 "ifconfig ",
122 "ipkg ", 122 "ipkg ",
123 "mkdir ", 123 "mkdir ",
124 "mv ", 124 "mv ",
125 "nc localhost 7776", 125 "nc localhost 7776",
126 "nc localhost 7777", 126 "nc localhost 7777",
127 "netstat ", 127 "netstat ",
128 "nslookup ", 128 "nslookup ",
129 "ping ", 129 "ping ",
130 "ps aux", 130 "ps aux",
131 "pwd ", 131 "pwd ",
132 "rm ", 132 "rm ",
133 "rmdir ", 133 "rmdir ",
134 "route ", 134 "route ",
135 "set ", 135 "set ",
136 "traceroute", 136 "traceroute",
137 137
138/* 138/*
139 "gzip", 139 "gzip",
140 "gunzip", 140 "gunzip",
141 "chgrp", 141 "chgrp",
142 "chown", 142 "chown",
143 "date", 143 "date",
144 "dd", 144 "dd",
145 "df", 145 "df",
146 "dmesg", 146 "dmesg",
147 "fuser", 147 "fuser",
148 "hostname", 148 "hostname",
149 "kill", 149 "kill",
150 "killall", 150 "killall",
151 "ln", 151 "ln",
152 "ping", 152 "ping",
153 "mount", 153 "mount",
154 "more", 154 "more",
155 "sort", 155 "sort",
156 "touch", 156 "touch",
157 "umount", 157 "umount",
158 "mknod", 158 "mknod",
159 "netstat", 159 "netstat",
160*/ 160*/
161 161
162 "exit", 162 "exit",
163 NULL 163 NULL
164}; 164};
165 165
166 166
167Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) : 167Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) :
168 QMainWindow(parent, name, fl) 168 QMainWindow(parent, name, fl)
169{ 169{
170 QStrList args; 170 QStrList args;
171 init("/bin/sh",args); 171 init("/bin/ash",args);
172// init("/bin/sh",args);
172} 173}
173 174
174Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int) 175Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int)
175 : QMainWindow(0, name) 176 : QMainWindow(0, name)
176{ 177{
177 init(_pgm,_args); 178 init(_pgm,_args);
178} 179}
179 180
180void Konsole::initCommandList() 181void Konsole::initCommandList()
181{ 182{
182// qDebug("Konsole::initCommandList"); 183// qDebug("Konsole::initCommandList");
183 Config cfg("Konsole"); 184 Config cfg("Konsole");
184 cfg.setGroup("Commands"); 185 cfg.setGroup("Commands");
185 commonCombo->setInsertionPolicy(QComboBox::AtCurrent); 186 commonCombo->setInsertionPolicy(QComboBox::AtCurrent);
186 commonCombo->clear(); 187 commonCombo->clear();
187 if (cfg.readEntry("Commands Set","FALSE") == "FALSE") { 188 if (cfg.readEntry("Commands Set","FALSE") == "FALSE") {
188 for (int i = 0; commonCmds[i] != NULL; i++) { 189 for (int i = 0; commonCmds[i] != NULL; i++) {
189 commonCombo->insertItem(commonCmds[i],i); 190 commonCombo->insertItem(commonCmds[i],i);
190 } 191 }
191 } else { 192 } else {
192 for (int i = 0; i < 100; i++) { 193 for (int i = 0; i < 100; i++) {
193 if (!(cfg.readEntry( QString::number(i),"")).isEmpty()) 194 if (!(cfg.readEntry( QString::number(i),"")).isEmpty())
194 commonCombo->insertItem((cfg.readEntry( QString::number(i),""))); 195 commonCombo->insertItem((cfg.readEntry( QString::number(i),"")));
195 } 196 }
196 } 197 }
197 198
198} 199}
199 200
200void Konsole::init(const char* _pgm, QStrList & _args) 201void Konsole::init(const char* _pgm, QStrList & _args)
201{ 202{
202 b_scroll = TRUE; // histon; 203 b_scroll = TRUE; // histon;
203 n_keytab = 0; 204 n_keytab = 0;
204 n_render = 0; 205 n_render = 0;
205 startUp=0; 206 startUp=0;
206 setCaption( tr("Terminal") ); 207 setCaption( tr("Terminal") );
207 setIcon( Resource::loadPixmap( "konsole" ) ); 208 setIcon( Resource::loadPixmap( "konsole" ) );
208 209
209 Config cfg("Konsole"); 210 Config cfg("Konsole");
210 cfg.setGroup("Konsole"); 211 cfg.setGroup("Konsole");
211 QString tmp; 212 QString tmp;
212 // initialize the list of allowed fonts /////////////////////////////////// 213 // initialize the list of allowed fonts ///////////////////////////////////
213 cfont = cfg.readNumEntry("FontID", 1); 214 cfont = cfg.readNumEntry("FontID", 1);
214 QFont f = QFont("Micro", 4, QFont::Normal); 215 QFont f = QFont("Micro", 4, QFont::Normal);
215 f.setFixedPitch(TRUE); 216 f.setFixedPitch(TRUE);
216 fonts.append(new VTFont(tr("Micro"), f)); 217 fonts.append(new VTFont(tr("Micro"), f));
217 218
218 f = QFont("Fixed", 7, QFont::Normal); 219 f = QFont("Fixed", 7, QFont::Normal);
219 f.setFixedPitch(TRUE); 220 f.setFixedPitch(TRUE);
220 fonts.append(new VTFont(tr("Small Fixed"), f)); 221 fonts.append(new VTFont(tr("Small Fixed"), f));
221 222
222 f = QFont("Fixed", 12, QFont::Normal); 223 f = QFont("Fixed", 12, QFont::Normal);
223 f.setFixedPitch(TRUE); 224 f.setFixedPitch(TRUE);
224 fonts.append(new VTFont(tr("Medium Fixed"), f)); 225 fonts.append(new VTFont(tr("Medium Fixed"), f));
225 226
226 // create terminal emulation framework //////////////////////////////////// 227 // create terminal emulation framework ////////////////////////////////////
227 nsessions = 0; 228 nsessions = 0;
228 229
229 tab = new EKNumTabWidget(this); 230 tab = new EKNumTabWidget(this);
230 231
231 connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*))); 232 connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*)));
232 233
233 // create terminal toolbar //////////////////////////////////////////////// 234 // create terminal toolbar ////////////////////////////////////////////////
234 setToolBarsMovable( FALSE ); 235 setToolBarsMovable( FALSE );
235 QPEToolBar *menuToolBar = new QPEToolBar( this ); 236 QPEToolBar *menuToolBar = new QPEToolBar( this );
236 menuToolBar->setHorizontalStretchable( TRUE ); 237 menuToolBar->setHorizontalStretchable( TRUE );
237 238
238 QPEMenuBar *menuBar = new QPEMenuBar( menuToolBar ); 239 QPEMenuBar *menuBar = new QPEMenuBar( menuToolBar );
239 240
240 fontList = new QPopupMenu( this ); 241 fontList = new QPopupMenu( this );
241 for(uint i = 0; i < fonts.count(); i++) { 242 for(uint i = 0; i < fonts.count(); i++) {
242 VTFont *fnt = fonts.at(i); 243 VTFont *fnt = fonts.at(i);
243 fontList->insertItem(fnt->getName(), i); 244 fontList->insertItem(fnt->getName(), i);
244 } 245 }
245 fontChanged(cfont); 246 fontChanged(cfont);
246 247
247 configMenu = new QPopupMenu( this); 248 configMenu = new QPopupMenu( this);
248 colorMenu = new QPopupMenu( this); 249 colorMenu = new QPopupMenu( this);
249 scrollMenu = new QPopupMenu( this); 250 scrollMenu = new QPopupMenu( this);
250 editCommandListMenu = new QPopupMenu( this); 251 editCommandListMenu = new QPopupMenu( this);
251 252
252 configMenu->insertItem("Command List",editCommandListMenu); 253 configMenu->insertItem("Command List",editCommandListMenu);
253 254
254 bool listHidden; 255 bool listHidden;
255 cfg.setGroup("Menubar"); 256 cfg.setGroup("Menubar");
256 if( cfg.readEntry("Hidden","FALSE") == "TRUE") { 257 if( cfg.readEntry("Hidden","FALSE") == "TRUE") {
257 editCommandListMenu->insertItem( tr( "Show command list" )); 258 editCommandListMenu->insertItem( tr( "Show command list" ));
258 listHidden=TRUE; 259 listHidden=TRUE;
259 } else { 260 } else {
260 editCommandListMenu->insertItem( tr( "Hide command list" )); 261 editCommandListMenu->insertItem( tr( "Hide command list" ));
261 listHidden=FALSE; 262 listHidden=FALSE;
262 } 263 }
263 264
264 cfg.setGroup("Tabs"); 265 cfg.setGroup("Tabs");
265 tmp=cfg.readEntry("Position","Bottom"); 266 tmp=cfg.readEntry("Position","Bottom");
266 if(tmp=="Top") { 267 if(tmp=="Top") {
267 tab->setTabPosition(QTabWidget::Top); 268 tab->setTabPosition(QTabWidget::Top);
268 configMenu->insertItem( tr( "Tabs on Bottom" ) ); 269 configMenu->insertItem( tr( "Tabs on Bottom" ) );
269 } else { 270 } else {
270 tab->setTabPosition(QTabWidget::Bottom); 271 tab->setTabPosition(QTabWidget::Bottom);
271 configMenu->insertItem("Tabs on Top"); 272 configMenu->insertItem("Tabs on Top");
272 } 273 }
273 configMenu->insertSeparator(2); 274 configMenu->insertSeparator(2);
274 275
275 colorMenu->insertItem(tr( "Green on Black")); 276 colorMenu->insertItem(tr( "Green on Black"));
276 colorMenu->insertItem(tr( "Black on White")); 277 colorMenu->insertItem(tr( "Black on White"));
277 colorMenu->insertItem(tr( "White on Black")); 278 colorMenu->insertItem(tr( "White on Black"));
278 colorMenu->insertItem(tr( "Black on Transparent")); 279 colorMenu->insertItem(tr( "Black on Transparent"));
279 colorMenu->insertItem(tr( "Black on Red")); 280 colorMenu->insertItem(tr( "Black on Red"));
280 colorMenu->insertItem(tr( "Red on Black")); 281 colorMenu->insertItem(tr( "Red on Black"));
281 colorMenu->insertItem(tr( "Green on Yellow")); 282 colorMenu->insertItem(tr( "Green on Yellow"));
282 colorMenu->insertItem(tr( "Blue on Magenta")); 283 colorMenu->insertItem(tr( "Blue on Magenta"));
283 colorMenu->insertItem(tr( "Magenta on Blue")); 284 colorMenu->insertItem(tr( "Magenta on Blue"));
284 colorMenu->insertItem(tr( "Cyan on White")); 285 colorMenu->insertItem(tr( "Cyan on White"));
285 colorMenu->insertItem(tr( "White on Cyan")); 286 colorMenu->insertItem(tr( "White on Cyan"));
286 colorMenu->insertItem(tr( "Blue on Black")); 287 colorMenu->insertItem(tr( "Blue on Black"));
287 colorMenu->insertItem(tr( "Amber on Black")); 288 colorMenu->insertItem(tr( "Amber on Black"));
288 configMenu->insertItem(tr( "Colors") ,colorMenu); 289 configMenu->insertItem(tr( "Colors") ,colorMenu);
289 290
290 connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) )); 291 connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) ));
291 connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) )); 292 connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) ));
292 connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuSelected(int) )); 293 connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuSelected(int) ));
293 connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int))); 294 connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int)));
294 connect(editCommandListMenu,SIGNAL(activated(int)),this,SLOT(editCommandListMenuSelected(int))); 295 connect(editCommandListMenu,SIGNAL(activated(int)),this,SLOT(editCommandListMenuSelected(int)));
295 menuBar->insertItem( tr("Font"), fontList ); 296 menuBar->insertItem( tr("Font"), fontList );
296 menuBar->insertItem( tr("Options"), configMenu ); 297 menuBar->insertItem( tr("Options"), configMenu );
297 298
298 QPEToolBar *toolbar = new QPEToolBar( this ); 299 QPEToolBar *toolbar = new QPEToolBar( this );
299 300
300 QAction *a; 301 QAction *a;
301 302
302 // Button Commands 303 // Button Commands
303 a = new QAction( tr("New"), Resource::loadPixmap( "konsole" ), QString::null, 0, this, 0 ); 304 a = new QAction( tr("New"), Resource::loadPixmap( "konsole" ), QString::null, 0, this, 0 );
304 connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); a->addTo( toolbar ); 305 connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); a->addTo( toolbar );
305 a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 ); 306 a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 );
306 connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolbar ); 307 connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolbar );
307 a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 ); 308 a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 );
308 connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolbar ); 309 connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolbar );
309 a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 ); 310 a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 );
310 connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolbar ); 311 connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolbar );
311 a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 ); 312 a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 );
312 connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar ); 313 connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar );
313 a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 ); 314 a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 );
314 connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar ); 315 connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar );
315 a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); 316 a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 );
316 connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); a->addTo( toolbar ); 317 connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); a->addTo( toolbar );
317/* 318/*
318 a = new QAction( tr("Up"), Resource::loadPixmap( "up" ), QString::null, 0, this, 0 ); 319 a = new QAction( tr("Up"), Resource::loadPixmap( "up" ), QString::null, 0, this, 0 );
319 connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar ); 320 connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar );
320 a = new QAction( tr("Down"), Resource::loadPixmap( "down" ), QString::null, 0, this, 0 ); 321 a = new QAction( tr("Down"), Resource::loadPixmap( "down" ), QString::null, 0, this, 0 );
321 connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar ); 322 connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar );
322*/ 323*/
323 324
324 secondToolBar = new QPEToolBar( this ); 325 secondToolBar = new QPEToolBar( this );
325 secondToolBar->setHorizontalStretchable( TRUE ); 326 secondToolBar->setHorizontalStretchable( TRUE );
326 327
327 commonCombo = new QComboBox( secondToolBar ); 328 commonCombo = new QComboBox( secondToolBar );
328 commonCombo->setMaximumWidth(236); 329 commonCombo->setMaximumWidth(236);
329 330
330 editCommandListMenu->insertItem( tr( "Quick Edit" ) ); 331 editCommandListMenu->insertItem( tr( "Quick Edit" ) );
331 if( listHidden) { 332 if( listHidden) {
332 secondToolBar->hide(); 333 secondToolBar->hide();
333 editCommandListMenu->setItemEnabled(-22 ,FALSE); 334 editCommandListMenu->setItemEnabled(-22 ,FALSE);
334 } 335 }
335 editCommandListMenu->insertItem(tr( "Edit" ) ); 336 editCommandListMenu->insertItem(tr( "Edit" ) );
336 337
337 cfg.setGroup("Commands"); 338 cfg.setGroup("Commands");
338 commonCombo->setInsertionPolicy(QComboBox::AtCurrent); 339 commonCombo->setInsertionPolicy(QComboBox::AtCurrent);
339 340
340 initCommandList(); 341 initCommandList();
341// for (int i = 0; commonCmds[i] != NULL; i++) { 342// for (int i = 0; commonCmds[i] != NULL; i++) {
342// commonCombo->insertItem( commonCmds[i], i ); 343// commonCombo->insertItem( commonCmds[i], i );
343// tmp = cfg.readEntry( QString::number(i),""); 344// tmp = cfg.readEntry( QString::number(i),"");
344// if(tmp != "") 345// if(tmp != "")
345// commonCombo->changeItem( tmp,i ); 346// commonCombo->changeItem( tmp,i );
346// } 347// }
347 348
348 connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) )); 349 connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) ));
349 350
350 scrollMenu->insertItem(tr( "None" )); 351 scrollMenu->insertItem(tr( "None" ));
351 scrollMenu->insertItem(tr( "Left" )); 352 scrollMenu->insertItem(tr( "Left" ));
352 scrollMenu->insertItem(tr( "Right" )); 353 scrollMenu->insertItem(tr( "Right" ));
353 configMenu->insertItem(tr( "ScrollBar" ),scrollMenu); 354 configMenu->insertItem(tr( "ScrollBar" ),scrollMenu);
354 355
355 // create applications ///////////////////////////////////////////////////// 356 // create applications /////////////////////////////////////////////////////
356 setCentralWidget(tab); 357 setCentralWidget(tab);
357 358
358 // load keymaps //////////////////////////////////////////////////////////// 359 // load keymaps ////////////////////////////////////////////////////////////
359 KeyTrans::loadAll(); 360 KeyTrans::loadAll();
360 for (int i = 0; i < KeyTrans::count(); i++) 361 for (int i = 0; i < KeyTrans::count(); i++)
361 { KeyTrans* s = KeyTrans::find(i); 362 { KeyTrans* s = KeyTrans::find(i);
362 assert( s ); 363 assert( s );
363 } 364 }
364 365
365 se_pgm = _pgm; 366 se_pgm = _pgm;
366 se_args = _args; 367 se_args = _args;
367 368
368parseCommandLine(); 369parseCommandLine();
369 // read and apply default values /////////////////////////////////////////// 370 // read and apply default values ///////////////////////////////////////////
370 resize(321, 321); // Dummy. 371 resize(321, 321); // Dummy.
371 QSize currentSize = size(); 372 QSize currentSize = size();
372 if (currentSize != size()) 373 if (currentSize != size())
373 defaultSize = size(); 374 defaultSize = size();
374} 375}
375 376
376void Konsole::show() 377void Konsole::show()
377{ 378{
378 if ( !nsessions ) { 379 if ( !nsessions ) {
379 newSession(); 380 newSession();
380 } 381 }
381 QMainWindow::show(); 382 QMainWindow::show();
382} 383}
383 384
384void Konsole::initSession(const char*, QStrList &) 385void Konsole::initSession(const char*, QStrList &)
385{ 386{
386 QMainWindow::show(); 387 QMainWindow::show();
387} 388}
388 389
389Konsole::~Konsole() 390Konsole::~Konsole()
390{ 391{
391 while (nsessions > 0) { 392 while (nsessions > 0) {
392 doneSession(getTe()->currentSession, 0); 393 doneSession(getTe()->currentSession, 0);
393 } 394 }
394 395
395 Config cfg("Konsole"); 396 Config cfg("Konsole");
396 cfg.setGroup("Konsole"); 397 cfg.setGroup("Konsole");
397 cfg.writeEntry("FontID", cfont); 398 cfg.writeEntry("FontID", cfont);
398} 399}
399 400
400void Konsole::fontChanged(int f) 401void Konsole::fontChanged(int f)
401{ 402{
402 VTFont* font = fonts.at(f); 403 VTFont* font = fonts.at(f);
403 if (font != 0) { 404 if (font != 0) {
404 for(uint i = 0; i < fonts.count(); i++) { 405 for(uint i = 0; i < fonts.count(); i++) {
405 fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE); 406 fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE);
406 } 407 }
407 408
408 cfont = f; 409 cfont = f;
409 410
410 TEWidget* te = getTe(); 411 TEWidget* te = getTe();
411 if (te != 0) { 412 if (te != 0) {
412 te->setVTFont(font->getFont()); 413 te->setVTFont(font->getFont());
413 } 414 }
414 } 415 }
415} 416}
416 417
417 418
418void Konsole::enterCommand(int c) 419void Konsole::enterCommand(int c)
419{ 420{
420 TEWidget* te = getTe(); 421 TEWidget* te = getTe();
421 if (te != 0) { 422 if (te != 0) {
422 if(!commonCombo->editable()) { 423 if(!commonCombo->editable()) {
423 QString text = commonCombo->text(c); //commonCmds[c]; 424 QString text = commonCombo->text(c); //commonCmds[c];
424 te->emitText(text); 425 te->emitText(text);
425 } else { 426 } else {
426 changeCommand( commonCombo->text(c), c); 427 changeCommand( commonCombo->text(c), c);
427 } 428 }
428 } 429 }
429} 430}
430 431
431void Konsole::hitEnter() 432void Konsole::hitEnter()
432{ 433{
433 TEWidget* te = getTe(); 434 TEWidget* te = getTe();
434 if (te != 0) { 435 if (te != 0) {
435 te->emitText(QString("\r")); 436 te->emitText(QString("\r"));
436 } 437 }
437} 438}
438 439
439void Konsole::hitSpace() 440void Konsole::hitSpace()
440{ 441{
441 TEWidget* te = getTe(); 442 TEWidget* te = getTe();
442 if (te != 0) { 443 if (te != 0) {
443 te->emitText(QString(" ")); 444 te->emitText(QString(" "));
444 } 445 }
445} 446}
446 447
447void Konsole::hitTab() 448void Konsole::hitTab()
448{ 449{
449 TEWidget* te = getTe(); 450 TEWidget* te = getTe();
450 if (te != 0) { 451 if (te != 0) {
451 te->emitText(QString("\t")); 452 te->emitText(QString("\t"));
452 } 453 }
453} 454}
454 455
455void Konsole::hitPaste() 456void Konsole::hitPaste()
456{ 457{
457 TEWidget* te = getTe(); 458 TEWidget* te = getTe();
458 if (te != 0) { 459 if (te != 0) {
459 te->pasteClipboard(); 460 te->pasteClipboard();
460 } 461 }
461} 462}
462 463
463void Konsole::hitUp() 464void Konsole::hitUp()
464{ 465{
465 TEWidget* te = getTe(); 466 TEWidget* te = getTe();
466 if (te != 0) { 467 if (te != 0) {
467 QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Up, 0, 0); 468 QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Up, 0, 0);
468 QApplication::sendEvent( te, &ke ); 469 QApplication::sendEvent( te, &ke );
469 } 470 }
470} 471}
471 472
472void Konsole::hitDown() 473void Konsole::hitDown()
473{ 474{
474 TEWidget* te = getTe(); 475 TEWidget* te = getTe();
475 if (te != 0) { 476 if (te != 0) {
476 QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Down, 0, 0); 477 QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Down, 0, 0);
477 QApplication::sendEvent( te, &ke ); 478 QApplication::sendEvent( te, &ke );
478 } 479 }
479} 480}
480 481
481/** 482/**
482 This function calculates the size of the external widget 483 This function calculates the size of the external widget
483 needed for the internal widget to be 484 needed for the internal widget to be
484 */ 485 */
485QSize Konsole::calcSize(int columns, int lines) { 486QSize Konsole::calcSize(int columns, int lines) {
486 TEWidget* te = getTe(); 487 TEWidget* te = getTe();
487 if (te != 0) { 488 if (te != 0) {
488 QSize size = te->calcSize(columns, lines); 489 QSize size = te->calcSize(columns, lines);
489 return size; 490 return size;
490 } else { 491 } else {
491 QSize size; 492 QSize size;
492 return size; 493 return size;
493 } 494 }
494} 495}
495 496
496/** 497/**
497 sets application window to a size based on columns X lines of the te 498 sets application window to a size based on columns X lines of the te
498 guest widget. Call with (0,0) for setting default size. 499 guest widget. Call with (0,0) for setting default size.
499*/ 500*/
500 501
501void Konsole::setColLin(int columns, int lines) 502void Konsole::setColLin(int columns, int lines)
502{ 503{
503 if ((columns==0) || (lines==0)) 504 if ((columns==0) || (lines==0))
504 { 505 {
505 if (defaultSize.isEmpty()) // not in config file : set default value 506 if (defaultSize.isEmpty()) // not in config file : set default value
506 { 507 {
507 defaultSize = calcSize(80,24); 508 defaultSize = calcSize(80,24);
508 // notifySize(24,80); // set menu items (strange arg order !) 509 // notifySize(24,80); // set menu items (strange arg order !)
509 } 510 }
510 resize(defaultSize); 511 resize(defaultSize);
511 } else { 512 } else {
512 resize(calcSize(columns, lines)); 513 resize(calcSize(columns, lines));
513 // notifySize(lines,columns); // set menu items (strange arg order !) 514 // notifySize(lines,columns); // set menu items (strange arg order !)
514 } 515 }
515} 516}
516 517
517/* 518/*
518void Konsole::setFont(int fontno) 519void Konsole::setFont(int fontno)
519{ 520{
520 QFont f; 521 QFont f;
521 if (fontno == 0) 522 if (fontno == 0)
522 f = defaultFont = QFont( "Helvetica", 12 ); 523 f = defaultFont = QFont( "Helvetica", 12 );
523 else 524 else
524 if (fonts[fontno][0] == '-') 525 if (fonts[fontno][0] == '-')
525 f.setRawName( fonts[fontno] ); 526 f.setRawName( fonts[fontno] );
526 else 527 else
527 { 528 {
528 f.setFamily(fonts[fontno]); 529 f.setFamily(fonts[fontno]);
529 f.setRawMode( TRUE ); 530 f.setRawMode( TRUE );
530 } 531 }
531 if ( !f.exactMatch() && fontno != 0) 532 if ( !f.exactMatch() && fontno != 0)
532 { 533 {
533 QString msg = i18n("Font `%1' not found.\nCheck README.linux.console for help.").arg(fonts[fontno]); 534 QString msg = i18n("Font `%1' not found.\nCheck README.linux.console for help.").arg(fonts[fontno]);
534 QMessageBox(this, msg); 535 QMessageBox(this, msg);
535 return; 536 return;
536 } 537 }
537 if (se) se->setFontNo(fontno); 538 if (se) se->setFontNo(fontno);
538 te->setVTFont(f); 539 te->setVTFont(f);
539 n_font = fontno; 540 n_font = fontno;
540} 541}
541*/ 542*/
542 543
543// --| color selection |------------------------------------------------------- 544// --| color selection |-------------------------------------------------------
544 545
545void Konsole::changeColumns(int columns) 546void Konsole::changeColumns(int columns)
546{ 547{
547 TEWidget* te = getTe(); 548 TEWidget* te = getTe();
548 if (te != 0) { 549 if (te != 0) {
549 setColLin(columns,te->Lines()); 550 setColLin(columns,te->Lines());
550 te->update(); 551 te->update();
551 } 552 }
552} 553}
553 554
554//FIXME: If a child dies during session swap, 555//FIXME: If a child dies during session swap,
555// this routine might be called before 556// this routine might be called before