Tweaking still more comments.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4731 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
b115aab586
commit
189fff44dc
|
@ -18,7 +18,7 @@
|
||||||
* src/prompt.c (get_prompt_string): Fix compilation for the
|
* src/prompt.c (get_prompt_string): Fix compilation for the
|
||||||
combination of --enable-tiny with --enable-tabcomp.
|
combination of --enable-tiny with --enable-tabcomp.
|
||||||
* src/prompt.c (get_prompt_string): Normalize the indentation.
|
* src/prompt.c (get_prompt_string): Normalize the indentation.
|
||||||
* src/text.c (do_wrap): Fix compilation with --enable-wrapping.
|
* src/text.c: Comment tweaks.
|
||||||
|
|
||||||
2014-04-03 Benno Schulenberg <bensberg@justemail.net>
|
2014-04-03 Benno Schulenberg <bensberg@justemail.net>
|
||||||
* configure.ac: Remove unused '*_support' variables.
|
* configure.ac: Remove unused '*_support' variables.
|
||||||
|
|
92
src/text.c
92
src/text.c
|
@ -216,8 +216,7 @@ void do_indent(ssize_t cols)
|
||||||
if (cols == 0)
|
if (cols == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* If cols is negative, make it positive and set unindent to
|
/* If cols is negative, make it positive and set unindent to TRUE. */
|
||||||
* TRUE. */
|
|
||||||
if (cols < 0) {
|
if (cols < 0) {
|
||||||
cols = -cols;
|
cols = -cols;
|
||||||
unindent = TRUE;
|
unindent = TRUE;
|
||||||
|
@ -360,20 +359,21 @@ void do_unindent(void)
|
||||||
do_indent(-tabsize);
|
do_indent(-tabsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* undo a cut, or re-do an uncut */
|
|
||||||
|
/* Undo a cut, or redo an uncut. */
|
||||||
void undo_cut(undo *u)
|
void undo_cut(undo *u)
|
||||||
{
|
{
|
||||||
/* If we cut the magicline may was well not crash :/ */
|
/* If we cut the magicline, we may as well not crash. :/ */
|
||||||
if (!u->cutbuffer)
|
if (!u->cutbuffer)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
cutbuffer = copy_filestruct(u->cutbuffer);
|
cutbuffer = copy_filestruct(u->cutbuffer);
|
||||||
|
|
||||||
/* Compute cutbottom for the uncut using out copy */
|
/* Compute cutbottom for the uncut using our copy. */
|
||||||
for (cutbottom = cutbuffer; cutbottom->next != NULL; cutbottom = cutbottom->next)
|
for (cutbottom = cutbuffer; cutbottom->next != NULL; cutbottom = cutbottom->next)
|
||||||
;
|
;
|
||||||
|
|
||||||
/* Get to where we need to uncut from */
|
/* Get to where we need to uncut from. */
|
||||||
if (u->mark_set && u->mark_begin_lineno < u->lineno)
|
if (u->mark_set && u->mark_begin_lineno < u->lineno)
|
||||||
do_gotolinecolumn(u->mark_begin_lineno, u->mark_begin_x+1, FALSE, FALSE, FALSE, FALSE);
|
do_gotolinecolumn(u->mark_begin_lineno, u->mark_begin_x+1, FALSE, FALSE, FALSE, FALSE);
|
||||||
else
|
else
|
||||||
|
@ -385,12 +385,12 @@ void undo_cut(undo *u)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Re-do a cut, or undo an uncut */
|
/* Redo a cut, or undo an uncut. */
|
||||||
void redo_cut(undo *u) {
|
void redo_cut(undo *u) {
|
||||||
int i;
|
int i;
|
||||||
filestruct *t, *c;
|
filestruct *t, *c;
|
||||||
|
|
||||||
/* If we cut the magicline may was well not crash :/ */
|
/* If we cut the magicline, we may as well not crash. :/ */
|
||||||
if (!u->cutbuffer)
|
if (!u->cutbuffer)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -400,15 +400,15 @@ void redo_cut(undo *u) {
|
||||||
free(cutbuffer);
|
free(cutbuffer);
|
||||||
cutbuffer = NULL;
|
cutbuffer = NULL;
|
||||||
|
|
||||||
/* Move ahead the same # lines we had if a marked cut */
|
/* Move ahead the same # lines we had if a marked cut. */
|
||||||
if (u->mark_set) {
|
if (u->mark_set) {
|
||||||
for (i = 1, t = openfile->fileage; i != u->mark_begin_lineno; i++)
|
for (i = 1, t = openfile->fileage; i != u->mark_begin_lineno; i++)
|
||||||
t = t->next;
|
t = t->next;
|
||||||
openfile->mark_begin = t;
|
openfile->mark_begin = t;
|
||||||
} else if (!u->to_end) {
|
} else if (!u->to_end) {
|
||||||
/* Here we have a regular old potentially multi-line ^K cut. We'll
|
/* Here we have a regular old potentially multi-line ^K cut.
|
||||||
need to trick nano into thinking it's a marked cut to cut more
|
* We'll need to trick nano into thinking it's a marked cut,
|
||||||
than one line again */
|
* to cut more than one line again. */
|
||||||
for (c = u->cutbuffer, t = openfile->current; c->next != NULL && t->next != NULL; ) {
|
for (c = u->cutbuffer, t = openfile->current; c->next != NULL && t->next != NULL; ) {
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
@ -430,7 +430,7 @@ void redo_cut(undo *u) {
|
||||||
edit_refresh_needed = TRUE;
|
edit_refresh_needed = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Undo the last thing(s) we did */
|
/* Undo the last thing(s) we did. */
|
||||||
void do_undo(void)
|
void do_undo(void)
|
||||||
{
|
{
|
||||||
undo *u = openfile->current_undo;
|
undo *u = openfile->current_undo;
|
||||||
|
@ -444,7 +444,6 @@ void do_undo(void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (u->lineno <= f->lineno)
|
if (u->lineno <= f->lineno)
|
||||||
for (; f->prev != NULL && f->lineno != u->lineno; f = f->prev)
|
for (; f->prev != NULL && f->lineno != u->lineno; f = f->prev)
|
||||||
;
|
;
|
||||||
|
@ -498,7 +497,7 @@ void do_undo(void)
|
||||||
}
|
}
|
||||||
renumber(f);
|
renumber(f);
|
||||||
break;
|
break;
|
||||||
#endif /* DISABLE_WRAPPING */
|
#endif /* !DISABLE_WRAPPING */
|
||||||
case UNSPLIT:
|
case UNSPLIT:
|
||||||
undidmsg = _("line join");
|
undidmsg = _("line join");
|
||||||
t = make_new_node(f);
|
t = make_new_node(f);
|
||||||
|
@ -532,9 +531,9 @@ void do_undo(void)
|
||||||
undidmsg = _("text insert");
|
undidmsg = _("text insert");
|
||||||
cutbuffer = NULL;
|
cutbuffer = NULL;
|
||||||
cutbottom = NULL;
|
cutbottom = NULL;
|
||||||
/* When we updated mark_begin_lineno in update_undo, it was effectively how many line
|
/* When we updated mark_begin_lineno in update_undo, it was effectively
|
||||||
were inserted due to being partitioned before read_file was called. So we
|
* how many lines were inserted due to being partitioned before read_file
|
||||||
add its value here */
|
* was called. So we add its value here. */
|
||||||
openfile->mark_begin = fsfromline(u->lineno + u->mark_begin_lineno - 1);
|
openfile->mark_begin = fsfromline(u->lineno + u->mark_begin_lineno - 1);
|
||||||
openfile->mark_begin_x = 0;
|
openfile->mark_begin_x = 0;
|
||||||
openfile->mark_set = TRUE;
|
openfile->mark_set = TRUE;
|
||||||
|
@ -565,6 +564,7 @@ void do_undo(void)
|
||||||
openfile->last_action = OTHER;
|
openfile->last_action = OTHER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Redo the last thing(s) we undid. */
|
||||||
void do_redo(void)
|
void do_redo(void)
|
||||||
{
|
{
|
||||||
undo *u = openfile->undotop;
|
undo *u = openfile->undotop;
|
||||||
|
@ -631,7 +631,7 @@ void do_redo(void)
|
||||||
do_wrap(f, TRUE);
|
do_wrap(f, TRUE);
|
||||||
renumber(f);
|
renumber(f);
|
||||||
break;
|
break;
|
||||||
#endif /* DISABLE_WRAPPING */
|
#endif /* !DISABLE_WRAPPING */
|
||||||
case UNSPLIT:
|
case UNSPLIT:
|
||||||
undidmsg = _("line join");
|
undidmsg = _("line join");
|
||||||
len = strlen(f->data) + strlen(u->strdata + 1);
|
len = strlen(f->data) + strlen(u->strdata + 1);
|
||||||
|
@ -772,9 +772,8 @@ bool execute_command(const char *command)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check $SHELL for the shell to use. If it isn't set, use
|
/* Check $SHELL for the shell to use. If it isn't set, use /bin/sh.
|
||||||
* /bin/sh. Note that $SHELL should contain only a path, with no
|
* Note that $SHELL should contain only a path, with no arguments. */
|
||||||
* arguments. */
|
|
||||||
shellenv = getenv("SHELL");
|
shellenv = getenv("SHELL");
|
||||||
if (shellenv == NULL)
|
if (shellenv == NULL)
|
||||||
shellenv = (char *) "/bin/sh";
|
shellenv = (char *) "/bin/sh";
|
||||||
|
@ -840,26 +839,26 @@ bool execute_command(const char *command)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add a new undo struct to the top of the current pile */
|
/* Add a new undo struct to the top of the current pile. */
|
||||||
void add_undo(undo_type current_action)
|
void add_undo(undo_type current_action)
|
||||||
{
|
{
|
||||||
undo *u;
|
undo *u;
|
||||||
char *data;
|
char *data;
|
||||||
openfilestruct *fs = openfile;
|
openfilestruct *fs = openfile;
|
||||||
static undo *last_cutu = NULL; /* Last thing we cut to set up the undo for uncut */
|
static undo *last_cutu = NULL; /* Last thing we cut to set up the undo for uncut. */
|
||||||
ssize_t wrap_loc; /* For calculating split beginning */
|
ssize_t wrap_loc; /* For calculating split beginning. */
|
||||||
|
|
||||||
if (!ISSET(UNDOABLE))
|
if (!ISSET(UNDOABLE))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Ugh, if we were called while cutting not-to-end, non-marked and on the same lineno,
|
/* Ugh, if we were called while cutting not-to-end, non-marked, and
|
||||||
we need to abort here */
|
* on the same lineno, we need to abort here. */
|
||||||
u = fs->current_undo;
|
u = fs->current_undo;
|
||||||
if (current_action == CUT && u && u->type == CUT
|
if (current_action == CUT && u && u->type == CUT
|
||||||
&& !u->mark_set && u->lineno == fs->current->lineno)
|
&& !u->mark_set && u->lineno == fs->current->lineno)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Blow away the old undo stack if we are starting from the middle */
|
/* Blow away the old undo stack if we are starting from the middle. */
|
||||||
while (fs->undotop != NULL && fs->undotop != fs->current_undo) {
|
while (fs->undotop != NULL && fs->undotop != fs->current_undo) {
|
||||||
undo *u2 = fs->undotop;
|
undo *u2 = fs->undotop;
|
||||||
fs->undotop = fs->undotop->next;
|
fs->undotop = fs->undotop->next;
|
||||||
|
@ -870,7 +869,7 @@ void add_undo(undo_type current_action)
|
||||||
free(u2);
|
free(u2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Allocate and initialize a new undo type */
|
/* Allocate and initialize a new undo type. */
|
||||||
u = (undo *) nmalloc(sizeof(undo));
|
u = (undo *) nmalloc(sizeof(undo));
|
||||||
u->type = current_action;
|
u->type = current_action;
|
||||||
u->lineno = fs->current->lineno;
|
u->lineno = fs->current->lineno;
|
||||||
|
@ -889,8 +888,8 @@ void add_undo(undo_type current_action)
|
||||||
u->to_end = FALSE;
|
u->to_end = FALSE;
|
||||||
|
|
||||||
switch (u->type) {
|
switch (u->type) {
|
||||||
/* We need to start copying data into the undo buffer or we wont be able
|
/* We need to start copying data into the undo buffer
|
||||||
to restore it later */
|
* or we won't be able to restore it later. */
|
||||||
case ADD:
|
case ADD:
|
||||||
data = charalloc(2);
|
data = charalloc(2);
|
||||||
data[0] = fs->current->data[fs->current_x];
|
data[0] = fs->current->data[fs->current_x];
|
||||||
|
@ -904,7 +903,7 @@ void add_undo(undo_type current_action)
|
||||||
u->strdata = data;
|
u->strdata = data;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* Else purposely fall into unsplit code */
|
/* Else purposely fall into unsplit code. */
|
||||||
current_action = u->type = UNSPLIT;
|
current_action = u->type = UNSPLIT;
|
||||||
case UNSPLIT:
|
case UNSPLIT:
|
||||||
if (fs->current->next) {
|
if (fs->current->next) {
|
||||||
|
@ -920,13 +919,13 @@ void add_undo(undo_type current_action)
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
u->strdata = mallocstrcpy(NULL, &openfile->current->data[wrap_loc]);
|
u->strdata = mallocstrcpy(NULL, &openfile->current->data[wrap_loc]);
|
||||||
/* Don't both saving the next line if we're not prepending as a new line
|
/* Don't bother saving the next line if we're not prepending,
|
||||||
will be created */
|
* as a new line will be created. */
|
||||||
if (prepend_wrap)
|
if (prepend_wrap)
|
||||||
u->strdata2 = mallocstrcpy(NULL, fs->current->next->data);
|
u->strdata2 = mallocstrcpy(NULL, fs->current->next->data);
|
||||||
u->begin = wrap_loc;
|
u->begin = wrap_loc;
|
||||||
break;
|
break;
|
||||||
#endif /* DISABLE_WRAPPING */
|
#endif /* !DISABLE_WRAPPING */
|
||||||
case INSERT:
|
case INSERT:
|
||||||
case REPLACE:
|
case REPLACE:
|
||||||
data = mallocstrcpy(NULL, fs->current->data);
|
data = mallocstrcpy(NULL, fs->current->data);
|
||||||
|
@ -964,11 +963,10 @@ void add_undo(undo_type current_action)
|
||||||
fs->last_action = current_action;
|
fs->last_action = current_action;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update an undo item, or determine whether a new one
|
/* Update an undo item, or determine whether a new one is really needed
|
||||||
is really needed and bounce the data to add_undo
|
* and bounce the data to add_undo instead. The latter functionality
|
||||||
instead. The latter functionality just feels
|
* just feels gimmicky and may just be more hassle than it's worth,
|
||||||
gimmicky and may just be more hassle than
|
* so it should be axed if needed. */
|
||||||
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;
|
||||||
|
@ -989,7 +987,7 @@ void update_undo(undo_type action)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Change to an add if we're not using the same undo struct
|
/* Change to an add if we're not using the same undo struct
|
||||||
that we should be using */
|
* that we should be using. */
|
||||||
if (action != fs->last_action
|
if (action != fs->last_action
|
||||||
|| (action != CUT && action != INSERT && action != SPLIT
|
|| (action != CUT && action != INSERT && action != SPLIT
|
||||||
&& openfile->current->lineno != fs->current_undo->lineno)) {
|
&& openfile->current->lineno != fs->current_undo->lineno)) {
|
||||||
|
@ -1019,7 +1017,7 @@ void update_undo(undo_type action)
|
||||||
len = strlen(u->strdata) + 2;
|
len = strlen(u->strdata) + 2;
|
||||||
assert(len > 2);
|
assert(len > 2);
|
||||||
if (fs->current_x == u->begin) {
|
if (fs->current_x == u->begin) {
|
||||||
/* They're deleting */
|
/* They're deleting. */
|
||||||
if (!u->xflags)
|
if (!u->xflags)
|
||||||
u->xflags = UNdel_del;
|
u->xflags = UNdel_del;
|
||||||
else if (u->xflags != UNdel_del) {
|
else if (u->xflags != UNdel_del) {
|
||||||
|
@ -1033,7 +1031,7 @@ void update_undo(undo_type action)
|
||||||
free(u->strdata);
|
free(u->strdata);
|
||||||
u->strdata = data;
|
u->strdata = data;
|
||||||
} else if (fs->current_x == u->begin - 1) {
|
} else if (fs->current_x == u->begin - 1) {
|
||||||
/* They're backspacing */
|
/* They're backspacing. */
|
||||||
if (!u->xflags)
|
if (!u->xflags)
|
||||||
u->xflags = UNdel_backspace;
|
u->xflags = UNdel_backspace;
|
||||||
else if (u->xflags != UNdel_backspace) {
|
else if (u->xflags != UNdel_backspace) {
|
||||||
|
@ -1047,7 +1045,7 @@ void update_undo(undo_type action)
|
||||||
u->strdata = data;
|
u->strdata = data;
|
||||||
u->begin--;
|
u->begin--;
|
||||||
} else {
|
} else {
|
||||||
/* They deleted something else on the line */
|
/* They deleted something else on the line. */
|
||||||
add_undo(DEL);
|
add_undo(DEL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1061,7 +1059,7 @@ void update_undo(undo_type action)
|
||||||
if (u->cutbuffer)
|
if (u->cutbuffer)
|
||||||
free(u->cutbuffer);
|
free(u->cutbuffer);
|
||||||
u->cutbuffer = copy_filestruct(cutbuffer);
|
u->cutbuffer = copy_filestruct(cutbuffer);
|
||||||
/* Compute cutbottom for the uncut using out copy */
|
/* Compute cutbottom for the uncut using our copy. */
|
||||||
for (u->cutbottom = u->cutbuffer; u->cutbottom->next != NULL; u->cutbottom = u->cutbottom->next)
|
for (u->cutbottom = u->cutbuffer; u->cutbottom->next != NULL; u->cutbottom = u->cutbottom->next)
|
||||||
;
|
;
|
||||||
break;
|
break;
|
||||||
|
@ -1075,12 +1073,12 @@ void update_undo(undo_type action)
|
||||||
#ifndef DISABLE_WRAPPING
|
#ifndef DISABLE_WRAPPING
|
||||||
case SPLIT:
|
case SPLIT:
|
||||||
/* This will only be called if we made a completely new line,
|
/* This will only be called if we made a completely new line,
|
||||||
and as such we should note that so we can destroy it later */
|
* and as such we should note that so we can destroy it later. */
|
||||||
u->xflags = UNsplit_madenew;
|
u->xflags = UNsplit_madenew;
|
||||||
break;
|
break;
|
||||||
#endif /* DISABLE_WRAPPING */
|
#endif /* DISABLE_WRAPPING */
|
||||||
case UNSPLIT:
|
case UNSPLIT:
|
||||||
/* These cases are handled by the earlier check for a new line and action */
|
/* These cases are handled by the earlier check for a new line and action. */
|
||||||
case ENTER:
|
case ENTER:
|
||||||
case OTHER:
|
case OTHER:
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue