-
Notifications
You must be signed in to change notification settings - Fork 0
/
PrintLine.go
91 lines (88 loc) · 2.43 KB
/
PrintLine.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package main
import (
"fmt"
"strconv"
)
func KeyBordCtrl(data string, SelectLine *int, Line 队列) {
switch {
case data == "Down" || data == "Right":
*SelectLine++
PrintLine(SelectLine)
case data == "Up" || data == "Left":
*SelectLine--
PrintLine(SelectLine)
case data == "Delete":
DeleteLine(*SelectLine)
case data == "End":
*SelectLine = 0
PrintLine(SelectLine)
}
}
func PrintLine(SelectLine *int) {
//fmt.Println("打印", SelectLine, lineup)
CallClear()
GuarLineLEN, GiftLineLEN, CommonLineLEN := len(lineup.GuardLine), len(lineup.GiftLine), len(lineup.CommonLine)
if *SelectLine+1 > GuarLineLEN+GiftLineLEN+CommonLineLEN {
*SelectLine = 0
}
if *SelectLine < (-1) {
*SelectLine = GuarLineLEN + GiftLineLEN + CommonLineLEN - 1
}
//fmt.Println(GuarLineLEN, GiftLineLEN, CommonLineLEN)
switch {
case *SelectLine+1 <= GuarLineLEN:
for k, s := range lineup.GuardLine {
if *SelectLine == k {
ColorPrint(s.UserName, 4)
fmt.Println()
} else {
ColorPrint(s.UserName, s.PrintColor)
fmt.Println()
}
}
for _, s := range lineup.GiftLine {
ColorPrint(s.UserName+" "+strconv.FormatFloat(s.GiftPrice, 'g', 5, 64)+"元", s.PrintColor)
fmt.Println()
}
for _, s := range lineup.CommonLine {
ColorPrint(s.UserName, s.PrintColor)
fmt.Println()
}
case GuarLineLEN < *SelectLine+1 && *SelectLine+1 <= GiftLineLEN+GuarLineLEN:
for _, s := range lineup.GuardLine {
ColorPrint(s.UserName, s.PrintColor)
fmt.Println()
}
for k, s := range lineup.GiftLine {
if k == *SelectLine-GuarLineLEN {
ColorPrint(s.UserName+" "+strconv.FormatFloat(s.GiftPrice, 'g', 5, 64)+"元", 4)
fmt.Println()
} else {
ColorPrint(s.UserName+" "+strconv.FormatFloat(s.GiftPrice, 'g', 5, 64)+"元", s.PrintColor)
fmt.Println()
}
}
for _, s := range lineup.CommonLine {
ColorPrint(s.UserName, s.PrintColor)
fmt.Println()
}
case GuarLineLEN+GiftLineLEN < *SelectLine+1 && *SelectLine+1 <= GuarLineLEN+GiftLineLEN+CommonLineLEN:
for _, s := range lineup.GuardLine {
ColorPrint(s.UserName, s.PrintColor)
fmt.Println()
}
for _, s := range lineup.GiftLine {
ColorPrint(s.UserName+" "+strconv.FormatFloat(s.GiftPrice, 'g', 5, 64)+"元", s.PrintColor)
fmt.Println()
}
for k, s := range lineup.CommonLine {
if k == *SelectLine-GuarLineLEN-GiftLineLEN {
ColorPrint(s.UserName, 4)
fmt.Println()
} else {
ColorPrint(s.UserName, s.PrintColor)
fmt.Println()
}
}
}
}