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.



1995
1996
1997
1998
1999
# File 'lib/textbringer/buffer.rb', line 1995

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.



1993
1994
1995
# File 'lib/textbringer/buffer.rb', line 1993

def string
  @string
end

Instance Method Details

#redoObject



2007
2008
2009
2010
2011
# File 'lib/textbringer/buffer.rb', line 2007

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

#undoObject



2001
2002
2003
2004
2005
# File 'lib/textbringer/buffer.rb', line 2001

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