in find_paragraph(), add parameter begin, the line that we can't move
further back than when searching for a paragraph; this is needed to ensure that we don't justify the same lines more than once if auto-indent is turned on, and the indentation of what should be the previous paragraph matches that of what should be the current paragraph git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3224 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
1932dfb131
commit
9a065c089f
|
@ -206,6 +206,13 @@ CVS code -
|
||||||
text is copied and so can be used instead of the old return
|
text is copied and so can be used instead of the old return
|
||||||
value. (DLR)
|
value. (DLR)
|
||||||
- Remove unused quote_len parameter. (DLR)
|
- Remove unused quote_len parameter. (DLR)
|
||||||
|
find_paragraph()
|
||||||
|
- Add parameter begin, the line that we can't move further back
|
||||||
|
than when searching for a paragraph. This is needed to ensure
|
||||||
|
that we don't justify the same lines more than once if
|
||||||
|
auto-indent is turned on, and the indentation of what should
|
||||||
|
be the previous paragraph matches that of what should be the
|
||||||
|
current paragraph. (DLR)
|
||||||
do_justify()
|
do_justify()
|
||||||
- Don't save current_y and restore it if the user unjustifies,
|
- Don't save current_y and restore it if the user unjustifies,
|
||||||
as the reset_cursor() called by edit_refresh() after restoring
|
as the reset_cursor() called by edit_refresh() after restoring
|
||||||
|
|
|
@ -583,7 +583,8 @@ bool indents_match(const char *a_line, size_t a_indent, const char
|
||||||
bool begpar(const filestruct *const foo);
|
bool begpar(const filestruct *const foo);
|
||||||
bool inpar(const filestruct *const foo);
|
bool inpar(const filestruct *const foo);
|
||||||
void backup_lines(filestruct *first_line, size_t par_len);
|
void backup_lines(filestruct *first_line, size_t par_len);
|
||||||
bool find_paragraph(size_t *const quote, size_t *const par);
|
bool find_paragraph(filestruct *begin, size_t *const quote, size_t
|
||||||
|
*const par);
|
||||||
void do_justify(bool full_justify);
|
void do_justify(bool full_justify);
|
||||||
void do_justify_void(void);
|
void do_justify_void(void);
|
||||||
void do_full_justify(void);
|
void do_full_justify(void);
|
||||||
|
|
39
src/text.c
39
src/text.c
|
@ -1066,15 +1066,17 @@ void backup_lines(filestruct *first_line, size_t par_len)
|
||||||
set_modified();
|
set_modified();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Find the beginning of the current paragraph if we're in one, or the
|
/* Find the beginning of the current paragraph if we're in one (not
|
||||||
* beginning of the next paragraph if we're not. Afterwards, save the
|
* going any further back than begin), or the beginning of the next
|
||||||
* quote length and paragraph length in *quote and *par. Return TRUE if
|
* paragraph if we're not. Afterwards, save the quote length and
|
||||||
* we found a paragraph, or FALSE if there was an error or we didn't
|
* paragraph length in *quote and *par. Return TRUE if we found a
|
||||||
* find a paragraph.
|
* paragraph, or FALSE if there was an error or we didn't find a
|
||||||
|
* paragraph.
|
||||||
*
|
*
|
||||||
* See the comment at begpar() for more about when a line is the
|
* See the comment at begpar() for more about when a line is the
|
||||||
* beginning of a paragraph. */
|
* beginning of a paragraph. */
|
||||||
bool find_paragraph(size_t *const quote, size_t *const par)
|
bool find_paragraph(filestruct *begin, size_t *const quote, size_t
|
||||||
|
*const par)
|
||||||
{
|
{
|
||||||
size_t quote_len;
|
size_t quote_len;
|
||||||
/* Length of the initial quotation of the paragraph we search
|
/* Length of the initial quotation of the paragraph we search
|
||||||
|
@ -1106,6 +1108,7 @@ bool find_paragraph(size_t *const quote, size_t *const par)
|
||||||
* last line of the next paragraph, if any. */
|
* last line of the next paragraph, if any. */
|
||||||
if (!inpar(openfile->current)) {
|
if (!inpar(openfile->current)) {
|
||||||
do_para_end(FALSE);
|
do_para_end(FALSE);
|
||||||
|
|
||||||
/* If we end up past the beginning of the line, it means that
|
/* If we end up past the beginning of the line, it means that
|
||||||
* we're at the end of the last line of the file, and the line
|
* we're at the end of the last line of the file, and the line
|
||||||
* isn't blank, in which case the last line of the file is the
|
* isn't blank, in which case the last line of the file is the
|
||||||
|
@ -1122,10 +1125,18 @@ bool find_paragraph(size_t *const quote, size_t *const par)
|
||||||
openfile->current = openfile->current->prev;
|
openfile->current = openfile->current->prev;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If the current line isn't the first line of the paragraph, move
|
/* If the current line isn't the first line of the paragraph, move
|
||||||
* back to the first line of the paragraph. */
|
* back to the first line of the paragraph. If we go further back
|
||||||
if (!begpar(openfile->current))
|
* than begin, move forward to begin. */
|
||||||
|
if (!begpar(openfile->current)) {
|
||||||
do_para_begin(FALSE);
|
do_para_begin(FALSE);
|
||||||
|
if (openfile->current->lineno < begin->lineno) {
|
||||||
|
openfile->current_y += begin->lineno -
|
||||||
|
openfile->current->lineno;
|
||||||
|
openfile->current = begin;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Now current is the first line of the paragraph. Set quote_len to
|
/* Now current is the first line of the paragraph. Set quote_len to
|
||||||
* the quotation length of that line, and set par_len to the number
|
* the quotation length of that line, and set par_len to the number
|
||||||
|
@ -1135,6 +1146,7 @@ bool find_paragraph(size_t *const quote, size_t *const par)
|
||||||
current_y_save = openfile->current_y;
|
current_y_save = openfile->current_y;
|
||||||
do_para_end(FALSE);
|
do_para_end(FALSE);
|
||||||
par_len = openfile->current->lineno - current_save->lineno;
|
par_len = openfile->current->lineno - current_save->lineno;
|
||||||
|
|
||||||
/* If we end up past the beginning of the line, it means that we're
|
/* If we end up past the beginning of the line, it means that we're
|
||||||
* at the end of the last line of the file, and the line isn't
|
* at the end of the last line of the file, and the line isn't
|
||||||
* blank, in which case the last line of the file is part of the
|
* blank, in which case the last line of the file is part of the
|
||||||
|
@ -1221,6 +1233,13 @@ void do_justify(bool full_justify)
|
||||||
* length (number of lines). Don't refresh the screen yet,
|
* length (number of lines). Don't refresh the screen yet,
|
||||||
* since we'll do that after we justify.
|
* since we'll do that after we justify.
|
||||||
*
|
*
|
||||||
|
* When searching for a paragraph, don't go further back than
|
||||||
|
* fileage if it's the first search, or current if it isn't.
|
||||||
|
* This ensures that we don't justify the same lines more than
|
||||||
|
* once if auto-indent is turned on, and the indentation of
|
||||||
|
* what should be the previous paragraph matches that of what
|
||||||
|
* should be the current paragraph.
|
||||||
|
*
|
||||||
* If the search failed, we do one of two things. If we're
|
* If the search failed, we do one of two things. If we're
|
||||||
* justifying the whole file, and we've found at least one
|
* justifying the whole file, and we've found at least one
|
||||||
* paragraph, it means that we should justify all the way to the
|
* paragraph, it means that we should justify all the way to the
|
||||||
|
@ -1228,7 +1247,9 @@ void do_justify(bool full_justify)
|
||||||
* justified to the last line of the file and break out of the
|
* justified to the last line of the file and break out of the
|
||||||
* loop. Otherwise, it means that there are no paragraph(s) to
|
* loop. Otherwise, it means that there are no paragraph(s) to
|
||||||
* justify, so refresh the screen and get out. */
|
* justify, so refresh the screen and get out. */
|
||||||
if (!find_paragraph("e_len, &par_len)) {
|
if (!find_paragraph((first_par_line == NULL) ?
|
||||||
|
openfile->fileage : openfile->current, "e_len,
|
||||||
|
&par_len)) {
|
||||||
if (full_justify && first_par_line != NULL) {
|
if (full_justify && first_par_line != NULL) {
|
||||||
last_par_line = openfile->filebot;
|
last_par_line = openfile->filebot;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue