Display ranking only for positive values
Signed-off-by: Yohann D'ANELLO <ynerant@crans.org>
This commit is contained in:
parent
4ecbe2540e
commit
f6cf031a22
10
main.go
10
main.go
|
@ -86,10 +86,10 @@ func teaHandler(s ssh.Session) (tea.Model, []tea.ProgramOption) {
|
||||||
ti.CharLimit = 26
|
ti.CharLimit = 26
|
||||||
ti.Width = 26
|
ti.Width = 26
|
||||||
|
|
||||||
content, err := ioutil.ReadFile("cemantics.txt")
|
content, err := ioutil.ReadFile("cemantix.txt")
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Error while opening cemantics.txt: %s", err)
|
log.Printf("Error while opening cemantix.txt: %s", err)
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -255,8 +255,10 @@ func (w word) View(m model) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
var progressBar string
|
var progressBar string
|
||||||
|
var ranking string = " "
|
||||||
if w.ranking > 0 {
|
if w.ranking > 0 {
|
||||||
progressBar = m.progressBar.ViewAs(float64(w.ranking) / 1000.0)
|
progressBar = m.progressBar.ViewAs(float64(w.ranking) / 1000.0)
|
||||||
|
ranking = fmt.Sprintf("%4d", w.ranking)
|
||||||
}
|
}
|
||||||
|
|
||||||
distStr := fmt.Sprintf("%.02f", w.distance)
|
distStr := fmt.Sprintf("%.02f", w.distance)
|
||||||
|
@ -271,11 +273,11 @@ func (w word) View(m model) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
return fmt.Sprintf(
|
return fmt.Sprintf(
|
||||||
"* %s %s %s %4d %s\n",
|
"* %s %s %s %s %s\n",
|
||||||
w.content+strings.Repeat(" ", m.maxLength-utf8.RuneCountInString(w.content)),
|
w.content+strings.Repeat(" ", m.maxLength-utf8.RuneCountInString(w.content)),
|
||||||
distStr,
|
distStr,
|
||||||
emoji,
|
emoji,
|
||||||
w.ranking,
|
ranking,
|
||||||
progressBar,
|
progressBar,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue