| File src/menus/filetypes_menu.c changed (mode: 100644) (index ff286b394..0ac691caf) |
| 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 |
45 |
int descr_width); |
int descr_width); |
| 46 |
|
static const char * form_filetype_data_entry(assoc_record_t prog); |
|
| 47 |
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); |
| 48 |
47 |
static KHandlerResponse filetypes_khandler(view_t *view, menu_data_t *m, |
static KHandlerResponse filetypes_khandler(view_t *view, menu_data_t *m, |
| 49 |
48 |
const wchar_t keys[]); |
const wchar_t keys[]); |
| |
| ... |
... |
show_file_menu(view_t *view, int background) |
| 84 |
83 |
|
|
| 85 |
84 |
for(i = 0; i < ft.count; ++i) |
for(i = 0; i < ft.count; ++i) |
| 86 |
85 |
{ |
{ |
| 87 |
|
(void)add_to_string_array(&m.data, m.len, 1, |
|
| 88 |
|
form_filetype_data_entry(ft.list[i])); |
|
|
86 |
|
(void)add_to_string_array(&m.data, m.len, 1, ft.list[i].command); |
| 89 |
87 |
m.len = add_to_string_array(&m.items, m.len, 1, |
m.len = add_to_string_array(&m.items, m.len, 1, |
| 90 |
88 |
form_filetype_menu_entry(ft.list[i], max_len)); |
form_filetype_menu_entry(ft.list[i], max_len)); |
| 91 |
89 |
} |
} |
| |
| ... |
... |
show_file_menu(view_t *view, int background) |
| 95 |
93 |
* kind. */ |
* kind. */ |
| 96 |
94 |
if(ft.count > 0 || magic.count > 0) |
if(ft.count > 0 || magic.count > 0) |
| 97 |
95 |
{ |
{ |
| 98 |
|
(void)add_to_string_array(&m.data, m.len, 1, |
|
| 99 |
|
form_filetype_data_entry(NONE_PSEUDO_PROG)); |
|
|
96 |
|
(void)add_to_string_array(&m.data, m.len, 1, NONE_PSEUDO_PROG.command); |
| 100 |
97 |
m.len = add_to_string_array(&m.items, m.len, 1, ""); |
m.len = add_to_string_array(&m.items, m.len, 1, ""); |
| 101 |
98 |
} |
} |
| 102 |
99 |
#endif |
#endif |
| |
| ... |
... |
show_file_menu(view_t *view, int background) |
| 105 |
102 |
|
|
| 106 |
103 |
for(i = 0; i < magic.count; ++i) |
for(i = 0; i < magic.count; ++i) |
| 107 |
104 |
{ |
{ |
| 108 |
|
(void)add_to_string_array(&m.data, m.len, 1, |
|
| 109 |
|
form_filetype_data_entry(magic.list[i])); |
|
|
105 |
|
(void)add_to_string_array(&m.data, m.len, 1, magic.list[i].command); |
| 110 |
106 |
m.len = add_to_string_array(&m.items, m.len, 1, |
m.len = add_to_string_array(&m.items, m.len, 1, |
| 111 |
107 |
form_filetype_menu_entry(magic.list[i], max_len)); |
form_filetype_menu_entry(magic.list[i], max_len)); |
| 112 |
108 |
} |
} |
| |
| ... |
... |
form_filetype_menu_entry(assoc_record_t prog, int descr_width) |
| 144 |
140 |
return result; |
return result; |
| 145 |
141 |
} |
} |
| 146 |
142 |
|
|
| 147 |
|
/* Returns pointer to a statically allocated buffer */ |
|
| 148 |
|
static const char * |
|
| 149 |
|
form_filetype_data_entry(assoc_record_t prog) |
|
| 150 |
|
{ |
|
| 151 |
|
static char result[PATH_MAX + 1]; |
|
| 152 |
|
snprintf(result, sizeof(result), "%s|%s", prog.description, prog.command); |
|
| 153 |
|
return result; |
|
| 154 |
|
} |
|
| 155 |
|
|
|
| 156 |
143 |
/* Callback that is invoked when menu item is selected. Should return non-zero |
/* Callback that is invoked when menu item is selected. Should return non-zero |
| 157 |
144 |
* to stay in menu mode. */ |
* to stay in menu mode. */ |
| 158 |
145 |
static int |
static int |
| 159 |
146 |
execute_filetype_cb(view_t *view, menu_data_t *m) |
execute_filetype_cb(view_t *view, menu_data_t *m) |
| 160 |
147 |
{ |
{ |
| 161 |
|
const char *const prog_str = strchr(m->data[m->pos], '|') + 1; |
|
|
148 |
|
const char *const prog_str = m->data[m->pos]; |
| 162 |
149 |
if(prog_str[0] != '\0') |
if(prog_str[0] != '\0') |
| 163 |
150 |
{ |
{ |
| 164 |
151 |
int background = m->extra_data & 1; |
int background = m->extra_data & 1; |
| |
| ... |
... |
filetypes_khandler(view_t *view, menu_data_t *m, const wchar_t keys[]) |
| 177 |
164 |
{ |
{ |
| 178 |
165 |
if(wcscmp(keys, L"c") == 0) |
if(wcscmp(keys, L"c") == 0) |
| 179 |
166 |
{ |
{ |
| 180 |
|
const char *const prog_str = after_first(m->data[m->pos], '|'); |
|
|
167 |
|
const char *const prog_str = m->data[m->pos]; |
| 181 |
168 |
if(prog_str[0] != '\0') |
if(prog_str[0] != '\0') |
| 182 |
169 |
{ |
{ |
| 183 |
170 |
menu_morph_into_cmdline(CLS_COMMAND, prog_str, 1); |
menu_morph_into_cmdline(CLS_COMMAND, prog_str, 1); |