pub struct TermLinux { /* private fields */ }linux and term only.Expand description
๐ฎ ๐ง Linux terminal frontend.
๐ sys/os/term::TermLinux
๐ฆ size_of::<TermLinux>() == 44 bytes / 352 bits #๏ธโฃ #[cfg(not(feature = โeventโ))]
๐ฆ size_of::<TermLinux>() == 372 bytes / 2976 bits #๏ธโฃ #[cfg(feature = โeventโ)] #[cfg(target_pointer_width = โ32โ)]
๐ฆ size_of::<TermLinux>() == 392 bytes / 3136 bits #๏ธโฃ #[cfg(feature = โeventโ)] #[cfg(target_pointer_width = โ64โ)]
Owns terminal input parsing, scoped session control, cached terminal and
runtime capabilities, and the last known terminal size over the lower-level
Linux terminal helpers.
Implementationsยง
Sourceยงimpl TermLinux
ยงCore frontend control
impl TermLinux
ยงCore frontend control
Sourcepub fn open() -> LinuxResult<Self>
pub fn open() -> LinuxResult<Self>
Opens a Linux terminal frontend.
This does not enter raw mode and does not install terminal cleanup guards. Session discipline belongs to the future terminal session layer.
Sourcepub fn session(
&mut self,
mode: TermMode,
) -> LinuxResult<TermSession<TermLinuxRestore>>
pub fn session( &mut self, mode: TermMode, ) -> LinuxResult<TermSession<TermLinuxRestore>>
Enters a scoped terminal session.
Applies the requested terminal mode changes and
returns a guard that restores the changed state when dropped.
The requested mode is translated by the backend restore payload, which records only the changes that must be undone on drop.
Only successfully applied changes are registered for restoration. This makes partial setup failures safe: if entering a later mode fails, earlier changes are still undone as the restore payload is dropped.
The returned guard does not borrow self, so the terminal
frontend can continue to be used while the session is active.
Sourcepub fn session_raw(&mut self) -> LinuxResult<TermSession<TermLinuxRestore>>
pub fn session_raw(&mut self) -> LinuxResult<TermSession<TermLinuxRestore>>
Enters a scoped raw terminal session.
This is a convenience wrapper around session with TermMode::raw.
Sourcepub fn print(&mut self, bytes: &[u8]) -> LinuxResult<()>
pub fn print(&mut self, bytes: &[u8]) -> LinuxResult<()>
Writes bytes to stdout.
Sourcepub fn refresh_size(&mut self) -> LinuxResult<Option<TermSize>>
pub fn refresh_size(&mut self) -> LinuxResult<Option<TermSize>>
Refreshes and returns the terminal size.
Sourceยงimpl TermLinux
ยงCapabilities
impl TermLinux
ยงCapabilities
Sourcepub const fn term_capabilities(&self) -> TermCaps
pub const fn term_capabilities(&self) -> TermCaps
Returns the last known terminal protocol capabilities.
Sourcepub const fn run_capabilities(&self) -> RunCap
pub const fn run_capabilities(&self) -> RunCap
Returns the last known runtime capabilities.
Sourcepub fn probe_term_capabilities(&mut self) -> LinuxResult<TermCaps>
Available on crate features event and time only.
pub fn probe_term_capabilities(&mut self) -> LinuxResult<TermCaps>
event and time only.Probes terminal protocol capabilities exposed by the current terminal endpoint.
When running inside a terminal multiplexer such as tmux, this probes the
multiplexer pseudo-terminal, not necessarily the outer terminal emulator.
ยงFeatures
Available with the time feature,
because probing uses bounded waits for terminal replies.
Sourcepub fn probe_run_capabilities(&mut self) -> LinuxResult<RunCap>
Available on crate features event and time only.
pub fn probe_run_capabilities(&mut self) -> LinuxResult<RunCap>
event and time only.Probes terminal capabilities, refreshes size, and recomputes runtime capabilities.
ยงFeatures
Available with the time feature, because terminal probing uses bounded waits.
Sourcepub fn refresh_run_capabilities(&mut self) -> LinuxResult<RunCap>
pub fn refresh_run_capabilities(&mut self) -> LinuxResult<RunCap>
Refreshes runtime capabilities from cached terminal capabilities and current size.
Sourceยงimpl TermLinux
ยงEvent polling
impl TermLinux
ยงEvent polling
Sourcepub fn poll_event(&mut self) -> LinuxResult<Option<EventKind>>
Available on crate feature event only.
pub fn poll_event(&mut self) -> LinuxResult<Option<EventKind>>
event only.Polls for one terminal event using the default low-latency policy.
This is non-blocking. It drains ready bytes and resolves a pending lone Escape when no more bytes are immediately available.
Sourcepub fn poll_event_with(
&mut self,
policy: TermPollPolicy,
) -> LinuxResult<Option<EventKind>>
Available on crate feature event only.
pub fn poll_event_with( &mut self, policy: TermPollPolicy, ) -> LinuxResult<Option<EventKind>>
event only.Polls for one terminal event using policy.
ยงFeatures
With the time feature, this also supports TermPollPolicy::Timeout.
Sourcepub fn poll_event_pending(&mut self) -> LinuxResult<Option<EventKind>>
Available on crate feature event only.
pub fn poll_event_pending(&mut self) -> LinuxResult<Option<EventKind>>
event only.Non-blocking. Preserves pending partial input sequences.
Sourcepub fn poll_event_timeout(
&mut self,
timeout: Duration,
) -> LinuxResult<Option<EventKind>>
Available on crate features event and time only.
pub fn poll_event_timeout( &mut self, timeout: Duration, ) -> LinuxResult<Option<EventKind>>
event and time only.Non-blocking. Resolves pending lone Escape after timeout.
This only waits when the parser is holding a pending ESC.
Sourcepub fn wait_event(&mut self) -> LinuxResult<EventKind>
Available on crate feature event only.
pub fn wait_event(&mut self) -> LinuxResult<EventKind>
event only.Blocks until a terminal event is available.
Buffered events are returned first. Newly read bytes are parsed through the semantic event queue, preserving the same construction and timestamping path used by non-blocking polling.
With time, a pending lone ESC is briefly disambiguated
before being emitted as an Escape event.
Sourceยงimpl TermLinux
ยงSignal handling
impl TermLinux
ยงSignal handling
Sourcepub fn listen_signals(&mut self, controls: AppControlSet)
Available on crate feature event only.
pub fn listen_signals(&mut self, controls: AppControlSet)
event only.Registers Linux signals used by this terminal event source.
This enables application control notices from controls and terminal resize
notices from SIGWINCH. Pending notices are drained into this backendโs event
queue as EventKind::Control and EventWindow::Resized.
This installs process-wide signal handlers. Registering another handler for the same Linux signals may replace this path.
Sourcepub fn listen_app_controls(&mut self, controls: AppControlSet)
Available on crate feature event only.
pub fn listen_app_controls(&mut self, controls: AppControlSet)
event only.Registers application control notices as terminal events.
This installs process-wide Linux signal handlers for the corresponding
controls. Pending notices are drained into this backendโs event queue as
EventKind::Control.
Registering another handler for the same Linux signals may replace this path.
Sourcepub fn listen_resize(&mut self)
Available on crate feature event only.
pub fn listen_resize(&mut self)
event only.Registers terminal resize notices as window resize events.
This installs a process-wide SIGWINCH handler. Pending resize notices are
drained into this backendโs event queue as EventWindow::Resized.
Registering another handler for SIGWINCH may replace this path.
Trait Implementationsยง
Sourceยงimpl RunService for TermLinux
impl RunService for TermLinux
Sourceยงfn run_capabilities(&self) -> RunCap
fn run_capabilities(&self) -> RunCap
Sourceยงfn run_version(&self) -> VersionFull<'_>
fn run_version(&self) -> VersionFull<'_>
Sourceยงimpl RunServiceProbe for TermLinux
Available on crate features event and time only.
impl RunServiceProbe for TermLinux
event and time only.Sourceยงimpl TermBackend for TermLinux
impl TermBackend for TermLinux
Sourceยงtype Error = LinuxError
type Error = LinuxError
Sourceยงtype Session = TermSession<TermLinuxRestore>
type Session = TermSession<TermLinuxRestore>
Sourceยงfn open() -> LinuxResult<Self>
fn open() -> LinuxResult<Self>
Sourceยงfn session(&mut self, mode: TermMode) -> LinuxResult<Self::Session>
fn session(&mut self, mode: TermMode) -> LinuxResult<Self::Session>
Sourceยงfn print(&mut self, bytes: &[u8]) -> LinuxResult<()>
fn print(&mut self, bytes: &[u8]) -> LinuxResult<()>
Sourceยงfn refresh_size(&mut self) -> LinuxResult<Option<TermSize>>
fn refresh_size(&mut self) -> LinuxResult<Option<TermSize>>
Sourceยงfn term_capabilities(&self) -> TermCaps
fn term_capabilities(&self) -> TermCaps
Sourceยงfn probe_term_capabilities(&mut self) -> LinuxResult<TermCaps>
fn probe_term_capabilities(&mut self) -> LinuxResult<TermCaps>
Sourceยงfn poll_event_with(
&mut self,
policy: TermPollPolicy,
) -> LinuxResult<Option<EventKind>>
fn poll_event_with( &mut self, policy: TermPollPolicy, ) -> LinuxResult<Option<EventKind>>
event only.policy.Auto Trait Implementationsยง
impl Freeze for TermLinux
impl RefUnwindSafe for TermLinux
impl Send for TermLinux
impl Sync for TermLinux
impl Unpin for TermLinux
impl UnsafeUnpin for TermLinux
impl UnwindSafe for TermLinux
Blanket Implementationsยง
Sourceยงimpl<T> AnyExt for T
impl<T> AnyExt for T
Sourceยงfn type_hash_with<H: Hasher>(&self, hasher: H) -> u64
fn type_hash_with<H: Hasher>(&self, hasher: H) -> u64
TypeId of Self using a custom hasher.Sourceยงfn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
fn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
Sourceยงfn as_any_box(self: Box<Self>) -> Box<dyn Any>where
Self: Sized,
fn as_any_box(self: Box<Self>) -> Box<dyn Any>where
Self: Sized,
alloc only.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
Sourceยงimpl<T> ByteSized for T
impl<T> ByteSized for T
Sourceยงconst BYTE_ALIGN: usize = _
const BYTE_ALIGN: usize = _
Sourceยงfn byte_align(&self) -> usize
fn byte_align(&self) -> usize
Sourceยงfn ptr_size_ratio(&self) -> [usize; 2]
fn ptr_size_ratio(&self) -> [usize; 2]
Sourceยงimpl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Sourceยงimpl<T> MemExt for Twhere
T: ?Sized,
impl<T> MemExt for Twhere
T: ?Sized,
Sourceยงconst NEEDS_DROP: bool = _
const NEEDS_DROP: bool = _
Sourceยงfn mem_align_of<T>() -> usize
fn mem_align_of<T>() -> usize
Sourceยงfn mem_align_of_val(&self) -> usize
fn mem_align_of_val(&self) -> usize
Sourceยงfn mem_size_of<T>() -> usize
fn mem_size_of<T>() -> usize
Sourceยงfn mem_size_of_val(&self) -> usize
fn mem_size_of_val(&self) -> usize
Sourceยงfn mem_needs_drop(&self) -> bool
fn mem_needs_drop(&self) -> bool
true if dropping values of this type matters. Read moreSourceยงfn mem_forget(self)where
Self: Sized,
fn mem_forget(self)where
Self: Sized,
self without running its destructor. Read moreSourceยงfn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
fn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
Sourceยงunsafe fn mem_zeroed<T>() -> T
unsafe fn mem_zeroed<T>() -> T
unsafe_layout only.T represented by the all-zero byte-pattern. Read moreSourceยงunsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst
unsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst
unsafe_layout only.T represented by the all-zero byte-pattern. Read moreSourceยงfn mem_as_bytes(&self) -> &[u8] โ
fn mem_as_bytes(&self) -> &[u8] โ
unsafe_slice only.