mirror of
https://github.com/mum4k/termdash.git
synced 2025-04-25 13:48:50 +08:00
Fixing issues reported by go vet.
This commit is contained in:
parent
e2a4927612
commit
039a028ff9
@ -297,84 +297,84 @@ func TestFocusTrackerMouse(t *testing.T) {
|
||||
{
|
||||
desc: "click and release moves focus to the left",
|
||||
events: []*terminalapi.Mouse{
|
||||
&terminalapi.Mouse{image.Point{0, 0}, mouse.ButtonLeft},
|
||||
&terminalapi.Mouse{image.Point{1, 1}, mouse.ButtonRelease},
|
||||
&terminalapi.Mouse{Position: image.Point{0, 0}, Button: mouse.ButtonLeft},
|
||||
&terminalapi.Mouse{Position: image.Point{1, 1}, Button: mouse.ButtonRelease},
|
||||
},
|
||||
wantFocused: contLocLeft,
|
||||
},
|
||||
{
|
||||
desc: "click and release moves focus to the right",
|
||||
events: []*terminalapi.Mouse{
|
||||
&terminalapi.Mouse{image.Point{5, 5}, mouse.ButtonLeft},
|
||||
&terminalapi.Mouse{image.Point{6, 6}, mouse.ButtonRelease},
|
||||
&terminalapi.Mouse{Position: image.Point{5, 5}, Button: mouse.ButtonLeft},
|
||||
&terminalapi.Mouse{Position: image.Point{6, 6}, Button: mouse.ButtonRelease},
|
||||
},
|
||||
wantFocused: contLocRight,
|
||||
},
|
||||
{
|
||||
desc: "click in the same container is a no-op",
|
||||
events: []*terminalapi.Mouse{
|
||||
&terminalapi.Mouse{insideRight, mouse.ButtonLeft},
|
||||
&terminalapi.Mouse{insideRight, mouse.ButtonRelease},
|
||||
&terminalapi.Mouse{insideRight, mouse.ButtonLeft},
|
||||
&terminalapi.Mouse{insideRight, mouse.ButtonRelease},
|
||||
&terminalapi.Mouse{Position: insideRight, Button: mouse.ButtonLeft},
|
||||
&terminalapi.Mouse{Position: insideRight, Button: mouse.ButtonRelease},
|
||||
&terminalapi.Mouse{Position: insideRight, Button: mouse.ButtonLeft},
|
||||
&terminalapi.Mouse{Position: insideRight, Button: mouse.ButtonRelease},
|
||||
},
|
||||
wantFocused: contLocRight,
|
||||
},
|
||||
{
|
||||
desc: "click in the same container and release never happens",
|
||||
events: []*terminalapi.Mouse{
|
||||
&terminalapi.Mouse{insideRight, mouse.ButtonLeft},
|
||||
&terminalapi.Mouse{insideLeft, mouse.ButtonLeft},
|
||||
&terminalapi.Mouse{insideLeft, mouse.ButtonRelease},
|
||||
&terminalapi.Mouse{Position: insideRight, Button: mouse.ButtonLeft},
|
||||
&terminalapi.Mouse{Position: insideLeft, Button: mouse.ButtonLeft},
|
||||
&terminalapi.Mouse{Position: insideLeft, Button: mouse.ButtonRelease},
|
||||
},
|
||||
wantFocused: contLocLeft,
|
||||
},
|
||||
{
|
||||
desc: "click in the same container, release elsewhere",
|
||||
events: []*terminalapi.Mouse{
|
||||
&terminalapi.Mouse{insideRight, mouse.ButtonLeft},
|
||||
&terminalapi.Mouse{insideLeft, mouse.ButtonRelease},
|
||||
&terminalapi.Mouse{Position: insideRight, Button: mouse.ButtonLeft},
|
||||
&terminalapi.Mouse{Position: insideLeft, Button: mouse.ButtonRelease},
|
||||
},
|
||||
wantFocused: contLocRoot,
|
||||
},
|
||||
{
|
||||
desc: "other buttons are ignored",
|
||||
events: []*terminalapi.Mouse{
|
||||
&terminalapi.Mouse{insideLeft, mouse.ButtonMiddle},
|
||||
&terminalapi.Mouse{insideLeft, mouse.ButtonRelease},
|
||||
&terminalapi.Mouse{insideLeft, mouse.ButtonRight},
|
||||
&terminalapi.Mouse{insideLeft, mouse.ButtonRelease},
|
||||
&terminalapi.Mouse{insideLeft, mouse.ButtonWheelUp},
|
||||
&terminalapi.Mouse{insideLeft, mouse.ButtonWheelDown},
|
||||
&terminalapi.Mouse{Position: insideLeft, Button: mouse.ButtonMiddle},
|
||||
&terminalapi.Mouse{Position: insideLeft, Button: mouse.ButtonRelease},
|
||||
&terminalapi.Mouse{Position: insideLeft, Button: mouse.ButtonRight},
|
||||
&terminalapi.Mouse{Position: insideLeft, Button: mouse.ButtonRelease},
|
||||
&terminalapi.Mouse{Position: insideLeft, Button: mouse.ButtonWheelUp},
|
||||
&terminalapi.Mouse{Position: insideLeft, Button: mouse.ButtonWheelDown},
|
||||
},
|
||||
wantFocused: contLocRoot,
|
||||
},
|
||||
{
|
||||
desc: "moving mouse with pressed button and then releasing moves focus",
|
||||
events: []*terminalapi.Mouse{
|
||||
&terminalapi.Mouse{image.Point{0, 0}, mouse.ButtonLeft},
|
||||
&terminalapi.Mouse{image.Point{1, 1}, mouse.ButtonLeft},
|
||||
&terminalapi.Mouse{image.Point{2, 2}, mouse.ButtonRelease},
|
||||
&terminalapi.Mouse{Position: image.Point{0, 0}, Button: mouse.ButtonLeft},
|
||||
&terminalapi.Mouse{Position: image.Point{1, 1}, Button: mouse.ButtonLeft},
|
||||
&terminalapi.Mouse{Position: image.Point{2, 2}, Button: mouse.ButtonRelease},
|
||||
},
|
||||
wantFocused: contLocLeft,
|
||||
},
|
||||
{
|
||||
desc: "click ignored if followed by another click of the same button elsewhere",
|
||||
events: []*terminalapi.Mouse{
|
||||
&terminalapi.Mouse{insideRight, mouse.ButtonLeft},
|
||||
&terminalapi.Mouse{insideLeft, mouse.ButtonLeft},
|
||||
&terminalapi.Mouse{insideRight, mouse.ButtonRelease},
|
||||
&terminalapi.Mouse{insideRight, mouse.ButtonRelease},
|
||||
&terminalapi.Mouse{Position: insideRight, Button: mouse.ButtonLeft},
|
||||
&terminalapi.Mouse{Position: insideLeft, Button: mouse.ButtonLeft},
|
||||
&terminalapi.Mouse{Position: insideRight, Button: mouse.ButtonRelease},
|
||||
&terminalapi.Mouse{Position: insideRight, Button: mouse.ButtonRelease},
|
||||
},
|
||||
wantFocused: contLocRoot,
|
||||
},
|
||||
{
|
||||
desc: "click ignored if followed by another click of a different button",
|
||||
events: []*terminalapi.Mouse{
|
||||
&terminalapi.Mouse{insideRight, mouse.ButtonLeft},
|
||||
&terminalapi.Mouse{insideRight, mouse.ButtonMiddle},
|
||||
&terminalapi.Mouse{insideRight, mouse.ButtonRelease},
|
||||
&terminalapi.Mouse{insideRight, mouse.ButtonRelease},
|
||||
&terminalapi.Mouse{Position: insideRight, Button: mouse.ButtonLeft},
|
||||
&terminalapi.Mouse{Position: insideRight, Button: mouse.ButtonMiddle},
|
||||
&terminalapi.Mouse{Position: insideRight, Button: mouse.ButtonRelease},
|
||||
&terminalapi.Mouse{Position: insideRight, Button: mouse.ButtonRelease},
|
||||
},
|
||||
wantFocused: contLocRoot,
|
||||
},
|
||||
|
@ -35,7 +35,7 @@ import (
|
||||
)
|
||||
|
||||
// Example shows how to setup and run termdash.
|
||||
func Example() error {
|
||||
func Example() {
|
||||
// Create the terminal.
|
||||
t, err := termbox.New()
|
||||
if err != nil {
|
||||
@ -66,9 +66,8 @@ func Example() error {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
defer cancel()
|
||||
if err := Run(ctx, t, c); err != nil {
|
||||
return err
|
||||
panic(err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// errorHandler just stores the last error received.
|
||||
|
Loading…
x
Reference in New Issue
Block a user