summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2004-04-07 07:56:05 (UTC)
committer llornkcor <llornkcor>2004-04-07 07:56:05 (UTC)
commit00dda4de55885bf3942fe3d4b6cd552ee6f020bf (patch) (unidiff)
tree476f0e48eb5cef00b97c0602a846918d90974320
parenta1221f718bb1e9bcb6318dbf3314b9a35891caac (diff)
downloadopie-00dda4de55885bf3942fe3d4b6cd552ee6f020bf.zip
opie-00dda4de55885bf3942fe3d4b6cd552ee6f020bf.tar.gz
opie-00dda4de55885bf3942fe3d4b6cd552ee6f020bf.tar.bz2
re-add enter,space,tab,up,down icons, as convience for non keyboarded devices
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/embeddedkonsole/konsole.cpp5
1 files changed, 1 insertions, 4 deletions
diff --git a/core/apps/embeddedkonsole/konsole.cpp b/core/apps/embeddedkonsole/konsole.cpp
index ff5c2f1..8207f23 100644
--- a/core/apps/embeddedkonsole/konsole.cpp
+++ b/core/apps/embeddedkonsole/konsole.cpp
@@ -108,1038 +108,1035 @@ public:
108}; 108};
109 109
110class EKNumTabWidget : public QTabWidget 110class EKNumTabWidget : public QTabWidget
111{ 111{
112public: 112public:
113 EKNumTabWidget(QWidget* parent) : QTabWidget(parent) 113 EKNumTabWidget(QWidget* parent) : QTabWidget(parent)
114 { 114 {
115 setTabBar(new EKNumTabBar(parent,"EKTabBar")); 115 setTabBar(new EKNumTabBar(parent,"EKTabBar"));
116 setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); 116 setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );
117 } 117 }
118 118
119 EKNumTabBar *getTabBar() const 119 EKNumTabBar *getTabBar() const
120 { 120 {
121 return ((EKNumTabBar*)tabBar()); 121 return ((EKNumTabBar*)tabBar());
122 } 122 }
123 123
124 124
125 void addTab(QWidget* w) 125 void addTab(QWidget* w)
126 { 126 {
127 QTab* t = new QTab(QString::number(tabBar()->count()+1)); 127 QTab* t = new QTab(QString::number(tabBar()->count()+1));
128 QTabWidget::addTab(w,t); 128 QTabWidget::addTab(w,t);
129 } 129 }
130 130
131 void removeTab(QWidget* w) 131 void removeTab(QWidget* w)
132 { 132 {
133 removePage(w); 133 removePage(w);
134 ((EKNumTabBar*)tabBar())->numberTabs(); 134 ((EKNumTabBar*)tabBar())->numberTabs();
135 } 135 }
136}; 136};
137 137
138// This could be configurable or dynamicly generated from the bash history 138// This could be configurable or dynamicly generated from the bash history
139// file of the user 139// file of the user
140static const char *commonCmds[] = 140static const char *commonCmds[] =
141 { 141 {
142 "ls ", // I left this here, cause it looks better than the first alpha 142 "ls ", // I left this here, cause it looks better than the first alpha
143 "cardctl eject", 143 "cardctl eject",
144 "cat ", 144 "cat ",
145 "cd ", 145 "cd ",
146 "chmod ", 146 "chmod ",
147 "clear", 147 "clear",
148 "cp ", 148 "cp ",
149 "dc ", 149 "dc ",
150 "df ", 150 "df ",
151 "dmesg", 151 "dmesg",
152 "echo ", 152 "echo ",
153 "env", 153 "env",
154 "find ", 154 "find ",
155 "free", 155 "free",
156 "grep ", 156 "grep ",
157 "ifconfig ", 157 "ifconfig ",
158 "ipkg ", 158 "ipkg ",
159 "mkdir ", 159 "mkdir ",
160 "mv ", 160 "mv ",
161 "nc localhost 7776", 161 "nc localhost 7776",
162 "nc localhost 7777", 162 "nc localhost 7777",
163 "netstat ", 163 "netstat ",
164 "nslookup ", 164 "nslookup ",
165 "ping ", 165 "ping ",
166 "ps aux", 166 "ps aux",
167 "pwd ", 167 "pwd ",
168 "qcop QPE/System 'linkChanged(QString)' ''", 168 "qcop QPE/System 'linkChanged(QString)' ''",
169 "qcop QPE/System 'restart()'", 169 "qcop QPE/System 'restart()'",
170 "qcop QPE/System 'quit()'", 170 "qcop QPE/System 'quit()'",
171 "rm ", 171 "rm ",
172 "rmdir ", 172 "rmdir ",
173 "route ", 173 "route ",
174 "set ", 174 "set ",
175 "traceroute", 175 "traceroute",
176 176
177 /* 177 /*
178 "gzip", 178 "gzip",
179 "gunzip", 179 "gunzip",
180 "chgrp", 180 "chgrp",
181 "chown", 181 "chown",
182 "date", 182 "date",
183 "dd", 183 "dd",
184 "df", 184 "df",
185 "dmesg", 185 "dmesg",
186 "fuser", 186 "fuser",
187 "hostname", 187 "hostname",
188 "kill", 188 "kill",
189 "killall", 189 "killall",
190 "ln", 190 "ln",
191 "ping", 191 "ping",
192 "mount", 192 "mount",
193 "more", 193 "more",
194 "sort", 194 "sort",
195 "touch", 195 "touch",
196 "umount", 196 "umount",
197 "mknod", 197 "mknod",
198 "netstat", 198 "netstat",
199 */ 199 */
200 200
201 "exit", 201 "exit",
202 NULL 202 NULL
203 }; 203 };
204 204
205 205
206static void konsoleInit(const char** shell) { 206static void konsoleInit(const char** shell) {
207 if(setuid(getuid()) !=0) qDebug("setuid failed"); 207 if(setuid(getuid()) !=0) qDebug("setuid failed");
208 if(setgid(getgid()) != 0) qDebug("setgid failed"); // drop privileges 208 if(setgid(getgid()) != 0) qDebug("setgid failed"); // drop privileges
209 209
210 210
211// QPEApplication::grabKeyboard(); // for CTRL and ALT 211// QPEApplication::grabKeyboard(); // for CTRL and ALT
212 212
213 qDebug("keyboard grabbed"); 213 qDebug("keyboard grabbed");
214#ifdef FAKE_CTRL_AND_ALT 214#ifdef FAKE_CTRL_AND_ALT
215 qDebug("Fake Ctrl and Alt defined"); 215 qDebug("Fake Ctrl and Alt defined");
216 QPEApplication::grabKeyboard(); // for CTRL and ALT 216 QPEApplication::grabKeyboard(); // for CTRL and ALT
217#endif 217#endif
218 218
219 *shell = getenv("SHELL"); 219 *shell = getenv("SHELL");
220 qWarning("SHell initially is %s", *shell ); 220 qWarning("SHell initially is %s", *shell );
221 221
222 if (shell == NULL || *shell == '\0') { 222 if (shell == NULL || *shell == '\0') {
223 struct passwd *ent = 0; 223 struct passwd *ent = 0;
224 uid_t me = getuid(); 224 uid_t me = getuid();
225 *shell = "/bin/sh"; 225 *shell = "/bin/sh";
226 226
227 while ( (ent = getpwent()) != 0 ) { 227 while ( (ent = getpwent()) != 0 ) {
228 if (ent->pw_uid == me) { 228 if (ent->pw_uid == me) {
229 if (ent->pw_shell != "") 229 if (ent->pw_shell != "")
230 *shell = ent->pw_shell; 230 *shell = ent->pw_shell;
231 break; 231 break;
232 } 232 }
233 } 233 }
234 endpwent(); 234 endpwent();
235 } 235 }
236 236
237 if( putenv((char*)"COLORTERM=") !=0) 237 if( putenv((char*)"COLORTERM=") !=0)
238 qDebug("putenv failed"); // to trigger mc's color detection 238 qDebug("putenv failed"); // to trigger mc's color detection
239} 239}
240 240
241 241
242Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) : 242Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) :
243 QMainWindow(parent, name, fl) 243 QMainWindow(parent, name, fl)
244{ 244{
245 QStrList tmp; const char* shell; 245 QStrList tmp; const char* shell;
246 246
247 konsoleInit( &shell); 247 konsoleInit( &shell);
248 init(shell,tmp); 248 init(shell,tmp);
249} 249}
250 250
251Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int) 251Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int)
252 : QMainWindow(0, name) 252 : QMainWindow(0, name)
253{ 253{
254 init(_pgm,_args); 254 init(_pgm,_args);
255} 255}
256 256
257struct HistoryItem 257struct HistoryItem
258{ 258{
259 HistoryItem(int c, const QString &l) 259 HistoryItem(int c, const QString &l)
260 { 260 {
261 count = c; 261 count = c;
262 line = l; 262 line = l;
263 } 263 }
264 int count; 264 int count;
265 QString line; 265 QString line;
266}; 266};
267 267
268class HistoryList : public QList<HistoryItem> 268class HistoryList : public QList<HistoryItem>
269{ 269{
270 virtual int compareItems( QCollection::Item item1, QCollection::Item item2) 270 virtual int compareItems( QCollection::Item item1, QCollection::Item item2)
271 { 271 {
272 int c1 = ((HistoryItem*)item1)->count; 272 int c1 = ((HistoryItem*)item1)->count;
273 int c2 = ((HistoryItem*)item2)->count; 273 int c2 = ((HistoryItem*)item2)->count;
274 if (c1 > c2) 274 if (c1 > c2)
275 return(1); 275 return(1);
276 if (c1 < c2) 276 if (c1 < c2)
277 return(-1); 277 return(-1);
278 return(0); 278 return(0);
279 } 279 }
280}; 280};
281 281
282void Konsole::initCommandList() 282void Konsole::initCommandList()
283{ 283{
284 // qDebug("Konsole::initCommandList"); 284 // qDebug("Konsole::initCommandList");
285 Config cfg( "Konsole" ); 285 Config cfg( "Konsole" );
286 cfg.setGroup("Commands"); 286 cfg.setGroup("Commands");
287 // commonCombo->setInsertionPolicy(QComboBox::AtCurrent); 287 // commonCombo->setInsertionPolicy(QComboBox::AtCurrent);
288 commonCombo->clear(); 288 commonCombo->clear();
289 289
290 if (cfg.readEntry("ShellHistory","TRUE") == "TRUE") 290 if (cfg.readEntry("ShellHistory","TRUE") == "TRUE")
291 { 291 {
292 QString histfilename = QString(getenv("HOME")) + "/.bash_history"; 292 QString histfilename = QString(getenv("HOME")) + "/.bash_history";
293 histfilename = cfg.readEntry("ShellHistoryPath",histfilename); 293 histfilename = cfg.readEntry("ShellHistoryPath",histfilename);
294 QFile histfile(histfilename); 294 QFile histfile(histfilename);
295 // note: compiler barfed on: 295 // note: compiler barfed on:
296 // QFile histfile(QString(getenv("HOME")) + "/.bash_history"); 296 // QFile histfile(QString(getenv("HOME")) + "/.bash_history");
297 if (histfile.open( IO_ReadOnly )) 297 if (histfile.open( IO_ReadOnly ))
298 { 298 {
299 QString line; 299 QString line;
300 uint i; 300 uint i;
301 HistoryList items; 301 HistoryList items;
302 302
303 int lineno = 0; 303 int lineno = 0;
304 while(!histfile.atEnd()) 304 while(!histfile.atEnd())
305 { 305 {
306 if (histfile.readLine(line, 200) < 0) 306 if (histfile.readLine(line, 200) < 0)
307 { 307 {
308 break; 308 break;
309 } 309 }
310 line = line.left(line.length()-1); 310 line = line.left(line.length()-1);
311 lineno++; 311 lineno++;
312 312
313 for(i=0; i<items.count(); i++) 313 for(i=0; i<items.count(); i++)
314 { 314 {
315 if (line == items.at(i)->line) 315 if (line == items.at(i)->line)
316 { 316 {
317 // weight recent commands & repeated commands more 317 // weight recent commands & repeated commands more
318 // by adding up the index of each command 318 // by adding up the index of each command
319 items.at(i)->count += lineno; 319 items.at(i)->count += lineno;
320 break; 320 break;
321 } 321 }
322 } 322 }
323 if (i >= items.count()) 323 if (i >= items.count())
324 { 324 {
325 items.append(new HistoryItem(lineno, line)); 325 items.append(new HistoryItem(lineno, line));
326 } 326 }
327 } 327 }
328 items.sort(); 328 items.sort();
329 int n = items.count(); 329 int n = items.count();
330 if (n > 40) 330 if (n > 40)
331 { 331 {
332 n = 40; 332 n = 40;
333 } 333 }
334 for(int i=0; i<n; i++) 334 for(int i=0; i<n; i++)
335 { 335 {
336 // should insert start of command, but keep whole thing 336 // should insert start of command, but keep whole thing
337 if (items.at(items.count()-i-1)->line.length() < 30) 337 if (items.at(items.count()-i-1)->line.length() < 30)
338 { 338 {
339 commonCombo->insertItem(items.at(items.count()-i-1)->line); 339 commonCombo->insertItem(items.at(items.count()-i-1)->line);
340 } 340 }
341 } 341 }
342 histfile.close(); 342 histfile.close();
343 } 343 }
344 } 344 }
345 if (cfg.readEntry("Commands Set","FALSE") == "FALSE") 345 if (cfg.readEntry("Commands Set","FALSE") == "FALSE")
346 { 346 {
347 for (int i = 0; commonCmds[i] != NULL; i++) 347 for (int i = 0; commonCmds[i] != NULL; i++)
348 { 348 {
349 commonCombo->insertItem(commonCmds[i]); 349 commonCombo->insertItem(commonCmds[i]);
350 } 350 }
351 } 351 }
352 else 352 else
353 { 353 {
354 for (int i = 0; i < 100; i++) 354 for (int i = 0; i < 100; i++)
355 { 355 {
356 if (!(cfg.readEntry( QString::number(i),"")).isEmpty()) 356 if (!(cfg.readEntry( QString::number(i),"")).isEmpty())
357 commonCombo->insertItem(cfg.readEntry( QString::number(i),"")); 357 commonCombo->insertItem(cfg.readEntry( QString::number(i),""));
358 } 358 }
359 } 359 }
360 360
361 361
362} 362}
363 363
364static void sig_handler(int x) 364static void sig_handler(int x)
365{ 365{
366 printf("got signal %d\n",x); 366 printf("got signal %d\n",x);
367} 367}
368 368
369void Konsole::init(const char* _pgm, QStrList & _args) 369void Konsole::init(const char* _pgm, QStrList & _args)
370{ 370{
371 371
372#if 0 372#if 0
373 for(int i=1; i<=31; i++) 373 for(int i=1; i<=31; i++)
374 { 374 {
375 if (i != SIGPIPE && i != SIGPROF && i != SIGSEGV 375 if (i != SIGPIPE && i != SIGPROF && i != SIGSEGV
376 && i != SIGINT && i != SIGILL && i != SIGTERM 376 && i != SIGINT && i != SIGILL && i != SIGTERM
377 && i != SIGBUS) 377 && i != SIGBUS)
378 signal(i,sig_handler); 378 signal(i,sig_handler);
379 } 379 }
380#endif 380#endif
381 signal(SIGSTOP, sig_handler); 381 signal(SIGSTOP, sig_handler);
382 signal(SIGCONT, sig_handler); 382 signal(SIGCONT, sig_handler);
383 signal(SIGTSTP, sig_handler); 383 signal(SIGTSTP, sig_handler);
384 384
385 b_scroll = TRUE; // histon; 385 b_scroll = TRUE; // histon;
386 n_keytab = 0; 386 n_keytab = 0;
387 n_render = 0; 387 n_render = 0;
388 startUp=0; 388 startUp=0;
389 fromMenu = FALSE; 389 fromMenu = FALSE;
390 fullscreen = false; 390 fullscreen = false;
391 391
392 setCaption( tr( "Konsole" ) ); 392 setCaption( tr( "Konsole" ) );
393 setIcon( Resource::loadPixmap( "konsole/Terminal" ) ); 393 setIcon( Resource::loadPixmap( "konsole/Terminal" ) );
394 394
395 Config cfg( "Konsole" ); 395 Config cfg( "Konsole" );
396 cfg.setGroup("Font"); 396 cfg.setGroup("Font");
397 QString tmp; 397 QString tmp;
398 398
399 // initialize the list of allowed fonts /////////////////////////////////// 399 // initialize the list of allowed fonts ///////////////////////////////////
400 400
401 QString cfgFontName = cfg.readEntry("FontName","Lcfont"); 401 QString cfgFontName = cfg.readEntry("FontName","Lcfont");
402 int cfgFontSize = cfg.readNumEntry("FontSize",18); 402 int cfgFontSize = cfg.readNumEntry("FontSize",18);
403 403
404 cfont = -1; 404 cfont = -1;
405 405
406 // this code causes repeated access to all the font files 406 // this code causes repeated access to all the font files
407 // which does slow down startup 407 // which does slow down startup
408 QFontDatabase fontDB; 408 QFontDatabase fontDB;
409 QStringList familyNames; 409 QStringList familyNames;
410 familyNames = fontDB.families( FALSE ); 410 familyNames = fontDB.families( FALSE );
411 QString s; 411 QString s;
412 int fontIndex = 0; 412 int fontIndex = 0;
413 int familyNum = 0; 413 int familyNum = 0;
414 fontList = new QPopupMenu( this ); 414 fontList = new QPopupMenu( this );
415 415
416 for(uint j = 0; j < (uint)familyNames.count(); j++) 416 for(uint j = 0; j < (uint)familyNames.count(); j++)
417 { 417 {
418 s = familyNames[j]; 418 s = familyNames[j];
419 if ( s.contains('-') ) 419 if ( s.contains('-') )
420 { 420 {
421 int i = s.find('-'); 421 int i = s.find('-');
422 s = s.right( s.length() - i - 1 ) + " [" + s.left( i ) + "]"; 422 s = s.right( s.length() - i - 1 ) + " [" + s.left( i ) + "]";
423 } 423 }
424 s[0] = s[0].upper(); 424 s[0] = s[0].upper();
425 425
426 QValueList<int> sizes = fontDB.pointSizes( familyNames[j] ); 426 QValueList<int> sizes = fontDB.pointSizes( familyNames[j] );
427 427
428 printf("family[%d] = %s with %d sizes\n", j, familyNames[j].latin1(), 428 printf("family[%d] = %s with %d sizes\n", j, familyNames[j].latin1(),
429 sizes.count()); 429 sizes.count());
430 430
431 if (sizes.count() > 0) 431 if (sizes.count() > 0)
432 { 432 {
433 QPopupMenu *sizeMenu; 433 QPopupMenu *sizeMenu;
434 QFont f; 434 QFont f;
435 int last_width = -1; 435 int last_width = -1;
436 sizeMenu = NULL; 436 sizeMenu = NULL;
437 437
438 for(uint i = 0; i < (uint)sizes.count() + 4; i++) 438 for(uint i = 0; i < (uint)sizes.count() + 4; i++)
439 { 439 {
440 // printf("family %s size %d ", familyNames[j].latin1(), sizes[i]); 440 // printf("family %s size %d ", familyNames[j].latin1(), sizes[i]);
441 // need to divide by 10 on the Z, but not otherwise 441 // need to divide by 10 on the Z, but not otherwise
442 int size; 442 int size;
443 443
444 if (i >= (uint)sizes.count()) 444 if (i >= (uint)sizes.count())
445 { 445 {
446 // try for expandable fonts 446 // try for expandable fonts
447 size = sizes[sizes.count()-1] + 2 * (i - sizes.count() + 1); 447 size = sizes[sizes.count()-1] + 2 * (i - sizes.count() + 1);
448 } 448 }
449 else 449 else
450 { 450 {
451 printf("sizes[%d] = %d\n", i, sizes[i]); 451 printf("sizes[%d] = %d\n", i, sizes[i]);
452 size = sizes[i]; 452 size = sizes[i];
453 } 453 }
454 454
455 f = QFont(familyNames[j], size); 455 f = QFont(familyNames[j], size);
456 f.setFixedPitch(true); 456 f.setFixedPitch(true);
457 QFontMetrics fm(f); 457 QFontMetrics fm(f);
458 // don't trust f.fixedPitch() or f.exactMatch(), they lie!! 458 // don't trust f.fixedPitch() or f.exactMatch(), they lie!!
459 if (fm.width("l") == fm.width("m") 459 if (fm.width("l") == fm.width("m")
460 && (i < (uint)sizes.count() 460 && (i < (uint)sizes.count()
461 || fm.width("m") > last_width)) 461 || fm.width("m") > last_width))
462 { 462 {
463 if (i < (uint)sizes.count()) 463 if (i < (uint)sizes.count())
464 { 464 {
465 last_width = fm.width("m"); 465 last_width = fm.width("m");
466 } 466 }
467 if (sizeMenu == NULL) 467 if (sizeMenu == NULL)
468 { 468 {
469 sizeMenu = new QPopupMenu(); 469 sizeMenu = new QPopupMenu();
470 } 470 }
471 int id = sizeMenu->insertItem(QString("%1").arg(size), fontIndex); 471 int id = sizeMenu->insertItem(QString("%1").arg(size), fontIndex);
472 sizeMenu->setItemParameter(id, fontIndex); 472 sizeMenu->setItemParameter(id, fontIndex);
473 sizeMenu->connectItem(id, this, SLOT(setFont(int))); 473 sizeMenu->connectItem(id, this, SLOT(setFont(int)));
474 QString name = s + " " + QString::number(size); 474 QString name = s + " " + QString::number(size);
475 fonts.append(new VTFont(name, f, familyNames[j], familyNum, size)); 475 fonts.append(new VTFont(name, f, familyNames[j], familyNum, size));
476 if (familyNames[j] == cfgFontName && size == cfgFontSize) 476 if (familyNames[j] == cfgFontName && size == cfgFontSize)
477 { 477 {
478 cfont = fontIndex; 478 cfont = fontIndex;
479 } 479 }
480 printf("FOUND: %s family %s size %d\n", name.latin1(), familyNames[j].latin1(), size); 480 printf("FOUND: %s family %s size %d\n", name.latin1(), familyNames[j].latin1(), size);
481 fontIndex++; 481 fontIndex++;
482 } 482 }
483 } 483 }
484 if (sizeMenu) 484 if (sizeMenu)
485 { 485 {
486 fontList->insertItem(s, sizeMenu, familyNum + 1000); 486 fontList->insertItem(s, sizeMenu, familyNum + 1000);
487 487
488 familyNum++; 488 familyNum++;
489 } 489 }
490 } 490 }
491 491
492 } 492 }
493 493
494 if (cfont < 0 || cfont >= (int)fonts.count()) 494 if (cfont < 0 || cfont >= (int)fonts.count())
495 { 495 {
496 cfont = 0; 496 cfont = 0;
497 } 497 }
498 498
499 // create terminal emulation framework //////////////////////////////////// 499 // create terminal emulation framework ////////////////////////////////////
500 nsessions = 0; 500 nsessions = 0;
501 501
502 tab = new EKNumTabWidget(this); 502 tab = new EKNumTabWidget(this);
503 // tab->setMargin(tab->margin()-5); 503 // tab->setMargin(tab->margin()-5);
504 connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*))); 504 connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*)));
505 505
506 // create terminal toolbar //////////////////////////////////////////////// 506 // create terminal toolbar ////////////////////////////////////////////////
507 setToolBarsMovable( FALSE ); 507 setToolBarsMovable( FALSE );
508 menuToolBar = new QToolBar( this ); 508 menuToolBar = new QToolBar( this );
509 menuToolBar->setHorizontalStretchable( TRUE ); 509 menuToolBar->setHorizontalStretchable( TRUE );
510 510
511 QMenuBar *menuBar = new QMenuBar( menuToolBar ); 511 QMenuBar *menuBar = new QMenuBar( menuToolBar );
512 512
513 setFont(cfont); 513 setFont(cfont);
514 514
515 configMenu = new QPopupMenu( this); 515 configMenu = new QPopupMenu( this);
516 colorMenu = new QPopupMenu( this); 516 colorMenu = new QPopupMenu( this);
517 scrollMenu = new QPopupMenu( this); 517 scrollMenu = new QPopupMenu( this);
518 editCommandListMenu = new QPopupMenu( this); 518 editCommandListMenu = new QPopupMenu( this);
519 519
520 configMenu->insertItem(tr("Command List"), editCommandListMenu); 520 configMenu->insertItem(tr("Command List"), editCommandListMenu);
521 521
522 bool listHidden; 522 bool listHidden;
523 cfg.setGroup("Menubar"); 523 cfg.setGroup("Menubar");
524 if( cfg.readEntry("Hidden","FALSE") == "TRUE") 524 if( cfg.readEntry("Hidden","FALSE") == "TRUE")
525 { 525 {
526 ec_cmdlist = editCommandListMenu->insertItem( tr( "Show command list" )); 526 ec_cmdlist = editCommandListMenu->insertItem( tr( "Show command list" ));
527 listHidden=TRUE; 527 listHidden=TRUE;
528 } 528 }
529 else 529 else
530 { 530 {
531 ec_cmdlist = editCommandListMenu->insertItem( tr( "Hide command list" )); 531 ec_cmdlist = editCommandListMenu->insertItem( tr( "Hide command list" ));
532 listHidden=FALSE; 532 listHidden=FALSE;
533 } 533 }
534 534
535 cfg.setGroup("Tabs"); 535 cfg.setGroup("Tabs");
536 536
537 tabMenu = new QPopupMenu(this); 537 tabMenu = new QPopupMenu(this);
538 tm_bottom = tabMenu->insertItem(tr("Bottom" )); 538 tm_bottom = tabMenu->insertItem(tr("Bottom" ));
539 tm_top = tabMenu->insertItem(tr("Top")); 539 tm_top = tabMenu->insertItem(tr("Top"));
540 tm_hidden = tabMenu->insertItem(tr("Hidden")); 540 tm_hidden = tabMenu->insertItem(tr("Hidden"));
541 541
542 configMenu->insertItem(tr("Tabs"), tabMenu); 542 configMenu->insertItem(tr("Tabs"), tabMenu);
543 543
544 tmp=cfg.readEntry("Position","Top"); 544 tmp=cfg.readEntry("Position","Top");
545 if(tmp=="Top") 545 if(tmp=="Top")
546 { 546 {
547 tab->setTabPosition(QTabWidget::Top); 547 tab->setTabPosition(QTabWidget::Top);
548 tab->getTabBar()->show(); 548 tab->getTabBar()->show();
549 tabPos = tm_top; 549 tabPos = tm_top;
550 } 550 }
551 else if (tmp=="Bottom") 551 else if (tmp=="Bottom")
552 { 552 {
553 tab->setTabPosition(QTabWidget::Bottom); 553 tab->setTabPosition(QTabWidget::Bottom);
554 tab->getTabBar()->show(); 554 tab->getTabBar()->show();
555 tabPos = tm_bottom; 555 tabPos = tm_bottom;
556 } 556 }
557 else 557 else
558 { 558 {
559 tab->getTabBar()->hide(); 559 tab->getTabBar()->hide();
560 tab->setMargin(tab->margin()); 560 tab->setMargin(tab->margin());
561 tabPos = tm_hidden; 561 tabPos = tm_hidden;
562 } 562 }
563 563
564 cm_bw = colorMenu->insertItem(tr( "Black on White")); 564 cm_bw = colorMenu->insertItem(tr( "Black on White"));
565 cm_wb = colorMenu->insertItem(tr( "White on Black")); 565 cm_wb = colorMenu->insertItem(tr( "White on Black"));
566 cm_gb = colorMenu->insertItem(tr( "Green on Black")); 566 cm_gb = colorMenu->insertItem(tr( "Green on Black"));
567 // cm_bt = colorMenu->insertItem(tr( "Black on Transparent")); 567 // cm_bt = colorMenu->insertItem(tr( "Black on Transparent"));
568 cm_br = colorMenu->insertItem(tr( "Black on Pink")); 568 cm_br = colorMenu->insertItem(tr( "Black on Pink"));
569 cm_rb = colorMenu->insertItem(tr( "Pink on Black")); 569 cm_rb = colorMenu->insertItem(tr( "Pink on Black"));
570 cm_gy = colorMenu->insertItem(tr( "Green on Yellow")); 570 cm_gy = colorMenu->insertItem(tr( "Green on Yellow"));
571 cm_bm = colorMenu->insertItem(tr( "Blue on Magenta")); 571 cm_bm = colorMenu->insertItem(tr( "Blue on Magenta"));
572 cm_mb = colorMenu->insertItem(tr( "Magenta on Blue")); 572 cm_mb = colorMenu->insertItem(tr( "Magenta on Blue"));
573 cm_cw = colorMenu->insertItem(tr( "Cyan on White")); 573 cm_cw = colorMenu->insertItem(tr( "Cyan on White"));
574 cm_wc = colorMenu->insertItem(tr( "White on Cyan")); 574 cm_wc = colorMenu->insertItem(tr( "White on Cyan"));
575 cm_bb = colorMenu->insertItem(tr( "Blue on Black")); 575 cm_bb = colorMenu->insertItem(tr( "Blue on Black"));
576 cm_ab = colorMenu->insertItem(tr( "Amber on Black")); 576 cm_ab = colorMenu->insertItem(tr( "Amber on Black"));
577 cm_default = colorMenu->insertItem(tr("default")); 577 cm_default = colorMenu->insertItem(tr("default"));
578 578
579#ifdef QT_QWS_OPIE 579#ifdef QT_QWS_OPIE
580 580
581 colorMenu->insertItem(tr( "Custom")); 581 colorMenu->insertItem(tr( "Custom"));
582#endif 582#endif
583 583
584 configMenu->insertItem(tr( "Colors") ,colorMenu); 584 configMenu->insertItem(tr( "Colors") ,colorMenu);
585 585
586 sessionList = new QPopupMenu(this); 586 sessionList = new QPopupMenu(this);
587 sessionList-> insertItem ( Resource::loadPixmap ( "konsole/Terminal" ), tr( "new session" ), this, 587 sessionList-> insertItem ( Resource::loadPixmap ( "konsole/Terminal" ), tr( "new session" ), this,
588 SLOT(newSession()) ); 588 SLOT(newSession()) );
589 589
590 // connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) )); 590 // connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) ));
591 connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) )); 591 connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) ));
592 connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuIsSelected(int) )); 592 connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuIsSelected(int) ));
593 connect( tabMenu, SIGNAL( activated(int) ), this, SLOT( tabMenuSelected(int) )); 593 connect( tabMenu, SIGNAL( activated(int) ), this, SLOT( tabMenuSelected(int) ));
594 connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int))); 594 connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int)));
595 connect( editCommandListMenu,SIGNAL(activated(int)),this,SLOT(editCommandListMenuSelected(int))); 595 connect( editCommandListMenu,SIGNAL(activated(int)),this,SLOT(editCommandListMenuSelected(int)));
596 connect( sessionList, SIGNAL(activated(int)), this, SLOT( sessionListSelected(int) ) ); 596 connect( sessionList, SIGNAL(activated(int)), this, SLOT( sessionListSelected(int) ) );
597 597
598 menuBar->insertItem( tr("View"), configMenu ); 598 menuBar->insertItem( tr("View"), configMenu );
599 menuBar->insertItem( tr("Fonts"), fontList ); 599 menuBar->insertItem( tr("Fonts"), fontList );
600 menuBar->insertItem( tr("Sessions"), sessionList ); 600 menuBar->insertItem( tr("Sessions"), sessionList );
601 601
602 toolBar = new QToolBar( this ); 602 toolBar = new QToolBar( this );
603 603
604 QAction *a; 604 QAction *a;
605 605
606 // Button Commands 606 // Button Commands
607 a = new QAction( tr("New"), Resource::loadPixmap( "konsole/Terminal" ), QString::null, 0, this, 0 ); 607 a = new QAction( tr("New"), Resource::loadPixmap( "konsole/Terminal" ), QString::null, 0, this, 0 );
608 connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); 608 connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) );
609 a->addTo( toolBar ); 609 a->addTo( toolBar );
610 610
611 a = new QAction( tr("Full Screen"), Resource::loadPixmap( "fullscreen" ), QString::null, 0, this, 0 ); 611 a = new QAction( tr("Full Screen"), Resource::loadPixmap( "fullscreen" ), QString::null, 0, this, 0 );
612 connect( a, SIGNAL( activated() ), this, SLOT( toggleFullScreen() ) ); 612 connect( a, SIGNAL( activated() ), this, SLOT( toggleFullScreen() ) );
613 a->addTo( toolBar ); 613 a->addTo( toolBar );
614 614
615 a = new QAction( tr("Zoom"), Resource::loadPixmap( "zoom" ), QString::null, 0, this, 0 ); 615 a = new QAction( tr("Zoom"), Resource::loadPixmap( "zoom" ), QString::null, 0, this, 0 );
616 connect( a, SIGNAL( activated() ), this, SLOT( cycleZoom() ) ); 616 connect( a, SIGNAL( activated() ), this, SLOT( cycleZoom() ) );
617 a->addTo( toolBar ); 617 a->addTo( toolBar );
618 618
619 619
620 /*
621 a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 ); 620 a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 );
622 connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolBar ); 621 connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolBar );
623 a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 ); 622 a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 );
624 connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolBar ); 623 connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolBar );
625 a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 ); 624 a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 );
626 connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolBar ); 625 connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolBar );
627 */
628 /*
629 a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 ); 626 a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 );
630 connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolBar ); 627 connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolBar );
631 a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 ); 628 a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 );
632 connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolBar ); 629 connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolBar );
633 */ 630
634 a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); 631 a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 );
635 connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); 632 connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) );
636 a->addTo( toolBar ); 633 a->addTo( toolBar );
637 634
638 secondToolBar = new QToolBar( this ); 635 secondToolBar = new QToolBar( this );
639 secondToolBar->setHorizontalStretchable( TRUE ); 636 secondToolBar->setHorizontalStretchable( TRUE );
640 637
641 commonCombo = new QComboBox( secondToolBar ); 638 commonCombo = new QComboBox( secondToolBar );
642 // commonCombo->setMaximumWidth(236); 639 // commonCombo->setMaximumWidth(236);
643 640
644 ec_quick = editCommandListMenu->insertItem( tr( "Quick Edit" ) ); 641 ec_quick = editCommandListMenu->insertItem( tr( "Quick Edit" ) );
645 if( listHidden) 642 if( listHidden)
646 { 643 {
647 secondToolBar->hide(); 644 secondToolBar->hide();
648 editCommandListMenu->setItemEnabled(ec_quick ,FALSE); 645 editCommandListMenu->setItemEnabled(ec_quick ,FALSE);
649 } 646 }
650 ec_edit = editCommandListMenu->insertItem(tr( "Edit..." ) ); 647 ec_edit = editCommandListMenu->insertItem(tr( "Edit..." ) );
651 648
652 cfg.setGroup("Commands"); 649 cfg.setGroup("Commands");
653 commonCombo->setInsertionPolicy(QComboBox::AtCurrent); 650 commonCombo->setInsertionPolicy(QComboBox::AtCurrent);
654 651
655 initCommandList(); 652 initCommandList();
656 // for (int i = 0; commonCmds[i] != NULL; i++) { 653 // for (int i = 0; commonCmds[i] != NULL; i++) {
657 // commonCombo->insertItem( commonCmds[i], i ); 654 // commonCombo->insertItem( commonCmds[i], i );
658 // tmp = cfg.readEntry( QString::number(i),""); 655 // tmp = cfg.readEntry( QString::number(i),"");
659 // if(tmp != "") 656 // if(tmp != "")
660 // commonCombo->changeItem( tmp,i ); 657 // commonCombo->changeItem( tmp,i );
661 // } 658 // }
662 659
663 connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) )); 660 connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) ));
664 661
665 sm_none = scrollMenu->insertItem(tr( "None" )); 662 sm_none = scrollMenu->insertItem(tr( "None" ));
666 sm_left = scrollMenu->insertItem(tr( "Left" )); 663 sm_left = scrollMenu->insertItem(tr( "Left" ));
667 sm_right = scrollMenu->insertItem(tr( "Right" )); 664 sm_right = scrollMenu->insertItem(tr( "Right" ));
668 // scrollMenu->insertSeparator(4); 665 // scrollMenu->insertSeparator(4);
669 // scrollMenu->insertItem(tr( "Horizontal" )); 666 // scrollMenu->insertItem(tr( "Horizontal" ));
670 667
671 configMenu->insertItem(tr( "ScrollBar" ),scrollMenu); 668 configMenu->insertItem(tr( "ScrollBar" ),scrollMenu);
672 669
673 configMenu->insertItem(tr( "History..." ), this, SLOT(historyDialog())); 670 configMenu->insertItem(tr( "History..." ), this, SLOT(historyDialog()));
674 671
675 cm_wrap = configMenu->insertItem(tr( "Wrap" )); 672 cm_wrap = configMenu->insertItem(tr( "Wrap" ));
676 cfg.setGroup("ScrollBar"); 673 cfg.setGroup("ScrollBar");
677 configMenu->setItemChecked(cm_wrap, cfg.readBoolEntry("HorzScroll",0)); 674 configMenu->setItemChecked(cm_wrap, cfg.readBoolEntry("HorzScroll",0));
678 675
679 cm_beep = configMenu->insertItem(tr( "Use Beep" )); 676 cm_beep = configMenu->insertItem(tr( "Use Beep" ));
680 cfg.setGroup("Menubar"); 677 cfg.setGroup("Menubar");
681 configMenu->setItemChecked(cm_beep, cfg.readBoolEntry("useBeep",0)); 678 configMenu->setItemChecked(cm_beep, cfg.readBoolEntry("useBeep",0));
682 679
683 fullscreen_msg = new QLabel(this); 680 fullscreen_msg = new QLabel(this);
684 fullscreen_msg-> setAlignment ( AlignCenter | SingleLine ); 681 fullscreen_msg-> setAlignment ( AlignCenter | SingleLine );
685 fullscreen_msg-> hide(); 682 fullscreen_msg-> hide();
686 fullscreen_msg-> setSizePolicy ( QSizePolicy ( QSizePolicy::Expanding, QSizePolicy::Expanding )); 683 fullscreen_msg-> setSizePolicy ( QSizePolicy ( QSizePolicy::Expanding, QSizePolicy::Expanding ));
687 fullscreen_msg-> setAutoResize(true); 684 fullscreen_msg-> setAutoResize(true);
688 fullscreen_msg-> setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 685 fullscreen_msg-> setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
689 fullscreen_msg-> setText(tr("To exit fullscreen, tap here.")); 686 fullscreen_msg-> setText(tr("To exit fullscreen, tap here."));
690 687
691 fullscreen_timer = new QTimer(this); 688 fullscreen_timer = new QTimer(this);
692 connect(fullscreen_timer, SIGNAL(timeout()), 689 connect(fullscreen_timer, SIGNAL(timeout()),
693 this, SLOT(fullscreenTimeout())); 690 this, SLOT(fullscreenTimeout()));
694 show_fullscreen_msg = true; 691 show_fullscreen_msg = true;
695 692
696 //scrollMenuSelected(-29); 693 //scrollMenuSelected(-29);
697 // cfg.setGroup("ScrollBar"); 694 // cfg.setGroup("ScrollBar");
698 // if(cfg.readBoolEntry("HorzScroll",0)) { 695 // if(cfg.readBoolEntry("HorzScroll",0)) {
699 // if(cfg.readNumEntry("Position",2) == 0) 696 // if(cfg.readNumEntry("Position",2) == 0)
700 // te->setScrollbarLocation(1); 697 // te->setScrollbarLocation(1);
701 // else 698 // else
702 // te->setScrollbarLocation(0); 699 // te->setScrollbarLocation(0);
703 // te->setScrollbarLocation( cfg.readNumEntry("Position",2)); 700 // te->setScrollbarLocation( cfg.readNumEntry("Position",2));
704 // te->setWrapAt(120); 701 // te->setWrapAt(120);
705 // } 702 // }
706 // create applications ///////////////////////////////////////////////////// 703 // create applications /////////////////////////////////////////////////////
707 setCentralWidget(tab); 704 setCentralWidget(tab);
708 705
709 // load keymaps //////////////////////////////////////////////////////////// 706 // load keymaps ////////////////////////////////////////////////////////////
710 KeyTrans::loadAll(); 707 KeyTrans::loadAll();
711 for (int i = 0; i < KeyTrans::count(); i++) 708 for (int i = 0; i < KeyTrans::count(); i++)
712 { 709 {
713 KeyTrans* s = KeyTrans::find(i); 710 KeyTrans* s = KeyTrans::find(i);
714 assert( s ); 711 assert( s );
715 } 712 }
716 713
717 se_pgm = _pgm; 714 se_pgm = _pgm;
718 se_args = _args; 715 se_args = _args;
719 716
720 cfg.setGroup("CommandLine"); 717 cfg.setGroup("CommandLine");
721 718
722 if (cfg.hasKey("shell_args")) 719 if (cfg.hasKey("shell_args"))
723 { 720 {
724 QStringList se_args_list = cfg.readListEntry("shell_args",'|'); 721 QStringList se_args_list = cfg.readListEntry("shell_args",'|');
725 for(uint i = 0; i < se_args_list.count(); i++) 722 for(uint i = 0; i < se_args_list.count(); i++)
726 { 723 {
727 se_args.prepend(se_args_list[se_args_list.count() - i - 1].latin1()); 724 se_args.prepend(se_args_list[se_args_list.count() - i - 1].latin1());
728 } 725 }
729 } 726 }
730 else 727 else
731 { 728 {
732 se_args.prepend("--login"); 729 se_args.prepend("--login");
733 } 730 }
734 731
735 se_pgm = cfg.readEntry("shell_bin", QString(se_pgm)); 732 se_pgm = cfg.readEntry("shell_bin", QString(se_pgm));
736 733
737 // this is the "documentation" for those who know to look 734 // this is the "documentation" for those who know to look
738 if (! cfg.hasKey("shell_args")) 735 if (! cfg.hasKey("shell_args"))
739 { 736 {
740 cfg.writeEntry("shell_args",QStringList::fromStrList(se_args),'|'); 737 cfg.writeEntry("shell_args",QStringList::fromStrList(se_args),'|');
741 } 738 }
742 if (! cfg.hasKey("shell_bin")) 739 if (! cfg.hasKey("shell_bin"))
743 { 740 {
744 cfg.writeEntry("shell_bin",QString(se_pgm)); 741 cfg.writeEntry("shell_bin",QString(se_pgm));
745 } 742 }
746 743
747 parseCommandLine(); 744 parseCommandLine();
748 745
749 // read and apply default values /////////////////////////////////////////// 746 // read and apply default values ///////////////////////////////////////////
750 resize(321, 321); // Dummy. 747 resize(321, 321); // Dummy.
751 QSize currentSize = size(); 748 QSize currentSize = size();
752 if (currentSize != size()) 749 if (currentSize != size())
753 defaultSize = size(); 750 defaultSize = size();
754 751
755 752
756 /* allows us to catch cancel/escape */ 753 /* allows us to catch cancel/escape */
757 reparent ( 0, WStyle_Customize | WStyle_NoBorder, 754 reparent ( 0, WStyle_Customize | WStyle_NoBorder,
758 QPoint ( 0, 0 )); 755 QPoint ( 0, 0 ));
759} 756}
760 757
761void Konsole::show() 758void Konsole::show()
762{ 759{
763 if ( !nsessions ) 760 if ( !nsessions )
764 { 761 {
765 newSession(); 762 newSession();
766 } 763 }
767 QMainWindow::show(); 764 QMainWindow::show();
768 765
769} 766}
770 767
771void Konsole::initSession(const char*, QStrList &) 768void Konsole::initSession(const char*, QStrList &)
772{ 769{
773 QMainWindow::show(); 770 QMainWindow::show();
774} 771}
775 772
776Konsole::~Konsole() 773Konsole::~Konsole()
777{ 774{
778 while (nsessions > 0) 775 while (nsessions > 0)
779 { 776 {
780 doneSession(getTe(), 0); 777 doneSession(getTe(), 0);
781 } 778 }
782} 779}
783 780
784void 781void
785Konsole::historyDialog() 782Konsole::historyDialog()
786{ 783{
787 QDialog *d = new QDialog ( this, "histdlg", true ); 784 QDialog *d = new QDialog ( this, "histdlg", true );
788 // d-> setCaption ( tr( "History" )); 785 // d-> setCaption ( tr( "History" ));
789 786
790 QBoxLayout *lay = new QVBoxLayout ( d, 4, 4 ); 787 QBoxLayout *lay = new QVBoxLayout ( d, 4, 4 );
791 788
792 QLabel *l = new QLabel ( tr( "History Lines:" ), d ); 789 QLabel *l = new QLabel ( tr( "History Lines:" ), d );
793 lay-> addWidget ( l ); 790 lay-> addWidget ( l );
794 791
795 Config cfg( "Konsole" ); 792 Config cfg( "Konsole" );
796 cfg.setGroup("History"); 793 cfg.setGroup("History");
797 int hist = cfg.readNumEntry("history_lines",300); 794 int hist = cfg.readNumEntry("history_lines",300);
798 int avg_line = cfg.readNumEntry("avg_line_length",60); 795 int avg_line = cfg.readNumEntry("avg_line_length",60);
799 796
800 QSpinBox *spin = new QSpinBox ( 1, 100000, 20, d ); 797 QSpinBox *spin = new QSpinBox ( 1, 100000, 20, d );
801 spin-> setValue ( hist ); 798 spin-> setValue ( hist );
802 spin-> setWrapping ( true ); 799 spin-> setWrapping ( true );
803 spin-> setButtonSymbols ( QSpinBox::PlusMinus ); 800 spin-> setButtonSymbols ( QSpinBox::PlusMinus );
804 lay-> addWidget ( spin ); 801 lay-> addWidget ( spin );
805 802
806 if ( d-> exec ( ) == QDialog::Accepted ) 803 if ( d-> exec ( ) == QDialog::Accepted )
807 { 804 {
808 cfg.writeEntry("history_lines", spin->value()); 805 cfg.writeEntry("history_lines", spin->value());
809 cfg.writeEntry("avg_line_length", avg_line); 806 cfg.writeEntry("avg_line_length", avg_line);
810 if (getTe() != NULL) 807 if (getTe() != NULL)
811 { 808 {
812 getTe()->currentSession->setHistory(true); 809 getTe()->currentSession->setHistory(true);
813 } 810 }
814 } 811 }
815 812
816 delete d; 813 delete d;
817} 814}
818 815
819 816
820void Konsole::cycleZoom() 817void Konsole::cycleZoom()
821{ 818{
822 TEWidget* te = getTe(); 819 TEWidget* te = getTe();
823 QFont font = te->getVTFont(); 820 QFont font = te->getVTFont();
824 int size = font.pointSize(); 821 int size = font.pointSize();
825 changeFontSize(1); 822 changeFontSize(1);
826 font = te->getVTFont(); 823 font = te->getVTFont();
827 if (font.pointSize() <= size) 824 if (font.pointSize() <= size)
828 { 825 {
829 do 826 do
830 { 827 {
831 font = te->getVTFont(); 828 font = te->getVTFont();
832 size = font.pointSize(); 829 size = font.pointSize();
833 changeFontSize(-1); 830 changeFontSize(-1);
834 font = te->getVTFont(); 831 font = te->getVTFont();
835 } 832 }
836 while (font.pointSize() < size); 833 while (font.pointSize() < size);
837 } 834 }
838} 835}
839 836
840void Konsole::changeFontSize(int delta) 837void Konsole::changeFontSize(int delta)
841{ 838{
842 // printf("delta font size %d\n", delta); 839 // printf("delta font size %d\n", delta);
843 TEWidget* te = getTe(); 840 TEWidget* te = getTe();
844 QFont font = te->getVTFont(); 841 QFont font = te->getVTFont();
845 int size = font.pointSize(); 842 int size = font.pointSize();
846 int closest = delta > 0? 10000 : -10000; 843 int closest = delta > 0? 10000 : -10000;
847 int closest_font = -1; 844 int closest_font = -1;
848 for(uint i = 0; i < fonts.count(); i++) 845 for(uint i = 0; i < fonts.count(); i++)
849 { 846 {
850 if (fonts.at(i)->getFont() == font) 847 if (fonts.at(i)->getFont() == font)
851 { 848 {
852 if (delta > 0) 849 if (delta > 0)
853 { 850 {
854 if (i+1 < fonts.count() 851 if (i+1 < fonts.count()
855 && fonts.at(i+1)->getFamilyNum() == fonts.at(i)->getFamilyNum()) 852 && fonts.at(i+1)->getFamilyNum() == fonts.at(i)->getFamilyNum())
856 { 853 {
857 setFont(i+1); 854 setFont(i+1);
858 printf("font %d\n", i+1); 855 printf("font %d\n", i+1);
859 return; 856 return;
860 } 857 }
861 } 858 }
862 else if (delta < 0) 859 else if (delta < 0)
863 { 860 {
864 if (i > 0 861 if (i > 0
865 && fonts.at(i-1)->getFamilyNum() == fonts.at(i)->getFamilyNum()) 862 && fonts.at(i-1)->getFamilyNum() == fonts.at(i)->getFamilyNum())
866 { 863 {
867 setFont(i-1); 864 setFont(i-1);
868 printf("font %d\n", i-1); 865 printf("font %d\n", i-1);
869 return; 866 return;
870 } 867 }
871 } 868 }
872 } 869 }
873 int fsize = fonts.at(i)->getSize(); 870 int fsize = fonts.at(i)->getSize();
874 printf("%d size=%d fsize=%d closest=%d\n", i, size, fsize, closest); 871 printf("%d size=%d fsize=%d closest=%d\n", i, size, fsize, closest);
875 if ((delta > 0 && fsize > size && fsize < closest) 872 if ((delta > 0 && fsize > size && fsize < closest)
876 || (delta < 0 && fsize < size && fsize > closest)) 873 || (delta < 0 && fsize < size && fsize > closest))
877 { 874 {
878 closest = fsize; 875 closest = fsize;
879 closest_font = i; 876 closest_font = i;
880 } 877 }
881 } 878 }
882 if (closest_font >= 0) 879 if (closest_font >= 0)
883 { 880 {
884 printf("font closest %d (%d)\n", closest_font, closest); 881 printf("font closest %d (%d)\n", closest_font, closest);
885 setFont(closest_font); 882 setFont(closest_font);
886 } 883 }
887} 884}
888 885
889int Konsole::findFont(const QString& name, int size, bool exactMatch) 886int Konsole::findFont(const QString& name, int size, bool exactMatch)
890{ 887{
891 for(uint i = 0; i < fonts.count(); i++) 888 for(uint i = 0; i < fonts.count(); i++)
892 { 889 {
893 if (fonts.at(i)->getName() == name 890 if (fonts.at(i)->getName() == name
894 && fonts.at(i)->getSize() == size) 891 && fonts.at(i)->getSize() == size)
895 { 892 {
896 return(i); 893 return(i);
897 } 894 }
898 } 895 }
899 if (exactMatch) 896 if (exactMatch)
900 { 897 {
901 return(-1); 898 return(-1);
902 } 899 }
903 for(uint i = 0; i < fonts.count(); i++) 900 for(uint i = 0; i < fonts.count(); i++)
904 { 901 {
905 if (fonts.at(i)->getSize() == size) 902 if (fonts.at(i)->getSize() == size)
906 { 903 {
907 return(i); 904 return(i);
908 } 905 }
909 } 906 }
910 return(-1); 907 return(-1);
911} 908}
912 909
913void Konsole::setFont(int f) 910void Konsole::setFont(int f)
914{ 911{
915 VTFont* font = fonts.at(f); 912 VTFont* font = fonts.at(f);
916 if (font) 913 if (font)
917 { 914 {
918 TEWidget* te = getTe(); 915 TEWidget* te = getTe();
919 if (te != 0) 916 if (te != 0)
920 { 917 {
921 te->setVTFont(font->getFont()); 918 te->setVTFont(font->getFont());
922 } 919 }
923 cfont = f; 920 cfont = f;
924 921
925 int familyNum = font->getFamilyNum(); 922 int familyNum = font->getFamilyNum();
926 int size = font->getSize(); 923 int size = font->getSize();
927 printf("familyNum = %d size = %d count=%d\n", familyNum, size, 924 printf("familyNum = %d size = %d count=%d\n", familyNum, size,
928 fontList->count()); 925 fontList->count());
929 for(int i = 0; i < (int)fontList->count(); i++) 926 for(int i = 0; i < (int)fontList->count(); i++)
930 { 927 {
931 fontList->setItemChecked(i + 1000, i == familyNum); 928 fontList->setItemChecked(i + 1000, i == familyNum);
932 } 929 }
933 for(int i = 0; i < (int)fonts.count(); i++) 930 for(int i = 0; i < (int)fonts.count(); i++)
934 { 931 {
935 fontList->setItemChecked(i, fonts.at(i)->getFamilyNum() == familyNum 932 fontList->setItemChecked(i, fonts.at(i)->getFamilyNum() == familyNum
936 && fonts.at(i)->getSize() == size); 933 && fonts.at(i)->getSize() == size);
937 } 934 }
938 Config cfg( "Konsole" ); 935 Config cfg( "Konsole" );
939 cfg.setGroup("Font"); 936 cfg.setGroup("Font");
940 QString ss = "Session"+ QString::number(tab->currentPageIndex()+1); 937 QString ss = "Session"+ QString::number(tab->currentPageIndex()+1);
941 if (tab->currentPageIndex() == 0) 938 if (tab->currentPageIndex() == 0)
942 { 939 {
943 cfg.writeEntry("FontName", fonts.at(cfont)->getFamily()); 940 cfg.writeEntry("FontName", fonts.at(cfont)->getFamily());
944 cfg.writeEntry("FontSize", fonts.at(cfont)->getSize()); 941 cfg.writeEntry("FontSize", fonts.at(cfont)->getSize());
945 } 942 }
946 cfg.writeEntry("FontName"+ss, fonts.at(cfont)->getFamily()); 943 cfg.writeEntry("FontName"+ss, fonts.at(cfont)->getFamily());
947 cfg.writeEntry("FontSize"+ss, fonts.at(cfont)->getSize()); 944 cfg.writeEntry("FontSize"+ss, fonts.at(cfont)->getSize());
948 } 945 }
949} 946}
950 947
951#if 0 948#if 0
952void Konsole::fontChanged(int f) 949void Konsole::fontChanged(int f)
953{ 950{
954 VTFont* font = fonts.at(f); 951 VTFont* font = fonts.at(f);
955 if (font != 0) 952 if (font != 0)
956 { 953 {
957 for(uint i = 0; i < fonts.count(); i++) 954 for(uint i = 0; i < fonts.count(); i++)
958 { 955 {
959 fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE); 956 fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE);
960 } 957 }
961 958
962 cfont = f; 959 cfont = f;
963 960
964 TEWidget* te = getTe(); 961 TEWidget* te = getTe();
965 if (te != 0) 962 if (te != 0)
966 { 963 {
967 te->setVTFont(font->getFont()); 964 te->setVTFont(font->getFont());
968 } 965 }
969 } 966 }
970} 967}
971#endif 968#endif
972 969
973 970
974void Konsole::enterCommand(int c) 971void Konsole::enterCommand(int c)
975{ 972{
976 TEWidget* te = getTe(); 973 TEWidget* te = getTe();
977 if (te != 0) 974 if (te != 0)
978 { 975 {
979 if(!commonCombo->editable()) 976 if(!commonCombo->editable())
980 { 977 {
981 QString text = commonCombo->text(c); //commonCmds[c]; 978 QString text = commonCombo->text(c); //commonCmds[c];
982 te->emitText(text); 979 te->emitText(text);
983 } 980 }
984 else 981 else
985 { 982 {
986 changeCommand( commonCombo->text(c), c); 983 changeCommand( commonCombo->text(c), c);
987 } 984 }
988 } 985 }
989} 986}
990 987
991void Konsole::hitEnter() 988void Konsole::hitEnter()
992{ 989{
993 TEWidget* te = getTe(); 990 TEWidget* te = getTe();
994 if (te != 0) 991 if (te != 0)
995 { 992 {
996 te->emitText(QString("\r")); 993 te->emitText(QString("\r"));
997 } 994 }
998} 995}
999 996
1000void Konsole::hitSpace() 997void Konsole::hitSpace()
1001{ 998{
1002 TEWidget* te = getTe(); 999 TEWidget* te = getTe();
1003 if (te != 0) 1000 if (te != 0)
1004 { 1001 {
1005 te->emitText(QString(" ")); 1002 te->emitText(QString(" "));
1006 } 1003 }
1007} 1004}
1008 1005
1009void Konsole::hitTab() 1006void Konsole::hitTab()
1010{ 1007{
1011 TEWidget* te = getTe(); 1008 TEWidget* te = getTe();
1012 if (te != 0) 1009 if (te != 0)
1013 { 1010 {
1014 te->emitText(QString("\t")); 1011 te->emitText(QString("\t"));
1015 } 1012 }
1016} 1013}
1017 1014
1018void Konsole::hitPaste() 1015void Konsole::hitPaste()
1019{ 1016{
1020 TEWidget* te = getTe(); 1017 TEWidget* te = getTe();
1021 if (te != 0) 1018 if (te != 0)
1022 { 1019 {
1023 te->pasteClipboard(); 1020 te->pasteClipboard();
1024 } 1021 }
1025} 1022}
1026 1023
1027void Konsole::hitUp() 1024void Konsole::hitUp()
1028{ 1025{
1029 TEWidget* te = getTe(); 1026 TEWidget* te = getTe();
1030 if (te != 0) 1027 if (te != 0)
1031 { 1028 {
1032 QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Up, 0, 0); 1029 QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Up, 0, 0);
1033 QApplication::sendEvent( te, &ke ); 1030 QApplication::sendEvent( te, &ke );
1034 } 1031 }
1035} 1032}
1036 1033
1037void Konsole::hitDown() 1034void Konsole::hitDown()
1038{ 1035{
1039 TEWidget* te = getTe(); 1036 TEWidget* te = getTe();
1040 if (te != 0) 1037 if (te != 0)
1041 { 1038 {
1042 QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Down, 0, 0); 1039 QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Down, 0, 0);
1043 QApplication::sendEvent( te, &ke ); 1040 QApplication::sendEvent( te, &ke );
1044 } 1041 }
1045} 1042}
1046 1043
1047/** 1044/**
1048 This function calculates the size of the external widget 1045 This function calculates the size of the external widget
1049 needed for the internal widget to be 1046 needed for the internal widget to be
1050 */ 1047 */
1051QSize Konsole::calcSize(int columns, int lines) 1048QSize Konsole::calcSize(int columns, int lines)
1052{ 1049{
1053 TEWidget* te = getTe(); 1050 TEWidget* te = getTe();
1054 if (te != 0) 1051 if (te != 0)
1055 { 1052 {
1056 QSize size = te->calcSize(columns, lines); 1053 QSize size = te->calcSize(columns, lines);
1057 return size; 1054 return size;
1058 } 1055 }
1059 else 1056 else
1060 { 1057 {
1061 QSize size; 1058 QSize size;
1062 return size; 1059 return size;
1063 } 1060 }
1064} 1061}
1065 1062
1066/** 1063/**
1067 sets application window to a size based on columns X lines of the te 1064 sets application window to a size based on columns X lines of the te
1068 guest widget. Call with (0,0) for setting default size. 1065 guest widget. Call with (0,0) for setting default size.
1069*/ 1066*/
1070 1067
1071void Konsole::setColLin(int columns, int lines) 1068void Konsole::setColLin(int columns, int lines)
1072{ 1069{
1073 qDebug("konsole::setColLin:: Columns %d", columns); 1070 qDebug("konsole::setColLin:: Columns %d", columns);
1074 1071
1075 if ((columns==0) || (lines==0)) 1072 if ((columns==0) || (lines==0))
1076 { 1073 {
1077 if (defaultSize.isEmpty()) // not in config file : set default value 1074 if (defaultSize.isEmpty()) // not in config file : set default value
1078 { 1075 {
1079 defaultSize = calcSize(80,24); 1076 defaultSize = calcSize(80,24);
1080 // notifySize(24,80); // set menu items (strange arg order !) 1077 // notifySize(24,80); // set menu items (strange arg order !)
1081 } 1078 }
1082 resize(defaultSize); 1079 resize(defaultSize);
1083 } 1080 }
1084 else 1081 else
1085 { 1082 {
1086 resize(calcSize(columns, lines)); 1083 resize(calcSize(columns, lines));
1087 // notifySize(lines,columns); // set menu items (strange arg order !) 1084 // notifySize(lines,columns); // set menu items (strange arg order !)
1088 } 1085 }
1089} 1086}
1090 1087
1091/* 1088/*
1092void Konsole::setFont(int fontno) 1089void Konsole::setFont(int fontno)
1093{ 1090{
1094 QFont f; 1091 QFont f;
1095 if (fontno == 0) 1092 if (fontno == 0)
1096 f = defaultFont = QFont( "Helvetica", 12 ); 1093 f = defaultFont = QFont( "Helvetica", 12 );
1097 else 1094 else
1098 if (fonts[fontno][0] == '-') 1095 if (fonts[fontno][0] == '-')
1099 f.setRawName( fonts[fontno] ); 1096 f.setRawName( fonts[fontno] );
1100 else 1097 else
1101 { 1098 {
1102 f.setFamily(fonts[fontno]); 1099 f.setFamily(fonts[fontno]);
1103 f.setRawMode( TRUE ); 1100 f.setRawMode( TRUE );
1104 } 1101 }
1105 if ( !f.exactMatch() && fontno != 0) 1102 if ( !f.exactMatch() && fontno != 0)
1106 { 1103 {
1107 QString msg = i18n("Font `%1' not found.\nCheck README.linux.console for help.").arg(fonts[fontno]); 1104 QString msg = i18n("Font `%1' not found.\nCheck README.linux.console for help.").arg(fonts[fontno]);
1108 QMessageBox(this, msg); 1105 QMessageBox(this, msg);
1109 return; 1106 return;
1110 } 1107 }
1111 if (se) se->setFontNo(fontno); 1108 if (se) se->setFontNo(fontno);
1112 te->setVTFont(f); 1109 te->setVTFont(f);
1113 n_font = fontno; 1110 n_font = fontno;
1114} 1111}
1115*/ 1112*/
1116 1113
1117// --| color selection |------------------------------------------------------- 1114// --| color selection |-------------------------------------------------------
1118 1115
1119void Konsole::changeColumns(int /*columns*/) 1116void Konsole::changeColumns(int /*columns*/)
1120{ //FIXME this seems to cause silliness when reset command is executed 1117{ //FIXME this seems to cause silliness when reset command is executed
1121 // qDebug("change columns"); 1118 // qDebug("change columns");
1122 // TEWidget* te = getTe(); 1119 // TEWidget* te = getTe();
1123 // if (te != 0) { 1120 // if (te != 0) {
1124 // setColLin(columns,te->Lines()); 1121 // setColLin(columns,te->Lines());
1125 // te->update(); 1122 // te->update();
1126 // } 1123 // }
1127} 1124}
1128 1125
1129//FIXME: If a child dies during session swap, 1126//FIXME: If a child dies during session swap,
1130// this routine might be called before 1127// this routine might be called before
1131// session swap is completed. 1128// session swap is completed.
1132 1129
1133void Konsole::doneSession(TEWidget* te, int ) 1130void Konsole::doneSession(TEWidget* te, int )
1134{ 1131{
1135 // TEWidget *te = NULL; 1132 // TEWidget *te = NULL;
1136 // if (sess->currentSession == tab->currentPage()) { 1133 // if (sess->currentSession == tab->currentPage()) {
1137 // printf("done current session\n"); 1134 // printf("done current session\n");
1138 // te = getTe(); 1135 // te = getTe();
1139 // } else { 1136 // } else {
1140 // int currentPage = tab->currentPageIndex(); 1137 // int currentPage = tab->currentPageIndex();
1141 // printf("done not current session\n"); 1138 // printf("done not current session\n");
1142 // for(int i = 0; i < nsessions; i++) { 1139 // for(int i = 0; i < nsessions; i++) {
1143 // tab->setCurrentPage(i); 1140 // tab->setCurrentPage(i);
1144 // printf("find session %d tab page %x session %x\n", 1141 // printf("find session %d tab page %x session %x\n",
1145 // i, tab->currentPage(), sess->currentSession); 1142 // i, tab->currentPage(), sess->currentSession);