Class: Tuile::EventQueue::ColorSchemeEvent
- Inherits:
-
Object
- Object
- Tuile::EventQueue::ColorSchemeEvent
- Defined in:
- lib/tuile/event_queue.rb,
sig/tuile.rbs
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;1ndark,\e[?997;2nlight. /\A\e\[\?997;([12])n\z/
Instance Attribute Summary collapse
-
#scheme ⇒ Symbol
readonly
@return —
:lightor:dark.
Class Method Summary collapse
-
.parse(key) ⇒ ColorSchemeEvent?
@param
key— key read via Keys.getkey.
Instance Attribute Details
#scheme ⇒ Symbol (readonly)
@return — :light or :dark.
218 219 220 221 222 223 224 225 226 227 228 229 230 231 |
# File 'lib/tuile/event_queue.rb', line 218 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?
@param key — key read via Keys.getkey.
@return — nil when key is not a
color-scheme report.
227 228 229 230 |
# File 'lib/tuile/event_queue.rb', line 227 def self.parse(key) match = REPORT.match(key) match && new(match[1] == "2" ? :light : :dark) end |