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 75dd1539eaa0d8f175412aebd717150f5f5b16a8

Add present param to form_filetype_menu_entry()
This is a preparation for it being used.
Author: xaizek
Author date (UTC): 2026-10-01 11:01
Committer name: xaizek
Committer date (UTC): 2026-10-01 11:01
Parent(s): c884c2263e23cfe9160bee5190a0a59dfafd5989
Signing key: 99DC5E4DB05F6BE2
Tree: 1016060f89061e6b97403e5920f111521d04f768
File Lines added Lines deleted
src/menus/filetypes_menu.c 16 8
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 } }
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