Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ynerant
cemantix-charm
Commits
0ea390fc
Verified
Commit
0ea390fc
authored
Apr 28, 2022
by
ynerant
Browse files
Consider true word length
parent
ed640195
Changes
1
Hide whitespace changes
Inline
Side-by-side
main.go
View file @
0ea390fc
...
...
@@ -20,6 +20,7 @@ import (
"strings"
"syscall"
"time"
"unicode/utf8"
)
var
(
...
...
@@ -181,8 +182,8 @@ func (m model) InputWord() (model, tea.Cmd) {
input
:=
m
.
textInput
.
Value
()
m
.
lastWord
=
input
if
len
(
input
)
>
m
.
maxLength
{
m
.
maxLength
=
len
(
input
)
if
utf8
.
RuneCountInString
(
input
)
>
m
.
maxLength
{
m
.
maxLength
=
utf8
.
RuneCountInString
(
input
)
}
// TODO: Get distance and ranking from a file
w
:=
word
{
input
,
200
*
rand
.
Float64
()
-
100
,
rand
.
Intn
(
1000
)}
...
...
@@ -235,7 +236,7 @@ func (w word) View(m model) string {
return
fmt
.
Sprintf
(
"* %s %s %s %4d %s
\n
"
,
w
.
content
+
strings
.
Repeat
(
" "
,
m
.
maxLength
-
len
(
w
.
content
)),
w
.
content
+
strings
.
Repeat
(
" "
,
m
.
maxLength
-
utf8
.
RuneCountInString
(
w
.
content
)),
distStr
,
emoji
,
w
.
ranking
,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment