code cleanup for file quicksearch backspace

Egmont Koblinger egmont at uhulinux.hu
Thu Nov 11 17:29:46 UTC 2004


Hi,

When in file quicksearch mode (^S or Alt-S) and the search string is empty,
and I press backspace, then the ascii code of the backspace is put into the
search buffer, just as if I pressed a regular letter, and then (since no
filenames begin with backspace, at least on my system :-)) this will be
removed some lines later in the code.

The attached patch (against current cvs) fixes backspace in this case to do
nothing.

The patch doesn't change the behavior of mc (except if a filename really
begins with a backspace) but it cleans up the code and makes it easier to
port this code to understand UTF-8.


bye,

-- 
Egmont
-------------- next part --------------
diff -Naur mc.orig/src/screen.c mc/src/screen.c
--- mc.orig/src/screen.c	2004-11-03 21:31:59.000000000 +0100
+++ mc/src/screen.c	2004-11-11 18:23:38.544719201 +0100
@@ -1867,9 +1867,10 @@
     int found;
 
     l = strlen (panel->search_buffer);
-    if (l && (c_code == KEY_BACKSPACE))
-	panel->search_buffer[--l] = 0;
-    else {
+    if (c_code == KEY_BACKSPACE) {
+	if (l)
+	    panel->search_buffer[--l] = 0;
+    } else {
 	if (c_code && l < sizeof (panel->search_buffer)) {
 	    panel->search_buffer[l] = c_code;
 	    panel->search_buffer[l + 1] = 0;


More information about the mc-devel mailing list