Skip to content

add String/FromString for Key, Mods, MouseButton, FocusEvent#17

Merged
mitchellh merged 1 commit intomainfrom
push-ltouprosxluy
May 3, 2026
Merged

add String/FromString for Key, Mods, MouseButton, FocusEvent#17
mitchellh merged 1 commit intomainfrom
push-ltouprosxluy

Conversation

@mitchellh
Copy link
Copy Markdown
Owner

Add human-friendly string conversion to the input enum types so they can be serialized to and parsed from text formats like JSON or configuration files.

Each type gains a String() method returning the canonical snake_case name (e.g. "key_a", "arrow_down", "shift+ctrl", "middle", "gained") and a pointer-receiver FromString method that mutates the receiver. A top-level NewKeyFromString, NewModsFromString, NewMouseButtonFromString, and
NewFocusEventFromString constructor is also provided as a more ergonomic alternative.

Add human-friendly string conversion to the input enum types so they
can be serialized to and parsed from text formats like JSON or
configuration files.

Each type gains a String() method returning the canonical
snake_case name (e.g. "key_a", "arrow_down", "shift+ctrl",
"middle", "gained") and a pointer-receiver FromString method
that mutates the receiver. A top-level NewKeyFromString,
NewModsFromString, NewMouseButtonFromString, and
NewFocusEventFromString constructor is also provided as a more
ergonomic alternative.
@mitchellh mitchellh merged commit eb11e38 into main May 3, 2026
38 checks passed
@mitchellh mitchellh deleted the push-ltouprosxluy branch May 3, 2026 21:59
@mitchellh mitchellh restored the push-ltouprosxluy branch May 5, 2026 20:50
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.

1 participant