tweaks: condense and improve a couple of comments

master
Benno Schulenberg 2018-11-26 09:25:32 +01:00
parent e2c61d83ef
commit 0d96df7a91
1 changed files with 8 additions and 13 deletions

View File

@ -2225,11 +2225,9 @@ void do_justify(bool full_justify)
else if (inpar(openfile->current) && !begpar(openfile->current, 0)) else if (inpar(openfile->current) && !begpar(openfile->current, 0))
do_para_begin(&openfile->current); do_para_begin(&openfile->current);
/* Find the first line of the paragraph(s) to be justified. /* Find the first line of the paragraph(s) to be justified. If the
* If the search failed, it means that there are no paragraph(s) to * search fails, there is nothing to justify, and we will be on the
* justify. The search put us on the last line of the file, so * last line of the file, so put the cursor at the end of it. */
* put the cursor at the end of it. Then
* refresh the screen and get out. */
if (!find_paragraph(&openfile->current, &filebot_inpar, &quote_len, if (!find_paragraph(&openfile->current, &filebot_inpar, &quote_len,
&par_len)) { &par_len)) {
openfile->current_x = strlen(openfile->filebot->data); openfile->current_x = strlen(openfile->filebot->data);
@ -2244,14 +2242,11 @@ void do_justify(bool full_justify)
cutbuffer = NULL; cutbuffer = NULL;
cutbottom = NULL; cutbottom = NULL;
/* Set /* Start out at the first line of the paragraph. */
* first_par_line and last_par_line to the first line of the paragraph. */
first_par_line = openfile->current; first_par_line = openfile->current;
last_par_line = openfile->current; last_par_line = openfile->current;
/* If we're justifying the entire file, move last_par_line down to the /* Set the number of lines to be pulled into the cutbuffer. */
* last line of the file (counting the text at filebot). Otherwise, move
* last_par_line down to the last line of the paragraph. */
if (full_justify) { if (full_justify) {
text_on_last_line = (openfile->filebot->data[0] != '\0'); text_on_last_line = (openfile->filebot->data[0] != '\0');
jus_len = openfile->filebot->lineno - first_par_line->lineno + jus_len = openfile->filebot->lineno - first_par_line->lineno +
@ -2259,6 +2254,7 @@ void do_justify(bool full_justify)
} else } else
jus_len = par_len; jus_len = par_len;
/* Move down to just beyond the last line to be extracted. */
while (jus_len > 0 && last_par_line->next != NULL) { while (jus_len > 0 && last_par_line->next != NULL) {
last_par_line = last_par_line->next; last_par_line = last_par_line->next;
jus_len--; jus_len--;
@ -2287,8 +2283,7 @@ void do_justify(bool full_justify)
/* Justify the current paragraph. */ /* Justify the current paragraph. */
justify_paragraph(&jusline, quote_len, par_len); justify_paragraph(&jusline, quote_len, par_len);
/* If we're justifying the entire file, search for and justify paragraphs /* When justifying the entire buffer, find and justify all paragraphs. */
* until we can't anymore. */
if (full_justify) { if (full_justify) {
while (!filebot_inpar && while (!filebot_inpar &&
find_paragraph(&jusline, &filebot_inpar, &quote_len, &par_len)) find_paragraph(&jusline, &filebot_inpar, &quote_len, &par_len))
@ -2298,7 +2293,7 @@ void do_justify(bool full_justify)
#ifndef NANO_TINY #ifndef NANO_TINY
add_undo(PASTE); add_undo(PASTE);
#endif #endif
/* Do (the equivalent of) a paste of the justified text. */ /* Do the equivalent of a paste of the justified text. */
ingraft_buffer(cutbuffer); ingraft_buffer(cutbuffer);
#ifndef NANO_TINY #ifndef NANO_TINY
update_undo(PASTE); update_undo(PASTE);