summaryrefslogtreecommitdiff
path: root/Src/Zle/zle_utils.c
diff options
context:
space:
mode:
authorAxel Beckert <abe@deuxchevaux.org>2014-08-11 17:39:42 +0200
committerAxel Beckert <abe@deuxchevaux.org>2014-08-11 17:39:42 +0200
commit382c26acfc62a56744ab9eb603efc56130764fd3 (patch)
tree1b7cb9d3e372481007fc4546e7d06ce5bb1bc104 /Src/Zle/zle_utils.c
parent73508e345b4925f33b7f652aba9bd313169e5ac2 (diff)
parentf8ae47f29b766dc0330b19d7fdb35859d6aab930 (diff)
downloadzsh-382c26acfc62a56744ab9eb603efc56130764fd3.tar.gz
zsh-382c26acfc62a56744ab9eb603efc56130764fd3.zip
New upstream release candidate: Merge branch 'upstream' into debian
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.