|
38 | 38 | #include <LibGUI/CppSyntaxHighlighter.h>
|
39 | 39 | #include <LibGUI/FilePicker.h>
|
40 | 40 | #include <LibGUI/FontDatabase.h>
|
| 41 | +#include <LibGUI/JSSyntaxHighlighter.h> |
41 | 42 | #include <LibGUI/Menu.h>
|
42 | 43 | #include <LibGUI/MenuBar.h>
|
43 | 44 | #include <LibGUI/MessageBox.h>
|
@@ -402,6 +403,15 @@ TextEditorWidget::TextEditorWidget()
|
402 | 403 | syntax_actions.add_action(*m_cpp_highlight);
|
403 | 404 | syntax_menu->add_action(*m_cpp_highlight);
|
404 | 405 |
|
| 406 | + m_js_highlight = GUI::Action::create("Javascript", [&](GUI::Action& action) { |
| 407 | + action.set_checked(true); |
| 408 | + m_editor->set_syntax_highlighter(make<GUI::JSSyntaxHighlighter>()); |
| 409 | + m_editor->update(); |
| 410 | + }); |
| 411 | + m_js_highlight->set_checkable(true); |
| 412 | + syntax_actions.add_action(*m_js_highlight); |
| 413 | + syntax_menu->add_action(*m_js_highlight); |
| 414 | + |
405 | 415 | auto view_menu = GUI::Menu::construct("View");
|
406 | 416 | view_menu->add_action(*m_line_wrapping_setting_action);
|
407 | 417 | view_menu->add_separator();
|
@@ -446,6 +456,8 @@ void TextEditorWidget::set_path(const FileSystemPath& file)
|
446 | 456 |
|
447 | 457 | if (m_extension == "cpp" || m_extension == "h")
|
448 | 458 | m_cpp_highlight->activate();
|
| 459 | + else if (m_extension == "js") |
| 460 | + m_js_highlight->activate(); |
449 | 461 | else
|
450 | 462 | m_plain_text_highlight->activate();
|
451 | 463 |
|
|
0 commit comments