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

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.
This commit is contained in:
Daniel Bertalan 2021-06-05 09:29:49 +02:00 committed by Andreas Kling
parent 221ba1aac8
commit 8f8fd9c5a8
4 changed files with 14 additions and 11 deletions

View file

@ -33,7 +33,7 @@ void ConsoleImpl::clear()
{ {
m_client.clear(); m_client.clear();
} }
void ConsoleImpl::clear_including_history() void ConsoleImpl::clear_history()
{ {
} }

View file

@ -35,7 +35,7 @@ public:
private: private:
virtual void invalidate_cursor() override; virtual void invalidate_cursor() override;
virtual void clear() 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_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; virtual void scroll_down(u16 region_top, u16 region_bottom, size_t count) override;

View file

@ -32,17 +32,15 @@ void Terminal::clear()
{ {
dbgln_if(TERMINAL_DEBUG, "Clear the entire screen"); dbgln_if(TERMINAL_DEBUG, "Clear the entire screen");
for (size_t i = 0; i < rows(); ++i) 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); set_cursor(0, 0);
} }
void Terminal::clear_including_history() void Terminal::clear_history()
{ {
dbgln_if(TERMINAL_DEBUG, "Clear history");
m_history.clear(); m_history.clear();
m_history_start = 0; m_history_start = 0;
clear();
m_client.terminal_history_changed(); m_client.terminal_history_changed();
} }
#endif #endif
@ -626,8 +624,7 @@ void Terminal::ED(Parameters params)
clear(); clear();
break; break;
case 3: case 3:
// FIXME: <esc>[3J should also clear the scrollback buffer. clear_history();
clear();
break; break;
default: default:
unimplemented_csi_sequence(params, {}, 'J'); unimplemented_csi_sequence(params, {}, 'J');

View file

@ -74,12 +74,18 @@ public:
void set_cursor(unsigned row, unsigned column, bool skip_debug = false); void set_cursor(unsigned row, unsigned column, bool skip_debug = false);
void clear_including_history()
{
clear_history();
clear();
}
#ifndef KERNEL #ifndef KERNEL
void clear(); void clear();
void clear_including_history(); void clear_history();
#else #else
virtual void clear() = 0; virtual void clear() = 0;
virtual void clear_including_history() = 0; virtual void clear_history() = 0;
#endif #endif
#ifndef KERNEL #ifndef KERNEL