diff --git a/Applications/TextEditor/Makefile b/Applications/TextEditor/Makefile index 10d87dff0a5..051788ffa6e 100755 --- a/Applications/TextEditor/Makefile +++ b/Applications/TextEditor/Makefile @@ -4,6 +4,6 @@ OBJS = \ PROGRAM = TextEditor -LIB_DEPS = GUI Gfx VT IPC Thread Pthread Core +LIB_DEPS = GUI Gfx VT IPC Thread Pthread Core JS include ../../Makefile.common diff --git a/Applications/TextEditor/TextEditorWidget.cpp b/Applications/TextEditor/TextEditorWidget.cpp index 663a484dfb9..8fac10bf2f7 100644 --- a/Applications/TextEditor/TextEditorWidget.cpp +++ b/Applications/TextEditor/TextEditorWidget.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -402,6 +403,15 @@ TextEditorWidget::TextEditorWidget() syntax_actions.add_action(*m_cpp_highlight); syntax_menu->add_action(*m_cpp_highlight); + m_js_highlight = GUI::Action::create("Javascript", [&](GUI::Action& action) { + action.set_checked(true); + m_editor->set_syntax_highlighter(make()); + m_editor->update(); + }); + m_js_highlight->set_checkable(true); + syntax_actions.add_action(*m_js_highlight); + syntax_menu->add_action(*m_js_highlight); + auto view_menu = GUI::Menu::construct("View"); view_menu->add_action(*m_line_wrapping_setting_action); view_menu->add_separator(); @@ -446,6 +456,8 @@ void TextEditorWidget::set_path(const FileSystemPath& file) if (m_extension == "cpp" || m_extension == "h") m_cpp_highlight->activate(); + else if (m_extension == "js") + m_js_highlight->activate(); else m_plain_text_highlight->activate(); diff --git a/Applications/TextEditor/TextEditorWidget.h b/Applications/TextEditor/TextEditorWidget.h index 66a4d4edc0f..89e22f48bdc 100644 --- a/Applications/TextEditor/TextEditorWidget.h +++ b/Applications/TextEditor/TextEditorWidget.h @@ -82,6 +82,7 @@ private: GUI::ActionGroup syntax_actions; RefPtr m_plain_text_highlight; RefPtr m_cpp_highlight; + RefPtr m_js_highlight; bool m_document_dirty { false }; bool m_document_opening { false };