-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Modernised bindings to GNU ncurses -- -- GNU ncurses is a library for creating command-line application with -- pseudo-graphical interfaces. This package is a nice, modern binding to -- GNU ncurses. -- -- The following example is a program that display the message "Hello -- world!" until the user hits Q: -- --
-- import UI.NCurses -- -- main :: IO () -- main = runCurses $ do -- setEcho False -- w <- defaultWindow -- updateWindow w $ do -- moveCursor 1 10 -- drawString "Hello world!" -- moveCursor 3 10 -- drawString "(press q to quit)" -- moveCursor 0 0 -- render -- waitFor w (\ev -> ev == EventCharacter 'q' || ev == EventCharacter 'Q') -- -- waitFor :: Window -> (Event -> Bool) -> Curses () -- waitFor w p = loop where -- loop = do -- ev <- getEvent w Nothing -- case ev of -- Nothing -> loop -- Just ev' -> if p ev' then return () else loop --@package ncurses @version 0.2.3 module UI.NCurses -- | A small wrapper around IO, to ensure the ncurses -- library is initialized while running. data Curses a data Update a data Window -- | 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. runCurses :: Curses a -> IO a -- | The default window created when ncurses is initialized, also -- known as stdscr. defaultWindow :: Curses Window -- | 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). newWindow :: Integer -> Integer -> Integer -> Integer -> Curses Window -- | 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. closeWindow :: Window -> Curses () -- | Create a separate window, initialised with the state of an existing -- window. cloneWindow :: Window -> Curses Window -- | 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. updateWindow :: Window -> Update a -> Curses a -- | Re–draw any portions of the screen which have changed since the last -- render. render :: Curses () -- | Move the window’s cursor position to the given row and column. moveCursor :: Integer -> Integer -> Update () -- | Set the current foreground and background colors. See -- newColorID for how to create color IDs. setColor :: ColorID -> Update () -- | Add some text to the window, at the current cursor position. drawString :: String -> Update () -- | Add some text to the window, at the current cursor position. drawText :: Text -> Update () -- | Draw a border around the edge of the window. For any edge, passing -- Nothing means to use the default glyph. drawBorder :: Maybe Glyph -> Maybe Glyph -> Maybe Glyph -> Maybe Glyph -> Maybe Glyph -> Maybe Glyph -> Maybe Glyph -> Maybe Glyph -> Update () -- |
-- drawBox v h = drawBorder v v h h Nothing Nothing Nothing Nothing --drawBox :: Maybe Glyph -> Maybe Glyph -> Update () -- | Draw a horizontal line from left to right, using the given glyph and -- maximum character count. The cursor position is not changed. drawLineH :: Maybe Glyph -> Integer -> Update () -- | Draw a vertical line from top to bottom, using the given glyph and -- maximum character count. The cursor position is not changed. drawLineV :: Maybe Glyph -> Integer -> Update () -- | 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. setBackground :: Glyph -> Update () data Attribute AttributeStandout :: Attribute AttributeUnderline :: Attribute AttributeReverse :: Attribute AttributeBlink :: Attribute AttributeDim :: Attribute AttributeBold :: Attribute AttributeAltCharset :: Attribute AttributeInvisible :: Attribute AttributeProtect :: Attribute -- | Set a single Attribute on the current window. No other -- attributes are modified. setAttribute :: Attribute -> Bool -> Update () -- | Set all Attributes at once on the current window. Any -- attributes not included in the list will be unset. setAttributes :: [Attribute] -> Update () data Color ColorBlack :: Color ColorRed :: Color ColorGreen :: Color ColorYellow :: Color ColorBlue :: Color ColorMagenta :: Color ColorCyan :: Color ColorWhite :: Color -- | A wrapper around Integer to ensure clients don’t use an -- uninitialized color in an attribute. data ColorID -- | Check if the terminal supports color. If it doesn’t, alternative -- indicators (such as underlines or bold) should be used. supportsColor :: Curses Bool -- | Check if the terminal supports changing color defintiions. canDefineColor :: Curses Bool -- | Change the definition of an existing color. Use canDefineColor -- to determine whether changing color values is possible. defineColor :: Color -> Integer -> Integer -> Integer -> Curses () -- | Query the current definition of the given color (see -- defineColor). The returned tuple is (red, green, blue), with -- values 0 – 1000. queryColor :: Color -> Curses (Integer, Integer, Integer) -- | The default color ID defaultColorID :: 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. newColorID :: Color -> Color -> Integer -> Curses ColorID setColorID :: Color -> Color -> ColorID -> Curses () -- | Get the maximum color ID supported by the current terminal maxColorID :: Curses Integer -- | A glyph is a character, typically spacing, combined with a set of -- attributes. data Glyph Glyph :: Char -> [Attribute] -> Glyph glyphCharacter :: Glyph -> Char glyphAttributes :: Glyph -> [Attribute] -- | Upper left corner glyphCornerUL :: Glyph -- | Lower left corner glyphCornerLL :: Glyph -- | Upper right corner glyphCornerUR :: Glyph -- | Lower right corner glyphCornerLR :: Glyph -- | Tee pointing right glyphTeeL :: Glyph -- | Tee pointing left glyphTeeR :: Glyph -- | Tee pointing up glyphTeeB :: Glyph -- | Tee pointing down glyphTeeT :: Glyph -- | Horizontal line glyphLineH :: Glyph -- | Vertical line glyphLineV :: Glyph -- | Large plus or crossover glyphPlus :: Glyph -- | Scan line 1 glyphScan1 :: Glyph -- | Scan line 9 glyphScan9 :: Glyph -- | Diamond glyphDiamond :: Glyph -- | Stipple, or checker board glyphStipple :: Glyph -- | Degree symbol glyphDegree :: Glyph -- | Plus/minus glyphPlusMinus :: Glyph -- | Bullet glyphBullet :: Glyph -- | Arrow pointing left glyphArrowL :: Glyph -- | Arrow pointing right glyphArrowR :: Glyph -- | Arrow pointing down glyphArrowD :: Glyph -- | Arrow pointing up glyphArrowU :: Glyph -- | Board of squares glyphBoard :: Glyph -- | Lantern symbol glyphLantern :: Glyph -- | Solid square block glyphBlock :: Glyph -- | Scan line 3 glyphS3 :: Glyph -- | Scan line 7 glyphS7 :: Glyph -- | Not equal glyphNE :: Glyph -- | Less than or equal glyphLTE :: Glyph -- | Greater than or equal glyphGTE :: Glyph -- | Pi glyphPi :: Glyph -- | UK pounds sterling symbol glyphSterling :: Glyph data Event EventCharacter :: Char -> Event EventSpecialKey :: Key -> Event EventMouse :: Integer -> MouseState -> Event EventResized :: Event EventUnknown :: Integer -> Event -- | Get the next Event from a given window. -- -- If the timeout is specified, and no event is received within the -- timeout, getEvent returns Nothing. If the timeout is 0 -- or less, getEvent will not block at all. getEvent :: Window -> Maybe Integer -> Curses (Maybe Event) data Key KeyUpArrow :: Key KeyDownArrow :: Key KeyLeftArrow :: Key KeyRightArrow :: Key KeyHome :: Key KeyBackspace :: Key -- | Function keys, F0 – F64 KeyFunction :: Integer -> Key KeyDeleteLine :: Key KeyInsertLine :: Key KeyDeleteCharacter :: Key KeyInsertCharacter :: Key -- | Sent by rmir or smir in insert mode KeyEIC :: Key -- | Clear screen KeyClear :: Key -- | Clear to end of screen KeyEOS :: Key -- | Clear to end of line KeyEOL :: Key KeyScrollForward :: Key KeyScrollBackward :: Key KeyNextPage :: Key KeyPreviousPage :: Key KeySetTab :: Key KeyClearTab :: Key KeyClearAllTabs :: Key KeyEnter :: Key KeyPrint :: Key KeyHomeDown :: Key -- | Upper left of keypad KeyA1 :: Key -- | Upper right of keypad KeyA3 :: Key -- | Center of keypad KeyB2 :: Key -- | Lower left of keypad KeyC1 :: Key -- | Lower right of keypad KeyC3 :: Key KeyBackTab :: Key KeyBegin :: Key KeyCancel :: Key KeyClose :: Key KeyCommand :: Key KeyCopy :: Key KeyCreate :: Key KeyEnd :: Key KeyExit :: Key KeyFind :: Key KeyHelp :: Key KeyMark :: Key KeyMessage :: Key KeyMove :: Key KeyNext :: Key KeyOpen :: Key KeyOptions :: Key KeyPrevious :: Key KeyRedo :: Key KeyReference :: Key KeyRefresh :: Key KeyReplace :: Key KeyRestart :: Key KeyResume :: Key KeySave :: Key KeyShiftedBegin :: Key KeyShiftedCancel :: Key KeyShiftedCommand :: Key KeyShiftedCopy :: Key KeyShiftedCreate :: Key KeyShiftedDeleteCharacter :: Key KeyShiftedDeleteLine :: Key KeySelect :: Key KeyShiftedEnd :: Key KeyShiftedEOL :: Key KeyShiftedExit :: Key KeyShiftedFind :: Key KeyShiftedHelp :: Key KeyShiftedHome :: Key KeyShiftedInsertCharacter :: Key KeyShiftedLeftArrow :: Key KeyShiftedMessage :: Key KeyShiftedMove :: Key KeyShiftedNext :: Key KeyShiftedOptions :: Key KeyShiftedPrevious :: Key KeyShiftedPrint :: Key KeyShiftedRedo :: Key KeyShiftedReplace :: Key KeyShiftedRightArrow :: Key KeyShiftedResume :: Key KeyShiftedSave :: Key KeyShiftedSuspend :: Key KeyShiftedUndo :: Key KeySuspend :: Key KeyUndo :: Key data ButtonState ButtonPressed :: ButtonState ButtonReleased :: ButtonState ButtonClicked :: ButtonState ButtonDoubleClicked :: ButtonState ButtonTripleClicked :: ButtonState data MouseState MouseState :: (Integer, Integer, Integer) -> [(Integer, ButtonState)] -> Bool -> Bool -> Bool -> MouseState -- | (X, Y, Z) mouseCoordinates :: MouseState -> (Integer, Integer, Integer) -- | If the mouse event was caused by a change in button state, the buttons -- and their new state will be listed here. mouseButtons :: MouseState -> [(Integer, ButtonState)] mouseAlt :: MouseState -> Bool mouseShift :: MouseState -> Bool mouseControl :: MouseState -> Bool data CursorMode CursorInvisible :: CursorMode CursorVisible :: CursorMode CursorVeryVisible :: CursorMode -- | Set the current cursor mode to visible, invisible, or "very visible". -- The previous cursor mode is returned. setCursorMode :: CursorMode -> Curses CursorMode -- | Runs raw() or noraw() setRaw :: Bool -> Curses () -- | Runs cbreak() or nocbreak() setCBreak :: Bool -> Curses () -- | Runs echo() or noecho() setEcho :: Bool -> Curses () -- | Get the output speed of the current terminal, in bits per second. baudrate :: Curses Integer beep :: Curses () flash :: Curses () -- | Check if the terminal has a mouse hasMouse :: Curses Bool -- | Check if some position is contained within the given Window. enclosed :: Window -> Integer -> Integer -> Curses Bool -- | Return (rows, columns) of current screen screenSize :: Curses (Integer, Integer) -- | Set whether the entire window has been “touched”; touched characters -- are redrawn on the next refresh. setTouched :: Bool -> Update () -- | Set whether particular rows in the window have been “touched”. setRowsTouched :: Bool -> Integer -> Integer -> Update () -- | Enable/disable support for special keys. setKeypad :: Window -> Bool -> Curses () getCursor :: Window -> Curses (Integer, Integer) instance Show Attribute instance Eq Attribute instance Show Color instance Eq Color instance Show ColorID instance Eq ColorID instance Show Glyph instance Eq Glyph instance Show Key instance Eq Key instance Show ButtonState instance Eq ButtonState instance Show MouseState instance Eq MouseState instance Show Event instance Eq Event instance Eq CursorMode instance Show CursorMode module UI.NCurses.Panel data Panel -- | Creates a new Panel, on top of the panel stack. newPanel :: Window -> Curses Panel -- | Permanently removes the given panel from the panel stack. deletePanel :: Panel -> Curses () -- | Updates windows to account for the current panel stack order. The user -- must call render before changes are drawn to the screen. refreshPanels :: Curses () -- | panelAbove p retrieve the panel above p. panelAbove :: Panel -> Curses (Maybe Panel) -- | panelAbove p retrieve the panel below p. panelBelow :: Panel -> Curses (Maybe Panel) -- | Retrieve the top–most panel in the stack. panelTop :: Curses (Maybe Panel) -- | Retrieve the bottom–most panel in the stack. panelBottom :: Curses (Maybe Panel) -- | Makes a hidden panel visible, and places it on the top of the stack. showPanel :: Panel -> Curses () -- | Temporarily removes the given panel from the panel stack. Use -- showPanel to restore it. hidePanel :: Panel -> Curses () -- | Checks if the given panel is currently visible. panelHidden :: Panel -> Curses Bool -- | Move the panel so its upper–left corner is at the new coordinates. movePanel :: Panel -> Integer -> Integer -> Curses () -- | Raise a bottom to the top of the stack. raisePanel :: Panel -> Curses () -- | Lower a panel to the bottom of the stack. lowerPanel :: Panel -> Curses () -- | Retrieves which window a panel is drawn to. getPanelWindow :: Panel -> Curses Window -- | Replaces which window a panel is drawn to. replacePanelWindow :: Panel -> Window -> Curses ()