Commit 4352df00 authored by Luis Javier Merino's avatar Luis Javier Merino Committed by Kurt Hindenburg
Browse files

Use the correct last column for double-width lines

Some control functions special case the last column. When a line has
been set to double-width via DECDWL or DECDHL (double-height and
double-width), the correcr last column for that line should be used.
Control functions which special case the last column include TAB, CUF,
ICH and DECRC.

Can be tested with:

perl -E '$r=join "", map{$_%10}1..80; say "\e<\e[?40h\e[?3l\e[?7l$r";
         $s="L"."\tx"x4 ."\t\tR"; say "\e#3$s\n\e#4$s"'

The above tests that tabs don't travel beyond the last column in
double-width lines.  The last column (below columns 79 and 80 of
the previous line) should have an "R".

perl -E '$r=join "", map{$_%10}1..80; say "\e<\e[?40h\e[?3l\e[?7h$r";
         $s="L"."X"x36 ."\e[6C"."R"; say "\e#3$s\n\e#4$s"'

The above tests that CUF (Cursor Forward) doesn't travel beyond the last
column in double-width lines.  The last column (below columns 79 and 80
of the previous line) should have an "R".

perl -E '$r=join "", map{$_%10}1..80; say "\e<\e[?40h\e[?3l\e[?7h$r";
         $s="L"."X"x22 ."R"."x"x8 ."r"."\e[17D\e[16@";
         say "\e#3$s\n\e#4$s"'

The above tests that ICH (Insert CHaracters; VT200+) doesn't write past
the last column, visible on repaints (switch to another window and
back).

perl -E '$r=join "", map{$_%10}1..80; say "\e<\e[?40h\e[?3l\e[?7h$r";
         $s="L"."X"x38 ."r\e7\e[H\e8R"; say "\e#3$s\n\e#4$s"'

The above tests that DECRC (Restore Cursor) doesn't restore the cursor
to a position beyond the last column on double-width lines.  The last
column should have an "R", "r" should not be visible.

perl -E '$r=join "", map{$_%10}1..80; say "\e<\e[?40h\e[?3l\e[?7l$r";
         $s="L"."X"x38 ."R"; print "\e#6$s"'; sleep 5; echo

The above tests that the cursor stays at the rightmost column. The
cursor should stay over the "R" for 5 seconds.
parent 9ffe33a2
...@@ -155,7 +155,7 @@ void Screen::cursorRight(int n) ...@@ -155,7 +155,7 @@ void Screen::cursorRight(int n)
if (n > MAX_SCREEN_ARGUMENT) { if (n > MAX_SCREEN_ARGUMENT) {
n = MAX_SCREEN_ARGUMENT; n = MAX_SCREEN_ARGUMENT;
} }
_cuX = qMin(_columns - 1, _cuX + n); _cuX = qMin(getScreenLineColumns(_cuY) - 1, _cuX + n);
} }
void Screen::setMargins(int top, int bot) void Screen::setMargins(int top, int bot)
...@@ -272,8 +272,8 @@ void Screen::insertChars(int n) ...@@ -272,8 +272,8 @@ void Screen::insertChars(int n)
_screenLines[_cuY].insert(_cuX, n, Character(' ')); _screenLines[_cuY].insert(_cuX, n, Character(' '));
if (_screenLines[_cuY].count() > _columns) { if (_screenLines[_cuY].count() > getScreenLineColumns(_cuY)) {
_screenLines[_cuY].resize(_columns); _screenLines[_cuY].resize(getScreenLineColumns(_cuY));
} }
} }
...@@ -359,7 +359,7 @@ void Screen::saveCursor() ...@@ -359,7 +359,7 @@ void Screen::saveCursor()
void Screen::restoreCursor() void Screen::restoreCursor()
{ {
_cuX = qMin(_savedState.cursorColumn, _columns - 1); _cuX = qMin(_savedState.cursorColumn, getScreenLineColumns(_savedState.cursorLine) - 1);
_cuY = qMin(_savedState.cursorLine, _lines - 1); _cuY = qMin(_savedState.cursorLine, _lines - 1);
_currentRendition = _savedState.rendition; _currentRendition = _savedState.rendition;
_currentForeground = _savedState.foreground; _currentForeground = _savedState.foreground;
...@@ -677,7 +677,7 @@ void Screen::getImage(Character* dest, int size, int startLine, int endLine) con ...@@ -677,7 +677,7 @@ void Screen::getImage(Character* dest, int size, int startLine, int endLine) con
} }
} }
int visX = qMin(_cuX, _columns - 1); int visX = qMin(_cuX, getScreenLineColumns(_cuY) - 1);
// mark the character at the current cursor position // mark the character at the current cursor position
int cursorIndex = loc(visX, _cuY + linesInHistoryBuffer); int cursorIndex = loc(visX, _cuY + linesInHistoryBuffer);
if (getMode(MODE_Cursor) && cursorIndex < _columns * mergedLines) { if (getMode(MODE_Cursor) && cursorIndex < _columns * mergedLines) {
...@@ -771,9 +771,9 @@ void Screen::tab(int n) ...@@ -771,9 +771,9 @@ void Screen::tab(int n)
if (n < 1) { if (n < 1) {
n = 1; n = 1;
} }
while ((n > 0) && (_cuX < _columns - 1)) { while ((n > 0) && (_cuX < getScreenLineColumns(_cuY) - 1)) {
cursorRight(1); cursorRight(1);
while ((_cuX < _columns - 1) && !_tabStops[_cuX]) { while ((_cuX < getScreenLineColumns(_cuY) - 1) && !_tabStops[_cuX]) {
cursorRight(1); cursorRight(1);
} }
n--; n--;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment