termbox2-hs-0.4.0.0: Bindings to termbox2
LicenseAGPL-3-or-later
Maintainergatlin@niltag.net
Stabilityexperimental
PortabilityPOSIX
Safe HaskellSafe-Inferred
LanguageGHC2021

Termbox2

Description

Bindings to the C-language termbox2 console UI library.

Synopsis

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.

initFd :: Integral n => n -> Termbox2 () Source #

initRwFd :: (Integral n, Integral o) => n -> o -> Termbox2 () Source #

shutdown :: Termbox2 () Source #

Call this when you're finished or your terminal will act funky after exit!

width :: Integral n => Termbox2 n Source #

Width of the drawing space in characters.

height :: Integral n => Termbox2 n Source #

Height of the drawing space in lines.

present :: Termbox2 () Source #

Draws the buffer to the screen.

clear :: Termbox2 () Source #

Clears the screen.

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.

setCell Source #

Arguments

:: 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

data Tb2Event Source #

Incoming event from the tty.

Constructors

Tb2Event 

Fields

Constants

Errors

newtype Tb2Err Source #

Constructors

Tb2Err CInt 

Instances

Instances details
Enum Tb2Err Source # 
Instance details

Defined in Termbox2

Num Tb2Err Source # 
Instance details

Defined in Termbox2

Integral Tb2Err Source # 
Instance details

Defined in Termbox2

Real Tb2Err Source # 
Instance details

Defined in Termbox2

Show Tb2Err Source # 
Instance details

Defined in Termbox2

Eq Tb2Err Source # 
Instance details

Defined in Termbox2

Ord Tb2Err Source # 
Instance details

Defined in Termbox2

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

newtype Tb2Key Source #

Constructors

Tb2Key Word16 

Instances

Instances details
Storable Tb2Key Source # 
Instance details

Defined in Termbox2

Enum Tb2Key Source # 
Instance details

Defined in Termbox2

Num Tb2Key Source # 
Instance details

Defined in Termbox2

Integral Tb2Key Source # 
Instance details

Defined in Termbox2

Real Tb2Key Source # 
Instance details

Defined in Termbox2

Show Tb2Key Source # 
Instance details

Defined in Termbox2

Eq Tb2Key Source # 
Instance details

Defined in Termbox2

Ord Tb2Key Source # 
Instance details

Defined in Termbox2

Modifiers

newtype Tb2Mod Source #

Constructors

Tb2Mod Word8 

Instances

Instances details
Storable Tb2Mod Source # 
Instance details

Defined in Termbox2

Semigroup Tb2Mod Source # 
Instance details

Defined in Termbox2

Bits Tb2Mod Source # 
Instance details

Defined in Termbox2

Enum Tb2Mod Source # 
Instance details

Defined in Termbox2

Num Tb2Mod Source # 
Instance details

Defined in Termbox2

Integral Tb2Mod Source # 
Instance details

Defined in Termbox2

Real Tb2Mod Source # 
Instance details

Defined in Termbox2

Show Tb2Mod Source # 
Instance details

Defined in Termbox2

Eq Tb2Mod Source # 
Instance details

Defined in Termbox2

Ord Tb2Mod Source # 
Instance details

Defined in Termbox2

Caps

newtype Tb2Cap Source #

Constructors

Tb2Cap CInt 

Instances

Instances details
Enum Tb2Cap Source # 
Instance details

Defined in Termbox2

Num Tb2Cap Source # 
Instance details

Defined in Termbox2

Integral Tb2Cap Source # 
Instance details

Defined in Termbox2

Real Tb2Cap Source # 
Instance details

Defined in Termbox2

Show Tb2Cap Source # 
Instance details

Defined in Termbox2

Eq Tb2Cap Source # 
Instance details

Defined in Termbox2

Ord Tb2Cap Source # 
Instance details

Defined in Termbox2

Event types

newtype Tb2EventType Source #

Constructors

Tb2EventType Word8 

Instances

Instances details
Storable Tb2EventType Source # 
Instance details

Defined in Termbox2

Enum Tb2EventType Source # 
Instance details

Defined in Termbox2

Num Tb2EventType Source # 
Instance details

Defined in Termbox2

Integral Tb2EventType Source # 
Instance details

Defined in Termbox2

Real Tb2EventType Source # 
Instance details

Defined in Termbox2

Show Tb2EventType Source # 
Instance details

Defined in Termbox2

Eq Tb2EventType Source # 
Instance details

Defined in Termbox2

Ord Tb2EventType Source # 
Instance details

Defined in Termbox2

Colors & Attributes

newtype Tb2ColorAttr Source #

Constructors

Tb2ColorAttr CInt 

Instances

Instances details
Semigroup Tb2ColorAttr Source # 
Instance details

Defined in Termbox2

Bits Tb2ColorAttr Source # 
Instance details

Defined in Termbox2

Enum Tb2ColorAttr Source # 
Instance details

Defined in Termbox2

Num Tb2ColorAttr Source # 
Instance details

Defined in Termbox2

Integral Tb2ColorAttr Source # 
Instance details

Defined in Termbox2

Real Tb2ColorAttr Source # 
Instance details

Defined in Termbox2

Show Tb2ColorAttr Source # 
Instance details

Defined in Termbox2

Eq Tb2ColorAttr Source # 
Instance details

Defined in Termbox2

Ord Tb2ColorAttr Source # 
Instance details

Defined in Termbox2

Input modes

newtype Tb2Input Source #

Constructors

Tb2Input CInt 

Instances

Instances details
Semigroup Tb2Input Source # 
Instance details

Defined in Termbox2

Bits Tb2Input Source # 
Instance details

Defined in Termbox2

Enum Tb2Input Source # 
Instance details

Defined in Termbox2

Num Tb2Input Source # 
Instance details

Defined in Termbox2

Integral Tb2Input Source # 
Instance details

Defined in Termbox2

Real Tb2Input Source # 
Instance details

Defined in Termbox2

Show Tb2Input Source # 
Instance details

Defined in Termbox2

Eq Tb2Input Source # 
Instance details

Defined in Termbox2

Ord Tb2Input Source # 
Instance details

Defined in Termbox2

Output modes

newtype Tb2Output Source #

Constructors

Tb2Output CInt 

Instances

Instances details
Semigroup Tb2Output Source # 
Instance details

Defined in Termbox2

Bits Tb2Output Source # 
Instance details

Defined in Termbox2

Enum Tb2Output Source # 
Instance details

Defined in Termbox2

Num Tb2Output Source # 
Instance details

Defined in Termbox2

Integral Tb2Output Source # 
Instance details

Defined in Termbox2

Real Tb2Output Source # 
Instance details

Defined in Termbox2

Show Tb2Output Source # 
Instance details

Defined in Termbox2

Eq Tb2Output Source # 
Instance details

Defined in Termbox2

Ord Tb2Output Source # 
Instance details

Defined in Termbox2