Skip to main content

TextBoxState

Struct TextBoxState 

Source
pub struct TextBoxState<I: ApplicationInfo = EmptyInfo> { /* private fields */ }
Expand description

Persistent state for TextBox.

Implementations§

Source§

impl<I> TextBoxState<I>
where I: ApplicationInfo,

Source

pub fn new(buffer: SharedBuffer<I>) -> Self

Create state for a new text box.

Source

pub fn buffer(&self) -> SharedBuffer<I>

Get a reference to the shared buffer used by this text box.

Source

pub fn is_readonly(&self) -> bool

Indicates whether the buffer contents are readonly.

Source

pub fn set_readonly(&mut self, readonly: bool)

Set whether the buffer contents are modifiable through the Editable trait.

Source

pub fn get(&self) -> EditRope

Get the contents of the underlying buffer as an EditRope.

Source

pub fn get_text(&self) -> String

Get the contents of the underlying buffer as a String.

Source

pub fn set_text<T: Into<EditRope>>(&mut self, t: T)

Replace the contents of the text box’s underlying buffer.

Source

pub fn reset(&mut self) -> EditRope

Clear the text box’s underlying buffer of its content, and return it.

Source

pub fn reset_text(&mut self) -> String

Clear the text box’s underlying buffer of its content, and return it as a String.

Source

pub fn set_left_gutter(&mut self, line: usize, s: String, style: Option<Style>)

Create or update a line annotation for the left gutter.

Source

pub fn set_right_gutter(&mut self, line: usize, s: String, style: Option<Style>)

Create or update a line annotation for the right gutter.

Source

pub fn set_wrap(&mut self, wrap: bool)

Control whether the text box should wrap long lines when displaying them.

Source

pub fn set_term_info(&mut self, area: Rect)

Inform the text box what its dimensions and placement on the terminal window is.

Source

pub fn get_cursor(&mut self) -> Cursor

Get the leader cursor for this text box’s cursor group.

Source

pub fn get_lines(&self) -> usize

Calculate how many lines are in this text box.

Source

pub fn has_lines(&self, max: usize) -> usize

Check whether this text box is capable of displaying max lines.

If there are fewer lines available than max, this returns the same value as get_lines(). Otherwise, this returns max.

This method is useful for building additional widgets that want to create a TextBox with a flexible height up to max lines.

Trait Implementations§

Source§

impl<I> Editable<EditContext, Store<I>, I> for TextBoxState<I>
where I: ApplicationInfo,

Source§

fn editor_command( &mut self, act: &EditorAction, ctx: &EditContext, store: &mut Store<I>, ) -> EditResult<EditInfo, I>

Execute an editor action.
Source§

impl<I> Jumpable<EditContext, I> for TextBoxState<I>
where I: ApplicationInfo,

Source§

fn jump( &mut self, list: PositionList, dir: MoveDir1D, count: usize, ctx: &EditContext, ) -> UIResult<usize, I>

Move through a PositionList in MoveDir1D direction count times. Read more
Source§

impl<I> Promptable<EditContext, Store<I>, I> for TextBoxState<I>
where I: ApplicationInfo,

Source§

fn prompt( &mut self, _: &PromptAction, _: &EditContext, _: &mut Store<I>, ) -> EditResult<Vec<(Action<I>, EditContext)>, I>

Execute a prompt action.
Source§

impl<I> ScrollActions<EditContext, Store<I>, I> for TextBoxState<I>
where I: ApplicationInfo,

Source§

fn dirscroll( &mut self, dir: MoveDir2D, size: ScrollSize, count: &Count, ctx: &EditContext, _: &mut Store<I>, ) -> EditResult<EditInfo, I>

Pan the viewport.
Source§

fn cursorpos( &mut self, pos: MovePosition, axis: Axis, _: &EditContext, _: &mut Store<I>, ) -> EditResult<EditInfo, I>

Scroll so that the cursor is placed along a viewport boundary.
Source§

fn linepos( &mut self, pos: MovePosition, count: &Count, ctx: &EditContext, _: &mut Store<I>, ) -> EditResult<EditInfo, I>

Scroll so that a specific line is placed at a given place in the viewport.
Source§

impl<I> Scrollable<EditContext, Store<I>, I> for TextBoxState<I>
where I: ApplicationInfo,

Source§

fn scroll( &mut self, style: &ScrollStyle, ctx: &EditContext, store: &mut Store<I>, ) -> EditResult<EditInfo, I>

Scroll the viewable content in this object.
Source§

impl<I> Searchable<EditContext, Store<I>, I> for TextBoxState<I>
where I: ApplicationInfo,

Source§

fn search( &mut self, dir: MoveDirMod, count: Count, ctx: &EditContext, store: &mut Store<I>, ) -> UIResult<EditInfo, I>

Search for the nth result in MoveDirMod direction.
Source§

impl<I> TerminalCursor for TextBoxState<I>
where I: ApplicationInfo,

Source§

fn get_term_cursor(&self) -> Option<(u16, u16)>

Returns the current offset of the cursor, relative to the upper left corner of the terminal.
Source§

impl<I> WindowOps<I> for TextBoxState<I>
where I: ApplicationInfo,

Source§

fn dup(&self, _: &mut Store<I>) -> Self

Create a copy of this window during a window split.
Source§

fn close(&mut self, _: CloseFlags, _: &mut Store<I>) -> bool

Perform any necessary cleanup for this window and close it. Read more
Source§

fn write( &mut self, _: Option<&str>, _: WriteFlags, _: &mut Store<I>, ) -> UIResult<EditInfo, I>

Write the contents of the window.
Source§

fn draw(&mut self, area: Rect, buf: &mut Buffer, _: bool, _: &mut Store<I>)

Draw this window into the buffer for the prescribed area.
Source§

fn get_completions(&self) -> Option<CompletionList>

Get completion candidates to show the user.
Source§

fn get_cursor_word(&self, style: &WordStyle) -> Option<String>

Returns the word following the current cursor position in this window.
Source§

fn get_selected_word(&self) -> Option<String>

Returns the currently selected text in this window.

Auto Trait Implementations§

§

impl<I> Freeze for TextBoxState<I>

§

impl<I> RefUnwindSafe for TextBoxState<I>

§

impl<I> Send for TextBoxState<I>
where <I as ApplicationInfo>::ContentId: Sync, I: Send + Sync,

§

impl<I> Sync for TextBoxState<I>
where <I as ApplicationInfo>::ContentId: Sync, I: Send + Sync,

§

impl<I> Unpin for TextBoxState<I>

§

impl<I> UnsafeUnpin for TextBoxState<I>

§

impl<I> UnwindSafe for TextBoxState<I>

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, 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<T> Any for T
where T: Any,