Skip to content

Commit

Permalink
Added ability to press escape to quit input boxes.
Browse files Browse the repository at this point in the history
  • Loading branch information
a-h committed Sep 6, 2020
1 parent da5d5e5 commit bc84b28
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion browse/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,6 @@ func (o *Input) Draw() {

textStyle := defaultStyle
if o.ActiveIndex == 0 {
textStyle = defaultStyle.Underline(true)
NewText(o.Screen, o.X, o.Y+y+2, defaultStyle, ">").Draw()
}
NewText(o.Screen, o.X+2, o.Y+y+2, textStyle, o.Text).Draw()
Expand Down Expand Up @@ -685,6 +684,10 @@ func (o *Input) Focus() (text string, ok bool) {
o.Screen.Sync()
case *tcell.EventKey:
switch ev.Key() {
case tcell.KeyBacktab:
o.Up()
case tcell.KeyTab:
o.Down()
case tcell.KeyUp:
o.Up()
case tcell.KeyDown:
Expand All @@ -699,6 +702,8 @@ func (o *Input) Focus() (text string, ok bool) {
case 2:
return o.Text, false
}
case tcell.KeyEscape:
return o.Text, false
}
}
o.Draw()
Expand Down

0 comments on commit bc84b28

Please sign in to comment.