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.



1569
1570
1571
1572
# File 'lib/textbringer/buffer.rb', line 1569

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

Instance Method Details

#merge(s) ⇒ Object



1584
1585
1586
# File 'lib/textbringer/buffer.rb', line 1584

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

#redoObject



1579
1580
1581
1582
# File 'lib/textbringer/buffer.rb', line 1579

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

#undoObject



1574
1575
1576
1577
# File 'lib/textbringer/buffer.rb', line 1574

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