diff --git a/kitty/data-types.h b/kitty/data-types.h index b7845659f..a1b9d3898 100644 --- a/kitty/data-types.h +++ b/kitty/data-types.h @@ -65,7 +65,7 @@ typedef enum MouseTrackingProtocols { NORMAL_PROTOCOL, UTF8_PROTOCOL, SGR_PROTOC typedef enum MouseShapes { BEAM, HAND, ARROW } MouseShape; typedef enum { NONE, MENUBAR, WINDOW, ALL } WindowTitleIn; typedef enum { TILING, SCALED, MIRRORED, CLAMPED } BackgroundImageLayout; -typedef enum { NORTHWEST, NORTH, NORTHEAST, EAST, SOUTHEAST, SOUTH, SOUTHWEST, WEST, CENTER } BackgroundImageAnchor; +typedef enum { TOP_LEFT, TOP, TOP_RIGHT, LEFT, CENTER, RIGHT, BOTTOM_LEFT, BOTTOM, BOTTOM_RIGHT } BackgroundImageAnchor; #define MAX_CHILDREN 512 #define BLANK_CHAR 0 diff --git a/kitty/options/definition.py b/kitty/options/definition.py index 8c4a65bf4..55d654ed3 100644 --- a/kitty/options/definition.py +++ b/kitty/options/definition.py @@ -1110,8 +1110,8 @@ opt('background_image_layout', 'tiled', long_text='Whether to tile, scale or clamp the background image.' ) -opt('background_image_anchor', 'northwest', - choices=('northwest', 'north', 'northeast', 'east', 'southeast', 'south', 'southwest', 'west', 'center'), ctype='bganchor', +opt('background_image_anchor', 'top-left', + choices=('top-left', 'top', 'top-right', 'left', 'center', 'right', 'bottom-left', 'bottom', 'bottom-right'), ctype='bganchor', long_text='Where to position the background image in the window.' ) diff --git a/kitty/options/parse.py b/kitty/options/parse.py index c8aae2ead..3356bfef9 100644 --- a/kitty/options/parse.py +++ b/kitty/options/parse.py @@ -63,7 +63,7 @@ class Parser: raise ValueError(f"The value {val} is not a valid choice for background_image_anchor") ans["background_image_anchor"] = val - choices_for_background_image_anchor = frozenset(('northwest', 'north', 'northeast', 'east', 'southeast', 'south', 'southwest', 'west', 'center')) + choices_for_background_image_anchor = frozenset(('top-left', 'top', 'top-right', 'left', 'center', 'right', 'bottom-left', 'bottom', 'bottom-right')) def background_image_layout(self, val: str, ans: typing.Dict[str, typing.Any]) -> None: val = val.lower() diff --git a/kitty/options/to-c.h b/kitty/options/to-c.h index 7e9c7bbf7..32f48409e 100644 --- a/kitty/options/to-c.h +++ b/kitty/options/to-c.h @@ -81,31 +81,24 @@ bglayout(PyObject *layout_name) { static BackgroundImageAnchor bganchor(PyObject *anchor_name) { const char *name = PyUnicode_AsUTF8(anchor_name); - if (strcmp(name, "north") == 0) { - return NORTH; - } - else if (strcmp(name, "northeast") == 0) { - return NORTHEAST; - } - else if (strcmp(name, "east") == 0) { - return EAST; - } - else if (strcmp(name, "southeast") == 0) { - return SOUTHEAST; - } - else if (strcmp(name, "south") == 0) { - return SOUTH; - } - else if (strcmp(name, "southwest") == 0) { - return SOUTHWEST; - } - else if (strcmp(name, "west") == 0) { - return WEST; - } - else if (strcmp(name, "center") == 0) { + if (strcmp(name, "top") == 0) { + return TOP; + } else if (strcmp(name, "top-right") == 0) { + return TOP_RIGHT; + } else if (strcmp(name, "left") == 0) { + return LEFT; + } else if (strcmp(name, "center") == 0) { return CENTER; + } else if (strcmp(name, "right") == 0) { + return RIGHT; + } else if (strcmp(name, "bottom-left") == 0) { + return BOTTOM_LEFT; + } else if (strcmp(name, "bottom") == 0) { + return BOTTOM; + } else if (strcmp(name, "bottom-right") == 0) { + return BOTTOM_RIGHT; } - return NORTHWEST; + return TOP_LEFT; } #define STR_SETTER(name) { \ diff --git a/kitty/options/types.py b/kitty/options/types.py index 885157b87..154a31b1d 100644 --- a/kitty/options/types.py +++ b/kitty/options/types.py @@ -14,7 +14,7 @@ from kitty.types import FloatEdges, SingleKey import kitty.types if typing.TYPE_CHECKING: - choices_for_background_image_anchor = typing.Literal['northwest', 'north', 'northeast', 'east', 'southeast', 'south', 'southwest', 'west', 'center'] + choices_for_background_image_anchor = typing.Literal['top-left', 'top', 'top-right', 'left', 'center', 'right', 'bottom-left', 'bottom', 'bottom-right'] choices_for_background_image_layout = typing.Literal['mirror-tiled', 'scaled', 'tiled', 'clamped'] choices_for_default_pointer_shape = typing.Literal['arrow', 'beam', 'hand'] choices_for_linux_display_server = typing.Literal['auto', 'wayland', 'x11'] @@ -456,7 +456,7 @@ class Options: allow_remote_control: str = 'n' background: Color = Color(0, 0, 0) background_image: typing.Optional[str] = None - background_image_anchor: choices_for_background_image_anchor = 'northwest' + background_image_anchor: choices_for_background_image_anchor = 'top-left' background_image_layout: choices_for_background_image_layout = 'tiled' background_image_linear: bool = False background_opacity: float = 1.0 diff --git a/kitty/rc/set_background_image.py b/kitty/rc/set_background_image.py index 57390c848..7cfe93c11 100644 --- a/kitty/rc/set_background_image.py +++ b/kitty/rc/set_background_image.py @@ -55,7 +55,7 @@ How the image should be displayed. The value of configured will use the configur --anchor type=choices -choices=northwest,north,northeast,east,southeast,south,southwest,west,northwest,north,center,configured +choices=top-left,top,top-right,left,center,right,bottom-left,bottom,bottom-right,configured Where the image should be positioned. The value of configured will use the configured value. diff --git a/kitty/shaders.c b/kitty/shaders.c index 05c03abb9..76a4d9f73 100644 --- a/kitty/shaders.c +++ b/kitty/shaders.c @@ -418,14 +418,14 @@ draw_bg(OSWindow *w) { } float translate_left = 0.0f, translate_top = 0.0f; if (unscaled) { - if (OPT(background_image_anchor) == NORTH || OPT(background_image_anchor) == CENTER || OPT(background_image_anchor) == SOUTH) { + if (OPT(background_image_anchor) == TOP || OPT(background_image_anchor) == CENTER || OPT(background_image_anchor) == BOTTOM) { translate_left = ((float)w->window_width / 2.0f - (float)w->bgimage->width / 2.0f) / (float)w->bgimage->width; - } else if (OPT(background_image_anchor) == NORTHEAST || OPT(background_image_anchor) == EAST || OPT(background_image_anchor) == SOUTHEAST) { + } else if (OPT(background_image_anchor) == TOP_RIGHT || OPT(background_image_anchor) == RIGHT || OPT(background_image_anchor) == BOTTOM_RIGHT) { translate_left = ((float)w->window_width - (float)w->bgimage->width) / (float)w->bgimage->width; } - if (OPT(background_image_anchor) == WEST || OPT(background_image_anchor) == CENTER || OPT(background_image_anchor) == EAST) { + if (OPT(background_image_anchor) == LEFT || OPT(background_image_anchor) == CENTER || OPT(background_image_anchor) == RIGHT) { translate_top = ((float)w->window_height / 2.0f - (float)w->bgimage->height / 2.0f) / (float)w->bgimage->height; - } else if (OPT(background_image_anchor) == SOUTHWEST || OPT(background_image_anchor) == SOUTH || OPT(background_image_anchor) == SOUTHEAST) { + } else if (OPT(background_image_anchor) == BOTTOM_LEFT || OPT(background_image_anchor) == BOTTOM || OPT(background_image_anchor) == BOTTOM_RIGHT) { translate_top = ((float)w->window_height - (float)w->bgimage->height) / (float)w->bgimage->height; } }