-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A simple terminal UI library -- -- vty is terminal GUI library in the niche of ncurses. It is intended to -- be easy to use and to provide good support for common terminal types. -- -- See the vty-examples package as well as the program -- examples/interactive_terminal_test.hs included in the -- vty repository for examples on how to use the library. -- -- Import the Graphics.Vty convenience module to get access to -- the core parts of the library. -- -- © 2006-2007 Stefan O'Rear; BSD3 license. -- -- © Corey O'Connor; BSD3 license. -- -- © Jonathan Daugherty; BSD3 license. @package vty @version 6.1 -- | This module provides functions to measure the terminal column width of -- characters and strings. -- -- The functions provided in this module all ultimately make calls to the -- C implementation in cbits/mk_wcwidth.c. That code manages -- some global state that carries a table of Unicode character widths. -- For more details, see Install, the C code, and the -- "Multi-Column Character Support" section of the project -- README. module Graphics.Text.Width wcwidth :: Char -> Int wcswidth :: String -> Int wctwidth :: Text -> Int wctlwidth :: Text -> Int -- | Returns the display width of a character. Assumes all characters with -- unknown widths are 0 width. safeWcwidth :: Char -> Int -- | Returns the display width of a string. Assumes all characters with -- unknown widths are 0 width. safeWcswidth :: String -> Int -- | Returns the display width of a text. Assumes all characters with -- unknown widths are 0 width. safeWctwidth :: Text -> Int -- | Returns the display width of a lazy text. Assumes all characters with -- unknown widths are 0 width. safeWctlwidth :: Text -> Int module Graphics.Vty.Attributes.Color240 -- | Create a value in the Color240 set from an RGB triple. This maps the -- input arguments to an entry in the 240-color palette depicted at: -- -- https://rich.readthedocs.io/en/stable/appendix/colors.html rgbColorToColor240 :: Integral i => i -> i -> i -> Word8 -- | Create a RGB triple from a value in the Color240 set. color240CodeToRGB :: Word8 -> Maybe (Int, Int, Int) module Graphics.Vty.Attributes.Color -- | Abstract data type representing a color. -- -- Currently the foreground and background color are specified as points -- in either a: -- -- -- -- The 8 ISO 6429 (ANSI) colors are as follows: -- -- -- -- The mapping from points in the 240 color palette to colors actually -- displayable by the terminal depends on the number of colors the -- terminal claims to support. Which is usually determined by the -- terminfo "colors" property. If this property is not being accurately -- reported then the color reproduction will be incorrect. -- -- If the terminal reports <= 16 colors then the 240 color palette -- points are only mapped to the 8 color palette. I'm not sure of the RGB -- points for the "bright" colors which is why they are not addressable -- via the 240 color palette. -- -- If the terminal reports > 16 colors then the 240 color palette -- points are mapped to the nearest points in a ("color count" - 16) -- subsampling of the 240 color palette. -- -- All of this assumes the terminals are behaving similarly to xterm and -- rxvt when handling colors. And that the individual colors have not -- been remapped by the user. There may be a way to verify this through -- terminfo but I don't know it. -- -- Seriously, terminal color support is INSANE. data Color ISOColor :: !Word8 -> Color Color240 :: !Word8 -> Color RGBColor :: !Word8 -> !Word8 -> !Word8 -> Color data ColorMode NoColor :: ColorMode ColorMode8 :: ColorMode ColorMode16 :: ColorMode ColorMode240 :: !Word8 -> ColorMode FullColor :: ColorMode black :: Color red :: Color green :: Color yellow :: Color blue :: Color magenta :: Color cyan :: Color white :: Color brightBlack :: Color brightRed :: Color brightGreen :: Color brightYellow :: Color brightBlue :: Color brightMagenta :: Color brightCyan :: Color brightWhite :: Color -- | Create a color value from RGB values in the 0..255 range inclusive. No -- transformation of the input values is done; a color is created -- directly from the RGB values specified, unlike the srgbColor -- and color240 functions. linearColor :: Integral i => i -> i -> i -> Color -- | Given RGB values in the range 0..255 inclusive, create a color using -- the sRGB transformation described at -- -- https://en.wikipedia.org/wiki/SRGB#The_reverse_transformation srgbColor :: Integral i => i -> i -> i -> Color -- | Create a Vty Color (in the 240 color set) from an RGB triple. -- This is a synonym for color240. This function is lossy in the -- sense that we only internally support 240 colors but the #RRGGBB -- format supports 256^3 colors. rgbColor :: Integral i => i -> i -> i -> Color color240 :: Integral i => i -> i -> i -> Color instance Control.DeepSeq.NFData Graphics.Vty.Attributes.Color.Color instance GHC.Generics.Generic Graphics.Vty.Attributes.Color.Color instance GHC.Read.Read Graphics.Vty.Attributes.Color.Color instance GHC.Show.Show Graphics.Vty.Attributes.Color.Color instance GHC.Classes.Eq Graphics.Vty.Attributes.Color.Color instance GHC.Read.Read Graphics.Vty.Attributes.Color.ColorMode instance GHC.Show.Show Graphics.Vty.Attributes.Color.ColorMode instance GHC.Classes.Eq Graphics.Vty.Attributes.Color.ColorMode -- | Display attributes -- -- Attributes have three components: a foreground color, a background -- color, and a style mask. The simplest attribute is the default -- attribute, or defAttr. Attributes can be modified with -- withForeColor, withBackColor, and withStyle, -- e.g., -- --
--   defAttr `withForeColor` red
--   
-- -- Image constructors often require an Attr to indicate -- the attributes used in the image, e.g., -- --
--   string (defAttr `withForeColor` red) "this text will be red"
--   
-- -- The appearance of Images using defAttr is determined -- by the The terminal, so this is not something VTY can control. The -- user is free to The define the color scheme of the terminal as they -- see fit. -- -- The value currentAttr will keep the attributes of whatever was -- output previously. module Graphics.Vty.Attributes -- | A display attribute defines the Color and Style of all the characters -- rendered after the attribute is applied. -- -- At most 256 colors, picked from a 240 and 16 color palette, are -- possible for the background and foreground. The 240 colors and 16 -- colors are points in different palettes. See Color for more -- information. data Attr Attr :: !MaybeDefault Style -> !MaybeDefault Color -> !MaybeDefault Color -> !MaybeDefault Text -> Attr [attrStyle] :: Attr -> !MaybeDefault Style [attrForeColor] :: Attr -> !MaybeDefault Color [attrBackColor] :: Attr -> !MaybeDefault Color [attrURL] :: Attr -> !MaybeDefault Text -- | Specifies the display attributes such that the final style and color -- values do not depend on the previously applied display attribute. The -- display attributes can still depend on the terminal's default colors -- (unfortunately). data FixedAttr FixedAttr :: !Style -> !Maybe Color -> !Maybe Color -> !Maybe Text -> FixedAttr [fixedStyle] :: FixedAttr -> !Style [fixedForeColor] :: FixedAttr -> !Maybe Color [fixedBackColor] :: FixedAttr -> !Maybe Color [fixedURL] :: FixedAttr -> !Maybe Text -- | The style and color attributes can either be the terminal defaults. Or -- be equivalent to the previously applied style. Or be a specific value. data MaybeDefault v Default :: MaybeDefault v KeepCurrent :: MaybeDefault v SetTo :: !v -> MaybeDefault v -- | Sets the style, background color and foreground color to the default -- values for the terminal. There is no easy way to determine what the -- default background and foreground colors are. defAttr :: Attr -- | Keeps the style, background color and foreground color that was -- previously set. Used to override some part of the previous style. -- -- EG: current_style withForeColor brightMagenta -- -- Would be the currently applied style (be it underline, bold, etc) but -- with the foreground color set to brightMagenta. currentAttr :: Attr -- | Styles are represented as an 8 bit word. Each bit in the word is 1 if -- the style attribute assigned to that bit should be applied and 0 if -- the style attribute should not be applied. type Style = Word8 -- | Add the given style attribute withStyle :: Attr -> Style -> Attr -- | Valid style attributes include: -- -- -- -- (The invisible, protect, and altcharset display attributes some -- terminals support are not supported via VTY.) standout :: Style -- | Valid style attributes include: -- -- -- -- (The invisible, protect, and altcharset display attributes some -- terminals support are not supported via VTY.) italic :: Style -- | Valid style attributes include: -- -- -- -- (The invisible, protect, and altcharset display attributes some -- terminals support are not supported via VTY.) strikethrough :: Style -- | Valid style attributes include: -- -- -- -- (The invisible, protect, and altcharset display attributes some -- terminals support are not supported via VTY.) underline :: Style -- | Valid style attributes include: -- -- -- -- (The invisible, protect, and altcharset display attributes some -- terminals support are not supported via VTY.) reverseVideo :: Style -- | Valid style attributes include: -- -- -- -- (The invisible, protect, and altcharset display attributes some -- terminals support are not supported via VTY.) blink :: Style -- | Valid style attributes include: -- -- -- -- (The invisible, protect, and altcharset display attributes some -- terminals support are not supported via VTY.) dim :: Style -- | Valid style attributes include: -- -- -- -- (The invisible, protect, and altcharset display attributes some -- terminals support are not supported via VTY.) bold :: Style defaultStyleMask :: Style styleMask :: Attr -> Word8 -- | true if the given Style value has the specified Style set. hasStyle :: Style -> Style -> Bool -- | Set the foreground color of an Attr. withForeColor :: Attr -> Color -> Attr -- | Set the background color of an Attr. withBackColor :: Attr -> Color -> Attr -- | Add a hyperlinked URL using the proposed escape sequences for -- hyperlinked URLs. These escape sequences are comparatively new and -- aren't widely supported in terminal emulators yet, but most terminal -- emulators that don't know about these sequences will ignore these -- sequences, and therefore this should fall back sensibly. In some cases -- they won't and this will result in garbage, so this is why -- hyperlinking is disabled by default, in which case this combinator has -- no observable effect. To enable it, enable Hyperlink mode on -- your Vty output interface. withURL :: Attr -> Text -> Attr instance GHC.Show.Show v => GHC.Show.Show (Graphics.Vty.Attributes.MaybeDefault v) instance GHC.Read.Read v => GHC.Read.Read (Graphics.Vty.Attributes.MaybeDefault v) instance GHC.Classes.Eq v => GHC.Classes.Eq (Graphics.Vty.Attributes.MaybeDefault v) instance GHC.Show.Show Graphics.Vty.Attributes.FixedAttr instance GHC.Classes.Eq Graphics.Vty.Attributes.FixedAttr instance Control.DeepSeq.NFData Graphics.Vty.Attributes.Attr instance GHC.Generics.Generic Graphics.Vty.Attributes.Attr instance GHC.Read.Read Graphics.Vty.Attributes.Attr instance GHC.Show.Show Graphics.Vty.Attributes.Attr instance GHC.Classes.Eq Graphics.Vty.Attributes.Attr instance Control.DeepSeq.NFData v => Control.DeepSeq.NFData (Graphics.Vty.Attributes.MaybeDefault v) module Graphics.Vty.DisplayAttributes -- | difference between two display attributes. Used in the calculation of -- the operations required to go from one display attribute to the next. -- -- Previously, vty would reset display attributes to default then apply -- the new display attributes. This turned out to be very expensive: A -- *lot* more data would be sent to the terminal than required. data DisplayAttrDiff DisplayAttrDiff :: [StyleStateChange] -> DisplayColorDiff -> DisplayColorDiff -> URLDiff -> DisplayAttrDiff [styleDiffs] :: DisplayAttrDiff -> [StyleStateChange] [foreColorDiff] :: DisplayAttrDiff -> DisplayColorDiff [backColorDiff] :: DisplayAttrDiff -> DisplayColorDiff [urlDiff] :: DisplayAttrDiff -> URLDiff -- | Style attribute changes are transformed into a sequence of -- apply/removes of the individual attributes. data StyleStateChange ApplyStandout :: StyleStateChange RemoveStandout :: StyleStateChange ApplyItalic :: StyleStateChange RemoveItalic :: StyleStateChange ApplyStrikethrough :: StyleStateChange RemoveStrikethrough :: StyleStateChange ApplyUnderline :: StyleStateChange RemoveUnderline :: StyleStateChange ApplyReverseVideo :: StyleStateChange RemoveReverseVideo :: StyleStateChange ApplyBlink :: StyleStateChange RemoveBlink :: StyleStateChange ApplyDim :: StyleStateChange RemoveDim :: StyleStateChange ApplyBold :: StyleStateChange RemoveBold :: StyleStateChange -- | Difference between two display color attribute changes. data DisplayColorDiff ColorToDefault :: DisplayColorDiff NoColorChange :: DisplayColorDiff SetColor :: !Color -> DisplayColorDiff data URLDiff LinkTo :: !ByteString -> URLDiff NoLinkChange :: URLDiff EndLink :: URLDiff -- | Given the previously applied display attributes as a FixedAttr and the -- current display attributes as an Attr produces a FixedAttr that -- represents the current display attributes. This is done by using the -- previously applied display attributes to remove the KeepCurrent -- abstraction. fixDisplayAttr :: FixedAttr -> Attr -> FixedAttr -- | Determines the diff between two display&color attributes. This -- diff determines the operations that actually get output to the -- terminal. displayAttrDiffs :: FixedAttr -> FixedAttr -> DisplayAttrDiff instance GHC.Classes.Eq Graphics.Vty.DisplayAttributes.DisplayColorDiff instance GHC.Show.Show Graphics.Vty.DisplayAttributes.DisplayColorDiff instance GHC.Classes.Eq Graphics.Vty.DisplayAttributes.StyleStateChange instance GHC.Show.Show Graphics.Vty.DisplayAttributes.StyleStateChange instance GHC.Classes.Eq Graphics.Vty.DisplayAttributes.URLDiff instance GHC.Show.Show Graphics.Vty.DisplayAttributes.URLDiff instance GHC.Show.Show Graphics.Vty.DisplayAttributes.DisplayAttrDiff instance GHC.Base.Semigroup Graphics.Vty.DisplayAttributes.DisplayAttrDiff instance GHC.Base.Monoid Graphics.Vty.DisplayAttributes.DisplayAttrDiff module Graphics.Vty.Error -- | The type of exceptions specific to vty. -- -- These have fully qualified names by default since, IMO, exception -- handling requires this. data VtyException -- | Uncategorized failure specific to vty. VtyFailure :: String -> VtyException -- | A Vty program makes Pictures from Images. This module -- provides the core constructors for creating, combining, and modifying -- Images. module Graphics.Vty.Image -- | This is the internal representation of Images. Use the constructors in -- Graphics.Vty.Image to create instances. -- -- Images are: -- -- data Image -- | The width of an Image. This is the number display columns the image -- will occupy. imageWidth :: Image -> Int -- | The height of an Image. This is the number of display rows the image -- will occupy. imageHeight :: Image -> Int -- | The empty image. Useful for fold combinators. These occupy no space -- and do not affect display attributes. emptyImage :: Image -- | Make an image from a single character. This is a standard Haskell -- 31-bit character assumed to be in the ISO-10646 encoding. char :: Attr -> Char -> Image -- | Make an Image from a String. -- -- This is an alias for iso10646String since the usual case is that a -- literal string like "foo" is represented internally as a list of ISO -- 10646 31 bit characters. -- -- Note: Keep in mind that GHC will compile source encoded as UTF-8 but -- the literal strings, while UTF-8 encoded in the source, will be -- transcoded to a ISO 10646 31 bit characters runtime representation. string :: Attr -> String -> Image -- | Make an image from a string of characters laid out on a single row -- with the same display attribute. The string is assumed to be a -- sequence of ISO-10646 characters. The input string should be sanitized -- of escape sequences (ASCII 27) and carriage returns; otherwise layout -- and attribute problems may result. -- -- Note: depending on how the Haskell compiler represents string -- literals, a string literal in a UTF-8 encoded source file, for -- example, may be represented as a ISO-10646 string. That is, I think, -- the case with GHC 6.10. This means, for the most part, you don't need -- to worry about the encoding format when outputting string literals. -- Just provide the string literal directly to iso10646String or string. iso10646String :: Attr -> String -> Image -- | Make an Image from a string of characters layed out on a single -- row. The input is assumed to be the bytes for UTF-8 encoded text. utf8String :: Attr -> [Word8] -> Image -- | Make an Image from a lazy text value. The text value should be -- sanitized of escape sequences (ASCII 27) and carriage returns; -- otherwise layout and attribute problems may result. text :: Attr -> Text -> Image -- | Make an Image from a text value. The text value should be -- sanitized of escape sequences (ASCII 27) and carriage returns; -- otherwise layout and attribute problems may result. text' :: Attr -> Text -> Image -- | An area of the picture's background (See Background). backgroundFill :: Int -> Int -> Image -- | Make an Image from a UTF-8 encoded lazy bytestring. utf8Bytestring :: Attr -> ByteString -> Image -- | Make an Image from a UTF-8 encoded strict bytestring. utf8Bytestring' :: Attr -> ByteString -> Image -- | Make an image filling a region with the specified character. -- -- If either the width or height are less than or equal to 0, then the -- result is the empty image. charFill :: Integral d => Attr -> Char -> d -> d -> Image -- | combines two images side by side -- -- Combines text chunks where possible. Assures outputWidth and -- outputHeight properties are not violated. -- -- The result image will have a width equal to the sum of the two images -- width. And the height will equal the largest height of the two images. -- The area not defined in one image due to a height mismatch will be -- filled with the background pattern. horizJoin :: Image -> Image -> Image -- | Combines two images horizontally. This is an alias for -- horizJoin. -- -- infixr 5 (<|>) :: Image -> Image -> Image infixr 5 <|> -- | combines two images vertically -- -- The result image will have a height equal to the sum of the heights of -- both images. The width will equal the largest width of the two images. -- The area not defined in one image due to a width mismatch will be -- filled with the background pattern. vertJoin :: Image -> Image -> Image -- | Combines two images vertically. This is an alias for vertJoin. -- -- infixr 4 (<->) :: Image -> Image -> Image infixr 4 <-> -- | Compose any number of images together horizontally, with the first in -- the list being leftmost. horizCat :: [Image] -> Image -- | Compose any number of images vertically, with the first in the list -- being topmost. vertCat :: [Image] -> Image -- | Ensure an image is no larger than the provided size. If the image is -- larger then crop the right or bottom. -- -- This is equivalent to a vertical crop from the bottom followed by -- horizontal crop from the right. crop :: Int -> Int -> Image -> Image -- | Crop an image's width. If the image's width is less than or equal to -- the specified width then this operation has no effect. Otherwise the -- image is cropped from the right. cropRight :: Int -> Image -> Image -- | Crop an image's width. If the image's width is less than or equal to -- the specified width then this operation has no effect. Otherwise the -- image is cropped from the left. cropLeft :: Int -> Image -> Image -- | Crop an image's height. If the image's height is less than or equal to -- the specified height then this operation has no effect. Otherwise the -- image is cropped from the bottom. cropBottom :: Int -> Image -> Image -- | Crop an image's height. If the image's height is less than or equal to -- the specified height then this operation has no effect. Otherwise the -- image is cropped from the top. cropTop :: Int -> Image -> Image -- | Pad the given image. This adds background character fills to the left, -- top, right, bottom. pad :: Int -> Int -> Int -> Int -> Image -> Image -- | Generic resize. Pads and crops are added to ensure that the resulting -- image matches the specified dimensions. This is biased to pad/crop the -- right and bottom. resize :: Int -> Int -> Image -> Image -- | Resize the width. Pads and crops as required to assure the given -- display width. This is biased to pad/crop on the right. resizeWidth :: Int -> Image -> Image -- | Resize the height. Pads and crops as required to assure the given -- display height. This is biased to pad/crop on the bottom. resizeHeight :: Int -> Image -> Image -- | Translates an image by padding or cropping the left and top. -- -- If translation offsets are negative then the image is cropped. translate :: Int -> Int -> Image -> Image -- | Translates an image by padding or cropping its left side. translateX :: Int -> Image -> Image -- | Translates an image by padding or cropping its top. translateY :: Int -> Image -> Image -- | Returns the display width of a character. Assumes all characters with -- unknown widths are 0 width. safeWcwidth :: Char -> Int -- | Returns the display width of a string. Assumes all characters with -- unknown widths are 0 width. safeWcswidth :: String -> Int -- | Returns the display width of a text. Assumes all characters with -- unknown widths are 0 width. safeWctwidth :: Text -> Int -- | Returns the display width of a lazy text. Assumes all characters with -- unknown widths are 0 width. safeWctlwidth :: Text -> Int wcwidth :: Char -> Int wcswidth :: String -> Int wctwidth :: Text -> Int wctlwidth :: Text -> Int -- | A region of the display (first width, then height) type DisplayRegion = (Int, Int) regionWidth :: DisplayRegion -> Int regionHeight :: DisplayRegion -> Int module Graphics.Vty.Input.Events -- | Representations of non-modifier keys. -- -- data Key KEsc :: Key KChar :: {-# UNPACK #-}Char -> Key KBS :: Key KEnter :: Key KLeft :: Key KRight :: Key KUp :: Key KDown :: Key KUpLeft :: Key KUpRight :: Key KDownLeft :: Key KDownRight :: Key KCenter :: Key KFun :: {-# UNPACK #-}Int -> Key KBackTab :: Key KPrtScr :: Key KPause :: Key KIns :: Key KHome :: Key KPageUp :: Key KDel :: Key KEnd :: Key KPageDown :: Key KBegin :: Key KMenu :: Key -- | Modifier keys. Key codes are interpreted such that users are more -- likely to have Meta than Alt; for instance on the PC Linux console, -- MMeta will generally correspond to the physical Alt key. data Modifier MShift :: Modifier MCtrl :: Modifier MMeta :: Modifier MAlt :: Modifier -- | Events. data Event -- | A keyboard key was pressed with the specified modifiers. EvKey :: Key -> [Modifier] -> Event -- | A mouse button was pressed at the specified column and row. Any -- modifiers available in the event are also provided. EvMouseDown :: Int -> Int -> Button -> [Modifier] -> Event -- | A mouse button was released at the specified column and row. Some -- terminals report only that a button was released without specifying -- which one; in that case, Nothing is provided. Otherwise Just the -- button released is included in the event. EvMouseUp :: Int -> Int -> Maybe Button -> Event EvResize :: Int -> Int -> Event -- | A paste event occurs when a bracketed paste input sequence is -- received. For terminals that support bracketed paste mode, these -- events will be triggered on a paste event. Terminals that do not -- support bracketed pastes will send the paste contents as ordinary -- input (which is probably bad, so beware!) Note that the data is -- provided in raw form and you'll have to decode (e.g. as UTF-8) if -- that's what your application expects. EvPaste :: ByteString -> Event -- | The terminal running the application lost input focus. EvLostFocus :: Event -- | The terminal running the application gained input focus. EvGainedFocus :: Event -- | Mouse buttons. data Button BLeft :: Button BMiddle :: Button BRight :: Button BScrollUp :: Button BScrollDown :: Button type ClassifyMap = [(String, Event)] -- | The type of internal events that drive the internal Vty event -- dispatching to the application. data InternalEvent -- | Vty resumed operation after the process was interrupted (e.g. with a -- signal). In practice this translates into a screen redraw in the input -- event loop. ResumeAfterInterrupt :: InternalEvent -- | An input event was received. InputEvent :: Event -> InternalEvent instance GHC.Generics.Generic Graphics.Vty.Input.Events.Key instance GHC.Classes.Ord Graphics.Vty.Input.Events.Key instance GHC.Read.Read Graphics.Vty.Input.Events.Key instance GHC.Show.Show Graphics.Vty.Input.Events.Key instance GHC.Classes.Eq Graphics.Vty.Input.Events.Key instance GHC.Generics.Generic Graphics.Vty.Input.Events.Modifier instance GHC.Classes.Ord Graphics.Vty.Input.Events.Modifier instance GHC.Read.Read Graphics.Vty.Input.Events.Modifier instance GHC.Show.Show Graphics.Vty.Input.Events.Modifier instance GHC.Classes.Eq Graphics.Vty.Input.Events.Modifier instance GHC.Generics.Generic Graphics.Vty.Input.Events.Button instance GHC.Classes.Ord Graphics.Vty.Input.Events.Button instance GHC.Read.Read Graphics.Vty.Input.Events.Button instance GHC.Show.Show Graphics.Vty.Input.Events.Button instance GHC.Classes.Eq Graphics.Vty.Input.Events.Button instance GHC.Generics.Generic Graphics.Vty.Input.Events.Event instance GHC.Classes.Ord Graphics.Vty.Input.Events.Event instance GHC.Read.Read Graphics.Vty.Input.Events.Event instance GHC.Show.Show Graphics.Vty.Input.Events.Event instance GHC.Classes.Eq Graphics.Vty.Input.Events.Event instance Control.DeepSeq.NFData Graphics.Vty.Input.Events.Event instance Control.DeepSeq.NFData Graphics.Vty.Input.Events.Button instance Control.DeepSeq.NFData Graphics.Vty.Input.Events.Modifier instance Control.DeepSeq.NFData Graphics.Vty.Input.Events.Key -- | This module provides the input abstraction for Vty. module Graphics.Vty.Input -- | The library's input-processing abstraction. Platform-specific -- implementations must implement an Input and provide it to -- mkVtyFromPair. data Input Input :: TChan InternalEvent -> IO () -> IO () -> (String -> IO ()) -> Input -- | A channel of events generated by input processing. The input -- implementation must write its input events to this channel; the Vty -- event loop will read from this channel and provide the events to the -- user's application via nextEvent. [eventChannel] :: Input -> TChan InternalEvent -- | Shut down the input processing. As part of shutting down the input, -- this should also restore the input state if appropriate. [shutdownInput] :: Input -> IO () -- | Restore the terminal's input state to what it was prior to configuring -- the input for Vty. This should be done as part of shutdownInput -- but is exposed in case it needs to be used directly. [restoreInputState] :: Input -> IO () -- | Log the specified message. [inputLogMsg] :: Input -> String -> IO () -- | Vty supports a configuration file format and provides a corresponding -- VtyUserConfig data type. The VtyUserConfig can be -- provided to platform packages' mkVty functions to customize -- the application's use of Vty. -- --

Debug

-- --

colorMode

-- -- Format: -- --
--   colorMode "<int|FullColor>"
--   
-- -- The preferred color mode to use, chosen from the constructors of the -- ColorMode type. If absent, the backend driver may detect and -- choose an appropriate color mode. Implementor's note: backend packages -- should respect this setting when it is present even when their -- detection indicates that a different color mode should be used. -- --

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
--   
-- -- E.g., 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. A workflow for using this is to -- set VTY_DEBUG_LOG. Run the application. Check the debug log -- for incorrect mappings. Add corrected mappings to -- $HOME/.vty/config. -- --

Unicode Character Width Maps

-- --

widthMap

-- -- Format: -- --
--   "widthMap" string string
--   
-- -- E.g., -- --
--   widthMap "xterm" "/home/user/.vty/xterm_map.dat"
--   
-- -- This directive specifies the path to a Unicode character width map -- (the second argument) that should correspond to the terminal named by -- first argument. Unicode character width maps can be produced either by -- running platform packages' width table tools or by calling the library -- routine buildUnicodeWidthTable. Vty platform packages should -- use these configuration settings to attempt to load and install the -- specified width map. module Graphics.Vty.Config -- | 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. type InputMap = [(Maybe String, String, Event)] -- | A Vty core library configuration. Platform-specific details are not -- included in the VtyUserConfig. data VtyUserConfig VtyUserConfig :: Maybe FilePath -> InputMap -> [(String, FilePath)] -> Maybe Bool -> Maybe ColorMode -> VtyUserConfig -- | Debug information is appended to this file if not Nothing. [configDebugLog] :: VtyUserConfig -> Maybe FilePath -- | 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. [configInputMap] :: VtyUserConfig -> InputMap -- | Terminal width map files. [configTermWidthMaps] :: VtyUserConfig -> [(String, FilePath)] -- | Whether to permit custom Unicode width table loading by mkVty. -- Just False indicates that table loading should -- not be performed. Other values permit table loading. -- -- If a table load is attempted and fails, information about the failure -- will be logged to the debug log if the configuration specifies one. If -- no custom table is loaded (or if a load fails), the built-in character -- width table will be used. [configAllowCustomUnicodeWidthTables] :: VtyUserConfig -> Maybe Bool -- | Preferred color mode. If set, this should override platform color mode -- detection. [configPreferredColorMode] :: VtyUserConfig -> Maybe ColorMode -- | Load a configuration from vtyConfigPath and -- $VTY_CONFIG_FILE. If none is found, build a default -- configuration. userConfig :: IO VtyUserConfig overrideEnvConfig :: IO VtyUserConfig currentTerminalName :: IO (Maybe String) runParseConfig :: String -> ByteString -> VtyUserConfig -- | Parse a Vty configuration file. -- -- Lines in config files that fail to parse are ignored. Later entries -- take precedence over earlier ones. parseConfigFile :: FilePath -> IO VtyUserConfig defaultConfig :: VtyUserConfig vtyConfigPath :: IO FilePath widthTableFilename :: String -> String vtyDataDirectory :: IO FilePath terminalWidthTablePath :: IO (Maybe FilePath) vtyConfigFileEnvName :: String -- | The result of a configuration change attempt made by -- addConfigWidthMap. data ConfigUpdateResult -- | A new configuration file file was written with the new width table -- entry. ConfigurationCreated :: ConfigUpdateResult -- | An existing configuration file was modified with the new width table -- entry. ConfigurationModified :: ConfigUpdateResult -- | The attempted width table entry could not be written to the -- configuration due to a conflict; the argument here is the width table -- file path for the conflicting entry. ConfigurationConflict :: String -> ConfigUpdateResult -- | No change was made because the existing configuration already contains -- the specified mapping. ConfigurationRedundant :: ConfigUpdateResult -- | Add a widthMap directive to the Vty configuration file at the -- specified path. -- -- If the configuration path refers to a configuration that already -- contains the directive for the specified map and terminal type, the -- configuration file will not be modified. If the file does not contain -- the directive, it will be appended to the file. -- -- If the configuration path does not exist, a new configuration file -- will be created and any directories in the path will also be created. -- -- This returns a ConfigUpdateResult indicating the change to the -- configuration. This does not handle exceptions raised by file or -- directory permissions issues. addConfigWidthMap :: FilePath -> String -> FilePath -> IO ConfigUpdateResult instance GHC.Classes.Eq Graphics.Vty.Config.VtyUserConfig instance GHC.Show.Show Graphics.Vty.Config.VtyUserConfig instance GHC.Show.Show Graphics.Vty.Config.ConfigUpdateResult instance GHC.Classes.Eq Graphics.Vty.Config.ConfigUpdateResult instance Graphics.Vty.Config.GParseAlts f => Graphics.Vty.Config.GParse (GHC.Generics.M1 GHC.Generics.D i f) instance (GHC.Generics.Constructor i, Graphics.Vty.Config.GParse f) => Graphics.Vty.Config.GParseAlts (GHC.Generics.M1 GHC.Generics.C i f) instance (Graphics.Vty.Config.GParseAlts f, Graphics.Vty.Config.GParseAlts g) => Graphics.Vty.Config.GParseAlts (f GHC.Generics.:+: g) instance Graphics.Vty.Config.GParseAlts GHC.Generics.V1 instance Graphics.Vty.Config.GParse f => Graphics.Vty.Config.GParse (GHC.Generics.M1 GHC.Generics.S i f) instance Graphics.Vty.Config.GParse GHC.Generics.U1 instance Graphics.Vty.Config.Parse a => Graphics.Vty.Config.GParse (GHC.Generics.K1 i a) instance (Graphics.Vty.Config.GParse f, Graphics.Vty.Config.GParse g) => Graphics.Vty.Config.GParse (f GHC.Generics.:*: g) instance Graphics.Vty.Config.Parse GHC.Types.Char instance Graphics.Vty.Config.Parse GHC.Types.Int instance Graphics.Vty.Config.Parse Graphics.Vty.Input.Events.Key instance Graphics.Vty.Config.Parse Graphics.Vty.Input.Events.Modifier instance Graphics.Vty.Config.Parse a => Graphics.Vty.Config.Parse [a] instance GHC.Base.Semigroup Graphics.Vty.Config.VtyUserConfig instance GHC.Base.Monoid Graphics.Vty.Config.VtyUserConfig module Graphics.Vty.Picture -- | A Vty picture. -- -- These can be constructed directly or using picForImage. data Picture Picture :: Cursor -> [Image] -> Background -> Picture -- | The picture's cursor. [picCursor] :: Picture -> Cursor -- | The picture's image layers (top-most first). [picLayers] :: Picture -> [Image] -- | The picture's background to be displayed in locations with no Image -- data. [picBackground] :: Picture -> Background -- | A picture can be configured to hide the cursor or to show the cursor -- at the specified character position. -- -- There is not a 1:1 map from character positions to a row and column on -- the screen due to characters that take more than 1 column. data Cursor -- | Hide the cursor NoCursor :: Cursor -- | Set the terminal's cursor position without displaying a cursor -- character. This is important for accessibility with screen readers -- where a cursor position needs to be reported but we may not want to -- show a block cursor in that location for cosmetic reasons. The boolean -- argument indicates whether the positioning should be absolute as with -- AbsoluteCursor (True) or logical as with Cursor -- (False). PositionOnly :: !Bool -> !Int -> !Int -> Cursor -- | Show the cursor at the given logical column accounting for character -- width in the presence of multi-column characters. Cursor :: !Int -> !Int -> Cursor -- | Show the cursor at the given absolute terminal column and row AbsoluteCursor :: !Int -> !Int -> Cursor -- | A Picture has a background pattern. The background is either: -- -- -- -- If the display attribute used previously should be used for a -- background fill then use currentAttr for the background -- attribute. data Background Background :: Char -> Attr -> Background [backgroundChar] :: Background -> Char [backgroundAttr] :: Background -> Attr -- | A ClearBackground is: -- -- ClearBackground :: Background -- | A picture with no cursor, background or image layers. emptyPicture :: Picture -- | Add an Image as the top-most layer of a Picture. addToTop :: Picture -> Image -> Picture -- | Add an Image as the bottom-most layer of a Picture. addToBottom :: Picture -> Image -> Picture -- | Create a picture from the given image. The picture will not have a -- displayed cursor and no background pattern (ClearBackground) will be -- used. picForImage :: Image -> Picture -- | Create a picture with the given layers, top-most first. -- -- The picture will not have a displayed cursor and no background pattern -- (ClearBackgroun) will be used. picForLayers :: [Image] -> Picture -- | Return the top-most Image layer for a picture. This is unsafe -- for Pictures without at least one layer. -- -- This is provided for compatibility with applications that do not use -- more than a single layer. picImage :: Picture -> Image instance GHC.Show.Show Graphics.Vty.Picture.Cursor instance GHC.Classes.Eq Graphics.Vty.Picture.Cursor instance GHC.Show.Show Graphics.Vty.Picture.Background instance GHC.Classes.Eq Graphics.Vty.Picture.Background instance GHC.Show.Show Graphics.Vty.Picture.Picture instance GHC.Classes.Eq Graphics.Vty.Picture.Picture instance Control.DeepSeq.NFData Graphics.Vty.Picture.Picture instance Control.DeepSeq.NFData Graphics.Vty.Picture.Background instance Control.DeepSeq.NFData Graphics.Vty.Picture.Cursor -- | A picture is translated into a sequences of state changes and -- character spans. The attribute is applied to all following spans, -- including spans of the next row. The nth element of the sequence -- represents the nth row (from top to bottom) of the picture to render. -- -- A span op sequence will be defined for all rows and columns (and no -- more) of the region provided with the picture to spansForPic. module Graphics.Vty.Span -- | This represents an operation on the terminal: either an attribute -- change or the output of a text string. data SpanOp -- | A span of UTF-8 text occupies a specific number of screen space -- columns. A single UTF character does not necessarily represent 1 -- colunm. See Codec.Binary.UTF8.Width TextSpan [Attr] [output width in -- columns] [number of characters] [data] TextSpan :: !Attr -> !Int -> !Int -> Text -> SpanOp [textSpanAttr] :: SpanOp -> !Attr [textSpanOutputWidth] :: SpanOp -> !Int [textSpanCharWidth] :: SpanOp -> !Int [textSpanText] :: SpanOp -> Text -- | Skips the given number of columns. Skip :: !Int -> SpanOp -- | Marks the end of a row. Specifies how many columns are remaining. -- These columns will not be explicitly overwritten with the span ops. -- The terminal is require to assure the remaining columns are clear. RowEnd :: !Int -> SpanOp -- | The number of columns to the character at the given position in the -- span op. columnsToCharOffset :: Int -> SpanOp -> Int -- | The width of a single SpanOp in columns. spanOpHasWidth :: SpanOp -> Maybe (Int, Int) -- | A vector of span operations executed in succession. This represents -- the operations required to render a row of the terminal. The -- operations in one row may affect subsequent rows. For example, setting -- the foreground color in one row will affect all subsequent rows until -- the foreground color is changed. type SpanOps = Vector SpanOp -- | The number of columns a SpanOps affects. spanOpsAffectedColumns :: SpanOps -> Int splitOpsAt :: Int -> SpanOps -> (SpanOps, SpanOps) dropOps :: Int -> SpanOps -> SpanOps -- | A vector of span operation vectors for display, one per row of the -- output region. type DisplayOps = Vector SpanOps -- | The number of rows the DisplayOps are defined for. displayOpsRows :: DisplayOps -> Int -- | The number of columns the DisplayOps are defined for. -- -- All spans are verified to define same number of columns. displayOpsColumns :: DisplayOps -> Int affectedRegion :: DisplayOps -> DisplayRegion instance GHC.Classes.Eq Graphics.Vty.Span.SpanOp instance GHC.Show.Show Graphics.Vty.Span.SpanOp -- | Transforms an image into rows of operations. module Graphics.Vty.PictureToSpans -- | Produces the span ops that will render the given picture, possibly -- cropped or padded, into the specified region. displayOpsForPic :: Picture -> DisplayRegion -> DisplayOps -- | This module provides an abstract interface for performing terminal -- output and functions for accessing the current terminal or a specific -- terminal device. module Graphics.Vty.Output -- | The library's device output abstraction. Platform-specific -- implementations must implement an Output and provide it to -- mkVtyFromPair. data Output Output :: String -> IO () -> IO () -> IO () -> ((Int, Int) -> IO ()) -> IO DisplayRegion -> (ByteString -> IO ()) -> Bool -> (Mode -> Bool) -> (Mode -> Bool -> IO ()) -> (Mode -> IO Bool) -> IORef AssumedState -> (Output -> DisplayRegion -> IO DisplayContext) -> IO () -> IO Bool -> IO Bool -> IO Bool -> ColorMode -> (String -> IO ()) -> Output -- | Text identifier for the output device. Used for debugging. [terminalID] :: Output -> String -- | Release the terminal just prior to application exit and reset it to -- its state prior to application startup. [releaseTerminal] :: Output -> IO () -- | Clear the display and initialize the terminal to some initial display -- state. -- -- The expectation of a program is that the display starts in some The -- initial state. initial state would consist of fixed values: -- -- [reserveDisplay] :: Output -> IO () -- | Return the display to the state before reserveDisplay If no -- previous state then set the display state to the initial state. [releaseDisplay] :: Output -> IO () -- | Sets the current display bounds (width, height). [setDisplayBounds] :: Output -> (Int, Int) -> IO () -- | Returns the current display bounds. [displayBounds] :: Output -> IO DisplayRegion -- | Output the bytestring to the terminal device. [outputByteBuffer] :: Output -> ByteString -> IO () -- | Specifies whether the cursor can be shown / hidden. [supportsCursorVisibility] :: Output -> Bool -- | Indicates support for terminal modes for this output device. [supportsMode] :: Output -> Mode -> Bool -- | Enables or disables a mode (does nothing if the mode is unsupported). [setMode] :: Output -> Mode -> Bool -> IO () -- | Returns whether a mode is enabled. [getModeStatus] :: Output -> Mode -> IO Bool [assumedStateRef] :: Output -> IORef AssumedState -- | Acquire display access to the given region of the display. Currently -- all regions have the upper left corner of (0,0) and the lower right -- corner at (max displayWidth providedWidth, max displayHeight -- providedHeight) [mkDisplayContext] :: Output -> Output -> DisplayRegion -> IO DisplayContext -- | Ring the terminal bell if supported. [ringTerminalBell] :: Output -> IO () -- | Returns whether the terminal has an audio bell feature. [supportsBell] :: Output -> IO Bool -- | Returns whether the terminal supports italicized text. -- -- This is terminal-dependent and should make a best effort to determine -- whether this feature is supported, but even if the terminal advertises -- support (e.g. via terminfo) that might not be a reliable indicator of -- whether the feature will work as desired. [supportsItalics] :: Output -> IO Bool -- | Returns whether the terminal supports strikethrough text. -- -- This is terminal-dependent and should make a best effort to determine -- whether this feature is supported, but even if the terminal advertises -- support (e.g. via terminfo) that might not be a reliable indicator of -- whether the feature will work as desired. [supportsStrikethrough] :: Output -> IO Bool -- | Returns how many colors the terminal supports. [outputColorMode] :: Output -> ColorMode -- | Set the output's window title, if any. [setOutputWindowTitle] :: Output -> String -> IO () data AssumedState AssumedState :: Maybe FixedAttr -> Maybe DisplayOps -> AssumedState [prevFattr] :: AssumedState -> Maybe FixedAttr [prevOutputOps] :: AssumedState -> Maybe DisplayOps data DisplayContext DisplayContext :: Output -> DisplayRegion -> (Int -> Int -> Write) -> Write -> Write -> (Bool -> FixedAttr -> Attr -> DisplayAttrDiff -> Write) -> (Bool -> Write) -> Write -> IO () -> DisplayContext [contextDevice] :: DisplayContext -> Output -- | Provide the bounds of the display context. [contextRegion] :: DisplayContext -> DisplayRegion -- | Sets the output position to the specified row and column where the -- number of bytes required for the control codes can be specified -- seperate from the actual byte sequence. [writeMoveCursor] :: DisplayContext -> Int -> Int -> Write [writeShowCursor] :: DisplayContext -> Write [writeHideCursor] :: DisplayContext -> Write [writeSetAttr] :: DisplayContext -> Bool -> FixedAttr -> Attr -> DisplayAttrDiff -> Write -- | Reset the display attributes to the default display attributes. [writeDefaultAttr] :: DisplayContext -> Bool -> Write [writeRowEnd] :: DisplayContext -> Write -- | See inlineHack [inlineHack] :: DisplayContext -> IO () -- | Modal terminal features that can be enabled and disabled. data Mode -- | Mouse mode (whether the terminal is configured to provide mouse input -- events) Mouse :: Mode -- | Paste mode (whether the terminal is configured to provide events on OS -- pastes) BracketedPaste :: Mode -- | Focus-in/focus-out events (whether the terminal is configured to -- provide events on focus change) Focus :: Mode -- | Hyperlink mode via the withURL attribute modifier (see -- https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda). -- Note that this may not work gracefully in all terminal emulators so be -- sure to test this mode with the terminals you intend to support. It is -- off by default. Hyperlink :: Mode displayContext :: Output -> DisplayRegion -> IO DisplayContext -- | Displays the given Picture. -- --
    --
  1. The image is cropped to the display size.
  2. --
  3. Converted into a sequence of attribute changes and text -- spans.
  4. --
  5. The cursor is hidden.
  6. --
  7. Serialized to the display.
  8. --
  9. The cursor is then shown and positioned or kept hidden.
  10. --
outputPicture :: DisplayContext -> Picture -> IO () initialAssumedState :: AssumedState -- | Not all terminals support all display attributes. This filters a -- display attribute to what the given terminal can display. limitAttrForDisplay :: Output -> Attr -> Attr -- | Sets the cursor position to the given output column and row. -- -- This is not necessarily the same as the character position with the -- same coordinates. Characters can be a variable number of columns in -- width. -- -- Currently, the only way to set the cursor position to a given -- character coordinate is to specify the coordinate in the Picture -- instance provided to outputPicture or refresh. setCursorPos :: Output -> Int -> Int -> IO () -- | Hides the cursor. hideCursor :: Output -> IO () -- | Shows the cursor. showCursor :: Output -> IO () instance GHC.Show.Show Graphics.Vty.Output.Mode instance GHC.Read.Read Graphics.Vty.Output.Mode instance GHC.Classes.Eq Graphics.Vty.Output.Mode -- | This provides a mock terminal implementation that is nice for testing. -- This transforms the output operations to visible characters which is -- useful for testing. module Graphics.Vty.Output.Mock type MockData = IORef (UTF8 ByteString) -- | The mock display terminal produces a string representation of the -- requested picture. There is *not* an isomorphism between the string -- representation and the picture. The string representation is a -- simplification of the picture that is only useful in debugging VTY -- without considering terminal specific issues. -- -- The mock implementation is useful in manually determining if the -- sequence of terminal operations matches the expected sequence. The -- requirement of the produced representation is simplicity in parsing -- the text representation and determining how the picture was mapped to -- terminal operations. -- -- The string representation is a sequence of identifiers where each -- identifier is the name of an operation in the algebra. mockTerminal :: (Applicative m, MonadIO m) => DisplayRegion -> m (MockData, Output) module Graphics.Vty.Debug data MockWindow MockWindow :: Int -> Int -> MockWindow type SpanConstructLog = [SpanConstructEvent] regionForWindow :: MockWindow -> DisplayRegion allSpansHaveWidth :: DisplayOps -> Int -> Bool -- | The number of columns a SpanOps affects. spanOpsAffectedColumns :: SpanOps -> Int spanOpsAffectedRows :: DisplayOps -> Int rowOpsAffectedColumns :: DisplayOps -> [Int] isSetAttr :: Attr -> SpanConstructEvent -> Bool instance GHC.Classes.Eq Graphics.Vty.Debug.MockWindow instance GHC.Show.Show Graphics.Vty.Debug.MockWindow module Graphics.Vty.UnicodeWidthTable.Types -- | A run-length-encoded table of Unicode character widths. data UnicodeWidthTable UnicodeWidthTable :: [WidthTableRange] -> UnicodeWidthTable -- | The ranges in the table. [unicodeWidthTableRanges] :: UnicodeWidthTable -> [WidthTableRange] -- | A range of code points in a width table. data WidthTableRange WidthTableRange :: Word32 -> Word32 -> Word8 -> WidthTableRange -- | The range's starting code point. [rangeStart] :: WidthTableRange -> Word32 -- | The number of code points in the contiguous range, beginning with the -- starting code point (rangeStart). [rangeSize] :: WidthTableRange -> Word32 -- | The terminal width, in columns, of all of the characters corresponding -- to the code points in this range. [rangeColumns] :: WidthTableRange -> Word8 instance GHC.Show.Show Graphics.Vty.UnicodeWidthTable.Types.WidthTableRange instance GHC.Classes.Eq Graphics.Vty.UnicodeWidthTable.Types.WidthTableRange instance GHC.Show.Show Graphics.Vty.UnicodeWidthTable.Types.UnicodeWidthTable module Graphics.Vty.UnicodeWidthTable.Query -- | Construct a unicode character width table. This works by using the -- provided function to obtain the appropriate width for each character -- in a wide range of Unicode code points, which on some platforms may -- perform local terminal operations or may interact with system -- libraries. Depending on how the provided width function works, this -- may need to be run only in a terminal that is not actively controlled -- by a Vty handle. -- -- The character argument specifies the upper bound code point to test -- when building the table. This allows callers to decide how much of the -- Unicode code point space to scan when building the table. -- -- This does not handle exceptions. buildUnicodeWidthTable :: (Char -> IO Int) -> Char -> IO UnicodeWidthTable defaultUnicodeTableUpperBound :: Char module Graphics.Vty.UnicodeWidthTable.Install -- | Exception type raised by installUnicodeWidthTable. data TableInstallException -- | The width table could not be initialized. Args: failure status, -- requested table size. TableInitFailure :: Int -> Int -> TableInstallException -- | A code point range could not be configured. Args: failure status, -- offending range. TableRangeFailure :: Int -> WidthTableRange -> TableInstallException -- | The table could not be activated. Args: failure status. TableActivationFailure :: Int -> TableInstallException -- | Install a custom unicode character width table. Such tables are -- obtained with buildUnicodeWidthTable and -- readUnicodeWidthTable. -- -- ALERT! This function is probably not what you want to use because it -- is automatically called by mkVty. You will only ever need to -- call this function if you want to use functions in Width -- without controlling the terminal with mkVty. -- -- This affects the behavior of the wcwidth function and functions -- that call it. It does so by changing global state available to the C -- implementation of wcwidth. To ensure that your program gets -- consistent results from evaluating calls to wcwidth, the -- installation of a custom table should be performed before you call -- wcwidth in your program. -- -- This is best done at Vty startup, and if you use mkVty, that -- function calls this automatically based on the Vty configuration's -- declared width tables. It is exposed as part of the public API so that -- applications can call this as needed if they don't want to control the -- terminal with mkVty but do want to make calls to -- wcwidth. -- -- It's also important to note that once a custom table has been -- installed, it is permanent for the life of the process. No new table -- can be installed, and the new custom table cannot be removed. -- -- If this function fails for any reason -- if the table cannot be -- installed or is invalid, or if a custom table already exists -- this -- will raise a TableInstallException exception. -- -- This function is thread-safe. installUnicodeWidthTable :: UnicodeWidthTable -> IO () -- | Returns True if and only if a custom table has been allocated and -- marked as ready for use. -- -- This function is thread-safe. isCustomTableReady :: IO Bool instance GHC.Show.Show Graphics.Vty.UnicodeWidthTable.Install.TableInstallException instance GHC.Classes.Eq Graphics.Vty.UnicodeWidthTable.Install.TableInstallException instance GHC.Exception.Type.Exception Graphics.Vty.UnicodeWidthTable.Install.TableInstallException module Graphics.Vty.UnicodeWidthTable.IO -- | Load a binary unicode width table from the specified file. -- -- This either returns a successfully parsed table or a table parsing -- error message. This does not handle I/O exceptions. readUnicodeWidthTable :: FilePath -> IO (Either String UnicodeWidthTable) -- | Parse a binary unicode width table. parseUnicodeWidthTable :: ByteString -> Either String UnicodeWidthTable -- | Write the unicode width table to the specified path. -- -- This does not handle I/O exceptions. writeUnicodeWidthTable :: FilePath -> UnicodeWidthTable -> IO () -- | This module provides a command-line tool implementation for building -- Vty character width tables and updating the user's local Vty -- configuration to load them. -- -- The API is parameterized on a platform-specific function to obtain -- character widths. For example, on Unix platforms, this could be done -- with a routine that communicates with the terminal to query it for -- character widths. On other platforms, such a routine might interact -- with a system library. -- -- This tool is provided as a library implementation so that the tool has -- a consistent interface across platforms and so that it implements the -- Vty configuration update the same way everywhere. module Graphics.Vty.UnicodeWidthTable.Main -- | Run the character width table builder tool using the specified -- function to obtain character widths. This is intended to be a -- main implementation, e.g. main = defaultMain -- getCharWidth. -- -- The tool queries the local terminal in some way (as determined by the -- provided function) over a wide range of Unicode code points and -- generates a table of character widths that can subsequently be loaded -- by Vty-based applications. -- -- The tool respects the following command-line flags, all of which are -- optional and have sensible defaults: -- -- defaultMain :: (Char -> IO Int) -> IO () instance GHC.Show.Show Graphics.Vty.UnicodeWidthTable.Main.Arg instance GHC.Classes.Eq Graphics.Vty.UnicodeWidthTable.Main.Arg instance GHC.Show.Show Graphics.Vty.UnicodeWidthTable.Main.Config -- | Vty provides interfaces for both terminal input and terminal output. -- -- -- -- As a small example, the following program demonstrates the use of Vty -- on a Unix system using the vty-unix package: -- --
--   import Graphics.Vty
--   import Graphics.Vty.Platform.Unix (mkVty)
--   
--   main = do
--       vty <- mkVty defaultConfig
--       let line0 = string (defAttr `withForeColor` green) "first line"
--           line1 = string (defAttr `withBackColor` blue) "second line"
--           img = line0 <-> line1
--           pic = picForImage img
--       update vty pic
--       e <- nextEvent vty
--       shutdown vty
--       print ("Last event was: " ++ show e)
--   
-- -- Vty uses threads internally, so programs made with Vty must be -- compiled with the threaded runtime using the GHC -threaded -- option. module Graphics.Vty -- | A Vty value represents a handle to the Vty library that the -- application must create in order to use Vty. -- -- The use of this library typically follows this process: -- --
    --
  1. Initialize Vty with the mkVty implementation for your -- platform's Vty package (e.g. vty-unix), or, more generically, -- with mkVtyFromPair. This takes control of (and sets up) the -- terminal.
  2. --
  3. Use update to display a picture.
  4. --
  5. Use nextEvent to get the next input event.
  6. --
  7. Depending on the event, go to 2 or 5.
  8. --
  9. Shutdown Vty and restore the terminal state with shutdown. -- At this point the Vty handle cannot be used again.
  10. --
-- -- Operations on Vty handles are not thread-safe. data Vty Vty :: (Picture -> IO ()) -> IO Event -> IO (Maybe Event) -> Input -> Output -> IO () -> IO () -> IO Bool -> Vty -- | Output the given Picture to the terminal. [update] :: Vty -> Picture -> IO () -- | Return the next Event or block until one becomes available. [nextEvent] :: Vty -> IO Event -- | Non-blocking version of nextEvent. [nextEventNonblocking] :: Vty -> IO (Maybe Event) -- | The input interface. See Input. [inputIface] :: Vty -> Input -- | The output interface. See Output. [outputIface] :: Vty -> Output -- | Refresh the display. If other programs output to the terminal and mess -- up the display then the application might want to force a refresh -- using this function. [refresh] :: Vty -> IO () -- | Clean up after vty. A call to this function is necessary to cleanly -- restore the terminal state before application exit. The above methods -- will throw an exception if executed after this is executed. -- Idempotent. [shutdown] :: Vty -> IO () [isShutdown] :: Vty -> IO Bool -- | Set the terminal window title string. setWindowTitle :: Vty -> String -> IO () -- | Attempt to load and install a custom character width table into this -- process. -- -- This looks up the specified terminal name in the specified width table -- map and, if a map file path is found, the map is loaded and installed. -- This is exposed for Vty platform package implementors; application -- developers should never need to call this. installCustomWidthTable :: Maybe FilePath -> Maybe String -> [(String, FilePath)] -> IO () -- | Build a Vty handle from an input/output pair. -- -- This is exposed for Vty platform package implementors; application -- developers should never need to call this, and should instead call -- mkVty or equivalent from their platform package of choice. mkVtyFromPair :: Input -> Output -> IO Vty -- | The inline module provides a limited interface to changing the style -- of terminal output. The intention is for this interface to be used -- inline with other output systems. -- -- The changes specified by the InlineM monad are applied to the -- terminal's display attributes. These display attributes affect the -- display of all following text output to the terminal file descriptor. -- -- For example, in an IO monad the following code will print the text -- "Not styled. " Followed by the text " Styled! " drawn over a red -- background and underlined. -- --
--   putStr "Not styled. "
--   putAttrChange_ $ do
--       backColor red
--       applyStyle underline
--   putStr " Styled! "
--   putAttrChange_ $ defaultAll
--   putStrLn "Not styled."
--   
-- -- putAttrChange emits the control codes to the terminal device -- attached to Handle. This is a duplicate of the stdout -- handle when the terminalHandle was (first) acquired. If -- stdout has since been changed then putStr, -- putStrLn, print etc. will output to a different -- Handle than putAttrChange. -- -- Copyright 2009-2010 Corey O'Connor module Graphics.Vty.Inline data InlineState InlineState :: Attr -> Bool -> InlineState [inlineAttr] :: InlineState -> Attr [inlineUrlsEnabled] :: InlineState -> Bool type InlineM v = State InlineState v -- | Set the background color to the provided Color. backColor :: Color -> InlineM () -- | Set the foreground color to the provided Color. foreColor :: Color -> InlineM () -- | Attempt to change the Style of the following text.. -- -- If the terminal does not support the style change then no error is -- produced. The style can still be removed. applyStyle :: Style -> InlineM () -- | Attempt to remove the specified Style from the display of the -- following text. -- -- This will fail if applyStyle for the given style has not been -- previously called. removeStyle :: Style -> InlineM () -- | Reset the display attributes. defaultAll :: InlineM () -- | Apply the provided display attribute changes to the given terminal -- output device. -- -- This does not flush the terminal. putAttrChange :: (Applicative m, MonadIO m) => Output -> InlineM () -> m () -- | Apply the provided display attributes changes to the terminal output -- device. -- -- This will flush the terminal output. putAttrChange_ :: (Applicative m, MonadIO m) => Output -> InlineM () -> m ()