Editor: add SoftHome action to skip blank space

This commit is contained in:
Jeremy Soller 2023-10-20 10:25:46 -06:00
parent c6e4f9d04c
commit 4adcbf6784
No known key found for this signature in database
GPG key ID: DCFCA852D3906975
2 changed files with 13 additions and 0 deletions

View file

@ -426,6 +426,17 @@ impl Edit for Editor {
self.set_layout_cursor(font_system, cursor);
self.cursor_x_opt = None;
}
Action::SoftHome => {
let line: &mut BufferLine = &mut self.buffer.lines[self.cursor.line];
self.cursor.index = line
.text()
.unicode_word_indices()
.map(|(i, _)| i)
.next()
.unwrap_or(0);
self.buffer.set_redraw(true);
self.cursor_x_opt = None;
}
Action::End => {
let mut cursor = self.buffer.layout_cursor(&self.cursor);
cursor.glyph = usize::max_value();

View file

@ -35,6 +35,8 @@ pub enum Action {
Down,
/// Move cursor to start of line
Home,
/// Move cursor to start of line, skipping whitespace
SoftHome,
/// Move cursor to end of line
End,
/// Move cursor to start of paragraph