Ticket #2365: previous_seach.patch

File previous_seach.patch, 1.5 KB (added by E.L.K., 11 years ago)

previous search patch

  • src/panel.h

    diff --git a/src/panel.h b/src/panel.h
    index 65bde53..cf2cac2 100644
    a b typedef struct WPanel { 
    9696    struct   stat dir_stat;     /* Stat of current dir: used by execute () */ 
    9797 
    9898    gboolean searching; 
     99    char     previous_search_buffer [256]; 
    99100    char     search_buffer [256]; 
    100101    char     search_char [MB_LEN_MAX]; /*buffer for multibytes characters*/ 
    101102    int      search_chpoint;           /*point after last characters in search_char*/ 
  • src/screen.c

    diff --git a/src/screen.c b/src/screen.c
    index 1425796..43bdedb 100644
    a b start_search (WPanel * panel) 
    24712471            panel->selected = 0; 
    24722472        else 
    24732473            move_down (panel); 
     2474 
     2475        gboolean recall_search_string = panel->search_buffer[0] == '\0'; 
     2476 
     2477        if (recall_search_string) 
     2478        { 
     2479           /* in case if there was no search string we need to recall 
     2480              previous string, with which we ended previous searching */ 
     2481           strncpy(panel->search_buffer, panel->previous_search_buffer, 256); 
     2482        } 
     2483         
    24742484        do_search (panel, 0); 
    24752485    } 
    24762486    else 
    static void 
    24882498stop_search (WPanel * panel) 
    24892499{ 
    24902500    panel->searching = FALSE; 
     2501 
     2502    gboolean had_search_string = panel->search_buffer[0] != '\0'; 
     2503 
     2504    /* if user had overrdied search string, we need to store it to the 
     2505       previous_search_buffer */ 
     2506    if (had_search_string) { 
     2507       strncpy(panel->previous_search_buffer, panel->search_buffer, 256); 
     2508    }  
     2509     
    24912510    display_mini_info (panel); 
    24922511} 
    24932512