summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--colors.h7
-rw-r--r--hover.c9
-rw-r--r--main.c9
-rw-r--r--ted.cfg4
-rw-r--r--ted.h2
5 files changed, 25 insertions, 6 deletions
diff --git a/colors.h b/colors.h
index 92c8858..46d03fd 100644
--- a/colors.h
+++ b/colors.h
@@ -31,6 +31,10 @@ typedef enum {
COLOR_AUTOCOMPLETE_FUNCTION,
COLOR_AUTOCOMPLETE_VARIABLE,
COLOR_AUTOCOMPLETE_TYPE,
+
+ COLOR_HOVER_BG,
+ COLOR_HOVER_BORDER,
+ COLOR_HOVER_TEXT,
COLOR_YES,
COLOR_NO,
@@ -95,6 +99,9 @@ static ColorName const color_names[] = {
{COLOR_AUTOCOMPLETE_VARIABLE, "autocomplete-variable"},
{COLOR_AUTOCOMPLETE_FUNCTION, "autocomplete-function"},
{COLOR_AUTOCOMPLETE_TYPE, "autocomplete-type"},
+ {COLOR_HOVER_BORDER, "hover-border"},
+ {COLOR_HOVER_BG, "hover-bg"},
+ {COLOR_HOVER_TEXT, "hover-text"},
{COLOR_YES, "yes"},
{COLOR_NO, "no"},
{COLOR_CANCEL, "cancel"},
diff --git a/hover.c b/hover.c
index ebb3d8e..d22f513 100644
--- a/hover.c
+++ b/hover.c
@@ -93,6 +93,8 @@ void hover_frame(Ted *ted, double dt) {
return;
const Settings *settings = ted_active_settings(ted);
+ const float padding = settings->padding;
+ const float border = settings->border_thickness;
const u32 *colors = settings->colors;
const char *text = hover->text;
Font *font = ted->font;
@@ -114,8 +116,11 @@ void hover_frame(Ted *ted, double dt) {
state.y = y;
state.render = true;
state.max_y = y + height;
- gl_geometry_rect(rect_xywh(x, y, width, height), colors[COLOR_AUTOCOMPLETE_BG]);
- rgba_u32_to_floats(colors[COLOR_TEXT], state.color);
+
+ Rect rect = rect_xywh(x - padding, y - padding, width + 2*padding, height + 2*padding);
+ gl_geometry_rect(rect, colors[COLOR_HOVER_BG]);
+ gl_geometry_rect_border(rect, border, colors[COLOR_HOVER_BORDER]);
+ rgba_u32_to_floats(colors[COLOR_HOVER_TEXT], state.color);
text_utf8_with_state(font, &state, text);
gl_geometry_draw();
text_render(font);
diff --git a/main.c b/main.c
index 39e659b..fac2c4e 100644
--- a/main.c
+++ b/main.c
@@ -1,7 +1,6 @@
/*
@TODO:
- more LSP stuff:
- - hover
- go to definition using LSP
- find usages
- highlight hover range
@@ -1100,8 +1099,12 @@ int main(int argc, char **argv) {
ted->cursor = ted->cursor_move;
SDL_SetWindowTitle(window, ted->window_title);
- SDL_SetCursor(ted->cursor);
-
+ if (ted->cursor) {
+ SDL_SetCursor(ted->cursor);
+ SDL_ShowCursor(SDL_ENABLE);
+ } else {
+ SDL_ShowCursor(SDL_DISABLE);
+ }
// annoyingly, SDL_GL_SwapWindow seems to be a busy loop on my laptop for some reason...
// enforce a framerate of 60. this isn't ideal but SDL_GetDisplayMode is *extremely slow* (250ms), so we don't really have a choice.
diff --git a/ted.cfg b/ted.cfg
index 029031d..f954a48 100644
--- a/ted.cfg
+++ b/ted.cfg
@@ -303,6 +303,10 @@ cancel = #ffa
autocomplete-bg = #000
autocomplete-border = #999
autocomplete-hl = #f6a3
+# hover (press shift while hovering over an identifier with an LSP server running)
+hover-bg = #000a
+hover-border = #fffa
+hover-text = #fff
# these control the text color for various kinds of completions
autocomplete-variable = #bfb
autocomplete-function = #aaf
diff --git a/ted.h b/ted.h
index 004cc2a..64fb993 100644
--- a/ted.h
+++ b/ted.h
@@ -477,7 +477,7 @@ typedef struct Ted {
v2d prev_active_buffer_scroll;
SDL_Cursor *cursor_arrow, *cursor_ibeam, *cursor_resize_h, *cursor_resize_v, *cursor_hand, *cursor_move;
- SDL_Cursor *cursor; // which cursor to use this frame
+ SDL_Cursor *cursor; // which cursor to use this frame (NULL for no cursor)
// node containing tab user is dragging around, NULL if user is not dragging a tab
Node *dragging_tab_node;