diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2020-11-07 15:13:20 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-07 15:13:20 +0100 |
commit | e5d83a3bf344a4ab0ef539d70004c2b771e1044a (patch) | |
tree | c4de9a896700ff8a7131ab430cc108d90fd2774a /src/nvim/move.c | |
parent | da134270d3e9f8a4824b0e0540bf017f7e59b06e (diff) | |
parent | 0fce70252d8e5ccf4cb6f141d1c388966f9f3482 (diff) | |
download | rneovim-e5d83a3bf344a4ab0ef539d70004c2b771e1044a.tar.gz rneovim-e5d83a3bf344a4ab0ef539d70004c2b771e1044a.tar.bz2 rneovim-e5d83a3bf344a4ab0ef539d70004c2b771e1044a.zip |
Merge pull request #13117 from romgrk/add-scroll-events
Implement scroll autocommand
Diffstat (limited to 'src/nvim/move.c')
-rw-r--r-- | src/nvim/move.c | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/src/nvim/move.c b/src/nvim/move.c index 98a7792a09..ccd19a81de 100644 --- a/src/nvim/move.c +++ b/src/nvim/move.c @@ -1020,16 +1020,13 @@ void textpos2screenpos(win_T *wp, pos_T *pos, int *rowp, int *scolp, *ecolp = ecol + coloff; } -/* - * Scroll the current window down by "line_count" logical lines. "CTRL-Y" - */ -void -scrolldown ( - long line_count, - int byfold /* true: count a closed fold as one line */ -) +/// Scroll the current window down by "line_count" logical lines. "CTRL-Y" +/// +/// @param line_count number of lines to scroll +/// @param byfold if true, count a closed fold as one line +bool scrolldown(long line_count, int byfold) { - int done = 0; /* total # of physical lines done */ + int done = 0; // total # of physical lines done /* Make sure w_topline is at the first of a sequence of folded lines. */ (void)hasFolding(curwin->w_topline, &curwin->w_topline, NULL); @@ -1098,17 +1095,18 @@ scrolldown ( foldAdjustCursor(); coladvance(curwin->w_curswant); } + return moved; } -/* - * Scroll the current window up by "line_count" logical lines. "CTRL-E" - */ -void -scrollup ( - long line_count, - int byfold /* true: count a closed fold as one line */ -) +/// Scroll the current window up by "line_count" logical lines. "CTRL-E" +/// +/// @param line_count number of lines to scroll +/// @param byfold if true, count a closed fold as one line +bool scrollup(long line_count, int byfold) { + linenr_T topline = curwin->w_topline; + linenr_T botline = curwin->w_botline; + if ((byfold && hasAnyFolding(curwin)) || curwin->w_p_diff) { // count each sequence of folded lines as one logical line @@ -1151,6 +1149,11 @@ scrollup ( ~(VALID_WROW|VALID_WCOL|VALID_CHEIGHT|VALID_CROW|VALID_VIRTCOL); coladvance(curwin->w_curswant); } + + bool moved = topline != curwin->w_topline + || botline != curwin->w_botline; + + return moved; } /* |