Diffstat (limited to 'core/apps/embeddedkonsole/TEWidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/apps/embeddedkonsole/TEWidget.cpp | 148 |
1 files changed, 104 insertions, 44 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 | |||
@@ -67,4 +67,5 @@ | |||
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> |
@@ -245,21 +246,15 @@ void TEWidget::fontChange(const QFont &) | |||
245 | QFontMetrics fm(font()); | 246 | QFontMetrics fm(font()); |
246 | font_h = fm.height(); | 247 | font_h = fm.height(); |
247 | 248 | // font_w = fm.maxWidth(); | |
248 | // font_w = max width of ASCII chars (U.B.) | 249 | font_w = fm.width("m"); |
249 | font_w = 0; | 250 | font_a = fm.ascent(); |
250 | int fw; | 251 | printf("font h=%d max_width=%d width_m=%d assent=%d\n", font_h, |
251 | for (int i = 0x20; i < 0x80; i++) { | 252 | fm.maxWidth(), font_w, font_a); |
252 | if (isprint(i) && font_w < (fw = fm.width(i))) { | 253 | |
253 | font_w = fw; | 254 | //printf("font_h: %d\n",font_h); |
254 | } | 255 | //printf("font_w: %d\n",font_w); |
255 | } | 256 | //printf("font_a: %d\n",font_a); |
256 | //font_w = fm.maxWidth(); | 257 | //printf("charset: %s\n",QFont::encodingName(font().charSet()).ascii()); |
257 | 258 | //printf("rawname: %s\n",font().rawName().ascii()); | |
258 | font_a = fm.ascent(); | ||
259 | //printf("font_h: %d\n",font_h); | ||
260 | //printf("font_w: %d\n",font_w); | ||
261 | //printf("font_a: %d\n",font_a); | ||
262 | //printf("charset: %s\n",QFont::encodingName(font().charSet()).ascii()); | ||
263 | //printf("rawname: %s\n",font().rawName().ascii()); | ||
264 | fontMap = | 259 | fontMap = |
265 | #if QT_VERSION < 300 | 260 | #if QT_VERSION < 300 |
@@ -308,9 +303,9 @@ TEWidget::TEWidget(QWidget *parent, const char *name) : QFrame(parent,name) | |||
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)){ |
@@ -685,5 +680,6 @@ void TEWidget::mousePressEvent(QMouseEvent* ev) | |||
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); |
@@ -692,4 +688,6 @@ void TEWidget::mousePressEvent(QMouseEvent* ev) | |||
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 | ||
@@ -816,4 +814,10 @@ void TEWidget::mouseReleaseEvent(QMouseEvent* ev) | |||
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; |
@@ -1031,5 +1035,4 @@ bool TEWidget::eventFilter( QObject *obj, QEvent *e ) | |||
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; |
@@ -1070,23 +1073,81 @@ bool TEWidget::eventFilter( QObject *obj, QEvent *e ) | |||
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) { | 1075 | |
1073 | qDebug("key pressed is 0x%x, ascii is 0x%x, state %d", ke->key(), ke->ascii(), ke->state()); | 1076 | bool special_function = true; |
1074 | 1077 | switch(ke->key()) { | |
1075 | } | 1078 | //case 0x201b: // fn-5 |
1076 | 1079 | //case Key_F1: | |
1077 | if( ke->state() == ShiftButton && ke->key() == Key_Tab) { | 1080 | // switch sessions (?) |
1078 | //lets hardcode this sucker | 1081 | // emitText("\\"); // expose (??) |
1079 | 1082 | // break; | |
1080 | // qDebug("key pressed 2 is 0x%x", ke->key()); | 1083 | |
1081 | emitText("\\"); // expose | 1084 | case 0x2016: // fn-p |
1082 | } | 1085 | case Key_F2: |
1083 | else if( ke->state() == ControlButton && ke->key() == Key_V) { | 1086 | pasteClipboard(); |
1084 | pasteClipboard(); | 1087 | break; |
1085 | } | 1088 | |
1086 | // else if( ke->state() == ControlButton && ke->key() == Key_C) { | 1089 | case 0x2018: // fn-S |
1087 | // pasteClipboard(); | 1090 | case Key_F3: |
1088 | // } | 1091 | emit changeSession(1); |
1089 | else | 1092 | break; |
1090 | emit keyPressedSignal(ke); // expose | 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; | ||
1120 | } | ||
1121 | break; | ||
1122 | #endif | ||
1123 | |||
1124 | case 0x201b: // fn-5 | ||
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; | ||
1133 | |||
1134 | case 0x2010: // fn-2 magnify plus | ||
1135 | case Key_F6: | ||
1136 | emit changeFontSize(1); | ||
1137 | break; | ||
1138 | |||
1139 | default: | ||
1140 | special_function = false; | ||
1141 | } | ||
1142 | if (special_function) { | ||
1143 | return true; | ||
1144 | } | ||
1145 | // else if( ke->state() == ControlButton && ke->key() == Key_V) { | ||
1146 | // pasteClipboard(); | ||
1147 | // } | ||
1148 | // else if( ke->state() == ControlButton && ke->key() == Key_C) { | ||
1149 | // pasteClipboard(); | ||
1150 | // } | ||
1151 | emit keyPressedSignal(ke); // expose | ||
1091 | ke->accept(); | 1152 | ke->accept(); |
1092 | #ifdef FAKE_CTRL_AND_ALT | 1153 | #ifdef FAKE_CTRL_AND_ALT |
@@ -1117,5 +1178,4 @@ void TEWidget::frameChanged() | |||
1117 | update(); | 1178 | update(); |
1118 | } | 1179 | } |
1119 | |||
1120 | /* ------------------------------------------------------------------------- */ | 1180 | /* ------------------------------------------------------------------------- */ |
1121 | /* */ | 1181 | /* */ |
@@ -1168,5 +1228,5 @@ void TEWidget::calcGeometry() | |||
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); |
@@ -1369,5 +1429,5 @@ void TEWidget::setWrapAt(int columns) | |||
1369 | { | 1429 | { |
1370 | vcolumns = columns; | 1430 | vcolumns = columns; |
1371 | propagateSize(); | 1431 | propagateSize(); |
1372 | update(); | 1432 | update(); |
1373 | } | 1433 | } |