1-- Copyright 2009 Corey O'Connor
2{-# OPTIONS_GHC -D_XOPEN_SOURCE -fno-cse #-}
3{-# LANGUAGE ForeignFunctionInterface, BangPatterns #-}
4module Codec.Binary.UTF8.Width ( wcwidth
10import Foreign.C.String
11import Foreign.Storable
14-- import Numeric ( showHex )
16import System.IO.Unsafe
19wcwidth c = unsafePerformIO (withCWString [c] $! \ws -> do
21 -- putStr $ "wcwidth(0x" ++ showHex (fromEnum wc) "" ++ ")"
22 let !w = fromIntegral $! wcwidth' wc
23 -- putStrLn $ " -> " ++ show w
26{-# NOINLINE wcwidth #-}
28foreign import ccall unsafe "mk_wcwidth" wcwidth' :: CWchar -> CInt
30wcswidth :: String -> Int
31wcswidth str = unsafePerformIO (withCWStringLen str $! \(ws, ws_len) -> do
32 -- putStr $ "wcswidth(...)"
33 let !w = fromIntegral $! wcswidth' ws (fromIntegral ws_len)
34 -- putStrLn $ " -> " ++ show w
37{-# NOINLINE wcswidth #-}
39foreign import ccall unsafe "mk_wcswidth" wcswidth' :: Ptr CWchar -> CSize -> CInt
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list