Copyright | (c) David Janssen 2019 |
---|---|
License | MIT |
Maintainer | janssen.dhj@gmail.com |
Stability | experimental |
Portability | portable |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
A button contains 2 actions, one to perform on press, and another to perform on release. This module contains that definition, and some helper code that helps combine buttons. It is here that most of the complicated` buttons are implemented (like TapHold).
Synopsis
- data Button
- class HasButton c where
- button :: Lens' c Button
- pressAction :: Lens' c Action
- releaseAction :: Lens' c Action
- onPress :: AnyK () -> Button
- onRelease :: AnyK () -> Button
- mkButton :: AnyK () -> AnyK () -> Button
- around :: Button -> Button -> Button
- tapOn :: Switch -> Button -> Button
- emitB :: Keycode -> Button
- pressOnly :: Keycode -> Button
- releaseOnly :: Keycode -> Button
- modded :: Keycode -> Button -> Button
- layerToggle :: LayerTag -> Button
- layerSwitch :: LayerTag -> Button
- layerAdd :: LayerTag -> Button
- layerRem :: LayerTag -> Button
- pass :: Button
- cmdButton :: Text -> Maybe Text -> Button
- aroundNext :: Button -> Button
- aroundNextTimeout :: Milliseconds -> Button -> Button -> Button
- aroundNextSingle :: Button -> Button
- beforeAfterNext :: Button -> Button -> Button
- layerDelay :: Milliseconds -> LayerTag -> Button
- layerNext :: LayerTag -> Button
- tapHold :: Milliseconds -> Button -> Button -> Button
- multiTap :: Button -> [(Milliseconds, Button)] -> Button
- tapNext :: Button -> Button -> Button
- tapHoldNext :: Milliseconds -> Button -> Button -> Maybe Button -> Button
- tapNextRelease :: Button -> Button -> Button
- tapHoldNextRelease :: Milliseconds -> Button -> Button -> Maybe Button -> Button
- tapNextPress :: Button -> Button -> Button
- tapMacro :: [Button] -> Button
- tapMacroRelease :: [Button] -> Button
- stickyKey :: Milliseconds -> Button -> Button
Button basics
This section contains the basic definition of KMonad's Button
datatype. A
Button
is essentially a collection of 2 different actions, 1 to perform on
Press
and another on Release
.
class HasButton c where Source #
button :: Lens' c Button Source #
pressAction :: Lens' c Action Source #
releaseAction :: Lens' c Action Source #
Create a new button from 2 buttons, an inner and an outer. When the new button is pressed, first the outer is pressed, then the inner. On release, the inner is released first, and then the outer.
Create a new button that performs both a press and release of the input button on just a press or release
Simple buttons
A collection of simple buttons. These are basically almost direct wrappings
around MonadK
functionality.
emitB :: Keycode -> Button Source #
A button that emits a Press of a keycode when pressed, and a release when released.
releaseOnly :: Keycode -> Button Source #
A button that emits only a Release of a keycode.
layerToggle :: LayerTag -> Button Source #
Create a button that toggles a layer on and off
layerSwitch :: LayerTag -> Button Source #
Create a button that switches the base-layer on a press
layerRem :: LayerTag -> Button Source #
Create a button that removes the top instance of a layer on a press
cmdButton :: Text -> Maybe Text -> Button Source #
Create a button that executes a shell command on press and possibly on release
Button combinators
:: Milliseconds | How long before we tap |
-> Button | The |
-> Button | The |
-> Button | The resulting button |
A Button
that, once pressed, will surround the next button within some timeout with another.
If some other key is not pressed within an interval another button will be triggered as a tap.
A Button
that, once pressed, will surround the next button with another.
Think of this as, essentially, a tappable mod. For example, an 'aroundNext KeyCtrl' would, once tapped, then make the next keypress C-whatever.
This differs from aroundNext
in that it explicitly releases the modifier
immediately after the first event, where aroundSingle
waits around for the
original key that was modified to be released itself.
beforeAfterNext :: Button -> Button -> Button Source #
Surround some future button with a before and after tap
layerDelay :: Milliseconds -> LayerTag -> Button Source #
Switch to a layer for a period of time, then automatically switch back
layerNext :: LayerTag -> Button Source #
Switch to a layer for the next button-press and switch back automaically.
NOTE: liable to change, this is essentially just aroundNext
and
layerToggle
combined.
tapHold :: Milliseconds -> Button -> Button -> Button Source #
Create a Button
that performs a tap of one button if it is released
within an interval. If the interval is exceeded, press the other button (and
release it when a release is detected).
tapNext :: Button -> Button -> Button Source #
Create a Button
that performs a tap of 1 button if the next event is its
own release, or else switches to holding some other button if the next event
is a different keypress.
tapHoldNext :: Milliseconds -> Button -> Button -> Maybe Button -> Button Source #
Like tapNext
, except that after some interval it switches anyways
tapNextRelease :: Button -> Button -> Button Source #
Create a tap-hold style button that makes its decision based on the next detected release in the following manner: 1. It is the release of this button: We are tapping 2. It is of some other button that was pressed *before* this one, ignore. 3. It is of some other button that was pressed *after* this one, we hold.
It does all of this while holding processing of other buttons, so time will get rolled back like a TapHold button.
tapHoldNextRelease :: Milliseconds -> Button -> Button -> Maybe Button -> Button Source #
Create a tap-hold style button that makes its decision based on the next detected release in the following manner: 1. It is the release of this button: We are tapping 2. It is of some other button that was pressed *before* this one, ignore. 3. It is of some other button that was pressed *after* this one, we hold.
If we encounter the timeout before any other release, we switch to the specified timeout button, or to the hold button if none is specified.
It does all of this while holding processing of other buttons, so time will get rolled back like a TapHold button.
tapNextPress :: Button -> Button -> Button Source #
Create a button just like tap-release, but also trigger a hold on presses: 1. It is the release of this button: We are tapping 2. It is the press of some other button, we hold 3. It is the release of some other button, ignore.
tapMacro :: [Button] -> Button Source #
Create a Button
that performs a series of taps on press. Note that the
last button is only released when the tapMacro itself is released.