mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-20 17:58:18 +03:00
Terminal: Add selecting whole line on triple click
The line is also added to clipboard
This commit is contained in:
parent
e17386692a
commit
95df049071
Notes:
sideshowbarker
2024-07-19 11:12:41 +09:00
Author: https://github.com/rok-povsic Commit: https://github.com/SerenityOS/serenity/commit/95df0490713 Pull-request: https://github.com/SerenityOS/serenity/pull/787
@ -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)
|
||||
|
@ -118,4 +118,6 @@ private:
|
||||
RefPtr<CConfigFile> m_config;
|
||||
|
||||
RefPtr<GScrollBar> m_scrollbar;
|
||||
|
||||
CElapsedTimer m_triple_click_timer;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user