Skip to main content

CommandBarState

Struct CommandBarState 

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

Persistent state for rendering CommandBar.

Implementations§

Source§

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

Source

pub fn new(store: &mut Store<I>) -> Self

Create state for a CommandBar widget.

Source

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

Get completion candidates from the command bar to show the user.

Source

pub fn set_type( &mut self, prompt: &str, ct: CommandType, act: &Action<I>, ctx: &EditContext, )

Set the type of command that the bar is being used for.

Source

pub fn reset(&mut self) -> EditRope

Reset the contents of the bar, and return the contents as an EditRope.

Source

pub fn reset_text(&mut self) -> String

Reset the contents of the bar, and return the contents as a String.

Methods from Deref<Target = TextBoxState<I>>§

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> Deref for CommandBarState<I>
where I: ApplicationInfo,

Source§

type Target = TextBoxState<I>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<I> DerefMut for CommandBarState<I>
where I: ApplicationInfo,

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl<I> PromptActions<EditContext, Store<I>, I> for CommandBarState<I>
where I: ApplicationInfo,

Source§

fn submit( &mut self, ctx: &EditContext, store: &mut Store<I>, ) -> EditResult<Vec<(Action<I>, EditContext)>, I>

Submit the currently entered text.
Source§

fn abort( &mut self, _empty: bool, ctx: &EditContext, store: &mut Store<I>, ) -> EditResult<Vec<(Action<I>, EditContext)>, I>

Abort command entry and reset the current contents. Read more
Source§

fn recall( &mut self, filter: &RecallFilter, dir: &MoveDir1D, count: &Count, ctx: &EditContext, store: &mut Store<I>, ) -> EditResult<Vec<(Action<I>, EditContext)>, I>

Recall previously entered text.
Source§

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

Source§

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

Execute a prompt action.

Auto Trait Implementations§

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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,