packages feed

irc-fun-color 0.1.0.0 → 0.1.0.1

raw patch · 3 files changed

+40/−9 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

NEWS view
@@ -3,6 +3,31 @@   +irc-fun-color 0.1.0.1 -- 2015-09-10+===================================++General, build and documentation changes:++* (None)++New APIs, features and enhancements:++* (None)++Bug fixes:++* When a message starting with a digit is assigned a color, it may be+  interpreted as part of the color code. This has been fixed by inserting some+  dummy codes between the code and the message text.++Dependency changes:++* (None)+++++ irc-fun-color 0.1.0.0 -- 2015-07-18 =================================== 
irc-fun-color.cabal view
@@ -1,14 +1,10 @@ name:                irc-fun-color-version:             0.1.0.0+version:             0.1.0.1 synopsis:            Add color and style decorations to IRC messages. description:   An extension to IRC allows text formatting to be encoded into a message.   Colors and decorations (e.g. bold) are available. This library can encode   this formatting into a plain text message.-  .-  The \"fun\" part of the library name refers to the set of integrated-  irc-fun-* libraries. This is the first one to be released to Hackage, but all-  of them are already available as free software in Darcs repositories. homepage:            http://rel4tion.org/projects/irc-fun-color/ bug-reports:         http://rel4tion.org/projects/irc-fun-color/tickets/ license:             PublicDomain
src/Network/IRC/Fun/Color.hs view
@@ -26,8 +26,8 @@ -- -- The combinators are: ----- * '(#>)', '(<#)' : Apply a style to a styled string--- * '(<>)' : Styles strings are monoids, use '(<>)' to concatenate them+-- * '#>', '<#' : Apply a style to a styled string+-- * '<>' : Styles strings are monoids, use '<>' to concatenate them -- -- The tools for choosing styles for application are: --@@ -42,7 +42,7 @@ -- -- Here are some examples. I assume here the @OverloadedStrings@ extension is -- enabled. If you prefer not to use it, you'll need to directly apply--- 'Pure' or 'fromString' to 'String's before styling (e.g. with '(#>)').+-- 'Pure' or 'fromString' to 'String's before styling (e.g. with '#>'). -- -- Green text: --@@ -99,6 +99,7 @@     ) where +import Data.Char (isDigit) import Data.List (nub) import Data.Monoid import Data.String (IsString (..))@@ -300,9 +301,18 @@ flatten (Decorated d s) = applyDeco d $ flatten s flatten (Concat ss)     = concatMap flatten ss +-- If a message to be colored starts with a digit, insert dummy codes to+-- separate the text from the color code number+protect :: String -> String+protect []      = []+protect s@(d:r) =+    if isDigit d+        then decoCode Bold : decoCode Bold : s+        else s+ encodeColor :: Maybe Color -> Maybe Color -> String -> String encodeColor Nothing Nothing s = s-encodeColor f       b       s = colorCode f b ++ s ++ [colorChar]+encodeColor f       b       s = colorCode f b ++ protect s ++ [colorChar]  encodeDeco :: [Decoration] -> String -> String encodeDeco ds s = foldl f s $ nub ds