mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
api: refactor FloatAnchor usage
This commit is contained in:
parent
cfed9a4123
commit
98391cd6ab
@ -495,7 +495,7 @@ Dictionary nvim_win_get_config(Window window, Error *err)
|
|||||||
PUT(rv, "focusable", BOOLEAN_OBJ(wp->w_float_config.focusable));
|
PUT(rv, "focusable", BOOLEAN_OBJ(wp->w_float_config.focusable));
|
||||||
PUT(rv, "external", BOOLEAN_OBJ(wp->w_float_config.external));
|
PUT(rv, "external", BOOLEAN_OBJ(wp->w_float_config.external));
|
||||||
PUT(rv, "anchor", STRING_OBJ(cstr_to_string(
|
PUT(rv, "anchor", STRING_OBJ(cstr_to_string(
|
||||||
float_anchor_str[wp->w_float_config.anchor])));
|
float_anchor_str[wp->w_float_config.anchor])));
|
||||||
|
|
||||||
if (wp->w_float_config.relative == kFloatRelativeWindow) {
|
if (wp->w_float_config.relative == kFloatRelativeWindow) {
|
||||||
PUT(rv, "win", INTEGER_OBJ(wp->w_float_config.window));
|
PUT(rv, "win", INTEGER_OBJ(wp->w_float_config.window));
|
||||||
|
@ -958,20 +958,23 @@ struct matchitem {
|
|||||||
int conceal_char; ///< cchar for Conceal highlighting
|
int conceal_char; ///< cchar for Conceal highlighting
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef enum {
|
typedef int FloatAnchor;
|
||||||
kFloatAnchorEast = 1,
|
|
||||||
kFloatAnchorSouth = 2,
|
|
||||||
|
|
||||||
kFloatAnchorNW = 0,
|
enum {
|
||||||
kFloatAnchorNE = 1,
|
kFloatAnchorEast = 1,
|
||||||
kFloatAnchorSW = 2,
|
kFloatAnchorSouth = 2,
|
||||||
kFloatAnchorSE = 3,
|
};
|
||||||
} FloatAnchor;
|
|
||||||
|
// NW -> 0
|
||||||
|
// NE -> kFloatAnchorEast
|
||||||
|
// SW -> kFloatAnchorSouth
|
||||||
|
// SE -> kFloatAnchorSouth | kFloatAnchorEast
|
||||||
|
EXTERN const char *const float_anchor_str[] INIT(= { "NW", "NE", "SW", "SE" });
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
kFloatRelativeEditor = 0,
|
kFloatRelativeEditor = 0,
|
||||||
kFloatRelativeWindow = 1,
|
kFloatRelativeWindow = 1,
|
||||||
kFloatRelativeCursor = 2,
|
kFloatRelativeCursor = 2,
|
||||||
} FloatRelative;
|
} FloatRelative;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -614,12 +614,6 @@ static void ui_ext_win_position(win_T *wp)
|
|||||||
wp->w_wincol, wp->w_width, wp->w_height);
|
wp->w_wincol, wp->w_width, wp->w_height);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const char *const anchor_str[] = {
|
|
||||||
"NW",
|
|
||||||
"NE",
|
|
||||||
"SW",
|
|
||||||
"SE"
|
|
||||||
};
|
|
||||||
|
|
||||||
FloatConfig c = wp->w_float_config;
|
FloatConfig c = wp->w_float_config;
|
||||||
if (!c.external) {
|
if (!c.external) {
|
||||||
@ -635,7 +629,7 @@ static void ui_ext_win_position(win_T *wp)
|
|||||||
api_clear_error(&dummy);
|
api_clear_error(&dummy);
|
||||||
}
|
}
|
||||||
if (ui_has(kUIMultigrid)) {
|
if (ui_has(kUIMultigrid)) {
|
||||||
String anchor = cstr_to_string(anchor_str[c.anchor]);
|
String anchor = cstr_to_string(float_anchor_str[c.anchor]);
|
||||||
ui_call_win_float_pos(wp->w_grid.handle, wp->handle, anchor, grid->handle,
|
ui_call_win_float_pos(wp->w_grid.handle, wp->handle, anchor, grid->handle,
|
||||||
row, col, c.focusable);
|
row, col, c.focusable);
|
||||||
} else {
|
} else {
|
||||||
@ -672,14 +666,14 @@ static bool parse_float_anchor(String anchor, FloatAnchor *out)
|
|||||||
*out = (FloatAnchor)0;
|
*out = (FloatAnchor)0;
|
||||||
}
|
}
|
||||||
char *str = anchor.data;
|
char *str = anchor.data;
|
||||||
if (!STRICMP(str, "NW")) {
|
if (striequal(str, "NW")) {
|
||||||
*out = kFloatAnchorNW;
|
*out = 0; // NW is the default
|
||||||
} else if (!STRICMP(str, "NE")) {
|
} else if (striequal(str, "NE")) {
|
||||||
*out = kFloatAnchorNE;
|
*out = kFloatAnchorEast;
|
||||||
} else if (!STRICMP(str, "SW")) {
|
} else if (striequal(str, "SW")) {
|
||||||
*out = kFloatAnchorSW;
|
*out = kFloatAnchorSouth;
|
||||||
} else if (!STRICMP(str, "SE")) {
|
} else if (striequal(str, "SE")) {
|
||||||
*out = kFloatAnchorSE;
|
*out = kFloatAnchorSouth | kFloatAnchorEast;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user