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

Feature request: Allow toggle marks using <space> instead of Mark/Unmark keys #18

Open
eugenesan opened this issue Jun 4, 2024 · 8 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@eugenesan
Copy link

It would be nice to have an option to toggle marks using instead of Mark/Unmark keys

@drdo drdo added the enhancement New feature or request label Jun 6, 2024
@drdo
Copy link
Owner

drdo commented Jun 6, 2024

What would the use case for this be?

@eugenesan
Copy link
Author

Using the same key for marking/unmarking is much quicker.
No need to move the fingers or think about which key to use when correcting a mistake.

Also, it is how virtually all User Interfaces worked since the dawn of computing ;-)

@drdo
Copy link
Owner

drdo commented Jun 6, 2024

I wouldn't say that's how all UIs work.

redu takes inspiration from Emacs' dired, it even uses the same keys.

@drdo
Copy link
Owner

drdo commented Jun 6, 2024

My concern with having a toggle rather than separate keys is that I find that it's easier to make mistakes when moving around fast marking files.

With separate keys each action is idempotent, if you press the key one too many times it doesn't make a difference.

@eugenesan
Copy link
Author

eugenesan commented Jun 6, 2024

I guess it's a balance between tracking more keys and more visual information.

For most people, using the same key/button is more natural.
Example 1: When dealing with a list of radio buttons or checklists most people expect to use left-button or space key to toggle and not two different keys/buttons to set and unset.
Example 2: When selecting files in a file manager, you are expected to use CTRL+Left in GUI and Space/INS/Ctrl-T in TUI.

In any case, we could have both options and it's up to you.

@drdo drdo added the good first issue Good for newcomers label Jul 23, 2024
@drdo
Copy link
Owner

drdo commented Jul 23, 2024

My main concern was about taking up such a prime key for this task.
But I suppose that marking is a central operation and it's not unreasonable.

If you want to create a PR with this I'm happy to accept it :)

@eugenesan
Copy link
Author

My main concern was about taking up such a prime key for this task. But I suppose that marking is a central operation and it's not unreasonable.

If you want to create a PR with this I'm happy to accept it :)

I already made 2 attempts but my Rust is very rusty ;-)
I'll have to work on that sometime in the future when I'll have free time to actually learn rust.

No rush though, redu is an excellent helper as it is today.
Much better than what I was doing before, manually scanning repos and manually creating lists!

Feel free to close the issue.

@drdo
Copy link
Owner

drdo commented Jul 24, 2024

My main concern was about taking up such a prime key for this task. But I suppose that marking is a central operation and it's not unreasonable.
If you want to create a PR with this I'm happy to accept it :)

I already made 2 attempts but my Rust is very rusty ;-) I'll have to work on that sometime in the future when I'll have free time to actually learn rust.

No rush though, redu is an excellent helper as it is today. Much better than what I was doing before, manually scanning repos and manually creating lists!

Feel free to close the issue.

I would suggest understanding how the flow works for example for deleting a mark, then implementing a toggle should be very similar.

At a high level the event loop goes like this:

  1. Terminal event is read and converted from a raw key event to something a bit more high level with semantic meaning. See
    let mut o_event = convert_event(crossterm::event::read()?);
  2. We call the update function on the UI code with this event and get back some action that we should perform. See
    o_event = match app.update(event) {
    and

    redu/src/ui.rs

    Line 151 in 2e5bff7

    Unmark => self.unmark_selection(),
  3. We perform the action which might result in additional events which we feed back to the UI via update again. See
    Action::DeleteMark(loc) => {
  4. When there's no more events resulting from this action go back to 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants