better block view

This commit is contained in:
Torsten Ruger 2015-07-26 09:04:34 +03:00
parent 515e1b106b
commit 3464e50b2f
2 changed files with 19 additions and 8 deletions

View File

@ -7,26 +7,35 @@ class BlockView
include React::Component include React::Component
required_param :interpreter required_param :interpreter
define_state :block define_state :block => []
define_state :block_name => ""
before_mount do before_mount do
interpreter.register_event(:block_changed, self) interpreter.register_event(:instruction_changed, self)
block! interpreter.block update_block
end end
def block_changed old , bl def update_block
block! bl block_name! interpreter.block.name
codes = interpreter.block.codes.dup
codes.shift while( codes.index(interpreter.instruction) > 1 )
codes.pop while(codes.length > 4)
block! codes
end
def instruction_changed
update_block
end end
def render def render
return unless block return unless block
div.row do div.row do
div.col_md_5 do div.col_md_5 do
SourceView :source => block.codes.first.source SourceView :source => interpreter.instruction.source
end end
div.col_md_5 do div.col_md_5 do
h6 { "Block: #{block.name}"} h6 { "Block: #{block_name}"}
block.codes.each do |code| block.each do |code|
InstructionView :interpreter => interpreter , :instruction => code InstructionView :interpreter => interpreter , :instruction => code
end end
end end

View File

@ -27,6 +27,8 @@ class RegisterView
end end
object.get_instance_variables.each do |variable| object.get_instance_variables.each do |variable|
div.col_md_12 do div.col_md_12 do
## deal with String
## even better, make ObjectView
object.get_instance_variable(variable).to_s.span object.get_instance_variable(variable).to_s.span
end end
end end