kimtore / pms

Practical Music Search is an interactive Vim-like console client for the Music Player Daemon.
https://ambientsound.github.io/pms/
MIT License
250 stars 23 forks source link

Add cursor high/middle/low commands #76

Closed tremby closed 7 years ago

tremby commented 7 years ago

Moving the cursor to the top, middle, or bottom of the currently-visible viewport, like vim's H, M, L.

Closes ambientsound/pms#64

codecov-io commented 7 years ago

Codecov Report

Merging #76 into master will decrease coverage by 0.37%. The diff coverage is 25%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #76      +/-   ##
==========================================
- Coverage   53.99%   53.62%   -0.38%     
==========================================
  Files          49       50       +1     
  Lines        1702     1738      +36     
==========================================
+ Hits          919      932      +13     
- Misses        761      784      +23     
  Partials       22       22
Impacted Files Coverage Δ
options/defaults.go 0% <ø> (ø) :arrow_up:
commands/cursor.go 62.6% <25%> (-4.39%) :arrow_down:
commands/command.go 65.45% <0%> (ø) :arrow_up:
topbar/elapsed.go 0% <0%> (ø) :arrow_up:
commands/unbind.go 76.92% <0%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 31cddb5...0ee83ad. Read the comment docs.

kimtore commented 7 years ago

Very nice. How about default keyboard bindings, matching Vim's H, M, L?

tremby commented 7 years ago

I wanted to do this, but M is already taken (toggle mute). And m is defaulting to mark the current item.

I personally would move volume down to = (so same key as volume up), "mark" to - (like mutt), then mute to m, then middle to M. But that's me. What do you think?

kimtore commented 7 years ago

In Mutt, as far as I know, t is tag and - is flag. Unfortunately, t and T is used for next/previous windows. Maybe these keys could be remapped, and t used for tag/mark? As for mute, I don't consider it a particularly useful function, as we have pause which more or less accomplishes the same thing. I vote changing the default binding for mute. Any suggestions for which key?

Regarding the same physical key for the volume, you're referring to e.g. the US keyboard layout. Not all layouts have this property. Personally, I think it's more intuitive to use plus and minus (or other complementing keys).

tremby commented 7 years ago

Oh! I guess I'm getting my own mutt configuration confused with the defaults. I haven't changed it in years.

gt and gT for changing tabs would match vim, and is what I've now bound in PMS.

So we could have...

Regarding the same physical key for the volume, you're referring to e.g. the US keyboard layout. Not all layouts have this property. Personally, I think it's more intuitive to use plus and minus (or other complementing keys).

Very good point. Surprised I overlooked that: I don't even know what the Dvorak layout will be like for the new keyboard I'm hopefully getting soon!

kimtore commented 7 years ago

It's obvious that there should there should be a larger discussion on the keyboard bindings. I agree that PMS should try to match Vim as closely as possible, while still preserving single keystrokes for actions that are used most of the time.

Maybe previous and next tracklist could be mapped to h and l, since the tracklist provides only the vertical axis anyway?

<Mod-M> for mute sounds like a good idea. So then we have space for the HMS keys?

Also, what a wicked keyboard :grin: let me know how it works out for you!

tremby commented 7 years ago

I'm not convinced that a single keystroke for next and previous tab is necessary. How about gt and gT as the primary commands, but also <tab> to move to the next tab? Do you often have more than a few open, so many that you need a single-stroke "previous tab" binding? (If shift-tab is usable, that could be backwards, and would be very intuitive.)

I'd much rather leave h and l seeking back and forward a short amount. I'm looking forward to counts being available, because then we have a very nice 30l, 10h etc, which would feel just like vim. :D

I was going to suggest [ and ] as an alternative. I usually have these going through albums, but I just had the idea that now that multi-stroke bindings are supported I'll likely change these to act more like [ and ] in vim, i.e. as next/prev prefixes for movements through logical chunks of content. ]a for next artist, ]b for next album, etc.

Is any particular mod for mod-M for mute better than another? Ctrl? Meta?

kimtore commented 7 years ago

I was planning on using <Tab> as a back-and-forth switch between the playlist and the active list.

The hjkl keys are in Vim used for horizontal and vertical navigation. In a text file, there are columns and rows. Moving to PMS, this can be visualized as lists and tracks. And for what it's worth, I don't anticipate that people will be seeking in tracks too much.

So while I do support the idea of using gt and gT, I also feel that they should be default mapped to l and h, respectively.

As for <C-m> it's not really possible to map it, because it also maps to <Return> (possibly before it even reaches the terminal application). <Meta> use is discouraged by the author of tcell, so I wouldn't want to use it for a default.

tremby commented 7 years ago

I seek somewhat often. I see seeking with one keystroke bring significantly more useful than switching tabs with one keystroke, since it's an action with a real-time effect you are often going to want to repeat immediately. But if you disagree that's totally fine and I can remap.

So if not control and not meta, which mod key with m for mute?

kimtore commented 7 years ago

Ah, I was mistaking Alt for Mod. Just <Alt-M> for mute?

Really, I think it makes more sense to have tab switching on h and l, since it's likely one will travel through a lot of lists in order to reach the right one. Also I'd like to avoid as much as possible "disturbing" actions such as seek, stop, play, etc. on the regular keys.

tremby commented 7 years ago

Isn't alt the same as meta? You said it's discouraged. But for something like mute, maybe that's not a big deal?

OK: h and l for scrolling through lists, as well as gt and gT. I almost never have more than just the library and active playlist so maybe that's why I don't agree with your line of thinking. But that's OK!

kimtore commented 7 years ago

Alt isn't the same as Meta. So, to recap pending changes in this patch:

tremby commented 7 years ago

Should be done. I wasn't able to test the Alt-M binding right now on a Mac through SSH and tmux, but I think it's likely it's a configuration thing. Please check that I've used the right syntax.