diff options
author | 2021-03-10 21:13:07 +0100 | |
---|---|---|
committer | 2021-03-10 21:13:07 +0100 | |
commit | 7eb512774862d44772c43f9843f586bfcfa2aa89 (patch) | |
tree | 34d64096302f59f8cb6daf35a131d8ba42f46905 /native/src/widget/text_input/value.rs | |
parent | 939fcfe9dbe8c08a286c6328da6053b5fd577adf (diff) | |
parent | 17dcfa8faf68afe3cbad1151f41eb35230ef83e1 (diff) | |
download | iced-7eb512774862d44772c43f9843f586bfcfa2aa89.tar.gz iced-7eb512774862d44772c43f9843f586bfcfa2aa89.tar.bz2 iced-7eb512774862d44772c43f9843f586bfcfa2aa89.zip |
Merge pull request #770 from hecrj/feature/clipboard-write
Write clipboard support and `TextInput` copy and cut behavior
Diffstat (limited to 'native/src/widget/text_input/value.rs')
-rw-r--r-- | native/src/widget/text_input/value.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/native/src/widget/text_input/value.rs b/native/src/widget/text_input/value.rs index 86be2790..2034cca4 100644 --- a/native/src/widget/text_input/value.rs +++ b/native/src/widget/text_input/value.rs @@ -73,6 +73,15 @@ impl Value { .unwrap_or(self.len()) } + /// Returns a new [`Value`] containing the graphemes from `start` until the + /// given `end`. + pub fn select(&self, start: usize, end: usize) -> Self { + let graphemes = + self.graphemes[start.min(self.len())..end.min(self.len())].to_vec(); + + Self { graphemes } + } + /// Returns a new [`Value`] containing the graphemes until the given /// `index`. pub fn until(&self, index: usize) -> Self { |