basement-0.0.16: Foundation scrap box of array & string

License | BSD-style
Maintainer | Vincent Hanquez <vincent@snarc.org>
Safe Haskell | None
Language | Haskell2010

Basement.Terminal.ANSI

Contents

- Types
- Simple ANSI escape factory functions

Description

ANSI Terminal escape for cursor and attributes manipulations

On Unix system, it should be supported by most terminal emulators.

On Windows system, all escape sequences are empty for maximum compatibility purpose, and easy implementation. newer version of Windows 10 supports ANSI escape now, but we'll need some kind of detection.

Synopsis

- type Escape = String
- type Displacement = Word64
- type ColorComponent = Zn64 8
- type GrayComponent = Zn64 24
- type RGBComponent = Zn64 6
- cursorUp :: Displacement -> Escape
- cursorDown :: Displacement -> Escape
- cursorForward :: Displacement -> Escape
- cursorBack :: Displacement -> Escape
- cursorNextLine :: Displacement -> Escape
- cursorPrevLine :: Displacement -> Escape
- cursorHorizontalAbsolute :: Displacement -> Escape
- cursorPosition :: Displacement -> Displacement -> Escape
- eraseScreenFromCursor :: Escape
- eraseScreenToCursor :: Escape
- eraseScreenAll :: Escape
- eraseLineFromCursor :: Escape
- eraseLineToCursor :: Escape
- eraseLineAll :: Escape
- scrollUp :: Displacement -> Escape
- scrollDown :: Displacement -> Escape
- sgrReset :: Escape
- sgrForeground :: ColorComponent -> Bool -> Escape
- sgrBackground :: ColorComponent -> Bool -> Escape
- sgrForegroundGray24 :: GrayComponent -> Escape
- sgrBackgroundGray24 :: GrayComponent -> Escape
- sgrForegroundColor216 :: RGBComponent -> RGBComponent -> RGBComponent -> Escape
- sgrBackgroundColor216 :: RGBComponent -> RGBComponent -> RGBComponent -> Escape

# Types

type Escape = String #

type Displacement = Word64 #

type ColorComponent = Zn64 8 #

Simple color component on 8 color terminal (maximum compatibility)

type GrayComponent = Zn64 24 #

Gray color compent on 256colors terminals

type RGBComponent = Zn64 6 #

Color compent on 256colors terminals

# Simple ANSI escape factory functions

cursorUp :: Displacement -> Escape #

cursorDown :: Displacement -> Escape #

cursorForward :: Displacement -> Escape #

cursorBack :: Displacement -> Escape #

cursorNextLine :: Displacement -> Escape #

cursorPrevLine :: Displacement -> Escape #

cursorHorizontalAbsolute :: Displacement -> Escape #

cursorPosition :: Displacement -> Displacement -> Escape #

eraseScreenFromCursor :: Escape #

eraseScreenToCursor :: Escape #

eraseScreenAll :: Escape #

eraseLineFromCursor :: Escape #

eraseLineToCursor :: Escape #

eraseLineAll :: Escape #

scrollUp :: Displacement -> Escape #

scrollDown :: Displacement -> Escape #

sgrReset :: Escape #

All attribute off

sgrForeground :: ColorComponent -> Bool -> Escape #

8 Colors + Bold attribute for foreground

sgrBackground :: ColorComponent -> Bool -> Escape #

8 Colors + Bold attribute for background

sgrForegroundGray24 :: GrayComponent -> Escape #

sgrBackgroundGray24 :: GrayComponent -> Escape #

sgrForegroundColor216 #

Arguments

:: RGBComponent | Red component
-> RGBComponent | Green component
-> RGBComponent | Blue component
-> Escape |

sgrBackgroundColor216 #

Arguments

:: RGBComponent | Red component
-> RGBComponent | Green component
-> RGBComponent | Blue component
-> Escape |