Window functions
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
WindowCommandEnum, defining the commands throughWindowCommand.send_to_window(). If the user gives a key in thekey : WindowCommandHashMapwindow_cmd_mapthen we select that command, otherwise we default toWindowCommand::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!
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.
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 :)
Hi, is there anything else I should do? I'm not too familiar with open source stuff?