Re: find in viewer



Hello,

On Thu, 18 May 2006, Oswald Buddenhagen wrote:

On Thu, May 18, 2006 at 05:42:45PM +0300, Pavel Tsekov wrote:
I guess in the long term the last seach string should be remembered
onto persistent storage as for example the file positions.

yes.

How about the following patch ? This is not a final version - I am just posting it to see whether you like the idea. The patch uses the input
field's ability to automatically retrieve the last entered text from
the history. The last search expression would be loaded in the input
field even after you've exited MC and then launch it again - this differs
from the old behaviour where the search expression would be lost on MC
exit.
Index: src/view.c
===================================================================
RCS file: /cvsroot/mc/mc/src/view.c,v
retrieving revision 1.355
diff -u -p -r1.355 view.c
--- src/view.c	3 Feb 2006 14:33:19 -0000	1.355
+++ src/view.c	23 May 2006 12:33:24 -0000
@@ -2791,7 +2791,7 @@ view_regexp_search_cmd (WView *view)
 static void
 view_normal_search_cmd (WView *view)
 {
-    char *defval, *exp = NULL;
+    char *exp = NULL;
 
     enum {
 	SEARCH_DLG_HEIGHT = 8,
@@ -2810,8 +2810,8 @@ view_normal_search_cmd (WView *view)
 	{quick_checkbox, 3, SEARCH_DLG_WIDTH, 4, SEARCH_DLG_HEIGHT,
 	 N_("&Backwards"), 0, 0,
 	 0, 0, NULL},
-	{quick_input, 3, SEARCH_DLG_WIDTH, 3, SEARCH_DLG_HEIGHT, "", 52, 0,
-	 0, 0, N_("Search")},
+	{quick_input, 3, SEARCH_DLG_WIDTH, 3, SEARCH_DLG_HEIGHT, INPUT_LAST_TEXT,
+	 52, 0, 0, 0, N_("Search")},
 	{quick_label, 2, SEARCH_DLG_WIDTH, 2, SEARCH_DLG_HEIGHT,
 	 N_(" Enter search string:"), 0, 0,
 	 0, 0, 0},
@@ -2822,12 +2822,8 @@ view_normal_search_cmd (WView *view)
 	"[Input Line Keys]", quick_widgets, 0
     };
 
-    defval = g_strdup ((view->search_exp != NULL) ? view->search_exp : "");
-    convert_to_display (defval);
-
     quick_widgets[2].result = &treplace_backwards;
     quick_widgets[3].str_result = &exp;
-    quick_widgets[3].text = defval;
 
     if (quick_dialog (&Quick_input) == B_CANCEL)
 	goto cleanup;
@@ -2839,17 +2835,15 @@ view_normal_search_cmd (WView *view)
 
     convert_from_input (exp);
 
-    g_free (view->search_exp);
     view->search_exp = exp;
-    exp = NULL;
 
     view->direction = replace_backwards ? -1 : 1;
     do_normal_search (view);
     view->last_search = do_normal_search;
+    view->search_exp = NULL;
 
 cleanup:
     g_free (exp);
-    g_free (defval);
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]