mirror of
https://github.com/VladimirMarkelov/clui.git
synced 2025-05-05 19:30:22 +08:00
Merge pull request #75 from linkerlin/patch-1
Added support for Chinese
This commit is contained in:
commit
fb6ab7b916
@ -4,6 +4,7 @@ import (
|
|||||||
xs "github.com/huandu/xstrings"
|
xs "github.com/huandu/xstrings"
|
||||||
term "github.com/nsf/termbox-go"
|
term "github.com/nsf/termbox-go"
|
||||||
"strings"
|
"strings"
|
||||||
|
"unicode"
|
||||||
)
|
)
|
||||||
|
|
||||||
type attr struct {
|
type attr struct {
|
||||||
@ -274,7 +275,13 @@ func DrawText(x, y int, text string) {
|
|||||||
SetTextColor(elem.Fg)
|
SetTextColor(elem.Fg)
|
||||||
SetBackColor(elem.Bg)
|
SetBackColor(elem.Bg)
|
||||||
drawn := PutChar(x, y, elem.Ch)
|
drawn := PutChar(x, y, elem.Ch)
|
||||||
|
|
||||||
|
if unicode.Is(unicode.Scripts["Han"], elem.Ch){
|
||||||
|
x += 2
|
||||||
|
} else {
|
||||||
x += 1
|
x += 1
|
||||||
|
}
|
||||||
|
|
||||||
if firstdrawn && !drawn {
|
if firstdrawn && !drawn {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user