diff options
author | pommicket <pommicket@gmail.com> | 2022-12-31 15:48:12 -0500 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2022-12-31 15:48:12 -0500 |
commit | fd617d8d9723f76dcdb51b2fa54ef960be4edccc (patch) | |
tree | aaf01cc5bda6703448b63ea0ea7ffff30f820bba | |
parent | 992315198b510e210a7791f21953bf0e27786108 (diff) |
hover-time setting
-rw-r--r-- | config.c | 1 | ||||
-rw-r--r-- | ide-hover.c | 9 | ||||
-rw-r--r-- | main.c | 3 | ||||
-rw-r--r-- | ted.cfg | 2 | ||||
-rw-r--r-- | ted.h | 4 |
5 files changed, 14 insertions, 5 deletions
@@ -288,6 +288,7 @@ static OptionU32 const options_u32[] = { static OptionFloat const options_float[] = { {"cursor-blink-time-on", &options_zero.cursor_blink_time_on, 0, 1000, true}, {"cursor-blink-time-off", &options_zero.cursor_blink_time_off, 0, 1000, true}, + {"hover-time", &options_zero.hover_time, 0, INFINITY, true}, }; static OptionString const options_string[] = { {"build-default-command", options_zero.build_default_command, sizeof options_zero.build_default_command, true}, diff --git a/ide-hover.c b/ide-hover.c index 9a7c0c9..1d6ccbc 100644 --- a/ide-hover.c +++ b/ide-hover.c @@ -79,13 +79,16 @@ void hover_frame(Ted *ted, double dt) { bool shift_down = SDL_GetKeyboardState(NULL)[SDL_SCANCODE_LSHIFT] || SDL_GetKeyboardState(NULL)[SDL_SCANCODE_RSHIFT]; - if (!shift_down) { + bool open_hover = shift_down || hover->time >= settings->hover_time; + + hover->time += dt; + + if (!open_hover) hover_close(ted); - } (void)dt; if (!hover->open) { - if (shift_down) { + if (open_hover) { hover_send_request(ted); hover->open = true; } @@ -1,6 +1,5 @@ /* @TODO: -- hover-auto - handle multiple symbols with same name in go-to-definition menu - :go-to-cursor-definition - test full unicode position handling @@ -12,6 +11,7 @@ - what to do if initialize request takes a long time? - delete old sent requests? but make sure requests that just take a long time are okay. (if the server never sends a response) +- check LSP process status (TEST: what happens if LSP server is not installed) - make tags_dir the root folder - check that tags still works - TESTING: make rust-analyzer-slow (waits 10s before sending response) @@ -769,6 +769,7 @@ int main(int argc, char **argv) { buffer_pixels_to_pos(ted->drag_buffer, V2(x, y), &pos); buffer_select_to_pos(ted->drag_buffer, pos); } + ted->hover.time = 0.0; } break; case SDL_KEYDOWN: { SDL_Scancode scancode = event.key.keysym.scancode; @@ -41,6 +41,8 @@ lsp-enabled = yes signature-help-enabled = yes # display hover info when shift key is pressed? (only with LSP running) hover-enabled = yes +# if this is set to x, then hover info will be displayed without shift key after x seconds (with LSP running) +hover-time = 1e10 # highlight instances of the variable under the cursor when the ctrl key is pressed? (only with LSP running) highlight-enabled = yes # don't require ctrl key for highlighting @@ -136,8 +136,9 @@ typedef struct { // and change the options_<type> global constant in config.c SettingsContext context; - float cursor_blink_time_on, cursor_blink_time_off; u32 colors[COLOR_COUNT]; + float cursor_blink_time_on, cursor_blink_time_off; + float hover_time; u32 max_file_size; u32 max_file_size_view_only; u16 framerate_cap; @@ -425,6 +426,7 @@ typedef struct { LSPDocumentPosition requested_position; LSPID requested_lsp; LSPRange range; + double time; // how long the cursor has been hovering for } Hover; typedef struct { |