31 lines
1.4 KiB
Go
31 lines
1.4 KiB
Go
// Copyright (c) 2026 Storm Dragon
|
|
// Authors: Storm Dragon, Angus Kola
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
package app
|
|
|
|
import (
|
|
"git.stormux.org/storm/cthulhu/internal/atspi"
|
|
"git.stormux.org/storm/cthulhu/internal/input"
|
|
)
|
|
|
|
// A submission can clear an entry before its message appears in a transcript.
|
|
// Do not mistake that clear for an editing command. Unknown input/caret data,
|
|
// other controls and selected-text replacement keep their existing feedback.
|
|
func (state *eventLoopState) submitted_text_clear(event atspi.Event, activity input.Activity) bool {
|
|
source := event.Source
|
|
if event.Type != atspi.TextDeletedEvent || event.Payload == "" || event.Detail1 != 0 ||
|
|
!activity.PlainEnter || activity.Sequence == 0 || !atspi.IsEchoEditField(source) ||
|
|
(source.Role != "text" && source.Role != "entry") || source.Autocomplete || source.LiveRegion ||
|
|
source.ID() != state.focusedID || !source.TextCaretKnown || source.BrailleCaret != 0 ||
|
|
source.BrailleLineStart != 0 || source.Text != "" || source.TextBeforeCaret != "" || source.BrailleLine != "" ||
|
|
source.SelectionEnd > source.SelectionStart {
|
|
return false
|
|
}
|
|
if state.selection.id == source.ID() && state.selection.end > state.selection.start {
|
|
return false
|
|
}
|
|
// Some providers report selection removal before the deletion itself.
|
|
return state.selectionCaretID != source.ID() || state.selectionCaretSequence != activity.Sequence
|
|
}
|