nanocurses-1.5.2: Simple Curses bindingSource codeContentsIndex
Line drawing
Key codes
error handling

Binding to the [wn]curses library. From the ncurses man page:

      The curses library routines give the user a terminal-inde-
      pendent method of updating character screens with  reason-
      able  optimization.

Sections of the quoted documentation are from the OpenBSD man pages, which are distributed under a BSD license.

A useful reference is: Writing Programs with NCURSES, by Eric S. Raymond and Zeyd M. Ben-Halim,

attrs dont work with Irix curses.h. This should be fixed.

initCurses :: IO () -> IO ()
resetParams :: IO ()
stdScr :: Window
endWin :: IO ()
keypad :: Window -> Bool -> IO ()
scrSize :: IO (Int, Int)
refresh :: IO ()
getCh :: IO Char
waddnstr :: Window -> CString -> CInt -> IO CInt
bkgrndSet :: Attr -> Pair -> IO ()
clrToEol :: IO ()
wMove :: Window -> Int -> Int -> IO ()
keyBackspace :: Char
keyUp :: Char
keyDown :: Char
keyNPage :: Char
keyHome :: Char
keyPPage :: Char
keyEnd :: Char
keyLeft :: Char
keyRight :: Char
keyResize :: Char
data CursorVisibility
= CursorInvisible
| CursorVisible
| CursorVeryVisible
cursSet :: CInt -> IO CInt
getYX :: Window -> IO (Int, Int)
newtype Pair = Pair Int
data Color
initPair :: Pair -> Color -> Color -> IO ()
color :: String -> Maybe Color
hasColors :: IO Bool
data Attr
attr0 :: Attr
setBold :: Attr -> Bool -> Attr
setReverse :: Attr -> Bool -> Attr
attrSet :: Attr -> Pair -> IO ()
attrPlus :: Attr -> Attr -> Attr
throwIfErr_ :: Num a => ByteString -> IO a -> IO ()
initCurses :: IO () -> IO ()Source
Start it all up
resetParams :: IO ()Source
A bunch of settings we need
stdScr :: WindowSource
The standard screen
endWin :: IO ()Source
 The program must call endwin for each terminal being used before
 exiting from curses.
keypad :: Window -> Bool -> IO ()Source
Enable the keypad of the user's terminal.
scrSize :: IO (Int, Int)Source
get the dimensions of the screen
refresh :: IO ()Source
refresh curses windows and lines. curs_refresh(3)
getCh :: IO CharSource

read a character from the window

When ESC followed by another key is pressed before the ESC timeout, that second character is not returned until a third character is pressed. wtimeout, nodelay and timeout don't appear to change this behaviour.

On emacs, we really would want Alt to be our meta key, I think.

Be warned, getCh will block the whole process without noDelay

Line drawing
waddnstr :: Window -> CString -> CInt -> IO CIntSource
bkgrndSet :: Attr -> Pair -> IO ()Source
clrToEol :: IO ()Source
wMove :: Window -> Int -> Int -> IO ()Source
    move the cursor associated with the window
    to line y and column x.  This routine does  not  move  the
    physical  cursor  of the terminal until refresh is called.
    The position specified is relative to the upper  left-hand
    corner of the window, which is (0,0).
Key codes
keyBackspace :: CharSource
keyUp :: CharSource
keyDown :: CharSource
Some constants for easy symbolic manipulation. NB we don't map keys to an abstract type anymore, as we can't use Alex lexers then.
keyNPage :: CharSource
keyHome :: CharSource
keyPPage :: CharSource
keyEnd :: CharSource
keyLeft :: CharSource
keyRight :: CharSource
keyResize :: CharSource
data CursorVisibility Source
cursSet :: CInt -> IO CIntSource

Set the cursor state

       The curs_set routine sets  the  cursor  state  is  set  to
       invisible, normal, or very visible for visibility equal to
       0, 1, or 2 respectively.  If  the  terminal  supports  the
       visibility   requested,   the  previous  cursor  state  is
       returned; otherwise, ERR is returned.
getYX :: Window -> IO (Int, Int)Source
Get the current cursor coordinates
newtype Pair Source
Pair Int
data Color Source
initPair :: Pair -> Color -> Color -> IO ()Source
 curses support color attributes  on  terminals  with  that
 capability.   To  use  these  routines start_color must be
 called, usually right after initscr.   Colors  are  always
 used  in pairs (referred to as color-pairs).  A color-pair
 consists of a foreground  color  (for  characters)  and  a
 background color (for the blank field on which the charac-
 ters are displayed).  A programmer  initializes  a  color-
 pair  with  the routine init_pair.  After it has been ini-
 tialized, COLOR_PAIR(n), a macro  defined  in  <curses.h>,
 can be used as a new video attribute.
 If  a  terminal  is capable of redefining colors, the pro-
 grammer can use the routine init_color to change the defi-
 nition   of   a   color.
 The init_pair routine changes the definition of  a  color-
 pair.   It takes three arguments: the number of the color-
 pair to be changed, the foreground color number,  and  the
 background color number.  For portable applications:
 -  The value of the first argument must be between 1 and
 -  The value of the second and third arguments  must  be
    between  0  and  COLORS (the 0 color pair is wired to
    white on black and cannot be changed).
color :: String -> Maybe ColorSource
hasColors :: IO BoolSource
data Attr Source
attr0 :: AttrSource
setBold :: Attr -> Bool -> AttrSource
setReverse :: Attr -> Bool -> AttrSource
attrSet :: Attr -> Pair -> IO ()Source
attrPlus :: Attr -> Attr -> AttrSource
error handling
throwIfErr_ :: Num a => ByteString -> IO a -> IO ()Source
Discard result
Produced by Haddock version 2.4.2