byline 0.1.0.0 → 0.2.0.0
raw patch · 6 files changed
+47/−16 lines, 6 filesdep ~mtldep ~transformersPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: mtl, transformers
API changes (from Hackage documentation)
+ System.Console.Byline: NoItems :: Choice a
+ System.Console.Byline.Menu: NoItems :: Choice a
Files
- CHANGES +6/−0
- byline.cabal +6/−6
- src/System/Console/Byline/Internal/Byline.hs +6/−0
- src/System/Console/Byline/Internal/Render.hs +6/−0
- src/System/Console/Byline/Menu.hs +17/−10
- src/System/Console/Byline/Modifiers.hs +6/−0
CHANGES view
@@ -3,6 +3,12 @@ #+title: Version History #+startup: showall +* 0.2.0.0 (May 22, 2015)++ - Added the NoItems constructor for Choice to deal with menus that+ are asked to display an empty list.+ - Changes to build with GHC 7.8.4. and 7.10.1+ * 0.1.0.0 (May 19, 2015) - Initial release.
byline.cabal view
@@ -1,6 +1,6 @@ -------------------------------------------------------------------------------- name: byline-version: 0.1.0.0+version: 0.2.0.0 synopsis: Library for creating command-line interfaces (colors, menus, etc.) homepage: http://github.com/pjones/byline bug-reports: http://github.com/pjones/byline/issues@@ -9,10 +9,10 @@ author: Peter Jones <pjones@devalot.com> maintainer: Peter Jones <pjones@devalot.com> copyright: Copyright: (c) 2015 Peter J. Jones-category: System+category: System, User Interfaces build-type: Simple stability: experimental-tested-with: GHC == 7.8.4+tested-with: GHC == 7.8.4, GHC == 7.10.1 cabal-version: >=1.10 description: Byline simplifies writing interactive terminal applications by@@ -68,10 +68,10 @@ hs-source-dirs: src default-language: Haskell2010 ghc-options: -Wall -fwarn-incomplete-uni-patterns- ghc-prof-options: -prof -auto-all if flag(maintainer) ghc-options: -Werror+ ghc-prof-options: -prof -auto-all build-depends: base >= 4.7 && < 5.0 , ansi-terminal >= 0.6 && < 0.7@@ -79,10 +79,10 @@ , containers >= 0.5 && < 0.6 , exceptions >= 0.8 && < 0.9 , haskeline >= 0.7 && < 0.8- , mtl >= 2.1 && < 2.2+ , mtl >= 2.1 && < 2.3 , terminfo-hs >= 0.1 && < 0.2 , text >= 0.11 && < 1.3- , transformers >= 0.3 && < 0.4+ , transformers >= 0.3 && < 0.5 -------------------------------------------------------------------------------- executable simple
src/System/Console/Byline/Internal/Byline.hs view
@@ -46,6 +46,12 @@ import System.Console.Byline.Internal.Render --------------------------------------------------------------------------------+-- The following is a kludge to avoid the "redundant import" warning+-- when using GHC >= 7.10.x. This should be removed after we decide+-- to stop supporting GHC < 7.10.x.+import Prelude++-------------------------------------------------------------------------------- -- | Reader environment for Byline. data Env = Env { sayMode :: RenderMode
src/System/Console/Byline/Internal/Render.hs view
@@ -37,6 +37,12 @@ import System.Console.Byline.Stylized --------------------------------------------------------------------------------+-- The following is a kludge to avoid the "redundant import" warning+-- when using GHC >= 7.10.x. This should be removed after we decide+-- to stop supporting GHC < 7.10.x.+import Prelude++-------------------------------------------------------------------------------- -- | How to render stylized text. data RenderMode = Plain -- ^ Text only, no modifiers. | Simple -- ^ Allow up to 8 colors.
src/System/Console/Byline/Menu.hs view
@@ -64,7 +64,8 @@ -------------------------------------------------------------------------------- -- | A type representing the choice made by a user while working with -- a menu.-data Choice a = Match a -- ^ User picked a menu item.+data Choice a = NoItems -- ^ Menu has no items to choose from.+ | Match a -- ^ User picked a menu item. | Other Text -- ^ User entered text that doesn't match an item. deriving Show @@ -187,16 +188,22 @@ -> Byline m (Choice a) askWithMenu m prompt = do currCompFunc <- Reader.asks compFunc >>= liftIO . readIORef- let firstItem = Text.strip $ renderText Plain (menuItemPrefix m 1) - -- Use the default completion function for menus, but not if another- -- completion function is already active.- withCompletionFunc (fromMaybe (defaultCompFunc m) currCompFunc) $ do- prefixes <- displayMenu- answer <- ask prompt (Just firstItem)- return (menuMatcher m m prefixes answer)+ if null (menuItems m)+ then return NoItems+ else go currCompFunc where+ -- Use the default completion function for menus, but not if another+ -- completion function is already active.+ go comp = withCompletionFunc (fromMaybe (defaultCompFunc m) comp) $ do+ prefixes <- displayMenu+ answer <- ask prompt (Just firstItem)+ return (menuMatcher m m prefixes answer)++ -- The default menu item.+ firstItem = Text.strip $ renderText Plain (menuItemPrefix m 1)+ -- Print the entire menu. displayMenu = do case menuBanner m of@@ -239,5 +246,5 @@ answer <- askWithMenu config prompt case answer of- Match _ -> return answer- _ -> go (config {menuBeforePrompt = Just errprompt})+ Other _ -> go (config {menuBeforePrompt = Just errprompt})+ _ -> return answer
src/System/Console/Byline/Modifiers.hs view
@@ -30,6 +30,12 @@ import System.Console.Byline.Stylized --------------------------------------------------------------------------------+-- The following is a kludge to avoid the "redundant import" warning+-- when using GHC >= 7.10.x. This should be removed after we decide+-- to stop supporting GHC < 7.10.x.+import Prelude++-------------------------------------------------------------------------------- -- | Set the foreground color. For example: -- -- @