Konsole: Add support for ECMA-48 REP: repeating previous character

Patch by btown using lxde/qtermwidget@60221da by @yan12125

ECMA-48 8.3.103 describes the sequence CSI Pn b for repeating the
previous character in the data stream. This sequence has been present
in XTerm since January 1997 and has been added to the latest terminfo
entry for xterm-new and derived entries such as xterm-256color.

https://phabricator.kde.org/D10064

Taken from KDE patches and adapted to TDE.

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
pull/184/head
Kurt Hindenburg 6 years ago committed by Slávek Banko
parent 6a2392888f
commit 4934beb550
No known key found for this signature in database
GPG Key ID: 608F5293A04BE668

@ -81,7 +81,8 @@ TEScreen::TEScreen(int l, int c)
ef_fg(cacol()), ef_bg(cacol()), ef_re(0),
sa_cuX(0), sa_cuY(0),
sa_cu_re(0), sa_cu_fg(cacol()), sa_cu_bg(cacol()),
lastPos(-1)
lastPos(-1),
lastDrawnChar(0)
{
/*
this->lines = lines;
@ -300,6 +301,26 @@ void TEScreen::insertChars(int n)
clearImage(loc(cuX,cuY),loc(q-1,cuY),' ');
}
void TEScreen::repeatChars(int n)
{
if (n == 0)
{
n = 1; // Default
}
// 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 < n; i++)
{
ShowCharacter(lastDrawnChar);
}
}
/*! delete `n' lines starting from (including) the cursor position.
The cursor is not moved by the operation.
@ -762,6 +783,8 @@ void TEScreen::ShowCharacter(unsigned short c)
lastPos = i;
lastDrawnChar = c;
cuX += w--;
while(w)

@ -83,6 +83,7 @@ public: // these are all `Screen' operations
void eraseChars (int n);
void deleteChars (int n);
void insertChars (int n);
void repeatChars (int n);
void deleteLines (int n);
void insertLines (int n);
//
@ -271,6 +272,9 @@ private: // helper
// last position where we added a character
int lastPos;
// used in REP (repeating char)
unsigned short lastDrawnChar;
// modes
ScreenParm saveParm;

@ -267,7 +267,7 @@ void TEmuVt102::initTokenizer()
for(i = 0; i < 256; i++) tbl[ i] = 0;
for(i = 0; i < 32; i++) tbl[ i] |= CTL;
for(i = 32; i < 256; i++) tbl[ i] |= CHR;
for(s = (UINT8*)"@ABCDGHILMPSTXZcdfry"; *s; s++) tbl[*s] |= CPN;
for(s = (UINT8*)"@ABCDGHILMPSTXZbcdfry"; *s; s++) tbl[*s] |= CPN;
// resize = \e[8;<row>;<col>t
for(s = (UINT8*)"t"; *s; s++) tbl[*s] |= CPS;
for(s = (UINT8*)"0123456789" ; *s; s++) tbl[*s] |= DIG;
@ -631,6 +631,7 @@ switch( N )
case TY_CSI_PN('T' ) : scr->scrollDown (p ); break;
case TY_CSI_PN('X' ) : scr->eraseChars (p ); break;
case TY_CSI_PN('Z' ) : scr->backTabulate (p ); break;
case TY_CSI_PN('b' ) : scr->repeatChars (p ); break;
case TY_CSI_PN('c' ) : reportTerminalType ( ); break; //VT100
case TY_CSI_PN('d' ) : scr->setCursorY (p ); break; //LINUX
case TY_CSI_PN('f' ) : scr->setCursorYX (p, q); break; //VT100

Loading…
Cancel
Save