summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/embeddedkonsole/konsole.cpp20
1 files changed, 9 insertions, 11 deletions
diff --git a/core/apps/embeddedkonsole/konsole.cpp b/core/apps/embeddedkonsole/konsole.cpp
index f154bb8..653652a 100644
--- a/core/apps/embeddedkonsole/konsole.cpp
+++ b/core/apps/embeddedkonsole/konsole.cpp
@@ -250,187 +250,187 @@ void Konsole::init(const char* _pgm, QStrList & _args)
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 );
a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolbar );
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 );
*/
secondToolBar = new QPEToolBar( this );
secondToolBar->setHorizontalStretchable( TRUE );
commonCombo = new QComboBox( secondToolBar );
-
+ commonCombo->setMaximumWidth(236);
configMenu->insertItem( "Edit Command List");
if( listHidden) {
secondToolBar->hide();
configMenu->setItemEnabled(-20 ,FALSE);
}
-
+
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 /////////////////////////////////////////////////////
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);
}
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);
}
cfont = f;
TEWidget* te = getTe();
if (te != 0) {
te->setVTFont(font->getFont());
}
}
}
void Konsole::enterCommand(int c)
{
TEWidget* te = getTe();
if (te != 0) {
if(!commonCombo->editable()) {
QString text = commonCombo->text(c); //commonCmds[c];
te->emitText(text);
} else {
- changeCommand( commonCombo->text(c), c);
+ changeCommand( commonCombo->text(c), c);
}
}
}
void Konsole::hitEnter()
{
TEWidget* te = getTe();
if (te != 0) {
te->emitText(QString("\r"));
}
}
void Konsole::hitSpace()
{
TEWidget* te = getTe();
if (te != 0) {
te->emitText(QString(" "));
}
}
void Konsole::hitTab()
{
TEWidget* te = getTe();
if (te != 0) {
te->emitText(QString("\t"));
}
}
void Konsole::hitPaste()
{
TEWidget* te = getTe();
if (te != 0) {
te->pasteClipboard();
}
}
void Konsole::hitUp()
{
TEWidget* te = getTe();
if (te != 0) {
QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Up, 0, 0);
QApplication::sendEvent( te, &ke );
}
}
void Konsole::hitDown()
{
TEWidget* te = getTe();
@@ -532,98 +532,97 @@ void Konsole::doneSession(TESession*, int )
close();
}
}
void Konsole::newSession() {
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);
+// qDebug( temp.sprintf("%d", iD));
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);
@@ -640,126 +639,125 @@ void Konsole::colorMenuSelected(int iD)
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);
+ QString temp;
+ qDebug( temp.sprintf("%d",iD));
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(-20,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);
+ commonCombo->setCurrentItem(c);
}
}
void Konsole::setColor()
{
Config cfg("Konsole");
cfg.setGroup("Colors");
- int scheme = cfg.readNumEntry("Schema",1);
- if(scheme != 1) colorMenuSelected( -scheme);
+ int scheme = cfg.readNumEntry("Schema",1);
+ if(scheme != 1) colorMenuSelected( -scheme);
}