// Cthulhu screen reader. // Copyright (c) 2026 Storm Dragon // Authors: Storm Dragon, Angus Kola // // This program is free software: you can redistribute it and/or modify it // under the terms of the GNU General Public License as published by the Free // Software Foundation, either version 3 of the License, or (at your option) // any later version. // // This program is distributed in the hope that it will be useful, but WITHOUT // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for // more details. // // You should have received a copy of the GNU General Public License along with // this program. If not, see . package app import ( "git.stormux.org/storm/cthulhu/internal/config" "git.stormux.org/storm/cthulhu/internal/input" ) type outputQueue struct { speech speechEnqueuer sounds soundService braille brailleFrameEnqueuer live *liveSettings } func (queue outputQueue) Enqueue(request speechRequest) { if len(request.Sound) != 0 && (queue.sounds == nil || !queue.sounds.EnqueueBatch(request.Sound)) && request.FallbackText != "" { request.Text = request.FallbackText request.Chunks = request.FallbackChunks } if request.Text != "" || len(request.ReadAll) != 0 { queue.speech.Enqueue(request) } if queue.braille != nil && queue.live != nil && request.Text != "" && request.Role == "system" && request.Cause != "read-all" && request.Cause != "document-caret-line" { if flasher, ok := queue.braille.(interface { Flash(string, config.BrailleOptions) bool }); ok { flasher.Flash(request.Text, queue.live.Load().Braille) } } } func (queue outputQueue) Interrupt() { queue.speech.Interrupt() } func (queue outputQueue) InterruptForUser() { if speech, ok := queue.speech.(interface{ InterruptForUser() }); ok { speech.InterruptForUser() } else { queue.speech.Interrupt() } } func (queue outputQueue) InterruptForInput(event input.Event) bool { if speech, ok := queue.speech.(interface{ InterruptForInput(input.Event) bool }); ok { return speech.InterruptForInput(event) } queue.InterruptForUser() return true } type discardSpeech struct{} func (discardSpeech) Enqueue(speechRequest) {} func (discardSpeech) Interrupt() {}