Skip to main content

pacsea/theme/
mod.rs

1//! Theme system for Pacsea.
2//!
3//! Split from a monolithic file into submodules for maintainability. Public
4//! re-exports keep the `crate::theme::*` API stable.
5
6/// Configuration file management and migration.
7mod config;
8/// Configuration parsing utilities.
9mod parsing;
10/// Path resolution for config directories.
11mod paths;
12/// Unified theme resolution logic.
13mod resolve;
14/// Settings access and management.
15mod settings;
16/// Theme store and caching.
17mod store;
18/// Terminal detection for theme fallback.
19mod terminal_detect;
20/// Terminal color query and theme derivation.
21mod terminal_query;
22/// Theme type definitions.
23mod types;
24
25pub use config::{
26    ConfigFile, ConfigWriteError, EDITABLE_KEYBINDS, EDITABLE_SETTINGS, EDITABLE_THEME,
27    EditableSetting, PatchOutcome, PatchRequest, REPOS_SKELETON_CONTENT, ReloadBehavior,
28    Sensitivity, ValueKind, ensure_settings_keys_present, ensure_theme_keys_present, find_setting,
29    keybind_scope, maybe_migrate_legacy_confs, patch_key, resolved_config_path,
30    save_app_start_mode, save_fuzzy_search, save_mirror_count, save_news_filter_installed_only,
31    save_news_filter_show_advisories, save_news_filter_show_arch_news,
32    save_news_filter_show_aur_comments, save_news_filter_show_aur_updates,
33    save_news_filter_show_pkg_updates, save_news_filters_collapsed, save_news_max_age_days,
34    save_results_filter_show_canonical, save_scan_do_clamav, save_scan_do_custom,
35    save_scan_do_semgrep, save_scan_do_shellcheck, save_scan_do_sleuth, save_scan_do_trivy,
36    save_scan_do_virustotal, save_selected_countries, save_show_install_pane,
37    save_show_keybinds_footer, save_show_recent_pane, save_sort_mode, save_startup_news_configured,
38    save_startup_news_max_age_days, save_startup_news_show_advisories,
39    save_startup_news_show_arch_news, save_startup_news_show_aur_comments,
40    save_startup_news_show_aur_updates, save_startup_news_show_pkg_updates,
41    save_virustotal_api_key, settings_for, try_load_theme_from_content, write_full_content,
42};
43pub use paths::{
44    config_dir, lists_dir, logs_dir, resolve_repos_config_path, set_config_dir_override,
45};
46pub use settings::settings;
47pub use store::{reload_theme, theme};
48pub use types::{KeyChord, KeyMap, PackageMarker, Settings, Theme};
49
50#[cfg(test)]
51static TEST_MUTEX: std::sync::OnceLock<std::sync::Mutex<()>> = std::sync::OnceLock::new();
52
53#[cfg(test)]
54/// What: Provide a process-wide mutex to serialize filesystem-mutating tests in this module.
55///
56/// Inputs:
57/// - None
58///
59/// Output:
60/// - Shared reference to a lazily-initialized `Mutex<()>`.
61///
62/// Details:
63/// - Uses `OnceLock` to ensure the mutex is constructed exactly once per process.
64/// - Callers should lock the mutex to guard environment-variable or disk state changes.
65pub(crate) fn test_mutex() -> &'static std::sync::Mutex<()> {
66    TEST_MUTEX.get_or_init(|| std::sync::Mutex::new(()))
67}