-rw-r--r-- | core/apps/embeddedkonsole/TEWidget.cpp | 8 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/konsole.cpp | 3 |
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 | |||
@@ -801,425 +801,429 @@ void TEWidget::mouseReleaseEvent(QMouseEvent* ev) | |||
801 | } | 801 | } |
802 | } | 802 | } |
803 | 803 | ||
804 | void TEWidget::mouseDoubleClickEvent(QMouseEvent* ev) | 804 | void 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 | ||
854 | void TEWidget::focusInEvent( QFocusEvent * ) | 854 | void TEWidget::focusInEvent( QFocusEvent * ) |
855 | { | 855 | { |
856 | // do nothing, to prevent repainting | 856 | // do nothing, to prevent repainting |
857 | } | 857 | } |
858 | 858 | ||
859 | 859 | ||
860 | void TEWidget::focusOutEvent( QFocusEvent * ) | 860 | void TEWidget::focusOutEvent( QFocusEvent * ) |
861 | { | 861 | { |
862 | // do nothing, to prevent repainting | 862 | // do nothing, to prevent repainting |
863 | } | 863 | } |
864 | 864 | ||
865 | bool TEWidget::focusNextPrevChild( bool next ) | 865 | bool 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 | ||
874 | int TEWidget::charClass(char ch) const | 874 | int 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 | ||
890 | void TEWidget::setMouseMarks(bool on) | 890 | void 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 | ||
904 | void TEWidget::emitSelection() | 904 | void 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 | ||
919 | void TEWidget::emitText(QString text) | 919 | void 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 | ||
925 | void TEWidget::pasteClipboard( ) | 925 | void TEWidget::pasteClipboard( ) |
926 | { | 926 | { |
927 | emitSelection(); | 927 | emitSelection(); |
928 | } | 928 | } |
929 | 929 | ||
930 | void TEWidget::setSelection(const QString& t) | 930 | void 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 | ||
945 | void TEWidget::onClearSelection() | 945 | void 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 | ||
970 | void TEWidget::doScroll(int lines) | 970 | void TEWidget::doScroll(int lines) |
971 | { | 971 | { |
972 | scrollbar->setValue(scrollbar->value()+lines); | 972 | scrollbar->setValue(scrollbar->value()+lines); |
973 | } | 973 | } |
974 | 974 | ||
975 | bool TEWidget::eventFilter( QObject *obj, QEvent *e ) | 975 | bool 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 | ||
1060 | void TEWidget::frameChanged() | 1064 | void 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 | ||
1072 | void TEWidget::Bell() | 1076 | void 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 | ||
1083 | void TEWidget::clearImage() | 1087 | void 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 | ||
1099 | void TEWidget::calcGeometry() | 1103 | void 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 | ||
1133 | void TEWidget::makeImage() | 1137 | void 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 |
1142 | QSize TEWidget::calcSize(int cols, int lins) const | 1146 | QSize 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 | ||
1150 | QSize TEWidget::sizeHint() const | 1154 | QSize TEWidget::sizeHint() const |
1151 | { | 1155 | { |
1152 | return size(); | 1156 | return size(); |
1153 | } | 1157 | } |
1154 | 1158 | ||
1155 | void TEWidget::styleChange(QStyle &) | 1159 | void 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 | ||
1169 | void TEWidget::dragEnterEvent(QDragEnterEvent* e) | 1173 | void 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 | ||
1175 | void TEWidget::dropEvent(QDropEvent* event) | 1179 | void 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 | } |
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,363 +1,364 @@ | |||
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 | ||
57 | class EKNumTabBar : public QTabBar { | 57 | class EKNumTabBar : public QTabBar { |
58 | public: | 58 | public: |
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 | ||
83 | class EKNumTabWidget : public QTabWidget { | 83 | class EKNumTabWidget : public QTabWidget { |
84 | public: | 84 | public: |
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 |
104 | static const char *commonCmds[] = | 104 | static 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 | ||
167 | Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) : | 167 | Konsole::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 | ||
174 | Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int) | 175 | Konsole::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 | ||
180 | void Konsole::initCommandList() | 181 | void 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 | ||
200 | void Konsole::init(const char* _pgm, QStrList & _args) | 201 | void 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 | } |