termcinema-engine 0.1.0

🧠 Core typewriter-style terminal animation engine (SVG renderer) for termcinema
Documentation
use crate::constants::*;

/// Cursor style specification used in rendering and theming.
///
/// Defines visual appearance and animation behavior of the text cursor.
/// Can be customized via theme presets or CLI overrides.
#[derive(Clone)]
pub struct CursorSpec {
    /// Cursor glyph (e.g. `"▋"`, `"|"`, `"⚡️"`).
    /// This is the character rendered as the cursor.
    pub char: String,

    /// Horizontal offset of the cursor in **pixels**.
    /// Useful for aligning visual placement with fonts.
    pub offset_x: u32,

    /// Cursor color in hex format (e.g. `"#00FF00"`), or `None`.
    /// If `None`, inherits the text color from [`StyleSpec`].
    pub color: Option<String>,

    /// Whether the cursor should blink.
    /// If `true`, enables a periodic visibility toggle.
    pub blink: bool,

    /// Blinking interval in **milliseconds**.
    /// Only effective if [`blink`] is `true`.
    pub blink_ms: u32,

    /// Opacity level of the cursor (range: `0.0` to `1.0`).
    /// Allows defining soft or transparent cursors (e.g. `0.6`).
    pub opacity: f32,
}

impl Default for CursorSpec {
    /// Returns the default cursor spec as defined in [`constants.rs`].
    ///
    /// These values are used unless overridden by a theme or CLI flags.
    fn default() -> Self {
        CursorSpec {
            char: DEFAULT_CURSOR_CHAR.into(),
            offset_x: DEFAULT_CURSOR_OFFSET_X,
            color: Some(DEFAULT_STYLE_TEXT_COLOR.into()),
            blink: DEFAULT_CURSOR_BLINK,
            blink_ms: DEFAULT_CURSOR_BLINK_MS,
            opacity: DEFAULT_CURSOR_OPACITY,
        }
    }
}