From 993039eba99c39daf084bdad1b7132efdf00649e Mon Sep 17 00:00:00 2001 From: Latchezar Tzvetkoff Date: Mon, 5 Jun 2017 19:02:57 +0300 Subject: [PATCH] Fix borken mouse on OSX (and not only) Attempt to fix broken mouse events. --- termbox.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/termbox.go b/termbox.go index c2d86c6..8942216 100644 --- a/termbox.go +++ b/termbox.go @@ -448,7 +448,16 @@ func extract_event(inbuf []byte, event *Event) bool { if inbuf[0] == '\033' { // possible escape sequence - if n, ok := parse_escape_sequence(event, inbuf); n != 0 { + n, ok := parse_escape_sequence(event, inbuf); + if !ok { + // check for broken mouse sequence (osx, xterm-only) + if len(inbuf) > 2 && inbuf[1] == '[' && inbuf[2] == '<' { + return false + } + } + + // either a valid escape sequence or a key + if n != 0 { event.N = n return ok }