Skip to content
This repository has been archived by the owner on Aug 31, 2018. It is now read-only.

Commit

Permalink
Use VisibleChoices
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Boyt committed Nov 18, 2013
1 parent 54ccb6d commit fc40be0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion selecta.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,16 @@ func main() {
if initialSearch == "" {
initialSearch = c.String("s")
}
search := selecta.BlankSearch(choices, initialSearch, 0)

// set up termbox
err := termbox.Init()
if err != nil {
panic(err)
}

_, height := termbox.Size()
search := selecta.BlankSearch(choices, initialSearch, height - 1)

termbox.SetInputMode(termbox.InputEsc)

termbox.Clear(termbox.ColorDefault, termbox.ColorDefault)
Expand Down Expand Up @@ -106,6 +108,9 @@ func DrawApp(s *selecta.Search) {
termbox.SetCursor(2+len(s.Query), 0)

for i, match := range s.Matches {
if i >= s.VisibleChoices {
break
}
choice := match.Value
highlight := false
if s.Index == i {
Expand Down
4 changes: 2 additions & 2 deletions selecta/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type Search struct {
Index int
Query string
Done bool
visibleChoices int
VisibleChoices int
}

// Match type & Matches sortable slice
Expand Down Expand Up @@ -78,7 +78,7 @@ func (s *Search) Down() {
nextIndex := s.Index + 1
if nextIndex == len(s.Matches) {
return
} else if nextIndex == s.visibleChoices {
} else if nextIndex == s.VisibleChoices {
return
}

Expand Down

0 comments on commit fc40be0

Please sign in to comment.