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.



1669
1670
1671
1672
1673
# File 'lib/textbringer/buffer.rb', line 1669

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

Instance Method Details

#redoObject



1681
1682
1683
1684
1685
# File 'lib/textbringer/buffer.rb', line 1681

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

#undoObject



1675
1676
1677
1678
1679
# File 'lib/textbringer/buffer.rb', line 1675

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