termbox-banana-0.1.0: reactive-banana + termbox

Safe HaskellNone
LanguageHaskell2010

Termbox.Banana

Contents

Synopsis

Documentation

This module is intended to be imported qualified.

import qualified Termbox.Banana as Termbox

type TermboxEvent = Event Source #

A termbox event. This type alias exists only for Haddock readability; in code, you are encouraged to use

  • Event for reactive-banana events
  • Termbox.Event for termbox events

Since: termbox-banana-0.1.0

main Source #

Arguments

:: (width ~ Int, height ~ Int) 
=> InputMode 
-> OutputMode 
-> (Event TermboxEvent -> Behavior (width, height) -> MomentIO (Behavior Scene, Event a)) 
-> IO a 

Run a termbox program with the specified input and output modes.

Given

  • the terminal event stream and
  • the time-varying terminal size,

return a time-varying

  • scene to render, and
  • a event stream of arbitrary values, only the first of which is relevant, which ends the termbox program and returns from the main action.

Since: termbox-banana-0.1.0

data Scene Source #

A scene to render; a grid of cells and a cursor.

Since: termbox-banana-0.1.0

Constructors

Scene !Cells !Cursor 

data Cells Source #

A grid of cells. Create a Cells with set or mempty and combine them with (<>).

Since: termbox-banana-0.1.0

Instances
Semigroup Cells Source # 
Instance details

Defined in Termbox.Banana

Methods

(<>) :: Cells -> Cells -> Cells #

sconcat :: NonEmpty Cells -> Cells #

stimes :: Integral b => b -> Cells -> Cells #

Monoid Cells Source # 
Instance details

Defined in Termbox.Banana

Methods

mempty :: Cells #

mappend :: Cells -> Cells -> Cells #

mconcat :: [Cells] -> Cells #

set :: (col ~ Int, row ~ Int) => col -> row -> Cell -> Cells Source #

Set a single cell's value.

Since: termbox-banana-0.1.0

data Cursor Source #

A cursor.

Since: termbox-banana-0.1.0

Constructors

Cursor !Int !Int

Column, then row

NoCursor 

Re-exports

black :: Attr #

black = 1.

red :: Attr #

red = 2.

green :: Attr #

green = 3.

yellow :: Attr #

yellow = 4.

blue :: Attr #

blue = 5.

magenta :: Attr #

magenta = 6.

cyan :: Attr #

cyan = 7.

white :: Attr #

white = 8.

bold :: Attr #

Bold modifier attribute.

underline :: Attr #

Underline modifier attribute.

reverse :: Attr #

Reverse modifier attribute.

data Attr #

A cell attribute, which includes its color, and whether or not it is bold, underlined, and/or reversed.

A cell can only have one color, but may be (for example) bold and underlined. The Monoid instance combines Attrs this way, with a left bias. That is,

red <> bold <> black <> underline = red <> bold <> underline

Warning: the Num instance is very partial! It only includes an implementation of fromInteger, for numeric literals.

Instances
Eq Attr 
Instance details

Defined in Termbox

Methods

(==) :: Attr -> Attr -> Bool #

(/=) :: Attr -> Attr -> Bool #

Num Attr

Only fromInteger is defined.

Instance details

Defined in Termbox

Methods

(+) :: Attr -> Attr -> Attr #

(-) :: Attr -> Attr -> Attr #

(*) :: Attr -> Attr -> Attr #

negate :: Attr -> Attr #

abs :: Attr -> Attr #

signum :: Attr -> Attr #

fromInteger :: Integer -> Attr #

Semigroup Attr

Left-biased color; attributes are merged.

Instance details

Defined in Termbox

Methods

(<>) :: Attr -> Attr -> Attr #

sconcat :: NonEmpty Attr -> Attr #

stimes :: Integral b => b -> Attr -> Attr #

Monoid Attr 
Instance details

Defined in Termbox

Methods

mempty :: Attr #

mappend :: Attr -> Attr -> Attr #

