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