summaryrefslogtreecommitdiff
path: root/ide-highlights.c
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2023-08-05 15:25:02 -0400
committerpommicket <pommicket@gmail.com>2023-08-05 15:25:02 -0400
commitda966bf4cc547c784c1631451eb2febf5cf75b13 (patch)
tree6076fbf17ea23724a24c40cbf1cd777a4e1a004e /ide-highlights.c
parent4b10cb8f0892a720bd8d7f61b39f5faffc43107c (diff)
more internalization
Diffstat (limited to 'ide-highlights.c')
-rw-r--r--ide-highlights.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/ide-highlights.c b/ide-highlights.c
index a2d149f..ae79053 100644
--- a/ide-highlights.c
+++ b/ide-highlights.c
@@ -2,8 +2,24 @@
#include "ted.h"
+struct Highlights {
+ LSPServerRequestID last_request;
+ LSPDocumentPosition requested_position;
+ LSPHighlight *highlights;
+};
+
+void highlights_init(Ted *ted) {
+ ted->highlights = calloc(1, sizeof *ted->highlights);
+}
+
+void highlights_quit(Ted *ted) {
+ highlights_close(ted);
+ free(ted->highlights);
+ ted->highlights = NULL;
+}
+
void highlights_close(Ted *ted) {
- Highlights *hls = &ted->highlights;
+ Highlights *hls = ted->highlights;
arr_clear(hls->highlights);
ted_cancel_lsp_request(ted, &hls->last_request);
hls->requested_position = (LSPDocumentPosition){0};
@@ -11,7 +27,7 @@ void highlights_close(Ted *ted) {
static void highlights_send_request(Ted *ted) {
TextBuffer *buffer = ted->active_buffer;
- Highlights *hls = &ted->highlights;
+ Highlights *hls = ted->highlights;
if (!buffer) {
highlights_close(ted);
return;
@@ -32,7 +48,7 @@ static void highlights_send_request(Ted *ted) {
void highlights_process_lsp_response(Ted *ted, const LSPResponse *response) {
- Highlights *hls = &ted->highlights;
+ Highlights *hls = ted->highlights;
if (response->request.type != LSP_REQUEST_HIGHLIGHT)
return; // not a highlight request
if (response->request.id != hls->last_request.id)
@@ -45,7 +61,7 @@ void highlights_process_lsp_response(Ted *ted, const LSPResponse *response) {
}
void highlights_frame(Ted *ted) {
- Highlights *hls = &ted->highlights;
+ Highlights *hls = ted->highlights;
TextBuffer *buffer = ted->active_buffer;
if (!buffer) {
highlights_close(ted);