Sha256: 6ab2ca3e8c7847f62e95c64c292051dbc17573a8f6f88a6cad3ba5fdea6eb491

Contents?: true

Size: 1.01 KB

Versions: 44

Compression:

Stored size: 1.01 KB

Contents

module Redcar
  class Macro
    attr_reader :actions
    attr_writer :name
    
    def initialize(name, actions, start_in_block_selection_mode)
      @actions = actions.reject {|action| action.is_a?(Redcar::Macros::StartStopRecordingCommand)}
      @name                          = name
      @start_in_block_selection_mode = start_in_block_selection_mode
    end
    
    def name
      @name
    end
    
    def start_in_block_selection_mode?
      @start_in_block_selection_mode
    end
    
    def run
      run_in EditView.focussed_edit_view
    end
    
    def run_in(edit_view)
      Macros.last_run = self
      Macros.last_run_or_recorded = self
      previous_block_selection_mode = edit_view.document.block_selection_mode?
      edit_view.document.block_selection_mode = start_in_block_selection_mode?
      
      Macros::ActionSequence.new(actions, 0).run_in(edit_view)
      
      edit_view.document.block_selection_mode = previous_block_selection_mode
      Redcar.app.repeat_event(:macro_ran)
    end
  end
end

Version data entries

44 entries across 44 versions & 2 rubygems

Version Path
redcar-0.13 plugins/macros/lib/macros/macro.rb
redcar-dev-0.13.5dev plugins/macros/lib/macros/macro.rb
redcar-dev-0.13.4dev plugins/macros/lib/macros/macro.rb
redcar-dev-0.13.3dev plugins/macros/lib/macros/macro.rb
redcar-dev-0.13.2dev plugins/macros/lib/macros/macro.rb
redcar-dev-0.13.1dev plugins/macros/lib/macros/macro.rb
redcar-0.12.1 plugins/macros/lib/macros/macro.rb
redcar-dev-0.13.0dev plugins/macros/lib/macros/macro.rb
redcar-0.12 plugins/macros/lib/macros/macro.rb
redcar-dev-0.12.27dev plugins/macros/lib/macros/macro.rb
redcar-dev-0.12.26dev plugins/macros/lib/macros/macro.rb
redcar-dev-0.12.25dev plugins/macros/lib/macros/macro.rb
redcar-dev-0.12.24dev plugins/macros/lib/macros/macro.rb
redcar-dev-0.12.23dev plugins/macros/lib/macros/macro.rb
redcar-dev-0.12.22dev plugins/macros/lib/macros/macro.rb
redcar-dev-0.12.21dev plugins/macros/lib/macros/macro.rb
redcar-dev-0.12.20dev plugins/macros/lib/macros/macro.rb
redcar-dev-0.12.19dev plugins/macros/lib/macros/macro.rb
redcar-dev-0.12.18dev plugins/macros/lib/macros/macro.rb
redcar-dev-0.12.17dev plugins/macros/lib/macros/macro.rb