summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorJames Crayne <jim.crayne@gmail.com>2018-05-29 01:05:54 +0000
committerJames Crayne <jim.crayne@gmail.com>2018-05-29 01:05:54 +0000
commit1a958b20ebc9ee24dc5ac5dfe505ff7f8f3434e6 (patch)
treecbcce9ee4c44307825d265e1b8e9c479c8180acf /examples
parentfe905494c23a56cc21afd702381486de5d892cf8 (diff)
utf8boldify function definition
Diffstat (limited to 'examples')
-rw-r--r--examples/dhtd.hs13
1 files changed, 12 insertions, 1 deletions
diff --git a/examples/dhtd.hs b/examples/dhtd.hs
index 291d0530..4f26fc16 100644
--- a/examples/dhtd.hs
+++ b/examples/dhtd.hs
@@ -80,6 +80,9 @@ import Data.Aeson as J (ToJSON, FromJSON)
80import qualified Data.Aeson as J 80import qualified Data.Aeson as J
81import qualified Data.ByteString.Lazy as L 81import qualified Data.ByteString.Lazy as L
82import qualified Data.ByteString.Char8 as B 82import qualified Data.ByteString.Char8 as B
83import qualified Data.Text as T
84import qualified Data.Text.Encoding as E
85import qualified Data.Text.Encoding.Error as E
83import Control.Concurrent.Tasks 86import Control.Concurrent.Tasks
84import System.IO.Error 87import System.IO.Error
85import qualified Data.Serialize as S 88import qualified Data.Serialize as S
@@ -1521,7 +1524,15 @@ showMsg (n,(flg,(snapshot,iocm))) = B.concat [bool " " "h " flg, showmsg' (snap
1521 where 1524 where
1522 showmsg' (snapshot,In cm) = B.concat [Tox.vNick snapshot,"> ", pshow cm] 1525 showmsg' (snapshot,In cm) = B.concat [Tox.vNick snapshot,"> ", pshow cm]
1523 showmsg' (snapshot,Out cm) = B.concat [utf8boldify (Tox.vNick snapshot),": ",pshow cm] 1526 showmsg' (snapshot,Out cm) = B.concat [utf8boldify (Tox.vNick snapshot),": ",pshow cm]
1524 utf8boldify s = s 1527 utf8boldify s = boldify (T.decodeUtf8With E.lenientDecode s)
1528 where
1529 boldify :: T.Text -> B.ByteString
1530 boldify j = E.encodeUtf8 $ T.map addIt j
1531 where addIt x = let o = ord x in case o of
1532 _ | o <= 90 && o >= 65 -> chr (o + 119743)
1533 _ | o <= 122 && o >= 97 -> chr (o + 119737)
1534 _ -> x
1535
1525 1536
1526main :: IO () 1537main :: IO ()
1527main = runResourceT $ liftBaseWith $ \resT -> do 1538main = runResourceT $ liftBaseWith $ \resT -> do