- tabB :: BufferM String
- indentSettingsB :: BufferM IndentSettings
- autoIndentB :: IndentBehaviour -> BufferM ()
- autoIndentHelperB :: BufferM [Int] -> (String -> BufferM [Int]) -> IndentBehaviour -> BufferM ()
- cycleIndentsB :: IndentBehaviour -> [Int] -> BufferM ()
- fetchPreviousIndentsB :: BufferM [Int]
- autoIndentWithKeywordsB :: [String] -> [String] -> IndentBehaviour -> BufferM ()
- lastOpenBracketHint :: String -> BufferM [Int]
- keywordHints :: [String] -> String -> BufferM [Int]
- keywordAfterHints :: [String] -> String -> BufferM [Int]
- indentOfB :: String -> BufferM Int
- spacingOfB :: String -> BufferM Int
- indentToB :: Int -> BufferM ()
- indentAsPreviousB :: BufferM ()
- indentAsNextB :: BufferM ()
- indentAsNeighborLineB :: Direction -> BufferM ()
- newlineAndIndentB :: BufferM ()
- rePadString :: IndentSettings -> Int -> String -> String
- indentString :: IndentSettings -> Int -> String -> String
- shiftIndentOfRegion :: Int -> Region -> BufferM ()
- deleteIndentOfRegion :: Region -> BufferM ()
- indentOfCurrentPosB :: BufferM Int
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:
Retrieve the current indentation settings for the buffer.
|:: BufferM [Int]|
Action to fetch hints from previous lines
|-> (String -> BufferM [Int])|
Action to calculate hints from previous line
Sets the indent behaviour,
|-> BufferM ()|
This takes two arguments the first is a function to
obtain indentation hints from lines above the current one.
The second is a function to obtain a set of indentation hints
from the previous line. Both of these are in the
monad although the second seems like it is unnecessary.
However we must take into account the length of tabs which come
from the the tab settings and hence we must be in the
To get the straightforward behaviour of the indents of all previous
lines until one of them has zero indent call this with:
autoIndentHelperB fetchPreviousIndentsB (fmap (: ) indentOfB)
However commonly we wish to have something more interesting for
the second argument, in particular we commonly wish to have the
last opening bracket of the previous line as well as its indent.
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
A function generally useful as the first argument to
autoIndentHelperB. This searches the lines above
the current line for the indentations of each line
until we get to a line which has no indentation
*and* is not empty. Indicating that we have reached
the outer scope.
Keywords to act as hints
Keywords to act as offset hints
|-> BufferM ()|
An application of
autoIndentHelperB which adds more
indentation hints using the given keywords.
The offsets of the first set of keywords are used as hints.
For the second set of keywords it is not the offsets of the
keywords themselves but the offset of the first non-white
characters after the keywords.
In addition to the keyword hints we also do the same as the
autoIndentB) which is to use any non-closed
opening brackets as hints.
Returns the position of the last opening bracket on the line which is not closed on the same line. Note that if we have unmatched parentheses such as ( ] then we may not get the correct answer, but in that case then arguably we don't really care if we get the correct answer (at least if we get it wrong the user may notice their error). We return a list here as it's a convenient way of returning no hint in the case of there being no non-closed bracket and normally such a hint will be part of a list of hints anyway. NOTE: this could be easily modified to return the indentations of *all* the non-closed opening brackets. But I think this is not what you generally want. TODO: we also do not care whether or not the bracket is within a string or escaped. If someone feels up to caring about that by all means please fix this.
Returns the offsets of all the given keywords within the given string. This is potentially useful as providing indentation hints.
Returns the offsets of anything that isn't white space
a keyword on the given line.
This is essentially then the same as
keywordHints except that
for each keyword on the input rather than return the offset at
the start of the keyword we return the offset of the first non-white
character after the keyword.
Returns the indentation of a given string. Note that this depends on the current indentation settings.
Returns the length of a given string taking into account the white space and the indentation settings.
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.
Insert a newline at point and indent the new line as the previous one.
Set the padding of the string to newCount, filling in tabs if expandTabs is set in the buffers IndentSettings
shifts right (or left if num is negative) num times, filling in tabs if expandTabs is set in the buffers IndentSettings
Increases the indentation on the region by the given amount of shiftWidth