Add a very basic selection mode
This commit is contained in:
parent
ce8f6e0e82
commit
459ab8d739
17
filter.go
17
filter.go
|
@ -38,6 +38,13 @@ var highlight tcell.Style
|
|||
var selectedStyle tcell.Style
|
||||
var helpStyle tcell.Style
|
||||
|
||||
type State struct {
|
||||
Current int
|
||||
InSelectionMode bool
|
||||
UpperBound int
|
||||
LowerBound int
|
||||
}
|
||||
|
||||
// Draws the given `text` to the screen `s` at the given coordinates. Remember that
|
||||
// the text will be wrapped if it overflow.
|
||||
func drawText(s tcell.Screen, x1, y1, x2, y2 int, style tcell.Style, text string) {
|
||||
|
@ -135,6 +142,8 @@ func main() {
|
|||
|
||||
lowerBound := 0
|
||||
upperBound := min(ymax-3, len(*input))
|
||||
inSelectedMode := false
|
||||
startOfSelection := 0
|
||||
|
||||
// Event loop
|
||||
for !done {
|
||||
|
@ -189,7 +198,13 @@ func main() {
|
|||
upperBound = ymax - 2
|
||||
lowerBound = 0
|
||||
currentLine = 0
|
||||
|
||||
} else if ev.Key() == tcell.KeyCtrlSpace {
|
||||
if inSelectedMode {
|
||||
toggleItems(input, startOfSelection, currentLine)
|
||||
} else {
|
||||
startOfSelection = currentLine
|
||||
}
|
||||
inSelectedMode = !inSelectedMode
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue