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

Terminal+LibVT: Add Alt shortcuts to menu actions

This commit is contained in:
Andreas Kling 2021-04-09 15:55:28 +02:00
parent afb6e3a79d
commit c2b760e335
2 changed files with 10 additions and 10 deletions

View file

@ -401,7 +401,7 @@ int main(int argc, char** argv)
auto new_scrollback_size = config->read_num_entry("Terminal", "MaxHistorySize", terminal.max_history_size()); auto new_scrollback_size = config->read_num_entry("Terminal", "MaxHistorySize", terminal.max_history_size());
terminal.set_max_history_size(new_scrollback_size); terminal.set_max_history_size(new_scrollback_size);
auto open_settings_action = GUI::Action::create("Settings", Gfx::Bitmap::load_from_file("/res/icons/16x16/gear.png"), auto open_settings_action = GUI::Action::create("&Settings", Gfx::Bitmap::load_from_file("/res/icons/16x16/gear.png"),
[&](const GUI::Action&) { [&](const GUI::Action&) {
if (!settings_window) if (!settings_window)
settings_window = create_settings_window(terminal); settings_window = create_settings_window(terminal);
@ -410,7 +410,7 @@ int main(int argc, char** argv)
}); });
terminal.context_menu().add_separator(); terminal.context_menu().add_separator();
auto pick_font_action = GUI::Action::create("Terminal font...", Gfx::Bitmap::load_from_file("/res/icons/16x16/app-font-editor.png"), auto pick_font_action = GUI::Action::create("Terminal &Font...", Gfx::Bitmap::load_from_file("/res/icons/16x16/app-font-editor.png"),
[&](auto&) { [&](auto&) {
auto picker = GUI::FontPicker::construct(window, &terminal.font(), true); auto picker = GUI::FontPicker::construct(window, &terminal.font(), true);
if (picker->exec() == GUI::Dialog::ExecOK) { if (picker->exec() == GUI::Dialog::ExecOK) {
@ -429,7 +429,7 @@ int main(int argc, char** argv)
auto menubar = GUI::MenuBar::construct(); auto menubar = GUI::MenuBar::construct();
auto& app_menu = menubar->add_menu("&File"); auto& app_menu = menubar->add_menu("&File");
app_menu.add_action(GUI::Action::create("Open new Terminal", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::load_from_file("/res/icons/16x16/app-terminal.png"), [&](auto&) { app_menu.add_action(GUI::Action::create("Open New &Terminal", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::load_from_file("/res/icons/16x16/app-terminal.png"), [&](auto&) {
pid_t child; pid_t child;
const char* argv[] = { "Terminal", nullptr }; const char* argv[] = { "Terminal", nullptr };
if ((errno = posix_spawn(&child, "/bin/Terminal", nullptr, nullptr, const_cast<char**>(argv), environ))) { if ((errno = posix_spawn(&child, "/bin/Terminal", nullptr, nullptr, const_cast<char**>(argv), environ))) {
@ -451,7 +451,7 @@ 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());
edit_menu.add_separator(); edit_menu.add_separator();
edit_menu.add_action(GUI::Action::create("Find...", { Mod_Ctrl | Mod_Shift, Key_F }, Gfx::Bitmap::load_from_file("/res/icons/16x16/find.png"), edit_menu.add_action(GUI::Action::create("&Find...", { Mod_Ctrl | Mod_Shift, Key_F }, Gfx::Bitmap::load_from_file("/res/icons/16x16/find.png"),
[&](auto&) { [&](auto&) {
if (!find_window) if (!find_window)
find_window = create_find_window(terminal); find_window = create_find_window(terminal);

View file

@ -141,17 +141,17 @@ TerminalWidget::TerminalWidget(int ptm_fd, bool automatic_size_policy, RefPtr<Co
m_terminal.set_size(m_config->read_num_entry("Window", "Width", 80), m_config->read_num_entry("Window", "Height", 25)); m_terminal.set_size(m_config->read_num_entry("Window", "Width", 80), m_config->read_num_entry("Window", "Height", 25));
m_copy_action = GUI::Action::create("Copy", { Mod_Ctrl | Mod_Shift, Key_C }, Gfx::Bitmap::load_from_file("/res/icons/16x16/edit-copy.png"), [this](auto&) { m_copy_action = GUI::Action::create("&Copy", { Mod_Ctrl | Mod_Shift, Key_C }, Gfx::Bitmap::load_from_file("/res/icons/16x16/edit-copy.png"), [this](auto&) {
copy(); copy();
}); });
m_copy_action->set_swallow_key_event_when_disabled(true); m_copy_action->set_swallow_key_event_when_disabled(true);
m_paste_action = GUI::Action::create("Paste", { Mod_Ctrl | Mod_Shift, Key_V }, Gfx::Bitmap::load_from_file("/res/icons/16x16/paste.png"), [this](auto&) { m_paste_action = GUI::Action::create("&Paste", { Mod_Ctrl | Mod_Shift, Key_V }, Gfx::Bitmap::load_from_file("/res/icons/16x16/paste.png"), [this](auto&) {
paste(); paste();
}); });
m_paste_action->set_swallow_key_event_when_disabled(true); m_paste_action->set_swallow_key_event_when_disabled(true);
m_clear_including_history_action = GUI::Action::create("Clear including history", { Mod_Ctrl | Mod_Shift, Key_K }, [this](auto&) { m_clear_including_history_action = GUI::Action::create("&Clear Including History", { Mod_Ctrl | Mod_Shift, Key_K }, [this](auto&) {
clear_including_history(); clear_including_history();
}); });
@ -1026,7 +1026,7 @@ void TerminalWidget::context_menu_event(GUI::ContextMenuEvent& event)
auto af = Desktop::AppFile::get_for_app(LexicalPath(handler).basename()); auto af = Desktop::AppFile::get_for_app(LexicalPath(handler).basename());
if (!af->is_valid()) if (!af->is_valid())
continue; continue;
auto action = GUI::Action::create(String::formatted("Open in {}", af->name()), af->icon().bitmap_for_size(16), [this, handler](auto&) { auto action = GUI::Action::create(String::formatted("&Open in {}", af->name()), af->icon().bitmap_for_size(16), [this, handler](auto&) {
Desktop::Launcher::open(m_context_menu_href, handler); Desktop::Launcher::open(m_context_menu_href, handler);
}); });
@ -1036,10 +1036,10 @@ void TerminalWidget::context_menu_event(GUI::ContextMenuEvent& event)
m_context_menu_for_hyperlink->add_action(action); m_context_menu_for_hyperlink->add_action(action);
} }
m_context_menu_for_hyperlink->add_action(GUI::Action::create("Copy URL", [this](auto&) { m_context_menu_for_hyperlink->add_action(GUI::Action::create("Copy &URL", [this](auto&) {
GUI::Clipboard::the().set_plain_text(m_context_menu_href); GUI::Clipboard::the().set_plain_text(m_context_menu_href);
})); }));
m_context_menu_for_hyperlink->add_action(GUI::Action::create("Copy name", [&](auto&) { m_context_menu_for_hyperlink->add_action(GUI::Action::create("Copy &Name", [&](auto&) {
// file://courage/home/anon/something -> /home/anon/something // file://courage/home/anon/something -> /home/anon/something
auto path = URL(m_context_menu_href).path(); auto path = URL(m_context_menu_href).path();
// /home/anon/something -> something // /home/anon/something -> something