packages feed

patat 0.10.1.0 → 0.10.1.1

raw patch · 7 files changed

+101/−25 lines, 7 filesPVP: minor bump suggested

API additions: PVP suggests at least a minor version bump

API changes (from Hackage documentation)

+ Patat.PrettyPrint.Internal: instance GHC.Show.Show Patat.PrettyPrint.Internal.Chunk
+ Patat.PrettyPrint.Internal: instance GHC.Show.Show Patat.PrettyPrint.Internal.Control

Files

CHANGELOG.md view
@@ -1,5 +1,12 @@ # Changelog +## 0.10.1.1 (2023-10-18)++ *  Fix issues in text wrapping when starting a transition++    This could show transitions using different wrapping or dropped characters+    when a line extends past the terminal width.+ ## 0.10.1.0 (2023-10-15)   *  Add dissolve transition effect (#150)
README.md view
@@ -75,19 +75,18 @@  ### Homebrew -Homebrew packages are offered by a third-party repository:+[Homebrew] packages are offered by a+[third-party repository](https://github.com/nicholasdille/homebrew-tap).+**Unfortunately this repo has been archived, and the latest version that can+be installed from there is v0.8.7.0**.  If you would like to contribute here,+please contact us by opening an issue. -1. Install [Homebrew] for your platform.-2. Run `brew tap nicholasdille/tap`.-3. Run `brew install patat-bin` to receive the official binaries or+1. Run `brew tap nicholasdille/tap`.+2. Run `brew install patat-bin` to receive the official binaries or    `brew install patat` for pre-built ("bottled") binaries.  [Homebrew]: https://brew.sh/ -For issues and feedback please refer to [nicholasdille/homebrew-tap].--[nicholasdille/homebrew-tap]: https://github.com/nicholasdille/homebrew-tap- ### From source  Installation from source is very easy.  You can build from source using `stack@@ -585,8 +584,6 @@   pandocExtensions:     - autolink_bare_uris     - emoji-...- ...  Document content...
lib/Patat/PrettyPrint/Internal.hs view
@@ -49,7 +49,7 @@ data Control     = ClearScreenControl     | GoToLineControl Int-    deriving (Eq)+    deriving (Eq, Show)   --------------------------------------------------------------------------------@@ -58,7 +58,7 @@     = StringChunk [Ansi.SGR] String     | NewlineChunk     | ControlChunk Control-    deriving (Eq)+    deriving (Eq, Show)   --------------------------------------------------------------------------------
lib/Patat/PrettyPrint/Matrix.hs view
@@ -35,21 +35,24 @@  -------------------------------------------------------------------------------- docToMatrix :: Size -> Doc -> Matrix-docToMatrix size doc = V.create $ do-    matrix <- VM.replicate (sRows size * sCols size) emptyCell+docToMatrix (Size rows cols) doc = V.create $ do+    matrix <- VM.replicate (rows * cols) emptyCell     go matrix 0 0 $ docToChunks doc     pure matrix   where+    go r y x (StringChunk _ [] : cs)                 = go r y x cs     go _ _ _ []                                      = pure ()-    go _ y _ _  | y >= sRows size                    = pure ()+    go _ y _ _  | y >= rows                          = pure ()     go r y _ (NewlineChunk : cs)                     = go r (y + 1) 0 cs-    go r y x cs | x > sCols size                     = go r (y + 1) 0 cs     go r y x (ControlChunk ClearScreenControl  : cs) = go r y x cs  -- ?     go r _ x (ControlChunk (GoToLineControl y) : cs) = go r y x cs-    go r y x (StringChunk _      []      : cs)       = go r y x cs-    go r y x (StringChunk codes (z : zs) : cs)       = do-        VM.write r (y * sCols size + x) (Cell codes z)-        go r y (x + wcwidth z) (StringChunk codes zs : cs)+    go r y x chunks@(StringChunk codes (z : zs) : cs)+        | x + w > cols = go r (y + 1) 0 chunks+        | otherwise    = do+            VM.write r (y * cols + x) (Cell codes z)+            go r y (x + wcwidth z) (StringChunk codes zs : cs)+      where+        w = wcwidth z   --------------------------------------------------------------------------------
patat.cabal view
@@ -1,5 +1,5 @@ Name:                patat-Version:             0.10.1.0+Version:             0.10.1.1 Synopsis:            Terminal-based presentations using Pandoc Description:         Terminal-based presentations using Pandoc. License:             GPL-2@@ -32,8 +32,8 @@    Build-depends:     aeson                >= 2.0  && < 2.2,-    ansi-terminal        >= 0.6  && < 0.12,-    ansi-wl-pprint       >= 0.6  && < 0.7,+    ansi-terminal        >= 0.6  && < 1.1,+    ansi-wl-pprint       >= 0.6  && < 1.1,     async                >= 2.2  && < 2.3,     base                 >= 4.9  && < 5,     base64-bytestring    >= 1.0  && < 1.3,@@ -42,7 +42,7 @@     containers           >= 0.5  && < 0.7,     directory            >= 1.2  && < 1.4,     filepath             >= 1.4  && < 1.5,-    mtl                  >= 2.2  && < 2.3,+    mtl                  >= 2.2  && < 2.4,     optparse-applicative >= 0.16 && < 0.19,     pandoc               >= 3.1  && < 3.2,     pandoc-types         >= 1.23 && < 1.24,@@ -130,7 +130,7 @@     base         >= 4.9 && < 5,     containers   >= 0.6 && < 0.7,     doctemplates >= 0.8 && < 0.12,-    mtl          >= 2.2 && < 2.3,+    mtl          >= 2.2 && < 2.4,     pandoc       >= 3.1 && < 3.2,     text         >= 1.2 && < 2.1,     time         >= 1.6 && < 1.13@@ -145,9 +145,11 @@   Other-modules:     Patat.Presentation.Interactive.Tests     Patat.Presentation.Read.Tests+    Patat.PrettyPrint.Matrix.Tests    Build-depends:     patat,+    ansi-terminal    >= 0.6  && < 1.1,     base             >= 4.8  && < 5,     directory        >= 1.2  && < 1.4,     pandoc           >= 3.1  && < 3.2,
tests/haskell/Main.hs view
@@ -2,10 +2,12 @@  import qualified Patat.Presentation.Interactive.Tests import qualified Patat.Presentation.Read.Tests+import qualified Patat.PrettyPrint.Matrix.Tests import qualified Test.Tasty                           as Tasty  main :: IO () main = Tasty.defaultMain $ Tasty.testGroup "patat"     [ Patat.Presentation.Interactive.Tests.tests     , Patat.Presentation.Read.Tests.tests+    , Patat.PrettyPrint.Matrix.Tests.tests     ]
+ tests/haskell/Patat/PrettyPrint/Matrix/Tests.hs view
@@ -0,0 +1,65 @@+--------------------------------------------------------------------------------+{-# LANGUAGE OverloadedLists #-}+module Patat.PrettyPrint.Matrix.Tests+    ( tests+    ) where+++--------------------------------------------------------------------------------+import           Patat.PrettyPrint+import           Patat.PrettyPrint.Matrix+import           Patat.Size+import qualified System.Console.ANSI      as Ansi+import qualified Test.Tasty               as Tasty+import qualified Test.Tasty.HUnit         as Tasty+import           Test.Tasty.HUnit         ((@?=))+++--------------------------------------------------------------------------------+tests :: Tasty.TestTree+tests = Tasty.testGroup "Patat.PrettyPrint.Matrix.Tests"+    [ testDocToMatrix+    ]+++--------------------------------------------------------------------------------+testDocToMatrix :: Tasty.TestTree+testDocToMatrix = Tasty.testGroup "docToMatrix"+    [ Tasty.testCase "wcwidth" $+        docToMatrix+            (Size 2 10)+            (string "wcwidth:" <$$> ansi [green] (string "コンニチハ")) @?=+        [ c 'w', c 'c', c 'w', c 'i', c 'd', c 't', c 'h', c ':', e, e+        , cg 'コ', e, cg 'ン', e, cg 'ニ', e, cg 'チ', e, cg 'ハ', e+        ]+    , Tasty.testCase "wrap" $+        docToMatrix+            (Size 4 4)+            (string "fits" <$$> string "wrapped" <$$> string "fits") @?=+        [ c 'f', c 'i', c 't', c 's'+        , c 'w', c 'r', c 'a', c 'p'+        , c 'p', c 'e', c 'd', e+        , c 'f', c 'i', c 't', c 's'+        ]+    , Tasty.testCase "overflow" $+        docToMatrix+            (Size 3 3)+            (string "overflowed") @?=+        [ c 'o', c 'v', c 'e'+        , c 'r', c 'f', c 'l'+        , c 'o', c 'w', c 'e'+        ]+    , Tasty.testCase "wrap in middle of wide character" $+        docToMatrix+            (Size 2 5)+            (string "溢れる") @?=+        [ c '溢', e, c 'れ', e, e+        , c 'る', e, e     , e, e+        ]+    ]+  where+    green = Ansi.SetColor Ansi.Foreground Ansi.Vivid Ansi.Green++    c  = Cell []+    cg = Cell [green]+    e  = emptyCell