From 3f882ce5a673f5716269777d9f119021b81a93e6 Mon Sep 17 00:00:00 2001
From: ierton <ierton@vault.homelinux.net>
Date: Sat, 12 Sep 2009 19:04:22 +0400
Subject: [PATCH] Added keycode checking in quicksearch mode. This
checking prevents execution of single-char
keybind handlers (allows user to type letters).
---
src/screen.c | 44 +++++++++++++++++++++++---------------------
1 files changed, 23 insertions(+), 21 deletions(-)
diff --git a/src/screen.c b/src/screen.c
index 4dd246a..c3a3c4f 100644
a
|
b
|
screen_execute_cmd (WPanel *panel, int command, int key) |
2431 | 2431 | } |
2432 | 2432 | } |
2433 | 2433 | |
| 2434 | /* Keys, that should be redirected to active search engine, if any */ |
| 2435 | #define SEARCHKEY(key) ((( key ) >= ' ' && ( key ) <= 255) || ( key ) == KEY_BACKSPACE) |
| 2436 | |
2434 | 2437 | static cb_ret_t |
2435 | 2438 | panel_key (WPanel *panel, int key) |
2436 | 2439 | { |
2437 | 2440 | int i; |
2438 | 2441 | |
2439 | | for (i = 0; panel_map[i].key; i++) { |
2440 | | if (key == panel_map[i].key) { |
2441 | | int old_searching = panel->searching; |
2442 | | |
2443 | | if (panel_map[i].command != CK_PanelStartSearch) |
2444 | | panel->searching = 0; |
| 2442 | if(!panel->searching || (panel->searching && !SEARCHKEY(key))) { |
| 2443 | for (i = 0; panel_map[i].key; i++) { |
| 2444 | if (key == panel_map[i].key) { |
| 2445 | int old_searching = panel->searching; |
2445 | 2446 | |
2446 | | screen_execute_cmd (panel, panel_map[i].command, key); |
| 2447 | screen_execute_cmd (panel, panel_map[i].command, key); |
2447 | 2448 | |
2448 | | if (panel->searching != old_searching) |
2449 | | display_mini_info (panel); |
2450 | | return MSG_HANDLED; |
| 2449 | if (panel->searching != old_searching) |
| 2450 | display_mini_info (panel); |
| 2451 | return MSG_HANDLED; |
| 2452 | } |
| 2453 | } |
2451 | 2454 | } |
2452 | | } |
2453 | 2455 | |
2454 | 2456 | if (torben_fj_mode && key == ALT ('h')) { |
2455 | 2457 | goto_middle_file (panel); |
… |
… |
panel_key (WPanel *panel, int key) |
2472 | 2474 | } |
2473 | 2475 | |
2474 | 2476 | /* Do not eat characters not meant for the panel below ' ' (e.g. C-l). */ |
2475 | | if ((key >= ' ' && key <= 255) || key == KEY_BACKSPACE) { |
2476 | | if (panel->searching) { |
2477 | | do_search (panel, key); |
2478 | | return MSG_HANDLED; |
2479 | | } |
| 2477 | if (SEARCHKEY(key)) { |
| 2478 | if (panel->searching) { |
| 2479 | do_search (panel, key); |
| 2480 | return MSG_HANDLED; |
| 2481 | } |
2480 | 2482 | |
2481 | | if (!command_prompt) { |
2482 | | start_search (panel); |
2483 | | do_search (panel, key); |
2484 | | return MSG_HANDLED; |
| 2483 | if (!command_prompt) { |
| 2484 | start_search (panel); |
| 2485 | do_search (panel, key); |
| 2486 | return MSG_HANDLED; |
| 2487 | } |
2485 | 2488 | } |
2486 | | } |
2487 | 2489 | |
2488 | 2490 | return MSG_NOT_HANDLED; |
2489 | 2491 | } |