From 9ad52ae4cc98566d054072d6a7942784d8f354d3 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Mon, 23 Aug 2010 13:31:39 +0000 Subject: [PATCH] When inserting tabs or other whitespace, propagate the attributes of the previous characters. This allows mc to render properly. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38318 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/terminal/BasicTerminalBuffer.cpp | 11 +++++++++-- src/apps/terminal/TermView.cpp | 14 +++++--------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/apps/terminal/BasicTerminalBuffer.cpp b/src/apps/terminal/BasicTerminalBuffer.cpp index b3783e8224..d4088baf02 100644 --- a/src/apps/terminal/BasicTerminalBuffer.cpp +++ b/src/apps/terminal/BasicTerminalBuffer.cpp @@ -663,11 +663,18 @@ BasicTerminalBuffer::InsertTab() fSoftWrappedCursor = false; for (x = fCursor.x + 1; x < fWidth && !fTabStops[x]; x++) - ; // no body + ; x = restrict_value(x, 0, fWidth - 1); if (x != fCursor.x) { + TerminalLine* line = _LineAt(fCursor.y); + for (int32 i = fCursor.x; i <= x; i++) { + line->cells[i].character = ' '; + line->cells[i].attributes = line->cells[fCursor.x - 1].attributes; + } fCursor.x = x; + if (line->length < fCursor.x) + line->length = fCursor.x; _CursorChanged(); } } @@ -705,7 +712,7 @@ BasicTerminalBuffer::InsertSpace(int32 num) TerminalLine* line = _LineAt(fCursor.y); for (int32 i = fCursor.x; i < fCursor.x + num; i++) { line->cells[i].character = kSpaceChar; - line->cells[i].attributes = 0; + line->cells[i].attributes = line->cells[fCursor.x - 1].attributes; } _Invalidate(fCursor.y, fCursor.y); diff --git a/src/apps/terminal/TermView.cpp b/src/apps/terminal/TermView.cpp index e9e9ec4f8b..1c8d95c7e3 100644 --- a/src/apps/terminal/TermView.cpp +++ b/src/apps/terminal/TermView.cpp @@ -1112,12 +1112,8 @@ TermView::_DrawLinePart(int32 x1, int32 y1, uint32 attr, char *buf, // color attribute int forecolor = IS_FORECOLOR(attr); int backcolor = IS_BACKCOLOR(attr); - - // if (IS_FORESET(attr)) - rgb_fore = kTermColorTable[forecolor]; - - // if (IS_BACKSET(attr)) - rgb_back = kTermColorTable[backcolor]; + rgb_fore = kTermColorTable[forecolor]; + rgb_back = kTermColorTable[backcolor]; // Selection check. if (cursor) { @@ -1373,9 +1369,9 @@ TermView::Draw(BRect updateRect) rect.bottom = rect.top + fFontHeight - 1; int t = 1; - while(count == 0 && i - t > 0) { - count = fVisibleTextBuffer->GetString(j - firstVisible, i - t, - lastColumn, buf, attr); + while (count == 0 && i - t > 0) { + count = fVisibleTextBuffer->GetString(j - firstVisible, + i - t, lastColumn, buf, attr); t++; }