zenity/internal/zencmd/mnemonic.go

26 lines
426 B
Go
Raw Permalink Normal View History

2022-12-20 07:23:15 -05:00
package zencmd
import "strings"
// StripMnemonic is internal.
func StripMnemonic(s string) string {
// Strips mnemonics described in:
// https: //docs.gtk.org/gtk4/class.Label.html#mnemonics
var res strings.Builder
underscore := false
for _, b := range []byte(s) {
switch {
case underscore:
underscore = false
case b == '_':
underscore = true
continue
}
res.WriteByte(b)
}
return res.String()
}