diff options
author | Andreas Kling <kling@serenityos.org> | 2023-01-03 19:06:31 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-01-06 12:02:20 +0100 |
commit | 43a10674d03a2dabea723787347354ef48e31197 (patch) | |
tree | 80c39a76802caac8770dd7968e6fbbafeda45714 /Userland/Applications/Terminal | |
parent | 8887766607c3632bcbef8efc819103c8d3502131 (diff) | |
download | serenity-43a10674d03a2dabea723787347354ef48e31197.zip |
Terminal: Add zoom in/out action to increment/decrement the font size
Diffstat (limited to 'Userland/Applications/Terminal')
-rw-r--r-- | Userland/Applications/Terminal/main.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/Userland/Applications/Terminal/main.cpp b/Userland/Applications/Terminal/main.cpp index 43a1b5f662..013fc2ef54 100644 --- a/Userland/Applications/Terminal/main.cpp +++ b/Userland/Applications/Terminal/main.cpp @@ -406,6 +406,25 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) }))); TRY(view_menu->try_add_action(terminal->clear_including_history_action())); + auto adjust_font_size = [&](float adjustment) { + auto& font = terminal->font(); + auto new_size = max(5, font.presentation_size() + adjustment); + if (auto new_font = Gfx::FontDatabase::the().get(font.family(), new_size, font.weight(), font.slope())) { + terminal->set_font_and_resize_to_fit(*new_font); + terminal->apply_size_increments_to_window(*window); + window->resize(terminal->size()); + } + + }; + + TRY(view_menu->try_add_separator()); + TRY(view_menu->try_add_action(GUI::CommonActions::make_zoom_in_action([&](auto&) { + adjust_font_size(1); + }))); + TRY(view_menu->try_add_action(GUI::CommonActions::make_zoom_out_action([&](auto&) { + adjust_font_size(-1); + }))); + auto help_menu = TRY(window->try_add_menu("&Help")); TRY(help_menu->try_add_action(GUI::CommonActions::make_command_palette_action(window))); TRY(help_menu->try_add_action(GUI::CommonActions::make_help_action([](auto&) { |