packages feed

reflex-vty 0.5.1.0 → 0.5.2.0

raw patch · 5 files changed

+38/−17 lines, 5 filesdep +vty-crossplatformdep ~basedep ~hspecdep ~primitive

Dependencies added: vty-crossplatform

Dependency ranges changed: base, hspec, primitive, vty

Files

ChangeLog.md view
@@ -1,9 +1,13 @@ # Revision history for reflex-vty +## 0.5.2.0+* Update to use latest version of vty (for cross-platform support)+* Fix an issue where the cursor tag is not used for an empty string in `displayLineWithAlignment`+   ## 0.5.1.0- * Change `inputInFocusedRegion` to filter mouse scroll wheel input based on if the region under than the mouse rather than using mouse drag tracking * Add MonadCatch, MonadThrow, and MonadMask instances (relies on reflex-0.9.2.0 or greater)+  ## 0.5.0.0 
reflex-vty.cabal view
@@ -1,5 +1,5 @@ name: reflex-vty-version: 0.5.1.0+version: 0.5.2.0 synopsis: Reflex FRP host and widgets for VTY applications description:   Build terminal applications using functional reactive programming (FRP) with Reflex FRP (<https://reflex-frp.org>).@@ -40,7 +40,7 @@                  , Reflex.Spider.Orphans                  , Control.Monad.NodeId   build-depends:-    base >= 4.10.0 && < 4.19,+    base >= 4.10.0 && < 4.20,     bimap >= 0.3.3 && < 0.6,     containers >= 0.5.0 && < 0.7,     mtl >= 2.2.2 && < 2.4,@@ -58,7 +58,8 @@     ref-tf >= 0.4.0 && < 0.6,     reflex >= 0.9.2 && < 1,     time >= 1.8.0 && < 1.13,-    vty >= 5.28 && < 5.39+    vty >= 6.0 && < 6.2,+    vty-crossplatform >= 0.1 && < 0.5   hs-source-dirs: src   default-language: Haskell2010   ghc-options: -Wall
src/Data/Text/Zipper.hs view
@@ -404,9 +404,11 @@  -- | converts deleted eol spaces into logical lines eolSpacesToLogicalLines :: [[WrappedLine]] -> [[(Text, Int)]]-eolSpacesToLogicalLines = fmap (fmap (\(WrappedLine a _ c) -> (a,c))) . ((L.groupBy (\(WrappedLine _ b _) _ -> not b)) =<<)+eolSpacesToLogicalLines = fmap (fmap (\(WrappedLine a _ c) -> (a,c))) .  concatMap (L.groupBy (\(WrappedLine _ b _) _ -> not b)) --- | Convert logical lines to a map of displayed rows of aligned text+offsetMapWithAlignmentInternal :: [[WrappedLine]] -> OffsetMapWithAlignment+offsetMapWithAlignmentInternal = offsetMapWithAlignment . eolSpacesToLogicalLines+ offsetMapWithAlignment   :: [[(Text, Int)]] -- ^ The outer list represents logical lines, inner list represents wrapped lines   -> OffsetMapWithAlignment@@ -423,9 +425,6 @@       -- add additional offset to last line in wrapped lines (for newline char)       return $ Map.adjust (\(align,_)->(align,o+1)) dl $ Map.unions maps --- | Convert logical lines to a map of displayed rows of aligned text-offsetMapWithAlignmentInternal :: [[WrappedLine]] -> OffsetMapWithAlignment-offsetMapWithAlignmentInternal = offsetMapWithAlignment . eolSpacesToLogicalLines  -- | Given a width and a 'TextZipper', produce a list of display lines -- (i.e., lines of wrapped text) with special attributes applied to@@ -469,7 +468,7 @@       -- map to spans and highlight the cursor       -- accumulator type (accumulated text length, Either (current y position) (cursor y and x position))       --mapaccumlfn :: (Int, Either Int (Int, Int)) -> WrappedLine -> ((Int, Either Int (Int, Int)), [Span tag])-      mapaccumlfn (acclength, ecpos') (WrappedLine t dwseol xoff) = r where+      mapaccumlfn (acclength, ecpos) (WrappedLine t dwseol xoff) = r where         tlength = T.length t         -- how many words we've gone through         nextacclength = acclength + tlength + if dwseol then 1 else 0@@ -478,7 +477,7 @@         charsbeforecursor = blength-acclength         ctlength = textWidth $ T.take charsbeforecursor t         cursorx = xoff + ctlength-        nextecpos = case ecpos' of+        nextecpos = case ecpos of           Left y -> if cursoroncurspan             then if ctlength == width               -- cursor wraps to next line case@@ -496,15 +495,15 @@         r = if cursoroncurspan           then (nextacc, cursorspans)           else (nextacc, [Span tag t])-      ((_, ecpos), curlinespans) = if T.null curlinetext+      ((_, ecpos_out), curlinespans) = if T.null curlinetext         -- manually handle empty case because mapaccumlfn doesn't handle it-        then ((0, Right (0, alignmentOffset alignment width "")), [[Span tag ""]])+        then ((0, Right (0, alignmentOffset alignment width "")), [[Span cursorTag ""]])         else L.mapAccumL mapaccumlfn (0, Left 0) curwrappedlines -      (cursorY', cursorX) = case ecpos of+      (cursorY', cursorX) = case ecpos_out of         Right (y,x) -> (y,x)         -- if we never hit the cursor position, this means it's at the beginning of the next line-        Left y -> (y+1, alignmentOffset alignment width "")+        Left y      -> (y+1, alignmentOffset alignment width "")       cursorY = cursorY' + length spansBefore    in  DisplayLines
src/Reflex/Vty/Host.hs view
@@ -30,6 +30,8 @@ import Reflex.Host.Class import Reflex.Spider.Orphans () import qualified Graphics.Vty as V+import qualified Graphics.Vty.CrossPlatform as V+ import Graphics.Vty (DisplayRegion)  -- | A synonym for the underlying vty event type from 'Graphics.Vty'. This should@@ -230,5 +232,8 @@ -- | Returns the standard vty configuration with mouse mode enabled. getDefaultVty :: IO V.Vty getDefaultVty = do-  cfg <- V.standardIOConfig-  V.mkVty $ cfg { V.mouseMode = Just True }+  cfg <- V.userConfig+  vty <- V.mkVty cfg+  liftIO $ V.setMode (V.outputIface vty) V.Mouse True+  return vty+
test/Data/Text/ZipperSpec.hs view
@@ -83,7 +83,9 @@       dl1 = displayLinesWithAlignment TextAlignment_Right 10 () () (fromText "aoeu\n\n\naoeu")       dl2 = displayLinesWithAlignment TextAlignment_Right 10 () () (fromText "\n\n\naoeu")       dl3 = displayLinesWithAlignment TextAlignment_Right 10 () () (fromText "aoeu\n\n\n")+      dl4 = displayLinesWithAlignment TextAlignment_Right 10 () () (empty) +     insertcharnewlinesentence `shouldBe` fromText newlineSentence      -- NOTE last " " is the generated cursor span char@@ -91,6 +93,16 @@     _displayLines_spans dl1 `shouldBe` makespans [["aoeu"],[""],[""],["aoeu", ""]]     _displayLines_spans dl2 `shouldBe` makespans [[""],[""],[""],["aoeu", ""]]     _displayLines_spans dl3 `shouldBe` makespans [["aoeu"],[""],[""],[""]]+    _displayLines_spans dl4 `shouldBe` makespans [[""]]++  +  it "displayLinesWithAlignment - cursor tag" $ do+    let+      dl0 = displayLinesWithAlignment TextAlignment_Right 10 0 1 (fromText "abc")+      dl1 = displayLinesWithAlignment TextAlignment_Right 10 0 1 empty+    _displayLines_spans dl0 `shouldBe` [[Span 0 "abc", Span 1 ""]]+    _displayLines_spans dl1 `shouldBe` [[Span 1 ""]]+