Skip to main content

Renderer

Struct Renderer 

Source
pub struct Renderer {
Show 53 fields pub device: Device, pub queue: Queue, pub surface: Surface<'static>, pub surface_config: SurfaceConfiguration, pub rect_pipeline: RectPipeline, pub font_system: FontSystem, pub swash_cache: SwashCache, pub glyph_cache: Cache, pub glyph_viewport: Viewport, pub text_atlas: TextAtlas, pub text_renderer: TextRenderer, pub viewport: Viewport, pub font_size: f32, pub theme: Theme, pub scale_factor: f32, pub blocks: Vec<Block>, pub input_text: String, pub input_cursor: usize, pub input_all_selected: bool, pub input_mode_prefix: String, pub input_preedit: String, pub input_ghost: String, pub input_caret_rect: [f32; 4], pub selected_block: Option<usize>, pub selected_sub_output: bool, pub input_running: bool, pub tui_active: bool, pub tui_cells: Vec<Vec<TuiCell>>, pub tui_cursor: (usize, usize), pub tui_cursor_shape: u8, pub running_block_idx: Option<usize>, pub spinner_frame: u8, pub context_pills: Vec<String>, pub open_dropdown: Option<(usize, Vec<String>, Option<usize>)>, pub pill_rects: Vec<[f32; 4]>, pub link_rects: Vec<([f32; 4], String)>, pub dropdown_item_rects: Vec<[f32; 4]>, pub command_palette: Option<Vec<(String, String)>>, pub cmd_palette_hovered: Option<usize>, pub cmd_palette_rects: Vec<[f32; 4]>, pub mode_label: String, pub mode_pill_rect: [f32; 4], pub agent_model: String, pub agent_running_tool: HashMap<AgentId, String>, pub user_expanded: HashSet<BlockId>, pub tab_labels: Vec<String>, pub active_tab: usize, pub tab_rects: Vec<[f32; 4]>, pub search_match_blocks: Vec<usize>, pub search_current_match: Option<usize>, pub text_selection: Option<TextSelection>, pub selecting: bool, pub qr_overlays: HashMap<BlockId, QrBitmap>, /* private fields */
}

Fields§

§device: Device§queue: Queue§surface: Surface<'static>§surface_config: SurfaceConfiguration§rect_pipeline: RectPipeline§font_system: FontSystem§swash_cache: SwashCache§glyph_cache: Cache§glyph_viewport: Viewport§text_atlas: TextAtlas§text_renderer: TextRenderer§viewport: Viewport§font_size: f32

Logical font size in points/px. Multiply by scale_factor for physical pixels.

§theme: Theme

Active color palette. All drawing functions consult this; swap with set_theme.

§scale_factor: f32

HiDPI scale factor — 2.0 on Retina, 1.0 on standard displays.

§blocks: Vec<Block>§input_text: String§input_cursor: usize§input_all_selected: bool§input_mode_prefix: String§input_preedit: String

Active IME preedit string (displayed at the caret in self.theme.sky with an underline until the input method commits). Synced from App.

§input_ghost: String

Ghost suggestion suffix from history — rendered in muted color after the cursor.

§input_caret_rect: [f32; 4]

Last known caret rect [x, y, w, h] in physical pixels — used by the host App to position the IME candidate window via set_ime_cursor_area.

§selected_block: Option<usize>

Selected block index — highlighted on screen, text copyable via Cmd+C.

§selected_sub_output: bool

For ShellCommand blocks: true = output panel selected, false = cmd bar selected.

§input_running: bool

True while a command is running — input bar shows a “running” indicator.

§tui_active: bool§tui_cells: Vec<Vec<TuiCell>>§tui_cursor: (usize, usize)§tui_cursor_shape: u8

Cursor shape requested by the TUI app (0=block, 1=beam, 2=underline).

§running_block_idx: Option<usize>

Index of the currently running ShellCommand block (if any). Its content area renders live TermGrid cells instead of stored output.

§spinner_frame: u8§context_pills: Vec<String>

Labels for the 3 context pills: [conda, node, dir].

§open_dropdown: Option<(usize, Vec<String>, Option<usize>)>

Currently open dropdown: (pill_idx, items, hovered_idx).

§pill_rects: Vec<[f32; 4]>

Bounding rects [x, y, w, h] for each pill (written during layout).

§link_rects: Vec<([f32; 4], String)>

OSC 8 hyperlink hit rects: ([x,y,w,h], url). Rebuilt each frame.

§dropdown_item_rects: Vec<[f32; 4]>

Bounding rects [x, y, w, h] per dropdown item (written during layout).

§command_palette: Option<Vec<(String, String)>>

Filtered command list: (usage, description). Set by App each frame.

§cmd_palette_hovered: Option<usize>§cmd_palette_rects: Vec<[f32; 4]>

Hit-test rects for each palette row [x, y, w, h].

§mode_label: String§mode_pill_rect: [f32; 4]§agent_model: String

Active agent model name — shown as a pill in the top-right of the input bar.

§agent_running_tool: HashMap<AgentId, String>

Currently executing tool per agent: agent_id → tool_name. Set by App when ToolCallRequested arrives; cleared on TextDelta or TurnComplete.

§user_expanded: HashSet<BlockId>

Blocks whose default-collapsed state has been overridden by the user. A block_id in this set is always shown expanded regardless of collapsed_default.

§tab_labels: Vec<String>

Labels for each tab. Strip is shown only when tab_labels.len() >= 2.

§active_tab: usize

Index of the currently-active tab.

§tab_rects: Vec<[f32; 4]>

Hit rects [x, y, w, h] per tab, written during tab-strip layout.

§search_match_blocks: Vec<usize>

Indices of blocks that contain a search match — painted with a translucent yellow overlay.

§search_current_match: Option<usize>

Index (within search_match_blocks) of the currently focused match — painted more opaque.

§text_selection: Option<TextSelection>

Drag-based text selection (cell range for shell output, cursor range for agent text).

§selecting: bool

True while the user is mid-drag (mouse down + dragging).

§qr_overlays: HashMap<BlockId, QrBitmap>

Blocks that render as a QR bitmap instead of text — rect-painted directly so line-height spacing doesn’t shatter the modules. Key is the block id of a Text block registered via set_qr_block; value is the module grid.

Implementations§

Source§

impl Renderer

Source

pub async fn new(window: Arc<Window>) -> Result<Self>

Source

pub fn resize(&mut self, width: u32, height: u32)

Source

pub fn tab_bar_height_phys(&self) -> f32

Physical-pixel height of the tab strip. Zero when fewer than 2 tabs or when a TUI app is active.

Source

pub fn tab_hit(&self, px: f32, py: f32) -> Option<usize>

Returns the tab index that was clicked at (px, py), if any.

Source

pub fn set_scale_factor(&mut self, scale_factor: f64)

Source

pub fn block_hit_at(&self, screen_y: f32) -> Option<(usize, bool)>

Return the block and sub-region hit by a click at screen_y. Returns (block_index, is_output_panel). For ShellCommand blocks the cmd bar and output panel are separate hit regions.

Source

pub fn block_index_at(&self, screen_y: f32) -> Option<usize>

Plain block index hit-test (ignores sub-regions).

Source

pub fn begin_text_selection(&mut self, phys_x: f32, phys_y: f32) -> bool

Mouse-down: start a selection at (phys_x, phys_y). Returns true if a selection began.

Source

pub fn update_text_selection(&mut self, phys_x: f32, phys_y: f32)

Mouse-drag: extend the active selection to (phys_x, phys_y). No-op if not selecting.

Source

pub fn end_text_selection(&mut self)

Mouse-up: stop tracking drag motion but keep the selection until next click/clear.

Source

pub fn clear_text_selection(&mut self)

Source

pub fn set_qr_block(&mut self, block_id: BlockId, qr: QrBitmap)

Register a Text block to be rendered as a QR bitmap (solid rect modules, no glyphs). The caller is responsible for pushing a Text block first and then calling this with its id.

Source

pub fn has_text_selection(&self) -> bool

True when there’s a non-empty selection (anchor != cursor).

Source

pub fn selected_text(&self) -> Option<String>

Extract the selected text as a string. Returns None if no non-empty selection.

Source

pub fn mode_pill_hit(&self, px: f32, py: f32) -> bool

Returns true if the mode switcher pill at the bottom-left was clicked.

Source

pub fn pill_hit(&self, px: f32, py: f32) -> Option<usize>

Returns the index of the pill that was clicked (0=conda, 1=node, 2=dir).

Source

pub fn cmd_palette_hit(&self, px: f32, py: f32) -> Option<usize>

Returns the index of the command palette row that was clicked.

Source

pub fn dropdown_hit(&self, px: f32, py: f32) -> Option<usize>

Returns the index of the dropdown item that was clicked.

Source

pub fn dropdown_hover_at(&self, px: f32, py: f32) -> Option<usize>

Returns the index of the dropdown item hovered at the given position.

Source

pub fn scroll(&mut self, delta: f32)

Source

pub fn scroll_to_bottom(&mut self)

Source

pub fn terminal_cell_size(&self) -> (f32, f32)

Physical size of one terminal cell based on actual font metrics. Derived from max_ascent + max_descent of shaped text so that box-drawing and block-element characters tile without gaps between rows.

Source

pub fn bar_height_phys(&self) -> f32

Physical height of the input bar in pixels.

Source

pub fn surface_size(&self) -> (f32, f32)

Physical (width, height) of the surface in pixels.

Source

pub fn scroll_input(&mut self, delta: f32)

Scroll the input text viewport by delta physical pixels (positive = down / toward newer text). Clamped between 0 and max scroll. Call this when the user scrolls over the input bar.

Source

pub fn snap_input_scroll_to_cursor(&mut self)

Snap input scroll back so the cursor is visible (call after any cursor-moving keystroke).

Source

pub fn cell_at_phys(&self, px: f32, py: f32) -> Option<(u32, u32)>

Convert physical-pixel coords inside the TUI grid into 1-based (col, row) for SGR mouse reporting. Returns None if the point is outside the grid.

Source

pub fn tui_grid_size(&self) -> (u16, u16)

Terminal grid dimensions for TUI fullscreen mode (bar hidden — full window).

Source

pub fn terminal_grid_size(&self) -> (u16, u16)

Terminal grid dimensions (cols × rows) that fit in the usable area above the input bar. This is the source of truth for PTY sizing on spawn and resize. NOTE: viewport.height is already set to (surface_height - bar_height_phys) by resize(), so we use it directly — do NOT subtract bar_height again here.

Source

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

Source

pub fn set_theme(&mut self, theme: Theme)

Swap the active theme; invalidates color-baked glyph caches.

Source

pub fn toggle_collapsed(&mut self, block_id: &BlockId)

Toggle a tool block open/closed.

Source

pub fn block_top_y(&self, idx: usize) -> Option<f32>

Content-space Y (top) of block index idx, using the layout cache. Returns None if idx out of range.

Source

pub fn invalidate_block_caches(&mut self)

Invalidate all block-related caches. Must be called after replacing self.blocks externally (e.g. tab switch) so the layout, glyph, and label caches rebuild from the new block set.

Auto Trait Implementations§

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> 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<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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

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

Source§

impl<T> WasmNotSendSync for T

Source§

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