mirror of
https://github.com/neovim/neovim.git
synced 2025-09-30 06:58:35 +00:00
feat(marks): add conceal_lines to nvim_buf_set_extmark()
Implement an extmark property that conceals lines vertically.
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
#include "nvim/charset.h"
|
||||
#include "nvim/cmdhist.h"
|
||||
#include "nvim/cursor.h"
|
||||
#include "nvim/decoration.h"
|
||||
#include "nvim/diff.h"
|
||||
#include "nvim/digraph.h"
|
||||
#include "nvim/drawscreen.h"
|
||||
@@ -2486,7 +2487,7 @@ bool find_decl(char *ptr, size_t len, bool locally, bool thisblock, int flags_ar
|
||||
/// 'dist' must be positive.
|
||||
///
|
||||
/// @return true if able to move cursor, false otherwise.
|
||||
bool nv_screengo(oparg_T *oap, int dir, int dist)
|
||||
bool nv_screengo(oparg_T *oap, int dir, int dist, bool skip_conceal)
|
||||
{
|
||||
int linelen = linetabsize(curwin, curwin->w_cursor.lnum);
|
||||
bool retval = true;
|
||||
@@ -2548,7 +2549,7 @@ bool nv_screengo(oparg_T *oap, int dir, int dist)
|
||||
retval = false;
|
||||
break;
|
||||
}
|
||||
cursor_up_inner(curwin, 1);
|
||||
cursor_up_inner(curwin, 1, skip_conceal);
|
||||
|
||||
linelen = linetabsize(curwin, curwin->w_cursor.lnum);
|
||||
if (linelen > width1) {
|
||||
@@ -2573,7 +2574,7 @@ bool nv_screengo(oparg_T *oap, int dir, int dist)
|
||||
retval = false;
|
||||
break;
|
||||
}
|
||||
cursor_down_inner(curwin, 1);
|
||||
cursor_down_inner(curwin, 1, skip_conceal);
|
||||
curwin->w_curswant %= width2;
|
||||
|
||||
// Check if the cursor has moved below the number display
|
||||
@@ -3616,12 +3617,11 @@ static void nv_scroll(cmdarg_T *cap)
|
||||
if (cap->count1 - 1 >= curwin->w_cursor.lnum) {
|
||||
curwin->w_cursor.lnum = 1;
|
||||
} else {
|
||||
if (hasAnyFolding(curwin)) {
|
||||
if (win_lines_concealed(curwin)) {
|
||||
// Count a fold for one screen line.
|
||||
for (n = cap->count1 - 1; n > 0
|
||||
&& curwin->w_cursor.lnum > curwin->w_topline; n--) {
|
||||
hasFolding(curwin, curwin->w_cursor.lnum,
|
||||
&curwin->w_cursor.lnum, NULL);
|
||||
for (n = cap->count1 - 1; n > 0 && curwin->w_cursor.lnum > curwin->w_topline; n--) {
|
||||
hasFolding(curwin, curwin->w_cursor.lnum, &curwin->w_cursor.lnum, NULL);
|
||||
n += decor_conceal_line(curwin, curwin->w_cursor.lnum, true);
|
||||
if (curwin->w_cursor.lnum > curwin->w_topline) {
|
||||
curwin->w_cursor.lnum--;
|
||||
}
|
||||
@@ -3634,8 +3634,7 @@ static void nv_scroll(cmdarg_T *cap)
|
||||
if (cap->cmdchar == 'M') {
|
||||
int used = 0;
|
||||
// Don't count filler lines above the window.
|
||||
used -= win_get_fill(curwin, curwin->w_topline)
|
||||
- curwin->w_topfill;
|
||||
used -= win_get_fill(curwin, curwin->w_topline) - curwin->w_topfill;
|
||||
validate_botline(curwin); // make sure w_empty_rows is valid
|
||||
int half = (curwin->w_height_inner - curwin->w_empty_rows + 1) / 2;
|
||||
for (n = 0; curwin->w_topline + n < curbuf->b_ml.ml_line_count; n++) {
|
||||
@@ -3658,10 +3657,11 @@ static void nv_scroll(cmdarg_T *cap)
|
||||
}
|
||||
} else { // (cap->cmdchar == 'H')
|
||||
n = cap->count1 - 1;
|
||||
if (hasAnyFolding(curwin)) {
|
||||
if (win_lines_concealed(curwin)) {
|
||||
// Count a fold for one screen line.
|
||||
lnum = curwin->w_topline;
|
||||
while (n-- > 0 && lnum < curwin->w_botline - 1) {
|
||||
while ((decor_conceal_line(curwin, lnum - 1, true) || n-- > 0)
|
||||
&& lnum < curwin->w_botline - 1) {
|
||||
hasFolding(curwin, lnum, NULL, &lnum);
|
||||
lnum++;
|
||||
}
|
||||
@@ -5316,7 +5316,7 @@ static void nv_g_dollar_cmd(cmdarg_T *cap)
|
||||
curwin->w_cursor.col--;
|
||||
}
|
||||
}
|
||||
} else if (nv_screengo(oap, FORWARD, cap->count1 - 1) == false) {
|
||||
} else if (nv_screengo(oap, FORWARD, cap->count1 - 1, false) == false) {
|
||||
clearopbeep(oap);
|
||||
}
|
||||
} else {
|
||||
@@ -5443,7 +5443,7 @@ static void nv_g_cmd(cmdarg_T *cap)
|
||||
oap->motion_type = kMTLineWise;
|
||||
i = cursor_down(cap->count1, oap->op_type == OP_NOP);
|
||||
} else {
|
||||
i = nv_screengo(oap, FORWARD, cap->count1);
|
||||
i = nv_screengo(oap, FORWARD, cap->count1, false);
|
||||
}
|
||||
if (!i) {
|
||||
clearopbeep(oap);
|
||||
@@ -5457,7 +5457,7 @@ static void nv_g_cmd(cmdarg_T *cap)
|
||||
oap->motion_type = kMTLineWise;
|
||||
i = cursor_up(cap->count1, oap->op_type == OP_NOP);
|
||||
} else {
|
||||
i = nv_screengo(oap, BACKWARD, cap->count1);
|
||||
i = nv_screengo(oap, BACKWARD, cap->count1, false);
|
||||
}
|
||||
if (!i) {
|
||||
clearopbeep(oap);
|
||||
|
Reference in New Issue
Block a user