struct
Termisu::RenderState
- Termisu::RenderState
- Struct
- Value
- Object
Overview
Tracks the current terminal rendering state for optimization.
Used to avoid emitting redundant escape sequences by tracking what colors and attributes are currently set. Only emits escape sequences when the state actually changes.
Example:
state = Termisu::RenderState.new
# First cell - emits all sequences
state.apply_style(renderer, fg: Color.green, bg: Color.black, attr: Attribute::Bold)
# Second cell with same style - no sequences emitted
state.apply_style(renderer, fg: Color.green, bg: Color.black, attr: Attribute::Bold)
# Third cell with different color - only color change emitted
state.apply_style(renderer, fg: Color.red, bg: Color.black, attr: Attribute::Bold)
Defined in:
termisu/render_state.crConstructors
Instance Method Summary
-
#apply_style(renderer : Renderer, fg : Color, bg : Color, attr : Attribute) : Bool
Applies style to renderer, only emitting changes.
-
#attr : Attribute
Current text attributes
-
#attr=(attr : Attribute)
Current text attributes
-
#bg : Color | Nil
Current background color (nil = unknown/reset)
-
#bg=(bg : Color | Nil)
Current background color (nil = unknown/reset)
-
#fg : Color | Nil
Current foreground color (nil = unknown/reset)
-
#fg=(fg : Color | Nil)
Current foreground color (nil = unknown/reset)
-
#reset
Resets state to unknown (forces next render to emit all sequences).
Constructor Detail
Instance Method Detail
Applies style to renderer, only emitting changes.
Returns true if any escape sequences were emitted.