Skip to main content

Composer

Struct Composer 

Source
pub struct Composer { /* private fields */ }

Implementations§

Source§

impl Composer

Source

pub fn on_resize(&mut self, width: u16)

Adopts a new terminal width, so wrapping and vertical cursor movement follow the rows the next layout will produce.

Source

pub fn layout(&self, width: u16, theme: &Theme) -> ComposerLayout

Lays the composer out for width columns: a rule, the wrapped input with its @mentions highlighted, any attachments, and a closing rule.

Source§

impl Composer

Source

pub fn new() -> Self

Source

pub fn text(&self) -> &str

Source

pub fn is_empty(&self) -> bool

Source

pub fn selected_mentions(&self) -> Vec<SelectedFileMention>

Source

pub fn take_submission(&mut self) -> (String, Vec<PromptAttachment>)

Source

pub fn clear(&mut self)

Source

pub fn add_dropped_media(&mut self, paths: Vec<PathBuf>) -> bool

Source

pub fn pending_media(&self) -> &[PromptAttachment]

Source

pub fn apply_edit_key(&mut self, key: KeyEvent) -> bool

Applies one shared editing keystroke. Anything that changes the text also ends history navigation, so the recalled prompt becomes the user’s draft.

Source

pub fn insert_char(&mut self, character: char)

Source

pub fn insert_str(&mut self, text: &str)

Source

pub fn insert_paste(&mut self, text: &str)

Source

pub fn insert_newline(&mut self)

Source

pub fn backspace(&mut self)

Source

pub fn move_left(&mut self)

Source

pub fn move_line_start(&mut self)

Source

pub fn move_line_end(&mut self)

Source

pub fn move_up(&mut self) -> bool

Moves the cursor to the visual row above, reporting whether there was one. A long line the composer soft-wrapped has rows above without any newline before the cursor, so this follows what is on screen rather than the newlines in the text.

Source

pub fn move_down(&mut self) -> bool

Moves the cursor to the visual row below, reporting whether there was one.

Source

pub fn recall_previous(&mut self) -> bool

Source

pub fn recall_next(&mut self) -> bool

Source

pub fn open_command_picker(&mut self, commands: Vec<CommandEntry>)

Source

pub fn open_file_picker(&mut self, root: &Path) -> FilesystemCommand

Opens the @ picker and asks for the file index it will show. The walk runs off the event loop, so opening the picker never stalls the keystroke that triggered it.

Source

pub fn on_files_indexed(&mut self, request_id: RequestId, files: Vec<FileEntry>)

Source

pub fn has_completion(&self) -> bool

Source

pub fn completion(&self) -> Option<&CompletionOverlay>

Source

pub fn completion_mut(&mut self) -> Option<&mut CompletionOverlay>

The open completion list, for navigation and stateful rendering.

Source

pub fn prompt_search_mut(&mut self) -> Option<&mut PromptSearchPicker>

The open prompt-history picker, for queries and stateful rendering.

Source

pub fn has_open_overlay(&self) -> bool

Source

pub fn on_overlay_mouse(&mut self, action: MouseAction, row: u16)

Routes a mouse event to whichever overlay is open. Browsing history results previews each candidate in the composer, the way the arrow keys do.

Source

pub fn on_prompt_search_key(&mut self, key: KeyEvent) -> Option<ComposerOutcome>

Applies a keystroke to the open history search, or reports that there is none for it to go to.

Source

pub fn on_prompt_search_paste(&mut self, text: &str) -> Option<ComposerOutcome>

Applies a paste to the open history search, or reports that there is none for it to go to.

Source

pub fn on_completion_key(&mut self, key: KeyEvent) -> Option<ComposerOutcome>

Applies a keystroke to the open completion list, or reports that there is none for it to go to.

Source

pub fn prompt_search_on_results(&mut self, response: PromptSearchResponse)

Source

pub fn accept_command(&mut self) -> Option<CommandEntry>

Source

pub fn accept_file(&mut self) -> Option<FileEntry>

Source

pub fn refresh_overlay_query(&mut self)

Source

pub fn cursor_position(&self) -> (usize, usize)

Trait Implementations§

Source§

impl Debug for Composer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Composer

Source§

fn default() -> Composer

Returns the “default value” for a type. Read more

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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

Source§

fn into_maybe_undefined(self) -> MaybeUndefined<T>

Converts this value into a three-state builder argument.
Source§

impl<T> IntoOption<T> for T

Source§

fn into_option(self) -> Option<T>

Converts this value into an optional builder argument.
Source§

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

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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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