From 951b992b2f3c7bd81314af3c19657d49dfdc5693 Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Thu, 28 Jan 2016 15:01:40 -0500 Subject: [PATCH] reopen works again --- 4coder_string.h | 150 ++++++++++++++++- 4ed.cpp | 321 +++++++++++++++++++++--------------- 4ed.h | 44 +++-- 4ed_app_settings.h | 25 +++ 4ed_app_target.cpp | 2 + 4ed_color_view.cpp | 95 ++++++++--- 4ed_config_view.cpp | 89 ++++++++++ 4ed_file_view.cpp | 345 +++++++++++++++++++++++---------------- 4ed_interactive_view.cpp | 13 +- 4ed_layout.cpp | 3 +- 4ed_menu_view.cpp | 10 +- 4ed_rendering_helper.cpp | 6 + vc120.pdb | Bin 94208 -> 94208 bytes win32_4ed.cpp | 237 ++++++++++++++------------- 14 files changed, 901 insertions(+), 439 deletions(-) create mode 100644 4ed_app_settings.h create mode 100644 4ed_config_view.cpp diff --git a/4coder_string.h b/4coder_string.h index 984f5f4a..6f6f7b30 100644 --- a/4coder_string.h +++ b/4coder_string.h @@ -62,6 +62,8 @@ inline String make_string(char *s, int size); #define make_lit_string(str) (make_string((char*)(str), sizeof(str)-1, sizeof(str))) #define make_fixed_width_string(str) (make_string((char*)(str), 0, sizeof(str))) +#define expand_str(s) ((s).str), ((s).size) + inline String make_string_slowly(char *s); inline char* make_c_str(String s); @@ -86,6 +88,18 @@ inline bool match_part(String a, char *b) { int x; return match_part(a,b,&x) FCPP_LINK bool match_part(char *a, String b); FCPP_LINK bool match_part(String a, String b); +FCPP_LINK bool match_unsensitive(char *a, char *b); +FCPP_LINK bool match_unsensitive(String a, char *b); +inline bool match_unsensitive(char *a, String b) { return match_unsensitive(b,a); } +FCPP_LINK bool match_unsensitive(String a, String b); + +FCPP_LINK bool match_part_unsensitive(char *a, char *b, int *len); +FCPP_LINK bool match_part_unsensitive(String a, char *b, int *len); +inline bool match_part_unsensitive(char *a, char *b) { int x; return match_part(a,b,&x); } +inline bool match_part_unsensitive(String a, char *b) { int x; return match_part(a,b,&x); } +FCPP_LINK bool match_part_unsensitive(char *a, String b); +FCPP_LINK bool match_part_unsensitive(String a, String b); + FCPP_LINK int find(char *s, int start, char c); FCPP_LINK int find(String s, int start, char c); FCPP_LINK int find(char *s, int start, char *c); @@ -109,6 +123,7 @@ FCPP_LINK int int_to_str(int x, char *s_out); FCPP_LINK bool int_to_str(int x, String *s_out); FCPP_LINK bool append_int_to_str(int x, String *s_out); +FCPP_LINK int str_to_int(char *s); FCPP_LINK int str_to_int(String s); FCPP_LINK int hexchar_to_int(char c); FCPP_LINK int int_to_hexchar(char c); @@ -345,6 +360,96 @@ match_part(String a, String b){ return 1; } +FCPP_LINK bool +match_unsensitive(char *a, char *b){ + for (int i = 0;; ++i){ + if (char_to_upper(a[i]) != + char_to_upper(b[i])){ + return 0; + } + if (a[i] == 0){ + return 1; + } + } +} + +FCPP_LINK bool +match_unsensitive(String a, char *b){ + int i = 0; + for (; i < a.size; ++i){ + if (char_to_upper(a.str[i]) != + char_to_upper(b[i])){ + return 0; + } + } + if (b[i] != 0){ + return 0; + } + return 1; +} + +FCPP_LINK bool +match_unsensitive(String a, String b){ + if (a.size != b.size){ + return 0; + } + for (int i = 0; i < b.size; ++i){ + if (char_to_upper(a.str[i]) != + char_to_upper(b.str[i])){ + return 0; + } + } + return 1; +} + +FCPP_LINK bool +match_part_unsensitive(char *a, char *b, int *len){ + int i; + for (i = 0; b[i] != 0; ++i){ + if (char_to_upper(a[i]) != char_to_upper(b[i])){ + return 0; + } + } + *len = i; + return 1; +} + +FCPP_LINK bool +match_part_unsensitive(String a, char *b, int *len){ + int i; + for (i = 0; b[i] != 0; ++i){ + if (char_to_upper(a.str[i]) != char_to_upper(b[i]) || + i == a.size){ + return 0; + } + } + *len = i; + return 1; +} + +FCPP_LINK bool +match_part_unsensitive(char *a, String b){ + for (int i = 0; i != b.size; ++i){ + if (char_to_upper(a[i]) != char_to_upper(b.str[i])){ + return 0; + } + } + return 1; +} + +FCPP_LINK bool +match_part_unsensitive(String a, String b){ + if (a.size < b.size){ + return 0; + } + for (int i = 0; i < b.size; ++i){ + if (char_to_upper(a.str[i]) != char_to_upper(b.str[i])){ + return 0; + } + } + return 1; +} + FCPP_LINK int find(char *str, int start, char character){ int i = start; @@ -634,6 +739,22 @@ append_int_to_str(int x, String *dest){ return result; } +FCPP_LINK int +str_to_int(char *str){ + int x = 0; + for (; *str; ++str){ + if (*str >= '0' || *str <= '9'){ + x *= 10; + x += *str - '0'; + } + else{ + x = 0; + break; + } + } + return(x); +} + FCPP_LINK int str_to_int(String str){ int x, i; @@ -975,14 +1096,27 @@ get_absolutes(String name, Absolutes *absolutes, bool implicit_first, bool impli } FCPP_LINK bool -wildcard_match(Absolutes *absolutes, char *x){ +wildcard_match(Absolutes *absolutes, char *x, int case_sensitive){ bool r = 1; String *a = absolutes->a; - if (absolutes->count == 1){ - r = match(x, *a); + + bool (*match_func)(char*, String); + bool (*match_part_func)(char*, String); + + if (case_sensitive){ + match_func = match; + match_part_func = match_part; } else{ - if (!match_part(x, *a)){ + match_func = match_unsensitive; + match_part_func = match_part_unsensitive; + } + + if (absolutes->count == 1){ + r = match_func(x, *a); + } + else{ + if (!match_part_func(x, *a)){ r = 0; } else{ @@ -994,7 +1128,7 @@ wildcard_match(Absolutes *absolutes, char *x){ r = 0; break; } - if (match_part(x, *a)){ + if (match_part_func(x, *a)){ x += a->size; ++a; } @@ -1005,7 +1139,7 @@ wildcard_match(Absolutes *absolutes, char *x){ if (r && a->size > 0){ r = 0; while (*x != 0){ - if (match_part(x, *a) && *(x + a->size) == 0){ + if (match_part_func(x, *a) && *(x + a->size) == 0){ r = 1; break; } @@ -1020,9 +1154,9 @@ wildcard_match(Absolutes *absolutes, char *x){ } FCPP_LINK bool -wildcard_match(Absolutes *absolutes, String x){ +wildcard_match(Absolutes *absolutes, String x, int case_sensitive){ terminate_with_null(&x); - return wildcard_match(absolutes, x.str); + return wildcard_match(absolutes, x.str, case_sensitive); } #undef FCPP_STRING_IMPLEMENTATION diff --git a/4ed.cpp b/4ed.cpp index 9fd1273a..faedbccd 100644 --- a/4ed.cpp +++ b/4ed.cpp @@ -40,6 +40,9 @@ struct Sys_App_Binding{ struct App_Vars{ Mem_Options mem; + + App_Settings settings; + Command_Map map_top; Command_Map map_file; Command_Map map_ui; @@ -737,8 +740,7 @@ app_open_file(System_Functions *system, Exchange *exchange, Temp_Memory temp = begin_temp_memory(&vars->mem.part); command_data->part = partition_sub_part(&vars->mem.part, 16 << 10); - view_set_file(system, - file_view, target_file, style, + view_set_file(system, file_view, target_file, style, vars->hooks[hook_open_file], command_data, &app_links); command_data->part = old_part; @@ -778,7 +780,7 @@ app_open_file(System_Functions *system, App_Vars *vars, Exchange *exchange, Mem_Options *mem; Editing_File *target_file = 0; b32 created_file = 0; - + filename_str = make_string(filename, len); mem = &vars->mem; @@ -791,10 +793,9 @@ app_open_file(System_Functions *system, App_Vars *vars, Exchange *exchange, if (file_id){ created_file = 1; target_file = file.file; - file_get_loading(target_file); - file_init_strings(target_file); file_set_name(target_file, filename); - table_add(&working_set->table, target_file->state.source_path, file.index); + file_set_to_loading(target_file); + table_add(&working_set->table, target_file->name.source_path, file.index); app_push_file_binding(vars, file_id, file.index); } @@ -809,40 +810,28 @@ app_open_file(System_Functions *system, App_Vars *vars, Exchange *exchange, View *new_view = live_set_alloc_view(live_set, mem); view_replace_major(system, exchange, new_view, panel, live_set); - + File_View *file_view = file_view_init(new_view, &vars->layout); result = file_view; View *old_view = command_data->view; command_data->view = new_view; - + Partition old_part = command_data->part; Temp_Memory temp = begin_temp_memory(&mem->part); command_data->part = partition_sub_part(&mem->part, Kbytes(16)); - + view_set_file(system, file_view, target_file, vars->font_set, style, vars->hooks[hook_open_file], command_data, &app_links); - + command_data->part = old_part; end_temp_memory(temp); command_data->view = old_view; - + new_view->map = app_get_map(vars, target_file->settings.base_map_id); } -#if 0 - file_id = exchange_request_file(exchange, filename, len); - - if (file_id){ - Get_File_Result - - - result = live_set_alloc_view(live_set, &vars->mem); - } - //exchange_free_file(exchange, file_id); -#endif - return(result); } @@ -899,6 +888,28 @@ COMMAND_DECL(interactive_open){ // - Keep current version open and do some sort of diff to keep // the cursor position correct COMMAND_DECL(reopen){ + ProfileMomentFunction(); + REQ_FILE_VIEW(view); + REQ_FILE(file, view); + USE_EXCHANGE(exchange); + USE_WORKING_SET(working_set); + USE_VARS(vars); + USE_STYLE(style); + + i32 file_id = exchange_request_file(exchange, expand_str(file->name.source_path)); + i32 index = 0; + if (file_id){ + file_set_to_loading(file); + index = working_set_get_index(working_set, file); + app_push_file_binding(vars, file_id, index); + + view_set_file(system, view, file, vars->font_set, style, + vars->hooks[hook_open_file], command, &app_links); + } + else{ + // TODO(allen): feedback message + } + #if 0 ProfileMomentFunction(); REQ_FILE_VIEW(view); @@ -923,8 +934,7 @@ COMMAND_DECL(reopen){ Temp_Memory temp = begin_temp_memory(&vars->mem.part); command->part = partition_sub_part(&vars->mem.part, 16 << 10); - view_set_file(system, - view, file, style, + view_set_file(system, view, file, style, vars->hooks[hook_open_file], command, app_links); command->part = old_part; @@ -953,7 +963,7 @@ COMMAND_DECL(save){ USE_EXCHANGE(exchange); USE_WORKING_SET(working_set); - String *file_path = &file->state.source_path; + String *file_path = &file->name.source_path; if (file_path->size > 0){ 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)); @@ -1049,7 +1059,7 @@ COMMAND_DECL(kill_buffer){ REQ_FILE(file, view); USE_DELAY(delay); - delayed_action(delay, DACT_TRY_KILL, file->state.live_name, view->view_base.panel); + delayed_action(delay, DACT_TRY_KILL, file->name.live_name, view->view_base.panel); } COMMAND_DECL(toggle_line_wrap){ @@ -1519,6 +1529,29 @@ COMMAND_DECL(open_color_tweaker){ open_theme_options(system, exchange, vars, live_set, mem, panel); } +inline void +open_config_options(System_Functions *system, Exchange *exchange, + App_Vars *vars, Live_Views *live_set, Mem_Options *mem, Panel *panel){ + View *new_view = live_set_alloc_view(live_set, mem); + view_replace_minor(system, exchange, new_view, panel, live_set); + + new_view->map = &vars->map_ui; + config_view_init(new_view, &vars->style, + &vars->working_set, vars->font_set, + &vars->settings); +} + +COMMAND_DECL(open_config){ + ProfileMomentFunction(); + USE_VARS(vars); + USE_LIVE_SET(live_set); + USE_MEM(mem); + USE_PANEL(panel); + USE_EXCHANGE(exchange); + + open_config_options(system, exchange, vars, live_set, mem, panel); +} + COMMAND_DECL(open_menu){ ProfileMomentFunction(); USE_VARS(vars); @@ -1721,7 +1754,7 @@ build(System_Functions *system, Mem_Options *mem, if (file){ file_create_super_locked(system, mem, file, buffer_name, font_set, style->font_id); file->settings.unimportant = 1; - table_add(&working_set->table, file->state.live_name, index); + table_add(&working_set->table, file->name.live_name, index); if (bind_to_new_view){ View *new_view = live_set_alloc_view(live_set, mem); @@ -1961,11 +1994,13 @@ extern "C"{ Working_Set *working_set = cmd->working_set; buffer.file_id = (int)(file - working_set->files); buffer.size = file->state.buffer.size; - buffer.file_name_len = file->state.source_path.size; - buffer.buffer_name_len = file->state.live_name.size; - buffer.file_name = file->state.source_path.str; - buffer.buffer_name = file->state.live_name.str; buffer.file_cursor_pos = file->state.cursor_pos; + + buffer.file_name_len = file->name.source_path.size; + buffer.buffer_name_len = file->name.live_name.size; + buffer.file_name = file->name.source_path.str; + buffer.buffer_name = file->name.live_name.str; + buffer.is_lexed = file->settings.tokens_exist; buffer.map_id = file->settings.base_map_id; #endif @@ -2190,85 +2225,6 @@ setup_command_table(){ #undef SET } -// Interactive Bar - -internal void -hot_directory_draw_helper(Render_Target *target, - Hot_Directory *hot_directory, - Interactive_Bar *bar, String *string, - bool32 include_files){ - persist u8 str_open_bracket[] = " {"; - persist u8 str_close_bracket[] = "}"; - persist u8 str_comma[] = ", "; - - intbar_draw_string(target, bar, *string, bar->style.pop1_color); - intbar_draw_string(target, bar, str_open_bracket, bar->style.base_color); - - char front_name_[256]; - String front_name = make_fixed_width_string(front_name_); - get_front_of_directory(&front_name, *string); - - bool32 is_first_string = 1; - File_List *files = &hot_directory->file_list; - - Absolutes absolutes; - get_absolutes(front_name, &absolutes, 1, 1); - - File_Info *info, *end; - end = files->infos + files->count; - for (info = files->infos; info != end; ++info){ - String filename = info->filename; - - if (filename_match(front_name, &absolutes, filename)){ - if (is_first_string){ - is_first_string = 0; - } - else{ - intbar_draw_string(target, bar, str_comma, bar->style.base_color); - } - if (info->folder){ - intbar_draw_string(target, bar, filename, bar->style.pop1_color); - intbar_draw_string(target, bar, (u8*)"/", bar->style.pop1_color); - } - else{ - intbar_draw_string(target, bar, filename, bar->style.base_color); - } - } - } - - intbar_draw_string(target, bar, str_close_bracket, bar->style.base_color); -} - -internal void -live_file_draw_helper(Render_Target *target, Working_Set *working_set, - Interactive_Bar *bar, String *string){ - persist u8 str_open_bracket[] = " {"; - persist u8 str_close_bracket[] = "}"; - persist u8 str_comma[] = ", "; - - intbar_draw_string(target, bar, *string, bar->style.base_color); - - intbar_draw_string(target, bar, str_open_bracket, bar->style.base_color); - - bool32 is_first_string = 1; - for (i32 file_i = 0; - file_i < working_set->file_index_count; - ++file_i){ - Editing_File *file = &working_set->files[file_i]; - if (file->state.live_name.str && - (string->size == 0 || has_substr_unsensitive(file->state.live_name, *string))){ - if (is_first_string){ - is_first_string = 0; - } - else{ - intbar_draw_string(target, bar, str_comma, bar->style.base_color); - } - intbar_draw_string(target, bar, file->state.live_name, bar->style.base_color); - } - } - intbar_draw_string(target, bar, str_close_bracket, bar->style.base_color); -} - // App Functions internal void @@ -2535,6 +2491,91 @@ HOOK_SIG(default_open_file_hook){ app->clear_parameters(cmd_context); } +enum Command_Line_Action{ + CLAct_Ignore, + CLAct_UserFile, + CLAct_CustomDLL, + CLAct_InitialFilePosition, + CLAct_WindowSize, + CLAct_WindowPosition, + CLAct_Count +}; + +void +init_command_line_settings(App_Settings *settings, App_Plat_Settings *plat_settings, + Command_Line_Parameters clparams){ + char *arg; + Command_Line_Action action; + i32 i,index; + b32 strict = 0; + + settings->init_files_max = ArrayCount(settings->init_files); + for (i = 1; i < clparams.argc; ++i){ + arg = clparams.argv[i]; + if (arg[0] == '-'){ + action = CLAct_Ignore; + switch (arg[1]){ + case 'u': action = CLAct_UserFile; strict = 0; break; + case 'U': action = CLAct_UserFile; strict = 1; break; + + case 'd': action = CLAct_CustomDLL; strict = 0; break; + case 'D': action = CLAct_CustomDLL; strict = 1; break; + + case 'l': action = CLAct_InitialFilePosition; break; + + case 'w': action = CLAct_WindowSize; break; + case 'p': action = CLAct_WindowPosition; break; + } + + switch (action){ + case CLAct_UserFile: + settings->user_file_is_strict = strict; + ++i; + if (i < clparams.argc){ + settings->user_file = clparams.argv[i]; + } + break; + + case CLAct_CustomDLL: + plat_settings->custom_dll_is_strict = strict; + ++i; + if (i < clparams.argc){ + plat_settings->custom_dll = clparams.argv[i]; + } + break; + + case CLAct_InitialFilePosition: + ++i; + if (i < clparams.argc){ + settings->initial_line = str_to_int(clparams.argv[i]); + } + break; + + case CLAct_WindowSize: + break; + + case CLAct_WindowPosition: + break; + } + + } + else{ + if (settings->init_files_count < settings->init_files_max){ + index = settings->init_files_count++; + settings->init_files[index] = arg; + } + } + } +} + +App_Read_Command_Line_Sig(app_read_command_line){ + i32 output_size = 0; + + //init_command_line_settings(); + + return(output_size); +} + App_Init_Sig(app_init){ app_links_init(system); @@ -2546,11 +2587,12 @@ App_Init_Sig(app_init){ vars->mem.part = _partition; Partition *partition = &vars->mem.part; target->partition = partition; + general_memory_open(&vars->mem.general, memory->target_memory, memory->target_memory_size); i32 panel_max_count = vars->layout.panel_max_count = 16; - i32 panel_count = vars->layout.panel_count = 1; i32 divider_max_count = panel_max_count - 1; + vars->layout.panel_count = 1; Panel *panels = vars->layout.panels = push_array(partition, Panel, panel_max_count); @@ -2571,6 +2613,7 @@ App_Init_Sig(app_init){ sizeof(File_View), sizeof(Color_View), sizeof(Interactive_View), + sizeof(Menu_View), #if FRED_INTERNAL sizeof(Debug_View), #endif @@ -2595,21 +2638,21 @@ App_Init_Sig(app_init){ view->next_free = 0; } vars->live_set.free_view = (View*)views_; - + setup_command_table(); Command_Map *global = &vars->map_top; if (vars->config_api.get_bindings){ i32 size = partition_remaining(partition); void *data = partition_current(partition); - + // TODO(allen): Use a giant bubble of general memory for this. // So that it doesn't interfere with the command maps as they allocate // their own memory. - i32 wanted_size = vars->config_api.get_bindings(data, size, loose_codes); + i32 wanted_size = vars->config_api.get_bindings(data, size, codes); - bool32 did_top = 0; - bool32 did_file = 0; + b32 did_top = 0; + b32 did_file = 0; if (wanted_size <= size){ partition_allocate(partition, wanted_size); @@ -2711,17 +2754,17 @@ App_Init_Sig(app_init){ } } - if (!did_top) setup_top_commands(&vars->map_top, &vars->mem.part, loose_codes, global); - if (!did_file) setup_file_commands(&vars->map_file, &vars->mem.part, loose_codes, global); + if (!did_top) setup_top_commands(&vars->map_top, &vars->mem.part, codes, global); + if (!did_file) setup_file_commands(&vars->map_file, &vars->mem.part, codes, global); } else{ - setup_top_commands(&vars->map_top, &vars->mem.part, loose_codes, global); - setup_file_commands(&vars->map_file, &vars->mem.part, loose_codes, global); + setup_top_commands(&vars->map_top, &vars->mem.part, codes, global); + setup_file_commands(&vars->map_file, &vars->mem.part, codes, global); } - setup_ui_commands(&vars->map_ui, &vars->mem.part, loose_codes, global); + setup_ui_commands(&vars->map_ui, &vars->mem.part, codes, global); #if FRED_INTERNAL - setup_debug_commands(&vars->map_debug, &vars->mem.part, loose_codes, global); + setup_debug_commands(&vars->map_debug, &vars->mem.part, codes, global); #endif if (vars->hooks[hook_open_file] == 0){ @@ -2834,7 +2877,6 @@ App_Init_Sig(app_init){ vars->palette_size = 40; vars->palette = push_array(partition, u32, vars->palette_size); - AllowLocal(panel_count); panel_init(&panels[0]); String hdbase = make_fixed_width_string(vars->hot_dir_base_); @@ -2853,13 +2895,11 @@ App_Init_Sig(app_init){ vars->sys_app_max = exchange->file.max; vars->sys_app_count = 0; vars->sys_app_bindings = (Sys_App_Binding*)push_array(partition, Sys_App_Binding, vars->sys_app_max); - - return 1; } App_Step_Sig(app_step){ ProfileStart(OS_syncing); - Application_Step_Result app_result = {}; + Application_Step_Result app_result = *result; app_result.redraw = force_redraw; App_Vars *vars = (App_Vars*)memory->vars_memory; @@ -2883,7 +2923,7 @@ App_Step_Sig(app_step){ Editing_File *file = vars->working_set.files + i; if (!file->state.is_dummy){ - u64 time_stamp = system->file_time_stamp(make_c_str(file->state.source_path)); + u64 time_stamp = system->file_time_stamp(make_c_str(file->name.source_path)); if (time_stamp > 0){ file->state.last_sys_write_time = time_stamp; @@ -3381,7 +3421,7 @@ App_Step_Sig(app_step){ { Editing_File *file = working_set_lookup_file(working_set, *string); if (!file->state.is_dummy){ - file_save(system, exchange, mem, file, file->state.source_path.str); + file_save(system, exchange, mem, file, file->name.source_path.str); } }break; @@ -3390,7 +3430,7 @@ App_Step_Sig(app_step){ Get_File_Result file = working_set_get_available_file(working_set); file_create_empty(system, mem, file.file, string->str, vars->font_set, style->font_id); - table_add(&working_set->table, file.file->state.source_path, file.index); + table_add(&working_set->table, file.file->name.source_path, file.index); View *new_view = live_set_alloc_view(live_set, mem); view_replace_major(system, exchange, new_view, panel, live_set); @@ -3427,7 +3467,7 @@ App_Step_Sig(app_step){ { Editing_File *file = working_set_lookup_file(working_set, *string); if (file){ - table_remove(&working_set->table, file->state.source_path); + table_remove(&working_set->table, file->name.source_path); kill_file(system, exchange, general, file, live_set, &vars->layout); } }break; @@ -3447,10 +3487,10 @@ App_Step_Sig(app_step){ int_view->interaction = INTV_SURE_TO_KILL_INTER; int_view->action = INTV_SURE_TO_KILL; copy(&int_view->query, "Are you sure?"); - copy(&int_view->dest, file->state.live_name); + copy(&int_view->dest, file->name.live_name); } else{ - table_remove(&working_set->table, file->state.source_path); + table_remove(&working_set->table, file->name.source_path); kill_file(system, exchange, general, file, live_set, &vars->layout); view_remove_minor(system, exchange, panel, live_set); } @@ -3471,6 +3511,11 @@ App_Step_Sig(app_step){ { open_theme_options(system, exchange, vars, live_set, mem, panel); }break; + + case DACT_KEYBOARD_OPTIONS: + { + open_config_options(system, exchange, vars, live_set, mem, panel); + }break; } } } @@ -3586,7 +3631,7 @@ App_Step_Sig(app_step){ Editing_File *file = get_file(&vars->working_set, binding->app_id); if (file){ - file_synchronize_times(system, file, file->state.source_path.str); + file_synchronize_times(system, file, file->name.source_path.str); } exchange_free_file(exchange, binding->sys_id); @@ -3677,7 +3722,10 @@ App_Step_Sig(app_step){ vars->prev_mouse_panel = mouse_panel; ProfileEnd(get_cursor); - return app_result; + *result = app_result; + result->lctrl_lalt_is_altgr = vars->settings.lctrl_lalt_is_altgr; + + // end-of-app_step } internal @@ -3696,9 +3744,10 @@ App_Free_Sig(app_free){ external App_Get_Functions_Sig(app_get_functions){ App_Functions result = {}; + result.read_command_line = app_read_command_line; result.init = app_init; result.step = app_step; - + result.alloc = app_alloc; result.free = app_free; diff --git a/4ed.h b/4ed.h index f75bfa52..cef626f7 100644 --- a/4ed.h +++ b/4ed.h @@ -120,15 +120,34 @@ struct Exchange{ File_Exchange file; }; -#define App_Init_Sig(name) \ - b32 name(System_Functions *system, \ - Render_Target *target, \ - Application_Memory *memory, \ - Exchange *exchange, \ - Key_Codes *loose_codes, \ - Clipboard_Contents clipboard, \ - String current_directory, \ - Custom_API api) +struct Command_Line_Parameters{ + char **argv; + int argc; +}; + +struct App_Plat_Settings{ + char *custom_dll; + b32 custom_dll_is_strict; +}; + +#define App_Read_Command_Line_Sig(name) \ + i32 name(System_Functions *system, \ + Application_Memory *memory, \ + String current_directory, \ + Command_Line_Parameters clparams \ + ) + +typedef App_Read_Command_Line_Sig(App_Read_Command_Line); + +#define App_Init_Sig(name) void \ + name(System_Functions *system, \ + Render_Target *target, \ + Application_Memory *memory, \ + Exchange *exchange, \ + Key_Codes *codes, \ + Clipboard_Contents clipboard, \ + String current_directory, \ + Custom_API api) typedef App_Init_Sig(App_Init); @@ -145,9 +164,10 @@ enum Application_Mouse_Cursor{ struct Application_Step_Result{ Application_Mouse_Cursor mouse_cursor_type; b32 redraw; + b32 lctrl_lalt_is_altgr; }; -#define App_Step_Sig(name) Application_Step_Result \ +#define App_Step_Sig(name) void \ name(System_Functions *system, \ Key_Codes *codes, \ Key_Input_Data *input, \ @@ -156,7 +176,8 @@ struct Application_Step_Result{ Application_Memory *memory, \ Exchange *exchange, \ Clipboard_Contents clipboard, \ - b32 time_step, b32 first_step, b32 force_redraw) + b32 time_step, b32 first_step, b32 force_redraw, \ + Application_Step_Result *result) typedef App_Step_Sig(App_Step); @@ -167,6 +188,7 @@ typedef App_Alloc_Sig(App_Alloc); typedef App_Free_Sig(App_Free); struct App_Functions{ + App_Read_Command_Line *read_command_line; App_Init *init; App_Step *step; diff --git a/4ed_app_settings.h b/4ed_app_settings.h new file mode 100644 index 00000000..3c32db29 --- /dev/null +++ b/4ed_app_settings.h @@ -0,0 +1,25 @@ +/* + * Mr. 4th Dimention - Allen Webster + * + * 27.01.2016 + * + * Global app level settings definition + * + */ + +// TOP + +struct App_Settings{ + char *user_file; + b32 user_file_is_strict; + + char *init_files[4]; + i32 init_files_count; + i32 init_files_max; + + i32 initial_line; + b32 lctrl_lalt_is_altgr; +}; + +// BOTTOM + diff --git a/4ed_app_target.cpp b/4ed_app_target.cpp index e21e0d49..a27b3d6b 100644 --- a/4ed_app_target.cpp +++ b/4ed_app_target.cpp @@ -42,6 +42,8 @@ #include "4ed_color_view.cpp" #include "4ed_interactive_view.cpp" #include "4ed_menu_view.cpp" +#include "4ed_app_settings.h" +#include "4ed_config_view.cpp" #include "4ed_debug_view.cpp" #include "4ed.cpp" diff --git a/4ed_color_view.cpp b/4ed_color_view.cpp index 56194c62..4d9599b6 100644 --- a/4ed_color_view.cpp +++ b/4ed_color_view.cpp @@ -1189,7 +1189,7 @@ update_highlighting(Color_View *color_view){ color_view->highlight.ids[3] = raw_ptr_dif(&style->main.at_highlight_color, style); } - else if (file_view->paste_effect.tick_down > 0){ + else if (file->state.paste_effect.tick_down > 0){ color_view->highlight.ids[2] = raw_ptr_dif(&style->main.paste_color, style); color_view->highlight.ids[3] = 0; @@ -1289,7 +1289,8 @@ do_style_preview(Library_UI *ui, Style *style, i32 toggle = -1){ } internal b32 -do_main_file_box(System_Functions *system, UI_State *state, UI_Layout *layout, Hot_Directory *hot_directory, char *end = 0){ +do_main_file_box(System_Functions *system, UI_State *state, UI_Layout *layout, + Hot_Directory *hot_directory, b32 try_to_match, b32 case_sensitive, char *end){ b32 result = 0; Style *style = state->style; String *string = &hot_directory->string; @@ -1299,7 +1300,7 @@ do_main_file_box(System_Functions *system, UI_State *state, UI_Layout *layout, H i32_Rect box = layout_rect(layout, line_height + 2); if (state->input_stage){ - if (ui_do_file_field_input(system, state, hot_directory)){ + if (ui_do_file_field_input(system, state, hot_directory, try_to_match, case_sensitive)){ result = 1; } } @@ -1318,9 +1319,9 @@ do_main_file_box(System_Functions *system, UI_State *state, UI_Layout *layout, H return result; } -internal bool32 +internal b32 do_main_string_box(System_Functions *system, UI_State *state, UI_Layout *layout, String *string){ - bool32 result = 0; + b32 result = 0; Style *style = state->style; i16 font_id = style->font_id; @@ -1345,9 +1346,9 @@ do_main_string_box(System_Functions *system, UI_State *state, UI_Layout *layout, return result; } -internal bool32 +internal b32 do_list_option(i32 id, UI_State *state, UI_Layout *layout, String text){ - bool32 result = 0; + b32 result = 0; Style *style = state->style; i16 font_id = style->font_id; @@ -1381,7 +1382,51 @@ do_list_option(i32 id, UI_State *state, UI_Layout *layout, String text){ return result; } -#define do_list_option_lit(id,state,layout,str) do_list_option(id, state, layout, make_lit_string(str)) +internal b32 +do_checkbox_list_option(i32 id, UI_State *state, UI_Layout *layout, String text, b32 is_on){ + b32 result = 0; + Style *style = state->style; + + i16 font_id = style->font_id; + i32 character_h = get_font_info(state->font_set, font_id)->height; + + i32_Rect box = layout_rect(layout, character_h*2); + Widget_ID wid = make_id(state, id); + + if (state->input_stage){ + if (ui_do_button_input(state, box, wid, 0)){ + result = 1; + } + } + else{ + Render_Target *target = state->target; + i32_Rect inner = get_inner_rect(box, 3); + u32 back, outline, fore, pop, box_color; + back = style->main.back_color; + fore = style->main.default_color; + pop = style->main.file_info_style.pop2_color; + if (is_hover(state, wid)) outline = style->main.margin_active_color; + else outline = style->main.margin_color; + box_color = style->main.margin_active_color; + + draw_rectangle(target, inner, back); + + i32_Rect square; + square = get_inner_rect(inner, character_h/3); + square.x1 = square.x0 + (square.y1 - square.y0); + if (is_on) draw_rectangle(target, square, box_color); + else draw_margin(target, square, 1, box_color); + + i32 x = square.x1 + 3; + i32 y = box.y0 + character_h/2; + x = draw_string(target, font_id, text, x, y, fore); + draw_margin(target, box, inner, outline); + } + + layout->y = box.y1; + return result; +} + internal b32 do_file_option(i32 id, UI_State *state, UI_Layout *layout, String filename, b32 is_folder, String extra){ @@ -1421,13 +1466,13 @@ do_file_option(i32 id, UI_State *state, UI_Layout *layout, String filename, b32 } internal b32 -do_file_list_box(System_Functions *system, UI_State *state, - UI_Layout *layout, Hot_Directory *hot_dir, b32 has_filter, +do_file_list_box(System_Functions *system, UI_State *state, UI_Layout *layout, + Hot_Directory *hot_dir, b32 has_filter, b32 try_to_match, b32 case_sensitive, b32 *new_dir, b32 *selected, char *end){ b32 result = 0; File_List *files = &hot_dir->file_list; - if (do_main_file_box(system, state, layout, hot_dir, end)){ + if (do_main_file_box(system, state, layout, hot_dir, try_to_match, case_sensitive, end)){ *selected = 1; terminate_with_null(&hot_dir->string); } @@ -1435,7 +1480,7 @@ do_file_list_box(System_Functions *system, UI_State *state, persist String p4c_extension = make_lit_string("p4c"); persist String message_loaded = make_lit_string(" LOADED"); persist String message_unsaved = make_lit_string(" LOADED *"); - persist String message_unsynced = make_lit_string(" LOADED BEHIND OS"); + persist String message_unsynced = make_lit_string(" LOADED !"); persist String message_nothing = {}; char front_name_space[256]; @@ -1464,7 +1509,7 @@ do_file_list_box(System_Functions *system, UI_State *state, b8 is_folder = (info->folder != 0); b8 ext_match = (match(file_extension(filename), p4c_extension) != 0); - b8 name_match = (filename_match(front_name, &absolutes, filename) != 0); + b8 name_match = (filename_match(front_name, &absolutes, filename, case_sensitive) != 0); b8 is_loaded = (file != 0); String message = message_nothing; @@ -1498,9 +1543,9 @@ do_file_list_box(System_Functions *system, UI_State *state, } internal b32 -do_live_file_list_box(System_Functions *system, UI_State *state, UI_Layout *layout, Working_Set *working_set, - String *string, bool32 *selected){ - bool32 result = 0; +do_live_file_list_box(System_Functions *system, UI_State *state, UI_Layout *layout, + Working_Set *working_set, String *string, b32 *selected){ + b32 result = 0; if (do_main_string_box(system, state, layout, string)){ *selected = 1; @@ -1508,7 +1553,7 @@ do_live_file_list_box(System_Functions *system, UI_State *state, UI_Layout *layo } else{ persist String message_unsaved = make_lit_string(" *"); - persist String message_unsynced = make_lit_string(" BEHIND OS"); + persist String message_unsynced = make_lit_string(" !"); persist String message_nothing = {}; Absolutes absolutes; @@ -1526,11 +1571,11 @@ do_live_file_list_box(System_Functions *system, UI_State *state, UI_Layout *layo case SYNC_UNSAVED: message = message_unsaved; break; } - if (filename_match(*string, &absolutes, file->state.live_name)){ - if (do_file_option(100+i, state, layout, file->state.live_name, 0, message)){ + if (filename_match(*string, &absolutes, file->name.live_name, 1)){ + if (do_file_option(100+i, state, layout, file->name.live_name, 0, message)){ result = 1; *selected = 1; - copy(string, file->state.live_name); + copy(string, file->name.live_name); terminate_with_null(string); } } @@ -1567,6 +1612,8 @@ step_draw_library(System_Functions *system, Exchange *exchange, Mem_Options *mem ui.layout.y -= FLOOR32(color_view->state.view_y); ui.layout.rect.x1 -= 20; + b32 case_sensitive = 0; + if (!ui.state.input_stage) draw_push_clip(ui.state.target, ui.layout.rect); switch (mode){ case CV_MODE_LIBRARY: @@ -1629,8 +1676,8 @@ step_draw_library(System_Functions *system, Exchange *exchange, Mem_Options *mem } b32 new_dir = 0; - if (do_file_list_box(system, - &ui.state, &ui.layout, ui.hot_directory, color_view->p4c_only, + if (do_file_list_box(system, &ui.state, &ui.layout, + ui.hot_directory, color_view->p4c_only, 1, case_sensitive, &new_dir, &file_selected, 0)){ result = 1; } @@ -1694,8 +1741,8 @@ step_draw_library(System_Functions *system, Exchange *exchange, Mem_Options *mem } b32 new_dir = 0; - if (do_file_list_box(system, - &ui.state, &ui.layout, ui.hot_directory, 1, + if (do_file_list_box(system, &ui.state, &ui.layout, + ui.hot_directory, 1, 1, case_sensitive, &new_dir, &file_selected, ".p4c")){ result = 1; } diff --git a/4ed_config_view.cpp b/4ed_config_view.cpp new file mode 100644 index 00000000..f01d83c4 --- /dev/null +++ b/4ed_config_view.cpp @@ -0,0 +1,89 @@ +/* + * Mr. 4th Dimention - Allen Webster + * + * 27.01.2016 + * + * Configuration customizing view for 4coder + * + */ + +// TOP + +struct Config_View{ + View view_base; + UI_State state; + Style *style; + Font_Set *font_set; + Working_Set *working_set; + + App_Settings *settings; +}; + +inline Config_View* +view_to_config_view(View *view){ + Config_View *result = 0; + if (view->type == VIEW_TYPE_CONFIG){ + result = (Config_View*)view; + } + return result; +} + +internal i32 +step_draw_config_view(Config_View *view, Render_Target *target, i32_Rect rect, + Input_Summary *user_input, b32 input_stage){ + i32 result = 0; + + UI_State state = + ui_state_init(&view->state, target, user_input, + view->style, view->font_set, view->working_set, input_stage); + + UI_Layout layout; + begin_layout(&layout, rect); + + i32 id = 0; + + do_label(&state, &layout, literal("Config"), 2.f); + + if (do_checkbox_list_option(++id, &state, &layout, make_lit_string("Left Ctrl + Left Alt = AltGr"), + view->settings->lctrl_lalt_is_altgr)){ + view->settings->lctrl_lalt_is_altgr = !view->settings->lctrl_lalt_is_altgr; + } + + if (ui_finish_frame(&view->state, &state, &layout, rect, 0, 0)){ + result = 1; + } + + return result; +} + +Do_View_Sig(do_config_view){ + i32 result = 0; + + Config_View *config_view = (Config_View*)view; + switch (message){ + case VMSG_STEP: case VMSG_DRAW: + result = step_draw_config_view(config_view, target, rect, user_input, + (message == VMSG_STEP)); + break; + } + + return result; +} + +internal Config_View* +config_view_init(View *view, Style *style, Working_Set *working_set, + Font_Set *font_set, App_Settings *settings){ + view->type = VIEW_TYPE_CONFIG; + view->do_view = do_config_view; + + Config_View *result; + result = (Config_View*)view; + result->style = style; + result->working_set = working_set; + result->font_set = font_set; + result->settings = settings; + return result; +} + +// BOTTOM + diff --git a/4ed_file_view.cpp b/4ed_file_view.cpp index 3499f05c..4b733079 100644 --- a/4ed_file_view.cpp +++ b/4ed_file_view.cpp @@ -85,6 +85,12 @@ struct Undo_Data{ b32 current_block_normal; }; +struct Text_Effect{ + i32 start, end; + u32 color; + i32 tick_down, tick_max; +}; + // NOTE(allen): The Editing_File struct is now divided into two // parts. Variables in the Settings part can be set even when the // file is still streaming in, and all operations except for the @@ -109,13 +115,6 @@ struct Editing_File_State{ Buffer_Type buffer; i32 cursor_pos; - char live_name_[256]; - String live_name; - - char source_path_[256]; - char extension_[16]; - String source_path; - String extension; Undo_Data undo; @@ -125,14 +124,27 @@ struct Editing_File_State{ b32 tokens_complete; b32 still_lexing; + Text_Effect paste_effect; + u64 last_4ed_write_time; u64 last_4ed_edit_time; u64 last_sys_write_time; }; +struct Editing_File_Name{ + char live_name_[256]; + String live_name; + + char source_path_[256]; + char extension_[16]; + String source_path; + String extension; +}; + struct Editing_File{ Editing_File_Settings settings; Editing_File_State state; + Editing_File_Name name; }; struct File_Table_Entry{ @@ -230,19 +242,13 @@ struct Working_Set{ i32 clipboard_current, clipboard_rolling; }; -struct Text_Effect{ - i32 start, end; - u32 color; - i32 tick_down, tick_max; -}; - struct File_View_Mode{ - bool8 rewrite; + b8 rewrite; }; struct Incremental_Search{ String str; - bool32 reverse; + b32 reverse; i32 pos; }; @@ -256,7 +262,8 @@ enum Action_Type{ DACT_KILL, DACT_CLOSE_MINOR, DACT_CLOSE_MAJOR, - DACT_THEME_OPTIONS + DACT_THEME_OPTIONS, + DACT_KEYBOARD_OPTIONS }; struct Delayed_Action{ @@ -356,22 +363,23 @@ hot_directory_reload(System_Functions *system, Hot_Directory *hot_directory, Wor struct Hot_Directory_Match{ String filename; - bool32 is_folder; + b32 is_folder; }; -internal bool32 -filename_match(String query, Absolutes *absolutes, String filename){ - bool32 result; +internal b32 +filename_match(String query, Absolutes *absolutes, String filename, b32 case_sensitive){ + b32 result; result = (query.size == 0); - if (!result) result = wildcard_match(absolutes, filename); + if (!result) result = wildcard_match(absolutes, filename, case_sensitive); return result; } internal Hot_Directory_Match hot_directory_first_match(Hot_Directory *hot_directory, String str, - bool32 include_files, - bool32 exact_match){ + b32 include_files, + b32 exact_match, + b32 case_sensitive){ Hot_Directory_Match result = {}; Absolutes absolutes; @@ -383,12 +391,17 @@ hot_directory_first_match(Hot_Directory *hot_directory, end = files->infos + files->count; for (info = files->infos; info != end; ++info){ String filename = info->filename; - bool32 is_match = 0; + b32 is_match = 0; if (exact_match){ - if (match(filename, str)) is_match = 1; + if (case_sensitive){ + if (match(filename, str)) is_match = 1; + } + else{ + if (match_unsensitive(filename, str)) is_match = 1; + } } else{ - if (filename_match(str, &absolutes, filename)) is_match = 1; + if (filename_match(str, &absolutes, filename, case_sensitive)) is_match = 1; } if (is_match){ @@ -422,6 +435,8 @@ struct Single_Line_Mode{ String *string; Hot_Directory *hot_directory; b32 fast_folder_select; + b32 try_to_match; + b32 case_sensitive; }; internal Single_Line_Input_Step @@ -464,14 +479,16 @@ app_single_line_input_core(System_Functions *system, else{ result.hit_newline = 1; if (mode.fast_folder_select){ - char front_name_space[256]; - String front_name = - make_string(front_name_space, 0, ArrayCount(front_name_space)); - get_front_of_directory(&front_name, *mode.string); Hot_Directory_Match match; - match = hot_directory_first_match(mode.hot_directory, front_name, 1, 1); - if (!match.filename.str){ - match = hot_directory_first_match(mode.hot_directory, front_name, 1, 0); + char front_name_space[256]; + String front_name = make_fixed_width_string(front_name_space); + get_front_of_directory(&front_name, *mode.string); + + match = + hot_directory_first_match(mode.hot_directory, front_name, 1, 1, mode.case_sensitive); + + if (mode.try_to_match && !match.filename.str){ + match = hot_directory_first_match(mode.hot_directory, front_name, 1, 0, mode.case_sensitive); } if (match.filename.str){ if (match.is_folder){ @@ -480,13 +497,16 @@ app_single_line_input_core(System_Functions *system, result.hit_newline = 0; } else{ - mode.string->size = reverse_seek_slash(*mode.string) + 1; - append(mode.string, match.filename); - result.hit_newline = 1; + if (mode.try_to_match){ + mode.string->size = reverse_seek_slash(*mode.string) + 1; + append(mode.string, match.filename); + } } } else{ - result.no_file_match = 1; + if (mode.try_to_match){ + result.no_file_match = 1; + } } } } @@ -531,21 +551,23 @@ app_single_line_input_step(System_Functions *system, } inline Single_Line_Input_Step -app_single_file_input_step(System_Functions *system, - Key_Codes *codes, Working_Set *working_set, Key_Event_Data key, +app_single_file_input_step(System_Functions *system, Key_Codes *codes, + Working_Set *working_set, Key_Event_Data key, String *string, Hot_Directory *hot_directory, - bool32 fast_folder_select){ + b32 fast_folder_select, b32 try_to_match, b32 case_sensitive){ Single_Line_Mode mode = {}; mode.type = SINGLE_LINE_FILE; mode.string = string; mode.hot_directory = hot_directory; mode.fast_folder_select = fast_folder_select; + mode.try_to_match = try_to_match; + mode.case_sensitive = case_sensitive; return app_single_line_input_core(system, codes, working_set, key, mode); } inline Single_Line_Input_Step -app_single_number_input_step(System_Functions *system, - Key_Codes *codes, Key_Event_Data key, String *string){ +app_single_number_input_step(System_Functions *system, Key_Codes *codes, + Key_Event_Data key, String *string){ Single_Line_Input_Step result = {}; Single_Line_Mode mode = {}; mode.type = SINGLE_LINE_STRING; @@ -933,9 +955,9 @@ ui_do_vscroll_input(UI_State *state, i32_Rect top, i32_Rect bottom, i32_Rect sli return val; } -internal bool32 +internal b32 ui_do_text_field_input(UI_State *state, String *str){ - bool32 result = 0; + b32 result = 0; Key_Summary *keys = state->keys; for (i32 key_i = 0; key_i < keys->count; ++key_i){ Key_Event_Data key = get_single_key(keys, key_i); @@ -954,26 +976,33 @@ ui_do_text_field_input(UI_State *state, String *str){ return result; } -internal bool32 -ui_do_file_field_input(System_Functions *system, - UI_State *state, Hot_Directory *hot_dir){ - bool32 result = 0; +internal b32 +ui_do_file_field_input(System_Functions *system, UI_State *state, + Hot_Directory *hot_dir, b32 try_to_match, b32 case_sensitive){ + Key_Event_Data key; + Single_Line_Input_Step step; + String *str = &hot_dir->string; Key_Summary *keys = state->keys; - for (i32 key_i = 0; key_i < keys->count; ++key_i){ - Key_Event_Data key = get_single_key(keys, key_i); - String *str = &hot_dir->string; - terminate_with_null(str); - Single_Line_Input_Step step = - app_single_file_input_step(system, state->codes, state->working_set, key, str, hot_dir, 1); + i32 key_i; + b32 result = 0; + + terminate_with_null(str); + + for (key_i = 0; key_i < keys->count; ++key_i){ + key = get_single_key(keys, key_i); + step = + app_single_file_input_step(system, state->codes, + state->working_set, key, str, + hot_dir, 1, try_to_match, case_sensitive); if ((step.hit_newline || step.hit_ctrl_newline) && !step.no_file_match) result = 1; } return result; } -internal bool32 +internal b32 ui_do_line_field_input(System_Functions *system, UI_State *state, String *string){ - bool32 result = 0; + b32 result = 0; Key_Summary *keys = state->keys; for (i32 key_i = 0; key_i < keys->count; ++key_i){ Key_Event_Data key = get_single_key(keys, key_i); @@ -1105,8 +1134,6 @@ struct File_View{ i32 line_count, line_max; f32 *line_wrap_y; - Text_Effect paste_effect; - Hyper_Link *links; i32 link_count, link_max; }; @@ -1156,24 +1183,24 @@ starts_new_line(u8 character){ inline void file_init_strings(Editing_File *file){ - file->state.source_path = make_fixed_width_string(file->state.source_path_); - file->state.live_name = make_fixed_width_string(file->state.live_name_); - file->state.extension = make_fixed_width_string(file->state.extension_); + file->name.source_path = make_fixed_width_string(file->name.source_path_); + file->name.live_name = make_fixed_width_string(file->name.live_name_); + file->name.extension = make_fixed_width_string(file->name.extension_); } inline void file_set_name(Editing_File *file, char *filename){ - file->state.live_name = make_fixed_width_string(file->state.live_name_); + if (file->name.live_name.str == 0) file_init_strings(file); if (filename[0] == '*'){ - copy(&file->state.live_name, filename); + copy(&file->name.live_name, filename); } else{ String f, ext; f = make_string_slowly(filename); - copy_checked(&file->state.source_path, f); - get_front_of_directory(&file->state.live_name, f); + copy_checked(&file->name.source_path, f); + get_front_of_directory(&file->name.live_name, f); ext = file_extension(f); - copy(&file->state.extension, ext); + copy(&file->name.extension, ext); } } @@ -1477,7 +1504,7 @@ file_create_from_string(System_Functions *system, Mem_Options *mem, file_init_strings(file); file_set_name(file, (char*)filename); - file->settings.base_map_id = mapid_file; + //file->settings.base_map_id = mapid_file; file->state.font_id = font_id; file_synchronize_times(system, file, filename); @@ -1560,6 +1587,12 @@ working_set_get_available_file(Working_Set *working_set){ return result; } +internal i32 +working_set_get_index(Working_Set *working_set, Editing_File *file){ + i32 index = (i32)(file - working_set->files); + return(index); +} + internal void file_close(System_Functions *system, General_Memory *general, Editing_File *file){ if (file->state.still_lexing){ @@ -1606,8 +1639,9 @@ file_get_dummy(Editing_File *file){ } inline void -file_get_loading(Editing_File *file){ - *file = {}; +file_set_to_loading(Editing_File *file){ + file->state = {}; + file->settings = {}; file->state.is_loading = 1; } @@ -2856,11 +2890,13 @@ view_replace_range(System_Functions *system, inline void view_post_paste_effect(File_View *view, i32 ticks, i32 start, i32 size, u32 color){ - view->paste_effect.start = start; - view->paste_effect.end = start + size; - view->paste_effect.color = color; - view->paste_effect.tick_down = ticks; - view->paste_effect.tick_max = ticks; + Editing_File *file = view->file; + + file->state.paste_effect.start = start; + file->state.paste_effect.end = start + size; + file->state.paste_effect.color = color; + file->state.paste_effect.tick_down = ticks; + file->state.paste_effect.tick_max = ticks; } internal void @@ -3149,8 +3185,8 @@ working_set_lookup_file(Working_Set *working_set, String string){ i32 end = working_set->file_index_count; file = working_set->files; for (file_i = 0; file_i < end; ++file_i, ++file){ - if (file->state.live_name.str && - (string.size == 0 || has_substr(file->state.live_name, string))){ + if (file->name.live_name.str && + (string.size == 0 || has_substr(file->name.live_name, string))){ break; } } @@ -3803,6 +3839,10 @@ step_file_view(System_Functions *system, View *view_, i32_Rect rect, i32 result = 0; File_View *view = (File_View*)view_; Editing_File *file = view->file; + + if (file->state.is_loading){ + return result; + } f32 line_height = (f32)view->font_height; f32 cursor_y = view_get_cursor_y(view); @@ -3855,14 +3895,14 @@ step_file_view(System_Functions *system, View *view_, i32_Rect rect, if (target_y < -extra_top) target_y = -extra_top; view->target_y = target_y; - real32 cursor_x = view_get_cursor_x(view); - real32 target_x = view->target_x; - real32 max_x = view_compute_width(view); + f32 cursor_x = view_get_cursor_x(view); + f32 target_x = view->target_x; + f32 max_x = view_compute_width(view); if (cursor_x < target_x){ - target_x = (real32)Max(0, cursor_x - max_x/2); + target_x = (f32)Max(0, cursor_x - max_x/2); } else if (cursor_x >= target_x + max_x){ - target_x = (real32)(cursor_x - max_x/2); + target_x = (f32)(cursor_x - max_x/2); } view->target_x = target_x; @@ -3873,15 +3913,15 @@ step_file_view(System_Functions *system, View *view_, i32_Rect rect, if (smooth_camera_step(&view->target_x, &view->scroll_x, &view->vel_x, 40.f, 1.f/4.f)){ result = 1; } - if (view->paste_effect.tick_down > 0){ - --view->paste_effect.tick_down; + if (file->state.paste_effect.tick_down > 0){ + --file->state.paste_effect.tick_down; result = 1; } if (is_active && user_input->mouse.press_l){ - real32 max_y = view_compute_height(view); - real32 rx = (real32)(user_input->mouse.mx - rect.x0); - real32 ry = (real32)(user_input->mouse.my - rect.y0 - line_height - 2); + f32 max_y = view_compute_height(view); + f32 rx = (f32)(user_input->mouse.mx - rect.x0); + f32 ry = (f32)(user_input->mouse.my - rect.y0 - line_height - 2); if (ry >= extra_top){ view_set_widget(view, FWIDG_NONE); @@ -4027,31 +4067,75 @@ buffer_needs_save(Editing_File *file){ return(result); } +internal void +draw_file_setup_bar(Style *style, i32 line_height, Interactive_Bar *bar, i32_Rect *rect){ + bar->style = style->main.file_info_style; + bar->font_id = style->font_id; + bar->pos_x = (f32)rect->x0; + bar->pos_y = (f32)rect->y0; + bar->text_shift_y = 2; + bar->text_shift_x = 0; + bar->rect = *rect; + bar->rect.y1 = bar->rect.y0 + line_height + 2; + rect->y0 += line_height + 2; +} + +internal void +draw_file_bar(File_View *view, Interactive_Bar *bar, Render_Target *target){ + Editing_File *file = view->file; + + u32 back_color = bar->style.bar_color; + u32 base_color = bar->style.base_color; + u32 pop2_color = bar->style.pop2_color; + + draw_rectangle(target, bar->rect, back_color); + intbar_draw_string(target, bar, file->name.live_name, base_color); + intbar_draw_string(target, bar, make_lit_string(" - "), base_color); + + if (file->state.is_loading){ + intbar_draw_string(target, bar, make_lit_string(" loading"), base_color); + } + else{ + char line_number_space[30]; + String line_number = make_string(line_number_space, 0, 30); + append(&line_number, "L#"); + append_int_to_str(view->cursor.line, &line_number); + + intbar_draw_string(target, bar, line_number, base_color); + + if (file){ + switch (buffer_get_sync(file)){ + case SYNC_BEHIND_OS: + { + persist String out_of_sync = make_lit_string(" !"); + intbar_draw_string(target, bar, out_of_sync, pop2_color); + }break; + + case SYNC_UNSAVED: + { + persist String out_of_sync = make_lit_string(" *"); + intbar_draw_string(target, bar, out_of_sync, pop2_color); + }break; + } + } + } +} + internal i32 -draw_file_loaded(View *view_, i32_Rect rect, b32 is_active, Render_Target *target){ - File_View *view = (File_View*)view_; +draw_file_loaded(File_View *view, i32_Rect rect, b32 is_active, Render_Target *target){ Editing_File *file = view->file; Style *style = view->style; - i32 line_height = view->font_height; - - Interactive_Bar bar; - bar.style = style->main.file_info_style; - bar.font_id = style->font_id; - bar.pos_x = (f32)rect.x0; - bar.pos_y = (f32)rect.y0; - bar.text_shift_y = 2; - bar.text_shift_x = 0; - bar.rect = rect; - bar.rect.y1 = bar.rect.y0 + line_height + 2; - rect.y0 += line_height + 2; + Interactive_Bar bar; + draw_file_setup_bar(style, line_height, &bar, &rect); + #if BUFFER_EXPERIMENT_SCALPEL <= 3 i32 max_x = rect.x1 - rect.x0; i32 max_y = rect.y1 - rect.y0 + line_height; Assert(file && !file->state.is_dummy && buffer_good(&file->state.buffer)); - + b32 tokens_use = 0; Cpp_Token_Stack token_stack = {}; if (file){ @@ -4070,7 +4154,7 @@ draw_file_loaded(View *view_, i32_Rect rect, b32 is_active, Render_Target *targe } } - Partition *part = &view_->mem->part; + Partition *part = &view->view_base.mem->part; Temp_Memory temp = begin_temp_memory(part); @@ -4169,10 +4253,11 @@ draw_file_loaded(View *view_, i32_Rect rect, b32 is_active, Render_Target *targe u32 fade_color = 0xFFFF00FF; f32 fade_amount = 0.f; - if (view->paste_effect.tick_down > 0 && - view->paste_effect.start <= i && i < view->paste_effect.end){ - fade_color = view->paste_effect.color; - fade_amount = (real32)(view->paste_effect.tick_down) / view->paste_effect.tick_max; + if (file->state.paste_effect.tick_down > 0 && + file->state.paste_effect.start <= ind && + ind < file->state.paste_effect.end){ + fade_color = file->state.paste_effect.color; + fade_amount = (f32)(file->state.paste_effect.tick_down) / file->state.paste_effect.tick_max; } char_color = color_blend(char_color, fade_amount, fade_color); @@ -4261,39 +4346,19 @@ draw_file_loaded(View *view_, i32_Rect rect, b32 is_active, Render_Target *targe ui_finish_frame(&view->widget.state, &state, &layout, widg_rect, 0, 0); } - { - u32 back_color = bar.style.bar_color; - draw_rectangle(target, bar.rect, back_color); - - u32 base_color = bar.style.base_color; - intbar_draw_string(target, &bar, file->state.live_name, base_color); - intbar_draw_string(target, &bar, make_lit_string(" - "), base_color); - - char line_number_space[30]; - String line_number = make_string(line_number_space, 0, 30); - append(&line_number, "L#"); - append_int_to_str(view->cursor.line, &line_number); - - intbar_draw_string(target, &bar, line_number, base_color); - - if (file){ - switch (buffer_get_sync(file)){ - case SYNC_BEHIND_OS: - { - persist String out_of_sync = make_lit_string(" BEHIND OS"); - intbar_draw_string(target, &bar, out_of_sync, bar.style.pop2_color); - }break; - - case SYNC_UNSAVED: - { - persist String out_of_sync = make_lit_string(" *"); - intbar_draw_string(target, &bar, out_of_sync, bar.style.pop2_color); - }break; - } - } - } + draw_file_bar(view, &bar, target); - return 0; + return(0); +} + +internal i32 +draw_file_loading(File_View *view, i32_Rect rect, b32 is_active, Render_Target *target){ + Interactive_Bar bar; + draw_file_setup_bar(view->style, view->font_height, &bar, &rect); + + draw_file_bar(view, &bar, target); + + return(0); } internal i32 @@ -4304,10 +4369,10 @@ draw_file_view(View *view_, i32_Rect rect, bool32 is_active, if (view->file){ if (view->file->state.is_loading){ - // TODO(allen): draw file loading screen + result = draw_file_loading(view, rect, is_active, target); } else{ - result = draw_file_loaded(view_, rect, is_active, target); + result = draw_file_loaded(view, rect, is_active, target); } } diff --git a/4ed_interactive_view.cpp b/4ed_interactive_view.cpp index fea58350..014f274e 100644 --- a/4ed_interactive_view.cpp +++ b/4ed_interactive_view.cpp @@ -112,13 +112,18 @@ step_draw_int_view(System_Functions *system, Interactive_View *view, b32 new_dir = 0; b32 complete = 0; - + do_label(&state, &layout, view->query, 1.f); + b32 case_sensitive = 0; + switch (view->interaction){ case INTV_SYS_FILE_LIST: - if (do_file_list_box(system, - &state, &layout, view->hot_directory, 0, + { + b32 is_new = (view->action == INTV_NEW); + + if (do_file_list_box(system, &state, + &layout, view->hot_directory, 0, !is_new, case_sensitive, &new_dir, &complete, 0)){ result = 1; } @@ -126,7 +131,7 @@ step_draw_int_view(System_Functions *system, Interactive_View *view, hot_directory_reload(system, view->hot_directory, view->working_set); } - break; + }break; case INTV_LIVE_FILE_LIST: if (do_live_file_list_box(system, &state, &layout, view->working_set, &view->dest, &complete)){ diff --git a/4ed_layout.cpp b/4ed_layout.cpp index 2ef14da0..7cbfab3e 100644 --- a/4ed_layout.cpp +++ b/4ed_layout.cpp @@ -60,7 +60,8 @@ enum View_Type{ VIEW_TYPE_COLOR, VIEW_TYPE_DEBUG, VIEW_TYPE_INTERACTIVE, - VIEW_TYPE_MENU + VIEW_TYPE_MENU, + VIEW_TYPE_CONFIG }; struct Panel; diff --git a/4ed_menu_view.cpp b/4ed_menu_view.cpp index 6d16ed72..aa9de0ec 100644 --- a/4ed_menu_view.cpp +++ b/4ed_menu_view.cpp @@ -29,7 +29,7 @@ view_to_menu_view(View *view){ internal i32 step_draw_menu_view(Menu_View *view, Render_Target *target, i32_Rect rect, - Input_Summary *user_input, bool32 input_stage){ + Input_Summary *user_input, b32 input_stage){ i32 result = 0; UI_State state = @@ -38,14 +38,18 @@ step_draw_menu_view(Menu_View *view, Render_Target *target, i32_Rect rect, UI_Layout layout; begin_layout(&layout, rect); - + i32 id = 0; do_label(&state, &layout, literal("Menu"), 2.f); - if (do_list_option_lit(++id, &state, &layout, "Theme Options")){ + if (do_list_option(++id, &state, &layout, make_lit_string("Theme Options"))){ delayed_action(view->delay, DACT_THEME_OPTIONS, {}, view->view_base.panel); } + + if (do_list_option(++id, &state, &layout, make_lit_string("Keyboard Layout Options"))){ + delayed_action(view->delay, DACT_KEYBOARD_OPTIONS, {}, view->view_base.panel); + } if (ui_finish_frame(&view->state, &state, &layout, rect, 0, 0)){ result = 1; diff --git a/4ed_rendering_helper.cpp b/4ed_rendering_helper.cpp index 7858fc44..91d3ecd0 100644 --- a/4ed_rendering_helper.cpp +++ b/4ed_rendering_helper.cpp @@ -99,6 +99,12 @@ draw_margin(Render_Target *target, i32_Rect outer, i32_Rect inner, u32 color){ draw_rectangle(target, i32R(inner.x1, inner.y0, outer.x1, inner.y1), color); } +inline void +draw_margin(Render_Target *target, i32_Rect outer, i32 width, u32 color){ + i32_Rect inner = get_inner_rect(outer, width); + draw_margin(target, outer, inner, color); +} + inline internal i32 font_predict_size(i32 pt_size){ return pt_size*pt_size*128; diff --git a/vc120.pdb b/vc120.pdb index e32ca26cc30e1addb3bf203386c93ab5a3170f81..fee3ca2b1740359e79bcd3f3f4c886caffd98361 100644 GIT binary patch delta 821 zcmZp8z}oPDb%F{b(?(T(ZjHG|85n*r1T!%J0gO(7@?kWCLNL?j815x3%nTMkHVX>8 z=bx+~z{mW+p&icIWUxUAXtEbfro*SL5P7-h#6?650GEL#=uYlWb-j_2pE7Y zVqj(n5oFkW-$|2~@z-X~0A>Nj2TouKh8gk<43a=*0V@!*FffP$*+3?Pz+~M7`RP6Z zj2xRo5?%<4z5dJ0ka~!TVSXSpLzoN$7&8cLb}U)Py{W;+lzZ)Q28L6M85w4lF>Uq^ zUCA}+01s=JAOpjS$$|%jc_V;Eg0KY0rp<;2xJC4^83;01)SQ{&(|jfdj|)r;0bCHv zz!pv8-t@qS6~m%UA8hzojTl(OxF>)7COrAV51z?qeu%K}1MQw3sLNoAHZgx-_%H+UdSGB7^Y5YYMS)=<$G|8CbT9)bjB^u9k~88<^NLgRiZe?x%Tj^n z!Q@qN$ScA0yTcU}Bo>vRnDS8yswfob#PZCXl;p&slz6ah3@8p32Rdl-jQ=H64^?1H zsY(GYPXML_c834|f%X7NP+DSO$N+Lcm;=Zz*lwu6c$=SCwFZpW`5Aw0=X7AiliGj@ Zl|clEd8X?IFv?H%N#NKX62Q1d9sp3Kw%z~$ delta 426 zcmZp8z}oPDb%F{b<3?3}ZVgvv28JID-xwKy07fT3`7oM6;Tz-T815x3%nvMDHVX>8 z=bx+~z{kws@EgwAWUxVK^M;@Xrp*SfH@Fx@H**Fs3n*@I0vXG|U?a!CAPJ;XSQ!{x zSQr>Yfovd?foHOAg8X!!07j0@Aqg*pHwTn#;GP&DvZ=wxbhA(B7OqJLcvyo485k-i z3my>W^#N)DVF{2)n+*?ei@-HJ@L>gO*!01MZ}I^PpUDL+9GfTD6);X=B+dk&O{)Ar zn^=G@WoP*RALvLR2@D$`umN&Fm;=am*>0%7c$=SCwFZpW`58sGb2>2M2@N)&xgtO; UFkLr*QGT*d0>}1{0LC@)0N!6=vH$=8 diff --git a/win32_4ed.cpp b/win32_4ed.cpp index 8d2928e5..5e3346e9 100644 --- a/win32_4ed.cpp +++ b/win32_4ed.cpp @@ -112,6 +112,7 @@ struct Win32_Vars{ Key_Codes key_codes; Win32_Input_Chunk input_chunk; + b32 lctrl_lalt_is_altgr; HCURSOR cursor_ibeam; HCURSOR cursor_arrow; @@ -156,8 +157,6 @@ struct Win32_Vars{ Win32_Font_Load_Parameters free_font_param; Partition fnt_part; - char **argv; - i32 argc; }; globalvar Win32_Vars win32vars; @@ -1031,7 +1030,54 @@ Win32Callback(HWND hwnd, UINT uMsg, switch (wParam){ case VK_CONTROL:case VK_LCONTROL:case VK_RCONTROL: case VK_MENU:case VK_LMENU:case VK_RMENU: - case VK_SHIFT:case VK_LSHIFT:case VK_RSHIFT: break; + case VK_SHIFT:case VK_LSHIFT:case VK_RSHIFT: + { + Control_Keys *controls = 0; + b8 *control_keys = 0; + controls = &win32vars.input_chunk.pers.controls; + control_keys = win32vars.input_chunk.pers.control_keys; + + system_acquire_lock(INPUT_LOCK); + + b8 down = ((lParam & Bit_31)?(0):(1)); + b8 is_right = ((lParam & Bit_24)?(1):(0)); + + if (wParam != 255){ + switch (wParam){ + case VK_SHIFT: + { + control_keys[CONTROL_KEY_SHIFT] = down; + }break; + + case VK_CONTROL: + { + if (is_right) controls->r_ctrl = down; + else controls->l_ctrl = down; + }break; + + case VK_MENU: + { + if (is_right) controls->r_alt = down; + else controls->l_alt = down; + }break; + } + + b8 ctrl, alt; + ctrl = (controls->r_ctrl || (controls->l_ctrl && !controls->r_alt)); + alt = (controls->l_alt || (controls->r_alt && !controls->l_ctrl)); + + if (win32vars.lctrl_lalt_is_altgr){ + if (controls->l_alt && controls->l_ctrl){ + ctrl = 0; + alt = 0; + } + } + + control_keys[CONTROL_KEY_CONTROL] = ctrl; + control_keys[CONTROL_KEY_ALT] = alt; + } + system_release_lock(INPUT_LOCK); + }break; default: b8 previous_state, current_state; @@ -1109,56 +1155,7 @@ Win32Callback(HWND hwnd, UINT uMsg, }break; case WM_INPUT: - { - char buffer[sizeof(RAWINPUT)] = {}; - UINT size = sizeof(RAWINPUT); - GetRawInputData((HRAWINPUT)(lParam), RID_INPUT, buffer, &size, sizeof(RAWINPUTHEADER)); - - system_acquire_lock(INPUT_LOCK); - Control_Keys *controls = 0; - b8 *control_keys = 0; - controls = &win32vars.input_chunk.pers.controls; - control_keys = win32vars.input_chunk.pers.control_keys; - - RAWINPUT *rawinput = (RAWINPUT*)(buffer); - if (rawinput->header.dwType == RIM_TYPEKEYBOARD){ - RAWKEYBOARD *raw = &rawinput->data.keyboard; - UINT vk = raw->VKey; - UINT flags = raw->Flags; - b8 down = !(flags & 1); - UINT is_left = ((flags & RI_KEY_E0) != 0); - - if (vk != 255){ - switch (vk){ - case VK_SHIFT: - { - control_keys[CONTROL_KEY_SHIFT] = down; - }break; - - case VK_CONTROL: - { - if (is_left) controls->l_ctrl = down; - else controls->r_ctrl = down; - }break; - - case VK_MENU: - { - if (is_left) controls->l_alt = down; - else controls->r_alt = down; - }break; - } - - b8 ctrl, alt; - ctrl = (controls->r_ctrl || (controls->l_ctrl && !controls->r_alt)); - alt = (controls->l_alt || (controls->r_alt && !controls->l_ctrl)); - control_keys[CONTROL_KEY_CONTROL] = ctrl; - control_keys[CONTROL_KEY_ALT] = alt; - } - } - system_release_lock(INPUT_LOCK); - - result = DefWindowProcA(hwnd, uMsg, wParam, lParam); - }break; + case WM_MOUSEMOVE: { @@ -1382,24 +1379,29 @@ UpdateLoop(LPVOID param){ mouse.right_button_released = input_chunk.trans.mouse_r_release; mouse.wheel = input_chunk.trans.mouse_wheel; - + mouse.x = input_chunk.pers.mouse_x; mouse.y = input_chunk.pers.mouse_y; - - result = - win32vars.app.step(win32vars.system, - &win32vars.key_codes, - &input_data, - &mouse, - &win32vars.target, - &memory_vars, - &exchange_vars, - win32vars.clipboard_contents, - 1, win32vars.first, redraw); - + + result.mouse_cursor_type = APP_MOUSE_CURSOR_DEFAULT; + result.redraw = redraw; + result.lctrl_lalt_is_altgr = win32vars.lctrl_lalt_is_altgr; + + win32vars.app.step(win32vars.system, + &win32vars.key_codes, + &input_data, + &mouse, + &win32vars.target, + &memory_vars, + &exchange_vars, + win32vars.clipboard_contents, + 1, win32vars.first, redraw, + &result); + ProfileStart(OS_frame_out); Win32SetCursorFromUpdate(result.mouse_cursor_type); + win32vars.lctrl_lalt_is_altgr = result.lctrl_lalt_is_altgr; if (result.redraw) Win32RedrawFromUpdate(); @@ -1484,9 +1486,6 @@ WinMain(HINSTANCE hInstance, int nCmdShow){ win32vars = {}; exchange_vars = {}; - - win32vars.argv = __argv; - win32vars.argc = __argc; #if FRED_INTERNAL win32vars.internal_bubble.next = &win32vars.internal_bubble; @@ -1504,6 +1503,55 @@ WinMain(HINSTANCE hInstance, win32vars.system = system; Win32LoadSystemCode(); + LPVOID base; +#if FRED_INTERNAL + base = (LPVOID)Tbytes(1); +#else + base = (LPVOID)0; +#endif + + memory_vars.vars_memory_size = Mbytes(2); + memory_vars.vars_memory = VirtualAlloc(base, memory_vars.vars_memory_size, + MEM_COMMIT | MEM_RESERVE, + PAGE_READWRITE); + +#if FRED_INTERNAL + base = (LPVOID)Tbytes(2); +#else + base = (LPVOID)0; +#endif + memory_vars.target_memory_size = Mbytes(512); + memory_vars.target_memory = VirtualAlloc(base, memory_vars.target_memory_size, + MEM_COMMIT | MEM_RESERVE, + PAGE_READWRITE); + + if (!memory_vars.vars_memory){ + return 4; + } + + DWORD required = GetCurrentDirectory(0, 0); + required += 1; + required *= 4; + char *current_directory_mem = (char*)Win32GetMemory(required); + DWORD written = GetCurrentDirectory(required, current_directory_mem); + + String current_directory = make_string(current_directory_mem, written, required); + terminate_with_null(¤t_directory); + + Command_Line_Parameters clparams; + clparams.argv = __argv; + clparams.argc = __argc; + + i32 output_size = + win32vars.app.read_command_line(system, + &memory_vars, + current_directory, + clparams); + if (output_size > 0){ + + } + if (output_size != 0) return 0; + LARGE_INTEGER lpf; QueryPerformanceFrequency(&lpf); win32vars.performance_frequency = lpf.QuadPart; @@ -1611,13 +1659,15 @@ WinMain(HINSTANCE hInstance, win32vars.window_hdc = hdc; GetClientRect(window_handle, &window_rect); - + +#if 0 RAWINPUTDEVICE device; device.usUsagePage = 0x1; device.usUsage = 0x6; device.dwFlags = 0; device.hwndTarget = window_handle; RegisterRawInputDevices(&device, 1, sizeof(device)); +#endif static PIXELFORMATDESCRIPTOR pfd = { sizeof(PIXELFORMATDESCRIPTOR), @@ -1652,32 +1702,6 @@ WinMain(HINSTANCE hInstance, Win32Resize(window_rect.right - window_rect.left, window_rect.bottom - window_rect.top); - LPVOID base; -#if FRED_INTERNAL - base = (LPVOID)Tbytes(1); -#else - base = (LPVOID)0; -#endif - - memory_vars.vars_memory_size = Mbytes(2); - memory_vars.vars_memory = VirtualAlloc(base, memory_vars.vars_memory_size, - MEM_COMMIT | MEM_RESERVE, - PAGE_READWRITE); - -#if FRED_INTERNAL - base = (LPVOID)Tbytes(2); -#else - base = (LPVOID)0; -#endif - memory_vars.target_memory_size = Mbytes(512); - memory_vars.target_memory = VirtualAlloc(base, memory_vars.target_memory_size, - MEM_COMMIT | MEM_RESERVE, - PAGE_READWRITE); - - if (!memory_vars.vars_memory){ - return 4; - } - win32vars.clipboard_sequence = GetClipboardSequenceNumber(); if (win32vars.clipboard_sequence == 0){ @@ -1728,7 +1752,7 @@ WinMain(HINSTANCE hInstance, exchange_vars.file.active = {}; exchange_vars.file.active.next = &exchange_vars.file.active; exchange_vars.file.active.prev = &exchange_vars.file.active; - + exchange_vars.file.free_list = {}; exchange_vars.file.free_list.next = &exchange_vars.file.free_list; exchange_vars.file.free_list.prev = &exchange_vars.file.free_list; @@ -1746,15 +1770,6 @@ WinMain(HINSTANCE hInstance, filename_space += FileNameMax; } - DWORD required = GetCurrentDirectory(0, 0); - required += 1; - required *= 4; - char *current_directory_mem = (char*)Win32GetMemory(required); - DWORD written = GetCurrentDirectory(required, current_directory_mem); - - String current_directory = make_string(current_directory_mem, written, required); - terminate_with_null(¤t_directory); - win32vars.free_font_param.next = &win32vars.free_font_param; win32vars.free_font_param.prev = &win32vars.free_font_param; @@ -1765,12 +1780,10 @@ WinMain(HINSTANCE hInstance, fnt__insert(&win32vars.free_font_param, win32vars.fnt_params + i); } - if (!win32vars.app.init(win32vars.system, &win32vars.target, - &memory_vars, &exchange_vars, &win32vars.key_codes, - win32vars.clipboard_contents, current_directory, - win32vars.custom_api)){ - return(5); - } + win32vars.app.init(win32vars.system, &win32vars.target, + &memory_vars, &exchange_vars, &win32vars.key_codes, + win32vars.clipboard_contents, current_directory, + win32vars.custom_api); win32vars.input_chunk.pers.keep_playing = 1; win32vars.first = 1;