forked from olekukonko/tablewriter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
table_unicode.go
55 lines (49 loc) · 1.56 KB
/
table_unicode.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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
}