summaryrefslogtreecommitdiffstats
path: root/native/src/widget/text_input
diff options
context:
space:
mode:
Diffstat (limited to 'native/src/widget/text_input')
-rw-r--r--native/src/widget/text_input/cursor.rs5
-rw-r--r--native/src/widget/text_input/value.rs20
2 files changed, 1 insertions, 24 deletions
diff --git a/native/src/widget/text_input/cursor.rs b/native/src/widget/text_input/cursor.rs
index aa03bb74..e630e293 100644
--- a/native/src/widget/text_input/cursor.rs
+++ b/native/src/widget/text_input/cursor.rs
@@ -8,8 +8,6 @@ pub struct Cursor {
}
/// The state of a [`Cursor`].
-///
-/// [`Cursor`]: struct.Cursor.html
#[derive(Debug, Copy, Clone)]
pub enum State {
/// Cursor without a selection
@@ -34,9 +32,6 @@ impl Default for Cursor {
impl Cursor {
/// Returns the [`State`] of the [`Cursor`].
- ///
- /// [`State`]: struct.State.html
- /// [`Cursor`]: struct.Cursor.html
pub fn state(&self, value: &Value) -> State {
match self.state {
State::Index(index) => State::Index(index.min(value.len())),
diff --git a/native/src/widget/text_input/value.rs b/native/src/widget/text_input/value.rs
index 8df74e0c..86be2790 100644
--- a/native/src/widget/text_input/value.rs
+++ b/native/src/widget/text_input/value.rs
@@ -2,7 +2,7 @@ use unicode_segmentation::UnicodeSegmentation;
/// The value of a [`TextInput`].
///
-/// [`TextInput`]: struct.TextInput.html
+/// [`TextInput`]: crate::widget::TextInput
// TODO: Reduce allocations, cache results (?)
#[derive(Debug, Clone)]
pub struct Value {
@@ -11,8 +11,6 @@ pub struct Value {
impl Value {
/// Creates a new [`Value`] from a string slice.
- ///
- /// [`Value`]: struct.Value.html
pub fn new(string: &str) -> Self {
let graphemes = UnicodeSegmentation::graphemes(string, true)
.map(String::from)
@@ -24,23 +22,17 @@ impl Value {
/// Returns whether the [`Value`] is empty or not.
///
/// A [`Value`] is empty when it contains no graphemes.
- ///
- /// [`Value`]: struct.Value.html
pub fn is_empty(&self) -> bool {
self.len() == 0
}
/// Returns the total amount of graphemes in the [`Value`].
- ///
- /// [`Value`]: struct.Value.html
pub fn len(&self) -> usize {
self.graphemes.len()
}
/// Returns the position of the previous start of a word from the given
/// grapheme `index`.
- ///
- /// [`Value`]: struct.Value.html
pub fn previous_start_of_word(&self, index: usize) -> usize {
let previous_string =
&self.graphemes[..index.min(self.graphemes.len())].concat();
@@ -63,8 +55,6 @@ impl Value {
/// Returns the position of the next end of a word from the given grapheme
/// `index`.
- ///
- /// [`Value`]: struct.Value.html
pub fn next_end_of_word(&self, index: usize) -> usize {
let next_string = &self.graphemes[index..].concat();
@@ -85,8 +75,6 @@ impl Value {
/// Returns a new [`Value`] containing the graphemes until the given
/// `index`.
- ///
- /// [`Value`]: struct.Value.html
pub fn until(&self, index: usize) -> Self {
let graphemes = self.graphemes[..index.min(self.len())].to_vec();
@@ -94,8 +82,6 @@ impl Value {
}
/// Converts the [`Value`] into a `String`.
- ///
- /// [`Value`]: struct.Value.html
pub fn to_string(&self) -> String {
self.graphemes.concat()
}
@@ -118,8 +104,6 @@ impl Value {
}
/// Removes the grapheme at the given `index`.
- ///
- /// [`Value`]: struct.Value.html
pub fn remove(&mut self, index: usize) {
let _ = self.graphemes.remove(index);
}
@@ -131,8 +115,6 @@ impl Value {
/// Returns a new [`Value`] with all its graphemes replaced with the
/// dot ('•') character.
- ///
- /// [`Value`]: struct.Value.html
pub fn secure(&self) -> Self {
Self {
graphemes: std::iter::repeat(String::from("•"))