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.



1672
1673
1674
1675
1676
# File 'lib/textbringer/buffer.rb', line 1672

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

Instance Method Details

#redoObject



1684
1685
1686
1687
1688
# File 'lib/textbringer/buffer.rb', line 1684

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

#undoObject



1678
1679
1680
1681
1682
# File 'lib/textbringer/buffer.rb', line 1678

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