aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api
diff options
context:
space:
mode:
authorZyX <kp-pav@yandex.ru>2017-10-30 00:49:12 +0300
committerZyX <kp-pav@yandex.ru>2017-10-30 00:49:12 +0300
commitb29a776550dadefefb891d01054ea21eb942bad1 (patch)
tree799bb2c0e926a20ac5b1af262f0849208eae699a /src/nvim/api
parent538af1c90a4ac9928f60e97338869e516def4956 (diff)
parent45296b331fa462eeabb141037ad10a3ad24ab8a6 (diff)
downloadrneovim-b29a776550dadefefb891d01054ea21eb942bad1.tar.gz
rneovim-b29a776550dadefefb891d01054ea21eb942bad1.tar.bz2
rneovim-b29a776550dadefefb891d01054ea21eb942bad1.zip
Merge branch 'master' into expression-parser
Diffstat (limited to 'src/nvim/api')
-rw-r--r--src/nvim/api/buffer.c6
-rw-r--r--src/nvim/api/private/helpers.c33
-rw-r--r--src/nvim/api/ui_events.in.h16
3 files changed, 54 insertions, 1 deletions
diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c
index 82de8fd4a2..c381e92dc7 100644
--- a/src/nvim/api/buffer.c
+++ b/src/nvim/api/buffer.c
@@ -793,7 +793,11 @@ Integer nvim_buf_add_highlight(Buffer buffer,
col_end = MAXCOL;
}
- int hlg_id = syn_name2id((char_u *)(hl_group.data ? hl_group.data : ""));
+ int hlg_id = 0;
+ if (hl_group.size > 0) {
+ hlg_id = syn_check_group((char_u *)hl_group.data, (int)hl_group.size);
+ }
+
src_id = bufhl_add_hl(buf, (int)src_id, hlg_id, (linenr_T)line+1,
(colnr_T)col_start+1, (colnr_T)col_end);
return src_id;
diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c
index e736e29e2d..2944925a9c 100644
--- a/src/nvim/api/private/helpers.c
+++ b/src/nvim/api/private/helpers.c
@@ -667,6 +667,22 @@ tabpage_T *find_tab_by_handle(Tabpage tabpage, Error *err)
return rv;
}
+/// Allocates a String consisting of a single char. Does not support multibyte
+/// characters. The resulting string is also NUL-terminated, to facilitate
+/// interoperating with code using C strings.
+///
+/// @param char the char to convert
+/// @return the resulting String, if the input char was NUL, an
+/// empty String is returned
+String cchar_to_string(char c)
+{
+ char buf[] = { c, NUL };
+ return (String) {
+ .data = xmemdupz(buf, 1),
+ .size = (c != NUL) ? 1 : 0
+ };
+}
+
/// Copies a C string into a String (binary safe string, characters + length).
/// The resulting string is also NUL-terminated, to facilitate interoperating
/// with code using C strings.
@@ -687,6 +703,23 @@ String cstr_to_string(const char *str)
};
}
+/// Copies buffer to an allocated String.
+/// The resulting string is also NUL-terminated, to facilitate interoperating
+/// with code using C strings.
+///
+/// @param buf the buffer to copy
+/// @param size length of the buffer
+/// @return the resulting String, if the input string was NULL, an
+/// empty String is returned
+String cbuf_to_string(const char *buf, size_t size)
+ FUNC_ATTR_NONNULL_ALL
+{
+ return (String) {
+ .data = xmemdupz(buf, size),
+ .size = size
+ };
+}
+
/// Creates a String using the given C string. Unlike
/// cstr_to_string this function DOES NOT copy the C string.
///
diff --git a/src/nvim/api/ui_events.in.h b/src/nvim/api/ui_events.in.h
index 1b5d17584f..65357d008a 100644
--- a/src/nvim/api/ui_events.in.h
+++ b/src/nvim/api/ui_events.in.h
@@ -68,4 +68,20 @@ void popupmenu_select(Integer selected)
void tabline_update(Tabpage current, Array tabs)
FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY;
+void cmdline_show(Array content, Integer pos, String firstc, String prompt,
+ Integer indent, Integer level)
+ FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY;
+void cmdline_pos(Integer pos, Integer level)
+ FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY;
+void cmdline_special_char(String c, Boolean shift, Integer level)
+ FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY;
+void cmdline_hide(Integer level)
+ FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY;
+void cmdline_block_show(Array lines)
+ FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY;
+void cmdline_block_append(Array lines)
+ FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY;
+void cmdline_block_hide(void)
+ FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY;
+
#endif // NVIM_API_UI_EVENTS_IN_H