1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//! Per-thread persistent style state.
//!
//! Style "bleed" calls (e.g. cprintb!) intentionally don't reset at the end,
//! so subsequent calls see the leftover ANSI styles in the terminal. To handle
//! `[/red]`-style targeted resets correctly across calls, we persist the
//! active style stack between renders.
//!
//! Per-thread because terminal output is inherently per-thread state — two
//! threads writing to the same stdout are already racing; they shouldn't also
//! be racing over style state.
use crateTagType;
use RefCell;
thread_local!
/// Returns a clone of the current persisted stack.
/// Used by the parser at the start of `render` to resume from prior state.
/// Replaces the persisted stack.
/// Used by the parser at the end of `render` to save its working state.
/// Clears the persisted stack.
/// Called by the upper layer after a non-bleed print (which appends \x1b[0m,
/// so the terminal is back to a clean slate).