terminfo-0.4.0.2: Haskell bindings to the terminfo library.

Maintainer judah.jacobson@gmail.com experimental portable (FFI) Trustworthy Haskell2010

System.Console.Terminfo.Base

Description

This module provides a low-level interface to the C functions of the terminfo library.

NOTE: Since this library is built on top of the curses interface, it is not thread-safe.

Synopsis

# Initialization

Initialize the terminfo library to the given terminal entry.

Throws a SetupTermError if the terminfo database could not be read.

Initialize the terminfo library, using the TERM environmental variable. If TERM is not set, we use the generic, minimal entry dumb.

Throws a SetupTermError if the terminfo database could not be read.

Instances

 # Methods # Methods

# Capabilities

data Capability a Source #

A feature or operation which a Terminal may define.

Instances

 # Methods(>>=) :: Capability a -> (a -> Capability b) -> Capability b Source #(>>) :: Capability a -> Capability b -> Capability b Source #return :: a -> Capability a Source # # Methodsfmap :: (a -> b) -> Capability a -> Capability b Source #(<$) :: a -> Capability b -> Capability a Source # # Methodspure :: a -> Capability a Source #(<*>) :: Capability (a -> b) -> Capability a -> Capability b Source #(*>) :: Capability a -> Capability b -> Capability b Source #(<*) :: Capability a -> Capability b -> Capability a Source # # Methods(<|>) :: Capability a -> Capability a -> Capability a Source #some :: Capability a -> Capability [a] Source #many :: Capability a -> Capability [a] Source # # Methodsmplus :: Capability a -> Capability a -> Capability a Source # Look up a boolean capability in the terminfo database. Unlike tiGuardFlag, this capability never fails; it returns False if the capability is absent or set to false, and returns True otherwise. Look up a boolean capability in the terminfo database, and fail if it's not defined. Look up a numeric capability in the terminfo database. Deprecated: use tiGetOutput instead. Look up a string capability in the terminfo database. NOTE: This function is deprecated; use tiGetOutput1 instead. # Output Terminfo contains many string capabilities for special effects. For example, the cuu1 capability moves the cursor up one line; on ANSI terminals this is accomplished by printing the control sequence "\ESC[A". However, some older terminals also require "padding", or short pauses, after certain commands. For example, when TERM=vt100 the cuu1 capability is "\ESC[A$<2>", which instructs terminfo to pause for two milliseconds after outputting the control sequence.

The TermOutput monoid abstracts away all padding and control sequence output. Unfortunately, that datatype is difficult to integrate into existing String-based APIs such as pretty-printers. Thus, as a workaround, tiGetOutput1 also lets us access the control sequences as Strings. The one caveat is that it will not allow you to access padded control sequences as Strings. For example:

> t <- setupTerm "vt100"
> isJust (getCapability t (tiGetOutput1 "cuu1") :: Maybe String)
False
> isJust (getCapability t (tiGetOutput1 "cuu1") :: Maybe TermOutput)
True

String capabilities will work with software-based terminal types such as xterm and linux. However, you should use TermOutput if compatibility with older terminals is important. Additionally, the visualBell capability which flashes the screen usually produces its effect with a padding directive, so it will only work with TermOutput.

tiGetOutput1 :: forall f. OutputCap f => String -> Capability f Source #

Look up an output capability which takes a fixed number of parameters (for example, Int -> Int -> TermOutput).

For capabilities which may contain variable-length padding, use tiGetOutput instead.

class OutputCap f Source #

Minimal complete definition

Instances

 # MethodsoutputCap :: ([Int] -> String) -> [Int] -> TermOutput # MethodshasOkPadding :: [Char] -> String -> BooloutputCap :: ([Int] -> String) -> [Int] -> [Char] (Enum p, OutputCap f) => OutputCap (p -> f) # MethodshasOkPadding :: (p -> f) -> String -> BooloutputCap :: ([Int] -> String) -> [Int] -> p -> f

class (Monoid s, OutputCap s) => TermStr s Source #

Instances

 # #

## TermOutput

An action which sends output to the terminal. That output may mix plain text with control characters and escape sequences, along with delays (called "padding") required by some older terminals.

Instances

 # Methods # # MethodsoutputCap :: ([Int] -> String) -> [Int] -> TermOutput

Write the terminal output to the standard output device.

Write the terminal output to the terminal or file managed by the given Handle.

Look up an output capability in the terminfo database.

A parameter to specify the number of lines affected. Some capabilities (e.g., clear and dch1) use this parameter on some terminals to compute variable-length padding.

## Monoid functions

class Monoid a where Source #

The class of monoids (types with an associative binary operation that has an identity). Instances should satisfy the following laws:

• mappend mempty x = x
• mappend x mempty = x
• mappend x (mappend y z) = mappend (mappend x y) z
• mconcat = foldr mappend mempty

