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