author | llornkcor <llornkcor> | 2002-12-01 17:59:12 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-12-01 17:59:12 (UTC) |
commit | 90e100450625fc121523e67413b2da7f57f6d650 (patch) (unidiff) | |
tree | 2ba6428b734cc7374ea1b64d900252aecdce30c3 | |
parent | bd476ac2563bee270f79c8db995b8e1e08eec77f (diff) | |
download | opie-90e100450625fc121523e67413b2da7f57f6d650.zip opie-90e100450625fc121523e67413b2da7f57f6d650.tar.gz opie-90e100450625fc121523e67413b2da7f57f6d650.tar.bz2 |
whoops
-rw-r--r-- | core/apps/embeddedkonsole/konsole.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/core/apps/embeddedkonsole/konsole.cpp b/core/apps/embeddedkonsole/konsole.cpp index 8ca55fe..70acc42 100644 --- a/core/apps/embeddedkonsole/konsole.cpp +++ b/core/apps/embeddedkonsole/konsole.cpp | |||
@@ -1,278 +1,278 @@ | |||
1 | /* ---------------------------------------------------------------------- */ | 1 | /* ---------------------------------------------------------------------- */ |
2 | /* */ | 2 | /* */ |
3 | /* [main.C] Konsole */ | 3 | /* [main.C] Konsole */ |
4 | /* */ | 4 | /* */ |
5 | /* ---------------------------------------------------------------------- */ | 5 | /* ---------------------------------------------------------------------- */ |
6 | /* */ | 6 | /* */ |
7 | /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ | 7 | /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ |
8 | /* */ | 8 | /* */ |
9 | /* This file is part of Konsole, an X terminal. */ | 9 | /* This file is part of Konsole, an X terminal. */ |
10 | /* */ | 10 | /* */ |
11 | /* The material contained in here more or less directly orginates from */ | 11 | /* The material contained in here more or less directly orginates from */ |
12 | /* kvt, which is copyright (c) 1996 by Matthias Ettrich <ettrich@kde.org> */ | 12 | /* kvt, which is copyright (c) 1996 by Matthias Ettrich <ettrich@kde.org> */ |
13 | /* */ | 13 | /* */ |
14 | /* ---------------------------------------------------------------------- */ | 14 | /* ---------------------------------------------------------------------- */ |
15 | /* */ | 15 | /* */ |
16 | /* Ported Konsole to Qt/Embedded */ | 16 | /* Ported Konsole to Qt/Embedded */ |
17 | /* */ | 17 | /* */ |
18 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ | 18 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ |
19 | /* */ | 19 | /* */ |
20 | /* -------------------------------------------------------------------------- */ | 20 | /* -------------------------------------------------------------------------- */ |
21 | // enhancements added by L.J. Potter <ljp@llornkcor.com> | 21 | // enhancements added by L.J. Potter <ljp@llornkcor.com> |
22 | //#define QT_QWS_OPIE | 22 | #define QT_QWS_OPIE |
23 | 23 | ||
24 | #include <qpe/resource.h> | 24 | #include <qpe/resource.h> |
25 | 25 | ||
26 | #include <qdir.h> | 26 | #include <qdir.h> |
27 | #include <qevent.h> | 27 | #include <qevent.h> |
28 | #include <qdragobject.h> | 28 | #include <qdragobject.h> |
29 | #include <qobjectlist.h> | 29 | #include <qobjectlist.h> |
30 | #include <qtoolbutton.h> | 30 | #include <qtoolbutton.h> |
31 | #include <qpe/qpetoolbar.h> | 31 | #include <qpe/qpetoolbar.h> |
32 | #include <qpushbutton.h> | 32 | #include <qpushbutton.h> |
33 | #include <qfontdialog.h> | 33 | #include <qfontdialog.h> |
34 | #include <qglobal.h> | 34 | #include <qglobal.h> |
35 | #include <qpainter.h> | 35 | #include <qpainter.h> |
36 | #include <qpe/qpemenubar.h> | 36 | #include <qpe/qpemenubar.h> |
37 | #include <qmessagebox.h> | 37 | #include <qmessagebox.h> |
38 | #include <qaction.h> | 38 | #include <qaction.h> |
39 | #include <qapplication.h> | 39 | #include <qapplication.h> |
40 | #include <qfontmetrics.h> | 40 | #include <qfontmetrics.h> |
41 | #include <qcombobox.h> | 41 | #include <qcombobox.h> |
42 | #include <qevent.h> | 42 | #include <qevent.h> |
43 | #include <qtabwidget.h> | 43 | #include <qtabwidget.h> |
44 | #include <qtabbar.h> | 44 | #include <qtabbar.h> |
45 | #include <qpe/config.h> | 45 | #include <qpe/config.h> |
46 | #include <qstringlist.h> | 46 | #include <qstringlist.h> |
47 | #include <qpalette.h> | 47 | #include <qpalette.h> |
48 | 48 | ||
49 | #include <sys/wait.h> | 49 | #include <sys/wait.h> |
50 | #include <stdio.h> | 50 | #include <stdio.h> |
51 | #include <stdlib.h> | 51 | #include <stdlib.h> |
52 | #include <assert.h> | 52 | #include <assert.h> |
53 | 53 | ||
54 | #include "konsole.h" | 54 | #include "konsole.h" |
55 | #include "keytrans.h" | 55 | #include "keytrans.h" |
56 | #include "commandeditdialog.h" | 56 | #include "commandeditdialog.h" |
57 | 57 | ||
58 | #ifdef QT_QWS_OPIE | 58 | #ifdef QT_QWS_OPIE |
59 | #include <opie/colorpopupmenu.h> | 59 | #include <opie/colorpopupmenu.h> |
60 | #endif | 60 | #endif |
61 | 61 | ||
62 | class EKNumTabBar : public QTabBar { | 62 | class EKNumTabBar : public QTabBar { |
63 | public: | 63 | public: |
64 | void numberTabs() | 64 | void numberTabs() |
65 | { | 65 | { |
66 | // Yes, it really is this messy. QTabWidget needs functions | 66 | // Yes, it really is this messy. QTabWidget needs functions |
67 | // that provide acces to tabs in a sequential way. | 67 | // that provide acces to tabs in a sequential way. |
68 | int m=INT_MIN; | 68 | int m=INT_MIN; |
69 | for (int i=0; i<count(); i++) { | 69 | for (int i=0; i<count(); i++) { |
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 | int tx = t->rect().x(); | 74 | int tx = t->rect().x(); |
75 | if ( tx<x && tx>m ) { | 75 | if ( tx<x && tx>m ) { |
76 | x = tx; | 76 | x = tx; |
77 | left = t; | 77 | left = t; |
78 | } | 78 | } |
79 | } | 79 | } |
80 | if ( left ) { | 80 | if ( left ) { |
81 | left->setText(QString::number(i+1)); | 81 | left->setText(QString::number(i+1)); |
82 | m = left->rect().x(); | 82 | m = left->rect().x(); |
83 | } | 83 | } |
84 | } | 84 | } |
85 | } | 85 | } |
86 | }; | 86 | }; |
87 | 87 | ||
88 | class EKNumTabWidget : public QTabWidget { | 88 | class EKNumTabWidget : public QTabWidget { |
89 | public: | 89 | public: |
90 | EKNumTabWidget(QWidget* parent) : QTabWidget(parent) | 90 | EKNumTabWidget(QWidget* parent) : QTabWidget(parent) |
91 | { | 91 | { |
92 | } | 92 | } |
93 | 93 | ||
94 | void addTab(QWidget* w) | 94 | void addTab(QWidget* w) |
95 | { | 95 | { |
96 | QTab* t = new QTab(QString::number(tabBar()->count()+1)); | 96 | QTab* t = new QTab(QString::number(tabBar()->count()+1)); |
97 | QTabWidget::addTab(w,t); | 97 | QTabWidget::addTab(w,t); |
98 | } | 98 | } |
99 | 99 | ||
100 | void removeTab(QWidget* w) | 100 | void removeTab(QWidget* w) |
101 | { | 101 | { |
102 | removePage(w); | 102 | removePage(w); |
103 | ((EKNumTabBar*)tabBar())->numberTabs(); | 103 | ((EKNumTabBar*)tabBar())->numberTabs(); |
104 | } | 104 | } |
105 | }; | 105 | }; |
106 | 106 | ||
107 | // This could be configurable or dynamicly generated from the bash history | 107 | // This could be configurable or dynamicly generated from the bash history |
108 | // file of the user | 108 | // file of the user |
109 | static const char *commonCmds[] = | 109 | static const char *commonCmds[] = |
110 | { | 110 | { |
111 | "ls ", // I left this here, cause it looks better than the first alpha | 111 | "ls ", // I left this here, cause it looks better than the first alpha |
112 | "cardctl eject", | 112 | "cardctl eject", |
113 | "cat ", | 113 | "cat ", |
114 | "cd ", | 114 | "cd ", |
115 | "chmod ", | 115 | "chmod ", |
116 | "clear", | 116 | "clear", |
117 | "cp ", | 117 | "cp ", |
118 | "dc ", | 118 | "dc ", |
119 | "df ", | 119 | "df ", |
120 | "dmesg", | 120 | "dmesg", |
121 | "echo ", | 121 | "echo ", |
122 | "env", | 122 | "env", |
123 | "find ", | 123 | "find ", |
124 | "free", | 124 | "free", |
125 | "grep ", | 125 | "grep ", |
126 | "ifconfig ", | 126 | "ifconfig ", |
127 | "ipkg ", | 127 | "ipkg ", |
128 | "mkdir ", | 128 | "mkdir ", |
129 | "mv ", | 129 | "mv ", |
130 | "nc localhost 7776", | 130 | "nc localhost 7776", |
131 | "nc localhost 7777", | 131 | "nc localhost 7777", |
132 | "netstat ", | 132 | "netstat ", |
133 | "nslookup ", | 133 | "nslookup ", |
134 | "ping ", | 134 | "ping ", |
135 | "ps aux", | 135 | "ps aux", |
136 | "pwd ", | 136 | "pwd ", |
137 | "qcop QPE/System 'linkChanged(QString)' ''", | 137 | "qcop QPE/System 'linkChanged(QString)' ''", |
138 | "qcop QPE/System 'restart()'", | 138 | "qcop QPE/System 'restart()'", |
139 | "qcop QPE/System 'quit()'", | 139 | "qcop QPE/System 'quit()'", |
140 | "rm ", | 140 | "rm ", |
141 | "rmdir ", | 141 | "rmdir ", |
142 | "route ", | 142 | "route ", |
143 | "set ", | 143 | "set ", |
144 | "traceroute", | 144 | "traceroute", |
145 | 145 | ||
146 | /* | 146 | /* |
147 | "gzip", | 147 | "gzip", |
148 | "gunzip", | 148 | "gunzip", |
149 | "chgrp", | 149 | "chgrp", |
150 | "chown", | 150 | "chown", |
151 | "date", | 151 | "date", |
152 | "dd", | 152 | "dd", |
153 | "df", | 153 | "df", |
154 | "dmesg", | 154 | "dmesg", |
155 | "fuser", | 155 | "fuser", |
156 | "hostname", | 156 | "hostname", |
157 | "kill", | 157 | "kill", |
158 | "killall", | 158 | "killall", |
159 | "ln", | 159 | "ln", |
160 | "ping", | 160 | "ping", |
161 | "mount", | 161 | "mount", |
162 | "more", | 162 | "more", |
163 | "sort", | 163 | "sort", |
164 | "touch", | 164 | "touch", |
165 | "umount", | 165 | "umount", |
166 | "mknod", | 166 | "mknod", |
167 | "netstat", | 167 | "netstat", |
168 | */ | 168 | */ |
169 | 169 | ||
170 | "exit", | 170 | "exit", |
171 | NULL | 171 | NULL |
172 | }; | 172 | }; |
173 | 173 | ||
174 | 174 | ||
175 | Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) : | 175 | Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) : |
176 | QMainWindow(parent, name, fl) | 176 | QMainWindow(parent, name, fl) |
177 | { | 177 | { |
178 | QStrList args; | 178 | QStrList args; |
179 | init("/bin/sh",args); | 179 | init("/bin/sh",args); |
180 | } | 180 | } |
181 | 181 | ||
182 | Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int) | 182 | Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int) |
183 | : QMainWindow(0, name) | 183 | : QMainWindow(0, name) |
184 | { | 184 | { |
185 | init(_pgm,_args); | 185 | init(_pgm,_args); |
186 | } | 186 | } |
187 | 187 | ||
188 | void Konsole::initCommandList() | 188 | void Konsole::initCommandList() |
189 | { | 189 | { |
190 | // qDebug("Konsole::initCommandList"); | 190 | // qDebug("Konsole::initCommandList"); |
191 | Config cfg("Konsole"); | 191 | Config cfg("Konsole"); |
192 | cfg.setGroup("Commands"); | 192 | cfg.setGroup("Commands"); |
193 | commonCombo->setInsertionPolicy(QComboBox::AtCurrent); | 193 | commonCombo->setInsertionPolicy(QComboBox::AtCurrent); |
194 | commonCombo->clear(); | 194 | commonCombo->clear(); |
195 | if (cfg.readEntry("Commands Set","FALSE") == "FALSE") { | 195 | if (cfg.readEntry("Commands Set","FALSE") == "FALSE") { |
196 | for (int i = 0; commonCmds[i] != NULL; i++) { | 196 | for (int i = 0; commonCmds[i] != NULL; i++) { |
197 | commonCombo->insertItem(commonCmds[i],i); | 197 | commonCombo->insertItem(commonCmds[i],i); |
198 | } | 198 | } |
199 | } else { | 199 | } else { |
200 | for (int i = 0; i < 100; i++) { | 200 | for (int i = 0; i < 100; i++) { |
201 | if (!(cfg.readEntry( QString::number(i),"")).isEmpty()) | 201 | if (!(cfg.readEntry( QString::number(i),"")).isEmpty()) |
202 | commonCombo->insertItem((cfg.readEntry( QString::number(i),""))); | 202 | commonCombo->insertItem((cfg.readEntry( QString::number(i),""))); |
203 | } | 203 | } |
204 | } | 204 | } |
205 | 205 | ||
206 | } | 206 | } |
207 | 207 | ||
208 | void Konsole::init(const char* _pgm, QStrList & _args) | 208 | void Konsole::init(const char* _pgm, QStrList & _args) |
209 | { | 209 | { |
210 | b_scroll = TRUE; // histon; | 210 | b_scroll = TRUE; // histon; |
211 | n_keytab = 0; | 211 | n_keytab = 0; |
212 | n_render = 0; | 212 | n_render = 0; |
213 | startUp=0; | 213 | startUp=0; |
214 | fromMenu = FALSE; | 214 | fromMenu = FALSE; |
215 | 215 | ||
216 | setCaption( tr("Terminal") ); | 216 | setCaption( tr("Terminal") ); |
217 | setIcon( Resource::loadPixmap( "konsole" ) ); | 217 | setIcon( Resource::loadPixmap( "konsole" ) ); |
218 | 218 | ||
219 | Config cfg("Konsole"); | 219 | Config cfg("Konsole"); |
220 | cfg.setGroup("Konsole"); | 220 | cfg.setGroup("Konsole"); |
221 | QString tmp; | 221 | QString tmp; |
222 | // initialize the list of allowed fonts /////////////////////////////////// | 222 | // initialize the list of allowed fonts /////////////////////////////////// |
223 | cfont = cfg.readNumEntry("FontID", 1); | 223 | cfont = cfg.readNumEntry("FontID", 1); |
224 | QFont f = QFont("Micro", 4, QFont::Normal); | 224 | QFont f = QFont("Micro", 4, QFont::Normal); |
225 | f.setFixedPitch(TRUE); | 225 | f.setFixedPitch(TRUE); |
226 | fonts.append(new VTFont(tr("Micro"), f)); | 226 | fonts.append(new VTFont(tr("Micro"), f)); |
227 | 227 | ||
228 | f = QFont("Fixed", 7, QFont::Normal); | 228 | f = QFont("Fixed", 7, QFont::Normal); |
229 | f.setFixedPitch(TRUE); | 229 | f.setFixedPitch(TRUE); |
230 | fonts.append(new VTFont(tr("Small Fixed"), f)); | 230 | fonts.append(new VTFont(tr("Small Fixed"), f)); |
231 | 231 | ||
232 | f = QFont("Fixed", 12, QFont::Normal); | 232 | f = QFont("Fixed", 12, QFont::Normal); |
233 | f.setFixedPitch(TRUE); | 233 | f.setFixedPitch(TRUE); |
234 | fonts.append(new VTFont(tr("Medium Fixed"), f)); | 234 | fonts.append(new VTFont(tr("Medium Fixed"), f)); |
235 | 235 | ||
236 | // create terminal emulation framework //////////////////////////////////// | 236 | // create terminal emulation framework //////////////////////////////////// |
237 | nsessions = 0; | 237 | nsessions = 0; |
238 | 238 | ||
239 | tab = new EKNumTabWidget(this); | 239 | tab = new EKNumTabWidget(this); |
240 | 240 | ||
241 | connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*))); | 241 | connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*))); |
242 | 242 | ||
243 | // create terminal toolbar //////////////////////////////////////////////// | 243 | // create terminal toolbar //////////////////////////////////////////////// |
244 | setToolBarsMovable( FALSE ); | 244 | setToolBarsMovable( FALSE ); |
245 | QPEToolBar *menuToolBar = new QPEToolBar( this ); | 245 | QPEToolBar *menuToolBar = new QPEToolBar( this ); |
246 | menuToolBar->setHorizontalStretchable( TRUE ); | 246 | menuToolBar->setHorizontalStretchable( TRUE ); |
247 | 247 | ||
248 | QPEMenuBar *menuBar = new QPEMenuBar( menuToolBar ); | 248 | QPEMenuBar *menuBar = new QPEMenuBar( menuToolBar ); |
249 | 249 | ||
250 | fontList = new QPopupMenu( this ); | 250 | fontList = new QPopupMenu( this ); |
251 | for(uint i = 0; i < fonts.count(); i++) { | 251 | for(uint i = 0; i < fonts.count(); i++) { |
252 | VTFont *fnt = fonts.at(i); | 252 | VTFont *fnt = fonts.at(i); |
253 | fontList->insertItem(fnt->getName(), i); | 253 | fontList->insertItem(fnt->getName(), i); |
254 | } | 254 | } |
255 | fontChanged(cfont); | 255 | fontChanged(cfont); |
256 | 256 | ||
257 | configMenu = new QPopupMenu( this); | 257 | configMenu = new QPopupMenu( this); |
258 | colorMenu = new QPopupMenu( this); | 258 | colorMenu = new QPopupMenu( this); |
259 | scrollMenu = new QPopupMenu( this); | 259 | scrollMenu = new QPopupMenu( this); |
260 | editCommandListMenu = new QPopupMenu( this); | 260 | editCommandListMenu = new QPopupMenu( this); |
261 | 261 | ||
262 | configMenu->insertItem(tr("Command List"), editCommandListMenu); | 262 | configMenu->insertItem(tr("Command List"), editCommandListMenu); |
263 | 263 | ||
264 | bool listHidden; | 264 | bool listHidden; |
265 | cfg.setGroup("Menubar"); | 265 | cfg.setGroup("Menubar"); |
266 | if( cfg.readEntry("Hidden","FALSE") == "TRUE") { | 266 | if( cfg.readEntry("Hidden","FALSE") == "TRUE") { |
267 | editCommandListMenu->insertItem( tr( "Show command list" )); | 267 | editCommandListMenu->insertItem( tr( "Show command list" )); |
268 | listHidden=TRUE; | 268 | listHidden=TRUE; |
269 | } else { | 269 | } else { |
270 | editCommandListMenu->insertItem( tr( "Hide command list" )); | 270 | editCommandListMenu->insertItem( tr( "Hide command list" )); |
271 | listHidden=FALSE; | 271 | listHidden=FALSE; |
272 | } | 272 | } |
273 | 273 | ||
274 | cfg.setGroup("Tabs"); | 274 | cfg.setGroup("Tabs"); |
275 | tmp=cfg.readEntry("Position","Bottom"); | 275 | tmp=cfg.readEntry("Position","Bottom"); |
276 | if(tmp=="Top") { | 276 | if(tmp=="Top") { |
277 | tab->setTabPosition(QTabWidget::Top); | 277 | tab->setTabPosition(QTabWidget::Top); |
278 | configMenu->insertItem( tr( "Tabs on Bottom" ) ); | 278 | configMenu->insertItem( tr( "Tabs on Bottom" ) ); |