Class: Textbringer::DeleteAction
- Inherits:
-
UndoableAction
- Object
- UndoableAction
- Textbringer::DeleteAction
- 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, 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.
1876 1877 1878 1879 1880 |
# File 'lib/textbringer/buffer.rb', line 1876 def initialize(buffer, location, insert_location, string) super(buffer, location) @insert_location = insert_location @string = string end |
Instance Attribute Details
#string ⇒ Object (readonly)
Returns the value of attribute string.
1874 1875 1876 |
# File 'lib/textbringer/buffer.rb', line 1874 def string @string end |
Instance Method Details
#redo ⇒ Object
1888 1889 1890 1891 1892 |
# File 'lib/textbringer/buffer.rb', line 1888 def redo @buffer.goto_char(@insert_location) @buffer.delete_region(@insert_location, @insert_location + @string.bytesize) end |
#undo ⇒ Object
1882 1883 1884 1885 1886 |
# File 'lib/textbringer/buffer.rb', line 1882 def undo @buffer.goto_char(@insert_location) @buffer.insert(@string) @buffer.goto_char(@location) end |