Ticket #3530: mc-3530-v1.patch

File mc-3530-v1.patch, 35.4 KB (added by egmont, 5 years ago)

Fix

  • lib/widget/dialog-switch.c

    diff --git a/lib/widget/dialog-switch.c b/lib/widget/dialog-switch.c
    index f008674..a3732bb 100644
    a b dialog_switch_list (void) 
    250250        else 
    251251            title = g_strdup (""); 
    252252 
    253         listbox_add_item (listbox->list, LISTBOX_APPEND_BEFORE, get_hotkey (i++), title, NULL); 
     253        listbox_add_item (listbox->list, LISTBOX_APPEND_BEFORE, get_hotkey (i++), title, NULL, 
     254                          FALSE); 
    254255 
    255256        g_free (title); 
    256257    } 
  • lib/widget/input_complete.c

    diff --git a/lib/widget/input_complete.c b/lib/widget/input_complete.c
    index 0de9618..200d414 100644
    a b complete_engine (WInput * in, int what_to_do) 
    12511251            query_list = listbox_new (1, 1, h - 2, w - 2, FALSE, NULL); 
    12521252            add_widget (query_dlg, query_list); 
    12531253            for (p = in->completions + 1; *p; p++) 
    1254                 listbox_add_item (query_list, LISTBOX_APPEND_AT_END, 0, *p, NULL); 
     1254                listbox_add_item (query_list, LISTBOX_APPEND_AT_END, 0, *p, NULL, FALSE); 
    12551255            dlg_run (query_dlg); 
    12561256            q = NULL; 
    12571257            if (query_dlg->ret_value == B_ENTER) 
  • lib/widget/listbox-window.h

    diff --git a/lib/widget/listbox-window.h b/lib/widget/listbox-window.h
    index a96cd59..b4c3f28 100644
    a b  
    77 
    88/*** typedefs(not structures) and defined constants **********************************************/ 
    99 
    10 #define LISTBOX_APPEND_TEXT(l,h,t,d) \ 
    11     listbox_add_item (l->list, LISTBOX_APPEND_AT_END, h, t, d) 
     10#define LISTBOX_APPEND_TEXT(l,h,t,d,f) \ 
     11    listbox_add_item (l->list, LISTBOX_APPEND_AT_END, h, t, d, f) 
    1212 
    1313/*** enums ***************************************************************************************/ 
    1414 
  • lib/widget/listbox.c

    diff --git a/lib/widget/listbox.c b/lib/widget/listbox.c
    index fd97b76..d7fbb4c 100644
    a b listbox_entry_free (void *data) 
    7676{ 
    7777    WLEntry *e = data; 
    7878    g_free (e->text); 
     79    if (e->free_data) 
     80        g_free (e->data); 
    7981    g_free (e); 
    8082} 
    8183 
    listbox_remove_list (WListbox * l) 
    770772/* --------------------------------------------------------------------------------------------- */ 
    771773 
    772774char * 
    773 listbox_add_item (WListbox * l, listbox_append_t pos, int hotkey, const char *text, void *data) 
     775listbox_add_item (WListbox * l, listbox_append_t pos, int hotkey, const char *text, void *data, 
     776                  gboolean free_data) 
    774777{ 
    775778    WLEntry *entry; 
    776779 
    listbox_add_item (WListbox * l, listbox_append_t pos, int hotkey, const char *te 
    783786    entry = g_new (WLEntry, 1); 
    784787    entry->text = g_strdup (text); 
    785788    entry->data = data; 
     789    entry->free_data = free_data; 
    786790    entry->hotkey = hotkey; 
    787791 
    788792    listbox_append_item (l, entry, pos); 
  • lib/widget/listbox.h

    diff --git a/lib/widget/listbox.h b/lib/widget/listbox.h
    index f8f2491..62d5e15 100644
    a b typedef struct WLEntry 
    4040    char *text;                 /* Text to display */ 
    4141    int hotkey; 
    4242    void *data;                 /* Client information */ 
     43    gboolean free_data;         /* Whether to free the data on entry's removal */ 
    4344} WLEntry; 
    4445 
    4546typedef struct WListbox 
    gboolean listbox_is_empty (const WListbox * l); 
    7475void listbox_set_list (WListbox * l, GList * list); 
    7576void listbox_remove_list (WListbox * l); 
    7677char *listbox_add_item (WListbox * l, listbox_append_t pos, 
    77                         int hotkey, const char *text, void *data); 
     78                        int hotkey, const char *text, void *data, gboolean free_data); 
    7879 
    7980/*** inline functions ****************************************************************************/ 
    8081 
  • src/editor/choosesyntax.c

    diff --git a/src/editor/choosesyntax.c b/src/editor/choosesyntax.c
    index af62818..129d77f 100644
    a b exec_edit_syntax_dialog (const GPtrArray * names, const char *current_syntax) 
    7474 
    7575    syntaxlist = create_listbox_window (LIST_LINES, MAX_ENTRY_LEN, 
    7676                                        _("Choose syntax highlighting"), NULL); 
    77     LISTBOX_APPEND_TEXT (syntaxlist, 'A', _("< Auto >"), NULL); 
    78     LISTBOX_APPEND_TEXT (syntaxlist, 'R', _("< Reload Current Syntax >"), NULL); 
     77    LISTBOX_APPEND_TEXT (syntaxlist, 'A', _("< Auto >"), NULL, FALSE); 
     78    LISTBOX_APPEND_TEXT (syntaxlist, 'R', _("< Reload Current Syntax >"), NULL, FALSE); 
    7979 
    8080    for (i = 0; i < names->len; i++) 
    8181    { 
    8282        const char *name; 
    8383 
    8484        name = g_ptr_array_index (names, i); 
    85         LISTBOX_APPEND_TEXT (syntaxlist, 0, name, NULL); 
     85        LISTBOX_APPEND_TEXT (syntaxlist, 0, name, NULL, FALSE); 
    8686        if (current_syntax != NULL && strcmp (name, current_syntax) == 0) 
    8787            listbox_select_entry (syntaxlist->list, i + N_DFLT_ENTRIES); 
    8888    } 
  • src/editor/editcmd_dialogs.c

    diff --git a/src/editor/editcmd_dialogs.c b/src/editor/editcmd_dialogs.c
    index 3a9883a..079407e 100644
    a b editcmd_dialog_completion_show (const WEdit * edit, int max_len, GString ** comp 
    390390 
    391391    /* fill the listbox with the completions */ 
    392392    for (i = num_compl - 1; i >= 0; i--)        /* reverse order */ 
    393         listbox_add_item (compl_list, LISTBOX_APPEND_AT_END, 0, (char *) compl[i]->str, NULL); 
     393        listbox_add_item (compl_list, LISTBOX_APPEND_AT_END, 0, (char *) compl[i]->str, NULL, 
     394                          FALSE); 
    394395 
    395396    /* pop up the dialog and apply the chosen completion */ 
    396397    if (dlg_run (compl_dlg) == B_ENTER) 
    editcmd_dialog_select_definition_show (WEdit * edit, char *match_expr, int max_l 
    461462        label_def = 
    462463            g_strdup_printf ("%s -> %s:%ld", def_hash[i].short_define, def_hash[i].filename, 
    463464                             def_hash[i].line); 
    464         listbox_add_item (def_list, LISTBOX_APPEND_AT_END, 0, label_def, &def_hash[i]); 
     465        listbox_add_item (def_list, LISTBOX_APPEND_AT_END, 0, label_def, &def_hash[i], FALSE); 
    465466        g_free (label_def); 
    466467    } 
    467468 
  • src/editor/editwidget.c

    diff --git a/src/editor/editwidget.c b/src/editor/editwidget.c
    index 40f60ba..eb2e812 100644
    a b edit_window_list (const WDialog * h) 
    342342                                     vfs_path_as_str (e->filename_vpath)); 
    343343 
    344344            listbox_add_item (listbox->list, LISTBOX_APPEND_AT_END, get_hotkey (i++), 
    345                               str_term_trim (fname, WIDGET (listbox->list)->cols - 2), NULL); 
     345                              str_term_trim (fname, WIDGET (listbox->list)->cols - 2), NULL, FALSE); 
    346346            g_free (fname); 
    347347        } 
    348348 
  • src/editor/spell_dialogs.c

    diff --git a/src/editor/spell_dialogs.c b/src/editor/spell_dialogs.c
    index 012dce6..9e1e53d 100644
    a b spell_dialog_spell_suggest_show (WEdit * edit, const char *word, char **new_word 
    120120    sug_list = listbox_new (5, 2, sug_dlg_h - 7, 24, FALSE, NULL); 
    121121    for (i = 0; i < suggest->len; i++) 
    122122        listbox_add_item (sug_list, LISTBOX_APPEND_AT_END, 0, g_array_index (suggest, char *, i), 
    123                           NULL); 
     123                          NULL, FALSE); 
    124124    add_widget (sug_dlg, sug_list); 
    125125 
    126126    add_widget (sug_dlg, add_btn); 
    spell_dialog_lang_list_show (GArray * languages) 
    170170                                                _("Select language"), "[ASpell]"); 
    171171 
    172172    for (i = 0; i < languages->len; i++) 
    173         LISTBOX_APPEND_TEXT (lang_list, 0, g_array_index (languages, char *, i), NULL); 
     173        LISTBOX_APPEND_TEXT (lang_list, 0, g_array_index (languages, char *, i), NULL, FALSE); 
    174174 
    175175    res = run_listbox (lang_list); 
    176176    if (res >= 0) 
  • src/filemanager/achown.c

    diff --git a/src/filemanager/achown.c b/src/filemanager/achown.c
    index f14f15c..146a172 100644
    a b do_enter_key (WDialog * h, int f_pos) 
    343343 
    344344        /* get new listboxes */ 
    345345        chl_list = listbox_new (1, 1, 11, 15, FALSE, NULL); 
    346         listbox_add_item (chl_list, LISTBOX_APPEND_AT_END, 0, "<Unknown>", NULL); 
     346        listbox_add_item (chl_list, LISTBOX_APPEND_AT_END, 0, "<Unknown>", NULL, FALSE); 
    347347        if (is_owner) 
    348348        { 
    349349            /* get and put user names in the listbox */ 
    350350            setpwent (); 
    351351            while ((chl_pass = getpwent ()) != NULL) 
    352                 listbox_add_item (chl_list, LISTBOX_APPEND_SORTED, 0, chl_pass->pw_name, NULL); 
     352                listbox_add_item (chl_list, LISTBOX_APPEND_SORTED, 0, chl_pass->pw_name, NULL, 
     353                                  FALSE); 
    353354            endpwent (); 
    354355            fe = listbox_search_text (chl_list, get_owner (sf_stat->st_uid)); 
    355356        } 
    do_enter_key (WDialog * h, int f_pos) 
    358359            /* get and put group names in the listbox */ 
    359360            setgrent (); 
    360361            while ((chl_grp = getgrent ()) != NULL) 
    361                 listbox_add_item (chl_list, LISTBOX_APPEND_SORTED, 0, chl_grp->gr_name, NULL); 
     362                listbox_add_item (chl_list, LISTBOX_APPEND_SORTED, 0, chl_grp->gr_name, NULL, 
     363                                  FALSE); 
    362364            endgrent (); 
    363365            fe = listbox_search_text (chl_list, get_group (sf_stat->st_gid)); 
    364366        } 
  • src/filemanager/boxes.c

    diff --git a/src/filemanager/boxes.c b/src/filemanager/boxes.c
    index 82a93ee..875eb1b 100644
    a b sel_skin_button (WButton * button, int action) 
    205205    skin_list = listbox_new (1, 1, 11, 22, FALSE, NULL); 
    206206    skin_name = "default"; 
    207207    listbox_add_item (skin_list, LISTBOX_APPEND_AT_END, 0, skin_name_to_label (skin_name), 
    208                       (void *) skin_name); 
     208                      (void *) skin_name, FALSE); 
    209209 
    210210    if (strcmp (skin_name, current_skin_name) == 0) 
    211211        listbox_select_entry (skin_list, 0); 
    sel_skin_button (WButton * button, int action) 
    216216        if (strcmp (skin_name, "default") != 0) 
    217217        { 
    218218            listbox_add_item (skin_list, LISTBOX_APPEND_AT_END, 0, skin_name_to_label (skin_name), 
    219                               (void *) skin_name); 
     219                              (void *) skin_name, FALSE); 
    220220            if (strcmp (skin_name, current_skin_name) == 0) 
    221221                listbox_select_entry (skin_list, pos); 
    222222            pos++; 
    jobs_fill_listbox (WListbox * list) 
    467467        char *s; 
    468468 
    469469        s = g_strconcat (state_str[tl->state], " ", tl->info, (char *) NULL); 
    470         listbox_add_item (list, LISTBOX_APPEND_AT_END, 0, s, (void *) tl); 
     470        listbox_add_item (list, LISTBOX_APPEND_AT_END, 0, s, (void *) tl, FALSE); 
    471471        g_free (s); 
    472472    } 
    473473} 
  • src/filemanager/chown.c

    diff --git a/src/filemanager/chown.c b/src/filemanager/chown.c
    index 41d800a..263efe9 100644
    a b init_chown (void) 
    218218    l_user = listbox_new (3, 4, GH - 2, GW - 2, FALSE, NULL); 
    219219    add_widget (ch_dlg, l_user); 
    220220    /* add field for unknown names (numbers) */ 
    221     listbox_add_item (l_user, LISTBOX_APPEND_AT_END, 0, _("<Unknown user>"), NULL); 
     221    listbox_add_item (l_user, LISTBOX_APPEND_AT_END, 0, _("<Unknown user>"), NULL, FALSE); 
    222222    /* get and put user names in the listbox */ 
    223223    setpwent (); 
    224224    while ((l_pass = getpwent ()) != NULL) 
    225         listbox_add_item (l_user, LISTBOX_APPEND_SORTED, 0, l_pass->pw_name, NULL); 
     225        listbox_add_item (l_user, LISTBOX_APPEND_SORTED, 0, l_pass->pw_name, NULL, FALSE); 
    226226    endpwent (); 
    227227 
    228228    add_widget (ch_dlg, groupbox_new (2, 4 + GW, GH, GW, _("Group name"))); 
    229229    l_group = listbox_new (3, 5 + GW, GH - 2, GW - 2, FALSE, NULL); 
    230230    add_widget (ch_dlg, l_group); 
    231231    /* add field for unknown names (numbers) */ 
    232     listbox_add_item (l_group, LISTBOX_APPEND_AT_END, 0, _("<Unknown group>"), NULL); 
     232    listbox_add_item (l_group, LISTBOX_APPEND_AT_END, 0, _("<Unknown group>"), NULL, FALSE); 
    233233    /* get and put group names in the listbox */ 
    234234    setgrent (); 
    235235    while ((l_grp = getgrent ()) != NULL) 
    236         listbox_add_item (l_group, LISTBOX_APPEND_SORTED, 0, l_grp->gr_name, NULL); 
     236        listbox_add_item (l_group, LISTBOX_APPEND_SORTED, 0, l_grp->gr_name, NULL, FALSE); 
    237237    endgrent (); 
    238238 
    239239    add_widget (ch_dlg, groupbox_new (2, 5 + GW * 2, GH, GW, _("File"))); 
  • src/filemanager/cmd.c

    diff --git a/src/filemanager/cmd.c b/src/filemanager/cmd.c
    index 557964e..fabafc1 100644
    a b set_basic_panel_listing_to (int panel_index, int listing_mode) 
    541541 
    542542gboolean 
    543543view_file_at_line (const vfs_path_t * filename_vpath, gboolean plain_view, gboolean internal, 
    544                    long start_line) 
     544                   long start_line, off_t search_start, off_t search_end) 
    545545{ 
    546546    gboolean ret = TRUE; 
    547547 
    view_file_at_line (const vfs_path_t * filename_vpath, gboolean plain_view, gbool 
    564564        mcview_default_nroff_flag = 0; 
    565565        mcview_default_magic_flag = 0; 
    566566 
    567         ret = mcview_viewer (NULL, filename_vpath, start_line); 
     567        ret = mcview_viewer (NULL, filename_vpath, start_line, search_start, search_end); 
    568568 
    569569        if (changed_hex_mode && !mcview_altered_hex_mode) 
    570570            mcview_default_hex_mode = 1; 
    view_file_at_line (const vfs_path_t * filename_vpath, gboolean plain_view, gbool 
    587587        ret = (regex_command (filename_vpath, view_entry) == 0); 
    588588        if (ret) 
    589589        { 
    590             ret = mcview_viewer (NULL, filename_vpath, start_line); 
     590            ret = mcview_viewer (NULL, filename_vpath, start_line, search_start, search_end); 
    591591            dialog_switch_process_pending (); 
    592592        } 
    593593    } 
    view_file_at_line (const vfs_path_t * filename_vpath, gboolean plain_view, gbool 
    623623gboolean 
    624624view_file (const vfs_path_t * filename_vpath, gboolean plain_view, gboolean internal) 
    625625{ 
    626     return view_file_at_line (filename_vpath, plain_view, internal, 0); 
     626    return view_file_at_line (filename_vpath, plain_view, internal, 0, 0, 0); 
    627627} 
    628628 
    629629 
    view_filtered_cmd (void) 
    687687 
    688688    if (command != NULL) 
    689689    { 
    690         mcview_viewer (command, NULL, 0); 
     690        mcview_viewer (command, NULL, 0, 0, 0); 
    691691        g_free (command); 
    692692        dialog_switch_process_pending (); 
    693693    } 
  • src/filemanager/cmd.h

    diff --git a/src/filemanager/cmd.h b/src/filemanager/cmd.h
    index 892f1ce..cc57e49 100644
    a b void smart_dirsize_cmd (void); 
    4444void single_dirsize_cmd (void); 
    4545void dirsizes_cmd (void); 
    4646gboolean view_file_at_line (const vfs_path_t * filename_vpath, gboolean plain_view, 
    47                             gboolean internal, long start_line); 
     47                            gboolean internal, long start_line, off_t search_start, 
     48                            off_t search_end); 
    4849gboolean view_file (const vfs_path_t * filename_vpath, gboolean normal, gboolean internal); 
    4950void view_cmd (void); 
    5051void view_file_cmd (void); 
  • src/filemanager/ext.c

    diff --git a/src/filemanager/ext.c b/src/filemanager/ext.c
    index 2fa9ae5..b8f7da3 100644
    a b exec_extension_view (void *target, char *cmd, const vfs_path_t * filename_vpath, 
    364364        changed_nroff_flag = 1; 
    365365 
    366366    if (target == NULL) 
    367         mcview_viewer (cmd, filename_vpath, start_line); 
     367        mcview_viewer (cmd, filename_vpath, start_line, 0, 0); 
    368368    else 
    369         mcview_load ((mcview_t *) target, cmd, vfs_path_as_str (filename_vpath), start_line); 
     369        mcview_load ((mcview_t *) target, cmd, vfs_path_as_str (filename_vpath), start_line, 0, 0); 
    370370 
    371371    if (changed_hex_mode && !mcview_altered_hex_mode) 
    372372        mcview_default_hex_mode = def_hex_mode; 
  • src/filemanager/find.c

    diff --git a/src/filemanager/find.c b/src/filemanager/find.c
    index 1b829b3..980f60c 100644
    a b typedef struct 
    111111    char *ignore_dirs; 
    112112} find_file_options_t; 
    113113 
     114typedef struct 
     115{ 
     116    char *dir; 
     117    gsize start; 
     118    gsize end; 
     119} find_match_location_t; 
     120 
    114121/*** file scope variables ************************************************************************/ 
    115122 
    116123/* button callbacks */ 
    static struct timeval last_refresh; 
    157164static gboolean resuming; 
    158165static int last_line; 
    159166static int last_pos; 
     167static off_t last_off; 
     168static int last_i; 
    160169 
    161170static size_t ignore_count = 0; 
    162171 
    find_save_options (void) 
    332341static inline char * 
    333342add_to_list (const char *text, void *data) 
    334343{ 
    335     return listbox_add_item (find_list, LISTBOX_APPEND_AT_END, 0, text, data); 
     344    return listbox_add_item (find_list, LISTBOX_APPEND_AT_END, 0, text, data, TRUE); 
    336345} 
    337346 
    338347/* --------------------------------------------------------------------------------------------- */ 
    found_num_update (void) 
    364373/* --------------------------------------------------------------------------------------------- */ 
    365374 
    366375static void 
    367 get_list_info (char **file, char **dir) 
     376get_list_info (char **file, char **dir, gsize * start, gsize * end) 
    368377{ 
    369     listbox_get_current (find_list, file, (void **) dir); 
     378    find_match_location_t *location; 
     379    listbox_get_current (find_list, file, (void **) &location); 
     380    if (location != NULL) 
     381    { 
     382        if (dir != NULL) 
     383            *dir = location->dir; 
     384        if (start != NULL) 
     385            *start = location->start; 
     386        if (end != NULL) 
     387            *end = location->end; 
     388    } 
     389    else 
     390    { 
     391        if (dir != NULL) 
     392            *dir = NULL; 
     393    } 
    370394} 
    371395 
    372396/* --------------------------------------------------------------------------------------------- */ 
    clear_stack (void) 
    825849/* --------------------------------------------------------------------------------------------- */ 
    826850 
    827851static void 
    828 insert_file (const char *dir, const char *file) 
     852insert_file (const char *dir, const char *file, gsize start, gsize end) 
    829853{ 
    830854    char *tmp_name = NULL; 
    831855    static char *dirname = NULL; 
     856    find_match_location_t *location; 
    832857 
    833858    while (IS_PATH_SEP (dir[0]) && IS_PATH_SEP (dir[1])) 
    834859        dir++; 
    insert_file (const char *dir, const char *file) 
    849874    } 
    850875 
    851876    tmp_name = g_strdup_printf ("    %s", file); 
    852     add_to_list (tmp_name, dirname); 
     877    location = g_malloc (sizeof (*location)); 
     878    location->dir = dirname; 
     879    location->start = start; 
     880    location->end = end; 
     881    add_to_list (tmp_name, location); 
    853882    g_free (tmp_name); 
    854883} 
    855884 
    856885/* --------------------------------------------------------------------------------------------- */ 
    857886 
    858887static void 
    859 find_add_match (const char *dir, const char *file) 
     888find_add_match (const char *dir, const char *file, gsize start, gsize end) 
    860889{ 
    861     insert_file (dir, file); 
     890    insert_file (dir, file, start, end); 
    862891 
    863892    /* Don't scroll */ 
    864893    if (matches == 0) 
    search_content (WDialog * h, const char *directory, const char *filename) 
    967996        int line = 1; 
    968997        int pos = 0; 
    969998        int n_read = 0; 
     999        off_t off = 0;          /* file_fd's offset corresponding to strbuf[0] */ 
    9701000        gboolean found = FALSE; 
    9711001        gsize found_len; 
     1002        gsize found_start; 
    9721003        char result[BUF_MEDIUM]; 
    9731004        char *strbuf = NULL;    /* buffer for fetched string */ 
    9741005        int strbuf_size = 0; 
     1006        int i = -1;             /* compensate for a newline we'll add when we first enter the loop */ 
    9751007 
    9761008        if (resuming) 
    9771009        { 
    search_content (WDialog * h, const char *directory, const char *filename) 
    9791011            resuming = FALSE; 
    9801012            line = last_line; 
    9811013            pos = last_pos; 
     1014            off = last_off; 
     1015            i = last_i; 
    9821016        } 
    9831017 
    9841018        while (!ret_val) 
    9851019        { 
    9861020            char ch = '\0'; 
    987             int i = 0; 
     1021            off += i + 1;       /* the previous line, plus a newline character */ 
     1022            i = 0; 
    9881023 
    9891024            /* read to buffer and get line from there */ 
    9901025            while (TRUE) 
    search_content (WDialog * h, const char *directory, const char *filename) 
    10021037                { 
    10031038                    /* skip possible leading zero(s) */ 
    10041039                    if (i == 0) 
     1040                    { 
     1041                        off++; 
    10051042                        continue; 
     1043                    } 
    10061044                    break; 
    10071045                } 
    10081046 
    search_content (WDialog * h, const char *directory, const char *filename) 
    10451083                } 
    10461084 
    10471085                g_snprintf (result, sizeof (result), "%d:%s", line, filename); 
    1048                 find_add_match (directory, result); 
     1086                found_start = off + search_content_handle->normal_offset + 1;   /* off by one: ticket 3280 */ 
     1087                find_add_match (directory, result, found_start, found_start + found_len); 
    10491088                found = TRUE; 
    10501089            } 
    10511090 
    search_content (WDialog * h, const char *directory, const char *filename) 
    10731112                    resuming = TRUE; 
    10741113                    last_line = line; 
    10751114                    last_pos = pos; 
     1115                    last_off = off; 
     1116                    last_i = i; 
    10761117                    ret_val = TRUE; 
    10771118                    break; 
    10781119                default: 
    do_search (WDialog * h) 
    13011342            if (search_ok) 
    13021343            { 
    13031344                if (content_pattern == NULL) 
    1304                     find_add_match (directory, dp->d_name); 
     1345                    find_add_match (directory, dp->d_name, 0, 0); 
    13051346                else if (search_content (h, directory, dp->d_name)) 
    13061347                    return 1; 
    13071348            } 
    init_find_vars (void) 
    13361377/* --------------------------------------------------------------------------------------------- */ 
    13371378 
    13381379static void 
    1339 find_do_view_edit (gboolean unparsed_view, gboolean edit, char *dir, char *file) 
     1380find_do_view_edit (gboolean unparsed_view, gboolean edit, char *dir, char *file, off_t search_start, 
     1381                   off_t search_end) 
    13401382{ 
    13411383    char *fullname = NULL; 
    13421384    const char *filename = NULL; 
    find_do_view_edit (gboolean unparsed_view, gboolean edit, char *dir, char *file) 
    13581400    if (edit) 
    13591401        edit_file_at_line (fullname_vpath, use_internal_edit != 0, line); 
    13601402    else 
    1361         view_file_at_line (fullname_vpath, unparsed_view, use_internal_view != 0, line); 
     1403        view_file_at_line (fullname_vpath, unparsed_view, use_internal_view != 0, line, 
     1404                           search_start, search_end); 
    13621405    vfs_path_free (fullname_vpath); 
    13631406    g_free (fullname); 
    13641407} 
    find_do_view_edit (gboolean unparsed_view, gboolean edit, char *dir, char *file) 
    13681411static cb_ret_t 
    13691412view_edit_currently_selected_file (gboolean unparsed_view, gboolean edit) 
    13701413{ 
    1371     char *dir = NULL; 
    13721414    char *text = NULL; 
     1415    find_match_location_t *location; 
    13731416 
    1374     listbox_get_current (find_list, &text, (void **) &dir); 
     1417    listbox_get_current (find_list, &text, (void **) &location); 
    13751418 
    1376     if ((text == NULL) || (dir == NULL)) 
     1419    if ((text == NULL) || (location == NULL) || (location->dir == NULL)) 
    13771420        return MSG_NOT_HANDLED; 
    13781421 
    1379     find_do_view_edit (unparsed_view, edit, dir, text); 
     1422    find_do_view_edit (unparsed_view, edit, location->dir, text, location->start, location->end); 
    13801423    return MSG_HANDLED; 
    13811424} 
    13821425 
    do_find (const char *start_dir, ssize_t start_dir_len, const char *ignore_dirs, 
    16471690    /* Clear variables */ 
    16481691    init_find_vars (); 
    16491692 
    1650     get_list_info (&file_tmp, &dir_tmp); 
     1693    get_list_info (&file_tmp, &dir_tmp, NULL, NULL); 
    16511694 
    16521695    if (dir_tmp) 
    16531696        *dirname = g_strdup (dir_tmp); 
    do_find (const char *start_dir, ssize_t start_dir_len, const char *ignore_dirs, 
    16701713        { 
    16711714            const char *lc_filename = NULL; 
    16721715            WLEntry *le = LENTRY (entry->data); 
     1716            find_match_location_t *location = le->data; 
    16731717            char *p; 
    16741718 
    1675             if ((le->text == NULL) || (le->data == NULL)) 
     1719            if ((le->text == NULL) || (location == NULL) || (location->dir == NULL)) 
    16761720                continue; 
    16771721 
    16781722            if (content_pattern != NULL) 
    do_find (const char *start_dir, ssize_t start_dir_len, const char *ignore_dirs, 
    16801724            else 
    16811725                lc_filename = le->text + 4; 
    16821726 
    1683             name = mc_build_filename (le->data, lc_filename, (char *) NULL); 
     1727            name = mc_build_filename (location->dir, lc_filename, (char *) NULL); 
    16841728            /* skip initial start dir */ 
    16851729            if (start_dir_len < 0) 
    16861730                p = name; 
  • src/filemanager/hotlist.c

    diff --git a/src/filemanager/hotlist.c b/src/filemanager/hotlist.c
    index 3d76082..869ef08 100644
    a b fill_listbox (WListbox * list) 
    290290                g_string_truncate (buff, 0); 
    291291                g_string_append (buff, "->"); 
    292292                g_string_append (buff, current->label); 
    293                 listbox_add_item (list, LISTBOX_APPEND_AT_END, 0, buff->str, current); 
     293                listbox_add_item (list, LISTBOX_APPEND_AT_END, 0, buff->str, current, FALSE); 
    294294            } 
    295295            break; 
    296296        case HL_TYPE_DOTDOT: 
    297297        case HL_TYPE_ENTRY: 
    298             listbox_add_item (list, LISTBOX_APPEND_AT_END, 0, current->label, current); 
     298            listbox_add_item (list, LISTBOX_APPEND_AT_END, 0, current->label, current, FALSE); 
    299299        default: 
    300300            break; 
    301301        } 
    unlink_entry (struct hotlist *entry) 
    328328static void 
    329329add_name_to_list (const char *path) 
    330330{ 
    331     listbox_add_item (l_hotlist, LISTBOX_APPEND_AT_END, 0, path, 0); 
     331    listbox_add_item (l_hotlist, LISTBOX_APPEND_AT_END, 0, path, 0, FALSE); 
    332332} 
    333333#endif /* !ENABLE_VFS */ 
    334334 
    hotlist_button_callback (WButton * button, int action) 
    476476 
    477477    case B_REFRESH_VFS: 
    478478        listbox_remove_list (l_hotlist); 
    479         listbox_add_item (l_hotlist, LISTBOX_APPEND_AT_END, 0, mc_config_get_home_dir (), 0); 
     479        listbox_add_item (l_hotlist, LISTBOX_APPEND_AT_END, 0, mc_config_get_home_dir (), 0, FALSE); 
    480480        vfs_fill_names (add_name_to_list); 
    481481        return 0; 
    482482#endif /* ENABLE_VFS */ 
    init_hotlist (hotlist_t list_type) 
    762762#ifdef ENABLE_VFS 
    763763    if (list_type == LIST_VFSLIST) 
    764764    { 
    765         listbox_add_item (l_hotlist, LISTBOX_APPEND_AT_END, 0, mc_config_get_home_dir (), 0); 
     765        listbox_add_item (l_hotlist, LISTBOX_APPEND_AT_END, 0, mc_config_get_home_dir (), 0, FALSE); 
    766766        vfs_fill_names (add_name_to_list); 
    767767    } 
    768768    else 
    add2hotlist (char *label, char *directory, enum HotListType type, listbox_append 
    948948            char *lbl; 
    949949 
    950950            lbl = g_strconcat ("->", new->label, (char *) NULL); 
    951             listbox_add_item (l_hotlist, pos, 0, lbl, new); 
     951            listbox_add_item (l_hotlist, pos, 0, lbl, new, FALSE); 
    952952            g_free (lbl); 
    953953        } 
    954954        else 
    955             listbox_add_item (l_hotlist, pos, 0, new->label, new); 
     955            listbox_add_item (l_hotlist, pos, 0, new->label, new, FALSE); 
    956956        listbox_select_entry (l_hotlist, l_hotlist->pos); 
    957957    } 
    958958 
  • src/filemanager/layout.c

    diff --git a/src/filemanager/layout.c b/src/filemanager/layout.c
    index 7b948d1..3fa3827 100644
    a b set_display_type (int num, panel_view_mode_t type) 
    10211021        else 
    10221022            file_name = ""; 
    10231023 
    1024         mcview_load ((struct mcview_struct *) new_widget, 0, file_name, 0); 
     1024        mcview_load ((struct mcview_struct *) new_widget, 0, file_name, 0, 0, 0); 
    10251025        break; 
    10261026 
    10271027    default: 
  • src/filemanager/listmode.c

    diff --git a/src/filemanager/listmode.c b/src/filemanager/listmode.c
    index 2504c93..3a01166 100644
    a b select_new_item (void) 
    120120    mylistbox = create_listbox_window (20, 12, "Add listing format item", listmode_section); 
    121121    for (i = 0; possible_items[i]; i++) 
    122122    { 
    123         listbox_add_item (mylistbox->list, LISTBOX_APPEND_AT_END, 0, possible_items[i], NULL); 
     123        listbox_add_item (mylistbox->list, LISTBOX_APPEND_AT_END, 0, possible_items[i], NULL, 
     124                          FALSE); 
    124125    } 
    125126 
    126127    i = run_listbox (mylistbox); 
    badd_cback (int action) 
    155156    char *s = select_new_item (); 
    156157    if (s) 
    157158    { 
    158         listbox_add_item (l_listmode, LISTBOX_APPEND_AT_END, 0, s, NULL); 
     159        listbox_add_item (l_listmode, LISTBOX_APPEND_AT_END, 0, s, NULL, FALSE); 
    159160        g_free (s); 
    160161    } 
    161162    return 0; 
    init_listmode (char *oldlistformat) 
    250251 
    251252    while (s) 
    252253    { 
    253         listbox_add_item (l_listmode, LISTBOX_APPEND_AT_END, 0, s, NULL); 
     254        listbox_add_item (l_listmode, LISTBOX_APPEND_AT_END, 0, s, NULL, FALSE); 
    254255        s = strtok (NULL, ","); 
    255256    } 
    256257 
  • src/filemanager/panelize.c

    diff --git a/src/filemanager/panelize.c b/src/filemanager/panelize.c
    index 893357d..328e7c7 100644
    a b init_panelize (void) 
    179179 
    180180    l_panelize = listbox_new (y, UX + 1, 10, panelize_cols - UX * 2 - 2, FALSE, NULL); 
    181181    for (current = panelize; current != NULL; current = current->next) 
    182         listbox_add_item (l_panelize, LISTBOX_APPEND_AT_END, 0, current->label, current); 
     182        listbox_add_item (l_panelize, LISTBOX_APPEND_AT_END, 0, current->label, current, FALSE); 
    183183    listbox_select_entry (l_panelize, listbox_search_text (l_panelize, _("Other command"))); 
    184184    add_widget (panelize_dlg, l_panelize); 
    185185 
  • src/filemanager/usermenu.c

    diff --git a/src/filemanager/usermenu.c b/src/filemanager/usermenu.c
    index fc593b5..e63564f 100644
    a b execute_menu_command (WEdit * edit_widget, const char *commands, gboolean show_p 
    550550    mc_chmod (file_name_vpath, S_IRWXU); 
    551551    if (run_view) 
    552552    { 
    553         mcview_viewer (vfs_path_as_str (file_name_vpath), NULL, 0); 
     553        mcview_viewer (vfs_path_as_str (file_name_vpath), NULL, 0, 0, 0); 
    554554        dialog_switch_process_pending (); 
    555555    } 
    556556    else 
    user_menu_cmd (struct WEdit * edit_widget, const char *menu_file, int selected_e 
    11071107            { 
    11081108                p = entries[i]; 
    11091109                LISTBOX_APPEND_TEXT (listbox, (unsigned char) p[0], 
    1110                                      extract_line (p, p + MAX_ENTRY_LEN), p); 
     1110                                     extract_line (p, p + MAX_ENTRY_LEN), p, FALSE); 
    11111111            } 
    11121112            /* Select the default entry */ 
    11131113            listbox_select_entry (listbox->list, selected); 
  • src/selcodepage.c

    diff --git a/src/selcodepage.c b/src/selcodepage.c
    index 57f76c6..9bb6d24 100644
    a b select_charset (int center_y, int center_x, int current_charset, gboolean seldis 
    8686                                                       "[Codepages Translation]"); 
    8787 
    8888    if (!seldisplay) 
    89         LISTBOX_APPEND_TEXT (listbox, '-', _("-  < No translation >"), NULL); 
     89        LISTBOX_APPEND_TEXT (listbox, '-', _("-  < No translation >"), NULL, FALSE); 
    9090 
    9191    /* insert all the items found */ 
    9292    for (i = 0; i < codepages->len; i++) 
    9393    { 
    9494        const char *name = ((codepage_desc *) g_ptr_array_index (codepages, i))->name; 
    9595        g_snprintf (buffer, sizeof (buffer), "%c  %s", get_hotkey (i), name); 
    96         LISTBOX_APPEND_TEXT (listbox, get_hotkey (i), buffer, NULL); 
     96        LISTBOX_APPEND_TEXT (listbox, get_hotkey (i), buffer, NULL, FALSE); 
    9797    } 
    9898    if (seldisplay) 
    9999    { 
    100100        unsigned char hotkey = get_hotkey (codepages->len); 
    101101        g_snprintf (buffer, sizeof (buffer), "%c  %s", hotkey, _("Other 8 bit")); 
    102         LISTBOX_APPEND_TEXT (listbox, hotkey, buffer, NULL); 
     102        LISTBOX_APPEND_TEXT (listbox, hotkey, buffer, NULL, FALSE); 
    103103    } 
    104104 
    105105    /* Select the default entry */ 
  • src/viewer/actions_cmd.c

    diff --git a/src/viewer/actions_cmd.c b/src/viewer/actions_cmd.c
    index 20fdbf1..492dcfa 100644
    a b mcview_hook (void *v) 
    210210 
    211211    mcview_done (view); 
    212212    mcview_init (view); 
    213     mcview_load (view, 0, panel->dir.list[panel->selected].fname, 0); 
     213    mcview_load (view, 0, panel->dir.list[panel->selected].fname, 0, 0, 0); 
    214214    mcview_display (view); 
    215215} 
    216216 
    mcview_load_next_prev (mcview_t * view, int direction) 
    369369    mcview_remove_ext_script (view); 
    370370    mcview_init (view); 
    371371    if (regex_command_for (view, vfile, "View", &ext_script) == 0) 
    372         mcview_load (view, NULL, vfs_path_as_str (vfile), 0); 
     372        mcview_load (view, NULL, vfs_path_as_str (vfile), 0, 0, 0); 
    373373    vfs_path_free (vfile); 
    374374    view->dir = dir; 
    375375    view->dir_idx = dir_idx; 
  • src/viewer/lib.c

    diff --git a/src/viewer/lib.c b/src/viewer/lib.c
    index 2528c10..4d72f60 100644
    a b mcview_toggle_magic_mode (mcview_t * view) 
    9191    view->dir_idx = NULL; 
    9292    mcview_done (view); 
    9393    mcview_init (view); 
    94     mcview_load (view, command, filename, 0); 
     94    mcview_load (view, command, filename, 0, 0, 0); 
    9595    view->dir = dir; 
    9696    view->dir_idx = dir_idx; 
    9797    g_free (filename); 
  • src/viewer/mcviewer.c

    diff --git a/src/viewer/mcviewer.c b/src/viewer/mcviewer.c
    index a34099b..530ac31 100644
    a b mcview_new (int y, int x, int lines, int cols, gboolean is_panel) 
    232232/** Real view only */ 
    233233 
    234234gboolean 
    235 mcview_viewer (const char *command, const vfs_path_t * file_vpath, int start_line) 
     235mcview_viewer (const char *command, const vfs_path_t * file_vpath, int start_line, 
     236               off_t search_start, off_t search_end) 
    236237{ 
    237238    gboolean succeeded; 
    238239    mcview_t *lc_mcview; 
    mcview_viewer (const char *command, const vfs_path_t * file_vpath, int start_lin 
    249250 
    250251    view_dlg->get_title = mcview_get_title; 
    251252 
    252     succeeded = mcview_load (lc_mcview, command, vfs_path_as_str (file_vpath), start_line); 
     253    succeeded = 
     254        mcview_load (lc_mcview, command, vfs_path_as_str (file_vpath), start_line, search_start, 
     255                     search_end); 
    253256 
    254257    if (succeeded) 
    255258        dlg_run (view_dlg); 
    mcview_viewer (const char *command, const vfs_path_t * file_vpath, int start_lin 
    267270/* --------------------------------------------------------------------------------------------- */ 
    268271 
    269272gboolean 
    270 mcview_load (mcview_t * view, const char *command, const char *file, int start_line) 
     273mcview_load (mcview_t * view, const char *command, const char *file, int start_line, 
     274             off_t search_start, off_t search_end) 
    271275{ 
    272276    gboolean retval = FALSE; 
    273277    vfs_path_t *vpath = NULL; 
    mcview_load (mcview_t * view, const char *command, const char *file, int start_l 
    409413    mcview_state_machine_init (&view->dpy_state_top, 0); 
    410414    view->dpy_wrap_dirty = FALSE; 
    411415    view->force_max = -1; 
    412     view->search_start = 0; 
    413     view->search_end = 0; 
    414416    view->dpy_text_column = 0; 
    415417 
    416418    mcview_compute_areas (view); 
    mcview_load (mcview_t * view, const char *command, const char *file, int start_l 
    441443    else if (start_line > 0) 
    442444        mcview_moveto (view, start_line - 1, 0); 
    443445 
     446    view->search_start = search_start; 
     447    view->search_end = search_end; 
    444448    view->hexedit_lownibble = FALSE; 
    445449    view->hexview_in_text = FALSE; 
    446450    view->change_list = NULL; 
  • src/viewer/mcviewer.h

    diff --git a/src/viewer/mcviewer.h b/src/viewer/mcviewer.h
    index e68642b..89c4073 100644
    a b extern mcview_t *mcview_new (int y, int x, int lines, int cols, gboolean is_pane 
    4343/* Shows {file} or the output of {command} in the internal viewer, 
    4444 * starting in line {start_line}. 
    4545 */ 
    46 extern gboolean mcview_viewer (const char *command, const vfs_path_t * file_vpath, int start_line); 
     46extern gboolean mcview_viewer (const char *command, const vfs_path_t * file_vpath, int start_line, 
     47                               off_t search_start, off_t search_end); 
    4748 
    4849extern gboolean mcview_load (mcview_t * view, const char *command, const char *file, 
    49                              int start_line); 
     50                             int start_line, off_t search_start, off_t search_end); 
    5051 
    5152/*** inline functions ****************************************************************************/ 
    5253#endif /* MC__VIEWER_H */