Method: Console::Terminal::XTerm#style

Defined in:
lib/console/terminal/xterm.rb

#style(foreground, background = nil, *attributes) ⇒ Object

Apply the given style to the output.



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/console/terminal/xterm.rb', line 65

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