2022-03-13 17:48:49 +00:00
|
|
|
package readline
|
|
|
|
|
|
|
|
// FindMode defines how the autocomplete suggestions display
|
|
|
|
type FindMode int
|
|
|
|
|
|
|
|
const (
|
|
|
|
// HistoryFind - Searching through history
|
|
|
|
HistoryFind = iota
|
|
|
|
// CompletionFind - Searching through completion items
|
|
|
|
CompletionFind
|
|
|
|
// RegisterFind - The user can complete/search registers
|
|
|
|
RegisterFind
|
|
|
|
)
|
|
|
|
|
|
|
|
func (rl *Instance) backspaceTabFind() {
|
|
|
|
if len(rl.tfLine) > 0 {
|
|
|
|
rl.tfLine = rl.tfLine[:len(rl.tfLine)-1]
|
|
|
|
}
|
|
|
|
rl.updateTabFind([]rune{})
|
|
|
|
}
|
|
|
|
|
|
|
|
// Filter and refresh (print) a list of completions. The caller should have reset
|
|
|
|
// the virtual completion system before, so that should not clash with this.
|
|
|
|
func (rl *Instance) updateTabFind(r []rune) {
|
|
|
|
|
|
|
|
rl.tfLine = append(rl.tfLine, r...)
|
|
|
|
|
|
|
|
// The search regex is common to all search modes
|
2023-03-26 00:14:26 +00:00
|
|
|
rl.search = string(rl.tfLine)
|
2022-03-13 17:48:49 +00:00
|
|
|
|
|
|
|
// We update and print
|
|
|
|
rl.clearHelpers()
|
|
|
|
rl.getTabCompletion()
|
|
|
|
rl.renderHelpers()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (rl *Instance) resetTabFind() {
|
|
|
|
rl.modeTabFind = false
|
|
|
|
// rl.modeAutoFind = false // Added, because otherwise it gets stuck on search completions
|
|
|
|
|
|
|
|
rl.mainHist = false
|
|
|
|
rl.tfLine = []rune{}
|
|
|
|
|
|
|
|
rl.clearHelpers()
|
|
|
|
rl.resetTabCompletion()
|
|
|
|
|
|
|
|
// If we were browsing history, we don't load the completions again
|
|
|
|
// if rl.searchMode != HistoryFind {
|
|
|
|
rl.getTabCompletion()
|
|
|
|
// }
|
|
|
|
|
|
|
|
rl.renderHelpers()
|
|
|
|
}
|