Class: Textbringer::DeleteAction

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, insert_location, string) ⇒ DeleteAction

Returns a new instance of DeleteAction.



1805
1806
1807
1808
1809
# File 'lib/textbringer/buffer.rb', line 1805

def initialize(buffer, location, insert_location, string)
  super(buffer, location)
  @insert_location = insert_location
  @string = string
end

Instance Method Details

#redoObject



1817
1818
1819
1820
1821
# File 'lib/textbringer/buffer.rb', line 1817

def redo
  @buffer.goto_char(@insert_location)
  @buffer.delete_region(@insert_location,
                        @insert_location + @string.bytesize)
end

#undoObject



1811
1812
1813
1814
1815
# File 'lib/textbringer/buffer.rb', line 1811

def undo
  @buffer.goto_char(@insert_location)
  @buffer.insert(@string)
  @buffer.goto_char(@location)
end