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 /core/apps/embeddedkonsole/TEScreen.cpp | |
parent | 7d8a563125b981718ae963ba6308e3506e870045 (diff) | |
download | opie-c3a6f53669140cf9e3c953772c610cd91d69ab78.zip opie-c3a6f53669140cf9e3c953772c610cd91d69ab78.tar.gz opie-c3a6f53669140cf9e3c953772c610cd91d69ab78.tar.bz2 |
no wrap mode taken from console, gui needs work
Diffstat (limited to 'core/apps/embeddedkonsole/TEScreen.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/apps/embeddedkonsole/TEScreen.cpp | 107 |
1 files changed, 94 insertions, 13 deletions
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 @@ -15,6 +15,7 @@ /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ /* */ /* -------------------------------------------------------------------------- */ +// enhancements added by L.J. Potter <ljp@llornkcor.com> /*! \file */ @@ -50,6 +51,7 @@ #include <string.h> #include <ctype.h> +#include <qpe/config.h> #include "TEScreen.h" #define HERE printf("%s(%d): here\n",__FILE__,__LINE__) @@ -67,11 +69,13 @@ 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(); reset(); @@ -383,13 +387,11 @@ void TEScreen::restoreCursor() 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); } } @@ -400,8 +402,7 @@ void TEScreen::resizeImage(int new_lines, int new_columns) // clear new image 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 = ' '; newimg[y*new_columns+x].f = DEFAULT_FORE_COLOR; newimg[y*new_columns+x].b = DEFAULT_BACK_COLOR; @@ -411,8 +412,7 @@ void TEScreen::resizeImage(int new_lines, int new_columns) 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++) - { + 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; @@ -505,7 +505,8 @@ 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); @@ -548,6 +549,65 @@ ca* TEScreen::getCookedImage() if (getMode(MODE_Cursor) && (cuY+(hist.getLines()-histCursor) < lines)) // cursor visible 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; + */ + } @@ -556,7 +616,12 @@ 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 setMode(MODE_Cursor); // cursor visible @@ -659,6 +724,7 @@ void TEScreen::ShowCharacter(unsigned short c) if (cuX >= columns) { if (getMode(MODE_Wrap)) NextLine(); else cuX = columns-1; + // comment out for no wrap } if (getMode(MODE_Insert)) insertChars(1); @@ -687,6 +753,7 @@ void TEScreen::scrollUp(int from, int n) { 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),' '); } @@ -698,14 +765,18 @@ 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 (from > bmargin) return; if (from + n > bmargin) n = bmargin - from; + 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) { @@ -1152,8 +1223,8 @@ void TEScreen::addHistLine() // add to hist buffer // we have to take care about scrolling, too... - if (hasScroll()) - { ca dft; + if (hasScroll()){ + ca dft; int end = columns-1; while (end >= 0 && image[end] == dft) @@ -1174,11 +1245,21 @@ void TEScreen::setHistCursor(int cursor) histCursor = cursor; //FIXME:rangecheck } +void TEScreen::setHorzCursor(int cursor) +{ + horzCursor = cursor; +} + int TEScreen::getHistCursor() { return histCursor; } +int TEScreen::getHorzCursor() +{ + return horzCursor; +} + int TEScreen::getHistLines() { return hist.getLines(); |