From 4736d2d6c02b2715bba58484eacce51495df2f4c Mon Sep 17 00:00:00 2001 From: pommicket Date: Wed, 4 Jan 2023 12:47:59 -0500 Subject: fix mouse clicks in the "go to definition" menu --- main.c | 2 +- ted.h | 3 ++- ui.c | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index a3af116..75bc97d 100644 --- a/main.c +++ b/main.c @@ -1,6 +1,5 @@ /* @TODO: -- handle mouse clicks in "go to definition..." menu - ted.h documentation - document lsp.h and lsp.c. - debug-lsp option (which logs LSP messages) @@ -25,6 +24,7 @@ - make buffer->path NULL for untitled buffers & fix resulting mess - rust-analyzer bug reports: - bad json can give "Unexpected error: client exited without proper shutdown sequence" + - containerName not always given - clangd bug report: - textDocumemt/definition on ted.h declarations just gives you the declaration FUTURE FEATURES: diff --git a/ted.h b/ted.h index 98b78d6..57eeb2c 100644 --- a/ted.h +++ b/ted.h @@ -1130,7 +1130,8 @@ void selector_up(Ted *ted, Selector *s, i64 n); void selector_down(Ted *ted, Selector *s, i64 n); // sort entries alphabetically void selector_sort_entries_by_name(Selector *s); -// returns a null-terminated UTF-8 string of the option selected, or NULL if none was. +// returns a null-terminated UTF-8 string of the entry selected, or NULL if none was. +// also, sel->cursor will be set to the index of the entry, even if the mouse was used. // you should call free() on the return value. char *selector_update(Ted *ted, Selector *s); // NOTE: also renders the line buffer diff --git a/ui.c b/ui.c index ad1fe56..0a68d03 100644 --- a/ui.c +++ b/ui.c @@ -82,6 +82,7 @@ char *selector_update(Ted *ted, Selector *s) { for (uint c = 0; c < ted->nmouse_clicks[SDL_BUTTON_LEFT]; ++c) { if (rect_contains_point(entry_rect, ted->mouse_clicks[SDL_BUTTON_LEFT][c])) { // this option was selected + s->cursor = i; // indicate the index of the selected entry using s->cursor ret = str_dup(s->entries[i].name); break; } -- cgit v1.2.3