diff options
author | 2021-03-10 01:59:02 +0100 | |
---|---|---|
committer | 2021-03-10 01:59:02 +0100 | |
commit | 21971e0037c2ddcb96fd48ea96332445de4137bb (patch) | |
tree | 7cc1dc9147923a45c25f70d187cdecf08ab33497 /native/src/widget/text_input/value.rs | |
parent | 35425001edcb54d861a42ec6d23f9e57b37745fd (diff) | |
download | iced-21971e0037c2ddcb96fd48ea96332445de4137bb.tar.gz iced-21971e0037c2ddcb96fd48ea96332445de4137bb.tar.bz2 iced-21971e0037c2ddcb96fd48ea96332445de4137bb.zip |
Make `Clipboard` argument in `Widget` trait mutable
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 { |