package commandctrl import ( "context" tea "github.com/charmbracelet/bubbletea" ) type commandCtlKeyType struct{} var commandCtlKey = commandCtlKeyType{} func PostMsg(ctx context.Context, msg tea.Msg) { cmdCtl, ok := ctx.Value(commandCtlKey).(*CommandController) if ok { cmdCtl.postMessage(msg) } } func SelectedItemIndex(ctx context.Context) (int, bool) { cmdCtl, ok := ctx.Value(commandCtlKey).(*CommandController) if !ok { return 0, false } return cmdCtl.uiStateProvider.SelectedItemIndex(), true }