termcinema_engine/core/cursor.rs
1use crate::constants::*;
2
3/// Cursor style specification used in rendering and theming.
4///
5/// Defines visual appearance and animation behavior of the text cursor.
6/// Can be customized via theme presets or CLI overrides.
7#[derive(Clone)]
8pub struct CursorSpec {
9 /// Cursor glyph (e.g. `"▋"`, `"|"`, `"⚡️"`).
10 /// This is the character rendered as the cursor.
11 pub char: String,
12
13 /// Horizontal offset of the cursor in **pixels**.
14 /// Useful for aligning visual placement with fonts.
15 pub offset_x: u32,
16
17 /// Cursor color in hex format (e.g. `"#00FF00"`), or `None`.
18 /// If `None`, inherits the text color from [`StyleSpec`].
19 pub color: Option<String>,
20
21 /// Whether the cursor should blink.
22 /// If `true`, enables a periodic visibility toggle.
23 pub blink: bool,
24
25 /// Blinking interval in **milliseconds**.
26 /// Only effective if [`blink`] is `true`.
27 pub blink_ms: u32,
28
29 /// Opacity level of the cursor (range: `0.0` to `1.0`).
30 /// Allows defining soft or transparent cursors (e.g. `0.6`).
31 pub opacity: f32,
32}
33
34impl Default for CursorSpec {
35 /// Returns the default cursor spec as defined in [`constants.rs`].
36 ///
37 /// These values are used unless overridden by a theme or CLI flags.
38 fn default() -> Self {
39 CursorSpec {
40 char: DEFAULT_CURSOR_CHAR.into(),
41 offset_x: DEFAULT_CURSOR_OFFSET_X,
42 color: Some(DEFAULT_STYLE_TEXT_COLOR.into()),
43 blink: DEFAULT_CURSOR_BLINK,
44 blink_ms: DEFAULT_CURSOR_BLINK_MS,
45 opacity: DEFAULT_CURSOR_OPACITY,
46 }
47 }
48}