-
diff --git a/lib/widget/dialog-switch.c b/lib/widget/dialog-switch.c
index f008674..a3732bb 100644
a
|
b
|
dialog_switch_list (void) |
250 | 250 | else |
251 | 251 | title = g_strdup (""); |
252 | 252 | |
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); |
254 | 255 | |
255 | 256 | g_free (title); |
256 | 257 | } |
-
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) |
1251 | 1251 | query_list = listbox_new (1, 1, h - 2, w - 2, FALSE, NULL); |
1252 | 1252 | add_widget (query_dlg, query_list); |
1253 | 1253 | 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); |
1255 | 1255 | dlg_run (query_dlg); |
1256 | 1256 | q = NULL; |
1257 | 1257 | if (query_dlg->ret_value == B_ENTER) |
-
diff --git a/lib/widget/listbox-window.h b/lib/widget/listbox-window.h
index a96cd59..b4c3f28 100644
a
|
b
|
|
7 | 7 | |
8 | 8 | /*** typedefs(not structures) and defined constants **********************************************/ |
9 | 9 | |
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) |
12 | 12 | |
13 | 13 | /*** enums ***************************************************************************************/ |
14 | 14 | |
-
diff --git a/lib/widget/listbox.c b/lib/widget/listbox.c
index fd97b76..d7fbb4c 100644
a
|
b
|
listbox_entry_free (void *data) |
76 | 76 | { |
77 | 77 | WLEntry *e = data; |
78 | 78 | g_free (e->text); |
| 79 | if (e->free_data) |
| 80 | g_free (e->data); |
79 | 81 | g_free (e); |
80 | 82 | } |
81 | 83 | |
… |
… |
listbox_remove_list (WListbox * l) |
770 | 772 | /* --------------------------------------------------------------------------------------------- */ |
771 | 773 | |
772 | 774 | char * |
773 | | listbox_add_item (WListbox * l, listbox_append_t pos, int hotkey, const char *text, void *data) |
| 775 | listbox_add_item (WListbox * l, listbox_append_t pos, int hotkey, const char *text, void *data, |
| 776 | gboolean free_data) |
774 | 777 | { |
775 | 778 | WLEntry *entry; |
776 | 779 | |
… |
… |
listbox_add_item (WListbox * l, listbox_append_t pos, int hotkey, const char *te |
783 | 786 | entry = g_new (WLEntry, 1); |
784 | 787 | entry->text = g_strdup (text); |
785 | 788 | entry->data = data; |
| 789 | entry->free_data = free_data; |
786 | 790 | entry->hotkey = hotkey; |
787 | 791 | |
788 | 792 | listbox_append_item (l, entry, pos); |
-
diff --git a/lib/widget/listbox.h b/lib/widget/listbox.h
index f8f2491..62d5e15 100644
a
|
b
|
typedef struct WLEntry |
40 | 40 | char *text; /* Text to display */ |
41 | 41 | int hotkey; |
42 | 42 | void *data; /* Client information */ |
| 43 | gboolean free_data; /* Whether to free the data on entry's removal */ |
43 | 44 | } WLEntry; |
44 | 45 | |
45 | 46 | typedef struct WListbox |
… |
… |
gboolean listbox_is_empty (const WListbox * l); |
74 | 75 | void listbox_set_list (WListbox * l, GList * list); |
75 | 76 | void listbox_remove_list (WListbox * l); |
76 | 77 | char *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); |
78 | 79 | |
79 | 80 | /*** inline functions ****************************************************************************/ |
80 | 81 | |
-
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) |
74 | 74 | |
75 | 75 | syntaxlist = create_listbox_window (LIST_LINES, MAX_ENTRY_LEN, |
76 | 76 | _("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); |
79 | 79 | |
80 | 80 | for (i = 0; i < names->len; i++) |
81 | 81 | { |
82 | 82 | const char *name; |
83 | 83 | |
84 | 84 | name = g_ptr_array_index (names, i); |
85 | | LISTBOX_APPEND_TEXT (syntaxlist, 0, name, NULL); |
| 85 | LISTBOX_APPEND_TEXT (syntaxlist, 0, name, NULL, FALSE); |
86 | 86 | if (current_syntax != NULL && strcmp (name, current_syntax) == 0) |
87 | 87 | listbox_select_entry (syntaxlist->list, i + N_DFLT_ENTRIES); |
88 | 88 | } |
-
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 |
390 | 390 | |
391 | 391 | /* fill the listbox with the completions */ |
392 | 392 | 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); |
394 | 395 | |
395 | 396 | /* pop up the dialog and apply the chosen completion */ |
396 | 397 | if (dlg_run (compl_dlg) == B_ENTER) |
… |
… |
editcmd_dialog_select_definition_show (WEdit * edit, char *match_expr, int max_l |
461 | 462 | label_def = |
462 | 463 | g_strdup_printf ("%s -> %s:%ld", def_hash[i].short_define, def_hash[i].filename, |
463 | 464 | 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); |
465 | 466 | g_free (label_def); |
466 | 467 | } |
467 | 468 | |
-
diff --git a/src/editor/editwidget.c b/src/editor/editwidget.c
index 40f60ba..eb2e812 100644
a
|
b
|
edit_window_list (const WDialog * h) |
342 | 342 | vfs_path_as_str (e->filename_vpath)); |
343 | 343 | |
344 | 344 | 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); |
346 | 346 | g_free (fname); |
347 | 347 | } |
348 | 348 | |
-
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 |
120 | 120 | sug_list = listbox_new (5, 2, sug_dlg_h - 7, 24, FALSE, NULL); |
121 | 121 | for (i = 0; i < suggest->len; i++) |
122 | 122 | listbox_add_item (sug_list, LISTBOX_APPEND_AT_END, 0, g_array_index (suggest, char *, i), |
123 | | NULL); |
| 123 | NULL, FALSE); |
124 | 124 | add_widget (sug_dlg, sug_list); |
125 | 125 | |
126 | 126 | add_widget (sug_dlg, add_btn); |
… |
… |
spell_dialog_lang_list_show (GArray * languages) |
170 | 170 | _("Select language"), "[ASpell]"); |
171 | 171 | |
172 | 172 | 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); |
174 | 174 | |
175 | 175 | res = run_listbox (lang_list); |
176 | 176 | if (res >= 0) |
-
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) |
343 | 343 | |
344 | 344 | /* get new listboxes */ |
345 | 345 | 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); |
347 | 347 | if (is_owner) |
348 | 348 | { |
349 | 349 | /* get and put user names in the listbox */ |
350 | 350 | setpwent (); |
351 | 351 | 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); |
353 | 354 | endpwent (); |
354 | 355 | fe = listbox_search_text (chl_list, get_owner (sf_stat->st_uid)); |
355 | 356 | } |
… |
… |
do_enter_key (WDialog * h, int f_pos) |
358 | 359 | /* get and put group names in the listbox */ |
359 | 360 | setgrent (); |
360 | 361 | 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); |
362 | 364 | endgrent (); |
363 | 365 | fe = listbox_search_text (chl_list, get_group (sf_stat->st_gid)); |
364 | 366 | } |
-
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) |
205 | 205 | skin_list = listbox_new (1, 1, 11, 22, FALSE, NULL); |
206 | 206 | skin_name = "default"; |
207 | 207 | 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); |
209 | 209 | |
210 | 210 | if (strcmp (skin_name, current_skin_name) == 0) |
211 | 211 | listbox_select_entry (skin_list, 0); |
… |
… |
sel_skin_button (WButton * button, int action) |
216 | 216 | if (strcmp (skin_name, "default") != 0) |
217 | 217 | { |
218 | 218 | 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); |
220 | 220 | if (strcmp (skin_name, current_skin_name) == 0) |
221 | 221 | listbox_select_entry (skin_list, pos); |
222 | 222 | pos++; |
… |
… |
jobs_fill_listbox (WListbox * list) |
467 | 467 | char *s; |
468 | 468 | |
469 | 469 | 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); |
471 | 471 | g_free (s); |
472 | 472 | } |
473 | 473 | } |
-
diff --git a/src/filemanager/chown.c b/src/filemanager/chown.c
index 41d800a..263efe9 100644
a
|
b
|
init_chown (void) |
218 | 218 | l_user = listbox_new (3, 4, GH - 2, GW - 2, FALSE, NULL); |
219 | 219 | add_widget (ch_dlg, l_user); |
220 | 220 | /* 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); |
222 | 222 | /* get and put user names in the listbox */ |
223 | 223 | setpwent (); |
224 | 224 | 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); |
226 | 226 | endpwent (); |
227 | 227 | |
228 | 228 | add_widget (ch_dlg, groupbox_new (2, 4 + GW, GH, GW, _("Group name"))); |
229 | 229 | l_group = listbox_new (3, 5 + GW, GH - 2, GW - 2, FALSE, NULL); |
230 | 230 | add_widget (ch_dlg, l_group); |
231 | 231 | /* 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); |
233 | 233 | /* get and put group names in the listbox */ |
234 | 234 | setgrent (); |
235 | 235 | 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); |
237 | 237 | endgrent (); |
238 | 238 | |
239 | 239 | add_widget (ch_dlg, groupbox_new (2, 5 + GW * 2, GH, GW, _("File"))); |
-
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) |
541 | 541 | |
542 | 542 | gboolean |
543 | 543 | view_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) |
545 | 545 | { |
546 | 546 | gboolean ret = TRUE; |
547 | 547 | |
… |
… |
view_file_at_line (const vfs_path_t * filename_vpath, gboolean plain_view, gbool |
564 | 564 | mcview_default_nroff_flag = 0; |
565 | 565 | mcview_default_magic_flag = 0; |
566 | 566 | |
567 | | ret = mcview_viewer (NULL, filename_vpath, start_line); |
| 567 | ret = mcview_viewer (NULL, filename_vpath, start_line, search_start, search_end); |
568 | 568 | |
569 | 569 | if (changed_hex_mode && !mcview_altered_hex_mode) |
570 | 570 | mcview_default_hex_mode = 1; |
… |
… |
view_file_at_line (const vfs_path_t * filename_vpath, gboolean plain_view, gbool |
587 | 587 | ret = (regex_command (filename_vpath, view_entry) == 0); |
588 | 588 | if (ret) |
589 | 589 | { |
590 | | ret = mcview_viewer (NULL, filename_vpath, start_line); |
| 590 | ret = mcview_viewer (NULL, filename_vpath, start_line, search_start, search_end); |
591 | 591 | dialog_switch_process_pending (); |
592 | 592 | } |
593 | 593 | } |
… |
… |
view_file_at_line (const vfs_path_t * filename_vpath, gboolean plain_view, gbool |
623 | 623 | gboolean |
624 | 624 | view_file (const vfs_path_t * filename_vpath, gboolean plain_view, gboolean internal) |
625 | 625 | { |
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); |
627 | 627 | } |
628 | 628 | |
629 | 629 | |
… |
… |
view_filtered_cmd (void) |
687 | 687 | |
688 | 688 | if (command != NULL) |
689 | 689 | { |
690 | | mcview_viewer (command, NULL, 0); |
| 690 | mcview_viewer (command, NULL, 0, 0, 0); |
691 | 691 | g_free (command); |
692 | 692 | dialog_switch_process_pending (); |
693 | 693 | } |
-
diff --git a/src/filemanager/cmd.h b/src/filemanager/cmd.h
index 892f1ce..cc57e49 100644
a
|
b
|
void smart_dirsize_cmd (void); |
44 | 44 | void single_dirsize_cmd (void); |
45 | 45 | void dirsizes_cmd (void); |
46 | 46 | gboolean 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); |
48 | 49 | gboolean view_file (const vfs_path_t * filename_vpath, gboolean normal, gboolean internal); |
49 | 50 | void view_cmd (void); |
50 | 51 | void view_file_cmd (void); |
-
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, |
364 | 364 | changed_nroff_flag = 1; |
365 | 365 | |
366 | 366 | if (target == NULL) |
367 | | mcview_viewer (cmd, filename_vpath, start_line); |
| 367 | mcview_viewer (cmd, filename_vpath, start_line, 0, 0); |
368 | 368 | 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); |
370 | 370 | |
371 | 371 | if (changed_hex_mode && !mcview_altered_hex_mode) |
372 | 372 | mcview_default_hex_mode = def_hex_mode; |
-
diff --git a/src/filemanager/find.c b/src/filemanager/find.c
index 1b829b3..980f60c 100644
a
|
b
|
typedef struct |
111 | 111 | char *ignore_dirs; |
112 | 112 | } find_file_options_t; |
113 | 113 | |
| 114 | typedef struct |
| 115 | { |
| 116 | char *dir; |
| 117 | gsize start; |
| 118 | gsize end; |
| 119 | } find_match_location_t; |
| 120 | |
114 | 121 | /*** file scope variables ************************************************************************/ |
115 | 122 | |
116 | 123 | /* button callbacks */ |
… |
… |
static struct timeval last_refresh; |
157 | 164 | static gboolean resuming; |
158 | 165 | static int last_line; |
159 | 166 | static int last_pos; |
| 167 | static off_t last_off; |
| 168 | static int last_i; |
160 | 169 | |
161 | 170 | static size_t ignore_count = 0; |
162 | 171 | |
… |
… |
find_save_options (void) |
332 | 341 | static inline char * |
333 | 342 | add_to_list (const char *text, void *data) |
334 | 343 | { |
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); |
336 | 345 | } |
337 | 346 | |
338 | 347 | /* --------------------------------------------------------------------------------------------- */ |
… |
… |
found_num_update (void) |
364 | 373 | /* --------------------------------------------------------------------------------------------- */ |
365 | 374 | |
366 | 375 | static void |
367 | | get_list_info (char **file, char **dir) |
| 376 | get_list_info (char **file, char **dir, gsize * start, gsize * end) |
368 | 377 | { |
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 | } |
370 | 394 | } |
371 | 395 | |
372 | 396 | /* --------------------------------------------------------------------------------------------- */ |
… |
… |
clear_stack (void) |
825 | 849 | /* --------------------------------------------------------------------------------------------- */ |
826 | 850 | |
827 | 851 | static void |
828 | | insert_file (const char *dir, const char *file) |
| 852 | insert_file (const char *dir, const char *file, gsize start, gsize end) |
829 | 853 | { |
830 | 854 | char *tmp_name = NULL; |
831 | 855 | static char *dirname = NULL; |
| 856 | find_match_location_t *location; |
832 | 857 | |
833 | 858 | while (IS_PATH_SEP (dir[0]) && IS_PATH_SEP (dir[1])) |
834 | 859 | dir++; |
… |
… |
insert_file (const char *dir, const char *file) |
849 | 874 | } |
850 | 875 | |
851 | 876 | 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); |
853 | 882 | g_free (tmp_name); |
854 | 883 | } |
855 | 884 | |
856 | 885 | /* --------------------------------------------------------------------------------------------- */ |
857 | 886 | |
858 | 887 | static void |
859 | | find_add_match (const char *dir, const char *file) |
| 888 | find_add_match (const char *dir, const char *file, gsize start, gsize end) |
860 | 889 | { |
861 | | insert_file (dir, file); |
| 890 | insert_file (dir, file, start, end); |
862 | 891 | |
863 | 892 | /* Don't scroll */ |
864 | 893 | if (matches == 0) |
… |
… |
search_content (WDialog * h, const char *directory, const char *filename) |
967 | 996 | int line = 1; |
968 | 997 | int pos = 0; |
969 | 998 | int n_read = 0; |
| 999 | off_t off = 0; /* file_fd's offset corresponding to strbuf[0] */ |
970 | 1000 | gboolean found = FALSE; |
971 | 1001 | gsize found_len; |
| 1002 | gsize found_start; |
972 | 1003 | char result[BUF_MEDIUM]; |
973 | 1004 | char *strbuf = NULL; /* buffer for fetched string */ |
974 | 1005 | int strbuf_size = 0; |
| 1006 | int i = -1; /* compensate for a newline we'll add when we first enter the loop */ |
975 | 1007 | |
976 | 1008 | if (resuming) |
977 | 1009 | { |
… |
… |
search_content (WDialog * h, const char *directory, const char *filename) |
979 | 1011 | resuming = FALSE; |
980 | 1012 | line = last_line; |
981 | 1013 | pos = last_pos; |
| 1014 | off = last_off; |
| 1015 | i = last_i; |
982 | 1016 | } |
983 | 1017 | |
984 | 1018 | while (!ret_val) |
985 | 1019 | { |
986 | 1020 | char ch = '\0'; |
987 | | int i = 0; |
| 1021 | off += i + 1; /* the previous line, plus a newline character */ |
| 1022 | i = 0; |
988 | 1023 | |
989 | 1024 | /* read to buffer and get line from there */ |
990 | 1025 | while (TRUE) |
… |
… |
search_content (WDialog * h, const char *directory, const char *filename) |
1002 | 1037 | { |
1003 | 1038 | /* skip possible leading zero(s) */ |
1004 | 1039 | if (i == 0) |
| 1040 | { |
| 1041 | off++; |
1005 | 1042 | continue; |
| 1043 | } |
1006 | 1044 | break; |
1007 | 1045 | } |
1008 | 1046 | |
… |
… |
search_content (WDialog * h, const char *directory, const char *filename) |
1045 | 1083 | } |
1046 | 1084 | |
1047 | 1085 | 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); |
1049 | 1088 | found = TRUE; |
1050 | 1089 | } |
1051 | 1090 | |
… |
… |
search_content (WDialog * h, const char *directory, const char *filename) |
1073 | 1112 | resuming = TRUE; |
1074 | 1113 | last_line = line; |
1075 | 1114 | last_pos = pos; |
| 1115 | last_off = off; |
| 1116 | last_i = i; |
1076 | 1117 | ret_val = TRUE; |
1077 | 1118 | break; |
1078 | 1119 | default: |
… |
… |
do_search (WDialog * h) |
1301 | 1342 | if (search_ok) |
1302 | 1343 | { |
1303 | 1344 | if (content_pattern == NULL) |
1304 | | find_add_match (directory, dp->d_name); |
| 1345 | find_add_match (directory, dp->d_name, 0, 0); |
1305 | 1346 | else if (search_content (h, directory, dp->d_name)) |
1306 | 1347 | return 1; |
1307 | 1348 | } |
… |
… |
init_find_vars (void) |
1336 | 1377 | /* --------------------------------------------------------------------------------------------- */ |
1337 | 1378 | |
1338 | 1379 | static void |
1339 | | find_do_view_edit (gboolean unparsed_view, gboolean edit, char *dir, char *file) |
| 1380 | find_do_view_edit (gboolean unparsed_view, gboolean edit, char *dir, char *file, off_t search_start, |
| 1381 | off_t search_end) |
1340 | 1382 | { |
1341 | 1383 | char *fullname = NULL; |
1342 | 1384 | const char *filename = NULL; |
… |
… |
find_do_view_edit (gboolean unparsed_view, gboolean edit, char *dir, char *file) |
1358 | 1400 | if (edit) |
1359 | 1401 | edit_file_at_line (fullname_vpath, use_internal_edit != 0, line); |
1360 | 1402 | 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); |
1362 | 1405 | vfs_path_free (fullname_vpath); |
1363 | 1406 | g_free (fullname); |
1364 | 1407 | } |
… |
… |
find_do_view_edit (gboolean unparsed_view, gboolean edit, char *dir, char *file) |
1368 | 1411 | static cb_ret_t |
1369 | 1412 | view_edit_currently_selected_file (gboolean unparsed_view, gboolean edit) |
1370 | 1413 | { |
1371 | | char *dir = NULL; |
1372 | 1414 | char *text = NULL; |
| 1415 | find_match_location_t *location; |
1373 | 1416 | |
1374 | | listbox_get_current (find_list, &text, (void **) &dir); |
| 1417 | listbox_get_current (find_list, &text, (void **) &location); |
1375 | 1418 | |
1376 | | if ((text == NULL) || (dir == NULL)) |
| 1419 | if ((text == NULL) || (location == NULL) || (location->dir == NULL)) |
1377 | 1420 | return MSG_NOT_HANDLED; |
1378 | 1421 | |
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); |
1380 | 1423 | return MSG_HANDLED; |
1381 | 1424 | } |
1382 | 1425 | |
… |
… |
do_find (const char *start_dir, ssize_t start_dir_len, const char *ignore_dirs, |
1647 | 1690 | /* Clear variables */ |
1648 | 1691 | init_find_vars (); |
1649 | 1692 | |
1650 | | get_list_info (&file_tmp, &dir_tmp); |
| 1693 | get_list_info (&file_tmp, &dir_tmp, NULL, NULL); |
1651 | 1694 | |
1652 | 1695 | if (dir_tmp) |
1653 | 1696 | *dirname = g_strdup (dir_tmp); |
… |
… |
do_find (const char *start_dir, ssize_t start_dir_len, const char *ignore_dirs, |
1670 | 1713 | { |
1671 | 1714 | const char *lc_filename = NULL; |
1672 | 1715 | WLEntry *le = LENTRY (entry->data); |
| 1716 | find_match_location_t *location = le->data; |
1673 | 1717 | char *p; |
1674 | 1718 | |
1675 | | if ((le->text == NULL) || (le->data == NULL)) |
| 1719 | if ((le->text == NULL) || (location == NULL) || (location->dir == NULL)) |
1676 | 1720 | continue; |
1677 | 1721 | |
1678 | 1722 | if (content_pattern != NULL) |
… |
… |
do_find (const char *start_dir, ssize_t start_dir_len, const char *ignore_dirs, |
1680 | 1724 | else |
1681 | 1725 | lc_filename = le->text + 4; |
1682 | 1726 | |
1683 | | name = mc_build_filename (le->data, lc_filename, (char *) NULL); |
| 1727 | name = mc_build_filename (location->dir, lc_filename, (char *) NULL); |
1684 | 1728 | /* skip initial start dir */ |
1685 | 1729 | if (start_dir_len < 0) |
1686 | 1730 | p = name; |
-
diff --git a/src/filemanager/hotlist.c b/src/filemanager/hotlist.c
index 3d76082..869ef08 100644
a
|
b
|
fill_listbox (WListbox * list) |
290 | 290 | g_string_truncate (buff, 0); |
291 | 291 | g_string_append (buff, "->"); |
292 | 292 | 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); |
294 | 294 | } |
295 | 295 | break; |
296 | 296 | case HL_TYPE_DOTDOT: |
297 | 297 | 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); |
299 | 299 | default: |
300 | 300 | break; |
301 | 301 | } |
… |
… |
unlink_entry (struct hotlist *entry) |
328 | 328 | static void |
329 | 329 | add_name_to_list (const char *path) |
330 | 330 | { |
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); |
332 | 332 | } |
333 | 333 | #endif /* !ENABLE_VFS */ |
334 | 334 | |
… |
… |
hotlist_button_callback (WButton * button, int action) |
476 | 476 | |
477 | 477 | case B_REFRESH_VFS: |
478 | 478 | 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); |
480 | 480 | vfs_fill_names (add_name_to_list); |
481 | 481 | return 0; |
482 | 482 | #endif /* ENABLE_VFS */ |
… |
… |
init_hotlist (hotlist_t list_type) |
762 | 762 | #ifdef ENABLE_VFS |
763 | 763 | if (list_type == LIST_VFSLIST) |
764 | 764 | { |
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); |
766 | 766 | vfs_fill_names (add_name_to_list); |
767 | 767 | } |
768 | 768 | else |
… |
… |
add2hotlist (char *label, char *directory, enum HotListType type, listbox_append |
948 | 948 | char *lbl; |
949 | 949 | |
950 | 950 | 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); |
952 | 952 | g_free (lbl); |
953 | 953 | } |
954 | 954 | else |
955 | | listbox_add_item (l_hotlist, pos, 0, new->label, new); |
| 955 | listbox_add_item (l_hotlist, pos, 0, new->label, new, FALSE); |
956 | 956 | listbox_select_entry (l_hotlist, l_hotlist->pos); |
957 | 957 | } |
958 | 958 | |
-
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) |
1021 | 1021 | else |
1022 | 1022 | file_name = ""; |
1023 | 1023 | |
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); |
1025 | 1025 | break; |
1026 | 1026 | |
1027 | 1027 | default: |
-
diff --git a/src/filemanager/listmode.c b/src/filemanager/listmode.c
index 2504c93..3a01166 100644
a
|
b
|
select_new_item (void) |
120 | 120 | mylistbox = create_listbox_window (20, 12, "Add listing format item", listmode_section); |
121 | 121 | for (i = 0; possible_items[i]; i++) |
122 | 122 | { |
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); |
124 | 125 | } |
125 | 126 | |
126 | 127 | i = run_listbox (mylistbox); |
… |
… |
badd_cback (int action) |
155 | 156 | char *s = select_new_item (); |
156 | 157 | if (s) |
157 | 158 | { |
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); |
159 | 160 | g_free (s); |
160 | 161 | } |
161 | 162 | return 0; |
… |
… |
init_listmode (char *oldlistformat) |
250 | 251 | |
251 | 252 | while (s) |
252 | 253 | { |
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); |
254 | 255 | s = strtok (NULL, ","); |
255 | 256 | } |
256 | 257 | |
-
diff --git a/src/filemanager/panelize.c b/src/filemanager/panelize.c
index 893357d..328e7c7 100644
a
|
b
|
init_panelize (void) |
179 | 179 | |
180 | 180 | l_panelize = listbox_new (y, UX + 1, 10, panelize_cols - UX * 2 - 2, FALSE, NULL); |
181 | 181 | 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); |
183 | 183 | listbox_select_entry (l_panelize, listbox_search_text (l_panelize, _("Other command"))); |
184 | 184 | add_widget (panelize_dlg, l_panelize); |
185 | 185 | |
-
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 |
550 | 550 | mc_chmod (file_name_vpath, S_IRWXU); |
551 | 551 | if (run_view) |
552 | 552 | { |
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); |
554 | 554 | dialog_switch_process_pending (); |
555 | 555 | } |
556 | 556 | else |
… |
… |
user_menu_cmd (struct WEdit * edit_widget, const char *menu_file, int selected_e |
1107 | 1107 | { |
1108 | 1108 | p = entries[i]; |
1109 | 1109 | 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); |
1111 | 1111 | } |
1112 | 1112 | /* Select the default entry */ |
1113 | 1113 | listbox_select_entry (listbox->list, selected); |
-
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 |
86 | 86 | "[Codepages Translation]"); |
87 | 87 | |
88 | 88 | if (!seldisplay) |
89 | | LISTBOX_APPEND_TEXT (listbox, '-', _("- < No translation >"), NULL); |
| 89 | LISTBOX_APPEND_TEXT (listbox, '-', _("- < No translation >"), NULL, FALSE); |
90 | 90 | |
91 | 91 | /* insert all the items found */ |
92 | 92 | for (i = 0; i < codepages->len; i++) |
93 | 93 | { |
94 | 94 | const char *name = ((codepage_desc *) g_ptr_array_index (codepages, i))->name; |
95 | 95 | 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); |
97 | 97 | } |
98 | 98 | if (seldisplay) |
99 | 99 | { |
100 | 100 | unsigned char hotkey = get_hotkey (codepages->len); |
101 | 101 | 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); |
103 | 103 | } |
104 | 104 | |
105 | 105 | /* Select the default entry */ |
-
diff --git a/src/viewer/actions_cmd.c b/src/viewer/actions_cmd.c
index 20fdbf1..492dcfa 100644
a
|
b
|
mcview_hook (void *v) |
210 | 210 | |
211 | 211 | mcview_done (view); |
212 | 212 | 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); |
214 | 214 | mcview_display (view); |
215 | 215 | } |
216 | 216 | |
… |
… |
mcview_load_next_prev (mcview_t * view, int direction) |
369 | 369 | mcview_remove_ext_script (view); |
370 | 370 | mcview_init (view); |
371 | 371 | 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); |
373 | 373 | vfs_path_free (vfile); |
374 | 374 | view->dir = dir; |
375 | 375 | view->dir_idx = dir_idx; |
-
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) |
91 | 91 | view->dir_idx = NULL; |
92 | 92 | mcview_done (view); |
93 | 93 | mcview_init (view); |
94 | | mcview_load (view, command, filename, 0); |
| 94 | mcview_load (view, command, filename, 0, 0, 0); |
95 | 95 | view->dir = dir; |
96 | 96 | view->dir_idx = dir_idx; |
97 | 97 | g_free (filename); |
-
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) |
232 | 232 | /** Real view only */ |
233 | 233 | |
234 | 234 | gboolean |
235 | | mcview_viewer (const char *command, const vfs_path_t * file_vpath, int start_line) |
| 235 | mcview_viewer (const char *command, const vfs_path_t * file_vpath, int start_line, |
| 236 | off_t search_start, off_t search_end) |
236 | 237 | { |
237 | 238 | gboolean succeeded; |
238 | 239 | mcview_t *lc_mcview; |
… |
… |
mcview_viewer (const char *command, const vfs_path_t * file_vpath, int start_lin |
249 | 250 | |
250 | 251 | view_dlg->get_title = mcview_get_title; |
251 | 252 | |
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); |
253 | 256 | |
254 | 257 | if (succeeded) |
255 | 258 | dlg_run (view_dlg); |
… |
… |
mcview_viewer (const char *command, const vfs_path_t * file_vpath, int start_lin |
267 | 270 | /* --------------------------------------------------------------------------------------------- */ |
268 | 271 | |
269 | 272 | gboolean |
270 | | mcview_load (mcview_t * view, const char *command, const char *file, int start_line) |
| 273 | mcview_load (mcview_t * view, const char *command, const char *file, int start_line, |
| 274 | off_t search_start, off_t search_end) |
271 | 275 | { |
272 | 276 | gboolean retval = FALSE; |
273 | 277 | vfs_path_t *vpath = NULL; |
… |
… |
mcview_load (mcview_t * view, const char *command, const char *file, int start_l |
409 | 413 | mcview_state_machine_init (&view->dpy_state_top, 0); |
410 | 414 | view->dpy_wrap_dirty = FALSE; |
411 | 415 | view->force_max = -1; |
412 | | view->search_start = 0; |
413 | | view->search_end = 0; |
414 | 416 | view->dpy_text_column = 0; |
415 | 417 | |
416 | 418 | mcview_compute_areas (view); |
… |
… |
mcview_load (mcview_t * view, const char *command, const char *file, int start_l |
441 | 443 | else if (start_line > 0) |
442 | 444 | mcview_moveto (view, start_line - 1, 0); |
443 | 445 | |
| 446 | view->search_start = search_start; |
| 447 | view->search_end = search_end; |
444 | 448 | view->hexedit_lownibble = FALSE; |
445 | 449 | view->hexview_in_text = FALSE; |
446 | 450 | view->change_list = NULL; |
-
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 |
43 | 43 | /* Shows {file} or the output of {command} in the internal viewer, |
44 | 44 | * starting in line {start_line}. |
45 | 45 | */ |
46 | | extern gboolean mcview_viewer (const char *command, const vfs_path_t * file_vpath, int start_line); |
| 46 | extern gboolean mcview_viewer (const char *command, const vfs_path_t * file_vpath, int start_line, |
| 47 | off_t search_start, off_t search_end); |
47 | 48 | |
48 | 49 | extern 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); |
50 | 51 | |
51 | 52 | /*** inline functions ****************************************************************************/ |
52 | 53 | #endif /* MC__VIEWER_H */ |