author | llornkcor <llornkcor> | 2002-02-03 15:33:27 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-02-03 15:33:27 (UTC) |
commit | b7426bf997b8201667cecb0f66470e257b35ba60 (patch) (unidiff) | |
tree | 69ac9d9afd7be78aa7e421e0ee103d4eeec5138f | |
parent | a80b4c11934b93b3d067f812a68452617f202e61 (diff) | |
download | opie-b7426bf997b8201667cecb0f66470e257b35ba60.zip opie-b7426bf997b8201667cecb0f66470e257b35ba60.tar.gz opie-b7426bf997b8201667cecb0f66470e257b35ba60.tar.bz2 |
re-introduced vert scrollbar, with position options
-rw-r--r-- | core/apps/embeddedkonsole/TEWidget.cpp | 20 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/konsole.cpp | 31 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/konsole.h | 4 |
3 files changed, 49 insertions, 6 deletions
diff --git a/core/apps/embeddedkonsole/TEWidget.cpp b/core/apps/embeddedkonsole/TEWidget.cpp index f10bfb2..a56dc50 100644 --- a/core/apps/embeddedkonsole/TEWidget.cpp +++ b/core/apps/embeddedkonsole/TEWidget.cpp | |||
@@ -1,1247 +1,1261 @@ | |||
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 | /*! \class TEWidget | 18 | /*! \class TEWidget |
19 | 19 | ||
20 | \brief Visible screen contents | 20 | \brief Visible screen contents |
21 | 21 | ||
22 | 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 |
23 | 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 |
24 | 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 |
25 | emulation, it simply work within the terminal emulation framework by exposing | 25 | emulation, it simply work within the terminal emulation framework by exposing |
26 | 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. |
27 | 27 | ||
28 | <ul> | 28 | <ul> |
29 | <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) |
30 | <li> The external image used in setImage can have any size. | 30 | <li> The external image used in setImage can have any size. |
31 | <li> (internally) the external image is simply copied to the internal | 31 | <li> (internally) the external image is simply copied to the internal |
32 | when a setImage happens. During a resizeEvent no painting is done | 32 | when a setImage happens. During a resizeEvent no painting is done |
33 | a paintEvent is expected to follow anyway. | 33 | a paintEvent is expected to follow anyway. |
34 | </ul> | 34 | </ul> |
35 | 35 | ||
36 | \sa TEScreen \sa Emulation | 36 | \sa TEScreen \sa Emulation |
37 | */ | 37 | */ |
38 | 38 | ||
39 | /* FIXME: | 39 | /* FIXME: |
40 | - '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 |
41 | - 'font_a' not used in mouse events | 41 | - 'font_a' not used in mouse events |
42 | - add destructor | 42 | - add destructor |
43 | */ | 43 | */ |
44 | 44 | ||
45 | /* TODO | 45 | /* TODO |
46 | - evtl. be sensitive to `paletteChange' while using default colors. | 46 | - evtl. be sensitive to `paletteChange' while using default colors. |
47 | - set different 'rounding' styles? I.e. have a mode to show clipped chars? | 47 | - set different 'rounding' styles? I.e. have a mode to show clipped chars? |
48 | */ | 48 | */ |
49 | 49 | ||
50 | // #include "config.h" | 50 | // #include "config.h" |
51 | #include "TEWidget.h" | 51 | #include "TEWidget.h" |
52 | #include "session.h" | 52 | #include "session.h" |
53 | #include <qpe/config.h> | ||
53 | 54 | ||
54 | #include <qcursor.h> | 55 | #include <qcursor.h> |
55 | #include <qregexp.h> | 56 | #include <qregexp.h> |
56 | #include <qpainter.h> | 57 | #include <qpainter.h> |
57 | #include <qclipboard.h> | 58 | #include <qclipboard.h> |
58 | #include <qstyle.h> | 59 | #include <qstyle.h> |
59 | #include <qfile.h> | 60 | #include <qfile.h> |
60 | #include <qdragobject.h> | 61 | #include <qdragobject.h> |
61 | 62 | ||
62 | #include <stdio.h> | 63 | #include <stdio.h> |
63 | #include <stdlib.h> | 64 | #include <stdlib.h> |
64 | #include <unistd.h> | 65 | #include <unistd.h> |
65 | #include <ctype.h> | 66 | #include <ctype.h> |
66 | #include <sys/stat.h> | 67 | #include <sys/stat.h> |
67 | #include <sys/types.h> | 68 | #include <sys/types.h> |
68 | #include <signal.h> | 69 | #include <signal.h> |
69 | 70 | ||
70 | #include <assert.h> | 71 | #include <assert.h> |
71 | 72 | ||
72 | // #include "TEWidget.moc" | 73 | // #include "TEWidget.moc" |
73 | //#include <kapp.h> | 74 | //#include <kapp.h> |
74 | //#include <kcursor.h> | 75 | //#include <kcursor.h> |
75 | //#include <kurl.h> | 76 | //#include <kurl.h> |
76 | //#include <kdebug.h> | 77 | //#include <kdebug.h> |
77 | //#include <klocale.h> | 78 | //#include <klocale.h> |
78 | 79 | ||
79 | #define HERE printf("%s(%d): %s\n",__FILE__,__LINE__,__FUNCTION__) | 80 | #define HERE printf("%s(%d): %s\n",__FILE__,__LINE__,__FUNCTION__) |
80 | #define HCNT(Name) // { static int cnt = 1; printf("%s(%d): %s %d\n",__FILE__,__LINE__,Name,cnt++); } | 81 | #define HCNT(Name) // { static int cnt = 1; printf("%s(%d): %s %d\n",__FILE__,__LINE__,Name,cnt++); } |
81 | 82 | ||
82 | #define loc(X,Y) ((Y)*columns+(X)) | 83 | #define loc(X,Y) ((Y)*columns+(X)) |
83 | 84 | ||
84 | //FIXME: the rim should normally be 1, 0 only when running in full screen mode. | 85 | //FIXME: the rim should normally be 1, 0 only when running in full screen mode. |
85 | #define rimX 0 // left/right rim width | 86 | #define rimX 0 // left/right rim width |
86 | #define rimY 0 // top/bottom rim high | 87 | #define rimY 0 // top/bottom rim high |
87 | 88 | ||
88 | #define SCRWIDTH 16 // width of the scrollbar | 89 | #define SCRWIDTH 16 // width of the scrollbar |
89 | 90 | ||
90 | #define yMouseScroll 1 | 91 | #define yMouseScroll 1 |
91 | // scroll increment used when dragging selection at top/bottom of window. | 92 | // scroll increment used when dragging selection at top/bottom of window. |
92 | 93 | ||
93 | /* ------------------------------------------------------------------------- */ | 94 | /* ------------------------------------------------------------------------- */ |
94 | /* */ | 95 | /* */ |
95 | /* Colors */ | 96 | /* Colors */ |
96 | /* */ | 97 | /* */ |
97 | /* ------------------------------------------------------------------------- */ | 98 | /* ------------------------------------------------------------------------- */ |
98 | 99 | ||
99 | //FIXME: the default color table is in session.C now. | 100 | //FIXME: the default color table is in session.C now. |
100 | // We need a way to get rid of this one, here. | 101 | // We need a way to get rid of this one, here. |
101 | static const ColorEntry base_color_table[TABLE_COLORS] = | 102 | static const ColorEntry base_color_table[TABLE_COLORS] = |
102 | // The following are almost IBM standard color codes, with some slight | 103 | // The following are almost IBM standard color codes, with some slight |
103 | // gamma correction for the dim colors to compensate for bright X screens. | 104 | // gamma correction for the dim colors to compensate for bright X screens. |
104 | // It contains the 8 ansiterm/xterm colors in 2 intensities. | 105 | // It contains the 8 ansiterm/xterm colors in 2 intensities. |
105 | { | 106 | { |
106 | // Fixme: could add faint colors here, also. | 107 | // Fixme: could add faint colors here, also. |
107 | // normal | 108 | // normal |
108 | ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 1, 0 ), // Dfore, Dback | 109 | ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 1, 0 ), // Dfore, Dback |
109 | ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0x18), 0, 0 ), // Black, Red | 110 | ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0x18), 0, 0 ), // Black, Red |
110 | ColorEntry(QColor(0x18,0xB2,0x18), 0, 0 ), ColorEntry( QColor(0xB2,0x68,0x18), 0, 0 ), // Green, Yellow | 111 | ColorEntry(QColor(0x18,0xB2,0x18), 0, 0 ), ColorEntry( QColor(0xB2,0x68,0x18), 0, 0 ), // Green, Yellow |
111 | ColorEntry(QColor(0x18,0x18,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), // Blue, Magenta | 112 | ColorEntry(QColor(0x18,0x18,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), // Blue, Magenta |
112 | ColorEntry(QColor(0x18,0xB2,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 0, 0 ), // Cyan, White | 113 | ColorEntry(QColor(0x18,0xB2,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 0, 0 ), // Cyan, White |
113 | // intensiv | 114 | // intensiv |
114 | ColorEntry(QColor(0x00,0x00,0x00), 0, 1 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 1, 0 ), | 115 | ColorEntry(QColor(0x00,0x00,0x00), 0, 1 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 1, 0 ), |
115 | ColorEntry(QColor(0x68,0x68,0x68), 0, 0 ), ColorEntry( QColor(0xFF,0x54,0x54), 0, 0 ), | 116 | ColorEntry(QColor(0x68,0x68,0x68), 0, 0 ), ColorEntry( QColor(0xFF,0x54,0x54), 0, 0 ), |
116 | ColorEntry(QColor(0x54,0xFF,0x54), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0x54), 0, 0 ), | 117 | ColorEntry(QColor(0x54,0xFF,0x54), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0x54), 0, 0 ), |
117 | ColorEntry(QColor(0x54,0x54,0xFF), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), | 118 | ColorEntry(QColor(0x54,0x54,0xFF), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), |
118 | ColorEntry(QColor(0x54,0xFF,0xFF), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 0, 0 ) | 119 | ColorEntry(QColor(0x54,0xFF,0xFF), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 0, 0 ) |
119 | }; | 120 | }; |
120 | 121 | ||
121 | /* Note that we use ANSI color order (bgr), while IBMPC color order is (rgb) | 122 | /* Note that we use ANSI color order (bgr), while IBMPC color order is (rgb) |
122 | 123 | ||
123 | Code 0 1 2 3 4 5 6 7 | 124 | Code 0 1 2 3 4 5 6 7 |
124 | ----------- ------- ------- ------- ------- ------- ------- ------- ------- | 125 | ----------- ------- ------- ------- ------- ------- ------- ------- ------- |
125 | ANSI (bgr) Black Red Green Yellow Blue Magenta Cyan White | 126 | ANSI (bgr) Black Red Green Yellow Blue Magenta Cyan White |
126 | IBMPC (rgb) Black Blue Green Cyan Red Magenta Yellow White | 127 | IBMPC (rgb) Black Blue Green Cyan Red Magenta Yellow White |
127 | */ | 128 | */ |
128 | 129 | ||
129 | QColor TEWidget::getDefaultBackColor() | 130 | QColor TEWidget::getDefaultBackColor() |
130 | { | 131 | { |
131 | return color_table[DEFAULT_BACK_COLOR].color; | 132 | return color_table[DEFAULT_BACK_COLOR].color; |
132 | } | 133 | } |
133 | 134 | ||
134 | const ColorEntry* TEWidget::getColorTable() const | 135 | const ColorEntry* TEWidget::getColorTable() const |
135 | { | 136 | { |
136 | return color_table; | 137 | return color_table; |
137 | } | 138 | } |
138 | 139 | ||
139 | const ColorEntry* TEWidget::getdefaultColorTable() const | 140 | const ColorEntry* TEWidget::getdefaultColorTable() const |
140 | { | 141 | { |
141 | return base_color_table; | 142 | return base_color_table; |
142 | } | 143 | } |
143 | 144 | ||
144 | 145 | ||
145 | const QPixmap *TEWidget::backgroundPixmap() | 146 | const QPixmap *TEWidget::backgroundPixmap() |
146 | { | 147 | { |
147 | static QPixmap *bg = new QPixmap("~/qpim/main/pics/faded_bg.xpm"); | 148 | static QPixmap *bg = new QPixmap("~/qpim/main/pics/faded_bg.xpm"); |
148 | const QPixmap *pm = bg; | 149 | const QPixmap *pm = bg; |
149 | return pm; | 150 | return pm; |
150 | } | 151 | } |
151 | 152 | ||
152 | void TEWidget::setColorTable(const ColorEntry table[]) | 153 | void TEWidget::setColorTable(const ColorEntry table[]) |
153 | { | 154 | { |
154 | for (int i = 0; i < TABLE_COLORS; i++) color_table[i] = table[i]; | 155 | for (int i = 0; i < TABLE_COLORS; i++) color_table[i] = table[i]; |
155 | 156 | ||
156 | const QPixmap* pm = backgroundPixmap(); | 157 | const QPixmap* pm = backgroundPixmap(); |
157 | if (!pm) setBackgroundColor(color_table[DEFAULT_BACK_COLOR].color); | 158 | if (!pm) setBackgroundColor(color_table[DEFAULT_BACK_COLOR].color); |
158 | update(); | 159 | update(); |
159 | } | 160 | } |
160 | 161 | ||
161 | //FIXME: add backgroundPixmapChanged. | 162 | //FIXME: add backgroundPixmapChanged. |
162 | 163 | ||
163 | /* ------------------------------------------------------------------------- */ | 164 | /* ------------------------------------------------------------------------- */ |
164 | /* */ | 165 | /* */ |
165 | /* Font */ | 166 | /* Font */ |
166 | /* */ | 167 | /* */ |
167 | /* ------------------------------------------------------------------------- */ | 168 | /* ------------------------------------------------------------------------- */ |
168 | 169 | ||
169 | /* | 170 | /* |
170 | The VT100 has 32 special graphical characters. The usual vt100 extended | 171 | The VT100 has 32 special graphical characters. The usual vt100 extended |
171 | xterm fonts have these at 0x00..0x1f. | 172 | xterm fonts have these at 0x00..0x1f. |
172 | 173 | ||
173 | QT's iso mapping leaves 0x00..0x7f without any changes. But the graphicals | 174 | QT's iso mapping leaves 0x00..0x7f without any changes. But the graphicals |
174 | come in here as proper unicode characters. | 175 | come in here as proper unicode characters. |
175 | 176 | ||
176 | We treat non-iso10646 fonts as VT100 extended and do the requiered mapping | 177 | We treat non-iso10646 fonts as VT100 extended and do the requiered mapping |
177 | from unicode to 0x00..0x1f. The remaining translation is then left to the | 178 | from unicode to 0x00..0x1f. The remaining translation is then left to the |
178 | QCodec. | 179 | QCodec. |
179 | */ | 180 | */ |
180 | 181 | ||
181 | // assert for i in [0..31] : vt100extended(vt100_graphics[i]) == i. | 182 | // assert for i in [0..31] : vt100extended(vt100_graphics[i]) == i. |
182 | 183 | ||
183 | unsigned short vt100_graphics[32] = | 184 | unsigned short vt100_graphics[32] = |
184 | { // 0/8 1/9 2/10 3/11 4/12 5/13 6/14 7/15 | 185 | { // 0/8 1/9 2/10 3/11 4/12 5/13 6/14 7/15 |
185 | 0x0020, 0x25C6, 0x2592, 0x2409, 0x240c, 0x240d, 0x240a, 0x00b0, | 186 | 0x0020, 0x25C6, 0x2592, 0x2409, 0x240c, 0x240d, 0x240a, 0x00b0, |
186 | 0x00b1, 0x2424, 0x240b, 0x2518, 0x2510, 0x250c, 0x2514, 0x253c, | 187 | 0x00b1, 0x2424, 0x240b, 0x2518, 0x2510, 0x250c, 0x2514, 0x253c, |
187 | 0xF800, 0xF801, 0x2500, 0xF803, 0xF804, 0x251c, 0x2524, 0x2534, | 188 | 0xF800, 0xF801, 0x2500, 0xF803, 0xF804, 0x251c, 0x2524, 0x2534, |
188 | 0x252c, 0x2502, 0x2264, 0x2265, 0x03C0, 0x2260, 0x00A3, 0x00b7 | 189 | 0x252c, 0x2502, 0x2264, 0x2265, 0x03C0, 0x2260, 0x00A3, 0x00b7 |
189 | }; | 190 | }; |
190 | 191 | ||
191 | static QChar vt100extended(QChar c) | 192 | static QChar vt100extended(QChar c) |
192 | { | 193 | { |
193 | switch (c.unicode()) | 194 | switch (c.unicode()) |
194 | { | 195 | { |
195 | case 0x25c6 : return 1; | 196 | case 0x25c6 : return 1; |
196 | case 0x2592 : return 2; | 197 | case 0x2592 : return 2; |
197 | case 0x2409 : return 3; | 198 | case 0x2409 : return 3; |
198 | case 0x240c : return 4; | 199 | case 0x240c : return 4; |
199 | case 0x240d : return 5; | 200 | case 0x240d : return 5; |
200 | case 0x240a : return 6; | 201 | case 0x240a : return 6; |
201 | case 0x00b0 : return 7; | 202 | case 0x00b0 : return 7; |
202 | case 0x00b1 : return 8; | 203 | case 0x00b1 : return 8; |
203 | case 0x2424 : return 9; | 204 | case 0x2424 : return 9; |
204 | case 0x240b : return 10; | 205 | case 0x240b : return 10; |
205 | case 0x2518 : return 11; | 206 | case 0x2518 : return 11; |
206 | case 0x2510 : return 12; | 207 | case 0x2510 : return 12; |
207 | case 0x250c : return 13; | 208 | case 0x250c : return 13; |
208 | case 0x2514 : return 14; | 209 | case 0x2514 : return 14; |
209 | case 0x253c : return 15; | 210 | case 0x253c : return 15; |
210 | case 0xf800 : return 16; | 211 | case 0xf800 : return 16; |
211 | case 0xf801 : return 17; | 212 | case 0xf801 : return 17; |
212 | case 0x2500 : return 18; | 213 | case 0x2500 : return 18; |
213 | case 0xf803 : return 19; | 214 | case 0xf803 : return 19; |
214 | case 0xf804 : return 20; | 215 | case 0xf804 : return 20; |
215 | case 0x251c : return 21; | 216 | case 0x251c : return 21; |
216 | case 0x2524 : return 22; | 217 | case 0x2524 : return 22; |
217 | case 0x2534 : return 23; | 218 | case 0x2534 : return 23; |
218 | case 0x252c : return 24; | 219 | case 0x252c : return 24; |
219 | case 0x2502 : return 25; | 220 | case 0x2502 : return 25; |
220 | case 0x2264 : return 26; | 221 | case 0x2264 : return 26; |
221 | case 0x2265 : return 27; | 222 | case 0x2265 : return 27; |
222 | case 0x03c0 : return 28; | 223 | case 0x03c0 : return 28; |
223 | case 0x2260 : return 29; | 224 | case 0x2260 : return 29; |
224 | case 0x00a3 : return 30; | 225 | case 0x00a3 : return 30; |
225 | case 0x00b7 : return 31; | 226 | case 0x00b7 : return 31; |
226 | } | 227 | } |
227 | return c; | 228 | return c; |
228 | } | 229 | } |
229 | 230 | ||
230 | static QChar identicalMap(QChar c) | 231 | static QChar identicalMap(QChar c) |
231 | { | 232 | { |
232 | return c; | 233 | return c; |
233 | } | 234 | } |
234 | 235 | ||
235 | void TEWidget::fontChange(const QFont &) | 236 | void TEWidget::fontChange(const QFont &) |
236 | { | 237 | { |
237 | QFontMetrics fm(font()); | 238 | QFontMetrics fm(font()); |
238 | font_h = fm.height(); | 239 | font_h = fm.height(); |
239 | font_w = fm.maxWidth(); | 240 | font_w = fm.maxWidth(); |
240 | font_a = fm.ascent(); | 241 | font_a = fm.ascent(); |
241 | //printf("font_h: %d\n",font_h); | 242 | //printf("font_h: %d\n",font_h); |
242 | //printf("font_w: %d\n",font_w); | 243 | //printf("font_w: %d\n",font_w); |
243 | //printf("font_a: %d\n",font_a); | 244 | //printf("font_a: %d\n",font_a); |
244 | //printf("charset: %s\n",QFont::encodingName(font().charSet()).ascii()); | 245 | //printf("charset: %s\n",QFont::encodingName(font().charSet()).ascii()); |
245 | //printf("rawname: %s\n",font().rawName().ascii()); | 246 | //printf("rawname: %s\n",font().rawName().ascii()); |
246 | fontMap = | 247 | fontMap = |
247 | #if QT_VERSION < 300 | 248 | #if QT_VERSION < 300 |
248 | strcmp(QFont::encodingName(font().charSet()).ascii(),"iso10646") | 249 | strcmp(QFont::encodingName(font().charSet()).ascii(),"iso10646") |
249 | ? vt100extended | 250 | ? vt100extended |
250 | : | 251 | : |
251 | #endif | 252 | #endif |
252 | identicalMap; | 253 | identicalMap; |
253 | propagateSize(); | 254 | propagateSize(); |
254 | update(); | 255 | update(); |
255 | } | 256 | } |
256 | 257 | ||
257 | void TEWidget::setVTFont(const QFont& f) | 258 | void TEWidget::setVTFont(const QFont& f) |
258 | { | 259 | { |
259 | QFrame::setFont(f); | 260 | QFrame::setFont(f); |
260 | } | 261 | } |
261 | 262 | ||
262 | QFont TEWidget::getVTFont() { | 263 | QFont TEWidget::getVTFont() { |
263 | return font(); | 264 | return font(); |
264 | } | 265 | } |
265 | 266 | ||
266 | void TEWidget::setFont(const QFont &) | 267 | void TEWidget::setFont(const QFont &) |
267 | { | 268 | { |
268 | // ignore font change request if not coming from konsole itself | 269 | // ignore font change request if not coming from konsole itself |
269 | } | 270 | } |
270 | 271 | ||
271 | /* ------------------------------------------------------------------------- */ | 272 | /* ------------------------------------------------------------------------- */ |
272 | /* */ | 273 | /* */ |
273 | /* Constructor / Destructor */ | 274 | /* Constructor / Destructor */ |
274 | /* */ | 275 | /* */ |
275 | /* ------------------------------------------------------------------------- */ | 276 | /* ------------------------------------------------------------------------- */ |
276 | 277 | ||
277 | TEWidget::TEWidget(QWidget *parent, const char *name) : QFrame(parent,name) | 278 | TEWidget::TEWidget(QWidget *parent, const char *name) : QFrame(parent,name) |
278 | { | 279 | { |
279 | #ifndef QT_NO_CLIPBOARD | 280 | #ifndef QT_NO_CLIPBOARD |
280 | cb = QApplication::clipboard(); | 281 | cb = QApplication::clipboard(); |
281 | QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), | 282 | QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), |
282 | this, SLOT(onClearSelection()) ); | 283 | this, SLOT(onClearSelection()) ); |
283 | #endif | 284 | #endif |
284 | 285 | ||
285 | scrollbar = new QScrollBar(this); | 286 | scrollbar = new QScrollBar(this); |
286 | scrollbar->setCursor( arrowCursor ); | 287 | scrollbar->setCursor( arrowCursor ); |
287 | connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); | 288 | connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); |
288 | scrollLoc = SCRNONE; | 289 | |
290 | Config cfg("Konsole"); | ||
291 | cfg.setGroup("ScrollBar"); | ||
292 | switch( cfg.readNumEntry("Position",2)){ | ||
293 | case 0: | ||
294 | scrollLoc = SCRNONE; | ||
295 | break; | ||
296 | case 1: | ||
297 | scrollLoc = SCRLEFT; | ||
298 | break; | ||
299 | case 2: | ||
300 | scrollLoc = SCRRIGHT; | ||
301 | break; | ||
302 | }; | ||
289 | 303 | ||
290 | blinkT = new QTimer(this); | 304 | blinkT = new QTimer(this); |
291 | connect(blinkT, SIGNAL(timeout()), this, SLOT(blinkEvent())); | 305 | connect(blinkT, SIGNAL(timeout()), this, SLOT(blinkEvent())); |
292 | // blinking = FALSE; | 306 | // blinking = FALSE; |
293 | blinking = TRUE; | 307 | blinking = TRUE; |
294 | 308 | ||
295 | resizing = FALSE; | 309 | resizing = FALSE; |
296 | actSel = 0; | 310 | actSel = 0; |
297 | image = 0; | 311 | image = 0; |
298 | lines = 1; | 312 | lines = 1; |
299 | columns = 1; | 313 | columns = 1; |
300 | font_w = 1; | 314 | font_w = 1; |
301 | font_h = 1; | 315 | font_h = 1; |
302 | font_a = 1; | 316 | font_a = 1; |
303 | word_selection_mode = FALSE; | 317 | word_selection_mode = FALSE; |
304 | 318 | ||
305 | setMouseMarks(TRUE); | 319 | setMouseMarks(TRUE); |
306 | setVTFont( QFont("fixed") ); | 320 | setVTFont( QFont("fixed") ); |
307 | setColorTable(base_color_table); // init color table | 321 | setColorTable(base_color_table); // init color table |
308 | 322 | ||
309 | qApp->installEventFilter( this ); //FIXME: see below | 323 | qApp->installEventFilter( this ); //FIXME: see below |
310 | // KCursor::setAutoHideCursor( this, true ); | 324 | // KCursor::setAutoHideCursor( this, true ); |
311 | 325 | ||
312 | // Init DnD //////////////////////////////////////////////////////////////// | 326 | // Init DnD //////////////////////////////////////////////////////////////// |
313 | currentSession = NULL; | 327 | currentSession = NULL; |
314 | // setAcceptDrops(true); // attempt | 328 | // setAcceptDrops(true); // attempt |
315 | // m_drop = new QPopupMenu(this); | 329 | // m_drop = new QPopupMenu(this); |
316 | // m_drop->insertItem( QString("Paste"), 0); | 330 | // m_drop->insertItem( QString("Paste"), 0); |
317 | // m_drop->insertItem( QString("cd"), 1); | 331 | // m_drop->insertItem( QString("cd"), 1); |
318 | // connect(m_drop, SIGNAL(activated(int)), SLOT(drop_menu_activated(int))); | 332 | // connect(m_drop, SIGNAL(activated(int)), SLOT(drop_menu_activated(int))); |
319 | 333 | ||
320 | // we need focus so that the auto-hide cursor feature works | 334 | // we need focus so that the auto-hide cursor feature works |
321 | setFocus(); | 335 | setFocus(); |
322 | setFocusPolicy( WheelFocus ); | 336 | setFocusPolicy( WheelFocus ); |
323 | } | 337 | } |
324 | 338 | ||
325 | //FIXME: make proper destructor | 339 | //FIXME: make proper destructor |
326 | // Here's a start (David) | 340 | // Here's a start (David) |
327 | TEWidget::~TEWidget() | 341 | TEWidget::~TEWidget() |
328 | { | 342 | { |
329 | qApp->removeEventFilter( this ); | 343 | qApp->removeEventFilter( this ); |
330 | if (image) free(image); | 344 | if (image) free(image); |
331 | } | 345 | } |
332 | 346 | ||
333 | /* ------------------------------------------------------------------------- */ | 347 | /* ------------------------------------------------------------------------- */ |
334 | /* */ | 348 | /* */ |
335 | /* Display Operations */ | 349 | /* Display Operations */ |
336 | /* */ | 350 | /* */ |
337 | /* ------------------------------------------------------------------------- */ | 351 | /* ------------------------------------------------------------------------- */ |
338 | 352 | ||
339 | /*! | 353 | /*! |
340 | attributed string draw primitive | 354 | attributed string draw primitive |
341 | */ | 355 | */ |
342 | 356 | ||
343 | void TEWidget::drawAttrStr(QPainter &paint, QRect rect, | 357 | void TEWidget::drawAttrStr(QPainter &paint, QRect rect, |
344 | QString& str, ca attr, BOOL pm, BOOL clear) | 358 | QString& str, ca attr, BOOL pm, BOOL clear) |
345 | { | 359 | { |
346 | if (pm && color_table[attr.b].transparent) | 360 | if (pm && color_table[attr.b].transparent) |
347 | { | 361 | { |
348 | paint.setBackgroundMode( TransparentMode ); | 362 | paint.setBackgroundMode( TransparentMode ); |
349 | if (clear) erase(rect); | 363 | if (clear) erase(rect); |
350 | } | 364 | } |
351 | else | 365 | else |
352 | { | 366 | { |
353 | if (blinking) | 367 | if (blinking) |
354 | paint.fillRect(rect, color_table[attr.b].color); | 368 | paint.fillRect(rect, color_table[attr.b].color); |
355 | else | 369 | else |
356 | { | 370 | { |
357 | paint.setBackgroundMode( OpaqueMode ); | 371 | paint.setBackgroundMode( OpaqueMode ); |
358 | paint.setBackgroundColor( color_table[attr.b].color ); | 372 | paint.setBackgroundColor( color_table[attr.b].color ); |
359 | } | 373 | } |
360 | } | 374 | } |
361 | 375 | ||
362 | if (color_table[attr.f].bold) | 376 | if (color_table[attr.f].bold) |
363 | paint.setPen(QColor( 0x8F, 0x00, 0x00 )); | 377 | paint.setPen(QColor( 0x8F, 0x00, 0x00 )); |
364 | else | 378 | else |
365 | paint.setPen(color_table[attr.f].color); | 379 | paint.setPen(color_table[attr.f].color); |
366 | 380 | ||
367 | paint.drawText(rect.x(),rect.y()+font_a, str); | 381 | paint.drawText(rect.x(),rect.y()+font_a, str); |
368 | 382 | ||
369 | if (attr.r & RE_UNDERLINE) | 383 | if (attr.r & RE_UNDERLINE) |
370 | paint.drawLine(rect.left(), rect.y()+font_a+1, rect.right(),rect.y()+font_a+1 ); | 384 | paint.drawLine(rect.left(), rect.y()+font_a+1, rect.right(),rect.y()+font_a+1 ); |
371 | } | 385 | } |
372 | 386 | ||
373 | /*! | 387 | /*! |
374 | The image can only be set completely. | 388 | The image can only be set completely. |
375 | 389 | ||
376 | The size of the new image may or may not match the size of the widget. | 390 | The size of the new image may or may not match the size of the widget. |
377 | */ | 391 | */ |
378 | 392 | ||
379 | void TEWidget::setImage(const ca* const newimg, int lines, int columns) | 393 | void TEWidget::setImage(const ca* const newimg, int lines, int columns) |
380 | { int y,x,len; | 394 | { int y,x,len; |
381 | const QPixmap* pm = backgroundPixmap(); | 395 | const QPixmap* pm = backgroundPixmap(); |
382 | QPainter paint; | 396 | QPainter paint; |
383 | setUpdatesEnabled(FALSE); | 397 | setUpdatesEnabled(FALSE); |
384 | paint.begin( this ); | 398 | paint.begin( this ); |
385 | HCNT("setImage"); | 399 | HCNT("setImage"); |
386 | 400 | ||
387 | QPoint tL = contentsRect().topLeft(); | 401 | QPoint tL = contentsRect().topLeft(); |
388 | int tLx = tL.x(); | 402 | int tLx = tL.x(); |
389 | int tLy = tL.y(); | 403 | int tLy = tL.y(); |
390 | hasBlinker = FALSE; | 404 | hasBlinker = FALSE; |
391 | 405 | ||
392 | int cf = -1; // undefined | 406 | int cf = -1; // undefined |
393 | int cb = -1; // undefined | 407 | int cb = -1; // undefined |
394 | int cr = -1; // undefined | 408 | int cr = -1; // undefined |
395 | 409 | ||
396 | int lins = QMIN(this->lines, QMAX(0,lines )); | 410 | int lins = QMIN(this->lines, QMAX(0,lines )); |
397 | int cols = QMIN(this->columns,QMAX(0,columns)); | 411 | int cols = QMIN(this->columns,QMAX(0,columns)); |
398 | QChar *disstrU = new QChar[cols]; | 412 | QChar *disstrU = new QChar[cols]; |
399 | 413 | ||
400 | //{ static int cnt = 0; printf("setImage %d\n",cnt++); } | 414 | //{ static int cnt = 0; printf("setImage %d\n",cnt++); } |
401 | for (y = 0; y < lins; y++) | 415 | for (y = 0; y < lins; y++) |
402 | { | 416 | { |
403 | const ca* lcl = &image[y*this->columns]; | 417 | const ca* lcl = &image[y*this->columns]; |
404 | const ca* const ext = &newimg[y*columns]; | 418 | const ca* const ext = &newimg[y*columns]; |
405 | if (!resizing) // not while resizing, we're expecting a paintEvent | 419 | if (!resizing) // not while resizing, we're expecting a paintEvent |
406 | for (x = 0; x < cols; x++) | 420 | for (x = 0; x < cols; x++) |
407 | { | 421 | { |
408 | hasBlinker |= (ext[x].r & RE_BLINK); | 422 | hasBlinker |= (ext[x].r & RE_BLINK); |
409 | if (ext[x] != lcl[x]) | 423 | if (ext[x] != lcl[x]) |
410 | { | 424 | { |
411 | cr = ext[x].r; | 425 | cr = ext[x].r; |
412 | cb = ext[x].b; | 426 | cb = ext[x].b; |
413 | if (ext[x].f != cf) cf = ext[x].f; | 427 | if (ext[x].f != cf) cf = ext[x].f; |
414 | int lln = cols - x; | 428 | int lln = cols - x; |
415 | disstrU[0] = fontMap(ext[x+0].c); | 429 | disstrU[0] = fontMap(ext[x+0].c); |
416 | for (len = 1; len < lln; len++) | 430 | for (len = 1; len < lln; len++) |
417 | { | 431 | { |
418 | if (ext[x+len].f != cf || ext[x+len].b != cb || ext[x+len].r != cr || | 432 | if (ext[x+len].f != cf || ext[x+len].b != cb || ext[x+len].r != cr || |
419 | ext[x+len] == lcl[x+len] ) | 433 | ext[x+len] == lcl[x+len] ) |
420 | break; | 434 | break; |
421 | disstrU[len] = fontMap(ext[x+len].c); | 435 | disstrU[len] = fontMap(ext[x+len].c); |
422 | } | 436 | } |
423 | QString unistr(disstrU,len); | 437 | QString unistr(disstrU,len); |
424 | drawAttrStr(paint, | 438 | drawAttrStr(paint, |
425 | QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h), | 439 | QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h), |
426 | unistr, ext[x], pm != NULL, true); | 440 | unistr, ext[x], pm != NULL, true); |
427 | x += len - 1; | 441 | x += len - 1; |
428 | } | 442 | } |
429 | } | 443 | } |
430 | // finally, make `image' become `newimg'. | 444 | // finally, make `image' become `newimg'. |
431 | memcpy((void*)lcl,(const void*)ext,cols*sizeof(ca)); | 445 | memcpy((void*)lcl,(const void*)ext,cols*sizeof(ca)); |
432 | } | 446 | } |
433 | drawFrame( &paint ); | 447 | drawFrame( &paint ); |
434 | paint.end(); | 448 | paint.end(); |
435 | setUpdatesEnabled(TRUE); | 449 | setUpdatesEnabled(TRUE); |
436 | if ( hasBlinker && !blinkT->isActive()) blinkT->start(1000); // 1000 ms | 450 | if ( hasBlinker && !blinkT->isActive()) blinkT->start(1000); // 1000 ms |
437 | if (!hasBlinker && blinkT->isActive()) { blinkT->stop(); blinking = FALSE; } | 451 | if (!hasBlinker && blinkT->isActive()) { blinkT->stop(); blinking = FALSE; } |
438 | delete [] disstrU; | 452 | delete [] disstrU; |
439 | } | 453 | } |
440 | 454 | ||
441 | // paint Event //////////////////////////////////////////////////// | 455 | // paint Event //////////////////////////////////////////////////// |
442 | 456 | ||
443 | /*! | 457 | /*! |
444 | The difference of this routine vs. the `setImage' is, | 458 | The difference of this routine vs. the `setImage' is, |
445 | that the drawing does not include a difference analysis | 459 | that the drawing does not include a difference analysis |
446 | between the old and the new image. Instead, the internal | 460 | between the old and the new image. Instead, the internal |
447 | image is used and the painting bound by the PaintEvent box. | 461 | image is used and the painting bound by the PaintEvent box. |
448 | */ | 462 | */ |
449 | 463 | ||
450 | void TEWidget::paintEvent( QPaintEvent* pe ) | 464 | void TEWidget::paintEvent( QPaintEvent* pe ) |
451 | { | 465 | { |
452 | 466 | ||
453 | //{ static int cnt = 0; printf("paint %d\n",cnt++); } | 467 | //{ static int cnt = 0; printf("paint %d\n",cnt++); } |
454 | const QPixmap* pm = backgroundPixmap(); | 468 | const QPixmap* pm = backgroundPixmap(); |
455 | QPainter paint; | 469 | QPainter paint; |
456 | setUpdatesEnabled(FALSE); | 470 | setUpdatesEnabled(FALSE); |
457 | paint.begin( this ); | 471 | paint.begin( this ); |
458 | paint.setBackgroundMode( TransparentMode ); | 472 | paint.setBackgroundMode( TransparentMode ); |
459 | HCNT("paintEvent"); | 473 | HCNT("paintEvent"); |
460 | 474 | ||
461 | // Note that the actual widget size can be slightly larger | 475 | // Note that the actual widget size can be slightly larger |
462 | // that the image (the size is truncated towards the smaller | 476 | // that the image (the size is truncated towards the smaller |
463 | // number of characters in `resizeEvent'. The paint rectangle | 477 | // number of characters in `resizeEvent'. The paint rectangle |
464 | // can thus be larger than the image, but less then the size | 478 | // can thus be larger than the image, but less then the size |
465 | // of one character. | 479 | // of one character. |
466 | 480 | ||
467 | QRect rect = pe->rect().intersect(contentsRect()); | 481 | QRect rect = pe->rect().intersect(contentsRect()); |
468 | 482 | ||
469 | QPoint tL = contentsRect().topLeft(); | 483 | QPoint tL = contentsRect().topLeft(); |
470 | int tLx = tL.x(); | 484 | int tLx = tL.x(); |
471 | int tLy = tL.y(); | 485 | int tLy = tL.y(); |
472 | 486 | ||
473 | int lux = QMIN(columns-1, QMAX(0,(rect.left() - tLx - blX ) / font_w)); | 487 | int lux = QMIN(columns-1, QMAX(0,(rect.left() - tLx - blX ) / font_w)); |
474 | int luy = QMIN(lines-1, QMAX(0,(rect.top() - tLy - bY ) / font_h)); | 488 | int luy = QMIN(lines-1, QMAX(0,(rect.top() - tLy - bY ) / font_h)); |
475 | int rlx = QMIN(columns-1, QMAX(0,(rect.right() - tLx - blX ) / font_w)); | 489 | int rlx = QMIN(columns-1, QMAX(0,(rect.right() - tLx - blX ) / font_w)); |
476 | int rly = QMIN(lines-1, QMAX(0,(rect.bottom() - tLy - bY ) / font_h)); | 490 | int rly = QMIN(lines-1, QMAX(0,(rect.bottom() - tLy - bY ) / font_h)); |
477 | 491 | ||
478 | /* | 492 | /* |
479 | printf("paintEvent: %d..%d, %d..%d (%d..%d, %d..%d)\n",lux,rlx,luy,rly, | 493 | printf("paintEvent: %d..%d, %d..%d (%d..%d, %d..%d)\n",lux,rlx,luy,rly, |
480 | rect.left(), rect.right(), rect.top(), rect.bottom()); | 494 | rect.left(), rect.right(), rect.top(), rect.bottom()); |
481 | */ | 495 | */ |
482 | 496 | ||
483 | // if (pm != NULL && color_table[image->b].transparent) | 497 | // if (pm != NULL && color_table[image->b].transparent) |
484 | // erase(rect); | 498 | // erase(rect); |
485 | // BL: I have no idea why we need this, and it breaks the refresh. | 499 | // BL: I have no idea why we need this, and it breaks the refresh. |
486 | 500 | ||
487 | QChar *disstrU = new QChar[columns]; | 501 | QChar *disstrU = new QChar[columns]; |
488 | for (int y = luy; y <= rly; y++) | 502 | for (int y = luy; y <= rly; y++) |
489 | for (int x = lux; x <= rlx; x++) | 503 | for (int x = lux; x <= rlx; x++) |
490 | { | 504 | { |
491 | int len = 1; | 505 | int len = 1; |
492 | disstrU[0] = fontMap(image[loc(x,y)].c); | 506 | disstrU[0] = fontMap(image[loc(x,y)].c); |
493 | int cf = image[loc(x,y)].f; | 507 | int cf = image[loc(x,y)].f; |
494 | int cb = image[loc(x,y)].b; | 508 | int cb = image[loc(x,y)].b; |
495 | int cr = image[loc(x,y)].r; | 509 | int cr = image[loc(x,y)].r; |
496 | while (x+len <= rlx && | 510 | while (x+len <= rlx && |
497 | image[loc(x+len,y)].f == cf && | 511 | image[loc(x+len,y)].f == cf && |
498 | image[loc(x+len,y)].b == cb && | 512 | image[loc(x+len,y)].b == cb && |
499 | image[loc(x+len,y)].r == cr ) | 513 | image[loc(x+len,y)].r == cr ) |
500 | { | 514 | { |
501 | disstrU[len] = fontMap(image[loc(x+len,y)].c); | 515 | disstrU[len] = fontMap(image[loc(x+len,y)].c); |
502 | len += 1; | 516 | len += 1; |
503 | } | 517 | } |
504 | QString unistr(disstrU,len); | 518 | QString unistr(disstrU,len); |
505 | drawAttrStr(paint, | 519 | drawAttrStr(paint, |
506 | QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h), | 520 | QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h), |
507 | unistr, image[loc(x,y)], pm != NULL, false); | 521 | unistr, image[loc(x,y)], pm != NULL, false); |
508 | x += len - 1; | 522 | x += len - 1; |
509 | } | 523 | } |
510 | delete [] disstrU; | 524 | delete [] disstrU; |
511 | drawFrame( &paint ); | 525 | drawFrame( &paint ); |
512 | paint.end(); | 526 | paint.end(); |
513 | setUpdatesEnabled(TRUE); | 527 | setUpdatesEnabled(TRUE); |
514 | } | 528 | } |
515 | 529 | ||
516 | void TEWidget::blinkEvent() | 530 | void TEWidget::blinkEvent() |
517 | { | 531 | { |
518 | blinking = !blinking; | 532 | blinking = !blinking; |
519 | repaint(FALSE); | 533 | repaint(FALSE); |
520 | } | 534 | } |
521 | 535 | ||
522 | /* ------------------------------------------------------------------------- */ | 536 | /* ------------------------------------------------------------------------- */ |
523 | /* */ | 537 | /* */ |
524 | /* Resizing */ | 538 | /* Resizing */ |
525 | /* */ | 539 | /* */ |
526 | /* ------------------------------------------------------------------------- */ | 540 | /* ------------------------------------------------------------------------- */ |
527 | 541 | ||
528 | void TEWidget::resizeEvent(QResizeEvent* ev) | 542 | void TEWidget::resizeEvent(QResizeEvent* ev) |
529 | { | 543 | { |
530 | //printf("resize: %d,%d\n",ev->size().width(),ev->size().height()); | 544 | //printf("resize: %d,%d\n",ev->size().width(),ev->size().height()); |
531 | //printf("approx: %d,%d\n",ev->size().width()/font_w,ev->size().height()/font_h); | 545 | //printf("approx: %d,%d\n",ev->size().width()/font_w,ev->size().height()/font_h); |
532 | //printf("leaves: %d,%d\n",ev->size().width()%font_w,ev->size().height()%font_h); | 546 | //printf("leaves: %d,%d\n",ev->size().width()%font_w,ev->size().height()%font_h); |
533 | //printf("curren: %d,%d\n",width(),height()); | 547 | //printf("curren: %d,%d\n",width(),height()); |
534 | HCNT("resizeEvent"); | 548 | HCNT("resizeEvent"); |
535 | 549 | ||
536 | // see comment in `paintEvent' concerning the rounding. | 550 | // see comment in `paintEvent' concerning the rounding. |
537 | //FIXME: could make a routine here; check width(),height() | 551 | //FIXME: could make a routine here; check width(),height() |
538 | assert(ev->size().width() == width()); | 552 | assert(ev->size().width() == width()); |
539 | assert(ev->size().height() == height()); | 553 | assert(ev->size().height() == height()); |
540 | 554 | ||
541 | propagateSize(); | 555 | propagateSize(); |
542 | } | 556 | } |
543 | 557 | ||
544 | void TEWidget::propagateSize() | 558 | void TEWidget::propagateSize() |
545 | { | 559 | { |
546 | ca* oldimg = image; | 560 | ca* oldimg = image; |
547 | int oldlin = lines; | 561 | int oldlin = lines; |
548 | int oldcol = columns; | 562 | int oldcol = columns; |
549 | makeImage(); | 563 | makeImage(); |
550 | // we copy the old image to reduce flicker | 564 | // we copy the old image to reduce flicker |
551 | int lins = QMIN(oldlin,lines); | 565 | int lins = QMIN(oldlin,lines); |
552 | int cols = QMIN(oldcol,columns); | 566 | int cols = QMIN(oldcol,columns); |
553 | if (oldimg) | 567 | if (oldimg) |
554 | { | 568 | { |
555 | for (int lin = 0; lin < lins; lin++) | 569 | for (int lin = 0; lin < lins; lin++) |
556 | memcpy((void*)&image[columns*lin], | 570 | memcpy((void*)&image[columns*lin], |
557 | (void*)&oldimg[oldcol*lin],cols*sizeof(ca)); | 571 | (void*)&oldimg[oldcol*lin],cols*sizeof(ca)); |
558 | free(oldimg); //FIXME: try new,delete | 572 | free(oldimg); //FIXME: try new,delete |
559 | } | 573 | } |
560 | else | 574 | else |
561 | clearImage(); | 575 | clearImage(); |
562 | 576 | ||
563 | //NOTE: control flows from the back through the chest right into the eye. | 577 | //NOTE: control flows from the back through the chest right into the eye. |
564 | // `emu' will call back via `setImage'. | 578 | // `emu' will call back via `setImage'. |
565 | 579 | ||
566 | resizing = TRUE; | 580 | resizing = TRUE; |
567 | emit changedImageSizeSignal(lines, columns); // expose resizeEvent | 581 | emit changedImageSizeSignal(lines, columns); // expose resizeEvent |
568 | resizing = FALSE; | 582 | resizing = FALSE; |
569 | } | 583 | } |
570 | 584 | ||
571 | /* ------------------------------------------------------------------------- */ | 585 | /* ------------------------------------------------------------------------- */ |
572 | /* */ | 586 | /* */ |
573 | /* Scrollbar */ | 587 | /* Scrollbar */ |
574 | /* */ | 588 | /* */ |
575 | /* ------------------------------------------------------------------------- */ | 589 | /* ------------------------------------------------------------------------- */ |
576 | 590 | ||
577 | void TEWidget::scrollChanged(int) | 591 | void TEWidget::scrollChanged(int) |
578 | { | 592 | { |
579 | emit changedHistoryCursor(scrollbar->value()); //expose | 593 | emit changedHistoryCursor(scrollbar->value()); //expose |
580 | } | 594 | } |
581 | 595 | ||
582 | void TEWidget::setScroll(int cursor, int slines) | 596 | void TEWidget::setScroll(int cursor, int slines) |
583 | { | 597 | { |
584 | disconnect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); | 598 | disconnect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); |
585 | scrollbar->setRange(0,slines); | 599 | scrollbar->setRange(0,slines); |
586 | scrollbar->setSteps(1,lines); | 600 | scrollbar->setSteps(1,lines); |
587 | scrollbar->setValue(cursor); | 601 | scrollbar->setValue(cursor); |
588 | connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); | 602 | connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); |
589 | } | 603 | } |
590 | 604 | ||
591 | void TEWidget::setScrollbarLocation(int loc) | 605 | void TEWidget::setScrollbarLocation(int loc) |
592 | { | 606 | { |
593 | if (scrollLoc == loc) return; // quickly | 607 | if (scrollLoc == loc) return; // quickly |
594 | scrollLoc = loc; | 608 | scrollLoc = loc; |
595 | propagateSize(); | 609 | propagateSize(); |
596 | update(); | 610 | update(); |
597 | } | 611 | } |
598 | 612 | ||
599 | /* ------------------------------------------------------------------------- */ | 613 | /* ------------------------------------------------------------------------- */ |
600 | /* */ | 614 | /* */ |
601 | /* Mouse */ | 615 | /* Mouse */ |
602 | /* */ | 616 | /* */ |
603 | /* ------------------------------------------------------------------------- */ | 617 | /* ------------------------------------------------------------------------- */ |
604 | 618 | ||
605 | /*! | 619 | /*! |
606 | Three different operations can be performed using the mouse, and the | 620 | Three different operations can be performed using the mouse, and the |
607 | routines in this section serve all of them: | 621 | routines in this section serve all of them: |
608 | 622 | ||
609 | 1) The press/release events are exposed to the application | 623 | 1) The press/release events are exposed to the application |
610 | 2) Marking (press and move left button) and Pasting (press middle button) | 624 | 2) Marking (press and move left button) and Pasting (press middle button) |
611 | 3) The right mouse button is used from the configuration menu | 625 | 3) The right mouse button is used from the configuration menu |
612 | 626 | ||
613 | NOTE: During the marking process we attempt to keep the cursor within | 627 | NOTE: During the marking process we attempt to keep the cursor within |
614 | the bounds of the text as being displayed by setting the mouse position | 628 | the bounds of the text as being displayed by setting the mouse position |
615 | whenever the mouse has left the text area. | 629 | whenever the mouse has left the text area. |
616 | 630 | ||
617 | Two reasons to do so: | 631 | Two reasons to do so: |
618 | 1) QT does not allow the `grabMouse' to confine-to the TEWidget. | 632 | 1) QT does not allow the `grabMouse' to confine-to the TEWidget. |
619 | Thus a `XGrapPointer' would have to be used instead. | 633 | Thus a `XGrapPointer' would have to be used instead. |
620 | 2) Even if so, this would not help too much, since the text area | 634 | 2) Even if so, this would not help too much, since the text area |
621 | of the TEWidget is normally not identical with it's bounds. | 635 | of the TEWidget is normally not identical with it's bounds. |
622 | 636 | ||
623 | The disadvantage of the current handling is, that the mouse can visibly | 637 | The disadvantage of the current handling is, that the mouse can visibly |
624 | leave the bounds of the widget and is then moved back. Because of the | 638 | leave the bounds of the widget and is then moved back. Because of the |
625 | current construction, and the reasons mentioned above, we cannot do better | 639 | current construction, and the reasons mentioned above, we cannot do better |
626 | without changing the overall construction. | 640 | without changing the overall construction. |
627 | */ | 641 | */ |
628 | 642 | ||
629 | /*! | 643 | /*! |
630 | */ | 644 | */ |
631 | 645 | ||
632 | void TEWidget::mousePressEvent(QMouseEvent* ev) | 646 | void TEWidget::mousePressEvent(QMouseEvent* ev) |
633 | { | 647 | { |
634 | //printf("press [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button()); | 648 | //printf("press [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button()); |
635 | if ( !contentsRect().contains(ev->pos()) ) return; | 649 | if ( !contentsRect().contains(ev->pos()) ) return; |
636 | QPoint tL = contentsRect().topLeft(); | 650 | QPoint tL = contentsRect().topLeft(); |
637 | int tLx = tL.x(); | 651 | int tLx = tL.x(); |
638 | int tLy = tL.y(); | 652 | int tLy = tL.y(); |
639 | 653 | ||
640 | word_selection_mode = FALSE; | 654 | word_selection_mode = FALSE; |
641 | 655 | ||
642 | //printf("press top left [%d,%d] by=%d\n",tLx,tLy, bY); | 656 | //printf("press top left [%d,%d] by=%d\n",tLx,tLy, bY); |
643 | if ( ev->button() == LeftButton) | 657 | if ( ev->button() == LeftButton) |
644 | { | 658 | { |
645 | QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); | 659 | QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); |
646 | 660 | ||
647 | if ( ev->state() & ControlButton ) preserve_line_breaks = FALSE ; | 661 | if ( ev->state() & ControlButton ) preserve_line_breaks = FALSE ; |
648 | 662 | ||
649 | if (mouse_marks || (ev->state() & ShiftButton)) | 663 | if (mouse_marks || (ev->state() & ShiftButton)) |
650 | { | 664 | { |
651 | emit clearSelectionSignal(); | 665 | emit clearSelectionSignal(); |
652 | iPntSel = pntSel = pos; | 666 | iPntSel = pntSel = pos; |
653 | actSel = 1; // left mouse button pressed but nothing selected yet. | 667 | actSel = 1; // left mouse button pressed but nothing selected yet. |
654 | grabMouse( /*crossCursor*/ ); // handle with care! | 668 | grabMouse( /*crossCursor*/ ); // handle with care! |
655 | } | 669 | } |
656 | else | 670 | else |
657 | { | 671 | { |
658 | emit mouseSignal( 0, pos.x() + 1, pos.y() + 1 ); // left button | 672 | emit mouseSignal( 0, pos.x() + 1, pos.y() + 1 ); // left button |
659 | } | 673 | } |
660 | } | 674 | } |
661 | if ( ev->button() == MidButton ) | 675 | if ( ev->button() == MidButton ) |
662 | { | 676 | { |
663 | emitSelection(); | 677 | emitSelection(); |
664 | } | 678 | } |
665 | if ( ev->button() == RightButton ) // Configure | 679 | if ( ev->button() == RightButton ) // Configure |
666 | { | 680 | { |
667 | emit configureRequest( this, ev->state()&(ShiftButton|ControlButton), ev->x(), ev->y() ); | 681 | emit configureRequest( this, ev->state()&(ShiftButton|ControlButton), ev->x(), ev->y() ); |
668 | } | 682 | } |
669 | } | 683 | } |
670 | 684 | ||
671 | void TEWidget::mouseMoveEvent(QMouseEvent* ev) | 685 | void TEWidget::mouseMoveEvent(QMouseEvent* ev) |
672 | { | 686 | { |
673 | // for auto-hiding the cursor, we need mouseTracking | 687 | // for auto-hiding the cursor, we need mouseTracking |
674 | if (ev->state() == NoButton ) return; | 688 | if (ev->state() == NoButton ) return; |
675 | 689 | ||
676 | if (actSel == 0) return; | 690 | if (actSel == 0) return; |
677 | 691 | ||
678 | // don't extend selection while pasting | 692 | // don't extend selection while pasting |
679 | if (ev->state() & MidButton) return; | 693 | if (ev->state() & MidButton) return; |
680 | 694 | ||
681 | //if ( !contentsRect().contains(ev->pos()) ) return; | 695 | //if ( !contentsRect().contains(ev->pos()) ) return; |
682 | QPoint tL = contentsRect().topLeft(); | 696 | QPoint tL = contentsRect().topLeft(); |
683 | int tLx = tL.x(); | 697 | int tLx = tL.x(); |
684 | int tLy = tL.y(); | 698 | int tLy = tL.y(); |
685 | int scroll = scrollbar->value(); | 699 | int scroll = scrollbar->value(); |
686 | 700 | ||
687 | // we're in the process of moving the mouse with the left button pressed | 701 | // we're in the process of moving the mouse with the left button pressed |
688 | // the mouse cursor will kept catched within the bounds of the text in | 702 | // the mouse cursor will kept catched within the bounds of the text in |
689 | // this widget. | 703 | // this widget. |
690 | 704 | ||
691 | // Adjust position within text area bounds. See FIXME above. | 705 | // Adjust position within text area bounds. See FIXME above. |
692 | QPoint pos = ev->pos(); | 706 | QPoint pos = ev->pos(); |
693 | if ( pos.x() < tLx+blX ) pos.setX( tLx+blX ); | 707 | if ( pos.x() < tLx+blX ) pos.setX( tLx+blX ); |
694 | if ( pos.x() > tLx+blX+columns*font_w-1 ) pos.setX( tLx+blX+columns*font_w ); | 708 | if ( pos.x() > tLx+blX+columns*font_w-1 ) pos.setX( tLx+blX+columns*font_w ); |
695 | if ( pos.y() < tLy+bY ) pos.setY( tLy+bY ); | 709 | if ( pos.y() < tLy+bY ) pos.setY( tLy+bY ); |
696 | if ( pos.y() > tLy+bY+lines*font_h-1 ) pos.setY( tLy+bY+lines*font_h-1 ); | 710 | if ( pos.y() > tLy+bY+lines*font_h-1 ) pos.setY( tLy+bY+lines*font_h-1 ); |
697 | // check if we produce a mouse move event by this | 711 | // check if we produce a mouse move event by this |
698 | if ( pos != ev->pos() ) cursor().setPos(mapToGlobal(pos)); | 712 | if ( pos != ev->pos() ) cursor().setPos(mapToGlobal(pos)); |
699 | 713 | ||
700 | if ( pos.y() == tLy+bY+lines*font_h-1 ) | 714 | if ( pos.y() == tLy+bY+lines*font_h-1 ) |
701 | { | 715 | { |
702 | scrollbar->setValue(scrollbar->value()+yMouseScroll); // scrollforward | 716 | scrollbar->setValue(scrollbar->value()+yMouseScroll); // scrollforward |
703 | } | 717 | } |
704 | if ( pos.y() == tLy+bY ) | 718 | if ( pos.y() == tLy+bY ) |
705 | { | 719 | { |
706 | scrollbar->setValue(scrollbar->value()-yMouseScroll); // scrollback | 720 | scrollbar->setValue(scrollbar->value()-yMouseScroll); // scrollback |
707 | } | 721 | } |
708 | 722 | ||
709 | QPoint here = QPoint((pos.x()-tLx-blX)/font_w,(pos.y()-tLy-bY)/font_h); | 723 | QPoint here = QPoint((pos.x()-tLx-blX)/font_w,(pos.y()-tLy-bY)/font_h); |
710 | QPoint ohere; | 724 | QPoint ohere; |
711 | bool swapping = FALSE; | 725 | bool swapping = FALSE; |
712 | 726 | ||
713 | if ( word_selection_mode ) | 727 | if ( word_selection_mode ) |
714 | { | 728 | { |
715 | // Extend to word boundaries | 729 | // Extend to word boundaries |
716 | int i; | 730 | int i; |
717 | int selClass; | 731 | int selClass; |
718 | 732 | ||
719 | bool left_not_right = ( here.y() < iPntSel.y() || | 733 | bool left_not_right = ( here.y() < iPntSel.y() || |
720 | here.y() == iPntSel.y() && here.x() < iPntSel.x() ); | 734 | here.y() == iPntSel.y() && here.x() < iPntSel.x() ); |
721 | bool old_left_not_right = ( pntSel.y() < iPntSel.y() || | 735 | bool old_left_not_right = ( pntSel.y() < iPntSel.y() || |
722 | pntSel.y() == iPntSel.y() && pntSel.x() < iPntSel.x() ); | 736 | pntSel.y() == iPntSel.y() && pntSel.x() < iPntSel.x() ); |
723 | swapping = left_not_right != old_left_not_right; | 737 | swapping = left_not_right != old_left_not_right; |
724 | 738 | ||
725 | // Find left (left_not_right ? from here : from start) | 739 | // Find left (left_not_right ? from here : from start) |
726 | QPoint left = left_not_right ? here : iPntSel; | 740 | QPoint left = left_not_right ? here : iPntSel; |
727 | i = loc(left.x(),left.y()); | 741 | i = loc(left.x(),left.y()); |
728 | selClass = charClass(image[i].c); | 742 | selClass = charClass(image[i].c); |
729 | while ( left.x() > 0 && charClass(image[i-1].c) == selClass ) | 743 | while ( left.x() > 0 && charClass(image[i-1].c) == selClass ) |
730 | { i--; left.rx()--; } | 744 | { i--; left.rx()--; } |
731 | 745 | ||
732 | // Find left (left_not_right ? from start : from here) | 746 | // Find left (left_not_right ? from start : from here) |
733 | QPoint right = left_not_right ? iPntSel : here; | 747 | QPoint right = left_not_right ? iPntSel : here; |
734 | i = loc(right.x(),right.y()); | 748 | i = loc(right.x(),right.y()); |
735 | selClass = charClass(image[i].c); | 749 | selClass = charClass(image[i].c); |
736 | while ( right.x() < columns-1 && charClass(image[i+1].c) == selClass ) | 750 | while ( right.x() < columns-1 && charClass(image[i+1].c) == selClass ) |
737 | { i++; right.rx()++; } | 751 | { i++; right.rx()++; } |
738 | 752 | ||
739 | // Pick which is start (ohere) and which is extension (here) | 753 | // Pick which is start (ohere) and which is extension (here) |
740 | if ( left_not_right ) | 754 | if ( left_not_right ) |
741 | { | 755 | { |
742 | here = left; ohere = right; | 756 | here = left; ohere = right; |
743 | } | 757 | } |
744 | else | 758 | else |
745 | { | 759 | { |
746 | here = right; ohere = left; | 760 | here = right; ohere = left; |
747 | } | 761 | } |
748 | } | 762 | } |
749 | 763 | ||
750 | if (here == pntSel && scroll == scrollbar->value()) return; // not moved | 764 | if (here == pntSel && scroll == scrollbar->value()) return; // not moved |
751 | 765 | ||
752 | if ( word_selection_mode ) { | 766 | if ( word_selection_mode ) { |
753 | if ( actSel < 2 || swapping ) { | 767 | if ( actSel < 2 || swapping ) { |
754 | emit beginSelectionSignal( ohere.x(), ohere.y() ); | 768 | emit beginSelectionSignal( ohere.x(), ohere.y() ); |
755 | } | 769 | } |
756 | } else if ( actSel < 2 ) { | 770 | } else if ( actSel < 2 ) { |
757 | emit beginSelectionSignal( pntSel.x(), pntSel.y() ); | 771 | emit beginSelectionSignal( pntSel.x(), pntSel.y() ); |
758 | } | 772 | } |
759 | 773 | ||
760 | actSel = 2; // within selection | 774 | actSel = 2; // within selection |
761 | pntSel = here; | 775 | pntSel = here; |
762 | emit extendSelectionSignal( here.x(), here.y() ); | 776 | emit extendSelectionSignal( here.x(), here.y() ); |
763 | } | 777 | } |
764 | 778 | ||
765 | void TEWidget::mouseReleaseEvent(QMouseEvent* ev) | 779 | void TEWidget::mouseReleaseEvent(QMouseEvent* ev) |
766 | { | 780 | { |
767 | //printf("release [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button()); | 781 | //printf("release [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button()); |
768 | if ( ev->button() == LeftButton) | 782 | if ( ev->button() == LeftButton) |
769 | { | 783 | { |
770 | if ( actSel > 1 ) emit endSelectionSignal(preserve_line_breaks); | 784 | if ( actSel > 1 ) emit endSelectionSignal(preserve_line_breaks); |
771 | preserve_line_breaks = TRUE; | 785 | preserve_line_breaks = TRUE; |
772 | actSel = 0; | 786 | actSel = 0; |
773 | 787 | ||
774 | //FIXME: emits a release event even if the mouse is | 788 | //FIXME: emits a release event even if the mouse is |
775 | // outside the range. The procedure used in `mouseMoveEvent' | 789 | // outside the range. The procedure used in `mouseMoveEvent' |
776 | // applies here, too. | 790 | // applies here, too. |
777 | 791 | ||
778 | QPoint tL = contentsRect().topLeft(); | 792 | QPoint tL = contentsRect().topLeft(); |
779 | int tLx = tL.x(); | 793 | int tLx = tL.x(); |
780 | int tLy = tL.y(); | 794 | int tLy = tL.y(); |
781 | 795 | ||
782 | if (!mouse_marks && !(ev->state() & ShiftButton)) | 796 | if (!mouse_marks && !(ev->state() & ShiftButton)) |
783 | emit mouseSignal( 3, // release | 797 | emit mouseSignal( 3, // release |
784 | (ev->x()-tLx-blX)/font_w + 1, | 798 | (ev->x()-tLx-blX)/font_w + 1, |
785 | (ev->y()-tLy-bY)/font_h + 1 ); | 799 | (ev->y()-tLy-bY)/font_h + 1 ); |
786 | releaseMouse(); | 800 | releaseMouse(); |
787 | } | 801 | } |
788 | } | 802 | } |
789 | 803 | ||
790 | void TEWidget::mouseDoubleClickEvent(QMouseEvent* ev) | 804 | void TEWidget::mouseDoubleClickEvent(QMouseEvent* ev) |
791 | { | 805 | { |
792 | if ( ev->button() != LeftButton) return; | 806 | if ( ev->button() != LeftButton) return; |
793 | 807 | ||
794 | QPoint tL = contentsRect().topLeft(); | 808 | QPoint tL = contentsRect().topLeft(); |
795 | int tLx = tL.x(); | 809 | int tLx = tL.x(); |
796 | int tLy = tL.y(); | 810 | int tLy = tL.y(); |
797 | QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); | 811 | QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); |
798 | 812 | ||
799 | // pass on double click as two clicks. | 813 | // pass on double click as two clicks. |
800 | if (!mouse_marks && !(ev->state() & ShiftButton)) | 814 | if (!mouse_marks && !(ev->state() & ShiftButton)) |
801 | { | 815 | { |
802 | emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button | 816 | emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button |
803 | emit mouseSignal( 3, pos.x()+1, pos.y()+1 ); // release | 817 | emit mouseSignal( 3, pos.x()+1, pos.y()+1 ); // release |
804 | emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button | 818 | emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button |
805 | return; | 819 | return; |
806 | } | 820 | } |
807 | 821 | ||
808 | 822 | ||
809 | emit clearSelectionSignal(); | 823 | emit clearSelectionSignal(); |
810 | QPoint bgnSel = pos; | 824 | QPoint bgnSel = pos; |
811 | QPoint endSel = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); | 825 | QPoint endSel = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); |
812 | int i = loc(bgnSel.x(),bgnSel.y()); | 826 | int i = loc(bgnSel.x(),bgnSel.y()); |
813 | iPntSel = bgnSel; | 827 | iPntSel = bgnSel; |
814 | 828 | ||
815 | word_selection_mode = TRUE; | 829 | word_selection_mode = TRUE; |
816 | 830 | ||
817 | // find word boundaries... | 831 | // find word boundaries... |
818 | int selClass = charClass(image[i].c); | 832 | int selClass = charClass(image[i].c); |
819 | { | 833 | { |
820 | // set the start... | 834 | // set the start... |
821 | int x = bgnSel.x(); | 835 | int x = bgnSel.x(); |
822 | while ( x > 0 && charClass(image[i-1].c) == selClass ) | 836 | while ( x > 0 && charClass(image[i-1].c) == selClass ) |
823 | { i--; x--; } | 837 | { i--; x--; } |
824 | bgnSel.setX(x); | 838 | bgnSel.setX(x); |
825 | emit beginSelectionSignal( bgnSel.x(), bgnSel.y() ); | 839 | emit beginSelectionSignal( bgnSel.x(), bgnSel.y() ); |
826 | 840 | ||
827 | // set the end... | 841 | // set the end... |
828 | i = loc( endSel.x(), endSel.y() ); | 842 | i = loc( endSel.x(), endSel.y() ); |
829 | x = endSel.x(); | 843 | x = endSel.x(); |
830 | while( x < columns-1 && charClass(image[i+1].c) == selClass ) | 844 | while( x < columns-1 && charClass(image[i+1].c) == selClass ) |
831 | { i++; x++ ; } | 845 | { i++; x++ ; } |
832 | endSel.setX(x); | 846 | endSel.setX(x); |
833 | actSel = 2; // within selection | 847 | actSel = 2; // within selection |
834 | emit extendSelectionSignal( endSel.x(), endSel.y() ); | 848 | emit extendSelectionSignal( endSel.x(), endSel.y() ); |
835 | emit endSelectionSignal(preserve_line_breaks); | 849 | emit endSelectionSignal(preserve_line_breaks); |
836 | preserve_line_breaks = TRUE; | 850 | preserve_line_breaks = TRUE; |
837 | } | 851 | } |
838 | } | 852 | } |
839 | 853 | ||
840 | void TEWidget::focusInEvent( QFocusEvent * ) | 854 | void TEWidget::focusInEvent( QFocusEvent * ) |
841 | { | 855 | { |
842 | // do nothing, to prevent repainting | 856 | // do nothing, to prevent repainting |
843 | } | 857 | } |
844 | 858 | ||
845 | 859 | ||
846 | void TEWidget::focusOutEvent( QFocusEvent * ) | 860 | void TEWidget::focusOutEvent( QFocusEvent * ) |
847 | { | 861 | { |
848 | // do nothing, to prevent repainting | 862 | // do nothing, to prevent repainting |
849 | } | 863 | } |
850 | 864 | ||
851 | bool TEWidget::focusNextPrevChild( bool next ) | 865 | bool TEWidget::focusNextPrevChild( bool next ) |
852 | { | 866 | { |
853 | if (next) | 867 | if (next) |
854 | return false; // This disables changing the active part in konqueror | 868 | return false; // This disables changing the active part in konqueror |
855 | // when pressing Tab | 869 | // when pressing Tab |
856 | return QFrame::focusNextPrevChild( next ); | 870 | return QFrame::focusNextPrevChild( next ); |
857 | } | 871 | } |
858 | 872 | ||
859 | 873 | ||
860 | int TEWidget::charClass(char ch) const | 874 | int TEWidget::charClass(char ch) const |
861 | { | 875 | { |
862 | // This might seem like overkill, but imagine if ch was a Unicode | 876 | // This might seem like overkill, but imagine if ch was a Unicode |
863 | // character (Qt 2.0 QChar) - it might then be sensible to separate | 877 | // character (Qt 2.0 QChar) - it might then be sensible to separate |
864 | // the different language ranges, etc. | 878 | // the different language ranges, etc. |
865 | 879 | ||
866 | if ( isspace(ch) ) return ' '; | 880 | if ( isspace(ch) ) return ' '; |
867 | 881 | ||
868 | static const char *word_characters = ":@-./_~"; | 882 | static const char *word_characters = ":@-./_~"; |
869 | if ( isalnum(ch) || strchr(word_characters, ch) ) | 883 | if ( isalnum(ch) || strchr(word_characters, ch) ) |
870 | return 'a'; | 884 | return 'a'; |
871 | 885 | ||
872 | // Everything else is weird | 886 | // Everything else is weird |
873 | return 1; | 887 | return 1; |
874 | } | 888 | } |
875 | 889 | ||
876 | void TEWidget::setMouseMarks(bool on) | 890 | void TEWidget::setMouseMarks(bool on) |
877 | { | 891 | { |
878 | mouse_marks = on; | 892 | mouse_marks = on; |
879 | setCursor( mouse_marks ? ibeamCursor : arrowCursor ); | 893 | setCursor( mouse_marks ? ibeamCursor : arrowCursor ); |
880 | } | 894 | } |
881 | 895 | ||
882 | /* ------------------------------------------------------------------------- */ | 896 | /* ------------------------------------------------------------------------- */ |
883 | /* */ | 897 | /* */ |
884 | /* Clipboard */ | 898 | /* Clipboard */ |
885 | /* */ | 899 | /* */ |
886 | /* ------------------------------------------------------------------------- */ | 900 | /* ------------------------------------------------------------------------- */ |
887 | 901 | ||
888 | #undef KeyPress | 902 | #undef KeyPress |
889 | 903 | ||
890 | void TEWidget::emitSelection() | 904 | void TEWidget::emitSelection() |
891 | // Paste Clipboard by simulating keypress events | 905 | // Paste Clipboard by simulating keypress events |
892 | { | 906 | { |
893 | #ifndef QT_NO_CLIPBOARD | 907 | #ifndef QT_NO_CLIPBOARD |
894 | QString text = QApplication::clipboard()->text(); | 908 | QString text = QApplication::clipboard()->text(); |
895 | if ( ! text.isNull() ) | 909 | if ( ! text.isNull() ) |
896 | { | 910 | { |
897 | text.replace(QRegExp("\n"), "\r"); | 911 | text.replace(QRegExp("\n"), "\r"); |
898 | QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text); | 912 | QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text); |
899 | emit keyPressedSignal(&e); // expose as a big fat keypress event | 913 | emit keyPressedSignal(&e); // expose as a big fat keypress event |
900 | emit clearSelectionSignal(); | 914 | emit clearSelectionSignal(); |
901 | } | 915 | } |
902 | #endif | 916 | #endif |
903 | } | 917 | } |
904 | 918 | ||
905 | void TEWidget::emitText(QString text) | 919 | void TEWidget::emitText(QString text) |
906 | { | 920 | { |
907 | QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text); | 921 | QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text); |
908 | emit keyPressedSignal(&e); // expose as a big fat keypress event | 922 | emit keyPressedSignal(&e); // expose as a big fat keypress event |
909 | } | 923 | } |
910 | 924 | ||
911 | void TEWidget::pasteClipboard( ) | 925 | void TEWidget::pasteClipboard( ) |
912 | { | 926 | { |
913 | emitSelection(); | 927 | emitSelection(); |
914 | } | 928 | } |
915 | 929 | ||
916 | void TEWidget::setSelection(const QString& t) | 930 | void TEWidget::setSelection(const QString& t) |
917 | { | 931 | { |
918 | #ifndef QT_NO_CLIPBOARD | 932 | #ifndef QT_NO_CLIPBOARD |
919 | // Disconnect signal while WE set the clipboard | 933 | // Disconnect signal while WE set the clipboard |
920 | QObject *cb = QApplication::clipboard(); | 934 | QObject *cb = QApplication::clipboard(); |
921 | QObject::disconnect( cb, SIGNAL(dataChanged()), | 935 | QObject::disconnect( cb, SIGNAL(dataChanged()), |
922 | this, SLOT(onClearSelection()) ); | 936 | this, SLOT(onClearSelection()) ); |
923 | 937 | ||
924 | QApplication::clipboard()->setText(t); | 938 | QApplication::clipboard()->setText(t); |
925 | 939 | ||
926 | QObject::connect( cb, SIGNAL(dataChanged()), | 940 | QObject::connect( cb, SIGNAL(dataChanged()), |
927 | this, SLOT(onClearSelection()) ); | 941 | this, SLOT(onClearSelection()) ); |
928 | #endif | 942 | #endif |
929 | } | 943 | } |
930 | 944 | ||
931 | void TEWidget::onClearSelection() | 945 | void TEWidget::onClearSelection() |
932 | { | 946 | { |
933 | emit clearSelectionSignal(); | 947 | emit clearSelectionSignal(); |
934 | } | 948 | } |
935 | 949 | ||
936 | /* ------------------------------------------------------------------------- */ | 950 | /* ------------------------------------------------------------------------- */ |
937 | /* */ | 951 | /* */ |
938 | /* Keyboard */ | 952 | /* Keyboard */ |
939 | /* */ | 953 | /* */ |
940 | /* ------------------------------------------------------------------------- */ | 954 | /* ------------------------------------------------------------------------- */ |
941 | 955 | ||
942 | //FIXME: an `eventFilter' has been installed instead of a `keyPressEvent' | 956 | //FIXME: an `eventFilter' has been installed instead of a `keyPressEvent' |
943 | // due to a bug in `QT' or the ignorance of the author to prevent | 957 | // due to a bug in `QT' or the ignorance of the author to prevent |
944 | // repaint events being emitted to the screen whenever one leaves | 958 | // repaint events being emitted to the screen whenever one leaves |
945 | // or reenters the screen to/from another application. | 959 | // or reenters the screen to/from another application. |
946 | // | 960 | // |
947 | // Troll says one needs to change focusInEvent() and focusOutEvent(), | 961 | // Troll says one needs to change focusInEvent() and focusOutEvent(), |
948 | // which would also let you have an in-focus cursor and an out-focus | 962 | // which would also let you have an in-focus cursor and an out-focus |
949 | // cursor like xterm does. | 963 | // cursor like xterm does. |
950 | 964 | ||
951 | // for the auto-hide cursor feature, I added empty focusInEvent() and | 965 | // for the auto-hide cursor feature, I added empty focusInEvent() and |
952 | // focusOutEvent() so that update() isn't called. | 966 | // focusOutEvent() so that update() isn't called. |
953 | // For auto-hide, we need to get keypress-events, but we only get them when | 967 | // For auto-hide, we need to get keypress-events, but we only get them when |
954 | // we have focus. | 968 | // we have focus. |
955 | 969 | ||
956 | void TEWidget::doScroll(int lines) | 970 | void TEWidget::doScroll(int lines) |
957 | { | 971 | { |
958 | scrollbar->setValue(scrollbar->value()+lines); | 972 | scrollbar->setValue(scrollbar->value()+lines); |
959 | } | 973 | } |
960 | 974 | ||
961 | bool TEWidget::eventFilter( QObject *obj, QEvent *e ) | 975 | bool TEWidget::eventFilter( QObject *obj, QEvent *e ) |
962 | { | 976 | { |
963 | if ( (e->type() == QEvent::Accel || | 977 | if ( (e->type() == QEvent::Accel || |
964 | e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) | 978 | e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) |
965 | { | 979 | { |
966 | static_cast<QKeyEvent *>( e )->ignore(); | 980 | static_cast<QKeyEvent *>( e )->ignore(); |
967 | return true; | 981 | return true; |
968 | } | 982 | } |
969 | if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ ) | 983 | if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ ) |
970 | return FALSE; // not us | 984 | return FALSE; // not us |
971 | if ( e->type() == QEvent::Wheel) | 985 | if ( e->type() == QEvent::Wheel) |
972 | { | 986 | { |
973 | QApplication::sendEvent(scrollbar, e); | 987 | QApplication::sendEvent(scrollbar, e); |
974 | } | 988 | } |
975 | 989 | ||
976 | #ifdef FAKE_CTRL_AND_ALT | 990 | #ifdef FAKE_CTRL_AND_ALT |
977 | static bool control = FALSE; | 991 | static bool control = FALSE; |
978 | static bool alt = FALSE; | 992 | static bool alt = FALSE; |
979 | // Has a keyboard with no CTRL and ALT keys, but we fake it: | 993 | // Has a keyboard with no CTRL and ALT keys, but we fake it: |
980 | bool dele=FALSE; | 994 | bool dele=FALSE; |
981 | if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { | 995 | if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { |
982 | QKeyEvent* ke = (QKeyEvent*)e; | 996 | QKeyEvent* ke = (QKeyEvent*)e; |
983 | bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat(); | 997 | bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat(); |
984 | switch (ke->key()) { | 998 | switch (ke->key()) { |
985 | case Key_F9: // let this be "Control" | 999 | case Key_F9: // let this be "Control" |
986 | control = keydown; | 1000 | control = keydown; |
987 | e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state()); | 1001 | e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state()); |
988 | dele=TRUE; | 1002 | dele=TRUE; |
989 | break; | 1003 | break; |
990 | case Key_F13: // let this be "Alt" | 1004 | case Key_F13: // let this be "Alt" |
991 | alt = keydown; | 1005 | alt = keydown; |
992 | e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state()); | 1006 | e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state()); |
993 | dele=TRUE; | 1007 | dele=TRUE; |
994 | break; | 1008 | break; |
995 | default: | 1009 | default: |
996 | if ( control ) { | 1010 | if ( control ) { |
997 | int a = toupper(ke->ascii())-64; | 1011 | int a = toupper(ke->ascii())-64; |
998 | if ( a >= 0 && a < ' ' ) { | 1012 | if ( a >= 0 && a < ' ' ) { |
999 | e = new QKeyEvent(e->type(), ke->key(), | 1013 | e = new QKeyEvent(e->type(), ke->key(), |
1000 | a, ke->state()|ControlButton, QChar(a,0)); | 1014 | a, ke->state()|ControlButton, QChar(a,0)); |
1001 | dele=TRUE; | 1015 | dele=TRUE; |
1002 | } | 1016 | } |
1003 | } | 1017 | } |
1004 | if ( alt ) { | 1018 | if ( alt ) { |
1005 | e = new QKeyEvent(e->type(), ke->key(), | 1019 | e = new QKeyEvent(e->type(), ke->key(), |
1006 | ke->ascii(), ke->state()|AltButton, ke->text()); | 1020 | ke->ascii(), ke->state()|AltButton, ke->text()); |
1007 | dele=TRUE; | 1021 | dele=TRUE; |
1008 | } | 1022 | } |
1009 | } | 1023 | } |
1010 | } | 1024 | } |
1011 | #endif | 1025 | #endif |
1012 | 1026 | ||
1013 | if ( e->type() == QEvent::KeyPress ) | 1027 | if ( e->type() == QEvent::KeyPress ) |
1014 | { | 1028 | { |
1015 | QKeyEvent* ke = (QKeyEvent*)e; | 1029 | QKeyEvent* ke = (QKeyEvent*)e; |
1016 | 1030 | ||
1017 | actSel=0; // Key stroke implies a screen update, so TEWidget won't | 1031 | actSel=0; // Key stroke implies a screen update, so TEWidget won't |
1018 | // know where the current selection is. | 1032 | // know where the current selection is. |
1019 | 1033 | ||
1020 | emit keyPressedSignal(ke); // expose | 1034 | emit keyPressedSignal(ke); // expose |
1021 | ke->accept(); | 1035 | ke->accept(); |
1022 | #ifdef FAKE_CTRL_AND_ALT | 1036 | #ifdef FAKE_CTRL_AND_ALT |
1023 | if ( dele ) delete e; | 1037 | if ( dele ) delete e; |
1024 | #endif | 1038 | #endif |
1025 | return true; // stop the event | 1039 | return true; // stop the event |
1026 | } | 1040 | } |
1027 | if ( e->type() == QEvent::Enter ) | 1041 | if ( e->type() == QEvent::Enter ) |
1028 | { | 1042 | { |
1029 | QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()), | 1043 | QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()), |
1030 | this, SLOT(onClearSelection()) ); | 1044 | this, SLOT(onClearSelection()) ); |
1031 | } | 1045 | } |
1032 | if ( e->type() == QEvent::Leave ) | 1046 | if ( e->type() == QEvent::Leave ) |
1033 | { | 1047 | { |
1034 | QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), | 1048 | QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), |
1035 | this, SLOT(onClearSelection()) ); | 1049 | this, SLOT(onClearSelection()) ); |
1036 | } | 1050 | } |
1037 | return QFrame::eventFilter( obj, e ); | 1051 | return QFrame::eventFilter( obj, e ); |
1038 | } | 1052 | } |
1039 | 1053 | ||
1040 | /* ------------------------------------------------------------------------- */ | 1054 | /* ------------------------------------------------------------------------- */ |
1041 | /* */ | 1055 | /* */ |
1042 | /* Frame */ | 1056 | /* Frame */ |
1043 | /* */ | 1057 | /* */ |
1044 | /* ------------------------------------------------------------------------- */ | 1058 | /* ------------------------------------------------------------------------- */ |
1045 | 1059 | ||
1046 | void TEWidget::frameChanged() | 1060 | void TEWidget::frameChanged() |
1047 | { | 1061 | { |
1048 | propagateSize(); | 1062 | propagateSize(); |
1049 | update(); | 1063 | update(); |
1050 | } | 1064 | } |
1051 | 1065 | ||
1052 | /* ------------------------------------------------------------------------- */ | 1066 | /* ------------------------------------------------------------------------- */ |
1053 | /* */ | 1067 | /* */ |
1054 | /* Sound */ | 1068 | /* Sound */ |
1055 | /* */ | 1069 | /* */ |
1056 | /* ------------------------------------------------------------------------- */ | 1070 | /* ------------------------------------------------------------------------- */ |
1057 | 1071 | ||
1058 | void TEWidget::Bell() | 1072 | void TEWidget::Bell() |
1059 | { | 1073 | { |
1060 | QApplication::beep(); | 1074 | QApplication::beep(); |
1061 | } | 1075 | } |
1062 | 1076 | ||
1063 | /* ------------------------------------------------------------------------- */ | 1077 | /* ------------------------------------------------------------------------- */ |
1064 | /* */ | 1078 | /* */ |
1065 | /* Auxiluary */ | 1079 | /* Auxiluary */ |
1066 | /* */ | 1080 | /* */ |
1067 | /* ------------------------------------------------------------------------- */ | 1081 | /* ------------------------------------------------------------------------- */ |
1068 | 1082 | ||
1069 | void TEWidget::clearImage() | 1083 | void TEWidget::clearImage() |
1070 | // initialize the image | 1084 | // initialize the image |
1071 | // for internal use only | 1085 | // for internal use only |
1072 | { | 1086 | { |
1073 | for (int y = 0; y < lines; y++) | 1087 | for (int y = 0; y < lines; y++) |
1074 | for (int x = 0; x < columns; x++) | 1088 | for (int x = 0; x < columns; x++) |
1075 | { | 1089 | { |
1076 | image[loc(x,y)].c = 0xff; //' '; | 1090 | image[loc(x,y)].c = 0xff; //' '; |
1077 | image[loc(x,y)].f = 0xff; //DEFAULT_FORE_COLOR; | 1091 | image[loc(x,y)].f = 0xff; //DEFAULT_FORE_COLOR; |
1078 | image[loc(x,y)].b = 0xff; //DEFAULT_BACK_COLOR; | 1092 | image[loc(x,y)].b = 0xff; //DEFAULT_BACK_COLOR; |
1079 | image[loc(x,y)].r = 0xff; //DEFAULT_RENDITION; | 1093 | image[loc(x,y)].r = 0xff; //DEFAULT_RENDITION; |
1080 | } | 1094 | } |
1081 | } | 1095 | } |
1082 | 1096 | ||
1083 | // Create Image /////////////////////////////////////////////////////// | 1097 | // Create Image /////////////////////////////////////////////////////// |
1084 | 1098 | ||
1085 | void TEWidget::calcGeometry() | 1099 | void TEWidget::calcGeometry() |
1086 | { | 1100 | { |
1087 | //FIXME: set rimX == rimY == 0 when running in full screen mode. | 1101 | //FIXME: set rimX == rimY == 0 when running in full screen mode. |
1088 | 1102 | ||
1089 | scrollbar->resize(QApplication::style().scrollBarExtent().width(), | 1103 | scrollbar->resize(QApplication::style().scrollBarExtent().width(), |
1090 | contentsRect().height()); | 1104 | contentsRect().height()); |
1091 | switch(scrollLoc) | 1105 | switch(scrollLoc) |
1092 | { | 1106 | { |
1093 | case SCRNONE : | 1107 | case SCRNONE : |
1094 | columns = ( contentsRect().width() - 2 * rimX ) / font_w; | 1108 | columns = ( contentsRect().width() - 2 * rimX ) / font_w; |
1095 | blX = (contentsRect().width() - (columns*font_w) ) / 2; | 1109 | blX = (contentsRect().width() - (columns*font_w) ) / 2; |
1096 | brX = blX; | 1110 | brX = blX; |
1097 | scrollbar->hide(); | 1111 | scrollbar->hide(); |
1098 | break; | 1112 | break; |
1099 | case SCRLEFT : | 1113 | case SCRLEFT : |
1100 | columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; | 1114 | columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; |
1101 | brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; | 1115 | brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; |
1102 | blX = brX + scrollbar->width(); | 1116 | blX = brX + scrollbar->width(); |
1103 | scrollbar->move(contentsRect().topLeft()); | 1117 | scrollbar->move(contentsRect().topLeft()); |
1104 | scrollbar->show(); | 1118 | scrollbar->show(); |
1105 | break; | 1119 | break; |
1106 | case SCRRIGHT: | 1120 | case SCRRIGHT: |
1107 | columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; | 1121 | columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; |
1108 | blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; | 1122 | blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; |
1109 | brX = blX; | 1123 | brX = blX; |
1110 | scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0)); | 1124 | scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0)); |
1111 | scrollbar->show(); | 1125 | scrollbar->show(); |
1112 | break; | 1126 | break; |
1113 | } | 1127 | } |
1114 | //FIXME: support 'rounding' styles | 1128 | //FIXME: support 'rounding' styles |
1115 | lines = ( contentsRect().height() - 2 * rimY ) / font_h; | 1129 | lines = ( contentsRect().height() - 2 * rimY ) / font_h; |
1116 | bY = (contentsRect().height() - (lines *font_h)) / 2; | 1130 | bY = (contentsRect().height() - (lines *font_h)) / 2; |
1117 | } | 1131 | } |
1118 | 1132 | ||
1119 | void TEWidget::makeImage() | 1133 | void TEWidget::makeImage() |
1120 | //FIXME: rename 'calcGeometry? | 1134 | //FIXME: rename 'calcGeometry? |
1121 | { | 1135 | { |
1122 | calcGeometry(); | 1136 | calcGeometry(); |
1123 | image = (ca*) malloc(lines*columns*sizeof(ca)); | 1137 | image = (ca*) malloc(lines*columns*sizeof(ca)); |
1124 | clearImage(); | 1138 | clearImage(); |
1125 | } | 1139 | } |
1126 | 1140 | ||
1127 | // calculate the needed size | 1141 | // calculate the needed size |
1128 | QSize TEWidget::calcSize(int cols, int lins) const | 1142 | QSize TEWidget::calcSize(int cols, int lins) const |
1129 | { | 1143 | { |
1130 | int frw = width() - contentsRect().width(); | 1144 | int frw = width() - contentsRect().width(); |
1131 | int frh = height() - contentsRect().height(); | 1145 | int frh = height() - contentsRect().height(); |
1132 | int scw = (scrollLoc==SCRNONE?0:scrollbar->width()); | 1146 | int scw = (scrollLoc==SCRNONE?0:scrollbar->width()); |
1133 | return QSize( font_w*cols + 2*rimX + frw + scw, font_h*lins + 2*rimY + frh ); | 1147 | return QSize( font_w*cols + 2*rimX + frw + scw, font_h*lins + 2*rimY + frh ); |
1134 | } | 1148 | } |
1135 | 1149 | ||
1136 | QSize TEWidget::sizeHint() const | 1150 | QSize TEWidget::sizeHint() const |
1137 | { | 1151 | { |
1138 | return size(); | 1152 | return size(); |
1139 | } | 1153 | } |
1140 | 1154 | ||
1141 | void TEWidget::styleChange(QStyle &) | 1155 | void TEWidget::styleChange(QStyle &) |
1142 | { | 1156 | { |
1143 | propagateSize(); | 1157 | propagateSize(); |
1144 | } | 1158 | } |
1145 | 1159 | ||
1146 | #ifndef QT_NO_DRAGANDDROP | 1160 | #ifndef QT_NO_DRAGANDDROP |
1147 | 1161 | ||
1148 | /* --------------------------------------------------------------------- */ | 1162 | /* --------------------------------------------------------------------- */ |
1149 | /* */ | 1163 | /* */ |
1150 | /* Drag & Drop */ | 1164 | /* Drag & Drop */ |
1151 | /* */ | 1165 | /* */ |
1152 | /* --------------------------------------------------------------------- */ | 1166 | /* --------------------------------------------------------------------- */ |
1153 | 1167 | ||
1154 | 1168 | ||
1155 | void TEWidget::dragEnterEvent(QDragEnterEvent* e) | 1169 | void TEWidget::dragEnterEvent(QDragEnterEvent* e) |
1156 | { | 1170 | { |
1157 | e->accept(QTextDrag::canDecode(e) || | 1171 | e->accept(QTextDrag::canDecode(e) || |
1158 | QUriDrag::canDecode(e)); | 1172 | QUriDrag::canDecode(e)); |
1159 | } | 1173 | } |
1160 | 1174 | ||
1161 | void TEWidget::dropEvent(QDropEvent* event) | 1175 | void TEWidget::dropEvent(QDropEvent* event) |
1162 | { | 1176 | { |
1163 | // The current behaviour when url(s) are dropped is | 1177 | // The current behaviour when url(s) are dropped is |
1164 | // * if there is only ONE url and if it's a LOCAL one, ask for paste or cd | 1178 | // * if there is only ONE url and if it's a LOCAL one, ask for paste or cd |
1165 | // * in all other cases, just paste | 1179 | // * in all other cases, just paste |
1166 | // (for non-local ones, or for a list of URLs, 'cd' is nonsense) | 1180 | // (for non-local ones, or for a list of URLs, 'cd' is nonsense) |
1167 | QStrList strlist; | 1181 | QStrList strlist; |
1168 | int file_count = 0; | 1182 | int file_count = 0; |
1169 | dropText = ""; | 1183 | dropText = ""; |
1170 | bool bPopup = true; | 1184 | bool bPopup = true; |
1171 | 1185 | ||
1172 | if(QUriDrag::decode(event, strlist)) { | 1186 | if(QUriDrag::decode(event, strlist)) { |
1173 | if (strlist.count()) { | 1187 | if (strlist.count()) { |
1174 | for(const char* p = strlist.first(); p; p = strlist.next()) { | 1188 | for(const char* p = strlist.first(); p; p = strlist.next()) { |
1175 | if(file_count++ > 0) { | 1189 | if(file_count++ > 0) { |
1176 | dropText += " "; | 1190 | dropText += " "; |
1177 | bPopup = false; // more than one file, don't popup | 1191 | bPopup = false; // more than one file, don't popup |
1178 | } | 1192 | } |
1179 | 1193 | ||
1180 | /* | 1194 | /* |
1181 | KURL url(p); | 1195 | KURL url(p); |
1182 | if (url.isLocalFile()) { | 1196 | if (url.isLocalFile()) { |
1183 | dropText += url.path(); // local URL : remove protocol | 1197 | dropText += url.path(); // local URL : remove protocol |
1184 | } | 1198 | } |
1185 | else { | 1199 | else { |
1186 | dropText += url.prettyURL(); | 1200 | dropText += url.prettyURL(); |
1187 | bPopup = false; // a non-local file, don't popup | 1201 | bPopup = false; // a non-local file, don't popup |
1188 | } | 1202 | } |
1189 | */ | 1203 | */ |
1190 | 1204 | ||
1191 | } | 1205 | } |
1192 | 1206 | ||
1193 | if (bPopup) | 1207 | if (bPopup) |
1194 | // m_drop->popup(pos() + event->pos()); | 1208 | // m_drop->popup(pos() + event->pos()); |
1195 | m_drop->popup(mapToGlobal(event->pos())); | 1209 | m_drop->popup(mapToGlobal(event->pos())); |
1196 | else | 1210 | else |
1197 | { | 1211 | { |
1198 | if (currentSession) { | 1212 | if (currentSession) { |
1199 | currentSession->getEmulation()->sendString(dropText.local8Bit()); | 1213 | currentSession->getEmulation()->sendString(dropText.local8Bit()); |
1200 | } | 1214 | } |
1201 | // kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; | 1215 | // kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; |
1202 | } | 1216 | } |
1203 | } | 1217 | } |
1204 | } | 1218 | } |
1205 | else if(QTextDrag::decode(event, dropText)) { | 1219 | else if(QTextDrag::decode(event, dropText)) { |
1206 | // kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; | 1220 | // kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; |
1207 | if (currentSession) { | 1221 | if (currentSession) { |
1208 | currentSession->getEmulation()->sendString(dropText.local8Bit()); | 1222 | currentSession->getEmulation()->sendString(dropText.local8Bit()); |
1209 | } | 1223 | } |
1210 | // Paste it | 1224 | // Paste it |
1211 | } | 1225 | } |
1212 | } | 1226 | } |
1213 | #endif | 1227 | #endif |
1214 | 1228 | ||
1215 | 1229 | ||
1216 | void TEWidget::drop_menu_activated(int item) | 1230 | void TEWidget::drop_menu_activated(int item) |
1217 | { | 1231 | { |
1218 | #ifndef QT_NO_DRAGANDDROP | 1232 | #ifndef QT_NO_DRAGANDDROP |
1219 | switch (item) | 1233 | switch (item) |
1220 | { | 1234 | { |
1221 | case 0: // paste | 1235 | case 0: // paste |
1222 | currentSession->getEmulation()->sendString(dropText.local8Bit()); | 1236 | currentSession->getEmulation()->sendString(dropText.local8Bit()); |
1223 | // KWM::activate((Window)this->winId()); | 1237 | // KWM::activate((Window)this->winId()); |
1224 | break; | 1238 | break; |
1225 | case 1: // cd ... | 1239 | case 1: // cd ... |
1226 | currentSession->getEmulation()->sendString("cd "); | 1240 | currentSession->getEmulation()->sendString("cd "); |
1227 | struct stat statbuf; | 1241 | struct stat statbuf; |
1228 | if ( ::stat( QFile::encodeName( dropText ), &statbuf ) == 0 ) | 1242 | if ( ::stat( QFile::encodeName( dropText ), &statbuf ) == 0 ) |
1229 | { | 1243 | { |
1230 | if ( !S_ISDIR(statbuf.st_mode) ) | 1244 | if ( !S_ISDIR(statbuf.st_mode) ) |
1231 | { | 1245 | { |
1232 | /* | 1246 | /* |
1233 | KURL url; | 1247 | KURL url; |
1234 | url.setPath( dropText ); | 1248 | url.setPath( dropText ); |
1235 | dropText = url.directory( true, false ); // remove filename | 1249 | dropText = url.directory( true, false ); // remove filename |
1236 | */ | 1250 | */ |
1237 | } | 1251 | } |
1238 | } | 1252 | } |
1239 | dropText.replace(QRegExp(" "), "\\ "); // escape spaces | 1253 | dropText.replace(QRegExp(" "), "\\ "); // escape spaces |
1240 | currentSession->getEmulation()->sendString(dropText.local8Bit()); | 1254 | currentSession->getEmulation()->sendString(dropText.local8Bit()); |
1241 | currentSession->getEmulation()->sendString("\n"); | 1255 | currentSession->getEmulation()->sendString("\n"); |
1242 | // KWM::activate((Window)this->winId()); | 1256 | // KWM::activate((Window)this->winId()); |
1243 | break; | 1257 | break; |
1244 | } | 1258 | } |
1245 | #endif | 1259 | #endif |
1246 | } | 1260 | } |
1247 | 1261 | ||
diff --git a/core/apps/embeddedkonsole/konsole.cpp b/core/apps/embeddedkonsole/konsole.cpp index d54fa1f..e2d4886 100644 --- a/core/apps/embeddedkonsole/konsole.cpp +++ b/core/apps/embeddedkonsole/konsole.cpp | |||
@@ -1,765 +1,794 @@ | |||
1 | /* ---------------------------------------------------------------------- */ | 1 | /* ---------------------------------------------------------------------- */ |
2 | /* */ | 2 | /* */ |
3 | /* [main.C] Konsole */ | 3 | /* [main.C] Konsole */ |
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. */ | 9 | /* This file is part of Konsole, an X terminal. */ |
10 | /* */ | 10 | /* */ |
11 | /* The material contained in here more or less directly orginates from */ | 11 | /* The material contained in here more or less directly orginates from */ |
12 | /* kvt, which is copyright (c) 1996 by Matthias Ettrich <ettrich@kde.org> */ | 12 | /* kvt, which is copyright (c) 1996 by Matthias Ettrich <ettrich@kde.org> */ |
13 | /* */ | 13 | /* */ |
14 | /* ---------------------------------------------------------------------- */ | 14 | /* ---------------------------------------------------------------------- */ |
15 | /* */ | 15 | /* */ |
16 | /* Ported Konsole to Qt/Embedded */ | 16 | /* Ported Konsole to Qt/Embedded */ |
17 | /* */ | 17 | /* */ |
18 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ | 18 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ |
19 | /* */ | 19 | /* */ |
20 | /* -------------------------------------------------------------------------- */ | 20 | /* -------------------------------------------------------------------------- */ |
21 | 21 | ||
22 | #include <qpe/resource.h> | 22 | #include <qpe/resource.h> |
23 | 23 | ||
24 | #include <qdir.h> | 24 | #include <qdir.h> |
25 | #include <qevent.h> | 25 | #include <qevent.h> |
26 | #include <qdragobject.h> | 26 | #include <qdragobject.h> |
27 | #include <qobjectlist.h> | 27 | #include <qobjectlist.h> |
28 | #include <qtoolbutton.h> | 28 | #include <qtoolbutton.h> |
29 | #include <qpe/qpetoolbar.h> | 29 | #include <qpe/qpetoolbar.h> |
30 | #include <qpushbutton.h> | 30 | #include <qpushbutton.h> |
31 | #include <qfontdialog.h> | 31 | #include <qfontdialog.h> |
32 | #include <qglobal.h> | 32 | #include <qglobal.h> |
33 | #include <qpainter.h> | 33 | #include <qpainter.h> |
34 | #include <qpe/qpemenubar.h> | 34 | #include <qpe/qpemenubar.h> |
35 | #include <qmessagebox.h> | 35 | #include <qmessagebox.h> |
36 | #include <qaction.h> | 36 | #include <qaction.h> |
37 | #include <qapplication.h> | 37 | #include <qapplication.h> |
38 | #include <qfontmetrics.h> | 38 | #include <qfontmetrics.h> |
39 | #include <qcombobox.h> | 39 | #include <qcombobox.h> |
40 | #include <qevent.h> | 40 | #include <qevent.h> |
41 | #include <qtabwidget.h> | 41 | #include <qtabwidget.h> |
42 | #include <qtabbar.h> | 42 | #include <qtabbar.h> |
43 | #include <qpe/config.h> | 43 | #include <qpe/config.h> |
44 | #include <qstringlist.h> | 44 | #include <qstringlist.h> |
45 | #include <qpalette.h> | 45 | #include <qpalette.h> |
46 | 46 | ||
47 | #include <sys/wait.h> | 47 | #include <sys/wait.h> |
48 | #include <stdio.h> | 48 | #include <stdio.h> |
49 | #include <stdlib.h> | 49 | #include <stdlib.h> |
50 | #include <assert.h> | 50 | #include <assert.h> |
51 | 51 | ||
52 | #include "konsole.h" | 52 | #include "konsole.h" |
53 | #include "keytrans.h" | 53 | #include "keytrans.h" |
54 | 54 | ||
55 | class EKNumTabBar : public QTabBar { | 55 | class EKNumTabBar : public QTabBar { |
56 | public: | 56 | public: |
57 | void numberTabs() | 57 | void numberTabs() |
58 | { | 58 | { |
59 | // Yes, it really is this messy. QTabWidget needs functions | 59 | // Yes, it really is this messy. QTabWidget needs functions |
60 | // that provide acces to tabs in a sequential way. | 60 | // that provide acces to tabs in a sequential way. |
61 | int m=INT_MIN; | 61 | int m=INT_MIN; |
62 | for (int i=0; i<count(); i++) { | 62 | for (int i=0; i<count(); i++) { |
63 | QTab* left=0; | 63 | QTab* left=0; |
64 | QListIterator<QTab> it(*tabList()); | 64 | QListIterator<QTab> it(*tabList()); |
65 | int x=INT_MAX; | 65 | int x=INT_MAX; |
66 | for( QTab* t; (t=it.current()); ++it ) { | 66 | for( QTab* t; (t=it.current()); ++it ) { |
67 | int tx = t->rect().x(); | 67 | int tx = t->rect().x(); |
68 | if ( tx<x && tx>m ) { | 68 | if ( tx<x && tx>m ) { |
69 | x = tx; | 69 | x = tx; |
70 | left = t; | 70 | left = t; |
71 | } | 71 | } |
72 | } | 72 | } |
73 | if ( left ) { | 73 | if ( left ) { |
74 | left->setText(QString::number(i+1)); | 74 | left->setText(QString::number(i+1)); |
75 | m = left->rect().x(); | 75 | m = left->rect().x(); |
76 | } | 76 | } |
77 | } | 77 | } |
78 | } | 78 | } |
79 | }; | 79 | }; |
80 | 80 | ||
81 | class EKNumTabWidget : public QTabWidget { | 81 | class EKNumTabWidget : public QTabWidget { |
82 | public: | 82 | public: |
83 | EKNumTabWidget(QWidget* parent) : QTabWidget(parent) | 83 | EKNumTabWidget(QWidget* parent) : QTabWidget(parent) |
84 | { | 84 | { |
85 | } | 85 | } |
86 | 86 | ||
87 | void addTab(QWidget* w) | 87 | void addTab(QWidget* w) |
88 | { | 88 | { |
89 | QTab* t = new QTab(QString::number(tabBar()->count()+1)); | 89 | QTab* t = new QTab(QString::number(tabBar()->count()+1)); |
90 | QTabWidget::addTab(w,t); | 90 | QTabWidget::addTab(w,t); |
91 | } | 91 | } |
92 | 92 | ||
93 | void removeTab(QWidget* w) | 93 | void removeTab(QWidget* w) |
94 | { | 94 | { |
95 | removePage(w); | 95 | removePage(w); |
96 | ((EKNumTabBar*)tabBar())->numberTabs(); | 96 | ((EKNumTabBar*)tabBar())->numberTabs(); |
97 | } | 97 | } |
98 | }; | 98 | }; |
99 | 99 | ||
100 | // This could be configurable or dynamicly generated from the bash history | 100 | // This could be configurable or dynamicly generated from the bash history |
101 | // file of the user | 101 | // file of the user |
102 | static const char *commonCmds[] = | 102 | static const char *commonCmds[] = |
103 | { | 103 | { |
104 | "ls ", // I left this here, cause it looks better than the first alpha | 104 | "ls ", // I left this here, cause it looks better than the first alpha |
105 | "cardctl eject", | 105 | "cardctl eject", |
106 | "cat ", | 106 | "cat ", |
107 | "cd ", | 107 | "cd ", |
108 | "chmod ", | 108 | "chmod ", |
109 | "clear", | 109 | "clear", |
110 | "cp ", | 110 | "cp ", |
111 | "dc ", | 111 | "dc ", |
112 | "df ", | 112 | "df ", |
113 | "dmesg", | 113 | "dmesg", |
114 | "echo ", | 114 | "echo ", |
115 | "env", | 115 | "env", |
116 | "find ", | 116 | "find ", |
117 | "free", | 117 | "free", |
118 | "grep ", | 118 | "grep ", |
119 | "ifconfig ", | 119 | "ifconfig ", |
120 | "ipkg ", | 120 | "ipkg ", |
121 | "mkdir ", | 121 | "mkdir ", |
122 | "mv ", | 122 | "mv ", |
123 | "nc localhost 7776", | 123 | "nc localhost 7776", |
124 | "nc localhost 7777", | 124 | "nc localhost 7777", |
125 | "netstat ", | 125 | "netstat ", |
126 | "nslookup ", | 126 | "nslookup ", |
127 | "ping ", | 127 | "ping ", |
128 | "ps aux", | 128 | "ps aux", |
129 | "pwd ", | 129 | "pwd ", |
130 | "rm ", | 130 | "rm ", |
131 | "rmdir ", | 131 | "rmdir ", |
132 | "route ", | 132 | "route ", |
133 | "set ", | 133 | "set ", |
134 | "traceroute", | 134 | "traceroute", |
135 | 135 | ||
136 | /* | 136 | /* |
137 | "gzip", | 137 | "gzip", |
138 | "gunzip", | 138 | "gunzip", |
139 | "chgrp", | 139 | "chgrp", |
140 | "chown", | 140 | "chown", |
141 | "date", | 141 | "date", |
142 | "dd", | 142 | "dd", |
143 | "df", | 143 | "df", |
144 | "dmesg", | 144 | "dmesg", |
145 | "fuser", | 145 | "fuser", |
146 | "hostname", | 146 | "hostname", |
147 | "kill", | 147 | "kill", |
148 | "killall", | 148 | "killall", |
149 | "ln", | 149 | "ln", |
150 | "ping", | 150 | "ping", |
151 | "mount", | 151 | "mount", |
152 | "more", | 152 | "more", |
153 | "sort", | 153 | "sort", |
154 | "touch", | 154 | "touch", |
155 | "umount", | 155 | "umount", |
156 | "mknod", | 156 | "mknod", |
157 | "netstat", | 157 | "netstat", |
158 | */ | 158 | */ |
159 | 159 | ||
160 | "exit", | 160 | "exit", |
161 | NULL | 161 | NULL |
162 | }; | 162 | }; |
163 | 163 | ||
164 | 164 | ||
165 | Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) : | 165 | Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) : |
166 | QMainWindow(parent, name, fl) | 166 | QMainWindow(parent, name, fl) |
167 | { | 167 | { |
168 | QStrList args; | 168 | QStrList args; |
169 | init("/bin/sh",args); | 169 | init("/bin/sh",args); |
170 | } | 170 | } |
171 | 171 | ||
172 | Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int) | 172 | Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int) |
173 | : QMainWindow(0, name) | 173 | : QMainWindow(0, name) |
174 | { | 174 | { |
175 | init(_pgm,_args); | 175 | init(_pgm,_args); |
176 | } | 176 | } |
177 | 177 | ||
178 | void Konsole::init(const char* _pgm, QStrList & _args) | 178 | void Konsole::init(const char* _pgm, QStrList & _args) |
179 | { | 179 | { |
180 | b_scroll = TRUE; // histon; | 180 | b_scroll = TRUE; // histon; |
181 | n_keytab = 0; | 181 | n_keytab = 0; |
182 | n_render = 0; | 182 | n_render = 0; |
183 | 183 | ||
184 | setCaption( tr("Terminal") ); | 184 | setCaption( tr("Terminal") ); |
185 | setIcon( Resource::loadPixmap( "konsole" ) ); | 185 | setIcon( Resource::loadPixmap( "konsole" ) ); |
186 | 186 | ||
187 | Config cfg("Konsole"); | 187 | Config cfg("Konsole"); |
188 | cfg.setGroup("Konsole"); | 188 | cfg.setGroup("Konsole"); |
189 | QString tmp; | 189 | QString tmp; |
190 | // initialize the list of allowed fonts /////////////////////////////////// | 190 | // initialize the list of allowed fonts /////////////////////////////////// |
191 | cfont = cfg.readNumEntry("FontID", 1); | 191 | cfont = cfg.readNumEntry("FontID", 1); |
192 | QFont f = QFont("Micro", 4, QFont::Normal); | 192 | QFont f = QFont("Micro", 4, QFont::Normal); |
193 | f.setFixedPitch(TRUE); | 193 | f.setFixedPitch(TRUE); |
194 | fonts.append(new VTFont(tr("Micro"), f)); | 194 | fonts.append(new VTFont(tr("Micro"), f)); |
195 | 195 | ||
196 | f = QFont("Fixed", 7, QFont::Normal); | 196 | f = QFont("Fixed", 7, QFont::Normal); |
197 | f.setFixedPitch(TRUE); | 197 | f.setFixedPitch(TRUE); |
198 | fonts.append(new VTFont(tr("Small Fixed"), f)); | 198 | fonts.append(new VTFont(tr("Small Fixed"), f)); |
199 | 199 | ||
200 | f = QFont("Fixed", 12, QFont::Normal); | 200 | f = QFont("Fixed", 12, QFont::Normal); |
201 | f.setFixedPitch(TRUE); | 201 | f.setFixedPitch(TRUE); |
202 | fonts.append(new VTFont(tr("Medium Fixed"), f)); | 202 | fonts.append(new VTFont(tr("Medium Fixed"), f)); |
203 | 203 | ||
204 | // create terminal emulation framework //////////////////////////////////// | 204 | // create terminal emulation framework //////////////////////////////////// |
205 | nsessions = 0; | 205 | nsessions = 0; |
206 | 206 | ||
207 | tab = new EKNumTabWidget(this); | 207 | tab = new EKNumTabWidget(this); |
208 | 208 | ||
209 | connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*))); | 209 | connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*))); |
210 | 210 | ||
211 | // create terminal toolbar //////////////////////////////////////////////// | 211 | // create terminal toolbar //////////////////////////////////////////////// |
212 | setToolBarsMovable( FALSE ); | 212 | setToolBarsMovable( FALSE ); |
213 | QPEToolBar *menuToolBar = new QPEToolBar( this ); | 213 | QPEToolBar *menuToolBar = new QPEToolBar( this ); |
214 | menuToolBar->setHorizontalStretchable( TRUE ); | 214 | menuToolBar->setHorizontalStretchable( TRUE ); |
215 | 215 | ||
216 | QPEMenuBar *menuBar = new QPEMenuBar( menuToolBar ); | 216 | QPEMenuBar *menuBar = new QPEMenuBar( menuToolBar ); |
217 | 217 | ||
218 | fontList = new QPopupMenu( this ); | 218 | fontList = new QPopupMenu( this ); |
219 | for(uint i = 0; i < fonts.count(); i++) { | 219 | for(uint i = 0; i < fonts.count(); i++) { |
220 | VTFont *fnt = fonts.at(i); | 220 | VTFont *fnt = fonts.at(i); |
221 | fontList->insertItem(fnt->getName(), i); | 221 | fontList->insertItem(fnt->getName(), i); |
222 | } | 222 | } |
223 | fontChanged(cfont); | 223 | fontChanged(cfont); |
224 | 224 | ||
225 | configMenu = new QPopupMenu( this); | 225 | configMenu = new QPopupMenu( this); |
226 | colorMenu = new QPopupMenu( this); | 226 | colorMenu = new QPopupMenu( this); |
227 | 227 | scrollMenu = new QPopupMenu( this); | |
228 | |||
228 | bool listHidden; | 229 | bool listHidden; |
229 | cfg.setGroup("Menubar"); | 230 | cfg.setGroup("Menubar"); |
230 | if( cfg.readEntry("Hidden","FALSE") == "TRUE") { | 231 | if( cfg.readEntry("Hidden","FALSE") == "TRUE") { |
231 | configMenu->insertItem("Show command list"); | 232 | configMenu->insertItem("Show command list"); |
232 | listHidden=TRUE; | 233 | listHidden=TRUE; |
233 | } else { | 234 | } else { |
234 | configMenu->insertItem("Hide command list"); | 235 | configMenu->insertItem("Hide command list"); |
235 | listHidden=FALSE; | 236 | listHidden=FALSE; |
236 | } | 237 | } |
237 | 238 | ||
238 | cfg.setGroup("Tabs"); | 239 | cfg.setGroup("Tabs"); |
239 | tmp=cfg.readEntry("Position","Bottom"); | 240 | tmp=cfg.readEntry("Position","Bottom"); |
240 | if(tmp=="Top") { | 241 | if(tmp=="Top") { |
241 | tab->setTabPosition(QTabWidget::Top); | 242 | tab->setTabPosition(QTabWidget::Top); |
242 | configMenu->insertItem("Tabs on Bottom"); | 243 | configMenu->insertItem("Tabs on Bottom"); |
243 | } else { | 244 | } else { |
244 | tab->setTabPosition(QTabWidget::Bottom); | 245 | tab->setTabPosition(QTabWidget::Bottom); |
245 | configMenu->insertItem("Tabs on Top"); | 246 | configMenu->insertItem("Tabs on Top"); |
246 | } | 247 | } |
247 | configMenu->insertSeparator(2); | 248 | configMenu->insertSeparator(2); |
248 | 249 | ||
249 | colorMenu->insertItem("Green on Black"); | 250 | colorMenu->insertItem("Green on Black"); |
250 | colorMenu->insertItem("Black on White"); | 251 | colorMenu->insertItem("Black on White"); |
251 | colorMenu->insertItem("White on Black"); | 252 | colorMenu->insertItem("White on Black"); |
252 | colorMenu->insertItem("Black on Transparent"); | 253 | colorMenu->insertItem("Black on Transparent"); |
253 | colorMenu->insertItem("Black on Red"); | 254 | colorMenu->insertItem("Black on Red"); |
254 | colorMenu->insertItem("Red on Black"); | 255 | colorMenu->insertItem("Red on Black"); |
255 | colorMenu->insertItem("Green on Yellow"); | 256 | colorMenu->insertItem("Green on Yellow"); |
256 | colorMenu->insertItem("Blue on Magenta"); | 257 | colorMenu->insertItem("Blue on Magenta"); |
257 | colorMenu->insertItem("Magenta on Blue"); | 258 | colorMenu->insertItem("Magenta on Blue"); |
258 | colorMenu->insertItem("Cyan on White"); | 259 | colorMenu->insertItem("Cyan on White"); |
259 | colorMenu->insertItem("White on Cyan"); | 260 | colorMenu->insertItem("White on Cyan"); |
260 | colorMenu->insertItem("Blue on Black"); | 261 | colorMenu->insertItem("Blue on Black"); |
261 | configMenu->insertItem("Colors",colorMenu); | 262 | configMenu->insertItem("Colors",colorMenu); |
262 | 263 | ||
263 | connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) )); | 264 | connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) )); |
264 | connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) )); | 265 | connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) )); |
265 | connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuSelected(int) )); | 266 | connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuSelected(int) )); |
267 | connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int))); | ||
266 | 268 | ||
267 | menuBar->insertItem( tr("Font"), fontList ); | 269 | menuBar->insertItem( tr("Font"), fontList ); |
268 | menuBar->insertItem( tr("Options"), configMenu ); | 270 | menuBar->insertItem( tr("Options"), configMenu ); |
269 | 271 | ||
270 | QPEToolBar *toolbar = new QPEToolBar( this ); | 272 | QPEToolBar *toolbar = new QPEToolBar( this ); |
271 | 273 | ||
272 | QAction *a; | 274 | QAction *a; |
273 | 275 | ||
274 | // Button Commands | 276 | // Button Commands |
275 | a = new QAction( tr("New"), Resource::loadPixmap( "konsole" ), QString::null, 0, this, 0 ); | 277 | a = new QAction( tr("New"), Resource::loadPixmap( "konsole" ), QString::null, 0, this, 0 ); |
276 | connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); a->addTo( toolbar ); | 278 | connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); a->addTo( toolbar ); |
277 | a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 ); | 279 | a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 ); |
278 | connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolbar ); | 280 | connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolbar ); |
279 | a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 ); | 281 | a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 ); |
280 | connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolbar ); | 282 | connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolbar ); |
281 | a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 ); | 283 | a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 ); |
282 | connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolbar ); | 284 | connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolbar ); |
283 | a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 ); | 285 | a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 ); |
284 | connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar ); | 286 | connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar ); |
285 | a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 ); | 287 | a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 ); |
286 | connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar ); | 288 | connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar ); |
287 | a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); | 289 | a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); |
288 | connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); a->addTo( toolbar ); | 290 | connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); a->addTo( toolbar ); |
289 | /* | 291 | /* |
290 | a = new QAction( tr("Up"), Resource::loadPixmap( "up" ), QString::null, 0, this, 0 ); | 292 | a = new QAction( tr("Up"), Resource::loadPixmap( "up" ), QString::null, 0, this, 0 ); |
291 | connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar ); | 293 | connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar ); |
292 | a = new QAction( tr("Down"), Resource::loadPixmap( "down" ), QString::null, 0, this, 0 ); | 294 | a = new QAction( tr("Down"), Resource::loadPixmap( "down" ), QString::null, 0, this, 0 ); |
293 | connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar ); | 295 | connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar ); |
294 | */ | 296 | */ |
295 | 297 | ||
296 | secondToolBar = new QPEToolBar( this ); | 298 | secondToolBar = new QPEToolBar( this ); |
297 | secondToolBar->setHorizontalStretchable( TRUE ); | 299 | secondToolBar->setHorizontalStretchable( TRUE ); |
298 | 300 | ||
299 | commonCombo = new QComboBox( secondToolBar ); | 301 | commonCombo = new QComboBox( secondToolBar ); |
300 | commonCombo->setMaximumWidth(236); | 302 | commonCombo->setMaximumWidth(236); |
301 | configMenu->insertItem( "Edit Command List"); | 303 | configMenu->insertItem( "Edit Command List"); |
302 | if( listHidden) { | 304 | if( listHidden) { |
303 | secondToolBar->hide(); | 305 | secondToolBar->hide(); |
304 | configMenu->setItemEnabled(-20 ,FALSE); | 306 | configMenu->setItemEnabled(-20 ,FALSE); |
305 | } | 307 | } |
306 | 308 | ||
307 | cfg.setGroup("Commands"); | 309 | cfg.setGroup("Commands"); |
308 | commonCombo->setInsertionPolicy(QComboBox::AtCurrent); | 310 | commonCombo->setInsertionPolicy(QComboBox::AtCurrent); |
309 | 311 | ||
310 | for (int i = 0; commonCmds[i] != NULL; i++) { | 312 | for (int i = 0; commonCmds[i] != NULL; i++) { |
311 | commonCombo->insertItem( commonCmds[i], i ); | 313 | commonCombo->insertItem( commonCmds[i], i ); |
312 | tmp = cfg.readEntry( QString::number(i),""); | 314 | tmp = cfg.readEntry( QString::number(i),""); |
313 | if(tmp != "") | 315 | if(tmp != "") |
314 | commonCombo->changeItem( tmp,i ); | 316 | commonCombo->changeItem( tmp,i ); |
315 | } | 317 | } |
316 | 318 | ||
317 | connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) )); | 319 | connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) )); |
318 | 320 | ||
321 | scrollMenu->insertItem("None"); | ||
322 | scrollMenu->insertItem("Left"); | ||
323 | scrollMenu->insertItem("Right"); | ||
324 | configMenu->insertItem("ScrollBar",scrollMenu); | ||
325 | |||
319 | // create applications ///////////////////////////////////////////////////// | 326 | // create applications ///////////////////////////////////////////////////// |
320 | setCentralWidget(tab); | 327 | setCentralWidget(tab); |
321 | 328 | ||
322 | // load keymaps //////////////////////////////////////////////////////////// | 329 | // load keymaps //////////////////////////////////////////////////////////// |
323 | KeyTrans::loadAll(); | 330 | KeyTrans::loadAll(); |
324 | for (int i = 0; i < KeyTrans::count(); i++) | 331 | for (int i = 0; i < KeyTrans::count(); i++) |
325 | { KeyTrans* s = KeyTrans::find(i); | 332 | { KeyTrans* s = KeyTrans::find(i); |
326 | assert( s ); | 333 | assert( s ); |
327 | } | 334 | } |
328 | 335 | ||
329 | se_pgm = _pgm; | 336 | se_pgm = _pgm; |
330 | se_args = _args; | 337 | se_args = _args; |
331 | 338 | ||
332 | // read and apply default values /////////////////////////////////////////// | 339 | // read and apply default values /////////////////////////////////////////// |
333 | resize(321, 321); // Dummy. | 340 | resize(321, 321); // Dummy. |
334 | QSize currentSize = size(); | 341 | QSize currentSize = size(); |
335 | if (currentSize != size()) | 342 | if (currentSize != size()) |
336 | defaultSize = size(); | 343 | defaultSize = size(); |
337 | 344 | ||
338 | } | 345 | } |
339 | 346 | ||
340 | void Konsole::show() | 347 | void Konsole::show() |
341 | { | 348 | { |
342 | if ( !nsessions ) { | 349 | if ( !nsessions ) { |
343 | newSession(); | 350 | newSession(); |
344 | } | 351 | } |
345 | QMainWindow::show(); | 352 | QMainWindow::show(); |
346 | } | 353 | } |
347 | 354 | ||
348 | void Konsole::initSession(const char*, QStrList &) | 355 | void Konsole::initSession(const char*, QStrList &) |
349 | { | 356 | { |
350 | QMainWindow::show(); | 357 | QMainWindow::show(); |
351 | } | 358 | } |
352 | 359 | ||
353 | Konsole::~Konsole() | 360 | Konsole::~Konsole() |
354 | { | 361 | { |
355 | while (nsessions > 0) { | 362 | while (nsessions > 0) { |
356 | doneSession(getTe()->currentSession, 0); | 363 | doneSession(getTe()->currentSession, 0); |
357 | } | 364 | } |
358 | 365 | ||
359 | Config cfg("Konsole"); | 366 | Config cfg("Konsole"); |
360 | cfg.setGroup("Konsole"); | 367 | cfg.setGroup("Konsole"); |
361 | cfg.writeEntry("FontID", cfont); | 368 | cfg.writeEntry("FontID", cfont); |
362 | } | 369 | } |
363 | 370 | ||
364 | void Konsole::fontChanged(int f) | 371 | void Konsole::fontChanged(int f) |
365 | { | 372 | { |
366 | VTFont* font = fonts.at(f); | 373 | VTFont* font = fonts.at(f); |
367 | if (font != 0) { | 374 | if (font != 0) { |
368 | for(uint i = 0; i < fonts.count(); i++) { | 375 | for(uint i = 0; i < fonts.count(); i++) { |
369 | fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE); | 376 | fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE); |
370 | } | 377 | } |
371 | 378 | ||
372 | cfont = f; | 379 | cfont = f; |
373 | 380 | ||
374 | TEWidget* te = getTe(); | 381 | TEWidget* te = getTe(); |
375 | if (te != 0) { | 382 | if (te != 0) { |
376 | te->setVTFont(font->getFont()); | 383 | te->setVTFont(font->getFont()); |
377 | } | 384 | } |
378 | } | 385 | } |
379 | } | 386 | } |
380 | 387 | ||
381 | 388 | ||
382 | void Konsole::enterCommand(int c) | 389 | void Konsole::enterCommand(int c) |
383 | { | 390 | { |
384 | TEWidget* te = getTe(); | 391 | TEWidget* te = getTe(); |
385 | if (te != 0) { | 392 | if (te != 0) { |
386 | if(!commonCombo->editable()) { | 393 | if(!commonCombo->editable()) { |
387 | QString text = commonCombo->text(c); //commonCmds[c]; | 394 | QString text = commonCombo->text(c); //commonCmds[c]; |
388 | te->emitText(text); | 395 | te->emitText(text); |
389 | } else { | 396 | } else { |
390 | changeCommand( commonCombo->text(c), c); | 397 | changeCommand( commonCombo->text(c), c); |
391 | } | 398 | } |
392 | } | 399 | } |
393 | } | 400 | } |
394 | 401 | ||
395 | void Konsole::hitEnter() | 402 | void Konsole::hitEnter() |
396 | { | 403 | { |
397 | TEWidget* te = getTe(); | 404 | TEWidget* te = getTe(); |
398 | if (te != 0) { | 405 | if (te != 0) { |
399 | te->emitText(QString("\r")); | 406 | te->emitText(QString("\r")); |
400 | } | 407 | } |
401 | } | 408 | } |
402 | 409 | ||
403 | void Konsole::hitSpace() | 410 | void Konsole::hitSpace() |
404 | { | 411 | { |
405 | TEWidget* te = getTe(); | 412 | TEWidget* te = getTe(); |
406 | if (te != 0) { | 413 | if (te != 0) { |
407 | te->emitText(QString(" ")); | 414 | te->emitText(QString(" ")); |
408 | } | 415 | } |
409 | } | 416 | } |
410 | 417 | ||
411 | void Konsole::hitTab() | 418 | void Konsole::hitTab() |
412 | { | 419 | { |
413 | TEWidget* te = getTe(); | 420 | TEWidget* te = getTe(); |
414 | if (te != 0) { | 421 | if (te != 0) { |
415 | te->emitText(QString("\t")); | 422 | te->emitText(QString("\t")); |
416 | } | 423 | } |
417 | } | 424 | } |
418 | 425 | ||
419 | void Konsole::hitPaste() | 426 | void Konsole::hitPaste() |
420 | { | 427 | { |
421 | TEWidget* te = getTe(); | 428 | TEWidget* te = getTe(); |
422 | if (te != 0) { | 429 | if (te != 0) { |
423 | te->pasteClipboard(); | 430 | te->pasteClipboard(); |
424 | } | 431 | } |
425 | } | 432 | } |
426 | 433 | ||
427 | void Konsole::hitUp() | 434 | void Konsole::hitUp() |
428 | { | 435 | { |
429 | TEWidget* te = getTe(); | 436 | TEWidget* te = getTe(); |
430 | if (te != 0) { | 437 | if (te != 0) { |
431 | QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Up, 0, 0); | 438 | QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Up, 0, 0); |
432 | QApplication::sendEvent( te, &ke ); | 439 | QApplication::sendEvent( te, &ke ); |
433 | } | 440 | } |
434 | } | 441 | } |
435 | 442 | ||
436 | void Konsole::hitDown() | 443 | void Konsole::hitDown() |
437 | { | 444 | { |
438 | TEWidget* te = getTe(); | 445 | TEWidget* te = getTe(); |
439 | if (te != 0) { | 446 | if (te != 0) { |
440 | QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Down, 0, 0); | 447 | QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Down, 0, 0); |
441 | QApplication::sendEvent( te, &ke ); | 448 | QApplication::sendEvent( te, &ke ); |
442 | } | 449 | } |
443 | } | 450 | } |
444 | 451 | ||
445 | /** | 452 | /** |
446 | This function calculates the size of the external widget | 453 | This function calculates the size of the external widget |
447 | needed for the internal widget to be | 454 | needed for the internal widget to be |
448 | */ | 455 | */ |
449 | QSize Konsole::calcSize(int columns, int lines) { | 456 | QSize Konsole::calcSize(int columns, int lines) { |
450 | TEWidget* te = getTe(); | 457 | TEWidget* te = getTe(); |
451 | if (te != 0) { | 458 | if (te != 0) { |
452 | QSize size = te->calcSize(columns, lines); | 459 | QSize size = te->calcSize(columns, lines); |
453 | return size; | 460 | return size; |
454 | } else { | 461 | } else { |
455 | QSize size; | 462 | QSize size; |
456 | return size; | 463 | return size; |
457 | } | 464 | } |
458 | } | 465 | } |
459 | 466 | ||
460 | /** | 467 | /** |
461 | sets application window to a size based on columns X lines of the te | 468 | sets application window to a size based on columns X lines of the te |
462 | guest widget. Call with (0,0) for setting default size. | 469 | guest widget. Call with (0,0) for setting default size. |
463 | */ | 470 | */ |
464 | 471 | ||
465 | void Konsole::setColLin(int columns, int lines) | 472 | void Konsole::setColLin(int columns, int lines) |
466 | { | 473 | { |
467 | if ((columns==0) || (lines==0)) | 474 | if ((columns==0) || (lines==0)) |
468 | { | 475 | { |
469 | if (defaultSize.isEmpty()) // not in config file : set default value | 476 | if (defaultSize.isEmpty()) // not in config file : set default value |
470 | { | 477 | { |
471 | defaultSize = calcSize(80,24); | 478 | defaultSize = calcSize(80,24); |
472 | // notifySize(24,80); // set menu items (strange arg order !) | 479 | // notifySize(24,80); // set menu items (strange arg order !) |
473 | } | 480 | } |
474 | resize(defaultSize); | 481 | resize(defaultSize); |
475 | } else { | 482 | } else { |
476 | resize(calcSize(columns, lines)); | 483 | resize(calcSize(columns, lines)); |
477 | // notifySize(lines,columns); // set menu items (strange arg order !) | 484 | // notifySize(lines,columns); // set menu items (strange arg order !) |
478 | } | 485 | } |
479 | } | 486 | } |
480 | 487 | ||
481 | /* | 488 | /* |
482 | void Konsole::setFont(int fontno) | 489 | void Konsole::setFont(int fontno) |
483 | { | 490 | { |
484 | QFont f; | 491 | QFont f; |
485 | if (fontno == 0) | 492 | if (fontno == 0) |
486 | f = defaultFont = QFont( "Helvetica", 12 ); | 493 | f = defaultFont = QFont( "Helvetica", 12 ); |
487 | else | 494 | else |
488 | if (fonts[fontno][0] == '-') | 495 | if (fonts[fontno][0] == '-') |
489 | f.setRawName( fonts[fontno] ); | 496 | f.setRawName( fonts[fontno] ); |
490 | else | 497 | else |
491 | { | 498 | { |
492 | f.setFamily(fonts[fontno]); | 499 | f.setFamily(fonts[fontno]); |
493 | f.setRawMode( TRUE ); | 500 | f.setRawMode( TRUE ); |
494 | } | 501 | } |
495 | if ( !f.exactMatch() && fontno != 0) | 502 | if ( !f.exactMatch() && fontno != 0) |
496 | { | 503 | { |
497 | QString msg = i18n("Font `%1' not found.\nCheck README.linux.console for help.").arg(fonts[fontno]); | 504 | QString msg = i18n("Font `%1' not found.\nCheck README.linux.console for help.").arg(fonts[fontno]); |
498 | QMessageBox(this, msg); | 505 | QMessageBox(this, msg); |
499 | return; | 506 | return; |
500 | } | 507 | } |
501 | if (se) se->setFontNo(fontno); | 508 | if (se) se->setFontNo(fontno); |
502 | te->setVTFont(f); | 509 | te->setVTFont(f); |
503 | n_font = fontno; | 510 | n_font = fontno; |
504 | } | 511 | } |
505 | */ | 512 | */ |
506 | 513 | ||
507 | // --| color selection |------------------------------------------------------- | 514 | // --| color selection |------------------------------------------------------- |
508 | 515 | ||
509 | void Konsole::changeColumns(int columns) | 516 | void Konsole::changeColumns(int columns) |
510 | { | 517 | { |
511 | TEWidget* te = getTe(); | 518 | TEWidget* te = getTe(); |
512 | if (te != 0) { | 519 | if (te != 0) { |
513 | setColLin(columns,te->Lines()); | 520 | setColLin(columns,te->Lines()); |
514 | te->update(); | 521 | te->update(); |
515 | } | 522 | } |
516 | } | 523 | } |
517 | 524 | ||
518 | //FIXME: If a child dies during session swap, | 525 | //FIXME: If a child dies during session swap, |
519 | // this routine might be called before | 526 | // this routine might be called before |
520 | // session swap is completed. | 527 | // session swap is completed. |
521 | 528 | ||
522 | void Konsole::doneSession(TESession*, int ) | 529 | void Konsole::doneSession(TESession*, int ) |
523 | { | 530 | { |
524 | TEWidget *te = getTe(); | 531 | TEWidget *te = getTe(); |
525 | if (te != 0) { | 532 | if (te != 0) { |
526 | te->currentSession->setConnect(FALSE); | 533 | te->currentSession->setConnect(FALSE); |
527 | tab->removeTab(te); | 534 | tab->removeTab(te); |
528 | delete te->currentSession; | 535 | delete te->currentSession; |
529 | delete te; | 536 | delete te; |
530 | nsessions--; | 537 | nsessions--; |
531 | } | 538 | } |
532 | 539 | ||
533 | if (nsessions == 0) { | 540 | if (nsessions == 0) { |
534 | close(); | 541 | close(); |
535 | } | 542 | } |
536 | } | 543 | } |
537 | 544 | ||
538 | void Konsole::newSession() { | 545 | void Konsole::newSession() { |
539 | if(nsessions < 15) { // seems to be something weird about 16 tabs on the Zaurus.... memory? | 546 | if(nsessions < 15) { // seems to be something weird about 16 tabs on the Zaurus.... memory? |
540 | TEWidget* te = new TEWidget(tab); | 547 | TEWidget* te = new TEWidget(tab); |
541 | // te->setBackgroundMode(PaletteBase); //we want transparent!! | 548 | // te->setBackgroundMode(PaletteBase); //we want transparent!! |
542 | te->setVTFont(fonts.at(cfont)->getFont()); | 549 | te->setVTFont(fonts.at(cfont)->getFont()); |
543 | tab->addTab(te); | 550 | tab->addTab(te); |
544 | TESession* se = new TESession(this, te, se_pgm, se_args, "xterm"); | 551 | TESession* se = new TESession(this, te, se_pgm, se_args, "xterm"); |
545 | te->currentSession = se; | 552 | te->currentSession = se; |
546 | connect( se, SIGNAL(done(TESession*,int)), this, SLOT(doneSession(TESession*,int)) ); | 553 | connect( se, SIGNAL(done(TESession*,int)), this, SLOT(doneSession(TESession*,int)) ); |
547 | se->run(); | 554 | se->run(); |
548 | se->setConnect(TRUE); | 555 | se->setConnect(TRUE); |
549 | se->setHistory(b_scroll); | 556 | se->setHistory(b_scroll); |
550 | tab->setCurrentPage(nsessions); | 557 | tab->setCurrentPage(nsessions); |
551 | nsessions++; | 558 | nsessions++; |
552 | setColor(); | 559 | setColor(); |
553 | } | 560 | } |
554 | } | 561 | } |
555 | 562 | ||
556 | TEWidget* Konsole::getTe() { | 563 | TEWidget* Konsole::getTe() { |
557 | if (nsessions) { | 564 | if (nsessions) { |
558 | return (TEWidget *) tab->currentPage(); | 565 | return (TEWidget *) tab->currentPage(); |
559 | } else { | 566 | } else { |
560 | return 0; | 567 | return 0; |
561 | } | 568 | } |
562 | } | 569 | } |
563 | 570 | ||
564 | void Konsole::switchSession(QWidget* w) { | 571 | void Konsole::switchSession(QWidget* w) { |
565 | TEWidget* te = (TEWidget *) w; | 572 | TEWidget* te = (TEWidget *) w; |
566 | 573 | ||
567 | QFont teFnt = te->getVTFont(); | 574 | QFont teFnt = te->getVTFont(); |
568 | for(uint i = 0; i < fonts.count(); i++) { | 575 | for(uint i = 0; i < fonts.count(); i++) { |
569 | VTFont *fnt = fonts.at(i); | 576 | VTFont *fnt = fonts.at(i); |
570 | bool cf = fnt->getFont() == teFnt; | 577 | bool cf = fnt->getFont() == teFnt; |
571 | fontList->setItemChecked(i, cf); | 578 | fontList->setItemChecked(i, cf); |
572 | if (cf) { | 579 | if (cf) { |
573 | cfont = i; | 580 | cfont = i; |
574 | } | 581 | } |
575 | } | 582 | } |
576 | } | 583 | } |
577 | 584 | ||
578 | /// ------------------------------- some new stuff by L.J. Potter | 585 | /// ------------------------------- some new stuff by L.J. Potter |
579 | void Konsole::colorMenuSelected(int iD) | 586 | void Konsole::colorMenuSelected(int iD) |
580 | { // this is NOT pretty, elegant or anything else besides functional | 587 | { // this is NOT pretty, elegant or anything else besides functional |
581 | // QString temp; | 588 | // QString temp; |
582 | // qDebug( temp.sprintf("%d", iD)); | 589 | // qDebug( temp.sprintf("%d", iD)); |
583 | TEWidget* te = getTe(); | 590 | TEWidget* te = getTe(); |
584 | Config cfg("Konsole"); | 591 | Config cfg("Konsole"); |
585 | cfg.setGroup("Colors"); | 592 | cfg.setGroup("Colors"); |
586 | QColor foreground; | 593 | QColor foreground; |
587 | QColor background; | 594 | QColor background; |
588 | colorMenu->setItemChecked(lastSelectedMenu,FALSE); | 595 | colorMenu->setItemChecked(lastSelectedMenu,FALSE); |
589 | ColorEntry m_table[TABLE_COLORS]; | 596 | ColorEntry m_table[TABLE_COLORS]; |
590 | const ColorEntry * defaultCt=te->getdefaultColorTable(); | 597 | const ColorEntry * defaultCt=te->getdefaultColorTable(); |
591 | /////////// fore back | 598 | /////////// fore back |
592 | int i; | 599 | int i; |
593 | if(iD==-8) { // default default | 600 | if(iD==-8) { // default default |
594 | for (i = 0; i < TABLE_COLORS; i++) { | 601 | for (i = 0; i < TABLE_COLORS; i++) { |
595 | m_table[i].color = defaultCt[i].color; | 602 | m_table[i].color = defaultCt[i].color; |
596 | if(i==1 || i == 11) | 603 | if(i==1 || i == 11) |
597 | m_table[i].transparent=1; | 604 | m_table[i].transparent=1; |
598 | cfg.writeEntry("Schema","8"); | 605 | cfg.writeEntry("Schema","8"); |
599 | colorMenu->setItemChecked(-8,TRUE); | 606 | colorMenu->setItemChecked(-8,TRUE); |
600 | } | 607 | } |
601 | } else { | 608 | } else { |
602 | if(iD==-5) { // green black | 609 | if(iD==-5) { // green black |
603 | foreground.setRgb(0x18,255,0x18); | 610 | foreground.setRgb(0x18,255,0x18); |
604 | background.setRgb(0x00,0x00,0x00); | 611 | background.setRgb(0x00,0x00,0x00); |
605 | cfg.writeEntry("Schema","5"); | 612 | cfg.writeEntry("Schema","5"); |
606 | colorMenu->setItemChecked(-5,TRUE); | 613 | colorMenu->setItemChecked(-5,TRUE); |
607 | } | 614 | } |
608 | if(iD==-6) { // black white | 615 | if(iD==-6) { // black white |
609 | foreground.setRgb(0x00,0x00,0x00); | 616 | foreground.setRgb(0x00,0x00,0x00); |
610 | background.setRgb(0xFF,0xFF,0xFF); | 617 | background.setRgb(0xFF,0xFF,0xFF); |
611 | cfg.writeEntry("Schema","6"); | 618 | cfg.writeEntry("Schema","6"); |
612 | colorMenu->setItemChecked(-6,TRUE); | 619 | colorMenu->setItemChecked(-6,TRUE); |
613 | } | 620 | } |
614 | if(iD==-7) { // white black | 621 | if(iD==-7) { // white black |
615 | foreground.setRgb(0xFF,0xFF,0xFF); | 622 | foreground.setRgb(0xFF,0xFF,0xFF); |
616 | background.setRgb(0x00,0x00,0x00); | 623 | background.setRgb(0x00,0x00,0x00); |
617 | cfg.writeEntry("Schema","7"); | 624 | cfg.writeEntry("Schema","7"); |
618 | colorMenu->setItemChecked(-7,TRUE); | 625 | colorMenu->setItemChecked(-7,TRUE); |
619 | } | 626 | } |
620 | if(iD==-9) {// Black, Red | 627 | if(iD==-9) {// Black, Red |
621 | foreground.setRgb(0x00,0x00,0x00); | 628 | foreground.setRgb(0x00,0x00,0x00); |
622 | background.setRgb(0xB2,0x18,0x18); | 629 | background.setRgb(0xB2,0x18,0x18); |
623 | cfg.writeEntry("Schema","9"); | 630 | cfg.writeEntry("Schema","9"); |
624 | colorMenu->setItemChecked(-9,TRUE); | 631 | colorMenu->setItemChecked(-9,TRUE); |
625 | } | 632 | } |
626 | if(iD==-10) {// Red, Black | 633 | if(iD==-10) {// Red, Black |
627 | foreground.setRgb(230,31,31); //0xB2,0x18,0x18 | 634 | foreground.setRgb(230,31,31); //0xB2,0x18,0x18 |
628 | background.setRgb(0x00,0x00,0x00); | 635 | background.setRgb(0x00,0x00,0x00); |
629 | cfg.writeEntry("Schema","10"); | 636 | cfg.writeEntry("Schema","10"); |
630 | colorMenu->setItemChecked(-10,TRUE); | 637 | colorMenu->setItemChecked(-10,TRUE); |
631 | } | 638 | } |
632 | if(iD==-11) {// Green, Yellow - is ugly | 639 | if(iD==-11) {// Green, Yellow - is ugly |
633 | // foreground.setRgb(0x18,0xB2,0x18); | 640 | // foreground.setRgb(0x18,0xB2,0x18); |
634 | foreground.setRgb(36,139,10); | 641 | foreground.setRgb(36,139,10); |
635 | // background.setRgb(0xB2,0x68,0x18); | 642 | // background.setRgb(0xB2,0x68,0x18); |
636 | background.setRgb(255,255,0); | 643 | background.setRgb(255,255,0); |
637 | cfg.writeEntry("Schema","11"); | 644 | cfg.writeEntry("Schema","11"); |
638 | colorMenu->setItemChecked(-11,TRUE); | 645 | colorMenu->setItemChecked(-11,TRUE); |
639 | } | 646 | } |
640 | if(iD==-12) {// Blue, Magenta | 647 | if(iD==-12) {// Blue, Magenta |
641 | foreground.setRgb(0x18,0xB2,0xB2); | 648 | foreground.setRgb(0x18,0xB2,0xB2); |
642 | background.setRgb(0x18,0x18,0xB2); | 649 | background.setRgb(0x18,0x18,0xB2); |
643 | cfg.writeEntry("Schema","12"); | 650 | cfg.writeEntry("Schema","12"); |
644 | colorMenu->setItemChecked(-12,TRUE); | 651 | colorMenu->setItemChecked(-12,TRUE); |
645 | } | 652 | } |
646 | if(iD==-13) {// Magenta, Blue | 653 | if(iD==-13) {// Magenta, Blue |
647 | foreground.setRgb(0x18,0x18,0xB2); | 654 | foreground.setRgb(0x18,0x18,0xB2); |
648 | background.setRgb(0x18,0xB2,0xB2); | 655 | background.setRgb(0x18,0xB2,0xB2); |
649 | cfg.writeEntry("Schema","13"); | 656 | cfg.writeEntry("Schema","13"); |
650 | colorMenu->setItemChecked(-13,TRUE); | 657 | colorMenu->setItemChecked(-13,TRUE); |
651 | } | 658 | } |
652 | if(iD==-14) {// Cyan, White | 659 | if(iD==-14) {// Cyan, White |
653 | foreground.setRgb(0x18,0xB2,0xB2); | 660 | foreground.setRgb(0x18,0xB2,0xB2); |
654 | background.setRgb(0xFF,0xFF,0xFF); | 661 | background.setRgb(0xFF,0xFF,0xFF); |
655 | cfg.writeEntry("Schema","14"); | 662 | cfg.writeEntry("Schema","14"); |
656 | colorMenu->setItemChecked(-14,TRUE); | 663 | colorMenu->setItemChecked(-14,TRUE); |
657 | } | 664 | } |
658 | if(iD==-15) {// White, Cyan | 665 | if(iD==-15) {// White, Cyan |
659 | background.setRgb(0x18,0xB2,0xB2); | 666 | background.setRgb(0x18,0xB2,0xB2); |
660 | foreground.setRgb(0xFF,0xFF,0xFF); | 667 | foreground.setRgb(0xFF,0xFF,0xFF); |
661 | cfg.writeEntry("Schema","15"); | 668 | cfg.writeEntry("Schema","15"); |
662 | colorMenu->setItemChecked(-15,TRUE); | 669 | colorMenu->setItemChecked(-15,TRUE); |
663 | } | 670 | } |
664 | if(iD==-16) {// Black, Blue | 671 | if(iD==-16) {// Black, Blue |
665 | background.setRgb(0x00,0x00,0x00); | 672 | background.setRgb(0x00,0x00,0x00); |
666 | foreground.setRgb(0x18,0xB2,0xB2); | 673 | foreground.setRgb(0x18,0xB2,0xB2); |
667 | cfg.writeEntry("Schema","16"); | 674 | cfg.writeEntry("Schema","16"); |
668 | colorMenu->setItemChecked(-16,TRUE); | 675 | colorMenu->setItemChecked(-16,TRUE); |
669 | } | 676 | } |
670 | 677 | ||
671 | for (i = 0; i < TABLE_COLORS; i++) { | 678 | for (i = 0; i < TABLE_COLORS; i++) { |
672 | if(i==0 || i == 10) { | 679 | if(i==0 || i == 10) { |
673 | m_table[i].color = foreground; | 680 | m_table[i].color = foreground; |
674 | } | 681 | } |
675 | else if(i==1 || i == 11) { | 682 | else if(i==1 || i == 11) { |
676 | m_table[i].color = background; m_table[i].transparent=0; | 683 | m_table[i].color = background; m_table[i].transparent=0; |
677 | } | 684 | } |
678 | else | 685 | else |
679 | m_table[i].color = defaultCt[i].color; | 686 | m_table[i].color = defaultCt[i].color; |
680 | } | 687 | } |
681 | } | 688 | } |
682 | lastSelectedMenu = iD; | 689 | lastSelectedMenu = iD; |
683 | te->setColorTable(m_table); | 690 | te->setColorTable(m_table); |
684 | update(); | 691 | update(); |
685 | } | 692 | } |
686 | 693 | ||
687 | void Konsole::configMenuSelected(int iD) | 694 | void Konsole::configMenuSelected(int iD) |
688 | { | 695 | { |
689 | QString temp; | 696 | QString temp; |
690 | qDebug( temp.sprintf("%d",iD)); | 697 | qDebug( temp.sprintf("%d",iD)); |
691 | TEWidget* te = getTe(); | 698 | TEWidget* te = getTe(); |
692 | Config cfg("Konsole"); | 699 | Config cfg("Konsole"); |
693 | cfg.setGroup("Menubar"); | 700 | cfg.setGroup("Menubar"); |
694 | if( iD == -2) { | 701 | if( iD == -2) { |
695 | if(!secondToolBar->isHidden()) { | 702 | if(!secondToolBar->isHidden()) { |
696 | secondToolBar->hide(); | 703 | secondToolBar->hide(); |
697 | configMenu->changeItem( iD,"Show Command List"); | 704 | configMenu->changeItem( iD,"Show Command List"); |
698 | cfg.writeEntry("Hidden","TRUE"); | 705 | cfg.writeEntry("Hidden","TRUE"); |
699 | configMenu->setItemEnabled(-20 ,FALSE); | 706 | configMenu->setItemEnabled(-20 ,FALSE); |
700 | } else { | 707 | } else { |
701 | secondToolBar->show(); | 708 | secondToolBar->show(); |
702 | configMenu->changeItem( iD,"Hide Command List"); | 709 | configMenu->changeItem( iD,"Hide Command List"); |
703 | cfg.writeEntry("Hidden","FALSE"); | 710 | cfg.writeEntry("Hidden","FALSE"); |
704 | configMenu->setItemEnabled(-20 ,TRUE); | 711 | configMenu->setItemEnabled(-20 ,TRUE); |
705 | 712 | ||
706 | if(cfg.readEntry("EditEnabled","FALSE")=="TRUE") { | 713 | if(cfg.readEntry("EditEnabled","FALSE")=="TRUE") { |
707 | configMenu->setItemChecked(-20,TRUE); | 714 | configMenu->setItemChecked(-20,TRUE); |
708 | commonCombo->setEditable( TRUE ); | 715 | commonCombo->setEditable( TRUE ); |
709 | } else { | 716 | } else { |
710 | configMenu->setItemChecked(-20,FALSE); | 717 | configMenu->setItemChecked(-20,FALSE); |
711 | commonCombo->setEditable( FALSE ); | 718 | commonCombo->setEditable( FALSE ); |
712 | } | 719 | } |
713 | } | 720 | } |
714 | } | 721 | } |
715 | if( iD == -3) { | 722 | if( iD == -3) { |
716 | cfg.setGroup("Tabs"); | 723 | cfg.setGroup("Tabs"); |
717 | QString tmp=cfg.readEntry("Position","Top"); | 724 | QString tmp=cfg.readEntry("Position","Top"); |
718 | 725 | ||
719 | if(tmp=="Top") { | 726 | if(tmp=="Top") { |
720 | tab->setTabPosition(QTabWidget::Bottom); | 727 | tab->setTabPosition(QTabWidget::Bottom); |
721 | configMenu->changeItem( iD,"Tabs on Top"); | 728 | configMenu->changeItem( iD,"Tabs on Top"); |
722 | cfg.writeEntry("Position","Bottom"); | 729 | cfg.writeEntry("Position","Bottom"); |
723 | } else { | 730 | } else { |
724 | tab->setTabPosition(QTabWidget::Top); | 731 | tab->setTabPosition(QTabWidget::Top); |
725 | configMenu->changeItem( iD,"Tabs on Bottom"); | 732 | configMenu->changeItem( iD,"Tabs on Bottom"); |
726 | cfg.writeEntry("Position","Top"); | 733 | cfg.writeEntry("Position","Top"); |
727 | } | 734 | } |
728 | } | 735 | } |
729 | if( iD == -20) { | 736 | if( iD == -20) { |
730 | cfg.setGroup("Commands"); | 737 | cfg.setGroup("Commands"); |
731 | // qDebug("enableCommandEdit"); | 738 | // qDebug("enableCommandEdit"); |
732 | if( !configMenu->isItemChecked(iD) ) { | 739 | if( !configMenu->isItemChecked(iD) ) { |
733 | commonCombo->setEditable( TRUE ); | 740 | commonCombo->setEditable( TRUE ); |
734 | configMenu->setItemChecked(iD,TRUE); | 741 | configMenu->setItemChecked(iD,TRUE); |
735 | commonCombo->setCurrentItem(0); | 742 | commonCombo->setCurrentItem(0); |
736 | cfg.writeEntry("EditEnabled","TRUE"); | 743 | cfg.writeEntry("EditEnabled","TRUE"); |
737 | } else { | 744 | } else { |
738 | commonCombo->setEditable( FALSE ); | 745 | commonCombo->setEditable( FALSE ); |
739 | configMenu->setItemChecked(iD,FALSE); | 746 | configMenu->setItemChecked(iD,FALSE); |
740 | cfg.writeEntry("EditEnabled","FALSE"); | 747 | cfg.writeEntry("EditEnabled","FALSE"); |
741 | commonCombo->setFocusPolicy(QWidget::NoFocus); | 748 | commonCombo->setFocusPolicy(QWidget::NoFocus); |
742 | te->setFocus(); | 749 | te->setFocus(); |
743 | } | 750 | } |
744 | } | 751 | } |
745 | } | 752 | } |
746 | 753 | ||
747 | void Konsole::changeCommand(const QString &text, int c) | 754 | void Konsole::changeCommand(const QString &text, int c) |
748 | { | 755 | { |
749 | Config cfg("Konsole"); | 756 | Config cfg("Konsole"); |
750 | cfg.setGroup("Commands"); | 757 | cfg.setGroup("Commands"); |
751 | if(commonCmds[c] != text) { | 758 | if(commonCmds[c] != text) { |
752 | cfg.writeEntry(QString::number(c),text); | 759 | cfg.writeEntry(QString::number(c),text); |
753 | commonCombo->clearEdit(); | 760 | commonCombo->clearEdit(); |
754 | commonCombo->setCurrentItem(c); | 761 | commonCombo->setCurrentItem(c); |
755 | } | 762 | } |
756 | } | 763 | } |
757 | 764 | ||
758 | void Konsole::setColor() | 765 | void Konsole::setColor() |
759 | { | 766 | { |
760 | Config cfg("Konsole"); | 767 | Config cfg("Konsole"); |
761 | cfg.setGroup("Colors"); | 768 | cfg.setGroup("Colors"); |
762 | int scheme = cfg.readNumEntry("Schema",1); | 769 | int scheme = cfg.readNumEntry("Schema",1); |
763 | if(scheme != 1) colorMenuSelected( -scheme); | 770 | if(scheme != 1) colorMenuSelected( -scheme); |
764 | 771 | ||
765 | } | 772 | } |
773 | |||
774 | void Konsole::scrollMenuSelected(int index) | ||
775 | { | ||
776 | TEWidget* te = getTe(); | ||
777 | Config cfg("Konsole"); | ||
778 | cfg.setGroup("Scrollbar"); | ||
779 | switch( index){ | ||
780 | case -21: | ||
781 | te->setScrollbarLocation(0); | ||
782 | cfg.writeEntry("Position",0); | ||
783 | break; | ||
784 | case -22: | ||
785 | te->setScrollbarLocation(1); | ||
786 | cfg.writeEntry("Position",1); | ||
787 | break; | ||
788 | case -23: | ||
789 | te->setScrollbarLocation(2); | ||
790 | cfg.writeEntry("Position",2); | ||
791 | break; | ||
792 | }; | ||
793 | |||
794 | } | ||
diff --git a/core/apps/embeddedkonsole/konsole.h b/core/apps/embeddedkonsole/konsole.h index 40003d4..b4e5d87 100644 --- a/core/apps/embeddedkonsole/konsole.h +++ b/core/apps/embeddedkonsole/konsole.h | |||
@@ -1,131 +1,131 @@ | |||
1 | /* ----------------------------------------------------------------------- */ | 1 | /* ----------------------------------------------------------------------- */ |
2 | /* */ | 2 | /* */ |
3 | /* [konsole.h] Konsole */ | 3 | /* [konsole.h] Konsole */ |
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. */ | 9 | /* This file is part of Konsole, an X terminal. */ |
10 | /* */ | 10 | /* */ |
11 | /* The material contained in here more or less directly orginates from */ | 11 | /* The material contained in here more or less directly orginates from */ |
12 | /* kvt, which is copyright (c) 1996 by Matthias Ettrich <ettrich@kde.org> */ | 12 | /* kvt, which is copyright (c) 1996 by Matthias Ettrich <ettrich@kde.org> */ |
13 | /* */ | 13 | /* */ |
14 | /* -------------------------------------------------------------------------- */ | 14 | /* -------------------------------------------------------------------------- */ |
15 | /* */ | 15 | /* */ |
16 | /* Ported Konsole to Qt/Embedded */ | 16 | /* Ported Konsole to Qt/Embedded */ |
17 | /* */ | 17 | /* */ |
18 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ | 18 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ |
19 | /* */ | 19 | /* */ |
20 | /* -------------------------------------------------------------------------- */ | 20 | /* -------------------------------------------------------------------------- */ |
21 | 21 | ||
22 | #ifndef KONSOLE_H | 22 | #ifndef KONSOLE_H |
23 | #define KONSOLE_H | 23 | #define KONSOLE_H |
24 | 24 | ||
25 | 25 | ||
26 | #include <qmainwindow.h> | 26 | #include <qmainwindow.h> |
27 | #include <qaction.h> | 27 | #include <qaction.h> |
28 | #include <qpopupmenu.h> | 28 | #include <qpopupmenu.h> |
29 | #include <qstrlist.h> | 29 | #include <qstrlist.h> |
30 | #include <qintdict.h> | 30 | #include <qintdict.h> |
31 | #include <qptrdict.h> | 31 | #include <qptrdict.h> |
32 | #include <qtabwidget.h> | 32 | #include <qtabwidget.h> |
33 | #include <qpe/qpetoolbar.h> | 33 | #include <qpe/qpetoolbar.h> |
34 | #include <qcombobox.h> | 34 | #include <qcombobox.h> |
35 | 35 | ||
36 | #include "MyPty.h" | 36 | #include "MyPty.h" |
37 | #include "TEWidget.h" | 37 | #include "TEWidget.h" |
38 | #include "TEmuVt102.h" | 38 | #include "TEmuVt102.h" |
39 | #include "session.h" | 39 | #include "session.h" |
40 | 40 | ||
41 | class EKNumTabWidget; | 41 | class EKNumTabWidget; |
42 | 42 | ||
43 | class Konsole : public QMainWindow | 43 | class Konsole : public QMainWindow |
44 | { | 44 | { |
45 | Q_OBJECT | 45 | Q_OBJECT |
46 | 46 | ||
47 | public: | 47 | public: |
48 | 48 | ||
49 | Konsole(QWidget* parent = 0, const char* name = 0, WFlags fl = 0); | 49 | Konsole(QWidget* parent = 0, const char* name = 0, WFlags fl = 0); |
50 | Konsole(const char * name, const char* pgm, QStrList & _args, int histon); | 50 | Konsole(const char * name, const char* pgm, QStrList & _args, int histon); |
51 | ~Konsole(); | 51 | ~Konsole(); |
52 | void setColLin(int columns, int lines); | 52 | void setColLin(int columns, int lines); |
53 | QPEToolBar *secondToolBar; | 53 | QPEToolBar *secondToolBar; |
54 | void show(); | 54 | void show(); |
55 | void setColor(); | 55 | void setColor(); |
56 | int lastSelectedMenu; | 56 | int lastSelectedMenu; |
57 | private slots: | 57 | private slots: |
58 | void doneSession(TESession*,int); | 58 | void doneSession(TESession*,int); |
59 | void changeColumns(int); | 59 | void changeColumns(int); |
60 | void fontChanged(int); | 60 | void fontChanged(int); |
61 | void configMenuSelected(int ); | 61 | void configMenuSelected(int ); |
62 | void colorMenuSelected(int); | 62 | void colorMenuSelected(int); |
63 | void enterCommand(int); | 63 | void enterCommand(int); |
64 | void hitEnter(); | 64 | void hitEnter(); |
65 | void hitSpace(); | 65 | void hitSpace(); |
66 | void hitTab(); | 66 | void hitTab(); |
67 | void hitPaste(); | 67 | void hitPaste(); |
68 | void hitUp(); | 68 | void hitUp(); |
69 | void hitDown(); | 69 | void hitDown(); |
70 | void switchSession(QWidget *); | 70 | void switchSession(QWidget *); |
71 | void newSession(); | 71 | void newSession(); |
72 | void changeCommand(const QString &, int); | 72 | void changeCommand(const QString &, int); |
73 | 73 | void scrollMenuSelected(int); | |
74 | private: | 74 | private: |
75 | void init(const char* _pgm, QStrList & _args); | 75 | void init(const char* _pgm, QStrList & _args); |
76 | void initSession(const char* _pgm, QStrList & _args); | 76 | void initSession(const char* _pgm, QStrList & _args); |
77 | void runSession(TESession* s); | 77 | void runSession(TESession* s); |
78 | void setColorPixmaps(); | 78 | void setColorPixmaps(); |
79 | void setHistory(bool); | 79 | void setHistory(bool); |
80 | QSize calcSize(int columns, int lines); | 80 | QSize calcSize(int columns, int lines); |
81 | TEWidget* getTe(); | 81 | TEWidget* getTe(); |
82 | 82 | ||
83 | private: | 83 | private: |
84 | class VTFont | 84 | class VTFont |
85 | { | 85 | { |
86 | public: | 86 | public: |
87 | VTFont(QString name, QFont& font) | 87 | VTFont(QString name, QFont& font) |
88 | { | 88 | { |
89 | this->name = name; | 89 | this->name = name; |
90 | this->font = font; | 90 | this->font = font; |
91 | } | 91 | } |
92 | 92 | ||
93 | QFont& getFont() | 93 | QFont& getFont() |
94 | { | 94 | { |
95 | return font; | 95 | return font; |
96 | } | 96 | } |
97 | 97 | ||
98 | QString getName() | 98 | QString getName() |
99 | { | 99 | { |
100 | return name; | 100 | return name; |
101 | } | 101 | } |
102 | 102 | ||
103 | private: | 103 | private: |
104 | QString name; | 104 | QString name; |
105 | QFont font; | 105 | QFont font; |
106 | }; | 106 | }; |
107 | 107 | ||
108 | EKNumTabWidget* tab; | 108 | EKNumTabWidget* tab; |
109 | int nsessions; | 109 | int nsessions; |
110 | QList<VTFont> fonts; | 110 | QList<VTFont> fonts; |
111 | int cfont; | 111 | int cfont; |
112 | QCString se_pgm; | 112 | QCString se_pgm; |
113 | QStrList se_args; | 113 | QStrList se_args; |
114 | 114 | ||
115 | QPopupMenu* fontList,*configMenu,*colorMenu; | 115 | QPopupMenu* fontList,*configMenu,*colorMenu,*scrollMenu; |
116 | QComboBox *commonCombo; | 116 | QComboBox *commonCombo; |
117 | // history scrolling I think | 117 | // history scrolling I think |
118 | bool b_scroll; | 118 | bool b_scroll; |
119 | 119 | ||
120 | int n_keytab; | 120 | int n_keytab; |
121 | int n_scroll; | 121 | int n_scroll; |
122 | int n_render; | 122 | int n_render; |
123 | QString pmPath; // pixmap path | 123 | QString pmPath; // pixmap path |
124 | QString dropText; | 124 | QString dropText; |
125 | QFont defaultFont; | 125 | QFont defaultFont; |
126 | QSize defaultSize; | 126 | QSize defaultSize; |
127 | 127 | ||
128 | }; | 128 | }; |
129 | 129 | ||
130 | #endif | 130 | #endif |
131 | 131 | ||