#[non_exhaustive]pub struct TerminalState { /* private fields */ }Expand description
A terminal: the latest frame, the program’s status and everything the element needs to draw and to send input.
Implementations§
Source§impl TerminalState
impl TerminalState
Sourcepub fn marked_text(&self) -> Option<&str>
pub fn marked_text(&self) -> Option<&str>
Text being composed by an input method, drawn at the cursor.
Source§impl TerminalState
impl TerminalState
Sourcepub fn new(
source: impl FrameSource,
config: TerminalConfig,
window: &mut Window,
cx: &mut Context<'_, Self>,
) -> Self
pub fn new( source: impl FrameSource, config: TerminalConfig, window: &mut Window, cx: &mut Context<'_, Self>, ) -> Self
A terminal fed by source, started at once.
Sourcepub fn local(
options: LocalTerminalOptions,
config: TerminalConfig,
window: &mut Window,
cx: &mut Context<'_, Self>,
) -> Self
pub fn local( options: LocalTerminalOptions, config: TerminalConfig, window: &mut Window, cx: &mut Context<'_, Self>, ) -> Self
A terminal running a local program in a pty.
Sourcepub fn apply(&mut self, snapshot: &TerminalSnapshot, cx: &mut Context<'_, Self>)
pub fn apply(&mut self, snapshot: &TerminalSnapshot, cx: &mut Context<'_, Self>)
Install a snapshot. Public so a host driving its own frames can use the same path as the engine.
Sourcepub fn frame(&self) -> &Arc<TerminalFrame> ⓘ
pub fn frame(&self) -> &Arc<TerminalFrame> ⓘ
The frame being drawn.
Sourcepub fn status(&self) -> &TerminalStatus
pub fn status(&self) -> &TerminalStatus
The program’s status.
Sourcepub fn title(&self) -> &SharedString
pub fn title(&self) -> &SharedString
The title the program set.
Sourcepub fn cwd(&self) -> Option<&Path>
pub fn cwd(&self) -> Option<&Path>
The working directory: the one the shell reported through its integration (OSC 7), or else the foreground process’s.
Sourcepub fn foreground(&self) -> Option<&ForegroundProcess>
pub fn foreground(&self) -> Option<&ForegroundProcess>
The process in the foreground, such as the shell at its prompt or an
editor it started, when the source reports one. A local pty does.
TerminalEvent::ForegroundChanged reports a change.
Sourcepub fn needs_confirm_close(&self) -> bool
pub fn needs_confirm_close(&self) -> bool
Whether closing the terminal would end a program other than the one it started, such as an editor or a build in the foreground, so an application should ask first, as Ghostty does. Without a foreground process, as from a stream, it is whether the cursor is away from a shell prompt.
Sourcepub fn input_backlog(&self) -> usize
pub fn input_backlog(&self) -> usize
Queued input bytes not yet delivered; the busy signal.
Sourcepub fn appearance(&self) -> &TerminalAppearance
pub fn appearance(&self) -> &TerminalAppearance
The appearance.
Sourcepub fn font_size(&self, cx: &App) -> Pixels
pub fn font_size(&self, cx: &App) -> Pixels
The font size the grid draws with: the zoomed size, else the appearance’s, else the theme’s code font size.
Sourcepub fn set_font_size(
&mut self,
size: impl Into<Pixels>,
cx: &mut Context<'_, Self>,
)
pub fn set_font_size( &mut self, size: impl Into<Pixels>, cx: &mut Context<'_, Self>, )
Draw the grid at size, clamped to 1-255 points as Ghostty clamps
it. The grid is measured again at the next paint, which resizes
the program’s grid to fit. Emits TerminalEvent::FontSizeChanged.
Sourcepub fn increase_font_size(
&mut self,
points: impl Into<Pixels>,
cx: &mut Context<'_, Self>,
)
pub fn increase_font_size( &mut self, points: impl Into<Pixels>, cx: &mut Context<'_, Self>, )
Zoom the font in by points, as Ghostty’s increase_font_size.
Sourcepub fn decrease_font_size(
&mut self,
points: impl Into<Pixels>,
cx: &mut Context<'_, Self>,
)
pub fn decrease_font_size( &mut self, points: impl Into<Pixels>, cx: &mut Context<'_, Self>, )
Zoom the font out by points, as Ghostty’s decrease_font_size.
Sourcepub fn reset_font_size(&mut self, cx: &mut Context<'_, Self>)
pub fn reset_font_size(&mut self, cx: &mut Context<'_, Self>)
Go back to the appearance’s font size, or the theme’s.
Sourcepub fn set_appearance(
&mut self,
appearance: TerminalAppearance,
cx: &mut Context<'_, Self>,
)
pub fn set_appearance( &mut self, appearance: TerminalAppearance, cx: &mut Context<'_, Self>, )
Change the appearance. The grid is measured again at the next paint.
Sourcepub fn colors(&self) -> &TerminalColors
pub fn colors(&self) -> &TerminalColors
The colors.
Sourcepub fn set_colors(&mut self, colors: TerminalColors, cx: &mut Context<'_, Self>)
pub fn set_colors(&mut self, colors: TerminalColors, cx: &mut Context<'_, Self>)
Change the colors. The next frame carries them.
Sourcepub fn is_visible(&self) -> bool
pub fn is_visible(&self) -> bool
Whether the terminal is visible.
Sourcepub fn set_visible(&mut self, visible: bool, cx: &mut Context<'_, Self>)
pub fn set_visible(&mut self, visible: bool, cx: &mut Context<'_, Self>)
Hidden terminals keep parsing output but stop producing frames and stop the cursor cadence. Revealing one asks for a current frame.
Sourcepub fn close(&mut self, cx: &mut Context<'_, Self>)
pub fn close(&mut self, cx: &mut Context<'_, Self>)
Stop the program and the source. Idempotent.
Sourcepub fn set_right_click_passthrough(&mut self, passthrough: bool)
pub fn set_right_click_passthrough(&mut self, passthrough: bool)
Whether a right click goes to a program that reports the mouse. It does by default. When it does not, or a modifier is held, or no program reports the mouse, the click is left to the host, such as for a context menu.
Sourcepub fn has_selection(&self) -> bool
pub fn has_selection(&self) -> bool
Whether a non-empty selection exists.
Sourcepub fn selected_text(&self) -> Option<String>
pub fn selected_text(&self) -> Option<String>
The selected text as shown, without scrollback.
Sourcepub fn hovered_link(&self) -> Option<&str>
pub fn hovered_link(&self) -> Option<&str>
The link under the pointer while the platform modifier is held.
Sourcepub fn copy(&mut self, cx: &mut Context<'_, Self>)
pub fn copy(&mut self, cx: &mut Context<'_, Self>)
Copy the selection to the clipboard. A live engine is asked for the text because it can reach scrollback the frame does not carry.
Sourcepub fn select_all(&mut self, cx: &mut Context<'_, Self>)
pub fn select_all(&mut self, cx: &mut Context<'_, Self>)
Select the whole viewport.
Sourcepub fn clear_selection(&mut self, cx: &mut Context<'_, Self>) -> bool
pub fn clear_selection(&mut self, cx: &mut Context<'_, Self>) -> bool
Drop the selection. Returns whether there was one.
Sourcepub fn clear(&mut self, cx: &mut Context<'_, Self>)
pub fn clear(&mut self, cx: &mut Context<'_, Self>)
Send form feed, which clears the screen at most shells.
Sourcepub fn paste_text(
&mut self,
text: impl Into<String>,
cx: &mut Context<'_, Self>,
)
pub fn paste_text( &mut self, text: impl Into<String>, cx: &mut Context<'_, Self>, )
Paste text, bracketed when the program asked for it.
Sourcepub fn send_text(&mut self, text: impl Into<String>, cx: &mut Context<'_, Self>)
pub fn send_text(&mut self, text: impl Into<String>, cx: &mut Context<'_, Self>)
Send raw text to the program.
Sourcepub fn scroll(&mut self, request: ScrollRequest, cx: &mut Context<'_, Self>)
pub fn scroll(&mut self, request: ScrollRequest, cx: &mut Context<'_, Self>)
Scroll the viewport.
Sourcepub fn scroll_pages(&mut self, pages: isize, cx: &mut Context<'_, Self>)
pub fn scroll_pages(&mut self, pages: isize, cx: &mut Context<'_, Self>)
Scroll by whole pages; negative is toward older output.
Sourcepub fn is_scrolled(&self) -> bool
pub fn is_scrolled(&self) -> bool
Whether the viewport is scrolled into history.
Sourcepub fn focus_handle(&self) -> &FocusHandle
pub fn focus_handle(&self) -> &FocusHandle
The focus handle.
Trait Implementations§
Source§impl EntityInputHandler for TerminalState
impl EntityInputHandler for TerminalState
Source§fn bounds_for_range(
&mut self,
_range_utf16: Range<usize>,
element_bounds: Bounds<Pixels>,
_window: &mut Window,
_cx: &mut Context<'_, Self>,
) -> Option<Bounds<Pixels>>
fn bounds_for_range( &mut self, _range_utf16: Range<usize>, element_bounds: Bounds<Pixels>, _window: &mut Window, _cx: &mut Context<'_, Self>, ) -> Option<Bounds<Pixels>>
The candidate window follows the cursor cell.
Source§fn text_for_range(
&mut self,
range: Range<usize>,
adjusted: &mut Option<Range<usize>>,
_window: &mut Window,
_cx: &mut Context<'_, Self>,
) -> Option<String>
fn text_for_range( &mut self, range: Range<usize>, adjusted: &mut Option<Range<usize>>, _window: &mut Window, _cx: &mut Context<'_, Self>, ) -> Option<String>
InputHandler::text_for_range for detailsSource§fn selected_text_range(
&mut self,
_ignore_disabled_input: bool,
_window: &mut Window,
_cx: &mut Context<'_, Self>,
) -> Option<UTF16Selection>
fn selected_text_range( &mut self, _ignore_disabled_input: bool, _window: &mut Window, _cx: &mut Context<'_, Self>, ) -> Option<UTF16Selection>
InputHandler::selected_text_range for detailsSource§fn marked_text_range(
&self,
_window: &mut Window,
_cx: &mut Context<'_, Self>,
) -> Option<Range<usize>>
fn marked_text_range( &self, _window: &mut Window, _cx: &mut Context<'_, Self>, ) -> Option<Range<usize>>
InputHandler::marked_text_range for detailsSource§fn unmark_text(&mut self, _window: &mut Window, cx: &mut Context<'_, Self>)
fn unmark_text(&mut self, _window: &mut Window, cx: &mut Context<'_, Self>)
InputHandler::unmark_text for detailsSource§fn replace_text_in_range(
&mut self,
_range: Option<Range<usize>>,
text: &str,
_window: &mut Window,
cx: &mut Context<'_, Self>,
)
fn replace_text_in_range( &mut self, _range: Option<Range<usize>>, text: &str, _window: &mut Window, cx: &mut Context<'_, Self>, )
InputHandler::replace_text_in_range for detailsSource§fn replace_and_mark_text_in_range(
&mut self,
_range: Option<Range<usize>>,
new_text: &str,
_new_selected_range: Option<Range<usize>>,
_window: &mut Window,
cx: &mut Context<'_, Self>,
)
fn replace_and_mark_text_in_range( &mut self, _range: Option<Range<usize>>, new_text: &str, _new_selected_range: Option<Range<usize>>, _window: &mut Window, cx: &mut Context<'_, Self>, )
InputHandler::replace_and_mark_text_in_range for detailsSource§fn character_index_for_point(
&mut self,
_point: Point<Pixels>,
_window: &mut Window,
_cx: &mut Context<'_, Self>,
) -> Option<usize>
fn character_index_for_point( &mut self, _point: Point<Pixels>, _window: &mut Window, _cx: &mut Context<'_, Self>, ) -> Option<usize>
InputHandler::character_index_for_point for detailsSource§fn paste(
&mut self,
item: ClipboardItem,
window: &mut Window,
cx: &mut Context<'_, Self>,
)
fn paste( &mut self, item: ClipboardItem, window: &mut Window, cx: &mut Context<'_, Self>, )
InputHandler::paste for detailsSource§fn selection_bounds_for_range(
&mut self,
_range_utf16: Range<usize>,
_element_bounds: Bounds<Pixels>,
_window: &mut Window,
_cx: &mut Context<'_, Self>,
) -> Vec<Bounds<Pixels>>
fn selection_bounds_for_range( &mut self, _range_utf16: Range<usize>, _element_bounds: Bounds<Pixels>, _window: &mut Window, _cx: &mut Context<'_, Self>, ) -> Vec<Bounds<Pixels>>
InputHandler::selection_bounds_for_range for details.Source§fn set_selected_text_range(
&mut self,
_range_utf16: Range<usize>,
_window: &mut Window,
_cx: &mut Context<'_, Self>,
)
fn set_selected_text_range( &mut self, _range_utf16: Range<usize>, _window: &mut Window, _cx: &mut Context<'_, Self>, )
InputHandler::set_selected_text_range for detailsSource§fn text_length_utf16(
&mut self,
_window: &mut Window,
_cx: &mut Context<'_, Self>,
) -> Option<usize>
fn text_length_utf16( &mut self, _window: &mut Window, _cx: &mut Context<'_, Self>, ) -> Option<usize>
InputHandler::text_length_utf16 for detailsSource§fn accepts_text_input(
&self,
_window: &mut Window,
_cx: &mut Context<'_, Self>,
) -> bool
fn accepts_text_input( &self, _window: &mut Window, _cx: &mut Context<'_, Self>, ) -> bool
InputHandler::accepts_text_input for detailsSource§fn text_input_configuration(
&mut self,
_window: &mut Window,
_cx: &mut Context<'_, Self>,
) -> TextInputConfiguration
fn text_input_configuration( &mut self, _window: &mut Window, _cx: &mut Context<'_, Self>, ) -> TextInputConfiguration
InputHandler::text_input_configuration for detailsSource§fn text_input_editable_range(
&mut self,
_window: &mut Window,
_cx: &mut Context<'_, Self>,
) -> Option<Range<usize>>
fn text_input_editable_range( &mut self, _window: &mut Window, _cx: &mut Context<'_, Self>, ) -> Option<Range<usize>>
InputHandler::text_input_editable_range for detailsimpl EventEmitter<TerminalEvent> for TerminalState
Source§impl Focusable for TerminalState
impl Focusable for TerminalState
Source§fn focus_handle(&self, _: &App) -> FocusHandle
fn focus_handle(&self, _: &App) -> FocusHandle
Source§impl Render for TerminalState
impl Render for TerminalState
Auto Trait Implementations§
impl !RefUnwindSafe for TerminalState
impl !Send for TerminalState
impl !Sync for TerminalState
impl !UnwindSafe for TerminalState
impl Freeze for TerminalState
impl Unpin for TerminalState
impl UnsafeUnpin for TerminalState
Blanket Implementations§
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.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more