Struct nannou::ui::text::cursor::Index[][src]

pub struct Index {
    pub line: usize,
    pub char: usize,
}
Expand description

An index representing the position of a cursor within some text.

Fields

line: usize

The index of the line upon which the cursor is situated.

char: usize

The index within all possible cursor positions for the line.

For example, for the line foo, a char of 1 would indicate the cursor’s position as f|oo where | is the cursor.

Implementations

The cursor index of the beginning of the word (block of non-whitespace) before self.

If self is at the beginning of the line, call previous, which returns the last index position of the previous line, or None if it’s the first line

If self points to whitespace, skip past that whitespace, then return the index of the start of the word that precedes the whitespace

If self is in the middle or end of a word, return the index of the start of that word

The cursor index of the end of the first word (block of non-whitespace) after self.

If self is at the end of the text, this returns None.

If self is at the end of a line other than the last, this returns the first index of the next line.

If self points to whitespace, skip past that whitespace, then return the index of the end of the word after the whitespace

If self is in the middle or start of a word, return the index of the end of that word

The cursor index that comes before self.

If self is at the beginning of the text, this returns None.

If self is at the beginning of a line other than the first, this returns the last index position of the previous line.

If self is a position other than the start of a line, it will return the position that is immediately to the left.

The cursor index that follows self.

If self is at the end of the text, this returns None.

If self is at the end of a line other than the last, this returns the first index of the next line.

If self is a position other than the end of a line, it will return the position that is immediately to the right.

Clamps self to the given lines.

If self would lie after the end of the last line, return the index at the end of the last line.

If line_infos is empty, returns cursor at line=0 char=0.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Auto Trait Implementations

Blanket Implementations

Convert the source color to the destination color using the specified method Read more

Convert the source color to the destination color using the bradford method by default Read more

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Convert into T with values clamped to the color defined bounds Read more

Convert into T. The resulting color might be invalid in its color space Read more

Convert into T, returning ok if the color is inside of its defined range, otherwise an OutOfBounds error is returned which contains the unclamped color. Read more

Compare self to key and return true if they are equal.

Performs the conversion.

Performs the conversion.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.