From c099e0f2ea0f25b923203d17409eee8bc2831bfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Javier=20Merino=20Mor=C3=A1n?= Date: Wed, 20 Oct 2021 22:25:41 +0200 Subject: [PATCH] Fix regression on cursor controls at last column Commit 8de0e6c7 mistakenly removed code to cancel the pending wrap flag (which in konsole is implemented as having the cursor one past the width of the screen) before the cursor controls CUU, CUD, CUB and BS. While the behavior may seem counter-intuitive (specially BS and CUB, where `printf "A\bB"` at the last column results in `BA`), this is the behavior of VT100, xterm (without reverse-wraparound mode), and, most importantly, is expected by ncurses. CCBUG: 399615 --- src/Screen.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Screen.cpp b/src/Screen.cpp index c7351091..327f2674 100644 --- a/src/Screen.cpp +++ b/src/Screen.cpp @@ -96,6 +96,7 @@ void Screen::cursorUp(int n) n = 1; // Default } const int stop = _cuY < _topMargin ? 0 : _topMargin; + _cuX = qMin(_columns - 1, _cuX); // nowrap! _cuY = qMax(stop, _cuY - n); } @@ -109,6 +110,7 @@ void Screen::cursorDown(int n) n = MAX_SCREEN_ARGUMENT; } const int stop = _cuY > _bottomMargin ? _lines - 1 : _bottomMargin; + _cuX = qMin(_columns - 1, _cuX); // nowrap! _cuY = qMin(stop, _cuY + n); } @@ -118,6 +120,7 @@ void Screen::cursorLeft(int n) if (n < 1) { n = 1; // Default } + _cuX = qMin(_columns - 1, _cuX); // nowrap! _cuX = qMax(0, _cuX - n); } @@ -768,6 +771,7 @@ void Screen::reset() void Screen::backspace() { + _cuX = qMin(_columns - 1, _cuX); // nowrap! _cuX = qMax(0, _cuX - 1); if (_screenLines.at(_cuY).size() < _cuX + 1) {