From 0904de74ded0f626a88d3bcf6e1414cc12b6e2c5 Mon Sep 17 00:00:00 2001 From: Ryan Fleury Date: Wed, 26 Jun 2024 10:07:26 -0700 Subject: [PATCH] eliminate old duplicative code/output views --- src/df/gfx/df_views.c | 1700 ----------------------------------------- 1 file changed, 1700 deletions(-) diff --git a/src/df/gfx/df_views.c b/src/df/gfx/df_views.c index aaad81a2..dd8107e0 100644 --- a/src/df/gfx/df_views.c +++ b/src/df/gfx/df_views.c @@ -6169,7 +6169,6 @@ DF_VIEW_UI_FUNCTION_DEF(PendingEntity) //////////////////////////////// //~ rjf: Code @view_hook_impl -#if 1 DF_VIEW_SETUP_FUNCTION_DEF(Code) { // rjf: set up state @@ -6399,1086 +6398,6 @@ DF_VIEW_UI_FUNCTION_DEF(Code) hs_scope_close(hs_scope); scratch_end(scratch); } -#endif - -//~ TODO(rjf): OLD vvvvvvvv @src_collapse - -#if 0 -DF_VIEW_SETUP_FUNCTION_DEF(Code) -{ - // rjf: set up state - DF_CodeViewState *tv = df_view_user_state(view, DF_CodeViewState); - if(tv->initialized == 0) - { - tv->initialized = 1; - tv->cursor = tv->mark = txt_pt(1, 1); - tv->preferred_column = 1; - tv->find_text_arena = df_view_push_arena_ext(view); - } - - // rjf: deserialize cursor - DF_CfgNode *cursor_cfg = df_cfg_node_child_from_string(cfg_root, str8_lit("cursor"), StringMatchFlag_CaseInsensitive); - if(cursor_cfg != &df_g_nil_cfg_node) - { - TxtPt cursor = txt_pt(1, 1); - cursor.line = s64_from_str8(cursor_cfg->first->string, 10); - cursor.column = s64_from_str8(cursor_cfg->first->first->string, 10); - if(cursor.line == 0) { cursor.line = 1; } - if(cursor.column == 0) { cursor.column = 1; } - tv->cursor = tv->mark = cursor; - tv->center_cursor = 1; - } - - // rjf: default to loading - df_view_equip_loading_info(view, 1, 0, 0); - view->loading_t = view->loading_t_target = 1.f; -} - -DF_VIEW_STRING_FROM_STATE_FUNCTION_DEF(Code) -{ - DF_CodeViewState *tvs = df_view_user_state(view, DF_CodeViewState); - String8 string = push_str8f(arena, " cursor:%I64d:%I64d", tvs->cursor.line, tvs->cursor.column); - return string; -} - -DF_VIEW_CMD_FUNCTION_DEF(Code) -{ - DF_CodeViewState *tv = df_view_user_state(view, DF_CodeViewState); - DF_Entity *entity = df_entity_from_handle(view->entity); - for(DF_CmdNode *n = cmds->first; n != 0; n = n->next) - { - DF_Cmd *cmd = &n->cmd; - - // rjf: mismatched window/panel => skip - if(df_window_from_handle(cmd->params.window) != ws || - df_panel_from_handle(cmd->params.panel) != panel) - { - continue; - } - - // rjf: process - DF_CoreCmdKind core_cmd_kind = df_core_cmd_kind_from_string(cmd->spec->info.string); - switch(core_cmd_kind) - { - default: break; - case DF_CoreCmdKind_GoToLine: - { - tv->goto_line_num = cmd->params.text_point.line; - }break; - case DF_CoreCmdKind_CenterCursor: - { - tv->center_cursor = 1; - }break; - case DF_CoreCmdKind_ContainCursor: - { - tv->contain_cursor = 1; - }break; - case DF_CoreCmdKind_FindTextForward: - { - arena_clear(tv->find_text_arena); - tv->find_text_fwd = push_str8_copy(tv->find_text_arena, cmd->params.string); - }break; - case DF_CoreCmdKind_FindTextBackward: - { - arena_clear(tv->find_text_arena); - tv->find_text_bwd = push_str8_copy(tv->find_text_arena, cmd->params.string); - }break; - case DF_CoreCmdKind_ToggleBreakpointAtCursor: - { - DF_CmdParams params = df_cmd_params_from_view(ws, panel, view); - params.entity = view->entity; - params.text_point = tv->cursor; - df_push_cmd__root(¶ms, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_TextBreakpoint)); - tv->contain_cursor = 1; - }break; - case DF_CoreCmdKind_ToggleWatchPinAtCursor: - { - DF_CmdParams params = df_cmd_params_from_view(ws, panel, view); - params.entity = view->entity; - params.text_point = tv->cursor; - params.string = cmd->params.string; - df_push_cmd__root(¶ms, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_ToggleWatchPin)); - tv->contain_cursor = 1; - }break; - case DF_CoreCmdKind_RunToCursor: - { - DF_CmdParams params = df_cmd_params_from_view(ws, panel, view); - params.entity = view->entity; - params.text_point = tv->cursor; - df_push_cmd__root(¶ms, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_RunToLine)); - }break; - case DF_CoreCmdKind_SetNextStatement: - { - Temp scratch = scratch_begin(0, 0); - DF_Entity *thread = df_entity_from_handle(cmd->params.entity); - S64 line_num = (cmd->params.text_point.line == 0 ? tv->cursor.line : cmd->params.text_point.line); - DF_TextLineSrc2DasmInfoListArray src2dasm = df_text_line_src2dasm_info_list_array_from_src_line_range(scratch.arena, entity, r1s64(line_num, line_num)); - if(!df_entity_is_nil(thread) && src2dasm.count != 0) - { - DF_TextLineSrc2DasmInfoList *src2dasm_list = &src2dasm.v[0]; - if(src2dasm_list->first != 0) - { - Rng1U64 voff_rng = src2dasm_list->first->v.voff_range; - DI_Key dbgi_key = src2dasm_list->first->v.dbgi_key; - DF_EntityList possible_modules = df_modules_from_dbgi_key(scratch.arena, &dbgi_key); - DF_Entity *thread_dst_module = df_module_from_thread_candidates(thread, &possible_modules); - U64 thread_dst_voff = voff_rng.min; - if(!df_entity_is_nil(thread_dst_module) && thread_dst_voff != 0) - { - DF_CmdParams params = df_cmd_params_from_window(ws); - params.entity = df_handle_from_entity(thread); - params.vaddr = df_vaddr_from_voff(thread_dst_module, thread_dst_voff); - df_cmd_params_mark_slot(¶ms, DF_CmdParamSlot_Entity); - df_cmd_params_mark_slot(¶ms, DF_CmdParamSlot_VirtualAddr); - df_push_cmd__root(¶ms, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_SetThreadIP)); - } - } - } - scratch_end(scratch); - }break; - case DF_CoreCmdKind_GoToNameAtCursor: - { - Temp scratch = scratch_begin(0, 0); - TXT_Scope *txt_scope = txt_scope_open(); - HS_Scope *hs_scope = hs_scope_open(); - { - // rjf: unpack entity info - String8 path = df_full_path_from_entity(scratch.arena, entity); - U128 key = fs_key_from_path(path); - TXT_LangKind lang_kind = txt_lang_kind_from_extension(str8_skip_last_dot(path)); - U128 hash = {0}; - TXT_TextInfo text_info = txt_text_info_from_key_lang(txt_scope, key, lang_kind, &hash); - String8 data = hs_data_from_hash(hs_scope, hash); - - // rjf: determine expression range - Rng1U64 expr_range = {0}; - { - TxtRng selection_range = txt_rng(tv->cursor, tv->mark); - if(txt_pt_match(selection_range.min, selection_range.max)) - { - expr_range = txt_expr_off_range_from_info_data_pt(&text_info, data, tv->cursor); - } - else - { - expr_range = r1u64(txt_off_from_info_pt(&text_info, selection_range.min), txt_off_from_info_pt(&text_info, selection_range.max)); - } - } - - // rjf: expression range -> text - String8 expr_text = str8_substr(data, expr_range); - - // rjf: go to name - DF_CmdParams params = df_cmd_params_from_view(ws, panel, view); - params.entity = df_handle_from_entity(entity); - params.string = expr_text; - df_cmd_params_mark_slot(¶ms, DF_CmdParamSlot_String); - df_push_cmd__root(¶ms, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_GoToName)); - } - hs_scope_close(hs_scope); - txt_scope_close(txt_scope); - scratch_end(scratch); - }break; - case DF_CoreCmdKind_ToggleWatchExpressionAtCursor: - { - Temp scratch = scratch_begin(0, 0); - TXT_Scope *txt_scope = txt_scope_open(); - HS_Scope *hs_scope = hs_scope_open(); - { - // rjf: unpack entity info - String8 path = df_full_path_from_entity(scratch.arena, entity); - U128 key = fs_key_from_path(path); - TXT_LangKind lang_kind = txt_lang_kind_from_extension(str8_skip_last_dot(path)); - U128 hash = {0}; - TXT_TextInfo text_info = txt_text_info_from_key_lang(txt_scope, key, lang_kind, &hash); - String8 data = hs_data_from_hash(hs_scope, hash); - - // rjf: determine expression range - Rng1U64 expr_range = {0}; - { - TxtRng selection_range = txt_rng(tv->cursor, tv->mark); - if(txt_pt_match(selection_range.min, selection_range.max)) - { - expr_range = txt_expr_off_range_from_info_data_pt(&text_info, data, tv->cursor); - } - else - { - expr_range = r1u64(txt_off_from_info_pt(&text_info, selection_range.min), txt_off_from_info_pt(&text_info, selection_range.max)); - } - } - - // rjf: expression range -> text - String8 expr_text = str8_substr(data, expr_range); - - // rjf: toggle watch expr - DF_CmdParams params = df_cmd_params_from_view(ws, panel, view); - params.string = expr_text; - df_cmd_params_mark_slot(¶ms, DF_CmdParamSlot_String); - df_push_cmd__root(¶ms, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_ToggleWatchExpression)); - scratch_end(scratch); - } - hs_scope_close(hs_scope); - txt_scope_close(txt_scope); - scratch_end(scratch); - }break; - case DF_CoreCmdKind_PickFile: - { - DF_Entity *missing_file = df_entity_from_handle(tv->pick_file_override_target); - String8 pick_string = cmd->params.file_path; - if(!df_entity_is_nil(missing_file) && pick_string.size != 0) - { - DF_Entity *replacement = df_entity_from_path(pick_string, DF_EntityFromPathFlag_OpenAsNeeded|DF_EntityFromPathFlag_OpenMissing); - view->entity = df_handle_from_entity(replacement); - DF_CmdParams p = df_cmd_params_from_view(ws, panel, view); - p.entity = df_handle_from_entity(missing_file); - p.file_path = pick_string; - df_cmd_params_mark_slot(&p, DF_CmdParamSlot_Entity); - df_cmd_params_mark_slot(&p, DF_CmdParamSlot_FilePath); - df_push_cmd__root(&p, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_SetFileReplacementPath)); - } - }break; - } - } -} - -DF_VIEW_UI_FUNCTION_DEF(Code) -{ - ProfBeginFunction(); - Temp scratch = scratch_begin(0, 0); - HS_Scope *hs_scope = hs_scope_open(); - DI_Scope *di_scope = di_scope_open(); - TXT_Scope *txt_scope = txt_scope_open(); - DF_CodeViewState *tv = df_view_user_state(view, DF_CodeViewState); - - ////////////////////////////// - //- rjf: extract invariants - // - DF_Entity *entity = df_entity_from_handle(view->entity); - DF_CtrlCtx ctrl_ctx = df_ctrl_ctx_from_view(ws, view); - F_Tag code_font = df_font_from_slot(DF_FontSlot_Code); - F32 code_font_size = df_font_size_from_slot(ws, DF_FontSlot_Code); - F32 code_tab_size = f_column_size_from_tag_size(code_font, code_font_size)*df_setting_val_from_code(DF_SettingCode_TabWidth).s32; - F_Metrics code_font_metrics = f_metrics_from_tag_size(code_font, code_font_size); - F32 code_line_height = ceil_f32(f_line_height_from_metrics(&code_font_metrics) * 1.5f); - F32 big_glyph_advance = f_dim_from_tag_size_string(code_font, code_font_size, 0, 0, str8_lit("H")).x; - Vec2F32 panel_box_dim = dim_2f32(rect); - Vec2F32 bottom_bar_dim = {panel_box_dim.x, ui_em(1.8f, 0).value}; - F32 scroll_bar_dim = floor_f32(ui_top_font_size()*1.5f); - Vec2F32 code_area_dim = v2f32(panel_box_dim.x - scroll_bar_dim, panel_box_dim.y - scroll_bar_dim - bottom_bar_dim.y); - S64 num_possible_visible_lines = (S64)(code_area_dim.y/code_line_height)+1; - - ////////////////////////////// - //- rjf: unpack ctrl ctx & make parse ctx - // - DF_Entity *thread = df_entity_from_handle(ctrl_ctx.thread); - U64 unwind_count = ctrl_ctx.unwind_count; - U64 rip_vaddr = df_query_cached_rip_from_thread_unwind(thread, unwind_count); - DF_Entity *process = df_entity_ancestor_from_kind(thread, DF_EntityKind_Process); - EVAL_ParseCtx parse_ctx = df_eval_parse_ctx_from_process_vaddr(di_scope, process, rip_vaddr); - - ////////////////////////////// - //- rjf: unpack file/text entity info - // - B32 entity_is_missing = !!(entity->flags & DF_EntityFlag_IsMissing && !(entity->flags & DF_EntityFlag_Output)); - String8 path = df_full_path_from_entity(scratch.arena, entity); - df_interact_regs()->text_key = fs_key_from_path(path); - df_interact_regs()->lang_kind = txt_lang_kind_from_extension(str8_skip_last_dot(path)); - U128 hash = {0}; - TXT_TextInfo text_info = txt_text_info_from_key_lang(txt_scope, df_interact_regs()->text_key, df_interact_regs()->lang_kind, &hash); - String8 data = hs_data_from_hash(hs_scope, hash); - B32 text_info_is_ready = (text_info.lines_count != 0); - - ////////////////////////////// - //- rjf: buffer is pending -> equip view with loading information - // - if(!entity_is_missing && !text_info_is_ready) - { - df_view_equip_loading_info(view, 1, text_info.bytes_processed, text_info.bytes_to_process); - } - - ////////////////////////////// - //- rjf: determine visible line range / count - // - Rng1S64 visible_line_num_range = r1s64(view->scroll_pos.y.idx + (S64)(view->scroll_pos.y.off) + 1 - !!(view->scroll_pos.y.off < 0), - view->scroll_pos.y.idx + (S64)(view->scroll_pos.y.off) + 1 + num_possible_visible_lines); - Rng1S64 target_visible_line_num_range = r1s64(view->scroll_pos.y.idx + 1, - view->scroll_pos.y.idx + 1 + num_possible_visible_lines); - U64 visible_line_count = 0; - { - visible_line_num_range.min = Clamp(1, visible_line_num_range.min, (S64)text_info.lines_count); - visible_line_num_range.max = Clamp(1, visible_line_num_range.max, (S64)text_info.lines_count); - visible_line_num_range.min = Max(1, visible_line_num_range.min); - visible_line_num_range.max = Max(1, visible_line_num_range.max); - target_visible_line_num_range.min = Clamp(1, target_visible_line_num_range.min, (S64)text_info.lines_count); - target_visible_line_num_range.max = Clamp(1, target_visible_line_num_range.max, (S64)text_info.lines_count); - target_visible_line_num_range.min = Max(1, target_visible_line_num_range.min); - target_visible_line_num_range.max = Max(1, target_visible_line_num_range.max); - visible_line_count = (U64)dim_1s64(visible_line_num_range)+1; - } - - ////////////////////////////// - //- rjf: calculate scroll bounds - // - S64 line_size_x = 0; - Rng1S64 scroll_idx_rng[Axis2_COUNT] = {0}; - { - line_size_x = (text_info.lines_max_size*big_glyph_advance*3)/2; - line_size_x = ClampBot(line_size_x, (S64)big_glyph_advance*120); - line_size_x = ClampBot(line_size_x, (S64)code_area_dim.x); - scroll_idx_rng[Axis2_X] = r1s64(0, line_size_x-(S64)code_area_dim.x); - scroll_idx_rng[Axis2_Y] = r1s64(0, (S64)text_info.lines_count-1); - } - - ////////////////////////////// - //- 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); - TXT_LineTokensSlice slice = txt_line_tokens_slice_from_info_data_line_range(scratch.arena, &text_info, data, visible_line_num_range); - - ////////////////////////////// - //- rjf: get active search query - // - String8 search_query = {0}; - Side search_query_side = Side_Invalid; - B32 search_query_is_active = 0; - { - DF_CoreCmdKind query_cmd_kind = df_core_cmd_kind_from_string(ws->query_cmd_spec->info.string); - if(query_cmd_kind == DF_CoreCmdKind_FindTextForward || - query_cmd_kind == DF_CoreCmdKind_FindTextBackward) - { - search_query = str8(ws->query_view_stack_top->query_buffer, ws->query_view_stack_top->query_string_size); - search_query_is_active = 1; - search_query_side = (query_cmd_kind == DF_CoreCmdKind_FindTextForward) ? Side_Max : Side_Min; - } - } - - ////////////////////////////// - //- rjf: prepare code slice info bundle, for the viewable region of text - // - DF_CodeSliceParams code_slice_params = {0}; - if(text_info_is_ready) - { - // rjf: fill basics - code_slice_params.flags = DF_CodeSliceFlag_PriorityMargin|DF_CodeSliceFlag_CatchallMargin|DF_CodeSliceFlag_LineNums|DF_CodeSliceFlag_Clickable; - 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_ranges = push_array(scratch.arena, Rng1U64, visible_line_count); - code_slice_params.line_tokens = push_array(scratch.arena, TXT_TokenArray, visible_line_count); - code_slice_params.line_bps = push_array(scratch.arena, DF_EntityList, visible_line_count); - code_slice_params.line_ips = push_array(scratch.arena, DF_EntityList, visible_line_count); - code_slice_params.line_pins = push_array(scratch.arena, DF_EntityList, visible_line_count); - code_slice_params.line_vaddrs = push_array(scratch.arena, U64, visible_line_count); - code_slice_params.line_dasm2src = push_array(scratch.arena, DF_TextLineDasm2SrcInfoList, visible_line_count); - code_slice_params.line_src2dasm = push_array(scratch.arena, DF_TextLineSrc2DasmInfoList, visible_line_count); - code_slice_params.font = code_font; - code_slice_params.font_size = code_font_size; - code_slice_params.tab_size = code_tab_size; - code_slice_params.line_height_px = code_line_height; - code_slice_params.search_query = search_query; - code_slice_params.priority_margin_width_px = priority_margin_width_px; - code_slice_params.catchall_margin_width_px = catchall_margin_width_px; - code_slice_params.line_num_width_px = line_num_width_px; - code_slice_params.line_text_max_width_px = (F32)line_size_x; - code_slice_params.margin_float_off_px = view->scroll_pos.x.idx + view->scroll_pos.x.off; - - // rjf: fill text info - { - S64 line_num = visible_line_num_range.min; - U64 line_idx = visible_line_num_range.min-1; - for(U64 visible_line_idx = 0; visible_line_idx < visible_line_count; visible_line_idx += 1, line_idx += 1, line_num += 1) - { - code_slice_params.line_text[visible_line_idx] = str8_substr(data, text_info.lines_ranges[line_idx]); - code_slice_params.line_ranges[visible_line_idx] = text_info.lines_ranges[line_idx]; - code_slice_params.line_tokens[visible_line_idx] = slice.line_tokens[visible_line_idx]; - } - } - - // rjf: find visible breakpoints - ProfScope("find visible breakpoints") - { - for(DF_Entity *bp = entity->first; !df_entity_is_nil(bp); bp = bp->next) - { - if(bp->deleted || bp->kind != DF_EntityKind_Breakpoint) { continue; } - if(visible_line_num_range.min <= bp->text_point.line && bp->text_point.line <= visible_line_num_range.max) - { - U64 slice_line_idx = (bp->text_point.line-visible_line_num_range.min); - df_entity_list_push(scratch.arena, &code_slice_params.line_bps[slice_line_idx], bp); - } - } - } - - // rjf: find live threads mapping to this file - ProfScope("find live threads mapping to this file") - { - DF_Entity *selected_thread = df_entity_from_handle(ctrl_ctx.thread); - DF_EntityList threads = df_query_cached_entity_list_with_kind(DF_EntityKind_Thread); - for(DF_EntityNode *thread_n = threads.first; thread_n != 0; thread_n = thread_n->next) - { - DF_Entity *thread = thread_n->entity; - DF_Entity *process = df_entity_ancestor_from_kind(thread, DF_EntityKind_Process); - U64 base_unwind_count = (thread == selected_thread) ? ctrl_ctx.unwind_count : 0; - U64 inline_unwind_count = (thread == selected_thread) ? ctrl_ctx.inline_unwind_count : 0; - U64 rip_vaddr = df_query_cached_rip_from_thread_unwind(thread, unwind_count); - U64 last_inst_on_unwound_rip_vaddr = rip_vaddr - !!unwind_count; - DF_Entity *module = df_module_from_process_vaddr(process, last_inst_on_unwound_rip_vaddr); - U64 rip_voff = df_voff_from_vaddr(module, last_inst_on_unwound_rip_vaddr); - DI_Key dbgi_key = df_dbgi_key_from_module(module); - DF_TextLineDasm2SrcInfo dasm2src_info = df_text_line_dasm2src_info_from_dbgi_key_voff(&dbgi_key, rip_voff, inline_unwind_count); - if(dasm2src_info.file == entity && visible_line_num_range.min <= dasm2src_info.pt.line && dasm2src_info.pt.line <= visible_line_num_range.max) - { - U64 slice_line_idx = dasm2src_info.pt.line-visible_line_num_range.min; - df_entity_list_push(scratch.arena, &code_slice_params.line_ips[slice_line_idx], thread); - } - } - } - - // rjf: find visible watch pins - ProfScope("find visible watch pins") - { - for(DF_Entity *wp = entity->first; !df_entity_is_nil(wp); wp = wp->next) - { - if(wp->deleted || wp->kind != DF_EntityKind_WatchPin) { continue; } - if(visible_line_num_range.min <= wp->text_point.line && wp->text_point.line <= visible_line_num_range.max) - { - U64 slice_line_idx = (wp->text_point.line-visible_line_num_range.min); - df_entity_list_push(scratch.arena, &code_slice_params.line_pins[slice_line_idx], wp); - } - } - } - - // rjf: find all src -> dasm info - ProfScope("find all src -> dasm info") - { - DF_TextLineSrc2DasmInfoListArray src2dasm = df_text_line_src2dasm_info_list_array_from_src_line_range(scratch.arena, entity, visible_line_num_range); - if(src2dasm.count != 0) - { - MemoryCopy(code_slice_params.line_src2dasm, src2dasm.v, sizeof(DF_TextLineSrc2DasmInfoList)*src2dasm.count); - } - code_slice_params.relevant_dbgi_keys = src2dasm.dbgi_keys; - } - } - - ////////////////////////////// - //- rjf: build missing & override interface - // - if(entity_is_missing && !text_info_is_ready) - { - UI_WidthFill UI_HeightFill UI_Column UI_Padding(ui_pct(1, 0)) - { - Temp scratch = scratch_begin(0, 0); - String8 full_path = df_full_path_from_entity(scratch.arena, entity); - UI_PrefWidth(ui_children_sum(1)) UI_PrefHeight(ui_em(3, 1)) - UI_Row UI_Padding(ui_pct(1, 0)) - UI_PrefWidth(ui_text_dim(10, 1)) - UI_Palette(ui_build_palette(ui_top_palette(), .text = df_rgba_from_theme_color(DF_ThemeColor_TextNegative))) - { - UI_Font(df_font_from_slot(DF_FontSlot_Icons)) - UI_RunFlags(F_RunFlag_Smooth) - ui_label(df_g_icon_kind_text_table[DF_IconKind_WarningBig]); - ui_labelf("Could not find \"%S\".", full_path); - } - UI_PrefHeight(ui_em(3, 1)) - UI_Row UI_Padding(ui_pct(1, 0)) - UI_PrefWidth(ui_text_dim(10, 1)) - UI_CornerRadius(ui_top_font_size()/3) - UI_PrefWidth(ui_text_dim(10, 1)) - UI_Focus(UI_FocusKind_On) - DF_Palette(DF_PaletteCode_NeutralPopButton) - if(ui_clicked(ui_buttonf("Find alternative..."))) - { - DF_CmdParams params = df_cmd_params_from_view(ws, panel, view); - params.cmd_spec = df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_PickFile); - df_cmd_params_mark_slot(¶ms, DF_CmdParamSlot_CmdSpec); - df_push_cmd__root(¶ms, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_RunCommand)); - tv->pick_file_override_target = df_handle_from_entity(entity); - } - scratch_end(scratch); - } - } - - ////////////////////////////// - //- rjf: build container - // - UI_Box *container_box = &ui_g_nil_box; - if(text_info_is_ready) - { - ui_set_next_pref_width(ui_px(code_area_dim.x, 1)); - ui_set_next_pref_height(ui_px(code_area_dim.y, 1)); - ui_set_next_child_layout_axis(Axis2_Y); - container_box = ui_build_box_from_stringf(UI_BoxFlag_Clip| - UI_BoxFlag_Scroll| - UI_BoxFlag_AllowOverflowX| - UI_BoxFlag_AllowOverflowY, - "###code_area_%p", view); - } - - ////////////////////////////// - //- rjf: cancelled search query -> center cursor - // - if(!search_query_is_active && tv->drifted_for_search) - { - tv->drifted_for_search = 0; - tv->center_cursor = 1; - } - - ////////////////////////////// - //- rjf: do searching operations - // - if(text_info_is_ready) - { - //- rjf: find text (forward) - if(tv->find_text_fwd.size != 0) - { - Temp scratch = scratch_begin(0, 0); - B32 found = 0; - B32 first = 1; - S64 line_num_start = tv->cursor.line; - S64 line_num_last = (S64)text_info.lines_count; - for(S64 line_num = line_num_start;; first = 0) - { - // rjf: pop scratch - temp_end(scratch); - - // rjf: gather line info - String8 line_string = str8_substr(data, text_info.lines_ranges[line_num-1]); - U64 search_start = 0; - if(tv->cursor.line == line_num && first) - { - search_start = tv->cursor.column; - } - - // rjf: search string - U64 needle_pos = str8_find_needle(line_string, search_start, tv->find_text_fwd, StringMatchFlag_CaseInsensitive); - if(needle_pos < line_string.size) - { - tv->cursor.line = line_num; - tv->cursor.column = needle_pos+1; - tv->mark = tv->cursor; - found = 1; - break; - } - - // rjf: break if circled back around to cursor - else if(line_num == line_num_start && !first) - { - break; - } - - // rjf: increment - line_num += 1; - if(line_num > line_num_last) - { - line_num = 1; - } - } - tv->center_cursor = found; - if(found == 0) - { - DF_CmdParams params = df_cmd_params_from_view(ws, panel, view); - params.string = push_str8f(scratch.arena, "Could not find \"%S\"", tv->find_text_fwd); - df_cmd_params_mark_slot(¶ms, DF_CmdParamSlot_String); - df_push_cmd__root(¶ms, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_Error)); - } - scratch_end(scratch); - } - - //- rjf: find text (backward) - if(tv->find_text_bwd.size != 0) - { - Temp scratch = scratch_begin(0, 0); - B32 found = 0; - B32 first = 1; - S64 line_num_start = tv->cursor.line; - S64 line_num_last = (S64)text_info.lines_count; - for(S64 line_num = line_num_start;; first = 0) - { - // rjf: pop scratch - temp_end(scratch); - - // rjf: gather line info - String8 line_string = str8_substr(data, text_info.lines_ranges[line_num-1]); - if(tv->cursor.line == line_num && first) - { - line_string = str8_prefix(line_string, tv->cursor.column-1); - } - - // rjf: search string - U64 next_needle_pos = line_string.size; - for(U64 needle_pos = 0; needle_pos < line_string.size;) - { - needle_pos = str8_find_needle(line_string, needle_pos, tv->find_text_bwd, StringMatchFlag_CaseInsensitive); - if(needle_pos < line_string.size) - { - next_needle_pos = needle_pos; - needle_pos += 1; - } - } - if(next_needle_pos < line_string.size) - { - tv->cursor.line = line_num; - tv->cursor.column = next_needle_pos+1; - tv->mark = tv->cursor; - found = 1; - break; - } - - // rjf: break if circled back around to cursor line - else if(line_num == line_num_start && !first) - { - break; - } - - // rjf: increment - line_num -= 1; - if(line_num == 0) - { - line_num = line_num_last; - } - } - tv->center_cursor = found; - if(found == 0) - { - DF_CmdParams params = df_cmd_params_from_view(ws, panel, view); - params.string = push_str8f(scratch.arena, "Could not find \"%S\"", tv->find_text_bwd); - df_cmd_params_mark_slot(¶ms, DF_CmdParamSlot_String); - df_push_cmd__root(¶ms, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_Error)); - } - scratch_end(scratch); - } - - MemoryZeroStruct(&tv->find_text_fwd); - MemoryZeroStruct(&tv->find_text_bwd); - arena_clear(tv->find_text_arena); - } - - ////////////////////////////// - //- rjf: do goto line - // - if(text_info_is_ready) if(tv->goto_line_num != 0) - { - S64 line_num = tv->goto_line_num; - tv->goto_line_num = 0; - line_num = Clamp(1, line_num, text_info.lines_count); - tv->cursor = tv->mark = txt_pt(line_num, 1); - tv->center_cursor = !tv->contain_cursor || (line_num < target_visible_line_num_range.min+4 || target_visible_line_num_range.max-4 < line_num); - } - - ////////////////////////////// - //- rjf: do keyboard interaction - // - B32 snap[Axis2_COUNT] = {0}; - UI_Focus(UI_FocusKind_On) - { - if(ui_is_focus_active() && text_info_is_ready && visible_line_num_range.max >= visible_line_num_range.min) - { - snap[Axis2_X] = snap[Axis2_Y] = df_do_txt_controls(&text_info, data, ClampBot(num_possible_visible_lines, 10) - 10, &tv->cursor, &tv->mark, &tv->preferred_column); - } - } - - ////////////////////////////// - //- rjf: build container contents - // - if(text_info_is_ready) UI_Parent(container_box) - { - //- rjf: build fractional space - container_box->view_off.x = container_box->view_off_target.x = view->scroll_pos.x.idx + view->scroll_pos.x.off; - container_box->view_off.y = container_box->view_off_target.y = code_line_height*mod_f32(view->scroll_pos.y.off, 1.f) + code_line_height*(view->scroll_pos.y.off < 0) - code_line_height*(view->scroll_pos.y.off == -1.f && view->scroll_pos.y.idx == 1); - - //- rjf: build code slice - DF_CodeSliceSignal sig = {0}; - UI_Focus(UI_FocusKind_On) - { - sig = df_code_slicef(ws, &ctrl_ctx, &parse_ctx, &code_slice_params, &tv->cursor, &tv->mark, &tv->preferred_column, "txt_view_%p", view); - } - - //- rjf: hover eval - if(!ui_dragging(sig.base) && sig.mouse_expr_rng.min.line != 0 && sig.base.event_flags == 0) - { - TxtRng expr_rng = sig.mouse_expr_rng; - String8 expr = txt_string_from_info_data_txt_rng(&text_info, data, expr_rng); - if(expr.size != 0) - { - DF_Eval eval = df_eval_from_string(scratch.arena, di_scope, &ctrl_ctx, &parse_ctx, &eval_string2expr_map_nil, expr); - if(eval.mode != EVAL_EvalMode_NULL) - { - df_set_hover_eval(ws, sig.mouse_expr_baseline_pos, ctrl_ctx, entity, sig.mouse_pt, 0, expr); - } - } - } - - //- rjf: press code slice? -> focus panel - if(ui_pressed(sig.base)) - { - DF_CmdParams p = df_cmd_params_from_panel(ws, panel); - df_push_cmd__root(&p, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_FocusPanel)); - } - - //- rjf: dragging & outside region? -> contain cursor - if(ui_dragging(sig.base) && sig.base.event_flags == 0) - { - if(!contains_2f32(sig.base.box->rect, ui_mouse())) - { - tv->contain_cursor = 1; - } - else - { - snap[Axis2_X] = 1; - } - } - - //- rjf: ctrl+pressed? -> go to name - if(ui_pressed(sig.base) && sig.base.event_flags & OS_EventFlag_Ctrl) - { - ui_kill_action(); - DF_CmdParams params = df_cmd_params_from_view(ws, panel, view); - params.entity = df_handle_from_entity(entity); - params.string = txt_string_from_info_data_txt_rng(&text_info, data, sig.mouse_expr_rng); - df_cmd_params_mark_slot(¶ms, DF_CmdParamSlot_String); - df_push_cmd__root(¶ms, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_GoToName)); - } - - //- rjf: clicked margin? -> place breakpoint - if(sig.clicked_margin_line_num != 0) - { - DF_CmdParams params = df_cmd_params_from_view(ws, panel, view); - params.text_point = txt_pt(sig.clicked_margin_line_num, 1); - params.entity = df_handle_from_entity(entity); - df_cmd_params_mark_slot(¶ms, DF_CmdParamSlot_TextPoint); - df_cmd_params_mark_slot(¶ms, DF_CmdParamSlot_Entity); - df_push_cmd__root(¶ms, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_TextBreakpoint)); - } - - //- rjf: dropped entity onto line? -> do drop - if(sig.dropped_entity_line_num != 0 && !df_entity_is_nil(sig.dropped_entity)) - { - DF_Entity *dropped_entity = sig.dropped_entity; - switch(dropped_entity->kind) - { - default:{}break; - case DF_EntityKind_Breakpoint: - case DF_EntityKind_WatchPin: - { - DF_StateDeltaHistory *hist = df_state_delta_history(); - df_state_delta_history_push_batch(hist, &dropped_entity->generation); - df_state_delta_history_push_struct_delta(hist, &dropped_entity->text_point); - df_entity_change_parent(hist, dropped_entity, dropped_entity->parent, entity); - df_entity_equip_txt_pt(dropped_entity, txt_pt(sig.dropped_entity_line_num, 1)); - if(dropped_entity->flags & DF_EntityFlag_HasVAddr) - { - df_state_delta_history_push_struct_delta(hist, &dropped_entity->vaddr); - df_entity_equip_vaddr(dropped_entity, 0); - } - }break; - case DF_EntityKind_Thread: - if(contains_1s64(visible_line_num_range, sig.dropped_entity_line_num)) - { - U64 line_idx = (sig.dropped_entity_line_num-visible_line_num_range.min); - DF_TextLineSrc2DasmInfoList *src2dasm_list = &code_slice_params.line_src2dasm[line_idx]; - if(src2dasm_list->first != 0) - { - Rng1U64 voff_rng = src2dasm_list->first->v.voff_range; - DI_Key dbgi_key = src2dasm_list->first->v.dbgi_key; - DF_EntityList possible_modules = df_modules_from_dbgi_key(scratch.arena, &dbgi_key); - DF_Entity *thread_dst_module = df_module_from_thread_candidates(dropped_entity, &possible_modules); - U64 thread_dst_voff = voff_rng.min; - if(!df_entity_is_nil(thread_dst_module) && thread_dst_voff != 0) - { - DF_CmdParams params = df_cmd_params_from_window(ws); - params.entity = df_handle_from_entity(dropped_entity); - params.vaddr = df_vaddr_from_voff(thread_dst_module, thread_dst_voff); - df_cmd_params_mark_slot(¶ms, DF_CmdParamSlot_Entity); - df_cmd_params_mark_slot(¶ms, DF_CmdParamSlot_VirtualAddr); - df_push_cmd__root(¶ms, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_SetThreadIP)); - } - } - }break; - } - } - - //- rjf: copy text - if(!txt_pt_match(sig.copy_range.min, sig.copy_range.max)) - { - String8 text = txt_string_from_info_data_txt_rng(&text_info, data, sig.copy_range); - os_set_clipboard_text(text); - } - - //- rjf: selected text on single line, no query? -> set search text - if(!txt_pt_match(tv->cursor, tv->mark) && tv->cursor.line == tv->mark.line && search_query.size == 0) - { - String8 text = txt_string_from_info_data_txt_rng(&text_info, data, txt_rng(tv->cursor, tv->mark)); - df_set_search_string(text); - } - - //- rjf: toggle cursor watch - if(sig.toggle_cursor_watch) - { - DF_CmdParams params = df_cmd_params_from_view(ws, panel, view); - df_push_cmd__root(¶ms, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_ToggleWatchExpressionAtCursor)); - } - - //- rjf: set next statement - if(sig.set_next_statement_line_num != 0 && contains_1s64(visible_line_num_range, sig.set_next_statement_line_num)) - { - DF_CmdParams params = df_cmd_params_from_view(ws, panel, view); - params.text_point = txt_pt(sig.set_next_statement_line_num, 1); - df_push_cmd__root(¶ms, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_SetNextStatement)); - } - - //- rjf: run-to-line - if(sig.run_to_line_num != 0 && contains_1s64(visible_line_num_range, sig.run_to_line_num)) - { - DF_CmdParams params = df_cmd_params_from_view(ws, panel, view); - params.entity = df_handle_from_entity(entity); - params.text_point = txt_pt(sig.run_to_line_num, 1); - df_push_cmd__root(¶ms, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_RunToLine)); - } - - //- rjf: go to disasm - if(sig.goto_disasm_line_num != 0 && contains_1s64(visible_line_num_range, sig.goto_disasm_line_num)) - { - U64 line_idx = (sig.goto_disasm_line_num-visible_line_num_range.min); - DF_TextLineSrc2DasmInfoList *src2dasm_list = &code_slice_params.line_src2dasm[line_idx]; - if(src2dasm_list->first != 0) - { - Rng1U64 voff_rng = src2dasm_list->first->v.voff_range; - DI_Key dbgi_key = src2dasm_list->first->v.dbgi_key; - DF_EntityList possible_modules = df_modules_from_dbgi_key(scratch.arena, &dbgi_key); - DF_Entity *thread = df_entity_from_handle(ctrl_ctx.thread); - DF_Entity *thread_dst_module = df_module_from_thread_candidates(thread, &possible_modules); - DF_Entity *process = df_entity_ancestor_from_kind(thread, DF_EntityKind_Process); - DF_Entity *module = thread_dst_module; - if(df_entity_is_nil(module)) - { - module = df_first_entity_from_list(&possible_modules); - } - U64 voff = voff_rng.min; - if(!df_entity_is_nil(module) && voff != 0) - { - DF_CmdParams params = df_cmd_params_from_window(ws); - params.entity = df_handle_from_entity(process); - params.vaddr = df_vaddr_from_voff(module, voff); - df_cmd_params_mark_slot(¶ms, DF_CmdParamSlot_Entity); - df_cmd_params_mark_slot(¶ms, DF_CmdParamSlot_VirtualAddr); - df_push_cmd__root(¶ms, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_FindCodeLocation)); - } - } - } - } - - ////////////////////////////// - //- rjf: apply post-build view snapping rules - // - if(text_info_is_ready) - { - // rjf: contain => snap - if(tv->contain_cursor) - { - tv->contain_cursor = 0; - snap[Axis2_X] = 1; - snap[Axis2_Y] = 1; - } - - // rjf: center cursor - if(tv->center_cursor) - { - tv->center_cursor = 0; - String8 cursor_line = str8_substr(data, text_info.lines_ranges[tv->cursor.line-1]); - F32 cursor_advance = f_dim_from_tag_size_string(code_font, code_font_size, 0, code_tab_size, str8_prefix(cursor_line, tv->cursor.column-1)).x; - - // rjf: scroll x - { - S64 new_idx = (S64)(cursor_advance - code_area_dim.x/2); - new_idx = Clamp(scroll_idx_rng[Axis2_X].min, new_idx, scroll_idx_rng[Axis2_X].max); - ui_scroll_pt_target_idx(&view->scroll_pos.x, new_idx); - snap[Axis2_X] = 0; - } - - // rjf: scroll y - { - S64 new_idx = (tv->cursor.line-1) - num_possible_visible_lines/2 + 2; - new_idx = Clamp(scroll_idx_rng[Axis2_Y].min, new_idx, scroll_idx_rng[Axis2_Y].max); - ui_scroll_pt_target_idx(&view->scroll_pos.y, new_idx); - snap[Axis2_Y] = 0; - } - } - - // rjf: snap in X - if(snap[Axis2_X]) - { - String8 cursor_line = str8_substr(data, text_info.lines_ranges[tv->cursor.line-1]); - S64 cursor_off = (S64)(f_dim_from_tag_size_string(code_font, code_font_size, 0, code_tab_size, str8_prefix(cursor_line, tv->cursor.column-1)).x + priority_margin_width_px + catchall_margin_width_px + line_num_width_px); - Rng1S64 visible_pixel_range = - { - view->scroll_pos.x.idx, - view->scroll_pos.x.idx + (S64)code_area_dim.x, - }; - Rng1S64 cursor_pixel_range = - { - cursor_off - (S64)(big_glyph_advance*4) - (S64)(priority_margin_width_px + catchall_margin_width_px + line_num_width_px), - cursor_off + (S64)(big_glyph_advance*4), - }; - S64 min_delta = Min(0, cursor_pixel_range.min - visible_pixel_range.min); - S64 max_delta = Max(0, cursor_pixel_range.max - visible_pixel_range.max); - S64 new_idx = view->scroll_pos.x.idx+min_delta+max_delta; - new_idx = Clamp(scroll_idx_rng[Axis2_X].min, new_idx, scroll_idx_rng[Axis2_X].max); - ui_scroll_pt_target_idx(&view->scroll_pos.x, new_idx); - } - - // rjf: snap in Y - if(snap[Axis2_Y]) - { - Rng1S64 cursor_visibility_range = r1s64(tv->cursor.line-4, tv->cursor.line+4); - cursor_visibility_range.min = ClampBot(0, cursor_visibility_range.min); - cursor_visibility_range.max = ClampBot(0, cursor_visibility_range.max); - S64 min_delta = Min(0, cursor_visibility_range.min-(target_visible_line_num_range.min)); - S64 max_delta = Max(0, cursor_visibility_range.max-(target_visible_line_num_range.min+num_possible_visible_lines)); - S64 new_idx = view->scroll_pos.y.idx+min_delta+max_delta; - new_idx = Clamp(0, new_idx, (S64)text_info.lines_count-1); - ui_scroll_pt_target_idx(&view->scroll_pos.y, new_idx); - } - } - - ////////////////////////////// - //- rjf: build horizontal scroll bar - // - if(text_info_is_ready) - { - ui_set_next_fixed_x(0); - ui_set_next_fixed_y(code_area_dim.y); - ui_set_next_fixed_width(panel_box_dim.x - scroll_bar_dim); - ui_set_next_fixed_height(scroll_bar_dim); - { - view->scroll_pos.x = ui_scroll_bar(Axis2_X, - ui_px(scroll_bar_dim, 1.f), - view->scroll_pos.x, - scroll_idx_rng[Axis2_X], - (S64)code_area_dim.x); - } - } - - ////////////////////////////// - //- rjf: build vertical scroll bar - // - if(text_info_is_ready) - { - ui_set_next_fixed_x(code_area_dim.x); - ui_set_next_fixed_y(0); - ui_set_next_fixed_width(scroll_bar_dim); - ui_set_next_fixed_height(panel_box_dim.y - bottom_bar_dim.y - scroll_bar_dim); - { - view->scroll_pos.y = ui_scroll_bar(Axis2_Y, - ui_px(scroll_bar_dim, 1.f), - view->scroll_pos.y, - scroll_idx_rng[Axis2_Y], - num_possible_visible_lines); - } - } - - ////////////////////////////// - //- rjf: top-level container interaction (scrolling) - // - if(text_info_is_ready) - { - UI_Signal sig = ui_signal_from_box(container_box); - if(sig.scroll.x != 0) - { - S64 new_idx = view->scroll_pos.x.idx+sig.scroll.x*big_glyph_advance; - new_idx = clamp_1s64(scroll_idx_rng[Axis2_X], new_idx); - ui_scroll_pt_target_idx(&view->scroll_pos.x, new_idx); - } - if(sig.scroll.y != 0) - { - S64 new_idx = view->scroll_pos.y.idx + sig.scroll.y; - new_idx = clamp_1s64(scroll_idx_rng[Axis2_Y], new_idx); - ui_scroll_pt_target_idx(&view->scroll_pos.y, new_idx); - } - ui_scroll_pt_clamp_idx(&view->scroll_pos.x, scroll_idx_rng[Axis2_X]); - ui_scroll_pt_clamp_idx(&view->scroll_pos.y, scroll_idx_rng[Axis2_Y]); - } - - ////////////////////////////// - //- rjf: determine up-to-dateness of source file - // - B32 file_is_out_of_date = 0; - String8 out_of_date_dbgi_name = {0}; - for(DI_KeyNode *n = code_slice_params.relevant_dbgi_keys.first; n != 0; n = n->next) - { - DI_Key key = n->v; - if(key.path.size != 0) - { - String8 full_path = df_full_path_from_entity(scratch.arena, entity); - TXTI_Handle handle = txti_handle_from_path(full_path); - TXTI_BufferInfo info = txti_buffer_info_from_handle(scratch.arena, handle); - if(key.min_timestamp < info.timestamp) - { - file_is_out_of_date = 1; - out_of_date_dbgi_name = str8_skip_last_slash(key.path); - break; - } - } - } - - ////////////////////////////// - //- rjf: build bottom info bar - // - if(text_info_is_ready) - { - ui_set_next_fixed_x(0); - ui_set_next_fixed_y(code_area_dim.y + scroll_bar_dim); - ui_set_next_pref_width(ui_px(bottom_bar_dim.x, 1)); - ui_set_next_pref_height(ui_px(bottom_bar_dim.y, 1)); - ui_set_next_flags(UI_BoxFlag_DrawBackground); - UI_Row - UI_TextAlignment(UI_TextAlign_Center) - UI_PrefWidth(ui_text_dim(10, 1)) - UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) - { - String8 full_path = df_full_path_from_entity(scratch.arena, entity); - TXTI_Handle handle = txti_handle_from_path(full_path); - TXTI_BufferInfo info = txti_buffer_info_from_handle(scratch.arena, handle); - if(file_is_out_of_date) - { - UI_Box *box = &ui_g_nil_box; - UI_Palette(ui_build_palette(ui_top_palette(), .text = df_rgba_from_theme_color(DF_ThemeColor_TextNegative))) - UI_Font(df_font_from_slot(DF_FontSlot_Icons)) - UI_RunFlags(F_RunFlag_Smooth) - { - box = ui_build_box_from_stringf(UI_BoxFlag_DrawText|UI_BoxFlag_Clickable, "%S###file_ood_warning", df_g_icon_kind_text_table[DF_IconKind_WarningBig]); - } - UI_Signal sig = ui_signal_from_box(box); - if(ui_hovering(sig)) UI_Tooltip - { - UI_PrefWidth(ui_children_sum(1)) UI_Row UI_PrefWidth(ui_text_dim(1, 1)) - { - ui_labelf("This file has changed since ", out_of_date_dbgi_name); - UI_Palette(ui_build_palette(ui_top_palette(), .text = df_rgba_from_theme_color(DF_ThemeColor_TextNeutral))) ui_label(out_of_date_dbgi_name); - ui_labelf(" was produced."); - } - } - } - UI_Font(code_font) - { - ui_label(full_path); - ui_spacer(ui_em(1.5f, 1)); - ui_labelf("Line: %I64d, Column: %I64d", tv->cursor.line, tv->cursor.column); - ui_spacer(ui_pct(1, 0)); - ui_labelf("(read only)"); - ui_labelf("%s", - info.line_end_kind == TXT_LineEndKind_LF ? "lf" : - info.line_end_kind == TXT_LineEndKind_CRLF ? "crlf" : - "bin"); - } - } - } - - txt_scope_close(txt_scope); - di_scope_close(di_scope); - hs_scope_close(hs_scope); - scratch_end(scratch); - ProfEnd(); -} -#endif //////////////////////////////// //~ rjf: Disassembly @view_hook_impl @@ -8511,7 +7430,6 @@ DF_VIEW_UI_FUNCTION_DEF(Procedures) //////////////////////////////// //~ rjf: Output @view_hook_impl -#if 1 DF_VIEW_SETUP_FUNCTION_DEF(Output) { DF_CodeViewState *cv = df_view_user_state(view, DF_CodeViewState); @@ -8602,624 +7520,6 @@ DF_VIEW_UI_FUNCTION_DEF(Output) hs_scope_close(hs_scope); scratch_end(scratch); } -#endif - -//~ TODO(rjf): OLD vvvvvvvvvvvvvvvvvvvv @src_collapse -#if 0 -DF_VIEW_SETUP_FUNCTION_DEF(Output) -{ - // rjf: set up state - DF_CodeViewState *tv = df_view_user_state(view, DF_CodeViewState); - if(tv->initialized == 0) - { - tv->initialized = 1; - tv->cursor = tv->mark = txt_pt(1, 1); - tv->preferred_column = 1; - tv->find_text_arena = df_view_push_arena_ext(view); - } - - // rjf: default to loading - df_view_equip_loading_info(view, 1, 0, 0); - view->loading_t = view->loading_t_target = 1.f; -} - -DF_VIEW_STRING_FROM_STATE_FUNCTION_DEF(Output) -{ - return str8_lit(""); -} - -DF_VIEW_CMD_FUNCTION_DEF(Output) -{ - DF_CodeViewState *tv = df_view_user_state(view, DF_CodeViewState); - DF_Entity *entity = df_entity_from_handle(view->entity); - for(DF_CmdNode *n = cmds->first; n != 0; n = n->next) - { - DF_Cmd *cmd = &n->cmd; - - // rjf: mismatched window/panel => skip - if(df_window_from_handle(cmd->params.window) != ws || - df_panel_from_handle(cmd->params.panel) != panel) - { - continue; - } - - // rjf: process - DF_CoreCmdKind core_cmd_kind = df_core_cmd_kind_from_string(cmd->spec->info.string); - switch(core_cmd_kind) - { - default: break; - case DF_CoreCmdKind_GoToLine: - { - tv->goto_line_num = cmd->params.text_point.line; - }break; - case DF_CoreCmdKind_CenterCursor: - { - tv->center_cursor = 1; - }break; - case DF_CoreCmdKind_ContainCursor: - { - tv->contain_cursor = 1; - }break; - case DF_CoreCmdKind_FindTextForward: - { - arena_clear(tv->find_text_arena); - tv->find_text_fwd = push_str8_copy(tv->find_text_arena, cmd->params.string); - }break; - case DF_CoreCmdKind_FindTextBackward: - { - arena_clear(tv->find_text_arena); - tv->find_text_bwd = push_str8_copy(tv->find_text_arena, cmd->params.string); - }break; - case DF_CoreCmdKind_ToggleBreakpointAtCursor: - { - DF_CmdParams params = df_cmd_params_from_view(ws, panel, view); - params.entity = view->entity; - params.text_point = tv->cursor; - df_push_cmd__root(¶ms, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_TextBreakpoint)); - tv->contain_cursor = 1; - }break; - case DF_CoreCmdKind_ToggleWatchPinAtCursor: - { - DF_CmdParams params = df_cmd_params_from_view(ws, panel, view); - params.entity = view->entity; - params.text_point = tv->cursor; - params.string = cmd->params.string; - df_push_cmd__root(¶ms, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_ToggleWatchPin)); - tv->contain_cursor = 1; - }break; - } - } -} - -DF_VIEW_UI_FUNCTION_DEF(Output) -{ - ProfBeginFunction(); - Temp scratch = scratch_begin(0, 0); - DI_Scope *scope = di_scope_open(); - DF_CodeViewState *tv = df_view_user_state(view, DF_CodeViewState); - - ////////////////////////////// - //- rjf: extract invariants - // - DF_Entity *entity = df_log_from_entity(df_entity_root()); - DF_CtrlCtx ctrl_ctx = df_ctrl_ctx_from_view(ws, view); - F_Tag code_font = df_font_from_slot(DF_FontSlot_Code); - F32 code_font_size = df_font_size_from_slot(ws, DF_FontSlot_Code); - F32 code_tab_size = f_column_size_from_tag_size(code_font, code_font_size)*df_setting_val_from_code(DF_SettingCode_TabWidth).s32; - F_Metrics code_font_metrics = f_metrics_from_tag_size(code_font, code_font_size); - F32 code_line_height = ceil_f32(f_line_height_from_metrics(&code_font_metrics) * 1.5f); - F32 big_glyph_advance = f_dim_from_tag_size_string(code_font, code_font_size, 0, 0, str8_lit("H")).x; - Vec2F32 panel_box_dim = dim_2f32(rect); - Vec2F32 bottom_bar_dim = {panel_box_dim.x, ui_top_font_size()*1.8f}; - F32 scroll_bar_dim = floor_f32(ui_top_font_size()*1.5f); - Vec2F32 code_area_dim = v2f32(panel_box_dim.x - scroll_bar_dim, panel_box_dim.y - scroll_bar_dim - bottom_bar_dim.y); - S64 num_possible_visible_lines = (S64)(code_area_dim.y/code_line_height)+1; - - ////////////////////////////// - //- rjf: unpack ctrl ctx & make parse ctx - // - DF_Entity *thread = df_entity_from_handle(ctrl_ctx.thread); - U64 unwind_count = ctrl_ctx.unwind_count; - U64 rip_vaddr = df_query_cached_rip_from_thread_unwind(thread, unwind_count); - DF_Entity *process = df_entity_ancestor_from_kind(thread, DF_EntityKind_Process); - EVAL_ParseCtx parse_ctx = df_eval_parse_ctx_from_process_vaddr(scope, process, rip_vaddr); - - ////////////////////////////// - //- rjf: unpack entity info - // - TXTI_Handle txti_handle = df_txti_handle_from_entity(entity); - TXTI_BufferInfo txti_buffer_info = txti_buffer_info_from_handle(scratch.arena, txti_handle); - B32 txti_buffer_is_ready = ((txti_buffer_info.timestamp != 0 || entity->flags & DF_EntityFlag_Output) && - (txti_buffer_info.bytes_processed == txti_buffer_info.bytes_to_process || txti_buffer_info.buffer_apply_gen != 0)); - - ////////////////////////////// - //- rjf: buffer is pending -> equip view with loading information - // - if(!txti_buffer_is_ready) - { - df_view_equip_loading_info(view, 1, txti_buffer_info.bytes_processed, txti_buffer_info.bytes_to_process); - } - - ////////////////////////////// - //- rjf: determine visible line range / count - // - Rng1S64 visible_line_num_range = r1s64(view->scroll_pos.y.idx + (S64)(view->scroll_pos.y.off) + 1 - !!(view->scroll_pos.y.off < 0), - view->scroll_pos.y.idx + (S64)(view->scroll_pos.y.off) + 1 + num_possible_visible_lines); - Rng1S64 target_visible_line_num_range = r1s64(view->scroll_pos.y.idx + 1, - view->scroll_pos.y.idx + 1 + num_possible_visible_lines); - U64 visible_line_count = 0; - { - visible_line_num_range.min = Clamp(1, visible_line_num_range.min, (S64)txti_buffer_info.total_line_count); - visible_line_num_range.max = Clamp(1, visible_line_num_range.max, (S64)txti_buffer_info.total_line_count); - visible_line_num_range.min = Max(1, visible_line_num_range.min); - visible_line_num_range.max = Max(1, visible_line_num_range.max); - target_visible_line_num_range.min = Clamp(1, target_visible_line_num_range.min, (S64)txti_buffer_info.total_line_count); - target_visible_line_num_range.max = Clamp(1, target_visible_line_num_range.max, (S64)txti_buffer_info.total_line_count); - target_visible_line_num_range.min = Max(1, target_visible_line_num_range.min); - target_visible_line_num_range.max = Max(1, target_visible_line_num_range.max); - visible_line_count = (U64)dim_1s64(visible_line_num_range)+1; - } - - ////////////////////////////// - //- rjf: calculate scroll bounds - // - S64 line_size_x = 0; - Rng1S64 scroll_idx_rng[Axis2_COUNT] = {0}; - { - line_size_x = (txti_buffer_info.max_line_size*big_glyph_advance*3)/2; - line_size_x = ClampBot(line_size_x, (S64)big_glyph_advance*120); - line_size_x = ClampBot(line_size_x, (S64)code_area_dim.x); - scroll_idx_rng[Axis2_X] = r1s64(0, line_size_x-(S64)code_area_dim.x); - scroll_idx_rng[Axis2_Y] = r1s64(0, (S64)txti_buffer_info.total_line_count-1); - } - - ////////////////////////////// - //- 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); - TXTI_Slice slice = txti_slice_from_handle_line_range(scratch.arena, txti_handle, visible_line_num_range); - - ////////////////////////////// - //- rjf: get active search query - // - String8 search_query = {0}; - Side search_query_side = Side_Invalid; - B32 search_query_is_active = 0; - { - DF_CoreCmdKind query_cmd_kind = df_core_cmd_kind_from_string(ws->query_cmd_spec->info.string); - if(query_cmd_kind == DF_CoreCmdKind_FindTextForward || - query_cmd_kind == DF_CoreCmdKind_FindTextBackward) - { - search_query = str8(ws->query_view_stack_top->query_buffer, ws->query_view_stack_top->query_string_size); - search_query_is_active = 1; - search_query_side = (query_cmd_kind == DF_CoreCmdKind_FindTextForward) ? Side_Max : Side_Min; - } - } - - ////////////////////////////// - //- rjf: prepare code slice info bundle, for the viewable region of text - // - DF_CodeSliceParams code_slice_params = {0}; - if(txti_buffer_is_ready) - { - // rjf: fill basics - code_slice_params.flags = DF_CodeSliceFlag_LineNums|DF_CodeSliceFlag_Clickable; - code_slice_params.line_num_range = visible_line_num_range; - code_slice_params.line_text = slice.line_text; - code_slice_params.line_ranges = slice.line_ranges; - code_slice_params.line_tokens = slice.line_tokens; - code_slice_params.line_bps = push_array(scratch.arena, DF_EntityList, slice.line_count); - code_slice_params.line_ips = push_array(scratch.arena, DF_EntityList, slice.line_count); - code_slice_params.line_pins = push_array(scratch.arena, DF_EntityList, slice.line_count); - code_slice_params.line_vaddrs = push_array(scratch.arena, U64, visible_line_count); - code_slice_params.line_dasm2src = push_array(scratch.arena, DF_TextLineDasm2SrcInfoList, slice.line_count); - code_slice_params.line_src2dasm = push_array(scratch.arena, DF_TextLineSrc2DasmInfoList, slice.line_count); - code_slice_params.font = code_font; - code_slice_params.font_size = code_font_size; - code_slice_params.tab_size = code_tab_size; - code_slice_params.line_height_px = code_line_height; - code_slice_params.search_query = search_query; - code_slice_params.priority_margin_width_px = 0.f; - code_slice_params.catchall_margin_width_px = 0.f; - code_slice_params.line_num_width_px = line_num_width_px; - code_slice_params.line_text_max_width_px = (F32)line_size_x; - code_slice_params.margin_float_off_px = view->scroll_pos.x.idx + view->scroll_pos.x.off; - } - - ////////////////////////////// - //- rjf: build container - // - UI_Box *container_box = &ui_g_nil_box; - if(txti_buffer_is_ready) - { - ui_set_next_pref_width(ui_px(code_area_dim.x, 1)); - ui_set_next_pref_height(ui_px(code_area_dim.y, 1)); - ui_set_next_child_layout_axis(Axis2_Y); - container_box = ui_build_box_from_stringf(UI_BoxFlag_Clip| - UI_BoxFlag_Scroll| - UI_BoxFlag_DrawBorder| - UI_BoxFlag_AllowOverflowX| - UI_BoxFlag_AllowOverflowY, - "###code_area_%p", view); - } - - ////////////////////////////// - //- rjf: cancelled search query -> center cursor - // - if(!search_query_is_active && tv->drifted_for_search) - { - tv->drifted_for_search = 0; - tv->center_cursor = 1; - } - - ////////////////////////////// - //- rjf: do searching operations - // - if(txti_buffer_is_ready) - { - //- rjf: find text (forward) - if(tv->find_text_fwd.size != 0) - { - Temp scratch = scratch_begin(0, 0); - B32 found = 0; - B32 first = 1; - S64 line_num_start = tv->cursor.line; - S64 line_num_last = (S64)txti_buffer_info.total_line_count; - for(S64 line_num = line_num_start;; first = 0) - { - // rjf: pop scratch - temp_end(scratch); - - // rjf: gather line info - String8 line_string = txti_string_from_handle_line_num(scratch.arena, txti_handle, line_num); - U64 search_start = 0; - if(tv->cursor.line == line_num && first) - { - search_start = tv->cursor.column; - } - - // rjf: search string - U64 needle_pos = str8_find_needle(line_string, search_start, tv->find_text_fwd, StringMatchFlag_CaseInsensitive); - if(needle_pos < line_string.size) - { - tv->cursor.line = line_num; - tv->cursor.column = needle_pos+1; - tv->mark = tv->cursor; - found = 1; - break; - } - - // rjf: break if circled back around to cursor - else if(line_num == line_num_start && !first) - { - break; - } - - // rjf: increment - line_num += 1; - if(line_num > line_num_last) - { - line_num = 1; - } - } - tv->center_cursor = found; - if(found == 0) - { - DF_CmdParams params = df_cmd_params_from_view(ws, panel, view); - params.string = push_str8f(scratch.arena, "Could not find \"%S\"", tv->find_text_fwd); - df_cmd_params_mark_slot(¶ms, DF_CmdParamSlot_String); - df_push_cmd__root(¶ms, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_Error)); - } - scratch_end(scratch); - } - - //- rjf: find text (backward) - if(tv->find_text_bwd.size != 0) - { - Temp scratch = scratch_begin(0, 0); - B32 found = 0; - B32 first = 1; - S64 line_num_start = tv->cursor.line; - S64 line_num_last = (S64)txti_buffer_info.total_line_count; - for(S64 line_num = line_num_start;; first = 0) - { - // rjf: pop scratch - temp_end(scratch); - - // rjf: gather line info - String8 line_string = txti_string_from_handle_line_num(scratch.arena, txti_handle, line_num); - if(tv->cursor.line == line_num && first) - { - line_string = str8_prefix(line_string, tv->cursor.column-1); - } - - // rjf: search string - U64 next_needle_pos = line_string.size; - for(U64 needle_pos = 0; needle_pos < line_string.size;) - { - needle_pos = str8_find_needle(line_string, needle_pos, tv->find_text_bwd, StringMatchFlag_CaseInsensitive); - if(needle_pos < line_string.size) - { - next_needle_pos = needle_pos; - needle_pos += 1; - } - } - if(next_needle_pos < line_string.size) - { - tv->cursor.line = line_num; - tv->cursor.column = next_needle_pos+1; - tv->mark = tv->cursor; - found = 1; - break; - } - - // rjf: break if circled back around to cursor line - else if(line_num == line_num_start && !first) - { - break; - } - - // rjf: increment - line_num -= 1; - if(line_num == 0) - { - line_num = line_num_last; - } - } - tv->center_cursor = found; - if(found == 0) - { - DF_CmdParams params = df_cmd_params_from_view(ws, panel, view); - params.string = push_str8f(scratch.arena, "Could not find \"%S\"", tv->find_text_bwd); - df_cmd_params_mark_slot(¶ms, DF_CmdParamSlot_String); - df_push_cmd__root(¶ms, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_Error)); - } - scratch_end(scratch); - } - - MemoryZeroStruct(&tv->find_text_fwd); - MemoryZeroStruct(&tv->find_text_bwd); - arena_clear(tv->find_text_arena); - } - - ////////////////////////////// - //- rjf: do goto line - // - if(txti_buffer_is_ready) if(tv->goto_line_num != 0) - { - S64 line_num = tv->goto_line_num; - tv->goto_line_num = 0; - line_num = Clamp(1, line_num, txti_buffer_info.total_line_count); - tv->cursor = tv->mark = txt_pt(line_num, 1); - tv->center_cursor = !tv->contain_cursor || (line_num < target_visible_line_num_range.min+4 || target_visible_line_num_range.max-4 < line_num); - } - - ////////////////////////////// - //- rjf: do keyboard interaction - // - B32 snap[Axis2_COUNT] = {0}; - UI_Focus(UI_FocusKind_On) - { - if(txti_buffer_is_ready && visible_line_num_range.max >= visible_line_num_range.min && ui_is_focus_active()) - { - snap[Axis2_X] = snap[Axis2_Y] = df_do_txti_controls(txti_handle, ClampBot(num_possible_visible_lines, 10) - 10, &tv->cursor, &tv->mark, &tv->preferred_column); - } - } - - ////////////////////////////// - //- rjf: build container contents - // - if(txti_buffer_is_ready) UI_Parent(container_box) - { - //- rjf: build fractional space - container_box->view_off.x = container_box->view_off_target.x = view->scroll_pos.x.idx + view->scroll_pos.x.off; - container_box->view_off.y = container_box->view_off_target.y = code_line_height*mod_f32(view->scroll_pos.y.off, 1.f) + code_line_height*(view->scroll_pos.y.off < 0) - code_line_height*(view->scroll_pos.y.off == -1.f && view->scroll_pos.y.idx == 1); - - //- rjf: build code slice - DF_CodeSliceSignal sig = {0}; - UI_Focus(UI_FocusKind_On) - { - sig = df_code_slicef(ws, &ctrl_ctx, &parse_ctx, &code_slice_params, &tv->cursor, &tv->mark, &tv->preferred_column, "txt_view_%p", view); - } - - //- rjf: hover eval - if(!ui_dragging(sig.base) && sig.mouse_expr_rng.min.line != 0) - { - TxtRng expr_rng = sig.mouse_expr_rng; - String8 expr = txti_string_from_handle_txt_rng(scratch.arena, txti_handle, expr_rng); - if(expr.size != 0) - { - DF_Eval eval = df_eval_from_string(scratch.arena, scope, &ctrl_ctx, &parse_ctx, &eval_string2expr_map_nil, expr); - if(eval.mode != EVAL_EvalMode_NULL) - { - df_set_hover_eval(ws, sig.mouse_expr_baseline_pos, ctrl_ctx, entity, sig.mouse_pt, 0, expr); - } - } - } - - //- rjf: press code slice? -> focus panel - if(ui_pressed(sig.base)) - { - DF_CmdParams p = df_cmd_params_from_panel(ws, panel); - df_push_cmd__root(&p, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_FocusPanel)); - } - - //- rjf: dragging & outside region? -> contain cursor - if(ui_dragging(sig.base) && !contains_2f32(sig.base.box->rect, ui_mouse()) && sig.base.event_flags == 0) - { - tv->contain_cursor = 1; - } - - //- rjf: copy text - if(!txt_pt_match(sig.copy_range.min, sig.copy_range.max)) - { - Temp temp = temp_begin(scratch.arena); - String8 text = txti_string_from_handle_txt_rng(temp.arena, txti_handle, sig.copy_range); - os_set_clipboard_text(text); - temp_end(temp); - } - } - - ////////////////////////////// - //- rjf: apply post-build view snapping rules - // - if(txti_buffer_is_ready) - { - // rjf: contain => snap - if(tv->contain_cursor) - { - tv->contain_cursor = 0; - snap[Axis2_X] = 1; - snap[Axis2_Y] = 1; - } - - // rjf: center cursor - if(tv->center_cursor) - { - tv->center_cursor = 0; - String8 cursor_line = txti_string_from_handle_line_num(scratch.arena, txti_handle, tv->cursor.line); - F32 cursor_advance = f_dim_from_tag_size_string(code_font, code_font_size, 0, code_tab_size, str8_prefix(cursor_line, tv->cursor.column-1)).x; - - // rjf: scroll x - { - S64 new_idx = (S64)(cursor_advance - code_area_dim.x/2); - new_idx = Clamp(scroll_idx_rng[Axis2_X].min, new_idx, scroll_idx_rng[Axis2_X].max); - ui_scroll_pt_target_idx(&view->scroll_pos.x, new_idx); - snap[Axis2_X] = 0; - } - - // rjf: scroll y - { - S64 new_idx = (tv->cursor.line-1) - num_possible_visible_lines/2 + 2; - new_idx = Clamp(scroll_idx_rng[Axis2_Y].min, new_idx, scroll_idx_rng[Axis2_Y].max); - ui_scroll_pt_target_idx(&view->scroll_pos.y, new_idx); - snap[Axis2_Y] = 0; - } - } - - // rjf: snap in X - if(snap[Axis2_X]) - { - String8 cursor_line = txti_string_from_handle_line_num(scratch.arena, txti_handle, tv->cursor.line); - S64 cursor_off = (S64)(f_dim_from_tag_size_string(code_font, code_font_size, 0, code_tab_size, str8_prefix(cursor_line, tv->cursor.column-1)).x + priority_margin_width_px + catchall_margin_width_px + line_num_width_px); - Rng1S64 visible_pixel_range = - { - view->scroll_pos.x.idx, - view->scroll_pos.x.idx + (S64)code_area_dim.x, - }; - Rng1S64 cursor_pixel_range = - { - cursor_off - (S64)(big_glyph_advance*4) - (S64)(priority_margin_width_px + catchall_margin_width_px + line_num_width_px), - cursor_off + (S64)(big_glyph_advance*4), - }; - S64 min_delta = Min(0, cursor_pixel_range.min - visible_pixel_range.min); - S64 max_delta = Max(0, cursor_pixel_range.max - visible_pixel_range.max); - S64 new_idx = view->scroll_pos.x.idx+min_delta+max_delta; - new_idx = Clamp(scroll_idx_rng[Axis2_X].min, new_idx, scroll_idx_rng[Axis2_X].max); - ui_scroll_pt_target_idx(&view->scroll_pos.x, new_idx); - } - - // rjf: snap in Y - if(snap[Axis2_Y]) - { - Rng1S64 cursor_visibility_range = r1s64(tv->cursor.line-4, tv->cursor.line+4); - cursor_visibility_range.min = ClampBot(0, cursor_visibility_range.min); - cursor_visibility_range.max = ClampBot(0, cursor_visibility_range.max); - S64 min_delta = Min(0, cursor_visibility_range.min-(target_visible_line_num_range.min)); - S64 max_delta = Max(0, cursor_visibility_range.max-(target_visible_line_num_range.min+num_possible_visible_lines)); - S64 new_idx = view->scroll_pos.y.idx+min_delta+max_delta; - new_idx = Clamp(0, new_idx, (S64)txti_buffer_info.total_line_count-1); - ui_scroll_pt_target_idx(&view->scroll_pos.y, new_idx); - } - } - - ////////////////////////////// - //- rjf: build horizontal scroll bar - // - if(txti_buffer_is_ready) - { - ui_set_next_fixed_x(0); - ui_set_next_fixed_y(code_area_dim.y); - ui_set_next_fixed_width(panel_box_dim.x - scroll_bar_dim); - ui_set_next_fixed_height(scroll_bar_dim); - { - view->scroll_pos.x = ui_scroll_bar(Axis2_X, - ui_px(scroll_bar_dim, 1.f), - view->scroll_pos.x, - scroll_idx_rng[Axis2_X], - (S64)code_area_dim.x); - } - } - - ////////////////////////////// - //- rjf: build vertical scroll bar - // - if(txti_buffer_is_ready) - { - ui_set_next_fixed_x(code_area_dim.x); - ui_set_next_fixed_y(0); - ui_set_next_fixed_width(scroll_bar_dim); - ui_set_next_fixed_height(panel_box_dim.y - bottom_bar_dim.y - scroll_bar_dim); - { - view->scroll_pos.y = ui_scroll_bar(Axis2_Y, - ui_px(scroll_bar_dim, 1.f), - view->scroll_pos.y, - scroll_idx_rng[Axis2_Y], - num_possible_visible_lines); - } - } - - ////////////////////////////// - //- rjf: top-level container interaction (scrolling) - // - if(txti_buffer_is_ready) - { - UI_Signal sig = ui_signal_from_box(container_box); - if(sig.scroll.x != 0) - { - S64 new_idx = view->scroll_pos.x.idx+sig.scroll.x*big_glyph_advance; - new_idx = clamp_1s64(scroll_idx_rng[Axis2_X], new_idx); - ui_scroll_pt_target_idx(&view->scroll_pos.x, new_idx); - } - if(sig.scroll.y != 0) - { - S64 new_idx = view->scroll_pos.y.idx + sig.scroll.y; - new_idx = clamp_1s64(scroll_idx_rng[Axis2_Y], new_idx); - ui_scroll_pt_target_idx(&view->scroll_pos.y, new_idx); - } - ui_scroll_pt_clamp_idx(&view->scroll_pos.x, scroll_idx_rng[Axis2_X]); - ui_scroll_pt_clamp_idx(&view->scroll_pos.y, scroll_idx_rng[Axis2_Y]); - } - - ////////////////////////////// - //- rjf: build bottom info bar - // - if(txti_buffer_is_ready) - { - ui_set_next_fixed_x(0); - ui_set_next_fixed_y(code_area_dim.y + scroll_bar_dim); - ui_set_next_pref_width(ui_px(bottom_bar_dim.x, 1)); - ui_set_next_pref_height(ui_px(bottom_bar_dim.y, 1)); - ui_set_next_flags(UI_BoxFlag_DrawBackground); - UI_Row - UI_TextAlignment(UI_TextAlign_Center) - UI_PrefWidth(ui_text_dim(10, 1)) - UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) - UI_Font(code_font) - { - ui_labelf("Line: %I64d, Column: %I64d", tv->cursor.line, tv->cursor.column); - ui_spacer(ui_pct(1, 0)); - ui_labelf("(read only)"); - } - } - - di_scope_close(scope); - scratch_end(scratch); - ProfEnd(); -} -#endif //////////////////////////////// //~ rjf: Memory @view_hook_impl