vty-5.4.0: A simple terminal UI library

Safe Haskell | None
Language | Haskell2010

Graphics.Vty.Config

Description

A `Config` can be provided to mkVty to customize the applications use of vty. A config file can be used to customize vty for a user's system.

The `Config` provided is mappend'd to `Config`s loaded from ``getAppUserDataDirectory`/config` and `$VTY_CONFIG_FILE`. The `$VTY_CONFIG_FILE` takes precedence over the `config` file or the application provided `Config`.

Lines in config files that fail to parse are ignored. Later entries take precedence over earlier.

For all directives:

     string := "\"" chars+ "\""

# Debug

## `debugLog`

Format:

     "debugLog" string

The value of the environment variable `VTY_DEBUG_LOG` is equivalent to a debugLog entry at the end of the last config file.

# Input Processing

## `map`

Format:

     "map" term string key modifier_list
     where
         key := KEsc | KChar Char | KBS ... (same as Key)
         modifier_list := "[" modifier+ "]"
         modifier := MShift | MCtrl | MMeta | MAlt
         term := "_" | string

EG: If the contents are

     map _       "\ESC[B"    KUp   []
     map _       "\ESC[1;3B" KDown [MAlt]
     map "xterm" "\ESC[D"    KLeft []

Then the bytes `"\ESC[B"` will result in the KUp event on all terminals. The bytes `"\ESC[1;3B"` will result in the event KDown with the MAlt modifier on all terminals. The bytes `"\ESC[D"` will result in the KLeft event when `TERM` is `xterm`.

If a debug log is requested then vty will output the current input table to the log in the above format.

Set VTY_DEBUG_LOG. Run vty. Check debug log for incorrect mappings. Add corrected mappings to .vty/config

Synopsis

- type InputMap = [(Maybe String, String, Event)]
- data Config = Config {
  - vmin :: Maybe Int
  - vtime :: Maybe Int
  - debugLog :: Maybe FilePath
  - inputMap :: InputMap
  - inputFd :: Maybe Fd
  - outputFd :: Maybe Fd
  - termName :: Maybe String
  }
- type ConfigParser s a = ParsecT s () (Writer Config) a
- userConfig :: IO Config
- overrideEnvConfig :: IO Config
- standardIOConfig :: IO Config
- parseConfigFile :: FilePath -> IO Config
- runParseConfig :: Stream s (Writer Config) Char => String -> s -> Config
- configLanguage :: Stream s m Char => GenLanguageDef s u m
- configLexer :: Stream s m Char => GenTokenParser s u m
- mapDecl :: forall s u m. (Monad m, Stream s (WriterT Config m) Char) => ParsecT s u (WriterT Config m) ()
- parseKey :: forall s u m. Stream s m Char => ParsecT s u m Key
- parseModifiers :: forall s u m. Stream s m Char => ParsecT s u m [Modifier]
- parseModifier :: forall s u m. Stream s m Char => ParsecT s u m Modifier
- debugLogDecl :: forall s u m. (Monad m, Stream s (WriterT Config m) Char) => ParsecT s u (WriterT Config m) ()
- ignoreLine :: forall s u m. Stream s m Char => ParsecT s u m ()
- parseConfig :: forall s u m. (Monad m, Stream s (WriterT Config m) Char) => ParsecT s u (WriterT Config m) ()

# Documentation

type InputMap = [(Maybe String, String, Event)] Source

Mappings from input bytes to event in the order specified. Later entries take precedence over earlier in the case multiple entries have the same byte string.

data Config Source

Constructors

Config |

Fields

vmin :: Maybe Int

  The default is 1 character.

vtime :: Maybe Int

  The default is 100 milliseconds, 0.1 seconds.

debugLog :: Maybe FilePath

  Debug information is appended to this file if not Nothing.

inputMap :: InputMap

  The (input byte, output event) pairs extend the internal input table of VTY and the table from terminfo.

  See Graphics.Vty.Config module documentation for documentation of the `map` directive.

inputFd :: Maybe Fd

  The input file descriptor to use. The default is `stdInput`

outputFd :: Maybe Fd

  The output file descriptor to use. The default is `stdOutput`

termName :: Maybe String

  The terminal name used to look up terminfo capabilities. The default is the value of the TERM environment variable.

Instances

Eq Config Source |
Show Config Source |
Monoid Config Source |
Default Config Source |

type ConfigParser s a = ParsecT s () (Writer Config) a Source

userConfig :: IO Config Source

Config from ``getAppUserDataDirectory`/config` and `$VTY_CONFIG_FILE`

overrideEnvConfig :: IO Config Source

standardIOConfig :: IO Config Source

parseConfigFile :: FilePath -> IO Config Source

runParseConfig :: Stream s (Writer Config) Char => String -> s -> Config Source

configLanguage :: Stream s m Char => GenLanguageDef s u m Source

configLexer :: Stream s m Char => GenTokenParser s u m Source

mapDecl :: forall s u m. (Monad m, Stream s (WriterT Config m) Char) => ParsecT s u (WriterT Config m) () Source

parseKey :: forall s u m. Stream s m Char => ParsecT s u m Key Source

parseModifiers :: forall s u m. Stream s m Char => ParsecT s u m [Modifier] Source

parseModifier :: forall s u m. Stream s m Char => ParsecT s u m Modifier Source

debugLogDecl :: forall s u m. (Monad m, Stream s (WriterT Config m) Char) => ParsecT s u (WriterT Config m) () Source

ignoreLine :: forall s u m. Stream s m Char => ParsecT s u m () Source

parseConfig :: forall s u m. (Monad m, Stream s (WriterT Config m) Char) => ParsecT s u (WriterT Config m) () Source