LibVT: Implement DECFI and DECBI

These escape sequences are the horizontal scrolling equivalents of `IND`
and `RI`. Normally, they move the cursor forward or backward. But if
they hit the margins (which we just treat as the first and last
columns), they scroll the line.

Another VT420 feature done.
This commit is contained in:
Daniel Bertalan 2021-06-05 15:35:14 +02:00 committed by Andreas Kling
parent 89843cd692
commit 13991eade7
Notes: sideshowbarker 2024-07-18 12:29:46 +09:00
2 changed files with 28 additions and 0 deletions

View File

@ -888,6 +888,22 @@ void Terminal::RI()
set_cursor(cursor_row() - 1, cursor_column());
}
void Terminal::DECFI()
{
if (cursor_column() == columns() - 1)
scroll_left(cursor_row(), 0, 1);
else
set_cursor(cursor_row(), cursor_column() + 1);
}
void Terminal::DECBI()
{
if (cursor_column() == 0)
scroll_right(cursor_row(), 0, 1);
else
set_cursor(cursor_row(), cursor_column() - 1);
}
void Terminal::DSR(Parameters params)
{
if (params.size() == 1 && params[0] == 5) {
@ -991,12 +1007,18 @@ void Terminal::execute_escape_sequence(Intermediates intermediates, bool ignore,
case '\\':
// ST (string terminator) -- do nothing
return;
case '6':
DECBI();
return;
case '7':
DECSC();
return;
case '8':
DECRC();
return;
case '9':
DECFI();
return;
}
} else if (intermediates[0] == '#') {
switch (last_byte) {

View File

@ -304,6 +304,12 @@ protected:
// RI - Reverse Index (move up)
void RI();
// DECBI - Back Index
void DECBI();
// DECFI - Forward Index
void DECFI();
// DSR - Device Status Reports
void DSR(Parameters);