byline 0.2.4.0 → 0.3.0.0
raw patch · 7 files changed
+34/−11 lines, 7 filesdep ~ansi-terminalPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: ansi-terminal
API changes (from Hackage documentation)
+ System.Console.Byline: swapFgBg :: Stylized
+ System.Console.Byline.Modifiers: swapFgBg :: Stylized
Files
- CHANGES.md +6/−0
- byline.cabal +3/−3
- src/System/Console/Byline.hs +1/−1
- src/System/Console/Byline/Internal/Byline.hs +3/−0
- src/System/Console/Byline/Internal/Render.hs +11/−4
- src/System/Console/Byline/Internal/Types.hs +4/−3
- src/System/Console/Byline/Modifiers.hs +6/−0
CHANGES.md view
@@ -1,5 +1,11 @@ # Version History +## 0.3.0.0 (December 1, 2017)++ - New style modifier: `swapFgBg` (Thanks to Sam Tay)++ - `Byline` is now an instance of `MonadTrans` (Thanks to Sam Tay)+ ## 0.2.4.0 (March 19, 2017) - Update dependency bounds
byline.cabal view
@@ -1,6 +1,6 @@ -------------------------------------------------------------------------------- name: byline-version: 0.2.4.0+version: 0.3.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@@ -12,7 +12,7 @@ category: System, User Interfaces build-type: Simple stability: experimental-tested-with: GHC == 7.8.4, GHC == 7.10.3, GHC == 8.0.1+tested-with: GHC == 7.8.4, GHC == 7.10.3, GHC == 8.0.2 cabal-version: >=1.18 description: Byline simplifies writing interactive terminal applications by@@ -73,7 +73,7 @@ ghc-options: -Werror build-depends: base >= 4.7 && < 5.0- , ansi-terminal >= 0.6 && < 0.7+ , ansi-terminal >= 0.6 && < 0.8 , colour >= 2.3 && < 2.4 , containers >= 0.5 && < 0.6 , exceptions >= 0.8 && < 0.9
src/System/Console/Byline.hs view
@@ -75,7 +75,7 @@ -- This means you can change attributes of the text by using -- the following functions along with @mappend@ or the @(<>)@ -- operator.- , fg, bg, bold, underline+ , fg, bg, bold, underline, swapFgBg -- * Specifying Colors , Color
src/System/Console/Byline/Internal/Byline.hs view
@@ -66,6 +66,9 @@ newtype Byline m a = Byline {unByline :: ReaderT Env (MaybeT m) a} deriving (Functor, Applicative, Monad, MonadReader Env, MonadIO) +instance MonadTrans Byline where+ lift = liftBase+ -------------------------------------------------------------------------------- -- | Calculate the default rendering modes based on the terminal type. defRenderMode :: H.InputT IO (RenderMode, RenderMode)
src/System/Console/Byline/Internal/Render.hs view
@@ -99,10 +99,11 @@ -- | Convert a modifier into a series of SGR codes. modToSGR :: Modifier -> [SGR] modToSGR m =- catMaybes [ SetColor Foreground Dull <$> modColor modColorFG- , SetColor Background Dull <$> modColor modColorBG- , SetConsoleIntensity <$> modIntensity- , SetUnderlining <$> modUnderlining+ catMaybes [ SetColor Foreground Dull <$> modColor modColorFG+ , SetColor Background Dull <$> modColor modColorBG+ , SetConsoleIntensity <$> modIntensity+ , SetUnderlining <$> modUnderlining+ , SetSwapForegroundBackground <$> modSwapForegroundBackground ] where@@ -118,6 +119,12 @@ modUnderlining = case modUnderline m of Off -> Nothing On -> Just SingleUnderline++ modSwapForegroundBackground :: Maybe Bool+ modSwapForegroundBackground = case modSwapFgBg m of+ Off -> Nothing+ On -> Just True+ -------------------------------------------------------------------------------- -- | Convert modifiers into direct escape sequences for modifiers
src/System/Console/Byline/Internal/Types.hs view
@@ -56,10 +56,11 @@ , modColorBG :: OnlyOne Color , modBold :: Status , modUnderline :: Status+ , modSwapFgBg :: Status } -------------------------------------------------------------------------------- instance Monoid Modifier where- mempty = Modifier mempty mempty mempty mempty- mappend (Modifier a b c d) (Modifier a' b' c' d') =- Modifier (a <> a') (b <> b') (c <> c') (d <> d')+ mempty = Modifier mempty mempty mempty mempty mempty+ mappend (Modifier a b c d e) (Modifier a' b' c' d' e') =+ Modifier (a <> a') (b <> b') (c <> c') (d <> d') (e <> e')
src/System/Console/Byline/Modifiers.hs view
@@ -17,6 +17,7 @@ , bg , bold , underline+ , swapFgBg ) where --------------------------------------------------------------------------------@@ -58,3 +59,8 @@ -- | Produce underlined text. underline :: Stylized underline = modStylized (mempty {modUnderline = On})++--------------------------------------------------------------------------------+-- | Produce swapped foreground/background text.+swapFgBg :: Stylized+swapFgBg = modStylized (mempty {modSwapFgBg = On})