#if ENABLE_FEATURE_VI_UNDO
static void flush_undo_data(void);
static void undo_push(char *, unsigned int, unsigned char); // Push an operation on the undo stack
+static void undo_push_insert(char *, int, int); // convenience function
static void undo_pop(void); // Undo the last operation
# if ENABLE_FEATURE_VI_UNDO_QUEUE
static void undo_queue_commit(void); // Flush any queued objects to the undo stack
c = get_one_char();
*p = c;
#if ENABLE_FEATURE_VI_UNDO
- switch (undo) {
- case ALLOW_UNDO:
- undo_push(p, 1, UNDO_INS);
- break;
- case ALLOW_UNDO_CHAIN:
- undo_push(p, 1, UNDO_INS_CHAIN);
- break;
-# if ENABLE_FEATURE_VI_UNDO_QUEUE
- case ALLOW_UNDO_QUEUED:
- undo_push(p, 1, UNDO_INS_QUEUED);
- break;
-# endif
- }
+ undo_push_insert(p, 1, undo);
#else
modified_count++;
#endif /* ENABLE_FEATURE_VI_UNDO */
if (c == '\n')
undo_queue_commit();
# endif
- switch (undo) {
- case ALLOW_UNDO:
- undo_push(p, 1, UNDO_INS);
- break;
- case ALLOW_UNDO_CHAIN:
- undo_push(p, 1, UNDO_INS_CHAIN);
- break;
-# if ENABLE_FEATURE_VI_UNDO_QUEUE
- case ALLOW_UNDO_QUEUED:
- undo_push(p, 1, UNDO_INS_QUEUED);
- break;
-# endif
- }
+ undo_push_insert(p, 1, undo);
#else
modified_count++;
#endif /* ENABLE_FEATURE_VI_UNDO */
p += bias;
q += bias;
#if ENABLE_FEATURE_VI_UNDO
- undo_push(p, len, UNDO_INS);
+ undo_push_insert(p, len, undo);
#endif
memcpy(p, q, len);
p += len;
modified_count++;
}
+static void undo_push_insert(char *p, int len, int undo)
+{
+ switch (undo) {
+ case ALLOW_UNDO:
+ undo_push(p, len, UNDO_INS);
+ break;
+ case ALLOW_UNDO_CHAIN:
+ undo_push(p, len, UNDO_INS_CHAIN);
+ break;
+# if ENABLE_FEATURE_VI_UNDO_QUEUE
+ case ALLOW_UNDO_QUEUED:
+ undo_push(p, len, UNDO_INS_QUEUED);
+ break;
+# endif
+ }
+}
+
static void undo_pop(void) // Undo the last operation
{
int repeat;
i = strlen(s);
#if ENABLE_FEATURE_VI_UNDO
- switch (undo) {
- case ALLOW_UNDO:
- undo_push(p, i, UNDO_INS);
- break;
- case ALLOW_UNDO_CHAIN:
- undo_push(p, i, UNDO_INS_CHAIN);
- break;
- }
+ undo_push_insert(p, i, undo);
#endif
bias = text_hole_make(p, i);
p += bias;