summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-02-01 14:11:46 (UTC)
committer llornkcor <llornkcor>2002-02-01 14:11:46 (UTC)
commit07ec85f797cad04431df30855a81b88f06fe27d3 (patch) (unidiff)
tree72b6e4a2f63f47df4214df486333313128011840
parent2802e5a2b474101a50bf95e707061ca5542876fd (diff)
downloadopie-07ec85f797cad04431df30855a81b88f06fe27d3.zip
opie-07ec85f797cad04431df30855a81b88f06fe27d3.tar.gz
opie-07ec85f797cad04431df30855a81b88f06fe27d3.tar.bz2
Added editable commandlist, tabs position, and user selectable colors.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/embeddedkonsole/TECommon.h6
-rw-r--r--core/apps/embeddedkonsole/TEWidget.cpp98
-rw-r--r--core/apps/embeddedkonsole/TEWidget.h8
-rw-r--r--core/apps/embeddedkonsole/konsole.cpp430
-rw-r--r--core/apps/embeddedkonsole/konsole.h22
5 files changed, 412 insertions, 152 deletions
diff --git a/core/apps/embeddedkonsole/TECommon.h b/core/apps/embeddedkonsole/TECommon.h
index 261d51b..5db41ad 100644
--- a/core/apps/embeddedkonsole/TECommon.h
+++ b/core/apps/embeddedkonsole/TECommon.h
@@ -1,28 +1,28 @@
1/* -------------------------------------------------------------------------- */ 1/* -------------------------------------------------------------------------- */
2/* */ 2/* */
3/* [TECommon.h] Common Definitions */ 3/* [TECommon.h] Common Definitions */
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 for KDE */ 9/* This file is part of Konsole - an X terminal for KDE */
10/* */ 10/* */
11/* -------------------------------------------------------------------------- */ 11/* -------------------------------------------------------------------------- */
12 /* */ 12/* */
13/* Ported Konsole to Qt/Embedded */ 13/* Ported Konsole to Qt/Embedded */
14 /* */ 14/* */
15/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ 15/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */
16 /* */ 16/* */
17/* -------------------------------------------------------------------------- */ 17/* -------------------------------------------------------------------------- */
18 18
19/*! \file TECommon.h 19/*! \file TECommon.h
20 \brief Definitions shared between TEScreen and TEWidget. 20 \brief Definitions shared between TEScreen and TEWidget.
21*/ 21*/
22 22
23#ifndef TECOMMON_H 23#ifndef TECOMMON_H
24#define TECOMMON_H 24#define TECOMMON_H
25 25
26#include <qcolor.h> 26#include <qcolor.h>
27 27
28#ifndef BOOL 28#ifndef BOOL
diff --git a/core/apps/embeddedkonsole/TEWidget.cpp b/core/apps/embeddedkonsole/TEWidget.cpp
index dc83998..f10bfb2 100644
--- a/core/apps/embeddedkonsole/TEWidget.cpp
+++ b/core/apps/embeddedkonsole/TEWidget.cpp
@@ -1,30 +1,29 @@
1/* ------------------------------------------------------------------------ */ 1/* ------------------------------------------------------------------------ */
2/* */ 2/* */
3/* [TEWidget.C] Terminal Emulation Widget */ 3/* [TEWidget.C] Terminal Emulation Widget */
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 for KDE */ 9/* This file is part of Konsole - an X terminal for KDE */
10/* */ 10/* */
11/* ------------------------------------------------------------------------ */ 11/* ------------------------------------------------------------------------ */
12 /* */ 12/* */
13/* Ported Konsole to Qt/Embedded */ 13/* Ported Konsole to Qt/Embedded */
14 /* */ 14/* */
15/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ 15/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */
16 /* */ 16/* */
17/* -------------------------------------------------------------------------- */ 17/* -------------------------------------------------------------------------- */
18
19/*! \class TEWidget 18/*! \class TEWidget
20 19
21 \brief Visible screen contents 20 \brief Visible screen contents
22 21
23 This class is responsible to map the `image' of a terminal emulation to the 22 This class is responsible to map the `image' of a terminal emulation to the
24 display. All the dependency of the emulation to a specific GUI or toolkit is 23 display. All the dependency of the emulation to a specific GUI or toolkit is
25 localized here. Further, this widget has no knowledge about being part of an 24 localized here. Further, this widget has no knowledge about being part of an
26 emulation, it simply work within the terminal emulation framework by exposing 25 emulation, it simply work within the terminal emulation framework by exposing
27 size and key events and by being ordered to show a new image. 26 size and key events and by being ordered to show a new image.
28 27
29 <ul> 28 <ul>
30 <li> The internal image has the size of the widget (evtl. rounded up) 29 <li> The internal image has the size of the widget (evtl. rounded up)
@@ -106,46 +105,52 @@ static const ColorEntry base_color_table[TABLE_COLORS] =
106{ 105{
107 // Fixme: could add faint colors here, also. 106 // Fixme: could add faint colors here, also.
108 // normal 107 // normal
109 ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 1, 0 ), // Dfore, Dback 108 ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 1, 0 ), // Dfore, Dback
110 ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0x18), 0, 0 ), // Black, Red 109 ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0x18), 0, 0 ), // Black, Red
111 ColorEntry(QColor(0x18,0xB2,0x18), 0, 0 ), ColorEntry( QColor(0xB2,0x68,0x18), 0, 0 ), // Green, Yellow 110 ColorEntry(QColor(0x18,0xB2,0x18), 0, 0 ), ColorEntry( QColor(0xB2,0x68,0x18), 0, 0 ), // Green, Yellow
112 ColorEntry(QColor(0x18,0x18,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), // Blue, Magenta 111 ColorEntry(QColor(0x18,0x18,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), // Blue, Magenta
113 ColorEntry(QColor(0x18,0xB2,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 0, 0 ), // Cyan, White 112 ColorEntry(QColor(0x18,0xB2,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 0, 0 ), // Cyan, White
114 // intensiv 113 // intensiv
115 ColorEntry(QColor(0x00,0x00,0x00), 0, 1 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 1, 0 ), 114 ColorEntry(QColor(0x00,0x00,0x00), 0, 1 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 1, 0 ),
116 ColorEntry(QColor(0x68,0x68,0x68), 0, 0 ), ColorEntry( QColor(0xFF,0x54,0x54), 0, 0 ), 115 ColorEntry(QColor(0x68,0x68,0x68), 0, 0 ), ColorEntry( QColor(0xFF,0x54,0x54), 0, 0 ),
117 ColorEntry(QColor(0x54,0xFF,0x54), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0x54), 0, 0 ), 116 ColorEntry(QColor(0x54,0xFF,0x54), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0x54), 0, 0 ),
118 ColorEntry(QColor(0x54,0x54,0xFF), 0, 0 ), ColorEntry( QColor(0xFF,0x54,0xFF), 0, 0 ), 117 ColorEntry(QColor(0x54,0x54,0xFF), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ),
119 ColorEntry(QColor(0x54,0xFF,0xFF), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 0, 0 ) 118 ColorEntry(QColor(0x54,0xFF,0xFF), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 0, 0 )
120}; 119};
121 120
122/* Note that we use ANSI color order (bgr), while IBMPC color order is (rgb) 121/* Note that we use ANSI color order (bgr), while IBMPC color order is (rgb)
123 122
124 Code 0 1 2 3 4 5 6 7 123 Code 0 1 2 3 4 5 6 7
125 ----------- ------- ------- ------- ------- ------- ------- ------- ------- 124 ----------- ------- ------- ------- ------- ------- ------- ------- -------
126 ANSI (bgr) Black Red Green Yellow Blue Magenta Cyan White 125 ANSI (bgr) Black Red Green Yellow Blue Magenta Cyan White
127 IBMPC (rgb) Black Blue Green Cyan Red Magenta Yellow White 126 IBMPC (rgb) Black Blue Green Cyan Red Magenta Yellow White
128*/ 127*/
129 128
130QColor TEWidget::getDefaultBackColor() 129QColor TEWidget::getDefaultBackColor()
131{ 130{
132 return color_table[DEFAULT_BACK_COLOR].color; 131 return color_table[DEFAULT_BACK_COLOR].color;
133} 132}
134 133
135const ColorEntry* TEWidget::getColorTable() const 134const ColorEntry* TEWidget::getColorTable() const
136{ 135{
137 return color_table; 136 return color_table;
138} 137}
139 138
139const ColorEntry* TEWidget::getdefaultColorTable() const
140{
141 return base_color_table;
142}
143
144
140const QPixmap *TEWidget::backgroundPixmap() 145const QPixmap *TEWidget::backgroundPixmap()
141{ 146{
142 static QPixmap *bg = new QPixmap("~/qpim/main/pics/faded_bg.xpm"); 147 static QPixmap *bg = new QPixmap("~/qpim/main/pics/faded_bg.xpm");
143 const QPixmap *pm = bg; 148 const QPixmap *pm = bg;
144 return pm; 149 return pm;
145} 150}
146 151
147void TEWidget::setColorTable(const ColorEntry table[]) 152void TEWidget::setColorTable(const ColorEntry table[])
148{ 153{
149 for (int i = 0; i < TABLE_COLORS; i++) color_table[i] = table[i]; 154 for (int i = 0; i < TABLE_COLORS; i++) color_table[i] = table[i];
150 155
151 const QPixmap* pm = backgroundPixmap(); 156 const QPixmap* pm = backgroundPixmap();
@@ -231,40 +236,39 @@ void TEWidget::fontChange(const QFont &)
231{ 236{
232 QFontMetrics fm(font()); 237 QFontMetrics fm(font());
233 font_h = fm.height(); 238 font_h = fm.height();
234 font_w = fm.maxWidth(); 239 font_w = fm.maxWidth();
235 font_a = fm.ascent(); 240 font_a = fm.ascent();
236//printf("font_h: %d\n",font_h); 241//printf("font_h: %d\n",font_h);
237//printf("font_w: %d\n",font_w); 242//printf("font_w: %d\n",font_w);
238//printf("font_a: %d\n",font_a); 243//printf("font_a: %d\n",font_a);
239//printf("charset: %s\n",QFont::encodingName(font().charSet()).ascii()); 244//printf("charset: %s\n",QFont::encodingName(font().charSet()).ascii());
240//printf("rawname: %s\n",font().rawName().ascii()); 245//printf("rawname: %s\n",font().rawName().ascii());
241 fontMap = 246 fontMap =
242#if QT_VERSION < 300 247#if QT_VERSION < 300
243 strcmp(QFont::encodingName(font().charSet()).ascii(),"iso10646") 248 strcmp(QFont::encodingName(font().charSet()).ascii(),"iso10646")
244 ? vt100extended 249 ? vt100extended
245 : 250 :
246#endif 251#endif
247 identicalMap; 252 identicalMap;
248 propagateSize(); 253 propagateSize();
249 update(); 254 update();
250} 255}
251 256
252void TEWidget::setVTFont(const QFont& f) 257void TEWidget::setVTFont(const QFont& f)
253{ 258{
254 QFrame::setFont(f); 259 QFrame::setFont(f);
255} 260}
256 261
257QFont TEWidget::getVTFont() 262QFont TEWidget::getVTFont() {
258{
259 return font(); 263 return font();
260} 264}
261 265
262void TEWidget::setFont(const QFont &) 266void TEWidget::setFont(const QFont &)
263{ 267{
264 // ignore font change request if not coming from konsole itself 268 // ignore font change request if not coming from konsole itself
265} 269}
266 270
267/* ------------------------------------------------------------------------- */ 271/* ------------------------------------------------------------------------- */
268/* */ 272/* */
269/* Constructor / Destructor */ 273/* Constructor / Destructor */
270/* */ 274/* */
@@ -638,25 +642,25 @@ void TEWidget::mousePressEvent(QMouseEvent* ev)
638//printf("press top left [%d,%d] by=%d\n",tLx,tLy, bY); 642//printf("press top left [%d,%d] by=%d\n",tLx,tLy, bY);
639 if ( ev->button() == LeftButton) 643 if ( ev->button() == LeftButton)
640 { 644 {
641 QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); 645 QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h);
642 646
643 if ( ev->state() & ControlButton ) preserve_line_breaks = FALSE ; 647 if ( ev->state() & ControlButton ) preserve_line_breaks = FALSE ;
644 648
645 if (mouse_marks || (ev->state() & ShiftButton)) 649 if (mouse_marks || (ev->state() & ShiftButton))
646 { 650 {
647 emit clearSelectionSignal(); 651 emit clearSelectionSignal();
648 iPntSel = pntSel = pos; 652 iPntSel = pntSel = pos;
649 actSel = 1; // left mouse button pressed but nothing selected yet. 653 actSel = 1; // left mouse button pressed but nothing selected yet.
650 grabMouse( /*crossCursor*/ ); // handle with care! 654 grabMouse( /*crossCursor*/ ); // handle with care!
651 } 655 }
652 else 656 else
653 { 657 {
654 emit mouseSignal( 0, pos.x() + 1, pos.y() + 1 ); // left button 658 emit mouseSignal( 0, pos.x() + 1, pos.y() + 1 ); // left button
655 } 659 }
656 } 660 }
657 if ( ev->button() == MidButton ) 661 if ( ev->button() == MidButton )
658 { 662 {
659 emitSelection(); 663 emitSelection();
660 } 664 }
661 if ( ev->button() == RightButton ) // Configure 665 if ( ev->button() == RightButton ) // Configure
662 { 666 {
@@ -704,27 +708,27 @@ void TEWidget::mouseMoveEvent(QMouseEvent* ev)
704 708
705 QPoint here = QPoint((pos.x()-tLx-blX)/font_w,(pos.y()-tLy-bY)/font_h); 709 QPoint here = QPoint((pos.x()-tLx-blX)/font_w,(pos.y()-tLy-bY)/font_h);
706 QPoint ohere; 710 QPoint ohere;
707 bool swapping = FALSE; 711 bool swapping = FALSE;
708 712
709 if ( word_selection_mode ) 713 if ( word_selection_mode )
710 { 714 {
711 // Extend to word boundaries 715 // Extend to word boundaries
712 int i; 716 int i;
713 int selClass; 717 int selClass;
714 718
715 bool left_not_right = ( here.y() < iPntSel.y() || 719 bool left_not_right = ( here.y() < iPntSel.y() ||
716 here.y() == iPntSel.y() && here.x() < iPntSel.x() ); 720 here.y() == iPntSel.y() && here.x() < iPntSel.x() );
717 bool old_left_not_right = ( pntSel.y() < iPntSel.y() || 721 bool old_left_not_right = ( pntSel.y() < iPntSel.y() ||
718 pntSel.y() == iPntSel.y() && pntSel.x() < iPntSel.x() ); 722 pntSel.y() == iPntSel.y() && pntSel.x() < iPntSel.x() );
719 swapping = left_not_right != old_left_not_right; 723 swapping = left_not_right != old_left_not_right;
720 724
721 // Find left (left_not_right ? from here : from start) 725 // Find left (left_not_right ? from here : from start)
722 QPoint left = left_not_right ? here : iPntSel; 726 QPoint left = left_not_right ? here : iPntSel;
723 i = loc(left.x(),left.y()); 727 i = loc(left.x(),left.y());
724 selClass = charClass(image[i].c); 728 selClass = charClass(image[i].c);
725 while ( left.x() > 0 && charClass(image[i-1].c) == selClass ) 729 while ( left.x() > 0 && charClass(image[i-1].c) == selClass )
726 { i--; left.rx()--; } 730 { i--; left.rx()--; }
727 731
728 // Find left (left_not_right ? from start : from here) 732 // Find left (left_not_right ? from start : from here)
729 QPoint right = left_not_right ? iPntSel : here; 733 QPoint right = left_not_right ? iPntSel : here;
730 i = loc(right.x(),right.y()); 734 i = loc(right.x(),right.y());
@@ -966,52 +970,52 @@ bool TEWidget::eventFilter( QObject *obj, QEvent *e )
966 return FALSE; // not us 970 return FALSE; // not us
967 if ( e->type() == QEvent::Wheel) 971 if ( e->type() == QEvent::Wheel)
968 { 972 {
969 QApplication::sendEvent(scrollbar, e); 973 QApplication::sendEvent(scrollbar, e);
970 } 974 }
971 975
972#ifdef FAKE_CTRL_AND_ALT 976#ifdef FAKE_CTRL_AND_ALT
973 static bool control = FALSE; 977 static bool control = FALSE;
974 static bool alt = FALSE; 978 static bool alt = FALSE;
975 // Has a keyboard with no CTRL and ALT keys, but we fake it: 979 // Has a keyboard with no CTRL and ALT keys, but we fake it:
976 bool dele=FALSE; 980 bool dele=FALSE;
977 if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { 981 if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) {
978 QKeyEvent* ke = (QKeyEvent*)e; 982 QKeyEvent* ke = (QKeyEvent*)e;
979 bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat(); 983 bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat();
980 switch (ke->key()) { 984 switch (ke->key()) {
981 case Key_F9: // let this be "Control" 985 case Key_F9: // let this be "Control"
982 control = keydown; 986 control = keydown;
983 e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state()); 987 e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state());
984 dele=TRUE; 988 dele=TRUE;
985 break; 989 break;
986 case Key_F13: // let this be "Alt" 990 case Key_F13: // let this be "Alt"
987 alt = keydown; 991 alt = keydown;
988 e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state()); 992 e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state());
989 dele=TRUE; 993 dele=TRUE;
990 break; 994 break;
991 default: 995 default:
992 if ( control ) { 996 if ( control ) {
993 int a = toupper(ke->ascii())-64; 997 int a = toupper(ke->ascii())-64;
994 if ( a >= 0 && a < ' ' ) { 998 if ( a >= 0 && a < ' ' ) {
995 e = new QKeyEvent(e->type(), ke->key(), 999 e = new QKeyEvent(e->type(), ke->key(),
996 a, ke->state()|ControlButton, QChar(a,0)); 1000 a, ke->state()|ControlButton, QChar(a,0));
997 dele=TRUE; 1001 dele=TRUE;
998 } 1002 }
999 } 1003 }
1000 if ( alt ) { 1004 if ( alt ) {
1001 e = new QKeyEvent(e->type(), ke->key(), 1005 e = new QKeyEvent(e->type(), ke->key(),
1002 ke->ascii(), ke->state()|AltButton, ke->text()); 1006 ke->ascii(), ke->state()|AltButton, ke->text());
1003 dele=TRUE; 1007 dele=TRUE;
1004 } 1008 }
1005 } 1009 }
1006 } 1010 }
1007#endif 1011#endif
1008 1012
1009 if ( e->type() == QEvent::KeyPress ) 1013 if ( e->type() == QEvent::KeyPress )
1010 { 1014 {
1011 QKeyEvent* ke = (QKeyEvent*)e; 1015 QKeyEvent* ke = (QKeyEvent*)e;
1012 1016
1013 actSel=0; // Key stroke implies a screen update, so TEWidget won't 1017 actSel=0; // Key stroke implies a screen update, so TEWidget won't
1014 // know where the current selection is. 1018 // know where the current selection is.
1015 1019
1016 emit keyPressedSignal(ke); // expose 1020 emit keyPressedSignal(ke); // expose
1017 ke->accept(); 1021 ke->accept();
@@ -1179,32 +1183,32 @@ void TEWidget::dropEvent(QDropEvent* event)
1179 dropText += url.path(); // local URL : remove protocol 1183 dropText += url.path(); // local URL : remove protocol
1180 } 1184 }
1181 else { 1185 else {
1182 dropText += url.prettyURL(); 1186 dropText += url.prettyURL();
1183 bPopup = false; // a non-local file, don't popup 1187 bPopup = false; // a non-local file, don't popup
1184 } 1188 }
1185*/ 1189*/
1186 1190
1187 } 1191 }
1188 1192
1189 if (bPopup) 1193 if (bPopup)
1190 // m_drop->popup(pos() + event->pos()); 1194 // m_drop->popup(pos() + event->pos());
1191 m_drop->popup(mapToGlobal(event->pos())); 1195 m_drop->popup(mapToGlobal(event->pos()));
1192 else 1196 else
1193 { 1197 {
1194 if (currentSession) { 1198 if (currentSession) {
1195 currentSession->getEmulation()->sendString(dropText.local8Bit()); 1199 currentSession->getEmulation()->sendString(dropText.local8Bit());
1196 } 1200 }
1197 // kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; 1201// kdDebug() << "Drop:" << dropText.local8Bit() << "\n";
1198 } 1202 }
1199 } 1203 }
1200 } 1204 }
1201 else if(QTextDrag::decode(event, dropText)) { 1205 else if(QTextDrag::decode(event, dropText)) {
1202// kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; 1206// kdDebug() << "Drop:" << dropText.local8Bit() << "\n";
1203 if (currentSession) { 1207 if (currentSession) {
1204 currentSession->getEmulation()->sendString(dropText.local8Bit()); 1208 currentSession->getEmulation()->sendString(dropText.local8Bit());
1205 } 1209 }
1206 // Paste it 1210 // Paste it
1207 } 1211 }
1208} 1212}
1209#endif 1213#endif
1210 1214
diff --git a/core/apps/embeddedkonsole/TEWidget.h b/core/apps/embeddedkonsole/TEWidget.h
index 3f9f4ae..40e1aea 100644
--- a/core/apps/embeddedkonsole/TEWidget.h
+++ b/core/apps/embeddedkonsole/TEWidget.h
@@ -1,30 +1,29 @@
1/* ----------------------------------------------------------------------- */ 1/* ----------------------------------------------------------------------- */
2/* */ 2/* */
3/* [te_widget.h] Terminal Emulation Widget */ 3/* [te_widget.h] Terminal Emulation Widget */
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 for KDE */ 9/* This file is part of Konsole - an X terminal for KDE */
10/* */ 10/* */
11/* ----------------------------------------------------------------------- */ 11/* ----------------------------------------------------------------------- */
12 /* */ 12/* */
13/* Ported Konsole to Qt/Embedded */ 13/* Ported Konsole to Qt/Embedded */
14 /* */ 14/* */
15/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ 15/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */
16 /* */ 16/* */
17/* -------------------------------------------------------------------------- */ 17/* -------------------------------------------------------------------------- */
18
19#ifndef TE_WIDGET_H 18#ifndef TE_WIDGET_H
20#define TE_WIDGET_H 19#define TE_WIDGET_H
21 20
22#include <qwidget.h> 21#include <qwidget.h>
23#include <qlabel.h> 22#include <qlabel.h>
24#include <qtimer.h> 23#include <qtimer.h>
25#include <qcolor.h> 24#include <qcolor.h>
26#include <qkeycode.h> 25#include <qkeycode.h>
27#include <qscrollbar.h> 26#include <qscrollbar.h>
28 27
29#include <qpopupmenu.h> 28#include <qpopupmenu.h>
30 29
@@ -43,24 +42,25 @@ class TEWidget : public QFrame
43// friend class Konsole; 42// friend class Konsole;
44 43
45public: 44public:
46 45
47 TEWidget(QWidget *parent=0, const char *name=0); 46 TEWidget(QWidget *parent=0, const char *name=0);
48 virtual ~TEWidget(); 47 virtual ~TEWidget();
49 48
50public: 49public:
51 50
52 QColor getDefaultBackColor(); 51 QColor getDefaultBackColor();
53 52
54 const ColorEntry* getColorTable() const; 53 const ColorEntry* getColorTable() const;
54 const ColorEntry* getdefaultColorTable() const;
55 void setColorTable(const ColorEntry table[]); 55 void setColorTable(const ColorEntry table[]);
56 56
57 void setScrollbarLocation(int loc); 57 void setScrollbarLocation(int loc);
58 enum { SCRNONE=0, SCRLEFT=1, SCRRIGHT=2 }; 58 enum { SCRNONE=0, SCRLEFT=1, SCRRIGHT=2 };
59 59
60 void setScroll(int cursor, int lines); 60 void setScroll(int cursor, int lines);
61 void doScroll(int lines); 61 void doScroll(int lines);
62 62
63 void emitSelection(); 63 void emitSelection();
64 64
65public: 65public:
66 66
diff --git a/core/apps/embeddedkonsole/konsole.cpp b/core/apps/embeddedkonsole/konsole.cpp
index 7253baf..1102ef3 100644
--- a/core/apps/embeddedkonsole/konsole.cpp
+++ b/core/apps/embeddedkonsole/konsole.cpp
@@ -3,144 +3,141 @@
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>
45#include <qpalette.h>
44 46
45#include <sys/wait.h> 47#include <sys/wait.h>
46#include <stdio.h> 48#include <stdio.h>
47#include <stdlib.h> 49#include <stdlib.h>
48#include <assert.h> 50#include <assert.h>
49 51
50#include "konsole.h" 52#include "konsole.h"
51#include "keytrans.h" 53#include "keytrans.h"
52 54
53class EKNumTabBar : public QTabBar { 55class EKNumTabBar : public QTabBar {
54public: 56public:
55 void numberTabs() 57 void numberTabs()
56 { 58 {
57 // Yes, it really is this messy. QTabWidget needs functions 59 // Yes, it really is this messy. QTabWidget needs functions
58 // that provide acces to tabs in a sequential way. 60 // that provide acces to tabs in a sequential way.
59 int m=INT_MIN; 61 int m=INT_MIN;
60 for (int i=0; i<count(); i++) { 62 for (int i=0; i<count(); i++) {
61 QTab* left=0; 63 QTab* left=0;
62 QListIterator<QTab> it(*tabList()); 64 QListIterator<QTab> it(*tabList());
63 int x=INT_MAX; 65 int x=INT_MAX;
64 for( QTab* t; (t=it.current()); ++it ) { 66 for( QTab* t; (t=it.current()); ++it ) {
65 int tx = t->rect().x(); 67 int tx = t->rect().x();
66 if ( tx<x && tx>m ) { 68 if ( tx<x && tx>m ) {
67 x = tx; 69 x = tx;
68 left = t; 70 left = t;
69 } 71 }
70 } 72 }
71 if ( left ) { 73 if ( left ) {
72 left->setText(QString::number(i+1)); 74 left->setText(QString::number(i+1));
73 m = left->rect().x(); 75 m = left->rect().x();
74 } 76 }
75 } 77 }
76 } 78 }
77}; 79};
78 80
79class EKNumTabWidget : public QTabWidget { 81class EKNumTabWidget : public QTabWidget {
80public: 82public:
81 EKNumTabWidget(QWidget* parent) : QTabWidget(parent) 83 EKNumTabWidget(QWidget* parent) : QTabWidget(parent)
82 { 84 {
83 } 85 }
84 86
85 void addTab(QWidget* w) 87 void addTab(QWidget* w)
86 { 88 {
87 QTab* t = new QTab(QString::number(tabBar()->count()+1)); 89 QTab* t = new QTab(QString::number(tabBar()->count()+1));
88 QTabWidget::addTab(w,t); 90 QTabWidget::addTab(w,t);
89 } 91 }
90 92
91 void removeTab(QWidget* w) 93 void removeTab(QWidget* w)
92 { 94 {
93 removePage(w); 95 removePage(w);
94 ((EKNumTabBar*)tabBar())->numberTabs(); 96 ((EKNumTabBar*)tabBar())->numberTabs();
95 } 97 }
96}; 98};
97 99
98// This could be configurable or dynamicly generated from the bash history 100// This could be configurable or dynamicly generated from the bash history
99// file of the user 101// file of the user
100static const char *commonCmds[] = 102static const char *commonCmds[] =
101{ 103{
102 "ls ", 104 "ls ", // I left this here, cause it looks better than the first alpha
103 //"ls -la ", 105 "cardctl eject",
106 "cat ",
104 "cd ", 107 "cd ",
105 "pwd", 108 "chmod ",
106 //"cat", 109 "cp ",
107 //"less ", 110 "dc ",
108 //"vi ", 111 "df ",
109 //"man ", 112 "dmesg",
110 "echo ", 113 "echo ",
111 "set ", 114 "find ",
112 //"ps", 115 "free",
113 "ps aux",
114 //"tar",
115 //"tar -zxf",
116 "grep ", 116 "grep ",
117 //"grep -i", 117 "ifconfig ",
118 //"mkdir", 118 "ipkg ",
119 "cp ", 119 "mkdir ",
120 "mv ", 120 "mv ",
121 "nc localhost 7776",
122 "nc localhost 7777",
123 "nslookup ",
124 "ping ",
125 "ps aux",
126 "pwd ",
121 "rm ", 127 "rm ",
122 "rmdir ", 128 "rmdir ",
123 //"chmod", 129 "route ",
124 //"su", 130 "set ",
125// "top", 131 "traceroute",
126 //"find",
127 //"make",
128 //"tail",
129 "cardctl eject",
130 "ifconfig ",
131// "iwconfig eth0 ",
132 "nc localhost 7777",
133 "nc localhost 7776",
134 //"mount /dev/hda1",
135 132
136/* 133/*
137 "gzip", 134 "gzip",
138 "gunzip", 135 "gunzip",
139 "chgrp", 136 "chgrp",
140 "chown", 137 "chown",
141 "date", 138 "date",
142 "dd", 139 "dd",
143 "df", 140 "df",
144 "dmesg", 141 "dmesg",
145 "fuser", 142 "fuser",
146 "hostname", 143 "hostname",
@@ -177,62 +174,104 @@ Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int)
177 174
178void Konsole::init(const char* _pgm, QStrList & _args) 175void Konsole::init(const char* _pgm, QStrList & _args)
179{ 176{
180 b_scroll = TRUE; // histon; 177 b_scroll = TRUE; // histon;
181 n_keytab = 0; 178 n_keytab = 0;
182 n_render = 0; 179 n_render = 0;
183 180
184 setCaption( tr("Terminal") ); 181 setCaption( tr("Terminal") );
185 setIcon( Resource::loadPixmap( "konsole" ) ); 182 setIcon( Resource::loadPixmap( "konsole" ) );
186 183
187 Config cfg("Konsole"); 184 Config cfg("Konsole");
188 cfg.setGroup("Konsole"); 185 cfg.setGroup("Konsole");
189 186 QString tmp;
190 // initialize the list of allowed fonts /////////////////////////////////// 187 // initialize the list of allowed fonts ///////////////////////////////////
191 cfont = cfg.readNumEntry("FontID", 1); 188 cfont = cfg.readNumEntry("FontID", 1);
192 QFont f = QFont("Micro", 4, QFont::Normal); 189 QFont f = QFont("Micro", 4, QFont::Normal);
193 f.setFixedPitch(TRUE); 190 f.setFixedPitch(TRUE);
194 fonts.append(new VTFont(tr("Micro"), f)); 191 fonts.append(new VTFont(tr("Micro"), f));
195 192
196 f = QFont("Fixed", 7, QFont::Normal); 193 f = QFont("Fixed", 7, QFont::Normal);
197 f.setFixedPitch(TRUE); 194 f.setFixedPitch(TRUE);
198 fonts.append(new VTFont(tr("Small Fixed"), f)); 195 fonts.append(new VTFont(tr("Small Fixed"), f));
199 196
200 f = QFont("Fixed", 12, QFont::Normal); 197 f = QFont("Fixed", 12, QFont::Normal);
201 f.setFixedPitch(TRUE); 198 f.setFixedPitch(TRUE);
202 fonts.append(new VTFont(tr("Medium Fixed"), f)); 199 fonts.append(new VTFont(tr("Medium Fixed"), f));
203 200
204 // create terminal emulation framework //////////////////////////////////// 201 // create terminal emulation framework ////////////////////////////////////
205 nsessions = 0; 202 nsessions = 0;
203
206 tab = new EKNumTabWidget(this); 204 tab = new EKNumTabWidget(this);
207 tab->setTabPosition(QTabWidget::Bottom); 205
208 connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*))); 206 connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*)));
209 207
210 // create terminal toolbar //////////////////////////////////////////////// 208 // create terminal toolbar ////////////////////////////////////////////////
211 setToolBarsMovable( FALSE ); 209 setToolBarsMovable( FALSE );
212 QPEToolBar *menuToolBar = new QPEToolBar( this ); 210 QPEToolBar *menuToolBar = new QPEToolBar( this );
213 menuToolBar->setHorizontalStretchable( TRUE ); 211 menuToolBar->setHorizontalStretchable( TRUE );
214 212
215 QPEMenuBar *menuBar = new QPEMenuBar( menuToolBar ); 213 QPEMenuBar *menuBar = new QPEMenuBar( menuToolBar );
216 214
217 fontList = new QPopupMenu( this ); 215 fontList = new QPopupMenu( this );
218 for(uint i = 0; i < fonts.count(); i++) { 216 for(uint i = 0; i < fonts.count(); i++) {
219 VTFont *fnt = fonts.at(i); 217 VTFont *fnt = fonts.at(i);
220 fontList->insertItem(fnt->getName(), i); 218 fontList->insertItem(fnt->getName(), i);
221 } 219 }
222 fontChanged(cfont); 220 fontChanged(cfont);
223 221
222 configMenu = new QPopupMenu( this);
223 colorMenu = new QPopupMenu( this);
224
225 bool listHidden;
226 cfg.setGroup("Menubar");
227 if( cfg.readEntry("Hidden","FALSE") == "TRUE") {
228 configMenu->insertItem("Show command list");
229 listHidden=TRUE;
230 } else {
231 configMenu->insertItem("Hide command list");
232 listHidden=FALSE;
233 }
234
235 cfg.setGroup("Tabs");
236 tmp=cfg.readEntry("Position","Bottom");
237 if(tmp=="Top") {
238 tab->setTabPosition(QTabWidget::Top);
239 configMenu->insertItem("Tabs on Bottom");
240 } else {
241 tab->setTabPosition(QTabWidget::Bottom);
242 configMenu->insertItem("Tabs on Top");
243 }
244 configMenu->insertSeparator(2);
245
246 colorMenu->insertItem("Green on Black");
247 colorMenu->insertItem("Black on White");
248 colorMenu->insertItem("White on Black");
249 colorMenu->insertItem("Black on Transparent");
250 colorMenu->insertItem("Black on Red");
251 colorMenu->insertItem("Red on Black");
252 colorMenu->insertItem("Green on Yellow");
253 colorMenu->insertItem("Blue on Magenta");
254 colorMenu->insertItem("Magenta on Blue");
255 colorMenu->insertItem("Cyan on White");
256 colorMenu->insertItem("White on Cyan");
257 colorMenu->insertItem("Blue on Black");
258 configMenu->insertItem("Colors",colorMenu);
259
224 connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) )); 260 connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) ));
261 connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) ));
262 connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuSelected(int) ));
225 263
226 menuBar->insertItem( tr("Font"), fontList ); 264 menuBar->insertItem( tr("Font"), fontList );
265 menuBar->insertItem( tr("Options"), configMenu );
227 266
228 QPEToolBar *toolbar = new QPEToolBar( this ); 267 QPEToolBar *toolbar = new QPEToolBar( this );
229 268
230 QAction *a; 269 QAction *a;
231 270
232 // Button Commands 271 // Button Commands
233 a = new QAction( tr("New"), Resource::loadPixmap( "konsole" ), QString::null, 0, this, 0 ); 272 a = new QAction( tr("New"), Resource::loadPixmap( "konsole" ), QString::null, 0, this, 0 );
234 connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); a->addTo( toolbar ); 273 connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); a->addTo( toolbar );
235 a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 ); 274 a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 );
236 connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolbar ); 275 connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolbar );
237 a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 ); 276 a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 );
238 connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolbar ); 277 connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolbar );
@@ -241,101 +280,119 @@ void Konsole::init(const char* _pgm, QStrList & _args)
241 a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 ); 280 a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 );
242 connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar ); 281 connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar );
243 a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 ); 282 a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 );
244 connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar ); 283 connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar );
245 a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); 284 a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 );
246 connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); a->addTo( toolbar ); 285 connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); a->addTo( toolbar );
247/* 286/*
248 a = new QAction( tr("Up"), Resource::loadPixmap( "up" ), QString::null, 0, this, 0 ); 287 a = new QAction( tr("Up"), Resource::loadPixmap( "up" ), QString::null, 0, this, 0 );
249 connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar ); 288 connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar );
250 a = new QAction( tr("Down"), Resource::loadPixmap( "down" ), QString::null, 0, this, 0 ); 289 a = new QAction( tr("Down"), Resource::loadPixmap( "down" ), QString::null, 0, this, 0 );
251 connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar ); 290 connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar );
252*/ 291*/
253 292
254 QPEToolBar *secondToolBar = new QPEToolBar( this ); 293 secondToolBar = new QPEToolBar( this );
255 secondToolBar->setHorizontalStretchable( TRUE ); 294 secondToolBar->setHorizontalStretchable( TRUE );
256 295
257 QComboBox *commonCombo = new QComboBox( secondToolBar ); 296 commonCombo = new QComboBox( secondToolBar );
258// commonCombo->setEditable( TRUE ); 297
259 for (int i = 0; commonCmds[i] != NULL; i++) 298 if( listHidden)
260 commonCombo->insertItem( commonCmds[i], i ); 299 secondToolBar->hide();
300 configMenu->insertItem( "Edit Command List");
301
302 cfg.setGroup("Commands");
303 commonCombo->setInsertionPolicy(QComboBox::AtCurrent);
304
305 for (int i = 0; commonCmds[i] != NULL; i++) {
306 commonCombo->insertItem( commonCmds[i], i );
307 tmp = cfg.readEntry( QString::number(i),"");
308 if(tmp != "")
309 commonCombo->changeItem( tmp,i );
310 }
311
261 connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) )); 312 connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) ));
262 313
263 // create applications ///////////////////////////////////////////////////// 314 // create applications /////////////////////////////////////////////////////
264 setCentralWidget(tab); 315 setCentralWidget(tab);
265 316
266 // load keymaps //////////////////////////////////////////////////////////// 317 // load keymaps ////////////////////////////////////////////////////////////
267 KeyTrans::loadAll(); 318 KeyTrans::loadAll();
268 for (int i = 0; i < KeyTrans::count(); i++) 319 for (int i = 0; i < KeyTrans::count(); i++)
269 { KeyTrans* s = KeyTrans::find(i); 320 { KeyTrans* s = KeyTrans::find(i);
270 assert( s ); 321 assert( s );
271 } 322 }
272 323
273 se_pgm = _pgm; 324 se_pgm = _pgm;
274 se_args = _args; 325 se_args = _args;
275 326
276 // read and apply default values /////////////////////////////////////////// 327 // read and apply default values ///////////////////////////////////////////
277 resize(321, 321); // Dummy. 328 resize(321, 321); // Dummy.
278 QSize currentSize = size(); 329 QSize currentSize = size();
279 if (currentSize != size()) 330 if (currentSize != size())
280 defaultSize = size(); 331 defaultSize = size();
332
281} 333}
282 334
283void Konsole::show() 335void Konsole::show()
284{ 336{
285 if ( !nsessions ) { 337 if ( !nsessions ) {
286 newSession(); 338 newSession();
287 } 339 }
288 QMainWindow::show(); 340 QMainWindow::show();
289} 341}
290 342
291void Konsole::initSession(const char*, QStrList &) 343void Konsole::initSession(const char*, QStrList &)
292{ 344{
293 QMainWindow::show(); 345 QMainWindow::show();
294} 346}
295 347
296Konsole::~Konsole() 348Konsole::~Konsole()
297{ 349{
298 while (nsessions > 0) { 350 while (nsessions > 0) {
299 doneSession(getTe()->currentSession, 0); 351 doneSession(getTe()->currentSession, 0);
300 } 352 }
301 353
302 Config cfg("Konsole"); 354 Config cfg("Konsole");
303 cfg.setGroup("Konsole"); 355 cfg.setGroup("Konsole");
304 cfg.writeEntry("FontID", cfont); 356 cfg.writeEntry("FontID", cfont);
305} 357}
306 358
307void Konsole::fontChanged(int f) 359void Konsole::fontChanged(int f)
308{ 360{
309 VTFont* font = fonts.at(f); 361 VTFont* font = fonts.at(f);
310 if (font != 0) { 362 if (font != 0) {
311 for(uint i = 0; i < fonts.count(); i++) { 363 for(uint i = 0; i < fonts.count(); i++) {
312 fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE); 364 fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE);
313 } 365 }
314 366
315 cfont = f; 367 cfont = f;
316 368
317 TEWidget* te = getTe(); 369 TEWidget* te = getTe();
318 if (te != 0) { 370 if (te != 0) {
319 te->setVTFont(font->getFont()); 371 te->setVTFont(font->getFont());
320 } 372 }
321 } 373 }
322} 374}
323 375
376
324void Konsole::enterCommand(int c) 377void Konsole::enterCommand(int c)
325{ 378{
326 TEWidget* te = getTe(); 379 TEWidget* te = getTe();
327 if (te != 0) { 380 if (te != 0) {
328 QString text = commonCmds[c]; 381 if(!commonCombo->editable()) {
329 te->emitText(text); 382 QString text = commonCombo->text(c); //commonCmds[c];
383 te->emitText(text);
384 } else {
385 changeCommand( commonCombo->text(c), c);
386 }
330 } 387 }
331} 388}
332 389
333void Konsole::hitEnter() 390void Konsole::hitEnter()
334{ 391{
335 TEWidget* te = getTe(); 392 TEWidget* te = getTe();
336 if (te != 0) { 393 if (te != 0) {
337 te->emitText(QString("\r")); 394 te->emitText(QString("\r"));
338 } 395 }
339} 396}
340 397
341void Konsole::hitSpace() 398void Konsole::hitSpace()
@@ -381,26 +438,26 @@ void Konsole::hitDown()
381} 438}
382 439
383/** 440/**
384 This function calculates the size of the external widget 441 This function calculates the size of the external widget
385 needed for the internal widget to be 442 needed for the internal widget to be
386 */ 443 */
387QSize Konsole::calcSize(int columns, int lines) { 444QSize Konsole::calcSize(int columns, int lines) {
388 TEWidget* te = getTe(); 445 TEWidget* te = getTe();
389 if (te != 0) { 446 if (te != 0) {
390 QSize size = te->calcSize(columns, lines); 447 QSize size = te->calcSize(columns, lines);
391 return size; 448 return size;
392 } else { 449 } else {
393 QSize size; 450 QSize size;
394 return size; 451 return size;
395 } 452 }
396} 453}
397 454
398/** 455/**
399 sets application window to a size based on columns X lines of the te 456 sets application window to a size based on columns X lines of the te
400 guest widget. Call with (0,0) for setting default size. 457 guest widget. Call with (0,0) for setting default size.
401*/ 458*/
402 459
403void Konsole::setColLin(int columns, int lines) 460void Konsole::setColLin(int columns, int lines)
404{ 461{
405 if ((columns==0) || (lines==0)) 462 if ((columns==0) || (lines==0))
406 { 463 {
@@ -458,55 +515,248 @@ void Konsole::changeColumns(int columns)
458// session swap is completed. 515// session swap is completed.
459 516
460void Konsole::doneSession(TESession*, int ) 517void Konsole::doneSession(TESession*, int )
461{ 518{
462 TEWidget *te = getTe(); 519 TEWidget *te = getTe();
463 if (te != 0) { 520 if (te != 0) {
464 te->currentSession->setConnect(FALSE); 521 te->currentSession->setConnect(FALSE);
465 tab->removeTab(te); 522 tab->removeTab(te);
466 delete te->currentSession; 523 delete te->currentSession;
467 delete te; 524 delete te;
468 nsessions--; 525 nsessions--;
469 } 526 }
470 527
471 if (nsessions == 0) { 528 if (nsessions == 0) {
472 close(); 529 close();
473 } 530 }
474} 531}
475 532
476
477void Konsole::newSession() { 533void Konsole::newSession() {
478 TEWidget* te = new TEWidget(tab); 534 if(nsessions < 15) { // seems to be something weird about 16 tabs on the Zaurus.... memory?
479 te->setBackgroundMode(PaletteBase); 535 TEWidget* te = new TEWidget(tab);
480 te->setVTFont(fonts.at(cfont)->getFont()); 536// te->setBackgroundMode(PaletteBase); //we want transparent!!
481 tab->addTab(te); 537 te->setVTFont(fonts.at(cfont)->getFont());
482 TESession* se = new TESession(this, te, se_pgm, se_args, "xterm"); 538 tab->addTab(te);
483 te->currentSession = se; 539 TESession* se = new TESession(this, te, se_pgm, se_args, "xterm");
484 connect( se, SIGNAL(done(TESession*,int)), this, SLOT(doneSession(TESession*,int)) ); 540 te->currentSession = se;
485 se->run(); 541 connect( se, SIGNAL(done(TESession*,int)), this, SLOT(doneSession(TESession*,int)) );
486 se->setConnect(TRUE); 542 se->run();
487 se->setHistory(b_scroll); 543 se->setConnect(TRUE);
488 tab->setCurrentPage(nsessions); 544 se->setHistory(b_scroll);
489 nsessions++; 545 tab->setCurrentPage(nsessions);
546 nsessions++;
547 setColor();
548 }
490} 549}
491 550
492TEWidget* Konsole::getTe() { 551TEWidget* Konsole::getTe() {
493 if (nsessions) { 552 if (nsessions) {
494 return (TEWidget *) tab->currentPage(); 553 return (TEWidget *) tab->currentPage();
495 } else { 554 } else {
496 return 0; 555 return 0;
497 } 556 }
498 } 557}
499 558
500void Konsole::switchSession(QWidget* w) { 559void Konsole::switchSession(QWidget* w) {
501 TEWidget* te = (TEWidget *) w; 560 TEWidget* te = (TEWidget *) w;
502 561
503 QFont teFnt = te->getVTFont(); 562 QFont teFnt = te->getVTFont();
504 for(uint i = 0; i < fonts.count(); i++) { 563 for(uint i = 0; i < fonts.count(); i++) {
505 VTFont *fnt = fonts.at(i); 564 VTFont *fnt = fonts.at(i);
506 bool cf = fnt->getFont() == teFnt; 565 bool cf = fnt->getFont() == teFnt;
507 fontList->setItemChecked(i, cf); 566 fontList->setItemChecked(i, cf);
508 if (cf) { 567 if (cf) {
509 cfont = i; 568 cfont = i;
510 } 569 }
511 } 570 }
512} 571}
572
573/// ------------------------------- some new stuff by L.J. Potter
574void Konsole::colorMenuSelected(int iD)
575{ // this is NOT pretty, elegant or anything else besides functional
576// QString temp;
577// temp.sprintf("%d", iD);
578// qDebug(temp);
579 TEWidget* te = getTe();
580 Config cfg("Konsole");
581 cfg.setGroup("Colors");
582 QColor foreground;
583 QColor background;
584 colorMenu->setItemChecked(lastSelectedMenu,FALSE);
585 ColorEntry m_table[TABLE_COLORS];
586 const ColorEntry * defaultCt=te->getdefaultColorTable();
587 /////////// fore back
588 int i;
589 if(iD==-8) { // default default
590 for (i = 0; i < TABLE_COLORS; i++) {
591 m_table[i].color = defaultCt[i].color;
592 if(i==1 || i == 11)
593 m_table[i].transparent=1;
594 cfg.writeEntry("Schema","8");
595 colorMenu->setItemChecked(-8,TRUE);
596 }
597 } else {
598 if(iD==-5) { // green black
599 foreground.setRgb(0x18,255,0x18);
600 background.setRgb(0x00,0x00,0x00);
601 cfg.writeEntry("Schema","5");
602 colorMenu->setItemChecked(-5,TRUE);
603 }
604 if(iD==-6) { // black white
605 foreground.setRgb(0x00,0x00,0x00);
606 background.setRgb(0xFF,0xFF,0xFF);
607 cfg.writeEntry("Schema","6");
608 colorMenu->setItemChecked(-6,TRUE);
609 }
610 if(iD==-7) { // white black
611 foreground.setRgb(0xFF,0xFF,0xFF);
612 background.setRgb(0x00,0x00,0x00);
613 cfg.writeEntry("Schema","7");
614 colorMenu->setItemChecked(-7,TRUE);
615 }
616 if(iD==-9) {// Black, Red
617 foreground.setRgb(0x00,0x00,0x00);
618 background.setRgb(0xB2,0x18,0x18);
619 cfg.writeEntry("Schema","9");
620 colorMenu->setItemChecked(-9,TRUE);
621 }
622 if(iD==-10) {// Red, Black
623 foreground.setRgb(230,31,31); //0xB2,0x18,0x18
624 background.setRgb(0x00,0x00,0x00);
625 cfg.writeEntry("Schema","10");
626 colorMenu->setItemChecked(-10,TRUE);
627 }
628 if(iD==-11) {// Green, Yellow - is ugly
629// foreground.setRgb(0x18,0xB2,0x18);
630 foreground.setRgb(36,139,10);
631// background.setRgb(0xB2,0x68,0x18);
632 background.setRgb(255,255,0);
633 cfg.writeEntry("Schema","11");
634 colorMenu->setItemChecked(-11,TRUE);
635 }
636 if(iD==-12) {// Blue, Magenta
637 foreground.setRgb(0x18,0xB2,0xB2);
638 background.setRgb(0x18,0x18,0xB2);
639 cfg.writeEntry("Schema","12");
640 colorMenu->setItemChecked(-12,TRUE);
641 }
642 if(iD==-13) {// Magenta, Blue
643 foreground.setRgb(0x18,0x18,0xB2);
644 background.setRgb(0x18,0xB2,0xB2);
645 cfg.writeEntry("Schema","13");
646 colorMenu->setItemChecked(-13,TRUE);
647 }
648 if(iD==-14) {// Cyan, White
649 foreground.setRgb(0x18,0xB2,0xB2);
650 background.setRgb(0xFF,0xFF,0xFF);
651 cfg.writeEntry("Schema","14");
652 colorMenu->setItemChecked(-14,TRUE);
653 }
654 if(iD==-15) {// White, Cyan
655 background.setRgb(0x18,0xB2,0xB2);
656 foreground.setRgb(0xFF,0xFF,0xFF);
657 cfg.writeEntry("Schema","15");
658 colorMenu->setItemChecked(-15,TRUE);
659 }
660 if(iD==-16) {// Black, Blue
661 background.setRgb(0x00,0x00,0x00);
662 foreground.setRgb(0x18,0xB2,0xB2);
663 cfg.writeEntry("Schema","16");
664 colorMenu->setItemChecked(-16,TRUE);
665 }
666
667 for (i = 0; i < TABLE_COLORS; i++) {
668 if(i==0 || i == 10) {
669 m_table[i].color = foreground;
670 }
671 else if(i==1 || i == 11) {
672 m_table[i].color = background; m_table[i].transparent=0;
673 }
674 else
675 m_table[i].color = defaultCt[i].color;
676 }
677 }
678 lastSelectedMenu = iD;
679 te->setColorTable(m_table);
680// update();
681}
682
683void Konsole::configMenuSelected(int iD)
684{
685// QString temp;
686// temp.sprintf("%d",iD);
687// qDebug(temp);
688 TEWidget* te = getTe();
689 Config cfg("Konsole");
690 cfg.setGroup("Menubar");
691 if( iD == -2) {
692 if(!secondToolBar->isHidden()) {
693 secondToolBar->hide();
694 configMenu->changeItem( iD,"Show Command List");
695 cfg.writeEntry("Hidden","TRUE");
696 configMenu->setItemEnabled(-20 ,FALSE);
697 } else {
698 secondToolBar->show();
699 configMenu->changeItem( iD,"Hide Command List");
700 cfg.writeEntry("Hidden","FALSE");
701 configMenu->setItemEnabled(-20 ,TRUE);
702
703 if(cfg.readEntry("EditEnabled","FALSE")=="TRUE") {
704 configMenu->setItemChecked(-16,TRUE);
705 commonCombo->setEditable( TRUE );
706 } else {
707 configMenu->setItemChecked(-20,FALSE);
708 commonCombo->setEditable( FALSE );
709 }
710 }
711 }
712 if( iD == -3) {
713 cfg.setGroup("Tabs");
714 QString tmp=cfg.readEntry("Position","Top");
715
716 if(tmp=="Top") {
717 tab->setTabPosition(QTabWidget::Bottom);
718 configMenu->changeItem( iD,"Tabs on Top");
719 cfg.writeEntry("Position","Bottom");
720 } else {
721 tab->setTabPosition(QTabWidget::Top);
722 configMenu->changeItem( iD,"Tabs on Bottom");
723 cfg.writeEntry("Position","Top");
724 }
725 }
726 if( iD == -20) {
727 cfg.setGroup("Commands");
728// qDebug("enableCommandEdit");
729 if( !configMenu->isItemChecked(iD) ) {
730 commonCombo->setEditable( TRUE );
731 configMenu->setItemChecked(iD,TRUE);
732 commonCombo->setCurrentItem(0);
733 cfg.writeEntry("EditEnabled","TRUE");
734 } else {
735 commonCombo->setEditable( FALSE );
736 configMenu->setItemChecked(iD,FALSE);
737 cfg.writeEntry("EditEnabled","FALSE");
738 commonCombo->setFocusPolicy(QWidget::NoFocus);
739 te->setFocus();
740 }
741 }
742}
743
744void Konsole::changeCommand(const QString &text, int c)
745{
746 Config cfg("Konsole");
747 cfg.setGroup("Commands");
748 if(commonCmds[c] != text) {
749 cfg.writeEntry(QString::number(c),text);
750 commonCombo->clearEdit();
751 commonCombo->setCurrentItem(c);
752 }
753}
754
755void Konsole::setColor()
756{
757 Config cfg("Konsole");
758 cfg.setGroup("Colors");
759 int scheme = cfg.readNumEntry("Schema",1);
760 if(scheme != 1) colorMenuSelected( -scheme);
761
762}
diff --git a/core/apps/embeddedkonsole/konsole.h b/core/apps/embeddedkonsole/konsole.h
index 819ea5d..40003d4 100644
--- a/core/apps/embeddedkonsole/konsole.h
+++ b/core/apps/embeddedkonsole/konsole.h
@@ -3,76 +3,82 @@
3/* [konsole.h] Konsole */ 3/* [konsole.h] 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#ifndef KONSOLE_H 22#ifndef KONSOLE_H
23#define KONSOLE_H 23#define KONSOLE_H
24 24
25 25
26#include <qmainwindow.h> 26#include <qmainwindow.h>
27#include <qaction.h> 27#include <qaction.h>
28#include <qpopupmenu.h> 28#include <qpopupmenu.h>
29#include <qstrlist.h> 29#include <qstrlist.h>
30#include <qintdict.h> 30#include <qintdict.h>
31#include <qptrdict.h> 31#include <qptrdict.h>
32#include <qtabwidget.h> 32#include <qtabwidget.h>
33#include <qpe/qpetoolbar.h>
34#include <qcombobox.h>
33 35
34#include "MyPty.h" 36#include "MyPty.h"
35#include "TEWidget.h" 37#include "TEWidget.h"
36#include "TEmuVt102.h" 38#include "TEmuVt102.h"
37#include "session.h" 39#include "session.h"
38 40
39class EKNumTabWidget; 41class EKNumTabWidget;
40 42
41class Konsole : public QMainWindow 43class Konsole : public QMainWindow
42{ 44{
43Q_OBJECT 45Q_OBJECT
44 46
45public: 47public:
46 48
47 Konsole(QWidget* parent = 0, const char* name = 0, WFlags fl = 0); 49 Konsole(QWidget* parent = 0, const char* name = 0, WFlags fl = 0);
48 Konsole(const char * name, const char* pgm, QStrList & _args, int histon); 50 Konsole(const char * name, const char* pgm, QStrList & _args, int histon);
49 ~Konsole(); 51 ~Konsole();
50 void setColLin(int columns, int lines); 52 void setColLin(int columns, int lines);
51 53 QPEToolBar *secondToolBar;
52 void show(); 54 void show();
53 55 void setColor();
56 int lastSelectedMenu;
54private slots: 57private slots:
55 void doneSession(TESession*,int); 58 void doneSession(TESession*,int);
56 void changeColumns(int); 59 void changeColumns(int);
57 void fontChanged(int); 60 void fontChanged(int);
61 void configMenuSelected(int );
62 void colorMenuSelected(int);
58 void enterCommand(int); 63 void enterCommand(int);
59 void hitEnter(); 64 void hitEnter();
60 void hitSpace(); 65 void hitSpace();
61 void hitTab(); 66 void hitTab();
62 void hitPaste(); 67 void hitPaste();
63 void hitUp(); 68 void hitUp();
64 void hitDown(); 69 void hitDown();
65 void switchSession(QWidget *); 70 void switchSession(QWidget *);
66 void newSession(); 71 void newSession();
72 void changeCommand(const QString &, int);
67 73
68private: 74private:
69 void init(const char* _pgm, QStrList & _args); 75 void init(const char* _pgm, QStrList & _args);
70 void initSession(const char* _pgm, QStrList & _args); 76 void initSession(const char* _pgm, QStrList & _args);
71 void runSession(TESession* s); 77 void runSession(TESession* s);
72 void setColorPixmaps(); 78 void setColorPixmaps();
73 void setHistory(bool); 79 void setHistory(bool);
74 QSize calcSize(int columns, int lines); 80 QSize calcSize(int columns, int lines);
75 TEWidget* getTe(); 81 TEWidget* getTe();
76 82
77private: 83private:
78 class VTFont 84 class VTFont
@@ -97,27 +103,27 @@ private:
97 private: 103 private:
98 QString name; 104 QString name;
99 QFont font; 105 QFont font;
100 }; 106 };
101 107
102 EKNumTabWidget* tab; 108 EKNumTabWidget* tab;
103 int nsessions; 109 int nsessions;
104 QList<VTFont> fonts; 110 QList<VTFont> fonts;
105 int cfont; 111 int cfont;
106 QCString se_pgm; 112 QCString se_pgm;
107 QStrList se_args; 113 QStrList se_args;
108 114
109 QPopupMenu* fontList; 115 QPopupMenu* fontList,*configMenu,*colorMenu;
110 116 QComboBox *commonCombo;
111 // history scrolling I think 117 // history scrolling I think
112 bool b_scroll; 118 bool b_scroll;
113 119
114 int n_keytab; 120 int n_keytab;
115 int n_scroll; 121 int n_scroll;
116 int n_render; 122 int n_render;
117 QString pmPath; // pixmap path 123 QString pmPath; // pixmap path
118 QString dropText; 124 QString dropText;
119 QFont defaultFont; 125 QFont defaultFont;
120 QSize defaultSize; 126 QSize defaultSize;
121 127
122}; 128};
123 129