on master help sign in
Merge pull request #130 from doublescale/mouse-wheel

Handle mouse wheel events

commit0f3de8f00c5d745b0186b81bf75727dc3e2fd4cc authorJonathan Daugherty <cygnus@foobox.com> dateThu 20 Jul 2017, 19:23 (9 years ago) parent7e3a2e933c61af
2 files changed+10−2
src/Graphics/Vty/Input/Events.hs+1−1 src/Graphics/Vty/Input/Mouse.hs+9−1
src/Graphics/Vty/Input/Events.hs+1−1
@@ -28,7 +28,7 @@ data Modifier = MShift | MCtrl | MMeta | MAlt
2828 deriving (Eq,Show,Read,Ord,Generic)
2929
3030-- | Mouse buttons.
31−data Button = BLeft | BMiddle | BRight
31+data Button = BLeft | BMiddle | BRight | BScrollUp | BScrollDown
3232 deriving (Eq,Show,Read,Ord,Generic)
3333
3434-- | Events.
src/Graphics/Vty/Input/Mouse.hs+9−1
@@ -67,7 +67,7 @@ ctrlBit = 16
6767
6868-- These bits indicate the buttons involved:
6969buttonMask :: Int
70−buttonMask = 3
70+buttonMask = 67
7171
7272leftButton :: Int
7373leftButton = 0
@@ -78,6 +78,12 @@ middleButton = 1
7878rightButton :: Int
7979rightButton = 2
8080
81+scrollUp :: Int
82+scrollUp = 64
83+
84+scrollDown :: Int
85+scrollDown = 65
86+
8187hasBitSet :: Int -> Int -> Bool
8288hasBitSet val bit = val .&. bit > 0
8389
@@ -100,6 +106,8 @@ getSGRButton mods =
100106 let buttonMap = [ (leftButton, BLeft)
101107 , (middleButton, BMiddle)
102108 , (rightButton, BRight)
109+ , (scrollUp, BScrollUp)
110+ , (scrollDown, BScrollDown)
103111 ]
104112 in case lookup (mods .&. buttonMask) buttonMap of
105113 Nothing -> failParse