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 @@ | |||
15 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ | 15 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ |
16 | /* */ | 16 | /* */ |
17 | /* -------------------------------------------------------------------------- */ | 17 | /* -------------------------------------------------------------------------- */ |
18 | // enhancements added by L.J. Potter <ljp@llornkcor.com> | ||
18 | 19 | ||
19 | /*! \file | 20 | /*! \file |
20 | */ | 21 | */ |
@@ -50,6 +51,7 @@ | |||
50 | #include <string.h> | 51 | #include <string.h> |
51 | #include <ctype.h> | 52 | #include <ctype.h> |
52 | 53 | ||
54 | #include <qpe/config.h> | ||
53 | #include "TEScreen.h" | 55 | #include "TEScreen.h" |
54 | 56 | ||
55 | #define HERE printf("%s(%d): here\n",__FILE__,__LINE__) | 57 | #define HERE printf("%s(%d): here\n",__FILE__,__LINE__) |
@@ -67,11 +69,13 @@ TEScreen::TEScreen(int lines, int columns) | |||
67 | { | 69 | { |
68 | this->lines = lines; | 70 | this->lines = lines; |
69 | this->columns = columns; | 71 | this->columns = columns; |
72 | // qDebug("Columns %d", columns); | ||
70 | 73 | ||
71 | image = (ca*) malloc(lines*columns*sizeof(ca)); | 74 | image = (ca*) malloc(lines*columns*sizeof(ca)); |
72 | tabstops = NULL; initTabStops(); | 75 | tabstops = NULL; initTabStops(); |
73 | 76 | ||
74 | histCursor = 0; | 77 | histCursor = 0; |
78 | horzCursor = 0; | ||
75 | 79 | ||
76 | clearSelection(); | 80 | clearSelection(); |
77 | reset(); | 81 | reset(); |
@@ -383,13 +387,11 @@ void TEScreen::restoreCursor() | |||
383 | 387 | ||
384 | void TEScreen::resizeImage(int new_lines, int new_columns) | 388 | void TEScreen::resizeImage(int new_lines, int new_columns) |
385 | { | 389 | { |
386 | 390 | if (cuY > new_lines-1) { | |
387 | if (cuY > new_lines-1) | 391 | // attempt to preserve focus and lines |
388 | { // attempt to preserve focus and lines | ||
389 | bmargin = lines-1; //FIXME: margin lost | 392 | bmargin = lines-1; //FIXME: margin lost |
390 | for (int i = 0; i < cuY-(new_lines-1); i++) | 393 | for (int i = 0; i < cuY-(new_lines-1); i++) { |
391 | { | 394 | addHistLine(); scrollUp(horzCursor,1); |
392 | addHistLine(); scrollUp(0,1); | ||
393 | } | 395 | } |
394 | } | 396 | } |
395 | 397 | ||
@@ -400,8 +402,7 @@ void TEScreen::resizeImage(int new_lines, int new_columns) | |||
400 | 402 | ||
401 | // clear new image | 403 | // clear new image |
402 | for (int y = 0; y < new_lines; y++) | 404 | for (int y = 0; y < new_lines; y++) |
403 | for (int x = 0; x < new_columns; x++) | 405 | for (int x = 0; x < new_columns; x++) { |
404 | { | ||
405 | newimg[y*new_columns+x].c = ' '; | 406 | newimg[y*new_columns+x].c = ' '; |
406 | newimg[y*new_columns+x].f = DEFAULT_FORE_COLOR; | 407 | newimg[y*new_columns+x].f = DEFAULT_FORE_COLOR; |
407 | newimg[y*new_columns+x].b = DEFAULT_BACK_COLOR; | 408 | newimg[y*new_columns+x].b = DEFAULT_BACK_COLOR; |
@@ -411,8 +412,7 @@ void TEScreen::resizeImage(int new_lines, int new_columns) | |||
411 | int cpy_columns = QMIN(new_columns,columns); | 412 | int cpy_columns = QMIN(new_columns,columns); |
412 | // copy to new image | 413 | // copy to new image |
413 | for (int y = 0; y < cpy_lines; y++) | 414 | for (int y = 0; y < cpy_lines; y++) |
414 | for (int x = 0; x < cpy_columns; x++) | 415 | for (int x = 0; x < cpy_columns; x++) { |
415 | { | ||
416 | newimg[y*new_columns+x].c = image[loc(x,y)].c; | 416 | newimg[y*new_columns+x].c = image[loc(x,y)].c; |
417 | newimg[y*new_columns+x].f = image[loc(x,y)].f; | 417 | newimg[y*new_columns+x].f = image[loc(x,y)].f; |
418 | newimg[y*new_columns+x].b = image[loc(x,y)].b; | 418 | newimg[y*new_columns+x].b = image[loc(x,y)].b; |
@@ -505,7 +505,8 @@ void TEScreen::effectiveRendition() | |||
505 | */ | 505 | */ |
506 | 506 | ||
507 | ca* TEScreen::getCookedImage() | 507 | ca* TEScreen::getCookedImage() |
508 | { int x,y; | 508 | { |
509 | int x,y; | ||
509 | ca* merged = (ca*)malloc(lines*columns*sizeof(ca)); | 510 | ca* merged = (ca*)malloc(lines*columns*sizeof(ca)); |
510 | ca dft(' ',DEFAULT_FORE_COLOR,DEFAULT_BACK_COLOR,DEFAULT_RENDITION); | 511 | ca dft(' ',DEFAULT_FORE_COLOR,DEFAULT_BACK_COLOR,DEFAULT_RENDITION); |
511 | 512 | ||
@@ -548,6 +549,65 @@ ca* TEScreen::getCookedImage() | |||
548 | if (getMode(MODE_Cursor) && (cuY+(hist.getLines()-histCursor) < lines)) // cursor visible | 549 | if (getMode(MODE_Cursor) && (cuY+(hist.getLines()-histCursor) < lines)) // cursor visible |
549 | reverseRendition(&merged[loc(cuX,cuY+(hist.getLines()-histCursor))]); | 550 | reverseRendition(&merged[loc(cuX,cuY+(hist.getLines()-histCursor))]); |
550 | return merged; | 551 | return merged; |
552 | |||
553 | /* | ||
554 | int x, y, z; | ||
555 | |||
556 | ca* merged = (ca*)malloc( lines * columns * sizeof( ca)); | ||
557 | |||
558 | ca dft(' ',DEFAULT_FORE_COLOR,DEFAULT_BACK_COLOR,DEFAULT_RENDITION); | ||
559 | |||
560 | // qDebug("hist lines %d, historyCursor %d, minus %d ,lines %d, columns %d", | ||
561 | // hist.getLines(), histCursor, hist.getLines() - histCursor , lines, columns); | ||
562 | for (y = 0; (y < lines) && (y < ( hist.getLines() - histCursor )); y++) { | ||
563 | |||
564 | int len = QMIN( columns, hist.getLineLen( y + histCursor) ); | ||
565 | int yp = y * columns; | ||
566 | int yq = ( y + histCursor) * columns; | ||
567 | // qDebug("horzCursor %d, columns %d, len %d", horzCursor, columns, len); | ||
568 | // qDebug("lineno %d, colno %d, count %d\n", y + histCursor, (horzCursor / 2), len ); | ||
569 | qDebug("Y %d", y); | ||
570 | hist.getCells( y + histCursor, (horzCursor / 2), len, merged + yp); | ||
571 | |||
572 | for (x = len; x < columns; x++) | ||
573 | merged[yp + x] = dft; | ||
574 | for (x = 0; x < columns; x++) { | ||
575 | int p = x + yp; int q = x + yq; | ||
576 | if ( ( q >= sel_TL ) && ( q <= sel_BR ) ) | ||
577 | reverseRendition(&merged[p]); // for selection | ||
578 | } | ||
579 | } | ||
580 | |||
581 | if (lines >= hist.getLines() - histCursor) { | ||
582 | for (y = ( hist.getLines() - histCursor); y < lines ; y++) { | ||
583 | int z = horzCursor; | ||
584 | int yp = y * columns; | ||
585 | int yq = ( y + histCursor) * columns; | ||
586 | int yr = ( y - hist.getLines() + histCursor) * columns; | ||
587 | // qDebug("y %d, yp %d, yq %d, columns %d, z cursor %d", y, yp, yq, columns, z); | ||
588 | for (x = 0; x < columns; x++) { | ||
589 | int p = x + yp; int q = x + yq; int r = (x + (horzCursor/2) ) + yr; | ||
590 | merged[p] = image[r]; | ||
591 | if ( q >= sel_TL && q <= sel_BR ) | ||
592 | reverseRendition( &merged[p]); // for selection | ||
593 | } | ||
594 | } | ||
595 | } | ||
596 | |||
597 | |||
598 | // evtl. inverse display | ||
599 | if (getMode(MODE_Screen)) | ||
600 | { int i, n = lines * columns; | ||
601 | for (i = 0; i < n; i++) | ||
602 | reverseRendition( &merged[i]); // for reverse display | ||
603 | } | ||
604 | if (getMode(MODE_Cursor) && ( cuY + ( hist.getLines() - histCursor) < lines)) // cursor visible | ||
605 | |||
606 | reverseRendition( &merged[ loc( cuX, cuY + ( hist.getLines() - histCursor))] ); | ||
607 | |||
608 | return merged; | ||
609 | */ | ||
610 | |||
551 | } | 611 | } |
552 | 612 | ||
553 | 613 | ||
@@ -556,7 +616,12 @@ ca* TEScreen::getCookedImage() | |||
556 | 616 | ||
557 | void TEScreen::reset() | 617 | void TEScreen::reset() |
558 | { | 618 | { |
619 | Config cfg("Konsole"); | ||
620 | cfg.setGroup("ScrollBar"); | ||
621 | if( !cfg.readBoolEntry("HorzScroll",0) ) | ||
559 | setMode(MODE_Wrap ); saveMode(MODE_Wrap ); // wrap at end of margin | 622 | setMode(MODE_Wrap ); saveMode(MODE_Wrap ); // wrap at end of margin |
623 | |||
624 | |||
560 | resetMode(MODE_Origin); saveMode(MODE_Origin); // position refere to [1,1] | 625 | resetMode(MODE_Origin); saveMode(MODE_Origin); // position refere to [1,1] |
561 | resetMode(MODE_Insert); saveMode(MODE_Insert); // overstroke | 626 | resetMode(MODE_Insert); saveMode(MODE_Insert); // overstroke |
562 | setMode(MODE_Cursor); // cursor visible | 627 | setMode(MODE_Cursor); // cursor visible |
@@ -659,6 +724,7 @@ void TEScreen::ShowCharacter(unsigned short c) | |||
659 | if (cuX >= columns) | 724 | if (cuX >= columns) |
660 | { | 725 | { |
661 | if (getMode(MODE_Wrap)) NextLine(); else cuX = columns-1; | 726 | if (getMode(MODE_Wrap)) NextLine(); else cuX = columns-1; |
727 | // comment out for no wrap | ||
662 | } | 728 | } |
663 | 729 | ||
664 | if (getMode(MODE_Insert)) insertChars(1); | 730 | if (getMode(MODE_Insert)) insertChars(1); |
@@ -687,6 +753,7 @@ void TEScreen::scrollUp(int from, int n) | |||
687 | { | 753 | { |
688 | if (n <= 0 || from + n > bmargin) return; | 754 | if (n <= 0 || from + n > bmargin) return; |
689 | //FIXME: make sure `tmargin', `bmargin', `from', `n' is in bounds. | 755 | //FIXME: make sure `tmargin', `bmargin', `from', `n' is in bounds. |
756 | |||
690 | moveImage(loc(0,from),loc(0,from+n),loc(columns-1,bmargin)); | 757 | moveImage(loc(0,from),loc(0,from+n),loc(columns-1,bmargin)); |
691 | clearImage(loc(0,bmargin-n+1),loc(columns-1,bmargin),' '); | 758 | clearImage(loc(0,bmargin-n+1),loc(columns-1,bmargin),' '); |
692 | } | 759 | } |
@@ -698,14 +765,18 @@ void TEScreen::scrollUp(int from, int n) | |||
698 | 765 | ||
699 | void TEScreen::scrollDown(int from, int n) | 766 | void TEScreen::scrollDown(int from, int n) |
700 | { | 767 | { |
768 | |||
701 | //FIXME: make sure `tmargin', `bmargin', `from', `n' is in bounds. | 769 | //FIXME: make sure `tmargin', `bmargin', `from', `n' is in bounds. |
702 | if (n <= 0) return; | 770 | if (n <= 0) return; |
703 | if (from > bmargin) return; | 771 | if (from > bmargin) return; |
704 | if (from + n > bmargin) n = bmargin - from; | 772 | if (from + n > bmargin) n = bmargin - from; |
773 | |||
705 | moveImage(loc(0,from+n),loc(0,from),loc(columns-1,bmargin-n)); | 774 | moveImage(loc(0,from+n),loc(0,from),loc(columns-1,bmargin-n)); |
706 | clearImage(loc(0,from),loc(columns-1,from+n-1),' '); | 775 | clearImage(loc(0,from),loc(columns-1,from+n-1),' '); |
707 | } | 776 | } |
708 | 777 | ||
778 | |||
779 | |||
709 | /*! position the cursor to a specific line and column. */ | 780 | /*! position the cursor to a specific line and column. */ |
710 | void TEScreen::setCursorYX(int y, int x) | 781 | void TEScreen::setCursorYX(int y, int x) |
711 | { | 782 | { |
@@ -1152,8 +1223,8 @@ void TEScreen::addHistLine() | |||
1152 | // add to hist buffer | 1223 | // add to hist buffer |
1153 | // we have to take care about scrolling, too... | 1224 | // we have to take care about scrolling, too... |
1154 | 1225 | ||
1155 | if (hasScroll()) | 1226 | if (hasScroll()){ |
1156 | { ca dft; | 1227 | ca dft; |
1157 | 1228 | ||
1158 | int end = columns-1; | 1229 | int end = columns-1; |
1159 | while (end >= 0 && image[end] == dft) | 1230 | while (end >= 0 && image[end] == dft) |
@@ -1174,11 +1245,21 @@ void TEScreen::setHistCursor(int cursor) | |||
1174 | histCursor = cursor; //FIXME:rangecheck | 1245 | histCursor = cursor; //FIXME:rangecheck |
1175 | } | 1246 | } |
1176 | 1247 | ||
1248 | void TEScreen::setHorzCursor(int cursor) | ||
1249 | { | ||
1250 | horzCursor = cursor; | ||
1251 | } | ||
1252 | |||
1177 | int TEScreen::getHistCursor() | 1253 | int TEScreen::getHistCursor() |
1178 | { | 1254 | { |
1179 | return histCursor; | 1255 | return histCursor; |
1180 | } | 1256 | } |
1181 | 1257 | ||
1258 | int TEScreen::getHorzCursor() | ||
1259 | { | ||
1260 | return horzCursor; | ||
1261 | } | ||
1262 | |||
1182 | int TEScreen::getHistLines() | 1263 | int TEScreen::getHistLines() |
1183 | { | 1264 | { |
1184 | return hist.getLines(); | 1265 | return hist.getLines(); |