efficiency and comment fixes
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3233 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
26ebd35d54
commit
a685468a18
44
src/text.c
44
src/text.c
|
@ -1161,11 +1161,11 @@ bool find_paragraph(size_t *const quote, size_t *const par)
|
||||||
void do_justify(bool full_justify)
|
void do_justify(bool full_justify)
|
||||||
{
|
{
|
||||||
filestruct *first_par_line = NULL;
|
filestruct *first_par_line = NULL;
|
||||||
/* Will be the first line of the justified paragraph. For
|
/* Will be the first line of the justified paragraph(s), if any.
|
||||||
* restoring after unjustify. */
|
* For restoring after unjustify. */
|
||||||
filestruct *last_par_line = NULL;
|
filestruct *last_par_line = NULL;
|
||||||
/* Will be the line after the last line of the justified
|
/* Will be the line after the last line of the justified
|
||||||
* paragraph, if any. Also for restoring after unjustify. */
|
* paragraph(s), if any. Also for restoring after unjustify. */
|
||||||
bool filebot_inpar = FALSE;
|
bool filebot_inpar = FALSE;
|
||||||
/* Whether the text at filebot is part of the current
|
/* Whether the text at filebot is part of the current
|
||||||
* paragraph. */
|
* paragraph. */
|
||||||
|
@ -1198,25 +1198,27 @@ void do_justify(bool full_justify)
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
size_t i;
|
size_t i;
|
||||||
/* Generic loop variable. */
|
/* Generic loop variable. */
|
||||||
|
filestruct *curr_first_par_line;
|
||||||
|
/* The first line of the current paragraph. */
|
||||||
size_t quote_len;
|
size_t quote_len;
|
||||||
/* Length of the initial quotation of the paragraph we
|
/* Length of the initial quotation of the current
|
||||||
* justify. */
|
* paragraph. */
|
||||||
size_t indent_len;
|
size_t indent_len;
|
||||||
/* Length of the initial indentation of the paragraph we
|
/* Length of the initial indentation of the current
|
||||||
* justify. */
|
* paragraph. */
|
||||||
size_t par_len;
|
size_t par_len;
|
||||||
/* Number of lines in the paragraph we justify. */
|
/* Number of lines in the current paragraph. */
|
||||||
ssize_t break_pos;
|
ssize_t break_pos;
|
||||||
/* Where we will break lines. */
|
/* Where we will break lines. */
|
||||||
char *indent_string;
|
char *indent_string;
|
||||||
/* The first indentation that doesn't match the initial
|
/* The first indentation that doesn't match the initial
|
||||||
* indentation of the paragraph we justify. This is put at
|
* indentation of the current paragraph. This is put at the
|
||||||
* the beginning of every line broken off the first
|
* beginning of every line broken off the first justified
|
||||||
* justified line of the paragraph. Note that this works
|
* line of the paragraph. Note that this works because a
|
||||||
* because a paragraph can only contain two indentations at
|
* paragraph can only contain two indentations at most: the
|
||||||
* most: the initial one, and a different one starting on a
|
* initial one, and a different one starting on a line after
|
||||||
* line after the first. See the comment at begpar() for
|
* the first. See the comment at begpar() for more about
|
||||||
* more about when a line is part of a paragraph. */
|
* when a line is part of a paragraph. */
|
||||||
|
|
||||||
/* Find the first line of the paragraph to be justified. That
|
/* Find the first line of the paragraph to be justified. That
|
||||||
* is the start of this paragraph if we're in one, or the start
|
* is the start of this paragraph if we're in one, or the start
|
||||||
|
@ -1259,6 +1261,10 @@ void do_justify(bool full_justify)
|
||||||
first_par_line = openfile->current;
|
first_par_line = openfile->current;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Set curr_first_par_line to the first line of the current
|
||||||
|
* paragraph. */
|
||||||
|
curr_first_par_line = openfile->current;
|
||||||
|
|
||||||
/* Initialize indent_string to a blank string. */
|
/* Initialize indent_string to a blank string. */
|
||||||
indent_string = mallocstrcpy(NULL, "");
|
indent_string = mallocstrcpy(NULL, "");
|
||||||
|
|
||||||
|
@ -1448,10 +1454,10 @@ void do_justify(bool full_justify)
|
||||||
} else
|
} else
|
||||||
openfile->current_x = strlen(openfile->current->data);
|
openfile->current_x = strlen(openfile->current->data);
|
||||||
|
|
||||||
/* Renumber the lines of the now-justified paragraph, since both
|
/* Renumber the lines of the now-justified current paragraph,
|
||||||
* find_paragraph() and edit_refresh() need the line numbers to
|
* since both find_paragraph() and edit_refresh() need the line
|
||||||
* be right. */
|
* numbers to be right. */
|
||||||
renumber(first_par_line);
|
renumber(curr_first_par_line);
|
||||||
|
|
||||||
/* We've just finished justifying the paragraph. If we're not
|
/* We've just finished justifying the paragraph. If we're not
|
||||||
* justifying the entire file, break out of the loop.
|
* justifying the entire file, break out of the loop.
|
||||||
|
|
Loading…
Reference in New Issue