pub struct Session<T = Pty> { /* private fields */ }Expand description
Drives terminal state and child I/O from a nonblocking PTY.
Implementations§
Source§impl Session<Pty>
impl Session<Pty>
Sourcepub fn interests(&self) -> SessionInterests<'_>
pub fn interests(&self) -> SessionInterests<'_>
Current interests for a level-triggered event loop. Refresh after dispatch.
Sourcepub fn dispatch_ready(
&mut self,
ready: SessionReady,
) -> Result<Option<WaitOutcome>>
pub fn dispatch_ready( &mut self, ready: SessionReady, ) -> Result<Option<WaitOutcome>>
Services readiness, buffered work, or an expired presentation deadline without waiting. A child exit is delivered before PTY work when both are ready.
Sourcepub fn wait_and_pump(
&mut self,
timeout: Option<Duration>,
) -> Result<WaitOutcome>
pub fn wait_and_pump( &mut self, timeout: Option<Duration>, ) -> Result<WaitOutcome>
Pumps on PTY readiness or at the presentation deadline and reports child exit once.
A zero timeout checks readiness without waiting. None waits without a caller limit.
Finished follows both child exit notification and drained PTY output.
Source§impl Session<Pty>
impl Session<Pty>
Sourcepub fn spawn(command: Command, size: PtySize, palette: Palette) -> Result<Self>
pub fn spawn(command: Command, size: PtySize, palette: Palette) -> Result<Self>
Starts a session with a child exit monitor on Linux 5.3 or later.
Sourcepub fn resize(&mut self, size: PtySize) -> Result<()>
pub fn resize(&mut self, size: PtySize) -> Result<()>
Commits a PTY resize and reflows its screen before publishing VT geometry.
A pending input chunk returns WouldBlock; pump it before retrying.
Sourcepub fn try_wait(&mut self) -> Result<Option<ExitStatus>>
pub fn try_wait(&mut self) -> Result<Option<ExitStatus>>
Polls child status independently of whether PTY output has reached EOF.
Sourcepub fn foreground_process_group(&self) -> Option<u32>
pub fn foreground_process_group(&self) -> Option<u32>
Returns the foreground process group ID attached to the PTY, if any.
Source§impl<T: Read + Write> Session<T>
impl<T: Read + Write> Session<T>
pub fn screen(&self) -> &Screen
pub fn toggle_prompt_bookmark( &mut self, chronological_row: usize, ) -> Option<bool>
pub fn geometry(&self) -> GridGeometry
Sourcepub fn presentation_screen(&self) -> Option<&Screen>
pub fn presentation_screen(&self) -> Option<&Screen>
The live screen when it is ready for presentation.
Sourcepub fn presentation_frame(&self) -> Option<PresentationFrame<'_>>
pub fn presentation_frame(&self) -> Option<PresentationFrame<'_>>
Borrows the visible viewport and its rendition state when presentation is ready.
Sourcepub fn presentation_deadline(&self) -> Option<Instant>
pub fn presentation_deadline(&self) -> Option<Instant>
When to pump again for presentation work, even if the PTY is idle.
pub fn processor(&self) -> &Processor
pub fn graphics_image(&self, id: u32) -> Option<&GraphicsImage>
pub fn take_notifications(&mut self) -> TerminalNotifications<'_>
pub fn set_theme(&mut self, palette: &Palette, scheme: Option<ColorScheme>)
pub fn set_default_cursor_appearance( &mut self, shape: CursorShape, blinking: bool, )
Sourcepub fn set_history_limits(
&mut self,
limits: HistoryLimits,
) -> Result<(), StorageError>
pub fn set_history_limits( &mut self, limits: HistoryLimits, ) -> Result<(), StorageError>
Updates primary scrollback limits and clamps the visible history.
Sourcepub fn scroll_history(&mut self, steps: isize) -> bool
pub fn scroll_history(&mut self, steps: isize) -> bool
Moves the local viewport. Positive steps go toward older rows.
Sourcepub fn follow_output(&mut self)
pub fn follow_output(&mut self)
Returns the primary viewport to the live buffer.
Sourcepub fn collect_styles(
&mut self,
retained: impl IntoIterator<Item = StyleId>,
) -> Result<usize, StyleError>
pub fn collect_styles( &mut self, retained: impl IntoIterator<Item = StyleId>, ) -> Result<usize, StyleError>
Reclaims unreachable styles while preserving IDs held by the caller.
pub fn wants_read(&self) -> bool
pub fn wants_write(&self) -> bool
Sourcepub fn is_finished(&self) -> bool
pub fn is_finished(&self) -> bool
Returns whether PTY output reached EOF and VT finalization succeeded.
Sourcepub fn queue_input(&mut self, bytes: &[u8]) -> Result<()>
pub fn queue_input(&mut self, bytes: &[u8]) -> Result<()>
Accepts a complete input frame when earlier input and replies have drained.
Sourcepub fn queue_key(
&mut self,
key: Key,
modifiers: Modifiers,
repeat: bool,
) -> Result<bool>
pub fn queue_key( &mut self, key: Key, modifiers: Modifiers, repeat: bool, ) -> Result<bool>
Queues a key using current VT modes. Returns false for a suppressed event.
Sourcepub fn queue_character(
&mut self,
character: char,
modifiers: Modifiers,
repeat: bool,
) -> Result<bool>
pub fn queue_character( &mut self, character: char, modifiers: Modifiers, repeat: bool, ) -> Result<bool>
Queues a layout-resolved character with its Control and Alt modifiers.
Sourcepub fn queue_key_event(&mut self, event: KeyEvent<'_>) -> Result<bool>
pub fn queue_key_event(&mut self, event: KeyEvent<'_>) -> Result<bool>
Queues a rich keyboard event using active Kitty keyboard protocol or legacy encoding.
Sourcepub fn queue_focus(&mut self, focused: bool) -> Result<bool>
pub fn queue_focus(&mut self, focused: bool) -> Result<bool>
Queues a focus transition when focus reporting is enabled.
Sourcepub fn mouse_input(
&mut self,
event: MouseEvent,
cell: CellPosition,
pixel: Option<PixelPosition>,
modifiers: Modifiers,
) -> Result<MouseInputOutcome>
pub fn mouse_input( &mut self, event: MouseEvent, cell: CellPosition, pixel: Option<PixelPosition>, modifiers: Modifiers, ) -> Result<MouseInputOutcome>
Routes a pointer event to the primary viewport or the PTY. A historical viewport handles vertical wheel steps locally. Pixel reports require a position inside the committed content size.
Sourcepub fn mouse_input_at(
&mut self,
event: MouseEvent,
pixel: PixelPosition,
modifiers: Modifiers,
) -> Result<MouseInputOutcome>
pub fn mouse_input_at( &mut self, event: MouseEvent, pixel: PixelPosition, modifiers: Modifiers, ) -> Result<MouseInputOutcome>
Routes a pixel hit in the committed grid through the current mouse mode.
Sourcepub fn queue_paste(&mut self, payload: &str) -> Result<()>
pub fn queue_paste(&mut self, payload: &str) -> Result<()>
Queues up to MAX_PASTE_BYTES of text with the current framing.
The entire paste precedes later replies.
Trait Implementations§
Auto Trait Implementations§
impl<T = Pty> !Freeze for Session<T>
impl<T = Pty> !RefUnwindSafe for Session<T>
impl<T = Pty> !UnwindSafe for Session<T>
impl<T> Forget for Session<T>
impl<T> Move for Session<T>
impl<T> Send for Session<T>where
T: Send,
I32NotAllOnes: Send,
NonZero<u32>: Send,
RawVecInner: Send,
BoxRaw<SizedRows>: Send,
Atomic<u64>: Send,
Arc<Image>: Send,
RawTable<((u32, u32), usize)>: Send,
RawTable<(u64, Option<[i64; 2]>)>: Send,
RawTable<(u64, usize)>: Send,
Arc<SizedBudget>: Send,
Weak<SizedBlock>: Send,
RawTable<(StyleKey, StyleId)>: Send,
RawTable<(Hyperlink, HyperlinkId)>: Send,
RawTable<(ImageKey, StoredImage)>: Send,
BoxRaw<InflateState>: Send,
&'static [u8]: Send,
Vec<u8>: Send,
Arc<dyn TransformExecutor<u8> + Sync + Send>: Send,
Arc<dyn TransformExecutor<u16> + Sync + Send>: Send,
Arc<Vec<u8>>: Send,
Arc<NarrowTransform>: Send,
Arc<HdrTransform>: Send,
OnceLock<Arc<FrameBudget>>: Send,
BoxRaw<Animation>: Send,
RawTable<(ImageKey, ())>: Send,
NodeRef<Owned, Instant, Vec<ImageKey>, LeafOrInternal>: Send,
BoxRaw<(Instant, Vec<ImageKey>)>: Send,
BoxRaw<FeatureReply>: Send,
NonZero<u64>: Send,
RawTable<(u64, ())>: Send,
impl<T> Sync for Session<T>where
T: Sync,
I32NotAllOnes: Sync,
NonZero<u32>: Sync,
RawVecInner: Sync,
BoxRaw<SizedRows>: Sync,
Atomic<u64>: Sync,
Arc<Image>: Sync,
RawTable<((u32, u32), usize)>: Sync,
RawTable<(u64, Option<[i64; 2]>)>: Sync,
RawTable<(u64, usize)>: Sync,
Arc<SizedBudget>: Sync,
Weak<SizedBlock>: Sync,
RawTable<(StyleKey, StyleId)>: Sync,
RawTable<(Hyperlink, HyperlinkId)>: Sync,
RawTable<(ImageKey, StoredImage)>: Sync,
BoxRaw<InflateState>: Sync,
Vec<u8>: Sync,
Arc<dyn TransformExecutor<u8> + Sync + Send>: Sync,
Arc<dyn TransformExecutor<u16> + Sync + Send>: Sync,
Arc<Vec<u8>>: Sync,
Arc<NarrowTransform>: Sync,
Arc<HdrTransform>: Sync,
OnceLock<Arc<FrameBudget>>: Sync,
BoxRaw<Animation>: Sync,
RawTable<(ImageKey, ())>: Sync,
NodeRef<Owned, Instant, Vec<ImageKey>, LeafOrInternal>: Sync,
BoxRaw<(Instant, Vec<ImageKey>)>: Sync,
BoxRaw<FeatureReply>: Sync,
NonZero<u64>: Sync,
RawTable<(u64, ())>: Sync,
impl<T> Unpin for Session<T>where
T: Unpin,
I32NotAllOnes: Unpin,
NonZero<u32>: Unpin,
*const u8 is !null: Unpin,
Box<SizedRows>: Unpin,
Align8<u64>: Unpin,
Arc<Image>: Unpin,
Arc<SizedBudget>: Unpin,
*const ArcInner<SizedBlock> is !null: Unpin,
Box<Animation>: Unpin,
*const ArcInner<Image> is !null: Unpin,
Box<InflateState>: Unpin,
&'static [u8]: Unpin,
Vec<u8>: Unpin,
Arc<dyn TransformExecutor<u8> + Sync + Send>: Unpin,
Arc<dyn TransformExecutor<u16> + Sync + Send>: Unpin,
Arc<Vec<u8>>: Unpin,
Arc<NarrowTransform>: Unpin,
Arc<HdrTransform>: Unpin,
Align4<u32>: Unpin,
Arc<FrameBudget>: Unpin,
*const LeafNode<Instant, Vec<ImageKey>> is !null: Unpin,
Box<(Instant, Vec<ImageKey>)>: Unpin,
Box<FeatureReply>: Unpin,
NonZero<u64>: Unpin,
impl<T> UnsafeUnpin for Session<T>where
T: UnsafeUnpin,
I32NotAllOnes: UnsafeUnpin,
NonZeroU32Inner: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<Row>: UnsafeUnpin,
PhantomData<GraphicsPlacement>: UnsafeUnpin,
PhantomData<((u32, u32), usize)>: UnsafeUnpin,
PhantomData<(u64, Option<[i64; 2]>)>: UnsafeUnpin,
PhantomData<(u64, usize)>: UnsafeUnpin,
PhantomData<u16>: UnsafeUnpin,
PhantomData<OrphanedImage>: UnsafeUnpin,
PhantomData<ImageKey>: UnsafeUnpin,
PhantomData<Entry>: UnsafeUnpin,
PhantomData<u64>: UnsafeUnpin,
*const ArcInner<SizedBudget> is !null: UnsafeUnpin,
PhantomData<ArcInner<SizedBudget>>: UnsafeUnpin,
*const ArcInner<SizedBlock> is !null: UnsafeUnpin,
PhantomData<(StyleKey, StyleId)>: UnsafeUnpin,
PhantomData<Slot>: UnsafeUnpin,
PhantomData<(Hyperlink, HyperlinkId)>: UnsafeUnpin,
PhantomData<Slot>: UnsafeUnpin,
PhantomData<Vec<u8>>: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<(ImageKey, StoredImage)>: UnsafeUnpin,
PhantomData<NumberedImage>: UnsafeUnpin,
*const InflateState is !null: UnsafeUnpin,
PhantomData<InflateState>: UnsafeUnpin,
&'static [u8]: UnsafeUnpin,
Vec<u8>: UnsafeUnpin,
*const ArcInner<dyn TransformExecutor<u8> + Sync + Send> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn TransformExecutor<u8> + Sync + Send>>: UnsafeUnpin,
*const ArcInner<dyn TransformExecutor<u16> + Sync + Send> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn TransformExecutor<u16> + Sync + Send>>: UnsafeUnpin,
*const ArcInner<Vec<u8>> is !null: UnsafeUnpin,
PhantomData<ArcInner<Vec<u8>>>: UnsafeUnpin,
*const ArcInner<NarrowTransform> is !null: UnsafeUnpin,
PhantomData<ArcInner<NarrowTransform>>: UnsafeUnpin,
*const ArcInner<HdrTransform> is !null: UnsafeUnpin,
PhantomData<ArcInner<HdrTransform>>: UnsafeUnpin,
Align4<u32>: UnsafeUnpin,
*const ArcInner<FrameBudget> is !null: UnsafeUnpin,
PhantomData<ArcInner<FrameBudget>>: UnsafeUnpin,
PhantomData<Arc<FrameBudget>>: UnsafeUnpin,
*const Animation is !null: UnsafeUnpin,
PhantomData<Animation>: UnsafeUnpin,
PhantomData<(ImageKey, ())>: UnsafeUnpin,
*const LeafNode<Instant, Vec<ImageKey>> is !null: UnsafeUnpin,
PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin,
PhantomData<Box<(Instant, Vec<ImageKey>)>>: UnsafeUnpin,
PhantomData<Candidate>: UnsafeUnpin,
PhantomData<u32>: UnsafeUnpin,
*const FeatureReply is !null: UnsafeUnpin,
PhantomData<FeatureReply>: UnsafeUnpin,
PhantomData<Option<RowRevision>>: UnsafeUnpin,
PhantomData<(u64, ())>: UnsafeUnpin,
PhantomData<usize>: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> AsSource for Twhere
T: AsFd,
impl<T> AsSource for Twhere
T: AsFd,
Source§fn source(&self) -> BorrowedFd<'_>
fn source(&self) -> BorrowedFd<'_>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.