Safe Haskell | None |
---|
- data Curses a
- data Update a
- data Window
- runCurses :: Curses a -> IO a
- defaultWindow :: Curses Window
- newWindow :: Integer -> Integer -> Integer -> Integer -> Curses Window
- closeWindow :: Window -> Curses ()
- cloneWindow :: Window -> Curses Window
- updateWindow :: Window -> Update a -> Curses a
- render :: Curses ()
- moveCursor :: Integer -> Integer -> Update ()
- setColor :: ColorID -> Update ()
- drawString :: String -> Update ()
- drawText :: Text -> Update ()
- drawBorder :: Maybe Glyph -> Maybe Glyph -> Maybe Glyph -> Maybe Glyph -> Maybe Glyph -> Maybe Glyph -> Maybe Glyph -> Maybe Glyph -> Update ()
- drawBox :: Maybe Glyph -> Maybe Glyph -> Update ()
- drawLineH :: Maybe Glyph -> Integer -> Update ()
- drawLineV :: Maybe Glyph -> Integer -> Update ()
- setBackground :: Glyph -> Update ()
- data Attribute
- setAttribute :: Attribute -> Bool -> Update ()
- setAttributes :: [Attribute] -> Update ()
- data Color
- = ColorBlack
- | ColorRed
- | ColorGreen
- | ColorYellow
- | ColorBlue
- | ColorMagenta
- | ColorCyan
- | ColorWhite
- data ColorID
- supportsColor :: Curses Bool
- canDefineColor :: Curses Bool
- defineColor :: Color -> Integer -> Integer -> Integer -> Curses ()
- queryColor :: Color -> Curses (Integer, Integer, Integer)
- defaultColorID :: ColorID
- newColorID :: Color -> Color -> Integer -> Curses ColorID
- setColorID :: Color -> Color -> ColorID -> Curses ()
- maxColorID :: Curses Integer
- data Glyph = Glyph {}
- glyphCornerUL :: Glyph
- glyphCornerLL :: Glyph
- glyphCornerUR :: Glyph
- glyphCornerLR :: Glyph
- glyphTeeL :: Glyph
- glyphTeeR :: Glyph
- glyphTeeB :: Glyph
- glyphTeeT :: Glyph
- glyphLineH :: Glyph
- glyphLineV :: Glyph
- glyphPlus :: Glyph
- glyphScan1 :: Glyph
- glyphScan9 :: Glyph
- glyphDiamond :: Glyph
- glyphStipple :: Glyph
- glyphDegree :: Glyph
- glyphPlusMinus :: Glyph
- glyphBullet :: Glyph
- glyphArrowL :: Glyph
- glyphArrowR :: Glyph
- glyphArrowD :: Glyph
- glyphArrowU :: Glyph
- glyphBoard :: Glyph
- glyphLantern :: Glyph
- glyphBlock :: Glyph
- glyphS3 :: Glyph
- glyphS7 :: Glyph
- glyphNE :: Glyph
- glyphLTE :: Glyph
- glyphGTE :: Glyph
- glyphPi :: Glyph
- glyphSterling :: Glyph
- data Event
- getEvent :: Window -> Maybe Integer -> Curses (Maybe Event)
- data Key
- = KeyUpArrow
- | KeyDownArrow
- | KeyLeftArrow
- | KeyRightArrow
- | KeyHome
- | KeyBackspace
- | KeyFunction Integer
- | KeyDeleteLine
- | KeyInsertLine
- | KeyDeleteCharacter
- | KeyInsertCharacter
- | KeyEIC
- | KeyClear
- | KeyEOS
- | KeyEOL
- | KeyScrollForward
- | KeyScrollBackward
- | KeyNextPage
- | KeyPreviousPage
- | KeySetTab
- | KeyClearTab
- | KeyClearAllTabs
- | KeyEnter
- | KeyPrint
- | KeyHomeDown
- | KeyA1
- | KeyA3
- | KeyB2
- | KeyC1
- | KeyC3
- | KeyBackTab
- | KeyBegin
- | KeyCancel
- | KeyClose
- | KeyCommand
- | KeyCopy
- | KeyCreate
- | KeyEnd
- | KeyExit
- | KeyFind
- | KeyHelp
- | KeyMark
- | KeyMessage
- | KeyMove
- | KeyNext
- | KeyOpen
- | KeyOptions
- | KeyPrevious
- | KeyRedo
- | KeyReference
- | KeyRefresh
- | KeyReplace
- | KeyRestart
- | KeyResume
- | KeySave
- | KeyShiftedBegin
- | KeyShiftedCancel
- | KeyShiftedCommand
- | KeyShiftedCopy
- | KeyShiftedCreate
- | KeyShiftedDeleteCharacter
- | KeyShiftedDeleteLine
- | KeySelect
- | KeyShiftedEnd
- | KeyShiftedEOL
- | KeyShiftedExit
- | KeyShiftedFind
- | KeyShiftedHelp
- | KeyShiftedHome
- | KeyShiftedInsertCharacter
- | KeyShiftedLeftArrow
- | KeyShiftedMessage
- | KeyShiftedMove
- | KeyShiftedNext
- | KeyShiftedOptions
- | KeyShiftedPrevious
- | KeyShiftedPrint
- | KeyShiftedRedo
- | KeyShiftedReplace
- | KeyShiftedRightArrow
- | KeyShiftedResume
- | KeyShiftedSave
- | KeyShiftedSuspend
- | KeyShiftedUndo
- | KeySuspend
- | KeyUndo
- data ButtonState
- data MouseState = MouseState {
- mouseCoordinates :: (Integer, Integer, Integer)
- mouseButtons :: [(Integer, ButtonState)]
- mouseAlt :: Bool
- mouseShift :: Bool
- mouseControl :: Bool
- data CursorMode
- setCursorMode :: CursorMode -> Curses CursorMode
- setRaw :: Bool -> Curses ()
- setCBreak :: Bool -> Curses ()
- setEcho :: Bool -> Curses ()
- baudrate :: Curses Integer
- beep :: Curses ()
- flash :: Curses ()
- hasMouse :: Curses Bool
- enclosed :: Window -> Integer -> Integer -> Curses Bool
- screenSize :: Curses (Integer, Integer)
- setTouched :: Bool -> Update ()
- setRowsTouched :: Bool -> Integer -> Integer -> Update ()
- setKeypad :: Window -> Bool -> Curses ()
- getCursor :: Window -> Curses (Integer, Integer)
Primary types
A small wrapper around IO
, to ensure the ncurses
library is
initialized while running.
Initialization
runCurses :: Curses a -> IO aSource
Put the terminal in graphical mode, including enabling special keys, colors, and mouse events (if supported).
After the Curses
block has finished running, the terminal is reset
to text mode.
defaultWindow :: Curses WindowSource
The default window created when ncurses
is initialized, also known
as stdscr
.
Window management
Create a new Window
, with the given dimensions. To create a
fullscreen window, use
.
newWindow
0 0 0 0
When the window is no longer needed, call closeWindow
. Windows are not
garbage–collected, because there’s no way to know if
they’re still in use (as a background, or event source, etc).
closeWindow :: Window -> Curses ()Source
Close a window, and free all resources associated with it. Once a window has been closed, it is no longer safe to use.
Note: this computation will not automatically clear the window from the screen.
cloneWindow :: Window -> Curses WindowSource
Create a separate window, initialised with the state of an existing window.
Drawing to the screen
updateWindow :: Window -> Update a -> Curses aSource
Apply a window update to the window. After all of an
application’s windows have been updated, call render
to update
the terminal’s contents.
Re–draw any portions of the screen which have changed since the last render.
Move the window’s cursor position to the given row and column.
setColor :: ColorID -> Update ()Source
Set the current foreground and background colors. See newColorID
for how to create color IDs.
drawString :: String -> Update ()Source
Add some text to the window, at the current cursor position.
:: Maybe Glyph | Left edge |
-> Maybe Glyph | Right edge |
-> Maybe Glyph | Top edge |
-> Maybe Glyph | Bottom edge |
-> Maybe Glyph | Top left corner |
-> Maybe Glyph | Top right corner |
-> Maybe Glyph | Bottom left corner |
-> Maybe Glyph | Bottom right corner |
-> Update () |
Draw a border around the edge of the window. For any edge, passing
Nothing
means to use the default glyph.
drawBox :: Maybe Glyph -> Maybe Glyph -> Update ()Source
drawBox v h = drawBorder v v h h Nothing Nothing Nothing Nothing
drawLineH :: Maybe Glyph -> Integer -> Update ()Source
Draw a horizontal line from left to right, using the given glyph and maximum character count. The cursor position is not changed.
drawLineV :: Maybe Glyph -> Integer -> Update ()Source
Draw a vertical line from top to bottom, using the given glyph and maximum character count. The cursor position is not changed.
setBackground :: Glyph -> Update ()Source
Set the window’s background glyph. The glyph will be drawn in place of any blank characters, and the glyph’s attributes will be combined with those of every character.
Attributes
setAttribute :: Attribute -> Bool -> Update ()Source
Set a single Attribute
on the current window. No other attributes
are modified.
setAttributes :: [Attribute] -> Update ()Source
Set all Attribute
s at once on the current window. Any attributes not
included in the list will be unset.
Colors
A wrapper around Integer
to ensure clients don’t use an
uninitialized color in an attribute.
supportsColor :: Curses BoolSource
Check if the terminal supports color. If it doesn’t, alternative indicators (such as underlines or bold) should be used.
canDefineColor :: Curses BoolSource
Check if the terminal supports changing color defintiions.
Change the definition of an existing color. Use canDefineColor
to
determine whether changing color values is possible.
queryColor :: Color -> Curses (Integer, Integer, Integer)Source
Query the current definition of the given color (see defineColor
).
The returned tuple is (red, green, blue), with values 0 – 1000.
defaultColorID :: ColorIDSource
The default color ID
:: Color | Foreground |
-> Color | Background |
-> Integer | A value n, such that
(0 < n ≤ |
-> Curses ColorID |
Assign a new ColorID
to some (foreground, background) color pair.
The user may pick which color ID is assigned, but it must be valid. Use
maxColorID
to determine how many colors the current terminal supports.
maxColorID :: Curses IntegerSource
Get the maximum color ID supported by the current terminal
Glyphs
A glyph is a character, typically spacing, combined with a set of attributes.
Glyph | |
|
VT100 drawing glyphs
Upper left corner
Lower left corner
Upper right corner
Lower right corner
Horizontal line
Vertical line
Scan line 1
Scan line 9
Diamond
Stipple, or checker board
Degree symbol
Plus/minus
Bullet
Teletype 5410v1 symbols
Arrow pointing left
Arrow pointing right
Arrow pointing down
Arrow pointing up
Board of squares
Lantern symbol
Solid square block
Other glyphs
UK pounds sterling symbol
Event handling
Keyboard events
Mouse events
data ButtonState Source
data MouseState Source
MouseState | |
|
Cursor mode
setCursorMode :: CursorMode -> Curses CursorModeSource
Set the current cursor mode to visible, invisible, or "very visible". The previous cursor mode is returned.
misc
Check if some position is contained within the given Window
.
screenSize :: Curses (Integer, Integer)Source
Return (rows, columns) of current screen
setTouched :: Bool -> Update ()Source
Set whether the entire window has been “touched”; touched characters are redrawn on the next refresh.
Set whether particular rows in the window have been “touched”.