diff options
author | 2023-09-16 16:27:02 +0200 | |
---|---|---|
committer | 2023-09-16 16:27:02 +0200 | |
commit | c9dbccba468da683af2513535c40374da804aa60 (patch) | |
tree | e3ab48f87adaba193806b3de9be5c50597ed584f /graphics | |
parent | d051f21597bb333ac10183aaa3214a292e9aa365 (diff) | |
download | iced-c9dbccba468da683af2513535c40374da804aa60.tar.gz iced-c9dbccba468da683af2513535c40374da804aa60.tar.bz2 iced-c9dbccba468da683af2513535c40374da804aa60.zip |
Use fork of `cosmic-text` with some minor fixes
Diffstat (limited to 'graphics')
-rw-r--r-- | graphics/src/text/editor.rs | 36 |
1 files changed, 1 insertions, 35 deletions
diff --git a/graphics/src/text/editor.rs b/graphics/src/text/editor.rs index 1890cb82..a828a3bc 100644 --- a/graphics/src/text/editor.rs +++ b/graphics/src/text/editor.rs @@ -81,33 +81,7 @@ impl editor::Editor for Editor { } fn selection(&self) -> Option<String> { - let internal = self.internal(); - - let cursor = internal.editor.cursor(); - let selection = internal.editor.select_opt()?; - - let (start, end) = if cursor < selection { - (cursor, selection) - } else { - (selection, cursor) - }; - - Some( - internal.editor.buffer().lines[start.line..=end.line] - .iter() - .enumerate() - .map(|(i, line)| { - if i == 0 { - &line.text()[start.index..] - } else if i == end.line - start.line { - &line.text()[..end.index] - } else { - line.text() - } - }) - .collect::<Vec<_>>() - .join("\n"), - ) + self.internal().editor.copy_selection() } fn cursor(&self) -> editor::Cursor { @@ -400,14 +374,6 @@ impl editor::Editor for Editor { } Action::Paste(text) => { editor.insert_string(&text, None); - - // TODO: Fix cosmic-text - // Cursor should be marked as moved after `insert_string`. - let cursor = editor.cursor(); - - editor - .buffer_mut() - .shape_until_cursor(font_system.raw(), cursor); } Action::Enter => { editor.action(font_system.raw(), cosmic_text::Action::Enter); |