annotate pidgin/gtksourceundomanager.c @ 32827:4a34689eeb33 default tip

merged from im.pidgin.pidgin
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Sat, 19 Nov 2011 14:42:54 +0900
parents 8e29b6fff216
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2 /*
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3 * gtksourceundomanager.c
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
4 * This file is part of GtkSourceView
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
5 *
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
6 * Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
7 * Copyright (C) 2000, 2001 Chema Celorio, Paolo Maggi
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
8 * Copyright (C) 2002-2005 Paolo Maggi
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
9 *
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
10 * This program is free software; you can redistribute it and/or modify
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
11 * it under the terms of the GNU General Public License as published by
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
12 * the Free Software Foundation; either version 2 of the License, or
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
13 * (at your option) any later version.
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
14 *
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
15 * This program is distributed in the hope that it will be useful,
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
18 * GNU General Public License for more details.
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
19 *
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
20 * You should have received a copy of the GNU General Public License
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
21 * along with this program; if not, write to the Free Software
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
19680
44b4e8bd759b The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 19548
diff changeset
23 * Boston, MA 02111-1301, USA.
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
24 */
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
25
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
26 #ifdef HAVE_CONFIG_H
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
27 #include <config.h>
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
28 #endif
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
29
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
30 #include <glib.h>
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
31 #include <stdlib.h>
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
32 #include <string.h>
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
33
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
34 #include "gtksourceundomanager.h"
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
35 #include "gtksourceview-marshal.h"
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
36
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
37
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
38 #define DEFAULT_MAX_UNDO_LEVELS 25
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
39
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
40
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
41 typedef struct _GtkSourceUndoAction GtkSourceUndoAction;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
42 typedef struct _GtkSourceUndoInsertAction GtkSourceUndoInsertAction;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
43 typedef struct _GtkSourceUndoDeleteAction GtkSourceUndoDeleteAction;
22674
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
44 typedef struct _GtkSourceUndoInsertAnchorAction GtkSourceUndoInsertAnchorAction;
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
45
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
46 typedef enum {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
47 GTK_SOURCE_UNDO_ACTION_INSERT,
22674
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
48 GTK_SOURCE_UNDO_ACTION_DELETE,
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
49 GTK_SOURCE_UNDO_ACTION_INSERT_ANCHOR,
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
50 } GtkSourceUndoActionType;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
51
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
52 /*
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
53 * We use offsets instead of GtkTextIters because the last ones
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
54 * require to much memory in this context without giving us any advantage.
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
55 */
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
56
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
57 struct _GtkSourceUndoInsertAction
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
58 {
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
59 gint pos;
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
60 gchar *text;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
61 gint length;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
62 gint chars;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
63 };
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
64
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
65 struct _GtkSourceUndoDeleteAction
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
66 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
67 gint start;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
68 gint end;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
69 gchar *text;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
70 gboolean forward;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
71 };
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
72
22674
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
73 struct _GtkSourceUndoInsertAnchorAction
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
74 {
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
75 gint pos;
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
76 GtkTextChildAnchor *anchor;
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
77 };
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
78
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
79 struct _GtkSourceUndoAction
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
80 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
81 GtkSourceUndoActionType action_type;
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
82
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
83 union {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
84 GtkSourceUndoInsertAction insert;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
85 GtkSourceUndoDeleteAction delete;
22674
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
86 GtkSourceUndoInsertAnchorAction insert_anchor;
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
87 } action;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
88
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
89 gint order_in_group;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
90
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
91 /* It is TRUE whether the action can be merged with the following action. */
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
92 guint mergeable : 1;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
93
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
94 /* It is TRUE whether the action is marked as "modified".
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
95 * An action is marked as "modified" if it changed the
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
96 * state of the buffer from "not modified" to "modified". Only the first
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
97 * action of a group can be marked as modified.
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
98 * There can be a single action marked as "modified" in the actions list.
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
99 */
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
100 guint modified : 1;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
101 };
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
102
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
103 /* INVALID is a pointer to an invalid action */
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
104 #define INVALID ((void *) "IA")
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
105
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
106 struct _GtkSourceUndoManagerPrivate
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
107 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
108 GtkTextBuffer *document;
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
109
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
110 GList* actions;
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
111 gint next_redo;
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
112
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
113 gint actions_in_current_group;
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
114
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
115 gint running_not_undoable_actions;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
116
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
117 gint num_of_groups;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
118
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
119 gint max_undo_levels;
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
120
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
121 guint can_undo : 1;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
122 guint can_redo : 1;
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
123
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
124 /* It is TRUE whether, while undoing an action of the current group (with order_in_group > 1),
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
125 * the state of the buffer changed from "not modified" to "modified".
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
126 */
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
127 guint modified_undoing_group : 1;
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
128
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
129 /* Pointer to the action (in the action list) marked as "modified".
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
130 * It is NULL when no action is marked as "modified".
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
131 * It is INVALID when the action marked as "modified" has been removed
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
132 * from the action list (freeing the list or resizing it) */
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
133 GtkSourceUndoAction *modified_action;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
134 };
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
135
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
136 enum {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
137 CAN_UNDO,
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
138 CAN_REDO,
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
139 LAST_SIGNAL
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
140 };
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
141
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
142 static void gtk_source_undo_manager_class_init (GtkSourceUndoManagerClass *klass);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
143 static void gtk_source_undo_manager_init (GtkSourceUndoManager *um);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
144 static void gtk_source_undo_manager_finalize (GObject *object);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
145
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
146 static void gtk_source_undo_manager_insert_text_handler (GtkTextBuffer *buffer,
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
147 GtkTextIter *pos,
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
148 const gchar *text,
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
149 gint length,
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
150 GtkSourceUndoManager *um);
22674
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
151 static void gtk_source_undo_manager_insert_anchor_handler (GtkTextBuffer *buffer,
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
152 GtkTextIter *pos,
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
153 GtkTextChildAnchor *anchor,
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
154 GtkSourceUndoManager *um);
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
155 static void gtk_source_undo_manager_delete_range_handler (GtkTextBuffer *buffer,
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
156 GtkTextIter *start,
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
157 GtkTextIter *end,
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
158 GtkSourceUndoManager *um);
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
159 static void gtk_source_undo_manager_begin_user_action_handler (GtkTextBuffer *buffer,
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
160 GtkSourceUndoManager *um);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
161 static void gtk_source_undo_manager_modified_changed_handler (GtkTextBuffer *buffer,
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
162 GtkSourceUndoManager *um);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
163
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
164 static void gtk_source_undo_manager_free_action_list (GtkSourceUndoManager *um);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
165
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
166 static void gtk_source_undo_manager_add_action (GtkSourceUndoManager *um,
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
167 const GtkSourceUndoAction *undo_action);
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
168 static void gtk_source_undo_manager_free_first_n_actions (GtkSourceUndoManager *um,
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
169 gint n);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
170 static void gtk_source_undo_manager_check_list_size (GtkSourceUndoManager *um);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
171
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
172 static gboolean gtk_source_undo_manager_merge_action (GtkSourceUndoManager *um,
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
173 const GtkSourceUndoAction *undo_action);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
174
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
175 static GObjectClass *parent_class = NULL;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
176 static guint undo_manager_signals [LAST_SIGNAL] = { 0 };
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
177
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
178 GType
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
179 gtk_source_undo_manager_get_type (void)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
180 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
181 static GType undo_manager_type = 0;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
182
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
183 if (undo_manager_type == 0)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
184 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
185 static const GTypeInfo our_info =
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
186 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
187 sizeof (GtkSourceUndoManagerClass),
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
188 NULL, /* base_init */
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
189 NULL, /* base_finalize */
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
190 (GClassInitFunc) gtk_source_undo_manager_class_init,
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
191 NULL, /* class_finalize */
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
192 NULL, /* class_data */
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
193 sizeof (GtkSourceUndoManager),
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
194 0, /* n_preallocs */
18086
a92cadf6a978 Get rid of a compile warning
Mark Doliner <mark@kingant.net>
parents: 17411
diff changeset
195 (GInstanceInitFunc) gtk_source_undo_manager_init,
a92cadf6a978 Get rid of a compile warning
Mark Doliner <mark@kingant.net>
parents: 17411
diff changeset
196 NULL /* value_table */
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
197 };
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
198
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
199 undo_manager_type = g_type_register_static (G_TYPE_OBJECT,
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
200 "GtkSourceUndoManager",
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
201 &our_info,
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
202 0);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
203 }
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
204
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
205 return undo_manager_type;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
206 }
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
207
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
208 static void
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
209 gtk_source_undo_manager_class_init (GtkSourceUndoManagerClass *klass)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
210 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
211 GObjectClass *object_class = G_OBJECT_CLASS (klass);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
212
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
213 parent_class = g_type_class_peek_parent (klass);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
214
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
215 object_class->finalize = gtk_source_undo_manager_finalize;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
216
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
217 klass->can_undo = NULL;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
218 klass->can_redo = NULL;
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
219
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
220 undo_manager_signals[CAN_UNDO] =
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
221 g_signal_new ("can_undo",
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
222 G_OBJECT_CLASS_TYPE (object_class),
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
223 G_SIGNAL_RUN_LAST,
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
224 G_STRUCT_OFFSET (GtkSourceUndoManagerClass, can_undo),
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
225 NULL, NULL,
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
226 gtksourceview_marshal_VOID__BOOLEAN,
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
227 G_TYPE_NONE,
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
228 1,
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
229 G_TYPE_BOOLEAN);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
230
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
231 undo_manager_signals[CAN_REDO] =
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
232 g_signal_new ("can_redo",
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
233 G_OBJECT_CLASS_TYPE (object_class),
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
234 G_SIGNAL_RUN_LAST,
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
235 G_STRUCT_OFFSET (GtkSourceUndoManagerClass, can_redo),
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
236 NULL, NULL,
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
237 gtksourceview_marshal_VOID__BOOLEAN,
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
238 G_TYPE_NONE,
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
239 1,
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
240 G_TYPE_BOOLEAN);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
241 }
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
242
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
243 static void
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
244 gtk_source_undo_manager_init (GtkSourceUndoManager *um)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
245 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
246 um->priv = g_new0 (GtkSourceUndoManagerPrivate, 1);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
247
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
248 um->priv->actions = NULL;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
249 um->priv->next_redo = 0;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
250
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
251 um->priv->can_undo = FALSE;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
252 um->priv->can_redo = FALSE;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
253
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
254 um->priv->running_not_undoable_actions = 0;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
255
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
256 um->priv->num_of_groups = 0;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
257
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
258 um->priv->max_undo_levels = DEFAULT_MAX_UNDO_LEVELS;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
259
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
260 um->priv->modified_action = NULL;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
261
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
262 um->priv->modified_undoing_group = FALSE;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
263 }
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
264
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
265 static void
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
266 gtk_source_undo_manager_finalize (GObject *object)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
267 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
268 GtkSourceUndoManager *um;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
269
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
270 g_return_if_fail (object != NULL);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
271 g_return_if_fail (GTK_SOURCE_IS_UNDO_MANAGER (object));
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
272
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
273 um = GTK_SOURCE_UNDO_MANAGER (object);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
274
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
275 g_return_if_fail (um->priv != NULL);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
276
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
277 if (um->priv->actions != NULL)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
278 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
279 gtk_source_undo_manager_free_action_list (um);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
280 }
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
281
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
282 g_signal_handlers_disconnect_by_func (G_OBJECT (um->priv->document),
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
283 G_CALLBACK (gtk_source_undo_manager_delete_range_handler),
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
284 um);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
285
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
286 g_signal_handlers_disconnect_by_func (G_OBJECT (um->priv->document),
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
287 G_CALLBACK (gtk_source_undo_manager_insert_text_handler),
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
288 um);
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
289
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
290 g_signal_handlers_disconnect_by_func (G_OBJECT (um->priv->document),
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
291 G_CALLBACK (gtk_source_undo_manager_insert_anchor_handler),
22674
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
292 um);
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
293
22674
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
294 g_signal_handlers_disconnect_by_func (G_OBJECT (um->priv->document),
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
295 G_CALLBACK (gtk_source_undo_manager_begin_user_action_handler),
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
296 um);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
297
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
298 g_free (um->priv);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
299
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
300 G_OBJECT_CLASS (parent_class)->finalize (object);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
301 }
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
302
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
303 GtkSourceUndoManager*
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
304 gtk_source_undo_manager_new (GtkTextBuffer* buffer)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
305 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
306 GtkSourceUndoManager *um;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
307
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
308 um = GTK_SOURCE_UNDO_MANAGER (g_object_new (GTK_SOURCE_TYPE_UNDO_MANAGER, NULL));
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
309
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
310 g_return_val_if_fail (um->priv != NULL, NULL);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
311 um->priv->document = buffer;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
312
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
313 g_signal_connect (G_OBJECT (buffer), "insert_text",
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
314 G_CALLBACK (gtk_source_undo_manager_insert_text_handler),
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
315 um);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
316
22674
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
317 g_signal_connect (G_OBJECT (buffer), "insert_child_anchor",
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
318 G_CALLBACK (gtk_source_undo_manager_insert_anchor_handler),
22674
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
319 um);
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
320
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
321 g_signal_connect (G_OBJECT (buffer), "delete_range",
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
322 G_CALLBACK (gtk_source_undo_manager_delete_range_handler),
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
323 um);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
324
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
325 g_signal_connect (G_OBJECT (buffer), "begin_user_action",
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
326 G_CALLBACK (gtk_source_undo_manager_begin_user_action_handler),
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
327 um);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
328
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
329 g_signal_connect (G_OBJECT (buffer), "modified_changed",
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
330 G_CALLBACK (gtk_source_undo_manager_modified_changed_handler),
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
331 um);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
332 return um;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
333 }
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
334
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
335 void
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
336 gtk_source_undo_manager_begin_not_undoable_action (GtkSourceUndoManager *um)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
337 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
338 g_return_if_fail (GTK_SOURCE_IS_UNDO_MANAGER (um));
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
339 g_return_if_fail (um->priv != NULL);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
340
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
341 ++um->priv->running_not_undoable_actions;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
342 }
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
343
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
344 static void
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
345 gtk_source_undo_manager_end_not_undoable_action_internal (GtkSourceUndoManager *um)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
346 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
347 g_return_if_fail (GTK_SOURCE_IS_UNDO_MANAGER (um));
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
348 g_return_if_fail (um->priv != NULL);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
349
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
350 g_return_if_fail (um->priv->running_not_undoable_actions > 0);
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
351
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
352 --um->priv->running_not_undoable_actions;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
353 }
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
354
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
355 void
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
356 gtk_source_undo_manager_end_not_undoable_action (GtkSourceUndoManager *um)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
357 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
358 g_return_if_fail (GTK_SOURCE_IS_UNDO_MANAGER (um));
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
359 g_return_if_fail (um->priv != NULL);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
360
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
361 gtk_source_undo_manager_end_not_undoable_action_internal (um);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
362
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
363 if (um->priv->running_not_undoable_actions == 0)
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
364 {
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
365 gtk_source_undo_manager_free_action_list (um);
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
366
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
367 um->priv->next_redo = -1;
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
368
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
369 if (um->priv->can_undo)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
370 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
371 um->priv->can_undo = FALSE;
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
372 g_signal_emit (G_OBJECT (um),
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
373 undo_manager_signals [CAN_UNDO],
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
374 0,
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
375 FALSE);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
376 }
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
377
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
378 if (um->priv->can_redo)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
379 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
380 um->priv->can_redo = FALSE;
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
381 g_signal_emit (G_OBJECT (um),
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
382 undo_manager_signals [CAN_REDO],
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
383 0,
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
384 FALSE);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
385 }
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
386 }
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
387 }
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
388
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
389 gboolean
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
390 gtk_source_undo_manager_can_undo (const GtkSourceUndoManager *um)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
391 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
392 g_return_val_if_fail (GTK_SOURCE_IS_UNDO_MANAGER (um), FALSE);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
393 g_return_val_if_fail (um->priv != NULL, FALSE);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
394
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
395 return um->priv->can_undo;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
396 }
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
397
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
398 gboolean
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
399 gtk_source_undo_manager_can_redo (const GtkSourceUndoManager *um)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
400 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
401 g_return_val_if_fail (GTK_SOURCE_IS_UNDO_MANAGER (um), FALSE);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
402 g_return_val_if_fail (um->priv != NULL, FALSE);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
403
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
404 return um->priv->can_redo;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
405 }
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
406
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
407 static void
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
408 set_cursor (GtkTextBuffer *buffer, gint cursor)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
409 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
410 GtkTextIter iter;
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
411
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
412 /* Place the cursor at the requested position */
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
413 gtk_text_buffer_get_iter_at_offset (buffer, &iter, cursor);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
414 gtk_text_buffer_place_cursor (buffer, &iter);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
415 }
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
416
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
417 static void
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
418 insert_text (GtkTextBuffer *buffer, gint pos, const gchar *text, gint len)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
419 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
420 GtkTextIter iter;
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
421
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
422 gtk_text_buffer_get_iter_at_offset (buffer, &iter, pos);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
423 gtk_text_buffer_insert (buffer, &iter, text, len);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
424 }
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
425
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
426 static void
22674
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
427 insert_anchor (GtkTextBuffer *buffer, gint pos, GtkTextChildAnchor *anchor)
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
428 {
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
429 GtkTextIter iter;
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
430
22674
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
431 gtk_text_buffer_get_iter_at_offset (buffer, &iter, pos);
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
432 gtk_text_buffer_insert_child_anchor (buffer, &iter, anchor);
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
433 }
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
434
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
435 static void
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
436 delete_text (GtkTextBuffer *buffer, gint start, gint end)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
437 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
438 GtkTextIter start_iter;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
439 GtkTextIter end_iter;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
440
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
441 gtk_text_buffer_get_iter_at_offset (buffer, &start_iter, start);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
442
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
443 if (end < 0)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
444 gtk_text_buffer_get_end_iter (buffer, &end_iter);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
445 else
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
446 gtk_text_buffer_get_iter_at_offset (buffer, &end_iter, end);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
447
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
448 gtk_text_buffer_delete (buffer, &start_iter, &end_iter);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
449 }
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
450
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
451 static gchar*
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
452 get_chars (GtkTextBuffer *buffer, gint start, gint end)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
453 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
454 GtkTextIter start_iter;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
455 GtkTextIter end_iter;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
456
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
457 gtk_text_buffer_get_iter_at_offset (buffer, &start_iter, start);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
458
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
459 if (end < 0)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
460 gtk_text_buffer_get_end_iter (buffer, &end_iter);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
461 else
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
462 gtk_text_buffer_get_iter_at_offset (buffer, &end_iter, end);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
463
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
464 return gtk_text_buffer_get_slice (buffer, &start_iter, &end_iter, TRUE);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
465 }
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
466
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
467 void
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
468 gtk_source_undo_manager_undo (GtkSourceUndoManager *um)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
469 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
470 GtkSourceUndoAction *undo_action;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
471 gboolean modified = FALSE;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
472
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
473 g_return_if_fail (GTK_SOURCE_IS_UNDO_MANAGER (um));
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
474 g_return_if_fail (um->priv != NULL);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
475 g_return_if_fail (um->priv->can_undo);
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
476
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
477 um->priv->modified_undoing_group = FALSE;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
478
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
479 gtk_source_undo_manager_begin_not_undoable_action (um);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
480
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
481 do
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
482 {
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
483 undo_action = g_list_nth_data (um->priv->actions, um->priv->next_redo + 1);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
484 g_return_if_fail (undo_action != NULL);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
485
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
486 /* undo_action->modified can be TRUE only if undo_action->order_in_group <= 1 */
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
487 g_return_if_fail ((undo_action->order_in_group <= 1) ||
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
488 ((undo_action->order_in_group > 1) && !undo_action->modified));
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
489
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
490 if (undo_action->order_in_group <= 1)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
491 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
492 /* Set modified to TRUE only if the buffer did not change its state from
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
493 * "not modified" to "modified" undoing an action (with order_in_group > 1)
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
494 * in current group. */
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
495 modified = (undo_action->modified && !um->priv->modified_undoing_group);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
496 }
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
497
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
498 switch (undo_action->action_type)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
499 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
500 case GTK_SOURCE_UNDO_ACTION_DELETE:
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
501 insert_text (
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
502 um->priv->document,
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
503 undo_action->action.delete.start,
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
504 undo_action->action.delete.text,
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
505 strlen (undo_action->action.delete.text));
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
506
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
507 if (undo_action->action.delete.forward)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
508 set_cursor (
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
509 um->priv->document,
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
510 undo_action->action.delete.start);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
511 else
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
512 set_cursor (
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
513 um->priv->document,
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
514 undo_action->action.delete.end);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
515
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
516 break;
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
517
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
518 case GTK_SOURCE_UNDO_ACTION_INSERT:
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
519 delete_text (
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
520 um->priv->document,
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
521 undo_action->action.insert.pos,
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
522 undo_action->action.insert.pos +
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
523 undo_action->action.insert.chars);
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
524
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
525 set_cursor (
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
526 um->priv->document,
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
527 undo_action->action.insert.pos);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
528 break;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
529
22674
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
530 case GTK_SOURCE_UNDO_ACTION_INSERT_ANCHOR:
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
531 delete_text (
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
532 um->priv->document,
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
533 undo_action->action.insert_anchor.pos,
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
534 undo_action->action.insert_anchor.pos + 1);
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
535 undo_action->action.insert_anchor.anchor->segment = NULL; /* XXX: This may be a bug in GTK+ */
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
536 break;
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
537 default:
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
538 /* Unknown action type. */
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
539 g_return_if_reached ();
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
540 }
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
541
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
542 ++um->priv->next_redo;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
543
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
544 } while (undo_action->order_in_group > 1);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
545
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
546 if (modified)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
547 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
548 --um->priv->next_redo;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
549 gtk_text_buffer_set_modified (um->priv->document, FALSE);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
550 ++um->priv->next_redo;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
551 }
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
552
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
553 gtk_source_undo_manager_end_not_undoable_action_internal (um);
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
554
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
555 um->priv->modified_undoing_group = FALSE;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
556
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
557 if (!um->priv->can_redo)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
558 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
559 um->priv->can_redo = TRUE;
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
560 g_signal_emit (G_OBJECT (um),
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
561 undo_manager_signals [CAN_REDO],
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
562 0,
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
563 TRUE);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
564 }
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
565
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
566 if (um->priv->next_redo >= (gint)(g_list_length (um->priv->actions) - 1))
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
567 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
568 um->priv->can_undo = FALSE;
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
569 g_signal_emit (G_OBJECT (um),
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
570 undo_manager_signals [CAN_UNDO],
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
571 0,
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
572 FALSE);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
573 }
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
574 }
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
575
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
576 void
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
577 gtk_source_undo_manager_redo (GtkSourceUndoManager *um)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
578 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
579 GtkSourceUndoAction *undo_action;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
580 gboolean modified = FALSE;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
581
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
582 g_return_if_fail (GTK_SOURCE_IS_UNDO_MANAGER (um));
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
583 g_return_if_fail (um->priv != NULL);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
584 g_return_if_fail (um->priv->can_redo);
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
585
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
586 undo_action = g_list_nth_data (um->priv->actions, um->priv->next_redo);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
587 g_return_if_fail (undo_action != NULL);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
588
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
589 gtk_source_undo_manager_begin_not_undoable_action (um);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
590
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
591 do
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
592 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
593 if (undo_action->modified)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
594 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
595 g_return_if_fail (undo_action->order_in_group <= 1);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
596 modified = TRUE;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
597 }
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
598
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
599 --um->priv->next_redo;
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
600
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
601 switch (undo_action->action_type)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
602 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
603 case GTK_SOURCE_UNDO_ACTION_DELETE:
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
604 delete_text (
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
605 um->priv->document,
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
606 undo_action->action.delete.start,
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
607 undo_action->action.delete.end);
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
608
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
609 set_cursor (
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
610 um->priv->document,
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
611 undo_action->action.delete.start);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
612
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
613 break;
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
614
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
615 case GTK_SOURCE_UNDO_ACTION_INSERT:
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
616 set_cursor (
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
617 um->priv->document,
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
618 undo_action->action.insert.pos);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
619
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
620 insert_text (
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
621 um->priv->document,
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
622 undo_action->action.insert.pos,
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
623 undo_action->action.insert.text,
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
624 undo_action->action.insert.length);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
625
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
626 break;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
627
22674
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
628 case GTK_SOURCE_UNDO_ACTION_INSERT_ANCHOR:
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
629 set_cursor (
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
630 um->priv->document,
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
631 undo_action->action.insert_anchor.pos);
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
632
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
633 insert_anchor (
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
634 um->priv->document,
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
635 undo_action->action.insert_anchor.pos,
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
636 undo_action->action.insert_anchor.anchor);
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
637 break;
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
638
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
639 default:
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
640 /* Unknown action type */
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
641 ++um->priv->next_redo;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
642 g_return_if_reached ();
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
643 }
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
644
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
645 if (um->priv->next_redo < 0)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
646 undo_action = NULL;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
647 else
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
648 undo_action = g_list_nth_data (um->priv->actions, um->priv->next_redo);
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
649
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
650 } while ((undo_action != NULL) && (undo_action->order_in_group > 1));
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
651
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
652 if (modified)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
653 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
654 ++um->priv->next_redo;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
655 gtk_text_buffer_set_modified (um->priv->document, FALSE);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
656 --um->priv->next_redo;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
657 }
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
658
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
659 gtk_source_undo_manager_end_not_undoable_action_internal (um);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
660
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
661 if (um->priv->next_redo < 0)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
662 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
663 um->priv->can_redo = FALSE;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
664 g_signal_emit (G_OBJECT (um), undo_manager_signals [CAN_REDO], 0, FALSE);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
665 }
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
666
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
667 if (!um->priv->can_undo)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
668 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
669 um->priv->can_undo = TRUE;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
670 g_signal_emit (G_OBJECT (um), undo_manager_signals [CAN_UNDO], 0, TRUE);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
671 }
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
672 }
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
673
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
674 static void
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
675 gtk_source_undo_action_free (GtkSourceUndoAction *action)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
676 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
677 if (action == NULL)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
678 return;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
679
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
680 if (action->action_type == GTK_SOURCE_UNDO_ACTION_INSERT)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
681 g_free (action->action.insert.text);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
682 else if (action->action_type == GTK_SOURCE_UNDO_ACTION_DELETE)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
683 g_free (action->action.delete.text);
22674
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
684 else if (action->action_type == GTK_SOURCE_UNDO_ACTION_INSERT_ANCHOR)
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
685 g_object_unref(action->action.insert_anchor.anchor);
31545
8e29b6fff216 gtksourceundomanager: Fix a few memory leaks in our bundled copy of this widget. Refs #13162.
morshed.nader@gmail.com
parents: 30843
diff changeset
686 else {
8e29b6fff216 gtksourceundomanager: Fix a few memory leaks in our bundled copy of this widget. Refs #13162.
morshed.nader@gmail.com
parents: 30843
diff changeset
687 g_free (action);
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
688 g_return_if_reached ();
31545
8e29b6fff216 gtksourceundomanager: Fix a few memory leaks in our bundled copy of this widget. Refs #13162.
morshed.nader@gmail.com
parents: 30843
diff changeset
689 }
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
690
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
691 g_free (action);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
692 }
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
693
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
694 static void
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
695 gtk_source_undo_manager_free_action_list (GtkSourceUndoManager *um)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
696 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
697 GList *l;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
698
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
699 l = um->priv->actions;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
700
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
701 while (l != NULL)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
702 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
703 GtkSourceUndoAction *action = l->data;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
704
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
705 if (action->order_in_group == 1)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
706 --um->priv->num_of_groups;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
707
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
708 if (action->modified)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
709 um->priv->modified_action = INVALID;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
710
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
711 gtk_source_undo_action_free (action);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
712
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
713 l = g_list_next (l);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
714 }
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
715
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
716 g_list_free (um->priv->actions);
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
717 um->priv->actions = NULL;
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
718 }
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
719
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
720 static void
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
721 gtk_source_undo_manager_insert_text_handler (GtkTextBuffer *buffer,
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
722 GtkTextIter *pos,
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
723 const gchar *text,
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
724 gint length,
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
725 GtkSourceUndoManager *um)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
726 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
727 GtkSourceUndoAction undo_action;
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
728
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
729 if (um->priv->running_not_undoable_actions > 0)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
730 return;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
731
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
732 undo_action.action_type = GTK_SOURCE_UNDO_ACTION_INSERT;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
733
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
734 undo_action.action.insert.pos = gtk_text_iter_get_offset (pos);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
735 undo_action.action.insert.text = (gchar*) text;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
736 undo_action.action.insert.length = length;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
737 undo_action.action.insert.chars = g_utf8_strlen (text, length);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
738
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
739 if ((undo_action.action.insert.chars > 1) || (g_utf8_get_char (text) == '\n'))
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
740
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
741 undo_action.mergeable = FALSE;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
742 else
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
743 undo_action.mergeable = TRUE;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
744
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
745 undo_action.modified = FALSE;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
746
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
747 gtk_source_undo_manager_add_action (um, &undo_action);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
748 }
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
749
22674
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
750 static void gtk_source_undo_manager_insert_anchor_handler (GtkTextBuffer *buffer,
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
751 GtkTextIter *pos,
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
752 GtkTextChildAnchor *anchor,
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
753 GtkSourceUndoManager *um)
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
754 {
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
755 GtkSourceUndoAction undo_action;
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
756
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
757 if (um->priv->running_not_undoable_actions > 0)
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
758 return;
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
759
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
760 undo_action.action_type = GTK_SOURCE_UNDO_ACTION_INSERT_ANCHOR;
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
761
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
762 undo_action.action.insert_anchor.pos = gtk_text_iter_get_offset (pos);
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
763 undo_action.action.insert_anchor.anchor = g_object_ref (anchor);
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
764
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
765 undo_action.mergeable = FALSE;
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
766 undo_action.modified = FALSE;
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
767
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
768 gtk_source_undo_manager_add_action (um, &undo_action);
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
769 }
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
770
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
771 static void
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
772 gtk_source_undo_manager_delete_range_handler (GtkTextBuffer *buffer,
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
773 GtkTextIter *start,
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
774 GtkTextIter *end,
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
775 GtkSourceUndoManager *um)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
776 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
777 GtkSourceUndoAction undo_action;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
778 GtkTextIter insert_iter;
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
779
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
780 if (um->priv->running_not_undoable_actions > 0)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
781 return;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
782
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
783 undo_action.action_type = GTK_SOURCE_UNDO_ACTION_DELETE;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
784
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
785 gtk_text_iter_order (start, end);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
786
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
787 undo_action.action.delete.start = gtk_text_iter_get_offset (start);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
788 undo_action.action.delete.end = gtk_text_iter_get_offset (end);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
789
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
790 undo_action.action.delete.text = get_chars (
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
791 buffer,
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
792 undo_action.action.delete.start,
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
793 undo_action.action.delete.end);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
794
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
795 /* figure out if the user used the Delete or the Backspace key */
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
796 gtk_text_buffer_get_iter_at_mark (buffer, &insert_iter,
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
797 gtk_text_buffer_get_insert (buffer));
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
798 if (gtk_text_iter_get_offset (&insert_iter) <= undo_action.action.delete.start)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
799 undo_action.action.delete.forward = TRUE;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
800 else
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
801 undo_action.action.delete.forward = FALSE;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
802
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
803 if (((undo_action.action.delete.end - undo_action.action.delete.start) > 1) ||
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
804 (g_utf8_get_char (undo_action.action.delete.text ) == '\n'))
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
805 undo_action.mergeable = FALSE;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
806 else
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
807 undo_action.mergeable = TRUE;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
808
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
809 undo_action.modified = FALSE;
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
810
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
811 gtk_source_undo_manager_add_action (um, &undo_action);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
812
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
813 g_free (undo_action.action.delete.text);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
814
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
815 }
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
816
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
817 static void
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
818 gtk_source_undo_manager_begin_user_action_handler (GtkTextBuffer *buffer, GtkSourceUndoManager *um)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
819 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
820 g_return_if_fail (GTK_SOURCE_IS_UNDO_MANAGER (um));
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
821 g_return_if_fail (um->priv != NULL);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
822
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
823 if (um->priv->running_not_undoable_actions > 0)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
824 return;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
825
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
826 um->priv->actions_in_current_group = 0;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
827 }
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
828
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
829 static void
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
830 gtk_source_undo_manager_add_action (GtkSourceUndoManager *um,
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
831 const GtkSourceUndoAction *undo_action)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
832 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
833 GtkSourceUndoAction* action;
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
834
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
835 if (um->priv->next_redo >= 0)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
836 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
837 gtk_source_undo_manager_free_first_n_actions (um, um->priv->next_redo + 1);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
838 }
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
839
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
840 um->priv->next_redo = -1;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
841
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
842 if (!gtk_source_undo_manager_merge_action (um, undo_action))
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
843 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
844 action = g_new (GtkSourceUndoAction, 1);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
845 *action = *undo_action;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
846
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
847 if (action->action_type == GTK_SOURCE_UNDO_ACTION_INSERT)
19548
e2135da444a5 "text" isn't guarranteed to be null terminated, so make sure we use
Mark Doliner <mark@kingant.net>
parents: 18086
diff changeset
848 action->action.insert.text = g_strndup (undo_action->action.insert.text, undo_action->action.insert.length);
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
849 else if (action->action_type == GTK_SOURCE_UNDO_ACTION_DELETE)
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
850 action->action.delete.text = g_strdup (undo_action->action.delete.text);
22674
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
851 else if (action->action_type == GTK_SOURCE_UNDO_ACTION_INSERT_ANCHOR)
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
852 {
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
853 /* Nothing needs to be done */
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
854 }
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
855 else
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
856 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
857 g_free (action);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
858 g_return_if_reached ();
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
859 }
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
860
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
861 ++um->priv->actions_in_current_group;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
862 action->order_in_group = um->priv->actions_in_current_group;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
863
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
864 if (action->order_in_group == 1)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
865 ++um->priv->num_of_groups;
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
866
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
867 um->priv->actions = g_list_prepend (um->priv->actions, action);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
868 }
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
869
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
870 gtk_source_undo_manager_check_list_size (um);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
871
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
872 if (!um->priv->can_undo)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
873 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
874 um->priv->can_undo = TRUE;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
875 g_signal_emit (G_OBJECT (um), undo_manager_signals [CAN_UNDO], 0, TRUE);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
876 }
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
877
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
878 if (um->priv->can_redo)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
879 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
880 um->priv->can_redo = FALSE;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
881 g_signal_emit (G_OBJECT (um), undo_manager_signals [CAN_REDO], 0, FALSE);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
882 }
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
883 }
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
884
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
885 static void
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
886 gtk_source_undo_manager_free_first_n_actions (GtkSourceUndoManager *um,
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
887 gint n)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
888 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
889 gint i;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
890
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
891 if (um->priv->actions == NULL)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
892 return;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
893
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
894 for (i = 0; i < n; i++)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
895 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
896 GtkSourceUndoAction *action = g_list_first (um->priv->actions)->data;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
897
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
898 if (action->order_in_group == 1)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
899 --um->priv->num_of_groups;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
900
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
901 if (action->modified)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
902 um->priv->modified_action = INVALID;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
903
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
904 gtk_source_undo_action_free (action);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
905
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
906 um->priv->actions = g_list_delete_link (um->priv->actions,
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
907 um->priv->actions);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
908
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
909 if (um->priv->actions == NULL)
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
910 return;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
911 }
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
912 }
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
913
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
914 static void
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
915 gtk_source_undo_manager_check_list_size (GtkSourceUndoManager *um)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
916 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
917 gint undo_levels;
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
918
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
919 g_return_if_fail (GTK_SOURCE_IS_UNDO_MANAGER (um));
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
920 g_return_if_fail (um->priv != NULL);
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
921
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
922 undo_levels = gtk_source_undo_manager_get_max_undo_levels (um);
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
923
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
924 if (undo_levels < 1)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
925 return;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
926
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
927 if (um->priv->num_of_groups > undo_levels)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
928 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
929 GtkSourceUndoAction *undo_action;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
930 GList *last;
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
931
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
932 last = g_list_last (um->priv->actions);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
933 undo_action = (GtkSourceUndoAction*) last->data;
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
934
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
935 do
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
936 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
937 GList *tmp;
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
938
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
939 if (undo_action->order_in_group == 1)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
940 --um->priv->num_of_groups;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
941
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
942 if (undo_action->modified)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
943 um->priv->modified_action = INVALID;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
944
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
945 gtk_source_undo_action_free (undo_action);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
946
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
947 tmp = g_list_previous (last);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
948 um->priv->actions = g_list_delete_link (um->priv->actions, last);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
949 last = tmp;
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
950 g_return_if_fail (last != NULL);
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
951
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
952 undo_action = (GtkSourceUndoAction*) last->data;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
953
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
954 } while ((undo_action->order_in_group > 1) ||
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
955 (um->priv->num_of_groups > undo_levels));
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
956 }
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
957 }
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
958
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
959 /**
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
960 * gtk_source_undo_manager_merge_action:
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
961 * @um: a #GtkSourceUndoManager.
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
962 * @undo_action: a #GtkSourceUndoAction.
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
963 *
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
964 * This function tries to merge the undo action at the top of
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
965 * the stack with a new undo action. So when we undo for example
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
966 * typing, we can undo the whole word and not each letter by itself.
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
967 *
30843
f6017a90c1b8 Remove non-UTF8 character.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25415
diff changeset
968 * Return Value: %TRUE is merge was successful, %FALSE otherwise.
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
969 **/
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
970 static gboolean
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
971 gtk_source_undo_manager_merge_action (GtkSourceUndoManager *um,
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
972 const GtkSourceUndoAction *undo_action)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
973 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
974 GtkSourceUndoAction *last_action;
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
975
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
976 g_return_val_if_fail (GTK_SOURCE_IS_UNDO_MANAGER (um), FALSE);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
977 g_return_val_if_fail (um->priv != NULL, FALSE);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
978
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
979 if (um->priv->actions == NULL)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
980 return FALSE;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
981
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
982 last_action = (GtkSourceUndoAction*) g_list_nth_data (um->priv->actions, 0);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
983
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
984 if (!last_action->mergeable)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
985 return FALSE;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
986
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
987 if ((!undo_action->mergeable) ||
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
988 (undo_action->action_type != last_action->action_type))
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
989 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
990 last_action->mergeable = FALSE;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
991 return FALSE;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
992 }
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
993
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
994 if (undo_action->action_type == GTK_SOURCE_UNDO_ACTION_DELETE)
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
995 {
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
996 if ((last_action->action.delete.forward != undo_action->action.delete.forward) ||
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
997 ((last_action->action.delete.start != undo_action->action.delete.start) &&
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
998 (last_action->action.delete.start != undo_action->action.delete.end)))
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
999 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1000 last_action->mergeable = FALSE;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1001 return FALSE;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1002 }
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
1003
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1004 if (last_action->action.delete.start == undo_action->action.delete.start)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1005 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1006 gchar *str;
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
1007
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1008 #define L (last_action->action.delete.end - last_action->action.delete.start - 1)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1009 #define g_utf8_get_char_at(p,i) g_utf8_get_char(g_utf8_offset_to_pointer((p),(i)))
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
1010
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1011 /* Deleted with the delete key */
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1012 if ((g_utf8_get_char (undo_action->action.delete.text) != ' ') &&
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1013 (g_utf8_get_char (undo_action->action.delete.text) != '\t') &&
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1014 ((g_utf8_get_char_at (last_action->action.delete.text, L) == ' ') ||
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1015 (g_utf8_get_char_at (last_action->action.delete.text, L) == '\t')))
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1016 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1017 last_action->mergeable = FALSE;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1018 return FALSE;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1019 }
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
1020
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
1021 str = g_strdup_printf ("%s%s", last_action->action.delete.text,
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1022 undo_action->action.delete.text);
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
1023
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1024 g_free (last_action->action.delete.text);
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
1025 last_action->action.delete.end += (undo_action->action.delete.end -
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1026 undo_action->action.delete.start);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1027 last_action->action.delete.text = str;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1028 }
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1029 else
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1030 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1031 gchar *str;
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
1032
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1033 /* Deleted with the backspace key */
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1034 if ((g_utf8_get_char (undo_action->action.delete.text) != ' ') &&
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1035 (g_utf8_get_char (undo_action->action.delete.text) != '\t') &&
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1036 ((g_utf8_get_char (last_action->action.delete.text) == ' ') ||
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1037 (g_utf8_get_char (last_action->action.delete.text) == '\t')))
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1038 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1039 last_action->mergeable = FALSE;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1040 return FALSE;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1041 }
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1042
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
1043 str = g_strdup_printf ("%s%s", undo_action->action.delete.text,
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1044 last_action->action.delete.text);
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
1045
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1046 g_free (last_action->action.delete.text);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1047 last_action->action.delete.start = undo_action->action.delete.start;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1048 last_action->action.delete.text = str;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1049 }
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1050 }
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1051 else if (undo_action->action_type == GTK_SOURCE_UNDO_ACTION_INSERT)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1052 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1053 gchar* str;
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
1054
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1055 #define I (last_action->action.insert.chars - 1)
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
1056
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
1057 if ((undo_action->action.insert.pos !=
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1058 (last_action->action.insert.pos + last_action->action.insert.chars)) ||
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1059 ((g_utf8_get_char (undo_action->action.insert.text) != ' ') &&
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1060 (g_utf8_get_char (undo_action->action.insert.text) != '\t') &&
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1061 ((g_utf8_get_char_at (last_action->action.insert.text, I) == ' ') ||
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1062 (g_utf8_get_char_at (last_action->action.insert.text, I) == '\t')))
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1063 )
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1064 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1065 last_action->mergeable = FALSE;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1066 return FALSE;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1067 }
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1068
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
1069 str = g_strdup_printf ("%s%s", last_action->action.insert.text,
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1070 undo_action->action.insert.text);
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
1071
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1072 g_free (last_action->action.insert.text);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1073 last_action->action.insert.length += undo_action->action.insert.length;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1074 last_action->action.insert.text = str;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1075 last_action->action.insert.chars += undo_action->action.insert.chars;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1076
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1077 }
22674
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
1078 else if (undo_action->action_type == GTK_SOURCE_UNDO_ACTION_INSERT_ANCHOR)
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
1079 {
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
1080 /* Nothing needs to be done */
27c9c55499f8 Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
1081 }
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1082 else
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1083 /* Unknown action inside undo merge encountered */
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1084 g_return_val_if_reached (TRUE);
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
1085
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1086 return TRUE;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1087 }
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1088
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1089 gint
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1090 gtk_source_undo_manager_get_max_undo_levels (GtkSourceUndoManager *um)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1091 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1092 g_return_val_if_fail (um != NULL, 0);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1093 g_return_val_if_fail (GTK_SOURCE_IS_UNDO_MANAGER (um), 0);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1094
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1095 return um->priv->max_undo_levels;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1096 }
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1097
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1098 void
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1099 gtk_source_undo_manager_set_max_undo_levels (GtkSourceUndoManager *um,
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1100 gint max_undo_levels)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1101 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1102 gint old_levels;
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
1103
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1104 g_return_if_fail (um != NULL);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1105 g_return_if_fail (GTK_SOURCE_IS_UNDO_MANAGER (um));
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1106
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1107 old_levels = um->priv->max_undo_levels;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1108 um->priv->max_undo_levels = max_undo_levels;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1109
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1110 if (max_undo_levels < 1)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1111 return;
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
1112
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1113 if (old_levels > max_undo_levels)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1114 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1115 /* strip redo actions first */
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1116 while (um->priv->next_redo >= 0 && (um->priv->num_of_groups > max_undo_levels))
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1117 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1118 gtk_source_undo_manager_free_first_n_actions (um, 1);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1119 um->priv->next_redo--;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1120 }
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
1121
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1122 /* now remove undo actions if necessary */
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1123 gtk_source_undo_manager_check_list_size (um);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1124
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1125 /* emit "can_undo" and/or "can_redo" if appropiate */
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1126 if (um->priv->next_redo < 0 && um->priv->can_redo)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1127 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1128 um->priv->can_redo = FALSE;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1129 g_signal_emit (G_OBJECT (um), undo_manager_signals [CAN_REDO], 0, FALSE);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1130 }
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1131
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1132 if (um->priv->can_undo &&
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1133 um->priv->next_redo >= (gint)(g_list_length (um->priv->actions) - 1))
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1134 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1135 um->priv->can_undo = FALSE;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1136 g_signal_emit (G_OBJECT (um), undo_manager_signals [CAN_UNDO], 0, FALSE);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1137 }
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1138 }
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1139 }
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1140
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1141 static void
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1142 gtk_source_undo_manager_modified_changed_handler (GtkTextBuffer *buffer,
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1143 GtkSourceUndoManager *um)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1144 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1145 GtkSourceUndoAction *action;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1146 GList *list;
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
1147
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1148 g_return_if_fail (GTK_SOURCE_IS_UNDO_MANAGER (um));
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1149 g_return_if_fail (um->priv != NULL);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1150
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1151 if (um->priv->actions == NULL)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1152 return;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1153
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1154 list = g_list_nth (um->priv->actions, um->priv->next_redo + 1);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1155
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1156 if (list != NULL)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1157 action = (GtkSourceUndoAction*) list->data;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1158 else
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1159 action = NULL;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1160
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1161 if (gtk_text_buffer_get_modified (buffer) == FALSE)
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
1162 {
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1163 if (action != NULL)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1164 action->mergeable = FALSE;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1165
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1166 if (um->priv->modified_action != NULL)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1167 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1168 if (um->priv->modified_action != INVALID)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1169 um->priv->modified_action->modified = FALSE;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1170
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1171 um->priv->modified_action = NULL;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1172 }
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1173
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1174 return;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1175 }
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1176
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1177 if (action == NULL)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1178 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1179 g_return_if_fail (um->priv->running_not_undoable_actions > 0);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1180
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1181 return;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1182 }
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25414
diff changeset
1183
17411
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1184 /* gtk_text_buffer_get_modified (buffer) == TRUE */
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1185
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1186 g_return_if_fail (um->priv->modified_action == NULL);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1187
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1188 if (action->order_in_group > 1)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1189 um->priv->modified_undoing_group = TRUE;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1190
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1191 while (action->order_in_group > 1)
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1192 {
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1193 list = g_list_next (list);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1194 g_return_if_fail (list != NULL);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1195
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1196 action = (GtkSourceUndoAction*) list->data;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1197 g_return_if_fail (action != NULL);
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1198 }
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1199
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1200 action->modified = TRUE;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1201 um->priv->modified_action = action;
674d8bc2b980 Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1202 }