Compare commits

..

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

View File

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