forked from derailed/k9s
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
92 changed files
with
2,857 additions
and
2,314 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ install: true | |
|
||
env: | ||
- GO111MODULE=on | ||
- GOPROXY=https://proxy.golang.org | ||
|
||
script: | ||
- go build | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package ui | ||
|
||
import ( | ||
"sort" | ||
|
||
"github.com/gdamore/tcell" | ||
"github.com/rs/zerolog/log" | ||
) | ||
|
||
type ( | ||
// ActionHandler handles a keyboard command. | ||
ActionHandler func(*tcell.EventKey) *tcell.EventKey | ||
|
||
// KeyAction represents a keyboard action. | ||
KeyAction struct { | ||
Description string | ||
Action ActionHandler | ||
Visible bool | ||
} | ||
|
||
// KeyActions tracks mappings between keystrokes and actions. | ||
KeyActions map[tcell.Key]KeyAction | ||
) | ||
|
||
// NewKeyAction returns a new keyboard action. | ||
func NewKeyAction(d string, a ActionHandler, display bool) KeyAction { | ||
return KeyAction{Description: d, Action: a, Visible: display} | ||
} | ||
|
||
// Hints returns a collection of hints. | ||
func (a KeyActions) Hints() Hints { | ||
kk := make([]int, 0, len(a)) | ||
for k, v := range a { | ||
if v.Visible { | ||
kk = append(kk, int(k)) | ||
} | ||
} | ||
sort.Ints(kk) | ||
|
||
hh := make(Hints, 0, len(kk)) | ||
for _, k := range kk { | ||
if name, ok := tcell.KeyNames[tcell.Key(k)]; ok { | ||
hh = append(hh, Hint{ | ||
mnemonic: name, | ||
description: a[tcell.Key(k)].Description}) | ||
} else { | ||
log.Error().Msgf("Unable to locate KeyName for %#v", string(k)) | ||
} | ||
} | ||
return hh | ||
} |
Oops, something went wrong.