yi-core 0.13.3 → 0.13.4
raw patch · 3 files changed
+31/−16 lines, 3 files
Files
- src/Yi/Buffer/HighLevel.hs +11/−0
- src/Yi/Buffer/Misc.hs +19/−15
- yi-core.cabal +1/−1
src/Yi/Buffer/HighLevel.hs view
@@ -96,6 +96,7 @@ , scrollToCursorB , scrollToLineAboveWindowB , scrollToLineBelowWindowB+ , selectNParagraphs , setSelectionMarkPointB , setSelectRegionB , shapeOfBlockRegionB@@ -292,6 +293,16 @@ -- | Move up prev @n@ paragraphs prevNParagraphs :: Int -> BufferM () prevNParagraphs n = replicateM_ n $ moveB unitEmacsParagraph Backward++-- | Select next @n@ paragraphs+selectNParagraphs :: Int -> BufferM ()+selectNParagraphs n = do+ getVisibleSelection >>= \case+ True -> exchangePointAndMarkB+ >> nextNParagraphs n >> (setVisibleSelection True)+ >> exchangePointAndMarkB+ False -> nextNParagraphs n >> (setVisibleSelection True)+ >> pointB >>= setSelectionMarkPointB >> prevNParagraphs n -- ! Examples: -- @goUnmatchedB Backward '(' ')'@
src/Yi/Buffer/Misc.hs view
@@ -6,9 +6,9 @@ {-# LANGUAGE ExistentialQuantification #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-}-{-# LANGUAGE ImpredicativeTypes #-} {-# LANGUAGE LambdaCase #-} {-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE RankNTypes #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE StandaloneDeriving #-} {-# LANGUAGE TemplateHaskell #-}@@ -245,12 +245,14 @@ -- | Gets a short identifier of a buffer. If we're given a 'MemBuffer' -- then just wraps the buffer name like so: @*name*@. If we're given a--- 'FileBuffer', it drops the the number of characters specified.+-- 'FileBuffer', it drops the number of path components. ----- >>> shortIdentString 3 (MemBuffer "hello")--- "*hello*"--- >>> shortIdentString 3 (FileBuffer "hello")--- "lo"+-- >>> let memBuf = newB (BufferRef 0) (MemBuffer "foo/bar/hello") ""+-- >>> shortIdentString 2 memBuf+-- "*foo/bar/hello*"+-- >>> let fileBuf = newB (BufferRef 0) (FileBuffer "foo/bar/hello") ""+-- >>> shortIdentString 2 fileBuf+-- "hello" shortIdentString :: Int -- ^ Number of characters to drop from FileBuffer names -> FBuffer -- ^ Buffer to work with -> T.Text@@ -260,10 +262,12 @@ -- | Gets the buffer's identifier string, emphasising the 'MemBuffer': ----- >>> identString (MemBuffer "hello")--- "*hello*"--- >>> identString (FileBuffer "hello")--- "hello"+-- >>> let memBuf = newB (BufferRef 0) (MemBuffer "foo/bar/hello") ""+-- >>> identString memBuf+-- "*foo/bar/hello*"+-- >>> let fileBuf = newB (BufferRef 0) (FileBuffer "foo/bar/hello") ""+-- >>> identString fileBuf+-- "foo/bar/hello" identString :: FBuffer -> T.Text identString b = case b ^. identA of MemBuffer bName -> "*" <> bName <> "*"@@ -389,13 +393,13 @@ bb = fromIntegral b :: Double queryBuffer :: (forall syntax. BufferImpl syntax -> x) -> BufferM x-queryBuffer = gets . queryRawbuf+queryBuffer x = gets (queryRawbuf x) modifyBuffer :: (forall syntax. BufferImpl syntax -> BufferImpl syntax) -> BufferM ()-modifyBuffer = modify . modifyRawbuf+modifyBuffer x = modify (modifyRawbuf x) queryAndModify :: (forall syntax. BufferImpl syntax -> (BufferImpl syntax,x)) -> BufferM x-queryAndModify = getsAndModify . queryAndModifyRawbuf+queryAndModify x = getsAndModify (queryAndModifyRawbuf x) -- | Adds an "overlay" to the buffer addOverlayB :: Overlay -> BufferM ()@@ -812,7 +816,7 @@ withMode0 f FBuffer {bmode = m} = f m withModeB :: (forall syntax. Mode syntax -> BufferM a) -> BufferM a-withModeB = join . gets . withMode0+withModeB x = join (gets (withMode0 x)) withSyntax0 :: (forall syntax. Mode syntax -> syntax -> a) -> WindowRef -> FBuffer -> a withSyntax0 f wk (FBuffer bm rb _attrs) = f bm (getAst wk rb)@@ -826,7 +830,7 @@ focusSyntax r = modifyRawbuf (focusAst r) withSyntaxB' :: (forall syntax. Mode syntax -> syntax -> BufferM a) -> BufferM a-withSyntaxB' = join . withSyntaxB+withSyntaxB' x = join (withSyntaxB x) -- | Return indices of strings in buffer matched by regex in the -- given region.
yi-core.cabal view
@@ -3,7 +3,7 @@ -- see: https://github.com/sol/hpack name: yi-core-version: 0.13.3+version: 0.13.4 synopsis: Yi editor core library category: Yi homepage: https://github.com/yi-editor/yi#readme