Add auto indenting of wrapped lines which should be indented. Also fix
total file size (totsize) when auto indenting. git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@557 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
46055b2543
commit
1e9183fe31
23
nano.c
23
nano.c
|
@ -586,6 +586,7 @@ int do_enter(filestruct * inptr)
|
||||||
extra++;
|
extra++;
|
||||||
spc++;
|
spc++;
|
||||||
current_x++;
|
current_x++;
|
||||||
|
totsize++;
|
||||||
}
|
}
|
||||||
new->data = nmalloc(strlen(tmp) + extra + 1);
|
new->data = nmalloc(strlen(tmp) + extra + 1);
|
||||||
strncpy(new->data, current->data, extra);
|
strncpy(new->data, current->data, extra);
|
||||||
|
@ -911,6 +912,7 @@ void do_wrap(filestruct * inptr, char input_char)
|
||||||
}
|
}
|
||||||
/* Else we start a new line. */
|
/* Else we start a new line. */
|
||||||
else {
|
else {
|
||||||
|
|
||||||
temp->prev = inptr;
|
temp->prev = inptr;
|
||||||
temp->next = inptr->next;
|
temp->next = inptr->next;
|
||||||
|
|
||||||
|
@ -922,6 +924,25 @@ void do_wrap(filestruct * inptr, char input_char)
|
||||||
filebot = temp;
|
filebot = temp;
|
||||||
|
|
||||||
SET(SAMELINEWRAP);
|
SET(SAMELINEWRAP);
|
||||||
|
|
||||||
|
if (ISSET(AUTOINDENT)) {
|
||||||
|
char *spc = inptr->data;
|
||||||
|
char *t = NULL;
|
||||||
|
int extra = 0;
|
||||||
|
if (spc) {
|
||||||
|
while ((*spc == ' ') || (*spc == '\t')) {
|
||||||
|
extra++;
|
||||||
|
spc++;
|
||||||
|
right++;
|
||||||
|
totsize++;
|
||||||
|
}
|
||||||
|
t = nmalloc(strlen(temp->data) + extra + 1);
|
||||||
|
strncpy(t, inptr->data, extra);
|
||||||
|
strcpy(t + extra, temp->data);
|
||||||
|
free(temp->data);
|
||||||
|
temp->data = t;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -929,7 +950,7 @@ void do_wrap(filestruct * inptr, char input_char)
|
||||||
/* Everything about it makes me want this line here but it causes
|
/* Everything about it makes me want this line here but it causes
|
||||||
* totsize to be high by one for some reason. Sigh. (Rob) */
|
* totsize to be high by one for some reason. Sigh. (Rob) */
|
||||||
/* totsize++; */
|
/* totsize++; */
|
||||||
|
|
||||||
renumber(inptr);
|
renumber(inptr);
|
||||||
edit_update(edittop, TOP);
|
edit_update(edittop, TOP);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue