Class: Textbringer::InsertAction
- Inherits:
-
UndoableAction
- Object
- UndoableAction
- Textbringer::InsertAction
- Defined in:
- lib/textbringer/buffer.rb
Instance Attribute Summary
Attributes inherited from UndoableAction
Instance Method Summary collapse
-
#initialize(buffer, location, string) ⇒ InsertAction
constructor
A new instance of InsertAction.
- #merge(s) ⇒ Object
- #redo ⇒ Object
- #undo ⇒ Object
Constructor Details
#initialize(buffer, location, string) ⇒ InsertAction
Returns a new instance of InsertAction.
1649 1650 1651 1652 |
# File 'lib/textbringer/buffer.rb', line 1649 def initialize(buffer, location, string) super(buffer, location) @string = string end |
Instance Method Details
#merge(s) ⇒ Object
1664 1665 1666 |
# File 'lib/textbringer/buffer.rb', line 1664 def merge(s) @string.concat(s) end |
#redo ⇒ Object
1659 1660 1661 1662 |
# File 'lib/textbringer/buffer.rb', line 1659 def redo @buffer.goto_char(@location) @buffer.insert(@string) end |
#undo ⇒ Object
1654 1655 1656 1657 |
# File 'lib/textbringer/buffer.rb', line 1654 def undo @buffer.goto_char(@location) @buffer.delete_region(@location, @location + @string.bytesize) end |