summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgedit <gedit>1999-09-12 16:35:02 +0000
committergedit <gedit>1999-09-12 16:35:02 +0000
commit921e200a5805b815c81590d9d466190a66c9c723 (patch)
tree671ee4c00f904d56f6c4e025068e6ab726dc49c3
parentf7adf0a984c5ffdb8113c1b8ff7e8b4a1c9616de (diff)
downloadgedit-921e200a5805b815c81590d9d466190a66c9c723.tar.gz
Added gE_undo.[ch] to the build list, added a undo list insertion function, and set the view to update the undo stack.. wheee..
-rw-r--r--ChangeLog9
-rw-r--r--gedit/Makefile.am2
-rw-r--r--gedit/gE_undo.c27
-rw-r--r--gedit/gE_undo.h4
-rw-r--r--gedit/gE_view.c10
-rw-r--r--gedit/main.h1
-rw-r--r--src/Makefile.am2
-rw-r--r--src/gE_undo.c27
-rw-r--r--src/gE_undo.h4
-rw-r--r--src/gE_view.c10
-rw-r--r--src/main.h1
11 files changed, 91 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index a43f7ec8d..3a6a0b176 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+Sun Sep 12 17:28:35 BST 1999 Alex Roberts <bse@gedit.pn.org>
+
+ * src/gE_undo.c: (gE_undo_add) New fucntion. Add's undo item to the stack.
+
+ * src/gE_view.c: (doc_insert_text_cb) (doc_delete_text_cb) Added function
+ call to insert the inserted or deleted text into the undo stack.
+
+ * src/Makefile.am: Added gE_undo.[ch] to the source list.
+
Sun Sep 12 16:18:18 BST 1999 Alex Roberts <bse@gedit.pn.org>
* src/gE_undo.[ch]: Added stubs for the new undo/redo system.
diff --git a/gedit/Makefile.am b/gedit/Makefile.am
index ef0737968..98863730b 100644
--- a/gedit/Makefile.am
+++ b/gedit/Makefile.am
@@ -48,6 +48,8 @@ gedit_SOURCES = \
gE_view.h \
gE_mdi.c \
gE_mdi.h \
+ gE_undo.c \
+ gE_undo.h \
gE_about.c \
gE_about.h \
gE_files.c \
diff --git a/gedit/gE_undo.c b/gedit/gE_undo.c
index f578003a7..3fb41657e 100644
--- a/gedit/gE_undo.c
+++ b/gedit/gE_undo.c
@@ -25,3 +25,30 @@
#include "gE_mdi.h"
#include "gE_window.h"
+
+void gE_undo_add (gchar *text, gint start_pos, gint end_pos, gint action, gE_document *doc)
+{
+
+ gE_undo *undo;
+
+ undo = g_new(gE_undo, 1);
+
+ undo->text = text;
+ undo->start_pos = start_pos;
+ undo->end_pos = end_pos;
+ undo->action = action;
+ undo->status = doc->changed;
+
+ /* nuke the redo list, if its available */
+ if (doc->redo) {
+
+ g_list_free (doc->redo);
+
+ }
+
+ g_message ("gE_undo_add: Adding to Undo list..");
+
+ doc->undo = g_list_prepend (doc->undo, undo);
+
+}
+
diff --git a/gedit/gE_undo.h b/gedit/gE_undo.h
index bdbaf77f9..85482b3fc 100644
--- a/gedit/gE_undo.h
+++ b/gedit/gE_undo.h
@@ -44,10 +44,10 @@ typedef struct _gE_undo {
/* add an undo node */
-extern void gE_undo_add (gchar*, gint*, gint*, gint*, gE_document*);
+extern void gE_undo_add (gchar*, gint, gint, gint, gE_document*);
/* clear the list */
-extern void gE_undo_reset (gE_document*);
+extern void gE_undo_reset (GList*);
/* callbacks to do the undo or the redo */
extern void gE_undo_do (GtkWidget*, gpointer*);
diff --git a/gedit/gE_view.c b/gedit/gE_view.c
index a875c0a65..57bc280a7 100644
--- a/gedit/gE_view.c
+++ b/gedit/gE_view.c
@@ -22,6 +22,7 @@
#include <config.h>
#include "gE_view.h"
#include "main.h"
+#include "gE_undo.h"
#include "gE_mdi.h"
#include "commands.h"
#include "gE_prefs.h"
@@ -244,6 +245,9 @@ doc_insert_text_cb(GtkWidget *editable, const guchar *insertion_text, int length
gtk_text_set_point (GTK_TEXT (significant_other), position);
g_free (data);
+
+
+ gE_undo_add (buffer, position, (pos + length), INSERT, doc);
if (length > 96)
g_free (buffer);
@@ -258,6 +262,7 @@ doc_delete_text_cb(GtkWidget *editable, int start_pos, int end_pos,
GtkWidget *significant_other;
gE_document *doc;
gE_view *nth_view = NULL;
+ gchar *buffer;
gint n;
if (!view->split_screen)
@@ -295,6 +300,9 @@ doc_delete_text_cb(GtkWidget *editable, int start_pos, int end_pos,
}
+ buffer = gtk_editable_get_chars (GTK_EDITABLE(editable), start_pos, end_pos);
+ gE_undo_add (buffer, start_pos, end_pos, DELETE, doc);
+
view->flag = significant_other;
gtk_text_freeze (GTK_TEXT (significant_other));
gtk_editable_delete_text (GTK_EDITABLE (significant_other), start_pos, end_pos);
@@ -335,7 +343,7 @@ doc_delete_text_cb(GtkWidget *editable, int start_pos, int end_pos,
}
}
-
+
}
diff --git a/gedit/main.h b/gedit/main.h
index 920efca66..f50a79032 100644
--- a/gedit/main.h
+++ b/gedit/main.h
@@ -78,6 +78,7 @@ typedef struct _gE_document {
/* Undo/Redo GLists */
GList *undo; /* Undo Stack */
+ GList *undo_top;
GList *redo; /* Redo Stack */
} gE_document;
diff --git a/src/Makefile.am b/src/Makefile.am
index ef0737968..98863730b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -48,6 +48,8 @@ gedit_SOURCES = \
gE_view.h \
gE_mdi.c \
gE_mdi.h \
+ gE_undo.c \
+ gE_undo.h \
gE_about.c \
gE_about.h \
gE_files.c \
diff --git a/src/gE_undo.c b/src/gE_undo.c
index f578003a7..3fb41657e 100644
--- a/src/gE_undo.c
+++ b/src/gE_undo.c
@@ -25,3 +25,30 @@
#include "gE_mdi.h"
#include "gE_window.h"
+
+void gE_undo_add (gchar *text, gint start_pos, gint end_pos, gint action, gE_document *doc)
+{
+
+ gE_undo *undo;
+
+ undo = g_new(gE_undo, 1);
+
+ undo->text = text;
+ undo->start_pos = start_pos;
+ undo->end_pos = end_pos;
+ undo->action = action;
+ undo->status = doc->changed;
+
+ /* nuke the redo list, if its available */
+ if (doc->redo) {
+
+ g_list_free (doc->redo);
+
+ }
+
+ g_message ("gE_undo_add: Adding to Undo list..");
+
+ doc->undo = g_list_prepend (doc->undo, undo);
+
+}
+
diff --git a/src/gE_undo.h b/src/gE_undo.h
index bdbaf77f9..85482b3fc 100644
--- a/src/gE_undo.h
+++ b/src/gE_undo.h
@@ -44,10 +44,10 @@ typedef struct _gE_undo {
/* add an undo node */
-extern void gE_undo_add (gchar*, gint*, gint*, gint*, gE_document*);
+extern void gE_undo_add (gchar*, gint, gint, gint, gE_document*);
/* clear the list */
-extern void gE_undo_reset (gE_document*);
+extern void gE_undo_reset (GList*);
/* callbacks to do the undo or the redo */
extern void gE_undo_do (GtkWidget*, gpointer*);
diff --git a/src/gE_view.c b/src/gE_view.c
index a875c0a65..57bc280a7 100644
--- a/src/gE_view.c
+++ b/src/gE_view.c
@@ -22,6 +22,7 @@
#include <config.h>
#include "gE_view.h"
#include "main.h"
+#include "gE_undo.h"
#include "gE_mdi.h"
#include "commands.h"
#include "gE_prefs.h"
@@ -244,6 +245,9 @@ doc_insert_text_cb(GtkWidget *editable, const guchar *insertion_text, int length
gtk_text_set_point (GTK_TEXT (significant_other), position);
g_free (data);
+
+
+ gE_undo_add (buffer, position, (pos + length), INSERT, doc);
if (length > 96)
g_free (buffer);
@@ -258,6 +262,7 @@ doc_delete_text_cb(GtkWidget *editable, int start_pos, int end_pos,
GtkWidget *significant_other;
gE_document *doc;
gE_view *nth_view = NULL;
+ gchar *buffer;
gint n;
if (!view->split_screen)
@@ -295,6 +300,9 @@ doc_delete_text_cb(GtkWidget *editable, int start_pos, int end_pos,
}
+ buffer = gtk_editable_get_chars (GTK_EDITABLE(editable), start_pos, end_pos);
+ gE_undo_add (buffer, start_pos, end_pos, DELETE, doc);
+
view->flag = significant_other;
gtk_text_freeze (GTK_TEXT (significant_other));
gtk_editable_delete_text (GTK_EDITABLE (significant_other), start_pos, end_pos);
@@ -335,7 +343,7 @@ doc_delete_text_cb(GtkWidget *editable, int start_pos, int end_pos,
}
}
-
+
}
diff --git a/src/main.h b/src/main.h
index 920efca66..f50a79032 100644
--- a/src/main.h
+++ b/src/main.h
@@ -78,6 +78,7 @@ typedef struct _gE_document {
/* Undo/Redo GLists */
GList *undo; /* Undo Stack */
+ GList *undo_top;
GList *redo; /* Redo Stack */
} gE_document;