summaryrefslogtreecommitdiffstats
path: root/graphics
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2023-09-14 15:23:20 +0200
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2023-09-14 15:23:20 +0200
commit8cad1d682a306071f1f03bff4e70196adc946491 (patch)
treeba2081ad8555a8ce0d971f6d0e530b815e5e167f /graphics
parentf7d66899f1ae087a87be5d084ec1ee9a03dd4ecc (diff)
downloadiced-8cad1d682a306071f1f03bff4e70196adc946491.tar.gz
iced-8cad1d682a306071f1f03bff4e70196adc946491.tar.bz2
iced-8cad1d682a306071f1f03bff4e70196adc946491.zip
Implement `Action::SelectLine` in `text::Editor`
Diffstat (limited to 'graphics')
-rw-r--r--graphics/src/text/editor.rs19
1 files changed, 18 insertions, 1 deletions
diff --git a/graphics/src/text/editor.rs b/graphics/src/text/editor.rs
index 3fd2c4fe..8eec94c9 100644
--- a/graphics/src/text/editor.rs
+++ b/graphics/src/text/editor.rs
@@ -334,7 +334,24 @@ impl editor::Editor for Editor {
}
}
}
- Action::SelectLine => todo!(),
+ Action::SelectLine => {
+ let cursor = editor.cursor();
+
+ if let Some(line_length) = editor
+ .buffer()
+ .lines
+ .get(cursor.line)
+ .map(|line| line.text().len())
+ {
+ editor
+ .set_cursor(cosmic_text::Cursor { index: 0, ..cursor });
+
+ editor.set_select_opt(Some(cosmic_text::Cursor {
+ index: line_length,
+ ..cursor
+ }));
+ }
+ }
// Editing events
Action::Insert(c) => {