From 7047762954d983487db8c6de01c26381d09fa330 Mon Sep 17 00:00:00 2001 From: pdlla Date: Fri, 5 Jan 2024 14:43:25 -0800 Subject: [PATCH] remove icu dep --- TODO.txt | 55 +++++++++------------------- src/Potato/Data/Text/Unicode.hs | 27 +++++++------- test/Potato/Data/Text/UnicodeSpec.hs | 5 +++ tinytools.cabal | 4 +- 4 files changed, 38 insertions(+), 53 deletions(-) diff --git a/TODO.txt b/TODO.txt index d62a3fac..e19de1b9 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,4 +1,7 @@ + + +---- Hi, I'm been working on my terminal based unicode diagram editor [tinytools](https://github.com/minimapletinytools/tinytools-vty) for about 4 years now 😱. It's been ready to release for some time now but I keep putting it off and adding more features instead! But no more!! I'm a complete potato when it comes to OSS release/distribution/promotion. Looking for tips/suggestions on other ways to distribute this app. @@ -38,42 +41,9 @@ ghc options -drule-check = ----- -Error: cabal: Could not resolve dependencies: -[__0] trying: tinytools-vty-0.1.0.4 (user goal) -[__1] trying: tinytools-0.1.0.4 (dependency of tinytools-vty) -[__2] next goal: text-icu (dependency of tinytools) -[__2] rejecting: text-icu-0.8.0.2, text-icu-0.8.0.1 (conflict: pkg-config -package icu-i18n>=62.1, not found in the pkg-config database) -[__2] rejecting: text-icu-0.8.0 (conflict: pkg-config package icu-i18n-any, -not found in the pkg-config database) -[__2] trying: text-icu-0.7.1.0 -[__3] trying: pretty-simple-4.1.2.0 (dependency of tinytools) -[__4] trying: hashable-1.4.3.0 (dependency of tinytools) -[__5] next goal: text (dependency of tinytools-vty) -[__5] rejecting: text-2.0.1/installed-2.0.1 (conflict: text-icu => -text>=0.9.1.0 && <2) -[__5] skipping: text-2.0.2, text-2.0.1, text-2.0 (has the same characteristics -that caused the previous version to fail: excluded by constraint '>=0.9.1.0 && -<2' from 'text-icu') -[__5] trying: text-1.2.5.0 -[__6] next goal: base (dependency of tinytools-vty) -[__6] rejecting: base-4.17.0.0/installed-4.17.0.0 (conflict: text => -ghc-prim>=0.2 && <0.9, base => ghc-prim==0.9.0/installed-0.9.0) -[__6] rejecting: base-4.18.0.0, base-4.17.2.0, base-4.17.1.0, base-4.17.0.0, -base-4.16.4.0, base-4.16.3.0, base-4.16.2.0, base-4.16.1.0, base-4.16.0.0, -base-4.15.1.0, base-4.15.0.0, base-4.14.3.0, base-4.14.2.0, base-4.14.1.0, -base-4.14.0.0, base-4.13.0.0, base-4.12.0.0, base-4.11.1.0, base-4.11.0.0, -base-4.10.1.0, base-4.10.0.0, base-4.9.1.0, base-4.9.0.0, base-4.8.2.0, -base-4.8.1.0, base-4.8.0.0, base-4.7.0.2, base-4.7.0.1, base-4.7.0.0, -base-4.6.0.1, base-4.6.0.0, base-4.5.1.0, base-4.5.0.0, base-4.4.1.0, -base-4.4.0.0, base-4.3.1.0, base-4.3.0.0, base-4.2.0.2, base-4.2.0.1, -base-4.2.0.0, base-4.1.0.0, base-4.0.0.0, base-3.0.3.2, base-3.0.3.1 -(constraint from non-upgradeable package requires installed instance) -[__6] fail (backjumping, conflict set: base, text, tinytools-vty) -After searching the rest of the dependency tree exhaustively, these were the -goals I've had most trouble fulfilling: base, text, hashable, tinytools, -unordered-containers, mono-traversable, text-icu, pretty-simple, tinytools-vty -Try running with --minimize-conflict-set to improve the error message. + +to enable static linking: +-optl-static -optl-pthread ---------- to get call stacks, first build with: @@ -92,7 +62,10 @@ cabal test --test-options='--match "/Potato.Flow.Controller.Manipulator.Pan"' cabal test --test-options='--match "/Potato.Flow.Controller.Manipulator.Layers/Layers/drag_folder2_test"' cabal run tinytools -- -help - + +---- +nix-shell --packages cabal2nix --run "cabal2nix ." > default.nix +nix-shell --attr tinytools release.nix ---------- normal @@ -134,6 +107,14 @@ IGNORE-grapheme cluster DONE-EMOJIS DONE-moveable line anchors DONE-adjustable attachment spec +-support more shapes + -diamond + -ellipse + -probably needs now styling classes, these should probably be presentsonly +-generalize object and manipulator refactor likely + -generalize text area + -generalize Box handler bulk maniplutaion + -generalize line connection points -swatches -unicode character picker -lives at params level diff --git a/src/Potato/Data/Text/Unicode.hs b/src/Potato/Data/Text/Unicode.hs index 688b0ff7..42c55d0b 100644 --- a/src/Potato/Data/Text/Unicode.hs +++ b/src/Potato/Data/Text/Unicode.hs @@ -6,9 +6,11 @@ import Prelude import Data.Int import Data.Text (Text) import qualified Data.Text as T -import qualified Data.Text.ICU as ICU + import qualified Potato.Data.Text.Zipper as TZ +--import qualified Data.Text.ICU as ICU + @@ -20,6 +22,15 @@ getCharWidth = fromIntegral . TZ.charWidth removeWideChars :: Text -> Text removeWideChars = T.filter (\c -> getCharWidth c <= 1) + +-- never detect grapheme clusters for now +-- proper implementation removed do remove text-icu dependency +-- TODO fix +endsInGraphemeCluster :: Text -> Bool +endsInGraphemeCluster _ = False + + +{- internal_getCharacterBreaks :: Text -> [ICU.Break ()] internal_getCharacterBreaks input = r where breaker = ICU.breakCharacter ICU.Current @@ -66,16 +77,4 @@ removeGraphemeCluster input = r where containsGraphemeCluster :: Text -> Bool containsGraphemeCluster input = removeGraphemeCluster input /= input - - --- πŸ€– isn't correct, misses emojis :() -{- -getCharWidth :: Char -> Int8 -getCharWidth c - | isControl c || c == '\t' = 0 - | w == 0x0 || w > 0x10ffff = 1 - | w >= 0x1100 && (w <= 0x115f || w == 0x2329 || w == 0x232a || (w >= 0x2e80 && w <= 0xa4cf && w /= 0x303f) || (w >= 0xac00 && w <= 0xd7a3) || (w >= 0xf900 && w <= 0xfaff) || (w >= 0xfe10 && w <= 0xfe19) || (w >= 0xfe30 && w <= 0xfe6f) || (w >= 0xff00 && w <= 0xff60) || (w >= 0xffe0 && w <= 0xffe6) || (w >= 0x20000 && w <= 0x2fffd) || (w >= 0x30000 && w <= 0x3fffd)) = 2 - | otherwise = 1 - where - w = ord c --} +-} \ No newline at end of file diff --git a/test/Potato/Data/Text/UnicodeSpec.hs b/test/Potato/Data/Text/UnicodeSpec.hs index aee42fe2..771ff98f 100644 --- a/test/Potato/Data/Text/UnicodeSpec.hs +++ b/test/Potato/Data/Text/UnicodeSpec.hs @@ -16,8 +16,12 @@ import Potato.Data.Text.Unicode doubleWidthChars :: String doubleWidthChars = "ο½”ο½ˆο½…ο½’ο½…γ€€ο½ο½’ο½…γ€€ο½Žο½γ€€ο½“ο½ο½ο½ƒο½…γ€€ο½‚ο½…ο½”ο½—ο½…ο½…ο½Žγ€€ο½ο½„ο½Šο½ο½ƒο½…ο½Žο½”γ€€ο½ƒο½ˆο½ο½’ο½ο½ƒο½”ο½…ο½’ο½“" + + + spec :: Spec spec = describe "Unicode" $ do + {- it "isSingleGraphemeCluster" $ do isSingleGraphemeCluster "πŸ‘ŽπŸΌ" `shouldBe` True isSingleGraphemeCluster "πŸ‘Ž" `shouldBe` False @@ -38,6 +42,7 @@ spec = describe "Unicode" $ do it "containsGraphemeCluster" $ do containsGraphemeCluster "πŸ‘ŽπŸ‘ŽπŸ‘ŽπŸ‘ŽπŸ‘Ž" `shouldBe` False containsGraphemeCluster "πŸ‘ŽπŸ‘ŽπŸ‘ŽπŸΏπŸ‘ŽπŸ‘ŽπŸ‘Ž" `shouldBe` True + -} forM_ doubleWidthChars $ \c -> do it ("getCharWidth " <> show c) $ do getCharWidth c `shouldBe` 2 diff --git a/tinytools.cabal b/tinytools.cabal index bfef41b9..38c4ee96 100644 --- a/tinytools.cabal +++ b/tinytools.cabal @@ -146,9 +146,9 @@ library , linear >= 1.22 && < 1.23 , pretty-simple >= 4.1.2 && < 4.2 , ref-tf >= 0.5.0 && < 0.6 - , text-icu >= 0.8.0 && < 0.9 + --, text-icu >= 0.8.0 && < 0.9 , vty>=5.28 && <6.2 - pkgconfig-depends: icu-i18n, icu-uc + --pkgconfig-depends: icu-i18n, icu-uc default-language: Haskell2010 test-suite tinytools-test