Class: Textbringer::CompositeAction

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

Instance Attribute Summary

Attributes inherited from UndoableAction

#location, #version

Instance Method Summary collapse

Constructor Details

#initialize(buffer, location) ⇒ CompositeAction

Returns a new instance of CompositeAction.



1888
1889
1890
1891
# File 'lib/textbringer/buffer.rb', line 1888

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

Instance Method Details

#add_action(action) ⇒ Object



1893
1894
1895
# File 'lib/textbringer/buffer.rb', line 1893

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

#redoObject



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

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

#undoObject



1897
1898
1899
1900
1901
1902
# File 'lib/textbringer/buffer.rb', line 1897

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