diff options
author | 2023-09-18 19:07:41 +0200 | |
---|---|---|
committer | 2023-09-18 19:07:41 +0200 | |
commit | e7326f0af6f16cf2ff04fbac93bf296a044923f4 (patch) | |
tree | 05a309b7faf7a8b6f8c609c128dffa996660f1e4 /graphics | |
parent | 8446fe6de52fa68077d23d39f728f79a29b52f00 (diff) | |
download | iced-e7326f0af6f16cf2ff04fbac93bf296a044923f4.tar.gz iced-e7326f0af6f16cf2ff04fbac93bf296a044923f4.tar.bz2 iced-e7326f0af6f16cf2ff04fbac93bf296a044923f4.zip |
Flesh out the `editor` example a bit more
Diffstat (limited to 'graphics')
-rw-r--r-- | graphics/src/text/editor.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/graphics/src/text/editor.rs b/graphics/src/text/editor.rs index 4673fce3..dfb91f34 100644 --- a/graphics/src/text/editor.rs +++ b/graphics/src/text/editor.rs @@ -221,6 +221,12 @@ impl editor::Editor for Editor { } } + fn cursor_position(&self) -> (usize, usize) { + let cursor = self.internal().editor.cursor(); + + (cursor.line, cursor.index) + } + fn perform(&mut self, action: Action) { let mut font_system = text::font_system().write().expect("Write font system"); @@ -559,7 +565,7 @@ impl editor::Editor for Editor { Some(i) } }) - .unwrap_or(buffer.lines.len()); + .unwrap_or(buffer.lines.len().saturating_sub(1)); let current_line = highlighter.current_line(); |