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