author | llornkcor <llornkcor> | 2002-10-31 14:49:24 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-10-31 14:49:24 (UTC) |
commit | c3a6f53669140cf9e3c953772c610cd91d69ab78 (patch) (side-by-side diff) | |
tree | ab8579e66582aedc01da2aea4272e754902e9287 | |
parent | 7d8a563125b981718ae963ba6308e3506e870045 (diff) | |
download | opie-c3a6f53669140cf9e3c953772c610cd91d69ab78.zip opie-c3a6f53669140cf9e3c953772c610cd91d69ab78.tar.gz opie-c3a6f53669140cf9e3c953772c610cd91d69ab78.tar.bz2 |
no wrap mode taken from console, gui needs work
-rw-r--r-- | core/apps/embeddedkonsole/TEHistory.cpp | 29 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/TEScreen.cpp | 415 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/TEWidget.cpp | 169 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/TEWidget.h | 15 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/TEmulation.cpp | 43 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/konsole.cpp | 34 |
6 files changed, 491 insertions, 214 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 @@ -10,9 +10,9 @@ /* */ /* -------------------------------------------------------------------------- */ -/* */ +/* */ /* Ported Konsole to Qt/Embedded */ -/* */ +/* */ /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ -/* */ +/* */ /* -------------------------------------------------------------------------- */ @@ -118,16 +118,22 @@ void HistoryBuffer::add(const unsigned char* bytes, int len) { int rc; 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; } -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; } + 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; } } @@ -196,5 +202,6 @@ void HistoryScroll::getCells(int lineno, int colno, int count, ca res[]) { assert(hasScroll()); - cells.get((unsigned char*)res,count*sizeof(ca),startOfLine(lineno)+colno*sizeof(ca)); +//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 @@ -10,10 +10,11 @@ /* */ /* -------------------------------------------------------------------------- */ -/* */ +/* */ /* Ported Konsole to Qt/Embedded */ -/* */ +/* */ /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ -/* */ +/* */ /* -------------------------------------------------------------------------- */ +// enhancements added by L.J. Potter <ljp@llornkcor.com> /*! \file @@ -51,4 +52,5 @@ #include <ctype.h> +#include <qpe/config.h> #include "TEScreen.h" @@ -59,5 +61,5 @@ #define BS_CLEARS FALSE -#define loc(X,Y) ((Y)*columns+(X)) +#define loc(X,Y) ((Y) * columns + (X)) /*! creates a `TEScreen' of `lines' lines and `columns' columns. @@ -68,9 +70,11 @@ TEScreen::TEScreen(int lines, int columns) this->lines = lines; this->columns = columns; - +// qDebug("Columns %d", columns); + image = (ca*) malloc(lines*columns*sizeof(ca)); tabstops = NULL; initTabStops(); histCursor = 0; + horzCursor = 0; clearSelection(); @@ -384,51 +388,47 @@ void TEScreen::restoreCursor() void TEScreen::resizeImage(int new_lines, int new_columns) { - - 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); + 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(horzCursor,1); + } } - } - // make new image - ca* newimg = (ca*)malloc(new_lines*new_columns*sizeof(ca)); + // make new image + ca* newimg = (ca*)malloc( new_lines * new_columns * sizeof( ca)); - clearSelection(); - - // clear new image - for (int y = 0; y < new_lines; y++) - for (int x = 0; x < new_columns; x++) - { - newimg[y*new_columns+x].c = ' '; - newimg[y*new_columns+x].f = DEFAULT_FORE_COLOR; - newimg[y*new_columns+x].b = DEFAULT_BACK_COLOR; - newimg[y*new_columns+x].r = DEFAULT_RENDITION; - } - int cpy_lines = QMIN(new_lines, lines); - int cpy_columns = QMIN(new_columns,columns); - // copy to new image - for (int y = 0; y < cpy_lines; y++) - for (int x = 0; x < cpy_columns; x++) - { - newimg[y*new_columns+x].c = image[loc(x,y)].c; - newimg[y*new_columns+x].f = image[loc(x,y)].f; - newimg[y*new_columns+x].b = image[loc(x,y)].b; - newimg[y*new_columns+x].r = image[loc(x,y)].r; - } - free(image); - image = newimg; - lines = new_lines; - columns = new_columns; - cuX = QMIN(cuX,columns-1); - cuY = QMIN(cuY,lines-1); + clearSelection(); - // FIXME: try to keep values, evtl. - tmargin=0; - bmargin=lines-1; - initTabStops(); - clearSelection(); + // clear new image + for (int y = 0; y < new_lines; y++) + for (int x = 0; x < new_columns; x++) { + newimg[y*new_columns+x].c = ' '; + newimg[y*new_columns+x].f = DEFAULT_FORE_COLOR; + newimg[y*new_columns+x].b = DEFAULT_BACK_COLOR; + newimg[y*new_columns+x].r = DEFAULT_RENDITION; + } + int cpy_lines = QMIN(new_lines, lines); + int cpy_columns = QMIN(new_columns,columns); + // copy to new image + for (int y = 0; y < cpy_lines; y++) + for (int x = 0; x < cpy_columns; x++) { + newimg[y*new_columns+x].c = image[loc(x,y)].c; + newimg[y*new_columns+x].f = image[loc(x,y)].f; + newimg[y*new_columns+x].b = image[loc(x,y)].b; + newimg[y*new_columns+x].r = image[loc(x,y)].r; + } + free(image); + image = newimg; + lines = new_lines; + columns = new_columns; + cuX = QMIN(cuX,columns-1); + cuY = QMIN(cuY,lines-1); + + // FIXME: try to keep values, evtl. + tmargin=0; + bmargin=lines-1; + initTabStops(); + clearSelection(); } @@ -506,5 +506,6 @@ void TEScreen::effectiveRendition() ca* TEScreen::getCookedImage() -{ int x,y; +{ + int x,y; ca* merged = (ca*)malloc(lines*columns*sizeof(ca)); ca dft(' ',DEFAULT_FORE_COLOR,DEFAULT_BACK_COLOR,DEFAULT_RENDITION); @@ -549,4 +550,63 @@ ca* TEScreen::getCookedImage() reverseRendition(&merged[loc(cuX,cuY+(hist.getLines()-histCursor))]); 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; + */ + } @@ -557,5 +617,10 @@ ca* TEScreen::getCookedImage() 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] resetMode(MODE_Insert); saveMode(MODE_Insert); // overstroke @@ -659,10 +724,11 @@ void TEScreen::ShowCharacter(unsigned short c) if (cuX >= columns) { - if (getMode(MODE_Wrap)) NextLine(); else cuX = columns-1; + if (getMode(MODE_Wrap)) NextLine(); else cuX = columns - 1; + // comment out for no wrap } if (getMode(MODE_Insert)) insertChars(1); - int i = loc(cuX,cuY); + int i = loc( cuX, cuY); checkSelection(i, i); // check if selection is still valid. @@ -686,8 +752,9 @@ void TEScreen::ShowCharacter(unsigned short c) void TEScreen::scrollUp(int from, int n) { - if (n <= 0 || from + n > bmargin) return; + if (n <= 0 || from + n > bmargin) return; //FIXME: make sure `tmargin', `bmargin', `from', `n' is in bounds. - moveImage(loc(0,from),loc(0,from+n),loc(columns-1,bmargin)); - clearImage(loc(0,bmargin-n+1),loc(columns-1,bmargin),' '); + + moveImage( loc( 0, from), loc( 0, from + n), loc( columns - 1, bmargin)); + clearImage( loc( 0, bmargin - n + 1), loc( columns - 1, bmargin), ' '); } @@ -699,12 +766,16 @@ void TEScreen::scrollUp(int from, int n) void TEScreen::scrollDown(int from, int n) { + //FIXME: make sure `tmargin', `bmargin', `from', `n' is in bounds. - if (n <= 0) return; + if (n <= 0) return; if (from > bmargin) return; if (from + n > bmargin) n = bmargin - from; - moveImage(loc(0,from+n),loc(0,from),loc(columns-1,bmargin-n)); + + moveImage( loc(0,from+n), loc(0,from), loc(columns-1,bmargin-n)); clearImage(loc(0,from),loc(columns-1,from+n-1),' '); } + + /*! position the cursor to a specific line and column. */ void TEScreen::setCursorYX(int y, int x) @@ -872,5 +943,5 @@ void TEScreen::clearToBeginOfLine() void TEScreen::clearEntireLine() { - clearImage(loc(0,cuY),loc(columns-1,cuY),' '); + clearImage( loc( 0, cuY),loc( columns - 1, cuY),' '); } @@ -989,15 +1060,15 @@ QString TEScreen::getSelText(const BOOL preserve_line_breaks) return QString::null; // Selection got clear while selecting. - int *m; // buffer to fill. - int s, d; // source index, dest. index. + int *m; // buffer to fill. + int s, d; // source index, dest. index. int hist_BR = loc(0, hist.getLines()); int hY = sel_TL / columns; int hX = sel_TL % columns; - int eol; // end of line + int eol; // end of line - s = sel_TL; // tracks copy in source. + s = sel_TL; // tracks copy in source. - // allocate buffer for maximum - // possible size... + // allocate buffer for maximum + // possible size... d = (sel_BR - sel_TL) / columns + 1; m = new int[d * (columns + 1) + 2]; @@ -1007,101 +1078,101 @@ QString TEScreen::getSelText(const BOOL preserve_line_breaks) { if (s < hist_BR) - { // get lines from hist.history - // buffer. - eol = hist.getLineLen(hY); - - if ((hY == (sel_BR / columns)) && - (eol >= (sel_BR % columns))) - { - eol = sel_BR % columns + 1; - } - - while (hX < eol) - { - m[d++] = hist.getCell(hY, hX++).c; - s++; - } - - if (s <= sel_BR) - { - // The line break handling - // It's different from the screen - // image case! - if (eol % columns == 0) - { - // That's either a completely filled - // line or an empty line - if (eol == 0) - { - m[d++] = '\n'; - } - else - { - // We have a full line. - // FIXME: How can we handle newlines - // at this position?! - } - } - else if ((eol + 1) % columns == 0) - { - // FIXME: We don't know if this was a - // space at the last position or a - // short line!! - m[d++] = ' '; - } - else - { - // We have a short line here. Put a - // newline or a space into the - // buffer. - m[d++] = preserve_line_breaks ? '\n' : ' '; - } - } - - hY++; - hX = 0; - s = hY * columns; - } + { // get lines from hist.history + // buffer. + eol = hist.getLineLen(hY); + + if ((hY == (sel_BR / columns)) && + (eol >= (sel_BR % columns))) + { + eol = sel_BR % columns + 1; + } + + while (hX < eol) + { + m[d++] = hist.getCell(hY, hX++).c; + s++; + } + + if (s <= sel_BR) + { + // The line break handling + // It's different from the screen + // image case! + if (eol % columns == 0) + { + // That's either a completely filled + // line or an empty line + if (eol == 0) + { + m[d++] = '\n'; + } + else + { + // We have a full line. + // FIXME: How can we handle newlines + // at this position?! + } + } + else if ((eol + 1) % columns == 0) + { + // FIXME: We don't know if this was a + // space at the last position or a + // short line!! + m[d++] = ' '; + } + else + { + // We have a short line here. Put a + // newline or a space into the + // buffer. + m[d++] = preserve_line_breaks ? '\n' : ' '; + } + } + + hY++; + hX = 0; + s = hY * columns; + } else - { // or from screen image. - eol = (s / columns + 1) * columns - 1; - - if (eol < sel_BR) - { - while ((eol > s) && - isspace(image[eol - hist_BR].c)) - { - eol--; - } - } - else - { - eol = sel_BR; - } - - while (s <= eol) - { - m[d++] = image[s++ - hist_BR].c; - } - - if (eol < sel_BR) - { - // eol processing see below ... - if ((eol + 1) % columns == 0) - { - if (image[eol - hist_BR].c == ' ') - { - m[d++] = ' '; - } - } - else - { - m[d++] = ((preserve_line_breaks || - ((eol % columns) == 0)) ? - '\n' : ' '); - } - } - - s = (eol / columns + 1) * columns; + { // or from screen image. + eol = (s / columns + 1) * columns - 1; + + if (eol < sel_BR) + { + while ((eol > s) && + isspace(image[eol - hist_BR].c)) + { + eol--; + } + } + else + { + eol = sel_BR; + } + + while (s <= eol) + { + m[d++] = image[s++ - hist_BR].c; + } + + if (eol < sel_BR) + { + // eol processing see below ... + if ((eol + 1) % columns == 0) + { + if (image[eol - hist_BR].c == ' ') + { + m[d++] = ' '; + } + } + else + { + m[d++] = ((preserve_line_breaks || + ((eol % columns) == 0)) ? + '\n' : ' '); + } + } + + s = (eol / columns + 1) * columns; } } @@ -1130,6 +1201,6 @@ cases: FIXME: - * this suppresses \n for command output that is - sized to the exact column width of the screen. + * this suppresses \n for command output that is + sized to the exact column width of the screen. 2) eol%columns == 0 --> blank line. @@ -1139,5 +1210,5 @@ FIXME: not preserving line_breaks, you want to preserve paragraph breaks. -3) else --> partially filled line +3) else --> partially filled line insert a \n in preserve line break mode, else a space The space prevents concatenation of the last word of one @@ -1153,16 +1224,16 @@ void TEScreen::addHistLine() // we have to take care about scrolling, too... - if (hasScroll()) - { ca dft; + if (hasScroll()){ + ca dft; - int end = columns-1; + int end = columns - 1; while (end >= 0 && image[end] == dft) end -= 1; - hist.addCells(image,end+1); + hist.addCells( image, end + 1); hist.addLine(); // adjust history cursor - histCursor += (hist.getLines()-1 == histCursor); + histCursor += ( hist.getLines() - 1 == histCursor); } @@ -1175,4 +1246,9 @@ void TEScreen::setHistCursor(int cursor) } +void TEScreen::setHorzCursor(int cursor) +{ + horzCursor = cursor; +} + int TEScreen::getHistCursor() { @@ -1180,4 +1256,9 @@ 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 @@ -53,4 +53,11 @@ #include <qpe/config.h> +#include <qpe/resource.h> +#include <qpe/sound.h> + +#ifdef QWS +#include <qpe/qcopenvelope_qws.h> +#endif + #include <qcursor.h> #include <qregexp.h> @@ -288,4 +295,11 @@ TEWidget::TEWidget(QWidget *parent, const char *name) : QFrame(parent,name) 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"); @@ -302,4 +316,6 @@ TEWidget::TEWidget(QWidget *parent, const char *name) : QFrame(parent,name) }; + useHorzScroll=cfg.readBoolEntry("HorzScroll",0); + blinkT = new QTimer(this); connect(blinkT, SIGNAL(timeout()), this, SLOT(blinkEvent())); @@ -316,4 +332,5 @@ TEWidget::TEWidget(QWidget *parent, const char *name) : QFrame(parent,name) font_a = 1; word_selection_mode = FALSE; + hposition = 0; setMouseMarks(TRUE); @@ -411,8 +428,5 @@ HCNT("setImage"); int cols = QMIN(this->columns,QMAX(0,columns)); 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]; const ca* const ext = &newimg[y*columns]; @@ -589,9 +603,16 @@ void TEWidget::propagateSize() /* ------------------------------------------------------------------------- */ -void TEWidget::scrollChanged(int) -{ +void TEWidget::scrollChanged(int) { emit changedHistoryCursor(scrollbar->value()); //expose } +void TEWidget::hScrollChanged(int loc) { + hposition = loc; + propagateSize(); + update(); + +// emit changedHorzCursor( hScrollbar->value()); //expose +} + void TEWidget::setScroll(int cursor, int slines) { @@ -698,4 +719,5 @@ void TEWidget::mouseMoveEvent(QMouseEvent* ev) int tLy = tL.y(); int scroll = scrollbar->value(); +// int hScroll = hScrollbar->value(); // we're in the process of moving the mouse with the left button pressed @@ -974,4 +996,8 @@ void TEWidget::doScroll(int lines) } +void TEWidget::doHScroll(int lines) { + hScrollbar->setValue( hScrollbar->value()+lines); +} + bool TEWidget::eventFilter( QObject *obj, QEvent *e ) { @@ -1079,5 +1105,15 @@ void TEWidget::frameChanged() 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(); } @@ -1106,8 +1142,78 @@ void TEWidget::clearImage() 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; - scrollbar->resize(QApplication::style().scrollBarExtent().width(), + 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); + + scrollbar->resize( QApplication::style().scrollBarExtent().width(), contentsRect().height()); + qDebug("font_w %d", font_w); switch(scrollLoc) { @@ -1120,4 +1226,5 @@ void TEWidget::calcGeometry() case SCRLEFT : 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; blX = brX + scrollbar->width(); @@ -1126,14 +1233,38 @@ void TEWidget::calcGeometry() break; case SCRRIGHT: - columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; - blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; - brX = blX; - scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0)); + 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) ); scrollbar->show(); break; } + + 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; + bY = (contentsRect().height() - (lines *font_h)) / 2; + } + */ //FIXME: support 'rounding' styles - lines = ( contentsRect().height() - 2 * rimY ) / font_h; - bY = (contentsRect().height() - (lines *font_h)) / 2; } @@ -1267,2 +1398,10 @@ 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 @@ -61,5 +61,9 @@ public: void doScroll(int lines); + void doHScroll(int lines); + + void emitSelection(); + void setWrapAt(int columns); public: @@ -77,4 +81,5 @@ public: public: + bool useHorzScroll; void Bell(); @@ -88,4 +93,5 @@ signals: void changedImageSizeSignal(int lines, int columns); void changedHistoryCursor(int value); + void changedHorzCursor(int value); void configureRequest( TEWidget*, int state, int x, int y ); @@ -97,5 +103,4 @@ signals: protected: - virtual void styleChange( QStyle& ); @@ -148,4 +153,5 @@ protected slots: void scrollChanged(int value); + void hScrollChanged(int value); void blinkEvent(); @@ -181,7 +187,10 @@ private: QClipboard* cb; - QScrollBar* scrollbar; - int scrollLoc; + QScrollBar* scrollbar, *hScrollbar; + + int scrollLoc, hScrollLoc; + int hposition, vcolumns; + //#define SCRNONE 0 //#define SCRLEFT 1 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 @@ -10,9 +10,9 @@ /* */ /* -------------------------------------------------------------------------- */ -/* */ +/* */ /* Ported Konsole to Qt/Embedded */ -/* */ +/* */ /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ -/* */ +/* */ /* -------------------------------------------------------------------------- */ @@ -104,18 +104,28 @@ 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)) ); + this,SLOT(onSelectionBegin(const int,const int)) ); + QObject::connect(gui,SIGNAL(extendSelectionSignal(const int,const int)), - this,SLOT(onSelectionExtend(const int,const int)) ); + this,SLOT(onSelectionExtend(const int,const int)) ); + QObject::connect(gui,SIGNAL(endSelectionSignal(const BOOL)), - this,SLOT(setSelection(const BOOL)) ); + this,SLOT(setSelection(const BOOL)) ); + QObject::connect(gui,SIGNAL(clearSelectionSignal()), - this,SLOT(clearSelection()) ); + this,SLOT(clearSelection()) ); } @@ -300,6 +310,8 @@ void TEmulation::showBulk() scr->getColumns()); // actual refresh free(image); - //FIXME: check that we do not trigger other draw event here. + + //FIXME: check that we do not trigger other draw event here. gui->setScroll(scr->getHistCursor(),scr->getHistLines()); + } } @@ -340,6 +352,5 @@ void TEmulation::setConnect(bool c) */ -void TEmulation::onImageSizeChange(int lines, int columns) -{ +void TEmulation::onImageSizeChange(int lines, int columns) { if (!connected) return; screen[0]->resizeImage(lines,columns); @@ -349,6 +360,5 @@ void TEmulation::onImageSizeChange(int lines, int columns) } -void TEmulation::onHistoryCursorChange(int cursor) -{ +void TEmulation::onHistoryCursorChange(int cursor) { if (!connected) return; scr->setHistCursor(cursor); @@ -356,6 +366,11 @@ 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. // Can we put this straight or explain it at least? 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 @@ -359,6 +359,18 @@ void Konsole::init(const char* _pgm, QStrList & _args) scrollMenu->insertItem(tr( "Left" )); scrollMenu->insertItem(tr( "Right" )); + 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 ///////////////////////////////////////////////////// setCentralWidget(tab); @@ -373,5 +385,5 @@ void Konsole::init(const char* _pgm, QStrList & _args) se_pgm = _pgm; se_args = _args; - + se_args.prepend("--login"); parseCommandLine(); // read and apply default values /////////////////////////////////////////// @@ -509,4 +521,6 @@ QSize Konsole::calcSize(int columns, int lines) { void Konsole::setColLin(int columns, int lines) { + qDebug("konsole::setColLin:: Columns %d", columns); + if ((columns==0) || (lines==0)) { @@ -553,4 +567,5 @@ void Konsole::setFont(int fontno) void Konsole::changeColumns(int columns) { + qDebug("change columns"); TEWidget* te = getTe(); if (te != 0) { @@ -801,6 +816,5 @@ void Konsole::setColor() void Konsole::scrollMenuSelected(int index) { -// QString temp; -// qDebug( temp.sprintf("scrollbar menu %d",index)); + qDebug( "scrollbar menu %d",index); TEWidget* te = getTe(); Config cfg("Konsole"); @@ -819,4 +833,16 @@ void Konsole::scrollMenuSelected(int index) 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; }; |