// 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) } }