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: f32Logical font size in points/px. Multiply by scale_factor for physical pixels.
theme: ThemeActive color palette. All drawing functions consult this; swap with set_theme.
scale_factor: f32HiDPI 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: StringActive IME preedit string (displayed at the caret in self.theme.sky
with an underline until the input method commits). Synced from App.
input_ghost: StringGhost 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: boolFor ShellCommand blocks: true = output panel selected, false = cmd bar selected.
input_running: boolTrue 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: u8Cursor 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: StringActive 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: usizeIndex 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: boolTrue 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
impl Renderer
pub async fn new(window: Arc<Window>) -> Result<Self>
pub fn resize(&mut self, width: u32, height: u32)
Sourcepub fn tab_bar_height_phys(&self) -> f32
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.
Sourcepub fn tab_hit(&self, px: f32, py: f32) -> Option<usize>
pub fn tab_hit(&self, px: f32, py: f32) -> Option<usize>
Returns the tab index that was clicked at (px, py), if any.
pub fn set_scale_factor(&mut self, scale_factor: f64)
Sourcepub fn block_hit_at(&self, screen_y: f32) -> Option<(usize, bool)>
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.
Sourcepub fn block_index_at(&self, screen_y: f32) -> Option<usize>
pub fn block_index_at(&self, screen_y: f32) -> Option<usize>
Plain block index hit-test (ignores sub-regions).
Sourcepub fn begin_text_selection(&mut self, phys_x: f32, phys_y: f32) -> bool
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.
Sourcepub fn update_text_selection(&mut self, phys_x: f32, phys_y: f32)
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.
Sourcepub fn end_text_selection(&mut self)
pub fn end_text_selection(&mut self)
Mouse-up: stop tracking drag motion but keep the selection until next click/clear.
pub fn clear_text_selection(&mut self)
Sourcepub fn set_qr_block(&mut self, block_id: BlockId, qr: QrBitmap)
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.
Sourcepub fn has_text_selection(&self) -> bool
pub fn has_text_selection(&self) -> bool
True when there’s a non-empty selection (anchor != cursor).
Sourcepub fn selected_text(&self) -> Option<String>
pub fn selected_text(&self) -> Option<String>
Extract the selected text as a string. Returns None if no non-empty selection.
Sourcepub fn mode_pill_hit(&self, px: f32, py: f32) -> bool
pub fn mode_pill_hit(&self, px: f32, py: f32) -> bool
Returns true if the mode switcher pill at the bottom-left was clicked.
Sourcepub fn pill_hit(&self, px: f32, py: f32) -> Option<usize>
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).
Sourcepub fn cmd_palette_hit(&self, px: f32, py: f32) -> Option<usize>
pub fn cmd_palette_hit(&self, px: f32, py: f32) -> Option<usize>
Returns the index of the command palette row that was clicked.
Sourcepub fn dropdown_hit(&self, px: f32, py: f32) -> Option<usize>
pub fn dropdown_hit(&self, px: f32, py: f32) -> Option<usize>
Returns the index of the dropdown item that was clicked.
Sourcepub fn dropdown_hover_at(&self, px: f32, py: f32) -> Option<usize>
pub fn dropdown_hover_at(&self, px: f32, py: f32) -> Option<usize>
Returns the index of the dropdown item hovered at the given position.
pub fn scroll(&mut self, delta: f32)
pub fn scroll_to_bottom(&mut self)
Sourcepub fn terminal_cell_size(&self) -> (f32, f32)
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.
Sourcepub fn bar_height_phys(&self) -> f32
pub fn bar_height_phys(&self) -> f32
Physical height of the input bar in pixels.
Sourcepub fn surface_size(&self) -> (f32, f32)
pub fn surface_size(&self) -> (f32, f32)
Physical (width, height) of the surface in pixels.
Sourcepub fn scroll_input(&mut self, delta: f32)
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.
Sourcepub fn snap_input_scroll_to_cursor(&mut self)
pub fn snap_input_scroll_to_cursor(&mut self)
Snap input scroll back so the cursor is visible (call after any cursor-moving keystroke).
Sourcepub fn cell_at_phys(&self, px: f32, py: f32) -> Option<(u32, u32)>
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.
Sourcepub fn tui_grid_size(&self) -> (u16, u16)
pub fn tui_grid_size(&self) -> (u16, u16)
Terminal grid dimensions for TUI fullscreen mode (bar hidden — full window).
Sourcepub fn terminal_grid_size(&self) -> (u16, u16)
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.
pub fn render(&mut self) -> Result<()>
Sourcepub fn set_theme(&mut self, theme: Theme)
pub fn set_theme(&mut self, theme: Theme)
Swap the active theme; invalidates color-baked glyph caches.
Sourcepub fn toggle_collapsed(&mut self, block_id: &BlockId)
pub fn toggle_collapsed(&mut self, block_id: &BlockId)
Toggle a tool block open/closed.
Sourcepub fn block_top_y(&self, idx: usize) -> Option<f32>
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.
Sourcepub fn invalidate_block_caches(&mut self)
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§
impl !Freeze for Renderer
impl !RefUnwindSafe for Renderer
impl Send for Renderer
impl Sync for Renderer
impl Unpin for Renderer
impl UnsafeUnpin for Renderer
impl !UnwindSafe for Renderer
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
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> DowncastSync for T
impl<T> DowncastSync for T
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