diff options
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) | 
