Class: Textbringer::CompositeAction

Inherits:
UndoableAction show all
Defined in:
lib/textbringer/buffer.rb

Instance Attribute Summary

Attributes inherited from UndoableAction

#file_version, #location

Instance Method Summary collapse

Constructor Details

#initialize(buffer, location) ⇒ CompositeAction



1896
1897
1898
1899
# File 'lib/textbringer/buffer.rb', line 1896

def initialize(buffer, location)
  super(buffer, location)
  @actions = []
end

Instance Method Details

#add_action(action) ⇒ Object



1901
1902
1903
# File 'lib/textbringer/buffer.rb', line 1901

def add_action(action)
  @actions.push(action)
end

#redoObject



1912
1913
1914
1915
1916
# File 'lib/textbringer/buffer.rb', line 1912

def redo
  @actions.each do |action|
    action.redo
  end
end

#undoObject



1905
1906
1907
1908
1909
1910
# File 'lib/textbringer/buffer.rb', line 1905

def undo
  @actions.reverse_each do |action|
    action.undo
  end
  @buffer.goto_char(@location)
end