Skip to main content

par_term_config/
lib.rs

1//! Configuration system for par-term terminal emulator.
2//!
3//! This crate provides configuration loading, saving, and default values
4//! for the terminal emulator. It includes:
5//!
6//! - Terminal configuration types and settings
7//! - Theme definitions and color schemes
8//! - Shader configuration management
9//! - Snippets and automation support
10//! - Configuration file watching
11//! - Status bar widget configuration
12//! - Profile configuration types and manager
13//!
14//! # Organization
15//!
16//! All public types are re-exported at the crate root for backward compatibility.
17//! For better discoverability, they are also grouped into prelude sub-modules:
18//!
19//! - [`prelude::core`] — Config, ConfigError, Cell, Theme, Color
20//! - [`prelude::types`] — All config enums and structs (cursor, shell, rendering, etc.)
21//! - [`prelude::automation`] — Triggers, coprocesses, and scripting
22//! - [`prelude::shader`] — Shader controls, metadata, bundles, and resolution
23//! - [`prelude::assistant`] — AI assistant prompts and input history
24//! - [`prelude::snippets`] — Snippets, custom actions, and built-in variables
25//! - [`prelude::status_bar`] — Status bar widgets and layout
26//! - [`prelude::profile`] — Profiles, profile manager, and dynamic sources
27//! - [`prelude::unicode`] — Unicode width, normalization, and version types
28//! - [`prelude::color`] — Color conversion helper functions
29
30pub mod agent_commands;
31pub mod agent_launcher;
32pub mod assistant_input_history;
33pub mod assistant_prompts;
34pub mod atomic_save;
35pub mod automation;
36pub mod cell;
37pub mod config;
38pub mod defaults;
39pub mod error;
40pub mod layout_constants;
41pub mod profile;
42pub mod profile_types;
43pub mod scripting;
44pub mod scrollback_mark;
45pub mod shader_bundle;
46pub mod shader_config;
47pub mod shader_controls;
48pub mod shader_metadata;
49pub mod shell_detection;
50pub mod snapshot_types;
51pub mod snippets;
52pub mod status_bar;
53pub mod text;
54pub mod themes;
55mod types;
56pub mod url_policy;
57#[cfg(feature = "watcher")]
58pub mod watcher;
59
60// ---------------------------------------------------------------------------
61// Domain-organized prelude sub-modules for discoverability.
62// All items here are also re-exported at the crate root below for backward
63// compatibility. Consumers can either `use par_term_config::Config` (root)
64// or `use par_term_config::prelude::core::Config` (grouped) interchangeably.
65// ---------------------------------------------------------------------------
66
67/// Organized prelude modules grouping re-exports by domain.
68///
69/// Each sub-module re-exports a cohesive set of types so that consumers can
70/// narrow their imports to just the domain they need. The crate root still
71/// re-exports everything for backward compatibility — nothing changes for
72/// existing `use par_term_config::X` paths.
73pub mod prelude {
74    /// Core config types: the main [`crate::Config`] struct, error type, cell, theme, and color.
75    ///
76    /// These are the types most downstream crates need on every import.
77    pub mod core {
78        pub use crate::cell::Cell;
79        pub use crate::config::{
80            ALLOWED_ENV_VARS, AiInspectorConfig, AssistantInputHistoryMode, Config, CursorConfig,
81            CustomAcpAgentActionConfig, CustomAcpAgentConfig, FontRenderingConfig,
82            GlobalShaderConfig, MouseConfig, StatusBarConfig, WindowConfig, is_env_var_allowed,
83            substitute_variables, substitute_variables_with_allowlist,
84            substitute_variables_with_lookup,
85        };
86        pub use crate::error::ConfigError;
87        pub use crate::scrollback_mark::ScrollbackMark;
88        pub use crate::snapshot_types::TabSnapshot;
89        pub use crate::themes::{Color, Theme};
90    }
91
92    /// Configuration enums and structs organized by subsystem.
93    ///
94    /// This re-exports every type from the internal `types` module, grouped
95    /// under a single namespace so consumers can `use prelude::types::*` or
96    /// import individual items.
97    pub mod types {
98        // Alert sounds
99        pub use crate::types::alert::{AlertEvent, AlertSoundConfig};
100        // Font and display
101        pub use crate::types::font::{
102            DownloadSaveLocation, DroppedFileQuoteStyle, FontRange, ThinStrokesMode,
103        };
104        // Integration / install prompts
105        pub use crate::types::integration::{
106            InstallPromptState, IntegrationVersions, ProgressBarPosition, ProgressBarStyle,
107            ShaderInstallPrompt, UpdateCheckFrequency,
108        };
109        // Keybindings
110        pub use crate::types::keybinding::KeyBinding;
111        #[allow(unused_imports)]
112        // Re-exported for downstream crates; nothing inside par-term-config imports it
113        pub use crate::types::keybinding::KeyModifier;
114        // Rendering and layout
115        pub use crate::types::rendering::{
116            BackgroundImageMode, BackgroundMode, DividerRect, DividerStyle, ImageScalingMode,
117            PaneBackground, PaneBackgroundConfig, PaneId, PaneTitlePosition, PowerPreference,
118            SeparatorMark, TabId, VsyncMode,
119        };
120        // Selection
121        pub use crate::types::selection::{
122            SmartSelectionPrecision, SmartSelectionRule, default_smart_selection_rules,
123        };
124        // Shader types
125        pub use crate::types::shader::{
126            CursorShaderConfig, CursorShaderMetadata, ResolvedCursorShaderConfig,
127            ResolvedShaderConfig, ShaderBackgroundBlendMode, ShaderConfig, ShaderMetadata,
128            ShaderSafetyBadge,
129        };
130        #[allow(unused_imports)]
131        // Re-exported for downstream crates; nothing inside par-term-config imports these
132        pub use crate::types::shader::{ShaderColorValue, ShaderUniformValue};
133        // Shell
134        pub use crate::types::shell::{ShellExitAction, ShellType, StartupDirectoryMode};
135        // Tab bar and window
136        pub use crate::types::tab_bar::{
137            NewTabPosition, RemoteTabTitleFormat, StatusBarPosition, TabBarMode, TabBarPosition,
138            TabStyle, TabTitleMode, WindowType,
139        };
140        // Terminal / cursor / input
141        pub use crate::types::terminal::{
142            CursorStyle, LinkUnderlineStyle, LogLevel, ModifierRemapping, ModifierTarget,
143            OptionKeyMode, SemanticHistoryEditorMode, SessionLogFormat, UnfocusedCursorStyle,
144        };
145    }
146
147    /// Automation types: triggers, coprocesses, rate limiting, and command safety checks.
148    pub mod automation {
149        pub use crate::automation::{
150            CoprocessDefConfig, RestartPolicy, SplitPaneCommand, TriggerActionConfig,
151            TriggerConfig, TriggerRateLimiter, TriggerSplitDirection, TriggerSplitTarget,
152            check_command_allowlist, check_command_denylist, warn_prompt_before_run_false,
153        };
154        pub use crate::scripting::ScriptConfig;
155    }
156
157    /// Shader system: controls, metadata, bundles, config resolution, and cached metadata.
158    pub mod shader {
159        pub use crate::shader_bundle::ShaderBundleManifest;
160        pub use crate::shader_config::{resolve_cursor_shader_config, resolve_shader_config};
161        pub use crate::shader_controls::{
162            AngleUnit, ShaderControl, ShaderControlKind, ShaderControlParseResult,
163            ShaderControlWarning, SliderScale, fallback_value_for_control, parse_shader_controls,
164        };
165        pub use crate::shader_metadata::{
166            CursorShaderMetadataCache, ShaderMetadataCache, parse_cursor_shader_metadata,
167            parse_shader_metadata, update_cursor_shader_metadata_file, update_shader_metadata_file,
168        };
169    }
170
171    /// AI assistant types: prompt library, input history, and serialization helpers.
172    pub mod assistant {
173        pub use crate::assistant_input_history::{
174            MAX_ASSISTANT_INPUT_HISTORY_ENTRIES, assistant_input_history_path,
175            load_assistant_input_history, merge_assistant_input_history,
176            normalize_assistant_input_history, save_assistant_input_history,
177        };
178        pub use crate::assistant_prompts::{
179            AssistantPrompt, AssistantPromptDraft, assistant_prompts_dir, delete_prompt,
180            list_prompts, list_prompts_in_dir, parse_prompt_markdown, safe_prompt_filename,
181            save_prompt, save_prompt_in_dir, serialize_prompt_markdown,
182        };
183    }
184
185    /// Snippets and custom actions: user-defined commands, built-in variables, and the snippet library.
186    pub mod snippets {
187        pub use crate::snippets::{
188            BuiltInVariable, CustomActionConfig, SnippetConfig, SnippetLibrary,
189        };
190    }
191
192    /// Status bar widgets, sections, layout, and default widget configuration.
193    pub mod status_bar {
194        pub use crate::status_bar::{
195            StatusBarSection, StatusBarWidgetConfig, WidgetId, default_widgets,
196        };
197    }
198
199    /// Profile management: profiles, the profile manager, dynamic sources, and conflict resolution.
200    pub mod profile {
201        pub use crate::profile::{ConflictResolution, DynamicProfileSource};
202        pub use crate::profile_types::{
203            Profile, ProfileId, ProfileManager, ProfileSource, TmuxConnectionMode,
204        };
205    }
206
207    /// Unicode configuration: ambiguous-width handling, normalization form, and Unicode version.
208    ///
209    /// These types mirror the par-term-emu-core-rust enums but belong to the config layer,
210    /// removing the upward dependency from the foundation config crate to the emulation core.
211    /// Higher-level crates (par-term-terminal, root crate) convert via `From` impls.
212    pub mod unicode {
213        pub use crate::types::unicode::{AmbiguousWidth, NormalizationForm, UnicodeVersion};
214    }
215
216    /// Color conversion helpers for translating u8/tuple colors to f32 GPU-ready values.
217    pub mod color {
218        pub use crate::types::color::{
219            color_tuple_to_f32_a, color_u8_to_f32, color_u8_to_f32_a, color_u8x4_rgb_to_f32,
220            color_u8x4_rgb_to_f32_a, color_u8x4_to_f32,
221        };
222    }
223}
224
225// ---------------------------------------------------------------------------
226// Top-level re-exports — backward-compatible public API.
227// Every item below is also available via a prelude sub-module above.
228// Do NOT remove any of these without auditing all downstream crates first.
229// ---------------------------------------------------------------------------
230
231// Assistant prompt-library storage types and helpers
232pub use assistant_input_history::{
233    MAX_ASSISTANT_INPUT_HISTORY_ENTRIES, assistant_input_history_path,
234    load_assistant_input_history, merge_assistant_input_history, normalize_assistant_input_history,
235    save_assistant_input_history,
236};
237pub use assistant_prompts::{
238    AssistantPrompt, AssistantPromptDraft, assistant_prompts_dir, delete_prompt, list_prompts,
239    list_prompts_in_dir, parse_prompt_markdown, safe_prompt_filename, save_prompt,
240    save_prompt_in_dir, serialize_prompt_markdown,
241};
242
243// Error types
244pub use error::ConfigError;
245
246// Core types
247pub use cell::Cell;
248pub use config::{
249    ALLOWED_ENV_VARS, AiInspectorConfig, AssistantInputHistoryMode, AutomationConfig,
250    BackgroundConfig, BadgeConfig, ClipboardConfig, CommandSeparatorConfig, Config, CursorConfig,
251    CustomAcpAgentActionConfig, CustomAcpAgentConfig, FontRenderingConfig, GlobalShaderConfig,
252    ImageConfig, InputConfig, IntegrationConfig, MouseConfig, PaneConfig, PluginStateConfig,
253    PowerConfig, ProgressBarConfig, RenderingConfig, ScrollbarConfig, SecurityConfig,
254    SelectionConfig, SemanticHistoryConfig, SessionLogConfig, SessionRestoreConfig,
255    ShaderOverridesConfig, ShaderWatchConfig, ShellConfig, StatusBarConfig, TabBarColorsConfig,
256    TabConfig, ThemeColorsConfig, TmuxConfig, WindowConfig, WindowPlacementConfig,
257    WordSelectionConfig, is_env_var_allowed, substitute_variables,
258    substitute_variables_with_allowlist, substitute_variables_with_lookup,
259};
260pub use scrollback_mark::ScrollbackMark;
261pub use themes::{Color, Theme};
262
263// Color conversion helpers
264pub use types::{
265    color_tuple_to_f32_a, color_u8_to_f32, color_u8_to_f32_a, color_u8x4_rgb_to_f32,
266    color_u8x4_rgb_to_f32_a, color_u8x4_to_f32,
267};
268
269// Automation types
270pub use automation::{
271    CoprocessDefConfig, RestartPolicy, SplitPaneCommand, TriggerActionConfig, TriggerConfig,
272    TriggerRateLimiter, TriggerSplitDirection, TriggerSplitTarget, check_command_allowlist,
273    check_command_denylist, warn_prompt_before_run_false,
274};
275pub use types::{
276    AlertEvent, AlertSoundConfig, BackgroundImageMode, BackgroundMode, CursorShaderConfig,
277    CursorShaderMetadata, CursorStyle, DividerRect, DividerStyle, DownloadSaveLocation,
278    DroppedFileQuoteStyle, FontRange, ImageScalingMode, InstallPromptState, IntegrationVersions,
279    KeyBinding, LinkUnderlineStyle, LogLevel, ModifierRemapping, ModifierTarget, NewTabPosition,
280    OptionKeyMode, PaneBackground, PaneBackgroundConfig, PaneId, PaneTitlePosition,
281    PowerPreference, ProgressBarPosition, ProgressBarStyle, RemoteTabTitleFormat,
282    SemanticHistoryEditorMode, SeparatorMark, SessionLogFormat, ShaderBackgroundBlendMode,
283    ShaderConfig, ShaderInstallPrompt, ShaderMetadata, ShaderSafetyBadge, ShellExitAction,
284    ShellType, SmartSelectionPrecision, SmartSelectionRule, StartupDirectoryMode,
285    StatusBarPosition, TabBarMode, TabBarPosition, TabId, TabStyle, TabTitleMode, ThinStrokesMode,
286    UnfocusedCursorStyle, UpdateCheckFrequency, VsyncMode, WindowType,
287    default_smart_selection_rules,
288};
289// Scripting / observer scripts
290pub use scripting::ScriptConfig;
291// Snippets and custom actions
292pub use snippets::{BuiltInVariable, CustomActionConfig, SnippetConfig, SnippetLibrary};
293// Status bar configuration
294pub use status_bar::{StatusBarSection, StatusBarWidgetConfig, WidgetId, default_widgets};
295// Profile configuration
296pub use profile::{ConflictResolution, DynamicProfileSource};
297// Profile types and manager
298pub use profile_types::{Profile, ProfileId, ProfileManager, ProfileSource, TmuxConnectionMode};
299// Shader bundle manifests
300pub use shader_bundle::ShaderBundleManifest;
301// Shader config resolution
302pub use shader_config::{resolve_cursor_shader_config, resolve_shader_config};
303// Shader controls
304pub use shader_controls::{
305    AngleUnit, ShaderControl, ShaderControlKind, ShaderControlParseResult, ShaderControlWarning,
306    SliderScale, fallback_value_for_control, parse_shader_controls,
307};
308// Shader metadata
309pub use shader_metadata::{CursorShaderMetadataCache, ShaderMetadataCache};
310pub use shader_metadata::{
311    parse_cursor_shader_metadata, parse_shader_metadata, update_cursor_shader_metadata_file,
312    update_shader_metadata_file,
313};
314// Shared snapshot types for session and arrangement persistence
315pub use snapshot_types::TabSnapshot;
316
317// Unicode types (ARC-003: native config-layer definitions)
318pub use types::{AmbiguousWidth, NormalizationForm, UnicodeVersion};
319// KeyModifier and the shader value types — unused-import suppressions are intentional;
320// these are re-exported for downstream crates (root crate src/config/mod.rs facade).
321#[allow(unused_imports)]
322pub use types::KeyModifier;
323#[allow(unused_imports)]
324pub use types::shader::{ShaderColorValue, ShaderUniformValue};
325pub use types::{ResolvedCursorShaderConfig, ResolvedShaderConfig};