From 7adf08cc7be0c9d5e3223a830dcd5f87c6bf9b75 Mon Sep 17 00:00:00 2001 From: Ryan Fleury Date: Thu, 17 Oct 2024 12:57:53 -0700 Subject: [PATCH] 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) --- src/raddbg/raddbg_core.c | 21 ++++++++++++--------- src/raddbg/raddbg_core.h | 2 +- src/raddbg/raddbg_main.c | 1 + src/raddbg/raddbg_views.c | 6 +++--- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/raddbg/raddbg_core.c b/src/raddbg/raddbg_core.c index d249db60..abebece2 100644 --- a/src/raddbg/raddbg_core.c +++ b/src/raddbg/raddbg_core.c @@ -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.")); diff --git a/src/raddbg/raddbg_core.h b/src/raddbg/raddbg_core.h index c43e5682..ed10ed8c 100644 --- a/src/raddbg/raddbg_core.h +++ b/src/raddbg/raddbg_core.h @@ -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); diff --git a/src/raddbg/raddbg_main.c b/src/raddbg/raddbg_main.c index ba542ced..2663d668 100644 --- a/src/raddbg/raddbg_main.c +++ b/src/raddbg/raddbg_main.c @@ -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 diff --git a/src/raddbg/raddbg_views.c b/src/raddbg/raddbg_views.c index 9f78959f..c4399f77 100644 --- a/src/raddbg/raddbg_views.c +++ b/src/raddbg/raddbg_views.c @@ -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); }