New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Directory navigation #242

Merged
merged 3 commits into from Jun 2, 2016

Conversation

Projects
None yet
2 participants
@guns
Copy link
Contributor

guns commented May 28, 2016

Hello,

This patch series adds:

  • prev_dir and next_dir actions that navigate to the first image of an adjacent directory
  • --sort dirname: Sort filelist by dirname, then by name. Ensures all regular files in a directory are grouped together
  • A fix for an oversight in menu.c from the --sort mtime patch

prev_dir, next_dir are bound to [, ] by default, but I'm happy to change those if you like.

The patch headers go into more detail, but in short this allows me to use feh to naturally navigate large photo albums that are organized into subdirectories.

Thanks!

guns added some commits May 28, 2016

Add --sort mtime to menu and fix menu when sorting by mtime
We did not preload when SORT_MTIME, so check opt.sort > SORT_MTIME
before offering to sort by file size.

The CB_* enum block was run through s/, /,\n\t/g for legibility.
New sort option: dirname
Sort filelist by dirname, then by name. This results in file entries
sorting before subdirectory entries.

Useful in conjunction with upcoming prev_dir and next_dir navigation
actions.
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
@derf

This comment has been minimized.

Copy link
Owner

derf commented Jun 2, 2016

That looks pretty good, thanks a lot

@derf derf merged commit 36b09fa into derf:master Jun 2, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment