tweaks: reshuffle some lines, to elide an 'if'
parent
b20fadd604
commit
98cc39e8e5
51
src/text.c
51
src/text.c
|
@ -2003,32 +2003,6 @@ void do_justify(bool full_justify)
|
||||||
size_t second_lead_len = 0;
|
size_t second_lead_len = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef NANO_TINY
|
|
||||||
/* Do normal justification only when the mark is off. */
|
|
||||||
if (!openfile->mark)
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
/* When justifying the entire buffer, start at the top. Otherwise, when
|
|
||||||
* in a paragraph but not at its beginning, move back to its first line. */
|
|
||||||
if (full_justify)
|
|
||||||
openfile->current = openfile->filetop;
|
|
||||||
else if (inpar(openfile->current) && !begpar(openfile->current, 0))
|
|
||||||
do_para_begin(&openfile->current);
|
|
||||||
|
|
||||||
/* Find the first line of the paragraph(s) to be justified. If the
|
|
||||||
* search fails, there is nothing to justify, and we will be on the
|
|
||||||
* last line of the file, so put the cursor at the end of it. */
|
|
||||||
if (!find_paragraph(&openfile->current, &par_len)) {
|
|
||||||
openfile->current_x = strlen(openfile->filebot->data);
|
|
||||||
refresh_needed = TRUE;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Prepare to put the text we want to justify in the cutbuffer. */
|
|
||||||
cutbuffer = NULL;
|
|
||||||
cutbottom = NULL;
|
|
||||||
|
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
/* If the mark is on, do as Pico: treat all marked text as one paragraph. */
|
/* If the mark is on, do as Pico: treat all marked text as one paragraph. */
|
||||||
if (openfile->mark) {
|
if (openfile->mark) {
|
||||||
|
@ -2075,9 +2049,23 @@ void do_justify(bool full_justify)
|
||||||
size_t jus_len;
|
size_t jus_len;
|
||||||
/* The number of lines we're storing in the current cutbuffer. */
|
/* The number of lines we're storing in the current cutbuffer. */
|
||||||
|
|
||||||
/* Start out at the first line of the paragraph. */
|
/* When justifying the entire buffer, start at the top. Otherwise, when
|
||||||
|
* in a paragraph but not at its beginning, move back to its first line. */
|
||||||
|
if (full_justify)
|
||||||
|
openfile->current = openfile->filetop;
|
||||||
|
else if (inpar(openfile->current) && !begpar(openfile->current, 0))
|
||||||
|
do_para_begin(&openfile->current);
|
||||||
|
|
||||||
|
/* Find the first line of the paragraph(s) to be justified. If the
|
||||||
|
* search fails, there is nothing to justify, and we will be on the
|
||||||
|
* last line of the file, so put the cursor at the end of it. */
|
||||||
|
if (!find_paragraph(&openfile->current, &par_len)) {
|
||||||
|
openfile->current_x = strlen(openfile->filebot->data);
|
||||||
|
refresh_needed = TRUE;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
first_par_line = openfile->current;
|
first_par_line = openfile->current;
|
||||||
last_par_line = openfile->current;
|
|
||||||
top_x = 0;
|
top_x = 0;
|
||||||
|
|
||||||
/* Set the number of lines to be pulled into the cutbuffer. */
|
/* Set the number of lines to be pulled into the cutbuffer. */
|
||||||
|
@ -2087,7 +2075,7 @@ void do_justify(bool full_justify)
|
||||||
jus_len = par_len;
|
jus_len = par_len;
|
||||||
|
|
||||||
/* Move down to the last line to be extracted. */
|
/* Move down to the last line to be extracted. */
|
||||||
for (; jus_len > 1; jus_len--)
|
for (last_par_line = openfile->current; jus_len > 1; jus_len--)
|
||||||
last_par_line = last_par_line->next;
|
last_par_line = last_par_line->next;
|
||||||
|
|
||||||
/* When possible, step one line further; otherwise, to line's end. */
|
/* When possible, step one line further; otherwise, to line's end. */
|
||||||
|
@ -2108,7 +2096,10 @@ void do_justify(bool full_justify)
|
||||||
|
|
||||||
add_undo(CUT);
|
add_undo(CUT);
|
||||||
#endif
|
#endif
|
||||||
/* Do the equivalent of a marked cut. */
|
|
||||||
|
/* Do the equivalent of a marked cut into an empty cutbuffer. */
|
||||||
|
cutbuffer = NULL;
|
||||||
|
cutbottom = NULL;
|
||||||
extract_buffer(&cutbuffer, &cutbottom, first_par_line, top_x,
|
extract_buffer(&cutbuffer, &cutbottom, first_par_line, top_x,
|
||||||
last_par_line, bot_x);
|
last_par_line, bot_x);
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
|
|
Loading…
Reference in New Issue