diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-09-05 22:33:28 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-09-05 22:33:28 +0200 |
commit | af7645d3733fdd3cd2df03ec7b653601d26969ef (patch) | |
tree | 1b3c3d1d0d6428c33026693a5086910cca8b3078 /src/diff.c | |
parent | 8d3b51084a5bdcd2ee9e31bc03cba0d16c43d428 (diff) | |
download | vim-git-af7645d3733fdd3cd2df03ec7b653601d26969ef.tar.gz |
patch 8.1.1989: the evalfunc.c file is still too bigv8.1.1989
Problem: The evalfunc.c file is still too big.
Solution: Move f_pathshorten() to filepath.c. Move f_cscope_connection() to
if_cscope.c. Move diff_ functions to diff.c. Move timer_
functions to ex_cmds2.c. move callback functions to evalvars.c.
Diffstat (limited to 'src/diff.c')
-rw-r--r-- | src/diff.c | 75 |
1 files changed, 74 insertions, 1 deletions
diff --git a/src/diff.c b/src/diff.c index 4c0041d41..01125aaf4 100644 --- a/src/diff.c +++ b/src/diff.c @@ -3215,4 +3215,77 @@ xdiff_out(void *priv, mmbuffer_t *mb, int nbuf) return 0; } -#endif /* FEAT_DIFF */ +#endif // FEAT_DIFF + +#if defined(FEAT_EVAL) || defined(PROTO) + +/* + * "diff_filler()" function + */ + void +f_diff_filler(typval_T *argvars UNUSED, typval_T *rettv UNUSED) +{ +#ifdef FEAT_DIFF + rettv->vval.v_number = diff_check_fill(curwin, tv_get_lnum(argvars)); +#endif +} + +/* + * "diff_hlID()" function + */ + void +f_diff_hlID(typval_T *argvars UNUSED, typval_T *rettv UNUSED) +{ +#ifdef FEAT_DIFF + linenr_T lnum = tv_get_lnum(argvars); + static linenr_T prev_lnum = 0; + static varnumber_T changedtick = 0; + static int fnum = 0; + static int change_start = 0; + static int change_end = 0; + static hlf_T hlID = (hlf_T)0; + int filler_lines; + int col; + + if (lnum < 0) /* ignore type error in {lnum} arg */ + lnum = 0; + if (lnum != prev_lnum + || changedtick != CHANGEDTICK(curbuf) + || fnum != curbuf->b_fnum) + { + /* New line, buffer, change: need to get the values. */ + filler_lines = diff_check(curwin, lnum); + if (filler_lines < 0) + { + if (filler_lines == -1) + { + change_start = MAXCOL; + change_end = -1; + if (diff_find_change(curwin, lnum, &change_start, &change_end)) + hlID = HLF_ADD; /* added line */ + else + hlID = HLF_CHD; /* changed line */ + } + else + hlID = HLF_ADD; /* added line */ + } + else + hlID = (hlf_T)0; + prev_lnum = lnum; + changedtick = CHANGEDTICK(curbuf); + fnum = curbuf->b_fnum; + } + + if (hlID == HLF_CHD || hlID == HLF_TXD) + { + col = tv_get_number(&argvars[1]) - 1; /* ignore type error in {col} */ + if (col >= change_start && col <= change_end) + hlID = HLF_TXD; /* changed text */ + else + hlID = HLF_CHD; /* changed line */ + } + rettv->vval.v_number = hlID == (hlf_T)0 ? 0 : (int)hlID; +#endif +} + +#endif |