mconcat :: [Attr] -> Attr #

data Cell #

A Cell contains a character, foreground attribute, and background attribute.

Constructors

Cell !Char !Attr !Attr 
Instances
Eq Cell 
Instance details

Defined in Termbox

Methods

(==) :: Cell -> Cell -> Bool #

(/=) :: Cell -> Cell -> Bool #

Show Cell 
Instance details

Defined in Termbox

Methods

showsPrec :: Int -> Cell -> ShowS #

show :: Cell -> String #

showList :: [Cell] -> ShowS #

Storable Cell 
Instance details

Defined in Termbox

Methods

sizeOf :: Cell -> Int #

alignment :: Cell -> Int #

peekElemOff :: Ptr Cell -> Int -> IO Cell #

pokeElemOff :: Ptr Cell -> Int -> Cell -> IO () #

peekByteOff :: Ptr b -> Int -> IO Cell #

pokeByteOff :: Ptr b -> Int -> Cell -> IO () #

peek :: Ptr Cell -> IO Cell #

poke :: Ptr Cell -> Cell -> IO () #

data Event #

A input event.

Constructors

EventKey !Key !Bool

Key event. The bool indicates the alt modifier.

EventResize !Int !Int

Resize event (width, then height)

EventMouse !Mouse !Int !Int

Mouse event (column, then row)

Instances
Eq Event 
Instance details

Defined in Termbox

Methods

(==) :: Event -> Event -> Bool #

(/=) :: Event -> Event -> Bool #

Show Event 
Instance details

Defined in Termbox

Methods

showsPrec :: Int -> Event -> ShowS #

show :: Event -> String #

showList :: [Event] -> ShowS #

data InitError #

Initialization errors that can be thrown by main.

Instances
Show InitError 
Instance details

Defined in Termbox

Exception InitError 
Instance details

Defined in Termbox

data InputMode #

The input modes.

  • Esc. When ESC sequence is in the buffer and it doesn't match any known sequence, ESC means KeyEsc.
  • Alt. When ESC sequence is in the buffer and it doesn't match any known sequence, ESC enables the alt modifier for the next keyboard event.
Instances
Eq InputMode 
Instance details

Defined in Termbox

Ord InputMode 
Instance details

Defined in Termbox

Show InputMode 
Instance details

Defined in Termbox

data Mouse #

A mouse event.

Instances
Eq Mouse 
Instance details

Defined in Termbox

Methods

(==) :: Mouse -> Mouse -> Bool #

(/=) :: Mouse -> Mouse -> Bool #

Ord Mouse 
Instance details

Defined in Termbox

Methods

compare :: Mouse -> Mouse -> Ordering #

(<) :: Mouse -> Mouse -> Bool #

(<=) :: Mouse -> Mouse -> Bool #

(>) :: Mouse -> Mouse -> Bool #

(>=) :: Mouse -> Mouse -> Bool #

max :: Mouse -> Mouse -> Mouse #

min :: Mouse -> Mouse -> Mouse #

Show Mouse 
Instance details

Defined in Termbox

Methods

showsPrec :: Int -> Mouse -> ShowS #

show :: Mouse -> String #

showList :: [Mouse] -> ShowS #

data MouseMode #

The mouse mode.

  • No. Don't handle mouse events.
  • Yes. Handle mouse events.

Constructors

MouseModeNo

Default.

MouseModeYes 
Instances
Eq MouseMode 
Instance details

Defined in Termbox

Ord MouseMode 
Instance details

Defined in Termbox

Show MouseMode 
Instance details

Defined in Termbox

data OutputMode #

The output modes.

  • Normal. Supports colors 0..8, which includes all named color attributes exported by this library, e.g. red.
  • Grayscale. Supports colors 0..23.
  • 216. Supports colors 0..216.
  • 256. Supports colors 0..255.
Instances
Eq OutputMode 
Instance details

Defined in Termbox

Ord OutputMode 
Instance details

Defined in Termbox

Show OutputMode 
Instance details

Defined in Termbox