swarm-game / swarm

Resource gathering + programming game
Other
835 stars 52 forks source link

Customizable keybindings #523

Closed byorgey closed 2 months ago

byorgey commented 2 years ago

Is your feature request related to a problem? Please describe. It always takes me a second to think about the right key shortcut to get to the panel I want, and it's annoying.

Describe the solution you'd like Personally, I think I would find it more natural if the key shortcuts were arranged physically on the keyboard in a way that mirrors the physical layout of the panels. For example, I would like

M-w : inventory       M-e : world
M-s : info panel       M-d : REPL

However, I doubt everyone will agree! Some people might use a different keyboard layout. Some people might simply prefer different keys.

The most general solution would be a way to configure keyboard shortcuts, i.e. some kind of "configuration" menu that would let you set whatever shortcuts you like (and, in time, other things as well). Configuration should be stored in $XDG_CONFIG_HOME so that it would be persistent across runs of the app.

jtdaugherty commented 2 years ago

@byorgey FYI, matterhorn has such a keybinding configuration system. You are welcome to rip off any/all of it that you like. The core of it shouldn't be too tightly coupled to Matterhorn and could probably be abstracted just a tad (e.g. on key event handler monad). I haven't thought much about whether Matterhorn's functionality could be cleanly factored out as a separate package, but I know that many brick applications are probably going to want this and it would be sad to reinvent the wheel.

byorgey commented 2 years ago

@jtdaugherty thanks for the tip! We will definitely check that out.

jtdaugherty commented 2 years ago

I have some time today so I'm starting to hack on a branch to factor out as much of the configuration and keybinding machinery as possible. It's on this branch and I'll update here once I reach some kind of stopping point.

jtdaugherty commented 2 years ago

Brick 1.1 is out with some important API changes/additions relevant to this ticket.

xsebek commented 1 year ago

A detailed How-To is in the brick guide:

Demo program:

With the relevant documentation:


Looks like a bit of refactoring will be needed but it should be mostly automatic. :slightly_smiling_face: