Class: VER::RegisterList

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ RegisterList

Returns a new instance of RegisterList.



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/ver/register.rb', line 66

def initialize(*args)
  super
  pack fill: :x

  bind '<FocusOut>' do
    destroy
  end

  Register.each do |register|
    frame = Tk::Tile::Frame.new(self)
    label = Tk::Label.new(frame, text: register.name)
    entry = Tk::Tile::Entry.new(frame)
    entry.insert(0, register.value)

    frame.pack side: :top, fill: :x
    label.pack side: :left
    entry.pack side: :right, fill: :x, expand: true
  end
end

Class Method Details

.open(buffer) ⇒ Object



46
47
48
# File 'lib/ver/register.rb', line 46

def self.open(buffer)
  new(buffer)
end

.show(buffer) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/ver/register.rb', line 50

def self.show(buffer)
  buffer.ask ':register ' do |answer, action|
    case action
    when :modified
      begin
        buffer.warn ""
        register = Register.fetch(answer)
        buffer.message '"%s: %p' % [register.name, register.value]
        :abort
      rescue KeyError => ex
        buffer.warn "#{ex}: #{answer}"
      end
    end
  end
end