Skip to content

Commit

Permalink
Make aroundNext only affect the next button
Browse files Browse the repository at this point in the history
Before this change, aroundNext was able to change more buttons than just
the very next one, provided the next button was released after some
other buttons were pressed.  For example, suppose we had

    (defalias
      nsh (around-next sft))

Then the old behaviour would give

    T@nsh Ta Tb       ==> Ab
    T@nsh Pa Pb Ra Rb ==> AB

while the intended behaviour (and the one that this commit introduces)
would be

    T@nsh Ta Tb       ==> Ab
    T@nsh Pa Pb Ra Rb ==> Ab
  • Loading branch information
slotThe committed Jan 2, 2021
1 parent e27efe2 commit 5e4a3d0
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/KMonad/Button.hs
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,10 @@ around outer inner = Button
aroundNext ::
Button -- ^ The outer 'Button'
-> Button -- ^ The resulting 'Button'
aroundNext b = onPress $ await isPress $ \e -> do
aroundNext b = onPress $ await isPress $ \_ -> do
runAction $ b^.pressAction
await (isReleaseOf $ e^.keycode) $ \_ -> do
-- Wait for the next *event*, regardless of what it is
await (pure True) $ \_ -> do
runAction $ b^.releaseAction
pure NoCatch
pure NoCatch
Expand Down Expand Up @@ -351,5 +352,3 @@ layerNext :: LayerTag -> Button
layerNext t = onPress $ do
layerOp (PushLayer t)
await isPress (\_ -> whenDone (layerOp $ PopLayer t) *> pure NoCatch)


0 comments on commit 5e4a3d0

Please sign in to comment.