-rw-r--r-- | core/apps/embeddedkonsole/TEWidget.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/core/apps/embeddedkonsole/TEWidget.cpp b/core/apps/embeddedkonsole/TEWidget.cpp index a989e10..8214e7d 100644 --- a/core/apps/embeddedkonsole/TEWidget.cpp +++ b/core/apps/embeddedkonsole/TEWidget.cpp | |||
@@ -277,85 +277,85 @@ void TEWidget::setFont(const QFont &) | |||
277 | } | 277 | } |
278 | 278 | ||
279 | /* ------------------------------------------------------------------------- */ | 279 | /* ------------------------------------------------------------------------- */ |
280 | /* */ | 280 | /* */ |
281 | /* Constructor / Destructor */ | 281 | /* Constructor / Destructor */ |
282 | /* */ | 282 | /* */ |
283 | /* ------------------------------------------------------------------------- */ | 283 | /* ------------------------------------------------------------------------- */ |
284 | 284 | ||
285 | TEWidget::TEWidget(QWidget *parent, const char *name) : QFrame(parent,name) | 285 | TEWidget::TEWidget(QWidget *parent, const char *name) : QFrame(parent,name) |
286 | { | 286 | { |
287 | #ifndef QT_NO_CLIPBOARD | 287 | #ifndef QT_NO_CLIPBOARD |
288 | cb = QApplication::clipboard(); | 288 | cb = QApplication::clipboard(); |
289 | QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), | 289 | QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), |
290 | this, SLOT(onClearSelection()) ); | 290 | this, SLOT(onClearSelection()) ); |
291 | #endif | 291 | #endif |
292 | 292 | ||
293 | scrollbar = new QScrollBar(this); | 293 | scrollbar = new QScrollBar(this); |
294 | scrollbar->setCursor( arrowCursor ); | 294 | scrollbar->setCursor( arrowCursor ); |
295 | connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); | 295 | connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); |
296 | 296 | ||
297 | hScrollbar = new QScrollBar(this); | 297 | hScrollbar = new QScrollBar(this); |
298 | hScrollbar->setCursor( arrowCursor ); | 298 | hScrollbar->setCursor( arrowCursor ); |
299 | hScrollbar->setOrientation(QScrollBar::Horizontal); | 299 | hScrollbar->setOrientation(QScrollBar::Horizontal); |
300 | hScrollbar->setMaximumHeight(16); | 300 | hScrollbar->setMaximumHeight(16); |
301 | 301 | ||
302 | connect( hScrollbar, SIGNAL(valueChanged(int)), this, SLOT( hScrollChanged(int))); | 302 | connect( hScrollbar, SIGNAL(valueChanged(int)), this, SLOT( hScrollChanged(int))); |
303 | 303 | ||
304 | Config cfg("Konsole"); | 304 | Config cfg("Konsole"); |
305 | cfg.setGroup("ScrollBar"); | 305 | cfg.setGroup("ScrollBar"); |
306 | switch( cfg.readNumEntry("Position",2)){ | 306 | switch( cfg.readNumEntry("Position",2)){ |
307 | case 0: | 307 | case 0: |
308 | scrollLoc = SCRNONE; | 308 | scrollLoc = SCRNONE; |
309 | break; | 309 | break; |
310 | case 1: | 310 | case 1: |
311 | scrollLoc = SCRLEFT; | 311 | scrollLoc = SCRLEFT; |
312 | break; | 312 | break; |
313 | case 2: | 313 | case 2: |
314 | scrollLoc = SCRRIGHT; | 314 | scrollLoc = SCRRIGHT; |
315 | break; | 315 | break; |
316 | }; | 316 | }; |
317 | 317 | ||
318 | useHorzScroll=cfg.readBoolEntry("HorzScroll",0); | 318 | useHorzScroll=cfg.readBoolEntry("HorzScroll",0); |
319 | 319 | ||
320 | blinkT = new QTimer(this); | 320 | blinkT = new QTimer(this); |
321 | connect(blinkT, SIGNAL(timeout()), this, SLOT(blinkEvent())); | 321 | connect(blinkT, SIGNAL(timeout()), this, SLOT(blinkEvent())); |
322 | // blinking = FALSE; | 322 | // blinking = FALSE; |
323 | blinking = TRUE; | 323 | blinking = TRUE; |
324 | 324 | ||
325 | resizing = FALSE; | 325 | resizing = FALSE; |
326 | actSel = 0; | 326 | actSel = 0; |
327 | image = 0; | 327 | image = 0; |
328 | lines = 1; | 328 | lines = 1; |
329 | columns = 1; | 329 | columns = 1; |
330 | font_w = 1; | 330 | font_w = 1; |
331 | font_h = 1; | 331 | font_h = 1; |
332 | font_a = 1; | 332 | font_a = 1; |
333 | word_selection_mode = FALSE; | 333 | word_selection_mode = FALSE; |
334 | hposition = 0; | 334 | hposition = 0; |
335 | vcolumns = 0; | 335 | vcolumns = 0; |
336 | useBeep = true; | 336 | useBeep = true; |
337 | 337 | ||
338 | setMouseMarks(TRUE); | 338 | setMouseMarks(TRUE); |
339 | setVTFont( QFont("fixed") ); | 339 | setVTFont( QFont("fixed") ); |
340 | setColorTable(base_color_table); // init color table | 340 | setColorTable(base_color_table); // init color table |
341 | 341 | ||
342 | qApp->installEventFilter( this ); //FIXME: see below | 342 | qApp->installEventFilter( this ); //FIXME: see below |
343 | // KCursor::setAutoHideCursor( this, true ); | 343 | // KCursor::setAutoHideCursor( this, true ); |
344 | 344 | ||
345 | // Init DnD //////////////////////////////////////////////////////////////// | 345 | // Init DnD //////////////////////////////////////////////////////////////// |
346 | currentSession = NULL; | 346 | currentSession = NULL; |
347 | // setAcceptDrops(true); // attempt | 347 | // setAcceptDrops(true); // attempt |
348 | // m_drop = new QPopupMenu(this); | 348 | // m_drop = new QPopupMenu(this); |
349 | // m_drop->insertItem( QString("Paste"), 0); | 349 | // m_drop->insertItem( QString("Paste"), 0); |
350 | // m_drop->insertItem( QString("cd"), 1); | 350 | // m_drop->insertItem( QString("cd"), 1); |
351 | // connect(m_drop, SIGNAL(activated(int)), SLOT(drop_menu_activated(int))); | 351 | // connect(m_drop, SIGNAL(activated(int)), SLOT(drop_menu_activated(int))); |
352 | 352 | ||
353 | // we need focus so that the auto-hide cursor feature works | 353 | // we need focus so that the auto-hide cursor feature works |
354 | setFocus(); | 354 | setFocus(); |
355 | setFocusPolicy( WheelFocus ); | 355 | setFocusPolicy( WheelFocus ); |
356 | } | 356 | } |
357 | 357 | ||
358 | //FIXME: make proper destructor | 358 | //FIXME: make proper destructor |
359 | // Here's a start (David) | 359 | // Here's a start (David) |
360 | TEWidget::~TEWidget() | 360 | TEWidget::~TEWidget() |
361 | { | 361 | { |
@@ -856,49 +856,49 @@ void TEWidget::mouseDoubleClickEvent(QMouseEvent* ev) | |||
856 | int selClass = charClass(image[i].c); | 856 | int selClass = charClass(image[i].c); |
857 | { | 857 | { |
858 | // set the start... | 858 | // set the start... |
859 | int x = bgnSel.x(); | 859 | int x = bgnSel.x(); |
860 | while ( x > 0 && charClass(image[i-1].c) == selClass ) | 860 | while ( x > 0 && charClass(image[i-1].c) == selClass ) |
861 | { i--; x--; } | 861 | { i--; x--; } |
862 | bgnSel.setX(x); | 862 | bgnSel.setX(x); |
863 | emit beginSelectionSignal( bgnSel.x(), bgnSel.y() ); | 863 | emit beginSelectionSignal( bgnSel.x(), bgnSel.y() ); |
864 | 864 | ||
865 | // set the end... | 865 | // set the end... |
866 | i = loc( endSel.x(), endSel.y() ); | 866 | i = loc( endSel.x(), endSel.y() ); |
867 | x = endSel.x(); | 867 | x = endSel.x(); |
868 | while( x < columns-1 && charClass(image[i+1].c) == selClass ) | 868 | while( x < columns-1 && charClass(image[i+1].c) == selClass ) |
869 | { i++; x++ ; } | 869 | { i++; x++ ; } |
870 | endSel.setX(x); | 870 | endSel.setX(x); |
871 | actSel = 2; // within selection | 871 | actSel = 2; // within selection |
872 | emit extendSelectionSignal( endSel.x(), endSel.y() ); | 872 | emit extendSelectionSignal( endSel.x(), endSel.y() ); |
873 | emit endSelectionSignal(preserve_line_breaks); | 873 | emit endSelectionSignal(preserve_line_breaks); |
874 | preserve_line_breaks = TRUE; | 874 | preserve_line_breaks = TRUE; |
875 | } | 875 | } |
876 | } | 876 | } |
877 | 877 | ||
878 | void TEWidget::focusInEvent( QFocusEvent * ) | 878 | void TEWidget::focusInEvent( QFocusEvent * ) |
879 | { | 879 | { |
880 | 880 | ||
881 | // do nothing, to prevent repainting | 881 | // do nothing, to prevent repainting |
882 | } | 882 | } |
883 | 883 | ||
884 | 884 | ||
885 | void TEWidget::focusOutEvent( QFocusEvent * ) | 885 | void TEWidget::focusOutEvent( QFocusEvent * ) |
886 | { | 886 | { |
887 | // do nothing, to prevent repainting | 887 | // do nothing, to prevent repainting |
888 | } | 888 | } |
889 | 889 | ||
890 | bool TEWidget::focusNextPrevChild( bool next ) | 890 | bool TEWidget::focusNextPrevChild( bool next ) |
891 | { | 891 | { |
892 | if (next) | 892 | if (next) |
893 | return false; // This disables changing the active part in konqueror | 893 | return false; // This disables changing the active part in konqueror |
894 | // when pressing Tab | 894 | // when pressing Tab |
895 | return QFrame::focusNextPrevChild( next ); | 895 | return QFrame::focusNextPrevChild( next ); |
896 | } | 896 | } |
897 | 897 | ||
898 | 898 | ||
899 | int TEWidget::charClass(char ch) const | 899 | int TEWidget::charClass(char ch) const |
900 | { | 900 | { |
901 | // This might seem like overkill, but imagine if ch was a Unicode | 901 | // This might seem like overkill, but imagine if ch was a Unicode |
902 | // character (Qt 2.0 QChar) - it might then be sensible to separate | 902 | // character (Qt 2.0 QChar) - it might then be sensible to separate |
903 | // the different language ranges, etc. | 903 | // the different language ranges, etc. |
904 | 904 | ||
@@ -1047,101 +1047,101 @@ bool TEWidget::eventFilter( QObject *obj, QEvent *e ) | |||
1047 | e = new QKeyEvent(e->type(), ke->key(), | 1047 | e = new QKeyEvent(e->type(), ke->key(), |
1048 | ke->ascii(), ke->state()|AltButton, ke->text()); | 1048 | ke->ascii(), ke->state()|AltButton, ke->text()); |
1049 | dele=TRUE; | 1049 | dele=TRUE; |
1050 | } | 1050 | } |
1051 | } | 1051 | } |
1052 | } | 1052 | } |
1053 | #endif | 1053 | #endif |
1054 | 1054 | ||
1055 | if ( e->type() == QEvent::KeyPress ) { | 1055 | if ( e->type() == QEvent::KeyPress ) { |
1056 | QKeyEvent* ke = (QKeyEvent*)e; | 1056 | QKeyEvent* ke = (QKeyEvent*)e; |
1057 | actSel=0; // Key stroke implies a screen update, so TEWidget won't | 1057 | actSel=0; // Key stroke implies a screen update, so TEWidget won't |
1058 | // know where the current selection is. | 1058 | // know where the current selection is. |
1059 | 1059 | ||
1060 | // qDebug("key pressed is 0x%x, ascii is 0x%x, state %d", ke->key(), ke->ascii(), ke->state()); | 1060 | // qDebug("key pressed is 0x%x, ascii is 0x%x, state %d", ke->key(), ke->ascii(), ke->state()); |
1061 | 1061 | ||
1062 | if( ke->state() == ShiftButton && ke->key() == Key_Tab) { | 1062 | if( ke->state() == ShiftButton && ke->key() == Key_Tab) { |
1063 | //lets hardcode this sucker | 1063 | //lets hardcode this sucker |
1064 | 1064 | ||
1065 | // qDebug("key pressed 2 is 0x%x", ke->key()); | 1065 | // qDebug("key pressed 2 is 0x%x", ke->key()); |
1066 | emitText("\\"); // expose | 1066 | emitText("\\"); // expose |
1067 | } | 1067 | } |
1068 | else if( ke->state() == ControlButton && ke->key() == Key_V) { | 1068 | else if( ke->state() == ControlButton && ke->key() == Key_V) { |
1069 | pasteClipboard(); | 1069 | pasteClipboard(); |
1070 | } | 1070 | } |
1071 | else if( ke->state() == ControlButton && ke->key() == Key_C) { | 1071 | // else if( ke->state() == ControlButton && ke->key() == Key_C) { |
1072 | // pasteClipboard(); | 1072 | // pasteClipboard(); |
1073 | } | 1073 | // } |
1074 | else | 1074 | else |
1075 | emit keyPressedSignal(ke); // expose | 1075 | emit keyPressedSignal(ke); // expose |
1076 | ke->accept(); | 1076 | ke->accept(); |
1077 | #ifdef FAKE_CTRL_AND_ALT | 1077 | #ifdef FAKE_CTRL_AND_ALT |
1078 | if ( dele ) delete e; | 1078 | if ( dele ) delete e; |
1079 | #endif | 1079 | #endif |
1080 | return true; // stop the event | 1080 | return true; // stop the event |
1081 | } | 1081 | } |
1082 | if ( e->type() == QEvent::Enter ) { | 1082 | if ( e->type() == QEvent::Enter ) { |
1083 | QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()), | 1083 | QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()), |
1084 | this, SLOT(onClearSelection()) ); | 1084 | this, SLOT(onClearSelection()) ); |
1085 | } | 1085 | } |
1086 | if ( e->type() == QEvent::Leave ) { | 1086 | if ( e->type() == QEvent::Leave ) { |
1087 | QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), | 1087 | QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), |
1088 | this, SLOT(onClearSelection()) ); | 1088 | this, SLOT(onClearSelection()) ); |
1089 | } | 1089 | } |
1090 | return QFrame::eventFilter( obj, e ); | 1090 | return QFrame::eventFilter( obj, e ); |
1091 | } | 1091 | } |
1092 | 1092 | ||
1093 | /* ------------------------------------------------------------------------- */ | 1093 | /* ------------------------------------------------------------------------- */ |
1094 | /* */ | 1094 | /* */ |
1095 | /* Frame */ | 1095 | /* Frame */ |
1096 | /* */ | 1096 | /* */ |
1097 | /* ------------------------------------------------------------------------- */ | 1097 | /* ------------------------------------------------------------------------- */ |
1098 | 1098 | ||
1099 | void TEWidget::frameChanged() | 1099 | void TEWidget::frameChanged() |
1100 | { | 1100 | { |
1101 | propagateSize(); | 1101 | propagateSize(); |
1102 | update(); | 1102 | update(); |
1103 | } | 1103 | } |
1104 | 1104 | ||
1105 | /* ------------------------------------------------------------------------- */ | 1105 | /* ------------------------------------------------------------------------- */ |
1106 | /* */ | 1106 | /* */ |
1107 | /* Sound */ | 1107 | /* Sound */ |
1108 | /* */ | 1108 | /* */ |
1109 | /* ------------------------------------------------------------------------- */ | 1109 | /* ------------------------------------------------------------------------- */ |
1110 | 1110 | ||
1111 | void TEWidget::Bell() | 1111 | void TEWidget::Bell() |
1112 | { | 1112 | { |
1113 | //#ifdef QT_QWS_SHARP | 1113 | //#ifdef QT_QWS_SHARP |
1114 | //# ifndef QT_NO_COP | 1114 | //# ifndef QT_NO_COP |
1115 | if(useBeep) | 1115 | if(useBeep) |
1116 | QCopEnvelope( "QPE/TaskBar", "soundAlarm()" ); | 1116 | QCopEnvelope( "QPE/TaskBar", "soundAlarm()" ); |
1117 | 1117 | ||
1118 | //# endif | 1118 | //# endif |
1119 | //#else | 1119 | //#else |
1120 | //# ifndef QT_NO_SOUND | 1120 | //# ifndef QT_NO_SOUND |
1121 | // QSound::play(Resource::findSound("alarm")); | 1121 | // QSound::play(Resource::findSound("alarm")); |
1122 | //# endif | 1122 | //# endif |
1123 | //#endif | 1123 | //#endif |
1124 | 1124 | ||
1125 | // QApplication::beep(); | 1125 | // QApplication::beep(); |
1126 | } | 1126 | } |
1127 | 1127 | ||
1128 | /* ------------------------------------------------------------------------- */ | 1128 | /* ------------------------------------------------------------------------- */ |
1129 | /* */ | 1129 | /* */ |
1130 | /* Auxiluary */ | 1130 | /* Auxiluary */ |
1131 | /* */ | 1131 | /* */ |
1132 | /* ------------------------------------------------------------------------- */ | 1132 | /* ------------------------------------------------------------------------- */ |
1133 | 1133 | ||
1134 | void TEWidget::clearImage() | 1134 | void TEWidget::clearImage() |
1135 | // initialize the image | 1135 | // initialize the image |
1136 | // for internal use only | 1136 | // for internal use only |
1137 | { | 1137 | { |
1138 | for (int y = 0; y < lines; y++) | 1138 | for (int y = 0; y < lines; y++) |
1139 | for (int x = 0; x < columns; x++) | 1139 | for (int x = 0; x < columns; x++) |
1140 | { | 1140 | { |
1141 | image[loc(x,y)].c = 0xff; //' '; | 1141 | image[loc(x,y)].c = 0xff; //' '; |
1142 | image[loc(x,y)].f = 0xff; //DEFAULT_FORE_COLOR; | 1142 | image[loc(x,y)].f = 0xff; //DEFAULT_FORE_COLOR; |
1143 | image[loc(x,y)].b = 0xff; //DEFAULT_BACK_COLOR; | 1143 | image[loc(x,y)].b = 0xff; //DEFAULT_BACK_COLOR; |
1144 | image[loc(x,y)].r = 0xff; //DEFAULT_RENDITION; | 1144 | image[loc(x,y)].r = 0xff; //DEFAULT_RENDITION; |
1145 | } | 1145 | } |
1146 | } | 1146 | } |
1147 | 1147 | ||
@@ -1188,49 +1188,49 @@ void TEWidget::calcGeometry() | |||
1188 | columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; | 1188 | columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; |
1189 | dcolumns = columns; | 1189 | dcolumns = columns; |
1190 | if(vcolumns) columns = vcolumns; | 1190 | if(vcolumns) columns = vcolumns; |
1191 | blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; | 1191 | blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; |
1192 | if(showhscrollbar) | 1192 | if(showhscrollbar) |
1193 | blX = -hposition * font_w; | 1193 | blX = -hposition * font_w; |
1194 | brX = blX; | 1194 | brX = blX; |
1195 | scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0)); | 1195 | scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0)); |
1196 | scrollbar->show(); | 1196 | scrollbar->show(); |
1197 | break; | 1197 | break; |
1198 | } | 1198 | } |
1199 | //FIXME: support 'rounding' styles | 1199 | //FIXME: support 'rounding' styles |
1200 | lines = ( contentsRect().height() - 2 * rimY ) / font_h; | 1200 | lines = ( contentsRect().height() - 2 * rimY ) / font_h; |
1201 | bY = (contentsRect().height() - (lines *font_h)) / 2; | 1201 | bY = (contentsRect().height() - (lines *font_h)) / 2; |
1202 | 1202 | ||
1203 | if(showhscrollbar == 1) { | 1203 | if(showhscrollbar == 1) { |
1204 | hScrollbar->resize(contentsRect().width() - hwidth, hwidth); | 1204 | hScrollbar->resize(contentsRect().width() - hwidth, hwidth); |
1205 | hScrollbar->setRange(0, vcolumns - dcolumns); | 1205 | hScrollbar->setRange(0, vcolumns - dcolumns); |
1206 | 1206 | ||
1207 | QPoint p = contentsRect().bottomLeft(); | 1207 | QPoint p = contentsRect().bottomLeft(); |
1208 | if(scrollLoc == SCRLEFT) | 1208 | if(scrollLoc == SCRLEFT) |
1209 | hScrollbar->move(QPoint(p.x()+hwidth, p.y() - hwidth)); | 1209 | hScrollbar->move(QPoint(p.x()+hwidth, p.y() - hwidth)); |
1210 | else | 1210 | else |
1211 | hScrollbar->move(QPoint(p.x(), p.y() - hwidth)); | 1211 | hScrollbar->move(QPoint(p.x(), p.y() - hwidth)); |
1212 | 1212 | ||
1213 | hScrollbar->show(); | 1213 | hScrollbar->show(); |
1214 | } | 1214 | } |
1215 | else hScrollbar->hide(); | 1215 | else hScrollbar->hide(); |
1216 | 1216 | ||
1217 | if(showhscrollbar == 1) { | 1217 | if(showhscrollbar == 1) { |
1218 | lines = lines - (hwidth / font_h) - 1; | 1218 | lines = lines - (hwidth / font_h) - 1; |
1219 | if(lines < 1) lines = 1; | 1219 | if(lines < 1) lines = 1; |
1220 | } | 1220 | } |
1221 | //FIXME: support 'rounding' styles | 1221 | //FIXME: support 'rounding' styles |
1222 | } | 1222 | } |
1223 | 1223 | ||
1224 | void TEWidget::makeImage() | 1224 | void TEWidget::makeImage() |
1225 | //FIXME: rename 'calcGeometry? | 1225 | //FIXME: rename 'calcGeometry? |
1226 | { | 1226 | { |
1227 | calcGeometry(); | 1227 | calcGeometry(); |
1228 | image = (ca*) malloc(lines*columns*sizeof(ca)); | 1228 | image = (ca*) malloc(lines*columns*sizeof(ca)); |
1229 | clearImage(); | 1229 | clearImage(); |
1230 | } | 1230 | } |
1231 | 1231 | ||
1232 | // calculate the needed size | 1232 | // calculate the needed size |
1233 | QSize TEWidget::calcSize(int cols, int lins) const | 1233 | QSize TEWidget::calcSize(int cols, int lins) const |
1234 | { | 1234 | { |
1235 | int frw = width() - contentsRect().width(); | 1235 | int frw = width() - contentsRect().width(); |
1236 | int frh = height() - contentsRect().height(); | 1236 | int frh = height() - contentsRect().height(); |