Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
- type MonadWorkflow = MonadFree WorkflowF
- type Workflow = Free WorkflowF
- type Workflow_ = Workflow ()
- type CWorkflow = F WorkflowF
- type CWorkflow_ = CWorkflow ()
- data WorkflowF k
- = SendKeyChord [Modifier] Key k
- | SendText String k
- | GetClipboard (ClipboardText -> k)
- | SetClipboard ClipboardText k
- | CurrentApplication (Application -> k)
- | OpenApplication Application k
- | OpenURL URL k
- | Delay Time k
- type ClipboardText = String
- type Application = String
- type URL = String
- type Time = Int
- type CGKeyCode = CUShort
- type CGEventFlags = CULLong
- type KeyRiff = [KeyChord]
- type KeyChord = ([Modifier], Key)
- pattern KeyChord :: t -> t -> (t, t)
- pattern NoMod :: t -> ([t], t)
- addMod :: Modifier -> KeyChord -> KeyChord
- data Modifier
- data Key
- = CommandKey
- | ControlKey
- | CapsLockKey
- | ShiftKey
- | OptionKey
- | FunctionKey
- | GraveKey
- | MinusKey
- | EqualKey
- | DeleteKey
- | ForwardDeleteKey
- | LeftBracketKey
- | RightBracketKey
- | BackslashKey
- | SemicolonKey
- | QuoteKey
- | CommaKey
- | PeriodKey
- | SlashKey
- | TabKey
- | SpaceKey
- | ReturnKey
- | LeftArrowKey
- | RightArrowKey
- | DownArrowKey
- | UpArrowKey
- | AKey
- | BKey
- | CKey
- | DKey
- | EKey
- | FKey
- | GKey
- | HKey
- | IKey
- | JKey
- | KKey
- | LKey
- | MKey
- | NKey
- | OKey
- | PKey
- | QKey
- | RKey
- | SKey
- | TKey
- | UKey
- | VKey
- | WKey
- | XKey
- | YKey
- | ZKey
- | ZeroKey
- | OneKey
- | TwoKey
- | ThreeKey
- | FourKey
- | FiveKey
- | SixKey
- | SevenKey
- | EightKey
- | NineKey
- | EscapeKey
- | F1Key
- | F2Key
- | F3Key
- | F4Key
- | F5Key
- | F6Key
- | F7Key
- | F8Key
- | F9Key
- | F10Key
- | F11Key
- | F12Key
- | F13Key
- | F14Key
- | F15Key
- | F16Key
- | F17Key
- | F18Key
- | F19Key
- | F20Key
- int2keypress :: Integer -> [KeyChord]
- digit2keypress :: MonadThrow m => Integer -> m KeyChord
- char2keypress :: MonadThrow m => Char -> m KeyChord
- keypress2char :: MonadThrow m => KeyChord -> m Char
Documentation
type MonadWorkflow = MonadFree WorkflowF
a monad constraint for "workflow effects", (just like MonadState
is a monad constraint for "state effects") can use in any monad transformer stack that handles them.
type Workflow = Free WorkflowF
a platform-agnostic free monad, which can be executed by platform-specific bindings.
type CWorkflow_ = CWorkflow ()
data WorkflowF k
the "Workflow Functor".
SendKeyChord [Modifier] Key k | |
SendText String k | a logical grouping for debugging and optimizing |
GetClipboard (ClipboardText -> k) | |
SetClipboard ClipboardText k | |
CurrentApplication (Application -> k) | |
OpenApplication Application k | |
OpenURL URL k | |
Delay Time k |
type ClipboardText = String
type Application = String
relates a Haskell type with a Objective-C type:
- Objective-C defines
typedef unsigned short uint16_t;
- line 34 of /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/CoreGraphics.framework/Versions/A/Headers/CGRemoteOperation.h defines
typedef uint16_t CGKeyCode;
type CGEventFlags = CULLong
relates a Haskell type with a Objective-C type:
- Objective-C defines
typedef unsigned long long uint64_t;
- line 98 of /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/CoreGraphics.framework/Versions/A/Headers/CGEventTypes.h defines
typedef uint64_t CGEventFlags;
an (unordered, no-duplicates) sequence of key chords make up a keyboard shortcut
pattern KeyChord :: t -> t -> (t, t)
pattern KeyChord ms k = (ms,k)
pattern NoMod :: t -> ([t], t)
pattern NoMod k = ([],k)
data Modifier
modifier keys are keys that can be "held".
the escape key is "pressed", not "held", it seems. (possibly explains its behavior in your terminal emulator?)
alt
is OptionModifier
.
data Key
all the keys on a standard Apple keyboard.
int2keypress :: Integer -> [KeyChord]
>>>
int2keypress -12
[([],MinusKey),([],OneKey),([],TwoKey)]
digit2keypress :: MonadThrow m => Integer -> m KeyChord
a (base ten) digit is a number between zero and nine inclusive.
>>>
digit2keypress 2
([],TwoKey)
>>>
digit2keypress -2
Nothing
>>>
digit2keypress 12
Nothing
char2keypress :: MonadThrow m => Char -> m KeyChord
the keypress that would insert the character into the application.
>>>
char2keypress '@' :: Maybe KeyChord
Just ([ShiftModifier], TwoKey)
some characters cannot be represented as keypresses, like some non-printable characters (in arbitrary applications, not just the terminal emulator):
>>>
char2keypress '\0' :: Maybe KeyChord
Nothing
case char2keypress c of { Just ([],_) -> True; Just ([ShiftModifier],_) -> True; Nothing -> True; _ -> False }
keypress2char :: MonadThrow m => KeyChord -> m Char
the character that represents the keypress:
>>>
keypress2char ([ShiftModifier], TwoKey) :: Maybe Char
Just '@'
some keypresses cannot be represented as characters, like keyboard shortcuts:
>>>
keypress2char ([Command], CKey) :: Maybe Char
Nothing
>>>
import Data.Char
>>>
import Data.Maybe
prop> maybe True isAscii (keypress2char k) TODO replace true with redo test