packages feed

itemfield 1.2.0.0 → 1.2.1.0

raw patch · 11 files changed

+190/−138 lines, 11 filesdep +transformersdep ~basedep ~brickdep ~microlensPVP ok

version bump matches the API change (PVP)

Dependencies added: transformers

Dependency ranges changed: base, brick, microlens, text, vty

API changes (from Hackage documentation)

Files

− brickcompat/015plus/TextUI/ItemField/BrickHelper.hs
@@ -1,53 +0,0 @@-module TextUI.ItemField.BrickHelper-       (getEventWidgetLocation)-       where--import Brick.Main (lookupViewport, lookupExtent, clickedExtent)-import Brick.Types (EventM, Location(..), locationRowL, locationColumnL,-                    Extent(..), Viewport(..))-import Brick.Widgets.Core (Named(..))-import Data.Monoid ((<>))-import Lens.Micro ((^.))----- | When processing a global EvMouseDown VtyEvent, the coordinates of--- the mouse event on the screen must be mapped to a specific location--- in a Widget.  The `lookupExtent` function will return the "extent"--- of the Widget (i.e. where it was drawn and how big it is) but this--- only indicates that the widget was clocked and does not identify--- the actual location within the widget where the click occurred.------ The `getEventWidgetLocation` function translates the mouse event--- coordinates to a specific location within the widget in the--- widget's local reference frame, taking into account any scrolling--- that has occurred within a viewport that wraps that widget.------    drawUI st = reportExtent (getName st) $---                viewport (getName st) Vertical $---                Widget Fixed Fixed $ ...------    handleEvent event st =---      case event of---        EvMouseDown col row button _mods ->---          do wcoords <- getEventWidgetLocation fieldw col row---             case wcoords of---               Nothing -> return fieldw---               Just l -> ...----getEventWidgetLocation :: (Named a n, Ord n)-                          => a -> Int -> Int -> EventM n (Maybe Location)-getEventWidgetLocation widget screenCol screenRow =-    do mExtent <- Brick.Main.lookupExtent (getName widget)-       case mExtent of-         Nothing -> return Nothing-         Just e@(Extent _ upperLeft _) ->-             if Brick.Main.clickedExtent (screenCol, screenRow) e-             then let widgetRow = screenRow - upperLeft^.locationRowL-                      widgetCol = screenCol - upperLeft^.locationColumnL-                      widgetLoc = Location (widgetCol, widgetRow)-                  in do mView <- Brick.Main.lookupViewport (getName widget)-                        case mView of-                          Nothing -> return $ Just widgetLoc-                          Just (VP left top _) ->-                            return $ Just $ widgetLoc <> Location (left, top)-             else return Nothing
− brickcompat/pre015/TextUI/ItemField/BrickHelper.hs
@@ -1,53 +0,0 @@-module TextUI.ItemField.BrickHelper-       (getEventWidgetLocation)-       where--import Brick.Main (lookupViewport, lookupExtent, clickedExtent)-import Brick.Types (EventM, Location(..), rowL, columnL,-                    Extent(..), Viewport(..))-import Brick.Widgets.Core (Named(..))-import Data.Monoid ((<>))-import Lens.Micro ((^.))----- | When processing a global EvMouseDown VtyEvent, the coordinates of--- the mouse event on the screen must be mapped to a specific location--- in a Widget.  The `lookupExtent` function will return the "extent"--- of the Widget (i.e. where it was drawn and how big it is) but this--- only indicates that the widget was clocked and does not identify--- the actual location within the widget where the click occurred.------ The `getEventWidgetLocation` function translates the mouse event--- coordinates to a specific location within the widget in the--- widget's local reference frame, taking into account any scrolling--- that has occurred within a viewport that wraps that widget.------    drawUI st = reportExtent (getName st) $---                viewport (getName st) Vertical $---                Widget Fixed Fixed $ ...------    handleEvent event st =---      case event of---        EvMouseDown col row button _mods ->---          do wcoords <- getEventWidgetLocation fieldw col row---             case wcoords of---               Nothing -> return fieldw---               Just l -> ...----getEventWidgetLocation :: (Named a n, Ord n)-                          => a -> Int -> Int -> EventM n (Maybe Location)-getEventWidgetLocation widget screenCol screenRow =-    do mExtent <- Brick.Main.lookupExtent (getName widget)-       case mExtent of-         Nothing -> return Nothing-         Just e@(Extent _ upperLeft _) ->-             if Brick.Main.clickedExtent (screenCol, screenRow) e-             then let widgetRow = screenRow - upperLeft^.rowL-                      widgetCol = screenCol - upperLeft^.columnL-                      widgetLoc = Location (widgetCol, widgetRow)-                  in do mView <- Brick.Main.lookupViewport (getName widget)-                        case mView of-                          Nothing -> return $ Just widgetLoc-                          Just (VP left top _) ->-                            return $ Just $ widgetLoc <> Location (left, top)-             else return Nothing
+ compat/base48/Compat.hs view
@@ -0,0 +1,3 @@+module Compat+       (length, (<$>))+where
+ compat/base_pre48/Compat.hs view
@@ -0,0 +1,15 @@+module Compat+       (module Data.Foldable+       , length+       , (<$>)+       )+where++import Prelude hiding (length)+import qualified Prelude as P+import Data.Foldable hiding (maximum, concat, mapM_)+import Control.Applicative+++length :: Foldable t => t a -> Int+length = P.length . toList
+ compat/brick_015plus/TextUI/ItemField/BrickHelper.hs view
@@ -0,0 +1,53 @@+module TextUI.ItemField.BrickHelper+       (getEventWidgetLocation)+       where++import Brick.Main (lookupViewport, lookupExtent, clickedExtent)+import Brick.Types (EventM, Location(..), locationRowL, locationColumnL,+                    Extent(..), Viewport(..))+import Brick.Widgets.Core (Named(..))+import Data.Monoid ((<>))+import Lens.Micro ((^.))+++-- | When processing a global EvMouseDown VtyEvent, the coordinates of+-- the mouse event on the screen must be mapped to a specific location+-- in a Widget.  The `lookupExtent` function will return the "extent"+-- of the Widget (i.e. where it was drawn and how big it is) but this+-- only indicates that the widget was clocked and does not identify+-- the actual location within the widget where the click occurred.+--+-- The `getEventWidgetLocation` function translates the mouse event+-- coordinates to a specific location within the widget in the+-- widget's local reference frame, taking into account any scrolling+-- that has occurred within a viewport that wraps that widget.+--+--    drawUI st = reportExtent (getName st) $+--                viewport (getName st) Vertical $+--                Widget Fixed Fixed $ ...+--+--    handleEvent event st =+--      case event of+--        EvMouseDown col row button _mods ->+--          do wcoords <- getEventWidgetLocation fieldw col row+--             case wcoords of+--               Nothing -> return fieldw+--               Just l -> ...+--+getEventWidgetLocation :: (Named a n, Ord n)+                          => a -> Int -> Int -> EventM n (Maybe Location)+getEventWidgetLocation widget screenCol screenRow =+    do mExtent <- Brick.Main.lookupExtent (getName widget)+       case mExtent of+         Nothing -> return Nothing+         Just e@(Extent _ upperLeft _) ->+             if Brick.Main.clickedExtent (screenCol, screenRow) e+             then let widgetRow = screenRow - upperLeft^.locationRowL+                      widgetCol = screenCol - upperLeft^.locationColumnL+                      widgetLoc = Location (widgetCol, widgetRow)+                  in do mView <- Brick.Main.lookupViewport (getName widget)+                        case mView of+                          Nothing -> return $ Just widgetLoc+                          Just (VP left top _) ->+                            return $ Just $ widgetLoc <> Location (left, top)+             else return Nothing
+ compat/brick_pre015/TextUI/ItemField/BrickHelper.hs view
@@ -0,0 +1,53 @@+module TextUI.ItemField.BrickHelper+       (getEventWidgetLocation)+       where++import Brick.Main (lookupViewport, lookupExtent, clickedExtent)+import Brick.Types (EventM, Location(..), rowL, columnL,+                    Extent(..), Viewport(..))+import Brick.Widgets.Core (Named(..))+import Data.Monoid ((<>))+import Lens.Micro ((^.))+++-- | When processing a global EvMouseDown VtyEvent, the coordinates of+-- the mouse event on the screen must be mapped to a specific location+-- in a Widget.  The `lookupExtent` function will return the "extent"+-- of the Widget (i.e. where it was drawn and how big it is) but this+-- only indicates that the widget was clocked and does not identify+-- the actual location within the widget where the click occurred.+--+-- The `getEventWidgetLocation` function translates the mouse event+-- coordinates to a specific location within the widget in the+-- widget's local reference frame, taking into account any scrolling+-- that has occurred within a viewport that wraps that widget.+--+--    drawUI st = reportExtent (getName st) $+--                viewport (getName st) Vertical $+--                Widget Fixed Fixed $ ...+--+--    handleEvent event st =+--      case event of+--        EvMouseDown col row button _mods ->+--          do wcoords <- getEventWidgetLocation fieldw col row+--             case wcoords of+--               Nothing -> return fieldw+--               Just l -> ...+--+getEventWidgetLocation :: (Named a n, Ord n)+                          => a -> Int -> Int -> EventM n (Maybe Location)+getEventWidgetLocation widget screenCol screenRow =+    do mExtent <- Brick.Main.lookupExtent (getName widget)+       case mExtent of+         Nothing -> return Nothing+         Just e@(Extent _ upperLeft _) ->+             if Brick.Main.clickedExtent (screenCol, screenRow) e+             then let widgetRow = screenRow - upperLeft^.rowL+                      widgetCol = screenCol - upperLeft^.columnL+                      widgetLoc = Location (widgetCol, widgetRow)+                  in do mView <- Brick.Main.lookupViewport (getName widget)+                        case mView of+                          Nothing -> return $ Just widgetLoc+                          Just (VP left top _) ->+                            return $ Just $ widgetLoc <> Location (left, top)+             else return Nothing
examples/workreport.hs view
@@ -9,6 +9,8 @@  module Main where +import Prelude hiding (length)+import Compat import Data.List (intercalate) import Data.Monoid import Data.Default
itemfield.cabal view
@@ -1,6 +1,5 @@ name:                itemfield-version:             1.2.0.0-+version:             1.2.1.0 synopsis:            A brick Widget for selectable summary of many elements on a terminal description:          @@ -27,6 +26,8 @@   * 1.1.0.0  -- add support for 's' and 'f' keys and mouse events   .   * 1.2.0.0  -- intermediary state is "Pending"+  .+  * 1.2.1.0  -- added compatibility for older distributions  license:             BSD3 license-file:        LICENSE@@ -37,8 +38,10 @@ build-type:          Simple cabal-version:       >=1.8 -extra-source-files: brickcompat/015plus/TextUI/ItemField/BrickHelper.hs-                    brickcompat/pre015/TextUI/ItemField/BrickHelper.hs+extra-source-files: compat/brick_015plus/TextUI/ItemField/BrickHelper.hs+                    compat/brick_pre015/TextUI/ItemField/BrickHelper.hs+                    compat/base_pre48/Compat.hs+                    compat/base48/Compat.hs  library   hs-source-dirs:    src@@ -48,40 +51,58 @@                      , TextUI.ItemField.Operations                      , TextUI.ItemField.Layout                      , TextUI.ItemField.BrickHelper-  build-depends:       base ==4.* , vty, text, microlens+                     , Compat+  build-depends:       vty < 5.14+                     , text < 1.3+                     , microlens < 0.5+  if flag(base48)+    build-depends:   base >= 4.8 && < 5.0+    hs-source-dirs:  compat/base48+  else+    build-depends:   base < 4.8+    hs-source-dirs:  compat/base_pre48   if flag(brick015plus)     build-depends:   brick >= 0.15-    hs-source-dirs:  brickcompat/015plus+    hs-source-dirs:  compat/brick_015plus   else     build-depends:   brick >= 0.13 && < 0.15-    hs-source-dirs:  brickcompat/pre015+    hs-source-dirs:  compat/brick_pre015   ghc-options:       -Wall -fno-warn-unused-do-bind -O3   Flag examples      Description: Build example programs-     Default:     False+     Default:     True  Flag brick015plus      Description: true for Brick version 0.15 or later      Default: True +Flag base48+     Description: base 4.8 or later+     Default: True++ executable bookcase            if !flag(examples)               Buildable: False            hs-source-dirs: src, examples+           if flag(base48)+             build-depends:   base >= 4.8 && < 5.0+             hs-source-dirs:  compat/base48+           else+             build-depends:   base < 4.8+             hs-source-dirs:  compat/base_pre48            if flag(brick015plus)              build-depends:   brick >= 0.15-             hs-source-dirs:  brickcompat/015plus+             hs-source-dirs:  compat/brick_015plus            else              build-depends:   brick >= 0.13 && < 0.15-             hs-source-dirs:  brickcompat/pre015+             hs-source-dirs:  compat/brick_pre015            ghc-options:  -threaded -Wall -fno-warn-unused-do-bind -O3            -- default-language: Haskell2010            main-is: bookcase.hs-           build-depends: base==4.*-                        , brick >= 0.13 && < 1.0-                        , vty, text, microlens, microlens-th+           build-depends: vty, text, microlens, microlens-th                         , itemfield, data-default  @@ -89,18 +110,22 @@            if !flag(examples)               Buildable: False            hs-source-dirs: src, examples+           if flag(base48)+             build-depends:   base >= 4.8 && < 5.0+             hs-source-dirs:  compat/base48+           else+             build-depends:   base < 4.8, transformers+             hs-source-dirs:  compat/base_pre48            if flag(brick015plus)              build-depends:   brick >= 0.15-             hs-source-dirs:  brickcompat/015plus+             hs-source-dirs:  compat/brick_015plus            else              build-depends:   brick >= 0.13 && < 0.15-             hs-source-dirs:  brickcompat/pre015+             hs-source-dirs:  compat/brick_pre015            ghc-options:  -threaded -Wall -fno-warn-unused-do-bind -O3            -- default-language: Haskell2010            main-is: workreport.hs-           build-depends: base==4.*-                        , brick >= 0.13 && < 1.0-                        , vty, text, microlens, microlens-th+           build-depends: vty, text, microlens, microlens-th                         , itemfield, data-default, random  @@ -108,14 +133,20 @@            type: exitcode-stdio-1.0            main-is: test_itemfield.hs            hs-source-dirs: test, src+           if flag(base48)+             build-depends:   base >= 4.8 && < 5.0+             hs-source-dirs:  compat/base48+           else+             build-depends:   base < 4.8+             hs-source-dirs:  compat/base_pre48            if flag(brick015plus)              build-depends:   brick >= 0.15-             hs-source-dirs:  brickcompat/015plus+             hs-source-dirs:  compat/brick_015plus            else              build-depends:   brick >= 0.13 && < 0.15-             hs-source-dirs:  brickcompat/pre015+             hs-source-dirs:  compat/brick_pre015            ghc-options:  -threaded -O0-           build-depends: base, HUnit, QuickCheck+           build-depends: HUnit, QuickCheck                         , test-framework, test-framework-hunit                         , test-framework-quickcheck2                         , brick >= 0.13 && < 1.0@@ -125,15 +156,21 @@            type: exitcode-stdio-1.0            main-is: test_layout.hs            hs-source-dirs: test, src+           if flag(base48)+             build-depends:   base >= 4.8 && < 5.0+             hs-source-dirs:  compat/base48+           else+             build-depends:   base < 4.8+             hs-source-dirs:  compat/base_pre48            if flag(brick015plus)              build-depends:   brick >= 0.15-             hs-source-dirs:  brickcompat/015plus+             hs-source-dirs:  compat/brick_015plus            else              build-depends:   brick >= 0.13 && < 0.15-             hs-source-dirs:  brickcompat/pre015+             hs-source-dirs:  compat/brick_pre015            ghc-options:  -threaded -O0            cpp-options: -DTEST-           build-depends: base, HUnit, QuickCheck+           build-depends: HUnit, QuickCheck                         , test-framework, test-framework-hunit                         , test-framework-quickcheck2                         , brick >= 0.13 && < 1.0
src/TextUI/ItemField.hs view
@@ -83,10 +83,6 @@     ) where -      -- KWQ: user provides marks?  that would imply state as well?  no for simplicity-      -- KWQ:  finish top level documentation.  Then ItemField is in good position refactoring lens, and then publishing.--  import           Brick.AttrMap import           Brick.Main (lookupViewport)
src/TextUI/ItemField/Layout.hs view
@@ -1,6 +1,8 @@ module TextUI.ItemField.Layout where  +import Prelude hiding (length)+import Compat import Data.Monoid ( (<>) ) import Data.Either import Data.Maybe
src/TextUI/ItemField/Types.hs view
@@ -47,10 +47,7 @@     showsPrec p s = showParen (p > 10) $                             showString "ItemFld @ " . shows (curSel s)                             . showString " with " . shows (length $ itemst8 s)-                            . showString " items:"-                            . shows (items s)-                            . showString " states:"-                            . shows (itemst8 s)+                            . showString " items"   -- | Standard factory to create an ItemField from a specification of