diff options
author | guns <self@sungpae.com> | 2016-05-28 00:45:33 -0500 |
---|---|---|
committer | guns <self@sungpae.com> | 2016-05-28 00:45:33 -0500 |
commit | 36b09fa038a8b7996a12e45419c28821c5596308 (patch) | |
tree | 36e759b0bd5d94fa4ef8817a746f43b6e6e9d5c4 /src/keyevents.c | |
parent | 7db8895f8cfb3d58b8e9b4c7a5a64a4df9bb1af0 (diff) |
Add prev_dir and next_dir navigation actions
Many image collections are organized by directory, so it is nice to have
jump-to-adjacent-directory navigation.
e.g. Given the following file hierarchy:
.
├── A
│ ├── 1.jpg
│ ├── 2.jpg
│ └── C
│ ├── 1.jpg
│ ├── 2.jpg
│ └── 3.jpg
└── B
├── 1.jpg
├── 2.jpg
└── 3.jpg
`feh --recursive` creates the following filelist:
A/1.jpg <---- current_file
A/2.jpg
A/C/1.jpg
A/C/2.jpg
A/C/3.jpg
B/1.jpg
B/2.jpg
B/3.jpg
If we press [next_dir], we move the current_file pointer to:
A/1.jpg
A/2.jpg
A/C/1.jpg <-- current_file
A/C/2.jpg
A/C/3.jpg
B/1.jpg
B/2.jpg
B/3.jpg
Pressing [next_dir] again moves the pointer to:
A/1.jpg
A/2.jpg
A/C/1.jpg
A/C/2.jpg
A/C/3.jpg
B/1.jpg <---- current_file
B/2.jpg
B/3.jpg
[next_dir] now moves the pointer back to the top of the list:
A/1.jpg <---- current_file
A/2.jpg
A/C/1.jpg
A/C/2.jpg
A/C/3.jpg
B/1.jpg
B/2.jpg
B/3.jpg
Pressing [prev_dir] from here moves backwards to the first image of the
previous directory:
A/1.jpg
A/2.jpg
A/C/1.jpg
A/C/2.jpg
A/C/3.jpg
B/1.jpg <---- current_file
B/2.jpg
B/3.jpg
When starting from an position that is not the first image of a
directory, [prev_dir] moves the pointer to the first image of the
current directory.
These actions combine well with `--sort dirname` since all regular files
in a directory will be sorted before any subdirectories, avoiding a
filelist like the following:
A/1.jpg
A/SUBDIR/2.jpg
A/SUBDIR/3.jpg
A/4.jpg
With `--sort dirname` that filelist becomes:
A/1.jpg
A/4.jpg
A/SUBDIR/2.jpg
A/SUBDIR/3.jpg
Diffstat (limited to 'src/keyevents.c')
-rw-r--r-- | src/keyevents.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/keyevents.c b/src/keyevents.c index 8977111..4837c0b 100644 --- a/src/keyevents.c +++ b/src/keyevents.c @@ -110,6 +110,8 @@ void init_keyevents(void) { feh_set_kb(&keys.next_img , 0, XK_Right , 0, XK_n , 0, XK_space); feh_set_kb(&keys.jump_back , 0, XK_Page_Up , 0, XK_KP_Page_Up, 0, 0); feh_set_kb(&keys.jump_fwd , 0, XK_Page_Down , 0, XK_KP_Page_Down,0,0); + feh_set_kb(&keys.prev_dir , 0, XK_bracketleft, 0, 0 , 0, 0); + feh_set_kb(&keys.next_dir , 0, XK_bracketright, 0, 0 , 0, 0); feh_set_kb(&keys.jump_random,0, XK_z , 0, 0 , 0, 0); feh_set_kb(&keys.quit , 0, XK_Escape , 0, XK_q , 0, 0); feh_set_kb(&keys.close , 0, XK_x , 0, 0 , 0, 0); @@ -222,6 +224,10 @@ void init_keyevents(void) { cur_kb = &keys.jump_back; else if (!strcmp(action, "jump_fwd")) cur_kb = &keys.jump_fwd; + else if (!strcmp(action, "prev_dir")) + cur_kb = &keys.prev_dir; + else if (!strcmp(action, "next_dir")) + cur_kb = &keys.next_dir; else if (!strcmp(action, "jump_random")) cur_kb = &keys.jump_random; else if (!strcmp(action, "quit")) @@ -532,6 +538,14 @@ void feh_event_handle_keypress(XEvent * ev) else if (winwid->type == WIN_TYPE_THUMBNAIL) feh_thumbnail_select_next(winwid, 10); } + else if (feh_is_kp(&keys.next_dir, keysym, state)) { + if (opt.slideshow) + slideshow_change_image(winwid, SLIDE_JUMP_NEXT_DIR, 1); + } + else if (feh_is_kp(&keys.prev_dir, keysym, state)) { + if (opt.slideshow) + slideshow_change_image(winwid, SLIDE_JUMP_PREV_DIR, 1); + } else if (feh_is_kp(&keys.quit, keysym, state)) { winwidget_destroy_all(); } |