Skip to main content

Editor

Struct Editor 

Source
pub struct Editor {
    pub config: Config,
    /* private fields */
}
Expand description

Interactive line editor instance.

Fields§

§config: Config

Configuration for this editor instance.

Implementations§

Source§

impl Editor

Source

pub fn new() -> Self

Creates a new editor with default configuration.

Source

pub fn with_config(config: Config) -> Self

Creates a new editor with the specified configuration.

Source

pub fn readline( &mut self, prompt: impl AsRef<BStr>, ) -> Result<BString, ReadlineError>

Reads a line from stdin/stdout using this editor.

Source

pub fn readline_from<R: Read, W: Write>( &mut self, reader: R, writer: W, mode: OperatingMode, prompt: impl AsRef<BStr>, ) -> Result<BString, ReadlineError>

Reads a line from the provided reader and writer streams using the specified operating mode.

Source

pub fn readline_stream<R: Read, W: Write>( &mut self, reader: &mut R, writer: &mut W, prompt: &BStr, ) -> Result<BString, ReadlineError>

Reads a line directly from raw reader and writer streams in interactive mode.

Source

pub fn set_completion_handler<H: CompletionHandler + 'static>( &mut self, handler: H, )

Registers a completion handler for tab autocompletion.

Source

pub fn clear_completion_handler(&mut self)

Removes any registered completion handler.

Source

pub fn set_hint_handler<H: HintHandler + 'static>(&mut self, handler: H)

Registers a hint handler for inline completions/hints.

Source

pub fn clear_hint_handler(&mut self)

Removes any registered hint handler.

Source

pub fn add_history(&mut self, line: impl Into<BString>) -> bool

Adds a line to the editor’s history buffer.

Returns true if the entry was added (deduplicating adjacent identical entries).

Source

pub fn history(&self) -> &History

Returns a shared reference to the editor’s history manager.

Source

pub fn history_mut(&mut self) -> &mut History

Returns a mutable reference to the editor’s history manager.

Source

pub fn clear_screen(&self) -> Result<(), Error>

Clears the terminal screen using stdout.

Source

pub fn clear_screen_writer<W: Write>(&self, writer: &mut W) -> Result<(), Error>

Clears the terminal screen using the provided writer.

Trait Implementations§

Source§

impl Default for Editor

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl !Freeze for Editor

§

impl !RefUnwindSafe for Editor

§

impl !Sync for Editor

§

impl !UnwindSafe for Editor

§

impl Send for Editor

§

impl Unpin for Editor

§

impl UnsafeUnpin for Editor

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, 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.