Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
- Basic data types
- Cursor movement by character
- Cursor movement by line
- Directly changing cursor position
- Saving, restoring and reporting cursor position
- Clearing parts of the screen
- Scrolling the screen
- Select Graphic Rendition mode: colors and other whizzy stuff
- Cursor visibilty changes
- Hyperlinks
- Changing the title
- Utilities
This module exports functions that return String
values containing codes
in accordance with the 'ANSI' standards for control character sequences
described in the documentation of module System.Console.ANSI.
The module System.Console.ANSI exports functions with the same names as those in this module. On some versions of Windows, the terminal in use may not be ANSI-capable. When that is the case, the same-named functions exported by module System.Console.ANSI return "", for the reasons set out in the documentation of that module.
Consequently, if module System.Console.ANSI is also imported, this module is intended to be imported qualified, to avoid name clashes with those functions. For example:
import qualified System.Console.ANSI.Codes as ANSI
Synopsis
- module System.Console.ANSI.Types
- cursorUpCode :: Int -> String
- cursorDownCode :: Int -> String
- cursorForwardCode :: Int -> String
- cursorBackwardCode :: Int -> String
- cursorUpLineCode :: Int -> String
- cursorDownLineCode :: Int -> String
- setCursorColumnCode :: Int -> String
- setCursorPositionCode :: Int -> Int -> String
- saveCursorCode :: String
- restoreCursorCode :: String
- reportCursorPositionCode :: String
- clearFromCursorToScreenEndCode :: String
- clearFromCursorToScreenBeginningCode :: String
- clearScreenCode :: String
- clearFromCursorToLineEndCode :: String
- clearFromCursorToLineBeginningCode :: String
- clearLineCode :: String
- scrollPageUpCode :: Int -> String
- scrollPageDownCode :: Int -> String
- setSGRCode :: [SGR] -> String
- hideCursorCode :: String
- showCursorCode :: String
- hyperlinkCode :: String -> String -> String
- hyperlinkWithIdCode :: String -> String -> String -> String
- hyperlinkWithParamsCode :: [(String, String)] -> String -> String -> String
- setTitleCode :: String -> String
- colorToCode :: Color -> Int
- csi :: [Int] -> String -> String
- sgrToCode :: SGR -> [Int]
Basic data types
module System.Console.ANSI.Types
Cursor movement by character
Cursor movement by line
Directly changing cursor position
Code to move the cursor to the specified column. The column numbering is 0-based (that is, the left-most column is numbered 0).
setCursorPositionCode Source #
Code to move the cursor to the specified position (row and column). The position is 0-based (that is, the top-left corner is at row 0 column 0).
Saving, restoring and reporting cursor position
saveCursorCode :: String Source #
Since: 0.7.1
restoreCursorCode :: String Source #
Since: 0.7.1
reportCursorPositionCode :: String Source #
Code to emit the cursor position into the console input stream, immediately
after being recognised on the output stream, as:
ESC [ <cursor row> ; <cursor column> R
Note that the information that is emitted is 1-based (the top-left corner is
at row 1 column 1) but setCursorPositionCode
is 0-based.
In isolation of getReportedCursorPosition
or getCursorPosition
, this
function may be of limited use on Windows operating systems because of
difficulties in obtaining the data emitted into the console input stream.
The function hGetBufNonBlocking
in module System.IO does not work on
Windows. This has been attributed to the lack of non-blocking primatives in
the operating system (see the GHC bug report #806 at
https://ghc.haskell.org/trac/ghc/ticket/806).
Since: 0.7.1
Clearing parts of the screen
Scrolling the screen
Select Graphic Rendition mode: colors and other whizzy stuff
Cursor visibilty changes
Hyperlinks
Some, but not all, terminals support hyperlinks - that is, clickable text that points to a URI.
Code to introduce a hyperlink.
Since: 0.11.3
Code to introduce a hyperlink with an identifier for the link. Some terminals support an identifier, so that hyperlinks with the same identifier are treated as connected.
Since: 0.11.3
hyperlinkWithParamsCode Source #
Code to introduce a hyperlink with (key, value) parameters. Some terminals
support an id
parameter key, so that hyperlinks with the same id
value
are treated as connected.
Since: 0.11.3
Changing the title
Code to set the terminal window title and the icon name (that is, the text for the window in the Start bar, or similar).
Utilities
colorToCode :: Color -> Int Source #
colorToCode
color
returns the 0-based index of the color (one of the
eight colors in the ANSI standard).