-rw-r--r-- | core/apps/embeddedkonsole/konsole.cpp | 2 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/opie-embeddedkonsole.control | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/core/apps/embeddedkonsole/konsole.cpp b/core/apps/embeddedkonsole/konsole.cpp index 80c8223..5cfd644 100644 --- a/core/apps/embeddedkonsole/konsole.cpp +++ b/core/apps/embeddedkonsole/konsole.cpp | |||
@@ -1,1376 +1,1376 @@ | |||
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> | 26 | #include <sys/types.h> |
27 | #include <pwd.h> | 27 | #include <pwd.h> |
28 | #include <unistd.h> | 28 | #include <unistd.h> |
29 | 29 | ||
30 | #ifdef QT_QWS_OPIE | 30 | #ifdef QT_QWS_OPIE |
31 | #include <opie2/ocolorpopupmenu.h> | 31 | #include <opie2/ocolorpopupmenu.h> |
32 | #include <opie2/odebug.h> | 32 | #include <opie2/odebug.h> |
33 | using namespace Opie; | 33 | using namespace Opie; |
34 | #endif | 34 | #endif |
35 | 35 | ||
36 | #include <qpe/resource.h> | 36 | #include <qpe/resource.h> |
37 | 37 | ||
38 | #include <qmenubar.h> | 38 | #include <qmenubar.h> |
39 | #include <qtabbar.h> | 39 | #include <qtabbar.h> |
40 | #include <qpe/config.h> | 40 | #include <qpe/config.h> |
41 | #include <qfontdatabase.h> | 41 | #include <qfontdatabase.h> |
42 | #include <qfile.h> | 42 | #include <qfile.h> |
43 | #include <qspinbox.h> | 43 | #include <qspinbox.h> |
44 | #include <qlayout.h> | 44 | #include <qlayout.h> |
45 | 45 | ||
46 | #include <sys/wait.h> | 46 | #include <sys/wait.h> |
47 | #include <stdio.h> | 47 | #include <stdio.h> |
48 | #include <stdlib.h> | 48 | #include <stdlib.h> |
49 | #include <assert.h> | 49 | #include <assert.h> |
50 | 50 | ||
51 | #include "konsole.h" | 51 | #include "konsole.h" |
52 | #include "commandeditdialog.h" | 52 | #include "commandeditdialog.h" |
53 | 53 | ||
54 | class EKNumTabBar : public QTabBar | 54 | class EKNumTabBar : public QTabBar |
55 | { | 55 | { |
56 | public: | 56 | public: |
57 | EKNumTabBar(QWidget *parent = 0, const char *name = 0) : | 57 | EKNumTabBar(QWidget *parent = 0, const char *name = 0) : |
58 | QTabBar(parent, name) | 58 | QTabBar(parent, name) |
59 | {} | 59 | {} |
60 | 60 | ||
61 | // QList<QTab> *getTabList() { return(tabList()); } | 61 | // QList<QTab> *getTabList() { return(tabList()); } |
62 | 62 | ||
63 | void numberTabs() | 63 | void numberTabs() |
64 | { | 64 | { |
65 | // Yes, it really is this messy. QTabWidget needs functions | 65 | // Yes, it really is this messy. QTabWidget needs functions |
66 | // that provide acces to tabs in a sequential way. | 66 | // that provide acces to tabs in a sequential way. |
67 | int m=INT_MIN; | 67 | int m=INT_MIN; |
68 | for (int i=0; i<count(); i++) | 68 | for (int i=0; i<count(); i++) |
69 | { | 69 | { |
70 | QTab* left=0; | 70 | QTab* left=0; |
71 | QListIterator<QTab> it(*tabList()); | 71 | QListIterator<QTab> it(*tabList()); |
72 | int x=INT_MAX; | 72 | int x=INT_MAX; |
73 | for( QTab* t; (t=it.current()); ++it ) | 73 | for( QTab* t; (t=it.current()); ++it ) |
74 | { | 74 | { |
75 | int tx = t->rect().x(); | 75 | int tx = t->rect().x(); |
76 | if ( tx<x && tx>m ) | 76 | if ( tx<x && tx>m ) |
77 | { | 77 | { |
78 | x = tx; | 78 | x = tx; |
79 | left = t; | 79 | left = t; |
80 | } | 80 | } |
81 | } | 81 | } |
82 | if ( left ) | 82 | if ( left ) |
83 | { | 83 | { |
84 | left->setText(QString::number(i+1)); | 84 | left->setText(QString::number(i+1)); |
85 | m = left->rect().x(); | 85 | m = left->rect().x(); |
86 | } | 86 | } |
87 | } | 87 | } |
88 | } | 88 | } |
89 | 89 | ||
90 | virtual QSize sizeHint() const | 90 | virtual QSize sizeHint() const |
91 | { | 91 | { |
92 | if (isHidden()) | 92 | if (isHidden()) |
93 | { | 93 | { |
94 | return(QSize(0,0)); | 94 | return(QSize(0,0)); |
95 | } | 95 | } |
96 | else | 96 | else |
97 | { | 97 | { |
98 | QSize size = QTabBar::sizeHint(); | 98 | QSize size = QTabBar::sizeHint(); |
99 | int shrink = 5; | 99 | int shrink = 5; |
100 | if (qApp->desktop()->width() > 600 || qApp->desktop()->height() > 600) | 100 | if (qApp->desktop()->width() > 600 || qApp->desktop()->height() > 600) |
101 | { | 101 | { |
102 | shrink = 10; | 102 | shrink = 10; |
103 | } | 103 | } |
104 | size.setHeight(size.height() - shrink); | 104 | size.setHeight(size.height() - shrink); |
105 | return(size); | 105 | return(size); |
106 | } | 106 | } |
107 | } | 107 | } |
108 | 108 | ||
109 | }; | 109 | }; |
110 | 110 | ||
111 | class EKNumTabWidget : public QTabWidget | 111 | class EKNumTabWidget : public QTabWidget |
112 | { | 112 | { |
113 | public: | 113 | public: |
114 | EKNumTabWidget(QWidget* parent) : QTabWidget(parent) | 114 | EKNumTabWidget(QWidget* parent) : QTabWidget(parent) |
115 | { | 115 | { |
116 | setTabBar(new EKNumTabBar(parent,"EKTabBar")); | 116 | setTabBar(new EKNumTabBar(parent,"EKTabBar")); |
117 | setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); | 117 | setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); |
118 | } | 118 | } |
119 | 119 | ||
120 | EKNumTabBar *getTabBar() const | 120 | EKNumTabBar *getTabBar() const |
121 | { | 121 | { |
122 | return ((EKNumTabBar*)tabBar()); | 122 | return ((EKNumTabBar*)tabBar()); |
123 | } | 123 | } |
124 | 124 | ||
125 | 125 | ||
126 | void addTab(QWidget* w) | 126 | void addTab(QWidget* w) |
127 | { | 127 | { |
128 | QTab* t = new QTab(QString::number(tabBar()->count()+1)); | 128 | QTab* t = new QTab(QString::number(tabBar()->count()+1)); |
129 | QTabWidget::addTab(w,t); | 129 | QTabWidget::addTab(w,t); |
130 | } | 130 | } |
131 | 131 | ||
132 | void removeTab(QWidget* w) | 132 | void removeTab(QWidget* w) |
133 | { | 133 | { |
134 | removePage(w); | 134 | removePage(w); |
135 | ((EKNumTabBar*)tabBar())->numberTabs(); | 135 | ((EKNumTabBar*)tabBar())->numberTabs(); |
136 | } | 136 | } |
137 | }; | 137 | }; |
138 | 138 | ||
139 | // This could be configurable or dynamicly generated from the bash history | 139 | // This could be configurable or dynamicly generated from the bash history |
140 | // file of the user | 140 | // file of the user |
141 | static const char *commonCmds[] = | 141 | static const char *commonCmds[] = |
142 | { | 142 | { |
143 | "ls ", // I left this here, cause it looks better than the first alpha | 143 | "ls ", // I left this here, cause it looks better than the first alpha |
144 | "cardctl eject", | 144 | "cardctl eject", |
145 | "cat ", | 145 | "cat ", |
146 | "cd ", | 146 | "cd ", |
147 | "chmod ", | 147 | "chmod ", |
148 | "clear", | 148 | "clear", |
149 | "cp ", | 149 | "cp ", |
150 | "dc ", | 150 | "dc ", |
151 | "df ", | 151 | "df ", |
152 | "dmesg", | 152 | "dmesg", |
153 | "echo ", | 153 | "echo ", |
154 | "env", | 154 | "env", |
155 | "find ", | 155 | "find ", |
156 | "free", | 156 | "free", |
157 | "grep ", | 157 | "grep ", |
158 | "ifconfig ", | 158 | "ifconfig ", |
159 | "ipkg ", | 159 | "ipkg ", |
160 | "mkdir ", | 160 | "mkdir ", |
161 | "mv ", | 161 | "mv ", |
162 | "nc localhost 7776", | 162 | "nc localhost 7776", |
163 | "nc localhost 7777", | 163 | "nc localhost 7777", |
164 | "netstat ", | 164 | "netstat ", |
165 | "nslookup ", | 165 | "nslookup ", |
166 | "ping ", | 166 | "ping ", |
167 | "ps aux", | 167 | "ps aux", |
168 | "pwd ", | 168 | "pwd ", |
169 | "qcop QPE/System 'linkChanged(QString)' ''", | 169 | "qcop QPE/System 'linkChanged(QString)' ''", |
170 | "qcop QPE/System 'restart()'", | 170 | "qcop QPE/System 'restart()'", |
171 | "qcop QPE/System 'quit()'", | 171 | "qcop QPE/System 'quit()'", |
172 | "rm ", | 172 | "rm ", |
173 | "rmdir ", | 173 | "rmdir ", |
174 | "route ", | 174 | "route ", |
175 | "set ", | 175 | "set ", |
176 | "traceroute", | 176 | "traceroute", |
177 | 177 | ||
178 | /* | 178 | /* |
179 | "gzip", | 179 | "gzip", |
180 | "gunzip", | 180 | "gunzip", |
181 | "chgrp", | 181 | "chgrp", |
182 | "chown", | 182 | "chown", |
183 | "date", | 183 | "date", |
184 | "dd", | 184 | "dd", |
185 | "df", | 185 | "df", |
186 | "dmesg", | 186 | "dmesg", |
187 | "fuser", | 187 | "fuser", |
188 | "hostname", | 188 | "hostname", |
189 | "kill", | 189 | "kill", |
190 | "killall", | 190 | "killall", |
191 | "ln", | 191 | "ln", |
192 | "ping", | 192 | "ping", |
193 | "mount", | 193 | "mount", |
194 | "more", | 194 | "more", |
195 | "sort", | 195 | "sort", |
196 | "touch", | 196 | "touch", |
197 | "umount", | 197 | "umount", |
198 | "mknod", | 198 | "mknod", |
199 | "netstat", | 199 | "netstat", |
200 | */ | 200 | */ |
201 | 201 | ||
202 | "exit", | 202 | "exit", |
203 | NULL | 203 | NULL |
204 | }; | 204 | }; |
205 | 205 | ||
206 | 206 | ||
207 | static void konsoleInit(const char** shell) { | 207 | static void konsoleInit(const char** shell) { |
208 | if(setuid(getuid()) !=0) odebug << "setuid failed" << oendl; | 208 | if(setuid(getuid()) !=0) odebug << "setuid failed" << oendl; |
209 | if(setgid(getgid()) != 0) odebug << "setgid failed" << oendl; // drop privileges | 209 | if(setgid(getgid()) != 0) odebug << "setgid failed" << oendl; // drop privileges |
210 | 210 | ||
211 | 211 | ||
212 | // QPEApplication::grabKeyboard(); // for CTRL and ALT | 212 | // QPEApplication::grabKeyboard(); // for CTRL and ALT |
213 | 213 | ||
214 | odebug << "keyboard grabbed" << oendl; | 214 | odebug << "keyboard grabbed" << oendl; |
215 | #ifdef FAKE_CTRL_AND_ALT | 215 | #ifdef FAKE_CTRL_AND_ALT |
216 | odebug << "Fake Ctrl and Alt defined" << oendl; | 216 | odebug << "Fake Ctrl and Alt defined" << oendl; |
217 | QPEApplication::grabKeyboard(); // for CTRL and ALT | 217 | QPEApplication::grabKeyboard(); // for CTRL and ALT |
218 | #endif | 218 | #endif |
219 | 219 | ||
220 | *shell = getenv("SHELL"); | 220 | *shell = getenv("SHELL"); |
221 | owarn << "SHell initially is " << *shell << "" << oendl; | 221 | owarn << "SHell initially is " << *shell << "" << oendl; |
222 | 222 | ||
223 | if (shell == NULL || *shell == '\0') { | 223 | if (shell == NULL || *shell == '\0') { |
224 | struct passwd *ent = 0; | 224 | struct passwd *ent = 0; |
225 | uid_t me = getuid(); | 225 | uid_t me = getuid(); |
226 | *shell = "/bin/sh"; | 226 | *shell = "/bin/sh"; |
227 | 227 | ||
228 | while ( (ent = getpwent()) != 0 ) { | 228 | while ( (ent = getpwent()) != 0 ) { |
229 | if (ent->pw_uid == me) { | 229 | if (ent->pw_uid == me) { |
230 | if (ent->pw_shell != "") | 230 | if (ent->pw_shell != "") |
231 | *shell = ent->pw_shell; | 231 | *shell = ent->pw_shell; |
232 | break; | 232 | break; |
233 | } | 233 | } |
234 | } | 234 | } |
235 | endpwent(); | 235 | endpwent(); |
236 | } | 236 | } |
237 | 237 | ||
238 | if( putenv((char*)"COLORTERM=") !=0) | 238 | if( putenv((char*)"COLORTERM=") !=0) |
239 | odebug << "putenv failed" << oendl; // to trigger mc's color detection | 239 | odebug << "putenv failed" << oendl; // to trigger mc's color detection |
240 | } | 240 | } |
241 | 241 | ||
242 | 242 | ||
243 | Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) : | 243 | Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) : |
244 | QMainWindow(parent, name, fl) | 244 | QMainWindow(parent, name, fl) |
245 | { | 245 | { |
246 | QStrList tmp; const char* shell; | 246 | QStrList tmp; const char* shell; |
247 | 247 | ||
248 | konsoleInit( &shell); | 248 | konsoleInit( &shell); |
249 | init(shell,tmp); | 249 | init(shell,tmp); |
250 | } | 250 | } |
251 | 251 | ||
252 | Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int) | 252 | Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int) |
253 | : QMainWindow(0, name) | 253 | : QMainWindow(0, name) |
254 | { | 254 | { |
255 | init(_pgm,_args); | 255 | init(_pgm,_args); |
256 | } | 256 | } |
257 | 257 | ||
258 | struct HistoryItem | 258 | struct HistoryItem |
259 | { | 259 | { |
260 | HistoryItem(int c, const QString &l) | 260 | HistoryItem(int c, const QString &l) |
261 | { | 261 | { |
262 | count = c; | 262 | count = c; |
263 | line = l; | 263 | line = l; |
264 | } | 264 | } |
265 | int count; | 265 | int count; |
266 | QString line; | 266 | QString line; |
267 | }; | 267 | }; |
268 | 268 | ||
269 | class HistoryList : public QList<HistoryItem> | 269 | class HistoryList : public QList<HistoryItem> |
270 | { | 270 | { |
271 | virtual int compareItems( QCollection::Item item1, QCollection::Item item2) | 271 | virtual int compareItems( QCollection::Item item1, QCollection::Item item2) |
272 | { | 272 | { |
273 | int c1 = ((HistoryItem*)item1)->count; | 273 | int c1 = ((HistoryItem*)item1)->count; |
274 | int c2 = ((HistoryItem*)item2)->count; | 274 | int c2 = ((HistoryItem*)item2)->count; |
275 | if (c1 > c2) | 275 | if (c1 > c2) |
276 | return(1); | 276 | return(1); |
277 | if (c1 < c2) | 277 | if (c1 < c2) |
278 | return(-1); | 278 | return(-1); |
279 | return(0); | 279 | return(0); |
280 | } | 280 | } |
281 | }; | 281 | }; |
282 | 282 | ||
283 | void Konsole::initCommandList() | 283 | void Konsole::initCommandList() |
284 | { | 284 | { |
285 | // odebug << "Konsole::initCommandList" << oendl; | 285 | // odebug << "Konsole::initCommandList" << oendl; |
286 | Config cfg( "Konsole" ); | 286 | Config cfg( "Konsole" ); |
287 | cfg.setGroup("Commands"); | 287 | cfg.setGroup("Commands"); |
288 | // commonCombo->setInsertionPolicy(QComboBox::AtCurrent); | 288 | // commonCombo->setInsertionPolicy(QComboBox::AtCurrent); |
289 | commonCombo->clear(); | 289 | commonCombo->clear(); |
290 | 290 | ||
291 | if (cfg.readEntry("ShellHistory","TRUE") == "TRUE") | 291 | if (cfg.readEntry("ShellHistory","TRUE") == "TRUE") |
292 | { | 292 | { |
293 | QString histfilename = QString(getenv("HOME")) + "/.bash_history"; | 293 | QString histfilename = QString(getenv("HOME")) + "/.bash_history"; |
294 | histfilename = cfg.readEntry("ShellHistoryPath",histfilename); | 294 | histfilename = cfg.readEntry("ShellHistoryPath",histfilename); |
295 | QFile histfile(histfilename); | 295 | QFile histfile(histfilename); |
296 | // note: compiler barfed on: | 296 | // note: compiler barfed on: |
297 | // QFile histfile(QString(getenv("HOME")) + "/.bash_history"); | 297 | // QFile histfile(QString(getenv("HOME")) + "/.bash_history"); |
298 | if (histfile.open( IO_ReadOnly )) | 298 | if (histfile.open( IO_ReadOnly )) |
299 | { | 299 | { |
300 | QString line; | 300 | QString line; |
301 | uint i; | 301 | uint i; |
302 | HistoryList items; | 302 | HistoryList items; |
303 | 303 | ||
304 | int lineno = 0; | 304 | int lineno = 0; |
305 | while(!histfile.atEnd()) | 305 | while(!histfile.atEnd()) |
306 | { | 306 | { |
307 | if (histfile.readLine(line, 200) < 0) | 307 | if (histfile.readLine(line, 200) < 0) |
308 | { | 308 | { |
309 | break; | 309 | break; |
310 | } | 310 | } |
311 | line = line.left(line.length()-1); | 311 | line = line.left(line.length()-1); |
312 | lineno++; | 312 | lineno++; |
313 | 313 | ||
314 | for(i=0; i<items.count(); i++) | 314 | for(i=0; i<items.count(); i++) |
315 | { | 315 | { |
316 | if (line == items.at(i)->line) | 316 | if (line == items.at(i)->line) |
317 | { | 317 | { |
318 | // weight recent commands & repeated commands more | 318 | // weight recent commands & repeated commands more |
319 | // by adding up the index of each command | 319 | // by adding up the index of each command |
320 | items.at(i)->count += lineno; | 320 | items.at(i)->count += lineno; |
321 | break; | 321 | break; |
322 | } | 322 | } |
323 | } | 323 | } |
324 | if (i >= items.count()) | 324 | if (i >= items.count()) |
325 | { | 325 | { |
326 | items.append(new HistoryItem(lineno, line)); | 326 | items.append(new HistoryItem(lineno, line)); |
327 | } | 327 | } |
328 | } | 328 | } |
329 | items.sort(); | 329 | items.sort(); |
330 | int n = items.count(); | 330 | int n = items.count(); |
331 | if (n > 40) | 331 | if (n > 40) |
332 | { | 332 | { |
333 | n = 40; | 333 | n = 40; |
334 | } | 334 | } |
335 | for(int i=0; i<n; i++) | 335 | for(int i=0; i<n; i++) |
336 | { | 336 | { |
337 | // should insert start of command, but keep whole thing | 337 | // should insert start of command, but keep whole thing |
338 | if (items.at(items.count()-i-1)->line.length() < 30) | 338 | if (items.at(items.count()-i-1)->line.length() < 30) |
339 | { | 339 | { |
340 | commonCombo->insertItem(items.at(items.count()-i-1)->line); | 340 | commonCombo->insertItem(items.at(items.count()-i-1)->line); |
341 | } | 341 | } |
342 | } | 342 | } |
343 | histfile.close(); | 343 | histfile.close(); |
344 | } | 344 | } |
345 | } | 345 | } |
346 | if (cfg.readEntry("Commands Set","FALSE") == "FALSE") | 346 | if (cfg.readEntry("Commands Set","FALSE") == "FALSE") |
347 | { | 347 | { |
348 | for (int i = 0; commonCmds[i] != NULL; i++) | 348 | for (int i = 0; commonCmds[i] != NULL; i++) |
349 | { | 349 | { |
350 | commonCombo->insertItem(commonCmds[i]); | 350 | commonCombo->insertItem(commonCmds[i]); |
351 | } | 351 | } |
352 | } | 352 | } |
353 | else | 353 | else |
354 | { | 354 | { |
355 | for (int i = 0; i < 100; i++) | 355 | for (int i = 0; i < 100; i++) |
356 | { | 356 | { |
357 | if (!(cfg.readEntry( QString::number(i),"")).isEmpty()) | 357 | if (!(cfg.readEntry( QString::number(i),"")).isEmpty()) |
358 | commonCombo->insertItem(cfg.readEntry( QString::number(i),"")); | 358 | commonCombo->insertItem(cfg.readEntry( QString::number(i),"")); |
359 | } | 359 | } |
360 | } | 360 | } |
361 | 361 | ||
362 | 362 | ||
363 | } | 363 | } |
364 | 364 | ||
365 | static void sig_handler(int x) | 365 | static void sig_handler(int x) |
366 | { | 366 | { |
367 | printf("got signal %d\n",x); | 367 | printf("got signal %d\n",x); |
368 | } | 368 | } |
369 | 369 | ||
370 | void Konsole::init(const char* _pgm, QStrList & _args) | 370 | void Konsole::init(const char* _pgm, QStrList & _args) |
371 | { | 371 | { |
372 | 372 | ||
373 | #if 0 | 373 | #if 0 |
374 | for(int i=1; i<=31; i++) | 374 | for(int i=1; i<=31; i++) |
375 | { | 375 | { |
376 | if (i != SIGPIPE && i != SIGPROF && i != SIGSEGV | 376 | if (i != SIGPIPE && i != SIGPROF && i != SIGSEGV |
377 | && i != SIGINT && i != SIGILL && i != SIGTERM | 377 | && i != SIGINT && i != SIGILL && i != SIGTERM |
378 | && i != SIGBUS) | 378 | && i != SIGBUS) |
379 | signal(i,sig_handler); | 379 | signal(i,sig_handler); |
380 | } | 380 | } |
381 | #endif | 381 | #endif |
382 | signal(SIGSTOP, sig_handler); | 382 | signal(SIGSTOP, sig_handler); |
383 | signal(SIGCONT, sig_handler); | 383 | signal(SIGCONT, sig_handler); |
384 | signal(SIGTSTP, sig_handler); | 384 | signal(SIGTSTP, sig_handler); |
385 | 385 | ||
386 | b_scroll = TRUE; // histon; | 386 | b_scroll = TRUE; // histon; |
387 | n_keytab = 0; | 387 | n_keytab = 0; |
388 | n_render = 0; | 388 | n_render = 0; |
389 | startUp=0; | 389 | startUp=0; |
390 | fromMenu = FALSE; | 390 | fromMenu = FALSE; |
391 | fullscreen = false; | 391 | fullscreen = false; |
392 | 392 | ||
393 | setCaption( tr( "Konsole" ) ); | 393 | setCaption( tr( "Konsole" ) ); |
394 | setIcon( Resource::loadPixmap( "konsole/Terminal" ) ); | 394 | setIcon( Resource::loadPixmap( "konsole/Terminal" ) ); |
395 | 395 | ||
396 | Config cfg( "Konsole" ); | 396 | Config cfg( "Konsole" ); |
397 | cfg.setGroup("Font"); | 397 | cfg.setGroup("Font"); |
398 | QString tmp; | 398 | QString tmp; |
399 | 399 | ||
400 | // initialize the list of allowed fonts /////////////////////////////////// | 400 | // initialize the list of allowed fonts /////////////////////////////////// |
401 | 401 | ||
402 | QString cfgFontName = cfg.readEntry("FontName","Lcfont"); | 402 | QString cfgFontName = cfg.readEntry("FontName","Lcfont"); |
403 | int cfgFontSize = cfg.readNumEntry("FontSize",18); | 403 | int cfgFontSize = cfg.readNumEntry("FontSize",18); |
404 | 404 | ||
405 | cfont = -1; | 405 | cfont = -1; |
406 | 406 | ||
407 | // this code causes repeated access to all the font files | 407 | // this code causes repeated access to all the font files |
408 | // which does slow down startup | 408 | // which does slow down startup |
409 | QFontDatabase fontDB; | 409 | QFontDatabase fontDB; |
410 | QStringList familyNames; | 410 | QStringList familyNames; |
411 | familyNames = fontDB.families( FALSE ); | 411 | familyNames = fontDB.families( FALSE ); |
412 | QString s; | 412 | QString s; |
413 | int fontIndex = 0; | 413 | int fontIndex = 0; |
414 | int familyNum = 0; | 414 | int familyNum = 0; |
415 | fontList = new QPopupMenu( this ); | 415 | fontList = new QPopupMenu( this ); |
416 | 416 | ||
417 | for(uint j = 0; j < (uint)familyNames.count(); j++) | 417 | for(uint j = 0; j < (uint)familyNames.count(); j++) |
418 | { | 418 | { |
419 | s = familyNames[j]; | 419 | s = familyNames[j]; |
420 | if ( s.contains('-') ) | 420 | if ( s.contains('-') ) |
421 | { | 421 | { |
422 | int i = s.find('-'); | 422 | int i = s.find('-'); |
423 | s = s.right( s.length() - i - 1 ) + " [" + s.left( i ) + "]"; | 423 | s = s.right( s.length() - i - 1 ) + " [" + s.left( i ) + "]"; |
424 | } | 424 | } |
425 | s[0] = s[0].upper(); | 425 | s[0] = s[0].upper(); |
426 | 426 | ||
427 | QValueList<int> sizes = fontDB.pointSizes( familyNames[j] ); | 427 | QValueList<int> sizes = fontDB.pointSizes( familyNames[j] ); |
428 | 428 | ||
429 | printf("family[%d] = %s with %d sizes\n", j, familyNames[j].latin1(), | 429 | printf("family[%d] = %s with %d sizes\n", j, familyNames[j].latin1(), |
430 | sizes.count()); | 430 | sizes.count()); |
431 | 431 | ||
432 | if (sizes.count() > 0) | 432 | if (sizes.count() > 0) |
433 | { | 433 | { |
434 | QPopupMenu *sizeMenu; | 434 | QPopupMenu *sizeMenu; |
435 | QFont f; | 435 | QFont f; |
436 | int last_width = -1; | 436 | int last_width = -1; |
437 | sizeMenu = NULL; | 437 | sizeMenu = NULL; |
438 | 438 | ||
439 | for(uint i = 0; i < (uint)sizes.count() + 4; i++) | 439 | for(uint i = 0; i < (uint)sizes.count() + 4; i++) |
440 | { | 440 | { |
441 | // printf("family %s size %d ", familyNames[j].latin1(), sizes[i]); | 441 | // printf("family %s size %d ", familyNames[j].latin1(), sizes[i]); |
442 | // need to divide by 10 on the Z, but not otherwise | 442 | // need to divide by 10 on the Z, but not otherwise |
443 | int size; | 443 | int size; |
444 | 444 | ||
445 | if (i >= (uint)sizes.count()) | 445 | if (i >= (uint)sizes.count()) |
446 | { | 446 | { |
447 | // try for expandable fonts | 447 | // try for expandable fonts |
448 | size = sizes[sizes.count()-1] + 2 * (i - sizes.count() + 1); | 448 | size = sizes[sizes.count()-1] + 2 * (i - sizes.count() + 1); |
449 | } | 449 | } |
450 | else | 450 | else |
451 | { | 451 | { |
452 | printf("sizes[%d] = %d\n", i, sizes[i]); | 452 | printf("sizes[%d] = %d\n", i, sizes[i]); |
453 | size = sizes[i]; | 453 | size = sizes[i]; |
454 | } | 454 | } |
455 | 455 | ||
456 | f = QFont(familyNames[j], size); | 456 | f = QFont(familyNames[j], size); |
457 | f.setFixedPitch(true); | 457 | f.setFixedPitch(true); |
458 | QFontMetrics fm(f); | 458 | QFontMetrics fm(f); |
459 | // don't trust f.fixedPitch() or f.exactMatch(), they lie!! | 459 | // don't trust f.fixedPitch() or f.exactMatch(), they lie!! |
460 | if (fm.width("l") == fm.width("m") | 460 | if (fm.width("l") == fm.width("m") |
461 | && (i < (uint)sizes.count() | 461 | && (i < (uint)sizes.count() |
462 | || fm.width("m") > last_width)) | 462 | || fm.width("m") > last_width)) |
463 | { | 463 | { |
464 | if (i < (uint)sizes.count()) | 464 | if (i < (uint)sizes.count()) |
465 | { | 465 | { |
466 | last_width = fm.width("m"); | 466 | last_width = fm.width("m"); |
467 | } | 467 | } |
468 | if (sizeMenu == NULL) | 468 | if (sizeMenu == NULL) |
469 | { | 469 | { |
470 | sizeMenu = new QPopupMenu(); | 470 | sizeMenu = new QPopupMenu(); |
471 | } | 471 | } |
472 | int id = sizeMenu->insertItem(QString("%1").arg(size), fontIndex); | 472 | int id = sizeMenu->insertItem(QString("%1").arg(size), fontIndex); |
473 | sizeMenu->setItemParameter(id, fontIndex); | 473 | sizeMenu->setItemParameter(id, fontIndex); |
474 | sizeMenu->connectItem(id, this, SLOT(setFont(int))); | 474 | sizeMenu->connectItem(id, this, SLOT(setFont(int))); |
475 | QString name = s + " " + QString::number(size); | 475 | QString name = s + " " + QString::number(size); |
476 | fonts.append(new VTFont(name, f, familyNames[j], familyNum, size)); | 476 | fonts.append(new VTFont(name, f, familyNames[j], familyNum, size)); |
477 | if (familyNames[j] == cfgFontName && size == cfgFontSize) | 477 | if (familyNames[j] == cfgFontName && size == cfgFontSize) |
478 | { | 478 | { |
479 | cfont = fontIndex; | 479 | cfont = fontIndex; |
480 | } | 480 | } |
481 | printf("FOUND: %s family %s size %d\n", name.latin1(), familyNames[j].latin1(), size); | 481 | printf("FOUND: %s family %s size %d\n", name.latin1(), familyNames[j].latin1(), size); |
482 | fontIndex++; | 482 | fontIndex++; |
483 | } | 483 | } |
484 | } | 484 | } |
485 | if (sizeMenu) | 485 | if (sizeMenu) |
486 | { | 486 | { |
487 | fontList->insertItem(s, sizeMenu, familyNum + 1000); | 487 | fontList->insertItem(s, sizeMenu, familyNum + 1000); |
488 | 488 | ||
489 | familyNum++; | 489 | familyNum++; |
490 | } | 490 | } |
491 | } | 491 | } |
492 | 492 | ||
493 | } | 493 | } |
494 | 494 | ||
495 | if (cfont < 0 || cfont >= (int)fonts.count()) | 495 | if (cfont < 0 || cfont >= (int)fonts.count()) |
496 | { | 496 | { |
497 | cfont = 0; | 497 | cfont = 0; |
498 | } | 498 | } |
499 | 499 | ||
500 | // create terminal emulation framework //////////////////////////////////// | 500 | // create terminal emulation framework //////////////////////////////////// |
501 | nsessions = 0; | 501 | nsessions = 0; |
502 | 502 | ||
503 | tab = new EKNumTabWidget(this); | 503 | tab = new EKNumTabWidget(this); |
504 | // tab->setMargin(tab->margin()-5); | 504 | // tab->setMargin(tab->margin()-5); |
505 | connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*))); | 505 | connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*))); |
506 | 506 | ||
507 | // create terminal toolbar //////////////////////////////////////////////// | 507 | // create terminal toolbar //////////////////////////////////////////////// |
508 | setToolBarsMovable( FALSE ); | 508 | setToolBarsMovable( FALSE ); |
509 | menuToolBar = new QToolBar( this ); | 509 | menuToolBar = new QToolBar( this ); |
510 | menuToolBar->setHorizontalStretchable( TRUE ); | 510 | menuToolBar->setHorizontalStretchable( TRUE ); |
511 | 511 | ||
512 | QMenuBar *menuBar = new QMenuBar( menuToolBar ); | 512 | QMenuBar *menuBar = new QMenuBar( menuToolBar ); |
513 | 513 | ||
514 | setFont(cfont); | 514 | setFont(cfont); |
515 | 515 | ||
516 | configMenu = new QPopupMenu( this); | 516 | configMenu = new QPopupMenu( this); |
517 | colorMenu = new QPopupMenu( this); | 517 | colorMenu = new QPopupMenu( this); |
518 | scrollMenu = new QPopupMenu( this); | 518 | scrollMenu = new QPopupMenu( this); |
519 | editCommandListMenu = new QPopupMenu( this); | 519 | editCommandListMenu = new QPopupMenu( this); |
520 | 520 | ||
521 | configMenu->insertItem(tr("Command List"), editCommandListMenu); | 521 | configMenu->insertItem(tr("Command List"), editCommandListMenu); |
522 | 522 | ||
523 | bool listHidden; | 523 | bool listHidden; |
524 | cfg.setGroup("Menubar"); | 524 | cfg.setGroup("Menubar"); |
525 | if( cfg.readEntry("Hidden","FALSE") == "TRUE") | 525 | if( cfg.readEntry("Hidden","FALSE") == "TRUE") |
526 | { | 526 | { |
527 | ec_cmdlist = editCommandListMenu->insertItem( tr( "Show command list" )); | 527 | ec_cmdlist = editCommandListMenu->insertItem( tr( "Show command list" )); |
528 | listHidden=TRUE; | 528 | listHidden=TRUE; |
529 | } | 529 | } |
530 | else | 530 | else |
531 | { | 531 | { |
532 | ec_cmdlist = editCommandListMenu->insertItem( tr( "Hide command list" )); | 532 | ec_cmdlist = editCommandListMenu->insertItem( tr( "Hide command list" )); |
533 | listHidden=FALSE; | 533 | listHidden=FALSE; |
534 | } | 534 | } |
535 | 535 | ||
536 | cfg.setGroup("Tabs"); | 536 | cfg.setGroup("Tabs"); |
537 | 537 | ||
538 | tabMenu = new QPopupMenu(this); | 538 | tabMenu = new QPopupMenu(this); |
539 | tm_bottom = tabMenu->insertItem(tr("Bottom" )); | 539 | tm_bottom = tabMenu->insertItem(tr("Bottom" )); |
540 | tm_top = tabMenu->insertItem(tr("Top")); | 540 | tm_top = tabMenu->insertItem(tr("Top")); |
541 | tm_hidden = tabMenu->insertItem(tr("Hidden")); | 541 | tm_hidden = tabMenu->insertItem(tr("Hidden")); |
542 | 542 | ||
543 | configMenu->insertItem(tr("Tabs"), tabMenu); | 543 | configMenu->insertItem(tr("Tabs"), tabMenu); |
544 | 544 | ||
545 | tmp=cfg.readEntry("Position","Top"); | 545 | tmp=cfg.readEntry("Position","Top"); |
546 | if(tmp=="Top") | 546 | if(tmp=="Top") |
547 | { | 547 | { |
548 | tab->setTabPosition(QTabWidget::Top); | 548 | tab->setTabPosition(QTabWidget::Top); |
549 | tab->getTabBar()->show(); | 549 | tab->getTabBar()->show(); |
550 | tabPos = tm_top; | 550 | tabPos = tm_top; |
551 | } | 551 | } |
552 | else if (tmp=="Bottom") | 552 | else if (tmp=="Bottom") |
553 | { | 553 | { |
554 | tab->setTabPosition(QTabWidget::Bottom); | 554 | tab->setTabPosition(QTabWidget::Bottom); |
555 | tab->getTabBar()->show(); | 555 | tab->getTabBar()->show(); |
556 | tabPos = tm_bottom; | 556 | tabPos = tm_bottom; |
557 | } | 557 | } |
558 | else | 558 | else |
559 | { | 559 | { |
560 | tab->getTabBar()->hide(); | 560 | tab->getTabBar()->hide(); |
561 | tab->setMargin(tab->margin()); | 561 | tab->setMargin(tab->margin()); |
562 | tabPos = tm_hidden; | 562 | tabPos = tm_hidden; |
563 | } | 563 | } |
564 | 564 | ||
565 | cm_bw = colorMenu->insertItem(tr( "Black on White")); | 565 | cm_bw = colorMenu->insertItem(tr( "Black on White")); |
566 | cm_wb = colorMenu->insertItem(tr( "White on Black")); | 566 | cm_wb = colorMenu->insertItem(tr( "White on Black")); |
567 | cm_gb = colorMenu->insertItem(tr( "Green on Black")); | 567 | cm_gb = colorMenu->insertItem(tr( "Green on Black")); |
568 | // cm_bt = colorMenu->insertItem(tr( "Black on Transparent")); | 568 | // cm_bt = colorMenu->insertItem(tr( "Black on Transparent")); |
569 | cm_br = colorMenu->insertItem(tr( "Black on Pink")); | 569 | cm_br = colorMenu->insertItem(tr( "Black on Pink")); |
570 | cm_rb = colorMenu->insertItem(tr( "Pink on Black")); | 570 | cm_rb = colorMenu->insertItem(tr( "Pink on Black")); |
571 | cm_gy = colorMenu->insertItem(tr( "Green on Yellow")); | 571 | cm_gy = colorMenu->insertItem(tr( "Green on Yellow")); |
572 | cm_bm = colorMenu->insertItem(tr( "Blue on Magenta")); | 572 | cm_bm = colorMenu->insertItem(tr( "Blue on Magenta")); |
573 | cm_mb = colorMenu->insertItem(tr( "Magenta on Blue")); | 573 | cm_mb = colorMenu->insertItem(tr( "Magenta on Blue")); |
574 | cm_cw = colorMenu->insertItem(tr( "Cyan on White")); | 574 | cm_cw = colorMenu->insertItem(tr( "Cyan on White")); |
575 | cm_wc = colorMenu->insertItem(tr( "White on Cyan")); | 575 | cm_wc = colorMenu->insertItem(tr( "White on Cyan")); |
576 | cm_bb = colorMenu->insertItem(tr( "Blue on Black")); | 576 | cm_bb = colorMenu->insertItem(tr( "Blue on Black")); |
577 | cm_ab = colorMenu->insertItem(tr( "Amber on Black")); | 577 | cm_ab = colorMenu->insertItem(tr( "Amber on Black")); |
578 | cm_default = colorMenu->insertItem(tr("default")); | 578 | cm_default = colorMenu->insertItem(tr("default")); |
579 | 579 | ||
580 | #ifdef QT_QWS_OPIE | 580 | #ifdef QT_QWS_OPIE |
581 | 581 | ||
582 | colorMenu->insertItem(tr( "Custom")); | 582 | colorMenu->insertItem(tr( "Custom")); |
583 | #endif | 583 | #endif |
584 | 584 | ||
585 | configMenu->insertItem(tr( "Colors") ,colorMenu); | 585 | configMenu->insertItem(tr( "Colors") ,colorMenu); |
586 | 586 | ||
587 | sessionList = new QPopupMenu(this); | 587 | sessionList = new QPopupMenu(this); |
588 | sessionList-> insertItem ( Resource::loadPixmap ( "konsole/Terminal" ), tr( "new session" ), this, | 588 | sessionList-> insertItem ( Resource::loadPixmap ( "konsole/Terminal" ), tr( "new session" ), this, |
589 | SLOT(newSession()) ); | 589 | SLOT(newSession()) ); |
590 | 590 | ||
591 | // connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) )); | 591 | // connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) )); |
592 | connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) )); | 592 | connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) )); |
593 | connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuIsSelected(int) )); | 593 | connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuIsSelected(int) )); |
594 | connect( tabMenu, SIGNAL( activated(int) ), this, SLOT( tabMenuSelected(int) )); | 594 | connect( tabMenu, SIGNAL( activated(int) ), this, SLOT( tabMenuSelected(int) )); |
595 | connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int))); | 595 | connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int))); |
596 | connect( editCommandListMenu,SIGNAL(activated(int)),this,SLOT(editCommandListMenuSelected(int))); | 596 | connect( editCommandListMenu,SIGNAL(activated(int)),this,SLOT(editCommandListMenuSelected(int))); |
597 | connect( sessionList, SIGNAL(activated(int)), this, SLOT( sessionListSelected(int) ) ); | 597 | connect( sessionList, SIGNAL(activated(int)), this, SLOT( sessionListSelected(int) ) ); |
598 | 598 | ||
599 | menuBar->insertItem( tr("View"), configMenu ); | 599 | menuBar->insertItem( tr("View"), configMenu ); |
600 | menuBar->insertItem( tr("Fonts"), fontList ); | 600 | menuBar->insertItem( tr("Fonts"), fontList ); |
601 | menuBar->insertItem( tr("Sessions"), sessionList ); | 601 | menuBar->insertItem( tr("Sessions"), sessionList ); |
602 | 602 | ||
603 | toolBar = new QToolBar( this ); | 603 | toolBar = new QToolBar( this ); |
604 | 604 | ||
605 | QAction *a; | 605 | QAction *a; |
606 | 606 | ||
607 | // Button Commands | 607 | // Button Commands |
608 | a = new QAction( tr("New"), Resource::loadPixmap( "konsole/Terminal" ), QString::null, 0, this, 0 ); | 608 | a = new QAction( tr("New"), Resource::loadPixmap( "konsole/konsole" ), QString::null, 0, this, 0 ); |
609 | connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); | 609 | connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); |
610 | a->addTo( toolBar ); | 610 | a->addTo( toolBar ); |
611 | 611 | ||
612 | a = new QAction( tr("Full Screen"), Resource::loadPixmap( "fullscreen" ), QString::null, 0, this, 0 ); | 612 | a = new QAction( tr("Full Screen"), Resource::loadPixmap( "fullscreen" ), QString::null, 0, this, 0 ); |
613 | connect( a, SIGNAL( activated() ), this, SLOT( toggleFullScreen() ) ); | 613 | connect( a, SIGNAL( activated() ), this, SLOT( toggleFullScreen() ) ); |
614 | a->addTo( toolBar ); | 614 | a->addTo( toolBar ); |
615 | 615 | ||
616 | a = new QAction( tr("Zoom"), Resource::loadPixmap( "zoom" ), QString::null, 0, this, 0 ); | 616 | a = new QAction( tr("Zoom"), Resource::loadPixmap( "zoom" ), QString::null, 0, this, 0 ); |
617 | connect( a, SIGNAL( activated() ), this, SLOT( cycleZoom() ) ); | 617 | connect( a, SIGNAL( activated() ), this, SLOT( cycleZoom() ) ); |
618 | a->addTo( toolBar ); | 618 | a->addTo( toolBar ); |
619 | 619 | ||
620 | 620 | ||
621 | a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 ); | 621 | a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 ); |
622 | connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolBar ); | 622 | connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolBar ); |
623 | a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 ); | 623 | a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 ); |
624 | connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolBar ); | 624 | connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolBar ); |
625 | a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 ); | 625 | a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 ); |
626 | connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolBar ); | 626 | connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolBar ); |
627 | a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 ); | 627 | a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 ); |
628 | connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolBar ); | 628 | connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolBar ); |
629 | a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 ); | 629 | a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 ); |
630 | connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolBar ); | 630 | connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolBar ); |
631 | 631 | ||
632 | a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); | 632 | a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); |
633 | connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); | 633 | connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); |
634 | a->addTo( toolBar ); | 634 | a->addTo( toolBar ); |
635 | 635 | ||
636 | secondToolBar = new QToolBar( this ); | 636 | secondToolBar = new QToolBar( this ); |
637 | secondToolBar->setHorizontalStretchable( TRUE ); | 637 | secondToolBar->setHorizontalStretchable( TRUE ); |
638 | 638 | ||
639 | commonCombo = new QComboBox( secondToolBar ); | 639 | commonCombo = new QComboBox( secondToolBar ); |
640 | // commonCombo->setMaximumWidth(236); | 640 | // commonCombo->setMaximumWidth(236); |
641 | 641 | ||
642 | ec_quick = editCommandListMenu->insertItem( tr( "Quick Edit" ) ); | 642 | ec_quick = editCommandListMenu->insertItem( tr( "Quick Edit" ) ); |
643 | if( listHidden) | 643 | if( listHidden) |
644 | { | 644 | { |
645 | secondToolBar->hide(); | 645 | secondToolBar->hide(); |
646 | editCommandListMenu->setItemEnabled(ec_quick ,FALSE); | 646 | editCommandListMenu->setItemEnabled(ec_quick ,FALSE); |
647 | } | 647 | } |
648 | ec_edit = editCommandListMenu->insertItem(tr( "Edit..." ) ); | 648 | ec_edit = editCommandListMenu->insertItem(tr( "Edit..." ) ); |
649 | 649 | ||
650 | cfg.setGroup("Commands"); | 650 | cfg.setGroup("Commands"); |
651 | commonCombo->setInsertionPolicy(QComboBox::AtCurrent); | 651 | commonCombo->setInsertionPolicy(QComboBox::AtCurrent); |
652 | 652 | ||
653 | initCommandList(); | 653 | initCommandList(); |
654 | // for (int i = 0; commonCmds[i] != NULL; i++) { | 654 | // for (int i = 0; commonCmds[i] != NULL; i++) { |
655 | // commonCombo->insertItem( commonCmds[i], i ); | 655 | // commonCombo->insertItem( commonCmds[i], i ); |
656 | // tmp = cfg.readEntry( QString::number(i),""); | 656 | // tmp = cfg.readEntry( QString::number(i),""); |
657 | // if(tmp != "") | 657 | // if(tmp != "") |
658 | // commonCombo->changeItem( tmp,i ); | 658 | // commonCombo->changeItem( tmp,i ); |
659 | // } | 659 | // } |
660 | 660 | ||
661 | connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) )); | 661 | connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) )); |
662 | 662 | ||
663 | sm_none = scrollMenu->insertItem(tr( "None" )); | 663 | sm_none = scrollMenu->insertItem(tr( "None" )); |
664 | sm_left = scrollMenu->insertItem(tr( "Left" )); | 664 | sm_left = scrollMenu->insertItem(tr( "Left" )); |
665 | sm_right = scrollMenu->insertItem(tr( "Right" )); | 665 | sm_right = scrollMenu->insertItem(tr( "Right" )); |
666 | // scrollMenu->insertSeparator(4); | 666 | // scrollMenu->insertSeparator(4); |
667 | // scrollMenu->insertItem(tr( "Horizontal" )); | 667 | // scrollMenu->insertItem(tr( "Horizontal" )); |
668 | 668 | ||
669 | configMenu->insertItem(tr( "ScrollBar" ),scrollMenu); | 669 | configMenu->insertItem(tr( "ScrollBar" ),scrollMenu); |
670 | 670 | ||
671 | configMenu->insertItem(tr( "History..." ), this, SLOT(historyDialog())); | 671 | configMenu->insertItem(tr( "History..." ), this, SLOT(historyDialog())); |
672 | 672 | ||
673 | cm_wrap = configMenu->insertItem(tr( "Wrap" )); | 673 | cm_wrap = configMenu->insertItem(tr( "Wrap" )); |
674 | cfg.setGroup("ScrollBar"); | 674 | cfg.setGroup("ScrollBar"); |
675 | configMenu->setItemChecked(cm_wrap, cfg.readBoolEntry("HorzScroll",0)); | 675 | configMenu->setItemChecked(cm_wrap, cfg.readBoolEntry("HorzScroll",0)); |
676 | 676 | ||
677 | cm_beep = configMenu->insertItem(tr( "Use Beep" )); | 677 | cm_beep = configMenu->insertItem(tr( "Use Beep" )); |
678 | cfg.setGroup("Menubar"); | 678 | cfg.setGroup("Menubar"); |
679 | configMenu->setItemChecked(cm_beep, cfg.readBoolEntry("useBeep",0)); | 679 | configMenu->setItemChecked(cm_beep, cfg.readBoolEntry("useBeep",0)); |
680 | 680 | ||
681 | fullscreen_msg = new QLabel(this); | 681 | fullscreen_msg = new QLabel(this); |
682 | fullscreen_msg-> setAlignment ( AlignCenter | SingleLine ); | 682 | fullscreen_msg-> setAlignment ( AlignCenter | SingleLine ); |
683 | fullscreen_msg-> hide(); | 683 | fullscreen_msg-> hide(); |
684 | fullscreen_msg-> setSizePolicy ( QSizePolicy ( QSizePolicy::Expanding, QSizePolicy::Expanding )); | 684 | fullscreen_msg-> setSizePolicy ( QSizePolicy ( QSizePolicy::Expanding, QSizePolicy::Expanding )); |
685 | fullscreen_msg-> setAutoResize(true); | 685 | fullscreen_msg-> setAutoResize(true); |
686 | fullscreen_msg-> setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 686 | fullscreen_msg-> setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
687 | fullscreen_msg-> setText(tr("To exit fullscreen, tap here.")); | 687 | fullscreen_msg-> setText(tr("To exit fullscreen, tap here.")); |
688 | 688 | ||
689 | fullscreen_timer = new QTimer(this); | 689 | fullscreen_timer = new QTimer(this); |
690 | connect(fullscreen_timer, SIGNAL(timeout()), | 690 | connect(fullscreen_timer, SIGNAL(timeout()), |
691 | this, SLOT(fullscreenTimeout())); | 691 | this, SLOT(fullscreenTimeout())); |
692 | show_fullscreen_msg = true; | 692 | show_fullscreen_msg = true; |
693 | 693 | ||
694 | //scrollMenuSelected(-29); | 694 | //scrollMenuSelected(-29); |
695 | // cfg.setGroup("ScrollBar"); | 695 | // cfg.setGroup("ScrollBar"); |
696 | // if(cfg.readBoolEntry("HorzScroll",0)) { | 696 | // if(cfg.readBoolEntry("HorzScroll",0)) { |
697 | // if(cfg.readNumEntry("Position",2) == 0) | 697 | // if(cfg.readNumEntry("Position",2) == 0) |
698 | // te->setScrollbarLocation(1); | 698 | // te->setScrollbarLocation(1); |
699 | // else | 699 | // else |
700 | // te->setScrollbarLocation(0); | 700 | // te->setScrollbarLocation(0); |
701 | // te->setScrollbarLocation( cfg.readNumEntry("Position",2)); | 701 | // te->setScrollbarLocation( cfg.readNumEntry("Position",2)); |
702 | // te->setWrapAt(120); | 702 | // te->setWrapAt(120); |
703 | // } | 703 | // } |
704 | // create applications ///////////////////////////////////////////////////// | 704 | // create applications ///////////////////////////////////////////////////// |
705 | setCentralWidget(tab); | 705 | setCentralWidget(tab); |
706 | 706 | ||
707 | // load keymaps //////////////////////////////////////////////////////////// | 707 | // load keymaps //////////////////////////////////////////////////////////// |
708 | KeyTrans::loadAll(); | 708 | KeyTrans::loadAll(); |
709 | for (int i = 0; i < KeyTrans::count(); i++) | 709 | for (int i = 0; i < KeyTrans::count(); i++) |
710 | { | 710 | { |
711 | KeyTrans* s = KeyTrans::find(i); | 711 | KeyTrans* s = KeyTrans::find(i); |
712 | assert( s ); | 712 | assert( s ); |
713 | } | 713 | } |
714 | 714 | ||
715 | se_pgm = _pgm; | 715 | se_pgm = _pgm; |
716 | se_args = _args; | 716 | se_args = _args; |
717 | 717 | ||
718 | cfg.setGroup("CommandLine"); | 718 | cfg.setGroup("CommandLine"); |
719 | 719 | ||
720 | if (cfg.hasKey("shell_args")) | 720 | if (cfg.hasKey("shell_args")) |
721 | { | 721 | { |
722 | QStringList se_args_list = cfg.readListEntry("shell_args",'|'); | 722 | QStringList se_args_list = cfg.readListEntry("shell_args",'|'); |
723 | for(uint i = 0; i < se_args_list.count(); i++) | 723 | for(uint i = 0; i < se_args_list.count(); i++) |
724 | { | 724 | { |
725 | se_args.prepend(se_args_list[se_args_list.count() - i - 1].latin1()); | 725 | se_args.prepend(se_args_list[se_args_list.count() - i - 1].latin1()); |
726 | } | 726 | } |
727 | } | 727 | } |
728 | else | 728 | else |
729 | { | 729 | { |
730 | se_args.prepend("--login"); | 730 | se_args.prepend("--login"); |
731 | } | 731 | } |
732 | 732 | ||
733 | se_pgm = cfg.readEntry("shell_bin", QString(se_pgm)); | 733 | se_pgm = cfg.readEntry("shell_bin", QString(se_pgm)); |
734 | 734 | ||
735 | // this is the "documentation" for those who know to look | 735 | // this is the "documentation" for those who know to look |
736 | if (! cfg.hasKey("shell_args")) | 736 | if (! cfg.hasKey("shell_args")) |
737 | { | 737 | { |
738 | cfg.writeEntry("shell_args",QStringList::fromStrList(se_args),'|'); | 738 | cfg.writeEntry("shell_args",QStringList::fromStrList(se_args),'|'); |
739 | } | 739 | } |
740 | if (! cfg.hasKey("shell_bin")) | 740 | if (! cfg.hasKey("shell_bin")) |
741 | { | 741 | { |
742 | cfg.writeEntry("shell_bin",QString(se_pgm)); | 742 | cfg.writeEntry("shell_bin",QString(se_pgm)); |
743 | } | 743 | } |
744 | 744 | ||
745 | parseCommandLine(); | 745 | parseCommandLine(); |
746 | 746 | ||
747 | // read and apply default values /////////////////////////////////////////// | 747 | // read and apply default values /////////////////////////////////////////// |
748 | resize(321, 321); // Dummy. | 748 | resize(321, 321); // Dummy. |
749 | QSize currentSize = size(); | 749 | QSize currentSize = size(); |
750 | if (currentSize != size()) | 750 | if (currentSize != size()) |
751 | defaultSize = size(); | 751 | defaultSize = size(); |
752 | 752 | ||
753 | 753 | ||
754 | /* allows us to catch cancel/escape */ | 754 | /* allows us to catch cancel/escape */ |
755 | reparent ( 0, WStyle_Customize | WStyle_NoBorder, | 755 | reparent ( 0, WStyle_Customize | WStyle_NoBorder, |
756 | QPoint ( 0, 0 )); | 756 | QPoint ( 0, 0 )); |
757 | } | 757 | } |
758 | 758 | ||
759 | void Konsole::show() | 759 | void Konsole::show() |
760 | { | 760 | { |
761 | if ( !nsessions ) | 761 | if ( !nsessions ) |
762 | { | 762 | { |
763 | newSession(); | 763 | newSession(); |
764 | } | 764 | } |
765 | QMainWindow::show(); | 765 | QMainWindow::show(); |
766 | 766 | ||
767 | } | 767 | } |
768 | 768 | ||
769 | void Konsole::initSession(const char*, QStrList &) | 769 | void Konsole::initSession(const char*, QStrList &) |
770 | { | 770 | { |
771 | QMainWindow::show(); | 771 | QMainWindow::show(); |
772 | } | 772 | } |
773 | 773 | ||
774 | Konsole::~Konsole() | 774 | Konsole::~Konsole() |
775 | { | 775 | { |
776 | while (nsessions > 0) | 776 | while (nsessions > 0) |
777 | { | 777 | { |
778 | doneSession(getTe(), 0); | 778 | doneSession(getTe(), 0); |
779 | } | 779 | } |
780 | } | 780 | } |
781 | 781 | ||
782 | void | 782 | void |
783 | Konsole::historyDialog() | 783 | Konsole::historyDialog() |
784 | { | 784 | { |
785 | QDialog *d = new QDialog ( this, "histdlg", true ); | 785 | QDialog *d = new QDialog ( this, "histdlg", true ); |
786 | // d-> setCaption ( tr( "History" )); | 786 | // d-> setCaption ( tr( "History" )); |
787 | 787 | ||
788 | QBoxLayout *lay = new QVBoxLayout ( d, 4, 4 ); | 788 | QBoxLayout *lay = new QVBoxLayout ( d, 4, 4 ); |
789 | 789 | ||
790 | QLabel *l = new QLabel ( tr( "History Lines:" ), d ); | 790 | QLabel *l = new QLabel ( tr( "History Lines:" ), d ); |
791 | lay-> addWidget ( l ); | 791 | lay-> addWidget ( l ); |
792 | 792 | ||
793 | Config cfg( "Konsole" ); | 793 | Config cfg( "Konsole" ); |
794 | cfg.setGroup("History"); | 794 | cfg.setGroup("History"); |
795 | int hist = cfg.readNumEntry("history_lines",300); | 795 | int hist = cfg.readNumEntry("history_lines",300); |
796 | int avg_line = cfg.readNumEntry("avg_line_length",60); | 796 | int avg_line = cfg.readNumEntry("avg_line_length",60); |
797 | 797 | ||
798 | QSpinBox *spin = new QSpinBox ( 1, 100000, 20, d ); | 798 | QSpinBox *spin = new QSpinBox ( 1, 100000, 20, d ); |
799 | spin-> setValue ( hist ); | 799 | spin-> setValue ( hist ); |
800 | spin-> setWrapping ( true ); | 800 | spin-> setWrapping ( true ); |
801 | spin-> setButtonSymbols ( QSpinBox::PlusMinus ); | 801 | spin-> setButtonSymbols ( QSpinBox::PlusMinus ); |
802 | lay-> addWidget ( spin ); | 802 | lay-> addWidget ( spin ); |
803 | 803 | ||
804 | if ( d-> exec ( ) == QDialog::Accepted ) | 804 | if ( d-> exec ( ) == QDialog::Accepted ) |
805 | { | 805 | { |
806 | cfg.writeEntry("history_lines", spin->value()); | 806 | cfg.writeEntry("history_lines", spin->value()); |
807 | cfg.writeEntry("avg_line_length", avg_line); | 807 | cfg.writeEntry("avg_line_length", avg_line); |
808 | if (getTe() != NULL) | 808 | if (getTe() != NULL) |
809 | { | 809 | { |
810 | getTe()->currentSession->setHistory(true); | 810 | getTe()->currentSession->setHistory(true); |
811 | } | 811 | } |
812 | } | 812 | } |
813 | 813 | ||
814 | delete d; | 814 | delete d; |
815 | } | 815 | } |
816 | 816 | ||
817 | 817 | ||
818 | void Konsole::cycleZoom() | 818 | void Konsole::cycleZoom() |
819 | { | 819 | { |
820 | TEWidget* te = getTe(); | 820 | TEWidget* te = getTe(); |
821 | QFont font = te->getVTFont(); | 821 | QFont font = te->getVTFont(); |
822 | int size = font.pointSize(); | 822 | int size = font.pointSize(); |
823 | changeFontSize(1); | 823 | changeFontSize(1); |
824 | font = te->getVTFont(); | 824 | font = te->getVTFont(); |
825 | if (font.pointSize() <= size) | 825 | if (font.pointSize() <= size) |
826 | { | 826 | { |
827 | do | 827 | do |
828 | { | 828 | { |
829 | font = te->getVTFont(); | 829 | font = te->getVTFont(); |
830 | size = font.pointSize(); | 830 | size = font.pointSize(); |
831 | changeFontSize(-1); | 831 | changeFontSize(-1); |
832 | font = te->getVTFont(); | 832 | font = te->getVTFont(); |
833 | } | 833 | } |
834 | while (font.pointSize() < size); | 834 | while (font.pointSize() < size); |
835 | } | 835 | } |
836 | } | 836 | } |
837 | 837 | ||
838 | void Konsole::changeFontSize(int delta) | 838 | void Konsole::changeFontSize(int delta) |
839 | { | 839 | { |
840 | // printf("delta font size %d\n", delta); | 840 | // printf("delta font size %d\n", delta); |
841 | TEWidget* te = getTe(); | 841 | TEWidget* te = getTe(); |
842 | QFont font = te->getVTFont(); | 842 | QFont font = te->getVTFont(); |
843 | int size = font.pointSize(); | 843 | int size = font.pointSize(); |
844 | int closest = delta > 0? 10000 : -10000; | 844 | int closest = delta > 0? 10000 : -10000; |
845 | int closest_font = -1; | 845 | int closest_font = -1; |
846 | for(uint i = 0; i < fonts.count(); i++) | 846 | for(uint i = 0; i < fonts.count(); i++) |
847 | { | 847 | { |
848 | if (fonts.at(i)->getFont() == font) | 848 | if (fonts.at(i)->getFont() == font) |
849 | { | 849 | { |
850 | if (delta > 0) | 850 | if (delta > 0) |
851 | { | 851 | { |
852 | if (i+1 < fonts.count() | 852 | if (i+1 < fonts.count() |
853 | && fonts.at(i+1)->getFamilyNum() == fonts.at(i)->getFamilyNum()) | 853 | && fonts.at(i+1)->getFamilyNum() == fonts.at(i)->getFamilyNum()) |
854 | { | 854 | { |
855 | setFont(i+1); | 855 | setFont(i+1); |
856 | printf("font %d\n", i+1); | 856 | printf("font %d\n", i+1); |
857 | return; | 857 | return; |
858 | } | 858 | } |
859 | } | 859 | } |
860 | else if (delta < 0) | 860 | else if (delta < 0) |
861 | { | 861 | { |
862 | if (i > 0 | 862 | if (i > 0 |
863 | && fonts.at(i-1)->getFamilyNum() == fonts.at(i)->getFamilyNum()) | 863 | && fonts.at(i-1)->getFamilyNum() == fonts.at(i)->getFamilyNum()) |
864 | { | 864 | { |
865 | setFont(i-1); | 865 | setFont(i-1); |
866 | printf("font %d\n", i-1); | 866 | printf("font %d\n", i-1); |
867 | return; | 867 | return; |
868 | } | 868 | } |
869 | } | 869 | } |
870 | } | 870 | } |
871 | int fsize = fonts.at(i)->getSize(); | 871 | int fsize = fonts.at(i)->getSize(); |
872 | printf("%d size=%d fsize=%d closest=%d\n", i, size, fsize, closest); | 872 | printf("%d size=%d fsize=%d closest=%d\n", i, size, fsize, closest); |
873 | if ((delta > 0 && fsize > size && fsize < closest) | 873 | if ((delta > 0 && fsize > size && fsize < closest) |
874 | || (delta < 0 && fsize < size && fsize > closest)) | 874 | || (delta < 0 && fsize < size && fsize > closest)) |
875 | { | 875 | { |
876 | closest = fsize; | 876 | closest = fsize; |
877 | closest_font = i; | 877 | closest_font = i; |
878 | } | 878 | } |
879 | } | 879 | } |
880 | if (closest_font >= 0) | 880 | if (closest_font >= 0) |
881 | { | 881 | { |
882 | printf("font closest %d (%d)\n", closest_font, closest); | 882 | printf("font closest %d (%d)\n", closest_font, closest); |
883 | setFont(closest_font); | 883 | setFont(closest_font); |
884 | } | 884 | } |
885 | } | 885 | } |
886 | 886 | ||
887 | int Konsole::findFont(const QString& name, int size, bool exactMatch) | 887 | int Konsole::findFont(const QString& name, int size, bool exactMatch) |
888 | { | 888 | { |
889 | for(uint i = 0; i < fonts.count(); i++) | 889 | for(uint i = 0; i < fonts.count(); i++) |
890 | { | 890 | { |
891 | if (fonts.at(i)->getName() == name | 891 | if (fonts.at(i)->getName() == name |
892 | && fonts.at(i)->getSize() == size) | 892 | && fonts.at(i)->getSize() == size) |
893 | { | 893 | { |
894 | return(i); | 894 | return(i); |
895 | } | 895 | } |
896 | } | 896 | } |
897 | if (exactMatch) | 897 | if (exactMatch) |
898 | { | 898 | { |
899 | return(-1); | 899 | return(-1); |
900 | } | 900 | } |
901 | for(uint i = 0; i < fonts.count(); i++) | 901 | for(uint i = 0; i < fonts.count(); i++) |
902 | { | 902 | { |
903 | if (fonts.at(i)->getSize() == size) | 903 | if (fonts.at(i)->getSize() == size) |
904 | { | 904 | { |
905 | return(i); | 905 | return(i); |
906 | } | 906 | } |
907 | } | 907 | } |
908 | return(-1); | 908 | return(-1); |
909 | } | 909 | } |
910 | 910 | ||
911 | void Konsole::setFont(int f) | 911 | void Konsole::setFont(int f) |
912 | { | 912 | { |
913 | VTFont* font = fonts.at(f); | 913 | VTFont* font = fonts.at(f); |
914 | if (font) | 914 | if (font) |
915 | { | 915 | { |
916 | TEWidget* te = getTe(); | 916 | TEWidget* te = getTe(); |
917 | if (te != 0) | 917 | if (te != 0) |
918 | { | 918 | { |
919 | te->setVTFont(font->getFont()); | 919 | te->setVTFont(font->getFont()); |
920 | } | 920 | } |
921 | cfont = f; | 921 | cfont = f; |
922 | 922 | ||
923 | int familyNum = font->getFamilyNum(); | 923 | int familyNum = font->getFamilyNum(); |
924 | int size = font->getSize(); | 924 | int size = font->getSize(); |
925 | printf("familyNum = %d size = %d count=%d\n", familyNum, size, | 925 | printf("familyNum = %d size = %d count=%d\n", familyNum, size, |
926 | fontList->count()); | 926 | fontList->count()); |
927 | for(int i = 0; i < (int)fontList->count(); i++) | 927 | for(int i = 0; i < (int)fontList->count(); i++) |
928 | { | 928 | { |
929 | fontList->setItemChecked(i + 1000, i == familyNum); | 929 | fontList->setItemChecked(i + 1000, i == familyNum); |
930 | } | 930 | } |
931 | for(int i = 0; i < (int)fonts.count(); i++) | 931 | for(int i = 0; i < (int)fonts.count(); i++) |
932 | { | 932 | { |
933 | fontList->setItemChecked(i, fonts.at(i)->getFamilyNum() == familyNum | 933 | fontList->setItemChecked(i, fonts.at(i)->getFamilyNum() == familyNum |
934 | && fonts.at(i)->getSize() == size); | 934 | && fonts.at(i)->getSize() == size); |
935 | } | 935 | } |
936 | Config cfg( "Konsole" ); | 936 | Config cfg( "Konsole" ); |
937 | cfg.setGroup("Font"); | 937 | cfg.setGroup("Font"); |
938 | QString ss = "Session"+ QString::number(tab->currentPageIndex()+1); | 938 | QString ss = "Session"+ QString::number(tab->currentPageIndex()+1); |
939 | if (tab->currentPageIndex() == 0) | 939 | if (tab->currentPageIndex() == 0) |
940 | { | 940 | { |
941 | cfg.writeEntry("FontName", fonts.at(cfont)->getFamily()); | 941 | cfg.writeEntry("FontName", fonts.at(cfont)->getFamily()); |
942 | cfg.writeEntry("FontSize", fonts.at(cfont)->getSize()); | 942 | cfg.writeEntry("FontSize", fonts.at(cfont)->getSize()); |
943 | } | 943 | } |
944 | cfg.writeEntry("FontName"+ss, fonts.at(cfont)->getFamily()); | 944 | cfg.writeEntry("FontName"+ss, fonts.at(cfont)->getFamily()); |
945 | cfg.writeEntry("FontSize"+ss, fonts.at(cfont)->getSize()); | 945 | cfg.writeEntry("FontSize"+ss, fonts.at(cfont)->getSize()); |
946 | } | 946 | } |
947 | } | 947 | } |
948 | 948 | ||
949 | #if 0 | 949 | #if 0 |
950 | void Konsole::fontChanged(int f) | 950 | void Konsole::fontChanged(int f) |
951 | { | 951 | { |
952 | VTFont* font = fonts.at(f); | 952 | VTFont* font = fonts.at(f); |
953 | if (font != 0) | 953 | if (font != 0) |
954 | { | 954 | { |
955 | for(uint i = 0; i < fonts.count(); i++) | 955 | for(uint i = 0; i < fonts.count(); i++) |
956 | { | 956 | { |
957 | fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE); | 957 | fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE); |
958 | } | 958 | } |
959 | 959 | ||
960 | cfont = f; | 960 | cfont = f; |
961 | 961 | ||
962 | TEWidget* te = getTe(); | 962 | TEWidget* te = getTe(); |
963 | if (te != 0) | 963 | if (te != 0) |
964 | { | 964 | { |
965 | te->setVTFont(font->getFont()); | 965 | te->setVTFont(font->getFont()); |
966 | } | 966 | } |
967 | } | 967 | } |
968 | } | 968 | } |
969 | #endif | 969 | #endif |
970 | 970 | ||
971 | 971 | ||
972 | void Konsole::enterCommand(int c) | 972 | void Konsole::enterCommand(int c) |
973 | { | 973 | { |
974 | TEWidget* te = getTe(); | 974 | TEWidget* te = getTe(); |
975 | if (te != 0) | 975 | if (te != 0) |
976 | { | 976 | { |
977 | if(!commonCombo->editable()) | 977 | if(!commonCombo->editable()) |
978 | { | 978 | { |
979 | QString text = commonCombo->text(c); //commonCmds[c]; | 979 | QString text = commonCombo->text(c); //commonCmds[c]; |
980 | te->emitText(text); | 980 | te->emitText(text); |
981 | } | 981 | } |
982 | else | 982 | else |
983 | { | 983 | { |
984 | changeCommand( commonCombo->text(c), c); | 984 | changeCommand( commonCombo->text(c), c); |
985 | } | 985 | } |
986 | } | 986 | } |
987 | } | 987 | } |
988 | 988 | ||
989 | void Konsole::hitEnter() | 989 | void Konsole::hitEnter() |
990 | { | 990 | { |
991 | TEWidget* te = getTe(); | 991 | TEWidget* te = getTe(); |
992 | if (te != 0) | 992 | if (te != 0) |
993 | { | 993 | { |
994 | te->emitText(QString("\r")); | 994 | te->emitText(QString("\r")); |
995 | } | 995 | } |
996 | } | 996 | } |
997 | 997 | ||
998 | void Konsole::hitSpace() | 998 | void Konsole::hitSpace() |
999 | { | 999 | { |
1000 | TEWidget* te = getTe(); | 1000 | TEWidget* te = getTe(); |
1001 | if (te != 0) | 1001 | if (te != 0) |
1002 | { | 1002 | { |
1003 | te->emitText(QString(" ")); | 1003 | te->emitText(QString(" ")); |
1004 | } | 1004 | } |
1005 | } | 1005 | } |
1006 | 1006 | ||
1007 | void Konsole::hitTab() | 1007 | void Konsole::hitTab() |
1008 | { | 1008 | { |
1009 | TEWidget* te = getTe(); | 1009 | TEWidget* te = getTe(); |
1010 | if (te != 0) | 1010 | if (te != 0) |
1011 | { | 1011 | { |
1012 | te->emitText(QString("\t")); | 1012 | te->emitText(QString("\t")); |
1013 | } | 1013 | } |
1014 | } | 1014 | } |
1015 | 1015 | ||
1016 | void Konsole::hitPaste() | 1016 | void Konsole::hitPaste() |
1017 | { | 1017 | { |
1018 | TEWidget* te = getTe(); | 1018 | TEWidget* te = getTe(); |
1019 | if (te != 0) | 1019 | if (te != 0) |
1020 | { | 1020 | { |
1021 | te->pasteClipboard(); | 1021 | te->pasteClipboard(); |
1022 | } | 1022 | } |
1023 | } | 1023 | } |
1024 | 1024 | ||
1025 | void Konsole::hitUp() | 1025 | void Konsole::hitUp() |
1026 | { | 1026 | { |
1027 | TEWidget* te = getTe(); | 1027 | TEWidget* te = getTe(); |
1028 | if (te != 0) | 1028 | if (te != 0) |
1029 | { | 1029 | { |
1030 | QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Up, 0, 0); | 1030 | QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Up, 0, 0); |
1031 | QApplication::sendEvent( te, &ke ); | 1031 | QApplication::sendEvent( te, &ke ); |
1032 | } | 1032 | } |
1033 | } | 1033 | } |
1034 | 1034 | ||
1035 | void Konsole::hitDown() | 1035 | void Konsole::hitDown() |
1036 | { | 1036 | { |
1037 | TEWidget* te = getTe(); | 1037 | TEWidget* te = getTe(); |
1038 | if (te != 0) | 1038 | if (te != 0) |
1039 | { | 1039 | { |
1040 | QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Down, 0, 0); | 1040 | QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Down, 0, 0); |
1041 | QApplication::sendEvent( te, &ke ); | 1041 | QApplication::sendEvent( te, &ke ); |
1042 | } | 1042 | } |
1043 | } | 1043 | } |
1044 | 1044 | ||
1045 | /** | 1045 | /** |
1046 | This function calculates the size of the external widget | 1046 | This function calculates the size of the external widget |
1047 | needed for the internal widget to be | 1047 | needed for the internal widget to be |
1048 | */ | 1048 | */ |
1049 | QSize Konsole::calcSize(int columns, int lines) | 1049 | QSize Konsole::calcSize(int columns, int lines) |
1050 | { | 1050 | { |
1051 | TEWidget* te = getTe(); | 1051 | TEWidget* te = getTe(); |
1052 | if (te != 0) | 1052 | if (te != 0) |
1053 | { | 1053 | { |
1054 | QSize size = te->calcSize(columns, lines); | 1054 | QSize size = te->calcSize(columns, lines); |
1055 | return size; | 1055 | return size; |
1056 | } | 1056 | } |
1057 | else | 1057 | else |
1058 | { | 1058 | { |
1059 | QSize size; | 1059 | QSize size; |
1060 | return size; | 1060 | return size; |
1061 | } | 1061 | } |
1062 | } | 1062 | } |
1063 | 1063 | ||
1064 | /** | 1064 | /** |
1065 | sets application window to a size based on columns X lines of the te | 1065 | sets application window to a size based on columns X lines of the te |
1066 | guest widget. Call with (0,0) for setting default size. | 1066 | guest widget. Call with (0,0) for setting default size. |
1067 | */ | 1067 | */ |
1068 | 1068 | ||
1069 | void Konsole::setColLin(int columns, int lines) | 1069 | void Konsole::setColLin(int columns, int lines) |
1070 | { | 1070 | { |
1071 | odebug << "konsole::setColLin:: Columns " << columns << "" << oendl; | 1071 | odebug << "konsole::setColLin:: Columns " << columns << "" << oendl; |
1072 | 1072 | ||
1073 | if ((columns==0) || (lines==0)) | 1073 | if ((columns==0) || (lines==0)) |
1074 | { | 1074 | { |
1075 | if (defaultSize.isEmpty()) // not in config file : set default value | 1075 | if (defaultSize.isEmpty()) // not in config file : set default value |
1076 | { | 1076 | { |
1077 | defaultSize = calcSize(80,24); | 1077 | defaultSize = calcSize(80,24); |
1078 | // notifySize(24,80); // set menu items (strange arg order !) | 1078 | // notifySize(24,80); // set menu items (strange arg order !) |
1079 | } | 1079 | } |
1080 | resize(defaultSize); | 1080 | resize(defaultSize); |
1081 | } | 1081 | } |
1082 | else | 1082 | else |
1083 | { | 1083 | { |
1084 | resize(calcSize(columns, lines)); | 1084 | resize(calcSize(columns, lines)); |
1085 | // notifySize(lines,columns); // set menu items (strange arg order !) | 1085 | // notifySize(lines,columns); // set menu items (strange arg order !) |
1086 | } | 1086 | } |
1087 | } | 1087 | } |
1088 | 1088 | ||
1089 | /* | 1089 | /* |
1090 | void Konsole::setFont(int fontno) | 1090 | void Konsole::setFont(int fontno) |
1091 | { | 1091 | { |
1092 | QFont f; | 1092 | QFont f; |
1093 | if (fontno == 0) | 1093 | if (fontno == 0) |
1094 | f = defaultFont = QFont( "Helvetica", 12 ); | 1094 | f = defaultFont = QFont( "Helvetica", 12 ); |
1095 | else | 1095 | else |
1096 | if (fonts[fontno][0] == '-') | 1096 | if (fonts[fontno][0] == '-') |
1097 | f.setRawName( fonts[fontno] ); | 1097 | f.setRawName( fonts[fontno] ); |
1098 | else | 1098 | else |
1099 | { | 1099 | { |
1100 | f.setFamily(fonts[fontno]); | 1100 | f.setFamily(fonts[fontno]); |
1101 | f.setRawMode( TRUE ); | 1101 | f.setRawMode( TRUE ); |
1102 | } | 1102 | } |
1103 | if ( !f.exactMatch() && fontno != 0) | 1103 | if ( !f.exactMatch() && fontno != 0) |
1104 | { | 1104 | { |
1105 | QString msg = i18n("Font `%1' not found.\nCheck README.linux.console for help.").arg(fonts[fontno]); | 1105 | QString msg = i18n("Font `%1' not found.\nCheck README.linux.console for help.").arg(fonts[fontno]); |
1106 | QMessageBox(this, msg); | 1106 | QMessageBox(this, msg); |
1107 | return; | 1107 | return; |
1108 | } | 1108 | } |
1109 | if (se) se->setFontNo(fontno); | 1109 | if (se) se->setFontNo(fontno); |
1110 | te->setVTFont(f); | 1110 | te->setVTFont(f); |
1111 | n_font = fontno; | 1111 | n_font = fontno; |
1112 | } | 1112 | } |
1113 | */ | 1113 | */ |
1114 | 1114 | ||
1115 | // --| color selection |------------------------------------------------------- | 1115 | // --| color selection |------------------------------------------------------- |
1116 | 1116 | ||
1117 | void Konsole::changeColumns(int /*columns*/) | 1117 | void Konsole::changeColumns(int /*columns*/) |
1118 | { //FIXME this seems to cause silliness when reset command is executed | 1118 | { //FIXME this seems to cause silliness when reset command is executed |
1119 | // odebug << "change columns" << oendl; | 1119 | // odebug << "change columns" << oendl; |
1120 | // TEWidget* te = getTe(); | 1120 | // TEWidget* te = getTe(); |
1121 | // if (te != 0) { | 1121 | // if (te != 0) { |
1122 | // setColLin(columns,te->Lines()); | 1122 | // setColLin(columns,te->Lines()); |
1123 | // te->update(); | 1123 | // te->update(); |
1124 | // } | 1124 | // } |
1125 | } | 1125 | } |
1126 | 1126 | ||
1127 | //FIXME: If a child dies during session swap, | 1127 | //FIXME: If a child dies during session swap, |
1128 | // this routine might be called before | 1128 | // this routine might be called before |
1129 | // session swap is completed. | 1129 | // session swap is completed. |
1130 | 1130 | ||
1131 | void Konsole::doneSession(TEWidget* te, int ) | 1131 | void Konsole::doneSession(TEWidget* te, int ) |
1132 | { | 1132 | { |
1133 | // TEWidget *te = NULL; | 1133 | // TEWidget *te = NULL; |
1134 | // if (sess->currentSession == tab->currentPage()) { | 1134 | // if (sess->currentSession == tab->currentPage()) { |
1135 | // printf("done current session\n"); | 1135 | // printf("done current session\n"); |
1136 | // te = getTe(); | 1136 | // te = getTe(); |
1137 | // } else { | 1137 | // } else { |
1138 | // int currentPage = tab->currentPageIndex(); | 1138 | // int currentPage = tab->currentPageIndex(); |
1139 | // printf("done not current session\n"); | 1139 | // printf("done not current session\n"); |
1140 | // for(int i = 0; i < nsessions; i++) { | 1140 | // for(int i = 0; i < nsessions; i++) { |
1141 | // tab->setCurrentPage(i); | 1141 | // tab->setCurrentPage(i); |
1142 | // printf("find session %d tab page %x session %x\n", | 1142 | // printf("find session %d tab page %x session %x\n", |
1143 | // i, tab->currentPage(), sess->currentSession); | 1143 | // i, tab->currentPage(), sess->currentSession); |
1144 | // if (tab->currentPage() == sess->currentSession) { | 1144 | // if (tab->currentPage() == sess->currentSession) { |
1145 | // printf("found session %d\n", i); | 1145 | // printf("found session %d\n", i); |
1146 | // te = tab->currentPage(); | 1146 | // te = tab->currentPage(); |
1147 | // break; | 1147 | // break; |
1148 | // } | 1148 | // } |
1149 | // } | 1149 | // } |
1150 | // tab->setCurrentPage(currentPage); | 1150 | // tab->setCurrentPage(currentPage); |
1151 | // } | 1151 | // } |
1152 | if (te != 0) | 1152 | if (te != 0) |
1153 | { | 1153 | { |
1154 | te->currentSession->setConnect(FALSE); | 1154 | te->currentSession->setConnect(FALSE); |
1155 | tab->removeTab(te); | 1155 | tab->removeTab(te); |
1156 | delete te->currentSession; | 1156 | delete te->currentSession; |
1157 | delete te; | 1157 | delete te; |
1158 | sessionList->removeItem(nsessions); | 1158 | sessionList->removeItem(nsessions); |
1159 | nsessions--; | 1159 | nsessions--; |
1160 | } | 1160 | } |
1161 | if (nsessions == 0) | 1161 | if (nsessions == 0) |
1162 | { | 1162 | { |
1163 | close(); | 1163 | close(); |
1164 | } | 1164 | } |
1165 | } | 1165 | } |
1166 | 1166 | ||
1167 | void Konsole::changeTitle(TEWidget* te, const QString& newTitle ) | 1167 | void Konsole::changeTitle(TEWidget* te, const QString& newTitle ) |
1168 | { | 1168 | { |
1169 | if (te == getTe()) | 1169 | if (te == getTe()) |
1170 | { | 1170 | { |
1171 | setCaption( newTitle + " - " + tr( "Konsole " ) ); | 1171 | setCaption( newTitle + " - " + tr( "Konsole " ) ); |
1172 | } | 1172 | } |
1173 | } | 1173 | } |
1174 | 1174 | ||
1175 | 1175 | ||
1176 | void Konsole::newSession() | 1176 | void Konsole::newSession() |
1177 | { | 1177 | { |
1178 | if(nsessions < 15) | 1178 | if(nsessions < 15) |
1179 | { // seems to be something weird about 16 tabs on the Zaurus.... memory? | 1179 | { // seems to be something weird about 16 tabs on the Zaurus.... memory? |
1180 | TEWidget* te = new TEWidget(tab); | 1180 | TEWidget* te = new TEWidget(tab); |
1181 | Config cfg( "Konsole" ); | 1181 | Config cfg( "Konsole" ); |
1182 | cfg.setGroup("Menubar"); | 1182 | cfg.setGroup("Menubar"); |
1183 | 1183 | ||
1184 | // FIXME use more defaults from config file | 1184 | // FIXME use more defaults from config file |
1185 | te->useBeep=cfg.readBoolEntry("useBeep",0); | 1185 | te->useBeep=cfg.readBoolEntry("useBeep",0); |
1186 | 1186 | ||
1187 | // te->setBackgroundMode(PaletteBase); //we want transparent!! | 1187 | // te->setBackgroundMode(PaletteBase); //we want transparent!! |
1188 | 1188 | ||
1189 | cfg.setGroup("Font"); | 1189 | cfg.setGroup("Font"); |
1190 | QString sn = "Session" + QString::number(nsessions+1); | 1190 | QString sn = "Session" + QString::number(nsessions+1); |
1191 | printf("read font session %s\n", sn.latin1()); | 1191 | printf("read font session %s\n", sn.latin1()); |
1192 | QString fontName = cfg.readEntry("FontName"+sn, | 1192 | QString fontName = cfg.readEntry("FontName"+sn, |
1193 | cfg.readEntry("FontName", | 1193 | cfg.readEntry("FontName", |
1194 | fonts.at(cfont)->getFamily())); | 1194 | fonts.at(cfont)->getFamily())); |
1195 | int fontSize = cfg.readNumEntry("FontSize"+sn, | 1195 | int fontSize = cfg.readNumEntry("FontSize"+sn, |
1196 | cfg.readNumEntry("FontSize", | 1196 | cfg.readNumEntry("FontSize", |
1197 | fonts.at(cfont)->getSize())); | 1197 | fonts.at(cfont)->getSize())); |
1198 | cfont = findFont(fontName, fontSize, false); | 1198 | cfont = findFont(fontName, fontSize, false); |
1199 | printf("lookup font %s size %d got %d\n", fontName.latin1(), fontSize, cfont); | 1199 | printf("lookup font %s size %d got %d\n", fontName.latin1(), fontSize, cfont); |
1200 | if (cfont < 0) | 1200 | if (cfont < 0) |
1201 | cfont = 0; | 1201 | cfont = 0; |
1202 | te->setVTFont(fonts.at(cfont)->getFont()); | 1202 | te->setVTFont(fonts.at(cfont)->getFont()); |
1203 | 1203 | ||
1204 | tab->addTab(te); | 1204 | tab->addTab(te); |
1205 | TESession* se = new TESession(this, te, se_pgm, se_args, "xterm"); | 1205 | TESession* se = new TESession(this, te, se_pgm, se_args, "xterm"); |
1206 | te->currentSession = se; | 1206 | te->currentSession = se; |
1207 | connect( se, SIGNAL(done(TEWidget*,int)), this, SLOT(doneSession(TEWidget*,int)) ); | 1207 | connect( se, SIGNAL(done(TEWidget*,int)), this, SLOT(doneSession(TEWidget*,int)) ); |
1208 | connect( se, SIGNAL(changeTitle(TEWidget*,const QString&)), this, | 1208 | connect( se, SIGNAL(changeTitle(TEWidget*,const QString&)), this, |
1209 | SLOT(changeTitle(TEWidget*,const QString&)) ); | 1209 | SLOT(changeTitle(TEWidget*,const QString&)) ); |
1210 | connect(te, SIGNAL(changeFontSize(int)), this, SLOT(changeFontSize(int))); | 1210 | connect(te, SIGNAL(changeFontSize(int)), this, SLOT(changeFontSize(int))); |
1211 | connect(te, SIGNAL(changeSession(int)), this, SLOT(changeSession(int))); | 1211 | connect(te, SIGNAL(changeSession(int)), this, SLOT(changeSession(int))); |
1212 | connect(te, SIGNAL(newSession()), this, SLOT(newSession())); | 1212 | connect(te, SIGNAL(newSession()), this, SLOT(newSession())); |
1213 | connect(te, SIGNAL(toggleFullScreen()), this, SLOT(toggleFullScreen())); | 1213 | connect(te, SIGNAL(toggleFullScreen()), this, SLOT(toggleFullScreen())); |
1214 | connect(te, SIGNAL(setFullScreen(bool)), this, SLOT(setFullScreen(bool))); | 1214 | connect(te, SIGNAL(setFullScreen(bool)), this, SLOT(setFullScreen(bool))); |
1215 | se->run(); | 1215 | se->run(); |
1216 | se->setConnect(TRUE); | 1216 | se->setConnect(TRUE); |
1217 | se->setHistory(b_scroll); | 1217 | se->setHistory(b_scroll); |
1218 | nsessions++; | 1218 | nsessions++; |
1219 | sessionList->insertItem(QString::number(nsessions), nsessions); | 1219 | sessionList->insertItem(QString::number(nsessions), nsessions); |
1220 | sessionListSelected(nsessions); | 1220 | sessionListSelected(nsessions); |
1221 | doWrap(); | 1221 | doWrap(); |
1222 | setColor(nsessions-1); | 1222 | setColor(nsessions-1); |
1223 | } | 1223 | } |
1224 | } | 1224 | } |
1225 | 1225 | ||
1226 | TEWidget* Konsole::getTe() | 1226 | TEWidget* Konsole::getTe() |
1227 | { | 1227 | { |
1228 | if (nsessions) | 1228 | if (nsessions) |
1229 | { | 1229 | { |
1230 | return (TEWidget *) tab->currentPage(); | 1230 | return (TEWidget *) tab->currentPage(); |
1231 | } | 1231 | } |
1232 | else | 1232 | else |
1233 | { | 1233 | { |
1234 | return 0; | 1234 | return 0; |
1235 | } | 1235 | } |
1236 | } | 1236 | } |
1237 | 1237 | ||
1238 | void Konsole::sessionListSelected(int id) | 1238 | void Konsole::sessionListSelected(int id) |
1239 | { | 1239 | { |
1240 | if (id < 0) | 1240 | if (id < 0) |
1241 | { | 1241 | { |
1242 | return; | 1242 | return; |
1243 | } | 1243 | } |
1244 | QString selected = sessionList->text(id); | 1244 | QString selected = sessionList->text(id); |
1245 | EKNumTabBar *tabBar = tab->getTabBar(); | 1245 | EKNumTabBar *tabBar = tab->getTabBar(); |
1246 | 1246 | ||
1247 | int n = 0; | 1247 | int n = 0; |
1248 | for(int i = 0; n < tabBar->count(); i++) | 1248 | for(int i = 0; n < tabBar->count(); i++) |
1249 | { | 1249 | { |
1250 | if (tabBar->tab(i)) | 1250 | if (tabBar->tab(i)) |
1251 | { | 1251 | { |
1252 | // printf("selected = %s tab %d = %s\n", selected.latin1(), | 1252 | // printf("selected = %s tab %d = %s\n", selected.latin1(), |
1253 | // i, tabBar->tab(i)->text().latin1()); | 1253 | // i, tabBar->tab(i)->text().latin1()); |
1254 | if (tabBar->tab(i)->text() == selected) | 1254 | if (tabBar->tab(i)->text() == selected) |
1255 | { | 1255 | { |
1256 | tab->setCurrentPage(i); | 1256 | tab->setCurrentPage(i); |
1257 | break; | 1257 | break; |
1258 | } | 1258 | } |
1259 | n++; | 1259 | n++; |
1260 | } | 1260 | } |
1261 | } | 1261 | } |
1262 | } | 1262 | } |
1263 | 1263 | ||
1264 | 1264 | ||
1265 | void Konsole::changeSession(int delta) | 1265 | void Konsole::changeSession(int delta) |
1266 | { | 1266 | { |
1267 | printf("delta session %d\n", delta); | 1267 | printf("delta session %d\n", delta); |
1268 | QTabBar *tabBar = tab->getTabBar(); | 1268 | QTabBar *tabBar = tab->getTabBar(); |
1269 | int i = tabBar->tab(tabBar->currentTab())->text().toInt() - 1; | 1269 | int i = tabBar->tab(tabBar->currentTab())->text().toInt() - 1; |
1270 | i += delta; | 1270 | i += delta; |
1271 | if (i < 0) | 1271 | if (i < 0) |
1272 | i += tabBar->count(); | 1272 | i += tabBar->count(); |
1273 | if (i >= tabBar->count()) | 1273 | if (i >= tabBar->count()) |
1274 | i -= tabBar->count(); | 1274 | i -= tabBar->count(); |
1275 | 1275 | ||
1276 | QString selected = QString::number(i+1); | 1276 | QString selected = QString::number(i+1); |
1277 | int n = 0; | 1277 | int n = 0; |
1278 | for(int i = 0; n < tabBar->count(); i++) | 1278 | for(int i = 0; n < tabBar->count(); i++) |
1279 | { | 1279 | { |
1280 | if (tabBar->tab(i)) | 1280 | if (tabBar->tab(i)) |
1281 | { | 1281 | { |
1282 | printf("selected = %s tab %d = %s\n", selected.latin1(), | 1282 | printf("selected = %s tab %d = %s\n", selected.latin1(), |
1283 | i, tabBar->tab(i)->text().latin1()); | 1283 | i, tabBar->tab(i)->text().latin1()); |
1284 | if (tabBar->tab(i)->text() == selected) | 1284 | if (tabBar->tab(i)->text() == selected) |
1285 | { | 1285 | { |
1286 | tab->setCurrentPage(i); | 1286 | tab->setCurrentPage(i); |
1287 | break; | 1287 | break; |
1288 | } | 1288 | } |
1289 | n++; | 1289 | n++; |
1290 | } | 1290 | } |
1291 | } | 1291 | } |
1292 | } | 1292 | } |
1293 | 1293 | ||
1294 | void Konsole::switchSession(QWidget* w) | 1294 | void Konsole::switchSession(QWidget* w) |
1295 | { | 1295 | { |
1296 | TEWidget* te = (TEWidget *) w; | 1296 | TEWidget* te = (TEWidget *) w; |
1297 | QFont teFnt = te->getVTFont(); | 1297 | QFont teFnt = te->getVTFont(); |
1298 | int familyNum = -1; | 1298 | int familyNum = -1; |
1299 | 1299 | ||
1300 | for(uint i = 0; i < fonts.count(); i++) | 1300 | for(uint i = 0; i < fonts.count(); i++) |
1301 | { | 1301 | { |
1302 | VTFont *fnt = fonts.at(i); | 1302 | VTFont *fnt = fonts.at(i); |
1303 | bool cf = fnt->getFont() == teFnt; | 1303 | bool cf = fnt->getFont() == teFnt; |
1304 | fontList->setItemChecked(i, cf); | 1304 | fontList->setItemChecked(i, cf); |
1305 | if (cf) | 1305 | if (cf) |
1306 | { | 1306 | { |
1307 | cfont = i; | 1307 | cfont = i; |
1308 | familyNum = fnt->getFamilyNum(); | 1308 | familyNum = fnt->getFamilyNum(); |
1309 | } | 1309 | } |
1310 | } | 1310 | } |
1311 | for(int i = 0; i < (int)fontList->count(); i++) | 1311 | for(int i = 0; i < (int)fontList->count(); i++) |
1312 | { | 1312 | { |
1313 | fontList->setItemChecked(i + 1000, i == familyNum); | 1313 | fontList->setItemChecked(i + 1000, i == familyNum); |
1314 | } | 1314 | } |
1315 | if (! te->currentSession->Title().isEmpty() ) | 1315 | if (! te->currentSession->Title().isEmpty() ) |
1316 | { | 1316 | { |
1317 | setCaption( te->currentSession->Title() + " - " + tr( "Konsole" ) ); | 1317 | setCaption( te->currentSession->Title() + " - " + tr( "Konsole" ) ); |
1318 | } | 1318 | } |
1319 | else | 1319 | else |
1320 | { | 1320 | { |
1321 | setCaption( tr( "Konsole" ) ); | 1321 | setCaption( tr( "Konsole" ) ); |
1322 | } | 1322 | } |
1323 | // colorMenuSelected(te->color_menu_item); | 1323 | // colorMenuSelected(te->color_menu_item); |
1324 | } | 1324 | } |
1325 | 1325 | ||
1326 | 1326 | ||
1327 | void Konsole::toggleFullScreen() | 1327 | void Konsole::toggleFullScreen() |
1328 | { | 1328 | { |
1329 | setFullScreen(! fullscreen); | 1329 | setFullScreen(! fullscreen); |
1330 | } | 1330 | } |
1331 | 1331 | ||
1332 | void Konsole::setFullScreen ( bool b ) | 1332 | void Konsole::setFullScreen ( bool b ) |
1333 | { | 1333 | { |
1334 | static QSize normalsize; | 1334 | static QSize normalsize; |
1335 | static bool listHidden; | 1335 | static bool listHidden; |
1336 | 1336 | ||
1337 | if (b == fullscreen) | 1337 | if (b == fullscreen) |
1338 | { | 1338 | { |
1339 | return; | 1339 | return; |
1340 | } | 1340 | } |
1341 | 1341 | ||
1342 | fullscreen = b; | 1342 | fullscreen = b; |
1343 | 1343 | ||
1344 | if ( b ) | 1344 | if ( b ) |
1345 | { | 1345 | { |
1346 | if ( !normalsize. isValid ( )) | 1346 | if ( !normalsize. isValid ( )) |
1347 | { | 1347 | { |
1348 | normalsize = size ( ); | 1348 | normalsize = size ( ); |
1349 | } | 1349 | } |
1350 | 1350 | ||
1351 | setFixedSize ( qApp-> desktop ( )-> size ( )); | 1351 | setFixedSize ( qApp-> desktop ( )-> size ( )); |
1352 | showNormal ( ); | 1352 | showNormal ( ); |
1353 | reparent ( 0, WStyle_Customize | WStyle_NoBorder, | 1353 | reparent ( 0, WStyle_Customize | WStyle_NoBorder, |
1354 | QPoint ( 0, 0 )); | 1354 | QPoint ( 0, 0 )); |
1355 | showFullScreen ( ); | 1355 | showFullScreen ( ); |
1356 | 1356 | ||
1357 | menuToolBar->hide(); | 1357 | menuToolBar->hide(); |
1358 | toolBar->hide(); | 1358 | toolBar->hide(); |
1359 | listHidden = secondToolBar->isHidden(); | 1359 | listHidden = secondToolBar->isHidden(); |
1360 | secondToolBar->hide(); | 1360 | secondToolBar->hide(); |
1361 | // commonCombo->hide(); | 1361 | // commonCombo->hide(); |
1362 | tab->getTabBar()->hide(); | 1362 | tab->getTabBar()->hide(); |
1363 | tab->setMargin(tab->margin()); | 1363 | tab->setMargin(tab->margin()); |
1364 | 1364 | ||
1365 | if (show_fullscreen_msg) | 1365 | if (show_fullscreen_msg) |
1366 | { | 1366 | { |
1367 | fullscreen_msg-> move(tab->x() + tab->width()/2 - fullscreen_msg->width()/2, | 1367 | fullscreen_msg-> move(tab->x() + tab->width()/2 - fullscreen_msg->width()/2, |
1368 | qApp->desktop()->height()/16 - fullscreen_msg->height()/2); | 1368 | qApp->desktop()->height()/16 - fullscreen_msg->height()/2); |
1369 | fullscreen_msg->show(); | 1369 | fullscreen_msg->show(); |
1370 | fullscreen_timer->start(3000, true); | 1370 | fullscreen_timer->start(3000, true); |
1371 | show_fullscreen_msg = false; | 1371 | show_fullscreen_msg = false; |
1372 | } | 1372 | } |
1373 | } | 1373 | } |
1374 | else | 1374 | else |
1375 | { | 1375 | { |
1376 | showNormal ( ); | 1376 | showNormal ( ); |
diff --git a/core/apps/embeddedkonsole/opie-embeddedkonsole.control b/core/apps/embeddedkonsole/opie-embeddedkonsole.control index a338e19..8456ff7 100644 --- a/core/apps/embeddedkonsole/opie-embeddedkonsole.control +++ b/core/apps/embeddedkonsole/opie-embeddedkonsole.control | |||
@@ -1,10 +1,10 @@ | |||
1 | Package: opie-embeddedkonsole | 1 | Package: opie-embeddedkonsole |
2 | Files: plugins/application/libembeddedkonsole.so* bin/embeddedkonsole apps/Applications/embeddedkonsole.desktop pics/konsole | 2 | Files: plugins/application/libembeddedkonsole.so* bin/embeddedkonsole apps/Applications/embeddedkonsole.desktop pics/konsole/Terminal.png pics/konsole/down.png pics/konsole/enter.png pics/konsole/konsole.png pics/konsole/space.png pics/konsole/tab.png pics/konsole/up.png |
3 | Priority: optional | 3 | Priority: optional |
4 | Section: opie/applications | 4 | Section: opie/applications |
5 | Maintainer: L.J. Potter <lpotter@trolltech.com> | 5 | Maintainer: L.J. Potter <lpotter@trolltech.com> |
6 | Architecture: arm | 6 | Architecture: arm |
7 | Depends: task-opie-minimal, libopiecore2, libqtaux2, opie-keytabs | 7 | Depends: task-opie-minimal, libopiecore2, libqtaux2, opie-keytabs |
8 | Description: KDE's konsole (shell terminal) | 8 | Description: KDE's konsole (shell terminal) |
9 | Ported to the Opie environment. | 9 | Ported to the Opie environment. |
10 | Version: $QPE_VERSION$EXTRAVERSION | 10 | Version: $QPE_VERSION$EXTRAVERSION |