rubyx-debugger/lib/views/source_view.rb

33 lines
561 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
@element = div(".source_view") << div("h4" ,"Future") << @text
@element
end
def instruction_changed
@text.text = source
end
def source
i = @interpreter.instruction
return "" unless i
case i.source
when AST::Node
i.source.to_s
when String
"String " + i.source
else
raise i.source.class.name
end
end
end