Count from 1 instead of 0 when searching packages

I feel like starting from 1 is much better ergonomically while not using
a numpad. This could be added as a config option instead if you would
prefer.
This commit is contained in:
morganamilo 2017-12-30 06:01:55 +00:00
parent 1fabad45e2
commit c0eac580a8
No known key found for this signature in database
GPG key ID: 6FE9E7996B0B082E
3 changed files with 12 additions and 12 deletions

16
cmd.go
View file

@ -323,11 +323,11 @@ func numberMenu(pkgS []string, flags []string) (err error) {
}
if config.SortMode == BottomUp {
aq.printSearch(numpq)
aq.printSearch(numpq + 1)
pq.printSearch()
} else {
pq.printSearch()
aq.printSearch(numpq)
aq.printSearch(numpq + 1)
}
fmt.Printf("\x1b[32m%s\x1b[0m\nNumbers: ", "Type numbers to install. Separate each number with a space.")
@ -349,19 +349,19 @@ func numberMenu(pkgS []string, flags []string) (err error) {
}
// Install package
if num > numaq+numpq-1 || num < 0 {
if num > numaq+numpq || num <= 0 {
continue
} else if num > numpq-1 {
} else if num > numpq {
if config.SortMode == BottomUp {
aurI = append(aurI, aq[numaq+numpq-num-1].Name)
aurI = append(aurI, aq[numaq+numpq-num].Name)
} else {
aurI = append(aurI, aq[num-numpq].Name)
aurI = append(aurI, aq[num-numpq-1].Name)
}
} else {
if config.SortMode == BottomUp {
repoI = append(repoI, pq[numpq-num-1].Name())
repoI = append(repoI, pq[numpq-num].Name())
} else {
repoI = append(repoI, pq[num].Name())
repoI = append(repoI, pq[num-1].Name())
}
}
}

View file

@ -58,9 +58,9 @@ func (s repoQuery) printSearch() {
var toprint string
if config.SearchMode == NumberMenu {
if config.SortMode == BottomUp {
toprint += fmt.Sprintf("\x1b[33m%d\x1b[0m ", len(s)-i-1)
toprint += fmt.Sprintf("\x1b[33m%d\x1b[0m ", len(s)-i)
} else {
toprint += fmt.Sprintf("\x1b[33m%d\x1b[0m ", i)
toprint += fmt.Sprintf("\x1b[33m%d\x1b[0m ", i+1)
}
} else if config.SearchMode == Minimal {
fmt.Println(res.Name())

View file

@ -141,11 +141,11 @@ func syncSearch(pkgS []string) (err error) {
}
if config.SortMode == BottomUp {
aq.printSearch(0)
aq.printSearch(1)
pq.printSearch()
} else {
pq.printSearch()
aq.printSearch(0)
aq.printSearch(1)
}
return nil