summaryrefslogtreecommitdiff
path: root/Userland/Applications
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2021-10-21 21:45:24 +0100
committerAndreas Kling <kling@serenityos.org>2021-10-23 19:07:44 +0200
commitd2690e551c39d3aa956b979d06c700c1c1826de3 (patch)
treeb32456ac70367a1700da4d7e9b29ab80ef4da1da /Userland/Applications
parent6f71516409a151b58e64678c613fffd9ae8acdaf (diff)
downloadserenity-d2690e551c39d3aa956b979d06c700c1c1826de3.zip
TextEditor: Add syntax-highlighting for CSS files
Diffstat (limited to 'Userland/Applications')
-rw-r--r--Userland/Applications/TextEditor/MainWidget.cpp10
-rw-r--r--Userland/Applications/TextEditor/MainWidget.h1
2 files changed, 11 insertions, 0 deletions
diff --git a/Userland/Applications/TextEditor/MainWidget.cpp b/Userland/Applications/TextEditor/MainWidget.cpp
index 31263affb8..76b638b755 100644
--- a/Userland/Applications/TextEditor/MainWidget.cpp
+++ b/Userland/Applications/TextEditor/MainWidget.cpp
@@ -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();
}
diff --git a/Userland/Applications/TextEditor/MainWidget.h b/Userland/Applications/TextEditor/MainWidget.h
index 925dda707c..9292ca3ebd 100644
--- a/Userland/Applications/TextEditor/MainWidget.h
+++ b/Userland/Applications/TextEditor/MainWidget.h
@@ -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;