rubyx-debugger/lib/views/source_view.rb

31 lines
586 B
Ruby
Raw Normal View History

2015-10-29 15:49:14 +01:00
class SourceView < ElementView
def initialize interpreter
@interpreter = interpreter
@interpreter.register_event(:instruction_changed, self)
end
def draw
@text = div
2015-10-29 15:53:46 +01:00
@ticker = div
@element = div(".source_view") << div("h4" ,"Future") << @ticker << @text
2015-10-29 15:49:14 +01:00
@element
end
def instruction_changed
i = @interpreter.instruction
return "" unless i
case i.source
when AST::Node
2015-10-29 15:53:46 +01:00
@text.text = i.source.to_s
@ticker.text = ""
2015-10-29 15:49:14 +01:00
when String
2015-10-29 15:53:46 +01:00
@ticker.text = i.source
2015-10-29 15:49:14 +01:00
else
raise i.source.class.name
end
end
end