aboutsummaryrefslogtreecommitdiff
path: root/go-src/ui
diff options
context:
space:
mode:
Diffstat (limited to 'go-src/ui')
-rw-r--r--go-src/ui/ui.go41
1 files changed, 21 insertions, 20 deletions
diff --git a/go-src/ui/ui.go b/go-src/ui/ui.go
index a35eac0..1a362e6 100644
--- a/go-src/ui/ui.go
+++ b/go-src/ui/ui.go
@@ -39,16 +39,19 @@ const (
var scanner = bufio.NewScanner(os.Stdin)
// Returns an error box
-func ErrorBox(message string) (box string) {
+func ErrorBox(message string) {
+ var box string
// 2+len because message length doesn't accomodate the spaces between the left and right border
box += fmt.Sprintf("%c%v%c\n", boxErrTopLeftCorner, utils.RepeatRune(boxErrHorLine, 2+len(message)), boxErrTopRightCorner)
box += fmt.Sprintf("%c %v %c\n", boxErrVertLine, message, boxErrVertLine)
box += fmt.Sprintf("%c%v%c", boxErrBottomLeftCorner, utils.RepeatRune(boxErrHorLine, 2+len(message)), boxErrBottomRightCorner)
- return
+ fmt.Println(box)
}
// Returns a normal box, most commonly used for the menu items
-func NormalBox(railed bool, messages ...string) (box string) {
+func NormalBox(railed bool, messages ...string) {
+ var box string
+
message := strings.Join(messages, " │ ")
var messagesLengths []int
@@ -93,38 +96,36 @@ func NormalBox(railed bool, messages ...string) (box string) {
// Replaces the border character on the bottom with one that connects to the middle broder: └───────────┴───────────┘
box = utils.ReplaceAtIndex(box, boxHorUpLine, indBot)
}
- return
+ fmt.Println(box)
}
-func TextField(message string) string {
- return fmt.Sprintf("%c%c %v", boxVertRightLine, textRune, message)
+func TextField(message string) {
+ fmt.Printf("%c%c %v\n", boxVertRightLine, textRune, message)
}
func InputField(specification string) string {
- return fmt.Sprintf("%c%c %v : ", boxBottomLeftCorner, inputRune, specification)
+ fmt.Printf("%c%c %v : ", boxBottomLeftCorner, inputRune, specification)
+ scanner.Scan()
+ return scanner.Text()
}
-func InputFieldFilled(specification string, input string) string {
- return utils.ReplaceAtIndex(InputField(specification), boxVertRightLine, 0) + input
+func InputFieldFilled(specification string, input string) {
+ fmt.Printf("%c%c %v : %v\n", boxVertRightLine, inputRune, specification, input)
}
-func NumberedFields(messages ...string) (result string) {
+func NumberedFields(messages ...string) {
+ var result string
for i, v := range messages {
result += fmt.Sprintf("%c%v %v\n", boxVertRightLine, i+1, v)
}
result = result[:len(result)-1]
- return
-}
-
-func GetInput() string {
- scanner.Scan()
- return scanner.Text()
+ fmt.Println(result)
}
-func PageField(current int, max int) string {
- return fmt.Sprintf("├─Page %v/%v─┘", current, max)
+func PageField(current int, max int) {
+ fmt.Printf("├─Page %v/%v─┘\n", current, max)
}
-func EmptyLine() string {
- return string(boxVertLine)
+func EmptyLine() {
+ fmt.Println(string(boxVertLine))
}