Module: Canis::BorderTitle

Included in:
Box, MessageBox, TextPad
Defined in:
lib/canis/core/include/bordertitle.rb

Instance Method Summary collapse

Instance Method Details

#bordertitle_initObject



10
11
12
13
14
# File 'lib/canis/core/include/bordertitle.rb', line 10

def bordertitle_init
  @_bordertitle_init_called = true
  @row_offset = @col_offset = 0 if @suppress_borders 
  @internal_width = 1 if @suppress_borders # the other programs have zero not 1 NOTE
end

why the dash does it reduce height by one.

Raises:

  • (ArgumentError)


16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/canis/core/include/bordertitle.rb', line 16

def print_borders
  bordertitle_init unless @_bordertitle_init_called
  raise ArgumentError, "Graphic not set" unless @graphic
  raise "#{self} needs width" unless @width
  raise "#{self} needs height" unless @height
  width = @width
  height = @height-1
  window = @graphic
  startcol = @col 
  startrow = @row 
  @color_pair = get_color($datacolor)
  bordercolor = @border_color || @color_pair
  borderatt = @border_attrib || Ncurses::A_NORMAL
  window.print_border startrow, startcol, height, width, bordercolor, borderatt
  print_title
end


32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/canis/core/include/bordertitle.rb', line 32

def print_title
  bordertitle_init unless @_bordertitle_init_called
  return unless @title
  raise "#{self} needs width" unless @width
  # removed || since this can change after first invocation and should be recalculated.
  @color_pair = get_color($datacolor) 
  #$log.debug " print_title #{@row}, #{@col}, #{@width}  "
  # check title.length and truncate if exceeds width
  _title = @title
  if @title.length > @width - 2
    _title = @title[0..@width-2]
  end
  @graphic.printstring( @row, @col+(@width-_title.length)/2, _title, @color_pair, @title_attrib) unless @title.nil?
end