mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 03:55:24 +00:00
GTextEditor: Backspace over soft tabs
This makes the backspace erase backwards until the next soft tab stop. We currently always use 4 as the soft tab width, but I suppose we could make it configurable at some point. :^)
This commit is contained in:
parent
98e556fee9
commit
8fa466e496
Notes:
sideshowbarker
2024-07-19 11:31:28 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/8fa466e4965
1 changed files with 14 additions and 2 deletions
|
@ -622,10 +622,22 @@ void GTextEditor::keydown_event(GKeyEvent& event)
|
|||
return;
|
||||
}
|
||||
if (m_cursor.column() > 0) {
|
||||
int erase_count = 1;
|
||||
if (current_line().first_non_whitespace_column() >= m_cursor.column()) {
|
||||
int new_column;
|
||||
if (m_cursor.column() % m_soft_tab_width == 0)
|
||||
new_column = m_cursor.column() - m_soft_tab_width;
|
||||
else
|
||||
new_column = (m_cursor.column() / m_soft_tab_width) * m_soft_tab_width;
|
||||
erase_count = m_cursor.column() - new_column;
|
||||
}
|
||||
|
||||
// Backspace within line
|
||||
current_line().remove(m_cursor.column() - 1);
|
||||
for (int i = 0; i < erase_count; ++i) {
|
||||
current_line().remove(m_cursor.column() - 1 - i);
|
||||
}
|
||||
update_content_size();
|
||||
set_cursor(m_cursor.line(), m_cursor.column() - 1);
|
||||
set_cursor(m_cursor.line(), m_cursor.column() - erase_count);
|
||||
did_change();
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue