diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-12-01 21:41:28 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-12-01 21:41:28 +0100 |
commit | 217e1b8359447f5550dcb0d1ee43380a90c253c5 (patch) | |
tree | 137e8b7d6f27848c95caa47e2fc13a4dc4c50d29 /src/fold.c | |
parent | 5d18efecfd6c45d69f55268948a22cd0465bb955 (diff) |
patch 8.1.2379: using old C style commentsv8.1.2379
Problem: Using old C style comments.
Solution: Use // comments where appropriate.
Diffstat (limited to 'src/fold.c')
-rw-r--r-- | src/fold.c | 870 |
1 files changed, 432 insertions, 438 deletions
diff --git a/src/fold.c b/src/fold.c index 8cadd43277..d91203c75c 100644 --- a/src/fold.c +++ b/src/fold.c @@ -16,8 +16,8 @@ #if defined(FEAT_FOLDING) || defined(PROTO) -/* local declarations. {{{1 */ -/* typedef fold_T {{{2 */ +// local declarations. {{{1 +// typedef fold_T {{{2 /* * The toplevel folds for each window are stored in the w_folds growarray. * Each toplevel fold can contain an array of second level folds in the @@ -26,23 +26,23 @@ */ typedef struct { - linenr_T fd_top; /* first line of fold; for nested fold - * relative to parent */ - linenr_T fd_len; /* number of lines in the fold */ - garray_T fd_nested; /* array of nested folds */ - char fd_flags; /* see below */ - char fd_small; /* TRUE, FALSE or MAYBE: fold smaller than - 'foldminlines'; MAYBE applies to nested - folds too */ + linenr_T fd_top; // first line of fold; for nested fold + // relative to parent + linenr_T fd_len; // number of lines in the fold + garray_T fd_nested; // array of nested folds + char fd_flags; // see below + char fd_small; // TRUE, FALSE or MAYBE: fold smaller than + // 'foldminlines'; MAYBE applies to nested + // folds too } fold_T; -#define FD_OPEN 0 /* fold is open (nested ones can be closed) */ -#define FD_CLOSED 1 /* fold is closed */ -#define FD_LEVEL 2 /* depends on 'foldlevel' (nested folds too) */ +#define FD_OPEN 0 // fold is open (nested ones can be closed) +#define FD_CLOSED 1 // fold is closed +#define FD_LEVEL 2 // depends on 'foldlevel' (nested folds too) -#define MAX_LEVEL 20 /* maximum fold depth */ +#define MAX_LEVEL 20 // maximum fold depth -/* static functions {{{2 */ +// static functions {{{2 static void newFoldLevelWin(win_T *wp); static int checkCloseRec(garray_T *gap, linenr_T lnum, int level); static int foldFind(garray_T *gap, linenr_T lnum, fold_T **fpp); @@ -84,17 +84,17 @@ static linenr_T invalid_bot = (linenr_T)0; static linenr_T prev_lnum = 0; static int prev_lnum_lvl = -1; -/* Flags used for "done" argument of setManualFold. */ +// Flags used for "done" argument of setManualFold. #define DONE_NOTHING 0 -#define DONE_ACTION 1 /* did close or open a fold */ -#define DONE_FOLD 2 /* did find a fold */ +#define DONE_ACTION 1 // did close or open a fold +#define DONE_FOLD 2 // did find a fold static int foldstartmarkerlen; static char_u *foldendmarker; static int foldendmarkerlen; -/* Exported folding functions. {{{1 */ -/* copyFoldingState() {{{2 */ +// Exported folding functions. {{{1 +// copyFoldingState() {{{2 /* * Copy that folding state from window "wp_from" to window "wp_to". @@ -107,19 +107,19 @@ copyFoldingState(win_T *wp_from, win_T *wp_to) cloneFoldGrowArray(&wp_from->w_folds, &wp_to->w_folds); } -/* hasAnyFolding() {{{2 */ +// hasAnyFolding() {{{2 /* * Return TRUE if there may be folded lines in the current window. */ int hasAnyFolding(win_T *win) { - /* very simple now, but can become more complex later */ + // very simple now, but can become more complex later return (win->w_p_fen && (!foldmethodIsManual(win) || win->w_folds.ga_len > 0)); } -/* hasFolding() {{{2 */ +// hasFolding() {{{2 /* * Return TRUE if line "lnum" in the current window is part of a closed * fold. @@ -132,15 +132,15 @@ hasFolding(linenr_T lnum, linenr_T *firstp, linenr_T *lastp) return hasFoldingWin(curwin, lnum, firstp, lastp, TRUE, NULL); } -/* hasFoldingWin() {{{2 */ +// hasFoldingWin() {{{2 int hasFoldingWin( win_T *win, linenr_T lnum, linenr_T *firstp, linenr_T *lastp, - int cache, /* when TRUE: use cached values of window */ - foldinfo_T *infop) /* where to store fold info */ + int cache, // when TRUE: use cached values of window + foldinfo_T *infop) // where to store fold info { int had_folded = FALSE; linenr_T first = 0; @@ -192,25 +192,25 @@ hasFoldingWin( if (!foldFind(gap, lnum_rel, &fp)) break; - /* Remember lowest level of fold that starts in "lnum". */ + // Remember lowest level of fold that starts in "lnum". if (lnum_rel == fp->fd_top && low_level == 0) low_level = level + 1; first += fp->fd_top; last += fp->fd_top; - /* is this fold closed? */ + // is this fold closed? had_folded = check_closed(win, fp, &use_level, level, &maybe_small, lnum - lnum_rel); if (had_folded) { - /* Fold closed: Set last and quit loop. */ + // Fold closed: Set last and quit loop. last += fp->fd_len - 1; break; } - /* Fold found, but it's open: Check nested folds. Line number is - * relative to containing fold. */ + // Fold found, but it's open: Check nested folds. Line number is + // relative to containing fold. gap = &fp->fd_nested; lnum_rel -= fp->fd_top; ++level; @@ -243,7 +243,7 @@ hasFoldingWin( return TRUE; } -/* foldLevel() {{{2 */ +// foldLevel() {{{2 #ifdef FEAT_EVAL /* * Return fold level at line number "lnum" in the current window. @@ -251,8 +251,8 @@ hasFoldingWin( static int foldLevel(linenr_T lnum) { - /* While updating the folds lines between invalid_top and invalid_bot have - * an undefined fold level. Otherwise update the folds first. */ + // While updating the folds lines between invalid_top and invalid_bot have + // an undefined fold level. Otherwise update the folds first. if (invalid_top == (linenr_T)0) checkupdate(curwin); else if (lnum == prev_lnum && prev_lnum_lvl >= 0) @@ -260,7 +260,7 @@ foldLevel(linenr_T lnum) else if (lnum >= invalid_top && lnum <= invalid_bot) return -1; - /* Return quickly when there is no folding at all in this window. */ + // Return quickly when there is no folding at all in this window. if (!hasAnyFolding(curwin)) return 0; @@ -268,7 +268,7 @@ foldLevel(linenr_T lnum) } #endif -/* lineFolded() {{{2 */ +// lineFolded() {{{2 /* * Low level function to check if a line is folded. Doesn't use any caching. * Return TRUE if line is folded. @@ -281,7 +281,7 @@ lineFolded(win_T *win, linenr_T lnum) return foldedCount(win, lnum, NULL) != 0; } -/* foldedCount() {{{2 */ +// foldedCount() {{{2 /* * 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 @@ -300,7 +300,7 @@ foldedCount(win_T *win, linenr_T lnum, foldinfo_T *infop) return 0; } -/* foldmethodIsManual() {{{2 */ +// foldmethodIsManual() {{{2 /* * Return TRUE if 'foldmethod' is "manual" */ @@ -310,7 +310,7 @@ foldmethodIsManual(win_T *wp) return (wp->w_p_fdm[3] == 'u'); } -/* foldmethodIsIndent() {{{2 */ +// foldmethodIsIndent() {{{2 /* * Return TRUE if 'foldmethod' is "indent" */ @@ -320,7 +320,7 @@ foldmethodIsIndent(win_T *wp) return (wp->w_p_fdm[0] == 'i'); } -/* foldmethodIsExpr() {{{2 */ +// foldmethodIsExpr() {{{2 /* * Return TRUE if 'foldmethod' is "expr" */ @@ -330,7 +330,7 @@ foldmethodIsExpr(win_T *wp) return (wp->w_p_fdm[1] == 'x'); } -/* foldmethodIsMarker() {{{2 */ +// foldmethodIsMarker() {{{2 /* * Return TRUE if 'foldmethod' is "marker" */ @@ -340,7 +340,7 @@ foldmethodIsMarker(win_T *wp) return (wp->w_p_fdm[2] == 'r'); } -/* foldmethodIsSyntax() {{{2 */ +// foldmethodIsSyntax() {{{2 /* * Return TRUE if 'foldmethod' is "syntax" */ @@ -350,7 +350,7 @@ foldmethodIsSyntax(win_T *wp) return (wp->w_p_fdm[0] == 's'); } -/* foldmethodIsDiff() {{{2 */ +// foldmethodIsDiff() {{{2 /* * Return TRUE if 'foldmethod' is "diff" */ @@ -360,7 +360,7 @@ foldmethodIsDiff(win_T *wp) return (wp->w_p_fdm[0] == 'd'); } -/* closeFold() {{{2 */ +// closeFold() {{{2 /* * Close fold for current window at line "lnum". * Repeat "count" times. @@ -371,7 +371,7 @@ closeFold(linenr_T lnum, long count) setFoldRepeat(lnum, count, FALSE); } -/* closeFoldRecurse() {{{2 */ +// closeFoldRecurse() {{{2 /* * Close fold for current window at line "lnum" recursively. */ @@ -381,7 +381,7 @@ closeFoldRecurse(linenr_T lnum) (void)setManualFold(lnum, FALSE, TRUE, NULL); } -/* opFoldRange() {{{2 */ +// opFoldRange() {{{2 /* * Open or Close folds for current window in lines "first" to "last". * Used for "zo", "zO", "zc" and "zC" in Visual mode. @@ -390,35 +390,35 @@ closeFoldRecurse(linenr_T lnum) opFoldRange( linenr_T first, linenr_T last, - int opening, /* TRUE to open, FALSE to close */ - int recurse, /* TRUE to do it recursively */ - int had_visual) /* TRUE when Visual selection used */ + int opening, // TRUE to open, FALSE to close + int recurse, // TRUE to do it recursively + int had_visual) // TRUE when Visual selection used { - int done = DONE_NOTHING; /* avoid error messages */ + int done = DONE_NOTHING; // avoid error messages linenr_T lnum; linenr_T lnum_next; for (lnum = first; lnum <= last; lnum = lnum_next + 1) { lnum_next = lnum; - /* Opening one level only: next fold to open is after the one going to - * be opened. */ + // Opening one level only: next fold to open is after the one going to + // be opened. if (opening && !recurse) (void)hasFolding(lnum, NULL, &lnum_next); (void)setManualFold(lnum, opening, recurse, &done); - /* Closing one level only: next line to close a fold is after just - * closed fold. */ + // Closing one level only: next line to close a fold is after just + // closed fold. if (!opening && !recurse) (void)hasFolding(lnum, NULL, &lnum_next); } if (done == DONE_NOTHING) emsg(_(e_nofold)); - /* Force a redraw to remove the Visual highlighting. */ + // Force a redraw to remove the Visual highlighting. if (had_visual) redraw_curbuf_later(INVERTED); } -/* openFold() {{{2 */ +// openFold() {{{2 /* * Open fold for current window at line "lnum". * Repeat "count" times. @@ -429,7 +429,7 @@ openFold(linenr_T lnum, long count) setFoldRepeat(lnum, count, TRUE); } -/* openFoldRecurse() {{{2 */ +// openFoldRecurse() {{{2 /* * Open fold for current window at line "lnum" recursively. */ @@ -439,7 +439,7 @@ openFoldRecurse(linenr_T lnum) (void)setManualFold(lnum, TRUE, TRUE, NULL); } -/* foldOpenCursor() {{{2 */ +// foldOpenCursor() {{{2 /* * Open folds until the cursor line is not in a closed fold. */ @@ -459,7 +459,7 @@ foldOpenCursor(void) } } -/* newFoldLevel() {{{2 */ +// newFoldLevel() {{{2 /* * Set new foldlevel for current window. */ @@ -497,9 +497,9 @@ newFoldLevelWin(win_T *wp) checkupdate(wp); if (wp->w_fold_manual) { - /* Set all flags for the first level of folds to FD_LEVEL. Following - * manual open/close will then change the flags to FD_OPEN or - * FD_CLOSED for those folds that don't use 'foldlevel'. */ + // Set all flags for the first level of folds to FD_LEVEL. Following + // manual open/close will then change the flags to FD_OPEN or + // FD_CLOSED for those folds that don't use 'foldlevel'. fp = (fold_T *)wp->w_folds.ga_data; for (i = 0; i < wp->w_folds.ga_len; ++i) fp[i].fd_flags = FD_LEVEL; @@ -508,14 +508,14 @@ newFoldLevelWin(win_T *wp) changed_window_setting_win(wp); } -/* foldCheckClose() {{{2 */ +// foldCheckClose() {{{2 /* * Apply 'foldlevel' to all folds that don't contain the cursor. */ void foldCheckClose(void) { - if (*p_fcl != NUL) /* can only be "all" right now */ + if (*p_fcl != NUL) // can only be "all" right now { checkupdate(curwin); if (checkCloseRec(&curwin->w_folds, curwin->w_cursor.lnum, @@ -524,7 +524,7 @@ foldCheckClose(void) } } -/* checkCloseRec() {{{2 */ +// checkCloseRec() {{{2 static int checkCloseRec(garray_T *gap, linenr_T lnum, int level) { @@ -535,7 +535,7 @@ checkCloseRec(garray_T *gap, linenr_T lnum, int level) fp = (fold_T *)gap->ga_data; for (i = 0; i < gap->ga_len; ++i) { - /* Only manually opened folds may need to be closed. */ + // Only manually opened folds may need to be closed. if (fp[i].fd_flags == FD_OPEN) { if (level <= 0 && (lnum < fp[i].fd_top @@ -552,7 +552,7 @@ checkCloseRec(garray_T *gap, linenr_T lnum, int level) return retval; } -/* foldCreateAllowed() {{{2 */ +// foldCreateAllowed() {{{2 /* * Return TRUE if it's allowed to manually create or delete a fold. * Give an error message and return FALSE if not. @@ -569,7 +569,7 @@ foldManualAllowed(int create) return FALSE; } -/* foldCreate() {{{2 */ +// foldCreate() {{{2 /* * Create a fold from line "start" to line "end" (inclusive) in the current * window. @@ -590,14 +590,14 @@ foldCreate(linenr_T start, linenr_T end) if (start > end) { - /* reverse the range */ + // reverse the range end = start_rel; start = end_rel; start_rel = start; end_rel = end; } - /* When 'foldmethod' is "marker" add markers, which creates the folds. */ + // When 'foldmethod' is "marker" add markers, which creates the folds. if (foldmethodIsMarker(curwin)) { foldCreateMarkers(start, end); @@ -606,7 +606,7 @@ foldCreate(linenr_T start, linenr_T end) checkupdate(curwin); - /* Find the place to insert the new fold. */ + // Find the place to insert the new fold. gap = &curwin->w_folds; for (;;) { @@ -614,7 +614,7 @@ foldCreate(linenr_T start, linenr_T end) break; if (fp->fd_top + fp->fd_len > end_rel) { - /* New fold is completely inside this fold: Go one level deeper. */ + // New fold is completely inside this fold: Go one level deeper. gap = &fp->fd_nested; start_rel -= fp->fd_top; end_rel -= fp->fd_top; @@ -630,8 +630,8 @@ foldCreate(linenr_T start, linenr_T end) } else { - /* This fold and new fold overlap: Insert here and move some folds - * inside the new fold. */ + // This fold and new fold overlap: Insert here and move some folds + // inside the new fold. break; } } @@ -642,45 +642,44 @@ foldCreate(linenr_T start, linenr_T end) fp = (fold_T *)gap->ga_data + i; ga_init2(&fold_ga, (int)sizeof(fold_T), 10); - /* Count number of folds that will be contained in the new fold. */ + // Count number of folds that will be contained in the new fold. for (cont = 0; i + cont < gap->ga_len; ++cont) if (fp[cont].fd_top > end_rel) break; if (cont > 0 && ga_grow(&fold_ga, cont) == OK) { - /* If the first fold starts before the new fold, let the new fold - * start there. Otherwise the existing fold would change. */ + // If the first fold starts before the new fold, let the new fold + // start there. Otherwise the existing fold would change. if (start_rel > fp->fd_top) start_rel = fp->fd_top; - /* When last contained fold isn't completely contained, adjust end - * of new fold. */ + // When last contained fold isn't completely contained, adjust end + // of new fold. if (end_rel < fp[cont - 1].fd_top + fp[cont - 1].fd_len - 1) end_rel = fp[cont - 1].fd_top + fp[cont - 1].fd_len - 1; - /* Move contained folds to inside new fold. */ + // Move contained folds to inside new fold. mch_memmove(fold_ga.ga_data, fp, sizeof(fold_T) * cont); fold_ga.ga_len += cont; i += cont; - /* Adjust line numbers in contained folds to be relative to the - * new fold. */ + // Adjust line numbers in contained folds to be relative to the + // new fold. for (j = 0; j < cont; ++j) ((fold_T *)fold_ga.ga_data)[j].fd_top -= start_rel; } - /* Move remaining entries to after the new fold. */ + // Move remaining entries to after the new fold. if (i < gap->ga_len) mch_memmove(fp + 1, (fold_T *)gap->ga_data + i, sizeof(fold_T) * (gap->ga_len - i)); gap->ga_len = gap->ga_len + 1 - cont; - /* insert new fold */ + // insert new fold fp->fd_nested = fold_ga; fp->fd_top = start_rel; fp->fd_len = end_rel - start_rel + 1; - /* We want the new fold to be closed. If it would remain open because - * of using 'foldlevel', need to adjust fd_flags of containing folds. - */ + // We want the new fold to be closed. If it would remain open because + // of using 'foldlevel', need to adjust fd_flags of containing folds. if (use_level && !closed && level < curwin->w_p_fdl) closeFold(start, 1L); if (!use_level) @@ -688,12 +687,12 @@ foldCreate(linenr_T start, linenr_T end) fp->fd_flags = FD_CLOSED; fp->fd_small = MAYBE; - /* redraw */ + // redraw changed_window_setting(); } } -/* deleteFold() {{{2 */ +// deleteFold() {{{2 /* * Delete a fold at line "start" in the current window. * When "end" is not 0, delete all folds from "start" to "end". @@ -704,7 +703,7 @@ deleteFold( linenr_T start, linenr_T end, int recursive, - int had_visual) /* TRUE when Visual selection used */ + int had_visual) // TRUE when Visual selection used { garray_T *gap; fold_T *fp; @@ -724,7 +723,7 @@ deleteFold( while (lnum <= end) { - /* Find the deepest fold for "start". */ + // Find the deepest fold for "start". gap = &curwin->w_folds; found_ga = NULL; lnum_off = 0; @@ -733,17 +732,17 @@ deleteFold( { if (!foldFind(gap, lnum - lnum_off, &fp)) break; - /* lnum is inside this fold, remember info */ + // lnum is inside this fold, remember info found_ga = gap; found_fp = fp; found_off = lnum_off; - /* if "lnum" is folded, don't check nesting */ + // if "lnum" is folded, don't check nesting if (check_closed(curwin, fp, &use_level, level, &maybe_small, lnum_off)) break; - /* check nested folds */ + // check nested folds gap = &fp->fd_nested; lnum_off += fp->fd_top; ++level; @@ -771,26 +770,26 @@ deleteFold( } did_one = TRUE; - /* redraw window */ + // redraw window changed_window_setting(); } } if (!did_one) { emsg(_(e_nofold)); - /* Force a redraw to remove the Visual highlighting. */ + // Force a redraw to remove the Visual highlighting. if (had_visual) redraw_curbuf_later(INVERTED); } else - /* Deleting markers may make cursor column invalid. */ + // Deleting markers may make cursor column invalid. check_cursor_col(); if (last_lnum > 0) changed_lines(first_lnum, (colnr_T)0, last_lnum, 0L); } -/* clearFolding() {{{2 */ +// clearFolding() {{{2 /* * Remove all folding for window "win". */ @@ -801,7 +800,7 @@ clearFolding(win_T *win) win->w_foldinvalid = FALSE; } -/* foldUpdate() {{{2 */ +// foldUpdate() {{{2 /* * Update folds for changes in the buffer of a window. * Note that inserted/deleted lines must have already been taken care of by @@ -821,7 +820,7 @@ foldUpdate(win_T *wp, linenr_T top, linenr_T bot) return; #endif - /* Mark all folds from top to bot as maybe-small. */ + // Mark all folds from top to bot as maybe-small. (void)foldFind(&wp->w_folds, top, &fp); while (fp < (fold_T *)wp->w_folds.ga_data + wp->w_folds.ga_len && fp->fd_top < bot) @@ -840,14 +839,14 @@ foldUpdate(win_T *wp, linenr_T top, linenr_T bot) { int save_got_int = got_int; - /* reset got_int here, otherwise it won't work */ + // reset got_int here, otherwise it won't work got_int = FALSE; foldUpdateIEMS(wp, top, bot); got_int |= save_got_int; } } -/* foldUpdateAll() {{{2 */ +// foldUpdateAll() {{{2 /* * Update all lines in a window for folding. * Used when a fold setting changes or after reloading the buffer. @@ -861,7 +860,7 @@ foldUpdateAll(win_T *win) redraw_win_later(win, NOT_VALID); } -/* foldMoveTo() {{{2 */ +// foldMoveTo() {{{2 /* * If "updown" is FALSE: Move to the start or end of the fold. * If "updown" is TRUE: move to fold at the same level. @@ -870,7 +869,7 @@ foldUpdateAll(win_T *win) int foldMoveTo( int updown, - int dir, /* FORWARD or BACKWARD */ + int dir, // FORWARD or BACKWARD long count) { long n; @@ -887,11 +886,11 @@ foldMoveTo( checkupdate(curwin); - /* Repeat "count" times. */ + // Repeat "count" times. for (n = 0; n < count; ++n) { - /* Find nested folds. Stop when a fold is closed. The deepest fold - * that moves the cursor is used. */ + // Find nested folds. Stop when a fold is closed. The deepest fold + // that moves the cursor is used. lnum_off = 0; gap = &curwin->w_folds; use_level = FALSE; @@ -906,8 +905,8 @@ foldMoveTo( if (!updown) break; - /* When moving up, consider a fold above the cursor; when - * moving down consider a fold below the cursor. */ + // When moving up, consider a fold above the cursor; when + // moving down consider a fold below the cursor. if (dir == FORWARD) { if (fp - (fold_T *)gap->ga_data >= gap->ga_len) @@ -919,19 +918,19 @@ foldMoveTo( if (fp == (fold_T *)gap->ga_data) break; } - /* don't look for contained folds, they will always move - * the cursor too far. */ + // don't look for contained folds, they will always move + // the cursor too far. last = TRUE; } if (!last) { - /* Check if this fold is closed. */ + // Check if this fold is closed. if (check_closed(curwin, fp, &use_level, level, &maybe_small, lnum_off)) last = TRUE; - /* "[z" and "]z" stop at closed fold */ + // "[z" and "]z" stop at closed fold if (last && !updown) break; } @@ -940,7 +939,7 @@ foldMoveTo( { if (dir == FORWARD) { - /* to start of next fold if there is one */ + // to start of next fold if there is one if (fp + 1 - (fold_T *)gap->ga_data < gap->ga_len) { lnum = fp[1].fd_top + lnum_off; @@ -950,7 +949,7 @@ foldMoveTo( } else { - /* to end of previous fold if there is one */ + // to end of previous fold if there is one if (fp > (fold_T *)gap->ga_data) { lnum = fp[-1].fd_top + lnum_off + fp[-1].fd_len - 1; @@ -961,8 +960,8 @@ foldMoveTo( } else { - /* Open fold found, set cursor to its start/end and then check - * nested folds. */ + // Open fold found, set cursor to its start/end and then check + // nested folds. if (dir == FORWARD) { lnum = fp->fd_top + lnum_off + fp->fd_len - 1; @@ -980,7 +979,7 @@ foldMoveTo( if (last) break; - /* Check nested folds (if any). */ + // Check nested folds (if any). gap = &fp->fd_nested; lnum_off += fp->fd_top; ++level; @@ -1000,7 +999,7 @@ foldMoveTo( return retval; } -/* foldInitWin() {{{2 */ +// foldInitWin() {{{2 /* * Init the fold info in a new window. */ @@ -1010,7 +1009,7 @@ foldInitWin(win_T *new_win) ga_init2(&new_win->w_folds, (int)sizeof(fold_T), 10); } -/* find_wl_entry() {{{2 */ +// find_wl_entry() {{{2 /* * 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 @@ -1033,7 +1032,7 @@ find_wl_entry(win_T *win, linenr_T lnum) return -1; } -/* foldAdjustVisual() {{{2 */ +// foldAdjustVisual() {{{2 /* * Adjust the Visual area to include any fold at the start or end completely. */ @@ -1064,13 +1063,13 @@ foldAdjustVisual(void) end->col = (colnr_T)STRLEN(ptr); if (end->col > 0 && *p_sel == 'o') --end->col; - /* prevent cursor from moving on the trail byte */ + // prevent cursor from moving on the trail byte if (has_mbyte) mb_adjust_cursor(); } } -/* cursor_foldstart() {{{2 */ +// cursor_foldstart() {{{2 /* * Move the cursor to the first line of a closed fold. */ @@ -1080,8 +1079,8 @@ foldAdjustCursor(void) (void)hasFolding(curwin->w_cursor.lnum, &curwin->w_cursor.lnum, NULL); } -/* Internal functions for "fold_T" {{{1 */ -/* cloneFoldGrowArray() {{{2 */ +// Internal functions for "fold_T" {{{1 +// cloneFoldGrowArray() {{{2 /* * Will "clone" (i.e deep copy) a garray_T of folds. * @@ -1114,7 +1113,7 @@ cloneFoldGrowArray(garray_T *from, garray_T *to) } } -/* foldFind() {{{2 */ +// foldFind() {{{2 /* * Search for line "lnum" in folds of growarray "gap". * Set *fpp to the fold struct for the fold that contains "lnum" or @@ -1140,14 +1139,14 @@ foldFind(garray_T *gap, linenr_T lnum, fold_T **fpp) { i = (low + high) / 2; if (fp[i].fd_top > lnum) - /* fold below lnum, adjust high */ + // fold below lnum, adjust high high = i - 1; else if (fp[i].fd_top + fp[i].fd_len <= lnum) - /* fold above lnum, adjust low */ + // fold above lnum, adjust low low = i + 1; else { - /* lnum is inside this fold */ + // lnum is inside this fold *fpp = fp + i; return TRUE; } @@ -1156,7 +1155,7 @@ foldFind(garray_T *gap, linenr_T lnum, fold_T **fpp) return FALSE; } -/* foldLevelWin() {{{2 */ +// foldLevelWin() {{{2 /* * Return fold level at line number "lnum" in window "wp". */ @@ -1168,13 +1167,13 @@ foldLevelWin(win_T *wp, linenr_T lnum) int level = 0; garray_T *gap; - /* Recursively search for a fold that contains "lnum". */ + // Recursively search for a fold that contains "lnum". gap = &wp->w_folds; for (;;) { if (!foldFind(gap, lnum_rel, &fp)) break; - /* Check nested folds. Line number is relative to containing fold. */ + // Check nested folds. Line number is relative to containing fold. gap = &fp->fd_nested; lnum_rel -= fp->fd_top; ++level; @@ -1183,7 +1182,7 @@ foldLevelWin(win_T *wp, linenr_T lnum) return level; } -/* checkupdate() {{{2 */ +// checkupdate() {{{2 /* * Check if the folds in window "wp" are invalid and update them if needed. */ @@ -1192,12 +1191,12 @@ checkupdate(win_T *wp) { if (wp->w_foldinvalid) { - foldUpdate(wp, (linenr_T)1, (linenr_T)MAXLNUM); /* will update all */ + foldUpdate(wp, (linenr_T)1, (linenr_T)MAXLNUM); // will update all wp->w_foldinvalid = FALSE; } } -/* setFoldRepeat() {{{2 */ +// setFoldRepeat() {{{2 /* * Open or close fold for current window at line "lnum". * Repeat "count" times. @@ -1214,7 +1213,7 @@ setFoldRepeat(linenr_T lnum, long count, int do_open) (void)setManualFold(lnum, do_open, FALSE, &done); if (!(done & DONE_ACTION)) { - /* Only give an error message when no fold could be opened. */ + // Only give an error message when no fold could be opened. if (n == 0 && !(done & DONE_FOLD)) emsg(_(e_nofold)); break; @@ -1222,7 +1221,7 @@ setFoldRepeat(linenr_T lnum, long count, int do_open) } } -/* setManualFold() {{{2 */ +// setManualFold() {{{2 /* * Open or close the fold in the current window which contains "lnum". * Also does this for other windows in diff mode when needed. @@ -1230,8 +1229,8 @@ setFoldRepeat(linenr_T lnum, long count, int do_open) static linenr_T setManualFold( linenr_T lnum, - int opening, /* TRUE when opening, FALSE when closing */ - int recurse, /* TRUE when closing/opening recursive */ + int opening, // TRUE when opening, FALSE when closing + int recurse, // TRUE when closing/opening recursive int *donep) { #ifdef FEAT_DIFF @@ -1259,7 +1258,7 @@ setManualFold( return setManualFoldWin(curwin, lnum, opening, recurse, donep); } -/* setManualFoldWin() {{{2 */ +// setManualFoldWin() {{{2 /* * Open or close the fold in window "wp" which contains "lnum". * "donep", when not NULL, points to flag that is set to DONE_FOLD when some @@ -1273,8 +1272,8 @@ setManualFold( setManualFoldWin( win_T *wp, linenr_T lnum, - int opening, /* TRUE when opening, FALSE when closing */ - int recurse, /* TRUE when closing/opening recursive */ + int opening, // TRUE when opening, FALSE when closing + int recurse, // TRUE when closing/opening recursive int *donep) { fold_T *fp; @@ -1299,20 +1298,20 @@ setManualFoldWin( { if (!foldFind(gap, lnum, &fp)) { - /* If there is a following fold, continue there next time. */ + // If there is a following fold, continue there next time. if (fp < (fold_T *)gap->ga_data + gap->ga_len) next = fp->fd_top + off; break; } - /* lnum is inside this fold */ + // lnum is inside this fold found_fold = TRUE; - /* If there is a following fold, continue there next time. */ + // If there is a following fold, continue there next time. if (fp + 1 < (fold_T *)gap->ga_data + gap->ga_len) next = fp[1].fd_top + off; - /* Change from level-dependent folding to manual. */ + // Change from level-dependent folding to manual. if (use_level || fp->fd_flags == FD_LEVEL) { use_level = TRUE; @@ -1325,7 +1324,7 @@ setManualFoldWin( fp2[j].fd_flags = FD_LEVEL; } - /* Simple case: Close recursively means closing the fold. */ + // Simple case: Close recursively means closing the fold. if (!opening && recurse) { if (fp->fd_flags != FD_CLOSED) @@ -1336,7 +1335,7 @@ setManualFoldWin( } else if (fp->fd_flags == FD_CLOSED) { - /* When opening, open topmost closed fold. */ + // When opening, open topmost closed fold. if (opening) { fp->fd_flags = FD_OPEN; @@ -1347,7 +1346,7 @@ setManualFoldWin( break; } - /* fold is open, check nested folds */ + // fold is open, check nested folds found = fp; gap = &fp->fd_nested; lnum -= fp->fd_top; @@ -1356,7 +1355,7 @@ setManualFoldWin( } if (found_fold) { - /* When closing and not recurse, close deepest open fold. */ + // When closing and not recurse, close deepest open fold. if (!opening && found != NULL) { found->fd_flags = FD_CLOSED; @@ -1376,7 +1375,7 @@ setManualFoldWin( return next; } -/* foldOpenNested() {{{2 */ +// foldOpenNested() {{{2 /* * Open all nested folds in fold "fpr" recursively. */ @@ -1394,7 +1393,7 @@ foldOpenNested(fold_T *fpr) } } -/* deleteFoldEntry() {{{2 */ +// deleteFoldEntry() {{{2 /* * Delete fold "idx" from growarray "gap". * When "recursive" is TRUE also delete all the folds contained in it. @@ -1411,7 +1410,7 @@ deleteFoldEntry(garray_T *gap, int idx, int recursive) fp = (fold_T *)gap->ga_data + idx; if (recursive || fp->fd_nested.ga_len == 0) { - /* recursively delete the contained folds */ + // recursively delete the contained folds deleteFoldRecurse(&fp->fd_nested); --gap->ga_len; if (idx < gap->ga_len) @@ -1419,15 +1418,15 @@ deleteFoldEntry(garray_T *gap, int idx, int recursive) } else { - /* Move nested folds one level up, to overwrite the fold that is - * deleted. */ + // Move nested folds one level up, to overwrite the fold that is + // deleted. moved = fp->fd_nested.ga_len; if (ga_grow(gap, (int)(moved - 1)) == OK) { - /* Get "fp" again, the array may have been reallocated. */ + // Get "fp" again, the array may have been reallocated. fp = (fold_T *)gap->ga_data + idx; - /* adjust fd_top and fd_flags for the moved folds */ + // adjust fd_top and fd_flags for the moved folds nfp = (fold_T *)fp->fd_nested.ga_data; for (i = 0; i < moved; ++i) { @@ -1438,11 +1437,11 @@ deleteFoldEntry(garray_T *gap, int idx, int recursive) nfp[i].fd_small = MAYBE; } - /* move the existing folds down to make room */ + // move the existing folds down to make room if (idx + 1 < gap->ga_len) mch_memmove(fp + moved, fp + 1, sizeof(fold_T) * (gap->ga_len - (idx + 1))); - /* move the contained folds one level up */ + // move the contained folds one level up mch_memmove(fp, nfp, (size_t)(sizeof(fold_T) * moved)); vim_free(nfp); gap->ga_len += moved - 1; @@ -1450,7 +1449,7 @@ deleteFoldEntry(garray_T *gap, int idx, int recursive) } } -/* deleteFoldRecurse() {{{2 */ +// deleteFoldRecurse() {{{2 /* * Delete nested folds in a fold. */ @@ -1464,7 +1463,7 @@ deleteFoldRecurse(garray_T *gap) ga_clear(gap); } -/* foldMarkAdjust() {{{2 */ +// foldMarkAdjust() {{{2 /* * Update line numbers of folds for inserted/deleted lines. */ @@ -1476,18 +1475,18 @@ foldMarkAdjust( long amount, long amount_after) { - /* If deleting marks from line1 to line2, but not deleting all those - * lines, set line2 so that only deleted lines have their folds removed. */ + // If deleting marks from line1 to line2, but not deleting all those + // lines, set line2 so that only deleted lines have their folds removed. if (amount == MAXLNUM && line2 >= line1 && line2 - line1 >= -amount_after) line2 = line1 - amount_after - 1; - /* If appending a line in Insert mode, it should be included in the fold - * just above the line. */ + // If appending a line in Insert mode, it should be included in the fold + // just above the line. if ((State & INSERT) && amount == (linenr_T)1 && line2 == MAXLNUM) --line1; foldMarkAdjustRecurse(&wp->w_folds, line1, line2, amount, amount_after); } -/* foldMarkAdjustRecurse() {{{2 */ +// foldMarkAdjustRecurse() {{{2 static void foldMarkAdjustRecurse( garray_T *gap, @@ -1501,14 +1500,14 @@ foldMarkAdjustRecurse( linenr_T last; linenr_T top; - /* In Insert mode an inserted line at the top of a fold is considered part - * of the fold, otherwise it isn't. */ + // In Insert mode an inserted line at the top of a fold is considered part + // of the fold, otherwise it isn't. if ((State & INSERT) && amount == (linenr_T)1 && line2 == MAXLNUM) top = line1 + 1; else top = line1; |