diff options
| author | 2021-07-22 12:37:39 -0500 | |
|---|---|---|
| committer | 2021-07-22 12:37:39 -0500 | |
| commit | e822f654e44d2d7375b7fda966bb772055f377d4 (patch) | |
| tree | 8707561f1bb09c9e58cc9d9884bfb16d956f9f65 /native/src/widget/text_input/value.rs | |
| parent | 1c06920158e1a47977b2762bf8b34e56fd1a935a (diff) | |
| parent | dc0b96ce407283f2ffd9add5ad339f89097555d3 (diff) | |
| download | iced-e822f654e44d2d7375b7fda966bb772055f377d4.tar.gz iced-e822f654e44d2d7375b7fda966bb772055f377d4.tar.bz2 iced-e822f654e44d2d7375b7fda966bb772055f377d4.zip | |
Merge branch 'master' of https://github.com/hecrj/iced into wgpu_outdatedframe
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 { |
