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