tweaks: adjust two comments, move two declarations, rewrap three lines
parent
22f7861694
commit
95fffa99aa
34
src/text.c
34
src/text.c
|
@ -1368,20 +1368,19 @@ void update_multiline_undo(ssize_t lineno, char *indentation)
|
||||||
u->newsize = openfile->totsize;
|
u->newsize = openfile->totsize;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update an undo item, or determine whether a new one is really needed
|
/* Update an undo record, after checking that a new one is not needed. */
|
||||||
* and bounce the data to add_undo instead. The latter functionality
|
|
||||||
* just feels gimmicky and may just be more hassle than it's worth,
|
|
||||||
* so it should be axed if needed. */
|
|
||||||
void update_undo(undo_type action)
|
void update_undo(undo_type action)
|
||||||
{
|
{
|
||||||
undo *u;
|
undo *u = openfile->undotop;
|
||||||
|
char *char_buf;
|
||||||
|
int char_len;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, " >> Updating an undo... action = %d\n", action);
|
fprintf(stderr, " >> Updating an undo... action = %d\n", action);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Change to an add if we're not using the same undo struct
|
/* If the action is different or the position changed, don't update the
|
||||||
* that we should be using. */
|
* current record but add a new one instead. */
|
||||||
if (action != openfile->last_action ||
|
if (action != openfile->last_action ||
|
||||||
(action != ENTER && action != CUT && action != INSERT &&
|
(action != ENTER && action != CUT && action != INSERT &&
|
||||||
openfile->current->lineno != openfile->current_undo->lineno)) {
|
openfile->current->lineno != openfile->current_undo->lineno)) {
|
||||||
|
@ -1389,27 +1388,27 @@ fprintf(stderr, " >> Updating an undo... action = %d\n", action);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
u = openfile->undotop;
|
|
||||||
|
|
||||||
u->newsize = openfile->totsize;
|
u->newsize = openfile->totsize;
|
||||||
|
|
||||||
switch (u->type) {
|
switch (u->type) {
|
||||||
case ADD: {
|
case ADD:
|
||||||
char *char_buf = charalloc(MAXCHARLEN);
|
char_buf = charalloc(MAXCHARLEN);
|
||||||
int char_len = parse_mbchar(&openfile->current->data[u->mark_begin_x], char_buf, NULL);
|
char_len = parse_mbchar(&openfile->current->data[u->mark_begin_x],
|
||||||
u->strdata = addstrings(u->strdata, u->strdata ? strlen(u->strdata) : 0, char_buf, char_len);
|
char_buf, NULL);
|
||||||
|
u->strdata = addstrings(u->strdata, u->strdata ? strlen(u->strdata) : 0,
|
||||||
|
char_buf, char_len);
|
||||||
u->mark_begin_lineno = openfile->current->lineno;
|
u->mark_begin_lineno = openfile->current->lineno;
|
||||||
u->mark_begin_x = openfile->current_x;
|
u->mark_begin_x = openfile->current_x;
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case ENTER:
|
case ENTER:
|
||||||
u->strdata = mallocstrcpy(NULL, openfile->current->data);
|
u->strdata = mallocstrcpy(NULL, openfile->current->data);
|
||||||
u->mark_begin_x = openfile->current_x;
|
u->mark_begin_x = openfile->current_x;
|
||||||
break;
|
break;
|
||||||
case BACK:
|
case BACK:
|
||||||
case DEL: {
|
case DEL:
|
||||||
char *char_buf = charalloc(MAXCHARLEN);
|
char_buf = charalloc(MAXCHARLEN);
|
||||||
int char_len = parse_mbchar(&openfile->current->data[openfile->current_x], char_buf, NULL);
|
char_len = parse_mbchar(&openfile->current->data[openfile->current_x],
|
||||||
|
char_buf, NULL);
|
||||||
if (openfile->current_x == u->begin) {
|
if (openfile->current_x == u->begin) {
|
||||||
/* They deleted more: add removed character after earlier stuff. */
|
/* They deleted more: add removed character after earlier stuff. */
|
||||||
u->strdata = addstrings(u->strdata, strlen(u->strdata), char_buf, char_len);
|
u->strdata = addstrings(u->strdata, strlen(u->strdata), char_buf, char_len);
|
||||||
|
@ -1425,7 +1424,6 @@ fprintf(stderr, " >> Updating an undo... action = %d\n", action);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case JOIN:
|
case JOIN:
|
||||||
break;
|
break;
|
||||||
case REPLACE:
|
case REPLACE:
|
||||||
|
|
Loading…
Reference in New Issue