Class: Tuile::EventQueue::ColorSchemeEvent
- Inherits:
-
Object
- Object
- Tuile::EventQueue::ColorSchemeEvent
- Defined in:
- lib/tuile/event_queue.rb
Overview
The terminal’s color scheme changed — the user flipped the OS between light and dark appearance. Terminals supporting mode 2031 (kitty, foot, contour, ghostty, …) push the DSR-style report ‘e[?997;1n` (dark) / `e[?997;2n` (light) once Screen#run_event_loop enables the mode via TerminalBackground::NOTIFY_ON; the key thread parses it into this event and Screen#event_loop follows by assigning the matching Theme.
Constant Summary collapse
- REPORT =
The DSR-style color-scheme report: ‘e[?997;1n` dark, `e[?997;2n` light.
/\A\e\[\?997;([12])n\z/
Instance Attribute Summary collapse
-
#scheme ⇒ Symbol
readonly
‘:light` or `:dark`.
Class Method Summary collapse
-
.parse(key) ⇒ ColorSchemeEvent?
Nil when ‘key` is not a color-scheme report.
Instance Attribute Details
#scheme ⇒ Symbol (readonly)
Returns ‘:light` or `:dark`.
197 198 199 200 201 202 203 204 205 206 207 208 209 210 |
# File 'lib/tuile/event_queue.rb', line 197 class ColorSchemeEvent < Data.define(:scheme) # The DSR-style color-scheme report: `\e[?997;1n` dark, `\e[?997;2n` # light. # @return [Regexp] REPORT = /\A\e\[\?997;([12])n\z/ # @param key [String] key read via {Keys.getkey}. # @return [ColorSchemeEvent, nil] nil when `key` is not a # color-scheme report. def self.parse(key) match = REPORT.match(key) match && new(match[1] == "2" ? :light : :dark) end end |
Class Method Details
.parse(key) ⇒ ColorSchemeEvent?
Returns nil when ‘key` is not a color-scheme report.
206 207 208 209 |
# File 'lib/tuile/event_queue.rb', line 206 def self.parse(key) match = REPORT.match(key) match && new(match[1] == "2" ? :light : :dark) end |