Module: WindowBlessing::XtermOutput::SetColor
- Included in:
- WindowBlessing::XtermOutput
- Defined in:
- lib/window_blessing/xterm_output.rb
Instance Attribute Summary collapse
-
#current_bg ⇒ Object
readonly
Returns the value of attribute current_bg.
-
#current_fg ⇒ Object
readonly
Returns the value of attribute current_fg.
Instance Method Summary collapse
- #change_bg(bg) ⇒ Object
- #change_fg(fg) ⇒ Object
- #out_color(txt, fg, bg) ⇒ Object
- #reset_color ⇒ Object
- #set_bg(bg) ⇒ Object
- #set_bold ⇒ Object
- #set_color(fg, bg = nil) ⇒ Object
-
#set_color_24bit(fg, bg = nil) ⇒ Object
fg and bg are r-g-b arrays: [0..255, 0..255, 0..255] This is not supported by iTerm2: code.google.com/p/iterm2/issues/detail?id=218 konsole supports it: github.com/robertknight/konsole/blob/master/user-doc/README.moreColors.
- #set_fg(fg) ⇒ Object
- #set_underline ⇒ Object
Instance Attribute Details
#current_bg ⇒ Object (readonly)
Returns the value of attribute current_bg.
26 27 28 |
# File 'lib/window_blessing/xterm_output.rb', line 26 def current_bg @current_bg end |
#current_fg ⇒ Object (readonly)
Returns the value of attribute current_fg.
26 27 28 |
# File 'lib/window_blessing/xterm_output.rb', line 26 def current_fg @current_fg end |
Instance Method Details
#change_bg(bg) ⇒ Object
13 14 15 16 |
# File 'lib/window_blessing/xterm_output.rb', line 13 def change_bg(bg) set_bg(bg) if bg!=@current_bg @current_bg = bg end |
#change_fg(fg) ⇒ Object
8 9 10 11 |
# File 'lib/window_blessing/xterm_output.rb', line 8 def change_fg(fg) set_fg(fg) if fg!=@current_fg @current_fg = fg end |
#out_color(txt, fg, bg) ⇒ Object
47 48 49 50 51 |
# File 'lib/window_blessing/xterm_output.rb', line 47 def out_color(txt, fg, bg) set_color(fg, bg) out txt reset_color end |
#reset_color ⇒ Object
41 42 43 44 45 |
# File 'lib/window_blessing/xterm_output.rb', line 41 def reset_color @current_fg = 7 @current_bg = 0 out "\x1b[0m" end |
#set_bg(bg) ⇒ Object
22 23 24 |
# File 'lib/window_blessing/xterm_output.rb', line 22 def set_bg(bg) out "\x1b[48;5;#{bg}m" end |
#set_bold ⇒ Object
53 |
# File 'lib/window_blessing/xterm_output.rb', line 53 def set_bold; out "\x1b[1m" end |
#set_color(fg, bg = nil) ⇒ Object
28 29 30 31 |
# File 'lib/window_blessing/xterm_output.rb', line 28 def set_color(fg, bg=nil) set_fg(fg) if fg set_bg(bg) if bg end |
#set_color_24bit(fg, bg = nil) ⇒ Object
fg and bg are r-g-b arrays: [0..255, 0..255, 0..255] This is not supported by iTerm2: code.google.com/p/iterm2/issues/detail?id=218 konsole supports it: github.com/robertknight/konsole/blob/master/user-doc/README.moreColors
36 37 38 39 |
# File 'lib/window_blessing/xterm_output.rb', line 36 def set_color_24bit(fg, bg=nil) out "\x1b[38;2;#{fg.join(';')}m" if fg out "\x1b[48;2;#{bg.join(';')}m" if bg end |
#set_fg(fg) ⇒ Object
18 19 20 |
# File 'lib/window_blessing/xterm_output.rb', line 18 def set_fg(fg) out "\x1b[38;5;#{fg}m" end |
#set_underline ⇒ Object
54 |
# File 'lib/window_blessing/xterm_output.rb', line 54 def set_underline; out "\x1b[4m" end |