Support REP escape sequence defined in ECMA-48, section 8.3.103

Since ncurses 20170729, supporting REP is necessary for terminals with
xterm compatibility (TERM=xterm or similar). This patch fixes layout
issues with htop. [1]

[1] http://lists.gnu.org/archive/html/bug-ncurses/2017-08/msg00051.html
This commit is contained in:
Yen Chi Hsuan
2017-08-29 14:50:38 +08:00
parent 35e5f4141d
commit 60221dae4c
3 changed files with 34 additions and 1 deletions
+24
View File
@@ -226,6 +226,28 @@ void Screen::insertChars(int n)
screenLines[cuY].resize(columns);
}
void Screen::repeatChars(int count)
//=REP
{
if (count == 0)
{
count = 1;
}
/**
* From ECMA-48 version 5, section 8.3.103
* If the character preceding REP is a control function or part of a
* control function, the effect of REP is not defined by this Standard.
*
* So, a "normal" program should always use REP immediately after a visible
* character (those other than escape sequences). So, lastDrawnChar can be
* safely used.
*/
for (int i = 0; i < count; i++)
{
displayCharacter(lastDrawnChar);
}
}
void Screen::deleteLines(int n)
{
if (n == 0) n = 1; // Default
@@ -663,6 +685,8 @@ void Screen::displayCharacter(unsigned short c)
currentChar.backgroundColor = effectiveBackground;
currentChar.rendition = effectiveRendition;
lastDrawnChar = c;
int i = 0;
int newCursorX = cuX + w--;
while(w)