After commit c018f5fd29 Fenrir is being switched over to go. If you do not want to be part of the testing process, please switch to master.
This commit is contained in:
1 parent
c018f5fd29
commit
0e50de4c76
1047 files changed
+58364
-63747
No files matched your search
@@ -0,0 +1,48 @@
|
||||
// Copyright (c) 2026 Storm Dragon
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
package reader
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.stormux.org/storm/fenrir/internal/screen"
|
||||
"git.stormux.org/storm/fenrir/internal/spellcheck"
|
||||
)
|
||||
|
||||
// Spellcheck_word observes the active cursor without moving it or entering review.
|
||||
func (r *Reader) Spellcheck_word() string { return r.review.Spellcheck_word() }
|
||||
|
||||
// Completed_words contains only screen-confirmed typing from the latest Update.
|
||||
// Raw keys, cursor navigation, deletion and passive output never supply words.
|
||||
func (r *Reader) Completed_words() []string { return r.completedWords }
|
||||
|
||||
func (r *Reader) completed_word(index int, snapshot screen.Snapshot) {
|
||||
char := snapshot.Cells[index]
|
||||
if !spellcheck.Separator(char) {
|
||||
return
|
||||
}
|
||||
end := index
|
||||
for end > 0 && spellcheck.Separator(snapshot.Cells[end-1]) {
|
||||
end--
|
||||
}
|
||||
start := end
|
||||
for start > 0 && !spellcheck.Separator(snapshot.Cells[start-1]) {
|
||||
start--
|
||||
}
|
||||
if start == end {
|
||||
return
|
||||
}
|
||||
value := string(snapshot.Cells[start:end])
|
||||
word := spellcheck.Word(value)
|
||||
if word == "" {
|
||||
return
|
||||
}
|
||||
key := fmt.Sprintf("%d:%d:%s", start, snapshot.Cols, word)
|
||||
if key == r.lastCompletedWord {
|
||||
return
|
||||
}
|
||||
r.lastCompletedWord = key
|
||||
if len(r.completedWords) < 32 {
|
||||
r.completedWords = append(r.completedWords, word)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user