1 Star 0 Fork 2

王布衣/pkg

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
table_unicode.go 1.56 KB
一键复制 编辑 原始数据 按行查看 历史
王布衣 提交于 2023-11-18 06:31 +08:00 . 新增: github.com/olekukonko/tablewriter v0.0.5
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
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/quant1x/pkg.git
git@gitee.com:quant1x/pkg.git
quant1x
pkg
pkg
v0.8.2

搜索帮助