1 Star 0 Fork 1

王布衣 / pkg

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
table_unicode.go 1.56 KB
一键复制 编辑 原始数据 按行查看 历史
package tablewriter
import "errors"
type UnicodeLineStyle int
const (
Regular UnicodeLineStyle = iota
Thick
Double
)
const (
symsRR = "─│┌┐└┘├┤┬┴┼"
symsTT = "━┃┏┓┗┛┣┫┳┻╋"
symsDD = "═║╔╗╚╝╠╣╦╩╬"
symsRT = "─┃┎┒┖┚┠┨┰┸╂"
symsTR = "━│┍┑┕┙┝┥┯┷┿"
symsRD = "─║╓╖╙╜╟╢╥╨╫"
symsDR = "═│╒╕╘╛╞╡╤╧╪"
)
func simpleSyms(center, row, column string) []string {
return []string{row, column, center, center, center, center, center, center, center, center, center}
}
// Use unicode box drawing symbols to achieve the specified line styles.
// Note that combinations of thick and double lines are not supported.
// Will return an error in case of unsupported combinations.
func (t *Table) SetUnicodeHV(horizontal, vertical UnicodeLineStyle) error {
var syms string
switch {
case horizontal == Regular && vertical == Regular:
syms = symsRR
case horizontal == Thick && vertical == Thick:
syms = symsTT
case horizontal == Double && vertical == Double:
syms = symsDD
case horizontal == Regular && vertical == Thick:
syms = symsRT
case horizontal == Thick && vertical == Regular:
syms = symsTR
case horizontal == Regular && vertical == Double:
syms = symsRD
case horizontal == Double && vertical == Regular:
syms = symsDR
default:
return errors.New("Unsupported combination of unicode line styles")
}
t.syms = make([]string, 0, 11)
for _, sym := range []rune(syms) {
t.syms = append(t.syms, string(sym))
}
return nil
}
1
https://gitee.com/quant1x/pkg.git
git@gitee.com:quant1x/pkg.git
quant1x
pkg
pkg
v0.2.8

搜索帮助