diff --git a/gems/src/test/terminal_decoder/main.cc b/gems/src/test/terminal_decoder/main.cc index 4540121706..149b838779 100644 --- a/gems/src/test/terminal_decoder/main.cc +++ b/gems/src/test/terminal_decoder/main.cc @@ -77,6 +77,10 @@ class Static_character_screen : public Terminal::Character_screen { } + void cub(int) + { + } + void cuf(int) { if (_cursor_pos.x >= _boundary.width) diff --git a/os/include/terminal/char_cell_array_character_screen.h b/os/include/terminal/char_cell_array_character_screen.h index c2927e2ed3..9db6b638c5 100644 --- a/os/include/terminal/char_cell_array_character_screen.h +++ b/os/include/terminal/char_cell_array_character_screen.h @@ -236,6 +236,14 @@ class Char_cell_array_character_screen : public Terminal::Character_screen _region_end = Genode::max(_region_end, _region_start); } + void cub(int dx) + { + Cursor_guard guard(*this); + + _cursor_pos.x -= dx; + _cursor_pos.x = Genode::max(0, _cursor_pos.x); + } + void cuf(int dx) { Cursor_guard guard(*this); diff --git a/os/include/terminal/character_screen.h b/os/include/terminal/character_screen.h index e54eccb4f4..3ee5bd072f 100644 --- a/os/include/terminal/character_screen.h +++ b/os/include/terminal/character_screen.h @@ -61,6 +61,11 @@ namespace Terminal { */ virtual void csr(int, int) = 0; + /** + * Move cursor backwards + */ + virtual void cub(int) = 0; + /** * Non-destructive space - move right #1 spaces */ diff --git a/os/include/terminal/character_screen_tracer.h b/os/include/terminal/character_screen_tracer.h index 1612710eb6..6da026ad0a 100644 --- a/os/include/terminal/character_screen_tracer.h +++ b/os/include/terminal/character_screen_tracer.h @@ -37,6 +37,7 @@ namespace Terminal { CS_TRACE_OP(cvvis); CS_TRACE_OP(cpr); CS_TRACE_OP_2(csr); + CS_TRACE_OP_1(cub); CS_TRACE_OP(cuf1); CS_TRACE_OP_2(cup); CS_TRACE_OP(cuu1); diff --git a/os/include/terminal/decoder.h b/os/include/terminal/decoder.h index be2a6955c2..3744f949f8 100644 --- a/os/include/terminal/decoder.h +++ b/os/include/terminal/decoder.h @@ -257,6 +257,7 @@ namespace Terminal { if (starts_with_digit(4, p1)) return (_screen.setab(remove_first_digit(p1)), true); + case 'D': return (_screen.cub(p1), true); case 'd': return (_screen.vpa(p1), true); case 'g': return (p1 == 3) && (_screen.tbc(), true); case 'G': return (_screen.hpa(p1), true);