summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--Cargo.toml4
-rw-r--r--graphics/src/text/editor.rs36
2 files changed, 5 insertions, 35 deletions
diff --git a/Cargo.toml b/Cargo.toml
index af74a3cf..f8dd5f14 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -151,3 +151,7 @@ wgpu = "0.17"
winapi = "0.3"
window_clipboard = "0.3"
winit = { git = "https://github.com/iced-rs/winit.git", rev = "c52db2045d0a2f1b8d9923870de1d4ab1994146e", default-features = false }
+
+[patch.crates-io.cosmic-text]
+git = "https://github.com/hecrj/cosmic-text.git"
+rev = "cb83458e7d0b84ef37c5beb72dda5046d7d343a6"
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);