author | zecke <zecke> | 2002-11-07 18:31:52 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-11-07 18:31:52 (UTC) |
commit | b89e9179db00b777e41bdd0c95885fb76b3f1a88 (patch) (unidiff) | |
tree | 6b0b6e33d5d084849ab8d7b17ba1c03b74d8a0c9 | |
parent | 8baa44cf756fc3767829983941fc64c9547b8cc0 (diff) | |
download | opie-b89e9179db00b777e41bdd0c95885fb76b3f1a88.zip opie-b89e9179db00b777e41bdd0c95885fb76b3f1a88.tar.gz opie-b89e9179db00b777e41bdd0c95885fb76b3f1a88.tar.bz2 |
Renove Emulationhandler from MetaFactory
common.h clashed with TECommon.h
Implement saving of history!
-rw-r--r-- | noncore/apps/opie-console/TEScreen.cpp | 17 | ||||
-rw-r--r-- | noncore/apps/opie-console/TEScreen.h | 2 | ||||
-rw-r--r-- | noncore/apps/opie-console/TEmulation.cpp | 4 | ||||
-rw-r--r-- | noncore/apps/opie-console/TEmulation.h | 7 | ||||
-rw-r--r-- | noncore/apps/opie-console/emulation_handler.cpp | 3 | ||||
-rw-r--r-- | noncore/apps/opie-console/emulation_handler.h | 1 | ||||
-rw-r--r-- | noncore/apps/opie-console/mainwindow.cpp | 35 | ||||
-rw-r--r-- | noncore/apps/opie-console/mainwindow.h | 1 | ||||
-rw-r--r-- | noncore/apps/opie-console/metafactory.cpp | 25 | ||||
-rw-r--r-- | noncore/apps/opie-console/metafactory.h | 11 |
10 files changed, 64 insertions, 42 deletions
diff --git a/noncore/apps/opie-console/TEScreen.cpp b/noncore/apps/opie-console/TEScreen.cpp index a3d115d..2675d31 100644 --- a/noncore/apps/opie-console/TEScreen.cpp +++ b/noncore/apps/opie-console/TEScreen.cpp | |||
@@ -796,402 +796,413 @@ void TEScreen::clearImage(int loca, int loce, char c) | |||
796 | image[i].c = c; | 796 | image[i].c = c; |
797 | image[i].f = ef_fg; //DEFAULT_FORE_COLOR; //FIXME: xterm and linux/ansi | 797 | image[i].f = ef_fg; //DEFAULT_FORE_COLOR; //FIXME: xterm and linux/ansi |
798 | image[i].b = ef_bg; //DEFAULT_BACK_COLOR; // many have different | 798 | image[i].b = ef_bg; //DEFAULT_BACK_COLOR; // many have different |
799 | image[i].r = ef_re; //DEFAULT_RENDITION; // ideas here. | 799 | image[i].r = ef_re; //DEFAULT_RENDITION; // ideas here. |
800 | } | 800 | } |
801 | } | 801 | } |
802 | 802 | ||
803 | /*! move image between (including) `loca' and `loce' to 'dst'. | 803 | /*! move image between (including) `loca' and `loce' to 'dst'. |
804 | 804 | ||
805 | This is an internal helper functions. The parameter types are internal | 805 | This is an internal helper functions. The parameter types are internal |
806 | addresses of within the screen image and make use of the way how the | 806 | addresses of within the screen image and make use of the way how the |
807 | screen matrix is mapped to the image vector. | 807 | screen matrix is mapped to the image vector. |
808 | */ | 808 | */ |
809 | 809 | ||
810 | void TEScreen::moveImage(int dst, int loca, int loce) | 810 | void TEScreen::moveImage(int dst, int loca, int loce) |
811 | { | 811 | { |
812 | //FIXME: check positions | 812 | //FIXME: check positions |
813 | if (loce < loca) { | 813 | if (loce < loca) { |
814 | // kdDebug() << "WARNING!!! call to TEScreen:moveImage with loce < loca!" << endl; | 814 | // kdDebug() << "WARNING!!! call to TEScreen:moveImage with loce < loca!" << endl; |
815 | return; | 815 | return; |
816 | } | 816 | } |
817 | memmove(&image[dst],&image[loca],(loce-loca+1)*sizeof(ca)); | 817 | memmove(&image[dst],&image[loca],(loce-loca+1)*sizeof(ca)); |
818 | } | 818 | } |
819 | 819 | ||
820 | /*! clear from (including) current cursor position to end of screen. | 820 | /*! clear from (including) current cursor position to end of screen. |
821 | */ | 821 | */ |
822 | 822 | ||
823 | void TEScreen::clearToEndOfScreen() | 823 | void TEScreen::clearToEndOfScreen() |
824 | { | 824 | { |
825 | clearImage(loc(cuX,cuY),loc(columns-1,lines-1),' '); | 825 | clearImage(loc(cuX,cuY),loc(columns-1,lines-1),' '); |
826 | } | 826 | } |
827 | 827 | ||
828 | /*! clear from begin of screen to (including) current cursor position. | 828 | /*! clear from begin of screen to (including) current cursor position. |
829 | */ | 829 | */ |
830 | 830 | ||
831 | void TEScreen::clearToBeginOfScreen() | 831 | void TEScreen::clearToBeginOfScreen() |
832 | { | 832 | { |
833 | clearImage(loc(0,0),loc(cuX,cuY),' '); | 833 | clearImage(loc(0,0),loc(cuX,cuY),' '); |
834 | } | 834 | } |
835 | 835 | ||
836 | /*! clear the entire screen. | 836 | /*! clear the entire screen. |
837 | */ | 837 | */ |
838 | 838 | ||
839 | void TEScreen::clearEntireScreen() | 839 | void TEScreen::clearEntireScreen() |
840 | { | 840 | { |
841 | clearImage(loc(0,0),loc(columns-1,lines-1),' '); | 841 | clearImage(loc(0,0),loc(columns-1,lines-1),' '); |
842 | } | 842 | } |
843 | 843 | ||
844 | /*! fill screen with 'E' | 844 | /*! fill screen with 'E' |
845 | This is to aid screen alignment | 845 | This is to aid screen alignment |
846 | */ | 846 | */ |
847 | 847 | ||
848 | void TEScreen::helpAlign() | 848 | void TEScreen::helpAlign() |
849 | { | 849 | { |
850 | clearImage(loc(0,0),loc(columns-1,lines-1),'E'); | 850 | clearImage(loc(0,0),loc(columns-1,lines-1),'E'); |
851 | } | 851 | } |
852 | 852 | ||
853 | /*! clear from (including) current cursor position to end of current cursor line. | 853 | /*! clear from (including) current cursor position to end of current cursor line. |
854 | */ | 854 | */ |
855 | 855 | ||
856 | void TEScreen::clearToEndOfLine() | 856 | void TEScreen::clearToEndOfLine() |
857 | { | 857 | { |
858 | clearImage(loc(cuX,cuY),loc(columns-1,cuY),' '); | 858 | clearImage(loc(cuX,cuY),loc(columns-1,cuY),' '); |
859 | } | 859 | } |
860 | 860 | ||
861 | /*! clear from begin of current cursor line to (including) current cursor position. | 861 | /*! clear from begin of current cursor line to (including) current cursor position. |
862 | */ | 862 | */ |
863 | 863 | ||
864 | void TEScreen::clearToBeginOfLine() | 864 | void TEScreen::clearToBeginOfLine() |
865 | { | 865 | { |
866 | clearImage(loc(0,cuY),loc(cuX,cuY),' '); | 866 | clearImage(loc(0,cuY),loc(cuX,cuY),' '); |
867 | } | 867 | } |
868 | 868 | ||
869 | /*! clears entire current cursor line | 869 | /*! clears entire current cursor line |
870 | */ | 870 | */ |
871 | 871 | ||
872 | void TEScreen::clearEntireLine() | 872 | void TEScreen::clearEntireLine() |
873 | { | 873 | { |
874 | clearImage(loc(0,cuY),loc(columns-1,cuY),' '); | 874 | clearImage(loc(0,cuY),loc(columns-1,cuY),' '); |
875 | } | 875 | } |
876 | 876 | ||
877 | // Rendition ------------------------------------------------------------------ | 877 | // Rendition ------------------------------------------------------------------ |
878 | 878 | ||
879 | /*! | 879 | /*! |
880 | set rendition mode | 880 | set rendition mode |
881 | */ | 881 | */ |
882 | 882 | ||
883 | void TEScreen::setRendition(int re) | 883 | void TEScreen::setRendition(int re) |
884 | { | 884 | { |
885 | cu_re |= re; | 885 | cu_re |= re; |
886 | effectiveRendition(); | 886 | effectiveRendition(); |
887 | } | 887 | } |
888 | 888 | ||
889 | /*! | 889 | /*! |
890 | reset rendition mode | 890 | reset rendition mode |
891 | */ | 891 | */ |
892 | 892 | ||
893 | void TEScreen::resetRendition(int re) | 893 | void TEScreen::resetRendition(int re) |
894 | { | 894 | { |
895 | cu_re &= ~re; | 895 | cu_re &= ~re; |
896 | effectiveRendition(); | 896 | effectiveRendition(); |
897 | } | 897 | } |
898 | 898 | ||
899 | /*! | 899 | /*! |
900 | */ | 900 | */ |
901 | 901 | ||
902 | void TEScreen::setDefaultRendition() | 902 | void TEScreen::setDefaultRendition() |
903 | { | 903 | { |
904 | setForeColorToDefault(); | 904 | setForeColorToDefault(); |
905 | setBackColorToDefault(); | 905 | setBackColorToDefault(); |
906 | cu_re = DEFAULT_RENDITION; | 906 | cu_re = DEFAULT_RENDITION; |
907 | effectiveRendition(); | 907 | effectiveRendition(); |
908 | } | 908 | } |
909 | 909 | ||
910 | /*! | 910 | /*! |
911 | */ | 911 | */ |
912 | 912 | ||
913 | void TEScreen::setForeColor(int fgcolor) | 913 | void TEScreen::setForeColor(int fgcolor) |
914 | { | 914 | { |
915 | cu_fg = (fgcolor&7)+((fgcolor&8) ? 4+8 : 2); | 915 | cu_fg = (fgcolor&7)+((fgcolor&8) ? 4+8 : 2); |
916 | effectiveRendition(); | 916 | effectiveRendition(); |
917 | } | 917 | } |
918 | 918 | ||
919 | /*! | 919 | /*! |
920 | */ | 920 | */ |
921 | 921 | ||
922 | void TEScreen::setBackColor(int bgcolor) | 922 | void TEScreen::setBackColor(int bgcolor) |
923 | { | 923 | { |
924 | cu_bg = (bgcolor&7)+((bgcolor&8) ? 4+8 : 2); | 924 | cu_bg = (bgcolor&7)+((bgcolor&8) ? 4+8 : 2); |
925 | effectiveRendition(); | 925 | effectiveRendition(); |
926 | } | 926 | } |
927 | 927 | ||
928 | /*! | 928 | /*! |
929 | */ | 929 | */ |
930 | 930 | ||
931 | void TEScreen::setBackColorToDefault() | 931 | void TEScreen::setBackColorToDefault() |
932 | { | 932 | { |
933 | cu_bg = DEFAULT_BACK_COLOR; | 933 | cu_bg = DEFAULT_BACK_COLOR; |
934 | effectiveRendition(); | 934 | effectiveRendition(); |
935 | } | 935 | } |
936 | 936 | ||
937 | /*! | 937 | /*! |
938 | */ | 938 | */ |
939 | 939 | ||
940 | void TEScreen::setForeColorToDefault() | 940 | void TEScreen::setForeColorToDefault() |
941 | { | 941 | { |
942 | cu_fg = DEFAULT_FORE_COLOR; | 942 | cu_fg = DEFAULT_FORE_COLOR; |
943 | effectiveRendition(); | 943 | effectiveRendition(); |
944 | } | 944 | } |
945 | 945 | ||
946 | /* ------------------------------------------------------------------------- */ | 946 | /* ------------------------------------------------------------------------- */ |
947 | /* */ | 947 | /* */ |
948 | /* Marking & Selection */ | 948 | /* Marking & Selection */ |
949 | /* */ | 949 | /* */ |
950 | /* ------------------------------------------------------------------------- */ | 950 | /* ------------------------------------------------------------------------- */ |
951 | 951 | ||
952 | void TEScreen::clearSelection() | 952 | void TEScreen::clearSelection() |
953 | { | 953 | { |
954 | sel_BR = -1; | 954 | sel_BR = -1; |
955 | sel_TL = -1; | 955 | sel_TL = -1; |
956 | sel_begin = -1; | 956 | sel_begin = -1; |
957 | } | 957 | } |
958 | 958 | ||
959 | void TEScreen::setSelBeginXY(const int x, const int y) | 959 | void TEScreen::setSelBeginXY(const int x, const int y) |
960 | { | 960 | { |
961 | sel_begin = loc(x,y+histCursor) ; | 961 | sel_begin = loc(x,y+histCursor) ; |
962 | sel_BR = sel_begin; | 962 | sel_BR = sel_begin; |
963 | sel_TL = sel_begin; | 963 | sel_TL = sel_begin; |
964 | } | 964 | } |
965 | 965 | ||
966 | void TEScreen::setSelExtentXY(const int x, const int y) | 966 | void TEScreen::setSelExtentXY(const int x, const int y) |
967 | { | 967 | { |
968 | if (sel_begin == -1) return; | 968 | if (sel_begin == -1) return; |
969 | int l = loc(x,y + histCursor); | 969 | int l = loc(x,y + histCursor); |
970 | 970 | ||
971 | if (l < sel_begin) | 971 | if (l < sel_begin) |
972 | { | 972 | { |
973 | sel_TL = l; | 973 | sel_TL = l; |
974 | sel_BR = sel_begin; | 974 | sel_BR = sel_begin; |
975 | } | 975 | } |
976 | else | 976 | else |
977 | { | 977 | { |
978 | /* FIXME, HACK to correct for x too far to the right... */ | 978 | /* FIXME, HACK to correct for x too far to the right... */ |
979 | if (( x == columns )|| (x == 0)) l--; | 979 | if (( x == columns )|| (x == 0)) l--; |
980 | 980 | ||
981 | sel_TL = sel_begin; | 981 | sel_TL = sel_begin; |
982 | sel_BR = l; | 982 | sel_BR = l; |
983 | } | 983 | } |
984 | } | 984 | } |
985 | 985 | ||
986 | QString TEScreen::getSelText(const BOOL preserve_line_breaks) | 986 | QString TEScreen::getSelText(const BOOL preserve_line_breaks) |
987 | { | 987 | { |
988 | if (sel_begin == -1) | 988 | if (sel_begin == -1) |
989 | return QString::null; // Selection got clear while selecting. | 989 | return QString::null; // Selection got clear while selecting. |
990 | 990 | ||
991 | int *m; // buffer to fill. | 991 | int *m; // buffer to fill. |
992 | int s, d; // source index, dest. index. | 992 | int s, d; // source index, dest. index. |
993 | int hist_BR = loc(0, hist.getLines()); | 993 | int hist_BR = loc(0, hist.getLines()); |
994 | int hY = sel_TL / columns; | 994 | int hY = sel_TL / columns; |
995 | int hX = sel_TL % columns; | 995 | int hX = sel_TL % columns; |
996 | int eol; // end of line | 996 | int eol; // end of line |
997 | 997 | ||
998 | s = sel_TL; // tracks copy in source. | 998 | s = sel_TL; // tracks copy in source. |
999 | 999 | ||
1000 | // allocate buffer for maximum | 1000 | // allocate buffer for maximum |
1001 | // possible size... | 1001 | // possible size... |
1002 | d = (sel_BR - sel_TL) / columns + 1; | 1002 | d = (sel_BR - sel_TL) / columns + 1; |
1003 | m = new int[d * (columns + 1) + 2]; | 1003 | m = new int[d * (columns + 1) + 2]; |
1004 | d = 0; | 1004 | d = 0; |
1005 | 1005 | ||
1006 | while (s <= sel_BR) | 1006 | while (s <= sel_BR) |
1007 | { | 1007 | { |
1008 | if (s < hist_BR) | 1008 | if (s < hist_BR) |
1009 | { // get lines from hist.history | 1009 | { // get lines from hist.history |
1010 | // buffer. | 1010 | // buffer. |
1011 | eol = hist.getLineLen(hY); | 1011 | eol = hist.getLineLen(hY); |
1012 | 1012 | ||
1013 | if ((hY == (sel_BR / columns)) && | 1013 | if ((hY == (sel_BR / columns)) && |
1014 | (eol >= (sel_BR % columns))) | 1014 | (eol >= (sel_BR % columns))) |
1015 | { | 1015 | { |
1016 | eol = sel_BR % columns + 1; | 1016 | eol = sel_BR % columns + 1; |
1017 | } | 1017 | } |
1018 | 1018 | ||
1019 | while (hX < eol) | 1019 | while (hX < eol) |
1020 | { | 1020 | { |
1021 | m[d++] = hist.getCell(hY, hX++).c; | 1021 | m[d++] = hist.getCell(hY, hX++).c; |
1022 | s++; | 1022 | s++; |
1023 | } | 1023 | } |
1024 | 1024 | ||
1025 | if (s <= sel_BR) | 1025 | if (s <= sel_BR) |
1026 | { | 1026 | { |
1027 | // The line break handling | 1027 | // The line break handling |
1028 | // It's different from the screen | 1028 | // It's different from the screen |
1029 | // image case! | 1029 | // image case! |
1030 | if (eol % columns == 0) | 1030 | if (eol % columns == 0) |
1031 | { | 1031 | { |
1032 | // That's either a completely filled | 1032 | // That's either a completely filled |
1033 | // line or an empty line | 1033 | // line or an empty line |
1034 | if (eol == 0) | 1034 | if (eol == 0) |
1035 | { | 1035 | { |
1036 | m[d++] = '\n'; | 1036 | m[d++] = '\n'; |
1037 | } | 1037 | } |
1038 | else | 1038 | else |
1039 | { | 1039 | { |
1040 | // We have a full line. | 1040 | // We have a full line. |
1041 | // FIXME: How can we handle newlines | 1041 | // FIXME: How can we handle newlines |
1042 | // at this position?! | 1042 | // at this position?! |
1043 | } | 1043 | } |
1044 | } | 1044 | } |
1045 | else if ((eol + 1) % columns == 0) | 1045 | else if ((eol + 1) % columns == 0) |
1046 | { | 1046 | { |
1047 | // FIXME: We don't know if this was a | 1047 | // FIXME: We don't know if this was a |
1048 | // space at the last position or a | 1048 | // space at the last position or a |
1049 | // short line!! | 1049 | // short line!! |
1050 | m[d++] = ' '; | 1050 | m[d++] = ' '; |
1051 | } | 1051 | } |
1052 | else | 1052 | else |
1053 | { | 1053 | { |
1054 | // We have a short line here. Put a | 1054 | // We have a short line here. Put a |
1055 | // newline or a space into the | 1055 | // newline or a space into the |
1056 | // buffer. | 1056 | // buffer. |
1057 | m[d++] = preserve_line_breaks ? '\n' : ' '; | 1057 | m[d++] = preserve_line_breaks ? '\n' : ' '; |
1058 | } | 1058 | } |
1059 | } | 1059 | } |
1060 | 1060 | ||
1061 | hY++; | 1061 | hY++; |
1062 | hX = 0; | 1062 | hX = 0; |
1063 | s = hY * columns; | 1063 | s = hY * columns; |
1064 | } | 1064 | } |
1065 | else | 1065 | else |
1066 | { // or from screen image. | 1066 | { // or from screen image. |
1067 | eol = (s / columns + 1) * columns - 1; | 1067 | eol = (s / columns + 1) * columns - 1; |
1068 | 1068 | ||
1069 | if (eol < sel_BR) | 1069 | if (eol < sel_BR) |
1070 | { | 1070 | { |
1071 | while ((eol > s) && | 1071 | while ((eol > s) && |
1072 | isspace(image[eol - hist_BR].c)) | 1072 | isspace(image[eol - hist_BR].c)) |
1073 | { | 1073 | { |
1074 | eol--; | 1074 | eol--; |
1075 | } | 1075 | } |
1076 | } | 1076 | } |
1077 | else | 1077 | else |
1078 | { | 1078 | { |
1079 | eol = sel_BR; | 1079 | eol = sel_BR; |
1080 | } | 1080 | } |
1081 | 1081 | ||
1082 | while (s <= eol) | 1082 | while (s <= eol) |
1083 | { | 1083 | { |
1084 | m[d++] = image[s++ - hist_BR].c; | 1084 | m[d++] = image[s++ - hist_BR].c; |
1085 | } | 1085 | } |
1086 | 1086 | ||
1087 | if (eol < sel_BR) | 1087 | if (eol < sel_BR) |
1088 | { | 1088 | { |
1089 | // eol processing see below ... | 1089 | // eol processing see below ... |
1090 | if ((eol + 1) % columns == 0) | 1090 | if ((eol + 1) % columns == 0) |
1091 | { | 1091 | { |
1092 | if (image[eol - hist_BR].c == ' ') | 1092 | if (image[eol - hist_BR].c == ' ') |
1093 | { | 1093 | { |
1094 | m[d++] = ' '; | 1094 | m[d++] = ' '; |
1095 | } | 1095 | } |
1096 | } | 1096 | } |
1097 | else | 1097 | else |
1098 | { | 1098 | { |
1099 | m[d++] = ((preserve_line_breaks || | 1099 | m[d++] = ((preserve_line_breaks || |
1100 | ((eol % columns) == 0)) ? | 1100 | ((eol % columns) == 0)) ? |
1101 | '\n' : ' '); | 1101 | '\n' : ' '); |
1102 | } | 1102 | } |
1103 | } | 1103 | } |
1104 | 1104 | ||
1105 | s = (eol / columns + 1) * columns; | 1105 | s = (eol / columns + 1) * columns; |
1106 | } | 1106 | } |
1107 | } | 1107 | } |
1108 | 1108 | ||
1109 | QChar* qc = new QChar[d]; | 1109 | QChar* qc = new QChar[d]; |
1110 | 1110 | ||
1111 | for (int i = 0; i < d; i++) | 1111 | for (int i = 0; i < d; i++) |
1112 | { | 1112 | { |
1113 | qc[i] = m[i]; | 1113 | qc[i] = m[i]; |
1114 | } | 1114 | } |
1115 | 1115 | ||
1116 | QString res(qc, d); | 1116 | QString res(qc, d); |
1117 | 1117 | ||
1118 | delete m; | 1118 | delete m; |
1119 | delete qc; | 1119 | delete qc; |
1120 | 1120 | ||
1121 | return res; | 1121 | return res; |
1122 | } | 1122 | } |
1123 | QString TEScreen::getHistory() { | ||
1124 | sel_begin = 0; | ||
1125 | sel_BR = sel_begin; | ||
1126 | sel_TL = sel_begin; | ||
1127 | setSelExtentXY(columns-1,lines-1); | ||
1128 | QString tmp=getSelText(true); | ||
1129 | while (tmp.at(tmp.length()-2).unicode()==10 && tmp.at(tmp.length()-1).unicode()==10) | ||
1130 | tmp.truncate(tmp.length()-1); | ||
1131 | |||
1132 | return tmp; | ||
1133 | } | ||
1123 | /* above ... end of line processing for selection -- psilva | 1134 | /* above ... end of line processing for selection -- psilva |
1124 | cases: | 1135 | cases: |
1125 | 1136 | ||
1126 | 1) (eol+1)%columns == 0 --> the whole line is filled. | 1137 | 1) (eol+1)%columns == 0 --> the whole line is filled. |
1127 | If the last char is a space, insert (preserve) space. otherwise | 1138 | If the last char is a space, insert (preserve) space. otherwise |
1128 | leave the text alone, so that words that are broken by linewrap | 1139 | leave the text alone, so that words that are broken by linewrap |
1129 | are preserved. | 1140 | are preserved. |
1130 | 1141 | ||
1131 | FIXME: | 1142 | FIXME: |
1132 | * this suppresses \n for command output that is | 1143 | * this suppresses \n for command output that is |
1133 | sized to the exact column width of the screen. | 1144 | sized to the exact column width of the screen. |
1134 | 1145 | ||
1135 | 2) eol%columns == 0 --> blank line. | 1146 | 2) eol%columns == 0 --> blank line. |
1136 | insert a \n unconditionally. | 1147 | insert a \n unconditionally. |
1137 | Do it either you would because you are in preserve_line_break mode, | 1148 | Do it either you would because you are in preserve_line_break mode, |
1138 | or because it's an ASCII paragraph delimiter, so even when | 1149 | or because it's an ASCII paragraph delimiter, so even when |
1139 | not preserving line_breaks, you want to preserve paragraph breaks. | 1150 | not preserving line_breaks, you want to preserve paragraph breaks. |
1140 | 1151 | ||
1141 | 3) else --> partially filled line | 1152 | 3) else --> partially filled line |
1142 | insert a \n in preserve line break mode, else a space | 1153 | insert a \n in preserve line break mode, else a space |
1143 | The space prevents concatenation of the last word of one | 1154 | The space prevents concatenation of the last word of one |
1144 | line with the first of the next. | 1155 | line with the first of the next. |
1145 | 1156 | ||
1146 | */ | 1157 | */ |
1147 | 1158 | ||
1148 | void TEScreen::addHistLine() | 1159 | void TEScreen::addHistLine() |
1149 | { | 1160 | { |
1150 | assert(hasScroll() || histCursor == 0); | 1161 | assert(hasScroll() || histCursor == 0); |
1151 | 1162 | ||
1152 | // add to hist buffer | 1163 | // add to hist buffer |
1153 | // we have to take care about scrolling, too... | 1164 | // we have to take care about scrolling, too... |
1154 | 1165 | ||
1155 | if (hasScroll()) | 1166 | if (hasScroll()) |
1156 | { ca dft; | 1167 | { ca dft; |
1157 | 1168 | ||
1158 | int end = columns-1; | 1169 | int end = columns-1; |
1159 | while (end >= 0 && image[end] == dft) | 1170 | while (end >= 0 && image[end] == dft) |
1160 | end -= 1; | 1171 | end -= 1; |
1161 | 1172 | ||
1162 | hist.addCells(image,end+1); | 1173 | hist.addCells(image,end+1); |
1163 | hist.addLine(); | 1174 | hist.addLine(); |
1164 | 1175 | ||
1165 | // adjust history cursor | 1176 | // adjust history cursor |
1166 | histCursor += (hist.getLines()-1 == histCursor); | 1177 | histCursor += (hist.getLines()-1 == histCursor); |
1167 | } | 1178 | } |
1168 | 1179 | ||
1169 | if (!hasScroll()) histCursor = 0; //FIXME: a poor workaround | 1180 | if (!hasScroll()) histCursor = 0; //FIXME: a poor workaround |
1170 | } | 1181 | } |
1171 | 1182 | ||
1172 | void TEScreen::setHistCursor(int cursor) | 1183 | void TEScreen::setHistCursor(int cursor) |
1173 | { | 1184 | { |
1174 | histCursor = cursor; //FIXME:rangecheck | 1185 | histCursor = cursor; //FIXME:rangecheck |
1175 | } | 1186 | } |
1176 | 1187 | ||
1177 | int TEScreen::getHistCursor() | 1188 | int TEScreen::getHistCursor() |
1178 | { | 1189 | { |
1179 | return histCursor; | 1190 | return histCursor; |
1180 | } | 1191 | } |
1181 | 1192 | ||
1182 | int TEScreen::getHistLines() | 1193 | int TEScreen::getHistLines() |
1183 | { | 1194 | { |
1184 | return hist.getLines(); | 1195 | return hist.getLines(); |
1185 | } | 1196 | } |
1186 | 1197 | ||
1187 | void TEScreen::setScroll(bool on) | 1198 | void TEScreen::setScroll(bool on) |
1188 | { | 1199 | { |
1189 | histCursor = 0; | 1200 | histCursor = 0; |
1190 | clearSelection(); | 1201 | clearSelection(); |
1191 | hist.setScroll(on); | 1202 | hist.setScroll(on); |
1192 | } | 1203 | } |
1193 | 1204 | ||
1194 | bool TEScreen::hasScroll() | 1205 | bool TEScreen::hasScroll() |
1195 | { | 1206 | { |
1196 | return hist.hasScroll(); | 1207 | return hist.hasScroll(); |
1197 | } | 1208 | } |
diff --git a/noncore/apps/opie-console/TEScreen.h b/noncore/apps/opie-console/TEScreen.h index 473ce79..a840b44 100644 --- a/noncore/apps/opie-console/TEScreen.h +++ b/noncore/apps/opie-console/TEScreen.h | |||
@@ -1,259 +1,261 @@ | |||
1 | /* -------------------------------------------------------------------------- */ | 1 | /* -------------------------------------------------------------------------- */ |
2 | /* */ | 2 | /* */ |
3 | /* [te_screen.h] Screen Data Type */ | 3 | /* [te_screen.h] Screen Data Type */ |
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 for KDE */ | 9 | /* This file is part of Konsole - an X terminal for KDE */ |
10 | /* */ | 10 | /* */ |
11 | /* -------------------------------------------------------------------------- */ | 11 | /* -------------------------------------------------------------------------- */ |
12 | /* */ | 12 | /* */ |
13 | /* Ported Konsole to Qt/Embedded */ | 13 | /* Ported Konsole to Qt/Embedded */ |
14 | /* */ | 14 | /* */ |
15 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ | 15 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ |
16 | /* */ | 16 | /* */ |
17 | /* -------------------------------------------------------------------------- */ | 17 | /* -------------------------------------------------------------------------- */ |
18 | 18 | ||
19 | #ifndef TESCREEN_H | 19 | #ifndef TESCREEN_H |
20 | #define TESCREEN_H | 20 | #define TESCREEN_H |
21 | 21 | ||
22 | /*! \file | 22 | /*! \file |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include "TECommon.h" | 25 | #include "TECommon.h" |
26 | #include "TEHistory.h" | 26 | #include "TEHistory.h" |
27 | 27 | ||
28 | #define MODE_Origin 0 | 28 | #define MODE_Origin 0 |
29 | #define MODE_Wrap 1 | 29 | #define MODE_Wrap 1 |
30 | #define MODE_Insert 2 | 30 | #define MODE_Insert 2 |
31 | #define MODE_Screen 3 | 31 | #define MODE_Screen 3 |
32 | #define MODE_Cursor 4 | 32 | #define MODE_Cursor 4 |
33 | #define MODE_NewLine 5 | 33 | #define MODE_NewLine 5 |
34 | #define MODES_SCREEN 6 | 34 | #define MODES_SCREEN 6 |
35 | 35 | ||
36 | /*! | 36 | /*! |
37 | */ | 37 | */ |
38 | struct ScreenParm | 38 | struct ScreenParm |
39 | { | 39 | { |
40 | int mode[MODES_SCREEN]; | 40 | int mode[MODES_SCREEN]; |
41 | }; | 41 | }; |
42 | 42 | ||
43 | 43 | ||
44 | class TEScreen | 44 | class TEScreen |
45 | { | 45 | { |
46 | public: | 46 | public: |
47 | TEScreen(int lines, int columns); | 47 | TEScreen(int lines, int columns); |
48 | ~TEScreen(); | 48 | ~TEScreen(); |
49 | 49 | ||
50 | public: // these are all `Screen' operations | 50 | public: // these are all `Screen' operations |
51 | // | 51 | // |
52 | // VT100/2 Operations ------------------ | 52 | // VT100/2 Operations ------------------ |
53 | // | 53 | // |
54 | // Cursor Movement | 54 | // Cursor Movement |
55 | // | 55 | // |
56 | void cursorUp (int n); | 56 | void cursorUp (int n); |
57 | void cursorDown (int n); | 57 | void cursorDown (int n); |
58 | void cursorLeft (int n); | 58 | void cursorLeft (int n); |
59 | void cursorRight (int n); | 59 | void cursorRight (int n); |
60 | void setCursorY (int y); | 60 | void setCursorY (int y); |
61 | void setCursorX (int x); | 61 | void setCursorX (int x); |
62 | void setCursorYX (int y, int x); | 62 | void setCursorYX (int y, int x); |
63 | void setMargins (int t, int b); | 63 | void setMargins (int t, int b); |
64 | // | 64 | // |
65 | // Cursor Movement with Scrolling | 65 | // Cursor Movement with Scrolling |
66 | // | 66 | // |
67 | void NewLine (); | 67 | void NewLine (); |
68 | void NextLine (); | 68 | void NextLine (); |
69 | void index (); | 69 | void index (); |
70 | void reverseIndex(); | 70 | void reverseIndex(); |
71 | // | 71 | // |
72 | void Return (); | 72 | void Return (); |
73 | void BackSpace (); | 73 | void BackSpace (); |
74 | void Tabulate (); | 74 | void Tabulate (); |
75 | // | 75 | // |
76 | // Editing | 76 | // Editing |
77 | // | 77 | // |
78 | void eraseChars (int n); | 78 | void eraseChars (int n); |
79 | void deleteChars (int n); | 79 | void deleteChars (int n); |
80 | void insertChars (int n); | 80 | void insertChars (int n); |
81 | void deleteLines (int n); | 81 | void deleteLines (int n); |
82 | void insertLines (int n); | 82 | void insertLines (int n); |
83 | // | 83 | // |
84 | // ------------------------------------- | 84 | // ------------------------------------- |
85 | // | 85 | // |
86 | void clearTabStops(); | 86 | void clearTabStops(); |
87 | void changeTabStop(bool set); | 87 | void changeTabStop(bool set); |
88 | // | 88 | // |
89 | void resetMode (int n); | 89 | void resetMode (int n); |
90 | void setMode (int n); | 90 | void setMode (int n); |
91 | void saveMode (int n); | 91 | void saveMode (int n); |
92 | void restoreMode (int n); | 92 | void restoreMode (int n); |
93 | // | 93 | // |
94 | void saveCursor (); | 94 | void saveCursor (); |
95 | void restoreCursor(); | 95 | void restoreCursor(); |
96 | // | 96 | // |
97 | // ------------------------------------- | 97 | // ------------------------------------- |
98 | // | 98 | // |
99 | void clearEntireScreen(); | 99 | void clearEntireScreen(); |
100 | void clearToEndOfScreen(); | 100 | void clearToEndOfScreen(); |
101 | void clearToBeginOfScreen(); | 101 | void clearToBeginOfScreen(); |
102 | // | 102 | // |
103 | void clearEntireLine(); | 103 | void clearEntireLine(); |
104 | void clearToEndOfLine(); | 104 | void clearToEndOfLine(); |
105 | void clearToBeginOfLine(); | 105 | void clearToBeginOfLine(); |
106 | // | 106 | // |
107 | void helpAlign (); | 107 | void helpAlign (); |
108 | // | 108 | // |
109 | // ------------------------------------- | 109 | // ------------------------------------- |
110 | // | 110 | // |
111 | void setRendition (int rendition); | 111 | void setRendition (int rendition); |
112 | void resetRendition(int rendition); | 112 | void resetRendition(int rendition); |
113 | void setForeColor (int fgcolor); | 113 | void setForeColor (int fgcolor); |
114 | void setBackColor (int bgcolor); | 114 | void setBackColor (int bgcolor); |
115 | // | 115 | // |
116 | void setDefaultRendition(); | 116 | void setDefaultRendition(); |
117 | void setForeColorToDefault(); | 117 | void setForeColorToDefault(); |
118 | void setBackColorToDefault(); | 118 | void setBackColorToDefault(); |
119 | // | 119 | // |
120 | // ------------------------------------- | 120 | // ------------------------------------- |
121 | // | 121 | // |
122 | BOOL getMode (int n); | 122 | BOOL getMode (int n); |
123 | // | 123 | // |
124 | // only for report cursor position | 124 | // only for report cursor position |
125 | // | 125 | // |
126 | int getCursorX(); | 126 | int getCursorX(); |
127 | int getCursorY(); | 127 | int getCursorY(); |
128 | // | 128 | // |
129 | // ------------------------------------- | 129 | // ------------------------------------- |
130 | // | 130 | // |
131 | void clear(); | 131 | void clear(); |
132 | void home(); | 132 | void home(); |
133 | void reset(); | 133 | void reset(); |
134 | // | 134 | // |
135 | void ShowCharacter(unsigned short c); | 135 | void ShowCharacter(unsigned short c); |
136 | // | 136 | // |
137 | void resizeImage(int new_lines, int new_columns); | 137 | void resizeImage(int new_lines, int new_columns); |
138 | // | 138 | // |
139 | ca* getCookedImage(); | 139 | ca* getCookedImage(); |
140 | 140 | ||
141 | /*! return the number of lines. */ | 141 | /*! return the number of lines. */ |
142 | int getLines() { return lines; } | 142 | int getLines() { return lines; } |
143 | /*! return the number of columns. */ | 143 | /*! return the number of columns. */ |
144 | int getColumns() { return columns; } | 144 | int getColumns() { return columns; } |
145 | 145 | ||
146 | /*! set the position of the history cursor. */ | 146 | /*! set the position of the history cursor. */ |
147 | void setHistCursor(int cursor); | 147 | void setHistCursor(int cursor); |
148 | /*! return the position of the history cursor. */ | 148 | /*! return the position of the history cursor. */ |
149 | int getHistCursor(); | 149 | int getHistCursor(); |
150 | 150 | ||
151 | int getHistLines (); | 151 | int getHistLines (); |
152 | void setScroll(bool on); | 152 | void setScroll(bool on); |
153 | bool hasScroll(); | 153 | bool hasScroll(); |
154 | 154 | ||
155 | // | 155 | // |
156 | // Selection | 156 | // Selection |
157 | // | 157 | // |
158 | void setSelBeginXY(const int x, const int y); | 158 | void setSelBeginXY(const int x, const int y); |
159 | void setSelExtentXY(const int x, const int y); | 159 | void setSelExtentXY(const int x, const int y); |
160 | void clearSelection(); | 160 | void clearSelection(); |
161 | QString getSelText(const BOOL preserve_line_breaks); | 161 | QString getSelText(const BOOL preserve_line_breaks); |
162 | 162 | ||
163 | void checkSelection(int from, int to); | 163 | void checkSelection(int from, int to); |
164 | 164 | ||
165 | QString getHistory(); | ||
166 | |||
165 | private: // helper | 167 | private: // helper |
166 | 168 | ||
167 | void clearImage(int loca, int loce, char c); | 169 | void clearImage(int loca, int loce, char c); |
168 | void moveImage(int dst, int loca, int loce); | 170 | void moveImage(int dst, int loca, int loce); |
169 | 171 | ||
170 | void scrollUp(int from, int i); | 172 | void scrollUp(int from, int i); |
171 | void scrollDown(int from, int i); | 173 | void scrollDown(int from, int i); |
172 | 174 | ||
173 | void addHistLine(); | 175 | void addHistLine(); |
174 | 176 | ||
175 | void initTabStops(); | 177 | void initTabStops(); |
176 | 178 | ||
177 | void effectiveRendition(); | 179 | void effectiveRendition(); |
178 | void reverseRendition(ca* p); | 180 | void reverseRendition(ca* p); |
179 | 181 | ||
180 | private: | 182 | private: |
181 | 183 | ||
182 | /* | 184 | /* |
183 | The state of the screen is more complex as one would | 185 | The state of the screen is more complex as one would |
184 | expect first. The screem does really do part of the | 186 | expect first. The screem does really do part of the |
185 | emulation providing state informations in form of modes, | 187 | emulation providing state informations in form of modes, |
186 | margins, tabulators, cursor etc. | 188 | margins, tabulators, cursor etc. |
187 | 189 | ||
188 | Even more unexpected are variables to save and restore | 190 | Even more unexpected are variables to save and restore |
189 | parts of the state. | 191 | parts of the state. |
190 | */ | 192 | */ |
191 | 193 | ||
192 | // screen image ---------------- | 194 | // screen image ---------------- |
193 | 195 | ||
194 | int lines; | 196 | int lines; |
195 | int columns; | 197 | int columns; |
196 | ca *image; // [lines][columns] | 198 | ca *image; // [lines][columns] |
197 | 199 | ||
198 | // history buffer --------------- | 200 | // history buffer --------------- |
199 | 201 | ||
200 | int histCursor; // display position relative to start of the history buffer | 202 | int histCursor; // display position relative to start of the history buffer |
201 | HistoryScroll hist; | 203 | HistoryScroll hist; |
202 | 204 | ||
203 | // cursor location | 205 | // cursor location |
204 | 206 | ||
205 | int cuX; | 207 | int cuX; |
206 | int cuY; | 208 | int cuY; |
207 | 209 | ||
208 | // cursor color and rendition info | 210 | // cursor color and rendition info |
209 | 211 | ||
210 | UINT8 cu_fg; // foreground | 212 | UINT8 cu_fg; // foreground |
211 | UINT8 cu_bg; // background | 213 | UINT8 cu_bg; // background |
212 | UINT8 cu_re; // rendition | 214 | UINT8 cu_re; // rendition |
213 | 215 | ||
214 | // margins ---------------- | 216 | // margins ---------------- |
215 | 217 | ||
216 | int tmargin; // top margin | 218 | int tmargin; // top margin |
217 | int bmargin; // bottom margin | 219 | int bmargin; // bottom margin |
218 | 220 | ||
219 | // states ---------------- | 221 | // states ---------------- |
220 | 222 | ||
221 | ScreenParm currParm; | 223 | ScreenParm currParm; |
222 | 224 | ||
223 | // ---------------------------- | 225 | // ---------------------------- |
224 | 226 | ||
225 | bool* tabstops; | 227 | bool* tabstops; |
226 | 228 | ||
227 | // selection ------------------- | 229 | // selection ------------------- |
228 | 230 | ||
229 | int sel_begin; // The first location selected. | 231 | int sel_begin; // The first location selected. |
230 | int sel_TL; // TopLeft Location. | 232 | int sel_TL; // TopLeft Location. |
231 | int sel_BR; // Bottom Right Location. | 233 | int sel_BR; // Bottom Right Location. |
232 | 234 | ||
233 | // effective colors and rendition ------------ | 235 | // effective colors and rendition ------------ |
234 | 236 | ||
235 | UINT8 ef_fg; // These are derived from | 237 | UINT8 ef_fg; // These are derived from |
236 | UINT8 ef_bg; // the cu_* variables above | 238 | UINT8 ef_bg; // the cu_* variables above |
237 | UINT8 ef_re; // to speed up operation | 239 | UINT8 ef_re; // to speed up operation |
238 | 240 | ||
239 | // | 241 | // |
240 | // save cursor, rendition & states ------------ | 242 | // save cursor, rendition & states ------------ |
241 | // | 243 | // |
242 | 244 | ||
243 | // cursor location | 245 | // cursor location |
244 | 246 | ||
245 | int sa_cuX; | 247 | int sa_cuX; |
246 | int sa_cuY; | 248 | int sa_cuY; |
247 | 249 | ||
248 | // rendition info | 250 | // rendition info |
249 | 251 | ||
250 | UINT8 sa_cu_re; | 252 | UINT8 sa_cu_re; |
251 | UINT8 sa_cu_fg; | 253 | UINT8 sa_cu_fg; |
252 | UINT8 sa_cu_bg; | 254 | UINT8 sa_cu_bg; |
253 | 255 | ||
254 | // modes | 256 | // modes |
255 | 257 | ||
256 | ScreenParm saveParm; | 258 | ScreenParm saveParm; |
257 | }; | 259 | }; |
258 | 260 | ||
259 | #endif // TESCREEN_H | 261 | #endif // TESCREEN_H |
diff --git a/noncore/apps/opie-console/TEmulation.cpp b/noncore/apps/opie-console/TEmulation.cpp index 7a0c624..3b1b9e1 100644 --- a/noncore/apps/opie-console/TEmulation.cpp +++ b/noncore/apps/opie-console/TEmulation.cpp | |||
@@ -82,283 +82,285 @@ | |||
82 | /* */ | 82 | /* */ |
83 | /* TEmulation */ | 83 | /* TEmulation */ |
84 | /* */ | 84 | /* */ |
85 | /* ------------------------------------------------------------------------- */ | 85 | /* ------------------------------------------------------------------------- */ |
86 | 86 | ||
87 | #define CNTL(c) ((c)-'@') | 87 | #define CNTL(c) ((c)-'@') |
88 | 88 | ||
89 | /*! | 89 | /*! |
90 | */ | 90 | */ |
91 | 91 | ||
92 | TEmulation::TEmulation(TEWidget* gui) | 92 | TEmulation::TEmulation(TEWidget* gui) |
93 | : decoder((QTextDecoder*)NULL) | 93 | : decoder((QTextDecoder*)NULL) |
94 | { | 94 | { |
95 | this->gui = gui; | 95 | this->gui = gui; |
96 | 96 | ||
97 | screen[0] = new TEScreen(gui->Lines(),gui->Columns()); | 97 | screen[0] = new TEScreen(gui->Lines(),gui->Columns()); |
98 | screen[1] = new TEScreen(gui->Lines(),gui->Columns()); | 98 | screen[1] = new TEScreen(gui->Lines(),gui->Columns()); |
99 | scr = screen[0]; | 99 | scr = screen[0]; |
100 | 100 | ||
101 | bulk_nlcnt = 0; // reset bulk newline counter | 101 | bulk_nlcnt = 0; // reset bulk newline counter |
102 | bulk_incnt = 0; // reset bulk counter | 102 | bulk_incnt = 0; // reset bulk counter |
103 | connected = FALSE; | 103 | connected = FALSE; |
104 | 104 | ||
105 | QObject::connect(&bulk_timer, SIGNAL(timeout()), this, SLOT(showBulk()) ); | 105 | QObject::connect(&bulk_timer, SIGNAL(timeout()), this, SLOT(showBulk()) ); |
106 | QObject::connect(gui,SIGNAL(changedImageSizeSignal(int,int)), | 106 | QObject::connect(gui,SIGNAL(changedImageSizeSignal(int,int)), |
107 | this,SLOT(onImageSizeChange(int,int))); | 107 | this,SLOT(onImageSizeChange(int,int))); |
108 | QObject::connect(gui,SIGNAL(changedHistoryCursor(int)), | 108 | QObject::connect(gui,SIGNAL(changedHistoryCursor(int)), |
109 | this,SLOT(onHistoryCursorChange(int))); | 109 | this,SLOT(onHistoryCursorChange(int))); |
110 | QObject::connect(gui,SIGNAL(keyPressedSignal(QKeyEvent*)), | 110 | QObject::connect(gui,SIGNAL(keyPressedSignal(QKeyEvent*)), |
111 | this,SLOT(onKeyPress(QKeyEvent*))); | 111 | this,SLOT(onKeyPress(QKeyEvent*))); |
112 | QObject::connect(gui,SIGNAL(beginSelectionSignal(const int,const int)), | 112 | QObject::connect(gui,SIGNAL(beginSelectionSignal(const int,const int)), |
113 | this,SLOT(onSelectionBegin(const int,const int)) ); | 113 | this,SLOT(onSelectionBegin(const int,const int)) ); |
114 | QObject::connect(gui,SIGNAL(extendSelectionSignal(const int,const int)), | 114 | QObject::connect(gui,SIGNAL(extendSelectionSignal(const int,const int)), |
115 | this,SLOT(onSelectionExtend(const int,const int)) ); | 115 | this,SLOT(onSelectionExtend(const int,const int)) ); |
116 | QObject::connect(gui,SIGNAL(endSelectionSignal(const BOOL)), | 116 | QObject::connect(gui,SIGNAL(endSelectionSignal(const BOOL)), |
117 | this,SLOT(setSelection(const BOOL)) ); | 117 | this,SLOT(setSelection(const BOOL)) ); |
118 | QObject::connect(gui,SIGNAL(clearSelectionSignal()), | 118 | QObject::connect(gui,SIGNAL(clearSelectionSignal()), |
119 | this,SLOT(clearSelection()) ); | 119 | this,SLOT(clearSelection()) ); |
120 | } | 120 | } |
121 | 121 | ||
122 | /*! | 122 | /*! |
123 | */ | 123 | */ |
124 | 124 | ||
125 | TEmulation::~TEmulation() | 125 | TEmulation::~TEmulation() |
126 | { | 126 | { |
127 | delete screen[0]; | 127 | delete screen[0]; |
128 | delete screen[1]; | 128 | delete screen[1]; |
129 | bulk_timer.stop(); | 129 | bulk_timer.stop(); |
130 | } | 130 | } |
131 | 131 | ||
132 | /*! change between primary and alternate screen | 132 | /*! change between primary and alternate screen |
133 | */ | 133 | */ |
134 | 134 | ||
135 | void TEmulation::setScreen(int n) | 135 | void TEmulation::setScreen(int n) |
136 | { | 136 | { |
137 | scr = screen[n&1]; | 137 | scr = screen[n&1]; |
138 | } | 138 | } |
139 | 139 | ||
140 | void TEmulation::setHistory(bool on) | 140 | void TEmulation::setHistory(bool on) |
141 | { | 141 | { |
142 | screen[0]->setScroll(on); | 142 | screen[0]->setScroll(on); |
143 | if (!connected) return; | 143 | if (!connected) return; |
144 | showBulk(); | 144 | showBulk(); |
145 | } | 145 | } |
146 | 146 | ||
147 | bool TEmulation::history() | 147 | bool TEmulation::history() |
148 | { | 148 | { |
149 | return screen[0]->hasScroll(); | 149 | return screen[0]->hasScroll(); |
150 | } | 150 | } |
151 | 151 | ||
152 | void TEmulation::setCodec(int c) | 152 | void TEmulation::setCodec(int c) |
153 | { | 153 | { |
154 | //FIXME: check whether we have to free codec | 154 | //FIXME: check whether we have to free codec |
155 | codec = c ? QTextCodec::codecForName("utf8") | 155 | codec = c ? QTextCodec::codecForName("utf8") |
156 | : QTextCodec::codecForLocale(); | 156 | : QTextCodec::codecForLocale(); |
157 | if (decoder) delete decoder; | 157 | if (decoder) delete decoder; |
158 | decoder = codec->makeDecoder(); | 158 | decoder = codec->makeDecoder(); |
159 | } | 159 | } |
160 | 160 | ||
161 | void TEmulation::setKeytrans(int no) | 161 | void TEmulation::setKeytrans(int no) |
162 | { | 162 | { |
163 | keytrans = KeyTrans::find(no); | 163 | keytrans = KeyTrans::find(no); |
164 | } | 164 | } |
165 | 165 | ||
166 | void TEmulation::setKeytrans(const char * no) | 166 | void TEmulation::setKeytrans(const char * no) |
167 | { | 167 | { |
168 | keytrans = KeyTrans::find(no); | 168 | keytrans = KeyTrans::find(no); |
169 | } | 169 | } |
170 | 170 | ||
171 | // Interpreting Codes --------------------------------------------------------- | 171 | // Interpreting Codes --------------------------------------------------------- |
172 | 172 | ||
173 | /* | 173 | /* |
174 | This section deals with decoding the incoming character stream. | 174 | This section deals with decoding the incoming character stream. |
175 | Decoding means here, that the stream is first seperated into `tokens' | 175 | Decoding means here, that the stream is first seperated into `tokens' |
176 | which are then mapped to a `meaning' provided as operations by the | 176 | which are then mapped to a `meaning' provided as operations by the |
177 | `Screen' class. | 177 | `Screen' class. |
178 | */ | 178 | */ |
179 | 179 | ||
180 | /*! | 180 | /*! |
181 | */ | 181 | */ |
182 | 182 | ||
183 | void TEmulation::onRcvChar(int c) | 183 | void TEmulation::onRcvChar(int c) |
184 | // process application unicode input to terminal | 184 | // process application unicode input to terminal |
185 | // this is a trivial scanner | 185 | // this is a trivial scanner |
186 | { | 186 | { |
187 | c &= 0xff; | 187 | c &= 0xff; |
188 | switch (c) | 188 | switch (c) |
189 | { | 189 | { |
190 | case '\b' : scr->BackSpace(); break; | 190 | case '\b' : scr->BackSpace(); break; |
191 | case '\t' : scr->Tabulate(); break; | 191 | case '\t' : scr->Tabulate(); break; |
192 | case '\n' : scr->NewLine(); break; | 192 | case '\n' : scr->NewLine(); break; |
193 | case '\r' : scr->Return(); break; | 193 | case '\r' : scr->Return(); break; |
194 | case 0x07 : gui->Bell(); break; | 194 | case 0x07 : gui->Bell(); break; |
195 | default : scr->ShowCharacter(c); break; | 195 | default : scr->ShowCharacter(c); break; |
196 | }; | 196 | }; |
197 | } | 197 | } |
198 | 198 | ||
199 | /* ------------------------------------------------------------------------- */ | 199 | /* ------------------------------------------------------------------------- */ |
200 | /* */ | 200 | /* */ |
201 | /* Keyboard Handling */ | 201 | /* Keyboard Handling */ |
202 | /* */ | 202 | /* */ |
203 | /* ------------------------------------------------------------------------- */ | 203 | /* ------------------------------------------------------------------------- */ |
204 | 204 | ||
205 | /*! | 205 | /*! |
206 | */ | 206 | */ |
207 | 207 | ||
208 | void TEmulation::onKeyPress( QKeyEvent* ev ) | 208 | void TEmulation::onKeyPress( QKeyEvent* ev ) |
209 | { | 209 | { |
210 | qWarning("onKeyPress,...."); | 210 | qWarning("onKeyPress,...."); |
211 | if (!connected) return; // someone else gets the keys | 211 | if (!connected) return; // someone else gets the keys |
212 | if (scr->getHistCursor() != scr->getHistLines()); | 212 | if (scr->getHistCursor() != scr->getHistLines()); |
213 | scr->setHistCursor(scr->getHistLines()); | 213 | scr->setHistCursor(scr->getHistLines()); |
214 | if (!ev->text().isEmpty()) | 214 | if (!ev->text().isEmpty()) |
215 | { // A block of text | 215 | { // A block of text |
216 | // Note that the text is proper unicode. | 216 | // Note that the text is proper unicode. |
217 | // We should do a conversion here, but since this | 217 | // We should do a conversion here, but since this |
218 | // routine will never be used, we simply emit plain ascii. | 218 | // routine will never be used, we simply emit plain ascii. |
219 | emit sndBlock(ev->text().ascii(),ev->text().length()); | 219 | emit sndBlock(ev->text().ascii(),ev->text().length()); |
220 | } | 220 | } |
221 | else if (ev->ascii()>0) | 221 | else if (ev->ascii()>0) |
222 | { unsigned char c[1]; | 222 | { unsigned char c[1]; |
223 | c[0] = ev->ascii(); | 223 | c[0] = ev->ascii(); |
224 | emit sndBlock((char*)c,1); | 224 | emit sndBlock((char*)c,1); |
225 | } | 225 | } |
226 | } | 226 | } |
227 | 227 | ||
228 | // Unblocking, Byte to Unicode translation --------------------------------- -- | 228 | // Unblocking, Byte to Unicode translation --------------------------------- -- |
229 | 229 | ||
230 | /* | 230 | /* |
231 | We are doing code conversion from locale to unicode first. | 231 | We are doing code conversion from locale to unicode first. |
232 | */ | 232 | */ |
233 | 233 | ||
234 | void TEmulation::onRcvBlock(const char *s, int len) | 234 | void TEmulation::onRcvBlock(const char *s, int len) |
235 | { | 235 | { |
236 | bulkStart(); | 236 | bulkStart(); |
237 | bulk_incnt += 1; | 237 | bulk_incnt += 1; |
238 | for (int i = 0; i < len; i++) | 238 | for (int i = 0; i < len; i++) |
239 | { | 239 | { |
240 | QString result = decoder->toUnicode(&s[i],1); | 240 | QString result = decoder->toUnicode(&s[i],1); |
241 | int reslen = result.length(); | 241 | int reslen = result.length(); |
242 | for (int j = 0; j < reslen; j++) | 242 | for (int j = 0; j < reslen; j++) |
243 | onRcvChar(result[j].unicode()); | 243 | onRcvChar(result[j].unicode()); |
244 | if (s[i] == '\n') bulkNewline(); | 244 | if (s[i] == '\n') bulkNewline(); |
245 | } | 245 | } |
246 | bulkEnd(); | 246 | bulkEnd(); |
247 | } | 247 | } |
248 | 248 | ||
249 | // Selection --------------------------------------------------------------- -- | 249 | // Selection --------------------------------------------------------------- -- |
250 | 250 | ||
251 | void TEmulation::onSelectionBegin(const int x, const int y) { | 251 | void TEmulation::onSelectionBegin(const int x, const int y) { |
252 | if (!connected) return; | 252 | if (!connected) return; |
253 | scr->setSelBeginXY(x,y); | 253 | scr->setSelBeginXY(x,y); |
254 | showBulk(); | 254 | showBulk(); |
255 | } | 255 | } |
256 | 256 | ||
257 | void TEmulation::onSelectionExtend(const int x, const int y) { | 257 | void TEmulation::onSelectionExtend(const int x, const int y) { |
258 | if (!connected) return; | 258 | if (!connected) return; |
259 | scr->setSelExtentXY(x,y); | 259 | scr->setSelExtentXY(x,y); |
260 | showBulk(); | 260 | showBulk(); |
261 | } | 261 | } |
262 | 262 | ||
263 | void TEmulation::setSelection(const BOOL preserve_line_breaks) { | 263 | void TEmulation::setSelection(const BOOL preserve_line_breaks) { |
264 | if (!connected) return; | 264 | if (!connected) return; |
265 | QString t = scr->getSelText(preserve_line_breaks); | 265 | QString t = scr->getSelText(preserve_line_breaks); |
266 | if (!t.isNull()) gui->setSelection(t); | 266 | if (!t.isNull()) gui->setSelection(t); |
267 | } | 267 | } |
268 | 268 | ||
269 | void TEmulation::clearSelection() { | 269 | void TEmulation::clearSelection() { |
270 | if (!connected) return; | 270 | if (!connected) return; |
271 | scr->clearSelection(); | 271 | scr->clearSelection(); |
272 | showBulk(); | 272 | showBulk(); |
273 | } | 273 | } |
274 | 274 | void TEmulation::streamHistory(QTextStream* stream) { | |
275 | *stream << scr->getHistory(); | ||
276 | } | ||
275 | // Refreshing -------------------------------------------------------------- -- | 277 | // Refreshing -------------------------------------------------------------- -- |
276 | 278 | ||
277 | #define BULK_TIMEOUT 20 | 279 | #define BULK_TIMEOUT 20 |
278 | 280 | ||
279 | /*! | 281 | /*! |
280 | called when \n comes in. Evtl. triggers showBulk at endBulk | 282 | called when \n comes in. Evtl. triggers showBulk at endBulk |
281 | */ | 283 | */ |
282 | 284 | ||
283 | void TEmulation::bulkNewline() | 285 | void TEmulation::bulkNewline() |
284 | { | 286 | { |
285 | bulk_nlcnt += 1; | 287 | bulk_nlcnt += 1; |
286 | bulk_incnt = 0; // reset bulk counter since `nl' rule applies | 288 | bulk_incnt = 0; // reset bulk counter since `nl' rule applies |
287 | } | 289 | } |
288 | 290 | ||
289 | /*! | 291 | /*! |
290 | */ | 292 | */ |
291 | 293 | ||
292 | void TEmulation::showBulk() | 294 | void TEmulation::showBulk() |
293 | { | 295 | { |
294 | bulk_nlcnt = 0; // reset bulk newline counter | 296 | bulk_nlcnt = 0; // reset bulk newline counter |
295 | bulk_incnt = 0; // reset bulk counter | 297 | bulk_incnt = 0; // reset bulk counter |
296 | if (connected) | 298 | if (connected) |
297 | { | 299 | { |
298 | ca* image = scr->getCookedImage(); // get the image | 300 | ca* image = scr->getCookedImage(); // get the image |
299 | gui->setImage(image, | 301 | gui->setImage(image, |
300 | scr->getLines(), | 302 | scr->getLines(), |
301 | scr->getColumns()); // actual refresh | 303 | scr->getColumns()); // actual refresh |
302 | free(image); | 304 | free(image); |
303 | //FIXME: check that we do not trigger other draw event here. | 305 | //FIXME: check that we do not trigger other draw event here. |
304 | gui->setScroll(scr->getHistCursor(),scr->getHistLines()); | 306 | gui->setScroll(scr->getHistCursor(),scr->getHistLines()); |
305 | } | 307 | } |
306 | } | 308 | } |
307 | 309 | ||
308 | void TEmulation::bulkStart() | 310 | void TEmulation::bulkStart() |
309 | { | 311 | { |
310 | if (bulk_timer.isActive()) bulk_timer.stop(); | 312 | if (bulk_timer.isActive()) bulk_timer.stop(); |
311 | } | 313 | } |
312 | 314 | ||
313 | void TEmulation::bulkEnd() | 315 | void TEmulation::bulkEnd() |
314 | { | 316 | { |
315 | if ( bulk_nlcnt > gui->Lines() || bulk_incnt > 20 ) | 317 | if ( bulk_nlcnt > gui->Lines() || bulk_incnt > 20 ) |
316 | showBulk(); // resets bulk_??cnt to 0, too. | 318 | showBulk(); // resets bulk_??cnt to 0, too. |
317 | else | 319 | else |
318 | bulk_timer.start(BULK_TIMEOUT,TRUE); | 320 | bulk_timer.start(BULK_TIMEOUT,TRUE); |
319 | } | 321 | } |
320 | 322 | ||
321 | void TEmulation::setConnect(bool c) | 323 | void TEmulation::setConnect(bool c) |
322 | { | 324 | { |
323 | connected = c; | 325 | connected = c; |
324 | if ( connected) | 326 | if ( connected) |
325 | { | 327 | { |
326 | onImageSizeChange(gui->Lines(), gui->Columns()); | 328 | onImageSizeChange(gui->Lines(), gui->Columns()); |
327 | showBulk(); | 329 | showBulk(); |
328 | } | 330 | } |
329 | else | 331 | else |
330 | { | 332 | { |
331 | scr->clearSelection(); | 333 | scr->clearSelection(); |
332 | } | 334 | } |
333 | } | 335 | } |
334 | 336 | ||
335 | // --------------------------------------------------------------------------- | 337 | // --------------------------------------------------------------------------- |
336 | 338 | ||
337 | /*! triggered by image size change of the TEWidget `gui'. | 339 | /*! triggered by image size change of the TEWidget `gui'. |
338 | 340 | ||
339 | This event is simply propagated to the attached screens | 341 | This event is simply propagated to the attached screens |
340 | and to the related serial line. | 342 | and to the related serial line. |
341 | */ | 343 | */ |
342 | 344 | ||
343 | void TEmulation::onImageSizeChange(int lines, int columns) | 345 | void TEmulation::onImageSizeChange(int lines, int columns) |
344 | { | 346 | { |
345 | if (!connected) return; | 347 | if (!connected) return; |
346 | screen[0]->resizeImage(lines,columns); | 348 | screen[0]->resizeImage(lines,columns); |
347 | screen[1]->resizeImage(lines,columns); | 349 | screen[1]->resizeImage(lines,columns); |
348 | showBulk(); | 350 | showBulk(); |
349 | emit ImageSizeChanged(lines,columns); // propagate event to serial line | 351 | emit ImageSizeChanged(lines,columns); // propagate event to serial line |
350 | } | 352 | } |
351 | 353 | ||
352 | void TEmulation::onHistoryCursorChange(int cursor) | 354 | void TEmulation::onHistoryCursorChange(int cursor) |
353 | { | 355 | { |
354 | if (!connected) return; | 356 | if (!connected) return; |
355 | scr->setHistCursor(cursor); | 357 | scr->setHistCursor(cursor); |
356 | showBulk(); | 358 | showBulk(); |
357 | } | 359 | } |
358 | 360 | ||
359 | void TEmulation::setColumns(int columns) | 361 | void TEmulation::setColumns(int columns) |
360 | { | 362 | { |
361 | //FIXME: this goes strange ways. | 363 | //FIXME: this goes strange ways. |
362 | // Can we put this straight or explain it at least? | 364 | // Can we put this straight or explain it at least? |
363 | emit changeColumns(columns); | 365 | emit changeColumns(columns); |
364 | } | 366 | } |
diff --git a/noncore/apps/opie-console/TEmulation.h b/noncore/apps/opie-console/TEmulation.h index ec15e7a..d7b3d6d 100644 --- a/noncore/apps/opie-console/TEmulation.h +++ b/noncore/apps/opie-console/TEmulation.h | |||
@@ -1,117 +1,122 @@ | |||
1 | /* -------------------------------------------------------------------------- */ | 1 | /* -------------------------------------------------------------------------- */ |
2 | /* */ | 2 | /* */ |
3 | /* [emulation.h] Fundamental Terminal Emulation */ | 3 | /* [emulation.h] Fundamental Terminal Emulation */ |
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 for KDE */ | 9 | /* This file is part of Konsole - an X terminal for KDE */ |
10 | /* */ | 10 | /* */ |
11 | /* -------------------------------------------------------------------------- */ | 11 | /* -------------------------------------------------------------------------- */ |
12 | /* */ | 12 | /* */ |
13 | /* Ported Konsole to Qt/Embedded */ | 13 | /* Ported Konsole to Qt/Embedded */ |
14 | /* */ | 14 | /* */ |
15 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ | 15 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ |
16 | /* */ | 16 | /* */ |
17 | /* -------------------------------------------------------------------------- */ | 17 | /* -------------------------------------------------------------------------- */ |
18 | 18 | ||
19 | #ifndef EMULATION_H | 19 | #ifndef EMULATION_H |
20 | #define EMULATION_H | 20 | #define EMULATION_H |
21 | 21 | ||
22 | #include "TEWidget.h" | 22 | #include "TEWidget.h" |
23 | #include "TEScreen.h" | 23 | #include "TEScreen.h" |
24 | #include <qtimer.h> | 24 | #include <qtimer.h> |
25 | #include <stdio.h> | 25 | #include <stdio.h> |
26 | #include <qtextcodec.h> | 26 | #include <qtextcodec.h> |
27 | #include <qtextstream.h> | ||
28 | |||
27 | #include "keytrans.h" | 29 | #include "keytrans.h" |
28 | 30 | ||
29 | class TEmulation : public QObject | 31 | class TEmulation : public QObject |
30 | { Q_OBJECT | 32 | { Q_OBJECT |
31 | 33 | ||
32 | public: | 34 | public: |
33 | 35 | ||
34 | TEmulation(TEWidget* gui); | 36 | TEmulation(TEWidget* gui); |
35 | ~TEmulation(); | 37 | ~TEmulation(); |
36 | 38 | ||
37 | public: | 39 | public: |
38 | virtual void setHistory(bool on); | 40 | virtual void setHistory(bool on); |
39 | virtual bool history(); | 41 | virtual bool history(); |
42 | virtual void streamHistory( QTextStream* ); | ||
40 | 43 | ||
41 | public slots: // signals incoming from TEWidget | 44 | public slots: // signals incoming from TEWidget |
42 | 45 | ||
43 | virtual void onImageSizeChange(int lines, int columns); | 46 | virtual void onImageSizeChange(int lines, int columns); |
44 | virtual void onHistoryCursorChange(int cursor); | 47 | virtual void onHistoryCursorChange(int cursor); |
45 | virtual void onKeyPress(QKeyEvent*); | 48 | virtual void onKeyPress(QKeyEvent*); |
46 | 49 | ||
47 | virtual void clearSelection(); | 50 | virtual void clearSelection(); |
48 | virtual void onSelectionBegin(const int x, const int y); | 51 | virtual void onSelectionBegin(const int x, const int y); |
49 | virtual void onSelectionExtend(const int x, const int y); | 52 | virtual void onSelectionExtend(const int x, const int y); |
50 | virtual void setSelection(const BOOL preserve_line_breaks); | 53 | virtual void setSelection(const BOOL preserve_line_breaks); |
51 | 54 | ||
52 | public slots: // signals incoming from data source | 55 | public slots: // signals incoming from data source |
53 | 56 | ||
54 | void onRcvBlock(const char* txt,int len); | 57 | void onRcvBlock(const char* txt,int len); |
55 | 58 | ||
56 | signals: | 59 | signals: |
57 | 60 | ||
58 | void sndBlock(const char* txt,int len); | 61 | void sndBlock(const char* txt,int len); |
59 | void ImageSizeChanged(int lines, int columns); | 62 | void ImageSizeChanged(int lines, int columns); |
60 | void changeColumns(int columns); | 63 | void changeColumns(int columns); |
61 | void changeTitle(int arg, const char* str); | 64 | void changeTitle(int arg, const char* str); |
62 | 65 | ||
63 | public: | 66 | public: |
64 | 67 | ||
65 | virtual void onRcvChar(int); | 68 | virtual void onRcvChar(int); |
66 | 69 | ||
67 | virtual void setMode (int) = 0; | 70 | virtual void setMode (int) = 0; |
68 | virtual void resetMode(int) = 0; | 71 | virtual void resetMode(int) = 0; |
69 | 72 | ||
70 | virtual void sendString(const char*) = 0; | 73 | virtual void sendString(const char*) = 0; |
71 | 74 | ||
72 | virtual void setConnect(bool r); | 75 | virtual void setConnect(bool r); |
73 | void setColumns(int columns); | 76 | void setColumns(int columns); |
74 | 77 | ||
75 | void setKeytrans(int no); | 78 | void setKeytrans(int no); |
76 | void setKeytrans(const char * no); | 79 | void setKeytrans(const char * no); |
77 | 80 | ||
81 | |||
82 | |||
78 | protected: | 83 | protected: |
79 | 84 | ||
80 | TEWidget* gui; | 85 | TEWidget* gui; |
81 | TEScreen* scr; // referes to one `screen' | 86 | TEScreen* scr; // referes to one `screen' |
82 | TEScreen* screen[2]; // 0 = primary, 1 = alternate | 87 | TEScreen* screen[2]; // 0 = primary, 1 = alternate |
83 | void setScreen(int n); // set `scr' to `screen[n]' | 88 | void setScreen(int n); // set `scr' to `screen[n]' |
84 | 89 | ||
85 | bool connected; // communicate with widget | 90 | bool connected; // communicate with widget |
86 | 91 | ||
87 | void setCodec(int c); // codec number, 0 = locale, 1=utf8 | 92 | void setCodec(int c); // codec number, 0 = locale, 1=utf8 |
88 | 93 | ||
89 | QTextCodec* codec; | 94 | QTextCodec* codec; |
90 | QTextCodec* localeCodec; | 95 | QTextCodec* localeCodec; |
91 | QTextDecoder* decoder; | 96 | QTextDecoder* decoder; |
92 | 97 | ||
93 | KeyTrans* keytrans; | 98 | KeyTrans* keytrans; |
94 | 99 | ||
95 | // refreshing related material. | 100 | // refreshing related material. |
96 | // this is localized in the class. | 101 | // this is localized in the class. |
97 | private slots: // triggered by timer | 102 | private slots: // triggered by timer |
98 | 103 | ||
99 | void showBulk(); | 104 | void showBulk(); |
100 | 105 | ||
101 | private: | 106 | private: |
102 | 107 | ||
103 | void bulkNewline(); | 108 | void bulkNewline(); |
104 | void bulkStart(); | 109 | void bulkStart(); |
105 | void bulkEnd(); | 110 | void bulkEnd(); |
106 | 111 | ||
107 | private: | 112 | private: |
108 | 113 | ||
109 | QTimer bulk_timer; | 114 | QTimer bulk_timer; |
110 | int bulk_nlcnt; // bulk newline counter | 115 | int bulk_nlcnt; // bulk newline counter |
111 | char* SelectedText; | 116 | char* SelectedText; |
112 | int bulk_incnt; // bulk counter | 117 | int bulk_incnt; // bulk counter |
113 | 118 | ||
114 | 119 | ||
115 | }; | 120 | }; |
116 | 121 | ||
117 | #endif // ifndef EMULATION_H | 122 | #endif // ifndef EMULATION_H |
diff --git a/noncore/apps/opie-console/emulation_handler.cpp b/noncore/apps/opie-console/emulation_handler.cpp index 7924568..235facb 100644 --- a/noncore/apps/opie-console/emulation_handler.cpp +++ b/noncore/apps/opie-console/emulation_handler.cpp | |||
@@ -1,206 +1,209 @@ | |||
1 | #include <qwidget.h> | 1 | #include <qwidget.h> |
2 | #include <qpushbutton.h> | 2 | #include <qpushbutton.h> |
3 | 3 | ||
4 | #include "TEWidget.h" | 4 | #include "TEWidget.h" |
5 | #include "TEmuVt102.h" | 5 | #include "TEmuVt102.h" |
6 | 6 | ||
7 | #include "profile.h" | 7 | #include "profile.h" |
8 | #include "emulation_handler.h" | 8 | #include "emulation_handler.h" |
9 | #include "script.h" | 9 | #include "script.h" |
10 | 10 | ||
11 | EmulationHandler::EmulationHandler( const Profile& prof, QWidget* parent,const char* name ) | 11 | EmulationHandler::EmulationHandler( const Profile& prof, QWidget* parent,const char* name ) |
12 | : QObject(0, name ) | 12 | : QObject(0, name ) |
13 | { | 13 | { |
14 | m_teWid = new TEWidget( parent, "TerminalMain"); | 14 | m_teWid = new TEWidget( parent, "TerminalMain"); |
15 | // use setWrapAt(0) for classic behaviour (wrap at screen width, no scrollbar) | 15 | // use setWrapAt(0) for classic behaviour (wrap at screen width, no scrollbar) |
16 | // use setWrapAt(80) for normal console with scrollbar | 16 | // use setWrapAt(80) for normal console with scrollbar |
17 | setWrap(prof.readNumEntry("Wrap", 0) ? 0 : 80); | 17 | setWrap(prof.readNumEntry("Wrap", 0) ? 0 : 80); |
18 | m_teWid->setMinimumSize(150, 70 ); | 18 | m_teWid->setMinimumSize(150, 70 ); |
19 | m_script = 0; | 19 | m_script = 0; |
20 | parent->resize( m_teWid->calcSize(80, 24 ) ); | 20 | parent->resize( m_teWid->calcSize(80, 24 ) ); |
21 | m_teEmu = new TEmuVt102(m_teWid ); | 21 | m_teEmu = new TEmuVt102(m_teWid ); |
22 | 22 | ||
23 | connect(m_teEmu,SIGNAL(ImageSizeChanged(int, int) ), | 23 | connect(m_teEmu,SIGNAL(ImageSizeChanged(int, int) ), |
24 | this, SIGNAL(changeSize(int, int) ) ); | 24 | this, SIGNAL(changeSize(int, int) ) ); |
25 | connect(m_teEmu, SIGNAL(sndBlock(const char*, int) ), | 25 | connect(m_teEmu, SIGNAL(sndBlock(const char*, int) ), |
26 | this, SLOT(recvEmulation(const char*, int) ) ); | 26 | this, SLOT(recvEmulation(const char*, int) ) ); |
27 | m_teEmu->setConnect( true ); | 27 | m_teEmu->setConnect( true ); |
28 | m_teEmu->setHistory( TRUE ); | 28 | m_teEmu->setHistory( TRUE ); |
29 | load( prof ); | 29 | load( prof ); |
30 | 30 | ||
31 | 31 | ||
32 | 32 | ||
33 | } | 33 | } |
34 | TEmulation* EmulationHandler::emulation() { | ||
35 | return m_teEmu; | ||
36 | } | ||
34 | EmulationHandler::~EmulationHandler() { | 37 | EmulationHandler::~EmulationHandler() { |
35 | if (isRecording()) | 38 | if (isRecording()) |
36 | clearScript(); | 39 | clearScript(); |
37 | delete m_teEmu; | 40 | delete m_teEmu; |
38 | delete m_teWid; | 41 | delete m_teWid; |
39 | } | 42 | } |
40 | 43 | ||
41 | void EmulationHandler::load( const Profile& prof) { | 44 | void EmulationHandler::load( const Profile& prof) { |
42 | m_teWid->setVTFont( font( prof.readNumEntry("Font") ) ); | 45 | m_teWid->setVTFont( font( prof.readNumEntry("Font") ) ); |
43 | int num = prof.readNumEntry("Color"); | 46 | int num = prof.readNumEntry("Color"); |
44 | setColor( foreColor(num), backColor(num) ); | 47 | setColor( foreColor(num), backColor(num) ); |
45 | m_teWid->setBackgroundColor(backColor(num) ); | 48 | m_teWid->setBackgroundColor(backColor(num) ); |
46 | 49 | ||
47 | int term = prof.readNumEntry("Terminal", 0) ; | 50 | int term = prof.readNumEntry("Terminal", 0) ; |
48 | switch(term) { | 51 | switch(term) { |
49 | default: | 52 | default: |
50 | case Profile::VT102: | 53 | case Profile::VT102: |
51 | case Profile::VT100: | 54 | case Profile::VT100: |
52 | m_teEmu->setKeytrans("vt100.keytab"); | 55 | m_teEmu->setKeytrans("vt100.keytab"); |
53 | break; | 56 | break; |
54 | case Profile::Linux: | 57 | case Profile::Linux: |
55 | m_teEmu->setKeytrans("linux.keytab"); | 58 | m_teEmu->setKeytrans("linux.keytab"); |
56 | break; | 59 | break; |
57 | case Profile::XTerm: | 60 | case Profile::XTerm: |
58 | m_teEmu->setKeytrans("default.Keytab"); | 61 | m_teEmu->setKeytrans("default.Keytab"); |
59 | break; | 62 | break; |
60 | } | 63 | } |
61 | } | 64 | } |
62 | void EmulationHandler::recv( const QByteArray& ar) { | 65 | void EmulationHandler::recv( const QByteArray& ar) { |
63 | m_teEmu->onRcvBlock(ar.data(), ar.count() ); | 66 | m_teEmu->onRcvBlock(ar.data(), ar.count() ); |
64 | } | 67 | } |
65 | void EmulationHandler::recvEmulation(const char* src, int len ) { | 68 | void EmulationHandler::recvEmulation(const char* src, int len ) { |
66 | QByteArray ar(len); | 69 | QByteArray ar(len); |
67 | 70 | ||
68 | memcpy(ar.data(), src, sizeof(char) * len ); | 71 | memcpy(ar.data(), src, sizeof(char) * len ); |
69 | if (isRecording()) | 72 | if (isRecording()) |
70 | m_script->append(ar); | 73 | m_script->append(ar); |
71 | emit send(ar); | 74 | emit send(ar); |
72 | } | 75 | } |
73 | QWidget* EmulationHandler::widget() { | 76 | QWidget* EmulationHandler::widget() { |
74 | return m_teWid; | 77 | return m_teWid; |
75 | } | 78 | } |
76 | /* | 79 | /* |
77 | * allocate a new table of colors | 80 | * allocate a new table of colors |
78 | */ | 81 | */ |
79 | void EmulationHandler::setColor( const QColor& fore, const QColor& back ) { | 82 | void EmulationHandler::setColor( const QColor& fore, const QColor& back ) { |
80 | ColorEntry table[TABLE_COLORS]; | 83 | ColorEntry table[TABLE_COLORS]; |
81 | const ColorEntry *defaultCt = m_teWid->getdefaultColorTable(); | 84 | const ColorEntry *defaultCt = m_teWid->getdefaultColorTable(); |
82 | 85 | ||
83 | for (int i = 0; i < TABLE_COLORS; i++ ) { | 86 | for (int i = 0; i < TABLE_COLORS; i++ ) { |
84 | if ( i == 0 || i == 10 ) { | 87 | if ( i == 0 || i == 10 ) { |
85 | table[i].color = fore; | 88 | table[i].color = fore; |
86 | }else if ( i == 1 || i == 11 ) { | 89 | }else if ( i == 1 || i == 11 ) { |
87 | table[i].color = back; | 90 | table[i].color = back; |
88 | table[i].transparent = 0; | 91 | table[i].transparent = 0; |
89 | }else { | 92 | }else { |
90 | table[i].color = defaultCt[i].color; | 93 | table[i].color = defaultCt[i].color; |
91 | } | 94 | } |
92 | } | 95 | } |
93 | m_teWid->setColorTable(table ); | 96 | m_teWid->setColorTable(table ); |
94 | m_teWid->update(); | 97 | m_teWid->update(); |
95 | } | 98 | } |
96 | QFont EmulationHandler::font( int id ) { | 99 | QFont EmulationHandler::font( int id ) { |
97 | QString name; | 100 | QString name; |
98 | int size = 0; | 101 | int size = 0; |
99 | switch(id ) { | 102 | switch(id ) { |
100 | default: // fall through | 103 | default: // fall through |
101 | case 0: | 104 | case 0: |
102 | name = QString::fromLatin1("Micro"); | 105 | name = QString::fromLatin1("Micro"); |
103 | size = 4; | 106 | size = 4; |
104 | break; | 107 | break; |
105 | case 1: | 108 | case 1: |
106 | name = QString::fromLatin1("Fixed"); | 109 | name = QString::fromLatin1("Fixed"); |
107 | size = 7; | 110 | size = 7; |
108 | break; | 111 | break; |
109 | case 2: | 112 | case 2: |
110 | name = QString::fromLatin1("Fixed"); | 113 | name = QString::fromLatin1("Fixed"); |
111 | size = 12; | 114 | size = 12; |
112 | break; | 115 | break; |
113 | } | 116 | } |
114 | QFont font(name, size, QFont::Normal ); | 117 | QFont font(name, size, QFont::Normal ); |
115 | font.setFixedPitch(TRUE ); | 118 | font.setFixedPitch(TRUE ); |
116 | return font; | 119 | return font; |
117 | } | 120 | } |
118 | QColor EmulationHandler::foreColor(int col) { | 121 | QColor EmulationHandler::foreColor(int col) { |
119 | QColor co; | 122 | QColor co; |
120 | /* we need to switch it */ | 123 | /* we need to switch it */ |
121 | switch( col ) { | 124 | switch( col ) { |
122 | default: | 125 | default: |
123 | case Profile::White: | 126 | case Profile::White: |
124 | /* color is black */ | 127 | /* color is black */ |
125 | co = Qt::white; | 128 | co = Qt::white; |
126 | break; | 129 | break; |
127 | case Profile::Black: | 130 | case Profile::Black: |
128 | co = Qt::black; | 131 | co = Qt::black; |
129 | break; | 132 | break; |
130 | case Profile::Green: | 133 | case Profile::Green: |
131 | qWarning("Foreground green"); | 134 | qWarning("Foreground green"); |
132 | co = Qt::green; | 135 | co = Qt::green; |
133 | break; | 136 | break; |
134 | case Profile::Orange: | 137 | case Profile::Orange: |
135 | qWarning("Foreground orange"); | 138 | qWarning("Foreground orange"); |
136 | co.setRgb( 231, 184, 98 ); | 139 | co.setRgb( 231, 184, 98 ); |
137 | break; | 140 | break; |
138 | } | 141 | } |
139 | 142 | ||
140 | return co; | 143 | return co; |
141 | } | 144 | } |
142 | QColor EmulationHandler::backColor(int col ) { | 145 | QColor EmulationHandler::backColor(int col ) { |
143 | QColor co; | 146 | QColor co; |
144 | /* we need to switch it */ | 147 | /* we need to switch it */ |
145 | switch( col ) { | 148 | switch( col ) { |
146 | default: | 149 | default: |
147 | case Profile::White: | 150 | case Profile::White: |
148 | /* color is white */ | 151 | /* color is white */ |
149 | co = Qt::black; | 152 | co = Qt::black; |
150 | break; | 153 | break; |
151 | case Profile::Black: | 154 | case Profile::Black: |
152 | co = Qt::white; | 155 | co = Qt::white; |
153 | break; | 156 | break; |
154 | case Profile::Green: | 157 | case Profile::Green: |
155 | qWarning("Background black"); | 158 | qWarning("Background black"); |
156 | co = Qt::black; | 159 | co = Qt::black; |
157 | break; | 160 | break; |
158 | case Profile::Orange: | 161 | case Profile::Orange: |
159 | qWarning("Background black"); | 162 | qWarning("Background black"); |
160 | co = Qt::black; | 163 | co = Qt::black; |
161 | break; | 164 | break; |
162 | } | 165 | } |
163 | 166 | ||
164 | return co; | 167 | return co; |
165 | } | 168 | } |
166 | 169 | ||
167 | QPushButton* EmulationHandler::cornerButton() { | 170 | QPushButton* EmulationHandler::cornerButton() { |
168 | return m_teWid->cornerButton(); | 171 | return m_teWid->cornerButton(); |
169 | } | 172 | } |
170 | 173 | ||
171 | 174 | ||
172 | Script *EmulationHandler::script() { | 175 | Script *EmulationHandler::script() { |
173 | return m_script; | 176 | return m_script; |
174 | } | 177 | } |
175 | 178 | ||
176 | bool EmulationHandler::isRecording() { | 179 | bool EmulationHandler::isRecording() { |
177 | return (m_script != 0); | 180 | return (m_script != 0); |
178 | } | 181 | } |
179 | 182 | ||
180 | void EmulationHandler::startRecording() { | 183 | void EmulationHandler::startRecording() { |
181 | if (!isRecording()) | 184 | if (!isRecording()) |
182 | m_script = new Script(); | 185 | m_script = new Script(); |
183 | } | 186 | } |
184 | 187 | ||
185 | void EmulationHandler::clearScript() { | 188 | void EmulationHandler::clearScript() { |
186 | if (isRecording()) { | 189 | if (isRecording()) { |
187 | delete m_script; | 190 | delete m_script; |
188 | m_script = 0; | 191 | m_script = 0; |
189 | } | 192 | } |
190 | } | 193 | } |
191 | 194 | ||
192 | void EmulationHandler::runScript(const Script *script) { | 195 | void EmulationHandler::runScript(const Script *script) { |
193 | emit send(script->script()); | 196 | emit send(script->script()); |
194 | } | 197 | } |
195 | 198 | ||
196 | void EmulationHandler::copy() { | 199 | void EmulationHandler::copy() { |
197 | m_teWid->emitSelection(); | 200 | m_teWid->emitSelection(); |
198 | } | 201 | } |
199 | void EmulationHandler::paste() { | 202 | void EmulationHandler::paste() { |
200 | m_teWid->pasteClipboard(); | 203 | m_teWid->pasteClipboard(); |
201 | } | 204 | } |
202 | 205 | ||
203 | void EmulationHandler::setWrap(int columns) { | 206 | void EmulationHandler::setWrap(int columns) { |
204 | m_teWid->setWrapAt(columns); | 207 | m_teWid->setWrapAt(columns); |
205 | } | 208 | } |
206 | 209 | ||
diff --git a/noncore/apps/opie-console/emulation_handler.h b/noncore/apps/opie-console/emulation_handler.h index 7bc6f16..1338525 100644 --- a/noncore/apps/opie-console/emulation_handler.h +++ b/noncore/apps/opie-console/emulation_handler.h | |||
@@ -1,94 +1,95 @@ | |||
1 | #ifndef OPIE_EMULATION_HANDLER_H | 1 | #ifndef OPIE_EMULATION_HANDLER_H |
2 | #define OPIE_EMULATION_HANDLER_H | 2 | #define OPIE_EMULATION_HANDLER_H |
3 | 3 | ||
4 | #include <qobject.h> | 4 | #include <qobject.h> |
5 | #include <qcolor.h> | 5 | #include <qcolor.h> |
6 | #include <qcstring.h> | 6 | #include <qcstring.h> |
7 | 7 | ||
8 | /* | 8 | /* |
9 | * Badly ibotty lacks the time to finish | 9 | * Badly ibotty lacks the time to finish |
10 | * his widget in time.. | 10 | * his widget in time.. |
11 | * Never the less we've to have an EmulationWidget | 11 | * Never the less we've to have an EmulationWidget |
12 | * This is why I'm taking the inferior not cleaned | 12 | * This is why I'm taking the inferior not cleaned |
13 | * up TE* KDE STUFF | 13 | * up TE* KDE STUFF |
14 | */ | 14 | */ |
15 | 15 | ||
16 | /** | 16 | /** |
17 | * This is the layer above the IOLayer* | 17 | * This is the layer above the IOLayer* |
18 | * This nice QObject here will get stuff from | 18 | * This nice QObject here will get stuff from |
19 | * got a slot and a signal | 19 | * got a slot and a signal |
20 | * the signal for data | 20 | * the signal for data |
21 | * the slot for receiving | 21 | * the slot for receiving |
22 | * it'll set up the widget internally | 22 | * it'll set up the widget internally |
23 | * and manage the communication between | 23 | * and manage the communication between |
24 | * the pre QByteArray world! | 24 | * the pre QByteArray world! |
25 | */ | 25 | */ |
26 | class Profile; | 26 | class Profile; |
27 | class QWidget; | 27 | class QWidget; |
28 | class QPushButton; | 28 | class QPushButton; |
29 | class TEWidget; | 29 | class TEWidget; |
30 | class TEmulation; | 30 | class TEmulation; |
31 | class QFont; | 31 | class QFont; |
32 | class Script; | 32 | class Script; |
33 | class EmulationHandler : public QObject { | 33 | class EmulationHandler : public QObject { |
34 | Q_OBJECT | 34 | Q_OBJECT |
35 | public: | 35 | public: |
36 | /** | 36 | /** |
37 | * simple c'tor the parent of the TEWdiget | 37 | * simple c'tor the parent of the TEWdiget |
38 | * and a name | 38 | * and a name |
39 | * and a Profile | 39 | * and a Profile |
40 | */ | 40 | */ |
41 | EmulationHandler( const Profile&, QWidget* parent, const char* name = 0l ); | 41 | EmulationHandler( const Profile&, QWidget* parent, const char* name = 0l ); |
42 | 42 | ||
43 | /** | 43 | /** |
44 | * delete all components | 44 | * delete all components |
45 | */ | 45 | */ |
46 | ~EmulationHandler(); | 46 | ~EmulationHandler(); |
47 | 47 | ||
48 | void load( const Profile& ); | 48 | void load( const Profile& ); |
49 | QWidget* widget(); | 49 | QWidget* widget(); |
50 | TEmulation *emulation(); | ||
50 | void setColor( const QColor& fore, const QColor& back ); | 51 | void setColor( const QColor& fore, const QColor& back ); |
51 | QPushButton* cornerButton(); | 52 | QPushButton* cornerButton(); |
52 | 53 | ||
53 | /* Scripts */ | 54 | /* Scripts */ |
54 | /* Create a new script and record all typed characters */ | 55 | /* Create a new script and record all typed characters */ |
55 | void startRecording(); | 56 | void startRecording(); |
56 | 57 | ||
57 | /* Return whether we are currently recording a script */ | 58 | /* Return whether we are currently recording a script */ |
58 | bool isRecording(); | 59 | bool isRecording(); |
59 | 60 | ||
60 | /* Return the current script (or NULL) */ | 61 | /* Return the current script (or NULL) */ |
61 | Script *script(); | 62 | Script *script(); |
62 | 63 | ||
63 | /* Stop recording and remove the current script from memory */ | 64 | /* Stop recording and remove the current script from memory */ |
64 | void clearScript(); | 65 | void clearScript(); |
65 | 66 | ||
66 | /* Run a script by forwarding its keys to the EmulationLayer */ | 67 | /* Run a script by forwarding its keys to the EmulationLayer */ |
67 | void runScript(const Script *); | 68 | void runScript(const Script *); |
68 | 69 | ||
69 | /* Propagate change to widget */ | 70 | /* Propagate change to widget */ |
70 | void setWrap(int columns); | 71 | void setWrap(int columns); |
71 | signals: | 72 | signals: |
72 | void send( const QByteArray& ); | 73 | void send( const QByteArray& ); |
73 | void changeSize(int rows, int cols ); | 74 | void changeSize(int rows, int cols ); |
74 | 75 | ||
75 | 76 | ||
76 | public slots: | 77 | public slots: |
77 | void recv( const QByteArray& ); | 78 | void recv( const QByteArray& ); |
78 | void paste(); | 79 | void paste(); |
79 | void copy(); | 80 | void copy(); |
80 | 81 | ||
81 | private slots: | 82 | private slots: |
82 | void recvEmulation( const char*, int len ); | 83 | void recvEmulation( const char*, int len ); |
83 | private: | 84 | private: |
84 | QFont font( int ); | 85 | QFont font( int ); |
85 | QColor foreColor(int ); | 86 | QColor foreColor(int ); |
86 | QColor backColor(int ); | 87 | QColor backColor(int ); |
87 | 88 | ||
88 | private: | 89 | private: |
89 | TEWidget* m_teWid; | 90 | TEWidget* m_teWid; |
90 | TEmulation* m_teEmu; | 91 | TEmulation* m_teEmu; |
91 | Script * m_script; | 92 | Script * m_script; |
92 | }; | 93 | }; |
93 | 94 | ||
94 | #endif | 95 | #endif |
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp index d221715..01468ca 100644 --- a/noncore/apps/opie-console/mainwindow.cpp +++ b/noncore/apps/opie-console/mainwindow.cpp | |||
@@ -1,497 +1,505 @@ | |||
1 | #include <assert.h> | 1 | #include <assert.h> |
2 | 2 | ||
3 | #include <qaction.h> | 3 | #include <qaction.h> |
4 | #include <qmenubar.h> | 4 | #include <qmenubar.h> |
5 | #include <qlabel.h> | 5 | #include <qlabel.h> |
6 | #include <qpopupmenu.h> | 6 | #include <qpopupmenu.h> |
7 | #include <qtoolbar.h> | 7 | #include <qtoolbar.h> |
8 | #include <qmessagebox.h> | 8 | #include <qmessagebox.h> |
9 | #include <qpushbutton.h> | 9 | #include <qpushbutton.h> |
10 | #include <qwhatsthis.h> | 10 | #include <qwhatsthis.h> |
11 | #include <qfileinfo.h> | 11 | #include <qfileinfo.h> |
12 | #include <qtextstream.h> | ||
12 | 13 | ||
13 | #include <qpe/resource.h> | 14 | #include <qpe/resource.h> |
14 | #include <qpe/qpeapplication.h> | 15 | #include <qpe/qpeapplication.h> |
15 | #include <qpe/filemanager.h> | 16 | #include <qpe/filemanager.h> |
16 | #include <qpe/mimetype.h> | 17 | #include <qpe/mimetype.h> |
17 | 18 | ||
18 | #include <opie/ofiledialog.h> | 19 | #include <opie/ofiledialog.h> |
19 | 20 | ||
21 | #include "TEmulation.h" | ||
20 | #include "keytrans.h" | 22 | #include "keytrans.h" |
21 | #include "profileeditordialog.h" | 23 | #include "profileeditordialog.h" |
22 | #include "configdialog.h" | 24 | #include "configdialog.h" |
23 | #include "default.h" | 25 | #include "default.h" |
24 | #include "metafactory.h" | 26 | #include "metafactory.h" |
25 | #include "profile.h" | 27 | #include "profile.h" |
26 | #include "profilemanager.h" | 28 | #include "profilemanager.h" |
27 | #include "mainwindow.h" | 29 | #include "mainwindow.h" |
28 | #include "tabwidget.h" | 30 | #include "tabwidget.h" |
29 | #include "transferdialog.h" | 31 | #include "transferdialog.h" |
30 | #include "function_keyboard.h" | 32 | #include "function_keyboard.h" |
31 | #include "emulation_handler.h" | 33 | #include "emulation_handler.h" |
32 | #include "script.h" | 34 | #include "script.h" |
33 | 35 | ||
34 | static char * filesave_xpm[] = { | 36 | static char * filesave_xpm[] = { |
35 | "16 16 78 1", | 37 | "16 16 78 1", |
36 | " c None", | 38 | " c None", |
37 | ". c #343434", | 39 | ". c #343434", |
38 | "+ c #A0A0A0", | 40 | "+ c #A0A0A0", |
39 | "@ c #565656", | 41 | "@ c #565656", |
40 | "# c #9E9E9E", | 42 | "# c #9E9E9E", |
41 | "$ c #525252", | 43 | "$ c #525252", |
42 | "% c #929292", | 44 | "% c #929292", |
43 | "& c #676767", | 45 | "& c #676767", |
44 | "* c #848484", | 46 | "* c #848484", |
45 | "= c #666666", | 47 | "= c #666666", |
46 | "- c #D8D8D8", | 48 | "- c #D8D8D8", |
47 | "; c #FFFFFF", | 49 | "; c #FFFFFF", |
48 | "> c #DBDBDB", | 50 | "> c #DBDBDB", |
49 | ", c #636363", | 51 | ", c #636363", |
50 | "' c #989898", | 52 | "' c #989898", |
51 | ") c #2D2D2D", | 53 | ") c #2D2D2D", |
52 | "! c #909090", | 54 | "! c #909090", |
53 | "~ c #AEAEAE", | 55 | "~ c #AEAEAE", |
54 | "{ c #EAEAEA", | 56 | "{ c #EAEAEA", |
55 | "] c #575757", | 57 | "] c #575757", |
56 | "^ c #585858", | 58 | "^ c #585858", |
57 | "/ c #8A8A8A", | 59 | "/ c #8A8A8A", |
58 | "( c #828282", | 60 | "( c #828282", |
59 | "_ c #6F6F6F", | 61 | "_ c #6F6F6F", |
60 | ": c #C9C9C9", | 62 | ": c #C9C9C9", |
61 | "< c #050505", | 63 | "< c #050505", |
62 | "[ c #292929", | 64 | "[ c #292929", |
63 | "} c #777777", | 65 | "} c #777777", |
64 | "| c #616161", | 66 | "| c #616161", |
65 | "1 c #3A3A3A", | 67 | "1 c #3A3A3A", |
66 | "2 c #BEBEBE", | 68 | "2 c #BEBEBE", |
67 | "3 c #2C2C2C", | 69 | "3 c #2C2C2C", |
68 | "4 c #7C7C7C", | 70 | "4 c #7C7C7C", |
69 | "5 c #F6F6F6", | 71 | "5 c #F6F6F6", |
70 | "6 c #FCFCFC", | 72 | "6 c #FCFCFC", |
71 | "7 c #6B6B6B", | 73 | "7 c #6B6B6B", |
72 | "8 c #959595", | 74 | "8 c #959595", |
73 | "9 c #4F4F4F", | 75 | "9 c #4F4F4F", |
74 | "0 c #808080", | 76 | "0 c #808080", |
75 | "a c #767676", | 77 | "a c #767676", |
76 | "b c #818181", | 78 | "b c #818181", |
77 | "c c #B8B8B8", | 79 | "c c #B8B8B8", |
78 | "d c #FBFBFB", | 80 | "d c #FBFBFB", |
79 | "e c #F9F9F9", | 81 | "e c #F9F9F9", |
80 | "f c #CCCCCC", | 82 | "f c #CCCCCC", |
81 | "g c #030303", | 83 | "g c #030303", |
82 | "h c #737373", | 84 | "h c #737373", |
83 | "i c #7A7A7A", | 85 | "i c #7A7A7A", |
84 | "j c #7E7E7E", | 86 | "j c #7E7E7E", |
85 | "k c #6A6A6A", | 87 | "k c #6A6A6A", |
86 | "l c #FAFAFA", | 88 | "l c #FAFAFA", |
87 | "m c #505050", | 89 | "m c #505050", |
88 | "n c #9D9D9D", | 90 | "n c #9D9D9D", |
89 | "o c #333333", | 91 | "o c #333333", |
90 | "p c #7B7B7B", | 92 | "p c #7B7B7B", |
91 | "q c #787878", | 93 | "q c #787878", |
92 | "r c #696969", | 94 | "r c #696969", |
93 | "s c #494949", | 95 | "s c #494949", |
94 | "t c #555555", | 96 | "t c #555555", |
95 | "u c #949494", | 97 | "u c #949494", |
96 | "v c #E6E6E6", | 98 | "v c #E6E6E6", |
97 | "w c #424242", | 99 | "w c #424242", |
98 | "x c #515151", | 100 | "x c #515151", |
99 | "y c #535353", | 101 | "y c #535353", |
100 | "z c #3E3E3E", | 102 | "z c #3E3E3E", |
101 | "A c #D4D4D4", | 103 | "A c #D4D4D4", |
102 | "B c #0C0C0C", | 104 | "B c #0C0C0C", |
103 | "C c #353535", | 105 | "C c #353535", |
104 | "D c #474747", | 106 | "D c #474747", |
105 | "E c #ECECEC", | 107 | "E c #ECECEC", |
106 | "F c #919191", | 108 | "F c #919191", |
107 | "G c #7D7D7D", | 109 | "G c #7D7D7D", |
108 | "H c #000000", | 110 | "H c #000000", |
109 | "I c #404040", | 111 | "I c #404040", |
110 | "J c #858585", | 112 | "J c #858585", |
111 | "K c #323232", | 113 | "K c #323232", |
112 | "L c #D0D0D0", | 114 | "L c #D0D0D0", |
113 | "M c #1C1C1C", | 115 | "M c #1C1C1C", |
114 | " ...+ ", | 116 | " ...+ ", |
115 | " @#$%&..+ ", | 117 | " @#$%&..+ ", |
116 | " .*=-;;>,..+ ", | 118 | " .*=-;;>,..+ ", |
117 | " ')!~;;;;;;{]..", | 119 | " ')!~;;;;;;{]..", |
118 | " ^/(-;;;;;;;_:<", | 120 | " ^/(-;;;;;;;_:<", |
119 | " [}|;;;;;;;{12$", | 121 | " [}|;;;;;;;{12$", |
120 | " #34-55;;;;678$+", | 122 | " #34-55;;;;678$+", |
121 | " 90ab=c;dd;e1fg ", | 123 | " 90ab=c;dd;e1fg ", |
122 | " [ahij((kbl0mn$ ", | 124 | " [ahij((kbl0mn$ ", |
123 | " op^q^^7r&]s/$+ ", | 125 | " op^q^^7r&]s/$+ ", |
124 | "@btu;vbwxy]zAB ", | 126 | "@btu;vbwxy]zAB ", |
125 | "CzDEvEv;;DssF$ ", | 127 | "CzDEvEv;;DssF$ ", |
126 | "G.H{E{E{IxsJ$+ ", | 128 | "G.H{E{E{IxsJ$+ ", |
127 | " +...vEKxzLM ", | 129 | " +...vEKxzLM ", |
128 | " +...z]n$ ", | 130 | " +...z]n$ ", |
129 | " +... "}; | 131 | " +... "}; |
130 | 132 | ||
131 | 133 | ||
132 | 134 | ||
133 | MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) { | 135 | MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) { |
134 | KeyTrans::loadAll(); | 136 | KeyTrans::loadAll(); |
135 | for (int i = 0; i < KeyTrans::count(); i++ ) { | 137 | for (int i = 0; i < KeyTrans::count(); i++ ) { |
136 | KeyTrans* s = KeyTrans::find(i ); | 138 | KeyTrans* s = KeyTrans::find(i ); |
137 | assert( s ); | 139 | assert( s ); |
138 | } | 140 | } |
139 | m_factory = new MetaFactory(); | 141 | m_factory = new MetaFactory(); |
140 | Default def(m_factory); | 142 | Default def(m_factory); |
141 | m_sessions.setAutoDelete( TRUE ); | 143 | m_sessions.setAutoDelete( TRUE ); |
142 | m_curSession = 0; | 144 | m_curSession = 0; |
143 | m_manager = new ProfileManager( m_factory ); | 145 | m_manager = new ProfileManager( m_factory ); |
144 | m_manager->load(); | 146 | m_manager->load(); |
145 | m_scriptsData.setAutoDelete(TRUE); | 147 | m_scriptsData.setAutoDelete(TRUE); |
146 | 148 | ||
147 | initUI(); | 149 | initUI(); |
148 | populateProfiles(); | 150 | populateProfiles(); |
149 | populateScripts(); | 151 | populateScripts(); |
150 | } | 152 | } |
151 | void MainWindow::initUI() { | 153 | void MainWindow::initUI() { |
152 | setToolBarsMovable( FALSE ); | 154 | setToolBarsMovable( FALSE ); |
153 | 155 | ||
154 | /* tool bar for the menu */ | 156 | /* tool bar for the menu */ |
155 | m_tool = new QToolBar( this ); | 157 | m_tool = new QToolBar( this ); |
156 | m_tool->setHorizontalStretchable( TRUE ); | 158 | m_tool->setHorizontalStretchable( TRUE ); |
157 | 159 | ||
158 | m_bar = new QMenuBar( m_tool ); | 160 | m_bar = new QMenuBar( m_tool ); |
159 | m_console = new QPopupMenu( this ); | 161 | m_console = new QPopupMenu( this ); |
160 | m_scripts = new QPopupMenu( this ); | 162 | m_scripts = new QPopupMenu( this ); |
161 | m_sessionsPop= new QPopupMenu( this ); | 163 | m_sessionsPop= new QPopupMenu( this ); |
162 | m_scriptsPop = new QPopupMenu( this ); | 164 | m_scriptsPop = new QPopupMenu( this ); |
163 | 165 | ||
164 | /* add a toolbar for icons */ | 166 | /* add a toolbar for icons */ |
165 | m_icons = new QToolBar(this); | 167 | m_icons = new QToolBar(this); |
166 | 168 | ||
167 | /* | 169 | /* |
168 | * the settings action | 170 | * the settings action |
169 | */ | 171 | */ |
170 | m_setProfiles = new QAction(tr("Configure Profiles"), | 172 | m_setProfiles = new QAction(tr("Configure Profiles"), |
171 | Resource::loadPixmap( "SettingsIcon" ), | 173 | Resource::loadPixmap( "SettingsIcon" ), |
172 | QString::null, 0, this, 0); | 174 | QString::null, 0, this, 0); |
173 | m_setProfiles->addTo( m_console ); | 175 | m_setProfiles->addTo( m_console ); |
174 | connect( m_setProfiles, SIGNAL(activated() ), | 176 | connect( m_setProfiles, SIGNAL(activated() ), |
175 | this, SLOT(slotConfigure() ) ); | 177 | this, SLOT(slotConfigure() ) ); |
176 | 178 | ||
177 | m_console->insertSeparator(); | 179 | m_console->insertSeparator(); |
178 | /* | 180 | /* |
179 | * new Action for new sessions | 181 | * new Action for new sessions |
180 | */ | 182 | */ |
181 | QAction* newCon = new QAction(tr("New Connection"), | 183 | QAction* newCon = new QAction(tr("New Connection"), |
182 | Resource::loadPixmap( "new" ), | 184 | Resource::loadPixmap( "new" ), |
183 | QString::null, 0, this, 0); | 185 | QString::null, 0, this, 0); |
184 | newCon->addTo( m_console ); | 186 | newCon->addTo( m_console ); |
185 | connect( newCon, SIGNAL(activated() ), | 187 | connect( newCon, SIGNAL(activated() ), |
186 | this, SLOT(slotNew() ) ); | 188 | this, SLOT(slotNew() ) ); |
187 | 189 | ||
188 | m_console->insertSeparator(); | 190 | m_console->insertSeparator(); |
189 | 191 | ||
190 | QAction *saveCon = new QAction(tr("Save Connection"), | 192 | QAction *saveCon = new QAction(tr("Save Connection"), |
191 | QPixmap( ( const char** ) filesave_xpm ) , QString::null, | 193 | QPixmap( ( const char** ) filesave_xpm ) , QString::null, |
192 | 0, this, 0 ); | 194 | 0, this, 0 ); |
193 | saveCon->addTo( m_console ); | 195 | saveCon->addTo( m_console ); |
194 | connect( saveCon, SIGNAL(activated() ), | 196 | connect( saveCon, SIGNAL(activated() ), |
195 | this, SLOT(slotSaveSession() ) ); | 197 | this, SLOT(slotSaveSession() ) ); |
196 | m_console->insertSeparator(); | 198 | m_console->insertSeparator(); |
197 | 199 | ||
198 | /* | 200 | /* |
199 | * connect action | 201 | * connect action |
200 | */ | 202 | */ |
201 | m_connect = new QAction( tr("Connect"), Resource::loadPixmap("console/connected"), | 203 | m_connect = new QAction( tr("Connect"), Resource::loadPixmap("console/connected"), |
202 | QString::null, 0, this, 0 ); | 204 | QString::null, 0, this, 0 ); |
203 | m_connect->addTo( m_console ); | 205 | m_connect->addTo( m_console ); |
204 | connect(m_connect, SIGNAL(activated() ), | 206 | connect(m_connect, SIGNAL(activated() ), |
205 | this, SLOT(slotConnect() ) ); | 207 | this, SLOT(slotConnect() ) ); |
206 | 208 | ||
207 | /* | 209 | /* |
208 | * disconnect action | 210 | * disconnect action |
209 | */ | 211 | */ |
210 | m_disconnect = new QAction( tr("Disconnect"), Resource::loadPixmap("console/notconnected"), | 212 | m_disconnect = new QAction( tr("Disconnect"), Resource::loadPixmap("console/notconnected"), |
211 | QString::null, 0, this, 0 ); | 213 | QString::null, 0, this, 0 ); |
212 | m_disconnect->addTo( m_console ); | 214 | m_disconnect->addTo( m_console ); |
213 | connect(m_disconnect, SIGNAL(activated() ), | 215 | connect(m_disconnect, SIGNAL(activated() ), |
214 | this, SLOT(slotDisconnect() ) ); | 216 | this, SLOT(slotDisconnect() ) ); |
215 | 217 | ||
216 | m_console->insertSeparator(); | 218 | m_console->insertSeparator(); |
217 | 219 | ||
218 | m_transfer = new QAction( tr("Transfer file..."), Resource::loadPixmap("pass") , QString::null, | 220 | m_transfer = new QAction( tr("Transfer file..."), Resource::loadPixmap("pass") , QString::null, |
219 | 0, this, 0 ); | 221 | 0, this, 0 ); |
220 | m_transfer->addTo( m_console ); | 222 | m_transfer->addTo( m_console ); |
221 | connect(m_transfer, SIGNAL(activated() ), | 223 | connect(m_transfer, SIGNAL(activated() ), |
222 | this, SLOT(slotTransfer() ) ); | 224 | this, SLOT(slotTransfer() ) ); |
223 | 225 | ||
224 | /* | 226 | /* |
225 | * immediate change of line wrap policy | 227 | * immediate change of line wrap policy |
226 | */ | 228 | */ |
227 | m_isWrapped = false; | 229 | m_isWrapped = false; |
228 | m_wrap = new QAction( tr("Line wrap"), Resource::loadPixmap( "linewrap" ), QString::null, 0, this, 0 ); | 230 | m_wrap = new QAction( tr("Line wrap"), Resource::loadPixmap( "linewrap" ), QString::null, 0, this, 0 ); |
229 | m_wrap->addTo( m_console ); | 231 | m_wrap->addTo( m_console ); |
230 | connect( m_wrap, SIGNAL( activated() ), SLOT( slotWrap() ) ); | 232 | connect( m_wrap, SIGNAL( activated() ), SLOT( slotWrap() ) ); |
231 | 233 | ||
232 | /* | 234 | /* |
233 | * fullscreen | 235 | * fullscreen |
234 | */ | 236 | */ |
235 | m_isFullscreen = false; | 237 | m_isFullscreen = false; |
236 | 238 | ||
237 | m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" ) | 239 | m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" ) |
238 | , QString::null, 0, this, 0); | 240 | , QString::null, 0, this, 0); |
239 | m_fullscreen->addTo( m_console ); | 241 | m_fullscreen->addTo( m_console ); |
240 | connect( m_fullscreen, SIGNAL( activated() ), | 242 | connect( m_fullscreen, SIGNAL( activated() ), |
241 | this, SLOT( slotFullscreen() ) ); | 243 | this, SLOT( slotFullscreen() ) ); |
242 | 244 | ||
243 | m_console->insertSeparator(); | 245 | m_console->insertSeparator(); |
246 | |||
247 | QAction *a = new QAction(); | ||
248 | a->setText( tr("Save history") ); | ||
249 | a->addTo( m_console ); | ||
250 | connect(a, SIGNAL(activated() ), | ||
251 | this, SLOT(slotSaveHistory() ) ); | ||
244 | /* | 252 | /* |
245 | * terminate action | 253 | * terminate action |
246 | */ | 254 | */ |
247 | m_terminate = new QAction(); | 255 | m_terminate = new QAction(); |
248 | m_terminate->setText( tr("Terminate") ); | 256 | m_terminate->setText( tr("Terminate") ); |
249 | m_terminate->addTo( m_console ); | 257 | m_terminate->addTo( m_console ); |
250 | connect(m_terminate, SIGNAL(activated() ), | 258 | connect(m_terminate, SIGNAL(activated() ), |
251 | this, SLOT(slotTerminate() ) ); | 259 | this, SLOT(slotTerminate() ) ); |
252 | 260 | ||
253 | m_closewindow = new QAction(); | 261 | m_closewindow = new QAction(); |
254 | m_closewindow->setText( tr("Close Window") ); | 262 | m_closewindow->setText( tr("Close Window") ); |
255 | m_closewindow->addTo( m_console ); | 263 | m_closewindow->addTo( m_console ); |
256 | connect( m_closewindow, SIGNAL(activated() ), | 264 | connect( m_closewindow, SIGNAL(activated() ), |
257 | this, SLOT(slotClose() ) ); | 265 | this, SLOT(slotClose() ) ); |
258 | 266 | ||
259 | 267 | ||
260 | /* | 268 | /* |
261 | * script actions | 269 | * script actions |
262 | */ | 270 | */ |
263 | m_runScript_id = m_scripts->insertItem(tr("Run Script"), m_scriptsPop, -1, 0); | 271 | m_runScript_id = m_scripts->insertItem(tr("Run Script"), m_scriptsPop, -1, 0); |
264 | connect(m_scriptsPop, SIGNAL(activated(int)), this, SLOT(slotRunScript(int))); | 272 | connect(m_scriptsPop, SIGNAL(activated(int)), this, SLOT(slotRunScript(int))); |
265 | 273 | ||
266 | m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0); | 274 | m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0); |
267 | m_recordScript->addTo(m_scripts); | 275 | m_recordScript->addTo(m_scripts); |
268 | connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript())); | 276 | connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript())); |
269 | 277 | ||
270 | m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0); | 278 | m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0); |
271 | m_saveScript->addTo(m_scripts); | 279 | m_saveScript->addTo(m_scripts); |
272 | connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript())); | 280 | connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript())); |
273 | 281 | ||
274 | 282 | ||
275 | /* | 283 | /* |
276 | * action that open/closes the keyboard | 284 | * action that open/closes the keyboard |
277 | */ | 285 | */ |
278 | m_openKeys = new QAction (tr("Open Keyboard..."), | 286 | m_openKeys = new QAction (tr("Open Keyboard..."), |
279 | Resource::loadPixmap( "console/keys/keyboard_icon" ), | 287 | Resource::loadPixmap( "console/keys/keyboard_icon" ), |
280 | QString::null, 0, this, 0); | 288 | QString::null, 0, this, 0); |
281 | m_openKeys->setToggleAction(true); | 289 | m_openKeys->setToggleAction(true); |
282 | connect (m_openKeys, SIGNAL(toggled(bool)), this, SLOT(slotOpenKeb(bool))); | 290 | connect (m_openKeys, SIGNAL(toggled(bool)), this, SLOT(slotOpenKeb(bool))); |
283 | 291 | ||
284 | /* insert the submenu */ | 292 | /* insert the submenu */ |
285 | m_console->insertItem(tr("New from Profile"), m_sessionsPop, | 293 | m_console->insertItem(tr("New from Profile"), m_sessionsPop, |
286 | -1, 0); | 294 | -1, 0); |
287 | 295 | ||
288 | /* insert the connection menu */ | 296 | /* insert the connection menu */ |
289 | m_bar->insertItem( tr("Connection"), m_console ); | 297 | m_bar->insertItem( tr("Connection"), m_console ); |
290 | 298 | ||
291 | /* the scripts menu */ | 299 | /* the scripts menu */ |
292 | m_bar->insertItem( tr("Scripts"), m_scripts ); | 300 | m_bar->insertItem( tr("Scripts"), m_scripts ); |
293 | 301 | ||
294 | /* and the keyboard */ | 302 | /* and the keyboard */ |
295 | m_keyBar = new QToolBar(this); | 303 | m_keyBar = new QToolBar(this); |
296 | addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); | 304 | addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); |
297 | m_keyBar->setHorizontalStretchable( TRUE ); | 305 | m_keyBar->setHorizontalStretchable( TRUE ); |
298 | m_keyBar->hide(); | 306 | m_keyBar->hide(); |
299 | 307 | ||
300 | m_kb = new FunctionKeyboard(m_keyBar); | 308 | m_kb = new FunctionKeyboard(m_keyBar); |
301 | connect(m_kb, SIGNAL(keyPressed(FKey, ushort, ushort, bool)), | 309 | connect(m_kb, SIGNAL(keyPressed(FKey, ushort, ushort, bool)), |
302 | this, SLOT(slotKeyReceived(FKey, ushort, ushort, bool))); | 310 | this, SLOT(slotKeyReceived(FKey, ushort, ushort, bool))); |
303 | 311 | ||
304 | 312 | ||
305 | QAction *a = new QAction(tr("Copy"), | 313 | a = new QAction(tr("Copy"), |
306 | Resource::loadPixmap("copy"), QString::null, | 314 | Resource::loadPixmap("copy"), QString::null, |
307 | 0, this, 0 ); | 315 | 0, this, 0 ); |
308 | //a->addTo( m_icons ); | 316 | //a->addTo( m_icons ); |
309 | connect( a, SIGNAL(activated() ), | 317 | connect( a, SIGNAL(activated() ), |
310 | this, SLOT(slotCopy() ) ); | 318 | this, SLOT(slotCopy() ) ); |
311 | 319 | ||
312 | QAction *paste = new QAction(tr("Paste"), | 320 | QAction *paste = new QAction(tr("Paste"), |
313 | Resource::loadPixmap("paste"), QString::null, | 321 | Resource::loadPixmap("paste"), QString::null, |
314 | 0, this, 0 ); | 322 | 0, this, 0 ); |
315 | connect( paste, SIGNAL(activated() ), | 323 | connect( paste, SIGNAL(activated() ), |
316 | this, SLOT(slotPaste() ) ); | 324 | this, SLOT(slotPaste() ) ); |
317 | 325 | ||
318 | 326 | ||
319 | newCon->addTo( m_icons ); | 327 | newCon->addTo( m_icons ); |
320 | m_setProfiles->addTo( m_icons ); | 328 | m_setProfiles->addTo( m_icons ); |
321 | paste->addTo( m_icons ); | 329 | paste->addTo( m_icons ); |
322 | m_openKeys->addTo(m_icons); | 330 | m_openKeys->addTo(m_icons); |
323 | m_fullscreen->addTo( m_icons ); | 331 | m_fullscreen->addTo( m_icons ); |
324 | 332 | ||
325 | m_connect->setEnabled( false ); | 333 | m_connect->setEnabled( false ); |
326 | m_disconnect->setEnabled( false ); | 334 | m_disconnect->setEnabled( false ); |
327 | m_terminate->setEnabled( false ); | 335 | m_terminate->setEnabled( false ); |
328 | m_transfer->setEnabled( false ); | 336 | m_transfer->setEnabled( false ); |
329 | m_scripts->setItemEnabled(m_runScript_id, false); | 337 | m_scripts->setItemEnabled(m_runScript_id, false); |
330 | m_recordScript->setEnabled( false ); | 338 | m_recordScript->setEnabled( false ); |
331 | m_saveScript->setEnabled( false ); | 339 | m_saveScript->setEnabled( false ); |
332 | m_fullscreen->setEnabled( false ); | 340 | m_fullscreen->setEnabled( false ); |
333 | m_closewindow->setEnabled( false ); | 341 | m_closewindow->setEnabled( false ); |
334 | m_wrap->setEnabled( false ); | 342 | m_wrap->setEnabled( false ); |
335 | 343 | ||
336 | /* | 344 | /* |
337 | * connect to the menu activation | 345 | * connect to the menu activation |
338 | */ | 346 | */ |
339 | connect( m_sessionsPop, SIGNAL(activated( int ) ), | 347 | connect( m_sessionsPop, SIGNAL(activated( int ) ), |
340 | this, SLOT(slotProfile( int ) ) ); | 348 | this, SLOT(slotProfile( int ) ) ); |
341 | 349 | ||
342 | m_consoleWindow = new TabWidget( this, "blah"); | 350 | m_consoleWindow = new TabWidget( this, "blah"); |
343 | connect(m_consoleWindow, SIGNAL(activated(Session*) ), | 351 | connect(m_consoleWindow, SIGNAL(activated(Session*) ), |
344 | this, SLOT(slotSessionChanged(Session*) ) ); | 352 | this, SLOT(slotSessionChanged(Session*) ) ); |
345 | setCentralWidget( m_consoleWindow ); | 353 | setCentralWidget( m_consoleWindow ); |
346 | 354 | ||
347 | } | 355 | } |
348 | 356 | ||
349 | ProfileManager* MainWindow::manager() { | 357 | ProfileManager* MainWindow::manager() { |
350 | return m_manager; | 358 | return m_manager; |
351 | } | 359 | } |
352 | TabWidget* MainWindow::tabWidget() { | 360 | TabWidget* MainWindow::tabWidget() { |
353 | return m_consoleWindow; | 361 | return m_consoleWindow; |
354 | } | 362 | } |
355 | void MainWindow::populateProfiles() { | 363 | void MainWindow::populateProfiles() { |
356 | m_sessionsPop->clear(); | 364 | m_sessionsPop->clear(); |
357 | Profile::ValueList list = manager()->all(); | 365 | Profile::ValueList list = manager()->all(); |
358 | for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { | 366 | for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { |
359 | m_sessionsPop->insertItem( (*it).name() ); | 367 | m_sessionsPop->insertItem( (*it).name() ); |
360 | } | 368 | } |
361 | 369 | ||
362 | } | 370 | } |
363 | 371 | ||
364 | void MainWindow::populateScripts() { | 372 | void MainWindow::populateScripts() { |
365 | m_scriptsPop->clear(); | 373 | m_scriptsPop->clear(); |
366 | m_scriptsData.clear(); | 374 | m_scriptsData.clear(); |
367 | DocLnkSet files(QPEApplication::documentDir(), "text/plain"); | 375 | DocLnkSet files(QPEApplication::documentDir(), "text/plain"); |
368 | QListIterator<DocLnk> dit(files.children()); | 376 | QListIterator<DocLnk> dit(files.children()); |
369 | for (; dit.current(); ++dit) { | 377 | for (; dit.current(); ++dit) { |
370 | if (*dit && (*dit)->name().length()>0) { | 378 | if (*dit && (*dit)->name().length()>0) { |
371 | QFileInfo info((*dit)->file()); | 379 | QFileInfo info((*dit)->file()); |
372 | if (info.extension(false) == "script") { | 380 | if (info.extension(false) == "script") { |
373 | m_scriptsData.append(new DocLnk(**dit)); | 381 | m_scriptsData.append(new DocLnk(**dit)); |
374 | m_scriptsPop->insertItem((*dit)->name()); | 382 | m_scriptsPop->insertItem((*dit)->name()); |
375 | } | 383 | } |
376 | } | 384 | } |
377 | } | 385 | } |
378 | 386 | ||
379 | } | 387 | } |
380 | 388 | ||
381 | MainWindow::~MainWindow() { | 389 | MainWindow::~MainWindow() { |
382 | delete m_factory; | 390 | delete m_factory; |
383 | manager()->save(); | 391 | manager()->save(); |
384 | } | 392 | } |
385 | 393 | ||
386 | MetaFactory* MainWindow::factory() { | 394 | MetaFactory* MainWindow::factory() { |
387 | return m_factory; | 395 | return m_factory; |
388 | } | 396 | } |
389 | 397 | ||
390 | Session* MainWindow::currentSession() { | 398 | Session* MainWindow::currentSession() { |
391 | return m_curSession; | 399 | return m_curSession; |
392 | } | 400 | } |
393 | 401 | ||
394 | QList<Session> MainWindow::sessions() { | 402 | QList<Session> MainWindow::sessions() { |
395 | return m_sessions; | 403 | return m_sessions; |
396 | } | 404 | } |
397 | 405 | ||
398 | void MainWindow::slotNew() { | 406 | void MainWindow::slotNew() { |
399 | ProfileEditorDialog dlg(factory() ); | 407 | ProfileEditorDialog dlg(factory() ); |
400 | dlg.showMaximized(); | 408 | dlg.showMaximized(); |
401 | dlg.setCaption( tr("New Connection") ); | 409 | dlg.setCaption( tr("New Connection") ); |
402 | int ret = dlg.exec(); | 410 | int ret = dlg.exec(); |
403 | 411 | ||
404 | if ( ret == QDialog::Accepted ) { | 412 | if ( ret == QDialog::Accepted ) { |
405 | create( dlg.profile() ); | 413 | create( dlg.profile() ); |
406 | } | 414 | } |
407 | } | 415 | } |
408 | 416 | ||
409 | void MainWindow::slotRecordScript() { | 417 | void MainWindow::slotRecordScript() { |
410 | if (currentSession()) { | 418 | if (currentSession()) { |
411 | currentSession()->emulationHandler()->startRecording(); | 419 | currentSession()->emulationHandler()->startRecording(); |
412 | m_saveScript->setEnabled(true); | 420 | m_saveScript->setEnabled(true); |
413 | m_recordScript->setEnabled(false); | 421 | m_recordScript->setEnabled(false); |
414 | } | 422 | } |
415 | } | 423 | } |
416 | 424 | ||
417 | void MainWindow::slotSaveScript() { | 425 | void MainWindow::slotSaveScript() { |
418 | if (currentSession() && currentSession()->emulationHandler()->isRecording()) { | 426 | if (currentSession() && currentSession()->emulationHandler()->isRecording()) { |
419 | QMap<QString, QStringList> map; | 427 | QMap<QString, QStringList> map; |
420 | QStringList text; | 428 | QStringList text; |
421 | text << "text/plain"; | 429 | text << "text/plain"; |
422 | map.insert(tr("Script"), text ); | 430 | map.insert(tr("Script"), text ); |
423 | QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); | 431 | QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); |
424 | if (!filename.isEmpty()) { | 432 | if (!filename.isEmpty()) { |
425 | QFileInfo info(filename); | 433 | QFileInfo info(filename); |
426 | if (info.extension(FALSE) != "script") | 434 | if (info.extension(FALSE) != "script") |
427 | filename += ".script"; | 435 | filename += ".script"; |
428 | DocLnk nf; | 436 | DocLnk nf; |
429 | nf.setType("text/plain"); | 437 | nf.setType("text/plain"); |
430 | nf.setFile(filename); | 438 | nf.setFile(filename); |
431 | nf.setName(info.fileName()); | 439 | nf.setName(info.fileName()); |
432 | FileManager fm; | 440 | FileManager fm; |
433 | fm.saveFile(nf, currentSession()->emulationHandler()->script()->script()); | 441 | fm.saveFile(nf, currentSession()->emulationHandler()->script()->script()); |
434 | currentSession()->emulationHandler()->clearScript(); | 442 | currentSession()->emulationHandler()->clearScript(); |
435 | m_saveScript->setEnabled(false); | 443 | m_saveScript->setEnabled(false); |
436 | m_recordScript->setEnabled(true); | 444 | m_recordScript->setEnabled(true); |
437 | populateScripts(); | 445 | populateScripts(); |
438 | } | 446 | } |
439 | } | 447 | } |
440 | } | 448 | } |
441 | 449 | ||
442 | void MainWindow::slotRunScript(int id) { | 450 | void MainWindow::slotRunScript(int id) { |
443 | if (currentSession()) { | 451 | if (currentSession()) { |
444 | int index = m_scriptsPop->indexOf(id); | 452 | int index = m_scriptsPop->indexOf(id); |
445 | DocLnk *lnk = m_scriptsData.at(index); | 453 | DocLnk *lnk = m_scriptsData.at(index); |
446 | QString filePath = lnk->file(); | 454 | QString filePath = lnk->file(); |
447 | Script script(filePath); | 455 | Script script(filePath); |
448 | currentSession()->emulationHandler()->runScript(&script); | 456 | currentSession()->emulationHandler()->runScript(&script); |
449 | } | 457 | } |
450 | } | 458 | } |
451 | 459 | ||
452 | void MainWindow::slotConnect() { | 460 | void MainWindow::slotConnect() { |
453 | if ( currentSession() ) { | 461 | if ( currentSession() ) { |
454 | bool ret = currentSession()->layer()->open(); | 462 | bool ret = currentSession()->layer()->open(); |
455 | if(!ret) QMessageBox::warning(currentSession()->widgetStack(), | 463 | if(!ret) QMessageBox::warning(currentSession()->widgetStack(), |
456 | QObject::tr("Failed"), | 464 | QObject::tr("Failed"), |
457 | QObject::tr("Connecting failed for this session.")); | 465 | QObject::tr("Connecting failed for this session.")); |
458 | else { | 466 | else { |
459 | m_connect->setEnabled( false ); | 467 | m_connect->setEnabled( false ); |
460 | m_disconnect->setEnabled( true ); | 468 | m_disconnect->setEnabled( true ); |
461 | 469 | ||
462 | // if it does not support file transfer, disable the menu entry | 470 | // if it does not support file transfer, disable the menu entry |
463 | if ( ( m_curSession->layer() )->supports()[1] == 0 ) { | 471 | if ( ( m_curSession->layer() )->supports()[1] == 0 ) { |
464 | m_transfer->setEnabled( false ); | 472 | m_transfer->setEnabled( false ); |
465 | } else { | 473 | } else { |
466 | m_transfer->setEnabled( true ); | 474 | m_transfer->setEnabled( true ); |
467 | } | 475 | } |
468 | 476 | ||
469 | m_recordScript->setEnabled( true ); | 477 | m_recordScript->setEnabled( true ); |
470 | m_scripts->setItemEnabled(m_runScript_id, true); | 478 | m_scripts->setItemEnabled(m_runScript_id, true); |
471 | } | 479 | } |
472 | } | 480 | } |
473 | } | 481 | } |
474 | 482 | ||
475 | void MainWindow::slotDisconnect() { | 483 | void MainWindow::slotDisconnect() { |
476 | if ( currentSession() ) { | 484 | if ( currentSession() ) { |
477 | currentSession()->layer()->close(); | 485 | currentSession()->layer()->close(); |
478 | m_connect->setEnabled( true ); | 486 | m_connect->setEnabled( true ); |
479 | m_disconnect->setEnabled( false ); | 487 | m_disconnect->setEnabled( false ); |
480 | m_transfer->setEnabled( false ); | 488 | m_transfer->setEnabled( false ); |
481 | m_recordScript->setEnabled( false); | 489 | m_recordScript->setEnabled( false); |
482 | m_saveScript->setEnabled( false ); | 490 | m_saveScript->setEnabled( false ); |
483 | m_scripts->setItemEnabled(m_runScript_id, false); | 491 | m_scripts->setItemEnabled(m_runScript_id, false); |
484 | } | 492 | } |
485 | } | 493 | } |
486 | 494 | ||
487 | void MainWindow::slotTerminate() { | 495 | void MainWindow::slotTerminate() { |
488 | if ( currentSession() ) | 496 | if ( currentSession() ) |
489 | currentSession()->layer()->close(); | 497 | currentSession()->layer()->close(); |
490 | 498 | ||
491 | slotClose(); | 499 | slotClose(); |
492 | /* FIXME move to the next session */ | 500 | /* FIXME move to the next session */ |
493 | } | 501 | } |
494 | 502 | ||
495 | void MainWindow::slotConfigure() { | 503 | void MainWindow::slotConfigure() { |
496 | ConfigDialog conf( manager()->all(), factory() ); | 504 | ConfigDialog conf( manager()->all(), factory() ); |
497 | conf.showMaximized(); | 505 | conf.showMaximized(); |
@@ -579,192 +587,217 @@ void MainWindow::create( const Profile& prof ) { | |||
579 | m_transfer->setEnabled( false ); | 587 | m_transfer->setEnabled( false ); |
580 | m_recordScript->setEnabled( false ); | 588 | m_recordScript->setEnabled( false ); |
581 | m_saveScript->setEnabled( false ); | 589 | m_saveScript->setEnabled( false ); |
582 | m_scripts->setItemEnabled(m_runScript_id, false); | 590 | m_scripts->setItemEnabled(m_runScript_id, false); |
583 | 591 | ||
584 | // is io_layer wants direct connection, then autoconnect | 592 | // is io_layer wants direct connection, then autoconnect |
585 | //if ( ( m_curSession->layer() )->supports()[0] == 1 ) { | 593 | //if ( ( m_curSession->layer() )->supports()[0] == 1 ) { |
586 | if (prof.autoConnect()) { | 594 | if (prof.autoConnect()) { |
587 | slotConnect(); | 595 | slotConnect(); |
588 | } | 596 | } |
589 | 597 | ||
590 | 598 | ||
591 | QWidget *w = currentSession()->widget(); | 599 | QWidget *w = currentSession()->widget(); |
592 | if(w) w->setFocus(); | 600 | if(w) w->setFocus(); |
593 | 601 | ||
594 | if(currentSession()->profile().readNumEntry("Wrap", 80)){ | 602 | if(currentSession()->profile().readNumEntry("Wrap", 80)){ |
595 | m_isWrapped = true; | 603 | m_isWrapped = true; |
596 | } else { | 604 | } else { |
597 | m_isWrapped = false; | 605 | m_isWrapped = false; |
598 | } | 606 | } |
599 | 607 | ||
600 | m_kb->load(currentSession()->profile()); | 608 | m_kb->load(currentSession()->profile()); |
601 | } | 609 | } |
602 | 610 | ||
603 | void MainWindow::slotTransfer() | 611 | void MainWindow::slotTransfer() |
604 | { | 612 | { |
605 | if ( currentSession() ) { | 613 | if ( currentSession() ) { |
606 | Session *mysession = currentSession(); | 614 | Session *mysession = currentSession(); |
607 | TransferDialog dlg(/*mysession->widgetStack()*/this, this); | 615 | TransferDialog dlg(/*mysession->widgetStack()*/this, this); |
608 | mysession->setTransferDialog(&dlg); | 616 | mysession->setTransferDialog(&dlg); |
609 | //dlg.reparent(mysession->widgetStack(), QPoint(0, 0)); | 617 | //dlg.reparent(mysession->widgetStack(), QPoint(0, 0)); |
610 | //dlg.showMaximized(); | 618 | //dlg.showMaximized(); |
611 | currentSession()->widgetStack()->addWidget(&dlg, -1); | 619 | currentSession()->widgetStack()->addWidget(&dlg, -1); |
612 | dlg.show(); | 620 | dlg.show(); |
613 | //dlg.exec(); | 621 | //dlg.exec(); |
614 | while(dlg.isRunning()) qApp->processEvents(); | 622 | while(dlg.isRunning()) qApp->processEvents(); |
615 | mysession->setTransferDialog(0l); | 623 | mysession->setTransferDialog(0l); |
616 | } | 624 | } |
617 | } | 625 | } |
618 | 626 | ||
619 | 627 | ||
620 | void MainWindow::slotOpenKeb(bool state) { | 628 | void MainWindow::slotOpenKeb(bool state) { |
621 | 629 | ||
622 | if (state) m_keyBar->show(); | 630 | if (state) m_keyBar->show(); |
623 | else m_keyBar->hide(); | 631 | else m_keyBar->hide(); |
624 | 632 | ||
625 | } | 633 | } |
626 | 634 | ||
627 | 635 | ||
628 | void MainWindow::slotOpenButtons( bool state ) { | 636 | void MainWindow::slotOpenButtons( bool state ) { |
629 | 637 | ||
630 | if ( state ) { | 638 | if ( state ) { |
631 | m_buttonBar->show(); | 639 | m_buttonBar->show(); |
632 | } else { | 640 | } else { |
633 | m_buttonBar->hide(); | 641 | m_buttonBar->hide(); |
634 | } | 642 | } |
635 | } | 643 | } |
636 | 644 | ||
637 | 645 | ||
638 | 646 | ||
639 | void MainWindow::slotSessionChanged( Session* ses ) { | 647 | void MainWindow::slotSessionChanged( Session* ses ) { |
640 | qWarning("changed!"); | 648 | qWarning("changed!"); |
641 | 649 | ||
642 | if(m_curSession) | 650 | if(m_curSession) |
643 | if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); | 651 | if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); |
644 | if(ses) | 652 | if(ses) |
645 | if(ses->transferDialog()) ses->transferDialog()->show(); | 653 | if(ses->transferDialog()) ses->transferDialog()->show(); |
646 | 654 | ||
647 | if ( ses ) { | 655 | if ( ses ) { |
648 | m_curSession = ses; | 656 | m_curSession = ses; |
649 | qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) ); | 657 | qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) ); |
650 | if ( m_curSession->layer()->isConnected() ) { | 658 | if ( m_curSession->layer()->isConnected() ) { |
651 | m_connect->setEnabled( false ); | 659 | m_connect->setEnabled( false ); |
652 | m_disconnect->setEnabled( true ); | 660 | m_disconnect->setEnabled( true ); |
653 | m_recordScript->setEnabled(!m_curSession->emulationHandler()->isRecording()); | 661 | m_recordScript->setEnabled(!m_curSession->emulationHandler()->isRecording()); |
654 | m_saveScript->setEnabled(m_curSession->emulationHandler()->isRecording()); | 662 | m_saveScript->setEnabled(m_curSession->emulationHandler()->isRecording()); |
655 | m_scripts->setItemEnabled(m_runScript_id, true); | 663 | m_scripts->setItemEnabled(m_runScript_id, true); |
656 | } else { | 664 | } else { |
657 | m_connect->setEnabled( true ); | 665 | m_connect->setEnabled( true ); |
658 | m_disconnect->setEnabled( false ); | 666 | m_disconnect->setEnabled( false ); |
659 | m_recordScript->setEnabled( false ); | 667 | m_recordScript->setEnabled( false ); |
660 | m_saveScript->setEnabled( false ); | 668 | m_saveScript->setEnabled( false ); |
661 | m_scripts->setItemEnabled(m_runScript_id, false); | 669 | m_scripts->setItemEnabled(m_runScript_id, false); |
662 | } | 670 | } |
663 | 671 | ||
664 | if ( ( m_curSession->layer() )->supports()[1] == 0 ) { | 672 | if ( ( m_curSession->layer() )->supports()[1] == 0 ) { |
665 | m_transfer->setEnabled( false ); | 673 | m_transfer->setEnabled( false ); |
666 | } else { | 674 | } else { |
667 | m_transfer->setEnabled( true ); | 675 | m_transfer->setEnabled( true ); |
668 | } | 676 | } |
669 | 677 | ||
670 | QWidget *w = m_curSession->widget(); | 678 | QWidget *w = m_curSession->widget(); |
671 | if(w) w->setFocus(); | 679 | if(w) w->setFocus(); |
672 | 680 | ||
673 | if(currentSession()->profile().readNumEntry("Wrap", 80)){ | 681 | if(currentSession()->profile().readNumEntry("Wrap", 80)){ |
674 | m_isWrapped = true; | 682 | m_isWrapped = true; |
675 | } else { | 683 | } else { |
676 | m_isWrapped = false; | 684 | m_isWrapped = false; |
677 | } | 685 | } |
678 | 686 | ||
679 | m_kb->load(currentSession()->profile()); | 687 | m_kb->load(currentSession()->profile()); |
680 | } | 688 | } |
681 | } | 689 | } |
682 | 690 | ||
683 | void MainWindow::slotWrap() | 691 | void MainWindow::slotWrap() |
684 | { | 692 | { |
685 | if(m_curSession) | 693 | if(m_curSession) |
686 | { | 694 | { |
687 | EmulationHandler *e = m_curSession->emulationHandler(); | 695 | EmulationHandler *e = m_curSession->emulationHandler(); |
688 | if(e) | 696 | if(e) |
689 | { | 697 | { |
690 | if(m_isWrapped) | 698 | if(m_isWrapped) |
691 | { | 699 | { |
692 | e->setWrap(80); | 700 | e->setWrap(80); |
693 | m_isWrapped = false; | 701 | m_isWrapped = false; |
694 | } | 702 | } |
695 | else | 703 | else |
696 | { | 704 | { |
697 | e->setWrap(0); | 705 | e->setWrap(0); |
698 | m_isWrapped = true; | 706 | m_isWrapped = true; |
699 | } | 707 | } |
700 | } | 708 | } |
701 | } | 709 | } |
702 | } | 710 | } |
703 | 711 | ||
704 | void MainWindow::slotFullscreen() { | 712 | void MainWindow::slotFullscreen() { |
705 | 713 | ||
706 | 714 | ||
707 | 715 | ||
708 | if ( m_isFullscreen ) { | 716 | if ( m_isFullscreen ) { |
709 | ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), true ); | 717 | ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), true ); |
710 | ( m_curSession->widgetStack() )->resize( savedParentFullscreen->width(), savedParentFullscreen->height() ); | 718 | ( m_curSession->widgetStack() )->resize( savedParentFullscreen->width(), savedParentFullscreen->height() ); |
711 | ( m_curSession->emulationHandler() )->cornerButton()->hide(); | 719 | ( m_curSession->emulationHandler() )->cornerButton()->hide(); |
712 | disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); | 720 | disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); |
713 | 721 | ||
714 | } else { | 722 | } else { |
715 | savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget(); | 723 | savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget(); |
716 | ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); | 724 | ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); |
717 | ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop | 725 | ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop |
718 | , QPoint(0,0), false ); | 726 | , QPoint(0,0), false ); |
719 | ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() ); | 727 | ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() ); |
720 | ( m_curSession->widgetStack() )->setFocus(); | 728 | ( m_curSession->widgetStack() )->setFocus(); |
721 | ( m_curSession->widgetStack() )->show(); | 729 | ( m_curSession->widgetStack() )->show(); |
722 | 730 | ||
723 | ( ( m_curSession->emulationHandler() )->cornerButton() )->show(); | 731 | ( ( m_curSession->emulationHandler() )->cornerButton() )->show(); |
724 | 732 | ||
725 | connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); | 733 | connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); |
726 | } | 734 | } |
727 | 735 | ||
728 | m_isFullscreen = !m_isFullscreen; | 736 | m_isFullscreen = !m_isFullscreen; |
729 | } | 737 | } |
730 | 738 | ||
731 | 739 | ||
732 | void MainWindow::slotKeyReceived(FKey k, ushort, ushort, bool pressed) { | 740 | void MainWindow::slotKeyReceived(FKey k, ushort, ushort, bool pressed) { |
733 | 741 | ||
734 | if ( m_curSession ) { | 742 | if ( m_curSession ) { |
735 | 743 | ||
736 | QEvent::Type state; | 744 | QEvent::Type state; |
737 | 745 | ||
738 | if (pressed) state = QEvent::KeyPress; | 746 | if (pressed) state = QEvent::KeyPress; |
739 | else state = QEvent::KeyRelease; | 747 | else state = QEvent::KeyRelease; |
740 | 748 | ||
741 | QKeyEvent ke(state, k.qcode, k.unicode, 0, QString(QChar(k.unicode))); | 749 | QKeyEvent ke(state, k.qcode, k.unicode, 0, QString(QChar(k.unicode))); |
742 | 750 | ||
743 | // is this the best way to do this? cant figure out any other way to work | 751 | // is this the best way to do this? cant figure out any other way to work |
744 | QApplication::sendEvent((QObject *)m_curSession->widget(), &ke); | 752 | QApplication::sendEvent((QObject *)m_curSession->widget(), &ke); |
745 | ke.ignore(); | 753 | ke.ignore(); |
746 | } | 754 | } |
747 | } | 755 | } |
748 | void MainWindow::slotCopy() { | 756 | void MainWindow::slotCopy() { |
749 | if (!currentSession() ) return; | 757 | if (!currentSession() ) return; |
750 | currentSession()->emulationHandler()->copy(); | 758 | currentSession()->emulationHandler()->copy(); |
751 | } | 759 | } |
752 | void MainWindow::slotPaste() { | 760 | void MainWindow::slotPaste() { |
753 | if (!currentSession() ) return; | 761 | if (!currentSession() ) return; |
754 | currentSession()->emulationHandler()->paste(); | 762 | currentSession()->emulationHandler()->paste(); |
755 | } | 763 | } |
756 | 764 | ||
757 | /* | 765 | /* |
758 | * Save the session | 766 | * Save the session |
759 | */ | 767 | */ |
760 | 768 | ||
761 | void MainWindow::slotSaveSession() { | 769 | void MainWindow::slotSaveSession() { |
762 | if (!currentSession() ) { | 770 | if (!currentSession() ) { |
763 | QMessageBox::information(this, tr("Save Connection"), | 771 | QMessageBox::information(this, tr("Save Connection"), |
764 | tr("<qt>There is no Connection.</qt>"), 1 ); | 772 | tr("<qt>There is no Connection.</qt>"), 1 ); |
765 | return; | 773 | return; |
766 | } | 774 | } |
767 | manager()->add( currentSession()->profile() ); | 775 | manager()->add( currentSession()->profile() ); |
768 | manager()->save(); | 776 | manager()->save(); |
769 | populateProfiles(); | 777 | populateProfiles(); |
770 | } | 778 | } |
779 | void MainWindow::slotSaveHistory() { | ||
780 | QMap<QString, QStringList> map; | ||
781 | QStringList text; | ||
782 | text << "text/plain"; | ||
783 | map.insert(tr("History"), text ); | ||
784 | QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); | ||
785 | if (filename.isEmpty() ) return; | ||
786 | |||
787 | QFileInfo info(filename); | ||
788 | |||
789 | DocLnk nf; | ||
790 | nf.setType("text/plain"); | ||
791 | nf.setFile(filename); | ||
792 | nf.setName(info.fileName()); | ||
793 | |||
794 | |||
795 | QFile file(filename); | ||
796 | file.open(IO_WriteOnly ); | ||
797 | QTextStream str(&file ); | ||
798 | if ( currentSession() ) | ||
799 | currentSession()->emulationHandler()->emulation()->streamHistory(&str); | ||
800 | |||
801 | file.close(); | ||
802 | nf.writeLink(); | ||
803 | } | ||
diff --git a/noncore/apps/opie-console/mainwindow.h b/noncore/apps/opie-console/mainwindow.h index 37219c5..0fac38b 100644 --- a/noncore/apps/opie-console/mainwindow.h +++ b/noncore/apps/opie-console/mainwindow.h | |||
@@ -1,135 +1,136 @@ | |||
1 | #ifndef OPIE_MAIN_WINDOW_H | 1 | #ifndef OPIE_MAIN_WINDOW_H |
2 | #define OPIE_MAIN_WINDOW_H | 2 | #define OPIE_MAIN_WINDOW_H |
3 | 3 | ||
4 | #include <qmainwindow.h> | 4 | #include <qmainwindow.h> |
5 | #include <qlist.h> | 5 | #include <qlist.h> |
6 | 6 | ||
7 | #include "session.h" | 7 | #include "session.h" |
8 | 8 | ||
9 | /** | 9 | /** |
10 | * this is the MainWindow of the new opie console | 10 | * this is the MainWindow of the new opie console |
11 | * it's also the dispatcher between the different | 11 | * it's also the dispatcher between the different |
12 | * actions supported by the gui | 12 | * actions supported by the gui |
13 | */ | 13 | */ |
14 | class QToolBar; | 14 | class QToolBar; |
15 | class QToolButton; | 15 | class QToolButton; |
16 | class QMenuBar; | 16 | class QMenuBar; |
17 | class QAction; | 17 | class QAction; |
18 | class MetaFactory; | 18 | class MetaFactory; |
19 | class TabWidget; | 19 | class TabWidget; |
20 | class ProfileManager; | 20 | class ProfileManager; |
21 | class Profile; | 21 | class Profile; |
22 | class FunctionKeyboard; | 22 | class FunctionKeyboard; |
23 | class FKey; | 23 | class FKey; |
24 | class DocLnk; | 24 | class DocLnk; |
25 | 25 | ||
26 | class MainWindow : public QMainWindow { | 26 | class MainWindow : public QMainWindow { |
27 | Q_OBJECT | 27 | Q_OBJECT |
28 | public: | 28 | public: |
29 | MainWindow( QWidget *parent = 0, const char *name = 0, WFlags fl = 0 ); | 29 | MainWindow( QWidget *parent = 0, const char *name = 0, WFlags fl = 0 ); |
30 | ~MainWindow(); | 30 | ~MainWindow(); |
31 | 31 | ||
32 | /** | 32 | /** |
33 | * our factory to generate IOLayer and so on | 33 | * our factory to generate IOLayer and so on |
34 | * | 34 | * |
35 | */ | 35 | */ |
36 | MetaFactory* factory(); | 36 | MetaFactory* factory(); |
37 | 37 | ||
38 | /** | 38 | /** |
39 | * A session contains a QWidget*, | 39 | * A session contains a QWidget*, |
40 | * an IOLayer* and some infos for us | 40 | * an IOLayer* and some infos for us |
41 | */ | 41 | */ |
42 | Session* currentSession(); | 42 | Session* currentSession(); |
43 | 43 | ||
44 | /** | 44 | /** |
45 | * the session list | 45 | * the session list |
46 | */ | 46 | */ |
47 | QList<Session> sessions(); | 47 | QList<Session> sessions(); |
48 | 48 | ||
49 | /** | 49 | /** |
50 | * | 50 | * |
51 | */ | 51 | */ |
52 | ProfileManager* manager(); | 52 | ProfileManager* manager(); |
53 | TabWidget* tabWidget(); | 53 | TabWidget* tabWidget(); |
54 | 54 | ||
55 | private slots: | 55 | private slots: |
56 | void slotNew(); | 56 | void slotNew(); |
57 | void slotConnect(); | 57 | void slotConnect(); |
58 | void slotDisconnect(); | 58 | void slotDisconnect(); |
59 | void slotTerminate(); | 59 | void slotTerminate(); |
60 | void slotConfigure(); | 60 | void slotConfigure(); |
61 | void slotClose(); | 61 | void slotClose(); |
62 | void slotProfile(int); | 62 | void slotProfile(int); |
63 | void slotTransfer(); | 63 | void slotTransfer(); |
64 | void slotOpenKeb(bool); | 64 | void slotOpenKeb(bool); |
65 | void slotOpenButtons(bool); | 65 | void slotOpenButtons(bool); |
66 | void slotRecordScript(); | 66 | void slotRecordScript(); |
67 | void slotSaveScript(); | 67 | void slotSaveScript(); |
68 | void slotRunScript(int); | 68 | void slotRunScript(int); |
69 | void slotFullscreen(); | 69 | void slotFullscreen(); |
70 | void slotWrap(); | 70 | void slotWrap(); |
71 | void slotSessionChanged( Session* ); | 71 | void slotSessionChanged( Session* ); |
72 | void slotKeyReceived(FKey, ushort, ushort, bool); | 72 | void slotKeyReceived(FKey, ushort, ushort, bool); |
73 | void slotSaveHistory(); | ||
73 | 74 | ||
74 | /* what could these both slot do? */ | 75 | /* what could these both slot do? */ |
75 | void slotCopy(); | 76 | void slotCopy(); |
76 | void slotPaste(); | 77 | void slotPaste(); |
77 | 78 | ||
78 | /* save the currentSession() to Profiles */ | 79 | /* save the currentSession() to Profiles */ |
79 | void slotSaveSession(); | 80 | void slotSaveSession(); |
80 | 81 | ||
81 | private: | 82 | private: |
82 | void initUI(); | 83 | void initUI(); |
83 | void populateProfiles(); | 84 | void populateProfiles(); |
84 | void populateScripts(); | 85 | void populateScripts(); |
85 | void create( const Profile& ); | 86 | void create( const Profile& ); |
86 | /** | 87 | /** |
87 | * the current session | 88 | * the current session |
88 | */ | 89 | */ |
89 | Session* m_curSession; | 90 | Session* m_curSession; |
90 | 91 | ||
91 | /** | 92 | /** |
92 | * the session list | 93 | * the session list |
93 | */ | 94 | */ |
94 | QList<Session> m_sessions; | 95 | QList<Session> m_sessions; |
95 | QList<DocLnk> m_scriptsData; | 96 | QList<DocLnk> m_scriptsData; |
96 | 97 | ||
97 | /** | 98 | /** |
98 | * the metafactory | 99 | * the metafactory |
99 | */ | 100 | */ |
100 | MetaFactory* m_factory; | 101 | MetaFactory* m_factory; |
101 | ProfileManager* m_manager; | 102 | ProfileManager* m_manager; |
102 | 103 | ||
103 | TabWidget* m_consoleWindow; | 104 | TabWidget* m_consoleWindow; |
104 | QToolBar* m_tool; | 105 | QToolBar* m_tool; |
105 | QToolBar* m_icons; | 106 | QToolBar* m_icons; |
106 | QToolBar* m_keyBar; | 107 | QToolBar* m_keyBar; |
107 | QToolBar* m_buttonBar; | 108 | QToolBar* m_buttonBar; |
108 | QMenuBar* m_bar; | 109 | QMenuBar* m_bar; |
109 | QPopupMenu* m_console; | 110 | QPopupMenu* m_console; |
110 | QPopupMenu* m_sessionsPop; | 111 | QPopupMenu* m_sessionsPop; |
111 | QPopupMenu* m_scriptsPop; | 112 | QPopupMenu* m_scriptsPop; |
112 | QPopupMenu* m_scripts; | 113 | QPopupMenu* m_scripts; |
113 | QAction* m_connect; | 114 | QAction* m_connect; |
114 | QAction* m_disconnect; | 115 | QAction* m_disconnect; |
115 | QAction* m_terminate; | 116 | QAction* m_terminate; |
116 | QAction* m_transfer; | 117 | QAction* m_transfer; |
117 | QAction* m_setProfiles; | 118 | QAction* m_setProfiles; |
118 | QAction* m_openKeys; | 119 | QAction* m_openKeys; |
119 | QAction* m_openButtons; | 120 | QAction* m_openButtons; |
120 | QAction* m_recordScript; | 121 | QAction* m_recordScript; |
121 | QAction* m_saveScript; | 122 | QAction* m_saveScript; |
122 | QAction* m_fullscreen; | 123 | QAction* m_fullscreen; |
123 | QAction* m_wrap; | 124 | QAction* m_wrap; |
124 | QAction* m_closewindow; | 125 | QAction* m_closewindow; |
125 | 126 | ||
126 | FunctionKeyboard *m_kb; | 127 | FunctionKeyboard *m_kb; |
127 | int m_runScript_id; | 128 | int m_runScript_id; |
128 | bool m_isFullscreen; | 129 | bool m_isFullscreen; |
129 | bool m_isWrapped; | 130 | bool m_isWrapped; |
130 | 131 | ||
131 | QWidget* savedParentFullscreen; | 132 | QWidget* savedParentFullscreen; |
132 | }; | 133 | }; |
133 | 134 | ||
134 | 135 | ||
135 | #endif | 136 | #endif |
diff --git a/noncore/apps/opie-console/metafactory.cpp b/noncore/apps/opie-console/metafactory.cpp index 0b43e17..24928e7 100644 --- a/noncore/apps/opie-console/metafactory.cpp +++ b/noncore/apps/opie-console/metafactory.cpp | |||
@@ -1,190 +1,165 @@ | |||
1 | #include <qpe/config.h> | 1 | #include <qpe/config.h> |
2 | #include "metafactory.h" | 2 | #include "metafactory.h" |
3 | 3 | ||
4 | MetaFactory::MetaFactory() { | 4 | MetaFactory::MetaFactory() { |
5 | } | 5 | } |
6 | MetaFactory::~MetaFactory() { | 6 | MetaFactory::~MetaFactory() { |
7 | 7 | ||
8 | } | 8 | } |
9 | void MetaFactory::addConnectionWidgetFactory( const QCString& name, | 9 | void MetaFactory::addConnectionWidgetFactory( const QCString& name, |
10 | const QString& str, | 10 | const QString& str, |
11 | configWidget wid) { | 11 | configWidget wid) { |
12 | m_strings.insert( str, name ); | 12 | m_strings.insert( str, name ); |
13 | m_conFact.insert( str, wid ); | 13 | m_conFact.insert( str, wid ); |
14 | } | 14 | } |
15 | void MetaFactory::addTerminalWidgetFactory( const QCString& name, | 15 | void MetaFactory::addTerminalWidgetFactory( const QCString& name, |
16 | const QString& str, | 16 | const QString& str, |
17 | configWidget wid ) { | 17 | configWidget wid ) { |
18 | m_strings.insert( str, name ); | 18 | m_strings.insert( str, name ); |
19 | m_termFact.insert( str, wid ); | 19 | m_termFact.insert( str, wid ); |
20 | } | 20 | } |
21 | void MetaFactory::addKeyboardWidgetFactory( const QCString& name, | 21 | void MetaFactory::addKeyboardWidgetFactory( const QCString& name, |
22 | const QString & str, | 22 | const QString & str, |
23 | configWidget wid) { | 23 | configWidget wid) { |
24 | m_strings.insert( str, name ); | 24 | m_strings.insert( str, name ); |
25 | m_keyFact.insert( str, wid ); | 25 | m_keyFact.insert( str, wid ); |
26 | 26 | ||
27 | } | 27 | } |
28 | void MetaFactory::addIOLayerFactory( const QCString& name, | 28 | void MetaFactory::addIOLayerFactory( const QCString& name, |
29 | const QString& str, | 29 | const QString& str, |
30 | iolayer lay) { | 30 | iolayer lay) { |
31 | m_strings.insert( str, name ); | 31 | m_strings.insert( str, name ); |
32 | m_layerFact.insert( str, lay ); | 32 | m_layerFact.insert( str, lay ); |
33 | } | 33 | } |
34 | void MetaFactory::addFileTransferLayer( const QCString& name, | 34 | void MetaFactory::addFileTransferLayer( const QCString& name, |
35 | const QString& str, | 35 | const QString& str, |
36 | filelayer lay) { | 36 | filelayer lay) { |
37 | m_strings.insert(str, name ); | 37 | m_strings.insert(str, name ); |
38 | m_fileFact.insert( str, lay ); | 38 | m_fileFact.insert( str, lay ); |
39 | } | 39 | } |
40 | void MetaFactory::addReceiveLayer( const QCString& name, | 40 | void MetaFactory::addReceiveLayer( const QCString& name, |
41 | const QString& str, | 41 | const QString& str, |
42 | receivelayer lay) { | 42 | receivelayer lay) { |
43 | m_strings.insert(str, name ); | 43 | m_strings.insert(str, name ); |
44 | m_receiveFact.insert( str, lay ); | 44 | m_receiveFact.insert( str, lay ); |
45 | } | 45 | } |
46 | void MetaFactory::addEmulationLayer( const QCString& name, | ||
47 | const QString& str, | ||
48 | emulationLayer em) { | ||
49 | m_strings.insert(str, name ); | ||
50 | m_emu.insert( str, em ); | ||
51 | } | ||
52 | QStringList MetaFactory::ioLayers()const { | 46 | QStringList MetaFactory::ioLayers()const { |
53 | QStringList list; | 47 | QStringList list; |
54 | QMap<QString, iolayer>::ConstIterator it; | 48 | QMap<QString, iolayer>::ConstIterator it; |
55 | for (it = m_layerFact.begin(); it != m_layerFact.end(); ++it ) { | 49 | for (it = m_layerFact.begin(); it != m_layerFact.end(); ++it ) { |
56 | list << it.key(); | 50 | list << it.key(); |
57 | } | 51 | } |
58 | return list; | 52 | return list; |
59 | } | 53 | } |
60 | QStringList MetaFactory::connectionWidgets()const { | 54 | QStringList MetaFactory::connectionWidgets()const { |
61 | QStringList list; | 55 | QStringList list; |
62 | QMap<QString, configWidget>::ConstIterator it; | 56 | QMap<QString, configWidget>::ConstIterator it; |
63 | for ( it = m_conFact.begin(); it != m_conFact.end(); ++it ) { | 57 | for ( it = m_conFact.begin(); it != m_conFact.end(); ++it ) { |
64 | list << it.key(); | 58 | list << it.key(); |
65 | } | 59 | } |
66 | return list; | 60 | return list; |
67 | } | 61 | } |
68 | QStringList MetaFactory::terminalWidgets()const { | 62 | QStringList MetaFactory::terminalWidgets()const { |
69 | QStringList list; | 63 | QStringList list; |
70 | QMap<QString, configWidget>::ConstIterator it; | 64 | QMap<QString, configWidget>::ConstIterator it; |
71 | for ( it = m_termFact.begin(); it != m_termFact.end(); ++it ) { | 65 | for ( it = m_termFact.begin(); it != m_termFact.end(); ++it ) { |
72 | list << it.key(); | 66 | list << it.key(); |
73 | } | 67 | } |
74 | return list; | 68 | return list; |
75 | } | 69 | } |
76 | QStringList MetaFactory::fileTransferLayers()const { | 70 | QStringList MetaFactory::fileTransferLayers()const { |
77 | QStringList list; | 71 | QStringList list; |
78 | QMap<QString, filelayer>::ConstIterator it; | 72 | QMap<QString, filelayer>::ConstIterator it; |
79 | for ( it = m_fileFact.begin(); it != m_fileFact.end(); ++it ) { | 73 | for ( it = m_fileFact.begin(); it != m_fileFact.end(); ++it ) { |
80 | list << it.key(); | 74 | list << it.key(); |
81 | } | 75 | } |
82 | return list; | 76 | return list; |
83 | } | 77 | } |
84 | QStringList MetaFactory::receiveLayers()const { | 78 | QStringList MetaFactory::receiveLayers()const { |
85 | QStringList list; | 79 | QStringList list; |
86 | QMap<QString, receivelayer>::ConstIterator it; | 80 | QMap<QString, receivelayer>::ConstIterator it; |
87 | for ( it = m_receiveFact.begin(); it != m_receiveFact.end(); ++it ) { | 81 | for ( it = m_receiveFact.begin(); it != m_receiveFact.end(); ++it ) { |
88 | list << it.key(); | 82 | list << it.key(); |
89 | } | 83 | } |
90 | return list; | 84 | return list; |
91 | } | 85 | } |
92 | QStringList MetaFactory::emulationLayers()const { | ||
93 | QStringList list; | ||
94 | QMap<QString, emulationLayer>::ConstIterator it; | ||
95 | for ( it = m_emu.begin(); it != m_emu.end(); ++it ) { | ||
96 | list << it.key(); | ||
97 | } | ||
98 | return list; | ||
99 | } | ||
100 | 86 | ||
101 | IOLayer* MetaFactory::newIOLayer( const QString& str,const Profile& prof ) { | 87 | IOLayer* MetaFactory::newIOLayer( const QString& str,const Profile& prof ) { |
102 | IOLayer* lay = 0l; | 88 | IOLayer* lay = 0l; |
103 | 89 | ||
104 | QMap<QString, iolayer>::Iterator it; | 90 | QMap<QString, iolayer>::Iterator it; |
105 | it = m_layerFact.find( str ); | 91 | it = m_layerFact.find( str ); |
106 | if ( it != m_layerFact.end() ) { | 92 | if ( it != m_layerFact.end() ) { |
107 | lay = (*(it.data()))(prof); | 93 | lay = (*(it.data()))(prof); |
108 | /* | 94 | /* |
109 | iolayer laye = it.data(); | 95 | iolayer laye = it.data(); |
110 | lay = (*laye )(conf);*/ | 96 | lay = (*laye )(conf);*/ |
111 | } | 97 | } |
112 | 98 | ||
113 | return lay; | 99 | return lay; |
114 | } | 100 | } |
115 | 101 | ||
116 | ProfileDialogWidget *MetaFactory::newConnectionPlugin ( const QString& str, QWidget *parent) { | 102 | ProfileDialogWidget *MetaFactory::newConnectionPlugin ( const QString& str, QWidget *parent) { |
117 | ProfileDialogWidget* wid = 0l; | 103 | ProfileDialogWidget* wid = 0l; |
118 | 104 | ||
119 | QMap<QString, configWidget>::Iterator it; | 105 | QMap<QString, configWidget>::Iterator it; |
120 | it = m_conFact.find( str ); | 106 | it = m_conFact.find( str ); |
121 | if ( it != m_conFact.end() ) { | 107 | if ( it != m_conFact.end() ) { |
122 | wid = (*(it.data() ) )(str,parent); | 108 | wid = (*(it.data() ) )(str,parent); |
123 | } | 109 | } |
124 | return wid; | 110 | return wid; |
125 | } | 111 | } |
126 | ProfileDialogWidget *MetaFactory::newTerminalPlugin( const QString& str, QWidget *parent) { | 112 | ProfileDialogWidget *MetaFactory::newTerminalPlugin( const QString& str, QWidget *parent) { |
127 | if (str.isEmpty() ) | 113 | if (str.isEmpty() ) |
128 | return 0l; | 114 | return 0l; |
129 | ProfileDialogWidget* wid = 0l; | 115 | ProfileDialogWidget* wid = 0l; |
130 | 116 | ||
131 | QMap<QString, configWidget>::Iterator it; | 117 | QMap<QString, configWidget>::Iterator it; |
132 | it = m_termFact.find( str ); | 118 | it = m_termFact.find( str ); |
133 | if ( it != m_termFact.end() ) { | 119 | if ( it != m_termFact.end() ) { |
134 | wid = (*(it.data() ) )(str,parent); | 120 | wid = (*(it.data() ) )(str,parent); |
135 | } | 121 | } |
136 | return wid; | 122 | return wid; |
137 | } | 123 | } |
138 | ProfileDialogWidget *MetaFactory::newKeyboardPlugin( const QString& str, QWidget *parent) { | 124 | ProfileDialogWidget *MetaFactory::newKeyboardPlugin( const QString& str, QWidget *parent) { |
139 | 125 | ||
140 | if (str.isEmpty() ) | 126 | if (str.isEmpty() ) |
141 | return 0l; | 127 | return 0l; |
142 | ProfileDialogWidget* wid = 0l; | 128 | ProfileDialogWidget* wid = 0l; |
143 | 129 | ||
144 | QMap<QString, configWidget>::Iterator it; | 130 | QMap<QString, configWidget>::Iterator it; |
145 | it = m_keyFact.find( str ); | 131 | it = m_keyFact.find( str ); |
146 | if ( it != m_keyFact.end() ) { | 132 | if ( it != m_keyFact.end() ) { |
147 | wid = (*(it.data() ) )(str,parent); | 133 | wid = (*(it.data() ) )(str,parent); |
148 | } | 134 | } |
149 | return wid; | 135 | return wid; |
150 | } | 136 | } |
151 | EmulationLayer* MetaFactory::newEmulationLayer( const QString& str, WidgetLayer* wid) { | ||
152 | EmulationLayer* lay = 0l; | ||
153 | |||
154 | QMap<QString, emulationLayer>::Iterator it; | ||
155 | it = m_emu.find( str ); | ||
156 | if ( it != m_emu.end() ) { | ||
157 | lay = (*(it.data() ) )(wid); | ||
158 | } | ||
159 | |||
160 | return lay; | ||
161 | } | ||
162 | FileTransferLayer* MetaFactory::newFileTransfer(const QString& str, IOLayer* lay ) { | 137 | FileTransferLayer* MetaFactory::newFileTransfer(const QString& str, IOLayer* lay ) { |
163 | FileTransferLayer* file = 0l; | 138 | FileTransferLayer* file = 0l; |
164 | QMap<QString, filelayer>::Iterator it; | 139 | QMap<QString, filelayer>::Iterator it; |
165 | it = m_fileFact.find( str ); | 140 | it = m_fileFact.find( str ); |
166 | if ( it != m_fileFact.end() ) { | 141 | if ( it != m_fileFact.end() ) { |
167 | file = (*(it.data() ) )(lay); | 142 | file = (*(it.data() ) )(lay); |
168 | } | 143 | } |
169 | return file; | 144 | return file; |
170 | } | 145 | } |
171 | ReceiveLayer* MetaFactory::newReceive(const QString& str, IOLayer* lay ) { | 146 | ReceiveLayer* MetaFactory::newReceive(const QString& str, IOLayer* lay ) { |
172 | ReceiveLayer* file = 0l; | 147 | ReceiveLayer* file = 0l; |
173 | QMap<QString, receivelayer>::Iterator it; | 148 | QMap<QString, receivelayer>::Iterator it; |
174 | it = m_receiveFact.find( str ); | 149 | it = m_receiveFact.find( str ); |
175 | if ( it != m_receiveFact.end() ) { | 150 | if ( it != m_receiveFact.end() ) { |
176 | file = (*(it.data() ) )(lay); | 151 | file = (*(it.data() ) )(lay); |
177 | } | 152 | } |
178 | return file; | 153 | return file; |
179 | } | 154 | } |
180 | QCString MetaFactory::internal( const QString& str )const { | 155 | QCString MetaFactory::internal( const QString& str )const { |
181 | return m_strings[str]; | 156 | return m_strings[str]; |
182 | } | 157 | } |
183 | QString MetaFactory::external( const QCString& str )const { | 158 | QString MetaFactory::external( const QCString& str )const { |
184 | QMap<QString, QCString>::ConstIterator it; | 159 | QMap<QString, QCString>::ConstIterator it; |
185 | for ( it = m_strings.begin(); it != m_strings.end(); ++it ) { | 160 | for ( it = m_strings.begin(); it != m_strings.end(); ++it ) { |
186 | if ( it.data() == str ) | 161 | if ( it.data() == str ) |
187 | return it.key(); | 162 | return it.key(); |
188 | } | 163 | } |
189 | return QString::null; | 164 | return QString::null; |
190 | } | 165 | } |
diff --git a/noncore/apps/opie-console/metafactory.h b/noncore/apps/opie-console/metafactory.h index f89136c..bcc40db 100644 --- a/noncore/apps/opie-console/metafactory.h +++ b/noncore/apps/opie-console/metafactory.h | |||
@@ -1,120 +1,109 @@ | |||
1 | #ifndef OPIE_META_FACTORY_H | 1 | #ifndef OPIE_META_FACTORY_H |
2 | #define OPIE_META_FACTORY_H | 2 | #define OPIE_META_FACTORY_H |
3 | 3 | ||
4 | /** | 4 | /** |
5 | * The MetaFactory is used to keep track of all IOLayers, FileTransferLayers and ConfigWidgets | 5 | * The MetaFactory is used to keep track of all IOLayers, FileTransferLayers and ConfigWidgets |
6 | * and to instantiate these implementations on demand | 6 | * and to instantiate these implementations on demand |
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include <qwidget.h> | 9 | #include <qwidget.h> |
10 | #include <qmap.h> | 10 | #include <qmap.h> |
11 | 11 | ||
12 | #include <qpe/config.h> | 12 | #include <qpe/config.h> |
13 | 13 | ||
14 | #include "io_layer.h" | 14 | #include "io_layer.h" |
15 | #include "file_layer.h" | 15 | #include "file_layer.h" |
16 | #include "receive_layer.h" | 16 | #include "receive_layer.h" |
17 | #include "profile.h" | 17 | #include "profile.h" |
18 | #include "profiledialogwidget.h" | 18 | #include "profiledialogwidget.h" |
19 | #include "emulation_layer.h" | ||
20 | 19 | ||
21 | class WidgetLayer; | 20 | class WidgetLayer; |
22 | class MetaFactory { | 21 | class MetaFactory { |
23 | public: | 22 | public: |
24 | typedef ProfileDialogWidget* (*configWidget)(const QString&, QWidget* parent); | 23 | typedef ProfileDialogWidget* (*configWidget)(const QString&, QWidget* parent); |
25 | typedef IOLayer* (*iolayer)(const Profile& ); | 24 | typedef IOLayer* (*iolayer)(const Profile& ); |
26 | typedef FileTransferLayer* (*filelayer)(IOLayer*); | 25 | typedef FileTransferLayer* (*filelayer)(IOLayer*); |
27 | typedef ReceiveLayer* (*receivelayer)(IOLayer*); | 26 | typedef ReceiveLayer* (*receivelayer)(IOLayer*); |
28 | typedef EmulationLayer* (*emulationLayer)(WidgetLayer* ); | ||
29 | 27 | ||
30 | MetaFactory(); | 28 | MetaFactory(); |
31 | ~MetaFactory(); | 29 | ~MetaFactory(); |
32 | 30 | ||
33 | /** | 31 | /** |
34 | * add a ProfileDialogWidget to the factory | 32 | * add a ProfileDialogWidget to the factory |
35 | * name is the name shown to the user | 33 | * name is the name shown to the user |
36 | */ | 34 | */ |
37 | void addConnectionWidgetFactory( const QCString& internalName, | 35 | void addConnectionWidgetFactory( const QCString& internalName, |
38 | const QString& uiString, | 36 | const QString& uiString, |
39 | configWidget ); | 37 | configWidget ); |
40 | void addTerminalWidgetFactory ( const QCString& internalName, | 38 | void addTerminalWidgetFactory ( const QCString& internalName, |
41 | const QString& name, | 39 | const QString& name, |
42 | configWidget ); | 40 | configWidget ); |
43 | void addKeyboardWidgetFactory ( const QCString& internalName, | 41 | void addKeyboardWidgetFactory ( const QCString& internalName, |
44 | const QString& name, | 42 | const QString& name, |
45 | configWidget ); | 43 | configWidget ); |
46 | 44 | ||
47 | /** | 45 | /** |
48 | * adds an IOLayer factory | 46 | * adds an IOLayer factory |
49 | */ | 47 | */ |
50 | void addIOLayerFactory( const QCString&, | 48 | void addIOLayerFactory( const QCString&, |
51 | const QString&, | 49 | const QString&, |
52 | iolayer ); | 50 | iolayer ); |
53 | 51 | ||
54 | /** | 52 | /** |
55 | * adds a FileTransfer Layer | 53 | * adds a FileTransfer Layer |
56 | */ | 54 | */ |
57 | void addFileTransferLayer( const QCString& name, | 55 | void addFileTransferLayer( const QCString& name, |
58 | const QString&, | 56 | const QString&, |
59 | filelayer ); | 57 | filelayer ); |
60 | void addReceiveLayer( const QCString& name, | 58 | void addReceiveLayer( const QCString& name, |
61 | const QString&, | 59 | const QString&, |
62 | receivelayer); | 60 | receivelayer); |
63 | 61 | ||
64 | /** | ||
65 | * adds a Factory for Emulation to the Layer.. | ||
66 | */ | ||
67 | void addEmulationLayer ( const QCString& name, | ||
68 | const QString& uiString, | ||
69 | emulationLayer ); | ||
70 | 62 | ||
71 | /* translated UI Strings */ | 63 | /* translated UI Strings */ |
72 | QStringList ioLayers()const; | 64 | QStringList ioLayers()const; |
73 | QStringList connectionWidgets()const; | 65 | QStringList connectionWidgets()const; |
74 | 66 | ||
75 | /** | 67 | /** |
76 | * Terminal Configuration widgets | 68 | * Terminal Configuration widgets |
77 | */ | 69 | */ |
78 | QStringList terminalWidgets()const; | 70 | QStringList terminalWidgets()const; |
79 | QStringList fileTransferLayers()const; | 71 | QStringList fileTransferLayers()const; |
80 | QStringList receiveLayers()const; | 72 | QStringList receiveLayers()const; |
81 | QStringList emulationLayers()const; | ||
82 | 73 | ||
83 | /** | 74 | /** |
84 | * the generation... | 75 | * the generation... |
85 | */ | 76 | */ |
86 | IOLayer* newIOLayer( const QString&,const Profile& ); | 77 | IOLayer* newIOLayer( const QString&,const Profile& ); |
87 | ProfileDialogWidget *newConnectionPlugin ( const QString&, QWidget* ); | 78 | ProfileDialogWidget *newConnectionPlugin ( const QString&, QWidget* ); |
88 | ProfileDialogWidget* newTerminalPlugin( const QString&, QWidget* ); | 79 | ProfileDialogWidget* newTerminalPlugin( const QString&, QWidget* ); |
89 | ProfileDialogWidget* newKeyboardPlugin( const QString&, QWidget* ); | 80 | ProfileDialogWidget* newKeyboardPlugin( const QString&, QWidget* ); |
90 | EmulationLayer* newEmulationLayer(const QString&, WidgetLayer* ); | ||
91 | FileTransferLayer* newFileTransfer(const QString&, IOLayer* ); | 81 | FileTransferLayer* newFileTransfer(const QString&, IOLayer* ); |
92 | ReceiveLayer* newReceive(const QString&, IOLayer* ); | 82 | ReceiveLayer* newReceive(const QString&, IOLayer* ); |
93 | 83 | ||
94 | /* | 84 | /* |
95 | * internal takes the maybe translated | 85 | * internal takes the maybe translated |
96 | * public QString and maps it to the internal | 86 | * public QString and maps it to the internal |
97 | * not translatable QCString | 87 | * not translatable QCString |
98 | */ | 88 | */ |
99 | QCString internal( const QString& )const; | 89 | QCString internal( const QString& )const; |
100 | 90 | ||
101 | /* | 91 | /* |
102 | * external takes the internal name | 92 | * external takes the internal name |
103 | * it returns a translated name | 93 | * it returns a translated name |
104 | */ | 94 | */ |
105 | QString external( const QCString& )const; | 95 | QString external( const QCString& )const; |
106 | 96 | ||
107 | 97 | ||
108 | private: | 98 | private: |
109 | QMap<QString, QCString> m_strings; | 99 | QMap<QString, QCString> m_strings; |
110 | QMap<QString, configWidget> m_conFact; | 100 | QMap<QString, configWidget> m_conFact; |
111 | QMap<QString, configWidget> m_termFact; | 101 | QMap<QString, configWidget> m_termFact; |
112 | QMap<QString, configWidget> m_keyFact; | 102 | QMap<QString, configWidget> m_keyFact; |
113 | QMap<QString, iolayer> m_layerFact; | 103 | QMap<QString, iolayer> m_layerFact; |
114 | QMap<QString, filelayer> m_fileFact; | 104 | QMap<QString, filelayer> m_fileFact; |
115 | QMap<QString, receivelayer> m_receiveFact; | 105 | QMap<QString, receivelayer> m_receiveFact; |
116 | QMap<QString, emulationLayer> m_emu; | ||
117 | }; | 106 | }; |
118 | 107 | ||
119 | 108 | ||
120 | #endif | 109 | #endif |