From 29e3df9df681e8327163a3148af96d724f9b1887 Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Sat, 2 Dec 2017 13:04:56 -0500 Subject: [PATCH] Mac symlink problem fixed, *search* bs thingy fixed --- 4coder_default_framework.h | 1 + 4coder_generated/command_metadata.h | 18 +++++----- 4coder_search.cpp | 56 +++++++++++++++-------------- 4coder_search.h | 2 -- platform_mac/mac_4ed.cpp | 9 +++++ 5 files changed, 49 insertions(+), 37 deletions(-) diff --git a/4coder_default_framework.h b/4coder_default_framework.h index bc39b926..f338bf7e 100644 --- a/4coder_default_framework.h +++ b/4coder_default_framework.h @@ -875,6 +875,7 @@ process_config_file(Application_Links *app){ if (file == 0){ char space[256]; int32_t size = get_4ed_path(app, space, sizeof(space)); + print_message(app, space, size); String str = make_string_cap(space, size, sizeof(space)); append_sc(&str, "/config.4coder"); terminate_with_null(&str); diff --git a/4coder_generated/command_metadata.h b/4coder_generated/command_metadata.h index e11ea584..3d2adaaa 100644 --- a/4coder_generated/command_metadata.h +++ b/4coder_generated/command_metadata.h @@ -282,16 +282,16 @@ static Command_Metadata fcoder_metacmd_table[192] = { { PROC_LINKS(kill_rect, 0), "kill_rect", 9, "Delete characters in a rectangular region. Range testing is done by unwrapped-xy coordinates.", 93, "/Users/allenwebster/4ed/code/power/4coder_experiments.cpp", 57, 31 }, { PROC_LINKS(left_adjust_view, 0), "left_adjust_view", 16, "Sets the left size of the view near the x position of the cursor.", 65, "/Users/allenwebster/4ed/code/4coder_base_commands.cpp", 53, 151 }, { PROC_LINKS(list_all_functions_current_buffer, 0), "list_all_functions_current_buffer", 33, "Creates a jump list of lines of the current buffer that appear to define or declare functions.", 94, "/Users/allenwebster/4ed/code/4coder_function_list.cpp", 53, 348 }, -{ PROC_LINKS(list_all_locations, 0), "list_all_locations", 18, "Queries the user for a string and lists all exact case-sensitive matches found in all open buffers.", 99, "/Users/allenwebster/4ed/code/4coder_search.cpp", 46, 698 }, -{ PROC_LINKS(list_all_locations_case_insensitive, 0), "list_all_locations_case_insensitive", 35, "Queries the user for a string and lists all exact case-insensitive matches found in all open buffers.", 101, "/Users/allenwebster/4ed/code/4coder_search.cpp", 46, 718 }, -{ PROC_LINKS(list_all_locations_of_identifier, 0), "list_all_locations_of_identifier", 32, "Reads a token or word under the cursor and lists all exact case-sensitive mathces in all open buffers.", 102, "/Users/allenwebster/4ed/code/4coder_search.cpp", 46, 782 }, -{ PROC_LINKS(list_all_locations_of_identifier_case_insensitive, 0), "list_all_locations_of_identifier_case_insensitive", 49, "Reads a token or word under the cursor and lists all exact case-insensitive mathces in all open buffers.", 104, "/Users/allenwebster/4ed/code/4coder_search.cpp", 46, 788 }, -{ PROC_LINKS(list_all_locations_of_selection, 0), "list_all_locations_of_selection", 31, "Reads the string in the selected range and lists all exact case-sensitive mathces in all open buffers.", 102, "/Users/allenwebster/4ed/code/4coder_search.cpp", 46, 830 }, -{ PROC_LINKS(list_all_locations_of_selection_case_insensitive, 0), "list_all_locations_of_selection_case_insensitive", 48, "Reads the string in the selected range and lists all exact case-insensitive mathces in all open buffers.", 104, "/Users/allenwebster/4ed/code/4coder_search.cpp", 46, 836 }, +{ PROC_LINKS(list_all_locations, 0), "list_all_locations", 18, "Queries the user for a string and lists all exact case-sensitive matches found in all open buffers.", 99, "/Users/allenwebster/4ed/code/4coder_search.cpp", 46, 702 }, +{ PROC_LINKS(list_all_locations_case_insensitive, 0), "list_all_locations_case_insensitive", 35, "Queries the user for a string and lists all exact case-insensitive matches found in all open buffers.", 101, "/Users/allenwebster/4ed/code/4coder_search.cpp", 46, 722 }, +{ PROC_LINKS(list_all_locations_of_identifier, 0), "list_all_locations_of_identifier", 32, "Reads a token or word under the cursor and lists all exact case-sensitive mathces in all open buffers.", 102, "/Users/allenwebster/4ed/code/4coder_search.cpp", 46, 786 }, +{ PROC_LINKS(list_all_locations_of_identifier_case_insensitive, 0), "list_all_locations_of_identifier_case_insensitive", 49, "Reads a token or word under the cursor and lists all exact case-insensitive mathces in all open buffers.", 104, "/Users/allenwebster/4ed/code/4coder_search.cpp", 46, 792 }, +{ PROC_LINKS(list_all_locations_of_selection, 0), "list_all_locations_of_selection", 31, "Reads the string in the selected range and lists all exact case-sensitive mathces in all open buffers.", 102, "/Users/allenwebster/4ed/code/4coder_search.cpp", 46, 834 }, +{ PROC_LINKS(list_all_locations_of_selection_case_insensitive, 0), "list_all_locations_of_selection_case_insensitive", 48, "Reads the string in the selected range and lists all exact case-insensitive mathces in all open buffers.", 104, "/Users/allenwebster/4ed/code/4coder_search.cpp", 46, 840 }, { PROC_LINKS(list_all_locations_of_type_definition, 0), "list_all_locations_of_type_definition", 37, "Queries user for string, lists all locations of strings that appear to define a type whose name matches the input string.", 121, "/Users/allenwebster/4ed/code/4coder_default_include.cpp", 55, 454 }, { PROC_LINKS(list_all_locations_of_type_definition_of_identifier, 0), "list_all_locations_of_type_definition_of_identifier", 51, "Reads a token or word under the cursor and lists all locations of strings that appear to define a type whose name matches it.", 125, "/Users/allenwebster/4ed/code/4coder_default_include.cpp", 55, 466 }, -{ PROC_LINKS(list_all_substring_locations, 0), "list_all_substring_locations", 28, "Queries the user for a string and lists all case-sensitive substring matches found in all open buffers.", 103, "/Users/allenwebster/4ed/code/4coder_search.cpp", 46, 708 }, -{ PROC_LINKS(list_all_substring_locations_case_insensitive, 0), "list_all_substring_locations_case_insensitive", 45, "Queries the user for a string and lists all case-insensitive substring matches found in all open buffers.", 105, "/Users/allenwebster/4ed/code/4coder_search.cpp", 46, 728 }, +{ PROC_LINKS(list_all_substring_locations, 0), "list_all_substring_locations", 28, "Queries the user for a string and lists all case-sensitive substring matches found in all open buffers.", 103, "/Users/allenwebster/4ed/code/4coder_search.cpp", 46, 712 }, +{ PROC_LINKS(list_all_substring_locations_case_insensitive, 0), "list_all_substring_locations_case_insensitive", 45, "Queries the user for a string and lists all case-insensitive substring matches found in all open buffers.", 105, "/Users/allenwebster/4ed/code/4coder_search.cpp", 46, 732 }, { PROC_LINKS(load_project, 0), "load_project", 12, "Looks for a project.4coder file in the current directory and tries to load it. Looks in parent directories until a project file is found or there are no more parents.", 167, "/Users/allenwebster/4ed/code/4coder_project_commands.cpp", 56, 408 }, { PROC_LINKS(make_directory_query, 0), "make_directory_query", 20, "Queries the user for a name and creates a new directory with the given name.", 76, "/Users/allenwebster/4ed/code/4coder_base_commands.cpp", 53, 1130 }, { PROC_LINKS(miblo_decrement_basic, 0), "miblo_decrement_basic", 21, "Decrement an integer under the cursor by one.", 45, "/Users/allenwebster/4ed/code/power/4coder_miblo_numbers.cpp", 59, 119 }, @@ -393,7 +393,7 @@ static Command_Metadata fcoder_metacmd_table[192] = { { PROC_LINKS(toggle_virtual_whitespace, 0), "toggle_virtual_whitespace", 25, "Toggles the current buffer's virtual whitespace status.", 55, "/Users/allenwebster/4ed/code/4coder_base_commands.cpp", 53, 627 }, { PROC_LINKS(undo, 0), "undo", 4, "Advances backwards through the undo history.", 44, "/Users/allenwebster/4ed/code/4coder_base_commands.cpp", 53, 1165 }, { PROC_LINKS(view_buffer_other_panel, 0), "view_buffer_other_panel", 23, "Set the other non-active panel to view the buffer that the active panel views, and switch to that panel.", 104, "/Users/allenwebster/4ed/code/4coder_default_include.cpp", 55, 721 }, -{ PROC_LINKS(word_complete, 0), "word_complete", 13, "Iteratively tries completing the word to the left of the cursor with other words in open buffers that have the same prefix string.", 130, "/Users/allenwebster/4ed/code/4coder_search.cpp", 46, 859 }, +{ PROC_LINKS(word_complete, 0), "word_complete", 13, "Iteratively tries completing the word to the left of the cursor with other words in open buffers that have the same prefix string.", 130, "/Users/allenwebster/4ed/code/4coder_search.cpp", 46, 863 }, { PROC_LINKS(write_and_auto_tab, 0), "write_and_auto_tab", 18, "Inserts a character and auto-indents the line on which the cursor sits.", 71, "/Users/allenwebster/4ed/code/4coder_auto_indent.cpp", 51, 683 }, { PROC_LINKS(write_block, 0), "write_block", 11, "At the cursor, insert a block comment.", 38, "/Users/allenwebster/4ed/code/4coder_default_include.cpp", 55, 584 }, { PROC_LINKS(write_character, 0), "write_character", 15, "Inserts whatever character was used to trigger this command.", 60, "/Users/allenwebster/4ed/code/4coder_base_commands.cpp", 53, 47 }, diff --git a/4coder_search.cpp b/4coder_search.cpp index 677561b8..19613de7 100644 --- a/4coder_search.cpp +++ b/4coder_search.cpp @@ -403,7 +403,7 @@ search_next_match(Application_Links *app, Search_Set *set, Search_Iter *it_ptr){ Search_Iter iter = *it_ptr; int32_t count = set->count; - for (; iter.i < count;){ + for (;iter.i < count;){ Search_Range *range = set->ranges + iter.i; int32_t find_result = FindResult_None; @@ -413,7 +413,7 @@ search_next_match(Application_Links *app, Search_Set *set, Search_Iter *it_ptr){ switch (range->type){ case SearchRange_BackToFront: { - iter.back_pos = range->start+range->size-1; + iter.back_pos = range->start + range->size-1; }break; case SearchRange_Wave: @@ -547,39 +547,43 @@ initialize_generic_search_all_buffers(Application_Links *app, General_Memory *ge } if (!skip){ - ranges[0].type = SearchRange_FrontToBack; - ranges[0].flags = match_flags; - ranges[0].buffer = buffer.buffer_id; - ranges[0].start = 0; - ranges[0].size = buffer.size; - j = 1; + ranges[j].type = SearchRange_FrontToBack; + ranges[j].flags = match_flags; + ranges[j].buffer = buffer.buffer_id; + ranges[j].start = 0; + ranges[j].size = buffer.size; + ++j; } } for (Buffer_Summary buffer_it = get_buffer_first(app, AccessAll); buffer_it.exists; get_buffer_next(app, &buffer_it, AccessAll)){ - if (buffer.buffer_id != buffer_it.buffer_id){ - bool32 skip = false; - for (int32_t i = 0; i < skip_buffer_count; ++i){ - if (buffer.buffer_id == skip_buffers[i]){ - skip = true; - break; - } - } - - if (!skip){ - if (buffer_it.buffer_name[0] != '*'){ - ranges[j].type = SearchRange_FrontToBack; - ranges[j].flags = match_flags; - ranges[j].buffer = buffer_it.buffer_id; - ranges[j].start = 0; - ranges[j].size = buffer_it.size; - ++j; - } + if (buffer_it.buffer_id == buffer.buffer_id){ + continue; + } + + bool32 skip = false; + for (int32_t i = 0; i < skip_buffer_count; ++i){ + if (buffer_it.buffer_id == skip_buffers[i]){ + skip = true; + break; } } + + if (!skip){ + if (buffer_it.buffer_name[0] != '*'){ + ranges[j].type = SearchRange_FrontToBack; + ranges[j].flags = match_flags; + ranges[j].buffer = buffer_it.buffer_id; + ranges[j].start = 0; + ranges[j].size = buffer_it.size; + ++j; + } + } + } + set->count = j; } diff --git a/4coder_search.h b/4coder_search.h index 06b8c0f3..a0bcc5b6 100644 --- a/4coder_search.h +++ b/4coder_search.h @@ -43,10 +43,8 @@ struct Search_Set{ struct Search_Key{ char *base; int32_t base_size; - String words[16]; int32_t count; - int32_t min_size; }; diff --git a/platform_mac/mac_4ed.cpp b/platform_mac/mac_4ed.cpp index a264a933..205e45e3 100644 --- a/platform_mac/mac_4ed.cpp +++ b/platform_mac/mac_4ed.cpp @@ -120,14 +120,23 @@ Sys_Get_4ed_Path_Sig(system_get_4ed_path){ i32 size = 0; u32 buf_size = capacity; i32 status = _NSGetExecutablePath(temp_buffer, &buf_size); + buf_size = str_size(temp_buffer); if (status == 0){ ssize_t ln_len = readlink(temp_buffer, out, capacity); if (ln_len != -1){ + out[ln_len] = 0; String str = make_string_cap(out, ln_len, capacity); remove_last_folder(&str); terminate_with_null(&str); size = str.size; } + else{ + memcpy(out, temp_buffer, buf_size); + String str = make_string_cap(out, buf_size, capacity); + remove_last_folder(&str); + terminate_with_null(&str); + size = str.size; + } } end_temp_memory(temp); return(size);