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.



1368
1369
1370
1371
# File 'lib/textbringer/buffer.rb', line 1368

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

Instance Method Details

#merge(s) ⇒ Object



1383
1384
1385
# File 'lib/textbringer/buffer.rb', line 1383

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

#redoObject



1378
1379
1380
1381
# File 'lib/textbringer/buffer.rb', line 1378

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

#undoObject



1373
1374
1375
1376
# File 'lib/textbringer/buffer.rb', line 1373

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