class Curses::Window

Attributes

attr[RW]
bg[RW]
color[RW]
fg[RW]
update[RW]

Public Instance Methods

clr() click to toggle source

Set self.color for an already defined color pair such as: init_pair(1, 255, 3) The color pair is defined like this: init_pair(index, foreground, background) self.fg is set for the foreground color (and is used if self.color is not set) self.bg is set for the background color (and is used if self.color is not set) self.attr is set for text attributes like Curses::A_BOLD

# File lib/curses-extension.rb, line 9
def clr # Clears the whole window
  self.setpos(0, 0)
  self.maxy.times {self.deleteln()}
  self.refresh
  self.setpos(0, 0)
end
clr_from_cur_line() click to toggle source
# File lib/curses-extension.rb, line 21
def clr_from_cur_line
  l = self.cury
  (self.maxy - l).times {self.deleteln()}
  self.refresh
  self.setpos(l, 0)
end
clr_to_cur_line() click to toggle source
# File lib/curses-extension.rb, line 15
def clr_to_cur_line
  l = self.cury
  self.setpos(0, 0)
  l.times {self.deleteln()}
  self.refresh
end
fill() click to toggle source
# File lib/curses-extension.rb, line 27
def fill # Fill window with color as set by self.color (or self.bg if not set)
  self.setpos(0, 0)
  self.fill_from_cur_pos
end
fill_from_cur_pos() click to toggle source
# File lib/curses-extension.rb, line 47
def fill_from_cur_pos # Fills the rest of the window from current line
  x = self.curx
  y = self.cury
  self.setpos(y, 0)
  blank = " " * self.maxx
  if self.color == nil
    self.bg = 0 if self.bg   == nil
    self.fg = 255 if self.fg == nil
    init_pair(self.fg, self.fg, self.bg)
    self.maxy.times {self.attron(color_pair(self.fg)) {self << blank}}
  else
    self.maxy.times {self.attron(color_pair(self.color)) {self << blank}}
  end
  self.refresh
  self.setpos(y, x)
end
fill_to_cur_pos() click to toggle source
# File lib/curses-extension.rb, line 31
def fill_to_cur_pos # Fills the window up to current line
  x = self.curx
  y = self.cury
  self.setpos(0, 0)
  blank = " " * self.maxx
  if self.color == nil
    self.bg = 0 if self.bg   == nil
    self.fg = 255 if self.fg == nil
    init_pair(self.fg, self.fg, self.bg)
    y.times {self.attron(color_pair(self.fg)) {self << blank}}
  else
    y.times {self.attron(color_pair(self.color)) {self << blank}}
  end
  self.refresh
  self.setpos(y, x)
end
p(text) click to toggle source
# File lib/curses-extension.rb, line 63
def p(text) # Puts text to window
  self.attr = 0 if self.attr == nil
  if self.color == nil
    self.bg = 0 if self.bg   == nil
    self.fg = 255 if self.fg == nil
    init_pair(self.fg, self.fg, self.bg)
    self.attron(color_pair(self.fg) | self.attr) { self << text }
  else
    self.attron(color_pair(self.color) | self.attr) { self << text }
  end
  self.refresh
end
pa(fg, bg, attr, text) click to toggle source
# File lib/curses-extension.rb, line 83
def pa(fg, bg, attr, text) # Puts text to window with full set of attributes
  self.fg = fg
  self.bg = bg
  self.attr = attr
  init_pair(self.fg, self.fg, self.bg)
  self.attron(color_pair(self.fg) | self.attr) { self << text }
  self.refresh
end
paclr(fg, bg, attr, text) click to toggle source
# File lib/curses-extension.rb, line 79
def paclr(fg, bg, attr, text) # Puts text to window with full set of attributes and clears rest of window
  self.paclr(fg, bg, attr, text)
  self.clr_from_cur_line
end
pclr(text) click to toggle source
# File lib/curses-extension.rb, line 75
def pclr(text) # Puts text to window and clears the rest of the window
  self.p(text)
  self.clr_from_cur_line
end