packages feed

brick 2.3.2 → 2.4

raw patch · 7 files changed

+53/−61 lines, 7 filesdep −unixdep ~basedep ~microlensdep ~vtyPVP ok

version bump matches the API change (PVP)

Dependencies removed: unix

Dependency ranges changed: base, microlens, vty

API changes (from Hackage documentation)

+ Brick.Keybindings.Normalize: normalizeKey :: [Modifier] -> Key -> Key
+ Brick.Keybindings.Parse: normalizeKey :: [Modifier] -> Key -> Key
- Brick.BorderMap: eBottomL :: forall a_agvz. Lens' (Edges a_agvz) a_agvz
+ Brick.BorderMap: eBottomL :: forall a_agyR. Lens' (Edges a_agyR) a_agyR
- Brick.BorderMap: eLeftL :: forall a_agvz. Lens' (Edges a_agvz) a_agvz
+ Brick.BorderMap: eLeftL :: forall a_agyR. Lens' (Edges a_agyR) a_agyR
- Brick.BorderMap: eRightL :: forall a_agvz. Lens' (Edges a_agvz) a_agvz
+ Brick.BorderMap: eRightL :: forall a_agyR. Lens' (Edges a_agyR) a_agyR
- Brick.BorderMap: eTopL :: forall a_agvz. Lens' (Edges a_agvz) a_agvz
+ Brick.BorderMap: eTopL :: forall a_agyR. Lens' (Edges a_agyR) a_agyR
- Brick.Types: availHeightL :: forall n_awKS. Lens' (Context n_awKS) Int
+ Brick.Types: availHeightL :: forall n_awOa. Lens' (Context n_awOa) Int
- Brick.Types: availWidthL :: forall n_awKS. Lens' (Context n_awKS) Int
+ Brick.Types: availWidthL :: forall n_awOa. Lens' (Context n_awOa) Int
- Brick.Types: bordersL :: forall n_awKW. Lens' (Result n_awKW) (BorderMap DynBorder)
+ Brick.Types: bordersL :: forall n_awOe. Lens' (Result n_awOe) (BorderMap DynBorder)
- Brick.Types: ctxAttrMapL :: forall n_awKS. Lens' (Context n_awKS) AttrMap
+ Brick.Types: ctxAttrMapL :: forall n_awOa. Lens' (Context n_awOa) AttrMap
- Brick.Types: ctxAttrNameL :: forall n_awKS. Lens' (Context n_awKS) AttrName
+ Brick.Types: ctxAttrNameL :: forall n_awOa. Lens' (Context n_awOa) AttrName
- Brick.Types: ctxBorderStyleL :: forall n_awKS. Lens' (Context n_awKS) BorderStyle
+ Brick.Types: ctxBorderStyleL :: forall n_awOa. Lens' (Context n_awOa) BorderStyle
- Brick.Types: ctxDynBordersL :: forall n_awKS. Lens' (Context n_awKS) Bool
+ Brick.Types: ctxDynBordersL :: forall n_awOa. Lens' (Context n_awOa) Bool
- Brick.Types: ctxHScrollBarOrientationL :: forall n_awKS. Lens' (Context n_awKS) (Maybe HScrollBarOrientation)
+ Brick.Types: ctxHScrollBarOrientationL :: forall n_awOa. Lens' (Context n_awOa) (Maybe HScrollBarOrientation)
- Brick.Types: ctxHScrollBarRendererL :: forall n_awKS. Lens' (Context n_awKS) (Maybe (HScrollbarRenderer n_awKS))
+ Brick.Types: ctxHScrollBarRendererL :: forall n_awOa. Lens' (Context n_awOa) (Maybe (HScrollbarRenderer n_awOa))
- Brick.Types: ctxVScrollBarOrientationL :: forall n_awKS. Lens' (Context n_awKS) (Maybe VScrollBarOrientation)
+ Brick.Types: ctxVScrollBarOrientationL :: forall n_awOa. Lens' (Context n_awOa) (Maybe VScrollBarOrientation)
- Brick.Types: ctxVScrollBarRendererL :: forall n_awKS. Lens' (Context n_awKS) (Maybe (VScrollbarRenderer n_awKS))
+ Brick.Types: ctxVScrollBarRendererL :: forall n_awOa. Lens' (Context n_awOa) (Maybe (VScrollbarRenderer n_awOa))
- Brick.Types: cursorLocationL :: forall n_awKX. Lens' (CursorLocation n_awKX) Location
+ Brick.Types: cursorLocationL :: forall n_awOf. Lens' (CursorLocation n_awOf) Location
- Brick.Types: cursorLocationNameL :: forall n_awKX n_azkz. Lens (CursorLocation n_awKX) (CursorLocation n_azkz) (Maybe n_awKX) (Maybe n_azkz)
+ Brick.Types: cursorLocationNameL :: forall n_awOf n_aznR. Lens (CursorLocation n_awOf) (CursorLocation n_aznR) (Maybe n_awOf) (Maybe n_aznR)
- Brick.Types: cursorsL :: forall n_awKW. Lens' (Result n_awKW) [CursorLocation n_awKW]
+ Brick.Types: cursorsL :: forall n_awOe. Lens' (Result n_awOe) [CursorLocation n_awOe]
- Brick.Types: eBottomL :: forall a_agvz. Lens' (Edges a_agvz) a_agvz
+ Brick.Types: eBottomL :: forall a_agyR. Lens' (Edges a_agyR) a_agyR
- Brick.Types: eLeftL :: forall a_agvz. Lens' (Edges a_agvz) a_agvz
+ Brick.Types: eLeftL :: forall a_agyR. Lens' (Edges a_agyR) a_agyR
- Brick.Types: eRightL :: forall a_agvz. Lens' (Edges a_agvz) a_agvz
+ Brick.Types: eRightL :: forall a_agyR. Lens' (Edges a_agyR) a_agyR
- Brick.Types: eTopL :: forall a_agvz. Lens' (Edges a_agvz) a_agvz
+ Brick.Types: eTopL :: forall a_agyR. Lens' (Edges a_agyR) a_agyR
- Brick.Types: extentsL :: forall n_awKW. Lens' (Result n_awKW) [Extent n_awKW]
+ Brick.Types: extentsL :: forall n_awOe. Lens' (Result n_awOe) [Extent n_awOe]
- Brick.Types: imageL :: forall n_awKW. Lens' (Result n_awKW) Image
+ Brick.Types: imageL :: forall n_awOe. Lens' (Result n_awOe) Image
- Brick.Types: visibilityRequestsL :: forall n_awKW. Lens' (Result n_awKW) [VisibilityRequest]
+ Brick.Types: visibilityRequestsL :: forall n_awOe. Lens' (Result n_awOe) [VisibilityRequest]
- Brick.Types: windowHeightL :: forall n_awKS. Lens' (Context n_awKS) Int
+ Brick.Types: windowHeightL :: forall n_awOa. Lens' (Context n_awOa) Int
- Brick.Types: windowWidthL :: forall n_awKS. Lens' (Context n_awKS) Int
+ Brick.Types: windowWidthL :: forall n_awOa. Lens' (Context n_awOa) Int
- Brick.Widgets.Dialog: dialogButtonsL :: forall a_a1rvQ n_a1rvR a_a1rwO. Lens (Dialog a_a1rvQ n_a1rvR) (Dialog a_a1rwO n_a1rvR) [(String, n_a1rvR, a_a1rvQ)] [(String, n_a1rvR, a_a1rwO)]
+ Brick.Widgets.Dialog: dialogButtonsL :: forall a_a1rz7 n_a1rz8 a_a1rA5. Lens (Dialog a_a1rz7 n_a1rz8) (Dialog a_a1rA5 n_a1rz8) [(String, n_a1rz8, a_a1rz7)] [(String, n_a1rz8, a_a1rA5)]
- Brick.Widgets.Dialog: dialogTitleL :: forall a_a1rvQ n_a1rvR. Lens' (Dialog a_a1rvQ n_a1rvR) (Maybe (Widget n_a1rvR))
+ Brick.Widgets.Dialog: dialogTitleL :: forall a_a1rz7 n_a1rz8. Lens' (Dialog a_a1rz7 n_a1rz8) (Maybe (Widget n_a1rz8))
- Brick.Widgets.Dialog: dialogWidthL :: forall a_a1rvQ n_a1rvR. Lens' (Dialog a_a1rvQ n_a1rvR) Int
+ Brick.Widgets.Dialog: dialogWidthL :: forall a_a1rz7 n_a1rz8. Lens' (Dialog a_a1rz7 n_a1rz8) Int
- Brick.Widgets.Edit: editContentsL :: forall t_a1jEt n_a1jEu t_a1jFe. Lens (Editor t_a1jEt n_a1jEu) (Editor t_a1jFe n_a1jEu) (TextZipper t_a1jEt) (TextZipper t_a1jFe)
+ Brick.Widgets.Edit: editContentsL :: forall t_a1jHK n_a1jHL t_a1jIv. Lens (Editor t_a1jHK n_a1jHL) (Editor t_a1jIv n_a1jHL) (TextZipper t_a1jHK) (TextZipper t_a1jIv)
- Brick.Widgets.FileBrowser: fileBrowserEntriesG :: forall n_a1Eeb. SimpleGetter (FileBrowser n_a1Eeb) (List n_a1Eeb FileInfo)
+ Brick.Widgets.FileBrowser: fileBrowserEntriesG :: forall n_a1Ehh. SimpleGetter (FileBrowser n_a1Ehh) (List n_a1Ehh FileInfo)
- Brick.Widgets.FileBrowser: fileBrowserEntryFilterG :: forall n_a1Eeb. SimpleGetter (FileBrowser n_a1Eeb) (Maybe (FileInfo -> Bool))
+ Brick.Widgets.FileBrowser: fileBrowserEntryFilterG :: forall n_a1Ehh. SimpleGetter (FileBrowser n_a1Ehh) (Maybe (FileInfo -> Bool))
- Brick.Widgets.FileBrowser: fileBrowserExceptionG :: forall n_a1Eeb. SimpleGetter (FileBrowser n_a1Eeb) (Maybe IOException)
+ Brick.Widgets.FileBrowser: fileBrowserExceptionG :: forall n_a1Ehh. SimpleGetter (FileBrowser n_a1Ehh) (Maybe IOException)
- Brick.Widgets.FileBrowser: fileBrowserLatestResultsG :: forall n_a1Eeb. SimpleGetter (FileBrowser n_a1Eeb) [FileInfo]
+ Brick.Widgets.FileBrowser: fileBrowserLatestResultsG :: forall n_a1Ehh. SimpleGetter (FileBrowser n_a1Ehh) [FileInfo]
- Brick.Widgets.FileBrowser: fileBrowserNameG :: forall n_a1Eeb. SimpleGetter (FileBrowser n_a1Eeb) n_a1Eeb
+ Brick.Widgets.FileBrowser: fileBrowserNameG :: forall n_a1Ehh. SimpleGetter (FileBrowser n_a1Ehh) n_a1Ehh
- Brick.Widgets.FileBrowser: fileBrowserSearchStringG :: forall n_a1Eeb. SimpleGetter (FileBrowser n_a1Eeb) (Maybe Text)
+ Brick.Widgets.FileBrowser: fileBrowserSearchStringG :: forall n_a1Ehh. SimpleGetter (FileBrowser n_a1Ehh) (Maybe Text)
- Brick.Widgets.FileBrowser: fileBrowserSelectableG :: forall n_a1Eeb. SimpleGetter (FileBrowser n_a1Eeb) (FileInfo -> Bool)
+ Brick.Widgets.FileBrowser: fileBrowserSelectableG :: forall n_a1Ehh. SimpleGetter (FileBrowser n_a1Ehh) (FileInfo -> Bool)
- Brick.Widgets.FileBrowser: fileBrowserSelectableL :: forall n_a1Eeb. Lens' (FileBrowser n_a1Eeb) (FileInfo -> Bool)
+ Brick.Widgets.FileBrowser: fileBrowserSelectableL :: forall n_a1Ehh. Lens' (FileBrowser n_a1Ehh) (FileInfo -> Bool)
- Brick.Widgets.FileBrowser: fileBrowserSelectedFilesG :: forall n_a1Eeb. SimpleGetter (FileBrowser n_a1Eeb) (Set String)
+ Brick.Widgets.FileBrowser: fileBrowserSelectedFilesG :: forall n_a1Ehh. SimpleGetter (FileBrowser n_a1Ehh) (Set String)
- Brick.Widgets.FileBrowser: fileBrowserWorkingDirectoryG :: forall n_a1Eeb. SimpleGetter (FileBrowser n_a1Eeb) FilePath
+ Brick.Widgets.FileBrowser: fileBrowserWorkingDirectoryG :: forall n_a1Ehh. SimpleGetter (FileBrowser n_a1Ehh) FilePath
- Brick.Widgets.List: listElementsL :: forall n_a1xRi t_a1xRj e_a1xRk t_a1y6T e_a1y6U. Lens (GenericList n_a1xRi t_a1xRj e_a1xRk) (GenericList n_a1xRi t_a1y6T e_a1y6U) (t_a1xRj e_a1xRk) (t_a1y6T e_a1y6U)
+ Brick.Widgets.List: listElementsL :: forall n_a1xUz t_a1xUA e_a1xUB t_a1yaa e_a1yab. Lens (GenericList n_a1xUz t_a1xUA e_a1xUB) (GenericList n_a1xUz t_a1yaa e_a1yab) (t_a1xUA e_a1xUB) (t_a1yaa e_a1yab)
- Brick.Widgets.List: listItemHeightL :: forall n_a1xRi t_a1xRj e_a1xRk. Lens' (GenericList n_a1xRi t_a1xRj e_a1xRk) Int
+ Brick.Widgets.List: listItemHeightL :: forall n_a1xUz t_a1xUA e_a1xUB. Lens' (GenericList n_a1xUz t_a1xUA e_a1xUB) Int
- Brick.Widgets.List: listNameL :: forall n_a1xRi t_a1xRj e_a1xRk n_a1y6V. Lens (GenericList n_a1xRi t_a1xRj e_a1xRk) (GenericList n_a1y6V t_a1xRj e_a1xRk) n_a1xRi n_a1y6V
+ Brick.Widgets.List: listNameL :: forall n_a1xUz t_a1xUA e_a1xUB n_a1yac. Lens (GenericList n_a1xUz t_a1xUA e_a1xUB) (GenericList n_a1yac t_a1xUA e_a1xUB) n_a1xUz n_a1yac
- Brick.Widgets.List: listSelectedL :: forall n_a1xRi t_a1xRj e_a1xRk. Lens' (GenericList n_a1xRi t_a1xRj e_a1xRk) (Maybe Int)
+ Brick.Widgets.List: listSelectedL :: forall n_a1xUz t_a1xUA e_a1xUB. Lens' (GenericList n_a1xUz t_a1xUA e_a1xUB) (Maybe Int)

