diff options
author | Dylan Katz <dykatz@uw.edu> | 2021-05-08 18:30:44 -0700 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-05-09 09:39:05 +0200 |
commit | 3ab37674c615eea5ed8ba5926db543004ff312c2 (patch) | |
tree | 6b7b42b83875012e5a39b300adf1dbe195b5b34b /Userland/Applications | |
parent | 984b6e08cf4e877a1c043cd8ab144559213394dd (diff) | |
download | serenity-3ab37674c615eea5ed8ba5926db543004ff312c2.zip |
TextEditor: Add support for SQL highlighting
Diffstat (limited to 'Userland/Applications')
-rw-r--r-- | Userland/Applications/TextEditor/CMakeLists.txt | 2 | ||||
-rw-r--r-- | Userland/Applications/TextEditor/MainWidget.cpp | 10 | ||||
-rw-r--r-- | Userland/Applications/TextEditor/MainWidget.h | 1 |
3 files changed, 12 insertions, 1 deletions
diff --git a/Userland/Applications/TextEditor/CMakeLists.txt b/Userland/Applications/TextEditor/CMakeLists.txt index 33f0934ac6..25a0dd3fb8 100644 --- a/Userland/Applications/TextEditor/CMakeLists.txt +++ b/Userland/Applications/TextEditor/CMakeLists.txt @@ -8,4 +8,4 @@ set(SOURCES ) serenity_app(TextEditor ICON app-text-editor) -target_link_libraries(TextEditor LibWeb LibMarkdown LibGUI LibShell LibRegex LibDesktop LibCpp LibJS) +target_link_libraries(TextEditor LibWeb LibMarkdown LibGUI LibShell LibRegex LibDesktop LibCpp LibJS LibSQL) diff --git a/Userland/Applications/TextEditor/MainWidget.cpp b/Userland/Applications/TextEditor/MainWidget.cpp index 7cdf0c8879..a849af2ba5 100644 --- a/Userland/Applications/TextEditor/MainWidget.cpp +++ b/Userland/Applications/TextEditor/MainWidget.cpp @@ -38,6 +38,7 @@ #include <LibGfx/Painter.h> #include <LibJS/SyntaxHighlighter.h> #include <LibMarkdown/Document.h> +#include <LibSQL/SyntaxHighlighter.h> #include <LibWeb/OutOfProcessWebView.h> #include <Shell/SyntaxHighlighter.h> @@ -570,6 +571,13 @@ void MainWidget::initialize_menubar(GUI::Menubar& menubar) syntax_actions.add_action(*m_shell_highlight); syntax_menu.add_action(*m_shell_highlight); + m_sql_highlight = GUI::Action::create_checkable("S&QL File", [&](auto&) { + m_editor->set_syntax_highlighter(make<SQL::SyntaxHighlighter>()); + m_editor->update(); + }); + syntax_actions.add_action(*m_sql_highlight); + syntax_menu.add_action(*m_sql_highlight); + auto& help_menu = menubar.add_menu("&Help"); help_menu.add_action(GUI::CommonActions::make_help_action([](auto&) { Desktop::Launcher::open(URL::create_with_file_protocol("/usr/share/man/man1/TextEditor.md"), "/bin/Help"); @@ -591,6 +599,8 @@ void MainWidget::set_path(const LexicalPath& lexical_path) m_gml_highlight->activate(); } else if (m_extension == "ini") { m_ini_highlight->activate(); + } else if (m_extension == "sql") { + m_sql_highlight->activate(); } else { m_plain_text_highlight->activate(); } diff --git a/Userland/Applications/TextEditor/MainWidget.h b/Userland/Applications/TextEditor/MainWidget.h index 9c9e309eab..dc19f487b9 100644 --- a/Userland/Applications/TextEditor/MainWidget.h +++ b/Userland/Applications/TextEditor/MainWidget.h @@ -114,6 +114,7 @@ private: RefPtr<GUI::Action> m_gml_highlight; RefPtr<GUI::Action> m_ini_highlight; RefPtr<GUI::Action> m_shell_highlight; + RefPtr<GUI::Action> m_sql_highlight; RefPtr<Web::OutOfProcessWebView> m_page_view; RefPtr<Core::ConfigFile> m_config; |