From 384fe0223480bf613f2978f386ce5d4f15dc3b4c Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Mon, 22 Nov 2010 19:21:56 +0000 Subject: [PATCH] * Use the attributes from the parser instead of trying to guess blindly when inserting a tab. This avoids strange things hapenning when a tab is inserted at the start of a line. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39574 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/terminal/BasicTerminalBuffer.cpp | 6 ++++-- src/apps/terminal/BasicTerminalBuffer.h | 2 +- src/apps/terminal/TermParse.cpp | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/apps/terminal/BasicTerminalBuffer.cpp b/src/apps/terminal/BasicTerminalBuffer.cpp index d4088baf02..e471799c44 100644 --- a/src/apps/terminal/BasicTerminalBuffer.cpp +++ b/src/apps/terminal/BasicTerminalBuffer.cpp @@ -656,21 +656,23 @@ BasicTerminalBuffer::InsertRI() void -BasicTerminalBuffer::InsertTab() +BasicTerminalBuffer::InsertTab(uint32 attributes) { int32 x; fSoftWrappedCursor = false; + // Find the next tab stop for (x = fCursor.x + 1; x < fWidth && !fTabStops[x]; x++) ; + // Ensure x stayx within the line bounds 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; + line->cells[i].attributes = attributes; } fCursor.x = x; if (line->length < fCursor.x) diff --git a/src/apps/terminal/BasicTerminalBuffer.h b/src/apps/terminal/BasicTerminalBuffer.h index bd46152359..1571fbd1e0 100644 --- a/src/apps/terminal/BasicTerminalBuffer.h +++ b/src/apps/terminal/BasicTerminalBuffer.h @@ -108,7 +108,7 @@ public: void InsertCR(); void InsertLF(); void InsertRI(); - void InsertTab(); + void InsertTab(uint32 attr); void SetInsertMode(int flag); void InsertSpace(int32 num); void InsertLines(int32 numLines); diff --git a/src/apps/terminal/TermParse.cpp b/src/apps/terminal/TermParse.cpp index cd7b666425..824d88444a 100644 --- a/src/apps/terminal/TermParse.cpp +++ b/src/apps/terminal/TermParse.cpp @@ -605,7 +605,7 @@ TermParse::EscParse() break; case CASE_TAB: - fBuffer->InsertTab(); + fBuffer->InsertTab(fAttr); break; case CASE_ESC: