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