author | zecke <zecke> | 2004-02-29 18:39:07 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-02-29 18:39:07 (UTC) |
commit | 1a59dd467d210703b69d2d694f95988f2e97c27f (patch) (unidiff) | |
tree | 009e2d2c137c4d0d89b4901a8d3a53ff76bd64de | |
parent | f8e1f2c5201f7e86abaa7365040d919e2afcd2ae (diff) | |
download | opie-1a59dd467d210703b69d2d694f95988f2e97c27f.zip opie-1a59dd467d210703b69d2d694f95988f2e97c27f.tar.gz opie-1a59dd467d210703b69d2d694f95988f2e97c27f.tar.bz2 |
from the branch to find the best shell or fallback to /bin/sh
-rw-r--r-- | core/apps/embeddedkonsole/konsole.cpp | 45 |
1 files changed, 43 insertions, 2 deletions
diff --git a/core/apps/embeddedkonsole/konsole.cpp b/core/apps/embeddedkonsole/konsole.cpp index eafc12e..084c39d 100644 --- a/core/apps/embeddedkonsole/konsole.cpp +++ b/core/apps/embeddedkonsole/konsole.cpp | |||
@@ -1,995 +1,1036 @@ | |||
1 | 1 | ||
2 | /* ---------------------------------------------------------------------- */ | 2 | /* ---------------------------------------------------------------------- */ |
3 | /* */ | 3 | /* */ |
4 | /* [main.C] Konsole */ | 4 | /* [main.C] Konsole */ |
5 | /* */ | 5 | /* */ |
6 | /* ---------------------------------------------------------------------- */ | 6 | /* ---------------------------------------------------------------------- */ |
7 | /* */ | 7 | /* */ |
8 | /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ | 8 | /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ |
9 | /* */ | 9 | /* */ |
10 | /* This file is part of Konsole, an X terminal. */ | 10 | /* This file is part of Konsole, an X terminal. */ |
11 | /* */ | 11 | /* */ |
12 | /* The material contained in here more or less directly orginates from */ | 12 | /* The material contained in here more or less directly orginates from */ |
13 | /* kvt, which is copyright (c) 1996 by Matthias Ettrich <ettrich@kde.org> */ | 13 | /* kvt, which is copyright (c) 1996 by Matthias Ettrich <ettrich@kde.org> */ |
14 | /* */ | 14 | /* */ |
15 | /* ---------------------------------------------------------------------- */ | 15 | /* ---------------------------------------------------------------------- */ |
16 | /* */ | 16 | /* */ |
17 | /* Ported Konsole to Qt/Embedded */ | 17 | /* Ported Konsole to Qt/Embedded */ |
18 | /* */ | 18 | /* */ |
19 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ | 19 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ |
20 | /* */ | 20 | /* */ |
21 | /* -------------------------------------------------------------------------- */ | 21 | /* -------------------------------------------------------------------------- */ |
22 | // enhancements added by L.J. Potter <ljp@llornkcor.com> | 22 | // enhancements added by L.J. Potter <ljp@llornkcor.com> |
23 | // enhancements added by Phillip Kuhn | 23 | // enhancements added by Phillip Kuhn |
24 | 24 | ||
25 | #include <stdlib.h> | 25 | #include <stdlib.h> |
26 | #include <sys/types.h> | ||
27 | #include <pwd.h> | ||
28 | #include <unistd.h> | ||
26 | 29 | ||
27 | #ifdef QT_QWS_OPIE | 30 | #ifdef QT_QWS_OPIE |
28 | #include <opie2/ocolorpopupmenu.h> | 31 | #include <opie2/ocolorpopupmenu.h> |
29 | #endif | 32 | #endif |
30 | 33 | ||
31 | #include <qpe/resource.h> | 34 | #include <qpe/resource.h> |
32 | 35 | ||
33 | #include <qdir.h> | 36 | #include <qdir.h> |
34 | #include <qevent.h> | 37 | #include <qevent.h> |
35 | #include <qdragobject.h> | 38 | #include <qdragobject.h> |
36 | #include <qobjectlist.h> | 39 | #include <qobjectlist.h> |
37 | #include <qtoolbutton.h> | 40 | #include <qtoolbutton.h> |
38 | #include <qtoolbar.h> | 41 | #include <qtoolbar.h> |
39 | #include <qpushbutton.h> | 42 | #include <qpushbutton.h> |
40 | #include <qfontdialog.h> | 43 | #include <qfontdialog.h> |
41 | #include <qglobal.h> | 44 | #include <qglobal.h> |
42 | #include <qpainter.h> | 45 | #include <qpainter.h> |
43 | #include <qmenubar.h> | 46 | #include <qmenubar.h> |
44 | #include <qmessagebox.h> | 47 | #include <qmessagebox.h> |
45 | #include <qaction.h> | 48 | #include <qaction.h> |
46 | #include <qapplication.h> | 49 | #include <qapplication.h> |
47 | #include <qfontmetrics.h> | 50 | #include <qfontmetrics.h> |
48 | #include <qcombobox.h> | 51 | #include <qcombobox.h> |
49 | #include <qevent.h> | 52 | #include <qevent.h> |
50 | #include <qtabwidget.h> | 53 | #include <qtabwidget.h> |
51 | #include <qtabbar.h> | 54 | #include <qtabbar.h> |
52 | #include <qpe/config.h> | 55 | #include <qpe/config.h> |
53 | #include <qstringlist.h> | 56 | #include <qstringlist.h> |
54 | #include <qpalette.h> | 57 | #include <qpalette.h> |
55 | #include <qfontdatabase.h> | 58 | #include <qfontdatabase.h> |
56 | #include <qfile.h> | 59 | #include <qfile.h> |
57 | #include <qspinbox.h> | 60 | #include <qspinbox.h> |
58 | #include <qlayout.h> | 61 | #include <qlayout.h> |
59 | #include <qvbox.h> | 62 | #include <qvbox.h> |
60 | 63 | ||
61 | #include <sys/wait.h> | 64 | #include <sys/wait.h> |
62 | #include <stdio.h> | 65 | #include <stdio.h> |
63 | #include <stdlib.h> | 66 | #include <stdlib.h> |
64 | #include <assert.h> | 67 | #include <assert.h> |
65 | 68 | ||
66 | #include "konsole.h" | 69 | #include "konsole.h" |
67 | #include "keytrans.h" | 70 | #include "keytrans.h" |
68 | #include "commandeditdialog.h" | 71 | #include "commandeditdialog.h" |
69 | 72 | ||
70 | class EKNumTabBar : public QTabBar | 73 | class EKNumTabBar : public QTabBar |
71 | { | 74 | { |
72 | public: | 75 | public: |
73 | EKNumTabBar(QWidget *parent = 0, const char *name = 0) : | 76 | EKNumTabBar(QWidget *parent = 0, const char *name = 0) : |
74 | QTabBar(parent, name) | 77 | QTabBar(parent, name) |
75 | {} | 78 | {} |
76 | 79 | ||
77 | // QList<QTab> *getTabList() { return(tabList()); } | 80 | // QList<QTab> *getTabList() { return(tabList()); } |
78 | 81 | ||
79 | void numberTabs() | 82 | void numberTabs() |
80 | { | 83 | { |
81 | // Yes, it really is this messy. QTabWidget needs functions | 84 | // Yes, it really is this messy. QTabWidget needs functions |
82 | // that provide acces to tabs in a sequential way. | 85 | // that provide acces to tabs in a sequential way. |
83 | int m=INT_MIN; | 86 | int m=INT_MIN; |
84 | for (int i=0; i<count(); i++) | 87 | for (int i=0; i<count(); i++) |
85 | { | 88 | { |
86 | QTab* left=0; | 89 | QTab* left=0; |
87 | QListIterator<QTab> it(*tabList()); | 90 | QListIterator<QTab> it(*tabList()); |
88 | int x=INT_MAX; | 91 | int x=INT_MAX; |
89 | for( QTab* t; (t=it.current()); ++it ) | 92 | for( QTab* t; (t=it.current()); ++it ) |
90 | { | 93 | { |
91 | int tx = t->rect().x(); | 94 | int tx = t->rect().x(); |
92 | if ( tx<x && tx>m ) | 95 | if ( tx<x && tx>m ) |
93 | { | 96 | { |
94 | x = tx; | 97 | x = tx; |
95 | left = t; | 98 | left = t; |
96 | } | 99 | } |
97 | } | 100 | } |
98 | if ( left ) | 101 | if ( left ) |
99 | { | 102 | { |
100 | left->setText(QString::number(i+1)); | 103 | left->setText(QString::number(i+1)); |
101 | m = left->rect().x(); | 104 | m = left->rect().x(); |
102 | } | 105 | } |
103 | } | 106 | } |
104 | } | 107 | } |
105 | 108 | ||
106 | virtual QSize sizeHint() const | 109 | virtual QSize sizeHint() const |
107 | { | 110 | { |
108 | if (isHidden()) | 111 | if (isHidden()) |
109 | { | 112 | { |
110 | return(QSize(0,0)); | 113 | return(QSize(0,0)); |
111 | } | 114 | } |
112 | else | 115 | else |
113 | { | 116 | { |
114 | QSize size = QTabBar::sizeHint(); | 117 | QSize size = QTabBar::sizeHint(); |
115 | int shrink = 5; | 118 | int shrink = 5; |
116 | if (qApp->desktop()->width() > 600 || qApp->desktop()->height() > 600) | 119 | if (qApp->desktop()->width() > 600 || qApp->desktop()->height() > 600) |
117 | { | 120 | { |
118 | shrink = 10; | 121 | shrink = 10; |
119 | } | 122 | } |
120 | size.setHeight(size.height() - shrink); | 123 | size.setHeight(size.height() - shrink); |
121 | return(size); | 124 | return(size); |
122 | } | 125 | } |
123 | } | 126 | } |
124 | 127 | ||
125 | }; | 128 | }; |
126 | 129 | ||
127 | class EKNumTabWidget : public QTabWidget | 130 | class EKNumTabWidget : public QTabWidget |
128 | { | 131 | { |
129 | public: | 132 | public: |
130 | EKNumTabWidget(QWidget* parent) : QTabWidget(parent) | 133 | EKNumTabWidget(QWidget* parent) : QTabWidget(parent) |
131 | { | 134 | { |
132 | setTabBar(new EKNumTabBar(parent,"EKTabBar")); | 135 | setTabBar(new EKNumTabBar(parent,"EKTabBar")); |
133 | setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); | 136 | setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); |
134 | } | 137 | } |
135 | 138 | ||
136 | EKNumTabBar *getTabBar() const | 139 | EKNumTabBar *getTabBar() const |
137 | { | 140 | { |
138 | return ((EKNumTabBar*)tabBar()); | 141 | return ((EKNumTabBar*)tabBar()); |
139 | } | 142 | } |
140 | 143 | ||
141 | 144 | ||
142 | void addTab(QWidget* w) | 145 | void addTab(QWidget* w) |
143 | { | 146 | { |
144 | QTab* t = new QTab(QString::number(tabBar()->count()+1)); | 147 | QTab* t = new QTab(QString::number(tabBar()->count()+1)); |
145 | QTabWidget::addTab(w,t); | 148 | QTabWidget::addTab(w,t); |
146 | } | 149 | } |
147 | 150 | ||
148 | void removeTab(QWidget* w) | 151 | void removeTab(QWidget* w) |
149 | { | 152 | { |
150 | removePage(w); | 153 | removePage(w); |
151 | ((EKNumTabBar*)tabBar())->numberTabs(); | 154 | ((EKNumTabBar*)tabBar())->numberTabs(); |
152 | } | 155 | } |
153 | }; | 156 | }; |
154 | 157 | ||
155 | // This could be configurable or dynamicly generated from the bash history | 158 | // This could be configurable or dynamicly generated from the bash history |
156 | // file of the user | 159 | // file of the user |
157 | static const char *commonCmds[] = | 160 | static const char *commonCmds[] = |
158 | { | 161 | { |
159 | "ls ", // I left this here, cause it looks better than the first alpha | 162 | "ls ", // I left this here, cause it looks better than the first alpha |
160 | "cardctl eject", | 163 | "cardctl eject", |
161 | "cat ", | 164 | "cat ", |
162 | "cd ", | 165 | "cd ", |
163 | "chmod ", | 166 | "chmod ", |
164 | "clear", | 167 | "clear", |
165 | "cp ", | 168 | "cp ", |
166 | "dc ", | 169 | "dc ", |
167 | "df ", | 170 | "df ", |
168 | "dmesg", | 171 | "dmesg", |
169 | "echo ", | 172 | "echo ", |
170 | "env", | 173 | "env", |
171 | "find ", | 174 | "find ", |
172 | "free", | 175 | "free", |
173 | "grep ", | 176 | "grep ", |
174 | "ifconfig ", | 177 | "ifconfig ", |
175 | "ipkg ", | 178 | "ipkg ", |
176 | "mkdir ", | 179 | "mkdir ", |
177 | "mv ", | 180 | "mv ", |
178 | "nc localhost 7776", | 181 | "nc localhost 7776", |
179 | "nc localhost 7777", | 182 | "nc localhost 7777", |
180 | "netstat ", | 183 | "netstat ", |
181 | "nslookup ", | 184 | "nslookup ", |
182 | "ping ", | 185 | "ping ", |
183 | "ps aux", | 186 | "ps aux", |
184 | "pwd ", | 187 | "pwd ", |
185 | "qcop QPE/System 'linkChanged(QString)' ''", | 188 | "qcop QPE/System 'linkChanged(QString)' ''", |
186 | "qcop QPE/System 'restart()'", | 189 | "qcop QPE/System 'restart()'", |
187 | "qcop QPE/System 'quit()'", | 190 | "qcop QPE/System 'quit()'", |
188 | "rm ", | 191 | "rm ", |
189 | "rmdir ", | 192 | "rmdir ", |
190 | "route ", | 193 | "route ", |
191 | "set ", | 194 | "set ", |
192 | "traceroute", | 195 | "traceroute", |
193 | 196 | ||
194 | /* | 197 | /* |
195 | "gzip", | 198 | "gzip", |
196 | "gunzip", | 199 | "gunzip", |
197 | "chgrp", | 200 | "chgrp", |
198 | "chown", | 201 | "chown", |
199 | "date", | 202 | "date", |
200 | "dd", | 203 | "dd", |
201 | "df", | 204 | "df", |
202 | "dmesg", | 205 | "dmesg", |
203 | "fuser", | 206 | "fuser", |
204 | "hostname", | 207 | "hostname", |
205 | "kill", | 208 | "kill", |
206 | "killall", | 209 | "killall", |
207 | "ln", | 210 | "ln", |
208 | "ping", | 211 | "ping", |
209 | "mount", | 212 | "mount", |
210 | "more", | 213 | "more", |
211 | "sort", | 214 | "sort", |
212 | "touch", | 215 | "touch", |
213 | "umount", | 216 | "umount", |
214 | "mknod", | 217 | "mknod", |
215 | "netstat", | 218 | "netstat", |
216 | */ | 219 | */ |
217 | 220 | ||
218 | "exit", | 221 | "exit", |
219 | NULL | 222 | NULL |
220 | }; | 223 | }; |
221 | 224 | ||
222 | 225 | ||
226 | static void konsoleInit(const char** shell) { | ||
227 | if(setuid(getuid()) !=0) qDebug("setuid failed"); | ||
228 | if(setgid(getgid()) != 0) qDebug("setgid failed"); // drop privileges | ||
229 | |||
230 | |||
231 | // QPEApplication::grabKeyboard(); // for CTRL and ALT | ||
232 | |||
233 | qDebug("keyboard grabbed"); | ||
234 | #ifdef FAKE_CTRL_AND_ALT | ||
235 | qDebug("Fake Ctrl and Alt defined"); | ||
236 | QPEApplication::grabKeyboard(); // for CTRL and ALT | ||
237 | #endif | ||
238 | |||
239 | *shell = getenv("SHELL"); | ||
240 | qWarning("SHell initially is %s", *shell ); | ||
241 | |||
242 | if (shell == NULL || *shell == '\0') { | ||
243 | struct passwd *ent = 0; | ||
244 | uid_t me = getuid(); | ||
245 | *shell = "/bin/sh"; | ||
246 | |||
247 | while ( (ent = getpwent()) != 0 ) { | ||
248 | if (ent->pw_uid == me) { | ||
249 | if (ent->pw_shell != "") | ||
250 | *shell = ent->pw_shell; | ||
251 | break; | ||
252 | } | ||
253 | } | ||
254 | endpwent(); | ||
255 | } | ||
256 | |||
257 | if( putenv((char*)"COLORTERM=") !=0) | ||
258 | qDebug("putenv failed"); // to trigger mc's color detection | ||
259 | } | ||
260 | |||
261 | |||
223 | Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) : | 262 | Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) : |
224 | QMainWindow(parent, name, fl) | 263 | QMainWindow(parent, name, fl) |
225 | { | 264 | { |
226 | QStrList args; | 265 | QStrList tmp; const char* shell; |
227 | init("/bin/bash",args); | 266 | |
267 | konsoleInit( &shell); | ||
268 | init(shell,tmp); | ||
228 | } | 269 | } |
229 | 270 | ||
230 | Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int) | 271 | Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int) |
231 | : QMainWindow(0, name) | 272 | : QMainWindow(0, name) |
232 | { | 273 | { |
233 | init(_pgm,_args); | 274 | init(_pgm,_args); |
234 | } | 275 | } |
235 | 276 | ||
236 | struct HistoryItem | 277 | struct HistoryItem |
237 | { | 278 | { |
238 | HistoryItem(int c, const QString &l) | 279 | HistoryItem(int c, const QString &l) |
239 | { | 280 | { |
240 | count = c; | 281 | count = c; |
241 | line = l; | 282 | line = l; |
242 | } | 283 | } |
243 | int count; | 284 | int count; |
244 | QString line; | 285 | QString line; |
245 | }; | 286 | }; |
246 | 287 | ||
247 | class HistoryList : public QList<HistoryItem> | 288 | class HistoryList : public QList<HistoryItem> |
248 | { | 289 | { |
249 | virtual int compareItems( QCollection::Item item1, QCollection::Item item2) | 290 | virtual int compareItems( QCollection::Item item1, QCollection::Item item2) |
250 | { | 291 | { |
251 | int c1 = ((HistoryItem*)item1)->count; | 292 | int c1 = ((HistoryItem*)item1)->count; |
252 | int c2 = ((HistoryItem*)item2)->count; | 293 | int c2 = ((HistoryItem*)item2)->count; |
253 | if (c1 > c2) | 294 | if (c1 > c2) |
254 | return(1); | 295 | return(1); |
255 | if (c1 < c2) | 296 | if (c1 < c2) |
256 | return(-1); | 297 | return(-1); |
257 | return(0); | 298 | return(0); |
258 | } | 299 | } |
259 | }; | 300 | }; |
260 | 301 | ||
261 | void Konsole::initCommandList() | 302 | void Konsole::initCommandList() |
262 | { | 303 | { |
263 | // qDebug("Konsole::initCommandList"); | 304 | // qDebug("Konsole::initCommandList"); |
264 | Config cfg( "Konsole" ); | 305 | Config cfg( "Konsole" ); |
265 | cfg.setGroup("Commands"); | 306 | cfg.setGroup("Commands"); |
266 | // commonCombo->setInsertionPolicy(QComboBox::AtCurrent); | 307 | // commonCombo->setInsertionPolicy(QComboBox::AtCurrent); |
267 | commonCombo->clear(); | 308 | commonCombo->clear(); |
268 | 309 | ||
269 | if (cfg.readEntry("ShellHistory","TRUE") == "TRUE") | 310 | if (cfg.readEntry("ShellHistory","TRUE") == "TRUE") |
270 | { | 311 | { |
271 | QString histfilename = QString(getenv("HOME")) + "/.bash_history"; | 312 | QString histfilename = QString(getenv("HOME")) + "/.bash_history"; |
272 | histfilename = cfg.readEntry("ShellHistoryPath",histfilename); | 313 | histfilename = cfg.readEntry("ShellHistoryPath",histfilename); |
273 | QFile histfile(histfilename); | 314 | QFile histfile(histfilename); |
274 | // note: compiler barfed on: | 315 | // note: compiler barfed on: |
275 | // QFile histfile(QString(getenv("HOME")) + "/.bash_history"); | 316 | // QFile histfile(QString(getenv("HOME")) + "/.bash_history"); |
276 | if (histfile.open( IO_ReadOnly )) | 317 | if (histfile.open( IO_ReadOnly )) |
277 | { | 318 | { |
278 | QString line; | 319 | QString line; |
279 | uint i; | 320 | uint i; |
280 | HistoryList items; | 321 | HistoryList items; |
281 | 322 | ||
282 | int lineno = 0; | 323 | int lineno = 0; |
283 | while(!histfile.atEnd()) | 324 | while(!histfile.atEnd()) |
284 | { | 325 | { |
285 | if (histfile.readLine(line, 200) < 0) | 326 | if (histfile.readLine(line, 200) < 0) |
286 | { | 327 | { |
287 | break; | 328 | break; |
288 | } | 329 | } |
289 | line = line.left(line.length()-1); | 330 | line = line.left(line.length()-1); |
290 | lineno++; | 331 | lineno++; |
291 | 332 | ||
292 | for(i=0; i<items.count(); i++) | 333 | for(i=0; i<items.count(); i++) |
293 | { | 334 | { |
294 | if (line == items.at(i)->line) | 335 | if (line == items.at(i)->line) |
295 | { | 336 | { |
296 | // weight recent commands & repeated commands more | 337 | // weight recent commands & repeated commands more |
297 | // by adding up the index of each command | 338 | // by adding up the index of each command |
298 | items.at(i)->count += lineno; | 339 | items.at(i)->count += lineno; |
299 | break; | 340 | break; |
300 | } | 341 | } |
301 | } | 342 | } |
302 | if (i >= items.count()) | 343 | if (i >= items.count()) |
303 | { | 344 | { |
304 | items.append(new HistoryItem(lineno, line)); | 345 | items.append(new HistoryItem(lineno, line)); |
305 | } | 346 | } |
306 | } | 347 | } |
307 | items.sort(); | 348 | items.sort(); |
308 | int n = items.count(); | 349 | int n = items.count(); |
309 | if (n > 40) | 350 | if (n > 40) |
310 | { | 351 | { |
311 | n = 40; | 352 | n = 40; |
312 | } | 353 | } |
313 | for(int i=0; i<n; i++) | 354 | for(int i=0; i<n; i++) |
314 | { | 355 | { |
315 | // should insert start of command, but keep whole thing | 356 | // should insert start of command, but keep whole thing |
316 | if (items.at(items.count()-i-1)->line.length() < 30) | 357 | if (items.at(items.count()-i-1)->line.length() < 30) |
317 | { | 358 | { |
318 | commonCombo->insertItem(items.at(items.count()-i-1)->line); | 359 | commonCombo->insertItem(items.at(items.count()-i-1)->line); |
319 | } | 360 | } |
320 | } | 361 | } |
321 | histfile.close(); | 362 | histfile.close(); |
322 | } | 363 | } |
323 | } | 364 | } |
324 | if (cfg.readEntry("Commands Set","FALSE") == "FALSE") | 365 | if (cfg.readEntry("Commands Set","FALSE") == "FALSE") |
325 | { | 366 | { |
326 | for (int i = 0; commonCmds[i] != NULL; i++) | 367 | for (int i = 0; commonCmds[i] != NULL; i++) |
327 | { | 368 | { |
328 | commonCombo->insertItem(commonCmds[i]); | 369 | commonCombo->insertItem(commonCmds[i]); |
329 | } | 370 | } |
330 | } | 371 | } |
331 | else | 372 | else |
332 | { | 373 | { |
333 | for (int i = 0; i < 100; i++) | 374 | for (int i = 0; i < 100; i++) |
334 | { | 375 | { |
335 | if (!(cfg.readEntry( QString::number(i),"")).isEmpty()) | 376 | if (!(cfg.readEntry( QString::number(i),"")).isEmpty()) |
336 | commonCombo->insertItem(cfg.readEntry( QString::number(i),"")); | 377 | commonCombo->insertItem(cfg.readEntry( QString::number(i),"")); |
337 | } | 378 | } |
338 | } | 379 | } |
339 | 380 | ||
340 | 381 | ||
341 | } | 382 | } |
342 | 383 | ||
343 | static void sig_handler(int x) | 384 | static void sig_handler(int x) |
344 | { | 385 | { |
345 | printf("got signal %d\n",x); | 386 | printf("got signal %d\n",x); |
346 | } | 387 | } |
347 | 388 | ||
348 | void Konsole::init(const char* _pgm, QStrList & _args) | 389 | void Konsole::init(const char* _pgm, QStrList & _args) |
349 | { | 390 | { |
350 | 391 | ||
351 | #if 0 | 392 | #if 0 |
352 | for(int i=1; i<=31; i++) | 393 | for(int i=1; i<=31; i++) |
353 | { | 394 | { |
354 | if (i != SIGPIPE && i != SIGPROF && i != SIGSEGV | 395 | if (i != SIGPIPE && i != SIGPROF && i != SIGSEGV |
355 | && i != SIGINT && i != SIGILL && i != SIGTERM | 396 | && i != SIGINT && i != SIGILL && i != SIGTERM |
356 | && i != SIGBUS) | 397 | && i != SIGBUS) |
357 | signal(i,sig_handler); | 398 | signal(i,sig_handler); |
358 | } | 399 | } |
359 | #endif | 400 | #endif |
360 | signal(SIGSTOP, sig_handler); | 401 | signal(SIGSTOP, sig_handler); |
361 | signal(SIGCONT, sig_handler); | 402 | signal(SIGCONT, sig_handler); |
362 | signal(SIGTSTP, sig_handler); | 403 | signal(SIGTSTP, sig_handler); |
363 | 404 | ||
364 | b_scroll = TRUE; // histon; | 405 | b_scroll = TRUE; // histon; |
365 | n_keytab = 0; | 406 | n_keytab = 0; |
366 | n_render = 0; | 407 | n_render = 0; |
367 | startUp=0; | 408 | startUp=0; |
368 | fromMenu = FALSE; | 409 | fromMenu = FALSE; |
369 | fullscreen = false; | 410 | fullscreen = false; |
370 | 411 | ||
371 | setCaption( tr( "Konsole" ) ); | 412 | setCaption( tr( "Konsole" ) ); |
372 | setIcon( Resource::loadPixmap( "konsole/Terminal" ) ); | 413 | setIcon( Resource::loadPixmap( "konsole/Terminal" ) ); |
373 | 414 | ||
374 | Config cfg( "Konsole" ); | 415 | Config cfg( "Konsole" ); |
375 | cfg.setGroup("Font"); | 416 | cfg.setGroup("Font"); |
376 | QString tmp; | 417 | QString tmp; |
377 | 418 | ||
378 | // initialize the list of allowed fonts /////////////////////////////////// | 419 | // initialize the list of allowed fonts /////////////////////////////////// |
379 | 420 | ||
380 | QString cfgFontName = cfg.readEntry("FontName","Lcfont"); | 421 | QString cfgFontName = cfg.readEntry("FontName","Lcfont"); |
381 | int cfgFontSize = cfg.readNumEntry("FontSize",18); | 422 | int cfgFontSize = cfg.readNumEntry("FontSize",18); |
382 | 423 | ||
383 | cfont = -1; | 424 | cfont = -1; |
384 | 425 | ||
385 | // this code causes repeated access to all the font files | 426 | // this code causes repeated access to all the font files |
386 | // which does slow down startup | 427 | // which does slow down startup |
387 | QFontDatabase fontDB; | 428 | QFontDatabase fontDB; |
388 | QStringList familyNames; | 429 | QStringList familyNames; |
389 | familyNames = fontDB.families( FALSE ); | 430 | familyNames = fontDB.families( FALSE ); |
390 | QString s; | 431 | QString s; |
391 | int fontIndex = 0; | 432 | int fontIndex = 0; |
392 | int familyNum = 0; | 433 | int familyNum = 0; |
393 | fontList = new QPopupMenu( this ); | 434 | fontList = new QPopupMenu( this ); |
394 | 435 | ||
395 | for(uint j = 0; j < (uint)familyNames.count(); j++) | 436 | for(uint j = 0; j < (uint)familyNames.count(); j++) |
396 | { | 437 | { |
397 | s = familyNames[j]; | 438 | s = familyNames[j]; |
398 | if ( s.contains('-') ) | 439 | if ( s.contains('-') ) |
399 | { | 440 | { |
400 | int i = s.find('-'); | 441 | int i = s.find('-'); |
401 | s = s.right( s.length() - i - 1 ) + " [" + s.left( i ) + "]"; | 442 | s = s.right( s.length() - i - 1 ) + " [" + s.left( i ) + "]"; |
402 | } | 443 | } |
403 | s[0] = s[0].upper(); | 444 | s[0] = s[0].upper(); |
404 | 445 | ||
405 | QValueList<int> sizes = fontDB.pointSizes( familyNames[j] ); | 446 | QValueList<int> sizes = fontDB.pointSizes( familyNames[j] ); |
406 | 447 | ||
407 | printf("family[%d] = %s with %d sizes\n", j, familyNames[j].latin1(), | 448 | printf("family[%d] = %s with %d sizes\n", j, familyNames[j].latin1(), |
408 | sizes.count()); | 449 | sizes.count()); |
409 | 450 | ||
410 | if (sizes.count() > 0) | 451 | if (sizes.count() > 0) |
411 | { | 452 | { |
412 | QPopupMenu *sizeMenu; | 453 | QPopupMenu *sizeMenu; |
413 | QFont f; | 454 | QFont f; |
414 | int last_width = -1; | 455 | int last_width = -1; |
415 | sizeMenu = NULL; | 456 | sizeMenu = NULL; |
416 | 457 | ||
417 | for(uint i = 0; i < (uint)sizes.count() + 4; i++) | 458 | for(uint i = 0; i < (uint)sizes.count() + 4; i++) |
418 | { | 459 | { |
419 | // printf("family %s size %d ", familyNames[j].latin1(), sizes[i]); | 460 | // printf("family %s size %d ", familyNames[j].latin1(), sizes[i]); |
420 | // need to divide by 10 on the Z, but not otherwise | 461 | // need to divide by 10 on the Z, but not otherwise |
421 | int size; | 462 | int size; |
422 | 463 | ||
423 | if (i >= (uint)sizes.count()) | 464 | if (i >= (uint)sizes.count()) |
424 | { | 465 | { |
425 | // try for expandable fonts | 466 | // try for expandable fonts |
426 | size = sizes[sizes.count()-1] + 2 * (i - sizes.count() + 1); | 467 | size = sizes[sizes.count()-1] + 2 * (i - sizes.count() + 1); |
427 | } | 468 | } |
428 | else | 469 | else |
429 | { | 470 | { |
430 | printf("sizes[%d] = %d\n", i, sizes[i]); | 471 | printf("sizes[%d] = %d\n", i, sizes[i]); |
431 | size = sizes[i]; | 472 | size = sizes[i]; |
432 | } | 473 | } |
433 | 474 | ||
434 | f = QFont(familyNames[j], size); | 475 | f = QFont(familyNames[j], size); |
435 | f.setFixedPitch(true); | 476 | f.setFixedPitch(true); |
436 | QFontMetrics fm(f); | 477 | QFontMetrics fm(f); |
437 | // don't trust f.fixedPitch() or f.exactMatch(), they lie!! | 478 | // don't trust f.fixedPitch() or f.exactMatch(), they lie!! |
438 | if (fm.width("l") == fm.width("m") | 479 | if (fm.width("l") == fm.width("m") |
439 | && (i < (uint)sizes.count() | 480 | && (i < (uint)sizes.count() |
440 | || fm.width("m") > last_width)) | 481 | || fm.width("m") > last_width)) |
441 | { | 482 | { |
442 | if (i < (uint)sizes.count()) | 483 | if (i < (uint)sizes.count()) |
443 | { | 484 | { |
444 | last_width = fm.width("m"); | 485 | last_width = fm.width("m"); |
445 | } | 486 | } |
446 | if (sizeMenu == NULL) | 487 | if (sizeMenu == NULL) |
447 | { | 488 | { |
448 | sizeMenu = new QPopupMenu(); | 489 | sizeMenu = new QPopupMenu(); |
449 | } | 490 | } |
450 | int id = sizeMenu->insertItem(QString("%1").arg(size), fontIndex); | 491 | int id = sizeMenu->insertItem(QString("%1").arg(size), fontIndex); |
451 | sizeMenu->setItemParameter(id, fontIndex); | 492 | sizeMenu->setItemParameter(id, fontIndex); |
452 | sizeMenu->connectItem(id, this, SLOT(setFont(int))); | 493 | sizeMenu->connectItem(id, this, SLOT(setFont(int))); |
453 | QString name = s + " " + QString::number(size); | 494 | QString name = s + " " + QString::number(size); |
454 | fonts.append(new VTFont(name, f, familyNames[j], familyNum, size)); | 495 | fonts.append(new VTFont(name, f, familyNames[j], familyNum, size)); |
455 | if (familyNames[j] == cfgFontName && size == cfgFontSize) | 496 | if (familyNames[j] == cfgFontName && size == cfgFontSize) |
456 | { | 497 | { |
457 | cfont = fontIndex; | 498 | cfont = fontIndex; |
458 | } | 499 | } |
459 | printf("FOUND: %s family %s size %d\n", name.latin1(), familyNames[j].latin1(), size); | 500 | printf("FOUND: %s family %s size %d\n", name.latin1(), familyNames[j].latin1(), size); |
460 | fontIndex++; | 501 | fontIndex++; |
461 | } | 502 | } |
462 | } | 503 | } |
463 | if (sizeMenu) | 504 | if (sizeMenu) |
464 | { | 505 | { |
465 | fontList->insertItem(s, sizeMenu, familyNum + 1000); | 506 | fontList->insertItem(s, sizeMenu, familyNum + 1000); |
466 | 507 | ||
467 | familyNum++; | 508 | familyNum++; |
468 | } | 509 | } |
469 | } | 510 | } |
470 | 511 | ||
471 | } | 512 | } |
472 | 513 | ||
473 | if (cfont < 0 || cfont >= (int)fonts.count()) | 514 | if (cfont < 0 || cfont >= (int)fonts.count()) |
474 | { | 515 | { |
475 | cfont = 0; | 516 | cfont = 0; |
476 | } | 517 | } |
477 | 518 | ||
478 | // create terminal emulation framework //////////////////////////////////// | 519 | // create terminal emulation framework //////////////////////////////////// |
479 | nsessions = 0; | 520 | nsessions = 0; |
480 | 521 | ||
481 | tab = new EKNumTabWidget(this); | 522 | tab = new EKNumTabWidget(this); |
482 | // tab->setMargin(tab->margin()-5); | 523 | // tab->setMargin(tab->margin()-5); |
483 | connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*))); | 524 | connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*))); |
484 | 525 | ||
485 | // create terminal toolbar //////////////////////////////////////////////// | 526 | // create terminal toolbar //////////////////////////////////////////////// |
486 | setToolBarsMovable( FALSE ); | 527 | setToolBarsMovable( FALSE ); |
487 | menuToolBar = new QToolBar( this ); | 528 | menuToolBar = new QToolBar( this ); |
488 | menuToolBar->setHorizontalStretchable( TRUE ); | 529 | menuToolBar->setHorizontalStretchable( TRUE ); |
489 | 530 | ||
490 | QMenuBar *menuBar = new QMenuBar( menuToolBar ); | 531 | QMenuBar *menuBar = new QMenuBar( menuToolBar ); |
491 | 532 | ||
492 | bool c7xx = false; | 533 | bool c7xx = false; |
493 | if (qApp->desktop()->width() > 600 || qApp->desktop()->height() > 600) | 534 | if (qApp->desktop()->width() > 600 || qApp->desktop()->height() > 600) |
494 | { | 535 | { |
495 | c7xx = true; | 536 | c7xx = true; |
496 | } | 537 | } |
497 | QFont menuFont; | 538 | QFont menuFont; |
498 | menuFont.setPointSize(c7xx? 18 : 10); | 539 | menuFont.setPointSize(c7xx? 18 : 10); |
499 | qApp->setFont(menuFont, true); | 540 | qApp->setFont(menuFont, true); |
500 | 541 | ||
501 | setFont(cfont); | 542 | setFont(cfont); |
502 | 543 | ||
503 | configMenu = new QPopupMenu( this); | 544 | configMenu = new QPopupMenu( this); |
504 | colorMenu = new QPopupMenu( this); | 545 | colorMenu = new QPopupMenu( this); |
505 | scrollMenu = new QPopupMenu( this); | 546 | scrollMenu = new QPopupMenu( this); |
506 | editCommandListMenu = new QPopupMenu( this); | 547 | editCommandListMenu = new QPopupMenu( this); |
507 | 548 | ||
508 | configMenu->insertItem(tr("Command List"), editCommandListMenu); | 549 | configMenu->insertItem(tr("Command List"), editCommandListMenu); |
509 | 550 | ||
510 | bool listHidden; | 551 | bool listHidden; |
511 | cfg.setGroup("Menubar"); | 552 | cfg.setGroup("Menubar"); |
512 | if( cfg.readEntry("Hidden","FALSE") == "TRUE") | 553 | if( cfg.readEntry("Hidden","FALSE") == "TRUE") |
513 | { | 554 | { |
514 | ec_cmdlist = editCommandListMenu->insertItem( tr( "Show command list" )); | 555 | ec_cmdlist = editCommandListMenu->insertItem( tr( "Show command list" )); |
515 | listHidden=TRUE; | 556 | listHidden=TRUE; |
516 | } | 557 | } |
517 | else | 558 | else |
518 | { | 559 | { |
519 | ec_cmdlist = editCommandListMenu->insertItem( tr( "Hide command list" )); | 560 | ec_cmdlist = editCommandListMenu->insertItem( tr( "Hide command list" )); |
520 | listHidden=FALSE; | 561 | listHidden=FALSE; |
521 | } | 562 | } |
522 | 563 | ||
523 | cfg.setGroup("Tabs"); | 564 | cfg.setGroup("Tabs"); |
524 | 565 | ||
525 | tabMenu = new QPopupMenu(this); | 566 | tabMenu = new QPopupMenu(this); |
526 | tm_bottom = tabMenu->insertItem(tr("Bottom" )); | 567 | tm_bottom = tabMenu->insertItem(tr("Bottom" )); |
527 | tm_top = tabMenu->insertItem(tr("Top")); | 568 | tm_top = tabMenu->insertItem(tr("Top")); |
528 | tm_hidden = tabMenu->insertItem(tr("Hidden")); | 569 | tm_hidden = tabMenu->insertItem(tr("Hidden")); |
529 | 570 | ||
530 | configMenu->insertItem(tr("Tabs"), tabMenu); | 571 | configMenu->insertItem(tr("Tabs"), tabMenu); |
531 | 572 | ||
532 | tmp=cfg.readEntry("Position","Top"); | 573 | tmp=cfg.readEntry("Position","Top"); |
533 | if(tmp=="Top") | 574 | if(tmp=="Top") |
534 | { | 575 | { |
535 | tab->setTabPosition(QTabWidget::Top); | 576 | tab->setTabPosition(QTabWidget::Top); |
536 | tab->getTabBar()->show(); | 577 | tab->getTabBar()->show(); |
537 | tabPos = tm_top; | 578 | tabPos = tm_top; |
538 | } | 579 | } |
539 | else if (tmp=="Bottom") | 580 | else if (tmp=="Bottom") |
540 | { | 581 | { |
541 | tab->setTabPosition(QTabWidget::Bottom); | 582 | tab->setTabPosition(QTabWidget::Bottom); |
542 | tab->getTabBar()->show(); | 583 | tab->getTabBar()->show(); |
543 | tabPos = tm_bottom; | 584 | tabPos = tm_bottom; |
544 | } | 585 | } |
545 | else | 586 | else |
546 | { | 587 | { |
547 | tab->getTabBar()->hide(); | 588 | tab->getTabBar()->hide(); |
548 | tab->setMargin(tab->margin()); | 589 | tab->setMargin(tab->margin()); |
549 | tabPos = tm_hidden; | 590 | tabPos = tm_hidden; |
550 | } | 591 | } |
551 | 592 | ||
552 | cm_bw = colorMenu->insertItem(tr( "Black on White")); | 593 | cm_bw = colorMenu->insertItem(tr( "Black on White")); |
553 | cm_wb = colorMenu->insertItem(tr( "White on Black")); | 594 | cm_wb = colorMenu->insertItem(tr( "White on Black")); |
554 | cm_gb = colorMenu->insertItem(tr( "Green on Black")); | 595 | cm_gb = colorMenu->insertItem(tr( "Green on Black")); |
555 | // cm_bt = colorMenu->insertItem(tr( "Black on Transparent")); | 596 | // cm_bt = colorMenu->insertItem(tr( "Black on Transparent")); |
556 | cm_br = colorMenu->insertItem(tr( "Black on Pink")); | 597 | cm_br = colorMenu->insertItem(tr( "Black on Pink")); |
557 | cm_rb = colorMenu->insertItem(tr( "Pink on Black")); | 598 | cm_rb = colorMenu->insertItem(tr( "Pink on Black")); |
558 | cm_gy = colorMenu->insertItem(tr( "Green on Yellow")); | 599 | cm_gy = colorMenu->insertItem(tr( "Green on Yellow")); |
559 | cm_bm = colorMenu->insertItem(tr( "Blue on Magenta")); | 600 | cm_bm = colorMenu->insertItem(tr( "Blue on Magenta")); |
560 | cm_mb = colorMenu->insertItem(tr( "Magenta on Blue")); | 601 | cm_mb = colorMenu->insertItem(tr( "Magenta on Blue")); |
561 | cm_cw = colorMenu->insertItem(tr( "Cyan on White")); | 602 | cm_cw = colorMenu->insertItem(tr( "Cyan on White")); |
562 | cm_wc = colorMenu->insertItem(tr( "White on Cyan")); | 603 | cm_wc = colorMenu->insertItem(tr( "White on Cyan")); |
563 | cm_bb = colorMenu->insertItem(tr( "Blue on Black")); | 604 | cm_bb = colorMenu->insertItem(tr( "Blue on Black")); |
564 | cm_ab = colorMenu->insertItem(tr( "Amber on Black")); | 605 | cm_ab = colorMenu->insertItem(tr( "Amber on Black")); |
565 | cm_default = colorMenu->insertItem(tr("default")); | 606 | cm_default = colorMenu->insertItem(tr("default")); |
566 | 607 | ||
567 | #ifdef QT_QWS_OPIE | 608 | #ifdef QT_QWS_OPIE |
568 | 609 | ||
569 | colorMenu->insertItem(tr( "Custom")); | 610 | colorMenu->insertItem(tr( "Custom")); |
570 | #endif | 611 | #endif |
571 | 612 | ||
572 | configMenu->insertItem(tr( "Colors") ,colorMenu); | 613 | configMenu->insertItem(tr( "Colors") ,colorMenu); |
573 | 614 | ||
574 | sessionList = new QPopupMenu(this); | 615 | sessionList = new QPopupMenu(this); |
575 | sessionList-> insertItem ( Resource::loadPixmap ( "konsole/Terminal" ), tr( "new session" ), this, | 616 | sessionList-> insertItem ( Resource::loadPixmap ( "konsole/Terminal" ), tr( "new session" ), this, |
576 | SLOT(newSession()) ); | 617 | SLOT(newSession()) ); |
577 | 618 | ||
578 | // connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) )); | 619 | // connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) )); |
579 | connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) )); | 620 | connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) )); |
580 | connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuIsSelected(int) )); | 621 | connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuIsSelected(int) )); |
581 | connect( tabMenu, SIGNAL( activated(int) ), this, SLOT( tabMenuSelected(int) )); | 622 | connect( tabMenu, SIGNAL( activated(int) ), this, SLOT( tabMenuSelected(int) )); |
582 | connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int))); | 623 | connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int))); |
583 | connect( editCommandListMenu,SIGNAL(activated(int)),this,SLOT(editCommandListMenuSelected(int))); | 624 | connect( editCommandListMenu,SIGNAL(activated(int)),this,SLOT(editCommandListMenuSelected(int))); |
584 | connect( sessionList, SIGNAL(activated(int)), this, SLOT( sessionListSelected(int) ) ); | 625 | connect( sessionList, SIGNAL(activated(int)), this, SLOT( sessionListSelected(int) ) ); |
585 | 626 | ||
586 | menuBar->insertItem( tr("View"), configMenu ); | 627 | menuBar->insertItem( tr("View"), configMenu ); |
587 | menuBar->insertItem( tr("Fonts"), fontList ); | 628 | menuBar->insertItem( tr("Fonts"), fontList ); |
588 | menuBar->insertItem( tr("Sessions"), sessionList ); | 629 | menuBar->insertItem( tr("Sessions"), sessionList ); |
589 | 630 | ||
590 | toolBar = new QToolBar( this ); | 631 | toolBar = new QToolBar( this ); |
591 | 632 | ||
592 | QAction *a; | 633 | QAction *a; |
593 | 634 | ||
594 | // Button Commands | 635 | // Button Commands |
595 | a = new QAction( tr("New"), Resource::loadPixmap( "konsole/Terminal" ), QString::null, 0, this, 0 ); | 636 | a = new QAction( tr("New"), Resource::loadPixmap( "konsole/Terminal" ), QString::null, 0, this, 0 ); |
596 | connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); | 637 | connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); |
597 | a->addTo( toolBar ); | 638 | a->addTo( toolBar ); |
598 | 639 | ||
599 | a = new QAction( tr("Full Screen"), Resource::loadPixmap( "fullscreen" ), QString::null, 0, this, 0 ); | 640 | a = new QAction( tr("Full Screen"), Resource::loadPixmap( "fullscreen" ), QString::null, 0, this, 0 ); |
600 | connect( a, SIGNAL( activated() ), this, SLOT( toggleFullScreen() ) ); | 641 | connect( a, SIGNAL( activated() ), this, SLOT( toggleFullScreen() ) ); |
601 | a->addTo( toolBar ); | 642 | a->addTo( toolBar ); |
602 | 643 | ||
603 | a = new QAction( tr("Zoom"), Resource::loadPixmap( "zoom" ), QString::null, 0, this, 0 ); | 644 | a = new QAction( tr("Zoom"), Resource::loadPixmap( "zoom" ), QString::null, 0, this, 0 ); |
604 | connect( a, SIGNAL( activated() ), this, SLOT( cycleZoom() ) ); | 645 | connect( a, SIGNAL( activated() ), this, SLOT( cycleZoom() ) ); |
605 | a->addTo( toolBar ); | 646 | a->addTo( toolBar ); |
606 | 647 | ||
607 | 648 | ||
608 | /* | 649 | /* |
609 | a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 ); | 650 | a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 ); |
610 | connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolBar ); | 651 | connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolBar ); |
611 | a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 ); | 652 | a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 ); |
612 | connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolBar ); | 653 | connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolBar ); |
613 | a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 ); | 654 | a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 ); |
614 | connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolBar ); | 655 | connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolBar ); |
615 | */ | 656 | */ |
616 | /* | 657 | /* |
617 | a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 ); | 658 | a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 ); |
618 | connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolBar ); | 659 | connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolBar ); |
619 | a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 ); | 660 | a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 ); |
620 | connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolBar ); | 661 | connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolBar ); |
621 | */ | 662 | */ |
622 | a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); | 663 | a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); |
623 | connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); | 664 | connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); |
624 | a->addTo( toolBar ); | 665 | a->addTo( toolBar ); |
625 | 666 | ||
626 | secondToolBar = new QToolBar( this ); | 667 | secondToolBar = new QToolBar( this ); |
627 | secondToolBar->setHorizontalStretchable( TRUE ); | 668 | secondToolBar->setHorizontalStretchable( TRUE ); |
628 | 669 | ||
629 | commonCombo = new QComboBox( secondToolBar ); | 670 | commonCombo = new QComboBox( secondToolBar ); |
630 | // commonCombo->setMaximumWidth(236); | 671 | // commonCombo->setMaximumWidth(236); |
631 | 672 | ||
632 | ec_quick = editCommandListMenu->insertItem( tr( "Quick Edit" ) ); | 673 | ec_quick = editCommandListMenu->insertItem( tr( "Quick Edit" ) ); |
633 | if( listHidden) | 674 | if( listHidden) |
634 | { | 675 | { |
635 | secondToolBar->hide(); | 676 | secondToolBar->hide(); |
636 | editCommandListMenu->setItemEnabled(ec_quick ,FALSE); | 677 | editCommandListMenu->setItemEnabled(ec_quick ,FALSE); |
637 | } | 678 | } |
638 | ec_edit = editCommandListMenu->insertItem(tr( "Edit..." ) ); | 679 | ec_edit = editCommandListMenu->insertItem(tr( "Edit..." ) ); |
639 | 680 | ||
640 | cfg.setGroup("Commands"); | 681 | cfg.setGroup("Commands"); |
641 | commonCombo->setInsertionPolicy(QComboBox::AtCurrent); | 682 | commonCombo->setInsertionPolicy(QComboBox::AtCurrent); |
642 | 683 | ||
643 | initCommandList(); | 684 | initCommandList(); |
644 | // for (int i = 0; commonCmds[i] != NULL; i++) { | 685 | // for (int i = 0; commonCmds[i] != NULL; i++) { |
645 | // commonCombo->insertItem( commonCmds[i], i ); | 686 | // commonCombo->insertItem( commonCmds[i], i ); |
646 | // tmp = cfg.readEntry( QString::number(i),""); | 687 | // tmp = cfg.readEntry( QString::number(i),""); |
647 | // if(tmp != "") | 688 | // if(tmp != "") |
648 | // commonCombo->changeItem( tmp,i ); | 689 | // commonCombo->changeItem( tmp,i ); |
649 | // } | 690 | // } |
650 | 691 | ||
651 | connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) )); | 692 | connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) )); |
652 | 693 | ||
653 | sm_none = scrollMenu->insertItem(tr( "None" )); | 694 | sm_none = scrollMenu->insertItem(tr( "None" )); |
654 | sm_left = scrollMenu->insertItem(tr( "Left" )); | 695 | sm_left = scrollMenu->insertItem(tr( "Left" )); |
655 | sm_right = scrollMenu->insertItem(tr( "Right" )); | 696 | sm_right = scrollMenu->insertItem(tr( "Right" )); |
656 | // scrollMenu->insertSeparator(4); | 697 | // scrollMenu->insertSeparator(4); |
657 | // scrollMenu->insertItem(tr( "Horizontal" )); | 698 | // scrollMenu->insertItem(tr( "Horizontal" )); |
658 | 699 | ||
659 | configMenu->insertItem(tr( "ScrollBar" ),scrollMenu); | 700 | configMenu->insertItem(tr( "ScrollBar" ),scrollMenu); |
660 | 701 | ||
661 | configMenu->insertItem(tr( "History..." ), this, SLOT(historyDialog())); | 702 | configMenu->insertItem(tr( "History..." ), this, SLOT(historyDialog())); |
662 | 703 | ||
663 | cm_wrap = configMenu->insertItem(tr( "Wrap" )); | 704 | cm_wrap = configMenu->insertItem(tr( "Wrap" )); |
664 | cfg.setGroup("ScrollBar"); | 705 | cfg.setGroup("ScrollBar"); |
665 | configMenu->setItemChecked(cm_wrap, cfg.readBoolEntry("HorzScroll",0)); | 706 | configMenu->setItemChecked(cm_wrap, cfg.readBoolEntry("HorzScroll",0)); |
666 | 707 | ||
667 | cm_beep = configMenu->insertItem(tr( "Use Beep" )); | 708 | cm_beep = configMenu->insertItem(tr( "Use Beep" )); |
668 | cfg.setGroup("Menubar"); | 709 | cfg.setGroup("Menubar"); |
669 | configMenu->setItemChecked(cm_beep, cfg.readBoolEntry("useBeep",0)); | 710 | configMenu->setItemChecked(cm_beep, cfg.readBoolEntry("useBeep",0)); |
670 | 711 | ||
671 | fullscreen_msg = new QLabel(this); | 712 | fullscreen_msg = new QLabel(this); |
672 | fullscreen_msg-> setAlignment ( AlignCenter | SingleLine ); | 713 | fullscreen_msg-> setAlignment ( AlignCenter | SingleLine ); |
673 | fullscreen_msg-> hide(); | 714 | fullscreen_msg-> hide(); |
674 | fullscreen_msg-> setSizePolicy ( QSizePolicy ( QSizePolicy::Expanding, QSizePolicy::Expanding )); | 715 | fullscreen_msg-> setSizePolicy ( QSizePolicy ( QSizePolicy::Expanding, QSizePolicy::Expanding )); |
675 | fullscreen_msg-> setAutoResize(true); | 716 | fullscreen_msg-> setAutoResize(true); |
676 | fullscreen_msg-> setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 717 | fullscreen_msg-> setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
677 | fullscreen_msg-> setText(tr("To exit fullscreen, tap here.")); | 718 | fullscreen_msg-> setText(tr("To exit fullscreen, tap here.")); |
678 | 719 | ||
679 | fullscreen_timer = new QTimer(this); | 720 | fullscreen_timer = new QTimer(this); |
680 | connect(fullscreen_timer, SIGNAL(timeout()), | 721 | connect(fullscreen_timer, SIGNAL(timeout()), |
681 | this, SLOT(fullscreenTimeout())); | 722 | this, SLOT(fullscreenTimeout())); |
682 | show_fullscreen_msg = true; | 723 | show_fullscreen_msg = true; |
683 | 724 | ||
684 | //scrollMenuSelected(-29); | 725 | //scrollMenuSelected(-29); |
685 | // cfg.setGroup("ScrollBar"); | 726 | // cfg.setGroup("ScrollBar"); |
686 | // if(cfg.readBoolEntry("HorzScroll",0)) { | 727 | // if(cfg.readBoolEntry("HorzScroll",0)) { |
687 | // if(cfg.readNumEntry("Position",2) == 0) | 728 | // if(cfg.readNumEntry("Position",2) == 0) |
688 | // te->setScrollbarLocation(1); | 729 | // te->setScrollbarLocation(1); |
689 | // else | 730 | // else |
690 | // te->setScrollbarLocation(0); | 731 | // te->setScrollbarLocation(0); |
691 | // te->setScrollbarLocation( cfg.readNumEntry("Position",2)); | 732 | // te->setScrollbarLocation( cfg.readNumEntry("Position",2)); |
692 | // te->setWrapAt(120); | 733 | // te->setWrapAt(120); |
693 | // } | 734 | // } |
694 | // create applications ///////////////////////////////////////////////////// | 735 | // create applications ///////////////////////////////////////////////////// |
695 | setCentralWidget(tab); | 736 | setCentralWidget(tab); |
696 | 737 | ||
697 | // load keymaps //////////////////////////////////////////////////////////// | 738 | // load keymaps //////////////////////////////////////////////////////////// |
698 | KeyTrans::loadAll(); | 739 | KeyTrans::loadAll(); |
699 | for (int i = 0; i < KeyTrans::count(); i++) | 740 | for (int i = 0; i < KeyTrans::count(); i++) |
700 | { | 741 | { |
701 | KeyTrans* s = KeyTrans::find(i); | 742 | KeyTrans* s = KeyTrans::find(i); |
702 | assert( s ); | 743 | assert( s ); |
703 | } | 744 | } |
704 | 745 | ||
705 | se_pgm = _pgm; | 746 | se_pgm = _pgm; |
706 | se_args = _args; | 747 | se_args = _args; |
707 | 748 | ||
708 | cfg.setGroup("CommandLine"); | 749 | cfg.setGroup("CommandLine"); |
709 | 750 | ||
710 | if (cfg.hasKey("shell_args")) | 751 | if (cfg.hasKey("shell_args")) |
711 | { | 752 | { |
712 | QStringList se_args_list = cfg.readListEntry("shell_args",'|'); | 753 | QStringList se_args_list = cfg.readListEntry("shell_args",'|'); |
713 | for(uint i = 0; i < se_args_list.count(); i++) | 754 | for(uint i = 0; i < se_args_list.count(); i++) |
714 | { | 755 | { |
715 | se_args.prepend(se_args_list[se_args_list.count() - i - 1].latin1()); | 756 | se_args.prepend(se_args_list[se_args_list.count() - i - 1].latin1()); |
716 | } | 757 | } |
717 | } | 758 | } |
718 | else | 759 | else |
719 | { | 760 | { |
720 | se_args.prepend("--login"); | 761 | se_args.prepend("--login"); |
721 | } | 762 | } |
722 | 763 | ||
723 | se_pgm = cfg.readEntry("shell_bin", QString(se_pgm)); | 764 | se_pgm = cfg.readEntry("shell_bin", QString(se_pgm)); |
724 | 765 | ||
725 | // this is the "documentation" for those who know to look | 766 | // this is the "documentation" for those who know to look |
726 | if (! cfg.hasKey("shell_args")) | 767 | if (! cfg.hasKey("shell_args")) |
727 | { | 768 | { |
728 | cfg.writeEntry("shell_args",QStringList::fromStrList(se_args),'|'); | 769 | cfg.writeEntry("shell_args",QStringList::fromStrList(se_args),'|'); |
729 | } | 770 | } |
730 | if (! cfg.hasKey("shell_bin")) | 771 | if (! cfg.hasKey("shell_bin")) |
731 | { | 772 | { |
732 | cfg.writeEntry("shell_bin",QString(se_pgm)); | 773 | cfg.writeEntry("shell_bin",QString(se_pgm)); |
733 | } | 774 | } |
734 | 775 | ||
735 | parseCommandLine(); | 776 | parseCommandLine(); |
736 | 777 | ||
737 | // read and apply default values /////////////////////////////////////////// | 778 | // read and apply default values /////////////////////////////////////////// |
738 | resize(321, 321); // Dummy. | 779 | resize(321, 321); // Dummy. |
739 | QSize currentSize = size(); | 780 | QSize currentSize = size(); |
740 | if (currentSize != size()) | 781 | if (currentSize != size()) |
741 | defaultSize = size(); | 782 | defaultSize = size(); |
742 | 783 | ||
743 | 784 | ||
744 | /* allows us to catch cancel/escape */ | 785 | /* allows us to catch cancel/escape */ |
745 | reparent ( 0, WStyle_Customize | WStyle_NoBorder, | 786 | reparent ( 0, WStyle_Customize | WStyle_NoBorder, |
746 | QPoint ( 0, 0 )); | 787 | QPoint ( 0, 0 )); |
747 | } | 788 | } |
748 | 789 | ||
749 | void Konsole::show() | 790 | void Konsole::show() |
750 | { | 791 | { |
751 | if ( !nsessions ) | 792 | if ( !nsessions ) |
752 | { | 793 | { |
753 | newSession(); | 794 | newSession(); |
754 | } | 795 | } |
755 | QMainWindow::show(); | 796 | QMainWindow::show(); |
756 | 797 | ||
757 | } | 798 | } |
758 | 799 | ||
759 | void Konsole::initSession(const char*, QStrList &) | 800 | void Konsole::initSession(const char*, QStrList &) |
760 | { | 801 | { |
761 | QMainWindow::show(); | 802 | QMainWindow::show(); |
762 | } | 803 | } |
763 | 804 | ||
764 | Konsole::~Konsole() | 805 | Konsole::~Konsole() |
765 | { | 806 | { |
766 | while (nsessions > 0) | 807 | while (nsessions > 0) |
767 | { | 808 | { |
768 | doneSession(getTe(), 0); | 809 | doneSession(getTe(), 0); |
769 | } | 810 | } |
770 | } | 811 | } |
771 | 812 | ||
772 | void | 813 | void |
773 | Konsole::historyDialog() | 814 | Konsole::historyDialog() |
774 | { | 815 | { |
775 | QDialog *d = new QDialog ( this, "histdlg", true ); | 816 | QDialog *d = new QDialog ( this, "histdlg", true ); |
776 | // d-> setCaption ( tr( "History" )); | 817 | // d-> setCaption ( tr( "History" )); |
777 | 818 | ||
778 | QBoxLayout *lay = new QVBoxLayout ( d, 4, 4 ); | 819 | QBoxLayout *lay = new QVBoxLayout ( d, 4, 4 ); |
779 | 820 | ||
780 | QLabel *l = new QLabel ( tr( "History Lines:" ), d ); | 821 | QLabel *l = new QLabel ( tr( "History Lines:" ), d ); |
781 | lay-> addWidget ( l ); | 822 | lay-> addWidget ( l ); |
782 | 823 | ||
783 | Config cfg( "Konsole" ); | 824 | Config cfg( "Konsole" ); |
784 | cfg.setGroup("History"); | 825 | cfg.setGroup("History"); |
785 | int hist = cfg.readNumEntry("history_lines",300); | 826 | int hist = cfg.readNumEntry("history_lines",300); |
786 | int avg_line = cfg.readNumEntry("avg_line_length",60); | 827 | int avg_line = cfg.readNumEntry("avg_line_length",60); |
787 | 828 | ||
788 | QSpinBox *spin = new QSpinBox ( 1, 100000, 20, d ); | 829 | QSpinBox *spin = new QSpinBox ( 1, 100000, 20, d ); |
789 | spin-> setValue ( hist ); | 830 | spin-> setValue ( hist ); |
790 | spin-> setWrapping ( true ); | 831 | spin-> setWrapping ( true ); |
791 | spin-> setButtonSymbols ( QSpinBox::PlusMinus ); | 832 | spin-> setButtonSymbols ( QSpinBox::PlusMinus ); |
792 | lay-> addWidget ( spin ); | 833 | lay-> addWidget ( spin ); |
793 | 834 | ||
794 | if ( d-> exec ( ) == QDialog::Accepted ) | 835 | if ( d-> exec ( ) == QDialog::Accepted ) |
795 | { | 836 | { |
796 | cfg.writeEntry("history_lines", spin->value()); | 837 | cfg.writeEntry("history_lines", spin->value()); |
797 | cfg.writeEntry("avg_line_length", avg_line); | 838 | cfg.writeEntry("avg_line_length", avg_line); |
798 | if (getTe() != NULL) | 839 | if (getTe() != NULL) |
799 | { | 840 | { |
800 | getTe()->currentSession->setHistory(true); | 841 | getTe()->currentSession->setHistory(true); |
801 | } | 842 | } |
802 | } | 843 | } |
803 | 844 | ||
804 | delete d; | 845 | delete d; |
805 | } | 846 | } |
806 | 847 | ||
807 | 848 | ||
808 | void Konsole::cycleZoom() | 849 | void Konsole::cycleZoom() |
809 | { | 850 | { |
810 | TEWidget* te = getTe(); | 851 | TEWidget* te = getTe(); |
811 | QFont font = te->getVTFont(); | 852 | QFont font = te->getVTFont(); |
812 | int size = font.pointSize(); | 853 | int size = font.pointSize(); |
813 | changeFontSize(1); | 854 | changeFontSize(1); |
814 | font = te->getVTFont(); | 855 | font = te->getVTFont(); |
815 | if (font.pointSize() <= size) | 856 | if (font.pointSize() <= size) |
816 | { | 857 | { |
817 | do | 858 | do |
818 | { | 859 | { |
819 | font = te->getVTFont(); | 860 | font = te->getVTFont(); |
820 | size = font.pointSize(); | 861 | size = font.pointSize(); |
821 | changeFontSize(-1); | 862 | changeFontSize(-1); |
822 | font = te->getVTFont(); | 863 | font = te->getVTFont(); |
823 | } | 864 | } |
824 | while (font.pointSize() < size); | 865 | while (font.pointSize() < size); |
825 | } | 866 | } |
826 | } | 867 | } |
827 | 868 | ||
828 | void Konsole::changeFontSize(int delta) | 869 | void Konsole::changeFontSize(int delta) |
829 | { | 870 | { |
830 | // printf("delta font size %d\n", delta); | 871 | // printf("delta font size %d\n", delta); |
831 | TEWidget* te = getTe(); | 872 | TEWidget* te = getTe(); |
832 | QFont font = te->getVTFont(); | 873 | QFont font = te->getVTFont(); |
833 | int size = font.pointSize(); | 874 | int size = font.pointSize(); |
834 | int closest = delta > 0? 10000 : -10000; | 875 | int closest = delta > 0? 10000 : -10000; |
835 | int closest_font = -1; | 876 | int closest_font = -1; |
836 | for(uint i = 0; i < fonts.count(); i++) | 877 | for(uint i = 0; i < fonts.count(); i++) |
837 | { | 878 | { |
838 | if (fonts.at(i)->getFont() == font) | 879 | if (fonts.at(i)->getFont() == font) |
839 | { | 880 | { |
840 | if (delta > 0) | 881 | if (delta > 0) |
841 | { | 882 | { |
842 | if (i+1 < fonts.count() | 883 | if (i+1 < fonts.count() |
843 | && fonts.at(i+1)->getFamilyNum() == fonts.at(i)->getFamilyNum()) | 884 | && fonts.at(i+1)->getFamilyNum() == fonts.at(i)->getFamilyNum()) |
844 | { | 885 | { |
845 | setFont(i+1); | 886 | setFont(i+1); |
846 | printf("font %d\n", i+1); | 887 | printf("font %d\n", i+1); |
847 | return; | 888 | return; |
848 | } | 889 | } |
849 | } | 890 | } |
850 | else if (delta < 0) | 891 | else if (delta < 0) |
851 | { | 892 | { |
852 | if (i > 0 | 893 | if (i > 0 |
853 | && fonts.at(i-1)->getFamilyNum() == fonts.at(i)->getFamilyNum()) | 894 | && fonts.at(i-1)->getFamilyNum() == fonts.at(i)->getFamilyNum()) |
854 | { | 895 | { |
855 | setFont(i-1); | 896 | setFont(i-1); |
856 | printf("font %d\n", i-1); | 897 | printf("font %d\n", i-1); |
857 | return; | 898 | return; |
858 | } | 899 | } |
859 | } | 900 | } |
860 | } | 901 | } |
861 | int fsize = fonts.at(i)->getSize(); | 902 | int fsize = fonts.at(i)->getSize(); |
862 | printf("%d size=%d fsize=%d closest=%d\n", i, size, fsize, closest); | 903 | printf("%d size=%d fsize=%d closest=%d\n", i, size, fsize, closest); |
863 | if ((delta > 0 && fsize > size && fsize < closest) | 904 | if ((delta > 0 && fsize > size && fsize < closest) |
864 | || (delta < 0 && fsize < size && fsize > closest)) | 905 | || (delta < 0 && fsize < size && fsize > closest)) |
865 | { | 906 | { |
866 | closest = fsize; | 907 | closest = fsize; |
867 | closest_font = i; | 908 | closest_font = i; |
868 | } | 909 | } |
869 | } | 910 | } |
870 | if (closest_font >= 0) | 911 | if (closest_font >= 0) |
871 | { | 912 | { |
872 | printf("font closest %d (%d)\n", closest_font, closest); | 913 | printf("font closest %d (%d)\n", closest_font, closest); |
873 | setFont(closest_font); | 914 | setFont(closest_font); |
874 | } | 915 | } |
875 | } | 916 | } |
876 | 917 | ||
877 | int Konsole::findFont(const QString& name, int size, bool exactMatch) | 918 | int Konsole::findFont(const QString& name, int size, bool exactMatch) |
878 | { | 919 | { |
879 | for(uint i = 0; i < fonts.count(); i++) | 920 | for(uint i = 0; i < fonts.count(); i++) |
880 | { | 921 | { |
881 | if (fonts.at(i)->getName() == name | 922 | if (fonts.at(i)->getName() == name |
882 | && fonts.at(i)->getSize() == size) | 923 | && fonts.at(i)->getSize() == size) |
883 | { | 924 | { |
884 | return(i); | 925 | return(i); |
885 | } | 926 | } |
886 | } | 927 | } |
887 | if (exactMatch) | 928 | if (exactMatch) |
888 | { | 929 | { |
889 | return(-1); | 930 | return(-1); |
890 | } | 931 | } |
891 | for(uint i = 0; i < fonts.count(); i++) | 932 | for(uint i = 0; i < fonts.count(); i++) |
892 | { | 933 | { |
893 | if (fonts.at(i)->getSize() == size) | 934 | if (fonts.at(i)->getSize() == size) |
894 | { | 935 | { |
895 | return(i); | 936 | return(i); |
896 | } | 937 | } |
897 | } | 938 | } |
898 | return(-1); | 939 | return(-1); |
899 | } | 940 | } |
900 | 941 | ||
901 | void Konsole::setFont(int f) | 942 | void Konsole::setFont(int f) |
902 | { | 943 | { |
903 | VTFont* font = fonts.at(f); | 944 | VTFont* font = fonts.at(f); |
904 | if (font) | 945 | if (font) |
905 | { | 946 | { |
906 | TEWidget* te = getTe(); | 947 | TEWidget* te = getTe(); |
907 | if (te != 0) | 948 | if (te != 0) |
908 | { | 949 | { |
909 | te->setVTFont(font->getFont()); | 950 | te->setVTFont(font->getFont()); |
910 | } | 951 | } |
911 | cfont = f; | 952 | cfont = f; |
912 | 953 | ||
913 | int familyNum = font->getFamilyNum(); | 954 | int familyNum = font->getFamilyNum(); |
914 | int size = font->getSize(); | 955 | int size = font->getSize(); |
915 | printf("familyNum = %d size = %d count=%d\n", familyNum, size, | 956 | printf("familyNum = %d size = %d count=%d\n", familyNum, size, |
916 | fontList->count()); | 957 | fontList->count()); |
917 | for(int i = 0; i < (int)fontList->count(); i++) | 958 | for(int i = 0; i < (int)fontList->count(); i++) |
918 | { | 959 | { |
919 | fontList->setItemChecked(i + 1000, i == familyNum); | 960 | fontList->setItemChecked(i + 1000, i == familyNum); |
920 | } | 961 | } |
921 | for(int i = 0; i < (int)fonts.count(); i++) | 962 | for(int i = 0; i < (int)fonts.count(); i++) |
922 | { | 963 | { |
923 | fontList->setItemChecked(i, fonts.at(i)->getFamilyNum() == familyNum | 964 | fontList->setItemChecked(i, fonts.at(i)->getFamilyNum() == familyNum |
924 | && fonts.at(i)->getSize() == size); | 965 | && fonts.at(i)->getSize() == size); |
925 | } | 966 | } |
926 | Config cfg( "Konsole" ); | 967 | Config cfg( "Konsole" ); |
927 | cfg.setGroup("Font"); | 968 | cfg.setGroup("Font"); |
928 | QString ss = "Session"+ QString::number(tab->currentPageIndex()+1); | 969 | QString ss = "Session"+ QString::number(tab->currentPageIndex()+1); |
929 | if (tab->currentPageIndex() == 0) | 970 | if (tab->currentPageIndex() == 0) |
930 | { | 971 | { |
931 | cfg.writeEntry("FontName", fonts.at(cfont)->getFamily()); | 972 | cfg.writeEntry("FontName", fonts.at(cfont)->getFamily()); |
932 | cfg.writeEntry("FontSize", fonts.at(cfont)->getSize()); | 973 | cfg.writeEntry("FontSize", fonts.at(cfont)->getSize()); |
933 | } | 974 | } |
934 | cfg.writeEntry("FontName"+ss, fonts.at(cfont)->getFamily()); | 975 | cfg.writeEntry("FontName"+ss, fonts.at(cfont)->getFamily()); |
935 | cfg.writeEntry("FontSize"+ss, fonts.at(cfont)->getSize()); | 976 | cfg.writeEntry("FontSize"+ss, fonts.at(cfont)->getSize()); |
936 | } | 977 | } |
937 | } | 978 | } |
938 | 979 | ||
939 | #if 0 | 980 | #if 0 |
940 | void Konsole::fontChanged(int f) | 981 | void Konsole::fontChanged(int f) |
941 | { | 982 | { |
942 | VTFont* font = fonts.at(f); | 983 | VTFont* font = fonts.at(f); |
943 | if (font != 0) | 984 | if (font != 0) |
944 | { | 985 | { |
945 | for(uint i = 0; i < fonts.count(); i++) | 986 | for(uint i = 0; i < fonts.count(); i++) |
946 | { | 987 | { |
947 | fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE); | 988 | fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE); |
948 | } | 989 | } |
949 | 990 | ||
950 | cfont = f; | 991 | cfont = f; |
951 | 992 | ||
952 | TEWidget* te = getTe(); | 993 | TEWidget* te = getTe(); |
953 | if (te != 0) | 994 | if (te != 0) |
954 | { | 995 | { |
955 | te->setVTFont(font->getFont()); | 996 | te->setVTFont(font->getFont()); |
956 | } | 997 | } |
957 | } | 998 | } |
958 | } | 999 | } |
959 | #endif | 1000 | #endif |
960 | 1001 | ||
961 | 1002 | ||
962 | void Konsole::enterCommand(int c) | 1003 | void Konsole::enterCommand(int c) |
963 | { | 1004 | { |
964 | TEWidget* te = getTe(); | 1005 | TEWidget* te = getTe(); |
965 | if (te != 0) | 1006 | if (te != 0) |
966 | { | 1007 | { |
967 | if(!commonCombo->editable()) | 1008 | if(!commonCombo->editable()) |
968 | { | 1009 | { |
969 | QString text = commonCombo->text(c); //commonCmds[c]; | 1010 | QString text = commonCombo->text(c); //commonCmds[c]; |
970 | te->emitText(text); | 1011 | te->emitText(text); |
971 | } | 1012 | } |
972 | else | 1013 | else |
973 | { | 1014 | { |
974 | changeCommand( commonCombo->text(c), c); | 1015 | changeCommand( commonCombo->text(c), c); |
975 | } | 1016 | } |
976 | } | 1017 | } |
977 | } | 1018 | } |
978 | 1019 | ||
979 | void Konsole::hitEnter() | 1020 | void Konsole::hitEnter() |
980 | { | 1021 | { |
981 | TEWidget* te = getTe(); | 1022 | TEWidget* te = getTe(); |
982 | if (te != 0) | 1023 | if (te != 0) |
983 | { | 1024 | { |
984 | te->emitText(QString("\r")); | 1025 | te->emitText(QString("\r")); |
985 | } | 1026 | } |
986 | } | 1027 | } |
987 | 1028 | ||
988 | void Konsole::hitSpace() | 1029 | void Konsole::hitSpace() |
989 | { | 1030 | { |
990 | TEWidget* te = getTe(); | 1031 | TEWidget* te = getTe(); |
991 | if (te != 0) | 1032 | if (te != 0) |
992 | { | 1033 | { |
993 | te->emitText(QString(" ")); | 1034 | te->emitText(QString(" ")); |
994 | } | 1035 | } |
995 | } | 1036 | } |