Class: VER::Status::NanoHelp

Inherits:
Tk::Tile::Frame
  • Object
show all
Defined in:
lib/ver/status/nano_help.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status, options = {}) ⇒ NanoHelp

Returns a new instance of NanoHelp.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/ver/status/nano_help.rb', line 6

def initialize(status, options = {})
  @status = status
  @weight = options.delete(:weight) || 0
  @row = options.delete(:row)
  @column = options.delete(:column)
  @sticky = options.delete(:sticky)
  @font = status.text.options.font

  super

  @long_labels = []
  @short_labels = []

  add 0, 0, '^G', ' Get Help'
  add 0, 1, '^O', ' WriteOut'
  add 0, 2, '^R', ' Read File'
  add 0, 3, '^Y', ' Prev Page'
  add 0, 4, '^K', ' Cut Text'
  add 0, 5, '^C', ' Cur Pos'
  add 1, 0, '^X', ' Exit'
  add 1, 1, '^J', ' Justify'
  add 1, 2, '^W', ' Where Is'
  add 1, 3, '^V', ' Next Page'
  add 1, 4, '^U', ' UnCut Text'
  add 1, 5, '^T', ' To Spell'

  0.upto 11 do |col|
    weight = col % 2 == 0 ? 0 : 1
    grid_columnconfigure(col, weight: weight)
  end
end

Instance Attribute Details

#columnObject (readonly)

Returns the value of attribute column.



4
5
6
# File 'lib/ver/status/nano_help.rb', line 4

def column
  @column
end

#rowObject (readonly)

Returns the value of attribute row.



4
5
6
# File 'lib/ver/status/nano_help.rb', line 4

def row
  @row
end

#statusObject (readonly)

Returns the value of attribute status.



4
5
6
# File 'lib/ver/status/nano_help.rb', line 4

def status
  @status
end

#stickyObject (readonly)

Returns the value of attribute sticky.



4
5
6
# File 'lib/ver/status/nano_help.rb', line 4

def sticky
  @sticky
end

#weightObject (readonly)

Returns the value of attribute weight.



4
5
6
# File 'lib/ver/status/nano_help.rb', line 4

def weight
  @weight
end

Instance Method Details

#add(row, col, short, long) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/ver/status/nano_help.rb', line 38

def add(row, col, short, long)
  short_label = Tk::Tile::Label.new(
    self, font: @font, background: 'white', foreground: 'black', text: short)
  long_label  = Tk::Tile::Label.new(
    self, font: @font, background: 'black', foreground: 'white', text: long)
  short_col = col * 2
  long_col = short_col + 1

  short_label.grid_configure(row: row, column: short_col, sticky: :w)
  long_label.grid_configure(row: row, column: long_col, sticky: :we)

  @long_labels << long_label
  @short_labels << short_label
end

#style=(config) ⇒ Object



53
54
55
# File 'lib/ver/status/nano_help.rb', line 53

def style=(config)
  # @long_labels.each{|label| label.configure(config) }
end

#toggleObject



57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/ver/status/nano_help.rb', line 57

def toggle
  info = grid_info

  if info.empty?
    grid_configure(@last_grid_info)
    true
  else
    @last_grid_info = info
    grid_forget
    false
  end
end