From 1a9e03bf68dc38df757f26d84b10bb2398b1602a Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Sun, 11 Aug 2019 13:09:55 +0200 Subject: [PATCH] ui/key: expand documentation Signed-off-by: Elias Naur --- ui/key/key.go | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/ui/key/key.go b/ui/key/key.go index 36477b56..a23c6cb5 100644 --- a/ui/key/key.go +++ b/ui/key/key.go @@ -34,23 +34,37 @@ type FocusEvent struct { Focus bool } +// Event is sent when a key is pressed. For text input +// use EditEvent. type Event struct { - Name rune + // Name is the rune character that most closely + // match the key. For letters, the upper case form + // is used. + Name rune + // Modifiers is the set of active modifiers when + // the key was pressed. Modifiers Modifiers } +// EditEvent is sent when text is input. type EditEvent struct { Text string } +// Modifiers type Modifiers uint32 const ( + // ModCommand is the command modifier. On macOS + // it is the Cmd key, on other platforms the Ctrl + // key. ModCommand Modifiers = 1 << iota + // THe shift key. ModShift ) const ( + // Runes for special keys. NameLeftArrow = '←' NameRightArrow = '→' NameUpArrow = '↑' @@ -66,6 +80,8 @@ const ( NamePageDown = '⇟' ) +// Contain reports whether m contains all modifiers +// in m2. func (m Modifiers) Contain(m2 Modifiers) bool { return m&m2 == m2 }