summaryrefslogtreecommitdiff
path: root/Src/Zle/zle_utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'Src/Zle/zle_utils.c')
-rw-r--r--Src/Zle/zle_utils.c52
1 files changed, 51 insertions, 1 deletions
diff --git a/Src/Zle/zle_utils.c b/Src/Zle/zle_utils.c
index b82e54ce5..1089e274f 100644
--- a/Src/Zle/zle_utils.c
+++ b/Src/Zle/zle_utils.c
@@ -710,6 +710,27 @@ zle_restore_positions(void)
}
/*
+ * Discard positions previously saved, the line has been updated.
+ */
+
+/**/
+mod_export void
+zle_free_positions(void)
+{
+ struct zle_position *oldpos = zle_positions;
+ struct zle_region *oldrhp;
+
+ zle_positions = oldpos->next;
+ oldrhp = oldpos->regions;
+ while (oldrhp) {
+ struct zle_region *nextrhp = oldrhp->next;
+ zfree(oldrhp, sizeof(*oldrhp));
+ oldrhp = nextrhp;
+ }
+ zfree(oldpos, sizeof(*oldpos));
+}
+
+/*
* Basic utility functions for adding to line or removing from line.
* At this level the counts supplied are raw character counts, so
* the calling code must be aware of combining characters where
@@ -1354,7 +1375,10 @@ handlesuffix(UNUSED(char **args))
/* head of the undo list, and the current position */
-static struct change *changes, *curchange;
+/**/
+struct change *curchange;
+
+static struct change *changes;
/* list of pending changes, not yet in the undo system */
@@ -1629,6 +1653,32 @@ viundochange(char **args)
return undo(args);
}
+/**/
+int
+splitundo(char **args)
+{
+ if (vistartchange >= 0) {
+ mergeundo();
+ vistartchange = (curchange && curchange->prev) ?
+ curchange->prev->changeno : 0;
+ }
+ handleundo();
+ return 0;
+}
+
+/**/
+void
+mergeundo(void)
+{
+ struct change *current;
+ for (current = curchange->prev;
+ current && current->prev && current->changeno > vistartchange+1;
+ current = current->prev) {
+ current->flags |= CH_PREV;
+ current->prev->flags |= CH_NEXT;
+ }
+}
+
/*
* Call a ZLE hook: a user-defined widget called at a specific point
* within the line editor.