From 13991eade72ef6f2c488f40e9cb1304f0133ed57 Mon Sep 17 00:00:00 2001 From: Daniel Bertalan Date: Sat, 5 Jun 2021 15:35:14 +0200 Subject: [PATCH] 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. --- Userland/Libraries/LibVT/Terminal.cpp | 22 ++++++++++++++++++++++ Userland/Libraries/LibVT/Terminal.h | 6 ++++++ 2 files changed, 28 insertions(+) diff --git a/Userland/Libraries/LibVT/Terminal.cpp b/Userland/Libraries/LibVT/Terminal.cpp index 5e72d1dd8e..7009a79db5 100644 --- a/Userland/Libraries/LibVT/Terminal.cpp +++ b/Userland/Libraries/LibVT/Terminal.cpp @@ -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) { diff --git a/Userland/Libraries/LibVT/Terminal.h b/Userland/Libraries/LibVT/Terminal.h index ea719935ba..3087a05c4f 100644 --- a/Userland/Libraries/LibVT/Terminal.h +++ b/Userland/Libraries/LibVT/Terminal.h @@ -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);