feed autocompletion rows forward from autocompletion lister

This commit is contained in:
Ryan Fleury
2025-04-30 15:33:15 -07:00
parent 9c53215daf
commit 6ea0a237ce
2 changed files with 30 additions and 4 deletions
+28 -2
View File
@@ -4024,6 +4024,32 @@ rd_view_ui(Rng2F32 rect)
}
}
//////////////////////////////
//- rjf: autocomplete watches -> feed autocompletion info forward
//
if(rd_watch_pt_match(ewv->cursor, ewv->mark) &&
rd_cfg_child_from_string(view, str8_lit("autocomplete")) != &rd_nil_cfg)
{
U64 row_num = ev_num_from_key(&block_ranges, ewv->cursor.key);
EV_Row *row = ev_row_from_num(scratch.arena, rd_view_eval_view(), rd_view_query_input(), &block_ranges, row_num);
RD_WatchRowInfo row_info = rd_watch_row_info_from_row(scratch.arena, row);
RD_WatchCell *cell = row_info.cells.first;
if(cell != 0)
{
RD_WatchRowCellInfo cell_info = rd_info_from_watch_row_cell(scratch.arena, row, 0, &row_info, cell, ui_top_font(), ui_top_font_size(), dim_2f32(rect).y);
String8 string = dr_string_from_fstrs(ui_build_arena(), &cell_info.eval_fstrs);
if(string.size != 0)
{
UI_Event evt = zero_struct;
{
evt.kind = UI_EventKind_AutocompleteHint;
evt.string = string;
}
ui_event_list_push(ui_build_arena(), ui_state->events, &evt);
}
}
}
//////////////////////////////
//- rjf: build ui
//
@@ -4995,7 +5021,7 @@ rd_view_ui(Rng2F32 rect)
// rjf: this watch window is a lister? -> move cursor & accept
if(rd_cfg_child_from_string(view, str8_lit("lister")) != &rd_nil_cfg ||
rd_cfg_child_from_string(view, str8_lit("expr_lister")) != &rd_nil_cfg)
rd_cfg_child_from_string(view, str8_lit("autocomplete")) != &rd_nil_cfg)
{
ewv->next_cursor = ewv->next_mark = cell_pt;
rd_cmd(RD_CmdKind_Accept);
@@ -6600,7 +6626,7 @@ rd_window_frame(void)
// rjf: build view
RD_Cfg *root = rd_immediate_cfg_from_keyf("autocomp_view_%I64x", window->id);
RD_Cfg *view = rd_cfg_child_from_string_or_alloc(root, str8_lit("watch"));
rd_cfg_child_from_string_or_alloc(view, str8_lit("expr_lister"));
rd_cfg_child_from_string_or_alloc(view, str8_lit("autocomplete"));
RD_Cfg *query = rd_cfg_child_from_string_or_alloc(view, str8_lit("query"));
RD_Cfg *input = rd_cfg_child_from_string_or_alloc(query, str8_lit("input"));
rd_cfg_new_replace(input, ws->autocomp_regs->string);
+2 -2
View File
@@ -1161,9 +1161,9 @@ rd_watch_row_info_from_row(Arena *arena, EV_Row *row)
}
////////////////////////////
//- rjf: @watch_row_build_cells expr lister rows
//- rjf: @watch_row_build_cells autocomplete rows
//
else if(rd_cfg_child_from_string(rd_cfg_from_id(rd_regs()->view), str8_lit("expr_lister")) != &rd_nil_cfg)
else if(rd_cfg_child_from_string(rd_cfg_from_id(rd_regs()->view), str8_lit("autocomplete")) != &rd_nil_cfg)
{
info.can_expand = 0;
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Eval, row->eval, .flags = RD_WatchCellFlag_Expr|RD_WatchCellFlag_NoEval|RD_WatchCellFlag_Button|RD_WatchCellFlag_Indented, .pct = 1.f);