summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2020-12-27 21:03:11 -0500
committerLeo Tenenbaum <pommicket@gmail.com>2020-12-27 21:03:11 -0500
commitc1cb1b308d65b0f3a0b7a946d5aa74ce43b30d0a (patch)
treee7bd601a1c1bb456ee594abb7de93dcc48d05ae3 /main.c
parentc38e418286c5cc2e8af7f68de9483d9cdcf95dce (diff)
click to move cursor
Diffstat (limited to 'main.c')
-rw-r--r--main.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/main.c b/main.c
index 763decd..41387d1 100644
--- a/main.c
+++ b/main.c
@@ -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)