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.
1948 1949 1950 1951 1952 |
# File 'lib/textbringer/buffer.rb', line 1948 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.
1946 1947 1948 |
# File 'lib/textbringer/buffer.rb', line 1946 def string @string end |
Instance Method Details
#merge(s) ⇒ Object
1964 1965 1966 1967 1968 1969 1970 |
# File 'lib/textbringer/buffer.rb', line 1964 def merge(s) unless @copied @string = @string.dup @copied = true end @string.concat(s) end |
#redo ⇒ Object
1959 1960 1961 1962 |
# File 'lib/textbringer/buffer.rb', line 1959 def redo @buffer.goto_char(@location) @buffer.insert(@string) end |
#undo ⇒ Object
1954 1955 1956 1957 |
# File 'lib/textbringer/buffer.rb', line 1954 def undo @buffer.goto_char(@location) @buffer.delete_region(@location, @location + @string.bytesize) end |