The new UI's root model: Screen x viewer focus x native selection x filter edit x modal stack, one inputOwner, keys resolved through the registry, an action table that features extend from register_*.go. Directory reads and previews run in Cmds with tickets: Update never blocks (N-P1-1), stale results are dropped (U-P1-13), failed navigation keeps the panel and a vanished directory climbs up (U-P1-8). q closes layers before asking to quit (U-P1-16), PgDn pages (U-P1-6), the theme list previews live and saves with config.SetKey. Mouse mode is reconciled after every Update; View only reads state. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
44 lines
929 B
Go
44 lines
929 B
Go
package tui
|
|
|
|
import tea "github.com/charmbracelet/bubbletea"
|
|
|
|
// Terminal side effects (mouse mode, image overlay) are not done in View or
|
|
// scattered in handlers: after every Update the desired state is compared
|
|
// with what was applied and one command fixes the difference (design §7.9).
|
|
|
|
const (
|
|
mouseUnknown int8 = iota
|
|
mouseOn
|
|
mouseOff
|
|
)
|
|
|
|
type effects struct {
|
|
mouse int8
|
|
// overlay: imgview.Desired once stage 5C/6.3 lands.
|
|
}
|
|
|
|
type desiredEffects struct {
|
|
Mouse bool
|
|
}
|
|
|
|
func (a *App) desired() desiredEffects {
|
|
return desiredEffects{Mouse: !a.nativeSelect}
|
|
}
|
|
|
|
// reconcile returns the command that brings the terminal to the desired
|
|
// state, or nil.
|
|
func (a *App) reconcile() tea.Cmd {
|
|
d := a.desired()
|
|
want := mouseOff
|
|
if d.Mouse {
|
|
want = mouseOn
|
|
}
|
|
if a.applied.mouse == want {
|
|
return nil
|
|
}
|
|
a.applied.mouse = want
|
|
if want == mouseOn {
|
|
return tea.EnableMouseCellMotion
|
|
}
|
|
return tea.DisableMouse
|
|
}
|