From 4934beb5506ba7564e0f397781cd7fe7d49eb0c0 Mon Sep 17 00:00:00 2001 From: Kurt Hindenburg Date: Sun, 4 Feb 2018 14:09:28 -0500 Subject: Konsole: Add support for ECMA-48 REP: repeating previous character MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- konsole/konsole/TEScreen.cpp | 25 ++++++++++++++++++++++++- konsole/konsole/TEScreen.h | 4 ++++ konsole/konsole/TEmuVt102.cpp | 3 ++- 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/konsole/konsole/TEScreen.cpp b/konsole/konsole/TEScreen.cpp index 9bd62ff4d..d1d7985a5 100644 --- a/konsole/konsole/TEScreen.cpp +++ b/konsole/konsole/TEScreen.cpp @@ -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) diff --git a/konsole/konsole/TEScreen.h b/konsole/konsole/TEScreen.h index 9797b53ab..557a07e4c 100644 --- a/konsole/konsole/TEScreen.h +++ b/konsole/konsole/TEScreen.h @@ -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; diff --git a/konsole/konsole/TEmuVt102.cpp b/konsole/konsole/TEmuVt102.cpp index e0efab745..b5ca0ea5b 100644 --- a/konsole/konsole/TEmuVt102.cpp +++ b/konsole/konsole/TEmuVt102.cpp @@ -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;;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 -- cgit v1.2.3