unifying use of working_set's table

This commit is contained in:
Allen Webster 2016-02-07 16:15:58 -05:00
parent 959bdcd8cf
commit 5abea3ce3c
8 changed files with 3158 additions and 3139 deletions

22
4ed.cpp
View File

@ -789,6 +789,7 @@ app_open_file_background(App_Vars *vars, Exchange *exchange, Working_Set *workin
if (file_id){ if (file_id){
result.is_new = 1; result.is_new = 1;
result.file = file.file; result.file = file.file;
file_init_strings(result.file);
file_set_name(result.file, filename.str); file_set_name(result.file, filename.str);
file_set_to_loading(result.file); file_set_to_loading(result.file);
table_add(&working_set->table, result.file->name.source_path, file.index); table_add(&working_set->table, result.file->name.source_path, file.index);
@ -923,16 +924,17 @@ COMMAND_DECL(save){
ProfileMomentFunction(); ProfileMomentFunction();
REQ_FILE_VIEW(view); REQ_FILE_VIEW(view);
REQ_FILE(file, view); REQ_FILE(file, view);
USE_VARS(vars); USE_DELAY(delay);
USE_MEM(mem); USE_PANEL(panel);
USE_EXCHANGE(exchange);
USE_WORKING_SET(working_set);
delayed_action(delay, DACT_SAVE, file->name.source_path, panel);
#if 0
String *file_path = &file->name.source_path; String *file_path = &file->name.source_path;
if (file_path->size > 0){ if (file_path->size > 0){
i32 sys_id = file_save(system, exchange, mem, file, file_path->str); i32 sys_id = file_save(system, exchange, mem, file, file_path->str);
app_push_file_binding(vars, sys_id, get_file_id(working_set, file)); app_push_file_binding(vars, sys_id, get_file_id(working_set, file));
} }
#endif
} }
COMMAND_DECL(interactive_save_as){ COMMAND_DECL(interactive_save_as){
@ -1678,6 +1680,7 @@ build(System_Functions *system, Mem_Options *mem,
Font_Set *font_set, Style *style, Font_Set *font_set, Style *style,
Live_Views *live_set, Exchange *exchange, Live_Views *live_set, Exchange *exchange,
Panel *panel, Command_Data *command, Panel *panel, Command_Data *command,
String hot_directory,
char *buffer_name, i32 buffer_name_len, char *buffer_name, i32 buffer_name_len,
char *path, i32 path_len, char *path, i32 path_len,
char *script, i32 script_len, char *script, i32 script_len,
@ -1725,7 +1728,7 @@ build(System_Functions *system, Mem_Options *mem,
if (file){ if (file){
file_create_super_locked(system, mem, file, buffer_name, font_set, style->font_id); file_create_super_locked(system, mem, file, buffer_name, font_set, style->font_id);
file->settings.unimportant = 1; file->settings.unimportant = 1;
table_add(&working_set->table, file->name.live_name, index); table_add(&working_set->table, file->name.source_path, index);
if (bind_to_new_view){ if (bind_to_new_view){
View *new_view = live_set_alloc_view(live_set, mem); View *new_view = live_set_alloc_view(live_set, mem);
@ -1735,7 +1738,6 @@ build(System_Functions *system, Mem_Options *mem,
view_set_file(system, file_view, file, font_set, style, view_set_file(system, file_view, file, font_set, style,
vars->hooks[hook_open_file], command, &app_links); vars->hooks[hook_open_file], command, &app_links);
new_view->map = app_get_map(vars, file->settings.base_map_id); new_view->map = app_get_map(vars, file->settings.base_map_id);
} }
i32 i = vars->cli_processes.count++; i32 i = vars->cli_processes.count++;
@ -1830,6 +1832,7 @@ COMMAND_DECL(build){
build(system, mem, vars, working_set, build(system, mem, vars, working_set,
font_set, style, live_set, exchange, font_set, style, live_set, exchange,
panel, command, panel, command,
vars->hot_directory.string,
buffer_name, buffer_name_len, buffer_name, buffer_name_len,
path, path_len, path, path_len,
script, script_len, script, script_len,
@ -1877,6 +1880,7 @@ COMMAND_DECL(build_here){
build(system, mem, vars, working_set, build(system, mem, vars, working_set,
font_set, style, live_set, exchange, font_set, style, live_set, exchange,
panel, command, panel, command,
vars->hot_directory.string,
buffer_name, buffer_name_len, buffer_name, buffer_name_len,
path.str, path.size, path.str, path.size,
dir.str, dir.size, dir.str, dir.size,
@ -3461,7 +3465,8 @@ App_Step_Sig(app_step){
if (fview){ if (fview){
Editing_File *file = fview->file; Editing_File *file = fview->file;
if (file && !file->state.is_dummy){ if (file && !file->state.is_dummy){
file_save_and_set_names(system, exchange, mem, file, string->str); i32 sys_id = file_save_and_set_names(system, exchange, mem, file, string->str);
app_push_file_binding(vars, sys_id, get_file_id(working_set, file));
} }
} }
}break; }break;
@ -3470,7 +3475,8 @@ App_Step_Sig(app_step){
{ {
Editing_File *file = working_set_lookup_file(working_set, *string); Editing_File *file = working_set_lookup_file(working_set, *string);
if (!file->state.is_dummy){ if (!file->state.is_dummy){
file_save(system, exchange, mem, file, file->name.source_path.str); i32 sys_id = file_save(system, exchange, mem, file, file->name.source_path.str);
app_push_file_binding(vars, sys_id, get_file_id(working_set, file));
} }
}break; }break;

File diff suppressed because it is too large Load Diff

View File

@ -1205,15 +1205,18 @@ file_init_strings(Editing_File *file){
inline void inline void
file_set_name(Editing_File *file, char *filename){ file_set_name(Editing_File *file, char *filename){
if (file->name.live_name.str == 0) file_init_strings(file); String f, ext;
if (filename[0] == '*'){
copy(&file->name.live_name, filename); Assert(file->name.live_name.str != 0);
f = make_string_slowly(filename);
copy_checked(&file->name.source_path, f);
file->name.live_name.size = 0;
get_front_of_directory(&file->name.live_name, f);
if (file->name.source_path.size == file->name.live_name.size){
file->name.extension.size = 0;
} }
else{ else{
String f, ext;
f = make_string_slowly(filename);
copy_checked(&file->name.source_path, f);
get_front_of_directory(&file->name.live_name, f);
ext = file_extension(f); ext = file_extension(f);
copy(&file->name.extension, ext); copy(&file->name.extension, ext);
} }
@ -1270,8 +1273,8 @@ inline b32
file_save_and_set_names(System_Functions *system, Exchange *exchange, file_save_and_set_names(System_Functions *system, Exchange *exchange,
Mem_Options *mem, Editing_File *file, char *filename){ Mem_Options *mem, Editing_File *file, char *filename){
b32 result = 0; b32 result = 0;
if (file_save(system, exchange, mem, file, filename)){ result = file_save(system, exchange, mem, file, filename);
result = 1; if (result){
file_set_name(file, filename); file_set_name(file, filename);
} }
return result; return result;
@ -2223,7 +2226,7 @@ view_compute_cursor_from_unwrapped_xy(File_View *view, f32 seek_x, f32 seek_y,
#endif #endif
} }
inline Full_Cursor internal Full_Cursor
view_compute_cursor_from_wrapped_xy(File_View *view, f32 seek_x, f32 seek_y, view_compute_cursor_from_wrapped_xy(File_View *view, f32 seek_x, f32 seek_y,
b32 round_down = 0){ b32 round_down = 0){
#if BUFFER_EXPERIMENT_SCALPEL <= 3 #if BUFFER_EXPERIMENT_SCALPEL <= 3
@ -2246,7 +2249,7 @@ view_compute_cursor_from_wrapped_xy(File_View *view, f32 seek_x, f32 seek_y,
#endif #endif
} }
inline Full_Cursor internal Full_Cursor
view_compute_cursor_from_line_pos(File_View *view, i32 line, i32 pos){ view_compute_cursor_from_line_pos(File_View *view, i32 line, i32 pos){
#if BUFFER_EXPERIMENT_SCALPEL <= 3 #if BUFFER_EXPERIMENT_SCALPEL <= 3
Editing_File *file = view->file; Editing_File *file = view->file;
@ -2726,20 +2729,22 @@ file_edit_cursor_fix(System_Functions *system,
Editing_File *file, Editing_Layout *layout, Editing_File *file, Editing_Layout *layout,
Cursor_Fix_Descriptor desc){ Cursor_Fix_Descriptor desc){
Full_Cursor temp_cursor; Full_Cursor temp_cursor;
File_View *current_view;
Temp_Memory cursor_temp = begin_temp_memory(part); Temp_Memory cursor_temp = begin_temp_memory(part);
i32 cursor_max = layout->panel_max_count * 2; i32 cursor_max = layout->panel_max_count * 2;
Cursor_With_Index *cursors = push_array(part, Cursor_With_Index, cursor_max); Cursor_With_Index *cursors = push_array(part, Cursor_With_Index, cursor_max);
f32 y_offset = 0, y_position = 0;
i32 cursor_count = 0; i32 cursor_count = 0;
i32 panel_count = layout->panel_count; i32 panel_count = layout->panel_count;
Panel *current_panel = layout->panels; Panel *current_panel = layout->panels;
for (i32 i = 0; i < panel_count; ++i, ++current_panel){ for (i32 i = 0; i < panel_count; ++i, ++current_panel){
File_View *current_view = view_to_file_view(current_panel->view); current_view = view_to_file_view(current_panel->view);
if (current_view && current_view->file == file){ if (current_view && current_view->file == file){
view_measure_wraps(system, general, current_view); view_measure_wraps(system, general, current_view);
write_cursor_with_index(cursors, &cursor_count, current_view->cursor.pos); write_cursor_with_index(cursors, &cursor_count, current_view->cursor.pos);
write_cursor_with_index(cursors, &cursor_count, current_view->mark); write_cursor_with_index(cursors, &cursor_count, current_view->mark);
write_cursor_with_index(cursors, &cursor_count, current_view->scroll_i); write_cursor_with_index(cursors, &cursor_count, current_view->scroll_i - 1);
} }
} }
@ -2760,21 +2765,25 @@ file_edit_cursor_fix(System_Functions *system,
cursor_count = 0; cursor_count = 0;
current_panel = layout->panels; current_panel = layout->panels;
for (i32 i = 0; i < panel_count; ++i, ++current_panel){ for (i32 i = 0; i < panel_count; ++i, ++current_panel){
File_View *current_view = view_to_file_view(current_panel->view); current_view = view_to_file_view(current_panel->view);
if (current_view && current_view->file == file){ if (current_view && current_view->file == file){
view_cursor_move(current_view, cursors[cursor_count++].pos); view_cursor_move(current_view, cursors[cursor_count++].pos);
current_view->preferred_x = view_get_cursor_x(current_view); current_view->preferred_x = view_get_cursor_x(current_view);
current_view->mark = cursors[cursor_count++].pos; current_view->mark = cursors[cursor_count++].pos;
current_view->scroll_i = cursors[cursor_count++].pos; current_view->scroll_i = cursors[cursor_count++].pos + 1;
temp_cursor = view_compute_cursor_from_pos(current_view, current_view->scroll_i); temp_cursor = view_compute_cursor_from_pos(current_view, current_view->scroll_i);
y_offset = MOD(current_view->scroll_y, current_view->font_height);
if (current_view->unwrapped_lines){ if (current_view->unwrapped_lines){
current_view->target_y += (temp_cursor.unwrapped_y - current_view->scroll_y); y_position = temp_cursor.unwrapped_y + y_offset;
current_view->scroll_y = temp_cursor.unwrapped_y; current_view->target_y += (y_position - current_view->scroll_y);
current_view->scroll_y = y_position;
} }
else{ else{
current_view->target_y += (temp_cursor.wrapped_y - current_view->scroll_y); y_position = temp_cursor.wrapped_y + y_offset;
current_view->scroll_y = temp_cursor.wrapped_y; current_view->target_y += (y_position - current_view->scroll_y);
current_view->scroll_y = y_position;
} }
} }
} }
@ -4189,19 +4198,19 @@ draw_file_bar(File_View *view, Interactive_Bar *bar, Render_Target *target){
intbar_draw_string(target, bar, line_number, base_color); intbar_draw_string(target, bar, line_number, base_color);
if (file){ if (!file->settings.unimportant){
switch (buffer_get_sync(file)){ switch (buffer_get_sync(file)){
case SYNC_BEHIND_OS: case SYNC_BEHIND_OS:
{ {
persist String out_of_sync = make_lit_string(" !"); persist String out_of_sync = make_lit_string(" !");
intbar_draw_string(target, bar, out_of_sync, pop2_color); intbar_draw_string(target, bar, out_of_sync, pop2_color);
}break; }break;
case SYNC_UNSAVED: case SYNC_UNSAVED:
{ {
persist String out_of_sync = make_lit_string(" *"); persist String out_of_sync = make_lit_string(" *");
intbar_draw_string(target, bar, out_of_sync, pop2_color); intbar_draw_string(target, bar, out_of_sync, pop2_color);
}break; }break;
} }
} }
} }

View File

@ -1,230 +1,230 @@
/* /*
* Mr. 4th Dimention - Allen Webster * Mr. 4th Dimention - Allen Webster
* *
* 19.09.2015 * 19.09.2015
* *
* File editing view for 4coder * File editing view for 4coder
* *
*/ */
// TOP // TOP
enum Interactive_View_Action{ enum Interactive_View_Action{
INTV_OPEN, INTV_OPEN,
INTV_SAVE_AS, INTV_SAVE_AS,
INTV_NEW, INTV_NEW,
INTV_SWITCH, INTV_SWITCH,
INTV_KILL, INTV_KILL,
INTV_SURE_TO_KILL INTV_SURE_TO_KILL
}; };
enum Interactive_View_Interaction{ enum Interactive_View_Interaction{
INTV_SYS_FILE_LIST, INTV_SYS_FILE_LIST,
INTV_LIVE_FILE_LIST, INTV_LIVE_FILE_LIST,
INTV_SURE_TO_KILL_INTER INTV_SURE_TO_KILL_INTER
}; };
struct Interactive_View{ struct Interactive_View{
View view_base; View view_base;
Hot_Directory *hot_directory; Hot_Directory *hot_directory;
Style *style; Style *style;
Working_Set *working_set; Working_Set *working_set;
Delay *delay; Delay *delay;
Font_Set *font_set; Font_Set *font_set;
UI_State state; UI_State state;
Interactive_View_Interaction interaction; Interactive_View_Interaction interaction;
Interactive_View_Action action; Interactive_View_Action action;
char query_[256]; char query_[256];
String query; String query;
char dest_[256]; char dest_[256];
String dest; String dest;
i32 user_action; i32 user_action;
}; };
inline Interactive_View* inline Interactive_View*
view_to_interactive_view(View *view){ view_to_interactive_view(View *view){
Interactive_View *result = 0; Interactive_View *result = 0;
if (view->type == VIEW_TYPE_INTERACTIVE) if (view->type == VIEW_TYPE_INTERACTIVE)
result = (Interactive_View*)view; result = (Interactive_View*)view;
return result; return result;
} }
internal void internal void
interactive_view_complete(Interactive_View *view){ interactive_view_complete(Interactive_View *view){
Panel *panel = view->view_base.panel; Panel *panel = view->view_base.panel;
switch (view->action){ switch (view->action){
case INTV_OPEN: case INTV_OPEN:
delayed_action(view->delay, DACT_OPEN, delayed_action(view->delay, DACT_OPEN,
view->hot_directory->string, panel); view->hot_directory->string, panel);
break; break;
case INTV_SAVE_AS: case INTV_SAVE_AS:
delayed_action(view->delay, DACT_SAVE_AS, view->hot_directory->string, panel); delayed_action(view->delay, DACT_SAVE_AS, view->hot_directory->string, panel);
delayed_action(view->delay, DACT_CLOSE_MINOR, {}, panel); delayed_action(view->delay, DACT_CLOSE_MINOR, {}, panel);
break; break;
case INTV_NEW: case INTV_NEW:
delayed_action(view->delay, DACT_NEW, view->hot_directory->string, panel); delayed_action(view->delay, DACT_NEW, view->hot_directory->string, panel);
break; break;
case INTV_SWITCH: case INTV_SWITCH:
delayed_action(view->delay, DACT_SWITCH, view->dest, panel); delayed_action(view->delay, DACT_SWITCH, view->dest, panel);
break; break;
case INTV_KILL: case INTV_KILL:
delayed_action(view->delay, DACT_TRY_KILL, view->dest, panel); delayed_action(view->delay, DACT_TRY_KILL, view->dest, panel);
break; break;
case INTV_SURE_TO_KILL: case INTV_SURE_TO_KILL:
switch (view->user_action){ switch (view->user_action){
case 0: case 0:
delayed_action(view->delay, DACT_KILL, view->dest, panel); delayed_action(view->delay, DACT_KILL, view->dest, panel);
delayed_action(view->delay, DACT_CLOSE_MINOR, {}, panel); delayed_action(view->delay, DACT_CLOSE_MINOR, {}, panel);
break; break;
case 1: case 1:
delayed_action(view->delay, DACT_CLOSE_MINOR, {}, panel); delayed_action(view->delay, DACT_CLOSE_MINOR, {}, panel);
break; break;
case 2: case 2:
delayed_action(view->delay, DACT_SAVE, view->dest, panel); delayed_action(view->delay, DACT_SAVE, view->dest, panel);
delayed_action(view->delay, DACT_KILL, view->dest, panel); delayed_action(view->delay, DACT_KILL, view->dest, panel);
delayed_action(view->delay, DACT_CLOSE_MINOR, {}, panel); delayed_action(view->delay, DACT_CLOSE_MINOR, {}, panel);
break; break;
} }
break; break;
} }
} }
internal i32 internal i32
step_draw_int_view(System_Functions *system, Interactive_View *view, step_draw_int_view(System_Functions *system, Interactive_View *view,
Render_Target *target, i32_Rect rect, Render_Target *target, i32_Rect rect,
Input_Summary *user_input, b32 input_stage){ Input_Summary *user_input, b32 input_stage){
i32 result = 0; i32 result = 0;
UI_State state = UI_State state =
ui_state_init(&view->state, target, user_input, ui_state_init(&view->state, target, user_input,
view->style, view->font_set, view->working_set, input_stage); view->style, view->font_set, view->working_set, input_stage);
UI_Layout layout; UI_Layout layout;
begin_layout(&layout, rect); begin_layout(&layout, rect);
b32 new_dir = 0; b32 new_dir = 0;
b32 complete = 0; b32 complete = 0;
do_label(&state, &layout, view->query, 1.f); do_label(&state, &layout, view->query, 1.f);
b32 case_sensitive = 0; b32 case_sensitive = 0;
switch (view->interaction){ switch (view->interaction){
case INTV_SYS_FILE_LIST: case INTV_SYS_FILE_LIST:
{ {
b32 is_new = (view->action == INTV_NEW); b32 is_new = (view->action == INTV_NEW);
if (do_file_list_box(system, &state, if (do_file_list_box(system, &state,
&layout, view->hot_directory, 0, !is_new, case_sensitive, &layout, view->hot_directory, 0, !is_new, case_sensitive,
&new_dir, &complete, 0)){ &new_dir, &complete, 0)){
result = 1; result = 1;
} }
if (new_dir){ if (new_dir){
hot_directory_reload(system, hot_directory_reload(system,
view->hot_directory, view->working_set); view->hot_directory, view->working_set);
} }
}break; }break;
case INTV_LIVE_FILE_LIST: case INTV_LIVE_FILE_LIST:
if (do_live_file_list_box(system, &state, &layout, view->working_set, &view->dest, &complete)){ if (do_live_file_list_box(system, &state, &layout, view->working_set, &view->dest, &complete)){
result = 1; result = 1;
} }
break; break;
case INTV_SURE_TO_KILL_INTER: case INTV_SURE_TO_KILL_INTER:
{ {
i32 action = -1; i32 action = -1;
char s_[256]; char s_[256];
String s = make_fixed_width_string(s_); String s = make_fixed_width_string(s_);
append(&s, view->dest); append(&s, view->dest);
append(&s, " has unsaved changes, kill it?"); append(&s, " has unsaved changes, kill it?");
do_label(&state, &layout, s, 1.f); do_label(&state, &layout, s, 1.f);
i32 id = 0; i32 id = 0;
if (do_list_option(++id, &state, &layout, make_lit_string("(Y)es"))){ if (do_list_option(++id, &state, &layout, make_lit_string("(Y)es"))){
action = 0; action = 0;
} }
if (do_list_option(++id, &state, &layout, make_lit_string("(N)o"))){ if (do_list_option(++id, &state, &layout, make_lit_string("(N)o"))){
action = 1; action = 1;
} }
if (do_list_option(++id, &state, &layout, make_lit_string("(S)ave and kill"))){ if (do_list_option(++id, &state, &layout, make_lit_string("(S)ave and kill"))){
action = 2; action = 2;
} }
if (action == -1 && input_stage){ if (action == -1 && input_stage){
i32 key_count = user_input->keys.count; i32 key_count = user_input->keys.count;
for (i32 i = 0; i < key_count; ++i){ for (i32 i = 0; i < key_count; ++i){
Key_Event_Data key = user_input->keys.keys[i]; Key_Event_Data key = user_input->keys.keys[i];
switch (key.character){ switch (key.character){
case 'y': case 'Y': action = 0; break; case 'y': case 'Y': action = 0; break;
case 'n': case 'N': action = 1; break; case 'n': case 'N': action = 1; break;
case 's': case 'S': action = 2; break; case 's': case 'S': action = 2; break;
} }
if (action == -1 && key.keycode == state.codes->esc) action = 1; if (action == -1 && key.keycode == state.codes->esc) action = 1;
if (action != -1) break; if (action != -1) break;
} }
} }
if (action != -1){ if (action != -1){
complete = 1; complete = 1;
view->user_action = action; view->user_action = action;
} }
}break; }break;
} }
if (complete){ if (complete){
interactive_view_complete(view); interactive_view_complete(view);
} }
if (ui_finish_frame(&view->state, &state, &layout, rect, 0, 0)){ if (ui_finish_frame(&view->state, &state, &layout, rect, 0, 0)){
result = 1; result = 1;
} }
return result; return result;
} }
Do_View_Sig(do_interactive_view){ Do_View_Sig(do_interactive_view){
i32 result = 0; i32 result = 0;
view->mouse_cursor_type = APP_MOUSE_CURSOR_ARROW; view->mouse_cursor_type = APP_MOUSE_CURSOR_ARROW;
Interactive_View *int_view = (Interactive_View*)view; Interactive_View *int_view = (Interactive_View*)view;
switch (message){ switch (message){
case VMSG_STEP: case VMSG_DRAW: case VMSG_STEP: case VMSG_DRAW:
result = step_draw_int_view(system, int_view, target, rect, user_input, (message == VMSG_STEP)); result = step_draw_int_view(system, int_view, target, rect, user_input, (message == VMSG_STEP));
break; break;
} }
return result; return result;
} }
internal Interactive_View* internal Interactive_View*
interactive_view_init(System_Functions *system, View *view, interactive_view_init(System_Functions *system, View *view,
Hot_Directory *hot_dir, Style *style, Hot_Directory *hot_dir, Style *style,
Working_Set *working_set, Font_Set *font_set, Delay *delay){ Working_Set *working_set, Font_Set *font_set, Delay *delay){
Interactive_View *result = (Interactive_View*)view; Interactive_View *result = (Interactive_View*)view;
view->type = VIEW_TYPE_INTERACTIVE; view->type = VIEW_TYPE_INTERACTIVE;
view->do_view = do_interactive_view; view->do_view = do_interactive_view;
result->hot_directory = hot_dir; result->hot_directory = hot_dir;
hot_directory_clean_end(hot_dir); hot_directory_clean_end(hot_dir);
hot_directory_reload(system, hot_dir, working_set); hot_directory_reload(system, hot_dir, working_set);
result->query = make_fixed_width_string(result->query_); result->query = make_fixed_width_string(result->query_);
result->dest = make_fixed_width_string(result->dest_); result->dest = make_fixed_width_string(result->dest_);
result->style = style; result->style = style;
result->working_set = working_set; result->working_set = working_set;
result->font_set = font_set; result->font_set = font_set;
result->delay = delay; result->delay = delay;
return result; return result;
} }
// BOTTOM // BOTTOM

File diff suppressed because it is too large Load Diff

View File

@ -1,191 +1,191 @@
/* /*
* Mr. 4th Dimention - Allen Webster * Mr. 4th Dimention - Allen Webster
* *
* 21.01.2014 * 21.01.2014
* *
* System functions for project codename "4ed" * System functions for project codename "4ed"
* *
*/ */
// TOP // TOP
struct Plat_Handle{ struct Plat_Handle{
u32 d[4]; u32 d[4];
}; };
struct File_Info{ struct File_Info{
String filename; String filename;
b32 folder; b32 folder;
}; };
struct File_List{ struct File_List{
void *block; void *block;
File_Info *infos; File_Info *infos;
i32 count, block_size; i32 count, block_size;
}; };
#define Sys_File_Time_Stamp_Sig(name) u64 name(char *filename) #define Sys_File_Time_Stamp_Sig(name) u64 name(char *filename)
typedef Sys_File_Time_Stamp_Sig(System_File_Time_Stamp); typedef Sys_File_Time_Stamp_Sig(System_File_Time_Stamp);
// TODO(allen): make directory a char* to signal that it must be null terminated // TODO(allen): make directory a char* to signal that it must be null terminated
#define Sys_Set_File_List_Sig(name) void name(File_List *file_list, String directory) #define Sys_Set_File_List_Sig(name) void name(File_List *file_list, String directory)
typedef Sys_Set_File_List_Sig(System_Set_File_List); typedef Sys_Set_File_List_Sig(System_Set_File_List);
#define Sys_Post_Clipboard_Sig(name) void name(String str) #define Sys_Post_Clipboard_Sig(name) void name(String str)
typedef Sys_Post_Clipboard_Sig(System_Post_Clipboard); typedef Sys_Post_Clipboard_Sig(System_Post_Clipboard);
#define Sys_Time_Sig(name) u64 name() #define Sys_Time_Sig(name) u64 name()
typedef Sys_Time_Sig(System_Time); typedef Sys_Time_Sig(System_Time);
// cli // cli
struct CLI_Handles{ struct CLI_Handles{
Plat_Handle proc; Plat_Handle proc;
Plat_Handle out_read; Plat_Handle out_read;
Plat_Handle out_write; Plat_Handle out_write;
u32 scratch_space[4]; u32 scratch_space[4];
i32 exit; i32 exit;
}; };
#define Sys_CLI_Call_Sig(name) b32 name(char *path, char *script_name, CLI_Handles *cli_out) #define Sys_CLI_Call_Sig(name) b32 name(char *path, char *script_name, CLI_Handles *cli_out)
typedef Sys_CLI_Call_Sig(System_CLI_Call); typedef Sys_CLI_Call_Sig(System_CLI_Call);
#define Sys_CLI_Begin_Update_Sig(name) void name(CLI_Handles *cli) #define Sys_CLI_Begin_Update_Sig(name) void name(CLI_Handles *cli)
typedef Sys_CLI_Begin_Update_Sig(System_CLI_Begin_Update); typedef Sys_CLI_Begin_Update_Sig(System_CLI_Begin_Update);
#define Sys_CLI_Update_Step_Sig(name) b32 name(CLI_Handles *cli, char *dest, u32 max, u32 *amount) #define Sys_CLI_Update_Step_Sig(name) b32 name(CLI_Handles *cli, char *dest, u32 max, u32 *amount)
typedef Sys_CLI_Update_Step_Sig(System_CLI_Update_Step); typedef Sys_CLI_Update_Step_Sig(System_CLI_Update_Step);
#define Sys_CLI_End_Update_Sig(name) b32 name(CLI_Handles *cli) #define Sys_CLI_End_Update_Sig(name) b32 name(CLI_Handles *cli)
typedef Sys_CLI_End_Update_Sig(System_CLI_End_Update); typedef Sys_CLI_End_Update_Sig(System_CLI_End_Update);
// thread // thread
struct Thread_Context; struct Thread_Context;
enum Lock_ID{ enum Lock_ID{
FRAME_LOCK, FRAME_LOCK,
INPUT_LOCK, INPUT_LOCK,
FONT_LOCK, FONT_LOCK,
RENDER_LOCK, RENDER_LOCK,
CANCEL_LOCK0, CANCEL_LOCK0,
CANCEL_LOCK1, CANCEL_LOCK1,
CANCEL_LOCK2, CANCEL_LOCK2,
CANCEL_LOCK3, CANCEL_LOCK3,
CANCEL_LOCK4, CANCEL_LOCK4,
CANCEL_LOCK5, CANCEL_LOCK5,
CANCEL_LOCK6, CANCEL_LOCK6,
CANCEL_LOCK7, CANCEL_LOCK7,
LOCK_COUNT LOCK_COUNT
}; };
enum Thread_Group_ID{ enum Thread_Group_ID{
BACKGROUND_THREADS, BACKGROUND_THREADS,
THREAD_GROUP_COUNT THREAD_GROUP_COUNT
}; };
struct Thread_Memory{ struct Thread_Memory{
void *data; void *data;
i32 size; i32 size;
i32 id; i32 id;
}; };
struct Thread_Exchange; struct Thread_Exchange;
struct System_Functions; struct System_Functions;
#define Job_Callback_Sig(name) void name( \ #define Job_Callback_Sig(name) void name( \
System_Functions *system, Thread_Context *thread, Thread_Memory *memory, \ System_Functions *system, Thread_Context *thread, Thread_Memory *memory, \
Thread_Exchange *exchange, void *data[2]) Thread_Exchange *exchange, void *data[2])
typedef Job_Callback_Sig(Job_Callback); typedef Job_Callback_Sig(Job_Callback);
struct Job_Data{ struct Job_Data{
Job_Callback *callback; Job_Callback *callback;
void *data[2]; void *data[2];
i32 memory_request; i32 memory_request;
}; };
struct Full_Job_Data{ struct Full_Job_Data{
Job_Data job; Job_Data job;
u32 job_memory_index; u32 job_memory_index;
u32 running_thread; u32 running_thread;
b32 finished; b32 finished;
u32 id; u32 id;
}; };
struct Work_Queue{ struct Work_Queue{
Full_Job_Data jobs[256]; Full_Job_Data jobs[256];
Plat_Handle semaphore; Plat_Handle semaphore;
volatile u32 write_position; volatile u32 write_position;
volatile u32 read_position; volatile u32 read_position;
}; };
#define THREAD_NOT_ASSIGNED 0xFFFFFFFF #define THREAD_NOT_ASSIGNED 0xFFFFFFFF
#define JOB_ID_WRAP (ArrayCount(queue->jobs) * 4) #define JOB_ID_WRAP (ArrayCount(queue->jobs) * 4)
#define QUEUE_WRAP (ArrayCount(queue->jobs)) #define QUEUE_WRAP (ArrayCount(queue->jobs))
struct Thread_Exchange{ struct Thread_Exchange{
Work_Queue queues[THREAD_GROUP_COUNT]; Work_Queue queues[THREAD_GROUP_COUNT];
volatile u32 force_redraw; volatile u32 force_redraw;
}; };
#define Sys_Post_Job_Sig(name) u32 name(Thread_Group_ID group_id, Job_Data job) #define Sys_Post_Job_Sig(name) u32 name(Thread_Group_ID group_id, Job_Data job)
typedef Sys_Post_Job_Sig(System_Post_Job); typedef Sys_Post_Job_Sig(System_Post_Job);
#define Sys_Cancel_Job_Sig(name) void name(Thread_Group_ID group_id, u32 job_id) #define Sys_Cancel_Job_Sig(name) void name(Thread_Group_ID group_id, u32 job_id)
typedef Sys_Cancel_Job_Sig(System_Cancel_Job); typedef Sys_Cancel_Job_Sig(System_Cancel_Job);
#define Sys_Grow_Thread_Memory_Sig(name) void name(Thread_Memory *memory) #define Sys_Grow_Thread_Memory_Sig(name) void name(Thread_Memory *memory)
typedef Sys_Grow_Thread_Memory_Sig(System_Grow_Thread_Memory); typedef Sys_Grow_Thread_Memory_Sig(System_Grow_Thread_Memory);
#define Sys_Acquire_Lock_Sig(name) void name(i32 id) #define Sys_Acquire_Lock_Sig(name) void name(i32 id)
typedef Sys_Acquire_Lock_Sig(System_Acquire_Lock); typedef Sys_Acquire_Lock_Sig(System_Acquire_Lock);
#define Sys_Release_Lock_Sig(name) void name(i32 id) #define Sys_Release_Lock_Sig(name) void name(i32 id)
typedef Sys_Release_Lock_Sig(System_Release_Lock); typedef Sys_Release_Lock_Sig(System_Release_Lock);
// debug // debug
#define INTERNAL_Sys_Sentinel_Sig(name) Bubble* name() #define INTERNAL_Sys_Sentinel_Sig(name) Bubble* name()
typedef INTERNAL_Sys_Sentinel_Sig(INTERNAL_System_Sentinel); typedef INTERNAL_Sys_Sentinel_Sig(INTERNAL_System_Sentinel);
#define INTERNAL_Sys_Get_Thread_States_Sig(name) void name(Thread_Group_ID id, b8 *running, i32 *pending) #define INTERNAL_Sys_Get_Thread_States_Sig(name) void name(Thread_Group_ID id, b8 *running, i32 *pending)
typedef INTERNAL_Sys_Get_Thread_States_Sig(INTERNAL_System_Get_Thread_States); typedef INTERNAL_Sys_Get_Thread_States_Sig(INTERNAL_System_Get_Thread_States);
#define INTERNAL_Sys_Debug_Message_Sig(name) void name(char *message) #define INTERNAL_Sys_Debug_Message_Sig(name) void name(char *message)
typedef INTERNAL_Sys_Debug_Message_Sig(INTERNAL_System_Debug_Message); typedef INTERNAL_Sys_Debug_Message_Sig(INTERNAL_System_Debug_Message);
struct System_Functions{ struct System_Functions{
// files: 2 // files: 2
System_File_Time_Stamp *file_time_stamp; System_File_Time_Stamp *file_time_stamp;
System_Set_File_List *set_file_list; System_Set_File_List *set_file_list;
// file system navigation (4coder_custom.h): 2 // file system navigation (4coder_custom.h): 2
Directory_Has_File *directory_has_file; Directory_Has_File *directory_has_file;
Directory_CD *directory_cd; Directory_CD *directory_cd;
// clipboard: 1 // clipboard: 1
System_Post_Clipboard *post_clipboard; System_Post_Clipboard *post_clipboard;
// time: 1 // time: 1
System_Time *time; System_Time *time;
// cli: 4 // cli: 4
System_CLI_Call *cli_call; System_CLI_Call *cli_call;
System_CLI_Begin_Update *cli_begin_update; System_CLI_Begin_Update *cli_begin_update;
System_CLI_Update_Step *cli_update_step; System_CLI_Update_Step *cli_update_step;
System_CLI_End_Update *cli_end_update; System_CLI_End_Update *cli_end_update;
// threads: 5 // threads: 5
System_Post_Job *post_job; System_Post_Job *post_job;
System_Cancel_Job *cancel_job; System_Cancel_Job *cancel_job;
System_Grow_Thread_Memory *grow_thread_memory; System_Grow_Thread_Memory *grow_thread_memory;
System_Acquire_Lock *acquire_lock; System_Acquire_Lock *acquire_lock;
System_Release_Lock *release_lock; System_Release_Lock *release_lock;
// debug: 3 // debug: 3
INTERNAL_System_Sentinel *internal_sentinel; INTERNAL_System_Sentinel *internal_sentinel;
INTERNAL_System_Get_Thread_States *internal_get_thread_states; INTERNAL_System_Get_Thread_States *internal_get_thread_states;
INTERNAL_System_Debug_Message *internal_debug_message; INTERNAL_System_Debug_Message *internal_debug_message;
}; };
// BOTTOM // BOTTOM

BIN
vc120.pdb

Binary file not shown.

View File

@ -75,6 +75,8 @@ struct Win32_Input_Chunk_Transient{
b8 mouse_r_press, mouse_r_release; b8 mouse_r_press, mouse_r_release;
b32 out_of_window; b32 out_of_window;
i16 mouse_wheel; i16 mouse_wheel;
b32 redraw;
}; };
struct Win32_Input_Chunk_Persistent{ struct Win32_Input_Chunk_Persistent{
@ -411,7 +413,6 @@ Sys_Set_File_List_Sig(system_set_file_list){
info->folder = (find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0; info->folder = (find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
info->filename.str = name; info->filename.str = name;
char *name_base = name;
i32 i = 0; i32 i = 0;
for(;find_data.cFileName[i];++i) *name++ = find_data.cFileName[i]; for(;find_data.cFileName[i];++i) *name++ = find_data.cFileName[i];
info->filename.size = i; info->filename.size = i;
@ -1247,6 +1248,7 @@ Win32Callback(HWND hwnd, UINT uMsg,
i32 new_height = HIWORD(lParam); i32 new_height = HIWORD(lParam);
Win32Resize(new_width, new_height); Win32Resize(new_width, new_height);
win32vars.input_chunk.trans.redraw = 1;
} }
}break; }break;
@ -1378,7 +1380,9 @@ UpdateLoop(LPVOID param){
u32 redraw = exchange_vars.thread.force_redraw; u32 redraw = exchange_vars.thread.force_redraw;
if (redraw) exchange_vars.thread.force_redraw = 0; if (redraw) exchange_vars.thread.force_redraw = 0;
redraw = redraw || input_chunk.trans.redraw;
Key_Input_Data input_data; Key_Input_Data input_data;
Mouse_State mouse; Mouse_State mouse;
Application_Step_Result result; Application_Step_Result result;