be more judicious about edit buttons in fancy rows; allow escape-hatch identifier evaluation via grave accents

This commit is contained in:
Ryan Fleury
2025-05-06 15:42:36 -07:00
parent 53fea4a17e
commit 8d8e9b3cc5
4 changed files with 39 additions and 13 deletions
+6 -1
View File
@@ -1031,8 +1031,13 @@ e_push_parse_from_string_tokens__prec(Arena *arena, String8 text, E_TokenArray t
String8 token_string = str8_substr(text, token.range);
if(token.kind == E_TokenKind_Identifier)
{
String8 identifier_string = token_string;
if(identifier_string.size >= 2 && identifier_string.str[0] == '`' && identifier_string.str[identifier_string.size-1] == '`')
{
identifier_string = str8_skip(str8_chop(identifier_string, 1), 1);
}
atom = e_push_expr(arena, E_ExprKind_LeafIdentifier, token.range);
atom->string = token_string;
atom->string = identifier_string;
it += 1;
got_new_atom = 1;
}
+22 -4
View File
@@ -4860,6 +4860,12 @@ rd_view_ui(Rng2F32 rect)
MemoryZeroStruct(&cell_params.description);
}
// rjf: extra edit button for meta-cfg strings
if(cell->eval.space.kind == RD_EvalSpaceKind_MetaCfg)
{
cell_params.flags |= RD_CellFlag_EmptyEditButton;
}
// rjf: apply expander (or substitute space)
if(!ewv->text_editing || !cell_selected)
{
@@ -5071,13 +5077,19 @@ rd_view_ui(Rng2F32 rect)
rd_cfg_child_from_string(view, str8_lit("autocomplete")) != &rd_nil_cfg)
{
ewv->next_cursor = ewv->next_mark = cell_pt;
// TODO(rjf): @hack - we really want navigations to be event-like, but we need
// to insert a dumb no-op here so that the "rugpull" cursor move can take effect
// before the edit command we are queueing up...
rd_cmd(RD_CmdKind_Edit);
if(cell_info.flags & RD_WatchCellFlag_CanEdit)
{
// TODO(rjf): @hack - we really want navigations to be event-like, but we need
// to insert a dumb no-op here so that the "rugpull" cursor move can take effect
// before the edit command we are queueing up...
rd_cmd(RD_CmdKind_Edit);
rd_cmd(RD_CmdKind_Edit);
}
else
{
rd_cmd(RD_CmdKind_Edit);
ewv->next_cursor = ewv->next_mark = cell_pt;
rd_cmd(RD_CmdKind_Accept);
}
}
@@ -14055,6 +14067,12 @@ rd_frame(void)
{
B32 name_resolved = 0;
// rjf: strip `s
if(name.size >= 2 && name.str[0] == '`' && name.str[name.size-1] == '`')
{
name = str8_skip(str8_chop(name, 1), 1);
}
// rjf: try to resolve name as a symbol
U64 voff = 0;
DI_Key voff_dbgi_key = {0};
+1 -1
View File
@@ -3413,7 +3413,7 @@ rd_cell(RD_CellParams *params, String8 string)
//- rjf: build edit-button, if line edit is embedded, and has no string
//
B32 edit_started = 0;
if(!is_focus_active && !is_focus_active_disabled && build_lhs_name_desc && build_line_edit && value_name_fstrs.total_size == 0)
if(params->flags & RD_CellFlag_EmptyEditButton && !is_focus_active && !is_focus_active_disabled && build_lhs_name_desc && build_line_edit && value_name_fstrs.total_size == 0)
{
UI_TagF(".")
UI_TagF("weak")
+10 -7
View File
@@ -24,18 +24,21 @@ enum
//- rjf: bindings extension
RD_CellFlag_Bindings = (1<<5),
//- rjf: extra button extensions
RD_CellFlag_EmptyEditButton = (1<<6),
//- rjf: behavior
RD_CellFlag_DisableEdit = (1<<6),
RD_CellFlag_KeyboardClickable = (1<<7),
RD_CellFlag_SingleClickActivate = (1<<8),
RD_CellFlag_DisableEdit = (1<<7),
RD_CellFlag_KeyboardClickable = (1<<8),
RD_CellFlag_SingleClickActivate = (1<<9),
//- rjf: contents description
RD_CellFlag_CodeContents = (1<<9),
RD_CellFlag_CodeContents = (1<<10),
//- rjf: appearance
RD_CellFlag_Border = (1<<10),
RD_CellFlag_NoBackground = (1<<11),
RD_CellFlag_Button = (1<<12),
RD_CellFlag_Border = (1<<11),
RD_CellFlag_NoBackground = (1<<12),
RD_CellFlag_Button = (1<<13),
};
typedef struct RD_CellParams RD_CellParams;