wild-bind-task-x11 0.1.0.1 → 0.2.0.0
raw patch · 4 files changed
+77/−12 lines, 4 filesdep ~wild-bind-indicatordep ~wild-bind-x11PVP ok
version bump matches the API change (PVP)
Dependency ranges changed: wild-bind-indicator, wild-bind-x11
API changes (from Hackage documentation)
+ WildBind.Task.X11.Seq.Example: main :: IO ()
+ WildBind.Task.X11.Seq.Example: myBinding_complex :: Binding ActiveWindow XKeyEvent
+ WildBind.Task.X11.Seq.Example: myBinding_simple :: Binding ActiveWindow XKeyEvent
- WildBind.Task.X11: getPresence :: Indicator s i -> IO Bool
+ WildBind.Task.X11: getPresence :: () => Indicator s i -> IO Bool
- WildBind.Task.X11: quit :: Indicator s i -> IO ()
+ WildBind.Task.X11: quit :: () => Indicator s i -> IO ()
- WildBind.Task.X11: setPresence :: Indicator s i -> Bool -> IO ()
+ WildBind.Task.X11: setPresence :: () => Indicator s i -> Bool -> IO ()
- WildBind.Task.X11: togglePresence :: Indicator s i -> IO ()
+ WildBind.Task.X11: togglePresence :: () => Indicator s i -> IO ()
- WildBind.Task.X11: updateDescription :: Indicator s i -> i -> ActionDescription -> IO ()
+ WildBind.Task.X11: updateDescription :: () => Indicator s i -> i -> ActionDescription -> IO ()
- WildBind.Task.X11: wildNumPad :: (NumPadPosition i, KeySymLike i, ModifierLike i, Describable i, Ord i, Enum i, Bounded i) => Binding ActiveWindow i -> IO ()
+ WildBind.Task.X11: wildNumPad :: (NumPadPosition i, XKeyInput i, Describable i, Ord i, Enum i, Bounded i) => Binding ActiveWindow i -> IO ()
- WildBind.Task.X11: wildNumPad' :: (NumPadPosition i, KeySymLike i, ModifierLike i, Describable i, Ord i, Enum i, Bounded i) => (Indicator ActiveWindow i -> Binding ActiveWindow i) -> IO ()
+ WildBind.Task.X11: wildNumPad' :: (NumPadPosition i, XKeyInput i, Describable i, Ord i, Enum i, Bounded i) => (Indicator ActiveWindow i -> Binding ActiveWindow i) -> IO ()
Files
- ChangeLog.md +7/−0
- src/WildBind/Task/X11.hs +5/−7
- src/WildBind/Task/X11/Seq/Example.hs +60/−0
- wild-bind-task-x11.cabal +5/−5
ChangeLog.md view
@@ -1,5 +1,12 @@ # Revision history for wild-bind-task-x11 +## 0.2.0.0 -- 2018-01-01++* Modify constraints of `wildNumPad` and `wildNumPad'` functions+ because of the change in wild-bind-x11-0.2.0.0 package.+* Add `WildBind.Task.X11.Seq.Example` module.++ ## 0.1.0.1 -- 2016-09-22 * First version. Released on an unsuspecting world.
src/WildBind/Task/X11.hs view
@@ -39,9 +39,9 @@ import WildBind.Indicator ( Indicator, NumPadPosition(..), updateDescription, getPresence, setPresence, togglePresence, quit,- withNumPadIndicator, wildBindWithIndicator+ withNumPadIndicator, wildBindWithIndicator, toggleBinding )-import WildBind.X11.Internal.Key (KeySymLike, ModifierLike)+import WildBind.X11.Internal.Key (XKeyInput) -- | A convenient function to create an executable action with X11 -- 'FrontEnd' and 'Indicator' for a number pad.@@ -58,14 +58,12 @@ -- -- For the input type @i@, you can use 'NumPadUnlocked' or -- 'NumPadLocked'.-wildNumPad :: (NumPadPosition i, KeySymLike i, ModifierLike i, Describable i, Ord i, Enum i, Bounded i)+wildNumPad :: (NumPadPosition i, XKeyInput i, Describable i, Ord i, Enum i, Bounded i) => Binding ActiveWindow i -> IO ()-wildNumPad orig_binding = wildNumPad' $ \ind -> orig_binding <> help_binds ind where- help_binds ind = binding $ map (\input -> (input, Action "Toggle description" $ togglePresence ind)) help_likes- help_likes = filter ((== NumLDivide) . toNumPad) $ enumFromTo minBound maxBound+wildNumPad orig_binding = wildNumPad' $ \ind -> orig_binding <> toggleBinding ind NumLDivide -- | A more flexible version of 'wildNumPad'. It passes you an -- 'Indicator', and uses the 'Binding' you return as-is.-wildNumPad' :: (NumPadPosition i, KeySymLike i, ModifierLike i, Describable i, Ord i, Enum i, Bounded i)+wildNumPad' :: (NumPadPosition i, XKeyInput i, Describable i, Ord i, Enum i, Bounded i) => (Indicator ActiveWindow i -> Binding ActiveWindow i) -> IO () wildNumPad' create_binding = withNumPadIndicator $ \ind -> withFrontEnd $ wildBindWithIndicator ind (create_binding ind)
+ src/WildBind/Task/X11/Seq/Example.hs view
@@ -0,0 +1,60 @@+-- |+-- Module: WildBind.Task.X11.Seq.Example+-- Description: An example of WildBind.Seq+-- Maintainer: Toshio Ito <debug.ito@gmail.com>+--+-- This is an example of using "WildBind.Seq" module to build bindings+-- for key sequences. See the source.+--+-- @since 0.2.0.0+module WildBind.Task.X11.Seq.Example+ where++import Data.Monoid ((<>))++-- Following is from wild-bind package+import WildBind (Binding, wildBind, binds, on, run)+import WildBind.Seq+ ( SeqBinding,+ prefix, fromSeq, toSeq, withCancel, withPrefix+ )++-- Following is from wild-bind-x11 package+import WildBind.X11+ ( XKeyEvent, ActiveWindow,+ withFrontEnd, ctrl, press+ )+import qualified WildBind.X11.KeySym as Sym++main :: IO ()+main = withFrontEnd $ wildBind myBinding_simple++-- | 'prefix' is a simple API to build a binding for key sequence.+myBinding_simple :: Binding ActiveWindow XKeyEvent+myBinding_simple = prefix [ctrl Sym.xK_g] [ctrl Sym.xK_x] $ binds $ do+ on (ctrl Sym.xK_f) `run` putStrLn "C-x C-f"+ on (ctrl Sym.xK_o) `run` putStrLn "C-x C-o"+ on (ctrl Sym.xK_c) `run` putStrLn "C-x C-c"++-- | You can combine 'SeqBinding' objects together to build a complex+-- binding for key sequence.+myBinding_complex :: Binding ActiveWindow XKeyEvent+myBinding_complex = fromSeq $ withCancel [ctrl Sym.xK_g] seq_binding+ where+ seq_binding :: SeqBinding ActiveWindow XKeyEvent+ seq_binding = (withPrefix [ctrl Sym.xK_c] c_binding)+ <> (withPrefix [ctrl Sym.xK_x] x_binding)+ c_binding :: SeqBinding ActiveWindow XKeyEvent+ c_binding = toSeq $ binds $ do+ on (ctrl Sym.xK_n) `run` putStrLn "C-c C-n"+ on (ctrl Sym.xK_p) `run` putStrLn "C-c C-p"+ x_binding :: SeqBinding ActiveWindow XKeyEvent+ x_binding = (withPrefix [ctrl Sym.xK_Return] xret_binding)+ <> plain_x_binding+ plain_x_binding :: SeqBinding ActiveWindow XKeyEvent+ plain_x_binding = toSeq $ binds $ do+ on (ctrl Sym.xK_f) `run` putStrLn "C-x C-f"+ xret_binding :: SeqBinding ActiveWindow XKeyEvent+ xret_binding = toSeq $ binds $ do+ on (press Sym.xK_f) `run` putStrLn "C-x RET f"+ on (press Sym.xK_c) `run` putStrLn "C-x RET c"
wild-bind-task-x11.cabal view
@@ -1,5 +1,5 @@ name: wild-bind-task-x11-version: 0.1.0.1+version: 0.2.0.0 author: Toshio Ito <debug.ito@gmail.com> maintainer: Toshio Ito <debug.ito@gmail.com> license: BSD3@@ -17,13 +17,13 @@ default-language: Haskell2010 hs-source-dirs: src ghc-options: -Wall -fno-warn-unused-imports- default-extensions: OverloadedStrings- exposed-modules: WildBind.Task.X11+ exposed-modules: WildBind.Task.X11,+ WildBind.Task.X11.Seq.Example -- other-modules: build-depends: base >=4.6 && <5.0, wild-bind >=0.1.0 && <0.2,- wild-bind-x11 >=0.1.0 && <0.2,- wild-bind-indicator >=0.1.0 && <0.2,+ wild-bind-x11 >=0.1.0 && <0.3,+ wild-bind-indicator >=0.1.0 && <0.3, text >=1.2.0 && <1.3, transformers >=0.3.0 && <0.6