diff options
author | pommicket <pommicket@gmail.com> | 2023-08-05 15:08:45 -0400 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2023-08-05 15:08:45 -0400 |
commit | 4b10cb8f0892a720bd8d7f61b39f5faffc43107c (patch) | |
tree | 0c28195572231c93c11fa3d6b625ea0dc0328ce9 /ide-signature-help.c | |
parent | b65943698a241624973f3ab54530bb5d5884cff2 (diff) |
internalize signature help, usages
Diffstat (limited to 'ide-signature-help.c')
-rw-r--r-- | ide-signature-help.c | 41 |
1 files changed, 35 insertions, 6 deletions
diff --git a/ide-signature-help.c b/ide-signature-help.c index 87eef7d..a18eea0 100644 --- a/ide-signature-help.c +++ b/ide-signature-help.c @@ -3,6 +3,29 @@ #include "ted.h" +/// a single signature in the signature help. +typedef struct { + /// displayed normal + char *label_pre; + /// displayed bold + char *label_active; + /// displayed normal + char *label_post; +} Signature; + +struct SignatureHelp { + LSPServerRequestID last_request; + /// should we resend a signature help request this frame? + bool retrigger; + /// if signature_count = 0, signature help is closed + u16 signature_count; + Signature signatures[SIGNATURE_HELP_MAX]; +}; + +void signature_help_init(Ted *ted) { + ted->signature_help = calloc(1, sizeof *ted->signature_help); +} + static void signature_help_clear(SignatureHelp *help) { for (int i = 0; i < help->signature_count; ++i) { Signature sig = help->signatures[i]; @@ -15,7 +38,7 @@ static void signature_help_clear(SignatureHelp *help) { } static void signature_help_send_request(Ted *ted) { - SignatureHelp *help = &ted->signature_help; + SignatureHelp *help = ted->signature_help; Settings *settings = ted_active_settings(ted); if (!settings->signature_help_enabled) { signature_help_clear(help); @@ -42,7 +65,7 @@ static void signature_help_send_request(Ted *ted) { void signature_help_retrigger(Ted *ted) { // don't just send the request here -- we don't want to send more than // one request per frame. - ted->signature_help.retrigger = true; + ted->signature_help->retrigger = true; } void signature_help_open(Ted *ted, uint32_t trigger) { @@ -51,18 +74,18 @@ void signature_help_open(Ted *ted, uint32_t trigger) { } bool signature_help_is_open(Ted *ted) { - return ted->signature_help.signature_count > 0; + return ted->signature_help->signature_count > 0; } void signature_help_close(Ted *ted) { - SignatureHelp *help = &ted->signature_help; + SignatureHelp *help = ted->signature_help; signature_help_clear(help); ted_cancel_lsp_request(ted, &help->last_request); } void signature_help_process_lsp_response(Ted *ted, const LSPResponse *response) { - SignatureHelp *help = &ted->signature_help; + SignatureHelp *help = ted->signature_help; Settings *settings = ted_active_settings(ted); if (!settings->signature_help_enabled) return; @@ -110,7 +133,7 @@ void signature_help_frame(Ted *ted) { if (!settings->signature_help_enabled) return; - SignatureHelp *help = &ted->signature_help; + SignatureHelp *help = ted->signature_help; if (help->retrigger) signature_help_send_request(ted); u16 signature_count = help->signature_count; @@ -164,3 +187,9 @@ void signature_help_frame(Ted *ted) { text_render(font); text_render(font_bold); } + +void signature_help_quit(Ted *ted) { + signature_help_close(ted); + free(ted->signature_help); + ted->signature_help = NULL; +} |