The method names refer to the monoid of lists under concatenation, but there are many other instances.

Some types can be viewed as a monoid in more than one way, e.g. both addition and multiplication on numbers. In such cases we often define newtypes and make those instances of Monoid, e.g. Sum and Product.

Minimal complete definition

Instances

 Methodsmconcat :: [Ordering] -> Ordering Source # Monoid () Methodsmempty :: () Source #mappend :: () -> () -> () Source #mconcat :: [()] -> () Source # Methodsmappend :: All -> All -> All Source #mconcat :: [All] -> All Source # Methodsmappend :: Any -> Any -> Any Source #mconcat :: [Any] -> Any Source # # Methods Monoid [a] Methodsmempty :: [a] Source #mappend :: [a] -> [a] -> [a] Source #mconcat :: [[a]] -> [a] Source # Monoid a => Monoid (Maybe a) Lift a semigroup into Maybe forming a Monoid according to http://en.wikipedia.org/wiki/Monoid: "Any semigroup S may be turned into a monoid simply by adjoining an element e not in S and defining e*e = e and e*s = s = s*e for all s ∈ S." Since there is no "Semigroup" typeclass providing just mappend, we use Monoid instead. Methodsmappend :: Maybe a -> Maybe a -> Maybe a Source #mconcat :: [Maybe a] -> Maybe a Source # Monoid a => Monoid (IO a) Methodsmappend :: IO a -> IO a -> IO a Source #mconcat :: [IO a] -> IO a Source # Ord a => Monoid (Max a) Methodsmempty :: Max a Source #mappend :: Max a -> Max a -> Max a Source #mconcat :: [Max a] -> Max a Source # Ord a => Monoid (Min a) Methodsmempty :: Min a Source #mappend :: Min a -> Min a -> Min a Source #mconcat :: [Min a] -> Min a Source # Monoid a => Monoid (Dual a) Methodsmappend :: Dual a -> Dual a -> Dual a Source #mconcat :: [Dual a] -> Dual a Source # Monoid (Endo a) Methodsmappend :: Endo a -> Endo a -> Endo a Source #mconcat :: [Endo a] -> Endo a Source # Num a => Monoid (Sum a) Methodsmappend :: Sum a -> Sum a -> Sum a Source #mconcat :: [Sum a] -> Sum a Source # Num a => Monoid (Product a) Methodsmappend :: Product a -> Product a -> Product a Source #mconcat :: [Product a] -> Product a Source # Monoid (First a) Methodsmappend :: First a -> First a -> First a Source #mconcat :: [First a] -> First a Source # Monoid (Last a) Methodsmappend :: Last a -> Last a -> Last a Source #mconcat :: [Last a] -> Last a Source # Monoid b => Monoid (a -> b) Methodsmempty :: a -> b Source #mappend :: (a -> b) -> (a -> b) -> a -> b Source #mconcat :: [a -> b] -> a -> b Source # (Monoid a, Monoid b) => Monoid (a, b) Methodsmempty :: (a, b) Source #mappend :: (a, b) -> (a, b) -> (a, b) Source #mconcat :: [(a, b)] -> (a, b) Source # Monoid (Proxy k s) Methodsmempty :: Proxy k s Source #mappend :: Proxy k s -> Proxy k s -> Proxy k s Source #mconcat :: [Proxy k s] -> Proxy k s Source # (Monoid a, Monoid b, Monoid c) => Monoid (a, b, c) Methodsmempty :: (a, b, c) Source #mappend :: (a, b, c) -> (a, b, c) -> (a, b, c) Source #mconcat :: [(a, b, c)] -> (a, b, c) Source # Monoid a => Monoid (Const k a b) Methodsmempty :: Const k a b Source #mappend :: Const k a b -> Const k a b -> Const k a b Source #mconcat :: [Const k a b] -> Const k a b Source # Alternative f => Monoid (Alt * f a) Methodsmempty :: Alt * f a Source #mappend :: Alt * f a -> Alt * f a -> Alt * f a Source #mconcat :: [Alt * f a] -> Alt * f a Source # (Monoid a, Monoid b, Monoid c, Monoid d) => Monoid (a, b, c, d) Methodsmempty :: (a, b, c, d) Source #mappend :: (a, b, c, d) -> (a, b, c, d) -> (a, b, c, d) Source #mconcat :: [(a, b, c, d)] -> (a, b, c, d) Source # (Monoid a, Monoid b, Monoid c, Monoid d, Monoid e) => Monoid (a, b, c, d, e) Methodsmempty :: (a, b, c, d, e) Source #mappend :: (a, b, c, d, e) -> (a, b, c, d, e) -> (a, b, c, d, e) Source #mconcat :: [(a, b, c, d, e)] -> (a, b, c, d, e) Source #

(<#>) :: Monoid m => m -> m -> m infixl 2 Source #

An operator version of mappend.