Method: WindowBlessing::Buffer#fill
- Defined in:
- lib/window_blessing/buffer.rb
#fill(options = {}) ⇒ Object
Fills characters, foreground and/or background buffers with the specified values.
If one of the buffers is not specified to be filled, it is not changed.
For example, you can set the foreground color without changing the text:
fill :fg => rgb_screen_color(1,0,0)
options
:area => Rectangle # only fill the specified area (intersected with the crop_area)
:bg => background color OR 1d array of bg-color pattern - nil => don't touch bg
:fg => foreground color OR 1d array of fg-color pattern - nil => don't touch fb
:string => string - length 1 or more, use to fill-init @contents - nil => don't touch @contents
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 |
# File 'lib/window_blessing/buffer.rb', line 178 def fill( = {}) area = crop_area area = area | [:area] if [:area] string = [:string] fg = [:fg] bg = [:bg] fg = fg.to_screen_color if fg.kind_of?(Color) bg = bg.to_screen_color if bg.kind_of?(Color) return if area.size==point if area != internal_area @contents = (area.loc, gen_array2d(area.size, string), contents) if string @fg_buffer = (area.loc, gen_array2d(area.size, fg), fg_buffer) if fg @bg_buffer = (area.loc, gen_array2d(area.size, bg), bg_buffer) if bg else @contents = gen_array2d(size, string) if string @fg_buffer = gen_array2d(size, fg) if fg @bg_buffer = gen_array2d(size, bg) if bg end dirty area self end |