1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 07:38:10 +00:00

TextEditor: Show action long texts in the status bar :^)

We now display a description of the currently hovered action in the
text editor application's status bar. This is pretty cool! :^)

This is currentl achieved via the hooks on GUI::Application. Longer
term we'll probably want to find a more flexible abstraction for this,
since not all applications will be as simple as TextEditor.
This commit is contained in:
Andreas Kling 2021-04-17 18:44:45 +02:00
parent 22ed6a70eb
commit e67f392576

View file

@ -58,6 +58,7 @@
#include <LibGUI/ToolbarContainer.h>
#include <LibGUI/VimEditingEngine.h>
#include <LibGfx/Font.h>
#include <LibGfx/Painter.h>
#include <LibJS/SyntaxHighlighter.h>
#include <LibMarkdown/Document.h>
#include <LibWeb/OutOfProcessWebView.h>
@ -274,6 +275,17 @@ TextEditorWidget::TextEditorWidget()
m_statusbar = *find_descendant_of_type_named<GUI::Statusbar>("statusbar");
GUI::Application::the()->on_action_enter = [this](GUI::Action& action) {
auto text = action.long_text();
if (text.is_empty())
text = Gfx::parse_ampersand_string(action.text());
m_statusbar->set_override_text(move(text));
};
GUI::Application::the()->on_action_leave = [this](GUI::Action&) {
m_statusbar->set_override_text({});
};
m_editor->on_cursor_change = [this] { update_statusbar(); };
m_editor->on_selection_change = [this] { update_statusbar(); };