diff options
author | Leo Tenenbaum <pommicket@gmail.com> | 2020-12-27 21:03:11 -0500 |
---|---|---|
committer | Leo Tenenbaum <pommicket@gmail.com> | 2020-12-27 21:03:11 -0500 |
commit | c1cb1b308d65b0f3a0b7a946d5aa74ce43b30d0a (patch) | |
tree | e7bd601a1c1bb456ee594abb7de93dcc48d05ae3 /main.c | |
parent | c38e418286c5cc2e8af7f68de9483d9cdcf95dce (diff) |
click to move cursor
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -104,13 +104,22 @@ int main(void) { double scroll_speed = 2.5; buffer_scroll(&text_buffer, dx * scroll_speed, dy * scroll_speed); } break; + case SDL_MOUSEBUTTONDOWN: + switch (event.button.button) { + case SDL_BUTTON_LEFT: { + BufferPos pos; + if (buffer_pixels_to_pos(&text_buffer, (float)event.button.x, (float)event.button.y, &pos)) + buffer_cursor_move_to_pos(&text_buffer, pos); + } break; + } + break; case SDL_KEYDOWN: { switch (event.key.keysym.sym) { case SDLK_PAGEUP: - buffer_scroll(&text_buffer, 0, -buffer_display_rows(&text_buffer)); + buffer_scroll(&text_buffer, 0, -buffer_display_lines(&text_buffer)); break; case SDLK_PAGEDOWN: - buffer_scroll(&text_buffer, 0, +buffer_display_rows(&text_buffer)); + buffer_scroll(&text_buffer, 0, +buffer_display_lines(&text_buffer)); break; case SDLK_RIGHT: if (ctrl) |