figure out a way for the user to set default key bindings #83
It would be nice for the user to be able to set default key bindings in their
Currently there are two types of key bindings:
It would be nice to give the user the ability to change both of these key bindings.
That is to say, the user should be able to change the key associated with the menu actions (like
To start of with I really like the idea for this feature. I recently came across Termonad and like using it.
The last thing to do is let the user define their own bindings for menu actions. This could be done by exposing a function like
This way I assume it is fairly easy to write a function that adds all accelerators to the application.
However keep in mind I'm quite new to Haskell.
@burumaj Thanks for thinking about this!
This sounds like a good idea. Here are a couple small additions:
I think this is a little more tricky. If all we want to do is to let the user change key bindings for menu actions, then we need a mapping like the following:
data MenuAction = NewTab | CloseTab | Quit | Copy | Paste defaultMenuActionMap :: Map MenuAction String defaultMenuActionMap = mapFromList [ (NewTab, "<Shift><Ctrl>T") , (CloseTab, "<Shift><Ctrl>W") , ... ]
This should be relatively easy to implement.
However, if we also want to let the user override the actual action that is called, maybe we could have additional hooks:
For instance, instead of:
we could have the following code:
newTabAction <- simpleActionNew "newtab" Nothing void $ onSimpleActionActivate newTabAction $ \_ -> newTabHook actionMapAddAction app newTabAction applicationSetAccelsForAction app "app.newtab" ["<Shift><Ctrl>T"]
I guess we could also have a function like you suggest (
This would be a little more involved then the previous change, but it would make it much more customizable for the end-user.
The next step would be making it fully customizable, so that the end-user could even define which menu options are shown.
Currently the menu is defined in XML here:
This would have to be removed and redone completely in Haskell code. Then it could be made customizable and exposed to the user. I haven't given this a lot of thought, but eventually it would be nice to do.