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 7a43116aa611ad69dadc99012a5e1d20cba73caa

Simplify Enter handling in :file menu
The "is a directory and first menu entry" check is awfully
counter-intuitive, moreover it's not even needed. `rn_open_with()`
handles `VIFM_PSEUDO_CMD` by calling `rn_enter()`.

The change also allows to stop exporting rn_enter().
Author: xaizek
Author date (UTC): 2020-02-06 17:26
Committer name: xaizek
Committer date (UTC): 2020-02-06 17:26
Parent(s): 7f780beb57c97552bd2c420c7dfff47814f0cafd
Signing key: 99DC5E4DB05F6BE2
Tree: 78485b393a2aa747920dd9ed079d8af6f06e45f7
File Lines added Lines deleted
src/menus/filetypes_menu.c 4 11
src/running.c 7 5
src/running.h 0 3
File src/menus/filetypes_menu.c changed (mode: 100644) (index 9e98bdf5c..ff286b394)
... ... form_filetype_data_entry(assoc_record_t prog)
158 158 static int static int
159 159 execute_filetype_cb(view_t *view, menu_data_t *m) execute_filetype_cb(view_t *view, menu_data_t *m)
160 160 { {
161 if(get_current_entry(view)->type == FT_DIR && m->pos == 0)
161 const char *const prog_str = strchr(m->data[m->pos], '|') + 1;
162 if(prog_str[0] != '\0')
162 163 { {
163 rn_enter(view);
164 }
165 else
166 {
167 const char *const prog_str = strchr(m->data[m->pos], '|') + 1;
168 if(prog_str[0] != '\0')
169 {
170 int background = m->extra_data & 1;
171 rn_open_with(view, prog_str, 0, background);
172 }
164 int background = m->extra_data & 1;
165 rn_open_with(view, prog_str, 0, background);
173 166 } }
174 167
175 168 flist_sel_stash(view); flist_sel_stash(view);
File src/running.c changed (mode: 100644) (index b14236eb9..24cb55fcd)
... ... static void run_implicit_prog(view_t *view, const char prog_spec[], int pause,
105 105 int force_bg); int force_bg);
106 106 static void view_current_file(const view_t *view); static void view_current_file(const view_t *view);
107 107 static void follow_link(view_t *view, int follow_dirs); static void follow_link(view_t *view, int follow_dirs);
108 static void enter_dir(struct view_t *view);
108 109 static int cd_to_parent_dir(view_t *view); static int cd_to_parent_dir(view_t *view);
109 110 static void extract_last_path_component(const char path[], char buf[]); static void extract_last_path_component(const char path[], char buf[]);
110 111 static void setup_shellout_env(void); static void setup_shellout_env(void);
 
... ... handle_file(view_t *view, FileHandleExec exec, FileHandleLink follow)
177 178 { {
178 179 if(!curr->selected && (curr->type != FT_LINK || follow == FHL_NO_FOLLOW)) if(!curr->selected && (curr->type != FT_LINK || follow == FHL_NO_FOLLOW))
179 180 { {
180 rn_enter(view);
181 enter_dir(view);
181 182 return; return;
182 183 } }
183 184 } }
 
... ... run_with_defaults(view_t *view)
455 456 { {
456 457 if(get_current_entry(view)->type == FT_DIR) if(get_current_entry(view)->type == FT_DIR)
457 458 { {
458 rn_enter(view);
459 enter_dir(view);
459 460 } }
460 461 else if(view->selected_files <= 1) else if(view->selected_files <= 1)
461 462 { {
 
... ... rn_open_with(view_t *view, const char prog_spec[], int dont_execute,
541 542 } }
542 543 else if(strcmp(prog_spec, VIFM_PSEUDO_CMD) == 0) else if(strcmp(prog_spec, VIFM_PSEUDO_CMD) == 0)
543 544 { {
544 rn_enter(view);
545 enter_dir(view);
545 546 } }
546 547 else if(strchr(prog_spec, '%') != NULL) else if(strchr(prog_spec, '%') != NULL)
547 548 { {
 
... ... follow_link(view_t *view, int follow_dirs)
705 706 free(dir); free(dir);
706 707 } }
707 708
708 void
709 rn_enter(view_t *view)
709 /* Handles opening of current entry of the view as a directory. */
710 static void
711 enter_dir(view_t *view)
710 712 { {
711 713 char full_path[PATH_MAX + 1]; char full_path[PATH_MAX + 1];
712 714
File src/running.h changed (mode: 100644) (index 4bcb2a703..2dc632e5c)
... ... void rn_follow(struct view_t *view);
55 55 void rn_open_with(struct view_t *view, const char prog_spec[], int dont_execute, void rn_open_with(struct view_t *view, const char prog_spec[], int dont_execute,
56 56 int force_bg); int force_bg);
57 57
58 /* Handles opening of current entry of the view as directory. */
59 void rn_enter(struct view_t *view);
60
61 58 /* Moves the view to levels-th parent directory taking care of special cases /* Moves the view to levels-th parent directory taking care of special cases
62 59 * like root of FUSE mount. */ * like root of FUSE mount. */
63 60 void rn_leave(struct view_t *view, int levels); void rn_leave(struct view_t *view, int levels);
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