-rw-r--r-- | core/apps/embeddedkonsole/TEHistory.cpp | 19 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/TEScreen.cpp | 107 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/TEWidget.cpp | 157 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/TEWidget.h | 15 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/TEmulation.cpp | 27 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/konsole.cpp | 34 |
6 files changed, 318 insertions, 41 deletions
diff --git a/core/apps/embeddedkonsole/TEHistory.cpp b/core/apps/embeddedkonsole/TEHistory.cpp index 317ce57..db9d10c 100644 --- a/core/apps/embeddedkonsole/TEHistory.cpp +++ b/core/apps/embeddedkonsole/TEHistory.cpp @@ -119,4 +119,6 @@ void HistoryBuffer::add(const unsigned char* bytes, int len) assert(hasScroll()); - rc = lseek(ion,length,SEEK_SET); if (rc < 0) { perror("HistoryBuffer::add.seek"); setScroll(FALSE); return; } - rc = write(ion,bytes,len); if (rc < 0) { perror("HistoryBuffer::add.write"); setScroll(FALSE); return; } + rc = lseek( ion, length, SEEK_SET); + if (rc < 0) { perror("HistoryBuffer::add.seek"); setScroll(FALSE); return; } + rc = write( ion, bytes, len); + if (rc < 0) { perror("HistoryBuffer::add.write"); setScroll(FALSE); return; } length += rc; @@ -124,9 +126,13 @@ void HistoryBuffer::add(const unsigned char* bytes, int len) -void HistoryBuffer::get(unsigned char* bytes, int len, int loc) -{ int rc; +void HistoryBuffer::get(unsigned char* bytes, int len, int loc) { + int rc; assert(hasScroll()); +// qDebug("history get len %d, loc %d, length %d", len, loc, length); if (loc < 0 || len < 0 || loc + len > length) fprintf(stderr,"getHist(...,%d,%d): invalid args.\n",len,loc); - rc = lseek(ion,loc,SEEK_SET); if (rc < 0) { perror("HistoryBuffer::get.seek"); setScroll(FALSE); return; } - rc = read(ion,bytes,len); if (rc < 0) { perror("HistoryBuffer::get.read"); setScroll(FALSE); return; } + + rc = lseek( ion, loc, SEEK_SET); + if (rc < 0) { perror("HistoryBuffer::get.seek"); setScroll(FALSE); return; } + rc = read( ion, bytes, len); + if (rc < 0) { perror("HistoryBuffer::get.read"); setScroll(FALSE); return; } } @@ -197,2 +203,3 @@ void HistoryScroll::getCells(int lineno, int colno, int count, ca res[]) assert(hasScroll()); +//get(unsigned char* bytes, int len, int loc) cells.get((unsigned char*)res,count*sizeof(ca),startOfLine(lineno)+colno*sizeof(ca)); diff --git a/core/apps/embeddedkonsole/TEScreen.cpp b/core/apps/embeddedkonsole/TEScreen.cpp index a3d115d..50807d3 100644 --- a/core/apps/embeddedkonsole/TEScreen.cpp +++ b/core/apps/embeddedkonsole/TEScreen.cpp @@ -17,2 +17,3 @@ /* -------------------------------------------------------------------------- */ +// enhancements added by L.J. Potter <ljp@llornkcor.com> @@ -52,2 +53,3 @@ +#include <qpe/config.h> #include "TEScreen.h" @@ -69,2 +71,3 @@ TEScreen::TEScreen(int lines, int columns) this->columns = columns; +// qDebug("Columns %d", columns); @@ -74,2 +77,3 @@ TEScreen::TEScreen(int lines, int columns) histCursor = 0; + horzCursor = 0; @@ -385,9 +389,7 @@ void TEScreen::resizeImage(int new_lines, int new_columns) { - - if (cuY > new_lines-1) - { // attempt to preserve focus and lines + if (cuY > new_lines-1) { +// attempt to preserve focus and lines bmargin = lines-1; //FIXME: margin lost - for (int i = 0; i < cuY-(new_lines-1); i++) - { - addHistLine(); scrollUp(0,1); + for (int i = 0; i < cuY-(new_lines-1); i++) { + addHistLine(); scrollUp(horzCursor,1); } @@ -402,4 +404,3 @@ void TEScreen::resizeImage(int new_lines, int new_columns) for (int y = 0; y < new_lines; y++) - for (int x = 0; x < new_columns; x++) - { + for (int x = 0; x < new_columns; x++) { newimg[y*new_columns+x].c = ' '; @@ -413,4 +414,3 @@ void TEScreen::resizeImage(int new_lines, int new_columns) for (int y = 0; y < cpy_lines; y++) - for (int x = 0; x < cpy_columns; x++) - { + for (int x = 0; x < cpy_columns; x++) { newimg[y*new_columns+x].c = image[loc(x,y)].c; @@ -507,3 +507,4 @@ void TEScreen::effectiveRendition() ca* TEScreen::getCookedImage() -{ int x,y; +{ + int x,y; ca* merged = (ca*)malloc(lines*columns*sizeof(ca)); @@ -550,2 +551,61 @@ ca* TEScreen::getCookedImage() return merged; + + /* + int x, y, z; + + ca* merged = (ca*)malloc( lines * columns * sizeof( ca)); + + ca dft(' ',DEFAULT_FORE_COLOR,DEFAULT_BACK_COLOR,DEFAULT_RENDITION); + +// qDebug("hist lines %d, historyCursor %d, minus %d ,lines %d, columns %d", +// hist.getLines(), histCursor, hist.getLines() - histCursor , lines, columns); + for (y = 0; (y < lines) && (y < ( hist.getLines() - histCursor )); y++) { + + int len = QMIN( columns, hist.getLineLen( y + histCursor) ); + int yp = y * columns; + int yq = ( y + histCursor) * columns; +// qDebug("horzCursor %d, columns %d, len %d", horzCursor, columns, len); +// qDebug("lineno %d, colno %d, count %d\n", y + histCursor, (horzCursor / 2), len ); + qDebug("Y %d", y); + hist.getCells( y + histCursor, (horzCursor / 2), len, merged + yp); + + for (x = len; x < columns; x++) + merged[yp + x] = dft; + for (x = 0; x < columns; x++) { + int p = x + yp; int q = x + yq; + if ( ( q >= sel_TL ) && ( q <= sel_BR ) ) + reverseRendition(&merged[p]); // for selection + } + } + + if (lines >= hist.getLines() - histCursor) { + for (y = ( hist.getLines() - histCursor); y < lines ; y++) { + int z = horzCursor; + int yp = y * columns; + int yq = ( y + histCursor) * columns; + int yr = ( y - hist.getLines() + histCursor) * columns; +// qDebug("y %d, yp %d, yq %d, columns %d, z cursor %d", y, yp, yq, columns, z); + for (x = 0; x < columns; x++) { + int p = x + yp; int q = x + yq; int r = (x + (horzCursor/2) ) + yr; + merged[p] = image[r]; + if ( q >= sel_TL && q <= sel_BR ) + reverseRendition( &merged[p]); // for selection + } + } + } + + +// evtl. inverse display + if (getMode(MODE_Screen)) + { int i, n = lines * columns; + for (i = 0; i < n; i++) + reverseRendition( &merged[i]); // for reverse display + } + if (getMode(MODE_Cursor) && ( cuY + ( hist.getLines() - histCursor) < lines)) // cursor visible + + reverseRendition( &merged[ loc( cuX, cuY + ( hist.getLines() - histCursor))] ); + + return merged; + */ + } @@ -558,3 +618,8 @@ void TEScreen::reset() { + Config cfg("Konsole"); + cfg.setGroup("ScrollBar"); + if( !cfg.readBoolEntry("HorzScroll",0) ) setMode(MODE_Wrap ); saveMode(MODE_Wrap ); // wrap at end of margin + + resetMode(MODE_Origin); saveMode(MODE_Origin); // position refere to [1,1] @@ -661,2 +726,3 @@ void TEScreen::ShowCharacter(unsigned short c) if (getMode(MODE_Wrap)) NextLine(); else cuX = columns-1; + // comment out for no wrap } @@ -689,2 +755,3 @@ void TEScreen::scrollUp(int from, int n) //FIXME: make sure `tmargin', `bmargin', `from', `n' is in bounds. + moveImage(loc(0,from),loc(0,from+n),loc(columns-1,bmargin)); @@ -700,2 +767,3 @@ void TEScreen::scrollDown(int from, int n) { + //FIXME: make sure `tmargin', `bmargin', `from', `n' is in bounds. @@ -704,2 +772,3 @@ void TEScreen::scrollDown(int from, int n) if (from + n > bmargin) n = bmargin - from; + moveImage(loc(0,from+n),loc(0,from),loc(columns-1,bmargin-n)); @@ -708,2 +777,4 @@ void TEScreen::scrollDown(int from, int n) + + /*! position the cursor to a specific line and column. */ @@ -1154,4 +1225,4 @@ void TEScreen::addHistLine() - if (hasScroll()) - { ca dft; + if (hasScroll()){ + ca dft; @@ -1176,2 +1247,7 @@ void TEScreen::setHistCursor(int cursor) +void TEScreen::setHorzCursor(int cursor) +{ + horzCursor = cursor; +} + int TEScreen::getHistCursor() @@ -1181,2 +1257,7 @@ int TEScreen::getHistCursor() +int TEScreen::getHorzCursor() +{ + return horzCursor; +} + int TEScreen::getHistLines() diff --git a/core/apps/embeddedkonsole/TEWidget.cpp b/core/apps/embeddedkonsole/TEWidget.cpp index b1ad008..c10c7a8 100644 --- a/core/apps/embeddedkonsole/TEWidget.cpp +++ b/core/apps/embeddedkonsole/TEWidget.cpp @@ -54,2 +54,9 @@ +#include <qpe/resource.h> +#include <qpe/sound.h> + +#ifdef QWS +#include <qpe/qcopenvelope_qws.h> +#endif + #include <qcursor.h> @@ -289,2 +296,9 @@ TEWidget::TEWidget(QWidget *parent, const char *name) : QFrame(parent,name) + 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"); @@ -303,2 +317,4 @@ TEWidget::TEWidget(QWidget *parent, const char *name) : QFrame(parent,name) + useHorzScroll=cfg.readBoolEntry("HorzScroll",0); + blinkT = new QTimer(this); @@ -317,2 +333,3 @@ TEWidget::TEWidget(QWidget *parent, const char *name) : QFrame(parent,name) word_selection_mode = FALSE; + hposition = 0; @@ -412,6 +429,3 @@ HCNT("setImage"); QChar *disstrU = new QChar[cols]; - -//{ static int cnt = 0; printf("setImage %d\n",cnt++); } - for (y = 0; y < lins; y++) - { + for (y = 0; y < lins; y++) { const ca* lcl = &image[y*this->columns]; @@ -590,4 +604,3 @@ void TEWidget::propagateSize() -void TEWidget::scrollChanged(int) -{ +void TEWidget::scrollChanged(int) { emit changedHistoryCursor(scrollbar->value()); //expose @@ -595,2 +608,10 @@ void TEWidget::scrollChanged(int) +void TEWidget::hScrollChanged(int loc) { + hposition = loc; + propagateSize(); + update(); + +// emit changedHorzCursor( hScrollbar->value()); //expose +} + void TEWidget::setScroll(int cursor, int slines) @@ -699,2 +720,3 @@ void TEWidget::mouseMoveEvent(QMouseEvent* ev) int scroll = scrollbar->value(); +// int hScroll = hScrollbar->value(); @@ -975,2 +997,6 @@ void TEWidget::doScroll(int lines) +void TEWidget::doHScroll(int lines) { + hScrollbar->setValue( hScrollbar->value()+lines); +} + bool TEWidget::eventFilter( QObject *obj, QEvent *e ) @@ -1080,3 +1106,13 @@ void TEWidget::Bell() { - QApplication::beep(); +//#ifdef QT_QWS_CUSTOM +//# ifndef QT_NO_COP + QCopEnvelope( "QPE/TaskBar", "soundAlarm()" ); +//# endif +//#else +//# ifndef QT_NO_SOUND +// QSound::play(Resource::findSound("alarm")); +//# endif +//#endif + +// QApplication::beep(); } @@ -1107,3 +1143,72 @@ void TEWidget::calcGeometry() { - //FIXME: set rimX == rimY == 0 when running in full screen mode. + int showhscrollbar = 1; + int hwidth = 0; + int dcolumns; + Config cfg("Konsole"); + cfg.setGroup("ScrollBar"); + useHorzScroll=cfg.readBoolEntry("HorzScroll",0); + + if(vcolumns == 0) showhscrollbar = 0; + if(showhscrollbar == 1) hwidth = QApplication::style().scrollBarExtent().width(); + + scrollbar->resize(QApplication::style().scrollBarExtent().width(), + contentsRect().height() - hwidth); + + switch(scrollLoc) { + case SCRNONE : + columns = ( contentsRect().width() - 2 * rimX ) / font_w; + dcolumns = columns; + if(vcolumns) columns = vcolumns; + blX = (contentsRect().width() - (columns*font_w) ) / 2; + if(showhscrollbar) + blX = -hposition * font_w; + brX = blX; + scrollbar->hide(); + break; + case SCRLEFT : + columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; + dcolumns = columns; + if(vcolumns) columns = vcolumns; + brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; + if(showhscrollbar) + brX = -hposition * font_w; + blX = brX + scrollbar->width(); + scrollbar->move(contentsRect().topLeft()); + scrollbar->show(); + break; + case SCRRIGHT: + columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; + dcolumns = columns; + if(vcolumns) columns = vcolumns; + blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; + if(showhscrollbar) + blX = -hposition * font_w; + brX = blX; + scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0)); + scrollbar->show(); + break; + } + //FIXME: support 'rounding' styles + lines = ( contentsRect().height() - 2 * rimY ) / font_h; + bY = (contentsRect().height() - (lines *font_h)) / 2; + + if(showhscrollbar == 1) { + hScrollbar->resize(contentsRect().width() - hwidth, hwidth); + hScrollbar->setRange(0, vcolumns - dcolumns); + + QPoint p = contentsRect().bottomLeft(); + hScrollbar->move(QPoint(p.x(), p.y() - hwidth)); + hScrollbar->show(); + } + else hScrollbar->hide(); + + if(showhscrollbar == 1) { + lines = lines - (hwidth / font_h) - 1; + if(lines < 1) lines = 1; + } + + /*//FIXME: set rimX == rimY == 0 when running in full screen mode. + Config cfg("Konsole"); + cfg.setGroup("ScrollBar"); + useHorzScroll=cfg.readBoolEntry("HorzScroll",0); @@ -1111,2 +1216,3 @@ void TEWidget::calcGeometry() contentsRect().height()); + qDebug("font_w %d", font_w); switch(scrollLoc) @@ -1121,2 +1227,3 @@ void TEWidget::calcGeometry() columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; + if(useHorzScroll) columns = columns * (font_w/2); brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; @@ -1128,4 +1235,9 @@ void TEWidget::calcGeometry() columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; + if(useHorzScroll) columns = columns * (font_w/2); blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; + if(useHorzScroll) { + brX = blX =2; + } else { brX = blX; + } scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0)); @@ -1134,3 +1246,19 @@ void TEWidget::calcGeometry() } - //FIXME: support 'rounding' styles + + if( !scrollbar->isHidden()) + hScrollbar->resize( contentsRect().width()-SCRWIDTH, QApplication::style() + .scrollBarExtent().height()); + else + hScrollbar->resize( contentsRect().width(), QApplication::style() + .scrollBarExtent().height()); + + hScrollbar->move( 0, contentsRect().height() - SCRWIDTH); + + + if(useHorzScroll) { + hScrollbar->show(); + lines = ( (contentsRect().height() - SCRWIDTH) - 2 * rimY ) / font_h; + bY = ((contentsRect().height() - SCRWIDTH) - (lines *font_h)) / 2; + } else { + hScrollbar->hide(); lines = ( contentsRect().height() - 2 * rimY ) / font_h; @@ -1138,2 +1266,5 @@ void TEWidget::calcGeometry() } + */ + //FIXME: support 'rounding' styles +} @@ -1268 +1399,9 @@ void TEWidget::drop_menu_activated(int item) +void TEWidget::setWrapAt(int columns) +{ + vcolumns = columns; + propagateSize(); + update(); +} + + diff --git a/core/apps/embeddedkonsole/TEWidget.h b/core/apps/embeddedkonsole/TEWidget.h index 40e1aea..a480d45 100644 --- a/core/apps/embeddedkonsole/TEWidget.h +++ b/core/apps/embeddedkonsole/TEWidget.h @@ -62,3 +62,7 @@ public: + void doHScroll(int lines); + + void emitSelection(); + void setWrapAt(int columns); @@ -78,2 +82,3 @@ public: public: + bool useHorzScroll; @@ -89,2 +94,3 @@ signals: void changedHistoryCursor(int value); + void changedHorzCursor(int value); void configureRequest( TEWidget*, int state, int x, int y ); @@ -98,3 +104,2 @@ signals: protected: - virtual void styleChange( QStyle& ); @@ -149,2 +154,3 @@ protected slots: void scrollChanged(int value); + void hScrollChanged(int value); void blinkEvent(); @@ -182,4 +188,7 @@ private: QClipboard* cb; - QScrollBar* scrollbar; - int scrollLoc; + QScrollBar* scrollbar, *hScrollbar; + + int scrollLoc, hScrollLoc; + int hposition, vcolumns; + diff --git a/core/apps/embeddedkonsole/TEmulation.cpp b/core/apps/embeddedkonsole/TEmulation.cpp index 6f3ad32..c19f2a1 100644 --- a/core/apps/embeddedkonsole/TEmulation.cpp +++ b/core/apps/embeddedkonsole/TEmulation.cpp @@ -105,14 +105,24 @@ TEmulation::TEmulation(TEWidget* gui) QObject::connect(&bulk_timer, SIGNAL(timeout()), this, SLOT(showBulk()) ); + QObject::connect(gui,SIGNAL(changedImageSizeSignal(int,int)), this,SLOT(onImageSizeChange(int,int))); + QObject::connect(gui,SIGNAL(changedHistoryCursor(int)), this,SLOT(onHistoryCursorChange(int))); + + QObject::connect(gui,SIGNAL(changedHorzCursor(int)), + this,SLOT(onHorzCursorChange(int))); + QObject::connect(gui,SIGNAL(keyPressedSignal(QKeyEvent*)), this,SLOT(onKeyPress(QKeyEvent*))); + QObject::connect(gui,SIGNAL(beginSelectionSignal(const int,const int)), this,SLOT(onSelectionBegin(const int,const int)) ); + QObject::connect(gui,SIGNAL(extendSelectionSignal(const int,const int)), this,SLOT(onSelectionExtend(const int,const int)) ); + QObject::connect(gui,SIGNAL(endSelectionSignal(const BOOL)), this,SLOT(setSelection(const BOOL)) ); + QObject::connect(gui,SIGNAL(clearSelectionSignal()), @@ -301,4 +311,6 @@ void TEmulation::showBulk() free(image); + //FIXME: check that we do not trigger other draw event here. gui->setScroll(scr->getHistCursor(),scr->getHistLines()); + } @@ -341,4 +353,3 @@ void TEmulation::setConnect(bool c) -void TEmulation::onImageSizeChange(int lines, int columns) -{ +void TEmulation::onImageSizeChange(int lines, int columns) { if (!connected) return; @@ -350,4 +361,3 @@ void TEmulation::onImageSizeChange(int lines, int columns) -void TEmulation::onHistoryCursorChange(int cursor) -{ +void TEmulation::onHistoryCursorChange(int cursor) { if (!connected) return; @@ -357,4 +367,9 @@ void TEmulation::onHistoryCursorChange(int cursor) -void TEmulation::setColumns(int columns) -{ +void TEmulation::onHorzCursorChange(int cursor) { + if (!connected) return; + scr->setHorzCursor(cursor); + showBulk(); +} + +void TEmulation::setColumns(int columns) { //FIXME: this goes strange ways. diff --git a/core/apps/embeddedkonsole/konsole.cpp b/core/apps/embeddedkonsole/konsole.cpp index a8ddc99..3c87ad4 100644 --- a/core/apps/embeddedkonsole/konsole.cpp +++ b/core/apps/embeddedkonsole/konsole.cpp @@ -360,4 +360,16 @@ void Konsole::init(const char* _pgm, QStrList & _args) scrollMenu->insertItem(tr( "Right" )); - configMenu->insertItem(tr( "ScrollBar" ),scrollMenu); + scrollMenu->insertSeparator(4); + scrollMenu->insertItem(tr( "Horizontal" )); + configMenu->insertItem(tr( "ScrollBar" ),scrollMenu); +//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 ///////////////////////////////////////////////////// @@ -374,3 +386,3 @@ void Konsole::init(const char* _pgm, QStrList & _args) se_args = _args; - + se_args.prepend("--login"); parseCommandLine(); @@ -510,2 +522,4 @@ void Konsole::setColLin(int columns, int lines) { + qDebug("konsole::setColLin:: Columns %d", columns); + if ((columns==0) || (lines==0)) @@ -554,2 +568,3 @@ void Konsole::changeColumns(int columns) { + qDebug("change columns"); TEWidget* te = getTe(); @@ -802,4 +817,3 @@ void Konsole::scrollMenuSelected(int index) { -// QString temp; -// qDebug( temp.sprintf("scrollbar menu %d",index)); + qDebug( "scrollbar menu %d",index); TEWidget* te = getTe(); @@ -820,2 +834,14 @@ void Konsole::scrollMenuSelected(int index) 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; }; |