Terminal: Clear selection if we type behind/inside it

This commit is contained in:
rhin123 2019-08-25 00:01:47 -05:00 committed by Andreas Kling
parent 23b70d5c59
commit 280a9a2f34
Notes: sideshowbarker 2024-07-19 12:32:47 +09:00

View file

@ -172,6 +172,16 @@ void TerminalWidget::keydown_event(GKeyEvent& event)
if (event.alt())
write(m_ptm_fd, "\033", 1);
//Clear the selection if we type in/behind it
auto future_cursor_column = (event.key() == KeyCode::Key_Backspace) ? m_terminal.cursor_column() - 1 : m_terminal.cursor_column();
auto min_selection_row = min(m_selection_start.row(), m_selection_end.row());
auto max_selection_row = max(m_selection_start.row(), m_selection_end.row());
if (future_cursor_column <= max(m_selection_start.column(), m_selection_end.column()) && m_terminal.cursor_row() >= min_selection_row && m_terminal.cursor_row() <= max_selection_row) {
m_selection_end = {};
update();
}
write(m_ptm_fd, &ch, 1);
}
}