From 56afe8ca603680eb22b4ca81ebb80b9f629879f5 Mon Sep 17 00:00:00 2001 From: Ryan Fleury Date: Wed, 15 May 2024 11:57:46 -0700 Subject: [PATCH] watch window reordering --- src/df/core/df_core.mdesk | 2 ++ src/df/core/generated/df_core.meta.c | 4 ++- src/df/core/generated/df_core.meta.h | 2 ++ src/df/gfx/df_gfx.c | 18 ++++++++++++ src/df/gfx/df_gfx.mdesk | 2 ++ src/df/gfx/df_views.c | 42 ++++++++++++++++++++++++++-- src/df/gfx/generated/df_gfx.meta.c | 4 ++- src/df/gfx/generated/df_gfx.meta.h | 2 +- src/raddbg/raddbg.h | 4 +-- src/ui/ui_core.h | 1 + 10 files changed, 74 insertions(+), 7 deletions(-) diff --git a/src/df/core/df_core.mdesk b/src/df/core/df_core.mdesk index 355a3a15..cf37ac1e 100644 --- a/src/df/core/df_core.mdesk +++ b/src/df/core/df_core.mdesk @@ -281,6 +281,8 @@ DF_CoreCmdTable:// | | | {MoveDownPageSelect 0 Null Nil 0 0 0 0 0 0 Null "move_down_page_select" "Move Down Page Select" "Moves the cursor or selection down one page, while selecting." "" } {MoveUpWholeSelect 0 Null Nil 0 0 0 0 0 0 Null "move_up_whole_select" "Move Up Whole Select" "Moves the cursor or selection to the beginning of the relevant content, while selecting." "" } {MoveDownWholeSelect 0 Null Nil 0 0 0 0 0 0 Null "move_down_whole_select" "Move Down Whole Select" "Moves the cursor or selection to the end of the relevant content, while selecting." "" } + {MoveUpReorder 0 Null Nil 0 0 0 0 0 0 Null "move_up_reorder" "Move Up Reorder" "Moves the cursor or selection up, while swapping the currently selected element with that upward." "" } + {MoveDownReorder 0 Null Nil 0 0 0 0 0 0 Null "move_down_reorder" "Move Down Reorder" "Moves the cursor or selection down, while swapping the currently selected element with that downward." "" } {MoveHome 0 Null Nil 0 0 0 0 0 0 Null "move_home" "Move Home" "Moves the cursor to the beginning of the line." "" } {MoveEnd 0 Null Nil 0 0 0 0 0 0 Null "move_end" "Move End" "Moves the cursor to the end of the line." "" } {MoveHomeSelect 0 Null Nil 0 0 0 0 0 0 Null "move_home_select" "Move Home Select" "Moves the cursor to the beginning of the line, while selecting." "" } diff --git a/src/df/core/generated/df_core.meta.c b/src/df/core/generated/df_core.meta.c index 9638f520..03e9c0f9 100644 --- a/src/df/core/generated/df_core.meta.c +++ b/src/df/core/generated/df_core.meta.c @@ -217,7 +217,7 @@ DF_CoreCmdKind_Null, DF_CoreCmdKind_Null, }; -DF_CmdSpecInfo df_g_core_cmd_kind_spec_info_table[218] = +DF_CmdSpecInfo df_g_core_cmd_kind_spec_info_table[220] = { { 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}, @@ -344,6 +344,8 @@ DF_CmdSpecInfo df_g_core_cmd_kind_spec_info_table[218] = { str8_lit_comp("move_down_page_select"), str8_lit_comp("Moves the cursor or selection down one page, while selecting."), str8_lit_comp(""), str8_lit_comp("Move Down Page Select"), (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("move_up_whole_select"), str8_lit_comp("Moves the cursor or selection to the beginning of the relevant content, while selecting."), str8_lit_comp(""), str8_lit_comp("Move Up Whole Select"), (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("move_down_whole_select"), str8_lit_comp("Moves the cursor or selection to the end of the relevant content, while selecting."), str8_lit_comp(""), str8_lit_comp("Move Down Whole Select"), (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("move_up_reorder"), str8_lit_comp("Moves the cursor or selection up, while swapping the currently selected element with that upward."), str8_lit_comp(""), str8_lit_comp("Move Up Reorder"), (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("move_down_reorder"), str8_lit_comp("Moves the cursor or selection down, while swapping the currently selected element with that downward."), str8_lit_comp(""), str8_lit_comp("Move Down Reorder"), (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("move_home"), str8_lit_comp("Moves the cursor to the beginning of the line."), str8_lit_comp(""), str8_lit_comp("Move Home"), (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("move_end"), str8_lit_comp("Moves the cursor to the end of the line."), str8_lit_comp(""), str8_lit_comp("Move End"), (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("move_home_select"), str8_lit_comp("Moves the cursor to the beginning of the line, while selecting."), str8_lit_comp(""), str8_lit_comp("Move Home Select"), (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}, diff --git a/src/df/core/generated/df_core.meta.h b/src/df/core/generated/df_core.meta.h index ebdb155f..9e7faeef 100644 --- a/src/df/core/generated/df_core.meta.h +++ b/src/df/core/generated/df_core.meta.h @@ -174,6 +174,8 @@ DF_CoreCmdKind_MoveUpPageSelect, DF_CoreCmdKind_MoveDownPageSelect, DF_CoreCmdKind_MoveUpWholeSelect, DF_CoreCmdKind_MoveDownWholeSelect, +DF_CoreCmdKind_MoveUpReorder, +DF_CoreCmdKind_MoveDownReorder, DF_CoreCmdKind_MoveHome, DF_CoreCmdKind_MoveEnd, DF_CoreCmdKind_MoveHomeSelect, diff --git a/src/df/gfx/df_gfx.c b/src/df/gfx/df_gfx.c index 36968c75..686c2c53 100644 --- a/src/df/gfx/df_gfx.c +++ b/src/df/gfx/df_gfx.c @@ -2348,6 +2348,24 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) evt.delta_2s32 = v2s32(+0, +1); ui_event_list_push(ui_build_arena(), &events, &evt); }break; + case DF_CoreCmdKind_MoveUpReorder: + { + UI_Event evt = zero_struct; + evt.kind = UI_EventKind_Navigate; + evt.flags = UI_EventFlag_Reorder; + evt.delta_unit = UI_EventDeltaUnit_Char; + evt.delta_2s32 = v2s32(+0, -1); + ui_event_list_push(ui_build_arena(), &events, &evt); + }break; + case DF_CoreCmdKind_MoveDownReorder: + { + UI_Event evt = zero_struct; + evt.kind = UI_EventKind_Navigate; + evt.flags = UI_EventFlag_Reorder; + evt.delta_unit = UI_EventDeltaUnit_Char; + evt.delta_2s32 = v2s32(+0, +1); + ui_event_list_push(ui_build_arena(), &events, &evt); + }break; case DF_CoreCmdKind_MoveHome: { UI_Event evt = zero_struct; diff --git a/src/df/gfx/df_gfx.mdesk b/src/df/gfx/df_gfx.mdesk index 38470bad..3620c593 100644 --- a/src/df/gfx/df_gfx.mdesk +++ b/src/df/gfx/df_gfx.mdesk @@ -120,6 +120,8 @@ DF_DefaultBindingTable: { "move_down_page_select" PageDown 0 shift 0 } { "move_up_whole_select" Home ctrl shift 0 } { "move_down_whole_select" End ctrl shift 0 } + { "move_up_reorder" Up 0 0 alt } + { "move_down_reorder" Down 0 0 alt } { "move_home" Home 0 0 0 } { "move_end" End 0 0 0 } { "move_home_select" Home 0 shift 0 } diff --git a/src/df/gfx/df_views.c b/src/df/gfx/df_views.c index ba2b20c4..f35d43fc 100644 --- a/src/df/gfx/df_views.c +++ b/src/df/gfx/df_views.c @@ -1302,7 +1302,7 @@ df_watch_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_WatchViewS ////////////////////////// //- rjf: [table] apply deltas to cursor & mark // - if(!ewv->text_editing && !(evt->flags & UI_EventFlag_Delete)) + if(!ewv->text_editing && !(evt->flags & UI_EventFlag_Delete) && !(evt->flags & UI_EventFlag_Reorder)) { B32 cursor_tbl_min_is_empty_selection[Axis2_COUNT] = {0, 1}; Rng2S64 cursor_tbl_range = r2s64(v2s64(0, 0), v2s64(3, blocks.total_semantic_row_count)); @@ -1417,6 +1417,44 @@ df_watch_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_WatchViewS } } + ////////////////////////// + //- rjf: [table] do cell-granularity reorders + // + if(!ewv->text_editing && evt->flags & UI_EventFlag_Reorder) + { + taken = 1; + DF_ExpandKey first_root_key = df_key_from_viz_block_list_row_num(&blocks, selection_tbl.min.y); + DF_EvalRoot *first_root = df_eval_root_from_expand_key(ewv, eval_view, first_root_key); + DF_EvalRoot *last_root = first_root; + if(first_root != 0) + { + for(S64 y = selection_tbl.min.y+1; y <= selection_tbl.max.y; y += 1) + { + DF_ExpandKey key = df_key_from_viz_block_list_row_num(&blocks, y); + DF_EvalRoot *new_root = df_eval_root_from_expand_key(ewv, eval_view, key); + if(new_root != 0) + { + last_root = new_root; + } + } + } + if(evt->delta_2s32.y < 0 && first_root != 0 && first_root->prev != 0) + { + state_dirty = 1; + DF_EvalRoot *reordered = first_root->prev; + DLLRemove(ewv->first_root, ewv->last_root, reordered); + DLLInsert(ewv->first_root, ewv->last_root, last_root, reordered); + } + if(evt->delta_2s32.y > 0 && last_root != 0 && last_root->next != 0) + { + state_dirty = 1; + DF_EvalRoot *prev_child = first_root->prev; + DF_EvalRoot *reordered = last_root->next; + DLLRemove(ewv->first_root, ewv->last_root, reordered); + DLLInsert(ewv->first_root, ewv->last_root, prev_child, reordered); + } + } + ////////////////////////// //- rjf: consume event, if taken // @@ -1493,7 +1531,7 @@ df_watch_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_WatchViewS UI_TableCell if(df_help_label(str8_lit("View Rule"))) UI_Tooltip { F32 max_width = ui_top_font_size()*35; - ui_label_multiline(max_width, str8_lit("View rules are used to tweak the way evaluated expressions are visualized. Multiple rules can be specified on each row. They are specified in a key:(value) form.")); + ui_label_multiline(max_width, str8_lit("View rules are used to tweak the way evaluated expressions are visualized. Multiple rules can be specified on each row. They are specified in a key:(value) form. Some examples follow:")); ui_spacer(ui_em(1.5f, 1)); UI_Font(df_font_from_slot(DF_FontSlot_Code)) UI_TextColor(df_rgba_from_theme_color(DF_ThemeColor_PlainText)) ui_labelf("array:(N)"); ui_label_multiline(max_width, str8_lit("Specifies that a pointer points to N elements, rather than only 1.")); diff --git a/src/df/gfx/generated/df_gfx.meta.c b/src/df/gfx/generated/df_gfx.meta.c index 1edde9d8..ca6f9d3d 100644 --- a/src/df/gfx/generated/df_gfx.meta.c +++ b/src/df/gfx/generated/df_gfx.meta.c @@ -598,7 +598,7 @@ str8_lit_comp("goto_name"), str8_lit_comp("function_breakpoint"), }; -DF_StringBindingPair df_g_default_binding_table[102] = +DF_StringBindingPair df_g_default_binding_table[104] = { {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}}, @@ -671,6 +671,8 @@ DF_StringBindingPair df_g_default_binding_table[102] = {str8_lit_comp("move_down_page_select"), {OS_Key_PageDown, 0 |OS_EventFlag_Shift }}, {str8_lit_comp("move_up_whole_select"), {OS_Key_Home, 0 |OS_EventFlag_Ctrl |OS_EventFlag_Shift }}, {str8_lit_comp("move_down_whole_select"), {OS_Key_End, 0 |OS_EventFlag_Ctrl |OS_EventFlag_Shift }}, +{str8_lit_comp("move_up_reorder"), {OS_Key_Up, 0 |OS_EventFlag_Alt}}, +{str8_lit_comp("move_down_reorder"), {OS_Key_Down, 0 |OS_EventFlag_Alt}}, {str8_lit_comp("move_home"), {OS_Key_Home, 0 }}, {str8_lit_comp("move_end"), {OS_Key_End, 0 }}, {str8_lit_comp("move_home_select"), {OS_Key_Home, 0 |OS_EventFlag_Shift }}, diff --git a/src/df/gfx/generated/df_gfx.meta.h b/src/df/gfx/generated/df_gfx.meta.h index 118e62c1..e8921033 100644 --- a/src/df/gfx/generated/df_gfx.meta.h +++ b/src/df/gfx/generated/df_gfx.meta.h @@ -290,7 +290,7 @@ extern Vec4F32* df_g_theme_preset_colors_table[9]; extern DF_CmdParamSlot df_g_cmd_param_slot_2_view_spec_src_map[7]; extern String8 df_g_cmd_param_slot_2_view_spec_dst_map[7]; extern String8 df_g_cmd_param_slot_2_view_spec_cmd_map[7]; -extern DF_StringBindingPair df_g_default_binding_table[102]; +extern DF_StringBindingPair df_g_default_binding_table[104]; extern String8 df_g_binding_version_remap_old_name_table[3]; extern String8 df_g_binding_version_remap_new_name_table[3]; 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 ecc89863..7d62c32d 100644 --- a/src/raddbg/raddbg.h +++ b/src/raddbg/raddbg.h @@ -10,14 +10,14 @@ // ctrl+C // [x] UI_NavActions, OS_Event -> UI_Event (single event stream) // -// [ ] better discoverability for view rules - have better help hover tooltip, +// [x] better discoverability for view rules - have better help hover tooltip, // info on arguments, and better autocomplete lister // // [x] source view -> floating margin/line-nums // [ ] theme colors -> more explicit about e.g. opaque backgrounds vs. floating // & scrollbars etc. // [ ] target/breakpoint/watch-pin reordering -// [ ] watch window reordering +// [x] watch window reordering // [x] standard way to filter // [ ] visualize remapped files (via path map) // [ ] theme lister -> fonts & font sizes diff --git a/src/ui/ui_core.h b/src/ui/ui_core.h index 390315c0..6b24be53 100644 --- a/src/ui/ui_core.h +++ b/src/ui/ui_core.h @@ -97,6 +97,7 @@ enum UI_EventFlag_PickSelectSide = (1<<5), UI_EventFlag_CapAtLine = (1<<6), UI_EventFlag_ExplicitDirectional = (1<<7), + UI_EventFlag_Reorder = (1<<8), }; typedef enum UI_EventDeltaUnit