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 @@ Screen::Screen(int lines, int columns) { this->lines = lines; this->columns = columns; - image = (Character*) malloc(lines*columns*sizeof(Character)); + image = QArray<Character>( lines*columns ); tabstops = NULL; initTabStops(); histCursor = 0; clearSelection(); reset(); @@ -79,13 +79,13 @@ Screen::Screen(int lines, int columns) /*! Destructor */ Screen::~Screen() { - free(image); + delete image; if (tabstops) free(tabstops); } /* ------------------------------------------------------------------------- */ /* */ /* Normalized Screen Operations */ @@ -391,13 +391,13 @@ void Screen::resizeImage(int new_lines, int new_columns) { addHistLine(); scrollUp(0,1); } } // make new image - Character* newimg = (Character*) malloc(new_lines*new_columns*sizeof(Character)); + QArray<Character> newimg = QArray<Character>( new_lines * new_columns ); clearSelection(); // clear new image for (int y = 0; y < new_lines; y++) for (int x = 0; x < new_columns; x++) @@ -415,13 +415,13 @@ void Screen::resizeImage(int new_lines, int new_columns) { 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); + delete image; image = newimg; lines = new_lines; columns = new_columns; cuX = QMIN(cuX,columns-1); cuY = QMIN(cuY,lines-1); @@ -463,13 +463,13 @@ void Screen::resizeImage(int new_lines, int new_columns) (which is a font attribute) and intensive (which is a color attribute), we translate this and RE_BOLD in falls eventually appart into RE_BOLD and RE_INTENSIVE. */ -void Screen::reverseRendition(Character* p) +void Screen::reverseRendition(Character *p) { UINT8 f = p->f; UINT8 b = p->b; p->f = b; p->b = f; //p->r &= ~RE_TRANSPARENT; } void Screen::effectiveRendition() // calculate rendition @@ -501,24 +501,24 @@ void Screen::effectiveRendition() NOTE that the image returned by this function must later be freed. */ -Character* Screen::getCookedImage() +QArray<Character> Screen::getCookedImage() { int x,y; - Character* merged = (Character*) malloc(lines*columns*sizeof(Character)); + Character* merged = (Character*) malloc( lines * columns * sizeof( Character ) ); Character dft(' ',DEFAULT_FORE_COLOR,DEFAULT_BACK_COLOR,DEFAULT_RENDITION); 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; - hist.getCells(y+histCursor,0,len,merged+yp); + hist.getCells( y+histCursor, 0, 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 } @@ -544,13 +544,15 @@ Character* Screen::getCookedImage() { 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; + QArray<Character> res( sizeof( merged ) / sizeof( Character ) ); + res.assign( merged, sizeof( merged ) / sizeof( Character ) ); + return res; } /*! */ @@ -1156,13 +1158,13 @@ void Screen::addHistLine() { Character dft; int end = columns-1; while (end >= 0 && image[end] == dft) end -= 1; - hist.addCells(image,end+1); + hist.addCells(image.data(), end+1); hist.addLine(); // adjust history cursor histCursor += (hist.getLines()-1 == histCursor); } |