Skip to content

Commit 7adf08c

Browse files
committed
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)
1 parent a202999 commit 7adf08c

File tree

4 files changed

+17
-13
lines changed

4 files changed

+17
-13
lines changed

src/raddbg/raddbg_core.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2748,7 +2748,7 @@ rd_whole_range_from_eval_space(E_Space space)
27482748
//- rjf: writing values back to child processes
27492749

27502750
internal B32
2751-
rd_commit_eval_value_string(E_Eval dst_eval, String8 string)
2751+
rd_commit_eval_value_string(E_Eval dst_eval, String8 string, B32 string_needs_unescaping)
27522752
{
27532753
B32 result = 0;
27542754
if(dst_eval.mode == E_Mode_Offset)
@@ -2776,14 +2776,17 @@ rd_commit_eval_value_string(E_Eval dst_eval, String8 string)
27762776
e_type_kind_is_integer(direct_type_kind))
27772777
{
27782778
B32 is_quoted = 0;
2779-
if(string.size >= 1 && string.str[0] == '"')
2779+
if(string_needs_unescaping)
27802780
{
2781-
string = str8_skip(string, 1);
2782-
is_quoted = 1;
2783-
}
2784-
if(string.size >= 1 && string.str[string.size-1] == '"')
2785-
{
2786-
string = str8_chop(string, 1);
2781+
if(string.size >= 1 && string.str[0] == '"')
2782+
{
2783+
string = str8_skip(string, 1);
2784+
is_quoted = 1;
2785+
}
2786+
if(string.size >= 1 && string.str[string.size-1] == '"')
2787+
{
2788+
string = str8_chop(string, 1);
2789+
}
27872790
}
27882791
if(is_quoted)
27892792
{
@@ -6850,7 +6853,7 @@ rd_window_frame(RD_Window *ws)
68506853
if(ui_committed(sig))
68516854
{
68526855
String8 commit_string = str8(ws->hover_eval_txt_buffer, ws->hover_eval_txt_size);
6853-
B32 success = rd_commit_eval_value_string(row_eval, commit_string);
6856+
B32 success = rd_commit_eval_value_string(row_eval, commit_string, 1);
68546857
if(success == 0)
68556858
{
68566859
log_user_error(str8_lit("Could not commit value successfully."));

src/raddbg/raddbg_core.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1255,7 +1255,7 @@ internal Rng1U64 rd_whole_range_from_eval_space(E_Space space);
12551255
//~ rjf: Evaluation Visualization
12561256

12571257
//- rjf: writing values back to child processes
1258-
internal B32 rd_commit_eval_value_string(E_Eval dst_eval, String8 string);
1258+
internal B32 rd_commit_eval_value_string(E_Eval dst_eval, String8 string, B32 string_needs_unescaping);
12591259

12601260
//- rjf: eval / view rule params tree info extraction
12611261
internal U64 rd_base_offset_from_eval(E_Eval eval);

src/raddbg/raddbg_main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
//~ rjf: post-0.9.12 TODO notes
66
//
77
// [ ] fix quote input in quoteless watch window value editors
8+
// [ ] fix light themes
89
//
910
//
1011
// [ ] double click on breakpoints/watch-pins/etc. to go to location

src/raddbg/raddbg_views.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1747,7 +1747,7 @@ rd_watch_view_build(RD_WatchViewState *ewv, RD_WatchViewFlags flags, String8 roo
17471747
{
17481748
E_Expr *expr = rd_expr_from_watch_view_row_column(scratch.arena, eval_view, row, col);
17491749
E_Eval dst_eval = e_eval_from_expr(scratch.arena, expr);
1750-
success = rd_commit_eval_value_string(dst_eval, new_string);
1750+
success = rd_commit_eval_value_string(dst_eval, new_string, !col->dequote_string);
17511751
}
17521752
if(!success)
17531753
{
@@ -1893,7 +1893,7 @@ rd_watch_view_build(RD_WatchViewState *ewv, RD_WatchViewFlags flags, String8 roo
18931893
{
18941894
E_Expr *expr = rd_expr_from_watch_view_row_column(scratch.arena, eval_view, row, col);
18951895
E_Eval dst_eval = e_eval_from_expr(scratch.arena, expr);
1896-
rd_commit_eval_value_string(dst_eval, str8_zero());
1896+
rd_commit_eval_value_string(dst_eval, str8_zero(), 0);
18971897
}
18981898
}
18991899
}
@@ -7473,7 +7473,7 @@ RD_VIEW_RULE_UI_FUNCTION_DEF(checkbox)
74737473
E_Eval value_eval = e_value_eval_from_eval(eval);
74747474
if(ui_clicked(rd_icon_buttonf(value_eval.value.u64 == 0 ? RD_IconKind_CheckHollow : RD_IconKind_CheckFilled, 0, "###check")))
74757475
{
7476-
rd_commit_eval_value_string(eval, value_eval.value.u64 == 0 ? str8_lit("1") : str8_lit("0"));
7476+
rd_commit_eval_value_string(eval, value_eval.value.u64 == 0 ? str8_lit("1") : str8_lit("0"), 0);
74777477
}
74787478
scratch_end(scratch);
74797479
}

0 commit comments

Comments
 (0)