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



1866
1867
1868
1869
1870
# File 'lib/textbringer/buffer.rb', line 1866

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.



1864
1865
1866
# File 'lib/textbringer/buffer.rb', line 1864

def string
  @string
end

Instance Method Details

#redoObject



1878
1879
1880
1881
1882
# File 'lib/textbringer/buffer.rb', line 1878

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

#undoObject



1872
1873
1874
1875
1876
# File 'lib/textbringer/buffer.rb', line 1872

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