Diffstat (limited to 'noncore/apps/opie-console/TEScreen.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-console/TEScreen.cpp | 17 |
1 files changed, 14 insertions, 3 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 | |||
@@ -964,79 +964,79 @@ void TEScreen::setSelBeginXY(const int x, const int y) | |||
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?! |
@@ -1091,56 +1091,67 @@ QString TEScreen::getSelText(const BOOL preserve_line_breaks) | |||
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 | */ |