LambdaHack-0.11.0.1: A game engine library for tactical squad ASCII roguelike dungeon crawlers

Safe Haskell | None
Language | Haskell2010

Game.LambdaHack.Client.UI.Key

Contents

- Internal operations

Description

Frontend-independent keyboard input operations.

Synopsis

- data Key
  - = Esc
  - | Return
  - | Space
  - | Tab
  - | BackTab
  - | BackSpace
  - | PgUp
  - | PgDn
  - | Left
  - | Right
  - | Up
  - | Down
  - | End
  - | Begin
  - | Insert
  - | Delete
  - | PrintScreen
  - | Home
  - | KP Char
  - | Char Char
  - | Fun Int
  - | LeftButtonPress
  - | MiddleButtonPress
  - | RightButtonPress
  - | LeftButtonRelease
  - | MiddleButtonRelease
  - | RightButtonRelease
  - | WheelNorth
  - | WheelSouth
  - | Unknown String
  - | DeadKey
- data Modifier
  - = NoModifier
  - | ControlShift
  - | AltShift
  - | Shift
  - | Control
  - | Alt
- data KM = KM {
  - modifier :: Modifier
  - key :: Key
  }
- data KMP = KMP {
  - kmpKeyMod :: KM
  - kmpPointer :: PointUI
  }
- showKey :: Key -> String
- showKM :: KM -> String
- escKM :: KM
- controlEscKM :: KM
- spaceKM :: KM
- safeSpaceKM :: KM
- undefinedKM :: KM
- returnKM :: KM
- pgupKM :: KM
- pgdnKM :: KM
- wheelNorthKM :: KM
- wheelSouthKM :: KM
- upKM :: KM
- downKM :: KM
- leftKM :: KM
- rightKM :: KM
- homeKM :: KM
- endKM :: KM
- backspaceKM :: KM
- controlP :: KM
- leftButtonReleaseKM :: KM
- middleButtonReleaseKM :: KM
- rightButtonReleaseKM :: KM
- cardinalAllKM :: Bool -> Bool -> [KM]
- dirAllKey :: Bool -> Bool -> [Key]
- handleCardinal :: [KM] -> KM -> Maybe Vector
- handleDir :: [Key] -> KM -> Maybe Vector
- moveBinding :: Bool -> Bool -> (Vector -> a) -> (Vector -> a) -> [(KM, a)]
- mkKM :: String -> KM
- mkChar :: Char -> KM
- keyTranslate :: String -> Key
- keyTranslateWeb :: String -> Bool -> Key
- dirMoveNoModifier :: Bool -> Bool -> [Key]
- dirRunNoModifier :: Bool -> Bool -> [Key]
- dirRunControl :: [Key]
- dirRunShift :: [Key]
- dirKeypadKey :: [Key]
- dirKeypadShiftChar :: [Char]
- dirKeypadShiftKey :: [Key]
- dirLeftHandKey :: [Key]
- dirLeftHandShiftKey :: [Key]
- dirViChar :: [Char]
- dirViKey :: [Key]
- dirViShiftKey :: [Key]

# Documentation

data Key Source #

Frontend-independent datatype to represent keys.

Constructors

Esc |
Return |
Space |
Tab |
BackTab |
BackSpace |
PgUp |
PgDn |
Left |
Right |
Up |
Down |
End |
Begin |
Insert |
Delete |
PrintScreen |
Home |
KP Char | a keypad key for a character (digits and operators)
Char Char | a single printable character
Fun Int | function key
LeftButtonPress | left mouse button pressed
MiddleButtonPress | middle mouse button pressed
RightButtonPress | right mouse button pressed
LeftButtonRelease | left mouse button released
MiddleButtonRelease | middle mouse button released
RightButtonRelease | right mouse button released
WheelNorth | mouse wheel rotated north
WheelSouth | mouse wheel rotated south
Unknown String | an unknown key, registered to warn the user
DeadKey |

#### Instances

Instances details

