#include <inttypes.h>
#include <string.h>
#include "nvim/ascii.h"
#include "nvim/buffer_updates.h"
#include "nvim/change.h"
#include "nvim/charset.h"
#include "nvim/cursor.h"
#include "nvim/diff.h"
#include "nvim/eval.h"
#include "nvim/ex_docmd.h"
#include "nvim/ex_session.h"
#include "nvim/extmark.h"
#include "nvim/fold.h"
#include "nvim/func_attr.h"
#include "nvim/garray.h"
#include "nvim/indent.h"
#include "nvim/mark.h"
#include "nvim/memline.h"
#include "nvim/memory.h"
#include "nvim/message.h"
#include "nvim/move.h"
#include "nvim/ops.h"
#include "nvim/option.h"
#include "nvim/os/input.h"
#include "nvim/plines.h"
#include "nvim/screen.h"
#include "nvim/strings.h"
#include "nvim/syntax.h"
#include "nvim/undo.h"
#include "nvim/vim.h"
Data Structures | |
struct | fold_T |
struct | fline_T |
Macros | |
#define | FD_OPEN 0 |
#define | FD_CLOSED 1 |
#define | FD_LEVEL 2 |
#define | MAX_LEVEL 20 |
#define | DONE_NOTHING 0 |
#define | DONE_ACTION 1 |
#define | DONE_FOLD 2 |
#define | DELETE_FOLD_NESTED(fd) deleteFoldRecurse(bp, &((fd)->fd_nested)) |
#define | FOLD_END(fp) ((fp)->fd_top + (fp)->fd_len - 1) |
#define | VALID_FOLD(fp, gap) ((gap)->ga_len > 0 && (fp) < ((fold_T *)(gap)->ga_data + (gap)->ga_len)) |
#define | FOLD_INDEX(fp, gap) ((size_t)((fp) - ((fold_T *)(gap)->ga_data))) |
Typedefs | |
typedef void(* | LevelGetter) (fline_T *) |
Functions | |
void | copyFoldingState (win_T *wp_from, win_T *wp_to) |
Copy that folding state from window "wp_from" to window "wp_to". More... | |
int | hasAnyFolding (win_T *win) |
bool | hasFolding (linenr_T lnum, linenr_T *firstp, linenr_T *lastp) |
bool | hasFoldingWin (win_T *const win, const linenr_T lnum, linenr_T *const firstp, linenr_T *const lastp, const bool cache, foldinfo_T *const infop) |
int | foldLevel (linenr_T lnum) |
bool | lineFolded (win_T *const win, const linenr_T lnum) |
foldinfo_T | fold_info (win_T *win, linenr_T lnum) |
int | foldmethodIsManual (win_T *wp) |
int | foldmethodIsIndent (win_T *wp) |
int | foldmethodIsExpr (win_T *wp) |
int | foldmethodIsMarker (win_T *wp) |
int | foldmethodIsSyntax (win_T *wp) |
int | foldmethodIsDiff (win_T *wp) |
void | closeFold (pos_T pos, long count) |
void | closeFoldRecurse (pos_T pos) |
Close fold for current window at position pos recursively. More... | |
void | opFoldRange (pos_T firstpos, pos_T lastpos, int opening, int recurse, int had_visual) |
void | openFold (pos_T pos, long count) |
void | openFoldRecurse (pos_T pos) |
Open fold for current window at position pos recursively. More... | |
void | foldOpenCursor (void) |
Open folds until the cursor line is not in a closed fold. More... | |
void | newFoldLevel (void) |
Set new foldlevel for current window. More... | |
void | foldCheckClose (void) |
Apply 'foldlevel' to all folds that don't contain the cursor. More... | |
int | foldManualAllowed (bool create) |
void | foldCreate (win_T *wp, pos_T start, pos_T end) |
void | deleteFold (win_T *const wp, const linenr_T start, const linenr_T end, const int recursive, const bool had_visual) |
void | clearFolding (win_T *win) |
Remove all folding for window "win". More... | |
void | foldUpdate (win_T *wp, linenr_T top, linenr_T bot) |
void | foldUpdateAfterInsert (void) |
Updates folds when leaving insert-mode. More... | |
void | foldUpdateAll (win_T *win) |
int | foldMoveTo (const bool updown, const int dir, const long count) |
void | foldInitWin (win_T *new_win) |
Init the fold info in a new window. More... | |
int | find_wl_entry (win_T *win, linenr_T lnum) |
void | foldAdjustVisual (void) |
Adjust the Visual area to include any fold at the start or end completely. More... | |
void | foldAdjustCursor (void) |
Move the cursor to the first line of a closed fold. More... | |
void | cloneFoldGrowArray (garray_T *from, garray_T *to) |
Will "clone" (i.e deep copy) a garray_T of folds. More... | |
void | deleteFoldRecurse (buf_T *bp, garray_T *gap) |
Delete nested folds in a fold. More... | |
void | foldMarkAdjust (win_T *wp, linenr_T line1, linenr_T line2, long amount, long amount_after) |
Update line numbers of folds for inserted/deleted lines. More... | |
int | getDeepestNesting (win_T *wp) |
char_u * | get_foldtext (win_T *wp, linenr_T lnum, linenr_T lnume, foldinfo_T foldinfo, char_u *buf) FUNC_ATTR_NONNULL_ARG(1) |
void | foldtext_cleanup (char_u *str) |
Remove 'foldmarker' and 'commentstring' from "str" (in-place). More... | |
void | foldMoveRange (win_T *const wp, garray_T *gap, const linenr_T line1, const linenr_T line2, const linenr_T dest) |
int | put_folds (FILE *fd, win_T *wp) |
#define DELETE_FOLD_NESTED | ( | fd | ) | deleteFoldRecurse(bp, &((fd)->fd_nested)) |
#define DONE_ACTION 1 |
#define DONE_FOLD 2 |
#define DONE_NOTHING 0 |
#define FD_CLOSED 1 |
#define FD_LEVEL 2 |
#define FD_OPEN 0 |
#define MAX_LEVEL 20 |
#define VALID_FOLD | ( | fp, | |
gap | |||
) | ((gap)->ga_len > 0 && (fp) < ((fold_T *)(gap)->ga_data + (gap)->ga_len)) |
Will "clone" (i.e deep copy) a garray_T of folds.
Close fold for current window at position "pos". Repeat "count" times.
Copy that folding state from window "wp_from" to window "wp_to".
void deleteFold | ( | win_T *const | wp, |
const linenr_T | start, | ||
const linenr_T | end, | ||
const int | recursive, | ||
const bool | had_visual | ||
) |
start | delete all folds from start to end when not 0 |
end | delete all folds from start to end when not 0 |
recursive | delete recursively if true |
had_visual | true when Visual selection used |
Find an entry in the win->w_lines[] array for buffer line "lnum". Only valid entries are considered (for entries where wl_valid is FALSE the line number can be wrong).
foldinfo_T fold_info | ( | win_T * | win, |
linenr_T | lnum | ||
) |
Count the number of lines that are folded at line number "lnum". Normally "lnum" is the first line of a possible fold, and the returned number is the number of lines in the fold. Doesn't use caching from the displayed window.
Adjust the Visual area to include any fold at the start or end completely.
Create a fold from line "start" to line "end" (inclusive) in the current window.
int foldLevel | ( | linenr_T | lnum | ) |
int foldManualAllowed | ( | bool | create | ) |
Update line numbers of folds for inserted/deleted lines.
int foldmethodIsDiff | ( | win_T * | wp | ) |
int foldmethodIsExpr | ( | win_T * | wp | ) |
int foldmethodIsIndent | ( | win_T * | wp | ) |
int foldmethodIsManual | ( | win_T * | wp | ) |
int foldmethodIsMarker | ( | win_T * | wp | ) |
int foldmethodIsSyntax | ( | win_T * | wp | ) |
void foldMoveRange | ( | win_T *const | wp, |
garray_T * | gap, | ||
const linenr_T | line1, | ||
const linenr_T | line2, | ||
const linenr_T | dest | ||
) |
int foldMoveTo | ( | const bool | updown, |
const int | dir, | ||
const long | count | ||
) |
If "updown" is false: Move to the start or end of the fold. If "updown" is true: move to fold at the same level.
dir | FORWARD or BACKWARD |
Remove 'foldmarker' and 'commentstring' from "str" (in-place).
Update folds for changes in the buffer of a window. Note that inserted/deleted lines must have already been taken care of by calling foldMarkAdjust(). The changes in lines from top to bot (inclusive).
Update all lines in a window for folding. Used when a fold setting changes or after reloading the buffer. The actual updating is postponed until fold info is used, to avoid doing every time a setting is changed or a syntax item is added.
char_u* get_foldtext | ( | win_T * | wp, |
linenr_T | lnum, | ||
linenr_T | lnume, | ||
foldinfo_T | foldinfo, | ||
char_u * | buf | ||
) |
Generates text to display
buf | allocated memory of length FOLD_TEXT_LEN. Used when 'foldtext' isn't set puts the result in "buf[FOLD_TEXT_LEN]". |
at | line "lnum", with last line "lnume". |
Otherwise the result is in allocated memory.
int getDeepestNesting | ( | win_T * | wp | ) |
Get the lowest 'foldlevel' value that makes the deepest nested fold in window wp
.
int hasAnyFolding | ( | win_T * | win | ) |
When returning true, *firstp and *lastp are set to the first and last lnum of the sequence of folded lines (skipped when NULL).
bool hasFoldingWin | ( | win_T *const | win, |
const linenr_T | lnum, | ||
linenr_T *const | firstp, | ||
linenr_T *const | lastp, | ||
const bool | cache, | ||
foldinfo_T *const | infop | ||
) |
Search folds starting at lnum
lnum | first line to search | |
[out] | first | first line of fold containing lnum |
[out] | lastp | last line with a fold |
cache | when true: use cached values of window | |
[out] | infop | where to store fold info |
Low level function to check if a line is folded. Doesn't use any caching.
Open fold for current window at position "pos". Repeat "count" times.
Open or Close folds for current window in lines "first" to "last". Used for "zo", "zO", "zc" and "zC" in Visual mode.
opening | TRUE to open, FALSE to close |
recurse | TRUE to do it recursively |
had_visual | TRUE when Visual selection used |
int put_folds | ( | FILE * | fd, |
win_T * | wp | ||
) |
Write commands to "fd" to restore the manual folds in window "wp".