Menu & MenuBar experience improvements

This commit is contained in:
Luke I. Wilson
2021-03-18 23:37:42 -05:00
parent 1d77aae277
commit 83567c1341
3 changed files with 134 additions and 41 deletions

View File

@ -1,5 +1,25 @@
package ui
import "unicode"
// QuickCharInString is used for finding the "quick char" in a string. A quick char
// suffixes a '_' (underscore). So basically, this function returns any rune after
// an underscore. The rune is always made lowercase. The bool returned is whether
// the rune was found.
func QuickCharInString(s string) (bool, rune) {
runes := []rune(s)
for i, r := range runes {
if r == '_' {
if i+1 < len(runes) {
return true, unicode.ToLower(runes[i+1])
} else {
return false, ' '
}
}
}
return false, ' '
}
// Max returns the larger integer.
func Max(a, b int) int {
if a > b {