-- 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 displays 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.16 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 data CursesException -- | 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 -- | Moves the window to the given (row,column) coordinate. moveWindow :: Integer -> Integer -> Update () -- | Returns the current (row, column) coordinates of the window. windowPosition :: Update (Integer, Integer) -- | Resizes the window to the given row and column dimensions. resizeWindow :: Integer -> Integer -> Update () windowSize :: Update (Integer, Integer) -- | 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 data OverlayMode -- | Overlay only non-blank characters. OverlayMerge :: OverlayMode -- | Overlay all characters, including blanks. OverlayReplace :: OverlayMode -- | Overlay the entire content of another window onto this window. -- -- The overlay mode specifies whether to copy blank characters. -- -- Use copyWindow if precise control over coordinates is required. overlay :: Window -> OverlayMode -> Update () -- | Overlay a region of another window onto this window. -- -- Use overlay for copying the entire area of a window. copyWindow :: Window -> OverlayMode -> Integer -> Integer -> Integer -> Integer -> Integer -> Integer -> Update () -- | A Pad is a Window that is not associated with the screen. data Pad -- | Create a new Pad with the given dimensions. -- -- When the pad is no longer needed, call closePad. Pads are not -- garbage–collected, because there’s no way to know if they’re still in -- use. newPad :: Integer -> Integer -> Curses Pad -- | Close a pad, and free all resources associated with it. Once a pad has -- been closed, it is no longer safe to use. closePad :: Pad -> Curses () updatePad :: Pad -> Integer -> Integer -> Integer -> Integer -> Integer -> Integer -> Update a -> Curses a -- | Move the window’s cursor position to the given row and column. moveCursor :: Integer -> Integer -> Update () -- | Returns the current (row,column) coordinates of the cursor. -- -- This is the same as getCursor, but is usable within an Update. cursorPosition :: Update (Integer, Integer) -- | Return current cursor position as (row, column). -- -- This is the same as cursorPosition, but is usable outside of an -- Update. getCursor :: Window -> Curses (Integer, Integer) -- | Re–draw any portions of the screen which have changed since the last -- render. render :: Curses () -- | 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 () drawGlyph :: Glyph -> 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 () -- | Clear the window content by drawing blanks to every position. clear :: Update () -- | Clear the current line starting from the current cursor position -- (inclusive) to the end of the line. clearLine :: 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 -- | A_COLOR AttributeColor :: ColorID -> Attribute -- | A_STANDOUT AttributeStandout :: Attribute -- | A_UNDERLINE AttributeUnderline :: Attribute -- | A_REVERSE AttributeReverse :: Attribute -- | A_BLINK AttributeBlink :: Attribute -- | A_DIM AttributeDim :: Attribute -- | A_BOLD AttributeBold :: Attribute -- | A_ALTCHARSET AttributeAltCharset :: Attribute -- | A_INVISIBLE AttributeInvisible :: Attribute -- | A_PROTECT AttributeProtect :: Attribute -- | A_HORIZONTAL AttributeHorizontal :: Attribute -- | A_LEFT AttributeLeft :: Attribute -- | A_LOW AttributeLow :: Attribute -- | A_RIGHT AttributeRight :: Attribute -- | A_TOP AttributeTop :: Attribute -- | A_VERTICAL AttributeVertical :: 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 -- | An unspecified default terminal color, for terminals that support -- ISO/IEC 6429 escape sequences (or equivalent). -- -- This is most useful for terminals with translucent backgrounds. ColorDefault :: Color -- | A color outside of the standard COLOR_* enum space, for terminals that -- support more than eight colors. -- -- Color-related functions may fail if a Color is provided that cannot be -- supported by the current terminal. Users are responsible for checking -- maxColor when using extended colors. Color :: Int16 -> Color maxColor :: Curses Integer -- | 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 Nothing, getEvent blocks until an -- event is received. -- -- If the timeout is specified, getEvent blocks for up to that -- many milliseconds. If no event is received before timing out, -- 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 -- | Returns Left if a Curses exception occured in the given computation. -- -- See try for more details. tryCurses :: Curses a -> Curses (Either CursesException a) -- | Handles errors in the given computation by passing them to a callback. -- -- See catch for more details. catchCurses :: Curses a -> (CursesException -> Curses a) -> Curses a -- | Throws an exception from within Curses handling code. This is useful -- for re-throwing errors from within a catchCurses callback. -- -- See throwIO for more details. throwCurses :: CursesException -> Curses a -- | 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 () -- | Attempt to resize the terminal to the given number of lines and -- columns. resizeTerminal :: Integer -> Integer -> Curses () instance GHC.Show.Show UI.NCurses.CursorMode instance GHC.Classes.Eq UI.NCurses.CursorMode instance GHC.Classes.Eq UI.NCurses.Event instance GHC.Show.Show UI.NCurses.Event instance GHC.Classes.Eq UI.NCurses.MouseState instance GHC.Show.Show UI.NCurses.MouseState instance GHC.Classes.Eq UI.NCurses.ButtonState instance GHC.Show.Show UI.NCurses.ButtonState instance GHC.Classes.Eq UI.NCurses.Key instance GHC.Show.Show UI.NCurses.Key instance GHC.Classes.Eq UI.NCurses.Glyph instance GHC.Show.Show UI.NCurses.Glyph instance GHC.Classes.Eq UI.NCurses.Attribute instance GHC.Show.Show UI.NCurses.Attribute instance GHC.Classes.Eq UI.NCurses.ColorID instance GHC.Show.Show UI.NCurses.ColorID instance GHC.Classes.Eq UI.NCurses.Color instance GHC.Show.Show UI.NCurses.Color instance GHC.Classes.Eq UI.NCurses.OverlayMode instance GHC.Show.Show UI.NCurses.OverlayMode 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 ()