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

Window functions #180

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open

Conversation

CMJones001
Copy link

Implementation of #179 allowing for more complex actions a window, by giving a command key before selecting the window.

Currently, this adds x to kill the window and q to toggle floating, although this can be extended to much more complex functions. A full screen command and a split and launch [x] seem like good next candidates.

The main points:

  • We add a WindowCommand Enum, defining the commands through WindowCommand.send_to_window(). If the user gives a key in the key : WindowCommand HashMap window_cmd_map then we select that command, otherwise we default to WindowCommand::Focus.

  • The command keys are currently hard-coded, but if you're happy with the implementation, I'll add something to the command line args. --kill-window-char [x] and --focus-window-char [x] are pretty verbose, but seem to be the simplest way of allowing the user to configure the keys?

  • The Emacs packages used as reference silently ignores any keys used for commands, if they are also present in the hint_chars, however, I've decided to make this explicitly return an error, which seems more in line with Rust.

Happy for any other feedback!

Copy link
Owner

@svenstaro svenstaro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean and simple, I like it! Great feature, too! I'd like for the keys to be customizable the way you already mentioned. Please also document this stuff in the README and write a small blip for the CHANGELOG. :)

src/utils.rs Show resolved Hide resolved
src/utils.rs Outdated Show resolved Hide resolved
src/utils.rs Show resolved Hide resolved
src/main.rs Outdated Show resolved Hide resolved
src/main.rs Outdated Show resolved Hide resolved
src/main.rs Outdated Show resolved Hide resolved
@CMJones001
Copy link
Author

This should cover most of your comments, in particular, merging the logic of the window selection and command selection better.

Now we add the command character to the pressed_keys if it is pressed at the start of the sequence (ignored otherwise) and the command selection logic is moved until later, so we can remove the extra mut.

Maybe pressed_keys could do with being refactored to a struct and moving the command keys to a field rather than doing string parsing? But, this is the most I can do for now, before the weekend.

@CMJones001
Copy link
Author

I've added configuration options for --kill-window-char and --float-window-char. I'm not too familiar with Clap, so I'm not sure if there's a more elegant way of doing things.

The README and CHANGELOG are also updated :)

@CMJones001
Copy link
Author

Hi, is there anything else I should do? I'm not too familiar with open source stuff?

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

Successfully merging this pull request may close these issues.

None yet

2 participants