packages feed

tinytools-vty 0.1.0.3 → 0.1.0.4

raw patch · 8 files changed

+101/−77 lines, 8 filesdep ~reflex-vtynew-uploaderPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependency ranges changed: reflex-vty

API changes (from Hackage documentation)

- Potato.Flow.Vty.Tools: Tool_CartLine :: Tool
- Potato.Reflex.Vty.Widget.ScrollBar: vScrollBar :: forall t m a. MonadWidget t m => Dynamic t Int -> m (Dynamic t Int)
+ Potato.Reflex.Vty.Widget.ScrollBar: vScrollBar :: forall t m a. MonadWidget t m => Int -> Dynamic t Int -> m (Dynamic t Int)

Files

ChangeLog.md view
@@ -1,5 +1,13 @@ # Changelog for tinytools-vty ++## [0.1.0.4]+- update to use 0.1.0.4 of tinytools++## [0.1.0.3]+### Changed+- minor stuff to fix build+ ## [0.1.0.2] ### Added - minor stuff to fix build
README.md view
@@ -2,7 +2,7 @@  `tinytools-vty` is a mono-space unicode diagram editor written in Haskell -This repository contains the [reflex-vty](https://hackage.haskell.org/package/reflex-vty) based view/controller implementation built on top of the [tinytools](https://github.com/pdlla/tinytools) model.+This repository contains the [reflex-vty](https://hackage.haskell.org/package/reflex-vty) based view/controller implementation built on top of the [tinytools](https://github.com/minimapletinytools/tinytools) model.   # running@@ -11,66 +11,71 @@  Or if you are building locally then `cabal run tinytools` +NOTE that `tinytools` is also the name of the base model library for `tinytools-vty` which is why the `exe` is necessary. If you just `cabal install tinytools` you will install the library!+ # usage -When you first run `tinytools` a tutorial file will open which contains information on how to use `tinytools-vty`. This same tutorial is copied at the bottom of this README file.+When you first run `tinytools` a tutorial file will open which contains information on how to use `tinytools-vty`. This same tutorial is copied at the bottom of this README file. `tinytools-vty` has a very intuitive interface and most operations should be clear. -`tinytools-vty` has a very intuitive interface and most operations should be clear.+hotkeys are supported, unfortunately they seem to sometimes they get captured by the OS or the terminal and never get forwarded to the app :(. -hotkeys are supported, however sometimes they get captured by the OS or the terminal and never sent into the executable :(.+# tutorial +(open in the app instead for a better view, browser code preview doesn't render certain unicode characters in monospace correctly)++```++[new][open][save][save as]     *             ╔══════════════════════════════╗                                                                                            +[export to "potato.txt"][quit] *             ║                              ║ ╔IMPORTANT#########################╗                                                       +-------------------------------*   ███████████████████                      ╚>#to explore the canvas, click the  #                                                       +[(v)select][(p)an][(b)ox]      *   █THIS IS TINYTOOLS█═╗                      #[(p)an] button or press p         #                                                       +[(l)ine][(t)extbox][pai(n)t]   *   ███████████████████ ║                      #                                  #                                                       +-------------------------------*                       v                      #then click and drag in the canvas #                                                       +⇊ea 𐃛 starter                 #*   <═══╗   ╔══════════════════════╗           #area to move your view            #                                                       +  ea ⧈ info: more features    #*       ║   ║the menu on the left  ║           #                                  #                                                       +  ea ⤡ <line>                 #*       ╚═══║has a lot of important║═══╗       #                                  #                                                       +  ea ⤡ <line>                 #*           ║operations            ║   ║       ╚##################################╝                                                       +  ea ⤡ <line>                 #*           ╚══════════════════════╝   ║                        ^                                                                         +  ea ⧈ info: pan              #*                      ║               ║                        ║                                                                         +  ea ⤡ <line>                 #*                      v               ║                        ║                                                                         +  ea ⧈ info: box parameters   #*        ╔═══════════════════════════╗ ║                        ║                                                                         +  ea ⤡ <line>                 #*        ║to draw a box, click the   ║ ║                        ║                                                                         +  ea ⤡ <line>                 #*        ║[(b)ox] button or press b  ║ ║                        ╚════════════════════╗                                                    +  ea ⧈ info: canvas           #*        ║                           ║ ║                                             ║                                                    +  ea ⧈ info: box              #*        ║then click and drag in the ║ ║                                             ║                                                    +  ea ⧈ info: menu             #*        ║canvas area                ║ ║                        *------------------* ║                                                    +  ea ⤡ <line>                 #*        ╚═══════════════════════════╝ ║                        |this area (to the | ║                                                    +  ea ⤡ <line>                 #*                             ║        ╚═══════════════════════>|right) is called  |═╝                                                    +  ea ⧈ title                  #*                             ║                                 |the canvas        |                                                      +                              #*                             v                                 |                  |                                                      +                              #*            ╔═════════════════════════════════╗                |                  |                                                      +                              #*            ║after creating a box, it will be ║                |                  |                                                      +                              #*            ║selected, you can use the options║                *------------------*                                                      +                              #*            ║in the bottom right to change its║                                                                                          +                              #*      ╔═════║style. you can also convert your ║                                                                                          +                              #*  <═══╝     ║box into a text box or remove its║     ╔═══════════════════════════════╗                                                    +                              #*            ║border                           ║     ║of course there are many more  ║                                                    +                              #*            ║                                 ║     ║features, play around!         ║                                                    +                              #*            ║                                 ║     ║                               ║                                                    +                              #*            ╚═════════════════════════════════╝     ║                               ║                                                    +                              #*                                                    ║                               ║                                                    +                              #*                                                    ║                               ║                                                    +                              #*                                                    ║                               ║                                                    +                              #*                                                    ║                               ║                                                    +                              #*                                                    ║                               ║                                                    +                              #*                                                    ║                               ║                                                    +                              #*                                                    ║                               ║                                                    +                              #*                                                    ║                               ║                                                    +[new folder]                   *                                                    ║                               ║                                                    +-------------------------------*                                                    ╚═══════════════════════════════╝                                                    +canvas:                        *                                                                                                                                         + width: 500                    *                                                                                                                                         +height: 200                    *                                                                                                                                         +```                                                                                            + # enabling unicode widechar support  ## NOT WORKING, WILL CRASH RANDOMLY IF YOU USE UNICODE WIDE CHARS 😨 (this is due to bugs in TextZipper module that I still need to fix)  Unicode character display width seems to vary by terminal so you will need to generate a unicode width table file in order to enable support for unicode wide characters. You can run `tinytools-vty` with the `--widthtable` arg to generate the table to your local config directory for the current terminal. Generating the table samples each unicode character inside the terminal and takes a few seconds to run. Please see the `Graphics.Vty.UnicodeWidthTable` module of the [vty](https://hackage.haskell.org/package/vty) for more info.--# tutorial--```-             ╔══════════════════════════════╗                                                                                                                 -             ║                              ║ ╔IMPORTANT#########################╗                                                                            -   ███████████████████                      ╚>#to explore the canvas, click the  #                                                                            -   █THIS IS TINYTOOLS█═╗                      #[(p)an] button or press p         #                                                                            -   ███████████████████ ║                      #                                  #                                                                            -                       v                      #then click and drag in the canvas #                                                                            -   <═══╗   ╔══════════════════════╗           #area to move your view            #                                                                            -       ║   ║the menu on the left  ║           #                                  #                                                                            -       ╚═══║has a lot of important║═══╗       #                                  #                                                                            -           ║operations            ║   ║       ╚##################################╝                                                                            -           ╚══════════════════════╝   ║                        ^                                                                                              -                      ║               ║                        ║                                                                                              -                      v               ║                        ║                                                                                              -        ╔═══════════════════════════╗ ║                        ║                                                                                              -        ║to draw a box, click the   ║ ║                        ║                                                                                              -        ║[(b)ox] button or press b  ║ ║                        ╚════════════════════╗                                                                         -        ║                           ║ ║                                             ║                                                                         -        ║then click and drag in the ║ ║                                             ║                                                                         -        ║canvas area                ║ ║                        *------------------* ║                                                                         -        ╚═══════════════════════════╝ ║                        |this area (to the | ║                                                                         -                             ║        ╚═══════════════════════>|right) is called  |═╝                                                                         -                             ║                                 |the canvas        |                                                                           -                             v                                 |                  |                                                                           -            ╔═════════════════════════════════╗                |                  |                                                                           -            ║after creating a box, it will be ║                |                  |                                                                           -            ║selected, you can use the options║                *------------------*                                                                           -            ║in the bottom right to change its║                                                                                                               -      ╔═════║style. you can also convert your ║                                                                                                               -  <═══╝     ║box into a text box or remove its║     ╔═══════════════════════════════╗                                                                         -            ║border                           ║     ║of course there are many more  ║                                                                         -            ║                                 ║     ║features, play around!         ║                                                                         -            ║                                 ║     ║                               ║                                                                         -            ╚═════════════════════════════════╝     ║                               ║                                                                         -                                                    ║                               ║                                                                         -                                                    ║                               ║                                                                         -                                                    ║                               ║                                                                         -                                                    ║                               ║                                                                         -                                                    ║                               ║                                                                         -                                                    ║                               ║                                                                         -                                                    ║                               ║                                                                         -                                                    ║                               ║                                                                         -                                                    ║                               ║                                                                         -                                                    ╚═══════════════════════════════╝                                                                         --```                                                                                                                  
src/Potato/Flow/Vty/Layer.hs view
@@ -190,7 +190,7 @@       vScrollDyn <- (grout . fixed) 1 $ col $ do         let           contentSizeDyn = fmap ((+1) . Seq.length . _layersViewHandlerRenderOutput_entries) _layerWidgetConfig_layersView-        vScrollBar contentSizeDyn+        vScrollBar 1 contentSizeDyn        return layerInpEv_d2 
src/Potato/Flow/Vty/Params.hs view
@@ -80,10 +80,10 @@ toolOverrideTextAlign = (== Tool_Text)  toolOverrideSuperStyle :: ToolOverrideSelector-toolOverrideSuperStyle = (\t -> t == Tool_Box || t == Tool_Text || t == Tool_Line || t == Tool_CartLine)+toolOverrideSuperStyle = (\t -> t == Tool_Box || t == Tool_Text || t == Tool_Line)  toolOverrideLineStyle :: ToolOverrideSelector-toolOverrideLineStyle = (\t -> t == Tool_Line || t == Tool_CartLine)+toolOverrideLineStyle = (\t -> t == Tool_Line)  toolOverrideSBoxType :: ToolOverrideSelector toolOverrideSBoxType = (const False) -- NOTE default variant here does nothing as this is always overriden based on tool
src/Potato/Flow/Vty/Tools.hs view
@@ -35,19 +35,27 @@ --onlyIfBeh ev beh = fmapMaybe (\(b,e) -> if b then Just e else Nothing) $ attach beh ev  +toolWidgetToIndex :: Tool -> Int+toolWidgetToIndex = \case+  Tool_Select -> 0+  Tool_Pan -> 1+  Tool_Box -> 2+  Tool_Line -> 3+  Tool_TextArea -> 4+  _ -> 0+ holdToolsWidget :: forall t m. (PostBuild t m, MonadWidget t m)   => ToolWidgetConfig t   -> m (ToolWidget t) holdToolsWidget ToolWidgetConfig {..} = mdo -  (radioEvs, heightDyn) <- radioList (constDyn ["(v)select","(p)an","(b)ox","(l)ine","(t)extbox","pai(n)t"]) (fmap ((:[]) . fromEnum) _toolWidgetConfig_tool) (Just _toolWidgetConfig_widthDyn)+  (radioEvs, heightDyn) <- radioList (constDyn ["(v)select","(p)an","(b)ox","(l)ine","pai(n)t"]) (fmap ((:[]) . toolWidgetToIndex) _toolWidgetConfig_tool) (Just _toolWidgetConfig_widthDyn)   let     selectB = void $ ffilter (==0) radioEvs     panB = void $ ffilter (==1) radioEvs     boxB = void $ ffilter (==2) radioEvs     lineB = void $ ffilter (==3) radioEvs-    textB = void $ ffilter (==4) radioEvs-    textareaB = void $ ffilter (==5) radioEvs+    textareaB = void $ ffilter (==4) radioEvs    let     setTool = leftmost@@ -55,7 +63,6 @@       , Tool_Pan <$ leftmost [panB]       , Tool_Box <$ leftmost [boxB]       , Tool_Line <$ leftmost [lineB]-      , Tool_Text <$ leftmost [textB]       , Tool_TextArea <$ leftmost [textareaB]] {-   vLayoutPad 4 $ debugStream [
src/Potato/Reflex/Vty/Widget/FileExplorer.hs view
@@ -157,8 +157,10 @@                 then return fileclickev                 else return never         join . fmap (switchHold never) . networkView $ scrolledContents-      vScrollDyn <- (grout . fixed) 1 $ col $ do-        vScrollBar (constDyn (length xs))+      let +        vScrollWidth = 2+      vScrollDyn <- (grout . fixed) (constDyn vScrollWidth) $ col $ do+        vScrollBar vScrollWidth (constDyn (length xs))       return r    -- put it all together
src/Potato/Reflex/Vty/Widget/ScrollBar.hs view
@@ -43,12 +43,14 @@   These a _ -> Just a   _ -> Nothing + -- TODO write UTs -- TODO reduce constraints vScrollBar :: forall t m a. (MonadWidget t m)-  => Dynamic t Int -- ^ content height+  => Int -- ^ width+  -> Dynamic t Int -- ^ content height   -> m (Dynamic t Int) -- ^ offset-vScrollBar contentSizeDyn = mdo+vScrollBar scrollBarWidth contentSizeDyn = mdo   maxSizeDyn <- displayHeight   let     screen_over_content_dyn :: Dynamic t Float = liftA2 (\a b -> fromIntegral a / fromIntegral b ) maxSizeDyn contentSizeDyn@@ -57,7 +59,7 @@     maxContentSizeDiffDyn = fromIntegral . max 0 <$> liftA2 (-) contentSizeDyn maxSizeDyn      boxHeightDyn = fmap ceiling $ liftA2 (*) screen_over_content_dyn (fromIntegral <$> maxSizeDyn)-    boxRegionDyn = Region <$> 0 <*> offsetScreenUnitDyn <*> 1 <*> boxHeightDyn+    boxRegionDyn = Region <$> 0 <*> offsetScreenUnitDyn <*> constDyn scrollBarWidth <*> boxHeightDyn    --innerDragEv will only fire on drag events that started on the scroll bar handle portion   innerDragEv <- pane boxRegionDyn (constDyn True) $ do
tinytools-vty.cabal view
@@ -1,15 +1,15 @@ cabal-version: 1.12  name:           tinytools-vty-version:        0.1.0.3-description:    Please see the README on GitHub at <https://github.com/pdlla/tinytools-vty#readme>-homepage:       https://github.com/pdlla/tinytools-vty#readme-bug-reports:    https://github.com/pdlla/tinytools-vty/issues-author:         pdlla-maintainer:     chippermonky@gmail.com+version:        0.1.0.4+description:    tinytools-vty is a terminal based monospace unicode diagram editing tool+homepage:       https://github.com/minimapletinytools/tinytools-vty#readme+bug-reports:    https://github.com/minimapletinytools/tinytools-vty/issues+author:         minimaple+maintainer:     minimapletinytools@gmail.com category:       tinytools-synopsis:       a terminal based unicode diagram editing tool-copyright:      2020 Peter Lu+synopsis:       tinytools-vty is a terminal based monospace unicode diagram editing tool+copyright:      2023 minimaple (Peter Lu) license:        BSD3 license-file:   LICENSE build-type:     Simple@@ -21,7 +21,7 @@  source-repository head   type: git-  location: https://github.com/pdlla/tinytools-vty+  location: https://github.com/minimapletinytools/tinytools-vty   library@@ -121,7 +121,7 @@     , reflex     , reflex-potatoes     , reflex-test-host >=0.1.2.2-    , reflex-vty+    , reflex-vty >= 0.5.1     , relude     , semialign     -- TODO set latest version@@ -199,7 +199,7 @@     , tinytools-vty     , primitive     , ref-tf-    , reflex-vty+    , reflex-vty >= 0.5.1     , reflex >= 0.8 && <1     , reflex-potatoes >=0.1     , reflex-test-host >=0.1.2.2@@ -373,7 +373,7 @@     , reflex     , reflex-potatoes     , reflex-test-host >=0.1.2.2-    , reflex-vty+    , reflex-vty >= 0.5.1     , relude     , semialign     , template-haskell