mirror of
https://github.com/ilyakooo0/vty.git
synced 2024-12-01 14:36:27 +03:00
Add rewrite rules to use wct(l)width instead of wcswidth/unpack
This commit is contained in:
parent
d64ff96027
commit
c384656988
@ -21,12 +21,20 @@ foreign import ccall unsafe "vty_mk_wcwidth" wcwidth :: Char -> Int
|
||||
|
||||
wcswidth :: String -> Int
|
||||
wcswidth = foldl' (\l c -> wcwidth c + l) 0
|
||||
{-# INLINE [1] wcswidth #-}
|
||||
|
||||
wctwidth :: T.Text -> Int
|
||||
wctwidth = T.foldl' (\l c -> wcwidth c + l) 0
|
||||
{-# INLINE [1] wctwidth #-}
|
||||
|
||||
wctlwidth :: TL.Text -> Int
|
||||
wctlwidth = TL.foldl' (\l c -> wcwidth c + l) 0
|
||||
{-# INLINE [1] wctlwidth #-}
|
||||
|
||||
{-# RULES
|
||||
"wcswidth/unpack" forall x. wcswidth (T.unpack x) = wctwidth x
|
||||
"wcswidth/lazy-unpack" forall x. wcswidth (TL.unpack x) = wctlwidth x
|
||||
#-}
|
||||
|
||||
-- XXX: Characters with unknown widths occupy 1 column?
|
||||
--
|
||||
|
Loading…
Reference in New Issue
Block a user