summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--find.c5
-rw-r--r--ide-document-link.c26
-rw-r--r--main.c3
-rw-r--r--ted.h18
4 files changed, 34 insertions, 18 deletions
diff --git a/find.c b/find.c
index 2abcd42..34bc354 100644
--- a/find.c
+++ b/find.c
@@ -4,7 +4,10 @@
#include "pcre-inc.h"
#define FIND_MAX_GROUPS 50
-
+struct FindResult {
+ BufferPos start;
+ BufferPos end;
+};
static u32 find_compilation_flags(Ted *ted) {
return (ted->find_case_sensitive ? 0 : PCRE2_CASELESS)
diff --git a/ide-document-link.c b/ide-document-link.c
index 7f5e476..9325c21 100644
--- a/ide-document-link.c
+++ b/ide-document-link.c
@@ -1,14 +1,30 @@
#include "ted.h"
+typedef struct DocumentLink DocumentLink;
struct DocumentLink {
char *target;
char *tooltip;
BufferPos start;
BufferPos end;
};
+struct DocumentLinks {
+ LSPDocumentID requested_document;
+ LSPServerRequestID last_request;
+ DocumentLink *links;
+};
+
+void document_link_init(Ted *ted) {
+ ted->document_links = calloc(1, sizeof *ted->document_links);
+}
+
+void document_link_quit(Ted *ted) {
+ document_link_clear(ted);
+ free(ted->document_links);
+ ted->document_links = NULL;
+}
void document_link_clear(Ted *ted) {
- DocumentLinks *dl = &ted->document_links;
+ DocumentLinks *dl = ted->document_links;
arr_foreach_ptr(dl->links, DocumentLink, l) {
free(l->target);
free(l->tooltip);
@@ -24,7 +40,7 @@ static bool document_link_activation_key_down(Ted *ted) {
static Rect document_link_get_rect(Ted *ted, DocumentLink *link) {
TextBuffer *buffer = ted->active_buffer;
- DocumentLinks *dl = &ted->document_links;
+ DocumentLinks *dl = ted->document_links;
if (buffer_lsp_document_id(buffer) != dl->requested_document) {
return (Rect){0};
}
@@ -57,7 +73,7 @@ void document_link_frame(Ted *ted) {
document_link_clear(ted);
return;
}
- DocumentLinks *dl = &ted->document_links;
+ DocumentLinks *dl = ted->document_links;
bool key_down = document_link_activation_key_down(ted);
if (!key_down) {
@@ -92,7 +108,7 @@ void document_link_frame(Ted *ted) {
}
void document_link_process_lsp_response(Ted *ted, const LSPResponse *response) {
- DocumentLinks *dl = &ted->document_links;
+ DocumentLinks *dl = ted->document_links;
if (response->request.type != LSP_REQUEST_DOCUMENT_LINK
|| response->request.id != dl->last_request.id)
return;
@@ -120,7 +136,7 @@ void document_link_process_lsp_response(Ted *ted, const LSPResponse *response) {
}
const char *document_link_at_buffer_pos(Ted *ted, BufferPos pos) {
- DocumentLinks *dl = &ted->document_links;
+ DocumentLinks *dl = ted->document_links;
TextBuffer *buffer = ted->active_buffer;
if (buffer_lsp_document_id(buffer) != dl->requested_document) {
return NULL;
diff --git a/main.c b/main.c
index 93d8a00..9dbb713 100644
--- a/main.c
+++ b/main.c
@@ -506,6 +506,7 @@ int main(int argc, char **argv) {
highlights_init(ted);
hover_init(ted);
rename_symbol_init(ted);
+ document_link_init(ted);
PROFILE_TIME(gl_end)
@@ -1195,7 +1196,7 @@ int main(int argc, char **argv) {
usages_quit(ted);
session_write(ted);
rename_symbol_quit(ted);
- document_link_clear(ted);
+ document_link_quit(ted);
for (int i = 0; i < TED_LSP_MAX; ++i) {
if (!ted->lsps[i]) break;
diff --git a/ted.h b/ted.h
index 6524a25..2e07c18 100644
--- a/ted.h
+++ b/ted.h
@@ -580,10 +580,7 @@ struct Node {
#define TED_MAX_STRINGS 1000
/// "find" menu result
-typedef struct {
- BufferPos start;
- BufferPos end;
-} FindResult;
+typedef struct FindResult FindResult;
typedef struct {
char *path;
@@ -620,14 +617,9 @@ typedef struct Usages Usages;
/// "signature help" (LSP) is thing that shows the current parameter, etc.
typedef struct SignatureHelp SignatureHelp;
-typedef struct DocumentLink DocumentLink;
/// "document link" information (LSP)
-typedef struct {
- LSPDocumentID requested_document;
- LSPServerRequestID last_request;
- DocumentLink *links;
-} DocumentLinks;
+typedef struct DocumentLinks DocumentLinks;
/// information for symbol rename (LSP)
typedef struct RenameSymbol RenameSymbol;
@@ -760,7 +752,7 @@ struct Ted {
bool building;
Autocomplete *autocomplete;
SignatureHelp *signature_help;
- DocumentLinks document_links;
+ DocumentLinks *document_links;
Hover *hover;
Definitions definitions;
Highlights *highlights;
@@ -1483,8 +1475,12 @@ void definitions_selector_close(Ted *ted);
void definitions_frame(Ted *ted);
// === ide-document-link.c ===
+#if !TED_PLUGIN
+void document_link_init(Ted *ted);
+void document_link_quit(Ted *ted);
void document_link_frame(Ted *ted);
void document_link_process_lsp_response(Ted *ted, const LSPResponse *response);
+#endif
/// get document link at this position in the active buffer.
///
/// the returned pointer won't be freed immediately, but could be on the next frame,