Skip to main content

par_term_render/renderer/
params.rs

1//! Parameter struct for `Renderer::new()` to replace 46 individual arguments.
2
3use std::path::{Path, PathBuf};
4use std::sync::Arc;
5use winit::window::Window;
6
7/// Bundles all parameters needed by [`super::Renderer::new()`].
8///
9/// Grouping the parameters into a struct eliminates the 46-argument function
10/// signature (audit finding H4) without changing any behaviour.
11pub struct RendererParams<'a> {
12    // ── Window / GPU ──────────────────────────────────────────────────
13    /// The winit window that owns the wgpu surface.
14    pub window: Arc<Window>,
15    /// Vsync presentation mode.
16    pub vsync_mode: par_term_config::VsyncMode,
17    /// GPU power preference (low-power vs high-performance).
18    pub power_preference: par_term_config::PowerPreference,
19    /// Window opacity (0.0 fully transparent – 1.0 fully opaque).
20    pub window_opacity: f32,
21
22    // ── Fonts ─────────────────────────────────────────────────────────
23    /// Primary font family name (None = system default).
24    pub font_family: Option<&'a str>,
25    /// Bold variant family override.
26    pub font_family_bold: Option<&'a str>,
27    /// Italic variant family override.
28    pub font_family_italic: Option<&'a str>,
29    /// Bold-italic variant family override.
30    pub font_family_bold_italic: Option<&'a str>,
31    /// Additional Unicode ranges and their fallback fonts.
32    pub font_ranges: &'a [par_term_config::FontRange],
33    /// Font size in points.
34    pub font_size: f32,
35    /// Enable HarfBuzz text shaping.
36    pub enable_text_shaping: bool,
37    /// Enable OpenType ligatures.
38    pub enable_ligatures: bool,
39    /// Enable OpenType kerning.
40    pub enable_kerning: bool,
41    /// Enable font anti-aliasing.
42    pub font_antialias: bool,
43    /// Enable font hinting.
44    pub font_hinting: bool,
45    /// Thin-strokes rendering mode.
46    pub font_thin_strokes: par_term_config::ThinStrokesMode,
47    /// Minimum contrast ratio between foreground and background.
48    pub minimum_contrast: f32,
49
50    // ── Layout ────────────────────────────────────────────────────────
51    /// Padding around the terminal content in logical pixels.
52    pub window_padding: f32,
53    /// Line height multiplier.
54    pub line_spacing: f32,
55    /// Character width multiplier.
56    pub char_spacing: f32,
57
58    // ── Scrollbar ─────────────────────────────────────────────────────
59    /// Scrollbar position string ("left", "right", "hidden").
60    pub scrollbar_position: &'a str,
61    /// Scrollbar width in logical pixels.
62    pub scrollbar_width: f32,
63    /// Scrollbar thumb color [R, G, B, A].
64    pub scrollbar_thumb_color: [f32; 4],
65    /// Scrollbar track color [R, G, B, A].
66    pub scrollbar_track_color: [f32; 4],
67
68    // ── Background ────────────────────────────────────────────────────
69    /// Theme background color [R, G, B].
70    pub background_color: [u8; 3],
71    /// Optional background image file path.
72    pub background_image_path: Option<&'a str>,
73    /// Whether the background image feature is enabled.
74    pub background_image_enabled: bool,
75    /// How the background image is displayed (stretch, tile, etc.).
76    pub background_image_mode: par_term_config::BackgroundImageMode,
77    /// Background image opacity (0.0 – 1.0).
78    pub background_image_opacity: f32,
79
80    // ── Custom (background) shader ────────────────────────────────────
81    /// Name / path of the custom background shader.
82    pub custom_shader_path: Option<&'a str>,
83    /// Whether the custom shader is enabled.
84    pub custom_shader_enabled: bool,
85    /// Whether the custom shader is animated.
86    pub custom_shader_animation: bool,
87    /// Animation speed multiplier for the custom shader.
88    pub custom_shader_animation_speed: f32,
89    /// Whether the shader renders over the full surface (vs. terminal area).
90    pub custom_shader_full_content: bool,
91    /// Brightness multiplier applied to the shader output.
92    pub custom_shader_brightness: f32,
93    /// Channel texture paths (iChannel0..3).
94    pub custom_shader_channel_paths: &'a [Option<PathBuf>; 4],
95    /// Cubemap texture path prefix (iCubemap).
96    pub custom_shader_cubemap_path: Option<&'a Path>,
97    /// Use the background image as iChannel0.
98    pub use_background_as_channel0: bool,
99
100    // ── Inline image settings ─────────────────────────────────────────
101    /// Scaling filter for inline images (nearest vs linear).
102    pub image_scaling_mode: par_term_config::ImageScalingMode,
103    /// Whether to preserve aspect ratio when scaling inline images.
104    pub image_preserve_aspect_ratio: bool,
105
106    // ── Cursor shader ─────────────────────────────────────────────────
107    /// Name / path of the cursor shader.
108    pub cursor_shader_path: Option<&'a str>,
109    /// Whether the cursor shader is enabled.
110    pub cursor_shader_enabled: bool,
111    /// Whether the cursor shader is animated.
112    pub cursor_shader_animation: bool,
113    /// Animation speed multiplier for the cursor shader.
114    pub cursor_shader_animation_speed: f32,
115}