From 07e199ff0eed50e33cb3696e23c22b3ee6c4bd80 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Sat, 28 Mar 2015 17:01:46 +0000 Subject: [PATCH] When searching, put a found off-screen string on the center line instead of at the bottom or top, to show it in context. git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5170 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 7 +++++++ src/global.c | 2 ++ src/proto.h | 1 + src/search.c | 2 ++ src/winio.c | 5 +---- 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index d72b718d..241e8ef7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2015-03-28 Benno Schulenberg + * src/search.c (search_init_globals, search_replace_abort), + src/winio.c (edit_redraw), src/proto.h, src/global.c: When finding + an off-screen string, put it on the center line of the screen and + not on the bottom or top line. This restores the old behaviour + that was unintentionally changed in r5149 six days ago. + 2015-03-27 Mark Majeres * src/text.c (do_alt_speller): Adjust the end point of the marked region for any change in length of the region's last line. diff --git a/src/global.c b/src/global.c index 27ff938d..a26ded46 100644 --- a/src/global.c +++ b/src/global.c @@ -42,6 +42,8 @@ bool meta_key; /* Whether the current keystroke is a Meta key. */ bool func_key; /* Whether the current keystroke is an extended keypad value. */ +bool focusing = FALSE; + /* Whether an update of the edit window should center the cursor. */ #ifndef DISABLE_WRAPJUSTIFY ssize_t fill = 0; diff --git a/src/proto.h b/src/proto.h index 9199ac04..f8c8841e 100644 --- a/src/proto.h +++ b/src/proto.h @@ -34,6 +34,7 @@ extern bool jump_buf_main; extern bool meta_key; extern bool func_key; +extern bool focusing; #ifndef DISABLE_WRAPJUSTIFY extern ssize_t fill; diff --git a/src/search.c b/src/search.c index 104f823d..a1e2bb3b 100644 --- a/src/search.c +++ b/src/search.c @@ -106,6 +106,7 @@ void not_found_msg(const char *str) void search_replace_abort(void) { display_main_list(); + focusing = FALSE; #ifndef NANO_TINY if (openfile->mark_set) edit_refresh(); @@ -118,6 +119,7 @@ void search_replace_abort(void) /* Initialize the global search and replace strings. */ void search_init_globals(void) { + focusing = TRUE; if (last_search == NULL) last_search = mallocstrcpy(NULL, ""); if (last_replace == NULL) diff --git a/src/winio.c b/src/winio.c index 3dbc1d05..a1e30212 100644 --- a/src/winio.c +++ b/src/winio.c @@ -3161,10 +3161,7 @@ void edit_redraw(filestruct *old_current, size_t pww_save) #endif /* !NANO_TINY */ /* Make sure the current line is on the screen. */ - if (ISSET(SMOOTH_SCROLL)) - edit_update(NONE); - else - edit_update(CENTER); + edit_update((ISSET(SMOOTH_SCROLL) && !focusing) ? NONE : CENTER); /* Update old_current if we're not on the same page as * before. */ -- 2.39.5