From b3de7c9b5e003b1d2696aebcc035f74175484975 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Mon, 24 Aug 2015 01:45:33 +0200 Subject: [PATCH] implement instruction view , almost complete --- lib/instruction_view.rb | 52 +++++++++++++++++------------------------ lib/main_view.rb | 2 ++ 2 files changed, 24 insertions(+), 30 deletions(-) diff --git a/lib/instruction_view.rb b/lib/instruction_view.rb index 952543a..ac48bb6 100644 --- a/lib/instruction_view.rb +++ b/lib/instruction_view.rb @@ -1,38 +1,30 @@ -class InstructionView +require "base/constant_view" +require "base/list_view" - include React::Component - required_param :interpreter - required_param :instruction +class InstructionView < ListView - define_state :active => "" - - before_mount do - check_active interpreter.instruction + def initialize interpreter + @interpreter = interpreter + super([ConstantView.new( "span.bright" , "starting" )]) + @interpreter.register_event(:instruction_changed, self) end - def check_active i - active! instruction == i ? "bright" : "" - - end - def instruction_changed old , ins - check_active ins + def instruction_changed + @element.at_css(".bright").remove_class("bright") + instruction = append( ConstantView.new( "span.bright" , instruction_text ) ) + wrap_node_with instruction , div + remove_first if( @elements.length > 5) end - def render - div :class => active do - instruction.to_s if instruction - end + def draw + super() + wrap_node_with @elements.first , div + wrap_element div(".source_view") << div("h4" ,"Virtual Machine Instruction") + @element + end + + def instruction_text + return "" unless @interpreter.instruction + @interpreter.instruction.to_s end end - - -
-

Virtual Machine Instruction

- {{page._sources.each do |source| }} -
- - {{source._name}} - -
- {{end}} -
diff --git a/lib/main_view.rb b/lib/main_view.rb index c50ba14..17d3e5c 100644 --- a/lib/main_view.rb +++ b/lib/main_view.rb @@ -8,6 +8,7 @@ require_relative "classes_view" require_relative "status_view" require_relative "file_view" require_relative "blocks_view" +require_relative "instruction_view" require_relative "registers_view" class MainView < ListView @@ -31,6 +32,7 @@ class MainView < ListView super( [ClassesView.new(@interpreter) , FileView.new , BlocksView.new(@interpreter) , + InstructionView.new(@interpreter) , StatusView.new(@interpreter) , RegistersView.new(@interpreter) ] ) end