mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-08 20:32:56 +03:00
TextEditor: Add syntax-highlighting for CSS files
This commit is contained in:
parent
6f71516409
commit
d2690e551c
Notes:
sideshowbarker
2024-07-18 01:58:44 +09:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/SerenityOS/serenity/commit/d2690e551c3 Pull-request: https://github.com/SerenityOS/serenity/pull/10563 Reviewed-by: https://github.com/alimpfard ✅
@ -37,6 +37,7 @@
|
||||
#include <LibJS/SyntaxHighlighter.h>
|
||||
#include <LibMarkdown/Document.h>
|
||||
#include <LibSQL/AST/SyntaxHighlighter.h>
|
||||
#include <LibWeb/CSS/SyntaxHighlighter/SyntaxHighlighter.h>
|
||||
#include <LibWeb/HTML/SyntaxHighlighter/SyntaxHighlighter.h>
|
||||
#include <LibWeb/OutOfProcessWebView.h>
|
||||
#include <Shell/SyntaxHighlighter.h>
|
||||
@ -567,6 +568,13 @@ void MainWidget::initialize_menubar(GUI::Window& window)
|
||||
syntax_actions.add_action(*m_js_highlight);
|
||||
syntax_menu.add_action(*m_js_highlight);
|
||||
|
||||
m_css_highlight = GUI::Action::create_checkable("CSS", [&](auto&) {
|
||||
m_editor->set_syntax_highlighter(make<Web::CSS::SyntaxHighlighter>());
|
||||
m_editor->update();
|
||||
});
|
||||
syntax_actions.add_action(*m_css_highlight);
|
||||
syntax_menu.add_action(*m_css_highlight);
|
||||
|
||||
m_html_highlight = GUI::Action::create_checkable("&HTML File", [&](auto&) {
|
||||
m_editor->set_syntax_highlighter(make<Web::HTML::SyntaxHighlighter>());
|
||||
m_editor->update();
|
||||
@ -637,6 +645,8 @@ void MainWidget::set_path(StringView const& path)
|
||||
m_sql_highlight->activate();
|
||||
} else if (m_extension == "html" || m_extension == "htm") {
|
||||
m_html_highlight->activate();
|
||||
} else if (m_extension == "css") {
|
||||
m_css_highlight->activate();
|
||||
} else {
|
||||
m_plain_text_highlight->activate();
|
||||
}
|
||||
|
@ -116,6 +116,7 @@ private:
|
||||
GUI::ActionGroup syntax_actions;
|
||||
RefPtr<GUI::Action> m_plain_text_highlight;
|
||||
RefPtr<GUI::Action> m_cpp_highlight;
|
||||
RefPtr<GUI::Action> m_css_highlight;
|
||||
RefPtr<GUI::Action> m_js_highlight;
|
||||
RefPtr<GUI::Action> m_html_highlight;
|
||||
RefPtr<GUI::Action> m_gml_highlight;
|
||||
|
Loading…
Reference in New Issue
Block a user