From c59f63a5be50c54ca4f38f48e2dc82d8d8fd012a Mon Sep 17 00:00:00 2001 From: cflip Date: Thu, 12 Jan 2023 12:28:41 -0700 Subject: Add a cursor --- window.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/window.c b/window.c index 9d10f85..1c300b7 100644 --- a/window.c +++ b/window.c @@ -105,6 +105,16 @@ void window_redraw(struct editor_state *editor) draw_font_text(&buffer); + SDL_Rect cursor_rect; + cursor_rect.x = editor->cursor_display_x * font.width; + cursor_rect.y = (editor->cursor_y - editor->row_offset) * font.height; + cursor_rect.w = font.width; + cursor_rect.h = font.height; + + SDL_SetRenderDrawColor(renderer, 0x7f, 0x7f, 0x7f, 0xff); + SDL_RenderFillRect(renderer, &cursor_rect); + SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0x00, 0xff); + SDL_RenderPresent(renderer); SDL_UpdateWindowSurface(window); } -- cgit v1.2.3