From f2a7103461a55dc29e283960155c8576e70ad32c Mon Sep 17 00:00:00 2001 From: Ryan Fleury Date: Fri, 28 Jun 2024 09:14:58 -0700 Subject: [PATCH] watch-expr-at-mouse command --- src/df/core/df_core.mdesk | 1 + src/df/core/generated/df_core.meta.c | 3 ++- src/df/core/generated/df_core.meta.h | 1 + src/df/gfx/df_gfx.mdesk | 1 + src/df/gfx/df_views.c | 14 ++++++++++++++ src/df/gfx/df_views.h | 1 + src/df/gfx/generated/df_gfx.meta.c | 3 ++- src/df/gfx/generated/df_gfx.meta.h | 2 +- src/raddbg/raddbg.h | 7 +++---- 9 files changed, 26 insertions(+), 7 deletions(-) diff --git a/src/df/core/df_core.mdesk b/src/df/core/df_core.mdesk index a062c6a0..d74ccae1 100644 --- a/src/df/core/df_core.mdesk +++ b/src/df/core/df_core.mdesk @@ -315,6 +315,7 @@ DF_CoreCmdTable:// | | | //- rjf: watch expressions {ToggleWatchExpression 0 Null Nil 0 0 0 0 0 0 Binoculars "toggle_watch_expr" "Toggle Watch Expression" "Adds or removes an expression to an opened watch view." "" } {ToggleWatchExpressionAtCursor 0 Null Nil 0 0 0 0 0 0 Binoculars "toggle_watch_expr_at_cursor" "Toggle Watch Expression At Cursor" "Adds or removes the expression that the cursor or selection is currently over to an opened watch view." "" } + {ToggleWatchExpressionAtMouse 0 Null Nil 0 0 0 0 0 0 Binoculars "toggle_watch_expr_at_mouse" "Toggle Watch Expression At Mouse" "Adds or removes the expression that the mouse is currently over to an opened watch view." "" } //- rjf: memory view parameterization {SetColumns 0 Index Nil 0 0 0 0 1 1 Thumbnails "set_columns" "Set Columns" "Sets the number of columns for a memory view." "" } diff --git a/src/df/core/generated/df_core.meta.c b/src/df/core/generated/df_core.meta.c index 7f6d400e..fb610edb 100644 --- a/src/df/core/generated/df_core.meta.c +++ b/src/df/core/generated/df_core.meta.c @@ -209,7 +209,7 @@ DF_CoreCmdKind_Null, DF_CoreCmdKind_Null, }; -DF_CmdSpecInfo df_g_core_cmd_kind_spec_info_table[220] = +DF_CmdSpecInfo df_g_core_cmd_kind_spec_info_table[221] = { { str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp(""), (DF_CmdSpecFlag_OmitFromLists*1), {DF_CmdParamSlot_Null, DF_EntityKind_Nil, (DF_CmdQueryFlag_AllowFiles*0)|(DF_CmdQueryFlag_AllowFolders*0)|(DF_CmdQueryFlag_CodeInput*0)|(DF_CmdQueryFlag_KeepOldInput*0)|(DF_CmdQueryFlag_SelectOldInput*0)|(DF_CmdQueryFlag_Required*0)}, DF_IconKind_Null}, { str8_lit_comp("exit"), str8_lit_comp("Exits the debugger."), str8_lit_comp("quit,close,abort"), str8_lit_comp("Exit"), (DF_CmdSpecFlag_OmitFromLists*0), {DF_CmdParamSlot_Null, DF_EntityKind_Nil, (DF_CmdQueryFlag_AllowFiles*0)|(DF_CmdQueryFlag_AllowFolders*0)|(DF_CmdQueryFlag_CodeInput*0)|(DF_CmdQueryFlag_KeepOldInput*0)|(DF_CmdQueryFlag_SelectOldInput*0)|(DF_CmdQueryFlag_Required*0)}, DF_IconKind_X}, @@ -364,6 +364,7 @@ DF_CmdSpecInfo df_g_core_cmd_kind_spec_info_table[220] = { str8_lit_comp("goto_name_at_cursor"), str8_lit_comp("Searches for the text at the cursor as a file, a symbol in debug info, and more, then jumps to it if possible."), str8_lit_comp(""), str8_lit_comp("Go To Name At Cursor"), (DF_CmdSpecFlag_OmitFromLists*0), {DF_CmdParamSlot_Null, DF_EntityKind_Nil, (DF_CmdQueryFlag_AllowFiles*0)|(DF_CmdQueryFlag_AllowFolders*0)|(DF_CmdQueryFlag_CodeInput*0)|(DF_CmdQueryFlag_KeepOldInput*0)|(DF_CmdQueryFlag_SelectOldInput*0)|(DF_CmdQueryFlag_Required*0)}, DF_IconKind_Null}, { str8_lit_comp("toggle_watch_expr"), str8_lit_comp("Adds or removes an expression to an opened watch view."), str8_lit_comp(""), str8_lit_comp("Toggle Watch Expression"), (DF_CmdSpecFlag_OmitFromLists*0), {DF_CmdParamSlot_Null, DF_EntityKind_Nil, (DF_CmdQueryFlag_AllowFiles*0)|(DF_CmdQueryFlag_AllowFolders*0)|(DF_CmdQueryFlag_CodeInput*0)|(DF_CmdQueryFlag_KeepOldInput*0)|(DF_CmdQueryFlag_SelectOldInput*0)|(DF_CmdQueryFlag_Required*0)}, DF_IconKind_Binoculars}, { str8_lit_comp("toggle_watch_expr_at_cursor"), str8_lit_comp("Adds or removes the expression that the cursor or selection is currently over to an opened watch view."), str8_lit_comp(""), str8_lit_comp("Toggle Watch Expression At Cursor"), (DF_CmdSpecFlag_OmitFromLists*0), {DF_CmdParamSlot_Null, DF_EntityKind_Nil, (DF_CmdQueryFlag_AllowFiles*0)|(DF_CmdQueryFlag_AllowFolders*0)|(DF_CmdQueryFlag_CodeInput*0)|(DF_CmdQueryFlag_KeepOldInput*0)|(DF_CmdQueryFlag_SelectOldInput*0)|(DF_CmdQueryFlag_Required*0)}, DF_IconKind_Binoculars}, +{ str8_lit_comp("toggle_watch_expr_at_mouse"), str8_lit_comp("Adds or removes the expression that the mouse is currently over to an opened watch view."), str8_lit_comp(""), str8_lit_comp("Toggle Watch Expression At Mouse"), (DF_CmdSpecFlag_OmitFromLists*0), {DF_CmdParamSlot_Null, DF_EntityKind_Nil, (DF_CmdQueryFlag_AllowFiles*0)|(DF_CmdQueryFlag_AllowFolders*0)|(DF_CmdQueryFlag_CodeInput*0)|(DF_CmdQueryFlag_KeepOldInput*0)|(DF_CmdQueryFlag_SelectOldInput*0)|(DF_CmdQueryFlag_Required*0)}, DF_IconKind_Binoculars}, { str8_lit_comp("set_columns"), str8_lit_comp("Sets the number of columns for a memory view."), str8_lit_comp(""), str8_lit_comp("Set Columns"), (DF_CmdSpecFlag_OmitFromLists*0), {DF_CmdParamSlot_Index, DF_EntityKind_Nil, (DF_CmdQueryFlag_AllowFiles*0)|(DF_CmdQueryFlag_AllowFolders*0)|(DF_CmdQueryFlag_CodeInput*1)|(DF_CmdQueryFlag_KeepOldInput*0)|(DF_CmdQueryFlag_SelectOldInput*0)|(DF_CmdQueryFlag_Required*1)}, DF_IconKind_Thumbnails}, { str8_lit_comp("toggle_address_visibility"), str8_lit_comp("Toggles the visibility of addresses in a disassembly view."), str8_lit_comp(""), str8_lit_comp("Toggle Address Visibility"), (DF_CmdSpecFlag_OmitFromLists*0), {DF_CmdParamSlot_Null, DF_EntityKind_Nil, (DF_CmdQueryFlag_AllowFiles*0)|(DF_CmdQueryFlag_AllowFolders*0)|(DF_CmdQueryFlag_CodeInput*0)|(DF_CmdQueryFlag_KeepOldInput*0)|(DF_CmdQueryFlag_SelectOldInput*0)|(DF_CmdQueryFlag_Required*0)}, DF_IconKind_Thumbnails}, { str8_lit_comp("toggle_code_bytes_visibility"), str8_lit_comp("Toggles the visibility of machine code bytes in a disassembly view."), str8_lit_comp(""), str8_lit_comp("Toggle Code Bytes Visibility"), (DF_CmdSpecFlag_OmitFromLists*0), {DF_CmdParamSlot_Null, DF_EntityKind_Nil, (DF_CmdQueryFlag_AllowFiles*0)|(DF_CmdQueryFlag_AllowFolders*0)|(DF_CmdQueryFlag_CodeInput*0)|(DF_CmdQueryFlag_KeepOldInput*0)|(DF_CmdQueryFlag_SelectOldInput*0)|(DF_CmdQueryFlag_Required*0)}, DF_IconKind_Thumbnails}, diff --git a/src/df/core/generated/df_core.meta.h b/src/df/core/generated/df_core.meta.h index c40cf0f1..8bf2e41b 100644 --- a/src/df/core/generated/df_core.meta.h +++ b/src/df/core/generated/df_core.meta.h @@ -200,6 +200,7 @@ DF_CoreCmdKind_GoToName, DF_CoreCmdKind_GoToNameAtCursor, DF_CoreCmdKind_ToggleWatchExpression, DF_CoreCmdKind_ToggleWatchExpressionAtCursor, +DF_CoreCmdKind_ToggleWatchExpressionAtMouse, DF_CoreCmdKind_SetColumns, DF_CoreCmdKind_ToggleAddressVisibility, DF_CoreCmdKind_ToggleCodeBytesVisibility, diff --git a/src/df/gfx/df_gfx.mdesk b/src/df/gfx/df_gfx.mdesk index 382806a2..2dd38e76 100644 --- a/src/df/gfx/df_gfx.mdesk +++ b/src/df/gfx/df_gfx.mdesk @@ -155,6 +155,7 @@ DF_DefaultBindingTable: //- rjf: watch expressions { "toggle_watch_expr_at_cursor" W 0 0 alt } + { "toggle_watch_expr_at_mouse" D ctrl 0 0 } { "toggle_watch_pin_at_cursor" F9 ctrl 0 0 } //- rjf: breakpoints diff --git a/src/df/gfx/df_views.c b/src/df/gfx/df_views.c index 56180cbd..572d2c3b 100644 --- a/src/df/gfx/df_views.c +++ b/src/df/gfx/df_views.c @@ -450,6 +450,10 @@ df_code_view_cmds(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_CodeViewStat arena_clear(cv->find_text_arena); cv->find_text_bwd = push_str8_copy(cv->find_text_arena, cmd->params.string); }break; + case DF_CoreCmdKind_ToggleWatchExpressionAtMouse: + { + cv->watch_expr_at_mouse = 1; + }break; } } } @@ -974,6 +978,16 @@ df_code_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_CodeViewSta df_push_cmd__root(¶ms, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_GoToName)); } + //- rjf: watch expr at mouse + if(cv->watch_expr_at_mouse) + { + cv->watch_expr_at_mouse = 0; + DF_CmdParams params = df_cmd_params_from_view(ws, panel, view); + params.string = txt_string_from_info_data_txt_rng(text_info, text_data, sig.mouse_expr_rng); + df_cmd_params_mark_slot(¶ms, DF_CmdParamSlot_String); + df_push_cmd__root(¶ms, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_ToggleWatchExpression)); + } + //- rjf: selected text on single line, no query? -> set search text if(!txt_pt_match(view->cursor, view->mark) && view->cursor.line == view->mark.line && search_query.size == 0) { diff --git a/src/df/gfx/df_views.h b/src/df/gfx/df_views.h index 88e7ed5e..51373c3a 100644 --- a/src/df/gfx/df_views.h +++ b/src/df/gfx/df_views.h @@ -388,6 +388,7 @@ struct DF_CodeViewState S64 goto_line_num; B32 center_cursor; B32 contain_cursor; + B32 watch_expr_at_mouse; Arena *find_text_arena; String8 find_text_fwd; String8 find_text_bwd; diff --git a/src/df/gfx/generated/df_gfx.meta.c b/src/df/gfx/generated/df_gfx.meta.c index 6f0fc162..de2ad4bb 100644 --- a/src/df/gfx/generated/df_gfx.meta.c +++ b/src/df/gfx/generated/df_gfx.meta.c @@ -4,7 +4,7 @@ //- GENERATED CODE C_LINKAGE_BEGIN -DF_StringBindingPair df_g_default_binding_table[105] = +DF_StringBindingPair df_g_default_binding_table[106] = { {str8_lit_comp("kill_all"), {OS_Key_F5, 0 |OS_EventFlag_Shift }}, {str8_lit_comp("step_into_inst"), {OS_Key_F11, 0 |OS_EventFlag_Alt}}, @@ -104,6 +104,7 @@ DF_StringBindingPair df_g_default_binding_table[105] = {str8_lit_comp("goto_name"), {OS_Key_J, 0 |OS_EventFlag_Ctrl }}, {str8_lit_comp("goto_name_at_cursor"), {OS_Key_F12, 0 }}, {str8_lit_comp("toggle_watch_expr_at_cursor"), {OS_Key_W, 0 |OS_EventFlag_Alt}}, +{str8_lit_comp("toggle_watch_expr_at_mouse"), {OS_Key_D, 0 |OS_EventFlag_Ctrl }}, {str8_lit_comp("toggle_watch_pin_at_cursor"), {OS_Key_F9, 0 |OS_EventFlag_Ctrl }}, {str8_lit_comp("toggle_breakpoint_cursor"), {OS_Key_F9, 0 }}, {str8_lit_comp("add_target"), {OS_Key_T, 0 |OS_EventFlag_Ctrl }}, diff --git a/src/df/gfx/generated/df_gfx.meta.h b/src/df/gfx/generated/df_gfx.meta.h index 7710a112..0dc30118 100644 --- a/src/df/gfx/generated/df_gfx.meta.h +++ b/src/df/gfx/generated/df_gfx.meta.h @@ -314,7 +314,7 @@ DF_VIEW_UI_FUNCTION_DEF(disasm); DF_VIEW_UI_FUNCTION_DEF(bitmap); DF_VIEW_UI_FUNCTION_DEF(geo); C_LINKAGE_BEGIN -extern DF_StringBindingPair df_g_default_binding_table[105]; +extern DF_StringBindingPair df_g_default_binding_table[106]; extern String8 df_g_binding_version_remap_old_name_table[5]; extern String8 df_g_binding_version_remap_new_name_table[5]; extern DF_ViewSpecInfo df_g_gfx_view_kind_spec_info_table[31]; diff --git a/src/raddbg/raddbg.h b/src/raddbg/raddbg.h index 7cf9d53b..634383f1 100644 --- a/src/raddbg/raddbg.h +++ b/src/raddbg/raddbg.h @@ -112,10 +112,6 @@ // [ ] lock icon // [ ] "rotation arrow" icon next to executables // -// [ ] I LOVE ALT-W to add watch under cursor, but I would prefer to have it -// add what's under the MOUSE cursor instead of the keyboard cursor. Can -// we get a command for that so I can bind ALT-W to that instead? -// // [ ] For theme editing, when you hove the mouse over a theme color entry and // it highlights that entry, it might help to temporarily change that // color to white (or the inverse of the background color, or whatever) so @@ -410,6 +406,9 @@ // sometimes both source code and menu/tab/watch font size, sometimes // just menu/tab/watch font size not source size. // [x] colors: fill out rest of theme presets for new theme setup +// [x] I LOVE ALT-W to add watch under cursor, but I would prefer to have it +// add what's under the MOUSE cursor instead of the keyboard cursor. Can +// we get a command for that so I can bind ALT-W to that instead? #ifndef RADDBG_H #define RADDBG_H