on master help sign in
Image: update text/string functions to indicate that escapes are not permitted
commitbb68f7ae05a8f5747c2a1208267561078de9d02a authorJonathan Daugherty <cygnus@foobox.com> dateThu 26 Jul 2018, 07:23 (8 years ago) parent3a3d6b3
1 file changed+8−4
src/Graphics/Vty/Image.hs+8−4
src/Graphics/Vty/Image.hs+8−4
@@ -113,12 +113,14 @@ horizCat = foldr horizJoin EmptyImage
113113vertCat :: [Image] -> Image
114114vertCat = foldr vertJoin EmptyImage
115115
116−-- | Make an 'Image' from a lazy text value.
116+-- | Make an 'Image' from a lazy text value. This function should not be
117+-- given a text value containing escapes.
117118text :: Attr -> TL.Text -> Image
118119text a txt = let displayWidth = safeWcswidth (TL.unpack txt)
119120 in HorizText a txt displayWidth (fromIntegral $! TL.length txt)
120121
121−-- | Make an 'Image' from a text value.
122+-- | Make an 'Image' from a text value. This function should not be
123+-- given a text value containing escapes.
122124text' :: Attr -> T.Text -> Image
123125text' a txt = let displayWidth = safeWcswidth (T.unpack txt)
124126 in HorizText a (TL.fromStrict txt) displayWidth (T.length txt)
@@ -132,7 +134,8 @@ char a c =
132134
133135-- | Make an image from a string of characters layed out on a single
134136-- row with the same display attribute. The string is assumed to be a
135−-- sequence of ISO-10646 characters.
137+-- sequence of ISO-10646 characters. This function should not be given a
138+-- string containing escapes.
136139--
137140-- Note: depending on how the Haskell compiler represents string
138141-- literals, a string literal in a UTF-8 encoded source file, for
@@ -149,7 +152,8 @@ iso10646String a str =
149152--
150153-- This is an alias for iso10646String since the usual case is that a
151154-- literal string like "foo" is represented internally as a list of ISO
152−-- 10646 31 bit characters.
155+-- 10646 31 bit characters. This function should not be given a string
156+-- containing escapes.
153157--
154158-- Note: Keep in mind that GHC will compile source encoded as UTF-8
155159-- but the literal strings, while UTF-8 encoded in the source, will be