Class: Textbringer::DeleteAction

Inherits:
UndoableAction show all
Defined in:
lib/textbringer/buffer.rb

Instance Attribute Summary collapse

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.



1797
1798
1799
1800
1801
# File 'lib/textbringer/buffer.rb', line 1797

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

Instance Attribute Details

#stringObject (readonly)

Returns the value of attribute string.



1795
1796
1797
# File 'lib/textbringer/buffer.rb', line 1795

def string
  @string
end

Instance Method Details

#redoObject



1809
1810
1811
1812
1813
# File 'lib/textbringer/buffer.rb', line 1809

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

#undoObject



1803
1804
1805
1806
1807
# File 'lib/textbringer/buffer.rb', line 1803

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