| File src/menus/filetypes_menu.c changed (mode: 100644) (index 7872196b3..d966c1148) |
| 42 |
42 |
#include "menus.h" |
#include "menus.h" |
| 43 |
43 |
|
|
| 44 |
44 |
static const char * form_filetype_menu_entry(assoc_record_t prog, |
static const char * form_filetype_menu_entry(assoc_record_t prog, |
| 45 |
|
int descr_width); |
|
|
45 |
|
int descr_width, int present); |
| 46 |
46 |
static int execute_filetype_cb(view_t *view, menu_data_t *m); |
static int execute_filetype_cb(view_t *view, menu_data_t *m); |
| 47 |
47 |
static KHandlerResponse filetypes_khandler(view_t *view, menu_data_t *m, |
static KHandlerResponse filetypes_khandler(view_t *view, menu_data_t *m, |
| 48 |
48 |
const wchar_t keys[]); |
const wchar_t keys[]); |
| |
| ... |
... |
show_file_menu(view_t *view, int background) |
| 84 |
84 |
for(i = 0; i < ft.count; ++i) |
for(i = 0; i < ft.count; ++i) |
| 85 |
85 |
{ |
{ |
| 86 |
86 |
(void)add_to_string_array(&m.data, m.len, ft.list[i].command); |
(void)add_to_string_array(&m.data, m.len, ft.list[i].command); |
| 87 |
|
const char *entry = form_filetype_menu_entry(ft.list[i], max_len); |
|
|
87 |
|
const char *entry = |
|
88 |
|
form_filetype_menu_entry(ft.list[i], max_len, /*present=*/-1); |
| 88 |
89 |
m.len = add_to_string_array(&m.items, m.len, entry); |
m.len = add_to_string_array(&m.items, m.len, entry); |
| 89 |
90 |
} |
} |
| 90 |
91 |
|
|
| |
| ... |
... |
show_file_menu(view_t *view, int background) |
| 103 |
104 |
for(i = 0; i < magic.count; ++i) |
for(i = 0; i < magic.count; ++i) |
| 104 |
105 |
{ |
{ |
| 105 |
106 |
(void)add_to_string_array(&m.data, m.len, magic.list[i].command); |
(void)add_to_string_array(&m.data, m.len, magic.list[i].command); |
| 106 |
|
const char *entry = form_filetype_menu_entry(magic.list[i], max_len); |
|
|
107 |
|
const char *entry = |
|
108 |
|
form_filetype_menu_entry(magic.list[i], max_len, /*present=*/-1); |
| 107 |
109 |
m.len = add_to_string_array(&m.items, m.len, entry); |
m.len = add_to_string_array(&m.items, m.len, entry); |
| 108 |
110 |
} |
} |
| 109 |
111 |
|
|
| 110 |
112 |
return menus_enter(&m, view); |
return menus_enter(&m, view); |
| 111 |
113 |
} |
} |
| 112 |
114 |
|
|
| 113 |
|
/* Returns pointer to a statically allocated buffer */ |
|
|
115 |
|
/* Composes a single menu entry. The present parameter is tri-state with a |
|
116 |
|
* negative value meaning "determine". Returns pointer to a statically |
|
117 |
|
* allocated buffer. */ |
| 114 |
118 |
static const char * |
static const char * |
| 115 |
|
form_filetype_menu_entry(assoc_record_t prog, int descr_width) |
|
|
119 |
|
form_filetype_menu_entry(assoc_record_t prog, int descr_width, int present) |
| 116 |
120 |
{ |
{ |
| 117 |
121 |
static char result[PATH_MAX + 1]; |
static char result[PATH_MAX + 1]; |
| 118 |
122 |
|
|
| 119 |
|
int found = ft_exists(prog.command); |
|
| 120 |
|
const char *found_msg = (found ? "[present] " : " "); |
|
|
123 |
|
if(present < 0) |
|
124 |
|
{ |
|
125 |
|
present = ft_exists(prog.command); |
|
126 |
|
} |
|
127 |
|
const char *found_msg = (present ? "[present] " : " "); |
| 121 |
128 |
|
|
| 122 |
129 |
char descr[64]; |
char descr[64]; |
| 123 |
130 |
descr[0] = '\0'; |
descr[0] = '\0'; |
| |
| ... |
... |
fill_menu_from_records(menu_data_t *m, const assoc_records_t *records) |
| 217 |
224 |
|
|
| 218 |
225 |
for(i = 0; i < records->count; ++i) |
for(i = 0; i < records->count; ++i) |
| 219 |
226 |
{ |
{ |
| 220 |
|
const char *entry = form_filetype_menu_entry(records->list[i], max_len); |
|
|
227 |
|
const char *entry = |
|
228 |
|
form_filetype_menu_entry(records->list[i], max_len, /*present=*/-1); |
| 221 |
229 |
m->len = add_to_string_array(&m->items, m->len, entry); |
m->len = add_to_string_array(&m->items, m->len, entry); |
| 222 |
230 |
} |
} |
| 223 |
231 |
} |
} |