Skip to content

Commit

Permalink
Make sure the mischievous shark fin disappears with any UI input
Browse files Browse the repository at this point in the history
I had set it up to vanish if a key was pressed, but @pbksol reported it
sticks around - and I think that's because I didn't handle mouse input
too. Fixes #83.
  • Loading branch information
gcla committed May 7, 2020
1 parent 287dffe commit e24e6c0
Showing 1 changed file with 23 additions and 11 deletions.
34 changes: 23 additions & 11 deletions ui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -3002,18 +3002,30 @@ func Build() (*gowid.App, error) {
Fin = rossshark.New(appViewWithKeys)

if !termshark.ConfBool("main.disable-shark-fin", false) {
steerableFin := appkeys.New(
Fin,
func(evk *tcell.EventKey, app gowid.IApp) bool {
if Fin.Active() {
switch evk.Key() {
case tcell.KeyLeft:
Fin.Dir = rossshark.Backward
case tcell.KeyRight:
Fin.Dir = rossshark.Forward
default:
Fin.Deactivate()
steerableFin := appkeys.NewMouse(
appkeys.New(
Fin,
func(evk *tcell.EventKey, app gowid.IApp) bool {
if Fin.Active() {
switch evk.Key() {
case tcell.KeyLeft:
Fin.Dir = rossshark.Backward
case tcell.KeyRight:
Fin.Dir = rossshark.Forward
default:
Fin.Deactivate()
}
return true
}
return false
},
appkeys.Options{
ApplyBefore: true,
},
),
func(evm *tcell.EventMouse, app gowid.IApp) bool {
if Fin.Active() {
Fin.Deactivate()
return true
}
return false
Expand Down

0 comments on commit e24e6c0

Please sign in to comment.