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

Take Numeric arguments for Actions #48

Closed
Davejkane opened this issue May 15, 2019 · 5 comments · Fixed by #87
Closed

Take Numeric arguments for Actions #48

Davejkane opened this issue May 15, 2019 · 5 comments · Fixed by #87
Assignees
Labels
enhancement New feature or request help wanted Extra attention is needed
Milestone

Comments

@Davejkane
Copy link
Owner

Goal

Allow current operations to take numeric arguments, a la vim. For example, 5j would move through 5 images. 10d would delete the next 10 images (😱). 11G would go to the 11th image, etc.

Implementation

We're probably going to want to group all numeric keypresses to enter some kind of new State-Machine state. From there, further numeric keypresses will augment the number, and non-numeric keypresses will potentially dispatch an Action.

  • Numeric keypresses will be both number keys AND numpad keys. They are probably separate key events in SDL.
  • Alter the Action enum to contain numeric data (probably usize) for variants that would be valid for numeric operations
  • Probably want a state machine enum, with Normal being the current app behaviour, and Numeric being the new state.
  • If in the Numeric state, we probably want separate keyhandling code. But output should be the same Action enum as the regular keyhandling code (now containing data).
  • Update all of the Program methods that can, to take a numeric argument. E.g. move, delete, copy. (Increment and decrement already do)
  • When we enter the numeric state, we probably want to take over info bar and display the current number that builds as the user types. If an invalid argument follows from the numeric state, print a message on the infobar (this will mean refactoring the info bar to accept messages, which will also be useful later).
@Davejkane Davejkane added enhancement New feature or request help wanted Extra attention is needed labels May 15, 2019
@Davejkane Davejkane added this to the 0.4 milestone May 15, 2019
@gurgalex
Copy link
Collaborator

Hiya, I'd work to work on this if anybody else hasn't.

@gurgalex
Copy link
Collaborator

Questions.

10d
Would delete the next 10 images. The currently shown image would not be deleted.

If on image "2 of 5", images 1-2 would remain. While 3-5 are deleted.

Maybe an option or other key or key combo to be inclusive.

@Davejkane
Copy link
Owner Author

No, the current image would be deleted and 10 in total. At least that's how it works in vim

@gurgalex
Copy link
Collaborator

@Davejkane
What should the errors be like if copying 5 out of 50 images succeeds?

Should the program continuing moving/deleting/copying files if it encounters at least one that already exists, or fails for another reason.

@Davejkane
Copy link
Owner Author

@gurgalex I would suggest to keep processing in the event of an error and the error message should indicate how many images failed to copy/move/delete. You may want to still eprintln! on each failure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants