diff options
author | brapru <brapru@pm.me> | 2021-08-28 21:54:15 -0400 |
---|---|---|
committer | Ali Mohammad Pur <Ali.mpfard@gmail.com> | 2021-09-19 20:28:09 +0430 |
commit | 7a673f5aa38bc9760dd486a0928e41aac394697d (patch) | |
tree | e94feffd228ce4b0f42114254b190625459b6a59 /Userland | |
parent | 697e6ccb89f7885b83ae6fbe194990865ec32e24 (diff) | |
download | serenity-7a673f5aa38bc9760dd486a0928e41aac394697d.zip |
LibVT: Keep track of the buffer postiion on mousedown events
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibVT/TerminalWidget.cpp | 8 | ||||
-rw-r--r-- | Userland/Libraries/LibVT/TerminalWidget.h | 1 |
2 files changed, 5 insertions, 4 deletions
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; }; } |