Compare commits

..

21 commits
0.0.1 ... main

Author SHA1 Message Date
4c617ba4b5
fix styling 2024-08-08 10:47:24 -04:00
2b4361d641
fix list title styling 2024-08-08 10:46:33 -04:00
628eb8343d
fix list index, add blank line function 2024-08-08 10:43:10 -04:00
538949679f
fix spacing 2024-08-07 14:40:46 -04:00
42c4dbb3da
add displaylist 2024-08-07 14:36:32 -04:00
80d705644f Update ansi.go 2024-08-07 18:38:48 +02:00
23540cb43f Update textinput/text.go 2024-08-07 18:21:27 +02:00
d6c77ae8e0 Update progress/progress.go 2024-08-07 18:20:52 +02:00
6f111d7028 Update list/list.go 2024-08-07 18:20:29 +02:00
e662ed7a9f Update confirmation/confirmation.go 2024-08-07 18:20:10 +02:00
8d13e466bb Update go.mod 2024-08-07 18:19:36 +02:00
f2ff008b6a
fix confirmation 2024-07-25 13:36:42 -04:00
cd140e6e1f Update go.mod 2024-07-25 00:32:43 +01:00
530a37e631 Update go.mod
Signed-off-by: Eggactyl.bot <noreply@eggactyl.cloud>
2024-07-16 18:59:04 +02:00
689d9d1333
switch progress & textinput to use the new color variables 2024-07-07 16:59:27 -04:00
c483788ca5
re-add textinput 2024-07-07 16:45:35 -04:00
036e4ef01e
switch list to use color variables 2024-07-07 16:44:49 -04:00
61364764ad
switch confirmation to use color variables 2024-07-07 15:39:09 -04:00
bae1313e9b
add colors and formatting variable for ansi escape codes 2024-07-07 14:41:35 -04:00
897ced93e2 Merge pull request 'Update dependency go to v1.22.5' (#2) from renovate/go-1.x into main
Reviewed-on: https://git.shadowhosting.xyz/Eggactyl/tui/pulls/2
2024-07-04 23:34:11 +01:00
Renovate Bot
f1f2f5601c
Update dependency go to v1.22.5 2024-07-04 19:40:26 +00:00
7 changed files with 350 additions and 25 deletions

64
ansi.go Normal file
View file

@ -0,0 +1,64 @@
package tui
import (
"fmt"
"golang.org/x/term"
"os"
"strings"
)
type Colors = string
type Fmt = string
// Formatting
const (
FmtReset Colors = "\033[0m"
FmtBold = "\033[1m"
FmtBoldReset = "\033[22m"
FmtDim = "\033[2m"
FmtDimReset = FmtBoldReset
FmtItalic = "\033[3m"
FmtItalicReset = "\033[23m"
FmtUnderline = "\033[4m"
FmtUnderlineReset = "\033[24m"
FmtBlink = "\033[5m"
FmtBlinkReset = "\033[25m"
FmtReverse = "\033[7m"
FmtReverseReset = "\033[27m"
FmtHidden = "\033[8m"
FmtHiddenReset = "\033[28m"
FmtStrikethrough = "\033[9m"
FmtStrikethroughReset = "\033[29m"
)
// Foreground Colors
const (
FgColorGrey Fmt = "\033[38;5;247m"
FgColorGold = "\033[38;5;214m"
FgColorGreen = "\033[38;5;34m"
FgColorRed = "\033[38;5;167m"
)
func BlankLine() {
width, _, _ := term.GetSize(int(os.Stdin.Fd()))
// Assume ptero terminal if no width.
if width == 0 {
fmt.Print("\033[1B")
} else {
fmt.Println("")
}
}
func Format(codes ...string) string {
var str strings.Builder
for _, code := range codes {
str.WriteString(code)
}
return str.String()
}

View file

@ -2,6 +2,7 @@ package confirmation
import ( import (
"fmt" "fmt"
"git.eggactyl.cloud/Eggactyl/tui"
"strings" "strings"
"golang.org/x/term" "golang.org/x/term"
@ -15,11 +16,23 @@ type InputData struct {
func New(data InputData) (*bool, error) { func New(data InputData) (*bool, error) {
if data.Notice != "" { if data.Notice != "" {
fmt.Printf("\033[1m\033[38;5;247m[\033[38;5;214m!\033[38;5;247m]\033[22m \033[3m%s\033[0m\n", data.Notice) fmt.Printf(
tui.Format(tui.FmtBold, tui.FgColorGrey) +
"[" + tui.FgColorGold + "!" + tui.FgColorGrey + "]" + tui.FmtBoldReset + " " +
tui.FmtItalic + data.Notice + tui.FmtReset + "\n",
)
//fmt.Printf("\033[1m\033[38;5;247m[\033[38;5;214m!\033[38;5;247m]\033[22m \033[3m%s\033[0m\n", data.Notice)
} }
if data.Question != "" { if data.Question != "" {
fmt.Printf("\033[1m\033[38;5;247m[\033[38;5;214m?\033[38;5;247m]\033[0m %s (\033[38;5;34my\033[0m/\033[38;5;167mn\033[0m) \033[38;5;247m>>\033[3m\033[38;5;214m\n", data.Question) fmt.Printf(
tui.Format(tui.FmtBold, tui.FgColorGrey) +
"[" + tui.FgColorGold + "!" + tui.FgColorGrey + "]" + tui.FmtReset + " " +
data.Question + " " +
"(" + tui.FgColorGreen + "y" + tui.FmtReset + "/" + tui.FgColorRed + "n" + tui.FmtReset + ") " +
tui.FgColorGrey + ">>" + tui.Format(tui.FmtItalic, tui.FgColorGold) + "\n",
)
//fmt.Printf("\033[1m\033[38;5;247m[\033[38;5;214m?\033[38;5;247m]\033[0m %s (\033[38;5;34my\033[0m/\033[38;5;167mn\033[0m) \033[38;5;247m>>\033[3m\033[38;5;214m\n", data.Question)
} }
var input string var input string
@ -63,14 +76,31 @@ inputLoop:
for i := 0; i < lineNum; i++ { for i := 0; i < lineNum; i++ {
fmt.Printf("\033[A\033[K\033[0G") fmt.Printf("\033[A\033[K\033[0G")
} }
fmt.Printf("\033[1m\033[38;5;247m[\033[38;5;167m!\033[38;5;247m]\033[0m Invalid input, please try again!\n") fmt.Printf(
tui.Format(tui.FmtBold, tui.FgColorGrey) +
"[" + tui.FgColorGold + "!" + tui.FgColorGrey + "]" + tui.FmtReset + " " +
"Invalid input, please try again!\n",
)
//fmt.Printf("\033[1m\033[38;5;247m[\033[38;5;167m!\033[38;5;247m]\033[0m Invalid input, please try again!\n")
if data.Notice != "" { if data.Notice != "" {
fmt.Printf("\033[1m\033[38;5;247m[\033[38;5;214m!\033[38;5;247m]\033[22m \033[3m%s\033[0m\n", data.Notice) fmt.Printf(
tui.Format(tui.FmtBold, tui.FgColorGrey) +
"[" + tui.FgColorGold + "!" + tui.FgColorGrey + "]" + tui.FmtBoldReset + " " +
tui.FmtItalic + data.Notice + tui.FmtReset + "\n",
)
//fmt.Printf("\033[1m\033[38;5;247m[\033[38;5;214m!\033[38;5;247m]\033[22m \033[3m%s\033[0m\n", data.Notice)
} }
if data.Question != "" { if data.Question != "" {
fmt.Printf("\033[1m\033[38;5;247m[\033[38;5;214m?\033[38;5;247m]\033[0m %s (\033[38;5;34my\033[0m/\033[38;5;167mn\033[0m) \033[38;5;247m>>\033[3m\033[38;5;214m\n", data.Question) fmt.Printf(
tui.Format(tui.FmtBold, tui.FgColorGrey) +
"[" + tui.FgColorGold + "!" + tui.FgColorGrey + "]" + tui.FmtReset + " " +
data.Question + " " +
"(" + tui.FgColorGreen + "y" + tui.FmtReset + "/" + tui.FgColorRed + "n" + tui.FmtReset + ") " +
tui.FgColorGrey + ">>" + tui.Format(tui.FmtItalic, tui.FgColorGold) + "\n",
)
//fmt.Printf("\033[1m\033[38;5;247m[\033[38;5;214m?\033[38;5;247m]\033[0m %s (\033[38;5;34my\033[0m/\033[38;5;167mn\033[0m) \033[38;5;247m>>\033[3m\033[38;5;214m\n", data.Question)
} }
continue inputLoop continue inputLoop
} }

View file

@ -0,0 +1,31 @@
package displaylist
import (
"fmt"
"git.eggactyl.cloud/Eggactyl/tui"
)
type ListOptions struct {
Title string
Items []Item
}
type Item struct {
Key string
Value string
}
func New(opts ListOptions) {
fmt.Println(tui.FgColorGrey + "[ " + tui.Format(tui.FgColorGold, tui.FmtUnderline) + opts.Title + tui.Format(tui.FmtUnderlineReset, tui.FgColorGrey) + " ]" + tui.FmtReset)
for _, item := range opts.Items {
fmt.Println(itemString(item.Key, item.Value))
}
}
func itemString(key string, value string) string {
return tui.FgColorGrey + "[ " + tui.FgColorGold + key + " " + tui.FgColorGrey + value + tui.FgColorGrey + " ]" + tui.FmtReset
}

4
go.mod
View file

@ -1,6 +1,6 @@
module git.shadowhosting.xyz/Eggactyl/tui module git.eggactyl.cloud/Eggactyl/tui
go 1.22.4 go 1.22.5
require ( require (
github.com/nicksnyder/go-i18n/v2 v2.4.0 github.com/nicksnyder/go-i18n/v2 v2.4.0

View file

@ -3,6 +3,7 @@ package list
import ( import (
"bufio" "bufio"
"fmt" "fmt"
"git.eggactyl.cloud/Eggactyl/tui"
"os" "os"
"regexp" "regexp"
"sort" "sort"
@ -209,11 +210,15 @@ func (l *ListData) renderList() {
currentPage := l.pages[l.currentPage] currentPage := l.pages[l.currentPage]
listNotice := fmt.Sprintf("\033[1m\033[38;5;247m[\033[38;5;214m!\033[38;5;247m]\033[22m \033[3mPlease choose an option from 1 - %d\033[0m\n", len(currentPage.Cache)) listNotice := tui.Format(tui.FmtBold, tui.FgColorGrey) +
"[" + tui.FgColorGold + "!" + tui.FgColorGrey + "]" + tui.FmtBoldReset + " " +
tui.FmtItalic + fmt.Sprintf("Please choose an option from 1 - %d", len(currentPage.Cache)) + "\n"
//listNotice := fmt.Sprintf("\033[1m\033[38;5;247m[\033[38;5;214m!\033[38;5;247m]\033[22m \033[3mPlease choose an option from 1 - %d\033[0m\n", len(currentPage.Cache))
l.strLengths = append(l.strLengths, len(removeANSIEscapeCodes(listNotice))) l.strLengths = append(l.strLengths, len(removeANSIEscapeCodes(listNotice)))
fmt.Print(listNotice) fmt.Print(listNotice)
listTitle := fmt.Sprintf("\033[1m\033[38;5;247m\033[4m%s:\033[0m\n", currentPage.Title) listTitle := tui.FgColorGrey + "[ " + tui.Format(tui.FgColorGold, tui.FmtUnderline) + currentPage.Title + ":" + tui.Format(tui.FmtUnderlineReset, tui.FgColorGrey) + " ]" + tui.FmtReset + "\n"
l.strLengths = append(l.strLengths, len(removeANSIEscapeCodes(listTitle))) l.strLengths = append(l.strLengths, len(removeANSIEscapeCodes(listTitle)))
fmt.Print(listTitle) fmt.Print(listTitle)
@ -231,17 +236,23 @@ func (l *ListData) renderList() {
var userInputColor string var userInputColor string
if index == len(currentPage.Cache)-1 { if index == len(currentPage.Cache)-1 {
userInputColor = "\033[3m\033[38;5;214m" userInputColor = tui.Format(tui.FmtItalic, tui.FgColorGrey)
} }
if _, ok := item.Value.(string); ok { if _, ok := item.Value.(string); ok {
if item.Value == "action_back" { if item.Value == "action_back" {
listItem = fmt.Sprintf(" \033[38;5;247m[\033[1m\033[38;5;167m%d\033[22m\033[38;5;247m]\033[0m %-*s \033[3m\033[38;5;247m%s\033[0m%s\n", index+1, longestStrLength, item.Label, item.Notice, userInputColor) listItem = " " + tui.FgColorGrey + "[" + tui.Format(tui.FmtBold, tui.FgColorRed) + strconv.Itoa(index+1) + tui.Format(tui.FmtBoldReset, tui.FgColorGrey) + "]" + tui.FmtReset +
fmt.Sprintf(" %-*s ", longestStrLength, item.Label) + tui.Format(tui.FmtItalic, tui.FgColorGrey) + item.Notice + tui.FmtReset + userInputColor + "\n"
//listItem = fmt.Sprintf(" \033[38;5;247m[\033[1m\033[38;5;167m%d\033[22m\033[38;5;247m]\033[0m %-*s \033[3m\033[38;5;247m%s\033[0m%s\n", index+1, longestStrLength, item.Label, item.Notice, userInputColor)
} else { } else {
listItem = fmt.Sprintf(" \033[38;5;247m[\033[1m\033[38;5;214m%d\033[22m\033[38;5;247m]\033[0m %-*s \033[3m\033[38;5;247m%s\033[0m%s\n", index+1, longestStrLength, item.Label, item.Notice, userInputColor) listItem = " " + tui.FgColorGrey + "[" + tui.Format(tui.FmtBold, tui.FgColorGold) + strconv.Itoa(index+1) + tui.Format(tui.FmtBoldReset, tui.FgColorGrey) + "]" + tui.FmtReset +
fmt.Sprintf(" %-*s ", longestStrLength, item.Label) + tui.Format(tui.FmtItalic, tui.FgColorGrey) + item.Notice + tui.FmtReset + userInputColor + "\n"
//listItem = fmt.Sprintf(" \033[38;5;247m[\033[1m\033[38;5;214m%d\033[22m\033[38;5;247m]\033[0m %-*s \033[3m\033[38;5;247m%s\033[0m%s\n", index+1, longestStrLength, item.Label, item.Notice, userInputColor)
} }
} else { } else {
listItem = fmt.Sprintf(" \033[38;5;247m[\033[1m\033[38;5;214m%d\033[22m\033[38;5;247m]\033[0m %-*s \033[3m\033[38;5;247m%s\033[0m%s\n", index+1, longestStrLength, item.Label, item.Notice, userInputColor) listItem = " " + tui.FgColorGrey + "[" + tui.Format(tui.FmtBold, tui.FgColorGold) + strconv.Itoa(index+1) + tui.Format(tui.FmtBoldReset, tui.FgColorGrey) + "]" + tui.FmtReset +
fmt.Sprintf(" %-*s ", longestStrLength, item.Label) + tui.Format(tui.FmtItalic, tui.FgColorGrey) + item.Notice + tui.FmtReset + userInputColor + "\n"
//listItem = fmt.Sprintf(" \033[38;5;247m[\033[1m\033[38;5;214m%d\033[22m\033[38;5;247m]\033[0m %-*s \033[3m\033[38;5;247m%s\033[0m%s\n", index+1, longestStrLength, item.Label, item.Notice, userInputColor)
} }
l.strLengths = append(l.strLengths, len(removeANSIEscapeCodes(listItem))) l.strLengths = append(l.strLengths, len(removeANSIEscapeCodes(listItem)))
@ -271,7 +282,7 @@ func (l *ListData) inputHandler(items []ListItem) ListItem {
totalLineNum = len(l.strLengths) totalLineNum = len(l.strLengths)
} else { } else {
for _, strLength := range l.strLengths { for _, strLength := range l.strLengths {
totalLineNum += ((strLength) / width) totalLineNum += (strLength) / width
} }
} }
totalLineNum++ //User input line totalLineNum++ //User input line
@ -280,7 +291,12 @@ func (l *ListData) inputHandler(items []ListItem) ListItem {
fmt.Printf("\033[0m\033[A\033[K\033[0G") fmt.Printf("\033[0m\033[A\033[K\033[0G")
} }
fmt.Printf("\033[1m\033[38;5;247m[\033[38;5;167m!\033[38;5;247m]\033[0m Invalid input, please try again!\n") fmt.Printf(
tui.Format(tui.FmtBold, tui.FgColorGrey) +
"[" + tui.FgColorRed + "!" + tui.FgColorGrey + "]" + tui.FmtBoldReset + " " +
" Invalid input, please try again!\n",
)
//fmt.Printf("\033[1m\033[38;5;247m[\033[38;5;167m!\033[38;5;247m]\033[0m Invalid input, please try again!\n")
l.strLengths = []int{} l.strLengths = []int{}
l.renderList() l.renderList()
@ -296,7 +312,7 @@ func (l *ListData) inputHandler(items []ListItem) ListItem {
totalLineNum = len(l.strLengths) totalLineNum = len(l.strLengths)
} else { } else {
for _, strLength := range l.strLengths { for _, strLength := range l.strLengths {
totalLineNum += ((strLength) / width) totalLineNum += (strLength) / width
} }
} }
totalLineNum++ //User input line totalLineNum++ //User input line
@ -305,7 +321,12 @@ func (l *ListData) inputHandler(items []ListItem) ListItem {
fmt.Printf("\033[A\033[K\033[0G") fmt.Printf("\033[A\033[K\033[0G")
} }
fmt.Printf("\033[1m\033[38;5;247m[\033[38;5;167m!\033[38;5;247m]\033[0m Invalid input, please try again!\n") fmt.Printf(
tui.Format(tui.FmtBold, tui.FgColorGrey) +
"[" + tui.FgColorRed + "!" + tui.FgColorGrey + "]" + tui.FmtBoldReset + " " +
" Invalid input, please try again!\n",
)
//fmt.Printf("\033[1m\033[38;5;247m[\033[38;5;167m!\033[38;5;247m]\033[0m Invalid input, please try again!\n")
l.strLengths = []int{} l.strLengths = []int{}
l.renderList() l.renderList()

View file

@ -2,6 +2,7 @@ package progress
import ( import (
"fmt" "fmt"
"git.eggactyl.cloud/Eggactyl/tui"
"math" "math"
"regexp" "regexp"
"strconv" "strconv"
@ -59,9 +60,9 @@ func (p *ProgressBar) render(final bool) {
var blockColor string var blockColor string
if final { if final {
blockColor = "34" blockColor = tui.FgColorGreen
} else { } else {
blockColor = "214" blockColor = tui.FgColorGold
} }
sb.WriteString(p.desc) sb.WriteString(p.desc)
@ -76,11 +77,13 @@ func (p *ProgressBar) render(final bool) {
sb.WriteString(percentString) sb.WriteString(percentString)
sb.WriteString("\033[1m\033[38;5;247m [\033[0m") sb.WriteString(tui.Format(tui.FmtBold, tui.FgColorGrey) + " [" + tui.FmtReset)
//sb.WriteString("\033[1m\033[38;5;247m [\033[0m")
for i := 0; i < int(numFilled); i++ { for i := 0; i < int(numFilled); i++ {
sb.WriteString(fmt.Sprintf("\033[38;5;%sm█\033[0m", blockColor)) sb.WriteString(blockColor + "█" + tui.FmtReset)
//sb.WriteString(fmt.Sprintf("%sm█\033[0m", blockColor))
} }
@ -88,21 +91,25 @@ func (p *ProgressBar) render(final bool) {
numBlank = numBlank - 1 numBlank = numBlank - 1
sb.WriteString("\033[38;5;214m▒\033[0m") sb.WriteString(tui.FgColorGold + "▒" + tui.FmtReset)
//sb.WriteString("\033[38;5;214m▒\033[0m")
for i := 0; i < int(numBlank); i++ { for i := 0; i < int(numBlank); i++ {
sb.WriteString("\033[38;5;247m░\033[0m") sb.WriteString(tui.FgColorGrey + "░" + tui.FmtReset)
//sb.WriteString("\033[38;5;247m░\033[0m")
} }
} else { } else {
for i := 0; i < int(numBlank); i++ { for i := 0; i < int(numBlank); i++ {
sb.WriteString("\033[38;5;247m░\033[0m") sb.WriteString(tui.FgColorGrey + "░" + tui.FmtReset)
//sb.WriteString("\033[38;5;247m░\033[0m")
} }
} }
sb.WriteString("\033[1m\033[38;5;247m]\033[0m") sb.WriteString(tui.Format(tui.FmtBold, tui.FgColorGrey) + "]" + tui.FmtReset)
//sb.WriteString("\033[1m\033[38;5;247m]\033[0m")
width, _, err := term.GetSize(0) width, _, err := term.GetSize(0)
if err != nil { if err != nil {

172
textinput/text.go Normal file
View file

@ -0,0 +1,172 @@
package textinput
import (
"fmt"
"git.eggactyl.cloud/Eggactyl/tui"
"git.eggactyl.cloud/Eggactyl/tui/validators"
"golang.org/x/term"
)
type InputData struct {
Notice string
Question string
Validator validators.TextInputValidator
ValidationFunc func(input string) bool
}
func New(data InputData) (*string, error) {
if data.Notice != "" {
fmt.Printf(
tui.Format(tui.FmtBold, tui.FgColorGrey) +
"[" + tui.FgColorGold + "!" + tui.FgColorGrey + "]" + tui.FmtBoldReset + " " +
tui.FmtItalic + data.Notice + tui.FmtReset + "\n",
)
} else if data.Validator != nil && data.Validator.Notice() != "" {
fmt.Printf(
tui.Format(tui.FmtBold, tui.FgColorGrey) +
"[" + tui.FgColorGold + "!" + tui.FgColorGrey + "]" + tui.FmtBoldReset + " " +
tui.FmtItalic + data.Validator.Notice() + tui.FmtReset + "\n",
)
//fmt.Printf("\033[1m\033[38;5;247m[\033[38;5;214m!\033[38;5;247m]\033[22m \033[3m%s\033[0m\n", data.Validator.Notice())
}
if data.Question != "" {
fmt.Printf(
tui.Format(tui.FmtBold, tui.FgColorGrey) +
"[" + tui.FgColorGold + "?" + tui.FgColorGrey + "]" + tui.FmtReset + " " +
data.Question + " " + tui.FgColorGrey + ">>" + tui.Format(tui.FmtItalic, tui.FgColorGold) + "\n",
)
}
var input string
for {
if _, err := fmt.Scanln(&input); err != nil {
return nil, err
}
width, _, err := term.GetSize(0)
if err != nil {
return nil, err
}
if data.ValidationFunc != nil {
if !data.ValidationFunc(input) {
var lineNum int
if width == 0 {
if data.Notice != "" {
lineNum++
}
lineNum += 2
} else {
if data.Notice == "" {
lineNum = ((len(data.Question) + 5 + width - 1) / width) + 1
} else {
lineNum = ((len(data.Notice) + 5 + width) / width) + ((len(data.Question) + 5 + width - 1) / width) + 1
}
}
for i := 0; i < lineNum; i++ {
fmt.Printf("\033[A\033[K\033[0G")
}
fmt.Printf(
tui.Format(tui.FmtBold, tui.FgColorGrey) +
"[" + tui.FgColorRed + "!" + tui.FgColorGrey + "]" + tui.FmtBoldReset + " " +
" Invalid input, please try again!\n",
)
if data.Notice != "" {
fmt.Printf(
tui.Format(tui.FmtBold, tui.FgColorGrey) +
"[" + tui.FgColorGold + "!" + tui.FgColorGrey + "]" + tui.FmtBoldReset + " " +
tui.FmtItalic + data.Notice + tui.FmtReset + "\n",
)
} else if data.Validator != nil {
fmt.Printf(
tui.Format(tui.FmtBold, tui.FgColorGrey) +
"[" + tui.FgColorGold + "!" + tui.FgColorGrey + "]" + tui.FmtBoldReset + " " +
tui.FmtItalic + data.Validator.Notice() + tui.FmtReset + "\n",
)
}
if data.Question != "" {
fmt.Printf(
tui.Format(tui.FmtBold, tui.FgColorGrey) +
"[" + tui.FgColorGold + "?" + tui.FgColorGrey + "]" + tui.FmtReset + " " +
data.Question + " " + tui.FgColorGrey + ">>" + tui.Format(tui.FmtItalic, tui.FgColorGold) + "\n",
)
}
continue
}
} else if data.Validator != nil {
if !data.Validator.ValidationFunc(input) {
var lineNum int
if width == 0 {
if data.Notice != "" || data.Validator.Notice() != "" {
lineNum++
}
lineNum += 2
} else {
if data.Notice == "" && data.Validator.Notice() == "" {
lineNum = ((len(data.Question) + 5 + width - 1) / width) + 1
} else {
if data.Notice != "" {
lineNum = ((len(data.Notice) + 5 + width) / width) + ((len(data.Question) + 5 + width - 1) / width) + 1
} else if data.Validator.Notice() != "" {
lineNum = ((len(data.Validator.Notice()) + 5 + width - 1) / width) + ((len(data.Question) + 5 + width - 1) / width) + 1
}
}
}
for i := 0; i < lineNum; i++ {
fmt.Printf("\033[A\033[K\033[0G")
}
fmt.Printf(
tui.Format(tui.FmtBold, tui.FgColorGrey) +
"[" + tui.FgColorRed + "!" + tui.FgColorGrey + "]" + tui.FmtBoldReset + " " +
" Invalid input, please try again!\n",
)
if data.Notice != "" {
fmt.Printf(
tui.Format(tui.FmtBold, tui.FgColorGrey) +
"[" + tui.FgColorGold + "!" + tui.FgColorGrey + "]" + tui.FmtBoldReset + " " +
tui.FmtItalic + data.Notice + tui.FmtReset + "\n",
)
//fmt.Printf("\033[1m\033[38;5;247m[\033[38;5;214m!\033[38;5;247m]\033[22m \033[3m%s\033[0m\n", data.Notice)
} else if data.Validator.Notice() != "" {
fmt.Printf(
tui.Format(tui.FmtBold, tui.FgColorGrey) +
"[" + tui.FgColorGold + "!" + tui.FgColorGrey + "]" + tui.FmtBoldReset + " " +
tui.FmtItalic + data.Validator.Notice() + tui.FmtReset + "\n",
)
}
if data.Question != "" {
fmt.Printf(
tui.Format(tui.FmtBold, tui.FgColorGrey) +
"[" + tui.FgColorGold + "?" + tui.FgColorGrey + "]" + tui.FmtReset + " " +
data.Question + " " + tui.FgColorGrey + ">>" + tui.Format(tui.FmtItalic, tui.FgColorGold) + "\n",
)
//fmt.Printf("\033[1m\033[38;5;247m[\033[38;5;214m?\033[38;5;247m]\033[0m %s \033[38;5;247m>>\033[3m\033[38;5;214m\n", data.Question)
}
continue
}
}
break
}
fmt.Println("\033[0m")
return &input, nil
}