packages feed

vty 5.16 → 5.17

raw patch · 23 files changed

+83/−75 lines, 23 files

Files

CHANGELOG.md view
@@ -1,3 +1,15 @@+5.17+API changes:+ - Add support for terminal focus events. This change adds a new mode+   usable with setMode, Focus, that requests that the terminal send+   events on focus lose/gain. This change also adds two new Event+   constructors, EvLostFocus and EvGainedFocus.+ - No longer enable UTF8 mouse event encoding. This encoding was not+   working properly with Terminal.app, and using the other modes (SGR,+   etc.) work.+ - Graphics.Vty.Attributes: escape backticks in Haddock comment (fixes+   #131)+ 5.16 API changes:   - Added support for mouse wheel events while in mouse mode. The Button
− dist/build/verify-attribute-opsStub/verify-attribute-opsStub-tmp/verify-attribute-opsStub.hs
@@ -1,5 +0,0 @@-module Main ( main ) where-import Distribution.Simple.Test.LibV09 ( stubMain )-import VerifyAttributeOps ( tests )-main :: IO ()-main = stubMain tests
− dist/build/verify-crop-span-generationStub/verify-crop-span-generationStub-tmp/verify-crop-span-generationStub.hs
@@ -1,5 +0,0 @@-module Main ( main ) where-import Distribution.Simple.Test.LibV09 ( stubMain )-import VerifyCropSpanGeneration ( tests )-main :: IO ()-main = stubMain tests
− dist/build/verify-display-attributesStub/verify-display-attributesStub-tmp/verify-display-attributesStub.hs
@@ -1,5 +0,0 @@-module Main ( main ) where-import Distribution.Simple.Test.LibV09 ( stubMain )-import VerifyDisplayAttributes ( tests )-main :: IO ()-main = stubMain tests
− dist/build/verify-empty-image-propsStub/verify-empty-image-propsStub-tmp/verify-empty-image-propsStub.hs
@@ -1,5 +0,0 @@-module Main ( main ) where-import Distribution.Simple.Test.LibV09 ( stubMain )-import VerifyEmptyImageProps ( tests )-main :: IO ()-main = stubMain tests
− dist/build/verify-eval-terminfo-capsStub/verify-eval-terminfo-capsStub-tmp/verify-eval-terminfo-capsStub.hs
@@ -1,5 +0,0 @@-module Main ( main ) where-import Distribution.Simple.Test.LibV09 ( stubMain )-import VerifyEvalTerminfoCaps ( tests )-main :: IO ()-main = stubMain tests
− dist/build/verify-image-opsStub/verify-image-opsStub-tmp/verify-image-opsStub.hs
@@ -1,5 +0,0 @@-module Main ( main ) where-import Distribution.Simple.Test.LibV09 ( stubMain )-import VerifyImageOps ( tests )-main :: IO ()-main = stubMain tests
− dist/build/verify-image-transStub/verify-image-transStub-tmp/verify-image-transStub.hs
@@ -1,5 +0,0 @@-module Main ( main ) where-import Distribution.Simple.Test.LibV09 ( stubMain )-import VerifyImageTrans ( tests )-main :: IO ()-main = stubMain tests
− dist/build/verify-inlineStub/verify-inlineStub-tmp/verify-inlineStub.hs
@@ -1,5 +0,0 @@-module Main ( main ) where-import Distribution.Simple.Test.LibV09 ( stubMain )-import VerifyInline ( tests )-main :: IO ()-main = stubMain tests
− dist/build/verify-layers-span-generationStub/verify-layers-span-generationStub-tmp/verify-layers-span-generationStub.hs
@@ -1,5 +0,0 @@-module Main ( main ) where-import Distribution.Simple.Test.LibV09 ( stubMain )-import VerifyLayersSpanGeneration ( tests )-main :: IO ()-main = stubMain tests
− dist/build/verify-parse-terminfo-capsStub/verify-parse-terminfo-capsStub-tmp/verify-parse-terminfo-capsStub.hs
@@ -1,5 +0,0 @@-module Main ( main ) where-import Distribution.Simple.Test.LibV09 ( stubMain )-import VerifyParseTerminfoCaps ( tests )-main :: IO ()-main = stubMain tests
− dist/build/verify-simple-span-generationStub/verify-simple-span-generationStub-tmp/verify-simple-span-generationStub.hs
@@ -1,5 +0,0 @@-module Main ( main ) where-import Distribution.Simple.Test.LibV09 ( stubMain )-import VerifySimpleSpanGeneration ( tests )-main :: IO ()-main = stubMain tests
− dist/build/verify-terminalStub/verify-terminalStub-tmp/verify-terminalStub.hs
@@ -1,5 +0,0 @@-module Main ( main ) where-import Distribution.Simple.Test.LibV09 ( stubMain )-import VerifyOutput ( tests )-main :: IO ()-main = stubMain tests
− dist/build/verify-using-mock-terminalStub/verify-using-mock-terminalStub-tmp/verify-using-mock-terminalStub.hs
@@ -1,5 +0,0 @@-module Main ( main ) where-import Distribution.Simple.Test.LibV09 ( stubMain )-import VerifyUsingMockTerminal ( tests )-main :: IO ()-main = stubMain tests
− dist/build/verify-utf8-widthStub/verify-utf8-widthStub-tmp/verify-utf8-widthStub.hs
@@ -1,5 +0,0 @@-module Main ( main ) where-import Distribution.Simple.Test.LibV09 ( stubMain )-import VerifyUtf8Width ( tests )-main :: IO ()-main = stubMain tests
src/Graphics/Vty/Attributes.hs view
@@ -10,14 +10,14 @@ -- 'withForeColor', 'withBackColor', and 'withStyle', e.g., -- -- @---     defAttr `withForeColor` red+--     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"+--     string (defAttr \`withForeColor\` red) "this text will be red" -- @ -- -- The appearance of 'Image's using 'defAttr' is determined by the The
src/Graphics/Vty/Input/Classify.hs view
@@ -10,6 +10,7 @@  import Graphics.Vty.Input.Events import Graphics.Vty.Input.Mouse+import Graphics.Vty.Input.Focus import Graphics.Vty.Input.Paste import Graphics.Vty.Input.Classify.Types @@ -59,6 +60,7 @@             then parseBracketedPaste s             else Prefix         _ | isMouseEvent s   -> classifyMouseEvent s+        _ | isFocusEvent s   -> classifyFocusEvent s         c:cs | ord c >= 0xC2 -> classifyUtf8 c cs         _                    -> standardClassifier s 
src/Graphics/Vty/Input/Events.hs view
@@ -56,6 +56,10 @@     -- 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.+    | EvLostFocus+    -- ^ The terminal running the application lost input focus.+    | EvGainedFocus+    -- ^ The terminal running the application gained input focus.     deriving (Eq,Show,Read,Ord,Generic)  type ClassifyMap = [(String,Event)]
+ src/Graphics/Vty/Input/Focus.hs view
@@ -0,0 +1,47 @@+module Graphics.Vty.Input.Focus+  ( requestFocusEvents+  , disableFocusEvents+  , isFocusEvent+  , classifyFocusEvent+  )+where++import Graphics.Vty.Input.Events+import Graphics.Vty.Input.Classify.Types+import Graphics.Vty.Input.Classify.Parse++import Control.Monad.State+import Data.List (isPrefixOf)++-- | These sequences set xterm-based terminals to send focus event+-- sequences.+requestFocusEvents :: String+requestFocusEvents = "\ESC[?1004h"++-- | These sequences disable focus events.+disableFocusEvents :: String+disableFocusEvents = "\ESC[?1004l"++-- | Does the specified string begin with a focus event?+isFocusEvent :: String -> Bool+isFocusEvent s = isPrefixOf focusIn s ||+                 isPrefixOf focusOut s++focusIn :: String+focusIn = "\ESC[I"++focusOut :: String+focusOut = "\ESC[O"++-- | Attempt to classify an input string as a focus event.+classifyFocusEvent :: String -> KClass+classifyFocusEvent s = runParser s $ do+    when (not $ isFocusEvent s) failParse++    expectChar '\ESC'+    expectChar '['+    ty <- readChar+    case ty of+        'I' -> return EvGainedFocus+        'O' -> return EvLostFocus+        _   -> failParse
src/Graphics/Vty/Input/Mouse.hs view
@@ -33,11 +33,11 @@ -- | These sequences set xterm-based terminals to send mouse event -- sequences. requestMouseEvents :: String-requestMouseEvents = "\ESC[?1000h\ESC[?1002h\ESC[?1006h\ESC[?1005h"+requestMouseEvents = "\ESC[?1000h\ESC[?1002h\ESC[?1006h"  -- | These sequences disable mouse events. disableMouseEvents :: String-disableMouseEvents = "\ESC[?1000l\ESC[?1002l\ESC[?1006l\ESC[?1005l"+disableMouseEvents = "\ESC[?1000l\ESC[?1002l\ESC[?1006l"  -- | Does the specified string begin with a mouse event? isMouseEvent :: String -> Bool
src/Graphics/Vty/Output/Interface.hs view
@@ -44,6 +44,9 @@           | BracketedPaste           -- ^ Paste mode (whether the terminal is configured to provide           -- events on OS pastes)+          | Focus+          -- ^ Focus-in/focus-out events (whether the terminal is+          -- configured to provide events on focus change)           deriving (Eq, Read, Show)  -- | The Vty terminal output interface.
src/Graphics/Vty/Output/XTermColor.hs view
@@ -8,6 +8,7 @@  import Graphics.Vty.Output.Interface import Graphics.Vty.Input.Mouse+import Graphics.Vty.Input.Focus import qualified Graphics.Vty.Output.TerminfoBased as TerminfoBased  import Blaze.ByteString.Builder (writeToByteString)@@ -38,12 +39,18 @@     t <- TerminfoBased.reserveTerminal variant' outFd      mouseModeStatus <- newIORef False+    focusModeStatus <- newIORef False     pasteModeStatus <- newIORef False      let xtermSetMode t' m newStatus = do           curStatus <- getModeStatus t' m           when (newStatus /= curStatus) $               case m of+                  Focus -> liftIO $ do+                      case newStatus of+                          True -> flushedPut requestFocusEvents+                          False -> flushedPut disableFocusEvents+                      writeIORef focusModeStatus newStatus                   Mouse -> liftIO $ do                       case newStatus of                           True -> flushedPut requestMouseEvents@@ -56,6 +63,7 @@                       writeIORef pasteModeStatus newStatus          xtermGetMode Mouse = liftIO $ readIORef mouseModeStatus+        xtermGetMode Focus = liftIO $ readIORef focusModeStatus         xtermGetMode BracketedPaste = liftIO $ readIORef pasteModeStatus      let t' = t@@ -64,6 +72,7 @@                  when (not utf8a) $ liftIO $ flushedPut setDefaultCharSet                  setMode t' BracketedPaste False                  setMode t' Mouse False+                 setMode t' Focus False                  releaseTerminal t              , mkDisplayContext = \tActual r -> do                 dc <- mkDisplayContext t tActual r
vty.cabal view
@@ -1,5 +1,5 @@ name:                vty-version:             5.16+version:             5.17 license:             BSD3 license-file:        LICENSE author:              AUTHORS@@ -85,6 +85,7 @@                        Graphics.Vty.Input.Classify.Parse                        Graphics.Vty.Input.Loop                        Graphics.Vty.Input.Mouse+                       Graphics.Vty.Input.Focus                        Graphics.Vty.Input.Paste                        Graphics.Vty.Input.Terminfo                        Graphics.Vty.PictureToSpans