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.



1792
1793
1794
1795
1796
# File 'lib/textbringer/buffer.rb', line 1792

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.



1790
1791
1792
# File 'lib/textbringer/buffer.rb', line 1790

def string
  @string
end

Instance Method Details

#redoObject



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

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

#undoObject



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

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