summaryrefslogtreecommitdiff
path: root/buffer.c
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2023-07-18 17:20:11 -0400
committerpommicket <pommicket@gmail.com>2023-07-18 17:20:11 -0400
commiteb1c75720eaa8686c160e3ffa2559a03b5187e5a (patch)
tree47d1b9236ae45ba2392a64994c8fa8181c414630 /buffer.c
parent9bee6a4bbd74a6ef9c317cfb54ffa7136644de4c (diff)
font fallbacksvariable-width
Diffstat (limited to 'buffer.c')
-rw-r--r--buffer.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/buffer.c b/buffer.c
index 3ca57f9..5cf1820 100644
--- a/buffer.c
+++ b/buffer.c
@@ -956,8 +956,14 @@ bool buffer_pixels_to_pos(TextBuffer *buffer, vec2 pixel_coords, BufferPos *pos)
x -= buffer->x1;
y -= buffer->y1;
- x = clampd(x, 0, buffer->x2 - buffer->x1);
- y = clampd(y, 0, buffer->y2 - buffer->y1);
+ double buffer_width = buffer->x2 - buffer->x1;
+ double buffer_height = buffer->y2 - buffer->y1;
+
+ if (x < 0 || y < 0 || x >= buffer_width || y >= buffer_height)
+ ret = false;
+
+ x = clampd(x, 0, buffer_width);
+ y = clampd(y, 0, buffer_height);
double xoff = x + buffer->scroll_x * text_font_char_width(font, ' ');