diff options
author | pommicket <pommicket@gmail.com> | 2022-12-22 22:36:27 -0500 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2022-12-22 22:36:27 -0500 |
commit | 266af5ed551765ca22cb90819f570ff9371e279b (patch) | |
tree | b7933241354696fc11a9997b488973614f5f4df1 | |
parent | ed6661d4b0bd10d15796a3053da00eddace1f881 (diff) |
even better-looking autocomplete
-rw-r--r-- | autocomplete.c | 17 | ||||
-rw-r--r-- | colors.c | 5 | ||||
-rw-r--r-- | colors.h | 8 | ||||
-rw-r--r-- | ted.cfg | 6 |
4 files changed, 28 insertions, 8 deletions
diff --git a/autocomplete.c b/autocomplete.c index 930cd90..db7a045 100644 --- a/autocomplete.c +++ b/autocomplete.c @@ -231,7 +231,7 @@ static void autocomplete_frame(Ted *ted) { break; } - float menu_width = 400, menu_height = (float)ncompletions * char_height + 2 * padding; + float menu_width = 400, menu_height = (float)ncompletions * char_height; if (ac->waiting_for_lsp) { menu_height = 200.f; @@ -256,8 +256,8 @@ static void autocomplete_frame(Ted *ted) { start_y += char_height; // put menu below cursor { Rect menu_rect = rect(V2(x, start_y), V2(menu_width, menu_height)); - gl_geometry_rect(menu_rect, colors[COLOR_MENU_BG]); - //gl_geometry_rect_border(menu_rect, 1, colors[COLOR_BORDER]); + gl_geometry_rect(menu_rect, colors[COLOR_AUTOCOMPLETE_BG]); + gl_geometry_rect_border(menu_rect, 1, colors[COLOR_AUTOCOMPLETE_BORDER]); ac->rect = menu_rect; } @@ -300,11 +300,16 @@ static void autocomplete_frame(Ted *ted) { for (size_t i = 0; i < ncompletions; ++i) { state.x = x; state.y = y; - gl_geometry_rect(rect(V2(x, y + char_height), - V2(menu_width, border_thickness)), - colors[COLOR_AUTOCOMPLETE_BORDER]); + if (i != ncompletions-1) { + gl_geometry_rect(rect(V2(x, y + char_height), + V2(menu_width, border_thickness)), + colors[COLOR_AUTOCOMPLETE_BORDER]); + } ColorSetting label_color = color_for_symbol_kind(completions[i].kind); + if (!settings->syntax_highlighting) + label_color = COLOR_TEXT; + rgba_u32_to_floats(colors[label_color], state.color); // draw icon @@ -57,10 +57,13 @@ static ColorSetting color_for_symbol_kind(SymbolKind kind) { case SYMBOL_CONSTANT: return COLOR_CONSTANT; case SYMBOL_TYPE: + return COLOR_AUTOCOMPLETE_TYPE; case SYMBOL_FIELD: case SYMBOL_VARIABLE: - case SYMBOL_OTHER: + return COLOR_AUTOCOMPLETE_VARIABLE; case SYMBOL_FUNCTION: + return COLOR_AUTOCOMPLETE_FUNCTION; + case SYMBOL_OTHER: return COLOR_TEXT; case SYMBOL_KEYWORD: return COLOR_KEYWORD; @@ -25,7 +25,11 @@ typedef enum { COLOR_SELECTED_TAB_HL, COLOR_FIND_HL, + COLOR_AUTOCOMPLETE_BG, COLOR_AUTOCOMPLETE_BORDER, + COLOR_AUTOCOMPLETE_FUNCTION, + COLOR_AUTOCOMPLETE_VARIABLE, + COLOR_AUTOCOMPLETE_TYPE, COLOR_YES, COLOR_NO, @@ -84,7 +88,11 @@ static ColorName const color_names[] = { {COLOR_STRING, "string"}, {COLOR_CHARACTER, "character"}, {COLOR_CONSTANT, "constant"}, + {COLOR_AUTOCOMPLETE_BG, "autocomplete-bg"}, {COLOR_AUTOCOMPLETE_BORDER, "autocomplete-border"}, + {COLOR_AUTOCOMPLETE_VARIABLE, "autocomplete-variable"}, + {COLOR_AUTOCOMPLETE_FUNCTION, "autocomplete-function"}, + {COLOR_AUTOCOMPLETE_TYPE, "autocomplete-type"}, {COLOR_YES, "yes"}, {COLOR_NO, "no"}, {COLOR_CANCEL, "cancel"}, @@ -234,7 +234,11 @@ no = #faa cancel = #ffa # autocomplete -autocomplete-border = #777 +autocomplete-bg = #000 +autocomplete-border = #fff +autocomplete-variable = #bfb +autocomplete-function = #aaf +autocomplete-type = #fac # Syntax highlighting keyword = #0c0 |