eliminate txti layer

This commit is contained in:
Ryan Fleury
2024-06-26 11:09:58 -07:00
parent 6e2353d302
commit 1229a50c68
10 changed files with 3 additions and 1422 deletions
+2 -36
View File
@@ -1398,19 +1398,6 @@ df_entity_fuzzy_item_array_from_entity_array_needle(Arena *arena, DF_EntityArray
return result;
}
//- rjf: entity -> text info
internal TXTI_Handle
df_txti_handle_from_entity(DF_Entity *entity)
{
TXTI_Handle handle = {0};
Temp scratch = scratch_begin(0, 0);
String8 path = df_full_path_from_entity(scratch.arena, entity);
handle = txti_handle_from_path(path);
scratch_end(scratch);
return handle;
}
//- rjf: full path building, from file/folder entities
internal String8
@@ -7123,10 +7110,8 @@ df_core_begin_frame(Arena *arena, DF_CmdList *cmds, F32 dt)
DF_EntityList existing_processes = df_query_cached_entity_list_with_kind(DF_EntityKind_Process);
if(existing_processes.count == 0)
{
Temp scratch = scratch_begin(0, 0);
DF_Entity *session_log = df_log_from_entity(df_entity_root());
TXTI_Handle session_log_handle = df_txti_handle_from_entity(session_log);
txti_reload(session_log_handle, df_full_path_from_entity(scratch.arena, session_log));
MTX_Op op = {r1u64(0, 0xffffffffffffffffull), str8_lit("[new session]\n")};
mtx_push_op(df_state->output_log_key, op);
DF_EntityList bps = df_query_cached_entity_list_with_kind(DF_EntityKind_Breakpoint);
for(DF_EntityNode *n = bps.first; n != 0; n = n->next)
{
@@ -7315,25 +7300,6 @@ df_core_begin_frame(Arena *arena, DF_CmdList *cmds, F32 dt)
{
MTX_Op op = {r1u64(max_U64, max_U64), event->string};
mtx_push_op(df_state->output_log_key, op);
#if 0
String8 string = event->string;
DF_Entity *root = df_entity_root();
DF_Entity *thread = df_entity_from_ctrl_handle(event->machine_id, event->entity);
DF_Entity *process = df_entity_ancestor_from_kind(thread, DF_EntityKind_Process);
DF_Entity *machine = df_entity_ancestor_from_kind(process, DF_EntityKind_Machine);
DF_Entity *root_log = df_log_from_entity(root);
DF_Entity *thread_log = df_log_from_entity(thread);
DF_Entity *process_log = df_log_from_entity(process);
DF_Entity *machine_log = df_log_from_entity(machine);
TXTI_Handle root_log_handle = df_txti_handle_from_entity(root_log);
TXTI_Handle thread_log_handle = df_txti_handle_from_entity(thread_log);
TXTI_Handle process_log_handle = df_txti_handle_from_entity(process_log);
TXTI_Handle machine_log_handle = df_txti_handle_from_entity(machine_log);
txti_append(root_log_handle, string);
txti_append(thread_log_handle, string);
txti_append(process_log_handle, string);
txti_append(machine_log_handle, string);
#endif
}break;
case CTRL_EventKind_ThreadName:
-3
View File
@@ -1536,9 +1536,6 @@ internal DF_EntityArray df_entity_array_from_list(Arena *arena, DF_EntityList *l
internal DF_EntityFuzzyItemArray df_entity_fuzzy_item_array_from_entity_list_needle(Arena *arena, DF_EntityList *list, String8 needle);
internal DF_EntityFuzzyItemArray df_entity_fuzzy_item_array_from_entity_array_needle(Arena *arena, DF_EntityArray *array, String8 needle);
//- rjf: entity -> text info
internal TXTI_Handle df_txti_handle_from_entity(DF_Entity *entity);
//- rjf: full path building, from file/folder entities
internal String8 df_full_path_from_entity(Arena *arena, DF_Entity *entity);
-182
View File
@@ -12479,188 +12479,6 @@ df_do_txt_controls(TXT_TextInfo *info, String8 data, U64 line_count_per_page, Tx
return change;
}
internal B32
df_do_txti_controls(TXTI_Handle handle, U64 line_count_per_page, TxtPt *cursor, TxtPt *mark, S64 *preferred_column)
{
Temp scratch = scratch_begin(0, 0);
B32 change = 0;
UI_EventList *events = ui_events();
TXTI_BufferInfo buffer_info = txti_buffer_info_from_handle(scratch.arena, handle);
for(UI_EventNode *n = events->first, *next = 0; n != 0; n = next)
{
next = n->next;
B32 taken = 0;
if(n->v.kind != UI_EventKind_Navigate && n->v.kind != UI_EventKind_Edit)
{
continue;
}
String8 line = txti_string_from_handle_line_num(scratch.arena, handle, cursor->line);
UI_TxtOp single_line_op = ui_single_line_txt_op_from_event(scratch.arena, &n->v, line, *cursor, *mark);
//- rjf: invalid single-line op or endpoint units => try multiline
if(n->v.delta_unit == UI_EventDeltaUnit_Whole || single_line_op.flags & UI_TxtOpFlag_Invalid)
{
U64 line_count = buffer_info.total_line_count;
String8 prev_line = txti_string_from_handle_line_num(scratch.arena, handle, cursor->line-1);
String8 next_line = txti_string_from_handle_line_num(scratch.arena, handle, cursor->line+1);
Vec2S32 delta = n->v.delta_2s32;
//- rjf: wrap lines right
if(n->v.delta_unit != UI_EventDeltaUnit_Whole && delta.x > 0 && cursor->column == line.size+1 && cursor->line+1 <= line_count)
{
cursor->line += 1;
cursor->column = 1;
*preferred_column = 1;
change = 1;
taken = 1;
}
//- rjf: wrap lines left
if(n->v.delta_unit != UI_EventDeltaUnit_Whole && delta.x < 0 && cursor->column == 1 && cursor->line-1 >= 1)
{
cursor->line -= 1;
cursor->column = prev_line.size+1;
*preferred_column = prev_line.size+1;
change = 1;
taken = 1;
}
//- rjf: movement down (plain)
if(n->v.delta_unit == UI_EventDeltaUnit_Char && delta.y > 0 && cursor->line+1 <= line_count)
{
cursor->line += 1;
cursor->column = Min(*preferred_column, next_line.size+1);
change = 1;
taken = 1;
}
//- rjf: movement up (plain)
if(n->v.delta_unit == UI_EventDeltaUnit_Char && delta.y < 0 && cursor->line-1 >= 1)
{
cursor->line -= 1;
cursor->column = Min(*preferred_column, prev_line.size+1);
change = 1;
taken = 1;
}
//- rjf: movement down (chunk)
if(n->v.delta_unit == UI_EventDeltaUnit_Word && delta.y > 0 && cursor->line+1 <= line_count)
{
for(S64 line_num = cursor->line+1; line_num <= line_count; line_num += 1)
{
String8 line = txti_string_from_handle_line_num(scratch.arena, handle, line_num);
U64 line_size = line.size;
if(line_size == 0)
{
cursor->line = line_num;
cursor->column = 1;
break;
}
else if(line_num == line_count)
{
cursor->line = line_num;
cursor->column = line_size+1;
}
}
change = 1;
taken = 1;
}
//- rjf: movement up (chunk)
if(n->v.delta_unit == UI_EventDeltaUnit_Word && delta.y < 0 && cursor->line-1 >= 1)
{
for(S64 line_num = cursor->line-1; line_num > 0; line_num -= 1)
{
String8 line = txti_string_from_handle_line_num(scratch.arena, handle, line_num);
U64 line_size = line.size;
if(line_size == 0)
{
cursor->line = line_num;
cursor->column = 1;
break;
}
else if(line_num == 1)
{
cursor->line = line_num;
cursor->column = 1;
}
}
change = 1;
taken = 1;
}
//- rjf: movement down (page)
if(n->v.delta_unit == UI_EventDeltaUnit_Page && delta.y > 0)
{
cursor->line += line_count_per_page;
cursor->column = 1;
cursor->line = Clamp(1, cursor->line, line_count);
change = 1;
taken = 1;
}
//- rjf: movement up (page)
if(n->v.delta_unit == UI_EventDeltaUnit_Page && delta.y < 0)
{
cursor->line -= line_count_per_page;
cursor->column = 1;
cursor->line = Clamp(1, cursor->line, line_count);
change = 1;
taken = 1;
}
//- rjf: movement to endpoint (+)
if(n->v.delta_unit == UI_EventDeltaUnit_Whole && (delta.y > 0 || delta.x > 0))
{
*cursor = txt_pt(line_count, buffer_info.last_line_size);
change = 1;
taken = 1;
}
//- rjf: movement to endpoint (-)
if(n->v.delta_unit == UI_EventDeltaUnit_Whole && (delta.y < 0 || delta.x < 0))
{
*cursor = txt_pt(1, 1);
change = 1;
taken = 1;
}
//- rjf: stick mark to cursor, when we don't want to keep it in the same spot
if(!(n->v.flags & UI_EventFlag_KeepMark))
{
*mark = *cursor;
}
}
//- rjf: valid single-line op => do single-line op
else
{
*cursor = single_line_op.cursor;
*mark = single_line_op.mark;
*preferred_column = cursor->column;
change = 1;
taken = 1;
}
//- rjf: copy
if(n->v.flags & UI_EventFlag_Copy)
{
String8 text = txti_string_from_handle_txt_rng(scratch.arena, handle, txt_rng(*cursor, *mark));
os_set_clipboard_text(text);
taken = 1;
}
//- rjf: consume
if(taken)
{
ui_eat_event(events, n);
}
}
scratch_end(scratch);
return change;
}
////////////////////////////////
//~ rjf: UI Widgets: Fancy Labels
-1
View File
@@ -1084,7 +1084,6 @@ internal DF_CodeSliceSignal df_code_slice(DF_Window *ws, DF_CtrlCtx *ctrl_ctx, E
internal DF_CodeSliceSignal df_code_slicef(DF_Window *ws, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, DF_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *preferred_column, char *fmt, ...);
internal B32 df_do_txt_controls(TXT_TextInfo *info, String8 data, U64 line_count_per_page, TxtPt *cursor, TxtPt *mark, S64 *preferred_column);
internal B32 df_do_txti_controls(TXTI_Handle handle, U64 line_count_per_page, TxtPt *cursor, TxtPt *mark, S64 *preferred_column);
////////////////////////////////
//~ rjf: UI Widgets: Fancy Labels