Class: Textbringer::DeleteAction

Inherits:
UndoableAction show all
Defined in:
lib/textbringer/buffer.rb

Instance Attribute Summary collapse

Attributes inherited from UndoableAction

#location, #version

Instance Method Summary collapse

Constructor Details

#initialize(buffer, location, insert_location, string) ⇒ DeleteAction

Returns a new instance of DeleteAction.



1976
1977
1978
1979
1980
# File 'lib/textbringer/buffer.rb', line 1976

def initialize(buffer, location, insert_location, string)
  super(buffer, location)
  @insert_location = insert_location
  @string = string
end

Instance Attribute Details

#stringObject (readonly)

Returns the value of attribute string.



1974
1975
1976
# File 'lib/textbringer/buffer.rb', line 1974

def string
  @string
end

Instance Method Details

#redoObject



1988
1989
1990
1991
1992
# File 'lib/textbringer/buffer.rb', line 1988

def redo
  @buffer.goto_char(@insert_location)
  @buffer.delete_region(@insert_location,
                        @insert_location + @string.bytesize)
end

#undoObject



1982
1983
1984
1985
1986
# File 'lib/textbringer/buffer.rb', line 1982

def undo
  @buffer.goto_char(@insert_location)
  @buffer.insert(@string)
  @buffer.goto_char(@location)
end