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.



1865
1866
1867
1868
# File 'lib/textbringer/buffer.rb', line 1865

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

Instance Method Details

#add_action(action) ⇒ Object



1870
1871
1872
# File 'lib/textbringer/buffer.rb', line 1870

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

#redoObject



1881
1882
1883
1884
1885
# File 'lib/textbringer/buffer.rb', line 1881

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

#undoObject



1874
1875
1876
1877
1878
1879
# File 'lib/textbringer/buffer.rb', line 1874

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