mirror of
https://github.com/neovim/neovim.git
synced 2025-09-11 05:48:17 +00:00
feat(float): add winborder option (#31074)
Problem: There is currently no global option to define the default border style for floating windows. This leads to repetitive code when developers need consistent styling across multiple floating windows. Solution: Introduce a global option winborder to specify the default border style for floating windows. When a floating window is created without explicitly specifying a border style, the value of the winborder option will be used. This simplifies configuration and ensures consistency in floating window appearance. Co-authored-by: Gregory Anders <greg@gpanders.com>
This commit is contained in:
@@ -159,17 +159,11 @@
|
||||
/// 'fillchars' to a space char, and clearing the
|
||||
/// |hl-EndOfBuffer| region in 'winhighlight'.
|
||||
/// - border: Style of (optional) window border. This can either be a string
|
||||
/// or an array. The string values are
|
||||
/// - "none": No border (default).
|
||||
/// - "single": A single line box.
|
||||
/// - "double": A double line box.
|
||||
/// - "rounded": Like "single", but with rounded corners ("╭" etc.).
|
||||
/// - "solid": Adds padding by a single whitespace cell.
|
||||
/// - "shadow": A drop shadow effect by blending with the background.
|
||||
/// - If it is an array, it should have a length of eight or any divisor of
|
||||
/// eight. The array will specify the eight chars building up the border
|
||||
/// in a clockwise fashion starting with the top-left corner. As an
|
||||
/// example, the double box style could be specified as:
|
||||
/// or an array. The string values are the same as those described in 'winborder'.
|
||||
/// If it is an array, it should have a length of eight or any divisor of
|
||||
/// eight. The array will specify the eight chars building up the border
|
||||
/// in a clockwise fashion starting with the top-left corner. As an
|
||||
/// example, the double box style could be specified as:
|
||||
/// ```
|
||||
/// [ "╔", "═" ,"╗", "║", "╝", "═", "╚", "║" ].
|
||||
/// ```
|
||||
@@ -944,11 +938,11 @@ static void parse_border_style(Object style, WinConfig *fconfig, Error *err)
|
||||
char chars[8][MAX_SCHAR_SIZE];
|
||||
bool shadow_color;
|
||||
} defaults[] = {
|
||||
{ "double", { "╔", "═", "╗", "║", "╝", "═", "╚", "║" }, false },
|
||||
{ "single", { "┌", "─", "┐", "│", "┘", "─", "└", "│" }, false },
|
||||
{ "shadow", { "", "", " ", " ", " ", " ", " ", "" }, true },
|
||||
{ "rounded", { "╭", "─", "╮", "│", "╯", "─", "╰", "│" }, false },
|
||||
{ "solid", { " ", " ", " ", " ", " ", " ", " ", " " }, false },
|
||||
{ opt_winborder_values[1], { "╔", "═", "╗", "║", "╝", "═", "╚", "║" }, false },
|
||||
{ opt_winborder_values[2], { "┌", "─", "┐", "│", "┘", "─", "└", "│" }, false },
|
||||
{ opt_winborder_values[3], { "", "", " ", " ", " ", " ", " ", "" }, true },
|
||||
{ opt_winborder_values[4], { "╭", "─", "╮", "│", "╯", "─", "╰", "│" }, false },
|
||||
{ opt_winborder_values[5], { " ", " ", " ", " ", " ", " ", " ", " " }, false },
|
||||
{ NULL, { { NUL } }, false },
|
||||
};
|
||||
|
||||
@@ -1279,12 +1273,13 @@ static bool parse_win_config(win_T *wp, Dict(win_config) *config, WinConfig *fco
|
||||
}
|
||||
}
|
||||
|
||||
if (HAS_KEY_X(config, border)) {
|
||||
if (HAS_KEY_X(config, border) || *p_winbd != NUL) {
|
||||
if (is_split) {
|
||||
api_set_error(err, kErrorTypeValidation, "non-float cannot have 'border'");
|
||||
goto fail;
|
||||
}
|
||||
parse_border_style(config->border, fconfig, err);
|
||||
Object style = config->border.type != kObjectTypeNil ? config->border : CSTR_AS_OBJ(p_winbd);
|
||||
parse_border_style(style, fconfig, err);
|
||||
if (ERROR_SET(err)) {
|
||||
goto fail;
|
||||
}
|
||||
|
Reference in New Issue
Block a user