minor changes in formatting

fixed the blinking text issue
This commit is contained in:
aditya-K2 2021-10-17 22:26:26 +05:30
parent 24f94fc4e5
commit c3ede5403e

View File

@ -1,38 +1,39 @@
package main package main
import(
"strings" import (
"strconv" "strconv"
"strings"
) )
func strTime(e float64) string{ func strTime(e float64) string {
a := int(e) a := int(e)
var min, seconds string var min, seconds string
if (a/60 < 10){ if a/60 < 10 {
min = "0" min = "0"
min += strconv.Itoa(a/60) min += strconv.Itoa(a / 60)
} else { } else {
min = strconv.Itoa(a/60) min = strconv.Itoa(a / 60)
} }
if (a%60 < 10){ if a%60 < 10 {
seconds = "0" seconds = "0"
seconds += strconv.Itoa(a%60) seconds += strconv.Itoa(a % 60)
} else{ } else {
seconds = strconv.Itoa(a%60) seconds = strconv.Itoa(a % 60)
} }
return min + ":" + seconds return min + ":" + seconds
} }
func insertAt(inputString, stringTobeInserted string, index int) string{ func insertAt(inputString, stringTobeInserted string, index int) string {
s := inputString[:index] + stringTobeInserted + inputString[index:] s := inputString[:index] + stringTobeInserted + inputString[index:]
return s return s
} }
func getText(width , percentage float64, eta string) string{ func getText(width, percentage float64, eta string) string {
q := "[#000000:#ffffff:bl]" q := "[#000000:#ffffff:b]"
var a string var a string
a += strings.Repeat(" ", int(width) - len(eta)) a += strings.Repeat(" ", int(width)-len(eta))
a = insertAt(a, eta, int(width/2) - 10) a = insertAt(a, eta, int(width/2)-10)
a = insertAt(a, "[-:-:-]", int(width * percentage / 100)) a = insertAt(a, "[-:-:-]", int(width*percentage/100))
q += a q += a
return q return q
} }