Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature]<main>: ? as dy keyword switch ✨✨ #20

Merged
merged 1 commit into from
Jul 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions internal/ui/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ func (ie *InputElem) Init() tea.Cmd {
}

func (ie *InputElem) View() string {
ie.textInput.Placeholder = ie.suggestKey
if len(ie.suggestKeys) > 0 {
ie.textInput.Placeholder = ie.suggestKey
}
border := lipgloss.RoundedBorder()
box := lipgloss.NewStyle().
BorderStyle(border).
Expand Down Expand Up @@ -117,6 +119,20 @@ func (ie *InputElem) MsgKeyBindings() map[string]map[string]func(v interface{})
}
return cmd
},
"?": func(v interface{}) tea.Cmd {
if !ie.active {
return nil
}

switch {
case ie.textInput.Focused():
if len(ie.suggestKeys) > 0 {
ie.textInput.SetValue(ie.suggestKey)
ie.suggestKey = ie.suggestKeys[random.RandInt(0, len(ie.suggestKeys))]
}
}
return nil
},
"down": func(v interface{}) tea.Cmd {
if !ie.active {
return nil
Expand Down Expand Up @@ -182,9 +198,6 @@ func (ie *InputElem) MsgKeyBindings() map[string]map[string]func(v interface{})
ie.fetcherIdx += 1
pack := ie.fetch(ie.fetcherIdx)
ie.result.ResetList(pack)
case ie.textInput.Focused():
ie.textInput.SetValue(ie.suggestKey)
ie.suggestKey = ie.suggestKeys[random.RandInt(0, len(ie.suggestKeys))]
}
return nil
},
Expand Down
Loading