mirror of
https://github.com/neovim/neovim.git
synced 2025-10-06 01:46:29 +00:00
feat(decorations): support virtual lines (for now: only one block at a time)
This commit is contained in:
@@ -197,7 +197,7 @@ void update_topline(win_T *wp)
|
||||
}
|
||||
}
|
||||
// Check if there are more filler lines than allowed.
|
||||
if (!check_topline && wp->w_topfill > diff_check_fill(wp, wp->w_topline)) {
|
||||
if (!check_topline && wp->w_topfill > win_get_fill(wp, wp->w_topline)) {
|
||||
check_topline = true;
|
||||
}
|
||||
|
||||
@@ -582,8 +582,7 @@ static void curs_rows(win_T *wp)
|
||||
--i; // hold at inserted lines
|
||||
}
|
||||
}
|
||||
if (valid
|
||||
&& (lnum != wp->w_topline || !wp->w_p_diff)) {
|
||||
if (valid && (lnum != wp->w_topline || !win_may_fill(wp))) {
|
||||
lnum = wp->w_lines[i].wl_lastlnum + 1;
|
||||
// Cursor inside folded lines, don't count this row
|
||||
if (lnum > wp->w_cursor.lnum) {
|
||||
@@ -854,7 +853,7 @@ void curs_columns(win_T *wp, int may_scroll)
|
||||
if (wp->w_cursor.lnum == wp->w_topline) {
|
||||
wp->w_wrow += wp->w_topfill;
|
||||
} else {
|
||||
wp->w_wrow += diff_check_fill(wp, wp->w_cursor.lnum);
|
||||
wp->w_wrow += win_get_fill(wp, wp->w_cursor.lnum);
|
||||
}
|
||||
|
||||
prev_skipcol = wp->w_skipcol;
|
||||
@@ -1041,7 +1040,7 @@ bool scrolldown(long line_count, int byfold)
|
||||
(void)hasFolding(curwin->w_topline, &curwin->w_topline, NULL);
|
||||
validate_cursor(); // w_wrow needs to be valid
|
||||
while (line_count-- > 0) {
|
||||
if (curwin->w_topfill < diff_check(curwin, curwin->w_topline)
|
||||
if (curwin->w_topfill < win_get_fill(curwin, curwin->w_topline)
|
||||
&& curwin->w_topfill < curwin->w_height_inner - 1) {
|
||||
curwin->w_topfill++;
|
||||
done++;
|
||||
@@ -1122,7 +1121,7 @@ bool scrollup(long line_count, int byfold)
|
||||
linenr_T botline = curwin->w_botline;
|
||||
|
||||
if ((byfold && hasAnyFolding(curwin))
|
||||
|| curwin->w_p_diff) {
|
||||
|| win_may_fill(curwin)) {
|
||||
// count each sequence of folded lines as one logical line
|
||||
linenr_T lnum = curwin->w_topline;
|
||||
while (line_count--) {
|
||||
@@ -1135,8 +1134,8 @@ bool scrollup(long line_count, int byfold)
|
||||
if (lnum >= curbuf->b_ml.ml_line_count) {
|
||||
break;
|
||||
}
|
||||
++lnum;
|
||||
curwin->w_topfill = diff_check_fill(curwin, lnum);
|
||||
lnum++;
|
||||
curwin->w_topfill = win_get_fill(curwin, lnum);
|
||||
}
|
||||
}
|
||||
// approximate w_botline
|
||||
@@ -1207,7 +1206,7 @@ static void max_topfill(void)
|
||||
if (n >= curwin->w_height_inner) {
|
||||
curwin->w_topfill = 0;
|
||||
} else {
|
||||
curwin->w_topfill = diff_check_fill(curwin, curwin->w_topline);
|
||||
curwin->w_topfill = win_get_fill(curwin, curwin->w_topline);
|
||||
if (curwin->w_topfill + n > curwin->w_height_inner) {
|
||||
curwin->w_topfill = curwin->w_height_inner - n;
|
||||
}
|
||||
@@ -1220,8 +1219,7 @@ static void max_topfill(void)
|
||||
*/
|
||||
void scrolldown_clamp(void)
|
||||
{
|
||||
int can_fill = (curwin->w_topfill
|
||||
< diff_check_fill(curwin, curwin->w_topline));
|
||||
int can_fill = (curwin->w_topfill < win_get_fill(curwin, curwin->w_topline));
|
||||
|
||||
if (curwin->w_topline <= 1
|
||||
&& !can_fill) {
|
||||
@@ -1302,7 +1300,7 @@ void scrollup_clamp(void)
|
||||
*/
|
||||
static void topline_back(win_T *wp, lineoff_T *lp)
|
||||
{
|
||||
if (lp->fill < diff_check_fill(wp, lp->lnum)) {
|
||||
if (lp->fill < win_get_fill(wp, lp->lnum)) {
|
||||
// Add a filler line
|
||||
lp->fill++;
|
||||
lp->height = 1;
|
||||
@@ -1328,7 +1326,7 @@ static void topline_back(win_T *wp, lineoff_T *lp)
|
||||
*/
|
||||
static void botline_forw(win_T *wp, lineoff_T *lp)
|
||||
{
|
||||
if (lp->fill < diff_check_fill(wp, lp->lnum + 1)) {
|
||||
if (lp->fill < win_get_fill(wp, lp->lnum + 1)) {
|
||||
// Add a filler line.
|
||||
lp->fill++;
|
||||
lp->height = 1;
|
||||
@@ -1355,8 +1353,8 @@ static void botline_forw(win_T *wp, lineoff_T *lp)
|
||||
static void botline_topline(lineoff_T *lp)
|
||||
{
|
||||
if (lp->fill > 0) {
|
||||
++lp->lnum;
|
||||
lp->fill = diff_check_fill(curwin, lp->lnum) - lp->fill + 1;
|
||||
lp->lnum++;
|
||||
lp->fill = win_get_fill(curwin, lp->lnum) - lp->fill + 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1368,8 +1366,8 @@ static void botline_topline(lineoff_T *lp)
|
||||
static void topline_botline(lineoff_T *lp)
|
||||
{
|
||||
if (lp->fill > 0) {
|
||||
lp->fill = diff_check_fill(curwin, lp->lnum) - lp->fill + 1;
|
||||
--lp->lnum;
|
||||
lp->fill = win_get_fill(curwin, lp->lnum) - lp->fill + 1;
|
||||
lp->lnum--;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1417,7 +1415,7 @@ void scroll_cursor_top(int min_scroll, int always)
|
||||
// "used" already contains the number of filler lines above, don't add it
|
||||
// again.
|
||||
// Hide filler lines above cursor line by adding them to "extra".
|
||||
int extra = diff_check_fill(curwin, curwin->w_cursor.lnum);
|
||||
int extra = win_get_fill(curwin, curwin->w_cursor.lnum);
|
||||
|
||||
/*
|
||||
* Check if the lines from "top" to "bot" fit in the window. If they do,
|
||||
@@ -1475,7 +1473,7 @@ void scroll_cursor_top(int min_scroll, int always)
|
||||
if (curwin->w_topline > curwin->w_cursor.lnum) {
|
||||
curwin->w_topline = curwin->w_cursor.lnum;
|
||||
}
|
||||
curwin->w_topfill = diff_check_fill(curwin, curwin->w_topline);
|
||||
curwin->w_topfill = win_get_fill(curwin, curwin->w_topline);
|
||||
if (curwin->w_topfill > 0 && extra > off) {
|
||||
curwin->w_topfill -= extra - off;
|
||||
if (curwin->w_topfill < 0) {
|
||||
@@ -1505,7 +1503,7 @@ void set_empty_rows(win_T *wp, int used)
|
||||
} else {
|
||||
wp->w_empty_rows = wp->w_height_inner - used;
|
||||
if (wp->w_botline <= wp->w_buffer->b_ml.ml_line_count) {
|
||||
wp->w_filler_rows = diff_check_fill(wp, wp->w_botline);
|
||||
wp->w_filler_rows = win_get_fill(wp, wp->w_botline);
|
||||
if (wp->w_empty_rows > wp->w_filler_rows) {
|
||||
wp->w_empty_rows -= wp->w_filler_rows;
|
||||
} else {
|
||||
@@ -1590,7 +1588,7 @@ void scroll_cursor_bot(int min_scroll, int set_topbot)
|
||||
}
|
||||
loff.fill = 0;
|
||||
boff.fill = 0;
|
||||
fill_below_window = diff_check_fill(curwin, curwin->w_botline)
|
||||
fill_below_window = win_get_fill(curwin, curwin->w_botline)
|
||||
- curwin->w_filler_rows;
|
||||
|
||||
while (loff.lnum > 1) {
|
||||
@@ -1835,7 +1833,7 @@ void cursor_correct(void)
|
||||
|
||||
// Count filler lines below this line as context.
|
||||
if (topline < botline) {
|
||||
above += diff_check_fill(curwin, topline + 1);
|
||||
above += win_get_fill(curwin, topline + 1);
|
||||
}
|
||||
++topline;
|
||||
}
|
||||
@@ -1889,9 +1887,7 @@ int onepage(Direction dir, long count)
|
||||
? ((curwin->w_topline >= curbuf->b_ml.ml_line_count - so)
|
||||
&& curwin->w_botline > curbuf->b_ml.ml_line_count)
|
||||
: (curwin->w_topline == 1
|
||||
&& curwin->w_topfill ==
|
||||
diff_check_fill(curwin, curwin->w_topline)
|
||||
)) {
|
||||
&& curwin->w_topfill == win_get_fill(curwin, curwin->w_topline))) {
|
||||
beep_flush();
|
||||
retval = FAIL;
|
||||
break;
|
||||
@@ -1919,7 +1915,7 @@ int onepage(Direction dir, long count)
|
||||
/* For the overlap, start with the line just below the window
|
||||
* and go upwards. */
|
||||
loff.lnum = curwin->w_botline;
|
||||
loff.fill = diff_check_fill(curwin, loff.lnum)
|
||||
loff.fill = win_get_fill(curwin, loff.lnum)
|
||||
- curwin->w_filler_rows;
|
||||
get_scroll_overlap(&loff, -1);
|
||||
curwin->w_topline = loff.lnum;
|
||||
@@ -1956,8 +1952,7 @@ int onepage(Direction dir, long count)
|
||||
* line at the bottom of the window. Make sure this results in
|
||||
* the same line as before doing CTRL-F. */
|
||||
loff.lnum = curwin->w_topline - 1;
|
||||
loff.fill = diff_check_fill(curwin, loff.lnum + 1)
|
||||
- curwin->w_topfill;
|
||||
loff.fill = win_get_fill(curwin, loff.lnum + 1) - curwin->w_topfill;
|
||||
get_scroll_overlap(&loff, 1);
|
||||
|
||||
if (loff.lnum >= curbuf->b_ml.ml_line_count) {
|
||||
@@ -2000,8 +1995,7 @@ int onepage(Direction dir, long count)
|
||||
/* First try using the maximum number of filler lines. If
|
||||
* that's not enough, backup one line. */
|
||||
loff.fill = curwin->w_topfill;
|
||||
if (curwin->w_topfill < diff_check_fill(curwin,
|
||||
curwin->w_topline)) {
|
||||
if (curwin->w_topfill < win_get_fill(curwin, curwin->w_topline)) {
|
||||
max_topfill();
|
||||
}
|
||||
if (curwin->w_topfill == loff.fill) {
|
||||
@@ -2146,8 +2140,8 @@ void halfpage(bool flag, linenr_T Prenum)
|
||||
break;
|
||||
}
|
||||
(void)hasFolding(curwin->w_topline, NULL, &curwin->w_topline);
|
||||
++curwin->w_topline;
|
||||
curwin->w_topfill = diff_check_fill(curwin, curwin->w_topline);
|
||||
curwin->w_topline++;
|
||||
curwin->w_topfill = win_get_fill(curwin, curwin->w_topline);
|
||||
|
||||
if (curwin->w_cursor.lnum < curbuf->b_ml.ml_line_count) {
|
||||
++curwin->w_cursor.lnum;
|
||||
@@ -2158,11 +2152,9 @@ void halfpage(bool flag, linenr_T Prenum)
|
||||
curwin->w_valid &= ~(VALID_CROW|VALID_WROW);
|
||||
scrolled += i;
|
||||
|
||||
/*
|
||||
* Correct w_botline for changed w_topline.
|
||||
* Won't work when there are filler lines.
|
||||
*/
|
||||
if (curwin->w_p_diff) {
|
||||
// Correct w_botline for changed w_topline.
|
||||
// Won't work when there are filler lines.
|
||||
if (win_may_fill(curwin)) {
|
||||
curwin->w_valid &= ~(VALID_BOTLINE|VALID_BOTLINE_AP);
|
||||
} else {
|
||||
room += i;
|
||||
@@ -2197,7 +2189,7 @@ void halfpage(bool flag, linenr_T Prenum)
|
||||
* scroll the text down
|
||||
*/
|
||||
while (n > 0 && curwin->w_topline > 1) {
|
||||
if (curwin->w_topfill < diff_check_fill(curwin, curwin->w_topline)) {
|
||||
if (curwin->w_topfill < win_get_fill(curwin, curwin->w_topline)) {
|
||||
i = 1;
|
||||
n--;
|
||||
curwin->w_topfill++;
|
||||
|
Reference in New Issue
Block a user