summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/embeddedkonsole/konsole.cpp103
1 files changed, 88 insertions, 15 deletions
diff --git a/core/apps/embeddedkonsole/konsole.cpp b/core/apps/embeddedkonsole/konsole.cpp
index fff2f68..a5adc03 100644
--- a/core/apps/embeddedkonsole/konsole.cpp
+++ b/core/apps/embeddedkonsole/konsole.cpp
@@ -1,1102 +1,1175 @@
1/* ---------------------------------------------------------------------- */ 1/* ---------------------------------------------------------------------- */
2/* */ 2/* */
3/* [main.C] Konsole */ 3/* [main.C] Konsole */
4/* */ 4/* */
5/* ---------------------------------------------------------------------- */ 5/* ---------------------------------------------------------------------- */
6/* */ 6/* */
7/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ 7/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */
8/* */ 8/* */
9/* This file is part of Konsole, an X terminal. */ 9/* This file is part of Konsole, an X terminal. */
10/* */ 10/* */
11/* The material contained in here more or less directly orginates from */ 11/* The material contained in here more or less directly orginates from */
12/* kvt, which is copyright (c) 1996 by Matthias Ettrich <ettrich@kde.org> */ 12/* kvt, which is copyright (c) 1996 by Matthias Ettrich <ettrich@kde.org> */
13/* */ 13/* */
14/* ---------------------------------------------------------------------- */ 14/* ---------------------------------------------------------------------- */
15/* */ 15/* */
16/* Ported Konsole to Qt/Embedded */ 16/* Ported Konsole to Qt/Embedded */
17/* */ 17/* */
18/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ 18/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */
19/* */ 19/* */
20/* -------------------------------------------------------------------------- */ 20/* -------------------------------------------------------------------------- */
21// enhancements added by L.J. Potter <ljp@llornkcor.com> 21// enhancements added by L.J. Potter <ljp@llornkcor.com>
22#define QT_QWS_OPIE 22//#define QT_QWS_OPIE
23
24#include "signal.h"
23 25
24#include <qpe/resource.h> 26#include <qpe/resource.h>
25 27
26#include <qdir.h> 28#include <qdir.h>
27#include <qevent.h> 29#include <qevent.h>
28#include <qdragobject.h> 30#include <qdragobject.h>
29#include <qobjectlist.h> 31#include <qobjectlist.h>
30#include <qtoolbutton.h> 32#include <qtoolbutton.h>
31#include <qtoolbar.h> 33#include <qtoolbar.h>
32#include <qpushbutton.h> 34#include <qpushbutton.h>
33#include <qfontdialog.h> 35#include <qfontdialog.h>
34#include <qglobal.h> 36#include <qglobal.h>
35#include <qpainter.h> 37#include <qpainter.h>
36#include <qmenubar.h> 38#include <qmenubar.h>
37#include <qmessagebox.h> 39#include <qmessagebox.h>
38#include <qaction.h> 40#include <qaction.h>
39#include <qapplication.h> 41#include <qapplication.h>
40#include <qfontmetrics.h> 42#include <qfontmetrics.h>
41#include <qcombobox.h> 43#include <qcombobox.h>
42#include <qevent.h> 44#include <qevent.h>
43#include <qtabwidget.h> 45#include <qtabwidget.h>
44#include <qtabbar.h> 46#include <qtabbar.h>
45#include <qpe/config.h> 47#include <qpe/config.h>
46#include <qstringlist.h> 48#include <qstringlist.h>
47#include <qpalette.h> 49#include <qpalette.h>
48 50
49#include <unistd.h> 51#include <unistd.h>
50#include <pwd.h> 52#include <pwd.h>
51#include <sys/types.h> 53#include <sys/types.h>
52#include <sys/wait.h> 54//#include <sys/wait.h>
53#include <stdio.h> 55#include <stdio.h>
54#include <stdlib.h> 56#include <stdlib.h>
55#include <assert.h> 57#include <assert.h>
56 58
57#include "konsole.h" 59#include "konsole.h"
58#include "keytrans.h" 60#include "keytrans.h"
59#include "commandeditdialog.h" 61#include "commandeditdialog.h"
60 62
61#ifdef QT_QWS_OPIE 63#ifdef QT_QWS_OPIE
62#include <opie/colorpopupmenu.h> 64#include <opie/colorpopupmenu.h>
63#endif 65#endif
64 66
67 #include <qfontdatabase.h>// U.B.
68 #include <qstringlist.h>// U.B.
69 #include <qvaluelist.h> // U.B.
70
65class EKNumTabBar : public QTabBar { 71class EKNumTabBar : public QTabBar {
66public: 72public:
67 void numberTabs() 73 void numberTabs()
68 { 74 {
69 // Yes, it really is this messy. QTabWidget needs functions 75 // Yes, it really is this messy. QTabWidget needs functions
70 // that provide acces to tabs in a sequential way. 76 // that provide acces to tabs in a sequential way.
71 int m=INT_MIN; 77 int m=INT_MIN;
72 for (int i=0; i<count(); i++) { 78 for (int i=0; i<count(); i++) {
73 QTab* left=0; 79 QTab* left=0;
74 QListIterator<QTab> it(*tabList()); 80 QListIterator<QTab> it(*tabList());
75 int x=INT_MAX; 81 int x=INT_MAX;
76 for( QTab* t; (t=it.current()); ++it ) { 82 for( QTab* t; (t=it.current()); ++it ) {
77 int tx = t->rect().x(); 83 int tx = t->rect().x();
78 if ( tx<x && tx>m ) { 84 if ( tx<x && tx>m ) {
79 x = tx; 85 x = tx;
80 left = t; 86 left = t;
81 } 87 }
82 } 88 }
83 if ( left ) { 89 if ( left ) {
84 left->setText(QString::number(i+1)); 90 left->setText(QString::number(i+1));
85 m = left->rect().x(); 91 m = left->rect().x();
86 } 92 }
87 } 93 }
88 } 94 }
89}; 95};
90 96
91class EKNumTabWidget : public QTabWidget { 97class EKNumTabWidget : public QTabWidget {
92public: 98public:
93 EKNumTabWidget(QWidget* parent) : QTabWidget(parent) 99 EKNumTabWidget(QWidget* parent) : QTabWidget(parent)
94 { 100 {
95 } 101 }
96 102
97 void addTab(QWidget* w) 103 void addTab(QWidget* w)
98 { 104 {
99 QTab* t = new QTab(QString::number(tabBar()->count()+1)); 105 QTab* t = new QTab(QString::number(tabBar()->count()+1));
100 QTabWidget::addTab(w,t); 106 QTabWidget::addTab(w,t);
101 } 107 }
102 108
103 void removeTab(QWidget* w) 109 void removeTab(QWidget* w)
104 { 110 {
105 removePage(w); 111 removePage(w);
106 ((EKNumTabBar*)tabBar())->numberTabs(); 112 ((EKNumTabBar*)tabBar())->numberTabs();
107 } 113 }
108}; 114};
109 115
110// This could be configurable or dynamicly generated from the bash history 116// This could be configurable or dynamicly generated from the bash history
111// file of the user 117// file of the user
112static const char *commonCmds[] = 118static const char *commonCmds[] =
113{ 119{
114 "ls ", // I left this here, cause it looks better than the first alpha 120 "ls ", // I left this here, cause it looks better than the first alpha
115 "cardctl eject", 121 "cardctl eject",
116 "cat ", 122 "cat ",
117 "cd ", 123 "cd ",
118 "chmod ", 124 "chmod ",
119 "clear", 125 "clear",
120 "cp ", 126 "cp ",
121 "dc ", 127 "dc ",
122 "df ", 128 "df ",
123 "dmesg", 129 "dmesg",
124 "echo ", 130 "echo ",
125 "env", 131 "env",
126 "find ", 132 "find ",
127 "free", 133 "free",
128 "grep ", 134 "grep ",
129 "ifconfig ", 135 "ifconfig ",
130 "ipkg ", 136 "ipkg ",
131 "mkdir ", 137 "mkdir ",
132 "mv ", 138 "mv ",
133 "nc localhost 7776", 139 "nc localhost 7776",
134 "nc localhost 7777", 140 "nc localhost 7777",
135 "netstat ", 141 "netstat ",
136 "nslookup ", 142 "nslookup ",
137 "ping ", 143 "ping ",
138 "ps aux", 144 "ps aux",
139 "pwd ", 145 "pwd ",
140 "qcop QPE/System 'linkChanged(QString)' ''", 146 "qcop QPE/System 'linkChanged(QString)' ''",
141 "qcop QPE/System 'restart()'", 147 "qcop QPE/System 'restart()'",
142 "qcop QPE/System 'quit()'", 148 "qcop QPE/System 'quit()'",
143 "rm ", 149 "rm ",
144 "rmdir ", 150 "rmdir ",
145 "route ", 151 "route ",
146 "set ", 152 "set ",
147 "traceroute", 153 "traceroute",
148 154
149/* 155/*
150 "gzip", 156 "gzip",
151 "gunzip", 157 "gunzip",
152 "chgrp", 158 "chgrp",
153 "chown", 159 "chown",
154 "date", 160 "date",
155 "dd", 161 "dd",
156 "df", 162 "df",
157 "dmesg", 163 "dmesg",
158 "fuser", 164 "fuser",
159 "hostname", 165 "hostname",
160 "kill", 166 "kill",
161 "killall", 167 "killall",
162 "ln", 168 "ln",
163 "ping", 169 "ping",
164 "mount", 170 "mount",
165 "more", 171 "more",
166 "sort", 172 "sort",
167 "touch", 173 "touch",
168 "umount", 174 "umount",
169 "mknod", 175 "mknod",
170 "netstat", 176 "netstat",
171*/ 177*/
172 178
173 "exit", 179 "exit",
174 NULL 180 NULL
175}; 181};
176 182
177static void konsoleInit(const char** shell) { 183static void konsoleInit(const char** shell) {
178 if(setuid(getuid()) !=0) qDebug("setuid failed"); 184 if(setuid(getuid()) !=0) qDebug("setuid failed");
179 if(setgid(getgid()) != 0) qDebug("setgid failed"); // drop privileges 185 if(setgid(getgid()) != 0) qDebug("setgid failed"); // drop privileges
180 186
181 187 // signal (SIGSTOP, SIG_IGN);
188
182// QPEApplication::grabKeyboard(); // for CTRL and ALT 189// QPEApplication::grabKeyboard(); // for CTRL and ALT
183 190
184 qDebug("keyboard grabbed"); 191// qDebug("keyboard grabbed");
185#ifdef FAKE_CTRL_AND_ALT 192#ifdef FAKE_CTRL_AND_ALT
186 qDebug("Fake Ctrl and Alt defined"); 193 qDebug("Fake Ctrl and Alt defined");
187 QPEApplication::grabKeyboard(); // for CTRL and ALT 194 QPEApplication::grabKeyboard(); // for CTRL and ALT
188#endif 195#endif
189 196
190 *shell = getenv("SHELL"); 197 *shell = getenv("SHELL");
191 qWarning("SHell initially is %s", *shell ); 198// qWarning("SHell initially is %s", *shell );
192 199
193 if (shell == NULL || *shell == '\0') { 200 if (shell == NULL || *shell == '\0') {
194 struct passwd *ent = 0; 201 struct passwd *ent = 0;
195 uid_t me = getuid(); 202 uid_t me = getuid();
196 *shell = "/bin/sh"; 203 *shell = "/bin/sh";
197 204
198 while ( (ent = getpwent()) != 0 ) { 205 while ( (ent = getpwent()) != 0 ) {
199 if (ent->pw_uid == me) { 206 if (ent->pw_uid == me) {
200 if (ent->pw_shell != "") 207 if (ent->pw_shell != "")
201 *shell = ent->pw_shell; 208 *shell = ent->pw_shell;
202 break; 209 break;
203 } 210 }
204 } 211 }
205 endpwent(); 212 endpwent();
206 } 213 }
207 214
208 qWarning("SHELL now is %s", *shell ); 215// qWarning("SHELL now is %s", *shell );
209 216
210 if( putenv((char*)"COLORTERM=") !=0) 217 if( putenv((char*)"COLORTERM=") !=0)
211 qDebug("putenv failed"); // to trigger mc's color detection 218 qDebug("putenv failed"); // to trigger mc's color detection
212} 219}
213 220
214Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) : 221Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) :
215 QMainWindow(parent, name, fl) 222 QMainWindow(parent, name, fl)
216{ 223{
217 QStrList tmp; const char* shell; 224 QStrList tmp; const char* shell;
218 225
219 setCaption( tr("Terminal") ); 226 setCaption( tr("Terminal") );
220 227
221 konsoleInit( &shell); 228 konsoleInit( &shell);
222 qWarning("Using shell %s", shell); 229// qWarning("Using shell %s", shell);
223 init(shell,tmp); 230 init(shell,tmp);
224} 231}
225 232
226 233
227 234
228void Konsole::initCommandList() 235void Konsole::initCommandList()
229{ 236{
230// qDebug("Konsole::initCommandList"); 237// qDebug("Konsole::initCommandList");
231 Config cfg("Konsole"); 238 Config cfg("Konsole");
232 cfg.setGroup("Commands"); 239 cfg.setGroup("Commands");
233 commonCombo->setInsertionPolicy(QComboBox::AtCurrent); 240 commonCombo->setInsertionPolicy(QComboBox::AtCurrent);
234 commonCombo->clear(); 241 commonCombo->clear();
235 if (cfg.readEntry("Commands Set","FALSE") == "FALSE") { 242 if (cfg.readEntry("Commands Set","FALSE") == "FALSE") {
236 for (int i = 0; commonCmds[i] != NULL; i++) { 243 for (int i = 0; commonCmds[i] != NULL; i++) {
237 commonCombo->insertItem(commonCmds[i],i); 244 commonCombo->insertItem(commonCmds[i],i);
238 } 245 }
239 } else { 246 } else {
240 for (int i = 0; i < 100; i++) { 247 for (int i = 0; i < 100; i++) {
241 if (!(cfg.readEntry( QString::number(i),"")).isEmpty()) 248 if (!(cfg.readEntry( QString::number(i),"")).isEmpty())
242 commonCombo->insertItem((cfg.readEntry( QString::number(i),""))); 249 commonCombo->insertItem((cfg.readEntry( QString::number(i),"")));
243 } 250 }
244 } 251 }
245 252
246} 253}
247 254
248void Konsole::init(const char* _pgm, QStrList & _args) 255void Konsole::init(const char* _pgm, QStrList & _args)
249{ 256{
250 b_scroll = TRUE; // histon; 257 b_scroll = TRUE; // histon;
251 n_keytab = 0; 258 n_keytab = 0;
252 n_render = 0; 259 n_render = 0;
253 startUp=0; 260 startUp=0;
254 fromMenu = FALSE; 261 fromMenu = FALSE;
255 262
256 setCaption( tr("Terminal") ); 263 setCaption( tr("Terminal") );
257 setIcon( Resource::loadPixmap( "konsole" ) ); 264 setIcon( Resource::loadPixmap( "konsole" ) );
258 265
259 Config cfg("Konsole"); 266 Config cfg("Konsole");
260 cfg.setGroup("Konsole"); 267 cfg.setGroup("Konsole");
261 QString tmp; 268 QString tmp;
262 // initialize the list of allowed fonts /////////////////////////////////// 269 // initialize the list of allowed fonts ///////////////////////////////////
263 cfont = cfg.readNumEntry("FontID", 1); 270 cfont = cfg.readNumEntry("FontID", 1);
271
264 QFont f = QFont("Micro", 4, QFont::Normal); 272 QFont f = QFont("Micro", 4, QFont::Normal);
265 f.setFixedPitch(TRUE); 273 f.setFixedPitch(TRUE);
266 fonts.append(new VTFont(tr("Micro"), f)); 274 fonts.append(new VTFont(tr("Micro"), f));
267 275
268 f = QFont("Fixed", 7, QFont::Normal); 276 f = QFont("Fixed", 7, QFont::Normal);
269 f.setFixedPitch(TRUE); 277 f.setFixedPitch(TRUE);
270 fonts.append(new VTFont(tr("Small Fixed"), f)); 278 fonts.append(new VTFont(tr("Small Fixed"), f));
271 279
272 f = QFont("Fixed", 12, QFont::Normal); 280 f = QFont("Fixed", 12, QFont::Normal);
273 f.setFixedPitch(TRUE); 281 f.setFixedPitch(TRUE);
274 fonts.append(new VTFont(tr("Medium Fixed"), f)); 282 fonts.append(new VTFont(tr("Medium Fixed"), f));
275 283
276 // create terminal emulation framework //////////////////////////////////// 284// NEW STUFF
285
286 QStringList ignfont = cfg.readListEntry("IgnFont", ',');
287 /* If there is no "IgnFont = ..." entry in "myonsole.conf",
288 * put some Japanese fonts of the SL-C7x0 to "ignfont". */
289
290 if (ignfont.isEmpty()) {
291 ignfont = QStringList::split (',',"jisupasp,mmkjg1,mmkjg4,mmkjg5");
292 }
293
294 //QFont
295 f = QFont("Fixed", 16, QFont::Normal);
296 f.setFixedPitch(true);
297 fonts.append(new VTFont(tr("Default"), f));
298
299 int fcount = 1;
300
301 f.setCharSet(QFont::AnyCharSet);
302 f.setStyleHint(QFont::TypeWriter, QFont::PreferMatch);
303// f.setWeight(QFont::Normal);
304
305 /*
306 * Look for installed font families. If the family is not in
307 * the "ignfont" list, look for available sizes.
308 * If it is fixed pitch font, put the font and the size
309 * to the fontlist.
310 */
311 QFontDatabase fdb;
312 QStringList ff = fdb.families(false);
313
314 for (QStringList::Iterator it = ff.begin(); it != ff.end(); ++it ) {
315 QString fit = *it;
316
317 if( fit != "fixed" && fit != "micro" ) {
318 if ( ignfont.contains(*it) == 0) {
319 QValueList<int> pt = fdb.pointSizes(*it);
320
321 for (QValueList<int>::Iterator itv = pt.begin();
322 itv != pt.end(); ++itv ) {
323 int size = (*itv)/10;
324 if(size > 0) {
325 f.setFamily(*it);
326 f.setPointSize(size);
327 }
328
329 QFontMetrics fm(f);
330
331//qDebug("%s %d:\twidth('i')=%d, width('w')=%d", (*it).latin1(), (*itv)/10, fm.width('i'), fm.width('w'));
332
333 if (fm.width('i') == fm.width('w') ) {
334 qDebug((*it));
335 f.setFixedPitch(true);
336 fonts.append(new VTFont(*it + ' ' + QString::number(size), f));
337 fcount++;
338 }
339 }
340 }
341 }
342 }
343
344// END NEW STUFF
345
346
347// create terminal emulation framework ////////////////////////////////////
277 nsessions = 0; 348 nsessions = 0;
278 349
279 tab = new EKNumTabWidget(this); 350 tab = new EKNumTabWidget(this);
280 351
281 connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*))); 352 connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*)));
282 353
283 // create terminal toolbar //////////////////////////////////////////////// 354 // create terminal toolbar ////////////////////////////////////////////////
284 setToolBarsMovable( FALSE ); 355 setToolBarsMovable( FALSE );
285 QToolBar *menuToolBar = new QToolBar( this ); 356 QToolBar *menuToolBar = new QToolBar( this );
286 menuToolBar->setHorizontalStretchable( TRUE ); 357 menuToolBar->setHorizontalStretchable( TRUE );
287 358
288 QMenuBar *menuBar = new QMenuBar( menuToolBar ); 359 QMenuBar *menuBar = new QMenuBar( menuToolBar );
289 360
290 fontList = new QPopupMenu( this ); 361 fontList = new QPopupMenu( this );
291 for(uint i = 0; i < fonts.count(); i++) { 362 for(uint i = 0; i < fonts.count(); i++) {
292 VTFont *fnt = fonts.at(i); 363 VTFont *fnt = fonts.at(i);
293 fontList->insertItem(fnt->getName(), i); 364 fontList->insertItem(fnt->getName(), i);
294 } 365 }
366
295 fontChanged(cfont); 367 fontChanged(cfont);
296 368
297 configMenu = new QPopupMenu( this); 369 configMenu = new QPopupMenu( this);
298 colorMenu = new QPopupMenu( this); 370 colorMenu = new QPopupMenu( this);
299 scrollMenu = new QPopupMenu( this); 371 scrollMenu = new QPopupMenu( this);
300 editCommandListMenu = new QPopupMenu( this); 372 editCommandListMenu = new QPopupMenu( this);
301 373
302 configMenu->insertItem(tr("Command List"), editCommandListMenu); 374 configMenu->insertItem(tr("Command List"), editCommandListMenu);
303 375
304 bool listHidden; 376 bool listHidden;
305 cfg.setGroup("Menubar"); 377 cfg.setGroup("Menubar");
306 if( cfg.readEntry("Hidden","FALSE") == "TRUE") { 378 if( cfg.readEntry("Hidden","FALSE") == "TRUE") {
307 editCommandListMenu->insertItem( tr( "Show command list" )); 379 editCommandListMenu->insertItem( tr( "Show command list" ));
308 listHidden=TRUE; 380 listHidden=TRUE;
309 } else { 381 } else {
310 editCommandListMenu->insertItem( tr( "Hide command list" )); 382 editCommandListMenu->insertItem( tr( "Hide command list" ));
311 listHidden=FALSE; 383 listHidden=FALSE;
312 } 384 }
313 385
314 cfg.setGroup("Tabs"); 386 cfg.setGroup("Tabs");
315 tmp=cfg.readEntry("Position","Bottom"); 387 tmp=cfg.readEntry("Position","Bottom");
316 if(tmp=="Top") { 388 if(tmp=="Top") {
317 tab->setTabPosition(QTabWidget::Top); 389 tab->setTabPosition(QTabWidget::Top);
318 configMenu->insertItem( tr( "Tabs on Bottom" ) ); 390 configMenu->insertItem( tr( "Tabs on Bottom" ) );
319 } else { 391 } else {
320 tab->setTabPosition(QTabWidget::Bottom); 392 tab->setTabPosition(QTabWidget::Bottom);
321 configMenu->insertItem(tr("Tabs on Top")); 393 configMenu->insertItem(tr("Tabs on Top"));
322 } 394 }
323 configMenu->insertSeparator(2); 395 configMenu->insertSeparator(2);
324 396
325 colorMenu->insertItem(tr( "Green on Black")); 397 colorMenu->insertItem(tr( "Green on Black"));
326 colorMenu->insertItem(tr( "Black on White")); 398 colorMenu->insertItem(tr( "Black on White"));
327 colorMenu->insertItem(tr( "White on Black")); 399 colorMenu->insertItem(tr( "White on Black"));
328 colorMenu->insertItem(tr( "Black on Transparent")); 400 colorMenu->insertItem(tr( "Black on Transparent"));
329 colorMenu->insertItem(tr( "Black on Red")); 401 colorMenu->insertItem(tr( "Black on Red"));
330 colorMenu->insertItem(tr( "Red on Black")); 402 colorMenu->insertItem(tr( "Red on Black"));
331 colorMenu->insertItem(tr( "Green on Yellow")); 403 colorMenu->insertItem(tr( "Green on Yellow"));
332 colorMenu->insertItem(tr( "Blue on Magenta")); 404 colorMenu->insertItem(tr( "Blue on Magenta"));
333 colorMenu->insertItem(tr( "Magenta on Blue")); 405 colorMenu->insertItem(tr( "Magenta on Blue"));
334 colorMenu->insertItem(tr( "Cyan on White")); 406 colorMenu->insertItem(tr( "Cyan on White"));
335 colorMenu->insertItem(tr( "White on Cyan")); 407 colorMenu->insertItem(tr( "White on Cyan"));
336 colorMenu->insertItem(tr( "Blue on Black")); 408 colorMenu->insertItem(tr( "Blue on Black"));
337 colorMenu->insertItem(tr( "Amber on Black")); 409 colorMenu->insertItem(tr( "Amber on Black"));
338 410
339#ifdef QT_QWS_OPIE 411#ifdef QT_QWS_OPIE
340 colorMenu->insertItem(tr( "Custom")); 412 colorMenu->insertItem(tr( "Custom"));
341#endif 413#endif
342 414
343 configMenu->insertItem( tr("Font"), fontList ); 415 configMenu->insertItem( tr("Font"), fontList );
344 configMenu->insertItem(tr( "Colors") ,colorMenu); 416 configMenu->insertItem(tr( "Colors") ,colorMenu);
345 417
346 connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) )); 418 connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) ));
347 connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) )); 419 connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) ));
348 connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuIsSelected(int) )); 420 connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuIsSelected(int) ));
349 connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int))); 421 connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int)));
350 connect(editCommandListMenu,SIGNAL(activated(int)),this,SLOT(editCommandListMenuSelected(int))); 422 connect(editCommandListMenu,SIGNAL(activated(int)),this,SLOT(editCommandListMenuSelected(int)));
351 423
352 menuBar->insertItem( tr("Options"), configMenu ); 424 menuBar->insertItem( tr("Options"), configMenu );
353 425
354 QToolBar *toolbar = new QToolBar( this ); 426 QToolBar *toolbar = new QToolBar( this );
355 427
356 QAction *a; 428 QAction *a;
357 429
358 // Button Commands 430 // Button Commands
359 a = new QAction( tr("New"), Resource::loadPixmap( "konsole" ), QString::null, 0, this, 0 ); 431 a = new QAction( tr("New"), Resource::loadPixmap( "konsole" ), QString::null, 0, this, 0 );
360 connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); a->addTo( toolbar ); 432 connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); a->addTo( toolbar );
361 a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 ); 433 a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 );
362 connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolbar ); 434 connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolbar );
363 a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 ); 435 a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 );
364 connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolbar ); 436 connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolbar );
365 a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 ); 437 a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 );
366 connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolbar ); 438 connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolbar );
367 a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 ); 439 a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 );
368 connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar ); 440 connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar );
369 a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 ); 441 a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 );
370 connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar ); 442 connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar );
371 a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); 443 a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 );
372 connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); a->addTo( toolbar ); 444 connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); a->addTo( toolbar );
373/* 445/*
374 a = new QAction( tr("Up"), Resource::loadPixmap( "up" ), QString::null, 0, this, 0 ); 446 a = new QAction( tr("Up"), Resource::loadPixmap( "up" ), QString::null, 0, this, 0 );
375 connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar ); 447 connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar );
376 a = new QAction( tr("Down"), Resource::loadPixmap( "down" ), QString::null, 0, this, 0 ); 448 a = new QAction( tr("Down"), Resource::loadPixmap( "down" ), QString::null, 0, this, 0 );
377 connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar ); 449 connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar );
378*/ 450*/
379 451
380 secondToolBar = new QToolBar( this ); 452 secondToolBar = new QToolBar( this );
381 secondToolBar->setHorizontalStretchable( TRUE ); 453 secondToolBar->setHorizontalStretchable( TRUE );
382 454
383 commonCombo = new QComboBox( secondToolBar ); 455 commonCombo = new QComboBox( secondToolBar );
384 commonCombo->setMaximumWidth(236); 456 commonCombo->setMaximumWidth(236);
385 457
386 editCommandListMenu->insertItem( tr( "Quick Edit" ) ); 458 editCommandListMenu->insertItem( tr( "Quick Edit" ) );
387 if( listHidden) { 459 if( listHidden) {
388 secondToolBar->hide(); 460 secondToolBar->hide();
389 editCommandListMenu->setItemEnabled(-23 ,FALSE); 461 editCommandListMenu->setItemEnabled(-23 ,FALSE);
390 } 462 }
391 editCommandListMenu->insertItem(tr( "Edit" ) ); 463 editCommandListMenu->insertItem(tr( "Edit" ) );
392 464
393 cfg.setGroup("Commands"); 465 cfg.setGroup("Commands");
394 commonCombo->setInsertionPolicy(QComboBox::AtCurrent); 466 commonCombo->setInsertionPolicy(QComboBox::AtCurrent);
395 467
396 initCommandList(); 468 initCommandList();
397// for (int i = 0; commonCmds[i] != NULL; i++) { 469// for (int i = 0; commonCmds[i] != NULL; i++) {
398// commonCombo->insertItem( commonCmds[i], i ); 470// commonCombo->insertItem( commonCmds[i], i );
399// tmp = cfg.readEntry( QString::number(i),""); 471// tmp = cfg.readEntry( QString::number(i),"");
400// if(tmp != "") 472// if(tmp != "")
401// commonCombo->changeItem( tmp,i ); 473// commonCombo->changeItem( tmp,i );
402// } 474// }
403 475
404 connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) )); 476 connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) ));
405 477
406 scrollMenu->insertItem(tr( "None" )); 478 scrollMenu->insertItem(tr( "None" ));
407 scrollMenu->insertItem(tr( "Left" )); 479 scrollMenu->insertItem(tr( "Left" ));
408 scrollMenu->insertItem(tr( "Right" )); 480 scrollMenu->insertItem(tr( "Right" ));
409// scrollMenu->insertSeparator(4); 481// scrollMenu->insertSeparator(4);
410// scrollMenu->insertItem(tr( "Horizontal" )); 482// scrollMenu->insertItem(tr( "Horizontal" ));
411 483
412 configMenu->insertItem(tr( "ScrollBar" ),scrollMenu); 484 configMenu->insertItem(tr( "ScrollBar" ),scrollMenu);
413 485
414 int jut = configMenu->insertItem(tr( "Wrap" )); 486 int jut = configMenu->insertItem(tr( "Wrap" ));
415 cfg.setGroup("ScrollBar"); 487 cfg.setGroup("ScrollBar");
416 configMenu->setItemChecked(jut, cfg.readBoolEntry("HorzScroll",0)); 488 configMenu->setItemChecked(jut, cfg.readBoolEntry("HorzScroll",0));
417 489
418 jut = configMenu->insertItem(tr( "Use Beep" )); 490 jut = configMenu->insertItem(tr( "Use Beep" ));
419 cfg.setGroup("Menubar"); 491 cfg.setGroup("Menubar");
420 492
421 configMenu->setItemChecked(jut, cfg.readBoolEntry("useBeep",0)); 493 configMenu->setItemChecked(jut, cfg.readBoolEntry("useBeep",0));
422 494
423 495
424//scrollMenuSelected(-29); 496//scrollMenuSelected(-29);
425// cfg.setGroup("ScrollBar"); 497// cfg.setGroup("ScrollBar");
426// if(cfg.readBoolEntry("HorzScroll",0)) { 498// if(cfg.readBoolEntry("HorzScroll",0)) {
427// if(cfg.readNumEntry("Position",2) == 0) 499// if(cfg.readNumEntry("Position",2) == 0)
428// te->setScrollbarLocation(1); 500// te->setScrollbarLocation(1);
429// else 501// else
430// te->setScrollbarLocation(0); 502// te->setScrollbarLocation(0);
431// te->setScrollbarLocation( cfg.readNumEntry("Position",2)); 503// te->setScrollbarLocation( cfg.readNumEntry("Position",2));
432// te->setWrapAt(120); 504// te->setWrapAt(120);
433// } 505// }
434 // create applications ///////////////////////////////////////////////////// 506 // create applications /////////////////////////////////////////////////////
435 setCentralWidget(tab); 507 setCentralWidget(tab);
436 508
437 // load keymaps //////////////////////////////////////////////////////////// 509 // load keymaps ////////////////////////////////////////////////////////////
438 KeyTrans::loadAll(); 510 KeyTrans::loadAll();
439 for (int i = 0; i < KeyTrans::count(); i++) 511 for (int i = 0; i < KeyTrans::count(); i++)
440 { KeyTrans* s = KeyTrans::find(i); 512 { KeyTrans* s = KeyTrans::find(i);
441 assert( s ); 513 assert( s );
442 } 514 }
443 515
444 se_pgm = _pgm; 516 se_pgm = _pgm;
445 se_args = _args; 517 se_args = _args;
446 se_args.prepend("--login"); 518 se_args.prepend("--login");
447parseCommandLine(); 519parseCommandLine();
448 // read and apply default values /////////////////////////////////////////// 520 // read and apply default values ///////////////////////////////////////////
449 resize(321, 321); // Dummy. 521 resize(321, 321); // Dummy.
450 QSize currentSize = size(); 522 QSize currentSize = size();
451 if (currentSize != size()) 523 if (currentSize != size())
452 defaultSize = size(); 524 defaultSize = size();
453} 525}
454 526
455void Konsole::show() 527void Konsole::show()
456{ 528{
457 if ( !nsessions ) { 529 if ( !nsessions ) {
458 newSession(); 530 newSession();
459 } 531 }
460 QMainWindow::show(); 532 QMainWindow::show();
461 533
462} 534}
463 535
464void Konsole::initSession(const char*, QStrList &) 536void Konsole::initSession(const char*, QStrList &)
465{ 537{
466 QMainWindow::show(); 538 QMainWindow::show();
467} 539}
468 540
469Konsole::~Konsole() 541Konsole::~Konsole()
470{ 542{
471 while (nsessions > 0) { 543 while (nsessions > 0) {
472 doneSession(getTe()->currentSession, 0); 544 doneSession(getTe()->currentSession, 0);
473 } 545 }
474 546
475 Config cfg("Konsole"); 547 Config cfg("Konsole");
476 cfg.setGroup("Konsole"); 548 cfg.setGroup("Konsole");
477 cfg.writeEntry("FontID", cfont); 549 cfg.writeEntry("FontID", cfont);
478} 550}
479 551
480void Konsole::fontChanged(int f) 552void Konsole::fontChanged(int f)
481{ 553{
482 VTFont* font = fonts.at(f); 554 VTFont* font = fonts.at(f);
483 if (font != 0) { 555 if (font != 0) {
484 for(uint i = 0; i < fonts.count(); i++) { 556 for(uint i = 0; i < fonts.count(); i++) {
485 fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE); 557 fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE);
486 } 558 }
487 559
488 cfont = f; 560 cfont = f;
489 561
490 TEWidget* te = getTe(); 562 TEWidget* te = getTe();
491 if (te != 0) { 563 if (te != 0) {
492 te->setVTFont(font->getFont()); 564 te->setVTFont(font->getFont());
493 } 565 }
494 } 566 }
495} 567}
496 568
497 569
498void Konsole::enterCommand(int c) 570void Konsole::enterCommand(int c)
499{ 571{
500 TEWidget* te = getTe(); 572 TEWidget* te = getTe();
501 if (te != 0) { 573 if (te != 0) {
502 if(!commonCombo->editable()) { 574 if(!commonCombo->editable()) {
503 QString text = commonCombo->text(c); //commonCmds[c]; 575 QString text = commonCombo->text(c); //commonCmds[c];
504 te->emitText(text); 576 te->emitText(text);
505 } else { 577 } else {
506 changeCommand( commonCombo->text(c), c); 578 changeCommand( commonCombo->text(c), c);
507 } 579 }
508 } 580 }
509} 581}
510 582
511void Konsole::hitEnter() 583void Konsole::hitEnter()
512{ 584{
513 TEWidget* te = getTe(); 585 TEWidget* te = getTe();
514 if (te != 0) { 586 if (te != 0) {
515 te->emitText(QString("\r")); 587 te->emitText(QString("\r"));
516 } 588 }
517} 589}
518 590
519void Konsole::hitSpace() 591void Konsole::hitSpace()
520{ 592{
521 TEWidget* te = getTe(); 593 TEWidget* te = getTe();
522 if (te != 0) { 594 if (te != 0) {
523 te->emitText(QString(" ")); 595 te->emitText(QString(" "));
524 } 596 }
525} 597}
526 598
527void Konsole::hitTab() 599void Konsole::hitTab()
528{ 600{
529 TEWidget* te = getTe(); 601 TEWidget* te = getTe();
530 if (te != 0) { 602 if (te != 0) {
531 te->emitText(QString("\t")); 603 te->emitText(QString("\t"));
532 } 604 }
533} 605}
534 606
535void Konsole::hitPaste() 607void Konsole::hitPaste()
536{ 608{
537 TEWidget* te = getTe(); 609 TEWidget* te = getTe();
538 if (te != 0) { 610 if (te != 0) {
539 te->pasteClipboard(); 611 te->pasteClipboard();
540 } 612 }
541} 613}
542 614
543void Konsole::hitUp() 615void Konsole::hitUp()
544{ 616{
545 TEWidget* te = getTe(); 617 TEWidget* te = getTe();
546 if (te != 0) { 618 if (te != 0) {
547 QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Up, 0, 0); 619 QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Up, 0, 0);
548 QApplication::sendEvent( te, &ke ); 620 QApplication::sendEvent( te, &ke );
549 } 621 }
550} 622}
551 623
552void Konsole::hitDown() 624void Konsole::hitDown()
553{ 625{
554 TEWidget* te = getTe(); 626 TEWidget* te = getTe();
555 if (te != 0) { 627 if (te != 0) {
556 QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Down, 0, 0); 628 QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Down, 0, 0);
557 QApplication::sendEvent( te, &ke ); 629 QApplication::sendEvent( te, &ke );
558 } 630 }
559} 631}
560 632
561/** 633/**
562 This function calculates the size of the external widget 634 This function calculates the size of the external widget
563 needed for the internal widget to be 635 needed for the internal widget to be
564 */ 636 */
565QSize Konsole::calcSize(int columns, int lines) { 637QSize Konsole::calcSize(int columns, int lines) {
566 TEWidget* te = getTe(); 638 TEWidget* te = getTe();
567 if (te != 0) { 639 if (te != 0) {
568 QSize size = te->calcSize(columns, lines); 640 QSize size = te->calcSize(columns, lines);
569 return size; 641 return size;
570 } else { 642 } else {
571 QSize size; 643 QSize size;
572 return size; 644 return size;
573 } 645 }
574} 646}
575 647
576/** 648/**
577 sets application window to a size based on columns X lines of the te 649 sets application window to a size based on columns X lines of the te
578 guest widget. Call with (0,0) for setting default size. 650 guest widget. Call with (0,0) for setting default size.
579*/ 651*/
580 652
581void Konsole::setColLin(int columns, int lines) 653void Konsole::setColLin(int columns, int lines)
582{ 654{
583 qDebug("konsole::setColLin:: Columns %d", columns); 655 qDebug("konsole::setColLin:: Columns %d", columns);
584 656
585 if ((columns==0) || (lines==0)) 657 if ((columns==0) || (lines==0))
586 { 658 {
587 if (defaultSize.isEmpty()) // not in config file : set default value 659 if (defaultSize.isEmpty()) // not in config file : set default value
588 { 660 {
589 defaultSize = calcSize(80,24); 661 defaultSize = calcSize(80,24);
590 // notifySize(24,80); // set menu items (strange arg order !) 662 // notifySize(24,80); // set menu items (strange arg order !)
591 } 663 }
592 resize(defaultSize); 664 resize(defaultSize);
593 } else { 665 } else {
594 resize(calcSize(columns, lines)); 666 resize(calcSize(columns, lines));
595 // notifySize(lines,columns); // set menu items (strange arg order !) 667 // notifySize(lines,columns); // set menu items (strange arg order !)
596 } 668 }
597} 669}
598 670
599/* 671/*
600void Konsole::setFont(int fontno) 672void Konsole::setFont(int fontno)
601{ 673{
602 QFont f; 674 QFont f;
603 if (fontno == 0) 675 if (fontno == 0)
604 f = defaultFont = QFont( "Helvetica", 12 ); 676 f = defaultFont = QFont( "Helvetica", 12 );
605 else 677 else
606 if (fonts[fontno][0] == '-') 678 if (fonts[fontno][0] == '-')
607 f.setRawName( fonts[fontno] ); 679 f.setRawName( fonts[fontno] );
608 else 680 else
609 { 681 {
610 f.setFamily(fonts[fontno]); 682 f.setFamily(fonts[fontno]);
611 f.setRawMode( TRUE ); 683 f.setRawMode( TRUE );
612 } 684 }
613 if ( !f.exactMatch() && fontno != 0) 685 if ( !f.exactMatch() && fontno != 0)
614 { 686 {
615 QString msg = i18n("Font `%1' not found.\nCheck README.linux.console for help.").arg(fonts[fontno]); 687 QString msg = i18n("Font `%1' not found.\nCheck README.linux.console for help.").arg(fonts[fontno]);
616 QMessageBox(this, msg); 688 QMessageBox(this, msg);
617 return; 689 return;
618 } 690 }
619 if (se) se->setFontNo(fontno); 691 if (se) se->setFontNo(fontno);
620 te->setVTFont(f); 692 te->setVTFont(f);
621 n_font = fontno; 693 n_font = fontno;
622} 694}
623*/ 695*/
624 696
625// --| color selection |------------------------------------------------------- 697// --| color selection |-------------------------------------------------------
626 698
627void Konsole::changeColumns(int columns) 699void Konsole::changeColumns(int columns)
628{ //FIXME this seems to cause silliness when reset command is executed 700{
629// qDebug("change columns"); 701 //FIXME this seems to cause silliness when reset command is executed
630// TEWidget* te = getTe(); 702 // qDebug("change columns");
631// if (te != 0) { 703 // TEWidget* te = getTe();
632// setColLin(columns,te->Lines()); 704 // if (te != 0) {
633// te->update(); 705 // setColLin(columns,te->Lines());
634// } 706 // te->update();
707 // }
635} 708}
636 709
637//FIXME: If a child dies during session swap, 710//FIXME: If a child dies during session swap,
638// this routine might be called before 711// this routine might be called before
639// session swap is completed. 712// session swap is completed.
640 713
641void Konsole::doneSession(TESession*, int ) 714void Konsole::doneSession(TESession*, int )
642{ 715{
643 TEWidget *te = getTe(); 716 TEWidget *te = getTe();
644 if (te != 0) { 717 if (te != 0) {
645 te->currentSession->setConnect(FALSE); 718 te->currentSession->setConnect(FALSE);
646 tab->removeTab(te); 719 tab->removeTab(te);
647 delete te->currentSession; 720 delete te->currentSession;
648 delete te; 721 delete te;
649 nsessions--; 722 nsessions--;
650 } 723 }
651 724
652 if (nsessions == 0) { 725 if (nsessions == 0) {
653 close(); 726 close();
654 } 727 }
655} 728}
656 729
657void Konsole::newSession() { 730void Konsole::newSession() {
658 if(nsessions < 15) { // seems to be something weird about 16 tabs on the Zaurus.... memory? 731 if(nsessions < 15) { // seems to be something weird about 16 tabs on the Zaurus.... memory?
659 TEWidget* te = new TEWidget(tab); 732 TEWidget* te = new TEWidget(tab);
660 Config c("Konsole"); 733 Config c("Konsole");
661 c.setGroup("Menubar"); 734 c.setGroup("Menubar");
662 te->useBeep=c.readBoolEntry("useBeep",0); 735 te->useBeep=c.readBoolEntry("useBeep",0);
663 736
664// te->setBackgroundMode(PaletteBase); //we want transparent!! 737// te->setBackgroundMode(PaletteBase); //we want transparent!!
665 te->setVTFont(fonts.at(cfont)->getFont()); 738 te->setVTFont(fonts.at(cfont)->getFont());
666 tab->addTab(te); 739 tab->addTab(te);
667 TESession* se = new TESession(this, te, se_pgm, se_args, "xterm"); 740 TESession* se = new TESession(this, te, se_pgm, se_args, "xterm");
668 te->currentSession = se; 741 te->currentSession = se;
669 connect( se, SIGNAL(done(TESession*,int)), this, SLOT(doneSession(TESession*,int)) ); 742 connect( se, SIGNAL(done(TESession*,int)), this, SLOT(doneSession(TESession*,int)) );
670 se->run(); 743 se->run();
671 se->setConnect(TRUE); 744 se->setConnect(TRUE);
672 se->setHistory(b_scroll); 745 se->setHistory(b_scroll);
673 tab->setCurrentPage(nsessions); 746 tab->setCurrentPage(nsessions);
674 nsessions++; 747 nsessions++;
675 doWrap(); 748 doWrap();
676 setColor(); 749 setColor();
677 } 750 }
678} 751}
679 752
680TEWidget* Konsole::getTe() { 753TEWidget* Konsole::getTe() {
681 if (nsessions) { 754 if (nsessions) {
682 return (TEWidget *) tab->currentPage(); 755 return (TEWidget *) tab->currentPage();
683 } else { 756 } else {
684 return 0; 757 return 0;
685 } 758 }
686} 759}
687 760
688void Konsole::switchSession(QWidget* w) { 761void Konsole::switchSession(QWidget* w) {
689 TEWidget* te = (TEWidget *) w; 762 TEWidget* te = (TEWidget *) w;
690 763
691 QFont teFnt = te->getVTFont(); 764 QFont teFnt = te->getVTFont();
692 for(uint i = 0; i < fonts.count(); i++) { 765 for(uint i = 0; i < fonts.count(); i++) {
693 VTFont *fnt = fonts.at(i); 766 VTFont *fnt = fonts.at(i);
694 bool cf = fnt->getFont() == teFnt; 767 bool cf = fnt->getFont() == teFnt;
695 fontList->setItemChecked(i, cf); 768 fontList->setItemChecked(i, cf);
696 if (cf) { 769 if (cf) {
697 cfont = i; 770 cfont = i;
698 } 771 }
699 } 772 }
700} 773}
701 774
702void Konsole::colorMenuIsSelected(int iD) { 775void Konsole::colorMenuIsSelected(int iD) {
703 fromMenu = TRUE; 776 fromMenu = TRUE;
704 colorMenuSelected(iD); 777 colorMenuSelected(iD);
705} 778}
706 779
707/// ------------------------------- some new stuff by L.J. Potter 780/// ------------------------------- some new stuff by L.J. Potter
708void Konsole::colorMenuSelected(int iD) 781void Konsole::colorMenuSelected(int iD)
709{ // this is NOT pretty, elegant or anything else besides functional 782{ // this is NOT pretty, elegant or anything else besides functional
710// QString temp; 783// QString temp;
711// qDebug( temp.sprintf("colormenu %d", iD)); 784// qDebug( temp.sprintf("colormenu %d", iD));
712 785
713 TEWidget* te = getTe(); 786 TEWidget* te = getTe();
714 Config cfg("Konsole"); 787 Config cfg("Konsole");
715 cfg.setGroup("Colors"); 788 cfg.setGroup("Colors");
716// QColor foreground; 789// QColor foreground;
717// QColor background; 790// QColor background;
718 colorMenu->setItemChecked(lastSelectedMenu,FALSE); 791 colorMenu->setItemChecked(lastSelectedMenu,FALSE);
719 ColorEntry m_table[TABLE_COLORS]; 792 ColorEntry m_table[TABLE_COLORS];
720 const ColorEntry * defaultCt=te->getdefaultColorTable(); 793 const ColorEntry * defaultCt=te->getdefaultColorTable();
721 /////////// fore back 794 /////////// fore back
722 int i; 795 int i;
723 if(iD==-9) { // default default 796 if(iD==-9) { // default default
724 for (i = 0; i < TABLE_COLORS; i++) { 797 for (i = 0; i < TABLE_COLORS; i++) {
725 m_table[i].color = defaultCt[i].color; 798 m_table[i].color = defaultCt[i].color;
726 if(i==1 || i == 11) 799 if(i==1 || i == 11)
727 m_table[i].transparent=1; 800 m_table[i].transparent=1;
728 cfg.writeEntry("Schema","9"); 801 cfg.writeEntry("Schema","9");
729 colorMenu->setItemChecked(-9,TRUE); 802 colorMenu->setItemChecked(-9,TRUE);
730 } 803 }
731 } else { 804 } else {
732 if(iD==-6) { // green black 805 if(iD==-6) { // green black
733 foreground.setRgb(0x18,255,0x18); 806 foreground.setRgb(0x18,255,0x18);
734 background.setRgb(0x00,0x00,0x00); 807 background.setRgb(0x00,0x00,0x00);
735 cfg.writeEntry("Schema","6"); 808 cfg.writeEntry("Schema","6");
736 colorMenu->setItemChecked(-6,TRUE); 809 colorMenu->setItemChecked(-6,TRUE);
737 } 810 }
738 if(iD==-7) { // black white 811 if(iD==-7) { // black white
739 foreground.setRgb(0x00,0x00,0x00); 812 foreground.setRgb(0x00,0x00,0x00);
740 background.setRgb(0xFF,0xFF,0xFF); 813 background.setRgb(0xFF,0xFF,0xFF);
741 cfg.writeEntry("Schema","7"); 814 cfg.writeEntry("Schema","7");
742 colorMenu->setItemChecked(-7,TRUE); 815 colorMenu->setItemChecked(-7,TRUE);
743 } 816 }
744 if(iD==-8) { // white black 817 if(iD==-8) { // white black
745 foreground.setRgb(0xFF,0xFF,0xFF); 818 foreground.setRgb(0xFF,0xFF,0xFF);
746 background.setRgb(0x00,0x00,0x00); 819 background.setRgb(0x00,0x00,0x00);
747 cfg.writeEntry("Schema","8"); 820 cfg.writeEntry("Schema","8");
748 colorMenu->setItemChecked(-8,TRUE); 821 colorMenu->setItemChecked(-8,TRUE);
749 } 822 }
750 if(iD==-10) {// Black, Red 823 if(iD==-10) {// Black, Red
751 foreground.setRgb(0x00,0x00,0x00); 824 foreground.setRgb(0x00,0x00,0x00);
752 background.setRgb(0xB2,0x18,0x18); 825 background.setRgb(0xB2,0x18,0x18);
753 cfg.writeEntry("Schema","10"); 826 cfg.writeEntry("Schema","10");
754 colorMenu->setItemChecked(-10,TRUE); 827 colorMenu->setItemChecked(-10,TRUE);
755 } 828 }
756 if(iD==-11) {// Red, Black 829 if(iD==-11) {// Red, Black
757 foreground.setRgb(230,31,31); //0xB2,0x18,0x18 830 foreground.setRgb(230,31,31); //0xB2,0x18,0x18
758 background.setRgb(0x00,0x00,0x00); 831 background.setRgb(0x00,0x00,0x00);
759 cfg.writeEntry("Schema","11"); 832 cfg.writeEntry("Schema","11");
760 colorMenu->setItemChecked(-11,TRUE); 833 colorMenu->setItemChecked(-11,TRUE);
761 } 834 }
762 if(iD==-12) {// Green, Yellow - is ugly 835 if(iD==-12) {// Green, Yellow - is ugly
763// foreground.setRgb(0x18,0xB2,0x18); 836// foreground.setRgb(0x18,0xB2,0x18);
764 foreground.setRgb(36,139,10); 837 foreground.setRgb(36,139,10);
765// background.setRgb(0xB2,0x68,0x18); 838// background.setRgb(0xB2,0x68,0x18);
766 background.setRgb(255,255,0); 839 background.setRgb(255,255,0);
767 cfg.writeEntry("Schema","12"); 840 cfg.writeEntry("Schema","12");
768 colorMenu->setItemChecked(-12,TRUE); 841 colorMenu->setItemChecked(-12,TRUE);
769 } 842 }
770 if(iD==-13) {// Blue, Magenta 843 if(iD==-13) {// Blue, Magenta
771 foreground.setRgb(0x18,0xB2,0xB2); 844 foreground.setRgb(0x18,0xB2,0xB2);
772 background.setRgb(0x18,0x18,0xB2); 845 background.setRgb(0x18,0x18,0xB2);
773 cfg.writeEntry("Schema","13"); 846 cfg.writeEntry("Schema","13");
774 colorMenu->setItemChecked(-13,TRUE); 847 colorMenu->setItemChecked(-13,TRUE);
775 } 848 }
776 if(iD==-14) {// Magenta, Blue 849 if(iD==-14) {// Magenta, Blue
777 foreground.setRgb(0x18,0x18,0xB2); 850 foreground.setRgb(0x18,0x18,0xB2);
778 background.setRgb(0x18,0xB2,0xB2); 851 background.setRgb(0x18,0xB2,0xB2);
779 cfg.writeEntry("Schema","14"); 852 cfg.writeEntry("Schema","14");
780 colorMenu->setItemChecked(-14,TRUE); 853 colorMenu->setItemChecked(-14,TRUE);
781 } 854 }
782 if(iD==-15) {// Cyan, White 855 if(iD==-15) {// Cyan, White
783 foreground.setRgb(0x18,0xB2,0xB2); 856 foreground.setRgb(0x18,0xB2,0xB2);
784 background.setRgb(0xFF,0xFF,0xFF); 857 background.setRgb(0xFF,0xFF,0xFF);
785 cfg.writeEntry("Schema","15"); 858 cfg.writeEntry("Schema","15");
786 colorMenu->setItemChecked(-15,TRUE); 859 colorMenu->setItemChecked(-15,TRUE);
787 } 860 }
788 if(iD==-16) {// White, Cyan 861 if(iD==-16) {// White, Cyan
789 background.setRgb(0x18,0xB2,0xB2); 862 background.setRgb(0x18,0xB2,0xB2);
790 foreground.setRgb(0xFF,0xFF,0xFF); 863 foreground.setRgb(0xFF,0xFF,0xFF);
791 cfg.writeEntry("Schema","16"); 864 cfg.writeEntry("Schema","16");
792 colorMenu->setItemChecked(-16,TRUE); 865 colorMenu->setItemChecked(-16,TRUE);
793 } 866 }
794 if(iD==-17) {// Black, Blue 867 if(iD==-17) {// Black, Blue
795 background.setRgb(0x00,0x00,0x00); 868 background.setRgb(0x00,0x00,0x00);
796 foreground.setRgb(0x18,0xB2,0xB2); 869 foreground.setRgb(0x18,0xB2,0xB2);
797 cfg.writeEntry("Schema","17"); 870 cfg.writeEntry("Schema","17");
798 colorMenu->setItemChecked(-17,TRUE); 871 colorMenu->setItemChecked(-17,TRUE);
799 } 872 }
800 if(iD==-18) {// Black, Gold 873 if(iD==-18) {// Black, Gold
801 background.setRgb(0x00,0x00,0x00); 874 background.setRgb(0x00,0x00,0x00);
802 foreground.setRgb(255,215,0); 875 foreground.setRgb(255,215,0);
803 cfg.writeEntry("Schema","18"); 876 cfg.writeEntry("Schema","18");
804 colorMenu->setItemChecked(-18,TRUE); 877 colorMenu->setItemChecked(-18,TRUE);
805 } 878 }
806#ifdef QT_QWS_OPIE 879#ifdef QT_QWS_OPIE
807 if(iD==-19) { 880 if(iD==-19) {
808// Custom 881// Custom
809 qDebug("do custom"); 882 qDebug("do custom");
810 if(fromMenu) { 883 if(fromMenu) {
811 OColorPopupMenu* penColorPopupMenu = new OColorPopupMenu(Qt::black, this, "foreground color"); 884 OColorPopupMenu* penColorPopupMenu = new OColorPopupMenu(Qt::black, this, "foreground color");
812 connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, 885 connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this,
813 SLOT(changeForegroundColor(const QColor&))); 886 SLOT(changeForegroundColor(const QColor&)));
814 penColorPopupMenu->exec(); 887 penColorPopupMenu->exec();
815 } 888 }
816 cfg.writeEntry("Schema","19"); 889 cfg.writeEntry("Schema","19");
817 if(!fromMenu) { 890 if(!fromMenu) {
818 foreground.setNamedColor(cfg.readEntry("foreground","")); 891 foreground.setNamedColor(cfg.readEntry("foreground",""));
819 background.setNamedColor(cfg.readEntry("background","")); 892 background.setNamedColor(cfg.readEntry("background",""));
820 } 893 }
821 fromMenu=FALSE; 894 fromMenu=FALSE;
822 colorMenu->setItemChecked(-19,TRUE); 895 colorMenu->setItemChecked(-19,TRUE);
823 } 896 }
824#endif 897#endif
825 for (i = 0; i < TABLE_COLORS; i++) { 898 for (i = 0; i < TABLE_COLORS; i++) {
826 if(i==0 || i == 10) { 899 if(i==0 || i == 10) {
827 m_table[i].color = foreground; 900 m_table[i].color = foreground;
828 } 901 }
829 else if(i==1 || i == 11) { 902 else if(i==1 || i == 11) {
830 m_table[i].color = background; m_table[i].transparent=0; 903 m_table[i].color = background; m_table[i].transparent=0;
831 } 904 }
832 else 905 else
833 m_table[i].color = defaultCt[i].color; 906 m_table[i].color = defaultCt[i].color;
834 } 907 }
835 } 908 }
836 lastSelectedMenu = iD; 909 lastSelectedMenu = iD;
837 te->setColorTable(m_table); 910 te->setColorTable(m_table);
838 update(); 911 update();
839 912
840} 913}
841 914
842void Konsole::configMenuSelected(int iD) 915void Konsole::configMenuSelected(int iD)
843{ 916{
844// QString temp; 917// QString temp;
845// qDebug( temp.sprintf("configmenu %d",iD)); 918// qDebug( temp.sprintf("configmenu %d",iD));
846 919
847 TEWidget* te = getTe(); 920 TEWidget* te = getTe();
848 Config cfg("Konsole"); 921 Config cfg("Konsole");
849 cfg.setGroup("Menubar"); 922 cfg.setGroup("Menubar");
850 int i,j; 923 int i,j;
851#ifdef QT_QWS_OPIE 924#ifdef QT_QWS_OPIE
852 i=-29;j=-30; 925 i=-29;j=-30;
853#else 926#else
854 i=-28;j=-29; 927 i=-28;j=-29;
855#endif 928#endif
856 929
857 if(iD == -4) { 930 if(iD == -4) {
858 cfg.setGroup("Tabs"); 931 cfg.setGroup("Tabs");
859 QString tmp=cfg.readEntry("Position","Bottom"); 932 QString tmp=cfg.readEntry("Position","Bottom");
860 933
861 if(tmp=="Top") { 934 if(tmp=="Top") {
862 tab->setTabPosition(QTabWidget::Bottom); 935 tab->setTabPosition(QTabWidget::Bottom);
863 configMenu->changeItem( iD, tr("Tabs on Top")); 936 configMenu->changeItem( iD, tr("Tabs on Top"));
864 cfg.writeEntry("Position","Bottom"); 937 cfg.writeEntry("Position","Bottom");
865 } else { 938 } else {
866 tab->setTabPosition(QTabWidget::Top); 939 tab->setTabPosition(QTabWidget::Top);
867 configMenu->changeItem( iD, tr("Tabs on Bottom")); 940 configMenu->changeItem( iD, tr("Tabs on Bottom"));
868 cfg.writeEntry("Position","Top"); 941 cfg.writeEntry("Position","Top");
869 } 942 }
870 } 943 }
871 if(iD == i) { 944 if(iD == i) {
872 cfg.setGroup("ScrollBar"); 945 cfg.setGroup("ScrollBar");
873 bool b=cfg.readBoolEntry("HorzScroll",0); 946 bool b=cfg.readBoolEntry("HorzScroll",0);
874 b=!b; 947 b=!b;
875 cfg.writeEntry("HorzScroll", b ); 948 cfg.writeEntry("HorzScroll", b );
876 cfg.write(); 949 cfg.write();
877 doWrap(); 950 doWrap();
878 if(cfg.readNumEntry("Position",2) == 0) { 951 if(cfg.readNumEntry("Position",2) == 0) {
879 te->setScrollbarLocation(1); 952 te->setScrollbarLocation(1);
880 } else { 953 } else {
881 te->setScrollbarLocation(0); 954 te->setScrollbarLocation(0);
882 } 955 }
883 te->setScrollbarLocation( cfg.readNumEntry("Position",2)); 956 te->setScrollbarLocation( cfg.readNumEntry("Position",2));
884 } 957 }
885 if(iD == j) { 958 if(iD == j) {
886 cfg.setGroup("Menubar"); 959 cfg.setGroup("Menubar");
887 bool b=cfg.readBoolEntry("useBeep",0); 960 bool b=cfg.readBoolEntry("useBeep",0);
888 b=!b; 961 b=!b;
889 cfg.writeEntry("useBeep", b ); 962 cfg.writeEntry("useBeep", b );
890 cfg.write(); 963 cfg.write();
891 configMenu->setItemChecked(j,b); 964 configMenu->setItemChecked(j,b);
892 te->useBeep=b; 965 te->useBeep=b;
893 } 966 }
894} 967}
895 968
896void Konsole::changeCommand(const QString &text, int c) 969void Konsole::changeCommand(const QString &text, int c)
897{ 970{
898 Config cfg("Konsole"); 971 Config cfg("Konsole");
899 cfg.setGroup("Commands"); 972 cfg.setGroup("Commands");
900 if(commonCmds[c] != text) { 973 if(commonCmds[c] != text) {
901 cfg.writeEntry(QString::number(c),text); 974 cfg.writeEntry(QString::number(c),text);
902 commonCombo->clearEdit(); 975 commonCombo->clearEdit();
903 commonCombo->setCurrentItem(c); 976 commonCombo->setCurrentItem(c);
904 } 977 }
905} 978}
906 979
907void Konsole::setColor() 980void Konsole::setColor()
908{ 981{
909 Config cfg("Konsole"); 982 Config cfg("Konsole");
910 cfg.setGroup("Colors"); 983 cfg.setGroup("Colors");
911 int scheme = cfg.readNumEntry("Schema",1); 984 int scheme = cfg.readNumEntry("Schema",1);
912 if(scheme != 1) colorMenuSelected( -scheme); 985 if(scheme != 1) colorMenuSelected( -scheme);
913} 986}
914 987
915void Konsole::scrollMenuSelected(int index) 988void Konsole::scrollMenuSelected(int index)
916{ 989{
917// qDebug( "scrollbar menu %d",index); 990// qDebug( "scrollbar menu %d",index);
918 991
919 TEWidget* te = getTe(); 992 TEWidget* te = getTe();
920 Config cfg("Konsole"); 993 Config cfg("Konsole");
921 cfg.setGroup("ScrollBar"); 994 cfg.setGroup("ScrollBar");
922 int i,j,k; 995 int i,j,k;
923#ifdef QT_QWS_OPIE 996#ifdef QT_QWS_OPIE
924i=-25;j=-26;k=-27; 997i=-25;j=-26;k=-27;
925#else 998#else
926i=-24;j=-25;k=-26; 999i=-24;j=-25;k=-26;
927#endif 1000#endif
928 if(index == i) { 1001 if(index == i) {
929 1002
930 te->setScrollbarLocation(0); 1003 te->setScrollbarLocation(0);
931 cfg.writeEntry("Position",0); 1004 cfg.writeEntry("Position",0);
932 } else if(index == j) { 1005 } else if(index == j) {
933 1006
934 te->setScrollbarLocation(1); 1007 te->setScrollbarLocation(1);
935 cfg.writeEntry("Position",1); 1008 cfg.writeEntry("Position",1);
936 } else if(index == k) { 1009 } else if(index == k) {
937 1010
938 te->setScrollbarLocation(2); 1011 te->setScrollbarLocation(2);
939 cfg.writeEntry("Position",2); 1012 cfg.writeEntry("Position",2);
940 } 1013 }
941 1014
942// case -29: { 1015// case -29: {
943// bool b=cfg.readBoolEntry("HorzScroll",0); 1016// bool b=cfg.readBoolEntry("HorzScroll",0);
944// cfg.writeEntry("HorzScroll", !b ); 1017// cfg.writeEntry("HorzScroll", !b );
945// cfg.write(); 1018// cfg.write();
946// if(cfg.readNumEntry("Position",2) == 0) { 1019// if(cfg.readNumEntry("Position",2) == 0) {
947// te->setScrollbarLocation(1); 1020// te->setScrollbarLocation(1);
948// te->setWrapAt(0); 1021// te->setWrapAt(0);
949// } else { 1022// } else {
950// te->setScrollbarLocation(0); 1023// te->setScrollbarLocation(0);
951// te->setWrapAt(120); 1024// te->setWrapAt(120);
952// } 1025// }
953// te->setScrollbarLocation( cfg.readNumEntry("Position",2)); 1026// te->setScrollbarLocation( cfg.readNumEntry("Position",2));
954// } 1027// }
955// break; 1028// break;
956} 1029}
957 1030
958void Konsole::editCommandListMenuSelected(int iD) 1031void Konsole::editCommandListMenuSelected(int iD)
959{ 1032{
960// QString temp; 1033// QString temp;
961// qDebug( temp.sprintf("edit command list %d",iD)); 1034// qDebug( temp.sprintf("edit command list %d",iD));
962 TEWidget* te = getTe(); 1035 TEWidget* te = getTe();
963 Config cfg("Konsole"); 1036 Config cfg("Konsole");
964 cfg.setGroup("Menubar"); 1037 cfg.setGroup("Menubar");
965 if( iD == -3) { 1038 if( iD == -3) {
966 if(!secondToolBar->isHidden()) { 1039 if(!secondToolBar->isHidden()) {
967 secondToolBar->hide(); 1040 secondToolBar->hide();
968 configMenu->changeItem( iD,tr( "Show Command List" )); 1041 configMenu->changeItem( iD,tr( "Show Command List" ));
969 cfg.writeEntry("Hidden","TRUE"); 1042 cfg.writeEntry("Hidden","TRUE");
970 configMenu->setItemEnabled(-23 ,FALSE); 1043 configMenu->setItemEnabled(-23 ,FALSE);
971 } else { 1044 } else {
972 secondToolBar->show(); 1045 secondToolBar->show();
973 configMenu->changeItem( iD,tr( "Hide Command List" )); 1046 configMenu->changeItem( iD,tr( "Hide Command List" ));
974 cfg.writeEntry("Hidden","FALSE"); 1047 cfg.writeEntry("Hidden","FALSE");
975 configMenu->setItemEnabled(-23 ,TRUE); 1048 configMenu->setItemEnabled(-23 ,TRUE);
976 1049
977 if(cfg.readEntry("EditEnabled","FALSE")=="TRUE") { 1050 if(cfg.readEntry("EditEnabled","FALSE")=="TRUE") {
978 configMenu->setItemChecked(-23,TRUE); 1051 configMenu->setItemChecked(-23,TRUE);
979 commonCombo->setEditable( TRUE ); 1052 commonCombo->setEditable( TRUE );
980 } else { 1053 } else {
981 configMenu->setItemChecked(-23,FALSE); 1054 configMenu->setItemChecked(-23,FALSE);
982 commonCombo->setEditable( FALSE ); 1055 commonCombo->setEditable( FALSE );
983 } 1056 }
984 } 1057 }
985 } 1058 }
986 if( iD == -23) { 1059 if( iD == -23) {
987 cfg.setGroup("Commands"); 1060 cfg.setGroup("Commands");
988// qDebug("enableCommandEdit"); 1061// qDebug("enableCommandEdit");
989 if( !configMenu->isItemChecked(iD) ) { 1062 if( !configMenu->isItemChecked(iD) ) {
990 commonCombo->setEditable( TRUE ); 1063 commonCombo->setEditable( TRUE );
991 configMenu->setItemChecked(iD,TRUE); 1064 configMenu->setItemChecked(iD,TRUE);
992 commonCombo->setCurrentItem(0); 1065 commonCombo->setCurrentItem(0);
993 cfg.writeEntry("EditEnabled","TRUE"); 1066 cfg.writeEntry("EditEnabled","TRUE");
994 } else { 1067 } else {
995 commonCombo->setEditable( FALSE ); 1068 commonCombo->setEditable( FALSE );
996 configMenu->setItemChecked(iD,FALSE); 1069 configMenu->setItemChecked(iD,FALSE);
997 cfg.writeEntry("EditEnabled","FALSE"); 1070 cfg.writeEntry("EditEnabled","FALSE");
998 commonCombo->setFocusPolicy(QWidget::NoFocus); 1071 commonCombo->setFocusPolicy(QWidget::NoFocus);
999 te->setFocus(); 1072 te->setFocus();
1000 } 1073 }
1001 } 1074 }
1002 if(iD == -24) { 1075 if(iD == -24) {
1003 // "edit commands" 1076 // "edit commands"
1004 CommandEditDialog *m = new CommandEditDialog(this); 1077 CommandEditDialog *m = new CommandEditDialog(this);
1005 connect(m,SIGNAL(commandsEdited()),this,SLOT(initCommandList())); 1078 connect(m,SIGNAL(commandsEdited()),this,SLOT(initCommandList()));
1006 m->showMaximized(); 1079 m->showMaximized();
1007 } 1080 }
1008 1081
1009} 1082}
1010 1083
1011// $QPEDIR/bin/qcop QPE/Application/embeddedkonsole 'setDocument(QString)' 'ssh -V' 1084// $QPEDIR/bin/qcop QPE/Application/embeddedkonsole 'setDocument(QString)' 'ssh -V'
1012void Konsole::setDocument( const QString &cmd) { 1085void Konsole::setDocument( const QString &cmd) {
1013 newSession(); 1086 newSession();
1014 TEWidget* te = getTe(); 1087 TEWidget* te = getTe();
1015 if(cmd.find("-e", 0, TRUE) != -1) { 1088 if(cmd.find("-e", 0, TRUE) != -1) {
1016 QString cmd2; 1089 QString cmd2;
1017 cmd2=cmd.right(cmd.length()-3)+" &"; 1090 cmd2=cmd.right(cmd.length()-3)+" &";
1018 system(cmd2.latin1()); 1091 system(cmd2.latin1());
1019 if(startUp <= 1 && nsessions < 2) { 1092 if(startUp <= 1 && nsessions < 2) {
1020 doneSession(getTe()->currentSession, 0); 1093 doneSession(getTe()->currentSession, 0);
1021 exit(0); 1094 exit(0);
1022 } else 1095 } else
1023 doneSession(getTe()->currentSession, 0); 1096 doneSession(getTe()->currentSession, 0);
1024 } else { 1097 } else {
1025 if (te != 0) { 1098 if (te != 0) {
1026 te->emitText(cmd+"\r"); 1099 te->emitText(cmd+"\r");
1027 } 1100 }
1028 } 1101 }
1029 startUp++; 1102 startUp++;
1030} 1103}
1031 1104
1032void Konsole::parseCommandLine() { 1105void Konsole::parseCommandLine() {
1033 QString cmd; 1106 QString cmd;
1034 // newSession(); 1107 // newSession();
1035 for (int i=1;i< qApp->argc();i++) { 1108 for (int i=1;i< qApp->argc();i++) {
1036 if( QString(qApp->argv()[i]) == "-e") { 1109 if( QString(qApp->argv()[i]) == "-e") {
1037 i++; 1110 i++;
1038 for ( int j=i;j< qApp->argc();j++) { 1111 for ( int j=i;j< qApp->argc();j++) {
1039 cmd+=QString(qApp->argv()[j])+" "; 1112 cmd+=QString(qApp->argv()[j])+" ";
1040 } 1113 }
1041 cmd.stripWhiteSpace(); 1114 cmd.stripWhiteSpace();
1042 system(cmd.latin1()); 1115 system(cmd.latin1());
1043 exit(0);//close(); 1116 exit(0);//close();
1044 } // end -e switch 1117 } // end -e switch
1045 } 1118 }
1046 startUp++; 1119 startUp++;
1047} 1120}
1048 1121
1049void Konsole::changeForegroundColor(const QColor &color) { 1122void Konsole::changeForegroundColor(const QColor &color) {
1050 Config cfg("Konsole"); 1123 Config cfg("Konsole");
1051 cfg.setGroup("Colors"); 1124 cfg.setGroup("Colors");
1052 int r, g, b; 1125 int r, g, b;
1053 color.rgb(&r,&g,&b); 1126 color.rgb(&r,&g,&b);
1054 foreground.setRgb(r,g,b); 1127 foreground.setRgb(r,g,b);
1055 1128
1056 cfg.writeEntry("foreground",color.name()); 1129 cfg.writeEntry("foreground",color.name());
1057 qDebug("foreground "+color.name()); 1130 qDebug("foreground "+color.name());
1058 cfg.write(); 1131 cfg.write();
1059 1132
1060qDebug("do other dialog"); 1133qDebug("do other dialog");
1061#ifdef QT_QWS_OPIE 1134#ifdef QT_QWS_OPIE
1062 1135
1063 OColorPopupMenu* penColorPopupMenu2 = new OColorPopupMenu(Qt::black, this,"background color"); 1136 OColorPopupMenu* penColorPopupMenu2 = new OColorPopupMenu(Qt::black, this,"background color");
1064 connect(penColorPopupMenu2, SIGNAL(colorSelected(const QColor&)), this, 1137 connect(penColorPopupMenu2, SIGNAL(colorSelected(const QColor&)), this,
1065 SLOT(changeBackgroundColor(const QColor&))); 1138 SLOT(changeBackgroundColor(const QColor&)));
1066 penColorPopupMenu2->exec(); 1139 penColorPopupMenu2->exec();
1067#endif 1140#endif
1068} 1141}
1069 1142
1070void Konsole::changeBackgroundColor(const QColor &color) { 1143void Konsole::changeBackgroundColor(const QColor &color) {
1071 1144
1072 qDebug("Change background"); 1145 qDebug("Change background");
1073 Config cfg("Konsole"); 1146 Config cfg("Konsole");
1074 cfg.setGroup("Colors"); 1147 cfg.setGroup("Colors");
1075 int r, g, b; 1148 int r, g, b;
1076 color.rgb(&r,&g,&b); 1149 color.rgb(&r,&g,&b);
1077 background.setRgb(r,g,b); 1150 background.setRgb(r,g,b);
1078 cfg.writeEntry("background",color.name()); 1151 cfg.writeEntry("background",color.name());
1079 qDebug("background "+color.name()); 1152 qDebug("background "+color.name());
1080 cfg.write(); 1153 cfg.write();
1081} 1154}
1082 1155
1083void Konsole::doWrap() { 1156void Konsole::doWrap() {
1084int i; 1157int i;
1085#ifdef QT_QWS_OPIE 1158#ifdef QT_QWS_OPIE
1086i=-29; 1159i=-29;
1087#else 1160#else
1088i=-28; 1161i=-28;
1089#endif 1162#endif
1090 1163
1091 Config cfg("Konsole"); 1164 Config cfg("Konsole");
1092 cfg.setGroup("ScrollBar"); 1165 cfg.setGroup("ScrollBar");
1093 TEWidget* te = getTe(); 1166 TEWidget* te = getTe();
1094 if( !cfg.readBoolEntry("HorzScroll",0)) { 1167 if( !cfg.readBoolEntry("HorzScroll",0)) {
1095 te->setWrapAt(0); 1168 te->setWrapAt(0);
1096 configMenu->setItemChecked( i,TRUE); 1169 configMenu->setItemChecked( i,TRUE);
1097 } else { 1170 } else {
1098// te->setWrapAt(90); 1171// te->setWrapAt(90);
1099 te->setWrapAt(120); 1172 te->setWrapAt(120);
1100 configMenu->setItemChecked( i,FALSE); 1173 configMenu->setItemChecked( i,FALSE);
1101 } 1174 }
1102} 1175}