Skip to content

Commit

Permalink
Merge pull request #12 from herzrasen/updated-styling
Browse files Browse the repository at this point in the history
updated styling
  • Loading branch information
herzrasen authored Mar 18, 2023
2 parents 6ab04b6 + 591dfc9 commit 3c1f964
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions search/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"github.com/herzrasen/hist/fuzzy"
"github.com/herzrasen/hist/record"
"github.com/rivo/tview"
"strings"
)

type ListClient interface {
Expand All @@ -26,8 +25,14 @@ func NewSearcher(listClient ListClient) *Searcher {
list := tview.NewList().
ShowSecondaryText(false).
SetShortcutStyle(tcell.Style{}).
SetSelectedStyle(tcell.StyleDefault.
Foreground(tcell.ColorPaleGreen)).
SetMainTextColor(tcell.ColorViolet).
SetWrapAround(true)
input := tview.NewInputField()
input.SetFieldStyle(tcell.StyleDefault.
Italic(true).
Foreground(tcell.ColorLightBlue))
flex := tview.NewFlex().SetDirection(tview.FlexRow).
AddItem(list, 0, 20, false).
AddItem(input, 0, 2, true)
Expand All @@ -37,8 +42,6 @@ func NewSearcher(listClient ListClient) *Searcher {
SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
numItems := list.GetItemCount() - 1
currentItem := list.GetCurrentItem()
oldItemText, _ := list.GetItemText(currentItem)
list.SetItemText(currentItem, strings.TrimPrefix(oldItemText, "> "), "")
switch event.Key() {
case tcell.KeyEnter:
selectedIndex := list.GetCurrentItem()
Expand All @@ -51,17 +54,13 @@ func NewSearcher(listClient ListClient) *Searcher {
nextItem = currentItem - 1
}
list.SetCurrentItem(nextItem)
itemText, _ := list.GetItemText(nextItem)
list.SetItemText(nextItem, "> "+itemText, "")
return nil
case tcell.KeyDown:
nextItem := currentItem + 1
if currentItem >= numItems {
nextItem = numItems
}
list.SetCurrentItem(nextItem)
itemText, _ := list.GetItemText(nextItem)
list.SetItemText(nextItem, "> "+itemText, "")
return nil
}
return event
Expand Down

0 comments on commit 3c1f964

Please sign in to comment.