Skip to content

Commit

Permalink
Applications: TextEditor INI file syntax highlighter
Browse files Browse the repository at this point in the history
  • Loading branch information
asliturk authored and awesomekling committed May 1, 2020
1 parent 5c022ac commit 8551c10
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Applications/TextEditor/TextEditorWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include <LibGUI/CppSyntaxHighlighter.h>
#include <LibGUI/FilePicker.h>
#include <LibGUI/FontDatabase.h>
#include <LibGUI/INISyntaxHighlighter.h>
#include <LibGUI/JSSyntaxHighlighter.h>
#include <LibGUI/Menu.h>
#include <LibGUI/MenuBar.h>
Expand Down Expand Up @@ -429,6 +430,13 @@ TextEditorWidget::TextEditorWidget()
syntax_actions.add_action(*m_js_highlight);
syntax_menu.add_action(*m_js_highlight);

m_ini_highlight = GUI::Action::create_checkable("INI File", [&](auto&) {
m_editor->set_syntax_highlighter(make<GUI::IniSyntaxHighlighter>());
m_editor->update();
});
syntax_actions.add_action(*m_ini_highlight);
syntax_menu.add_action(*m_ini_highlight);

auto& help_menu = menubar->add_menu("Help");
help_menu.add_action(GUI::Action::create("About", [&](auto&) {
GUI::AboutDialog::show("Text Editor", Gfx::Bitmap::load_from_file("/res/icons/32x32/app-texteditor.png"), window());
Expand Down Expand Up @@ -467,6 +475,8 @@ void TextEditorWidget::set_path(const FileSystemPath& file)
m_cpp_highlight->activate();
} else if (m_extension == "js") {
m_js_highlight->activate();
} else if (m_extension == "ini") {
m_ini_highlight->activate();
} else {
m_plain_text_highlight->activate();
}
Expand Down
1 change: 1 addition & 0 deletions Applications/TextEditor/TextEditorWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class TextEditorWidget final : public GUI::Widget {
RefPtr<GUI::Action> m_plain_text_highlight;
RefPtr<GUI::Action> m_cpp_highlight;
RefPtr<GUI::Action> m_js_highlight;
RefPtr<GUI::Action> m_ini_highlight;

RefPtr<Web::HtmlView> m_html_view;

Expand Down

0 comments on commit 8551c10

Please sign in to comment.