parameterize string eval commit path by whether or not the surrounding ui expects the string to be manually escaped or not by the user (it is not in the case of things like the meta-entity views)

This commit is contained in:
Ryan Fleury
2024-10-17 12:57:53 -07:00
parent a202999655
commit 7adf08cc7b
4 changed files with 17 additions and 13 deletions
+12 -9
View File
@@ -2748,7 +2748,7 @@ rd_whole_range_from_eval_space(E_Space space)
//- rjf: writing values back to child processes
internal B32
rd_commit_eval_value_string(E_Eval dst_eval, String8 string)
rd_commit_eval_value_string(E_Eval dst_eval, String8 string, B32 string_needs_unescaping)
{
B32 result = 0;
if(dst_eval.mode == E_Mode_Offset)
@@ -2776,14 +2776,17 @@ rd_commit_eval_value_string(E_Eval dst_eval, String8 string)
e_type_kind_is_integer(direct_type_kind))
{
B32 is_quoted = 0;
if(string.size >= 1 && string.str[0] == '"')
if(string_needs_unescaping)
{
string = str8_skip(string, 1);
is_quoted = 1;
}
if(string.size >= 1 && string.str[string.size-1] == '"')
{
string = str8_chop(string, 1);
if(string.size >= 1 && string.str[0] == '"')
{
string = str8_skip(string, 1);
is_quoted = 1;
}
if(string.size >= 1 && string.str[string.size-1] == '"')
{
string = str8_chop(string, 1);
}
}
if(is_quoted)
{
@@ -6850,7 +6853,7 @@ rd_window_frame(RD_Window *ws)
if(ui_committed(sig))
{
String8 commit_string = str8(ws->hover_eval_txt_buffer, ws->hover_eval_txt_size);
B32 success = rd_commit_eval_value_string(row_eval, commit_string);
B32 success = rd_commit_eval_value_string(row_eval, commit_string, 1);
if(success == 0)
{
log_user_error(str8_lit("Could not commit value successfully."));
+1 -1
View File
@@ -1255,7 +1255,7 @@ internal Rng1U64 rd_whole_range_from_eval_space(E_Space space);
//~ rjf: Evaluation Visualization
//- rjf: writing values back to child processes
internal B32 rd_commit_eval_value_string(E_Eval dst_eval, String8 string);
internal B32 rd_commit_eval_value_string(E_Eval dst_eval, String8 string, B32 string_needs_unescaping);
//- rjf: eval / view rule params tree info extraction
internal U64 rd_base_offset_from_eval(E_Eval eval);
+1
View File
@@ -5,6 +5,7 @@
//~ rjf: post-0.9.12 TODO notes
//
// [ ] fix quote input in quoteless watch window value editors
// [ ] fix light themes
//
//
// [ ] double click on breakpoints/watch-pins/etc. to go to location
+3 -3
View File
@@ -1747,7 +1747,7 @@ rd_watch_view_build(RD_WatchViewState *ewv, RD_WatchViewFlags flags, String8 roo
{
E_Expr *expr = rd_expr_from_watch_view_row_column(scratch.arena, eval_view, row, col);
E_Eval dst_eval = e_eval_from_expr(scratch.arena, expr);
success = rd_commit_eval_value_string(dst_eval, new_string);
success = rd_commit_eval_value_string(dst_eval, new_string, !col->dequote_string);
}
if(!success)
{
@@ -1893,7 +1893,7 @@ rd_watch_view_build(RD_WatchViewState *ewv, RD_WatchViewFlags flags, String8 roo
{
E_Expr *expr = rd_expr_from_watch_view_row_column(scratch.arena, eval_view, row, col);
E_Eval dst_eval = e_eval_from_expr(scratch.arena, expr);
rd_commit_eval_value_string(dst_eval, str8_zero());
rd_commit_eval_value_string(dst_eval, str8_zero(), 0);
}
}
}
@@ -7473,7 +7473,7 @@ RD_VIEW_RULE_UI_FUNCTION_DEF(checkbox)
E_Eval value_eval = e_value_eval_from_eval(eval);
if(ui_clicked(rd_icon_buttonf(value_eval.value.u64 == 0 ? RD_IconKind_CheckHollow : RD_IconKind_CheckFilled, 0, "###check")))
{
rd_commit_eval_value_string(eval, value_eval.value.u64 == 0 ? str8_lit("1") : str8_lit("0"));
rd_commit_eval_value_string(eval, value_eval.value.u64 == 0 ? str8_lit("1") : str8_lit("0"), 0);
}
scratch_end(scratch);
}