yi-core-0.19.4: Yi editor core library

License | GPL-2
Maintainer | yi-devel@googlegroups.com
Stability | experimental
Portability | portable
Safe Haskell | None
Language | Haskell2010

Extensions

- Cpp
- TemplateHaskell
- TemplateHaskellQuotes
- ScopedTypeVariables
- BangPatterns
- OverloadedStrings
- StandaloneDeriving
- DeriveDataTypeable
- DeriveFunctor
- DeriveTraversable
- DeriveFoldable
- FlexibleContexts
- ExistentialQuantification
- GeneralizedNewtypeDeriving
- TupleSections
- RankNTypes
- ExplicitForAll
- LambdaCase

Yi.Buffer.Misc

Contents

- Orphan instances

Description

The `Buffer` module defines monadic editing operations over one-dimensional buffers, maintaining a current point.

Synopsis

- data FBuffer = FBuffer !(Mode syntax) !(BufferImpl syntax) !Attributes
- newtype BufferM a = BufferM {
  - fromBufferM :: ReaderT Window (State FBuffer) a
  }
- type WinMarks = MarkSet Mark
- data MarkSet a = MarkSet {
  - fromMark :: !a
  - insMark :: !a
  - selMark :: !a
  }
- bkey :: FBuffer -> BufferRef
- getMarks :: Window -> BufferM (Maybe WinMarks)
- runBuffer :: Window -> FBuffer -> BufferM a -> (a, FBuffer)
- runBufferFull :: Window -> FBuffer -> BufferM a -> (a, Seq Update, FBuffer)
- runBufferDummyWindow :: FBuffer -> BufferM a -> a
- screenTopLn :: BufferM Int
- screenMidLn :: BufferM Int
- screenBotLn :: BufferM Int
- curLn :: BufferM Int
- curCol :: BufferM Int
- colOf :: Point -> BufferM Int
- lineOf :: Point -> BufferM Int
- lineCountB :: BufferM Int
- sizeB :: BufferM Point
- pointB :: BufferM Point
- pointOfLineColB :: Int -> Int -> BufferM Point
- solPointB :: Point -> BufferM Point
- eolPointB :: Point -> BufferM Point
- markLines :: BufferM (MarkSet Int)
- moveTo :: Point -> BufferM ()
- moveToColB :: Int -> BufferM ()
- moveToLineColB :: Int -> Int -> BufferM ()
- lineMoveRel :: Int -> BufferM Int
- lineUp :: BufferM ()
- lineDown :: BufferM ()
- newB :: BufferRef -> BufferId -> YiString -> FBuffer
- data MarkValue = MarkValue {
  - markPoint :: !Point
  - markGravity :: !Direction
  }
- data Overlay
- mkOverlay :: YiString -> Region -> StyleName -> YiString -> Overlay
- gotoLn :: Int -> BufferM Int
- gotoLnFrom :: Int -> BufferM Int
- leftB :: BufferM ()
- rightB :: BufferM ()
- moveN :: Int -> BufferM ()
- leftN :: Int -> BufferM ()
- rightN :: Int -> BufferM ()
- insertN :: YiString -> BufferM ()
- insertNAt :: YiString -> Point -> BufferM ()
- insertB :: Char -> BufferM ()
- deleteN :: Int -> BufferM ()
- nelemsB :: Int -> Point -> BufferM YiString
- writeB :: Char -> BufferM ()
- writeN :: YiString -> BufferM ()
- newlineB :: BufferM ()
- deleteNAt :: Direction -> Int -> Point -> BufferM ()
- readB :: BufferM Char
- elemsB :: BufferM YiString
- undosA :: HasAttributes c => Lens' c URList
- undoB :: BufferM ()
- redoB :: BufferM ()
- getMarkB :: Maybe String -> BufferM Mark
- setMarkHereB :: BufferM Mark
- setNamedMarkHereB :: String -> BufferM ()
- mayGetMarkB :: String -> BufferM (Maybe Mark)
- getMarkValueB :: Mark -> BufferM MarkValue
- markPointA :: Functor f => Mark -> (Point -> f Point) -> FBuffer -> f FBuffer
- modifyMarkB :: Mark -> (MarkValue -> MarkValue) -> BufferM ()
- newMarkB :: MarkValue -> BufferM Mark
- deleteMarkB :: Mark -> BufferM ()
- getVisibleSelection :: BufferM Bool
- setVisibleSelection :: Bool -> BufferM ()
- isUnchangedBuffer :: FBuffer -> Bool
- setAnyMode :: AnyMode -> BufferM ()
- setMode :: Mode syntax -> BufferM ()
- setMode0 :: Mode syntax -> FBuffer -> FBuffer
- modifyMode :: (forall syntax. Mode syntax -> Mode syntax) -> BufferM ()
- regexRegionB :: SearchExp -> Region -> BufferM [Region]
- regexB :: Direction -> SearchExp -> BufferM [Region]
- readAtB :: Point -> BufferM Char
- getModeLine :: [Text] -> BufferM Text
- getPercent :: Point -> Point -> Text
- setInserting :: Bool -> BufferM ()
- savingPrefCol :: BufferM a -> BufferM a
- forgetPreferCol :: BufferM ()
- movingToPrefCol :: BufferM a -> BufferM a
- movingToPrefVisCol :: BufferM a -> BufferM a
- preferColA :: HasAttributes c => Lens' c (Maybe Int)
- markSavedB :: UTCTime -> BufferM ()
- retroactivelyAtSavePointB :: BufferM a -> BufferM a
- addOverlayB :: Overlay -> BufferM ()
- delOverlayB :: Overlay -> BufferM ()
- delOverlaysOfOwnerB :: YiString -> BufferM ()
- getOverlaysOfOwnerB :: YiString -> BufferM (Set Overlay)
- isPointInsideOverlay :: Point -> Overlay -> Bool
- savingExcursionB :: BufferM a -> BufferM a
- savingPointB :: BufferM a -> BufferM a
- savingPositionB :: BufferM a -> BufferM a
- pendingUpdatesA :: HasAttributes c => Lens' c (Seq UIUpdate)
- highlightSelectionA :: Lens' FBuffer Bool
- rectangleSelectionA :: Lens' FBuffer Bool
- readOnlyA :: HasAttributes c => Lens' c Bool
- insertingA :: HasAttributes c => Lens' c Bool
- pointFollowsWindowA :: HasAttributes c => Lens' c (Set WindowRef)
- revertPendingUpdatesB :: BufferM ()
- askWindow :: (Window -> a) -> BufferM a
- clearSyntax :: FBuffer -> FBuffer
- focusSyntax :: Map WindowRef Region -> FBuffer -> FBuffer
- data Mode syntax = Mode {
  - modeName :: Text
  - modeApplies :: FilePath -> YiString -> Bool
  - modeHL :: ExtHL syntax
  - modePrettify :: syntax -> BufferM ()
  - modeKeymap :: KeymapSet -> KeymapSet
  - modeIndent :: syntax -> IndentBehaviour -> BufferM ()
  - modeFollow :: syntax -> Action
  - modeIndentSettings :: IndentSettings
  - modeToggleCommentSelection :: Maybe (BufferM ())
  - modeGetStrokes :: syntax -> Point -> Point -> Point -> [Stroke]
  - modeOnLoad :: BufferM ()
  - modeModeLine :: [Text] -> BufferM Text
  - modeGotoDeclaration :: BufferM ()
  }
