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.



1607
1608
1609
1610
1611
# File 'lib/textbringer/buffer.rb', line 1607

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

Instance Method Details

#redoObject



1619
1620
1621
1622
1623
# File 'lib/textbringer/buffer.rb', line 1619

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

#undoObject



1613
1614
1615
1616
1617
# File 'lib/textbringer/buffer.rb', line 1613

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