rubyx-debugger/lib/status_view.rb

41 lines
896 B
Ruby
Raw Normal View History

2015-08-20 20:03:00 +02:00
class StatusView < ElementView
2015-08-22 01:06:48 +02:00
def initialize interpreter
@interpreter = interpreter
end
2015-08-20 20:03:00 +02:00
2015-08-22 01:06:48 +02:00
def draw
create_element(".status_view") <<
div("h4.tick" , "Interpreter" ) <<
div("span" , tick_text) <<
div("button.act" , "Next") <<
div( "br") <<
div("span.state" , state_text) <<
div( "br") <<
div( "span.link" , link_text) <<
div( "br" , "Stdout") <<
div("span.stdout")
# set up event handler
@element.at_css(".act").on("click") { @interpreter.tick }
return @element
end
2015-08-20 20:03:00 +02:00
2015-08-22 01:06:48 +02:00
def update
@element.at_css(".tick").text = tick_text
@link.at_css(".link").text = link_text
@stdout.at_css(".stdout").text = @interpreter.stdout
end
def link_text
"Link #{@interpreter.link}"
end
def state_text
"State #{@interpreter.state}"
end
def tick_text
"Instruction #{@interpreter.clock}"
end
end