- modeNameA :: forall syntax f. Functor f => (Text -> f Text) -> Mode syntax -> f (Mode syntax)
- modeAppliesA :: forall syntax f. Functor f => ((FilePath -> YiString -> Bool) -> f (FilePath -> YiString -> Bool)) -> Mode syntax -> f (Mode syntax)
- modeHLA :: forall syntax f. Functor f => (ExtHL syntax -> f (ExtHL syntax)) -> Mode syntax -> f (Mode syntax)
- modePrettifyA :: forall syntax f. Functor f => ((syntax -> BufferM ()) -> f (syntax -> BufferM ())) -> Mode syntax -> f (Mode syntax)
- modeKeymapA :: forall syntax f. Functor f => ((KeymapSet -> KeymapSet) -> f (KeymapSet -> KeymapSet)) -> Mode syntax -> f (Mode syntax)
- modeIndentA :: forall syntax f. Functor f => ((syntax -> IndentBehaviour -> BufferM ()) -> f (syntax -> IndentBehaviour -> BufferM ())) -> Mode syntax -> f (Mode syntax)
- modeFollowA :: forall syntax f. Functor f => ((syntax -> Action) -> f (syntax -> Action)) -> Mode syntax -> f (Mode syntax)
- modeIndentSettingsA :: forall syntax f. Functor f => (IndentSettings -> f IndentSettings) -> Mode syntax -> f (Mode syntax)
- modeToggleCommentSelectionA :: forall syntax f. Functor f => (Maybe (BufferM ()) -> f (Maybe (BufferM ()))) -> Mode syntax -> f (Mode syntax)
- modeGetStrokesA :: forall syntax f. Functor f => ((syntax -> Point -> Point -> Point -> [Stroke]) -> f (syntax -> Point -> Point -> Point -> [Stroke])) -> Mode syntax -> f (Mode syntax)
- modeOnLoadA :: forall syntax f. Functor f => (BufferM () -> f (BufferM ())) -> Mode syntax -> f (Mode syntax)
- modeGotoDeclarationA :: forall syntax f. Functor f => (BufferM () -> f (BufferM ())) -> Mode syntax -> f (Mode syntax)
- modeModeLineA :: forall syntax f. Functor f => (([Text] -> BufferM Text) -> f ([Text] -> BufferM Text)) -> Mode syntax -> f (Mode syntax)
- data AnyMode = AnyMode (Mode syntax)
- data IndentBehaviour
  - = IncreaseCycle
  - | DecreaseCycle
  - | IncreaseOnly
  - | DecreaseOnly
- data IndentSettings = IndentSettings {
  - expandTabs :: !Bool
  - tabSize :: !Int
  - shiftWidth :: !Int
  }
- expandTabsA :: Lens' IndentSettings Bool
- tabSizeA :: Lens' IndentSettings Int
- shiftWidthA :: Lens' IndentSettings Int
- modeAlwaysApplies :: a -> b -> Bool
- modeNeverApplies :: a -> b -> Bool
- emptyMode :: Mode syntax
- withModeB :: (forall syntax. Mode syntax -> BufferM a) -> BufferM a
- withMode0 :: (forall syntax. Mode syntax -> a) -> FBuffer -> a
- onMode :: (forall syntax. Mode syntax -> Mode syntax) -> AnyMode -> AnyMode
- withSyntaxB :: (forall syntax. Mode syntax -> syntax -> a) -> BufferM a
- withSyntaxB' :: (forall syntax. Mode syntax -> syntax -> BufferM a) -> BufferM a
- keymapProcessA :: HasAttributes c => Lens' c KeymapProcess
- strokesRangesB :: Maybe SearchExp -> Region -> BufferM [[Stroke]]
- streamB :: Direction -> Point -> BufferM YiString
- indexedStreamB :: Direction -> Point -> BufferM [(Point, Char)]
- askMarks :: BufferM WinMarks
- pointAt :: BufferM a -> BufferM Point
- data SearchExp
- lastActiveWindowA :: HasAttributes c => Lens' c Window
- putBufferDyn :: (YiVariable a, MonadState FBuffer m, Functor m) => a -> m ()
- getBufferDyn :: forall m a. (Default a, YiVariable a, MonadState FBuffer m, Functor m) => m a
- shortIdentString :: Int -> FBuffer -> Text
- identString :: FBuffer -> Text
- miniIdentString :: FBuffer -> Text
- identA :: HasAttributes c => Lens' c BufferId
- directoryContentA :: HasAttributes c => Lens' c Bool
- data BufferId
  - = MemBuffer !Text
  - | FileBuffer !FilePath
- file :: FBuffer -> Maybe FilePath
- lastSyncTimeA :: HasAttributes c => Lens' c UTCTime
- replaceCharB :: Char -> BufferM ()
- replaceCharWithBelowB :: BufferM ()
- replaceCharWithAboveB :: BufferM ()
- insertCharWithBelowB :: BufferM ()
- insertCharWithAboveB :: BufferM ()
- pointAfterCursorB :: Point -> BufferM Point
- destinationOfMoveB :: BufferM a -> BufferM Point
- withEveryLineB :: BufferM () -> BufferM ()
- startUpdateTransactionB :: BufferM ()
- commitUpdateTransactionB :: BufferM ()
- applyUpdate :: Update -> BufferM ()
- betweenB :: Point -> Point -> BufferM YiString
- decreaseFontSize :: Int -> BufferM ()
- increaseFontSize :: Int -> BufferM ()
- indentSettingsB :: BufferM IndentSettings
- fontsizeVariationA :: HasAttributes c => Lens' c Int
- stickyEolA :: HasAttributes c => Lens' c Bool
- queryBuffer :: (forall syntax. BufferImpl syntax -> x) -> BufferM x

# Documentation

data FBuffer Source #

Constructors

FBuffer !(Mode syntax) !(BufferImpl syntax) !Attributes |

#### Instances

Instances details

Binary FBuffer Source # |
Instance details Defined in Yi.Buffer.Misc Methods put :: FBuffer -> Put Source # get :: Get FBuffer Source # putList :: [FBuffer] -> Put Source #
Show FBuffer Source # |
Instance details Defined in Yi.Buffer.Misc Methods showsPrec :: Int -> FBuffer -> ShowS Source # show :: FBuffer -> String Source # showList :: [FBuffer] -> ShowS Source #
Eq FBuffer Source # |
Instance details Defined in Yi.Types Methods (==) :: FBuffer -> FBuffer -> Bool Source # (/=) :: FBuffer -> FBuffer -> Bool Source #
MonadState FBuffer BufferM Source # |
Instance details Defined in Yi.Types Methods get :: BufferM FBuffer Source # put :: FBuffer -> BufferM () Source # state :: (FBuffer -> (a, FBuffer)) -> BufferM a Source #

newtype BufferM a Source #

The BufferM monad writes the updates performed.

Constructors

BufferM |

Fields

- fromBufferM :: ReaderT Window (State FBuffer) a

#### Instances

Instances details

Applicative BufferM Source # |
Instance details Defined in Yi.Types Methods pure :: a -> BufferM a Source # (<*>) :: BufferM (a -> b) -> BufferM a -> BufferM b Source # liftA2 :: (a -> b -> c) -> BufferM a -> BufferM b -> BufferM c Source # (*>) :: BufferM a -> BufferM b -> BufferM b Source # (<*) :: BufferM a -> BufferM b -> BufferM a Source #
Functor BufferM Source # |
Instance details Defined in Yi.Types Methods fmap :: (a -> b) -> BufferM a -> BufferM b Source # (<$) :: a -> BufferM b -> BufferM a Source #
Monad BufferM Source # |
Instance details Defined in Yi.Types Methods (>>=) :: BufferM a -> (a -> BufferM b) -> BufferM b Source # (>>) :: BufferM a -> BufferM b -> BufferM b Source # return :: a -> BufferM a Source #
MonadFail BufferM Source # |
Instance details Defined in Yi.Types Methods fail :: String -> BufferM a Source #
MonadReader Window BufferM Source # |
Instance details Defined in Yi.Types Methods ask :: BufferM Window Source # local :: (Window -> Window) -> BufferM a -> BufferM a Source # reader :: (Window -> a) -> BufferM a Source #
MonadState FBuffer BufferM Source # |
Instance details Defined in Yi.Types Methods get :: BufferM FBuffer Source # put :: FBuffer -> BufferM () Source # state :: (FBuffer -> (a, FBuffer)) -> BufferM a Source #
YiAction (BufferM x) x Source # |
Instance details Defined in Yi.Keymap Methods makeAction :: BufferM x -> Action Source #

type WinMarks = MarkSet Mark Source #

data MarkSet a Source #

Constructors

MarkSet |

Fields

- fromMark :: !a
- insMark :: !a
- selMark :: !a

#### Instances

Instances details

Functor MarkSet Source # |
Instance details Defined in Yi.Types Methods fmap :: (a -> b) -> MarkSet a -> MarkSet b Source # (<$) :: a -> MarkSet b -> MarkSet a Source #
Foldable MarkSet Source # |

Instance details

Defined in Yi.Types

Methods

fold :: Monoid m => MarkSet m -> m Source #

foldMap :: Monoid m => (a -> m) -> MarkSet a -> m Source #

foldMap' :: Monoid m => (a -> m) -> MarkSet a -> m Source #

foldr :: (a -> b -> b) -> b -> MarkSet a -> b Source #

foldr' :: (a -> b -> b) -> b -> MarkSet a -> b Source #

foldl :: (b -> a -> b) -> b -> MarkSet a -> b Source #

foldl' :: (b -> a -> b) -> b -> MarkSet a -> b Source #

foldr1 :: (a -> a -> a) -> MarkSet a -> a Source #

foldl1 :: (a -> a -> a) -> MarkSet a -> a Source #

toList :: MarkSet a -> [a] Source #

null :: MarkSet a -> Bool Source #

length :: MarkSet a -> Int Source #

elem :: Eq a => a -> MarkSet a -> Bool Source #

maximum :: Ord a => MarkSet a -> a Source #

minimum :: Ord a => MarkSet a -> a Source #

sum :: Num a => MarkSet a -> a Source #

product :: Num a => MarkSet a -> a Source #

Traversable MarkSet Source # |
Instance details Defined in Yi.Types Methods traverse :: Applicative f => (a -> f b) -> MarkSet a -> f (MarkSet b) Source # sequenceA :: Applicative f => MarkSet (f a) -> f (MarkSet a) Source # mapM :: Monad m => (a -> m b) -> MarkSet a -> m (MarkSet b) Source # sequence :: Monad m => MarkSet (m a) -> m (MarkSet a) Source #
Binary a => Binary (MarkSet a) Source # |
Instance details Defined in Yi.Types Methods put :: MarkSet a -> Put Source # get :: Get (MarkSet a) Source # putList :: [MarkSet a] -> Put Source #
Show a => Show (MarkSet a) Source # |
Instance details Defined in Yi.Types Methods showsPrec :: Int -> MarkSet a -> ShowS Source # show :: MarkSet a -> String Source # showList :: [MarkSet a] -> ShowS Source #

bkey :: FBuffer -> BufferRef Source #

getMarks :: Window -> BufferM (Maybe WinMarks) Source #

runBuffer :: Window -> FBuffer -> BufferM a -> (a, FBuffer) Source #

Execute a `BufferM` value on a given buffer and window. The new state of the buffer is returned alongside the result of the computation.

runBufferFull :: Window -> FBuffer -> BufferM a -> (a, Seq Update, FBuffer) Source #

runBufferDummyWindow :: FBuffer -> BufferM a -> a Source #

Execute a `BufferM` value on a given buffer, using a dummy window. The new state of the buffer is discarded.

screenTopLn :: BufferM Int Source #

Top line of the screen

screenMidLn :: BufferM Int Source #

Middle line of the screen

screenBotLn :: BufferM Int Source #

Bottom line of the screen

curLn :: BufferM Int Source #

Return the current line number

curCol :: BufferM Int Source #

Current column. Note that this is different from offset or number of chars from sol. (This takes into account tabs, unicode chars, etc.)

colOf :: Point -> BufferM Int Source #

lineOf :: Point -> BufferM Int Source #

lineCountB :: BufferM Int Source #

sizeB :: BufferM Point Source #

Point of eof

pointB :: BufferM Point Source #

Extract the current point

pointOfLineColB :: Int -> Int -> BufferM Point Source #

solPointB :: Point -> BufferM Point Source #

Returns start of line point for a given point `p`

eolPointB :: Point -> BufferM Point Source #

Returns end of line for given point.

markLines :: BufferM (MarkSet Int) Source #

Return line numbers of marks

moveTo :: Point -> BufferM () Source #

Move point in buffer to the given index

moveToColB :: Int -> BufferM () Source #

moveToLineColB :: Int -> Int -> BufferM () Source #

lineMoveRel :: Int -> BufferM Int Source #

Move point down by `n` lines. `n` can be negative. Returns the actual difference in lines which we moved which may be negative if the requested line difference is negative.

lineUp :: BufferM () Source #

Move point up one line

lineDown :: BufferM () Source #

Move point down one line

newB :: BufferRef -> BufferId -> YiString -> FBuffer Source #

Create buffer named `nm` with contents `s`

data MarkValue Source #

Constructors

MarkValue |

Fields

- markPoint :: !Point
- markGravity :: !Direction

#### Instances

Instances details

Binary MarkValue Source # |
Instance details Defined in Yi.Buffer.Implementation Methods put :: MarkValue -> Put Source # get :: Get MarkValue Source # putList :: [MarkValue] -> Put Source #
Generic MarkValue Source # |

Instance details

Defined in Yi.Buffer.Implementation

Associated Types

type Rep MarkValue |

Instance details

Defined in Yi.Buffer.Implementation

