Class: Charming::Image::Terminal

Inherits:
Object
  • Object
show all
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

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

#protocolObject

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).

Returns:

  • (Boolean)


27
28
29
# File 'lib/charming/image/terminal.rb', line 27

def supports_graphics?
  protocol != :none
end