summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Bertalan <dani@danielbertalan.dev>2021-06-05 09:29:49 +0200
committerAndreas Kling <kling@serenityos.org>2021-06-10 17:18:02 +0200
commit8f8fd9c5a8acf25db12f5f74b4c3802c926b97aa (patch)
tree3d1924a294801eee55ad424c31ebff1959357f38
parent221ba1aac89f9472bd8b50310f36a832efcba76b (diff)
downloadserenity-8f8fd9c5a8acf25db12f5f74b4c3802c926b97aa.zip
LibVT+Kernel: Support clearing the scrollback buffer
As per the `xterm ctlseqs` documentation, `\e3J` should clear the scrollback buffer, and leave the visible lines unchanged. This commit fixes a FIXME.
-rw-r--r--Kernel/TTY/VirtualConsole.cpp2
-rw-r--r--Kernel/TTY/VirtualConsole.h2
-rw-r--r--Userland/Libraries/LibVT/Terminal.cpp11
-rw-r--r--Userland/Libraries/LibVT/Terminal.h10
4 files changed, 14 insertions, 11 deletions
diff --git a/Kernel/TTY/VirtualConsole.cpp b/Kernel/TTY/VirtualConsole.cpp
index 2684783ab1..36d027a33c 100644
--- a/Kernel/TTY/VirtualConsole.cpp
+++ b/Kernel/TTY/VirtualConsole.cpp
@@ -33,7 +33,7 @@ void ConsoleImpl::clear()
{
m_client.clear();
}
-void ConsoleImpl::clear_including_history()
+void ConsoleImpl::clear_history()
{
}
diff --git a/Kernel/TTY/VirtualConsole.h b/Kernel/TTY/VirtualConsole.h
index 69f6eecf90..6442998bc3 100644
--- a/Kernel/TTY/VirtualConsole.h
+++ b/Kernel/TTY/VirtualConsole.h
@@ -35,7 +35,7 @@ public:
private:
virtual void invalidate_cursor() override;
virtual void clear() override;
- virtual void clear_including_history() override;
+ virtual void clear_history() override;
virtual void scroll_up(u16 region_top, u16 region_bottom, size_t count) override;
virtual void scroll_down(u16 region_top, u16 region_bottom, size_t count) override;
diff --git a/Userland/Libraries/LibVT/Terminal.cpp b/Userland/Libraries/LibVT/Terminal.cpp
index bb64076859..8a965ed7f5 100644
--- a/Userland/Libraries/LibVT/Terminal.cpp
+++ b/Userland/Libraries/LibVT/Terminal.cpp
@@ -32,17 +32,15 @@ void Terminal::clear()
{
dbgln_if(TERMINAL_DEBUG, "Clear the entire screen");
for (size_t i = 0; i < rows(); ++i)
- active_buffer()[i].clear(m_current_state.attribute);
+ active_buffer()[i].clear(Attribute());
set_cursor(0, 0);
}
-void Terminal::clear_including_history()
+void Terminal::clear_history()
{
+ dbgln_if(TERMINAL_DEBUG, "Clear history");
m_history.clear();
m_history_start = 0;
-
- clear();
-
m_client.terminal_history_changed();
}
#endif
@@ -626,8 +624,7 @@ void Terminal::ED(Parameters params)
clear();
break;
case 3:
- // FIXME: <esc>[3J should also clear the scrollback buffer.
- clear();
+ clear_history();
break;
default:
unimplemented_csi_sequence(params, {}, 'J');
diff --git a/Userland/Libraries/LibVT/Terminal.h b/Userland/Libraries/LibVT/Terminal.h
index 5b34a960a2..8a52aa81ce 100644
--- a/Userland/Libraries/LibVT/Terminal.h
+++ b/Userland/Libraries/LibVT/Terminal.h
@@ -74,12 +74,18 @@ public:
void set_cursor(unsigned row, unsigned column, bool skip_debug = false);
+ void clear_including_history()
+ {
+ clear_history();
+ clear();
+ }
+
#ifndef KERNEL
void clear();
- void clear_including_history();
+ void clear_history();
#else
virtual void clear() = 0;
- virtual void clear_including_history() = 0;
+ virtual void clear_history() = 0;
#endif
#ifndef KERNEL