summaryrefslogtreecommitdiff
path: root/core
Unidiff
Diffstat (limited to 'core') (more/less context) (show whitespace changes)
-rw-r--r--core/apps/embeddedkonsole/TEScreen.cpp32
1 files changed, 17 insertions, 15 deletions
diff --git a/core/apps/embeddedkonsole/TEScreen.cpp b/core/apps/embeddedkonsole/TEScreen.cpp
index 1db34d2..30ff49d 100644
--- a/core/apps/embeddedkonsole/TEScreen.cpp
+++ b/core/apps/embeddedkonsole/TEScreen.cpp
@@ -60,39 +60,39 @@
60//FIXME: see if we can get this from terminfo. 60//FIXME: see if we can get this from terminfo.
61#define BS_CLEARS FALSE 61#define BS_CLEARS FALSE
62 62
63#define loc(X,Y) ((Y) * columns + (X)) 63#define loc(X,Y) ((Y) * columns + (X))
64 64
65/*! creates a `TEScreen' of `lines' lines and `columns' columns. 65/*! creates a `TEScreen' of `lines' lines and `columns' columns.
66*/ 66*/
67 67
68TEScreen::TEScreen(int lines, int columns) 68TEScreen::TEScreen(int _lines, int _columns) :
69 lines(_lines),
70 columns(_columns),
71 tabstops(0),
72 histCursor(0),
73 horzCursor(0)
69{ 74{
70 this->lines = lines;
71 this->columns = columns;
72// odebug << "Columns " << columns << "" << oendl; 75// odebug << "Columns " << columns << "" << oendl;
73 76
74 image = (ca*) malloc(lines*columns*sizeof(ca)); 77 image = new ca[lines*columns];
75 tabstops = NULL; initTabStops(); 78 initTabStops();
76
77 histCursor = 0;
78 horzCursor = 0;
79 79
80 clearSelection(); 80 clearSelection();
81 reset(); 81 reset();
82} 82}
83 83
84/*! Destructor 84/*! Destructor
85*/ 85*/
86 86
87TEScreen::~TEScreen() 87TEScreen::~TEScreen()
88{ 88{
89 free(image); 89 delete [] image;
90 if (tabstops) free(tabstops); 90 delete [] tabstops;
91} 91}
92 92
93/* ------------------------------------------------------------------------- */ 93/* ------------------------------------------------------------------------- */
94/* */ 94/* */
95/* Normalized Screen Operations */ 95/* Normalized Screen Operations */
96/* */ 96/* */
97/* ------------------------------------------------------------------------- */ 97/* ------------------------------------------------------------------------- */
98 98
@@ -391,17 +391,17 @@ void TEScreen::resizeImage(int new_lines, int new_columns)
391// attempt to preserve focus and lines 391// attempt to preserve focus and lines
392 bmargin = lines-1; //FIXME: margin lost 392 bmargin = lines-1; //FIXME: margin lost
393 for (int i = 0; i < cuY-(new_lines-1); i++) { 393 for (int i = 0; i < cuY-(new_lines-1); i++) {
394 addHistLine(); scrollUp(horzCursor,1); 394 addHistLine(); scrollUp(horzCursor,1);
395 } 395 }
396 } 396 }
397 397
398 // make new image 398 // make new image
399 ca* newimg = (ca*)malloc( new_lines * new_columns * sizeof( ca)); 399 ca* newimg = new ca[new_lines * new_columns];
400 400
401 clearSelection(); 401 clearSelection();
402 402
403 // clear new image 403 // clear new image
404 for (int y = 0; y < new_lines; y++) 404 for (int y = 0; y < new_lines; y++)
405 for (int x = 0; x < new_columns; x++) { 405 for (int x = 0; x < new_columns; x++) {
406 newimg[y*new_columns+x].c = ' '; 406 newimg[y*new_columns+x].c = ' ';
407 newimg[y*new_columns+x].f = DEFAULT_FORE_COLOR; 407 newimg[y*new_columns+x].f = DEFAULT_FORE_COLOR;
@@ -413,17 +413,17 @@ void TEScreen::resizeImage(int new_lines, int new_columns)
413 // copy to new image 413 // copy to new image
414 for (int y = 0; y < cpy_lines; y++) 414 for (int y = 0; y < cpy_lines; y++)
415 for (int x = 0; x < cpy_columns; x++) { 415 for (int x = 0; x < cpy_columns; x++) {
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
428 // FIXME: try to keep values, evtl. 428 // FIXME: try to keep values, evtl.
429 tmargin=0; 429 tmargin=0;
@@ -502,17 +502,17 @@ void TEScreen::effectiveRendition()
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
507ca* TEScreen::getCookedImage() 507ca* TEScreen::getCookedImage()
508{ 508{
509 int x,y; 509 int x,y;
510 ca* merged = (ca*)malloc(lines*columns*sizeof(ca)); 510 ca* merged = new ca[lines*columns];
511 ca dft(' ',DEFAULT_FORE_COLOR,DEFAULT_BACK_COLOR,DEFAULT_RENDITION); 511 ca dft(' ',DEFAULT_FORE_COLOR,DEFAULT_BACK_COLOR,DEFAULT_RENDITION);
512 512
513 if (histCursor > hist.getLines()) { 513 if (histCursor > hist.getLines()) {
514 histCursor = hist.getLines(); 514 histCursor = hist.getLines();
515 } 515 }
516 516
517 for (y = 0; (y < lines) && (y < (hist.getLines()-histCursor)); y++) 517 for (y = 0; (y < lines) && (y < (hist.getLines()-histCursor)); y++)
518 { 518 {
@@ -618,18 +618,20 @@ void TEScreen::clearTabStops()
618void TEScreen::changeTabStop(bool set) 618void TEScreen::changeTabStop(bool set)
619{ 619{
620 if (cuX >= columns) return; 620 if (cuX >= columns) return;
621 tabstops[cuX] = set; 621 tabstops[cuX] = set;
622} 622}
623 623
624void TEScreen::initTabStops() 624void TEScreen::initTabStops()
625{ 625{
626 if (tabstops) free(tabstops); 626 if (tabstops)
627 tabstops = (bool*)malloc(columns*sizeof(bool)); 627 delete [] tabstops;
628
629 tabstops = new bool[columns];
628 // Arrg! The 1st tabstop has to be one longer than the other. 630 // Arrg! The 1st tabstop has to be one longer than the other.
629 // i.e. the kids start counting from 0 instead of 1. 631 // i.e. the kids start counting from 0 instead of 1.
630 // Other programs might behave correctly. Be aware. 632 // Other programs might behave correctly. Be aware.
631 for (int i = 0; i < columns; i++) tabstops[i] = (i%8 == 0 && i != 0); 633 for (int i = 0; i < columns; i++) tabstops[i] = (i%8 == 0 && i != 0);
632} 634}
633 635
634/*! 636/*!
635 This behaves either as IND (Screen::Index) or as NEL (Screen::NextLine) 637 This behaves either as IND (Screen::Index) or as NEL (Screen::NextLine)