mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-05-19 03:20:21 -07:00
X.A.Prefix: Add orIfPrefixed
- Generalise signature of withPrefixArgument, in order to accommodate this.
This commit is contained in:
parent
4bdcab8bf6
commit
e02400b1c7
@ -232,6 +232,11 @@
|
|||||||
- The `emacsLikeXPKeymap` and `vimLikeXPKeymap` keymaps now treat
|
- The `emacsLikeXPKeymap` and `vimLikeXPKeymap` keymaps now treat
|
||||||
`C-m` the same as `Return`.
|
`C-m` the same as `Return`.
|
||||||
|
|
||||||
|
* `XMonad.Actions.Prefix`
|
||||||
|
|
||||||
|
- Added `orIfPrefixed`, a combinator to decide upon an action based
|
||||||
|
on whether any prefix argument was given.
|
||||||
|
|
||||||
### Other changes
|
### Other changes
|
||||||
|
|
||||||
## 0.17.1 (September 3, 2022)
|
## 0.17.1 (September 3, 2022)
|
||||||
|
@ -29,6 +29,7 @@ module XMonad.Actions.Prefix
|
|||||||
, withPrefixArgument
|
, withPrefixArgument
|
||||||
, isPrefixRaw
|
, isPrefixRaw
|
||||||
, isPrefixNumeric
|
, isPrefixNumeric
|
||||||
|
, orIfPrefixed
|
||||||
, ppFormatPrefix
|
, ppFormatPrefix
|
||||||
) where
|
) where
|
||||||
|
|
||||||
@ -173,7 +174,7 @@ handlePrefixArg events = do
|
|||||||
--
|
--
|
||||||
-- First, fetch the current prefix, then pass it as argument to the
|
-- First, fetch the current prefix, then pass it as argument to the
|
||||||
-- original function. You should use this to "run" your commands.
|
-- original function. You should use this to "run" your commands.
|
||||||
withPrefixArgument :: (PrefixArgument -> X ()) -> X ()
|
withPrefixArgument :: (PrefixArgument -> X a) -> X a
|
||||||
withPrefixArgument = (>>=) XS.get
|
withPrefixArgument = (>>=) XS.get
|
||||||
|
|
||||||
-- | Test if 'PrefixArgument' is 'Raw' or not.
|
-- | Test if 'PrefixArgument' is 'Raw' or not.
|
||||||
@ -186,6 +187,13 @@ isPrefixNumeric :: PrefixArgument -> Bool
|
|||||||
isPrefixNumeric (Numeric _) = True
|
isPrefixNumeric (Numeric _) = True
|
||||||
isPrefixNumeric _ = False
|
isPrefixNumeric _ = False
|
||||||
|
|
||||||
|
-- | Execute the first action, unless any prefix argument is given,
|
||||||
|
-- in which case the second action is chosen instead.
|
||||||
|
--
|
||||||
|
-- > action1 `orIfPrefixed` action2
|
||||||
|
orIfPrefixed :: X a -> X a -> X a
|
||||||
|
orIfPrefixed xa xb = withPrefixArgument $ bool xa xb . isPrefixRaw
|
||||||
|
|
||||||
-- | Format the prefix using the Emacs convetion for use in a
|
-- | Format the prefix using the Emacs convetion for use in a
|
||||||
-- statusbar, like xmobar.
|
-- statusbar, like xmobar.
|
||||||
--
|
--
|
||||||
|
Loading…
x
Reference in New Issue
Block a user