mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 17:40:27 +00:00
Terminal: Clear selection if we type behind/inside it
This commit is contained in:
parent
23b70d5c59
commit
280a9a2f34
Notes:
sideshowbarker
2024-07-19 12:32:47 +09:00
Author: https://github.com/RyanGrieb Commit: https://github.com/SerenityOS/serenity/commit/280a9a2f34c Pull-request: https://github.com/SerenityOS/serenity/pull/483
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…
Reference in a new issue