Files

CHANGELOG.md view
@@ -2,6 +2,22 @@ Brick changelog --------------- +2.4+---++Changes:+* The `Keybindings` API now normalizes keybindings+  to lowercase when modifiers are present. (See also+  https://github.com/jtdaugherty/brick/issues/512) This means that,+  for example, a constructed binding for `C-X` would be normalized to+  `C-x`, and a binding from a configuration file written `C-X` would be+  parsed and then normalized to `C-x`. This is because, in general, when+  modifiers are present, input events are received for the lowercase+  version of the character in question. Prior to changing this, Brick+  would silently parse (or permit the construction of) uppercase-mapped+  key bindings, but in practice those bindings were unusable because+  they are not generated by terminals.+ 2.3.2 ----- 
brick.cabal view
@@ -1,5 +1,5 @@ name:                brick-version:             2.3.2+version:             2.4 synopsis:            A declarative terminal user interface library description:   Write terminal user interfaces (TUIs) painlessly with 'brick'! You@@ -77,6 +77,7 @@     Brick.Keybindings.KeyConfig     Brick.Keybindings.KeyEvents     Brick.Keybindings.KeyDispatcher+    Brick.Keybindings.Normalize     Brick.Keybindings.Parse     Brick.Keybindings.Pretty     Brick.Focus@@ -492,22 +493,6 @@                        vty,                        text,                        microlens--executable brick-unix-suspend-demo-  hs-source-dirs:      programs-  ghc-options:         -threaded -Wall -Wcompat -O2-  default-language:    Haskell2010-  main-is:             UnixSuspendDemo.hs-  build-depends:       base,-                       brick,-                       vty,-                       text,-                       vector,-                       mtl,-                       microlens >= 0.3.0.0,-                       microlens-th,-                       microlens-mtl,-                       unix  executable brick-edit-demo   if !flag(demos)
programs/CustomEventDemo.hs view
@@ -54,9 +54,9 @@     case e of         VtyEvent (V.EvKey V.KEsc []) -> halt         VtyEvent _ -> stLastBrickEvent .= (Just e)-        AppEvent Counter -> do-            stCounter %= (+1)-            stLastBrickEvent .= (Just e)+        -- AppEvent Counter -> do+        --     stCounter %= (+1)+        --     stLastBrickEvent .= (Just e)         _ -> return ()  initialState :: St
− programs/UnixSuspendDemo.hs
@@ -1,33 +0,0 @@-module Main where--import qualified Graphics.Vty as V--import qualified Brick.Main as M-import qualified Brick.Types as T-import Brick.Widgets.Core (str)-import qualified Brick.AttrMap as A-import System.Posix.Signals--drawUI :: () -> [T.Widget ()]-drawUI () = [str "Press C-z to suspend or any other key to quit"]--appEvent :: T.BrickEvent () e -> T.EventM () () ()-appEvent (T.VtyEvent (V.EvKey (V.KChar 'z') [V.MCtrl])) = do-    st <- T.get-    M.suspendAndResume $ do-        raiseSignal keyboardStop-        return st-appEvent _ =-    M.halt--theApp :: M.App () e ()-theApp =-    M.App { M.appDraw = drawUI-          , M.appChooseCursor = M.neverShowCursor-          , M.appHandleEvent = appEvent-          , M.appStartEvent = return ()-          , M.appAttrMap = const $ A.attrMap V.defAttr []-          }--main :: IO ()-main = M.defaultMain theApp ()
src/Brick/Keybindings/KeyConfig.hs view
@@ -47,6 +47,7 @@ import qualified Graphics.Vty as Vty  import Brick.Keybindings.KeyEvents+import Brick.Keybindings.Normalize  -- | A key binding. --@@ -67,10 +68,12 @@             -- ^ The set of modifiers.             } deriving (Eq, Show, Ord) --- | Construct a 'Binding'. Modifier order is ignored.+-- | Construct a 'Binding'. Modifier order is ignored. If modifiers+-- are given and the binding is for a character key, it is forced to+-- lowercase. binding :: Vty.Key -> [Vty.Modifier] -> Binding binding k mods =-    Binding { kbKey = k+    Binding { kbKey = normalizeKey mods k             , kbMods = S.fromList mods             } @@ -230,17 +233,23 @@ addModifier :: (ToBinding a) => Vty.Modifier -> a -> Binding addModifier m val =     let b = bind val-    in b { kbMods = S.insert m (kbMods b) }+        newMods = S.insert m $ kbMods b+    in b { kbMods = newMods+         , kbKey = normalizeKey (S.toList newMods) $ kbKey b+         } --- | Add Meta to a binding.+-- | Add Meta to a binding. If the binding is for a character key, force+-- it to lowercase. meta :: (ToBinding a) => a -> Binding meta = addModifier Vty.MMeta --- | Add Ctrl to a binding.+-- | Add Ctrl to a binding. If the binding is for a character key, force+-- it to lowercase. ctrl :: (ToBinding a) => a -> Binding ctrl = addModifier Vty.MCtrl --- | Add Shift to a binding.+-- | Add Shift to a binding. If the binding is for a character key, force+-- it to lowercase. shift :: (ToBinding a) => a -> Binding shift = addModifier Vty.MShift 
+ src/Brick/Keybindings/Normalize.hs view
@@ -0,0 +1,14 @@+module Brick.Keybindings.Normalize+  ( normalizeKey+  )+where++import Data.Char (toLower)+import qualified Graphics.Vty as Vty++-- | A keybinding involving modifiers should have its key character+-- normalized to lowercase since it's impossible to get uppercase keys+-- from the terminal when modifiers are present.+normalizeKey :: [Vty.Modifier] -> Vty.Key -> Vty.Key+normalizeKey (_:_) (Vty.KChar c) = Vty.KChar $ toLower c+normalizeKey _ k = k
src/Brick/Keybindings/Parse.hs view
@@ -5,6 +5,7 @@ module Brick.Keybindings.Parse   ( parseBinding   , parseBindingList+  , normalizeKey    , keybindingsFromIni   , keybindingsFromFile@@ -14,7 +15,6 @@  import Control.Monad (forM) import Data.Maybe (catMaybes)-import qualified Data.Set as S import qualified Data.Text as T import qualified Data.Text.IO as T import qualified Graphics.Vty as Vty@@ -23,6 +23,7 @@  import Brick.Keybindings.KeyEvents import Brick.Keybindings.KeyConfig+import Brick.Keybindings.Normalize  -- | Parse a key binding list into a 'BindingState'. --@@ -83,7 +84,7 @@ parseBinding s = go (T.splitOn "-" $ T.toLower s) []   where go [k] mods = do           k' <- pKey k-          return Binding { kbMods = S.fromList mods, kbKey = k' }+          return $ binding k' mods         go (k:ks) mods = do           m <- case k of             "s"       -> return Vty.MShift