Tabulation issues

This commit is contained in:
Yohann D'ANELLO 2022-05-04 21:41:42 +02:00
parent 04025866b2
commit b591a6d799
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85

12
main.go
View File

@ -169,10 +169,10 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
} }
lineWidth := lipgloss.Width(fmt.Sprintf( lineWidth := lipgloss.Width(fmt.Sprintf(
"* %s %s %s %4d ", "* %s %s %s %4d ",
strings.Repeat(" ", m.maxLength), strings.Repeat(" ", m.maxLength),
"-100.00", "-100.00",
" ", " ",
42, 42,
)) ))
m.progressBar.Width = msg.Width - lineWidth m.progressBar.Width = msg.Width - lineWidth
@ -221,10 +221,10 @@ func (m model) InputWord() (model, tea.Cmd) {
m.words = InsertWord(m.words, w) m.words = InsertWord(m.words, w)
lineWidth := lipgloss.Width(fmt.Sprintf( lineWidth := lipgloss.Width(fmt.Sprintf(
"* %s %s %s %5d ", "* %s %s %s %5d ",
strings.Repeat(" ", m.maxLength), strings.Repeat(" ", m.maxLength),
"-00.00", "-00.00",
" ", " ",
1000, 1000,
)) ))
m.progressBar.Width = m.wordsViewport.Width - lineWidth m.progressBar.Width = m.wordsViewport.Width - lineWidth
@ -255,7 +255,7 @@ func (w word) View(m model) string {
} }
var progressBar string var progressBar string
var ranking 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) ranking = fmt.Sprintf("%4d", w.ranking)
@ -273,7 +273,7 @@ func (w word) View(m model) string {
} }
return fmt.Sprintf( return fmt.Sprintf(
"* %s %s %s %s %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,