Skip to content
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

Support counts in commands #86

Open
tremby opened this issue Aug 9, 2017 · 8 comments
Open

Support counts in commands #86

tremby opened this issue Aug 9, 2017 · 8 comments

Comments

@tremby
Copy link
Collaborator

tremby commented Aug 9, 2017

I imagine this will be quite an undertaking, but if we want PMS to be more vim-like (and I certainly do) it needs to support counts before commands. For example 4j to move the cursor down four times, 2gt to go to the second tab.

@tremby tremby changed the title Support counts before commands Support counts in commands Aug 9, 2017
@kimtore
Copy link
Owner

kimtore commented Aug 10, 2017

Absolutely. I support this idea. I don't imagine it will be an enormous amount of work, since all commands already support operating on a selection of tracks.

@tremby
Copy link
Collaborator Author

tremby commented Aug 10, 2017

I'm wondering how this would work. Would the system dispatch a single command which now has a new concept of the count being passed to it, or would it dispatch the regular command count times?

I imagine it'd have to be the former, because gt gt is not the same as 2gt.

@tremby
Copy link
Collaborator Author

tremby commented Aug 10, 2017

Each command would have to define what the count means to it, I think.

From an architecture point of view, what about this?

Command stays as it is. Things which directly implement Command don't support counts, and you get an error if you try to call them with a count.

A new class CountableCommand (or something) descends from Command an accepts a count, and it is passed to the handler method as an extra argument. The command decides what to do with this.

For convenience, a new class RepeatableCommand (or something) descends from CountableCommand and handles the count by simply running its handler count times.

(I don't know Go -- totally likely a different architecture is better!)

@kimtore
Copy link
Owner

kimtore commented Aug 11, 2017

The Command class should definitely be aware of the count, and execute as needed. Otherwise, e.g. 1000x would send thousand commands to the MPD server, instead of issuing a single command.

Is there anything to be gained from separating "one-off" commands from countable commands on a class level? In my opinion, it gains nothing except adding complexity. If the command explicitly does not support counting, it could just return an error.

@tremby
Copy link
Collaborator Author

tremby commented Aug 11, 2017 via email

@kimtore
Copy link
Owner

kimtore commented Aug 11, 2017

I'm not really certain it would be boilerplate code. As every command would have to handle the count, they might as well implement their functions to be countable from the start. As for the commands that doesn't support count or it doesn't make sense (such as play, pause, stop, single, repeat, etc.) they could also possibly silently ignore the counter?

@tremby
Copy link
Collaborator Author

tremby commented Aug 11, 2017 via email

@kimtore
Copy link
Owner

kimtore commented Sep 9, 2017

This is related to #92.

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

No branches or pull requests

2 participants