diff --git a/filter.go b/filter.go index 85fb98b..7f922bb 100644 --- a/filter.go +++ b/filter.go @@ -89,12 +89,15 @@ func RenderHelp(s *State, inputs Items) { func RenderMain(s *State, inputs Items) { y := 2 - status := fmt.Sprintf("[Line: %d][? For help]: %s", s.Current+1, s.UserInput) + //status := fmt.Sprintf("[Line: %d][? For help]: %s", s.Current+1, s.UserInput) + status := fmt.Sprintf("L: %d, U: %d, S: %d [Line: %d][? For help]: %s", s.LowerBound, s.UpperBound, s.SelectionStartLine, s.Current+1, s.UserInput) drawText(*s.Screen, 0, 0, xmax-1, 1, helpStyle, status) drawText(*s.Screen, len(status), 0, xmax-1, 1, cursorStyle, "⎥") + for i, item := range (*inputs)[s.LowerBound:s.UpperBound] { style := tcell.StyleDefault arrowStyle := normalArrow + index := s.LowerBound + i var txt string @@ -110,14 +113,14 @@ func RenderMain(s *State, inputs Items) { } if s.InSelectionMode { - if (s.SelectionStartLine < s.LowerBound && i <= s.Current) || (s.SelectionStartLine > s.UpperBound && i >= s.Current) { + if (s.SelectionStartLine < s.LowerBound && index <= s.Current) || (s.SelectionStartLine > s.UpperBound && index >= s.Current) { style = selectionStyle arrowStyle = selectionArrow } else { low := min(s.SelectionStartLine, s.Current) high := max(s.SelectionStartLine, s.Current) - if i >= low && i <= high { + if index >= low && index <= high { style = selectionStyle arrowStyle = selectionArrow } @@ -191,6 +194,8 @@ func HandleMain(state *State, ev tcell.EventKey, input Items) { } else if ev.Key() == tcell.KeyCtrlH { state.CurrentScene = 1 + } else if ev.Key() == tcell.KeyBackspace { + state.UserInput = string(state.UserInput[:len(state.UserInput)-2]) } else { state.UserInput = state.UserInput + string(ev.Rune()) } diff --git a/utils.go b/utils.go index 397ea29..6349047 100644 --- a/utils.go +++ b/utils.go @@ -23,9 +23,8 @@ import ( ) type Item struct { - Text string - Selected bool - Highlight bool + Text string + Selected bool } type Items = *[]*Item