mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 03:27:45 +00:00
Terminal+LibVT: Add "clear including history" action (Ctrl+Shift+K) :^)
Sometimes you just want to get rid of all your scrollback history in the terminal, and now there's a way to do that.
This commit is contained in:
parent
e8a59ef842
commit
0c4b0c0312
5 changed files with 27 additions and 0 deletions
|
@ -297,6 +297,9 @@ int main(int argc, char** argv)
|
||||||
edit_menu.add_action(terminal.copy_action());
|
edit_menu.add_action(terminal.copy_action());
|
||||||
edit_menu.add_action(terminal.paste_action());
|
edit_menu.add_action(terminal.paste_action());
|
||||||
|
|
||||||
|
auto& view_menu = menubar->add_menu("View");
|
||||||
|
view_menu.add_action(terminal.clear_including_history_action());
|
||||||
|
|
||||||
GUI::ActionGroup font_action_group;
|
GUI::ActionGroup font_action_group;
|
||||||
font_action_group.set_exclusive(true);
|
font_action_group.set_exclusive(true);
|
||||||
auto& font_menu = menubar->add_menu("Font");
|
auto& font_menu = menubar->add_menu("Font");
|
||||||
|
|
|
@ -49,6 +49,14 @@ void Terminal::clear()
|
||||||
set_cursor(0, 0);
|
set_cursor(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Terminal::clear_including_history()
|
||||||
|
{
|
||||||
|
m_history.clear();
|
||||||
|
clear();
|
||||||
|
|
||||||
|
m_client.terminal_history_changed();
|
||||||
|
}
|
||||||
|
|
||||||
inline bool is_valid_parameter_character(u8 ch)
|
inline bool is_valid_parameter_character(u8 ch)
|
||||||
{
|
{
|
||||||
return ch >= 0x30 && ch <= 0x3f;
|
return ch >= 0x30 && ch <= 0x3f;
|
||||||
|
|
|
@ -59,6 +59,8 @@ public:
|
||||||
void on_input(u8);
|
void on_input(u8);
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
|
void clear_including_history();
|
||||||
|
|
||||||
void set_size(u16 columns, u16 rows);
|
void set_size(u16 columns, u16 rows);
|
||||||
u16 columns() const { return m_columns; }
|
u16 columns() const { return m_columns; }
|
||||||
u16 rows() const { return m_rows; }
|
u16 rows() const { return m_rows; }
|
||||||
|
|
|
@ -133,9 +133,15 @@ TerminalWidget::TerminalWidget(int ptm_fd, bool automatic_size_policy, RefPtr<Co
|
||||||
paste();
|
paste();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
m_clear_including_history_action = GUI::Action::create("Clear including history", { Mod_Ctrl | Mod_Shift, Key_K }, [this](auto&) {
|
||||||
|
clear_including_history();
|
||||||
|
});
|
||||||
|
|
||||||
m_context_menu = GUI::Menu::construct();
|
m_context_menu = GUI::Menu::construct();
|
||||||
m_context_menu->add_action(copy_action());
|
m_context_menu->add_action(copy_action());
|
||||||
m_context_menu->add_action(paste_action());
|
m_context_menu->add_action(paste_action());
|
||||||
|
m_context_menu->add_separator();
|
||||||
|
m_context_menu->add_action(clear_including_history_action());
|
||||||
}
|
}
|
||||||
|
|
||||||
TerminalWidget::~TerminalWidget()
|
TerminalWidget::~TerminalWidget()
|
||||||
|
@ -865,3 +871,8 @@ void TerminalWidget::did_change_font()
|
||||||
if (!size().is_empty())
|
if (!size().is_empty())
|
||||||
relayout(size());
|
relayout(size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TerminalWidget::clear_including_history()
|
||||||
|
{
|
||||||
|
m_terminal.clear_including_history();
|
||||||
|
}
|
||||||
|
|
|
@ -79,9 +79,11 @@ public:
|
||||||
|
|
||||||
GUI::Action& copy_action() { return *m_copy_action; }
|
GUI::Action& copy_action() { return *m_copy_action; }
|
||||||
GUI::Action& paste_action() { return *m_paste_action; }
|
GUI::Action& paste_action() { return *m_paste_action; }
|
||||||
|
GUI::Action& clear_including_history_action() { return *m_clear_including_history_action; }
|
||||||
|
|
||||||
void copy();
|
void copy();
|
||||||
void paste();
|
void paste();
|
||||||
|
void clear_including_history();
|
||||||
|
|
||||||
virtual bool accepts_focus() const override { return true; }
|
virtual bool accepts_focus() const override { return true; }
|
||||||
|
|
||||||
|
@ -178,6 +180,7 @@ private:
|
||||||
|
|
||||||
RefPtr<GUI::Action> m_copy_action;
|
RefPtr<GUI::Action> m_copy_action;
|
||||||
RefPtr<GUI::Action> m_paste_action;
|
RefPtr<GUI::Action> m_paste_action;
|
||||||
|
RefPtr<GUI::Action> m_clear_including_history_action;
|
||||||
|
|
||||||
RefPtr<GUI::Menu> m_context_menu;
|
RefPtr<GUI::Menu> m_context_menu;
|
||||||
RefPtr<GUI::Menu> m_context_menu_for_hyperlink;
|
RefPtr<GUI::Menu> m_context_menu_for_hyperlink;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue