starting interpreter and getting ticks going (slowly)
This commit is contained in:
parent
3fa685a0bb
commit
ed2a054ca6
@ -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
|
||||
|
@ -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
|
||||
|
@ -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) ,
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user