Crate thag_styling

Crate thag_styling 

Source
Expand description

Terminal styling system with theme support and color detection for thag_rs and third party applications.

This crate provides a comprehensive styling system for terminal applications, including:

  • Color detection and terminal capability assessment
  • Theme-based styling with semantic roles
  • inquire UI integration for consistent theming
  • ANSI color conversion and optimization
  • Built-in theme collection

Re-exports§

pub use styling::display_terminal_attributes;
pub use styling::display_theme_details;
pub use styling::display_theme_roles;
pub use styling::find_closest_color;
pub use styling::get_rgb;
pub use styling::index_to_rgb;
pub use styling::paint_for_role;
pub use styling::AnsiStyleExt;
pub use styling::Color;
pub use styling::ColorInfo;
pub use styling::ColorInitStrategy;
pub use styling::ColorValue;
pub use styling::HowInitialized;
pub use styling::Palette;
pub use styling::PaletteConfig;
pub use styling::Role;
pub use styling::Style;
pub use styling::Styleable;
pub use styling::Styled;
pub use styling::StyledPrint;
pub use styling::StyledString;
pub use styling::Styler;
pub use styling::TermAttributes;
pub use styling::Theme;
pub use integrations::ThemedStyle;
pub use palette_sync::PaletteSync;
pub use exporters::export_all_formats;
pub use exporters::export_theme_to_file;
pub use exporters::generate_installation_instructions;
pub use exporters::ExportFormat;
pub use exporters::ThemeExporter;

Modules§

exporters
Format-specific theme export implementations.
help_system
Lightweight help system for thag tools
integrations
Integration modules for third-party terminal styling crates
palette_sync
Runtime terminal palette synchronization using OSC escape sequences
styling
Message styling
terminal
This module handles detection of terminal capabilities while preserving terminal state. In particular, it manages raw mode status which can be affected by some detection operations.

Macros§

auto_help
Macro to automatically extract help from current source file
cprtlnDeprecated
Print line with embedded styled content
cvprtlnDeprecated
Conditionally logs a message with verbosity control and styling.
debug_log
Debugging logger.
file_navigator
Generates a FileNavigator to allow the user to navigate the file system and select files and directories from a command-line interface.
help_system
Macro to create a help system - manually specify the source
prtln
Ungated print line macro for user messages
re
Lazy-static regular expression generator.
set_verbosity
Convenient macro for setting global verbosity with short syntax.
sprtln
Styled print line macro (replacement for cprtln!) Format: sprtln!(style: Style, "Lorem ipsum dolor {} amet", content: &str); Also accepts Role: sprtln!(Role::Code, "Hello {}", "world");
styled
Applies styling to text using inline color and style codes.
svprtln
Styled verbosity-gated print line macro (replacement for cvprtln!) Conditionally logs a message with verbosity control and styling.
vprtln
Verbosity-gated print line macro for user messages

Structs§

NoConfigProvider
Default implementation that uses no configuration

Enums§

ColorSupport
An enum to categorise the current terminal’s level of colour support as detected, configured or defaulted.
StylingError
Error types for styling operations
TermBgLuma
Terminal background luminance detection and specification
ThemeError
Theme-related error types
Verbosity
Controls the detail level of user messaging

Statics§

OUTPUT_MANAGER
Global output manager instance protected by a reentrant mutex for thread-safe access

Traits§

StylingConfigProvider
Trait for providing styling configuration to break circular dependency

Functions§

display_color_comparison
Display side-by-side color comparison of terminal palette vs thag_styling theme.
get_verbosity
Initializes and returns the global verbosity setting.
hsl_to_rgb
Helper: HSL -> RGB
init_verbosity
Initialize verbosity with a convenient function that handles common patterns.
is_konsole
Check if running in konsole (always supports TrueColor)
is_light_color
Check if a color is considered light
is_mintty
Check if running in mintty (always supports TrueColor)
rgb_to_hsl
Helper: RGB -> HSL
set_global_verbosity
Set the output verbosity for the current execution.
set_verbosity_from_env
Set global verbosity from the THAG_VERBOSITY environment variable.

Type Aliases§

StylingResult
Result type alias for styling operations
ThagCommonResult
Result type alias for thag_common operations
V
Type alias for Verbosity to provide a shorter name for convenience