License | AGPL-3-or-later |
---|---|
Maintainer | gatlin@niltag.net |
Stability | experimental |
Portability | POSIX |
Safe Haskell | Safe-Inferred |
Language | GHC2021 |
Bindings to the C-language termbox2 console UI library.
Synopsis
- type Termbox2 = ReaderT (Ptr Tb2Event) IO
- runTermbox2 :: Termbox2 a -> IO a
- init :: Termbox2 ()
- initFile :: String -> Termbox2 ()
- initFd :: Integral n => n -> Termbox2 ()
- initRwFd :: (Integral n, Integral o) => n -> o -> Termbox2 ()
- shutdown :: Termbox2 ()
- width :: Integral n => Termbox2 n
- height :: Integral n => Termbox2 n
- present :: Termbox2 ()
- clear :: Termbox2 ()
- setClearAttrs :: Tb2ColorAttr -> Tb2ColorAttr -> Termbox2 ()
- setCursor :: Int -> Int -> Termbox2 ()
- hideCursor :: Termbox2 ()
- setCell :: Int -> Int -> Int32 -> Tb2ColorAttr -> Tb2ColorAttr -> Termbox2 ()
- setInputMode :: Tb2Input -> Termbox2 (Maybe Tb2Input)
- setOutputMode :: Tb2Output -> Termbox2 (Maybe Tb2Output)
- print :: Int -> Int -> Tb2ColorAttr -> Tb2ColorAttr -> String -> Termbox2 ()
- pollEvent :: Termbox2 (Maybe Tb2Event)
- peekEvent :: Int -> Termbox2 (Maybe Tb2Event)
- data Tb2Event = Tb2Event {}
- newtype Tb2Err = Tb2Err CInt
- errOk :: Tb2Err
- errErr :: Tb2Err
- errNeedMore :: Tb2Err
- errInitAlready :: Tb2Err
- errInitOpen :: Tb2Err
- errMem :: Tb2Err
- errNoEvent :: Tb2Err
- errNoTerm :: Tb2Err
- errNotInit :: Tb2Err
- errOutOfBounds :: Tb2Err
- errRead :: Tb2Err
- errResizeIOCTL :: Tb2Err
- errResizePipe :: Tb2Err
- errResizeSigaction :: Tb2Err
- errPoll :: Tb2Err
- errUnsupportedTerm :: Tb2Err
- errResizeWrite :: Tb2Err
- errResizePoll :: Tb2Err
- errResizeRead :: Tb2Err
- errResizeSscanf :: Tb2Err
- errCapCollision :: Tb2Err
- newtype Tb2Key = Tb2Key Word16
- keyCtrlTilde :: Tb2Key
- keyCtrl2 :: Tb2Key
- keyCtrlA :: Tb2Key
- keyCtrlB :: Tb2Key
- keyCtrlC :: Tb2Key
- keyCtrlD :: Tb2Key
- keyCtrlE :: Tb2Key
- keyCtrlF :: Tb2Key
- keyCtrlG :: Tb2Key
- keyBackspace :: Tb2Key
- keyCtrlH :: Tb2Key
- keyCtrlTab :: Tb2Key
- keyCtrlI :: Tb2Key
- keyCtrlJ :: Tb2Key
- keyCtrlK :: Tb2Key
- keyCtrlL :: Tb2Key
- keyCtrlEnter :: Tb2Key
- keyCtrlM :: Tb2Key
- keyCtrlN :: Tb2Key
- keyCtrlO :: Tb2Key
- keyCtrlP :: Tb2Key
- keyCtrlQ :: Tb2Key
- keyCtrlR :: Tb2Key
- keyCtrlS :: Tb2Key
- keyCtrlT :: Tb2Key
- keyCtrlU :: Tb2Key
- keyCtrlV :: Tb2Key
- keyCtrlW :: Tb2Key
- keyCtrlX :: Tb2Key
- keyCtrlY :: Tb2Key
- keyCtrlZ :: Tb2Key
- keyCtrlEsc :: Tb2Key
- keyCtrlLsqBracket :: Tb2Key
- keyCtrl3 :: Tb2Key
- keyCtrl4 :: Tb2Key
- keyCtrlBackslash :: Tb2Key
- keyCtrl5 :: Tb2Key
- keyCtrlRsqBracket :: Tb2Key
- keyCtrl6 :: Tb2Key
- keyCtrl7 :: Tb2Key
- keyCtrlSlash :: Tb2Key
- keyCtrlUnderscore :: Tb2Key
- keySpace :: Tb2Key
- keyBackspace2 :: Tb2Key
- keyCtrl8 :: Tb2Key
- keyF1 :: Tb2Key
- keyF2 :: Tb2Key
- keyF3 :: Tb2Key
- keyF4 :: Tb2Key
- keyF5 :: Tb2Key
- keyF6 :: Tb2Key
- keyF7 :: Tb2Key
- keyF8 :: Tb2Key
- keyF9 :: Tb2Key
- keyF10 :: Tb2Key
- keyF11 :: Tb2Key
- keyF12 :: Tb2Key
- keyInsert :: Tb2Key
- keyDelete :: Tb2Key
- keyHome :: Tb2Key
- keyEnd :: Tb2Key
- keyPgUp :: Tb2Key
- keyPgDn :: Tb2Key
- keyArrowUp :: Tb2Key
- keyArrowDown :: Tb2Key
- keyArrowLeft :: Tb2Key
- keyArrowRight :: Tb2Key
- keyBackTab :: Tb2Key
- keyMouseLeft :: Tb2Key
- keyMouseRight :: Tb2Key
- keyMouseMiddle :: Tb2Key
- keyMouseRelease :: Tb2Key
- keyMouseWheelUp :: Tb2Key
- keyMouseWheelDown :: Tb2Key
- newtype Tb2Mod = Tb2Mod Word8
- modAlt :: Tb2Mod
- modCtrl :: Tb2Mod
- modShift :: Tb2Mod
- modMotion :: Tb2Mod
- newtype Tb2Cap = Tb2Cap CInt
- capF1 :: Tb2Cap
- capF2 :: Tb2Cap
- capF3 :: Tb2Cap
- capF4 :: Tb2Cap
- capF5 :: Tb2Cap
- capF6 :: Tb2Cap
- capF7 :: Tb2Cap
- capF8 :: Tb2Cap
- capF9 :: Tb2Cap
- capF10 :: Tb2Cap
- capF11 :: Tb2Cap
- capF12 :: Tb2Cap
- capInsert :: Tb2Cap
- capDelete :: Tb2Cap
- capHome :: Tb2Cap
- capEnd :: Tb2Cap
- capPgUp :: Tb2Cap
- capPgDn :: Tb2Cap
- capArrowUp :: Tb2Cap
- capArrowDown :: Tb2Cap
- capArrowLeft :: Tb2Cap
- capArrowRight :: Tb2Cap
- capBackTab :: Tb2Cap
- capEnterCA :: Tb2Cap
- capExitCA :: Tb2Cap
- capShowCursor :: Tb2Cap
- capHideCursor :: Tb2Cap
- capClearScreen :: Tb2Cap
- capSGR0 :: Tb2Cap
- capUnderline :: Tb2Cap
- capBold :: Tb2Cap
- capBlink :: Tb2Cap
- capItalic :: Tb2Cap
- capReverse :: Tb2Cap
- capEnterKeypad :: Tb2Cap
- capExitKeypad :: Tb2Cap
- newtype Tb2EventType = Tb2EventType Word8
- eventKey :: Tb2EventType
- eventResize :: Tb2EventType
- eventMouse :: Tb2EventType
- newtype Tb2ColorAttr = Tb2ColorAttr CInt
- colorBlack :: Tb2ColorAttr
- colorRed :: Tb2ColorAttr
- colorGreen :: Tb2ColorAttr
- colorYellow :: Tb2ColorAttr
- colorBlue :: Tb2ColorAttr
- colorMagenta :: Tb2ColorAttr
- colorCyan :: Tb2ColorAttr
- colorWhite :: Tb2ColorAttr
- colorDefault :: Tb2ColorAttr
- attrBold :: Tb2ColorAttr
- attrUnderline :: Tb2ColorAttr
- attrReverse :: Tb2ColorAttr
- attrItalic :: Tb2ColorAttr
- attrBlink :: Tb2ColorAttr
- newtype Tb2Input = Tb2Input CInt
- inputCurrent :: Tb2Input
- inputEsc :: Tb2Input
- inputAlt :: Tb2Input
- inputMouse :: Tb2Input
- newtype Tb2Output = Tb2Output CInt
- outputCurrent :: Tb2Output
- outputNormal :: Tb2Output
- output256 :: Tb2Output
- output216 :: Tb2Output
- outputGrayscale :: Tb2Output
Termbox2 monad
type Termbox2 = ReaderT (Ptr Tb2Event) IO Source #
Enables writing text-based user interfaces with termbox2.
runTermbox2 :: Termbox2 a -> IO a Source #
Allocates the Tb2Event
struct pointer, runs the UI, and frees.
shutdown :: Termbox2 () Source #
Call this when you're finished or your terminal will act funky after exit!
setClearAttrs :: Tb2ColorAttr -> Tb2ColorAttr -> Termbox2 () Source #
Specify the foreground and background attributes to be applied when 'clearing the buffer.
setCursor :: Int -> Int -> Termbox2 () Source #
Set the location of the cursor (upper-left character is origin).
hideCursor :: Termbox2 () Source #
Hide the mouse pointer.
:: Int | |
-> Int | |
-> Int32 | Unicode code point |
-> Tb2ColorAttr | |
-> Tb2ColorAttr | |
-> Termbox2 () |
Draw a single cell on the screen.
setInputMode :: Tb2Input -> Termbox2 (Maybe Tb2Input) Source #
NB: If the argument is inputCurrent
then the function acts as a query
and returns the current input mode.
setOutputMode :: Tb2Output -> Termbox2 (Maybe Tb2Output) Source #
NB: If the argument is outputCurrent
then the function acts as a query
and returns the current output mode.
print :: Int -> Int -> Tb2ColorAttr -> Tb2ColorAttr -> String -> Termbox2 () Source #
Prints a string of text to the screen.
pollEvent :: Termbox2 (Maybe Tb2Event) Source #
Blocks until an exception is thrown or an event is observed. The documentation for termbox2 says that sometimes this function returns TB_ERR_POLL which means simply "try again". Instead of imposing a specific loop implementation on client code this function returns a 'Maybe Tb2Event`.
peekEvent :: Int -> Termbox2 (Maybe Tb2Event) Source #
Blocks for the specified number of MILLISECONDS until an exception is
thrown or an event is received; returns Nothing
if the timeout is reached
without incident or event.
The documentation for termbox2 says that sometimes this function returns
TB_ERR_POLL which means simply "try again".
Instead of imposing a specific loop implementation on client code this
function returns a 'Maybe Tb2Event'.
Events
Incoming event from the tty.
Instances
Storable Tb2Event Source # | |
Defined in Termbox2 sizeOf :: Tb2Event -> Int Source # alignment :: Tb2Event -> Int Source # peekElemOff :: Ptr Tb2Event -> Int -> IO Tb2Event Source # pokeElemOff :: Ptr Tb2Event -> Int -> Tb2Event -> IO () Source # peekByteOff :: Ptr b -> Int -> IO Tb2Event Source # pokeByteOff :: Ptr b -> Int -> Tb2Event -> IO () Source # | |
Show Tb2Event Source # | |
Eq Tb2Event Source # | |
Ord Tb2Event Source # | |
Constants
Errors
Instances
Enum Tb2Err Source # | |
Defined in Termbox2 succ :: Tb2Err -> Tb2Err Source # pred :: Tb2Err -> Tb2Err Source # toEnum :: Int -> Tb2Err Source # fromEnum :: Tb2Err -> Int Source # enumFrom :: Tb2Err -> [Tb2Err] Source # enumFromThen :: Tb2Err -> Tb2Err -> [Tb2Err] Source # enumFromTo :: Tb2Err -> Tb2Err -> [Tb2Err] Source # enumFromThenTo :: Tb2Err -> Tb2Err -> Tb2Err -> [Tb2Err] Source # | |
Num Tb2Err Source # | |
Integral Tb2Err Source # | |
Defined in Termbox2 | |
Real Tb2Err Source # | |
Show Tb2Err Source # | |
Eq Tb2Err Source # | |
Ord Tb2Err Source # | |
Defined in Termbox2 |
errNeedMore :: Tb2Err Source #
errInitOpen :: Tb2Err Source #
errNoEvent :: Tb2Err Source #
errNotInit :: Tb2Err Source #
errCapCollision :: Tb2Err Source #
Must be called before anything else. The termbox2 documentation notes that
handling some exceptions requires calling shutdown
followed by init
again, hence this is not invoked automatically by runTermbox2
.
Keys
Instances
Storable Tb2Key Source # | |
Defined in Termbox2 sizeOf :: Tb2Key -> Int Source # alignment :: Tb2Key -> Int Source # peekElemOff :: Ptr Tb2Key -> Int -> IO Tb2Key Source # pokeElemOff :: Ptr Tb2Key -> Int -> Tb2Key -> IO () Source # peekByteOff :: Ptr b -> Int -> IO Tb2Key Source # pokeByteOff :: Ptr b -> Int -> Tb2Key -> IO () Source # | |
Enum Tb2Key Source # | |
Defined in Termbox2 succ :: Tb2Key -> Tb2Key Source # pred :: Tb2Key -> Tb2Key Source # toEnum :: Int -> Tb2Key Source # fromEnum :: Tb2Key -> Int Source # enumFrom :: Tb2Key -> [Tb2Key] Source # enumFromThen :: Tb2Key -> Tb2Key -> [Tb2Key] Source # enumFromTo :: Tb2Key -> Tb2Key -> [Tb2Key] Source # enumFromThenTo :: Tb2Key -> Tb2Key -> Tb2Key -> [Tb2Key] Source # | |
Num Tb2Key Source # | |
Integral Tb2Key Source # | |
Defined in Termbox2 | |
Real Tb2Key Source # | |
Show Tb2Key Source # | |
Eq Tb2Key Source # | |
Ord Tb2Key Source # | |
Defined in Termbox2 |
keyCtrlTab :: Tb2Key Source #
keyCtrlEsc :: Tb2Key Source #
keyArrowUp :: Tb2Key Source #
keyBackTab :: Tb2Key Source #
Modifiers
Instances
Caps
Instances
Enum Tb2Cap Source # | |
Defined in Termbox2 succ :: Tb2Cap -> Tb2Cap Source # pred :: Tb2Cap -> Tb2Cap Source # toEnum :: Int -> Tb2Cap Source # fromEnum :: Tb2Cap -> Int Source # enumFrom :: Tb2Cap -> [Tb2Cap] Source # enumFromThen :: Tb2Cap -> Tb2Cap -> [Tb2Cap] Source # enumFromTo :: Tb2Cap -> Tb2Cap -> [Tb2Cap] Source # enumFromThenTo :: Tb2Cap -> Tb2Cap -> Tb2Cap -> [Tb2Cap] Source # | |
Num Tb2Cap Source # | |
Integral Tb2Cap Source # | |
Defined in Termbox2 | |
Real Tb2Cap Source # | |
Show Tb2Cap Source # | |
Eq Tb2Cap Source # | |
Ord Tb2Cap Source # | |
Defined in Termbox2 |
capArrowUp :: Tb2Cap Source #
capBackTab :: Tb2Cap Source #
capEnterCA :: Tb2Cap Source #
capReverse :: Tb2Cap Source #
Event types
newtype Tb2EventType Source #
Instances
Colors & Attributes
newtype Tb2ColorAttr Source #