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
ed640195
Verified
Commit
ed640195
authored
Apr 28, 2022
by
ynerant
Browse files
Order output
parent
b3768042
Changes
1
Hide whitespace changes
Inline
Side-by-side
main.go
View file @
ed640195
...
...
@@ -166,6 +166,17 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return
m
,
tea
.
Batch
(
cmds
...
)
}
func
InsertWord
(
arr
[]
word
,
w
word
)
[]
word
{
if
len
(
arr
)
==
0
{
return
append
(
arr
,
w
)
}
w2
:=
arr
[
len
(
arr
)
-
1
]
if
w
.
distance
<
w2
.
distance
{
return
append
(
arr
,
w
)
}
return
append
(
InsertWord
(
arr
[
:
len
(
arr
)
-
1
],
w
),
w2
)
}
func
(
m
model
)
InputWord
()
(
model
,
tea
.
Cmd
)
{
input
:=
m
.
textInput
.
Value
()
...
...
@@ -174,9 +185,8 @@ func (m model) InputWord() (model, tea.Cmd) {
m
.
maxLength
=
len
(
input
)
}
// TODO: Get distance and ranking from a file
// TODO: Reorder the array
w
:=
word
{
input
,
200
*
rand
.
Float64
()
-
100
,
rand
.
Intn
(
1000
)}
m
.
words
=
appen
d
(
m
.
words
,
w
)
m
.
words
=
InsertWor
d
(
m
.
words
,
w
)
lineWidth
:=
lipgloss
.
Width
(
fmt
.
Sprintf
(
"* %s %s %s %4d "
,
...
...
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