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



1886
1887
1888
1889
# File 'lib/textbringer/buffer.rb', line 1886

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

Instance Method Details

#add_action(action) ⇒ Object



1891
1892
1893
# File 'lib/textbringer/buffer.rb', line 1891

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

#redoObject



1902
1903
1904
1905
1906
# File 'lib/textbringer/buffer.rb', line 1902

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

#undoObject



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

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