mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:17:34 +00: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
2 changed files with 18 additions and 2 deletions
|
@ -469,6 +469,8 @@ VT::Position TerminalWidget::buffer_position_at(const Point& position) const
|
||||||
void TerminalWidget::doubleclick_event(GMouseEvent& event)
|
void TerminalWidget::doubleclick_event(GMouseEvent& event)
|
||||||
{
|
{
|
||||||
if (event.button() == GMouseButton::Left) {
|
if (event.button() == GMouseButton::Left) {
|
||||||
|
m_triple_click_timer.start();
|
||||||
|
|
||||||
auto position = buffer_position_at(event.position());
|
auto position = buffer_position_at(event.position());
|
||||||
auto& line = m_terminal.line(position.row());
|
auto& line = m_terminal.line(position.row());
|
||||||
bool want_whitespace = line.characters[position.column()] == ' ';
|
bool want_whitespace = line.characters[position.column()] == ' ';
|
||||||
|
@ -496,8 +498,20 @@ void TerminalWidget::doubleclick_event(GMouseEvent& event)
|
||||||
void TerminalWidget::mousedown_event(GMouseEvent& event)
|
void TerminalWidget::mousedown_event(GMouseEvent& event)
|
||||||
{
|
{
|
||||||
if (event.button() == GMouseButton::Left) {
|
if (event.button() == GMouseButton::Left) {
|
||||||
m_selection_start = buffer_position_at(event.position());
|
if (m_triple_click_timer.is_valid() && m_triple_click_timer.elapsed() < 250) {
|
||||||
m_selection_end = {};
|
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();
|
update();
|
||||||
} else if (event.button() == GMouseButton::Right) {
|
} else if (event.button() == GMouseButton::Right) {
|
||||||
if (m_ptm_fd == -1)
|
if (m_ptm_fd == -1)
|
||||||
|
|
|
@ -118,4 +118,6 @@ private:
|
||||||
RefPtr<CConfigFile> m_config;
|
RefPtr<CConfigFile> m_config;
|
||||||
|
|
||||||
RefPtr<GScrollBar> m_scrollbar;
|
RefPtr<GScrollBar> m_scrollbar;
|
||||||
|
|
||||||
|
CElapsedTimer m_triple_click_timer;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue