summaryrefslogtreecommitdiff
authordrw <drw>2004-04-06 15:52:02 (UTC)
committer drw <drw>2004-04-06 15:52:02 (UTC)
commit31a82304d62ab4943c0926c35cce552e2164eaf4 (patch) (unidiff)
tree9c87a50ef57475a765dc16c26100372026dbdda2
parente97648cdac8aba383e69e87c2d60644eb3bcc18d (diff)
downloadopie-31a82304d62ab4943c0926c35cce552e2164eaf4.zip
opie-31a82304d62ab4943c0926c35cce552e2164eaf4.tar.gz
opie-31a82304d62ab4943c0926c35cce552e2164eaf4.tar.bz2
Do not override menu font size, use font as defined in Appearance settings, and fixed compiler warning
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/embeddedkonsole/TEWidget.cpp4
-rw-r--r--core/apps/embeddedkonsole/konsole.cpp9
2 files changed, 2 insertions, 11 deletions
diff --git a/core/apps/embeddedkonsole/TEWidget.cpp b/core/apps/embeddedkonsole/TEWidget.cpp
index cc88555..93348f4 100644
--- a/core/apps/embeddedkonsole/TEWidget.cpp
+++ b/core/apps/embeddedkonsole/TEWidget.cpp
@@ -1,1429 +1,1429 @@
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 55
56#if !(QT_NO_COP) 56#if !(QT_NO_COP)
57#include <qpe/qcopenvelope_qws.h> 57#include <qpe/qcopenvelope_qws.h>
58#endif 58#endif
59 59
60#include <qclipboard.h> 60#include <qclipboard.h>
61 61
62#ifndef QT_NO_DRAGANDDROP 62#ifndef QT_NO_DRAGANDDROP
63#include <qdragobject.h> 63#include <qdragobject.h>
64#include <qfile.h> 64#include <qfile.h>
65#endif 65#endif
66 66
67#include <stdio.h> 67#include <stdio.h>
68#include <stdlib.h> 68#include <stdlib.h>
69#include <unistd.h> 69#include <unistd.h>
70#include <ctype.h> 70#include <ctype.h>
71#include <sys/stat.h> 71#include <sys/stat.h>
72#include <sys/types.h> 72#include <sys/types.h>
73#include <signal.h> 73#include <signal.h>
74 74
75#include <assert.h> 75#include <assert.h>
76 76
77// #include "TEWidget.moc" 77// #include "TEWidget.moc"
78//#include <kapp.h> 78//#include <kapp.h>
79//#include <kcursor.h> 79//#include <kcursor.h>
80//#include <kurl.h> 80//#include <kurl.h>
81//#include <kdebug.h> 81//#include <kdebug.h>
82//#include <klocale.h> 82//#include <klocale.h>
83 83
84#define HERE printf("%s(%d): %s\n",__FILE__,__LINE__,__FUNCTION__) 84#define HERE printf("%s(%d): %s\n",__FILE__,__LINE__,__FUNCTION__)
85#define HCNT(Name) // { static int cnt = 1; printf("%s(%d): %s %d\n",__FILE__,__LINE__,Name,cnt++); } 85#define HCNT(Name) // { static int cnt = 1; printf("%s(%d): %s %d\n",__FILE__,__LINE__,Name,cnt++); }
86 86
87#define loc(X,Y) ((Y)*columns+(X)) 87#define loc(X,Y) ((Y)*columns+(X))
88 88
89//FIXME: the rim should normally be 1, 0 only when running in full screen mode. 89//FIXME: the rim should normally be 1, 0 only when running in full screen mode.
90#define rimX 0 // left/right rim width 90#define rimX 0 // left/right rim width
91#define rimY 0 // top/bottom rim high 91#define rimY 0 // top/bottom rim high
92 92
93#define SCRWIDTH 16 // width of the scrollbar 93#define SCRWIDTH 16 // width of the scrollbar
94 94
95#define yMouseScroll 1 95#define yMouseScroll 1
96// scroll increment used when dragging selection at top/bottom of window. 96// scroll increment used when dragging selection at top/bottom of window.
97 97
98/* ------------------------------------------------------------------------- */ 98/* ------------------------------------------------------------------------- */
99/* */ 99/* */
100/* Colors */ 100/* Colors */
101/* */ 101/* */
102/* ------------------------------------------------------------------------- */ 102/* ------------------------------------------------------------------------- */
103 103
104//FIXME: the default color table is in session.C now. 104//FIXME: the default color table is in session.C now.
105// We need a way to get rid of this one, here. 105// We need a way to get rid of this one, here.
106static const ColorEntry base_color_table[TABLE_COLORS] = 106static const ColorEntry base_color_table[TABLE_COLORS] =
107// The following are almost IBM standard color codes, with some slight 107// The following are almost IBM standard color codes, with some slight
108// gamma correction for the dim colors to compensate for bright X screens. 108// gamma correction for the dim colors to compensate for bright X screens.
109// It contains the 8 ansiterm/xterm colors in 2 intensities. 109// It contains the 8 ansiterm/xterm colors in 2 intensities.
110{ 110{
111 // Fixme: could add faint colors here, also. 111 // Fixme: could add faint colors here, also.
112 // normal 112 // normal
113 ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 1, 0 ), // Dfore, Dback 113 ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 1, 0 ), // Dfore, Dback
114 ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0x18), 0, 0 ), // Black, Red 114 ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0x18), 0, 0 ), // Black, Red
115 ColorEntry(QColor(0x18,0xB2,0x18), 0, 0 ), ColorEntry( QColor(0xB2,0x68,0x18), 0, 0 ), // Green, Yellow 115 ColorEntry(QColor(0x18,0xB2,0x18), 0, 0 ), ColorEntry( QColor(0xB2,0x68,0x18), 0, 0 ), // Green, Yellow
116 ColorEntry(QColor(0x18,0x18,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), // Blue, Magenta 116 ColorEntry(QColor(0x18,0x18,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), // Blue, Magenta
117 ColorEntry(QColor(0x18,0xB2,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 0, 0 ), // Cyan, White 117 ColorEntry(QColor(0x18,0xB2,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 0, 0 ), // Cyan, White
118 // intensiv 118 // intensiv
119 ColorEntry(QColor(0x00,0x00,0x00), 0, 1 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 1, 0 ), 119 ColorEntry(QColor(0x00,0x00,0x00), 0, 1 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 1, 0 ),
120 ColorEntry(QColor(0x68,0x68,0x68), 0, 0 ), ColorEntry( QColor(0xFF,0x54,0x54), 0, 0 ), 120 ColorEntry(QColor(0x68,0x68,0x68), 0, 0 ), ColorEntry( QColor(0xFF,0x54,0x54), 0, 0 ),
121 ColorEntry(QColor(0x54,0xFF,0x54), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0x54), 0, 0 ), 121 ColorEntry(QColor(0x54,0xFF,0x54), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0x54), 0, 0 ),
122 ColorEntry(QColor(0x54,0x54,0xFF), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), 122 ColorEntry(QColor(0x54,0x54,0xFF), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ),
123 ColorEntry(QColor(0x54,0xFF,0xFF), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 0, 0 ) 123 ColorEntry(QColor(0x54,0xFF,0xFF), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 0, 0 )
124}; 124};
125 125
126/* Note that we use ANSI color order (bgr), while IBMPC color order is (rgb) 126/* Note that we use ANSI color order (bgr), while IBMPC color order is (rgb)
127 127
128 Code 0 1 2 3 4 5 6 7 128 Code 0 1 2 3 4 5 6 7
129 ----------- ------- ------- ------- ------- ------- ------- ------- ------- 129 ----------- ------- ------- ------- ------- ------- ------- ------- -------
130 ANSI (bgr) Black Red Green Yellow Blue Magenta Cyan White 130 ANSI (bgr) Black Red Green Yellow Blue Magenta Cyan White
131 IBMPC (rgb) Black Blue Green Cyan Red Magenta Yellow White 131 IBMPC (rgb) Black Blue Green Cyan Red Magenta Yellow White
132*/ 132*/
133 133
134QColor TEWidget::getDefaultBackColor() 134QColor TEWidget::getDefaultBackColor()
135{ 135{
136 return color_table[DEFAULT_BACK_COLOR].color; 136 return color_table[DEFAULT_BACK_COLOR].color;
137} 137}
138 138
139const ColorEntry* TEWidget::getColorTable() const 139const ColorEntry* TEWidget::getColorTable() const
140{ 140{
141 return color_table; 141 return color_table;
142} 142}
143 143
144const ColorEntry* TEWidget::getdefaultColorTable() const 144const ColorEntry* TEWidget::getdefaultColorTable() const
145{ 145{
146 return base_color_table; 146 return base_color_table;
147} 147}
148 148
149 149
150const QPixmap *TEWidget::backgroundPixmap() 150const QPixmap *TEWidget::backgroundPixmap()
151{ 151{
152 static QPixmap *bg = new QPixmap("~/qpim/main/pics/faded_bg.xpm"); 152 static QPixmap *bg = new QPixmap("~/qpim/main/pics/faded_bg.xpm");
153 const QPixmap *pm = bg; 153 const QPixmap *pm = bg;
154 return pm; 154 return pm;
155} 155}
156 156
157void TEWidget::setColorTable(const ColorEntry table[]) 157void TEWidget::setColorTable(const ColorEntry table[])
158{ 158{
159 for (int i = 0; i < TABLE_COLORS; i++) color_table[i] = table[i]; 159 for (int i = 0; i < TABLE_COLORS; i++) color_table[i] = table[i];
160 160
161 const QPixmap* pm = backgroundPixmap(); 161 const QPixmap* pm = backgroundPixmap();
162 if (!pm) setBackgroundColor(color_table[DEFAULT_BACK_COLOR].color); 162 if (!pm) setBackgroundColor(color_table[DEFAULT_BACK_COLOR].color);
163 update(); 163 update();
164} 164}
165 165
166//FIXME: add backgroundPixmapChanged. 166//FIXME: add backgroundPixmapChanged.
167 167
168/* ------------------------------------------------------------------------- */ 168/* ------------------------------------------------------------------------- */
169/* */ 169/* */
170/* Font */ 170/* Font */
171/* */ 171/* */
172/* ------------------------------------------------------------------------- */ 172/* ------------------------------------------------------------------------- */
173 173
174/* 174/*
175 The VT100 has 32 special graphical characters. The usual vt100 extended 175 The VT100 has 32 special graphical characters. The usual vt100 extended
176 xterm fonts have these at 0x00..0x1f. 176 xterm fonts have these at 0x00..0x1f.
177 177
178 QT's iso mapping leaves 0x00..0x7f without any changes. But the graphicals 178 QT's iso mapping leaves 0x00..0x7f without any changes. But the graphicals
179 come in here as proper unicode characters. 179 come in here as proper unicode characters.
180 180
181 We treat non-iso10646 fonts as VT100 extended and do the requiered mapping 181 We treat non-iso10646 fonts as VT100 extended and do the requiered mapping
182 from unicode to 0x00..0x1f. The remaining translation is then left to the 182 from unicode to 0x00..0x1f. The remaining translation is then left to the
183 QCodec. 183 QCodec.
184*/ 184*/
185 185
186// assert for i in [0..31] : vt100extended(vt100_graphics[i]) == i. 186// assert for i in [0..31] : vt100extended(vt100_graphics[i]) == i.
187 187
188unsigned short vt100_graphics[32] = 188unsigned short vt100_graphics[32] =
189{ // 0/8 1/9 2/10 3/11 4/12 5/13 6/14 7/15 189{ // 0/8 1/9 2/10 3/11 4/12 5/13 6/14 7/15
190 0x0020, 0x25C6, 0x2592, 0x2409, 0x240c, 0x240d, 0x240a, 0x00b0, 190 0x0020, 0x25C6, 0x2592, 0x2409, 0x240c, 0x240d, 0x240a, 0x00b0,
191 0x00b1, 0x2424, 0x240b, 0x2518, 0x2510, 0x250c, 0x2514, 0x253c, 191 0x00b1, 0x2424, 0x240b, 0x2518, 0x2510, 0x250c, 0x2514, 0x253c,
192 0xF800, 0xF801, 0x2500, 0xF803, 0xF804, 0x251c, 0x2524, 0x2534, 192 0xF800, 0xF801, 0x2500, 0xF803, 0xF804, 0x251c, 0x2524, 0x2534,
193 0x252c, 0x2502, 0x2264, 0x2265, 0x03C0, 0x2260, 0x00A3, 0x00b7 193 0x252c, 0x2502, 0x2264, 0x2265, 0x03C0, 0x2260, 0x00A3, 0x00b7
194}; 194};
195 195
196static QChar vt100extended(QChar c) 196static QChar vt100extended(QChar c)
197{ 197{
198 switch (c.unicode()) 198 switch (c.unicode())
199 { 199 {
200 case 0x25c6 : return 1; 200 case 0x25c6 : return 1;
201 case 0x2592 : return 2; 201 case 0x2592 : return 2;
202 case 0x2409 : return 3; 202 case 0x2409 : return 3;
203 case 0x240c : return 4; 203 case 0x240c : return 4;
204 case 0x240d : return 5; 204 case 0x240d : return 5;
205 case 0x240a : return 6; 205 case 0x240a : return 6;
206 case 0x00b0 : return 7; 206 case 0x00b0 : return 7;
207 case 0x00b1 : return 8; 207 case 0x00b1 : return 8;
208 case 0x2424 : return 9; 208 case 0x2424 : return 9;
209 case 0x240b : return 10; 209 case 0x240b : return 10;
210 case 0x2518 : return 11; 210 case 0x2518 : return 11;
211 case 0x2510 : return 12; 211 case 0x2510 : return 12;
212 case 0x250c : return 13; 212 case 0x250c : return 13;
213 case 0x2514 : return 14; 213 case 0x2514 : return 14;
214 case 0x253c : return 15; 214 case 0x253c : return 15;
215 case 0xf800 : return 16; 215 case 0xf800 : return 16;
216 case 0xf801 : return 17; 216 case 0xf801 : return 17;
217 case 0x2500 : return 18; 217 case 0x2500 : return 18;
218 case 0xf803 : return 19; 218 case 0xf803 : return 19;
219 case 0xf804 : return 20; 219 case 0xf804 : return 20;
220 case 0x251c : return 21; 220 case 0x251c : return 21;
221 case 0x2524 : return 22; 221 case 0x2524 : return 22;
222 case 0x2534 : return 23; 222 case 0x2534 : return 23;
223 case 0x252c : return 24; 223 case 0x252c : return 24;
224 case 0x2502 : return 25; 224 case 0x2502 : return 25;
225 case 0x2264 : return 26; 225 case 0x2264 : return 26;
226 case 0x2265 : return 27; 226 case 0x2265 : return 27;
227 case 0x03c0 : return 28; 227 case 0x03c0 : return 28;
228 case 0x2260 : return 29; 228 case 0x2260 : return 29;
229 case 0x00a3 : return 30; 229 case 0x00a3 : return 30;
230 case 0x00b7 : return 31; 230 case 0x00b7 : return 31;
231 } 231 }
232 return c; 232 return c;
233} 233}
234 234
235static QChar identicalMap(QChar c) 235static QChar identicalMap(QChar c)
236{ 236{
237 return c; 237 return c;
238} 238}
239 239
240void TEWidget::fontChange(const QFont &) 240void TEWidget::fontChange(const QFont &)
241{ 241{
242 QFontMetrics fm(font()); 242 QFontMetrics fm(font());
243 font_h = fm.height(); 243 font_h = fm.height();
244 // font_w = fm.maxWidth(); 244 // font_w = fm.maxWidth();
245 font_w = fm.width("m"); 245 font_w = fm.width("m");
246 font_a = fm.ascent(); 246 font_a = fm.ascent();
247 printf("font h=%d max_width=%d width_m=%d assent=%d\n", font_h, 247 printf("font h=%d max_width=%d width_m=%d assent=%d\n", font_h,
248 fm.maxWidth(), font_w, font_a); 248 fm.maxWidth(), font_w, font_a);
249 249
250 //printf("font_h: %d\n",font_h); 250 //printf("font_h: %d\n",font_h);
251 //printf("font_w: %d\n",font_w); 251 //printf("font_w: %d\n",font_w);
252 //printf("font_a: %d\n",font_a); 252 //printf("font_a: %d\n",font_a);
253 //printf("charset: %s\n",QFont::encodingName(font().charSet()).ascii()); 253 //printf("charset: %s\n",QFont::encodingName(font().charSet()).ascii());
254 //printf("rawname: %s\n",font().rawName().ascii()); 254 //printf("rawname: %s\n",font().rawName().ascii());
255 fontMap = 255 fontMap =
256#if QT_VERSION < 300 256#if QT_VERSION < 300
257 strcmp(QFont::encodingName(font().charSet()).ascii(),"iso10646") 257 strcmp(QFont::encodingName(font().charSet()).ascii(),"iso10646")
258 ? vt100extended 258 ? vt100extended
259 : 259 :
260#endif 260#endif
261 identicalMap; 261 identicalMap;
262 propagateSize(); 262 propagateSize();
263 update(); 263 update();
264} 264}
265 265
266void TEWidget::setVTFont(const QFont& f) 266void TEWidget::setVTFont(const QFont& f)
267{ 267{
268 QFrame::setFont(f); 268 QFrame::setFont(f);
269} 269}
270 270
271QFont TEWidget::getVTFont() { 271QFont TEWidget::getVTFont() {
272 return font(); 272 return font();
273} 273}
274 274
275void TEWidget::setFont(const QFont &) 275void TEWidget::setFont(const QFont &)
276{ 276{
277 // ignore font change request if not coming from konsole itself 277 // ignore font change request if not coming from konsole itself
278} 278}
279 279
280/* ------------------------------------------------------------------------- */ 280/* ------------------------------------------------------------------------- */
281/* */ 281/* */
282/* Constructor / Destructor */ 282/* Constructor / Destructor */
283/* */ 283/* */
284/* ------------------------------------------------------------------------- */ 284/* ------------------------------------------------------------------------- */
285 285
286TEWidget::TEWidget(QWidget *parent, const char *name) : QFrame(parent,name) 286TEWidget::TEWidget(QWidget *parent, const char *name) : QFrame(parent,name)
287{ 287{
288#ifndef QT_NO_CLIPBOARD 288#ifndef QT_NO_CLIPBOARD
289 cb = QApplication::clipboard(); 289 cb = QApplication::clipboard();
290 QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), 290 QObject::connect( (QObject*)cb, SIGNAL(dataChanged()),
291 this, SLOT(onClearSelection()) ); 291 this, SLOT(onClearSelection()) );
292#endif 292#endif
293 293
294 scrollbar = new QScrollBar(this); 294 scrollbar = new QScrollBar(this);
295 scrollbar->setCursor( arrowCursor ); 295 scrollbar->setCursor( arrowCursor );
296 connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); 296 connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int)));
297 297
298 hScrollbar = new QScrollBar(this); 298 hScrollbar = new QScrollBar(this);
299 hScrollbar->setCursor( arrowCursor ); 299 hScrollbar->setCursor( arrowCursor );
300 hScrollbar->setOrientation(QScrollBar::Horizontal); 300 hScrollbar->setOrientation(QScrollBar::Horizontal);
301 // hScrollbar->setMaximumHeight(16); 301 // hScrollbar->setMaximumHeight(16);
302 302
303 connect( hScrollbar, SIGNAL(valueChanged(int)), this, SLOT( hScrollChanged(int))); 303 connect( hScrollbar, SIGNAL(valueChanged(int)), this, SLOT( hScrollChanged(int)));
304 304
305 Config cfg( "Konsole" ); 305 Config cfg( "Konsole" );
306 cfg.setGroup("ScrollBar"); 306 cfg.setGroup("ScrollBar");
307 switch( cfg.readNumEntry("Position",2)){ 307 switch( cfg.readNumEntry("Position",2)){
308 case 0: 308 case 0:
309 scrollLoc = SCRNONE; 309 scrollLoc = SCRNONE;
310 break; 310 break;
311 case 1: 311 case 1:
312 scrollLoc = SCRLEFT; 312 scrollLoc = SCRLEFT;
313 break; 313 break;
314 case 2: 314 case 2:
315 scrollLoc = SCRRIGHT; 315 scrollLoc = SCRRIGHT;
316 break; 316 break;
317 }; 317 };
318 318
319 useHorzScroll=cfg.readBoolEntry("HorzScroll",0); 319 useHorzScroll=cfg.readBoolEntry("HorzScroll",0);
320 320
321 blinkT = new QTimer(this); 321 blinkT = new QTimer(this);
322 connect(blinkT, SIGNAL(timeout()), this, SLOT(blinkEvent())); 322 connect(blinkT, SIGNAL(timeout()), this, SLOT(blinkEvent()));
323 // blinking = FALSE; 323 // blinking = FALSE;
324 blinking = TRUE; 324 blinking = TRUE;
325 325
326 resizing = FALSE; 326 resizing = FALSE;
327 actSel = 0; 327 actSel = 0;
328 image = 0; 328 image = 0;
329 lines = 1; 329 lines = 1;
330 columns = 1; 330 columns = 1;
331 font_w = 1; 331 font_w = 1;
332 font_h = 1; 332 font_h = 1;
333 font_a = 1; 333 font_a = 1;
334 word_selection_mode = FALSE; 334 word_selection_mode = FALSE;
335 hposition = 0; 335 hposition = 0;
336 vcolumns = 0; 336 vcolumns = 0;
337 useBeep = true; 337 useBeep = true;
338 338
339 setMouseMarks(TRUE); 339 setMouseMarks(TRUE);
340 setVTFont( QFont("fixed") ); 340 setVTFont( QFont("fixed") );
341 setColorTable(base_color_table); // init color table 341 setColorTable(base_color_table); // init color table
342 342
343 qApp->installEventFilter( this ); //FIXME: see below 343 qApp->installEventFilter( this ); //FIXME: see below
344// KCursor::setAutoHideCursor( this, true ); 344// KCursor::setAutoHideCursor( this, true );
345 345
346 // Init DnD //////////////////////////////////////////////////////////////// 346 // Init DnD ////////////////////////////////////////////////////////////////
347 currentSession = NULL; 347 currentSession = NULL;
348// setAcceptDrops(true); // attempt 348// setAcceptDrops(true); // attempt
349// m_drop = new QPopupMenu(this); 349// m_drop = new QPopupMenu(this);
350// m_drop->insertItem( QString("Paste"), 0); 350// m_drop->insertItem( QString("Paste"), 0);
351// m_drop->insertItem( QString("cd"), 1); 351// m_drop->insertItem( QString("cd"), 1);
352// connect(m_drop, SIGNAL(activated(int)), SLOT(drop_menu_activated(int))); 352// connect(m_drop, SIGNAL(activated(int)), SLOT(drop_menu_activated(int)));
353 353
354 // we need focus so that the auto-hide cursor feature works 354 // we need focus so that the auto-hide cursor feature works
355 setFocus(); 355 setFocus();
356 setFocusPolicy( WheelFocus ); 356 setFocusPolicy( WheelFocus );
357} 357}
358 358
359//FIXME: make proper destructor 359//FIXME: make proper destructor
360// Here's a start (David) 360// Here's a start (David)
361TEWidget::~TEWidget() 361TEWidget::~TEWidget()
362{ 362{
363 qApp->removeEventFilter( this ); 363 qApp->removeEventFilter( this );
364 if (image) free(image); 364 if (image) free(image);
365} 365}
366 366
367/* ------------------------------------------------------------------------- */ 367/* ------------------------------------------------------------------------- */
368/* */ 368/* */
369/* Display Operations */ 369/* Display Operations */
370/* */ 370/* */
371/* ------------------------------------------------------------------------- */ 371/* ------------------------------------------------------------------------- */
372 372
373/*! 373/*!
374 attributed string draw primitive 374 attributed string draw primitive
375*/ 375*/
376 376
377void TEWidget::drawAttrStr(QPainter &paint, QRect rect, 377void TEWidget::drawAttrStr(QPainter &paint, QRect rect,
378 QString& str, ca attr, BOOL pm, BOOL clear) 378 QString& str, ca attr, BOOL pm, BOOL clear)
379{ 379{
380 if (pm && color_table[attr.b].transparent) 380 if (pm && color_table[attr.b].transparent)
381 { 381 {
382 paint.setBackgroundMode( TransparentMode ); 382 paint.setBackgroundMode( TransparentMode );
383 if (clear) erase(rect); 383 if (clear) erase(rect);
384 } 384 }
385 else 385 else
386 { 386 {
387 if (blinking) 387 if (blinking)
388 paint.fillRect(rect, color_table[attr.b].color); 388 paint.fillRect(rect, color_table[attr.b].color);
389 else 389 else
390 { 390 {
391 paint.setBackgroundMode( OpaqueMode ); 391 paint.setBackgroundMode( OpaqueMode );
392 paint.setBackgroundColor( color_table[attr.b].color ); 392 paint.setBackgroundColor( color_table[attr.b].color );
393 } 393 }
394 } 394 }
395 395
396 if (color_table[attr.f].bold) 396 if (color_table[attr.f].bold)
397 paint.setPen(QColor( 0x8F, 0x00, 0x00 )); 397 paint.setPen(QColor( 0x8F, 0x00, 0x00 ));
398 else 398 else
399 paint.setPen(color_table[attr.f].color); 399 paint.setPen(color_table[attr.f].color);
400 400
401 paint.drawText(rect.x(),rect.y()+font_a, str); 401 paint.drawText(rect.x(),rect.y()+font_a, str);
402 402
403 if (attr.r & RE_UNDERLINE) 403 if (attr.r & RE_UNDERLINE)
404 paint.drawLine(rect.left(), rect.y()+font_a+1, rect.right(),rect.y()+font_a+1 ); 404 paint.drawLine(rect.left(), rect.y()+font_a+1, rect.right(),rect.y()+font_a+1 );
405} 405}
406 406
407/*! 407/*!
408 The image can only be set completely. 408 The image can only be set completely.
409 409
410 The size of the new image may or may not match the size of the widget. 410 The size of the new image may or may not match the size of the widget.
411*/ 411*/
412 412
413void TEWidget::setImage(const ca* const newimg, int lines, int columns) 413void TEWidget::setImage(const ca* const newimg, int lines, int columns)
414{ int y,x,len; 414{ int y,x,len;
415 const QPixmap* pm = backgroundPixmap(); 415 const QPixmap* pm = backgroundPixmap();
416 QPainter paint; 416 QPainter paint;
417 setUpdatesEnabled(FALSE); 417 setUpdatesEnabled(FALSE);
418 paint.begin( this ); 418 paint.begin( this );
419HCNT("setImage"); 419HCNT("setImage");
420 420
421 QPoint tL = contentsRect().topLeft(); 421 QPoint tL = contentsRect().topLeft();
422 int tLx = tL.x(); 422 int tLx = tL.x();
423 int tLy = tL.y(); 423 int tLy = tL.y();
424 hasBlinker = FALSE; 424 hasBlinker = FALSE;
425 425
426 int cf = -1; // undefined 426 int cf = -1; // undefined
427 int cb = -1; // undefined 427 int cb = -1; // undefined
428 int cr = -1; // undefined 428 int cr = -1; // undefined
429 429
430 int lins = QMIN(this->lines, QMAX(0,lines )); 430 int lins = QMIN(this->lines, QMAX(0,lines ));
431 int cols = QMIN(this->columns,QMAX(0,columns)); 431 int cols = QMIN(this->columns,QMAX(0,columns));
432 QChar *disstrU = new QChar[cols]; 432 QChar *disstrU = new QChar[cols];
433 for (y = 0; y < lins; y++) { 433 for (y = 0; y < lins; y++) {
434 const ca* lcl = &image[y*this->columns]; 434 const ca* lcl = &image[y*this->columns];
435 const ca* const ext = &newimg[y*columns]; 435 const ca* const ext = &newimg[y*columns];
436 if (!resizing) // not while resizing, we're expecting a paintEvent 436 if (!resizing) // not while resizing, we're expecting a paintEvent
437 for (x = 0; x < cols; x++) 437 for (x = 0; x < cols; x++)
438 { 438 {
439 hasBlinker |= (ext[x].r & RE_BLINK); 439 hasBlinker |= (ext[x].r & RE_BLINK);
440 if (ext[x] != lcl[x]) 440 if (ext[x] != lcl[x])
441 { 441 {
442 cr = ext[x].r; 442 cr = ext[x].r;
443 cb = ext[x].b; 443 cb = ext[x].b;
444 if (ext[x].f != cf) cf = ext[x].f; 444 if (ext[x].f != cf) cf = ext[x].f;
445 int lln = cols - x; 445 int lln = cols - x;
446 disstrU[0] = fontMap(ext[x+0].c); 446 disstrU[0] = fontMap(ext[x+0].c);
447 for (len = 1; len < lln; len++) 447 for (len = 1; len < lln; len++)
448 { 448 {
449 if (ext[x+len].f != cf || ext[x+len].b != cb || ext[x+len].r != cr || 449 if (ext[x+len].f != cf || ext[x+len].b != cb || ext[x+len].r != cr ||
450 ext[x+len] == lcl[x+len] ) 450 ext[x+len] == lcl[x+len] )
451 break; 451 break;
452 disstrU[len] = fontMap(ext[x+len].c); 452 disstrU[len] = fontMap(ext[x+len].c);
453 } 453 }
454 QString unistr(disstrU,len); 454 QString unistr(disstrU,len);
455 drawAttrStr(paint, 455 drawAttrStr(paint,
456 QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h), 456 QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h),
457 unistr, ext[x], pm != NULL, true); 457 unistr, ext[x], pm != NULL, true);
458 x += len - 1; 458 x += len - 1;
459 } 459 }
460 } 460 }
461 // finally, make `image' become `newimg'. 461 // finally, make `image' become `newimg'.
462 memcpy((void*)lcl,(const void*)ext,cols*sizeof(ca)); 462 memcpy((void*)lcl,(const void*)ext,cols*sizeof(ca));
463 } 463 }
464 drawFrame( &paint ); 464 drawFrame( &paint );
465 paint.end(); 465 paint.end();
466 setUpdatesEnabled(TRUE); 466 setUpdatesEnabled(TRUE);
467 if ( hasBlinker && !blinkT->isActive()) blinkT->start(1000); // 1000 ms 467 if ( hasBlinker && !blinkT->isActive()) blinkT->start(1000); // 1000 ms
468 if (!hasBlinker && blinkT->isActive()) { blinkT->stop(); blinking = FALSE; } 468 if (!hasBlinker && blinkT->isActive()) { blinkT->stop(); blinking = FALSE; }
469 delete [] disstrU; 469 delete [] disstrU;
470} 470}
471 471
472// paint Event //////////////////////////////////////////////////// 472// paint Event ////////////////////////////////////////////////////
473 473
474/*! 474/*!
475 The difference of this routine vs. the `setImage' is, 475 The difference of this routine vs. the `setImage' is,
476 that the drawing does not include a difference analysis 476 that the drawing does not include a difference analysis
477 between the old and the new image. Instead, the internal 477 between the old and the new image. Instead, the internal
478 image is used and the painting bound by the PaintEvent box. 478 image is used and the painting bound by the PaintEvent box.
479*/ 479*/
480 480
481void TEWidget::paintEvent( QPaintEvent* pe ) 481void TEWidget::paintEvent( QPaintEvent* pe )
482{ 482{
483 483
484//{ static int cnt = 0; printf("paint %d\n",cnt++); } 484//{ static int cnt = 0; printf("paint %d\n",cnt++); }
485 const QPixmap* pm = backgroundPixmap(); 485 const QPixmap* pm = backgroundPixmap();
486 QPainter paint; 486 QPainter paint;
487 setUpdatesEnabled(FALSE); 487 setUpdatesEnabled(FALSE);
488 paint.begin( this ); 488 paint.begin( this );
489 paint.setBackgroundMode( TransparentMode ); 489 paint.setBackgroundMode( TransparentMode );
490HCNT("paintEvent"); 490HCNT("paintEvent");
491 491
492 // Note that the actual widget size can be slightly larger 492 // Note that the actual widget size can be slightly larger
493 // that the image (the size is truncated towards the smaller 493 // that the image (the size is truncated towards the smaller
494 // number of characters in `resizeEvent'. The paint rectangle 494 // number of characters in `resizeEvent'. The paint rectangle
495 // can thus be larger than the image, but less then the size 495 // can thus be larger than the image, but less then the size
496 // of one character. 496 // of one character.
497 497
498 QRect rect = pe->rect().intersect(contentsRect()); 498 QRect rect = pe->rect().intersect(contentsRect());
499 499
500 QPoint tL = contentsRect().topLeft(); 500 QPoint tL = contentsRect().topLeft();
501 int tLx = tL.x(); 501 int tLx = tL.x();
502 int tLy = tL.y(); 502 int tLy = tL.y();
503 503
504 int lux = QMIN(columns-1, QMAX(0,(rect.left() - tLx - blX ) / font_w)); 504 int lux = QMIN(columns-1, QMAX(0,(rect.left() - tLx - blX ) / font_w));
505 int luy = QMIN(lines-1, QMAX(0,(rect.top() - tLy - bY ) / font_h)); 505 int luy = QMIN(lines-1, QMAX(0,(rect.top() - tLy - bY ) / font_h));
506 int rlx = QMIN(columns-1, QMAX(0,(rect.right() - tLx - blX ) / font_w)); 506 int rlx = QMIN(columns-1, QMAX(0,(rect.right() - tLx - blX ) / font_w));
507 int rly = QMIN(lines-1, QMAX(0,(rect.bottom() - tLy - bY ) / font_h)); 507 int rly = QMIN(lines-1, QMAX(0,(rect.bottom() - tLy - bY ) / font_h));
508 508
509 /* 509 /*
510 printf("paintEvent: %d..%d, %d..%d (%d..%d, %d..%d)\n",lux,rlx,luy,rly, 510 printf("paintEvent: %d..%d, %d..%d (%d..%d, %d..%d)\n",lux,rlx,luy,rly,
511 rect.left(), rect.right(), rect.top(), rect.bottom()); 511 rect.left(), rect.right(), rect.top(), rect.bottom());
512 */ 512 */
513 513
514 // if (pm != NULL && color_table[image->b].transparent) 514 // if (pm != NULL && color_table[image->b].transparent)
515 // erase(rect); 515 // erase(rect);
516 // BL: I have no idea why we need this, and it breaks the refresh. 516 // BL: I have no idea why we need this, and it breaks the refresh.
517 517
518 QChar *disstrU = new QChar[columns]; 518 QChar *disstrU = new QChar[columns];
519 for (int y = luy; y <= rly; y++) 519 for (int y = luy; y <= rly; y++)
520 for (int x = lux; x <= rlx; x++) 520 for (int x = lux; x <= rlx; x++)
521 { 521 {
522 int len = 1; 522 int len = 1;
523 disstrU[0] = fontMap(image[loc(x,y)].c); 523 disstrU[0] = fontMap(image[loc(x,y)].c);
524 int cf = image[loc(x,y)].f; 524 int cf = image[loc(x,y)].f;
525 int cb = image[loc(x,y)].b; 525 int cb = image[loc(x,y)].b;
526 int cr = image[loc(x,y)].r; 526 int cr = image[loc(x,y)].r;
527 while (x+len <= rlx && 527 while (x+len <= rlx &&
528 image[loc(x+len,y)].f == cf && 528 image[loc(x+len,y)].f == cf &&
529 image[loc(x+len,y)].b == cb && 529 image[loc(x+len,y)].b == cb &&
530 image[loc(x+len,y)].r == cr ) 530 image[loc(x+len,y)].r == cr )
531 { 531 {
532 disstrU[len] = fontMap(image[loc(x+len,y)].c); 532 disstrU[len] = fontMap(image[loc(x+len,y)].c);
533 len += 1; 533 len += 1;
534 } 534 }
535 QString unistr(disstrU,len); 535 QString unistr(disstrU,len);
536 drawAttrStr(paint, 536 drawAttrStr(paint,
537 QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h), 537 QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h),
538 unistr, image[loc(x,y)], pm != NULL, false); 538 unistr, image[loc(x,y)], pm != NULL, false);
539 x += len - 1; 539 x += len - 1;
540 } 540 }
541 delete [] disstrU; 541 delete [] disstrU;
542 drawFrame( &paint ); 542 drawFrame( &paint );
543 paint.end(); 543 paint.end();
544 setUpdatesEnabled(TRUE); 544 setUpdatesEnabled(TRUE);
545} 545}
546 546
547void TEWidget::blinkEvent() 547void TEWidget::blinkEvent()
548{ 548{
549 blinking = !blinking; 549 blinking = !blinking;
550 repaint(FALSE); 550 repaint(FALSE);
551} 551}
552 552
553/* ------------------------------------------------------------------------- */ 553/* ------------------------------------------------------------------------- */
554/* */ 554/* */
555/* Resizing */ 555/* Resizing */
556/* */ 556/* */
557/* ------------------------------------------------------------------------- */ 557/* ------------------------------------------------------------------------- */
558 558
559void TEWidget::resizeEvent(QResizeEvent* ev) 559void TEWidget::resizeEvent(QResizeEvent* ev)
560{ 560{
561// printf("resize: %d,%d\n",ev->size().width(),ev->size().height()); 561// printf("resize: %d,%d\n",ev->size().width(),ev->size().height());
562 //printf("approx: %d,%d\n",ev->size().width()/font_w,ev->size().height()/font_h); 562 //printf("approx: %d,%d\n",ev->size().width()/font_w,ev->size().height()/font_h);
563 //printf("leaves: %d,%d\n",ev->size().width()%font_w,ev->size().height()%font_h); 563 //printf("leaves: %d,%d\n",ev->size().width()%font_w,ev->size().height()%font_h);
564 //printf("curren: %d,%d\n",width(),height()); 564 //printf("curren: %d,%d\n",width(),height());
565HCNT("resizeEvent"); 565HCNT("resizeEvent");
566 566
567 // see comment in `paintEvent' concerning the rounding. 567 // see comment in `paintEvent' concerning the rounding.
568 //FIXME: could make a routine here; check width(),height() 568 //FIXME: could make a routine here; check width(),height()
569 assert(ev->size().width() == width()); 569 assert(ev->size().width() == width());
570 assert(ev->size().height() == height()); 570 assert(ev->size().height() == height());
571 571
572 propagateSize(); 572 propagateSize();
573} 573}
574 574
575void TEWidget::propagateSize() 575void TEWidget::propagateSize()
576{ 576{
577 ca* oldimg = image; 577 ca* oldimg = image;
578 int oldlin = lines; 578 int oldlin = lines;
579 int oldcol = columns; 579 int oldcol = columns;
580 makeImage(); 580 makeImage();
581 // we copy the old image to reduce flicker 581 // we copy the old image to reduce flicker
582 int lins = QMIN(oldlin,lines); 582 int lins = QMIN(oldlin,lines);
583 int cols = QMIN(oldcol,columns); 583 int cols = QMIN(oldcol,columns);
584 if (oldimg) 584 if (oldimg)
585 { 585 {
586 for (int lin = 0; lin < lins; lin++) 586 for (int lin = 0; lin < lins; lin++)
587 memcpy((void*)&image[columns*lin], 587 memcpy((void*)&image[columns*lin],
588 (void*)&oldimg[oldcol*lin],cols*sizeof(ca)); 588 (void*)&oldimg[oldcol*lin],cols*sizeof(ca));
589 free(oldimg); //FIXME: try new,delete 589 free(oldimg); //FIXME: try new,delete
590 } 590 }
591 else 591 else
592 clearImage(); 592 clearImage();
593 593
594 //NOTE: control flows from the back through the chest right into the eye. 594 //NOTE: control flows from the back through the chest right into the eye.
595 // `emu' will call back via `setImage'. 595 // `emu' will call back via `setImage'.
596 596
597 resizing = TRUE; 597 resizing = TRUE;
598 emit changedImageSizeSignal(lines, columns); // expose resizeEvent 598 emit changedImageSizeSignal(lines, columns); // expose resizeEvent
599 resizing = FALSE; 599 resizing = FALSE;
600} 600}
601 601
602/* ------------------------------------------------------------------------- */ 602/* ------------------------------------------------------------------------- */
603/* */ 603/* */
604/* Scrollbar */ 604/* Scrollbar */
605/* */ 605/* */
606/* ------------------------------------------------------------------------- */ 606/* ------------------------------------------------------------------------- */
607 607
608void TEWidget::scrollChanged(int) { 608void TEWidget::scrollChanged(int) {
609 emit changedHistoryCursor(scrollbar->value()); //expose 609 emit changedHistoryCursor(scrollbar->value()); //expose
610} 610}
611 611
612void TEWidget::hScrollChanged(int loc) { 612void TEWidget::hScrollChanged(int loc) {
613 hposition = loc; 613 hposition = loc;
614 propagateSize(); 614 propagateSize();
615 update(); 615 update();
616 616
617// emit changedHorzCursor( hScrollbar->value()); //expose 617// emit changedHorzCursor( hScrollbar->value()); //expose
618} 618}
619 619
620void TEWidget::setScroll(int cursor, int slines) 620void TEWidget::setScroll(int cursor, int slines)
621{ 621{
622 disconnect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); 622 disconnect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int)));
623 scrollbar->setRange(0,slines); 623 scrollbar->setRange(0,slines);
624 scrollbar->setSteps(1,lines); 624 scrollbar->setSteps(1,lines);
625 scrollbar->setValue(cursor); 625 scrollbar->setValue(cursor);
626 connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); 626 connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int)));
627} 627}
628 628
629void TEWidget::setScrollbarLocation(int loc) 629void TEWidget::setScrollbarLocation(int loc)
630{ 630{
631 if (scrollLoc == loc) return; // quickly 631 if (scrollLoc == loc) return; // quickly
632 scrollLoc = loc; 632 scrollLoc = loc;
633 propagateSize(); 633 propagateSize();
634 update(); 634 update();
635} 635}
636 636
637/* ------------------------------------------------------------------------- */ 637/* ------------------------------------------------------------------------- */
638/* */ 638/* */
639/* Mouse */ 639/* Mouse */
640/* */ 640/* */
641/* ------------------------------------------------------------------------- */ 641/* ------------------------------------------------------------------------- */
642 642
643/*! 643/*!
644 Three different operations can be performed using the mouse, and the 644 Three different operations can be performed using the mouse, and the
645 routines in this section serve all of them: 645 routines in this section serve all of them:
646 646
647 1) The press/release events are exposed to the application 647 1) The press/release events are exposed to the application
648 2) Marking (press and move left button) and Pasting (press middle button) 648 2) Marking (press and move left button) and Pasting (press middle button)
649 3) The right mouse button is used from the configuration menu 649 3) The right mouse button is used from the configuration menu
650 650
651 NOTE: During the marking process we attempt to keep the cursor within 651 NOTE: During the marking process we attempt to keep the cursor within
652 the bounds of the text as being displayed by setting the mouse position 652 the bounds of the text as being displayed by setting the mouse position
653 whenever the mouse has left the text area. 653 whenever the mouse has left the text area.
654 654
655 Two reasons to do so: 655 Two reasons to do so:
656 1) QT does not allow the `grabMouse' to confine-to the TEWidget. 656 1) QT does not allow the `grabMouse' to confine-to the TEWidget.
657 Thus a `XGrapPointer' would have to be used instead. 657 Thus a `XGrapPointer' would have to be used instead.
658 2) Even if so, this would not help too much, since the text area 658 2) Even if so, this would not help too much, since the text area
659 of the TEWidget is normally not identical with it's bounds. 659 of the TEWidget is normally not identical with it's bounds.
660 660
661 The disadvantage of the current handling is, that the mouse can visibly 661 The disadvantage of the current handling is, that the mouse can visibly
662 leave the bounds of the widget and is then moved back. Because of the 662 leave the bounds of the widget and is then moved back. Because of the
663 current construction, and the reasons mentioned above, we cannot do better 663 current construction, and the reasons mentioned above, we cannot do better
664 without changing the overall construction. 664 without changing the overall construction.
665*/ 665*/
666 666
667/*! 667/*!
668*/ 668*/
669 669
670void TEWidget::mousePressEvent(QMouseEvent* ev) 670void TEWidget::mousePressEvent(QMouseEvent* ev)
671{ 671{
672//printf("press [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button()); 672//printf("press [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button());
673 if ( !contentsRect().contains(ev->pos()) ) return; 673 if ( !contentsRect().contains(ev->pos()) ) return;
674 QPoint tL = contentsRect().topLeft(); 674 QPoint tL = contentsRect().topLeft();
675 int tLx = tL.x(); 675 int tLx = tL.x();
676 int tLy = tL.y(); 676 int tLy = tL.y();
677 677
678 mouse_down_x = ev->x(); 678 mouse_down_x = ev->x();
679 mouse_down_y = ev->y(); 679 mouse_down_y = ev->y();
680 680
681//printf("press top left [%d,%d] by=%d\n",tLx,tLy, bY); 681//printf("press top left [%d,%d] by=%d\n",tLx,tLy, bY);
682 if ( ev->button() == LeftButton) 682 if ( ev->button() == LeftButton)
683 { 683 {
684 QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); 684 QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h);
685 685
686 word_selection_mode = (ev->state() & ShiftButton); 686 word_selection_mode = (ev->state() & ShiftButton);
687 687
688 if ( ev->state() & ControlButton ) preserve_line_breaks = FALSE ; 688 if ( ev->state() & ControlButton ) preserve_line_breaks = FALSE ;
689 689
690 if (mouse_marks || (ev->state() & ShiftButton)) 690 if (mouse_marks || (ev->state() & ShiftButton))
691 { 691 {
692 emit clearSelectionSignal(); 692 emit clearSelectionSignal();
693 iPntSel = pntSel = pos; 693 iPntSel = pntSel = pos;
694 actSel = 1; // left mouse button pressed but nothing selected yet. 694 actSel = 1; // left mouse button pressed but nothing selected yet.
695 grabMouse( /*crossCursor*/ ); // handle with care! 695 grabMouse( /*crossCursor*/ ); // handle with care!
696 } 696 }
697 else 697 else
698 { 698 {
699 emit mouseSignal( 0, pos.x() + 1, pos.y() + 1 ); // left button 699 emit mouseSignal( 0, pos.x() + 1, pos.y() + 1 ); // left button
700 } 700 }
701 } 701 }
702 if ( ev->button() == MidButton ) 702 if ( ev->button() == MidButton )
703 { 703 {
704 emitSelection(); 704 emitSelection();
705 } 705 }
706 if ( ev->button() == RightButton ) // Configure 706 if ( ev->button() == RightButton ) // Configure
707 { 707 {
708 emit configureRequest( this, ev->state()&(ShiftButton|ControlButton), ev->x(), ev->y() ); 708 emit configureRequest( this, ev->state()&(ShiftButton|ControlButton), ev->x(), ev->y() );
709 } 709 }
710} 710}
711 711
712void TEWidget::mouseMoveEvent(QMouseEvent* ev) 712void TEWidget::mouseMoveEvent(QMouseEvent* ev)
713{ 713{
714 // for auto-hiding the cursor, we need mouseTracking 714 // for auto-hiding the cursor, we need mouseTracking
715 if (ev->state() == NoButton ) return; 715 if (ev->state() == NoButton ) return;
716 716
717 if (actSel == 0) return; 717 if (actSel == 0) return;
718 718
719 // don't extend selection while pasting 719 // don't extend selection while pasting
720 if (ev->state() & MidButton) return; 720 if (ev->state() & MidButton) return;
721 721
722 //if ( !contentsRect().contains(ev->pos()) ) return; 722 //if ( !contentsRect().contains(ev->pos()) ) return;
723 QPoint tL = contentsRect().topLeft(); 723 QPoint tL = contentsRect().topLeft();
724 int tLx = tL.x(); 724 int tLx = tL.x();
725 int tLy = tL.y(); 725 int tLy = tL.y();
726 int scroll = scrollbar->value(); 726 int scroll = scrollbar->value();
727// int hScroll = hScrollbar->value(); 727// int hScroll = hScrollbar->value();
728 728
729 // we're in the process of moving the mouse with the left button pressed 729 // we're in the process of moving the mouse with the left button pressed
730 // the mouse cursor will kept catched within the bounds of the text in 730 // the mouse cursor will kept catched within the bounds of the text in
731 // this widget. 731 // this widget.
732 732
733 // Adjust position within text area bounds. See FIXME above. 733 // Adjust position within text area bounds. See FIXME above.
734 QPoint pos = ev->pos(); 734 QPoint pos = ev->pos();
735 if ( pos.x() < tLx+blX ) pos.setX( tLx+blX ); 735 if ( pos.x() < tLx+blX ) pos.setX( tLx+blX );
736 if ( pos.x() > tLx+blX+columns*font_w-1 ) pos.setX( tLx+blX+columns*font_w ); 736 if ( pos.x() > tLx+blX+columns*font_w-1 ) pos.setX( tLx+blX+columns*font_w );
737 if ( pos.y() < tLy+bY ) pos.setY( tLy+bY ); 737 if ( pos.y() < tLy+bY ) pos.setY( tLy+bY );
738 if ( pos.y() > tLy+bY+lines*font_h-1 ) pos.setY( tLy+bY+lines*font_h-1 ); 738 if ( pos.y() > tLy+bY+lines*font_h-1 ) pos.setY( tLy+bY+lines*font_h-1 );
739 // check if we produce a mouse move event by this 739 // check if we produce a mouse move event by this
740 if ( pos != ev->pos() ) cursor().setPos(mapToGlobal(pos)); 740 if ( pos != ev->pos() ) cursor().setPos(mapToGlobal(pos));
741 741
742 if ( pos.y() == tLy+bY+lines*font_h-1 ) 742 if ( pos.y() == tLy+bY+lines*font_h-1 )
743 { 743 {
744 scrollbar->setValue(scrollbar->value()+yMouseScroll); // scrollforward 744 scrollbar->setValue(scrollbar->value()+yMouseScroll); // scrollforward
745 } 745 }
746 if ( pos.y() == tLy+bY ) 746 if ( pos.y() == tLy+bY )
747 { 747 {
748 scrollbar->setValue(scrollbar->value()-yMouseScroll); // scrollback 748 scrollbar->setValue(scrollbar->value()-yMouseScroll); // scrollback
749 } 749 }
750 750
751 QPoint here = QPoint((pos.x()-tLx-blX)/font_w,(pos.y()-tLy-bY)/font_h); 751 QPoint here = QPoint((pos.x()-tLx-blX)/font_w,(pos.y()-tLy-bY)/font_h);
752 QPoint ohere; 752 QPoint ohere;
753 bool swapping = FALSE; 753 bool swapping = FALSE;
754 754
755 if ( word_selection_mode ) 755 if ( word_selection_mode )
756 { 756 {
757 // Extend to word boundaries 757 // Extend to word boundaries
758 int i; 758 int i;
759 int selClass; 759 int selClass;
760 760
761 bool left_not_right = ( here.y() < iPntSel.y() || 761 bool left_not_right = ( here.y() < iPntSel.y() ||
762 here.y() == iPntSel.y() && here.x() < iPntSel.x() ); 762 here.y() == iPntSel.y() && here.x() < iPntSel.x() );
763 bool old_left_not_right = ( pntSel.y() < iPntSel.y() || 763 bool old_left_not_right = ( pntSel.y() < iPntSel.y() ||
764 pntSel.y() == iPntSel.y() && pntSel.x() < iPntSel.x() ); 764 pntSel.y() == iPntSel.y() && pntSel.x() < iPntSel.x() );
765 swapping = left_not_right != old_left_not_right; 765 swapping = left_not_right != old_left_not_right;
766 766
767 // Find left (left_not_right ? from here : from start) 767 // Find left (left_not_right ? from here : from start)
768 QPoint left = left_not_right ? here : iPntSel; 768 QPoint left = left_not_right ? here : iPntSel;
769 i = loc(left.x(),left.y()); 769 i = loc(left.x(),left.y());
770 selClass = charClass(image[i].c); 770 selClass = charClass(image[i].c);
771 while ( left.x() > 0 && charClass(image[i-1].c) == selClass ) 771 while ( left.x() > 0 && charClass(image[i-1].c) == selClass )
772 { i--; left.rx()--; } 772 { i--; left.rx()--; }
773 773
774 // Find left (left_not_right ? from start : from here) 774 // Find left (left_not_right ? from start : from here)
775 QPoint right = left_not_right ? iPntSel : here; 775 QPoint right = left_not_right ? iPntSel : here;
776 i = loc(right.x(),right.y()); 776 i = loc(right.x(),right.y());
777 selClass = charClass(image[i].c); 777 selClass = charClass(image[i].c);
778 while ( right.x() < columns-1 && charClass(image[i+1].c) == selClass ) 778 while ( right.x() < columns-1 && charClass(image[i+1].c) == selClass )
779 { i++; right.rx()++; } 779 { i++; right.rx()++; }
780 780
781 // Pick which is start (ohere) and which is extension (here) 781 // Pick which is start (ohere) and which is extension (here)
782 if ( left_not_right ) 782 if ( left_not_right )
783 { 783 {
784 here = left; ohere = right; 784 here = left; ohere = right;
785 } 785 }
786 else 786 else
787 { 787 {
788 here = right; ohere = left; 788 here = right; ohere = left;
789 } 789 }
790 } 790 }
791 791
792 if (here == pntSel && scroll == scrollbar->value()) return; // not moved 792 if (here == pntSel && scroll == scrollbar->value()) return; // not moved
793 793
794 if ( word_selection_mode ) { 794 if ( word_selection_mode ) {
795 if ( actSel < 2 || swapping ) { 795 if ( actSel < 2 || swapping ) {
796 emit beginSelectionSignal( ohere.x(), ohere.y() ); 796 emit beginSelectionSignal( ohere.x(), ohere.y() );
797 } 797 }
798 } else if ( actSel < 2 ) { 798 } else if ( actSel < 2 ) {
799 emit beginSelectionSignal( pntSel.x(), pntSel.y() ); 799 emit beginSelectionSignal( pntSel.x(), pntSel.y() );
800 } 800 }
801 801
802 actSel = 2; // within selection 802 actSel = 2; // within selection
803 pntSel = here; 803 pntSel = here;
804 emit extendSelectionSignal( here.x(), here.y() ); 804 emit extendSelectionSignal( here.x(), here.y() );
805} 805}
806 806
807void TEWidget::mouseReleaseEvent(QMouseEvent* ev) 807void TEWidget::mouseReleaseEvent(QMouseEvent* ev)
808{ 808{
809//printf("release [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button()); 809//printf("release [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button());
810 if ( ev->button() == LeftButton) 810 if ( ev->button() == LeftButton)
811 { 811 {
812 if (QABS(ev->x() - mouse_down_x) < 3 812 if (QABS(ev->x() - mouse_down_x) < 3
813 && QABS(ev->y() - mouse_down_y) < 3 813 && QABS(ev->y() - mouse_down_y) < 3
814 && ev->y() < qApp->desktop()->height()/8) { 814 && ev->y() < qApp->desktop()->height()/8) {
815 emit setFullScreen(false); 815 emit setFullScreen(false);
816 } 816 }
817 817
818 if ( actSel > 1 ) emit endSelectionSignal(preserve_line_breaks); 818 if ( actSel > 1 ) emit endSelectionSignal(preserve_line_breaks);
819 preserve_line_breaks = TRUE; 819 preserve_line_breaks = TRUE;
820 actSel = 0; 820 actSel = 0;
821 821
822 //FIXME: emits a release event even if the mouse is 822 //FIXME: emits a release event even if the mouse is
823 // outside the range. The procedure used in `mouseMoveEvent' 823 // outside the range. The procedure used in `mouseMoveEvent'
824 // applies here, too. 824 // applies here, too.
825 825
826 QPoint tL = contentsRect().topLeft(); 826 QPoint tL = contentsRect().topLeft();
827 int tLx = tL.x(); 827 int tLx = tL.x();
828 int tLy = tL.y(); 828 int tLy = tL.y();
829 829
830 if (!mouse_marks && !(ev->state() & ShiftButton)) 830 if (!mouse_marks && !(ev->state() & ShiftButton))
831 emit mouseSignal( 3, // release 831 emit mouseSignal( 3, // release
832 (ev->x()-tLx-blX)/font_w + 1, 832 (ev->x()-tLx-blX)/font_w + 1,
833 (ev->y()-tLy-bY)/font_h + 1 ); 833 (ev->y()-tLy-bY)/font_h + 1 );
834 releaseMouse(); 834 releaseMouse();
835 } 835 }
836} 836}
837 837
838void TEWidget::mouseDoubleClickEvent(QMouseEvent* ev) 838void TEWidget::mouseDoubleClickEvent(QMouseEvent* ev)
839{ 839{
840 if ( ev->button() != LeftButton) return; 840 if ( ev->button() != LeftButton) return;
841 841
842 QPoint tL = contentsRect().topLeft(); 842 QPoint tL = contentsRect().topLeft();
843 int tLx = tL.x(); 843 int tLx = tL.x();
844 int tLy = tL.y(); 844 int tLy = tL.y();
845 QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); 845 QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h);
846 846
847 // pass on double click as two clicks. 847 // pass on double click as two clicks.
848 if (!mouse_marks && !(ev->state() & ShiftButton)) 848 if (!mouse_marks && !(ev->state() & ShiftButton))
849 { 849 {
850 emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button 850 emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button
851 emit mouseSignal( 3, pos.x()+1, pos.y()+1 ); // release 851 emit mouseSignal( 3, pos.x()+1, pos.y()+1 ); // release
852 emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button 852 emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button
853 return; 853 return;
854 } 854 }
855 855
856 856
857 emit clearSelectionSignal(); 857 emit clearSelectionSignal();
858 QPoint bgnSel = pos; 858 QPoint bgnSel = pos;
859 QPoint endSel = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); 859 QPoint endSel = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h);
860 int i = loc(bgnSel.x(),bgnSel.y()); 860 int i = loc(bgnSel.x(),bgnSel.y());
861 iPntSel = bgnSel; 861 iPntSel = bgnSel;
862 862
863 word_selection_mode = TRUE; 863 word_selection_mode = TRUE;
864 864
865 // find word boundaries... 865 // find word boundaries...
866 int selClass = charClass(image[i].c); 866 int selClass = charClass(image[i].c);
867 { 867 {
868 // set the start... 868 // set the start...
869 int x = bgnSel.x(); 869 int x = bgnSel.x();
870 while ( x > 0 && charClass(image[i-1].c) == selClass ) 870 while ( x > 0 && charClass(image[i-1].c) == selClass )
871 { i--; x--; } 871 { i--; x--; }
872 bgnSel.setX(x); 872 bgnSel.setX(x);
873 emit beginSelectionSignal( bgnSel.x(), bgnSel.y() ); 873 emit beginSelectionSignal( bgnSel.x(), bgnSel.y() );
874 874
875 // set the end... 875 // set the end...
876 i = loc( endSel.x(), endSel.y() ); 876 i = loc( endSel.x(), endSel.y() );
877 x = endSel.x(); 877 x = endSel.x();
878 while( x < columns-1 && charClass(image[i+1].c) == selClass ) 878 while( x < columns-1 && charClass(image[i+1].c) == selClass )
879 { i++; x++ ; } 879 { i++; x++ ; }
880 endSel.setX(x); 880 endSel.setX(x);
881 actSel = 2; // within selection 881 actSel = 2; // within selection
882 emit extendSelectionSignal( endSel.x(), endSel.y() ); 882 emit extendSelectionSignal( endSel.x(), endSel.y() );
883 emit endSelectionSignal(preserve_line_breaks); 883 emit endSelectionSignal(preserve_line_breaks);
884 preserve_line_breaks = TRUE; 884 preserve_line_breaks = TRUE;
885 } 885 }
886} 886}
887 887
888void TEWidget::focusInEvent( QFocusEvent * ) 888void TEWidget::focusInEvent( QFocusEvent * )
889{ 889{
890 890
891 // do nothing, to prevent repainting 891 // do nothing, to prevent repainting
892} 892}
893 893
894 894
895void TEWidget::focusOutEvent( QFocusEvent * ) 895void TEWidget::focusOutEvent( QFocusEvent * )
896{ 896{
897 // do nothing, to prevent repainting 897 // do nothing, to prevent repainting
898} 898}
899 899
900bool TEWidget::focusNextPrevChild( bool next ) 900bool TEWidget::focusNextPrevChild( bool next )
901{ 901{
902 if (next) 902 if (next)
903 return false; // This disables changing the active part in konqueror 903 return false; // This disables changing the active part in konqueror
904 // when pressing Tab 904 // when pressing Tab
905 return QFrame::focusNextPrevChild( next ); 905 return QFrame::focusNextPrevChild( next );
906} 906}
907 907
908 908
909int TEWidget::charClass(char ch) const 909int TEWidget::charClass(char ch) const
910{ 910{
911 // This might seem like overkill, but imagine if ch was a Unicode 911 // This might seem like overkill, but imagine if ch was a Unicode
912 // character (Qt 2.0 QChar) - it might then be sensible to separate 912 // character (Qt 2.0 QChar) - it might then be sensible to separate
913 // the different language ranges, etc. 913 // the different language ranges, etc.
914 914
915 if ( isspace(ch) ) return ' '; 915 if ( isspace(ch) ) return ' ';
916 916
917 static const char *word_characters = ":@-./_~"; 917 static const char *word_characters = ":@-./_~";
918 if ( isalnum(ch) || strchr(word_characters, ch) ) 918 if ( isalnum(ch) || strchr(word_characters, ch) )
919 return 'a'; 919 return 'a';
920 920
921 // Everything else is weird 921 // Everything else is weird
922 return 1; 922 return 1;
923} 923}
924 924
925void TEWidget::setMouseMarks(bool on) 925void TEWidget::setMouseMarks(bool on)
926{ 926{
927 mouse_marks = on; 927 mouse_marks = on;
928 setCursor( mouse_marks ? ibeamCursor : arrowCursor ); 928 setCursor( mouse_marks ? ibeamCursor : arrowCursor );
929} 929}
930 930
931/* ------------------------------------------------------------------------- */ 931/* ------------------------------------------------------------------------- */
932/* */ 932/* */
933/* Clipboard */ 933/* Clipboard */
934/* */ 934/* */
935/* ------------------------------------------------------------------------- */ 935/* ------------------------------------------------------------------------- */
936 936
937#undef KeyPress 937#undef KeyPress
938 938
939void TEWidget::emitSelection() 939void TEWidget::emitSelection()
940// Paste Clipboard by simulating keypress events 940// Paste Clipboard by simulating keypress events
941{ 941{
942#ifndef QT_NO_CLIPBOARD 942#ifndef QT_NO_CLIPBOARD
943 QString text = QApplication::clipboard()->text(); 943 QString text = QApplication::clipboard()->text();
944 //qDebug(text); 944 //qDebug(text);
945 if ( ! text.isNull()) 945 if ( ! text.isNull())
946 { 946 {
947 text.replace(QRegExp("\n"), "\r"); 947 text.replace(QRegExp("\n"), "\r");
948 QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text); 948 QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text);
949 emit keyPressedSignal(&e); // expose as a big fat keypress event 949 emit keyPressedSignal(&e); // expose as a big fat keypress event
950 emit clearSelectionSignal(); 950 emit clearSelectionSignal();
951 } 951 }
952#endif 952#endif
953} 953}
954 954
955void TEWidget::emitText(QString text) 955void TEWidget::emitText(QString text)
956{ 956{
957 QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text); 957 QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text);
958 emit keyPressedSignal(&e); // expose as a big fat keypress event 958 emit keyPressedSignal(&e); // expose as a big fat keypress event
959} 959}
960 960
961void TEWidget::pasteClipboard( ) 961void TEWidget::pasteClipboard( )
962{ 962{
963 emitSelection(); 963 emitSelection();
964} 964}
965 965
966void TEWidget::setSelection(const QString& t) 966void TEWidget::setSelection(const QString& t)
967{ 967{
968#ifndef QT_NO_CLIPBOARD 968#ifndef QT_NO_CLIPBOARD
969 // Disconnect signal while WE set the clipboard 969 // Disconnect signal while WE set the clipboard
970 QObject *cb = QApplication::clipboard(); 970 QObject *cb = QApplication::clipboard();
971 QObject::disconnect( cb, SIGNAL(dataChanged()), 971 QObject::disconnect( cb, SIGNAL(dataChanged()),
972 this, SLOT(onClearSelection()) ); 972 this, SLOT(onClearSelection()) );
973 973
974 QApplication::clipboard()->setText(t); 974 QApplication::clipboard()->setText(t);
975 975
976 QObject::connect( cb, SIGNAL(dataChanged()), 976 QObject::connect( cb, SIGNAL(dataChanged()),
977 this, SLOT(onClearSelection()) ); 977 this, SLOT(onClearSelection()) );
978#endif 978#endif
979} 979}
980 980
981void TEWidget::onClearSelection() 981void TEWidget::onClearSelection()
982{ 982{
983 emit clearSelectionSignal(); 983 emit clearSelectionSignal();
984} 984}
985 985
986/* ------------------------------------------------------------------------- */ 986/* ------------------------------------------------------------------------- */
987/* */ 987/* */
988/* Keyboard */ 988/* Keyboard */
989/* */ 989/* */
990/* ------------------------------------------------------------------------- */ 990/* ------------------------------------------------------------------------- */
991 991
992//FIXME: an `eventFilter' has been installed instead of a `keyPressEvent' 992//FIXME: an `eventFilter' has been installed instead of a `keyPressEvent'
993// due to a bug in `QT' or the ignorance of the author to prevent 993// due to a bug in `QT' or the ignorance of the author to prevent
994// repaint events being emitted to the screen whenever one leaves 994// repaint events being emitted to the screen whenever one leaves
995// or reenters the screen to/from another application. 995// or reenters the screen to/from another application.
996// 996//
997// Troll says one needs to change focusInEvent() and focusOutEvent(), 997// Troll says one needs to change focusInEvent() and focusOutEvent(),
998// which would also let you have an in-focus cursor and an out-focus 998// which would also let you have an in-focus cursor and an out-focus
999// cursor like xterm does. 999// cursor like xterm does.
1000 1000
1001// for the auto-hide cursor feature, I added empty focusInEvent() and 1001// for the auto-hide cursor feature, I added empty focusInEvent() and
1002// focusOutEvent() so that update() isn't called. 1002// focusOutEvent() so that update() isn't called.
1003// For auto-hide, we need to get keypress-events, but we only get them when 1003// For auto-hide, we need to get keypress-events, but we only get them when
1004// we have focus. 1004// we have focus.
1005 1005
1006void TEWidget::doScroll(int lines) 1006void TEWidget::doScroll(int lines)
1007{ 1007{
1008 scrollbar->setValue(scrollbar->value()+lines); 1008 scrollbar->setValue(scrollbar->value()+lines);
1009} 1009}
1010 1010
1011void TEWidget::doHScroll(int lines) { 1011void TEWidget::doHScroll(int lines) {
1012 hScrollbar->setValue( hScrollbar->value()+lines); 1012 hScrollbar->setValue( hScrollbar->value()+lines);
1013} 1013}
1014 1014
1015bool TEWidget::eventFilter( QObject *obj, QEvent *e ) 1015bool TEWidget::eventFilter( QObject *obj, QEvent *e )
1016{ 1016{
1017 if ( (e->type() == QEvent::Accel || 1017 if ( (e->type() == QEvent::Accel ||
1018 e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) { 1018 e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) {
1019 static_cast<QKeyEvent *>( e )->ignore(); 1019 static_cast<QKeyEvent *>( e )->ignore();
1020 return true; 1020 return true;
1021 } 1021 }
1022 if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ ) 1022 if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ )
1023 return FALSE; // not us 1023 return FALSE; // not us
1024 if ( e->type() == QEvent::Wheel) { 1024 if ( e->type() == QEvent::Wheel) {
1025 QApplication::sendEvent(scrollbar, e); 1025 QApplication::sendEvent(scrollbar, e);
1026 } 1026 }
1027 1027
1028#ifdef FAKE_CTRL_AND_ALT 1028#ifdef FAKE_CTRL_AND_ALT
1029 static bool control = FALSE; 1029 static bool control = FALSE;
1030 static bool alt = FALSE; 1030 static bool alt = FALSE;
1031// qDebug(" Has a keyboard with no CTRL and ALT keys, but we fake it:"); 1031// qDebug(" Has a keyboard with no CTRL and ALT keys, but we fake it:");
1032 bool dele=FALSE; 1032 bool dele=FALSE;
1033 if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { 1033 if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) {
1034 QKeyEvent* ke = (QKeyEvent*)e; 1034 QKeyEvent* ke = (QKeyEvent*)e;
1035 bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat(); 1035 bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat();
1036 switch (ke->key()) { 1036 switch (ke->key()) {
1037 case Key_F9: // let this be "Control" 1037 case Key_F9: // let this be "Control"
1038 control = keydown; 1038 control = keydown;
1039 e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state()); 1039 e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state());
1040 dele=TRUE; 1040 dele=TRUE;
1041 break; 1041 break;
1042 case Key_F13: // let this be "Alt" 1042 case Key_F13: // let this be "Alt"
1043 alt = keydown; 1043 alt = keydown;
1044 e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state()); 1044 e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state());
1045 dele=TRUE; 1045 dele=TRUE;
1046 break; 1046 break;
1047 default: 1047 default:
1048 if ( control ) { 1048 if ( control ) {
1049 int a = toupper(ke->ascii())-64; 1049 int a = toupper(ke->ascii())-64;
1050 if ( a >= 0 && a < ' ' ) { 1050 if ( a >= 0 && a < ' ' ) {
1051 e = new QKeyEvent(e->type(), ke->key(), 1051 e = new QKeyEvent(e->type(), ke->key(),
1052 a, ke->state()|ControlButton, QChar(a,0)); 1052 a, ke->state()|ControlButton, QChar(a,0));
1053 dele=TRUE; 1053 dele=TRUE;
1054 } 1054 }
1055 } 1055 }
1056 if ( alt ) { 1056 if ( alt ) {
1057 e = new QKeyEvent(e->type(), ke->key(), 1057 e = new QKeyEvent(e->type(), ke->key(),
1058 ke->ascii(), ke->state()|AltButton, ke->text()); 1058 ke->ascii(), ke->state()|AltButton, ke->text());
1059 dele=TRUE; 1059 dele=TRUE;
1060 } 1060 }
1061 } 1061 }
1062 } 1062 }
1063#endif 1063#endif
1064 1064
1065 if ( e->type() == QEvent::KeyPress ) { 1065 if ( e->type() == QEvent::KeyPress ) {
1066 QKeyEvent* ke = (QKeyEvent*)e; 1066 QKeyEvent* ke = (QKeyEvent*)e;
1067 actSel=0; // Key stroke implies a screen update, so TEWidget won't 1067 actSel=0; // Key stroke implies a screen update, so TEWidget won't
1068 // know where the current selection is. 1068 // know where the current selection is.
1069 1069
1070// qDebug("key pressed is 0x%x, ascii is 0x%x, state %d", ke->key(), ke->ascii(), ke->state()); 1070// qDebug("key pressed is 0x%x, ascii is 0x%x, state %d", ke->key(), ke->ascii(), ke->state());
1071 1071
1072 bool special_function = true; 1072 bool special_function = true;
1073 switch(ke->key()) { 1073 switch(ke->key()) {
1074 //case 0x201b: // fn-5 1074 //case 0x201b: // fn-5
1075 //case Key_F1: 1075 //case Key_F1:
1076 // switch sessions (?) 1076 // switch sessions (?)
1077 // emitText("\\"); // expose (??) 1077 // emitText("\\"); // expose (??)
1078 // break; 1078 // break;
1079 1079
1080 case 0x2016: // fn-p 1080 case 0x2016: // fn-p
1081 case Key_F2: 1081 case Key_F2:
1082 pasteClipboard(); 1082 pasteClipboard();
1083 break; 1083 break;
1084 1084
1085 case 0x2018: // fn-S 1085 case 0x2018: // fn-S
1086 case Key_F3: 1086 case Key_F3:
1087 emit changeSession(1); 1087 emit changeSession(1);
1088 break; 1088 break;
1089 1089
1090 case 0x2019: // fn-n 1090 case 0x2019: // fn-n
1091 emit newSession(); 1091 emit newSession();
1092 break; 1092 break;
1093 1093
1094 case Qt::Key_Tab: 1094 case Qt::Key_Tab:
1095 if (ke->state() == ControlButton) { 1095 if (ke->state() == ControlButton) {
1096 emit changeSession(1); 1096 emit changeSession(1);
1097 } else { 1097 } else {
1098 special_function = false; 1098 special_function = false;
1099 } 1099 }
1100 break; 1100 break;
1101 1101
1102#if 0 1102#if 0
1103 case Qt::Key_Left: 1103 case Qt::Key_Left:
1104 if (vcolumns == 0) { 1104 if (vcolumns == 0) {
1105 emit changeSession(-1); 1105 emit changeSession(-1);
1106 } else { 1106 } else {
1107 special_function = false; 1107 special_function = false;
1108 } 1108 }
1109 break; 1109 break;
1110 1110
1111 case Qt::Key_Right: 1111 case Qt::Key_Right:
1112 if (vcolumns == 0) { 1112 if (vcolumns == 0) {
1113 emit changeSession(1); 1113 emit changeSession(1);
1114 } else { 1114 } else {
1115 special_function = false; 1115 special_function = false;
1116 } 1116 }
1117 break; 1117 break;
1118#endif 1118#endif
1119 1119
1120 case 0x201b: // fn-5 1120 case 0x201b: // fn-5
1121 case Key_F4: 1121 case Key_F4:
1122 emit toggleFullScreen(); 1122 emit toggleFullScreen();
1123 break; 1123 break;
1124 1124
1125 case 0x200f: // fn-1 magnify minus 1125 case 0x200f: // fn-1 magnify minus
1126 case Key_F5: 1126 case Key_F5:
1127 emit changeFontSize(-1); 1127 emit changeFontSize(-1);
1128 break; 1128 break;
1129 1129
1130 case 0x2010: // fn-2 magnify plus 1130 case 0x2010: // fn-2 magnify plus
1131 case Key_F6: 1131 case Key_F6:
1132 emit changeFontSize(1); 1132 emit changeFontSize(1);
1133 break; 1133 break;
1134 1134
1135 default: 1135 default:
1136 special_function = false; 1136 special_function = false;
1137 } 1137 }
1138 if (special_function) { 1138 if (special_function) {
1139 return true; 1139 return true;
1140 } 1140 }
1141 // else if( ke->state() == ControlButton && ke->key() == Key_V) { 1141 // else if( ke->state() == ControlButton && ke->key() == Key_V) {
1142 // pasteClipboard(); 1142 // pasteClipboard();
1143 // } 1143 // }
1144 // else if( ke->state() == ControlButton && ke->key() == Key_C) { 1144 // else if( ke->state() == ControlButton && ke->key() == Key_C) {
1145 // pasteClipboard(); 1145 // pasteClipboard();
1146 // } 1146 // }
1147 emit keyPressedSignal(ke); // expose 1147 emit keyPressedSignal(ke); // expose
1148 ke->accept(); 1148 ke->accept();
1149#ifdef FAKE_CTRL_AND_ALT 1149#ifdef FAKE_CTRL_AND_ALT
1150 if ( dele ) delete e; 1150 if ( dele ) delete e;
1151#endif 1151#endif
1152 return true; // stop the event 1152 return true; // stop the event
1153 } 1153 }
1154 if ( e->type() == QEvent::Enter ) { 1154 if ( e->type() == QEvent::Enter ) {
1155 QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()), 1155 QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()),
1156 this, SLOT(onClearSelection()) ); 1156 this, SLOT(onClearSelection()) );
1157 } 1157 }
1158 if ( e->type() == QEvent::Leave ) { 1158 if ( e->type() == QEvent::Leave ) {
1159 QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), 1159 QObject::connect( (QObject*)cb, SIGNAL(dataChanged()),
1160 this, SLOT(onClearSelection()) ); 1160 this, SLOT(onClearSelection()) );
1161 } 1161 }
1162 return QFrame::eventFilter( obj, e ); 1162 return QFrame::eventFilter( obj, e );
1163} 1163}
1164 1164
1165/* ------------------------------------------------------------------------- */ 1165/* ------------------------------------------------------------------------- */
1166/* */ 1166/* */
1167/* Frame */ 1167/* Frame */
1168/* */ 1168/* */
1169/* ------------------------------------------------------------------------- */ 1169/* ------------------------------------------------------------------------- */
1170 1170
1171void TEWidget::frameChanged() 1171void TEWidget::frameChanged()
1172{ 1172{
1173 propagateSize(); 1173 propagateSize();
1174 update(); 1174 update();
1175} 1175}
1176/* ------------------------------------------------------------------------- */ 1176/* ------------------------------------------------------------------------- */
1177/* */ 1177/* */
1178/* Sound */ 1178/* Sound */
1179/* */ 1179/* */
1180/* ------------------------------------------------------------------------- */ 1180/* ------------------------------------------------------------------------- */
1181 1181
1182void TEWidget::Bell() 1182void TEWidget::Bell()
1183{ 1183{
1184//#ifdef QT_QWS_SL5XXX 1184//#ifdef QT_QWS_SL5XXX
1185//# ifndef QT_NO_COP 1185//# ifndef QT_NO_COP
1186 if(useBeep) 1186 if(useBeep)
1187 QCopEnvelope( "QPE/TaskBar", "soundAlarm()" ); 1187 QCopEnvelope( "QPE/TaskBar", "soundAlarm()" );
1188 1188
1189//# endif 1189//# endif
1190//#else 1190//#else
1191//# ifndef QT_NO_SOUND 1191//# ifndef QT_NO_SOUND
1192// QSound::play(Resource::findSound("alarm")); 1192// QSound::play(Resource::findSound("alarm"));
1193//# endif 1193//# endif
1194//#endif 1194//#endif
1195 1195
1196// QApplication::beep(); 1196// QApplication::beep();
1197} 1197}
1198 1198
1199/* ------------------------------------------------------------------------- */ 1199/* ------------------------------------------------------------------------- */
1200/* */ 1200/* */
1201/* Auxiluary */ 1201/* Auxiluary */
1202/* */ 1202/* */
1203/* ------------------------------------------------------------------------- */ 1203/* ------------------------------------------------------------------------- */
1204 1204
1205void TEWidget::clearImage() 1205void TEWidget::clearImage()
1206// initialize the image 1206// initialize the image
1207// for internal use only 1207// for internal use only
1208{ 1208{
1209 for (int y = 0; y < lines; y++) 1209 for (int y = 0; y < lines; y++)
1210 for (int x = 0; x < columns; x++) 1210 for (int x = 0; x < columns; x++)
1211 { 1211 {
1212 image[loc(x,y)].c = 0xff; //' '; 1212 image[loc(x,y)].c = 0xff; //' ';
1213 image[loc(x,y)].f = 0xff; //DEFAULT_FORE_COLOR; 1213 image[loc(x,y)].f = 0xff; //DEFAULT_FORE_COLOR;
1214 image[loc(x,y)].b = 0xff; //DEFAULT_BACK_COLOR; 1214 image[loc(x,y)].b = 0xff; //DEFAULT_BACK_COLOR;
1215 image[loc(x,y)].r = 0xff; //DEFAULT_RENDITION; 1215 image[loc(x,y)].r = 0xff; //DEFAULT_RENDITION;
1216 } 1216 }
1217} 1217}
1218 1218
1219// Create Image /////////////////////////////////////////////////////// 1219// Create Image ///////////////////////////////////////////////////////
1220 1220
1221void TEWidget::calcGeometry() 1221void TEWidget::calcGeometry()
1222{ 1222{
1223 int showhscrollbar = 1; 1223 int showhscrollbar = 1;
1224 int hwidth = 0; 1224 int hwidth = 0;
1225 int dcolumns = 0; 1225 int dcolumns = 0;
1226 Config cfg( "Konsole" ); 1226 Config cfg( "Konsole" );
1227 cfg.setGroup("ScrollBar"); 1227 cfg.setGroup("ScrollBar");
1228 useHorzScroll=cfg.readBoolEntry("HorzScroll",0); 1228 useHorzScroll=cfg.readBoolEntry("HorzScroll",0);
1229 1229
1230 if(vcolumns == 0) showhscrollbar = 0; 1230 if(vcolumns == 0) showhscrollbar = 0;
1231 if(showhscrollbar == 1) hwidth = QApplication::style().scrollBarExtent().width(); 1231 if(showhscrollbar == 1) hwidth = QApplication::style().scrollBarExtent().width();
1232 1232
1233 scrollbar->resize(QApplication::style().scrollBarExtent().width(), 1233 scrollbar->resize(QApplication::style().scrollBarExtent().width(),
1234 contentsRect().height() - hwidth); 1234 contentsRect().height() - hwidth);
1235 1235
1236 switch(scrollLoc) { 1236 switch(scrollLoc) {
1237 case SCRNONE : 1237 case SCRNONE :
1238 columns = ( contentsRect().width() - 2 * rimX ) / font_w; 1238 columns = ( contentsRect().width() - 2 * rimX ) / font_w;
1239 dcolumns = columns; 1239 dcolumns = columns;
1240 if(vcolumns) columns = vcolumns; 1240 if(vcolumns) columns = vcolumns;
1241 blX = (contentsRect().width() - (columns*font_w) ) / 2; 1241 blX = (contentsRect().width() - (columns*font_w) ) / 2;
1242 if(showhscrollbar) 1242 if(showhscrollbar)
1243 blX = -hposition * font_w; 1243 blX = -hposition * font_w;
1244 brX = blX; 1244 brX = blX;
1245 scrollbar->hide(); 1245 scrollbar->hide();
1246 break; 1246 break;
1247 case SCRLEFT : 1247 case SCRLEFT :
1248 columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; 1248 columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w;
1249 dcolumns = columns; 1249 dcolumns = columns;
1250 if(vcolumns) columns = vcolumns; 1250 if(vcolumns) columns = vcolumns;
1251 brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; 1251 brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2;
1252 if(showhscrollbar) 1252 if(showhscrollbar)
1253 brX = -hposition * font_w; 1253 brX = -hposition * font_w;
1254 blX = brX + scrollbar->width(); 1254 blX = brX + scrollbar->width();
1255 scrollbar->move(contentsRect().topLeft()); 1255 scrollbar->move(contentsRect().topLeft());
1256 scrollbar->show(); 1256 scrollbar->show();
1257 break; 1257 break;
1258 case SCRRIGHT: 1258 case SCRRIGHT:
1259 columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; 1259 columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w;
1260 dcolumns = columns; 1260 dcolumns = columns;
1261 if(vcolumns) columns = vcolumns; 1261 if(vcolumns) columns = vcolumns;
1262 blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; 1262 blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2;
1263 if(showhscrollbar) 1263 if(showhscrollbar)
1264 blX = -hposition * font_w; 1264 blX = -hposition * font_w;
1265 brX = blX; 1265 brX = blX;
1266 scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0)); 1266 scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0));
1267 scrollbar->show(); 1267 scrollbar->show();
1268 break; 1268 break;
1269 } 1269 }
1270 //FIXME: support 'rounding' styles 1270 //FIXME: support 'rounding' styles
1271 lines = ( contentsRect().height() - 2 * rimY ) / font_h; 1271 lines = ( contentsRect().height() - 2 * rimY ) / font_h;
1272 bY = (contentsRect().height() - (lines *font_h)) / 2; 1272 bY = (contentsRect().height() - (lines *font_h)) / 2;
1273 1273
1274 if(showhscrollbar == 1) { 1274 if(showhscrollbar == 1) {
1275 hScrollbar->resize(contentsRect().width() - hwidth, hwidth); 1275 hScrollbar->resize(contentsRect().width() - hwidth, hwidth);
1276 hScrollbar->setRange(0, vcolumns - dcolumns); 1276 hScrollbar->setRange(0, vcolumns - dcolumns);
1277 1277
1278 QPoint p = contentsRect().bottomLeft(); 1278 QPoint p = contentsRect().bottomLeft();
1279 if(scrollLoc == SCRLEFT) 1279 if(scrollLoc == SCRLEFT)
1280 hScrollbar->move(QPoint(p.x()+hwidth, p.y() - hwidth)); 1280 hScrollbar->move(QPoint(p.x()+hwidth, p.y() - hwidth));
1281 else 1281 else
1282 hScrollbar->move(QPoint(p.x(), p.y() - hwidth)); 1282 hScrollbar->move(QPoint(p.x(), p.y() - hwidth));
1283 1283
1284 hScrollbar->show(); 1284 hScrollbar->show();
1285 } 1285 }
1286 else hScrollbar->hide(); 1286 else hScrollbar->hide();
1287 1287
1288 if(showhscrollbar == 1) { 1288 if(showhscrollbar == 1) {
1289 lines = lines - (hwidth / font_h) - 1; 1289 lines = lines - (hwidth / font_h) - 1;
1290 if(lines < 1) lines = 1; 1290 if(lines < 1) lines = 1;
1291 } 1291 }
1292 //FIXME: support 'rounding' styles 1292 //FIXME: support 'rounding' styles
1293} 1293}
1294 1294
1295void TEWidget::makeImage() 1295void TEWidget::makeImage()
1296//FIXME: rename 'calcGeometry? 1296//FIXME: rename 'calcGeometry?
1297{ 1297{
1298 calcGeometry(); 1298 calcGeometry();
1299 image = (ca*) malloc(lines*columns*sizeof(ca)); 1299 image = (ca*) malloc(lines*columns*sizeof(ca));
1300 clearImage(); 1300 clearImage();
1301} 1301}
1302 1302
1303// calculate the needed size 1303// calculate the needed size
1304QSize TEWidget::calcSize(int cols, int lins) const 1304QSize TEWidget::calcSize(int cols, int lins) const
1305{ 1305{
1306 int frw = width() - contentsRect().width(); 1306 int frw = width() - contentsRect().width();
1307 int frh = height() - contentsRect().height(); 1307 int frh = height() - contentsRect().height();
1308 int scw = (scrollLoc==SCRNONE?0:scrollbar->width()); 1308 int scw = (scrollLoc==SCRNONE?0:scrollbar->width());
1309 return QSize( font_w*cols + 2*rimX + frw + scw, font_h*lins + 2*rimY + frh ); 1309 return QSize( font_w*cols + 2*rimX + frw + scw, font_h*lins + 2*rimY + frh );
1310} 1310}
1311 1311
1312QSize TEWidget::sizeHint() const 1312QSize TEWidget::sizeHint() const
1313{ 1313{
1314 return size(); 1314 return size();
1315} 1315}
1316 1316
1317void TEWidget::styleChange(QStyle &) 1317void TEWidget::styleChange(QStyle &)
1318{ 1318{
1319 propagateSize(); 1319 propagateSize();
1320} 1320}
1321 1321
1322#ifndef QT_NO_DRAGANDDROP 1322#ifndef QT_NO_DRAGANDDROP
1323 1323
1324/* --------------------------------------------------------------------- */ 1324/* --------------------------------------------------------------------- */
1325/* */ 1325/* */
1326/* Drag & Drop */ 1326/* Drag & Drop */
1327/* */ 1327/* */
1328/* --------------------------------------------------------------------- */ 1328/* --------------------------------------------------------------------- */
1329 1329
1330 1330
1331void TEWidget::dragEnterEvent(QDragEnterEvent* e) 1331void TEWidget::dragEnterEvent(QDragEnterEvent* e)
1332{ 1332{
1333 e->accept(QTextDrag::canDecode(e) || 1333 e->accept(QTextDrag::canDecode(e) ||
1334 QUriDrag::canDecode(e)); 1334 QUriDrag::canDecode(e));
1335} 1335}
1336 1336
1337void TEWidget::dropEvent(QDropEvent* event) 1337void TEWidget::dropEvent(QDropEvent* event)
1338{ 1338{
1339 // The current behaviour when url(s) are dropped is 1339 // The current behaviour when url(s) are dropped is
1340 // * if there is only ONE url and if it's a LOCAL one, ask for paste or cd 1340 // * if there is only ONE url and if it's a LOCAL one, ask for paste or cd
1341 // * in all other cases, just paste 1341 // * in all other cases, just paste
1342 // (for non-local ones, or for a list of URLs, 'cd' is nonsense) 1342 // (for non-local ones, or for a list of URLs, 'cd' is nonsense)
1343 QStrList strlist; 1343 QStrList strlist;
1344 int file_count = 0; 1344 int file_count = 0;
1345 dropText = ""; 1345 dropText = "";
1346 bool bPopup = true; 1346 bool bPopup = true;
1347 1347
1348 if(QUriDrag::decode(event, strlist)) { 1348 if(QUriDrag::decode(event, strlist)) {
1349 if (strlist.count()) { 1349 if (strlist.count()) {
1350 for(const char* p = strlist.first(); p; p = strlist.next()) { 1350 for(const char* p = strlist.first(); p; p = strlist.next()) {
1351 if(file_count++ > 0) { 1351 if(file_count++ > 0) {
1352 dropText += " "; 1352 dropText += " ";
1353 bPopup = false; // more than one file, don't popup 1353 bPopup = false; // more than one file, don't popup
1354 } 1354 }
1355 1355
1356/* 1356/*
1357 KURL url(p); 1357 KURL url(p);
1358 if (url.isLocalFile()) { 1358 if (url.isLocalFile()) {
1359 dropText += url.path(); // local URL : remove protocol 1359 dropText += url.path(); // local URL : remove protocol
1360 } 1360 }
1361 else { 1361 else {
1362 dropText += url.prettyURL(); 1362 dropText += url.prettyURL();
1363 bPopup = false; // a non-local file, don't popup 1363 bPopup = false; // a non-local file, don't popup
1364 } 1364 }
1365*/ 1365*/
1366 1366
1367 } 1367 }
1368 1368
1369 if (bPopup) 1369 if (bPopup)
1370 // m_drop->popup(pos() + event->pos()); 1370 // m_drop->popup(pos() + event->pos());
1371 m_drop->popup(mapToGlobal(event->pos())); 1371 m_drop->popup(mapToGlobal(event->pos()));
1372 else 1372 else
1373 { 1373 {
1374 if (currentSession) { 1374 if (currentSession) {
1375 currentSession->getEmulation()->sendString(dropText.local8Bit()); 1375 currentSession->getEmulation()->sendString(dropText.local8Bit());
1376 } 1376 }
1377// kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; 1377// kdDebug() << "Drop:" << dropText.local8Bit() << "\n";
1378 } 1378 }
1379 } 1379 }
1380 } 1380 }
1381 else if(QTextDrag::decode(event, dropText)) { 1381 else if(QTextDrag::decode(event, dropText)) {
1382// kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; 1382// kdDebug() << "Drop:" << dropText.local8Bit() << "\n";
1383 if (currentSession) { 1383 if (currentSession) {
1384 currentSession->getEmulation()->sendString(dropText.local8Bit()); 1384 currentSession->getEmulation()->sendString(dropText.local8Bit());
1385 } 1385 }
1386 // Paste it 1386 // Paste it
1387 } 1387 }
1388} 1388}
1389#endif 1389#endif
1390 1390
1391 1391
1392void TEWidget::drop_menu_activated(int item) 1392void TEWidget::drop_menu_activated(int /*item*/)
1393{ 1393{
1394#ifndef QT_NO_DRAGANDDROP 1394#ifndef QT_NO_DRAGANDDROP
1395 switch (item) 1395 switch (item)
1396 { 1396 {
1397 case 0: // paste 1397 case 0: // paste
1398 currentSession->getEmulation()->sendString(dropText.local8Bit()); 1398 currentSession->getEmulation()->sendString(dropText.local8Bit());
1399// KWM::activate((Window)this->winId()); 1399// KWM::activate((Window)this->winId());
1400 break; 1400 break;
1401 case 1: // cd ... 1401 case 1: // cd ...
1402 currentSession->getEmulation()->sendString("cd "); 1402 currentSession->getEmulation()->sendString("cd ");
1403 struct stat statbuf; 1403 struct stat statbuf;
1404 if ( ::stat( QFile::encodeName( dropText ), &statbuf ) == 0 ) 1404 if ( ::stat( QFile::encodeName( dropText ), &statbuf ) == 0 )
1405 { 1405 {
1406 if ( !S_ISDIR(statbuf.st_mode) ) 1406 if ( !S_ISDIR(statbuf.st_mode) )
1407 { 1407 {
1408/* 1408/*
1409 KURL url; 1409 KURL url;
1410 url.setPath( dropText ); 1410 url.setPath( dropText );
1411 dropText = url.directory( true, false ); // remove filename 1411 dropText = url.directory( true, false ); // remove filename
1412*/ 1412*/
1413 } 1413 }
1414 } 1414 }
1415 dropText.replace(QRegExp(" "), "\\ "); // escape spaces 1415 dropText.replace(QRegExp(" "), "\\ "); // escape spaces
1416 currentSession->getEmulation()->sendString(dropText.local8Bit()); 1416 currentSession->getEmulation()->sendString(dropText.local8Bit());
1417 currentSession->getEmulation()->sendString("\n"); 1417 currentSession->getEmulation()->sendString("\n");
1418// KWM::activate((Window)this->winId()); 1418// KWM::activate((Window)this->winId());
1419 break; 1419 break;
1420 } 1420 }
1421#endif 1421#endif
1422} 1422}
1423 1423
1424void TEWidget::setWrapAt(int columns) 1424void TEWidget::setWrapAt(int columns)
1425{ 1425{
1426 vcolumns = columns; 1426 vcolumns = columns;
1427 propagateSize(); 1427 propagateSize();
1428 update(); 1428 update();
1429} 1429}
diff --git a/core/apps/embeddedkonsole/konsole.cpp b/core/apps/embeddedkonsole/konsole.cpp
index c5df47f..cbea7bd 100644
--- a/core/apps/embeddedkonsole/konsole.cpp
+++ b/core/apps/embeddedkonsole/konsole.cpp
@@ -1,1935 +1,1926 @@
1 1
2/* ---------------------------------------------------------------------- */ 2/* ---------------------------------------------------------------------- */
3/* */ 3/* */
4/* [main.C] Konsole */ 4/* [main.C] Konsole */
5/* */ 5/* */
6/* ---------------------------------------------------------------------- */ 6/* ---------------------------------------------------------------------- */
7/* */ 7/* */
8/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ 8/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */
9/* */ 9/* */
10/* This file is part of Konsole, an X terminal. */ 10/* This file is part of Konsole, an X terminal. */
11/* */ 11/* */
12/* The material contained in here more or less directly orginates from */ 12/* The material contained in here more or less directly orginates from */
13/* kvt, which is copyright (c) 1996 by Matthias Ettrich <ettrich@kde.org> */ 13/* kvt, which is copyright (c) 1996 by Matthias Ettrich <ettrich@kde.org> */
14/* */ 14/* */
15/* ---------------------------------------------------------------------- */ 15/* ---------------------------------------------------------------------- */
16/* */ 16/* */
17/* Ported Konsole to Qt/Embedded */ 17/* Ported Konsole to Qt/Embedded */
18/* */ 18/* */
19/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ 19/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */
20/* */ 20/* */
21/* -------------------------------------------------------------------------- */ 21/* -------------------------------------------------------------------------- */
22// enhancements added by L.J. Potter <ljp@llornkcor.com> 22// enhancements added by L.J. Potter <ljp@llornkcor.com>
23// enhancements added by Phillip Kuhn 23// enhancements added by Phillip Kuhn
24 24
25#include <stdlib.h> 25#include <stdlib.h>
26#include <sys/types.h> 26#include <sys/types.h>
27#include <pwd.h> 27#include <pwd.h>
28#include <unistd.h> 28#include <unistd.h>
29 29
30#ifdef QT_QWS_OPIE 30#ifdef QT_QWS_OPIE
31#include <opie2/ocolorpopupmenu.h> 31#include <opie2/ocolorpopupmenu.h>
32#endif 32#endif
33 33
34#include <qpe/resource.h> 34#include <qpe/resource.h>
35 35
36#include <qmenubar.h> 36#include <qmenubar.h>
37#include <qtabbar.h> 37#include <qtabbar.h>
38#include <qpe/config.h> 38#include <qpe/config.h>
39#include <qfontdatabase.h> 39#include <qfontdatabase.h>
40#include <qfile.h> 40#include <qfile.h>
41#include <qspinbox.h> 41#include <qspinbox.h>
42#include <qlayout.h> 42#include <qlayout.h>
43 43
44#include <sys/wait.h> 44#include <sys/wait.h>
45#include <stdio.h> 45#include <stdio.h>
46#include <stdlib.h> 46#include <stdlib.h>
47#include <assert.h> 47#include <assert.h>
48 48
49#include "konsole.h" 49#include "konsole.h"
50#include "commandeditdialog.h" 50#include "commandeditdialog.h"
51 51
52using namespace Opie; 52using namespace Opie;
53class EKNumTabBar : public QTabBar 53class EKNumTabBar : public QTabBar
54{ 54{
55public: 55public:
56 EKNumTabBar(QWidget *parent = 0, const char *name = 0) : 56 EKNumTabBar(QWidget *parent = 0, const char *name = 0) :
57 QTabBar(parent, name) 57 QTabBar(parent, name)
58 {} 58 {}
59 59
60 // QList<QTab> *getTabList() { return(tabList()); } 60 // QList<QTab> *getTabList() { return(tabList()); }
61 61
62 void numberTabs() 62 void numberTabs()
63 { 63 {
64 // Yes, it really is this messy. QTabWidget needs functions 64 // Yes, it really is this messy. QTabWidget needs functions
65 // that provide acces to tabs in a sequential way. 65 // that provide acces to tabs in a sequential way.
66 int m=INT_MIN; 66 int m=INT_MIN;
67 for (int i=0; i<count(); i++) 67 for (int i=0; i<count(); i++)
68 { 68 {
69 QTab* left=0; 69 QTab* left=0;
70 QListIterator<QTab> it(*tabList()); 70 QListIterator<QTab> it(*tabList());
71 int x=INT_MAX; 71 int x=INT_MAX;
72 for( QTab* t; (t=it.current()); ++it ) 72 for( QTab* t; (t=it.current()); ++it )
73 { 73 {
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 { 76 {
77 x = tx; 77 x = tx;
78 left = t; 78 left = t;
79 } 79 }
80 } 80 }
81 if ( left ) 81 if ( left )
82 { 82 {
83 left->setText(QString::number(i+1)); 83 left->setText(QString::number(i+1));
84 m = left->rect().x(); 84 m = left->rect().x();
85 } 85 }
86 } 86 }
87 } 87 }
88 88
89 virtual QSize sizeHint() const 89 virtual QSize sizeHint() const
90 { 90 {
91 if (isHidden()) 91 if (isHidden())
92 { 92 {
93 return(QSize(0,0)); 93 return(QSize(0,0));
94 } 94 }
95 else 95 else
96 { 96 {
97 QSize size = QTabBar::sizeHint(); 97 QSize size = QTabBar::sizeHint();
98 int shrink = 5; 98 int shrink = 5;
99 if (qApp->desktop()->width() > 600 || qApp->desktop()->height() > 600) 99 if (qApp->desktop()->width() > 600 || qApp->desktop()->height() > 600)
100 { 100 {
101 shrink = 10; 101 shrink = 10;
102 } 102 }
103 size.setHeight(size.height() - shrink); 103 size.setHeight(size.height() - shrink);
104 return(size); 104 return(size);
105 } 105 }
106 } 106 }
107 107
108}; 108};
109 109
110class EKNumTabWidget : public QTabWidget 110class EKNumTabWidget : public QTabWidget
111{ 111{
112public: 112public:
113 EKNumTabWidget(QWidget* parent) : QTabWidget(parent) 113 EKNumTabWidget(QWidget* parent) : QTabWidget(parent)
114 { 114 {
115 setTabBar(new EKNumTabBar(parent,"EKTabBar")); 115 setTabBar(new EKNumTabBar(parent,"EKTabBar"));
116 setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); 116 setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );
117 } 117 }
118 118
119 EKNumTabBar *getTabBar() const 119 EKNumTabBar *getTabBar() const
120 { 120 {
121 return ((EKNumTabBar*)tabBar()); 121 return ((EKNumTabBar*)tabBar());
122 } 122 }
123 123
124 124
125 void addTab(QWidget* w) 125 void addTab(QWidget* w)
126 { 126 {
127 QTab* t = new QTab(QString::number(tabBar()->count()+1)); 127 QTab* t = new QTab(QString::number(tabBar()->count()+1));
128 QTabWidget::addTab(w,t); 128 QTabWidget::addTab(w,t);
129 } 129 }
130 130
131 void removeTab(QWidget* w) 131 void removeTab(QWidget* w)
132 { 132 {
133 removePage(w); 133 removePage(w);
134 ((EKNumTabBar*)tabBar())->numberTabs(); 134 ((EKNumTabBar*)tabBar())->numberTabs();
135 } 135 }
136}; 136};
137 137
138// This could be configurable or dynamicly generated from the bash history 138// This could be configurable or dynamicly generated from the bash history
139// file of the user 139// file of the user
140static const char *commonCmds[] = 140static const char *commonCmds[] =
141 { 141 {
142 "ls ", // I left this here, cause it looks better than the first alpha 142 "ls ", // I left this here, cause it looks better than the first alpha
143 "cardctl eject", 143 "cardctl eject",
144 "cat ", 144 "cat ",
145 "cd ", 145 "cd ",
146 "chmod ", 146 "chmod ",
147 "clear", 147 "clear",
148 "cp ", 148 "cp ",
149 "dc ", 149 "dc ",
150 "df ", 150 "df ",
151 "dmesg", 151 "dmesg",
152 "echo ", 152 "echo ",
153 "env", 153 "env",
154 "find ", 154 "find ",
155 "free", 155 "free",
156 "grep ", 156 "grep ",
157 "ifconfig ", 157 "ifconfig ",
158 "ipkg ", 158 "ipkg ",
159 "mkdir ", 159 "mkdir ",
160 "mv ", 160 "mv ",
161 "nc localhost 7776", 161 "nc localhost 7776",
162 "nc localhost 7777", 162 "nc localhost 7777",
163 "netstat ", 163 "netstat ",
164 "nslookup ", 164 "nslookup ",
165 "ping ", 165 "ping ",
166 "ps aux", 166 "ps aux",
167 "pwd ", 167 "pwd ",
168 "qcop QPE/System 'linkChanged(QString)' ''", 168 "qcop QPE/System 'linkChanged(QString)' ''",
169 "qcop QPE/System 'restart()'", 169 "qcop QPE/System 'restart()'",
170 "qcop QPE/System 'quit()'", 170 "qcop QPE/System 'quit()'",
171 "rm ", 171 "rm ",
172 "rmdir ", 172 "rmdir ",
173 "route ", 173 "route ",
174 "set ", 174 "set ",
175 "traceroute", 175 "traceroute",
176 176
177 /* 177 /*
178 "gzip", 178 "gzip",
179 "gunzip", 179 "gunzip",
180 "chgrp", 180 "chgrp",
181 "chown", 181 "chown",
182 "date", 182 "date",
183 "dd", 183 "dd",
184 "df", 184 "df",
185 "dmesg", 185 "dmesg",
186 "fuser", 186 "fuser",
187 "hostname", 187 "hostname",
188 "kill", 188 "kill",
189 "killall", 189 "killall",
190 "ln", 190 "ln",
191 "ping", 191 "ping",
192 "mount", 192 "mount",
193 "more", 193 "more",
194 "sort", 194 "sort",
195 "touch", 195 "touch",
196 "umount", 196 "umount",
197 "mknod", 197 "mknod",
198 "netstat", 198 "netstat",
199 */ 199 */
200 200
201 "exit", 201 "exit",
202 NULL 202 NULL
203 }; 203 };
204 204
205 205
206static void konsoleInit(const char** shell) { 206static void konsoleInit(const char** shell) {
207 if(setuid(getuid()) !=0) qDebug("setuid failed"); 207 if(setuid(getuid()) !=0) qDebug("setuid failed");
208 if(setgid(getgid()) != 0) qDebug("setgid failed"); // drop privileges 208 if(setgid(getgid()) != 0) qDebug("setgid failed"); // drop privileges
209 209
210 210
211// QPEApplication::grabKeyboard(); // for CTRL and ALT 211// QPEApplication::grabKeyboard(); // for CTRL and ALT
212 212
213 qDebug("keyboard grabbed"); 213 qDebug("keyboard grabbed");
214#ifdef FAKE_CTRL_AND_ALT 214#ifdef FAKE_CTRL_AND_ALT
215 qDebug("Fake Ctrl and Alt defined"); 215 qDebug("Fake Ctrl and Alt defined");
216 QPEApplication::grabKeyboard(); // for CTRL and ALT 216 QPEApplication::grabKeyboard(); // for CTRL and ALT
217#endif 217#endif
218 218
219 *shell = getenv("SHELL"); 219 *shell = getenv("SHELL");
220 qWarning("SHell initially is %s", *shell ); 220 qWarning("SHell initially is %s", *shell );
221 221
222 if (shell == NULL || *shell == '\0') { 222 if (shell == NULL || *shell == '\0') {
223 struct passwd *ent = 0; 223 struct passwd *ent = 0;
224 uid_t me = getuid(); 224 uid_t me = getuid();
225 *shell = "/bin/sh"; 225 *shell = "/bin/sh";
226 226
227 while ( (ent = getpwent()) != 0 ) { 227 while ( (ent = getpwent()) != 0 ) {
228 if (ent->pw_uid == me) { 228 if (ent->pw_uid == me) {
229 if (ent->pw_shell != "") 229 if (ent->pw_shell != "")
230 *shell = ent->pw_shell; 230 *shell = ent->pw_shell;
231 break; 231 break;
232 } 232 }
233 } 233 }
234 endpwent(); 234 endpwent();
235 } 235 }
236 236
237 if( putenv((char*)"COLORTERM=") !=0) 237 if( putenv((char*)"COLORTERM=") !=0)
238 qDebug("putenv failed"); // to trigger mc's color detection 238 qDebug("putenv failed"); // to trigger mc's color detection
239} 239}
240 240
241 241
242Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) : 242Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) :
243 QMainWindow(parent, name, fl) 243 QMainWindow(parent, name, fl)
244{ 244{
245 QStrList tmp; const char* shell; 245 QStrList tmp; const char* shell;
246 246
247 konsoleInit( &shell); 247 konsoleInit( &shell);
248 init(shell,tmp); 248 init(shell,tmp);
249} 249}
250 250
251Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int) 251Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int)
252 : QMainWindow(0, name) 252 : QMainWindow(0, name)
253{ 253{
254 init(_pgm,_args); 254 init(_pgm,_args);
255} 255}
256 256
257struct HistoryItem 257struct HistoryItem
258{ 258{
259 HistoryItem(int c, const QString &l) 259 HistoryItem(int c, const QString &l)
260 { 260 {
261 count = c; 261 count = c;
262 line = l; 262 line = l;
263 } 263 }
264 int count; 264 int count;
265 QString line; 265 QString line;
266}; 266};
267 267
268class HistoryList : public QList<HistoryItem> 268class HistoryList : public QList<HistoryItem>
269{ 269{
270 virtual int compareItems( QCollection::Item item1, QCollection::Item item2) 270 virtual int compareItems( QCollection::Item item1, QCollection::Item item2)
271 { 271 {
272 int c1 = ((HistoryItem*)item1)->count; 272 int c1 = ((HistoryItem*)item1)->count;
273 int c2 = ((HistoryItem*)item2)->count; 273 int c2 = ((HistoryItem*)item2)->count;
274 if (c1 > c2) 274 if (c1 > c2)
275 return(1); 275 return(1);
276 if (c1 < c2) 276 if (c1 < c2)
277 return(-1); 277 return(-1);
278 return(0); 278 return(0);
279 } 279 }
280}; 280};
281 281
282void Konsole::initCommandList() 282void Konsole::initCommandList()
283{ 283{
284 // qDebug("Konsole::initCommandList"); 284 // qDebug("Konsole::initCommandList");
285 Config cfg( "Konsole" ); 285 Config cfg( "Konsole" );
286 cfg.setGroup("Commands"); 286 cfg.setGroup("Commands");
287 // commonCombo->setInsertionPolicy(QComboBox::AtCurrent); 287 // commonCombo->setInsertionPolicy(QComboBox::AtCurrent);
288 commonCombo->clear(); 288 commonCombo->clear();
289 289
290 if (cfg.readEntry("ShellHistory","TRUE") == "TRUE") 290 if (cfg.readEntry("ShellHistory","TRUE") == "TRUE")
291 { 291 {
292 QString histfilename = QString(getenv("HOME")) + "/.bash_history"; 292 QString histfilename = QString(getenv("HOME")) + "/.bash_history";
293 histfilename = cfg.readEntry("ShellHistoryPath",histfilename); 293 histfilename = cfg.readEntry("ShellHistoryPath",histfilename);
294 QFile histfile(histfilename); 294 QFile histfile(histfilename);
295 // note: compiler barfed on: 295 // note: compiler barfed on:
296 // QFile histfile(QString(getenv("HOME")) + "/.bash_history"); 296 // QFile histfile(QString(getenv("HOME")) + "/.bash_history");
297 if (histfile.open( IO_ReadOnly )) 297 if (histfile.open( IO_ReadOnly ))
298 { 298 {
299 QString line; 299 QString line;
300 uint i; 300 uint i;
301 HistoryList items; 301 HistoryList items;
302 302
303 int lineno = 0; 303 int lineno = 0;
304 while(!histfile.atEnd()) 304 while(!histfile.atEnd())
305 { 305 {
306 if (histfile.readLine(line, 200) < 0) 306 if (histfile.readLine(line, 200) < 0)
307 { 307 {
308 break; 308 break;
309 } 309 }
310 line = line.left(line.length()-1); 310 line = line.left(line.length()-1);
311 lineno++; 311 lineno++;
312 312
313 for(i=0; i<items.count(); i++) 313 for(i=0; i<items.count(); i++)
314 { 314 {
315 if (line == items.at(i)->line) 315 if (line == items.at(i)->line)
316 { 316 {
317 // weight recent commands & repeated commands more 317 // weight recent commands & repeated commands more
318 // by adding up the index of each command 318 // by adding up the index of each command
319 items.at(i)->count += lineno; 319 items.at(i)->count += lineno;
320 break; 320 break;
321 } 321 }
322 } 322 }
323 if (i >= items.count()) 323 if (i >= items.count())
324 { 324 {
325 items.append(new HistoryItem(lineno, line)); 325 items.append(new HistoryItem(lineno, line));
326 } 326 }
327 } 327 }
328 items.sort(); 328 items.sort();
329 int n = items.count(); 329 int n = items.count();
330 if (n > 40) 330 if (n > 40)
331 { 331 {
332 n = 40; 332 n = 40;
333 } 333 }
334 for(int i=0; i<n; i++) 334 for(int i=0; i<n; i++)
335 { 335 {
336 // should insert start of command, but keep whole thing 336 // should insert start of command, but keep whole thing
337 if (items.at(items.count()-i-1)->line.length() < 30) 337 if (items.at(items.count()-i-1)->line.length() < 30)
338 { 338 {
339 commonCombo->insertItem(items.at(items.count()-i-1)->line); 339 commonCombo->insertItem(items.at(items.count()-i-1)->line);
340 } 340 }
341 } 341 }
342 histfile.close(); 342 histfile.close();
343 } 343 }
344 } 344 }
345 if (cfg.readEntry("Commands Set","FALSE") == "FALSE") 345 if (cfg.readEntry("Commands Set","FALSE") == "FALSE")
346 { 346 {
347 for (int i = 0; commonCmds[i] != NULL; i++) 347 for (int i = 0; commonCmds[i] != NULL; i++)
348 { 348 {
349 commonCombo->insertItem(commonCmds[i]); 349 commonCombo->insertItem(commonCmds[i]);
350 } 350 }
351 } 351 }
352 else 352 else
353 { 353 {
354 for (int i = 0; i < 100; i++) 354 for (int i = 0; i < 100; i++)
355 { 355 {
356 if (!(cfg.readEntry( QString::number(i),"")).isEmpty()) 356 if (!(cfg.readEntry( QString::number(i),"")).isEmpty())
357 commonCombo->insertItem(cfg.readEntry( QString::number(i),"")); 357 commonCombo->insertItem(cfg.readEntry( QString::number(i),""));
358 } 358 }
359 } 359 }
360 360
361 361
362} 362}
363 363
364static void sig_handler(int x) 364static void sig_handler(int x)
365{ 365{
366 printf("got signal %d\n",x); 366 printf("got signal %d\n",x);
367} 367}
368 368
369void Konsole::init(const char* _pgm, QStrList & _args) 369void Konsole::init(const char* _pgm, QStrList & _args)
370{ 370{
371 371
372#if 0 372#if 0
373 for(int i=1; i<=31; i++) 373 for(int i=1; i<=31; i++)
374 { 374 {
375 if (i != SIGPIPE && i != SIGPROF && i != SIGSEGV 375 if (i != SIGPIPE && i != SIGPROF && i != SIGSEGV
376 && i != SIGINT && i != SIGILL && i != SIGTERM 376 && i != SIGINT && i != SIGILL && i != SIGTERM
377 && i != SIGBUS) 377 && i != SIGBUS)
378 signal(i,sig_handler); 378 signal(i,sig_handler);
379 } 379 }
380#endif 380#endif
381 signal(SIGSTOP, sig_handler); 381 signal(SIGSTOP, sig_handler);
382 signal(SIGCONT, sig_handler); 382 signal(SIGCONT, sig_handler);
383 signal(SIGTSTP, sig_handler); 383 signal(SIGTSTP, sig_handler);
384 384
385 b_scroll = TRUE; // histon; 385 b_scroll = TRUE; // histon;
386 n_keytab = 0; 386 n_keytab = 0;
387 n_render = 0; 387 n_render = 0;
388 startUp=0; 388 startUp=0;
389 fromMenu = FALSE; 389 fromMenu = FALSE;
390 fullscreen = false; 390 fullscreen = false;
391 391
392 setCaption( tr( "Konsole" ) ); 392 setCaption( tr( "Konsole" ) );
393 setIcon( Resource::loadPixmap( "konsole/Terminal" ) ); 393 setIcon( Resource::loadPixmap( "konsole/Terminal" ) );
394 394
395 Config cfg( "Konsole" ); 395 Config cfg( "Konsole" );
396 cfg.setGroup("Font"); 396 cfg.setGroup("Font");
397 QString tmp; 397 QString tmp;
398 398
399 // initialize the list of allowed fonts /////////////////////////////////// 399 // initialize the list of allowed fonts ///////////////////////////////////
400 400
401 QString cfgFontName = cfg.readEntry("FontName","Lcfont"); 401 QString cfgFontName = cfg.readEntry("FontName","Lcfont");
402 int cfgFontSize = cfg.readNumEntry("FontSize",18); 402 int cfgFontSize = cfg.readNumEntry("FontSize",18);
403 403
404 cfont = -1; 404 cfont = -1;
405 405
406 // this code causes repeated access to all the font files 406 // this code causes repeated access to all the font files
407 // which does slow down startup 407 // which does slow down startup
408 QFontDatabase fontDB; 408 QFontDatabase fontDB;
409 QStringList familyNames; 409 QStringList familyNames;
410 familyNames = fontDB.families( FALSE ); 410 familyNames = fontDB.families( FALSE );
411 QString s; 411 QString s;
412 int fontIndex = 0; 412 int fontIndex = 0;
413 int familyNum = 0; 413 int familyNum = 0;
414 fontList = new QPopupMenu( this ); 414 fontList = new QPopupMenu( this );
415 415
416 for(uint j = 0; j < (uint)familyNames.count(); j++) 416 for(uint j = 0; j < (uint)familyNames.count(); j++)
417 { 417 {
418 s = familyNames[j]; 418 s = familyNames[j];
419 if ( s.contains('-') ) 419 if ( s.contains('-') )
420 { 420 {
421 int i = s.find('-'); 421 int i = s.find('-');
422 s = s.right( s.length() - i - 1 ) + " [" + s.left( i ) + "]"; 422 s = s.right( s.length() - i - 1 ) + " [" + s.left( i ) + "]";
423 } 423 }
424 s[0] = s[0].upper(); 424 s[0] = s[0].upper();
425 425
426 QValueList<int> sizes = fontDB.pointSizes( familyNames[j] ); 426 QValueList<int> sizes = fontDB.pointSizes( familyNames[j] );
427 427
428 printf("family[%d] = %s with %d sizes\n", j, familyNames[j].latin1(), 428 printf("family[%d] = %s with %d sizes\n", j, familyNames[j].latin1(),
429 sizes.count()); 429 sizes.count());
430 430
431 if (sizes.count() > 0) 431 if (sizes.count() > 0)
432 { 432 {
433 QPopupMenu *sizeMenu; 433 QPopupMenu *sizeMenu;
434 QFont f; 434 QFont f;
435 int last_width = -1; 435 int last_width = -1;
436 sizeMenu = NULL; 436 sizeMenu = NULL;
437 437
438 for(uint i = 0; i < (uint)sizes.count() + 4; i++) 438 for(uint i = 0; i < (uint)sizes.count() + 4; i++)
439 { 439 {
440 // printf("family %s size %d ", familyNames[j].latin1(), sizes[i]); 440 // printf("family %s size %d ", familyNames[j].latin1(), sizes[i]);
441 // need to divide by 10 on the Z, but not otherwise 441 // need to divide by 10 on the Z, but not otherwise
442 int size; 442 int size;
443 443
444 if (i >= (uint)sizes.count()) 444 if (i >= (uint)sizes.count())
445 { 445 {
446 // try for expandable fonts 446 // try for expandable fonts
447 size = sizes[sizes.count()-1] + 2 * (i - sizes.count() + 1); 447 size = sizes[sizes.count()-1] + 2 * (i - sizes.count() + 1);
448 } 448 }
449 else 449 else
450 { 450 {
451 printf("sizes[%d] = %d\n", i, sizes[i]); 451 printf("sizes[%d] = %d\n", i, sizes[i]);
452 size = sizes[i]; 452 size = sizes[i];
453 } 453 }
454 454
455 f = QFont(familyNames[j], size); 455 f = QFont(familyNames[j], size);
456 f.setFixedPitch(true); 456 f.setFixedPitch(true);
457 QFontMetrics fm(f); 457 QFontMetrics fm(f);
458 // don't trust f.fixedPitch() or f.exactMatch(), they lie!! 458 // don't trust f.fixedPitch() or f.exactMatch(), they lie!!
459 if (fm.width("l") == fm.width("m") 459 if (fm.width("l") == fm.width("m")
460 && (i < (uint)sizes.count() 460 && (i < (uint)sizes.count()
461 || fm.width("m") > last_width)) 461 || fm.width("m") > last_width))
462 { 462 {
463 if (i < (uint)sizes.count()) 463 if (i < (uint)sizes.count())
464 { 464 {
465 last_width = fm.width("m"); 465 last_width = fm.width("m");
466 } 466 }
467 if (sizeMenu == NULL) 467 if (sizeMenu == NULL)
468 { 468 {
469 sizeMenu = new QPopupMenu(); 469 sizeMenu = new QPopupMenu();
470 } 470 }
471 int id = sizeMenu->insertItem(QString("%1").arg(size), fontIndex); 471 int id = sizeMenu->insertItem(QString("%1").arg(size), fontIndex);
472 sizeMenu->setItemParameter(id, fontIndex); 472 sizeMenu->setItemParameter(id, fontIndex);
473 sizeMenu->connectItem(id, this, SLOT(setFont(int))); 473 sizeMenu->connectItem(id, this, SLOT(setFont(int)));
474 QString name = s + " " + QString::number(size); 474 QString name = s + " " + QString::number(size);
475 fonts.append(new VTFont(name, f, familyNames[j], familyNum, size)); 475 fonts.append(new VTFont(name, f, familyNames[j], familyNum, size));
476 if (familyNames[j] == cfgFontName && size == cfgFontSize) 476 if (familyNames[j] == cfgFontName && size == cfgFontSize)
477 { 477 {
478 cfont = fontIndex; 478 cfont = fontIndex;
479 } 479 }
480 printf("FOUND: %s family %s size %d\n", name.latin1(), familyNames[j].latin1(), size); 480 printf("FOUND: %s family %s size %d\n", name.latin1(), familyNames[j].latin1(), size);
481 fontIndex++; 481 fontIndex++;
482 } 482 }
483 } 483 }
484 if (sizeMenu) 484 if (sizeMenu)
485 { 485 {
486 fontList->insertItem(s, sizeMenu, familyNum + 1000); 486 fontList->insertItem(s, sizeMenu, familyNum + 1000);
487 487
488 familyNum++; 488 familyNum++;
489 } 489 }
490 } 490 }
491 491
492 } 492 }
493 493
494 if (cfont < 0 || cfont >= (int)fonts.count()) 494 if (cfont < 0 || cfont >= (int)fonts.count())
495 { 495 {
496 cfont = 0; 496 cfont = 0;
497 } 497 }
498 498
499 // create terminal emulation framework //////////////////////////////////// 499 // create terminal emulation framework ////////////////////////////////////
500 nsessions = 0; 500 nsessions = 0;
501 501
502 tab = new EKNumTabWidget(this); 502 tab = new EKNumTabWidget(this);
503 // tab->setMargin(tab->margin()-5); 503 // tab->setMargin(tab->margin()-5);
504 connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*))); 504 connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*)));
505 505
506 // create terminal toolbar //////////////////////////////////////////////// 506 // create terminal toolbar ////////////////////////////////////////////////
507 setToolBarsMovable( FALSE ); 507 setToolBarsMovable( FALSE );
508 menuToolBar = new QToolBar( this ); 508 menuToolBar = new QToolBar( this );
509 menuToolBar->setHorizontalStretchable( TRUE ); 509 menuToolBar->setHorizontalStretchable( TRUE );
510 510
511 QMenuBar *menuBar = new QMenuBar( menuToolBar ); 511 QMenuBar *menuBar = new QMenuBar( menuToolBar );
512 512
513 bool c7xx = false;
514 if (qApp->desktop()->width() > 600 || qApp->desktop()->height() > 600)
515 {
516 c7xx = true;
517 }
518 QFont menuFont;
519 menuFont.setPointSize(c7xx? 18 : 10);
520 qApp->setFont(menuFont, true);
521
522 setFont(cfont); 513 setFont(cfont);
523 514
524 configMenu = new QPopupMenu( this); 515 configMenu = new QPopupMenu( this);
525 colorMenu = new QPopupMenu( this); 516 colorMenu = new QPopupMenu( this);
526 scrollMenu = new QPopupMenu( this); 517 scrollMenu = new QPopupMenu( this);
527 editCommandListMenu = new QPopupMenu( this); 518 editCommandListMenu = new QPopupMenu( this);
528 519
529 configMenu->insertItem(tr("Command List"), editCommandListMenu); 520 configMenu->insertItem(tr("Command List"), editCommandListMenu);
530 521
531 bool listHidden; 522 bool listHidden;
532 cfg.setGroup("Menubar"); 523 cfg.setGroup("Menubar");
533 if( cfg.readEntry("Hidden","FALSE") == "TRUE") 524 if( cfg.readEntry("Hidden","FALSE") == "TRUE")
534 { 525 {
535 ec_cmdlist = editCommandListMenu->insertItem( tr( "Show command list" )); 526 ec_cmdlist = editCommandListMenu->insertItem( tr( "Show command list" ));
536 listHidden=TRUE; 527 listHidden=TRUE;
537 } 528 }
538 else 529 else
539 { 530 {
540 ec_cmdlist = editCommandListMenu->insertItem( tr( "Hide command list" )); 531 ec_cmdlist = editCommandListMenu->insertItem( tr( "Hide command list" ));
541 listHidden=FALSE; 532 listHidden=FALSE;
542 } 533 }
543 534
544 cfg.setGroup("Tabs"); 535 cfg.setGroup("Tabs");
545 536
546 tabMenu = new QPopupMenu(this); 537 tabMenu = new QPopupMenu(this);
547 tm_bottom = tabMenu->insertItem(tr("Bottom" )); 538 tm_bottom = tabMenu->insertItem(tr("Bottom" ));
548 tm_top = tabMenu->insertItem(tr("Top")); 539 tm_top = tabMenu->insertItem(tr("Top"));
549 tm_hidden = tabMenu->insertItem(tr("Hidden")); 540 tm_hidden = tabMenu->insertItem(tr("Hidden"));
550 541
551 configMenu->insertItem(tr("Tabs"), tabMenu); 542 configMenu->insertItem(tr("Tabs"), tabMenu);
552 543
553 tmp=cfg.readEntry("Position","Top"); 544 tmp=cfg.readEntry("Position","Top");
554 if(tmp=="Top") 545 if(tmp=="Top")
555 { 546 {
556 tab->setTabPosition(QTabWidget::Top); 547 tab->setTabPosition(QTabWidget::Top);
557 tab->getTabBar()->show(); 548 tab->getTabBar()->show();
558 tabPos = tm_top; 549 tabPos = tm_top;
559 } 550 }
560 else if (tmp=="Bottom") 551 else if (tmp=="Bottom")
561 { 552 {
562 tab->setTabPosition(QTabWidget::Bottom); 553 tab->setTabPosition(QTabWidget::Bottom);
563 tab->getTabBar()->show(); 554 tab->getTabBar()->show();
564 tabPos = tm_bottom; 555 tabPos = tm_bottom;
565 } 556 }
566 else 557 else
567 { 558 {
568 tab->getTabBar()->hide(); 559 tab->getTabBar()->hide();
569 tab->setMargin(tab->margin()); 560 tab->setMargin(tab->margin());
570 tabPos = tm_hidden; 561 tabPos = tm_hidden;
571 } 562 }
572 563
573 cm_bw = colorMenu->insertItem(tr( "Black on White")); 564 cm_bw = colorMenu->insertItem(tr( "Black on White"));
574 cm_wb = colorMenu->insertItem(tr( "White on Black")); 565 cm_wb = colorMenu->insertItem(tr( "White on Black"));
575 cm_gb = colorMenu->insertItem(tr( "Green on Black")); 566 cm_gb = colorMenu->insertItem(tr( "Green on Black"));
576 // cm_bt = colorMenu->insertItem(tr( "Black on Transparent")); 567 // cm_bt = colorMenu->insertItem(tr( "Black on Transparent"));
577 cm_br = colorMenu->insertItem(tr( "Black on Pink")); 568 cm_br = colorMenu->insertItem(tr( "Black on Pink"));
578 cm_rb = colorMenu->insertItem(tr( "Pink on Black")); 569 cm_rb = colorMenu->insertItem(tr( "Pink on Black"));
579 cm_gy = colorMenu->insertItem(tr( "Green on Yellow")); 570 cm_gy = colorMenu->insertItem(tr( "Green on Yellow"));
580 cm_bm = colorMenu->insertItem(tr( "Blue on Magenta")); 571 cm_bm = colorMenu->insertItem(tr( "Blue on Magenta"));
581 cm_mb = colorMenu->insertItem(tr( "Magenta on Blue")); 572 cm_mb = colorMenu->insertItem(tr( "Magenta on Blue"));
582 cm_cw = colorMenu->insertItem(tr( "Cyan on White")); 573 cm_cw = colorMenu->insertItem(tr( "Cyan on White"));
583 cm_wc = colorMenu->insertItem(tr( "White on Cyan")); 574 cm_wc = colorMenu->insertItem(tr( "White on Cyan"));
584 cm_bb = colorMenu->insertItem(tr( "Blue on Black")); 575 cm_bb = colorMenu->insertItem(tr( "Blue on Black"));
585 cm_ab = colorMenu->insertItem(tr( "Amber on Black")); 576 cm_ab = colorMenu->insertItem(tr( "Amber on Black"));
586 cm_default = colorMenu->insertItem(tr("default")); 577 cm_default = colorMenu->insertItem(tr("default"));
587 578
588#ifdef QT_QWS_OPIE 579#ifdef QT_QWS_OPIE
589 580
590 colorMenu->insertItem(tr( "Custom")); 581 colorMenu->insertItem(tr( "Custom"));
591#endif 582#endif
592 583
593 configMenu->insertItem(tr( "Colors") ,colorMenu); 584 configMenu->insertItem(tr( "Colors") ,colorMenu);
594 585
595 sessionList = new QPopupMenu(this); 586 sessionList = new QPopupMenu(this);
596 sessionList-> insertItem ( Resource::loadPixmap ( "konsole/Terminal" ), tr( "new session" ), this, 587 sessionList-> insertItem ( Resource::loadPixmap ( "konsole/Terminal" ), tr( "new session" ), this,
597 SLOT(newSession()) ); 588 SLOT(newSession()) );
598 589
599 // connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) )); 590 // connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) ));
600 connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) )); 591 connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) ));
601 connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuIsSelected(int) )); 592 connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuIsSelected(int) ));
602 connect( tabMenu, SIGNAL( activated(int) ), this, SLOT( tabMenuSelected(int) )); 593 connect( tabMenu, SIGNAL( activated(int) ), this, SLOT( tabMenuSelected(int) ));
603 connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int))); 594 connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int)));
604 connect( editCommandListMenu,SIGNAL(activated(int)),this,SLOT(editCommandListMenuSelected(int))); 595 connect( editCommandListMenu,SIGNAL(activated(int)),this,SLOT(editCommandListMenuSelected(int)));
605 connect( sessionList, SIGNAL(activated(int)), this, SLOT( sessionListSelected(int) ) ); 596 connect( sessionList, SIGNAL(activated(int)), this, SLOT( sessionListSelected(int) ) );
606 597
607 menuBar->insertItem( tr("View"), configMenu ); 598 menuBar->insertItem( tr("View"), configMenu );
608 menuBar->insertItem( tr("Fonts"), fontList ); 599 menuBar->insertItem( tr("Fonts"), fontList );
609 menuBar->insertItem( tr("Sessions"), sessionList ); 600 menuBar->insertItem( tr("Sessions"), sessionList );
610 601
611 toolBar = new QToolBar( this ); 602 toolBar = new QToolBar( this );
612 603
613 QAction *a; 604 QAction *a;
614 605
615 // Button Commands 606 // Button Commands
616 a = new QAction( tr("New"), Resource::loadPixmap( "konsole/Terminal" ), QString::null, 0, this, 0 ); 607 a = new QAction( tr("New"), Resource::loadPixmap( "konsole/Terminal" ), QString::null, 0, this, 0 );
617 connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); 608 connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) );
618 a->addTo( toolBar ); 609 a->addTo( toolBar );
619 610
620 a = new QAction( tr("Full Screen"), Resource::loadPixmap( "fullscreen" ), QString::null, 0, this, 0 ); 611 a = new QAction( tr("Full Screen"), Resource::loadPixmap( "fullscreen" ), QString::null, 0, this, 0 );
621 connect( a, SIGNAL( activated() ), this, SLOT( toggleFullScreen() ) ); 612 connect( a, SIGNAL( activated() ), this, SLOT( toggleFullScreen() ) );
622 a->addTo( toolBar ); 613 a->addTo( toolBar );
623 614
624 a = new QAction( tr("Zoom"), Resource::loadPixmap( "zoom" ), QString::null, 0, this, 0 ); 615 a = new QAction( tr("Zoom"), Resource::loadPixmap( "zoom" ), QString::null, 0, this, 0 );
625 connect( a, SIGNAL( activated() ), this, SLOT( cycleZoom() ) ); 616 connect( a, SIGNAL( activated() ), this, SLOT( cycleZoom() ) );
626 a->addTo( toolBar ); 617 a->addTo( toolBar );
627 618
628 619
629 /* 620 /*
630 a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 ); 621 a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 );
631 connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolBar ); 622 connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolBar );
632 a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 ); 623 a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 );
633 connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolBar ); 624 connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolBar );
634 a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 ); 625 a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 );
635 connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolBar ); 626 connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolBar );
636 */ 627 */
637 /* 628 /*
638 a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 ); 629 a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 );
639 connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolBar ); 630 connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolBar );
640 a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 ); 631 a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 );
641 connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolBar ); 632 connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolBar );
642 */ 633 */
643 a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); 634 a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 );
644 connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); 635 connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) );
645 a->addTo( toolBar ); 636 a->addTo( toolBar );
646 637
647 secondToolBar = new QToolBar( this ); 638 secondToolBar = new QToolBar( this );
648 secondToolBar->setHorizontalStretchable( TRUE ); 639 secondToolBar->setHorizontalStretchable( TRUE );
649 640
650 commonCombo = new QComboBox( secondToolBar ); 641 commonCombo = new QComboBox( secondToolBar );
651 // commonCombo->setMaximumWidth(236); 642 // commonCombo->setMaximumWidth(236);
652 643
653 ec_quick = editCommandListMenu->insertItem( tr( "Quick Edit" ) ); 644 ec_quick = editCommandListMenu->insertItem( tr( "Quick Edit" ) );
654 if( listHidden) 645 if( listHidden)
655 { 646 {
656 secondToolBar->hide(); 647 secondToolBar->hide();
657 editCommandListMenu->setItemEnabled(ec_quick ,FALSE); 648 editCommandListMenu->setItemEnabled(ec_quick ,FALSE);
658 } 649 }
659 ec_edit = editCommandListMenu->insertItem(tr( "Edit..." ) ); 650 ec_edit = editCommandListMenu->insertItem(tr( "Edit..." ) );
660 651
661 cfg.setGroup("Commands"); 652 cfg.setGroup("Commands");
662 commonCombo->setInsertionPolicy(QComboBox::AtCurrent); 653 commonCombo->setInsertionPolicy(QComboBox::AtCurrent);
663 654
664 initCommandList(); 655 initCommandList();
665 // for (int i = 0; commonCmds[i] != NULL; i++) { 656 // for (int i = 0; commonCmds[i] != NULL; i++) {
666 // commonCombo->insertItem( commonCmds[i], i ); 657 // commonCombo->insertItem( commonCmds[i], i );
667 // tmp = cfg.readEntry( QString::number(i),""); 658 // tmp = cfg.readEntry( QString::number(i),"");
668 // if(tmp != "") 659 // if(tmp != "")
669 // commonCombo->changeItem( tmp,i ); 660 // commonCombo->changeItem( tmp,i );
670 // } 661 // }
671 662
672 connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) )); 663 connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) ));
673 664
674 sm_none = scrollMenu->insertItem(tr( "None" )); 665 sm_none = scrollMenu->insertItem(tr( "None" ));
675 sm_left = scrollMenu->insertItem(tr( "Left" )); 666 sm_left = scrollMenu->insertItem(tr( "Left" ));
676 sm_right = scrollMenu->insertItem(tr( "Right" )); 667 sm_right = scrollMenu->insertItem(tr( "Right" ));
677 // scrollMenu->insertSeparator(4); 668 // scrollMenu->insertSeparator(4);
678 // scrollMenu->insertItem(tr( "Horizontal" )); 669 // scrollMenu->insertItem(tr( "Horizontal" ));
679 670
680 configMenu->insertItem(tr( "ScrollBar" ),scrollMenu); 671 configMenu->insertItem(tr( "ScrollBar" ),scrollMenu);
681 672
682 configMenu->insertItem(tr( "History..." ), this, SLOT(historyDialog())); 673 configMenu->insertItem(tr( "History..." ), this, SLOT(historyDialog()));
683 674
684 cm_wrap = configMenu->insertItem(tr( "Wrap" )); 675 cm_wrap = configMenu->insertItem(tr( "Wrap" ));
685 cfg.setGroup("ScrollBar"); 676 cfg.setGroup("ScrollBar");
686 configMenu->setItemChecked(cm_wrap, cfg.readBoolEntry("HorzScroll",0)); 677 configMenu->setItemChecked(cm_wrap, cfg.readBoolEntry("HorzScroll",0));
687 678
688 cm_beep = configMenu->insertItem(tr( "Use Beep" )); 679 cm_beep = configMenu->insertItem(tr( "Use Beep" ));
689 cfg.setGroup("Menubar"); 680 cfg.setGroup("Menubar");
690 configMenu->setItemChecked(cm_beep, cfg.readBoolEntry("useBeep",0)); 681 configMenu->setItemChecked(cm_beep, cfg.readBoolEntry("useBeep",0));
691 682
692 fullscreen_msg = new QLabel(this); 683 fullscreen_msg = new QLabel(this);
693 fullscreen_msg-> setAlignment ( AlignCenter | SingleLine ); 684 fullscreen_msg-> setAlignment ( AlignCenter | SingleLine );
694 fullscreen_msg-> hide(); 685 fullscreen_msg-> hide();
695 fullscreen_msg-> setSizePolicy ( QSizePolicy ( QSizePolicy::Expanding, QSizePolicy::Expanding )); 686 fullscreen_msg-> setSizePolicy ( QSizePolicy ( QSizePolicy::Expanding, QSizePolicy::Expanding ));
696 fullscreen_msg-> setAutoResize(true); 687 fullscreen_msg-> setAutoResize(true);
697 fullscreen_msg-> setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 688 fullscreen_msg-> setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
698 fullscreen_msg-> setText(tr("To exit fullscreen, tap here.")); 689 fullscreen_msg-> setText(tr("To exit fullscreen, tap here."));
699 690
700 fullscreen_timer = new QTimer(this); 691 fullscreen_timer = new QTimer(this);
701 connect(fullscreen_timer, SIGNAL(timeout()), 692 connect(fullscreen_timer, SIGNAL(timeout()),
702 this, SLOT(fullscreenTimeout())); 693 this, SLOT(fullscreenTimeout()));
703 show_fullscreen_msg = true; 694 show_fullscreen_msg = true;
704 695
705 //scrollMenuSelected(-29); 696 //scrollMenuSelected(-29);
706 // cfg.setGroup("ScrollBar"); 697 // cfg.setGroup("ScrollBar");
707 // if(cfg.readBoolEntry("HorzScroll",0)) { 698 // if(cfg.readBoolEntry("HorzScroll",0)) {
708 // if(cfg.readNumEntry("Position",2) == 0) 699 // if(cfg.readNumEntry("Position",2) == 0)
709 // te->setScrollbarLocation(1); 700 // te->setScrollbarLocation(1);
710 // else 701 // else
711 // te->setScrollbarLocation(0); 702 // te->setScrollbarLocation(0);
712 // te->setScrollbarLocation( cfg.readNumEntry("Position",2)); 703 // te->setScrollbarLocation( cfg.readNumEntry("Position",2));
713 // te->setWrapAt(120); 704 // te->setWrapAt(120);
714 // } 705 // }
715 // create applications ///////////////////////////////////////////////////// 706 // create applications /////////////////////////////////////////////////////
716 setCentralWidget(tab); 707 setCentralWidget(tab);
717 708
718 // load keymaps //////////////////////////////////////////////////////////// 709 // load keymaps ////////////////////////////////////////////////////////////
719 KeyTrans::loadAll(); 710 KeyTrans::loadAll();
720 for (int i = 0; i < KeyTrans::count(); i++) 711 for (int i = 0; i < KeyTrans::count(); i++)
721 { 712 {
722 KeyTrans* s = KeyTrans::find(i); 713 KeyTrans* s = KeyTrans::find(i);
723 assert( s ); 714 assert( s );
724 } 715 }
725 716
726 se_pgm = _pgm; 717 se_pgm = _pgm;
727 se_args = _args; 718 se_args = _args;
728 719
729 cfg.setGroup("CommandLine"); 720 cfg.setGroup("CommandLine");
730 721
731 if (cfg.hasKey("shell_args")) 722 if (cfg.hasKey("shell_args"))
732 { 723 {
733 QStringList se_args_list = cfg.readListEntry("shell_args",'|'); 724 QStringList se_args_list = cfg.readListEntry("shell_args",'|');
734 for(uint i = 0; i < se_args_list.count(); i++) 725 for(uint i = 0; i < se_args_list.count(); i++)
735 { 726 {
736 se_args.prepend(se_args_list[se_args_list.count() - i - 1].latin1()); 727 se_args.prepend(se_args_list[se_args_list.count() - i - 1].latin1());
737 } 728 }
738 } 729 }
739 else 730 else
740 { 731 {
741 se_args.prepend("--login"); 732 se_args.prepend("--login");
742 } 733 }
743 734
744 se_pgm = cfg.readEntry("shell_bin", QString(se_pgm)); 735 se_pgm = cfg.readEntry("shell_bin", QString(se_pgm));
745 736
746 // this is the "documentation" for those who know to look 737 // this is the "documentation" for those who know to look
747 if (! cfg.hasKey("shell_args")) 738 if (! cfg.hasKey("shell_args"))
748 { 739 {
749 cfg.writeEntry("shell_args",QStringList::fromStrList(se_args),'|'); 740 cfg.writeEntry("shell_args",QStringList::fromStrList(se_args),'|');
750 } 741 }
751 if (! cfg.hasKey("shell_bin")) 742 if (! cfg.hasKey("shell_bin"))
752 { 743 {
753 cfg.writeEntry("shell_bin",QString(se_pgm)); 744 cfg.writeEntry("shell_bin",QString(se_pgm));
754 } 745 }
755 746
756 parseCommandLine(); 747 parseCommandLine();
757 748
758 // read and apply default values /////////////////////////////////////////// 749 // read and apply default values ///////////////////////////////////////////
759 resize(321, 321); // Dummy. 750 resize(321, 321); // Dummy.
760 QSize currentSize = size(); 751 QSize currentSize = size();
761 if (currentSize != size()) 752 if (currentSize != size())
762 defaultSize = size(); 753 defaultSize = size();
763 754
764 755
765 /* allows us to catch cancel/escape */ 756 /* allows us to catch cancel/escape */
766 reparent ( 0, WStyle_Customize | WStyle_NoBorder, 757 reparent ( 0, WStyle_Customize | WStyle_NoBorder,
767 QPoint ( 0, 0 )); 758 QPoint ( 0, 0 ));
768} 759}
769 760
770void Konsole::show() 761void Konsole::show()
771{ 762{
772 if ( !nsessions ) 763 if ( !nsessions )
773 { 764 {
774 newSession(); 765 newSession();
775 } 766 }
776 QMainWindow::show(); 767 QMainWindow::show();
777 768
778} 769}
779 770
780void Konsole::initSession(const char*, QStrList &) 771void Konsole::initSession(const char*, QStrList &)
781{ 772{
782 QMainWindow::show(); 773 QMainWindow::show();
783} 774}
784 775
785Konsole::~Konsole() 776Konsole::~Konsole()
786{ 777{
787 while (nsessions > 0) 778 while (nsessions > 0)
788 { 779 {
789 doneSession(getTe(), 0); 780 doneSession(getTe(), 0);
790 } 781 }
791} 782}
792 783
793void 784void
794Konsole::historyDialog() 785Konsole::historyDialog()
795{ 786{
796 QDialog *d = new QDialog ( this, "histdlg", true ); 787 QDialog *d = new QDialog ( this, "histdlg", true );
797 // d-> setCaption ( tr( "History" )); 788 // d-> setCaption ( tr( "History" ));
798 789
799 QBoxLayout *lay = new QVBoxLayout ( d, 4, 4 ); 790 QBoxLayout *lay = new QVBoxLayout ( d, 4, 4 );
800 791
801 QLabel *l = new QLabel ( tr( "History Lines:" ), d ); 792 QLabel *l = new QLabel ( tr( "History Lines:" ), d );
802 lay-> addWidget ( l ); 793 lay-> addWidget ( l );
803 794
804 Config cfg( "Konsole" ); 795 Config cfg( "Konsole" );
805 cfg.setGroup("History"); 796 cfg.setGroup("History");
806 int hist = cfg.readNumEntry("history_lines",300); 797 int hist = cfg.readNumEntry("history_lines",300);
807 int avg_line = cfg.readNumEntry("avg_line_length",60); 798 int avg_line = cfg.readNumEntry("avg_line_length",60);
808 799
809 QSpinBox *spin = new QSpinBox ( 1, 100000, 20, d ); 800 QSpinBox *spin = new QSpinBox ( 1, 100000, 20, d );
810 spin-> setValue ( hist ); 801 spin-> setValue ( hist );
811 spin-> setWrapping ( true ); 802 spin-> setWrapping ( true );
812 spin-> setButtonSymbols ( QSpinBox::PlusMinus ); 803 spin-> setButtonSymbols ( QSpinBox::PlusMinus );
813 lay-> addWidget ( spin ); 804 lay-> addWidget ( spin );
814 805
815 if ( d-> exec ( ) == QDialog::Accepted ) 806 if ( d-> exec ( ) == QDialog::Accepted )
816 { 807 {
817 cfg.writeEntry("history_lines", spin->value()); 808 cfg.writeEntry("history_lines", spin->value());
818 cfg.writeEntry("avg_line_length", avg_line); 809 cfg.writeEntry("avg_line_length", avg_line);
819 if (getTe() != NULL) 810 if (getTe() != NULL)
820 { 811 {
821 getTe()->currentSession->setHistory(true); 812 getTe()->currentSession->setHistory(true);
822 } 813 }
823 } 814 }
824 815
825 delete d; 816 delete d;
826} 817}
827 818
828 819
829void Konsole::cycleZoom() 820void Konsole::cycleZoom()
830{ 821{
831 TEWidget* te = getTe(); 822 TEWidget* te = getTe();
832 QFont font = te->getVTFont(); 823 QFont font = te->getVTFont();
833 int size = font.pointSize(); 824 int size = font.pointSize();
834 changeFontSize(1); 825 changeFontSize(1);
835 font = te->getVTFont(); 826 font = te->getVTFont();
836 if (font.pointSize() <= size) 827 if (font.pointSize() <= size)
837 { 828 {
838 do 829 do
839 { 830 {
840 font = te->getVTFont(); 831 font = te->getVTFont();
841 size = font.pointSize(); 832 size = font.pointSize();
842 changeFontSize(-1); 833 changeFontSize(-1);
843 font = te->getVTFont(); 834 font = te->getVTFont();
844 } 835 }
845 while (font.pointSize() < size); 836 while (font.pointSize() < size);
846 } 837 }
847} 838}
848 839
849void Konsole::changeFontSize(int delta) 840void Konsole::changeFontSize(int delta)
850{ 841{
851 // printf("delta font size %d\n", delta); 842 // printf("delta font size %d\n", delta);
852 TEWidget* te = getTe(); 843 TEWidget* te = getTe();
853 QFont font = te->getVTFont(); 844 QFont font = te->getVTFont();
854 int size = font.pointSize(); 845 int size = font.pointSize();
855 int closest = delta > 0? 10000 : -10000; 846 int closest = delta > 0? 10000 : -10000;
856 int closest_font = -1; 847 int closest_font = -1;
857 for(uint i = 0; i < fonts.count(); i++) 848 for(uint i = 0; i < fonts.count(); i++)
858 { 849 {
859 if (fonts.at(i)->getFont() == font) 850 if (fonts.at(i)->getFont() == font)
860 { 851 {
861 if (delta > 0) 852 if (delta > 0)
862 { 853 {
863 if (i+1 < fonts.count() 854 if (i+1 < fonts.count()
864 && fonts.at(i+1)->getFamilyNum() == fonts.at(i)->getFamilyNum()) 855 && fonts.at(i+1)->getFamilyNum() == fonts.at(i)->getFamilyNum())
865 { 856 {
866 setFont(i+1); 857 setFont(i+1);
867 printf("font %d\n", i+1); 858 printf("font %d\n", i+1);
868 return; 859 return;
869 } 860 }
870 } 861 }
871 else if (delta < 0) 862 else if (delta < 0)
872 { 863 {
873 if (i > 0 864 if (i > 0
874 && fonts.at(i-1)->getFamilyNum() == fonts.at(i)->getFamilyNum()) 865 && fonts.at(i-1)->getFamilyNum() == fonts.at(i)->getFamilyNum())
875 { 866 {
876 setFont(i-1); 867 setFont(i-1);
877 printf("font %d\n", i-1); 868 printf("font %d\n", i-1);
878 return; 869 return;
879 } 870 }
880 } 871 }
881 } 872 }
882 int fsize = fonts.at(i)->getSize(); 873 int fsize = fonts.at(i)->getSize();
883 printf("%d size=%d fsize=%d closest=%d\n", i, size, fsize, closest); 874 printf("%d size=%d fsize=%d closest=%d\n", i, size, fsize, closest);
884 if ((delta > 0 && fsize > size && fsize < closest) 875 if ((delta > 0 && fsize > size && fsize < closest)
885 || (delta < 0 && fsize < size && fsize > closest)) 876 || (delta < 0 && fsize < size && fsize > closest))
886 { 877 {
887 closest = fsize; 878 closest = fsize;
888 closest_font = i; 879 closest_font = i;
889 } 880 }
890 } 881 }
891 if (closest_font >= 0) 882 if (closest_font >= 0)
892 { 883 {
893 printf("font closest %d (%d)\n", closest_font, closest); 884 printf("font closest %d (%d)\n", closest_font, closest);
894 setFont(closest_font); 885 setFont(closest_font);
895 } 886 }
896} 887}
897 888
898int Konsole::findFont(const QString& name, int size, bool exactMatch) 889int Konsole::findFont(const QString& name, int size, bool exactMatch)
899{ 890{
900 for(uint i = 0; i < fonts.count(); i++) 891 for(uint i = 0; i < fonts.count(); i++)
901 { 892 {
902 if (fonts.at(i)->getName() == name 893 if (fonts.at(i)->getName() == name
903 && fonts.at(i)->getSize() == size) 894 && fonts.at(i)->getSize() == size)
904 { 895 {
905 return(i); 896 return(i);
906 } 897 }
907 } 898 }
908 if (exactMatch) 899 if (exactMatch)
909 { 900 {
910 return(-1); 901 return(-1);
911 } 902 }
912 for(uint i = 0; i < fonts.count(); i++) 903 for(uint i = 0; i < fonts.count(); i++)
913 { 904 {
914 if (fonts.at(i)->getSize() == size) 905 if (fonts.at(i)->getSize() == size)
915 { 906 {
916 return(i); 907 return(i);
917 } 908 }
918 } 909 }
919 return(-1); 910 return(-1);
920} 911}
921 912
922void Konsole::setFont(int f) 913void Konsole::setFont(int f)
923{ 914{
924 VTFont* font = fonts.at(f); 915 VTFont* font = fonts.at(f);
925 if (font) 916 if (font)
926 { 917 {
927 TEWidget* te = getTe(); 918 TEWidget* te = getTe();
928 if (te != 0) 919 if (te != 0)
929 { 920 {
930 te->setVTFont(font->getFont()); 921 te->setVTFont(font->getFont());
931 } 922 }
932 cfont = f; 923 cfont = f;
933 924
934 int familyNum = font->getFamilyNum(); 925 int familyNum = font->getFamilyNum();
935 int size = font->getSize(); 926 int size = font->getSize();
936 printf("familyNum = %d size = %d count=%d\n", familyNum, size, 927 printf("familyNum = %d size = %d count=%d\n", familyNum, size,
937 fontList->count()); 928 fontList->count());
938 for(int i = 0; i < (int)fontList->count(); i++) 929 for(int i = 0; i < (int)fontList->count(); i++)
939 { 930 {
940 fontList->setItemChecked(i + 1000, i == familyNum); 931 fontList->setItemChecked(i + 1000, i == familyNum);
941 } 932 }
942 for(int i = 0; i < (int)fonts.count(); i++) 933 for(int i = 0; i < (int)fonts.count(); i++)
943 { 934 {
944 fontList->setItemChecked(i, fonts.at(i)->getFamilyNum() == familyNum 935 fontList->setItemChecked(i, fonts.at(i)->getFamilyNum() == familyNum
945 && fonts.at(i)->getSize() == size); 936 && fonts.at(i)->getSize() == size);
946 } 937 }
947 Config cfg( "Konsole" ); 938 Config cfg( "Konsole" );
948 cfg.setGroup("Font"); 939 cfg.setGroup("Font");
949 QString ss = "Session"+ QString::number(tab->currentPageIndex()+1); 940 QString ss = "Session"+ QString::number(tab->currentPageIndex()+1);
950 if (tab->currentPageIndex() == 0) 941 if (tab->currentPageIndex() == 0)
951 { 942 {
952 cfg.writeEntry("FontName", fonts.at(cfont)->getFamily()); 943 cfg.writeEntry("FontName", fonts.at(cfont)->getFamily());
953 cfg.writeEntry("FontSize", fonts.at(cfont)->getSize()); 944 cfg.writeEntry("FontSize", fonts.at(cfont)->getSize());
954 } 945 }
955 cfg.writeEntry("FontName"+ss, fonts.at(cfont)->getFamily()); 946 cfg.writeEntry("FontName"+ss, fonts.at(cfont)->getFamily());
956 cfg.writeEntry("FontSize"+ss, fonts.at(cfont)->getSize()); 947 cfg.writeEntry("FontSize"+ss, fonts.at(cfont)->getSize());
957 } 948 }
958} 949}
959 950
960#if 0 951#if 0
961void Konsole::fontChanged(int f) 952void Konsole::fontChanged(int f)
962{ 953{
963 VTFont* font = fonts.at(f); 954 VTFont* font = fonts.at(f);
964 if (font != 0) 955 if (font != 0)
965 { 956 {
966 for(uint i = 0; i < fonts.count(); i++) 957 for(uint i = 0; i < fonts.count(); i++)
967 { 958 {
968 fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE); 959 fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE);
969 } 960 }
970 961
971 cfont = f; 962 cfont = f;
972 963
973 TEWidget* te = getTe(); 964 TEWidget* te = getTe();
974 if (te != 0) 965 if (te != 0)
975 { 966 {
976 te->setVTFont(font->getFont()); 967 te->setVTFont(font->getFont());
977 } 968 }
978 } 969 }
979} 970}
980#endif 971#endif
981 972
982 973
983void Konsole::enterCommand(int c) 974void Konsole::enterCommand(int c)
984{ 975{
985 TEWidget* te = getTe(); 976 TEWidget* te = getTe();
986 if (te != 0) 977 if (te != 0)
987 { 978 {
988 if(!commonCombo->editable()) 979 if(!commonCombo->editable())
989 { 980 {
990 QString text = commonCombo->text(c); //commonCmds[c]; 981 QString text = commonCombo->text(c); //commonCmds[c];
991 te->emitText(text); 982 te->emitText(text);
992 } 983 }
993 else 984 else
994 { 985 {
995 changeCommand( commonCombo->text(c), c); 986 changeCommand( commonCombo->text(c), c);
996 } 987 }
997 } 988 }
998} 989}
999 990
1000void Konsole::hitEnter() 991void Konsole::hitEnter()
1001{ 992{
1002 TEWidget* te = getTe(); 993 TEWidget* te = getTe();
1003 if (te != 0) 994 if (te != 0)
1004 { 995 {
1005 te->emitText(QString("\r")); 996 te->emitText(QString("\r"));
1006 } 997 }
1007} 998}
1008 999
1009void Konsole::hitSpace() 1000void Konsole::hitSpace()
1010{ 1001{
1011 TEWidget* te = getTe(); 1002 TEWidget* te = getTe();
1012 if (te != 0) 1003 if (te != 0)
1013 { 1004 {
1014 te->emitText(QString(" ")); 1005 te->emitText(QString(" "));
1015 } 1006 }
1016} 1007}
1017 1008
1018void Konsole::hitTab() 1009void Konsole::hitTab()
1019{ 1010{
1020 TEWidget* te = getTe(); 1011 TEWidget* te = getTe();
1021 if (te != 0) 1012 if (te != 0)
1022 { 1013 {
1023 te->emitText(QString("\t")); 1014 te->emitText(QString("\t"));
1024 } 1015 }
1025} 1016}
1026 1017
1027void Konsole::hitPaste() 1018void Konsole::hitPaste()
1028{ 1019{
1029 TEWidget* te = getTe(); 1020 TEWidget* te = getTe();
1030 if (te != 0) 1021 if (te != 0)
1031 { 1022 {
1032 te->pasteClipboard(); 1023 te->pasteClipboard();
1033 } 1024 }
1034} 1025}
1035 1026
1036void Konsole::hitUp() 1027void Konsole::hitUp()
1037{ 1028{
1038 TEWidget* te = getTe(); 1029 TEWidget* te = getTe();
1039 if (te != 0) 1030 if (te != 0)
1040 { 1031 {
1041 QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Up, 0, 0); 1032 QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Up, 0, 0);
1042 QApplication::sendEvent( te, &ke ); 1033 QApplication::sendEvent( te, &ke );
1043 } 1034 }
1044} 1035}
1045 1036
1046void Konsole::hitDown() 1037void Konsole::hitDown()
1047{ 1038{
1048 TEWidget* te = getTe(); 1039 TEWidget* te = getTe();
1049 if (te != 0) 1040 if (te != 0)
1050 { 1041 {
1051 QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Down, 0, 0); 1042 QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Down, 0, 0);
1052 QApplication::sendEvent( te, &ke ); 1043 QApplication::sendEvent( te, &ke );
1053 } 1044 }
1054} 1045}
1055 1046
1056/** 1047/**
1057 This function calculates the size of the external widget 1048 This function calculates the size of the external widget
1058 needed for the internal widget to be 1049 needed for the internal widget to be
1059 */ 1050 */
1060QSize Konsole::calcSize(int columns, int lines) 1051QSize Konsole::calcSize(int columns, int lines)
1061{ 1052{
1062 TEWidget* te = getTe(); 1053 TEWidget* te = getTe();
1063 if (te != 0) 1054 if (te != 0)
1064 { 1055 {
1065 QSize size = te->calcSize(columns, lines); 1056 QSize size = te->calcSize(columns, lines);
1066 return size; 1057 return size;
1067 } 1058 }
1068 else 1059 else
1069 { 1060 {
1070 QSize size; 1061 QSize size;
1071 return size; 1062 return size;
1072 } 1063 }
1073} 1064}
1074 1065
1075/** 1066/**
1076 sets application window to a size based on columns X lines of the te 1067 sets application window to a size based on columns X lines of the te
1077 guest widget. Call with (0,0) for setting default size. 1068 guest widget. Call with (0,0) for setting default size.
1078*/ 1069*/
1079 1070
1080void Konsole::setColLin(int columns, int lines) 1071void Konsole::setColLin(int columns, int lines)
1081{ 1072{
1082 qDebug("konsole::setColLin:: Columns %d", columns); 1073 qDebug("konsole::setColLin:: Columns %d", columns);
1083 1074
1084 if ((columns==0) || (lines==0)) 1075 if ((columns==0) || (lines==0))
1085 { 1076 {
1086 if (defaultSize.isEmpty()) // not in config file : set default value 1077 if (defaultSize.isEmpty()) // not in config file : set default value
1087 { 1078 {
1088 defaultSize = calcSize(80,24); 1079 defaultSize = calcSize(80,24);
1089 // notifySize(24,80); // set menu items (strange arg order !) 1080 // notifySize(24,80); // set menu items (strange arg order !)
1090 } 1081 }
1091 resize(defaultSize); 1082 resize(defaultSize);
1092 } 1083 }
1093 else 1084 else
1094 { 1085 {
1095 resize(calcSize(columns, lines)); 1086 resize(calcSize(columns, lines));
1096 // notifySize(lines,columns); // set menu items (strange arg order !) 1087 // notifySize(lines,columns); // set menu items (strange arg order !)
1097 } 1088 }
1098} 1089}
1099 1090
1100/* 1091/*
1101void Konsole::setFont(int fontno) 1092void Konsole::setFont(int fontno)
1102{ 1093{
1103 QFont f; 1094 QFont f;
1104 if (fontno == 0) 1095 if (fontno == 0)
1105 f = defaultFont = QFont( "Helvetica", 12 ); 1096 f = defaultFont = QFont( "Helvetica", 12 );
1106 else 1097 else
1107 if (fonts[fontno][0] == '-') 1098 if (fonts[fontno][0] == '-')
1108 f.setRawName( fonts[fontno] ); 1099 f.setRawName( fonts[fontno] );
1109 else 1100 else
1110 { 1101 {
1111 f.setFamily(fonts[fontno]); 1102 f.setFamily(fonts[fontno]);
1112 f.setRawMode( TRUE ); 1103 f.setRawMode( TRUE );
1113 } 1104 }
1114 if ( !f.exactMatch() && fontno != 0) 1105 if ( !f.exactMatch() && fontno != 0)
1115 { 1106 {
1116 QString msg = i18n("Font `%1' not found.\nCheck README.linux.console for help.").arg(fonts[fontno]); 1107 QString msg = i18n("Font `%1' not found.\nCheck README.linux.console for help.").arg(fonts[fontno]);
1117 QMessageBox(this, msg); 1108 QMessageBox(this, msg);
1118 return; 1109 return;
1119 } 1110 }
1120 if (se) se->setFontNo(fontno); 1111 if (se) se->setFontNo(fontno);
1121 te->setVTFont(f); 1112 te->setVTFont(f);
1122 n_font = fontno; 1113 n_font = fontno;
1123} 1114}
1124*/ 1115*/
1125 1116
1126// --| color selection |------------------------------------------------------- 1117// --| color selection |-------------------------------------------------------
1127 1118
1128void Konsole::changeColumns(int /*columns*/) 1119void Konsole::changeColumns(int /*columns*/)
1129{ //FIXME this seems to cause silliness when reset command is executed 1120{ //FIXME this seems to cause silliness when reset command is executed
1130 // qDebug("change columns"); 1121 // qDebug("change columns");
1131 // TEWidget* te = getTe(); 1122 // TEWidget* te = getTe();
1132 // if (te != 0) { 1123 // if (te != 0) {
1133 // setColLin(columns,te->Lines()); 1124 // setColLin(columns,te->Lines());
1134 // te->update(); 1125 // te->update();
1135 // } 1126 // }
1136} 1127}
1137 1128
1138//FIXME: If a child dies during session swap, 1129//FIXME: If a child dies during session swap,
1139// this routine might be called before 1130// this routine might be called before
1140// session swap is completed. 1131// session swap is completed.
1141 1132
1142void Konsole::doneSession(TEWidget* te, int ) 1133void Konsole::doneSession(TEWidget* te, int )
1143{ 1134{
1144 // TEWidget *te = NULL; 1135 // TEWidget *te = NULL;
1145 // if (sess->currentSession == tab->currentPage()) { 1136 // if (sess->currentSession == tab->currentPage()) {
1146 // printf("done current session\n"); 1137 // printf("done current session\n");
1147 // te = getTe(); 1138 // te = getTe();
1148 // } else { 1139 // } else {
1149 // int currentPage = tab->currentPageIndex(); 1140 // int currentPage = tab->currentPageIndex();
1150 // printf("done not current session\n"); 1141 // printf("done not current session\n");
1151 // for(int i = 0; i < nsessions; i++) { 1142 // for(int i = 0; i < nsessions; i++) {
1152 // tab->setCurrentPage(i); 1143 // tab->setCurrentPage(i);
1153 // printf("find session %d tab page %x session %x\n", 1144 // printf("find session %d tab page %x session %x\n",
1154 // i, tab->currentPage(), sess->currentSession); 1145 // i, tab->currentPage(), sess->currentSession);
1155 // if (tab->currentPage() == sess->currentSession) { 1146 // if (tab->currentPage() == sess->currentSession) {
1156 // printf("found session %d\n", i); 1147 // printf("found session %d\n", i);
1157 // te = tab->currentPage(); 1148 // te = tab->currentPage();
1158 // break; 1149 // break;
1159 // } 1150 // }
1160 // } 1151 // }
1161 // tab->setCurrentPage(currentPage); 1152 // tab->setCurrentPage(currentPage);
1162 // } 1153 // }
1163 if (te != 0) 1154 if (te != 0)
1164 { 1155 {
1165 te->currentSession->setConnect(FALSE); 1156 te->currentSession->setConnect(FALSE);
1166 tab->removeTab(te); 1157 tab->removeTab(te);
1167 delete te->currentSession; 1158 delete te->currentSession;
1168 delete te; 1159 delete te;
1169 sessionList->removeItem(nsessions); 1160 sessionList->removeItem(nsessions);
1170 nsessions--; 1161 nsessions--;
1171 } 1162 }
1172 if (nsessions == 0) 1163 if (nsessions == 0)
1173 { 1164 {
1174 close(); 1165 close();
1175 } 1166 }
1176} 1167}
1177 1168
1178void Konsole::changeTitle(TEWidget* te, const QString& newTitle ) 1169void Konsole::changeTitle(TEWidget* te, const QString& newTitle )
1179{ 1170{
1180 if (te == getTe()) 1171 if (te == getTe())
1181 { 1172 {
1182 setCaption( newTitle + " - " + tr( "Konsole " ) ); 1173 setCaption( newTitle + " - " + tr( "Konsole " ) );
1183 } 1174 }
1184} 1175}
1185 1176
1186 1177
1187void Konsole::newSession() 1178void Konsole::newSession()
1188{ 1179{
1189 if(nsessions < 15) 1180 if(nsessions < 15)
1190 { // seems to be something weird about 16 tabs on the Zaurus.... memory? 1181 { // seems to be something weird about 16 tabs on the Zaurus.... memory?
1191 TEWidget* te = new TEWidget(tab); 1182 TEWidget* te = new TEWidget(tab);
1192 Config cfg( "Konsole" ); 1183 Config cfg( "Konsole" );
1193 cfg.setGroup("Menubar"); 1184 cfg.setGroup("Menubar");
1194 1185
1195 // FIXME use more defaults from config file 1186 // FIXME use more defaults from config file
1196 te->useBeep=cfg.readBoolEntry("useBeep",0); 1187 te->useBeep=cfg.readBoolEntry("useBeep",0);
1197 1188
1198 // te->setBackgroundMode(PaletteBase); //we want transparent!! 1189 // te->setBackgroundMode(PaletteBase); //we want transparent!!
1199 1190
1200 cfg.setGroup("Font"); 1191 cfg.setGroup("Font");
1201 QString sn = "Session" + QString::number(nsessions+1); 1192 QString sn = "Session" + QString::number(nsessions+1);
1202 printf("read font session %s\n", sn.latin1()); 1193 printf("read font session %s\n", sn.latin1());
1203 QString fontName = cfg.readEntry("FontName"+sn, 1194 QString fontName = cfg.readEntry("FontName"+sn,
1204 cfg.readEntry("FontName", 1195 cfg.readEntry("FontName",
1205 fonts.at(cfont)->getFamily())); 1196 fonts.at(cfont)->getFamily()));
1206 int fontSize = cfg.readNumEntry("FontSize"+sn, 1197 int fontSize = cfg.readNumEntry("FontSize"+sn,
1207 cfg.readNumEntry("FontSize", 1198 cfg.readNumEntry("FontSize",
1208 fonts.at(cfont)->getSize())); 1199 fonts.at(cfont)->getSize()));
1209 cfont = findFont(fontName, fontSize, false); 1200 cfont = findFont(fontName, fontSize, false);
1210 printf("lookup font %s size %d got %d\n", fontName.latin1(), fontSize, cfont); 1201 printf("lookup font %s size %d got %d\n", fontName.latin1(), fontSize, cfont);
1211 if (cfont < 0) 1202 if (cfont < 0)
1212 cfont = 0; 1203 cfont = 0;
1213 te->setVTFont(fonts.at(cfont)->getFont()); 1204 te->setVTFont(fonts.at(cfont)->getFont());
1214 1205
1215 tab->addTab(te); 1206 tab->addTab(te);
1216 TESession* se = new TESession(this, te, se_pgm, se_args, "xterm"); 1207 TESession* se = new TESession(this, te, se_pgm, se_args, "xterm");
1217 te->currentSession = se; 1208 te->currentSession = se;
1218 connect( se, SIGNAL(done(TEWidget*,int)), this, SLOT(doneSession(TEWidget*,int)) ); 1209 connect( se, SIGNAL(done(TEWidget*,int)), this, SLOT(doneSession(TEWidget*,int)) );
1219 connect( se, SIGNAL(changeTitle(TEWidget*,const QString&)), this, 1210 connect( se, SIGNAL(changeTitle(TEWidget*,const QString&)), this,
1220 SLOT(changeTitle(TEWidget*,const QString&)) ); 1211 SLOT(changeTitle(TEWidget*,const QString&)) );
1221 connect(te, SIGNAL(changeFontSize(int)), this, SLOT(changeFontSize(int))); 1212 connect(te, SIGNAL(changeFontSize(int)), this, SLOT(changeFontSize(int)));
1222 connect(te, SIGNAL(changeSession(int)), this, SLOT(changeSession(int))); 1213 connect(te, SIGNAL(changeSession(int)), this, SLOT(changeSession(int)));
1223 connect(te, SIGNAL(newSession()), this, SLOT(newSession())); 1214 connect(te, SIGNAL(newSession()), this, SLOT(newSession()));
1224 connect(te, SIGNAL(toggleFullScreen()), this, SLOT(toggleFullScreen())); 1215 connect(te, SIGNAL(toggleFullScreen()), this, SLOT(toggleFullScreen()));
1225 connect(te, SIGNAL(setFullScreen(bool)), this, SLOT(setFullScreen(bool))); 1216 connect(te, SIGNAL(setFullScreen(bool)), this, SLOT(setFullScreen(bool)));
1226 se->run(); 1217 se->run();
1227 se->setConnect(TRUE); 1218 se->setConnect(TRUE);
1228 se->setHistory(b_scroll); 1219 se->setHistory(b_scroll);
1229 nsessions++; 1220 nsessions++;
1230 sessionList->insertItem(QString::number(nsessions), nsessions); 1221 sessionList->insertItem(QString::number(nsessions), nsessions);
1231 sessionListSelected(nsessions); 1222 sessionListSelected(nsessions);
1232 doWrap(); 1223 doWrap();
1233 setColor(nsessions-1); 1224 setColor(nsessions-1);
1234 } 1225 }
1235} 1226}
1236 1227
1237TEWidget* Konsole::getTe() 1228TEWidget* Konsole::getTe()
1238{ 1229{
1239 if (nsessions) 1230 if (nsessions)
1240 { 1231 {
1241 return (TEWidget *) tab->currentPage(); 1232 return (TEWidget *) tab->currentPage();
1242 } 1233 }
1243 else 1234 else
1244 { 1235 {
1245 return 0; 1236 return 0;
1246 } 1237 }
1247} 1238}
1248 1239
1249void Konsole::sessionListSelected(int id) 1240void Konsole::sessionListSelected(int id)
1250{ 1241{
1251 if (id < 0) 1242 if (id < 0)
1252 { 1243 {
1253 return; 1244 return;
1254 } 1245 }
1255 QString selected = sessionList->text(id); 1246 QString selected = sessionList->text(id);
1256 EKNumTabBar *tabBar = tab->getTabBar(); 1247 EKNumTabBar *tabBar = tab->getTabBar();
1257 1248
1258 int n = 0; 1249 int n = 0;
1259 for(int i = 0; n < tabBar->count(); i++) 1250 for(int i = 0; n < tabBar->count(); i++)
1260 { 1251 {
1261 if (tabBar->tab(i)) 1252 if (tabBar->tab(i))
1262 { 1253 {
1263 // printf("selected = %s tab %d = %s\n", selected.latin1(), 1254 // printf("selected = %s tab %d = %s\n", selected.latin1(),
1264 // i, tabBar->tab(i)->text().latin1()); 1255 // i, tabBar->tab(i)->text().latin1());
1265 if (tabBar->tab(i)->text() == selected) 1256 if (tabBar->tab(i)->text() == selected)
1266 { 1257 {
1267 tab->setCurrentPage(i); 1258 tab->setCurrentPage(i);
1268 break; 1259 break;
1269 } 1260 }
1270 n++; 1261 n++;
1271 } 1262 }
1272 } 1263 }
1273} 1264}
1274 1265
1275 1266
1276void Konsole::changeSession(int delta) 1267void Konsole::changeSession(int delta)
1277{ 1268{
1278 printf("delta session %d\n", delta); 1269 printf("delta session %d\n", delta);
1279 QTabBar *tabBar = tab->getTabBar(); 1270 QTabBar *tabBar = tab->getTabBar();
1280 int i = tabBar->tab(tabBar->currentTab())->text().toInt() - 1; 1271 int i = tabBar->tab(tabBar->currentTab())->text().toInt() - 1;
1281 i += delta; 1272 i += delta;
1282 if (i < 0) 1273 if (i < 0)
1283 i += tabBar->count(); 1274 i += tabBar->count();
1284 if (i >= tabBar->count()) 1275 if (i >= tabBar->count())
1285 i -= tabBar->count(); 1276 i -= tabBar->count();
1286 1277
1287 QString selected = QString::number(i+1); 1278 QString selected = QString::number(i+1);
1288 int n = 0; 1279 int n = 0;
1289 for(int i = 0; n < tabBar->count(); i++) 1280 for(int i = 0; n < tabBar->count(); i++)
1290 { 1281 {
1291 if (tabBar->tab(i)) 1282 if (tabBar->tab(i))
1292 { 1283 {
1293 printf("selected = %s tab %d = %s\n", selected.latin1(), 1284 printf("selected = %s tab %d = %s\n", selected.latin1(),
1294 i, tabBar->tab(i)->text().latin1()); 1285 i, tabBar->tab(i)->text().latin1());
1295 if (tabBar->tab(i)->text() == selected) 1286 if (tabBar->tab(i)->text() == selected)
1296 { 1287 {
1297 tab->setCurrentPage(i); 1288 tab->setCurrentPage(i);
1298 break; 1289 break;
1299 } 1290 }
1300 n++; 1291 n++;
1301 } 1292 }
1302 } 1293 }
1303} 1294}
1304 1295
1305void Konsole::switchSession(QWidget* w) 1296void Konsole::switchSession(QWidget* w)
1306{ 1297{
1307 TEWidget* te = (TEWidget *) w; 1298 TEWidget* te = (TEWidget *) w;
1308 QFont teFnt = te->getVTFont(); 1299 QFont teFnt = te->getVTFont();
1309 int familyNum = -1; 1300 int familyNum = -1;
1310 1301
1311 for(uint i = 0; i < fonts.count(); i++) 1302 for(uint i = 0; i < fonts.count(); i++)
1312 { 1303 {
1313 VTFont *fnt = fonts.at(i); 1304 VTFont *fnt = fonts.at(i);
1314 bool cf = fnt->getFont() == teFnt; 1305 bool cf = fnt->getFont() == teFnt;
1315 fontList->setItemChecked(i, cf); 1306 fontList->setItemChecked(i, cf);
1316 if (cf) 1307 if (cf)
1317 { 1308 {
1318 cfont = i; 1309 cfont = i;
1319 familyNum = fnt->getFamilyNum(); 1310 familyNum = fnt->getFamilyNum();
1320 } 1311 }
1321 } 1312 }
1322 for(int i = 0; i < (int)fontList->count(); i++) 1313 for(int i = 0; i < (int)fontList->count(); i++)
1323 { 1314 {
1324 fontList->setItemChecked(i + 1000, i == familyNum); 1315 fontList->setItemChecked(i + 1000, i == familyNum);
1325 } 1316 }
1326 if (! te->currentSession->Title().isEmpty() ) 1317 if (! te->currentSession->Title().isEmpty() )
1327 { 1318 {
1328 setCaption( te->currentSession->Title() + " - " + tr( "Konsole" ) ); 1319 setCaption( te->currentSession->Title() + " - " + tr( "Konsole" ) );
1329 } 1320 }
1330 else 1321 else
1331 { 1322 {
1332 setCaption( tr( "Konsole" ) ); 1323 setCaption( tr( "Konsole" ) );
1333 } 1324 }
1334 // colorMenuSelected(te->color_menu_item); 1325 // colorMenuSelected(te->color_menu_item);
1335} 1326}
1336 1327
1337 1328
1338void Konsole::toggleFullScreen() 1329void Konsole::toggleFullScreen()
1339{ 1330{
1340 setFullScreen(! fullscreen); 1331 setFullScreen(! fullscreen);
1341} 1332}
1342 1333
1343void Konsole::setFullScreen ( bool b ) 1334void Konsole::setFullScreen ( bool b )
1344{ 1335{
1345 static QSize normalsize; 1336 static QSize normalsize;
1346 static bool listHidden; 1337 static bool listHidden;
1347 1338
1348 if (b == fullscreen) 1339 if (b == fullscreen)
1349 { 1340 {
1350 return; 1341 return;
1351 } 1342 }
1352 1343
1353 fullscreen = b; 1344 fullscreen = b;
1354 1345
1355 if ( b ) 1346 if ( b )
1356 { 1347 {
1357 if ( !normalsize. isValid ( )) 1348 if ( !normalsize. isValid ( ))
1358 { 1349 {
1359 normalsize = size ( ); 1350 normalsize = size ( );
1360 } 1351 }
1361 1352
1362 setFixedSize ( qApp-> desktop ( )-> size ( )); 1353 setFixedSize ( qApp-> desktop ( )-> size ( ));
1363 showNormal ( ); 1354 showNormal ( );
1364 reparent ( 0, WStyle_Customize | WStyle_NoBorder, 1355 reparent ( 0, WStyle_Customize | WStyle_NoBorder,
1365 QPoint ( 0, 0 )); 1356 QPoint ( 0, 0 ));
1366 showFullScreen ( ); 1357 showFullScreen ( );
1367 1358
1368 menuToolBar->hide(); 1359 menuToolBar->hide();
1369 toolBar->hide(); 1360 toolBar->hide();
1370 listHidden = secondToolBar->isHidden(); 1361 listHidden = secondToolBar->isHidden();
1371 secondToolBar->hide(); 1362 secondToolBar->hide();
1372 // commonCombo->hide(); 1363 // commonCombo->hide();
1373 tab->getTabBar()->hide(); 1364 tab->getTabBar()->hide();
1374 tab->setMargin(tab->margin()); 1365 tab->setMargin(tab->margin());
1375 1366
1376 if (show_fullscreen_msg) 1367 if (show_fullscreen_msg)
1377 { 1368 {
1378 fullscreen_msg-> move(tab->x() + tab->width()/2 - fullscreen_msg->width()/2, 1369 fullscreen_msg-> move(tab->x() + tab->width()/2 - fullscreen_msg->width()/2,
1379 qApp->desktop()->height()/16 - fullscreen_msg->height()/2); 1370 qApp->desktop()->height()/16 - fullscreen_msg->height()/2);
1380 fullscreen_msg->show(); 1371 fullscreen_msg->show();
1381 fullscreen_timer->start(3000, true); 1372 fullscreen_timer->start(3000, true);
1382 show_fullscreen_msg = false; 1373 show_fullscreen_msg = false;
1383 } 1374 }
1384 } 1375 }
1385 else 1376 else
1386 { 1377 {
1387 showNormal ( ); 1378 showNormal ( );
1388 reparent ( 0, WStyle_Customize, QPoint ( 0, 0 )); 1379 reparent ( 0, WStyle_Customize, QPoint ( 0, 0 ));
1389 resize ( normalsize ); 1380 resize ( normalsize );
1390 showMaximized ( ); 1381 showMaximized ( );
1391 normalsize = QSize ( ); 1382 normalsize = QSize ( );
1392 1383
1393 menuToolBar->show(); 1384 menuToolBar->show();
1394 toolBar->show(); 1385 toolBar->show();
1395 if(! listHidden) 1386 if(! listHidden)
1396 { 1387 {
1397 secondToolBar->show(); 1388 secondToolBar->show();
1398 } 1389 }
1399 // commonCombo->show(); 1390 // commonCombo->show();
1400 menuToolBar->show(); 1391 menuToolBar->show();
1401 if (tabPos != tm_hidden) 1392 if (tabPos != tm_hidden)
1402 { 1393 {
1403 tab->getTabBar()->show(); 1394 tab->getTabBar()->show();
1404 } 1395 }
1405 } 1396 }
1406 tab->setMargin(tab->margin()); // cause setup to run 1397 tab->setMargin(tab->margin()); // cause setup to run
1407} 1398}
1408 1399
1409 1400
1410void Konsole::fullscreenTimeout() 1401void Konsole::fullscreenTimeout()
1411{ 1402{
1412 fullscreen_msg->hide(); 1403 fullscreen_msg->hide();
1413} 1404}
1414 1405
1415void Konsole::colorMenuIsSelected(int iD) 1406void Konsole::colorMenuIsSelected(int iD)
1416{ 1407{
1417 fromMenu = TRUE; 1408 fromMenu = TRUE;
1418 colorMenuSelected(iD); 1409 colorMenuSelected(iD);
1419} 1410}
1420 1411
1421/// ------------------------------- some new stuff by L.J. Potter 1412/// ------------------------------- some new stuff by L.J. Potter
1422 1413
1423 1414
1424void Konsole::colorMenuSelected(int iD) 1415void Konsole::colorMenuSelected(int iD)
1425{ 1416{
1426 // this is NOT pretty, elegant or anything else besides functional 1417 // this is NOT pretty, elegant or anything else besides functional
1427 // QString temp; 1418 // QString temp;
1428 // qDebug( temp.sprintf("colormenu %d", iD)); 1419 // qDebug( temp.sprintf("colormenu %d", iD));
1429 1420
1430 TEWidget* te = getTe(); 1421 TEWidget* te = getTe();
1431 Config cfg( "Konsole" ); 1422 Config cfg( "Konsole" );
1432 cfg.setGroup("Colors"); 1423 cfg.setGroup("Colors");
1433 1424
1434 ColorEntry m_table[TABLE_COLORS]; 1425 ColorEntry m_table[TABLE_COLORS];
1435 const ColorEntry * defaultCt=te->getdefaultColorTable(); 1426 const ColorEntry * defaultCt=te->getdefaultColorTable();
1436 1427
1437 int i; 1428 int i;
1438 1429
1439 // te->color_menu_item = iD; 1430 // te->color_menu_item = iD;
1440 1431
1441 colorMenu->setItemChecked(cm_ab,FALSE); 1432 colorMenu->setItemChecked(cm_ab,FALSE);
1442 colorMenu->setItemChecked(cm_bb,FALSE); 1433 colorMenu->setItemChecked(cm_bb,FALSE);
1443 colorMenu->setItemChecked(cm_wc,FALSE); 1434 colorMenu->setItemChecked(cm_wc,FALSE);
1444 colorMenu->setItemChecked(cm_cw,FALSE); 1435 colorMenu->setItemChecked(cm_cw,FALSE);
1445 colorMenu->setItemChecked(cm_mb,FALSE); 1436 colorMenu->setItemChecked(cm_mb,FALSE);
1446 colorMenu->setItemChecked(cm_bm,FALSE); 1437 colorMenu->setItemChecked(cm_bm,FALSE);
1447 colorMenu->setItemChecked(cm_gy,FALSE); 1438 colorMenu->setItemChecked(cm_gy,FALSE);
1448 colorMenu->setItemChecked(cm_rb,FALSE); 1439 colorMenu->setItemChecked(cm_rb,FALSE);
1449 colorMenu->setItemChecked(cm_br,FALSE); 1440 colorMenu->setItemChecked(cm_br,FALSE);
1450 colorMenu->setItemChecked(cm_wb,FALSE); 1441 colorMenu->setItemChecked(cm_wb,FALSE);
1451 colorMenu->setItemChecked(cm_bw,FALSE); 1442 colorMenu->setItemChecked(cm_bw,FALSE);
1452 colorMenu->setItemChecked(cm_gb,FALSE); 1443 colorMenu->setItemChecked(cm_gb,FALSE);
1453 1444
1454 if(iD==cm_default) 1445 if(iD==cm_default)
1455 { // default default 1446 { // default default
1456 printf("default colors\n"); 1447 printf("default colors\n");
1457 for (i = 0; i < TABLE_COLORS; i++) 1448 for (i = 0; i < TABLE_COLORS; i++)
1458 { 1449 {
1459 m_table[i].color = defaultCt[i].color; 1450 m_table[i].color = defaultCt[i].color;
1460 if(i==1 || i == 11) 1451 if(i==1 || i == 11)
1461 m_table[i].transparent=1; 1452 m_table[i].transparent=1;
1462 colorMenu->setItemChecked(cm_default,TRUE); 1453 colorMenu->setItemChecked(cm_default,TRUE);
1463 } 1454 }
1464 te->setColorTable(m_table); 1455 te->setColorTable(m_table);
1465 } 1456 }
1466 if(iD==cm_gb) 1457 if(iD==cm_gb)
1467 { // green black 1458 { // green black
1468 foreground.setRgb(100,255,100); // (0x18,255,0x18); 1459 foreground.setRgb(100,255,100); // (0x18,255,0x18);
1469 background.setRgb(0x00,0x00,0x00); 1460 background.setRgb(0x00,0x00,0x00);
1470 colorMenu->setItemChecked(cm_gb,TRUE); 1461 colorMenu->setItemChecked(cm_gb,TRUE);
1471 } 1462 }
1472 if(iD==cm_bw) 1463 if(iD==cm_bw)
1473 { // black white 1464 { // black white
1474 foreground.setRgb(0x00,0x00,0x00); 1465 foreground.setRgb(0x00,0x00,0x00);
1475 background.setRgb(0xFF,0xFF,0xFF); 1466 background.setRgb(0xFF,0xFF,0xFF);
1476 colorMenu->setItemChecked(cm_bw,TRUE); 1467 colorMenu->setItemChecked(cm_bw,TRUE);
1477 } 1468 }
1478 if(iD==cm_wb) 1469 if(iD==cm_wb)
1479 { // white black 1470 { // white black
1480 foreground.setRgb(0xFF,0xFF,0xFF); 1471 foreground.setRgb(0xFF,0xFF,0xFF);
1481 background.setRgb(0x00,0x00,0x00); 1472 background.setRgb(0x00,0x00,0x00);
1482 colorMenu->setItemChecked(cm_wb,TRUE); 1473 colorMenu->setItemChecked(cm_wb,TRUE);
1483 } 1474 }
1484 if(iD==cm_br) 1475 if(iD==cm_br)
1485 {// Black, Red 1476 {// Black, Red
1486 foreground.setRgb(0x00,0x00,0x00); 1477 foreground.setRgb(0x00,0x00,0x00);
1487 background.setRgb(255,85,85); //(0xB2,0x18,0x18); 1478 background.setRgb(255,85,85); //(0xB2,0x18,0x18);
1488 colorMenu->setItemChecked(cm_br,TRUE); 1479 colorMenu->setItemChecked(cm_br,TRUE);
1489 } 1480 }
1490 if(iD==cm_rb) 1481 if(iD==cm_rb)
1491 {// Red, Black 1482 {// Red, Black
1492 foreground.setRgb(255,85,85); 1483 foreground.setRgb(255,85,85);
1493 background.setRgb(0x00,0x00,0x00); 1484 background.setRgb(0x00,0x00,0x00);
1494 colorMenu->setItemChecked(cm_rb,TRUE); 1485 colorMenu->setItemChecked(cm_rb,TRUE);
1495 } 1486 }
1496 if(iD==cm_gy) 1487 if(iD==cm_gy)
1497 {// Green, Yellow - is ugly 1488 {// Green, Yellow - is ugly
1498 // foreground.setRgb(0x18,0xB2,0x18); 1489 // foreground.setRgb(0x18,0xB2,0x18);
1499 foreground.setRgb(15,115,0); 1490 foreground.setRgb(15,115,0);
1500 // background.setRgb(0xB2,0x68,0x18); 1491 // background.setRgb(0xB2,0x68,0x18);
1501 background.setRgb(255,255,0); 1492 background.setRgb(255,255,0);
1502 colorMenu->setItemChecked(cm_gy,TRUE); 1493 colorMenu->setItemChecked(cm_gy,TRUE);
1503 } 1494 }
1504 if(iD==cm_bm) 1495 if(iD==cm_bm)
1505 {// Blue, Magenta 1496 {// Blue, Magenta
1506 foreground.setRgb(3,24,132); 1497 foreground.setRgb(3,24,132);
1507 background.setRgb(225,2,255); 1498 background.setRgb(225,2,255);
1508 colorMenu->setItemChecked(cm_bm,TRUE); 1499 colorMenu->setItemChecked(cm_bm,TRUE);
1509 } 1500 }
1510 if(iD==cm_mb) 1501 if(iD==cm_mb)
1511 {// Magenta, Blue 1502 {// Magenta, Blue
1512 foreground.setRgb(225,2,255); 1503 foreground.setRgb(225,2,255);
1513 background.setRgb(3,24,132); 1504 background.setRgb(3,24,132);
1514 colorMenu->setItemChecked(cm_mb,TRUE); 1505 colorMenu->setItemChecked(cm_mb,TRUE);
1515 } 1506 }
1516 if(iD==cm_cw) 1507 if(iD==cm_cw)
1517 {// Cyan, White 1508 {// Cyan, White
1518 foreground.setRgb(8,91,129); 1509 foreground.setRgb(8,91,129);
1519 background.setRgb(0xFF,0xFF,0xFF); 1510 background.setRgb(0xFF,0xFF,0xFF);
1520 colorMenu->setItemChecked(cm_cw,TRUE); 1511 colorMenu->setItemChecked(cm_cw,TRUE);
1521 } 1512 }
1522 if(iD==cm_wc) 1513 if(iD==cm_wc)
1523 {// White, Cyan 1514 {// White, Cyan
1524 background.setRgb(8,91,129); 1515 background.setRgb(8,91,129);
1525 foreground.setRgb(0xFF,0xFF,0xFF); 1516 foreground.setRgb(0xFF,0xFF,0xFF);
1526 colorMenu->setItemChecked(cm_wc,TRUE); 1517 colorMenu->setItemChecked(cm_wc,TRUE);
1527 } 1518 }
1528 if(iD==cm_bb) 1519 if(iD==cm_bb)
1529 {// Black, Blue 1520 {// Black, Blue
1530 background.setRgb(0x00,0x00,0x00); 1521 background.setRgb(0x00,0x00,0x00);
1531 foreground.setRgb(127,147,225); 1522 foreground.setRgb(127,147,225);
1532 colorMenu->setItemChecked(cm_bb,TRUE); 1523 colorMenu->setItemChecked(cm_bb,TRUE);
1533 } 1524 }
1534 if(iD==cm_ab) 1525 if(iD==cm_ab)
1535 {// Black, Gold 1526 {// Black, Gold
1536 background.setRgb(0x00,0x00,0x00); 1527 background.setRgb(0x00,0x00,0x00);
1537 foreground.setRgb(255,215,105); 1528 foreground.setRgb(255,215,105);
1538 colorMenu->setItemChecked(cm_ab,TRUE); 1529 colorMenu->setItemChecked(cm_ab,TRUE);
1539 } 1530 }
1540#ifdef QT_QWS_OPIE 1531#ifdef QT_QWS_OPIE
1541 if(iD==-19) 1532 if(iD==-19)
1542 { 1533 {
1543 // Custom 1534 // Custom
1544 qDebug("do custom"); 1535 qDebug("do custom");
1545 if(fromMenu) 1536 if(fromMenu)
1546 { 1537 {
1547 Opie::OColorPopupMenu* penColorPopupMenu = new Opie::OColorPopupMenu(Qt::black, this, "foreground color"); 1538 Opie::OColorPopupMenu* penColorPopupMenu = new Opie::OColorPopupMenu(Qt::black, this, "foreground color");
1548 connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, 1539 connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this,
1549 SLOT(changeForegroundColor(const QColor&))); 1540 SLOT(changeForegroundColor(const QColor&)));
1550 penColorPopupMenu->exec(); 1541 penColorPopupMenu->exec();
1551 } 1542 }
1552 if(!fromMenu) 1543 if(!fromMenu)
1553 { 1544 {
1554 foreground.setNamedColor(cfg.readEntry("foreground","")); 1545 foreground.setNamedColor(cfg.readEntry("foreground",""));
1555 background.setNamedColor(cfg.readEntry("background","")); 1546 background.setNamedColor(cfg.readEntry("background",""));
1556 } 1547 }
1557 fromMenu=FALSE; 1548 fromMenu=FALSE;
1558 colorMenu->setItemChecked(-19,TRUE); 1549 colorMenu->setItemChecked(-19,TRUE);
1559 } 1550 }
1560#endif 1551#endif
1561 1552
1562 lastSelectedMenu = iD; 1553 lastSelectedMenu = iD;
1563 1554
1564 setColors(foreground, background); 1555 setColors(foreground, background);
1565 1556
1566 QTabBar *tabBar = tab->getTabBar(); 1557 QTabBar *tabBar = tab->getTabBar();
1567 QString ss = QString("Session%1").arg(tabBar->currentTab()); 1558 QString ss = QString("Session%1").arg(tabBar->currentTab());
1568 // printf("current tab = %d\n", tabBar->currentTab()); 1559 // printf("current tab = %d\n", tabBar->currentTab());
1569 1560
1570 if (tabBar->currentTab() == 0) 1561 if (tabBar->currentTab() == 0)
1571 { 1562 {
1572 cfg.writeEntry("foregroundRed",QString::number(foreground.red())); 1563 cfg.writeEntry("foregroundRed",QString::number(foreground.red()));
1573 cfg.writeEntry("foregroundGreen",QString::number(foreground.green())); 1564 cfg.writeEntry("foregroundGreen",QString::number(foreground.green()));
1574 cfg.writeEntry("foregroundBlue",QString::number(foreground.blue())); 1565 cfg.writeEntry("foregroundBlue",QString::number(foreground.blue()));
1575 cfg.writeEntry("backgroundRed",QString::number(background.red())); 1566 cfg.writeEntry("backgroundRed",QString::number(background.red()));
1576 cfg.writeEntry("backgroundGreen",QString::number(background.green())); 1567 cfg.writeEntry("backgroundGreen",QString::number(background.green()));
1577 cfg.writeEntry("backgroundBlue",QString::number(background.blue())); 1568 cfg.writeEntry("backgroundBlue",QString::number(background.blue()));
1578 } 1569 }
1579 cfg.writeEntry("foregroundRed"+ss,QString::number(foreground.red())); 1570 cfg.writeEntry("foregroundRed"+ss,QString::number(foreground.red()));
1580 cfg.writeEntry("foregroundGreen"+ss,QString::number(foreground.green())); 1571 cfg.writeEntry("foregroundGreen"+ss,QString::number(foreground.green()));
1581 cfg.writeEntry("foregroundBlue"+ss,QString::number(foreground.blue())); 1572 cfg.writeEntry("foregroundBlue"+ss,QString::number(foreground.blue()));
1582 cfg.writeEntry("backgroundRed"+ss,QString::number(background.red())); 1573 cfg.writeEntry("backgroundRed"+ss,QString::number(background.red()));
1583 cfg.writeEntry("backgroundGreen"+ss,QString::number(background.green())); 1574 cfg.writeEntry("backgroundGreen"+ss,QString::number(background.green()));
1584 cfg.writeEntry("backgroundBlue"+ss,QString::number(background.blue())); 1575 cfg.writeEntry("backgroundBlue"+ss,QString::number(background.blue()));
1585 1576
1586 update(); 1577 update();
1587} 1578}
1588 1579
1589void Konsole::setColors(QColor foreground, QColor background) 1580void Konsole::setColors(QColor foreground, QColor background)
1590{ 1581{
1591 int i; 1582 int i;
1592 ColorEntry m_table[TABLE_COLORS]; 1583 ColorEntry m_table[TABLE_COLORS];
1593 TEWidget* te = getTe(); 1584 TEWidget* te = getTe();
1594 const ColorEntry * defaultCt=te->getdefaultColorTable(); 1585 const ColorEntry * defaultCt=te->getdefaultColorTable();
1595 1586
1596 for (i = 0; i < TABLE_COLORS; i++) 1587 for (i = 0; i < TABLE_COLORS; i++)
1597 { 1588 {
1598 if(i==0 || i == 10) 1589 if(i==0 || i == 10)
1599 { 1590 {
1600 m_table[i].color = foreground; 1591 m_table[i].color = foreground;
1601 } 1592 }
1602 else if(i==1 || i == 11) 1593 else if(i==1 || i == 11)
1603 { 1594 {
1604 m_table[i].color = background; 1595 m_table[i].color = background;
1605 m_table[i].transparent=0; 1596 m_table[i].transparent=0;
1606 } 1597 }
1607 else 1598 else
1608 m_table[i].color = defaultCt[i].color; 1599 m_table[i].color = defaultCt[i].color;
1609 } 1600 }
1610 te->setColorTable(m_table); 1601 te->setColorTable(m_table);
1611} 1602}
1612 1603
1613void Konsole::tabMenuSelected(int id) 1604void Konsole::tabMenuSelected(int id)
1614{ 1605{
1615 Config cfg( "Konsole" ); 1606 Config cfg( "Konsole" );
1616 cfg.setGroup("Tabs"); 1607 cfg.setGroup("Tabs");
1617 tabMenu->setItemChecked(tabPos, false); 1608 tabMenu->setItemChecked(tabPos, false);
1618 if (id == tm_bottom) 1609 if (id == tm_bottom)
1619 { 1610 {
1620 printf("set bottom tab\n"); 1611 printf("set bottom tab\n");
1621 tab->getTabBar()->show(); 1612 tab->getTabBar()->show();
1622 tab->setTabPosition(QTabWidget::Bottom); 1613 tab->setTabPosition(QTabWidget::Bottom);
1623 tab->getTabBar()->show(); 1614 tab->getTabBar()->show();
1624 cfg.writeEntry("Position","Bottom"); 1615 cfg.writeEntry("Position","Bottom");
1625 } 1616 }
1626 else if (id == tm_top) 1617 else if (id == tm_top)
1627 { 1618 {
1628 printf("set top tab\n"); 1619 printf("set top tab\n");
1629 tab->getTabBar()->show(); 1620 tab->getTabBar()->show();
1630 tab->setTabPosition(QTabWidget::Bottom); 1621 tab->setTabPosition(QTabWidget::Bottom);
1631 tab->setTabPosition(QTabWidget::Top); 1622 tab->setTabPosition(QTabWidget::Top);
1632 tab->getTabBar()->show(); 1623 tab->getTabBar()->show();
1633 cfg.writeEntry("Position","Top"); 1624 cfg.writeEntry("Position","Top");
1634 } 1625 }
1635 else if (id == tm_hidden) 1626 else if (id == tm_hidden)
1636 { 1627 {
1637 tab->getTabBar()->hide(); 1628 tab->getTabBar()->hide();
1638 tab->setMargin(tab->margin()); 1629 tab->setMargin(tab->margin());
1639 cfg.writeEntry("Position","Hidden"); 1630 cfg.writeEntry("Position","Hidden");
1640 } 1631 }
1641 tabMenu->setItemChecked(id, true); 1632 tabMenu->setItemChecked(id, true);
1642 tabPos = id; 1633 tabPos = id;
1643} 1634}
1644 1635
1645 1636
1646void Konsole::configMenuSelected(int iD) 1637void Konsole::configMenuSelected(int iD)
1647{ 1638{
1648 // QString temp; 1639 // QString temp;
1649 // qDebug( temp.sprintf("configmenu %d",iD)); 1640 // qDebug( temp.sprintf("configmenu %d",iD));
1650 1641
1651 TEWidget* te = getTe(); 1642 TEWidget* te = getTe();
1652 Config cfg( "Konsole" ); 1643 Config cfg( "Konsole" );
1653 cfg.setGroup("Menubar"); 1644 cfg.setGroup("Menubar");
1654 if(iD == cm_wrap) 1645 if(iD == cm_wrap)
1655 { 1646 {
1656 cfg.setGroup("ScrollBar"); 1647 cfg.setGroup("ScrollBar");
1657 bool b=cfg.readBoolEntry("HorzScroll",0); 1648 bool b=cfg.readBoolEntry("HorzScroll",0);
1658 b=!b; 1649 b=!b;
1659 cfg.writeEntry("HorzScroll", b ); 1650 cfg.writeEntry("HorzScroll", b );
1660 cfg.write(); 1651 cfg.write();
1661 doWrap(); 1652 doWrap();
1662 if(cfg.readNumEntry("Position",2) == 0) 1653 if(cfg.readNumEntry("Position",2) == 0)
1663 { 1654 {
1664 te->setScrollbarLocation(1); 1655 te->setScrollbarLocation(1);
1665 } 1656 }
1666 else 1657 else
1667 { 1658 {
1668 te->setScrollbarLocation(0); 1659 te->setScrollbarLocation(0);
1669 } 1660 }
1670 te->setScrollbarLocation( cfg.readNumEntry("Position",2)); 1661 te->setScrollbarLocation( cfg.readNumEntry("Position",2));
1671 } 1662 }
1672 if(iD == cm_beep) 1663 if(iD == cm_beep)
1673 { 1664 {
1674 cfg.setGroup("Menubar"); 1665 cfg.setGroup("Menubar");
1675 bool b=cfg.readBoolEntry("useBeep",0); 1666 bool b=cfg.readBoolEntry("useBeep",0);
1676 b=!b; 1667 b=!b;
1677 cfg.writeEntry("useBeep", b ); 1668 cfg.writeEntry("useBeep", b );
1678 cfg.write(); 1669 cfg.write();
1679 configMenu->setItemChecked(cm_beep,b); 1670 configMenu->setItemChecked(cm_beep,b);
1680 te->useBeep=b; 1671 te->useBeep=b;
1681 } 1672 }
1682} 1673}
1683 1674
1684void Konsole::changeCommand(const QString &text, int c) 1675void Konsole::changeCommand(const QString &text, int c)
1685{ 1676{
1686 Config cfg( "Konsole" ); 1677 Config cfg( "Konsole" );
1687 cfg.setGroup("Commands"); 1678 cfg.setGroup("Commands");
1688 if(commonCmds[c] != text) 1679 if(commonCmds[c] != text)
1689 { 1680 {
1690 cfg.writeEntry(QString::number(c),text); 1681 cfg.writeEntry(QString::number(c),text);
1691 commonCombo->clearEdit(); 1682 commonCombo->clearEdit();
1692 commonCombo->setCurrentItem(c); 1683 commonCombo->setCurrentItem(c);
1693 } 1684 }
1694} 1685}
1695 1686
1696void Konsole::setColor(int sess) 1687void Konsole::setColor(int sess)
1697{ 1688{
1698 Config cfg( "Konsole" ); 1689 Config cfg( "Konsole" );
1699 cfg.setGroup("Colors"); 1690 cfg.setGroup("Colors");
1700 QColor foreground, background; 1691 QColor foreground, background;
1701 QString ss = QString("Session") + QString::number(sess); 1692 QString ss = QString("Session") + QString::number(sess);
1702 foreground.setRgb(cfg.readNumEntry("foregroundRed"+ss, 1693 foreground.setRgb(cfg.readNumEntry("foregroundRed"+ss,
1703 cfg.readNumEntry("foregroundRed",0xff)), 1694 cfg.readNumEntry("foregroundRed",0xff)),
1704 cfg.readNumEntry("foregroundGreen"+ss, 1695 cfg.readNumEntry("foregroundGreen"+ss,
1705 cfg.readNumEntry("foregroundGreen",0xff)), 1696 cfg.readNumEntry("foregroundGreen",0xff)),
1706 cfg.readNumEntry("foregroundBlue"+ss, 1697 cfg.readNumEntry("foregroundBlue"+ss,
1707 cfg.readNumEntry("foregroundBlue",0xff))); 1698 cfg.readNumEntry("foregroundBlue",0xff)));
1708 background.setRgb(cfg.readNumEntry("backgroundRed"+ss, 1699 background.setRgb(cfg.readNumEntry("backgroundRed"+ss,
1709 cfg.readNumEntry("backgroundRed",0)), 1700 cfg.readNumEntry("backgroundRed",0)),
1710 cfg.readNumEntry("backgroundGreen"+ss, 1701 cfg.readNumEntry("backgroundGreen"+ss,
1711 cfg.readNumEntry("backgroundGreen",0)), 1702 cfg.readNumEntry("backgroundGreen",0)),
1712 cfg.readNumEntry("backgroundBlue"+ss, 1703 cfg.readNumEntry("backgroundBlue"+ss,
1713 cfg.readNumEntry("backgroundBlue",0))); 1704 cfg.readNumEntry("backgroundBlue",0)));
1714 setColors(foreground, background); 1705 setColors(foreground, background);
1715} 1706}
1716 1707
1717void Konsole::scrollMenuSelected(int index) 1708void Konsole::scrollMenuSelected(int index)
1718{ 1709{
1719 // qDebug( "scrollbar menu %d",index); 1710 // qDebug( "scrollbar menu %d",index);
1720 1711
1721 TEWidget* te = getTe(); 1712 TEWidget* te = getTe();
1722 Config cfg( "Konsole" ); 1713 Config cfg( "Konsole" );
1723 cfg.setGroup("ScrollBar"); 1714 cfg.setGroup("ScrollBar");
1724 1715
1725 if(index == sm_none) 1716 if(index == sm_none)
1726 { 1717 {
1727 te->setScrollbarLocation(0); 1718 te->setScrollbarLocation(0);
1728 cfg.writeEntry("Position",0); 1719 cfg.writeEntry("Position",0);
1729 } 1720 }
1730 else if(index == sm_left) 1721 else if(index == sm_left)
1731 { 1722 {
1732 te->setScrollbarLocation(1); 1723 te->setScrollbarLocation(1);
1733 cfg.writeEntry("Position",1); 1724 cfg.writeEntry("Position",1);
1734 } 1725 }
1735 else if(index == sm_right) 1726 else if(index == sm_right)
1736 { 1727 {
1737 te->setScrollbarLocation(2); 1728 te->setScrollbarLocation(2);
1738 cfg.writeEntry("Position",2); 1729 cfg.writeEntry("Position",2);
1739 } 1730 }
1740 scrollMenu->setItemChecked(sm_none, index == sm_none); 1731 scrollMenu->setItemChecked(sm_none, index == sm_none);
1741 scrollMenu->setItemChecked(sm_left, index == sm_left); 1732 scrollMenu->setItemChecked(sm_left, index == sm_left);
1742 scrollMenu->setItemChecked(sm_right, index == sm_right); 1733 scrollMenu->setItemChecked(sm_right, index == sm_right);
1743} 1734}
1744 1735
1745// case -29: { 1736// case -29: {
1746// bool b=cfg.readBoolEntry("HorzScroll",0); 1737// bool b=cfg.readBoolEntry("HorzScroll",0);
1747// cfg.writeEntry("HorzScroll", !b ); 1738// cfg.writeEntry("HorzScroll", !b );
1748// cfg.write(); 1739// cfg.write();
1749// if(cfg.readNumEntry("Position",2) == 0) { 1740// if(cfg.readNumEntry("Position",2) == 0) {
1750// te->setScrollbarLocation(1); 1741// te->setScrollbarLocation(1);
1751// te->setWrapAt(0); 1742// te->setWrapAt(0);
1752// } else { 1743// } else {
1753// te->setScrollbarLocation(0); 1744// te->setScrollbarLocation(0);
1754// te->setWrapAt(120); 1745// te->setWrapAt(120);
1755// } 1746// }
1756// te->setScrollbarLocation( cfg.readNumEntry("Position",2)); 1747// te->setScrollbarLocation( cfg.readNumEntry("Position",2));
1757// } 1748// }
1758// break; 1749// break;
1759 1750
1760void Konsole::editCommandListMenuSelected(int iD) 1751void Konsole::editCommandListMenuSelected(int iD)
1761{ 1752{
1762 // QString temp; 1753 // QString temp;
1763 // qDebug( temp.sprintf("edit command list %d",iD)); 1754 // qDebug( temp.sprintf("edit command list %d",iD));
1764 1755
1765 // FIXME: more cleanup needed here 1756 // FIXME: more cleanup needed here
1766 1757
1767 1758
1768 TEWidget* te = getTe(); 1759 TEWidget* te = getTe();
1769 Config cfg( "Konsole" ); 1760 Config cfg( "Konsole" );
1770 cfg.setGroup("Menubar"); 1761 cfg.setGroup("Menubar");
1771 if( iD == ec_cmdlist) 1762 if( iD == ec_cmdlist)
1772 { 1763 {
1773 if(!secondToolBar->isHidden()) 1764 if(!secondToolBar->isHidden())
1774 { 1765 {
1775 secondToolBar->hide(); 1766 secondToolBar->hide();
1776 configMenu->changeItem( iD,tr( "Show Command List" )); 1767 configMenu->changeItem( iD,tr( "Show Command List" ));
1777 cfg.writeEntry("Hidden","TRUE"); 1768 cfg.writeEntry("Hidden","TRUE");
1778 configMenu->setItemEnabled(ec_edit ,FALSE); 1769 configMenu->setItemEnabled(ec_edit ,FALSE);
1779 configMenu->setItemEnabled(ec_quick ,FALSE); 1770 configMenu->setItemEnabled(ec_quick ,FALSE);
1780 } 1771 }
1781 else 1772 else
1782 { 1773 {
1783 secondToolBar->show(); 1774 secondToolBar->show();
1784 configMenu->changeItem( iD,tr( "Hide Command List" )); 1775 configMenu->changeItem( iD,tr( "Hide Command List" ));
1785 cfg.writeEntry("Hidden","FALSE"); 1776 cfg.writeEntry("Hidden","FALSE");
1786 configMenu->setItemEnabled(ec_edit ,TRUE); 1777 configMenu->setItemEnabled(ec_edit ,TRUE);
1787 configMenu->setItemEnabled(ec_quick ,TRUE); 1778 configMenu->setItemEnabled(ec_quick ,TRUE);
1788 1779
1789 if(cfg.readEntry("EditEnabled","FALSE")=="TRUE") 1780 if(cfg.readEntry("EditEnabled","FALSE")=="TRUE")
1790 { 1781 {
1791 configMenu->setItemChecked(ec_edit,TRUE); 1782 configMenu->setItemChecked(ec_edit,TRUE);
1792 commonCombo->setEditable( TRUE ); 1783 commonCombo->setEditable( TRUE );
1793 } 1784 }
1794 else 1785 else
1795 { 1786 {
1796 configMenu->setItemChecked(ec_edit,FALSE); 1787 configMenu->setItemChecked(ec_edit,FALSE);
1797 commonCombo->setEditable( FALSE ); 1788 commonCombo->setEditable( FALSE );
1798 } 1789 }
1799 } 1790 }
1800 } 1791 }
1801 if( iD == ec_quick) 1792 if( iD == ec_quick)
1802 { 1793 {
1803 cfg.setGroup("Commands"); 1794 cfg.setGroup("Commands");
1804 // qDebug("enableCommandEdit"); 1795 // qDebug("enableCommandEdit");
1805 if( !configMenu->isItemChecked(iD) ) 1796 if( !configMenu->isItemChecked(iD) )
1806 { 1797 {
1807 commonCombo->setEditable( TRUE ); 1798 commonCombo->setEditable( TRUE );
1808 configMenu->setItemChecked(iD,TRUE); 1799 configMenu->setItemChecked(iD,TRUE);
1809 commonCombo->setCurrentItem(0); 1800 commonCombo->setCurrentItem(0);
1810 cfg.writeEntry("EditEnabled","TRUE"); 1801 cfg.writeEntry("EditEnabled","TRUE");
1811 } 1802 }
1812 else 1803 else
1813 { 1804 {
1814 commonCombo->setEditable( FALSE ); 1805 commonCombo->setEditable( FALSE );
1815 configMenu->setItemChecked(iD,FALSE); 1806 configMenu->setItemChecked(iD,FALSE);
1816 cfg.writeEntry("EditEnabled","FALSE"); 1807 cfg.writeEntry("EditEnabled","FALSE");
1817 commonCombo->setFocusPolicy(QWidget::NoFocus); 1808 commonCombo->setFocusPolicy(QWidget::NoFocus);
1818 te->setFocus(); 1809 te->setFocus();
1819 } 1810 }
1820 } 1811 }
1821 if(iD == ec_edit) 1812 if(iD == ec_edit)
1822 { 1813 {
1823 // "edit commands" 1814 // "edit commands"
1824 CommandEditDialog *m = new CommandEditDialog(this); 1815 CommandEditDialog *m = new CommandEditDialog(this);
1825 connect(m,SIGNAL(commandsEdited()),this,SLOT(initCommandList())); 1816 connect(m,SIGNAL(commandsEdited()),this,SLOT(initCommandList()));
1826 m->showMaximized(); 1817 m->showMaximized();
1827 } 1818 }
1828 1819
1829} 1820}
1830 1821
1831// $QPEDIR/bin/qcop QPE/Application/embeddedkonsole 'setDocument(QString)' 'ssh -V' 1822// $QPEDIR/bin/qcop QPE/Application/embeddedkonsole 'setDocument(QString)' 'ssh -V'
1832void Konsole::setDocument( const QString &cmd) 1823void Konsole::setDocument( const QString &cmd)
1833{ 1824{
1834 newSession(); 1825 newSession();
1835 TEWidget* te = getTe(); 1826 TEWidget* te = getTe();
1836 if(cmd.find("-e", 0, TRUE) != -1) 1827 if(cmd.find("-e", 0, TRUE) != -1)
1837 { 1828 {
1838 QString cmd2; 1829 QString cmd2;
1839 cmd2=cmd.right(cmd.length()-3)+" &"; 1830 cmd2=cmd.right(cmd.length()-3)+" &";
1840 system(cmd2.latin1()); 1831 system(cmd2.latin1());
1841 if(startUp <= 1 && nsessions < 2) 1832 if(startUp <= 1 && nsessions < 2)
1842 { 1833 {
1843 doneSession(getTe(), 0); 1834 doneSession(getTe(), 0);
1844 exit(0); 1835 exit(0);
1845 } 1836 }
1846 else 1837 else
1847 doneSession(getTe(), 0); 1838 doneSession(getTe(), 0);
1848 } 1839 }
1849 else 1840 else
1850 { 1841 {
1851 if (te != 0) 1842 if (te != 0)
1852 { 1843 {
1853 te->emitText(cmd+"\r"); 1844 te->emitText(cmd+"\r");
1854 } 1845 }
1855 } 1846 }
1856 startUp++; 1847 startUp++;
1857} 1848}
1858 1849
1859 1850
1860// what is the point of this when you can just 1851// what is the point of this when you can just
1861// run commands by using the shell directly?? 1852// run commands by using the shell directly??
1862void Konsole::parseCommandLine() 1853void Konsole::parseCommandLine()
1863{ 1854{
1864 QString cmd; 1855 QString cmd;
1865 // newSession(); 1856 // newSession();
1866 for (int i=1;i< qApp->argc();i++) 1857 for (int i=1;i< qApp->argc();i++)
1867 { 1858 {
1868 if( QString(qApp->argv()[i]) == "-e") 1859 if( QString(qApp->argv()[i]) == "-e")
1869 { 1860 {
1870 i++; 1861 i++;
1871 for ( int j=i;j< qApp->argc();j++) 1862 for ( int j=i;j< qApp->argc();j++)
1872 { 1863 {
1873 cmd+=QString(qApp->argv()[j])+" "; 1864 cmd+=QString(qApp->argv()[j])+" ";
1874 } 1865 }
1875 cmd.stripWhiteSpace(); 1866 cmd.stripWhiteSpace();
1876 system(cmd.latin1()); 1867 system(cmd.latin1());
1877 exit(0);//close(); 1868 exit(0);//close();
1878 } // end -e switch 1869 } // end -e switch
1879 } 1870 }
1880 startUp++; 1871 startUp++;
1881} 1872}
1882 1873
1883void Konsole::changeForegroundColor(const QColor &color) 1874void Konsole::changeForegroundColor(const QColor &color)
1884{ 1875{
1885 Config cfg( "Konsole" ); 1876 Config cfg( "Konsole" );
1886 cfg.setGroup("Colors"); 1877 cfg.setGroup("Colors");
1887 int r, g, b; 1878 int r, g, b;
1888 color.rgb(&r,&g,&b); 1879 color.rgb(&r,&g,&b);
1889 foreground.setRgb(r,g,b); 1880 foreground.setRgb(r,g,b);
1890 1881
1891 cfg.writeEntry("foreground",color.name()); 1882 cfg.writeEntry("foreground",color.name());
1892 qDebug("foreground "+color.name()); 1883 qDebug("foreground "+color.name());
1893 cfg.write(); 1884 cfg.write();
1894 1885
1895 qDebug("do other dialog"); 1886 qDebug("do other dialog");
1896#ifdef QT_QWS_OPIE 1887#ifdef QT_QWS_OPIE
1897 1888
1898 Opie::OColorPopupMenu* penColorPopupMenu2 = new Opie::OColorPopupMenu(Qt::black, this,"background color"); 1889 Opie::OColorPopupMenu* penColorPopupMenu2 = new Opie::OColorPopupMenu(Qt::black, this,"background color");
1899 connect(penColorPopupMenu2, SIGNAL(colorSelected(const QColor&)), this, 1890 connect(penColorPopupMenu2, SIGNAL(colorSelected(const QColor&)), this,
1900 SLOT(changeBackgroundColor(const QColor&))); 1891 SLOT(changeBackgroundColor(const QColor&)));
1901 penColorPopupMenu2->exec(); 1892 penColorPopupMenu2->exec();
1902#endif 1893#endif
1903} 1894}
1904 1895
1905void Konsole::changeBackgroundColor(const QColor &color) 1896void Konsole::changeBackgroundColor(const QColor &color)
1906{ 1897{
1907 1898
1908 qDebug("Change background"); 1899 qDebug("Change background");
1909 Config cfg( "Konsole" ); 1900 Config cfg( "Konsole" );
1910 cfg.setGroup("Colors"); 1901 cfg.setGroup("Colors");
1911 int r, g, b; 1902 int r, g, b;
1912 color.rgb(&r,&g,&b); 1903 color.rgb(&r,&g,&b);
1913 background.setRgb(r,g,b); 1904 background.setRgb(r,g,b);
1914 cfg.writeEntry("background",color.name()); 1905 cfg.writeEntry("background",color.name());
1915 qDebug("background "+color.name()); 1906 qDebug("background "+color.name());
1916 cfg.write(); 1907 cfg.write();
1917} 1908}
1918 1909
1919void Konsole::doWrap() 1910void Konsole::doWrap()
1920{ 1911{
1921 Config cfg( "Konsole" ); 1912 Config cfg( "Konsole" );
1922 cfg.setGroup("ScrollBar"); 1913 cfg.setGroup("ScrollBar");
1923 TEWidget* te = getTe(); 1914 TEWidget* te = getTe();
1924 if( !cfg.readBoolEntry("HorzScroll",0)) 1915 if( !cfg.readBoolEntry("HorzScroll",0))
1925 { 1916 {
1926 te->setWrapAt(0); 1917 te->setWrapAt(0);
1927 configMenu->setItemChecked( cm_wrap,TRUE); 1918 configMenu->setItemChecked( cm_wrap,TRUE);
1928 } 1919 }
1929 else 1920 else
1930 { 1921 {
1931 // te->setWrapAt(90); 1922 // te->setWrapAt(90);
1932 te->setWrapAt(120); 1923 te->setWrapAt(120);
1933 configMenu->setItemChecked( cm_wrap,FALSE); 1924 configMenu->setItemChecked( cm_wrap,FALSE);
1934 } 1925 }
1935} 1926}