From 7a673f5aa38bc9760dd486a0928e41aac394697d Mon Sep 17 00:00:00 2001 From: brapru Date: Sat, 28 Aug 2021 21:54:15 -0400 Subject: LibVT: Keep track of the buffer postiion on mousedown events --- Userland/Libraries/LibVT/TerminalWidget.cpp | 8 ++++---- Userland/Libraries/LibVT/TerminalWidget.h | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'Userland') diff --git a/Userland/Libraries/LibVT/TerminalWidget.cpp b/Userland/Libraries/LibVT/TerminalWidget.cpp index bd49eadf2f..db0c57770a 100644 --- a/Userland/Libraries/LibVT/TerminalWidget.cpp +++ b/Userland/Libraries/LibVT/TerminalWidget.cpp @@ -783,8 +783,9 @@ void TerminalWidget::mousedown_event(GUI::MouseEvent& event) { if (event.button() == GUI::MouseButton::Left) { m_left_mousedown_position = event.position(); + m_left_mousedown_position_buffer = buffer_position_at(m_left_mousedown_position); - auto attribute = m_terminal.attribute_at(buffer_position_at(event.position())); + auto attribute = m_terminal.attribute_at(m_left_mousedown_position_buffer); if (!(event.modifiers() & Mod_Shift) && !attribute.href.is_empty()) { m_active_href = attribute.href; m_active_href_id = attribute.href_id; @@ -798,10 +799,9 @@ void TerminalWidget::mousedown_event(GUI::MouseEvent& event) int start_column = 0; int end_column = m_terminal.columns() - 1; - auto position = buffer_position_at(event.position()); - m_selection.set({ position.row(), start_column }, { position.row(), end_column }); + m_selection.set({ m_left_mousedown_position_buffer.row(), start_column }, { m_left_mousedown_position_buffer.row(), end_column }); } else { - m_selection.set(buffer_position_at(event.position()), {}); + m_selection.set(m_left_mousedown_position_buffer, {}); } if (m_alt_key_held) m_rectangle_selection = true; diff --git a/Userland/Libraries/LibVT/TerminalWidget.h b/Userland/Libraries/LibVT/TerminalWidget.h index 906b7c0326..d1e5c9680f 100644 --- a/Userland/Libraries/LibVT/TerminalWidget.h +++ b/Userland/Libraries/LibVT/TerminalWidget.h @@ -218,6 +218,7 @@ private: Core::ElapsedTimer m_triple_click_timer; Gfx::IntPoint m_left_mousedown_position; + VT::Position m_left_mousedown_position_buffer; }; } -- cgit v1.2.3