wmfocus icon indicating copy to clipboard operation
wmfocus copied to clipboard

Window functions

Open CMJones001 opened this issue 3 years ago • 3 comments

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!

CMJones001 avatar Jun 08 '22 19:06 CMJones001

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 avatar Jun 09 '22 20:06 CMJones001

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 avatar Jun 15 '22 18:06 CMJones001

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

CMJones001 avatar Jun 30 '22 18:06 CMJones001