-
Notifications
You must be signed in to change notification settings - Fork 0
/
display.go
131 lines (97 loc) · 2.65 KB
/
display.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
package main
//
//// IMPORTS
//
import (
// Modules in GOROOT
"fmt"
"strings"
// External modules
color "github.com/gookit/color"
wordwrap "github.com/mitchellh/go-wordwrap"
)
//
//// DISPLAY VARIABLES
//
var (
// Gray
grayHex = "#808080"
gray = color.HEX(grayHex)
// Light Gray
lightGrayHex = "#c8c4a9"
lightGray = color.HEX(lightGrayHex)
// Orange
orangeHex = "#ffa860"
orange = color.HEX(orangeHex)
// Blue
blueHex = "#55aaff"
blue = color.HEX(blueHex)
// Green
greenHex = "#55ff7f"
green = color.HEX(greenHex)
// Red
redHex = "#ff5050"
red = color.HEX(redHex)
// Light Copper
lightCopperHex = "#ffaa7f"
lightCopper = color.HEX(lightCopperHex)
// Salmon Pink
salmonPinkHex = "#ff8a82"
salmonPink = color.HEX(salmonPinkHex)
// Coral
coralHex = "#ff7458"
coral = color.HEX(coralHex)
// Light Brown
paleLimeHex = "#cee89c"
paleLime = color.HEX(paleLimeHex)
)
//
//// DISPLAY FUNCTIONS
//
func returnText(msg string, indentLevel int) string {
indent := strings.Repeat(" ", indentLevel)
return fmt.Sprintf(indent + msg)
}
func showText(msg string, indentLevel int) {
indent := strings.Repeat(" ", indentLevel)
fmt.Println(indent + msg)
}
func returnTextWrapped(msg string, factor float64, program Program) string {
terminalDimensions, _ := getTerminalDimensions(program)
wrapLimit := uint(float64(terminalDimensions.width) * factor)
wrappedText := wordwrap.WrapString(msg, wrapLimit)
return wrappedText
}
func showTextWrapped(msg string, factor float64, program Program) {
terminalDimensions, _ := getTerminalDimensions(program)
wrapLimit := uint(float64(terminalDimensions.width) * factor)
wrappedText := wordwrap.WrapString(msg, wrapLimit)
fmt.Println(wrappedText)
}
func printColoredMessage(c color.RGBColor, msg string, indentLevel int) {
indent := strings.Repeat(" ", indentLevel)
c.Println(indent + msg)
}
func showInfo(msg string, indentLevel int) {
printColoredMessage(gray, msg, indentLevel)
}
func showAttention(msg string, indentLevel int) {
printColoredMessage(orange, msg, indentLevel)
}
func showInfoSectionTitle(msg string, indentLevel int) {
printColoredMessage(lightGray, msg, indentLevel)
}
func showSuccess(msg string, indentLevel int) {
printColoredMessage(blue, msg, indentLevel)
}
func showError(msg string, indentLevel int) {
printColoredMessage(red, msg, indentLevel)
}
func space() {
fmt.Println("")
}
func hr(char string, factor float64, program Program) {
terminalDimensions, _ := getTerminalDimensions(program)
horizontalLine := strings.Repeat(string(char), int(float64(terminalDimensions.width)*factor))
showText(horizontalLine, program.indentLevel)
}