-rw-r--r-- | core/apps/embeddedkonsole/konsole.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/core/apps/embeddedkonsole/konsole.cpp b/core/apps/embeddedkonsole/konsole.cpp index 1016885..d54fa1f 100644 --- a/core/apps/embeddedkonsole/konsole.cpp +++ b/core/apps/embeddedkonsole/konsole.cpp | |||
@@ -1,252 +1,253 @@ | |||
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 | 21 | ||
22 | #include <qpe/resource.h> | 22 | #include <qpe/resource.h> |
23 | 23 | ||
24 | #include <qdir.h> | 24 | #include <qdir.h> |
25 | #include <qevent.h> | 25 | #include <qevent.h> |
26 | #include <qdragobject.h> | 26 | #include <qdragobject.h> |
27 | #include <qobjectlist.h> | 27 | #include <qobjectlist.h> |
28 | #include <qtoolbutton.h> | 28 | #include <qtoolbutton.h> |
29 | #include <qpe/qpetoolbar.h> | 29 | #include <qpe/qpetoolbar.h> |
30 | #include <qpushbutton.h> | 30 | #include <qpushbutton.h> |
31 | #include <qfontdialog.h> | 31 | #include <qfontdialog.h> |
32 | #include <qglobal.h> | 32 | #include <qglobal.h> |
33 | #include <qpainter.h> | 33 | #include <qpainter.h> |
34 | #include <qpe/qpemenubar.h> | 34 | #include <qpe/qpemenubar.h> |
35 | #include <qmessagebox.h> | 35 | #include <qmessagebox.h> |
36 | #include <qaction.h> | 36 | #include <qaction.h> |
37 | #include <qapplication.h> | 37 | #include <qapplication.h> |
38 | #include <qfontmetrics.h> | 38 | #include <qfontmetrics.h> |
39 | #include <qcombobox.h> | 39 | #include <qcombobox.h> |
40 | #include <qevent.h> | 40 | #include <qevent.h> |
41 | #include <qtabwidget.h> | 41 | #include <qtabwidget.h> |
42 | #include <qtabbar.h> | 42 | #include <qtabbar.h> |
43 | #include <qpe/config.h> | 43 | #include <qpe/config.h> |
44 | #include <qstringlist.h> | 44 | #include <qstringlist.h> |
45 | #include <qpalette.h> | 45 | #include <qpalette.h> |
46 | 46 | ||
47 | #include <sys/wait.h> | 47 | #include <sys/wait.h> |
48 | #include <stdio.h> | 48 | #include <stdio.h> |
49 | #include <stdlib.h> | 49 | #include <stdlib.h> |
50 | #include <assert.h> | 50 | #include <assert.h> |
51 | 51 | ||
52 | #include "konsole.h" | 52 | #include "konsole.h" |
53 | #include "keytrans.h" | 53 | #include "keytrans.h" |
54 | 54 | ||
55 | class EKNumTabBar : public QTabBar { | 55 | class EKNumTabBar : public QTabBar { |
56 | public: | 56 | public: |
57 | void numberTabs() | 57 | void numberTabs() |
58 | { | 58 | { |
59 | // Yes, it really is this messy. QTabWidget needs functions | 59 | // Yes, it really is this messy. QTabWidget needs functions |
60 | // that provide acces to tabs in a sequential way. | 60 | // that provide acces to tabs in a sequential way. |
61 | int m=INT_MIN; | 61 | int m=INT_MIN; |
62 | for (int i=0; i<count(); i++) { | 62 | for (int i=0; i<count(); i++) { |
63 | QTab* left=0; | 63 | QTab* left=0; |
64 | QListIterator<QTab> it(*tabList()); | 64 | QListIterator<QTab> it(*tabList()); |
65 | int x=INT_MAX; | 65 | int x=INT_MAX; |
66 | for( QTab* t; (t=it.current()); ++it ) { | 66 | for( QTab* t; (t=it.current()); ++it ) { |
67 | int tx = t->rect().x(); | 67 | int tx = t->rect().x(); |
68 | if ( tx<x && tx>m ) { | 68 | if ( tx<x && tx>m ) { |
69 | x = tx; | 69 | x = tx; |
70 | left = t; | 70 | left = t; |
71 | } | 71 | } |
72 | } | 72 | } |
73 | if ( left ) { | 73 | if ( left ) { |
74 | left->setText(QString::number(i+1)); | 74 | left->setText(QString::number(i+1)); |
75 | m = left->rect().x(); | 75 | m = left->rect().x(); |
76 | } | 76 | } |
77 | } | 77 | } |
78 | } | 78 | } |
79 | }; | 79 | }; |
80 | 80 | ||
81 | class EKNumTabWidget : public QTabWidget { | 81 | class EKNumTabWidget : public QTabWidget { |
82 | public: | 82 | public: |
83 | EKNumTabWidget(QWidget* parent) : QTabWidget(parent) | 83 | EKNumTabWidget(QWidget* parent) : QTabWidget(parent) |
84 | { | 84 | { |
85 | } | 85 | } |
86 | 86 | ||
87 | void addTab(QWidget* w) | 87 | void addTab(QWidget* w) |
88 | { | 88 | { |
89 | QTab* t = new QTab(QString::number(tabBar()->count()+1)); | 89 | QTab* t = new QTab(QString::number(tabBar()->count()+1)); |
90 | QTabWidget::addTab(w,t); | 90 | QTabWidget::addTab(w,t); |
91 | } | 91 | } |
92 | 92 | ||
93 | void removeTab(QWidget* w) | 93 | void removeTab(QWidget* w) |
94 | { | 94 | { |
95 | removePage(w); | 95 | removePage(w); |
96 | ((EKNumTabBar*)tabBar())->numberTabs(); | 96 | ((EKNumTabBar*)tabBar())->numberTabs(); |
97 | } | 97 | } |
98 | }; | 98 | }; |
99 | 99 | ||
100 | // This could be configurable or dynamicly generated from the bash history | 100 | // This could be configurable or dynamicly generated from the bash history |
101 | // file of the user | 101 | // file of the user |
102 | static const char *commonCmds[] = | 102 | static const char *commonCmds[] = |
103 | { | 103 | { |
104 | "ls ", // I left this here, cause it looks better than the first alpha | 104 | "ls ", // I left this here, cause it looks better than the first alpha |
105 | "cardctl eject", | 105 | "cardctl eject", |
106 | "cat ", | 106 | "cat ", |
107 | "cd ", | 107 | "cd ", |
108 | "chmod ", | 108 | "chmod ", |
109 | "clear", | 109 | "clear", |
110 | "cp ", | 110 | "cp ", |
111 | "dc ", | 111 | "dc ", |
112 | "df ", | 112 | "df ", |
113 | "dmesg", | 113 | "dmesg", |
114 | "echo ", | 114 | "echo ", |
115 | "env", | 115 | "env", |
116 | "find ", | 116 | "find ", |
117 | "free", | 117 | "free", |
118 | "grep ", | 118 | "grep ", |
119 | "ifconfig ", | 119 | "ifconfig ", |
120 | "ipkg ", | 120 | "ipkg ", |
121 | "mkdir ", | 121 | "mkdir ", |
122 | "mv ", | 122 | "mv ", |
123 | "nc localhost 7776", | 123 | "nc localhost 7776", |
124 | "nc localhost 7777", | 124 | "nc localhost 7777", |
125 | "netstat ", | ||
125 | "nslookup ", | 126 | "nslookup ", |
126 | "ping ", | 127 | "ping ", |
127 | "ps aux", | 128 | "ps aux", |
128 | "pwd ", | 129 | "pwd ", |
129 | "rm ", | 130 | "rm ", |
130 | "rmdir ", | 131 | "rmdir ", |
131 | "route ", | 132 | "route ", |
132 | "set ", | 133 | "set ", |
133 | "traceroute", | 134 | "traceroute", |
134 | 135 | ||
135 | /* | 136 | /* |
136 | "gzip", | 137 | "gzip", |
137 | "gunzip", | 138 | "gunzip", |
138 | "chgrp", | 139 | "chgrp", |
139 | "chown", | 140 | "chown", |
140 | "date", | 141 | "date", |
141 | "dd", | 142 | "dd", |
142 | "df", | 143 | "df", |
143 | "dmesg", | 144 | "dmesg", |
144 | "fuser", | 145 | "fuser", |
145 | "hostname", | 146 | "hostname", |
146 | "kill", | 147 | "kill", |
147 | "killall", | 148 | "killall", |
148 | "ln", | 149 | "ln", |
149 | "ping", | 150 | "ping", |
150 | "mount", | 151 | "mount", |
151 | "more", | 152 | "more", |
152 | "sort", | 153 | "sort", |
153 | "touch", | 154 | "touch", |
154 | "umount", | 155 | "umount", |
155 | "mknod", | 156 | "mknod", |
156 | "netstat", | 157 | "netstat", |
157 | */ | 158 | */ |
158 | 159 | ||
159 | "exit", | 160 | "exit", |
160 | NULL | 161 | NULL |
161 | }; | 162 | }; |
162 | 163 | ||
163 | 164 | ||
164 | Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) : | 165 | Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) : |
165 | QMainWindow(parent, name, fl) | 166 | QMainWindow(parent, name, fl) |
166 | { | 167 | { |
167 | QStrList args; | 168 | QStrList args; |
168 | init("/bin/sh",args); | 169 | init("/bin/sh",args); |
169 | } | 170 | } |
170 | 171 | ||
171 | Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int) | 172 | Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int) |
172 | : QMainWindow(0, name) | 173 | : QMainWindow(0, name) |
173 | { | 174 | { |
174 | init(_pgm,_args); | 175 | init(_pgm,_args); |
175 | } | 176 | } |
176 | 177 | ||
177 | void Konsole::init(const char* _pgm, QStrList & _args) | 178 | void Konsole::init(const char* _pgm, QStrList & _args) |
178 | { | 179 | { |
179 | b_scroll = TRUE; // histon; | 180 | b_scroll = TRUE; // histon; |
180 | n_keytab = 0; | 181 | n_keytab = 0; |
181 | n_render = 0; | 182 | n_render = 0; |
182 | 183 | ||
183 | setCaption( tr("Terminal") ); | 184 | setCaption( tr("Terminal") ); |
184 | setIcon( Resource::loadPixmap( "konsole" ) ); | 185 | setIcon( Resource::loadPixmap( "konsole" ) ); |
185 | 186 | ||
186 | Config cfg("Konsole"); | 187 | Config cfg("Konsole"); |
187 | cfg.setGroup("Konsole"); | 188 | cfg.setGroup("Konsole"); |
188 | QString tmp; | 189 | QString tmp; |
189 | // initialize the list of allowed fonts /////////////////////////////////// | 190 | // initialize the list of allowed fonts /////////////////////////////////// |
190 | cfont = cfg.readNumEntry("FontID", 1); | 191 | cfont = cfg.readNumEntry("FontID", 1); |
191 | QFont f = QFont("Micro", 4, QFont::Normal); | 192 | QFont f = QFont("Micro", 4, QFont::Normal); |
192 | f.setFixedPitch(TRUE); | 193 | f.setFixedPitch(TRUE); |
193 | fonts.append(new VTFont(tr("Micro"), f)); | 194 | fonts.append(new VTFont(tr("Micro"), f)); |
194 | 195 | ||
195 | f = QFont("Fixed", 7, QFont::Normal); | 196 | f = QFont("Fixed", 7, QFont::Normal); |
196 | f.setFixedPitch(TRUE); | 197 | f.setFixedPitch(TRUE); |
197 | fonts.append(new VTFont(tr("Small Fixed"), f)); | 198 | fonts.append(new VTFont(tr("Small Fixed"), f)); |
198 | 199 | ||
199 | f = QFont("Fixed", 12, QFont::Normal); | 200 | f = QFont("Fixed", 12, QFont::Normal); |
200 | f.setFixedPitch(TRUE); | 201 | f.setFixedPitch(TRUE); |
201 | fonts.append(new VTFont(tr("Medium Fixed"), f)); | 202 | fonts.append(new VTFont(tr("Medium Fixed"), f)); |
202 | 203 | ||
203 | // create terminal emulation framework //////////////////////////////////// | 204 | // create terminal emulation framework //////////////////////////////////// |
204 | nsessions = 0; | 205 | nsessions = 0; |
205 | 206 | ||
206 | tab = new EKNumTabWidget(this); | 207 | tab = new EKNumTabWidget(this); |
207 | 208 | ||
208 | connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*))); | 209 | connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*))); |
209 | 210 | ||
210 | // create terminal toolbar //////////////////////////////////////////////// | 211 | // create terminal toolbar //////////////////////////////////////////////// |
211 | setToolBarsMovable( FALSE ); | 212 | setToolBarsMovable( FALSE ); |
212 | QPEToolBar *menuToolBar = new QPEToolBar( this ); | 213 | QPEToolBar *menuToolBar = new QPEToolBar( this ); |
213 | menuToolBar->setHorizontalStretchable( TRUE ); | 214 | menuToolBar->setHorizontalStretchable( TRUE ); |
214 | 215 | ||
215 | QPEMenuBar *menuBar = new QPEMenuBar( menuToolBar ); | 216 | QPEMenuBar *menuBar = new QPEMenuBar( menuToolBar ); |
216 | 217 | ||
217 | fontList = new QPopupMenu( this ); | 218 | fontList = new QPopupMenu( this ); |
218 | for(uint i = 0; i < fonts.count(); i++) { | 219 | for(uint i = 0; i < fonts.count(); i++) { |
219 | VTFont *fnt = fonts.at(i); | 220 | VTFont *fnt = fonts.at(i); |
220 | fontList->insertItem(fnt->getName(), i); | 221 | fontList->insertItem(fnt->getName(), i); |
221 | } | 222 | } |
222 | fontChanged(cfont); | 223 | fontChanged(cfont); |
223 | 224 | ||
224 | configMenu = new QPopupMenu( this); | 225 | configMenu = new QPopupMenu( this); |
225 | colorMenu = new QPopupMenu( this); | 226 | colorMenu = new QPopupMenu( this); |
226 | 227 | ||
227 | bool listHidden; | 228 | bool listHidden; |
228 | cfg.setGroup("Menubar"); | 229 | cfg.setGroup("Menubar"); |
229 | if( cfg.readEntry("Hidden","FALSE") == "TRUE") { | 230 | if( cfg.readEntry("Hidden","FALSE") == "TRUE") { |
230 | configMenu->insertItem("Show command list"); | 231 | configMenu->insertItem("Show command list"); |
231 | listHidden=TRUE; | 232 | listHidden=TRUE; |
232 | } else { | 233 | } else { |
233 | configMenu->insertItem("Hide command list"); | 234 | configMenu->insertItem("Hide command list"); |
234 | listHidden=FALSE; | 235 | listHidden=FALSE; |
235 | } | 236 | } |
236 | 237 | ||
237 | cfg.setGroup("Tabs"); | 238 | cfg.setGroup("Tabs"); |
238 | tmp=cfg.readEntry("Position","Bottom"); | 239 | tmp=cfg.readEntry("Position","Bottom"); |
239 | if(tmp=="Top") { | 240 | if(tmp=="Top") { |
240 | tab->setTabPosition(QTabWidget::Top); | 241 | tab->setTabPosition(QTabWidget::Top); |
241 | configMenu->insertItem("Tabs on Bottom"); | 242 | configMenu->insertItem("Tabs on Bottom"); |
242 | } else { | 243 | } else { |
243 | tab->setTabPosition(QTabWidget::Bottom); | 244 | tab->setTabPosition(QTabWidget::Bottom); |
244 | configMenu->insertItem("Tabs on Top"); | 245 | configMenu->insertItem("Tabs on Top"); |
245 | } | 246 | } |
246 | configMenu->insertSeparator(2); | 247 | configMenu->insertSeparator(2); |
247 | 248 | ||
248 | colorMenu->insertItem("Green on Black"); | 249 | colorMenu->insertItem("Green on Black"); |
249 | colorMenu->insertItem("Black on White"); | 250 | colorMenu->insertItem("Black on White"); |
250 | colorMenu->insertItem("White on Black"); | 251 | colorMenu->insertItem("White on Black"); |
251 | colorMenu->insertItem("Black on Transparent"); | 252 | colorMenu->insertItem("Black on Transparent"); |
252 | colorMenu->insertItem("Black on Red"); | 253 | colorMenu->insertItem("Black on Red"); |