Binary Key Source # |
Instance details Defined in Game.LambdaHack.Client.UI.Key Methods put :: Key -> Put Source # get :: Get Key Source # putList :: [Key] -> Put Source #
NFData Key Source # |
Instance details Defined in Game.LambdaHack.Client.UI.Key Methods rnf :: Key -> () Source #
Generic Key Source # |

Instance details

Defined in Game.LambdaHack.Client.UI.Key

Associated Types

type Rep Key |

Instance details

Defined in Game.LambdaHack.Client.UI.Key

type Rep Key = D1 ('MetaData "Key" "Game.LambdaHack.Client.UI.Key" "LambdaHack-0.11.0.1-BLuOaw8nuizISmzkanqI8h" 'False) ((((C1 ('MetaCons "Esc" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Return" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Space" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "Tab" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "BackTab" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "BackSpace" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "PgUp" 'PrefixI 'False) (U1 :: Type -> Type)))) :+: (((C1 ('MetaCons "PgDn" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Left" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "Right" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Up" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "Down" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "End" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "Begin" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Insert" 'PrefixI 'False) (U1 :: Type -> Type))))) :+: ((((C1 ('MetaCons "Delete" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "PrintScreen" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "Home" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "KP" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Char)))) :+: ((C1 ('MetaCons "Char" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Char)) :+: C1 ('MetaCons "Fun" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Int))) :+: (C1 ('MetaCons "LeftButtonPress" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "MiddleButtonPress" 'PrefixI 'False) (U1 :: Type -> Type)))) :+: (((C1 ('MetaCons "RightButtonPress" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "LeftButtonRelease" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "MiddleButtonRelease" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "RightButtonRelease" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "WheelNorth" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "WheelSouth" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "Unknown" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 String)) :+: C1 ('MetaCons "DeadKey" 'PrefixI 'False) (U1 :: Type -> Type))))))

Methods

from :: Key -> Rep Key x Source #

to :: Rep Key x -> Key Source #

Eq Key Source # |
Instance details Defined in Game.LambdaHack.Client.UI.Key Methods (==) :: Key -> Key -> Bool Source # (/=) :: Key -> Key -> Bool Source #
Ord Key Source # |
Instance details Defined in Game.LambdaHack.Client.UI.Key Methods compare :: Key -> Key -> Ordering Source # (<) :: Key -> Key -> Bool Source # (<=) :: Key -> Key -> Bool Source # (>) :: Key -> Key -> Bool Source # (>=) :: Key -> Key -> Bool Source # max :: Key -> Key -> Key Source # min :: Key -> Key -> Key Source #
type Rep Key Source # |

Instance details

Defined in Game.LambdaHack.Client.UI.Key

type Rep Key = D1 ('MetaData "Key" "Game.LambdaHack.Client.UI.Key" "LambdaHack-0.11.0.1-BLuOaw8nuizISmzkanqI8h" 'False) ((((C1 ('MetaCons "Esc" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Return" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Space" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "Tab" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "BackTab" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "BackSpace" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "PgUp" 'PrefixI 'False) (U1 :: Type -> Type)))) :+: (((C1 ('MetaCons "PgDn" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Left" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "Right" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Up" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "Down" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "End" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "Begin" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Insert" 'PrefixI 'False) (U1 :: Type -> Type))))) :+: ((((C1 ('MetaCons "Delete" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "PrintScreen" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "Home" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "KP" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Char)))) :+: ((C1 ('MetaCons "Char" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Char)) :+: C1 ('MetaCons "Fun" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Int))) :+: (C1 ('MetaCons "LeftButtonPress" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "MiddleButtonPress" 'PrefixI 'False) (U1 :: Type -> Type)))) :+: (((C1 ('MetaCons "RightButtonPress" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "LeftButtonRelease" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "MiddleButtonRelease" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "RightButtonRelease" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "WheelNorth" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "WheelSouth" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "Unknown" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 String)) :+: C1 ('MetaCons "DeadKey" 'PrefixI 'False) (U1 :: Type -> Type))))))

data Modifier Source #

Our own encoding of modifiers.

Constructors

NoModifier |
ControlShift |
AltShift |
Shift |
Control |
Alt |

#### Instances

Instances details

Binary Modifier Source # |
Instance details Defined in Game.LambdaHack.Client.UI.Key Methods put :: Modifier -> Put Source # get :: Get Modifier Source # putList :: [Modifier] -> Put Source #
NFData Modifier Source # |
Instance details Defined in Game.LambdaHack.Client.UI.Key Methods rnf :: Modifier -> () Source #
Generic Modifier Source # |

Instance details

Defined in Game.LambdaHack.Client.UI.Key

Associated Types

type Rep Modifier |

Instance details

Defined in Game.LambdaHack.Client.UI.Key

type Rep Modifier = D1 ('MetaData "Modifier" "Game.LambdaHack.Client.UI.Key" "LambdaHack-0.11.0.1-BLuOaw8nuizISmzkanqI8h" 'False) ((C1 ('MetaCons "NoModifier" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "ControlShift" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "AltShift" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "Shift" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Control" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Alt" 'PrefixI 'False) (U1 :: Type -> Type))))

Methods

from :: Modifier -> Rep Modifier x Source #

to :: Rep Modifier x -> Modifier Source #

Show Modifier Source # |
Instance details Defined in Game.LambdaHack.Client.UI.Key Methods showsPrec :: Int -> Modifier -> ShowS Source # show :: Modifier -> String Source # showList :: [Modifier] -> ShowS Source #
Eq Modifier Source # |
Instance details Defined in Game.LambdaHack.Client.UI.Key Methods (==) :: Modifier -> Modifier -> Bool Source # (/=) :: Modifier -> Modifier -> Bool Source #
Ord Modifier Source # |
Instance details Defined in Game.LambdaHack.Client.UI.Key Methods compare :: Modifier -> Modifier -> Ordering Source # (<) :: Modifier -> Modifier -> Bool Source # (<=) :: Modifier -> Modifier -> Bool Source # (>) :: Modifier -> Modifier -> Bool Source # (>=) :: Modifier -> Modifier -> Bool Source # max :: Modifier -> Modifier -> Modifier Source # min :: Modifier -> Modifier -> Modifier Source #
type Rep Modifier Source # |

Instance details

Defined in Game.LambdaHack.Client.UI.Key

type Rep Modifier = D1 ('MetaData "Modifier" "Game.LambdaHack.Client.UI.Key" "LambdaHack-0.11.0.1-BLuOaw8nuizISmzkanqI8h" 'False) ((C1 ('MetaCons "NoModifier" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "ControlShift" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "AltShift" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "Shift" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Control" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Alt" 'PrefixI 'False) (U1 :: Type -> Type))))

data KM Source #

Key and modifier.

Constructors

KM |

Fields

- modifier :: Modifier
- key :: Key

#### Instances

Instances details

Binary KM Source # |
Instance details Defined in Game.LambdaHack.Client.UI.Key Methods put :: KM -> Put Source # get :: Get KM Source # putList :: [KM] -> Put Source #
NFData KM Source # |
Instance details Defined in Game.LambdaHack.Client.UI.Key Methods rnf :: KM -> () Source #
Generic KM Source # |

Instance details

Defined in Game.LambdaHack.Client.UI.Key

Associated Types

type Rep KM |

Instance details

Defined in Game.LambdaHack.Client.UI.Key

type Rep KM = D1 ('MetaData "KM" "Game.LambdaHack.Client.UI.Key" "LambdaHack-0.11.0.1-BLuOaw8nuizISmzkanqI8h" 'False) (C1 ('MetaCons "KM" 'PrefixI 'True) (S1 ('MetaSel ('Just "modifier") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Modifier) :*: S1 ('MetaSel ('Just "key") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Key)))

Methods

from :: KM -> Rep KM x Source #

to :: Rep KM x -> KM Source #

Show KM Source # |
Instance details Defined in Game.LambdaHack.Client.UI.Key Methods showsPrec :: Int -> KM -> ShowS Source # show :: KM -> String Source # showList :: [KM] -> ShowS Source #
Eq KM Source # |
Instance details Defined in Game.LambdaHack.Client.UI.Key Methods (==) :: KM -> KM -> Bool Source # (/=) :: KM -> KM -> Bool Source #
Ord KM Source # |
Instance details Defined in Game.LambdaHack.Client.UI.Key Methods compare :: KM -> KM -> Ordering Source # (<) :: KM -> KM -> Bool Source # (<=) :: KM -> KM -> Bool Source # (>) :: KM -> KM -> Bool Source # (>=) :: KM -> KM -> Bool Source # max :: KM -> KM -> KM Source # min :: KM -> KM -> KM Source #
type Rep KM Source # |

Instance details

Defined in Game.LambdaHack.Client.UI.Key

type Rep KM = D1 ('MetaData "KM" "Game.LambdaHack.Client.UI.Key" "LambdaHack-0.11.0.1-BLuOaw8nuizISmzkanqI8h" 'False) (C1 ('MetaCons "KM" 'PrefixI 'True) (S1 ('MetaSel ('Just "modifier") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Modifier) :*: S1 ('MetaSel ('Just "key") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Key)))

data KMP Source #

Key, modifier and position of mouse pointer.

Constructors

KMP |

Fields

- kmpKeyMod :: KM
- kmpPointer :: PointUI

showKey :: Key -> String Source #

Common and terse names for keys.

showKM :: KM -> String Source #

Show a key with a modifier, if any.

escKM :: KM Source #

controlEscKM :: KM Source #

spaceKM :: KM Source #

safeSpaceKM :: KM Source #

undefinedKM :: KM Source #

returnKM :: KM Source #

pgupKM :: KM Source #

pgdnKM :: KM Source #

wheelNorthKM :: KM Source #

wheelSouthKM :: KM Source #

upKM :: KM Source #

downKM :: KM Source #

leftKM :: KM Source #

rightKM :: KM Source #

homeKM :: KM Source #

endKM :: KM Source #

backspaceKM :: KM Source #

controlP :: KM Source #

leftButtonReleaseKM :: KM Source #

middleButtonReleaseKM :: KM Source #

rightButtonReleaseKM :: KM Source #

cardinalAllKM :: Bool -> Bool -> [KM] Source #

dirAllKey :: Bool -> Bool -> [Key] Source #

handleCardinal :: [KM] -> KM -> Maybe Vector Source #

handleDir :: [Key] -> KM -> Maybe Vector Source #

Configurable event handler for the direction keys. Used for directed commands such as close door.

moveBinding :: Bool -> Bool -> (Vector -> a) -> (Vector -> a) -> [(KM, a)] Source #

Binding of both sets of movement keys, vi and laptop.

mkKM :: String -> KM Source #

mkChar :: Char -> KM Source #

keyTranslate :: String -> Key Source #

Translate key from a GTK string description to our internal key type. To be used, in particular, for the command bindings and macros in the config file.

See https://github.com/twobob/gtk-/blob/master/gdk/keynames.txt

keyTranslateWeb :: String -> Bool -> Key Source #

Translate key from a Web API string description (https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key#Key_values) to our internal key type. To be used in web frontends. The argument says whether Shift is pressed.

dirMoveNoModifier :: Bool -> Bool -> [Key] Source #

dirRunNoModifier :: Bool -> Bool -> [Key] Source #

dirRunControl :: [Key] Source #

dirRunShift :: [Key] Source #

# Internal operations

dirKeypadKey :: [Key] Source #

dirKeypadShiftChar :: [Char] Source #

dirKeypadShiftKey :: [Key] Source #

dirLeftHandKey :: [Key] Source #

dirLeftHandShiftKey :: [Key] Source #

dirViChar :: [Char] Source #

dirViKey :: [Key] Source #

dirViShiftKey :: [Key] Source #