Method: GtkApp::TextBuffer#undo

Defined in:
lib/gtk_app/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.



52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/gtk_app/text_buffer.rb', line 52

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