on d304192 help sign in
16 files changed+34−80
since splitsnapshots
unifiedsplit
CHANGELOG.md−38 demos/Demo.hs+4−12 src/Graphics/Vty/Attributes/Color.hs+12−6 src/Graphics/Vty/Image.hs+1−1 src/Graphics/Vty/Image/Internal.hs+2−2 src/Graphics/Vty/Input.hs+2−2 src/Graphics/Vty/Input/Mouse.hs+2−2 src/Graphics/Vty/Output.hs+1−1 src/Graphics/Vty/Output/Mock.hs+1−1 src/Graphics/Vty/Output/TerminfoBased.hs+2−2 src/Graphics/Vty/PictureToSpans.hs+1−1 test/VerifyImageOps.hs+1−1 test/VerifyOutput.hs+2−6 test/VerifyUsingMockInput.hs+1−3 test/interactive_terminal_test.hs+1−1 vty.cabal+1−1
CHANGELOG.md−38
@@ -1,42 +1,4 @@
11
2−5.35.1
3−------
4−
5−Bug fixes:
6− * Fixed a build issue with a test program.
7−
8−5.35
9−----
10−
11−New features:
12− * Add support for 24-bit color (thanks @u-quark). This change
13− updates Vty to look at the `COLORTERM` environment variable that is
14− conventionally used to advertise support for truecolor escape
15− sequences. The change also updates the Vty demo to demonstrate
16− 24-bit colors. This change also adds a new data type, `ColorMode`,
17− to represent the color mode in use, as well as an `Output` interface
18− field, `outputColorMode`, to track the active color mode and use it
19− to clamp emitted color escape sequences to the active color range.
20−
21−API changes:
22− * All types in `Graphics.Vty.Input.Events` now have strict constructor
23− fields.
24− * Internal events are now wrapped in a new `InternalEvent` type to
25− improve how signal handling is done. This change modifies the `Input`
26− type's event channel API to produce `InternalEvents`, not `Events`.
27− The new `InternalEvent` either wraps `Event` with the `InputEvent`
28− constructor (the previous behavior) or indicates that Vty resumed
29− after handling a signal using the `ResumeAfterSignal` constructor.
30− This change avoids the previous use of `EvResize` with lazy exception
31− arguments as a sentinel value for `ResumeAfterSignal`.
32−
33−Other enhancements:
34− * Bracketed paste parsing performance has been greatly improved thanks
35− to benchmarking and optimization work by @iphydf. As part of that
36− work, Vty now uses bytestrings rather than Strings internally when
37− parsing input to look for events.
38− * The `\b` value is now interpreted as `KBS` (thanks @vglfr)
39−
4025.34
413----
424
demos/Demo.hs+4−12
@@ -31,8 +31,7 @@ introText = vertCat $ map (string defAttr)
3131 [ "this line is hidden by the top layer"
3232 , "The vty demo program will echo the events generated by the pressed keys."
3333 , "Below there is a 240 color box."
34− , "Followed by a description of the 16 color palette."
35− , "Followed by tones of red using a 24-bit palette."
34+ , "Followed by a description of the 16 color pallete."
3635 , "If the 240 color box is not visible then the terminal"
3736 , "claims 240 colors are not supported."
3837 , "Try setting TERM to xterm-256color"
@@ -43,19 +42,12 @@ introText = vertCat $ map (string defAttr)
4342 , "¯\\_(ツ)_/¯ ¯\\_(ツ)_/¯ ¯\\_(ツ)_/¯ ¯\\_(ツ)_/¯"
4443 ]
4544
46−splitColorImages :: [Image] -> [[Image]]
47−splitColorImages [] = []
48−splitColorImages is = (take 20 is ++ [string defAttr " "]) : (splitColorImages (drop 20 is))
49−
50−fullcolorbox :: Image
51−fullcolorbox = vertCat $ map horizCat $ splitColorImages colorImages
52− where
53− colorImages = map (\i -> string (currentAttr `withBackColor` linearColor i 0 0) " ") [0..255]
54−
5545colorbox_240 :: Image
5646colorbox_240 = vertCat $ map horizCat $ splitColorImages colorImages
5747 where
5848 colorImages = map (\i -> string (currentAttr `withBackColor` Color240 i) " ") [0..239]
49+ splitColorImages [] = []
50+ splitColorImages is = (take 20 is ++ [string defAttr " "]) : (splitColorImages (drop 20 is))
5951
6052colorbox_16 :: Image
6153colorbox_16 = border <|> column0 <|> border <|> column1 <|> border <|> column2 <|> border
@@ -78,7 +70,7 @@ updateDisplay = do
7870 "Press ESC to exit. Events for keys below."
7971 eventLog <- foldMap (string defAttr) <$> get
8072 let pic = picForImage (info <-> eventLog)
81− `addToBottom` (introText <-> colorbox_240 <|> colorbox_16 <|> fullcolorbox)
73+ `addToBottom` (introText <-> colorbox_240 <|> colorbox_16)
8274 vty <- ask
8375 liftIO $ update vty pic
8476
src/Graphics/Vty/Attributes/Color.hs+12−6
@@ -49,6 +49,7 @@ where
4949import Data.Word
5050import GHC.Generics
5151import Control.DeepSeq
52+import Text.Printf (printf)
5253import System.Environment (lookupEnv)
5354
5455import qualified System.Console.Terminfo as Terminfo
@@ -95,7 +96,7 @@ import Graphics.Vty.Attributes.Color240
9596-- reported then the color reproduction will be incorrect.
9697--
9798-- If the terminal reports <= 16 colors then the 240 color palette
98−-- points are only mapped to the 8 color palette. I'm not sure of
99+-- points are only mapped to the 8 color pallete. I'm not sure of
99100-- the RGB points for the "bright" colors which is why they are not
100101-- addressable via the 240 color palette.
101102--
@@ -157,13 +158,18 @@ brightMagenta= ISOColor 13
157158brightCyan = ISOColor 14
158159brightWhite = ISOColor 15
159160
161+-- TODO: test this with other terminals
160162linearColor :: Integral i => i -> i -> i -> Color
161−linearColor r g b = RGBColor r' g' b'
163+linearColor r g b
164+ | r < 0 || r > 255 = makeError
165+ | g < 0 || g > 255 = makeError
166+ | b < 0 || b > 255 = makeError
167+ | otherwise = RGBColor r' g' b'
162168 where
163− r' = fromIntegral (clamp r) :: Word8
164− g' = fromIntegral (clamp g) :: Word8
165− b' = fromIntegral (clamp b) :: Word8
166− clamp = min 255 . max 0
169+ r' = fromIntegral r :: Word8
170+ g' = fromIntegral g :: Word8
171+ b' = fromIntegral b :: Word8
172+ makeError = error $ printf "invalid value in rgbColor: (%d, %d, %d)" r' g' b'
167173
168174srgbColor :: Integral i => i -> i -> i -> Color
169175srgbColor r g b =
src/Graphics/Vty/Image.hs+1−1
@@ -137,7 +137,7 @@ char a c =
137137 let displayWidth = safeWcwidth c
138138 in HorizText a (TL.singleton c) displayWidth 1
139139
140−-- | Make an image from a string of characters laid out on a single
140+-- | Make an image from a string of characters layed out on a single
141141-- row with the same display attribute. The string is assumed to be a
142142-- sequence of ISO-10646 characters. The input string should be
143143-- sanitized of escape sequences (ASCII 27) and carriage returns;
src/Graphics/Vty/Image/Internal.hs+2−2
@@ -228,7 +228,7 @@ instance Monoid Image where
228228--
229229-- The result image will have a width equal to the sum of the two images
230230-- width. And the height will equal the largest height of the two
231−-- images. The area not defined in one image due to a height mismatch
231+-- images. The area not defined in one image due to a height missmatch
232232-- will be filled with the background pattern.
233233horizJoin :: Image -> Image -> Image
234234horizJoin EmptyImage i = i
@@ -259,7 +259,7 @@ horizJoin _ _ = error "horizJoin applied to undefined values."
259259--
260260-- The result image will have a height equal to the sum of the heights
261261-- of both images. The width will equal the largest width of the two
262−-- images. The area not defined in one image due to a width mismatch
262+-- images. The area not defined in one image due to a width missmatch
263263-- will be filled with the background pattern.
264264vertJoin :: Image -> Image -> Image
265265vertJoin EmptyImage i = i
src/Graphics/Vty/Input.hs+2−2
@@ -77,7 +77,7 @@
7777-- The input encoding determines how UTF-8 encoded characters are
7878-- recognized.
7979--
80−-- * 7-bit mode: UTF-8 can be input unambiguously. UTF-8 input is
80+-- * 7-bit mode: UTF-8 can be input unambiguiously. UTF-8 input is
8181-- a superset of ASCII. UTF-8 does not overlap escaped control key
8282-- sequences. However, the escape key must be differentiated from
8383-- escaped control key sequences by the timing of the input bytes.
@@ -95,7 +95,7 @@
9595--
9696-- == Terminal Input is Broken
9797--
98−-- Clearly terminal input has fundamental issues. There is no easy way
98+-- Clearly terminal input has fundemental issues. There is no easy way
9999-- to reliably resolve these issues.
100100--
101101-- One resolution would be to ditch standard terminal interfaces
src/Graphics/Vty/Input/Mouse.hs+2−2
@@ -89,7 +89,7 @@ scrollDown = 65
8989hasBitSet :: Int -> Int -> Bool
9090hasBitSet val bit = val .&. bit > 0
9191
92−-- | Attempt to classify an input string as a mouse event.
92+-- | Attempt to lassify an input string as a mouse event.
9393classifyMouseEvent :: ByteString -> KClass
9494classifyMouseEvent s = runParser s $ do
9595 when (not $ isMouseEvent s) failParse
@@ -102,7 +102,7 @@ classifyMouseEvent s = runParser s $ do
102102 'M' -> classifyNormalMouseEvent
103103 _ -> failParse
104104
105−-- Given a modifier/button value, determine which button was indicated
105+-- Given a modifer/button value, determine which button was indicated
106106getSGRButton :: Int -> Parser Button
107107getSGRButton mods =
108108 let buttonMap = [ (leftButton, BLeft)
src/Graphics/Vty/Output.hs+1−1
@@ -78,7 +78,7 @@ outputForConfig config = (<> config) <$> standardIOConfig >>= outputForConfig
7878
7979-- | Sets the cursor position to the given output column and row.
8080--
81−-- This is not necessarily the same as the character position with the
81+-- This is not necessarially the same as the character position with the
8282-- same coordinates. Characters can be a variable number of columns in
8383-- width.
8484--
src/Graphics/Vty/Output/Mock.hs+1−1
@@ -31,7 +31,7 @@ type MockData = IORef (UTF8.UTF8 BS.ByteString)
3131-- without considering terminal specific issues.
3232--
3333-- The mock implementation is useful in manually determining if the
34−-- sequence of terminal operations matches the expected sequence. The
34+-- sequence of terminal operations matche the expected sequence. The
3535-- requirement of the produced representation is simplicity in parsing
3636-- the text representation and determining how the picture was mapped to
3737-- terminal operations.
src/Graphics/Vty/Output/TerminfoBased.hs+2−2
@@ -453,8 +453,8 @@ hardcodeColor side (r, g, b) =
453453-- | The color table used by a terminal is a 16 color set followed by a
454454-- 240 color set that might not be supported by the terminal.
455455--
456−-- This takes a Color which clearly identifies which palette to use and
457−-- computes the index into the full 256 color palette.
456+-- This takes a Color which clearly identifies which pallete to use and
457+-- computes the index into the full 256 color pallete.
458458ansiColorIndex :: Color -> Int
459459ansiColorIndex (ISOColor v) = fromEnum v
460460ansiColorIndex (Color240 v) = 16 + fromEnum v
src/Graphics/Vty/PictureToSpans.hs+1−1
@@ -72,7 +72,7 @@ displayOpsForPic pic r = Vector.create (combinedOpsForLayers pic r)
7272-- | Returns the DisplayOps for an image rendered to a window the size
7373-- of the image.
7474--
75−-- largely used only for debugging.
75+-- largerly used only for debugging.
7676displayOpsForImage :: Image -> DisplayOps
7777displayOpsForImage i = displayOpsForPic (picForImage i) (imageWidth i, imageHeight i)
7878
test/VerifyImageOps.hs+1−1
@@ -137,7 +137,7 @@ cropBottomLimitsHeight :: Image -> Int -> Property
137137cropBottomLimitsHeight i v = v >= 0 ==>
138138 v >= imageHeight (cropBottom v i)
139139
140−-- ridiculous tests just to satisfy my desire for nice code coverage :-P
140+-- rediculous tests just to satisfy my desire for nice code coverage :-P
141141canShowImage :: Image -> Bool
142142canShowImage i = length (show i) > 0
143143
test/VerifyOutput.hs+2−6
@@ -1,4 +1,4 @@
1−-- We setup the environment to invoke certain terminals of interest.
1+-- We setup the environment to envoke certain terminals of interest.
22-- This assumes appropriate definitions exist in the current environment
33-- for the terminals of interest.
44{-# LANGUAGE ScopedTypeVariables #-}
@@ -35,11 +35,7 @@ smokeTestTermNonMac termName i = liftIOResult $ do
3535smokeTestTerm :: String -> Image -> IO Result
3636smokeTestTerm termName i = do
3737 nullOut <- openFd "/dev/null" WriteOnly Nothing defaultFileFlags
38− t <- outputForConfig $ defaultConfig
39− { outputFd = Just nullOut
40− , termName = Just termName
41− , colorMode = Just NoColor
42− }
38+ t <- outputForConfig $ defaultConfig { outputFd = Just nullOut, termName = Just termName }
4339 -- putStrLn $ "context color count: " ++ show (contextColorCount t)
4440 reserveDisplay t
4541 dc <- displayContext t (100,100)
test/VerifyUsingMockInput.hs+1−3
@@ -132,9 +132,7 @@ assertEventsFromSynInput table inputSpec expectedEvents = do
132132 readLoop 0 = return ()
133133 readLoop n = do
134134 e <- atomically $ readTChan $ input^.eventChannel
135− case e of
136− InputEvent ev -> modifyIORef eventsRef ((:) ev)
137− ResumeAfterSignal -> return ()
135+ modifyIORef eventsRef ((:) e)
138136 readLoop (n - 1)
139137 genEventsUsingIoActions maxDuration writeWaitClose readEvents
140138 outEvents <- reverse <$> readIORef eventsRef
test/interactive_terminal_test.hs+1−1
@@ -364,7 +364,7 @@ Did the test output match the description?
364364|]
365365 defaultSuccessConfirmResults
366366
367−-- Explicitly define the bytes that encode each example text.
367+-- Explicitely definethe bytes that encode each example text.
368368-- This avoids any issues with how the compiler represents string literals.
369369--
370370-- This document is UTF-8 encoded so the UTF-8 string is still included for
vty.cabal+1−1
@@ -1,5 +1,5 @@
11name: vty
2−version: 5.35.1
2+version: 5.34
33license: BSD3
44license-file: LICENSE
55author: AUTHORS