-
Notifications
You must be signed in to change notification settings - Fork 396
/
utils.go
51 lines (42 loc) · 881 Bytes
/
utils.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package completion
import (
"fmt"
"unicode"
"github.com/u-root/u-root/cmds/elvish/edit/ui"
"github.com/u-root/u-root/cmds/elvish/util"
)
func throw(e error) {
util.Throw(e)
}
func maybeThrow(e error) {
if e != nil {
util.Throw(e)
}
}
func throwf(format string, args ...interface{}) {
util.Throw(fmt.Errorf(format, args...))
}
func min(a, b int) int {
if a <= b {
return a
}
return b
}
func max(a, b int) int {
if a >= b {
return a
}
return b
}
// Styles for UI.
var (
// Use default style for completion listing
styleForCompletion = ui.Styles{}
// Use inverse style for selected completion entry
styleForSelectedCompletion = ui.Styles{"inverse"}
)
// likeChar returns if a key looks like a character meant to be input (as
// opposed to a function key).
func likeChar(k ui.Key) bool {
return k.Mod == 0 && k.Rune > 0 && unicode.IsGraphic(k.Rune)
}