Module: Fatty::Curses::WindowStyling

Included in:
Renderer::Curses, Renderer::Truecolor
Defined in:
lib/fatty/curses/window_styling.rb

Constant Summary collapse

ATTR_FLAGS =
{
  bold: ::Curses::A_BOLD,
  dim: ::Curses::A_DIM,
  reverse: ::Curses::A_REVERSE,
  underline: ::Curses::A_UNDERLINE,
}.freeze

Instance Method Summary collapse

Instance Method Details

#attr_flag(name) ⇒ Object



27
28
29
# File 'lib/fatty/curses/window_styling.rb', line 27

def attr_flag(name)
  ATTR_FLAGS.fetch(name.to_sym, 0)
end

#pair_attr(role, fallback:) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/fatty/curses/window_styling.rb', line 13

def pair_attr(role, fallback:)
  palette = context.palette
  spec = palette&.[](role)
  return fallback unless spec && spec[:pair]

  attr = ::Curses.color_pair(spec[:pair])

  Array(spec[:attrs]).each do |a|
    attr |= attr_flag(a)
  end

  attr
end