Files

38 lines
1.3 KiB
Go

// Copyright (c) 2026 Storm Dragon
// SPDX-License-Identifier: GPL-3.0-or-later
package app
import (
"git.stormux.org/storm/fenrir/internal/config"
"git.stormux.org/storm/fenrir/internal/i18n"
"git.stormux.org/storm/fenrir/internal/presentation"
"git.stormux.org/storm/fenrir/internal/spellcheck"
)
func present_misspelling(word string, settings config.Reading, voice Speaker, play func(presentation.Cue) bool) {
accepted := false
if settings.SpellcheckSound {
accepted = play(presentation.Misspelled)
}
if settings.SpellcheckReadWord {
voice.Say(word)
}
if settings.SpellcheckSayMisspelled || settings.SpellcheckSound && !accepted {
voice.Say(i18n.T("misspelled"))
}
}
func (a *application) spellcheck_result(result spellcheck.Result) {
if result.Operation != spellcheck.Automatic {
a.spellMenu.result(result)
return
}
if result.Generation != a.spellSession || result.Revision != a.spellFeedback || !a.lastActive || a.ui.active || a.muted || a.temporarySilence || !a.settings.live.Reading.Spellcheck || !result.Available || result.Err != nil || result.Correct || result.Word == "" {
return
}
present_misspelling(result.Word, a.settings.live.Reading, a.voice, func(cue presentation.Cue) bool {
return a.settings.live.Presentation.Sound.Volume > 0 && a.play(cue)
})
}