1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 06:07:34 +00:00

LibVT+Everywhere: Introduce 'automarks' and 'clear previous command'

Automarks are similar to bookmarks placed by the terminal, allowing the
user to selectively remove a single command and its output from the
terminal scrollback.
This commit implements a single way to add marks: automatically placing
them when the shell becomes interactive.

To make sure the shell behaves correctly after its expected prompt
position changes, the terminal layer forces a resize event to be passed
to the shell on such (possibly) partial clears; this also has the nice
side effect of fixing the disappearing prompt on the preexisting "clear
including history" action: Fixes #4192.
This commit is contained in:
Ali Mohammad Pur 2024-02-06 01:41:35 +03:30 committed by Ali Mohammad Pur
parent cde528fdd9
commit 54ab6fe5b9
12 changed files with 238 additions and 0 deletions

View file

@ -17,6 +17,7 @@
#ifndef KERNEL
# include <AK/ByteString.h>
# include <AK/HashTable.h>
# include <LibVT/Attribute.h>
# include <LibVT/Line.h>
#else
@ -49,6 +50,7 @@ public:
virtual void set_window_progress(int value, int max) = 0;
virtual void terminal_did_resize(u16 columns, u16 rows) = 0;
virtual void terminal_history_changed(int delta) = 0;
virtual void terminal_did_perform_possibly_partial_clear() = 0;
virtual void emit(u8 const*, size_t) = 0;
virtual void set_cursor_shape(CursorShape) = 0;
virtual void set_cursor_blinking(bool) = 0;
@ -85,8 +87,12 @@ public:
}
#ifndef KERNEL
void mark_cursor();
OrderedHashTable<Mark> const& marks() const { return m_valid_marks; }
void clear();
void clear_history();
void clear_to_mark(Mark);
#else
virtual void clear() = 0;
virtual void clear_history() = 0;
@ -438,6 +444,7 @@ protected:
#ifndef KERNEL
ByteString m_current_window_title;
Vector<ByteString> m_title_stack;
OrderedHashTable<Mark> m_valid_marks;
#endif
#ifndef KERNEL