summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/embeddedkonsole/konsole.cpp2
1 files changed, 0 insertions, 2 deletions
diff --git a/core/apps/embeddedkonsole/konsole.cpp b/core/apps/embeddedkonsole/konsole.cpp
index 1c613a9..2c0001f 100644
--- a/core/apps/embeddedkonsole/konsole.cpp
+++ b/core/apps/embeddedkonsole/konsole.cpp
@@ -1,1918 +1,1916 @@
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 26
27#ifdef QT_QWS_OPIE 27#ifdef QT_QWS_OPIE
28#include <opie2/ocolorpopupmenu.h> 28#include <opie2/ocolorpopupmenu.h>
29#endif 29#endif
30 30
31#include <qpe/resource.h> 31#include <qpe/resource.h>
32 32
33#include <qdir.h> 33#include <qdir.h>
34#include <qevent.h> 34#include <qevent.h>
35#include <qdragobject.h> 35#include <qdragobject.h>
36#include <qobjectlist.h> 36#include <qobjectlist.h>
37#include <qtoolbutton.h> 37#include <qtoolbutton.h>
38#include <qtoolbar.h> 38#include <qtoolbar.h>
39#include <qpushbutton.h> 39#include <qpushbutton.h>
40#include <qfontdialog.h> 40#include <qfontdialog.h>
41#include <qglobal.h> 41#include <qglobal.h>
42#include <qpainter.h> 42#include <qpainter.h>
43#include <qmenubar.h> 43#include <qmenubar.h>
44#include <qmessagebox.h> 44#include <qmessagebox.h>
45#include <qaction.h> 45#include <qaction.h>
46#include <qapplication.h> 46#include <qapplication.h>
47#include <qfontmetrics.h> 47#include <qfontmetrics.h>
48#include <qcombobox.h> 48#include <qcombobox.h>
49#include <qevent.h> 49#include <qevent.h>
50#include <qtabwidget.h> 50#include <qtabwidget.h>
51#include <qtabbar.h> 51#include <qtabbar.h>
52#include <qpe/config.h> 52#include <qpe/config.h>
53#include <qstringlist.h> 53#include <qstringlist.h>
54#include <qpalette.h> 54#include <qpalette.h>
55#include <qfontdatabase.h> 55#include <qfontdatabase.h>
56#include <qfile.h> 56#include <qfile.h>
57#include <qspinbox.h> 57#include <qspinbox.h>
58#include <qlayout.h> 58#include <qlayout.h>
59#include <qvbox.h> 59#include <qvbox.h>
60 60
61#include <sys/wait.h> 61#include <sys/wait.h>
62#include <stdio.h> 62#include <stdio.h>
63#include <stdlib.h> 63#include <stdlib.h>
64#include <assert.h> 64#include <assert.h>
65 65
66#include "konsole.h" 66#include "konsole.h"
67#include "keytrans.h" 67#include "keytrans.h"
68#include "commandeditdialog.h" 68#include "commandeditdialog.h"
69 69
70class EKNumTabBar : public QTabBar 70class EKNumTabBar : public QTabBar
71{ 71{
72public: 72public:
73 EKNumTabBar(QWidget *parent = 0, const char *name = 0) : 73 EKNumTabBar(QWidget *parent = 0, const char *name = 0) :
74 QTabBar(parent, name) 74 QTabBar(parent, name)
75 {} 75 {}
76 76
77 // QList<QTab> *getTabList() { return(tabList()); } 77 // QList<QTab> *getTabList() { return(tabList()); }
78 78
79 void numberTabs() 79 void numberTabs()
80 { 80 {
81 // Yes, it really is this messy. QTabWidget needs functions 81 // Yes, it really is this messy. QTabWidget needs functions
82 // that provide acces to tabs in a sequential way. 82 // that provide acces to tabs in a sequential way.
83 int m=INT_MIN; 83 int m=INT_MIN;
84 for (int i=0; i<count(); i++) 84 for (int i=0; i<count(); i++)
85 { 85 {
86 QTab* left=0; 86 QTab* left=0;
87 QListIterator<QTab> it(*tabList()); 87 QListIterator<QTab> it(*tabList());
88 int x=INT_MAX; 88 int x=INT_MAX;
89 for( QTab* t; (t=it.current()); ++it ) 89 for( QTab* t; (t=it.current()); ++it )
90 { 90 {
91 int tx = t->rect().x(); 91 int tx = t->rect().x();
92 if ( tx<x && tx>m ) 92 if ( tx<x && tx>m )
93 { 93 {
94 x = tx; 94 x = tx;
95 left = t; 95 left = t;
96 } 96 }
97 } 97 }
98 if ( left ) 98 if ( left )
99 { 99 {
100 left->setText(QString::number(i+1)); 100 left->setText(QString::number(i+1));
101 m = left->rect().x(); 101 m = left->rect().x();
102 } 102 }
103 } 103 }
104 } 104 }
105 105
106 virtual QSize sizeHint() const 106 virtual QSize sizeHint() const
107 { 107 {
108 if (isHidden()) 108 if (isHidden())
109 { 109 {
110 return(QSize(0,0)); 110 return(QSize(0,0));
111 } 111 }
112 else 112 else
113 { 113 {
114 QSize size = QTabBar::sizeHint(); 114 QSize size = QTabBar::sizeHint();
115 int shrink = 5; 115 int shrink = 5;
116 if (qApp->desktop()->width() > 600 || qApp->desktop()->height() > 600) 116 if (qApp->desktop()->width() > 600 || qApp->desktop()->height() > 600)
117 { 117 {
118 shrink = 10; 118 shrink = 10;
119 } 119 }
120 size.setHeight(size.height() - shrink); 120 size.setHeight(size.height() - shrink);
121 return(size); 121 return(size);
122 } 122 }
123 } 123 }
124 124
125}; 125};
126 126
127class EKNumTabWidget : public QTabWidget 127class EKNumTabWidget : public QTabWidget
128{ 128{
129public: 129public:
130 EKNumTabWidget(QWidget* parent) : QTabWidget(parent) 130 EKNumTabWidget(QWidget* parent) : QTabWidget(parent)
131 { 131 {
132 setTabBar(new EKNumTabBar(parent,"EKTabBar")); 132 setTabBar(new EKNumTabBar(parent,"EKTabBar"));
133 setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); 133 setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );
134 } 134 }
135 135
136 EKNumTabBar *getTabBar() const 136 EKNumTabBar *getTabBar() const
137 { 137 {
138 return ((EKNumTabBar*)tabBar()); 138 return ((EKNumTabBar*)tabBar());
139 } 139 }
140 140
141 141
142 void addTab(QWidget* w) 142 void addTab(QWidget* w)
143 { 143 {
144 QTab* t = new QTab(QString::number(tabBar()->count()+1)); 144 QTab* t = new QTab(QString::number(tabBar()->count()+1));
145 QTabWidget::addTab(w,t); 145 QTabWidget::addTab(w,t);
146 } 146 }
147 147
148 void removeTab(QWidget* w) 148 void removeTab(QWidget* w)
149 { 149 {
150 removePage(w); 150 removePage(w);
151 ((EKNumTabBar*)tabBar())->numberTabs(); 151 ((EKNumTabBar*)tabBar())->numberTabs();
152 } 152 }
153}; 153};
154 154
155// This could be configurable or dynamicly generated from the bash history 155// This could be configurable or dynamicly generated from the bash history
156// file of the user 156// file of the user
157static const char *commonCmds[] = 157static const char *commonCmds[] =
158 { 158 {
159 "ls ", // I left this here, cause it looks better than the first alpha 159 "ls ", // I left this here, cause it looks better than the first alpha
160 "cardctl eject", 160 "cardctl eject",
161 "cat ", 161 "cat ",
162 "cd ", 162 "cd ",
163 "chmod ", 163 "chmod ",
164 "clear", 164 "clear",
165 "cp ", 165 "cp ",
166 "dc ", 166 "dc ",
167 "df ", 167 "df ",
168 "dmesg", 168 "dmesg",
169 "echo ", 169 "echo ",
170 "env", 170 "env",
171 "find ", 171 "find ",
172 "free", 172 "free",
173 "grep ", 173 "grep ",
174 "ifconfig ", 174 "ifconfig ",
175 "ipkg ", 175 "ipkg ",
176 "mkdir ", 176 "mkdir ",
177 "mv ", 177 "mv ",
178 "nc localhost 7776", 178 "nc localhost 7776",
179 "nc localhost 7777", 179 "nc localhost 7777",
180 "netstat ", 180 "netstat ",
181 "nslookup ", 181 "nslookup ",
182 "ping ", 182 "ping ",
183 "ps aux", 183 "ps aux",
184 "pwd ", 184 "pwd ",
185 "qcop QPE/System 'linkChanged(QString)' ''", 185 "qcop QPE/System 'linkChanged(QString)' ''",
186 "qcop QPE/System 'restart()'", 186 "qcop QPE/System 'restart()'",
187 "qcop QPE/System 'quit()'", 187 "qcop QPE/System 'quit()'",
188 "rm ", 188 "rm ",
189 "rmdir ", 189 "rmdir ",
190 "route ", 190 "route ",
191 "set ", 191 "set ",
192 "traceroute", 192 "traceroute",
193 193
194 /* 194 /*
195 "gzip", 195 "gzip",
196 "gunzip", 196 "gunzip",
197 "chgrp", 197 "chgrp",
198 "chown", 198 "chown",
199 "date", 199 "date",
200 "dd", 200 "dd",
201 "df", 201 "df",
202 "dmesg", 202 "dmesg",
203 "fuser", 203 "fuser",
204 "hostname", 204 "hostname",
205 "kill", 205 "kill",
206 "killall", 206 "killall",
207 "ln", 207 "ln",
208 "ping", 208 "ping",
209 "mount", 209 "mount",
210 "more", 210 "more",
211 "sort", 211 "sort",
212 "touch", 212 "touch",
213 "umount", 213 "umount",
214 "mknod", 214 "mknod",
215 "netstat", 215 "netstat",
216 */ 216 */
217 217
218 "exit", 218 "exit",
219 NULL 219 NULL
220 }; 220 };
221 221
222 222
223Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) : 223Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) :
224 QMainWindow(parent, name, fl) 224 QMainWindow(parent, name, fl)
225{ 225{
226 QStrList args; 226 QStrList args;
227 init("/bin/bash",args); 227 init("/bin/bash",args);
228} 228}
229 229
230Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int) 230Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int)
231 : QMainWindow(0, name) 231 : QMainWindow(0, name)
232{ 232{
233 init(_pgm,_args); 233 init(_pgm,_args);
234} 234}
235 235
236struct HistoryItem 236struct HistoryItem
237{ 237{
238 HistoryItem(int c, const QString &l) 238 HistoryItem(int c, const QString &l)
239 { 239 {
240 count = c; 240 count = c;
241 line = l; 241 line = l;
242 } 242 }
243 int count; 243 int count;
244 QString line; 244 QString line;
245}; 245};
246 246
247class HistoryList : public QList<HistoryItem> 247class HistoryList : public QList<HistoryItem>
248{ 248{
249 virtual int compareItems( QCollection::Item item1, QCollection::Item item2) 249 virtual int compareItems( QCollection::Item item1, QCollection::Item item2)
250 { 250 {
251 int c1 = ((HistoryItem*)item1)->count; 251 int c1 = ((HistoryItem*)item1)->count;
252 int c2 = ((HistoryItem*)item2)->count; 252 int c2 = ((HistoryItem*)item2)->count;
253 if (c1 > c2) 253 if (c1 > c2)
254 return(1); 254 return(1);
255 if (c1 < c2) 255 if (c1 < c2)
256 return(-1); 256 return(-1);
257 return(0); 257 return(0);
258 } 258 }
259}; 259};
260 260
261void Konsole::initCommandList() 261void Konsole::initCommandList()
262{ 262{
263 // qDebug("Konsole::initCommandList"); 263 // qDebug("Konsole::initCommandList");
264 Config cfg( "Konsole" ); 264 Config cfg( "Konsole" );
265 cfg.setGroup("Commands"); 265 cfg.setGroup("Commands");
266 // commonCombo->setInsertionPolicy(QComboBox::AtCurrent); 266 // commonCombo->setInsertionPolicy(QComboBox::AtCurrent);
267 commonCombo->clear(); 267 commonCombo->clear();
268 268
269 if (cfg.readEntry("ShellHistory","TRUE") == "TRUE") 269 if (cfg.readEntry("ShellHistory","TRUE") == "TRUE")
270 { 270 {
271 QString histfilename = QString(getenv("HOME")) + "/.bash_history"; 271 QString histfilename = QString(getenv("HOME")) + "/.bash_history";
272 histfilename = cfg.readEntry("ShellHistoryPath",histfilename); 272 histfilename = cfg.readEntry("ShellHistoryPath",histfilename);
273 QFile histfile(histfilename); 273 QFile histfile(histfilename);
274 // note: compiler barfed on: 274 // note: compiler barfed on:
275 // QFile histfile(QString(getenv("HOME")) + "/.bash_history"); 275 // QFile histfile(QString(getenv("HOME")) + "/.bash_history");
276 if (histfile.open( IO_ReadOnly )) 276 if (histfile.open( IO_ReadOnly ))
277 { 277 {
278 QString line; 278 QString line;
279 uint i; 279 uint i;
280 HistoryList items; 280 HistoryList items;
281 281
282 int lineno = 0; 282 int lineno = 0;
283 while(!histfile.atEnd()) 283 while(!histfile.atEnd())
284 { 284 {
285 if (histfile.readLine(line, 200) < 0) 285 if (histfile.readLine(line, 200) < 0)
286 { 286 {
287 break; 287 break;
288 } 288 }
289 line = line.left(line.length()-1); 289 line = line.left(line.length()-1);
290 lineno++; 290 lineno++;
291 291
292 for(i=0; i<items.count(); i++) 292 for(i=0; i<items.count(); i++)
293 { 293 {
294 if (line == items.at(i)->line) 294 if (line == items.at(i)->line)
295 { 295 {
296 // weight recent commands & repeated commands more 296 // weight recent commands & repeated commands more
297 // by adding up the index of each command 297 // by adding up the index of each command
298 items.at(i)->count += lineno; 298 items.at(i)->count += lineno;
299 break; 299 break;
300 } 300 }
301 } 301 }
302 if (i >= items.count()) 302 if (i >= items.count())
303 { 303 {
304 items.append(new HistoryItem(lineno, line)); 304 items.append(new HistoryItem(lineno, line));
305 } 305 }
306 } 306 }
307 items.sort(); 307 items.sort();
308 int n = items.count(); 308 int n = items.count();
309 if (n > 40) 309 if (n > 40)
310 { 310 {
311 n = 40; 311 n = 40;
312 } 312 }
313 for(int i=0; i<n; i++) 313 for(int i=0; i<n; i++)
314 { 314 {
315 // should insert start of command, but keep whole thing 315 // should insert start of command, but keep whole thing
316 if (items.at(items.count()-i-1)->line.length() < 30) 316 if (items.at(items.count()-i-1)->line.length() < 30)
317 { 317 {
318 commonCombo->insertItem(items.at(items.count()-i-1)->line); 318 commonCombo->insertItem(items.at(items.count()-i-1)->line);
319 } 319 }
320 } 320 }
321 histfile.close(); 321 histfile.close();
322 } 322 }
323 } 323 }
324 if (cfg.readEntry("Commands Set","FALSE") == "FALSE") 324 if (cfg.readEntry("Commands Set","FALSE") == "FALSE")
325 { 325 {
326 for (int i = 0; commonCmds[i] != NULL; i++) 326 for (int i = 0; commonCmds[i] != NULL; i++)
327 { 327 {
328 commonCombo->insertItem(commonCmds[i]); 328 commonCombo->insertItem(commonCmds[i]);
329 } 329 }
330 } 330 }
331 else 331 else
332 { 332 {
333 for (int i = 0; i < 100; i++) 333 for (int i = 0; i < 100; i++)
334 { 334 {
335 if (!(cfg.readEntry( QString::number(i),"")).isEmpty()) 335 if (!(cfg.readEntry( QString::number(i),"")).isEmpty())
336 commonCombo->insertItem(cfg.readEntry( QString::number(i),"")); 336 commonCombo->insertItem(cfg.readEntry( QString::number(i),""));
337 } 337 }
338 } 338 }
339 339
340 340
341} 341}
342 342
343static void sig_handler(int x) 343static void sig_handler(int x)
344{ 344{
345 printf("got signal %d\n",x); 345 printf("got signal %d\n",x);
346} 346}
347 347
348void Konsole::init(const char* _pgm, QStrList & _args) 348void Konsole::init(const char* _pgm, QStrList & _args)
349{ 349{
350 350
351#if 0 351#if 0
352 for(int i=1; i<=31; i++) 352 for(int i=1; i<=31; i++)
353 { 353 {
354 if (i != SIGPIPE && i != SIGPROF && i != SIGSEGV 354 if (i != SIGPIPE && i != SIGPROF && i != SIGSEGV
355 && i != SIGINT && i != SIGILL && i != SIGTERM 355 && i != SIGINT && i != SIGILL && i != SIGTERM
356 && i != SIGBUS) 356 && i != SIGBUS)
357 signal(i,sig_handler); 357 signal(i,sig_handler);
358 } 358 }
359#endif 359#endif
360 signal(SIGSTOP, sig_handler); 360 signal(SIGSTOP, sig_handler);
361 signal(SIGCONT, sig_handler); 361 signal(SIGCONT, sig_handler);
362 signal(SIGTSTP, sig_handler); 362 signal(SIGTSTP, sig_handler);
363 363
364 b_scroll = TRUE; // histon; 364 b_scroll = TRUE; // histon;
365 n_keytab = 0; 365 n_keytab = 0;
366 n_render = 0; 366 n_render = 0;
367 startUp=0; 367 startUp=0;
368 fromMenu = FALSE; 368 fromMenu = FALSE;
369 fullscreen = false; 369 fullscreen = false;
370 370
371 setCaption( tr( "Konsole" ) ); 371 setCaption( tr( "Konsole" ) );
372 setIcon( Resource::loadPixmap( "konsole/Terminal" ) ); 372 setIcon( Resource::loadPixmap( "konsole/Terminal" ) );
373 373
374 Config cfg( "Konsole" ); 374 Config cfg( "Konsole" );
375 cfg.setGroup("Font"); 375 cfg.setGroup("Font");
376 QString tmp; 376 QString tmp;
377 377
378 // initialize the list of allowed fonts /////////////////////////////////// 378 // initialize the list of allowed fonts ///////////////////////////////////
379 379
380 QString cfgFontName = cfg.readEntry("FontName","Lcfont"); 380 QString cfgFontName = cfg.readEntry("FontName","Lcfont");
381 int cfgFontSize = cfg.readNumEntry("FontSize",18); 381 int cfgFontSize = cfg.readNumEntry("FontSize",18);
382 382
383 cfont = -1; 383 cfont = -1;
384 384
385 // this code causes repeated access to all the font files 385 // this code causes repeated access to all the font files
386 // which does slow down startup 386 // which does slow down startup
387 QFontDatabase fontDB; 387 QFontDatabase fontDB;
388 QStringList familyNames; 388 QStringList familyNames;
389 familyNames = fontDB.families( FALSE ); 389 familyNames = fontDB.families( FALSE );
390 QString s; 390 QString s;
391 int fontIndex = 0; 391 int fontIndex = 0;
392 int familyNum = 0; 392 int familyNum = 0;
393 fontList = new QPopupMenu( this ); 393 fontList = new QPopupMenu( this );
394 394
395 for(uint j = 0; j < (uint)familyNames.count(); j++) 395 for(uint j = 0; j < (uint)familyNames.count(); j++)
396 { 396 {
397 s = familyNames[j]; 397 s = familyNames[j];
398 if ( s.contains('-') ) 398 if ( s.contains('-') )
399 { 399 {
400 int i = s.find('-'); 400 int i = s.find('-');
401 s = s.right( s.length() - i - 1 ) + " [" + s.left( i ) + "]"; 401 s = s.right( s.length() - i - 1 ) + " [" + s.left( i ) + "]";
402 } 402 }
403 s[0] = s[0].upper(); 403 s[0] = s[0].upper();
404 404
405 QValueList<int> sizes = fontDB.pointSizes( familyNames[j] ); 405 QValueList<int> sizes = fontDB.pointSizes( familyNames[j] );
406 406
407 printf("family[%d] = %s with %d sizes\n", j, familyNames[j].latin1(), 407 printf("family[%d] = %s with %d sizes\n", j, familyNames[j].latin1(),
408 sizes.count()); 408 sizes.count());
409 409
410 if (sizes.count() > 0) 410 if (sizes.count() > 0)
411 { 411 {
412 QPopupMenu *sizeMenu; 412 QPopupMenu *sizeMenu;
413 QFont f; 413 QFont f;
414 int last_width = -1; 414 int last_width = -1;
415 sizeMenu = NULL; 415 sizeMenu = NULL;
416 416
417 for(uint i = 0; i < (uint)sizes.count() + 4; i++) 417 for(uint i = 0; i < (uint)sizes.count() + 4; i++)
418 { 418 {
419 // printf("family %s size %d ", familyNames[j].latin1(), sizes[i]); 419 // printf("family %s size %d ", familyNames[j].latin1(), sizes[i]);
420 // need to divide by 10 on the Z, but not otherwise 420 // need to divide by 10 on the Z, but not otherwise
421 int size; 421 int size;
422 422
423 if (i >= (uint)sizes.count()) 423 if (i >= (uint)sizes.count())
424 { 424 {
425 // try for expandable fonts 425 // try for expandable fonts
426 size = sizes[sizes.count()-1] + 2 * (i - sizes.count() + 1); 426 size = sizes[sizes.count()-1] + 2 * (i - sizes.count() + 1);
427 } 427 }
428 else 428 else
429 { 429 {
430 printf("sizes[%d] = %d\n", i, sizes[i]); 430 printf("sizes[%d] = %d\n", i, sizes[i]);
431 size = sizes[i]; 431 size = sizes[i];
432 } 432 }
433#ifndef __i386__
434 // a hack, sizes on Z seem to be points*10 433 // a hack, sizes on Z seem to be points*10
435 size /= 10; 434 size /= 10;
436#endif
437 435
438 f = QFont(familyNames[j], size); 436 f = QFont(familyNames[j], size);
439 f.setFixedPitch(true); 437 f.setFixedPitch(true);
440 QFontMetrics fm(f); 438 QFontMetrics fm(f);
441 // don't trust f.fixedPitch() or f.exactMatch(), they lie!! 439 // don't trust f.fixedPitch() or f.exactMatch(), they lie!!
442 if (fm.width("l") == fm.width("m") 440 if (fm.width("l") == fm.width("m")
443 && (i < (uint)sizes.count() 441 && (i < (uint)sizes.count()
444 || fm.width("m") > last_width)) 442 || fm.width("m") > last_width))
445 { 443 {
446 if (i < (uint)sizes.count()) 444 if (i < (uint)sizes.count())
447 { 445 {
448 last_width = fm.width("m"); 446 last_width = fm.width("m");
449 } 447 }
450 if (sizeMenu == NULL) 448 if (sizeMenu == NULL)
451 { 449 {
452 sizeMenu = new QPopupMenu(); 450 sizeMenu = new QPopupMenu();
453 } 451 }
454 int id = sizeMenu->insertItem(QString("%1").arg(size), fontIndex); 452 int id = sizeMenu->insertItem(QString("%1").arg(size), fontIndex);
455 sizeMenu->setItemParameter(id, fontIndex); 453 sizeMenu->setItemParameter(id, fontIndex);
456 sizeMenu->connectItem(id, this, SLOT(setFont(int))); 454 sizeMenu->connectItem(id, this, SLOT(setFont(int)));
457 QString name = s + " " + QString::number(size); 455 QString name = s + " " + QString::number(size);
458 fonts.append(new VTFont(name, f, familyNames[j], familyNum, size)); 456 fonts.append(new VTFont(name, f, familyNames[j], familyNum, size));
459 if (familyNames[j] == cfgFontName && size == cfgFontSize) 457 if (familyNames[j] == cfgFontName && size == cfgFontSize)
460 { 458 {
461 cfont = fontIndex; 459 cfont = fontIndex;
462 } 460 }
463 printf("FOUND: %s family %s size %d\n", name.latin1(), familyNames[j].latin1(), size); 461 printf("FOUND: %s family %s size %d\n", name.latin1(), familyNames[j].latin1(), size);
464 fontIndex++; 462 fontIndex++;
465 } 463 }
466 } 464 }
467 if (sizeMenu) 465 if (sizeMenu)
468 { 466 {
469 fontList->insertItem(s, sizeMenu, familyNum + 1000); 467 fontList->insertItem(s, sizeMenu, familyNum + 1000);
470 468
471 familyNum++; 469 familyNum++;
472 } 470 }
473 } 471 }
474 472
475 } 473 }
476 474
477 if (cfont < 0 || cfont >= (int)fonts.count()) 475 if (cfont < 0 || cfont >= (int)fonts.count())
478 { 476 {
479 cfont = 0; 477 cfont = 0;
480 } 478 }
481 479
482 // create terminal emulation framework //////////////////////////////////// 480 // create terminal emulation framework ////////////////////////////////////
483 nsessions = 0; 481 nsessions = 0;
484 482
485 tab = new EKNumTabWidget(this); 483 tab = new EKNumTabWidget(this);
486 // tab->setMargin(tab->margin()-5); 484 // tab->setMargin(tab->margin()-5);
487 connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*))); 485 connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*)));
488 486
489 // create terminal toolbar //////////////////////////////////////////////// 487 // create terminal toolbar ////////////////////////////////////////////////
490 setToolBarsMovable( FALSE ); 488 setToolBarsMovable( FALSE );
491 menuToolBar = new QToolBar( this ); 489 menuToolBar = new QToolBar( this );
492 menuToolBar->setHorizontalStretchable( TRUE ); 490 menuToolBar->setHorizontalStretchable( TRUE );
493 491
494 QMenuBar *menuBar = new QMenuBar( menuToolBar ); 492 QMenuBar *menuBar = new QMenuBar( menuToolBar );
495 493
496 bool c7xx = false; 494 bool c7xx = false;
497 if (qApp->desktop()->width() > 600 || qApp->desktop()->height() > 600) 495 if (qApp->desktop()->width() > 600 || qApp->desktop()->height() > 600)
498 { 496 {
499 c7xx = true; 497 c7xx = true;
500 } 498 }
501 QFont menuFont; 499 QFont menuFont;
502 menuFont.setPointSize(c7xx? 18 : 10); 500 menuFont.setPointSize(c7xx? 18 : 10);
503 qApp->setFont(menuFont, true); 501 qApp->setFont(menuFont, true);
504 502
505 setFont(cfont); 503 setFont(cfont);
506 504
507 configMenu = new QPopupMenu( this); 505 configMenu = new QPopupMenu( this);
508 colorMenu = new QPopupMenu( this); 506 colorMenu = new QPopupMenu( this);
509 scrollMenu = new QPopupMenu( this); 507 scrollMenu = new QPopupMenu( this);
510 editCommandListMenu = new QPopupMenu( this); 508 editCommandListMenu = new QPopupMenu( this);
511 509
512 configMenu->insertItem(tr("Command List"), editCommandListMenu); 510 configMenu->insertItem(tr("Command List"), editCommandListMenu);
513 511
514 bool listHidden; 512 bool listHidden;
515 cfg.setGroup("Menubar"); 513 cfg.setGroup("Menubar");
516 if( cfg.readEntry("Hidden","FALSE") == "TRUE") 514 if( cfg.readEntry("Hidden","FALSE") == "TRUE")
517 { 515 {
518 ec_cmdlist = editCommandListMenu->insertItem( tr( "Show command list" )); 516 ec_cmdlist = editCommandListMenu->insertItem( tr( "Show command list" ));
519 listHidden=TRUE; 517 listHidden=TRUE;
520 } 518 }
521 else 519 else
522 { 520 {
523 ec_cmdlist = editCommandListMenu->insertItem( tr( "Hide command list" )); 521 ec_cmdlist = editCommandListMenu->insertItem( tr( "Hide command list" ));
524 listHidden=FALSE; 522 listHidden=FALSE;
525 } 523 }
526 524
527 cfg.setGroup("Tabs"); 525 cfg.setGroup("Tabs");
528 526
529 tabMenu = new QPopupMenu(this); 527 tabMenu = new QPopupMenu(this);
530 tm_bottom = tabMenu->insertItem(tr("Bottom" )); 528 tm_bottom = tabMenu->insertItem(tr("Bottom" ));
531 tm_top = tabMenu->insertItem(tr("Top")); 529 tm_top = tabMenu->insertItem(tr("Top"));
532 tm_hidden = tabMenu->insertItem(tr("Hidden")); 530 tm_hidden = tabMenu->insertItem(tr("Hidden"));
533 531
534 configMenu->insertItem(tr("Tabs"), tabMenu); 532 configMenu->insertItem(tr("Tabs"), tabMenu);
535 533
536 tmp=cfg.readEntry("Position","Top"); 534 tmp=cfg.readEntry("Position","Top");
537 if(tmp=="Top") 535 if(tmp=="Top")
538 { 536 {
539 tab->setTabPosition(QTabWidget::Top); 537 tab->setTabPosition(QTabWidget::Top);
540 tab->getTabBar()->show(); 538 tab->getTabBar()->show();
541 tabPos = tm_top; 539 tabPos = tm_top;
542 } 540 }
543 else if (tmp=="Bottom") 541 else if (tmp=="Bottom")
544 { 542 {
545 tab->setTabPosition(QTabWidget::Bottom); 543 tab->setTabPosition(QTabWidget::Bottom);
546 tab->getTabBar()->show(); 544 tab->getTabBar()->show();
547 tabPos = tm_bottom; 545 tabPos = tm_bottom;
548 } 546 }
549 else 547 else
550 { 548 {
551 tab->getTabBar()->hide(); 549 tab->getTabBar()->hide();
552 tab->setMargin(tab->margin()); 550 tab->setMargin(tab->margin());
553 tabPos = tm_hidden; 551 tabPos = tm_hidden;
554 } 552 }
555 553
556 cm_bw = colorMenu->insertItem(tr( "Black on White")); 554 cm_bw = colorMenu->insertItem(tr( "Black on White"));
557 cm_wb = colorMenu->insertItem(tr( "White on Black")); 555 cm_wb = colorMenu->insertItem(tr( "White on Black"));
558 cm_gb = colorMenu->insertItem(tr( "Green on Black")); 556 cm_gb = colorMenu->insertItem(tr( "Green on Black"));
559 // cm_bt = colorMenu->insertItem(tr( "Black on Transparent")); 557 // cm_bt = colorMenu->insertItem(tr( "Black on Transparent"));
560 cm_br = colorMenu->insertItem(tr( "Black on Pink")); 558 cm_br = colorMenu->insertItem(tr( "Black on Pink"));
561 cm_rb = colorMenu->insertItem(tr( "Pink on Black")); 559 cm_rb = colorMenu->insertItem(tr( "Pink on Black"));
562 cm_gy = colorMenu->insertItem(tr( "Green on Yellow")); 560 cm_gy = colorMenu->insertItem(tr( "Green on Yellow"));
563 cm_bm = colorMenu->insertItem(tr( "Blue on Magenta")); 561 cm_bm = colorMenu->insertItem(tr( "Blue on Magenta"));
564 cm_mb = colorMenu->insertItem(tr( "Magenta on Blue")); 562 cm_mb = colorMenu->insertItem(tr( "Magenta on Blue"));
565 cm_cw = colorMenu->insertItem(tr( "Cyan on White")); 563 cm_cw = colorMenu->insertItem(tr( "Cyan on White"));
566 cm_wc = colorMenu->insertItem(tr( "White on Cyan")); 564 cm_wc = colorMenu->insertItem(tr( "White on Cyan"));
567 cm_bb = colorMenu->insertItem(tr( "Blue on Black")); 565 cm_bb = colorMenu->insertItem(tr( "Blue on Black"));
568 cm_ab = colorMenu->insertItem(tr( "Amber on Black")); 566 cm_ab = colorMenu->insertItem(tr( "Amber on Black"));
569 cm_default = colorMenu->insertItem(tr("default")); 567 cm_default = colorMenu->insertItem(tr("default"));
570 568
571#ifdef QT_QWS_OPIE 569#ifdef QT_QWS_OPIE
572 570
573 colorMenu->insertItem(tr( "Custom")); 571 colorMenu->insertItem(tr( "Custom"));
574#endif 572#endif
575 573
576 configMenu->insertItem(tr( "Colors") ,colorMenu); 574 configMenu->insertItem(tr( "Colors") ,colorMenu);
577 575
578 sessionList = new QPopupMenu(this); 576 sessionList = new QPopupMenu(this);
579 sessionList-> insertItem ( Resource::loadPixmap ( "konsole/Terminal" ), tr( "new session" ), this, 577 sessionList-> insertItem ( Resource::loadPixmap ( "konsole/Terminal" ), tr( "new session" ), this,
580 SLOT(newSession()) ); 578 SLOT(newSession()) );
581 579
582 // connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) )); 580 // connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) ));
583 connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) )); 581 connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) ));
584 connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuIsSelected(int) )); 582 connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuIsSelected(int) ));
585 connect( tabMenu, SIGNAL( activated(int) ), this, SLOT( tabMenuSelected(int) )); 583 connect( tabMenu, SIGNAL( activated(int) ), this, SLOT( tabMenuSelected(int) ));
586 connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int))); 584 connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int)));
587 connect( editCommandListMenu,SIGNAL(activated(int)),this,SLOT(editCommandListMenuSelected(int))); 585 connect( editCommandListMenu,SIGNAL(activated(int)),this,SLOT(editCommandListMenuSelected(int)));
588 connect( sessionList, SIGNAL(activated(int)), this, SLOT( sessionListSelected(int) ) ); 586 connect( sessionList, SIGNAL(activated(int)), this, SLOT( sessionListSelected(int) ) );
589 587
590 menuBar->insertItem( tr("View"), configMenu ); 588 menuBar->insertItem( tr("View"), configMenu );
591 menuBar->insertItem( tr("Fonts"), fontList ); 589 menuBar->insertItem( tr("Fonts"), fontList );
592 menuBar->insertItem( tr("Sessions"), sessionList ); 590 menuBar->insertItem( tr("Sessions"), sessionList );
593 591
594 toolBar = new QToolBar( this ); 592 toolBar = new QToolBar( this );
595 593
596 QAction *a; 594 QAction *a;
597 595
598 // Button Commands 596 // Button Commands
599 a = new QAction( tr("New"), Resource::loadPixmap( "konsole/Terminal" ), QString::null, 0, this, 0 ); 597 a = new QAction( tr("New"), Resource::loadPixmap( "konsole/Terminal" ), QString::null, 0, this, 0 );
600 connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); 598 connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) );
601 a->addTo( toolBar ); 599 a->addTo( toolBar );
602 600
603 a = new QAction( tr("Full Screen"), Resource::loadPixmap( "fullscreen" ), QString::null, 0, this, 0 ); 601 a = new QAction( tr("Full Screen"), Resource::loadPixmap( "fullscreen" ), QString::null, 0, this, 0 );
604 connect( a, SIGNAL( activated() ), this, SLOT( toggleFullScreen() ) ); 602 connect( a, SIGNAL( activated() ), this, SLOT( toggleFullScreen() ) );
605 a->addTo( toolBar ); 603 a->addTo( toolBar );
606 604
607 a = new QAction( tr("Zoom"), Resource::loadPixmap( "zoom" ), QString::null, 0, this, 0 ); 605 a = new QAction( tr("Zoom"), Resource::loadPixmap( "zoom" ), QString::null, 0, this, 0 );
608 connect( a, SIGNAL( activated() ), this, SLOT( cycleZoom() ) ); 606 connect( a, SIGNAL( activated() ), this, SLOT( cycleZoom() ) );
609 a->addTo( toolBar ); 607 a->addTo( toolBar );
610 608
611 609
612 /* 610 /*
613 a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 ); 611 a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 );
614 connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolBar ); 612 connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolBar );
615 a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 ); 613 a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 );
616 connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolBar ); 614 connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolBar );
617 a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 ); 615 a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 );
618 connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolBar ); 616 connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolBar );
619 */ 617 */
620 /* 618 /*
621 a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 ); 619 a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 );
622 connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolBar ); 620 connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolBar );
623 a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 ); 621 a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 );
624 connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolBar ); 622 connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolBar );
625 */ 623 */
626 a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); 624 a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 );
627 connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); 625 connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) );
628 a->addTo( toolBar ); 626 a->addTo( toolBar );
629 627
630 secondToolBar = new QToolBar( this ); 628 secondToolBar = new QToolBar( this );
631 secondToolBar->setHorizontalStretchable( TRUE ); 629 secondToolBar->setHorizontalStretchable( TRUE );
632 630
633 commonCombo = new QComboBox( secondToolBar ); 631 commonCombo = new QComboBox( secondToolBar );
634 // commonCombo->setMaximumWidth(236); 632 // commonCombo->setMaximumWidth(236);
635 633
636 ec_quick = editCommandListMenu->insertItem( tr( "Quick Edit" ) ); 634 ec_quick = editCommandListMenu->insertItem( tr( "Quick Edit" ) );
637 if( listHidden) 635 if( listHidden)
638 { 636 {
639 secondToolBar->hide(); 637 secondToolBar->hide();
640 editCommandListMenu->setItemEnabled(ec_quick ,FALSE); 638 editCommandListMenu->setItemEnabled(ec_quick ,FALSE);
641 } 639 }
642 ec_edit = editCommandListMenu->insertItem(tr( "Edit..." ) ); 640 ec_edit = editCommandListMenu->insertItem(tr( "Edit..." ) );
643 641
644 cfg.setGroup("Commands"); 642 cfg.setGroup("Commands");
645 commonCombo->setInsertionPolicy(QComboBox::AtCurrent); 643 commonCombo->setInsertionPolicy(QComboBox::AtCurrent);
646 644
647 initCommandList(); 645 initCommandList();
648 // for (int i = 0; commonCmds[i] != NULL; i++) { 646 // for (int i = 0; commonCmds[i] != NULL; i++) {
649 // commonCombo->insertItem( commonCmds[i], i ); 647 // commonCombo->insertItem( commonCmds[i], i );
650 // tmp = cfg.readEntry( QString::number(i),""); 648 // tmp = cfg.readEntry( QString::number(i),"");
651 // if(tmp != "") 649 // if(tmp != "")
652 // commonCombo->changeItem( tmp,i ); 650 // commonCombo->changeItem( tmp,i );
653 // } 651 // }
654 652
655 connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) )); 653 connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) ));
656 654
657 sm_none = scrollMenu->insertItem(tr( "None" )); 655 sm_none = scrollMenu->insertItem(tr( "None" ));
658 sm_left = scrollMenu->insertItem(tr( "Left" )); 656 sm_left = scrollMenu->insertItem(tr( "Left" ));
659 sm_right = scrollMenu->insertItem(tr( "Right" )); 657 sm_right = scrollMenu->insertItem(tr( "Right" ));
660 // scrollMenu->insertSeparator(4); 658 // scrollMenu->insertSeparator(4);
661 // scrollMenu->insertItem(tr( "Horizontal" )); 659 // scrollMenu->insertItem(tr( "Horizontal" ));
662 660
663 configMenu->insertItem(tr( "ScrollBar" ),scrollMenu); 661 configMenu->insertItem(tr( "ScrollBar" ),scrollMenu);
664 662
665 configMenu->insertItem(tr( "History..." ), this, SLOT(historyDialog())); 663 configMenu->insertItem(tr( "History..." ), this, SLOT(historyDialog()));
666 664
667 cm_wrap = configMenu->insertItem(tr( "Wrap" )); 665 cm_wrap = configMenu->insertItem(tr( "Wrap" ));
668 cfg.setGroup("ScrollBar"); 666 cfg.setGroup("ScrollBar");
669 configMenu->setItemChecked(cm_wrap, cfg.readBoolEntry("HorzScroll",0)); 667 configMenu->setItemChecked(cm_wrap, cfg.readBoolEntry("HorzScroll",0));
670 668
671 cm_beep = configMenu->insertItem(tr( "Use Beep" )); 669 cm_beep = configMenu->insertItem(tr( "Use Beep" ));
672 cfg.setGroup("Menubar"); 670 cfg.setGroup("Menubar");
673 configMenu->setItemChecked(cm_beep, cfg.readBoolEntry("useBeep",0)); 671 configMenu->setItemChecked(cm_beep, cfg.readBoolEntry("useBeep",0));
674 672
675 fullscreen_msg = new QLabel(this); 673 fullscreen_msg = new QLabel(this);
676 fullscreen_msg-> setAlignment ( AlignCenter | SingleLine ); 674 fullscreen_msg-> setAlignment ( AlignCenter | SingleLine );
677 fullscreen_msg-> hide(); 675 fullscreen_msg-> hide();
678 fullscreen_msg-> setSizePolicy ( QSizePolicy ( QSizePolicy::Expanding, QSizePolicy::Expanding )); 676 fullscreen_msg-> setSizePolicy ( QSizePolicy ( QSizePolicy::Expanding, QSizePolicy::Expanding ));
679 fullscreen_msg-> setAutoResize(true); 677 fullscreen_msg-> setAutoResize(true);
680 fullscreen_msg-> setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 678 fullscreen_msg-> setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
681 fullscreen_msg-> setText(tr("To exit fullscreen, tap here.")); 679 fullscreen_msg-> setText(tr("To exit fullscreen, tap here."));
682 680
683 fullscreen_timer = new QTimer(this); 681 fullscreen_timer = new QTimer(this);
684 connect(fullscreen_timer, SIGNAL(timeout()), 682 connect(fullscreen_timer, SIGNAL(timeout()),
685 this, SLOT(fullscreenTimeout())); 683 this, SLOT(fullscreenTimeout()));
686 show_fullscreen_msg = true; 684 show_fullscreen_msg = true;
687 685
688 //scrollMenuSelected(-29); 686 //scrollMenuSelected(-29);
689 // cfg.setGroup("ScrollBar"); 687 // cfg.setGroup("ScrollBar");
690 // if(cfg.readBoolEntry("HorzScroll",0)) { 688 // if(cfg.readBoolEntry("HorzScroll",0)) {
691 // if(cfg.readNumEntry("Position",2) == 0) 689 // if(cfg.readNumEntry("Position",2) == 0)
692 // te->setScrollbarLocation(1); 690 // te->setScrollbarLocation(1);
693 // else 691 // else
694 // te->setScrollbarLocation(0); 692 // te->setScrollbarLocation(0);
695 // te->setScrollbarLocation( cfg.readNumEntry("Position",2)); 693 // te->setScrollbarLocation( cfg.readNumEntry("Position",2));
696 // te->setWrapAt(120); 694 // te->setWrapAt(120);
697 // } 695 // }
698 // create applications ///////////////////////////////////////////////////// 696 // create applications /////////////////////////////////////////////////////
699 setCentralWidget(tab); 697 setCentralWidget(tab);
700 698
701 // load keymaps //////////////////////////////////////////////////////////// 699 // load keymaps ////////////////////////////////////////////////////////////
702 KeyTrans::loadAll(); 700 KeyTrans::loadAll();
703 for (int i = 0; i < KeyTrans::count(); i++) 701 for (int i = 0; i < KeyTrans::count(); i++)
704 { 702 {
705 KeyTrans* s = KeyTrans::find(i); 703 KeyTrans* s = KeyTrans::find(i);
706 assert( s ); 704 assert( s );
707 } 705 }
708 706
709 se_pgm = _pgm; 707 se_pgm = _pgm;
710 se_args = _args; 708 se_args = _args;
711 709
712 cfg.setGroup("CommandLine"); 710 cfg.setGroup("CommandLine");
713 711
714 if (cfg.hasKey("shell_args")) 712 if (cfg.hasKey("shell_args"))
715 { 713 {
716 QStringList se_args_list = cfg.readListEntry("shell_args",'|'); 714 QStringList se_args_list = cfg.readListEntry("shell_args",'|');
717 for(uint i = 0; i < se_args_list.count(); i++) 715 for(uint i = 0; i < se_args_list.count(); i++)
718 { 716 {
719 se_args.prepend(se_args_list[se_args_list.count() - i - 1].latin1()); 717 se_args.prepend(se_args_list[se_args_list.count() - i - 1].latin1());
720 } 718 }
721 } 719 }
722 else 720 else
723 { 721 {
724 se_args.prepend("--login"); 722 se_args.prepend("--login");
725 } 723 }
726 724
727 se_pgm = cfg.readEntry("shell_bin", QString(se_pgm)); 725 se_pgm = cfg.readEntry("shell_bin", QString(se_pgm));
728 726
729 // this is the "documentation" for those who know to look 727 // this is the "documentation" for those who know to look
730 if (! cfg.hasKey("shell_args")) 728 if (! cfg.hasKey("shell_args"))
731 { 729 {
732 cfg.writeEntry("shell_args",QStringList::fromStrList(se_args),'|'); 730 cfg.writeEntry("shell_args",QStringList::fromStrList(se_args),'|');
733 } 731 }
734 if (! cfg.hasKey("shell_bin")) 732 if (! cfg.hasKey("shell_bin"))
735 { 733 {
736 cfg.writeEntry("shell_bin",QString(se_pgm)); 734 cfg.writeEntry("shell_bin",QString(se_pgm));
737 } 735 }
738 736
739 parseCommandLine(); 737 parseCommandLine();
740 738
741 // read and apply default values /////////////////////////////////////////// 739 // read and apply default values ///////////////////////////////////////////
742 resize(321, 321); // Dummy. 740 resize(321, 321); // Dummy.
743 QSize currentSize = size(); 741 QSize currentSize = size();
744 if (currentSize != size()) 742 if (currentSize != size())
745 defaultSize = size(); 743 defaultSize = size();
746 744
747 745
748 /* allows us to catch cancel/escape */ 746 /* allows us to catch cancel/escape */
749 reparent ( 0, WStyle_Customize | WStyle_NoBorder, 747 reparent ( 0, WStyle_Customize | WStyle_NoBorder,
750 QPoint ( 0, 0 )); 748 QPoint ( 0, 0 ));
751} 749}
752 750
753void Konsole::show() 751void Konsole::show()
754{ 752{
755 if ( !nsessions ) 753 if ( !nsessions )
756 { 754 {
757 newSession(); 755 newSession();
758 } 756 }
759 QMainWindow::show(); 757 QMainWindow::show();
760 758
761} 759}
762 760
763void Konsole::initSession(const char*, QStrList &) 761void Konsole::initSession(const char*, QStrList &)
764{ 762{
765 QMainWindow::show(); 763 QMainWindow::show();
766} 764}
767 765
768Konsole::~Konsole() 766Konsole::~Konsole()
769{ 767{
770 while (nsessions > 0) 768 while (nsessions > 0)
771 { 769 {
772 doneSession(getTe(), 0); 770 doneSession(getTe(), 0);
773 } 771 }
774} 772}
775 773
776void 774void
777Konsole::historyDialog() 775Konsole::historyDialog()
778{ 776{
779 QDialog *d = new QDialog ( this, "histdlg", true ); 777 QDialog *d = new QDialog ( this, "histdlg", true );
780 // d-> setCaption ( tr( "History" )); 778 // d-> setCaption ( tr( "History" ));
781 779
782 QBoxLayout *lay = new QVBoxLayout ( d, 4, 4 ); 780 QBoxLayout *lay = new QVBoxLayout ( d, 4, 4 );
783 781
784 QLabel *l = new QLabel ( tr( "History Lines:" ), d ); 782 QLabel *l = new QLabel ( tr( "History Lines:" ), d );
785 lay-> addWidget ( l ); 783 lay-> addWidget ( l );
786 784
787 Config cfg( "Konsole" ); 785 Config cfg( "Konsole" );
788 cfg.setGroup("History"); 786 cfg.setGroup("History");
789 int hist = cfg.readNumEntry("history_lines",300); 787 int hist = cfg.readNumEntry("history_lines",300);
790 int avg_line = cfg.readNumEntry("avg_line_length",60); 788 int avg_line = cfg.readNumEntry("avg_line_length",60);
791 789
792 QSpinBox *spin = new QSpinBox ( 1, 100000, 20, d ); 790 QSpinBox *spin = new QSpinBox ( 1, 100000, 20, d );
793 spin-> setValue ( hist ); 791 spin-> setValue ( hist );
794 spin-> setWrapping ( true ); 792 spin-> setWrapping ( true );
795 spin-> setButtonSymbols ( QSpinBox::PlusMinus ); 793 spin-> setButtonSymbols ( QSpinBox::PlusMinus );
796 lay-> addWidget ( spin ); 794 lay-> addWidget ( spin );
797 795
798 if ( d-> exec ( ) == QDialog::Accepted ) 796 if ( d-> exec ( ) == QDialog::Accepted )
799 { 797 {
800 cfg.writeEntry("history_lines", spin->value()); 798 cfg.writeEntry("history_lines", spin->value());
801 cfg.writeEntry("avg_line_length", avg_line); 799 cfg.writeEntry("avg_line_length", avg_line);
802 if (getTe() != NULL) 800 if (getTe() != NULL)
803 { 801 {
804 getTe()->currentSession->setHistory(true); 802 getTe()->currentSession->setHistory(true);
805 } 803 }
806 } 804 }
807 805
808 delete d; 806 delete d;
809} 807}
810 808
811 809
812void Konsole::cycleZoom() 810void Konsole::cycleZoom()
813{ 811{
814 TEWidget* te = getTe(); 812 TEWidget* te = getTe();
815 QFont font = te->getVTFont(); 813 QFont font = te->getVTFont();
816 int size = font.pointSize(); 814 int size = font.pointSize();
817 changeFontSize(1); 815 changeFontSize(1);
818 font = te->getVTFont(); 816 font = te->getVTFont();
819 if (font.pointSize() <= size) 817 if (font.pointSize() <= size)
820 { 818 {
821 do 819 do
822 { 820 {
823 font = te->getVTFont(); 821 font = te->getVTFont();
824 size = font.pointSize(); 822 size = font.pointSize();
825 changeFontSize(-1); 823 changeFontSize(-1);
826 font = te->getVTFont(); 824 font = te->getVTFont();
827 } 825 }
828 while (font.pointSize() < size); 826 while (font.pointSize() < size);
829 } 827 }
830} 828}
831 829
832void Konsole::changeFontSize(int delta) 830void Konsole::changeFontSize(int delta)
833{ 831{
834 // printf("delta font size %d\n", delta); 832 // printf("delta font size %d\n", delta);
835 TEWidget* te = getTe(); 833 TEWidget* te = getTe();
836 QFont font = te->getVTFont(); 834 QFont font = te->getVTFont();
837 int size = font.pointSize(); 835 int size = font.pointSize();
838 int closest = delta > 0? 10000 : -10000; 836 int closest = delta > 0? 10000 : -10000;
839 int closest_font = -1; 837 int closest_font = -1;
840 for(uint i = 0; i < fonts.count(); i++) 838 for(uint i = 0; i < fonts.count(); i++)
841 { 839 {
842 if (fonts.at(i)->getFont() == font) 840 if (fonts.at(i)->getFont() == font)
843 { 841 {
844 if (delta > 0) 842 if (delta > 0)
845 { 843 {
846 if (i+1 < fonts.count() 844 if (i+1 < fonts.count()
847 && fonts.at(i+1)->getFamilyNum() == fonts.at(i)->getFamilyNum()) 845 && fonts.at(i+1)->getFamilyNum() == fonts.at(i)->getFamilyNum())
848 { 846 {
849 setFont(i+1); 847 setFont(i+1);
850 printf("font %d\n", i+1); 848 printf("font %d\n", i+1);
851 return; 849 return;
852 } 850 }
853 } 851 }
854 else if (delta < 0) 852 else if (delta < 0)
855 { 853 {
856 if (i > 0 854 if (i > 0
857 && fonts.at(i-1)->getFamilyNum() == fonts.at(i)->getFamilyNum()) 855 && fonts.at(i-1)->getFamilyNum() == fonts.at(i)->getFamilyNum())
858 { 856 {
859 setFont(i-1); 857 setFont(i-1);
860 printf("font %d\n", i-1); 858 printf("font %d\n", i-1);
861 return; 859 return;
862 } 860 }
863 } 861 }
864 } 862 }
865 int fsize = fonts.at(i)->getSize(); 863 int fsize = fonts.at(i)->getSize();
866 printf("%d size=%d fsize=%d closest=%d\n", i, size, fsize, closest); 864 printf("%d size=%d fsize=%d closest=%d\n", i, size, fsize, closest);
867 if ((delta > 0 && fsize > size && fsize < closest) 865 if ((delta > 0 && fsize > size && fsize < closest)
868 || (delta < 0 && fsize < size && fsize > closest)) 866 || (delta < 0 && fsize < size && fsize > closest))
869 { 867 {
870 closest = fsize; 868 closest = fsize;
871 closest_font = i; 869 closest_font = i;
872 } 870 }
873 } 871 }
874 if (closest_font >= 0) 872 if (closest_font >= 0)
875 { 873 {
876 printf("font closest %d (%d)\n", closest_font, closest); 874 printf("font closest %d (%d)\n", closest_font, closest);
877 setFont(closest_font); 875 setFont(closest_font);
878 } 876 }
879} 877}
880 878
881int Konsole::findFont(const QString& name, int size, bool exactMatch) 879int Konsole::findFont(const QString& name, int size, bool exactMatch)
882{ 880{
883 for(uint i = 0; i < fonts.count(); i++) 881 for(uint i = 0; i < fonts.count(); i++)
884 { 882 {
885 if (fonts.at(i)->getName() == name 883 if (fonts.at(i)->getName() == name
886 && fonts.at(i)->getSize() == size) 884 && fonts.at(i)->getSize() == size)
887 { 885 {
888 return(i); 886 return(i);
889 } 887 }
890 } 888 }
891 if (exactMatch) 889 if (exactMatch)
892 { 890 {
893 return(-1); 891 return(-1);
894 } 892 }
895 for(uint i = 0; i < fonts.count(); i++) 893 for(uint i = 0; i < fonts.count(); i++)
896 { 894 {
897 if (fonts.at(i)->getSize() == size) 895 if (fonts.at(i)->getSize() == size)
898 { 896 {
899 return(i); 897 return(i);
900 } 898 }
901 } 899 }
902 return(-1); 900 return(-1);
903} 901}
904 902
905void Konsole::setFont(int f) 903void Konsole::setFont(int f)
906{ 904{
907 VTFont* font = fonts.at(f); 905 VTFont* font = fonts.at(f);
908 if (font) 906 if (font)
909 { 907 {
910 TEWidget* te = getTe(); 908 TEWidget* te = getTe();
911 if (te != 0) 909 if (te != 0)
912 { 910 {
913 te->setVTFont(font->getFont()); 911 te->setVTFont(font->getFont());
914 } 912 }
915 cfont = f; 913 cfont = f;
916 914
917 int familyNum = font->getFamilyNum(); 915 int familyNum = font->getFamilyNum();
918 int size = font->getSize(); 916 int size = font->getSize();
919 printf("familyNum = %d size = %d count=%d\n", familyNum, size, 917 printf("familyNum = %d size = %d count=%d\n", familyNum, size,
920 fontList->count()); 918 fontList->count());
921 for(int i = 0; i < (int)fontList->count(); i++) 919 for(int i = 0; i < (int)fontList->count(); i++)
922 { 920 {
923 fontList->setItemChecked(i + 1000, i == familyNum); 921 fontList->setItemChecked(i + 1000, i == familyNum);
924 } 922 }
925 for(int i = 0; i < (int)fonts.count(); i++) 923 for(int i = 0; i < (int)fonts.count(); i++)
926 { 924 {
927 fontList->setItemChecked(i, fonts.at(i)->getFamilyNum() == familyNum 925 fontList->setItemChecked(i, fonts.at(i)->getFamilyNum() == familyNum
928 && fonts.at(i)->getSize() == size); 926 && fonts.at(i)->getSize() == size);
929 } 927 }
930 Config cfg( "Konsole" ); 928 Config cfg( "Konsole" );
931 cfg.setGroup("Font"); 929 cfg.setGroup("Font");
932 QString ss = "Session"+ QString::number(tab->currentPageIndex()+1); 930 QString ss = "Session"+ QString::number(tab->currentPageIndex()+1);
933 if (tab->currentPageIndex() == 0) 931 if (tab->currentPageIndex() == 0)
934 { 932 {
935 cfg.writeEntry("FontName", fonts.at(cfont)->getFamily()); 933 cfg.writeEntry("FontName", fonts.at(cfont)->getFamily());
936 cfg.writeEntry("FontSize", fonts.at(cfont)->getSize()); 934 cfg.writeEntry("FontSize", fonts.at(cfont)->getSize());
937 } 935 }
938 cfg.writeEntry("FontName"+ss, fonts.at(cfont)->getFamily()); 936 cfg.writeEntry("FontName"+ss, fonts.at(cfont)->getFamily());
939 cfg.writeEntry("FontSize"+ss, fonts.at(cfont)->getSize()); 937 cfg.writeEntry("FontSize"+ss, fonts.at(cfont)->getSize());
940 } 938 }
941} 939}
942 940
943#if 0 941#if 0
944void Konsole::fontChanged(int f) 942void Konsole::fontChanged(int f)
945{ 943{
946 VTFont* font = fonts.at(f); 944 VTFont* font = fonts.at(f);
947 if (font != 0) 945 if (font != 0)
948 { 946 {
949 for(uint i = 0; i < fonts.count(); i++) 947 for(uint i = 0; i < fonts.count(); i++)
950 { 948 {
951 fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE); 949 fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE);
952 } 950 }
953 951
954 cfont = f; 952 cfont = f;
955 953
956 TEWidget* te = getTe(); 954 TEWidget* te = getTe();
957 if (te != 0) 955 if (te != 0)
958 { 956 {
959 te->setVTFont(font->getFont()); 957 te->setVTFont(font->getFont());
960 } 958 }
961 } 959 }
962} 960}
963#endif 961#endif
964 962
965 963
966void Konsole::enterCommand(int c) 964void Konsole::enterCommand(int c)
967{ 965{
968 TEWidget* te = getTe(); 966 TEWidget* te = getTe();
969 if (te != 0) 967 if (te != 0)
970 { 968 {
971 if(!commonCombo->editable()) 969 if(!commonCombo->editable())
972 { 970 {
973 QString text = commonCombo->text(c); //commonCmds[c]; 971 QString text = commonCombo->text(c); //commonCmds[c];
974 te->emitText(text); 972 te->emitText(text);
975 } 973 }
976 else 974 else
977 { 975 {
978 changeCommand( commonCombo->text(c), c); 976 changeCommand( commonCombo->text(c), c);
979 } 977 }
980 } 978 }
981} 979}
982 980
983void Konsole::hitEnter() 981void Konsole::hitEnter()
984{ 982{
985 TEWidget* te = getTe(); 983 TEWidget* te = getTe();
986 if (te != 0) 984 if (te != 0)
987 { 985 {
988 te->emitText(QString("\r")); 986 te->emitText(QString("\r"));
989 } 987 }
990} 988}
991 989
992void Konsole::hitSpace() 990void Konsole::hitSpace()
993{ 991{
994 TEWidget* te = getTe(); 992 TEWidget* te = getTe();
995 if (te != 0) 993 if (te != 0)
996 { 994 {
997 te->emitText(QString(" ")); 995 te->emitText(QString(" "));
998 } 996 }
999} 997}
1000 998
1001void Konsole::hitTab() 999void Konsole::hitTab()
1002{ 1000{
1003 TEWidget* te = getTe(); 1001 TEWidget* te = getTe();
1004 if (te != 0) 1002 if (te != 0)
1005 { 1003 {
1006 te->emitText(QString("\t")); 1004 te->emitText(QString("\t"));
1007 } 1005 }
1008} 1006}
1009 1007
1010void Konsole::hitPaste() 1008void Konsole::hitPaste()
1011{ 1009{
1012 TEWidget* te = getTe(); 1010 TEWidget* te = getTe();
1013 if (te != 0) 1011 if (te != 0)
1014 { 1012 {
1015 te->pasteClipboard(); 1013 te->pasteClipboard();
1016 } 1014 }
1017} 1015}
1018 1016
1019void Konsole::hitUp() 1017void Konsole::hitUp()
1020{ 1018{
1021 TEWidget* te = getTe(); 1019 TEWidget* te = getTe();
1022 if (te != 0) 1020 if (te != 0)
1023 { 1021 {
1024 QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Up, 0, 0); 1022 QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Up, 0, 0);
1025 QApplication::sendEvent( te, &ke ); 1023 QApplication::sendEvent( te, &ke );
1026 } 1024 }
1027} 1025}
1028 1026
1029void Konsole::hitDown() 1027void Konsole::hitDown()
1030{ 1028{
1031 TEWidget* te = getTe(); 1029 TEWidget* te = getTe();
1032 if (te != 0) 1030 if (te != 0)
1033 { 1031 {
1034 QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Down, 0, 0); 1032 QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Down, 0, 0);
1035 QApplication::sendEvent( te, &ke ); 1033 QApplication::sendEvent( te, &ke );
1036 } 1034 }
1037} 1035}
1038 1036
1039/** 1037/**
1040 This function calculates the size of the external widget 1038 This function calculates the size of the external widget
1041 needed for the internal widget to be 1039 needed for the internal widget to be
1042 */ 1040 */
1043QSize Konsole::calcSize(int columns, int lines) 1041QSize Konsole::calcSize(int columns, int lines)
1044{ 1042{
1045 TEWidget* te = getTe(); 1043 TEWidget* te = getTe();
1046 if (te != 0) 1044 if (te != 0)
1047 { 1045 {
1048 QSize size = te->calcSize(columns, lines); 1046 QSize size = te->calcSize(columns, lines);
1049 return size; 1047 return size;
1050 } 1048 }
1051 else 1049 else
1052 { 1050 {
1053 QSize size; 1051 QSize size;
1054 return size; 1052 return size;
1055 } 1053 }
1056} 1054}
1057 1055
1058/** 1056/**
1059 sets application window to a size based on columns X lines of the te 1057 sets application window to a size based on columns X lines of the te
1060 guest widget. Call with (0,0) for setting default size. 1058 guest widget. Call with (0,0) for setting default size.
1061*/ 1059*/
1062 1060
1063void Konsole::setColLin(int columns, int lines) 1061void Konsole::setColLin(int columns, int lines)
1064{ 1062{
1065 qDebug("konsole::setColLin:: Columns %d", columns); 1063 qDebug("konsole::setColLin:: Columns %d", columns);
1066 1064
1067 if ((columns==0) || (lines==0)) 1065 if ((columns==0) || (lines==0))
1068 { 1066 {
1069 if (defaultSize.isEmpty()) // not in config file : set default value 1067 if (defaultSize.isEmpty()) // not in config file : set default value
1070 { 1068 {
1071 defaultSize = calcSize(80,24); 1069 defaultSize = calcSize(80,24);
1072 // notifySize(24,80); // set menu items (strange arg order !) 1070 // notifySize(24,80); // set menu items (strange arg order !)
1073 } 1071 }
1074 resize(defaultSize); 1072 resize(defaultSize);
1075 } 1073 }
1076 else 1074 else
1077 { 1075 {
1078 resize(calcSize(columns, lines)); 1076 resize(calcSize(columns, lines));
1079 // notifySize(lines,columns); // set menu items (strange arg order !) 1077 // notifySize(lines,columns); // set menu items (strange arg order !)
1080 } 1078 }
1081} 1079}
1082 1080
1083/* 1081/*
1084void Konsole::setFont(int fontno) 1082void Konsole::setFont(int fontno)
1085{ 1083{
1086 QFont f; 1084 QFont f;
1087 if (fontno == 0) 1085 if (fontno == 0)
1088 f = defaultFont = QFont( "Helvetica", 12 ); 1086 f = defaultFont = QFont( "Helvetica", 12 );
1089 else 1087 else
1090 if (fonts[fontno][0] == '-') 1088 if (fonts[fontno][0] == '-')
1091 f.setRawName( fonts[fontno] ); 1089 f.setRawName( fonts[fontno] );
1092 else 1090 else
1093 { 1091 {
1094 f.setFamily(fonts[fontno]); 1092 f.setFamily(fonts[fontno]);
1095 f.setRawMode( TRUE ); 1093 f.setRawMode( TRUE );
1096 } 1094 }
1097 if ( !f.exactMatch() && fontno != 0) 1095 if ( !f.exactMatch() && fontno != 0)
1098 { 1096 {
1099 QString msg = i18n("Font `%1' not found.\nCheck README.linux.console for help.").arg(fonts[fontno]); 1097 QString msg = i18n("Font `%1' not found.\nCheck README.linux.console for help.").arg(fonts[fontno]);
1100 QMessageBox(this, msg); 1098 QMessageBox(this, msg);
1101 return; 1099 return;
1102 } 1100 }
1103 if (se) se->setFontNo(fontno); 1101 if (se) se->setFontNo(fontno);
1104 te->setVTFont(f); 1102 te->setVTFont(f);
1105 n_font = fontno; 1103 n_font = fontno;
1106} 1104}
1107*/ 1105*/
1108 1106
1109// --| color selection |------------------------------------------------------- 1107// --| color selection |-------------------------------------------------------
1110 1108
1111void Konsole::changeColumns(int /*columns*/) 1109void Konsole::changeColumns(int /*columns*/)
1112{ //FIXME this seems to cause silliness when reset command is executed 1110{ //FIXME this seems to cause silliness when reset command is executed
1113 // qDebug("change columns"); 1111 // qDebug("change columns");
1114 // TEWidget* te = getTe(); 1112 // TEWidget* te = getTe();
1115 // if (te != 0) { 1113 // if (te != 0) {
1116 // setColLin(columns,te->Lines()); 1114 // setColLin(columns,te->Lines());
1117 // te->update(); 1115 // te->update();
1118 // } 1116 // }
1119} 1117}
1120 1118
1121//FIXME: If a child dies during session swap, 1119//FIXME: If a child dies during session swap,
1122// this routine might be called before 1120// this routine might be called before
1123// session swap is completed. 1121// session swap is completed.
1124 1122
1125void Konsole::doneSession(TEWidget* te, int ) 1123void Konsole::doneSession(TEWidget* te, int )
1126{ 1124{
1127 // TEWidget *te = NULL; 1125 // TEWidget *te = NULL;
1128 // if (sess->currentSession == tab->currentPage()) { 1126 // if (sess->currentSession == tab->currentPage()) {
1129 // printf("done current session\n"); 1127 // printf("done current session\n");
1130 // te = getTe(); 1128 // te = getTe();
1131 // } else { 1129 // } else {
1132 // int currentPage = tab->currentPageIndex(); 1130 // int currentPage = tab->currentPageIndex();
1133 // printf("done not current session\n"); 1131 // printf("done not current session\n");
1134 // for(int i = 0; i < nsessions; i++) { 1132 // for(int i = 0; i < nsessions; i++) {
1135 // tab->setCurrentPage(i); 1133 // tab->setCurrentPage(i);
1136 // printf("find session %d tab page %x session %x\n", 1134 // printf("find session %d tab page %x session %x\n",
1137 // i, tab->currentPage(), sess->currentSession); 1135 // i, tab->currentPage(), sess->currentSession);
1138 // if (tab->currentPage() == sess->currentSession) { 1136 // if (tab->currentPage() == sess->currentSession) {
1139 // printf("found session %d\n", i); 1137 // printf("found session %d\n", i);
1140 // te = tab->currentPage(); 1138 // te = tab->currentPage();
1141 // break; 1139 // break;
1142 // } 1140 // }
1143 // } 1141 // }
1144 // tab->setCurrentPage(currentPage); 1142 // tab->setCurrentPage(currentPage);
1145 // } 1143 // }
1146 if (te != 0) 1144 if (te != 0)
1147 { 1145 {
1148 te->currentSession->setConnect(FALSE); 1146 te->currentSession->setConnect(FALSE);
1149 tab->removeTab(te); 1147 tab->removeTab(te);
1150 delete te->currentSession; 1148 delete te->currentSession;
1151 delete te; 1149 delete te;
1152 sessionList->removeItem(nsessions); 1150 sessionList->removeItem(nsessions);
1153 nsessions--; 1151 nsessions--;
1154 } 1152 }
1155 if (nsessions == 0) 1153 if (nsessions == 0)
1156 { 1154 {
1157 close(); 1155 close();
1158 } 1156 }
1159} 1157}
1160 1158
1161void Konsole::changeTitle(TEWidget* te, const QString& newTitle ) 1159void Konsole::changeTitle(TEWidget* te, const QString& newTitle )
1162{ 1160{
1163 if (te == getTe()) 1161 if (te == getTe())
1164 { 1162 {
1165 setCaption( newTitle + " - " + tr( "Konsole " ) ); 1163 setCaption( newTitle + " - " + tr( "Konsole " ) );
1166 } 1164 }
1167} 1165}
1168 1166
1169 1167
1170void Konsole::newSession() 1168void Konsole::newSession()
1171{ 1169{
1172 if(nsessions < 15) 1170 if(nsessions < 15)
1173 { // seems to be something weird about 16 tabs on the Zaurus.... memory? 1171 { // seems to be something weird about 16 tabs on the Zaurus.... memory?
1174 TEWidget* te = new TEWidget(tab); 1172 TEWidget* te = new TEWidget(tab);
1175 Config cfg( "Konsole" ); 1173 Config cfg( "Konsole" );
1176 cfg.setGroup("Menubar"); 1174 cfg.setGroup("Menubar");
1177 1175
1178 // FIXME use more defaults from config file 1176 // FIXME use more defaults from config file
1179 te->useBeep=cfg.readBoolEntry("useBeep",0); 1177 te->useBeep=cfg.readBoolEntry("useBeep",0);
1180 1178
1181 // te->setBackgroundMode(PaletteBase); //we want transparent!! 1179 // te->setBackgroundMode(PaletteBase); //we want transparent!!
1182 1180
1183 cfg.setGroup("Font"); 1181 cfg.setGroup("Font");
1184 QString sn = "Session" + QString::number(nsessions+1); 1182 QString sn = "Session" + QString::number(nsessions+1);
1185 printf("read font session %s\n", sn.latin1()); 1183 printf("read font session %s\n", sn.latin1());
1186 QString fontName = cfg.readEntry("FontName"+sn, 1184 QString fontName = cfg.readEntry("FontName"+sn,
1187 cfg.readEntry("FontName", 1185 cfg.readEntry("FontName",
1188 fonts.at(cfont)->getFamily())); 1186 fonts.at(cfont)->getFamily()));
1189 int fontSize = cfg.readNumEntry("FontSize"+sn, 1187 int fontSize = cfg.readNumEntry("FontSize"+sn,
1190 cfg.readNumEntry("FontSize", 1188 cfg.readNumEntry("FontSize",
1191 fonts.at(cfont)->getSize())); 1189 fonts.at(cfont)->getSize()));
1192 cfont = findFont(fontName, fontSize, false); 1190 cfont = findFont(fontName, fontSize, false);
1193 printf("lookup font %s size %d got %d\n", fontName.latin1(), fontSize, cfont); 1191 printf("lookup font %s size %d got %d\n", fontName.latin1(), fontSize, cfont);
1194 if (cfont < 0) 1192 if (cfont < 0)
1195 cfont = 0; 1193 cfont = 0;
1196 te->setVTFont(fonts.at(cfont)->getFont()); 1194 te->setVTFont(fonts.at(cfont)->getFont());
1197 1195
1198 tab->addTab(te); 1196 tab->addTab(te);
1199 TESession* se = new TESession(this, te, se_pgm, se_args, "xterm"); 1197 TESession* se = new TESession(this, te, se_pgm, se_args, "xterm");
1200 te->currentSession = se; 1198 te->currentSession = se;
1201 connect( se, SIGNAL(done(TEWidget*,int)), this, SLOT(doneSession(TEWidget*,int)) ); 1199 connect( se, SIGNAL(done(TEWidget*,int)), this, SLOT(doneSession(TEWidget*,int)) );
1202 connect( se, SIGNAL(changeTitle(TEWidget*,const QString&)), this, 1200 connect( se, SIGNAL(changeTitle(TEWidget*,const QString&)), this,
1203 SLOT(changeTitle(TEWidget*,const QString&)) ); 1201 SLOT(changeTitle(TEWidget*,const QString&)) );
1204 connect(te, SIGNAL(changeFontSize(int)), this, SLOT(changeFontSize(int))); 1202 connect(te, SIGNAL(changeFontSize(int)), this, SLOT(changeFontSize(int)));
1205 connect(te, SIGNAL(changeSession(int)), this, SLOT(changeSession(int))); 1203 connect(te, SIGNAL(changeSession(int)), this, SLOT(changeSession(int)));
1206 connect(te, SIGNAL(newSession()), this, SLOT(newSession())); 1204 connect(te, SIGNAL(newSession()), this, SLOT(newSession()));
1207 connect(te, SIGNAL(toggleFullScreen()), this, SLOT(toggleFullScreen())); 1205 connect(te, SIGNAL(toggleFullScreen()), this, SLOT(toggleFullScreen()));
1208 connect(te, SIGNAL(setFullScreen(bool)), this, SLOT(setFullScreen(bool))); 1206 connect(te, SIGNAL(setFullScreen(bool)), this, SLOT(setFullScreen(bool)));
1209 se->run(); 1207 se->run();
1210 se->setConnect(TRUE); 1208 se->setConnect(TRUE);
1211 se->setHistory(b_scroll); 1209 se->setHistory(b_scroll);
1212 nsessions++; 1210 nsessions++;
1213 sessionList->insertItem(QString::number(nsessions), nsessions); 1211 sessionList->insertItem(QString::number(nsessions), nsessions);
1214 sessionListSelected(nsessions); 1212 sessionListSelected(nsessions);
1215 doWrap(); 1213 doWrap();
1216 setColor(nsessions-1); 1214 setColor(nsessions-1);
1217 } 1215 }
1218} 1216}
1219 1217
1220TEWidget* Konsole::getTe() 1218TEWidget* Konsole::getTe()
1221{ 1219{
1222 if (nsessions) 1220 if (nsessions)
1223 { 1221 {
1224 return (TEWidget *) tab->currentPage(); 1222 return (TEWidget *) tab->currentPage();
1225 } 1223 }
1226 else 1224 else
1227 { 1225 {
1228 return 0; 1226 return 0;
1229 } 1227 }
1230} 1228}
1231 1229
1232void Konsole::sessionListSelected(int id) 1230void Konsole::sessionListSelected(int id)
1233{ 1231{
1234 if (id < 0) 1232 if (id < 0)
1235 { 1233 {
1236 return; 1234 return;
1237 } 1235 }
1238 QString selected = sessionList->text(id); 1236 QString selected = sessionList->text(id);
1239 EKNumTabBar *tabBar = tab->getTabBar(); 1237 EKNumTabBar *tabBar = tab->getTabBar();
1240 1238
1241 int n = 0; 1239 int n = 0;
1242 for(int i = 0; n < tabBar->count(); i++) 1240 for(int i = 0; n < tabBar->count(); i++)
1243 { 1241 {
1244 if (tabBar->tab(i)) 1242 if (tabBar->tab(i))
1245 { 1243 {
1246 // printf("selected = %s tab %d = %s\n", selected.latin1(), 1244 // printf("selected = %s tab %d = %s\n", selected.latin1(),
1247 // i, tabBar->tab(i)->text().latin1()); 1245 // i, tabBar->tab(i)->text().latin1());
1248 if (tabBar->tab(i)->text() == selected) 1246 if (tabBar->tab(i)->text() == selected)
1249 { 1247 {
1250 tab->setCurrentPage(i); 1248 tab->setCurrentPage(i);
1251 break; 1249 break;
1252 } 1250 }
1253 n++; 1251 n++;
1254 } 1252 }
1255 } 1253 }
1256} 1254}
1257 1255
1258 1256
1259void Konsole::changeSession(int delta) 1257void Konsole::changeSession(int delta)
1260{ 1258{
1261 printf("delta session %d\n", delta); 1259 printf("delta session %d\n", delta);
1262 QTabBar *tabBar = tab->getTabBar(); 1260 QTabBar *tabBar = tab->getTabBar();
1263 int i = tabBar->tab(tabBar->currentTab())->text().toInt() - 1; 1261 int i = tabBar->tab(tabBar->currentTab())->text().toInt() - 1;
1264 i += delta; 1262 i += delta;
1265 if (i < 0) 1263 if (i < 0)
1266 i += tabBar->count(); 1264 i += tabBar->count();
1267 if (i >= tabBar->count()) 1265 if (i >= tabBar->count())
1268 i -= tabBar->count(); 1266 i -= tabBar->count();
1269 1267
1270 QString selected = QString::number(i+1); 1268 QString selected = QString::number(i+1);
1271 int n = 0; 1269 int n = 0;
1272 for(int i = 0; n < tabBar->count(); i++) 1270 for(int i = 0; n < tabBar->count(); i++)
1273 { 1271 {
1274 if (tabBar->tab(i)) 1272 if (tabBar->tab(i))
1275 { 1273 {
1276 printf("selected = %s tab %d = %s\n", selected.latin1(), 1274 printf("selected = %s tab %d = %s\n", selected.latin1(),
1277 i, tabBar->tab(i)->text().latin1()); 1275 i, tabBar->tab(i)->text().latin1());
1278 if (tabBar->tab(i)->text() == selected) 1276 if (tabBar->tab(i)->text() == selected)
1279 { 1277 {
1280 tab->setCurrentPage(i); 1278 tab->setCurrentPage(i);
1281 break; 1279 break;
1282 } 1280 }
1283 n++; 1281 n++;
1284 } 1282 }
1285 } 1283 }
1286} 1284}
1287 1285
1288void Konsole::switchSession(QWidget* w) 1286void Konsole::switchSession(QWidget* w)
1289{ 1287{
1290 TEWidget* te = (TEWidget *) w; 1288 TEWidget* te = (TEWidget *) w;
1291 QFont teFnt = te->getVTFont(); 1289 QFont teFnt = te->getVTFont();
1292 int familyNum = -1; 1290 int familyNum = -1;
1293 1291
1294 for(uint i = 0; i < fonts.count(); i++) 1292 for(uint i = 0; i < fonts.count(); i++)
1295 { 1293 {
1296 VTFont *fnt = fonts.at(i); 1294 VTFont *fnt = fonts.at(i);
1297 bool cf = fnt->getFont() == teFnt; 1295 bool cf = fnt->getFont() == teFnt;
1298 fontList->setItemChecked(i, cf); 1296 fontList->setItemChecked(i, cf);
1299 if (cf) 1297 if (cf)
1300 { 1298 {
1301 cfont = i; 1299 cfont = i;
1302 familyNum = fnt->getFamilyNum(); 1300 familyNum = fnt->getFamilyNum();
1303 } 1301 }
1304 } 1302 }
1305 for(int i = 0; i < (int)fontList->count(); i++) 1303 for(int i = 0; i < (int)fontList->count(); i++)
1306 { 1304 {
1307 fontList->setItemChecked(i + 1000, i == familyNum); 1305 fontList->setItemChecked(i + 1000, i == familyNum);
1308 } 1306 }
1309 if (! te->currentSession->Title().isEmpty() ) 1307 if (! te->currentSession->Title().isEmpty() )
1310 { 1308 {
1311 setCaption( te->currentSession->Title() + " - " + tr( "Konsole" ) ); 1309 setCaption( te->currentSession->Title() + " - " + tr( "Konsole" ) );
1312 } 1310 }
1313 else 1311 else
1314 { 1312 {
1315 setCaption( tr( "Konsole" ) ); 1313 setCaption( tr( "Konsole" ) );
1316 } 1314 }
1317 // colorMenuSelected(te->color_menu_item); 1315 // colorMenuSelected(te->color_menu_item);
1318} 1316}
1319 1317
1320 1318
1321void Konsole::toggleFullScreen() 1319void Konsole::toggleFullScreen()
1322{ 1320{
1323 setFullScreen(! fullscreen); 1321 setFullScreen(! fullscreen);
1324} 1322}
1325 1323
1326void Konsole::setFullScreen ( bool b ) 1324void Konsole::setFullScreen ( bool b )
1327{ 1325{
1328 static QSize normalsize; 1326 static QSize normalsize;
1329 static bool listHidden; 1327 static bool listHidden;
1330 1328
1331 if (b == fullscreen) 1329 if (b == fullscreen)
1332 { 1330 {
1333 return; 1331 return;
1334 } 1332 }
1335 1333
1336 fullscreen = b; 1334 fullscreen = b;
1337 1335
1338 if ( b ) 1336 if ( b )
1339 { 1337 {
1340 if ( !normalsize. isValid ( )) 1338 if ( !normalsize. isValid ( ))
1341 { 1339 {
1342 normalsize = size ( ); 1340 normalsize = size ( );
1343 } 1341 }
1344 1342
1345 setFixedSize ( qApp-> desktop ( )-> size ( )); 1343 setFixedSize ( qApp-> desktop ( )-> size ( ));
1346 showNormal ( ); 1344 showNormal ( );
1347 reparent ( 0, WStyle_Customize | WStyle_NoBorder, 1345 reparent ( 0, WStyle_Customize | WStyle_NoBorder,
1348 QPoint ( 0, 0 )); 1346 QPoint ( 0, 0 ));
1349 showFullScreen ( ); 1347 showFullScreen ( );
1350 1348
1351 menuToolBar->hide(); 1349 menuToolBar->hide();
1352 toolBar->hide(); 1350 toolBar->hide();
1353 listHidden = secondToolBar->isHidden(); 1351 listHidden = secondToolBar->isHidden();
1354 secondToolBar->hide(); 1352 secondToolBar->hide();
1355 // commonCombo->hide(); 1353 // commonCombo->hide();
1356 tab->getTabBar()->hide(); 1354 tab->getTabBar()->hide();
1357 tab->setMargin(tab->margin()); 1355 tab->setMargin(tab->margin());
1358 1356
1359 if (show_fullscreen_msg) 1357 if (show_fullscreen_msg)
1360 { 1358 {
1361 fullscreen_msg-> move(tab->x() + tab->width()/2 - fullscreen_msg->width()/2, 1359 fullscreen_msg-> move(tab->x() + tab->width()/2 - fullscreen_msg->width()/2,
1362 qApp->desktop()->height()/16 - fullscreen_msg->height()/2); 1360 qApp->desktop()->height()/16 - fullscreen_msg->height()/2);
1363 fullscreen_msg->show(); 1361 fullscreen_msg->show();
1364 fullscreen_timer->start(3000, true); 1362 fullscreen_timer->start(3000, true);
1365 show_fullscreen_msg = false; 1363 show_fullscreen_msg = false;
1366 } 1364 }
1367 } 1365 }
1368 else 1366 else
1369 { 1367 {
1370 showNormal ( ); 1368 showNormal ( );
1371 reparent ( 0, WStyle_Customize, QPoint ( 0, 0 )); 1369 reparent ( 0, WStyle_Customize, QPoint ( 0, 0 ));
1372 resize ( normalsize ); 1370 resize ( normalsize );
1373 showMaximized ( ); 1371 showMaximized ( );
1374 normalsize = QSize ( ); 1372 normalsize = QSize ( );
1375 1373
1376 menuToolBar->show(); 1374 menuToolBar->show();
1377 toolBar->show(); 1375 toolBar->show();
1378 if(! listHidden) 1376 if(! listHidden)
1379 { 1377 {
1380 secondToolBar->show(); 1378 secondToolBar->show();
1381 } 1379 }
1382 // commonCombo->show(); 1380 // commonCombo->show();
1383 menuToolBar->show(); 1381 menuToolBar->show();
1384 if (tabPos != tm_hidden) 1382 if (tabPos != tm_hidden)
1385 { 1383 {
1386 tab->getTabBar()->show(); 1384 tab->getTabBar()->show();
1387 } 1385 }
1388 } 1386 }
1389 tab->setMargin(tab->margin()); // cause setup to run 1387 tab->setMargin(tab->margin()); // cause setup to run
1390} 1388}
1391 1389
1392 1390
1393void Konsole::fullscreenTimeout() 1391void Konsole::fullscreenTimeout()
1394{ 1392{
1395 fullscreen_msg->hide(); 1393 fullscreen_msg->hide();
1396} 1394}
1397 1395
1398void Konsole::colorMenuIsSelected(int iD) 1396void Konsole::colorMenuIsSelected(int iD)
1399{ 1397{
1400 fromMenu = TRUE; 1398 fromMenu = TRUE;
1401 colorMenuSelected(iD); 1399 colorMenuSelected(iD);
1402} 1400}
1403 1401
1404/// ------------------------------- some new stuff by L.J. Potter 1402/// ------------------------------- some new stuff by L.J. Potter
1405 1403
1406 1404
1407void Konsole::colorMenuSelected(int iD) 1405void Konsole::colorMenuSelected(int iD)
1408{ 1406{
1409 // this is NOT pretty, elegant or anything else besides functional 1407 // this is NOT pretty, elegant or anything else besides functional
1410 // QString temp; 1408 // QString temp;
1411 // qDebug( temp.sprintf("colormenu %d", iD)); 1409 // qDebug( temp.sprintf("colormenu %d", iD));
1412 1410
1413 TEWidget* te = getTe(); 1411 TEWidget* te = getTe();
1414 Config cfg( "Konsole" ); 1412 Config cfg( "Konsole" );
1415 cfg.setGroup("Colors"); 1413 cfg.setGroup("Colors");
1416 1414
1417 ColorEntry m_table[TABLE_COLORS]; 1415 ColorEntry m_table[TABLE_COLORS];
1418 const ColorEntry * defaultCt=te->getdefaultColorTable(); 1416 const ColorEntry * defaultCt=te->getdefaultColorTable();
1419 1417
1420 int i; 1418 int i;
1421 1419
1422 // te->color_menu_item = iD; 1420 // te->color_menu_item = iD;
1423 1421
1424 colorMenu->setItemChecked(cm_ab,FALSE); 1422 colorMenu->setItemChecked(cm_ab,FALSE);
1425 colorMenu->setItemChecked(cm_bb,FALSE); 1423 colorMenu->setItemChecked(cm_bb,FALSE);
1426 colorMenu->setItemChecked(cm_wc,FALSE); 1424 colorMenu->setItemChecked(cm_wc,FALSE);
1427 colorMenu->setItemChecked(cm_cw,FALSE); 1425 colorMenu->setItemChecked(cm_cw,FALSE);
1428 colorMenu->setItemChecked(cm_mb,FALSE); 1426 colorMenu->setItemChecked(cm_mb,FALSE);
1429 colorMenu->setItemChecked(cm_bm,FALSE); 1427 colorMenu->setItemChecked(cm_bm,FALSE);
1430 colorMenu->setItemChecked(cm_gy,FALSE); 1428 colorMenu->setItemChecked(cm_gy,FALSE);
1431 colorMenu->setItemChecked(cm_rb,FALSE); 1429 colorMenu->setItemChecked(cm_rb,FALSE);
1432 colorMenu->setItemChecked(cm_br,FALSE); 1430 colorMenu->setItemChecked(cm_br,FALSE);
1433 colorMenu->setItemChecked(cm_wb,FALSE); 1431 colorMenu->setItemChecked(cm_wb,FALSE);
1434 colorMenu->setItemChecked(cm_bw,FALSE); 1432 colorMenu->setItemChecked(cm_bw,FALSE);
1435 colorMenu->setItemChecked(cm_gb,FALSE); 1433 colorMenu->setItemChecked(cm_gb,FALSE);
1436 1434
1437 if(iD==cm_default) 1435 if(iD==cm_default)
1438 { // default default 1436 { // default default
1439 printf("default colors\n"); 1437 printf("default colors\n");
1440 for (i = 0; i < TABLE_COLORS; i++) 1438 for (i = 0; i < TABLE_COLORS; i++)
1441 { 1439 {
1442 m_table[i].color = defaultCt[i].color; 1440 m_table[i].color = defaultCt[i].color;
1443 if(i==1 || i == 11) 1441 if(i==1 || i == 11)
1444 m_table[i].transparent=1; 1442 m_table[i].transparent=1;
1445 colorMenu->setItemChecked(cm_default,TRUE); 1443 colorMenu->setItemChecked(cm_default,TRUE);
1446 } 1444 }
1447 te->setColorTable(m_table); 1445 te->setColorTable(m_table);
1448 } 1446 }
1449 if(iD==cm_gb) 1447 if(iD==cm_gb)
1450 { // green black 1448 { // green black
1451 foreground.setRgb(100,255,100); // (0x18,255,0x18); 1449 foreground.setRgb(100,255,100); // (0x18,255,0x18);
1452 background.setRgb(0x00,0x00,0x00); 1450 background.setRgb(0x00,0x00,0x00);
1453 colorMenu->setItemChecked(cm_gb,TRUE); 1451 colorMenu->setItemChecked(cm_gb,TRUE);
1454 } 1452 }
1455 if(iD==cm_bw) 1453 if(iD==cm_bw)
1456 { // black white 1454 { // black white
1457 foreground.setRgb(0x00,0x00,0x00); 1455 foreground.setRgb(0x00,0x00,0x00);
1458 background.setRgb(0xFF,0xFF,0xFF); 1456 background.setRgb(0xFF,0xFF,0xFF);
1459 colorMenu->setItemChecked(cm_bw,TRUE); 1457 colorMenu->setItemChecked(cm_bw,TRUE);
1460 } 1458 }
1461 if(iD==cm_wb) 1459 if(iD==cm_wb)
1462 { // white black 1460 { // white black
1463 foreground.setRgb(0xFF,0xFF,0xFF); 1461 foreground.setRgb(0xFF,0xFF,0xFF);
1464 background.setRgb(0x00,0x00,0x00); 1462 background.setRgb(0x00,0x00,0x00);
1465 colorMenu->setItemChecked(cm_wb,TRUE); 1463 colorMenu->setItemChecked(cm_wb,TRUE);
1466 } 1464 }
1467 if(iD==cm_br) 1465 if(iD==cm_br)
1468 {// Black, Red 1466 {// Black, Red
1469 foreground.setRgb(0x00,0x00,0x00); 1467 foreground.setRgb(0x00,0x00,0x00);
1470 background.setRgb(255,85,85); //(0xB2,0x18,0x18); 1468 background.setRgb(255,85,85); //(0xB2,0x18,0x18);
1471 colorMenu->setItemChecked(cm_br,TRUE); 1469 colorMenu->setItemChecked(cm_br,TRUE);
1472 } 1470 }
1473 if(iD==cm_rb) 1471 if(iD==cm_rb)
1474 {// Red, Black 1472 {// Red, Black
1475 foreground.setRgb(255,85,85); 1473 foreground.setRgb(255,85,85);
1476 background.setRgb(0x00,0x00,0x00); 1474 background.setRgb(0x00,0x00,0x00);
1477 colorMenu->setItemChecked(cm_rb,TRUE); 1475 colorMenu->setItemChecked(cm_rb,TRUE);
1478 } 1476 }
1479 if(iD==cm_gy) 1477 if(iD==cm_gy)
1480 {// Green, Yellow - is ugly 1478 {// Green, Yellow - is ugly
1481 // foreground.setRgb(0x18,0xB2,0x18); 1479 // foreground.setRgb(0x18,0xB2,0x18);
1482 foreground.setRgb(15,115,0); 1480 foreground.setRgb(15,115,0);
1483 // background.setRgb(0xB2,0x68,0x18); 1481 // background.setRgb(0xB2,0x68,0x18);
1484 background.setRgb(255,255,0); 1482 background.setRgb(255,255,0);
1485 colorMenu->setItemChecked(cm_gy,TRUE); 1483 colorMenu->setItemChecked(cm_gy,TRUE);
1486 } 1484 }
1487 if(iD==cm_bm) 1485 if(iD==cm_bm)
1488 {// Blue, Magenta 1486 {// Blue, Magenta
1489 foreground.setRgb(3,24,132); 1487 foreground.setRgb(3,24,132);
1490 background.setRgb(225,2,255); 1488 background.setRgb(225,2,255);
1491 colorMenu->setItemChecked(cm_bm,TRUE); 1489 colorMenu->setItemChecked(cm_bm,TRUE);
1492 } 1490 }
1493 if(iD==cm_mb) 1491 if(iD==cm_mb)
1494 {// Magenta, Blue 1492 {// Magenta, Blue
1495 foreground.setRgb(225,2,255); 1493 foreground.setRgb(225,2,255);
1496 background.setRgb(3,24,132); 1494 background.setRgb(3,24,132);
1497 colorMenu->setItemChecked(cm_mb,TRUE); 1495 colorMenu->setItemChecked(cm_mb,TRUE);
1498 } 1496 }
1499 if(iD==cm_cw) 1497 if(iD==cm_cw)
1500 {// Cyan, White 1498 {// Cyan, White
1501 foreground.setRgb(8,91,129); 1499 foreground.setRgb(8,91,129);
1502 background.setRgb(0xFF,0xFF,0xFF); 1500 background.setRgb(0xFF,0xFF,0xFF);
1503 colorMenu->setItemChecked(cm_cw,TRUE); 1501 colorMenu->setItemChecked(cm_cw,TRUE);
1504 } 1502 }
1505 if(iD==cm_wc) 1503 if(iD==cm_wc)
1506 {// White, Cyan 1504 {// White, Cyan
1507 background.setRgb(8,91,129); 1505 background.setRgb(8,91,129);
1508 foreground.setRgb(0xFF,0xFF,0xFF); 1506 foreground.setRgb(0xFF,0xFF,0xFF);
1509 colorMenu->setItemChecked(cm_wc,TRUE); 1507 colorMenu->setItemChecked(cm_wc,TRUE);
1510 } 1508 }
1511 if(iD==cm_bb) 1509 if(iD==cm_bb)
1512 {// Black, Blue 1510 {// Black, Blue
1513 background.setRgb(0x00,0x00,0x00); 1511 background.setRgb(0x00,0x00,0x00);
1514 foreground.setRgb(127,147,225); 1512 foreground.setRgb(127,147,225);
1515 colorMenu->setItemChecked(cm_bb,TRUE); 1513 colorMenu->setItemChecked(cm_bb,TRUE);
1516 } 1514 }
1517 if(iD==cm_ab) 1515 if(iD==cm_ab)
1518 {// Black, Gold 1516 {// Black, Gold
1519 background.setRgb(0x00,0x00,0x00); 1517 background.setRgb(0x00,0x00,0x00);
1520 foreground.setRgb(255,215,105); 1518 foreground.setRgb(255,215,105);
1521 colorMenu->setItemChecked(cm_ab,TRUE); 1519 colorMenu->setItemChecked(cm_ab,TRUE);
1522 } 1520 }
1523#ifdef QT_QWS_OPIE 1521#ifdef QT_QWS_OPIE
1524 if(iD==-19) 1522 if(iD==-19)
1525 { 1523 {
1526 // Custom 1524 // Custom
1527 qDebug("do custom"); 1525 qDebug("do custom");
1528 if(fromMenu) 1526 if(fromMenu)
1529 { 1527 {
1530 Opie::OColorPopupMenu* penColorPopupMenu = new Opie::OColorPopupMenu(Qt::black, this, "foreground color"); 1528 Opie::OColorPopupMenu* penColorPopupMenu = new Opie::OColorPopupMenu(Qt::black, this, "foreground color");
1531 connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, 1529 connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this,
1532 SLOT(changeForegroundColor(const QColor&))); 1530 SLOT(changeForegroundColor(const QColor&)));
1533 penColorPopupMenu->exec(); 1531 penColorPopupMenu->exec();
1534 } 1532 }
1535 if(!fromMenu) 1533 if(!fromMenu)
1536 { 1534 {
1537 foreground.setNamedColor(cfg.readEntry("foreground","")); 1535 foreground.setNamedColor(cfg.readEntry("foreground",""));
1538 background.setNamedColor(cfg.readEntry("background","")); 1536 background.setNamedColor(cfg.readEntry("background",""));
1539 } 1537 }
1540 fromMenu=FALSE; 1538 fromMenu=FALSE;
1541 colorMenu->setItemChecked(-19,TRUE); 1539 colorMenu->setItemChecked(-19,TRUE);
1542 } 1540 }
1543#endif 1541#endif
1544 1542
1545 lastSelectedMenu = iD; 1543 lastSelectedMenu = iD;
1546 1544
1547 setColors(foreground, background); 1545 setColors(foreground, background);
1548 1546
1549 QTabBar *tabBar = tab->getTabBar(); 1547 QTabBar *tabBar = tab->getTabBar();
1550 QString ss = QString("Session%1").arg(tabBar->currentTab()); 1548 QString ss = QString("Session%1").arg(tabBar->currentTab());
1551 // printf("current tab = %d\n", tabBar->currentTab()); 1549 // printf("current tab = %d\n", tabBar->currentTab());
1552 1550
1553 if (tabBar->currentTab() == 0) 1551 if (tabBar->currentTab() == 0)
1554 { 1552 {
1555 cfg.writeEntry("foregroundRed",QString::number(foreground.red())); 1553 cfg.writeEntry("foregroundRed",QString::number(foreground.red()));
1556 cfg.writeEntry("foregroundGreen",QString::number(foreground.green())); 1554 cfg.writeEntry("foregroundGreen",QString::number(foreground.green()));
1557 cfg.writeEntry("foregroundBlue",QString::number(foreground.blue())); 1555 cfg.writeEntry("foregroundBlue",QString::number(foreground.blue()));
1558 cfg.writeEntry("backgroundRed",QString::number(background.red())); 1556 cfg.writeEntry("backgroundRed",QString::number(background.red()));
1559 cfg.writeEntry("backgroundGreen",QString::number(background.green())); 1557 cfg.writeEntry("backgroundGreen",QString::number(background.green()));
1560 cfg.writeEntry("backgroundBlue",QString::number(background.blue())); 1558 cfg.writeEntry("backgroundBlue",QString::number(background.blue()));
1561 } 1559 }
1562 cfg.writeEntry("foregroundRed"+ss,QString::number(foreground.red())); 1560 cfg.writeEntry("foregroundRed"+ss,QString::number(foreground.red()));
1563 cfg.writeEntry("foregroundGreen"+ss,QString::number(foreground.green())); 1561 cfg.writeEntry("foregroundGreen"+ss,QString::number(foreground.green()));
1564 cfg.writeEntry("foregroundBlue"+ss,QString::number(foreground.blue())); 1562 cfg.writeEntry("foregroundBlue"+ss,QString::number(foreground.blue()));
1565 cfg.writeEntry("backgroundRed"+ss,QString::number(background.red())); 1563 cfg.writeEntry("backgroundRed"+ss,QString::number(background.red()));
1566 cfg.writeEntry("backgroundGreen"+ss,QString::number(background.green())); 1564 cfg.writeEntry("backgroundGreen"+ss,QString::number(background.green()));
1567 cfg.writeEntry("backgroundBlue"+ss,QString::number(background.blue())); 1565 cfg.writeEntry("backgroundBlue"+ss,QString::number(background.blue()));
1568 1566
1569 update(); 1567 update();
1570} 1568}
1571 1569
1572void Konsole::setColors(QColor foreground, QColor background) 1570void Konsole::setColors(QColor foreground, QColor background)
1573{ 1571{
1574 int i; 1572 int i;
1575 ColorEntry m_table[TABLE_COLORS]; 1573 ColorEntry m_table[TABLE_COLORS];
1576 TEWidget* te = getTe(); 1574 TEWidget* te = getTe();
1577 const ColorEntry * defaultCt=te->getdefaultColorTable(); 1575 const ColorEntry * defaultCt=te->getdefaultColorTable();
1578 1576
1579 for (i = 0; i < TABLE_COLORS; i++) 1577 for (i = 0; i < TABLE_COLORS; i++)
1580 { 1578 {
1581 if(i==0 || i == 10) 1579 if(i==0 || i == 10)
1582 { 1580 {
1583 m_table[i].color = foreground; 1581 m_table[i].color = foreground;
1584 } 1582 }
1585 else if(i==1 || i == 11) 1583 else if(i==1 || i == 11)
1586 { 1584 {
1587 m_table[i].color = background; 1585 m_table[i].color = background;
1588 m_table[i].transparent=0; 1586 m_table[i].transparent=0;
1589 } 1587 }
1590 else 1588 else
1591 m_table[i].color = defaultCt[i].color; 1589 m_table[i].color = defaultCt[i].color;
1592 } 1590 }
1593 te->setColorTable(m_table); 1591 te->setColorTable(m_table);
1594} 1592}
1595 1593
1596void Konsole::tabMenuSelected(int id) 1594void Konsole::tabMenuSelected(int id)
1597{ 1595{
1598 Config cfg( "Konsole" ); 1596 Config cfg( "Konsole" );
1599 cfg.setGroup("Tabs"); 1597 cfg.setGroup("Tabs");
1600 tabMenu->setItemChecked(tabPos, false); 1598 tabMenu->setItemChecked(tabPos, false);
1601 if (id == tm_bottom) 1599 if (id == tm_bottom)
1602 { 1600 {
1603 printf("set bottom tab\n"); 1601 printf("set bottom tab\n");
1604 tab->getTabBar()->show(); 1602 tab->getTabBar()->show();
1605 tab->setTabPosition(QTabWidget::Bottom); 1603 tab->setTabPosition(QTabWidget::Bottom);
1606 tab->getTabBar()->show(); 1604 tab->getTabBar()->show();
1607 cfg.writeEntry("Position","Bottom"); 1605 cfg.writeEntry("Position","Bottom");
1608 } 1606 }
1609 else if (id == tm_top) 1607 else if (id == tm_top)
1610 { 1608 {
1611 printf("set top tab\n"); 1609 printf("set top tab\n");
1612 tab->getTabBar()->show(); 1610 tab->getTabBar()->show();
1613 tab->setTabPosition(QTabWidget::Bottom); 1611 tab->setTabPosition(QTabWidget::Bottom);
1614 tab->setTabPosition(QTabWidget::Top); 1612 tab->setTabPosition(QTabWidget::Top);
1615 tab->getTabBar()->show(); 1613 tab->getTabBar()->show();
1616 cfg.writeEntry("Position","Top"); 1614 cfg.writeEntry("Position","Top");
1617 } 1615 }
1618 else if (id == tm_hidden) 1616 else if (id == tm_hidden)
1619 { 1617 {
1620 tab->getTabBar()->hide(); 1618 tab->getTabBar()->hide();
1621 tab->setMargin(tab->margin()); 1619 tab->setMargin(tab->margin());
1622 cfg.writeEntry("Position","Hidden"); 1620 cfg.writeEntry("Position","Hidden");
1623 } 1621 }
1624 tabMenu->setItemChecked(id, true); 1622 tabMenu->setItemChecked(id, true);
1625 tabPos = id; 1623 tabPos = id;
1626} 1624}
1627 1625
1628 1626
1629void Konsole::configMenuSelected(int iD) 1627void Konsole::configMenuSelected(int iD)
1630{ 1628{
1631 // QString temp; 1629 // QString temp;
1632 // qDebug( temp.sprintf("configmenu %d",iD)); 1630 // qDebug( temp.sprintf("configmenu %d",iD));
1633 1631
1634 TEWidget* te = getTe(); 1632 TEWidget* te = getTe();
1635 Config cfg( "Konsole" ); 1633 Config cfg( "Konsole" );
1636 cfg.setGroup("Menubar"); 1634 cfg.setGroup("Menubar");
1637 if(iD == cm_wrap) 1635 if(iD == cm_wrap)
1638 { 1636 {
1639 cfg.setGroup("ScrollBar"); 1637 cfg.setGroup("ScrollBar");
1640 bool b=cfg.readBoolEntry("HorzScroll",0); 1638 bool b=cfg.readBoolEntry("HorzScroll",0);
1641 b=!b; 1639 b=!b;
1642 cfg.writeEntry("HorzScroll", b ); 1640 cfg.writeEntry("HorzScroll", b );
1643 cfg.write(); 1641 cfg.write();
1644 doWrap(); 1642 doWrap();
1645 if(cfg.readNumEntry("Position",2) == 0) 1643 if(cfg.readNumEntry("Position",2) == 0)
1646 { 1644 {
1647 te->setScrollbarLocation(1); 1645 te->setScrollbarLocation(1);
1648 } 1646 }
1649 else 1647 else
1650 { 1648 {
1651 te->setScrollbarLocation(0); 1649 te->setScrollbarLocation(0);
1652 } 1650 }
1653 te->setScrollbarLocation( cfg.readNumEntry("Position",2)); 1651 te->setScrollbarLocation( cfg.readNumEntry("Position",2));
1654 } 1652 }
1655 if(iD == cm_beep) 1653 if(iD == cm_beep)
1656 { 1654 {
1657 cfg.setGroup("Menubar"); 1655 cfg.setGroup("Menubar");
1658 bool b=cfg.readBoolEntry("useBeep",0); 1656 bool b=cfg.readBoolEntry("useBeep",0);
1659 b=!b; 1657 b=!b;
1660 cfg.writeEntry("useBeep", b ); 1658 cfg.writeEntry("useBeep", b );
1661 cfg.write(); 1659 cfg.write();
1662 configMenu->setItemChecked(cm_beep,b); 1660 configMenu->setItemChecked(cm_beep,b);
1663 te->useBeep=b; 1661 te->useBeep=b;
1664 } 1662 }
1665} 1663}
1666 1664
1667void Konsole::changeCommand(const QString &text, int c) 1665void Konsole::changeCommand(const QString &text, int c)
1668{ 1666{
1669 Config cfg( "Konsole" ); 1667 Config cfg( "Konsole" );
1670 cfg.setGroup("Commands"); 1668 cfg.setGroup("Commands");
1671 if(commonCmds[c] != text) 1669 if(commonCmds[c] != text)
1672 { 1670 {
1673 cfg.writeEntry(QString::number(c),text); 1671 cfg.writeEntry(QString::number(c),text);
1674 commonCombo->clearEdit(); 1672 commonCombo->clearEdit();
1675 commonCombo->setCurrentItem(c); 1673 commonCombo->setCurrentItem(c);
1676 } 1674 }
1677} 1675}
1678 1676
1679void Konsole::setColor(int sess) 1677void Konsole::setColor(int sess)
1680{ 1678{
1681 Config cfg( "Konsole" ); 1679 Config cfg( "Konsole" );
1682 cfg.setGroup("Colors"); 1680 cfg.setGroup("Colors");
1683 QColor foreground, background; 1681 QColor foreground, background;
1684 QString ss = QString("Session") + QString::number(sess); 1682 QString ss = QString("Session") + QString::number(sess);
1685 foreground.setRgb(cfg.readNumEntry("foregroundRed"+ss, 1683 foreground.setRgb(cfg.readNumEntry("foregroundRed"+ss,
1686 cfg.readNumEntry("foregroundRed",0xff)), 1684 cfg.readNumEntry("foregroundRed",0xff)),
1687 cfg.readNumEntry("foregroundGreen"+ss, 1685 cfg.readNumEntry("foregroundGreen"+ss,
1688 cfg.readNumEntry("foregroundGreen",0xff)), 1686 cfg.readNumEntry("foregroundGreen",0xff)),
1689 cfg.readNumEntry("foregroundBlue"+ss, 1687 cfg.readNumEntry("foregroundBlue"+ss,
1690 cfg.readNumEntry("foregroundBlue",0xff))); 1688 cfg.readNumEntry("foregroundBlue",0xff)));
1691 background.setRgb(cfg.readNumEntry("backgroundRed"+ss, 1689 background.setRgb(cfg.readNumEntry("backgroundRed"+ss,
1692 cfg.readNumEntry("backgroundRed",0)), 1690 cfg.readNumEntry("backgroundRed",0)),
1693 cfg.readNumEntry("backgroundGreen"+ss, 1691 cfg.readNumEntry("backgroundGreen"+ss,
1694 cfg.readNumEntry("backgroundGreen",0)), 1692 cfg.readNumEntry("backgroundGreen",0)),
1695 cfg.readNumEntry("backgroundBlue"+ss, 1693 cfg.readNumEntry("backgroundBlue"+ss,
1696 cfg.readNumEntry("backgroundBlue",0))); 1694 cfg.readNumEntry("backgroundBlue",0)));
1697 setColors(foreground, background); 1695 setColors(foreground, background);
1698} 1696}
1699 1697
1700void Konsole::scrollMenuSelected(int index) 1698void Konsole::scrollMenuSelected(int index)
1701{ 1699{
1702 // qDebug( "scrollbar menu %d",index); 1700 // qDebug( "scrollbar menu %d",index);
1703 1701
1704 TEWidget* te = getTe(); 1702 TEWidget* te = getTe();
1705 Config cfg( "Konsole" ); 1703 Config cfg( "Konsole" );
1706 cfg.setGroup("ScrollBar"); 1704 cfg.setGroup("ScrollBar");
1707 1705
1708 if(index == sm_none) 1706 if(index == sm_none)
1709 { 1707 {
1710 te->setScrollbarLocation(0); 1708 te->setScrollbarLocation(0);
1711 cfg.writeEntry("Position",0); 1709 cfg.writeEntry("Position",0);
1712 } 1710 }
1713 else if(index == sm_left) 1711 else if(index == sm_left)
1714 { 1712 {
1715 te->setScrollbarLocation(1); 1713 te->setScrollbarLocation(1);
1716 cfg.writeEntry("Position",1); 1714 cfg.writeEntry("Position",1);
1717 } 1715 }
1718 else if(index == sm_right) 1716 else if(index == sm_right)
1719 { 1717 {
1720 te->setScrollbarLocation(2); 1718 te->setScrollbarLocation(2);
1721 cfg.writeEntry("Position",2); 1719 cfg.writeEntry("Position",2);
1722 } 1720 }
1723 scrollMenu->setItemChecked(sm_none, index == sm_none); 1721 scrollMenu->setItemChecked(sm_none, index == sm_none);
1724 scrollMenu->setItemChecked(sm_left, index == sm_left); 1722 scrollMenu->setItemChecked(sm_left, index == sm_left);
1725 scrollMenu->setItemChecked(sm_right, index == sm_right); 1723 scrollMenu->setItemChecked(sm_right, index == sm_right);
1726} 1724}
1727 1725
1728// case -29: { 1726// case -29: {
1729// bool b=cfg.readBoolEntry("HorzScroll",0); 1727// bool b=cfg.readBoolEntry("HorzScroll",0);
1730// cfg.writeEntry("HorzScroll", !b ); 1728// cfg.writeEntry("HorzScroll", !b );
1731// cfg.write(); 1729// cfg.write();
1732// if(cfg.readNumEntry("Position",2) == 0) { 1730// if(cfg.readNumEntry("Position",2) == 0) {
1733// te->setScrollbarLocation(1); 1731// te->setScrollbarLocation(1);
1734// te->setWrapAt(0); 1732// te->setWrapAt(0);
1735// } else { 1733// } else {
1736// te->setScrollbarLocation(0); 1734// te->setScrollbarLocation(0);
1737// te->setWrapAt(120); 1735// te->setWrapAt(120);
1738// } 1736// }
1739// te->setScrollbarLocation( cfg.readNumEntry("Position",2)); 1737// te->setScrollbarLocation( cfg.readNumEntry("Position",2));
1740// } 1738// }
1741// break; 1739// break;
1742 1740
1743void Konsole::editCommandListMenuSelected(int iD) 1741void Konsole::editCommandListMenuSelected(int iD)
1744{ 1742{
1745 // QString temp; 1743 // QString temp;
1746 // qDebug( temp.sprintf("edit command list %d",iD)); 1744 // qDebug( temp.sprintf("edit command list %d",iD));
1747 1745
1748 // FIXME: more cleanup needed here 1746 // FIXME: more cleanup needed here
1749 1747
1750 1748
1751 TEWidget* te = getTe(); 1749 TEWidget* te = getTe();
1752 Config cfg( "Konsole" ); 1750 Config cfg( "Konsole" );
1753 cfg.setGroup("Menubar"); 1751 cfg.setGroup("Menubar");
1754 if( iD == ec_cmdlist) 1752 if( iD == ec_cmdlist)
1755 { 1753 {
1756 if(!secondToolBar->isHidden()) 1754 if(!secondToolBar->isHidden())
1757 { 1755 {
1758 secondToolBar->hide(); 1756 secondToolBar->hide();
1759 configMenu->changeItem( iD,tr( "Show Command List" )); 1757 configMenu->changeItem( iD,tr( "Show Command List" ));
1760 cfg.writeEntry("Hidden","TRUE"); 1758 cfg.writeEntry("Hidden","TRUE");
1761 configMenu->setItemEnabled(ec_edit ,FALSE); 1759 configMenu->setItemEnabled(ec_edit ,FALSE);
1762 configMenu->setItemEnabled(ec_quick ,FALSE); 1760 configMenu->setItemEnabled(ec_quick ,FALSE);
1763 } 1761 }
1764 else 1762 else
1765 { 1763 {
1766 secondToolBar->show(); 1764 secondToolBar->show();
1767 configMenu->changeItem( iD,tr( "Hide Command List" )); 1765 configMenu->changeItem( iD,tr( "Hide Command List" ));
1768 cfg.writeEntry("Hidden","FALSE"); 1766 cfg.writeEntry("Hidden","FALSE");
1769 configMenu->setItemEnabled(ec_edit ,TRUE); 1767 configMenu->setItemEnabled(ec_edit ,TRUE);
1770 configMenu->setItemEnabled(ec_quick ,TRUE); 1768 configMenu->setItemEnabled(ec_quick ,TRUE);
1771 1769
1772 if(cfg.readEntry("EditEnabled","FALSE")=="TRUE") 1770 if(cfg.readEntry("EditEnabled","FALSE")=="TRUE")
1773 { 1771 {
1774 configMenu->setItemChecked(ec_edit,TRUE); 1772 configMenu->setItemChecked(ec_edit,TRUE);
1775 commonCombo->setEditable( TRUE ); 1773 commonCombo->setEditable( TRUE );
1776 } 1774 }
1777 else 1775 else
1778 { 1776 {
1779 configMenu->setItemChecked(ec_edit,FALSE); 1777 configMenu->setItemChecked(ec_edit,FALSE);
1780 commonCombo->setEditable( FALSE ); 1778 commonCombo->setEditable( FALSE );
1781 } 1779 }
1782 } 1780 }
1783 } 1781 }
1784 if( iD == ec_quick) 1782 if( iD == ec_quick)
1785 { 1783 {
1786 cfg.setGroup("Commands"); 1784 cfg.setGroup("Commands");
1787 // qDebug("enableCommandEdit"); 1785 // qDebug("enableCommandEdit");
1788 if( !configMenu->isItemChecked(iD) ) 1786 if( !configMenu->isItemChecked(iD) )
1789 { 1787 {
1790 commonCombo->setEditable( TRUE ); 1788 commonCombo->setEditable( TRUE );
1791 configMenu->setItemChecked(iD,TRUE); 1789 configMenu->setItemChecked(iD,TRUE);
1792 commonCombo->setCurrentItem(0); 1790 commonCombo->setCurrentItem(0);
1793 cfg.writeEntry("EditEnabled","TRUE"); 1791 cfg.writeEntry("EditEnabled","TRUE");
1794 } 1792 }
1795 else 1793 else
1796 { 1794 {
1797 commonCombo->setEditable( FALSE ); 1795 commonCombo->setEditable( FALSE );
1798 configMenu->setItemChecked(iD,FALSE); 1796 configMenu->setItemChecked(iD,FALSE);
1799 cfg.writeEntry("EditEnabled","FALSE"); 1797 cfg.writeEntry("EditEnabled","FALSE");
1800 commonCombo->setFocusPolicy(QWidget::NoFocus); 1798 commonCombo->setFocusPolicy(QWidget::NoFocus);
1801 te->setFocus(); 1799 te->setFocus();
1802 } 1800 }
1803 } 1801 }
1804 if(iD == ec_edit) 1802 if(iD == ec_edit)
1805 { 1803 {
1806 // "edit commands" 1804 // "edit commands"
1807 CommandEditDialog *m = new CommandEditDialog(this); 1805 CommandEditDialog *m = new CommandEditDialog(this);
1808 connect(m,SIGNAL(commandsEdited()),this,SLOT(initCommandList())); 1806 connect(m,SIGNAL(commandsEdited()),this,SLOT(initCommandList()));
1809 m->showMaximized(); 1807 m->showMaximized();
1810 } 1808 }
1811 1809
1812} 1810}
1813 1811
1814// $QPEDIR/bin/qcop QPE/Application/embeddedkonsole 'setDocument(QString)' 'ssh -V' 1812// $QPEDIR/bin/qcop QPE/Application/embeddedkonsole 'setDocument(QString)' 'ssh -V'
1815void Konsole::setDocument( const QString &cmd) 1813void Konsole::setDocument( const QString &cmd)
1816{ 1814{
1817 newSession(); 1815 newSession();
1818 TEWidget* te = getTe(); 1816 TEWidget* te = getTe();
1819 if(cmd.find("-e", 0, TRUE) != -1) 1817 if(cmd.find("-e", 0, TRUE) != -1)
1820 { 1818 {
1821 QString cmd2; 1819 QString cmd2;
1822 cmd2=cmd.right(cmd.length()-3)+" &"; 1820 cmd2=cmd.right(cmd.length()-3)+" &";
1823 system(cmd2.latin1()); 1821 system(cmd2.latin1());
1824 if(startUp <= 1 && nsessions < 2) 1822 if(startUp <= 1 && nsessions < 2)
1825 { 1823 {
1826 doneSession(getTe(), 0); 1824 doneSession(getTe(), 0);
1827 exit(0); 1825 exit(0);
1828 } 1826 }
1829 else 1827 else
1830 doneSession(getTe(), 0); 1828 doneSession(getTe(), 0);
1831 } 1829 }
1832 else 1830 else
1833 { 1831 {
1834 if (te != 0) 1832 if (te != 0)
1835 { 1833 {
1836 te->emitText(cmd+"\r"); 1834 te->emitText(cmd+"\r");
1837 } 1835 }
1838 } 1836 }
1839 startUp++; 1837 startUp++;
1840} 1838}
1841 1839
1842 1840
1843// what is the point of this when you can just 1841// what is the point of this when you can just
1844// run commands by using the shell directly?? 1842// run commands by using the shell directly??
1845void Konsole::parseCommandLine() 1843void Konsole::parseCommandLine()
1846{ 1844{
1847 QString cmd; 1845 QString cmd;
1848 // newSession(); 1846 // newSession();
1849 for (int i=1;i< qApp->argc();i++) 1847 for (int i=1;i< qApp->argc();i++)
1850 { 1848 {
1851 if( QString(qApp->argv()[i]) == "-e") 1849 if( QString(qApp->argv()[i]) == "-e")
1852 { 1850 {
1853 i++; 1851 i++;
1854 for ( int j=i;j< qApp->argc();j++) 1852 for ( int j=i;j< qApp->argc();j++)
1855 { 1853 {
1856 cmd+=QString(qApp->argv()[j])+" "; 1854 cmd+=QString(qApp->argv()[j])+" ";
1857 } 1855 }
1858 cmd.stripWhiteSpace(); 1856 cmd.stripWhiteSpace();
1859 system(cmd.latin1()); 1857 system(cmd.latin1());
1860 exit(0);//close(); 1858 exit(0);//close();
1861 } // end -e switch 1859 } // end -e switch
1862 } 1860 }
1863 startUp++; 1861 startUp++;
1864} 1862}
1865 1863
1866void Konsole::changeForegroundColor(const QColor &color) 1864void Konsole::changeForegroundColor(const QColor &color)
1867{ 1865{
1868 Config cfg( "Konsole" ); 1866 Config cfg( "Konsole" );
1869 cfg.setGroup("Colors"); 1867 cfg.setGroup("Colors");
1870 int r, g, b; 1868 int r, g, b;
1871 color.rgb(&r,&g,&b); 1869 color.rgb(&r,&g,&b);
1872 foreground.setRgb(r,g,b); 1870 foreground.setRgb(r,g,b);
1873 1871
1874 cfg.writeEntry("foreground",color.name()); 1872 cfg.writeEntry("foreground",color.name());
1875 qDebug("foreground "+color.name()); 1873 qDebug("foreground "+color.name());
1876 cfg.write(); 1874 cfg.write();
1877 1875
1878 qDebug("do other dialog"); 1876 qDebug("do other dialog");
1879#ifdef QT_QWS_OPIE 1877#ifdef QT_QWS_OPIE
1880 1878
1881 Opie::OColorPopupMenu* penColorPopupMenu2 = new Opie::OColorPopupMenu(Qt::black, this,"background color"); 1879 Opie::OColorPopupMenu* penColorPopupMenu2 = new Opie::OColorPopupMenu(Qt::black, this,"background color");
1882 connect(penColorPopupMenu2, SIGNAL(colorSelected(const QColor&)), this, 1880 connect(penColorPopupMenu2, SIGNAL(colorSelected(const QColor&)), this,
1883 SLOT(changeBackgroundColor(const QColor&))); 1881 SLOT(changeBackgroundColor(const QColor&)));
1884 penColorPopupMenu2->exec(); 1882 penColorPopupMenu2->exec();
1885#endif 1883#endif
1886} 1884}
1887 1885
1888void Konsole::changeBackgroundColor(const QColor &color) 1886void Konsole::changeBackgroundColor(const QColor &color)
1889{ 1887{
1890 1888
1891 qDebug("Change background"); 1889 qDebug("Change background");
1892 Config cfg( "Konsole" ); 1890 Config cfg( "Konsole" );
1893 cfg.setGroup("Colors"); 1891 cfg.setGroup("Colors");
1894 int r, g, b; 1892 int r, g, b;
1895 color.rgb(&r,&g,&b); 1893 color.rgb(&r,&g,&b);
1896 background.setRgb(r,g,b); 1894 background.setRgb(r,g,b);
1897 cfg.writeEntry("background",color.name()); 1895 cfg.writeEntry("background",color.name());
1898 qDebug("background "+color.name()); 1896 qDebug("background "+color.name());
1899 cfg.write(); 1897 cfg.write();
1900} 1898}
1901 1899
1902void Konsole::doWrap() 1900void Konsole::doWrap()
1903{ 1901{
1904 Config cfg( "Konsole" ); 1902 Config cfg( "Konsole" );
1905 cfg.setGroup("ScrollBar"); 1903 cfg.setGroup("ScrollBar");
1906 TEWidget* te = getTe(); 1904 TEWidget* te = getTe();
1907 if( !cfg.readBoolEntry("HorzScroll",0)) 1905 if( !cfg.readBoolEntry("HorzScroll",0))
1908 { 1906 {
1909 te->setWrapAt(0); 1907 te->setWrapAt(0);
1910 configMenu->setItemChecked( cm_wrap,TRUE); 1908 configMenu->setItemChecked( cm_wrap,TRUE);
1911 } 1909 }
1912 else 1910 else
1913 { 1911 {
1914 // te->setWrapAt(90); 1912 // te->setWrapAt(90);
1915 te->setWrapAt(120); 1913 te->setWrapAt(120);
1916 configMenu->setItemChecked( cm_wrap,FALSE); 1914 configMenu->setItemChecked( cm_wrap,FALSE);
1917 } 1915 }
1918} 1916}