pub struct CustomShaderRenderer { /* private fields */ }Expand description
Custom shader renderer that applies post-processing effects
Implementations§
Source§impl CustomShaderRenderer
impl CustomShaderRenderer
Sourcepub fn update_cursor(
&mut self,
col: usize,
row: usize,
opacity: f32,
cursor_color: [f32; 4],
style: CursorStyle,
)
pub fn update_cursor( &mut self, col: usize, row: usize, opacity: f32, cursor_color: [f32; 4], style: CursorStyle, )
Update cursor position and appearance for shader effects
This method tracks cursor movement and records the time of change, enabling Ghostty-compatible cursor trail effects and animations.
§Arguments
col- Cursor column position (0-based)row- Cursor row position (0-based)opacity- Cursor opacity (0.0 = invisible, 1.0 = fully visible)cursor_color- Cursor RGBA colorstyle- Cursor style (Block, Beam, Underline)
Sourcepub fn update_cell_dimensions(
&mut self,
cell_width: f32,
cell_height: f32,
padding: f32,
)
pub fn update_cell_dimensions( &mut self, cell_width: f32, cell_height: f32, padding: f32, )
Update cell dimensions for cursor pixel position calculation
§Arguments
cell_width- Cell width in pixelscell_height- Cell height in pixelspadding- Window padding in pixels
Sourcepub fn set_content_offset_y(&mut self, offset: f32)
pub fn set_content_offset_y(&mut self, offset: f32)
Set vertical content offset (e.g., tab bar height)
Sourcepub fn set_content_offset_x(&mut self, offset: f32)
pub fn set_content_offset_x(&mut self, offset: f32)
Set horizontal content offset (e.g., tab bar on left)
Sourcepub fn set_scale_factor(&mut self, scale_factor: f32)
pub fn set_scale_factor(&mut self, scale_factor: f32)
Set display scale factor for DPI-aware cursor sizing
Sourcepub fn cursor_needs_animation(&self) -> bool
pub fn cursor_needs_animation(&self) -> bool
Check if cursor animation might need continuous rendering
Returns true if a cursor trail animation is likely still in progress (within 1 second of the last cursor movement).
Sourcepub fn update_cursor_shader_config(
&mut self,
color: [u8; 3],
trail_duration: f32,
glow_radius: f32,
glow_intensity: f32,
)
pub fn update_cursor_shader_config( &mut self, color: [u8; 3], trail_duration: f32, glow_radius: f32, glow_intensity: f32, )
Update cursor shader configuration from config values
§Arguments
color- Cursor color for shader effects [R, G, B] (0-255)trail_duration- Duration of cursor trail effect in secondsglow_radius- Radius of cursor glow effect in pixelsglow_intensity- Intensity of cursor glow effect (0.0-1.0)
Source§impl CustomShaderRenderer
impl CustomShaderRenderer
Sourcepub fn new(
device: &Device,
queue: &Queue,
surface_format: TextureFormat,
shader_path: &Path,
width: u32,
height: u32,
animation_enabled: bool,
animation_speed: f32,
window_opacity: f32,
full_content_mode: bool,
channel_paths: &[Option<PathBuf>; 4],
cubemap_path: Option<&Path>,
) -> Result<Self>
pub fn new( device: &Device, queue: &Queue, surface_format: TextureFormat, shader_path: &Path, width: u32, height: u32, animation_enabled: bool, animation_speed: f32, window_opacity: f32, full_content_mode: bool, channel_paths: &[Option<PathBuf>; 4], cubemap_path: Option<&Path>, ) -> Result<Self>
Create a new custom shader renderer from a GLSL shader file
Sourcepub fn intermediate_texture_view(&self) -> &TextureView
pub fn intermediate_texture_view(&self) -> &TextureView
Get a view of the intermediate texture for rendering terminal content into
Sourcepub fn clear_intermediate_texture(&self, device: &Device, queue: &Queue)
pub fn clear_intermediate_texture(&self, device: &Device, queue: &Queue)
Clear the intermediate texture (e.g., when switching to split pane mode)
This prevents old single-pane content from showing through the shader.
Sourcepub fn resize(&mut self, device: &Device, width: u32, height: u32)
pub fn resize(&mut self, device: &Device, width: u32, height: u32)
Resize the intermediate texture when window size changes
Sourcepub fn render(
&mut self,
device: &Device,
queue: &Queue,
output_view: &TextureView,
apply_opacity: bool,
) -> Result<()>
pub fn render( &mut self, device: &Device, queue: &Queue, output_view: &TextureView, apply_opacity: bool, ) -> Result<()>
Render the custom shader effect to the output texture
§Arguments
device- The GPU devicequeue- The command queueoutput_view- The texture view to render toapply_opacity- Whether to apply window opacity. Set tofalsewhen rendering to an intermediate texture that will be processed by another shader (to avoid double-applying opacity).
Sourcepub fn render_with_clear_color(
&mut self,
device: &Device,
queue: &Queue,
output_view: &TextureView,
apply_opacity: bool,
clear_color: Color,
) -> Result<()>
pub fn render_with_clear_color( &mut self, device: &Device, queue: &Queue, output_view: &TextureView, apply_opacity: bool, clear_color: Color, ) -> Result<()>
Render the custom shader with a specified clear color. Use this for solid background colors where the clear color provides the background.
Sourcepub fn animation_enabled(&self) -> bool
pub fn animation_enabled(&self) -> bool
Check if animation is enabled
Sourcepub fn set_animation_enabled(&mut self, enabled: bool)
pub fn set_animation_enabled(&mut self, enabled: bool)
Set animation enabled state
Sourcepub fn set_animation_speed(&mut self, speed: f32)
pub fn set_animation_speed(&mut self, speed: f32)
Update animation speed multiplier
Sourcepub fn set_opacity(&mut self, opacity: f32)
pub fn set_opacity(&mut self, opacity: f32)
Update window opacity
Sourcepub fn set_brightness(&mut self, brightness: f32)
pub fn set_brightness(&mut self, brightness: f32)
Update shader brightness multiplier
Sourcepub fn set_full_content_mode(&mut self, enabled: bool)
pub fn set_full_content_mode(&mut self, enabled: bool)
Update full content mode
Sourcepub fn full_content_mode(&self) -> bool
pub fn full_content_mode(&self) -> bool
Check if full content mode is enabled
Sourcepub fn set_keep_text_opaque(&mut self, keep_opaque: bool)
pub fn set_keep_text_opaque(&mut self, keep_opaque: bool)
Set whether text should always be rendered at full opacity When true, overrides text_opacity to 1.0
Sourcepub fn set_mouse_position(&mut self, x: f32, y: f32)
pub fn set_mouse_position(&mut self, x: f32, y: f32)
Update mouse position in pixel coordinates
Update mouse button state and click position
Sourcepub fn update_key_press(&mut self)
pub fn update_key_press(&mut self)
Update key press time for shader effects
Call this when a key is pressed to enable key-press-based shader effects like screen pulses or typing animations.
Sourcepub fn update_channel_texture(
&mut self,
device: &Device,
queue: &Queue,
channel: u8,
path: Option<&Path>,
) -> Result<()>
pub fn update_channel_texture( &mut self, device: &Device, queue: &Queue, channel: u8, path: Option<&Path>, ) -> Result<()>
Update a channel texture at runtime
Sourcepub fn update_cubemap(
&mut self,
device: &Device,
queue: &Queue,
path: Option<&Path>,
) -> Result<()>
pub fn update_cubemap( &mut self, device: &Device, queue: &Queue, path: Option<&Path>, ) -> Result<()>
Update the cubemap texture at runtime
Sourcepub fn set_use_background_as_channel0(&mut self, use_background: bool)
pub fn set_use_background_as_channel0(&mut self, use_background: bool)
Set whether to use the background image as iChannel0.
When enabled and a background texture is set, the background image will be used as iChannel0 instead of the configured channel0 texture file.
Note: This only updates the flag. Use update_use_background_as_channel0
if you also need to recreate the bind group.
Sourcepub fn use_background_as_channel0(&self) -> bool
pub fn use_background_as_channel0(&self) -> bool
Check if using background image as iChannel0.
Sourcepub fn set_background_texture(
&mut self,
device: &Device,
texture: Option<ChannelTexture>,
)
pub fn set_background_texture( &mut self, device: &Device, texture: Option<ChannelTexture>, )
Set the background texture to use as iChannel0 when enabled.
Call this whenever the background image changes to update the shader’s channel0 binding. The device parameter is needed to recreate the bind group.
When use_background_as_channel0 is enabled, the background texture takes priority over any configured channel0 texture.
§Arguments
device- The wgpu devicetexture- The background texture (view, sampler, dimensions), or None to clear
Sourcepub fn set_background_color(&mut self, color: [f32; 3], active: bool)
pub fn set_background_color(&mut self, color: [f32; 3], active: bool)
Set the solid background color for shader compositing.
When set (alpha > 0), the shader uses this color as background instead of shader output. This allows solid background colors to show through properly with window transparency.
§Arguments
color- RGB color values [R, G, B] (0.0-1.0, NOT premultiplied)active- Whether solid color mode is active (sets alpha to 1.0 or 0.0)
Sourcepub fn update_progress(
&mut self,
state: f32,
percent: f32,
is_active: f32,
active_count: f32,
)
pub fn update_progress( &mut self, state: f32, percent: f32, is_active: f32, active_count: f32, )
Update progress bar state for shader effects.
§Arguments
state- Progress state (0=hidden, 1=normal, 2=error, 3=indeterminate, 4=warning)percent- Progress percentage as 0.0-1.0is_active- 1.0 if any progress bar is active, 0.0 otherwiseactive_count- Total count of active bars (simple + named)
Sourcepub fn update_use_background_as_channel0(
&mut self,
device: &Device,
use_background: bool,
)
pub fn update_use_background_as_channel0( &mut self, device: &Device, use_background: bool, )
Update the use_background_as_channel0 setting and recreate bind group if needed.
Call this when the setting changes in the UI or config.
Sourcepub fn reload_from_source(
&mut self,
device: &Device,
source: &str,
name: &str,
) -> Result<()>
pub fn reload_from_source( &mut self, device: &Device, source: &str, name: &str, ) -> Result<()>
Reload the shader from a source string
Sourcepub fn set_content_inset_right(&mut self, inset: f32)
pub fn set_content_inset_right(&mut self, inset: f32)
Set the right content inset (e.g., AI Inspector panel).
When non-zero, the shader will render to a viewport that excludes the right inset area, ensuring effects don’t appear under the panel.
Auto Trait Implementations§
impl Freeze for CustomShaderRenderer
impl !RefUnwindSafe for CustomShaderRenderer
impl Send for CustomShaderRenderer
impl Sync for CustomShaderRenderer
impl Unpin for CustomShaderRenderer
impl UnsafeUnpin for CustomShaderRenderer
impl !UnwindSafe for CustomShaderRenderer
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