rubyx-debugger/lib/status_view.rb

43 lines
939 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
@element = div(".status_view") <<
2015-08-24 01:44:50 +02:00
div("h4" , "Interpreter" ) <<
2015-08-22 01:06:48 +02:00
div("button.act" , "Next") <<
div( "br") <<
2015-08-24 01:44:50 +02:00
div("span.clock" , clock_text) <<
div( "br") <<
2015-08-22 01:06:48 +02:00
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") { self.update }
2015-08-22 01:06:48 +02:00
return @element
end
2015-08-20 20:03:00 +02:00
2015-08-22 01:06:48 +02:00
def update
@interpreter.tick
@element.at_css(".clock").text = clock_text
@element.at_css(".link").text = link_text
@element.at_css(".stdout").text = @interpreter.stdout
2015-08-22 01:06:48 +02:00
end
def link_text
"Link #{@interpreter.link}"
end
def state_text
"State #{@interpreter.state}"
end
def clock_text
2015-08-22 01:06:48 +02:00
"Instruction #{@interpreter.clock}"
end
end