Compare commits

..

No commits in common. "f048f4a35fbb17878c0cb63d247e624aa6e4d17a" and "68585faa42a81949f0fd8028fb7932fe3f18a0e7" have entirely different histories.

View File

@ -43,11 +43,8 @@ typedef struct {
// GLOBALS // GLOBALS
vector_t token_table = { token_t * token_table[1000];
.data = NULL, int token_table_top = 0;
.element_size = sizeof(token_t *),
.element_count = 0UL
};
display_t * display_table = NULL; display_t * display_table = NULL;
@ -69,7 +66,7 @@ int free_token(token_t * token) {
} }
int append_token(token_t * token) { int append_token(token_t * token) {
vector_push(&token_table, token); token_table[token_table_top++] = token;
return 0; return 0;
} }
@ -201,10 +198,8 @@ void render_string(const char * const string,
int token_index = 0; int token_index = 0;
int offset; int offset;
for (; token_index < token_table.element_count; token_index++) { for (; token_index < token_table_top; token_index++) {
token_t * t = vector_get(&token_table, f = token_fits(token_table[token_index], string, s - string, &offset);
token_index);
f = token_fits(t, string, s - string, &offset);
if (f) { if (f) {
break; break;
} }
@ -217,17 +212,13 @@ void render_string(const char * const string,
// //
if (f) { if (f) {
for (int i = 0; i < offset; i++) { for (int i = 0; i < offset; i++) {
token_t * t = vector_get(&token_table,
token_index);
display->callback(s + i, display->callback(s + i,
0, 0,
t->hl->attributes); token_table[token_index]->hl->attributes);
} }
token_t * t = vector_get(&token_table,
token_index);
display->callback(s + offset, display->callback(s + offset,
f, f,
t->hl->attributes); token_table[token_index]->hl->attributes);
s += f + offset; s += f + offset;
} else { } else {
display->callback(s, display->callback(s,
@ -250,8 +241,8 @@ int hl_init(void) {
} }
int hl_deinit(void) { int hl_deinit(void) {
for (int i = 0; i < token_table.element_count; i++) { for (int i = 0; i < token_table_top; i++) {
free_token(vector_get(&token_table, i)); free_token(token_table[i]);
} }
return 0; return 0;