Files

56 lines
1.8 KiB
Go

// Copyright (c) 2026 Storm Dragon
// SPDX-License-Identifier: GPL-3.0-or-later
// Package applicationoverrides defines built-in, event-loop-owned application
// adapters. Adapters interpret snapshots; they never own devices or persistence.
package applicationoverrides
import (
"git.stormux.org/storm/fenrir/internal/command"
"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/screen"
)
type Region struct {
Name, Text string
}
// Read includes the region's name for an explicit read. Automatic updates can
// use Text alone when repeating the name would add unnecessary speech.
func (r Region) Read() string {
text := r.Text
if text == "" {
text = i18n.T("Information unavailable")
}
if r.Name == "" {
return text
}
return i18n.Format("{0}: {1}", r.Name, text)
}
// Frame supplements the ordinary reader. OwnsPresentation replaces generic
// automatic diffs, never raw review/copy or typing echo. Updates are independent
// of focus: a focus change must not swallow a simultaneous chat message.
type Frame struct {
Recognized, OwnsPresentation, FocusChanged bool
Focus, Updates []presentation.Message
Regions []Region
// Input limits typing/deletion echo to an application's actual input field.
Input *screen.Region
// InputCursor preserves navigation feedback inside Input while automatic
// terminal diffs remain suppressed. Activity is indeterminate working state.
InputCursor, Activity bool
}
type Adapter interface {
Name() string
Configure(*config.Settings)
Observe(screen.Snapshot) Frame
Command(command.ID) (presentation.CommandResult, bool)
// Reset forgets screen-derived baselines after suspension or layout changes.
Reset()
Close()
}