Class: Textbringer::DeleteAction
- Inherits:
-
UndoableAction
- Object
- UndoableAction
- Textbringer::DeleteAction
- Defined in:
- lib/textbringer/buffer.rb
Instance Attribute Summary
Attributes inherited from UndoableAction
Instance Method Summary collapse
-
#initialize(buffer, location, insert_location, string) ⇒ DeleteAction
constructor
A new instance of DeleteAction.
- #redo ⇒ Object
- #undo ⇒ Object
Constructor Details
#initialize(buffer, location, insert_location, string) ⇒ DeleteAction
Returns a new instance of DeleteAction.
1822 1823 1824 1825 1826 |
# File 'lib/textbringer/buffer.rb', line 1822 def initialize(buffer, location, insert_location, string) super(buffer, location) @insert_location = insert_location @string = string end |
Instance Method Details
#redo ⇒ Object
1834 1835 1836 1837 1838 |
# File 'lib/textbringer/buffer.rb', line 1834 def redo @buffer.goto_char(@insert_location) @buffer.delete_region(@insert_location, @insert_location + @string.bytesize) end |
#undo ⇒ Object
1828 1829 1830 1831 1832 |
# File 'lib/textbringer/buffer.rb', line 1828 def undo @buffer.goto_char(@insert_location) @buffer.insert(@string) @buffer.goto_char(@location) end |