diff options
author | Josh Rahm <rahm@google.com> | 2022-07-18 19:37:18 +0000 |
---|---|---|
committer | Josh Rahm <rahm@google.com> | 2022-07-18 19:37:18 +0000 |
commit | 308e1940dcd64aa6c344c403d4f9e0dda58d9c5c (patch) | |
tree | 35fe43e01755e0f312650667004487a44d6b7941 /src/nvim/api/win_config.c | |
parent | 96a00c7c588b2f38a2424aeeb4ea3581d370bf2d (diff) | |
parent | e8c94697bcbe23a5c7b07c292b90a6b70aadfa87 (diff) | |
download | rneovim-308e1940dcd64aa6c344c403d4f9e0dda58d9c5c.tar.gz rneovim-308e1940dcd64aa6c344c403d4f9e0dda58d9c5c.tar.bz2 rneovim-308e1940dcd64aa6c344c403d4f9e0dda58d9c5c.zip |
Merge remote-tracking branch 'upstream/master' into rahm
Diffstat (limited to 'src/nvim/api/win_config.c')
-rw-r--r-- | src/nvim/api/win_config.c | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/src/nvim/api/win_config.c b/src/nvim/api/win_config.c index 255e1e55cc..d36c5bfb95 100644 --- a/src/nvim/api/win_config.c +++ b/src/nvim/api/win_config.c @@ -10,6 +10,7 @@ #include "nvim/api/private/helpers.h" #include "nvim/api/win_config.h" #include "nvim/ascii.h" +#include "nvim/highlight_group.h" #include "nvim/option.h" #include "nvim/screen.h" #include "nvim/strings.h" @@ -21,7 +22,6 @@ # include "api/win_config.c.generated.h" #endif - /// Open a new window. /// /// Currently this is used to open floating and external windows. @@ -125,13 +125,13 @@ /// [ "╔", "═" ,"╗", "║", "╝", "═", "╚", "║" ]. /// If the number of chars are less than eight, they will be repeated. Thus /// an ASCII border could be specified as -/// [ "/", "-", "\\", "|" ], +/// [ "/", "-", \"\\\\\", "|" ], /// or all chars the same as /// [ "x" ]. /// An empty string can be used to turn off a specific border, for instance, /// [ "", "", "", ">", "", "", "", "<" ] /// will only make vertical borders but not horizontal ones. -/// By default, `FloatBorder` highlight is used, which links to `VertSplit` +/// By default, `FloatBorder` highlight is used, which links to `WinSeparator` /// when not defined. It could also be specified by character: /// [ {"+", "MyCorner"}, {"x", "MyBorder"} ]. /// - noautocmd: If true then no buffer-related autocommand events such as @@ -149,7 +149,7 @@ Window nvim_open_win(Buffer buffer, Boolean enter, Dict(float_config) *config, E if (!parse_float_config(config, &fconfig, false, true, err)) { return 0; } - win_T *wp = win_new_float(NULL, fconfig, err); + win_T *wp = win_new_float(NULL, false, fconfig, err); if (!wp) { return 0; } @@ -199,7 +199,7 @@ void nvim_win_set_config(Window window, Dict(float_config) *config, Error *err) return; } if (new_float) { - if (!win_new_float(win, fconfig, err)) { + if (!win_new_float(win, false, fconfig, err)) { return; } redraw_later(win, NOT_VALID); @@ -263,7 +263,7 @@ Dictionary nvim_win_get_config(Window window, Error *err) String s = cstrn_to_string((const char *)config->border_chars[i], sizeof(schar_T)); int hi_id = config->border_hl_ids[i]; - char_u *hi_name = syn_id2name(hi_id); + char *hi_name = (char *)syn_id2name(hi_id); if (hi_name[0]) { ADD(tuple, STRING_OBJ(s)); ADD(tuple, STRING_OBJ(cstr_to_string((const char *)hi_name))); @@ -325,7 +325,7 @@ static bool parse_float_bufpos(Array bufpos, lpos_T *out) || bufpos.items[1].type != kObjectTypeInteger) { return false; } - out->lnum = bufpos.items[0].data.integer; + out->lnum = (linenr_T)bufpos.items[0].data.integer; out->col = (colnr_T)bufpos.items[1].data.integer; return true; } @@ -353,7 +353,7 @@ static void parse_border_style(Object style, FloatConfig *fconfig, Error *err) if (style.type == kObjectTypeArray) { Array arr = style.data.array; size_t size = arr.size; - if (!size || size > 8 || (size & (size-1))) { + if (!size || size > 8 || (size & (size - 1))) { api_set_error(err, kErrorTypeValidation, "invalid number of border chars"); return; @@ -386,12 +386,12 @@ static void parse_border_style(Object style, FloatConfig *fconfig, Error *err) return; } if (string.size - && mb_string2cells_len((char_u *)string.data, string.size) > 1) { + && mb_string2cells_len(string.data, string.size) > 1) { api_set_error(err, kErrorTypeValidation, "border chars must be one cell"); return; } - size_t len = MIN(string.size, sizeof(*chars)-1); + size_t len = MIN(string.size, sizeof(*chars) - 1); if (len) { memcpy(chars[i], string.data, len); } @@ -399,8 +399,8 @@ static void parse_border_style(Object style, FloatConfig *fconfig, Error *err) hl_ids[i] = hl_id; } while (size < 8) { - memcpy(chars+size, chars, sizeof(*chars) * size); - memcpy(hl_ids+size, hl_ids, sizeof(*hl_ids) * size); + memcpy(chars + size, chars, sizeof(*chars) * size); + memcpy(hl_ids + size, hl_ids, sizeof(*hl_ids) * size); size <<= 1; } if ((chars[7][0] && chars[1][0] && !chars[0][0]) @@ -440,18 +440,18 @@ static void parse_border_style(Object style, FloatConfig *fconfig, Error *err) static bool parse_title(FloatConfig* out, String s) { // The raw title is going to be at most the length of the string. - char_u* out_title_raw = xcalloc(sizeof(char_u), s.size + 1); + char* out_title_raw = xcalloc(sizeof(char), s.size + 1); size_t out_cursor = 0; - char_u* data = (char_u*) s.data; + char* data = s.data; size_t out_hlrec_nalloc = 4; stl_hlrec_t* out_hlrec = xcalloc(sizeof(stl_hlrec_t), out_hlrec_nalloc); - out_hlrec[0].start = out_title_raw; + out_hlrec[0].start = (char*) out_title_raw; out_hlrec[0].userhl = 0; size_t out_hl_cur = 1; - char_u hlbuf[128]; + char hlbuf[128]; size_t hlbuf_cur = 0; int hl; @@ -471,7 +471,7 @@ static bool parse_title(FloatConfig* out, String s) i ++; } hlbuf[hlbuf_cur++] = 0; - hl = syn_check_group(hlbuf, (int) strlen((char*)hlbuf)); + hl = syn_check_group(hlbuf, strlen(hlbuf)); hlbuf_cur = 0; if (out_hl_cur >= out_hlrec_nalloc - 1) { // Leave room for last. @@ -479,7 +479,7 @@ static bool parse_title(FloatConfig* out, String s) xrealloc(out_hlrec, sizeof(stl_hlrec_t) * (out_hlrec_nalloc *= 2)); } - out_hlrec[out_hl_cur].start = out_title_raw + out_cursor; + out_hlrec[out_hl_cur].start = (out_title_raw + out_cursor); out_hlrec[out_hl_cur++].userhl = -hl; } else { out_title_raw[out_cursor++] = data[i]; @@ -653,7 +653,6 @@ static bool parse_float_config(Dict(float_config) *config, FloatConfig *fconfig, return false; } - if (HAS_KEY(config->focusable)) { fconfig->focusable = api_object_to_bool(config->focusable, "'focusable' key", false, err); if (ERROR_SET(err)) { |