plug in text scope tree to code slice visualization

This commit is contained in:
Ryan Fleury committed 2025-08-05 16:36:59 -07:00
1 parent 230f452edb
commit 01f60834e9
5 files changed
+30 -6

No files matched your search

+22
View File
@@ -2113,6 +2113,15 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe
result.base = text_container_sig;
}
//////////////////////////////
//- rjf: cursor -> scope info
//
TXT_ScopeNode *cursor_scope_node = &txt_scope_node_nil;
if(params->text_info != 0)
{
cursor_scope_node = txt_scope_node_from_info_pt(params->text_info, rd_regs()->cursor);
}
//////////////////////////////
//- rjf: produce fancy strings for each line
//
@@ -2170,6 +2179,19 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe
token_color = mix_4f32(token_color, lookup_color, lookup_color_mix_t);
}
// rjf: scope endpoints enclosing cursor -> highlight
for(TXT_ScopeNode *scope_n = cursor_scope_node;
scope_n != &txt_scope_node_nil;
scope_n = txt_scope_node_from_info_num(params->text_info, scope_n->parent_num))
{
if(params->text_info->tokens.v[scope_n->token_idx_range.min].range.min == token->range.min ||
params->text_info->tokens.v[scope_n->token_idx_range.max].range.min == token->range.min)
{
token_color = pop_color;
break;
}
}
// rjf: push fancy string
dr_fstrs_push_new(scratch.arena, &fstrs, &fstr_params, token_string, .color = token_color);
}