mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 05:08:13 +00:00
TextEditor+EditingEngine: Add support for the basics of Vim emulation
This commit is contained in:
parent
1c17ecdeb7
commit
b4a783d923
13 changed files with 1143 additions and 438 deletions
|
@ -47,6 +47,7 @@
|
|||
#include <LibGUI/Menu.h>
|
||||
#include <LibGUI/MenuBar.h>
|
||||
#include <LibGUI/MessageBox.h>
|
||||
#include <LibGUI/RegularEditingEngine.h>
|
||||
#include <LibGUI/ShellSyntaxHighlighter.h>
|
||||
#include <LibGUI/Splitter.h>
|
||||
#include <LibGUI/StatusBar.h>
|
||||
|
@ -54,6 +55,7 @@
|
|||
#include <LibGUI/TextEditor.h>
|
||||
#include <LibGUI/ToolBar.h>
|
||||
#include <LibGUI/ToolBarContainer.h>
|
||||
#include <LibGUI/VimEditingEngine.h>
|
||||
#include <LibGfx/Font.h>
|
||||
#include <LibMarkdown/Document.h>
|
||||
#include <LibWeb/OutOfProcessWebView.h>
|
||||
|
@ -69,6 +71,7 @@ TextEditorWidget::TextEditorWidget()
|
|||
m_editor->set_ruler_visible(true);
|
||||
m_editor->set_automatic_indentation_enabled(true);
|
||||
m_editor->set_line_wrapping_enabled(true);
|
||||
m_editor->set_editing_engine(make<GUI::RegularEditingEngine>());
|
||||
|
||||
m_editor->on_change = [this] {
|
||||
update_preview();
|
||||
|
@ -271,6 +274,14 @@ TextEditorWidget::TextEditorWidget()
|
|||
m_editor->set_focus(true);
|
||||
};
|
||||
|
||||
m_vim_emulation_setting_action = GUI::Action::create_checkable("Vim emulation", { Mod_Ctrl | Mod_Shift | Mod_Alt, Key_V }, [&](auto& action) {
|
||||
if (action.is_checked())
|
||||
m_editor->set_editing_engine(make<GUI::VimEditingEngine>());
|
||||
else
|
||||
m_editor->set_editing_engine(make<GUI::RegularEditingEngine>());
|
||||
});
|
||||
m_vim_emulation_setting_action->set_checked(false);
|
||||
|
||||
m_find_replace_action = GUI::Action::create("Find/Replace...", { Mod_Ctrl, Key_F }, Gfx::Bitmap::load_from_file("/res/icons/16x16/find.png"), [this](auto&) {
|
||||
m_find_replace_widget->set_visible(true);
|
||||
m_find_widget->set_visible(true);
|
||||
|
@ -380,6 +391,8 @@ TextEditorWidget::TextEditorWidget()
|
|||
edit_menu.add_action(m_editor->paste_action());
|
||||
edit_menu.add_action(m_editor->delete_action());
|
||||
edit_menu.add_separator();
|
||||
edit_menu.add_action(*m_vim_emulation_setting_action);
|
||||
edit_menu.add_separator();
|
||||
edit_menu.add_action(*m_find_replace_action);
|
||||
edit_menu.add_action(*m_find_next_action);
|
||||
edit_menu.add_action(*m_find_regex_action);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue