Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add keybindingINIList output to Brick.Keybindings.Pretty #513

Open
xsebek opened this issue Jul 9, 2024 · 5 comments
Open

Add keybindingINIList output to Brick.Keybindings.Pretty #513

xsebek opened this issue Jul 9, 2024 · 5 comments

Comments

@xsebek
Copy link
Contributor

xsebek commented Jul 9, 2024

I want to show users the current/default keybindings configuration. The output should look like this:

[keybindings]

;;;; Section name

;; Description of binding customized by user
quit = Alt-F4

;; Description of binding with default
; help = F1

In Swarm, I wrote keyBindingINI (which uses helper keybindingEventINI) by following the example of keybindingTextTable.
The code is essentially duplicated, though I opted to ignore non-customizable bindings for the INI output.

It would be nice if this was provided by Brick, as an inverse to keybindingsFromIni.

@jtdaugherty
Copy link
Owner

I am open to adding something like this to brick. If I did, it would be shaped something like this:

data INIGenerationConfig =
    INIGenerationConfig { includeDescriptions :: Bool
                        , includeCustomizedBindings :: Bool
                        }

defaultINIGenerationConfig :: INIGenerationConfig
defaultINIGenerationConfig =
    INIGenerationConfig { includeDescriptions = True
                        , includeCustomizedBindings = True
                        }

keybindingsToIni :: INIGenerationConfig -> KeyConfig k -> Text

and would produce a hunk of INI text compatible with keybindingsFromIni.

Would that work for your purposes?

@xsebek
Copy link
Contributor Author

xsebek commented Jul 11, 2024

@jtdaugherty sounds good to me. I assume you meant includeNonCustomizableBindings.

Should I create a PR or do you want to do it?

@jtdaugherty
Copy link
Owner

I assume you meant includeNonCustomizableBindings.

No, I meant includeCustomizedBindings, as in, whether to include bindings that have been changed from their defaults. I don't think a setting to control whether non-customizable bindings are included would be useful, since this is about producing an INI, and the only purpose of that is to customize bindings so the only ones worth including are the ones that can indeed be customized. Does that make sense?

Should I create a PR or do you want to do it?

If you would like to do so, that would be great - I don't know when I'll have time to get to it, so if you are more motivated or have more time, please be my guest.

Thanks!

@jtdaugherty
Copy link
Owner

Also, a minor note that I didn't mention since I was going to change it in the implementation anyway: I'd rather use # for comments in the generated INI than ;.

@jtdaugherty
Copy link
Owner

Also, I realized I forgot an argument. The function signature should be

keybindingsToIni :: INIGenerationConfig -> Text -> KeyConfig k -> Text

to include the name of the INI section that should be generated in the output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants