// Is there currently a search in progress
searching bool
+
+ // Stores the history for searching
+ searchHistory []string
)
// BeginSearch starts a search
func BeginSearch() {
+ searchHistory = append(searchHistory, "")
+ messenger.historyNum = len(searchHistory) - 1
searching = true
messenger.hasPrompt = true
messenger.Message("Find: ")
// EndSearch stops the current search
func EndSearch() {
+ searchHistory[len(searchHistory)-1] = messenger.response
searching = false
messenger.hasPrompt = false
messenger.Clear()
}
}
- messenger.HandleEvent(event)
+ messenger.HandleEvent(event, searchHistory)
if messenger.cursorx < 0 {
// Done
var charPos int
text := v.Buf.String()
if down {
- str = text[searchStart:]
+ str = string([]rune(text)[searchStart:])
charPos = searchStart
} else {
- str = text[:searchStart]
+ str = string([]rune(text)[:searchStart])
}
r, err := regexp.Compile(searchStr)
if settings["ignorecase"].(bool) {
return
}
- v.Cursor.CurSelection[0] = charPos + runePos(match[0], str)
- v.Cursor.CurSelection[1] = charPos + runePos(match[1], str)
- v.Cursor.X, v.Cursor.Y = FromCharPos(charPos+match[1]-1, v.Buf)
+ v.Cursor.CurSelection[0] = FromCharPos(charPos+runePos(match[0], str), v.Buf)
+ v.Cursor.CurSelection[1] = FromCharPos(charPos+runePos(match[1], str), v.Buf)
+ v.Cursor.Loc = v.Cursor.CurSelection[1]
if v.Relocate() {
v.matches = Match(v)
}