diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-10-27 13:10:37 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-10-27 13:10:37 +0100 |
commit | 1bcbc3f827ede8e0e701b44b582e830a6a673c9a (patch) | |
tree | 92ebe571fbcafe5c81b60754e9e26480372cfa39 /DevTools | |
parent | 1e5f4714c7b9850d1d9a5d902309428f5f2120d8 (diff) | |
download | serenity-1bcbc3f827ede8e0e701b44b582e830a6a673c9a.zip |
HackStudio: Allow switching between the two editors with Ctrl+E :^)
This is very hackish and should be done differently, but the feature
feels pretty nice and does work for now.
Diffstat (limited to 'DevTools')
-rw-r--r-- | DevTools/HackStudio/main.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/DevTools/HackStudio/main.cpp b/DevTools/HackStudio/main.cpp index 54696cc157..dd306fa228 100644 --- a/DevTools/HackStudio/main.cpp +++ b/DevTools/HackStudio/main.cpp @@ -27,6 +27,7 @@ #include <stdio.h> #include <unistd.h> +NonnullRefPtrVector<EditorWrapper> g_all_editor_wrappers; RefPtr<EditorWrapper> g_current_editor_wrapper; String g_currently_open_file; @@ -38,6 +39,7 @@ void add_new_editor(GWidget& parent) { auto wrapper = EditorWrapper::construct(&parent); g_current_editor_wrapper = wrapper; + g_all_editor_wrappers.append(wrapper); } EditorWrapper& current_editor_wrapper() @@ -120,6 +122,18 @@ int main(int argc, char** argv) open_file(filename); }); + auto switch_to_next_editor = GAction::create("Switch to next editor", { Mod_Ctrl, Key_E }, [&](auto&) { + if (g_all_editor_wrappers.size() <= 1) + return; + // FIXME: This will only work correctly when there are 2 editors. Make it work for any editor count. + for (auto& wrapper : g_all_editor_wrappers) { + if (&wrapper == ¤t_editor_wrapper()) + continue; + wrapper.editor().set_focus(true); + return; + } + }); + auto save_action = GAction::create("Save", { Mod_Ctrl, Key_S }, GraphicsBitmap::load_from_file("/res/icons/16x16/save.png"), [&](auto&) { if (g_currently_open_file.is_empty()) return; |