summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-02-02 00:17:02 (UTC)
committer llornkcor <llornkcor>2002-02-02 00:17:02 (UTC)
commit612f02246dbb07db268e158f6959727a6598c6d5 (patch) (unidiff)
tree7dceba4874ad04c35bd6e0cf7c0d053d931ea6d2
parent5a3c8bf8c1033882685f3a6d897c6fa5229403e3 (diff)
downloadopie-612f02246dbb07db268e158f6959727a6598c6d5.zip
opie-612f02246dbb07db268e158f6959727a6598c6d5.tar.gz
opie-612f02246dbb07db268e158f6959727a6598c6d5.tar.bz2
startup command list edit enable bug fixed. added env to commandlist
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/embeddedkonsole/konsole.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/core/apps/embeddedkonsole/konsole.cpp b/core/apps/embeddedkonsole/konsole.cpp
index efcb1f2..f154bb8 100644
--- a/core/apps/embeddedkonsole/konsole.cpp
+++ b/core/apps/embeddedkonsole/konsole.cpp
@@ -1,687 +1,688 @@
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 21
22#include <qpe/resource.h> 22#include <qpe/resource.h>
23 23
24#include <qdir.h> 24#include <qdir.h>
25#include <qevent.h> 25#include <qevent.h>
26#include <qdragobject.h> 26#include <qdragobject.h>
27#include <qobjectlist.h> 27#include <qobjectlist.h>
28#include <qtoolbutton.h> 28#include <qtoolbutton.h>
29#include <qpe/qpetoolbar.h> 29#include <qpe/qpetoolbar.h>
30#include <qpushbutton.h> 30#include <qpushbutton.h>
31#include <qfontdialog.h> 31#include <qfontdialog.h>
32#include <qglobal.h> 32#include <qglobal.h>
33#include <qpainter.h> 33#include <qpainter.h>
34#include <qpe/qpemenubar.h> 34#include <qpe/qpemenubar.h>
35#include <qmessagebox.h> 35#include <qmessagebox.h>
36#include <qaction.h> 36#include <qaction.h>
37#include <qapplication.h> 37#include <qapplication.h>
38#include <qfontmetrics.h> 38#include <qfontmetrics.h>
39#include <qcombobox.h> 39#include <qcombobox.h>
40#include <qevent.h> 40#include <qevent.h>
41#include <qtabwidget.h> 41#include <qtabwidget.h>
42#include <qtabbar.h> 42#include <qtabbar.h>
43#include <qpe/config.h> 43#include <qpe/config.h>
44#include <qstringlist.h> 44#include <qstringlist.h>
45#include <qpalette.h> 45#include <qpalette.h>
46 46
47#include <sys/wait.h> 47#include <sys/wait.h>
48#include <stdio.h> 48#include <stdio.h>
49#include <stdlib.h> 49#include <stdlib.h>
50#include <assert.h> 50#include <assert.h>
51 51
52#include "konsole.h" 52#include "konsole.h"
53#include "keytrans.h" 53#include "keytrans.h"
54 54
55
56class EKNumTabBar : public QTabBar { 55class EKNumTabBar : public QTabBar {
57public: 56public:
58 void numberTabs() 57 void numberTabs()
59 { 58 {
60 // Yes, it really is this messy. QTabWidget needs functions 59 // Yes, it really is this messy. QTabWidget needs functions
61 // that provide acces to tabs in a sequential way. 60 // that provide acces to tabs in a sequential way.
62 int m=INT_MIN; 61 int m=INT_MIN;
63 for (int i=0; i<count(); i++) { 62 for (int i=0; i<count(); i++) {
64 QTab* left=0; 63 QTab* left=0;
65 QListIterator<QTab> it(*tabList()); 64 QListIterator<QTab> it(*tabList());
66 int x=INT_MAX; 65 int x=INT_MAX;
67 for( QTab* t; (t=it.current()); ++it ) { 66 for( QTab* t; (t=it.current()); ++it ) {
68 int tx = t->rect().x(); 67 int tx = t->rect().x();
69 if ( tx<x && tx>m ) { 68 if ( tx<x && tx>m ) {
70 x = tx; 69 x = tx;
71 left = t; 70 left = t;
72 } 71 }
73 } 72 }
74 if ( left ) { 73 if ( left ) {
75 left->setText(QString::number(i+1)); 74 left->setText(QString::number(i+1));
76 m = left->rect().x(); 75 m = left->rect().x();
77 } 76 }
78 } 77 }
79 } 78 }
80}; 79};
81 80
82class EKNumTabWidget : public QTabWidget { 81class EKNumTabWidget : public QTabWidget {
83public: 82public:
84 EKNumTabWidget(QWidget* parent) : QTabWidget(parent) 83 EKNumTabWidget(QWidget* parent) : QTabWidget(parent)
85 { 84 {
86 } 85 }
87 86
88 void addTab(QWidget* w) 87 void addTab(QWidget* w)
89 { 88 {
90 QTab* t = new QTab(QString::number(tabBar()->count()+1)); 89 QTab* t = new QTab(QString::number(tabBar()->count()+1));
91 QTabWidget::addTab(w,t); 90 QTabWidget::addTab(w,t);
92 } 91 }
93 92
94 void removeTab(QWidget* w) 93 void removeTab(QWidget* w)
95 { 94 {
96 removePage(w); 95 removePage(w);
97 ((EKNumTabBar*)tabBar())->numberTabs(); 96 ((EKNumTabBar*)tabBar())->numberTabs();
98 } 97 }
99}; 98};
100 99
101// This could be configurable or dynamicly generated from the bash history 100// This could be configurable or dynamicly generated from the bash history
102// file of the user 101// file of the user
103static const char *commonCmds[] = 102static const char *commonCmds[] =
104{ 103{
105 "ls ", // I left this here, cause it looks better than the first alpha 104 "ls ", // I left this here, cause it looks better than the first alpha
106 "cardctl eject", 105 "cardctl eject",
107 "cat ", 106 "cat ",
108 "cd ", 107 "cd ",
109 "chmod ", 108 "chmod ",
110 "cp ", 109 "cp ",
111 "dc ", 110 "dc ",
112 "df ", 111 "df ",
113 "dmesg", 112 "dmesg",
114 "echo ", 113 "echo ",
114 "env",
115 "find ", 115 "find ",
116 "free", 116 "free",
117 "grep ", 117 "grep ",
118 "ifconfig ", 118 "ifconfig ",
119 "ipkg ", 119 "ipkg ",
120 "mkdir ", 120 "mkdir ",
121 "mv ", 121 "mv ",
122 "nc localhost 7776", 122 "nc localhost 7776",
123 "nc localhost 7777", 123 "nc localhost 7777",
124 "netstat ",
125 "nslookup ", 124 "nslookup ",
126 "ping ", 125 "ping ",
127 "ps aux", 126 "ps aux",
128 "pwd ", 127 "pwd ",
129 "rm ", 128 "rm ",
130 "rmdir ", 129 "rmdir ",
131 "route ", 130 "route ",
132 "set ", 131 "set ",
133 "traceroute", 132 "traceroute",
134 133
135/* 134/*
136 "gzip", 135 "gzip",
137 "gunzip", 136 "gunzip",
138 "chgrp", 137 "chgrp",
139 "chown", 138 "chown",
140 "date", 139 "date",
141 "dd", 140 "dd",
142 "df", 141 "df",
143 "dmesg", 142 "dmesg",
144 "fuser", 143 "fuser",
145 "hostname", 144 "hostname",
146 "kill", 145 "kill",
147 "killall", 146 "killall",
148 "ln", 147 "ln",
149 "ping", 148 "ping",
150 "mount", 149 "mount",
151 "more", 150 "more",
152 "sort", 151 "sort",
153 "touch", 152 "touch",
154 "umount", 153 "umount",
155 "mknod", 154 "mknod",
156 "netstat", 155 "netstat",
157*/ 156*/
158 157
159 "exit", 158 "exit",
160 NULL 159 NULL
161}; 160};
162 161
163 162
164Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) : 163Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) :
165 QMainWindow(parent, name, fl) 164 QMainWindow(parent, name, fl)
166{ 165{
167 QStrList args; 166 QStrList args;
168 init("/bin/sh",args); 167 init("/bin/sh",args);
169} 168}
170 169
171Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int) 170Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int)
172 : QMainWindow(0, name) 171 : QMainWindow(0, name)
173{ 172{
174 init(_pgm,_args); 173 init(_pgm,_args);
175} 174}
176 175
177void Konsole::init(const char* _pgm, QStrList & _args) 176void Konsole::init(const char* _pgm, QStrList & _args)
178{ 177{
179 b_scroll = TRUE; // histon; 178 b_scroll = TRUE; // histon;
180 n_keytab = 0; 179 n_keytab = 0;
181 n_render = 0; 180 n_render = 0;
182 181
183 setCaption( tr("Terminal") ); 182 setCaption( tr("Terminal") );
184 setIcon( Resource::loadPixmap( "konsole" ) ); 183 setIcon( Resource::loadPixmap( "konsole" ) );
185 184
186 Config cfg("Konsole"); 185 Config cfg("Konsole");
187 cfg.setGroup("Konsole"); 186 cfg.setGroup("Konsole");
188 QString tmp; 187 QString tmp;
189 // initialize the list of allowed fonts /////////////////////////////////// 188 // initialize the list of allowed fonts ///////////////////////////////////
190 cfont = cfg.readNumEntry("FontID", 1); 189 cfont = cfg.readNumEntry("FontID", 1);
191 QFont f = QFont("Micro", 4, QFont::Normal); 190 QFont f = QFont("Micro", 4, QFont::Normal);
192 f.setFixedPitch(TRUE); 191 f.setFixedPitch(TRUE);
193 fonts.append(new VTFont(tr("Micro"), f)); 192 fonts.append(new VTFont(tr("Micro"), f));
194 193
195 f = QFont("Fixed", 7, QFont::Normal); 194 f = QFont("Fixed", 7, QFont::Normal);
196 f.setFixedPitch(TRUE); 195 f.setFixedPitch(TRUE);
197 fonts.append(new VTFont(tr("Small Fixed"), f)); 196 fonts.append(new VTFont(tr("Small Fixed"), f));
198 197
199 f = QFont("Fixed", 12, QFont::Normal); 198 f = QFont("Fixed", 12, QFont::Normal);
200 f.setFixedPitch(TRUE); 199 f.setFixedPitch(TRUE);
201 fonts.append(new VTFont(tr("Medium Fixed"), f)); 200 fonts.append(new VTFont(tr("Medium Fixed"), f));
202 201
203 // create terminal emulation framework //////////////////////////////////// 202 // create terminal emulation framework ////////////////////////////////////
204 nsessions = 0; 203 nsessions = 0;
205 204
206 tab = new EKNumTabWidget(this); 205 tab = new EKNumTabWidget(this);
207 206
208 connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*))); 207 connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*)));
209 208
210 // create terminal toolbar //////////////////////////////////////////////// 209 // create terminal toolbar ////////////////////////////////////////////////
211 setToolBarsMovable( FALSE ); 210 setToolBarsMovable( FALSE );
212 QPEToolBar *menuToolBar = new QPEToolBar( this ); 211 QPEToolBar *menuToolBar = new QPEToolBar( this );
213 menuToolBar->setHorizontalStretchable( TRUE ); 212 menuToolBar->setHorizontalStretchable( TRUE );
214 213
215 QPEMenuBar *menuBar = new QPEMenuBar( menuToolBar ); 214 QPEMenuBar *menuBar = new QPEMenuBar( menuToolBar );
216 215
217 fontList = new QPopupMenu( this ); 216 fontList = new QPopupMenu( this );
218 for(uint i = 0; i < fonts.count(); i++) { 217 for(uint i = 0; i < fonts.count(); i++) {
219 VTFont *fnt = fonts.at(i); 218 VTFont *fnt = fonts.at(i);
220 fontList->insertItem(fnt->getName(), i); 219 fontList->insertItem(fnt->getName(), i);
221 } 220 }
222 fontChanged(cfont); 221 fontChanged(cfont);
223 222
224 configMenu = new QPopupMenu( this); 223 configMenu = new QPopupMenu( this);
225 colorMenu = new QPopupMenu( this); 224 colorMenu = new QPopupMenu( this);
226 225
227 bool listHidden; 226 bool listHidden;
228 cfg.setGroup("Menubar"); 227 cfg.setGroup("Menubar");
229 if( cfg.readEntry("Hidden","FALSE") == "TRUE") { 228 if( cfg.readEntry("Hidden","FALSE") == "TRUE") {
230 configMenu->insertItem("Show command list"); 229 configMenu->insertItem("Show command list");
231 listHidden=TRUE; 230 listHidden=TRUE;
232 } else { 231 } else {
233 configMenu->insertItem("Hide command list"); 232 configMenu->insertItem("Hide command list");
234 listHidden=FALSE; 233 listHidden=FALSE;
235 } 234 }
236 235
237 cfg.setGroup("Tabs"); 236 cfg.setGroup("Tabs");
238 tmp=cfg.readEntry("Position","Bottom"); 237 tmp=cfg.readEntry("Position","Bottom");
239 if(tmp=="Top") { 238 if(tmp=="Top") {
240 tab->setTabPosition(QTabWidget::Top); 239 tab->setTabPosition(QTabWidget::Top);
241 configMenu->insertItem("Tabs on Bottom"); 240 configMenu->insertItem("Tabs on Bottom");
242 } else { 241 } else {
243 tab->setTabPosition(QTabWidget::Bottom); 242 tab->setTabPosition(QTabWidget::Bottom);
244 configMenu->insertItem("Tabs on Top"); 243 configMenu->insertItem("Tabs on Top");
245 } 244 }
246 configMenu->insertSeparator(2); 245 configMenu->insertSeparator(2);
247 246
248 colorMenu->insertItem("Green on Black"); 247 colorMenu->insertItem("Green on Black");
249 colorMenu->insertItem("Black on White"); 248 colorMenu->insertItem("Black on White");
250 colorMenu->insertItem("White on Black"); 249 colorMenu->insertItem("White on Black");
251 colorMenu->insertItem("Black on Transparent"); 250 colorMenu->insertItem("Black on Transparent");
252 colorMenu->insertItem("Black on Red"); 251 colorMenu->insertItem("Black on Red");
253 colorMenu->insertItem("Red on Black"); 252 colorMenu->insertItem("Red on Black");
254 colorMenu->insertItem("Green on Yellow"); 253 colorMenu->insertItem("Green on Yellow");
255 colorMenu->insertItem("Blue on Magenta"); 254 colorMenu->insertItem("Blue on Magenta");
256 colorMenu->insertItem("Magenta on Blue"); 255 colorMenu->insertItem("Magenta on Blue");
257 colorMenu->insertItem("Cyan on White"); 256 colorMenu->insertItem("Cyan on White");
258 colorMenu->insertItem("White on Cyan"); 257 colorMenu->insertItem("White on Cyan");
259 colorMenu->insertItem("Blue on Black"); 258 colorMenu->insertItem("Blue on Black");
260 configMenu->insertItem("Colors",colorMenu); 259 configMenu->insertItem("Colors",colorMenu);
261 260
262 connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) )); 261 connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) ));
263 connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) )); 262 connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) ));
264 connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuSelected(int) )); 263 connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuSelected(int) ));
265 264
266 menuBar->insertItem( tr("Font"), fontList ); 265 menuBar->insertItem( tr("Font"), fontList );
267 menuBar->insertItem( tr("Options"), configMenu ); 266 menuBar->insertItem( tr("Options"), configMenu );
268 267
269 QPEToolBar *toolbar = new QPEToolBar( this ); 268 QPEToolBar *toolbar = new QPEToolBar( this );
270 269
271 QAction *a; 270 QAction *a;
272 271
273 // Button Commands 272 // Button Commands
274 a = new QAction( tr("New"), Resource::loadPixmap( "konsole" ), QString::null, 0, this, 0 ); 273 a = new QAction( tr("New"), Resource::loadPixmap( "konsole" ), QString::null, 0, this, 0 );
275 connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); a->addTo( toolbar ); 274 connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); a->addTo( toolbar );
276 a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 ); 275 a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 );
277 connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolbar ); 276 connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolbar );
278 a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 ); 277 a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 );
279 connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolbar ); 278 connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolbar );
280 a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 ); 279 a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 );
281 connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolbar ); 280 connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolbar );
282 a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 ); 281 a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 );
283 connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar ); 282 connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar );
284 a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 ); 283 a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 );
285 connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar ); 284 connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar );
286 a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); 285 a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 );
287 connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); a->addTo( toolbar ); 286 connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); a->addTo( toolbar );
288/* 287/*
289 a = new QAction( tr("Up"), Resource::loadPixmap( "up" ), QString::null, 0, this, 0 ); 288 a = new QAction( tr("Up"), Resource::loadPixmap( "up" ), QString::null, 0, this, 0 );
290 connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar ); 289 connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar );
291 a = new QAction( tr("Down"), Resource::loadPixmap( "down" ), QString::null, 0, this, 0 ); 290 a = new QAction( tr("Down"), Resource::loadPixmap( "down" ), QString::null, 0, this, 0 );
292 connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar ); 291 connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar );
293*/ 292*/
294 293
295 secondToolBar = new QPEToolBar( this ); 294 secondToolBar = new QPEToolBar( this );
296 secondToolBar->setHorizontalStretchable( TRUE ); 295 secondToolBar->setHorizontalStretchable( TRUE );
297 296
298 commonCombo = new QComboBox( secondToolBar ); 297 commonCombo = new QComboBox( secondToolBar );
299 298
300 if( listHidden)
301 secondToolBar->hide();
302 configMenu->insertItem( "Edit Command List"); 299 configMenu->insertItem( "Edit Command List");
303 300 if( listHidden) {
301 secondToolBar->hide();
302 configMenu->setItemEnabled(-20 ,FALSE);
303 }
304
304 cfg.setGroup("Commands"); 305 cfg.setGroup("Commands");
305 commonCombo->setInsertionPolicy(QComboBox::AtCurrent); 306 commonCombo->setInsertionPolicy(QComboBox::AtCurrent);
306 307
307 for (int i = 0; commonCmds[i] != NULL; i++) { 308 for (int i = 0; commonCmds[i] != NULL; i++) {
308 commonCombo->insertItem( commonCmds[i], i ); 309 commonCombo->insertItem( commonCmds[i], i );
309 tmp = cfg.readEntry( QString::number(i),""); 310 tmp = cfg.readEntry( QString::number(i),"");
310 if(tmp != "") 311 if(tmp != "")
311 commonCombo->changeItem( tmp,i ); 312 commonCombo->changeItem( tmp,i );
312 } 313 }
313 314
314 connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) )); 315 connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) ));
315 316
316 // create applications ///////////////////////////////////////////////////// 317 // create applications /////////////////////////////////////////////////////
317 setCentralWidget(tab); 318 setCentralWidget(tab);
318 319
319 // load keymaps //////////////////////////////////////////////////////////// 320 // load keymaps ////////////////////////////////////////////////////////////
320 KeyTrans::loadAll(); 321 KeyTrans::loadAll();
321 for (int i = 0; i < KeyTrans::count(); i++) 322 for (int i = 0; i < KeyTrans::count(); i++)
322 { KeyTrans* s = KeyTrans::find(i); 323 { KeyTrans* s = KeyTrans::find(i);
323 assert( s ); 324 assert( s );
324 } 325 }
325 326
326 se_pgm = _pgm; 327 se_pgm = _pgm;
327 se_args = _args; 328 se_args = _args;
328 329
329 // read and apply default values /////////////////////////////////////////// 330 // read and apply default values ///////////////////////////////////////////
330 resize(321, 321); // Dummy. 331 resize(321, 321); // Dummy.
331 QSize currentSize = size(); 332 QSize currentSize = size();
332 if (currentSize != size()) 333 if (currentSize != size())
333 defaultSize = size(); 334 defaultSize = size();
334 335
335} 336}
336 337
337void Konsole::show() 338void Konsole::show()
338{ 339{
339 if ( !nsessions ) { 340 if ( !nsessions ) {
340 newSession(); 341 newSession();
341 } 342 }
342 QMainWindow::show(); 343 QMainWindow::show();
343} 344}
344 345
345void Konsole::initSession(const char*, QStrList &) 346void Konsole::initSession(const char*, QStrList &)
346{ 347{
347 QMainWindow::show(); 348 QMainWindow::show();
348} 349}
349 350
350Konsole::~Konsole() 351Konsole::~Konsole()
351{ 352{
352 while (nsessions > 0) { 353 while (nsessions > 0) {
353 doneSession(getTe()->currentSession, 0); 354 doneSession(getTe()->currentSession, 0);
354 } 355 }
355 356
356 Config cfg("Konsole"); 357 Config cfg("Konsole");
357 cfg.setGroup("Konsole"); 358 cfg.setGroup("Konsole");
358 cfg.writeEntry("FontID", cfont); 359 cfg.writeEntry("FontID", cfont);
359} 360}
360 361
361void Konsole::fontChanged(int f) 362void Konsole::fontChanged(int f)
362{ 363{
363 VTFont* font = fonts.at(f); 364 VTFont* font = fonts.at(f);
364 if (font != 0) { 365 if (font != 0) {
365 for(uint i = 0; i < fonts.count(); i++) { 366 for(uint i = 0; i < fonts.count(); i++) {
366 fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE); 367 fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE);
367 } 368 }
368 369
369 cfont = f; 370 cfont = f;
370 371
371 TEWidget* te = getTe(); 372 TEWidget* te = getTe();
372 if (te != 0) { 373 if (te != 0) {
373 te->setVTFont(font->getFont()); 374 te->setVTFont(font->getFont());
374 } 375 }
375 } 376 }
376} 377}
377 378
378 379
379void Konsole::enterCommand(int c) 380void Konsole::enterCommand(int c)
380{ 381{
381 TEWidget* te = getTe(); 382 TEWidget* te = getTe();
382 if (te != 0) { 383 if (te != 0) {
383 if(!commonCombo->editable()) { 384 if(!commonCombo->editable()) {
384 QString text = commonCombo->text(c); //commonCmds[c]; 385 QString text = commonCombo->text(c); //commonCmds[c];
385 te->emitText(text); 386 te->emitText(text);
386 } else { 387 } else {
387 changeCommand( commonCombo->text(c), c); 388 changeCommand( commonCombo->text(c), c);
388 } 389 }
389 } 390 }
390} 391}
391 392
392void Konsole::hitEnter() 393void Konsole::hitEnter()
393{ 394{
394 TEWidget* te = getTe(); 395 TEWidget* te = getTe();
395 if (te != 0) { 396 if (te != 0) {
396 te->emitText(QString("\r")); 397 te->emitText(QString("\r"));
397 } 398 }
398} 399}
399 400
400void Konsole::hitSpace() 401void Konsole::hitSpace()
401{ 402{
402 TEWidget* te = getTe(); 403 TEWidget* te = getTe();
403 if (te != 0) { 404 if (te != 0) {
404 te->emitText(QString(" ")); 405 te->emitText(QString(" "));
405 } 406 }
406} 407}
407 408
408void Konsole::hitTab() 409void Konsole::hitTab()
409{ 410{
410 TEWidget* te = getTe(); 411 TEWidget* te = getTe();
411 if (te != 0) { 412 if (te != 0) {
412 te->emitText(QString("\t")); 413 te->emitText(QString("\t"));
413 } 414 }
414} 415}
415 416
416void Konsole::hitPaste() 417void Konsole::hitPaste()
417{ 418{
418 TEWidget* te = getTe(); 419 TEWidget* te = getTe();
419 if (te != 0) { 420 if (te != 0) {
420 te->pasteClipboard(); 421 te->pasteClipboard();
421 } 422 }
422} 423}
423 424
424void Konsole::hitUp() 425void Konsole::hitUp()
425{ 426{
426 TEWidget* te = getTe(); 427 TEWidget* te = getTe();
427 if (te != 0) { 428 if (te != 0) {
428 QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Up, 0, 0); 429 QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Up, 0, 0);
429 QApplication::sendEvent( te, &ke ); 430 QApplication::sendEvent( te, &ke );
430 } 431 }
431} 432}
432 433
433void Konsole::hitDown() 434void Konsole::hitDown()
434{ 435{
435 TEWidget* te = getTe(); 436 TEWidget* te = getTe();
436 if (te != 0) { 437 if (te != 0) {
437 QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Down, 0, 0); 438 QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Down, 0, 0);
438 QApplication::sendEvent( te, &ke ); 439 QApplication::sendEvent( te, &ke );
439 } 440 }
440} 441}
441 442
442/** 443/**
443 This function calculates the size of the external widget 444 This function calculates the size of the external widget
444 needed for the internal widget to be 445 needed for the internal widget to be
445 */ 446 */
446QSize Konsole::calcSize(int columns, int lines) { 447QSize Konsole::calcSize(int columns, int lines) {
447 TEWidget* te = getTe(); 448 TEWidget* te = getTe();
448 if (te != 0) { 449 if (te != 0) {
449 QSize size = te->calcSize(columns, lines); 450 QSize size = te->calcSize(columns, lines);
450 return size; 451 return size;
451 } else { 452 } else {
452 QSize size; 453 QSize size;
453 return size; 454 return size;
454 } 455 }
455} 456}
456 457
457/** 458/**
458 sets application window to a size based on columns X lines of the te 459 sets application window to a size based on columns X lines of the te
459 guest widget. Call with (0,0) for setting default size. 460 guest widget. Call with (0,0) for setting default size.
460*/ 461*/
461 462
462void Konsole::setColLin(int columns, int lines) 463void Konsole::setColLin(int columns, int lines)
463{ 464{
464 if ((columns==0) || (lines==0)) 465 if ((columns==0) || (lines==0))
465 { 466 {
466 if (defaultSize.isEmpty()) // not in config file : set default value 467 if (defaultSize.isEmpty()) // not in config file : set default value
467 { 468 {
468 defaultSize = calcSize(80,24); 469 defaultSize = calcSize(80,24);
469 // notifySize(24,80); // set menu items (strange arg order !) 470 // notifySize(24,80); // set menu items (strange arg order !)
470 } 471 }
471 resize(defaultSize); 472 resize(defaultSize);
472 } else { 473 } else {
473 resize(calcSize(columns, lines)); 474 resize(calcSize(columns, lines));
474 // notifySize(lines,columns); // set menu items (strange arg order !) 475 // notifySize(lines,columns); // set menu items (strange arg order !)
475 } 476 }
476} 477}
477 478
478/* 479/*
479void Konsole::setFont(int fontno) 480void Konsole::setFont(int fontno)
480{ 481{
481 QFont f; 482 QFont f;
482 if (fontno == 0) 483 if (fontno == 0)
483 f = defaultFont = QFont( "Helvetica", 12 ); 484 f = defaultFont = QFont( "Helvetica", 12 );
484 else 485 else
485 if (fonts[fontno][0] == '-') 486 if (fonts[fontno][0] == '-')
486 f.setRawName( fonts[fontno] ); 487 f.setRawName( fonts[fontno] );
487 else 488 else
488 { 489 {
489 f.setFamily(fonts[fontno]); 490 f.setFamily(fonts[fontno]);
490 f.setRawMode( TRUE ); 491 f.setRawMode( TRUE );
491 } 492 }
492 if ( !f.exactMatch() && fontno != 0) 493 if ( !f.exactMatch() && fontno != 0)
493 { 494 {
494 QString msg = i18n("Font `%1' not found.\nCheck README.linux.console for help.").arg(fonts[fontno]); 495 QString msg = i18n("Font `%1' not found.\nCheck README.linux.console for help.").arg(fonts[fontno]);
495 QMessageBox(this, msg); 496 QMessageBox(this, msg);
496 return; 497 return;
497 } 498 }
498 if (se) se->setFontNo(fontno); 499 if (se) se->setFontNo(fontno);
499 te->setVTFont(f); 500 te->setVTFont(f);
500 n_font = fontno; 501 n_font = fontno;
501} 502}
502*/ 503*/
503 504
504// --| color selection |------------------------------------------------------- 505// --| color selection |-------------------------------------------------------
505 506
506void Konsole::changeColumns(int columns) 507void Konsole::changeColumns(int columns)
507{ 508{
508 TEWidget* te = getTe(); 509 TEWidget* te = getTe();
509 if (te != 0) { 510 if (te != 0) {
510 setColLin(columns,te->Lines()); 511 setColLin(columns,te->Lines());
511 te->update(); 512 te->update();
512 } 513 }
513} 514}
514 515
515//FIXME: If a child dies during session swap, 516//FIXME: If a child dies during session swap,
516// this routine might be called before 517// this routine might be called before
517// session swap is completed. 518// session swap is completed.
518 519
519void Konsole::doneSession(TESession*, int ) 520void Konsole::doneSession(TESession*, int )
520{ 521{
521 TEWidget *te = getTe(); 522 TEWidget *te = getTe();
522 if (te != 0) { 523 if (te != 0) {
523 te->currentSession->setConnect(FALSE); 524 te->currentSession->setConnect(FALSE);
524 tab->removeTab(te); 525 tab->removeTab(te);
525 delete te->currentSession; 526 delete te->currentSession;
526 delete te; 527 delete te;
527 nsessions--; 528 nsessions--;
528 } 529 }
529 530
530 if (nsessions == 0) { 531 if (nsessions == 0) {
531 close(); 532 close();
532 } 533 }
533} 534}
534 535
535void Konsole::newSession() { 536void Konsole::newSession() {
536 if(nsessions < 15) { // seems to be something weird about 16 tabs on the Zaurus.... memory? 537 if(nsessions < 15) { // seems to be something weird about 16 tabs on the Zaurus.... memory?
537 TEWidget* te = new TEWidget(tab); 538 TEWidget* te = new TEWidget(tab);
538// te->setBackgroundMode(PaletteBase); //we want transparent!! 539// te->setBackgroundMode(PaletteBase); //we want transparent!!
539 te->setVTFont(fonts.at(cfont)->getFont()); 540 te->setVTFont(fonts.at(cfont)->getFont());
540 tab->addTab(te); 541 tab->addTab(te);
541 TESession* se = new TESession(this, te, se_pgm, se_args, "xterm"); 542 TESession* se = new TESession(this, te, se_pgm, se_args, "xterm");
542 te->currentSession = se; 543 te->currentSession = se;
543 connect( se, SIGNAL(done(TESession*,int)), this, SLOT(doneSession(TESession*,int)) ); 544 connect( se, SIGNAL(done(TESession*,int)), this, SLOT(doneSession(TESession*,int)) );
544 se->run(); 545 se->run();
545 se->setConnect(TRUE); 546 se->setConnect(TRUE);
546 se->setHistory(b_scroll); 547 se->setHistory(b_scroll);
547 tab->setCurrentPage(nsessions); 548 tab->setCurrentPage(nsessions);
548 nsessions++; 549 nsessions++;
549 setColor(); 550 setColor();
550 } 551 }
551} 552}
552 553
553TEWidget* Konsole::getTe() { 554TEWidget* Konsole::getTe() {
554 if (nsessions) { 555 if (nsessions) {
555 return (TEWidget *) tab->currentPage(); 556 return (TEWidget *) tab->currentPage();
556 } else { 557 } else {
557 return 0; 558 return 0;
558 } 559 }
559} 560}
560 561
561void Konsole::switchSession(QWidget* w) { 562void Konsole::switchSession(QWidget* w) {
562 TEWidget* te = (TEWidget *) w; 563 TEWidget* te = (TEWidget *) w;
563 564
564 QFont teFnt = te->getVTFont(); 565 QFont teFnt = te->getVTFont();
565 for(uint i = 0; i < fonts.count(); i++) { 566 for(uint i = 0; i < fonts.count(); i++) {
566 VTFont *fnt = fonts.at(i); 567 VTFont *fnt = fonts.at(i);
567 bool cf = fnt->getFont() == teFnt; 568 bool cf = fnt->getFont() == teFnt;
568 fontList->setItemChecked(i, cf); 569 fontList->setItemChecked(i, cf);
569 if (cf) { 570 if (cf) {
570 cfont = i; 571 cfont = i;
571 } 572 }
572 } 573 }
573} 574}
574 575
575/// ------------------------------- some new stuff by L.J. Potter 576/// ------------------------------- some new stuff by L.J. Potter
576void Konsole::colorMenuSelected(int iD) 577void Konsole::colorMenuSelected(int iD)
577{ // this is NOT pretty, elegant or anything else besides functional 578{ // this is NOT pretty, elegant or anything else besides functional
578// QString temp; 579// QString temp;
579// temp.sprintf("%d", iD); 580// temp.sprintf("%d", iD);
580// qDebug(temp); 581// qDebug(temp);
581 TEWidget* te = getTe(); 582 TEWidget* te = getTe();
582 Config cfg("Konsole"); 583 Config cfg("Konsole");
583 cfg.setGroup("Colors"); 584 cfg.setGroup("Colors");
584 QColor foreground; 585 QColor foreground;
585 QColor background; 586 QColor background;
586 colorMenu->setItemChecked(lastSelectedMenu,FALSE); 587 colorMenu->setItemChecked(lastSelectedMenu,FALSE);
587 ColorEntry m_table[TABLE_COLORS]; 588 ColorEntry m_table[TABLE_COLORS];
588 const ColorEntry * defaultCt=te->getdefaultColorTable(); 589 const ColorEntry * defaultCt=te->getdefaultColorTable();
589 /////////// fore back 590 /////////// fore back
590 int i; 591 int i;
591 if(iD==-8) { // default default 592 if(iD==-8) { // default default
592 for (i = 0; i < TABLE_COLORS; i++) { 593 for (i = 0; i < TABLE_COLORS; i++) {
593 m_table[i].color = defaultCt[i].color; 594 m_table[i].color = defaultCt[i].color;
594 if(i==1 || i == 11) 595 if(i==1 || i == 11)
595 m_table[i].transparent=1; 596 m_table[i].transparent=1;
596 cfg.writeEntry("Schema","8"); 597 cfg.writeEntry("Schema","8");
597 colorMenu->setItemChecked(-8,TRUE); 598 colorMenu->setItemChecked(-8,TRUE);
598 } 599 }
599 } else { 600 } else {
600 if(iD==-5) { // green black 601 if(iD==-5) { // green black
601 foreground.setRgb(0x18,255,0x18); 602 foreground.setRgb(0x18,255,0x18);
602 background.setRgb(0x00,0x00,0x00); 603 background.setRgb(0x00,0x00,0x00);
603 cfg.writeEntry("Schema","5"); 604 cfg.writeEntry("Schema","5");
604 colorMenu->setItemChecked(-5,TRUE); 605 colorMenu->setItemChecked(-5,TRUE);
605 } 606 }
606 if(iD==-6) { // black white 607 if(iD==-6) { // black white
607 foreground.setRgb(0x00,0x00,0x00); 608 foreground.setRgb(0x00,0x00,0x00);
608 background.setRgb(0xFF,0xFF,0xFF); 609 background.setRgb(0xFF,0xFF,0xFF);
609 cfg.writeEntry("Schema","6"); 610 cfg.writeEntry("Schema","6");
610 colorMenu->setItemChecked(-6,TRUE); 611 colorMenu->setItemChecked(-6,TRUE);
611 } 612 }
612 if(iD==-7) { // white black 613 if(iD==-7) { // white black
613 foreground.setRgb(0xFF,0xFF,0xFF); 614 foreground.setRgb(0xFF,0xFF,0xFF);
614 background.setRgb(0x00,0x00,0x00); 615 background.setRgb(0x00,0x00,0x00);
615 cfg.writeEntry("Schema","7"); 616 cfg.writeEntry("Schema","7");
616 colorMenu->setItemChecked(-7,TRUE); 617 colorMenu->setItemChecked(-7,TRUE);
617 } 618 }
618 if(iD==-9) {// Black, Red 619 if(iD==-9) {// Black, Red
619 foreground.setRgb(0x00,0x00,0x00); 620 foreground.setRgb(0x00,0x00,0x00);
620 background.setRgb(0xB2,0x18,0x18); 621 background.setRgb(0xB2,0x18,0x18);
621 cfg.writeEntry("Schema","9"); 622 cfg.writeEntry("Schema","9");
622 colorMenu->setItemChecked(-9,TRUE); 623 colorMenu->setItemChecked(-9,TRUE);
623 } 624 }
624 if(iD==-10) {// Red, Black 625 if(iD==-10) {// Red, Black
625 foreground.setRgb(230,31,31); //0xB2,0x18,0x18 626 foreground.setRgb(230,31,31); //0xB2,0x18,0x18
626 background.setRgb(0x00,0x00,0x00); 627 background.setRgb(0x00,0x00,0x00);
627 cfg.writeEntry("Schema","10"); 628 cfg.writeEntry("Schema","10");
628 colorMenu->setItemChecked(-10,TRUE); 629 colorMenu->setItemChecked(-10,TRUE);
629 } 630 }
630 if(iD==-11) {// Green, Yellow - is ugly 631 if(iD==-11) {// Green, Yellow - is ugly
631// foreground.setRgb(0x18,0xB2,0x18); 632// foreground.setRgb(0x18,0xB2,0x18);
632 foreground.setRgb(36,139,10); 633 foreground.setRgb(36,139,10);
633// background.setRgb(0xB2,0x68,0x18); 634// background.setRgb(0xB2,0x68,0x18);
634 background.setRgb(255,255,0); 635 background.setRgb(255,255,0);
635 cfg.writeEntry("Schema","11"); 636 cfg.writeEntry("Schema","11");
636 colorMenu->setItemChecked(-11,TRUE); 637 colorMenu->setItemChecked(-11,TRUE);
637 } 638 }
638 if(iD==-12) {// Blue, Magenta 639 if(iD==-12) {// Blue, Magenta
639 foreground.setRgb(0x18,0xB2,0xB2); 640 foreground.setRgb(0x18,0xB2,0xB2);
640 background.setRgb(0x18,0x18,0xB2); 641 background.setRgb(0x18,0x18,0xB2);
641 cfg.writeEntry("Schema","12"); 642 cfg.writeEntry("Schema","12");
642 colorMenu->setItemChecked(-12,TRUE); 643 colorMenu->setItemChecked(-12,TRUE);
643 } 644 }
644 if(iD==-13) {// Magenta, Blue 645 if(iD==-13) {// Magenta, Blue
645 foreground.setRgb(0x18,0x18,0xB2); 646 foreground.setRgb(0x18,0x18,0xB2);
646 background.setRgb(0x18,0xB2,0xB2); 647 background.setRgb(0x18,0xB2,0xB2);
647 cfg.writeEntry("Schema","13"); 648 cfg.writeEntry("Schema","13");
648 colorMenu->setItemChecked(-13,TRUE); 649 colorMenu->setItemChecked(-13,TRUE);
649 } 650 }
650 if(iD==-14) {// Cyan, White 651 if(iD==-14) {// Cyan, White
651 foreground.setRgb(0x18,0xB2,0xB2); 652 foreground.setRgb(0x18,0xB2,0xB2);
652 background.setRgb(0xFF,0xFF,0xFF); 653 background.setRgb(0xFF,0xFF,0xFF);
653 cfg.writeEntry("Schema","14"); 654 cfg.writeEntry("Schema","14");
654 colorMenu->setItemChecked(-14,TRUE); 655 colorMenu->setItemChecked(-14,TRUE);
655 } 656 }
656 if(iD==-15) {// White, Cyan 657 if(iD==-15) {// White, Cyan
657 background.setRgb(0x18,0xB2,0xB2); 658 background.setRgb(0x18,0xB2,0xB2);
658 foreground.setRgb(0xFF,0xFF,0xFF); 659 foreground.setRgb(0xFF,0xFF,0xFF);
659 cfg.writeEntry("Schema","15"); 660 cfg.writeEntry("Schema","15");
660 colorMenu->setItemChecked(-15,TRUE); 661 colorMenu->setItemChecked(-15,TRUE);
661 } 662 }
662 if(iD==-16) {// Black, Blue 663 if(iD==-16) {// Black, Blue
663 background.setRgb(0x00,0x00,0x00); 664 background.setRgb(0x00,0x00,0x00);
664 foreground.setRgb(0x18,0xB2,0xB2); 665 foreground.setRgb(0x18,0xB2,0xB2);
665 cfg.writeEntry("Schema","16"); 666 cfg.writeEntry("Schema","16");
666 colorMenu->setItemChecked(-16,TRUE); 667 colorMenu->setItemChecked(-16,TRUE);
667 } 668 }
668 669
669 for (i = 0; i < TABLE_COLORS; i++) { 670 for (i = 0; i < TABLE_COLORS; i++) {
670 if(i==0 || i == 10) { 671 if(i==0 || i == 10) {
671 m_table[i].color = foreground; 672 m_table[i].color = foreground;
672 } 673 }
673 else if(i==1 || i == 11) { 674 else if(i==1 || i == 11) {
674 m_table[i].color = background; m_table[i].transparent=0; 675 m_table[i].color = background; m_table[i].transparent=0;
675 } 676 }
676 else 677 else
677 m_table[i].color = defaultCt[i].color; 678 m_table[i].color = defaultCt[i].color;
678 } 679 }
679 } 680 }
680 lastSelectedMenu = iD; 681 lastSelectedMenu = iD;
681 te->setColorTable(m_table); 682 te->setColorTable(m_table);
682 update(); 683 update();
683} 684}
684 685
685void Konsole::configMenuSelected(int iD) 686void Konsole::configMenuSelected(int iD)
686{ 687{
687// QString temp; 688// QString temp;