class Console::Terminal::XTerm
XTerm style terminal output.
def colors?
def colors? true end
def reset
Reset the style.
def reset "\e[0m" end
def size
def size @stream.winsize rescue Errno::ENOTTY, Errno::ENODEV # Fake it... [24, 80] end
def style(foreground, background = nil, *attributes)
@parameter attributes [Array(Symbol)] The attributes to apply.
@parameter background [Symbol] The background color.
@parameter foreground [Symbol] The foreground color.
Apply the given style to the output.
def style(foreground, background = nil, *attributes) tokens = [] if foreground tokens << 30 + COLORS.fetch(foreground) end if background tokens << 40 + COLORS.fetch(background) end attributes.each do |attribute| tokens << ATTRIBUTES.fetch(attribute){attribute.to_i} end return "\e[#{tokens.join(';')}m" end
def width
def width size.last end