1-- Copyright 2009 Corey O'Connor
2{-# OPTIONS_GHC -D_XOPEN_SOURCE #-}
3{-# LANGUAGE ForeignFunctionInterface #-}
4module Graphics.Text.Width
12foreign import ccall unsafe "vty_mk_wcwidth" wcwidth :: Char -> Int
14wcswidth :: String -> Int
15wcswidth = sum . map wcwidth
17-- XXX: Characters with unknown widths occupy 1 column?
19-- Not sure if this is actually correct. I presume there is a
20-- replacement character that is output by the terminal instead of the
21-- character and this replacement character is 1 column wide. If this is
22-- not true for all terminals then a per-terminal replacement character
23-- width needs to be implemented.
25-- | Returns the display width of a character. Assumes all characters
26-- with unknown widths are 0 width.
27safeWcwidth :: Char -> Int
28safeWcwidth = max 0 . wcwidth
30-- | Returns the display width of a string. Assumes all characters with
31-- unknown widths are 0 width.
32safeWcswidth :: String -> Int
33safeWcswidth = sum . map safeWcwidth
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