[−][src]Struct stakker_tui::Terminal
Actor that manages the connection to the terminal
Implementations
impl Terminal
[src]
pub fn init(
cx: &mut Cx<'_, Self>,
resize: Fwd<Option<Share<TermOut>>>,
input: Fwd<Key>
) -> Option<Self>
[src]
cx: &mut Cx<'_, Self>,
resize: Fwd<Option<Share<TermOut>>>,
input: Fwd<Key>
) -> Option<Self>
Set up the terminal. Sends a message back to resize
immediately, which provides a reference to the shared
TermOut
which is used to buffer and flush terminal output
data.
Whenever the window size changes, a new resize
message is
sent. When the terminal output is paused, None
is sent to
resize
to let the app know that there is no output available
right now.
Input keys received are sent to input
once decoded.
In case of an error that can't be handled, cleans up the
terminal state and terminates the actor with
ActorDied::Failed
. The actor that created the terminal can
catch that and do whatever cleanup is necessary before
aborting the process.
Panic handling
When Rust panics, the terminal must be restored to its normal
state otherwise things would be left in a bad state for the
user (in cooked mode with no echo, requiring the user to
blindly type reset
on the command-line). So this code saves
a copy of the current panic handler (using
std::panic::take_hook
), and then installs its own handler
that does terminal cleanup before calling on to the saved
panic handler. This mean that if any custom panic handler is
needed by the application, then it must be set up before the
call to Terminal::init
.
pub fn check(&mut self, _cx: &mut Cx<'_, Self>, enable: bool)
[src]
Enable or disable generation of the Key::Check
keypress,
which occurs in a gap in typing, 300ms after the last key
pressed. This may be used to do validation if that's too
expensive to do on every keypress.
pub fn bell(&mut self, cx: &mut Cx<'_, Self>)
[src]
Ring the bell (i.e. beep) immediately. Doesn't wait for the buffered terminal data to be flushed. Will output even when paused.
pub fn pause(&mut self, cx: &mut Cx<'_, Self>)
[src]
Pause terminal input and output handling. Sends the cleanup
sequence to the terminal, and switches to cooked mode. Sends
a resize
message with None
to tell the app that output is
disabled.
This call should be used before forking off a process which
might prompt the user and receive user input, otherwise this
process would compete with the sub-process for user input.
Resume after the subprocess has finished with the resume
call.
pub fn resume(&mut self, cx: &mut Cx<'_, Self>)
[src]
Resume terminal output and input handling. Switches to raw mode and sends a resize message to trigger a full redraw.
pub fn flush(&mut self, cx: &mut Cx<'_, Self>)
[src]
Flush to the terminal all the data that's ready for sending
from the TermOut buffer. Use TermOut::flush
first to mark
the point up to which data should be flushed.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Terminal
impl !Send for Terminal
impl !Sync for Terminal
impl Unpin for Terminal
impl !UnwindSafe for Terminal
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Any for T where
T: Any,
T: Any,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,