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.



1839
1840
1841
1842
# File 'lib/textbringer/buffer.rb', line 1839

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

Instance Method Details

#add_action(action) ⇒ Object



1844
1845
1846
# File 'lib/textbringer/buffer.rb', line 1844

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

#redoObject



1855
1856
1857
1858
1859
# File 'lib/textbringer/buffer.rb', line 1855

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

#undoObject



1848
1849
1850
1851
1852
1853
# File 'lib/textbringer/buffer.rb', line 1848

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