Terminal: implement ECMA-48 "REP"

fix #16724

Change-Id: Ie9f8252393a65a0101a6d78db2360f48bb52bc73
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3607
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
This commit is contained in:
Jérôme Duval 2021-01-06 21:14:45 +01:00 committed by waddlesplash
parent b9e03b90a5
commit 242adb20f3
5 changed files with 27 additions and 2 deletions

View File

@ -121,7 +121,8 @@ BasicTerminalBuffer::BasicTerminalBuffer()
fSavedOriginMode(false),
fTabStops(NULL),
fEncoding(M_UTF8),
fCaptureFile(-1)
fCaptureFile(-1),
fLast()
{
}
@ -625,6 +626,7 @@ BasicTerminalBuffer::InsertChar(UTF8Char c)
{
//debug_printf("BasicTerminalBuffer::InsertChar('%.*s' (%d), %#lx)\n",
//(int)c.ByteCount(), c.bytes, c.bytes[0], attributes);
fLast = c;
int32 width = c.IsFullWidth() ? FULL_WIDTH : HALF_WIDTH;
if (fSoftWrappedCursor || (fCursor.x + width) > fWidth)
@ -1857,4 +1859,11 @@ BasicTerminalBuffer::CaptureChar(char ch)
write(fCaptureFile, &ch, 1);
}
void
BasicTerminalBuffer::InsertLastChar()
{
InsertChar(fLast);
}
#endif

View File

@ -141,6 +141,7 @@ public:
void SetInsertMode(int flag);
void InsertSpace(int32 num);
void InsertLines(int32 numLines);
void InsertLastChar();
// delete chars/lines
inline void EraseChars(int32 numChars);
@ -250,6 +251,8 @@ protected:
int fEncoding;
int fCaptureFile;
UTF8Char fLast;
// listener/dirty region management
TerminalBufferDirtyInfo fDirtyInfo;
};

View File

@ -1213,6 +1213,18 @@ TermParse::EscParse()
fBuffer->MoveCursorUp(row);
parsestate = groundtable;
break;
case CASE_REP: // ESC [...b repeat last graphic char
{
int repetitions = param[0];
int maxRepetitions = fBuffer->Width() * fBuffer->Height();
if (repetitions > maxRepetitions)
repetitions = maxRepetitions;
for (int i = 0; i < repetitions; i++)
fBuffer->InsertLastChar();
parsestate = groundtable;
break;
}
default:
break;
}

View File

@ -1119,7 +1119,7 @@ CASE_GROUND_STATE,
/* ` a b c */
CASE_GROUND_STATE,
CASE_GROUND_STATE,
CASE_GROUND_STATE,
CASE_REP,
CASE_DA1,
/* d e f g */
CASE_VPA,

View File

@ -101,3 +101,4 @@
#define CASE_CFT 98
#define CASE_INDEX 99
#define CASE_NEXT_LINE 100
#define CASE_REP 101