Trait linefeed::terminal::TerminalReader
source · pub trait TerminalReader<Term: Terminal> {
fn prepare(
&mut self,
block_signals: bool,
report_signals: SignalSet
) -> Result<Term::PrepareState>;
unsafe fn prepare_with_lock(
&mut self,
lock: &mut dyn TerminalWriter<Term>,
block_signals: bool,
report_signals: SignalSet
) -> Result<Term::PrepareState>;
fn restore(&mut self, state: Term::PrepareState) -> Result<()>;
unsafe fn restore_with_lock(
&mut self,
lock: &mut dyn TerminalWriter<Term>,
state: Term::PrepareState
) -> Result<()>;
fn read(&mut self, buf: &mut Vec<u8>) -> Result<RawRead>;
fn wait_for_input(&mut self, timeout: Option<Duration>) -> Result<bool>;
}
Expand description
Holds a lock on Terminal
read operations
Required Methods
sourcefn prepare(
&mut self,
block_signals: bool,
report_signals: SignalSet
) -> Result<Term::PrepareState>
fn prepare(
&mut self,
block_signals: bool,
report_signals: SignalSet
) -> Result<Term::PrepareState>
Prepares the terminal for line reading and editing operations.
If block_signals
is true
, the terminal will be configured to treat
special characters that would otherwise be interpreted as signals as
their literal value.
If block_signals
is false
, a signal contained in the report_signals
set may be returned.
Notes
This method may be called more than once. However, if the state values are not restored in reverse order in which they were created, the state of the underlying terminal device becomes undefined.
sourceunsafe fn prepare_with_lock(
&mut self,
lock: &mut dyn TerminalWriter<Term>,
block_signals: bool,
report_signals: SignalSet
) -> Result<Term::PrepareState>
unsafe fn prepare_with_lock(
&mut self,
lock: &mut dyn TerminalWriter<Term>,
block_signals: bool,
report_signals: SignalSet
) -> Result<Term::PrepareState>
Like prepare
, but called when the write lock is already held.
Safety
This method must be called with a TerminalWriter
instance returned
by the same Terminal
instance to which this TerminalReader
belongs.
sourcefn restore(&mut self, state: Term::PrepareState) -> Result<()>
fn restore(&mut self, state: Term::PrepareState) -> Result<()>
Restores the terminal state using the given state data.
sourceunsafe fn restore_with_lock(
&mut self,
lock: &mut dyn TerminalWriter<Term>,
state: Term::PrepareState
) -> Result<()>
unsafe fn restore_with_lock(
&mut self,
lock: &mut dyn TerminalWriter<Term>,
state: Term::PrepareState
) -> Result<()>
Like restore
, but called when the write lock is already held.
Safety
This method must be called with a TerminalWriter
instance returned
by the same Terminal
instance to which this TerminalReader
belongs.
sourcefn read(&mut self, buf: &mut Vec<u8>) -> Result<RawRead>
fn read(&mut self, buf: &mut Vec<u8>) -> Result<RawRead>
Reads some input from the terminal and appends it to the given buffer.
sourcefn wait_for_input(&mut self, timeout: Option<Duration>) -> Result<bool>
fn wait_for_input(&mut self, timeout: Option<Duration>) -> Result<bool>
Waits timeout
for user input. If timeout
is None
, waits indefinitely.
Returns Ok(true)
if input becomes available within the given timeout
or if a signal is received.
Returns Ok(false)
if the timeout expires before input becomes available.