mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 21:17:44 +00:00
Terminal: Clear selection if we type behind/inside it
This commit is contained in:
parent
23b70d5c59
commit
280a9a2f34
1 changed files with 10 additions and 0 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue