License | GPL-2 |
---|---|
Maintainer | yi-devel@googlegroups.com |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
Extensions |
|
The Buffer
module defines monadic editing operations over one-dimensional
buffers, maintaining a current point.
- data FBuffer = forall syntax . FBuffer !(Mode syntax) !(BufferImpl syntax) !Attributes
- newtype BufferM a = BufferM {
- fromBufferM :: RWS Window [Update] FBuffer a
- type WinMarks = MarkSet Mark
- data MarkSet a = MarkSet {}
- bkey :: FBuffer -> BufferRef
- getMarks :: Window -> BufferM (Maybe WinMarks)
- runBuffer :: Window -> FBuffer -> BufferM a -> (a, FBuffer)
- runBufferFull :: Window -> FBuffer -> BufferM a -> (a, [Update], FBuffer)
- runBufferDummyWindow :: FBuffer -> BufferM a -> a
- 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 :: Mark -> Lens' FBuffer Point
- modifyMarkB :: Mark -> (MarkValue -> MarkValue) -> BufferM ()
- newMarkB :: MarkValue -> BufferM Mark
- deleteMarkB :: Mark -> BufferM ()
- setVisibleSelection :: Bool -> BufferM ()
- isUnchangedBuffer :: FBuffer -> Bool
- setAnyMode :: AnyMode -> BufferM ()
- setMode :: Mode syntax -> BufferM ()
- setMode0 :: forall syntax. 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 [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 (WindowRef -> Bool)
- 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 ()
- modeAdjustBlock :: syntax -> Int -> 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. Lens' (Mode syntax) Text
- modeAppliesA :: forall syntax. Lens' (Mode syntax) (FilePath -> YiString -> Bool)
- modeHLA :: forall syntax. Lens' (Mode syntax) (ExtHL syntax)
- modePrettifyA :: forall syntax. Lens' (Mode syntax) (syntax -> BufferM ())
- modeKeymapA :: forall syntax. Lens' (Mode syntax) (KeymapSet -> KeymapSet)
- modeIndentA :: forall syntax. Lens' (Mode syntax) (syntax -> IndentBehaviour -> BufferM ())
- modeAdjustBlockA :: forall syntax. Lens' (Mode syntax) (syntax -> Int -> BufferM ())
- modeFollowA :: forall syntax. Lens' (Mode syntax) (syntax -> Action)
- modeIndentSettingsA :: forall syntax. Lens' (Mode syntax) IndentSettings
- modeToggleCommentSelectionA :: forall syntax. Lens' (Mode syntax) (Maybe (BufferM ()))
- modeGetStrokesA :: forall syntax. Lens' (Mode syntax) (syntax -> Point -> Point -> Point -> [Stroke])
- modeOnLoadA :: forall syntax. Lens' (Mode syntax) (BufferM ())
- modeModeLineA :: forall syntax. Lens' (Mode syntax) ([Text] -> BufferM Text)
- data AnyMode = forall syntax . AnyMode (Mode syntax)
- data IndentBehaviour
- 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 :: (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
- 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
- encodingConverterNameA :: HasAttributes c => Lens' c (Maybe ConverterName)
Documentation
forall syntax . FBuffer !(Mode syntax) !(BufferImpl syntax) !Attributes |
The BufferM monad writes the updates performed.
Monad BufferM | |
Functor BufferM | |
Applicative BufferM | |
MonadReader Window BufferM | |
MonadState FBuffer BufferM | |
MonadWriter [Update] BufferM | |
YiAction (BufferM x) x | |
MkSnippetCmd (SnippetCmd a) a | |
Typeable (* -> *) BufferM |
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.
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.
Current column. Note that this is different from offset or number of chars from sol. (This takes into account tabs, unicode chars, etc.)
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.
MarkValue | |
|
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.
moveN :: Int -> BufferM () Source
Move point by the given number of characters. A negative offset moves backwards a positive one forward.
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.
deleteNAt :: Direction -> Int -> Point -> BufferM () Source
deleteNAt n p
deletes n
characters forwards from position p
setNamedMarkHereB :: String -> BufferM () Source
getMarkValueB :: Mark -> BufferM MarkValue Source
deleteMarkB :: Mark -> BufferM () Source
setVisibleSelection :: Bool -> BufferM () Source
Highlight the selection
isUnchangedBuffer :: FBuffer -> Bool Source
setAnyMode :: AnyMode -> BufferM () Source
Set the mode
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
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 [UIUpdate] Source
insertingA :: HasAttributes c => Lens' c Bool Source
pointFollowsWindowA :: HasAttributes c => Lens' c (WindowRef -> Bool) Source
revertPendingUpdatesB :: BufferM () Source
Revert all the pending updates; don't touch the point.
clearSyntax :: FBuffer -> FBuffer Source
update the syntax information (clear the dirty "flag")
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.
Mode | |
|
modePrettifyA :: forall syntax. Lens' (Mode syntax) (syntax -> BufferM ()) Source
modeIndentA :: forall syntax. Lens' (Mode syntax) (syntax -> IndentBehaviour -> BufferM ()) Source
modeFollowA :: forall syntax. Lens' (Mode syntax) (syntax -> Action) Source
modeIndentSettingsA :: forall syntax. Lens' (Mode syntax) IndentSettings Source
modeGetStrokesA :: forall syntax. Lens' (Mode syntax) (syntax -> Point -> Point -> Point -> [Stroke]) Source
modeOnLoadA :: forall syntax. Lens' (Mode syntax) (BufferM ()) Source
data IndentBehaviour Source
Used to specify the behaviour of the automatic indent command.
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. |
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.
IndentSettings | |
|
modeAlwaysApplies :: a -> b -> Bool Source
Mode applies function that always returns True.
modeNeverApplies :: a -> b -> Bool Source
Mode applies function that always returns False.
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
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 :: (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
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.
>>>
shortIdentString 3 (MemBuffer "hello")
"*hello*">>>
shortIdentString 3 (FileBuffer "hello")
"lo"
identString :: FBuffer -> Text Source
Gets the buffer's identifier string, emphasising the MemBuffer
:
>>>
identString (MemBuffer "hello")
"*hello*">>>
identString (FileBuffer "hello")
"hello"
miniIdentString :: FBuffer -> Text Source
directoryContentA :: HasAttributes c => Lens' c Bool Source
lastSyncTimeA :: HasAttributes c => Lens' c UTCTime Source
replaceCharB :: Char -> 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
applyUpdate :: Update -> BufferM () Source
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
encodingConverterNameA :: HasAttributes c => Lens' c (Maybe ConverterName) Source