author | ibotty <ibotty> | 2002-10-09 17:40:35 (UTC) |
---|---|---|
committer | ibotty <ibotty> | 2002-10-09 17:40:35 (UTC) |
commit | c80818d8388c07c1606a70306aea0c9a1e17ea3c (patch) (unidiff) | |
tree | c010af190b398b698299a42ce06217c950d6525d /noncore/apps/opie-console/screen.cpp | |
parent | e0b4cca74ec611583c38901a83c448592e8ebec6 (diff) | |
download | opie-c80818d8388c07c1606a70306aea0c9a1e17ea3c.zip opie-c80818d8388c07c1606a70306aea0c9a1e17ea3c.tar.gz opie-c80818d8388c07c1606a70306aea0c9a1e17ea3c.tar.bz2 |
updated emulationLayer to use WidgetLayer (not Widget, which is b0rked)
default.cpp is broken, because there is still no new widget (coming
soon...)
Diffstat (limited to 'noncore/apps/opie-console/screen.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-console/screen.cpp | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/noncore/apps/opie-console/screen.cpp b/noncore/apps/opie-console/screen.cpp index 8ebc47d..a796ba1 100644 --- a/noncore/apps/opie-console/screen.cpp +++ b/noncore/apps/opie-console/screen.cpp | |||
@@ -65,13 +65,13 @@ | |||
65 | 65 | ||
66 | Screen::Screen(int lines, int columns) | 66 | Screen::Screen(int lines, int columns) |
67 | { | 67 | { |
68 | this->lines = lines; | 68 | this->lines = lines; |
69 | this->columns = columns; | 69 | this->columns = columns; |
70 | 70 | ||
71 | image = (Character*) malloc(lines*columns*sizeof(Character)); | 71 | image = QArray<Character>( lines*columns ); |
72 | tabstops = NULL; initTabStops(); | 72 | tabstops = NULL; initTabStops(); |
73 | 73 | ||
74 | histCursor = 0; | 74 | histCursor = 0; |
75 | 75 | ||
76 | clearSelection(); | 76 | clearSelection(); |
77 | reset(); | 77 | reset(); |
@@ -79,13 +79,13 @@ Screen::Screen(int lines, int columns) | |||
79 | 79 | ||
80 | /*! Destructor | 80 | /*! Destructor |
81 | */ | 81 | */ |
82 | 82 | ||
83 | Screen::~Screen() | 83 | Screen::~Screen() |
84 | { | 84 | { |
85 | free(image); | 85 | delete image; |
86 | if (tabstops) free(tabstops); | 86 | if (tabstops) free(tabstops); |
87 | } | 87 | } |
88 | 88 | ||
89 | /* ------------------------------------------------------------------------- */ | 89 | /* ------------------------------------------------------------------------- */ |
90 | /* */ | 90 | /* */ |
91 | /* Normalized Screen Operations */ | 91 | /* Normalized Screen Operations */ |
@@ -391,13 +391,13 @@ void Screen::resizeImage(int new_lines, int new_columns) | |||
391 | { | 391 | { |
392 | addHistLine(); scrollUp(0,1); | 392 | addHistLine(); scrollUp(0,1); |
393 | } | 393 | } |
394 | } | 394 | } |
395 | 395 | ||
396 | // make new image | 396 | // make new image |
397 | Character* newimg = (Character*) malloc(new_lines*new_columns*sizeof(Character)); | 397 | QArray<Character> newimg = QArray<Character>( new_lines * new_columns ); |
398 | 398 | ||
399 | clearSelection(); | 399 | clearSelection(); |
400 | 400 | ||
401 | // clear new image | 401 | // clear new image |
402 | for (int y = 0; y < new_lines; y++) | 402 | for (int y = 0; y < new_lines; y++) |
403 | for (int x = 0; x < new_columns; x++) | 403 | for (int x = 0; x < new_columns; x++) |
@@ -415,13 +415,13 @@ void Screen::resizeImage(int new_lines, int new_columns) | |||
415 | { | 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; |
419 | newimg[y*new_columns+x].r = image[loc(x,y)].r; | 419 | newimg[y*new_columns+x].r = image[loc(x,y)].r; |
420 | } | 420 | } |
421 | free(image); | 421 | delete image; |
422 | image = newimg; | 422 | image = newimg; |
423 | lines = new_lines; | 423 | lines = new_lines; |
424 | columns = new_columns; | 424 | columns = new_columns; |
425 | cuX = QMIN(cuX,columns-1); | 425 | cuX = QMIN(cuX,columns-1); |
426 | cuY = QMIN(cuY,lines-1); | 426 | cuY = QMIN(cuY,lines-1); |
427 | 427 | ||
@@ -463,13 +463,13 @@ void Screen::resizeImage(int new_lines, int new_columns) | |||
463 | (which is a font attribute) and intensive | 463 | (which is a font attribute) and intensive |
464 | (which is a color attribute), we translate | 464 | (which is a color attribute), we translate |
465 | this and RE_BOLD in falls eventually appart | 465 | this and RE_BOLD in falls eventually appart |
466 | into RE_BOLD and RE_INTENSIVE. | 466 | into RE_BOLD and RE_INTENSIVE. |
467 | */ | 467 | */ |
468 | 468 | ||
469 | void Screen::reverseRendition(Character* p) | 469 | void Screen::reverseRendition(Character *p) |
470 | { UINT8 f = p->f; UINT8 b = p->b; | 470 | { UINT8 f = p->f; UINT8 b = p->b; |
471 | p->f = b; p->b = f; //p->r &= ~RE_TRANSPARENT; | 471 | p->f = b; p->b = f; //p->r &= ~RE_TRANSPARENT; |
472 | } | 472 | } |
473 | 473 | ||
474 | void Screen::effectiveRendition() | 474 | void Screen::effectiveRendition() |
475 | // calculate rendition | 475 | // calculate rendition |
@@ -501,24 +501,24 @@ void Screen::effectiveRendition() | |||
501 | 501 | ||
502 | NOTE that the image returned by this function must later be | 502 | NOTE that the image returned by this function must later be |
503 | freed. | 503 | freed. |
504 | 504 | ||
505 | */ | 505 | */ |
506 | 506 | ||
507 | Character* Screen::getCookedImage() | 507 | QArray<Character> Screen::getCookedImage() |
508 | { int x,y; | 508 | { int x,y; |
509 | Character* merged = (Character*) malloc(lines*columns*sizeof(Character)); | 509 | Character* merged = (Character*) malloc( lines * columns * sizeof( Character ) ); |
510 | Character dft(' ',DEFAULT_FORE_COLOR,DEFAULT_BACK_COLOR,DEFAULT_RENDITION); | 510 | Character dft(' ',DEFAULT_FORE_COLOR,DEFAULT_BACK_COLOR,DEFAULT_RENDITION); |
511 | 511 | ||
512 | for (y = 0; (y < lines) && (y < (hist.getLines()-histCursor)); y++) | 512 | for (y = 0; (y < lines) && (y < (hist.getLines()-histCursor)); y++) |
513 | { | 513 | { |
514 | int len = QMIN(columns,hist.getLineLen(y+histCursor)); | 514 | int len = QMIN(columns,hist.getLineLen(y+histCursor)); |
515 | int yp = y*columns; | 515 | int yp = y*columns; |
516 | int yq = (y+histCursor)*columns; | 516 | int yq = (y+histCursor)*columns; |
517 | 517 | ||
518 | hist.getCells(y+histCursor,0,len,merged+yp); | 518 | hist.getCells( y+histCursor, 0, len, merged+yp ); |
519 | for (x = len; x < columns; x++) merged[yp+x] = dft; | 519 | for (x = len; x < columns; x++) merged[yp+x] = dft; |
520 | for (x = 0; x < columns; x++) | 520 | for (x = 0; x < columns; x++) |
521 | { int p=x + yp; int q=x + yq; | 521 | { int p=x + yp; int q=x + yq; |
522 | if ( ( q >= sel_TL ) && ( q <= sel_BR ) ) | 522 | if ( ( q >= sel_TL ) && ( q <= sel_BR ) ) |
523 | reverseRendition(&merged[p]); // for selection | 523 | reverseRendition(&merged[p]); // for selection |
524 | } | 524 | } |
@@ -544,13 +544,15 @@ Character* Screen::getCookedImage() | |||
544 | { int i,n = lines*columns; | 544 | { int i,n = lines*columns; |
545 | for (i = 0; i < n; i++) | 545 | for (i = 0; i < n; i++) |
546 | reverseRendition(&merged[i]); // for reverse display | 546 | reverseRendition(&merged[i]); // for reverse display |
547 | } | 547 | } |
548 | if (getMode(MODE_Cursor) && (cuY+(hist.getLines()-histCursor) < lines)) // cursor visible | 548 | if (getMode(MODE_Cursor) && (cuY+(hist.getLines()-histCursor) < lines)) // cursor visible |
549 | reverseRendition(&merged[loc(cuX,cuY+(hist.getLines()-histCursor))]); | 549 | reverseRendition(&merged[loc(cuX,cuY+(hist.getLines()-histCursor))]); |
550 | return merged; | 550 | QArray<Character> res( sizeof( merged ) / sizeof( Character ) ); |
551 | res.assign( merged, sizeof( merged ) / sizeof( Character ) ); | ||
552 | return res; | ||
551 | } | 553 | } |
552 | 554 | ||
553 | 555 | ||
554 | /*! | 556 | /*! |
555 | */ | 557 | */ |
556 | 558 | ||
@@ -1156,13 +1158,13 @@ void Screen::addHistLine() | |||
1156 | { Character dft; | 1158 | { Character dft; |
1157 | 1159 | ||
1158 | int end = columns-1; | 1160 | int end = columns-1; |
1159 | while (end >= 0 && image[end] == dft) | 1161 | while (end >= 0 && image[end] == dft) |
1160 | end -= 1; | 1162 | end -= 1; |
1161 | 1163 | ||
1162 | hist.addCells(image,end+1); | 1164 | hist.addCells(image.data(), end+1); |
1163 | hist.addLine(); | 1165 | hist.addLine(); |
1164 | 1166 | ||
1165 | // adjust history cursor | 1167 | // adjust history cursor |
1166 | histCursor += (hist.getLines()-1 == histCursor); | 1168 | histCursor += (hist.getLines()-1 == histCursor); |
1167 | } | 1169 | } |
1168 | 1170 | ||