-rw-r--r-- | core/apps/embeddedkonsole/konsole.cpp | 103 |
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,422 +1,494 @@ | |||
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 | |||
65 | class EKNumTabBar : public QTabBar { | 71 | class EKNumTabBar : public QTabBar { |
66 | public: | 72 | public: |
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 | ||
91 | class EKNumTabWidget : public QTabWidget { | 97 | class EKNumTabWidget : public QTabWidget { |
92 | public: | 98 | public: |
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 |
112 | static const char *commonCmds[] = | 118 | static 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 | ||
177 | static void konsoleInit(const char** shell) { | 183 | static 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 | ||
214 | Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) : | 221 | Konsole::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 | ||
228 | void Konsole::initCommandList() | 235 | void 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 | ||
248 | void Konsole::init(const char* _pgm, QStrList & _args) | 255 | void 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 |
359 | a = new QAction( tr("New"), Resource::loadPixmap( "konsole" ), QString::null, 0, this, 0 ); | 431 | a = new QAction( tr("New"), Resource::loadPixmap( "konsole" ), QString::null, 0, this, 0 ); |
360 | connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); a->addTo( toolbar ); | 432 | connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); a->addTo( toolbar ); |
361 | a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 ); | 433 | a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 ); |
362 | connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolbar ); | 434 | connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolbar ); |
363 | a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 ); | 435 | a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 ); |
364 | connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolbar ); | 436 | connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolbar ); |
365 | a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 ); | 437 | a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 ); |
366 | connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolbar ); | 438 | connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolbar ); |
367 | a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 ); | 439 | a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 ); |
368 | connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar ); | 440 | connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar ); |
369 | a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 ); | 441 | a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 ); |
370 | connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar ); | 442 | connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar ); |
371 | a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); | 443 | a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); |
372 | connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); a->addTo( toolbar ); | 444 | connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); a->addTo( toolbar ); |
373 | /* | 445 | /* |
374 | a = new QAction( tr("Up"), Resource::loadPixmap( "up" ), QString::null, 0, this, 0 ); | 446 | a = new QAction( tr("Up"), Resource::loadPixmap( "up" ), QString::null, 0, this, 0 ); |
375 | connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar ); | 447 | connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar ); |
376 | a = new QAction( tr("Down"), Resource::loadPixmap( "down" ), QString::null, 0, this, 0 ); | 448 | a = new QAction( tr("Down"), Resource::loadPixmap( "down" ), QString::null, 0, this, 0 ); |
377 | connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar ); | 449 | connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar ); |
378 | */ | 450 | */ |
379 | 451 | ||
380 | secondToolBar = new QToolBar( this ); | 452 | secondToolBar = new QToolBar( this ); |
381 | secondToolBar->setHorizontalStretchable( TRUE ); | 453 | secondToolBar->setHorizontalStretchable( TRUE ); |
382 | 454 | ||
383 | commonCombo = new QComboBox( secondToolBar ); | 455 | commonCombo = new QComboBox( secondToolBar ); |
384 | commonCombo->setMaximumWidth(236); | 456 | commonCombo->setMaximumWidth(236); |
385 | 457 | ||
386 | editCommandListMenu->insertItem( tr( "Quick Edit" ) ); | 458 | editCommandListMenu->insertItem( tr( "Quick Edit" ) ); |
387 | if( listHidden) { | 459 | if( listHidden) { |
388 | secondToolBar->hide(); | 460 | secondToolBar->hide(); |
389 | editCommandListMenu->setItemEnabled(-23 ,FALSE); | 461 | editCommandListMenu->setItemEnabled(-23 ,FALSE); |
390 | } | 462 | } |
391 | editCommandListMenu->insertItem(tr( "Edit" ) ); | 463 | editCommandListMenu->insertItem(tr( "Edit" ) ); |
392 | 464 | ||
393 | cfg.setGroup("Commands"); | 465 | cfg.setGroup("Commands"); |
394 | commonCombo->setInsertionPolicy(QComboBox::AtCurrent); | 466 | commonCombo->setInsertionPolicy(QComboBox::AtCurrent); |
395 | 467 | ||
396 | initCommandList(); | 468 | initCommandList(); |
397 | // for (int i = 0; commonCmds[i] != NULL; i++) { | 469 | // for (int i = 0; commonCmds[i] != NULL; i++) { |
398 | // commonCombo->insertItem( commonCmds[i], i ); | 470 | // commonCombo->insertItem( commonCmds[i], i ); |
399 | // tmp = cfg.readEntry( QString::number(i),""); | 471 | // tmp = cfg.readEntry( QString::number(i),""); |
400 | // if(tmp != "") | 472 | // if(tmp != "") |
401 | // commonCombo->changeItem( tmp,i ); | 473 | // commonCombo->changeItem( tmp,i ); |
402 | // } | 474 | // } |
403 | 475 | ||
404 | connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) )); | 476 | connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) )); |
405 | 477 | ||
406 | scrollMenu->insertItem(tr( "None" )); | 478 | scrollMenu->insertItem(tr( "None" )); |
407 | scrollMenu->insertItem(tr( "Left" )); | 479 | scrollMenu->insertItem(tr( "Left" )); |
408 | scrollMenu->insertItem(tr( "Right" )); | 480 | scrollMenu->insertItem(tr( "Right" )); |
409 | // scrollMenu->insertSeparator(4); | 481 | // scrollMenu->insertSeparator(4); |
410 | // scrollMenu->insertItem(tr( "Horizontal" )); | 482 | // scrollMenu->insertItem(tr( "Horizontal" )); |
411 | 483 | ||
412 | configMenu->insertItem(tr( "ScrollBar" ),scrollMenu); | 484 | configMenu->insertItem(tr( "ScrollBar" ),scrollMenu); |
413 | 485 | ||
414 | int jut = configMenu->insertItem(tr( "Wrap" )); | 486 | int jut = configMenu->insertItem(tr( "Wrap" )); |
415 | cfg.setGroup("ScrollBar"); | 487 | cfg.setGroup("ScrollBar"); |
416 | configMenu->setItemChecked(jut, cfg.readBoolEntry("HorzScroll",0)); | 488 | configMenu->setItemChecked(jut, cfg.readBoolEntry("HorzScroll",0)); |
417 | 489 | ||
418 | jut = configMenu->insertItem(tr( "Use Beep" )); | 490 | jut = configMenu->insertItem(tr( "Use Beep" )); |
419 | cfg.setGroup("Menubar"); | 491 | cfg.setGroup("Menubar"); |
420 | 492 | ||
421 | configMenu->setItemChecked(jut, cfg.readBoolEntry("useBeep",0)); | 493 | configMenu->setItemChecked(jut, cfg.readBoolEntry("useBeep",0)); |
422 | 494 | ||
@@ -500,263 +572,264 @@ void Konsole::enterCommand(int c) | |||
500 | TEWidget* te = getTe(); | 572 | TEWidget* te = getTe(); |
501 | if (te != 0) { | 573 | if (te != 0) { |
502 | if(!commonCombo->editable()) { | 574 | if(!commonCombo->editable()) { |
503 | QString text = commonCombo->text(c); //commonCmds[c]; | 575 | QString text = commonCombo->text(c); //commonCmds[c]; |
504 | te->emitText(text); | 576 | te->emitText(text); |
505 | } else { | 577 | } else { |
506 | changeCommand( commonCombo->text(c), c); | 578 | changeCommand( commonCombo->text(c), c); |
507 | } | 579 | } |
508 | } | 580 | } |
509 | } | 581 | } |
510 | 582 | ||
511 | void Konsole::hitEnter() | 583 | void Konsole::hitEnter() |
512 | { | 584 | { |
513 | TEWidget* te = getTe(); | 585 | TEWidget* te = getTe(); |
514 | if (te != 0) { | 586 | if (te != 0) { |
515 | te->emitText(QString("\r")); | 587 | te->emitText(QString("\r")); |
516 | } | 588 | } |
517 | } | 589 | } |
518 | 590 | ||
519 | void Konsole::hitSpace() | 591 | void Konsole::hitSpace() |
520 | { | 592 | { |
521 | TEWidget* te = getTe(); | 593 | TEWidget* te = getTe(); |
522 | if (te != 0) { | 594 | if (te != 0) { |
523 | te->emitText(QString(" ")); | 595 | te->emitText(QString(" ")); |
524 | } | 596 | } |
525 | } | 597 | } |
526 | 598 | ||
527 | void Konsole::hitTab() | 599 | void Konsole::hitTab() |
528 | { | 600 | { |
529 | TEWidget* te = getTe(); | 601 | TEWidget* te = getTe(); |
530 | if (te != 0) { | 602 | if (te != 0) { |
531 | te->emitText(QString("\t")); | 603 | te->emitText(QString("\t")); |
532 | } | 604 | } |
533 | } | 605 | } |
534 | 606 | ||
535 | void Konsole::hitPaste() | 607 | void Konsole::hitPaste() |
536 | { | 608 | { |
537 | TEWidget* te = getTe(); | 609 | TEWidget* te = getTe(); |
538 | if (te != 0) { | 610 | if (te != 0) { |
539 | te->pasteClipboard(); | 611 | te->pasteClipboard(); |
540 | } | 612 | } |
541 | } | 613 | } |
542 | 614 | ||
543 | void Konsole::hitUp() | 615 | void Konsole::hitUp() |
544 | { | 616 | { |
545 | TEWidget* te = getTe(); | 617 | TEWidget* te = getTe(); |
546 | if (te != 0) { | 618 | if (te != 0) { |
547 | QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Up, 0, 0); | 619 | QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Up, 0, 0); |
548 | QApplication::sendEvent( te, &ke ); | 620 | QApplication::sendEvent( te, &ke ); |
549 | } | 621 | } |
550 | } | 622 | } |
551 | 623 | ||
552 | void Konsole::hitDown() | 624 | void Konsole::hitDown() |
553 | { | 625 | { |
554 | TEWidget* te = getTe(); | 626 | TEWidget* te = getTe(); |
555 | if (te != 0) { | 627 | if (te != 0) { |
556 | QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Down, 0, 0); | 628 | QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Down, 0, 0); |
557 | QApplication::sendEvent( te, &ke ); | 629 | QApplication::sendEvent( te, &ke ); |
558 | } | 630 | } |
559 | } | 631 | } |
560 | 632 | ||
561 | /** | 633 | /** |
562 | This function calculates the size of the external widget | 634 | This function calculates the size of the external widget |
563 | needed for the internal widget to be | 635 | needed for the internal widget to be |
564 | */ | 636 | */ |
565 | QSize Konsole::calcSize(int columns, int lines) { | 637 | QSize 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 | ||
581 | void Konsole::setColLin(int columns, int lines) | 653 | void 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 | /* |
600 | void Konsole::setFont(int fontno) | 672 | void 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 | ||
627 | void Konsole::changeColumns(int columns) | 699 | void 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 | ||
641 | void Konsole::doneSession(TESession*, int ) | 714 | void 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 | ||
657 | void Konsole::newSession() { | 730 | void 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 | ||
680 | TEWidget* Konsole::getTe() { | 753 | TEWidget* 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 | ||
688 | void Konsole::switchSession(QWidget* w) { | 761 | void 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 | } |
699 | } | 772 | } |
700 | } | 773 | } |
701 | 774 | ||
702 | void Konsole::colorMenuIsSelected(int iD) { | 775 | void Konsole::colorMenuIsSelected(int iD) { |
703 | fromMenu = TRUE; | 776 | fromMenu = TRUE; |
704 | colorMenuSelected(iD); | 777 | colorMenuSelected(iD); |
705 | } | 778 | } |
706 | 779 | ||
707 | /// ------------------------------- some new stuff by L.J. Potter | 780 | /// ------------------------------- some new stuff by L.J. Potter |
708 | void Konsole::colorMenuSelected(int iD) | 781 | void Konsole::colorMenuSelected(int iD) |
709 | { // this is NOT pretty, elegant or anything else besides functional | 782 | { // this is NOT pretty, elegant or anything else besides functional |
710 | // QString temp; | 783 | // QString temp; |
711 | // qDebug( temp.sprintf("colormenu %d", iD)); | 784 | // qDebug( temp.sprintf("colormenu %d", iD)); |
712 | 785 | ||
713 | TEWidget* te = getTe(); | 786 | TEWidget* te = getTe(); |
714 | Config cfg("Konsole"); | 787 | Config cfg("Konsole"); |
715 | cfg.setGroup("Colors"); | 788 | cfg.setGroup("Colors"); |
716 | // QColor foreground; | 789 | // QColor foreground; |
717 | // QColor background; | 790 | // QColor background; |
718 | colorMenu->setItemChecked(lastSelectedMenu,FALSE); | 791 | colorMenu->setItemChecked(lastSelectedMenu,FALSE); |
719 | ColorEntry m_table[TABLE_COLORS]; | 792 | ColorEntry m_table[TABLE_COLORS]; |
720 | const ColorEntry * defaultCt=te->getdefaultColorTable(); | 793 | const ColorEntry * defaultCt=te->getdefaultColorTable(); |
721 | /////////// fore back | 794 | /////////// fore back |
722 | int i; | 795 | int i; |
723 | if(iD==-9) { // default default | 796 | if(iD==-9) { // default default |
724 | for (i = 0; i < TABLE_COLORS; i++) { | 797 | for (i = 0; i < TABLE_COLORS; i++) { |
725 | m_table[i].color = defaultCt[i].color; | 798 | m_table[i].color = defaultCt[i].color; |
726 | if(i==1 || i == 11) | 799 | if(i==1 || i == 11) |
727 | m_table[i].transparent=1; | 800 | m_table[i].transparent=1; |
728 | cfg.writeEntry("Schema","9"); | 801 | cfg.writeEntry("Schema","9"); |
729 | colorMenu->setItemChecked(-9,TRUE); | 802 | colorMenu->setItemChecked(-9,TRUE); |
730 | } | 803 | } |
731 | } else { | 804 | } else { |
732 | if(iD==-6) { // green black | 805 | if(iD==-6) { // green black |
733 | foreground.setRgb(0x18,255,0x18); | 806 | foreground.setRgb(0x18,255,0x18); |
734 | background.setRgb(0x00,0x00,0x00); | 807 | background.setRgb(0x00,0x00,0x00); |
735 | cfg.writeEntry("Schema","6"); | 808 | cfg.writeEntry("Schema","6"); |
736 | colorMenu->setItemChecked(-6,TRUE); | 809 | colorMenu->setItemChecked(-6,TRUE); |
737 | } | 810 | } |
738 | if(iD==-7) { // black white | 811 | if(iD==-7) { // black white |
739 | foreground.setRgb(0x00,0x00,0x00); | 812 | foreground.setRgb(0x00,0x00,0x00); |
740 | background.setRgb(0xFF,0xFF,0xFF); | 813 | background.setRgb(0xFF,0xFF,0xFF); |
741 | cfg.writeEntry("Schema","7"); | 814 | cfg.writeEntry("Schema","7"); |
742 | colorMenu->setItemChecked(-7,TRUE); | 815 | colorMenu->setItemChecked(-7,TRUE); |
743 | } | 816 | } |
744 | if(iD==-8) { // white black | 817 | if(iD==-8) { // white black |
745 | foreground.setRgb(0xFF,0xFF,0xFF); | 818 | foreground.setRgb(0xFF,0xFF,0xFF); |
746 | background.setRgb(0x00,0x00,0x00); | 819 | background.setRgb(0x00,0x00,0x00); |
747 | cfg.writeEntry("Schema","8"); | 820 | cfg.writeEntry("Schema","8"); |
748 | colorMenu->setItemChecked(-8,TRUE); | 821 | colorMenu->setItemChecked(-8,TRUE); |
749 | } | 822 | } |
750 | if(iD==-10) {// Black, Red | 823 | if(iD==-10) {// Black, Red |
751 | foreground.setRgb(0x00,0x00,0x00); | 824 | foreground.setRgb(0x00,0x00,0x00); |
752 | background.setRgb(0xB2,0x18,0x18); | 825 | background.setRgb(0xB2,0x18,0x18); |
753 | cfg.writeEntry("Schema","10"); | 826 | cfg.writeEntry("Schema","10"); |
754 | colorMenu->setItemChecked(-10,TRUE); | 827 | colorMenu->setItemChecked(-10,TRUE); |
755 | } | 828 | } |
756 | if(iD==-11) {// Red, Black | 829 | if(iD==-11) {// Red, Black |
757 | foreground.setRgb(230,31,31); //0xB2,0x18,0x18 | 830 | foreground.setRgb(230,31,31); //0xB2,0x18,0x18 |
758 | background.setRgb(0x00,0x00,0x00); | 831 | background.setRgb(0x00,0x00,0x00); |
759 | cfg.writeEntry("Schema","11"); | 832 | cfg.writeEntry("Schema","11"); |
760 | colorMenu->setItemChecked(-11,TRUE); | 833 | colorMenu->setItemChecked(-11,TRUE); |
761 | } | 834 | } |
762 | if(iD==-12) {// Green, Yellow - is ugly | 835 | if(iD==-12) {// Green, Yellow - is ugly |