New UI system up and running
This commit is contained in:
parent
c8a4b7e20a
commit
e307b67f4e
17
4ed.cpp
17
4ed.cpp
|
@ -339,6 +339,7 @@ App_Init_Sig(app_init){
|
||||||
// NOTE(allen): live set
|
// NOTE(allen): live set
|
||||||
Arena *arena = models->arena;
|
Arena *arena = models->arena;
|
||||||
{
|
{
|
||||||
|
models->live_set.node_arena = reserve_arena(models->tctx);
|
||||||
models->live_set.count = 0;
|
models->live_set.count = 0;
|
||||||
models->live_set.max = MAX_VIEWS;
|
models->live_set.max = MAX_VIEWS;
|
||||||
models->live_set.views = push_array(arena, View, models->live_set.max);
|
models->live_set.views = push_array(arena, View, models->live_set.max);
|
||||||
|
@ -848,8 +849,20 @@ App_Step_Sig(app_step){
|
||||||
begin_render_section(target, models->frame_counter, literal_dt, animation_dt);
|
begin_render_section(target, models->frame_counter, literal_dt, animation_dt);
|
||||||
models->in_render_mode = true;
|
models->in_render_mode = true;
|
||||||
|
|
||||||
if (models->render_caller != 0){
|
Live_Views *live_views = &models->live_set;
|
||||||
models->render_caller(&models->app_links, frame);
|
Layout *layout = &models->layout;
|
||||||
|
for (Node *node = layout->open_panels.next;
|
||||||
|
node != &layout->open_panels;
|
||||||
|
node = node->next){
|
||||||
|
Panel *panel = CastFromMember(Panel, node, node);
|
||||||
|
View *view = panel->view;
|
||||||
|
View_Context_Node *ctx = view->ctx;
|
||||||
|
if (ctx != 0){
|
||||||
|
Render_Caller_Function *render_caller = ctx->ctx.render_caller;
|
||||||
|
if (render_caller != 0){
|
||||||
|
render_caller(&models->app_links, frame, view_get_id(live_views, view));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
models->in_render_mode = false;
|
models->in_render_mode = false;
|
||||||
|
|
95
4ed_view.cpp
95
4ed_view.cpp
|
@ -445,6 +445,51 @@ view_set_file(Models *models, View *view, Editing_File *file){
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
|
||||||
|
function View_Context_Node*
|
||||||
|
view__alloc_context_node(Live_Views *views){
|
||||||
|
View_Context_Node *node = views->free_nodes;
|
||||||
|
if (node != 0){
|
||||||
|
sll_stack_pop(views->free_nodes);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
node = push_array(views->node_arena, View_Context_Node, 1);
|
||||||
|
}
|
||||||
|
return(node);
|
||||||
|
}
|
||||||
|
|
||||||
|
function void
|
||||||
|
view__free_context_node(Live_Views *views, View_Context_Node *node){
|
||||||
|
sll_stack_push(views->free_nodes, node);
|
||||||
|
}
|
||||||
|
|
||||||
|
function void
|
||||||
|
view_push_context(Models *models, View *view, View_Context *ctx){
|
||||||
|
View_Context_Node *node = view__alloc_context_node(&models->live_set);
|
||||||
|
sll_stack_push(view->ctx, node);
|
||||||
|
block_copy_struct(&node->ctx, ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
function void
|
||||||
|
view_pop_context(Models *models, View *view){
|
||||||
|
View_Context_Node *node = view->ctx;
|
||||||
|
if (node != 0){
|
||||||
|
sll_stack_pop(view->ctx);
|
||||||
|
view__free_context_node(&models->live_set, node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function View_Context
|
||||||
|
view_current_context(Models *models, View *view){
|
||||||
|
View_Context ctx = {};
|
||||||
|
View_Context_Node *node = view->ctx;
|
||||||
|
if (node != 0){
|
||||||
|
block_copy_struct(&ctx, &node->ctx);
|
||||||
|
}
|
||||||
|
return(ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
|
||||||
internal App_Coroutine_State
|
internal App_Coroutine_State
|
||||||
get_co_state(Application_Links *app){
|
get_co_state(Application_Links *app){
|
||||||
App_Coroutine_State state = {};
|
App_Coroutine_State state = {};
|
||||||
|
@ -512,6 +557,11 @@ function void
|
||||||
view_init(Models *models, View *view, Editing_File *initial_buffer,
|
view_init(Models *models, View *view, Editing_File *initial_buffer,
|
||||||
Custom_Command_Function *event_context_base){
|
Custom_Command_Function *event_context_base){
|
||||||
view_set_file(models, view, initial_buffer);
|
view_set_file(models, view, initial_buffer);
|
||||||
|
|
||||||
|
View_Context first_ctx = {};
|
||||||
|
first_ctx.render_caller = models->render_caller;
|
||||||
|
view_push_context(models, view, &first_ctx);
|
||||||
|
|
||||||
view->co = coroutine_create(&models->coroutines, view_event_context_base__inner);
|
view->co = coroutine_create(&models->coroutines, view_event_context_base__inner);
|
||||||
Co_In in = {};
|
Co_In in = {};
|
||||||
in.models = models;
|
in.models = models;
|
||||||
|
@ -607,51 +657,6 @@ co_send_core_event(Models *models, View *view, Core_Code code){
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
|
||||||
function View_Context_Node*
|
|
||||||
view__alloc_context_node(Live_Views *views){
|
|
||||||
View_Context_Node *node = views->free_nodes;
|
|
||||||
if (node != 0){
|
|
||||||
sll_stack_pop(views->free_nodes);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
node = push_array(views->node_arena, View_Context_Node, 1);
|
|
||||||
}
|
|
||||||
return(node);
|
|
||||||
}
|
|
||||||
|
|
||||||
function void
|
|
||||||
view__free_context_node(Live_Views *views, View_Context_Node *node){
|
|
||||||
sll_stack_push(views->free_nodes, node);
|
|
||||||
}
|
|
||||||
|
|
||||||
function void
|
|
||||||
view_push_context(Models *models, View *view, View_Context *ctx){
|
|
||||||
View_Context_Node *node = view__alloc_context_node(&models->live_set);
|
|
||||||
sll_stack_push(view->ctx, node);
|
|
||||||
block_copy_struct(&node->ctx, ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
function void
|
|
||||||
view_pop_context(Models *models, View *view){
|
|
||||||
View_Context_Node *node = view->ctx;
|
|
||||||
if (node != 0){
|
|
||||||
sll_stack_pop(view->ctx);
|
|
||||||
view__free_context_node(&models->live_set, node);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function View_Context
|
|
||||||
view_current_context(Models *models, View *view){
|
|
||||||
View_Context ctx = {};
|
|
||||||
View_Context_Node *node = view->ctx;
|
|
||||||
if (node != 0){
|
|
||||||
block_copy_struct(&ctx, &node->ctx);
|
|
||||||
}
|
|
||||||
return(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////
|
|
||||||
|
|
||||||
internal b32
|
internal b32
|
||||||
file_is_viewed(Layout *layout, Editing_File *file){
|
file_is_viewed(Layout *layout, Editing_File *file){
|
||||||
b32 is_viewed = false;
|
b32 is_viewed = false;
|
||||||
|
|
|
@ -325,202 +325,267 @@ get_token_color_cpp(Token token){
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
default_buffer_render_caller(Application_Links *app, Frame_Info frame_info, View_ID view_id, Rect_f32 view_inner_rect){
|
default_render_caller(Application_Links *app, Frame_Info frame_info, View_ID view_id){
|
||||||
Buffer_ID buffer = view_get_buffer(app, view_id, AccessAll);
|
View_ID active_view = get_active_view(app, AccessAll);
|
||||||
|
b32 is_active_view = (active_view == view_id);
|
||||||
|
|
||||||
|
Rect_f32 view_rect = view_get_screen_rect(app, view_id);
|
||||||
|
Rect_f32 inner = rect_inner(view_rect, 3);
|
||||||
|
draw_rectangle(app, view_rect, 0.f,
|
||||||
|
get_margin_color(is_active_view?UIHighlight_Active:UIHighlight_None));
|
||||||
|
draw_rectangle(app, inner, 0.f, Stag_Back);
|
||||||
|
|
||||||
|
Rect_f32 prev_clip = draw_set_clip(app, inner);
|
||||||
|
|
||||||
|
Buffer_ID buffer = view_get_buffer(app, view_id, AccessAll);
|
||||||
Face_ID face_id = get_face_id(app, buffer);
|
Face_ID face_id = get_face_id(app, buffer);
|
||||||
Face_Metrics face_metrics = get_face_metrics(app, face_id);
|
Face_Metrics face_metrics = get_face_metrics(app, face_id);
|
||||||
|
|
||||||
f32 line_height = face_metrics.line_height;
|
f32 line_height = face_metrics.line_height;
|
||||||
|
|
||||||
Rect_f32 sub_region = default_view_buffer_region(app, view_id, view_inner_rect);
|
// NOTE(allen): Frame
|
||||||
Rect_f32 buffer_rect = rect_intersect(sub_region, view_inner_rect);
|
Rect_f32 r_cursor = inner;
|
||||||
|
|
||||||
|
// NOTE(allen): Filebar
|
||||||
|
b64 showing_file_bar = false;
|
||||||
|
if (view_get_setting(app, view_id, ViewSetting_ShowFileBar, &showing_file_bar) && showing_file_bar){
|
||||||
|
Rect_f32 bar = r_cursor;
|
||||||
|
bar.y1 = bar.y0 + line_height + 2.f;
|
||||||
|
r_cursor.y0 = bar.y1;
|
||||||
|
|
||||||
|
draw_rectangle(app, bar, 0.f, Stag_Bar);
|
||||||
|
|
||||||
|
Fancy_Color base_color = fancy_id(Stag_Base);
|
||||||
|
Fancy_Color pop2_color = fancy_id(Stag_Pop2);
|
||||||
|
|
||||||
|
Scratch_Block scratch(app);
|
||||||
|
|
||||||
|
i64 cursor_position = view_get_cursor_pos(app, view_id);
|
||||||
|
Buffer_Cursor cursor = view_compute_cursor(app, view_id, seek_pos(cursor_position));
|
||||||
|
|
||||||
|
Fancy_String_List list = {};
|
||||||
|
String_Const_u8 unique_name = push_buffer_unique_name(app, scratch, buffer);
|
||||||
|
push_fancy_string(scratch, &list, base_color, unique_name);
|
||||||
|
push_fancy_stringf(scratch, &list, base_color, " - Row: %3.lld Col: %3.lld -", cursor.line, cursor.col);
|
||||||
|
|
||||||
|
b64 is_dos_mode = false;
|
||||||
|
if (buffer_get_setting(app, buffer, BufferSetting_Eol, &is_dos_mode)){
|
||||||
|
if (is_dos_mode){
|
||||||
|
push_fancy_string(scratch, &list, base_color, string_u8_litexpr(" dos"));
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
push_fancy_string(scratch, &list, base_color, string_u8_litexpr(" nix"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
push_fancy_string(scratch, &list, base_color, string_u8_litexpr(" ???"));
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
Dirty_State dirty = buffer_get_dirty_state(app, buffer);
|
||||||
|
u8 space[3];
|
||||||
|
String_u8 str = Su8(space, 0, 3);
|
||||||
|
if (dirty != 0){
|
||||||
|
string_append(&str, string_u8_litexpr(" "));
|
||||||
|
}
|
||||||
|
if (HasFlag(dirty, DirtyState_UnsavedChanges)){
|
||||||
|
string_append(&str, string_u8_litexpr("*"));
|
||||||
|
}
|
||||||
|
if (HasFlag(dirty, DirtyState_UnloadedChanges)){
|
||||||
|
string_append(&str, string_u8_litexpr("!"));
|
||||||
|
}
|
||||||
|
push_fancy_string(scratch, &list, pop2_color, str.string);
|
||||||
|
}
|
||||||
|
|
||||||
|
Vec2 p = bar.p0 + V2(0.f, 2.f);
|
||||||
|
draw_fancy_string(app, face_id, list.first, p, Stag_Default, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
Rect_f32 sub_region = default_view_buffer_region(app, view_id, inner);
|
||||||
|
Rect_f32 buffer_rect = rect_intersect(sub_region, inner);
|
||||||
|
|
||||||
Buffer_Scroll scroll = view_get_buffer_scroll(app, view_id);
|
Buffer_Scroll scroll = view_get_buffer_scroll(app, view_id);
|
||||||
Buffer_Point buffer_point = scroll.position;
|
Buffer_Point buffer_point = scroll.position;
|
||||||
Text_Layout_ID text_layout_id = text_layout_create(app, buffer, buffer_rect, buffer_point);
|
Text_Layout_ID text_layout_id = text_layout_create(app, buffer, buffer_rect, buffer_point);
|
||||||
Interval_i64 visible_range = text_layout_get_visible_range(app, text_layout_id);
|
Interval_i64 visible_range = text_layout_get_visible_range(app, text_layout_id);
|
||||||
|
|
||||||
View_ID active_view = get_active_view(app, AccessAll);
|
|
||||||
b32 is_active_view = (active_view == view_id);
|
|
||||||
|
|
||||||
Scratch_Block scratch(app);
|
Scratch_Block scratch(app);
|
||||||
|
|
||||||
// NOTE(allen): Token colorizing
|
|
||||||
Token_Array token_array = get_token_array_from_buffer(app, buffer);
|
|
||||||
if (token_array.tokens != 0){
|
|
||||||
i64 first_index = token_index_from_pos(&token_array, visible_range.first);
|
|
||||||
Token_Iterator_Array it = token_iterator_index(buffer, &token_array, first_index);
|
|
||||||
for (;;){
|
|
||||||
Token *token = token_it_read(&it);
|
|
||||||
if (token->pos >= visible_range.one_past_last){
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
int_color color = get_token_color_cpp(*token);
|
|
||||||
paint_text_color(app, text_layout_id, Ii64_size(token->pos, token->size), color);
|
|
||||||
|
|
||||||
if (!token_it_inc_non_whitespace(&it)){
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// NOTE(allen): Scan for TODOs and NOTEs
|
|
||||||
if (global_config.use_comment_keyword){
|
|
||||||
Temp_Memory temp = begin_temp(scratch);
|
|
||||||
String_Const_u8 tail = push_buffer_range(app, scratch, buffer, visible_range);
|
|
||||||
i32 index = 0;
|
|
||||||
for (;tail.size > 0; tail = string_skip(tail, 1), index += 1){
|
|
||||||
if (string_match(string_prefix(tail, 4), string_u8_litexpr("NOTE"))){
|
|
||||||
Interval_i64 range = Ii64_size(visible_range.first + index, 4);
|
|
||||||
paint_text_color(app, text_layout_id, range, Stag_Text_Cycle_2);
|
|
||||||
tail = string_skip(tail, 3);
|
|
||||||
index += 3;
|
|
||||||
}
|
|
||||||
else if (string_match(string_prefix(tail, 4), string_u8_litexpr("TODO"))){
|
|
||||||
Interval_i64 range = Ii64_size(visible_range.first + index, 4);
|
|
||||||
paint_text_color(app, text_layout_id, range, Stag_Text_Cycle_1);
|
|
||||||
tail = string_skip(tail, 3);
|
|
||||||
index += 3;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
end_temp(temp);
|
|
||||||
}
|
|
||||||
|
|
||||||
i64 cursor_pos = view_get_cursor_pos(app, view_id);
|
|
||||||
i64 mark_pos = view_get_mark_pos(app, view_id);
|
|
||||||
|
|
||||||
// NOTE(allen): Scope highlight
|
|
||||||
if (do_matching_enclosure_highlight){
|
|
||||||
static const i32 color_count = 4;
|
|
||||||
int_color colors[color_count];
|
|
||||||
for (u16 i = 0; i < color_count; i += 1){
|
|
||||||
colors[i] = Stag_Back_Cycle_1 + i;
|
|
||||||
}
|
|
||||||
draw_enclosures(app, text_layout_id, buffer,
|
|
||||||
cursor_pos, FindNest_Scope, RangeHighlightKind_LineHighlight,
|
|
||||||
colors, 0, color_count);
|
|
||||||
}
|
|
||||||
|
|
||||||
// NOTE(allen): Error highlight
|
|
||||||
{
|
{
|
||||||
String_Const_u8 name = string_u8_litexpr("*compilation*");
|
Rect_f32 prev_clip_sub = draw_set_clip(app, buffer_rect);
|
||||||
Buffer_ID compilation_buffer = get_buffer_by_name(app, name, AccessAll);
|
|
||||||
if (compilation_buffer != 0){
|
// NOTE(allen): Token colorizing
|
||||||
Managed_Scope scopes[2];
|
Token_Array token_array = get_token_array_from_buffer(app, buffer);
|
||||||
scopes[0] = buffer_get_managed_scope(app, compilation_buffer);
|
if (token_array.tokens != 0){
|
||||||
scopes[1] = buffer_get_managed_scope(app, buffer);
|
i64 first_index = token_index_from_pos(&token_array, visible_range.first);
|
||||||
Managed_Scope scope = get_managed_scope_with_multiple_dependencies(app, scopes, ArrayCount(scopes));
|
Token_Iterator_Array it = token_iterator_index(buffer, &token_array, first_index);
|
||||||
Managed_Object *markers_object = scope_attachment(app, scope, sticky_jump_marker_handle, Managed_Object);
|
for (;;){
|
||||||
|
Token *token = token_it_read(&it);
|
||||||
|
if (token->pos >= visible_range.one_past_last){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
int_color color = get_token_color_cpp(*token);
|
||||||
|
paint_text_color(app, text_layout_id, Ii64_size(token->pos, token->size), color);
|
||||||
|
|
||||||
|
if (!token_it_inc_non_whitespace(&it)){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NOTE(allen): Scan for TODOs and NOTEs
|
||||||
|
if (global_config.use_comment_keyword){
|
||||||
Temp_Memory temp = begin_temp(scratch);
|
Temp_Memory temp = begin_temp(scratch);
|
||||||
i32 count = managed_object_get_item_count(app, *markers_object);
|
String_Const_u8 tail = push_buffer_range(app, scratch, buffer, visible_range);
|
||||||
Marker *markers = push_array(scratch, Marker, count);
|
i32 index = 0;
|
||||||
managed_object_load_data(app, *markers_object, 0, count, markers);
|
for (;tail.size > 0; tail = string_skip(tail, 1), index += 1){
|
||||||
for (i32 i = 0; i < count; i += 1){
|
if (string_match(string_prefix(tail, 4), string_u8_litexpr("NOTE"))){
|
||||||
i64 line_number = get_line_number_from_pos(app, buffer, markers[i].pos);
|
Interval_i64 range = Ii64_size(visible_range.first + index, 4);
|
||||||
draw_line_highlight(app, text_layout_id, line_number,
|
paint_text_color(app, text_layout_id, range, Stag_Text_Cycle_2);
|
||||||
Stag_Highlight_Junk);
|
tail = string_skip(tail, 3);
|
||||||
|
index += 3;
|
||||||
|
}
|
||||||
|
else if (string_match(string_prefix(tail, 4), string_u8_litexpr("TODO"))){
|
||||||
|
Interval_i64 range = Ii64_size(visible_range.first + index, 4);
|
||||||
|
paint_text_color(app, text_layout_id, range, Stag_Text_Cycle_1);
|
||||||
|
tail = string_skip(tail, 3);
|
||||||
|
index += 3;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
end_temp(temp);
|
end_temp(temp);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
i64 cursor_pos = view_get_cursor_pos(app, view_id);
|
||||||
// NOTE(allen): Color parens
|
i64 mark_pos = view_get_mark_pos(app, view_id);
|
||||||
if (do_matching_paren_highlight){
|
|
||||||
i64 pos = cursor_pos;
|
// NOTE(allen): Scope highlight
|
||||||
if (buffer_get_char(app, buffer, pos) == '('){
|
if (do_matching_enclosure_highlight){
|
||||||
pos += 1;
|
static const i32 color_count = 4;
|
||||||
|
int_color colors[color_count];
|
||||||
|
for (u16 i = 0; i < color_count; i += 1){
|
||||||
|
colors[i] = Stag_Back_Cycle_1 + i;
|
||||||
|
}
|
||||||
|
draw_enclosures(app, text_layout_id, buffer,
|
||||||
|
cursor_pos, FindNest_Scope, RangeHighlightKind_LineHighlight,
|
||||||
|
colors, 0, color_count);
|
||||||
}
|
}
|
||||||
else if (pos > 0){
|
|
||||||
if (buffer_get_char(app, buffer, pos - 1) == ')'){
|
// NOTE(allen): Error highlight
|
||||||
pos -= 1;
|
{
|
||||||
|
String_Const_u8 name = string_u8_litexpr("*compilation*");
|
||||||
|
Buffer_ID compilation_buffer = get_buffer_by_name(app, name, AccessAll);
|
||||||
|
if (compilation_buffer != 0){
|
||||||
|
Managed_Scope scopes[2];
|
||||||
|
scopes[0] = buffer_get_managed_scope(app, compilation_buffer);
|
||||||
|
scopes[1] = buffer_get_managed_scope(app, buffer);
|
||||||
|
Managed_Scope comp_scope = get_managed_scope_with_multiple_dependencies(app, scopes, ArrayCount(scopes));
|
||||||
|
Managed_Object *markers_object = scope_attachment(app, comp_scope, sticky_jump_marker_handle, Managed_Object);
|
||||||
|
|
||||||
|
Temp_Memory temp = begin_temp(scratch);
|
||||||
|
i32 count = managed_object_get_item_count(app, *markers_object);
|
||||||
|
Marker *markers = push_array(scratch, Marker, count);
|
||||||
|
managed_object_load_data(app, *markers_object, 0, count, markers);
|
||||||
|
for (i32 i = 0; i < count; i += 1){
|
||||||
|
i64 line_number = get_line_number_from_pos(app, buffer, markers[i].pos);
|
||||||
|
draw_line_highlight(app, text_layout_id, line_number,
|
||||||
|
Stag_Highlight_Junk);
|
||||||
|
}
|
||||||
|
end_temp(temp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static const i32 color_count = 4;
|
|
||||||
int_color colors[color_count];
|
// NOTE(allen): Color parens
|
||||||
for (u16 i = 0; i < color_count; i += 1){
|
if (do_matching_paren_highlight){
|
||||||
colors[i] = Stag_Text_Cycle_1 + i;
|
i64 pos = cursor_pos;
|
||||||
}
|
if (buffer_get_char(app, buffer, pos) == '('){
|
||||||
draw_enclosures(app, text_layout_id, buffer,
|
pos += 1;
|
||||||
cursor_pos, FindNest_Paren, RangeHighlightKind_CharacterHighlight,
|
|
||||||
0, colors, color_count);
|
|
||||||
}
|
|
||||||
|
|
||||||
// NOTE(allen): Line highlight
|
|
||||||
if (highlight_line_at_cursor && is_active_view){
|
|
||||||
i64 line_number = get_line_number_from_pos(app, buffer, cursor_pos);
|
|
||||||
draw_line_highlight(app, text_layout_id, line_number, Stag_Highlight_Cursor_Line);
|
|
||||||
}
|
|
||||||
|
|
||||||
// NOTE(allen): Roundness
|
|
||||||
f32 cursor_roundness = 4.f;
|
|
||||||
f32 mark_thickness = 2.f;
|
|
||||||
|
|
||||||
// NOTE(allen): Highlight range
|
|
||||||
b32 has_highlight_range = false;
|
|
||||||
{
|
|
||||||
Managed_Scope scope = view_get_managed_scope(app, view_id);
|
|
||||||
Buffer_ID *highlight_buffer = scope_attachment(app, scope, view_highlight_buffer, Buffer_ID);
|
|
||||||
if (*highlight_buffer != 0){
|
|
||||||
if (*highlight_buffer != buffer){
|
|
||||||
view_disable_highlight_range(app, view_id);
|
|
||||||
}
|
}
|
||||||
else{
|
else if (pos > 0){
|
||||||
has_highlight_range = true;
|
if (buffer_get_char(app, buffer, pos - 1) == ')'){
|
||||||
Managed_Object *highlight = scope_attachment(app, scope, view_highlight_range, Managed_Object);
|
pos -= 1;
|
||||||
Marker marker_range[2];
|
|
||||||
if (managed_object_load_data(app, *highlight, 0, 2, marker_range)){
|
|
||||||
Range_i64 range = Ii64(marker_range[0].pos, marker_range[1].pos);
|
|
||||||
draw_character_block(app, text_layout_id, range, cursor_roundness, Stag_Highlight);
|
|
||||||
paint_text_color(app, text_layout_id, range, Stag_At_Highlight);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
static const i32 color_count = 4;
|
||||||
|
int_color colors[color_count];
|
||||||
|
for (u16 i = 0; i < color_count; i += 1){
|
||||||
|
colors[i] = Stag_Text_Cycle_1 + i;
|
||||||
|
}
|
||||||
|
draw_enclosures(app, text_layout_id, buffer,
|
||||||
|
cursor_pos, FindNest_Paren, RangeHighlightKind_CharacterHighlight,
|
||||||
|
0, colors, color_count);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
// NOTE(allen): Line highlight
|
||||||
// NOTE(allen): Cursor and mark
|
if (highlight_line_at_cursor && is_active_view){
|
||||||
if (!has_highlight_range){
|
i64 line_number = get_line_number_from_pos(app, buffer, cursor_pos);
|
||||||
switch (fcoder_mode){
|
draw_line_highlight(app, text_layout_id, line_number, Stag_Highlight_Cursor_Line);
|
||||||
case FCoderMode_Original:
|
}
|
||||||
{
|
|
||||||
if (is_active_view){
|
// NOTE(allen): Roundness
|
||||||
draw_character_block(app, text_layout_id, cursor_pos,
|
f32 cursor_roundness = 4.f;
|
||||||
cursor_roundness, Stag_Cursor);
|
f32 mark_thickness = 2.f;
|
||||||
paint_text_color_pos(app, text_layout_id, cursor_pos,
|
|
||||||
Stag_At_Cursor);
|
// NOTE(allen): Highlight range
|
||||||
draw_character_wire_frame(app, text_layout_id, mark_pos,
|
b32 has_highlight_range = false;
|
||||||
cursor_roundness, mark_thickness,
|
{
|
||||||
Stag_Mark);
|
Managed_Scope scope = view_get_managed_scope(app, view_id);
|
||||||
|
Buffer_ID *highlight_buffer = scope_attachment(app, scope, view_highlight_buffer, Buffer_ID);
|
||||||
|
if (*highlight_buffer != 0){
|
||||||
|
if (*highlight_buffer != buffer){
|
||||||
|
view_disable_highlight_range(app, view_id);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
draw_character_wire_frame(app, text_layout_id, mark_pos,
|
has_highlight_range = true;
|
||||||
cursor_roundness, mark_thickness,
|
Managed_Object *highlight = scope_attachment(app, scope, view_highlight_range, Managed_Object);
|
||||||
Stag_Mark);
|
Marker marker_range[2];
|
||||||
draw_character_wire_frame(app, text_layout_id, cursor_pos,
|
if (managed_object_load_data(app, *highlight, 0, 2, marker_range)){
|
||||||
cursor_roundness, mark_thickness,
|
Range_i64 range = Ii64(marker_range[0].pos, marker_range[1].pos);
|
||||||
Stag_Cursor);
|
draw_character_block(app, text_layout_id, range, cursor_roundness, Stag_Highlight);
|
||||||
|
paint_text_color(app, text_layout_id, range, Stag_At_Highlight);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}break;
|
}
|
||||||
|
|
||||||
case FCoderMode_NotepadLike:
|
|
||||||
{
|
|
||||||
if (cursor_pos != mark_pos){
|
|
||||||
Range_i64 range = Ii64(cursor_pos, mark_pos);
|
|
||||||
draw_character_block(app, text_layout_id, range,
|
|
||||||
cursor_roundness, Stag_Highlight);
|
|
||||||
paint_text_color(app, text_layout_id, range, Stag_At_Highlight);
|
|
||||||
}
|
|
||||||
draw_character_i_bar(app, text_layout_id, cursor_pos, Stag_Cursor);
|
|
||||||
}break;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
// NOTE(allen): Cursor and mark
|
||||||
{
|
if (!has_highlight_range){
|
||||||
Rect_f32 prev_clip = draw_set_clip(app, buffer_rect);
|
switch (fcoder_mode){
|
||||||
|
case FCoderMode_Original:
|
||||||
|
{
|
||||||
|
if (is_active_view){
|
||||||
|
draw_character_block(app, text_layout_id, cursor_pos,
|
||||||
|
cursor_roundness, Stag_Cursor);
|
||||||
|
paint_text_color_pos(app, text_layout_id, cursor_pos,
|
||||||
|
Stag_At_Cursor);
|
||||||
|
draw_character_wire_frame(app, text_layout_id, mark_pos,
|
||||||
|
cursor_roundness, mark_thickness,
|
||||||
|
Stag_Mark);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
draw_character_wire_frame(app, text_layout_id, mark_pos,
|
||||||
|
cursor_roundness, mark_thickness,
|
||||||
|
Stag_Mark);
|
||||||
|
draw_character_wire_frame(app, text_layout_id, cursor_pos,
|
||||||
|
cursor_roundness, mark_thickness,
|
||||||
|
Stag_Cursor);
|
||||||
|
}
|
||||||
|
}break;
|
||||||
|
|
||||||
|
case FCoderMode_NotepadLike:
|
||||||
|
{
|
||||||
|
if (cursor_pos != mark_pos){
|
||||||
|
Range_i64 range = Ii64(cursor_pos, mark_pos);
|
||||||
|
draw_character_block(app, text_layout_id, range,
|
||||||
|
cursor_roundness, Stag_Highlight);
|
||||||
|
paint_text_color(app, text_layout_id, range, Stag_At_Highlight);
|
||||||
|
}
|
||||||
|
draw_character_i_bar(app, text_layout_id, cursor_pos, Stag_Cursor);
|
||||||
|
}break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
draw_text_layout(app, text_layout_id);
|
draw_text_layout(app, text_layout_id);
|
||||||
draw_set_clip(app, prev_clip);
|
draw_set_clip(app, prev_clip_sub);
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE(allen): FPS HUD
|
// NOTE(allen): FPS HUD
|
||||||
|
@ -579,66 +644,6 @@ default_buffer_render_caller(Application_Links *app, Frame_Info frame_info, View
|
||||||
animate_in_n_milliseconds(app, 1000);
|
animate_in_n_milliseconds(app, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE(allen): Frame
|
|
||||||
Rect_f32 r_cursor = view_inner_rect;
|
|
||||||
|
|
||||||
// NOTE(allen): Filebar
|
|
||||||
b64 showing_file_bar = false;
|
|
||||||
if (view_get_setting(app, view_id, ViewSetting_ShowFileBar, &showing_file_bar) && showing_file_bar){
|
|
||||||
Rect_f32 bar = r_cursor;
|
|
||||||
bar.y1 = bar.y0 + line_height + 2.f;
|
|
||||||
r_cursor.y0 = bar.y1;
|
|
||||||
|
|
||||||
draw_rectangle(app, bar, 0.f, Stag_Bar);
|
|
||||||
|
|
||||||
Fancy_Color base_color = fancy_id(Stag_Base);
|
|
||||||
Fancy_Color pop2_color = fancy_id(Stag_Pop2);
|
|
||||||
|
|
||||||
Temp_Memory temp = begin_temp(scratch);
|
|
||||||
|
|
||||||
i64 cursor_position = view_get_cursor_pos(app, view_id);
|
|
||||||
Buffer_Cursor cursor = view_compute_cursor(app, view_id, seek_pos(cursor_position));
|
|
||||||
|
|
||||||
Fancy_String_List list = {};
|
|
||||||
String_Const_u8 unique_name = push_buffer_unique_name(app, scratch, buffer);
|
|
||||||
push_fancy_string(scratch, &list, base_color, unique_name);
|
|
||||||
push_fancy_stringf(scratch, &list, base_color, " - Row: %3.lld Col: %3.lld -", cursor.line, cursor.col);
|
|
||||||
|
|
||||||
b64 is_dos_mode = false;
|
|
||||||
if (buffer_get_setting(app, buffer, BufferSetting_Eol, &is_dos_mode)){
|
|
||||||
if (is_dos_mode){
|
|
||||||
push_fancy_string(scratch, &list, base_color, string_u8_litexpr(" dos"));
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
push_fancy_string(scratch, &list, base_color, string_u8_litexpr(" nix"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
push_fancy_string(scratch, &list, base_color, string_u8_litexpr(" ???"));
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
Dirty_State dirty = buffer_get_dirty_state(app, buffer);
|
|
||||||
u8 space[3];
|
|
||||||
String_u8 str = Su8(space, 0, 3);
|
|
||||||
if (dirty != 0){
|
|
||||||
string_append(&str, string_u8_litexpr(" "));
|
|
||||||
}
|
|
||||||
if (HasFlag(dirty, DirtyState_UnsavedChanges)){
|
|
||||||
string_append(&str, string_u8_litexpr("*"));
|
|
||||||
}
|
|
||||||
if (HasFlag(dirty, DirtyState_UnloadedChanges)){
|
|
||||||
string_append(&str, string_u8_litexpr("!"));
|
|
||||||
}
|
|
||||||
push_fancy_string(scratch, &list, pop2_color, str.string);
|
|
||||||
}
|
|
||||||
|
|
||||||
Vec2 p = bar.p0 + V2(0.f, 2.f);
|
|
||||||
draw_fancy_string(app, face_id, list.first, p, Stag_Default, 0);
|
|
||||||
|
|
||||||
end_temp(temp);
|
|
||||||
}
|
|
||||||
|
|
||||||
// NOTE(allen): Query Bars
|
// NOTE(allen): Query Bars
|
||||||
{
|
{
|
||||||
Query_Bar *space[32];
|
Query_Bar *space[32];
|
||||||
|
@ -683,7 +688,7 @@ default_buffer_render_caller(Application_Links *app, Frame_Info frame_info, View
|
||||||
|
|
||||||
draw_rectangle(app, left_margin, 0.f, Stag_Line_Numbers_Back);
|
draw_rectangle(app, left_margin, 0.f, Stag_Line_Numbers_Back);
|
||||||
|
|
||||||
Rect_f32 prev_clip = draw_set_clip(app, left_margin);
|
Rect_f32 prev_clip_line_numbers = draw_set_clip(app, left_margin);
|
||||||
|
|
||||||
Fancy_Color line_color = fancy_id(Stag_Line_Numbers_Text);
|
Fancy_Color line_color = fancy_id(Stag_Line_Numbers_Text);
|
||||||
|
|
||||||
|
@ -701,44 +706,14 @@ default_buffer_render_caller(Application_Links *app, Frame_Info frame_info, View
|
||||||
line_number += 1;
|
line_number += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
draw_set_clip(app, prev_clip);
|
draw_set_clip(app, prev_clip_line_numbers);
|
||||||
}
|
}
|
||||||
|
|
||||||
text_layout_free(app, text_layout_id);
|
text_layout_free(app, text_layout_id);
|
||||||
}
|
|
||||||
|
|
||||||
internal void
|
|
||||||
default_render_view(Application_Links *app, Frame_Info frame_info, View_ID view, b32 is_active){
|
|
||||||
Rect_f32 view_rect = view_get_screen_rect(app, view);
|
|
||||||
Rect_f32 inner = rect_inner(view_rect, 3);
|
|
||||||
draw_rectangle(app, view_rect, 0.f,
|
|
||||||
get_margin_color(is_active?UIHighlight_Active:UIHighlight_None));
|
|
||||||
draw_rectangle(app, inner, 0.f, Stag_Back);
|
|
||||||
Rect_f32 prev_clip = draw_set_clip(app, inner);
|
|
||||||
|
|
||||||
Managed_Scope scope = view_get_managed_scope(app, view);
|
|
||||||
View_Render_Hook **hook_ptr = scope_attachment(app, scope, view_render_hook, View_Render_Hook*);
|
|
||||||
|
|
||||||
if (*hook_ptr == 0){
|
|
||||||
default_buffer_render_caller(app, frame_info, view, inner);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
View_Render_Hook *hook = *hook_ptr;
|
|
||||||
hook(app, view, frame_info, inner);
|
|
||||||
}
|
|
||||||
|
|
||||||
draw_set_clip(app, prev_clip);
|
draw_set_clip(app, prev_clip);
|
||||||
}
|
}
|
||||||
|
|
||||||
RENDER_CALLER_SIG(default_render_caller){
|
|
||||||
View_ID active_view_id = get_active_view(app, AccessAll);
|
|
||||||
for (View_ID view_id = get_view_next(app, 0, AccessAll);
|
|
||||||
view_id != 0;
|
|
||||||
view_id = get_view_next(app, view_id, AccessAll)){
|
|
||||||
default_render_view(app, frame_info, view_id, (active_view_id == view_id));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
HOOK_SIG(default_exit){
|
HOOK_SIG(default_exit){
|
||||||
// If this returns false it cancels the exit.
|
// If this returns false it cancels the exit.
|
||||||
b32 result = true;
|
b32 result = true;
|
||||||
|
|
|
@ -69,7 +69,7 @@ begin_lister(Application_Links *app, Arena *arena, View_ID view, void *user_data
|
||||||
}
|
}
|
||||||
|
|
||||||
function void
|
function void
|
||||||
lister_render(Application_Links *app, View_ID view, Frame_Info frame_info, Rect_f32 inner){
|
lister_render(Application_Links *app, Frame_Info frame_info, View_ID view){
|
||||||
Scratch_Block scratch(app);
|
Scratch_Block scratch(app);
|
||||||
|
|
||||||
Lister *lister = view_get_lister(view);
|
Lister *lister = view_get_lister(view);
|
||||||
|
@ -77,9 +77,20 @@ lister_render(Application_Links *app, View_ID view, Frame_Info frame_info, Rect_
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Rect_f32 region = view_get_screen_rect(app, view);
|
////////////////////////////////
|
||||||
// TODO(allen): eliminate this. bad bad bad bad :(
|
View_ID active_view = get_active_view(app, AccessAll);
|
||||||
region = rect_inner(region, 3.f);
|
b32 is_active_view = (active_view == view);
|
||||||
|
|
||||||
|
Rect_f32 view_rect = view_get_screen_rect(app, view);
|
||||||
|
Rect_f32 inner = rect_inner(view_rect, 3);
|
||||||
|
draw_rectangle(app, view_rect, 0.f,
|
||||||
|
get_margin_color(is_active_view?UIHighlight_Active:UIHighlight_None));
|
||||||
|
draw_rectangle(app, inner, 0.f, Stag_Back);
|
||||||
|
|
||||||
|
Rect_f32 prev_clip = draw_set_clip(app, inner);
|
||||||
|
////////////////////////////////
|
||||||
|
|
||||||
|
Rect_f32 region = inner;
|
||||||
Mouse_State mouse = get_mouse_state(app);
|
Mouse_State mouse = get_mouse_state(app);
|
||||||
Vec2_f32 m_p = V2f32(mouse.p);
|
Vec2_f32 m_p = V2f32(mouse.p);
|
||||||
|
|
||||||
|
@ -104,7 +115,7 @@ lister_render(Application_Links *app, View_ID view, Frame_Info frame_info, Rect_
|
||||||
}
|
}
|
||||||
|
|
||||||
Range_f32 x = rect_range_x(layout.list_rect);
|
Range_f32 x = rect_range_x(layout.list_rect);
|
||||||
Rect_f32 prev_clip = draw_set_clip(app, layout.list_rect);
|
draw_set_clip(app, layout.list_rect);
|
||||||
|
|
||||||
i32 count = lister->data.filtered.count;
|
i32 count = lister->data.filtered.count;
|
||||||
Range_f32 scroll_range = If32(0.f, clamp_bot(0.f, count*block_height - block_height));
|
Range_f32 scroll_range = If32(0.f, clamp_bot(0.f, count*block_height - block_height));
|
||||||
|
@ -341,9 +352,9 @@ lister_run(Application_Links *app, View_ID view, Lister *lister){
|
||||||
lister->data.filter_restore_point = begin_temp(lister->arena);
|
lister->data.filter_restore_point = begin_temp(lister->arena);
|
||||||
lister_update_filtered_list(app, view, lister);
|
lister_update_filtered_list(app, view, lister);
|
||||||
|
|
||||||
Managed_Scope scope = view_get_managed_scope(app, view);
|
View_Context ctx = view_current_context(app, view);
|
||||||
View_Render_Hook **hook = scope_attachment(app, scope, view_render_hook, View_Render_Hook*);
|
ctx.render_caller = lister_render;
|
||||||
*hook = lister_render;
|
view_push_context(app, view, &ctx);
|
||||||
|
|
||||||
for (;;){
|
for (;;){
|
||||||
User_Input in = get_user_input(app, EventPropertyGroup_Any, EventProperty_Escape);
|
User_Input in = get_user_input(app, EventPropertyGroup_Any, EventProperty_Escape);
|
||||||
|
@ -488,8 +499,7 @@ lister_run(Application_Links *app, View_ID view, Lister *lister){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
hook = scope_attachment(app, scope, view_render_hook, View_Render_Hook*);
|
view_pop_context(app, view);
|
||||||
*hook = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function Lister_Prealloced_String
|
function Lister_Prealloced_String
|
||||||
|
|
|
@ -6,9 +6,9 @@
|
||||||
* Log parser.
|
* Log parser.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// TOP
|
// TOP
|
||||||
|
|
||||||
internal u64
|
internal u64
|
||||||
log_parse__string_code(Log_Parse *parse, String_Const_u8 string, Log_String_Source string_source){
|
log_parse__string_code(Log_Parse *parse, String_Const_u8 string, Log_String_Source string_source){
|
||||||
u64 result = 0;
|
u64 result = 0;
|
||||||
|
@ -30,7 +30,7 @@ log_parse__string_code(Log_Parse *parse, String_Const_u8 string, Log_String_Sour
|
||||||
}
|
}
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal String_Const_u8
|
internal String_Const_u8
|
||||||
log_parse__get_string(Log_Parse *parse, u64 code){
|
log_parse__get_string(Log_Parse *parse, u64 code){
|
||||||
Table_Lookup lookup = table_lookup(&parse->id_to_string_table, code);
|
Table_Lookup lookup = table_lookup(&parse->id_to_string_table, code);
|
||||||
|
@ -42,7 +42,7 @@ log_parse__get_string(Log_Parse *parse, u64 code){
|
||||||
}
|
}
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal Log_Event*
|
internal Log_Event*
|
||||||
log_parse__event(Log_Parse *parse,
|
log_parse__event(Log_Parse *parse,
|
||||||
String_Const_u8 file_name, String_Const_u8 line_number, String_Const_u8 event_name){
|
String_Const_u8 file_name, String_Const_u8 line_number, String_Const_u8 event_name){
|
||||||
|
@ -55,7 +55,7 @@ log_parse__event(Log_Parse *parse,
|
||||||
new_event->event_number = parse->event_count;
|
new_event->event_number = parse->event_count;
|
||||||
return(new_event);
|
return(new_event);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal Log_Tag*
|
internal Log_Tag*
|
||||||
log_parse__tag(Log_Parse *parse, Log_Event *event, String_Const_u8 tag_name, String_Const_u8 tag_value){
|
log_parse__tag(Log_Parse *parse, Log_Event *event, String_Const_u8 tag_name, String_Const_u8 tag_value){
|
||||||
Log_Tag *new_tag = push_array(parse->arena, Log_Tag, 1);
|
Log_Tag *new_tag = push_array(parse->arena, Log_Tag, 1);
|
||||||
|
@ -103,7 +103,7 @@ log_parse__tag(Log_Parse *parse, Log_Event *event, String_Const_u8 tag_name, Str
|
||||||
}
|
}
|
||||||
return(new_tag);
|
return(new_tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal Log_Event_List*
|
internal Log_Event_List*
|
||||||
log_parse_get_list_tag_value(Log_Parse *parse, u64 name, Log_Tag_Value value){
|
log_parse_get_list_tag_value(Log_Parse *parse, u64 name, Log_Tag_Value value){
|
||||||
Log_Event_List *result = 0;
|
Log_Event_List *result = 0;
|
||||||
|
@ -116,7 +116,7 @@ log_parse_get_list_tag_value(Log_Parse *parse, u64 name, Log_Tag_Value value){
|
||||||
}
|
}
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal Log_Event_List*
|
internal Log_Event_List*
|
||||||
log_parse__get_or_make_list_tag_value(Log_Parse *parse, Log_Tag *tag){
|
log_parse__get_or_make_list_tag_value(Log_Parse *parse, Log_Tag *tag){
|
||||||
Log_Event_List *result = 0;
|
Log_Event_List *result = 0;
|
||||||
|
@ -135,7 +135,7 @@ log_parse__get_or_make_list_tag_value(Log_Parse *parse, Log_Tag *tag){
|
||||||
}
|
}
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal Log_Event_List*
|
internal Log_Event_List*
|
||||||
log_parse_get_list_tag_name(Log_Parse *parse, u64 name){
|
log_parse_get_list_tag_name(Log_Parse *parse, u64 name){
|
||||||
Log_Event_List *result = 0;
|
Log_Event_List *result = 0;
|
||||||
|
@ -147,7 +147,7 @@ log_parse_get_list_tag_name(Log_Parse *parse, u64 name){
|
||||||
}
|
}
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal Log_Event_List*
|
internal Log_Event_List*
|
||||||
log_parse__get_or_make_list_tag_name(Log_Parse *parse, Log_Tag *tag){
|
log_parse__get_or_make_list_tag_name(Log_Parse *parse, Log_Tag *tag){
|
||||||
Log_Event_List *result = 0;
|
Log_Event_List *result = 0;
|
||||||
|
@ -163,7 +163,7 @@ log_parse__get_or_make_list_tag_name(Log_Parse *parse, Log_Tag *tag){
|
||||||
}
|
}
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal Log_Parse
|
internal Log_Parse
|
||||||
make_log_parse(Arena *arena, String_Const_u8 source){
|
make_log_parse(Arena *arena, String_Const_u8 source){
|
||||||
Log_Parse parse = {};
|
Log_Parse parse = {};
|
||||||
|
@ -171,82 +171,82 @@ make_log_parse(Arena *arena, String_Const_u8 source){
|
||||||
parse.string_id_counter = 1;
|
parse.string_id_counter = 1;
|
||||||
parse.string_to_id_table = make_table_Data_u64(arena->base_allocator, 500);
|
parse.string_to_id_table = make_table_Data_u64(arena->base_allocator, 500);
|
||||||
parse.id_to_string_table = make_table_u64_Data(arena->base_allocator, 500);
|
parse.id_to_string_table = make_table_u64_Data(arena->base_allocator, 500);
|
||||||
|
|
||||||
for (;source.size > 0;){
|
for (;source.size > 0;){
|
||||||
umem end_of_line = string_find_first(source, '\n');
|
umem end_of_line = string_find_first(source, '\n');
|
||||||
String_Const_u8 line = string_prefix(source, end_of_line);
|
String_Const_u8 line = string_prefix(source, end_of_line);
|
||||||
line = string_skip_chop_whitespace(line);
|
line = string_skip_chop_whitespace(line);
|
||||||
source = string_skip(source, end_of_line + 1);
|
source = string_skip(source, end_of_line + 1);
|
||||||
|
|
||||||
String_Const_u8 src_file_name = {};
|
String_Const_u8 src_file_name = {};
|
||||||
String_Const_u8 src_line_number = {};
|
String_Const_u8 src_line_number = {};
|
||||||
b32 got_source_position = false;
|
b32 got_source_position = false;
|
||||||
|
|
||||||
String_Const_u8 whole_line = line;
|
String_Const_u8 whole_line = line;
|
||||||
|
|
||||||
{
|
{
|
||||||
umem colon1 = string_find_first(line, ':');
|
umem colon1 = string_find_first(line, ':');
|
||||||
src_file_name = string_prefix(line, colon1);
|
src_file_name = string_prefix(line, colon1);
|
||||||
line = string_skip(line, colon1 + 1);
|
line = string_skip(line, colon1 + 1);
|
||||||
|
|
||||||
umem colon2 = string_find_first(line, ':');
|
umem colon2 = string_find_first(line, ':');
|
||||||
src_line_number = string_prefix(line, colon2);
|
src_line_number = string_prefix(line, colon2);
|
||||||
line = string_skip(line, colon2 + 1);
|
line = string_skip(line, colon2 + 1);
|
||||||
|
|
||||||
if (string_is_integer(src_line_number, 10)){
|
if (string_is_integer(src_line_number, 10)){
|
||||||
got_source_position = true;
|
got_source_position = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!got_source_position){
|
if (!got_source_position){
|
||||||
line = whole_line;
|
line = whole_line;
|
||||||
|
|
||||||
umem colon0 = string_find_first(line, ':');
|
umem colon0 = string_find_first(line, ':');
|
||||||
umem colon1 = string_find_first(line, colon0 + 1, ':');
|
umem colon1 = string_find_first(line, colon0 + 1, ':');
|
||||||
src_file_name = string_prefix(line, colon1);
|
src_file_name = string_prefix(line, colon1);
|
||||||
line = string_skip(line, colon1 + 1);
|
line = string_skip(line, colon1 + 1);
|
||||||
|
|
||||||
umem colon2 = string_find_first(line, ':');
|
umem colon2 = string_find_first(line, ':');
|
||||||
src_line_number = string_prefix(line, colon2);
|
src_line_number = string_prefix(line, colon2);
|
||||||
line = string_skip(line, colon2 + 1);
|
line = string_skip(line, colon2 + 1);
|
||||||
|
|
||||||
if (string_is_integer(src_line_number, 10)){
|
if (string_is_integer(src_line_number, 10)){
|
||||||
got_source_position = true;
|
got_source_position = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (got_source_position){
|
if (got_source_position){
|
||||||
umem bracket_open = string_find_first(line, '[');
|
umem bracket_open = string_find_first(line, '[');
|
||||||
String_Const_u8 event_name = string_prefix(line, bracket_open);
|
String_Const_u8 event_name = string_prefix(line, bracket_open);
|
||||||
event_name = string_skip_chop_whitespace(event_name);
|
event_name = string_skip_chop_whitespace(event_name);
|
||||||
line = string_skip(line, bracket_open + 1);
|
line = string_skip(line, bracket_open + 1);
|
||||||
|
|
||||||
Log_Event *event = log_parse__event(&parse,
|
Log_Event *event = log_parse__event(&parse,
|
||||||
src_file_name, src_line_number, event_name);
|
src_file_name, src_line_number, event_name);
|
||||||
|
|
||||||
for (;line.size > 0;){
|
for (;line.size > 0;){
|
||||||
umem bracket_close = string_find_first(line, ']');
|
umem bracket_close = string_find_first(line, ']');
|
||||||
String_Const_u8 tag = string_prefix(line, bracket_close);
|
String_Const_u8 tag = string_prefix(line, bracket_close);
|
||||||
line = string_skip(line, bracket_close + 1);
|
line = string_skip(line, bracket_close + 1);
|
||||||
bracket_open = string_find_first(line, '[');
|
bracket_open = string_find_first(line, '[');
|
||||||
line = string_skip(line, bracket_open + 1);
|
line = string_skip(line, bracket_open + 1);
|
||||||
|
|
||||||
umem equal_sign = string_find_first(tag, '=');
|
umem equal_sign = string_find_first(tag, '=');
|
||||||
String_Const_u8 tag_name = string_prefix(tag, equal_sign);
|
String_Const_u8 tag_name = string_prefix(tag, equal_sign);
|
||||||
String_Const_u8 tag_contents = string_skip(tag, equal_sign + 1);
|
String_Const_u8 tag_contents = string_skip(tag, equal_sign + 1);
|
||||||
|
|
||||||
log_parse__tag(&parse, event, tag_name, tag_contents);
|
log_parse__tag(&parse, event, tag_name, tag_contents);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
|
||||||
// NOTE(allen): fill acceleration structures
|
// NOTE(allen): fill acceleration structures
|
||||||
|
|
||||||
parse.tag_value_to_event_list_table = make_table_Data_u64(arena->base_allocator, Thousand(1));
|
parse.tag_value_to_event_list_table = make_table_Data_u64(arena->base_allocator, Thousand(1));
|
||||||
parse.tag_name_to_event_list_table = make_table_u64_u64(arena->base_allocator, 100);
|
parse.tag_name_to_event_list_table = make_table_u64_u64(arena->base_allocator, 100);
|
||||||
|
|
||||||
for (Log_Event *event = parse.first_event;
|
for (Log_Event *event = parse.first_event;
|
||||||
event != 0;
|
event != 0;
|
||||||
event = event->next){
|
event = event->next){
|
||||||
|
@ -269,7 +269,7 @@ make_log_parse(Arena *arena, String_Const_u8 source){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Log_Event *event = parse.first_event;
|
for (Log_Event *event = parse.first_event;
|
||||||
event != 0;
|
event != 0;
|
||||||
event = event->next){
|
event = event->next){
|
||||||
|
@ -281,12 +281,12 @@ make_log_parse(Arena *arena, String_Const_u8 source){
|
||||||
table_insert(&event->tag_name_to_tag_ptr_table, tag->name, (u64)PtrAsInt(tag));
|
table_insert(&event->tag_name_to_tag_ptr_table, tag->name, (u64)PtrAsInt(tag));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return(parse);
|
return(parse);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
log_events_sort_by_tag__inner(Log_Event **events, Log_Sort_Key *keys, i32 first, i32 one_past_last){
|
log_events_sort_by_tag__inner(Log_Event **events, Log_Sort_Key *keys, i32 first, i32 one_past_last){
|
||||||
if (first + 1 < one_past_last){
|
if (first + 1 < one_past_last){
|
||||||
|
@ -323,7 +323,7 @@ log_events_sort_by_tag__inner(Log_Event **events, Log_Sort_Key *keys, i32 first,
|
||||||
log_events_sort_by_tag__inner(events, keys, j + 1, one_past_last);
|
log_events_sort_by_tag__inner(events, keys, j + 1, one_past_last);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
log_events_sort_by_tag(Arena *scratch, Log_Event_Ptr_Array array, u64 tag_name){
|
log_events_sort_by_tag(Arena *scratch, Log_Event_Ptr_Array array, u64 tag_name){
|
||||||
Temp_Memory temp = begin_temp(scratch);
|
Temp_Memory temp = begin_temp(scratch);
|
||||||
|
@ -343,12 +343,12 @@ log_events_sort_by_tag(Arena *scratch, Log_Event_Ptr_Array array, u64 tag_name){
|
||||||
}
|
}
|
||||||
keys[i].number = event->event_number;
|
keys[i].number = event->event_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
log_events_sort_by_tag__inner(array.events, keys, 0, array.count);
|
log_events_sort_by_tag__inner(array.events, keys, 0, array.count);
|
||||||
|
|
||||||
end_temp(temp);
|
end_temp(temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal Log_Event_Ptr_Array
|
internal Log_Event_Ptr_Array
|
||||||
log_event_array_from_list(Arena *arena, Log_Event_List list){
|
log_event_array_from_list(Arena *arena, Log_Event_List list){
|
||||||
Log_Event_Ptr_Array array = {};
|
Log_Event_Ptr_Array array = {};
|
||||||
|
@ -363,16 +363,16 @@ log_event_array_from_list(Arena *arena, Log_Event_List list){
|
||||||
}
|
}
|
||||||
return(array);
|
return(array);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
|
||||||
global View_ID log_view = 0;
|
global View_ID log_view = 0;
|
||||||
global Arena *log_arena = {};
|
global Arena *log_arena = {};
|
||||||
global Log_Parse log_parse = {};
|
global Log_Parse log_parse = {};
|
||||||
global Log_Graph log_graph = {};
|
global Log_Graph log_graph = {};
|
||||||
global Log_Filter_Set log_filter_set = {};
|
global Log_Filter_Set log_filter_set = {};
|
||||||
global Log_Filter_Set log_preview_set = {};
|
global Log_Filter_Set log_preview_set = {};
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
log_filter_set_init(Log_Filter_Set *set){
|
log_filter_set_init(Log_Filter_Set *set){
|
||||||
block_zero_struct(set);
|
block_zero_struct(set);
|
||||||
|
@ -380,7 +380,7 @@ log_filter_set_init(Log_Filter_Set *set){
|
||||||
sll_stack_push(set->free_filters, &set->filters_memory[i]);
|
sll_stack_push(set->free_filters, &set->filters_memory[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal Log_Filter_Set*
|
internal Log_Filter_Set*
|
||||||
log_filter_set_from_tab(Log_Graph_List_Tab tab){
|
log_filter_set_from_tab(Log_Graph_List_Tab tab){
|
||||||
Log_Filter_Set *result = 0;
|
Log_Filter_Set *result = 0;
|
||||||
|
@ -396,7 +396,7 @@ log_filter_set_from_tab(Log_Graph_List_Tab tab){
|
||||||
}
|
}
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal Log_Filter*
|
internal Log_Filter*
|
||||||
log_filter_set__new_filter(Log_Filter_Set *set, Log_Filter *prototype){
|
log_filter_set__new_filter(Log_Filter_Set *set, Log_Filter *prototype){
|
||||||
Log_Filter *result = set->free_filters;
|
Log_Filter *result = set->free_filters;
|
||||||
|
@ -421,7 +421,7 @@ log_filter_set__new_filter(Log_Filter_Set *set, Log_Filter *prototype){
|
||||||
}
|
}
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
log_filter_set__free_filter(Log_Filter_Set *set, Log_Filter *filter){
|
log_filter_set__free_filter(Log_Filter_Set *set, Log_Filter *filter){
|
||||||
zdll_remove(set->first, set->last, filter);
|
zdll_remove(set->first, set->last, filter);
|
||||||
|
@ -429,7 +429,7 @@ log_filter_set__free_filter(Log_Filter_Set *set, Log_Filter *filter){
|
||||||
set->alter_counter += 1;
|
set->alter_counter += 1;
|
||||||
sll_stack_push(set->free_filters, filter);
|
sll_stack_push(set->free_filters, filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
log_graph_fill(Application_Links *app, Rect_f32 layout_region, Face_ID face_id){
|
log_graph_fill(Application_Links *app, Rect_f32 layout_region, Face_ID face_id){
|
||||||
if (log_parse.arena != 0){
|
if (log_parse.arena != 0){
|
||||||
|
@ -444,22 +444,22 @@ log_graph_fill(Application_Links *app, Rect_f32 layout_region, Face_ID face_id){
|
||||||
log_graph.filter_alter_counter = log_filter_set.alter_counter;
|
log_graph.filter_alter_counter = log_filter_set.alter_counter;
|
||||||
log_graph.preview_alter_counter = log_preview_set.alter_counter;
|
log_graph.preview_alter_counter = log_preview_set.alter_counter;
|
||||||
log_graph.tab = LogTab_Filters;
|
log_graph.tab = LogTab_Filters;
|
||||||
|
|
||||||
f32 details_h = rect_height(layout_region)*.22f;
|
f32 details_h = rect_height(layout_region)*.22f;
|
||||||
details_h = clamp_top(details_h, 250.f);
|
details_h = clamp_top(details_h, 250.f);
|
||||||
|
|
||||||
Rect_f32 details_region = Rf32(layout_region.x0, layout_region.y0,
|
Rect_f32 details_region = Rf32(layout_region.x0, layout_region.y0,
|
||||||
layout_region.x1, layout_region.y0 + details_h);
|
layout_region.x1, layout_region.y0 + details_h);
|
||||||
Rect_f32 event_list_region = Rf32(layout_region.x0, layout_region.y0 + details_h,
|
Rect_f32 event_list_region = Rf32(layout_region.x0, layout_region.y0 + details_h,
|
||||||
layout_region.x1, layout_region.y1);
|
layout_region.x1, layout_region.y1);
|
||||||
|
|
||||||
log_graph.details_region = details_region;
|
log_graph.details_region = details_region;
|
||||||
log_graph.details_region.p0 -= layout_region.p0;
|
log_graph.details_region.p0 -= layout_region.p0;
|
||||||
log_graph.details_region.p1 -= layout_region.p0;
|
log_graph.details_region.p1 -= layout_region.p0;
|
||||||
|
|
||||||
u64 thread_code = log_parse__string_code(&log_parse, string_u8_litexpr("thread"),
|
u64 thread_code = log_parse__string_code(&log_parse, string_u8_litexpr("thread"),
|
||||||
LogParse_ExternalString);
|
LogParse_ExternalString);
|
||||||
|
|
||||||
if (log_filter_set.count == 0){
|
if (log_filter_set.count == 0){
|
||||||
// NOTE(allen): everything goes into the filtered list
|
// NOTE(allen): everything goes into the filtered list
|
||||||
for (Log_Event *event = log_parse.first_event;
|
for (Log_Event *event = log_parse.first_event;
|
||||||
|
@ -483,7 +483,7 @@ log_graph_fill(Application_Links *app, Rect_f32 layout_region, Face_ID face_id){
|
||||||
else if (filter->kind == LogFilter_Tag){
|
else if (filter->kind == LogFilter_Tag){
|
||||||
filter_list = log_parse_get_list_tag_name(&log_parse, filter->tag_name_code);
|
filter_list = log_parse_get_list_tag_name(&log_parse, filter->tag_name_code);
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE(allen): combine with existing result
|
// NOTE(allen): combine with existing result
|
||||||
if (filter == log_filter_set.first){
|
if (filter == log_filter_set.first){
|
||||||
for (Log_Event_Ptr_Node *node = filter_list->first;
|
for (Log_Event_Ptr_Node *node = filter_list->first;
|
||||||
|
@ -502,7 +502,7 @@ log_graph_fill(Application_Links *app, Rect_f32 layout_region, Face_ID face_id){
|
||||||
node_a != 0;
|
node_a != 0;
|
||||||
node_a = next){
|
node_a = next){
|
||||||
next = node_a->next;
|
next = node_a->next;
|
||||||
|
|
||||||
b32 remove_node_a = true;
|
b32 remove_node_a = true;
|
||||||
for (Log_Event_Ptr_Node *node_b = filter_list->first;
|
for (Log_Event_Ptr_Node *node_b = filter_list->first;
|
||||||
node_b != 0;
|
node_b != 0;
|
||||||
|
@ -512,7 +512,7 @@ log_graph_fill(Application_Links *app, Rect_f32 layout_region, Face_ID face_id){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (remove_node_a){
|
if (remove_node_a){
|
||||||
*fixup_ptr = next;
|
*fixup_ptr = next;
|
||||||
}
|
}
|
||||||
|
@ -524,19 +524,19 @@ log_graph_fill(Application_Links *app, Rect_f32 layout_region, Face_ID face_id){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log_graph.event_array = log_event_array_from_list(log_arena,
|
log_graph.event_array = log_event_array_from_list(log_arena,
|
||||||
log_graph.filtered_list);
|
log_graph.filtered_list);
|
||||||
log_events_sort_by_tag(log_arena, log_graph.event_array, thread_code);
|
log_events_sort_by_tag(log_arena, log_graph.event_array, thread_code);
|
||||||
|
|
||||||
b32 had_a_tag = true;
|
b32 had_a_tag = true;
|
||||||
u64 thread_id_value = 0;
|
u64 thread_id_value = 0;
|
||||||
Log_Graph_Thread_Bucket *prev_bucket = 0;
|
Log_Graph_Thread_Bucket *prev_bucket = 0;
|
||||||
|
|
||||||
for (i32 i = 0; i < log_graph.event_array.count; i += 1){
|
for (i32 i = 0; i < log_graph.event_array.count; i += 1){
|
||||||
Table_u64_u64 *tag_table = &log_graph.event_array.events[i]->tag_name_to_tag_ptr_table;
|
Table_u64_u64 *tag_table = &log_graph.event_array.events[i]->tag_name_to_tag_ptr_table;
|
||||||
Table_Lookup lookup = table_lookup(tag_table, thread_code);
|
Table_Lookup lookup = table_lookup(tag_table, thread_code);
|
||||||
|
|
||||||
b32 emit_next_bucket = false;
|
b32 emit_next_bucket = false;
|
||||||
if (!lookup.found_match){
|
if (!lookup.found_match){
|
||||||
if (had_a_tag){
|
if (had_a_tag){
|
||||||
|
@ -559,7 +559,7 @@ log_graph_fill(Application_Links *app, Rect_f32 layout_region, Face_ID face_id){
|
||||||
emit_next_bucket = true;
|
emit_next_bucket = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (emit_next_bucket){
|
if (emit_next_bucket){
|
||||||
Log_Graph_Thread_Bucket *bucket = push_array(log_arena, Log_Graph_Thread_Bucket, 1);
|
Log_Graph_Thread_Bucket *bucket = push_array(log_arena, Log_Graph_Thread_Bucket, 1);
|
||||||
sll_queue_push(log_graph.first_bucket, log_graph.last_bucket, bucket);
|
sll_queue_push(log_graph.first_bucket, log_graph.last_bucket, bucket);
|
||||||
|
@ -576,16 +576,16 @@ log_graph_fill(Application_Links *app, Rect_f32 layout_region, Face_ID face_id){
|
||||||
if (prev_bucket != 0){
|
if (prev_bucket != 0){
|
||||||
prev_bucket->range.one_past_last = log_graph.event_array.count;
|
prev_bucket->range.one_past_last = log_graph.event_array.count;
|
||||||
}
|
}
|
||||||
|
|
||||||
Face_Metrics metrics = get_face_metrics(app, face_id);
|
Face_Metrics metrics = get_face_metrics(app, face_id);
|
||||||
f32 line_height = metrics.line_height;
|
f32 line_height = metrics.line_height;
|
||||||
f32 box_h = f32_floor32(line_height*1.5f);
|
f32 box_h = f32_floor32(line_height*1.5f);
|
||||||
f32 box_w = f32_floor32(rect_width(event_list_region)/log_graph.bucket_count);
|
f32 box_w = f32_floor32(rect_width(event_list_region)/log_graph.bucket_count);
|
||||||
f32 y_cursor = event_list_region.y0 - layout_region.y0;
|
f32 y_cursor = event_list_region.y0 - layout_region.y0;
|
||||||
|
|
||||||
if (log_graph.bucket_count > 0){
|
if (log_graph.bucket_count > 0){
|
||||||
f32 y_bottom = 0.f;
|
f32 y_bottom = 0.f;
|
||||||
|
|
||||||
for (;;){
|
for (;;){
|
||||||
i32 smallest_event_number = max_i32;
|
i32 smallest_event_number = max_i32;
|
||||||
i32 bucket_with_next_event_index = -1;
|
i32 bucket_with_next_event_index = -1;
|
||||||
|
@ -605,13 +605,13 @@ log_graph_fill(Application_Links *app, Rect_f32 layout_region, Face_ID face_id){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bucket_with_next_event == 0){
|
if (bucket_with_next_event == 0){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
bucket_with_next_event->range.first += 1;
|
bucket_with_next_event->range.first += 1;
|
||||||
|
|
||||||
Log_Graph_Box *box_node = push_array(log_arena, Log_Graph_Box, 1);
|
Log_Graph_Box *box_node = push_array(log_arena, Log_Graph_Box, 1);
|
||||||
sll_queue_push(log_graph.first_box, log_graph.last_box, box_node);
|
sll_queue_push(log_graph.first_box, log_graph.last_box, box_node);
|
||||||
log_graph.box_count += 1;
|
log_graph.box_count += 1;
|
||||||
|
@ -619,32 +619,32 @@ log_graph_fill(Application_Links *app, Rect_f32 layout_region, Face_ID face_id){
|
||||||
box_w*(bucket_with_next_event_index + 1), y_cursor + box_h);
|
box_w*(bucket_with_next_event_index + 1), y_cursor + box_h);
|
||||||
box_node->rect = rect;
|
box_node->rect = rect;
|
||||||
box_node->event = next_event;
|
box_node->event = next_event;
|
||||||
|
|
||||||
y_bottom = Max(y_bottom, rect.y1);
|
y_bottom = Max(y_bottom, rect.y1);
|
||||||
|
|
||||||
y_cursor += box_h;
|
y_cursor += box_h;
|
||||||
}
|
}
|
||||||
|
|
||||||
log_graph.max_y_scroll = clamp_bot(line_height, y_bottom - rect_height(event_list_region)*0.5f);
|
log_graph.max_y_scroll = clamp_bot(line_height, y_bottom - rect_height(event_list_region)*0.5f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
log_parse_fill(Application_Links *app, Buffer_ID buffer){
|
log_parse_fill(Application_Links *app, Buffer_ID buffer){
|
||||||
if (log_arena == 0){
|
if (log_arena == 0){
|
||||||
log_arena = reserve_arena(app);
|
log_arena = reserve_arena(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
linalloc_clear(log_arena);
|
linalloc_clear(log_arena);
|
||||||
block_zero_struct(&log_graph);
|
block_zero_struct(&log_graph);
|
||||||
log_filter_set_init(&log_filter_set);
|
log_filter_set_init(&log_filter_set);
|
||||||
log_filter_set_init(&log_preview_set);
|
log_filter_set_init(&log_preview_set);
|
||||||
|
|
||||||
String_Const_u8 log_text = push_whole_buffer(app, log_arena, buffer);
|
String_Const_u8 log_text = push_whole_buffer(app, log_arena, buffer);
|
||||||
log_parse = make_log_parse(log_arena, log_text);
|
log_parse = make_log_parse(log_arena, log_text);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
log_graph_render__tag(Arena *arena, Fancy_String_List *line, Log_Parse *log, Log_Tag *tag){
|
log_graph_render__tag(Arena *arena, Fancy_String_List *line, Log_Parse *log, Log_Tag *tag){
|
||||||
String_Const_u8 tag_name = log_parse__get_string(log, tag->name);
|
String_Const_u8 tag_name = log_parse__get_string(log, tag->name);
|
||||||
|
@ -660,10 +660,23 @@ log_graph_render__tag(Arena *arena, Fancy_String_List *line, Log_Parse *log, Log
|
||||||
}
|
}
|
||||||
push_fancy_stringf(arena, line, white, "]");
|
push_fancy_stringf(arena, line, white, "]");
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
log_graph_render(Application_Links *app, View_ID view, Frame_Info frame_info, Rect_f32 inner){
|
log_graph_render(Application_Links *app, Frame_Info frame_info, View_ID view){
|
||||||
if (log_parse.arena != 0){
|
if (log_parse.arena != 0){
|
||||||
|
////////////////////////////////
|
||||||
|
View_ID active_view = get_active_view(app, AccessAll);
|
||||||
|
b32 is_active_view = (active_view == view);
|
||||||
|
|
||||||
|
Rect_f32 view_rect = view_get_screen_rect(app, view);
|
||||||
|
Rect_f32 inner = rect_inner(view_rect, 3);
|
||||||
|
draw_rectangle(app, view_rect, 0.f,
|
||||||
|
get_margin_color(is_active_view?UIHighlight_Active:UIHighlight_None));
|
||||||
|
draw_rectangle(app, inner, 0.f, Stag_Back);
|
||||||
|
|
||||||
|
Rect_f32 prev_clip = draw_set_clip(app, inner);
|
||||||
|
////////////////////////////////
|
||||||
|
|
||||||
Face_ID face_id = get_face_id(app, 0);
|
Face_ID face_id = get_face_id(app, 0);
|
||||||
f32 y_scroll = log_graph.y_scroll;
|
f32 y_scroll = log_graph.y_scroll;
|
||||||
Log_Event *selected_event = log_graph.selected_event;
|
Log_Event *selected_event = log_graph.selected_event;
|
||||||
|
@ -675,28 +688,28 @@ log_graph_render(Application_Links *app, View_ID view, Frame_Info frame_info, Re
|
||||||
}
|
}
|
||||||
log_graph.y_scroll = clamp(0.f, y_scroll, log_graph.max_y_scroll);
|
log_graph.y_scroll = clamp(0.f, y_scroll, log_graph.max_y_scroll);
|
||||||
log_graph.selected_event = selected_event;
|
log_graph.selected_event = selected_event;
|
||||||
|
|
||||||
Mouse_State mouse = get_mouse_state(app);
|
Mouse_State mouse = get_mouse_state(app);
|
||||||
Vec2_f32 m_p = V2f32(mouse.p) - inner.p0;
|
Vec2_f32 m_p = V2f32(mouse.p) - inner.p0;
|
||||||
|
|
||||||
Face_Metrics metrics = get_face_metrics(app, log_graph.face_id);
|
Face_Metrics metrics = get_face_metrics(app, log_graph.face_id);
|
||||||
f32 line_height = metrics.line_height;
|
f32 line_height = metrics.line_height;
|
||||||
|
|
||||||
Log_Event *hover_event = 0;
|
Log_Event *hover_event = 0;
|
||||||
|
|
||||||
b32 in_details_region = (rect_contains_point(log_graph.details_region, m_p));
|
b32 in_details_region = (rect_contains_point(log_graph.details_region, m_p));
|
||||||
|
|
||||||
for (Log_Graph_Box *box_node = log_graph.first_box;
|
for (Log_Graph_Box *box_node = log_graph.first_box;
|
||||||
box_node != 0;
|
box_node != 0;
|
||||||
box_node = box_node->next){
|
box_node = box_node->next){
|
||||||
Scratch_Block scratch(app);
|
Scratch_Block scratch(app);
|
||||||
|
|
||||||
Rect_f32 box = box_node->rect;
|
Rect_f32 box = box_node->rect;
|
||||||
box.y0 -= log_graph.y_scroll;
|
box.y0 -= log_graph.y_scroll;
|
||||||
box.y1 -= log_graph.y_scroll;
|
box.y1 -= log_graph.y_scroll;
|
||||||
|
|
||||||
Rect_f32 box_inner = rect_inner(box, 3.f);
|
Rect_f32 box_inner = rect_inner(box, 3.f);
|
||||||
|
|
||||||
Fancy_Color margin_color = dark_gray;
|
Fancy_Color margin_color = dark_gray;
|
||||||
if (!in_details_region && hover_event == 0 && rect_contains_point(box, m_p)){
|
if (!in_details_region && hover_event == 0 && rect_contains_point(box, m_p)){
|
||||||
margin_color = gray;
|
margin_color = gray;
|
||||||
|
@ -705,16 +718,16 @@ log_graph_render(Application_Links *app, View_ID view, Frame_Info frame_info, Re
|
||||||
if (box_node->event == log_graph.selected_event){
|
if (box_node->event == log_graph.selected_event){
|
||||||
margin_color = light_gray;
|
margin_color = light_gray;
|
||||||
}
|
}
|
||||||
|
|
||||||
draw_rectangle_fancy(app, box , margin_color);
|
draw_rectangle_fancy(app, box , margin_color);
|
||||||
draw_rectangle_fancy(app, box_inner, black );
|
draw_rectangle_fancy(app, box_inner, black );
|
||||||
|
|
||||||
Log_Event *event = box_node->event;
|
Log_Event *event = box_node->event;
|
||||||
|
|
||||||
String_Const_u8 event_name = log_parse__get_string(&log_parse, event->event_name);
|
String_Const_u8 event_name = log_parse__get_string(&log_parse, event->event_name);
|
||||||
Fancy_String_List line = {};
|
Fancy_String_List line = {};
|
||||||
push_fancy_string(scratch, &line, white, event_name);
|
push_fancy_string(scratch, &line, white, event_name);
|
||||||
|
|
||||||
for (Log_Filter *filter = log_preview_set.first;
|
for (Log_Filter *filter = log_preview_set.first;
|
||||||
filter != 0;
|
filter != 0;
|
||||||
filter = filter->next){
|
filter = filter->next){
|
||||||
|
@ -728,29 +741,29 @@ log_graph_render(Application_Links *app, View_ID view, Frame_Info frame_info, Re
|
||||||
log_graph_render__tag(scratch, &line, &log_parse, tag);
|
log_graph_render__tag(scratch, &line, &log_parse, tag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Vec2_f32 p = V2f32(box_inner.x0 + 3.f,
|
Vec2_f32 p = V2f32(box_inner.x0 + 3.f,
|
||||||
(f32_round32((box_inner.y0 + box_inner.y1 - line_height)*0.5f)));
|
(f32_round32((box_inner.y0 + box_inner.y1 - line_height)*0.5f)));
|
||||||
draw_fancy_string(app, log_graph.face_id, line.first, p, 0, 0, 0, V2f32(1.f, 0.f));
|
draw_fancy_string(app, log_graph.face_id, line.first, p, 0, 0, 0, V2f32(1.f, 0.f));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
Scratch_Block scratch(app);
|
Scratch_Block scratch(app);
|
||||||
|
|
||||||
Rect_f32 box = log_graph.details_region;
|
Rect_f32 box = log_graph.details_region;
|
||||||
Rect_f32 box_inner = rect_inner(box, 3.f);
|
Rect_f32 box_inner = rect_inner(box, 3.f);
|
||||||
|
|
||||||
Log_Graph_List_Tab current_tab = log_graph.tab;
|
Log_Graph_List_Tab current_tab = log_graph.tab;
|
||||||
Log_Filter_Set *viewing_filter_set = log_filter_set_from_tab(current_tab);
|
Log_Filter_Set *viewing_filter_set = log_filter_set_from_tab(current_tab);
|
||||||
|
|
||||||
draw_rectangle_fancy(app, box , dark_gray);
|
draw_rectangle_fancy(app, box , dark_gray);
|
||||||
draw_rectangle_fancy(app, box_inner, black );
|
draw_rectangle_fancy(app, box_inner, black );
|
||||||
|
|
||||||
{
|
{
|
||||||
f32 y_cursor = box_inner.y0 + 3.f;
|
f32 y_cursor = box_inner.y0 + 3.f;
|
||||||
if (y_cursor + line_height > box_inner.y1) goto finish_list_display;
|
if (y_cursor + line_height > box_inner.y1) goto finish_list_display;
|
||||||
|
|
||||||
{
|
{
|
||||||
f32 x_cursor = box_inner.x0 + 3.f;
|
f32 x_cursor = box_inner.x0 + 3.f;
|
||||||
for (i32 i = LogTab_ERROR + 1; i < LogTab_COUNT; i += 1){
|
for (i32 i = LogTab_ERROR + 1; i < LogTab_COUNT; i += 1){
|
||||||
|
@ -766,13 +779,13 @@ log_graph_render(Application_Links *app, View_ID view, Frame_Info frame_info, Re
|
||||||
push_fancy_stringf(scratch, &line, color, "previews");
|
push_fancy_stringf(scratch, &line, color, "previews");
|
||||||
}break;
|
}break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec2_f32 p = V2f32(x_cursor, y_cursor);
|
Vec2_f32 p = V2f32(x_cursor, y_cursor);
|
||||||
f32 advance = get_fancy_string_advance(app, log_graph.face_id, line.first);
|
f32 advance = get_fancy_string_advance(app, log_graph.face_id, line.first);
|
||||||
draw_fancy_string(app, log_graph.face_id, line.first, p,
|
draw_fancy_string(app, log_graph.face_id, line.first, p,
|
||||||
Stag_Default, Stag_Back, 0, V2f32(1.f, 0.f));
|
Stag_Default, Stag_Back, 0, V2f32(1.f, 0.f));
|
||||||
x_cursor += advance + metrics.normal_advance;
|
x_cursor += advance + metrics.normal_advance;
|
||||||
|
|
||||||
if (log_graph.has_unused_click){
|
if (log_graph.has_unused_click){
|
||||||
Rect_f32 click_rect = Rf32(p.x, p.y, p.x + advance, p.y + line_height);
|
Rect_f32 click_rect = Rf32(p.x, p.y, p.x + advance, p.y + line_height);
|
||||||
if (rect_contains_point(click_rect, log_graph.unused_click)){
|
if (rect_contains_point(click_rect, log_graph.unused_click)){
|
||||||
|
@ -782,18 +795,18 @@ log_graph_render(Application_Links *app, View_ID view, Frame_Info frame_info, Re
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (viewing_filter_set != 0){
|
if (viewing_filter_set != 0){
|
||||||
for (Log_Filter *filter = viewing_filter_set->first, *next = 0;
|
for (Log_Filter *filter = viewing_filter_set->first, *next = 0;
|
||||||
filter != 0;
|
filter != 0;
|
||||||
filter = next){
|
filter = next){
|
||||||
next = filter->next;
|
next = filter->next;
|
||||||
|
|
||||||
y_cursor += line_height;
|
y_cursor += line_height;
|
||||||
if (y_cursor + line_height > box_inner.y1) goto finish_list_display;
|
if (y_cursor + line_height > box_inner.y1) goto finish_list_display;
|
||||||
|
|
||||||
Fancy_String_List line = {};
|
Fancy_String_List line = {};
|
||||||
|
|
||||||
if (filter->kind == LogFilter_TagValue){
|
if (filter->kind == LogFilter_TagValue){
|
||||||
push_fancy_stringf(scratch, &line, white, "val [");
|
push_fancy_stringf(scratch, &line, white, "val [");
|
||||||
String_Const_u8 tag_name = log_parse__get_string(&log_parse, filter->tag_name_code);
|
String_Const_u8 tag_name = log_parse__get_string(&log_parse, filter->tag_name_code);
|
||||||
|
@ -814,12 +827,12 @@ log_graph_render(Application_Links *app, View_ID view, Frame_Info frame_info, Re
|
||||||
push_fancy_stringf(scratch, &line, green, "%.*s", string_expand(tag_name));
|
push_fancy_stringf(scratch, &line, green, "%.*s", string_expand(tag_name));
|
||||||
push_fancy_stringf(scratch, &line, white, "]");
|
push_fancy_stringf(scratch, &line, white, "]");
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec2_f32 p = V2f32(box_inner.x0 + 3.f, y_cursor);
|
Vec2_f32 p = V2f32(box_inner.x0 + 3.f, y_cursor);
|
||||||
f32 advance = get_fancy_string_advance(app, log_graph.face_id, line.first);
|
f32 advance = get_fancy_string_advance(app, log_graph.face_id, line.first);
|
||||||
draw_fancy_string(app, log_graph.face_id, line.first, p, Stag_Default, Stag_Back,
|
draw_fancy_string(app, log_graph.face_id, line.first, p, Stag_Default, Stag_Back,
|
||||||
0, V2f32(1.f, 0.f));
|
0, V2f32(1.f, 0.f));
|
||||||
|
|
||||||
if (log_graph.has_unused_click){
|
if (log_graph.has_unused_click){
|
||||||
Rect_f32 click_rect = Rf32(p.x, p.y, p.x + advance, p.y + line_height);
|
Rect_f32 click_rect = Rf32(p.x, p.y, p.x + advance, p.y + line_height);
|
||||||
if (rect_contains_point(click_rect, log_graph.unused_click)){
|
if (rect_contains_point(click_rect, log_graph.unused_click)){
|
||||||
|
@ -829,45 +842,45 @@ log_graph_render(Application_Links *app, View_ID view, Frame_Info frame_info, Re
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
finish_list_display:;
|
finish_list_display:;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_Event *view_event = (hover_event!=0)?hover_event:log_graph.selected_event;
|
Log_Event *view_event = (hover_event!=0)?hover_event:log_graph.selected_event;
|
||||||
if (view_event != 0){
|
if (view_event != 0){
|
||||||
f32 y_cursor = box_inner.y0 + 3.f;
|
f32 y_cursor = box_inner.y0 + 3.f;
|
||||||
if (y_cursor + line_height > box_inner.y1) goto finish_event_display;
|
if (y_cursor + line_height > box_inner.y1) goto finish_event_display;
|
||||||
|
|
||||||
{
|
{
|
||||||
Fancy_String_List line = {};
|
Fancy_String_List line = {};
|
||||||
String_Const_u8 file_name = log_parse__get_string(&log_parse, view_event->src_file_name);
|
String_Const_u8 file_name = log_parse__get_string(&log_parse, view_event->src_file_name);
|
||||||
push_fancy_stringf(scratch, &line, green, "[%d] ", view_event->event_number);
|
push_fancy_stringf(scratch, &line, green, "[%d] ", view_event->event_number);
|
||||||
push_fancy_stringf(scratch, &line, white, "%.*s:", string_expand(file_name));
|
push_fancy_stringf(scratch, &line, white, "%.*s:", string_expand(file_name));
|
||||||
push_fancy_stringf(scratch, &line, pink, "%llu", view_event->line_number);
|
push_fancy_stringf(scratch, &line, pink, "%llu", view_event->line_number);
|
||||||
|
|
||||||
Vec2_f32 right_p = V2f32(box_inner.x1 - 3.f, y_cursor);
|
Vec2_f32 right_p = V2f32(box_inner.x1 - 3.f, y_cursor);
|
||||||
f32 advance = get_fancy_string_advance(app, log_graph.face_id, line.first);
|
f32 advance = get_fancy_string_advance(app, log_graph.face_id, line.first);
|
||||||
Vec2 p = V2f32(right_p.x - advance, right_p.y);
|
Vec2 p = V2f32(right_p.x - advance, right_p.y);
|
||||||
draw_fancy_string(app, log_graph.face_id, line.first, p, Stag_Default, Stag_Back,
|
draw_fancy_string(app, log_graph.face_id, line.first, p, Stag_Default, Stag_Back,
|
||||||
0, V2(1.f, 0.f));
|
0, V2(1.f, 0.f));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Log_Tag *tag = view_event->first_tag;
|
for (Log_Tag *tag = view_event->first_tag;
|
||||||
tag != 0;
|
tag != 0;
|
||||||
tag = tag->next){
|
tag = tag->next){
|
||||||
y_cursor += line_height;
|
y_cursor += line_height;
|
||||||
if (y_cursor + line_height > box_inner.y1) goto finish_event_display;
|
if (y_cursor + line_height > box_inner.y1) goto finish_event_display;
|
||||||
|
|
||||||
{
|
{
|
||||||
Fancy_String_List line = {};
|
Fancy_String_List line = {};
|
||||||
log_graph_render__tag(scratch, &line, &log_parse, tag);
|
log_graph_render__tag(scratch, &line, &log_parse, tag);
|
||||||
|
|
||||||
Vec2_f32 right_p = V2f32(box_inner.x1 - 3.f, y_cursor);
|
Vec2_f32 right_p = V2f32(box_inner.x1 - 3.f, y_cursor);
|
||||||
f32 advance = get_fancy_string_advance(app, log_graph.face_id, line.first);
|
f32 advance = get_fancy_string_advance(app, log_graph.face_id, line.first);
|
||||||
Vec2 p = V2f32(right_p.x - advance, right_p.y);
|
Vec2 p = V2f32(right_p.x - advance, right_p.y);
|
||||||
draw_fancy_string(app, log_graph.face_id, line.first, p,
|
draw_fancy_string(app, log_graph.face_id, line.first, p,
|
||||||
Stag_Default, Stag_Back, 0, V2(1.f, 0.f));
|
Stag_Default, Stag_Back, 0, V2(1.f, 0.f));
|
||||||
|
|
||||||
if (log_graph.has_unused_click){
|
if (log_graph.has_unused_click){
|
||||||
Rect_f32 click_rect = Rf32(p.x, p.y, right_p.x, p.y + line_height);
|
Rect_f32 click_rect = Rf32(p.x, p.y, right_p.x, p.y + line_height);
|
||||||
if (rect_contains_point(click_rect, log_graph.unused_click)){
|
if (rect_contains_point(click_rect, log_graph.unused_click)){
|
||||||
|
@ -894,12 +907,13 @@ log_graph_render(Application_Links *app, View_ID view, Frame_Info frame_info, Re
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
finish_event_display:;
|
finish_event_display:;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log_graph.has_unused_click = false;
|
log_graph.has_unused_click = false;
|
||||||
|
draw_set_clip(app, prev_clip);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -929,7 +943,7 @@ log_graph__get_box_at_mouse_point(Application_Links *app, Log_Graph *graph){
|
||||||
return(log_graph__get_box_at_point(graph, m_p));
|
return(log_graph__get_box_at_point(graph, m_p));
|
||||||
}
|
}
|
||||||
|
|
||||||
function void
|
function void
|
||||||
log_graph__click_select_event(Application_Links *app, Vec2_f32 m_p)
|
log_graph__click_select_event(Application_Links *app, Vec2_f32 m_p)
|
||||||
{
|
{
|
||||||
if (log_view != 0 && log_graph.holding_temp){
|
if (log_view != 0 && log_graph.holding_temp){
|
||||||
|
@ -944,14 +958,14 @@ log_graph__click_select_event(Application_Links *app, Vec2_f32 m_p)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function void
|
function void
|
||||||
log_graph__click_jump_to_event_source(Application_Links *app, Vec2_f32 m_p){
|
log_graph__click_jump_to_event_source(Application_Links *app, Vec2_f32 m_p){
|
||||||
if (log_view != 0 && log_graph.holding_temp){
|
if (log_view != 0 && log_graph.holding_temp){
|
||||||
Log_Graph_Box *box_node = log_graph__get_box_at_point(&log_graph, m_p);
|
Log_Graph_Box *box_node = log_graph__get_box_at_point(&log_graph, m_p);
|
||||||
if (box_node != 0){
|
if (box_node != 0){
|
||||||
Log_Event *event = box_node->event;
|
Log_Event *event = box_node->event;
|
||||||
log_graph.selected_event = event;
|
log_graph.selected_event = event;
|
||||||
|
|
||||||
View_ID target_view = get_next_view_looped_primary_panels(app, log_view, AccessProtected);
|
View_ID target_view = get_next_view_looped_primary_panels(app, log_view, AccessProtected);
|
||||||
if (target_view != 0){
|
if (target_view != 0){
|
||||||
String_Const_u8 file_name = log_parse__get_string(&log_parse, event->src_file_name);
|
String_Const_u8 file_name = log_parse__get_string(&log_parse, event->src_file_name);
|
||||||
|
@ -971,22 +985,7 @@ log_graph__click_jump_to_event_source(Application_Links *app, Vec2_f32 m_p){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
internal void
|
|
||||||
fill_log_graph_command_map(Mapping *mapping){
|
|
||||||
MappingScope();
|
|
||||||
SelectMapping(mapping);
|
|
||||||
SelectMap(default_log_graph_map);
|
|
||||||
//Bind(log_graph__escape, KeyCode_Escape);
|
|
||||||
//BindMouseWheel(log_graph__scroll_wheel);
|
|
||||||
//BindMouse(log_graph__click_jump_to_event_source, MouseCode_Left);
|
|
||||||
//BindMouse(log_graph__click_select_event, MouseCode_Right);
|
|
||||||
Bind(log_graph__page_up, KeyCode_PageUp);
|
|
||||||
Bind(log_graph__page_down, KeyCode_PageDown);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
CUSTOM_COMMAND_SIG(show_the_log_graph)
|
CUSTOM_COMMAND_SIG(show_the_log_graph)
|
||||||
CUSTOM_DOC("Parses *log* and displays the 'log graph' UI")
|
CUSTOM_DOC("Parses *log* and displays the 'log graph' UI")
|
||||||
{
|
{
|
||||||
|
@ -996,61 +995,60 @@ CUSTOM_DOC("Parses *log* and displays the 'log graph' UI")
|
||||||
if (log_view == 0){
|
if (log_view == 0){
|
||||||
log_view = get_active_view(app, AccessAll);
|
log_view = get_active_view(app, AccessAll);
|
||||||
}
|
}
|
||||||
Managed_Scope scope = view_get_managed_scope(app, log_view);
|
|
||||||
View_Render_Hook **hook = scope_attachment(app, scope, view_render_hook, View_Render_Hook*);
|
View_ID view = log_view;
|
||||||
*hook = log_graph_render;
|
View_Context ctx = view_current_context(app, log_view);
|
||||||
|
ctx.render_caller = log_graph_render;
|
||||||
for (;;){
|
view_push_context(app, log_view, &ctx);
|
||||||
User_Input in = get_user_input(app,
|
|
||||||
EventPropertyGroup_AnyUserInput,
|
for (;;){
|
||||||
KeyCode_Escape);
|
User_Input in = get_user_input(app, EventPropertyGroup_AnyUserInput, KeyCode_Escape);
|
||||||
if (in.abort){
|
if (in.abort){
|
||||||
log_view = 0;
|
log_view = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (in.event.kind){
|
switch (in.event.kind){
|
||||||
case InputEventKind_KeyStroke:
|
case InputEventKind_KeyStroke:
|
||||||
{
|
{
|
||||||
switch (in.event.key.code){
|
switch (in.event.key.code){
|
||||||
case KeyCode_PageUp:
|
case KeyCode_PageUp:
|
||||||
{
|
{
|
||||||
log_graph.y_scroll -= get_page_jump(app, log_view);
|
log_graph.y_scroll -= get_page_jump(app, log_view);
|
||||||
}break;
|
}break;
|
||||||
|
|
||||||
case KeyCode_PageDown:
|
case KeyCode_PageDown:
|
||||||
{
|
{
|
||||||
log_graph.y_scroll += get_page_jump(app, log_view);
|
log_graph.y_scroll += get_page_jump(app, log_view);
|
||||||
}break;
|
}break;
|
||||||
}
|
}
|
||||||
}break;
|
}break;
|
||||||
|
|
||||||
case InputEventKind_MouseButton:
|
case InputEventKind_MouseButton:
|
||||||
{
|
{
|
||||||
Vec2_f32 m_p = V2f32(in.event.mouse.p) - log_graph.layout_region.p0;
|
Vec2_f32 m_p = V2f32(in.event.mouse.p) - log_graph.layout_region.p0;
|
||||||
switch (in.event.mouse.code){
|
switch (in.event.mouse.code){
|
||||||
case MouseCode_Left:
|
case MouseCode_Left:
|
||||||
{
|
{
|
||||||
log_graph__click_jump_to_event_source(app, m_p);
|
log_graph__click_jump_to_event_source(app, m_p);
|
||||||
}break;
|
}break;
|
||||||
|
|
||||||
case MouseCode_Right:
|
case MouseCode_Right:
|
||||||
{
|
{
|
||||||
log_graph__click_select_event(app, m_p);
|
log_graph__click_select_event(app, m_p);
|
||||||
}break;
|
}break;
|
||||||
}
|
}
|
||||||
}break;
|
}break;
|
||||||
|
|
||||||
case InputEventKind_MouseWheel:
|
case InputEventKind_MouseWheel:
|
||||||
{
|
{
|
||||||
f32 value = in.event.mouse_wheel.value;
|
f32 value = in.event.mouse_wheel.value;
|
||||||
log_graph.y_scroll += f32_round32(value);
|
log_graph.y_scroll += f32_round32(value);
|
||||||
}break;
|
}break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
hook = scope_attachment(app, scope, view_render_hook, View_Render_Hook*);
|
view_pop_context(app, view);
|
||||||
*hook = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// BOTTOM
|
// BOTTOM
|
||||||
|
|
|
@ -101,8 +101,17 @@ STRUCT Character_Predicate{
|
||||||
u8 b[32];
|
u8 b[32];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct Frame_Info{
|
||||||
|
i32 index;
|
||||||
|
f32 literal_dt;
|
||||||
|
f32 animation_dt;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef void Render_Caller_Function(Application_Links *app, Frame_Info frame_info, View_ID view);
|
||||||
|
#define RENDER_CALLER_SIG(name) void name(Application_Links *app, Frame_Info frame_info, View_ID view)
|
||||||
|
|
||||||
struct View_Context{
|
struct View_Context{
|
||||||
Void_Func ctx_ptr;
|
Render_Caller_Function *render_caller;
|
||||||
b32 hides_buffer;
|
b32 hides_buffer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -472,14 +481,6 @@ STRUCT User_Input{
|
||||||
b32 abort;
|
b32 abort;
|
||||||
};
|
};
|
||||||
|
|
||||||
STRUCT Frame_Info{
|
|
||||||
i32 index;
|
|
||||||
f32 literal_dt;
|
|
||||||
f32 animation_dt;
|
|
||||||
};
|
|
||||||
|
|
||||||
TYPEDEF_FUNC void Render_Callback(struct Application_Links *app);
|
|
||||||
|
|
||||||
typedef i32 Hook_ID;
|
typedef i32 Hook_ID;
|
||||||
enum{
|
enum{
|
||||||
HookID_FileOutOfSync,
|
HookID_FileOutOfSync,
|
||||||
|
@ -505,9 +506,6 @@ enum{
|
||||||
TYPEDEF_FUNC i32 Hook_Function(struct Application_Links *app);
|
TYPEDEF_FUNC i32 Hook_Function(struct Application_Links *app);
|
||||||
#define HOOK_SIG(name) i32 name(struct Application_Links *app)
|
#define HOOK_SIG(name) i32 name(struct Application_Links *app)
|
||||||
|
|
||||||
TYPEDEF_FUNC void Render_Caller_Function(struct Application_Links *app, Frame_Info frame_info);
|
|
||||||
#define RENDER_CALLER_SIG(name) void name(struct Application_Links *app, Frame_Info frame_info)
|
|
||||||
|
|
||||||
TYPEDEF_FUNC i32 Buffer_Hook_Function(struct Application_Links *app, Buffer_ID buffer_id);
|
TYPEDEF_FUNC i32 Buffer_Hook_Function(struct Application_Links *app, Buffer_ID buffer_id);
|
||||||
#define BUFFER_HOOK_SIG(name) i32 name(struct Application_Links *app, Buffer_ID buffer_id)
|
#define BUFFER_HOOK_SIG(name) i32 name(struct Application_Links *app, Buffer_ID buffer_id)
|
||||||
|
|
||||||
|
|
|
@ -372,7 +372,7 @@ static Command_Metadata fcoder_metacmd_table[202] = {
|
||||||
{ PROC_LINKS(if_read_only_goto_position, 0), "if_read_only_goto_position", 26, "If the buffer in the active view is writable, inserts a character, otherwise performs goto_jump_at_cursor.", 106, "w:\\4ed\\code\\custom\\4coder_jump_sticky.cpp", 41, 562 },
|
{ PROC_LINKS(if_read_only_goto_position, 0), "if_read_only_goto_position", 26, "If the buffer in the active view is writable, inserts a character, otherwise performs goto_jump_at_cursor.", 106, "w:\\4ed\\code\\custom\\4coder_jump_sticky.cpp", 41, 562 },
|
||||||
{ PROC_LINKS(if_read_only_goto_position_same_panel, 0), "if_read_only_goto_position_same_panel", 37, "If the buffer in the active view is writable, inserts a character, otherwise performs goto_jump_at_cursor_same_panel.", 117, "w:\\4ed\\code\\custom\\4coder_jump_sticky.cpp", 41, 579 },
|
{ PROC_LINKS(if_read_only_goto_position_same_panel, 0), "if_read_only_goto_position_same_panel", 37, "If the buffer in the active view is writable, inserts a character, otherwise performs goto_jump_at_cursor_same_panel.", 117, "w:\\4ed\\code\\custom\\4coder_jump_sticky.cpp", 41, 579 },
|
||||||
{ PROC_LINKS(view_jump_list_with_lister, 0), "view_jump_list_with_lister", 26, "When executed on a buffer with jumps, creates a persistent lister for all the jumps", 83, "w:\\4ed\\code\\custom\\4coder_jump_lister.cpp", 41, 102 },
|
{ PROC_LINKS(view_jump_list_with_lister, 0), "view_jump_list_with_lister", 26, "When executed on a buffer with jumps, creates a persistent lister for all the jumps", 83, "w:\\4ed\\code\\custom\\4coder_jump_lister.cpp", 41, 102 },
|
||||||
{ PROC_LINKS(show_the_log_graph, 0), "show_the_log_graph", 18, "Parses *log* and displays the 'log graph' UI", 44, "w:\\4ed\\code\\custom\\4coder_log_parser.cpp", 40, 990 },
|
{ PROC_LINKS(show_the_log_graph, 0), "show_the_log_graph", 18, "Parses *log* and displays the 'log graph' UI", 44, "w:\\4ed\\code\\custom\\4coder_log_parser.cpp", 40, 989 },
|
||||||
{ PROC_LINKS(copy, 0), "copy", 4, "Copy the text in the range from the cursor to the mark onto the clipboard.", 74, "w:\\4ed\\code\\custom\\4coder_clipboard.cpp", 39, 19 },
|
{ PROC_LINKS(copy, 0), "copy", 4, "Copy the text in the range from the cursor to the mark onto the clipboard.", 74, "w:\\4ed\\code\\custom\\4coder_clipboard.cpp", 39, 19 },
|
||||||
{ PROC_LINKS(cut, 0), "cut", 3, "Cut the text in the range from the cursor to the mark onto the clipboard.", 73, "w:\\4ed\\code\\custom\\4coder_clipboard.cpp", 39, 28 },
|
{ PROC_LINKS(cut, 0), "cut", 3, "Cut the text in the range from the cursor to the mark onto the clipboard.", 73, "w:\\4ed\\code\\custom\\4coder_clipboard.cpp", 39, 28 },
|
||||||
{ PROC_LINKS(paste, 0), "paste", 5, "At the cursor, insert the text at the top of the clipboard.", 59, "w:\\4ed\\code\\custom\\4coder_clipboard.cpp", 39, 39 },
|
{ PROC_LINKS(paste, 0), "paste", 5, "At the cursor, insert the text at the top of the clipboard.", 59, "w:\\4ed\\code\\custom\\4coder_clipboard.cpp", 39, 39 },
|
||||||
|
|
Loading…
Reference in New Issue