mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 07:08:10 +00:00
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.
This commit is contained in:
parent
1e5f4714c7
commit
1bcbc3f827
1 changed files with 14 additions and 0 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue