summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2004-01-18 00:31:12 (UTC)
committer llornkcor <llornkcor>2004-01-18 00:31:12 (UTC)
commit933d897346745d3d51e41591c59387ef6d2bb917 (patch) (unidiff)
treec3f0caba0922d2f9ce8f73c6a4d60eb48f3efcb3
parente9700698b2d664a688af20008095551624c995ae (diff)
downloadopie-933d897346745d3d51e41591c59387ef6d2bb917.zip
opie-933d897346745d3d51e41591c59387ef6d2bb917.tar.gz
opie-933d897346745d3d51e41591c59387ef6d2bb917.tar.bz2
add unifont from somewhere
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/embeddedkonsole/konsole.cpp103
1 files changed, 88 insertions, 15 deletions
diff --git a/core/apps/embeddedkonsole/konsole.cpp b/core/apps/embeddedkonsole/konsole.cpp
index fff2f68..a5adc03 100644
--- a/core/apps/embeddedkonsole/konsole.cpp
+++ b/core/apps/embeddedkonsole/konsole.cpp
@@ -1,358 +1,430 @@
1/* ---------------------------------------------------------------------- */ 1/* ---------------------------------------------------------------------- */
2/* */ 2/* */
3/* [main.C] Konsole */ 3/* [main.C] Konsole */
4/* */ 4/* */
5/* ---------------------------------------------------------------------- */ 5/* ---------------------------------------------------------------------- */
6/* */ 6/* */
7/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ 7/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */
8/* */ 8/* */
9/* This file is part of Konsole, an X terminal. */ 9/* This file is part of Konsole, an X terminal. */
10/* */ 10/* */
11/* The material contained in here more or less directly orginates from */ 11/* The material contained in here more or less directly orginates from */
12/* kvt, which is copyright (c) 1996 by Matthias Ettrich <ettrich@kde.org> */ 12/* kvt, which is copyright (c) 1996 by Matthias Ettrich <ettrich@kde.org> */
13/* */ 13/* */
14/* ---------------------------------------------------------------------- */ 14/* ---------------------------------------------------------------------- */
15/* */ 15/* */
16/* Ported Konsole to Qt/Embedded */ 16/* Ported Konsole to Qt/Embedded */
17/* */ 17/* */
18/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ 18/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */
19/* */ 19/* */
20/* -------------------------------------------------------------------------- */ 20/* -------------------------------------------------------------------------- */
21// enhancements added by L.J. Potter <ljp@llornkcor.com> 21// enhancements added by L.J. Potter <ljp@llornkcor.com>
22#define QT_QWS_OPIE 22//#define QT_QWS_OPIE
23
24#include "signal.h"
23 25
24#include <qpe/resource.h> 26#include <qpe/resource.h>
25 27
26#include <qdir.h> 28#include <qdir.h>
27#include <qevent.h> 29#include <qevent.h>
28#include <qdragobject.h> 30#include <qdragobject.h>
29#include <qobjectlist.h> 31#include <qobjectlist.h>
30#include <qtoolbutton.h> 32#include <qtoolbutton.h>
31#include <qtoolbar.h> 33#include <qtoolbar.h>
32#include <qpushbutton.h> 34#include <qpushbutton.h>
33#include <qfontdialog.h> 35#include <qfontdialog.h>
34#include <qglobal.h> 36#include <qglobal.h>
35#include <qpainter.h> 37#include <qpainter.h>
36#include <qmenubar.h> 38#include <qmenubar.h>
37#include <qmessagebox.h> 39#include <qmessagebox.h>
38#include <qaction.h> 40#include <qaction.h>
39#include <qapplication.h> 41#include <qapplication.h>
40#include <qfontmetrics.h> 42#include <qfontmetrics.h>
41#include <qcombobox.h> 43#include <qcombobox.h>
42#include <qevent.h> 44#include <qevent.h>
43#include <qtabwidget.h> 45#include <qtabwidget.h>
44#include <qtabbar.h> 46#include <qtabbar.h>
45#include <qpe/config.h> 47#include <qpe/config.h>
46#include <qstringlist.h> 48#include <qstringlist.h>
47#include <qpalette.h> 49#include <qpalette.h>
48 50
49#include <unistd.h> 51#include <unistd.h>
50#include <pwd.h> 52#include <pwd.h>
51#include <sys/types.h> 53#include <sys/types.h>
52#include <sys/wait.h> 54//#include <sys/wait.h>
53#include <stdio.h> 55#include <stdio.h>
54#include <stdlib.h> 56#include <stdlib.h>
55#include <assert.h> 57#include <assert.h>
56 58
57#include "konsole.h" 59#include "konsole.h"
58#include "keytrans.h" 60#include "keytrans.h"
59#include "commandeditdialog.h" 61#include "commandeditdialog.h"
60 62
61#ifdef QT_QWS_OPIE 63#ifdef QT_QWS_OPIE
62#include <opie/colorpopupmenu.h> 64#include <opie/colorpopupmenu.h>
63#endif 65#endif
64 66
67 #include <qfontdatabase.h>// U.B.
68 #include <qstringlist.h>// U.B.
69 #include <qvaluelist.h> // U.B.
70
65class EKNumTabBar : public QTabBar { 71class EKNumTabBar : public QTabBar {
66public: 72public:
67 void numberTabs() 73 void numberTabs()
68 { 74 {
69 // Yes, it really is this messy. QTabWidget needs functions 75 // Yes, it really is this messy. QTabWidget needs functions
70 // that provide acces to tabs in a sequential way. 76 // that provide acces to tabs in a sequential way.
71 int m=INT_MIN; 77 int m=INT_MIN;
72 for (int i=0; i<count(); i++) { 78 for (int i=0; i<count(); i++) {
73 QTab* left=0; 79 QTab* left=0;
74 QListIterator<QTab> it(*tabList()); 80 QListIterator<QTab> it(*tabList());
75 int x=INT_MAX; 81 int x=INT_MAX;
76 for( QTab* t; (t=it.current()); ++it ) { 82 for( QTab* t; (t=it.current()); ++it ) {
77 int tx = t->rect().x(); 83 int tx = t->rect().x();
78 if ( tx<x && tx>m ) { 84 if ( tx<x && tx>m ) {
79 x = tx; 85 x = tx;
80 left = t; 86 left = t;
81 } 87 }
82 } 88 }
83 if ( left ) { 89 if ( left ) {
84 left->setText(QString::number(i+1)); 90 left->setText(QString::number(i+1));
85 m = left->rect().x(); 91 m = left->rect().x();
86 } 92 }
87 } 93 }
88 } 94 }
89}; 95};
90 96
91class EKNumTabWidget : public QTabWidget { 97class EKNumTabWidget : public QTabWidget {
92public: 98public:
93 EKNumTabWidget(QWidget* parent) : QTabWidget(parent) 99 EKNumTabWidget(QWidget* parent) : QTabWidget(parent)
94 { 100 {
95 } 101 }
96 102
97 void addTab(QWidget* w) 103 void addTab(QWidget* w)
98 { 104 {
99 QTab* t = new QTab(QString::number(tabBar()->count()+1)); 105 QTab* t = new QTab(QString::number(tabBar()->count()+1));
100 QTabWidget::addTab(w,t); 106 QTabWidget::addTab(w,t);
101 } 107 }
102 108
103 void removeTab(QWidget* w) 109 void removeTab(QWidget* w)
104 { 110 {
105 removePage(w); 111 removePage(w);
106 ((EKNumTabBar*)tabBar())->numberTabs(); 112 ((EKNumTabBar*)tabBar())->numberTabs();
107 } 113 }
108}; 114};
109 115
110// This could be configurable or dynamicly generated from the bash history 116// This could be configurable or dynamicly generated from the bash history
111// file of the user 117// file of the user
112static const char *commonCmds[] = 118static const char *commonCmds[] =
113{ 119{
114 "ls ", // I left this here, cause it looks better than the first alpha 120 "ls ", // I left this here, cause it looks better than the first alpha
115 "cardctl eject", 121 "cardctl eject",
116 "cat ", 122 "cat ",
117 "cd ", 123 "cd ",
118 "chmod ", 124 "chmod ",
119 "clear", 125 "clear",
120 "cp ", 126 "cp ",
121 "dc ", 127 "dc ",
122 "df ", 128 "df ",
123 "dmesg", 129 "dmesg",
124 "echo ", 130 "echo ",
125 "env", 131 "env",
126 "find ", 132 "find ",
127 "free", 133 "free",
128 "grep ", 134 "grep ",
129 "ifconfig ", 135 "ifconfig ",
130 "ipkg ", 136 "ipkg ",
131 "mkdir ", 137 "mkdir ",
132 "mv ", 138 "mv ",
133 "nc localhost 7776", 139 "nc localhost 7776",
134 "nc localhost 7777", 140 "nc localhost 7777",
135 "netstat ", 141 "netstat ",
136 "nslookup ", 142 "nslookup ",
137 "ping ", 143 "ping ",
138 "ps aux", 144 "ps aux",
139 "pwd ", 145 "pwd ",
140 "qcop QPE/System 'linkChanged(QString)' ''", 146 "qcop QPE/System 'linkChanged(QString)' ''",
141 "qcop QPE/System 'restart()'", 147 "qcop QPE/System 'restart()'",
142 "qcop QPE/System 'quit()'", 148 "qcop QPE/System 'quit()'",
143 "rm ", 149 "rm ",
144 "rmdir ", 150 "rmdir ",
145 "route ", 151 "route ",
146 "set ", 152 "set ",
147 "traceroute", 153 "traceroute",
148 154
149/* 155/*
150 "gzip", 156 "gzip",
151 "gunzip", 157 "gunzip",
152 "chgrp", 158 "chgrp",
153 "chown", 159 "chown",
154 "date", 160 "date",
155 "dd", 161 "dd",
156 "df", 162 "df",
157 "dmesg", 163 "dmesg",
158 "fuser", 164 "fuser",
159 "hostname", 165 "hostname",
160 "kill", 166 "kill",
161 "killall", 167 "killall",
162 "ln", 168 "ln",
163 "ping", 169 "ping",
164 "mount", 170 "mount",
165 "more", 171 "more",
166 "sort", 172 "sort",
167 "touch", 173 "touch",
168 "umount", 174 "umount",
169 "mknod", 175 "mknod",
170 "netstat", 176 "netstat",
171*/ 177*/
172 178
173 "exit", 179 "exit",
174 NULL 180 NULL
175}; 181};
176 182
177static void konsoleInit(const char** shell) { 183static void konsoleInit(const char** shell) {
178 if(setuid(getuid()) !=0) qDebug("setuid failed"); 184 if(setuid(getuid()) !=0) qDebug("setuid failed");
179 if(setgid(getgid()) != 0) qDebug("setgid failed"); // drop privileges 185 if(setgid(getgid()) != 0) qDebug("setgid failed"); // drop privileges
180 186
181 187 // signal (SIGSTOP, SIG_IGN);
188
182// QPEApplication::grabKeyboard(); // for CTRL and ALT 189// QPEApplication::grabKeyboard(); // for CTRL and ALT
183 190
184 qDebug("keyboard grabbed"); 191// qDebug("keyboard grabbed");
185#ifdef FAKE_CTRL_AND_ALT 192#ifdef FAKE_CTRL_AND_ALT
186 qDebug("Fake Ctrl and Alt defined"); 193 qDebug("Fake Ctrl and Alt defined");
187 QPEApplication::grabKeyboard(); // for CTRL and ALT 194 QPEApplication::grabKeyboard(); // for CTRL and ALT
188#endif 195#endif
189 196
190 *shell = getenv("SHELL"); 197 *shell = getenv("SHELL");
191 qWarning("SHell initially is %s", *shell ); 198// qWarning("SHell initially is %s", *shell );
192 199
193 if (shell == NULL || *shell == '\0') { 200 if (shell == NULL || *shell == '\0') {
194 struct passwd *ent = 0; 201 struct passwd *ent = 0;
195 uid_t me = getuid(); 202 uid_t me = getuid();
196 *shell = "/bin/sh"; 203 *shell = "/bin/sh";
197 204
198 while ( (ent = getpwent()) != 0 ) { 205 while ( (ent = getpwent()) != 0 ) {
199 if (ent->pw_uid == me) { 206 if (ent->pw_uid == me) {
200 if (ent->pw_shell != "") 207 if (ent->pw_shell != "")
201 *shell = ent->pw_shell; 208 *shell = ent->pw_shell;
202 break; 209 break;
203 } 210 }
204 } 211 }
205 endpwent(); 212 endpwent();
206 } 213 }
207 214
208 qWarning("SHELL now is %s", *shell ); 215// qWarning("SHELL now is %s", *shell );
209 216
210 if( putenv((char*)"COLORTERM=") !=0) 217 if( putenv((char*)"COLORTERM=") !=0)
211 qDebug("putenv failed"); // to trigger mc's color detection 218 qDebug("putenv failed"); // to trigger mc's color detection
212} 219}
213 220
214Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) : 221Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) :
215 QMainWindow(parent, name, fl) 222 QMainWindow(parent, name, fl)
216{ 223{
217 QStrList tmp; const char* shell; 224 QStrList tmp; const char* shell;
218 225
219 setCaption( tr("Terminal") ); 226 setCaption( tr("Terminal") );
220 227
221 konsoleInit( &shell); 228 konsoleInit( &shell);
222 qWarning("Using shell %s", shell); 229// qWarning("Using shell %s", shell);
223 init(shell,tmp); 230 init(shell,tmp);
224} 231}
225 232
226 233
227 234
228void Konsole::initCommandList() 235void Konsole::initCommandList()
229{ 236{
230// qDebug("Konsole::initCommandList"); 237// qDebug("Konsole::initCommandList");
231 Config cfg("Konsole"); 238 Config cfg("Konsole");
232 cfg.setGroup("Commands"); 239 cfg.setGroup("Commands");
233 commonCombo->setInsertionPolicy(QComboBox::AtCurrent); 240 commonCombo->setInsertionPolicy(QComboBox::AtCurrent);
234 commonCombo->clear(); 241 commonCombo->clear();
235 if (cfg.readEntry("Commands Set","FALSE") == "FALSE") { 242 if (cfg.readEntry("Commands Set","FALSE") == "FALSE") {
236 for (int i = 0; commonCmds[i] != NULL; i++) { 243 for (int i = 0; commonCmds[i] != NULL; i++) {
237 commonCombo->insertItem(commonCmds[i],i); 244 commonCombo->insertItem(commonCmds[i],i);
238 } 245 }
239 } else { 246 } else {
240 for (int i = 0; i < 100; i++) { 247 for (int i = 0; i < 100; i++) {
241 if (!(cfg.readEntry( QString::number(i),"")).isEmpty()) 248 if (!(cfg.readEntry( QString::number(i),"")).isEmpty())
242 commonCombo->insertItem((cfg.readEntry( QString::number(i),""))); 249 commonCombo->insertItem((cfg.readEntry( QString::number(i),"")));
243 } 250 }
244 } 251 }
245 252
246} 253}
247 254
248void Konsole::init(const char* _pgm, QStrList & _args) 255void Konsole::init(const char* _pgm, QStrList & _args)
249{ 256{
250 b_scroll = TRUE; // histon; 257 b_scroll = TRUE; // histon;
251 n_keytab = 0; 258 n_keytab = 0;
252 n_render = 0; 259 n_render = 0;
253 startUp=0; 260 startUp=0;
254 fromMenu = FALSE; 261 fromMenu = FALSE;
255 262
256 setCaption( tr("Terminal") ); 263 setCaption( tr("Terminal") );
257 setIcon( Resource::loadPixmap( "konsole" ) ); 264 setIcon( Resource::loadPixmap( "konsole" ) );
258 265
259 Config cfg("Konsole"); 266 Config cfg("Konsole");
260 cfg.setGroup("Konsole"); 267 cfg.setGroup("Konsole");
261 QString tmp; 268 QString tmp;
262 // initialize the list of allowed fonts /////////////////////////////////// 269 // initialize the list of allowed fonts ///////////////////////////////////
263 cfont = cfg.readNumEntry("FontID", 1); 270 cfont = cfg.readNumEntry("FontID", 1);
271
264 QFont f = QFont("Micro", 4, QFont::Normal); 272 QFont f = QFont("Micro", 4, QFont::Normal);
265 f.setFixedPitch(TRUE); 273 f.setFixedPitch(TRUE);
266 fonts.append(new VTFont(tr("Micro"), f)); 274 fonts.append(new VTFont(tr("Micro"), f));
267 275
268 f = QFont("Fixed", 7, QFont::Normal); 276 f = QFont("Fixed", 7, QFont::Normal);
269 f.setFixedPitch(TRUE); 277 f.setFixedPitch(TRUE);
270 fonts.append(new VTFont(tr("Small Fixed"), f)); 278 fonts.append(new VTFont(tr("Small Fixed"), f));
271 279
272 f = QFont("Fixed", 12, QFont::Normal); 280 f = QFont("Fixed", 12, QFont::Normal);
273 f.setFixedPitch(TRUE); 281 f.setFixedPitch(TRUE);
274 fonts.append(new VTFont(tr("Medium Fixed"), f)); 282 fonts.append(new VTFont(tr("Medium Fixed"), f));
275 283
276 // create terminal emulation framework //////////////////////////////////// 284// NEW STUFF
285
286 QStringList ignfont = cfg.readListEntry("IgnFont", ',');
287 /* If there is no "IgnFont = ..." entry in "myonsole.conf",
288 * put some Japanese fonts of the SL-C7x0 to "ignfont". */
289
290 if (ignfont.isEmpty()) {
291 ignfont = QStringList::split (',',"jisupasp,mmkjg1,mmkjg4,mmkjg5");
292 }
293
294 //QFont
295 f = QFont("Fixed", 16, QFont::Normal);
296 f.setFixedPitch(true);
297 fonts.append(new VTFont(tr("Default"), f));
298
299 int fcount = 1;
300
301 f.setCharSet(QFont::AnyCharSet);
302 f.setStyleHint(QFont::TypeWriter, QFont::PreferMatch);
303// f.setWeight(QFont::Normal);
304
305 /*
306 * Look for installed font families. If the family is not in
307 * the "ignfont" list, look for available sizes.
308 * If it is fixed pitch font, put the font and the size
309 * to the fontlist.
310 */
311 QFontDatabase fdb;
312 QStringList ff = fdb.families(false);
313
314 for (QStringList::Iterator it = ff.begin(); it != ff.end(); ++it ) {
315 QString fit = *it;
316
317 if( fit != "fixed" && fit != "micro" ) {
318 if ( ignfont.contains(*it) == 0) {
319 QValueList<int> pt = fdb.pointSizes(*it);
320
321 for (QValueList<int>::Iterator itv = pt.begin();
322 itv != pt.end(); ++itv ) {
323 int size = (*itv)/10;
324 if(size > 0) {
325 f.setFamily(*it);
326 f.setPointSize(size);
327 }
328
329 QFontMetrics fm(f);
330
331//qDebug("%s %d:\twidth('i')=%d, width('w')=%d", (*it).latin1(), (*itv)/10, fm.width('i'), fm.width('w'));
332
333 if (fm.width('i') == fm.width('w') ) {
334 qDebug((*it));
335 f.setFixedPitch(true);
336 fonts.append(new VTFont(*it + ' ' + QString::number(size), f));
337 fcount++;
338 }
339 }
340 }
341 }
342 }
343
344// END NEW STUFF
345
346
347// create terminal emulation framework ////////////////////////////////////
277 nsessions = 0; 348 nsessions = 0;
278 349
279 tab = new EKNumTabWidget(this); 350 tab = new EKNumTabWidget(this);
280 351
281 connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*))); 352 connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*)));
282 353
283 // create terminal toolbar //////////////////////////////////////////////// 354 // create terminal toolbar ////////////////////////////////////////////////
284 setToolBarsMovable( FALSE ); 355 setToolBarsMovable( FALSE );
285 QToolBar *menuToolBar = new QToolBar( this ); 356 QToolBar *menuToolBar = new QToolBar( this );
286 menuToolBar->setHorizontalStretchable( TRUE ); 357 menuToolBar->setHorizontalStretchable( TRUE );
287 358
288 QMenuBar *menuBar = new QMenuBar( menuToolBar ); 359 QMenuBar *menuBar = new QMenuBar( menuToolBar );
289 360
290 fontList = new QPopupMenu( this ); 361 fontList = new QPopupMenu( this );
291 for(uint i = 0; i < fonts.count(); i++) { 362 for(uint i = 0; i < fonts.count(); i++) {
292 VTFont *fnt = fonts.at(i); 363 VTFont *fnt = fonts.at(i);
293 fontList->insertItem(fnt->getName(), i); 364 fontList->insertItem(fnt->getName(), i);
294 } 365 }
366
295 fontChanged(cfont); 367 fontChanged(cfont);
296 368
297 configMenu = new QPopupMenu( this); 369 configMenu = new QPopupMenu( this);
298 colorMenu = new QPopupMenu( this); 370 colorMenu = new QPopupMenu( this);
299 scrollMenu = new QPopupMenu( this); 371 scrollMenu = new QPopupMenu( this);
300 editCommandListMenu = new QPopupMenu( this); 372 editCommandListMenu = new QPopupMenu( this);
301 373
302 configMenu->insertItem(tr("Command List"), editCommandListMenu); 374 configMenu->insertItem(tr("Command List"), editCommandListMenu);
303 375
304 bool listHidden; 376 bool listHidden;
305 cfg.setGroup("Menubar"); 377 cfg.setGroup("Menubar");
306 if( cfg.readEntry("Hidden","FALSE") == "TRUE") { 378 if( cfg.readEntry("Hidden","FALSE") == "TRUE") {
307 editCommandListMenu->insertItem( tr( "Show command list" )); 379 editCommandListMenu->insertItem( tr( "Show command list" ));
308 listHidden=TRUE; 380 listHidden=TRUE;
309 } else { 381 } else {
310 editCommandListMenu->insertItem( tr( "Hide command list" )); 382 editCommandListMenu->insertItem( tr( "Hide command list" ));
311 listHidden=FALSE; 383 listHidden=FALSE;
312 } 384 }
313 385
314 cfg.setGroup("Tabs"); 386 cfg.setGroup("Tabs");
315 tmp=cfg.readEntry("Position","Bottom"); 387 tmp=cfg.readEntry("Position","Bottom");
316 if(tmp=="Top") { 388 if(tmp=="Top") {
317 tab->setTabPosition(QTabWidget::Top); 389 tab->setTabPosition(QTabWidget::Top);
318 configMenu->insertItem( tr( "Tabs on Bottom" ) ); 390 configMenu->insertItem( tr( "Tabs on Bottom" ) );
319 } else { 391 } else {
320 tab->setTabPosition(QTabWidget::Bottom); 392 tab->setTabPosition(QTabWidget::Bottom);
321 configMenu->insertItem(tr("Tabs on Top")); 393 configMenu->insertItem(tr("Tabs on Top"));
322 } 394 }
323 configMenu->insertSeparator(2); 395 configMenu->insertSeparator(2);
324 396
325 colorMenu->insertItem(tr( "Green on Black")); 397 colorMenu->insertItem(tr( "Green on Black"));
326 colorMenu->insertItem(tr( "Black on White")); 398 colorMenu->insertItem(tr( "Black on White"));
327 colorMenu->insertItem(tr( "White on Black")); 399 colorMenu->insertItem(tr( "White on Black"));
328 colorMenu->insertItem(tr( "Black on Transparent")); 400 colorMenu->insertItem(tr( "Black on Transparent"));
329 colorMenu->insertItem(tr( "Black on Red")); 401 colorMenu->insertItem(tr( "Black on Red"));
330 colorMenu->insertItem(tr( "Red on Black")); 402 colorMenu->insertItem(tr( "Red on Black"));
331 colorMenu->insertItem(tr( "Green on Yellow")); 403 colorMenu->insertItem(tr( "Green on Yellow"));
332 colorMenu->insertItem(tr( "Blue on Magenta")); 404 colorMenu->insertItem(tr( "Blue on Magenta"));
333 colorMenu->insertItem(tr( "Magenta on Blue")); 405 colorMenu->insertItem(tr( "Magenta on Blue"));
334 colorMenu->insertItem(tr( "Cyan on White")); 406 colorMenu->insertItem(tr( "Cyan on White"));
335 colorMenu->insertItem(tr( "White on Cyan")); 407 colorMenu->insertItem(tr( "White on Cyan"));
336 colorMenu->insertItem(tr( "Blue on Black")); 408 colorMenu->insertItem(tr( "Blue on Black"));
337 colorMenu->insertItem(tr( "Amber on Black")); 409 colorMenu->insertItem(tr( "Amber on Black"));
338 410
339#ifdef QT_QWS_OPIE 411#ifdef QT_QWS_OPIE
340 colorMenu->insertItem(tr( "Custom")); 412 colorMenu->insertItem(tr( "Custom"));
341#endif 413#endif
342 414
343 configMenu->insertItem( tr("Font"), fontList ); 415 configMenu->insertItem( tr("Font"), fontList );
344 configMenu->insertItem(tr( "Colors") ,colorMenu); 416 configMenu->insertItem(tr( "Colors") ,colorMenu);
345 417
346 connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) )); 418 connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) ));
347 connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) )); 419 connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) ));
348 connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuIsSelected(int) )); 420 connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuIsSelected(int) ));
349 connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int))); 421 connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int)));
350 connect(editCommandListMenu,SIGNAL(activated(int)),this,SLOT(editCommandListMenuSelected(int))); 422 connect(editCommandListMenu,SIGNAL(activated(int)),this,SLOT(editCommandListMenuSelected(int)));
351 423
352 menuBar->insertItem( tr("Options"), configMenu ); 424 menuBar->insertItem( tr("Options"), configMenu );
353 425
354 QToolBar *toolbar = new QToolBar( this ); 426 QToolBar *toolbar = new QToolBar( this );
355 427
356 QAction *a; 428 QAction *a;
357 429
358 // Button Commands 430 // Button Commands
@@ -564,135 +636,136 @@ void Konsole::hitDown()
564 */ 636 */
565QSize Konsole::calcSize(int columns, int lines) { 637QSize Konsole::calcSize(int columns, int lines) {
566 TEWidget* te = getTe(); 638 TEWidget* te = getTe();
567 if (te != 0) { 639 if (te != 0) {
568 QSize size = te->calcSize(columns, lines); 640 QSize size = te->calcSize(columns, lines);
569 return size; 641 return size;
570 } else { 642 } else {
571 QSize size; 643 QSize size;
572 return size; 644 return size;
573 } 645 }
574} 646}
575 647
576/** 648/**
577 sets application window to a size based on columns X lines of the te 649 sets application window to a size based on columns X lines of the te
578 guest widget. Call with (0,0) for setting default size. 650 guest widget. Call with (0,0) for setting default size.
579*/ 651*/
580 652
581void Konsole::setColLin(int columns, int lines) 653void Konsole::setColLin(int columns, int lines)
582{ 654{
583 qDebug("konsole::setColLin:: Columns %d", columns); 655 qDebug("konsole::setColLin:: Columns %d", columns);
584 656
585 if ((columns==0) || (lines==0)) 657 if ((columns==0) || (lines==0))
586 { 658 {
587 if (defaultSize.isEmpty()) // not in config file : set default value 659 if (defaultSize.isEmpty()) // not in config file : set default value
588 { 660 {
589 defaultSize = calcSize(80,24); 661 defaultSize = calcSize(80,24);
590 // notifySize(24,80); // set menu items (strange arg order !) 662 // notifySize(24,80); // set menu items (strange arg order !)
591 } 663 }
592 resize(defaultSize); 664 resize(defaultSize);
593 } else { 665 } else {
594 resize(calcSize(columns, lines)); 666 resize(calcSize(columns, lines));
595 // notifySize(lines,columns); // set menu items (strange arg order !) 667 // notifySize(lines,columns); // set menu items (strange arg order !)
596 } 668 }
597} 669}
598 670
599/* 671/*
600void Konsole::setFont(int fontno) 672void Konsole::setFont(int fontno)
601{ 673{
602 QFont f; 674 QFont f;
603 if (fontno == 0) 675 if (fontno == 0)
604 f = defaultFont = QFont( "Helvetica", 12 ); 676 f = defaultFont = QFont( "Helvetica", 12 );
605 else 677 else
606 if (fonts[fontno][0] == '-') 678 if (fonts[fontno][0] == '-')
607 f.setRawName( fonts[fontno] ); 679 f.setRawName( fonts[fontno] );
608 else 680 else
609 { 681 {
610 f.setFamily(fonts[fontno]); 682 f.setFamily(fonts[fontno]);
611 f.setRawMode( TRUE ); 683 f.setRawMode( TRUE );
612 } 684 }
613 if ( !f.exactMatch() && fontno != 0) 685 if ( !f.exactMatch() && fontno != 0)
614 { 686 {
615 QString msg = i18n("Font `%1' not found.\nCheck README.linux.console for help.").arg(fonts[fontno]); 687 QString msg = i18n("Font `%1' not found.\nCheck README.linux.console for help.").arg(fonts[fontno]);
616 QMessageBox(this, msg); 688 QMessageBox(this, msg);
617 return; 689 return;
618 } 690 }
619 if (se) se->setFontNo(fontno); 691 if (se) se->setFontNo(fontno);
620 te->setVTFont(f); 692 te->setVTFont(f);
621 n_font = fontno; 693 n_font = fontno;
622} 694}
623*/ 695*/
624 696
625// --| color selection |------------------------------------------------------- 697// --| color selection |-------------------------------------------------------
626 698
627void Konsole::changeColumns(int columns) 699void Konsole::changeColumns(int columns)
628{ //FIXME this seems to cause silliness when reset command is executed 700{
629// qDebug("change columns"); 701 //FIXME this seems to cause silliness when reset command is executed
630// TEWidget* te = getTe(); 702 // qDebug("change columns");
631// if (te != 0) { 703 // TEWidget* te = getTe();
632// setColLin(columns,te->Lines()); 704 // if (te != 0) {
633// te->update(); 705 // setColLin(columns,te->Lines());
634// } 706 // te->update();
707 // }
635} 708}
636 709
637//FIXME: If a child dies during session swap, 710//FIXME: If a child dies during session swap,
638// this routine might be called before 711// this routine might be called before
639// session swap is completed. 712// session swap is completed.
640 713
641void Konsole::doneSession(TESession*, int ) 714void Konsole::doneSession(TESession*, int )
642{ 715{
643 TEWidget *te = getTe(); 716 TEWidget *te = getTe();
644 if (te != 0) { 717 if (te != 0) {
645 te->currentSession->setConnect(FALSE); 718 te->currentSession->setConnect(FALSE);
646 tab->removeTab(te); 719 tab->removeTab(te);
647 delete te->currentSession; 720 delete te->currentSession;
648 delete te; 721 delete te;
649 nsessions--; 722 nsessions--;
650 } 723 }
651 724
652 if (nsessions == 0) { 725 if (nsessions == 0) {
653 close(); 726 close();
654 } 727 }
655} 728}
656 729
657void Konsole::newSession() { 730void Konsole::newSession() {
658 if(nsessions < 15) { // seems to be something weird about 16 tabs on the Zaurus.... memory? 731 if(nsessions < 15) { // seems to be something weird about 16 tabs on the Zaurus.... memory?
659 TEWidget* te = new TEWidget(tab); 732 TEWidget* te = new TEWidget(tab);
660 Config c("Konsole"); 733 Config c("Konsole");
661 c.setGroup("Menubar"); 734 c.setGroup("Menubar");
662 te->useBeep=c.readBoolEntry("useBeep",0); 735 te->useBeep=c.readBoolEntry("useBeep",0);
663 736
664// te->setBackgroundMode(PaletteBase); //we want transparent!! 737// te->setBackgroundMode(PaletteBase); //we want transparent!!
665 te->setVTFont(fonts.at(cfont)->getFont()); 738 te->setVTFont(fonts.at(cfont)->getFont());
666 tab->addTab(te); 739 tab->addTab(te);
667 TESession* se = new TESession(this, te, se_pgm, se_args, "xterm"); 740 TESession* se = new TESession(this, te, se_pgm, se_args, "xterm");
668 te->currentSession = se; 741 te->currentSession = se;
669 connect( se, SIGNAL(done(TESession*,int)), this, SLOT(doneSession(TESession*,int)) ); 742 connect( se, SIGNAL(done(TESession*,int)), this, SLOT(doneSession(TESession*,int)) );
670 se->run(); 743 se->run();
671 se->setConnect(TRUE); 744 se->setConnect(TRUE);
672 se->setHistory(b_scroll); 745 se->setHistory(b_scroll);
673 tab->setCurrentPage(nsessions); 746 tab->setCurrentPage(nsessions);
674 nsessions++; 747 nsessions++;
675 doWrap(); 748 doWrap();
676 setColor(); 749 setColor();
677 } 750 }
678} 751}
679 752
680TEWidget* Konsole::getTe() { 753TEWidget* Konsole::getTe() {
681 if (nsessions) { 754 if (nsessions) {
682 return (TEWidget *) tab->currentPage(); 755 return (TEWidget *) tab->currentPage();
683 } else { 756 } else {
684 return 0; 757 return 0;
685 } 758 }
686} 759}
687 760
688void Konsole::switchSession(QWidget* w) { 761void Konsole::switchSession(QWidget* w) {
689 TEWidget* te = (TEWidget *) w; 762 TEWidget* te = (TEWidget *) w;
690 763
691 QFont teFnt = te->getVTFont(); 764 QFont teFnt = te->getVTFont();
692 for(uint i = 0; i < fonts.count(); i++) { 765 for(uint i = 0; i < fonts.count(); i++) {
693 VTFont *fnt = fonts.at(i); 766 VTFont *fnt = fonts.at(i);
694 bool cf = fnt->getFont() == teFnt; 767 bool cf = fnt->getFont() == teFnt;
695 fontList->setItemChecked(i, cf); 768 fontList->setItemChecked(i, cf);
696 if (cf) { 769 if (cf) {
697 cfont = i; 770 cfont = i;
698 } 771 }