New text coloring system setup
This commit is contained in:
parent
2e0992fdd3
commit
1f81120343
|
@ -557,7 +557,7 @@ default_buffer_render_caller(Application_Links *app, Frame_Info frame_info, View
|
||||||
{
|
{
|
||||||
if (is_active_view){
|
if (is_active_view){
|
||||||
draw_character_block(app, text_layout_id, cursor_pos, Stag_Cursor);
|
draw_character_block(app, text_layout_id, cursor_pos, Stag_Cursor);
|
||||||
paint_text_color(app, text_layout_id, make_range_i64(cursor_pos), Stag_At_Cursor);
|
paint_text_color(app, text_layout_id, cursor_pos, Stag_At_Cursor);
|
||||||
draw_character_wire_frame(app, text_layout_id, mark_pos, Stag_Mark);
|
draw_character_wire_frame(app, text_layout_id, mark_pos, Stag_Mark);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
@ -596,7 +596,7 @@ default_buffer_render_caller(Application_Links *app, Frame_Info frame_info, View
|
||||||
}
|
}
|
||||||
draw_enclosures(app, text_layout_id, buffer,
|
draw_enclosures(app, text_layout_id, buffer,
|
||||||
cursor_pos, FindScope_Paren, RangeHighlightKind_CharacterHighlight,
|
cursor_pos, FindScope_Paren, RangeHighlightKind_CharacterHighlight,
|
||||||
colors, 0, color_count);
|
0, colors, color_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
draw_clip_push(app, buffer_rect);
|
draw_clip_push(app, buffer_rect);
|
||||||
|
|
|
@ -3908,7 +3908,18 @@ Text_Layout_Character_On_Screen(Application_Links *app, Text_Layout_ID layout_id
|
||||||
|
|
||||||
API_EXPORT void
|
API_EXPORT void
|
||||||
Paint_Text_Color(Application_Links *app, Text_Layout_ID layout_id, Range_i64 range, int_color color){
|
Paint_Text_Color(Application_Links *app, Text_Layout_ID layout_id, Range_i64 range, int_color color){
|
||||||
//NotImplemented;
|
Models *models = (Models*)app->cmd_context;
|
||||||
|
Text_Layout layout = {};
|
||||||
|
Rect_f32 result = {};
|
||||||
|
if (text_layout_get(&models->text_layouts, layout_id, &layout)){
|
||||||
|
range.min = clamp_bot(layout.on_screen_range.min, range.min);
|
||||||
|
range.max = clamp_top(range.max, layout.on_screen_range.max);
|
||||||
|
range.min -= layout.on_screen_range.min;
|
||||||
|
range.max -= layout.on_screen_range.min;
|
||||||
|
for (i64 i = range.min; i < range.max; i += 1){
|
||||||
|
layout.item_colors[i] = color;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
API_EXPORT b32
|
API_EXPORT b32
|
||||||
|
@ -3944,7 +3955,7 @@ Compute_Render_Layout(Application_Links *app, View_ID view_id, Buffer_ID buffer_
|
||||||
linalloc_clear(&view->layout_arena);
|
linalloc_clear(&view->layout_arena);
|
||||||
}
|
}
|
||||||
Buffer_Render_Item *items = push_array(&view->layout_arena, Buffer_Render_Item, max);
|
Buffer_Render_Item *items = push_array(&view->layout_arena, Buffer_Render_Item, max);
|
||||||
|
|
||||||
b32 wrapped = (!file->settings.unwrapped_lines);
|
b32 wrapped = (!file->settings.unwrapped_lines);
|
||||||
|
|
||||||
Full_Cursor intermediate_cursor = file_compute_cursor(models, file, seek_line_char(buffer_point.line_number, 1));
|
Full_Cursor intermediate_cursor = file_compute_cursor(models, file, seek_line_char(buffer_point.line_number, 1));
|
||||||
|
@ -4030,12 +4041,14 @@ Compute_Render_Layout(Application_Links *app, View_ID view_id, Buffer_ID buffer_
|
||||||
Range range = Ii32((i32)render_cursor.pos, (i32)end_pos);
|
Range range = Ii32((i32)render_cursor.pos, (i32)end_pos);
|
||||||
|
|
||||||
// TODO(allen):
|
// TODO(allen):
|
||||||
|
int_color *item_colors = push_array_zero(&view->layout_arena, int_color, range.max - range.min);
|
||||||
view->render.view_rect = view->panel->rect_inner;
|
view->render.view_rect = view->panel->rect_inner;
|
||||||
view->render.buffer_rect = i32R(f32R(screen_p.x, screen_p.y,
|
view->render.buffer_rect = i32R(f32R(screen_p.x, screen_p.y,
|
||||||
screen_p.x + layout_dim.x, screen_p.y + layout_dim.y));
|
screen_p.x + layout_dim.x, screen_p.y + layout_dim.y));
|
||||||
view->render.cursor = render_cursor;
|
view->render.cursor = render_cursor;
|
||||||
view->render.range = range;
|
view->render.range = range;
|
||||||
view->render.items = items;
|
view->render.items = items;
|
||||||
|
view->render.item_colors = item_colors;
|
||||||
view->render.item_count = item_count;
|
view->render.item_count = item_count;
|
||||||
|
|
||||||
f32 height = 0.f;
|
f32 height = 0.f;
|
||||||
|
@ -4048,7 +4061,7 @@ Compute_Render_Layout(Application_Links *app, View_ID view_id, Buffer_ID buffer_
|
||||||
coordinates.on_screen_p0 = screen_p;
|
coordinates.on_screen_p0 = screen_p;
|
||||||
coordinates.in_buffer_p0 = in_buffer_p;
|
coordinates.in_buffer_p0 = in_buffer_p;
|
||||||
coordinates.dim = layout_dim;
|
coordinates.dim = layout_dim;
|
||||||
result = text_layout_new(&models->mem.heap, &models->text_layouts, buffer_id, buffer_point, range, height, coordinates);
|
result = text_layout_new(&models->mem.heap, &models->text_layouts, buffer_id, buffer_point, range, height, coordinates, item_colors);
|
||||||
}
|
}
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
@ -4060,7 +4073,9 @@ Draw_Render_Layout(Application_Links *app, View_ID view_id){
|
||||||
if (api_check_view(view) && models->target != 0){
|
if (api_check_view(view) && models->target != 0){
|
||||||
render_loaded_file_in_view__inner(models, models->target, view, view->render.buffer_rect,
|
render_loaded_file_in_view__inner(models, models->target, view, view->render.buffer_rect,
|
||||||
view->render.cursor, view->render.range,
|
view->render.cursor, view->render.range,
|
||||||
view->render.items, view->render.item_count);
|
view->render.items,
|
||||||
|
view->render.item_colors,
|
||||||
|
view->render.item_count);
|
||||||
linalloc_clear(&view->layout_arena);
|
linalloc_clear(&view->layout_arena);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,13 +29,14 @@ text_layout_new__alloc_layout(Text_Layout_Container *container){
|
||||||
}
|
}
|
||||||
|
|
||||||
internal Text_Layout_ID
|
internal Text_Layout_ID
|
||||||
text_layout_new(Heap *heap, Text_Layout_Container *container, Buffer_ID buffer_id, Buffer_Point point, Range on_screen_range, f32 height, Text_Layout_Coordinates coordinates){
|
text_layout_new(Heap *heap, Text_Layout_Container *container, Buffer_ID buffer_id, Buffer_Point point, Range on_screen_range, f32 height, Text_Layout_Coordinates coordinates, int_color *item_colors){
|
||||||
Text_Layout *new_layout_data = text_layout_new__alloc_layout(container);
|
Text_Layout *new_layout_data = text_layout_new__alloc_layout(container);
|
||||||
new_layout_data->buffer_id = buffer_id;
|
new_layout_data->buffer_id = buffer_id;
|
||||||
new_layout_data->point = point;
|
new_layout_data->point = point;
|
||||||
new_layout_data->on_screen_range = on_screen_range;
|
new_layout_data->on_screen_range = on_screen_range;
|
||||||
new_layout_data->height = height;
|
new_layout_data->height = height;
|
||||||
new_layout_data->coordinates = coordinates;
|
new_layout_data->coordinates = coordinates;
|
||||||
|
new_layout_data->item_colors = item_colors;
|
||||||
Text_Layout_ID new_id = ++container->id_counter;
|
Text_Layout_ID new_id = ++container->id_counter;
|
||||||
insert_u32_Ptr_table(heap, &container->table, new_id, new_layout_data);
|
insert_u32_Ptr_table(heap, &container->table, new_id, new_layout_data);
|
||||||
return(new_id);
|
return(new_id);
|
||||||
|
|
|
@ -26,6 +26,7 @@ struct Text_Layout{
|
||||||
f32 height;
|
f32 height;
|
||||||
|
|
||||||
Text_Layout_Coordinates coordinates;
|
Text_Layout_Coordinates coordinates;
|
||||||
|
int_color *item_colors;
|
||||||
};
|
};
|
||||||
|
|
||||||
union Text_Layout_Node{
|
union Text_Layout_Node{
|
||||||
|
|
16
4ed_view.cpp
16
4ed_view.cpp
|
@ -790,8 +790,8 @@ render__get_brush_from_range_stack(Render_Range_Record *stack, i32 stack_top){
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
render_loaded_file_in_view__inner(Models *models, Render_Target *target, View *view,
|
render_loaded_file_in_view__inner(Models *models, Render_Target *target, View *view,
|
||||||
i32_Rect rect, Full_Cursor render_cursor, Range on_screen_range,
|
Rect_i32 rect, Full_Cursor render_cursor, Range on_screen_range,
|
||||||
Buffer_Render_Item *items, i32 item_count){
|
Buffer_Render_Item *items, int_color *item_colors, i32 item_count){
|
||||||
Editing_File *file = view->file;
|
Editing_File *file = view->file;
|
||||||
Arena *scratch = &models->mem.arena;
|
Arena *scratch = &models->mem.arena;
|
||||||
Color_Table color_table = models->color_table;
|
Color_Table color_table = models->color_table;
|
||||||
|
@ -929,7 +929,7 @@ render_loaded_file_in_view__inner(Models *models, Render_Target *target, View *v
|
||||||
i32 prev_ind = -1;
|
i32 prev_ind = -1;
|
||||||
u32 highlight_color = 0;
|
u32 highlight_color = 0;
|
||||||
|
|
||||||
for (; item < item_end; ++item){
|
for (i32 i = 0; item < item_end; item += 1, i += 1){
|
||||||
i32 ind = item->index;
|
i32 ind = item->index;
|
||||||
|
|
||||||
// NOTE(allen): Line scanning
|
// NOTE(allen): Line scanning
|
||||||
|
@ -998,10 +998,16 @@ render_loaded_file_in_view__inner(Models *models, Render_Target *target, View *v
|
||||||
Rect_f32 char_rect = f32R(item->x0, item->y0, item->x1, item->y1);
|
Rect_f32 char_rect = f32R(item->x0, item->y0, item->x1, item->y1);
|
||||||
|
|
||||||
u32 char_color = main_color;
|
u32 char_color = main_color;
|
||||||
if (item->flags & BRFlag_Special_Character){
|
if (on_screen_range.min <= ind && ind < on_screen_range.max){
|
||||||
|
i32 index_shifted = ind - on_screen_range.min;
|
||||||
|
if (item_colors[index_shifted] != 0){
|
||||||
|
char_color = finalize_color(color_table, item_colors[index_shifted]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (HasFlag(item->flags, BRFlag_Special_Character)){
|
||||||
char_color = special_color;
|
char_color = special_color;
|
||||||
}
|
}
|
||||||
else if (item->flags & BRFlag_Ghost_Character){
|
else if (HasFlag(item->flags, BRFlag_Ghost_Character)){
|
||||||
char_color = ghost_color;
|
char_color = ghost_color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,7 @@ struct View{
|
||||||
Full_Cursor cursor;
|
Full_Cursor cursor;
|
||||||
Range range;
|
Range range;
|
||||||
Buffer_Render_Item *items;
|
Buffer_Render_Item *items;
|
||||||
|
int_color *item_colors;
|
||||||
i32 item_count;
|
i32 item_count;
|
||||||
} render;
|
} render;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue