Diffstat (limited to 'core/apps/embeddedkonsole/TEWidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/apps/embeddedkonsole/TEWidget.cpp | 98 |
1 files changed, 51 insertions, 47 deletions
diff --git a/core/apps/embeddedkonsole/TEWidget.cpp b/core/apps/embeddedkonsole/TEWidget.cpp index dc83998..f10bfb2 100644 --- a/core/apps/embeddedkonsole/TEWidget.cpp +++ b/core/apps/embeddedkonsole/TEWidget.cpp | |||
@@ -1,42 +1,41 @@ | |||
1 | /* ------------------------------------------------------------------------ */ | 1 | /* ------------------------------------------------------------------------ */ |
2 | /* */ | 2 | /* */ |
3 | /* [TEWidget.C] Terminal Emulation Widget */ | 3 | /* [TEWidget.C] Terminal Emulation Widget */ |
4 | /* */ | 4 | /* */ |
5 | /* ------------------------------------------------------------------------ */ | 5 | /* ------------------------------------------------------------------------ */ |
6 | /* */ | 6 | /* */ |
7 | /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ | 7 | /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ |
8 | /* */ | 8 | /* */ |
9 | /* This file is part of Konsole - an X terminal for KDE */ | 9 | /* This file is part of Konsole - an X terminal for KDE */ |
10 | /* */ | 10 | /* */ |
11 | /* ------------------------------------------------------------------------ */ | 11 | /* ------------------------------------------------------------------------ */ |
12 | /* */ | 12 | /* */ |
13 | /* Ported Konsole to Qt/Embedded */ | 13 | /* Ported Konsole to Qt/Embedded */ |
14 | /* */ | 14 | /* */ |
15 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ | 15 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ |
16 | /* */ | 16 | /* */ |
17 | /* -------------------------------------------------------------------------- */ | 17 | /* -------------------------------------------------------------------------- */ |
18 | |||
19 | /*! \class TEWidget | 18 | /*! \class TEWidget |
20 | 19 | ||
21 | \brief Visible screen contents | 20 | \brief Visible screen contents |
22 | 21 | ||
23 | This class is responsible to map the `image' of a terminal emulation to the | 22 | This class is responsible to map the `image' of a terminal emulation to the |
24 | display. All the dependency of the emulation to a specific GUI or toolkit is | 23 | display. All the dependency of the emulation to a specific GUI or toolkit is |
25 | localized here. Further, this widget has no knowledge about being part of an | 24 | localized here. Further, this widget has no knowledge about being part of an |
26 | emulation, it simply work within the terminal emulation framework by exposing | 25 | emulation, it simply work within the terminal emulation framework by exposing |
27 | size and key events and by being ordered to show a new image. | 26 | size and key events and by being ordered to show a new image. |
28 | 27 | ||
29 | <ul> | 28 | <ul> |
30 | <li> The internal image has the size of the widget (evtl. rounded up) | 29 | <li> The internal image has the size of the widget (evtl. rounded up) |
31 | <li> The external image used in setImage can have any size. | 30 | <li> The external image used in setImage can have any size. |
32 | <li> (internally) the external image is simply copied to the internal | 31 | <li> (internally) the external image is simply copied to the internal |
33 | when a setImage happens. During a resizeEvent no painting is done | 32 | when a setImage happens. During a resizeEvent no painting is done |
34 | a paintEvent is expected to follow anyway. | 33 | a paintEvent is expected to follow anyway. |
35 | </ul> | 34 | </ul> |
36 | 35 | ||
37 | \sa TEScreen \sa Emulation | 36 | \sa TEScreen \sa Emulation |
38 | */ | 37 | */ |
39 | 38 | ||
40 | /* FIXME: | 39 | /* FIXME: |
41 | - 'image' may also be used uninitialized (it isn't in fact) in resizeEvent | 40 | - 'image' may also be used uninitialized (it isn't in fact) in resizeEvent |
42 | - 'font_a' not used in mouse events | 41 | - 'font_a' not used in mouse events |
@@ -94,70 +93,76 @@ | |||
94 | /* ------------------------------------------------------------------------- */ | 93 | /* ------------------------------------------------------------------------- */ |
95 | /* */ | 94 | /* */ |
96 | /* Colors */ | 95 | /* Colors */ |
97 | /* */ | 96 | /* */ |
98 | /* ------------------------------------------------------------------------- */ | 97 | /* ------------------------------------------------------------------------- */ |
99 | 98 | ||
100 | //FIXME: the default color table is in session.C now. | 99 | //FIXME: the default color table is in session.C now. |
101 | // We need a way to get rid of this one, here. | 100 | // We need a way to get rid of this one, here. |
102 | static const ColorEntry base_color_table[TABLE_COLORS] = | 101 | static const ColorEntry base_color_table[TABLE_COLORS] = |
103 | // The following are almost IBM standard color codes, with some slight | 102 | // The following are almost IBM standard color codes, with some slight |
104 | // gamma correction for the dim colors to compensate for bright X screens. | 103 | // gamma correction for the dim colors to compensate for bright X screens. |
105 | // It contains the 8 ansiterm/xterm colors in 2 intensities. | 104 | // It contains the 8 ansiterm/xterm colors in 2 intensities. |
106 | { | 105 | { |
107 | // Fixme: could add faint colors here, also. | 106 | // Fixme: could add faint colors here, also. |
108 | // normal | 107 | // normal |
109 | ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 1, 0 ), // Dfore, Dback | 108 | ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 1, 0 ), // Dfore, Dback |
110 | ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0x18), 0, 0 ), // Black, Red | 109 | ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0x18), 0, 0 ), // Black, Red |
111 | ColorEntry(QColor(0x18,0xB2,0x18), 0, 0 ), ColorEntry( QColor(0xB2,0x68,0x18), 0, 0 ), // Green, Yellow | 110 | ColorEntry(QColor(0x18,0xB2,0x18), 0, 0 ), ColorEntry( QColor(0xB2,0x68,0x18), 0, 0 ), // Green, Yellow |
112 | ColorEntry(QColor(0x18,0x18,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), // Blue, Magenta | 111 | ColorEntry(QColor(0x18,0x18,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), // Blue, Magenta |
113 | ColorEntry(QColor(0x18,0xB2,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 0, 0 ), // Cyan, White | 112 | ColorEntry(QColor(0x18,0xB2,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 0, 0 ), // Cyan, White |
114 | // intensiv | 113 | // intensiv |
115 | ColorEntry(QColor(0x00,0x00,0x00), 0, 1 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 1, 0 ), | 114 | ColorEntry(QColor(0x00,0x00,0x00), 0, 1 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 1, 0 ), |
116 | ColorEntry(QColor(0x68,0x68,0x68), 0, 0 ), ColorEntry( QColor(0xFF,0x54,0x54), 0, 0 ), | 115 | ColorEntry(QColor(0x68,0x68,0x68), 0, 0 ), ColorEntry( QColor(0xFF,0x54,0x54), 0, 0 ), |
117 | ColorEntry(QColor(0x54,0xFF,0x54), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0x54), 0, 0 ), | 116 | ColorEntry(QColor(0x54,0xFF,0x54), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0x54), 0, 0 ), |
118 | ColorEntry(QColor(0x54,0x54,0xFF), 0, 0 ), ColorEntry( QColor(0xFF,0x54,0xFF), 0, 0 ), | 117 | ColorEntry(QColor(0x54,0x54,0xFF), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), |
119 | ColorEntry(QColor(0x54,0xFF,0xFF), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 0, 0 ) | 118 | ColorEntry(QColor(0x54,0xFF,0xFF), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 0, 0 ) |
120 | }; | 119 | }; |
121 | 120 | ||
122 | /* Note that we use ANSI color order (bgr), while IBMPC color order is (rgb) | 121 | /* Note that we use ANSI color order (bgr), while IBMPC color order is (rgb) |
123 | 122 | ||
124 | Code 0 1 2 3 4 5 6 7 | 123 | Code 0 1 2 3 4 5 6 7 |
125 | ----------- ------- ------- ------- ------- ------- ------- ------- ------- | 124 | ----------- ------- ------- ------- ------- ------- ------- ------- ------- |
126 | ANSI (bgr) Black Red Green Yellow Blue Magenta Cyan White | 125 | ANSI (bgr) Black Red Green Yellow Blue Magenta Cyan White |
127 | IBMPC (rgb) Black Blue Green Cyan Red Magenta Yellow White | 126 | IBMPC (rgb) Black Blue Green Cyan Red Magenta Yellow White |
128 | */ | 127 | */ |
129 | 128 | ||
130 | QColor TEWidget::getDefaultBackColor() | 129 | QColor TEWidget::getDefaultBackColor() |
131 | { | 130 | { |
132 | return color_table[DEFAULT_BACK_COLOR].color; | 131 | return color_table[DEFAULT_BACK_COLOR].color; |
133 | } | 132 | } |
134 | 133 | ||
135 | const ColorEntry* TEWidget::getColorTable() const | 134 | const ColorEntry* TEWidget::getColorTable() const |
136 | { | 135 | { |
137 | return color_table; | 136 | return color_table; |
138 | } | 137 | } |
139 | 138 | ||
139 | const ColorEntry* TEWidget::getdefaultColorTable() const | ||
140 | { | ||
141 | return base_color_table; | ||
142 | } | ||
143 | |||
144 | |||
140 | const QPixmap *TEWidget::backgroundPixmap() | 145 | const QPixmap *TEWidget::backgroundPixmap() |
141 | { | 146 | { |
142 | static QPixmap *bg = new QPixmap("~/qpim/main/pics/faded_bg.xpm"); | 147 | static QPixmap *bg = new QPixmap("~/qpim/main/pics/faded_bg.xpm"); |
143 | const QPixmap *pm = bg; | 148 | const QPixmap *pm = bg; |
144 | return pm; | 149 | return pm; |
145 | } | 150 | } |
146 | 151 | ||
147 | void TEWidget::setColorTable(const ColorEntry table[]) | 152 | void TEWidget::setColorTable(const ColorEntry table[]) |
148 | { | 153 | { |
149 | for (int i = 0; i < TABLE_COLORS; i++) color_table[i] = table[i]; | 154 | for (int i = 0; i < TABLE_COLORS; i++) color_table[i] = table[i]; |
150 | 155 | ||
151 | const QPixmap* pm = backgroundPixmap(); | 156 | const QPixmap* pm = backgroundPixmap(); |
152 | if (!pm) setBackgroundColor(color_table[DEFAULT_BACK_COLOR].color); | 157 | if (!pm) setBackgroundColor(color_table[DEFAULT_BACK_COLOR].color); |
153 | update(); | 158 | update(); |
154 | } | 159 | } |
155 | 160 | ||
156 | //FIXME: add backgroundPixmapChanged. | 161 | //FIXME: add backgroundPixmapChanged. |
157 | 162 | ||
158 | /* ------------------------------------------------------------------------- */ | 163 | /* ------------------------------------------------------------------------- */ |
159 | /* */ | 164 | /* */ |
160 | /* Font */ | 165 | /* Font */ |
161 | /* */ | 166 | /* */ |
162 | /* ------------------------------------------------------------------------- */ | 167 | /* ------------------------------------------------------------------------- */ |
163 | 168 | ||
@@ -219,64 +224,63 @@ static QChar vt100extended(QChar c) | |||
219 | case 0x00a3 : return 30; | 224 | case 0x00a3 : return 30; |
220 | case 0x00b7 : return 31; | 225 | case 0x00b7 : return 31; |
221 | } | 226 | } |
222 | return c; | 227 | return c; |
223 | } | 228 | } |
224 | 229 | ||
225 | static QChar identicalMap(QChar c) | 230 | static QChar identicalMap(QChar c) |
226 | { | 231 | { |
227 | return c; | 232 | return c; |
228 | } | 233 | } |
229 | 234 | ||
230 | void TEWidget::fontChange(const QFont &) | 235 | void TEWidget::fontChange(const QFont &) |
231 | { | 236 | { |
232 | QFontMetrics fm(font()); | 237 | QFontMetrics fm(font()); |
233 | font_h = fm.height(); | 238 | font_h = fm.height(); |
234 | font_w = fm.maxWidth(); | 239 | font_w = fm.maxWidth(); |
235 | font_a = fm.ascent(); | 240 | font_a = fm.ascent(); |
236 | //printf("font_h: %d\n",font_h); | 241 | //printf("font_h: %d\n",font_h); |
237 | //printf("font_w: %d\n",font_w); | 242 | //printf("font_w: %d\n",font_w); |
238 | //printf("font_a: %d\n",font_a); | 243 | //printf("font_a: %d\n",font_a); |
239 | //printf("charset: %s\n",QFont::encodingName(font().charSet()).ascii()); | 244 | //printf("charset: %s\n",QFont::encodingName(font().charSet()).ascii()); |
240 | //printf("rawname: %s\n",font().rawName().ascii()); | 245 | //printf("rawname: %s\n",font().rawName().ascii()); |
241 | fontMap = | 246 | fontMap = |
242 | #if QT_VERSION < 300 | 247 | #if QT_VERSION < 300 |
243 | strcmp(QFont::encodingName(font().charSet()).ascii(),"iso10646") | 248 | strcmp(QFont::encodingName(font().charSet()).ascii(),"iso10646") |
244 | ? vt100extended | 249 | ? vt100extended |
245 | : | 250 | : |
246 | #endif | 251 | #endif |
247 | identicalMap; | 252 | identicalMap; |
248 | propagateSize(); | 253 | propagateSize(); |
249 | update(); | 254 | update(); |
250 | } | 255 | } |
251 | 256 | ||
252 | void TEWidget::setVTFont(const QFont& f) | 257 | void TEWidget::setVTFont(const QFont& f) |
253 | { | 258 | { |
254 | QFrame::setFont(f); | 259 | QFrame::setFont(f); |
255 | } | 260 | } |
256 | 261 | ||
257 | QFont TEWidget::getVTFont() | 262 | QFont TEWidget::getVTFont() { |
258 | { | ||
259 | return font(); | 263 | return font(); |
260 | } | 264 | } |
261 | 265 | ||
262 | void TEWidget::setFont(const QFont &) | 266 | void TEWidget::setFont(const QFont &) |
263 | { | 267 | { |
264 | // ignore font change request if not coming from konsole itself | 268 | // ignore font change request if not coming from konsole itself |
265 | } | 269 | } |
266 | 270 | ||
267 | /* ------------------------------------------------------------------------- */ | 271 | /* ------------------------------------------------------------------------- */ |
268 | /* */ | 272 | /* */ |
269 | /* Constructor / Destructor */ | 273 | /* Constructor / Destructor */ |
270 | /* */ | 274 | /* */ |
271 | /* ------------------------------------------------------------------------- */ | 275 | /* ------------------------------------------------------------------------- */ |
272 | 276 | ||
273 | TEWidget::TEWidget(QWidget *parent, const char *name) : QFrame(parent,name) | 277 | TEWidget::TEWidget(QWidget *parent, const char *name) : QFrame(parent,name) |
274 | { | 278 | { |
275 | #ifndef QT_NO_CLIPBOARD | 279 | #ifndef QT_NO_CLIPBOARD |
276 | cb = QApplication::clipboard(); | 280 | cb = QApplication::clipboard(); |
277 | QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), | 281 | QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), |
278 | this, SLOT(onClearSelection()) ); | 282 | this, SLOT(onClearSelection()) ); |
279 | #endif | 283 | #endif |
280 | 284 | ||
281 | scrollbar = new QScrollBar(this); | 285 | scrollbar = new QScrollBar(this); |
282 | scrollbar->setCursor( arrowCursor ); | 286 | scrollbar->setCursor( arrowCursor ); |
@@ -626,49 +630,49 @@ void TEWidget::setScrollbarLocation(int loc) | |||
626 | */ | 630 | */ |
627 | 631 | ||
628 | void TEWidget::mousePressEvent(QMouseEvent* ev) | 632 | void TEWidget::mousePressEvent(QMouseEvent* ev) |
629 | { | 633 | { |
630 | //printf("press [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button()); | 634 | //printf("press [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button()); |
631 | if ( !contentsRect().contains(ev->pos()) ) return; | 635 | if ( !contentsRect().contains(ev->pos()) ) return; |
632 | QPoint tL = contentsRect().topLeft(); | 636 | QPoint tL = contentsRect().topLeft(); |
633 | int tLx = tL.x(); | 637 | int tLx = tL.x(); |
634 | int tLy = tL.y(); | 638 | int tLy = tL.y(); |
635 | 639 | ||
636 | word_selection_mode = FALSE; | 640 | word_selection_mode = FALSE; |
637 | 641 | ||
638 | //printf("press top left [%d,%d] by=%d\n",tLx,tLy, bY); | 642 | //printf("press top left [%d,%d] by=%d\n",tLx,tLy, bY); |
639 | if ( ev->button() == LeftButton) | 643 | if ( ev->button() == LeftButton) |
640 | { | 644 | { |
641 | QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); | 645 | QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); |
642 | 646 | ||
643 | if ( ev->state() & ControlButton ) preserve_line_breaks = FALSE ; | 647 | if ( ev->state() & ControlButton ) preserve_line_breaks = FALSE ; |
644 | 648 | ||
645 | if (mouse_marks || (ev->state() & ShiftButton)) | 649 | if (mouse_marks || (ev->state() & ShiftButton)) |
646 | { | 650 | { |
647 | emit clearSelectionSignal(); | 651 | emit clearSelectionSignal(); |
648 | iPntSel = pntSel = pos; | 652 | iPntSel = pntSel = pos; |
649 | actSel = 1; // left mouse button pressed but nothing selected yet. | 653 | actSel = 1; // left mouse button pressed but nothing selected yet. |
650 | grabMouse( /*crossCursor*/ ); // handle with care! | 654 | grabMouse( /*crossCursor*/ ); // handle with care! |
651 | } | 655 | } |
652 | else | 656 | else |
653 | { | 657 | { |
654 | emit mouseSignal( 0, pos.x() + 1, pos.y() + 1 ); // left button | 658 | emit mouseSignal( 0, pos.x() + 1, pos.y() + 1 ); // left button |
655 | } | 659 | } |
656 | } | 660 | } |
657 | if ( ev->button() == MidButton ) | 661 | if ( ev->button() == MidButton ) |
658 | { | 662 | { |
659 | emitSelection(); | 663 | emitSelection(); |
660 | } | 664 | } |
661 | if ( ev->button() == RightButton ) // Configure | 665 | if ( ev->button() == RightButton ) // Configure |
662 | { | 666 | { |
663 | emit configureRequest( this, ev->state()&(ShiftButton|ControlButton), ev->x(), ev->y() ); | 667 | emit configureRequest( this, ev->state()&(ShiftButton|ControlButton), ev->x(), ev->y() ); |
664 | } | 668 | } |
665 | } | 669 | } |
666 | 670 | ||
667 | void TEWidget::mouseMoveEvent(QMouseEvent* ev) | 671 | void TEWidget::mouseMoveEvent(QMouseEvent* ev) |
668 | { | 672 | { |
669 | // for auto-hiding the cursor, we need mouseTracking | 673 | // for auto-hiding the cursor, we need mouseTracking |
670 | if (ev->state() == NoButton ) return; | 674 | if (ev->state() == NoButton ) return; |
671 | 675 | ||
672 | if (actSel == 0) return; | 676 | if (actSel == 0) return; |
673 | 677 | ||
674 | // don't extend selection while pasting | 678 | // don't extend selection while pasting |
@@ -692,51 +696,51 @@ void TEWidget::mouseMoveEvent(QMouseEvent* ev) | |||
692 | if ( pos.y() > tLy+bY+lines*font_h-1 ) pos.setY( tLy+bY+lines*font_h-1 ); | 696 | if ( pos.y() > tLy+bY+lines*font_h-1 ) pos.setY( tLy+bY+lines*font_h-1 ); |
693 | // check if we produce a mouse move event by this | 697 | // check if we produce a mouse move event by this |
694 | if ( pos != ev->pos() ) cursor().setPos(mapToGlobal(pos)); | 698 | if ( pos != ev->pos() ) cursor().setPos(mapToGlobal(pos)); |
695 | 699 | ||
696 | if ( pos.y() == tLy+bY+lines*font_h-1 ) | 700 | if ( pos.y() == tLy+bY+lines*font_h-1 ) |
697 | { | 701 | { |
698 | scrollbar->setValue(scrollbar->value()+yMouseScroll); // scrollforward | 702 | scrollbar->setValue(scrollbar->value()+yMouseScroll); // scrollforward |
699 | } | 703 | } |
700 | if ( pos.y() == tLy+bY ) | 704 | if ( pos.y() == tLy+bY ) |
701 | { | 705 | { |
702 | scrollbar->setValue(scrollbar->value()-yMouseScroll); // scrollback | 706 | scrollbar->setValue(scrollbar->value()-yMouseScroll); // scrollback |
703 | } | 707 | } |
704 | 708 | ||
705 | QPoint here = QPoint((pos.x()-tLx-blX)/font_w,(pos.y()-tLy-bY)/font_h); | 709 | QPoint here = QPoint((pos.x()-tLx-blX)/font_w,(pos.y()-tLy-bY)/font_h); |
706 | QPoint ohere; | 710 | QPoint ohere; |
707 | bool swapping = FALSE; | 711 | bool swapping = FALSE; |
708 | 712 | ||
709 | if ( word_selection_mode ) | 713 | if ( word_selection_mode ) |
710 | { | 714 | { |
711 | // Extend to word boundaries | 715 | // Extend to word boundaries |
712 | int i; | 716 | int i; |
713 | int selClass; | 717 | int selClass; |
714 | 718 | ||
715 | bool left_not_right = ( here.y() < iPntSel.y() || | 719 | bool left_not_right = ( here.y() < iPntSel.y() || |
716 | here.y() == iPntSel.y() && here.x() < iPntSel.x() ); | 720 | here.y() == iPntSel.y() && here.x() < iPntSel.x() ); |
717 | bool old_left_not_right = ( pntSel.y() < iPntSel.y() || | 721 | bool old_left_not_right = ( pntSel.y() < iPntSel.y() || |
718 | pntSel.y() == iPntSel.y() && pntSel.x() < iPntSel.x() ); | 722 | pntSel.y() == iPntSel.y() && pntSel.x() < iPntSel.x() ); |
719 | swapping = left_not_right != old_left_not_right; | 723 | swapping = left_not_right != old_left_not_right; |
720 | 724 | ||
721 | // Find left (left_not_right ? from here : from start) | 725 | // Find left (left_not_right ? from here : from start) |
722 | QPoint left = left_not_right ? here : iPntSel; | 726 | QPoint left = left_not_right ? here : iPntSel; |
723 | i = loc(left.x(),left.y()); | 727 | i = loc(left.x(),left.y()); |
724 | selClass = charClass(image[i].c); | 728 | selClass = charClass(image[i].c); |
725 | while ( left.x() > 0 && charClass(image[i-1].c) == selClass ) | 729 | while ( left.x() > 0 && charClass(image[i-1].c) == selClass ) |
726 | { i--; left.rx()--; } | 730 | { i--; left.rx()--; } |
727 | 731 | ||
728 | // Find left (left_not_right ? from start : from here) | 732 | // Find left (left_not_right ? from start : from here) |
729 | QPoint right = left_not_right ? iPntSel : here; | 733 | QPoint right = left_not_right ? iPntSel : here; |
730 | i = loc(right.x(),right.y()); | 734 | i = loc(right.x(),right.y()); |
731 | selClass = charClass(image[i].c); | 735 | selClass = charClass(image[i].c); |
732 | while ( right.x() < columns-1 && charClass(image[i+1].c) == selClass ) | 736 | while ( right.x() < columns-1 && charClass(image[i+1].c) == selClass ) |
733 | { i++; right.rx()++; } | 737 | { i++; right.rx()++; } |
734 | 738 | ||
735 | // Pick which is start (ohere) and which is extension (here) | 739 | // Pick which is start (ohere) and which is extension (here) |
736 | if ( left_not_right ) | 740 | if ( left_not_right ) |
737 | { | 741 | { |
738 | here = left; ohere = right; | 742 | here = left; ohere = right; |
739 | } | 743 | } |
740 | else | 744 | else |
741 | { | 745 | { |
742 | here = right; ohere = left; | 746 | here = right; ohere = left; |
@@ -954,76 +958,76 @@ void TEWidget::doScroll(int lines) | |||
954 | scrollbar->setValue(scrollbar->value()+lines); | 958 | scrollbar->setValue(scrollbar->value()+lines); |
955 | } | 959 | } |
956 | 960 | ||
957 | bool TEWidget::eventFilter( QObject *obj, QEvent *e ) | 961 | bool TEWidget::eventFilter( QObject *obj, QEvent *e ) |
958 | { | 962 | { |
959 | if ( (e->type() == QEvent::Accel || | 963 | if ( (e->type() == QEvent::Accel || |
960 | e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) | 964 | e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) |
961 | { | 965 | { |
962 | static_cast<QKeyEvent *>( e )->ignore(); | 966 | static_cast<QKeyEvent *>( e )->ignore(); |
963 | return true; | 967 | return true; |
964 | } | 968 | } |
965 | if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ ) | 969 | if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ ) |
966 | return FALSE; // not us | 970 | return FALSE; // not us |
967 | if ( e->type() == QEvent::Wheel) | 971 | if ( e->type() == QEvent::Wheel) |
968 | { | 972 | { |
969 | QApplication::sendEvent(scrollbar, e); | 973 | QApplication::sendEvent(scrollbar, e); |
970 | } | 974 | } |
971 | 975 | ||
972 | #ifdef FAKE_CTRL_AND_ALT | 976 | #ifdef FAKE_CTRL_AND_ALT |
973 | static bool control = FALSE; | 977 | static bool control = FALSE; |
974 | static bool alt = FALSE; | 978 | static bool alt = FALSE; |
975 | // Has a keyboard with no CTRL and ALT keys, but we fake it: | 979 | // Has a keyboard with no CTRL and ALT keys, but we fake it: |
976 | bool dele=FALSE; | 980 | bool dele=FALSE; |
977 | if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { | 981 | if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { |
978 | QKeyEvent* ke = (QKeyEvent*)e; | 982 | QKeyEvent* ke = (QKeyEvent*)e; |
979 | bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat(); | 983 | bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat(); |
980 | switch (ke->key()) { | 984 | switch (ke->key()) { |
981 | case Key_F9: // let this be "Control" | 985 | case Key_F9: // let this be "Control" |
982 | control = keydown; | 986 | control = keydown; |
983 | e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state()); | 987 | e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state()); |
984 | dele=TRUE; | 988 | dele=TRUE; |
985 | break; | 989 | break; |
986 | case Key_F13: // let this be "Alt" | 990 | case Key_F13: // let this be "Alt" |
987 | alt = keydown; | 991 | alt = keydown; |
988 | e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state()); | 992 | e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state()); |
989 | dele=TRUE; | 993 | dele=TRUE; |
990 | break; | 994 | break; |
991 | default: | 995 | default: |
992 | if ( control ) { | 996 | if ( control ) { |
993 | int a = toupper(ke->ascii())-64; | 997 | int a = toupper(ke->ascii())-64; |
994 | if ( a >= 0 && a < ' ' ) { | 998 | if ( a >= 0 && a < ' ' ) { |
995 | e = new QKeyEvent(e->type(), ke->key(), | 999 | e = new QKeyEvent(e->type(), ke->key(), |
996 | a, ke->state()|ControlButton, QChar(a,0)); | 1000 | a, ke->state()|ControlButton, QChar(a,0)); |
997 | dele=TRUE; | 1001 | dele=TRUE; |
998 | } | 1002 | } |
999 | } | 1003 | } |
1000 | if ( alt ) { | 1004 | if ( alt ) { |
1001 | e = new QKeyEvent(e->type(), ke->key(), | 1005 | e = new QKeyEvent(e->type(), ke->key(), |
1002 | ke->ascii(), ke->state()|AltButton, ke->text()); | 1006 | ke->ascii(), ke->state()|AltButton, ke->text()); |
1003 | dele=TRUE; | 1007 | dele=TRUE; |
1004 | } | 1008 | } |
1005 | } | 1009 | } |
1006 | } | 1010 | } |
1007 | #endif | 1011 | #endif |
1008 | 1012 | ||
1009 | if ( e->type() == QEvent::KeyPress ) | 1013 | if ( e->type() == QEvent::KeyPress ) |
1010 | { | 1014 | { |
1011 | QKeyEvent* ke = (QKeyEvent*)e; | 1015 | QKeyEvent* ke = (QKeyEvent*)e; |
1012 | 1016 | ||
1013 | actSel=0; // Key stroke implies a screen update, so TEWidget won't | 1017 | actSel=0; // Key stroke implies a screen update, so TEWidget won't |
1014 | // know where the current selection is. | 1018 | // know where the current selection is. |
1015 | 1019 | ||
1016 | emit keyPressedSignal(ke); // expose | 1020 | emit keyPressedSignal(ke); // expose |
1017 | ke->accept(); | 1021 | ke->accept(); |
1018 | #ifdef FAKE_CTRL_AND_ALT | 1022 | #ifdef FAKE_CTRL_AND_ALT |
1019 | if ( dele ) delete e; | 1023 | if ( dele ) delete e; |
1020 | #endif | 1024 | #endif |
1021 | return true; // stop the event | 1025 | return true; // stop the event |
1022 | } | 1026 | } |
1023 | if ( e->type() == QEvent::Enter ) | 1027 | if ( e->type() == QEvent::Enter ) |
1024 | { | 1028 | { |
1025 | QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()), | 1029 | QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()), |
1026 | this, SLOT(onClearSelection()) ); | 1030 | this, SLOT(onClearSelection()) ); |
1027 | } | 1031 | } |
1028 | if ( e->type() == QEvent::Leave ) | 1032 | if ( e->type() == QEvent::Leave ) |
1029 | { | 1033 | { |
@@ -1167,56 +1171,56 @@ void TEWidget::dropEvent(QDropEvent* event) | |||
1167 | 1171 | ||
1168 | if(QUriDrag::decode(event, strlist)) { | 1172 | if(QUriDrag::decode(event, strlist)) { |
1169 | if (strlist.count()) { | 1173 | if (strlist.count()) { |
1170 | for(const char* p = strlist.first(); p; p = strlist.next()) { | 1174 | for(const char* p = strlist.first(); p; p = strlist.next()) { |
1171 | if(file_count++ > 0) { | 1175 | if(file_count++ > 0) { |
1172 | dropText += " "; | 1176 | dropText += " "; |
1173 | bPopup = false; // more than one file, don't popup | 1177 | bPopup = false; // more than one file, don't popup |
1174 | } | 1178 | } |
1175 | 1179 | ||
1176 | /* | 1180 | /* |
1177 | KURL url(p); | 1181 | KURL url(p); |
1178 | if (url.isLocalFile()) { | 1182 | if (url.isLocalFile()) { |
1179 | dropText += url.path(); // local URL : remove protocol | 1183 | dropText += url.path(); // local URL : remove protocol |
1180 | } | 1184 | } |
1181 | else { | 1185 | else { |
1182 | dropText += url.prettyURL(); | 1186 | dropText += url.prettyURL(); |
1183 | bPopup = false; // a non-local file, don't popup | 1187 | bPopup = false; // a non-local file, don't popup |
1184 | } | 1188 | } |
1185 | */ | 1189 | */ |
1186 | 1190 | ||
1187 | } | 1191 | } |
1188 | 1192 | ||
1189 | if (bPopup) | 1193 | if (bPopup) |
1190 | // m_drop->popup(pos() + event->pos()); | 1194 | // m_drop->popup(pos() + event->pos()); |
1191 | m_drop->popup(mapToGlobal(event->pos())); | 1195 | m_drop->popup(mapToGlobal(event->pos())); |
1192 | else | 1196 | else |
1193 | { | 1197 | { |
1194 | if (currentSession) { | 1198 | if (currentSession) { |
1195 | currentSession->getEmulation()->sendString(dropText.local8Bit()); | 1199 | currentSession->getEmulation()->sendString(dropText.local8Bit()); |
1196 | } | 1200 | } |
1197 | // kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; | 1201 | // kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; |
1198 | } | 1202 | } |
1199 | } | 1203 | } |
1200 | } | 1204 | } |
1201 | else if(QTextDrag::decode(event, dropText)) { | 1205 | else if(QTextDrag::decode(event, dropText)) { |
1202 | // kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; | 1206 | // kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; |
1203 | if (currentSession) { | 1207 | if (currentSession) { |
1204 | currentSession->getEmulation()->sendString(dropText.local8Bit()); | 1208 | currentSession->getEmulation()->sendString(dropText.local8Bit()); |
1205 | } | 1209 | } |
1206 | // Paste it | 1210 | // Paste it |
1207 | } | 1211 | } |
1208 | } | 1212 | } |
1209 | #endif | 1213 | #endif |
1210 | 1214 | ||
1211 | 1215 | ||
1212 | void TEWidget::drop_menu_activated(int item) | 1216 | void TEWidget::drop_menu_activated(int item) |
1213 | { | 1217 | { |
1214 | #ifndef QT_NO_DRAGANDDROP | 1218 | #ifndef QT_NO_DRAGANDDROP |
1215 | switch (item) | 1219 | switch (item) |
1216 | { | 1220 | { |
1217 | case 0: // paste | 1221 | case 0: // paste |
1218 | currentSession->getEmulation()->sendString(dropText.local8Bit()); | 1222 | currentSession->getEmulation()->sendString(dropText.local8Bit()); |
1219 | // KWM::activate((Window)this->winId()); | 1223 | // KWM::activate((Window)this->winId()); |
1220 | break; | 1224 | break; |
1221 | case 1: // cd ... | 1225 | case 1: // cd ... |
1222 | currentSession->getEmulation()->sendString("cd "); | 1226 | currentSession->getEmulation()->sendString("cd "); |