starting interpreter and getting ticks going (slowly)

This commit is contained in:
Torsten Ruger 2015-08-22 01:59:29 +02:00
parent 3fa685a0bb
commit ed2a054ca6
4 changed files with 10 additions and 9 deletions

View File

@ -42,7 +42,6 @@ class ElementView
#wrap the given node with the wappper, so for a div wrapper and a button node
# the result will be <div> <button>hwatever was in there</button> <div>
def wrap_node_with node , wrapper
puts "wraps parent #{node.parent}"
node.replace_with(wrapper) if node.parent
wrapper << node
end

View File

@ -15,7 +15,7 @@ class BlocksView < ElementView
blocks.each do |b|
dom.div do
dom.span do # class="{{b._class_name}}">
b.name
b.class.name
end
end
end

View File

@ -27,6 +27,7 @@ class MainView < ListView
machine.run_before "Register::CallImplementation"
@interpreter = Interpreter::Interpreter.new
@interpreter.start machine.init
super( [ClassesView.new(@interpreter) ,
FileView.new ,
BlocksView.new(@interpreter) ,

View File

@ -6,8 +6,8 @@ class StatusView < ElementView
def draw
@element = div(".status_view") <<
div("h4.tick" , "Interpreter" ) <<
div("span" , tick_text) <<
div("h4" , "Interpreter" ) <<
div("span.clock" , clock_text) <<
div("button.act" , "Next") <<
div( "br") <<
div("span.state" , state_text) <<
@ -16,14 +16,15 @@ class StatusView < ElementView
div( "br" , "Stdout") <<
div("span.stdout")
# set up event handler
@element.at_css(".act").on("click") { @interpreter.tick }
@element.at_css(".act").on("click") { self.update }
return @element
end
def update
@element.at_css(".tick").text = tick_text
@link.at_css(".link").text = link_text
@stdout.at_css(".stdout").text = @interpreter.stdout
@interpreter.tick
@element.at_css(".clock").text = clock_text
@element.at_css(".link").text = link_text
@element.at_css(".stdout").text = @interpreter.stdout
end
def link_text
@ -34,7 +35,7 @@ class StatusView < ElementView
"State #{@interpreter.state}"
end
def tick_text
def clock_text
"Instruction #{@interpreter.clock}"
end
end