switch progress & textinput to use the new color variables
This commit is contained in:
parent
c483788ca5
commit
689d9d1333
2 changed files with 75 additions and 19 deletions
|
@ -2,6 +2,7 @@ package progress
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"git.shadowhosting.xyz/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 {
|
||||||
|
|
|
@ -2,6 +2,7 @@ package textinput
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"git.shadowhosting.xyz/Eggactyl/tui"
|
||||||
"git.shadowhosting.xyz/Eggactyl/tui/validators"
|
"git.shadowhosting.xyz/Eggactyl/tui/validators"
|
||||||
|
|
||||||
"golang.org/x/term"
|
"golang.org/x/term"
|
||||||
|
@ -17,13 +18,26 @@ type InputData struct {
|
||||||
func New(data InputData) (*string, error) {
|
func New(data InputData) (*string, 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",
|
||||||
|
)
|
||||||
} else if data.Validator != nil && data.Validator.Notice() != "" {
|
} else if data.Validator != nil && data.Validator.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.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 != "" {
|
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;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.FgColorGrey + ">>" + tui.Format(tui.FmtItalic, tui.FgColorGold) + "\n",
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
var input string
|
var input string
|
||||||
|
@ -59,16 +73,33 @@ func New(data InputData) (*string, error) {
|
||||||
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.Println("\033[0m\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",
|
||||||
|
)
|
||||||
|
|
||||||
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",
|
||||||
|
)
|
||||||
} else if data.Validator != nil {
|
} else if data.Validator != nil {
|
||||||
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())
|
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 != "" {
|
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;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.FgColorGrey + ">>" + tui.Format(tui.FmtItalic, tui.FgColorGold) + "\n",
|
||||||
|
)
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -97,16 +128,34 @@ func New(data InputData) (*string, error) {
|
||||||
fmt.Printf("\033[A\033[K\033[0G")
|
fmt.Printf("\033[A\033[K\033[0G")
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println("\033[0m\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",
|
||||||
|
)
|
||||||
|
|
||||||
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)
|
||||||
} else if data.Validator.Notice() != "" {
|
} else if data.Validator.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.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 != "" {
|
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;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.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
|
continue
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue