on master help sign in
CHANGELOG.md+38
since splitsnapshots
unifiedsplit
@@ -1,4 +1,42 @@
1
1
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+
25.34
405.34
3----
41----
4
42
demos/Demo.hs+12−4
@@ -31,7 +31,8 @@ introText = vertCat $ map (string defAttr)
31 [ "this line is hidden by the top layer"
31 [ "this line is hidden by the top layer"
32 , "The vty demo program will echo the events generated by the pressed keys."
32 , "The vty demo program will echo the events generated by the pressed keys."
33 , "Below there is a 240 color box."
33 , "Below there is a 240 color box."
34− , "Followed by a description of the 16 color pallete."
34+ , "Followed by a description of the 16 color palette."
35+ , "Followed by tones of red using a 24-bit palette."
35 , "If the 240 color box is not visible then the terminal"
36 , "If the 240 color box is not visible then the terminal"
36 , "claims 240 colors are not supported."
37 , "claims 240 colors are not supported."
37 , "Try setting TERM to xterm-256color"
38 , "Try setting TERM to xterm-256color"
@@ -42,12 +43,19 @@ introText = vertCat $ map (string defAttr)
42 , "¯\\_(ツ)_/¯ ¯\\_(ツ)_/¯ ¯\\_(ツ)_/¯ ¯\\_(ツ)_/¯"
43 , "¯\\_(ツ)_/¯ ¯\\_(ツ)_/¯ ¯\\_(ツ)_/¯ ¯\\_(ツ)_/¯"
43 ]
44 ]
44
45
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+
45colorbox_240 :: Image
55colorbox_240 :: Image
46colorbox_240 = vertCat $ map horizCat $ splitColorImages colorImages
56colorbox_240 = vertCat $ map horizCat $ splitColorImages colorImages
47 where
57 where
48 colorImages = map (\i -> string (currentAttr `withBackColor` Color240 i) " ") [0..239]
58 colorImages = map (\i -> string (currentAttr `withBackColor` Color240 i) " ") [0..239]
49− splitColorImages [] = []
50− splitColorImages is = (take 20 is ++ [string defAttr " "]) : (splitColorImages (drop 20 is))
51
59
52colorbox_16 :: Image
60colorbox_16 :: Image
53colorbox_16 = border <|> column0 <|> border <|> column1 <|> border <|> column2 <|> border
61colorbox_16 = border <|> column0 <|> border <|> column1 <|> border <|> column2 <|> border
@@ -70,7 +78,7 @@ updateDisplay = do
70 "Press ESC to exit. Events for keys below."
78 "Press ESC to exit. Events for keys below."
71 eventLog <- foldMap (string defAttr) <$> get
79 eventLog <- foldMap (string defAttr) <$> get
72 let pic = picForImage (info <-> eventLog)
80 let pic = picForImage (info <-> eventLog)
73− `addToBottom` (introText <-> colorbox_240 <|> colorbox_16)
81+ `addToBottom` (introText <-> colorbox_240 <|> colorbox_16 <|> fullcolorbox)
74 vty <- ask
82 vty <- ask
75 liftIO $ update vty pic
83 liftIO $ update vty pic
76
84
src/Graphics/Vty/Attributes/Color.hs+6−12
@@ -49,7 +49,6 @@ where
49import Data.Word
49import Data.Word
50import GHC.Generics
50import GHC.Generics
51import Control.DeepSeq
51import Control.DeepSeq
52−import Text.Printf (printf)
53import System.Environment (lookupEnv)
52import System.Environment (lookupEnv)
54
53
55import qualified System.Console.Terminfo as Terminfo
54import qualified System.Console.Terminfo as Terminfo
@@ -96,7 +95,7 @@ import Graphics.Vty.Attributes.Color240
96-- reported then the color reproduction will be incorrect.
95-- reported then the color reproduction will be incorrect.
97--
96--
98-- If the terminal reports <= 16 colors then the 240 color palette
97-- If the terminal reports <= 16 colors then the 240 color palette
99−-- points are only mapped to the 8 color pallete. I'm not sure of
98+-- points are only mapped to the 8 color palette. I'm not sure of
100-- the RGB points for the "bright" colors which is why they are not
99-- the RGB points for the "bright" colors which is why they are not
101-- addressable via the 240 color palette.
100-- addressable via the 240 color palette.
102--
101--
@@ -158,18 +157,13 @@ brightMagenta= ISOColor 13
158brightCyan = ISOColor 14
157brightCyan = ISOColor 14
159brightWhite = ISOColor 15
158brightWhite = ISOColor 15
160
159
161−-- TODO: test this with other terminals
162linearColor :: Integral i => i -> i -> i -> Color
160linearColor :: Integral i => i -> i -> i -> Color
163−linearColor r g b
161+linearColor r g b = RGBColor 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'
168 where
162 where
169− r' = fromIntegral r :: Word8
163+ r' = fromIntegral (clamp r) :: Word8
170− g' = fromIntegral g :: Word8
164+ g' = fromIntegral (clamp g) :: Word8
171− b' = fromIntegral b :: Word8
165+ b' = fromIntegral (clamp b) :: Word8
172− makeError = error $ printf "invalid value in rgbColor: (%d, %d, %d)" r' g' b'
166+ clamp = min 255 . max 0
173
167
174srgbColor :: Integral i => i -> i -> i -> Color
168srgbColor :: Integral i => i -> i -> i -> Color
175srgbColor r g b =
169srgbColor r g b =
src/Graphics/Vty/Image.hs+1−1
@@ -137,7 +137,7 @@ char a c =
137 let displayWidth = safeWcwidth c
137 let displayWidth = safeWcwidth c
138 in HorizText a (TL.singleton c) displayWidth 1
138 in HorizText a (TL.singleton c) displayWidth 1
139
139
140−-- | Make an image from a string of characters layed out on a single
140+-- | Make an image from a string of characters laid out on a single
141-- row with the same display attribute. The string is assumed to be a
141-- row with the same display attribute. The string is assumed to be a
142-- sequence of ISO-10646 characters. The input string should be
142-- sequence of ISO-10646 characters. The input string should be
143-- sanitized of escape sequences (ASCII 27) and carriage returns;
143-- 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
228--
228--
229-- The result image will have a width equal to the sum of the two images
229-- The result image will have a width equal to the sum of the two images
230-- width. And the height will equal the largest height of the two
230-- 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 missmatch
231+-- images. The area not defined in one image due to a height mismatch
232-- will be filled with the background pattern.
232-- will be filled with the background pattern.
233horizJoin :: Image -> Image -> Image
233horizJoin :: Image -> Image -> Image
234horizJoin EmptyImage i = i
234horizJoin EmptyImage i = i
@@ -259,7 +259,7 @@ horizJoin _ _ = error "horizJoin applied to undefined values."
259--
259--
260-- The result image will have a height equal to the sum of the heights
260-- The result image will have a height equal to the sum of the heights
261-- of both images. The width will equal the largest width of the two
261-- 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 missmatch
262+-- images. The area not defined in one image due to a width mismatch
263-- will be filled with the background pattern.
263-- will be filled with the background pattern.
264vertJoin :: Image -> Image -> Image
264vertJoin :: Image -> Image -> Image
265vertJoin EmptyImage i = i
265vertJoin EmptyImage i = i
src/Graphics/Vty/Input.hs+2−2
@@ -77,7 +77,7 @@
77-- The input encoding determines how UTF-8 encoded characters are
77-- The input encoding determines how UTF-8 encoded characters are
78-- recognized.
78-- recognized.
79--
79--
80−-- * 7-bit mode: UTF-8 can be input unambiguiously. UTF-8 input is
80+-- * 7-bit mode: UTF-8 can be input unambiguously. UTF-8 input is
81-- a superset of ASCII. UTF-8 does not overlap escaped control key
81-- a superset of ASCII. UTF-8 does not overlap escaped control key
82-- sequences. However, the escape key must be differentiated from
82-- sequences. However, the escape key must be differentiated from
83-- escaped control key sequences by the timing of the input bytes.
83-- escaped control key sequences by the timing of the input bytes.
@@ -95,7 +95,7 @@
95--
95--
96-- == Terminal Input is Broken
96-- == Terminal Input is Broken
97--
97--
98−-- Clearly terminal input has fundemental issues. There is no easy way
98+-- Clearly terminal input has fundamental issues. There is no easy way
99-- to reliably resolve these issues.
99-- to reliably resolve these issues.
100--
100--
101-- One resolution would be to ditch standard terminal interfaces
101-- One resolution would be to ditch standard terminal interfaces
src/Graphics/Vty/Input/Mouse.hs+2−2
@@ -89,7 +89,7 @@ scrollDown = 65
89hasBitSet :: Int -> Int -> Bool
89hasBitSet :: Int -> Int -> Bool
90hasBitSet val bit = val .&. bit > 0
90hasBitSet val bit = val .&. bit > 0
91
91
92−-- | Attempt to lassify an input string as a mouse event.
92+-- | Attempt to classify an input string as a mouse event.
93classifyMouseEvent :: ByteString -> KClass
93classifyMouseEvent :: ByteString -> KClass
94classifyMouseEvent s = runParser s $ do
94classifyMouseEvent s = runParser s $ do
95 when (not $ isMouseEvent s) failParse
95 when (not $ isMouseEvent s) failParse
@@ -102,7 +102,7 @@ classifyMouseEvent s = runParser s $ do
102 'M' -> classifyNormalMouseEvent
102 'M' -> classifyNormalMouseEvent
103 _ -> failParse
103 _ -> failParse
104
104
105−-- Given a modifer/button value, determine which button was indicated
105+-- Given a modifier/button value, determine which button was indicated
106getSGRButton :: Int -> Parser Button
106getSGRButton :: Int -> Parser Button
107getSGRButton mods =
107getSGRButton mods =
108 let buttonMap = [ (leftButton, BLeft)
108 let buttonMap = [ (leftButton, BLeft)
src/Graphics/Vty/Output.hs+1−1
@@ -78,7 +78,7 @@ outputForConfig config = (<> config) <$> standardIOConfig >>= outputForConfig
78
78
79-- | Sets the cursor position to the given output column and row.
79-- | Sets the cursor position to the given output column and row.
80--
80--
81−-- This is not necessarially the same as the character position with the
81+-- This is not necessarily the same as the character position with the
82-- same coordinates. Characters can be a variable number of columns in
82-- same coordinates. Characters can be a variable number of columns in
83-- width.
83-- width.
84--
84--
src/Graphics/Vty/Output/Mock.hs+1−1
@@ -31,7 +31,7 @@ type MockData = IORef (UTF8.UTF8 BS.ByteString)
31-- without considering terminal specific issues.
31-- without considering terminal specific issues.
32--
32--
33-- The mock implementation is useful in manually determining if the
33-- The mock implementation is useful in manually determining if the
34−-- sequence of terminal operations matche the expected sequence. The
34+-- sequence of terminal operations matches the expected sequence. The
35-- requirement of the produced representation is simplicity in parsing
35-- requirement of the produced representation is simplicity in parsing
36-- the text representation and determining how the picture was mapped to
36-- the text representation and determining how the picture was mapped to
37-- terminal operations.
37-- terminal operations.
src/Graphics/Vty/Output/TerminfoBased.hs+2−2
@@ -453,8 +453,8 @@ hardcodeColor side (r, g, b) =
453-- | The color table used by a terminal is a 16 color set followed by a
453-- | The color table used by a terminal is a 16 color set followed by a
454-- 240 color set that might not be supported by the terminal.
454-- 240 color set that might not be supported by the terminal.
455--
455--
456−-- This takes a Color which clearly identifies which pallete to use and
456+-- This takes a Color which clearly identifies which palette to use and
457−-- computes the index into the full 256 color pallete.
457+-- computes the index into the full 256 color palette.
458ansiColorIndex :: Color -> Int
458ansiColorIndex :: Color -> Int
459ansiColorIndex (ISOColor v) = fromEnum v
459ansiColorIndex (ISOColor v) = fromEnum v
460ansiColorIndex (Color240 v) = 16 + fromEnum v
460ansiColorIndex (Color240 v) = 16 + fromEnum v
src/Graphics/Vty/PictureToSpans.hs+1−1
@@ -72,7 +72,7 @@ displayOpsForPic pic r = Vector.create (combinedOpsForLayers pic r)
72-- | Returns the DisplayOps for an image rendered to a window the size
72-- | Returns the DisplayOps for an image rendered to a window the size
73-- of the image.
73-- of the image.
74--
74--
75−-- largerly used only for debugging.
75+-- largely used only for debugging.
76displayOpsForImage :: Image -> DisplayOps
76displayOpsForImage :: Image -> DisplayOps
77displayOpsForImage i = displayOpsForPic (picForImage i) (imageWidth i, imageHeight i)
77displayOpsForImage i = displayOpsForPic (picForImage i) (imageWidth i, imageHeight i)
78
78
test/VerifyImageOps.hs+1−1
@@ -137,7 +137,7 @@ cropBottomLimitsHeight :: Image -> Int -> Property
137cropBottomLimitsHeight i v = v >= 0 ==>
137cropBottomLimitsHeight i v = v >= 0 ==>
138 v >= imageHeight (cropBottom v i)
138 v >= imageHeight (cropBottom v i)
139
139
140−-- rediculous tests just to satisfy my desire for nice code coverage :-P
140+-- ridiculous tests just to satisfy my desire for nice code coverage :-P
141canShowImage :: Image -> Bool
141canShowImage :: Image -> Bool
142canShowImage i = length (show i) > 0
142canShowImage i = length (show i) > 0
143
143
test/VerifyOutput.hs+6−2
@@ -1,4 +1,4 @@
1−-- We setup the environment to envoke certain terminals of interest.
1+-- We setup the environment to invoke certain terminals of interest.
2-- This assumes appropriate definitions exist in the current environment
2-- This assumes appropriate definitions exist in the current environment
3-- for the terminals of interest.
3-- for the terminals of interest.
4{-# LANGUAGE ScopedTypeVariables #-}
4{-# LANGUAGE ScopedTypeVariables #-}
@@ -35,7 +35,11 @@ smokeTestTermNonMac termName i = liftIOResult $ do
35smokeTestTerm :: String -> Image -> IO Result
35smokeTestTerm :: String -> Image -> IO Result
36smokeTestTerm termName i = do
36smokeTestTerm termName i = do
37 nullOut <- openFd "/dev/null" WriteOnly Nothing defaultFileFlags
37 nullOut <- openFd "/dev/null" WriteOnly Nothing defaultFileFlags
38− t <- outputForConfig $ defaultConfig { outputFd = Just nullOut, termName = Just termName }
38+ t <- outputForConfig $ defaultConfig
39+ { outputFd = Just nullOut
40+ , termName = Just termName
41+ , colorMode = Just NoColor
42+ }
39 -- putStrLn $ "context color count: " ++ show (contextColorCount t)
43 -- putStrLn $ "context color count: " ++ show (contextColorCount t)
40 reserveDisplay t
44 reserveDisplay t
41 dc <- displayContext t (100,100)
45 dc <- displayContext t (100,100)
test/VerifyUsingMockInput.hs+3−1
@@ -132,7 +132,9 @@ assertEventsFromSynInput table inputSpec expectedEvents = do
132 readLoop 0 = return ()
132 readLoop 0 = return ()
133 readLoop n = do
133 readLoop n = do
134 e <- atomically $ readTChan $ input^.eventChannel
134 e <- atomically $ readTChan $ input^.eventChannel
135+ case e of
135− modifyIORef eventsRef ((:) e)
136+ InputEvent ev -> modifyIORef eventsRef ((:) ev)
137+ ResumeAfterSignal -> return ()
136 readLoop (n - 1)
138 readLoop (n - 1)
137 genEventsUsingIoActions maxDuration writeWaitClose readEvents
139 genEventsUsingIoActions maxDuration writeWaitClose readEvents
138 outEvents <- reverse <$> readIORef eventsRef
140 outEvents <- reverse <$> readIORef eventsRef
test/interactive_terminal_test.hs+1−1
@@ -364,7 +364,7 @@ Did the test output match the description?
364|]
364|]
365 defaultSuccessConfirmResults
365 defaultSuccessConfirmResults
366
366
367−-- Explicitely definethe bytes that encode each example text.
367+-- Explicitly define the bytes that encode each example text.
368-- This avoids any issues with how the compiler represents string literals.
368-- This avoids any issues with how the compiler represents string literals.
369--
369--
370-- This document is UTF-8 encoded so the UTF-8 string is still included for
370-- This document is UTF-8 encoded so the UTF-8 string is still included for
vty.cabal+1−1
@@ -1,5 +1,5 @@
1name: vty
1name: vty
2−version: 5.34
2+version: 5.35.1
3license: BSD3
3license: BSD3
4license-file: LICENSE
4license-file: LICENSE
5author: AUTHORS
5author: AUTHORS