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

- OverloadedStrings
- LambdaCase

Yi.Buffer.Indent

Description

Handles indentation in the keymaps. Includes:

- (TODO) Auto-indentation to the previous lines indentation
- Tab-expansion
- Shifting of the indentation for a region of text

Synopsis

- autoIndentB :: IndentBehaviour -> BufferM ()
- cycleIndentsB :: IndentBehaviour -> [Int] -> BufferM ()
- indentAsNextB :: BufferM ()
- indentAsPreviousB :: BufferM ()
- indentAsTheMostIndentedNeighborLineB :: BufferM ()
- indentOfB :: YiString -> BufferM Int
- indentOfCurrentPosB :: BufferM Int
- indentSettingsB :: BufferM IndentSettings
- indentToB :: Int -> BufferM ()
- modifyIndentB :: (Int -> Int) -> BufferM ()
- newlineAndIndentB :: BufferM ()
- shiftIndentOfRegionB :: Int -> Region -> BufferM ()
- tabB :: BufferM String

# Documentation

autoIndentB :: IndentBehaviour -> BufferM () Source #

A specialisation of `autoIndentHelperB`. This is the most basic and the user is encouraged to specialise `autoIndentHelperB` on their own.

cycleIndentsB :: IndentBehaviour -> [Int] -> BufferM () Source #

Cycles through the indentation hints. It does this without requiring to set/get any state. We just look at the current indentation of the current line and moving to the largest indent that is

indentAsNextB :: BufferM () Source #

Indent as much as the next line

indentAsPreviousB :: BufferM () Source #

Indent as much as the previous line

indentAsTheMostIndentedNeighborLineB :: BufferM () Source #

indentOfB :: YiString -> BufferM Int Source #

Returns the indentation of a given string. Note that this depends on the current indentation settings.

indentOfCurrentPosB :: BufferM Int Source #

Return the number of spaces at the beginning of the line, up to the point.

indentSettingsB :: BufferM IndentSettings Source #

Gives the `IndentSettings` for the current buffer.

indentToB :: Int -> BufferM () Source #

Indents the current line to the given indentation level. In addition moves the point according to where it was on the line originally. If we were somewhere within the indentation (ie at the start of the line or on an empty line) then we want to just go to the end of the (new) indentation. However if we are currently pointing somewhere within the text of the line then we wish to remain pointing to the same character.

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

Modifies current line indent measured in visible spaces. Respects indent settings. Calling this with value (+ 4) will turn "t" into "tt" if shiftwidth is 4 and into "t " if shiftwidth is 8 If current line is empty nothing happens.

newlineAndIndentB :: BufferM () Source #

Insert a newline at point and indent the new line as the previous one.

shiftIndentOfRegionB :: Int -> Region -> BufferM () Source #

Increases the indentation on the region by the given amount of shiftWidth

tabB :: BufferM String Source #

Return either a t or the number of spaces specified by tabSize in the IndentSettings. Note that if you actually want to insert a tab character (for example when editing makefiles) then you should use: `insertB 't'`.