ArielHorwitz / hummingparrot

A TUI client for OpenAI chat
0 stars 0 forks source link

Configurable hotkeys #7

Closed ArielHorwitz closed 11 hours ago

ArielHorwitz commented 1 week ago

Hotkeys are hardcoded and not documented anywhere. They should be configurable in config.toml.

FriedlandAaron commented 1 week ago

Started working on this in a new branch. Really messy and dirty, will clean it up a bit later (it does work though). The general idea is:

This will allow us to make it configurable later using the config file

ArielHorwitz commented 1 week ago

Awesome!

Also, now that I see collaboration I'll make sure to PR before merging in main :)

ArielHorwitz commented 1 week ago

The solution is great, imo.

A suggestion that may make it less messy: add a "scope" to the code+modifiers that determines when the hotkey is active. E.g. a "global" scope is always active, while "conversation" and "config" scopes are only active in the respective tabs. I call it scope because that's what I've seen it called in other programs.

FriedlandAaron commented 1 week ago

A suggestion that may make it less messy: add a "scope" to the code+modifiers that determines when the hotkey is active. E.g. a "global" scope is always active, while "conversation" and "config" scopes are only active in the respective tabs. I call it scope because that's what I've seen it called in other programs.

This was something I was having thoughts about, wasn't sure yet about the implementation. At first I was thinking maybe adding a layer of indirection in the Hashmap itself, first mapping to "scope" and then to the hotkeys, then I thought about holding separate maps for separate "scopes". I guess a simpler solution would be to just add it to the tuple, which would also theoretically allow the same hotkey to be used for different purposes in different "scopes". Not sure if this is a desirable feature, just kind of cool conceptually :stuck_out_tongue:

ArielHorwitz commented 1 week ago

Yeah I think just having a Hotkey struct with scope, key, and modifier would be good. Also, using the same hotkey in different scopes should be desirable (most obvious being Enter or arrow keys). This may also mean that it's worth considering subdividing the HotkeyAction enum by scope...

FriedlandAaron commented 1 week ago

Actually, I don't think the HotkeyAction enum would need to be subdivided in that case. That's the beauty of that abstraction layer, the action can be independent of the hotkey, and the mapping will hold whatever hotkeys and scopes do whichever actions.