From 4ea7107c3caf4817ad1cd68b66eb5930869ed575 Mon Sep 17 00:00:00 2001 From: Ayman Bagabas Date: Thu, 14 Nov 2024 19:45:16 -0500 Subject: [PATCH] fix(ansi): mouse sgr coordinates are 1-based --- ansi/mouse.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ansi/mouse.go b/ansi/mouse.go index 709bfa15..bae52b71 100644 --- a/ansi/mouse.go +++ b/ansi/mouse.go @@ -26,5 +26,11 @@ func MouseSgr(b byte, x, y int, release bool) string { if release { s = "m" } - return fmt.Sprintf("\x1b[<%d;%d;%d%s", b, x, y, s) + if x < 0 { + x = -x + } + if y < 0 { + y = -y + } + return fmt.Sprintf("\x1b[<%d;%d;%d%s", b, x+1, y+1, s) }