packages feed

vty-unix 0.2.0.0 → 0.3.0.0

raw patch · 4 files changed

+47/−15 lines, 4 filesdep ~basedep ~vtyPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: base, vty

API changes (from Hackage documentation)

- Graphics.Vty.Platform.Unix.Input.Classify.Parse: type Parser a = MaybeT (State ByteString) a
+ Graphics.Vty.Platform.Unix.Input.Classify.Parse: type Parser a = MaybeT State ByteString a

Files

CHANGELOG.md view
@@ -1,8 +1,19 @@ +0.3.0.0+=======++* Added support in `Input.Mouse` for parsing horizontal scrolling inputs+  to work with Vty 6.6.+* Improved the `vty-unix-build-width-table` tool (thanks Eric Mertens)+  to make it more robust when the terminal fails to recognize the+  `getCursorPosition` escape sequence.+ 0.2.0.0 =======  API changes:+* The `buildOutput` function in `Graphics.Vty.Platform.Unix.Output` now+  takes a new first argument of type `VtyUserConfig`. * The `settingColorMode` field of `UnixSettings` was removed in favor of   Vty 6.1's new `configPreferredColorMode` field of the `VtyUserConfig`   type. This package now uses that setting if present; otherwise it does
src/Graphics/Vty/Platform/Unix/Input/Mouse.hs view
@@ -83,12 +83,20 @@ rightButton :: Int rightButton = 2 +-- | See https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Wheel-mice scrollUp :: Int scrollUp = 64  scrollDown :: Int scrollDown = 65 +-- | See https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Other-buttons+scrollLeft :: Int+scrollLeft = 66++scrollRight :: Int+scrollRight = 67+ hasBitSet :: Int -> Int -> Bool hasBitSet val bit = val .&. bit > 0 @@ -113,6 +121,8 @@                     , (rightButton,  BRight)                     , (scrollUp,     BScrollUp)                     , (scrollDown,   BScrollDown)+                    , (scrollLeft,   BScrollLeft)+                    , (scrollRight,  BScrollRight)                     ]     in case lookup (mods .&. buttonMask) buttonMap of         Nothing -> failParse
tools/BuildWidthTable.hs view
@@ -1,18 +1,29 @@-{-# LANGUAGE ScopedTypeVariables #-}-{-# LANGUAGE CPP #-}-module Main where+module Main (main) where +import Graphics.Vty.UnicodeWidthTable.Main (defaultMain) import System.Console.ANSI (getCursorPosition)-import Text.Printf (printf) -import Graphics.Vty.UnicodeWidthTable.Main (defaultMain)+main :: IO ()+main = defaultMain charWidth +-- | The number of times we'll attempt to compute a character's width+-- before defaulting to @1@ and continuing.+attempts :: Int+attempts = 3++-- | Experimentally determine the console width of the character. charWidth :: Char -> IO Int-charWidth c = do-    printf "\r"-    putChar c-    Just (_, col) <- getCursorPosition-    return col+charWidth = charWidth' 0 -main :: IO ()-main = defaultMain charWidth+-- | Helper for 'charWidth' with the number of failed attempts counted.+charWidth' :: Int {- ^ failed attempts -} -> Char -> IO Int+charWidth' n c+    | n >= attempts =+     do putStrLn ("\rUnable to check: " ++ [c] ++ " (" ++ show c ++ ")")+        pure 1 -- fallback default to 1+    | otherwise =+     do putStr ['\r', c]+        mb <- getCursorPosition+        case mb of+            Nothing -> charWidth' (n+1) c+            Just (_, col) -> pure col
vty-unix.cabal view
@@ -1,6 +1,6 @@ cabal-version:      3.0 name:               vty-unix-version:            0.2.0.0+version:            0.3.0.0 synopsis:           Unix backend for Vty description:        This package provides Unix terminal support for Vty. license:            BSD-3-Clause@@ -53,7 +53,7 @@                       mtl,                       unix,                       terminfo,-                      vty >= 6.1,+                      vty >= 6.6,                       deepseq,                       vector,                       parsec,@@ -74,6 +74,6 @@   if !impl(ghc >= 8.0)     build-depends:     semigroups >= 0.16 -  build-depends:       base,+  build-depends:       base >= 4.8 && < 5,                        vty,                        ansi-terminal