mirror of
https://github.com/neovim/neovim.git
synced 2025-10-05 17:36:29 +00:00
Border: allow to enable/disable specific border edges
This commit is contained in:
@@ -1760,10 +1760,12 @@ static void parse_border_style(Object style, FloatConfig *fconfig, Error *err)
|
||||
struct {
|
||||
const char *name;
|
||||
schar_T chars[8];
|
||||
bool shadow_color;
|
||||
} defaults[] = {
|
||||
{ "double", { "╔", "═", "╗", "║", "╝", "═", "╚", "║" } },
|
||||
{ "single", { "┌", "─", "┐", "│", "┘", "─", "└", "│" } },
|
||||
{ NULL, { { NUL } } },
|
||||
{ "double", { "╔", "═", "╗", "║", "╝", "═", "╚", "║" }, false },
|
||||
{ "single", { "┌", "─", "┐", "│", "┘", "─", "└", "│" }, false },
|
||||
{ "shadow", { "", "", " ", " ", " ", " ", " ", "" }, true },
|
||||
{ NULL, { { NUL } } , false },
|
||||
};
|
||||
|
||||
schar_T *chars = fconfig->border_chars;
|
||||
@@ -1807,13 +1809,16 @@ static void parse_border_style(Object style, FloatConfig *fconfig, Error *err)
|
||||
api_set_error(err, kErrorTypeValidation, "invalid border char");
|
||||
return;
|
||||
}
|
||||
if (!string.size
|
||||
|| mb_string2cells_len((char_u *)string.data, string.size) != 1) {
|
||||
if (string.size
|
||||
&& mb_string2cells_len((char_u *)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);
|
||||
memcpy(chars[i], string.data, len);
|
||||
if (len) {
|
||||
memcpy(chars[i], string.data, len);
|
||||
}
|
||||
chars[i][len] = NUL;
|
||||
hl_ids[i] = hl_id;
|
||||
}
|
||||
@@ -1822,6 +1827,13 @@ static void parse_border_style(Object style, FloatConfig *fconfig, Error *err)
|
||||
memcpy(hl_ids+size, hl_ids, sizeof(*hl_ids) * size);
|
||||
size <<= 1;
|
||||
}
|
||||
if ((chars[7][0] && chars[1][0] && !chars[0][0])
|
||||
|| (chars[1][0] && chars[3][0] && !chars[2][0])
|
||||
|| (chars[3][0] && chars[5][0] && !chars[4][0])
|
||||
|| (chars[5][0] && chars[7][0] && !chars[6][0])) {
|
||||
api_set_error(err, kErrorTypeValidation,
|
||||
"corner between used edges must be specified");
|
||||
}
|
||||
} else if (style.type == kObjectTypeString) {
|
||||
String str = style.data.string;
|
||||
if (str.size == 0 || strequal(str.data, "none")) {
|
||||
@@ -1832,6 +1844,15 @@ static void parse_border_style(Object style, FloatConfig *fconfig, Error *err)
|
||||
if (strequal(str.data, defaults[i].name)) {
|
||||
memcpy(chars, defaults[i].chars, sizeof(defaults[i].chars));
|
||||
memset(hl_ids, 0, 8 * sizeof(*hl_ids));
|
||||
if (defaults[i].shadow_color) {
|
||||
int hl_blend = SYN_GROUP_STATIC("FloatShadow");
|
||||
int hl_through = SYN_GROUP_STATIC("FloatShadowThrough");
|
||||
hl_ids[2] = hl_through;
|
||||
hl_ids[3] = hl_blend;
|
||||
hl_ids[4] = hl_blend;
|
||||
hl_ids[5] = hl_blend;
|
||||
hl_ids[6] = hl_through;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@@ -1421,6 +1421,7 @@ void nvim_chan_send(Integer chan, String data, Error *err)
|
||||
/// - "none" No border. This is the default
|
||||
/// - "single" a single line box
|
||||
/// - "double" a double line box
|
||||
/// - "shadow" a drop shadow effect by blending with the background.
|
||||
/// If it is an array it should be an array of eight items or any divisor of
|
||||
/// eight. The array will specifify the eight chars building up the border
|
||||
/// in a clockwise fashion starting with the top-left corner. As, an
|
||||
@@ -1431,6 +1432,9 @@ void nvim_chan_send(Integer chan, String data, Error *err)
|
||||
/// [ "/", "-", "\\", "|" ]
|
||||
/// 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`
|
||||
/// when not defined. It could also be specified by character:
|
||||
/// [ {"+", "MyCorner"}, {"x", "MyBorder"} ]
|
||||
|
Reference in New Issue
Block a user