add my display tweak to do_replace(), my efficiency tweaks to

do_gotoline(), and DB's efficiency tweaks to do_gotopos()


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1875 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
David Lawrence Ramsey 2004-07-30 20:21:34 +00:00
parent 9ef3adbc1d
commit 906257932f
3 changed files with 33 additions and 17 deletions

View File

@ -144,6 +144,16 @@ CVS code -
placewewant when a new match is found, so that edit_redraw()
will redraw the screen properly when only placewewant changes.
(DLR, found by Mike Frysinger)
do_replace()
- Instead of using edit_update() to redraw the screen with
edittop at the top, set edittop beforehand and call
edit_refresh(). (DLR)
do_gotoline()
- Use parse_num() to interpret a line entered by the user, and
start the search for a line from current instead of fileage.
(DLR)
do_gotopos()
- Tweak for efficiency. (David Benbennick)
- utils.c:
parse_num()
- New function to parse numeric values, so that we don't have to

View File

@ -402,7 +402,7 @@ char *replace_line(const char *needle);
int do_replace_loop(const char *needle, const filestruct *real_current,
size_t *real_current_x, int wholewords);
void do_replace(void);
void do_gotoline(ssize_t line, int save_pos);
void do_gotoline(int line, int save_pos);
void do_gotoline_void(void);
#if defined (ENABLE_MULTIBUFFER) || !defined (DISABLE_SPELLER)
void do_gotopos(int line, int pos_x, int pos_y, size_t pos_pww);

View File

@ -822,10 +822,11 @@ void do_replace(void)
numreplaced = do_replace_loop(last_search, begin, &beginx, FALSE);
/* Restore where we were. */
edittop = edittop_save;
current = begin;
current_x = beginx;
renumber_all();
edit_update(edittop_save, TOP);
edit_refresh();
if (numreplaced >= 0)
statusbar(P_("Replaced %d occurrence", "Replaced %d occurrences",
@ -834,11 +835,11 @@ void do_replace(void)
replace_abort();
}
void do_gotoline(ssize_t line, int save_pos)
void do_gotoline(int line, int save_pos)
{
if (line <= 0) { /* Ask for it */
if (line <= 0) { /* Ask for it. */
char *ans = mallocstrcpy(NULL, answer);
int st = statusq(FALSE, goto_list, line != 0 ? ans : "",
int st = statusq(FALSE, goto_list, line < 0 ? ans : "",
#ifndef NANO_SMALL
NULL,
#endif
@ -854,18 +855,23 @@ void do_gotoline(ssize_t line, int save_pos)
return;
}
line = (ssize_t)atol(answer);
/* Bounds check. */
if (line <= 0) {
if (parse_num(answer, &line) == -1 || line < 0) {
statusbar(_("Come on, be reasonable"));
display_main_list();
return;
}
}
for (current = fileage; current->next != NULL && line > 1; line--)
current = current->next;
if (current->lineno > line) {
for (; current->prev != NULL && current->lineno > line;
current = current->prev)
;
} else {
for (; current->next != NULL && current->lineno < line;
current = current->next)
;
}
current_x = 0;
@ -885,17 +891,17 @@ void do_gotoline_void(void)
#if defined(ENABLE_MULTIBUFFER) || !defined(DISABLE_SPELLER)
void do_gotopos(int line, int pos_x, int pos_y, size_t pos_pww)
{
/* since do_gotoline() resets the x-coordinate but not the
y-coordinate, set the coordinates up this way */
/* Since do_gotoline() resets the x-coordinate but not the
* y-coordinate, set the coordinates up this way. */
current_y = pos_y;
do_gotoline(line, TRUE);
/* make sure that the x-coordinate is sane here */
if (pos_x > strlen(current->data))
pos_x = strlen(current->data);
/* set the rest of the coordinates up */
/* Make sure that the x-coordinate is sane here. */
current_x = strlen(current->data);
if (pos_x < current_x)
current_x = pos_x;
/* Set the rest of the coordinates up. */
placewewant = pos_pww;
update_line(current, pos_x);
}