summaryrefslogtreecommitdiff
path: root/buffer.c
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2021-02-08 11:33:43 -0500
committerLeo Tenenbaum <pommicket@gmail.com>2021-02-08 11:33:43 -0500
commitabec84f7b2ee0f75c4622a6d4469dbf0c7eaf5ad (patch)
tree9cc6ccef1b897db7127f88a4de55c2f9b85c9535 /buffer.c
parentf7828a0718b730ffdc6b9f25e5d11cbfd666acf1 (diff)
find show number of matches
Diffstat (limited to 'buffer.c')
-rw-r--r--buffer.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/buffer.c b/buffer.c
index 2b23fe7..b00f122 100644
--- a/buffer.c
+++ b/buffer.c
@@ -1937,6 +1937,15 @@ void buffer_check_valid(TextBuffer *buffer) {
}
#endif
+u32 buffer_first_rendered_line(TextBuffer *buffer) {
+ return (u32)buffer->scroll_y;
+}
+
+u32 buffer_last_rendered_line(TextBuffer *buffer) {
+ u32 line = buffer_first_rendered_line(buffer) + (u32)buffer_display_lines(buffer) + 1;
+ return clamp_u32(line, 0, buffer->nlines);
+}
+
// Render the text buffer in the given rectangle
void buffer_render(TextBuffer *buffer, Rect r) {
float x1, y1, x2, y2;
@@ -1956,7 +1965,7 @@ void buffer_render(TextBuffer *buffer, Rect r) {
float const padding = settings->padding;
float const border_thickness = settings->border_thickness;
- u32 start_line = (u32)buffer->scroll_y; // line to start rendering from
+ u32 start_line = buffer_first_rendered_line(buffer); // line to start rendering from
Rect bounding_box = rect4(x1, y1, x2, y2);
float render_start_y = y1 - (float)(buffer->scroll_y - start_line) * char_height; // where the 1st line is rendered