Compare commits

...

2 Commits

2 changed files with 42 additions and 45 deletions

View File

@ -28,15 +28,15 @@ enum{
struct Code_Index_Nest{ struct Code_Index_Nest{
Code_Index_Nest *next; Code_Index_Nest *next;
Code_Index_Nest_Kind kind; Code_Index_Nest_Kind kind;
b32 is_closed; b32 is_closed;
Range_i64 open; Range_i64 open;
Range_i64 close; Range_i64 close;
struct Code_Index_File *file; struct Code_Index_File *file;
Code_Index_Nest *parent; Code_Index_Nest *parent;
Code_Index_Nest_List nest_list; Code_Index_Nest_List nest_list;
Code_Index_Nest_Ptr_Array nest_array; Code_Index_Nest_Ptr_Array nest_array;
}; };
@ -56,7 +56,7 @@ struct Code_Index_Note{
String_Const_u8 text; String_Const_u8 text;
struct Code_Index_File *file; struct Code_Index_File *file;
Code_Index_Nest *parent; Code_Index_Nest *parent;
Code_Index_Note *prev_in_hash; Code_Index_Note *prev_in_hash;
Code_Index_Note *next_in_hash; Code_Index_Note *next_in_hash;
}; };
@ -95,8 +95,8 @@ struct Code_Index{
Code_Index_File_Storage *storage_first; Code_Index_File_Storage *storage_first;
Code_Index_File_Storage *storage_last; Code_Index_File_Storage *storage_last;
i32 storage_count; i32 storage_count;
Code_Index_Note_List name_hash[4099]; Code_Index_Note_List name_hash[10000];
}; };
//////////////////////////////// ////////////////////////////////
@ -112,12 +112,12 @@ struct Generic_Parse_State{
Generic_Parse_Comment_Function *handle_comment; Generic_Parse_Comment_Function *handle_comment;
u8 *prev_line_start; u8 *prev_line_start;
b32 finished; b32 finished;
i32 scope_counter; i32 scope_counter;
i32 paren_counter; i32 paren_counter;
b32 in_preprocessor; b32 in_preprocessor;
b32 in_statement; b32 in_statement;
b32 do_cpp_parse; b32 do_cpp_parse;
}; };

View File

@ -325,6 +325,13 @@ default_render_buffer(Application_Links *app, View_ID view_id, Face_ID face_id,
f32 mark_thickness = (f32)def_get_config_u64(app, vars_save_string_lit("mark_thickness")); f32 mark_thickness = (f32)def_get_config_u64(app, vars_save_string_lit("mark_thickness"));
// NOTE(allen): Token colorizing // NOTE(allen): Token colorizing
ARGB_Color color_default = fcolor_resolve(fcolor_id(defcolor_text_default));
ARGB_Color color_function = fcolor_resolve(fcolor_id(defcolor_function));
ARGB_Color color_operator = fcolor_resolve(fcolor_id(defcolor_operator));
ARGB_Color color_type = fcolor_resolve(fcolor_id(defcolor_type));
ARGB_Color color_macro = fcolor_resolve(fcolor_id(defcolor_macro));
Token_Array token_array = get_token_array_from_buffer(app, buffer); Token_Array token_array = get_token_array_from_buffer(app, buffer);
if (token_array.tokens != 0){ if (token_array.tokens != 0){
draw_cpp_token_colors(app, text_layout_id, &token_array); draw_cpp_token_colors(app, text_layout_id, &token_array);
@ -342,56 +349,46 @@ default_render_buffer(Application_Links *app, View_ID view_id, Face_ID face_id,
// NOTE(allen): Color functions // NOTE(allen): Color functions
Scratch_Block scratch(app); Scratch_Block scratch(app);
ARGB_Color color_function = fcolor_resolve(fcolor_id(defcolor_function));
ARGB_Color color_operator = fcolor_resolve(fcolor_id(defcolor_operator));
ARGB_Color color_type = fcolor_resolve(fcolor_id(defcolor_type));
ARGB_Color color_macro = fcolor_resolve(fcolor_id(defcolor_macro));
Token_Iterator_Array it = token_iterator_pos(0, &token_array, visible_range.first); Token_Iterator_Array it = token_iterator_pos(0, &token_array, visible_range.first);
it.count = Min(it.count, visible_range.one_past_last - visible_range.first);
for (;;){ for (;;){
if (!token_it_inc_non_whitespace(&it)){ if (!token_it_inc_non_whitespace(&it)){
break; break;
} }
ARGB_Color token_color = color_default;
Token *token = token_it_read(&it); Token *token = token_it_read(&it);
String_Const_u8 lexeme = push_token_lexeme(app, scratch, buffer, token); if (token->kind == TokenBaseKind_Operator ||
Code_Index_Note *note = code_index_note_from_string(lexeme);
if (note != 0)
{
switch (note->note_kind)
{
case CodeIndexNote_Type:
{
paint_text_color(app, text_layout_id, Ii64_size(token->pos, token->size), color_type);
} break;
case CodeIndexNote_Function:
{
paint_text_color(app, text_layout_id, Ii64_size(token->pos, token->size), color_function);
} break;
case CodeIndexNote_Macro:
{
paint_text_color(app, text_layout_id, Ii64_size(token->pos, token->size), color_macro);
} break;
default: {} break;
}
}
else if (token->kind == TokenBaseKind_Operator ||
token->kind == TokenBaseKind_ScopeOpen || token->kind == TokenBaseKind_ScopeOpen ||
token->kind == TokenBaseKind_ScopeClose || token->kind == TokenBaseKind_ScopeClose ||
token->kind == TokenBaseKind_ParentheticalOpen || token->kind == TokenBaseKind_ParentheticalOpen ||
token->kind == TokenBaseKind_ParentheticalClose || token->kind == TokenBaseKind_ParentheticalClose ||
token->kind == TokenBaseKind_StatementClose) token->kind == TokenBaseKind_StatementClose)
{ {
paint_text_color(app, text_layout_id, Ii64_size(token->pos, token->size), color_operator); token_color = color_operator;
} }
} else
} {
else{ String_Const_u8 lexeme = push_token_lexeme(app, scratch, buffer, token);
paint_text_color_fcolor(app, text_layout_id, visible_range, fcolor_id(defcolor_text_default)); Code_Index_Note *note = code_index_note_from_string(lexeme);
} if (note != 0)
{
switch (note->note_kind)
{
case CodeIndexNote_Type: token_color = color_type; break;
case CodeIndexNote_Function: token_color = color_function; break;
case CodeIndexNote_Macro: token_color = color_macro; break;
default: {} break;
}
}
}
paint_text_color(app, text_layout_id, Ii64_size(token->pos, token->size), token_color);
}
}
else
{
paint_text_color(app, text_layout_id, visible_range, color_default);
}
i64 cursor_pos = view_correct_cursor(app, view_id); i64 cursor_pos = view_correct_cursor(app, view_id);
view_correct_mark(app, view_id); view_correct_mark(app, view_id);