summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/embeddedkonsole/konsole.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/core/apps/embeddedkonsole/konsole.cpp b/core/apps/embeddedkonsole/konsole.cpp
index 653652a..1016885 100644
--- a/core/apps/embeddedkonsole/konsole.cpp
+++ b/core/apps/embeddedkonsole/konsole.cpp
@@ -1,300 +1,301 @@
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
55class EKNumTabBar : public QTabBar { 55class EKNumTabBar : public QTabBar {
56public: 56public:
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
81class EKNumTabWidget : public QTabWidget { 81class EKNumTabWidget : public QTabWidget {
82public: 82public:
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
102static const char *commonCmds[] = 102static 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 "cp ", 110 "cp ",
110 "dc ", 111 "dc ",
111 "df ", 112 "df ",
112 "dmesg", 113 "dmesg",
113 "echo ", 114 "echo ",
114 "env", 115 "env",
115 "find ", 116 "find ",
116 "free", 117 "free",
117 "grep ", 118 "grep ",
118 "ifconfig ", 119 "ifconfig ",
119 "ipkg ", 120 "ipkg ",
120 "mkdir ", 121 "mkdir ",
121 "mv ", 122 "mv ",
122 "nc localhost 7776", 123 "nc localhost 7776",
123 "nc localhost 7777", 124 "nc localhost 7777",
124 "nslookup ", 125 "nslookup ",
125 "ping ", 126 "ping ",
126 "ps aux", 127 "ps aux",
127 "pwd ", 128 "pwd ",
128 "rm ", 129 "rm ",
129 "rmdir ", 130 "rmdir ",
130 "route ", 131 "route ",
131 "set ", 132 "set ",
132 "traceroute", 133 "traceroute",
133 134
134/* 135/*
135 "gzip", 136 "gzip",
136 "gunzip", 137 "gunzip",
137 "chgrp", 138 "chgrp",
138 "chown", 139 "chown",
139 "date", 140 "date",
140 "dd", 141 "dd",
141 "df", 142 "df",
142 "dmesg", 143 "dmesg",
143 "fuser", 144 "fuser",
144 "hostname", 145 "hostname",
145 "kill", 146 "kill",
146 "killall", 147 "killall",
147 "ln", 148 "ln",
148 "ping", 149 "ping",
149 "mount", 150 "mount",
150 "more", 151 "more",
151 "sort", 152 "sort",
152 "touch", 153 "touch",
153 "umount", 154 "umount",
154 "mknod", 155 "mknod",
155 "netstat", 156 "netstat",
156*/ 157*/
157 158
158 "exit", 159 "exit",
159 NULL 160 NULL
160}; 161};
161 162
162 163
163Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) : 164Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) :
164 QMainWindow(parent, name, fl) 165 QMainWindow(parent, name, fl)
165{ 166{
166 QStrList args; 167 QStrList args;
167 init("/bin/sh",args); 168 init("/bin/sh",args);
168} 169}
169 170
170Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int) 171Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int)
171 : QMainWindow(0, name) 172 : QMainWindow(0, name)
172{ 173{
173 init(_pgm,_args); 174 init(_pgm,_args);
174} 175}
175 176
176void Konsole::init(const char* _pgm, QStrList & _args) 177void Konsole::init(const char* _pgm, QStrList & _args)
177{ 178{
178 b_scroll = TRUE; // histon; 179 b_scroll = TRUE; // histon;
179 n_keytab = 0; 180 n_keytab = 0;
180 n_render = 0; 181 n_render = 0;
181 182
182 setCaption( tr("Terminal") ); 183 setCaption( tr("Terminal") );
183 setIcon( Resource::loadPixmap( "konsole" ) ); 184 setIcon( Resource::loadPixmap( "konsole" ) );
184 185
185 Config cfg("Konsole"); 186 Config cfg("Konsole");
186 cfg.setGroup("Konsole"); 187 cfg.setGroup("Konsole");
187 QString tmp; 188 QString tmp;
188 // initialize the list of allowed fonts /////////////////////////////////// 189 // initialize the list of allowed fonts ///////////////////////////////////
189 cfont = cfg.readNumEntry("FontID", 1); 190 cfont = cfg.readNumEntry("FontID", 1);
190 QFont f = QFont("Micro", 4, QFont::Normal); 191 QFont f = QFont("Micro", 4, QFont::Normal);
191 f.setFixedPitch(TRUE); 192 f.setFixedPitch(TRUE);
192 fonts.append(new VTFont(tr("Micro"), f)); 193 fonts.append(new VTFont(tr("Micro"), f));
193 194
194 f = QFont("Fixed", 7, QFont::Normal); 195 f = QFont("Fixed", 7, QFont::Normal);
195 f.setFixedPitch(TRUE); 196 f.setFixedPitch(TRUE);
196 fonts.append(new VTFont(tr("Small Fixed"), f)); 197 fonts.append(new VTFont(tr("Small Fixed"), f));
197 198
198 f = QFont("Fixed", 12, QFont::Normal); 199 f = QFont("Fixed", 12, QFont::Normal);
199 f.setFixedPitch(TRUE); 200 f.setFixedPitch(TRUE);
200 fonts.append(new VTFont(tr("Medium Fixed"), f)); 201 fonts.append(new VTFont(tr("Medium Fixed"), f));
201 202
202 // create terminal emulation framework //////////////////////////////////// 203 // create terminal emulation framework ////////////////////////////////////
203 nsessions = 0; 204 nsessions = 0;
204 205
205 tab = new EKNumTabWidget(this); 206 tab = new EKNumTabWidget(this);
206 207
207 connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*))); 208 connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*)));
208 209
209 // create terminal toolbar //////////////////////////////////////////////// 210 // create terminal toolbar ////////////////////////////////////////////////
210 setToolBarsMovable( FALSE ); 211 setToolBarsMovable( FALSE );
211 QPEToolBar *menuToolBar = new QPEToolBar( this ); 212 QPEToolBar *menuToolBar = new QPEToolBar( this );
212 menuToolBar->setHorizontalStretchable( TRUE ); 213 menuToolBar->setHorizontalStretchable( TRUE );
213 214
214 QPEMenuBar *menuBar = new QPEMenuBar( menuToolBar ); 215 QPEMenuBar *menuBar = new QPEMenuBar( menuToolBar );
215 216
216 fontList = new QPopupMenu( this ); 217 fontList = new QPopupMenu( this );
217 for(uint i = 0; i < fonts.count(); i++) { 218 for(uint i = 0; i < fonts.count(); i++) {
218 VTFont *fnt = fonts.at(i); 219 VTFont *fnt = fonts.at(i);
219 fontList->insertItem(fnt->getName(), i); 220 fontList->insertItem(fnt->getName(), i);
220 } 221 }
221 fontChanged(cfont); 222 fontChanged(cfont);
222 223
223 configMenu = new QPopupMenu( this); 224 configMenu = new QPopupMenu( this);
224 colorMenu = new QPopupMenu( this); 225 colorMenu = new QPopupMenu( this);
225 226
226 bool listHidden; 227 bool listHidden;
227 cfg.setGroup("Menubar"); 228 cfg.setGroup("Menubar");
228 if( cfg.readEntry("Hidden","FALSE") == "TRUE") { 229 if( cfg.readEntry("Hidden","FALSE") == "TRUE") {
229 configMenu->insertItem("Show command list"); 230 configMenu->insertItem("Show command list");
230 listHidden=TRUE; 231 listHidden=TRUE;
231 } else { 232 } else {
232 configMenu->insertItem("Hide command list"); 233 configMenu->insertItem("Hide command list");
233 listHidden=FALSE; 234 listHidden=FALSE;
234 } 235 }
235 236
236 cfg.setGroup("Tabs"); 237 cfg.setGroup("Tabs");
237 tmp=cfg.readEntry("Position","Bottom"); 238 tmp=cfg.readEntry("Position","Bottom");
238 if(tmp=="Top") { 239 if(tmp=="Top") {
239 tab->setTabPosition(QTabWidget::Top); 240 tab->setTabPosition(QTabWidget::Top);
240 configMenu->insertItem("Tabs on Bottom"); 241 configMenu->insertItem("Tabs on Bottom");
241 } else { 242 } else {
242 tab->setTabPosition(QTabWidget::Bottom); 243 tab->setTabPosition(QTabWidget::Bottom);
243 configMenu->insertItem("Tabs on Top"); 244 configMenu->insertItem("Tabs on Top");
244 } 245 }
245 configMenu->insertSeparator(2); 246 configMenu->insertSeparator(2);
246 247
247 colorMenu->insertItem("Green on Black"); 248 colorMenu->insertItem("Green on Black");
248 colorMenu->insertItem("Black on White"); 249 colorMenu->insertItem("Black on White");
249 colorMenu->insertItem("White on Black"); 250 colorMenu->insertItem("White on Black");
250 colorMenu->insertItem("Black on Transparent"); 251 colorMenu->insertItem("Black on Transparent");
251 colorMenu->insertItem("Black on Red"); 252 colorMenu->insertItem("Black on Red");
252 colorMenu->insertItem("Red on Black"); 253 colorMenu->insertItem("Red on Black");
253 colorMenu->insertItem("Green on Yellow"); 254 colorMenu->insertItem("Green on Yellow");
254 colorMenu->insertItem("Blue on Magenta"); 255 colorMenu->insertItem("Blue on Magenta");
255 colorMenu->insertItem("Magenta on Blue"); 256 colorMenu->insertItem("Magenta on Blue");
256 colorMenu->insertItem("Cyan on White"); 257 colorMenu->insertItem("Cyan on White");
257 colorMenu->insertItem("White on Cyan"); 258 colorMenu->insertItem("White on Cyan");
258 colorMenu->insertItem("Blue on Black"); 259 colorMenu->insertItem("Blue on Black");
259 configMenu->insertItem("Colors",colorMenu); 260 configMenu->insertItem("Colors",colorMenu);
260 261
261 connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) )); 262 connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) ));
262 connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) )); 263 connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) ));
263 connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuSelected(int) )); 264 connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuSelected(int) ));
264 265
265 menuBar->insertItem( tr("Font"), fontList ); 266 menuBar->insertItem( tr("Font"), fontList );
266 menuBar->insertItem( tr("Options"), configMenu ); 267 menuBar->insertItem( tr("Options"), configMenu );
267 268
268 QPEToolBar *toolbar = new QPEToolBar( this ); 269 QPEToolBar *toolbar = new QPEToolBar( this );
269 270
270 QAction *a; 271 QAction *a;
271 272
272 // Button Commands 273 // Button Commands
273 a = new QAction( tr("New"), Resource::loadPixmap( "konsole" ), QString::null, 0, this, 0 ); 274 a = new QAction( tr("New"), Resource::loadPixmap( "konsole" ), QString::null, 0, this, 0 );
274 connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); a->addTo( toolbar ); 275 connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); a->addTo( toolbar );
275 a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 ); 276 a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 );
276 connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolbar ); 277 connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolbar );
277 a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 ); 278 a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 );
278 connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolbar ); 279 connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolbar );
279 a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 ); 280 a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 );
280 connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolbar ); 281 connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolbar );
281 a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 ); 282 a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 );
282 connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar ); 283 connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar );
283 a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 ); 284 a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 );
284 connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar ); 285 connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar );
285 a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); 286 a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 );
286 connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); a->addTo( toolbar ); 287 connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); a->addTo( toolbar );
287/* 288/*
288 a = new QAction( tr("Up"), Resource::loadPixmap( "up" ), QString::null, 0, this, 0 ); 289 a = new QAction( tr("Up"), Resource::loadPixmap( "up" ), QString::null, 0, this, 0 );
289 connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar ); 290 connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar );
290 a = new QAction( tr("Down"), Resource::loadPixmap( "down" ), QString::null, 0, this, 0 ); 291 a = new QAction( tr("Down"), Resource::loadPixmap( "down" ), QString::null, 0, this, 0 );
291 connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar ); 292 connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar );
292*/ 293*/
293 294
294 secondToolBar = new QPEToolBar( this ); 295 secondToolBar = new QPEToolBar( this );
295 secondToolBar->setHorizontalStretchable( TRUE ); 296 secondToolBar->setHorizontalStretchable( TRUE );
296 297
297 commonCombo = new QComboBox( secondToolBar ); 298 commonCombo = new QComboBox( secondToolBar );
298 commonCombo->setMaximumWidth(236); 299 commonCombo->setMaximumWidth(236);
299 configMenu->insertItem( "Edit Command List"); 300 configMenu->insertItem( "Edit Command List");
300 if( listHidden) { 301 if( listHidden) {