summaryrefslogtreecommitdiff
path: root/DevTools
diff options
context:
space:
mode:
authorRok Povsic <rok.povsic@gmail.com>2021-01-02 11:59:55 +0100
committerAndreas Kling <kling@serenityos.org>2021-01-05 00:00:36 +0100
commitb4a783d9231d1c0d8dcc24d5659c34443e2976ab (patch)
tree499228084fc4e36187a5df0e7e0e391456311929 /DevTools
parent1c17ecdeb72cf62f651385fa302d401a19541345 (diff)
downloadserenity-b4a783d9231d1c0d8dcc24d5659c34443e2976ab.zip
TextEditor+EditingEngine: Add support for the basics of Vim emulation
Diffstat (limited to 'DevTools')
-rw-r--r--DevTools/HackStudio/HackStudioWidget.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/DevTools/HackStudio/HackStudioWidget.cpp b/DevTools/HackStudio/HackStudioWidget.cpp
index dbfd208e1d..bf149391f6 100644
--- a/DevTools/HackStudio/HackStudioWidget.cpp
+++ b/DevTools/HackStudio/HackStudioWidget.cpp
@@ -56,6 +56,7 @@
#include <LibGUI/Application.h>
#include <LibGUI/BoxLayout.h>
#include <LibGUI/Button.h>
+#include <LibGUI/EditingEngine.h>
#include <LibGUI/FilePicker.h>
#include <LibGUI/InputBox.h>
#include <LibGUI/ItemListModel.h>
@@ -63,6 +64,7 @@
#include <LibGUI/Menu.h>
#include <LibGUI/MenuBar.h>
#include <LibGUI/MessageBox.h>
+#include <LibGUI/RegularEditingEngine.h>
#include <LibGUI/Splitter.h>
#include <LibGUI/StackWidget.h>
#include <LibGUI/TabWidget.h>
@@ -72,6 +74,7 @@
#include <LibGUI/ToolBar.h>
#include <LibGUI/ToolBarContainer.h>
#include <LibGUI/TreeView.h>
+#include <LibGUI/VimEditingEngine.h>
#include <LibGUI/Widget.h>
#include <LibGUI/Window.h>
#include <LibGfx/FontDatabase.h>
@@ -234,6 +237,7 @@ void HackStudioWidget::open_file(const String& filename)
current_editor().set_mode(GUI::TextEditor::Editable);
current_editor().horizontal_scrollbar().set_value(new_project_file->horizontal_scroll_value());
current_editor().vertical_scrollbar().set_value(new_project_file->vertical_scroll_value());
+ current_editor().set_editing_engine(make<GUI::RegularEditingEngine>());
if (filename.ends_with(".frm")) {
set_edit_mode(EditMode::Form);
@@ -854,6 +858,17 @@ void HackStudioWidget::create_edit_menubar(GUI::MenuBar& menubar)
});
line_wrapping_action->set_checked(current_editor().is_line_wrapping_enabled());
edit_menu.add_action(line_wrapping_action);
+
+ edit_menu.add_separator();
+
+ auto vim_emulation_setting_action = GUI::Action::create_checkable("Vim emulation", { Mod_Ctrl | Mod_Shift | Mod_Alt, Key_V }, [this](auto& action) {
+ if (action.is_checked())
+ current_editor().set_editing_engine(make<GUI::VimEditingEngine>());
+ else
+ current_editor().set_editing_engine(make<GUI::RegularEditingEngine>());
+ });
+ vim_emulation_setting_action->set_checked(false);
+ edit_menu.add_action(vim_emulation_setting_action);
}
void HackStudioWidget::create_build_menubar(GUI::MenuBar& menubar)