Class: Textbringer::InsertAction

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, string) ⇒ InsertAction

Returns a new instance of InsertAction.



1651
1652
1653
1654
# File 'lib/textbringer/buffer.rb', line 1651

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

Instance Method Details

#merge(s) ⇒ Object



1666
1667
1668
# File 'lib/textbringer/buffer.rb', line 1666

def merge(s)
  @string.concat(s)
end

#redoObject



1661
1662
1663
1664
# File 'lib/textbringer/buffer.rb', line 1661

def redo
  @buffer.goto_char(@location)
  @buffer.insert(@string)
end

#undoObject



1656
1657
1658
1659
# File 'lib/textbringer/buffer.rb', line 1656

def undo
  @buffer.goto_char(@location)
  @buffer.delete_region(@location, @location + @string.bytesize)
end