Class: Textbringer::InsertAction
- Inherits:
-
UndoableAction
- Object
- UndoableAction
- Textbringer::InsertAction
- Defined in:
- lib/textbringer/buffer.rb
Instance Attribute Summary collapse
-
#string ⇒ Object
readonly
Returns the value of attribute string.
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.
1768 1769 1770 1771 1772 |
# File 'lib/textbringer/buffer.rb', line 1768 def initialize(buffer, location, string) super(buffer, location) @string = string @copied = false end |
Instance Attribute Details
#string ⇒ Object (readonly)
Returns the value of attribute string.
1766 1767 1768 |
# File 'lib/textbringer/buffer.rb', line 1766 def string @string end |
Instance Method Details
#merge(s) ⇒ Object
1784 1785 1786 1787 1788 1789 1790 |
# File 'lib/textbringer/buffer.rb', line 1784 def merge(s) unless @copied @string = @string.dup @copied = true end @string.concat(s) end |
#redo ⇒ Object
1779 1780 1781 1782 |
# File 'lib/textbringer/buffer.rb', line 1779 def redo @buffer.goto_char(@location) @buffer.insert(@string) end |
#undo ⇒ Object
1774 1775 1776 1777 |
# File 'lib/textbringer/buffer.rb', line 1774 def undo @buffer.goto_char(@location) @buffer.delete_region(@location, @location + @string.bytesize) end |