Skip to main content

TextInput

Struct TextInput 

Source
pub struct TextInput<T: ClipboardProvider> { /* private fields */ }
Expand description

Encapsulated state for handling keyboard input in a single or multiline text input control.

Implementations§

Source§

impl<T: ClipboardProvider> TextInput<T>

Source

pub fn new( lines: Lines, initial: DOMString, clipboard_provider: T, ) -> TextInput<T>

Instantiate a new text input control

Source

pub fn edit_point(&self) -> RopeIndex

Source

pub fn selection_origin(&self) -> Option<RopeIndex>

Source

pub fn selection_origin_or_edit_point(&self) -> RopeIndex

The selection origin, or the edit point if there is no selection. Note that the selection origin may be after the edit point, in the case of a backward selection.

Source

pub fn selection_direction(&self) -> SelectionDirection

Source

pub fn set_max_length(&mut self, length: Option<Utf16CodeUnitLength>)

Source

pub fn set_min_length(&mut self, length: Option<Utf16CodeUnitLength>)

Source

pub fn delete_char(&mut self, direction: Direction) -> bool

Remove a character at the current editing point

Returns true if any character was deleted

Source

pub fn insert<S: Into<String>>(&mut self, string: S)

Insert a string at the current editing point or replace the selection if one exists.

Source

pub fn selection_start(&self) -> RopeIndex

The start of the selection (or the edit point, if there is no selection). Always less than or equal to selection_end(), regardless of the selection direction.

Source

pub fn selection_end(&self) -> RopeIndex

The end of the selection (or the edit point, if there is no selection). Always greater than or equal to selection_start(), regardless of the selection direction.

Source

pub fn selection_end_offset(&self) -> Utf8CodeUnitLength

The byte offset of the selection_end()

Source

pub fn replace_selection(&mut self, insert: &DOMString)

Replace the current selection with the given DOMString. If the Rope is in single line mode this will strip newlines, as opposed to Self::set_content, which does not.

Source

pub fn modify_edit_point(&mut self, amount: isize, movement: RopeMovement)

Source

pub fn modify_selection(&mut self, amount: isize, movement: RopeMovement)

Source

pub fn modify_selection_or_edit_point( &mut self, amount: isize, movement: RopeMovement, select: Selection, )

Source

pub fn handle_return(&mut self) -> KeyReaction

Deal with a newline input.

Source

pub fn select_all(&mut self)

Select all text in the input control.

Source

pub fn clear_selection(&mut self)

Remove the current selection.

Source

pub fn handle_keydown_aux( &mut self, key: Key, mods: Modifiers, macos: bool, ) -> KeyReaction

Source

pub fn get_content(&self) -> DOMString

Get the current contents of the text input. Multiple lines are joined by \n.

Source

pub fn set_content(&mut self, content: DOMString)

Set the current contents of the text input. If this is control supports multiple lines, any \n encountered will be stripped and force a new logical line.

Note that when the Rope is in single line mode, this will not strip newlines. Newline stripping only happens for incremental updates to the Rope as <input> elements currently need to store unsanitized values while being created.

Source

pub fn set_selection_range_utf16( &mut self, start: Utf16CodeUnitLength, end: Utf16CodeUnitLength, direction: SelectionDirection, )

Source

pub fn set_selection_range_utf8( &mut self, start: Utf8CodeUnitLength, end: Utf8CodeUnitLength, direction: SelectionDirection, )

Trait Implementations§

Source§

impl<T> MallocSizeOf for TextInput<T>

Source§

fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize

Measure the heap usage of all descendant heap-allocated structures, but not the space taken up by the value itself.
Source§

impl<T> Traceable for TextInput<T>

Source§

unsafe fn trace(&self, tracer: *mut JSTracer)

Trace self.

Auto Trait Implementations§

§

impl<T> Freeze for TextInput<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for TextInput<T>
where T: RefUnwindSafe,

§

impl<T> Send for TextInput<T>
where T: Send,

§

impl<T> Sync for TextInput<T>
where T: Sync,

§

impl<T> Unpin for TextInput<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for TextInput<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for TextInput<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Filterable for T

Source§

fn filterable( self, filter_name: &'static str, ) -> RequestFilterDataProvider<T, fn(DataRequest<'_>) -> bool>

Creates a filterable data provider with the given name for debugging. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> MaybeBoxed<Box<T>> for T

Source§

fn maybe_boxed(self) -> Box<T>

Convert
Source§

impl<T> MaybeBoxed<T> for T

Source§

fn maybe_boxed(self) -> T

Convert
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

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

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T