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.



1551
1552
1553
1554
# File 'lib/textbringer/buffer.rb', line 1551

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

Instance Method Details

#merge(s) ⇒ Object



1566
1567
1568
# File 'lib/textbringer/buffer.rb', line 1566

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

#redoObject



1561
1562
1563
1564
# File 'lib/textbringer/buffer.rb', line 1561

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

#undoObject



1556
1557
1558
1559
# File 'lib/textbringer/buffer.rb', line 1556

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