Squashed TODO: When writing a character in the last column of a line we

wrapped to the next line and a subsequent LF would advance another line.
We behave like xterm now, i.e. visually the cursor stays on the same
line (on the last character), but the next character will be wrapped to
the next line.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26033 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2008-06-20 00:30:13 +00:00
parent f9428b3ecd
commit b43255b9f7
2 changed files with 33 additions and 7 deletions
+32 -7
View File
@@ -116,6 +116,7 @@ BasicTerminalBuffer::Init(int32 width, int32 height, int32 historySize)
fCursor.x = 0; fCursor.x = 0;
fCursor.y = 0; fCursor.y = 0;
fSoftWrappedCursor = false;
fScreenOffset = 0; fScreenOffset = 0;
@@ -180,6 +181,7 @@ BasicTerminalBuffer::SetHistoryCapacity(int32 historyCapacity)
void void
BasicTerminalBuffer::Clear(bool resetCursor) BasicTerminalBuffer::Clear(bool resetCursor)
{ {
fSoftWrappedCursor = false;
fScreenOffset = 0; fScreenOffset = 0;
_ClearLines(0, fHeight - 1); _ClearLines(0, fHeight - 1);
@@ -541,11 +543,13 @@ BasicTerminalBuffer::InsertChar(UTF8Char c, uint32 attributes)
if (width == FULL_WIDTH) if (width == FULL_WIDTH)
attributes |= A_WIDTH; attributes |= A_WIDTH;
if (fCursor.x + width > fWidth) if (fSoftWrappedCursor || fCursor.x + width > fWidth)
_SoftBreakLine(); _SoftBreakLine();
else else
_PadLineToCursor(); _PadLineToCursor();
fSoftWrappedCursor = false;
if (!fOverwriteMode) if (!fOverwriteMode)
_InsertGap(width); _InsertGap(width);
@@ -563,9 +567,10 @@ BasicTerminalBuffer::InsertChar(UTF8Char c, uint32 attributes)
// TODO: Deal correctly with full-width chars! We must take care not to // TODO: Deal correctly with full-width chars! We must take care not to
// overwrite half of a full-width char. This holds also for other methods. // overwrite half of a full-width char. This holds also for other methods.
if (fCursor.x == fWidth) if (fCursor.x == fWidth) {
_SoftBreakLine(); fCursor.x -= width;
// TODO: Handle a subsequent CR correctly! fSoftWrappedCursor = true;
}
} }
@@ -573,6 +578,7 @@ void
BasicTerminalBuffer::InsertCR() BasicTerminalBuffer::InsertCR()
{ {
_LineAt(fCursor.y)->softBreak = false; _LineAt(fCursor.y)->softBreak = false;
fSoftWrappedCursor = false;
fCursor.x = 0; fCursor.x = 0;
_CursorChanged(); _CursorChanged();
} }
@@ -581,6 +587,8 @@ BasicTerminalBuffer::InsertCR()
void void
BasicTerminalBuffer::InsertLF() BasicTerminalBuffer::InsertLF()
{ {
fSoftWrappedCursor = false;
// If we're at the end of the scroll region, scroll. Otherwise just advance // If we're at the end of the scroll region, scroll. Otherwise just advance
// the cursor. // the cursor.
if (fCursor.y == fScrollBottom) { if (fCursor.y == fScrollBottom) {
@@ -596,9 +604,11 @@ BasicTerminalBuffer::InsertLF()
void void
BasicTerminalBuffer::InsertLines(int32 numLines) BasicTerminalBuffer::InsertLines(int32 numLines)
{ {
if (fCursor.y >= fScrollTop && fCursor.y < fScrollBottom) if (fCursor.y >= fScrollTop && fCursor.y < fScrollBottom) {
fSoftWrappedCursor = false;
_Scroll(fCursor.y, fScrollBottom, -numLines); _Scroll(fCursor.y, fScrollBottom, -numLines);
} }
}
void void
@@ -616,6 +626,7 @@ BasicTerminalBuffer::InsertSpace(int32 num)
num = fWidth - fCursor.x; num = fWidth - fCursor.x;
if (num > 0) { if (num > 0) {
fSoftWrappedCursor = false;
_PadLineToCursor(); _PadLineToCursor();
_InsertGap(num); _InsertGap(num);
@@ -637,6 +648,8 @@ BasicTerminalBuffer::EraseChars(int32 numChars)
if (fCursor.y >= line->length) if (fCursor.y >= line->length)
return; return;
fSoftWrappedCursor = false;
int32 first = fCursor.x; int32 first = fCursor.x;
int32 end = min_c(fCursor.x + numChars, line->length); int32 end = min_c(fCursor.x + numChars, line->length);
if (first > 0 && IS_WIDTH(line->cells[first - 1].attributes)) if (first > 0 && IS_WIDTH(line->cells[first - 1].attributes))
@@ -660,6 +673,8 @@ BasicTerminalBuffer::EraseAbove()
if (fCursor.y > 0) if (fCursor.y > 0)
_ClearLines(0, fCursor.y - 1); _ClearLines(0, fCursor.y - 1);
fSoftWrappedCursor = false;
// Delete the chars on the cursor line before (and including) the cursor. // Delete the chars on the cursor line before (and including) the cursor.
TerminalLine* line = _LineAt(fCursor.y); TerminalLine* line = _LineAt(fCursor.y);
if (fCursor.x < line->length) { if (fCursor.x < line->length) {
@@ -680,6 +695,8 @@ BasicTerminalBuffer::EraseAbove()
void void
BasicTerminalBuffer::EraseBelow() BasicTerminalBuffer::EraseBelow()
{ {
fSoftWrappedCursor = false;
// Clear the following lines. // Clear the following lines.
if (fCursor.y < fHeight - 1) if (fCursor.y < fHeight - 1)
_ClearLines(fCursor.y + 1, fHeight - 1); _ClearLines(fCursor.y + 1, fHeight - 1);
@@ -692,6 +709,8 @@ BasicTerminalBuffer::EraseBelow()
void void
BasicTerminalBuffer::DeleteChars(int32 numChars) BasicTerminalBuffer::DeleteChars(int32 numChars)
{ {
fSoftWrappedCursor = false;
TerminalLine* line = _LineAt(fCursor.y); TerminalLine* line = _LineAt(fCursor.y);
if (fCursor.x < line->length) { if (fCursor.x < line->length) {
if (fCursor.x + numChars < line->length) { if (fCursor.x + numChars < line->length) {
@@ -712,6 +731,8 @@ BasicTerminalBuffer::DeleteChars(int32 numChars)
void void
BasicTerminalBuffer::DeleteColumns() BasicTerminalBuffer::DeleteColumns()
{ {
fSoftWrappedCursor = false;
TerminalLine* line = _LineAt(fCursor.y); TerminalLine* line = _LineAt(fCursor.y);
if (fCursor.x < line->length) { if (fCursor.x < line->length) {
line->length = fCursor.x; line->length = fCursor.x;
@@ -723,15 +744,18 @@ BasicTerminalBuffer::DeleteColumns()
void void
BasicTerminalBuffer::DeleteLines(int32 numLines) BasicTerminalBuffer::DeleteLines(int32 numLines)
{ {
if (fCursor.y >= fScrollTop && fCursor.y <= fScrollBottom) if (fCursor.y >= fScrollTop && fCursor.y <= fScrollBottom) {
fSoftWrappedCursor = false;
_Scroll(fCursor.y, fScrollBottom, numLines); _Scroll(fCursor.y, fScrollBottom, numLines);
} }
}
void void
BasicTerminalBuffer::SetCursor(int32 x, int32 y) BasicTerminalBuffer::SetCursor(int32 x, int32 y)
{ {
//debug_printf("BasicTerminalBuffer::SetCursor(%d, %d)\n", x, y); //debug_printf("BasicTerminalBuffer::SetCursor(%d, %d)\n", x, y);
fSoftWrappedCursor = false;
x = restrict_value(x, 0, fWidth - 1); x = restrict_value(x, 0, fWidth - 1);
y = restrict_value(y, 0, fHeight - 1); y = restrict_value(y, 0, fHeight - 1);
if (x != fCursor.x || y != fCursor.y) { if (x != fCursor.x || y != fCursor.y) {
@@ -955,6 +979,7 @@ BasicTerminalBuffer::_ResizeSimple(int32 width, int32 height,
if (fCursor.x > width) if (fCursor.x > width)
fCursor.x = width; fCursor.x = width;
fCursor.y -= firstLine; fCursor.y -= firstLine;
fSoftWrappedCursor = false;
return B_OK; return B_OK;
} }
@@ -1131,6 +1156,7 @@ BasicTerminalBuffer::_ResizeRewrap(int32 width, int32 height,
//cursor.x, cursor.y); //cursor.x, cursor.y);
fCursor.x = cursor.x; fCursor.x = cursor.x;
fCursor.y = cursor.y; fCursor.y = cursor.y;
fSoftWrappedCursor = false;
//debug_printf(" screen offset: %ld -> %ld\n", fScreenOffset, destScreenOffset % height); //debug_printf(" screen offset: %ld -> %ld\n", fScreenOffset, destScreenOffset % height);
fScreenOffset = destScreenOffset % height; fScreenOffset = destScreenOffset % height;
//debug_printf(" height %ld -> %ld\n", fHeight, height); //debug_printf(" height %ld -> %ld\n", fHeight, height);
@@ -1266,7 +1292,6 @@ void
BasicTerminalBuffer::_SoftBreakLine() BasicTerminalBuffer::_SoftBreakLine()
{ {
TerminalLine* line = _LineAt(fCursor.y); TerminalLine* line = _LineAt(fCursor.y);
line->length = fCursor.x;
line->softBreak = true; line->softBreak = true;
fCursor.x = 0; fCursor.x = 0;
+1
View File
@@ -183,6 +183,7 @@ protected:
// cursor position (origin: (0, 0)) // cursor position (origin: (0, 0))
TermPos fCursor; TermPos fCursor;
TermPos fSavedCursor; TermPos fSavedCursor;
bool fSoftWrappedCursor;
bool fOverwriteMode; // false for insert bool fOverwriteMode; // false for insert
bool fAlternateScreenActive; bool fAlternateScreenActive;