summaryrefslogtreecommitdiff
path: root/Applications
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2020-08-11 15:32:35 +0200
committerAndreas Kling <kling@serenityos.org>2020-08-11 15:45:02 +0200
commitfaab8a82cb0b9ae2c15b55f4174561474b71b1b3 (patch)
tree3ae3a3b85498f4af40e0b6c9480bf5769d26937c /Applications
parent1353edd0907bea2b6a087ced1fb5c05eea9e2d1b (diff)
downloadserenity-faab8a82cb0b9ae2c15b55f4174561474b71b1b3.zip
TextEditor: Show pageview URLs in statusbar on hover
Diffstat (limited to 'Applications')
-rw-r--r--Applications/TextEditor/TextEditorWidget.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/Applications/TextEditor/TextEditorWidget.cpp b/Applications/TextEditor/TextEditorWidget.cpp
index 84e1420623..3847685388 100644
--- a/Applications/TextEditor/TextEditorWidget.cpp
+++ b/Applications/TextEditor/TextEditorWidget.cpp
@@ -86,8 +86,20 @@ TextEditorWidget::TextEditorWidget()
update_title();
};
+ auto update_statusbar_cursor_position = [this] {
+ StringBuilder builder;
+ builder.appendf("Line: %d, Column: %d", m_editor->cursor().line() + 1, m_editor->cursor().column());
+ m_statusbar->set_text(builder.to_string());
+ };
+
m_page_view = splitter.add<Web::PageView>();
m_page_view->set_visible(false);
+ m_page_view->on_link_hover = [this, update_statusbar_cursor_position = move(update_statusbar_cursor_position)](auto& url) {
+ if (url.is_valid())
+ m_statusbar->set_text(url.to_string());
+ else
+ update_statusbar_cursor_position();
+ };
m_page_view->on_link_click = [&](auto& url, auto&, unsigned) {
if (!Desktop::Launcher::open(url)) {
GUI::MessageBox::show(
@@ -288,10 +300,8 @@ TextEditorWidget::TextEditorWidget()
m_statusbar = add<GUI::StatusBar>();
- m_editor->on_cursor_change = [this] {
- StringBuilder builder;
- builder.appendf("Line: %d, Column: %d", m_editor->cursor().line() + 1, m_editor->cursor().column());
- m_statusbar->set_text(builder.to_string());
+ m_editor->on_cursor_change = [update_statusbar_cursor_position = move(update_statusbar_cursor_position)] {
+ update_statusbar_cursor_position();
};
m_new_action = GUI::Action::create("New", { Mod_Ctrl, Key_N }, Gfx::Bitmap::load_from_file("/res/icons/16x16/new.png"), [this](const GUI::Action&) {