mirror of
https://github.com/Jguer/yay.git
synced 2024-11-07 01:27:21 +01:00
parent
14cc8d4ef0
commit
7ebe64871d
@ -6,6 +6,7 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
"syscall"
|
||||
"unicode"
|
||||
|
||||
"github.com/leonelquinteros/gotext"
|
||||
"golang.org/x/sys/unix"
|
||||
@ -84,13 +85,29 @@ func getColumnCount() int {
|
||||
}
|
||||
|
||||
func PrintInfoValue(key string, values ...string) {
|
||||
// 16 (text) + 1 (:) + 1 ( )
|
||||
const (
|
||||
keyLength = 18
|
||||
keyLength = 32
|
||||
delimCount = 2
|
||||
)
|
||||
|
||||
str := fmt.Sprintf(Bold("%-16s: "), key)
|
||||
specialWordsCount := 0
|
||||
|
||||
for _, runeValue := range key {
|
||||
// CJK handling: the character 'ー' is Katakana
|
||||
// but if use unicode.Katakana, it will return false
|
||||
if unicode.IsOneOf([]*unicode.RangeTable{
|
||||
unicode.Han,
|
||||
unicode.Hiragana,
|
||||
unicode.Katakana,
|
||||
unicode.Hangul,
|
||||
}, runeValue) || runeValue == 'ー' {
|
||||
specialWordsCount++
|
||||
}
|
||||
}
|
||||
|
||||
keyTextCount := specialWordsCount - keyLength + delimCount
|
||||
str := fmt.Sprintf(Bold("%-*s: "), keyTextCount, key)
|
||||
|
||||
if len(values) == 0 || (len(values) == 1 && values[0] == "") {
|
||||
fmt.Fprintf(os.Stdout, "%s%s\n", str, gotext.Get("None"))
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user