From 37a5a4be992d8893ca2a81fbc1ca250b4895e5df Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 16 Nov 2026 02:15:46 +0000 Subject: decodeMouseEvent: admit buttons 8 to 11 Terminals report buttons 8 to 11 (often back and forward) with bit 128 of the button byte set. decodeMouseEvent ignored that bit and reported them as buttons 1 to 3 and as an X10 release. The case analysis is now total, so the error for unknown buttons is gone; it could not be reached anyway. --- src/Scanner.hs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/Scanner.hs b/src/Scanner.hs index 993793c..24546be 100644 --- a/src/Scanner.hs +++ b/src/Scanner.hs @@ -164,16 +164,12 @@ hWaitLookAhead t h = do decodeMouseEvent :: Int -> Int -> Int -> Bool -> Scan decodeMouseEvent b x y pressed = let - button = case (b .&. 3) + (b .&. 64) of - 0 -> 1 - 1 -> 2 - 2 -> 3 - 64 -> 4 -- wheel up - 65 -> 5 -- wheel down - 66 -> 6 -- wheel left - 67 -> 7 -- wheel right - 3 -> 0 -- X10 release - btn -> error $ "TODO proper parseNormalButton error: " ++ show btn + button = case (b .&. 192, b .&. 3) of + (0, 3) -> 0 -- X10 release + (0, n) -> n + 1 -- buttons 1 to 3 + (64, n) -> n + 4 -- wheel up, down, left, right + (128, n) -> n + 8 -- buttons 8 to 11 + (_, n) -> n + 12 -- unassigned in ScanMouse { mouseButton = button -- cgit v1.3.1