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.9.0 plugins/macros/lib/macros/macro.rb
redcar-0.8.1 plugins/macros/lib/macros/macro.rb
redcar-0.8 plugins/macros/lib/macros/macro.rb
redcar-0.7 plugins/macros/lib/macros/macro.rb