Editor: add SoftHome action to skip blank space
This commit is contained in:
parent
c6e4f9d04c
commit
4adcbf6784
2 changed files with 13 additions and 0 deletions
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue