Module: LessCurse::Renderer

Defined in:
lib/less_curse/renderer.rb

Class Method Summary collapse

Class Method Details

.bold_if(condition, window) ⇒ Object

Switch on boldness depending on condition



21
22
23
24
25
26
27
28
29
# File 'lib/less_curse/renderer.rb', line 21

def self.bold_if condition, window
  if condition
    FFI::NCurses.wattron window, FFI::NCurses::A_BOLD
  end
  yield
  if condition
    FFI::NCurses.wattroff window, FFI::NCurses::A_BOLD
  end
end

.box_foot(window, text) ⇒ Object

Draw into lower border of a box



10
11
12
13
# File 'lib/less_curse/renderer.rb', line 10

def self.box_foot window, text
  height,width = FFI::NCurses::getmaxyx(window)
  FFI::NCurses.mvwaddstr window, height - 1, 1, text
end

.box_with_title(window, title) ⇒ Object

Draw box and title in top border of box



4
5
6
7
# File 'lib/less_curse/renderer.rb', line 4

def self.box_with_title window, title
  FFI::NCurses.box window, 0, 0
  FFI::NCurses.mvwaddstr window, 0, 1, title
end

.write_line(window, line_number, text) ⇒ Object

Write a line in window



16
17
18
# File 'lib/less_curse/renderer.rb', line 16

def self.write_line window, line_number, text
  FFI::NCurses.mvwaddstr window, line_number + 1, 1, text
end