Class: Charming::Image::Terminal
- Inherits:
-
Object
- Object
- Charming::Image::Terminal
- Defined in:
- lib/charming/image/terminal.rb
Overview
Terminal detects which terminal graphics protocol the host emulator supports, from
environment variables. It is the single detection seam: the rest of the image engine
dispatches on #protocol. Injectable (env:) so specs never depend on the real terminal,
mirroring Audio::System.
Phase 1 detects only the Kitty graphics protocol (Ghostty + Kitty). Other terminals report
:none, letting Components::Image fall back gracefully. Future protocols
(iTerm2, Sixel, half-block) slot in here without touching Source or the component.
Instance Method Summary collapse
-
#initialize(env: ENV) ⇒ Terminal
constructor
env is the environment hash probed for terminal identity (defaults to the process env).
-
#protocol ⇒ Object
The supported graphics protocol as a symbol:
:kittyfor Kitty/Ghostty, else:none. -
#supports_graphics? ⇒ Boolean
True when a real graphics protocol is available (i.e. #protocol is not
:none).
Constructor Details
#initialize(env: ENV) ⇒ Terminal
env is the environment hash probed for terminal identity (defaults to the process env).
15 16 17 |
# File 'lib/charming/image/terminal.rb', line 15 def initialize(env: ENV) @env = env end |
Instance Method Details
#protocol ⇒ Object
The supported graphics protocol as a symbol: :kitty for Kitty/Ghostty, else :none.
20 21 22 23 24 |
# File 'lib/charming/image/terminal.rb', line 20 def protocol return :kitty if kitty? :none end |
#supports_graphics? ⇒ Boolean
True when a real graphics protocol is available (i.e. #protocol is not :none).
27 28 29 |
# File 'lib/charming/image/terminal.rb', line 27 def supports_graphics? protocol != :none end |