hscurses-1.4.1.2: NCurses bindings for Haskell

Safe Haskell | None

UI.HSCurses.CursesHelper

Contents

- UI initialisation
- Input
- Drawing
- Navigation
- Colors
- Attributes
- Style
- Keys
- Helpers

Synopsis

- start :: IO ()
- end :: IO ()
- suspend :: IO ()
- resizeui :: IO (Int, Int)
- getKey :: MonadIO m => m () -> m Key
- drawLine :: Int -> String -> IO ()
- drawCursor :: (Int, Int) -> (Int, Int) -> IO ()
- gotoTop :: IO ()
- data ForegroundColor
  - = BlackF
  - | GreyF
  - | DarkRedF
  - | RedF
  - | DarkGreenF
  - | GreenF
  - | BrownF
  - | YellowF
  - | DarkBlueF
  - | BlueF
  - | PurpleF
  - | MagentaF
  - | DarkCyanF
  - | CyanF
  - | WhiteF
  - | BrightWhiteF
  - | DefaultF
- data BackgroundColor
  - = BlackB
  - | DarkRedB
  - | DarkGreenB
  - | BrownB
  - | DarkBlueB
  - | PurpleB
  - | DarkCyanB
  - | WhiteB
  - | DefaultB
- defaultColor :: Color
- black :: Color
- red :: Color
- green :: Color
- yellow :: Color
- blue :: Color
- magenta :: Color
- cyan :: Color
- white :: Color
- data Attribute
  - = Bold
  - | Underline
  - | Dim
  - | Reverse
  - | Blink
- convertAttributes :: [Attribute] -> Attr
- data Style
  - = Style ForegroundColor BackgroundColor
  - | AttributeStyle [Attribute] ForegroundColor BackgroundColor
  - | ColorlessStyle [Attribute]
- data CursesStyle
- mkCursesStyle :: [Attribute] -> CursesStyle
- changeCursesStyle :: CursesStyle -> [Attribute] -> CursesStyle
- setStyle :: CursesStyle -> IO ()
- wSetStyle :: Window -> CursesStyle -> IO ()
- resetStyle :: IO ()
- wResetStyle :: Window -> IO ()
- convertStyles :: [Style] -> IO [CursesStyle]
- defaultStyle :: Style
- defaultCursesStyle :: CursesStyle
- withStyle :: MonadExcIO m => CursesStyle -> m a -> m a
- wWithStyle :: MonadExcIO m => Window -> CursesStyle -> m a -> m a
- displayKey :: Key -> String
- withCursor :: MonadExcIO m => CursorVisibility -> m a -> m a
- withProgram :: MonadExcIO m => m a -> m a

# UI initialisation

start :: IO ()Source

`start` initializes the UI and grabs the keyboard.

This function installs a handler for the SIGWINCH signal which writes the KEY_RESIZE key to the input queue (if KEY_RESIZE and and SIGWINCH are both available).

end :: IO ()Source

Clean up and go home.

suspend :: IO ()Source

Suspend the program.

resizeui :: IO (Int, Int)Source

Resize the window From Writing Programs with NCURSES, by Eric S. Raymond and Zeyd M. Ben-Halim

# Input

getKey :: MonadIO m => m () -> m Key Source

`getKey refresh` reads a key.

The `refresh` function is used to redraw the screen when the terminal size changes (see the documentatio of `start` for a discussion of the problem).

# Drawing

drawLine :: Int -> String -> IO ()Source

`drawLine n s` draws `n` characters of string `s`.

drawCursor :: (Int, Int) -> (Int, Int) -> IO ()Source

Draw the cursor at the given position.

# Navigation

gotoTop :: IO ()Source

Move cursor to origin of stdScr.

# Colors

data ForegroundColor Source

Foreground colors.

Constructors

BlackF |
GreyF |
DarkRedF |
RedF |
DarkGreenF |
GreenF |
BrownF |
YellowF |
DarkBlueF |
BlueF |
PurpleF |
MagentaF |
DarkCyanF |
CyanF |
WhiteF |
BrightWhiteF |
DefaultF |

Instances

Eq ForegroundColor |
Show ForegroundColor |

data BackgroundColor Source

Background colors.

Constructors

BlackB |
DarkRedB |
DarkGreenB |
BrownB |
DarkBlueB |
PurpleB |
DarkCyanB |
WhiteB |
DefaultB |

Instances

Eq BackgroundColor |
Show BackgroundColor |

defaultColor :: Color Source

Basic colors.

black :: Color Source

red :: Color Source

green :: Color Source

yellow :: Color Source

blue :: Color Source

magenta :: Color Source

cyan :: Color Source

white :: Color Source

# Attributes

data Attribute Source

Abstractions for some commonly used attributes.

Constructors

Bold |
Underline |
Dim |
Reverse |
Blink |

Instances

Eq Attribute |
Show Attribute |

convertAttributes :: [Attribute] -> Attr Source

Converts an abstract attribute list into its curses representation.

# Style

data Style Source

A humand-readable style.

Constructors

Style ForegroundColor BackgroundColor |
AttributeStyle [Attribute] ForegroundColor BackgroundColor |
ColorlessStyle [Attribute] |

Instances

Eq Style |
Show Style |

data CursesStyle Source

A style which uses the internal curses representations for attributes and colors.

Instances

Eq CursesStyle |
Show CursesStyle |

mkCursesStyle :: [Attribute] -> CursesStyle Source

changeCursesStyle :: CursesStyle -> [Attribute] -> CursesStyle Source

Changes the attributes of the given CursesStyle.

setStyle :: CursesStyle -> IO ()Source

Manipulate the current style of the standard screen

wSetStyle :: Window -> CursesStyle -> IO ()Source

resetStyle :: IO ()Source

Reset the screen to normal values

wResetStyle :: Window -> IO ()Source

convertStyles :: [Style] -> IO [CursesStyle]Source

Converts a list of human-readable styles into the corresponding curses representation.

This function should be called exactly once at application startup for all styles of the application.

defaultStyle :: Style Source

defaultCursesStyle :: CursesStyle Source

withStyle :: MonadExcIO m => CursesStyle -> m a -> m aSource

wWithStyle :: MonadExcIO m => Window -> CursesStyle -> m a -> m aSource

# Keys

displayKey :: Key -> String Source

Converting keys to humand-readable strings

# Helpers

withCursor :: MonadExcIO m => CursorVisibility -> m a -> m aSource

Other helpers

set the cursor, and do action

withProgram :: MonadExcIO m => m a -> m aSource