pub struct TermRead<'t, 'p, P, T: IoProvider = StdioProvider>{ /* private fields */ }Available on crate features
raw and readers only.Expand description
Implementations§
Source§impl<'t, T: IoProvider> TermRead<'t, '_, KeyCode, T>
impl<'t, T: IoProvider> TermRead<'t, '_, KeyCode, T>
Source§impl<'t, 'p, P, T> TermRead<'t, 'p, P, T>
impl<'t, 'p, P, T> TermRead<'t, 'p, P, T>
Sourcepub fn new(term: &'t mut Terminal<T>, exit: P) -> Self
pub fn new(term: &'t mut Terminal<T>, exit: P) -> Self
Creates new terminal reader that exits with the given predicate.
Sourcepub fn from_config(
term: &'t mut Terminal<T>,
exit: P,
conf: ReadConf<'p>,
) -> Self
pub fn from_config( term: &'t mut Terminal<T>, exit: P, conf: ReadConf<'p>, ) -> Self
Create terminal reader from configuration.
Sourcepub fn read_to_str(&mut self, s: &mut String) -> Result<()>
pub fn read_to_str(&mut self, s: &mut String) -> Result<()>
Sourcepub fn finish_to_str(&mut self, s: &mut String) -> Result<()>
pub fn finish_to_str(&mut self, s: &mut String) -> Result<()>
Sourcepub fn set_prompt(&mut self, prompt: impl Into<TermText<'p>>)
pub fn set_prompt(&mut self, prompt: impl Into<TermText<'p>>)
Set the prompt.
Sourcepub fn set_buf(&mut self, buf: Vec<char>, pos: Option<usize>)
pub fn set_buf(&mut self, buf: Vec<char>, pos: Option<usize>)
Set the read buffer. It is filtered for non control characters.
Sourcepub unsafe fn read_one(&mut self) -> Result<bool>
pub unsafe fn read_one(&mut self) -> Result<bool>
Read one next character or nothing. Doesn’t block. Returns true if
the input has ended and the result may be retrieved with
TermRead::finish or TermRead::finish_to_str.
§Errors
Error::Ioon io write or read.
§Safety
This is unsafe because calls to set_ functions may break the input if
this is called.
Sourcepub fn is_finished(&self) -> bool
pub fn is_finished(&self) -> bool
Check if the reading is finished.
Sourcepub fn set_end_condition(&mut self, c: P)
pub fn set_end_condition(&mut self, c: P)
Sets the exit condition for the reader.
Sourcepub fn splice(
&mut self,
range: impl RangeBounds<usize>,
it: impl IntoIterator<Item = char>,
)
pub fn splice( &mut self, range: impl RangeBounds<usize>, it: impl IntoIterator<Item = char>, )
Modify the buffer. Control characters are ignored.
Sourcepub fn last_event(&self) -> Option<&Event>
pub fn last_event(&self) -> Option<&Event>
Gets the last event.
Sourcepub fn queue(&mut self, evt: impl IntoIterator<Item = Event>)
pub fn queue(&mut self, evt: impl IntoIterator<Item = Event>)
Queue event to the reader.
Auto Trait Implementations§
impl<'t, 'p, P, T = StdioProvider> !Freeze for TermRead<'t, 'p, P, T>
impl<'t, 'p, P, T = StdioProvider> !RefUnwindSafe for TermRead<'t, 'p, P, T>
impl<'t, 'p, P, T = StdioProvider> !Sync for TermRead<'t, 'p, P, T>
impl<'t, 'p, P, T = StdioProvider> !UnwindSafe for TermRead<'t, 'p, P, T>
impl<'t, 'p, P, T> Send for TermRead<'t, 'p, P, T>
impl<'t, 'p, P, T> Unpin for TermRead<'t, 'p, P, T>
impl<'t, 'p, P, T> UnsafeUnpin for TermRead<'t, 'p, P, T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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