diff options
author | pommicket <pommicket@gmail.com> | 2022-12-29 18:44:37 -0500 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2022-12-29 18:44:37 -0500 |
commit | d77782564bf0a090a4e7fa4f4c4bb685383275dc (patch) | |
tree | a4bc3c0bf142c663ea7f293b4381927adc896f1c /ted.c | |
parent | 5f7af06a9085835a3d1ad3a51374c245859d7d97 (diff) |
textDocument/definition for ctrl+click
Diffstat (limited to 'ted.c')
-rw-r--r-- | ted.c | 33 |
1 files changed, 33 insertions, 0 deletions
@@ -507,3 +507,36 @@ void ted_press_key(Ted *ted, SDL_Scancode scancode, SDL_Keymod modifier) { } } } + +// make the cursor red for a bit to indicate an error (e.g. no autocompletions) +void ted_flash_error_cursor(Ted *ted) { + ted->cursor_error_time = time_get_seconds(); +} + +void ted_go_to_position(Ted *ted, const char *path, u32 line, u32 index, bool is_lsp) { + if (ted_open_file(ted, path)) { + TextBuffer *buffer = ted->active_buffer; + BufferPos pos = {0}; + if (is_lsp) { + LSPPosition lsp_pos = { + .line = line, + .character = index + }; + pos = buffer_pos_from_lsp(buffer, lsp_pos); + } else { + pos.line = line; + pos.index = index; + } + buffer_cursor_move_to_pos(buffer, pos); + buffer->center_cursor_next_frame = true; + } else { + ted_flash_error_cursor(ted); + } +} + +void ted_go_to_lsp_document_position(Ted *ted, LSP *lsp, LSPDocumentPosition position) { + const char *path = lsp_document_path(lsp, position.document); + u32 line = position.pos.line; + u32 character = position.pos.character; + ted_go_to_position(ted, path, line, character, true); +} |