TextEditor: Enable CMake syntax highlighting
This commit is contained in:
parent
9f9ea8ccb5
commit
ac824677b8
Notes:
sideshowbarker
2024-07-17 17:40:13 +09:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/SerenityOS/serenity/commit/ac824677b8 Pull-request: https://github.com/SerenityOS/serenity/pull/17668 Reviewed-by: https://github.com/ADKaster ✅
3 changed files with 13 additions and 1 deletions
|
@ -18,4 +18,4 @@ set(GENERATED_SOURCES
|
|||
)
|
||||
|
||||
serenity_app(TextEditor ICON app-text-editor)
|
||||
target_link_libraries(TextEditor PRIVATE LibCore LibWebView LibWeb LibMarkdown LibGfx LibGUI LibShell LibRegex LibDesktop LibCpp LibJS LibSQL LibSyntax LibFileSystemAccessClient LibConfig LibMain)
|
||||
target_link_libraries(TextEditor PRIVATE LibCore LibWebView LibWeb LibMarkdown LibGfx LibGUI LibShell LibRegex LibDesktop LibCpp LibCMake LibJS LibSQL LibSyntax LibFileSystemAccessClient LibConfig LibMain)
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <AK/StringBuilder.h>
|
||||
#include <AK/URL.h>
|
||||
#include <Applications/TextEditor/TextEditorWindowGML.h>
|
||||
#include <LibCMake/SyntaxHighlighter.h>
|
||||
#include <LibConfig/Client.h>
|
||||
#include <LibCore/Debounce.h>
|
||||
#include <LibCpp/SyntaxHighlighter.h>
|
||||
|
@ -615,6 +616,13 @@ void MainWidget::initialize_menubar(GUI::Window& window)
|
|||
syntax_actions.add_action(*m_cpp_highlight);
|
||||
syntax_menu.add_action(*m_cpp_highlight);
|
||||
|
||||
m_cmake_highlight = GUI::Action::create_checkable("C&Make", [&](auto&) {
|
||||
m_editor->set_syntax_highlighter(make<CMake::SyntaxHighlighter>());
|
||||
m_editor->update();
|
||||
});
|
||||
syntax_actions.add_action(*m_cmake_highlight);
|
||||
syntax_menu.add_action(*m_cmake_highlight);
|
||||
|
||||
m_js_highlight = GUI::Action::create_checkable("&JavaScript", [&](auto&) {
|
||||
m_editor->set_syntax_highlighter(make<JS::SyntaxHighlighter>());
|
||||
m_editor->update();
|
||||
|
@ -695,6 +703,7 @@ void MainWidget::initialize_menubar(GUI::Window& window)
|
|||
|
||||
m_syntax_statusbar_menu->add_action(*m_plain_text_highlight);
|
||||
m_syntax_statusbar_menu->add_action(*m_cpp_highlight);
|
||||
m_syntax_statusbar_menu->add_action(*m_cmake_highlight);
|
||||
m_syntax_statusbar_menu->add_action(*m_css_highlight);
|
||||
m_syntax_statusbar_menu->add_action(*m_git_highlight);
|
||||
m_syntax_statusbar_menu->add_action(*m_gml_highlight);
|
||||
|
@ -721,6 +730,8 @@ void MainWidget::set_path(StringView path)
|
|||
if (m_extension == "c" || m_extension == "cc" || m_extension == "cxx" || m_extension == "cpp" || m_extension == "c++"
|
||||
|| m_extension == "h" || m_extension == "hh" || m_extension == "hxx" || m_extension == "hpp" || m_extension == "h++") {
|
||||
m_cpp_highlight->activate();
|
||||
} else if (m_extension == "cmake" || (m_extension == "txt" && m_name == "CMakeLists")) {
|
||||
m_cmake_highlight->activate();
|
||||
} else if (m_extension == "js" || m_extension == "mjs" || m_extension == "json") {
|
||||
m_js_highlight->activate();
|
||||
} else if (m_name == "COMMIT_EDITMSG") {
|
||||
|
|
|
@ -127,6 +127,7 @@ private:
|
|||
|
||||
GUI::ActionGroup syntax_actions;
|
||||
RefPtr<GUI::Action> m_plain_text_highlight;
|
||||
RefPtr<GUI::Action> m_cmake_highlight;
|
||||
RefPtr<GUI::Action> m_cpp_highlight;
|
||||
RefPtr<GUI::Action> m_css_highlight;
|
||||
RefPtr<GUI::Action> m_js_highlight;
|
||||
|
|
Loading…
Add table
Reference in a new issue