-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtable_process.go
More file actions
52 lines (48 loc) · 1.26 KB
/
table_process.go
File metadata and controls
52 lines (48 loc) · 1.26 KB
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
package stable
import (
"strings"
)
// createBorders create borders for given style
func createBorders(bs *BorderStyle, columnSizeList []int) (string, string, string, string) {
generic := buildGenericSeparator(columnSizeList)
topSeperator := styleTheBorder(generic,
bs.get(_BSITopLeft),
bs.get(_BSITopCenter),
bs.get(_BSITopRight),
bs.get(_BSIVertical),
)
midSeperator := styleTheBorder(generic,
bs.get(_BSIMidLeft),
bs.get(_BSIMidCenter),
bs.get(_BSIMidRight),
bs.get(_BSIVertical),
)
botSeperator := styleTheBorder(generic,
bs.get(_BSIBotLeft),
bs.get(_BSIBotCenter),
bs.get(_BSIBotRight),
bs.get(_BSIVertical),
)
return generic, topSeperator, midSeperator, botSeperator
}
func styleTheBorder(generic string, left, center, right, horizontal string) string {
sep := generic
sep = strings.Replace(sep, _SPHHorizontal, horizontal, -1)
sep = strings.Replace(sep, _SPHStart, left, -1)
sep = strings.Replace(sep, _SPHMiddle, center, -1)
sep = strings.Replace(sep, _SPHEnd, right, -1)
return sep
}
func buildGenericSeparator(columnSizeList []int) string {
s := _SPHStart
for i, l := range columnSizeList {
for j := 0; j < l; j++ {
s += _SPHHorizontal
}
if i != len(columnSizeList)-1 {
s += _SPHMiddle
}
}
s += _SPHEnd
return s
}