mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-20 19:45:12 +00:00
HackStudio+TextEditor: Add the Shell syntax highlighter
This commit is contained in:
parent
72b68221cc
commit
c1fc27cab2
Notes:
sideshowbarker
2024-07-19 02:07:21 +09:00
Author: https://github.com/alimpfard Commit: https://github.com/SerenityOS/serenity/commit/c1fc27cab27 Pull-request: https://github.com/SerenityOS/serenity/pull/3628
5 changed files with 14 additions and 2 deletions
|
@ -7,4 +7,4 @@ set(SOURCES
|
|||
)
|
||||
|
||||
serenity_bin(TextEditor)
|
||||
target_link_libraries(TextEditor LibWeb LibMarkdown LibGUI LibDesktop)
|
||||
target_link_libraries(TextEditor LibWeb LibMarkdown LibGUI LibShell LibDesktop)
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
#include <LibGUI/Menu.h>
|
||||
#include <LibGUI/MenuBar.h>
|
||||
#include <LibGUI/MessageBox.h>
|
||||
#include <LibGUI/ShellSyntaxHighlighter.h>
|
||||
#include <LibGUI/Splitter.h>
|
||||
#include <LibGUI/StatusBar.h>
|
||||
#include <LibGUI/TextBox.h>
|
||||
|
@ -438,6 +439,13 @@ TextEditorWidget::TextEditorWidget()
|
|||
syntax_actions.add_action(*m_ini_highlight);
|
||||
syntax_menu.add_action(*m_ini_highlight);
|
||||
|
||||
m_shell_highlight = GUI::Action::create_checkable("Shell File", [&](auto&) {
|
||||
m_editor->set_syntax_highlighter(make<GUI::ShellSyntaxHighlighter>());
|
||||
m_editor->update();
|
||||
});
|
||||
syntax_actions.add_action(*m_shell_highlight);
|
||||
syntax_menu.add_action(*m_shell_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-text-editor.png"), window());
|
||||
|
|
|
@ -104,6 +104,7 @@ private:
|
|||
RefPtr<GUI::Action> m_cpp_highlight;
|
||||
RefPtr<GUI::Action> m_js_highlight;
|
||||
RefPtr<GUI::Action> m_ini_highlight;
|
||||
RefPtr<GUI::Action> m_shell_highlight;
|
||||
|
||||
RefPtr<Web::InProcessWebView> m_page_view;
|
||||
|
||||
|
|
|
@ -32,4 +32,4 @@ set(SOURCES
|
|||
)
|
||||
|
||||
serenity_bin(HackStudio)
|
||||
target_link_libraries(HackStudio LibWeb LibMarkdown LibGUI LibGfx LibCore LibVT LibDebug LibX86 LibDiff)
|
||||
target_link_libraries(HackStudio LibWeb LibMarkdown LibGUI LibGfx LibCore LibVT LibDebug LibX86 LibDiff LibShell)
|
||||
|
|
|
@ -66,6 +66,7 @@
|
|||
#include <LibGUI/Menu.h>
|
||||
#include <LibGUI/MenuBar.h>
|
||||
#include <LibGUI/MessageBox.h>
|
||||
#include <LibGUI/ShellSyntaxHighlighter.h>
|
||||
#include <LibGUI/Splitter.h>
|
||||
#include <LibGUI/StackWidget.h>
|
||||
#include <LibGUI/TabWidget.h>
|
||||
|
@ -216,6 +217,8 @@ void HackStudioWidget::open_file(const String& filename)
|
|||
current_editor().set_syntax_highlighter(make<GUI::JSSyntaxHighlighter>());
|
||||
else if (filename.ends_with(".ini"))
|
||||
current_editor().set_syntax_highlighter(make<GUI::IniSyntaxHighlighter>());
|
||||
else if (filename.ends_with(".sh"))
|
||||
current_editor().set_syntax_highlighter(make<GUI::ShellSyntaxHighlighter>());
|
||||
else
|
||||
current_editor().set_syntax_highlighter(nullptr);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue