Skip to content

Commit

Permalink
show server in fuzzy search
Browse files Browse the repository at this point in the history
  • Loading branch information
Evidlo committed Aug 6, 2021
1 parent a0b3cae commit 17682c2
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions ui/fuzzy-search-modal.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ type FuzzySearchModal struct {

roomList []*rooms.Room
roomTitles []string
roomServers []string

parent *MainView
}
Expand All @@ -55,7 +56,9 @@ func NewFuzzySearchModal(mainView *MainView, width int, height int) *FuzzySearch

fs.InitList(mainView.rooms)

fs.results = mauview.NewTextView().SetRegions(true)
fs.results = mauview.NewTextView().
SetRegions(true).
SetDynamicColors(true)
fs.search = mauview.NewInputArea().
SetChangedFunc(fs.changeHandler).
SetTextColor(tcell.ColorWhite).
Expand Down Expand Up @@ -96,6 +99,7 @@ func (fs *FuzzySearchModal) InitList(rooms map[id.RoomID]*RoomView) {
}
fs.roomList = append(fs.roomList, room.Room)
fs.roomTitles = append(fs.roomTitles, room.Room.GetTitle())
fs.roomServers = append(fs.roomServers, room.Room.GetServer())
}
}

Expand All @@ -106,7 +110,14 @@ func (fs *FuzzySearchModal) changeHandler(str string) {
sort.Sort(fs.matches)
fs.results.Clear()
for _, match := range fs.matches {
fmt.Fprintf(fs.results, `["%d"]%s[""]%s`, match.OriginalIndex, match.Target, "\n")
fmt.Fprintf(
fs.results,
`["%d"]%s[""] [gray]%s[white]%s`,
match.OriginalIndex,
mauview.Escape(match.Target),
fs.roomServers[match.OriginalIndex],
"\n",
)
}
//fs.parent.parent.Render()
fs.results.Highlight(strconv.Itoa(fs.matches[0].OriginalIndex))
Expand Down

0 comments on commit 17682c2

Please sign in to comment.