-
Notifications
You must be signed in to change notification settings - Fork 275
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 From<KeyEvent> for String #792
Comments
Does the use crossterm::event::{self, Event};
fn main() {
loop {
if let Ok(Event::Key(ev)) = event::read() {
println!("{ev:?}");
break;
}
}
} KeyEvent { code: Char('a'), modifiers: NONE, kind: Press, state: NONE } |
The idea is to pretty print the key as part of the help message, so no, the
debug does not fit my needs.
…On Sat, Jul 29, 2023 at 1:23 PM Peter Hebden ***@***.***> wrote:
Does the fmt::Debug implementation suit your needs? E.g.
use crossterm::event::{self, Event};
fn main() {
loop {
if let Ok(Event::Key(ev)) = event::read() {
println!("{ev:?}");
break;
}
}}
KeyEvent { code: Char('a'), modifiers: NONE, kind: Press, state: NONE }
—
Reply to this email directly, view it on GitHub
<#792 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AARKJWMZO5HFR4CXEU5AFELXSTXDLANCNFSM6AAAAAA2CXXQHY>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
--
---
https://danielorodriguez.com
|
I think this probably should be I think it's probably reasonable to implement Display for |
Partially addresses crossterm-rs#792
Partially addresses #792 * Implement Display for KeyCode and KeyModifiers * Add demo for Display implementation
Is your feature request related to a problem? Please describe.
I’m implementing a system to automatically build help panes from a contextual action structure. I have everything I need already except the ability to turn the key event into a string for displaying in a nice way.
Describe the solution you'd like
I would love to see the from keyevent trait for string,so it can be used for this purposes. It could be behind a feature flag so only those needing it get it.
Describe alternatives you've considered if any
I can build a wrapper type in my own codebase and implement it there.
Additional context
Anything else?
Nope
The text was updated successfully, but these errors were encountered: