xaizek / vifm (License: GPLv2+) (since 2018-12-07)
Vifm is a file manager with curses interface, which provides Vi[m]-like environment for managing objects within file systems, extended with some useful ideas from mutt.
Commit 33f393f3130b684d27814b0cb6af8c529e22cdbb

Simplify data of :file menu
It contained commands description even though it's not being used.
Author: xaizek
Author date (UTC): 2020-02-06 23:11
Committer name: xaizek
Committer date (UTC): 2020-02-06 23:11
Parent(s): 14dc03ec784d2eb215cbcbf238061235f3284d92
Signing key: 99DC5E4DB05F6BE2
Tree: 9ead115cc32ac616ab3bb27dd2b683ffebe36f88
File Lines added Lines deleted
src/menus/filetypes_menu.c 5 18
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);
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/vifm

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/vifm

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master