Skip to main content

Session

Struct Session 

Source
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>

Source

pub fn interests(&self) -> SessionInterests<'_>

Current interests for a level-triggered event loop. Refresh after dispatch.

Source

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.

Source

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>

Source

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.

Source

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.

Source

pub fn try_wait(&mut self) -> Result<Option<ExitStatus>>

Polls child status independently of whether PTY output has reached EOF.

Source

pub fn child_id(&self) -> u32

Returns the direct child process ID of this PTY session.

Source

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>

Source

pub fn screen(&self) -> &Screen

Source

pub fn toggle_prompt_bookmark( &mut self, chronological_row: usize, ) -> Option<bool>

Source

pub fn geometry(&self) -> GridGeometry

Source

pub fn presentation_screen(&self) -> Option<&Screen>

The live screen when it is ready for presentation.

Source

pub fn presentation_frame(&self) -> Option<PresentationFrame<'_>>

Borrows the visible viewport and its rendition state when presentation is ready.

Source

pub fn presentation_deadline(&self) -> Option<Instant>

When to pump again for presentation work, even if the PTY is idle.

Source

pub fn processor(&self) -> &Processor

Source

pub fn graphics_image(&self, id: u32) -> Option<&GraphicsImage>

Source

pub fn take_notifications(&mut self) -> TerminalNotifications<'_>

Source

pub fn set_theme(&mut self, palette: &Palette, scheme: Option<ColorScheme>)

Source

pub fn set_default_cursor_appearance( &mut self, shape: CursorShape, blinking: bool, )

Source

pub fn set_history_limits( &mut self, limits: HistoryLimits, ) -> Result<(), StorageError>

Updates primary scrollback limits and clamps the visible history.

Source

pub fn scroll_history(&mut self, steps: isize) -> bool

Moves the local viewport. Positive steps go toward older rows.

Source

pub fn follow_output(&mut self)

Returns the primary viewport to the live buffer.

Source

pub fn collect_styles( &mut self, retained: impl IntoIterator<Item = StyleId>, ) -> Result<usize, StyleError>

Reclaims unreachable styles while preserving IDs held by the caller.

Source

pub fn wants_read(&self) -> bool

Source

pub fn wants_write(&self) -> bool

Source

pub fn is_finished(&self) -> bool

Returns whether PTY output reached EOF and VT finalization succeeded.

Source

pub fn queue_input(&mut self, bytes: &[u8]) -> Result<()>

Accepts a complete input frame when earlier input and replies have drained.

Source

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.

Source

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.

Source

pub fn queue_key_event(&mut self, event: KeyEvent<'_>) -> Result<bool>

Queues a rich keyboard event using active Kitty keyboard protocol or legacy encoding.

Source

pub fn queue_focus(&mut self, focused: bool) -> Result<bool>

Queues a focus transition when focus reporting is enabled.

Source

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.

Source

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.

Source

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.

Source

pub fn pump(&mut self) -> Result<()>

Writes at most 16 KiB of paste data and reads at most one chunk. Use level-triggered notifications and also pump on hangup.

Trait Implementations§

Source§

impl<T: AsFd> AsFd for Session<T>

Source§

fn as_fd(&self) -> BorrowedFd<'_>

Borrows the file descriptor. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AsSource for T
where T: AsFd,

Source§

fn source(&self) -> BorrowedFd<'_>

Returns the borrowed file descriptor.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send> ⓘ

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more