packages feed

vty 5.30 → 5.31

raw patch · 10 files changed

+79/−12 lines, 10 files

Files

CHANGELOG.md view
@@ -1,4 +1,20 @@ +5.31+----++New features and API changes:+ * Added support for strikethrough mode. This change adds a new+   `strikethrough` `Style` value and uses the `smxx` and `rmxx`+   Terminfo capabilities to activate and deactivate strikethrough mode,+   respectively. If the terminfo does not report those capabilities,+   this style is ignored.+ * `Output`: added the `setDisplayBounds` field to set the output+   dimensions of the output handle; added an implementation of this for+   the `TerminfoBased` backend.++Other changes:+ * The C prototype for `vty_c_get_window_size` in `gwinsz.h` was fixed.+ 5.30 ---- 
LICENSE view
@@ -1,3 +1,5 @@+BSD 3-Clause License+ Copyright Stefan O'Rear 2006, Corey O'Connor 2008, Corey O'Connor 2009  All rights reserved.
cbits/gwinsz.c view
@@ -1,9 +1,18 @@ #include <sys/ioctl.h>  unsigned long vty_c_get_window_size(int fd) {-	struct winsize w;-	if (ioctl (fd, TIOCGWINSZ, &w) >= 0)-		return (w.ws_row << 16) + w.ws_col;-	else-		return 0x190050;+    struct winsize w;+    if (ioctl (fd, TIOCGWINSZ, &w) >= 0)+        return (w.ws_row << 16) + w.ws_col;+    else+        return 0x190050;+}++void vty_c_set_window_size(int fd, unsigned long val) {+    struct winsize w;+    if (ioctl(fd, TIOCGWINSZ, &w) >= 0) {+        w.ws_row = val >> 16;+        w.ws_col = val & 0xFFFF;+        ioctl(fd, TIOCSWINSZ, &w);+    } }
src/Graphics/Vty/Attributes.hs view
@@ -43,6 +43,7 @@   , withStyle   , standout   , italic+  , strikethrough   , underline   , reverseVideo   , blink@@ -181,7 +182,7 @@ -- if the style attribute should not be applied. type Style = Word8 --- | The 7 possible style attributes:+-- | Valid style attributes include: -- --      * standout --@@ -197,9 +198,11 @@ -- --      * italic --+--      * strikethrough (via the smxx/rmxx terminfo capabilities)+-- --  (The invisible, protect, and altcharset display attributes some --  terminals support are not supported via VTY.)-standout, underline, reverseVideo, blink, dim, bold, italic :: Style+standout, underline, reverseVideo, blink, dim, bold, italic, strikethrough :: Style standout        = 0x01 underline       = 0x02 reverseVideo    = 0x04@@ -207,6 +210,7 @@ dim             = 0x10 bold            = 0x20 italic          = 0x40+strikethrough   = 0x80  defaultStyleMask :: Style defaultStyleMask = 0x00
src/Graphics/Vty/DisplayAttributes.hs view
@@ -96,6 +96,8 @@     | RemoveStandout     | ApplyItalic     | RemoveItalic+    | ApplyStrikethrough+    | RemoveStrikethrough     | ApplyUnderline     | RemoveUnderline     | ApplyReverseVideo@@ -144,6 +146,7 @@     [ styleDiff standout      ApplyStandout     RemoveStandout     , styleDiff underline     ApplyUnderline    RemoveUnderline     , styleDiff italic        ApplyItalic       RemoveItalic+    , styleDiff strikethrough ApplyStrikethrough RemoveStrikethrough     , styleDiff reverseVideo  ApplyReverseVideo RemoveReverseVideo     , styleDiff blink         ApplyBlink        RemoveBlink     , styleDiff dim           ApplyDim          RemoveDim
src/Graphics/Vty/Output/Interface.hs view
@@ -73,6 +73,8 @@       -- | Return the display to the state before `reserveDisplay` If no       -- previous state then set the display state to the initial state.     , releaseDisplay :: IO ()+      -- | Sets the current display bounds (width, height).+    , setDisplayBounds :: (Int, Int) -> IO ()       -- | Returns the current display bounds.     , displayBounds :: IO DisplayRegion       -- | Output the bytestring to the terminal device.
src/Graphics/Vty/Output/Mock.hs view
@@ -48,6 +48,7 @@             , releaseDisplay = return ()             , ringTerminalBell = return ()             , supportsBell = return False+            , setDisplayBounds = const $ return ()             , displayBounds = return r             , outputByteBuffer = \bytes -> do                 putStrLn $ "mock outputByteBuffer of " ++ show (BS.length bytes) ++ " bytes"
src/Graphics/Vty/Output/TerminfoBased.hs view
@@ -10,10 +10,12 @@ -- Copyright Corey O'Connor (coreyoconnor@gmail.com) module Graphics.Vty.Output.TerminfoBased   ( reserveTerminal+  , setWindowSize   ) where  import Control.Monad (when)+import Data.Bits (shiftL) import qualified Data.ByteString as BS import Data.ByteString.Internal (toForeignPtr) import Data.Terminfo.Parse@@ -66,6 +68,8 @@     , exitStandout :: Maybe CapExpression     , enterItalic :: Maybe CapExpression     , exitItalic :: Maybe CapExpression+    , enterStrikethrough :: Maybe CapExpression+    , exitStrikethrough :: Maybe CapExpression     , enterUnderline :: Maybe CapExpression     , exitUnderline :: Maybe CapExpression     , enterReverseVideo :: Maybe CapExpression@@ -174,6 +178,8 @@             , releaseDisplay = do                 maybeSendCap rmcup []                 maybeSendCap cnorm []+            , setDisplayBounds = \(w, h) ->+                setWindowSize outFd (w, h)             , displayBounds = do                 rawSize <- getWindowSize outFd                 case rawSize of@@ -231,6 +237,8 @@     <*> probeCap ti "rmso"     <*> probeCap ti "sitm"     <*> probeCap ti "ritm"+    <*> probeCap ti "smxx"+    <*> probeCap ti "rmxx"     <*> probeCap ti "smul"     <*> probeCap ti "rmul"     <*> probeCap ti "rev"@@ -244,6 +252,13 @@     (a,b) <- (`divMod` 65536) `fmap` c_getWindowSize fd     return (fromIntegral b, fromIntegral a) +foreign import ccall "gwinsz.h vty_c_set_window_size" c_setWindowSize :: Fd -> CLong -> IO ()++setWindowSize :: Fd -> (Int, Int) -> IO ()+setWindowSize fd (w, h) = do+    let val = (h `shiftL` 16) + w+    c_setWindowSize fd $ fromIntegral val+ terminfoDisplayContext :: Output -> TerminfoCaps -> DisplayRegion -> IO DisplayContext terminfoDisplayContext tActual terminfoCaps r = return dc     where dc = DisplayContext@@ -259,7 +274,11 @@             , writeSetAttr = terminfoWriteSetAttr dc terminfoCaps             , writeDefaultAttr = \urlsEnabled ->                 writeCapExpr (setDefaultAttr terminfoCaps) [] `mappend`-                (if urlsEnabled then writeURLEscapes EndLink else mempty)+                (if urlsEnabled then writeURLEscapes EndLink else mempty) `mappend`+                (case exitStrikethrough $ displayAttrCaps terminfoCaps of+                    Just cap -> writeCapExpr cap []+                    Nothing -> mempty+                )             , writeRowEnd = writeCapExpr (clearEol terminfoCaps) []             , inlineHack = return ()             }@@ -337,6 +356,7 @@                                                )                                                (sgrArgsForState state)                                   `mappend` setItalics+                                  `mappend` setStrikethrough                                   `mappend` setColors         -- Otherwise the display colors are not changing or changing         -- between two non-default points.@@ -364,6 +384,7 @@                                                )                                                (sgrArgsForState state)                                   `mappend` setItalics+                                  `mappend` setStrikethrough                                   `mappend` setColors     where         urlAttrs True = writeURLEscapes (urlDiff diffs)@@ -381,6 +402,11 @@           , Just sitm <- enterItalic (displayAttrCaps terminfoCaps)           = writeCapExpr sitm []           | otherwise = mempty+        setStrikethrough+          | hasStyle (fixedStyle attr) strikethrough+          , Just smxx <- enterStrikethrough (displayAttrCaps terminfoCaps)+          = writeCapExpr smxx []+          | otherwise = mempty         setColors =             (case fixedForeColor attr of                 Just c -> writeCapExpr (setForeColor terminfoCaps)@@ -449,6 +475,7 @@     { applyStandout :: Bool     , applyUnderline :: Bool     , applyItalic :: Bool+    , applyStrikethrough :: Bool     , applyReverseVideo :: Bool     , applyBlink :: Bool     , applyDim :: Bool@@ -485,6 +512,8 @@         -- set state cap then just use the set state cap.         ( True, True  ) -> SetState $ stateForStyle s     where+        noEnterExitCap ApplyStrikethrough = isNothing $ enterStrikethrough caps+        noEnterExitCap RemoveStrikethrough = isNothing $ exitStrikethrough caps         noEnterExitCap ApplyItalic = isNothing $ enterItalic caps         noEnterExitCap RemoveItalic = isNothing $ exitItalic caps         noEnterExitCap ApplyStandout = isNothing $ enterStandout caps@@ -499,6 +528,8 @@         noEnterExitCap RemoveDim = True         noEnterExitCap ApplyBold = isNothing $ enterBoldMode caps         noEnterExitCap RemoveBold = True+        enterExitCap ApplyStrikethrough = fromJust $ enterStrikethrough caps+        enterExitCap RemoveStrikethrough = fromJust $ exitStrikethrough caps         enterExitCap ApplyItalic = fromJust $ enterItalic caps         enterExitCap RemoveItalic = fromJust $ exitItalic caps         enterExitCap ApplyStandout = fromJust $ enterStandout caps@@ -515,6 +546,7 @@     { applyStandout = isStyleSet standout     , applyUnderline = isStyleSet underline     , applyItalic = isStyleSet italic+    , applyStrikethrough = isStyleSet strikethrough     , applyReverseVideo = isStyleSet reverseVideo     , applyBlink = isStyleSet blink     , applyDim = isStyleSet dim@@ -527,6 +559,7 @@     [ applyIfRequired ApplyStandout standout     , applyIfRequired ApplyUnderline underline     , applyIfRequired ApplyItalic italic+    , applyIfRequired ApplyStrikethrough strikethrough     , applyIfRequired ApplyReverseVideo reverseVideo     , applyIfRequired ApplyBlink blink     , applyIfRequired ApplyDim dim
src/Graphics/Vty/Output/XTermColor.hs view
@@ -113,9 +113,6 @@ setUtf8CharSet = "\ESC%G" setDefaultCharSet = "\ESC%@" --- | I think xterm is broken: Reseting the background color as the first--- bytes serialized on a new line does not effect the background color--- xterm uses to clear the line. Which is used *after* the next newline. xtermInlineHack :: Output -> IO () xtermInlineHack t = do     let writeReset = foldMap (writeWord8.toEnum.fromEnum) "\ESC[K"
vty.cabal view
@@ -1,5 +1,5 @@ name:                vty-version:             5.30+version:             5.31 license:             BSD3 license-file:        LICENSE author:              AUTHORS