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.



1586
1587
1588
1589
# File 'lib/textbringer/buffer.rb', line 1586

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

Instance Method Details

#merge(s) ⇒ Object



1601
1602
1603
# File 'lib/textbringer/buffer.rb', line 1601

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

#redoObject



1596
1597
1598
1599
# File 'lib/textbringer/buffer.rb', line 1596

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

#undoObject



1591
1592
1593
1594
# File 'lib/textbringer/buffer.rb', line 1591

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