summaryrefslogtreecommitdiff
path: root/Libraries
diff options
context:
space:
mode:
authorRok Povsic <rok.povsic@gmail.com>2019-11-15 23:48:58 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-11-15 23:58:06 +0100
commit95df04907131ca6410c89e01b1332133faaac558 (patch)
tree5f74cd0a50fe6c803c7088fb3fe6e82099c4f788 /Libraries
parente17386692af62bae402e16f56028895a627bc7cb (diff)
downloadserenity-95df04907131ca6410c89e01b1332133faaac558.zip
Terminal: Add selecting whole line on triple click
The line is also added to clipboard
Diffstat (limited to 'Libraries')
-rw-r--r--Libraries/LibVT/TerminalWidget.cpp18
-rw-r--r--Libraries/LibVT/TerminalWidget.h2
2 files changed, 18 insertions, 2 deletions
diff --git a/Libraries/LibVT/TerminalWidget.cpp b/Libraries/LibVT/TerminalWidget.cpp
index b3f937ca04..438ceb4ca9 100644
--- a/Libraries/LibVT/TerminalWidget.cpp
+++ b/Libraries/LibVT/TerminalWidget.cpp
@@ -469,6 +469,8 @@ VT::Position TerminalWidget::buffer_position_at(const Point& position) const
void TerminalWidget::doubleclick_event(GMouseEvent& event)
{
if (event.button() == GMouseButton::Left) {
+ m_triple_click_timer.start();
+
auto position = buffer_position_at(event.position());
auto& line = m_terminal.line(position.row());
bool want_whitespace = line.characters[position.column()] == ' ';
@@ -496,8 +498,20 @@ void TerminalWidget::doubleclick_event(GMouseEvent& event)
void TerminalWidget::mousedown_event(GMouseEvent& event)
{
if (event.button() == GMouseButton::Left) {
- m_selection_start = buffer_position_at(event.position());
- m_selection_end = {};
+ if (m_triple_click_timer.is_valid() && m_triple_click_timer.elapsed() < 250) {
+ int start_column = 0;
+ int end_column = m_terminal.columns() - 1;
+
+ auto position = buffer_position_at(event.position());
+ m_selection_start = { position.row(), start_column };
+ m_selection_end = { position.row(), end_column };
+
+ if (has_selection())
+ GClipboard::the().set_data(selected_text());
+ } else {
+ m_selection_start = buffer_position_at(event.position());
+ m_selection_end = {};
+ }
update();
} else if (event.button() == GMouseButton::Right) {
if (m_ptm_fd == -1)
diff --git a/Libraries/LibVT/TerminalWidget.h b/Libraries/LibVT/TerminalWidget.h
index 829c98158a..8c06844840 100644
--- a/Libraries/LibVT/TerminalWidget.h
+++ b/Libraries/LibVT/TerminalWidget.h
@@ -118,4 +118,6 @@ private:
RefPtr<CConfigFile> m_config;
RefPtr<GScrollBar> m_scrollbar;
+
+ CElapsedTimer m_triple_click_timer;
};