diff options
author | pommicket <pommicket@gmail.com> | 2022-12-29 12:23:16 -0500 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2022-12-29 12:23:16 -0500 |
commit | 7dca1a04452ca6caf6e230839c48f0f9dd9d67b8 (patch) | |
tree | 807b29089283f15a08cf809a1ff2e5984dd725f6 | |
parent | 18fbb21e6b95139a8890ba4a65f4402df128ac84 (diff) |
hover colors
-rw-r--r-- | colors.h | 7 | ||||
-rw-r--r-- | hover.c | 9 | ||||
-rw-r--r-- | main.c | 9 | ||||
-rw-r--r-- | ted.cfg | 4 | ||||
-rw-r--r-- | ted.h | 2 |
5 files changed, 25 insertions, 6 deletions
@@ -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"}, @@ -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); @@ -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. @@ -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 @@ -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; |