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 34d08f490b89298fec5ad611d5bea0a9ae2975e3

Extract src/modes/view.c:get_viewer_index()
Retrieves index of the current viewer in the mode-specific list of
viewers.
Author: xaizek
Author date (UTC): 2025-08-22 08:22
Committer name: xaizek
Committer date (UTC): 2025-08-22 08:22
Parent(s): 8731e0744cb5501162aaa9824069623c74988447
Signing key: 99DC5E4DB05F6BE2
Tree: 499eca889aeb5a3e0ea73c40226584783565c791
File Lines added Lines deleted
src/modes/view.c 19 9
File src/modes/view.c changed (mode: 100644) (index 4c5a1051c..efa912162)
... ... static void pick_current_viewer(modview_info_t *vi);
174 174 static void replace_vi(modview_info_t *orig, modview_info_t *new); static void replace_vi(modview_info_t *orig, modview_info_t *new);
175 175 static void cmd_a(key_info_t key_info, keys_info_t *keys_info); static void cmd_a(key_info_t key_info, keys_info_t *keys_info);
176 176 static void switch_viewer(modview_info_t *vi, int offset); static void switch_viewer(modview_info_t *vi, int offset);
177 static int get_viewer_index(const modview_info_t *vi);
177 178 static void cmd_b(key_info_t key_info, keys_info_t *keys_info); static void cmd_b(key_info_t key_info, keys_info_t *keys_info);
178 179 static void cmd_d(key_info_t key_info, keys_info_t *keys_info); static void cmd_d(key_info_t key_info, keys_info_t *keys_info);
179 180 static void cmd_f(key_info_t key_info, keys_info_t *keys_info); static void cmd_f(key_info_t key_info, keys_info_t *keys_info);
 
... ... switch_viewer(modview_info_t *vi, int offset)
1234 1235 return; return;
1235 1236 } }
1236 1237
1237 int i;
1238 for(i = 0; i < vi->viewers.nitems; ++i)
1239 {
1240 if(vi->viewers.items[i] == vi->curr_viewer)
1241 {
1242 break;
1243 }
1244 }
1245 if(i == vi->viewers.nitems)
1238 int i = get_viewer_index(vi);
1239 if(i < 0)
1246 1240 { {
1247 1241 return; return;
1248 1242 } }
 
... ... switch_viewer(modview_info_t *vi, int offset)
1260 1254 reload_view(vi, NOSILENT); reload_view(vi, NOSILENT);
1261 1255 } }
1262 1256
1257 /* Retrieves index of the current viewer. Returns the index or -1. */
1258 static int
1259 get_viewer_index(const modview_info_t *vi)
1260 {
1261 int i;
1262 for(i = 0; i < vi->viewers.nitems; ++i)
1263 {
1264 if(vi->viewers.items[i] == vi->curr_viewer)
1265 {
1266 return i;
1267 }
1268 }
1269
1270 return -1;
1271 }
1272
1263 1273 static void static void
1264 1274 cmd_b(key_info_t key_info, keys_info_t *keys_info) cmd_b(key_info_t key_info, keys_info_t *keys_info)
1265 1275 { {
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