rasa-ext-cursors 0.1.0.0 → 0.1.1
raw patch · 4 files changed
+48/−47 lines, 4 filesdep ~basedep ~data-defaultdep ~lensPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: base, data-default, lens, mtl, rasa, rasa-ext-style, text, text-lens, yi-rope
API changes (from Hackage documentation)
- Rasa.Ext.Cursors: findNext :: Text -> BufAction ()
+ Rasa.Ext.Cursors: findNext :: YiString -> BufAction ()
- Rasa.Ext.Cursors: findNextFrom :: Text -> Coord -> BufAction Coord
+ Rasa.Ext.Cursors: findNextFrom :: YiString -> Coord -> BufAction Coord
- Rasa.Ext.Cursors: findPrev :: Text -> BufAction ()
+ Rasa.Ext.Cursors: findPrev :: YiString -> BufAction ()
- Rasa.Ext.Cursors: findPrevFrom :: Text -> Coord -> BufAction Coord
+ Rasa.Ext.Cursors: findPrevFrom :: YiString -> Coord -> BufAction Coord
- Rasa.Ext.Cursors: insertText :: Text -> BufAction ()
+ Rasa.Ext.Cursors: insertText :: YiString -> BufAction ()
Files
- rasa-ext-cursors.cabal +36/−36
- src/Rasa/Ext/Cursors.hs +1/−1
- src/Rasa/Ext/Cursors/Actions.hs +10/−9
- src/Rasa/Ext/Cursors/Base.hs +1/−1
rasa-ext-cursors.cabal view
@@ -1,39 +1,39 @@-name: rasa-ext-cursors-version: 0.1.0.0-synopsis: Rasa Ext adding cursor(s)-description: Rasa Ext adding cursor(s)-homepage: https://github.com/ChrisPenner/rasa/-license: MIT-license-file: LICENSE-author: Chris Penner-maintainer: christopher.penner@gmail.com-copyright: 2016 Chris Penner-category: Extension-build-type: Simple--- extra-source-files:-cabal-version: >=1.10--library- hs-source-dirs: src- exposed-modules: Rasa.Ext.Cursors- other-modules:- Rasa.Ext.Cursors.Actions- Rasa.Ext.Cursors.Base- build-depends: base >= 4.7 && < 5- , rasa- , rasa-ext-style- , text-lens- , lens- , mtl- , text- , yi-rope- , data-default- default-language: Haskell2010+name: rasa-ext-cursors+version: 0.1.1+cabal-version: >=1.10+build-type: Simple+license: MIT+license-file: LICENSE+copyright: 2016 Chris Penner+maintainer: christopher.penner@gmail.com+homepage: https://github.com/ChrisPenner/rasa/+synopsis: Rasa Ext adding cursor(s)+description:+ Rasa Ext adding cursor(s)+category: Extension+author: Chris Penner - default-extensions:+source-repository head+ type: git+ location: https://github.com/ChrisPenner/rasa - ghc-options: -Wall+library+ exposed-modules:+ Rasa.Ext.Cursors+ build-depends:+ base >=4.8 && <5,+ rasa >=0.1.4 && <0.2,+ rasa-ext-style >=0.1.1 && <0.2,+ text-lens >=0.1.0.0 && <0.2,+ lens ==4.14.*,+ mtl >=2.2.1 && <2.3,+ text >=1.2.2.1 && <1.3,+ yi-rope >=0.7.0.2 && <0.8,+ data-default >=0.7.1.1 && <0.8+ default-language: Haskell2010+ hs-source-dirs: src+ other-modules:+ Rasa.Ext.Cursors.Actions+ Rasa.Ext.Cursors.Base+ ghc-options: -Wall -source-repository head- type: git- location: https://github.com/ChrisPenner/rasa
src/Rasa/Ext/Cursors.hs view
@@ -28,4 +28,4 @@ -- | Registers hooks for the extension. The user should add this to their config. cursors :: Scheduler ()-cursors = beforeRender $ bufDo displayRange+cursors = beforeRender $ buffersDo_ displayRange
src/Rasa/Ext/Cursors/Actions.hs view
@@ -9,6 +9,7 @@ , moveRangesByC ) where +import qualified Yi.Rope as Y import qualified Data.Text as T import Control.Lens@@ -33,13 +34,13 @@ moveSameLineRangesBy r (negate $ sizeOfR r) -- | Insert text at the beginning of all ranges in the buffer.-insertText :: T.Text -> BufAction ()+insertText :: Y.YiString -> BufAction () insertText txt = rangeDo_ $ \r@(Range s _) -> do insertAt s txt- moveSameLineRangesBy r (Coord 0 (T.length txt))+ moveSameLineRangesBy r (Coord 0 (Y.length txt)) -- | Move all ranges to the location of the next occurence of the given text.-findNext :: T.Text -> BufAction ()+findNext :: Y.YiString -> BufAction () findNext pat = do res <- rangeDo $ \(Range _ e) -> do off <- findNextFrom pat e@@ -48,13 +49,13 @@ ranges .= res -- | Get the 'Coord' of the next occurence of the given text after the given 'Coord'-findNextFrom :: T.Text -> Coord -> BufAction Coord+findNextFrom :: Y.YiString -> Coord -> BufAction Coord findNextFrom pat c = do- distance <- use (rope . afterC c . asText . tillNext pat . from asText . to sizeOf)+ distance <- use (text . afterC c . asText . tillNext (Y.toText pat) . from asText . to sizeOf) return (distance + c) -- | Move all ranges to the location of the previous occurence of the given text.-findPrev :: T.Text -> BufAction ()+findPrev :: Y.YiString -> BufAction () findPrev pat = do res <- rangeDo $ \(Range s _) -> do off <- findPrevFrom pat s@@ -63,11 +64,11 @@ ranges .= res -- | Get the 'Coord' of the previous occurence of the given text before the given 'Coord'-findPrevFrom :: T.Text -> Coord -> BufAction Coord+findPrevFrom :: Y.YiString -> Coord -> BufAction Coord findPrevFrom pat c = do- txt <- use rope+ txt <- use text let Offset o = c^.from (asCoord txt)- distance <- use (text . before o . tillPrev pat . to T.length .to negate)+ distance <- use (text . asText . before o . tillPrev (Y.toText pat) . to T.length .to negate) return ((Offset $ distance + o)^.asCoord txt) -- | Move all ranges by the given number of columns
src/Rasa/Ext/Cursors/Base.hs view
@@ -48,7 +48,7 @@ ranges :: Lens' Buffer [Range] ranges = lens getter setter where getter buf = buf^.bufExt.cursors- setter buf new = let txt = buf^.rope+ setter buf new = let txt = buf^.text in buf & bufExt.cursors .~ cleanRanges txt new -- | A Traversal over each Range for the given buffer.