-rw-r--r-- | core/apps/embeddedkonsole/TEHistory.h | 6 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/TEScreen.h | 14 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/TEWidget.cpp | 5 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/TEmulation.h | 7 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/konsole.cpp | 90 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/konsole.h | 1 |
6 files changed, 83 insertions, 40 deletions
diff --git a/core/apps/embeddedkonsole/TEHistory.h b/core/apps/embeddedkonsole/TEHistory.h index 8339ec6..11eb150 100644 --- a/core/apps/embeddedkonsole/TEHistory.h +++ b/core/apps/embeddedkonsole/TEHistory.h @@ -1,75 +1,75 @@ /* -------------------------------------------------------------------------- */ /* */ /* [TEHistory.H] History Buffer */ /* */ /* -------------------------------------------------------------------------- */ /* */ /* 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 TEHISTORY_H #define TEHISTORY_H #include "TECommon.h" /* An extendable tmpfile(1) based buffer. */ class HistoryBuffer { public: HistoryBuffer(); ~HistoryBuffer(); public: void setScroll(bool on); bool hasScroll(); public: void add(const unsigned char* bytes, int len); void get(unsigned char* bytes, int len, int loc); int len(); private: int ion; int length; }; class HistoryScroll { public: HistoryScroll(); ~HistoryScroll(); public: void setScroll(bool on); bool hasScroll(); public: // access to history int getLines(); int getLineLen(int lineno); void getCells(int lineno, int colno, int count, ca res[]); public: // backward compatibility (obsolete) ca getCell(int lineno, int colno) { ca res; getCells(lineno,colno,1,&res); return res; } public: // adding lines. void addCells(ca a[], int count); void addLine(); private: int startOfLine(int lineno); HistoryBuffer index; // lines Row(int) HistoryBuffer cells; // text Row(ca) }; #endif // TEHISTORY_H diff --git a/core/apps/embeddedkonsole/TEScreen.h b/core/apps/embeddedkonsole/TEScreen.h index ba47ee5..a28f7c5 100644 --- a/core/apps/embeddedkonsole/TEScreen.h +++ b/core/apps/embeddedkonsole/TEScreen.h @@ -1,259 +1,267 @@ /* -------------------------------------------------------------------------- */ /* */ /* [te_screen.h] Screen Data Type */ /* */ /* -------------------------------------------------------------------------- */ /* */ /* 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 TESCREEN_H #define TESCREEN_H /*! \file */ #include "TECommon.h" #include "TEHistory.h" #define MODE_Origin 0 #define MODE_Wrap 1 #define MODE_Insert 2 #define MODE_Screen 3 #define MODE_Cursor 4 #define MODE_NewLine 5 #define MODES_SCREEN 6 /*! */ struct ScreenParm { int mode[MODES_SCREEN]; }; class TEScreen { public: TEScreen(int lines, int columns); ~TEScreen(); public: // these are all `Screen' operations // // VT100/2 Operations ------------------ // // Cursor Movement // void cursorUp (int n); void cursorDown (int n); void cursorLeft (int n); void cursorRight (int n); void setCursorY (int y); void setCursorX (int x); void setCursorYX (int y, int x); void setMargins (int t, int b); // // Cursor Movement with Scrolling // void NewLine (); void NextLine (); void index (); void reverseIndex(); // void Return (); void BackSpace (); void Tabulate (); // // Editing // void eraseChars (int n); void deleteChars (int n); void insertChars (int n); void deleteLines (int n); void insertLines (int n); // // ------------------------------------- // void clearTabStops(); void changeTabStop(bool set); // void resetMode (int n); void setMode (int n); void saveMode (int n); void restoreMode (int n); // void saveCursor (); void restoreCursor(); // // ------------------------------------- // void clearEntireScreen(); void clearToEndOfScreen(); void clearToBeginOfScreen(); // void clearEntireLine(); void clearToEndOfLine(); void clearToBeginOfLine(); // void helpAlign (); // // ------------------------------------- // void setRendition (int rendition); void resetRendition(int rendition); void setForeColor (int fgcolor); void setBackColor (int bgcolor); // void setDefaultRendition(); void setForeColorToDefault(); void setBackColorToDefault(); // // ------------------------------------- // BOOL getMode (int n); // // only for report cursor position // int getCursorX(); int getCursorY(); // // ------------------------------------- // void clear(); void home(); void reset(); // void ShowCharacter(unsigned short c); // void resizeImage(int new_lines, int new_columns); // ca* getCookedImage(); /*! return the number of lines. */ int getLines() { return lines; } + /*! return the number of columns. */ int getColumns() { return columns; } /*! set the position of the history cursor. */ void setHistCursor(int cursor); /*! return the position of the history cursor. */ int getHistCursor(); + /*! set the position of the horizontal cursor. */ + void setHorzCursor(int cursor); + /*! return the position of the horizontal cursor. */ + int getHorzCursor(); + int getHistLines (); void setScroll(bool on); bool hasScroll(); // // Selection // void setSelBeginXY(const int x, const int y); void setSelExtentXY(const int x, const int y); void clearSelection(); QString getSelText(const BOOL preserve_line_breaks); void checkSelection(int from, int to); private: // helper void clearImage(int loca, int loce, char c); void moveImage(int dst, int loca, int loce); void scrollUp(int from, int i); void scrollDown(int from, int i); void addHistLine(); void initTabStops(); void effectiveRendition(); void reverseRendition(ca* p); private: /* The state of the screen is more complex as one would expect first. The screem does really do part of the emulation providing state informations in form of modes, margins, tabulators, cursor etc. Even more unexpected are variables to save and restore parts of the state. */ // screen image ---------------- int lines; int columns; ca *image; // [lines][columns] // history buffer --------------- int histCursor; // display position relative to start of the history buffer HistoryScroll hist; + + int horzCursor; // cursor location int cuX; int cuY; // cursor color and rendition info UINT8 cu_fg; // foreground UINT8 cu_bg; // background UINT8 cu_re; // rendition // margins ---------------- int tmargin; // top margin int bmargin; // bottom margin // states ---------------- ScreenParm currParm; // ---------------------------- bool* tabstops; // selection ------------------- int sel_begin; // The first location selected. int sel_TL; // TopLeft Location. int sel_BR; // Bottom Right Location. // effective colors and rendition ------------ UINT8 ef_fg; // These are derived from UINT8 ef_bg; // the cu_* variables above UINT8 ef_re; // to speed up operation // // save cursor, rendition & states ------------ // // cursor location int sa_cuX; int sa_cuY; // rendition info UINT8 sa_cu_re; UINT8 sa_cu_fg; UINT8 sa_cu_bg; // modes ScreenParm saveParm; }; #endif // TESCREEN_H diff --git a/core/apps/embeddedkonsole/TEWidget.cpp b/core/apps/embeddedkonsole/TEWidget.cpp index c10c7a8..60021f4 100644 --- a/core/apps/embeddedkonsole/TEWidget.cpp +++ b/core/apps/embeddedkonsole/TEWidget.cpp @@ -239,193 +239,194 @@ static QChar identicalMap(QChar c) { return c; } 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") ? vt100extended : #endif identicalMap; propagateSize(); update(); } void TEWidget::setVTFont(const QFont& f) { QFrame::setFont(f); } QFont TEWidget::getVTFont() { return font(); } void TEWidget::setFont(const QFont &) { // ignore font change request if not coming from konsole itself } /* ------------------------------------------------------------------------- */ /* */ /* Constructor / Destructor */ /* */ /* ------------------------------------------------------------------------- */ TEWidget::TEWidget(QWidget *parent, const char *name) : QFrame(parent,name) { #ifndef QT_NO_CLIPBOARD cb = QApplication::clipboard(); QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), this, SLOT(onClearSelection()) ); #endif scrollbar = new QScrollBar(this); scrollbar->setCursor( arrowCursor ); connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); hScrollbar = new QScrollBar(this); hScrollbar->setCursor( arrowCursor ); hScrollbar->setOrientation(QScrollBar::Horizontal); hScrollbar->setMaximumHeight(16); connect( hScrollbar, SIGNAL(valueChanged(int)), this, SLOT( hScrollChanged(int))); Config cfg("Konsole"); cfg.setGroup("ScrollBar"); switch( cfg.readNumEntry("Position",2)){ case 0: scrollLoc = SCRNONE; break; case 1: scrollLoc = SCRLEFT; break; case 2: scrollLoc = SCRRIGHT; break; }; useHorzScroll=cfg.readBoolEntry("HorzScroll",0); blinkT = new QTimer(this); connect(blinkT, SIGNAL(timeout()), this, SLOT(blinkEvent())); // blinking = FALSE; blinking = TRUE; resizing = FALSE; actSel = 0; image = 0; lines = 1; columns = 1; font_w = 1; font_h = 1; font_a = 1; word_selection_mode = FALSE; hposition = 0; - +vcolumns = 0; + setMouseMarks(TRUE); setVTFont( QFont("fixed") ); setColorTable(base_color_table); // init color table qApp->installEventFilter( this ); //FIXME: see below // KCursor::setAutoHideCursor( this, true ); // Init DnD //////////////////////////////////////////////////////////////// currentSession = NULL; // setAcceptDrops(true); // attempt // m_drop = new QPopupMenu(this); // m_drop->insertItem( QString("Paste"), 0); // m_drop->insertItem( QString("cd"), 1); // connect(m_drop, SIGNAL(activated(int)), SLOT(drop_menu_activated(int))); // we need focus so that the auto-hide cursor feature works setFocus(); setFocusPolicy( WheelFocus ); } //FIXME: make proper destructor // Here's a start (David) TEWidget::~TEWidget() { qApp->removeEventFilter( this ); if (image) free(image); } /* ------------------------------------------------------------------------- */ /* */ /* Display Operations */ /* */ /* ------------------------------------------------------------------------- */ /*! attributed string draw primitive */ void TEWidget::drawAttrStr(QPainter &paint, QRect rect, QString& str, ca attr, BOOL pm, BOOL clear) { if (pm && color_table[attr.b].transparent) { paint.setBackgroundMode( TransparentMode ); if (clear) erase(rect); } else { if (blinking) paint.fillRect(rect, color_table[attr.b].color); else { paint.setBackgroundMode( OpaqueMode ); paint.setBackgroundColor( color_table[attr.b].color ); } } if (color_table[attr.f].bold) paint.setPen(QColor( 0x8F, 0x00, 0x00 )); else paint.setPen(color_table[attr.f].color); paint.drawText(rect.x(),rect.y()+font_a, str); if (attr.r & RE_UNDERLINE) paint.drawLine(rect.left(), rect.y()+font_a+1, rect.right(),rect.y()+font_a+1 ); } /*! The image can only be set completely. The size of the new image may or may not match the size of the widget. */ void TEWidget::setImage(const ca* const newimg, int lines, int columns) { int y,x,len; const QPixmap* pm = backgroundPixmap(); QPainter paint; setUpdatesEnabled(FALSE); paint.begin( this ); HCNT("setImage"); QPoint tL = contentsRect().topLeft(); int tLx = tL.x(); int tLy = tL.y(); hasBlinker = FALSE; int cf = -1; // undefined int cb = -1; // undefined int cr = -1; // undefined int lins = QMIN(this->lines, QMAX(0,lines )); int cols = QMIN(this->columns,QMAX(0,columns)); QChar *disstrU = new QChar[cols]; for (y = 0; y < lins; y++) { const ca* lcl = &image[y*this->columns]; @@ -1310,98 +1311,96 @@ void TEWidget::dragEnterEvent(QDragEnterEvent* e) QUriDrag::canDecode(e)); } void TEWidget::dropEvent(QDropEvent* event) { // The current behaviour when url(s) are dropped is // * if there is only ONE url and if it's a LOCAL one, ask for paste or cd // * in all other cases, just paste // (for non-local ones, or for a list of URLs, 'cd' is nonsense) QStrList strlist; int file_count = 0; dropText = ""; bool bPopup = true; if(QUriDrag::decode(event, strlist)) { if (strlist.count()) { for(const char* p = strlist.first(); p; p = strlist.next()) { if(file_count++ > 0) { dropText += " "; bPopup = false; // more than one file, don't popup } /* KURL url(p); if (url.isLocalFile()) { 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())); else { 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 void TEWidget::drop_menu_activated(int item) { #ifndef QT_NO_DRAGANDDROP switch (item) { case 0: // paste currentSession->getEmulation()->sendString(dropText.local8Bit()); // KWM::activate((Window)this->winId()); break; case 1: // cd ... currentSession->getEmulation()->sendString("cd "); struct stat statbuf; if ( ::stat( QFile::encodeName( dropText ), &statbuf ) == 0 ) { if ( !S_ISDIR(statbuf.st_mode) ) { /* KURL url; url.setPath( dropText ); dropText = url.directory( true, false ); // remove filename */ } } dropText.replace(QRegExp(" "), "\\ "); // escape spaces currentSession->getEmulation()->sendString(dropText.local8Bit()); currentSession->getEmulation()->sendString("\n"); // KWM::activate((Window)this->winId()); break; } #endif } void TEWidget::setWrapAt(int columns) { vcolumns = columns; propagateSize(); update(); } - - diff --git a/core/apps/embeddedkonsole/TEmulation.h b/core/apps/embeddedkonsole/TEmulation.h index ec15e7a..bf43f11 100644 --- a/core/apps/embeddedkonsole/TEmulation.h +++ b/core/apps/embeddedkonsole/TEmulation.h @@ -1,117 +1,118 @@ /* -------------------------------------------------------------------------- */ /* */ /* [emulation.h] Fundamental Terminal Emulation */ /* */ /* -------------------------------------------------------------------------- */ /* */ /* 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 EMULATION_H #define EMULATION_H #include "TEWidget.h" #include "TEScreen.h" #include <qtimer.h> #include <stdio.h> #include <qtextcodec.h> #include "keytrans.h" class TEmulation : public QObject { Q_OBJECT public: TEmulation(TEWidget* gui); ~TEmulation(); public: virtual void setHistory(bool on); virtual bool history(); public slots: // signals incoming from TEWidget virtual void onImageSizeChange(int lines, int columns); virtual void onHistoryCursorChange(int cursor); + virtual void onHorzCursorChange(int cursor); virtual void onKeyPress(QKeyEvent*); virtual void clearSelection(); virtual void onSelectionBegin(const int x, const int y); virtual void onSelectionExtend(const int x, const int y); virtual void setSelection(const BOOL preserve_line_breaks); public slots: // signals incoming from data source void onRcvBlock(const char* txt,int len); signals: void sndBlock(const char* txt,int len); void ImageSizeChanged(int lines, int columns); void changeColumns(int columns); void changeTitle(int arg, const char* str); public: virtual void onRcvChar(int); virtual void setMode (int) = 0; virtual void resetMode(int) = 0; virtual void sendString(const char*) = 0; virtual void setConnect(bool r); void setColumns(int columns); void setKeytrans(int no); void setKeytrans(const char * no); protected: TEWidget* gui; TEScreen* scr; // referes to one `screen' TEScreen* screen[2]; // 0 = primary, 1 = alternate void setScreen(int n); // set `scr' to `screen[n]' bool connected; // communicate with widget void setCodec(int c); // codec number, 0 = locale, 1=utf8 QTextCodec* codec; QTextCodec* localeCodec; QTextDecoder* decoder; KeyTrans* keytrans; // refreshing related material. // this is localized in the class. private slots: // triggered by timer void showBulk(); private: void bulkNewline(); void bulkStart(); void bulkEnd(); private: QTimer bulk_timer; int bulk_nlcnt; // bulk newline counter char* SelectedText; int bulk_incnt; // bulk counter }; #endif // ifndef EMULATION_H diff --git a/core/apps/embeddedkonsole/konsole.cpp b/core/apps/embeddedkonsole/konsole.cpp index 3c87ad4..16db0ea 100644 --- a/core/apps/embeddedkonsole/konsole.cpp +++ b/core/apps/embeddedkonsole/konsole.cpp @@ -265,233 +265,237 @@ void Konsole::init(const char* _pgm, QStrList & _args) listHidden=TRUE; } else { editCommandListMenu->insertItem( tr( "Hide command list" )); listHidden=FALSE; } cfg.setGroup("Tabs"); tmp=cfg.readEntry("Position","Bottom"); if(tmp=="Top") { tab->setTabPosition(QTabWidget::Top); configMenu->insertItem( tr( "Tabs on Bottom" ) ); } else { tab->setTabPosition(QTabWidget::Bottom); configMenu->insertItem("Tabs on Top"); } configMenu->insertSeparator(2); colorMenu->insertItem(tr( "Green on Black")); colorMenu->insertItem(tr( "Black on White")); colorMenu->insertItem(tr( "White on Black")); colorMenu->insertItem(tr( "Black on Transparent")); colorMenu->insertItem(tr( "Black on Red")); colorMenu->insertItem(tr( "Red on Black")); colorMenu->insertItem(tr( "Green on Yellow")); colorMenu->insertItem(tr( "Blue on Magenta")); colorMenu->insertItem(tr( "Magenta on Blue")); colorMenu->insertItem(tr( "Cyan on White")); colorMenu->insertItem(tr( "White on Cyan")); colorMenu->insertItem(tr( "Blue on Black")); colorMenu->insertItem(tr( "Amber on Black")); colorMenu->insertItem(tr( "Custom")); configMenu->insertItem(tr( "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( colorMenuIsSelected(int) )); connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int))); connect(editCommandListMenu,SIGNAL(activated(int)),this,SLOT(editCommandListMenuSelected(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); editCommandListMenu->insertItem( tr( "Quick Edit" ) ); if( listHidden) { secondToolBar->hide(); editCommandListMenu->setItemEnabled(-23 ,FALSE); } editCommandListMenu->insertItem(tr( "Edit" ) ); cfg.setGroup("Commands"); commonCombo->setInsertionPolicy(QComboBox::AtCurrent); initCommandList(); // 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) )); scrollMenu->insertItem(tr( "None" )); scrollMenu->insertItem(tr( "Left" )); scrollMenu->insertItem(tr( "Right" )); - scrollMenu->insertSeparator(4); - scrollMenu->insertItem(tr( "Horizontal" )); +// scrollMenu->insertSeparator(4); +// scrollMenu->insertItem(tr( "Horizontal" )); configMenu->insertItem(tr( "ScrollBar" ),scrollMenu); + + configMenu->insertItem(tr( "Wrap" )); + //scrollMenuSelected(-29); // cfg.setGroup("ScrollBar"); // if(cfg.readBoolEntry("HorzScroll",0)) { // if(cfg.readNumEntry("Position",2) == 0) // te->setScrollbarLocation(1); // else // te->setScrollbarLocation(0); // te->setScrollbarLocation( cfg.readNumEntry("Position",2)); // te->setWrapAt(120); // } // 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; se_args.prepend("--login"); parseCommandLine(); // 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); } } } 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(); if (te != 0) { QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Down, 0, 0); QApplication::sendEvent( te, &ke ); @@ -505,469 +509,499 @@ void Konsole::hitDown() 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; } } /** 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) { qDebug("konsole::setColLin:: Columns %d", columns); if ((columns==0) || (lines==0)) { if (defaultSize.isEmpty()) // not in config file : set default value { defaultSize = calcSize(80,24); // notifySize(24,80); // set menu items (strange arg order !) } resize(defaultSize); } else { resize(calcSize(columns, lines)); // notifySize(lines,columns); // set menu items (strange arg order !) } } /* void Konsole::setFont(int fontno) { QFont f; if (fontno == 0) f = defaultFont = QFont( "Helvetica", 12 ); else if (fonts[fontno][0] == '-') f.setRawName( fonts[fontno] ); else { f.setFamily(fonts[fontno]); f.setRawMode( TRUE ); } if ( !f.exactMatch() && fontno != 0) { QString msg = i18n("Font `%1' not found.\nCheck README.linux.console for help.").arg(fonts[fontno]); QMessageBox(this, msg); return; } if (se) se->setFontNo(fontno); te->setVTFont(f); n_font = fontno; } */ // --| color selection |------------------------------------------------------- void Konsole::changeColumns(int columns) { qDebug("change columns"); TEWidget* te = getTe(); if (te != 0) { setColLin(columns,te->Lines()); te->update(); } } //FIXME: If a child dies during session swap, // this routine might be called before // 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() { 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(); + 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++; + doWrap(); + 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; } } } void Konsole::colorMenuIsSelected(int iD) { fromMenu = TRUE; colorMenuSelected(iD); } /// ------------------------------- some new stuff by L.J. Potter void Konsole::colorMenuSelected(int iD) { // this is NOT pretty, elegant or anything else besides functional // QString temp; // qDebug( temp.sprintf("colormenu %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==-9) { // 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","9"); colorMenu->setItemChecked(-9,TRUE); } } else { if(iD==-6) { // green black foreground.setRgb(0x18,255,0x18); background.setRgb(0x00,0x00,0x00); cfg.writeEntry("Schema","6"); colorMenu->setItemChecked(-6,TRUE); } if(iD==-7) { // black white foreground.setRgb(0x00,0x00,0x00); background.setRgb(0xFF,0xFF,0xFF); cfg.writeEntry("Schema","7"); colorMenu->setItemChecked(-7,TRUE); } if(iD==-8) { // white black foreground.setRgb(0xFF,0xFF,0xFF); background.setRgb(0x00,0x00,0x00); cfg.writeEntry("Schema","8"); colorMenu->setItemChecked(-8,TRUE); } if(iD==-10) {// Black, Red foreground.setRgb(0x00,0x00,0x00); background.setRgb(0xB2,0x18,0x18); cfg.writeEntry("Schema","10"); colorMenu->setItemChecked(-10,TRUE); } if(iD==-11) {// Red, Black foreground.setRgb(230,31,31); //0xB2,0x18,0x18 background.setRgb(0x00,0x00,0x00); cfg.writeEntry("Schema","11"); colorMenu->setItemChecked(-11,TRUE); } if(iD==-12) {// 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","12"); colorMenu->setItemChecked(-12,TRUE); } if(iD==-13) {// Blue, Magenta foreground.setRgb(0x18,0xB2,0xB2); background.setRgb(0x18,0x18,0xB2); cfg.writeEntry("Schema","13"); colorMenu->setItemChecked(-13,TRUE); } if(iD==-14) {// Magenta, Blue foreground.setRgb(0x18,0x18,0xB2); background.setRgb(0x18,0xB2,0xB2); cfg.writeEntry("Schema","14"); colorMenu->setItemChecked(-14,TRUE); } if(iD==-15) {// Cyan, White foreground.setRgb(0x18,0xB2,0xB2); background.setRgb(0xFF,0xFF,0xFF); cfg.writeEntry("Schema","15"); colorMenu->setItemChecked(-15,TRUE); } if(iD==-16) {// White, Cyan background.setRgb(0x18,0xB2,0xB2); foreground.setRgb(0xFF,0xFF,0xFF); cfg.writeEntry("Schema","16"); colorMenu->setItemChecked(-16,TRUE); } if(iD==-17) {// Black, Blue background.setRgb(0x00,0x00,0x00); foreground.setRgb(0x18,0xB2,0xB2); cfg.writeEntry("Schema","17"); colorMenu->setItemChecked(-17,TRUE); } if(iD==-18) {// Black, Gold background.setRgb(0x00,0x00,0x00); foreground.setRgb(255,215,0); cfg.writeEntry("Schema","18"); colorMenu->setItemChecked(-18,TRUE); } if(iD==-19) {// Custom qDebug("do custom"); if(fromMenu) { ColorPopupMenu* penColorPopupMenu = new ColorPopupMenu(Qt::black, this, "foreground color"); connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, SLOT(changeForegroundColor(const QColor&))); penColorPopupMenu->exec(); } cfg.writeEntry("Schema","19"); if(!fromMenu) { foreground.setNamedColor(cfg.readEntry("foreground","")); background.setNamedColor(cfg.readEntry("background","")); } fromMenu=FALSE; colorMenu->setItemChecked(-19,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; -// qDebug( temp.sprintf("configmenu %d",iD)); + QString temp; + qDebug( temp.sprintf("configmenu %d",iD)); TEWidget* te = getTe(); Config cfg("Konsole"); cfg.setGroup("Menubar"); if( iD == -4) { cfg.setGroup("Tabs"); QString tmp=cfg.readEntry("Position","Bottom"); 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 == -29) { + cfg.setGroup("ScrollBar"); + bool b=cfg.readBoolEntry("HorzScroll",0); + b=!b; + cfg.writeEntry("HorzScroll", b ); + cfg.write(); + doWrap(); + if(cfg.readNumEntry("Position",2) == 0) { + te->setScrollbarLocation(1); + } else { + te->setScrollbarLocation(0); + } + te->setScrollbarLocation( cfg.readNumEntry("Position",2)); + } } 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); } void Konsole::scrollMenuSelected(int index) { qDebug( "scrollbar menu %d",index); TEWidget* te = getTe(); Config cfg("Konsole"); cfg.setGroup("ScrollBar"); switch( index){ case -25: te->setScrollbarLocation(0); cfg.writeEntry("Position",0); break; case -26: te->setScrollbarLocation(1); cfg.writeEntry("Position",1); break; case -27: te->setScrollbarLocation(2); cfg.writeEntry("Position",2); break; - case -29: { - bool b=cfg.readBoolEntry("HorzScroll",0); - cfg.writeEntry("HorzScroll", !b ); - cfg.write(); - if(cfg.readNumEntry("Position",2) == 0) - te->setScrollbarLocation(1); - else - te->setScrollbarLocation(0); - te->setScrollbarLocation( cfg.readNumEntry("Position",2)); - te->setWrapAt(120); - } - break; +// case -29: { +// bool b=cfg.readBoolEntry("HorzScroll",0); +// cfg.writeEntry("HorzScroll", !b ); +// cfg.write(); +// if(cfg.readNumEntry("Position",2) == 0) { +// te->setScrollbarLocation(1); +// te->setWrapAt(0); +// } else { +// te->setScrollbarLocation(0); +// te->setWrapAt(120); +// } +// te->setScrollbarLocation( cfg.readNumEntry("Position",2)); +// } +// break; }; - } void Konsole::editCommandListMenuSelected(int iD) { // QString temp; // qDebug( temp.sprintf("edit command list %d",iD)); TEWidget* te = getTe(); Config cfg("Konsole"); cfg.setGroup("Menubar"); if( iD == -3) { if(!secondToolBar->isHidden()) { secondToolBar->hide(); configMenu->changeItem( iD,tr( "Show Command List" )); cfg.writeEntry("Hidden","TRUE"); configMenu->setItemEnabled(-23 ,FALSE); } else { secondToolBar->show(); configMenu->changeItem( iD,tr( "Hide Command List" )); cfg.writeEntry("Hidden","FALSE"); configMenu->setItemEnabled(-23 ,TRUE); if(cfg.readEntry("EditEnabled","FALSE")=="TRUE") { configMenu->setItemChecked(-23,TRUE); commonCombo->setEditable( TRUE ); } else { configMenu->setItemChecked(-23,FALSE); commonCombo->setEditable( FALSE ); } } } if( iD == -23) { 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(); } } if(iD == -24) { // "edit commands" CommandEditDialog *m = new CommandEditDialog(this); connect(m,SIGNAL(commandsEdited()),this,SLOT(initCommandList())); m->showMaximized(); } } // $QPEDIR/bin/qcop QPE/Application/embeddedkonsole 'setDocument(QString)' 'ssh -V' void Konsole::setDocument( const QString &cmd) { newSession(); TEWidget* te = getTe(); if(cmd.find("-e", 0, TRUE) != -1) { QString cmd2; cmd2=cmd.right(cmd.length()-3)+" &"; system(cmd2.latin1()); if(startUp <= 1 && nsessions < 2) { doneSession(getTe()->currentSession, 0); exit(0); } else doneSession(getTe()->currentSession, 0); } else { if (te != 0) { te->emitText(cmd+"\r"); } } startUp++; } void Konsole::parseCommandLine() { QString cmd; // newSession(); for (int i=1;i< qApp->argc();i++) { if( QString(qApp->argv()[i]) == "-e") { i++; for ( int j=i;j< qApp->argc();j++) { cmd+=QString(qApp->argv()[j])+" "; } cmd.stripWhiteSpace(); system(cmd.latin1()); exit(0);//close(); } // end -e switch } startUp++; } void Konsole::changeForegroundColor(const QColor &color) { Config cfg("Konsole"); cfg.setGroup("Colors"); int r, g, b; color.rgb(&r,&g,&b); foreground.setRgb(r,g,b); // QString colors; // colors.sprintf("%d,%d,%d"color.red,color.green,color.blue); cfg.writeEntry("foreground",color.name()); cfg.write(); qDebug("do other dialog"); ColorPopupMenu* penColorPopupMenu2 = new ColorPopupMenu(Qt::black, this,"background color"); connect(penColorPopupMenu2, SIGNAL(colorSelected(const QColor&)), this, SLOT(changeBackgroundColor(const QColor&))); penColorPopupMenu2->exec(); } void Konsole::changeBackgroundColor(const QColor &color) { qDebug("Change background"); Config cfg("Konsole"); cfg.setGroup("Colors"); int r, g, b; color.rgb(&r,&g,&b); background.setRgb(r,g,b); // QString colors; // colors.sprintf("%d,%d,%d"color.red,color.green,color.blue); cfg.writeEntry("background",color.name()); cfg.write(); } + +void Konsole::doWrap() { + Config cfg("Konsole"); + cfg.setGroup("ScrollBar"); + TEWidget* te = getTe(); + if( !cfg.readBoolEntry("HorzScroll",0)) { + te->setWrapAt(0); + configMenu->setItemChecked(-29,FALSE); + } else { + te->setWrapAt(90); +// te->setWrapAt(120); + configMenu->setItemChecked(-29,TRUE); + } +} diff --git a/core/apps/embeddedkonsole/konsole.h b/core/apps/embeddedkonsole/konsole.h index 0bf3fb3..4938159 100644 --- a/core/apps/embeddedkonsole/konsole.h +++ b/core/apps/embeddedkonsole/konsole.h @@ -1,143 +1,144 @@ /* ----------------------------------------------------------------------- */ /* */ /* [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 <qcolor.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; int startUp; private slots: void setDocument(const QString &); void doneSession(TESession*,int); void changeColumns(int); void fontChanged(int); void configMenuSelected(int ); void colorMenuSelected(int); void colorMenuIsSelected(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); void initCommandList(); void scrollMenuSelected(int); void editCommandListMenuSelected(int); void parseCommandLine(); void changeForegroundColor(const QColor &); void changeBackgroundColor(const QColor &); private: + void doWrap(); 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(); QStringList commands; QLabel * msgLabel; QColor foreground, background; bool fromMenu; private: class VTFont { public: VTFont(QString name, QFont& font) { this->name = name; this->font = font; } QFont& getFont() { return font; } QString getName() { return name; } private: QString name; QFont font; }; EKNumTabWidget* tab; int nsessions; QList<VTFont> fonts; int cfont; QCString se_pgm; QStrList se_args; QPopupMenu *fontList,*configMenu,*colorMenu,*scrollMenu,*editCommandListMenu; 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; }; #endif |