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