summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/embeddedkonsole/konsole.cpp43
1 files changed, 34 insertions, 9 deletions
diff --git a/core/apps/embeddedkonsole/konsole.cpp b/core/apps/embeddedkonsole/konsole.cpp
index 16db0ea..06bee33 100644
--- a/core/apps/embeddedkonsole/konsole.cpp
+++ b/core/apps/embeddedkonsole/konsole.cpp
@@ -1,1007 +1,1032 @@
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 QWS_QT_OPIE
22 23
23#include <qpe/resource.h> 24#include <qpe/resource.h>
24 25
25#include <qdir.h> 26#include <qdir.h>
26#include <qevent.h> 27#include <qevent.h>
27#include <qdragobject.h> 28#include <qdragobject.h>
28#include <qobjectlist.h> 29#include <qobjectlist.h>
29#include <qtoolbutton.h> 30#include <qtoolbutton.h>
30#include <qpe/qpetoolbar.h> 31#include <qpe/qpetoolbar.h>
31#include <qpushbutton.h> 32#include <qpushbutton.h>
32#include <qfontdialog.h> 33#include <qfontdialog.h>
33#include <qglobal.h> 34#include <qglobal.h>
34#include <qpainter.h> 35#include <qpainter.h>
35#include <qpe/qpemenubar.h> 36#include <qpe/qpemenubar.h>
36#include <qmessagebox.h> 37#include <qmessagebox.h>
37#include <qaction.h> 38#include <qaction.h>
38#include <qapplication.h> 39#include <qapplication.h>
39#include <qfontmetrics.h> 40#include <qfontmetrics.h>
40#include <qcombobox.h> 41#include <qcombobox.h>
41#include <qevent.h> 42#include <qevent.h>
42#include <qtabwidget.h> 43#include <qtabwidget.h>
43#include <qtabbar.h> 44#include <qtabbar.h>
44#include <qpe/config.h> 45#include <qpe/config.h>
45#include <qstringlist.h> 46#include <qstringlist.h>
46#include <qpalette.h> 47#include <qpalette.h>
47 48
48#include <sys/wait.h> 49#include <sys/wait.h>
49#include <stdio.h> 50#include <stdio.h>
50#include <stdlib.h> 51#include <stdlib.h>
51#include <assert.h> 52#include <assert.h>
52 53
53#include "konsole.h" 54#include "konsole.h"
54#include "keytrans.h" 55#include "keytrans.h"
55#include "commandeditdialog.h" 56#include "commandeditdialog.h"
56 57
58#ifdef QWS_QT_OPIE
57#include <opie/colorpopupmenu.h> 59#include <opie/colorpopupmenu.h>
60#endif
58 61
59class EKNumTabBar : public QTabBar { 62class EKNumTabBar : public QTabBar {
60public: 63public:
61 void numberTabs() 64 void numberTabs()
62 { 65 {
63 // Yes, it really is this messy. QTabWidget needs functions 66 // Yes, it really is this messy. QTabWidget needs functions
64 // that provide acces to tabs in a sequential way. 67 // that provide acces to tabs in a sequential way.
65 int m=INT_MIN; 68 int m=INT_MIN;
66 for (int i=0; i<count(); i++) { 69 for (int i=0; i<count(); i++) {
67 QTab* left=0; 70 QTab* left=0;
68 QListIterator<QTab> it(*tabList()); 71 QListIterator<QTab> it(*tabList());
69 int x=INT_MAX; 72 int x=INT_MAX;
70 for( QTab* t; (t=it.current()); ++it ) { 73 for( QTab* t; (t=it.current()); ++it ) {
71 int tx = t->rect().x(); 74 int tx = t->rect().x();
72 if ( tx<x && tx>m ) { 75 if ( tx<x && tx>m ) {
73 x = tx; 76 x = tx;
74 left = t; 77 left = t;
75 } 78 }
76 } 79 }
77 if ( left ) { 80 if ( left ) {
78 left->setText(QString::number(i+1)); 81 left->setText(QString::number(i+1));
79 m = left->rect().x(); 82 m = left->rect().x();
80 } 83 }
81 } 84 }
82 } 85 }
83}; 86};
84 87
85class EKNumTabWidget : public QTabWidget { 88class EKNumTabWidget : public QTabWidget {
86public: 89public:
87 EKNumTabWidget(QWidget* parent) : QTabWidget(parent) 90 EKNumTabWidget(QWidget* parent) : QTabWidget(parent)
88 { 91 {
89 } 92 }
90 93
91 void addTab(QWidget* w) 94 void addTab(QWidget* w)
92 { 95 {
93 QTab* t = new QTab(QString::number(tabBar()->count()+1)); 96 QTab* t = new QTab(QString::number(tabBar()->count()+1));
94 QTabWidget::addTab(w,t); 97 QTabWidget::addTab(w,t);
95 } 98 }
96 99
97 void removeTab(QWidget* w) 100 void removeTab(QWidget* w)
98 { 101 {
99 removePage(w); 102 removePage(w);
100 ((EKNumTabBar*)tabBar())->numberTabs(); 103 ((EKNumTabBar*)tabBar())->numberTabs();
101 } 104 }
102}; 105};
103 106
104// This could be configurable or dynamicly generated from the bash history 107// This could be configurable or dynamicly generated from the bash history
105// file of the user 108// file of the user
106static const char *commonCmds[] = 109static const char *commonCmds[] =
107{ 110{
108 "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
109 "cardctl eject", 112 "cardctl eject",
110 "cat ", 113 "cat ",
111 "cd ", 114 "cd ",
112 "chmod ", 115 "chmod ",
113 "clear", 116 "clear",
114 "cp ", 117 "cp ",
115 "dc ", 118 "dc ",
116 "df ", 119 "df ",
117 "dmesg", 120 "dmesg",
118 "echo ", 121 "echo ",
119 "env", 122 "env",
120 "find ", 123 "find ",
121 "free", 124 "free",
122 "grep ", 125 "grep ",
123 "ifconfig ", 126 "ifconfig ",
124 "ipkg ", 127 "ipkg ",
125 "mkdir ", 128 "mkdir ",
126 "mv ", 129 "mv ",
127 "nc localhost 7776", 130 "nc localhost 7776",
128 "nc localhost 7777", 131 "nc localhost 7777",
129 "netstat ", 132 "netstat ",
130 "nslookup ", 133 "nslookup ",
131 "ping ", 134 "ping ",
132 "ps aux", 135 "ps aux",
133 "pwd ", 136 "pwd ",
134 "qcop QPE/System 'linkChanged(QString)' ''", 137 "qcop QPE/System 'linkChanged(QString)' ''",
135 "qcop QPE/System 'restart()'", 138 "qcop QPE/System 'restart()'",
136 "qcop QPE/System 'quit()'", 139 "qcop QPE/System 'quit()'",
137 "rm ", 140 "rm ",
138 "rmdir ", 141 "rmdir ",
139 "route ", 142 "route ",
140 "set ", 143 "set ",
141 "traceroute", 144 "traceroute",
142 145
143/* 146/*
144 "gzip", 147 "gzip",
145 "gunzip", 148 "gunzip",
146 "chgrp", 149 "chgrp",
147 "chown", 150 "chown",
148 "date", 151 "date",
149 "dd", 152 "dd",
150 "df", 153 "df",
151 "dmesg", 154 "dmesg",
152 "fuser", 155 "fuser",
153 "hostname", 156 "hostname",
154 "kill", 157 "kill",
155 "killall", 158 "killall",
156 "ln", 159 "ln",
157 "ping", 160 "ping",
158 "mount", 161 "mount",
159 "more", 162 "more",
160 "sort", 163 "sort",
161 "touch", 164 "touch",
162 "umount", 165 "umount",
163 "mknod", 166 "mknod",
164 "netstat", 167 "netstat",
165*/ 168*/
166 169
167 "exit", 170 "exit",
168 NULL 171 NULL
169}; 172};
170 173
171 174
172Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) : 175Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) :
173 QMainWindow(parent, name, fl) 176 QMainWindow(parent, name, fl)
174{ 177{
175 QStrList args; 178 QStrList args;
176 init("/bin/sh",args); 179 init("/bin/sh",args);
177} 180}
178 181
179Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int) 182Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int)
180 : QMainWindow(0, name) 183 : QMainWindow(0, name)
181{ 184{
182 init(_pgm,_args); 185 init(_pgm,_args);
183} 186}
184 187
185void Konsole::initCommandList() 188void Konsole::initCommandList()
186{ 189{
187// qDebug("Konsole::initCommandList"); 190// qDebug("Konsole::initCommandList");
188 Config cfg("Konsole"); 191 Config cfg("Konsole");
189 cfg.setGroup("Commands"); 192 cfg.setGroup("Commands");
190 commonCombo->setInsertionPolicy(QComboBox::AtCurrent); 193 commonCombo->setInsertionPolicy(QComboBox::AtCurrent);
191 commonCombo->clear(); 194 commonCombo->clear();
192 if (cfg.readEntry("Commands Set","FALSE") == "FALSE") { 195 if (cfg.readEntry("Commands Set","FALSE") == "FALSE") {
193 for (int i = 0; commonCmds[i] != NULL; i++) { 196 for (int i = 0; commonCmds[i] != NULL; i++) {
194 commonCombo->insertItem(commonCmds[i],i); 197 commonCombo->insertItem(commonCmds[i],i);
195 } 198 }
196 } else { 199 } else {
197 for (int i = 0; i < 100; i++) { 200 for (int i = 0; i < 100; i++) {
198 if (!(cfg.readEntry( QString::number(i),"")).isEmpty()) 201 if (!(cfg.readEntry( QString::number(i),"")).isEmpty())
199 commonCombo->insertItem((cfg.readEntry( QString::number(i),""))); 202 commonCombo->insertItem((cfg.readEntry( QString::number(i),"")));
200 } 203 }
201 } 204 }
202 205
203} 206}
204 207
205void Konsole::init(const char* _pgm, QStrList & _args) 208void Konsole::init(const char* _pgm, QStrList & _args)
206{ 209{
207 b_scroll = TRUE; // histon; 210 b_scroll = TRUE; // histon;
208 n_keytab = 0; 211 n_keytab = 0;
209 n_render = 0; 212 n_render = 0;
210 startUp=0; 213 startUp=0;
211 fromMenu = FALSE; 214 fromMenu = FALSE;
212 215
213 setCaption( tr("Terminal") ); 216 setCaption( tr("Terminal") );
214 setIcon( Resource::loadPixmap( "konsole" ) ); 217 setIcon( Resource::loadPixmap( "konsole" ) );
215 218
216 Config cfg("Konsole"); 219 Config cfg("Konsole");
217 cfg.setGroup("Konsole"); 220 cfg.setGroup("Konsole");
218 QString tmp; 221 QString tmp;
219 // initialize the list of allowed fonts /////////////////////////////////// 222 // initialize the list of allowed fonts ///////////////////////////////////
220 cfont = cfg.readNumEntry("FontID", 1); 223 cfont = cfg.readNumEntry("FontID", 1);
221 QFont f = QFont("Micro", 4, QFont::Normal); 224 QFont f = QFont("Micro", 4, QFont::Normal);
222 f.setFixedPitch(TRUE); 225 f.setFixedPitch(TRUE);
223 fonts.append(new VTFont(tr("Micro"), f)); 226 fonts.append(new VTFont(tr("Micro"), f));
224 227
225 f = QFont("Fixed", 7, QFont::Normal); 228 f = QFont("Fixed", 7, QFont::Normal);
226 f.setFixedPitch(TRUE); 229 f.setFixedPitch(TRUE);
227 fonts.append(new VTFont(tr("Small Fixed"), f)); 230 fonts.append(new VTFont(tr("Small Fixed"), f));
228 231
229 f = QFont("Fixed", 12, QFont::Normal); 232 f = QFont("Fixed", 12, QFont::Normal);
230 f.setFixedPitch(TRUE); 233 f.setFixedPitch(TRUE);
231 fonts.append(new VTFont(tr("Medium Fixed"), f)); 234 fonts.append(new VTFont(tr("Medium Fixed"), f));
232 235
233 // create terminal emulation framework //////////////////////////////////// 236 // create terminal emulation framework ////////////////////////////////////
234 nsessions = 0; 237 nsessions = 0;
235 238
236 tab = new EKNumTabWidget(this); 239 tab = new EKNumTabWidget(this);
237 240
238 connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*))); 241 connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*)));
239 242
240 // create terminal toolbar //////////////////////////////////////////////// 243 // create terminal toolbar ////////////////////////////////////////////////
241 setToolBarsMovable( FALSE ); 244 setToolBarsMovable( FALSE );
242 QPEToolBar *menuToolBar = new QPEToolBar( this ); 245 QPEToolBar *menuToolBar = new QPEToolBar( this );
243 menuToolBar->setHorizontalStretchable( TRUE ); 246 menuToolBar->setHorizontalStretchable( TRUE );
244 247
245 QPEMenuBar *menuBar = new QPEMenuBar( menuToolBar ); 248 QPEMenuBar *menuBar = new QPEMenuBar( menuToolBar );
246 249
247 fontList = new QPopupMenu( this ); 250 fontList = new QPopupMenu( this );
248 for(uint i = 0; i < fonts.count(); i++) { 251 for(uint i = 0; i < fonts.count(); i++) {
249 VTFont *fnt = fonts.at(i); 252 VTFont *fnt = fonts.at(i);
250 fontList->insertItem(fnt->getName(), i); 253 fontList->insertItem(fnt->getName(), i);
251 } 254 }
252 fontChanged(cfont); 255 fontChanged(cfont);
253 256
254 configMenu = new QPopupMenu( this); 257 configMenu = new QPopupMenu( this);
255 colorMenu = new QPopupMenu( this); 258 colorMenu = new QPopupMenu( this);
256 scrollMenu = new QPopupMenu( this); 259 scrollMenu = new QPopupMenu( this);
257 editCommandListMenu = new QPopupMenu( this); 260 editCommandListMenu = new QPopupMenu( this);
258 261
259 configMenu->insertItem(tr("Command List"), editCommandListMenu); 262 configMenu->insertItem(tr("Command List"), editCommandListMenu);
260 263
261 bool listHidden; 264 bool listHidden;
262 cfg.setGroup("Menubar"); 265 cfg.setGroup("Menubar");
263 if( cfg.readEntry("Hidden","FALSE") == "TRUE") { 266 if( cfg.readEntry("Hidden","FALSE") == "TRUE") {
264 editCommandListMenu->insertItem( tr( "Show command list" )); 267 editCommandListMenu->insertItem( tr( "Show command list" ));
265 listHidden=TRUE; 268 listHidden=TRUE;
266 } else { 269 } else {
267 editCommandListMenu->insertItem( tr( "Hide command list" )); 270 editCommandListMenu->insertItem( tr( "Hide command list" ));
268 listHidden=FALSE; 271 listHidden=FALSE;
269 } 272 }
270 273
271 cfg.setGroup("Tabs"); 274 cfg.setGroup("Tabs");
272 tmp=cfg.readEntry("Position","Bottom"); 275 tmp=cfg.readEntry("Position","Bottom");
273 if(tmp=="Top") { 276 if(tmp=="Top") {
274 tab->setTabPosition(QTabWidget::Top); 277 tab->setTabPosition(QTabWidget::Top);
275 configMenu->insertItem( tr( "Tabs on Bottom" ) ); 278 configMenu->insertItem( tr( "Tabs on Bottom" ) );
276 } else { 279 } else {
277 tab->setTabPosition(QTabWidget::Bottom); 280 tab->setTabPosition(QTabWidget::Bottom);
278 configMenu->insertItem("Tabs on Top"); 281 configMenu->insertItem("Tabs on Top");
279 } 282 }
280 configMenu->insertSeparator(2); 283 configMenu->insertSeparator(2);
281 284
282 colorMenu->insertItem(tr( "Green on Black")); 285 colorMenu->insertItem(tr( "Green on Black"));
283 colorMenu->insertItem(tr( "Black on White")); 286 colorMenu->insertItem(tr( "Black on White"));
284 colorMenu->insertItem(tr( "White on Black")); 287 colorMenu->insertItem(tr( "White on Black"));
285 colorMenu->insertItem(tr( "Black on Transparent")); 288 colorMenu->insertItem(tr( "Black on Transparent"));
286 colorMenu->insertItem(tr( "Black on Red")); 289 colorMenu->insertItem(tr( "Black on Red"));
287 colorMenu->insertItem(tr( "Red on Black")); 290 colorMenu->insertItem(tr( "Red on Black"));
288 colorMenu->insertItem(tr( "Green on Yellow")); 291 colorMenu->insertItem(tr( "Green on Yellow"));
289 colorMenu->insertItem(tr( "Blue on Magenta")); 292 colorMenu->insertItem(tr( "Blue on Magenta"));
290 colorMenu->insertItem(tr( "Magenta on Blue")); 293 colorMenu->insertItem(tr( "Magenta on Blue"));
291 colorMenu->insertItem(tr( "Cyan on White")); 294 colorMenu->insertItem(tr( "Cyan on White"));
292 colorMenu->insertItem(tr( "White on Cyan")); 295 colorMenu->insertItem(tr( "White on Cyan"));
293 colorMenu->insertItem(tr( "Blue on Black")); 296 colorMenu->insertItem(tr( "Blue on Black"));
294 colorMenu->insertItem(tr( "Amber on Black")); 297 colorMenu->insertItem(tr( "Amber on Black"));
298
299#ifdef QWS_QT_OPIE
295 colorMenu->insertItem(tr( "Custom")); 300 colorMenu->insertItem(tr( "Custom"));
301#endif
302
296 configMenu->insertItem(tr( "Colors") ,colorMenu); 303 configMenu->insertItem(tr( "Colors") ,colorMenu);
297 304
298 connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) )); 305 connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) ));
299 connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) )); 306 connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) ));
300 connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuIsSelected(int) )); 307 connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuIsSelected(int) ));
301 connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int))); 308 connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int)));
302 connect(editCommandListMenu,SIGNAL(activated(int)),this,SLOT(editCommandListMenuSelected(int))); 309 connect(editCommandListMenu,SIGNAL(activated(int)),this,SLOT(editCommandListMenuSelected(int)));
303 menuBar->insertItem( tr("Font"), fontList ); 310 menuBar->insertItem( tr("Font"), fontList );
304 menuBar->insertItem( tr("Options"), configMenu ); 311 menuBar->insertItem( tr("Options"), configMenu );
305 312
306 QPEToolBar *toolbar = new QPEToolBar( this ); 313 QPEToolBar *toolbar = new QPEToolBar( this );
307 314
308 QAction *a; 315 QAction *a;
309 316
310 // Button Commands 317 // Button Commands
311 a = new QAction( tr("New"), Resource::loadPixmap( "konsole" ), QString::null, 0, this, 0 ); 318 a = new QAction( tr("New"), Resource::loadPixmap( "konsole" ), QString::null, 0, this, 0 );
312 connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); a->addTo( toolbar ); 319 connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); a->addTo( toolbar );
313 a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 ); 320 a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 );
314 connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolbar ); 321 connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolbar );
315 a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 ); 322 a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 );
316 connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolbar ); 323 connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolbar );
317 a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 ); 324 a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 );
318 connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolbar ); 325 connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolbar );
319 a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 ); 326 a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 );
320 connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar ); 327 connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar );
321 a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 ); 328 a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 );
322 connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar ); 329 connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar );
323 a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); 330 a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 );
324 connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); a->addTo( toolbar ); 331 connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); a->addTo( toolbar );
325/* 332/*
326 a = new QAction( tr("Up"), Resource::loadPixmap( "up" ), QString::null, 0, this, 0 ); 333 a = new QAction( tr("Up"), Resource::loadPixmap( "up" ), QString::null, 0, this, 0 );
327 connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar ); 334 connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar );
328 a = new QAction( tr("Down"), Resource::loadPixmap( "down" ), QString::null, 0, this, 0 ); 335 a = new QAction( tr("Down"), Resource::loadPixmap( "down" ), QString::null, 0, this, 0 );
329 connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar ); 336 connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar );
330*/ 337*/
331 338
332 secondToolBar = new QPEToolBar( this ); 339 secondToolBar = new QPEToolBar( this );
333 secondToolBar->setHorizontalStretchable( TRUE ); 340 secondToolBar->setHorizontalStretchable( TRUE );
334 341
335 commonCombo = new QComboBox( secondToolBar ); 342 commonCombo = new QComboBox( secondToolBar );
336 commonCombo->setMaximumWidth(236); 343 commonCombo->setMaximumWidth(236);
337 344
338 editCommandListMenu->insertItem( tr( "Quick Edit" ) ); 345 editCommandListMenu->insertItem( tr( "Quick Edit" ) );
339 if( listHidden) { 346 if( listHidden) {
340 secondToolBar->hide(); 347 secondToolBar->hide();
341 editCommandListMenu->setItemEnabled(-23 ,FALSE); 348 editCommandListMenu->setItemEnabled(-23 ,FALSE);
342 } 349 }
343 editCommandListMenu->insertItem(tr( "Edit" ) ); 350 editCommandListMenu->insertItem(tr( "Edit" ) );
344 351
345 cfg.setGroup("Commands"); 352 cfg.setGroup("Commands");
346 commonCombo->setInsertionPolicy(QComboBox::AtCurrent); 353 commonCombo->setInsertionPolicy(QComboBox::AtCurrent);
347 354
348 initCommandList(); 355 initCommandList();
349// for (int i = 0; commonCmds[i] != NULL; i++) { 356// for (int i = 0; commonCmds[i] != NULL; i++) {
350// commonCombo->insertItem( commonCmds[i], i ); 357// commonCombo->insertItem( commonCmds[i], i );
351// tmp = cfg.readEntry( QString::number(i),""); 358// tmp = cfg.readEntry( QString::number(i),"");
352// if(tmp != "") 359// if(tmp != "")
353// commonCombo->changeItem( tmp,i ); 360// commonCombo->changeItem( tmp,i );
354// } 361// }
355 362
356 connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) )); 363 connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) ));
357 364
358 scrollMenu->insertItem(tr( "None" )); 365 scrollMenu->insertItem(tr( "None" ));
359 scrollMenu->insertItem(tr( "Left" )); 366 scrollMenu->insertItem(tr( "Left" ));
360 scrollMenu->insertItem(tr( "Right" )); 367 scrollMenu->insertItem(tr( "Right" ));
361// scrollMenu->insertSeparator(4); 368// scrollMenu->insertSeparator(4);
362// scrollMenu->insertItem(tr( "Horizontal" )); 369// scrollMenu->insertItem(tr( "Horizontal" ));
363 370
364 configMenu->insertItem(tr( "ScrollBar" ),scrollMenu); 371 configMenu->insertItem(tr( "ScrollBar" ),scrollMenu);
365 372
366 configMenu->insertItem(tr( "Wrap" )); 373 configMenu->insertItem(tr( "Wrap" ));
367 374
368//scrollMenuSelected(-29); 375//scrollMenuSelected(-29);
369// cfg.setGroup("ScrollBar"); 376// cfg.setGroup("ScrollBar");
370// if(cfg.readBoolEntry("HorzScroll",0)) { 377// if(cfg.readBoolEntry("HorzScroll",0)) {
371// if(cfg.readNumEntry("Position",2) == 0) 378// if(cfg.readNumEntry("Position",2) == 0)
372// te->setScrollbarLocation(1); 379// te->setScrollbarLocation(1);
373// else 380// else
374// te->setScrollbarLocation(0); 381// te->setScrollbarLocation(0);
375// te->setScrollbarLocation( cfg.readNumEntry("Position",2)); 382// te->setScrollbarLocation( cfg.readNumEntry("Position",2));
376// te->setWrapAt(120); 383// te->setWrapAt(120);
377// } 384// }
378 // create applications ///////////////////////////////////////////////////// 385 // create applications /////////////////////////////////////////////////////
379 setCentralWidget(tab); 386 setCentralWidget(tab);
380 387
381 // load keymaps //////////////////////////////////////////////////////////// 388 // load keymaps ////////////////////////////////////////////////////////////
382 KeyTrans::loadAll(); 389 KeyTrans::loadAll();
383 for (int i = 0; i < KeyTrans::count(); i++) 390 for (int i = 0; i < KeyTrans::count(); i++)
384 { KeyTrans* s = KeyTrans::find(i); 391 { KeyTrans* s = KeyTrans::find(i);
385 assert( s ); 392 assert( s );
386 } 393 }
387 394
388 se_pgm = _pgm; 395 se_pgm = _pgm;
389 se_args = _args; 396 se_args = _args;
390 se_args.prepend("--login"); 397 se_args.prepend("--login");
391parseCommandLine(); 398parseCommandLine();
392 // read and apply default values /////////////////////////////////////////// 399 // read and apply default values ///////////////////////////////////////////
393 resize(321, 321); // Dummy. 400 resize(321, 321); // Dummy.
394 QSize currentSize = size(); 401 QSize currentSize = size();
395 if (currentSize != size()) 402 if (currentSize != size())
396 defaultSize = size(); 403 defaultSize = size();
397} 404}
398 405
399void Konsole::show() 406void Konsole::show()
400{ 407{
401 if ( !nsessions ) { 408 if ( !nsessions ) {
402 newSession(); 409 newSession();
403 } 410 }
404 QMainWindow::show(); 411 QMainWindow::show();
405 412
406} 413}
407 414
408void Konsole::initSession(const char*, QStrList &) 415void Konsole::initSession(const char*, QStrList &)
409{ 416{
410 QMainWindow::show(); 417 QMainWindow::show();
411} 418}
412 419
413Konsole::~Konsole() 420Konsole::~Konsole()
414{ 421{
415 while (nsessions > 0) { 422 while (nsessions > 0) {
416 doneSession(getTe()->currentSession, 0); 423 doneSession(getTe()->currentSession, 0);
417 } 424 }
418 425
419 Config cfg("Konsole"); 426 Config cfg("Konsole");
420 cfg.setGroup("Konsole"); 427 cfg.setGroup("Konsole");
421 cfg.writeEntry("FontID", cfont); 428 cfg.writeEntry("FontID", cfont);
422} 429}
423 430
424void Konsole::fontChanged(int f) 431void Konsole::fontChanged(int f)
425{ 432{
426 VTFont* font = fonts.at(f); 433 VTFont* font = fonts.at(f);
427 if (font != 0) { 434 if (font != 0) {
428 for(uint i = 0; i < fonts.count(); i++) { 435 for(uint i = 0; i < fonts.count(); i++) {
429 fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE); 436 fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE);
430 } 437 }
431 438
432 cfont = f; 439 cfont = f;
433 440
434 TEWidget* te = getTe(); 441 TEWidget* te = getTe();
435 if (te != 0) { 442 if (te != 0) {
436 te->setVTFont(font->getFont()); 443 te->setVTFont(font->getFont());
437 } 444 }
438 } 445 }
439} 446}
440 447
441 448
442void Konsole::enterCommand(int c) 449void Konsole::enterCommand(int c)
443{ 450{
444 TEWidget* te = getTe(); 451 TEWidget* te = getTe();
445 if (te != 0) { 452 if (te != 0) {
446 if(!commonCombo->editable()) { 453 if(!commonCombo->editable()) {
447 QString text = commonCombo->text(c); //commonCmds[c]; 454 QString text = commonCombo->text(c); //commonCmds[c];
448 te->emitText(text); 455 te->emitText(text);
449 } else { 456 } else {
450 changeCommand( commonCombo->text(c), c); 457 changeCommand( commonCombo->text(c), c);
451 } 458 }
452 } 459 }
453} 460}
454 461
455void Konsole::hitEnter() 462void Konsole::hitEnter()
456{ 463{
457 TEWidget* te = getTe(); 464 TEWidget* te = getTe();
458 if (te != 0) { 465 if (te != 0) {
459 te->emitText(QString("\r")); 466 te->emitText(QString("\r"));
460 } 467 }
461} 468}
462 469
463void Konsole::hitSpace() 470void Konsole::hitSpace()
464{ 471{
465 TEWidget* te = getTe(); 472 TEWidget* te = getTe();
466 if (te != 0) { 473 if (te != 0) {
467 te->emitText(QString(" ")); 474 te->emitText(QString(" "));
468 } 475 }
469} 476}
470 477
471void Konsole::hitTab() 478void Konsole::hitTab()
472{ 479{
473 TEWidget* te = getTe(); 480 TEWidget* te = getTe();
474 if (te != 0) { 481 if (te != 0) {
475 te->emitText(QString("\t")); 482 te->emitText(QString("\t"));
476 } 483 }
477} 484}
478 485
479void Konsole::hitPaste() 486void Konsole::hitPaste()
480{ 487{
481 TEWidget* te = getTe(); 488 TEWidget* te = getTe();
482 if (te != 0) { 489 if (te != 0) {
483 te->pasteClipboard(); 490 te->pasteClipboard();
484 } 491 }
485} 492}
486 493
487void Konsole::hitUp() 494void Konsole::hitUp()
488{ 495{
489 TEWidget* te = getTe(); 496 TEWidget* te = getTe();
490 if (te != 0) { 497 if (te != 0) {
491 QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Up, 0, 0); 498 QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Up, 0, 0);
492 QApplication::sendEvent( te, &ke ); 499 QApplication::sendEvent( te, &ke );
493 } 500 }
494} 501}
495 502
496void Konsole::hitDown() 503void Konsole::hitDown()
497{ 504{
498 TEWidget* te = getTe(); 505 TEWidget* te = getTe();
499 if (te != 0) { 506 if (te != 0) {
500 QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Down, 0, 0); 507 QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Down, 0, 0);
501 QApplication::sendEvent( te, &ke ); 508 QApplication::sendEvent( te, &ke );
502 } 509 }
503} 510}
504 511
505/** 512/**
506 This function calculates the size of the external widget 513 This function calculates the size of the external widget
507 needed for the internal widget to be 514 needed for the internal widget to be
508 */ 515 */
509QSize Konsole::calcSize(int columns, int lines) { 516QSize Konsole::calcSize(int columns, int lines) {
510 TEWidget* te = getTe(); 517 TEWidget* te = getTe();
511 if (te != 0) { 518 if (te != 0) {
512 QSize size = te->calcSize(columns, lines); 519 QSize size = te->calcSize(columns, lines);
513 return size; 520 return size;
514 } else { 521 } else {
515 QSize size; 522 QSize size;
516 return size; 523 return size;
517 } 524 }
518} 525}
519 526
520/** 527/**
521 sets application window to a size based on columns X lines of the te 528 sets application window to a size based on columns X lines of the te
522 guest widget. Call with (0,0) for setting default size. 529 guest widget. Call with (0,0) for setting default size.
523*/ 530*/
524 531
525void Konsole::setColLin(int columns, int lines) 532void Konsole::setColLin(int columns, int lines)
526{ 533{
527 qDebug("konsole::setColLin:: Columns %d", columns); 534 qDebug("konsole::setColLin:: Columns %d", columns);
528 535
529 if ((columns==0) || (lines==0)) 536 if ((columns==0) || (lines==0))
530 { 537 {
531 if (defaultSize.isEmpty()) // not in config file : set default value 538 if (defaultSize.isEmpty()) // not in config file : set default value
532 { 539 {
533 defaultSize = calcSize(80,24); 540 defaultSize = calcSize(80,24);
534 // notifySize(24,80); // set menu items (strange arg order !) 541 // notifySize(24,80); // set menu items (strange arg order !)
535 } 542 }
536 resize(defaultSize); 543 resize(defaultSize);
537 } else { 544 } else {
538 resize(calcSize(columns, lines)); 545 resize(calcSize(columns, lines));
539 // notifySize(lines,columns); // set menu items (strange arg order !) 546 // notifySize(lines,columns); // set menu items (strange arg order !)
540 } 547 }
541} 548}
542 549
543/* 550/*
544void Konsole::setFont(int fontno) 551void Konsole::setFont(int fontno)
545{ 552{
546 QFont f; 553 QFont f;
547 if (fontno == 0) 554 if (fontno == 0)
548 f = defaultFont = QFont( "Helvetica", 12 ); 555 f = defaultFont = QFont( "Helvetica", 12 );
549 else 556 else
550 if (fonts[fontno][0] == '-') 557 if (fonts[fontno][0] == '-')
551 f.setRawName( fonts[fontno] ); 558 f.setRawName( fonts[fontno] );
552 else 559 else
553 { 560 {
554 f.setFamily(fonts[fontno]); 561 f.setFamily(fonts[fontno]);
555 f.setRawMode( TRUE ); 562 f.setRawMode( TRUE );
556 } 563 }
557 if ( !f.exactMatch() && fontno != 0) 564 if ( !f.exactMatch() && fontno != 0)
558 { 565 {
559 QString msg = i18n("Font `%1' not found.\nCheck README.linux.console for help.").arg(fonts[fontno]); 566 QString msg = i18n("Font `%1' not found.\nCheck README.linux.console for help.").arg(fonts[fontno]);
560 QMessageBox(this, msg); 567 QMessageBox(this, msg);
561 return; 568 return;
562 } 569 }
563 if (se) se->setFontNo(fontno); 570 if (se) se->setFontNo(fontno);
564 te->setVTFont(f); 571 te->setVTFont(f);
565 n_font = fontno; 572 n_font = fontno;
566} 573}
567*/ 574*/
568 575
569// --| color selection |------------------------------------------------------- 576// --| color selection |-------------------------------------------------------
570 577
571void Konsole::changeColumns(int columns) 578void Konsole::changeColumns(int columns)
572{ 579{
573 qDebug("change columns"); 580 qDebug("change columns");
574 TEWidget* te = getTe(); 581 TEWidget* te = getTe();
575 if (te != 0) { 582 if (te != 0) {
576 setColLin(columns,te->Lines()); 583 setColLin(columns,te->Lines());
577 te->update(); 584 te->update();
578 } 585 }
579} 586}
580 587
581//FIXME: If a child dies during session swap, 588//FIXME: If a child dies during session swap,
582// this routine might be called before 589// this routine might be called before
583// session swap is completed. 590// session swap is completed.
584 591
585void Konsole::doneSession(TESession*, int ) 592void Konsole::doneSession(TESession*, int )
586{ 593{
587 TEWidget *te = getTe(); 594 TEWidget *te = getTe();
588 if (te != 0) { 595 if (te != 0) {
589 te->currentSession->setConnect(FALSE); 596 te->currentSession->setConnect(FALSE);
590 tab->removeTab(te); 597 tab->removeTab(te);
591 delete te->currentSession; 598 delete te->currentSession;
592 delete te; 599 delete te;
593 nsessions--; 600 nsessions--;
594 } 601 }
595 602
596 if (nsessions == 0) { 603 if (nsessions == 0) {
597 close(); 604 close();
598 } 605 }
599} 606}
600 607
601void Konsole::newSession() { 608void Konsole::newSession() {
602 if(nsessions < 15) { // seems to be something weird about 16 tabs on the Zaurus.... memory? 609 if(nsessions < 15) { // seems to be something weird about 16 tabs on the Zaurus.... memory?
603 TEWidget* te = new TEWidget(tab); 610 TEWidget* te = new TEWidget(tab);
604// te->setBackgroundMode(PaletteBase); //we want transparent!! 611// te->setBackgroundMode(PaletteBase); //we want transparent!!
605 te->setVTFont(fonts.at(cfont)->getFont()); 612 te->setVTFont(fonts.at(cfont)->getFont());
606 tab->addTab(te); 613 tab->addTab(te);
607 TESession* se = new TESession(this, te, se_pgm, se_args, "xterm"); 614 TESession* se = new TESession(this, te, se_pgm, se_args, "xterm");
608 te->currentSession = se; 615 te->currentSession = se;
609 connect( se, SIGNAL(done(TESession*,int)), this, SLOT(doneSession(TESession*,int)) ); 616 connect( se, SIGNAL(done(TESession*,int)), this, SLOT(doneSession(TESession*,int)) );
610 se->run(); 617 se->run();
611 se->setConnect(TRUE); 618 se->setConnect(TRUE);
612 se->setHistory(b_scroll); 619 se->setHistory(b_scroll);
613 tab->setCurrentPage(nsessions); 620 tab->setCurrentPage(nsessions);
614 nsessions++; 621 nsessions++;
615 doWrap(); 622 doWrap();
616 setColor(); 623 setColor();
617 } 624 }
618} 625}
619 626
620TEWidget* Konsole::getTe() { 627TEWidget* Konsole::getTe() {
621 if (nsessions) { 628 if (nsessions) {
622 return (TEWidget *) tab->currentPage(); 629 return (TEWidget *) tab->currentPage();
623 } else { 630 } else {
624 return 0; 631 return 0;
625 } 632 }
626} 633}
627 634
628void Konsole::switchSession(QWidget* w) { 635void Konsole::switchSession(QWidget* w) {
629 TEWidget* te = (TEWidget *) w; 636 TEWidget* te = (TEWidget *) w;
630 637
631 QFont teFnt = te->getVTFont(); 638 QFont teFnt = te->getVTFont();
632 for(uint i = 0; i < fonts.count(); i++) { 639 for(uint i = 0; i < fonts.count(); i++) {
633 VTFont *fnt = fonts.at(i); 640 VTFont *fnt = fonts.at(i);
634 bool cf = fnt->getFont() == teFnt; 641 bool cf = fnt->getFont() == teFnt;
635 fontList->setItemChecked(i, cf); 642 fontList->setItemChecked(i, cf);
636 if (cf) { 643 if (cf) {
637 cfont = i; 644 cfont = i;
638 } 645 }
639 } 646 }
640} 647}
641 648
642void Konsole::colorMenuIsSelected(int iD) { 649void Konsole::colorMenuIsSelected(int iD) {
643 fromMenu = TRUE; 650 fromMenu = TRUE;
644 colorMenuSelected(iD); 651 colorMenuSelected(iD);
645} 652}
646 653
647/// ------------------------------- some new stuff by L.J. Potter 654/// ------------------------------- some new stuff by L.J. Potter
648void Konsole::colorMenuSelected(int iD) 655void Konsole::colorMenuSelected(int iD)
649{ // this is NOT pretty, elegant or anything else besides functional 656{ // this is NOT pretty, elegant or anything else besides functional
650// QString temp; 657// QString temp;
651// qDebug( temp.sprintf("colormenu %d", iD)); 658// qDebug( temp.sprintf("colormenu %d", iD));
652 TEWidget* te = getTe(); 659 TEWidget* te = getTe();
653 Config cfg("Konsole"); 660 Config cfg("Konsole");
654 cfg.setGroup("Colors"); 661 cfg.setGroup("Colors");
655// QColor foreground; 662// QColor foreground;
656// QColor background; 663// QColor background;
657 colorMenu->setItemChecked(lastSelectedMenu,FALSE); 664 colorMenu->setItemChecked(lastSelectedMenu,FALSE);
658 ColorEntry m_table[TABLE_COLORS]; 665 ColorEntry m_table[TABLE_COLORS];
659 const ColorEntry * defaultCt=te->getdefaultColorTable(); 666 const ColorEntry * defaultCt=te->getdefaultColorTable();
660 /////////// fore back 667 /////////// fore back
661 int i; 668 int i;
662 if(iD==-9) { // default default 669 if(iD==-9) { // default default
663 for (i = 0; i < TABLE_COLORS; i++) { 670 for (i = 0; i < TABLE_COLORS; i++) {
664 m_table[i].color = defaultCt[i].color; 671 m_table[i].color = defaultCt[i].color;
665 if(i==1 || i == 11) 672 if(i==1 || i == 11)
666 m_table[i].transparent=1; 673 m_table[i].transparent=1;
667 cfg.writeEntry("Schema","9"); 674 cfg.writeEntry("Schema","9");
668 colorMenu->setItemChecked(-9,TRUE); 675 colorMenu->setItemChecked(-9,TRUE);
669 } 676 }
670 } else { 677 } else {
671 if(iD==-6) { // green black 678 if(iD==-6) { // green black
672 foreground.setRgb(0x18,255,0x18); 679 foreground.setRgb(0x18,255,0x18);
673 background.setRgb(0x00,0x00,0x00); 680 background.setRgb(0x00,0x00,0x00);
674 cfg.writeEntry("Schema","6"); 681 cfg.writeEntry("Schema","6");
675 colorMenu->setItemChecked(-6,TRUE); 682 colorMenu->setItemChecked(-6,TRUE);
676 } 683 }
677 if(iD==-7) { // black white 684 if(iD==-7) { // black white
678 foreground.setRgb(0x00,0x00,0x00); 685 foreground.setRgb(0x00,0x00,0x00);
679 background.setRgb(0xFF,0xFF,0xFF); 686 background.setRgb(0xFF,0xFF,0xFF);
680 cfg.writeEntry("Schema","7"); 687 cfg.writeEntry("Schema","7");
681 colorMenu->setItemChecked(-7,TRUE); 688 colorMenu->setItemChecked(-7,TRUE);
682 } 689 }
683 if(iD==-8) { // white black 690 if(iD==-8) { // white black
684 foreground.setRgb(0xFF,0xFF,0xFF); 691 foreground.setRgb(0xFF,0xFF,0xFF);
685 background.setRgb(0x00,0x00,0x00); 692 background.setRgb(0x00,0x00,0x00);
686 cfg.writeEntry("Schema","8"); 693 cfg.writeEntry("Schema","8");
687 colorMenu->setItemChecked(-8,TRUE); 694 colorMenu->setItemChecked(-8,TRUE);
688 } 695 }
689 if(iD==-10) {// Black, Red 696 if(iD==-10) {// Black, Red
690 foreground.setRgb(0x00,0x00,0x00); 697 foreground.setRgb(0x00,0x00,0x00);
691 background.setRgb(0xB2,0x18,0x18); 698 background.setRgb(0xB2,0x18,0x18);
692 cfg.writeEntry("Schema","10"); 699 cfg.writeEntry("Schema","10");
693 colorMenu->setItemChecked(-10,TRUE); 700 colorMenu->setItemChecked(-10,TRUE);
694 } 701 }
695 if(iD==-11) {// Red, Black 702 if(iD==-11) {// Red, Black
696 foreground.setRgb(230,31,31); //0xB2,0x18,0x18 703 foreground.setRgb(230,31,31); //0xB2,0x18,0x18
697 background.setRgb(0x00,0x00,0x00); 704 background.setRgb(0x00,0x00,0x00);
698 cfg.writeEntry("Schema","11"); 705 cfg.writeEntry("Schema","11");
699 colorMenu->setItemChecked(-11,TRUE); 706 colorMenu->setItemChecked(-11,TRUE);
700 } 707 }
701 if(iD==-12) {// Green, Yellow - is ugly 708 if(iD==-12) {// Green, Yellow - is ugly
702// foreground.setRgb(0x18,0xB2,0x18); 709// foreground.setRgb(0x18,0xB2,0x18);
703 foreground.setRgb(36,139,10); 710 foreground.setRgb(36,139,10);
704// background.setRgb(0xB2,0x68,0x18); 711// background.setRgb(0xB2,0x68,0x18);
705 background.setRgb(255,255,0); 712 background.setRgb(255,255,0);
706 cfg.writeEntry("Schema","12"); 713 cfg.writeEntry("Schema","12");
707 colorMenu->setItemChecked(-12,TRUE); 714 colorMenu->setItemChecked(-12,TRUE);
708 } 715 }
709 if(iD==-13) {// Blue, Magenta 716 if(iD==-13) {// Blue, Magenta
710 foreground.setRgb(0x18,0xB2,0xB2); 717 foreground.setRgb(0x18,0xB2,0xB2);
711 background.setRgb(0x18,0x18,0xB2); 718 background.setRgb(0x18,0x18,0xB2);
712 cfg.writeEntry("Schema","13"); 719 cfg.writeEntry("Schema","13");
713 colorMenu->setItemChecked(-13,TRUE); 720 colorMenu->setItemChecked(-13,TRUE);
714 } 721 }
715 if(iD==-14) {// Magenta, Blue 722 if(iD==-14) {// Magenta, Blue
716 foreground.setRgb(0x18,0x18,0xB2); 723 foreground.setRgb(0x18,0x18,0xB2);
717 background.setRgb(0x18,0xB2,0xB2); 724 background.setRgb(0x18,0xB2,0xB2);
718 cfg.writeEntry("Schema","14"); 725 cfg.writeEntry("Schema","14");
719 colorMenu->setItemChecked(-14,TRUE); 726 colorMenu->setItemChecked(-14,TRUE);
720 } 727 }
721 if(iD==-15) {// Cyan, White 728 if(iD==-15) {// Cyan, White
722 foreground.setRgb(0x18,0xB2,0xB2); 729 foreground.setRgb(0x18,0xB2,0xB2);
723 background.setRgb(0xFF,0xFF,0xFF); 730 background.setRgb(0xFF,0xFF,0xFF);
724 cfg.writeEntry("Schema","15"); 731 cfg.writeEntry("Schema","15");
725 colorMenu->setItemChecked(-15,TRUE); 732 colorMenu->setItemChecked(-15,TRUE);
726 } 733 }
727 if(iD==-16) {// White, Cyan 734 if(iD==-16) {// White, Cyan
728 background.setRgb(0x18,0xB2,0xB2); 735 background.setRgb(0x18,0xB2,0xB2);
729 foreground.setRgb(0xFF,0xFF,0xFF); 736 foreground.setRgb(0xFF,0xFF,0xFF);
730 cfg.writeEntry("Schema","16"); 737 cfg.writeEntry("Schema","16");
731 colorMenu->setItemChecked(-16,TRUE); 738 colorMenu->setItemChecked(-16,TRUE);
732 } 739 }
733 if(iD==-17) {// Black, Blue 740 if(iD==-17) {// Black, Blue
734 background.setRgb(0x00,0x00,0x00); 741 background.setRgb(0x00,0x00,0x00);
735 foreground.setRgb(0x18,0xB2,0xB2); 742 foreground.setRgb(0x18,0xB2,0xB2);
736 cfg.writeEntry("Schema","17"); 743 cfg.writeEntry("Schema","17");
737 colorMenu->setItemChecked(-17,TRUE); 744 colorMenu->setItemChecked(-17,TRUE);
738 } 745 }
739 if(iD==-18) {// Black, Gold 746 if(iD==-18) {// Black, Gold
740 background.setRgb(0x00,0x00,0x00); 747 background.setRgb(0x00,0x00,0x00);
741 foreground.setRgb(255,215,0); 748 foreground.setRgb(255,215,0);
742 cfg.writeEntry("Schema","18"); 749 cfg.writeEntry("Schema","18");
743 colorMenu->setItemChecked(-18,TRUE); 750 colorMenu->setItemChecked(-18,TRUE);
744 } 751 }
745 if(iD==-19) {// Custom 752#ifdef QWS_QT_OPIE
753 if(iD==-19) {
754// Custom
746 qDebug("do custom"); 755 qDebug("do custom");
747 if(fromMenu) { 756 if(fromMenu) {
748 ColorPopupMenu* penColorPopupMenu = new ColorPopupMenu(Qt::black, this, "foreground color"); 757 ColorPopupMenu* penColorPopupMenu = new ColorPopupMenu(Qt::black, this, "foreground color");
749 connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, 758 connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this,
750 SLOT(changeForegroundColor(const QColor&))); 759 SLOT(changeForegroundColor(const QColor&)));
751 penColorPopupMenu->exec(); 760 penColorPopupMenu->exec();
752 } 761 }
753 cfg.writeEntry("Schema","19"); 762 cfg.writeEntry("Schema","19");
754 if(!fromMenu) { 763 if(!fromMenu) {
755 foreground.setNamedColor(cfg.readEntry("foreground","")); 764 foreground.setNamedColor(cfg.readEntry("foreground",""));
756 background.setNamedColor(cfg.readEntry("background","")); 765 background.setNamedColor(cfg.readEntry("background",""));
757 } 766 }
758 fromMenu=FALSE; 767 fromMenu=FALSE;
759 colorMenu->setItemChecked(-19,TRUE); 768 colorMenu->setItemChecked(-19,TRUE);
760 } 769 }
761 770#endif
762 for (i = 0; i < TABLE_COLORS; i++) { 771 for (i = 0; i < TABLE_COLORS; i++) {
763 if(i==0 || i == 10) { 772 if(i==0 || i == 10) {
764 m_table[i].color = foreground; 773 m_table[i].color = foreground;
765 } 774 }
766 else if(i==1 || i == 11) { 775 else if(i==1 || i == 11) {
767 m_table[i].color = background; m_table[i].transparent=0; 776 m_table[i].color = background; m_table[i].transparent=0;
768 } 777 }
769 else 778 else
770 m_table[i].color = defaultCt[i].color; 779 m_table[i].color = defaultCt[i].color;
771 } 780 }
772 } 781 }
773 lastSelectedMenu = iD; 782 lastSelectedMenu = iD;
774 te->setColorTable(m_table); 783 te->setColorTable(m_table);
775 update(); 784 update();
776 785
777} 786}
778 787
779void Konsole::configMenuSelected(int iD) 788void Konsole::configMenuSelected(int iD)
780{ 789{
781 QString temp; 790// QString temp;
782 qDebug( temp.sprintf("configmenu %d",iD)); 791// qDebug( temp.sprintf("configmenu %d",iD));
783 TEWidget* te = getTe(); 792 TEWidget* te = getTe();
784 Config cfg("Konsole"); 793 Config cfg("Konsole");
785 cfg.setGroup("Menubar"); 794 cfg.setGroup("Menubar");
786 if( iD == -4) { 795 if( iD == -4) {
787 cfg.setGroup("Tabs"); 796 cfg.setGroup("Tabs");
788 QString tmp=cfg.readEntry("Position","Bottom"); 797 QString tmp=cfg.readEntry("Position","Bottom");
789 798
790 if(tmp=="Top") { 799 if(tmp=="Top") {
791 tab->setTabPosition(QTabWidget::Bottom); 800 tab->setTabPosition(QTabWidget::Bottom);
792 configMenu->changeItem( iD,"Tabs on Top"); 801 configMenu->changeItem( iD,"Tabs on Top");
793 cfg.writeEntry("Position","Bottom"); 802 cfg.writeEntry("Position","Bottom");
794 } else { 803 } else {
795 tab->setTabPosition(QTabWidget::Top); 804 tab->setTabPosition(QTabWidget::Top);
796 configMenu->changeItem( iD,"Tabs on Bottom"); 805 configMenu->changeItem( iD,"Tabs on Bottom");
797 cfg.writeEntry("Position","Top"); 806 cfg.writeEntry("Position","Top");
798 } 807 }
799 } 808 }
800 if( iD == -29) { 809 int i;
810#ifdef QWS_QT_OPIE
811i=-29;
812#else
813i=-28;
814#endif
815
816 if( iD == i) {
801 cfg.setGroup("ScrollBar"); 817 cfg.setGroup("ScrollBar");
802 bool b=cfg.readBoolEntry("HorzScroll",0); 818 bool b=cfg.readBoolEntry("HorzScroll",0);
803 b=!b; 819 b=!b;
804 cfg.writeEntry("HorzScroll", b ); 820 cfg.writeEntry("HorzScroll", b );
805 cfg.write(); 821 cfg.write();
806 doWrap(); 822 doWrap();
807 if(cfg.readNumEntry("Position",2) == 0) { 823 if(cfg.readNumEntry("Position",2) == 0) {
808 te->setScrollbarLocation(1); 824 te->setScrollbarLocation(1);
809 } else { 825 } else {
810 te->setScrollbarLocation(0); 826 te->setScrollbarLocation(0);
811 } 827 }
812 te->setScrollbarLocation( cfg.readNumEntry("Position",2)); 828 te->setScrollbarLocation( cfg.readNumEntry("Position",2));
813 } 829 }
814} 830}
815 831
816void Konsole::changeCommand(const QString &text, int c) 832void Konsole::changeCommand(const QString &text, int c)
817{ 833{
818 Config cfg("Konsole"); 834 Config cfg("Konsole");
819 cfg.setGroup("Commands"); 835 cfg.setGroup("Commands");
820 if(commonCmds[c] != text) { 836 if(commonCmds[c] != text) {
821 cfg.writeEntry(QString::number(c),text); 837 cfg.writeEntry(QString::number(c),text);
822 commonCombo->clearEdit(); 838 commonCombo->clearEdit();
823 commonCombo->setCurrentItem(c); 839 commonCombo->setCurrentItem(c);
824 } 840 }
825} 841}
826 842
827void Konsole::setColor() 843void Konsole::setColor()
828{ 844{
829 Config cfg("Konsole"); 845 Config cfg("Konsole");
830 cfg.setGroup("Colors"); 846 cfg.setGroup("Colors");
831 int scheme = cfg.readNumEntry("Schema",1); 847 int scheme = cfg.readNumEntry("Schema",1);
832 if(scheme != 1) colorMenuSelected( -scheme); 848 if(scheme != 1) colorMenuSelected( -scheme);
833} 849}
834 850
835void Konsole::scrollMenuSelected(int index) 851void Konsole::scrollMenuSelected(int index)
836{ 852{
837 qDebug( "scrollbar menu %d",index); 853 qDebug( "scrollbar menu %d",index);
838 TEWidget* te = getTe(); 854 TEWidget* te = getTe();
839 Config cfg("Konsole"); 855 Config cfg("Konsole");
840 cfg.setGroup("ScrollBar"); 856 cfg.setGroup("ScrollBar");
841 switch( index){ 857 switch( index){
842 case -25: 858 case -25:
843 te->setScrollbarLocation(0); 859 te->setScrollbarLocation(0);
844 cfg.writeEntry("Position",0); 860 cfg.writeEntry("Position",0);
845 break; 861 break;
846 case -26: 862 case -26:
847 te->setScrollbarLocation(1); 863 te->setScrollbarLocation(1);
848 cfg.writeEntry("Position",1); 864 cfg.writeEntry("Position",1);
849 break; 865 break;
850 case -27: 866 case -27:
851 te->setScrollbarLocation(2); 867 te->setScrollbarLocation(2);
852 cfg.writeEntry("Position",2); 868 cfg.writeEntry("Position",2);
853 break; 869 break;
854// case -29: { 870// case -29: {
855// bool b=cfg.readBoolEntry("HorzScroll",0); 871// bool b=cfg.readBoolEntry("HorzScroll",0);
856// cfg.writeEntry("HorzScroll", !b ); 872// cfg.writeEntry("HorzScroll", !b );
857// cfg.write(); 873// cfg.write();
858// if(cfg.readNumEntry("Position",2) == 0) { 874// if(cfg.readNumEntry("Position",2) == 0) {
859// te->setScrollbarLocation(1); 875// te->setScrollbarLocation(1);
860// te->setWrapAt(0); 876// te->setWrapAt(0);
861// } else { 877// } else {
862// te->setScrollbarLocation(0); 878// te->setScrollbarLocation(0);
863// te->setWrapAt(120); 879// te->setWrapAt(120);
864// } 880// }
865// te->setScrollbarLocation( cfg.readNumEntry("Position",2)); 881// te->setScrollbarLocation( cfg.readNumEntry("Position",2));
866// } 882// }
867// break; 883// break;
868 }; 884 };
869} 885}
870 886
871void Konsole::editCommandListMenuSelected(int iD) 887void Konsole::editCommandListMenuSelected(int iD)
872{ 888{
873// QString temp; 889// QString temp;
874// qDebug( temp.sprintf("edit command list %d",iD)); 890// qDebug( temp.sprintf("edit command list %d",iD));
875 TEWidget* te = getTe(); 891 TEWidget* te = getTe();
876 Config cfg("Konsole"); 892 Config cfg("Konsole");
877 cfg.setGroup("Menubar"); 893 cfg.setGroup("Menubar");
878 if( iD == -3) { 894 if( iD == -3) {
879 if(!secondToolBar->isHidden()) { 895 if(!secondToolBar->isHidden()) {
880 secondToolBar->hide(); 896 secondToolBar->hide();
881 configMenu->changeItem( iD,tr( "Show Command List" )); 897 configMenu->changeItem( iD,tr( "Show Command List" ));
882 cfg.writeEntry("Hidden","TRUE"); 898 cfg.writeEntry("Hidden","TRUE");
883 configMenu->setItemEnabled(-23 ,FALSE); 899 configMenu->setItemEnabled(-23 ,FALSE);
884 } else { 900 } else {
885 secondToolBar->show(); 901 secondToolBar->show();
886 configMenu->changeItem( iD,tr( "Hide Command List" )); 902 configMenu->changeItem( iD,tr( "Hide Command List" ));
887 cfg.writeEntry("Hidden","FALSE"); 903 cfg.writeEntry("Hidden","FALSE");
888 configMenu->setItemEnabled(-23 ,TRUE); 904 configMenu->setItemEnabled(-23 ,TRUE);
889 905
890 if(cfg.readEntry("EditEnabled","FALSE")=="TRUE") { 906 if(cfg.readEntry("EditEnabled","FALSE")=="TRUE") {
891 configMenu->setItemChecked(-23,TRUE); 907 configMenu->setItemChecked(-23,TRUE);
892 commonCombo->setEditable( TRUE ); 908 commonCombo->setEditable( TRUE );
893 } else { 909 } else {
894 configMenu->setItemChecked(-23,FALSE); 910 configMenu->setItemChecked(-23,FALSE);
895 commonCombo->setEditable( FALSE ); 911 commonCombo->setEditable( FALSE );
896 } 912 }
897 } 913 }
898 } 914 }
899 if( iD == -23) { 915 if( iD == -23) {
900 cfg.setGroup("Commands"); 916 cfg.setGroup("Commands");
901// qDebug("enableCommandEdit"); 917// qDebug("enableCommandEdit");
902 if( !configMenu->isItemChecked(iD) ) { 918 if( !configMenu->isItemChecked(iD) ) {
903 commonCombo->setEditable( TRUE ); 919 commonCombo->setEditable( TRUE );
904 configMenu->setItemChecked(iD,TRUE); 920 configMenu->setItemChecked(iD,TRUE);
905 commonCombo->setCurrentItem(0); 921 commonCombo->setCurrentItem(0);
906 cfg.writeEntry("EditEnabled","TRUE"); 922 cfg.writeEntry("EditEnabled","TRUE");
907 } else { 923 } else {
908 commonCombo->setEditable( FALSE ); 924 commonCombo->setEditable( FALSE );
909 configMenu->setItemChecked(iD,FALSE); 925 configMenu->setItemChecked(iD,FALSE);
910 cfg.writeEntry("EditEnabled","FALSE"); 926 cfg.writeEntry("EditEnabled","FALSE");
911 commonCombo->setFocusPolicy(QWidget::NoFocus); 927 commonCombo->setFocusPolicy(QWidget::NoFocus);
912 te->setFocus(); 928 te->setFocus();
913 } 929 }
914 } 930 }
915 if(iD == -24) { 931 if(iD == -24) {
916 // "edit commands" 932 // "edit commands"
917 CommandEditDialog *m = new CommandEditDialog(this); 933 CommandEditDialog *m = new CommandEditDialog(this);
918 connect(m,SIGNAL(commandsEdited()),this,SLOT(initCommandList())); 934 connect(m,SIGNAL(commandsEdited()),this,SLOT(initCommandList()));
919 m->showMaximized(); 935 m->showMaximized();
920 } 936 }
921 937
922} 938}
923 939
924// $QPEDIR/bin/qcop QPE/Application/embeddedkonsole 'setDocument(QString)' 'ssh -V' 940// $QPEDIR/bin/qcop QPE/Application/embeddedkonsole 'setDocument(QString)' 'ssh -V'
925void Konsole::setDocument( const QString &cmd) { 941void Konsole::setDocument( const QString &cmd) {
926 newSession(); 942 newSession();
927 TEWidget* te = getTe(); 943 TEWidget* te = getTe();
928 if(cmd.find("-e", 0, TRUE) != -1) { 944 if(cmd.find("-e", 0, TRUE) != -1) {
929 QString cmd2; 945 QString cmd2;
930 cmd2=cmd.right(cmd.length()-3)+" &"; 946 cmd2=cmd.right(cmd.length()-3)+" &";
931 system(cmd2.latin1()); 947 system(cmd2.latin1());
932 if(startUp <= 1 && nsessions < 2) { 948 if(startUp <= 1 && nsessions < 2) {
933 doneSession(getTe()->currentSession, 0); 949 doneSession(getTe()->currentSession, 0);
934 exit(0); 950 exit(0);
935 } else 951 } else
936 doneSession(getTe()->currentSession, 0); 952 doneSession(getTe()->currentSession, 0);
937 } else { 953 } else {
938 if (te != 0) { 954 if (te != 0) {
939 te->emitText(cmd+"\r"); 955 te->emitText(cmd+"\r");
940 } 956 }
941 } 957 }
942 startUp++; 958 startUp++;
943} 959}
944 960
945void Konsole::parseCommandLine() { 961void Konsole::parseCommandLine() {
946 QString cmd; 962 QString cmd;
947 // newSession(); 963 // newSession();
948 for (int i=1;i< qApp->argc();i++) { 964 for (int i=1;i< qApp->argc();i++) {
949 if( QString(qApp->argv()[i]) == "-e") { 965 if( QString(qApp->argv()[i]) == "-e") {
950 i++; 966 i++;
951 for ( int j=i;j< qApp->argc();j++) { 967 for ( int j=i;j< qApp->argc();j++) {
952 cmd+=QString(qApp->argv()[j])+" "; 968 cmd+=QString(qApp->argv()[j])+" ";
953 } 969 }
954 cmd.stripWhiteSpace(); 970 cmd.stripWhiteSpace();
955 system(cmd.latin1()); 971 system(cmd.latin1());
956 exit(0);//close(); 972 exit(0);//close();
957 } // end -e switch 973 } // end -e switch
958 } 974 }
959 startUp++; 975 startUp++;
960} 976}
961 977
962void Konsole::changeForegroundColor(const QColor &color) { 978void Konsole::changeForegroundColor(const QColor &color) {
963 Config cfg("Konsole"); 979 Config cfg("Konsole");
964 cfg.setGroup("Colors"); 980 cfg.setGroup("Colors");
965 int r, g, b; 981 int r, g, b;
966 color.rgb(&r,&g,&b); 982 color.rgb(&r,&g,&b);
967 foreground.setRgb(r,g,b); 983 foreground.setRgb(r,g,b);
968// QString colors; 984// QString colors;
969// colors.sprintf("%d,%d,%d"color.red,color.green,color.blue); 985// colors.sprintf("%d,%d,%d"color.red,color.green,color.blue);
970 cfg.writeEntry("foreground",color.name()); 986 cfg.writeEntry("foreground",color.name());
971 cfg.write(); 987 cfg.write();
972 988
973qDebug("do other dialog"); 989qDebug("do other dialog");
990#ifdef QWS_QT_OPIE
991
974 ColorPopupMenu* penColorPopupMenu2 = new ColorPopupMenu(Qt::black, this,"background color"); 992 ColorPopupMenu* penColorPopupMenu2 = new ColorPopupMenu(Qt::black, this,"background color");
975 connect(penColorPopupMenu2, SIGNAL(colorSelected(const QColor&)), this, 993 connect(penColorPopupMenu2, SIGNAL(colorSelected(const QColor&)), this,
976 SLOT(changeBackgroundColor(const QColor&))); 994 SLOT(changeBackgroundColor(const QColor&)));
977 penColorPopupMenu2->exec(); 995 penColorPopupMenu2->exec();
978 996#endif
979} 997}
980 998
981void Konsole::changeBackgroundColor(const QColor &color) { 999void Konsole::changeBackgroundColor(const QColor &color) {
982 1000
983 qDebug("Change background"); 1001 qDebug("Change background");
984 Config cfg("Konsole"); 1002 Config cfg("Konsole");
985 cfg.setGroup("Colors"); 1003 cfg.setGroup("Colors");
986 int r, g, b; 1004 int r, g, b;
987 color.rgb(&r,&g,&b); 1005 color.rgb(&r,&g,&b);
988 background.setRgb(r,g,b); 1006 background.setRgb(r,g,b);
989// QString colors; 1007// QString colors;
990// colors.sprintf("%d,%d,%d"color.red,color.green,color.blue); 1008// colors.sprintf("%d,%d,%d"color.red,color.green,color.blue);
991 cfg.writeEntry("background",color.name()); 1009 cfg.writeEntry("background",color.name());
992 cfg.write(); 1010 cfg.write();
993} 1011}
994 1012
995void Konsole::doWrap() { 1013void Konsole::doWrap() {
996 Config cfg("Konsole"); 1014int i;
1015#ifdef QWS_QT_OPIE
1016i=-29;
1017#else
1018i=-28;
1019#endif
1020
1021 Config cfg("Konsole");
997 cfg.setGroup("ScrollBar"); 1022 cfg.setGroup("ScrollBar");
998 TEWidget* te = getTe(); 1023 TEWidget* te = getTe();
999 if( !cfg.readBoolEntry("HorzScroll",0)) { 1024 if( !cfg.readBoolEntry("HorzScroll",0)) {
1000 te->setWrapAt(0); 1025 te->setWrapAt(0);
1001 configMenu->setItemChecked(-29,FALSE); 1026 configMenu->setItemChecked( i,FALSE);
1002 } else { 1027 } else {
1003 te->setWrapAt(90); 1028 te->setWrapAt(90);
1004// te->setWrapAt(120); 1029// te->setWrapAt(120);
1005 configMenu->setItemChecked(-29,TRUE); 1030 configMenu->setItemChecked( i,TRUE);
1006 } 1031 }
1007} 1032}