mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 07:17:35 +00:00
TextEditor+Browser: Enable HTML syntax highlighting on HTML documents
This commit is contained in:
parent
97a230e4ef
commit
dc388297eb
3 changed files with 13 additions and 0 deletions
|
@ -25,6 +25,7 @@
|
||||||
#include <LibGUI/ToolbarContainer.h>
|
#include <LibGUI/ToolbarContainer.h>
|
||||||
#include <LibGUI/Window.h>
|
#include <LibGUI/Window.h>
|
||||||
#include <LibJS/Interpreter.h>
|
#include <LibJS/Interpreter.h>
|
||||||
|
#include <LibWeb/HTML/SyntaxHighlighter/SyntaxHighlighter.h>
|
||||||
#include <LibWeb/InProcessWebView.h>
|
#include <LibWeb/InProcessWebView.h>
|
||||||
#include <LibWeb/Layout/BlockBox.h>
|
#include <LibWeb/Layout/BlockBox.h>
|
||||||
#include <LibWeb/Layout/InitialContainingBlockBox.h>
|
#include <LibWeb/Layout/InitialContainingBlockBox.h>
|
||||||
|
@ -69,6 +70,7 @@ void Tab::view_source(const URL& url, const String& source)
|
||||||
auto& editor = window->set_main_widget<GUI::TextEditor>();
|
auto& editor = window->set_main_widget<GUI::TextEditor>();
|
||||||
editor.set_text(source);
|
editor.set_text(source);
|
||||||
editor.set_mode(GUI::TextEditor::ReadOnly);
|
editor.set_mode(GUI::TextEditor::ReadOnly);
|
||||||
|
editor.set_syntax_highlighter(make<Web::HTML::SyntaxHighlighter>());
|
||||||
editor.set_ruler_visible(true);
|
editor.set_ruler_visible(true);
|
||||||
window->resize(640, 480);
|
window->resize(640, 480);
|
||||||
window->set_title(url.to_string());
|
window->set_title(url.to_string());
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
#include <LibJS/SyntaxHighlighter.h>
|
#include <LibJS/SyntaxHighlighter.h>
|
||||||
#include <LibMarkdown/Document.h>
|
#include <LibMarkdown/Document.h>
|
||||||
#include <LibSQL/SyntaxHighlighter.h>
|
#include <LibSQL/SyntaxHighlighter.h>
|
||||||
|
#include <LibWeb/HTML/SyntaxHighlighter/SyntaxHighlighter.h>
|
||||||
#include <LibWeb/OutOfProcessWebView.h>
|
#include <LibWeb/OutOfProcessWebView.h>
|
||||||
#include <Shell/SyntaxHighlighter.h>
|
#include <Shell/SyntaxHighlighter.h>
|
||||||
|
|
||||||
|
@ -547,6 +548,13 @@ void MainWidget::initialize_menubar(GUI::Menubar& menubar)
|
||||||
syntax_actions.add_action(*m_js_highlight);
|
syntax_actions.add_action(*m_js_highlight);
|
||||||
syntax_menu.add_action(*m_js_highlight);
|
syntax_menu.add_action(*m_js_highlight);
|
||||||
|
|
||||||
|
m_html_highlight = GUI::Action::create_checkable("&HTML File", [&](auto&) {
|
||||||
|
m_editor->set_syntax_highlighter(make<Web::HTML::SyntaxHighlighter>());
|
||||||
|
m_editor->update();
|
||||||
|
});
|
||||||
|
syntax_actions.add_action(*m_html_highlight);
|
||||||
|
syntax_menu.add_action(*m_html_highlight);
|
||||||
|
|
||||||
m_gml_highlight = GUI::Action::create_checkable("&GML", [&](auto&) {
|
m_gml_highlight = GUI::Action::create_checkable("&GML", [&](auto&) {
|
||||||
m_editor->set_syntax_highlighter(make<GUI::GMLSyntaxHighlighter>());
|
m_editor->set_syntax_highlighter(make<GUI::GMLSyntaxHighlighter>());
|
||||||
m_editor->update();
|
m_editor->update();
|
||||||
|
@ -598,6 +606,8 @@ void MainWidget::set_path(const LexicalPath& lexical_path)
|
||||||
m_ini_highlight->activate();
|
m_ini_highlight->activate();
|
||||||
} else if (m_extension == "sql") {
|
} else if (m_extension == "sql") {
|
||||||
m_sql_highlight->activate();
|
m_sql_highlight->activate();
|
||||||
|
} else if (m_extension == "html") {
|
||||||
|
m_html_highlight->activate();
|
||||||
} else {
|
} else {
|
||||||
m_plain_text_highlight->activate();
|
m_plain_text_highlight->activate();
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,6 +111,7 @@ private:
|
||||||
RefPtr<GUI::Action> m_plain_text_highlight;
|
RefPtr<GUI::Action> m_plain_text_highlight;
|
||||||
RefPtr<GUI::Action> m_cpp_highlight;
|
RefPtr<GUI::Action> m_cpp_highlight;
|
||||||
RefPtr<GUI::Action> m_js_highlight;
|
RefPtr<GUI::Action> m_js_highlight;
|
||||||
|
RefPtr<GUI::Action> m_html_highlight;
|
||||||
RefPtr<GUI::Action> m_gml_highlight;
|
RefPtr<GUI::Action> m_gml_highlight;
|
||||||
RefPtr<GUI::Action> m_ini_highlight;
|
RefPtr<GUI::Action> m_ini_highlight;
|
||||||
RefPtr<GUI::Action> m_shell_highlight;
|
RefPtr<GUI::Action> m_shell_highlight;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue