Skip to content

Commit

Permalink
fix(term): input: invalid x10 mouse position calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
aymanbagabas committed Mar 15, 2024
1 parent 89409c7 commit 7166446
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
4 changes: 0 additions & 4 deletions exp/term/input/driver_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package input
import (
"errors"
"fmt"
"log"

"github.com/charmbracelet/x/exp/term/ansi"
"github.com/erikgeiser/coninput"
Expand Down Expand Up @@ -130,7 +129,6 @@ loop:
}

return events

}

func parseConInputEvent(event coninput.InputRecord, ps *coninput.ButtonState) Event {
Expand Down Expand Up @@ -160,8 +158,6 @@ func mouseEventButton(p, s coninput.ButtonState) (button MouseButton, isRelease
isRelease = true
}

log.Printf("p: %s, s: %s\r\n", p, s)

if btn == 0 {
switch {
case s&coninput.FROM_LEFT_1ST_BUTTON_PRESSED > 0:
Expand Down
8 changes: 3 additions & 5 deletions exp/term/input/parse.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package input

import (
"log"
"unicode/utf8"

"github.com/charmbracelet/x/exp/term/ansi"
Expand Down Expand Up @@ -111,6 +110,7 @@ func parseCsi(p []byte) (int, Event) {
// Add the final byte
final = p[i]
seq = append(seq, p[i])
i++

switch initial {
case '?':
Expand Down Expand Up @@ -190,10 +190,10 @@ func parseCsi(p []byte) (int, Event) {
return len(seq), KeyDownEvent{Sym: KeyTab, Mod: Shift}
case 'M':
// Handle X10 mouse
if i+3 >= len(p) {
if i+3 > len(p) {
return len(seq), UnknownCsiEvent(seq)
}
return len(seq) + 3, parseX10MouseEvent(append(seq, p[i+1:i+3]...))
return len(seq) + 3, parseX10MouseEvent(append(seq, p[i:i+3]...))
case 'u':
// Kitty keyboard protocol
params := ansi.Params(p[start:end])
Expand Down Expand Up @@ -583,8 +583,6 @@ func parseDcs(p []byte) (int, Event) {
seq = append(seq, p[i])
}

log.Printf("seq: %q\r\n", seq)

switch final {
case 'r':
inters := p[istart:iend] // intermediates
Expand Down

0 comments on commit 7166446

Please sign in to comment.