type Rep MarkValue = D1 ('MetaData "MarkValue" "Yi.Buffer.Implementation" "yi-core-0.19.4-4E7mid7TC5Y9v8ChZSA8gi" 'False) (C1 ('MetaCons "MarkValue" 'PrefixI 'True) (S1 ('MetaSel ('Just "markPoint") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Point) :*: S1 ('MetaSel ('Just "markGravity") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Direction)))

Methods

from :: MarkValue -> Rep MarkValue x Source #

to :: Rep MarkValue x -> MarkValue Source #

Show MarkValue Source # |
Instance details Defined in Yi.Buffer.Implementation Methods showsPrec :: Int -> MarkValue -> ShowS Source # show :: MarkValue -> String Source # showList :: [MarkValue] -> ShowS Source #
Eq MarkValue Source # |
Instance details Defined in Yi.Buffer.Implementation Methods (==) :: MarkValue -> MarkValue -> Bool Source # (/=) :: MarkValue -> MarkValue -> Bool Source #
Ord MarkValue Source # |

Instance details

Defined in Yi.Buffer.Implementation

Methods

compare :: MarkValue -> MarkValue -> Ordering Source #

(<) :: MarkValue -> MarkValue -> Bool Source #

(<=) :: MarkValue -> MarkValue -> Bool Source #

(>) :: MarkValue -> MarkValue -> Bool Source #

(>=) :: MarkValue -> MarkValue -> Bool Source #

max :: MarkValue -> MarkValue -> MarkValue Source #

min :: MarkValue -> MarkValue -> MarkValue Source #

type Rep MarkValue Source # |

Instance details

Defined in Yi.Buffer.Implementation

type Rep MarkValue = D1 ('MetaData "MarkValue" "Yi.Buffer.Implementation" "yi-core-0.19.4-4E7mid7TC5Y9v8ChZSA8gi" 'False) (C1 ('MetaCons "MarkValue" 'PrefixI 'True) (S1 ('MetaSel ('Just "markPoint") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Point) :*: S1 ('MetaSel ('Just "markGravity") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Direction)))

data Overlay Source #

#### Instances

Instances details

Show Overlay Source # |
Instance details Defined in Yi.Buffer.Implementation Methods showsPrec :: Int -> Overlay -> ShowS Source # show :: Overlay -> String Source # showList :: [Overlay] -> ShowS Source #
Eq Overlay Source # |
Instance details Defined in Yi.Buffer.Implementation Methods (==) :: Overlay -> Overlay -> Bool Source # (/=) :: Overlay -> Overlay -> Bool Source #
Ord Overlay Source # |
Instance details Defined in Yi.Buffer.Implementation Methods compare :: Overlay -> Overlay -> Ordering Source # (<) :: Overlay -> Overlay -> Bool Source # (<=) :: Overlay -> Overlay -> Bool Source # (>) :: Overlay -> Overlay -> Bool Source # (>=) :: Overlay -> Overlay -> Bool Source # max :: Overlay -> Overlay -> Overlay Source # min :: Overlay -> Overlay -> Overlay Source #

mkOverlay :: YiString -> Region -> StyleName -> YiString -> Overlay Source #

Create an "overlay" for the style `sty` between points `s` and `e`

gotoLn :: Int -> BufferM Int Source #

Go to line number `n`. `n` is indexed from 1. Returns the actual line we went to (which may be not be the requested line, if it was out of range)

gotoLnFrom :: Int -> BufferM Int Source #

Go to line indexed from current point Returns the actual moved difference which of course may be negative if the requested difference was negative.

leftB :: BufferM () Source #

Move point -1

rightB :: BufferM () Source #

Move cursor +1

moveN :: Int -> BufferM () Source #

Move point by the given number of characters. A negative offset moves backwards a positive one forward.

leftN :: Int -> BufferM () Source #

Move cursor -n

rightN :: Int -> BufferM () Source #

Move cursor +n

insertN :: YiString -> BufferM () Source #

Insert the `YiString` at current point, extending size of buffer

insertNAt :: YiString -> Point -> BufferM () Source #

Insert given `YiString` at specified point, extending size of the buffer.

insertB :: Char -> BufferM () Source #

Insert the char at current point, extending size of buffer

Implementation note: This just `insertB`s a `singleton`. This seems sub-optimal because we should be able to do much better without spewing chunks of size 1 everywhere. This approach is necessary however so an `Update` can be recorded. A possible improvement for space would be to have ‘yi-rope’ package optimise for appends with length 1.

deleteN :: Int -> BufferM () Source #

Delete `n` characters forward from the current point

nelemsB :: Int -> Point -> BufferM YiString Source #

writeB :: Char -> BufferM () Source #

Write an element into the buffer at the current point.

writeN :: YiString -> BufferM () Source #

Write the list into the buffer at current point.

newlineB :: BufferM () Source #

Insert newline at current point.

deleteNAt :: Direction -> Int -> Point -> BufferM () Source #

`deleteNAt n p` deletes `n` characters forwards from position `p`

readB :: BufferM Char Source #

Read the character at the current point

elemsB :: BufferM YiString Source #

Return the contents of the buffer.

undosA :: HasAttributes c => Lens' c URList Source #

undoB :: BufferM () Source #

redoB :: BufferM () Source #

getMarkB :: Maybe String -> BufferM Mark Source #

setMarkHereB :: BufferM Mark Source #

setNamedMarkHereB :: String -> BufferM () Source #

mayGetMarkB :: String -> BufferM (Maybe Mark) Source #

getMarkValueB :: Mark -> BufferM MarkValue Source #

markPointA :: Functor f => Mark -> (Point -> f Point) -> FBuffer -> f FBuffer Source #

modifyMarkB :: Mark -> (MarkValue -> MarkValue) -> BufferM () Source #

newMarkB :: MarkValue -> BufferM Mark Source #

deleteMarkB :: Mark -> BufferM () Source #

getVisibleSelection :: BufferM Bool Source #

Whether the selection is highlighted

setVisibleSelection :: Bool -> BufferM () Source #

Highlight the selection

isUnchangedBuffer :: FBuffer -> Bool Source #

setAnyMode :: AnyMode -> BufferM () Source #

Set the mode

setMode :: Mode syntax -> BufferM () Source #

setMode0 :: Mode syntax -> FBuffer -> FBuffer Source #

modifyMode :: (forall syntax. Mode syntax -> Mode syntax) -> BufferM () Source #

Modify the mode

regexRegionB :: SearchExp -> Region -> BufferM [Region] Source #

Return indices of strings in buffer matched by regex in the given region.

regexB :: Direction -> SearchExp -> BufferM [Region] Source #

Return indices of next string in buffer matched by regex in the given direction

readAtB :: Point -> BufferM Char Source #

Read the character at the given index This is an unsafe operation: character NUL is returned when out of bounds

getModeLine :: [Text] -> BufferM Text Source #

Given a buffer, and some information update the modeline

N.B. the contents of modelines should be specified by user, and not hardcoded.

getPercent :: Point -> Point -> Text Source #

Given a point, and the file size, gives us a percent string

setInserting :: Bool -> BufferM () Source #

savingPrefCol :: BufferM a -> BufferM a Source #

forgetPreferCol :: BufferM () Source #

movingToPrefCol :: BufferM a -> BufferM a Source #

movingToPrefVisCol :: BufferM a -> BufferM a Source #

Moves to a visual column within the current line as shown on the editor (ie, moving within the current width of a single visual line)

preferColA :: HasAttributes c => Lens' c (Maybe Int) Source #

markSavedB :: UTCTime -> BufferM () Source #

Mark the current point in the undo list as a saved state.

retroactivelyAtSavePointB :: BufferM a -> BufferM a Source #

Undo all updates that happened since last save, perform a given action and redo all updates again. Given action must not modify undo history.

addOverlayB :: Overlay -> BufferM () Source #

Adds an "overlay" to the buffer

delOverlayB :: Overlay -> BufferM () Source #

Remove an existing "overlay"

delOverlaysOfOwnerB :: YiString -> BufferM () Source #

getOverlaysOfOwnerB :: YiString -> BufferM (Set Overlay) Source #

isPointInsideOverlay :: Point -> Overlay -> Bool Source #

savingExcursionB :: BufferM a -> BufferM a Source #

perform a `BufferM a`, and return to the current point. (by using a mark)

savingPointB :: BufferM a -> BufferM a Source #

Perform an `BufferM a`, and return to the current point.

savingPositionB :: BufferM a -> BufferM a Source #

Perform an `BufferM a`, and return to the current line and column number. The difference between this and `savingPointB` is that here we attempt to return to the specific line and column number, rather than a specific number of characters from the beginning of the buffer.

In case the column is further away than EOL, the point is left at EOL: `moveToLineColB` is used internally.

pendingUpdatesA :: HasAttributes c => Lens' c (Seq UIUpdate) Source #

highlightSelectionA :: Lens' FBuffer Bool Source #

rectangleSelectionA :: Lens' FBuffer Bool Source #

readOnlyA :: HasAttributes c => Lens' c Bool Source #

insertingA :: HasAttributes c => Lens' c Bool Source #

pointFollowsWindowA :: HasAttributes c => Lens' c (Set WindowRef) Source #

revertPendingUpdatesB :: BufferM () Source #

Revert all the pending updates; don't touch the point.

askWindow :: (Window -> a) -> BufferM a Source #

clearSyntax :: FBuffer -> FBuffer Source #

update the syntax information (clear the dirty "flag")

focusSyntax :: Map WindowRef Region -> FBuffer -> FBuffer Source #

data Mode syntax Source #

A Mode customizes the Yi interface for editing a particular data format. It specifies when the mode should be used and controls file-specific syntax highlighting and command input, among other things.

Constructors

Mode |

Fields

- modeName :: Text

  so this can be serialized, debugged.

- modeApplies :: FilePath -> YiString -> Bool

  What type of files does this mode apply to?

- modeHL :: ExtHL syntax

  Syntax highlighter

- modePrettify :: syntax -> BufferM ()

  Prettify current "paragraph"

- modeKeymap :: KeymapSet -> KeymapSet

  Buffer-local keymap modification

- modeIndent :: syntax -> IndentBehaviour -> BufferM ()

  emacs-style auto-indent line

- modeFollow :: syntax -> Action

  Follow a "link" in the file. (eg. go to location of error message)

- modeIndentSettings :: IndentSettings
- modeToggleCommentSelection :: Maybe (BufferM ())
- modeGetStrokes :: syntax -> Point -> Point -> Point -> [Stroke]

  Strokes that should be applied when displaying a syntax element should this be an Action instead?

- modeOnLoad :: BufferM ()

  An action that is to be executed when this mode is set

- modeModeLine :: [Text] -> BufferM Text

  buffer-local modeline formatting method

- modeGotoDeclaration :: BufferM ()

  go to the point where the variable is declared

#### Instances

Instances details

Binary (Mode syntax) Source # | Just stores the mode name.
Instance details Defined in Yi.Buffer.Misc Methods put :: Mode syntax -> Put Source # get :: Get (Mode syntax) Source # putList :: [Mode syntax] -> Put Source #

modeNameA :: forall syntax f. Functor f => (Text -> f Text) -> Mode syntax -> f (Mode syntax) Source #

modeAppliesA :: forall syntax f. Functor f => ((FilePath -> YiString -> Bool) -> f (FilePath -> YiString -> Bool)) -> Mode syntax -> f (Mode syntax) Source #

modeHLA :: forall syntax f. Functor f => (ExtHL syntax -> f (ExtHL syntax)) -> Mode syntax -> f (Mode syntax) Source #

modePrettifyA :: forall syntax f. Functor f => ((syntax -> BufferM ()) -> f (syntax -> BufferM ())) -> Mode syntax -> f (Mode syntax) Source #

modeKeymapA :: forall syntax f. Functor f => ((KeymapSet -> KeymapSet) -> f (KeymapSet -> KeymapSet)) -> Mode syntax -> f (Mode syntax) Source #

modeIndentA :: forall syntax f. Functor f => ((syntax -> IndentBehaviour -> BufferM ()) -> f (syntax -> IndentBehaviour -> BufferM ())) -> Mode syntax -> f (Mode syntax) Source #

modeFollowA :: forall syntax f. Functor f => ((syntax -> Action) -> f (syntax -> Action)) -> Mode syntax -> f (Mode syntax) Source #

modeIndentSettingsA :: forall syntax f. Functor f => (IndentSettings -> f IndentSettings) -> Mode syntax -> f (Mode syntax) Source #

modeToggleCommentSelectionA :: forall syntax f. Functor f => (Maybe (BufferM ()) -> f (Maybe (BufferM ()))) -> Mode syntax -> f (Mode syntax) Source #

modeGetStrokesA :: forall syntax f. Functor f => ((syntax -> Point -> Point -> Point -> [Stroke]) -> f (syntax -> Point -> Point -> Point -> [Stroke])) -> Mode syntax -> f (Mode syntax) Source #

modeOnLoadA :: forall syntax f. Functor f => (BufferM () -> f (BufferM ())) -> Mode syntax -> f (Mode syntax) Source #

modeGotoDeclarationA :: forall syntax f. Functor f => (BufferM () -> f (BufferM ())) -> Mode syntax -> f (Mode syntax) Source #

modeModeLineA :: forall syntax f. Functor f => (([Text] -> BufferM Text) -> f ([Text] -> BufferM Text)) -> Mode syntax -> f (Mode syntax) Source #

data AnyMode Source #

Constructors

AnyMode (Mode syntax) |

data IndentBehaviour Source #

Used to specify the behaviour of the automatic indent command.

Constructors

IncreaseCycle | Increase the indentation to the next higher indentation hint. If we are currently at the highest level of indentation then cycle back to the lowest.
DecreaseCycle | Decrease the indentation to the next smaller indentation hint. If we are currently at the smallest level then cycle back to the largest
IncreaseOnly | Increase the indentation to the next higher hint if no such hint exists do nothing.
DecreaseOnly | Decrease the indentation to the next smaller indentation hint, if no such hint exists do nothing.

#### Instances

Instances details

Show IndentBehaviour Source # |
Instance details Defined in Yi.Types Methods showsPrec :: Int -> IndentBehaviour -> ShowS Source # show :: IndentBehaviour -> String Source # showList :: [IndentBehaviour] -> ShowS Source #
Eq IndentBehaviour Source # |
Instance details Defined in Yi.Types Methods (==) :: IndentBehaviour -> IndentBehaviour -> Bool Source # (/=) :: IndentBehaviour -> IndentBehaviour -> Bool Source #

data IndentSettings Source #

Currently duplicates some of Vim's indent settings. Allowing a buffer to specify settings that are more dynamic, perhaps via closures, could be useful.

Constructors

IndentSettings |

Fields

- expandTabs :: !Bool

  Insert spaces instead of tabs as possible

- tabSize :: !Int

  Size of a Tab

- shiftWidth :: !Int

  Indent by so many columns

#### Instances

Instances details

Show IndentSettings Source # |
Instance details Defined in Yi.Types Methods showsPrec :: Int -> IndentSettings -> ShowS Source # show :: IndentSettings -> String Source # showList :: [IndentSettings] -> ShowS Source #
Eq IndentSettings Source # |
Instance details Defined in Yi.Types Methods (==) :: IndentSettings -> IndentSettings -> Bool Source # (/=) :: IndentSettings -> IndentSettings -> Bool Source #

expandTabsA :: Lens' IndentSettings Bool Source #

tabSizeA :: Lens' IndentSettings Int Source #

shiftWidthA :: Lens' IndentSettings Int Source #

modeAlwaysApplies :: a -> b -> Bool Source #

Mode applies function that always returns True.

modeNeverApplies :: a -> b -> Bool Source #

Mode applies function that always returns False.

emptyMode :: Mode syntax Source #

withModeB :: (forall syntax. Mode syntax -> BufferM a) -> BufferM a Source #

withMode0 :: (forall syntax. Mode syntax -> a) -> FBuffer -> a Source #

onMode :: (forall syntax. Mode syntax -> Mode syntax) -> AnyMode -> AnyMode Source #

withSyntaxB :: (forall syntax. Mode syntax -> syntax -> a) -> BufferM a Source #

withSyntaxB' :: (forall syntax. Mode syntax -> syntax -> BufferM a) -> BufferM a Source #

keymapProcessA :: HasAttributes c => Lens' c KeymapProcess Source #

strokesRangesB :: Maybe SearchExp -> Region -> BufferM [[Stroke]] Source #

streamB :: Direction -> Point -> BufferM YiString Source #

indexedStreamB :: Direction -> Point -> BufferM [(Point, Char)] Source #

askMarks :: BufferM WinMarks Source #

pointAt :: BufferM a -> BufferM Point Source #

data SearchExp Source #

#### Instances

Instances details

Binary SearchExp |
Instance details Defined in Yi.Regex Methods put :: SearchExp -> Put Source # get :: Get SearchExp Source # putList :: [SearchExp] -> Put Source #

lastActiveWindowA :: HasAttributes c => Lens' c Window Source #

putBufferDyn :: (YiVariable a, MonadState FBuffer m, Functor m) => a -> m () Source #

Access to a value into the extensible state, keyed by its type. This allows you to save inside a `BufferM` monad, ie:

    putBufferDyn updatedvalue

getBufferDyn :: forall m a. (Default a, YiVariable a, MonadState FBuffer m, Functor m) => m a Source #

Access to a value into the extensible state, keyed by its type. This allows you to retrieve inside a `BufferM` monad, ie:

    value <- getBufferDyn

shortIdentString Source #

Arguments

:: Int | Number of characters to drop from FileBuffer names
-> FBuffer | Buffer to work with
-> Text |

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 number of path components.

    >>> 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"

identString :: FBuffer -> Text Source #

Gets the buffer's identifier string, emphasising the `MemBuffer`:

    >>> 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"

miniIdentString :: FBuffer -> Text Source #

identA :: HasAttributes c => Lens' c BufferId Source #

directoryContentA :: HasAttributes c => Lens' c Bool Source #

data BufferId Source #

Constructors

MemBuffer !Text |
FileBuffer !FilePath |

#### Instances

Instances details

Binary BufferId Source # |
Instance details Defined in Yi.Types Methods put :: BufferId -> Put Source # get :: Get BufferId Source # putList :: [BufferId] -> Put Source #
Show BufferId Source # |
Instance details Defined in Yi.Types Methods showsPrec :: Int -> BufferId -> ShowS Source # show :: BufferId -> String Source # showList :: [BufferId] -> ShowS Source #
Eq BufferId Source # |
Instance details Defined in Yi.Types Methods (==) :: BufferId -> BufferId -> Bool Source # (/=) :: BufferId -> BufferId -> Bool Source #
Ord BufferId Source # |
Instance details Defined in Yi.Types Methods compare :: BufferId -> BufferId -> Ordering Source # (<) :: BufferId -> BufferId -> Bool Source # (<=) :: BufferId -> BufferId -> Bool Source # (>) :: BufferId -> BufferId -> Bool Source # (>=) :: BufferId -> BufferId -> Bool Source # max :: BufferId -> BufferId -> BufferId Source # min :: BufferId -> BufferId -> BufferId Source #

file :: FBuffer -> Maybe FilePath Source #

lastSyncTimeA :: HasAttributes c => Lens' c UTCTime Source #

replaceCharB :: Char -> BufferM () Source #

replaceCharWithBelowB :: BufferM () Source #

replaceCharWithAboveB :: BufferM () Source #

insertCharWithBelowB :: BufferM () Source #

insertCharWithAboveB :: BufferM () Source #

pointAfterCursorB :: Point -> BufferM Point Source #

destinationOfMoveB :: BufferM a -> BufferM Point Source #

What would be the point after doing the given action? The argument must not modify the buffer.

withEveryLineB :: BufferM () -> BufferM () Source #

startUpdateTransactionB :: BufferM () Source #

commitUpdateTransactionB :: BufferM () Source #

applyUpdate :: Update -> BufferM () Source #

betweenB Source #

Arguments

:: Point | Point to start at
-> Point | Point to stop at
-> BufferM YiString |

Returns the contents of the buffer between the two points.

If the `startPoint >= endPoint`, empty string is returned. If the points are out of bounds, as much of the content as possible is taken: you're not guaranteed to get `endPoint - startPoint` characters.

decreaseFontSize :: Int -> BufferM () Source #

Decreases the font size in the buffer by specified number. What this number actually means depends on the front-end.

increaseFontSize :: Int -> BufferM () Source #

Increases the font size in the buffer by specified number. What this number actually means depends on the front-end.

indentSettingsB :: BufferM IndentSettings Source #

Gives the `IndentSettings` for the current buffer.

fontsizeVariationA :: HasAttributes c => Lens' c Int Source #

stickyEolA :: HasAttributes c => Lens' c Bool Source #

queryBuffer :: (forall syntax. BufferImpl syntax -> x) -> BufferM x Source #

# Orphan instances

Binary FBuffer Source # |
Instance details Methods put :: FBuffer -> Put Source # get :: Get FBuffer Source # putList :: [FBuffer] -> Put Source #
Show FBuffer Source # |
Instance details Methods showsPrec :: Int -> FBuffer -> ShowS Source # show :: FBuffer -> String Source # showList :: [FBuffer] -> ShowS Source #
Binary (Mode syntax) Source # | Just stores the mode name.
Instance details Methods put :: Mode syntax -> Put Source # get :: Get (Mode syntax) Source # putList :: [Mode syntax] -> Put Source #