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