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.
1793 1794 1795 1796 1797 |
# File 'lib/textbringer/buffer.rb', line 1793 def initialize(buffer, location, string) super(buffer, location) @string = string @copied = false end |
Instance Method Details
#merge(s) ⇒ Object
1809 1810 1811 1812 1813 1814 1815 |
# File 'lib/textbringer/buffer.rb', line 1809 def merge(s) unless @copied @string = @string.dup @copied = true end @string.concat(s) end |
#redo ⇒ Object
1804 1805 1806 1807 |
# File 'lib/textbringer/buffer.rb', line 1804 def redo @buffer.goto_char(@location) @buffer.insert(@string) end |
#undo ⇒ Object
1799 1800 1801 1802 |
# File 'lib/textbringer/buffer.rb', line 1799 def undo @buffer.goto_char(@location) @buffer.delete_region(@location, @location + @string.bytesize) end |