Module: VER::Methods::Undo

Defined in:
lib/ver/methods/undo.rb

Overview

Handles most operations on Text that concern undo/redo.

See Also:

Class Method Summary collapse

Class Method Details

.record(buffer) {|proxy| ... } ⇒ Object

Wrapper to record multiple changes to given buffer as one change, so they can be undone and redone together. A user usually expects one command to correspond to one undo record, except for things like replacement or input. So use this wrapper when you do more than one modification inside your command.

Yield Parameters:



28
29
30
# File 'lib/ver/methods/undo.rb', line 28

def record(buffer, &block)
  buffer.undo_record(&block)
end

.redo(buffer, count = buffer.prefix_count) ⇒ Object

Redo count changes made in the given buffer.



10
11
12
# File 'lib/ver/methods/undo.rb', line 10

def redo(buffer, count = buffer.prefix_count)
  count.times{ buffer.redo }
end

.separator(buffer) ⇒ Object

Insert a separator into the undo history, undo/redo apply always up to the next separator. Operates on the undoer of the given buffer.



35
36
37
# File 'lib/ver/methods/undo.rb', line 35

def separator(buffer)
  buffer.undoer.separate!
end

.undo(buffer, count = buffer.prefix_count) ⇒ Object

Undo count changes made in the given buffer



15
16
17
# File 'lib/ver/methods/undo.rb', line 15

def undo(buffer, count = buffer.prefix_count)
  count.times{ buffer.undo }
end