aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/buffer.c
diff options
context:
space:
mode:
authorKillTheMule <KillTheMule@users.noreply.github.com>2017-09-02 23:28:49 +0200
committerKillTheMule <KillTheMule@users.noreply.github.com>2017-10-29 18:10:46 +0100
commit8d929f558c981c75f19dfc22e54e36c904be887e (patch)
treeb691f62f264394da969e14b75d1fec3d8a510efd /src/nvim/buffer.c
parent45296b331fa462eeabb141037ad10a3ad24ab8a6 (diff)
downloadrneovim-8d929f558c981c75f19dfc22e54e36c904be887e.tar.gz
rneovim-8d929f558c981c75f19dfc22e54e36c904be887e.tar.bz2
rneovim-8d929f558c981c75f19dfc22e54e36c904be887e.zip
Inccommand: Multiline substitutions, highlighting, multibyte.
Make inccomand work with multiline patterns and substitutions. Also care for proper highlighting and multibyte characters.
Diffstat (limited to 'src/nvim/buffer.c')
-rw-r--r--src/nvim/buffer.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c
index 9d42fbc1b3..3080d4960d 100644
--- a/src/nvim/buffer.c
+++ b/src/nvim/buffer.c
@@ -5278,6 +5278,43 @@ int bufhl_add_hl(buf_T *buf,
return src_id;
}
+/// Add highlighting to a buffer, bounded by two cursor positions,
+/// with an offset
+/// @param buf The buffer to add highlights to
+/// @param src_id src_id to use or 0 to use a new src_id group,
+/// or -1 for ungrouped highlight.
+/// @param hl_id Id of the highlight group to use
+/// @param lpos_start Cursor position to start the hightlighting at
+/// @param lpos_end Cursor position to end the highlighting at
+/// @param offset Move the whole highlighting this many columns to the right
+void bufhl_add_hl_pos_offset(buf_T *buf,
+ int src_id,
+ int hl_id,
+ lpos_T pos_start,
+ lpos_T pos_end,
+ colnr_T offset)
+{
+ colnr_T hl_start = 0;
+ colnr_T hl_end = 0;
+
+ for (linenr_T lnum = pos_start.lnum; lnum <= pos_end.lnum; lnum ++) {
+ if (pos_start.lnum < lnum && lnum < pos_end.lnum) {
+ hl_start = offset;
+ hl_end = MAXCOL;
+ } else if (lnum == pos_start.lnum && lnum < pos_end.lnum) {
+ hl_start = pos_start.col + offset + 1;
+ hl_end = MAXCOL;
+ } else if (pos_start.lnum < lnum && lnum == pos_end.lnum) {
+ hl_start = offset;
+ hl_end = pos_end.col + offset;
+ } else if (pos_start.lnum == lnum && pos_end.lnum == lnum) {
+ hl_start = pos_start.col + offset + 1;
+ hl_end = pos_end.col + offset;
+ }
+ (void)bufhl_add_hl(buf, src_id, hl_id, lnum, hl_start, hl_end);
+ }
+}
+
/// Clear bufhl highlights from a given source group and range of lines.
///
/// @param buf The buffer to remove highlights from