eliminate margin from output

This commit is contained in:
Ryan Fleury
2024-06-26 11:01:51 -07:00
parent 3d272a598b
commit 6e2353d302
2 changed files with 24 additions and 8 deletions
+16 -7
View File
@@ -432,7 +432,7 @@ df_code_view_cmds(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_CodeViewStat
} }
internal void internal void
df_code_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_CodeViewState *cv, Rng2F32 rect, String8 text_data, TXT_TextInfo *text_info, DASM_InstArray *dasm_insts, Rng1U64 dasm_vaddr_range, DI_Key dasm_dbgi_key) df_code_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_CodeViewState *cv, DF_CodeViewFlags flags, Rng2F32 rect, String8 text_data, TXT_TextInfo *text_info, DASM_InstArray *dasm_insts, Rng1U64 dasm_vaddr_range, DI_Key dasm_dbgi_key)
{ {
ProfBeginFunction(); ProfBeginFunction();
Temp scratch = scratch_begin(0, 0); Temp scratch = scratch_begin(0, 0);
@@ -500,9 +500,14 @@ df_code_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_CodeViewSta
////////////////////////////// //////////////////////////////
//- rjf: calculate line-range-dependent info //- rjf: calculate line-range-dependent info
// //
F32 priority_margin_width_px = big_glyph_advance*3.5f;
F32 catchall_margin_width_px = big_glyph_advance*3.5f;
F32 line_num_width_px = big_glyph_advance * (log10(visible_line_num_range.max) + 3); F32 line_num_width_px = big_glyph_advance * (log10(visible_line_num_range.max) + 3);
F32 priority_margin_width_px = 0;
F32 catchall_margin_width_px = 0;
if(flags & DF_CodeViewFlag_Margins)
{
priority_margin_width_px = big_glyph_advance*3.5f;
catchall_margin_width_px = big_glyph_advance*3.5f;
}
TXT_LineTokensSlice slice = txt_line_tokens_slice_from_info_data_line_range(scratch.arena, text_info, text_data, visible_line_num_range); TXT_LineTokensSlice slice = txt_line_tokens_slice_from_info_data_line_range(scratch.arena, text_info, text_data, visible_line_num_range);
////////////////////////////// //////////////////////////////
@@ -528,7 +533,11 @@ df_code_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_CodeViewSta
DF_CodeSliceParams code_slice_params = {0}; DF_CodeSliceParams code_slice_params = {0};
{ {
// rjf: fill basics // rjf: fill basics
code_slice_params.flags = DF_CodeSliceFlag_PriorityMargin|DF_CodeSliceFlag_CatchallMargin|DF_CodeSliceFlag_LineNums|DF_CodeSliceFlag_Clickable; code_slice_params.flags = DF_CodeSliceFlag_LineNums|DF_CodeSliceFlag_Clickable;
if(flags & DF_CodeViewFlag_Margins)
{
code_slice_params.flags |= DF_CodeSliceFlag_PriorityMargin|DF_CodeSliceFlag_CatchallMargin;
}
code_slice_params.line_num_range = visible_line_num_range; code_slice_params.line_num_range = visible_line_num_range;
code_slice_params.line_text = push_array(scratch.arena, String8, visible_line_count); code_slice_params.line_text = push_array(scratch.arena, String8, visible_line_count);
code_slice_params.line_ranges = push_array(scratch.arena, Rng1U64, visible_line_count); code_slice_params.line_ranges = push_array(scratch.arena, Rng1U64, visible_line_count);
@@ -6423,7 +6432,7 @@ DF_VIEW_UI_FUNCTION_DEF(Code)
// //
if(!entity_is_missing && key_has_data) if(!entity_is_missing && key_has_data)
{ {
df_code_view_build(ws, panel, view, cv, code_area_rect, data, &info, 0, r1u64(0, 0), di_key_zero()); df_code_view_build(ws, panel, view, cv, DF_CodeViewFlag_All, code_area_rect, data, &info, 0, r1u64(0, 0), di_key_zero());
} }
////////////////////////////// //////////////////////////////
@@ -6673,7 +6682,7 @@ DF_VIEW_UI_FUNCTION_DEF(Disassembly)
// //
if(!is_loading && has_disasm) if(!is_loading && has_disasm)
{ {
df_code_view_build(ws, panel, view, cv, code_area_rect, dasm_text_data, &dasm_text_info, &dasm_info.insts, dasm_vaddr_range, dasm_dbgi_key); df_code_view_build(ws, panel, view, cv, DF_CodeViewFlag_All, code_area_rect, dasm_text_data, &dasm_text_info, &dasm_info.insts, dasm_vaddr_range, dasm_dbgi_key);
} }
////////////////////////////// //////////////////////////////
@@ -6953,7 +6962,7 @@ DF_VIEW_UI_FUNCTION_DEF(Output)
//- rjf: build code contents //- rjf: build code contents
// //
{ {
df_code_view_build(ws, panel, view, cv, code_area_rect, data, &info, 0, r1u64(0, 0), di_key_zero()); df_code_view_build(ws, panel, view, cv, 0, code_area_rect, data, &info, 0, r1u64(0, 0), di_key_zero());
} }
////////////////////////////// //////////////////////////////
+8 -1
View File
@@ -361,6 +361,13 @@ struct DF_WatchViewState
//////////////////////////////// ////////////////////////////////
//~ rjf: Code, Output @view_types //~ rjf: Code, Output @view_types
typedef U32 DF_CodeViewFlags;
enum
{
DF_CodeViewFlag_Margins = (1<<0),
DF_CodeViewFlag_All = 0xffffffff,
};
typedef struct DF_CodeViewState DF_CodeViewState; typedef struct DF_CodeViewState DF_CodeViewState;
struct DF_CodeViewState struct DF_CodeViewState
{ {
@@ -458,7 +465,7 @@ internal void df_entity_lister_item_array_sort_by_strength__in_place(DF_EntityLi
internal void df_code_view_init(DF_CodeViewState *cv, DF_View *view); internal void df_code_view_init(DF_CodeViewState *cv, DF_View *view);
internal void df_code_view_cmds(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_CodeViewState *cv, DF_CmdList *cmds, String8 text_data, TXT_TextInfo *text_info, DASM_InstArray *dasm_insts, Rng1U64 dasm_vaddr_range, DI_Key dasm_dbgi_key); internal void df_code_view_cmds(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_CodeViewState *cv, DF_CmdList *cmds, String8 text_data, TXT_TextInfo *text_info, DASM_InstArray *dasm_insts, Rng1U64 dasm_vaddr_range, DI_Key dasm_dbgi_key);
internal void df_code_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_CodeViewState *cv, Rng2F32 rect, String8 text_data, TXT_TextInfo *text_info, DASM_InstArray *dasm_insts, Rng1U64 dasm_vaddr_range, DI_Key dasm_dbgi_key); internal void df_code_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_CodeViewState *cv, DF_CodeViewFlags flags, Rng2F32 rect, String8 text_data, TXT_TextInfo *text_info, DASM_InstArray *dasm_insts, Rng1U64 dasm_vaddr_range, DI_Key dasm_dbgi_key);
//////////////////////////////// ////////////////////////////////
//~ rjf: Watch Views //~ rjf: Watch Views