junie-undo
This commit is contained in:
64
main.c
64
main.c
@@ -1121,18 +1121,27 @@ insertch(const int16_t c)
|
||||
* a row; it can just figure out where the cursor is
|
||||
* at and what to do.
|
||||
*/
|
||||
if (ECURY == ENROWS) {
|
||||
erow_insert(ENROWS, "", 0);
|
||||
}
|
||||
if (ECURY == ENROWS) {
|
||||
erow_insert(ENROWS, "", 0);
|
||||
}
|
||||
|
||||
/* Inserting ends kill ring chaining. */
|
||||
editor.kill = 0;
|
||||
/* Inserting ends kill ring chaining. */
|
||||
editor.kill = 0;
|
||||
|
||||
row_insert_ch(&EROW[ECURY],
|
||||
ECURX,
|
||||
(int16_t) (c & 0xff));
|
||||
ECURX++;
|
||||
EDIRTY++;
|
||||
/* Begin/append undo record for insert operations */
|
||||
undo_tree *utree = &CURBUF->undo;
|
||||
undo_begin(utree, UNDO_INSERT);
|
||||
if (utree->pending && utree->pending->text.size == 0) {
|
||||
utree->pending->row = ECURY;
|
||||
utree->pending->col = ECURX;
|
||||
}
|
||||
undo_appendch(utree, (char)(c & 0xff));
|
||||
|
||||
row_insert_ch(&EROW[ECURY],
|
||||
ECURX,
|
||||
(int16_t) (c & 0xff));
|
||||
ECURX++;
|
||||
EDIRTY++;
|
||||
}
|
||||
|
||||
|
||||
@@ -1905,15 +1914,24 @@ move_cursor(const int16_t c, const int interactive)
|
||||
void
|
||||
newline(void)
|
||||
{
|
||||
abuf *row = NULL;
|
||||
size_t rhs_len = 0;
|
||||
char *tmp = NULL;
|
||||
abuf *row = NULL;
|
||||
size_t rhs_len = 0;
|
||||
char *tmp = NULL;
|
||||
|
||||
if (ECURY >= ENROWS) {
|
||||
erow_insert(ECURY, "", 0);
|
||||
ECURY++;
|
||||
ECURX = 0;
|
||||
} else if (ECURX == 0) {
|
||||
/* Begin/append undo record for insert operations (newline as '\n') */
|
||||
undo_tree *utree = &CURBUF->undo;
|
||||
undo_begin(utree, UNDO_INSERT);
|
||||
if (utree->pending && utree->pending->text.size == 0) {
|
||||
utree->pending->row = ECURY;
|
||||
utree->pending->col = ECURX;
|
||||
}
|
||||
undo_appendch(utree, '\n');
|
||||
|
||||
if (ECURY >= ENROWS) {
|
||||
erow_insert(ECURY, "", 0);
|
||||
ECURY++;
|
||||
ECURX = 0;
|
||||
} else if (ECURX == 0) {
|
||||
erow_insert(ECURY, "", 0);
|
||||
ECURY++;
|
||||
ECURX = 0;
|
||||
@@ -2177,14 +2195,16 @@ process_kcommand(const int16_t c)
|
||||
case 'u':
|
||||
reps = uarg_get();
|
||||
|
||||
while (reps--) {}
|
||||
editor_set_status("Undo not implemented.");
|
||||
while (reps--) {
|
||||
editor_undo(CURBUF);
|
||||
}
|
||||
break;
|
||||
case 'U':
|
||||
reps = uarg_get();
|
||||
|
||||
while (reps--) {}
|
||||
editor_set_status("Redo not implemented.");
|
||||
while (reps--) {
|
||||
editor_redo(CURBUF);
|
||||
}
|
||||
break;
|
||||
case 'y':
|
||||
reps = uarg_get();
|
||||
|
||||
Reference in New Issue
Block a user