summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config.c1
-rw-r--r--ide-hover.c9
-rw-r--r--main.c3
-rw-r--r--ted.cfg2
-rw-r--r--ted.h4
5 files changed, 14 insertions, 5 deletions
diff --git a/config.c b/config.c
index ddfc8ad..7f52fe0 100644
--- a/config.c
+++ b/config.c
@@ -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;
}
diff --git a/main.c b/main.c
index c2e4904..e393cc8 100644
--- a/main.c
+++ b/main.c
@@ -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;
diff --git a/ted.cfg b/ted.cfg
index dcf926b..7c0079e 100644
--- a/ted.cfg
+++ b/ted.cfg
@@ -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
diff --git a/ted.h b/ted.h
index 8b73898..ecf592b 100644
--- a/ted.h
+++ b/ted.h
@@ -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 {