Method: Gtk::TextBuffer#undo

Defined in:
lib/gtk_app/ext/text_buffer.rb

#undoObject

Pop the last action off the undo stack and rewind changes. If an action was performed, the cursor is placed at the actions starting Gtk::TextIter.



32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/gtk_app/ext/text_buffer.rb', line 32

def undo
  if @undo_stack.empty?
    Gdk.beep
  else
    action = @undo_stack.pop
    s_iter = get_iter_at_offset(action[1])
    case action[0]
    when :insert then delete(s_iter, get_iter_at_offset(action[2]))
    when :delete then insert(s_iter, action[3])
    end
    @redo_stack.push(action)
    place_cursor(s_iter)
  end
end