preserve query regs in floating views, so that we can chain info from many query commands together; more progress on theme editing, simplify command surface

This commit is contained in:
Ryan Fleury
2025-05-02 11:10:14 -07:00
parent 137855c217
commit 2b12239300
4 changed files with 41 additions and 21 deletions
File diff suppressed because one or more lines are too long
+2 -2
View File
@@ -238,8 +238,8 @@ RD_CmdKind_AddTypeView,
RD_CmdKind_AddFilePathMap,
RD_CmdKind_OpenTheme,
RD_CmdKind_AddThemeColor,
RD_CmdKind_ForkLoadedThemeColors,
RD_CmdKind_SaveThemeColors,
RD_CmdKind_ForkLoadedTheme,
RD_CmdKind_SaveTheme,
RD_CmdKind_SetNextStatement,
RD_CmdKind_AddTarget,
RD_CmdKind_SelectTarget,
+9 -9
View File
@@ -237,11 +237,11 @@ RD_VocabTable:
'code_font': string,
//- rjf: theme
@display_name('Theme Preset') @description("The selected built-in theme preset.")
@no_expand @display_name('User Theme Preset') @description("The selected built-in theme preset.")
'theme_preset': string,
@no_expand @display_name('Theme File') @description("The path from which theme data is loaded, overriding the preset.")
@no_expand @no_expand @display_name('User Theme File') @description("The path from which theme data is loaded, overriding the preset.")
'theme_file': path,
@display_name('Theme Colors') @description("Additional theme colors which are applied on top of the theme file or preset.")
@display_name('User Theme') @description("The user's theme, which describes all colors used throughout the UI.")
'theme_colors': query,
//- rjf: autocompletion
@@ -291,11 +291,11 @@ RD_VocabTable:
@default(2) @display_name('Project Tab Width') 'tab_width': @range[1, 32] u64,
//- rjf: theme
@display_name('Project Theme Preset') @description("The selected built-in project theme preset.")
@no_expand @display_name('Project Theme Preset') @description("The selected built-in project theme preset.")
'theme_preset': string,
@no_expand @display_name('Project Theme File') @description("The path from which project's theme data is loaded, overriding the preset.")
'theme_file': path,
@display_name('Project Theme Colors') @description("Additional theme colors which are applied on top of the project's theme file or preset.")
@display_name('Project Theme') @description("The project's theme, which describes all colors used throughout the UI, and can override the user's theme.")
'theme_colors': query,
//- rjf: exception settings
@@ -381,7 +381,7 @@ RD_VocabTable:
{
theme_color,
```
@collection_commands(add_theme_color, fork_loaded_theme_colors, save_theme_colors)
@collection_commands(open_theme, add_theme_color, fork_loaded_theme, save_theme)
@row_commands(remove_cfg)
x:
{
@@ -978,10 +978,10 @@ RD_CmdTable: // | | | |
{AddFilePathMap 0 0 0 0 "" Null null Nil Null 0 0 0 0 0 0 0 FileOutline "add_file_path_map" "Add File Path Map" "Adds a new file path map." "" "" }
//- rjf: themes
{OpenTheme 1 1 0 0 `folder:\\"$input\\"` FilePath null Nil Null 1 0 0 0 0 1 1 Palette "open_theme" "Open Theme" "Opens a theme file." "color" "" }
{OpenTheme 0 0 0 0 `folder:\\"$input\\"` FilePath null Nil Null 1 0 0 0 0 1 1 Palette "open_theme" "Open Theme" "Opens a theme file." "color" "" }
{AddThemeColor 0 0 0 0 "" Null null Nil Null 0 0 0 0 0 0 0 Palette "add_theme_color" "Add Theme Color" "Adds a new theme color." "" "" }
{ForkLoadedThemeColors 0 0 0 0 "" Null null Nil Null 0 0 0 0 0 0 0 Palette "fork_loaded_theme_colors" "Fork Loaded Theme Colors" "Imports all colors from a loaded color theme file or color theme preset, so they can be individually edited." "" "" }
{SaveThemeColors 0 0 0 0 `folder:\\"$input\\"` FilePath null Nil Null 1 0 0 0 0 1 1 Save "save_theme_colors" "Save Theme Colors" "Saves all theme colors to a new theme file." "" "" }
{ForkLoadedTheme 0 0 0 0 "" Null null Nil Null 0 0 0 0 0 0 0 Palette "fork_loaded_theme" "Fork Loaded Theme" "Imports all colors from the loaded color theme file or color theme preset, so they can be individually edited." "" "" }
{SaveTheme 0 0 0 0 `folder:\\"$input\\"` FilePath null Nil Null 1 0 0 0 0 1 1 Save "save_theme" "Save Theme" "Saves all theme colors to a new theme file." "" "" }
//- rjf: line operations
{SetNextStatement 1 1 1 0 "" Null null Nil Null 0 0 0 0 0 0 0 RightArrow "set_next_statement" "Set Next Statement" "Sets the selected thread's instruction pointer to the cursor's position." "" "$text_pt," }
+22 -2
View File
@@ -6612,6 +6612,7 @@ rd_window_frame(void)
{
FloatingViewTask *next;
RD_Cfg *view;
RD_Regs *regs;
Rng2F32 rect;
B32 is_focused;
B32 is_anchored;
@@ -6941,6 +6942,7 @@ rd_window_frame(void)
SLLQueuePush(first_floating_view_task, last_floating_view_task, t);
query_floating_view_task = t;
t->view = view;
t->regs = ws->query_regs;
t->rect = rect;
t->is_focused = 1;
t->is_anchored = query_is_anchored;
@@ -6970,8 +6972,13 @@ rd_window_frame(void)
F32 open_t = ui_anim(ui_key_from_stringf(ui_key_zero(), "floating_view_open_%p", view), 1.f, .rate = is_anchored ? fast_open_rate : slow_open_rate, .reset = t->reset_open, .initial = 0.f);
// rjf: push view regs
rd_push_regs(.view = view->id);
rd_push_regs();
{
if(t->regs != 0)
{
rd_regs()->cfg = t->regs->cfg;
}
rd_regs()->view = view->id;
String8 view_expr = rd_expr_from_cfg(view);
String8 view_file_path = rd_file_path_from_eval_string(rd_frame_arena(), view_expr);
// NOTE(rjf): we want to only fill out this view's file path slot if it
@@ -14709,7 +14716,7 @@ rd_frame(void)
RD_Cfg *value = rd_cfg_new(color, str8_lit("value"));
rd_cfg_new(value, str8_lit("0xffffffff"));
}break;
case RD_CmdKind_ForkLoadedThemeColors:
case RD_CmdKind_ForkLoadedTheme:
{
RD_Cfg *parent = rd_cfg_from_id(rd_regs()->cfg);
RD_CfgList colors = rd_cfg_child_list_from_string(scratch.arena, parent, str8_lit("theme_color"));
@@ -14734,6 +14741,19 @@ rd_frame(void)
}
}
}break;
case RD_CmdKind_SaveTheme:
{
String8 dst_path = rd_regs()->file_path;
RD_Cfg *parent = rd_cfg_from_id(rd_regs()->cfg);
RD_CfgList colors = rd_cfg_child_list_from_string(scratch.arena, parent, str8_lit("theme_color"));
String8List strings = {0};
for(RD_CfgNode *n = colors.first; n != 0; n = n->next)
{
str8_list_push(scratch.arena, &strings, rd_string_from_cfg_tree(scratch.arena, dst_path, n->v));
}
String8 data = str8_list_join(scratch.arena, &strings, 0);
os_write_data_to_file_path(dst_path, data);
}break;
//- rjf: watches
case RD_CmdKind_ToggleWatchExpression: