summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-02-01 14:11:46 (UTC)
committer llornkcor <llornkcor>2002-02-01 14:11:46 (UTC)
commit07ec85f797cad04431df30855a81b88f06fe27d3 (patch) (side-by-side diff)
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 @@
/* -------------------------------------------------------------------------- */
/* */
/* [TECommon.h] Common Definitions */
/* */
/* -------------------------------------------------------------------------- */
/* */
/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */
/* */
/* This file is part of Konsole - an X terminal for KDE */
/* */
/* -------------------------------------------------------------------------- */
-/* */
+/* */
/* Ported Konsole to Qt/Embedded */
-/* */
+/* */
/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */
-/* */
+/* */
/* -------------------------------------------------------------------------- */
/*! \file TECommon.h
\brief Definitions shared between TEScreen and TEWidget.
*/
#ifndef TECOMMON_H
#define TECOMMON_H
#include <qcolor.h>
#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 @@
/* ------------------------------------------------------------------------ */
/* */
/* [TEWidget.C] Terminal Emulation Widget */
/* */
/* ------------------------------------------------------------------------ */
/* */
/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */
/* */
/* This file is part of Konsole - an X terminal for KDE */
/* */
/* ------------------------------------------------------------------------ */
-/* */
+/* */
/* Ported Konsole to Qt/Embedded */
-/* */
+/* */
/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */
-/* */
+/* */
/* -------------------------------------------------------------------------- */
-
/*! \class TEWidget
\brief Visible screen contents
This class is responsible to map the `image' of a terminal emulation to the
display. All the dependency of the emulation to a specific GUI or toolkit is
localized here. Further, this widget has no knowledge about being part of an
emulation, it simply work within the terminal emulation framework by exposing
size and key events and by being ordered to show a new image.
<ul>
<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] =
{
// Fixme: could add faint colors here, also.
// normal
ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 1, 0 ), // Dfore, Dback
ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0x18), 0, 0 ), // Black, Red
ColorEntry(QColor(0x18,0xB2,0x18), 0, 0 ), ColorEntry( QColor(0xB2,0x68,0x18), 0, 0 ), // Green, Yellow
ColorEntry(QColor(0x18,0x18,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), // Blue, Magenta
ColorEntry(QColor(0x18,0xB2,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 0, 0 ), // Cyan, White
// intensiv
ColorEntry(QColor(0x00,0x00,0x00), 0, 1 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 1, 0 ),
ColorEntry(QColor(0x68,0x68,0x68), 0, 0 ), ColorEntry( QColor(0xFF,0x54,0x54), 0, 0 ),
ColorEntry(QColor(0x54,0xFF,0x54), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0x54), 0, 0 ),
- ColorEntry(QColor(0x54,0x54,0xFF), 0, 0 ), ColorEntry( QColor(0xFF,0x54,0xFF), 0, 0 ),
+ ColorEntry(QColor(0x54,0x54,0xFF), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ),
ColorEntry(QColor(0x54,0xFF,0xFF), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 0, 0 )
};
/* Note that we use ANSI color order (bgr), while IBMPC color order is (rgb)
Code 0 1 2 3 4 5 6 7
----------- ------- ------- ------- ------- ------- ------- ------- -------
ANSI (bgr) Black Red Green Yellow Blue Magenta Cyan White
IBMPC (rgb) Black Blue Green Cyan Red Magenta Yellow White
*/
QColor TEWidget::getDefaultBackColor()
{
return color_table[DEFAULT_BACK_COLOR].color;
}
const ColorEntry* TEWidget::getColorTable() const
{
return color_table;
}
+const ColorEntry* TEWidget::getdefaultColorTable() const
+{
+ return base_color_table;
+}
+
+
const QPixmap *TEWidget::backgroundPixmap()
{
static QPixmap *bg = new QPixmap("~/qpim/main/pics/faded_bg.xpm");
const QPixmap *pm = bg;
return pm;
}
void TEWidget::setColorTable(const ColorEntry table[])
{
for (int i = 0; i < TABLE_COLORS; i++) color_table[i] = table[i];
const QPixmap* pm = backgroundPixmap();
@@ -231,40 +236,39 @@ void TEWidget::fontChange(const QFont &)
{
QFontMetrics fm(font());
font_h = fm.height();
font_w = fm.maxWidth();
font_a = fm.ascent();
//printf("font_h: %d\n",font_h);
//printf("font_w: %d\n",font_w);
//printf("font_a: %d\n",font_a);
//printf("charset: %s\n",QFont::encodingName(font().charSet()).ascii());
//printf("rawname: %s\n",font().rawName().ascii());
fontMap =
#if QT_VERSION < 300
- strcmp(QFont::encodingName(font().charSet()).ascii(),"iso10646")
+ strcmp(QFont::encodingName(font().charSet()).ascii(),"iso10646")
? vt100extended
:
#endif
- identicalMap;
+ identicalMap;
propagateSize();
update();
}
void TEWidget::setVTFont(const QFont& f)
{
QFrame::setFont(f);
}
-QFont TEWidget::getVTFont()
-{
+QFont TEWidget::getVTFont() {
return font();
}
void TEWidget::setFont(const QFont &)
{
// ignore font change request if not coming from konsole itself
}
/* ------------------------------------------------------------------------- */
/* */
/* Constructor / Destructor */
/* */
@@ -638,25 +642,25 @@ void TEWidget::mousePressEvent(QMouseEvent* ev)
//printf("press top left [%d,%d] by=%d\n",tLx,tLy, bY);
if ( ev->button() == LeftButton)
{
QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h);
if ( ev->state() & ControlButton ) preserve_line_breaks = FALSE ;
if (mouse_marks || (ev->state() & ShiftButton))
{
emit clearSelectionSignal();
iPntSel = pntSel = pos;
actSel = 1; // left mouse button pressed but nothing selected yet.
- grabMouse( /*crossCursor*/ ); // handle with care!
+ grabMouse( /*crossCursor*/ ); // handle with care!
}
else
{
emit mouseSignal( 0, pos.x() + 1, pos.y() + 1 ); // left button
}
}
if ( ev->button() == MidButton )
{
emitSelection();
}
if ( ev->button() == RightButton ) // Configure
{
@@ -704,27 +708,27 @@ void TEWidget::mouseMoveEvent(QMouseEvent* ev)
QPoint here = QPoint((pos.x()-tLx-blX)/font_w,(pos.y()-tLy-bY)/font_h);
QPoint ohere;
bool swapping = FALSE;
if ( word_selection_mode )
{
// Extend to word boundaries
int i;
int selClass;
bool left_not_right = ( here.y() < iPntSel.y() ||
- here.y() == iPntSel.y() && here.x() < iPntSel.x() );
+ here.y() == iPntSel.y() && here.x() < iPntSel.x() );
bool old_left_not_right = ( pntSel.y() < iPntSel.y() ||
- pntSel.y() == iPntSel.y() && pntSel.x() < iPntSel.x() );
+ pntSel.y() == iPntSel.y() && pntSel.x() < iPntSel.x() );
swapping = left_not_right != old_left_not_right;
// Find left (left_not_right ? from here : from start)
QPoint left = left_not_right ? here : iPntSel;
i = loc(left.x(),left.y());
selClass = charClass(image[i].c);
while ( left.x() > 0 && charClass(image[i-1].c) == selClass )
{ i--; left.rx()--; }
// Find left (left_not_right ? from start : from here)
QPoint right = left_not_right ? iPntSel : here;
i = loc(right.x(),right.y());
@@ -966,52 +970,52 @@ bool TEWidget::eventFilter( QObject *obj, QEvent *e )
return FALSE; // not us
if ( e->type() == QEvent::Wheel)
{
QApplication::sendEvent(scrollbar, e);
}
#ifdef FAKE_CTRL_AND_ALT
static bool control = FALSE;
static bool alt = FALSE;
// Has a keyboard with no CTRL and ALT keys, but we fake it:
bool dele=FALSE;
if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) {
- QKeyEvent* ke = (QKeyEvent*)e;
- bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat();
- switch (ke->key()) {
- case Key_F9: // let this be "Control"
- control = keydown;
- e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state());
- dele=TRUE;
- break;
- case Key_F13: // let this be "Alt"
- alt = keydown;
- e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state());
- dele=TRUE;
- break;
- default:
- if ( control ) {
- int a = toupper(ke->ascii())-64;
- if ( a >= 0 && a < ' ' ) {
- e = new QKeyEvent(e->type(), ke->key(),
- a, ke->state()|ControlButton, QChar(a,0));
- dele=TRUE;
- }
- }
- if ( alt ) {
- e = new QKeyEvent(e->type(), ke->key(),
- ke->ascii(), ke->state()|AltButton, ke->text());
- dele=TRUE;
- }
- }
+ QKeyEvent* ke = (QKeyEvent*)e;
+ bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat();
+ switch (ke->key()) {
+ case Key_F9: // let this be "Control"
+ control = keydown;
+ e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state());
+ dele=TRUE;
+ break;
+ case Key_F13: // let this be "Alt"
+ alt = keydown;
+ e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state());
+ dele=TRUE;
+ break;
+ default:
+ if ( control ) {
+ int a = toupper(ke->ascii())-64;
+ if ( a >= 0 && a < ' ' ) {
+ e = new QKeyEvent(e->type(), ke->key(),
+ a, ke->state()|ControlButton, QChar(a,0));
+ dele=TRUE;
+ }
+ }
+ if ( alt ) {
+ e = new QKeyEvent(e->type(), ke->key(),
+ ke->ascii(), ke->state()|AltButton, ke->text());
+ dele=TRUE;
+ }
+ }
}
#endif
if ( e->type() == QEvent::KeyPress )
{
QKeyEvent* ke = (QKeyEvent*)e;
actSel=0; // Key stroke implies a screen update, so TEWidget won't
// know where the current selection is.
emit keyPressedSignal(ke); // expose
ke->accept();
@@ -1179,32 +1183,32 @@ void TEWidget::dropEvent(QDropEvent* event)
dropText += url.path(); // local URL : remove protocol
}
else {
dropText += url.prettyURL();
bPopup = false; // a non-local file, don't popup
}
*/
}
if (bPopup)
// m_drop->popup(pos() + event->pos());
- m_drop->popup(mapToGlobal(event->pos()));
+ m_drop->popup(mapToGlobal(event->pos()));
else
- {
- if (currentSession) {
- currentSession->getEmulation()->sendString(dropText.local8Bit());
- }
-// kdDebug() << "Drop:" << dropText.local8Bit() << "\n";
- }
+ {
+ if (currentSession) {
+ currentSession->getEmulation()->sendString(dropText.local8Bit());
+ }
+// kdDebug() << "Drop:" << dropText.local8Bit() << "\n";
+ }
}
}
else if(QTextDrag::decode(event, dropText)) {
// kdDebug() << "Drop:" << dropText.local8Bit() << "\n";
if (currentSession) {
currentSession->getEmulation()->sendString(dropText.local8Bit());
}
// Paste it
}
}
#endif
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 @@
/* ----------------------------------------------------------------------- */
/* */
/* [te_widget.h] Terminal Emulation Widget */
/* */
/* ----------------------------------------------------------------------- */
/* */
/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */
/* */
/* This file is part of Konsole - an X terminal for KDE */
/* */
/* ----------------------------------------------------------------------- */
-/* */
+/* */
/* Ported Konsole to Qt/Embedded */
-/* */
+/* */
/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */
-/* */
+/* */
/* -------------------------------------------------------------------------- */
-
#ifndef TE_WIDGET_H
#define TE_WIDGET_H
#include <qwidget.h>
#include <qlabel.h>
#include <qtimer.h>
#include <qcolor.h>
#include <qkeycode.h>
#include <qscrollbar.h>
#include <qpopupmenu.h>
@@ -43,24 +42,25 @@ class TEWidget : public QFrame
// friend class Konsole;
public:
TEWidget(QWidget *parent=0, const char *name=0);
virtual ~TEWidget();
public:
QColor getDefaultBackColor();
const ColorEntry* getColorTable() const;
+ const ColorEntry* getdefaultColorTable() const;
void setColorTable(const ColorEntry table[]);
void setScrollbarLocation(int loc);
enum { SCRNONE=0, SCRLEFT=1, SCRRIGHT=2 };
void setScroll(int cursor, int lines);
void doScroll(int lines);
void emitSelection();
public:
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 @@
/* [main.C] Konsole */
/* */
/* ---------------------------------------------------------------------- */
/* */
/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */
/* */
/* This file is part of Konsole, an X terminal. */
/* */
/* The material contained in here more or less directly orginates from */
/* kvt, which is copyright (c) 1996 by Matthias Ettrich <ettrich@kde.org> */
/* */
/* ---------------------------------------------------------------------- */
-/* */
+/* */
/* Ported Konsole to Qt/Embedded */
-/* */
+/* */
/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */
-/* */
+/* */
/* -------------------------------------------------------------------------- */
#include <qpe/resource.h>
#include <qdir.h>
#include <qevent.h>
#include <qdragobject.h>
#include <qobjectlist.h>
#include <qtoolbutton.h>
#include <qpe/qpetoolbar.h>
#include <qpushbutton.h>
#include <qfontdialog.h>
#include <qglobal.h>
#include <qpainter.h>
#include <qpe/qpemenubar.h>
#include <qmessagebox.h>
#include <qaction.h>
#include <qapplication.h>
#include <qfontmetrics.h>
#include <qcombobox.h>
#include <qevent.h>
#include <qtabwidget.h>
#include <qtabbar.h>
#include <qpe/config.h>
+#include <qstringlist.h>
+#include <qpalette.h>
#include <sys/wait.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "konsole.h"
#include "keytrans.h"
class EKNumTabBar : public QTabBar {
public:
void numberTabs()
{
- // Yes, it really is this messy. QTabWidget needs functions
- // that provide acces to tabs in a sequential way.
- int m=INT_MIN;
- for (int i=0; i<count(); i++) {
- QTab* left=0;
- QListIterator<QTab> it(*tabList());
- int x=INT_MAX;
- for( QTab* t; (t=it.current()); ++it ) {
- int tx = t->rect().x();
- if ( tx<x && tx>m ) {
- x = tx;
- left = t;
- }
- }
- if ( left ) {
- left->setText(QString::number(i+1));
- m = left->rect().x();
- }
- }
+ // Yes, it really is this messy. QTabWidget needs functions
+ // that provide acces to tabs in a sequential way.
+ int m=INT_MIN;
+ for (int i=0; i<count(); i++) {
+ QTab* left=0;
+ QListIterator<QTab> it(*tabList());
+ int x=INT_MAX;
+ for( QTab* t; (t=it.current()); ++it ) {
+ int tx = t->rect().x();
+ if ( tx<x && tx>m ) {
+ x = tx;
+ left = t;
+ }
+ }
+ if ( left ) {
+ left->setText(QString::number(i+1));
+ m = left->rect().x();
+ }
+ }
}
};
class EKNumTabWidget : public QTabWidget {
public:
EKNumTabWidget(QWidget* parent) : QTabWidget(parent)
{
}
void addTab(QWidget* w)
{
- QTab* t = new QTab(QString::number(tabBar()->count()+1));
- QTabWidget::addTab(w,t);
+ QTab* t = new QTab(QString::number(tabBar()->count()+1));
+ QTabWidget::addTab(w,t);
}
void removeTab(QWidget* w)
{
- removePage(w);
- ((EKNumTabBar*)tabBar())->numberTabs();
+ removePage(w);
+ ((EKNumTabBar*)tabBar())->numberTabs();
}
};
// This could be configurable or dynamicly generated from the bash history
// file of the user
static const char *commonCmds[] =
{
- "ls ",
- //"ls -la ",
+ "ls ", // I left this here, cause it looks better than the first alpha
+ "cardctl eject",
+ "cat ",
"cd ",
- "pwd",
- //"cat",
- //"less ",
- //"vi ",
- //"man ",
+ "chmod ",
+ "cp ",
+ "dc ",
+ "df ",
+ "dmesg",
"echo ",
- "set ",
- //"ps",
- "ps aux",
- //"tar",
- //"tar -zxf",
+ "find ",
+ "free",
"grep ",
- //"grep -i",
- //"mkdir",
- "cp ",
+ "ifconfig ",
+ "ipkg ",
+ "mkdir ",
"mv ",
+ "nc localhost 7776",
+ "nc localhost 7777",
+ "nslookup ",
+ "ping ",
+ "ps aux",
+ "pwd ",
"rm ",
"rmdir ",
- //"chmod",
- //"su",
-// "top",
- //"find",
- //"make",
- //"tail",
- "cardctl eject",
- "ifconfig ",
-// "iwconfig eth0 ",
- "nc localhost 7777",
- "nc localhost 7776",
- //"mount /dev/hda1",
+ "route ",
+ "set ",
+ "traceroute",
/*
"gzip",
"gunzip",
"chgrp",
"chown",
"date",
"dd",
"df",
"dmesg",
"fuser",
"hostname",
@@ -177,62 +174,104 @@ Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int)
void Konsole::init(const char* _pgm, QStrList & _args)
{
b_scroll = TRUE; // histon;
n_keytab = 0;
n_render = 0;
setCaption( tr("Terminal") );
setIcon( Resource::loadPixmap( "konsole" ) );
Config cfg("Konsole");
cfg.setGroup("Konsole");
-
+ QString tmp;
// initialize the list of allowed fonts ///////////////////////////////////
cfont = cfg.readNumEntry("FontID", 1);
QFont f = QFont("Micro", 4, QFont::Normal);
f.setFixedPitch(TRUE);
fonts.append(new VTFont(tr("Micro"), f));
f = QFont("Fixed", 7, QFont::Normal);
f.setFixedPitch(TRUE);
fonts.append(new VTFont(tr("Small Fixed"), f));
f = QFont("Fixed", 12, QFont::Normal);
f.setFixedPitch(TRUE);
fonts.append(new VTFont(tr("Medium Fixed"), f));
// create terminal emulation framework ////////////////////////////////////
nsessions = 0;
+
tab = new EKNumTabWidget(this);
- tab->setTabPosition(QTabWidget::Bottom);
+
connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*)));
- // create terminal toolbar ////////////////////////////////////////////////
+ // create terminal toolbar ////////////////////////////////////////////////
setToolBarsMovable( FALSE );
QPEToolBar *menuToolBar = new QPEToolBar( this );
menuToolBar->setHorizontalStretchable( TRUE );
QPEMenuBar *menuBar = new QPEMenuBar( menuToolBar );
fontList = new QPopupMenu( this );
for(uint i = 0; i < fonts.count(); i++) {
VTFont *fnt = fonts.at(i);
fontList->insertItem(fnt->getName(), i);
}
fontChanged(cfont);
+ configMenu = new QPopupMenu( this);
+ colorMenu = new QPopupMenu( this);
+
+ bool listHidden;
+ cfg.setGroup("Menubar");
+ if( cfg.readEntry("Hidden","FALSE") == "TRUE") {
+ configMenu->insertItem("Show command list");
+ listHidden=TRUE;
+ } else {
+ configMenu->insertItem("Hide command list");
+ listHidden=FALSE;
+ }
+
+ cfg.setGroup("Tabs");
+ tmp=cfg.readEntry("Position","Bottom");
+ if(tmp=="Top") {
+ tab->setTabPosition(QTabWidget::Top);
+ configMenu->insertItem("Tabs on Bottom");
+ } else {
+ tab->setTabPosition(QTabWidget::Bottom);
+ configMenu->insertItem("Tabs on Top");
+ }
+ configMenu->insertSeparator(2);
+
+ colorMenu->insertItem("Green on Black");
+ colorMenu->insertItem("Black on White");
+ colorMenu->insertItem("White on Black");
+ colorMenu->insertItem("Black on Transparent");
+ colorMenu->insertItem("Black on Red");
+ colorMenu->insertItem("Red on Black");
+ colorMenu->insertItem("Green on Yellow");
+ colorMenu->insertItem("Blue on Magenta");
+ colorMenu->insertItem("Magenta on Blue");
+ colorMenu->insertItem("Cyan on White");
+ colorMenu->insertItem("White on Cyan");
+ colorMenu->insertItem("Blue on Black");
+ configMenu->insertItem("Colors",colorMenu);
+
connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) ));
+ connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) ));
+ connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuSelected(int) ));
menuBar->insertItem( tr("Font"), fontList );
+ menuBar->insertItem( tr("Options"), configMenu );
QPEToolBar *toolbar = new QPEToolBar( this );
QAction *a;
// Button Commands
a = new QAction( tr("New"), Resource::loadPixmap( "konsole" ), QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); a->addTo( toolbar );
a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolbar );
a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolbar );
@@ -241,101 +280,119 @@ void Konsole::init(const char* _pgm, QStrList & _args)
a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar );
a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar );
a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); a->addTo( toolbar );
/*
a = new QAction( tr("Up"), Resource::loadPixmap( "up" ), QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar );
a = new QAction( tr("Down"), Resource::loadPixmap( "down" ), QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar );
*/
-
- QPEToolBar *secondToolBar = new QPEToolBar( this );
+
+ secondToolBar = new QPEToolBar( this );
secondToolBar->setHorizontalStretchable( TRUE );
- QComboBox *commonCombo = new QComboBox( secondToolBar );
-// commonCombo->setEditable( TRUE );
- for (int i = 0; commonCmds[i] != NULL; i++)
- commonCombo->insertItem( commonCmds[i], i );
+ commonCombo = new QComboBox( secondToolBar );
+
+ if( listHidden)
+ secondToolBar->hide();
+ configMenu->insertItem( "Edit Command List");
+
+ cfg.setGroup("Commands");
+ commonCombo->setInsertionPolicy(QComboBox::AtCurrent);
+
+ for (int i = 0; commonCmds[i] != NULL; i++) {
+ commonCombo->insertItem( commonCmds[i], i );
+ tmp = cfg.readEntry( QString::number(i),"");
+ if(tmp != "")
+ commonCombo->changeItem( tmp,i );
+ }
+
connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) ));
- // create applications /////////////////////////////////////////////////////
+ // create applications /////////////////////////////////////////////////////
setCentralWidget(tab);
// load keymaps ////////////////////////////////////////////////////////////
KeyTrans::loadAll();
for (int i = 0; i < KeyTrans::count(); i++)
{ KeyTrans* s = KeyTrans::find(i);
assert( s );
}
se_pgm = _pgm;
se_args = _args;
// read and apply default values ///////////////////////////////////////////
resize(321, 321); // Dummy.
QSize currentSize = size();
if (currentSize != size())
defaultSize = size();
+
}
void Konsole::show()
{
if ( !nsessions ) {
newSession();
}
QMainWindow::show();
}
void Konsole::initSession(const char*, QStrList &)
{
QMainWindow::show();
}
Konsole::~Konsole()
{
while (nsessions > 0) {
- doneSession(getTe()->currentSession, 0);
+ doneSession(getTe()->currentSession, 0);
}
Config cfg("Konsole");
cfg.setGroup("Konsole");
cfg.writeEntry("FontID", cfont);
}
void Konsole::fontChanged(int f)
{
VTFont* font = fonts.at(f);
if (font != 0) {
for(uint i = 0; i < fonts.count(); i++) {
- fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE);
- }
+ fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE);
+ }
- cfont = f;
+ cfont = f;
TEWidget* te = getTe();
- if (te != 0) {
- te->setVTFont(font->getFont());
- }
+ if (te != 0) {
+ te->setVTFont(font->getFont());
+ }
}
}
+
void Konsole::enterCommand(int c)
{
TEWidget* te = getTe();
if (te != 0) {
- QString text = commonCmds[c];
- te->emitText(text);
+ if(!commonCombo->editable()) {
+ QString text = commonCombo->text(c); //commonCmds[c];
+ te->emitText(text);
+ } else {
+ changeCommand( commonCombo->text(c), c);
+ }
}
}
void Konsole::hitEnter()
{
TEWidget* te = getTe();
if (te != 0) {
te->emitText(QString("\r"));
}
}
void Konsole::hitSpace()
@@ -381,26 +438,26 @@ void Konsole::hitDown()
}
/**
This function calculates the size of the external widget
needed for the internal widget to be
*/
QSize Konsole::calcSize(int columns, int lines) {
TEWidget* te = getTe();
if (te != 0) {
QSize size = te->calcSize(columns, lines);
return size;
} else {
- QSize size;
- return size;
+ QSize size;
+ return size;
}
}
/**
sets application window to a size based on columns X lines of the te
guest widget. Call with (0,0) for setting default size.
*/
void Konsole::setColLin(int columns, int lines)
{
if ((columns==0) || (lines==0))
{
@@ -458,55 +515,248 @@ void Konsole::changeColumns(int columns)
// session swap is completed.
void Konsole::doneSession(TESession*, int )
{
TEWidget *te = getTe();
if (te != 0) {
te->currentSession->setConnect(FALSE);
tab->removeTab(te);
delete te->currentSession;
delete te;
nsessions--;
}
-
+
if (nsessions == 0) {
close();
}
}
-
void Konsole::newSession() {
- TEWidget* te = new TEWidget(tab);
- te->setBackgroundMode(PaletteBase);
- te->setVTFont(fonts.at(cfont)->getFont());
- tab->addTab(te);
- TESession* se = new TESession(this, te, se_pgm, se_args, "xterm");
- te->currentSession = se;
- connect( se, SIGNAL(done(TESession*,int)), this, SLOT(doneSession(TESession*,int)) );
- se->run();
- se->setConnect(TRUE);
- se->setHistory(b_scroll);
- tab->setCurrentPage(nsessions);
- nsessions++;
+ if(nsessions < 15) { // seems to be something weird about 16 tabs on the Zaurus.... memory?
+ TEWidget* te = new TEWidget(tab);
+// te->setBackgroundMode(PaletteBase); //we want transparent!!
+ te->setVTFont(fonts.at(cfont)->getFont());
+ tab->addTab(te);
+ TESession* se = new TESession(this, te, se_pgm, se_args, "xterm");
+ te->currentSession = se;
+ connect( se, SIGNAL(done(TESession*,int)), this, SLOT(doneSession(TESession*,int)) );
+ se->run();
+ se->setConnect(TRUE);
+ se->setHistory(b_scroll);
+ tab->setCurrentPage(nsessions);
+ nsessions++;
+ setColor();
+ }
}
TEWidget* Konsole::getTe() {
if (nsessions) {
return (TEWidget *) tab->currentPage();
} else {
return 0;
}
- }
-
+}
+
void Konsole::switchSession(QWidget* w) {
TEWidget* te = (TEWidget *) w;
QFont teFnt = te->getVTFont();
for(uint i = 0; i < fonts.count(); i++) {
VTFont *fnt = fonts.at(i);
bool cf = fnt->getFont() == teFnt;
fontList->setItemChecked(i, cf);
if (cf) {
cfont = i;
}
}
}
+
+/// ------------------------------- some new stuff by L.J. Potter
+void Konsole::colorMenuSelected(int iD)
+{ // this is NOT pretty, elegant or anything else besides functional
+// QString temp;
+// temp.sprintf("%d", iD);
+// qDebug(temp);
+ TEWidget* te = getTe();
+ Config cfg("Konsole");
+ cfg.setGroup("Colors");
+ QColor foreground;
+ QColor background;
+ colorMenu->setItemChecked(lastSelectedMenu,FALSE);
+ ColorEntry m_table[TABLE_COLORS];
+ const ColorEntry * defaultCt=te->getdefaultColorTable();
+ /////////// fore back
+ int i;
+ if(iD==-8) { // default default
+ for (i = 0; i < TABLE_COLORS; i++) {
+ m_table[i].color = defaultCt[i].color;
+ if(i==1 || i == 11)
+ m_table[i].transparent=1;
+ cfg.writeEntry("Schema","8");
+ colorMenu->setItemChecked(-8,TRUE);
+ }
+ } else {
+ if(iD==-5) { // green black
+ foreground.setRgb(0x18,255,0x18);
+ background.setRgb(0x00,0x00,0x00);
+ cfg.writeEntry("Schema","5");
+ colorMenu->setItemChecked(-5,TRUE);
+ }
+ if(iD==-6) { // black white
+ foreground.setRgb(0x00,0x00,0x00);
+ background.setRgb(0xFF,0xFF,0xFF);
+ cfg.writeEntry("Schema","6");
+ colorMenu->setItemChecked(-6,TRUE);
+ }
+ if(iD==-7) { // white black
+ foreground.setRgb(0xFF,0xFF,0xFF);
+ background.setRgb(0x00,0x00,0x00);
+ cfg.writeEntry("Schema","7");
+ colorMenu->setItemChecked(-7,TRUE);
+ }
+ if(iD==-9) {// Black, Red
+ foreground.setRgb(0x00,0x00,0x00);
+ background.setRgb(0xB2,0x18,0x18);
+ cfg.writeEntry("Schema","9");
+ colorMenu->setItemChecked(-9,TRUE);
+ }
+ if(iD==-10) {// Red, Black
+ foreground.setRgb(230,31,31); //0xB2,0x18,0x18
+ background.setRgb(0x00,0x00,0x00);
+ cfg.writeEntry("Schema","10");
+ colorMenu->setItemChecked(-10,TRUE);
+ }
+ if(iD==-11) {// Green, Yellow - is ugly
+// foreground.setRgb(0x18,0xB2,0x18);
+ foreground.setRgb(36,139,10);
+// background.setRgb(0xB2,0x68,0x18);
+ background.setRgb(255,255,0);
+ cfg.writeEntry("Schema","11");
+ colorMenu->setItemChecked(-11,TRUE);
+ }
+ if(iD==-12) {// Blue, Magenta
+ foreground.setRgb(0x18,0xB2,0xB2);
+ background.setRgb(0x18,0x18,0xB2);
+ cfg.writeEntry("Schema","12");
+ colorMenu->setItemChecked(-12,TRUE);
+ }
+ if(iD==-13) {// Magenta, Blue
+ foreground.setRgb(0x18,0x18,0xB2);
+ background.setRgb(0x18,0xB2,0xB2);
+ cfg.writeEntry("Schema","13");
+ colorMenu->setItemChecked(-13,TRUE);
+ }
+ if(iD==-14) {// Cyan, White
+ foreground.setRgb(0x18,0xB2,0xB2);
+ background.setRgb(0xFF,0xFF,0xFF);
+ cfg.writeEntry("Schema","14");
+ colorMenu->setItemChecked(-14,TRUE);
+ }
+ if(iD==-15) {// White, Cyan
+ background.setRgb(0x18,0xB2,0xB2);
+ foreground.setRgb(0xFF,0xFF,0xFF);
+ cfg.writeEntry("Schema","15");
+ colorMenu->setItemChecked(-15,TRUE);
+ }
+ if(iD==-16) {// Black, Blue
+ background.setRgb(0x00,0x00,0x00);
+ foreground.setRgb(0x18,0xB2,0xB2);
+ cfg.writeEntry("Schema","16");
+ colorMenu->setItemChecked(-16,TRUE);
+ }
+
+ for (i = 0; i < TABLE_COLORS; i++) {
+ if(i==0 || i == 10) {
+ m_table[i].color = foreground;
+ }
+ else if(i==1 || i == 11) {
+ m_table[i].color = background; m_table[i].transparent=0;
+ }
+ else
+ m_table[i].color = defaultCt[i].color;
+ }
+ }
+ lastSelectedMenu = iD;
+ te->setColorTable(m_table);
+// update();
+}
+
+void Konsole::configMenuSelected(int iD)
+{
+// QString temp;
+// temp.sprintf("%d",iD);
+// qDebug(temp);
+ TEWidget* te = getTe();
+ Config cfg("Konsole");
+ cfg.setGroup("Menubar");
+ if( iD == -2) {
+ if(!secondToolBar->isHidden()) {
+ secondToolBar->hide();
+ configMenu->changeItem( iD,"Show Command List");
+ cfg.writeEntry("Hidden","TRUE");
+ configMenu->setItemEnabled(-20 ,FALSE);
+ } else {
+ secondToolBar->show();
+ configMenu->changeItem( iD,"Hide Command List");
+ cfg.writeEntry("Hidden","FALSE");
+ configMenu->setItemEnabled(-20 ,TRUE);
+
+ if(cfg.readEntry("EditEnabled","FALSE")=="TRUE") {
+ configMenu->setItemChecked(-16,TRUE);
+ commonCombo->setEditable( TRUE );
+ } else {
+ configMenu->setItemChecked(-20,FALSE);
+ commonCombo->setEditable( FALSE );
+ }
+ }
+ }
+ if( iD == -3) {
+ cfg.setGroup("Tabs");
+ QString tmp=cfg.readEntry("Position","Top");
+
+ if(tmp=="Top") {
+ tab->setTabPosition(QTabWidget::Bottom);
+ configMenu->changeItem( iD,"Tabs on Top");
+ cfg.writeEntry("Position","Bottom");
+ } else {
+ tab->setTabPosition(QTabWidget::Top);
+ configMenu->changeItem( iD,"Tabs on Bottom");
+ cfg.writeEntry("Position","Top");
+ }
+ }
+ if( iD == -20) {
+ cfg.setGroup("Commands");
+// qDebug("enableCommandEdit");
+ if( !configMenu->isItemChecked(iD) ) {
+ commonCombo->setEditable( TRUE );
+ configMenu->setItemChecked(iD,TRUE);
+ commonCombo->setCurrentItem(0);
+ cfg.writeEntry("EditEnabled","TRUE");
+ } else {
+ commonCombo->setEditable( FALSE );
+ configMenu->setItemChecked(iD,FALSE);
+ cfg.writeEntry("EditEnabled","FALSE");
+ commonCombo->setFocusPolicy(QWidget::NoFocus);
+ te->setFocus();
+ }
+ }
+}
+
+void Konsole::changeCommand(const QString &text, int c)
+{
+ Config cfg("Konsole");
+ cfg.setGroup("Commands");
+ if(commonCmds[c] != text) {
+ cfg.writeEntry(QString::number(c),text);
+ commonCombo->clearEdit();
+ commonCombo->setCurrentItem(c);
+ }
+}
+
+void Konsole::setColor()
+{
+ Config cfg("Konsole");
+ cfg.setGroup("Colors");
+ int scheme = cfg.readNumEntry("Schema",1);
+ if(scheme != 1) colorMenuSelected( -scheme);
+
+}
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 @@
/* [konsole.h] Konsole */
/* */
/* -------------------------------------------------------------------------- */
/* */
/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */
/* */
/* This file is part of Konsole, an X terminal. */
/* */
/* The material contained in here more or less directly orginates from */
/* kvt, which is copyright (c) 1996 by Matthias Ettrich <ettrich@kde.org> */
/* */
/* -------------------------------------------------------------------------- */
-/* */
+/* */
/* Ported Konsole to Qt/Embedded */
-/* */
+/* */
/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */
-/* */
+/* */
/* -------------------------------------------------------------------------- */
#ifndef KONSOLE_H
#define KONSOLE_H
#include <qmainwindow.h>
#include <qaction.h>
#include <qpopupmenu.h>
#include <qstrlist.h>
#include <qintdict.h>
#include <qptrdict.h>
#include <qtabwidget.h>
+#include <qpe/qpetoolbar.h>
+#include <qcombobox.h>
#include "MyPty.h"
#include "TEWidget.h"
#include "TEmuVt102.h"
#include "session.h"
class EKNumTabWidget;
class Konsole : public QMainWindow
{
Q_OBJECT
public:
Konsole(QWidget* parent = 0, const char* name = 0, WFlags fl = 0);
Konsole(const char * name, const char* pgm, QStrList & _args, int histon);
~Konsole();
void setColLin(int columns, int lines);
-
+ QPEToolBar *secondToolBar;
void show();
-
+ void setColor();
+ int lastSelectedMenu;
private slots:
void doneSession(TESession*,int);
void changeColumns(int);
void fontChanged(int);
+ void configMenuSelected(int );
+ void colorMenuSelected(int);
void enterCommand(int);
void hitEnter();
void hitSpace();
void hitTab();
void hitPaste();
void hitUp();
void hitDown();
void switchSession(QWidget *);
void newSession();
+ void changeCommand(const QString &, int);
private:
void init(const char* _pgm, QStrList & _args);
void initSession(const char* _pgm, QStrList & _args);
void runSession(TESession* s);
void setColorPixmaps();
void setHistory(bool);
QSize calcSize(int columns, int lines);
TEWidget* getTe();
private:
class VTFont
@@ -97,27 +103,27 @@ private:
private:
QString name;
QFont font;
};
EKNumTabWidget* tab;
int nsessions;
QList<VTFont> fonts;
int cfont;
QCString se_pgm;
QStrList se_args;
- QPopupMenu* fontList;
-
- // history scrolling I think
+ QPopupMenu* fontList,*configMenu,*colorMenu;
+ QComboBox *commonCombo;
+ // history scrolling I think
bool b_scroll;
int n_keytab;
int n_scroll;
int n_render;
QString pmPath; // pixmap path
QString dropText;
QFont defaultFont;
QSize defaultSize;
};