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

Implement Display for KeyCode and KeyModifiers #862

Merged
merged 2 commits into from May 3, 2024

Conversation

joshka
Copy link
Contributor

@joshka joshka commented Feb 17, 2024

Partially addresses #792

In Ratatui apps using Crossterm, something we'd like to be able to generally provide approaches for is help screens that show the key bindings that will be used. The responsibility for displaying each keys properly most likely belongs in Crossterm rather than each application.

I've tried to make some reasonable choices about displaying the keys that match the target platform (e.g. on Mac, Backspace is Delete, Delete is Fwd Del, Enter is Return, Alt is Option, Ctrl is Control, Super is Command, and on Windows Super is the Windows key). These choices are backed by the style guidelines from Apple and Microsoft where possible and intuition where not (e.g. Next Track instead of Track Next).

It would be nice to be able to have used something like strum's Display derive macro to make the implementation of this simple, but there currently isn't a way to make the format for the function keys (F1) or the media / modifier key variants work with that, so a more manual approach is taken.

@joshka
Copy link
Contributor Author

joshka commented May 3, 2024

Ping @TimonPost for a review on this.

Copy link
Member

@TimonPost TimonPost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweet!

@TimonPost TimonPost merged commit 39ef1e4 into crossterm-rs:master May 3, 2024
@heaths heaths mentioned this pull request May 4, 2024
@joshka joshka deleted the jm/keycode-display branch May 5, 2024 09:50
joshka added a commit to joshka/crossterm that referenced this pull request May 5, 2024
An incorrect #[cfg] attribute introduced in crossterm-rs#862 prevented compilation on unix
@joshka joshka mentioned this pull request May 5, 2024
joshka added a commit to joshka/crossterm that referenced this pull request May 5, 2024
An incorrect #[cfg] attribute introduced in crossterm-rs#862 prevented compilation on unix
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

Successfully merging this pull request may close these issues.

None yet

3 participants