eliminate mutual exclusion of expression/evaluation cells; allow both paths to be turned on in a single cell

This commit is contained in:
Ryan Fleury
2025-04-22 10:17:16 -07:00
parent 3d1f764741
commit c7a9e174fa
3 changed files with 233 additions and 236 deletions
+11 -21
View File
@@ -3277,13 +3277,11 @@ rd_view_ui(Rng2F32 rect)
edit_state->cursor = op.cursor;
edit_state->mark = op.mark;
// rjf: commit edited cell string
switch(cell->kind)
// rjf: commit edited cell string - first try to commit eval value, if that path is
// enabled on this cell, next try to commit expression string, if that path is enabled
if(cell->kind == RD_WatchCellKind_Eval)
{
case RD_WatchCellKind_ViewUI:
case RD_WatchCellKind_CallStackFrame:
{}break;
case RD_WatchCellKind_Expr:
if(cell->flags & RD_WatchCellFlag_Expr && cell->flags & RD_WatchCellFlag_NoEval)
{
RD_Cfg *cfg = row_info.group_cfg_child;
String8 child_key = str8_lit("expression");
@@ -3312,10 +3310,8 @@ rd_view_ui(Rng2F32 rect)
RD_Cfg *expr = child_key.size != 0 ? rd_cfg_child_from_string_or_alloc(cfg, child_key) : cfg;
rd_cfg_new_replace(expr, new_string);
}
}break;
case RD_WatchCellKind_Eval:
{
if(cell->eval.irtree.mode == E_Mode_Offset)
}
else
{
B32 should_commit_asap = editing_complete;
if(cell->eval.space.kind == RD_EvalSpaceKind_MetaCfg)
@@ -3336,7 +3332,6 @@ rd_view_ui(Rng2F32 rect)
}
}
}
}break;
}
}
}
@@ -3418,10 +3413,7 @@ rd_view_ui(Rng2F32 rect)
continue;
}
RD_WatchPt pt = {row->block->key, row->key, rd_id_from_watch_cell(cell)};
switch(cell->kind)
{
default:{}break;
case RD_WatchCellKind_Expr:
if(cell->flags & RD_WatchCellFlag_Expr && cell->flags & RD_WatchCellFlag_NoEval)
{
RD_Cfg *cfg = row_info.group_cfg_child;
if(cfg != &rd_nil_cfg)
@@ -3450,11 +3442,10 @@ rd_view_ui(Rng2F32 rect)
state_dirty = 1;
}
}
}break;
case RD_WatchCellKind_Eval:
}
else
{
rd_commit_eval_value_string(cell->eval, str8_zero());
}break;
}
}
}
@@ -4325,8 +4316,7 @@ rd_view_ui(Rng2F32 rect)
else
{
// rjf: compute visual params
B32 fancy_editors_in_expr = (row_info->cells.count == 1);
B32 cell_has_fancy_editors = (cell->kind != RD_WatchCellKind_Expr || fancy_editors_in_expr);
B32 cell_has_fancy_editors = (!(cell->flags & RD_WatchCellFlag_NoEval));
B32 is_button = !!(cell_info.flags & RD_WatchCellFlag_Button);
B32 has_background = !!(cell_info.flags & RD_WatchCellFlag_Background);
B32 is_toggle_switch = (cell_has_fancy_editors && cell->eval.irtree.mode != E_Mode_Null && e_type_kind_from_key(e_type_key_unwrap(cell->eval.irtree.type_key, E_TypeUnwrapFlag_AllDecorative)) == E_TypeKind_Bool);
@@ -4334,7 +4324,7 @@ rd_view_ui(Rng2F32 rect)
B32 is_activated_on_single_click = !!(cell_info.flags & RD_WatchCellFlag_ActivateWithSingleClick);
B32 is_non_code = !!(cell_info.flags & RD_WatchCellFlag_IsNonCode);
String8 ghost_text = {0};
if(cell_selected && ewv->text_editing && cell->kind == RD_WatchCellKind_Expr)
if(cell_selected && ewv->text_editing && cell->flags & RD_WatchCellFlag_Expr && cell->flags & RD_WatchCellFlag_NoEval)
{
is_non_code = 0;
is_button = 0;
+35 -29
View File
@@ -823,7 +823,7 @@ rd_id_from_watch_cell(RD_WatchCell *cell)
{
U64 result = 5381;
result = e_hash_from_string(result, str8_struct(&cell->kind));
if(cell->kind != RD_WatchCellKind_Expr)
if(!(cell->flags & RD_WatchCellFlag_Expr))
{
result = e_hash_from_string(result, str8_struct(&cell->index));
result = e_hash_from_string(result, str8_struct(&cell->default_pct));
@@ -1129,7 +1129,7 @@ rd_watch_row_info_from_row(Arena *arena, EV_Row *row)
if(type->kind == E_TypeKind_Set)
{
String8 file_path = e_string_from_id(row->eval.value.u64);
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Expr, row->eval, .edit_string = row->edit_string, .flags = RD_WatchCellFlag_Indented|RD_WatchCellFlag_Button|RD_WatchCellFlag_IsNonCode, .pct = 1.f);
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Eval, row->eval, .edit_string = row->edit_string, .flags = RD_WatchCellFlag_Expr|RD_WatchCellFlag_Indented|RD_WatchCellFlag_Button|RD_WatchCellFlag_IsNonCode, .pct = 1.f);
if(str8_match(type->name, str8_lit("file"), 0))
{
info.can_expand = 0;
@@ -1143,7 +1143,7 @@ rd_watch_row_info_from_row(Arena *arena, EV_Row *row)
RD_Cfg *w_cfg = style->first;
F32 next_pct = 0;
#define take_pct() (next_pct = (F32)f64_from_str8(w_cfg->string), w_cfg = w_cfg->next, next_pct)
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Expr, row->eval, .edit_string = row->edit_string, .flags = RD_WatchCellFlag_Indented, .default_pct = 0.35f, .pct = take_pct());
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Eval, row->eval, .edit_string = row->edit_string, .flags = RD_WatchCellFlag_Expr|RD_WatchCellFlag_NoEval|RD_WatchCellFlag_Indented, .default_pct = 0.35f, .pct = take_pct());
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Eval, row->eval, .default_pct = 0.65f, .pct = take_pct());
#undef take_pct
}
@@ -1155,7 +1155,10 @@ rd_watch_row_info_from_row(Arena *arena, EV_Row *row)
else if(row->eval.space.kind == RD_EvalSpaceKind_MetaUnattachedProcess &&
str8_match(row_type->name, str8_lit("unattached_process"), 0))
{
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Expr, row->eval, .edit_string = row->edit_string, .flags = RD_WatchCellFlag_Button|RD_WatchCellFlag_Indented, .pct = 1.f);
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Eval, row->eval,
.edit_string = row->edit_string,
.flags = RD_WatchCellFlag_Button|RD_WatchCellFlag_Indented,
.pct = 1.f);
}
////////////////////////////
@@ -1164,7 +1167,7 @@ rd_watch_row_info_from_row(Arena *arena, EV_Row *row)
else if(rd_cfg_child_from_string(rd_cfg_from_id(rd_regs()->view), str8_lit("lister")) != &rd_nil_cfg)
{
info.can_expand = 0;
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Expr, row->eval, .edit_string = row->edit_string, .flags = RD_WatchCellFlag_Button|RD_WatchCellFlag_Indented, .pct = 1.f);
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Eval, row->eval, .edit_string = row->edit_string, .flags = RD_WatchCellFlag_Expr|RD_WatchCellFlag_Button|RD_WatchCellFlag_Indented, .pct = 1.f);
}
////////////////////////////
@@ -1173,7 +1176,7 @@ rd_watch_row_info_from_row(Arena *arena, EV_Row *row)
else if(is_top_level && evalled_cfg != &rd_nil_cfg)
{
RD_Cfg *cfg = evalled_cfg;
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Expr, row->eval, .edit_string = row->edit_string, .flags = RD_WatchCellFlag_Button|RD_WatchCellFlag_Indented, .pct = 1.f);
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Eval, row->eval, .edit_string = row->edit_string, .flags = RD_WatchCellFlag_Button|RD_WatchCellFlag_Indented, .pct = 1.f);
MD_NodePtrList schemas = rd_schemas_from_name(cfg->string);
for(MD_NodePtrNode *n = schemas.first; n != 0; n = n->next)
{
@@ -1243,7 +1246,7 @@ rd_watch_row_info_from_row(Arena *arena, EV_Row *row)
else if(is_top_level && evalled_entity != &ctrl_entity_nil)
{
CTRL_Entity *entity = evalled_entity;
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Expr, row->eval,
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Eval, row->eval,
.edit_string = row->edit_string,
.flags = RD_WatchCellFlag_Indented|RD_WatchCellFlag_Button,
.pct = 1.f);
@@ -1275,7 +1278,7 @@ rd_watch_row_info_from_row(Arena *arena, EV_Row *row)
//
else if(row->eval.space.kind == RD_EvalSpaceKind_MetaQuery)
{
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Expr, row->eval, .edit_string = row->edit_string,.flags = RD_WatchCellFlag_Indented, .pct = 1.f);
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Eval, row->eval, .edit_string = row->edit_string,.flags = RD_WatchCellFlag_Indented, .pct = 1.f);
}
////////////////////////////
@@ -1286,13 +1289,13 @@ rd_watch_row_info_from_row(Arena *arena, EV_Row *row)
E_Type *type = e_type_from_key__cached(row->eval.irtree.type_key);
if(type->kind == E_TypeKind_Set)
{
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Expr, row->eval,
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Eval, row->eval,
.edit_string = row->edit_string,
.flags = RD_WatchCellFlag_Indented, .pct = 1.f);
}
else
{
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Expr, row->eval,
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Eval, row->eval,
.edit_string = row->edit_string,
.flags = RD_WatchCellFlag_Indented|RD_WatchCellFlag_Button|RD_WatchCellFlag_ActivateWithSingleClick,
.pct = 1.f);
@@ -1312,9 +1315,9 @@ rd_watch_row_info_from_row(Arena *arena, EV_Row *row)
//
else if(row->eval.expr == &e_expr_nil && info.group_cfg_name.size != 0 && info.group_cfg_child == &rd_nil_cfg)
{
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Expr, row->eval,
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Eval, row->eval,
.edit_string = row->edit_string,
.flags = RD_WatchCellFlag_Indented, .pct = 1.f);
.flags = RD_WatchCellFlag_Expr|RD_WatchCellFlag_NoEval|RD_WatchCellFlag_Indented, .pct = 1.f);
}
////////////////////////////
@@ -1325,9 +1328,9 @@ rd_watch_row_info_from_row(Arena *arena, EV_Row *row)
row->eval.space.kind == RD_EvalSpaceKind_MetaCmd ||
row->eval.space.kind == RD_EvalSpaceKind_MetaCtrlEntity))
{
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Expr, row->eval,
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Eval, row->eval,
.edit_string = row->edit_string,
.flags = RD_WatchCellFlag_Indented, .pct = 1.f);
.flags = RD_WatchCellFlag_Expr|RD_WatchCellFlag_Indented, .pct = 1.f);
}
////////////////////////////
@@ -1349,9 +1352,9 @@ rd_watch_row_info_from_row(Arena *arena, EV_Row *row)
RD_Cfg *w_cfg = style->first;
F32 next_pct = 0;
#define take_pct() (next_pct = (F32)f64_from_str8(w_cfg->string), w_cfg = w_cfg->next, next_pct)
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Expr, row->eval,
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Eval, row->eval,
.edit_string = row->edit_string,
.flags = RD_WatchCellFlag_Indented, .default_pct = 0.35f, .pct = take_pct());
.flags = RD_WatchCellFlag_Expr|RD_WatchCellFlag_NoEval|RD_WatchCellFlag_Indented, .default_pct = 0.35f, .pct = take_pct());
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Eval, row->eval,
.edit_string = row->edit_string,
.default_pct = 0.65f, .pct = take_pct());
@@ -1369,9 +1372,9 @@ rd_watch_row_info_from_row(Arena *arena, EV_Row *row)
RD_Cfg *w_cfg = style->first;
F32 next_pct = 0;
#define take_pct() (next_pct = (F32)f64_from_str8(w_cfg->string), w_cfg = w_cfg->next, next_pct)
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Expr, row->eval,
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Eval, row->eval,
.edit_string = row->edit_string,
.flags = RD_WatchCellFlag_Indented,
.flags = RD_WatchCellFlag_Expr|RD_WatchCellFlag_NoEval|RD_WatchCellFlag_Indented,
.default_pct = 0.75f,
.pct = take_pct());
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Eval, e_eval_wrapf(arena, row->eval, "lens:hex((uint64)$)"), .default_pct = 0.25f, .pct = take_pct());
@@ -1416,9 +1419,9 @@ rd_watch_row_info_from_row(Arena *arena, EV_Row *row)
RD_Cfg *w_cfg = style->first;
F32 next_pct = 0;
#define take_pct() (next_pct = (F32)f64_from_str8(w_cfg->string), w_cfg = w_cfg->next, next_pct)
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Expr, row->eval,
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Eval, row->eval,
.edit_string = row->edit_string,
.flags = RD_WatchCellFlag_Indented,
.flags = RD_WatchCellFlag_Expr|RD_WatchCellFlag_NoEval|RD_WatchCellFlag_Indented,
.default_pct = 0.35f,
.pct = take_pct());
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Eval, row->eval, .default_pct = 0.40f, .pct = take_pct());
@@ -1489,23 +1492,22 @@ rd_info_from_watch_row_cell(Arena *arena, EV_Row *row, EV_StringFlags string_fla
//////////////////////////////
//- rjf: determine cell editability
//
switch(cell->kind)
if(cell->kind == RD_WatchCellKind_Eval)
{
default:{}break;
case RD_WatchCellKind_Expr:
if(cell->flags & RD_WatchCellFlag_Expr && cell->flags & RD_WatchCellFlag_NoEval)
{
if(row_info->expr_is_editable)
{
result.flags |= RD_WatchCellFlag_CanEdit;
}
}break;
case RD_WatchCellKind_Eval:
}
else
{
if(ev_type_key_is_editable(cell->eval.irtree.type_key) && cell->eval.irtree.mode == E_Mode_Offset)
{
result.flags |= RD_WatchCellFlag_CanEdit;
}
}break;
}
}
//////////////////////////////
@@ -1563,8 +1565,11 @@ rd_info_from_watch_row_cell(Arena *arena, EV_Row *row, EV_StringFlags string_fla
result.flags |= RD_WatchCellFlag_Button;
}
//- rjf: expression cell -> need to form "left-hand-side", or "meta" string, for some evaluation
else if(cell->kind == RD_WatchCellKind_Expr)
//- rjf: catchall cell -> need to form "left-hand-side", or "meta" string, for expression, and/or value string
else
{
//- rjf: build left-hand-side strings
if(cell->flags & RD_WatchCellFlag_Expr)
{
// rjf: funnel-through this cell's string, if it has one
B32 is_non_code = 0;
@@ -1685,7 +1690,7 @@ rd_info_from_watch_row_cell(Arena *arena, EV_Row *row, EV_StringFlags string_fla
}
//- rjf: evaluation -> need to form value string
else if(cell->kind == RD_WatchCellKind_Eval)
if(!(cell->flags & RD_WatchCellFlag_NoEval))
{
// rjf: determine string generation parameters based on evaluation
EV_StringParams string_params = {string_flags, 10};
@@ -1730,6 +1735,7 @@ rd_info_from_watch_row_cell(Arena *arena, EV_Row *row, EV_StringFlags string_fla
result.flags |= RD_WatchCellFlag_IsNonCode;
}
}
}
}break;
//- rjf: unattached processes
+10 -9
View File
@@ -43,8 +43,7 @@ struct RD_CodeViewBuildResult
typedef enum RD_WatchCellKind
{
RD_WatchCellKind_Expr, // strings to represent expression itself
RD_WatchCellKind_Eval, // an evaluation of the expression, with some optional modification - e.g. `$expr.some_member`, or `typeof($expr)`
RD_WatchCellKind_Eval, // an evaluation cell
RD_WatchCellKind_ViewUI, // an arbitrary user interface, supplied by a hook
RD_WatchCellKind_CallStackFrame, // a slot for a yellow arrow, to show call stack frame selection
}
@@ -53,13 +52,15 @@ RD_WatchCellKind;
typedef U32 RD_WatchCellFlags;
enum
{
RD_WatchCellFlag_Button = (1<<0),
RD_WatchCellFlag_Background = (1<<1),
RD_WatchCellFlag_ActivateWithSingleClick = (1<<2),
RD_WatchCellFlag_IsNonCode = (1<<3),
RD_WatchCellFlag_CanEdit = (1<<4),
RD_WatchCellFlag_IsErrored = (1<<5),
RD_WatchCellFlag_Indented = (1<<6),
RD_WatchCellFlag_Expr = (1<<0),
RD_WatchCellFlag_NoEval = (1<<1),
RD_WatchCellFlag_Button = (1<<2),
RD_WatchCellFlag_Background = (1<<3),
RD_WatchCellFlag_ActivateWithSingleClick = (1<<4),
RD_WatchCellFlag_IsNonCode = (1<<5),
RD_WatchCellFlag_CanEdit = (1<<6),
RD_WatchCellFlag_IsErrored = (1<<7),
RD_WatchCellFlag_Indented = (1<<8),
};
typedef struct RD_WatchCell RD_WatchCell;