summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/embeddedkonsole/konsole.cpp20
1 files changed, 9 insertions, 11 deletions
diff --git a/core/apps/embeddedkonsole/konsole.cpp b/core/apps/embeddedkonsole/konsole.cpp
index f154bb8..653652a 100644
--- a/core/apps/embeddedkonsole/konsole.cpp
+++ b/core/apps/embeddedkonsole/konsole.cpp
@@ -106,660 +106,658 @@ static const char *commonCmds[] =
106 "cat ", 106 "cat ",
107 "cd ", 107 "cd ",
108 "chmod ", 108 "chmod ",
109 "cp ", 109 "cp ",
110 "dc ", 110 "dc ",
111 "df ", 111 "df ",
112 "dmesg", 112 "dmesg",
113 "echo ", 113 "echo ",
114 "env", 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 "nslookup ", 124 "nslookup ",
125 "ping ", 125 "ping ",
126 "ps aux", 126 "ps aux",
127 "pwd ", 127 "pwd ",
128 "rm ", 128 "rm ",
129 "rmdir ", 129 "rmdir ",
130 "route ", 130 "route ",
131 "set ", 131 "set ",
132 "traceroute", 132 "traceroute",
133 133
134/* 134/*
135 "gzip", 135 "gzip",
136 "gunzip", 136 "gunzip",
137 "chgrp", 137 "chgrp",
138 "chown", 138 "chown",
139 "date", 139 "date",
140 "dd", 140 "dd",
141 "df", 141 "df",
142 "dmesg", 142 "dmesg",
143 "fuser", 143 "fuser",
144 "hostname", 144 "hostname",
145 "kill", 145 "kill",
146 "killall", 146 "killall",
147 "ln", 147 "ln",
148 "ping", 148 "ping",
149 "mount", 149 "mount",
150 "more", 150 "more",
151 "sort", 151 "sort",
152 "touch", 152 "touch",
153 "umount", 153 "umount",
154 "mknod", 154 "mknod",
155 "netstat", 155 "netstat",
156*/ 156*/
157 157
158 "exit", 158 "exit",
159 NULL 159 NULL
160}; 160};
161 161
162 162
163Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) : 163Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) :
164 QMainWindow(parent, name, fl) 164 QMainWindow(parent, name, fl)
165{ 165{
166 QStrList args; 166 QStrList args;
167 init("/bin/sh",args); 167 init("/bin/sh",args);
168} 168}
169 169
170Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int) 170Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int)
171 : QMainWindow(0, name) 171 : QMainWindow(0, name)
172{ 172{
173 init(_pgm,_args); 173 init(_pgm,_args);
174} 174}
175 175
176void Konsole::init(const char* _pgm, QStrList & _args) 176void Konsole::init(const char* _pgm, QStrList & _args)
177{ 177{
178 b_scroll = TRUE; // histon; 178 b_scroll = TRUE; // histon;
179 n_keytab = 0; 179 n_keytab = 0;
180 n_render = 0; 180 n_render = 0;
181 181
182 setCaption( tr("Terminal") ); 182 setCaption( tr("Terminal") );
183 setIcon( Resource::loadPixmap( "konsole" ) ); 183 setIcon( Resource::loadPixmap( "konsole" ) );
184 184
185 Config cfg("Konsole"); 185 Config cfg("Konsole");
186 cfg.setGroup("Konsole"); 186 cfg.setGroup("Konsole");
187 QString tmp; 187 QString tmp;
188 // initialize the list of allowed fonts /////////////////////////////////// 188 // initialize the list of allowed fonts ///////////////////////////////////
189 cfont = cfg.readNumEntry("FontID", 1); 189 cfont = cfg.readNumEntry("FontID", 1);
190 QFont f = QFont("Micro", 4, QFont::Normal); 190 QFont f = QFont("Micro", 4, QFont::Normal);
191 f.setFixedPitch(TRUE); 191 f.setFixedPitch(TRUE);
192 fonts.append(new VTFont(tr("Micro"), f)); 192 fonts.append(new VTFont(tr("Micro"), f));
193 193
194 f = QFont("Fixed", 7, QFont::Normal); 194 f = QFont("Fixed", 7, QFont::Normal);
195 f.setFixedPitch(TRUE); 195 f.setFixedPitch(TRUE);
196 fonts.append(new VTFont(tr("Small Fixed"), f)); 196 fonts.append(new VTFont(tr("Small Fixed"), f));
197 197
198 f = QFont("Fixed", 12, QFont::Normal); 198 f = QFont("Fixed", 12, QFont::Normal);
199 f.setFixedPitch(TRUE); 199 f.setFixedPitch(TRUE);
200 fonts.append(new VTFont(tr("Medium Fixed"), f)); 200 fonts.append(new VTFont(tr("Medium Fixed"), f));
201 201
202 // create terminal emulation framework //////////////////////////////////// 202 // create terminal emulation framework ////////////////////////////////////
203 nsessions = 0; 203 nsessions = 0;
204 204
205 tab = new EKNumTabWidget(this); 205 tab = new EKNumTabWidget(this);
206 206
207 connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*))); 207 connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*)));
208 208
209 // create terminal toolbar //////////////////////////////////////////////// 209 // create terminal toolbar ////////////////////////////////////////////////
210 setToolBarsMovable( FALSE ); 210 setToolBarsMovable( FALSE );
211 QPEToolBar *menuToolBar = new QPEToolBar( this ); 211 QPEToolBar *menuToolBar = new QPEToolBar( this );
212 menuToolBar->setHorizontalStretchable( TRUE ); 212 menuToolBar->setHorizontalStretchable( TRUE );
213 213
214 QPEMenuBar *menuBar = new QPEMenuBar( menuToolBar ); 214 QPEMenuBar *menuBar = new QPEMenuBar( menuToolBar );
215 215
216 fontList = new QPopupMenu( this ); 216 fontList = new QPopupMenu( this );
217 for(uint i = 0; i < fonts.count(); i++) { 217 for(uint i = 0; i < fonts.count(); i++) {
218 VTFont *fnt = fonts.at(i); 218 VTFont *fnt = fonts.at(i);
219 fontList->insertItem(fnt->getName(), i); 219 fontList->insertItem(fnt->getName(), i);
220 } 220 }
221 fontChanged(cfont); 221 fontChanged(cfont);
222 222
223 configMenu = new QPopupMenu( this); 223 configMenu = new QPopupMenu( this);
224 colorMenu = new QPopupMenu( this); 224 colorMenu = new QPopupMenu( this);
225 225
226 bool listHidden; 226 bool listHidden;
227 cfg.setGroup("Menubar"); 227 cfg.setGroup("Menubar");
228 if( cfg.readEntry("Hidden","FALSE") == "TRUE") { 228 if( cfg.readEntry("Hidden","FALSE") == "TRUE") {
229 configMenu->insertItem("Show command list"); 229 configMenu->insertItem("Show command list");
230 listHidden=TRUE; 230 listHidden=TRUE;
231 } else { 231 } else {
232 configMenu->insertItem("Hide command list"); 232 configMenu->insertItem("Hide command list");
233 listHidden=FALSE; 233 listHidden=FALSE;
234 } 234 }
235 235
236 cfg.setGroup("Tabs"); 236 cfg.setGroup("Tabs");
237 tmp=cfg.readEntry("Position","Bottom"); 237 tmp=cfg.readEntry("Position","Bottom");
238 if(tmp=="Top") { 238 if(tmp=="Top") {
239 tab->setTabPosition(QTabWidget::Top); 239 tab->setTabPosition(QTabWidget::Top);
240 configMenu->insertItem("Tabs on Bottom"); 240 configMenu->insertItem("Tabs on Bottom");
241 } else { 241 } else {
242 tab->setTabPosition(QTabWidget::Bottom); 242 tab->setTabPosition(QTabWidget::Bottom);
243 configMenu->insertItem("Tabs on Top"); 243 configMenu->insertItem("Tabs on Top");
244 } 244 }
245 configMenu->insertSeparator(2); 245 configMenu->insertSeparator(2);
246 246
247 colorMenu->insertItem("Green on Black"); 247 colorMenu->insertItem("Green on Black");
248 colorMenu->insertItem("Black on White"); 248 colorMenu->insertItem("Black on White");
249 colorMenu->insertItem("White on Black"); 249 colorMenu->insertItem("White on Black");
250 colorMenu->insertItem("Black on Transparent"); 250 colorMenu->insertItem("Black on Transparent");
251 colorMenu->insertItem("Black on Red"); 251 colorMenu->insertItem("Black on Red");
252 colorMenu->insertItem("Red on Black"); 252 colorMenu->insertItem("Red on Black");
253 colorMenu->insertItem("Green on Yellow"); 253 colorMenu->insertItem("Green on Yellow");
254 colorMenu->insertItem("Blue on Magenta"); 254 colorMenu->insertItem("Blue on Magenta");
255 colorMenu->insertItem("Magenta on Blue"); 255 colorMenu->insertItem("Magenta on Blue");
256 colorMenu->insertItem("Cyan on White"); 256 colorMenu->insertItem("Cyan on White");
257 colorMenu->insertItem("White on Cyan"); 257 colorMenu->insertItem("White on Cyan");
258 colorMenu->insertItem("Blue on Black"); 258 colorMenu->insertItem("Blue on Black");
259 configMenu->insertItem("Colors",colorMenu); 259 configMenu->insertItem("Colors",colorMenu);
260 260
261 connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) )); 261 connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) ));
262 connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) )); 262 connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) ));
263 connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuSelected(int) )); 263 connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuSelected(int) ));
264 264
265 menuBar->insertItem( tr("Font"), fontList ); 265 menuBar->insertItem( tr("Font"), fontList );
266 menuBar->insertItem( tr("Options"), configMenu ); 266 menuBar->insertItem( tr("Options"), configMenu );
267 267
268 QPEToolBar *toolbar = new QPEToolBar( this ); 268 QPEToolBar *toolbar = new QPEToolBar( this );
269 269
270 QAction *a; 270 QAction *a;
271 271
272 // Button Commands 272 // Button Commands
273 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 );
274 connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); a->addTo( toolbar ); 274 connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); a->addTo( toolbar );
275 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 );
276 connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolbar ); 276 connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolbar );
277 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 );
278 connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolbar ); 278 connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolbar );
279 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 );
280 connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolbar ); 280 connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolbar );
281 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 );
282 connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar ); 282 connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar );
283 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 );
284 connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar ); 284 connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar );
285 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 );
286 connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); a->addTo( toolbar ); 286 connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); a->addTo( toolbar );
287/* 287/*
288 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 );
289 connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar ); 289 connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar );
290 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 );
291 connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar ); 291 connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar );
292*/ 292*/
293 293
294 secondToolBar = new QPEToolBar( this ); 294 secondToolBar = new QPEToolBar( this );
295 secondToolBar->setHorizontalStretchable( TRUE ); 295 secondToolBar->setHorizontalStretchable( TRUE );
296 296
297 commonCombo = new QComboBox( secondToolBar ); 297 commonCombo = new QComboBox( secondToolBar );
298 298 commonCombo->setMaximumWidth(236);
299 configMenu->insertItem( "Edit Command List"); 299 configMenu->insertItem( "Edit Command List");
300 if( listHidden) { 300 if( listHidden) {
301 secondToolBar->hide(); 301 secondToolBar->hide();
302 configMenu->setItemEnabled(-20 ,FALSE); 302 configMenu->setItemEnabled(-20 ,FALSE);
303 } 303 }
304 304
305 cfg.setGroup("Commands"); 305 cfg.setGroup("Commands");
306 commonCombo->setInsertionPolicy(QComboBox::AtCurrent); 306 commonCombo->setInsertionPolicy(QComboBox::AtCurrent);
307 307
308 for (int i = 0; commonCmds[i] != NULL; i++) { 308 for (int i = 0; commonCmds[i] != NULL; i++) {
309 commonCombo->insertItem( commonCmds[i], i ); 309 commonCombo->insertItem( commonCmds[i], i );
310 tmp = cfg.readEntry( QString::number(i),""); 310 tmp = cfg.readEntry( QString::number(i),"");
311 if(tmp != "") 311 if(tmp != "")
312 commonCombo->changeItem( tmp,i ); 312 commonCombo->changeItem( tmp,i );
313 } 313 }
314 314
315 connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) )); 315 connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) ));
316 316
317 // create applications ///////////////////////////////////////////////////// 317 // create applications /////////////////////////////////////////////////////
318 setCentralWidget(tab); 318 setCentralWidget(tab);
319 319
320 // load keymaps //////////////////////////////////////////////////////////// 320 // load keymaps ////////////////////////////////////////////////////////////
321 KeyTrans::loadAll(); 321 KeyTrans::loadAll();
322 for (int i = 0; i < KeyTrans::count(); i++) 322 for (int i = 0; i < KeyTrans::count(); i++)
323 { KeyTrans* s = KeyTrans::find(i); 323 { KeyTrans* s = KeyTrans::find(i);
324 assert( s ); 324 assert( s );
325 } 325 }
326 326
327 se_pgm = _pgm; 327 se_pgm = _pgm;
328 se_args = _args; 328 se_args = _args;
329 329
330 // read and apply default values /////////////////////////////////////////// 330 // read and apply default values ///////////////////////////////////////////
331 resize(321, 321); // Dummy. 331 resize(321, 321); // Dummy.
332 QSize currentSize = size(); 332 QSize currentSize = size();
333 if (currentSize != size()) 333 if (currentSize != size())
334 defaultSize = size(); 334 defaultSize = size();
335 335
336} 336}
337 337
338void Konsole::show() 338void Konsole::show()
339{ 339{
340 if ( !nsessions ) { 340 if ( !nsessions ) {
341 newSession(); 341 newSession();
342 } 342 }
343 QMainWindow::show(); 343 QMainWindow::show();
344} 344}
345 345
346void Konsole::initSession(const char*, QStrList &) 346void Konsole::initSession(const char*, QStrList &)
347{ 347{
348 QMainWindow::show(); 348 QMainWindow::show();
349} 349}
350 350
351Konsole::~Konsole() 351Konsole::~Konsole()
352{ 352{
353 while (nsessions > 0) { 353 while (nsessions > 0) {
354 doneSession(getTe()->currentSession, 0); 354 doneSession(getTe()->currentSession, 0);
355 } 355 }
356 356
357 Config cfg("Konsole"); 357 Config cfg("Konsole");
358 cfg.setGroup("Konsole"); 358 cfg.setGroup("Konsole");
359 cfg.writeEntry("FontID", cfont); 359 cfg.writeEntry("FontID", cfont);
360} 360}
361 361
362void Konsole::fontChanged(int f) 362void Konsole::fontChanged(int f)
363{ 363{
364 VTFont* font = fonts.at(f); 364 VTFont* font = fonts.at(f);
365 if (font != 0) { 365 if (font != 0) {
366 for(uint i = 0; i < fonts.count(); i++) { 366 for(uint i = 0; i < fonts.count(); i++) {
367 fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE); 367 fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE);
368 } 368 }
369 369
370 cfont = f; 370 cfont = f;
371 371
372 TEWidget* te = getTe(); 372 TEWidget* te = getTe();
373 if (te != 0) { 373 if (te != 0) {
374 te->setVTFont(font->getFont()); 374 te->setVTFont(font->getFont());
375 } 375 }
376 } 376 }
377} 377}
378 378
379 379
380void Konsole::enterCommand(int c) 380void Konsole::enterCommand(int c)
381{ 381{
382 TEWidget* te = getTe(); 382 TEWidget* te = getTe();
383 if (te != 0) { 383 if (te != 0) {
384 if(!commonCombo->editable()) { 384 if(!commonCombo->editable()) {
385 QString text = commonCombo->text(c); //commonCmds[c]; 385 QString text = commonCombo->text(c); //commonCmds[c];
386 te->emitText(text); 386 te->emitText(text);
387 } else { 387 } else {
388 changeCommand( commonCombo->text(c), c); 388 changeCommand( commonCombo->text(c), c);
389 } 389 }
390 } 390 }
391} 391}
392 392
393void Konsole::hitEnter() 393void Konsole::hitEnter()
394{ 394{
395 TEWidget* te = getTe(); 395 TEWidget* te = getTe();
396 if (te != 0) { 396 if (te != 0) {
397 te->emitText(QString("\r")); 397 te->emitText(QString("\r"));
398 } 398 }
399} 399}
400 400
401void Konsole::hitSpace() 401void Konsole::hitSpace()
402{ 402{
403 TEWidget* te = getTe(); 403 TEWidget* te = getTe();
404 if (te != 0) { 404 if (te != 0) {
405 te->emitText(QString(" ")); 405 te->emitText(QString(" "));
406 } 406 }
407} 407}
408 408
409void Konsole::hitTab() 409void Konsole::hitTab()
410{ 410{
411 TEWidget* te = getTe(); 411 TEWidget* te = getTe();
412 if (te != 0) { 412 if (te != 0) {
413 te->emitText(QString("\t")); 413 te->emitText(QString("\t"));
414 } 414 }
415} 415}
416 416
417void Konsole::hitPaste() 417void Konsole::hitPaste()
418{ 418{
419 TEWidget* te = getTe(); 419 TEWidget* te = getTe();
420 if (te != 0) { 420 if (te != 0) {
421 te->pasteClipboard(); 421 te->pasteClipboard();
422 } 422 }
423} 423}
424 424
425void Konsole::hitUp() 425void Konsole::hitUp()
426{ 426{
427 TEWidget* te = getTe(); 427 TEWidget* te = getTe();
428 if (te != 0) { 428 if (te != 0) {
429 QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Up, 0, 0); 429 QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Up, 0, 0);
430 QApplication::sendEvent( te, &ke ); 430 QApplication::sendEvent( te, &ke );
431 } 431 }
432} 432}
433 433
434void Konsole::hitDown() 434void Konsole::hitDown()
435{ 435{
436 TEWidget* te = getTe(); 436 TEWidget* te = getTe();
437 if (te != 0) { 437 if (te != 0) {
438 QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Down, 0, 0); 438 QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Down, 0, 0);
439 QApplication::sendEvent( te, &ke ); 439 QApplication::sendEvent( te, &ke );
440 } 440 }
441} 441}
442 442
443/** 443/**
444 This function calculates the size of the external widget 444 This function calculates the size of the external widget
445 needed for the internal widget to be 445 needed for the internal widget to be
446 */ 446 */
447QSize Konsole::calcSize(int columns, int lines) { 447QSize Konsole::calcSize(int columns, int lines) {
448 TEWidget* te = getTe(); 448 TEWidget* te = getTe();
449 if (te != 0) { 449 if (te != 0) {
450 QSize size = te->calcSize(columns, lines); 450 QSize size = te->calcSize(columns, lines);
451 return size; 451 return size;
452 } else { 452 } else {
453 QSize size; 453 QSize size;
454 return size; 454 return size;
455 } 455 }
456} 456}
457 457
458/** 458/**
459 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
460 guest widget. Call with (0,0) for setting default size. 460 guest widget. Call with (0,0) for setting default size.
461*/ 461*/
462 462
463void Konsole::setColLin(int columns, int lines) 463void Konsole::setColLin(int columns, int lines)
464{ 464{
465 if ((columns==0) || (lines==0)) 465 if ((columns==0) || (lines==0))
466 { 466 {
467 if (defaultSize.isEmpty()) // not in config file : set default value 467 if (defaultSize.isEmpty()) // not in config file : set default value
468 { 468 {
469 defaultSize = calcSize(80,24); 469 defaultSize = calcSize(80,24);
470 // notifySize(24,80); // set menu items (strange arg order !) 470 // notifySize(24,80); // set menu items (strange arg order !)
471 } 471 }
472 resize(defaultSize); 472 resize(defaultSize);
473 } else { 473 } else {
474 resize(calcSize(columns, lines)); 474 resize(calcSize(columns, lines));
475 // notifySize(lines,columns); // set menu items (strange arg order !) 475 // notifySize(lines,columns); // set menu items (strange arg order !)
476 } 476 }
477} 477}
478 478
479/* 479/*
480void Konsole::setFont(int fontno) 480void Konsole::setFont(int fontno)
481{ 481{
482 QFont f; 482 QFont f;
483 if (fontno == 0) 483 if (fontno == 0)
484 f = defaultFont = QFont( "Helvetica", 12 ); 484 f = defaultFont = QFont( "Helvetica", 12 );
485 else 485 else
486 if (fonts[fontno][0] == '-') 486 if (fonts[fontno][0] == '-')
487 f.setRawName( fonts[fontno] ); 487 f.setRawName( fonts[fontno] );
488 else 488 else
489 { 489 {
490 f.setFamily(fonts[fontno]); 490 f.setFamily(fonts[fontno]);
491 f.setRawMode( TRUE ); 491 f.setRawMode( TRUE );
492 } 492 }
493 if ( !f.exactMatch() && fontno != 0) 493 if ( !f.exactMatch() && fontno != 0)
494 { 494 {
495 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]);
496 QMessageBox(this, msg); 496 QMessageBox(this, msg);
497 return; 497 return;
498 } 498 }
499 if (se) se->setFontNo(fontno); 499 if (se) se->setFontNo(fontno);
500 te->setVTFont(f); 500 te->setVTFont(f);
501 n_font = fontno; 501 n_font = fontno;
502} 502}
503*/ 503*/
504 504
505// --| color selection |------------------------------------------------------- 505// --| color selection |-------------------------------------------------------
506 506
507void Konsole::changeColumns(int columns) 507void Konsole::changeColumns(int columns)
508{ 508{
509 TEWidget* te = getTe(); 509 TEWidget* te = getTe();
510 if (te != 0) { 510 if (te != 0) {
511 setColLin(columns,te->Lines()); 511 setColLin(columns,te->Lines());
512 te->update(); 512 te->update();
513 } 513 }
514} 514}
515 515
516//FIXME: If a child dies during session swap, 516//FIXME: If a child dies during session swap,
517// this routine might be called before 517// this routine might be called before
518// session swap is completed. 518// session swap is completed.
519 519
520void Konsole::doneSession(TESession*, int ) 520void Konsole::doneSession(TESession*, int )
521{ 521{
522 TEWidget *te = getTe(); 522 TEWidget *te = getTe();
523 if (te != 0) { 523 if (te != 0) {
524 te->currentSession->setConnect(FALSE); 524 te->currentSession->setConnect(FALSE);
525 tab->removeTab(te); 525 tab->removeTab(te);
526 delete te->currentSession; 526 delete te->currentSession;
527 delete te; 527 delete te;
528 nsessions--; 528 nsessions--;
529 } 529 }
530 530
531 if (nsessions == 0) { 531 if (nsessions == 0) {
532 close(); 532 close();
533 } 533 }
534} 534}
535 535
536void Konsole::newSession() { 536void Konsole::newSession() {
537 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?
538 TEWidget* te = new TEWidget(tab); 538 TEWidget* te = new TEWidget(tab);
539// te->setBackgroundMode(PaletteBase); //we want transparent!! 539// te->setBackgroundMode(PaletteBase); //we want transparent!!
540 te->setVTFont(fonts.at(cfont)->getFont()); 540 te->setVTFont(fonts.at(cfont)->getFont());
541 tab->addTab(te); 541 tab->addTab(te);
542 TESession* se = new TESession(this, te, se_pgm, se_args, "xterm"); 542 TESession* se = new TESession(this, te, se_pgm, se_args, "xterm");
543 te->currentSession = se; 543 te->currentSession = se;
544 connect( se, SIGNAL(done(TESession*,int)), this, SLOT(doneSession(TESession*,int)) ); 544 connect( se, SIGNAL(done(TESession*,int)), this, SLOT(doneSession(TESession*,int)) );
545 se->run(); 545 se->run();
546 se->setConnect(TRUE); 546 se->setConnect(TRUE);
547 se->setHistory(b_scroll); 547 se->setHistory(b_scroll);
548 tab->setCurrentPage(nsessions); 548 tab->setCurrentPage(nsessions);
549 nsessions++; 549 nsessions++;
550 setColor(); 550 setColor();
551 } 551 }
552} 552}
553 553
554TEWidget* Konsole::getTe() { 554TEWidget* Konsole::getTe() {
555 if (nsessions) { 555 if (nsessions) {
556 return (TEWidget *) tab->currentPage(); 556 return (TEWidget *) tab->currentPage();
557 } else { 557 } else {
558 return 0; 558 return 0;
559 } 559 }
560} 560}
561 561
562void Konsole::switchSession(QWidget* w) { 562void Konsole::switchSession(QWidget* w) {
563 TEWidget* te = (TEWidget *) w; 563 TEWidget* te = (TEWidget *) w;
564 564
565 QFont teFnt = te->getVTFont(); 565 QFont teFnt = te->getVTFont();
566 for(uint i = 0; i < fonts.count(); i++) { 566 for(uint i = 0; i < fonts.count(); i++) {
567 VTFont *fnt = fonts.at(i); 567 VTFont *fnt = fonts.at(i);
568 bool cf = fnt->getFont() == teFnt; 568 bool cf = fnt->getFont() == teFnt;
569 fontList->setItemChecked(i, cf); 569 fontList->setItemChecked(i, cf);
570 if (cf) { 570 if (cf) {
571 cfont = i; 571 cfont = i;
572 } 572 }
573 } 573 }
574} 574}
575 575
576/// ------------------------------- some new stuff by L.J. Potter 576/// ------------------------------- some new stuff by L.J. Potter
577void Konsole::colorMenuSelected(int iD) 577void Konsole::colorMenuSelected(int iD)
578{ // this is NOT pretty, elegant or anything else besides functional 578{ // this is NOT pretty, elegant or anything else besides functional
579// QString temp; 579// QString temp;
580// temp.sprintf("%d", iD); 580// qDebug( temp.sprintf("%d", iD));
581// qDebug(temp);
582 TEWidget* te = getTe(); 581 TEWidget* te = getTe();
583 Config cfg("Konsole"); 582 Config cfg("Konsole");
584 cfg.setGroup("Colors"); 583 cfg.setGroup("Colors");
585 QColor foreground; 584 QColor foreground;
586 QColor background; 585 QColor background;
587 colorMenu->setItemChecked(lastSelectedMenu,FALSE); 586 colorMenu->setItemChecked(lastSelectedMenu,FALSE);
588 ColorEntry m_table[TABLE_COLORS]; 587 ColorEntry m_table[TABLE_COLORS];
589 const ColorEntry * defaultCt=te->getdefaultColorTable(); 588 const ColorEntry * defaultCt=te->getdefaultColorTable();
590 /////////// fore back 589 /////////// fore back
591 int i; 590 int i;
592 if(iD==-8) { // default default 591 if(iD==-8) { // default default
593 for (i = 0; i < TABLE_COLORS; i++) { 592 for (i = 0; i < TABLE_COLORS; i++) {
594 m_table[i].color = defaultCt[i].color; 593 m_table[i].color = defaultCt[i].color;
595 if(i==1 || i == 11) 594 if(i==1 || i == 11)
596 m_table[i].transparent=1; 595 m_table[i].transparent=1;
597 cfg.writeEntry("Schema","8"); 596 cfg.writeEntry("Schema","8");
598 colorMenu->setItemChecked(-8,TRUE); 597 colorMenu->setItemChecked(-8,TRUE);
599 } 598 }
600 } else { 599 } else {
601 if(iD==-5) { // green black 600 if(iD==-5) { // green black
602 foreground.setRgb(0x18,255,0x18); 601 foreground.setRgb(0x18,255,0x18);
603 background.setRgb(0x00,0x00,0x00); 602 background.setRgb(0x00,0x00,0x00);
604 cfg.writeEntry("Schema","5"); 603 cfg.writeEntry("Schema","5");
605 colorMenu->setItemChecked(-5,TRUE); 604 colorMenu->setItemChecked(-5,TRUE);
606 } 605 }
607 if(iD==-6) { // black white 606 if(iD==-6) { // black white
608 foreground.setRgb(0x00,0x00,0x00); 607 foreground.setRgb(0x00,0x00,0x00);
609 background.setRgb(0xFF,0xFF,0xFF); 608 background.setRgb(0xFF,0xFF,0xFF);
610 cfg.writeEntry("Schema","6"); 609 cfg.writeEntry("Schema","6");
611 colorMenu->setItemChecked(-6,TRUE); 610 colorMenu->setItemChecked(-6,TRUE);
612 } 611 }
613 if(iD==-7) { // white black 612 if(iD==-7) { // white black
614 foreground.setRgb(0xFF,0xFF,0xFF); 613 foreground.setRgb(0xFF,0xFF,0xFF);
615 background.setRgb(0x00,0x00,0x00); 614 background.setRgb(0x00,0x00,0x00);
616 cfg.writeEntry("Schema","7"); 615 cfg.writeEntry("Schema","7");
617 colorMenu->setItemChecked(-7,TRUE); 616 colorMenu->setItemChecked(-7,TRUE);
618 } 617 }
619 if(iD==-9) {// Black, Red 618 if(iD==-9) {// Black, Red
620 foreground.setRgb(0x00,0x00,0x00); 619 foreground.setRgb(0x00,0x00,0x00);
621 background.setRgb(0xB2,0x18,0x18); 620 background.setRgb(0xB2,0x18,0x18);
622 cfg.writeEntry("Schema","9"); 621 cfg.writeEntry("Schema","9");
623 colorMenu->setItemChecked(-9,TRUE); 622 colorMenu->setItemChecked(-9,TRUE);
624 } 623 }
625 if(iD==-10) {// Red, Black 624 if(iD==-10) {// Red, Black
626 foreground.setRgb(230,31,31); //0xB2,0x18,0x18 625 foreground.setRgb(230,31,31); //0xB2,0x18,0x18
627 background.setRgb(0x00,0x00,0x00); 626 background.setRgb(0x00,0x00,0x00);
628 cfg.writeEntry("Schema","10"); 627 cfg.writeEntry("Schema","10");
629 colorMenu->setItemChecked(-10,TRUE); 628 colorMenu->setItemChecked(-10,TRUE);
630 } 629 }
631 if(iD==-11) {// Green, Yellow - is ugly 630 if(iD==-11) {// Green, Yellow - is ugly
632// foreground.setRgb(0x18,0xB2,0x18); 631// foreground.setRgb(0x18,0xB2,0x18);
633 foreground.setRgb(36,139,10); 632 foreground.setRgb(36,139,10);
634// background.setRgb(0xB2,0x68,0x18); 633// background.setRgb(0xB2,0x68,0x18);
635 background.setRgb(255,255,0); 634 background.setRgb(255,255,0);
636 cfg.writeEntry("Schema","11"); 635 cfg.writeEntry("Schema","11");
637 colorMenu->setItemChecked(-11,TRUE); 636 colorMenu->setItemChecked(-11,TRUE);
638 } 637 }
639 if(iD==-12) {// Blue, Magenta 638 if(iD==-12) {// Blue, Magenta
640 foreground.setRgb(0x18,0xB2,0xB2); 639 foreground.setRgb(0x18,0xB2,0xB2);
641 background.setRgb(0x18,0x18,0xB2); 640 background.setRgb(0x18,0x18,0xB2);
642 cfg.writeEntry("Schema","12"); 641 cfg.writeEntry("Schema","12");
643 colorMenu->setItemChecked(-12,TRUE); 642 colorMenu->setItemChecked(-12,TRUE);
644 } 643 }
645 if(iD==-13) {// Magenta, Blue 644 if(iD==-13) {// Magenta, Blue
646 foreground.setRgb(0x18,0x18,0xB2); 645 foreground.setRgb(0x18,0x18,0xB2);
647 background.setRgb(0x18,0xB2,0xB2); 646 background.setRgb(0x18,0xB2,0xB2);
648 cfg.writeEntry("Schema","13"); 647 cfg.writeEntry("Schema","13");
649 colorMenu->setItemChecked(-13,TRUE); 648 colorMenu->setItemChecked(-13,TRUE);
650 } 649 }
651 if(iD==-14) {// Cyan, White 650 if(iD==-14) {// Cyan, White
652 foreground.setRgb(0x18,0xB2,0xB2); 651 foreground.setRgb(0x18,0xB2,0xB2);
653 background.setRgb(0xFF,0xFF,0xFF); 652 background.setRgb(0xFF,0xFF,0xFF);
654 cfg.writeEntry("Schema","14"); 653 cfg.writeEntry("Schema","14");
655 colorMenu->setItemChecked(-14,TRUE); 654 colorMenu->setItemChecked(-14,TRUE);
656 } 655 }
657 if(iD==-15) {// White, Cyan 656 if(iD==-15) {// White, Cyan
658 background.setRgb(0x18,0xB2,0xB2); 657 background.setRgb(0x18,0xB2,0xB2);
659 foreground.setRgb(0xFF,0xFF,0xFF); 658 foreground.setRgb(0xFF,0xFF,0xFF);
660 cfg.writeEntry("Schema","15"); 659 cfg.writeEntry("Schema","15");
661 colorMenu->setItemChecked(-15,TRUE); 660 colorMenu->setItemChecked(-15,TRUE);
662 } 661 }
663 if(iD==-16) {// Black, Blue 662 if(iD==-16) {// Black, Blue
664 background.setRgb(0x00,0x00,0x00); 663 background.setRgb(0x00,0x00,0x00);
665 foreground.setRgb(0x18,0xB2,0xB2); 664 foreground.setRgb(0x18,0xB2,0xB2);
666 cfg.writeEntry("Schema","16"); 665 cfg.writeEntry("Schema","16");
667 colorMenu->setItemChecked(-16,TRUE); 666 colorMenu->setItemChecked(-16,TRUE);
668 } 667 }
669 668
670 for (i = 0; i < TABLE_COLORS; i++) { 669 for (i = 0; i < TABLE_COLORS; i++) {
671 if(i==0 || i == 10) { 670 if(i==0 || i == 10) {
672 m_table[i].color = foreground; 671 m_table[i].color = foreground;
673 } 672 }
674 else if(i==1 || i == 11) { 673 else if(i==1 || i == 11) {
675 m_table[i].color = background; m_table[i].transparent=0; 674 m_table[i].color = background; m_table[i].transparent=0;
676 } 675 }
677 else 676 else
678 m_table[i].color = defaultCt[i].color; 677 m_table[i].color = defaultCt[i].color;
679 } 678 }
680 } 679 }
681 lastSelectedMenu = iD; 680 lastSelectedMenu = iD;
682 te->setColorTable(m_table); 681 te->setColorTable(m_table);
683 update(); 682 update();
684} 683}
685 684
686void Konsole::configMenuSelected(int iD) 685void Konsole::configMenuSelected(int iD)
687{ 686{
688// QString temp; 687 QString temp;
689// temp.sprintf("%d",iD); 688 qDebug( temp.sprintf("%d",iD));
690// qDebug(temp);
691 TEWidget* te = getTe(); 689 TEWidget* te = getTe();
692 Config cfg("Konsole"); 690 Config cfg("Konsole");
693 cfg.setGroup("Menubar"); 691 cfg.setGroup("Menubar");
694 if( iD == -2) { 692 if( iD == -2) {
695 if(!secondToolBar->isHidden()) { 693 if(!secondToolBar->isHidden()) {
696 secondToolBar->hide(); 694 secondToolBar->hide();
697 configMenu->changeItem( iD,"Show Command List"); 695 configMenu->changeItem( iD,"Show Command List");
698 cfg.writeEntry("Hidden","TRUE"); 696 cfg.writeEntry("Hidden","TRUE");
699 configMenu->setItemEnabled(-20 ,FALSE); 697 configMenu->setItemEnabled(-20 ,FALSE);
700 } else { 698 } else {
701 secondToolBar->show(); 699 secondToolBar->show();
702 configMenu->changeItem( iD,"Hide Command List"); 700 configMenu->changeItem( iD,"Hide Command List");
703 cfg.writeEntry("Hidden","FALSE"); 701 cfg.writeEntry("Hidden","FALSE");
704 configMenu->setItemEnabled(-20 ,TRUE); 702 configMenu->setItemEnabled(-20 ,TRUE);
705 703
706 if(cfg.readEntry("EditEnabled","FALSE")=="TRUE") { 704 if(cfg.readEntry("EditEnabled","FALSE")=="TRUE") {
707 configMenu->setItemChecked(-20,TRUE); 705 configMenu->setItemChecked(-20,TRUE);
708 commonCombo->setEditable( TRUE ); 706 commonCombo->setEditable( TRUE );
709 } else { 707 } else {
710 configMenu->setItemChecked(-20,FALSE); 708 configMenu->setItemChecked(-20,FALSE);
711 commonCombo->setEditable( FALSE ); 709 commonCombo->setEditable( FALSE );
712 } 710 }
713 } 711 }
714 } 712 }
715 if( iD == -3) { 713 if( iD == -3) {
716 cfg.setGroup("Tabs"); 714 cfg.setGroup("Tabs");
717 QString tmp=cfg.readEntry("Position","Top"); 715 QString tmp=cfg.readEntry("Position","Top");
718 716
719 if(tmp=="Top") { 717 if(tmp=="Top") {
720 tab->setTabPosition(QTabWidget::Bottom); 718 tab->setTabPosition(QTabWidget::Bottom);
721 configMenu->changeItem( iD,"Tabs on Top"); 719 configMenu->changeItem( iD,"Tabs on Top");
722 cfg.writeEntry("Position","Bottom"); 720 cfg.writeEntry("Position","Bottom");
723 } else { 721 } else {
724 tab->setTabPosition(QTabWidget::Top); 722 tab->setTabPosition(QTabWidget::Top);
725 configMenu->changeItem( iD,"Tabs on Bottom"); 723 configMenu->changeItem( iD,"Tabs on Bottom");
726 cfg.writeEntry("Position","Top"); 724 cfg.writeEntry("Position","Top");
727 } 725 }
728 } 726 }
729 if( iD == -20) { 727 if( iD == -20) {
730 cfg.setGroup("Commands"); 728 cfg.setGroup("Commands");
731// qDebug("enableCommandEdit"); 729// qDebug("enableCommandEdit");
732 if( !configMenu->isItemChecked(iD) ) { 730 if( !configMenu->isItemChecked(iD) ) {
733 commonCombo->setEditable( TRUE ); 731 commonCombo->setEditable( TRUE );
734 configMenu->setItemChecked(iD,TRUE); 732 configMenu->setItemChecked(iD,TRUE);
735 commonCombo->setCurrentItem(0); 733 commonCombo->setCurrentItem(0);
736 cfg.writeEntry("EditEnabled","TRUE"); 734 cfg.writeEntry("EditEnabled","TRUE");
737 } else { 735 } else {
738 commonCombo->setEditable( FALSE ); 736 commonCombo->setEditable( FALSE );
739 configMenu->setItemChecked(iD,FALSE); 737 configMenu->setItemChecked(iD,FALSE);
740 cfg.writeEntry("EditEnabled","FALSE"); 738 cfg.writeEntry("EditEnabled","FALSE");
741 commonCombo->setFocusPolicy(QWidget::NoFocus); 739 commonCombo->setFocusPolicy(QWidget::NoFocus);
742 te->setFocus(); 740 te->setFocus();
743 } 741 }
744 } 742 }
745} 743}
746 744
747void Konsole::changeCommand(const QString &text, int c) 745void Konsole::changeCommand(const QString &text, int c)
748{ 746{
749 Config cfg("Konsole"); 747 Config cfg("Konsole");
750 cfg.setGroup("Commands"); 748 cfg.setGroup("Commands");
751 if(commonCmds[c] != text) { 749 if(commonCmds[c] != text) {
752 cfg.writeEntry(QString::number(c),text); 750 cfg.writeEntry(QString::number(c),text);
753 commonCombo->clearEdit(); 751 commonCombo->clearEdit();
754 commonCombo->setCurrentItem(c); 752 commonCombo->setCurrentItem(c);
755 } 753 }
756} 754}
757 755
758void Konsole::setColor() 756void Konsole::setColor()
759{ 757{
760 Config cfg("Konsole"); 758 Config cfg("Konsole");
761 cfg.setGroup("Colors"); 759 cfg.setGroup("Colors");
762 int scheme = cfg.readNumEntry("Schema",1); 760 int scheme = cfg.readNumEntry("Schema",1);
763 if(scheme != 1) colorMenuSelected( -scheme); 761 if(scheme != 1) colorMenuSelected( -scheme);
764 762
765} 763}