Fix the multiselect highlight issue
This commit is contained in:
parent
c0b97850ae
commit
fe2ec158be
11
filter.go
11
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())
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue