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