mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-06-23 04:04:59 -07:00
begin working on watch window stylization for file system evaluations
This commit is contained in:
@@ -134,8 +134,6 @@ E_ExprKindTable:
|
||||
{ Array Null 0 "array" "" "" "" }
|
||||
{ Func Null 0 "function" "" "" "" }
|
||||
|
||||
{ Line Binary 1 ":" "" ":" "" }
|
||||
|
||||
{ Define Binary 13 "=" "" "=" "" }
|
||||
|
||||
{ Tag Null 0 "=>" "=>" "," "" }
|
||||
|
||||
+15
-65
@@ -243,19 +243,25 @@ E_LOOKUP_ACCESS_FUNCTION_DEF(file)
|
||||
String8 member_name = rhs->string;
|
||||
if(str8_match(member_name, str8_lit("size"), 0))
|
||||
{
|
||||
result.irtree_and_type.root = e_irtree_const_u(arena, accel->props.size);
|
||||
E_Space space = e_space_make(E_SpaceKind_FileSystem);
|
||||
space.u64_0 = e_id_from_string(accel->file_path);
|
||||
result.irtree_and_type.root = e_irtree_set_space(arena, space, e_irtree_const_u(arena, accel->props.size));
|
||||
result.irtree_and_type.type_key = e_type_key_basic(E_TypeKind_U64);
|
||||
result.irtree_and_type.mode = E_Mode_Value;
|
||||
}
|
||||
else if(str8_match(member_name, str8_lit("last_modified_time"), 0))
|
||||
{
|
||||
result.irtree_and_type.root = e_irtree_const_u(arena, accel->props.modified);
|
||||
E_Space space = e_space_make(E_SpaceKind_FileSystem);
|
||||
space.u64_0 = e_id_from_string(accel->file_path);
|
||||
result.irtree_and_type.root = e_irtree_set_space(arena, space, e_irtree_const_u(arena, accel->props.modified));
|
||||
result.irtree_and_type.type_key = e_type_key_basic(E_TypeKind_U64);
|
||||
result.irtree_and_type.mode = E_Mode_Value;
|
||||
}
|
||||
else if(str8_match(member_name, str8_lit("creation_time"), 0))
|
||||
{
|
||||
result.irtree_and_type.root = e_irtree_const_u(arena, accel->props.created);
|
||||
E_Space space = e_space_make(E_SpaceKind_FileSystem);
|
||||
space.u64_0 = e_id_from_string(accel->file_path);
|
||||
result.irtree_and_type.root = e_irtree_set_space(arena, space, e_irtree_const_u(arena, accel->props.created));
|
||||
result.irtree_and_type.type_key = e_type_key_basic(E_TypeKind_U64);
|
||||
result.irtree_and_type.mode = E_Mode_Value;
|
||||
}
|
||||
@@ -2223,32 +2229,24 @@ E_IRGEN_FUNCTION_DEF(default)
|
||||
//- rjf: leaf file paths
|
||||
case E_ExprKind_LeafFilePath:
|
||||
{
|
||||
FileProperties props = os_properties_from_file_path(expr->string);
|
||||
Temp scratch = scratch_begin(&arena, 1);
|
||||
String8 file_path = path_normalized_from_string(scratch.arena, expr->string);
|
||||
FileProperties props = os_properties_from_file_path(file_path);
|
||||
if(props.flags & FilePropertyFlag_IsFolder)
|
||||
{
|
||||
E_Space space = e_space_make(E_SpaceKind_FileSystem);
|
||||
result.root = e_irtree_set_space(arena, space, e_irtree_const_u(arena, e_id_from_string(expr->string)));
|
||||
result.root = e_irtree_set_space(arena, space, e_irtree_const_u(arena, e_id_from_string(file_path)));
|
||||
result.type_key = e_type_key_cons(.kind = E_TypeKind_Set, .name = str8_lit("folder"));
|
||||
result.mode = E_Mode_Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
E_Space space = e_space_make(E_SpaceKind_FileSystem);
|
||||
result.root = e_irtree_set_space(arena, space, e_irtree_const_u(arena, e_id_from_string(expr->string)));
|
||||
result.root = e_irtree_set_space(arena, space, e_irtree_const_u(arena, e_id_from_string(file_path)));
|
||||
result.type_key = e_type_key_cons(.kind = E_TypeKind_Set, .name = str8_lit("file"));
|
||||
result.mode = E_Mode_Value;
|
||||
#if 0
|
||||
U128 key = fs_key_from_path_range(expr->string, r1u64(0, max_U64));
|
||||
E_Space space = {E_SpaceKind_HashStoreKey, .u128 = key};
|
||||
U64 size = props.size;
|
||||
E_IRNode *base_offset = e_irtree_const_u(arena, 0);
|
||||
base_offset->space = space;
|
||||
result.root = base_offset;
|
||||
result.root->string = push_str8_copy(arena, expr->string);
|
||||
result.type_key = e_type_key_cons_array(e_type_key_basic(E_TypeKind_U8), size);
|
||||
result.mode = E_Mode_Offset;
|
||||
#endif
|
||||
}
|
||||
scratch_end(scratch);
|
||||
}break;
|
||||
|
||||
//- rjf: types
|
||||
@@ -2268,54 +2266,6 @@ E_IRGEN_FUNCTION_DEF(default)
|
||||
e_msgf(arena, &result.msgs, E_MsgKind_MalformedInput, expr->location, "Type expression not expected.");
|
||||
}break;
|
||||
|
||||
//- rjf: textual line slicing
|
||||
case E_ExprKind_Line:
|
||||
{
|
||||
E_Expr *lhs = expr->first;
|
||||
E_Expr *rhs = expr->last;
|
||||
E_IRTreeAndType lhs_irtree = e_irtree_and_type_from_expr(arena, lhs);
|
||||
U64 line_num = rhs->value.u64;
|
||||
B32 space_is_good = 1;
|
||||
E_Space space = {0};
|
||||
if(lhs_irtree.root->op != E_IRExtKind_SetSpace)
|
||||
{
|
||||
space_is_good = 0;
|
||||
e_msgf(arena, &result.msgs, E_MsgKind_MalformedInput, lhs->location, "Cannot take a line from a non-file.");
|
||||
}
|
||||
else
|
||||
{
|
||||
MemoryCopy(&space, &lhs_irtree.root->value, sizeof(space));
|
||||
}
|
||||
B32 line_num_is_good = 1;
|
||||
if(rhs->kind != E_ExprKind_LeafU64)
|
||||
{
|
||||
line_num_is_good = 0;
|
||||
e_msgf(arena, &result.msgs, E_MsgKind_MalformedInput, rhs->location, "Line number must be specified as a constant number.");
|
||||
}
|
||||
if(space_is_good && line_num_is_good)
|
||||
{
|
||||
TXT_Scope *txt_scope = txt_scope_open();
|
||||
U128 key = space.u128;
|
||||
U128 hash = {0};
|
||||
TXT_TextInfo text_info = txt_text_info_from_key_lang(txt_scope, key, TXT_LangKind_Null, &hash);
|
||||
if(1 <= line_num && line_num <= text_info.lines_count)
|
||||
{
|
||||
Rng1U64 line_range = text_info.lines_ranges[line_num-1];
|
||||
U64 line_size = dim_1u64(line_range);
|
||||
E_IRNode *line_offset = e_irtree_const_u(arena, line_range.min);
|
||||
result.root = line_offset;
|
||||
result.root->space = space;
|
||||
result.type_key = e_type_key_cons_array(e_type_key_basic(E_TypeKind_U8), line_size);
|
||||
result.mode = E_Mode_Offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
e_msgf(arena, &result.msgs, E_MsgKind_MalformedInput, rhs->location, "Line %I64u is out of bounds.", line_num);
|
||||
}
|
||||
txt_scope_close(txt_scope);
|
||||
}
|
||||
}break;
|
||||
|
||||
//- rjf: definitions
|
||||
case E_ExprKind_Define:
|
||||
{
|
||||
|
||||
@@ -14,7 +14,7 @@ str8_lit_comp("CharLiteral"),
|
||||
str8_lit_comp("Symbol"),
|
||||
};
|
||||
|
||||
String8 e_expr_kind_strings[51] =
|
||||
String8 e_expr_kind_strings[50] =
|
||||
{
|
||||
str8_lit_comp("Nil"),
|
||||
str8_lit_comp("Ref"),
|
||||
@@ -64,7 +64,6 @@ str8_lit_comp("TypeIdent"),
|
||||
str8_lit_comp("Ptr"),
|
||||
str8_lit_comp("Array"),
|
||||
str8_lit_comp("Func"),
|
||||
str8_lit_comp("Line"),
|
||||
str8_lit_comp("Define"),
|
||||
str8_lit_comp("Tag"),
|
||||
};
|
||||
@@ -84,7 +83,7 @@ str8_lit_comp("Insufficient evaluation machine stack space."),
|
||||
str8_lit_comp("Malformed bytecode."),
|
||||
};
|
||||
|
||||
E_OpInfo e_expr_kind_op_info_table[51] =
|
||||
E_OpInfo e_expr_kind_op_info_table[50] =
|
||||
{
|
||||
{ E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("") },
|
||||
{ E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("") },
|
||||
@@ -134,7 +133,6 @@ E_OpInfo e_expr_kind_op_info_table[51] =
|
||||
{ E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("") },
|
||||
{ E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("") },
|
||||
{ E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("") },
|
||||
{ E_OpKind_Binary, 1, str8_lit_comp(""), str8_lit_comp(":"), str8_lit_comp("") },
|
||||
{ E_OpKind_Binary, 13, str8_lit_comp(""), str8_lit_comp("="), str8_lit_comp("") },
|
||||
{ E_OpKind_Null, 0, str8_lit_comp("=>"), str8_lit_comp(","), str8_lit_comp("") },
|
||||
};
|
||||
|
||||
@@ -139,7 +139,6 @@ E_ExprKind_TypeIdent,
|
||||
E_ExprKind_Ptr,
|
||||
E_ExprKind_Array,
|
||||
E_ExprKind_Func,
|
||||
E_ExprKind_Line,
|
||||
E_ExprKind_Define,
|
||||
E_ExprKind_Tag,
|
||||
E_ExprKind_COUNT,
|
||||
@@ -163,9 +162,9 @@ E_InterpretationCode_COUNT,
|
||||
|
||||
C_LINKAGE_BEGIN
|
||||
extern String8 e_token_kind_strings[6];
|
||||
extern String8 e_expr_kind_strings[51];
|
||||
extern String8 e_expr_kind_strings[50];
|
||||
extern String8 e_interpretation_code_display_strings[11];
|
||||
extern E_OpInfo e_expr_kind_op_info_table[51];
|
||||
extern E_OpInfo e_expr_kind_op_info_table[50];
|
||||
extern U8 e_kind_basic_byte_size_table[56];
|
||||
extern String8 e_kind_basic_string_table[56];
|
||||
|
||||
|
||||
@@ -288,7 +288,7 @@ ASYNC_WORK_DEF(fs_stream_work)
|
||||
ProfBegin("load \"%.*s\"", str8_varg(path));
|
||||
FileProperties pre_props = os_properties_from_file_path(path);
|
||||
U64 range_size = dim_1u64(range);
|
||||
U64 read_size = Min(pre_props.size, range_size);
|
||||
U64 read_size = Min(pre_props.size - range.min, range_size);
|
||||
OS_Handle file = os_file_open(OS_AccessFlag_Read|OS_AccessFlag_ShareRead|OS_AccessFlag_ShareWrite, path);
|
||||
B32 file_handle_is_valid = !os_handle_match(os_handle_zero(), file);
|
||||
U64 data_arena_size = read_size+ARENA_HEADER_SIZE;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
//- GENERATED CODE
|
||||
|
||||
C_LINKAGE_BEGIN
|
||||
RD_VocabInfo rd_vocab_info_table[285] =
|
||||
RD_VocabInfo rd_vocab_info_table[288] =
|
||||
{
|
||||
{str8_lit_comp("auto_view_rule"), str8_lit_comp("auto_view_rules"), str8_lit_comp("Auto View Rule"), str8_lit_comp("Auto View Rules"), RD_IconKind_Binoculars},
|
||||
{str8_lit_comp("file_path_map"), str8_lit_comp("file_path_maps"), str8_lit_comp("File Path Map"), str8_lit_comp("File Path Maps"), RD_IconKind_FileOutline},
|
||||
@@ -79,6 +79,9 @@ RD_VocabInfo rd_vocab_info_table[285] =
|
||||
{str8_lit_comp("environment"), str8_lit_comp("environments"), str8_lit_comp("Environment"), str8_lit_comp("Environments"), RD_IconKind_Null},
|
||||
{str8_lit_comp("frozen"), str8_lit_comp(""), str8_lit_comp("Frozen"), str8_lit_comp(""), RD_IconKind_Null},
|
||||
{str8_lit_comp("id"), str8_lit_comp("ids"), str8_lit_comp("ID"), str8_lit_comp("IDs"), RD_IconKind_Null},
|
||||
{str8_lit_comp("last_modified_time"), str8_lit_comp("last_modified_times"), str8_lit_comp("Last Modified Time"), str8_lit_comp("Last Modified Times"), RD_IconKind_Null},
|
||||
{str8_lit_comp("creation_time"), str8_lit_comp("creation_times"), str8_lit_comp("Creation Time"), str8_lit_comp("Creation Times"), RD_IconKind_Null},
|
||||
{str8_lit_comp("data"), str8_lit_comp("datas"), str8_lit_comp("Data"), str8_lit_comp("Datas"), RD_IconKind_Null},
|
||||
{str8_lit_comp("launch_and_run"), str8_lit_comp(""), str8_lit_comp("Launch and Run"), str8_lit_comp(""), RD_IconKind_Play},
|
||||
{str8_lit_comp("launch_and_init"), str8_lit_comp(""), str8_lit_comp("Launch and Initialize"), str8_lit_comp(""), RD_IconKind_PlayStepForward},
|
||||
{str8_lit_comp("kill"), str8_lit_comp(""), str8_lit_comp("Kill"), str8_lit_comp(""), RD_IconKind_X},
|
||||
|
||||
@@ -555,7 +555,7 @@ RD_Query query;
|
||||
.os_event = rd_regs()->os_event,\
|
||||
|
||||
C_LINKAGE_BEGIN
|
||||
extern RD_VocabInfo rd_vocab_info_table[285];
|
||||
extern RD_VocabInfo rd_vocab_info_table[288];
|
||||
extern RD_NameSchemaInfo rd_name_schema_info_table[10];
|
||||
extern Rng1U64 rd_reg_slot_range_table[38];
|
||||
extern String8 rd_binding_version_remap_old_name_table[8];
|
||||
|
||||
@@ -91,6 +91,9 @@ RD_VocabTable:
|
||||
{environment _ "Environment" _ Null }
|
||||
{frozen "" "Frozen" "" Null }
|
||||
{id _ "ID" _ Null }
|
||||
{last_modified_time _ "Last Modified Time" _ Null }
|
||||
{creation_time _ "Creation Time" _ Null }
|
||||
{data _ "Data" _ Null }
|
||||
}
|
||||
|
||||
@struct RD_VocabInfo:
|
||||
|
||||
@@ -3032,19 +3032,31 @@ rd_eval_space_read(void *u, E_Space space, void *out, Rng1U64 range)
|
||||
//- rjf: file reads
|
||||
case E_SpaceKind_File:
|
||||
{
|
||||
// rjf: unpack space/path
|
||||
U64 file_path_string_id = space.u64_0;
|
||||
String8 file_path = e_string_from_id(file_path_string_id);
|
||||
U128 key = fs_key_from_path_range(file_path, range);
|
||||
|
||||
// rjf: find containing chunk range
|
||||
U64 chunk_size = KB(4);
|
||||
Rng1U64 containing_range = range;
|
||||
containing_range.min -= containing_range.min%chunk_size;
|
||||
containing_range.max += chunk_size-1;
|
||||
containing_range.max -= containing_range.max%chunk_size;
|
||||
|
||||
// rjf: map to hash
|
||||
U128 key = fs_key_from_path_range(file_path, containing_range);
|
||||
U128 hash = hs_hash_from_key(key, 0);
|
||||
|
||||
// rjf: look up from hash store
|
||||
HS_Scope *scope = hs_scope_open();
|
||||
{
|
||||
String8 data = hs_data_from_hash(scope, hash);
|
||||
Rng1U64 legal_range = r1u64(0, data.size);
|
||||
Rng1U64 legal_range = r1u64(containing_range.min, containing_range.min + data.size);
|
||||
Rng1U64 read_range = intersect_1u64(range, legal_range);
|
||||
if(read_range.min < read_range.max)
|
||||
{
|
||||
result = 1;
|
||||
MemoryCopy(out, data.str + read_range.min, dim_1u64(read_range));
|
||||
MemoryCopy(out, data.str + read_range.min - containing_range.min, dim_1u64(read_range));
|
||||
}
|
||||
}
|
||||
hs_scope_close(scope);
|
||||
@@ -8636,7 +8648,7 @@ rd_window_frame(void)
|
||||
{
|
||||
// rjf: brighten
|
||||
{
|
||||
R_Rect2DInst *inst = dr_rect(box->rect, v4f32(0, 0, 0, 0), 0, 0, 1.f);
|
||||
R_Rect2DInst *inst = dr_rect(pad_2f32(box->rect, 1.f), v4f32(0, 0, 0, 0), 0, 0, 1.f);
|
||||
Vec4F32 color = rd_rgba_from_theme_color(RD_ThemeColor_Hover);
|
||||
color.w *= t*0.2f;
|
||||
inst->colors[Corner_00] = color;
|
||||
|
||||
@@ -1101,6 +1101,42 @@ rd_watch_row_info_from_row(Arena *arena, EV_Row *row)
|
||||
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Expr, .flags = RD_WatchCellFlag_Button|RD_WatchCellFlag_ActivateWithSingleClick, .pct = 1.f, .fstrs = rd_title_fstrs_from_code_name(arena, cmd_kind_info->string, ui_top_palette()->text_weak, ui_top_font_size()));
|
||||
}
|
||||
|
||||
// rjf: singular button for folders & files
|
||||
else if(info.eval.space.kind == E_SpaceKind_FileSystem)
|
||||
{
|
||||
DR_FStrParams params = {rd_font_from_slot(RD_FontSlot_Main), rd_raster_flags_from_slot(RD_FontSlot_Main), ui_top_palette()->text, ui_top_font_size()};
|
||||
E_Type *type = e_type_from_key__cached(info.eval.type_key);
|
||||
String8 file_path = e_string_from_id(info.eval.value.u64);
|
||||
String8 file_name = str8_skip_last_slash(file_path);
|
||||
if(str8_match(type->name, str8_lit("folder"), 0))
|
||||
{
|
||||
DR_FStrList fstrs = {0};
|
||||
dr_fstrs_push_new(arena, &fstrs, ¶ms, file_name);
|
||||
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Expr,
|
||||
.flags = RD_WatchCellFlag_Button|RD_WatchCellFlag_IsNonCode,
|
||||
.pct = 1.f,
|
||||
.fstrs = fstrs);
|
||||
}
|
||||
else
|
||||
{
|
||||
info.cell_style_key = str8_lit("expr_and_eval");
|
||||
RD_Cfg *view = rd_cfg_from_id(rd_regs()->view);
|
||||
RD_Cfg *style = rd_cfg_child_from_string(view, info.cell_style_key);
|
||||
RD_Cfg *w_cfg = style->first;
|
||||
F32 next_pct = 0;
|
||||
#define take_pct() (next_pct = (F32)f64_from_str8(w_cfg->string), w_cfg = w_cfg->next, next_pct)
|
||||
DR_FStrList fstrs = {0};
|
||||
dr_fstrs_push_new(arena, &fstrs, ¶ms, file_name);
|
||||
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Expr,
|
||||
.flags = RD_WatchCellFlag_Button|RD_WatchCellFlag_IsNonCode,
|
||||
.default_pct = 0.35f,
|
||||
.pct = take_pct(),
|
||||
.fstrs = fstrs);
|
||||
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Eval, .default_pct = 0.65f, .pct = take_pct());
|
||||
#undef take_pct
|
||||
}
|
||||
}
|
||||
|
||||
// rjf: singular cell for view ui
|
||||
else if(info.view_ui_rule != &rd_nil_view_ui_rule)
|
||||
{
|
||||
@@ -1243,7 +1279,9 @@ rd_info_from_watch_row_cell(Arena *arena, EV_Row *row, EV_StringFlags string_fla
|
||||
B32 is_non_code = 0;
|
||||
String8 string = push_str8f(arena, ".%S", member_name);
|
||||
if(row_eval.space.kind == RD_EvalSpaceKind_MetaCfg ||
|
||||
row_eval.space.kind == RD_EvalSpaceKind_MetaCtrlEntity)
|
||||
row_eval.space.kind == RD_EvalSpaceKind_MetaCtrlEntity ||
|
||||
row_eval.space.kind == E_SpaceKind_File ||
|
||||
row_eval.space.kind == E_SpaceKind_FileSystem)
|
||||
{
|
||||
String8 fancy_name = rd_display_from_code_name(member_name);
|
||||
if(fancy_name.size != 0)
|
||||
|
||||
Reference in New Issue
Block a user