update stuff

This commit is contained in:
alessandro bason 2025-06-15 11:32:55 +02:00
parent 6d36aa4442
commit 95d74c2ef4
13 changed files with 1196 additions and 48 deletions

49
highlight.h Normal file
View file

@ -0,0 +1,49 @@
#pragma once
#include "str.h"
typedef enum {
HL_COLOR_NORMAL,
HL_COLOR_PREPROC,
HL_COLOR_TYPES,
HL_COLOR_CUSTOM_TYPES,
HL_COLOR_KEYWORDS,
HL_COLOR_NUMBER,
HL_COLOR_STRING,
HL_COLOR_COMMENT,
HL_COLOR_FUNC,
HL_COLOR_SYMBOL,
HL_COLOR_MACRO,
HL_COLOR__COUNT,
} hl_color_e;
typedef enum {
HL_FLAG_NONE = 0,
HL_FLAG_HTML = 1 << 0,
} hl_flags_e;
typedef struct {
strview_t keyword;
hl_color_e color;
} hl_keyword_t;
typedef struct {
usize idx;
usize size;
} hl_line_t;
typedef struct {
strview_t colors[HL_COLOR__COUNT];
hl_keyword_t *extra_kwrds;
int kwrds_count;
hl_flags_e flags;
} hl_config_t;
typedef struct hl_ctx_t hl_ctx_t;
hl_ctx_t *hl_init(arena_t *arena, hl_config_t *config);
str_t hl_highlight(arena_t *arena, hl_ctx_t *ctx, strview_t str);
void hl_set_symbol_in_table(hl_ctx_t *ctx, char symbol, bool value);
void hl_add_keyword(arena_t *arena, hl_ctx_t *ctx, hl_keyword_t *keyword);