Fixed a few cosmetic bugs
- Clear status messages when setting or deleting fields - Fixed "Filter" status label
This commit is contained in:
parent
0c377e231a
commit
5f76836166
|
@ -10,8 +10,10 @@ func Error(err error) tea.Msg {
|
|||
return ErrorMsg(err)
|
||||
}
|
||||
|
||||
func SetStatus(msg string) tea.Msg {
|
||||
return StatusMsg(msg)
|
||||
func SetStatus(msg string) tea.Cmd {
|
||||
return func() tea.Msg {
|
||||
return StatusMsg(msg)
|
||||
}
|
||||
}
|
||||
|
||||
func PromptForInput(prompt string, onDone func(value string) tea.Msg) tea.Msg {
|
||||
|
|
|
@ -27,7 +27,7 @@ func (rs NewResultSet) ModeMessage() string {
|
|||
}
|
||||
|
||||
if rs.currentFilter != "" {
|
||||
modeLine = fmt.Sprintf("%v - PromptForFilter: '%v'", modeLine, rs.currentFilter)
|
||||
modeLine = fmt.Sprintf("%v - Filter: '%v'", modeLine, rs.currentFilter)
|
||||
}
|
||||
return modeLine
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ func NewKeyBindingController(service *keybindings.Service) *KeyBindingController
|
|||
func (kb *KeyBindingController) Rebind(bindingName string, newKey string, force bool) tea.Msg {
|
||||
err := kb.service.Rebind(bindingName, newKey, force)
|
||||
if err == nil {
|
||||
return events.SetStatus(fmt.Sprintf("Binding '%v' now bound to '%v'", bindingName, newKey))
|
||||
return events.StatusMsg(fmt.Sprintf("Binding '%v' now bound to '%v'", bindingName, newKey))
|
||||
} else if force {
|
||||
return events.Error(errors.Wrapf(err, "cannot bind '%v' to '%v'", bindingName, newKey))
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ func (kb *KeyBindingController) Rebind(bindingName string, newKey string, force
|
|||
if err != nil {
|
||||
return events.Error(err)
|
||||
}
|
||||
return events.SetStatus(fmt.Sprintf("Binding '%v' now bound to '%v'", bindingName, newKey))
|
||||
return events.StatusMsg(fmt.Sprintf("Binding '%v' now bound to '%v'", bindingName, newKey))
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -152,7 +152,7 @@ func (c *TableReadController) doIfNoneDirty(cmd tea.Cmd) tea.Msg {
|
|||
Prompt: "reset modified items? ",
|
||||
OnDone: func(value string) tea.Msg {
|
||||
if value != "y" {
|
||||
return events.SetStatus("operation aborted")
|
||||
return events.StatusMsg("operation aborted")
|
||||
}
|
||||
|
||||
return cmd()
|
||||
|
@ -321,7 +321,7 @@ func (c *TableReadController) CopyItemToClipboard(idx int) tea.Msg {
|
|||
clipboard.Write(clipboard.FmtText, []byte(sb.String()))
|
||||
})
|
||||
|
||||
return events.SetStatus(applyToN("", itemCount, "item", "items", " copied to clipboard"))
|
||||
return events.StatusMsg(applyToN("", itemCount, "item", "items", " copied to clipboard"))
|
||||
}
|
||||
|
||||
func (c *TableReadController) initClipboard() error {
|
||||
|
|
|
@ -288,7 +288,7 @@ func (twc *TableWriteController) PutItems() tea.Msg {
|
|||
Prompt: promptMessage,
|
||||
OnDone: func(value string) tea.Msg {
|
||||
if value != "y" {
|
||||
return events.SetStatus("operation aborted")
|
||||
return events.StatusMsg("operation aborted")
|
||||
}
|
||||
|
||||
if err := twc.state.withResultSetReturningError(func(rs *models.ResultSet) error {
|
||||
|
@ -370,7 +370,7 @@ func (twc *TableWriteController) DeleteMarked() tea.Msg {
|
|||
Prompt: applyToN("delete ", len(markedItems), "item", "items", "? "),
|
||||
OnDone: func(value string) tea.Msg {
|
||||
if value != "y" {
|
||||
return events.SetStatus("operation aborted")
|
||||
return events.StatusMsg("operation aborted")
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
|
|
|
@ -139,7 +139,7 @@ func NewModel(
|
|||
for _, arg := range args {
|
||||
s.WriteString(arg)
|
||||
}
|
||||
return events.SetStatus(s.String())
|
||||
return events.StatusMsg(s.String())
|
||||
},
|
||||
"rebind": func(ctx commandctrl.ExecContext, args []string) tea.Msg {
|
||||
if len(args) != 2 {
|
||||
|
@ -189,7 +189,10 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||
cmd := m.setMainViewIndex(msg.ViewIndex)
|
||||
return m, cmd
|
||||
case controllers.ResultSetUpdated:
|
||||
return m, m.tableView.Refresh()
|
||||
return m, tea.Batch(
|
||||
m.tableView.Refresh(),
|
||||
events.SetStatus(msg.StatusMessage()),
|
||||
)
|
||||
case tea.KeyMsg:
|
||||
if !m.statusAndPrompt.InPrompt() && !m.tableSelect.Visible() {
|
||||
switch {
|
||||
|
|
|
@ -7,6 +7,7 @@ import (
|
|||
"github.com/lmika/audax/internal/common/sliceutils"
|
||||
"github.com/lmika/audax/internal/common/ui/events"
|
||||
"github.com/lmika/audax/internal/dynamo-browse/ui/teamodels/layout"
|
||||
"log"
|
||||
)
|
||||
|
||||
// StatusAndPrompt is a resizing model which displays a submodel and a status bar. When the start prompt
|
||||
|
@ -67,7 +68,11 @@ func (s *StatusAndPrompt) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||
pendingInput := s.pendingInput
|
||||
s.pendingInput = nil
|
||||
|
||||
return s, func() tea.Msg { return pendingInput.OnDone(s.textInput.Value()) }
|
||||
return s, func() tea.Msg {
|
||||
m := pendingInput.OnDone(s.textInput.Value())
|
||||
log.Printf("return msg type = %T", m)
|
||||
return m
|
||||
}
|
||||
default:
|
||||
if msg.Type == tea.KeyRunes {
|
||||
msg.Runes = sliceutils.Filter(msg.Runes, func(r rune) bool { return r != '\x0d' && r != '\x0a' })
|
||||
|
|
Loading…
Reference in a new issue