Skip to content

Commit

Permalink
fix(ansi): mouse sgr coordinates are 1-based
Browse files Browse the repository at this point in the history
  • Loading branch information
aymanbagabas committed Nov 15, 2024
1 parent 854ee22 commit 4ea7107
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion ansi/mouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit 4ea7107

Please sign in to comment.