mirror of
https://github.com/taigrr/bubbletea.git
synced 2026-04-17 10:35:28 -07:00
chore: gofmt sources
This commit is contained in:
67
key.go
67
key.go
@@ -11,30 +11,30 @@ import (
|
||||
// the program's update function. There are a couple general patterns you could
|
||||
// use to check for keypresses:
|
||||
//
|
||||
// // Switch on the string representation of the key (shorter)
|
||||
// switch msg := msg.(type) {
|
||||
// case KeyMsg:
|
||||
// switch msg.String() {
|
||||
// case "enter":
|
||||
// fmt.Println("you pressed enter!")
|
||||
// case "a":
|
||||
// fmt.Println("you pressed a!")
|
||||
// }
|
||||
// }
|
||||
// // Switch on the string representation of the key (shorter)
|
||||
// switch msg := msg.(type) {
|
||||
// case KeyMsg:
|
||||
// switch msg.String() {
|
||||
// case "enter":
|
||||
// fmt.Println("you pressed enter!")
|
||||
// case "a":
|
||||
// fmt.Println("you pressed a!")
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // Switch on the key type (more foolproof)
|
||||
// switch msg := msg.(type) {
|
||||
// case KeyMsg:
|
||||
// switch msg.Type {
|
||||
// case KeyEnter:
|
||||
// fmt.Println("you pressed enter!")
|
||||
// case KeyRunes:
|
||||
// switch string(msg.Runes) {
|
||||
// case "a":
|
||||
// fmt.Println("you pressed a!")
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// // Switch on the key type (more foolproof)
|
||||
// switch msg := msg.(type) {
|
||||
// case KeyMsg:
|
||||
// switch msg.Type {
|
||||
// case KeyEnter:
|
||||
// fmt.Println("you pressed enter!")
|
||||
// case KeyRunes:
|
||||
// switch string(msg.Runes) {
|
||||
// case "a":
|
||||
// fmt.Println("you pressed a!")
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Note that Key.Runes will always contain at least one character, so you can
|
||||
// always safely call Key.Runes[0]. In most cases Key.Runes will only contain
|
||||
@@ -58,10 +58,9 @@ type Key struct {
|
||||
// String returns a friendly string representation for a key. It's safe (and
|
||||
// encouraged) for use in key comparison.
|
||||
//
|
||||
// k := Key{Type: KeyEnter}
|
||||
// fmt.Println(k)
|
||||
// // Output: enter
|
||||
//
|
||||
// k := Key{Type: KeyEnter}
|
||||
// fmt.Println(k)
|
||||
// // Output: enter
|
||||
func (k Key) String() (str string) {
|
||||
if k.Alt {
|
||||
str += "alt+"
|
||||
@@ -80,16 +79,16 @@ func (k Key) String() (str string) {
|
||||
// All other keys will be type KeyRunes. To get the rune value, check the Rune
|
||||
// method on a Key struct, or use the Key.String() method:
|
||||
//
|
||||
// k := Key{Type: KeyRunes, Runes: []rune{'a'}, Alt: true}
|
||||
// if k.Type == KeyRunes {
|
||||
// k := Key{Type: KeyRunes, Runes: []rune{'a'}, Alt: true}
|
||||
// if k.Type == KeyRunes {
|
||||
//
|
||||
// fmt.Println(k.Runes)
|
||||
// // Output: a
|
||||
// fmt.Println(k.Runes)
|
||||
// // Output: a
|
||||
//
|
||||
// fmt.Println(k.String())
|
||||
// // Output: alt+a
|
||||
// fmt.Println(k.String())
|
||||
// // Output: alt+a
|
||||
//
|
||||
// }
|
||||
// }
|
||||
type KeyType int
|
||||
|
||||
func (k KeyType) String() (str string) {
|
||||
|
||||
Reference in New Issue
Block a user