summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/embeddedkonsole/konsole.cpp45
-rw-r--r--core/apps/embeddedkonsole/konsole.h3
2 files changed, 45 insertions, 3 deletions
diff --git a/core/apps/embeddedkonsole/konsole.cpp b/core/apps/embeddedkonsole/konsole.cpp
index 217d8d8..16ff4df 100644
--- a/core/apps/embeddedkonsole/konsole.cpp
+++ b/core/apps/embeddedkonsole/konsole.cpp
@@ -5,32 +5,33 @@
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 22
22#include <qpe/resource.h> 23#include <qpe/resource.h>
23 24
24#include <qdir.h> 25#include <qdir.h>
25#include <qevent.h> 26#include <qevent.h>
26#include <qdragobject.h> 27#include <qdragobject.h>
27#include <qobjectlist.h> 28#include <qobjectlist.h>
28#include <qtoolbutton.h> 29#include <qtoolbutton.h>
29#include <qpe/qpetoolbar.h> 30#include <qpe/qpetoolbar.h>
30#include <qpushbutton.h> 31#include <qpushbutton.h>
31#include <qfontdialog.h> 32#include <qfontdialog.h>
32#include <qglobal.h> 33#include <qglobal.h>
33#include <qpainter.h> 34#include <qpainter.h>
34#include <qpe/qpemenubar.h> 35#include <qpe/qpemenubar.h>
35#include <qmessagebox.h> 36#include <qmessagebox.h>
36#include <qaction.h> 37#include <qaction.h>
@@ -188,33 +189,33 @@ void Konsole::initCommandList()
188 commonCombo->insertItem(commonCmds[i],i); 189 commonCombo->insertItem(commonCmds[i],i);
189 } 190 }
190 } else { 191 } else {
191 for (int i = 0; i < 100; i++) { 192 for (int i = 0; i < 100; i++) {
192 if (!(cfg.readEntry( QString::number(i),"")).isEmpty()) 193 if (!(cfg.readEntry( QString::number(i),"")).isEmpty())
193 commonCombo->insertItem((cfg.readEntry( QString::number(i),""))); 194 commonCombo->insertItem((cfg.readEntry( QString::number(i),"")));
194 } 195 }
195 } 196 }
196 197
197} 198}
198 199
199void Konsole::init(const char* _pgm, QStrList & _args) 200void Konsole::init(const char* _pgm, QStrList & _args)
200{ 201{
201 b_scroll = TRUE; // histon; 202 b_scroll = TRUE; // histon;
202 n_keytab = 0; 203 n_keytab = 0;
203 n_render = 0; 204 n_render = 0;
204 205 startUp=0;
205 setCaption( tr("Terminal") ); 206 setCaption( tr("Terminal") );
206 setIcon( Resource::loadPixmap( "konsole" ) ); 207 setIcon( Resource::loadPixmap( "konsole" ) );
207 208
208 Config cfg("Konsole"); 209 Config cfg("Konsole");
209 cfg.setGroup("Konsole"); 210 cfg.setGroup("Konsole");
210 QString tmp; 211 QString tmp;
211 // initialize the list of allowed fonts /////////////////////////////////// 212 // initialize the list of allowed fonts ///////////////////////////////////
212 cfont = cfg.readNumEntry("FontID", 1); 213 cfont = cfg.readNumEntry("FontID", 1);
213 QFont f = QFont("Micro", 4, QFont::Normal); 214 QFont f = QFont("Micro", 4, QFont::Normal);
214 f.setFixedPitch(TRUE); 215 f.setFixedPitch(TRUE);
215 fonts.append(new VTFont(tr("Micro"), f)); 216 fonts.append(new VTFont(tr("Micro"), f));
216 217
217 f = QFont("Fixed", 7, QFont::Normal); 218 f = QFont("Fixed", 7, QFont::Normal);
218 f.setFixedPitch(TRUE); 219 f.setFixedPitch(TRUE);
219 fonts.append(new VTFont(tr("Small Fixed"), f)); 220 fonts.append(new VTFont(tr("Small Fixed"), f));
220 221
@@ -351,58 +352,58 @@ void Konsole::init(const char* _pgm, QStrList & _args)
351 scrollMenu->insertItem("Right"); 352 scrollMenu->insertItem("Right");
352 configMenu->insertItem("ScrollBar",scrollMenu); 353 configMenu->insertItem("ScrollBar",scrollMenu);
353 354
354 // create applications ///////////////////////////////////////////////////// 355 // create applications /////////////////////////////////////////////////////
355 setCentralWidget(tab); 356 setCentralWidget(tab);
356 357
357 // load keymaps //////////////////////////////////////////////////////////// 358 // load keymaps ////////////////////////////////////////////////////////////
358 KeyTrans::loadAll(); 359 KeyTrans::loadAll();
359 for (int i = 0; i < KeyTrans::count(); i++) 360 for (int i = 0; i < KeyTrans::count(); i++)
360 { KeyTrans* s = KeyTrans::find(i); 361 { KeyTrans* s = KeyTrans::find(i);
361 assert( s ); 362 assert( s );
362 } 363 }
363 364
364 se_pgm = _pgm; 365 se_pgm = _pgm;
365 se_args = _args; 366 se_args = _args;
366 367
368parseCommandLine();
367 // read and apply default values /////////////////////////////////////////// 369 // read and apply default values ///////////////////////////////////////////
368 resize(321, 321); // Dummy. 370 resize(321, 321); // Dummy.
369 QSize currentSize = size(); 371 QSize currentSize = size();
370 if (currentSize != size()) 372 if (currentSize != size())
371 defaultSize = size(); 373 defaultSize = size();
372
373} 374}
374 375
375void Konsole::show() 376void Konsole::show()
376{ 377{
377 if ( !nsessions ) { 378 if ( !nsessions ) {
378 newSession(); 379 newSession();
379 } 380 }
380 QMainWindow::show(); 381 QMainWindow::show();
381} 382}
382 383
383void Konsole::initSession(const char*, QStrList &) 384void Konsole::initSession(const char*, QStrList &)
384{ 385{
385 QMainWindow::show(); 386 QMainWindow::show();
386} 387}
387 388
388Konsole::~Konsole() 389Konsole::~Konsole()
389{ 390{
390 while (nsessions > 0) { 391 while (nsessions > 0) {
391 doneSession(getTe()->currentSession, 0); 392 doneSession(getTe()->currentSession, 0);
392 } 393 }
393 394
394 Config cfg("Konsole"); 395 Config cfg("Konsole");
395 cfg.setGroup("Konsole"); 396 cfg.setGroup("Konsole");
396 cfg.writeEntry("FontID", cfont); 397 cfg.writeEntry("FontID", cfont);
397} 398}
398 399
399void Konsole::fontChanged(int f) 400void Konsole::fontChanged(int f)
400{ 401{
401 VTFont* font = fonts.at(f); 402 VTFont* font = fonts.at(f);
402 if (font != 0) { 403 if (font != 0) {
403 for(uint i = 0; i < fonts.count(); i++) { 404 for(uint i = 0; i < fonts.count(); i++) {
404 fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE); 405 fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE);
405 } 406 }
406 407
407 cfont = f; 408 cfont = f;
408 409
@@ -830,16 +831,54 @@ void Konsole::editCommandListMenuSelected(int iD)
830 } else { 831 } else {
831 commonCombo->setEditable( FALSE ); 832 commonCombo->setEditable( FALSE );
832 configMenu->setItemChecked(iD,FALSE); 833 configMenu->setItemChecked(iD,FALSE);
833 cfg.writeEntry("EditEnabled","FALSE"); 834 cfg.writeEntry("EditEnabled","FALSE");
834 commonCombo->setFocusPolicy(QWidget::NoFocus); 835 commonCombo->setFocusPolicy(QWidget::NoFocus);
835 te->setFocus(); 836 te->setFocus();
836 } 837 }
837 } 838 }
838 if(iD == -23) { 839 if(iD == -23) {
839 // "edit commands" 840 // "edit commands"
840 CommandEditDialog *m = new CommandEditDialog(this); 841 CommandEditDialog *m = new CommandEditDialog(this);
841 connect(m,SIGNAL(commandsEdited()),this,SLOT(initCommandList())); 842 connect(m,SIGNAL(commandsEdited()),this,SLOT(initCommandList()));
842 m->showMaximized(); 843 m->showMaximized();
843 } 844 }
844 845
845} 846}
847
848// $QPEDIR/bin/qcop QPE/Application/embeddedkonsole 'setDocument(QString)' 'ssh -V'
849void Konsole::setDocument( const QString &cmd) {
850 newSession();
851 TEWidget* te = getTe();
852 if(cmd.find("-e", 0, TRUE) != -1) {
853 QString cmd2;
854 cmd2=cmd.right(cmd.length()-3)+" &";
855 system(cmd2.latin1());
856 if(startUp <= 1 && nsessions < 2) {
857 doneSession(getTe()->currentSession, 0);
858 exit(0);
859 } else
860 doneSession(getTe()->currentSession, 0);
861 } else {
862 if (te != 0) {
863 te->emitText(cmd+"\r");
864 }
865 }
866 startUp++;
867}
868
869void Konsole::parseCommandLine() {
870 QString cmd;
871 // newSession();
872 for (int i=1;i< qApp->argc();i++) {
873 if( QString(qApp->argv()[i]) == "-e") {
874 i++;
875 for ( int j=i;j< qApp->argc();j++) {
876 cmd+=QString(qApp->argv()[j])+" ";
877 }
878 cmd.stripWhiteSpace();
879 system(cmd.latin1());
880 exit(0);//close();
881 } // end -e switch
882 }
883 startUp++;
884}
diff --git a/core/apps/embeddedkonsole/konsole.h b/core/apps/embeddedkonsole/konsole.h
index b508cf8..40edaec 100644
--- a/core/apps/embeddedkonsole/konsole.h
+++ b/core/apps/embeddedkonsole/konsole.h
@@ -41,51 +41,54 @@
41class EKNumTabWidget; 41class EKNumTabWidget;
42 42
43class Konsole : public QMainWindow 43class Konsole : public QMainWindow
44{ 44{
45Q_OBJECT 45Q_OBJECT
46 46
47public: 47public:
48 48
49 Konsole(QWidget* parent = 0, const char* name = 0, WFlags fl = 0); 49 Konsole(QWidget* parent = 0, const char* name = 0, WFlags fl = 0);
50 Konsole(const char * name, const char* pgm, QStrList & _args, int histon); 50 Konsole(const char * name, const char* pgm, QStrList & _args, int histon);
51 ~Konsole(); 51 ~Konsole();
52 void setColLin(int columns, int lines); 52 void setColLin(int columns, int lines);
53 QPEToolBar *secondToolBar; 53 QPEToolBar *secondToolBar;
54 void show(); 54 void show();
55 void setColor(); 55 void setColor();
56 int lastSelectedMenu; 56 int lastSelectedMenu;
57 int startUp;
57private slots: 58private slots:
59 void setDocument(const QString &);
58 void doneSession(TESession*,int); 60 void doneSession(TESession*,int);
59 void changeColumns(int); 61 void changeColumns(int);
60 void fontChanged(int); 62 void fontChanged(int);
61 void configMenuSelected(int ); 63 void configMenuSelected(int );
62 void colorMenuSelected(int); 64 void colorMenuSelected(int);
63 void enterCommand(int); 65 void enterCommand(int);
64 void hitEnter(); 66 void hitEnter();
65 void hitSpace(); 67 void hitSpace();
66 void hitTab(); 68 void hitTab();
67 void hitPaste(); 69 void hitPaste();
68 void hitUp(); 70 void hitUp();
69 void hitDown(); 71 void hitDown();
70 void switchSession(QWidget *); 72 void switchSession(QWidget *);
71 void newSession(); 73 void newSession();
72 void changeCommand(const QString &, int); 74 void changeCommand(const QString &, int);
73 void initCommandList(); 75 void initCommandList();
74 void scrollMenuSelected(int); 76 void scrollMenuSelected(int);
75 void editCommandListMenuSelected(int); 77 void editCommandListMenuSelected(int);
78 void parseCommandLine();
76private: 79private:
77 void init(const char* _pgm, QStrList & _args); 80 void init(const char* _pgm, QStrList & _args);
78 void initSession(const char* _pgm, QStrList & _args); 81 void initSession(const char* _pgm, QStrList & _args);
79 void runSession(TESession* s); 82 void runSession(TESession* s);
80 void setColorPixmaps(); 83 void setColorPixmaps();
81 void setHistory(bool); 84 void setHistory(bool);
82 QSize calcSize(int columns, int lines); 85 QSize calcSize(int columns, int lines);
83 TEWidget* getTe(); 86 TEWidget* getTe();
84 QStringList commands; 87 QStringList commands;
85 88
86private: 89private:
87 class VTFont 90 class VTFont
88 { 91 {
89 public: 92 public:
90 VTFont(QString name, QFont& font) 93 VTFont(QString name, QFont& font)
91 { 94 {