remove some unneeded edit_update()s in do_para_search() and do_justify()
per DB's patch, and simplify an if statement in do_justify() git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1742 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
1d43db879e
commit
7097d7b6d2
|
@ -51,6 +51,9 @@ CVS code -
|
||||||
- Tweak for efficiency. (David Benbennick)
|
- Tweak for efficiency. (David Benbennick)
|
||||||
justify_format()
|
justify_format()
|
||||||
- Remove redundant assignment. (DLR)
|
- Remove redundant assignment. (DLR)
|
||||||
|
do_para_search(), do_justify()
|
||||||
|
- Remove unneeded edit_update() calls. (David Benbennick)
|
||||||
|
- Simplify an if statement. (DLR)
|
||||||
do_exit()
|
do_exit()
|
||||||
- Refactor so that no recursion is needed if we try to exit with
|
- Refactor so that no recursion is needed if we try to exit with
|
||||||
a modified file that has no name when TEMP_OPT is set. (DLR)
|
a modified file that has no name when TEMP_OPT is set. (DLR)
|
||||||
|
|
40
src/nano.c
40
src/nano.c
|
@ -2217,9 +2217,10 @@ int do_para_search(int search_type, size_t *quote, size_t *par, size_t
|
||||||
current_x = 0;
|
current_x = 0;
|
||||||
|
|
||||||
restart_para_search:
|
restart_para_search:
|
||||||
/* Here we find the first line of the paragraph to search. If the
|
/* Here we find the first line of the paragraph to search. If the
|
||||||
* current line is in a paragraph, then we move back to the first line.
|
* current line is in a paragraph, then we move back to the first
|
||||||
* Otherwise we move to the first line that is in a paragraph. */
|
* line. Otherwise, we move to the first line that is in a
|
||||||
|
* paragraph. */
|
||||||
quote_len = quote_length(IFREG(current->data, &qreg));
|
quote_len = quote_length(IFREG(current->data, &qreg));
|
||||||
indent_len = indent_length(current->data + quote_len);
|
indent_len = indent_length(current->data + quote_len);
|
||||||
|
|
||||||
|
@ -2240,8 +2241,7 @@ int do_para_search(int search_type, size_t *quote, size_t *par, size_t
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
&& !ISSET(AUTOINDENT)
|
&& !ISSET(AUTOINDENT)
|
||||||
#endif
|
#endif
|
||||||
) ||
|
) || !indents_match(current->prev->data + quote_len,
|
||||||
!indents_match(current->prev->data + quote_len,
|
|
||||||
temp_id_len, current->data + quote_len, indent_len))
|
temp_id_len, current->data + quote_len, indent_len))
|
||||||
break;
|
break;
|
||||||
indent_len = temp_id_len;
|
indent_len = temp_id_len;
|
||||||
|
@ -2255,12 +2255,8 @@ int do_para_search(int search_type, size_t *quote, size_t *par, size_t
|
||||||
/* There is no previous paragraph, so nothing to move to. */
|
/* There is no previous paragraph, so nothing to move to. */
|
||||||
if (current->prev == NULL) {
|
if (current->prev == NULL) {
|
||||||
placewewant = 0;
|
placewewant = 0;
|
||||||
if (do_refresh) {
|
if (do_refresh)
|
||||||
if (current_y < 0)
|
|
||||||
edit_update(current, CENTER);
|
|
||||||
else
|
|
||||||
edit_refresh();
|
edit_refresh();
|
||||||
}
|
|
||||||
#ifdef HAVE_REGEX_H
|
#ifdef HAVE_REGEX_H
|
||||||
if (!do_restart)
|
if (!do_restart)
|
||||||
regfree(&qreg);
|
regfree(&qreg);
|
||||||
|
@ -2294,10 +2290,11 @@ int do_para_search(int search_type, size_t *quote, size_t *par, size_t
|
||||||
} while (current->data[quote_len + indent_len] == '\0');
|
} while (current->data[quote_len + indent_len] == '\0');
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now current is the first line of the paragraph, and quote_len is the
|
/* Now current is the first line of the paragraph, and quote_len is
|
||||||
* quotation length of that line. */
|
* the quotation length of that line. */
|
||||||
|
|
||||||
/* Next step, compute par_len, the number of lines in this paragraph. */
|
/* Next step, compute par_len, the number of lines in this
|
||||||
|
* paragraph. */
|
||||||
line = current;
|
line = current;
|
||||||
par_len = 1;
|
par_len = 1;
|
||||||
indent_len = indent_length(line->data + quote_len);
|
indent_len = indent_length(line->data + quote_len);
|
||||||
|
@ -2359,7 +2356,7 @@ int do_para_search(int search_type, size_t *quote, size_t *par, size_t
|
||||||
regfree(&qreg);
|
regfree(&qreg);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Now par_len is the number of lines in this paragraph. We should
|
/* Now par_len is the number of lines in this paragraph. We should
|
||||||
* never call quotes_match() or quote_length() again. */
|
* never call quotes_match() or quote_length() again. */
|
||||||
|
|
||||||
/* If we're searching for the end of the paragraph, move down the
|
/* If we're searching for the end of the paragraph, move down the
|
||||||
|
@ -2370,13 +2367,8 @@ int do_para_search(int search_type, size_t *quote, size_t *par, size_t
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Refresh the screen if needed. */
|
/* Refresh the screen if needed. */
|
||||||
if (do_refresh) {
|
if (do_refresh)
|
||||||
if (((search_type == 0 || search_type == 2) && current_y >
|
|
||||||
editwinrows - 1) || (search_type == 1 && current_y < 0))
|
|
||||||
edit_update(current, CENTER);
|
|
||||||
else
|
|
||||||
edit_refresh();
|
edit_refresh();
|
||||||
}
|
|
||||||
|
|
||||||
/* Save the values of quote_len, par_len, and indent_len if
|
/* Save the values of quote_len, par_len, and indent_len if
|
||||||
* needed. */
|
* needed. */
|
||||||
|
@ -2515,10 +2507,11 @@ int do_justify(int full_justify)
|
||||||
splice_node(current, make_new_node(current), current->next);
|
splice_node(current, make_new_node(current), current->next);
|
||||||
/* In a non-quoted paragraph, we copy the indent
|
/* In a non-quoted paragraph, we copy the indent
|
||||||
* only if AUTOINDENT is turned on. */
|
* only if AUTOINDENT is turned on. */
|
||||||
if (quote_len == 0)
|
if (quote_len == 0
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
if (!ISSET(AUTOINDENT))
|
&& !ISSET(AUTOINDENT)
|
||||||
#endif
|
#endif
|
||||||
|
)
|
||||||
indent_len = 0;
|
indent_len = 0;
|
||||||
current->next->data = charalloc(indent_len + line_len -
|
current->next->data = charalloc(indent_len + line_len -
|
||||||
break_pos);
|
break_pos);
|
||||||
|
@ -2648,9 +2641,6 @@ int do_justify(int full_justify)
|
||||||
|
|
||||||
} /* while (TRUE) */
|
} /* while (TRUE) */
|
||||||
|
|
||||||
if (current_y > editwinrows - 1)
|
|
||||||
edit_update(current, CENTER);
|
|
||||||
else
|
|
||||||
edit_refresh();
|
edit_refresh();
|
||||||
|
|
||||||
statusbar(_("Can now UnJustify!"));
|
statusbar(_("Can now UnJustify!"));
|
||||||
|
|
Loading…
Reference in New Issue