author | waspe <waspe> | 2004-02-22 12:57:58 (UTC) |
---|---|---|
committer | waspe <waspe> | 2004-02-22 12:57:58 (UTC) |
commit | 5bc4dbd932fcfa64773b6e17fe57c665bdcd50b8 (patch) (unidiff) | |
tree | b97f5281b807b4218f437150a4e9082694e7a642 /core/apps/embeddedkonsole/TEWidget.cpp | |
parent | 908f9c9f0c68d1c3e5a620a69bbf0d05684e2ab3 (diff) | |
download | opie-5bc4dbd932fcfa64773b6e17fe57c665bdcd50b8.zip opie-5bc4dbd932fcfa64773b6e17fe57c665bdcd50b8.tar.gz opie-5bc4dbd932fcfa64773b6e17fe57c665bdcd50b8.tar.bz2 |
merged changes form qkonsole back into opie-embeddedkonsole (most likely not bugfree !)
Diffstat (limited to 'core/apps/embeddedkonsole/TEWidget.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/apps/embeddedkonsole/TEWidget.cpp | 110 |
1 files changed, 85 insertions, 25 deletions
diff --git a/core/apps/embeddedkonsole/TEWidget.cpp b/core/apps/embeddedkonsole/TEWidget.cpp index ec1b30c..98c3cdf 100644 --- a/core/apps/embeddedkonsole/TEWidget.cpp +++ b/core/apps/embeddedkonsole/TEWidget.cpp | |||
@@ -65,8 +65,9 @@ | |||
65 | #include <qclipboard.h> | 65 | #include <qclipboard.h> |
66 | #include <qstyle.h> | 66 | #include <qstyle.h> |
67 | #include <qfile.h> | 67 | #include <qfile.h> |
68 | #include <qdragobject.h> | 68 | #include <qdragobject.h> |
69 | #include <qnamespace.h> | ||
69 | 70 | ||
70 | #include <stdio.h> | 71 | #include <stdio.h> |
71 | #include <stdlib.h> | 72 | #include <stdlib.h> |
72 | #include <unistd.h> | 73 | #include <unistd.h> |
@@ -243,20 +244,14 @@ static QChar identicalMap(QChar c) | |||
243 | void TEWidget::fontChange(const QFont &) | 244 | void TEWidget::fontChange(const QFont &) |
244 | { | 245 | { |
245 | QFontMetrics fm(font()); | 246 | QFontMetrics fm(font()); |
246 | font_h = fm.height(); | 247 | font_h = fm.height(); |
247 | |||
248 | // font_w = max width of ASCII chars (U.B.) | ||
249 | font_w = 0; | ||
250 | int fw; | ||
251 | for (int i = 0x20; i < 0x80; i++) { | ||
252 | if (isprint(i) && font_w < (fw = fm.width(i))) { | ||
253 | font_w = fw; | ||
254 | } | ||
255 | } | ||
256 | //font_w = fm.maxWidth(); | 248 | //font_w = fm.maxWidth(); |
257 | 249 | font_w = fm.width("m"); | |
258 | font_a = fm.ascent(); | 250 | font_a = fm.ascent(); |
251 | printf("font h=%d max_width=%d width_m=%d assent=%d\n", font_h, | ||
252 | fm.maxWidth(), font_w, font_a); | ||
253 | |||
259 | //printf("font_h: %d\n",font_h); | 254 | //printf("font_h: %d\n",font_h); |
260 | //printf("font_w: %d\n",font_w); | 255 | //printf("font_w: %d\n",font_w); |
261 | //printf("font_a: %d\n",font_a); | 256 | //printf("font_a: %d\n",font_a); |
262 | //printf("charset: %s\n",QFont::encodingName(font().charSet()).ascii()); | 257 | //printf("charset: %s\n",QFont::encodingName(font().charSet()).ascii()); |
@@ -306,13 +301,13 @@ TEWidget::TEWidget(QWidget *parent, const char *name) : QFrame(parent,name) | |||
306 | 301 | ||
307 | hScrollbar = new QScrollBar(this); | 302 | hScrollbar = new QScrollBar(this); |
308 | hScrollbar->setCursor( arrowCursor ); | 303 | hScrollbar->setCursor( arrowCursor ); |
309 | hScrollbar->setOrientation(QScrollBar::Horizontal); | 304 | hScrollbar->setOrientation(QScrollBar::Horizontal); |
310 | hScrollbar->setMaximumHeight(16); | 305 | // hScrollbar->setMaximumHeight(16); |
311 | 306 | ||
312 | connect( hScrollbar, SIGNAL(valueChanged(int)), this, SLOT( hScrollChanged(int))); | 307 | connect( hScrollbar, SIGNAL(valueChanged(int)), this, SLOT( hScrollChanged(int))); |
313 | 308 | ||
314 | Config cfg("Konsole"); | 309 | Config cfg("Qkonsole"); |
315 | cfg.setGroup("ScrollBar"); | 310 | cfg.setGroup("ScrollBar"); |
316 | switch( cfg.readNumEntry("Position",2)){ | 311 | switch( cfg.readNumEntry("Position",2)){ |
317 | case 0: | 312 | case 0: |
318 | scrollLoc = SCRNONE; | 313 | scrollLoc = SCRNONE; |
@@ -683,15 +678,18 @@ void TEWidget::mousePressEvent(QMouseEvent* ev) | |||
683 | QPoint tL = contentsRect().topLeft(); | 678 | QPoint tL = contentsRect().topLeft(); |
684 | int tLx = tL.x(); | 679 | int tLx = tL.x(); |
685 | int tLy = tL.y(); | 680 | int tLy = tL.y(); |
686 | 681 | ||
687 | word_selection_mode = FALSE; | 682 | mouse_down_x = ev->x(); |
683 | mouse_down_y = ev->y(); | ||
688 | 684 | ||
689 | //printf("press top left [%d,%d] by=%d\n",tLx,tLy, bY); | 685 | //printf("press top left [%d,%d] by=%d\n",tLx,tLy, bY); |
690 | if ( ev->button() == LeftButton) | 686 | if ( ev->button() == LeftButton) |
691 | { | 687 | { |
692 | QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); | 688 | QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); |
693 | 689 | ||
690 | word_selection_mode = (ev->state() & ShiftButton); | ||
691 | |||
694 | if ( ev->state() & ControlButton ) preserve_line_breaks = FALSE ; | 692 | if ( ev->state() & ControlButton ) preserve_line_breaks = FALSE ; |
695 | 693 | ||
696 | if (mouse_marks || (ev->state() & ShiftButton)) | 694 | if (mouse_marks || (ev->state() & ShiftButton)) |
697 | { | 695 | { |
@@ -814,8 +812,14 @@ void TEWidget::mouseReleaseEvent(QMouseEvent* ev) | |||
814 | { | 812 | { |
815 | //printf("release [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button()); | 813 | //printf("release [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button()); |
816 | if ( ev->button() == LeftButton) | 814 | if ( ev->button() == LeftButton) |
817 | { | 815 | { |
816 | if (QABS(ev->x() - mouse_down_x) < 3 | ||
817 | && QABS(ev->y() - mouse_down_y) < 3 | ||
818 | && ev->y() < qApp->desktop()->height()/8) { | ||
819 | emit setFullScreen(false); | ||
820 | } | ||
821 | |||
818 | if ( actSel > 1 ) emit endSelectionSignal(preserve_line_breaks); | 822 | if ( actSel > 1 ) emit endSelectionSignal(preserve_line_breaks); |
819 | preserve_line_breaks = TRUE; | 823 | preserve_line_breaks = TRUE; |
820 | actSel = 0; | 824 | actSel = 0; |
821 | 825 | ||
@@ -1029,9 +1033,8 @@ bool TEWidget::eventFilter( QObject *obj, QEvent *e ) | |||
1029 | static bool control = FALSE; | 1033 | static bool control = FALSE; |
1030 | static bool alt = FALSE; | 1034 | static bool alt = FALSE; |
1031 | // qDebug(" Has a keyboard with no CTRL and ALT keys, but we fake it:"); | 1035 | // qDebug(" Has a keyboard with no CTRL and ALT keys, but we fake it:"); |
1032 | bool dele=FALSE; | 1036 | bool dele=FALSE; |
1033 | |||
1034 | if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { | 1037 | if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { |
1035 | QKeyEvent* ke = (QKeyEvent*)e; | 1038 | QKeyEvent* ke = (QKeyEvent*)e; |
1036 | bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat(); | 1039 | bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat(); |
1037 | switch (ke->key()) { | 1040 | switch (ke->key()) { |
@@ -1068,26 +1071,84 @@ bool TEWidget::eventFilter( QObject *obj, QEvent *e ) | |||
1068 | actSel=0; // Key stroke implies a screen update, so TEWidget won't | 1071 | actSel=0; // Key stroke implies a screen update, so TEWidget won't |
1069 | // know where the current selection is. | 1072 | // know where the current selection is. |
1070 | 1073 | ||
1071 | // qDebug("key pressed is 0x%x, ascii is 0x%x, state %d", ke->key(), ke->ascii(), ke->state()); | 1074 | // qDebug("key pressed is 0x%x, ascii is 0x%x, state %d", ke->key(), ke->ascii(), ke->state()); |
1072 | if(ke->key() == Key_Escape) { | ||
1073 | qDebug("key pressed is 0x%x, ascii is 0x%x, state %d", ke->key(), ke->ascii(), ke->state()); | ||
1074 | 1075 | ||
1076 | bool special_function = true; | ||
1077 | switch(ke->key()) { | ||
1078 | //case 0x201b: // fn-5 | ||
1079 | //case Key_F1: | ||
1080 | // switch sessions (?) | ||
1081 | // emitText("\\"); // expose (??) | ||
1082 | // break; | ||
1083 | |||
1084 | case 0x2016: // fn-p | ||
1085 | case Key_F2: | ||
1086 | pasteClipboard(); | ||
1087 | break; | ||
1088 | |||
1089 | case 0x2018: // fn-S | ||
1090 | case Key_F3: | ||
1091 | emit changeSession(1); | ||
1092 | break; | ||
1093 | |||
1094 | case 0x2019: // fn-n | ||
1095 | emit newSession(); | ||
1096 | break; | ||
1097 | |||
1098 | case Qt::Key_Tab: | ||
1099 | if (ke->state() == ControlButton) { | ||
1100 | emit changeSession(1); | ||
1101 | } else { | ||
1102 | special_function = false; | ||
1103 | } | ||
1104 | break; | ||
1105 | |||
1106 | #if 0 | ||
1107 | case Qt::Key_Left: | ||
1108 | if (vcolumns == 0) { | ||
1109 | emit changeSession(-1); | ||
1110 | } else { | ||
1111 | special_function = false; | ||
1112 | } | ||
1113 | break; | ||
1114 | |||
1115 | case Qt::Key_Right: | ||
1116 | if (vcolumns == 0) { | ||
1117 | emit changeSession(1); | ||
1118 | } else { | ||
1119 | special_function = false; | ||
1075 | } | 1120 | } |
1121 | break; | ||
1122 | #endif | ||
1076 | 1123 | ||
1077 | if( ke->state() == ShiftButton && ke->key() == Key_Tab) { | 1124 | case 0x201b: // fn-5 |
1078 | //lets hardcode this sucker | 1125 | case Key_F4: |
1126 | emit toggleFullScreen(); | ||
1127 | break; | ||
1128 | |||
1129 | case 0x200f: // fn-1 magnify minus | ||
1130 | case Key_F5: | ||
1131 | emit changeFontSize(-1); | ||
1132 | break; | ||
1079 | 1133 | ||
1080 | // qDebug("key pressed 2 is 0x%x", ke->key()); | 1134 | case 0x2010: // fn-2 magnify plus |
1081 | emitText("\\"); // expose | 1135 | case Key_F6: |
1136 | emit changeFontSize(1); | ||
1137 | break; | ||
1138 | |||
1139 | default: | ||
1140 | special_function = false; | ||
1082 | } | 1141 | } |
1083 | else if( ke->state() == ControlButton && ke->key() == Key_V) { | 1142 | if (special_function) { |
1084 | pasteClipboard(); | 1143 | return true; |
1085 | } | 1144 | } |
1145 | // else if( ke->state() == ControlButton && ke->key() == Key_V) { | ||
1146 | // pasteClipboard(); | ||
1147 | // } | ||
1086 | // else if( ke->state() == ControlButton && ke->key() == Key_C) { | 1148 | // else if( ke->state() == ControlButton && ke->key() == Key_C) { |
1087 | // pasteClipboard(); | 1149 | // pasteClipboard(); |
1088 | // } | 1150 | // } |
1089 | else | ||
1090 | emit keyPressedSignal(ke); // expose | 1151 | emit keyPressedSignal(ke); // expose |
1091 | ke->accept(); | 1152 | ke->accept(); |
1092 | #ifdef FAKE_CTRL_AND_ALT | 1153 | #ifdef FAKE_CTRL_AND_ALT |
1093 | if ( dele ) delete e; | 1154 | if ( dele ) delete e; |
@@ -1115,9 +1176,8 @@ void TEWidget::frameChanged() | |||
1115 | { | 1176 | { |
1116 | propagateSize(); | 1177 | propagateSize(); |
1117 | update(); | 1178 | update(); |
1118 | } | 1179 | } |
1119 | |||
1120 | /* ------------------------------------------------------------------------- */ | 1180 | /* ------------------------------------------------------------------------- */ |
1121 | /* */ | 1181 | /* */ |
1122 | /* Sound */ | 1182 | /* Sound */ |
1123 | /* */ | 1183 | /* */ |
@@ -1166,9 +1226,9 @@ void TEWidget::calcGeometry() | |||
1166 | { | 1226 | { |
1167 | int showhscrollbar = 1; | 1227 | int showhscrollbar = 1; |
1168 | int hwidth = 0; | 1228 | int hwidth = 0; |
1169 | int dcolumns; | 1229 | int dcolumns; |
1170 | Config cfg("Konsole"); | 1230 | Config cfg("Qkonsole"); |
1171 | cfg.setGroup("ScrollBar"); | 1231 | cfg.setGroup("ScrollBar"); |
1172 | useHorzScroll=cfg.readBoolEntry("HorzScroll",0); | 1232 | useHorzScroll=cfg.readBoolEntry("HorzScroll",0); |
1173 | 1233 | ||
1174 | if(vcolumns == 0) showhscrollbar = 0; | 1234 | if(vcolumns == 0) showhscrollbar = 0; |