author | llornkcor <llornkcor> | 2003-03-16 20:50:47 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2003-03-16 20:50:47 (UTC) |
commit | 75ebe1838923e121cb093310f7f7c1b021abdcc1 (patch) (unidiff) | |
tree | a7b6e735b7faa08ba1689a7ed6155ceaca5ea1e4 | |
parent | 0aff3e917df1fb56eb1f2a6b2ed98355b25ad653 (diff) | |
download | opie-75ebe1838923e121cb093310f7f7c1b021abdcc1.zip opie-75ebe1838923e121cb093310f7f7c1b021abdcc1.tar.gz opie-75ebe1838923e121cb093310f7f7c1b021abdcc1.tar.bz2 |
fix Ctrl-C
-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 | |||
@@ -237,165 +237,165 @@ static QChar vt100extended(QChar c) | |||
237 | 237 | ||
238 | static QChar identicalMap(QChar c) | 238 | static QChar identicalMap(QChar c) |
239 | { | 239 | { |
240 | return c; | 240 | return c; |
241 | } | 241 | } |
242 | 242 | ||
243 | void TEWidget::fontChange(const QFont &) | 243 | void TEWidget::fontChange(const QFont &) |
244 | { | 244 | { |
245 | QFontMetrics fm(font()); | 245 | QFontMetrics fm(font()); |
246 | font_h = fm.height(); | 246 | font_h = fm.height(); |
247 | font_w = fm.maxWidth(); | 247 | font_w = fm.maxWidth(); |
248 | font_a = fm.ascent(); | 248 | font_a = fm.ascent(); |
249 | //printf("font_h: %d\n",font_h); | 249 | //printf("font_h: %d\n",font_h); |
250 | //printf("font_w: %d\n",font_w); | 250 | //printf("font_w: %d\n",font_w); |
251 | //printf("font_a: %d\n",font_a); | 251 | //printf("font_a: %d\n",font_a); |
252 | //printf("charset: %s\n",QFont::encodingName(font().charSet()).ascii()); | 252 | //printf("charset: %s\n",QFont::encodingName(font().charSet()).ascii()); |
253 | //printf("rawname: %s\n",font().rawName().ascii()); | 253 | //printf("rawname: %s\n",font().rawName().ascii()); |
254 | fontMap = | 254 | fontMap = |
255 | #if QT_VERSION < 300 | 255 | #if QT_VERSION < 300 |
256 | strcmp(QFont::encodingName(font().charSet()).ascii(),"iso10646") | 256 | strcmp(QFont::encodingName(font().charSet()).ascii(),"iso10646") |
257 | ? vt100extended | 257 | ? vt100extended |
258 | : | 258 | : |
259 | #endif | 259 | #endif |
260 | identicalMap; | 260 | identicalMap; |
261 | propagateSize(); | 261 | propagateSize(); |
262 | update(); | 262 | update(); |
263 | } | 263 | } |
264 | 264 | ||
265 | void TEWidget::setVTFont(const QFont& f) | 265 | void TEWidget::setVTFont(const QFont& f) |
266 | { | 266 | { |
267 | QFrame::setFont(f); | 267 | QFrame::setFont(f); |
268 | } | 268 | } |
269 | 269 | ||
270 | QFont TEWidget::getVTFont() { | 270 | QFont TEWidget::getVTFont() { |
271 | return font(); | 271 | return font(); |
272 | } | 272 | } |
273 | 273 | ||
274 | void TEWidget::setFont(const QFont &) | 274 | void TEWidget::setFont(const QFont &) |
275 | { | 275 | { |
276 | // ignore font change request if not coming from konsole itself | 276 | // ignore font change request if not coming from konsole itself |
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 | { |
362 | qApp->removeEventFilter( this ); | 362 | qApp->removeEventFilter( this ); |
363 | if (image) free(image); | 363 | if (image) free(image); |
364 | } | 364 | } |
365 | 365 | ||
366 | /* ------------------------------------------------------------------------- */ | 366 | /* ------------------------------------------------------------------------- */ |
367 | /* */ | 367 | /* */ |
368 | /* Display Operations */ | 368 | /* Display Operations */ |
369 | /* */ | 369 | /* */ |
370 | /* ------------------------------------------------------------------------- */ | 370 | /* ------------------------------------------------------------------------- */ |
371 | 371 | ||
372 | /*! | 372 | /*! |
373 | attributed string draw primitive | 373 | attributed string draw primitive |
374 | */ | 374 | */ |
375 | 375 | ||
376 | void TEWidget::drawAttrStr(QPainter &paint, QRect rect, | 376 | void TEWidget::drawAttrStr(QPainter &paint, QRect rect, |
377 | QString& str, ca attr, BOOL pm, BOOL clear) | 377 | QString& str, ca attr, BOOL pm, BOOL clear) |
378 | { | 378 | { |
379 | if (pm && color_table[attr.b].transparent) | 379 | if (pm && color_table[attr.b].transparent) |
380 | { | 380 | { |
381 | paint.setBackgroundMode( TransparentMode ); | 381 | paint.setBackgroundMode( TransparentMode ); |
382 | if (clear) erase(rect); | 382 | if (clear) erase(rect); |
383 | } | 383 | } |
384 | else | 384 | else |
385 | { | 385 | { |
386 | if (blinking) | 386 | if (blinking) |
387 | paint.fillRect(rect, color_table[attr.b].color); | 387 | paint.fillRect(rect, color_table[attr.b].color); |
388 | else | 388 | else |
389 | { | 389 | { |
390 | paint.setBackgroundMode( OpaqueMode ); | 390 | paint.setBackgroundMode( OpaqueMode ); |
391 | paint.setBackgroundColor( color_table[attr.b].color ); | 391 | paint.setBackgroundColor( color_table[attr.b].color ); |
392 | } | 392 | } |
393 | } | 393 | } |
394 | 394 | ||
395 | if (color_table[attr.f].bold) | 395 | if (color_table[attr.f].bold) |
396 | paint.setPen(QColor( 0x8F, 0x00, 0x00 )); | 396 | paint.setPen(QColor( 0x8F, 0x00, 0x00 )); |
397 | else | 397 | else |
398 | paint.setPen(color_table[attr.f].color); | 398 | paint.setPen(color_table[attr.f].color); |
399 | 399 | ||
400 | paint.drawText(rect.x(),rect.y()+font_a, str); | 400 | paint.drawText(rect.x(),rect.y()+font_a, str); |
401 | 401 | ||
@@ -816,129 +816,129 @@ void TEWidget::mouseReleaseEvent(QMouseEvent* ev) | |||
816 | QPoint tL = contentsRect().topLeft(); | 816 | QPoint tL = contentsRect().topLeft(); |
817 | int tLx = tL.x(); | 817 | int tLx = tL.x(); |
818 | int tLy = tL.y(); | 818 | int tLy = tL.y(); |
819 | 819 | ||
820 | if (!mouse_marks && !(ev->state() & ShiftButton)) | 820 | if (!mouse_marks && !(ev->state() & ShiftButton)) |
821 | emit mouseSignal( 3, // release | 821 | emit mouseSignal( 3, // release |
822 | (ev->x()-tLx-blX)/font_w + 1, | 822 | (ev->x()-tLx-blX)/font_w + 1, |
823 | (ev->y()-tLy-bY)/font_h + 1 ); | 823 | (ev->y()-tLy-bY)/font_h + 1 ); |
824 | releaseMouse(); | 824 | releaseMouse(); |
825 | } | 825 | } |
826 | } | 826 | } |
827 | 827 | ||
828 | void TEWidget::mouseDoubleClickEvent(QMouseEvent* ev) | 828 | void TEWidget::mouseDoubleClickEvent(QMouseEvent* ev) |
829 | { | 829 | { |
830 | if ( ev->button() != LeftButton) return; | 830 | if ( ev->button() != LeftButton) return; |
831 | 831 | ||
832 | QPoint tL = contentsRect().topLeft(); | 832 | QPoint tL = contentsRect().topLeft(); |
833 | int tLx = tL.x(); | 833 | int tLx = tL.x(); |
834 | int tLy = tL.y(); | 834 | int tLy = tL.y(); |
835 | QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); | 835 | QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); |
836 | 836 | ||
837 | // pass on double click as two clicks. | 837 | // pass on double click as two clicks. |
838 | if (!mouse_marks && !(ev->state() & ShiftButton)) | 838 | if (!mouse_marks && !(ev->state() & ShiftButton)) |
839 | { | 839 | { |
840 | emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button | 840 | emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button |
841 | emit mouseSignal( 3, pos.x()+1, pos.y()+1 ); // release | 841 | emit mouseSignal( 3, pos.x()+1, pos.y()+1 ); // release |
842 | emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button | 842 | emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button |
843 | return; | 843 | return; |
844 | } | 844 | } |
845 | 845 | ||
846 | 846 | ||
847 | emit clearSelectionSignal(); | 847 | emit clearSelectionSignal(); |
848 | QPoint bgnSel = pos; | 848 | QPoint bgnSel = pos; |
849 | QPoint endSel = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); | 849 | QPoint endSel = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); |
850 | int i = loc(bgnSel.x(),bgnSel.y()); | 850 | int i = loc(bgnSel.x(),bgnSel.y()); |
851 | iPntSel = bgnSel; | 851 | iPntSel = bgnSel; |
852 | 852 | ||
853 | word_selection_mode = TRUE; | 853 | word_selection_mode = TRUE; |
854 | 854 | ||
855 | // find word boundaries... | 855 | // find word boundaries... |
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 | ||
905 | if ( isspace(ch) ) return ' '; | 905 | if ( isspace(ch) ) return ' '; |
906 | 906 | ||
907 | static const char *word_characters = ":@-./_~"; | 907 | static const char *word_characters = ":@-./_~"; |
908 | if ( isalnum(ch) || strchr(word_characters, ch) ) | 908 | if ( isalnum(ch) || strchr(word_characters, ch) ) |
909 | return 'a'; | 909 | return 'a'; |
910 | 910 | ||
911 | // Everything else is weird | 911 | // Everything else is weird |
912 | return 1; | 912 | return 1; |
913 | } | 913 | } |
914 | 914 | ||
915 | void TEWidget::setMouseMarks(bool on) | 915 | void TEWidget::setMouseMarks(bool on) |
916 | { | 916 | { |
917 | mouse_marks = on; | 917 | mouse_marks = on; |
918 | setCursor( mouse_marks ? ibeamCursor : arrowCursor ); | 918 | setCursor( mouse_marks ? ibeamCursor : arrowCursor ); |
919 | } | 919 | } |
920 | 920 | ||
921 | /* ------------------------------------------------------------------------- */ | 921 | /* ------------------------------------------------------------------------- */ |
922 | /* */ | 922 | /* */ |
923 | /* Clipboard */ | 923 | /* Clipboard */ |
924 | /* */ | 924 | /* */ |
925 | /* ------------------------------------------------------------------------- */ | 925 | /* ------------------------------------------------------------------------- */ |
926 | 926 | ||
927 | #undef KeyPress | 927 | #undef KeyPress |
928 | 928 | ||
929 | void TEWidget::emitSelection() | 929 | void TEWidget::emitSelection() |
930 | // Paste Clipboard by simulating keypress events | 930 | // Paste Clipboard by simulating keypress events |
931 | { | 931 | { |
932 | #ifndef QT_NO_CLIPBOARD | 932 | #ifndef QT_NO_CLIPBOARD |
933 | QString text = QApplication::clipboard()->text(); | 933 | QString text = QApplication::clipboard()->text(); |
934 | //qDebug(text); | 934 | //qDebug(text); |
935 | if ( ! text.isNull()) | 935 | if ( ! text.isNull()) |
936 | { | 936 | { |
937 | text.replace(QRegExp("\n"), "\r"); | 937 | text.replace(QRegExp("\n"), "\r"); |
938 | QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text); | 938 | QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text); |
939 | emit keyPressedSignal(&e); // expose as a big fat keypress event | 939 | emit keyPressedSignal(&e); // expose as a big fat keypress event |
940 | emit clearSelectionSignal(); | 940 | emit clearSelectionSignal(); |
941 | } | 941 | } |
942 | #endif | 942 | #endif |
943 | } | 943 | } |
944 | 944 | ||
@@ -1007,270 +1007,270 @@ bool TEWidget::eventFilter( QObject *obj, QEvent *e ) | |||
1007 | if ( (e->type() == QEvent::Accel || | 1007 | if ( (e->type() == QEvent::Accel || |
1008 | e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) { | 1008 | e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) { |
1009 | static_cast<QKeyEvent *>( e )->ignore(); | 1009 | static_cast<QKeyEvent *>( e )->ignore(); |
1010 | return true; | 1010 | return true; |
1011 | } | 1011 | } |
1012 | if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ ) | 1012 | if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ ) |
1013 | return FALSE; // not us | 1013 | return FALSE; // not us |
1014 | if ( e->type() == QEvent::Wheel) { | 1014 | if ( e->type() == QEvent::Wheel) { |
1015 | QApplication::sendEvent(scrollbar, e); | 1015 | QApplication::sendEvent(scrollbar, e); |
1016 | } | 1016 | } |
1017 | 1017 | ||
1018 | #ifdef FAKE_CTRL_AND_ALT | 1018 | #ifdef FAKE_CTRL_AND_ALT |
1019 | static bool control = FALSE; | 1019 | static bool control = FALSE; |
1020 | static bool alt = FALSE; | 1020 | static bool alt = FALSE; |
1021 | // qDebug(" Has a keyboard with no CTRL and ALT keys, but we fake it:"); | 1021 | // qDebug(" Has a keyboard with no CTRL and ALT keys, but we fake it:"); |
1022 | bool dele=FALSE; | 1022 | bool dele=FALSE; |
1023 | if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { | 1023 | if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { |
1024 | QKeyEvent* ke = (QKeyEvent*)e; | 1024 | QKeyEvent* ke = (QKeyEvent*)e; |
1025 | bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat(); | 1025 | bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat(); |
1026 | switch (ke->key()) { | 1026 | switch (ke->key()) { |
1027 | case Key_F9: // let this be "Control" | 1027 | case Key_F9: // let this be "Control" |
1028 | control = keydown; | 1028 | control = keydown; |
1029 | e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state()); | 1029 | e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state()); |
1030 | dele=TRUE; | 1030 | dele=TRUE; |
1031 | break; | 1031 | break; |
1032 | case Key_F13: // let this be "Alt" | 1032 | case Key_F13: // let this be "Alt" |
1033 | alt = keydown; | 1033 | alt = keydown; |
1034 | e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state()); | 1034 | e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state()); |
1035 | dele=TRUE; | 1035 | dele=TRUE; |
1036 | break; | 1036 | break; |
1037 | default: | 1037 | default: |
1038 | if ( control ) { | 1038 | if ( control ) { |
1039 | int a = toupper(ke->ascii())-64; | 1039 | int a = toupper(ke->ascii())-64; |
1040 | if ( a >= 0 && a < ' ' ) { | 1040 | if ( a >= 0 && a < ' ' ) { |
1041 | e = new QKeyEvent(e->type(), ke->key(), | 1041 | e = new QKeyEvent(e->type(), ke->key(), |
1042 | a, ke->state()|ControlButton, QChar(a,0)); | 1042 | a, ke->state()|ControlButton, QChar(a,0)); |
1043 | dele=TRUE; | 1043 | dele=TRUE; |
1044 | } | 1044 | } |
1045 | } | 1045 | } |
1046 | if ( alt ) { | 1046 | if ( alt ) { |
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 | ||
1148 | // Create Image /////////////////////////////////////////////////////// | 1148 | // Create Image /////////////////////////////////////////////////////// |
1149 | 1149 | ||
1150 | void TEWidget::calcGeometry() | 1150 | void TEWidget::calcGeometry() |
1151 | { | 1151 | { |
1152 | int showhscrollbar = 1; | 1152 | int showhscrollbar = 1; |
1153 | int hwidth = 0; | 1153 | int hwidth = 0; |
1154 | int dcolumns; | 1154 | int dcolumns; |
1155 | Config cfg("Konsole"); | 1155 | Config cfg("Konsole"); |
1156 | cfg.setGroup("ScrollBar"); | 1156 | cfg.setGroup("ScrollBar"); |
1157 | useHorzScroll=cfg.readBoolEntry("HorzScroll",0); | 1157 | useHorzScroll=cfg.readBoolEntry("HorzScroll",0); |
1158 | 1158 | ||
1159 | if(vcolumns == 0) showhscrollbar = 0; | 1159 | if(vcolumns == 0) showhscrollbar = 0; |
1160 | if(showhscrollbar == 1) hwidth = QApplication::style().scrollBarExtent().width(); | 1160 | if(showhscrollbar == 1) hwidth = QApplication::style().scrollBarExtent().width(); |
1161 | 1161 | ||
1162 | scrollbar->resize(QApplication::style().scrollBarExtent().width(), | 1162 | scrollbar->resize(QApplication::style().scrollBarExtent().width(), |
1163 | contentsRect().height() - hwidth); | 1163 | contentsRect().height() - hwidth); |
1164 | 1164 | ||
1165 | switch(scrollLoc) { | 1165 | switch(scrollLoc) { |
1166 | case SCRNONE : | 1166 | case SCRNONE : |
1167 | columns = ( contentsRect().width() - 2 * rimX ) / font_w; | 1167 | columns = ( contentsRect().width() - 2 * rimX ) / font_w; |
1168 | dcolumns = columns; | 1168 | dcolumns = columns; |
1169 | if(vcolumns) columns = vcolumns; | 1169 | if(vcolumns) columns = vcolumns; |
1170 | blX = (contentsRect().width() - (columns*font_w) ) / 2; | 1170 | blX = (contentsRect().width() - (columns*font_w) ) / 2; |
1171 | if(showhscrollbar) | 1171 | if(showhscrollbar) |
1172 | blX = -hposition * font_w; | 1172 | blX = -hposition * font_w; |
1173 | brX = blX; | 1173 | brX = blX; |
1174 | scrollbar->hide(); | 1174 | scrollbar->hide(); |
1175 | break; | 1175 | break; |
1176 | case SCRLEFT : | 1176 | case SCRLEFT : |
1177 | columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; | 1177 | columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; |
1178 | dcolumns = columns; | 1178 | dcolumns = columns; |
1179 | if(vcolumns) columns = vcolumns; | 1179 | if(vcolumns) columns = vcolumns; |
1180 | brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; | 1180 | brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; |
1181 | if(showhscrollbar) | 1181 | if(showhscrollbar) |
1182 | brX = -hposition * font_w; | 1182 | brX = -hposition * font_w; |
1183 | blX = brX + scrollbar->width(); | 1183 | blX = brX + scrollbar->width(); |
1184 | scrollbar->move(contentsRect().topLeft()); | 1184 | scrollbar->move(contentsRect().topLeft()); |
1185 | scrollbar->show(); | 1185 | scrollbar->show(); |
1186 | break; | 1186 | break; |
1187 | case SCRRIGHT: | 1187 | case SCRRIGHT: |
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(); |
1237 | int scw = (scrollLoc==SCRNONE?0:scrollbar->width()); | 1237 | int scw = (scrollLoc==SCRNONE?0:scrollbar->width()); |
1238 | return QSize( font_w*cols + 2*rimX + frw + scw, font_h*lins + 2*rimY + frh ); | 1238 | return QSize( font_w*cols + 2*rimX + frw + scw, font_h*lins + 2*rimY + frh ); |
1239 | } | 1239 | } |
1240 | 1240 | ||
1241 | QSize TEWidget::sizeHint() const | 1241 | QSize TEWidget::sizeHint() const |
1242 | { | 1242 | { |
1243 | return size(); | 1243 | return size(); |
1244 | } | 1244 | } |
1245 | 1245 | ||
1246 | void TEWidget::styleChange(QStyle &) | 1246 | void TEWidget::styleChange(QStyle &) |
1247 | { | 1247 | { |
1248 | propagateSize(); | 1248 | propagateSize(); |
1249 | } | 1249 | } |
1250 | 1250 | ||
1251 | #ifndef QT_NO_DRAGANDDROP | 1251 | #ifndef QT_NO_DRAGANDDROP |
1252 | 1252 | ||
1253 | /* --------------------------------------------------------------------- */ | 1253 | /* --------------------------------------------------------------------- */ |
1254 | /* */ | 1254 | /* */ |
1255 | /* Drag & Drop */ | 1255 | /* Drag & Drop */ |
1256 | /* */ | 1256 | /* */ |
1257 | /* --------------------------------------------------------------------- */ | 1257 | /* --------------------------------------------------------------------- */ |
1258 | 1258 | ||
1259 | 1259 | ||
1260 | void TEWidget::dragEnterEvent(QDragEnterEvent* e) | 1260 | void TEWidget::dragEnterEvent(QDragEnterEvent* e) |
1261 | { | 1261 | { |
1262 | e->accept(QTextDrag::canDecode(e) || | 1262 | e->accept(QTextDrag::canDecode(e) || |
1263 | QUriDrag::canDecode(e)); | 1263 | QUriDrag::canDecode(e)); |
1264 | } | 1264 | } |
1265 | 1265 | ||
1266 | void TEWidget::dropEvent(QDropEvent* event) | 1266 | void TEWidget::dropEvent(QDropEvent* event) |
1267 | { | 1267 | { |
1268 | // The current behaviour when url(s) are dropped is | 1268 | // The current behaviour when url(s) are dropped is |
1269 | // * if there is only ONE url and if it's a LOCAL one, ask for paste or cd | 1269 | // * if there is only ONE url and if it's a LOCAL one, ask for paste or cd |
1270 | // * in all other cases, just paste | 1270 | // * in all other cases, just paste |
1271 | // (for non-local ones, or for a list of URLs, 'cd' is nonsense) | 1271 | // (for non-local ones, or for a list of URLs, 'cd' is nonsense) |
1272 | QStrList strlist; | 1272 | QStrList strlist; |
1273 | int file_count = 0; | 1273 | int file_count = 0; |
1274 | dropText = ""; | 1274 | dropText = ""; |
1275 | bool bPopup = true; | 1275 | bool bPopup = true; |
1276 | 1276 | ||