diff --git a/4coder_API/types.h b/4coder_API/types.h index 3a01b10e..05e9eb5f 100644 --- a/4coder_API/types.h +++ b/4coder_API/types.h @@ -63,6 +63,8 @@ ENUM(uint64_t, Command_ID){ cmdid_interactive_new, /* DOC(cmdid_interactive_open begins an interactive dialogue to open a file into a buffer.) */ cmdid_interactive_open, + /* DOC(cmdid_interactive_open_or_new begins an interactive dialogue to open a file into a buffer, if the name specified does not match any existing buffer, a new buffer is created instead.) */ + cmdid_interactive_open_or_new, /* DOC(cmdid_save_as does not currently work and is likely to be removed rather that fixed.) */ cmdid_save_as, /* DOC(cmdid_interactive_switch_buffer begins an interactive dialogue to choose an open buffer to swap into the active view.) */ @@ -187,14 +189,14 @@ ENUM(int32_t, View_Setting_ID){ /* DOC(ViewSetting_Null is not a valid setting, it is reserved to detect errors.) */ ViewSetting_Null, - /* DOC(The ViewSetting_ShowWhitespace setting determines whether the view highlights - whitespace in a file. Whenever the view switches to a new buffer this setting is turned off.) */ + /* DOC(The ViewSetting_ShowWhitespace setting determines whether the view highlights whitespace in a file. Whenever the view switches to a new buffer this setting is turned off.) */ ViewSetting_ShowWhitespace, - /* DOC(The ViewSetting_ShowScrollbar setting determines whether a scroll bar is - attached to a view in it's scrollable section.) */ + /* DOC(The ViewSetting_ShowScrollbar setting determines whether a scroll bar is attached to a view in it's scrollable section.) */ ViewSetting_ShowScrollbar, + /* DOC(The ViewSetting_ShowFileBar settings determines whether to show the file bar.) */ + ViewSetting_ShowFileBar, }; /* DOC(A Buffer_Create_Flag field specifies how a buffer should be created.) */ @@ -230,18 +232,13 @@ ENUM(uint32_t, Buffer_Kill_Flag){ /* DOC(An Access_Flag field specifies what sort of permission you grant to an access call. An access call is usually one the returns a summary struct. If a 4coder object has a particular protection flag set and the corresponding bit is not set in the access field, that 4coder object is hidden. On the other hand if a protection flag is set in the access parameter and the object does not have that protection flag, the object is still returned from the access call.) */ ENUM(uint32_t, Access_Flag){ - /* DOC(AccessOpen does not include any bits, it indicates that the access should - only return objects that have no protection flags set.) */ + /* DOC(AccessOpen does not include any bits, it indicates that the access should only return objects that have no protection flags set.) */ AccessOpen = 0x0, - /* DOC(AccessProtected is set on buffers and views that are "read only" such as - the output from an app->exec_system_command call into *build*. This is to prevent - the user from accidentally editing output that they might prefer to keep in tact.) */ + /* DOC(AccessProtected is set on buffers and views that are "read only" such as the output from an exec_system_command call into *build*. This is to prevent the user from accidentally editing output that they might prefer to keep in tact.) */ AccessProtected = 0x1, - /* DOC(AccessHidden is set on any view that is not currently showing it's file, for - instance because it is navigating the file system to open a file.) */ + /* DOC(AccessHidden is set on any view that is not currently showing it's file, for instance because it is navigating the file system to open a file.) */ AccessHidden = 0x2, - /* DOC(AccessAll is a catchall access for cases where an access call should always - return an object no matter what it's protection flags are.) */ + /* DOC(AccessAll is a catchall access for cases where an access call should always return an object no matter what it's protection flags are.) */ AccessAll = 0xFF }; diff --git a/4coder_base_commands.cpp b/4coder_base_commands.cpp index d85c0616..3f11ba38 100644 --- a/4coder_base_commands.cpp +++ b/4coder_base_commands.cpp @@ -473,15 +473,25 @@ CUSTOM_COMMAND_SIG(open_panel_hsplit){ // CUSTOM_COMMAND_SIG(show_scrollbar){ - View_Summary view = get_active_view(app, AccessProtected); + View_Summary view = get_active_view(app, AccessAll); view_set_setting(app, &view, ViewSetting_ShowScrollbar, true); } CUSTOM_COMMAND_SIG(hide_scrollbar){ - View_Summary view = get_active_view(app, AccessProtected); + View_Summary view = get_active_view(app, AccessAll); view_set_setting(app, &view, ViewSetting_ShowScrollbar, false); } +CUSTOM_COMMAND_SIG(show_file_bar){ + View_Summary view = get_active_view(app, AccessAll); + view_set_setting(app, &view, ViewSetting_ShowFileBar, true); +} + +CUSTOM_COMMAND_SIG(hide_file_bar){ + View_Summary view = get_active_view(app, AccessAll); + view_set_setting(app, &view, ViewSetting_ShowFileBar, false); +} + //toggle_fullscreen can be used as a command CUSTOM_COMMAND_SIG(toggle_line_wrap){ @@ -835,6 +845,10 @@ CUSTOM_COMMAND_SIG(interactive_open){ exec_command(app, cmdid_interactive_open); } +CUSTOM_COMMAND_SIG(interactive_open_or_new){ + exec_command(app, cmdid_interactive_open_or_new); +} + CUSTOM_COMMAND_SIG(save_as){ exec_command(app, cmdid_save_as); } diff --git a/4coder_default_bindings.cpp b/4coder_default_bindings.cpp index 9d34b346..0836768e 100644 --- a/4coder_default_bindings.cpp +++ b/4coder_default_bindings.cpp @@ -22,7 +22,7 @@ default_keys(Bind_Helper *context){ bind(context, '<', MDFR_CTRL, change_active_panel_backwards); bind(context, 'n', MDFR_CTRL, interactive_new); - bind(context, 'o', MDFR_CTRL, interactive_open); + bind(context, 'o', MDFR_CTRL, interactive_open_or_new); bind(context, 'o', MDFR_ALT, open_in_other); bind(context, 'k', MDFR_CTRL, interactive_kill_buffer); bind(context, 'i', MDFR_CTRL, interactive_switch_buffer); diff --git a/4coder_default_framework.h b/4coder_default_framework.h index d039ca8e..c631ae27 100644 --- a/4coder_default_framework.h +++ b/4coder_default_framework.h @@ -621,6 +621,8 @@ static String user_name = make_fixed_width_string(user_name_space); static Extension_List treat_as_code_exts = {0}; +static bool32 automatically_load_project = false; + static bool32 get_current_name(char **name_out, int32_t *len_out){ bool32 result = false; @@ -748,6 +750,8 @@ process_config_file(Application_Links *app){ set_extensions(&treat_as_code_exts, str); } } + + config_bool_var(item, "automatically_load_project", 0, &automatically_load_project); } } adjust_all_buffer_wrap_widths(app, new_wrap_width, new_min_base_width); @@ -780,8 +784,11 @@ init_memory(Application_Links *app){ general_memory_open(&global_general, general_mem, general_size); } +static bool32 default_use_scrollbars = false; +static bool32 default_use_file_bars = true; + static void -default_4coder_initialize(Application_Links *app){ +default_4coder_initialize(Application_Links *app, bool32 use_scrollbars, bool32 use_file_bars){ init_memory(app); process_config_file(app); @@ -790,28 +797,48 @@ default_4coder_initialize(Application_Links *app){ change_theme(app, theme.str, theme.size); change_font(app, font.str, font.size, 1); + + default_use_scrollbars = use_scrollbars; + default_use_file_bars = use_file_bars; +} + +static void +default_4coder_initialize(Application_Links *app){ + default_4coder_initialize(app, false, true); } static void default_4coder_side_by_side_panels(Application_Links *app){ - exec_command(app, open_panel_vsplit); - exec_command(app, hide_scrollbar); - exec_command(app, change_active_panel); - exec_command(app, hide_scrollbar); + open_panel_vsplit(app); + if (!default_use_scrollbars){ + hide_scrollbar(app); + } + if (!default_use_file_bars){ + hide_file_bar(app); + } + change_active_panel(app); + if (!default_use_scrollbars){ + hide_scrollbar(app); + } + if (!default_use_file_bars){ + hide_file_bar(app); + } } static void default_4coder_one_panel(Application_Links *app){ - exec_command(app, hide_scrollbar); + if (!default_use_scrollbars){ + hide_scrollbar(app); + } + if (!default_use_file_bars){ + hide_file_bar(app); + } } static void default_4coder_full_width_bottom_side_by_side_panels(Application_Links *app){ open_special_note_view(app); - exec_command(app, open_panel_vsplit); - exec_command(app, hide_scrollbar); - exec_command(app, change_active_panel); - exec_command(app, hide_scrollbar); + default_4coder_side_by_side_panels(app); } #endif diff --git a/4coder_default_hooks.cpp b/4coder_default_hooks.cpp index c26a18ff..e0b6afbd 100644 --- a/4coder_default_hooks.cpp +++ b/4coder_default_hooks.cpp @@ -11,11 +11,16 @@ TYPE: 'internal-for-default-system' #include "4coder_default_framework.h" #include "4coder_helper/4coder_bind_helper.h" +#include "4coder_project_commands.cpp" HOOK_SIG(default_start){ default_4coder_initialize(app); default_4coder_side_by_side_panels(app); + if (automatically_load_project){ + load_project(app); + } + // no meaning for return return(0); } diff --git a/4coder_helper/4coder_long_seek.h b/4coder_helper/4coder_long_seek.h index e625c903..38bb4d42 100644 --- a/4coder_helper/4coder_long_seek.h +++ b/4coder_helper/4coder_long_seek.h @@ -317,7 +317,7 @@ buffer_seek_alphanumeric_right(Application_Links *app, Buffer_Summary *buffer, i bool32 still_looping = 1; do{ for (; pos < stream.end; ++pos){ - if (char_is_alpha_numeric_true(stream.data[pos])){ + if (char_is_alpha_numeric_true_utf8(stream.data[pos])){ goto double_break1; } } @@ -328,7 +328,7 @@ buffer_seek_alphanumeric_right(Application_Links *app, Buffer_Summary *buffer, i still_looping = 1; do{ for (; pos < stream.end; ++pos){ - if (!char_is_alpha_numeric_true(stream.data[pos])){ + if (!char_is_alpha_numeric_true_utf8(stream.data[pos])){ goto double_break2; } } @@ -347,13 +347,12 @@ buffer_seek_alphanumeric_left(Application_Links *app, Buffer_Summary *buffer, in --pos; if (pos > 0){ - if (init_stream_chunk(&stream, app, buffer, - pos, data_chunk, sizeof(data_chunk))){ + if (init_stream_chunk(&stream, app, buffer, pos, data_chunk, sizeof(data_chunk))){ bool32 still_looping = 1; do{ for (; pos >= stream.start; --pos){ - if (char_is_alpha_numeric_true(stream.data[pos])){ + if (char_is_alpha_numeric_true_utf8(stream.data[pos])){ goto double_break1; } } @@ -364,7 +363,7 @@ buffer_seek_alphanumeric_left(Application_Links *app, Buffer_Summary *buffer, in still_looping = 1; do{ for (; pos >= stream.start; --pos){ - if (!char_is_alpha_numeric_true(stream.data[pos])){ + if (!char_is_alpha_numeric_true_utf8(stream.data[pos])){ ++pos; goto double_break2; } @@ -389,20 +388,18 @@ buffer_seek_range_camel_right(Application_Links *app, Buffer_Summary *buffer, in ++pos; if (pos < an_pos){ stream.max_end = an_pos; - if (init_stream_chunk(&stream, app, buffer, - pos, data_chunk, sizeof(data_chunk))){ + if (init_stream_chunk(&stream, app, buffer, pos, data_chunk, sizeof(data_chunk))){ - char c = 0, pc = stream.data[pos]; + uint8_t c = 0; ++pos; bool32 still_looping = 1; do{ for (; pos < stream.end; ++pos){ c = stream.data[pos]; - if (char_is_upper(c) && char_is_lower(pc)){ + if (char_is_upper(c)){ goto double_break1; } - pc = c; } still_looping = forward_stream_chunk(&stream); }while(still_looping); @@ -426,16 +423,15 @@ buffer_seek_range_camel_left(Application_Links *app, Buffer_Summary *buffer, int stream.min_start = an_pos+1; if (init_stream_chunk(&stream, app, buffer, pos, data_chunk, sizeof(data_chunk))){ - char c = 0, pc = stream.data[pos]; + char c = 0; bool32 still_looping = 1; do{ for (; pos >= stream.start; --pos){ c = stream.data[pos]; - if (char_is_upper(c) && char_is_lower(pc)){ + if (char_is_upper(c)){ goto double_break1; } - pc = c; } still_looping = backward_stream_chunk(&stream); }while(still_looping); diff --git a/4coder_lib/4coder_string.h b/4coder_lib/4coder_string.h index c126ca17..7654841b 100644 --- a/4coder_lib/4coder_string.h +++ b/4coder_lib/4coder_string.h @@ -1,5 +1,5 @@ /* -4coder_string.h - Version 1.0.66 +4coder_string.h - Version 1.0.72 no warranty implied; use at your own risk This software is in the public domain. Where that dedication is not @@ -70,16 +70,24 @@ static String null_string = {0}; FSTRING_INLINE b32_4tech char_is_slash(char c); FSTRING_INLINE b32_4tech char_is_upper(char c); +FSTRING_INLINE b32_4tech char_is_upper_utf8(char c); FSTRING_INLINE b32_4tech char_is_lower(char c); +FSTRING_INLINE b32_4tech char_is_lower_utf8(u8_4tech c); FSTRING_INLINE char char_to_upper(char c); FSTRING_INLINE char char_to_lower(char c); FSTRING_INLINE b32_4tech char_is_whitespace(char c); FSTRING_INLINE b32_4tech char_is_alpha_numeric(char c); +FSTRING_INLINE b32_4tech char_is_alpha_numeric_utf8(u8_4tech c); FSTRING_INLINE b32_4tech char_is_alpha_numeric_true(char c); +FSTRING_INLINE b32_4tech char_is_alpha_numeric_true_utf8(u8_4tech c); FSTRING_INLINE b32_4tech char_is_alpha(char c); +FSTRING_INLINE b32_4tech char_is_alpha_utf8(u8_4tech c); FSTRING_INLINE b32_4tech char_is_alpha_true(char c); +FSTRING_INLINE b32_4tech char_is_alpha_true_utf8(u8_4tech c); FSTRING_INLINE b32_4tech char_is_hex(char c); +FSTRING_INLINE b32_4tech char_is_hex_utf8(u8_4tech c); FSTRING_INLINE b32_4tech char_is_numeric(char c); +FSTRING_INLINE b32_4tech char_is_numeric_utf8(u8_4tech c); FSTRING_INLINE String make_string_cap(void *str, i32_4tech size, i32_4tech mem_size); FSTRING_INLINE String make_string(void *str, i32_4tech size); #ifndef make_lit_string @@ -300,6 +308,14 @@ char_is_upper(char c) } #endif +#if !defined(FSTRING_GUARD) + FSTRING_INLINE b32_4tech +char_is_upper_utf8(char c) +{ + return (c >= 'A' && c <= 'Z' || c >= 128); +} +#endif + #if !defined(FSTRING_GUARD) FSTRING_INLINE b32_4tech char_is_lower(char c) @@ -308,6 +324,14 @@ char_is_lower(char c) } #endif +#if !defined(FSTRING_GUARD) + FSTRING_INLINE b32_4tech +char_is_lower_utf8(u8_4tech c) +{ + return (c >= 'a' && c <= 'z' || c >= 128); +} +#endif + #if !defined(FSTRING_GUARD) FSTRING_INLINE char char_to_upper(char c) @@ -340,6 +364,14 @@ char_is_alpha_numeric(char c) } #endif +#if !defined(FSTRING_GUARD) + FSTRING_INLINE b32_4tech +char_is_alpha_numeric_utf8(u8_4tech c) +{ + return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c >= '0' && c <= '9' || c == '_' || c >= 128); +} +#endif + #if !defined(FSTRING_GUARD) FSTRING_INLINE b32_4tech char_is_alpha_numeric_true(char c) @@ -348,6 +380,14 @@ char_is_alpha_numeric_true(char c) } #endif +#if !defined(FSTRING_GUARD) + FSTRING_INLINE b32_4tech +char_is_alpha_numeric_true_utf8(u8_4tech c) +{ + return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c >= '0' && c <= '9' || c >= 128); +} +#endif + #if !defined(FSTRING_GUARD) FSTRING_INLINE b32_4tech char_is_alpha(char c) @@ -356,6 +396,14 @@ char_is_alpha(char c) } #endif +#if !defined(FSTRING_GUARD) + FSTRING_INLINE b32_4tech +char_is_alpha_utf8(u8_4tech c) +{ + return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c == '_' || c >= 128); +} +#endif + #if !defined(FSTRING_GUARD) FSTRING_INLINE b32_4tech char_is_alpha_true(char c) @@ -364,6 +412,14 @@ char_is_alpha_true(char c) } #endif +#if !defined(FSTRING_GUARD) + FSTRING_INLINE b32_4tech +char_is_alpha_true_utf8(u8_4tech c) +{ + return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c >= 128); +} +#endif + #if !defined(FSTRING_GUARD) FSTRING_INLINE b32_4tech char_is_hex(char c) @@ -372,6 +428,14 @@ char_is_hex(char c) } #endif +#if !defined(FSTRING_GUARD) + FSTRING_INLINE b32_4tech +char_is_hex_utf8(u8_4tech c) +{ + return (c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f' || c >= 128); +} +#endif + #if !defined(FSTRING_GUARD) FSTRING_INLINE b32_4tech char_is_numeric(char c) @@ -380,6 +444,14 @@ char_is_numeric(char c) } #endif +#if !defined(FSTRING_GUARD) + FSTRING_INLINE b32_4tech +char_is_numeric_utf8(u8_4tech c) +{ + return (c >= '0' && c <= '9' || c >= 128); +} +#endif + // // String Making Functions diff --git a/4coder_project_commands.cpp b/4coder_project_commands.cpp index 8a7c2459..073dd94c 100644 --- a/4coder_project_commands.cpp +++ b/4coder_project_commands.cpp @@ -154,12 +154,26 @@ open_all_files_with_extension(Application_Links *app, Partition *scratch_part, c } // NOTE(allen|a4.0.14): open_all_code and close_all_code now use the extensions set in the loaded project. If there is no project loaded the extensions ".cpp.hpp.c.h.cc" are used. +static void +open_all_code(Application_Links *app, String dir){ + int32_t extension_count = 0; + char **extension_list = get_current_project_extensions(&extension_count); + open_all_files_with_extension_internal(app, dir, extension_list, extension_count, false); +} + CUSTOM_COMMAND_SIG(open_all_code){ int32_t extension_count = 0; char **extension_list = get_current_project_extensions(&extension_count); open_all_files_with_extension(app, &global_part, extension_list, extension_count, false); } +static void +open_all_code_recursive(Application_Links *app, String dir){ + int32_t extension_count = 0; + char **extension_list = get_current_project_extensions(&extension_count); + open_all_files_with_extension_internal(app, dir, extension_list, extension_count, true); +} + CUSTOM_COMMAND_SIG(open_all_code_recursive){ int32_t extension_count = 0; char **extension_list = get_current_project_extensions(&extension_count); @@ -172,6 +186,195 @@ CUSTOM_COMMAND_SIG(close_all_code){ close_all_files_with_extension(app, &global_part, extension_list, extension_count); } +static void +load_project_from_file(Application_Links *app, Partition *part, FILE *file, String project_dir){ + Temp_Memory temp = begin_temp_memory(part); + + char *mem = 0; + int32_t size = 0; + bool32 file_read_success = file_handle_dump(part, file, &mem, &size); + if (file_read_success){ + Cpp_Token_Array array; + array.count = 0; + array.max_count = (1 << 20)/sizeof(Cpp_Token); + array.tokens = push_array(&global_part, Cpp_Token, array.max_count); + + Cpp_Lex_Data S = cpp_lex_data_init(); + Cpp_Lex_Result result = cpp_lex_step(&S, mem, size+1, HAS_NULL_TERM, &array, NO_OUT_LIMIT); + + if (result == LexResult_Finished){ + // Clear out current project + if (current_project.close_all_code_when_this_project_closes){ + exec_command(app, close_all_code); + } + current_project = null_project; + + // Set new project directory + { + current_project.dir = current_project.dir_space; + String str = make_fixed_width_string(current_project.dir_space); + copy(&str, project_dir); + terminate_with_null(&str); + current_project.dir_len = str.size; + } + + // Read the settings from project.4coder + for (int32_t i = 0; i < array.count; ++i){ + Config_Line config_line = read_config_line(array, &i); + if (config_line.read_success){ + Config_Item item = get_config_item(config_line, mem, array); + + { + char str_space[512]; + String str = make_fixed_width_string(str_space); + if (config_string_var(item, "extensions", 0, &str)){ + if (str.size < sizeof(current_project.extension_list.extension_space)){ + set_extensions(¤t_project.extension_list, str); + print_message(app, str.str, str.size); + print_message(app, "\n", 1); + } + else{ + print_message(app, literal("STRING TOO LONG!\n")); + } + } + } + + { + bool32 open_recursively = false; + if (config_bool_var(item, "open_recursively", 0, &open_recursively)){ + current_project.open_recursively = open_recursively; + } + } + + { +#if defined(_WIN32) +#define FKEY_COMMAND "fkey_command_win" +#elif defined(__linux__) +#define FKEY_COMMAND "fkey_command_linux" +#else +#error no project configuration names for this platform +#endif + + int32_t index = 0; + Config_Array_Reader array_reader = {0}; + if (config_array_var(item, FKEY_COMMAND, &index, &array_reader)){ + if (index >= 1 && index <= 16){ + Config_Item array_item = {0}; + int32_t item_index = 0; + + char space[256]; + String msg = make_fixed_width_string(space); + append(&msg, FKEY_COMMAND"["); + append_int_to_str(&msg, index); + append(&msg, "] = {"); + + for (config_array_next_item(&array_reader, &array_item); + config_array_good(&array_reader); + config_array_next_item(&array_reader, &array_item)){ + + if (item_index >= 4){ + break; + } + + append(&msg, "["); + append_int_to_str(&msg, item_index); + append(&msg, "] = "); + + bool32 read_string = false; + bool32 read_bool = false; + + char *dest_str = 0; + int32_t dest_str_size = 0; + + bool32 *dest_bool = 0; + + switch (item_index){ + case 0: + { + dest_str = current_project.fkey_commands[index-1].command; + dest_str_size = sizeof(current_project.fkey_commands[index-1].command); + read_string = true; + }break; + + case 1: + { + dest_str = current_project.fkey_commands[index-1].out; + dest_str_size = sizeof(current_project.fkey_commands[index-1].out); + read_string = true; + }break; + + case 2: + { + dest_bool = ¤t_project.fkey_commands[index-1].use_build_panel; + read_bool = true; + }break; + + case 3: + { + dest_bool = ¤t_project.fkey_commands[index-1].save_dirty_buffers; + read_bool = true; + }break; + } + + if (read_string){ + if (config_int_var(array_item, 0, 0, 0)){ + append(&msg, "NULL, "); + dest_str[0] = 0; + } + + char str_space[512]; + String str = make_fixed_width_string(str_space); + if (config_string_var(array_item, 0, 0, &str)){ + if (str.size < dest_str_size){ + interpret_escaped_string(dest_str, str); + append(&msg, dest_str); + append(&msg, ", "); + } + else{ + append(&msg, "STRING TOO LONG!, "); + } + } + } + + if (read_bool){ + if (config_bool_var(array_item, 0, 0, dest_bool)){ + if (*dest_bool){ + append(&msg, "true, "); + } + else{ + append(&msg, "false, "); + } + } + } + + item_index++; + } + + append(&msg, "}\n"); + print_message(app, msg.str, msg.size); + } + } + } + } + } + + if (current_project.close_all_files_when_project_opens){ + close_all_files_with_extension(app, &global_part, 0, 0); + } + + // Open all project files + if (current_project.open_recursively){ + open_all_code_recursive(app, project_dir); + } + else{ + open_all_code(app, project_dir); + } + } + } + + end_temp_memory(temp); +} + CUSTOM_COMMAND_SIG(load_project){ Partition *part = &global_part; @@ -183,204 +386,33 @@ CUSTOM_COMMAND_SIG(load_project){ } if (project_name.size != 0){ - int32_t original_size = project_name.size; - append_sc(&project_name, "project.4coder"); - terminate_with_null(&project_name); - FILE *file = fopen(project_name.str, "rb"); - if (file){ - project_name.size = original_size; + bool32 load_failed = false; + for(;;){ + int32_t original_size = project_name.size; + append_sc(&project_name, "project.4coder"); terminate_with_null(&project_name); - Temp_Memory temp = begin_temp_memory(part); - - char *mem = 0; - int32_t size = 0; - bool32 file_read_success = file_handle_dump(part, file, &mem, &size); - if (file_read_success){ + FILE *file = fopen(project_name.str, "rb"); + if (file){ + project_name.size = original_size; + terminate_with_null(&project_name); + load_project_from_file(app, part, file, project_name); fclose(file); + break; + } + else{ + project_name.size = original_size; + remove_last_folder(&project_name); - Cpp_Token_Array array; - array.count = 0; - array.max_count = (1 << 20)/sizeof(Cpp_Token); - array.tokens = push_array(&global_part, Cpp_Token, array.max_count); - - Cpp_Lex_Data S = cpp_lex_data_init(); - Cpp_Lex_Result result = cpp_lex_step(&S, mem, size+1, HAS_NULL_TERM, &array, NO_OUT_LIMIT); - - if (result == LexResult_Finished){ - // Clear out current project - if (current_project.close_all_code_when_this_project_closes){ - exec_command(app, close_all_code); - } - current_project = null_project; - - // Set new project directory - { - current_project.dir = current_project.dir_space; - String str = make_fixed_width_string(current_project.dir_space); - copy(&str, project_name); - terminate_with_null(&str); - current_project.dir_len = str.size; - } - - // Read the settings from project.4coder - for (int32_t i = 0; i < array.count; ++i){ - Config_Line config_line = read_config_line(array, &i); - if (config_line.read_success){ - Config_Item item = get_config_item(config_line, mem, array); - - { - char str_space[512]; - String str = make_fixed_width_string(str_space); - if (config_string_var(item, "extensions", 0, &str)){ - if (str.size < sizeof(current_project.extension_list.extension_space)){ - set_extensions(¤t_project.extension_list, str); - print_message(app, str.str, str.size); - print_message(app, "\n", 1); - } - else{ - print_message(app, literal("STRING TOO LONG!\n")); - } - } - } - - { - bool32 open_recursively = false; - if (config_bool_var(item, "open_recursively", 0, &open_recursively)){ - current_project.open_recursively = open_recursively; - } - } - - { -#if defined(_WIN32) -#define FKEY_COMMAND "fkey_command_win" -#elif defined(__linux__) -#define FKEY_COMMAND "fkey_command_linux" -#else -#error no project configuration names for this platform -#endif - - int32_t index = 0; - Config_Array_Reader array_reader = {0}; - if (config_array_var(item, FKEY_COMMAND, &index, &array_reader)){ - if (index >= 1 && index <= 16){ - Config_Item array_item = {0}; - int32_t item_index = 0; - - char space[256]; - String msg = make_fixed_width_string(space); - append(&msg, FKEY_COMMAND"["); - append_int_to_str(&msg, index); - append(&msg, "] = {"); - - for (config_array_next_item(&array_reader, &array_item); - config_array_good(&array_reader); - config_array_next_item(&array_reader, &array_item)){ - - if (item_index >= 4){ - break; - } - - append(&msg, "["); - append_int_to_str(&msg, item_index); - append(&msg, "] = "); - - bool32 read_string = false; - bool32 read_bool = false; - - char *dest_str = 0; - int32_t dest_str_size = 0; - - bool32 *dest_bool = 0; - - switch (item_index){ - case 0: - { - dest_str = current_project.fkey_commands[index-1].command; - dest_str_size = sizeof(current_project.fkey_commands[index-1].command); - read_string = true; - }break; - - case 1: - { - dest_str = current_project.fkey_commands[index-1].out; - dest_str_size = sizeof(current_project.fkey_commands[index-1].out); - read_string = true; - }break; - - case 2: - { - dest_bool = ¤t_project.fkey_commands[index-1].use_build_panel; - read_bool = true; - }break; - - case 3: - { - dest_bool = ¤t_project.fkey_commands[index-1].save_dirty_buffers; - read_bool = true; - }break; - } - - if (read_string){ - if (config_int_var(array_item, 0, 0, 0)){ - append(&msg, "NULL, "); - dest_str[0] = 0; - } - - char str_space[512]; - String str = make_fixed_width_string(str_space); - if (config_string_var(array_item, 0, 0, &str)){ - if (str.size < dest_str_size){ - interpret_escaped_string(dest_str, str); - append(&msg, dest_str); - append(&msg, ", "); - } - else{ - append(&msg, "STRING TOO LONG!, "); - } - } - } - - if (read_bool){ - if (config_bool_var(array_item, 0, 0, dest_bool)){ - if (*dest_bool){ - append(&msg, "true, "); - } - else{ - append(&msg, "false, "); - } - } - } - - item_index++; - } - - append(&msg, "}\n"); - print_message(app, msg.str, msg.size); - } - } - } - } - } - - if (current_project.close_all_files_when_project_opens){ - close_all_files_with_extension(app, &global_part, 0, 0); - } - - // Open all project files - if (current_project.open_recursively){ - exec_command(app, open_all_code_recursive); - } - else{ - exec_command(app, open_all_code); - } + if (project_name.size >= original_size){ + load_failed = true; + break; } } - - end_temp_memory(temp); } - else{ + + if (load_failed){ char message_space[512]; String message = make_fixed_width_string(message_space); append_sc(&message, "Did not find project.4coder. "); @@ -391,6 +423,7 @@ CUSTOM_COMMAND_SIG(load_project){ else{ append_sc(&message, "Continuing without a project"); } + append_s_char(&message, '\n'); print_message(app, message.str, message.size); } } @@ -456,8 +489,22 @@ exec_project_fkey_command(Application_Links *app, int32_t command_ind){ CUSTOM_COMMAND_SIG(project_fkey_command){ User_Input input = get_command_input(app); if (input.type == UserInputKey){ + bool32 got_ind = false; + int32_t ind = 0; if (input.key.keycode >= key_f1 && input.key.keycode <= key_f16){ - int32_t ind = (input.key.keycode - key_f1); + ind = (input.key.keycode - key_f1); + got_ind = true; + } + else if (input.key.character_no_caps_lock >= '1' && input.key.character_no_caps_lock >= '9'){ + ind = (input.key.character_no_caps_lock - '1'); + got_ind = true; + } + else if (input.key.character_no_caps_lock == '0'){ + ind = 9; + got_ind = true; + } + + if (got_ind){ exec_project_fkey_command(app, ind); } } diff --git a/4coder_search.cpp b/4coder_search.cpp index d6669ad4..3b79c458 100644 --- a/4coder_search.cpp +++ b/4coder_search.cpp @@ -148,8 +148,7 @@ search_hit_add(General_Memory *general, Table *hits, String_Space *space, char * if (new_size < space->max + len){ new_size = space->max + len; } - space->space = (char*)general_memory_reallocate( - general, space->space, space->new_pos, new_size); + space->space = (char*)general_memory_reallocate(general, space->space, space->new_pos, new_size); ostring = strspace_append(space, str, len); } @@ -183,8 +182,8 @@ buffer_seek_alpha_numeric_end(Application_Links *app, Buffer_Summary *buffer, in int32_t still_looping = true; do{ for (; pos < chunk.end; ++pos){ - char at_pos = chunk.data[pos]; - if (!char_is_alpha_numeric(at_pos)) goto double_break; + uint8_t at_pos = (uint8_t)chunk.data[pos]; + if (!char_is_alpha_numeric_utf8(at_pos)) goto double_break; } still_looping = forward_stream_chunk(&chunk); }while(still_looping); @@ -222,21 +221,21 @@ match_check(Application_Links *app, Search_Range *range, int32_t *pos, Search_Ma char first = word.str[0]; char prev = ' '; - if (char_is_alpha_numeric(first)){ + if (char_is_alpha_numeric_utf8(first)){ prev = buffer_get_char(app, &result.buffer, result.start - 1); } - if (!char_is_alpha_numeric(prev)){ + if (!char_is_alpha_numeric_utf8(prev)){ result.end = result.start + word.size; if (result.end <= end_pos){ char last = word.str[word.size-1]; char next = ' '; - if (char_is_alpha_numeric(last)){ + if (char_is_alpha_numeric_utf8(last)){ next = buffer_get_char(app, &result.buffer, result.end); } - if (!char_is_alpha_numeric(next)){ + if (!char_is_alpha_numeric_utf8(next)){ result.found_match = true; found_match = FindResult_FoundMatch; } @@ -250,7 +249,7 @@ match_check(Application_Links *app, Search_Range *range, int32_t *pos, Search_Ma case SearchFlag_MatchWordPrefix: { char prev = buffer_get_char(app, &result.buffer, result.start - 1); - if (!char_is_alpha_numeric(prev)){ + if (!char_is_alpha_numeric_utf8(prev)){ result.end = buffer_seek_alpha_numeric_end( app, &result.buffer, result.start); @@ -770,7 +769,7 @@ CUSTOM_COMMAND_SIG(word_complete){ do{ for (; cursor_pos >= chunk.start; --cursor_pos){ char c = chunk.data[cursor_pos]; - if (char_is_alpha(c)){ + if (char_is_alpha_utf8(c)){ word_start = cursor_pos; } else if (!char_is_numeric(c)){ diff --git a/4cpp/4cpp_lexer.h b/4cpp/4cpp_lexer.h index 473c1d15..4a76b8ea 100644 --- a/4cpp/4cpp_lexer.h +++ b/4cpp/4cpp_lexer.h @@ -363,7 +363,7 @@ cpp_lex_nonalloc_null_end_no_limit(Cpp_Lex_Data *S_ptr, char *chunk, i32_4tech s S.white_done = 0; for(;;){ for (; S.pp_state < LSPP_count && S.pos < end_pos;){ - c = chunk[S.pos++]; + c = (u8_4tech)chunk[S.pos++]; i32_4tech i = S.pp_state + whitespace_fsm_eq_classes[c]; S.pp_state = whitespace_fsm_table[i]; } diff --git a/4cpp/4cpp_lexer_tables.c b/4cpp/4cpp_lexer_tables.c index f05d4125..65ff1064 100644 --- a/4cpp/4cpp_lexer_tables.c +++ b/4cpp/4cpp_lexer_tables.c @@ -28,7 +28,7 @@ uint8_t multiline_state_table[] = { }; uint16_t main_fsm_eq_classes[] = { - 0,40,40,40,40,40,40,40,40,40,80,120,120,120,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,160,200,240,280,320,360,400,440,480,480,520,560,480,600,640,680,720,760,760,760,760,760,760,760,760,760,800,480,840,880,920,480,480,960,960,960,960,960,960,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,480,1040,480,1080,320,40,960,960,960,960,1120,960,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1160,1000,1000,480,1200,480,480,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40, + 0,40,40,40,40,40,40,40,40,40,80,120,120,120,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,160,200,240,280,320,360,400,440,480,480,520,560,480,600,640,680,720,760,760,760,760,760,760,760,760,760,800,480,840,880,920,480,480,960,960,960,960,960,960,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,480,1040,480,1080,320,40,960,960,960,960,1120,960,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1160,1000,1000,480,1200,480,480,40,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960, }; const int32_t num_main_fsm_eq_classes = 31; @@ -68,7 +68,7 @@ uint8_t main_fsm_table[] = { }; uint16_t pp_include_fsm_eq_classes[] = { - 0,40,40,40,40,40,40,40,40,40,80,120,120,120,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,160,200,240,280,320,360,400,440,480,480,520,560,480,600,640,680,720,760,760,760,760,760,760,760,760,760,800,480,840,880,920,480,480,960,960,960,960,960,960,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,480,1040,480,1080,320,40,960,960,960,960,1120,960,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1160,1000,1000,480,1200,480,480,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40, + 0,40,40,40,40,40,40,40,40,40,80,120,120,120,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,160,200,240,280,320,360,400,440,480,480,520,560,480,600,640,680,720,760,760,760,760,760,760,760,760,760,800,480,840,880,920,480,480,960,960,960,960,960,960,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,480,1040,480,1080,320,40,960,960,960,960,1120,960,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1160,1000,1000,480,1200,480,480,40,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960, }; const int32_t num_pp_include_fsm_eq_classes = 31; @@ -108,7 +108,7 @@ uint8_t pp_include_fsm_table[] = { }; uint16_t pp_macro_fsm_eq_classes[] = { - 0,40,40,40,40,40,40,40,40,40,80,120,120,120,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,160,200,240,280,320,360,400,440,480,480,520,560,480,600,640,680,720,760,760,760,760,760,760,760,760,760,800,480,840,880,920,480,480,960,960,960,960,960,960,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,480,1040,480,1080,320,40,960,960,960,960,1120,960,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1160,1000,1000,480,1200,480,480,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40, + 0,40,40,40,40,40,40,40,40,40,80,120,120,120,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,160,200,240,280,320,360,400,440,480,480,520,560,480,600,640,680,720,760,760,760,760,760,760,760,760,760,800,480,840,880,920,480,480,960,960,960,960,960,960,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,480,1040,480,1080,320,40,960,960,960,960,1120,960,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1160,1000,1000,480,1200,480,480,40,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960, }; const int32_t num_pp_macro_fsm_eq_classes = 31; @@ -148,7 +148,7 @@ uint8_t pp_macro_fsm_table[] = { }; uint16_t pp_identifier_fsm_eq_classes[] = { - 0,40,40,40,40,40,40,40,40,40,80,120,120,120,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,160,200,240,280,320,360,400,440,480,480,520,560,480,600,640,680,720,760,760,760,760,760,760,760,760,760,800,480,840,880,920,480,480,960,960,960,960,960,960,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,480,1040,480,1080,320,40,960,960,960,960,1120,960,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1160,1000,1000,480,1200,480,480,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40, + 0,40,40,40,40,40,40,40,40,40,80,120,120,120,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,160,200,240,280,320,360,400,440,480,480,520,560,480,600,640,680,720,760,760,760,760,760,760,760,760,760,800,480,840,880,920,480,480,960,960,960,960,960,960,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,480,1040,480,1080,320,40,960,960,960,960,1120,960,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1160,1000,1000,480,1200,480,480,40,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960, }; const int32_t num_pp_identifier_fsm_eq_classes = 31; @@ -188,7 +188,7 @@ uint8_t pp_identifier_fsm_table[] = { }; uint16_t pp_body_if_fsm_eq_classes[] = { - 0,40,40,40,40,40,40,40,40,40,80,120,120,120,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,160,200,240,280,320,360,400,440,480,480,520,560,480,600,640,680,720,760,760,760,760,760,760,760,760,760,800,480,840,880,920,480,480,960,960,960,960,960,960,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,480,1040,480,1080,320,40,960,960,960,960,1120,960,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1160,1000,1000,480,1200,480,480,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40, + 0,40,40,40,40,40,40,40,40,40,80,120,120,120,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,160,200,240,280,320,360,400,440,480,480,520,560,480,600,640,680,720,760,760,760,760,760,760,760,760,760,800,480,840,880,920,480,480,960,960,960,960,960,960,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,480,1040,480,1080,320,40,960,960,960,960,1120,960,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1160,1000,1000,480,1200,480,480,40,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960, }; const int32_t num_pp_body_if_fsm_eq_classes = 31; @@ -228,7 +228,7 @@ uint8_t pp_body_if_fsm_table[] = { }; uint16_t pp_body_fsm_eq_classes[] = { - 0,40,40,40,40,40,40,40,40,40,80,120,120,120,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,160,200,240,280,320,360,400,440,480,480,520,560,480,600,640,680,720,760,760,760,760,760,760,760,760,760,800,480,840,880,920,480,480,960,960,960,960,960,960,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,480,1040,480,1080,320,40,960,960,960,960,1120,960,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1160,1000,1000,480,1200,480,480,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40, + 0,40,40,40,40,40,40,40,40,40,80,120,120,120,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,160,200,240,280,320,360,400,440,480,480,520,560,480,600,640,680,720,760,760,760,760,760,760,760,760,760,800,480,840,880,920,480,480,960,960,960,960,960,960,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,480,1040,480,1080,320,40,960,960,960,960,1120,960,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1160,1000,1000,480,1200,480,480,40,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960, }; const int32_t num_pp_body_fsm_eq_classes = 31; @@ -268,7 +268,7 @@ uint8_t pp_body_fsm_table[] = { }; uint16_t pp_number_fsm_eq_classes[] = { - 0,40,40,40,40,40,40,40,40,40,80,120,120,120,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,160,200,240,280,320,360,400,440,480,480,520,560,480,600,640,680,720,760,760,760,760,760,760,760,760,760,800,480,840,880,920,480,480,960,960,960,960,960,960,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,480,1040,480,1080,320,40,960,960,960,960,1120,960,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1160,1000,1000,480,1200,480,480,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40, + 0,40,40,40,40,40,40,40,40,40,80,120,120,120,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,160,200,240,280,320,360,400,440,480,480,520,560,480,600,640,680,720,760,760,760,760,760,760,760,760,760,800,480,840,880,920,480,480,960,960,960,960,960,960,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,480,1040,480,1080,320,40,960,960,960,960,1120,960,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1160,1000,1000,480,1200,480,480,40,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960, }; const int32_t num_pp_number_fsm_eq_classes = 31; @@ -320,7 +320,7 @@ uint8_t pp_error_fsm_table[] = { }; uint16_t pp_junk_fsm_eq_classes[] = { - 0,40,40,40,40,40,40,40,40,40,80,120,120,120,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,160,200,240,280,320,360,400,440,480,480,520,560,480,600,640,680,720,760,760,760,760,760,760,760,760,760,800,480,840,880,920,480,480,960,960,960,960,960,960,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,480,1040,480,1080,320,40,960,960,960,960,1120,960,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1160,1000,1000,480,1200,480,480,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40, + 0,40,40,40,40,40,40,40,40,40,80,120,120,120,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,160,200,240,280,320,360,400,440,480,480,520,560,480,600,640,680,720,760,760,760,760,760,760,760,760,760,800,480,840,880,920,480,480,960,960,960,960,960,960,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,480,1040,480,1080,320,40,960,960,960,960,1120,960,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1160,1000,1000,480,1200,480,480,40,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960, }; const int32_t num_pp_junk_fsm_eq_classes = 31; diff --git a/4ed.cpp b/4ed.cpp index 08cf2a1c..ccb63bf2 100644 --- a/4ed.cpp +++ b/4ed.cpp @@ -306,16 +306,19 @@ COMMAND_DECL(redo){ COMMAND_DECL(interactive_new){ USE_VIEW(view); - view_show_interactive(system, view, IAct_New, IInt_Sys_File_List, make_lit_string("New: ")); } COMMAND_DECL(interactive_open){ USE_VIEW(view); - view_show_interactive(system, view, IAct_Open, IInt_Sys_File_List,make_lit_string("Open: ")); } +COMMAND_DECL(interactive_open_or_new){ + USE_VIEW(view); + view_show_interactive(system, view, IAct_OpenOrNew, IInt_Sys_File_List,make_lit_string("Open: ")); +} + // TODO(allen): Improvements to reopen // - Perform a diff // - If the diff is not tremendously big, apply the edits. @@ -608,6 +611,7 @@ setup_command_table(){ SET(interactive_new); SET(interactive_open); + SET(interactive_open_or_new); SET(interactive_switch_buffer); SET(interactive_kill_buffer); SET(save_as); diff --git a/4ed_api_implementation.cpp b/4ed_api_implementation.cpp index 8617d859..fb3e22cd 100644 --- a/4ed_api_implementation.cpp +++ b/4ed_api_implementation.cpp @@ -1629,6 +1629,7 @@ DOC_RETURN(returns non-zero on success) switch (setting){ case ViewSetting_ShowWhitespace: *value_out = vptr->file_data.show_whitespace; break; case ViewSetting_ShowScrollbar: *value_out = !vptr->hide_scrollbar; break; + case ViewSetting_ShowFileBar: *value_out = !vptr->hide_file_bar; break; default: result = 0; break; } } @@ -1663,6 +1664,11 @@ DOC_SEE(View_Setting_ID) vptr->hide_scrollbar = !value; }break; + case ViewSetting_ShowFileBar: + { + vptr->hide_file_bar = !value; + }break; + default: { result = false; diff --git a/4ed_file_view.cpp b/4ed_file_view.cpp index ee96d513..76598ff2 100644 --- a/4ed_file_view.cpp +++ b/4ed_file_view.cpp @@ -107,6 +107,7 @@ enum Interactive_Action{ IAct_Open, IAct_Save_As, IAct_New, + IAct_OpenOrNew, IAct_Switch, IAct_Kill, IAct_Sure_To_Kill, @@ -212,6 +213,7 @@ struct View{ i32 list_i; b32 hide_scrollbar; + b32 hide_file_bar; // interactive stuff Interactive_Interaction interaction; @@ -1665,7 +1667,7 @@ file_measure_wraps(System_Functions *system, Models *models, Editing_File *file, potential_wrap.adjust_top_to_this = 0; if (buffer_stringify_loop(&stream, params.buffer, i, end_i)){ - b32 still_looping = 1; + b32 still_looping = true; while(still_looping){ for (; i < stream.end; ++i){ @@ -1677,6 +1679,7 @@ file_measure_wraps(System_Functions *system, Models *models, Editing_File *file, for (TRANSLATION_DECL_EMIT_LOOP(J, emits)){ TRANSLATION_DECL_GET_STEP(buffer_step, behav, J, emits); if (!codepoint_is_whitespace(buffer_step.value)){ + i = buffer_step.i; goto doublebreak_stage_vspace; } } @@ -3946,9 +3949,7 @@ save_file_by_name(System_Functions *system, Models *models, String name){ internal void interactive_begin_sure_to_kill(System_Functions *system, View *view, Editing_File *file){ - view_show_interactive(system, view, - IAct_Sure_To_Kill, IInt_Sure_To_Kill, - make_lit_string("Are you sure?")); + view_show_interactive(system, view, IAct_Sure_To_Kill, IInt_Sure_To_Kill, make_lit_string("Are you sure?")); copy_ss(&view->dest, file->name.live_name); } @@ -4003,14 +4004,16 @@ interactive_view_complete(System_Functions *system, View *view, String dest, i32 switch (view->action){ case IAct_Open: - view_open_file(system, models, view, dest); - view_show_file(view); - break; + { + view_open_file(system, models, view, dest); + view_show_file(view); + }break; case IAct_Save_As: - view_interactive_save_as(system, models, view->file_data.file, dest); - view_show_file(view); - break; + { + view_interactive_save_as(system, models, view->file_data.file, dest); + view_show_file(view); + }break; case IAct_New: if (dest.size > 0 && !char_is_slash(dest.str[dest.size-1])){ @@ -4022,6 +4025,11 @@ interactive_view_complete(System_Functions *system, View *view, String dest, i32 } }break; + case IAct_OpenOrNew: + { + InvalidCodePath; + }break; + case IAct_Switch: { Editing_File *file = working_set_name_contains(&models->working_set, dest); @@ -4039,123 +4047,42 @@ interactive_view_complete(System_Functions *system, View *view, String dest, i32 case IAct_Sure_To_Close: switch (user_action){ case 0: - models->keep_playing = 0; - break; + { + models->keep_playing = 0; + }break; case 1: - view_show_file(view); - break; + { + view_show_file(view); + }break; - case 2: - // TODO(allen): Save all and close. + case 2: // TODO(allen): Save all and close. break; - } - break; + }break; case IAct_Sure_To_Kill: switch (user_action){ case 0: - kill_file_by_name(system, models, dest); - view_show_file(view); - break; + { + kill_file_by_name(system, models, dest); + view_show_file(view); + }break; case 1: - view_show_file(view); - break; + { + view_show_file(view); + }break; case 2: - save_file_by_name(system, models, dest); - kill_file_by_name(system, models, dest); - view_show_file(view); - break; - } - break; + { + save_file_by_name(system, models, dest); + kill_file_by_name(system, models, dest); + view_show_file(view); + }break; + }break; } } -#if 0 -internal void -update_highlighting(View *view){ - View *file_view = view->hot_file_view; - if (!file_view){ - view->highlight = {}; - return; - } - - Editing_File *file = file_view->file; - if (!file || !file_is_ready(file)){ - view->highlight = {}; - return; - } - - Models *models = view->persistent.models; - - Style *style = &models->style; - i32 pos = view_get_cursor_pos(file_view); - char c = buffer_get_char(&file->state.buffer, pos); - - if (c == '\r'){ - view->highlight.ids[0] = - raw_ptr_dif(&style->main.special_character_color, style); - } - - else if (file->state.tokens_complete){ - Cpp_Token_Stack *tokens = &file->state.token_array; - Cpp_Get_Token_Result result = cpp_get_token(tokens, pos); - Cpp_Token token = tokens->tokens[result.token_index]; - if (!result.in_whitespace){ - u32 *color = style_get_color(style, token); - view->highlight.ids[0] = raw_ptr_dif(color, style); - if (token.type == CPP_TOKEN_JUNK){ - view->highlight.ids[1] = - raw_ptr_dif(&style->main.highlight_junk_color, style); - } - else if (char_is_whitespace(c)){ - view->highlight.ids[1] = - raw_ptr_dif(&style->main.highlight_white_color, style); - } - else{ - view->highlight.ids[1] = 0; - } - } - else{ - view->highlight.ids[0] = 0; - view->highlight.ids[1] = - raw_ptr_dif(&style->main.highlight_white_color, style); - } - } - - else{ - if (char_is_whitespace(c)){ - view->highlight.ids[0] = 0; - view->highlight.ids[1] = - raw_ptr_dif(&style->main.highlight_white_color, style); - } - else{ - view->highlight.ids[0] = - raw_ptr_dif(&style->main.default_color, style); - view->highlight.ids[1] = 0; - } - } - - if (file_view->show_temp_highlight){ - view->highlight.ids[2] = - raw_ptr_dif(&style->main.highlight_color, style); - view->highlight.ids[3] = - raw_ptr_dif(&style->main.at_highlight_color, style); - } - else if (file->state.paste_effect.tick_down > 0){ - view->highlight.ids[2] = - raw_ptr_dif(&style->main.paste_color, style); - view->highlight.ids[3] = 0; - } - else{ - view->highlight.ids[2] = 0; - view->highlight.ids[3] = 0; - } -} -#endif - struct File_Bar{ f32 pos_x, pos_y; f32 text_shift_x, text_shift_y; @@ -4207,15 +4134,14 @@ view_reinit_scrolling(View *view){ internal b32 file_step(View *view, i32_Rect region, Input_Summary *user_input, b32 is_active, b32 *consumed_l){ - i32 is_animating = 0; + b32 is_animating = false; Editing_File *file = view->file_data.file; if (file && !file->is_loading){ if (file->state.paste_effect.seconds_down > 0.f){ file->state.paste_effect.seconds_down -= user_input->dt; - is_animating = 1; + is_animating = true; } } - return(is_animating); } @@ -4642,7 +4568,7 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su gui_begin_top_level(target, input); { - if (view->showing_ui != VUI_Debug){ + if (view->showing_ui != VUI_Debug && !view->hide_file_bar){ gui_do_top_bar(target); } do_widget(view, target); @@ -4944,69 +4870,68 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su switch (view->interaction){ case IInt_Sys_File_List: { - b32 autocomplete_with_enter = 1; - b32 activate_directly = 0; + b32 autocomplete_with_enter = true; + b32 activate_directly = false; if (view->action == IAct_Save_As || view->action == IAct_New){ - autocomplete_with_enter = 0; + autocomplete_with_enter = false; } String message = null_string; switch (view->action){ + case IAct_OpenOrNew: case IAct_Open: message = make_lit_string("Open: "); break; case IAct_Save_As: message = make_lit_string("Save As: "); break; case IAct_New: message = make_lit_string("New: "); break; } - Exhaustive_File_Loop loop; - Exhaustive_File_Info file_info; - GUI_Item_Update update = {0}; Hot_Directory *hdir = &models->hot_directory; - { - Single_Line_Input_Step step = {0}; - Key_Event_Data key = {0}; - i32 i; + b32 do_open_or_new = false; + for (i32 i = 0; i < keys.count; ++i){ + Key_Event_Data key = get_single_key(&keys, i); + Single_Line_Input_Step step = app_single_file_input_step(system, &models->working_set, key, + &hdir->string, hdir, 1, 0); - for (i = 0; i < keys.count; ++i){ - key = get_single_key(&keys, i); - step = app_single_file_input_step(system, &models->working_set, key, - &hdir->string, hdir, 1, 0); - if (step.made_a_change){ - view->list_i = 0; - result.consume_keys = 1; + if (step.made_a_change){ + view->list_i = 0; + result.consume_keys = true; + } + + if (key.keycode == '\n'){ + if (!autocomplete_with_enter){ + activate_directly = true; + result.consume_keys = true; } - - if (!autocomplete_with_enter && key.keycode == '\n'){ - activate_directly = 1; - result.consume_keys = 1; + else if (view->action == IAct_OpenOrNew){ + do_open_or_new = true; + result.consume_keys = true; } } } gui_do_text_field(target, message, hdir->string); - b32 snap_into_view = 0; + b32 snap_into_view = false; scroll_context.id[0] = (u64)(hdir); if (gui_scroll_was_activated(target, scroll_context)){ - snap_into_view = 1; + snap_into_view = true; } - gui_begin_scrollable(target, scroll_context, view->gui_scroll, - 9 * view->line_height, show_scrollbar); + gui_begin_scrollable(target, scroll_context, view->gui_scroll, 9 * view->line_height, show_scrollbar); id.id[0] = (u64)(hdir) + 1; - if (gui_begin_list(target, id, view->list_i, 0, - snap_into_view, &update)){ + if (gui_begin_list(target, id, view->list_i, 0, snap_into_view, &update)){ // TODO(allen): Allow me to handle key consumption correctly here! gui_standard_list(target, id, &view->gui_scroll, view->scroll_region, &keys, &view->list_i, &update, user_up_key, user_down_key); } b32 do_new_directory = false; + Exhaustive_File_Loop loop; begin_exhaustive_loop(&loop, hdir); for (i32 i = 0; i < loop.count; ++i){ - file_info = get_exhaustive_info(system, &models->working_set, &loop, i); + Exhaustive_File_Info file_info = get_exhaustive_info(system, &models->working_set, &loop, i); if (file_info.name_match){ id.id[0] = (u64)(file_info.info); @@ -5018,22 +4943,32 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su if (gui_do_file_option(target, id, filename, file_info.is_folder, file_info.message)){ if (file_info.is_folder){ set_last_folder_sc(&hdir->string, file_info.info->filename, '/'); - do_new_directory = 1; + do_new_directory = true; } else if (autocomplete_with_enter){ - complete = 1; + complete = true; copy_ss(&comp_dest, loop.full_path); + if (view->action == IAct_OpenOrNew){ + view->action = IAct_Open; + } } } + + if (do_open_or_new){ + do_open_or_new = false; + } } } gui_end_list(target); - if (activate_directly){ - complete = 1; + if (activate_directly || do_open_or_new){ + complete = true; copy_ss(&comp_dest, hdir->string); + if (do_open_or_new){ + view->action = IAct_New; + } } if (do_new_directory){ diff --git a/linux_4ed_fonts.cpp b/linux_4ed_fonts.cpp index 766fb4e2..a8903151 100644 --- a/linux_4ed_fonts.cpp +++ b/linux_4ed_fonts.cpp @@ -112,7 +112,7 @@ Sys_Font_Init_Sig(system_font_init){ u32 dir_max = KB(32); u8 *directory = push_array(scratch, u8, dir_max); String dir_str = make_string_cap(directory, 0, dir_max); - i32 dir_len = system_get_binary_path(&dir_str); + u32 dir_len = system_get_binary_path(&dir_str); Assert(dir_len < dir_max); { diff --git a/meta/fsm_table_generator.cpp b/meta/fsm_table_generator.cpp index a9b28de3..2cb34ee3 100644 --- a/meta/fsm_table_generator.cpp +++ b/meta/fsm_table_generator.cpp @@ -114,7 +114,7 @@ main_fsm(Cpp_Lex_FSM fsm, uint8_t pp_state, uint8_t c){ default: switch (fsm.state){ case LS_default: - if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_' || c == '$'){ + if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_' || c == '$' || c >= 128){ fsm.state = LS_identifier; } else if (c >= '1' && c <= '9'){ @@ -192,40 +192,41 @@ main_fsm(Cpp_Lex_FSM fsm, uint8_t pp_state, uint8_t c){ break; case LS_identifier: - if (!((c >= '0' && c <= '9') || - (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || - c == '_' || c == '$')){ - fsm.emit_token = 1; + { + int is_ident = (c >= '0' && c <= '9') || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_' || c == '$' || c >= 128; + if (!is_ident){ + fsm.emit_token = 1; + } } break; case LS_pound: - switch (c){ - case '#': fsm.emit_token = 1; break; - default: fsm.emit_token = 1; break; - } - break; + { + fsm.emit_token = 1; + }break; case LS_pp: - if (c == ' ' || c == '\r' || c == '\v' || c == '\f'){ - // NOTE(allen): do nothing - } - else if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')){ - fsm.state = LS_ppdef; - } - else{ - fsm.emit_token = 1; - } - break; + { + if (c == ' ' || c == '\r' || c == '\v' || c == '\f'){ + // NOTE(allen): do nothing + } + else if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c >= 128){ + fsm.state = LS_ppdef; + } + else{ + fsm.emit_token = 1; + } + }break; case LS_ppdef: - if (!((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))){ - fsm.emit_token = 1; - } - break; + { + int is_ident = (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c >= 128; + if (!is_ident){ + fsm.emit_token = 1; + } + }break; - case LS_char: - case LS_char_multiline: + case LS_char: case LS_char_multiline: switch(c){ case '\n': case '\'': fsm.emit_token = 1; break; case '\\': fsm.state = LS_char_slashed; break; @@ -317,22 +318,26 @@ main_fsm(Cpp_Lex_FSM fsm, uint8_t pp_state, uint8_t c){ break; case LS_hex: - if (!(c >= '0' && c <= '9' || c >= 'a' && c <= 'f' || c >= 'A' && c <= 'F')){ - fsm.emit_token = 1; - } - break; + { + int is_hex = c >= '0' && c <= '9' || c >= 'a' && c <= 'f' || c >= 'A' && c <= 'F' || c >= 128; + if (!is_hex){ + fsm.emit_token = 1; + } + }break; case LS_dot: - if (c >= '0' && c <= '9'){ - fsm.state = LS_float; - } - else - switch (c){ - case '.': fsm.state = LS_ellipsis; break; - case '*': fsm.emit_token = 1; break; - default: fsm.emit_token = 1; break; - } - break; + { + if (c >= '0' && c <= '9'){ + fsm.state = LS_float; + } + else{ + switch (c){ + case '.': fsm.state = LS_ellipsis; break; + case '*': fsm.emit_token = 1; break; + default: fsm.emit_token = 1; break; + } + } + }break; case LS_ellipsis: fsm.emit_token = 1; break; diff --git a/string/4coder_string_build_num.txt b/string/4coder_string_build_num.txt index f89e02d7..0ffa4d1e 100644 --- a/string/4coder_string_build_num.txt +++ b/string/4coder_string_build_num.txt @@ -1,5 +1,5 @@ 1 0 -69 +73 diff --git a/string/_4coder_string.ctm b/string/_4coder_string.ctm index 459c3aff..266c561b 100644 Binary files a/string/_4coder_string.ctm and b/string/_4coder_string.ctm differ diff --git a/string/internal_4coder_string.cpp b/string/internal_4coder_string.cpp index c2bc3a5b..4d6b13b7 100644 --- a/string/internal_4coder_string.cpp +++ b/string/internal_4coder_string.cpp @@ -63,12 +63,24 @@ char_is_upper(char c) return (c >= 'A' && c <= 'Z'); } +API_EXPORT_INLINE FSTRING_INLINE b32_4tech +char_is_upper_utf8(char c) +/* DOC(If c is an uppercase letter this call returns true.) */{ + return (c >= 'A' && c <= 'Z' || c >= 128); +} + API_EXPORT_INLINE FSTRING_INLINE b32_4tech char_is_lower(char c) /* DOC(If c is a lower letter this call returns true.) */{ return (c >= 'a' && c <= 'z'); } +API_EXPORT_INLINE FSTRING_INLINE b32_4tech +char_is_lower_utf8(u8_4tech c) +/* DOC(If c is a lower letter this call returns true.) */{ + return (c >= 'a' && c <= 'z' || c >= 128); +} + API_EXPORT_INLINE FSTRING_INLINE char char_to_upper(char c) /* DOC(If c is a lowercase letter this call returns the uppercase equivalent, otherwise it returns c.) */{ @@ -93,36 +105,72 @@ char_is_alpha_numeric(char c) return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c >= '0' && c <= '9' || c == '_'); } +API_EXPORT_INLINE FSTRING_INLINE b32_4tech +char_is_alpha_numeric_utf8(u8_4tech c) +/* DOC(This call returns non-zero if c is any alphanumeric character including underscore, or is a part of a UTF8 sequence outside of ASCII.) */{ + return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c >= '0' && c <= '9' || c == '_' || c >= 128); +} + API_EXPORT_INLINE FSTRING_INLINE b32_4tech char_is_alpha_numeric_true(char c) /* DOC(This call returns non-zero if c is any alphanumeric character no including underscore.) */{ return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c >= '0' && c <= '9'); } +API_EXPORT_INLINE FSTRING_INLINE b32_4tech +char_is_alpha_numeric_true_utf8(u8_4tech c) +/* DOC(This call returns non-zero if c is any alphanumeric character no including underscore.) */{ + return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c >= '0' && c <= '9' || c >= 128); +} + API_EXPORT_INLINE FSTRING_INLINE b32_4tech char_is_alpha(char c) /* DOC(This call returns non-zero if c is any alphabetic character including underscore.) */{ return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c == '_'); } +API_EXPORT_INLINE FSTRING_INLINE b32_4tech +char_is_alpha_utf8(u8_4tech c) +/* DOC(This call returns non-zero if c is any alphabetic character including underscore, or is a part of a UTF8 sequence outside of ASCII.) */{ + return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c == '_' || c >= 128); +} + API_EXPORT_INLINE FSTRING_INLINE b32_4tech char_is_alpha_true(char c) /* DOC(This call returns non-zero if c is any alphabetic character.) */{ return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z'); } +API_EXPORT_INLINE FSTRING_INLINE b32_4tech +char_is_alpha_true_utf8(u8_4tech c) +/* DOC(This call returns non-zero if c is any alphabetic character, or is a part of a UTF8 sequence outside of ASCII.) */{ + return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c >= 128); +} + API_EXPORT_INLINE FSTRING_INLINE b32_4tech char_is_hex(char c) /* DOC(This call returns non-zero if c is any valid hexadecimal digit.) */{ return (c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f'); } +API_EXPORT_INLINE FSTRING_INLINE b32_4tech +char_is_hex_utf8(u8_4tech c) +/* DOC(This call returns non-zero if c is any valid hexadecimal digit, or is a part of a UTF8 sequence outside of ASCII.) */{ + return (c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f' || c >= 128); +} + API_EXPORT_INLINE FSTRING_INLINE b32_4tech char_is_numeric(char c) /* DOC(This call returns non-zero if c is any valid decimal digit.) */{ return (c >= '0' && c <= '9'); } +API_EXPORT_INLINE FSTRING_INLINE b32_4tech +char_is_numeric_utf8(u8_4tech c) +/* DOC(This call returns non-zero if c is any valid decimal digit, or is a part of a UTF8 sequence outside of ASCII.) */{ + return (c >= '0' && c <= '9' || c >= 128); +} + // // String Making Functions diff --git a/win32_4ed.cpp b/win32_4ed.cpp index 4e5703a9..390e4e75 100644 --- a/win32_4ed.cpp +++ b/win32_4ed.cpp @@ -1100,9 +1100,8 @@ Win32ToggleFullscreen(void){ HWND Window = win32vars.window_handle; LONG_PTR Style = GetWindowLongPtr(Window, GWL_STYLE); if (Style & WS_OVERLAPPEDWINDOW){ - MONITORINFO MonitorInfo = {sizeof(MonitorInfo)}; - if(GetWindowPlacement(Window, &win32vars.GlobalWindowPosition) && - GetMonitorInfo(MonitorFromWindow(Window, MONITOR_DEFAULTTOPRIMARY), &MonitorInfo)) + MONITORINFO MonitorInfo = {sizeof(MONITORINFO)}; + if(GetWindowPlacement(Window, &win32vars.GlobalWindowPosition) && GetMonitorInfo(MonitorFromWindow(Window, MONITOR_DEFAULTTOPRIMARY), &MonitorInfo)) { SetWindowLongPtr(Window, GWL_STYLE, Style & ~WS_OVERLAPPEDWINDOW); SetWindowPos(Window, HWND_TOP, @@ -1110,16 +1109,14 @@ Win32ToggleFullscreen(void){ MonitorInfo.rcMonitor.right - MonitorInfo.rcMonitor.left, MonitorInfo.rcMonitor.bottom - MonitorInfo.rcMonitor.top, SWP_NOOWNERZORDER | SWP_FRAMECHANGED); - win32vars.full_screen = 1; + win32vars.full_screen = true; } } else{ SetWindowLongPtr(Window, GWL_STYLE, Style | WS_OVERLAPPEDWINDOW); SetWindowPlacement(Window, &win32vars.GlobalWindowPosition); - SetWindowPos(Window, 0, 0, 0, 0, 0, - SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | - SWP_NOOWNERZORDER | SWP_FRAMECHANGED); - win32vars.full_screen = 0; + SetWindowPos(Window, 0, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_FRAMECHANGED); + win32vars.full_screen = false; } } @@ -1892,6 +1889,24 @@ Win32Callback(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam){ Win32Resize(new_width, new_height); }break; + case WM_DISPLAYCHANGE: + { + win32vars.got_useful_event = 1; + + LONG_PTR style = GetWindowLongPtr(hwnd, GWL_STYLE); + if (!(style & WS_OVERLAPPEDWINDOW)){ + MONITORINFO monitor_info = {sizeof(MONITORINFO)}; + if(GetMonitorInfo(MonitorFromWindow(hwnd, MONITOR_DEFAULTTOPRIMARY), &monitor_info)) + { + SetWindowPos(hwnd, HWND_TOP, + monitor_info.rcMonitor.left, monitor_info.rcMonitor.top, + monitor_info.rcMonitor.right - monitor_info.rcMonitor.left, + monitor_info.rcMonitor.bottom - monitor_info.rcMonitor.top, + SWP_NOOWNERZORDER | SWP_FRAMECHANGED); + } + } + }break; + case WM_PAINT: { win32vars.got_useful_event = 1; diff --git a/win32_4ed_fonts.cpp b/win32_4ed_fonts.cpp index 3c13329a..f5e48b34 100644 --- a/win32_4ed_fonts.cpp +++ b/win32_4ed_fonts.cpp @@ -112,7 +112,7 @@ Sys_Font_Init_Sig(system_font_init){ u32 dir_max = KB(32); u8 *directory = push_array(scratch, u8, dir_max); String dir_str = make_string_cap(directory, 0, dir_max); - i32 dir_len = system_get_binary_path(&dir_str); + u32 dir_len = system_get_binary_path(&dir_str); Assert(dir_len < dir_max); {