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