diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2018-08-14 12:33:12 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-14 12:33:12 +0200 |
commit | f767cee10002afc360af1aad209676d08cc3a758 (patch) | |
tree | f47652d37d72abf921de07ce1bd4ca35f85ca4ce /src/nvim/cursor_shape.c | |
parent | bec5e4cb6183f3b403aca35ef55c3798a48dc64b (diff) | |
parent | fa4c2601000df2d792b0de865da3ac8c43ab723f (diff) | |
download | rneovim-f767cee10002afc360af1aad209676d08cc3a758.tar.gz rneovim-f767cee10002afc360af1aad209676d08cc3a758.tar.bz2 rneovim-f767cee10002afc360af1aad209676d08cc3a758.zip |
Merge pull request #8790 from bfredl/hlattr
pass highlight attrs per value and thread-safely to TUI thread
Diffstat (limited to 'src/nvim/cursor_shape.c')
-rw-r--r-- | src/nvim/cursor_shape.c | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/src/nvim/cursor_shape.c b/src/nvim/cursor_shape.c index b45e7002f7..cf79005a37 100644 --- a/src/nvim/cursor_shape.c +++ b/src/nvim/cursor_shape.c @@ -64,6 +64,9 @@ Array mode_style_array(void) PUT(dic, "blinkoff", INTEGER_OBJ(cur->blinkoff)); PUT(dic, "hl_id", INTEGER_OBJ(cur->id)); PUT(dic, "id_lm", INTEGER_OBJ(cur->id_lm)); + PUT(dic, "attr_id", INTEGER_OBJ(cur->id ? syn_id2attr(cur->id) : 0)); + PUT(dic, "attr_id_lm", INTEGER_OBJ(cur->id_lm ? syn_id2attr(cur->id_lm) + : 0)); } PUT(dic, "name", STRING_OBJ(cstr_to_string(cur->full_name))); PUT(dic, "short_name", STRING_OBJ(cstr_to_string(cur->name))); @@ -258,15 +261,30 @@ char_u *parse_shape_opt(int what) /// @return -1 in case of failure, else the matching SHAPE_ID* integer int cursor_mode_str2int(const char *mode) { - for (int current_mode = 0; current_mode < SHAPE_IDX_COUNT; current_mode++) { - if (strcmp(shape_table[current_mode].full_name, mode) == 0) { - return current_mode; + for (int mode_idx = 0; mode_idx < SHAPE_IDX_COUNT; mode_idx++) { + if (strcmp(shape_table[mode_idx].full_name, mode) == 0) { + return mode_idx; } } WLOG("Unknown mode %s", mode); return -1; } +/// Check if a syntax id is used as a cursor style. +bool cursor_mode_uses_syn_id(int syn_id) +{ + if (*p_guicursor == NUL) { + return false; + } + for (int mode_idx = 0; mode_idx < SHAPE_IDX_COUNT; mode_idx++) { + if (shape_table[mode_idx].id == syn_id + || shape_table[mode_idx].id_lm == syn_id) { + return true; + } + } + return false; +} + /// Return the index into shape_table[] for the current mode. int cursor_get_mode_idx(void) |