From 05027b9ef0c9600242a7a230bb74fa78dbfc1836 Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Sun, 18 Oct 2020 17:44:01 -0700 Subject: [PATCH 1/9] [code index] put notes into a hash table --- custom/4coder_casey_index.cpp | 708 ++++++++++++++++++++++++++++ custom/4coder_casey_index.h | 100 ++++ custom/4coder_code_index.cpp | 126 +++-- custom/4coder_code_index.h | 5 + custom/4coder_command_map.h | 2 +- custom/4coder_default_hooks.cpp | 19 + custom/4coder_search.cpp | 2 +- custom/generated/command_metadata.h | 496 +++++++++---------- platform_win32/win32_4ed.cpp | 9 +- 9 files changed, 1177 insertions(+), 290 deletions(-) create mode 100644 custom/4coder_casey_index.cpp create mode 100644 custom/4coder_casey_index.h diff --git a/custom/4coder_casey_index.cpp b/custom/4coder_casey_index.cpp new file mode 100644 index 00000000..d4d333d3 --- /dev/null +++ b/custom/4coder_casey_index.cpp @@ -0,0 +1,708 @@ +static Content_Index *global_content_index = 0; + +internal String get_name_of_index_type(Indexed_Content_Element_Type content_type) +{ + String result = {}; + + switch(content_type) + { + case ContentType_Unspecified: {result = make_lit_string("Unspecified");} break; + + case ContentType_Function: {result = make_lit_string("Function");} break; + case ContentType_Type: {result = make_lit_string("Type");} break; + case ContentType_Macro: {result = make_lit_string("Macro");} break; + case ContentType_EnumValue: {result = make_lit_string("Enum Value");} break; + case ContentType_ForwardDeclaration: {result = make_lit_string("Forward Declaration");} break; + + case ContentType_TODO: {result = make_lit_string("TODO");} break; + case ContentType_NOTE: {result = make_lit_string("Note");} break; + case ContentType_IMPORTANT: {result = make_lit_string("Important");} break; + case ContentType_STUDY: {result = make_lit_string("Study");} break; + } + + return(result); +} + +static Content_Index * +create_content_index(Application_Links *app) +{ + // TODO(casey): I really just want this to be its own allocating arena, but I can't find anything like that in 4coder? + // All arenas seem to be fixed size and they can't get more memory if they run out :( + Content_Index *index = (Content_Index *)malloc(sizeof(Content_Index)); + + memset(index, 0, sizeof(*index)); + + return(index); +} + +static Indexed_Content_Element ** +get_element_slot_for_name(Content_Index *index, String name) +{ + Indexed_Content_Element **slot = &index->name_hash[table_hash_u8((uint8_t *)name.str, name.size) % ArrayCount(index->name_hash)]; + return(slot); +} + +static Indexed_Buffer * +get_or_create_indexed_buffer(Content_Index *index, Buffer_ID buffer_id) +{ + Indexed_Buffer *result = 0; + + Indexed_Buffer **slot = &index->buffer_hash[buffer_id % ArrayCount(index->buffer_hash)]; + for(Indexed_Buffer *search = *slot; + search; + search = search->next_in_hash) + { + if(search->buffer_id == buffer_id) + { + result = search; + break; + } + } + + if(!result) + { + result = (Indexed_Buffer *)malloc(sizeof(Indexed_Buffer)); + result->buffer_id = buffer_id; + result->first_tag = 0; + result->next_in_hash = *slot; + *slot = result; + } + + return(result); +} + +static color_pair +get_color_pair_for(Indexed_Content_Element_Type type) +{ + color_pair result = {}; + + switch(type) + { + case ContentType_Function: + { + result.fore = CC_Function; + } break; + + case ContentType_Type: + { + result.fore = CC_Type; + } break; + + case ContentType_Macro: + { + result.fore = CC_Macro; + } break; + + case ContentType_EnumValue: + { + result.fore = CC_EnumValue; + } break; + + case ContentType_ForwardDeclaration: + { + result.fore = CC_ForwardDeclaration; + } break; + + case ContentType_TODO: + { + result.fore = CC_TODO; + } break; + + case ContentType_NOTE: + { + result.fore = CC_NOTE; + } break; + + case ContentType_IMPORTANT: + { + result.fore = CC_IMPORTANT; + } break; + + case ContentType_STUDY: + { + result.fore = CC_STUDY; + } break; + } + + return(result); +} + +static Indexed_Content_Element * +begin_element_in_index(Content_Index *index, Indexed_Content_Element_Type type, Buffer_ID buffer_id, int32_t location, + int32_t name_size, int32_t content_size) +{ + Indexed_Content_Element *elem = 0; + + // TODO(casey): I really just want this to be its own allocating arena, but I can't find anything like that in 4coder? + // All arenas seem to be fixed size and they can't get more memory if they run out :( + uint8_t *mem = (uint8_t *)malloc(sizeof(Indexed_Content_Element) + name_size + content_size); + if(mem) + { + elem = (Indexed_Content_Element *)mem; + + elem->next_in_hash = 0; + elem->type = type; + elem->name.memory_size = elem->name.size = name_size; + elem->name.str = (char *)(elem + 1); + elem->content.memory_size = elem->content.size = content_size; + elem->content.str = elem->name.str + name_size; + + elem->color = get_color_pair_for(type); + + elem->buffer_id = buffer_id; + elem->last_known_location = location; + + index->total_string_space += name_size + content_size; + ++index->element_count; + } + + return(elem); +} + +static void +end_element_in_index(Content_Index *index, Indexed_Content_Element *elem, u32 flags) +{ + if(elem) + { + // NOTE(casey): By convention, we make content into a single line, and remove leading/trailing whitespace + condense_whitespace(&elem->name); + condense_whitespace(&elem->content); + + Indexed_Content_Element **slot = &index->unhashed; + if(!(flags & IndexFlag_NoNameLookup)) + { + slot = get_element_slot_for_name(index, elem->name); + } + elem->next_in_hash = *slot; + *slot = elem; + + Indexed_Buffer *buffer = get_or_create_indexed_buffer(index, elem->buffer_id); + ++buffer->element_type_counts[elem->type]; + ++index->element_type_counts[elem->type]; + } +} + +static Indexed_Content_Element * +add_element_to_index(Application_Links *app, Content_Index *index, Indexed_Content_Element_Type type, Buffer_Summary *buffer, int32_t location, + int32_t name_start, int32_t name_end, + int32_t content_start, int32_t content_end, + u32 flags = 0) +{ + Indexed_Content_Element *elem = 0; + if((name_start <= name_end) && + (content_start <= content_end)) + { + elem = begin_element_in_index(index, type, buffer->buffer_id, location, name_end - name_start, content_end - content_start); + if(elem) + { + buffer_read_range(app, buffer, name_start, name_end, elem->name.str); + buffer_read_range(app, buffer, content_start, content_end, elem->content.str); + end_element_in_index(index, elem, flags); + } + } + + return(elem); +} + +static Indexed_Content_Element * +add_element_to_index(Content_Index *index, Indexed_Content_Element_Type type, Buffer_ID buffer_id, int32_t location, String name, String content, + u32 flags = 0) +{ + Indexed_Content_Element *elem = begin_element_in_index(index, type, buffer_id, location, name.size, content.size); + if(elem) + { + copy_ss(&elem->name, name); + copy_ss(&elem->content, content); + end_element_in_index(index, elem, flags); + } + + return(elem); +} + +static Indexed_Content_Tag * +add_tag_to_index(Content_Index *index, Buffer_Summary *buffer, uint32_t type, int32_t start, int32_t end, String content) +{ + Indexed_Content_Tag *tag = 0; + + if(start <= end) + { + Indexed_Buffer *index_buffer = get_or_create_indexed_buffer(index, buffer->buffer_id); + // TODO(casey): I really just want this to be its own allocating arena, but I can't find anything like that in 4coder? + // All arenas seem to be fixed size and they can't get more memory if they run out :( + uint8_t *mem = (uint8_t *)malloc(sizeof(Indexed_Content_Tag) + content.size); + if(mem) + { + tag = (Indexed_Content_Tag *)mem; + tag->content.size = tag->content.memory_size = content.size; + tag->content.str = (char *)(tag + 1); + copy_ss(&tag->content, content); + tag->type = type; + tag->start = start; + tag->end = end; + tag->next_in_buffer = index_buffer->first_tag; + index_buffer->first_tag = tag; + } + } + + return(tag); +} + +static Indexed_Content_Element * +get_element_by_name(Content_Index *index, String name) +{ + Indexed_Content_Element *result = 0; + + if(index) + { + for(Indexed_Content_Element *elem = *get_element_slot_for_name(index, name); + elem; + elem = elem->next_in_hash) + { + if(compare_ss(elem->name, name) == 0) + { + result = elem; + break; + } + } + } + + return(result); +} + +static void +remove_buffer_from_index(Application_Links *app, Content_Index *index, Buffer_ID buffer_id) +{ + for(int hash_index = 0; + hash_index <= ArrayCount(index->name_hash); + ++hash_index) + { + for(Indexed_Content_Element **elem_ptr = &index->name_hash[hash_index]; + *elem_ptr; + ) + { + Indexed_Content_Element *elem = *elem_ptr; + if(elem->buffer_id == buffer_id) + { + *elem_ptr = elem->next_in_hash; + free(elem); + } + else + { + elem_ptr = &elem->next_in_hash; + } + } + } + + Indexed_Buffer *index_buffer = get_or_create_indexed_buffer(index, buffer_id); + while(index_buffer->first_tag) + { + Indexed_Content_Tag *tag = index_buffer->first_tag; + index_buffer->first_tag = tag->next_in_buffer; + free(tag); + } + + for(u32 type_index = 0; + type_index < ContentType_Count; + ++type_index) + { + index->element_type_counts[type_index] -= index_buffer->element_type_counts[type_index]; + index_buffer->element_type_counts[type_index] = 0; + } +} + +static void +add_buffer_to_index(Application_Links *app, Content_Index *index, Buffer_Summary *buffer) +{ + ++index->buffer_count; + + Token_Iterator iter = iterate_tokens(app, buffer, 0); + + int32_t paren_level = 0; + int32_t brace_level = 0; + + while(iter.valid) + { + Cpp_Token token = get_next_token(app, &iter); + + if(token.flags & CPP_TFLAG_PP_BODY) + { + // TODO(casey): Do we need to pick up macros here? + } + else + { + switch(token.type) + { + case CPP_TOKEN_COMMENT: + { + // NOTE(casey): Comments can contain special operations that we want to perform, so we thunk to a special parser to handle those + parse_comment(app, index, buffer, token); + } break; + + case CPP_PP_DEFINE: + { + int32_t content_start = token.start; + token = get_next_token(app, &iter); + + // TODO(casey): Allen, how do I scan for the next "not continued newline"? + int32_t content_end = token.start + token.size; + + add_element_to_index(app, index, ContentType_Macro, buffer, token.start, + token.start, token.start + token.size, + content_start, content_end); + } break; + + case CPP_TOKEN_KEY_TYPE_DECLARATION: + { + bool32 forward_declaration = true; + int32_t content_start = token.start; + Cpp_Token element_name = {}; + Cpp_Token last_identifier = {}; + + String typedef_keyword = make_lit_string("typedef"); + if(token_text_is(app, buffer, token, typedef_keyword)) + { + // NOTE(casey): Typedefs can't be "forward declared", so we always record their location. + forward_declaration = false; + + // NOTE(casey): This is a simple "usually works" parser for typedefs. It is well-known that C grammar + // doesn't actually allow you to parse typedefs properly without actually knowing the declared types + // at the time, which of course we cannot do since we parse per-file, and don't even know things we + // would need (like -D switches, etc.) + + // TODO(casey): If eventually this were upgraded to a more thoughtful parser, struct/union/enum defs + // would be parsed from brace to brace, so they could be handled recursively inside of a typedef for + // the pattern "typedef struct {} foo;", which currently we do not handle (we ignore the foo). + int typedef_paren_level = 0; + while(iter.valid) + { + token = get_next_token(app, &iter); + if(token.type == CPP_TOKEN_IDENTIFIER) + { + last_identifier = token; + } + else if(token.type == CPP_TOKEN_PARENTHESE_OPEN) + { + if(typedef_paren_level == 0) + { + // NOTE(casey): If we are going back into a parenthetical, it means that whatever the last + // identifier we saw is our best candidate. + element_name = last_identifier; + } + ++typedef_paren_level; + } + else if(token.type == CPP_TOKEN_PARENTHESE_CLOSE) + { + --typedef_paren_level; + } + else if(token.type == CPP_TOKEN_KEY_TYPE_DECLARATION) + { + // TODO(casey): If we _really_ wanted to, we could parse the type here recursively, + // and then we could capture things that were named differently a la "typedef struct foo {...} bar;" + // but I think that should wait until the 4coder parser is more structural, because I don't + // know how much parsing we _really_ want to do here. + forward_declaration = true; + break; + } + else if(token.type == CPP_TOKEN_SEMICOLON) + { + break; + } + } + + if(element_name.size == 0) + { + element_name = last_identifier; + } + } + + if(!element_name.size) + { + while(iter.valid) + { + token = peek_token(app, &iter); + if(token.type == CPP_TOKEN_IDENTIFIER) + { + element_name = token; + get_next_token(app, &iter); + } + else if((token.type == CPP_TOKEN_KEY_MODIFIER) || + (token.type == CPP_TOKEN_KEY_QUALIFIER) || + (token.type == CPP_TOKEN_KEY_ACCESS) || + (token.type == CPP_TOKEN_KEY_LINKAGE)) + { + // NOTE(casey): Let it go. + get_next_token(app, &iter); + } + else if(token.type == CPP_TOKEN_BRACE_OPEN) + { + // NOTE(casey): It's probably type definition + forward_declaration = false; + break; + } + else + { + // NOTE(casey): It's probably a forward declaration + break; + } + } + } + + int32_t content_end = token.start; + + if(element_name.size) + { + Indexed_Content_Element_Type type = ContentType_Type; + if(forward_declaration) + { + type = ContentType_ForwardDeclaration; + } + + add_element_to_index(app, index, type, buffer, element_name.start, + element_name.start, element_name.start + element_name.size, + content_start, content_end); + } + } break; + + case CPP_TOKEN_PARENTHESE_OPEN: + { + ++paren_level; + } break; + + case CPP_TOKEN_PARENTHESE_CLOSE: + { + --paren_level; + } break; + + case CPP_TOKEN_BRACE_OPEN: + { + if((paren_level == 0) && + (brace_level == 0)) + { + // NOTE(casey): This is presumably a function, see if we can find it's name. + int32_t content_end = token.start; + int32_t content_start = content_end; + int32_t name_start = 0; + int32_t name_end = 0; + + Token_Iterator back = iter; + get_prev_token(app, &back); + get_prev_token(app, &back); + Cpp_Token comment_pass = get_prev_token(app, &back); + while(comment_pass.type == CPP_TOKEN_COMMENT) + { + comment_pass = get_prev_token(app, &back); + } + if(comment_pass.type == CPP_TOKEN_PARENTHESE_CLOSE) + { + paren_level = -1; + while(back.valid) + { + if(token.type != CPP_TOKEN_COMMENT) + { + content_start = token.start; + } + token = get_prev_token(app, &back); + if((paren_level == 0) && + (brace_level == 0) && + ((token.flags & CPP_TFLAG_PP_BODY) || + (token.type == CPP_TOKEN_BRACE_CLOSE) || + (token.type == CPP_TOKEN_SEMICOLON) || + (token.type == CPP_TOKEN_EOF))) + { + break; + } + else + { + switch(token.type) + { + case CPP_TOKEN_PARENTHESE_OPEN: + { + ++paren_level; + } break; + + case CPP_TOKEN_PARENTHESE_CLOSE: + { + --paren_level; + } break; + + case CPP_TOKEN_BRACE_OPEN: + { + ++brace_level; + } break; + + case CPP_TOKEN_BRACE_CLOSE: + { + --brace_level; + } break; + + case CPP_TOKEN_IDENTIFIER: + { + if((paren_level == 0) && + (brace_level == 0) && + (name_start == 0)) + { + name_start = token.start; + name_end = token.start + token.size; + Token_Iterator probe = back; + get_next_token(app, &probe); + for(;;) + { + Cpp_Token test = get_next_token(app, &probe); + if((test.type == 0) || + (test.type == CPP_TOKEN_EOF) || + (test.type == CPP_TOKEN_PARENTHESE_CLOSE) || + (test.type == CPP_TOKEN_PARENTHESE_OPEN)) + { + name_end = test.start; + break; + } + } + } + } break; + } + } + } + + if(name_start < name_end) + { + Indexed_Content_Element_Type type = ContentType_Function; + add_element_to_index(app, index, type, buffer, name_start, + name_start, name_end, + content_start, content_end); + } + + brace_level = 0; + paren_level = 0; + } + } + + ++brace_level; + } break; + + case CPP_TOKEN_BRACE_CLOSE: + { + --brace_level; + } break; + } + } + } +} + +static void +add_all_buffers_to_index(Application_Links *app, Content_Index *index) +{ + for(Buffer_Summary buffer = get_buffer_first(app, AccessAll); + buffer.exists; + get_buffer_next(app, &buffer, AccessAll)) + { + int32_t Unimportant = true; + buffer_get_setting(app, &buffer, BufferSetting_Unimportant, &Unimportant); + + if(buffer.tokens_are_ready && !Unimportant) + { + add_buffer_to_index(app, index, &buffer); + } + } +} + +static void +update_index_for_buffer(Application_Links *app, Content_Index *index, Buffer_Summary *buffer) +{ + remove_buffer_from_index(app, index, buffer->buffer_id); + add_buffer_to_index(app, index, buffer); +} + +static Content_Index * +get_global_content_index(Application_Links *app) +{ + Content_Index *result = global_content_index; + if(!result) + { + global_content_index = create_content_index(app); + add_all_buffers_to_index(app, global_content_index); + result = global_content_index; + } + + return(result); +} + +static void +jump_to_element(Application_Links *app, View_Summary *view, Indexed_Content_Element *elem) +{ + if (view->buffer_id != elem->buffer_id) + { + view_set_buffer(app, view, elem->buffer_id, 0); + } + Buffer_Seek seek; + seek.type = buffer_seek_pos; + seek.pos = elem->last_known_location;; + view_set_cursor(app, view, seek, true); +} + +static void +jump_to_element_activate(Application_Links *app, Partition *scratch, Heap *heap, + View_Summary *view, Lister_State *state, + String text_field, void *user_data, bool32 activated_by_mouse) +{ + lister_default(app, scratch, heap, view, state, ListerActivation_Finished); + if(user_data) + { + jump_to_element(app, view, (Indexed_Content_Element *)user_data); + } +} + +typedef bool32 element_type_predicate(Application_Links *app, Content_Index *index, Indexed_Content_Element *elem, void *user_data); + +static bool32 +element_is_definition(Application_Links *app, Content_Index *index, Indexed_Content_Element *elem, void *user_data) +{ + bool32 result = ((elem->type == ContentType_Function) || + (elem->type == ContentType_Type) || + (elem->type == ContentType_Macro) || + (elem->type == ContentType_EnumValue)); + return(result); +} + +static bool32 +element_type_equals(Application_Links *app, Content_Index *index, Indexed_Content_Element *elem, void *user_data) +{ + bool32 result = (elem->type == (uint64_t)user_data); + return(result); +} + +static void +jump_to_element_lister(Application_Links *app, char *Label, element_type_predicate *predicate, void *user_data = 0) +{ + Partition *arena = &global_part; + + View_Summary view = get_active_view(app, AccessAll); + view_end_ui_mode(app, &view); + Temp_Memory temp = begin_temp_memory(arena); + + Content_Index *index = get_global_content_index(app); + + Lister_Option *options = push_array(arena, Lister_Option, index->element_count); + int32_t option_index = 0; + for(int hash_index = 0; + hash_index <= ArrayCount(index->name_hash); + ++hash_index) + { + for(Indexed_Content_Element *elem = index->name_hash[hash_index]; + elem; + elem = elem->next_in_hash) + { + if(predicate(app, index, elem, user_data)) + { + options[option_index].text_color = get_color(elem->color.fore); + options[option_index].pop_color = get_color(CC_DefaultText); + options[option_index].back_color = get_color(elem->color.back); + options[option_index].string = elem->name; + options[option_index].status = elem->content; + options[option_index].user_data = elem; + ++option_index; + } + } + } + begin_integrated_lister__basic_list(app, Label, jump_to_element_activate, 0, 0, options, option_index, index->total_string_space, &view); + end_temp_memory(temp); +} diff --git a/custom/4coder_casey_index.h b/custom/4coder_casey_index.h new file mode 100644 index 00000000..0ca1c552 --- /dev/null +++ b/custom/4coder_casey_index.h @@ -0,0 +1,100 @@ +/* date = October 18th 2020 3:41 pm */ + +#ifndef FCODER_CASEY_INDEX_H +#define FCODER_CASEY_INDEX_H + +struct color_pair +{ + casey_color_id fore; + casey_color_id back; +}; + +enum Indexed_Content_Element_Type +{ + ContentType_Unspecified, + + ContentType_Function, + ContentType_Type, + ContentType_Macro, + ContentType_EnumValue, + ContentType_ForwardDeclaration, + + ContentType_TODO, + ContentType_NOTE, + ContentType_IMPORTANT, + ContentType_STUDY, + + ContentType_Count, +}; + +struct Indexed_Content_Element +{ + Indexed_Content_Element *next_in_hash; + uint32_t type; + + String name; + String content; + + color_pair color; + + Buffer_ID buffer_id; + int32_t last_known_location; +}; + +enum Indexed_Content_Flag +{ + IndexFlag_NoNameLookup = 0x1, +}; + +enum Indexed_Content_Tag_Type +{ + TagType_Unspecified , + + TagType_Label, + TagType_Scope, + TagType_Highlight, +}; +struct Indexed_Content_Tag +{ + Indexed_Content_Tag *next_in_buffer; + String content; + + uint32_t type; + int32_t start; + int32_t end; + + color_pair color; +}; + +struct Indexed_Buffer +{ + Indexed_Buffer *next_in_hash; + Buffer_ID buffer_id; + + int32_t element_type_counts[ContentType_Count]; + + // TODO(casey): I really want a growable arena here, so I don't have to manage this memory. Everything + // gets cleared by buffer. + + // TODO(casey): This should be a spatial query so it is more scalable + Indexed_Content_Tag *first_tag; +}; + +struct Content_Index +{ + int32_t buffer_count; + int32_t element_count; + int32_t total_string_space; + + int32_t element_type_counts[ContentType_Count]; + + Indexed_Buffer *buffer_hash[257]; + + // NOTE(casey): unhashed _must_ come immediately aftter name_hash, as they are treated as contiguous + // { + Indexed_Content_Element *name_hash[4099]; + Indexed_Content_Element *unhashed; + // } +}; + +#endif //4CODER_CASEY_INDEX_H diff --git a/custom/4coder_code_index.cpp b/custom/4coder_code_index.cpp index 48fd978e..37dfc064 100644 --- a/custom/4coder_code_index.cpp +++ b/custom/4coder_code_index.cpp @@ -6,6 +6,63 @@ global Code_Index global_code_index = {}; +//////////////////////////////// +// NOTE(allen): Lookups + +// TODO(allen): accelerator for these nest lookups? +// Looks like the only one I ever actually use is the file one, not the array one. +function Code_Index_Nest* +code_index_get_nest_(Code_Index_Nest_Ptr_Array *array, i64 pos){ + Code_Index_Nest *result = 0; + i32 count = array->count; + Code_Index_Nest **nest_ptrs = array->ptrs; + for (i32 i = 0; i < count; i += 1){ + Code_Index_Nest *nest = nest_ptrs[i]; + if (nest->open.max <= pos && pos <= nest->close.min){ + Code_Index_Nest *sub_nest = code_index_get_nest_(&nest->nest_array, pos); + if (sub_nest != 0){ + result = sub_nest; + } + else{ + result = nest; + } + break; + } + } + return(result); +} + +function Code_Index_Nest* +code_index_get_nest(Code_Index_File *file, i64 pos){ + return(code_index_get_nest_(&file->nest_array, pos)); +} + +function Code_Index_Note_List* +code_index__list_from_string(String_Const_u8 string){ + u64 hash = table_hash_u8(string.str, string.size); + Code_Index_Note_List *result = &global_code_index.name_hash[hash % ArrayCount(global_code_index.name_hash)]; + return(result); +} + +function Code_Index_Note* +code_index_note_from_string(String_Const_u8 string){ + Code_Index_Note_List *list = code_index__list_from_string(string); + Code_Index_Note *result = 0; + for (Code_Index_Note *node = list->first; + node != 0; + node = node->next_in_hash){ + if (string_match(string, node->text)){ + result = node; + break; + } + } + return(result); +} + + +//////////////////////////////// +// NOTE(allen): Global Code Index + function void code_index_init(void){ global_code_index.mutex = system_mutex_make(); @@ -80,6 +137,28 @@ code_index_unlock(void){ system_mutex_release(global_code_index.mutex); } +function void +code_index__hash_file(Code_Index_File *file){ + for (Code_Index_Note *node = file->note_list.first; + node != 0; + node = node->next){ + Code_Index_Note_List *list = code_index__list_from_string(node->text); + zdll_push_back_NP_(list->first, list->last, node, next_in_hash, prev_in_hash); + list->count += 1; + } +} + +function void +code_index__clear_file(Code_Index_File *file){ + for (Code_Index_Note *node = file->note_list.first; + node != 0; + node = node->next){ + Code_Index_Note_List *list = code_index__list_from_string(node->text); + zdll_remove_NP_(list->first, list->last, node, next_in_hash, prev_in_hash); + list->count -= 1; + } +} + function void code_index_set_file(Buffer_ID buffer, Arena arena, Code_Index_File *index){ Code_Index_File_Storage *storage = 0; @@ -88,6 +167,7 @@ code_index_set_file(Buffer_ID buffer, Arena arena, Code_Index_File *index){ u64 val = 0; table_read(&global_code_index.buffer_to_index_file, lookup, &val); storage = (Code_Index_File_Storage*)IntAsPtr(val); + code_index__clear_file(storage->file); linalloc_clear(&storage->arena); } else{ @@ -96,6 +176,8 @@ code_index_set_file(Buffer_ID buffer, Arena arena, Code_Index_File *index){ } storage->arena = arena; storage->file = index; + + code_index__hash_file(index); } function void @@ -105,6 +187,9 @@ code_index_erase_file(Buffer_ID buffer){ u64 val = 0; table_read(&global_code_index.buffer_to_index_file, lookup, &val); Code_Index_File_Storage *storage = (Code_Index_File_Storage*)IntAsPtr(val); + + code_index__clear_file(storage->file); + linalloc_clear(&storage->arena); table_erase(&global_code_index.buffer_to_index_file, lookup); code_index__free_storage(storage); @@ -124,38 +209,6 @@ code_index_get_file(Buffer_ID buffer){ return(result); } -function Code_Index_Nest* -code_index_get_nest(Code_Index_Nest_Ptr_Array *array, i64 pos){ - Code_Index_Nest *result = 0; - i32 count = array->count; - Code_Index_Nest **nest_ptrs = array->ptrs; - for (i32 i = 0; i < count; i += 1){ - Code_Index_Nest *nest = nest_ptrs[i]; - if (nest->open.max <= pos && pos <= nest->close.min){ - Code_Index_Nest *sub_nest = - code_index_get_nest(&nest->nest_array, pos); - if (sub_nest != 0){ - result = sub_nest; - } - else{ - result = nest; - } - break; - } - } - return(result); -} - -function Code_Index_Nest* -code_index_get_nest(Code_Index_Nest *nest, i64 pos){ - return(code_index_get_nest(&nest->nest_array, pos)); -} - -function Code_Index_Nest* -code_index_get_nest(Code_Index_File *file, i64 pos){ - return(code_index_get_nest(&file->nest_array, pos)); -} - function void index_shift(i64 *ptr, Range_i64 old_range, u64 new_size){ i64 i = *ptr; @@ -189,7 +242,9 @@ code_index_shift(Code_Index_File *file, Range_i64 old_range, u64 new_size){ code_index_shift(&file->nest_array, old_range, new_size); } + //////////////////////////////// +// NOTE(allen): Parser Helpers function void generic_parse_inc(Generic_Parse_State *state){ @@ -239,6 +294,7 @@ generic_parse_init(Application_Links *app, Arena *arena, String_Const_u8 content } //////////////////////////////// +// NOTE(allen): Parser #if 0 /* @@ -271,8 +327,6 @@ function: >"(" ["(" ")" | * - ("(" | ")")] ")" ("{" | ";") */ #endif -//////////////////////////////// - function Code_Index_Note* index_new_note(Code_Index_File *index, Generic_Parse_State *state, Range_i64 range, Code_Index_Note_Kind kind, Code_Index_Nest *parent){ Code_Index_Note *result = push_array(state->arena, Code_Index_Note, 1); @@ -757,7 +811,9 @@ generic_parse_full_input_breaks(Code_Index_File *index, Generic_Parse_State *sta return(result); } + //////////////////////////////// +// NOTE(allen): Not sure function void default_comment_index(Application_Links *app, Arena *arena, Code_Index_File *index, Token *token, String_Const_u8 contents){ @@ -769,7 +825,9 @@ generic_parse_init(Application_Links *app, Arena *arena, String_Const_u8 content generic_parse_init(app, arena, contents, tokens, default_comment_index, state); } + //////////////////////////////// +// NOTE(allen): Virtual Whitespace Layout function Token_Pair layout_token_pair(Token_Array *tokens, i64 pos){ diff --git a/custom/4coder_code_index.h b/custom/4coder_code_index.h index 3e75c258..1b99f78e 100644 --- a/custom/4coder_code_index.h +++ b/custom/4coder_code_index.h @@ -56,6 +56,9 @@ struct Code_Index_Note{ String_Const_u8 text; struct Code_Index_File *file; Code_Index_Nest *parent; + + Code_Index_Note *prev_in_hash; + Code_Index_Note *next_in_hash; }; struct Code_Index_Note_List{ @@ -92,6 +95,8 @@ struct Code_Index{ Code_Index_File_Storage *storage_first; Code_Index_File_Storage *storage_last; i32 storage_count; + + Code_Index_Note_List name_hash[4099]; }; //////////////////////////////// diff --git a/custom/4coder_command_map.h b/custom/4coder_command_map.h index 00fad919..97583e85 100644 --- a/custom/4coder_command_map.h +++ b/custom/4coder_command_map.h @@ -93,4 +93,4 @@ struct Map_Event_Breakdown{ #endif -// BOTTOM \ No newline at end of file +// BOTTOM diff --git a/custom/4coder_default_hooks.cpp b/custom/4coder_default_hooks.cpp index 64d243a7..eb87c507 100644 --- a/custom/4coder_default_hooks.cpp +++ b/custom/4coder_default_hooks.cpp @@ -249,6 +249,25 @@ default_render_buffer(Application_Links *app, View_ID view_id, Face_ID face_id, draw_comment_highlights(app, buffer, text_layout_id, &token_array, pairs, ArrayCount(pairs)); } + + // TODO(allen): Put in 4coder_draw.cpp + // NOTE(allen): Color functions + + Scratch_Block scratch(app); + ARGB_Color argb = 0xFFFF00FF; + + Token_Iterator_Array it = token_iterator_pos(0, &token_array, visible_range.first); + for (;;){ + if (!token_it_inc_non_whitespace(&it)){ + break; + } + Token *token = token_it_read(&it); + String_Const_u8 lexeme = push_token_lexeme(app, scratch, buffer, token); + Code_Index_Note *note = code_index_note_from_string(lexeme); + if (note != 0 && note->note_kind == CodeIndexNote_Function){ + paint_text_color(app, text_layout_id, Ii64_size(token->pos, token->size), argb); + } + } } else{ paint_text_color_fcolor(app, text_layout_id, visible_range, fcolor_id(defcolor_text_default)); diff --git a/custom/4coder_search.cpp b/custom/4coder_search.cpp index ee0a9b5f..5f8d7739 100644 --- a/custom/4coder_search.cpp +++ b/custom/4coder_search.cpp @@ -340,7 +340,7 @@ word_complete_iter_init(Buffer_ID buffer, Range_i64 range, Word_Complete_Iterato Arena *arena = iter->arena; Scratch_Block scratch(app, arena); String_Const_u8 needle = push_buffer_range(app, scratch, buffer, range); - word_complete_iter_init__inner(buffer, needle, range, iter); + word_complete_iter_init__inner(buffer, needle, range, iter); } } diff --git a/custom/generated/command_metadata.h b/custom/generated/command_metadata.h index f8108cab..a70a6b70 100644 --- a/custom/generated/command_metadata.h +++ b/custom/generated/command_metadata.h @@ -270,254 +270,254 @@ i32 source_name_len; i32 line_number; }; static Command_Metadata fcoder_metacmd_table[248] = { -{ PROC_LINKS(allow_mouse, 0), false, "allow_mouse", 11, "Shows the mouse and causes all mouse input to be processed normally.", 68, "w:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 485 }, -{ PROC_LINKS(auto_indent_line_at_cursor, 0), false, "auto_indent_line_at_cursor", 26, "Auto-indents the line on which the cursor sits.", 47, "w:\\4ed\\code\\custom\\4coder_auto_indent.cpp", 41, 417 }, -{ PROC_LINKS(auto_indent_range, 0), false, "auto_indent_range", 17, "Auto-indents the range between the cursor and the mark.", 55, "w:\\4ed\\code\\custom\\4coder_auto_indent.cpp", 41, 427 }, -{ PROC_LINKS(auto_indent_whole_file, 0), false, "auto_indent_whole_file", 22, "Audo-indents the entire current buffer.", 39, "w:\\4ed\\code\\custom\\4coder_auto_indent.cpp", 41, 408 }, -{ PROC_LINKS(backspace_alpha_numeric_boundary, 0), false, "backspace_alpha_numeric_boundary", 32, "Delete characters between the cursor position and the first alphanumeric boundary to the left.", 94, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 154 }, -{ PROC_LINKS(backspace_char, 0), false, "backspace_char", 14, "Deletes the character to the left of the cursor.", 48, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 96 }, -{ PROC_LINKS(basic_change_active_panel, 0), false, "basic_change_active_panel", 25, "Change the currently active panel, moving to the panel with the next highest view_id. Will not skipe the build panel if it is open.", 132, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 666 }, -{ PROC_LINKS(begin_clipboard_collection_mode, 0), true, "begin_clipboard_collection_mode", 31, "Allows the user to copy multiple strings from other applications before switching to 4coder and pasting them all.", 113, "w:\\4ed\\code\\custom\\4coder_clipboard.cpp", 39, 71 }, -{ PROC_LINKS(build_in_build_panel, 0), false, "build_in_build_panel", 20, "Looks for a build.bat, build.sh, or makefile in the current and parent directories. Runs the first that it finds and prints the output to *compilation*. Puts the *compilation* buffer in a panel at the footer of the current view.", 230, "w:\\4ed\\code\\custom\\4coder_build_commands.cpp", 44, 159 }, -{ PROC_LINKS(build_search, 0), false, "build_search", 12, "Looks for a build.bat, build.sh, or makefile in the current and parent directories. Runs the first that it finds and prints the output to *compilation*.", 153, "w:\\4ed\\code\\custom\\4coder_build_commands.cpp", 44, 122 }, -{ PROC_LINKS(center_view, 0), false, "center_view", 11, "Centers the view vertically on the line on which the cursor sits.", 65, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 195 }, -{ PROC_LINKS(change_active_panel, 0), false, "change_active_panel", 19, "Change the currently active panel, moving to the panel with the next highest view_id.", 85, "w:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 360 }, -{ PROC_LINKS(change_active_panel_backwards, 0), false, "change_active_panel_backwards", 29, "Change the currently active panel, moving to the panel with the next lowest view_id.", 84, "w:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 366 }, -{ PROC_LINKS(change_to_build_panel, 0), false, "change_to_build_panel", 21, "If the special build panel is open, makes the build panel the active panel.", 75, "w:\\4ed\\code\\custom\\4coder_build_commands.cpp", 44, 180 }, -{ PROC_LINKS(clean_all_lines, 0), false, "clean_all_lines", 15, "Removes trailing whitespace from all lines and removes all blank lines in the current buffer.", 93, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 646 }, -{ PROC_LINKS(clean_trailing_whitespace, 0), false, "clean_trailing_whitespace", 25, "Removes trailing whitespace from all lines in the current buffer.", 65, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 655 }, -{ PROC_LINKS(clear_all_themes, 0), false, "clear_all_themes", 16, "Clear the theme list", 20, "w:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 556 }, -{ PROC_LINKS(clear_clipboard, 0), false, "clear_clipboard", 15, "Clears the history of the clipboard", 35, "w:\\4ed\\code\\custom\\4coder_clipboard.cpp", 39, 221 }, -{ PROC_LINKS(click_set_cursor, 0), false, "click_set_cursor", 16, "Sets the cursor position to the mouse position.", 47, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 233 }, -{ PROC_LINKS(click_set_cursor_and_mark, 0), false, "click_set_cursor_and_mark", 25, "Sets the cursor position and mark to the mouse position.", 56, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 223 }, -{ PROC_LINKS(click_set_cursor_if_lbutton, 0), false, "click_set_cursor_if_lbutton", 27, "If the mouse left button is pressed, sets the cursor position to the mouse position.", 84, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 243 }, -{ PROC_LINKS(click_set_mark, 0), false, "click_set_mark", 14, "Sets the mark position to the mouse position.", 45, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 256 }, -{ PROC_LINKS(clipboard_record_clip, 0), false, "clipboard_record_clip", 21, "In response to a new clipboard contents events, saves the new clip onto the clipboard history", 93, "w:\\4ed\\code\\custom\\4coder_clipboard.cpp", 39, 7 }, -{ PROC_LINKS(close_all_code, 0), false, "close_all_code", 14, "Closes any buffer with a filename ending with an extension configured to be recognized as a code file type.", 107, "w:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 844 }, -{ PROC_LINKS(close_build_panel, 0), false, "close_build_panel", 17, "If the special build panel is open, closes it.", 46, "w:\\4ed\\code\\custom\\4coder_build_commands.cpp", 44, 174 }, -{ PROC_LINKS(close_panel, 0), false, "close_panel", 11, "Closes the currently active panel if it is not the only panel open.", 67, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 674 }, -{ PROC_LINKS(command_documentation, 0), true, "command_documentation", 21, "Prompts the user to select a command then loads a doc buffer for that item", 74, "w:\\4ed\\code\\custom\\4coder_docs.cpp", 34, 190 }, -{ PROC_LINKS(command_lister, 0), true, "command_lister", 14, "Opens an interactive list of all registered commands.", 53, "w:\\4ed\\code\\custom\\4coder_lists.cpp", 35, 760 }, -{ PROC_LINKS(comment_line, 0), false, "comment_line", 12, "Insert '//' at the beginning of the line after leading whitespace.", 66, "w:\\4ed\\code\\custom\\4coder_combined_write_commands.cpp", 53, 125 }, -{ PROC_LINKS(comment_line_toggle, 0), false, "comment_line_toggle", 19, "Turns uncommented lines into commented lines and vice versa for comments starting with '//'.", 92, "w:\\4ed\\code\\custom\\4coder_combined_write_commands.cpp", 53, 149 }, -{ PROC_LINKS(copy, 0), false, "copy", 4, "Copy the text in the range from the cursor to the mark onto the clipboard.", 74, "w:\\4ed\\code\\custom\\4coder_clipboard.cpp", 39, 110 }, -{ PROC_LINKS(cursor_mark_swap, 0), false, "cursor_mark_swap", 16, "Swaps the position of the cursor and the mark.", 46, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 124 }, -{ PROC_LINKS(custom_api_documentation, 0), true, "custom_api_documentation", 24, "Prompts the user to select a Custom API item then loads a doc buffer for that item", 82, "w:\\4ed\\code\\custom\\4coder_docs.cpp", 34, 175 }, -{ PROC_LINKS(cut, 0), false, "cut", 3, "Cut the text in the range from the cursor to the mark onto the clipboard.", 73, "w:\\4ed\\code\\custom\\4coder_clipboard.cpp", 39, 119 }, -{ PROC_LINKS(decrease_face_size, 0), false, "decrease_face_size", 18, "Decrease the size of the face used by the current buffer.", 57, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 757 }, -{ PROC_LINKS(default_file_externally_modified, 0), false, "default_file_externally_modified", 32, "Notes the external modification of attached files by printing a message.", 72, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 2055 }, -{ PROC_LINKS(default_startup, 0), false, "default_startup", 15, "Default command for responding to a startup event", 49, "w:\\4ed\\code\\custom\\4coder_default_hooks.cpp", 43, 7 }, -{ PROC_LINKS(default_try_exit, 0), false, "default_try_exit", 16, "Default command for responding to a try-exit event", 50, "w:\\4ed\\code\\custom\\4coder_default_hooks.cpp", 43, 23 }, -{ PROC_LINKS(default_view_input_handler, 0), false, "default_view_input_handler", 26, "Input consumption loop for default view behavior", 48, "w:\\4ed\\code\\custom\\4coder_default_hooks.cpp", 43, 51 }, -{ PROC_LINKS(delete_alpha_numeric_boundary, 0), false, "delete_alpha_numeric_boundary", 29, "Delete characters between the cursor position and the first alphanumeric boundary to the right.", 95, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 161 }, -{ PROC_LINKS(delete_char, 0), false, "delete_char", 11, "Deletes the character to the right of the cursor.", 49, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 79 }, -{ PROC_LINKS(delete_current_scope, 0), false, "delete_current_scope", 20, "Deletes the braces surrounding the currently selected scope. Leaves the contents within the scope.", 99, "w:\\4ed\\code\\custom\\4coder_scope_commands.cpp", 44, 112 }, -{ PROC_LINKS(delete_file_query, 0), false, "delete_file_query", 17, "Deletes the file of the current buffer if 4coder has the appropriate access rights. Will ask the user for confirmation first.", 125, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1381 }, -{ PROC_LINKS(delete_line, 0), false, "delete_line", 11, "Delete the line the on which the cursor sits.", 45, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1553 }, -{ PROC_LINKS(delete_range, 0), false, "delete_range", 12, "Deletes the text in the range between the cursor and the mark.", 62, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 134 }, -{ PROC_LINKS(display_key_codes, 0), false, "display_key_codes", 17, "Example of input handling loop", 30, "w:\\4ed\\code\\custom\\4coder_examples.cpp", 38, 90 }, -{ PROC_LINKS(display_text_input, 0), false, "display_text_input", 18, "Example of to_writable and leave_current_input_unhandled", 56, "w:\\4ed\\code\\custom\\4coder_examples.cpp", 38, 137 }, -{ PROC_LINKS(double_backspace, 0), false, "double_backspace", 16, "Example of history group helpers", 32, "w:\\4ed\\code\\custom\\4coder_examples.cpp", 38, 10 }, -{ PROC_LINKS(duplicate_line, 0), false, "duplicate_line", 14, "Create a copy of the line on which the cursor sits.", 51, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1539 }, -{ PROC_LINKS(execute_any_cli, 0), false, "execute_any_cli", 15, "Queries for an output buffer name and system command, runs the system command as a CLI and prints the output to the specified buffer.", 133, "w:\\4ed\\code\\custom\\4coder_cli_command.cpp", 41, 22 }, -{ PROC_LINKS(execute_previous_cli, 0), false, "execute_previous_cli", 20, "If the command execute_any_cli has already been used, this will execute a CLI reusing the most recent buffer name and command.", 126, "w:\\4ed\\code\\custom\\4coder_cli_command.cpp", 41, 7 }, -{ PROC_LINKS(exit_4coder, 0), false, "exit_4coder", 11, "Attempts to close 4coder.", 25, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 844 }, -{ PROC_LINKS(goto_beginning_of_file, 0), false, "goto_beginning_of_file", 22, "Sets the cursor to the beginning of the file.", 45, "w:\\4ed\\code\\custom\\4coder_helper.cpp", 36, 2248 }, -{ PROC_LINKS(goto_end_of_file, 0), false, "goto_end_of_file", 16, "Sets the cursor to the end of the file.", 39, "w:\\4ed\\code\\custom\\4coder_helper.cpp", 36, 2256 }, -{ PROC_LINKS(goto_first_jump, 0), false, "goto_first_jump", 15, "If a buffer containing jump locations has been locked in, goes to the first jump in the buffer.", 95, "w:\\4ed\\code\\custom\\4coder_jump_sticky.cpp", 41, 525 }, -{ PROC_LINKS(goto_first_jump_same_panel_sticky, 0), false, "goto_first_jump_same_panel_sticky", 33, "If a buffer containing jump locations has been locked in, goes to the first jump in the buffer and views the buffer in the panel where the jump list was.", 153, "w:\\4ed\\code\\custom\\4coder_jump_sticky.cpp", 41, 542 }, -{ PROC_LINKS(goto_jump_at_cursor, 0), false, "goto_jump_at_cursor", 19, "If the cursor is found to be on a jump location, parses the jump location and brings up the file and position in another view and changes the active panel to the view containing the jump.", 187, "w:\\4ed\\code\\custom\\4coder_jump_sticky.cpp", 41, 348 }, -{ PROC_LINKS(goto_jump_at_cursor_same_panel, 0), false, "goto_jump_at_cursor_same_panel", 30, "If the cursor is found to be on a jump location, parses the jump location and brings up the file and position in this view, losing the compilation output or jump list.", 167, "w:\\4ed\\code\\custom\\4coder_jump_sticky.cpp", 41, 375 }, -{ PROC_LINKS(goto_line, 0), false, "goto_line", 9, "Queries the user for a number, and jumps the cursor to the corresponding line.", 78, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 852 }, -{ PROC_LINKS(goto_next_jump, 0), false, "goto_next_jump", 14, "If a buffer containing jump locations has been locked in, goes to the next jump in the buffer, skipping sub jump locations.", 123, "w:\\4ed\\code\\custom\\4coder_jump_sticky.cpp", 41, 464 }, -{ PROC_LINKS(goto_next_jump_no_skips, 0), false, "goto_next_jump_no_skips", 23, "If a buffer containing jump locations has been locked in, goes to the next jump in the buffer, and does not skip sub jump locations.", 132, "w:\\4ed\\code\\custom\\4coder_jump_sticky.cpp", 41, 494 }, -{ PROC_LINKS(goto_prev_jump, 0), false, "goto_prev_jump", 14, "If a buffer containing jump locations has been locked in, goes to the previous jump in the buffer, skipping sub jump locations.", 127, "w:\\4ed\\code\\custom\\4coder_jump_sticky.cpp", 41, 481 }, -{ PROC_LINKS(goto_prev_jump_no_skips, 0), false, "goto_prev_jump_no_skips", 23, "If a buffer containing jump locations has been locked in, goes to the previous jump in the buffer, and does not skip sub jump locations.", 136, "w:\\4ed\\code\\custom\\4coder_jump_sticky.cpp", 41, 511 }, -{ PROC_LINKS(hide_filebar, 0), false, "hide_filebar", 12, "Sets the current view to hide it's filebar.", 43, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 704 }, -{ PROC_LINKS(hide_scrollbar, 0), false, "hide_scrollbar", 14, "Sets the current view to hide it's scrollbar.", 45, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 690 }, -{ PROC_LINKS(hms_demo_tutorial, 0), false, "hms_demo_tutorial", 17, "Tutorial for built in 4coder bindings and features.", 51, "w:\\4ed\\code\\custom\\4coder_tutorial.cpp", 38, 869 }, -{ PROC_LINKS(if0_off, 0), false, "if0_off", 7, "Surround the range between the cursor and mark with an '#if 0' and an '#endif'", 78, "w:\\4ed\\code\\custom\\4coder_combined_write_commands.cpp", 53, 70 }, -{ PROC_LINKS(if_read_only_goto_position, 0), false, "if_read_only_goto_position", 26, "If the buffer in the active view is writable, inserts a character, otherwise performs goto_jump_at_cursor.", 106, "w:\\4ed\\code\\custom\\4coder_jump_sticky.cpp", 41, 564 }, -{ PROC_LINKS(if_read_only_goto_position_same_panel, 0), false, "if_read_only_goto_position_same_panel", 37, "If the buffer in the active view is writable, inserts a character, otherwise performs goto_jump_at_cursor_same_panel.", 117, "w:\\4ed\\code\\custom\\4coder_jump_sticky.cpp", 41, 581 }, -{ PROC_LINKS(increase_face_size, 0), false, "increase_face_size", 18, "Increase the size of the face used by the current buffer.", 57, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 746 }, -{ PROC_LINKS(interactive_kill_buffer, 0), true, "interactive_kill_buffer", 23, "Interactively kill an open buffer.", 34, "w:\\4ed\\code\\custom\\4coder_lists.cpp", 35, 520 }, -{ PROC_LINKS(interactive_new, 0), true, "interactive_new", 15, "Interactively creates a new file.", 33, "w:\\4ed\\code\\custom\\4coder_lists.cpp", 35, 660 }, -{ PROC_LINKS(interactive_open, 0), true, "interactive_open", 16, "Interactively opens a file.", 27, "w:\\4ed\\code\\custom\\4coder_lists.cpp", 35, 714 }, -{ PROC_LINKS(interactive_open_or_new, 0), true, "interactive_open_or_new", 23, "Interactively open a file out of the file system.", 49, "w:\\4ed\\code\\custom\\4coder_lists.cpp", 35, 611 }, -{ PROC_LINKS(interactive_switch_buffer, 0), true, "interactive_switch_buffer", 25, "Interactively switch to an open buffer.", 39, "w:\\4ed\\code\\custom\\4coder_lists.cpp", 35, 510 }, -{ PROC_LINKS(jump_to_definition, 0), true, "jump_to_definition", 18, "List all definitions in the code index and jump to one chosen by the user.", 74, "w:\\4ed\\code\\custom\\4coder_code_index_listers.cpp", 48, 12 }, -{ PROC_LINKS(jump_to_definition_at_cursor, 0), true, "jump_to_definition_at_cursor", 28, "Jump to the first definition in the code index matching an identifier at the cursor", 83, "w:\\4ed\\code\\custom\\4coder_code_index_listers.cpp", 48, 68 }, -{ PROC_LINKS(jump_to_last_point, 0), false, "jump_to_last_point", 18, "Read from the top of the point stack and jump there; if already there pop the top and go to the next option", 107, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1334 }, -{ PROC_LINKS(keyboard_macro_finish_recording, 0), false, "keyboard_macro_finish_recording", 31, "Stop macro recording, do nothing if macro recording is not already started", 74, "w:\\4ed\\code\\custom\\4coder_keyboard_macro.cpp", 44, 54 }, -{ PROC_LINKS(keyboard_macro_replay, 0), false, "keyboard_macro_replay", 21, "Replay the most recently recorded keyboard macro", 48, "w:\\4ed\\code\\custom\\4coder_keyboard_macro.cpp", 44, 77 }, -{ PROC_LINKS(keyboard_macro_start_recording, 0), false, "keyboard_macro_start_recording", 30, "Start macro recording, do nothing if macro recording is already started", 71, "w:\\4ed\\code\\custom\\4coder_keyboard_macro.cpp", 44, 41 }, -{ PROC_LINKS(kill_buffer, 0), false, "kill_buffer", 11, "Kills the current buffer.", 25, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1717 }, -{ PROC_LINKS(kill_tutorial, 0), false, "kill_tutorial", 13, "If there is an active tutorial, kill it.", 40, "w:\\4ed\\code\\custom\\4coder_tutorial.cpp", 38, 9 }, -{ PROC_LINKS(left_adjust_view, 0), false, "left_adjust_view", 16, "Sets the left size of the view near the x position of the cursor.", 65, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 210 }, -{ PROC_LINKS(list_all_functions_all_buffers, 0), false, "list_all_functions_all_buffers", 30, "Creates a jump list of lines from all buffers that appear to define or declare functions.", 89, "w:\\4ed\\code\\custom\\4coder_function_list.cpp", 43, 296 }, -{ PROC_LINKS(list_all_functions_all_buffers_lister, 0), true, "list_all_functions_all_buffers_lister", 37, "Creates a lister of locations that look like function definitions and declarations all buffers.", 95, "w:\\4ed\\code\\custom\\4coder_function_list.cpp", 43, 302 }, -{ PROC_LINKS(list_all_functions_current_buffer, 0), false, "list_all_functions_current_buffer", 33, "Creates a jump list of lines of the current buffer that appear to define or declare functions.", 94, "w:\\4ed\\code\\custom\\4coder_function_list.cpp", 43, 268 }, -{ PROC_LINKS(list_all_functions_current_buffer_lister, 0), true, "list_all_functions_current_buffer_lister", 40, "Creates a lister of locations that look like function definitions and declarations in the buffer.", 97, "w:\\4ed\\code\\custom\\4coder_function_list.cpp", 43, 278 }, -{ PROC_LINKS(list_all_locations, 0), false, "list_all_locations", 18, "Queries the user for a string and lists all exact case-sensitive matches found in all open buffers.", 99, "w:\\4ed\\code\\custom\\4coder_search.cpp", 36, 168 }, -{ PROC_LINKS(list_all_locations_case_insensitive, 0), false, "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, "w:\\4ed\\code\\custom\\4coder_search.cpp", 36, 180 }, -{ PROC_LINKS(list_all_locations_of_identifier, 0), false, "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, "w:\\4ed\\code\\custom\\4coder_search.cpp", 36, 192 }, -{ PROC_LINKS(list_all_locations_of_identifier_case_insensitive, 0), false, "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, "w:\\4ed\\code\\custom\\4coder_search.cpp", 36, 198 }, -{ PROC_LINKS(list_all_locations_of_selection, 0), false, "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, "w:\\4ed\\code\\custom\\4coder_search.cpp", 36, 204 }, -{ PROC_LINKS(list_all_locations_of_selection_case_insensitive, 0), false, "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, "w:\\4ed\\code\\custom\\4coder_search.cpp", 36, 210 }, -{ PROC_LINKS(list_all_locations_of_type_definition, 0), false, "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, "w:\\4ed\\code\\custom\\4coder_search.cpp", 36, 216 }, -{ PROC_LINKS(list_all_locations_of_type_definition_of_identifier, 0), false, "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, "w:\\4ed\\code\\custom\\4coder_search.cpp", 36, 224 }, -{ PROC_LINKS(list_all_substring_locations, 0), false, "list_all_substring_locations", 28, "Queries the user for a string and lists all case-sensitive substring matches found in all open buffers.", 103, "w:\\4ed\\code\\custom\\4coder_search.cpp", 36, 174 }, -{ PROC_LINKS(list_all_substring_locations_case_insensitive, 0), false, "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, "w:\\4ed\\code\\custom\\4coder_search.cpp", 36, 186 }, -{ PROC_LINKS(load_project, 0), false, "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, "w:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 864 }, -{ PROC_LINKS(load_theme_current_buffer, 0), false, "load_theme_current_buffer", 25, "Parse the current buffer as a theme file and add the theme to the theme list. If the buffer has a .4coder postfix in it's name, it is removed when the name is saved.", 165, "w:\\4ed\\code\\custom\\4coder_config.cpp", 36, 1667 }, -{ PROC_LINKS(load_themes_default_folder, 0), false, "load_themes_default_folder", 26, "Loads all the theme files in the default theme folder.", 54, "w:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 533 }, -{ PROC_LINKS(load_themes_hot_directory, 0), false, "load_themes_hot_directory", 25, "Loads all the theme files in the current hot directory.", 55, "w:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 545 }, -{ PROC_LINKS(make_directory_query, 0), false, "make_directory_query", 20, "Queries the user for a name and creates a new directory with the given name.", 76, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1493 }, -{ PROC_LINKS(miblo_decrement_basic, 0), false, "miblo_decrement_basic", 21, "Decrement an integer under the cursor by one.", 45, "w:\\4ed\\code\\custom\\4coder_miblo_numbers.cpp", 43, 44 }, -{ PROC_LINKS(miblo_decrement_time_stamp, 0), false, "miblo_decrement_time_stamp", 26, "Decrement a time stamp under the cursor by one second. (format [m]m:ss or h:mm:ss", 81, "w:\\4ed\\code\\custom\\4coder_miblo_numbers.cpp", 43, 237 }, -{ PROC_LINKS(miblo_decrement_time_stamp_minute, 0), false, "miblo_decrement_time_stamp_minute", 33, "Decrement a time stamp under the cursor by one minute. (format [m]m:ss or h:mm:ss", 81, "w:\\4ed\\code\\custom\\4coder_miblo_numbers.cpp", 43, 249 }, -{ PROC_LINKS(miblo_increment_basic, 0), false, "miblo_increment_basic", 21, "Increment an integer under the cursor by one.", 45, "w:\\4ed\\code\\custom\\4coder_miblo_numbers.cpp", 43, 29 }, -{ PROC_LINKS(miblo_increment_time_stamp, 0), false, "miblo_increment_time_stamp", 26, "Increment a time stamp under the cursor by one second. (format [m]m:ss or h:mm:ss", 81, "w:\\4ed\\code\\custom\\4coder_miblo_numbers.cpp", 43, 231 }, -{ PROC_LINKS(miblo_increment_time_stamp_minute, 0), false, "miblo_increment_time_stamp_minute", 33, "Increment a time stamp under the cursor by one minute. (format [m]m:ss or h:mm:ss", 81, "w:\\4ed\\code\\custom\\4coder_miblo_numbers.cpp", 43, 243 }, -{ PROC_LINKS(mouse_wheel_change_face_size, 0), false, "mouse_wheel_change_face_size", 28, "Reads the state of the mouse wheel and uses it to either increase or decrease the face size.", 92, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 799 }, -{ PROC_LINKS(mouse_wheel_scroll, 0), false, "mouse_wheel_scroll", 18, "Reads the scroll wheel value from the mouse state and scrolls accordingly.", 74, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 266 }, -{ PROC_LINKS(move_down, 0), false, "move_down", 9, "Moves the cursor down one line.", 31, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 340 }, -{ PROC_LINKS(move_down_10, 0), false, "move_down_10", 12, "Moves the cursor down ten lines.", 32, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 352 }, -{ PROC_LINKS(move_down_textual, 0), false, "move_down_textual", 17, "Moves down to the next line of actual text, regardless of line wrapping.", 72, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 358 }, -{ PROC_LINKS(move_down_to_blank_line, 0), false, "move_down_to_blank_line", 23, "Seeks the cursor down to the next blank line.", 45, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 411 }, -{ PROC_LINKS(move_down_to_blank_line_end, 0), false, "move_down_to_blank_line_end", 27, "Seeks the cursor down to the next blank line and places it at the end of the line.", 82, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 435 }, -{ PROC_LINKS(move_down_to_blank_line_skip_whitespace, 0), false, "move_down_to_blank_line_skip_whitespace", 39, "Seeks the cursor down to the next blank line and places it at the end of the line.", 82, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 423 }, -{ PROC_LINKS(move_left, 0), false, "move_left", 9, "Moves the cursor one character to the left.", 43, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 441 }, -{ PROC_LINKS(move_left_alpha_numeric_boundary, 0), false, "move_left_alpha_numeric_boundary", 32, "Seek left for boundary between alphanumeric characters and non-alphanumeric characters.", 87, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 518 }, -{ PROC_LINKS(move_left_alpha_numeric_or_camel_boundary, 0), false, "move_left_alpha_numeric_or_camel_boundary", 41, "Seek left for boundary between alphanumeric characters or camel case word and non-alphanumeric characters.", 106, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 532 }, -{ PROC_LINKS(move_left_token_boundary, 0), false, "move_left_token_boundary", 24, "Seek left for the next beginning of a token.", 44, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 490 }, -{ PROC_LINKS(move_left_whitespace_boundary, 0), false, "move_left_whitespace_boundary", 29, "Seek left for the next boundary between whitespace and non-whitespace.", 70, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 475 }, -{ PROC_LINKS(move_left_whitespace_or_token_boundary, 0), false, "move_left_whitespace_or_token_boundary", 38, "Seek left for the next end of a token or boundary between whitespace and non-whitespace.", 88, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 504 }, -{ PROC_LINKS(move_line_down, 0), false, "move_line_down", 14, "Swaps the line under the cursor with the line below it, and moves the cursor down with it.", 90, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1533 }, -{ PROC_LINKS(move_line_up, 0), false, "move_line_up", 12, "Swaps the line under the cursor with the line above it, and moves the cursor up with it.", 88, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1527 }, -{ PROC_LINKS(move_right, 0), false, "move_right", 10, "Moves the cursor one character to the right.", 44, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 449 }, -{ PROC_LINKS(move_right_alpha_numeric_boundary, 0), false, "move_right_alpha_numeric_boundary", 33, "Seek right for boundary between alphanumeric characters and non-alphanumeric characters.", 88, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 511 }, -{ PROC_LINKS(move_right_alpha_numeric_or_camel_boundary, 0), false, "move_right_alpha_numeric_or_camel_boundary", 42, "Seek right for boundary between alphanumeric characters or camel case word and non-alphanumeric characters.", 107, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 525 }, -{ PROC_LINKS(move_right_token_boundary, 0), false, "move_right_token_boundary", 25, "Seek right for the next end of a token.", 39, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 483 }, -{ PROC_LINKS(move_right_whitespace_boundary, 0), false, "move_right_whitespace_boundary", 30, "Seek right for the next boundary between whitespace and non-whitespace.", 71, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 467 }, -{ PROC_LINKS(move_right_whitespace_or_token_boundary, 0), false, "move_right_whitespace_or_token_boundary", 39, "Seek right for the next end of a token or boundary between whitespace and non-whitespace.", 89, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 497 }, -{ PROC_LINKS(move_up, 0), false, "move_up", 7, "Moves the cursor up one line.", 29, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 334 }, -{ PROC_LINKS(move_up_10, 0), false, "move_up_10", 10, "Moves the cursor up ten lines.", 30, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 346 }, -{ PROC_LINKS(move_up_to_blank_line, 0), false, "move_up_to_blank_line", 21, "Seeks the cursor up to the next blank line.", 43, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 405 }, -{ PROC_LINKS(move_up_to_blank_line_end, 0), false, "move_up_to_blank_line_end", 25, "Seeks the cursor up to the next blank line and places it at the end of the line.", 80, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 429 }, -{ PROC_LINKS(move_up_to_blank_line_skip_whitespace, 0), false, "move_up_to_blank_line_skip_whitespace", 37, "Seeks the cursor up to the next blank line and places it at the end of the line.", 80, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 417 }, -{ PROC_LINKS(multi_paste, 0), false, "multi_paste", 11, "Paste multiple entries from the clipboard at once", 49, "w:\\4ed\\code\\custom\\4coder_clipboard.cpp", 39, 229 }, -{ PROC_LINKS(multi_paste_interactive, 0), false, "multi_paste_interactive", 23, "Paste multiple lines from the clipboard history, controlled with arrow keys", 75, "w:\\4ed\\code\\custom\\4coder_clipboard.cpp", 39, 371 }, -{ PROC_LINKS(multi_paste_interactive_quick, 0), false, "multi_paste_interactive_quick", 29, "Paste multiple lines from the clipboard history, controlled by inputing the number of lines to paste", 100, "w:\\4ed\\code\\custom\\4coder_clipboard.cpp", 39, 380 }, -{ PROC_LINKS(open_all_code, 0), false, "open_all_code", 13, "Open all code in the current directory. File types are determined by extensions. An extension is considered code based on the extensions specified in 4coder.config.", 164, "w:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 850 }, -{ PROC_LINKS(open_all_code_recursive, 0), false, "open_all_code_recursive", 23, "Works as open_all_code but also runs in all subdirectories.", 59, "w:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 856 }, -{ PROC_LINKS(open_file_in_quotes, 0), false, "open_file_in_quotes", 19, "Reads a filename from surrounding '\"' characters and attempts to open the corresponding file.", 94, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1618 }, -{ PROC_LINKS(open_in_other, 0), false, "open_in_other", 13, "Interactively opens a file in the other panel.", 46, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 2049 }, -{ PROC_LINKS(open_long_braces, 0), false, "open_long_braces", 16, "At the cursor, insert a '{' and '}' separated by a blank line.", 62, "w:\\4ed\\code\\custom\\4coder_combined_write_commands.cpp", 53, 46 }, -{ PROC_LINKS(open_long_braces_break, 0), false, "open_long_braces_break", 22, "At the cursor, insert a '{' and '}break;' separated by a blank line.", 68, "w:\\4ed\\code\\custom\\4coder_combined_write_commands.cpp", 53, 62 }, -{ PROC_LINKS(open_long_braces_semicolon, 0), false, "open_long_braces_semicolon", 26, "At the cursor, insert a '{' and '};' separated by a blank line.", 63, "w:\\4ed\\code\\custom\\4coder_combined_write_commands.cpp", 53, 54 }, -{ PROC_LINKS(open_matching_file_cpp, 0), false, "open_matching_file_cpp", 22, "If the current file is a *.cpp or *.h, attempts to open the corresponding *.h or *.cpp file in the other view.", 110, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1650 }, -{ PROC_LINKS(open_panel_hsplit, 0), false, "open_panel_hsplit", 17, "Create a new panel by horizontally splitting the active panel.", 62, "w:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 386 }, -{ PROC_LINKS(open_panel_vsplit, 0), false, "open_panel_vsplit", 17, "Create a new panel by vertically splitting the active panel.", 60, "w:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 376 }, -{ PROC_LINKS(page_down, 0), false, "page_down", 9, "Scrolls the view down one view height and moves the cursor down one view height.", 80, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 376 }, -{ PROC_LINKS(page_up, 0), false, "page_up", 7, "Scrolls the view up one view height and moves the cursor up one view height.", 76, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 368 }, -{ PROC_LINKS(paste, 0), false, "paste", 5, "At the cursor, insert the text at the top of the clipboard.", 59, "w:\\4ed\\code\\custom\\4coder_clipboard.cpp", 39, 130 }, -{ PROC_LINKS(paste_and_indent, 0), false, "paste_and_indent", 16, "Paste from the top of clipboard and run auto-indent on the newly pasted text.", 77, "w:\\4ed\\code\\custom\\4coder_clipboard.cpp", 39, 207 }, -{ PROC_LINKS(paste_next, 0), false, "paste_next", 10, "If the previous command was paste or paste_next, replaces the paste range with the next text down on the clipboard, otherwise operates as the paste command.", 156, "w:\\4ed\\code\\custom\\4coder_clipboard.cpp", 39, 164 }, -{ PROC_LINKS(paste_next_and_indent, 0), false, "paste_next_and_indent", 21, "Paste the next item on the clipboard and run auto-indent on the newly pasted text.", 82, "w:\\4ed\\code\\custom\\4coder_clipboard.cpp", 39, 214 }, -{ PROC_LINKS(place_in_scope, 0), false, "place_in_scope", 14, "Wraps the code contained in the range between cursor and mark with a new curly brace scope.", 91, "w:\\4ed\\code\\custom\\4coder_scope_commands.cpp", 44, 106 }, -{ PROC_LINKS(play_with_a_counter, 0), false, "play_with_a_counter", 19, "Example of query bar", 20, "w:\\4ed\\code\\custom\\4coder_examples.cpp", 38, 29 }, -{ PROC_LINKS(profile_clear, 0), false, "profile_clear", 13, "Clear all profiling information from 4coder's self profiler.", 60, "w:\\4ed\\code\\custom\\4coder_profile.cpp", 37, 226 }, -{ PROC_LINKS(profile_disable, 0), false, "profile_disable", 15, "Prevent 4coder's self profiler from gathering new profiling information.", 72, "w:\\4ed\\code\\custom\\4coder_profile.cpp", 37, 219 }, -{ PROC_LINKS(profile_enable, 0), false, "profile_enable", 14, "Allow 4coder's self profiler to gather new profiling information.", 65, "w:\\4ed\\code\\custom\\4coder_profile.cpp", 37, 212 }, -{ PROC_LINKS(profile_inspect, 0), true, "profile_inspect", 15, "Inspect all currently collected profiling information in 4coder's self profiler.", 80, "w:\\4ed\\code\\custom\\4coder_profile_inspect.cpp", 45, 886 }, -{ PROC_LINKS(project_command_lister, 0), false, "project_command_lister", 22, "Open a lister of all commands in the currently loaded project.", 62, "w:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1290 }, -{ PROC_LINKS(project_fkey_command, 0), false, "project_fkey_command", 20, "Run an 'fkey command' configured in a project.4coder file. Determines the index of the 'fkey command' by which function key or numeric key was pressed to trigger the command.", 175, "w:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 872 }, -{ PROC_LINKS(project_go_to_root_directory, 0), false, "project_go_to_root_directory", 28, "Changes 4coder's hot directory to the root directory of the currently loaded project. With no loaded project nothing hapepns.", 125, "w:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 898 }, -{ PROC_LINKS(query_replace, 0), false, "query_replace", 13, "Queries the user for two strings, and incrementally replaces every occurence of the first string with the second string.", 120, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1280 }, -{ PROC_LINKS(query_replace_identifier, 0), false, "query_replace_identifier", 24, "Queries the user for a string, and incrementally replace every occurence of the word or token found at the cursor with the specified string.", 140, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1301 }, -{ PROC_LINKS(query_replace_selection, 0), false, "query_replace_selection", 23, "Queries the user for a string, and incrementally replace every occurence of the string found in the selected range with the specified string.", 141, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1317 }, -{ PROC_LINKS(quick_swap_buffer, 0), false, "quick_swap_buffer", 17, "Change to the most recently used buffer in this view - or to the top of the buffer stack if the most recent doesn't exist anymore", 129, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1697 }, -{ PROC_LINKS(redo, 0), false, "redo", 4, "Advances forwards through the undo history of the current buffer.", 65, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1876 }, -{ PROC_LINKS(redo_all_buffers, 0), false, "redo_all_buffers", 16, "Advances forward through the undo history in the buffer containing the most recent regular edit.", 96, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1973 }, -{ PROC_LINKS(rename_file_query, 0), false, "rename_file_query", 17, "Queries the user for a new name and renames the file of the current buffer, altering the buffer's name too.", 107, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1458 }, -{ PROC_LINKS(reopen, 0), false, "reopen", 6, "Reopen the current buffer from the hard drive.", 46, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1735 }, -{ PROC_LINKS(replace_in_all_buffers, 0), false, "replace_in_all_buffers", 22, "Queries the user for a needle and string. Replaces all occurences of needle with string in all editable buffers.", 112, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1190 }, -{ PROC_LINKS(replace_in_buffer, 0), false, "replace_in_buffer", 17, "Queries the user for a needle and string. Replaces all occurences of needle with string in the active buffer.", 109, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1181 }, -{ PROC_LINKS(replace_in_range, 0), false, "replace_in_range", 16, "Queries the user for a needle and string. Replaces all occurences of needle with string in the range between cursor and the mark in the active buffer.", 150, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1172 }, -{ PROC_LINKS(reverse_search, 0), false, "reverse_search", 14, "Begins an incremental search up through the current buffer for a user specified string.", 87, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1113 }, -{ PROC_LINKS(reverse_search_identifier, 0), false, "reverse_search_identifier", 25, "Begins an incremental search up through the current buffer for the word or token under the cursor.", 98, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1125 }, -{ PROC_LINKS(save, 0), false, "save", 4, "Saves the current buffer.", 25, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1725 }, -{ PROC_LINKS(save_all_dirty_buffers, 0), false, "save_all_dirty_buffers", 22, "Saves all buffers marked dirty (showing the '*' indicator).", 59, "w:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 458 }, -{ PROC_LINKS(save_to_query, 0), false, "save_to_query", 13, "Queries the user for a file name and saves the contents of the current buffer, altering the buffer's name too.", 110, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1425 }, -{ PROC_LINKS(search, 0), false, "search", 6, "Begins an incremental search down through the current buffer for a user specified string.", 89, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1107 }, -{ PROC_LINKS(search_identifier, 0), false, "search_identifier", 17, "Begins an incremental search down through the current buffer for the word or token under the cursor.", 100, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1119 }, -{ PROC_LINKS(seek_beginning_of_line, 0), false, "seek_beginning_of_line", 22, "Seeks the cursor to the beginning of the visual line.", 53, "w:\\4ed\\code\\custom\\4coder_helper.cpp", 36, 2236 }, -{ PROC_LINKS(seek_beginning_of_textual_line, 0), false, "seek_beginning_of_textual_line", 30, "Seeks the cursor to the beginning of the line across all text.", 62, "w:\\4ed\\code\\custom\\4coder_helper.cpp", 36, 2224 }, -{ PROC_LINKS(seek_end_of_line, 0), false, "seek_end_of_line", 16, "Seeks the cursor to the end of the visual line.", 47, "w:\\4ed\\code\\custom\\4coder_helper.cpp", 36, 2242 }, -{ PROC_LINKS(seek_end_of_textual_line, 0), false, "seek_end_of_textual_line", 24, "Seeks the cursor to the end of the line across all text.", 56, "w:\\4ed\\code\\custom\\4coder_helper.cpp", 36, 2230 }, -{ PROC_LINKS(select_all, 0), false, "select_all", 10, "Puts the cursor at the top of the file, and the mark at the bottom of the file.", 79, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 541 }, -{ PROC_LINKS(select_next_scope_absolute, 0), false, "select_next_scope_absolute", 26, "Finds the first scope started by '{' after the cursor and puts the cursor and mark on the '{' and '}'.", 102, "w:\\4ed\\code\\custom\\4coder_scope_commands.cpp", 44, 57 }, -{ PROC_LINKS(select_next_scope_after_current, 0), false, "select_next_scope_after_current", 31, "If a scope is selected, find first scope that starts after the selected scope. Otherwise find the first scope that starts after the cursor.", 139, "w:\\4ed\\code\\custom\\4coder_scope_commands.cpp", 44, 66 }, -{ PROC_LINKS(select_prev_scope_absolute, 0), false, "select_prev_scope_absolute", 26, "Finds the first scope started by '{' before the cursor and puts the cursor and mark on the '{' and '}'.", 103, "w:\\4ed\\code\\custom\\4coder_scope_commands.cpp", 44, 82 }, -{ PROC_LINKS(select_prev_top_most_scope, 0), false, "select_prev_top_most_scope", 26, "Finds the first scope that starts before the cursor, then finds the top most scope that contains that scope.", 108, "w:\\4ed\\code\\custom\\4coder_scope_commands.cpp", 44, 99 }, -{ PROC_LINKS(select_surrounding_scope, 0), false, "select_surrounding_scope", 24, "Finds the scope enclosed by '{' '}' surrounding the cursor and puts the cursor and mark on the '{' and '}'.", 107, "w:\\4ed\\code\\custom\\4coder_scope_commands.cpp", 44, 27 }, -{ PROC_LINKS(select_surrounding_scope_maximal, 0), false, "select_surrounding_scope_maximal", 32, "Selects the top-most scope that surrounds the cursor.", 53, "w:\\4ed\\code\\custom\\4coder_scope_commands.cpp", 44, 39 }, -{ PROC_LINKS(set_eol_mode_from_contents, 0), false, "set_eol_mode_from_contents", 26, "Sets the buffer's line ending mode to match the contents of the buffer.", 71, "w:\\4ed\\code\\custom\\4coder_eol.cpp", 33, 125 }, -{ PROC_LINKS(set_eol_mode_to_binary, 0), false, "set_eol_mode_to_binary", 22, "Puts the buffer in bin line ending mode.", 40, "w:\\4ed\\code\\custom\\4coder_eol.cpp", 33, 112 }, -{ PROC_LINKS(set_eol_mode_to_crlf, 0), false, "set_eol_mode_to_crlf", 20, "Puts the buffer in crlf line ending mode.", 41, "w:\\4ed\\code\\custom\\4coder_eol.cpp", 33, 86 }, -{ PROC_LINKS(set_eol_mode_to_lf, 0), false, "set_eol_mode_to_lf", 18, "Puts the buffer in lf line ending mode.", 39, "w:\\4ed\\code\\custom\\4coder_eol.cpp", 33, 99 }, -{ PROC_LINKS(set_face_size, 0), false, "set_face_size", 13, "Set face size of the face used by the current buffer.", 53, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 726 }, -{ PROC_LINKS(set_face_size_this_buffer, 0), false, "set_face_size_this_buffer", 25, "Set face size of the face used by the current buffer; if any other buffers are using the same face a new face is created so that only this buffer is effected", 157, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 768 }, -{ PROC_LINKS(set_mark, 0), false, "set_mark", 8, "Sets the mark to the current position of the cursor.", 52, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 115 }, -{ PROC_LINKS(set_mode_to_notepad_like, 0), false, "set_mode_to_notepad_like", 24, "Sets the edit mode to Notepad like.", 35, "w:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 503 }, -{ PROC_LINKS(set_mode_to_original, 0), false, "set_mode_to_original", 20, "Sets the edit mode to 4coder original.", 38, "w:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 497 }, -{ PROC_LINKS(setup_build_bat, 0), false, "setup_build_bat", 15, "Queries the user for several configuration options and initializes a new build batch script.", 92, "w:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1239 }, -{ PROC_LINKS(setup_build_bat_and_sh, 0), false, "setup_build_bat_and_sh", 22, "Queries the user for several configuration options and initializes a new build batch script.", 92, "w:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1251 }, -{ PROC_LINKS(setup_build_sh, 0), false, "setup_build_sh", 14, "Queries the user for several configuration options and initializes a new build shell script.", 92, "w:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1245 }, -{ PROC_LINKS(setup_new_project, 0), false, "setup_new_project", 17, "Queries the user for several configuration options and initializes a new 4coder project with build scripts for every OS.", 120, "w:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1232 }, -{ PROC_LINKS(show_filebar, 0), false, "show_filebar", 12, "Sets the current view to show it's filebar.", 43, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 697 }, -{ PROC_LINKS(show_scrollbar, 0), false, "show_scrollbar", 14, "Sets the current view to show it's scrollbar.", 45, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 683 }, -{ PROC_LINKS(show_the_log_graph, 0), true, "show_the_log_graph", 18, "Parses *log* and displays the 'log graph' UI", 44, "w:\\4ed\\code\\custom\\4coder_log_parser.cpp", 40, 993 }, -{ PROC_LINKS(snipe_backward_whitespace_or_token_boundary, 0), false, "snipe_backward_whitespace_or_token_boundary", 43, "Delete a single, whole token on or to the left of the cursor and post it to the clipboard.", 90, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 177 }, -{ PROC_LINKS(snipe_forward_whitespace_or_token_boundary, 0), false, "snipe_forward_whitespace_or_token_boundary", 42, "Delete a single, whole token on or to the right of the cursor and post it to the clipboard.", 91, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 185 }, -{ PROC_LINKS(snippet_lister, 0), true, "snippet_lister", 14, "Opens a snippet lister for inserting whole pre-written snippets of text.", 72, "w:\\4ed\\code\\custom\\4coder_combined_write_commands.cpp", 53, 237 }, -{ PROC_LINKS(string_repeat, 0), false, "string_repeat", 13, "Example of query_user_string and query_user_number", 50, "w:\\4ed\\code\\custom\\4coder_examples.cpp", 38, 179 }, -{ PROC_LINKS(suppress_mouse, 0), false, "suppress_mouse", 14, "Hides the mouse and causes all mosue input (clicks, position, wheel) to be ignored.", 83, "w:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 479 }, -{ PROC_LINKS(swap_panels, 0), false, "swap_panels", 11, "Swaps the active panel with it's sibling.", 41, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1675 }, -{ PROC_LINKS(test_the_new_api, 0), false, "test_the_new_api", 16, "If you are reading this I forgot to delete this test, please let me know", 72, "w:\\4ed\\code\\custom\\4coder_examples.cpp", 38, 212 }, -{ PROC_LINKS(theme_lister, 0), true, "theme_lister", 12, "Opens an interactive list of all registered themes.", 51, "w:\\4ed\\code\\custom\\4coder_lists.cpp", 35, 784 }, -{ PROC_LINKS(to_lowercase, 0), false, "to_lowercase", 12, "Converts all ascii text in the range between the cursor and the mark to lowercase.", 82, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 567 }, -{ PROC_LINKS(to_uppercase, 0), false, "to_uppercase", 12, "Converts all ascii text in the range between the cursor and the mark to uppercase.", 82, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 554 }, -{ PROC_LINKS(toggle_filebar, 0), false, "toggle_filebar", 14, "Toggles the visibility status of the current view's filebar.", 60, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 711 }, -{ PROC_LINKS(toggle_fps_meter, 0), false, "toggle_fps_meter", 16, "Toggles the visibility of the FPS performance meter", 51, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 720 }, -{ PROC_LINKS(toggle_fullscreen, 0), false, "toggle_fullscreen", 17, "Toggle fullscreen mode on or off. The change(s) do not take effect until the next frame.", 89, "w:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 527 }, -{ PROC_LINKS(toggle_highlight_enclosing_scopes, 0), false, "toggle_highlight_enclosing_scopes", 33, "In code files scopes surrounding the cursor are highlighted with distinguishing colors.", 87, "w:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 515 }, -{ PROC_LINKS(toggle_highlight_line_at_cursor, 0), false, "toggle_highlight_line_at_cursor", 31, "Toggles the line highlight at the cursor.", 41, "w:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 509 }, -{ PROC_LINKS(toggle_line_numbers, 0), false, "toggle_line_numbers", 19, "Toggles the left margin line numbers.", 37, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 825 }, -{ PROC_LINKS(toggle_line_wrap, 0), false, "toggle_line_wrap", 16, "Toggles the line wrap setting on this buffer.", 45, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 831 }, -{ PROC_LINKS(toggle_mouse, 0), false, "toggle_mouse", 12, "Toggles the mouse suppression mode, see suppress_mouse and allow_mouse.", 71, "w:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 491 }, -{ PROC_LINKS(toggle_paren_matching_helper, 0), false, "toggle_paren_matching_helper", 28, "In code files matching parentheses pairs are colored with distinguishing colors.", 80, "w:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 521 }, -{ PROC_LINKS(toggle_show_whitespace, 0), false, "toggle_show_whitespace", 22, "Toggles the current buffer's whitespace visibility status.", 58, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 816 }, -{ PROC_LINKS(toggle_virtual_whitespace, 0), false, "toggle_virtual_whitespace", 25, "Toggles virtual whitespace for all files.", 41, "w:\\4ed\\code\\custom\\4coder_code_index.cpp", 40, 1176 }, -{ PROC_LINKS(tutorial_maximize, 0), false, "tutorial_maximize", 17, "Expand the tutorial window", 26, "w:\\4ed\\code\\custom\\4coder_tutorial.cpp", 38, 20 }, -{ PROC_LINKS(tutorial_minimize, 0), false, "tutorial_minimize", 17, "Shrink the tutorial window", 26, "w:\\4ed\\code\\custom\\4coder_tutorial.cpp", 38, 34 }, -{ PROC_LINKS(uncomment_line, 0), false, "uncomment_line", 14, "If present, delete '//' at the beginning of the line after leading whitespace.", 78, "w:\\4ed\\code\\custom\\4coder_combined_write_commands.cpp", 53, 137 }, -{ PROC_LINKS(undo, 0), false, "undo", 4, "Advances backwards through the undo history of the current buffer.", 66, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1825 }, -{ PROC_LINKS(undo_all_buffers, 0), false, "undo_all_buffers", 16, "Advances backward through the undo history in the buffer containing the most recent regular edit.", 97, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1902 }, -{ PROC_LINKS(view_buffer_other_panel, 0), false, "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, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1663 }, -{ PROC_LINKS(view_jump_list_with_lister, 0), false, "view_jump_list_with_lister", 26, "When executed on a buffer with jumps, creates a persistent lister for all the jumps", 83, "w:\\4ed\\code\\custom\\4coder_jump_lister.cpp", 41, 59 }, -{ PROC_LINKS(word_complete, 0), false, "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, "w:\\4ed\\code\\custom\\4coder_search.cpp", 36, 434 }, -{ PROC_LINKS(word_complete_drop_down, 0), false, "word_complete_drop_down", 23, "Word complete with drop down menu.", 34, "w:\\4ed\\code\\custom\\4coder_search.cpp", 36, 680 }, -{ PROC_LINKS(write_block, 0), false, "write_block", 11, "At the cursor, insert a block comment.", 38, "w:\\4ed\\code\\custom\\4coder_combined_write_commands.cpp", 53, 94 }, -{ PROC_LINKS(write_hack, 0), false, "write_hack", 10, "At the cursor, insert a '// HACK' comment, includes user name if it was specified in config.4coder.", 99, "w:\\4ed\\code\\custom\\4coder_combined_write_commands.cpp", 53, 82 }, -{ PROC_LINKS(write_note, 0), false, "write_note", 10, "At the cursor, insert a '// NOTE' comment, includes user name if it was specified in config.4coder.", 99, "w:\\4ed\\code\\custom\\4coder_combined_write_commands.cpp", 53, 88 }, -{ PROC_LINKS(write_space, 0), false, "write_space", 11, "Inserts a space.", 16, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 67 }, -{ PROC_LINKS(write_text_and_auto_indent, 0), false, "write_text_and_auto_indent", 26, "Inserts text and auto-indents the line on which the cursor sits if any of the text contains 'layout punctuation' such as ;:{}()[]# and new lines.", 145, "w:\\4ed\\code\\custom\\4coder_auto_indent.cpp", 41, 437 }, -{ PROC_LINKS(write_text_input, 0), false, "write_text_input", 16, "Inserts whatever text was used to trigger this command.", 55, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 59 }, -{ PROC_LINKS(write_todo, 0), false, "write_todo", 10, "At the cursor, insert a '// TODO' comment, includes user name if it was specified in config.4coder.", 99, "w:\\4ed\\code\\custom\\4coder_combined_write_commands.cpp", 53, 76 }, -{ PROC_LINKS(write_underscore, 0), false, "write_underscore", 16, "Inserts an underscore.", 22, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 73 }, -{ PROC_LINKS(write_zero_struct, 0), false, "write_zero_struct", 17, "At the cursor, insert a ' = {};'.", 33, "w:\\4ed\\code\\custom\\4coder_combined_write_commands.cpp", 53, 100 }, +{ PROC_LINKS(allow_mouse, 0), false, "allow_mouse", 11, "Shows the mouse and causes all mouse input to be processed normally.", 68, "W:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 485 }, +{ PROC_LINKS(auto_indent_line_at_cursor, 0), false, "auto_indent_line_at_cursor", 26, "Auto-indents the line on which the cursor sits.", 47, "W:\\4ed\\code\\custom\\4coder_auto_indent.cpp", 41, 417 }, +{ PROC_LINKS(auto_indent_range, 0), false, "auto_indent_range", 17, "Auto-indents the range between the cursor and the mark.", 55, "W:\\4ed\\code\\custom\\4coder_auto_indent.cpp", 41, 427 }, +{ PROC_LINKS(auto_indent_whole_file, 0), false, "auto_indent_whole_file", 22, "Audo-indents the entire current buffer.", 39, "W:\\4ed\\code\\custom\\4coder_auto_indent.cpp", 41, 408 }, +{ PROC_LINKS(backspace_alpha_numeric_boundary, 0), false, "backspace_alpha_numeric_boundary", 32, "Delete characters between the cursor position and the first alphanumeric boundary to the left.", 94, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 154 }, +{ PROC_LINKS(backspace_char, 0), false, "backspace_char", 14, "Deletes the character to the left of the cursor.", 48, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 96 }, +{ PROC_LINKS(basic_change_active_panel, 0), false, "basic_change_active_panel", 25, "Change the currently active panel, moving to the panel with the next highest view_id. Will not skipe the build panel if it is open.", 132, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 666 }, +{ PROC_LINKS(begin_clipboard_collection_mode, 0), true, "begin_clipboard_collection_mode", 31, "Allows the user to copy multiple strings from other applications before switching to 4coder and pasting them all.", 113, "W:\\4ed\\code\\custom\\4coder_clipboard.cpp", 39, 71 }, +{ PROC_LINKS(build_in_build_panel, 0), false, "build_in_build_panel", 20, "Looks for a build.bat, build.sh, or makefile in the current and parent directories. Runs the first that it finds and prints the output to *compilation*. Puts the *compilation* buffer in a panel at the footer of the current view.", 230, "W:\\4ed\\code\\custom\\4coder_build_commands.cpp", 44, 159 }, +{ PROC_LINKS(build_search, 0), false, "build_search", 12, "Looks for a build.bat, build.sh, or makefile in the current and parent directories. Runs the first that it finds and prints the output to *compilation*.", 153, "W:\\4ed\\code\\custom\\4coder_build_commands.cpp", 44, 122 }, +{ PROC_LINKS(center_view, 0), false, "center_view", 11, "Centers the view vertically on the line on which the cursor sits.", 65, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 195 }, +{ PROC_LINKS(change_active_panel, 0), false, "change_active_panel", 19, "Change the currently active panel, moving to the panel with the next highest view_id.", 85, "W:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 360 }, +{ PROC_LINKS(change_active_panel_backwards, 0), false, "change_active_panel_backwards", 29, "Change the currently active panel, moving to the panel with the next lowest view_id.", 84, "W:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 366 }, +{ PROC_LINKS(change_to_build_panel, 0), false, "change_to_build_panel", 21, "If the special build panel is open, makes the build panel the active panel.", 75, "W:\\4ed\\code\\custom\\4coder_build_commands.cpp", 44, 180 }, +{ PROC_LINKS(clean_all_lines, 0), false, "clean_all_lines", 15, "Removes trailing whitespace from all lines and removes all blank lines in the current buffer.", 93, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 646 }, +{ PROC_LINKS(clean_trailing_whitespace, 0), false, "clean_trailing_whitespace", 25, "Removes trailing whitespace from all lines in the current buffer.", 65, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 655 }, +{ PROC_LINKS(clear_all_themes, 0), false, "clear_all_themes", 16, "Clear the theme list", 20, "W:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 556 }, +{ PROC_LINKS(clear_clipboard, 0), false, "clear_clipboard", 15, "Clears the history of the clipboard", 35, "W:\\4ed\\code\\custom\\4coder_clipboard.cpp", 39, 221 }, +{ PROC_LINKS(click_set_cursor, 0), false, "click_set_cursor", 16, "Sets the cursor position to the mouse position.", 47, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 233 }, +{ PROC_LINKS(click_set_cursor_and_mark, 0), false, "click_set_cursor_and_mark", 25, "Sets the cursor position and mark to the mouse position.", 56, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 223 }, +{ PROC_LINKS(click_set_cursor_if_lbutton, 0), false, "click_set_cursor_if_lbutton", 27, "If the mouse left button is pressed, sets the cursor position to the mouse position.", 84, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 243 }, +{ PROC_LINKS(click_set_mark, 0), false, "click_set_mark", 14, "Sets the mark position to the mouse position.", 45, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 256 }, +{ PROC_LINKS(clipboard_record_clip, 0), false, "clipboard_record_clip", 21, "In response to a new clipboard contents events, saves the new clip onto the clipboard history", 93, "W:\\4ed\\code\\custom\\4coder_clipboard.cpp", 39, 7 }, +{ PROC_LINKS(close_all_code, 0), false, "close_all_code", 14, "Closes any buffer with a filename ending with an extension configured to be recognized as a code file type.", 107, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 844 }, +{ PROC_LINKS(close_build_panel, 0), false, "close_build_panel", 17, "If the special build panel is open, closes it.", 46, "W:\\4ed\\code\\custom\\4coder_build_commands.cpp", 44, 174 }, +{ PROC_LINKS(close_panel, 0), false, "close_panel", 11, "Closes the currently active panel if it is not the only panel open.", 67, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 674 }, +{ PROC_LINKS(command_documentation, 0), true, "command_documentation", 21, "Prompts the user to select a command then loads a doc buffer for that item", 74, "W:\\4ed\\code\\custom\\4coder_docs.cpp", 34, 190 }, +{ PROC_LINKS(command_lister, 0), true, "command_lister", 14, "Opens an interactive list of all registered commands.", 53, "W:\\4ed\\code\\custom\\4coder_lists.cpp", 35, 760 }, +{ PROC_LINKS(comment_line, 0), false, "comment_line", 12, "Insert '//' at the beginning of the line after leading whitespace.", 66, "W:\\4ed\\code\\custom\\4coder_combined_write_commands.cpp", 53, 125 }, +{ PROC_LINKS(comment_line_toggle, 0), false, "comment_line_toggle", 19, "Turns uncommented lines into commented lines and vice versa for comments starting with '//'.", 92, "W:\\4ed\\code\\custom\\4coder_combined_write_commands.cpp", 53, 149 }, +{ PROC_LINKS(copy, 0), false, "copy", 4, "Copy the text in the range from the cursor to the mark onto the clipboard.", 74, "W:\\4ed\\code\\custom\\4coder_clipboard.cpp", 39, 110 }, +{ PROC_LINKS(cursor_mark_swap, 0), false, "cursor_mark_swap", 16, "Swaps the position of the cursor and the mark.", 46, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 124 }, +{ PROC_LINKS(custom_api_documentation, 0), true, "custom_api_documentation", 24, "Prompts the user to select a Custom API item then loads a doc buffer for that item", 82, "W:\\4ed\\code\\custom\\4coder_docs.cpp", 34, 175 }, +{ PROC_LINKS(cut, 0), false, "cut", 3, "Cut the text in the range from the cursor to the mark onto the clipboard.", 73, "W:\\4ed\\code\\custom\\4coder_clipboard.cpp", 39, 119 }, +{ PROC_LINKS(decrease_face_size, 0), false, "decrease_face_size", 18, "Decrease the size of the face used by the current buffer.", 57, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 757 }, +{ PROC_LINKS(default_file_externally_modified, 0), false, "default_file_externally_modified", 32, "Notes the external modification of attached files by printing a message.", 72, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 2055 }, +{ PROC_LINKS(default_startup, 0), false, "default_startup", 15, "Default command for responding to a startup event", 49, "W:\\4ed\\code\\custom\\4coder_default_hooks.cpp", 43, 7 }, +{ PROC_LINKS(default_try_exit, 0), false, "default_try_exit", 16, "Default command for responding to a try-exit event", 50, "W:\\4ed\\code\\custom\\4coder_default_hooks.cpp", 43, 23 }, +{ PROC_LINKS(default_view_input_handler, 0), false, "default_view_input_handler", 26, "Input consumption loop for default view behavior", 48, "W:\\4ed\\code\\custom\\4coder_default_hooks.cpp", 43, 51 }, +{ PROC_LINKS(delete_alpha_numeric_boundary, 0), false, "delete_alpha_numeric_boundary", 29, "Delete characters between the cursor position and the first alphanumeric boundary to the right.", 95, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 161 }, +{ PROC_LINKS(delete_char, 0), false, "delete_char", 11, "Deletes the character to the right of the cursor.", 49, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 79 }, +{ PROC_LINKS(delete_current_scope, 0), false, "delete_current_scope", 20, "Deletes the braces surrounding the currently selected scope. Leaves the contents within the scope.", 99, "W:\\4ed\\code\\custom\\4coder_scope_commands.cpp", 44, 112 }, +{ PROC_LINKS(delete_file_query, 0), false, "delete_file_query", 17, "Deletes the file of the current buffer if 4coder has the appropriate access rights. Will ask the user for confirmation first.", 125, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1381 }, +{ PROC_LINKS(delete_line, 0), false, "delete_line", 11, "Delete the line the on which the cursor sits.", 45, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1553 }, +{ PROC_LINKS(delete_range, 0), false, "delete_range", 12, "Deletes the text in the range between the cursor and the mark.", 62, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 134 }, +{ PROC_LINKS(display_key_codes, 0), false, "display_key_codes", 17, "Example of input handling loop", 30, "W:\\4ed\\code\\custom\\4coder_examples.cpp", 38, 90 }, +{ PROC_LINKS(display_text_input, 0), false, "display_text_input", 18, "Example of to_writable and leave_current_input_unhandled", 56, "W:\\4ed\\code\\custom\\4coder_examples.cpp", 38, 137 }, +{ PROC_LINKS(double_backspace, 0), false, "double_backspace", 16, "Example of history group helpers", 32, "W:\\4ed\\code\\custom\\4coder_examples.cpp", 38, 10 }, +{ PROC_LINKS(duplicate_line, 0), false, "duplicate_line", 14, "Create a copy of the line on which the cursor sits.", 51, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1539 }, +{ PROC_LINKS(execute_any_cli, 0), false, "execute_any_cli", 15, "Queries for an output buffer name and system command, runs the system command as a CLI and prints the output to the specified buffer.", 133, "W:\\4ed\\code\\custom\\4coder_cli_command.cpp", 41, 22 }, +{ PROC_LINKS(execute_previous_cli, 0), false, "execute_previous_cli", 20, "If the command execute_any_cli has already been used, this will execute a CLI reusing the most recent buffer name and command.", 126, "W:\\4ed\\code\\custom\\4coder_cli_command.cpp", 41, 7 }, +{ PROC_LINKS(exit_4coder, 0), false, "exit_4coder", 11, "Attempts to close 4coder.", 25, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 844 }, +{ PROC_LINKS(goto_beginning_of_file, 0), false, "goto_beginning_of_file", 22, "Sets the cursor to the beginning of the file.", 45, "W:\\4ed\\code\\custom\\4coder_helper.cpp", 36, 2248 }, +{ PROC_LINKS(goto_end_of_file, 0), false, "goto_end_of_file", 16, "Sets the cursor to the end of the file.", 39, "W:\\4ed\\code\\custom\\4coder_helper.cpp", 36, 2256 }, +{ PROC_LINKS(goto_first_jump, 0), false, "goto_first_jump", 15, "If a buffer containing jump locations has been locked in, goes to the first jump in the buffer.", 95, "W:\\4ed\\code\\custom\\4coder_jump_sticky.cpp", 41, 525 }, +{ PROC_LINKS(goto_first_jump_same_panel_sticky, 0), false, "goto_first_jump_same_panel_sticky", 33, "If a buffer containing jump locations has been locked in, goes to the first jump in the buffer and views the buffer in the panel where the jump list was.", 153, "W:\\4ed\\code\\custom\\4coder_jump_sticky.cpp", 41, 542 }, +{ PROC_LINKS(goto_jump_at_cursor, 0), false, "goto_jump_at_cursor", 19, "If the cursor is found to be on a jump location, parses the jump location and brings up the file and position in another view and changes the active panel to the view containing the jump.", 187, "W:\\4ed\\code\\custom\\4coder_jump_sticky.cpp", 41, 348 }, +{ PROC_LINKS(goto_jump_at_cursor_same_panel, 0), false, "goto_jump_at_cursor_same_panel", 30, "If the cursor is found to be on a jump location, parses the jump location and brings up the file and position in this view, losing the compilation output or jump list.", 167, "W:\\4ed\\code\\custom\\4coder_jump_sticky.cpp", 41, 375 }, +{ PROC_LINKS(goto_line, 0), false, "goto_line", 9, "Queries the user for a number, and jumps the cursor to the corresponding line.", 78, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 852 }, +{ PROC_LINKS(goto_next_jump, 0), false, "goto_next_jump", 14, "If a buffer containing jump locations has been locked in, goes to the next jump in the buffer, skipping sub jump locations.", 123, "W:\\4ed\\code\\custom\\4coder_jump_sticky.cpp", 41, 464 }, +{ PROC_LINKS(goto_next_jump_no_skips, 0), false, "goto_next_jump_no_skips", 23, "If a buffer containing jump locations has been locked in, goes to the next jump in the buffer, and does not skip sub jump locations.", 132, "W:\\4ed\\code\\custom\\4coder_jump_sticky.cpp", 41, 494 }, +{ PROC_LINKS(goto_prev_jump, 0), false, "goto_prev_jump", 14, "If a buffer containing jump locations has been locked in, goes to the previous jump in the buffer, skipping sub jump locations.", 127, "W:\\4ed\\code\\custom\\4coder_jump_sticky.cpp", 41, 481 }, +{ PROC_LINKS(goto_prev_jump_no_skips, 0), false, "goto_prev_jump_no_skips", 23, "If a buffer containing jump locations has been locked in, goes to the previous jump in the buffer, and does not skip sub jump locations.", 136, "W:\\4ed\\code\\custom\\4coder_jump_sticky.cpp", 41, 511 }, +{ PROC_LINKS(hide_filebar, 0), false, "hide_filebar", 12, "Sets the current view to hide it's filebar.", 43, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 704 }, +{ PROC_LINKS(hide_scrollbar, 0), false, "hide_scrollbar", 14, "Sets the current view to hide it's scrollbar.", 45, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 690 }, +{ PROC_LINKS(hms_demo_tutorial, 0), false, "hms_demo_tutorial", 17, "Tutorial for built in 4coder bindings and features.", 51, "W:\\4ed\\code\\custom\\4coder_tutorial.cpp", 38, 869 }, +{ PROC_LINKS(if0_off, 0), false, "if0_off", 7, "Surround the range between the cursor and mark with an '#if 0' and an '#endif'", 78, "W:\\4ed\\code\\custom\\4coder_combined_write_commands.cpp", 53, 70 }, +{ PROC_LINKS(if_read_only_goto_position, 0), false, "if_read_only_goto_position", 26, "If the buffer in the active view is writable, inserts a character, otherwise performs goto_jump_at_cursor.", 106, "W:\\4ed\\code\\custom\\4coder_jump_sticky.cpp", 41, 564 }, +{ PROC_LINKS(if_read_only_goto_position_same_panel, 0), false, "if_read_only_goto_position_same_panel", 37, "If the buffer in the active view is writable, inserts a character, otherwise performs goto_jump_at_cursor_same_panel.", 117, "W:\\4ed\\code\\custom\\4coder_jump_sticky.cpp", 41, 581 }, +{ PROC_LINKS(increase_face_size, 0), false, "increase_face_size", 18, "Increase the size of the face used by the current buffer.", 57, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 746 }, +{ PROC_LINKS(interactive_kill_buffer, 0), true, "interactive_kill_buffer", 23, "Interactively kill an open buffer.", 34, "W:\\4ed\\code\\custom\\4coder_lists.cpp", 35, 520 }, +{ PROC_LINKS(interactive_new, 0), true, "interactive_new", 15, "Interactively creates a new file.", 33, "W:\\4ed\\code\\custom\\4coder_lists.cpp", 35, 660 }, +{ PROC_LINKS(interactive_open, 0), true, "interactive_open", 16, "Interactively opens a file.", 27, "W:\\4ed\\code\\custom\\4coder_lists.cpp", 35, 714 }, +{ PROC_LINKS(interactive_open_or_new, 0), true, "interactive_open_or_new", 23, "Interactively open a file out of the file system.", 49, "W:\\4ed\\code\\custom\\4coder_lists.cpp", 35, 611 }, +{ PROC_LINKS(interactive_switch_buffer, 0), true, "interactive_switch_buffer", 25, "Interactively switch to an open buffer.", 39, "W:\\4ed\\code\\custom\\4coder_lists.cpp", 35, 510 }, +{ PROC_LINKS(jump_to_definition, 0), true, "jump_to_definition", 18, "List all definitions in the code index and jump to one chosen by the user.", 74, "W:\\4ed\\code\\custom\\4coder_code_index_listers.cpp", 48, 12 }, +{ PROC_LINKS(jump_to_definition_at_cursor, 0), true, "jump_to_definition_at_cursor", 28, "Jump to the first definition in the code index matching an identifier at the cursor", 83, "W:\\4ed\\code\\custom\\4coder_code_index_listers.cpp", 48, 68 }, +{ PROC_LINKS(jump_to_last_point, 0), false, "jump_to_last_point", 18, "Read from the top of the point stack and jump there; if already there pop the top and go to the next option", 107, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1334 }, +{ PROC_LINKS(keyboard_macro_finish_recording, 0), false, "keyboard_macro_finish_recording", 31, "Stop macro recording, do nothing if macro recording is not already started", 74, "W:\\4ed\\code\\custom\\4coder_keyboard_macro.cpp", 44, 54 }, +{ PROC_LINKS(keyboard_macro_replay, 0), false, "keyboard_macro_replay", 21, "Replay the most recently recorded keyboard macro", 48, "W:\\4ed\\code\\custom\\4coder_keyboard_macro.cpp", 44, 77 }, +{ PROC_LINKS(keyboard_macro_start_recording, 0), false, "keyboard_macro_start_recording", 30, "Start macro recording, do nothing if macro recording is already started", 71, "W:\\4ed\\code\\custom\\4coder_keyboard_macro.cpp", 44, 41 }, +{ PROC_LINKS(kill_buffer, 0), false, "kill_buffer", 11, "Kills the current buffer.", 25, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1717 }, +{ PROC_LINKS(kill_tutorial, 0), false, "kill_tutorial", 13, "If there is an active tutorial, kill it.", 40, "W:\\4ed\\code\\custom\\4coder_tutorial.cpp", 38, 9 }, +{ PROC_LINKS(left_adjust_view, 0), false, "left_adjust_view", 16, "Sets the left size of the view near the x position of the cursor.", 65, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 210 }, +{ PROC_LINKS(list_all_functions_all_buffers, 0), false, "list_all_functions_all_buffers", 30, "Creates a jump list of lines from all buffers that appear to define or declare functions.", 89, "W:\\4ed\\code\\custom\\4coder_function_list.cpp", 43, 296 }, +{ PROC_LINKS(list_all_functions_all_buffers_lister, 0), true, "list_all_functions_all_buffers_lister", 37, "Creates a lister of locations that look like function definitions and declarations all buffers.", 95, "W:\\4ed\\code\\custom\\4coder_function_list.cpp", 43, 302 }, +{ PROC_LINKS(list_all_functions_current_buffer, 0), false, "list_all_functions_current_buffer", 33, "Creates a jump list of lines of the current buffer that appear to define or declare functions.", 94, "W:\\4ed\\code\\custom\\4coder_function_list.cpp", 43, 268 }, +{ PROC_LINKS(list_all_functions_current_buffer_lister, 0), true, "list_all_functions_current_buffer_lister", 40, "Creates a lister of locations that look like function definitions and declarations in the buffer.", 97, "W:\\4ed\\code\\custom\\4coder_function_list.cpp", 43, 278 }, +{ PROC_LINKS(list_all_locations, 0), false, "list_all_locations", 18, "Queries the user for a string and lists all exact case-sensitive matches found in all open buffers.", 99, "W:\\4ed\\code\\custom\\4coder_search.cpp", 36, 168 }, +{ PROC_LINKS(list_all_locations_case_insensitive, 0), false, "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, "W:\\4ed\\code\\custom\\4coder_search.cpp", 36, 180 }, +{ PROC_LINKS(list_all_locations_of_identifier, 0), false, "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, "W:\\4ed\\code\\custom\\4coder_search.cpp", 36, 192 }, +{ PROC_LINKS(list_all_locations_of_identifier_case_insensitive, 0), false, "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, "W:\\4ed\\code\\custom\\4coder_search.cpp", 36, 198 }, +{ PROC_LINKS(list_all_locations_of_selection, 0), false, "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, "W:\\4ed\\code\\custom\\4coder_search.cpp", 36, 204 }, +{ PROC_LINKS(list_all_locations_of_selection_case_insensitive, 0), false, "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, "W:\\4ed\\code\\custom\\4coder_search.cpp", 36, 210 }, +{ PROC_LINKS(list_all_locations_of_type_definition, 0), false, "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, "W:\\4ed\\code\\custom\\4coder_search.cpp", 36, 216 }, +{ PROC_LINKS(list_all_locations_of_type_definition_of_identifier, 0), false, "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, "W:\\4ed\\code\\custom\\4coder_search.cpp", 36, 224 }, +{ PROC_LINKS(list_all_substring_locations, 0), false, "list_all_substring_locations", 28, "Queries the user for a string and lists all case-sensitive substring matches found in all open buffers.", 103, "W:\\4ed\\code\\custom\\4coder_search.cpp", 36, 174 }, +{ PROC_LINKS(list_all_substring_locations_case_insensitive, 0), false, "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, "W:\\4ed\\code\\custom\\4coder_search.cpp", 36, 186 }, +{ PROC_LINKS(load_project, 0), false, "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, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 864 }, +{ PROC_LINKS(load_theme_current_buffer, 0), false, "load_theme_current_buffer", 25, "Parse the current buffer as a theme file and add the theme to the theme list. If the buffer has a .4coder postfix in it's name, it is removed when the name is saved.", 165, "W:\\4ed\\code\\custom\\4coder_config.cpp", 36, 1667 }, +{ PROC_LINKS(load_themes_default_folder, 0), false, "load_themes_default_folder", 26, "Loads all the theme files in the default theme folder.", 54, "W:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 533 }, +{ PROC_LINKS(load_themes_hot_directory, 0), false, "load_themes_hot_directory", 25, "Loads all the theme files in the current hot directory.", 55, "W:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 545 }, +{ PROC_LINKS(make_directory_query, 0), false, "make_directory_query", 20, "Queries the user for a name and creates a new directory with the given name.", 76, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1493 }, +{ PROC_LINKS(miblo_decrement_basic, 0), false, "miblo_decrement_basic", 21, "Decrement an integer under the cursor by one.", 45, "W:\\4ed\\code\\custom\\4coder_miblo_numbers.cpp", 43, 44 }, +{ PROC_LINKS(miblo_decrement_time_stamp, 0), false, "miblo_decrement_time_stamp", 26, "Decrement a time stamp under the cursor by one second. (format [m]m:ss or h:mm:ss", 81, "W:\\4ed\\code\\custom\\4coder_miblo_numbers.cpp", 43, 237 }, +{ PROC_LINKS(miblo_decrement_time_stamp_minute, 0), false, "miblo_decrement_time_stamp_minute", 33, "Decrement a time stamp under the cursor by one minute. (format [m]m:ss or h:mm:ss", 81, "W:\\4ed\\code\\custom\\4coder_miblo_numbers.cpp", 43, 249 }, +{ PROC_LINKS(miblo_increment_basic, 0), false, "miblo_increment_basic", 21, "Increment an integer under the cursor by one.", 45, "W:\\4ed\\code\\custom\\4coder_miblo_numbers.cpp", 43, 29 }, +{ PROC_LINKS(miblo_increment_time_stamp, 0), false, "miblo_increment_time_stamp", 26, "Increment a time stamp under the cursor by one second. (format [m]m:ss or h:mm:ss", 81, "W:\\4ed\\code\\custom\\4coder_miblo_numbers.cpp", 43, 231 }, +{ PROC_LINKS(miblo_increment_time_stamp_minute, 0), false, "miblo_increment_time_stamp_minute", 33, "Increment a time stamp under the cursor by one minute. (format [m]m:ss or h:mm:ss", 81, "W:\\4ed\\code\\custom\\4coder_miblo_numbers.cpp", 43, 243 }, +{ PROC_LINKS(mouse_wheel_change_face_size, 0), false, "mouse_wheel_change_face_size", 28, "Reads the state of the mouse wheel and uses it to either increase or decrease the face size.", 92, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 799 }, +{ PROC_LINKS(mouse_wheel_scroll, 0), false, "mouse_wheel_scroll", 18, "Reads the scroll wheel value from the mouse state and scrolls accordingly.", 74, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 266 }, +{ PROC_LINKS(move_down, 0), false, "move_down", 9, "Moves the cursor down one line.", 31, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 340 }, +{ PROC_LINKS(move_down_10, 0), false, "move_down_10", 12, "Moves the cursor down ten lines.", 32, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 352 }, +{ PROC_LINKS(move_down_textual, 0), false, "move_down_textual", 17, "Moves down to the next line of actual text, regardless of line wrapping.", 72, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 358 }, +{ PROC_LINKS(move_down_to_blank_line, 0), false, "move_down_to_blank_line", 23, "Seeks the cursor down to the next blank line.", 45, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 411 }, +{ PROC_LINKS(move_down_to_blank_line_end, 0), false, "move_down_to_blank_line_end", 27, "Seeks the cursor down to the next blank line and places it at the end of the line.", 82, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 435 }, +{ PROC_LINKS(move_down_to_blank_line_skip_whitespace, 0), false, "move_down_to_blank_line_skip_whitespace", 39, "Seeks the cursor down to the next blank line and places it at the end of the line.", 82, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 423 }, +{ PROC_LINKS(move_left, 0), false, "move_left", 9, "Moves the cursor one character to the left.", 43, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 441 }, +{ PROC_LINKS(move_left_alpha_numeric_boundary, 0), false, "move_left_alpha_numeric_boundary", 32, "Seek left for boundary between alphanumeric characters and non-alphanumeric characters.", 87, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 518 }, +{ PROC_LINKS(move_left_alpha_numeric_or_camel_boundary, 0), false, "move_left_alpha_numeric_or_camel_boundary", 41, "Seek left for boundary between alphanumeric characters or camel case word and non-alphanumeric characters.", 106, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 532 }, +{ PROC_LINKS(move_left_token_boundary, 0), false, "move_left_token_boundary", 24, "Seek left for the next beginning of a token.", 44, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 490 }, +{ PROC_LINKS(move_left_whitespace_boundary, 0), false, "move_left_whitespace_boundary", 29, "Seek left for the next boundary between whitespace and non-whitespace.", 70, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 475 }, +{ PROC_LINKS(move_left_whitespace_or_token_boundary, 0), false, "move_left_whitespace_or_token_boundary", 38, "Seek left for the next end of a token or boundary between whitespace and non-whitespace.", 88, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 504 }, +{ PROC_LINKS(move_line_down, 0), false, "move_line_down", 14, "Swaps the line under the cursor with the line below it, and moves the cursor down with it.", 90, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1533 }, +{ PROC_LINKS(move_line_up, 0), false, "move_line_up", 12, "Swaps the line under the cursor with the line above it, and moves the cursor up with it.", 88, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1527 }, +{ PROC_LINKS(move_right, 0), false, "move_right", 10, "Moves the cursor one character to the right.", 44, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 449 }, +{ PROC_LINKS(move_right_alpha_numeric_boundary, 0), false, "move_right_alpha_numeric_boundary", 33, "Seek right for boundary between alphanumeric characters and non-alphanumeric characters.", 88, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 511 }, +{ PROC_LINKS(move_right_alpha_numeric_or_camel_boundary, 0), false, "move_right_alpha_numeric_or_camel_boundary", 42, "Seek right for boundary between alphanumeric characters or camel case word and non-alphanumeric characters.", 107, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 525 }, +{ PROC_LINKS(move_right_token_boundary, 0), false, "move_right_token_boundary", 25, "Seek right for the next end of a token.", 39, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 483 }, +{ PROC_LINKS(move_right_whitespace_boundary, 0), false, "move_right_whitespace_boundary", 30, "Seek right for the next boundary between whitespace and non-whitespace.", 71, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 467 }, +{ PROC_LINKS(move_right_whitespace_or_token_boundary, 0), false, "move_right_whitespace_or_token_boundary", 39, "Seek right for the next end of a token or boundary between whitespace and non-whitespace.", 89, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 497 }, +{ PROC_LINKS(move_up, 0), false, "move_up", 7, "Moves the cursor up one line.", 29, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 334 }, +{ PROC_LINKS(move_up_10, 0), false, "move_up_10", 10, "Moves the cursor up ten lines.", 30, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 346 }, +{ PROC_LINKS(move_up_to_blank_line, 0), false, "move_up_to_blank_line", 21, "Seeks the cursor up to the next blank line.", 43, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 405 }, +{ PROC_LINKS(move_up_to_blank_line_end, 0), false, "move_up_to_blank_line_end", 25, "Seeks the cursor up to the next blank line and places it at the end of the line.", 80, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 429 }, +{ PROC_LINKS(move_up_to_blank_line_skip_whitespace, 0), false, "move_up_to_blank_line_skip_whitespace", 37, "Seeks the cursor up to the next blank line and places it at the end of the line.", 80, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 417 }, +{ PROC_LINKS(multi_paste, 0), false, "multi_paste", 11, "Paste multiple entries from the clipboard at once", 49, "W:\\4ed\\code\\custom\\4coder_clipboard.cpp", 39, 229 }, +{ PROC_LINKS(multi_paste_interactive, 0), false, "multi_paste_interactive", 23, "Paste multiple lines from the clipboard history, controlled with arrow keys", 75, "W:\\4ed\\code\\custom\\4coder_clipboard.cpp", 39, 371 }, +{ PROC_LINKS(multi_paste_interactive_quick, 0), false, "multi_paste_interactive_quick", 29, "Paste multiple lines from the clipboard history, controlled by inputing the number of lines to paste", 100, "W:\\4ed\\code\\custom\\4coder_clipboard.cpp", 39, 380 }, +{ PROC_LINKS(open_all_code, 0), false, "open_all_code", 13, "Open all code in the current directory. File types are determined by extensions. An extension is considered code based on the extensions specified in 4coder.config.", 164, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 850 }, +{ PROC_LINKS(open_all_code_recursive, 0), false, "open_all_code_recursive", 23, "Works as open_all_code but also runs in all subdirectories.", 59, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 856 }, +{ PROC_LINKS(open_file_in_quotes, 0), false, "open_file_in_quotes", 19, "Reads a filename from surrounding '\"' characters and attempts to open the corresponding file.", 94, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1618 }, +{ PROC_LINKS(open_in_other, 0), false, "open_in_other", 13, "Interactively opens a file in the other panel.", 46, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 2049 }, +{ PROC_LINKS(open_long_braces, 0), false, "open_long_braces", 16, "At the cursor, insert a '{' and '}' separated by a blank line.", 62, "W:\\4ed\\code\\custom\\4coder_combined_write_commands.cpp", 53, 46 }, +{ PROC_LINKS(open_long_braces_break, 0), false, "open_long_braces_break", 22, "At the cursor, insert a '{' and '}break;' separated by a blank line.", 68, "W:\\4ed\\code\\custom\\4coder_combined_write_commands.cpp", 53, 62 }, +{ PROC_LINKS(open_long_braces_semicolon, 0), false, "open_long_braces_semicolon", 26, "At the cursor, insert a '{' and '};' separated by a blank line.", 63, "W:\\4ed\\code\\custom\\4coder_combined_write_commands.cpp", 53, 54 }, +{ PROC_LINKS(open_matching_file_cpp, 0), false, "open_matching_file_cpp", 22, "If the current file is a *.cpp or *.h, attempts to open the corresponding *.h or *.cpp file in the other view.", 110, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1650 }, +{ PROC_LINKS(open_panel_hsplit, 0), false, "open_panel_hsplit", 17, "Create a new panel by horizontally splitting the active panel.", 62, "W:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 386 }, +{ PROC_LINKS(open_panel_vsplit, 0), false, "open_panel_vsplit", 17, "Create a new panel by vertically splitting the active panel.", 60, "W:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 376 }, +{ PROC_LINKS(page_down, 0), false, "page_down", 9, "Scrolls the view down one view height and moves the cursor down one view height.", 80, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 376 }, +{ PROC_LINKS(page_up, 0), false, "page_up", 7, "Scrolls the view up one view height and moves the cursor up one view height.", 76, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 368 }, +{ PROC_LINKS(paste, 0), false, "paste", 5, "At the cursor, insert the text at the top of the clipboard.", 59, "W:\\4ed\\code\\custom\\4coder_clipboard.cpp", 39, 130 }, +{ PROC_LINKS(paste_and_indent, 0), false, "paste_and_indent", 16, "Paste from the top of clipboard and run auto-indent on the newly pasted text.", 77, "W:\\4ed\\code\\custom\\4coder_clipboard.cpp", 39, 207 }, +{ PROC_LINKS(paste_next, 0), false, "paste_next", 10, "If the previous command was paste or paste_next, replaces the paste range with the next text down on the clipboard, otherwise operates as the paste command.", 156, "W:\\4ed\\code\\custom\\4coder_clipboard.cpp", 39, 164 }, +{ PROC_LINKS(paste_next_and_indent, 0), false, "paste_next_and_indent", 21, "Paste the next item on the clipboard and run auto-indent on the newly pasted text.", 82, "W:\\4ed\\code\\custom\\4coder_clipboard.cpp", 39, 214 }, +{ PROC_LINKS(place_in_scope, 0), false, "place_in_scope", 14, "Wraps the code contained in the range between cursor and mark with a new curly brace scope.", 91, "W:\\4ed\\code\\custom\\4coder_scope_commands.cpp", 44, 106 }, +{ PROC_LINKS(play_with_a_counter, 0), false, "play_with_a_counter", 19, "Example of query bar", 20, "W:\\4ed\\code\\custom\\4coder_examples.cpp", 38, 29 }, +{ PROC_LINKS(profile_clear, 0), false, "profile_clear", 13, "Clear all profiling information from 4coder's self profiler.", 60, "W:\\4ed\\code\\custom\\4coder_profile.cpp", 37, 226 }, +{ PROC_LINKS(profile_disable, 0), false, "profile_disable", 15, "Prevent 4coder's self profiler from gathering new profiling information.", 72, "W:\\4ed\\code\\custom\\4coder_profile.cpp", 37, 219 }, +{ PROC_LINKS(profile_enable, 0), false, "profile_enable", 14, "Allow 4coder's self profiler to gather new profiling information.", 65, "W:\\4ed\\code\\custom\\4coder_profile.cpp", 37, 212 }, +{ PROC_LINKS(profile_inspect, 0), true, "profile_inspect", 15, "Inspect all currently collected profiling information in 4coder's self profiler.", 80, "W:\\4ed\\code\\custom\\4coder_profile_inspect.cpp", 45, 886 }, +{ PROC_LINKS(project_command_lister, 0), false, "project_command_lister", 22, "Open a lister of all commands in the currently loaded project.", 62, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1290 }, +{ PROC_LINKS(project_fkey_command, 0), false, "project_fkey_command", 20, "Run an 'fkey command' configured in a project.4coder file. Determines the index of the 'fkey command' by which function key or numeric key was pressed to trigger the command.", 175, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 872 }, +{ PROC_LINKS(project_go_to_root_directory, 0), false, "project_go_to_root_directory", 28, "Changes 4coder's hot directory to the root directory of the currently loaded project. With no loaded project nothing hapepns.", 125, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 898 }, +{ PROC_LINKS(query_replace, 0), false, "query_replace", 13, "Queries the user for two strings, and incrementally replaces every occurence of the first string with the second string.", 120, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1280 }, +{ PROC_LINKS(query_replace_identifier, 0), false, "query_replace_identifier", 24, "Queries the user for a string, and incrementally replace every occurence of the word or token found at the cursor with the specified string.", 140, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1301 }, +{ PROC_LINKS(query_replace_selection, 0), false, "query_replace_selection", 23, "Queries the user for a string, and incrementally replace every occurence of the string found in the selected range with the specified string.", 141, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1317 }, +{ PROC_LINKS(quick_swap_buffer, 0), false, "quick_swap_buffer", 17, "Change to the most recently used buffer in this view - or to the top of the buffer stack if the most recent doesn't exist anymore", 129, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1697 }, +{ PROC_LINKS(redo, 0), false, "redo", 4, "Advances forwards through the undo history of the current buffer.", 65, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1876 }, +{ PROC_LINKS(redo_all_buffers, 0), false, "redo_all_buffers", 16, "Advances forward through the undo history in the buffer containing the most recent regular edit.", 96, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1973 }, +{ PROC_LINKS(rename_file_query, 0), false, "rename_file_query", 17, "Queries the user for a new name and renames the file of the current buffer, altering the buffer's name too.", 107, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1458 }, +{ PROC_LINKS(reopen, 0), false, "reopen", 6, "Reopen the current buffer from the hard drive.", 46, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1735 }, +{ PROC_LINKS(replace_in_all_buffers, 0), false, "replace_in_all_buffers", 22, "Queries the user for a needle and string. Replaces all occurences of needle with string in all editable buffers.", 112, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1190 }, +{ PROC_LINKS(replace_in_buffer, 0), false, "replace_in_buffer", 17, "Queries the user for a needle and string. Replaces all occurences of needle with string in the active buffer.", 109, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1181 }, +{ PROC_LINKS(replace_in_range, 0), false, "replace_in_range", 16, "Queries the user for a needle and string. Replaces all occurences of needle with string in the range between cursor and the mark in the active buffer.", 150, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1172 }, +{ PROC_LINKS(reverse_search, 0), false, "reverse_search", 14, "Begins an incremental search up through the current buffer for a user specified string.", 87, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1113 }, +{ PROC_LINKS(reverse_search_identifier, 0), false, "reverse_search_identifier", 25, "Begins an incremental search up through the current buffer for the word or token under the cursor.", 98, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1125 }, +{ PROC_LINKS(save, 0), false, "save", 4, "Saves the current buffer.", 25, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1725 }, +{ PROC_LINKS(save_all_dirty_buffers, 0), false, "save_all_dirty_buffers", 22, "Saves all buffers marked dirty (showing the '*' indicator).", 59, "W:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 458 }, +{ PROC_LINKS(save_to_query, 0), false, "save_to_query", 13, "Queries the user for a file name and saves the contents of the current buffer, altering the buffer's name too.", 110, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1425 }, +{ PROC_LINKS(search, 0), false, "search", 6, "Begins an incremental search down through the current buffer for a user specified string.", 89, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1107 }, +{ PROC_LINKS(search_identifier, 0), false, "search_identifier", 17, "Begins an incremental search down through the current buffer for the word or token under the cursor.", 100, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1119 }, +{ PROC_LINKS(seek_beginning_of_line, 0), false, "seek_beginning_of_line", 22, "Seeks the cursor to the beginning of the visual line.", 53, "W:\\4ed\\code\\custom\\4coder_helper.cpp", 36, 2236 }, +{ PROC_LINKS(seek_beginning_of_textual_line, 0), false, "seek_beginning_of_textual_line", 30, "Seeks the cursor to the beginning of the line across all text.", 62, "W:\\4ed\\code\\custom\\4coder_helper.cpp", 36, 2224 }, +{ PROC_LINKS(seek_end_of_line, 0), false, "seek_end_of_line", 16, "Seeks the cursor to the end of the visual line.", 47, "W:\\4ed\\code\\custom\\4coder_helper.cpp", 36, 2242 }, +{ PROC_LINKS(seek_end_of_textual_line, 0), false, "seek_end_of_textual_line", 24, "Seeks the cursor to the end of the line across all text.", 56, "W:\\4ed\\code\\custom\\4coder_helper.cpp", 36, 2230 }, +{ PROC_LINKS(select_all, 0), false, "select_all", 10, "Puts the cursor at the top of the file, and the mark at the bottom of the file.", 79, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 541 }, +{ PROC_LINKS(select_next_scope_absolute, 0), false, "select_next_scope_absolute", 26, "Finds the first scope started by '{' after the cursor and puts the cursor and mark on the '{' and '}'.", 102, "W:\\4ed\\code\\custom\\4coder_scope_commands.cpp", 44, 57 }, +{ PROC_LINKS(select_next_scope_after_current, 0), false, "select_next_scope_after_current", 31, "If a scope is selected, find first scope that starts after the selected scope. Otherwise find the first scope that starts after the cursor.", 139, "W:\\4ed\\code\\custom\\4coder_scope_commands.cpp", 44, 66 }, +{ PROC_LINKS(select_prev_scope_absolute, 0), false, "select_prev_scope_absolute", 26, "Finds the first scope started by '{' before the cursor and puts the cursor and mark on the '{' and '}'.", 103, "W:\\4ed\\code\\custom\\4coder_scope_commands.cpp", 44, 82 }, +{ PROC_LINKS(select_prev_top_most_scope, 0), false, "select_prev_top_most_scope", 26, "Finds the first scope that starts before the cursor, then finds the top most scope that contains that scope.", 108, "W:\\4ed\\code\\custom\\4coder_scope_commands.cpp", 44, 99 }, +{ PROC_LINKS(select_surrounding_scope, 0), false, "select_surrounding_scope", 24, "Finds the scope enclosed by '{' '}' surrounding the cursor and puts the cursor and mark on the '{' and '}'.", 107, "W:\\4ed\\code\\custom\\4coder_scope_commands.cpp", 44, 27 }, +{ PROC_LINKS(select_surrounding_scope_maximal, 0), false, "select_surrounding_scope_maximal", 32, "Selects the top-most scope that surrounds the cursor.", 53, "W:\\4ed\\code\\custom\\4coder_scope_commands.cpp", 44, 39 }, +{ PROC_LINKS(set_eol_mode_from_contents, 0), false, "set_eol_mode_from_contents", 26, "Sets the buffer's line ending mode to match the contents of the buffer.", 71, "W:\\4ed\\code\\custom\\4coder_eol.cpp", 33, 125 }, +{ PROC_LINKS(set_eol_mode_to_binary, 0), false, "set_eol_mode_to_binary", 22, "Puts the buffer in bin line ending mode.", 40, "W:\\4ed\\code\\custom\\4coder_eol.cpp", 33, 112 }, +{ PROC_LINKS(set_eol_mode_to_crlf, 0), false, "set_eol_mode_to_crlf", 20, "Puts the buffer in crlf line ending mode.", 41, "W:\\4ed\\code\\custom\\4coder_eol.cpp", 33, 86 }, +{ PROC_LINKS(set_eol_mode_to_lf, 0), false, "set_eol_mode_to_lf", 18, "Puts the buffer in lf line ending mode.", 39, "W:\\4ed\\code\\custom\\4coder_eol.cpp", 33, 99 }, +{ PROC_LINKS(set_face_size, 0), false, "set_face_size", 13, "Set face size of the face used by the current buffer.", 53, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 726 }, +{ PROC_LINKS(set_face_size_this_buffer, 0), false, "set_face_size_this_buffer", 25, "Set face size of the face used by the current buffer; if any other buffers are using the same face a new face is created so that only this buffer is effected", 157, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 768 }, +{ PROC_LINKS(set_mark, 0), false, "set_mark", 8, "Sets the mark to the current position of the cursor.", 52, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 115 }, +{ PROC_LINKS(set_mode_to_notepad_like, 0), false, "set_mode_to_notepad_like", 24, "Sets the edit mode to Notepad like.", 35, "W:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 503 }, +{ PROC_LINKS(set_mode_to_original, 0), false, "set_mode_to_original", 20, "Sets the edit mode to 4coder original.", 38, "W:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 497 }, +{ PROC_LINKS(setup_build_bat, 0), false, "setup_build_bat", 15, "Queries the user for several configuration options and initializes a new build batch script.", 92, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1239 }, +{ PROC_LINKS(setup_build_bat_and_sh, 0), false, "setup_build_bat_and_sh", 22, "Queries the user for several configuration options and initializes a new build batch script.", 92, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1251 }, +{ PROC_LINKS(setup_build_sh, 0), false, "setup_build_sh", 14, "Queries the user for several configuration options and initializes a new build shell script.", 92, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1245 }, +{ PROC_LINKS(setup_new_project, 0), false, "setup_new_project", 17, "Queries the user for several configuration options and initializes a new 4coder project with build scripts for every OS.", 120, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1232 }, +{ PROC_LINKS(show_filebar, 0), false, "show_filebar", 12, "Sets the current view to show it's filebar.", 43, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 697 }, +{ PROC_LINKS(show_scrollbar, 0), false, "show_scrollbar", 14, "Sets the current view to show it's scrollbar.", 45, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 683 }, +{ PROC_LINKS(show_the_log_graph, 0), true, "show_the_log_graph", 18, "Parses *log* and displays the 'log graph' UI", 44, "W:\\4ed\\code\\custom\\4coder_log_parser.cpp", 40, 993 }, +{ PROC_LINKS(snipe_backward_whitespace_or_token_boundary, 0), false, "snipe_backward_whitespace_or_token_boundary", 43, "Delete a single, whole token on or to the left of the cursor and post it to the clipboard.", 90, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 177 }, +{ PROC_LINKS(snipe_forward_whitespace_or_token_boundary, 0), false, "snipe_forward_whitespace_or_token_boundary", 42, "Delete a single, whole token on or to the right of the cursor and post it to the clipboard.", 91, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 185 }, +{ PROC_LINKS(snippet_lister, 0), true, "snippet_lister", 14, "Opens a snippet lister for inserting whole pre-written snippets of text.", 72, "W:\\4ed\\code\\custom\\4coder_combined_write_commands.cpp", 53, 237 }, +{ PROC_LINKS(string_repeat, 0), false, "string_repeat", 13, "Example of query_user_string and query_user_number", 50, "W:\\4ed\\code\\custom\\4coder_examples.cpp", 38, 179 }, +{ PROC_LINKS(suppress_mouse, 0), false, "suppress_mouse", 14, "Hides the mouse and causes all mosue input (clicks, position, wheel) to be ignored.", 83, "W:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 479 }, +{ PROC_LINKS(swap_panels, 0), false, "swap_panels", 11, "Swaps the active panel with it's sibling.", 41, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1675 }, +{ PROC_LINKS(test_the_new_api, 0), false, "test_the_new_api", 16, "If you are reading this I forgot to delete this test, please let me know", 72, "W:\\4ed\\code\\custom\\4coder_examples.cpp", 38, 212 }, +{ PROC_LINKS(theme_lister, 0), true, "theme_lister", 12, "Opens an interactive list of all registered themes.", 51, "W:\\4ed\\code\\custom\\4coder_lists.cpp", 35, 784 }, +{ PROC_LINKS(to_lowercase, 0), false, "to_lowercase", 12, "Converts all ascii text in the range between the cursor and the mark to lowercase.", 82, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 567 }, +{ PROC_LINKS(to_uppercase, 0), false, "to_uppercase", 12, "Converts all ascii text in the range between the cursor and the mark to uppercase.", 82, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 554 }, +{ PROC_LINKS(toggle_filebar, 0), false, "toggle_filebar", 14, "Toggles the visibility status of the current view's filebar.", 60, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 711 }, +{ PROC_LINKS(toggle_fps_meter, 0), false, "toggle_fps_meter", 16, "Toggles the visibility of the FPS performance meter", 51, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 720 }, +{ PROC_LINKS(toggle_fullscreen, 0), false, "toggle_fullscreen", 17, "Toggle fullscreen mode on or off. The change(s) do not take effect until the next frame.", 89, "W:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 527 }, +{ PROC_LINKS(toggle_highlight_enclosing_scopes, 0), false, "toggle_highlight_enclosing_scopes", 33, "In code files scopes surrounding the cursor are highlighted with distinguishing colors.", 87, "W:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 515 }, +{ PROC_LINKS(toggle_highlight_line_at_cursor, 0), false, "toggle_highlight_line_at_cursor", 31, "Toggles the line highlight at the cursor.", 41, "W:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 509 }, +{ PROC_LINKS(toggle_line_numbers, 0), false, "toggle_line_numbers", 19, "Toggles the left margin line numbers.", 37, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 825 }, +{ PROC_LINKS(toggle_line_wrap, 0), false, "toggle_line_wrap", 16, "Toggles the line wrap setting on this buffer.", 45, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 831 }, +{ PROC_LINKS(toggle_mouse, 0), false, "toggle_mouse", 12, "Toggles the mouse suppression mode, see suppress_mouse and allow_mouse.", 71, "W:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 491 }, +{ PROC_LINKS(toggle_paren_matching_helper, 0), false, "toggle_paren_matching_helper", 28, "In code files matching parentheses pairs are colored with distinguishing colors.", 80, "W:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 521 }, +{ PROC_LINKS(toggle_show_whitespace, 0), false, "toggle_show_whitespace", 22, "Toggles the current buffer's whitespace visibility status.", 58, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 816 }, +{ PROC_LINKS(toggle_virtual_whitespace, 0), false, "toggle_virtual_whitespace", 25, "Toggles virtual whitespace for all files.", 41, "W:\\4ed\\code\\custom\\4coder_code_index.cpp", 40, 1234 }, +{ PROC_LINKS(tutorial_maximize, 0), false, "tutorial_maximize", 17, "Expand the tutorial window", 26, "W:\\4ed\\code\\custom\\4coder_tutorial.cpp", 38, 20 }, +{ PROC_LINKS(tutorial_minimize, 0), false, "tutorial_minimize", 17, "Shrink the tutorial window", 26, "W:\\4ed\\code\\custom\\4coder_tutorial.cpp", 38, 34 }, +{ PROC_LINKS(uncomment_line, 0), false, "uncomment_line", 14, "If present, delete '//' at the beginning of the line after leading whitespace.", 78, "W:\\4ed\\code\\custom\\4coder_combined_write_commands.cpp", 53, 137 }, +{ PROC_LINKS(undo, 0), false, "undo", 4, "Advances backwards through the undo history of the current buffer.", 66, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1825 }, +{ PROC_LINKS(undo_all_buffers, 0), false, "undo_all_buffers", 16, "Advances backward through the undo history in the buffer containing the most recent regular edit.", 97, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1902 }, +{ PROC_LINKS(view_buffer_other_panel, 0), false, "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, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1663 }, +{ PROC_LINKS(view_jump_list_with_lister, 0), false, "view_jump_list_with_lister", 26, "When executed on a buffer with jumps, creates a persistent lister for all the jumps", 83, "W:\\4ed\\code\\custom\\4coder_jump_lister.cpp", 41, 59 }, +{ PROC_LINKS(word_complete, 0), false, "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, "W:\\4ed\\code\\custom\\4coder_search.cpp", 36, 434 }, +{ PROC_LINKS(word_complete_drop_down, 0), false, "word_complete_drop_down", 23, "Word complete with drop down menu.", 34, "W:\\4ed\\code\\custom\\4coder_search.cpp", 36, 680 }, +{ PROC_LINKS(write_block, 0), false, "write_block", 11, "At the cursor, insert a block comment.", 38, "W:\\4ed\\code\\custom\\4coder_combined_write_commands.cpp", 53, 94 }, +{ PROC_LINKS(write_hack, 0), false, "write_hack", 10, "At the cursor, insert a '// HACK' comment, includes user name if it was specified in config.4coder.", 99, "W:\\4ed\\code\\custom\\4coder_combined_write_commands.cpp", 53, 82 }, +{ PROC_LINKS(write_note, 0), false, "write_note", 10, "At the cursor, insert a '// NOTE' comment, includes user name if it was specified in config.4coder.", 99, "W:\\4ed\\code\\custom\\4coder_combined_write_commands.cpp", 53, 88 }, +{ PROC_LINKS(write_space, 0), false, "write_space", 11, "Inserts a space.", 16, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 67 }, +{ PROC_LINKS(write_text_and_auto_indent, 0), false, "write_text_and_auto_indent", 26, "Inserts text and auto-indents the line on which the cursor sits if any of the text contains 'layout punctuation' such as ;:{}()[]# and new lines.", 145, "W:\\4ed\\code\\custom\\4coder_auto_indent.cpp", 41, 437 }, +{ PROC_LINKS(write_text_input, 0), false, "write_text_input", 16, "Inserts whatever text was used to trigger this command.", 55, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 59 }, +{ PROC_LINKS(write_todo, 0), false, "write_todo", 10, "At the cursor, insert a '// TODO' comment, includes user name if it was specified in config.4coder.", 99, "W:\\4ed\\code\\custom\\4coder_combined_write_commands.cpp", 53, 76 }, +{ PROC_LINKS(write_underscore, 0), false, "write_underscore", 16, "Inserts an underscore.", 22, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 73 }, +{ PROC_LINKS(write_zero_struct, 0), false, "write_zero_struct", 17, "At the cursor, insert a ' = {};'.", 33, "W:\\4ed\\code\\custom\\4coder_combined_write_commands.cpp", 53, 100 }, }; static i32 fcoder_metacmd_ID_allow_mouse = 0; static i32 fcoder_metacmd_ID_auto_indent_line_at_cursor = 1; diff --git a/platform_win32/win32_4ed.cpp b/platform_win32/win32_4ed.cpp index fd81eeb9..d52bdf9a 100644 --- a/platform_win32/win32_4ed.cpp +++ b/platform_win32/win32_4ed.cpp @@ -756,12 +756,6 @@ win32_keycode_init(void){ keycode_lookup_table[VK_NUMPAD8] = KeyCode_NumPad8; keycode_lookup_table[VK_NUMPAD9] = KeyCode_NumPad9; - keycode_lookup_table[VK_MULTIPLY] = KeyCode_NumPadStar; - keycode_lookup_table[VK_ADD] = KeyCode_NumPadPlus; - keycode_lookup_table[VK_SUBTRACT] = KeyCode_NumPadMinus; - keycode_lookup_table[VK_DECIMAL] = KeyCode_NumPadDot; - keycode_lookup_table[VK_DIVIDE] = KeyCode_NumPadSlash; - for (i32 i = 0xDF; i < 0xFF; i += 1){ keycode_lookup_table[i] = KeyCode_Ex0 + 1; } @@ -1625,6 +1619,9 @@ win32_gl_create_window(HWND *wnd_out, HGLRC *context_out, DWORD style, RECT rect DestroyWindow(wnd); SetLastError(error); } + else{ + ReleaseDC(wnd, dc); + } } } From 8915bcceba075082f7396d7887138787d2a837ab Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Thu, 22 Oct 2020 14:57:28 -0700 Subject: [PATCH 2/9] [variables] added new 4coder variables system --- custom/4coder_casey_index.cpp | 708 ---------------------------- custom/4coder_casey_index.h | 100 ---- custom/4coder_default_framework.cpp | 4 +- custom/4coder_default_framework.h | 14 + custom/4coder_default_hooks.cpp | 30 +- custom/4coder_default_include.cpp | 2 + custom/4coder_variables.cpp | 237 ++++++++++ custom/4coder_variables.h | 51 ++ custom/generated/command_metadata.h | 2 +- ship_files/changes.txt | 7 + 10 files changed, 339 insertions(+), 816 deletions(-) delete mode 100644 custom/4coder_casey_index.cpp delete mode 100644 custom/4coder_casey_index.h create mode 100644 custom/4coder_variables.cpp create mode 100644 custom/4coder_variables.h diff --git a/custom/4coder_casey_index.cpp b/custom/4coder_casey_index.cpp deleted file mode 100644 index d4d333d3..00000000 --- a/custom/4coder_casey_index.cpp +++ /dev/null @@ -1,708 +0,0 @@ -static Content_Index *global_content_index = 0; - -internal String get_name_of_index_type(Indexed_Content_Element_Type content_type) -{ - String result = {}; - - switch(content_type) - { - case ContentType_Unspecified: {result = make_lit_string("Unspecified");} break; - - case ContentType_Function: {result = make_lit_string("Function");} break; - case ContentType_Type: {result = make_lit_string("Type");} break; - case ContentType_Macro: {result = make_lit_string("Macro");} break; - case ContentType_EnumValue: {result = make_lit_string("Enum Value");} break; - case ContentType_ForwardDeclaration: {result = make_lit_string("Forward Declaration");} break; - - case ContentType_TODO: {result = make_lit_string("TODO");} break; - case ContentType_NOTE: {result = make_lit_string("Note");} break; - case ContentType_IMPORTANT: {result = make_lit_string("Important");} break; - case ContentType_STUDY: {result = make_lit_string("Study");} break; - } - - return(result); -} - -static Content_Index * -create_content_index(Application_Links *app) -{ - // TODO(casey): I really just want this to be its own allocating arena, but I can't find anything like that in 4coder? - // All arenas seem to be fixed size and they can't get more memory if they run out :( - Content_Index *index = (Content_Index *)malloc(sizeof(Content_Index)); - - memset(index, 0, sizeof(*index)); - - return(index); -} - -static Indexed_Content_Element ** -get_element_slot_for_name(Content_Index *index, String name) -{ - Indexed_Content_Element **slot = &index->name_hash[table_hash_u8((uint8_t *)name.str, name.size) % ArrayCount(index->name_hash)]; - return(slot); -} - -static Indexed_Buffer * -get_or_create_indexed_buffer(Content_Index *index, Buffer_ID buffer_id) -{ - Indexed_Buffer *result = 0; - - Indexed_Buffer **slot = &index->buffer_hash[buffer_id % ArrayCount(index->buffer_hash)]; - for(Indexed_Buffer *search = *slot; - search; - search = search->next_in_hash) - { - if(search->buffer_id == buffer_id) - { - result = search; - break; - } - } - - if(!result) - { - result = (Indexed_Buffer *)malloc(sizeof(Indexed_Buffer)); - result->buffer_id = buffer_id; - result->first_tag = 0; - result->next_in_hash = *slot; - *slot = result; - } - - return(result); -} - -static color_pair -get_color_pair_for(Indexed_Content_Element_Type type) -{ - color_pair result = {}; - - switch(type) - { - case ContentType_Function: - { - result.fore = CC_Function; - } break; - - case ContentType_Type: - { - result.fore = CC_Type; - } break; - - case ContentType_Macro: - { - result.fore = CC_Macro; - } break; - - case ContentType_EnumValue: - { - result.fore = CC_EnumValue; - } break; - - case ContentType_ForwardDeclaration: - { - result.fore = CC_ForwardDeclaration; - } break; - - case ContentType_TODO: - { - result.fore = CC_TODO; - } break; - - case ContentType_NOTE: - { - result.fore = CC_NOTE; - } break; - - case ContentType_IMPORTANT: - { - result.fore = CC_IMPORTANT; - } break; - - case ContentType_STUDY: - { - result.fore = CC_STUDY; - } break; - } - - return(result); -} - -static Indexed_Content_Element * -begin_element_in_index(Content_Index *index, Indexed_Content_Element_Type type, Buffer_ID buffer_id, int32_t location, - int32_t name_size, int32_t content_size) -{ - Indexed_Content_Element *elem = 0; - - // TODO(casey): I really just want this to be its own allocating arena, but I can't find anything like that in 4coder? - // All arenas seem to be fixed size and they can't get more memory if they run out :( - uint8_t *mem = (uint8_t *)malloc(sizeof(Indexed_Content_Element) + name_size + content_size); - if(mem) - { - elem = (Indexed_Content_Element *)mem; - - elem->next_in_hash = 0; - elem->type = type; - elem->name.memory_size = elem->name.size = name_size; - elem->name.str = (char *)(elem + 1); - elem->content.memory_size = elem->content.size = content_size; - elem->content.str = elem->name.str + name_size; - - elem->color = get_color_pair_for(type); - - elem->buffer_id = buffer_id; - elem->last_known_location = location; - - index->total_string_space += name_size + content_size; - ++index->element_count; - } - - return(elem); -} - -static void -end_element_in_index(Content_Index *index, Indexed_Content_Element *elem, u32 flags) -{ - if(elem) - { - // NOTE(casey): By convention, we make content into a single line, and remove leading/trailing whitespace - condense_whitespace(&elem->name); - condense_whitespace(&elem->content); - - Indexed_Content_Element **slot = &index->unhashed; - if(!(flags & IndexFlag_NoNameLookup)) - { - slot = get_element_slot_for_name(index, elem->name); - } - elem->next_in_hash = *slot; - *slot = elem; - - Indexed_Buffer *buffer = get_or_create_indexed_buffer(index, elem->buffer_id); - ++buffer->element_type_counts[elem->type]; - ++index->element_type_counts[elem->type]; - } -} - -static Indexed_Content_Element * -add_element_to_index(Application_Links *app, Content_Index *index, Indexed_Content_Element_Type type, Buffer_Summary *buffer, int32_t location, - int32_t name_start, int32_t name_end, - int32_t content_start, int32_t content_end, - u32 flags = 0) -{ - Indexed_Content_Element *elem = 0; - if((name_start <= name_end) && - (content_start <= content_end)) - { - elem = begin_element_in_index(index, type, buffer->buffer_id, location, name_end - name_start, content_end - content_start); - if(elem) - { - buffer_read_range(app, buffer, name_start, name_end, elem->name.str); - buffer_read_range(app, buffer, content_start, content_end, elem->content.str); - end_element_in_index(index, elem, flags); - } - } - - return(elem); -} - -static Indexed_Content_Element * -add_element_to_index(Content_Index *index, Indexed_Content_Element_Type type, Buffer_ID buffer_id, int32_t location, String name, String content, - u32 flags = 0) -{ - Indexed_Content_Element *elem = begin_element_in_index(index, type, buffer_id, location, name.size, content.size); - if(elem) - { - copy_ss(&elem->name, name); - copy_ss(&elem->content, content); - end_element_in_index(index, elem, flags); - } - - return(elem); -} - -static Indexed_Content_Tag * -add_tag_to_index(Content_Index *index, Buffer_Summary *buffer, uint32_t type, int32_t start, int32_t end, String content) -{ - Indexed_Content_Tag *tag = 0; - - if(start <= end) - { - Indexed_Buffer *index_buffer = get_or_create_indexed_buffer(index, buffer->buffer_id); - // TODO(casey): I really just want this to be its own allocating arena, but I can't find anything like that in 4coder? - // All arenas seem to be fixed size and they can't get more memory if they run out :( - uint8_t *mem = (uint8_t *)malloc(sizeof(Indexed_Content_Tag) + content.size); - if(mem) - { - tag = (Indexed_Content_Tag *)mem; - tag->content.size = tag->content.memory_size = content.size; - tag->content.str = (char *)(tag + 1); - copy_ss(&tag->content, content); - tag->type = type; - tag->start = start; - tag->end = end; - tag->next_in_buffer = index_buffer->first_tag; - index_buffer->first_tag = tag; - } - } - - return(tag); -} - -static Indexed_Content_Element * -get_element_by_name(Content_Index *index, String name) -{ - Indexed_Content_Element *result = 0; - - if(index) - { - for(Indexed_Content_Element *elem = *get_element_slot_for_name(index, name); - elem; - elem = elem->next_in_hash) - { - if(compare_ss(elem->name, name) == 0) - { - result = elem; - break; - } - } - } - - return(result); -} - -static void -remove_buffer_from_index(Application_Links *app, Content_Index *index, Buffer_ID buffer_id) -{ - for(int hash_index = 0; - hash_index <= ArrayCount(index->name_hash); - ++hash_index) - { - for(Indexed_Content_Element **elem_ptr = &index->name_hash[hash_index]; - *elem_ptr; - ) - { - Indexed_Content_Element *elem = *elem_ptr; - if(elem->buffer_id == buffer_id) - { - *elem_ptr = elem->next_in_hash; - free(elem); - } - else - { - elem_ptr = &elem->next_in_hash; - } - } - } - - Indexed_Buffer *index_buffer = get_or_create_indexed_buffer(index, buffer_id); - while(index_buffer->first_tag) - { - Indexed_Content_Tag *tag = index_buffer->first_tag; - index_buffer->first_tag = tag->next_in_buffer; - free(tag); - } - - for(u32 type_index = 0; - type_index < ContentType_Count; - ++type_index) - { - index->element_type_counts[type_index] -= index_buffer->element_type_counts[type_index]; - index_buffer->element_type_counts[type_index] = 0; - } -} - -static void -add_buffer_to_index(Application_Links *app, Content_Index *index, Buffer_Summary *buffer) -{ - ++index->buffer_count; - - Token_Iterator iter = iterate_tokens(app, buffer, 0); - - int32_t paren_level = 0; - int32_t brace_level = 0; - - while(iter.valid) - { - Cpp_Token token = get_next_token(app, &iter); - - if(token.flags & CPP_TFLAG_PP_BODY) - { - // TODO(casey): Do we need to pick up macros here? - } - else - { - switch(token.type) - { - case CPP_TOKEN_COMMENT: - { - // NOTE(casey): Comments can contain special operations that we want to perform, so we thunk to a special parser to handle those - parse_comment(app, index, buffer, token); - } break; - - case CPP_PP_DEFINE: - { - int32_t content_start = token.start; - token = get_next_token(app, &iter); - - // TODO(casey): Allen, how do I scan for the next "not continued newline"? - int32_t content_end = token.start + token.size; - - add_element_to_index(app, index, ContentType_Macro, buffer, token.start, - token.start, token.start + token.size, - content_start, content_end); - } break; - - case CPP_TOKEN_KEY_TYPE_DECLARATION: - { - bool32 forward_declaration = true; - int32_t content_start = token.start; - Cpp_Token element_name = {}; - Cpp_Token last_identifier = {}; - - String typedef_keyword = make_lit_string("typedef"); - if(token_text_is(app, buffer, token, typedef_keyword)) - { - // NOTE(casey): Typedefs can't be "forward declared", so we always record their location. - forward_declaration = false; - - // NOTE(casey): This is a simple "usually works" parser for typedefs. It is well-known that C grammar - // doesn't actually allow you to parse typedefs properly without actually knowing the declared types - // at the time, which of course we cannot do since we parse per-file, and don't even know things we - // would need (like -D switches, etc.) - - // TODO(casey): If eventually this were upgraded to a more thoughtful parser, struct/union/enum defs - // would be parsed from brace to brace, so they could be handled recursively inside of a typedef for - // the pattern "typedef struct {} foo;", which currently we do not handle (we ignore the foo). - int typedef_paren_level = 0; - while(iter.valid) - { - token = get_next_token(app, &iter); - if(token.type == CPP_TOKEN_IDENTIFIER) - { - last_identifier = token; - } - else if(token.type == CPP_TOKEN_PARENTHESE_OPEN) - { - if(typedef_paren_level == 0) - { - // NOTE(casey): If we are going back into a parenthetical, it means that whatever the last - // identifier we saw is our best candidate. - element_name = last_identifier; - } - ++typedef_paren_level; - } - else if(token.type == CPP_TOKEN_PARENTHESE_CLOSE) - { - --typedef_paren_level; - } - else if(token.type == CPP_TOKEN_KEY_TYPE_DECLARATION) - { - // TODO(casey): If we _really_ wanted to, we could parse the type here recursively, - // and then we could capture things that were named differently a la "typedef struct foo {...} bar;" - // but I think that should wait until the 4coder parser is more structural, because I don't - // know how much parsing we _really_ want to do here. - forward_declaration = true; - break; - } - else if(token.type == CPP_TOKEN_SEMICOLON) - { - break; - } - } - - if(element_name.size == 0) - { - element_name = last_identifier; - } - } - - if(!element_name.size) - { - while(iter.valid) - { - token = peek_token(app, &iter); - if(token.type == CPP_TOKEN_IDENTIFIER) - { - element_name = token; - get_next_token(app, &iter); - } - else if((token.type == CPP_TOKEN_KEY_MODIFIER) || - (token.type == CPP_TOKEN_KEY_QUALIFIER) || - (token.type == CPP_TOKEN_KEY_ACCESS) || - (token.type == CPP_TOKEN_KEY_LINKAGE)) - { - // NOTE(casey): Let it go. - get_next_token(app, &iter); - } - else if(token.type == CPP_TOKEN_BRACE_OPEN) - { - // NOTE(casey): It's probably type definition - forward_declaration = false; - break; - } - else - { - // NOTE(casey): It's probably a forward declaration - break; - } - } - } - - int32_t content_end = token.start; - - if(element_name.size) - { - Indexed_Content_Element_Type type = ContentType_Type; - if(forward_declaration) - { - type = ContentType_ForwardDeclaration; - } - - add_element_to_index(app, index, type, buffer, element_name.start, - element_name.start, element_name.start + element_name.size, - content_start, content_end); - } - } break; - - case CPP_TOKEN_PARENTHESE_OPEN: - { - ++paren_level; - } break; - - case CPP_TOKEN_PARENTHESE_CLOSE: - { - --paren_level; - } break; - - case CPP_TOKEN_BRACE_OPEN: - { - if((paren_level == 0) && - (brace_level == 0)) - { - // NOTE(casey): This is presumably a function, see if we can find it's name. - int32_t content_end = token.start; - int32_t content_start = content_end; - int32_t name_start = 0; - int32_t name_end = 0; - - Token_Iterator back = iter; - get_prev_token(app, &back); - get_prev_token(app, &back); - Cpp_Token comment_pass = get_prev_token(app, &back); - while(comment_pass.type == CPP_TOKEN_COMMENT) - { - comment_pass = get_prev_token(app, &back); - } - if(comment_pass.type == CPP_TOKEN_PARENTHESE_CLOSE) - { - paren_level = -1; - while(back.valid) - { - if(token.type != CPP_TOKEN_COMMENT) - { - content_start = token.start; - } - token = get_prev_token(app, &back); - if((paren_level == 0) && - (brace_level == 0) && - ((token.flags & CPP_TFLAG_PP_BODY) || - (token.type == CPP_TOKEN_BRACE_CLOSE) || - (token.type == CPP_TOKEN_SEMICOLON) || - (token.type == CPP_TOKEN_EOF))) - { - break; - } - else - { - switch(token.type) - { - case CPP_TOKEN_PARENTHESE_OPEN: - { - ++paren_level; - } break; - - case CPP_TOKEN_PARENTHESE_CLOSE: - { - --paren_level; - } break; - - case CPP_TOKEN_BRACE_OPEN: - { - ++brace_level; - } break; - - case CPP_TOKEN_BRACE_CLOSE: - { - --brace_level; - } break; - - case CPP_TOKEN_IDENTIFIER: - { - if((paren_level == 0) && - (brace_level == 0) && - (name_start == 0)) - { - name_start = token.start; - name_end = token.start + token.size; - Token_Iterator probe = back; - get_next_token(app, &probe); - for(;;) - { - Cpp_Token test = get_next_token(app, &probe); - if((test.type == 0) || - (test.type == CPP_TOKEN_EOF) || - (test.type == CPP_TOKEN_PARENTHESE_CLOSE) || - (test.type == CPP_TOKEN_PARENTHESE_OPEN)) - { - name_end = test.start; - break; - } - } - } - } break; - } - } - } - - if(name_start < name_end) - { - Indexed_Content_Element_Type type = ContentType_Function; - add_element_to_index(app, index, type, buffer, name_start, - name_start, name_end, - content_start, content_end); - } - - brace_level = 0; - paren_level = 0; - } - } - - ++brace_level; - } break; - - case CPP_TOKEN_BRACE_CLOSE: - { - --brace_level; - } break; - } - } - } -} - -static void -add_all_buffers_to_index(Application_Links *app, Content_Index *index) -{ - for(Buffer_Summary buffer = get_buffer_first(app, AccessAll); - buffer.exists; - get_buffer_next(app, &buffer, AccessAll)) - { - int32_t Unimportant = true; - buffer_get_setting(app, &buffer, BufferSetting_Unimportant, &Unimportant); - - if(buffer.tokens_are_ready && !Unimportant) - { - add_buffer_to_index(app, index, &buffer); - } - } -} - -static void -update_index_for_buffer(Application_Links *app, Content_Index *index, Buffer_Summary *buffer) -{ - remove_buffer_from_index(app, index, buffer->buffer_id); - add_buffer_to_index(app, index, buffer); -} - -static Content_Index * -get_global_content_index(Application_Links *app) -{ - Content_Index *result = global_content_index; - if(!result) - { - global_content_index = create_content_index(app); - add_all_buffers_to_index(app, global_content_index); - result = global_content_index; - } - - return(result); -} - -static void -jump_to_element(Application_Links *app, View_Summary *view, Indexed_Content_Element *elem) -{ - if (view->buffer_id != elem->buffer_id) - { - view_set_buffer(app, view, elem->buffer_id, 0); - } - Buffer_Seek seek; - seek.type = buffer_seek_pos; - seek.pos = elem->last_known_location;; - view_set_cursor(app, view, seek, true); -} - -static void -jump_to_element_activate(Application_Links *app, Partition *scratch, Heap *heap, - View_Summary *view, Lister_State *state, - String text_field, void *user_data, bool32 activated_by_mouse) -{ - lister_default(app, scratch, heap, view, state, ListerActivation_Finished); - if(user_data) - { - jump_to_element(app, view, (Indexed_Content_Element *)user_data); - } -} - -typedef bool32 element_type_predicate(Application_Links *app, Content_Index *index, Indexed_Content_Element *elem, void *user_data); - -static bool32 -element_is_definition(Application_Links *app, Content_Index *index, Indexed_Content_Element *elem, void *user_data) -{ - bool32 result = ((elem->type == ContentType_Function) || - (elem->type == ContentType_Type) || - (elem->type == ContentType_Macro) || - (elem->type == ContentType_EnumValue)); - return(result); -} - -static bool32 -element_type_equals(Application_Links *app, Content_Index *index, Indexed_Content_Element *elem, void *user_data) -{ - bool32 result = (elem->type == (uint64_t)user_data); - return(result); -} - -static void -jump_to_element_lister(Application_Links *app, char *Label, element_type_predicate *predicate, void *user_data = 0) -{ - Partition *arena = &global_part; - - View_Summary view = get_active_view(app, AccessAll); - view_end_ui_mode(app, &view); - Temp_Memory temp = begin_temp_memory(arena); - - Content_Index *index = get_global_content_index(app); - - Lister_Option *options = push_array(arena, Lister_Option, index->element_count); - int32_t option_index = 0; - for(int hash_index = 0; - hash_index <= ArrayCount(index->name_hash); - ++hash_index) - { - for(Indexed_Content_Element *elem = index->name_hash[hash_index]; - elem; - elem = elem->next_in_hash) - { - if(predicate(app, index, elem, user_data)) - { - options[option_index].text_color = get_color(elem->color.fore); - options[option_index].pop_color = get_color(CC_DefaultText); - options[option_index].back_color = get_color(elem->color.back); - options[option_index].string = elem->name; - options[option_index].status = elem->content; - options[option_index].user_data = elem; - ++option_index; - } - } - } - begin_integrated_lister__basic_list(app, Label, jump_to_element_activate, 0, 0, options, option_index, index->total_string_space, &view); - end_temp_memory(temp); -} diff --git a/custom/4coder_casey_index.h b/custom/4coder_casey_index.h deleted file mode 100644 index 0ca1c552..00000000 --- a/custom/4coder_casey_index.h +++ /dev/null @@ -1,100 +0,0 @@ -/* date = October 18th 2020 3:41 pm */ - -#ifndef FCODER_CASEY_INDEX_H -#define FCODER_CASEY_INDEX_H - -struct color_pair -{ - casey_color_id fore; - casey_color_id back; -}; - -enum Indexed_Content_Element_Type -{ - ContentType_Unspecified, - - ContentType_Function, - ContentType_Type, - ContentType_Macro, - ContentType_EnumValue, - ContentType_ForwardDeclaration, - - ContentType_TODO, - ContentType_NOTE, - ContentType_IMPORTANT, - ContentType_STUDY, - - ContentType_Count, -}; - -struct Indexed_Content_Element -{ - Indexed_Content_Element *next_in_hash; - uint32_t type; - - String name; - String content; - - color_pair color; - - Buffer_ID buffer_id; - int32_t last_known_location; -}; - -enum Indexed_Content_Flag -{ - IndexFlag_NoNameLookup = 0x1, -}; - -enum Indexed_Content_Tag_Type -{ - TagType_Unspecified , - - TagType_Label, - TagType_Scope, - TagType_Highlight, -}; -struct Indexed_Content_Tag -{ - Indexed_Content_Tag *next_in_buffer; - String content; - - uint32_t type; - int32_t start; - int32_t end; - - color_pair color; -}; - -struct Indexed_Buffer -{ - Indexed_Buffer *next_in_hash; - Buffer_ID buffer_id; - - int32_t element_type_counts[ContentType_Count]; - - // TODO(casey): I really want a growable arena here, so I don't have to manage this memory. Everything - // gets cleared by buffer. - - // TODO(casey): This should be a spatial query so it is more scalable - Indexed_Content_Tag *first_tag; -}; - -struct Content_Index -{ - int32_t buffer_count; - int32_t element_count; - int32_t total_string_space; - - int32_t element_type_counts[ContentType_Count]; - - Indexed_Buffer *buffer_hash[257]; - - // NOTE(casey): unhashed _must_ come immediately aftter name_hash, as they are treated as contiguous - // { - Indexed_Content_Element *name_hash[4099]; - Indexed_Content_Element *unhashed; - // } -}; - -#endif //4CODER_CASEY_INDEX_H diff --git a/custom/4coder_default_framework.cpp b/custom/4coder_default_framework.cpp index 400815ee..91cba6be 100644 --- a/custom/4coder_default_framework.cpp +++ b/custom/4coder_default_framework.cpp @@ -1013,7 +1013,9 @@ function void set_next_rewrite(Application_Links *app, View_ID view, Rewrite_Type rewrite){ Managed_Scope scope = view_get_managed_scope(app, view); Rewrite_Type *next_rewrite = scope_attachment(app, scope, view_next_rewrite_loc, Rewrite_Type); - *next_rewrite = rewrite; + if (next_rewrite != 0){ + *next_rewrite = rewrite; + } } function void diff --git a/custom/4coder_default_framework.h b/custom/4coder_default_framework.h index 7b3095d7..4853b34c 100644 --- a/custom/4coder_default_framework.h +++ b/custom/4coder_default_framework.h @@ -133,5 +133,19 @@ struct Fade_Range_List{ #endif +//////////////////////////////// + +struct Implicit_Map_Result{ + String_ID map; + Custom_Command_Function *command; +}; + +typedef Implicit_Map_Result Implicit_Map_Function(Application_Links *app, + String_ID buffer_language, + String_ID global_mode, + Input_Event *event); + +global Implicit_Map_Function *implicit_map_function = 0; + // BOTTOM diff --git a/custom/4coder_default_hooks.cpp b/custom/4coder_default_hooks.cpp index eb87c507..dbdebc2e 100644 --- a/custom/4coder_default_hooks.cpp +++ b/custom/4coder_default_hooks.cpp @@ -48,6 +48,22 @@ CUSTOM_DOC("Default command for responding to a try-exit event") } } +function Implicit_Map_Result +default_implicit_map(Application_Links *app, String_ID lang, String_ID mode, Input_Event *event){ + Implicit_Map_Result result = {}; + + View_ID view = get_this_ctx_view(app, Access_Always); + + Command_Map_ID map_id = default_get_map_id(app, view); + Command_Binding binding = map_get_binding_recursive(&framework_mapping, map_id, event); + + // TODO(allen): map_id <-> map name? + result.map = 0; + result.command = binding.custom; + + return(result); +} + CUSTOM_COMMAND_SIG(default_view_input_handler) CUSTOM_DOC("Input consumption loop for default view behavior") { @@ -72,12 +88,12 @@ CUSTOM_DOC("Input consumption loop for default view behavior") continue; } - // NOTE(allen): Get map_id - Command_Map_ID map_id = default_get_map_id(app, view); - // NOTE(allen): Get binding - Command_Binding binding = map_get_binding_recursive(&framework_mapping, map_id, &input.event); - if (binding.custom == 0){ + if (implicit_map_function == 0){ + implicit_map_function = default_implicit_map; + } + Implicit_Map_Result map_result = implicit_map_function(app, 0, 0, &input.event); + if (map_result.command == 0){ leave_current_input_unhandled(app); continue; } @@ -85,7 +101,7 @@ CUSTOM_DOC("Input consumption loop for default view behavior") // NOTE(allen): Run the command and pre/post command stuff default_pre_command(app, scope); ProfileCloseNow(view_input_profile); - binding.custom(app); + map_result.command(app); ProfileScope(app, "after view input"); default_post_command(app, scope); } @@ -250,6 +266,7 @@ default_render_buffer(Application_Links *app, View_ID view_id, Face_ID face_id, &token_array, pairs, ArrayCount(pairs)); } +#if 0 // TODO(allen): Put in 4coder_draw.cpp // NOTE(allen): Color functions @@ -268,6 +285,7 @@ default_render_buffer(Application_Links *app, View_ID view_id, Face_ID face_id, paint_text_color(app, text_layout_id, Ii64_size(token->pos, token->size), argb); } } +#endif } else{ paint_text_color_fcolor(app, text_layout_id, visible_range, fcolor_id(defcolor_text_default)); diff --git a/custom/4coder_default_include.cpp b/custom/4coder_default_include.cpp index 00df60a3..bb8d0400 100644 --- a/custom/4coder_default_include.cpp +++ b/custom/4coder_default_include.cpp @@ -27,6 +27,7 @@ #include "generated/command_metadata.h" #endif +#include "4coder_variables.h" #include "4coder_profile.h" #include "4coder_async_tasks.h" #include "4coder_token.h" @@ -126,6 +127,7 @@ #include "4coder_doc_content_types.cpp" #include "4coder_doc_commands.cpp" #include "4coder_docs.cpp" +#include "4coder_variables.cpp" #include "4coder_examples.cpp" diff --git a/custom/4coder_variables.cpp b/custom/4coder_variables.cpp new file mode 100644 index 00000000..6547e559 --- /dev/null +++ b/custom/4coder_variables.cpp @@ -0,0 +1,237 @@ +/* +4coder_variables.cpp - Variables system +*/ + +// TOP + +//////////////////////////////// +// NOTE(allen): String hashing + +global Arena vars_arena = {}; +global Table_Data_u64 vars_string_to_id = {}; +global Table_u64_Data vars_id_to_string = {}; +global String_ID vars_string_id_counter = 0; + +function void +_vars_init(void){ + local_persist b32 did_init = false; + if (!did_init) + { + did_init = true; + Base_Allocator *base = get_base_allocator_system(); + vars_arena = make_arena(base); + vars_string_to_id = make_table_Data_u64(base, 100); + vars_id_to_string = make_table_u64_Data(base, 100); + } +} + +function String_ID +vars_save_string(String_Const_u8 string){ + _vars_init(); + + String_ID result = 0; + Data string_data = make_data(string.str, string.size); + Table_Lookup location = table_lookup(&vars_string_to_id, string_data); + if (location.found_match){ + table_read(&vars_string_to_id, location, &result); + } + else{ + vars_string_id_counter += 1; + result = vars_string_id_counter; + string_data = push_data_copy(&vars_arena, string_data); + table_insert(&vars_string_to_id, string_data, result); + table_insert(&vars_id_to_string, result, string_data); + } + return(result); +} + +function String_Const_u8 +vars_read_string(Arena *arena, String_ID id){ + _vars_init(); + + String_Const_u8 result = {}; + Table_Lookup location = table_lookup(&vars_id_to_string, id); + if (location.found_match){ + Data data = {}; + table_read(&vars_id_to_string, location, &data); + result.str = push_array(arena, u8 , data.size); + block_copy(result.str, data.data, data.size); + result.size = data.size; + } + return(result); +} + +//////////////////////////////// +// NOTE(allen): Variable structure + +global Variable vars_global_root = {}; +global Variable vars_nil = {}; +global Variable *vars_free_variables = 0; + +function Variable_Handle +vars_get_root(void){ + Variable_Handle handle = {&vars_global_root}; + return(handle); +} + +function Variable_Handle +vars_get_nil(void){ + Variable_Handle handle = {&vars_nil}; + return(handle); +} + +function b32 +vars_is_nil(Variable_Handle var){ + return(var.ptr == &vars_nil); +} + +function b32 +vars_match(Variable_Handle a, Variable_Handle b){ + return(a.ptr == b.ptr); +} + + +function String_ID +vars_string_id_from_var(Variable_Handle var){ + return(var.ptr->string); +} + +function String_Const_u8 +vars_string_from_var(Arena *arena, Variable_Handle var){ + String_ID id = vars_string_id_from_var(var); + String_Const_u8 result = vars_read_string(arena, id); + return(result); +} + +function Variable_Handle +vars_read_key(Variable_Handle var, String_ID key){ + Variable_Handle result = vars_get_nil(); + for (Variable *node = var.ptr->first; + node != 0; + node = node->next){ + if (node->key == key){ + result.ptr = node; + break; + } + } + return(result); +} + +function Variable_Handle +vars_read_key(Variable_Handle var, String_Const_u8 key){ + String_ID id = vars_save_string(key); + Variable_Handle result = vars_read_key(var, id); + return(result); +} + +function void +vars_set_string(Variable_Handle var, String_ID string){ + if (var.ptr != &vars_nil){ + var.ptr->string = string; + } +} + +function void +vars_set_string(Variable_Handle var, String_Const_u8 string){ + String_ID id = vars_save_string(string); + vars_set_string(var, id); +} + +function void +_vars_free_variable_children(Variable *var){ + for (Variable *node = var->first; + node != 0; + node = node->next){ + _vars_free_variable_children(node); + } + + if (var->last != 0){ + var->last->next = vars_free_variables; + } + if (var->first != 0){ + vars_free_variables = var->first; + } +} + +function void +vars_erase(Variable_Handle var, String_ID key){ + if (var.ptr != &vars_nil){ + Variable *prev = 0; + Variable *node = var.ptr->first; + for (; node != 0; + node = node->next){ + if (node->key == key){ + break; + } + prev = node; + } + + if (node != 0){ + _vars_free_variable_children(node); + if (prev != 0){ + prev->next = node->next; + } + if (var.ptr->first == node){ + var.ptr->first = node->next; + } + if (var.ptr->last == node){ + var.ptr->last = prev; + } + sll_stack_push(vars_free_variables, node); + } + } +} + +function Variable_Handle +vars_new_variable(Variable_Handle var, String_ID key){ + Variable_Handle handle = vars_get_nil(); + if (var.ptr != &vars_nil){ + Variable *prev = 0; + Variable *node = var.ptr->first; + for (; node != 0; + node = node->next){ + if (node->key == key){ + break; + } + prev = node; + } + + if (node != 0){ + handle.ptr = node; + _vars_free_variable_children(node); + } + else{ + handle.ptr = vars_free_variables; + if (handle.ptr == 0){ + sll_stack_pop(vars_free_variables); + } + else{ + handle.ptr = push_array(&vars_arena, Variable, 1); + } + sll_queue_push(var.ptr->first, var.ptr->last, handle.ptr); + handle.ptr->key = key; + } + + handle.ptr->string = 0; + handle.ptr->first = 0; + handle.ptr->last = 0; + } + return(handle); +} + +function Variable_Handle +vars_new_variable(Variable_Handle var, String_ID key, String_ID string){ + Variable_Handle result = vars_new_variable(var, key); + vars_set_string(var, string); + return(result); +} + +function void +vars_clear_keys(Variable_Handle var){ + if (var.ptr != &vars_nil){ + _vars_free_variable_children(var.ptr); + } +} + +// BOTTOM + diff --git a/custom/4coder_variables.h b/custom/4coder_variables.h new file mode 100644 index 00000000..2f2825dd --- /dev/null +++ b/custom/4coder_variables.h @@ -0,0 +1,51 @@ +/* +4coder_variables.h - Variables system +*/ + +// TOP + +#if !defined(FCODER_VARIABLES_H) +#define FCODER_VARIABLES_H + +//////////////////////////////// +// NOTE(allen): Types + +typedef u64 String_ID; + +struct Variable{ + Variable *next; + String_ID key; + String_ID string; + Variable *first; + Variable *last; +}; + +struct Variable_Handle{ + Variable *ptr; +}; + +//////////////////////////////// +// NOTE(allen): Functions + +function String_ID vars_save_string(String_Const_u8 string); +#define vars_save_string_lit(S) vars_save_string(string_u8_litexpr(S)) +function String_Const_u8 vars_read_string(Arena *arena, String_ID id); + +function Variable_Handle vars_get_root(void); +function Variable_Handle vars_get_nil(void); +function b32 vars_is_nil(Variable_Handle var); +function b32 vars_match(Variable_Handle a, Variable_Handle b); + +function Variable_Handle vars_read_key(Variable_Handle var, String_ID key); +function String_ID vars_string_id_from_var(Variable_Handle var); +function String_Const_u8 vars_string_from_var(Arena *arena, Variable_Handle var); + +function void vars_set_string(Variable_Handle var, String_ID string); +function void vars_erase(Variable_Handle var, String_ID key); +function Variable_Handle vars_new_variable(Variable_Handle var, String_ID key); +function Variable_Handle vars_new_variable(Variable_Handle var, String_ID key, String_ID string); +function void vars_clear_keys(Variable_Handle var); + +#endif //4CODER_VARIABLES_H + +// BOTTOM diff --git a/custom/generated/command_metadata.h b/custom/generated/command_metadata.h index a70a6b70..067070d0 100644 --- a/custom/generated/command_metadata.h +++ b/custom/generated/command_metadata.h @@ -308,7 +308,7 @@ static Command_Metadata fcoder_metacmd_table[248] = { { PROC_LINKS(default_file_externally_modified, 0), false, "default_file_externally_modified", 32, "Notes the external modification of attached files by printing a message.", 72, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 2055 }, { PROC_LINKS(default_startup, 0), false, "default_startup", 15, "Default command for responding to a startup event", 49, "W:\\4ed\\code\\custom\\4coder_default_hooks.cpp", 43, 7 }, { PROC_LINKS(default_try_exit, 0), false, "default_try_exit", 16, "Default command for responding to a try-exit event", 50, "W:\\4ed\\code\\custom\\4coder_default_hooks.cpp", 43, 23 }, -{ PROC_LINKS(default_view_input_handler, 0), false, "default_view_input_handler", 26, "Input consumption loop for default view behavior", 48, "W:\\4ed\\code\\custom\\4coder_default_hooks.cpp", 43, 51 }, +{ PROC_LINKS(default_view_input_handler, 0), false, "default_view_input_handler", 26, "Input consumption loop for default view behavior", 48, "W:\\4ed\\code\\custom\\4coder_default_hooks.cpp", 43, 67 }, { PROC_LINKS(delete_alpha_numeric_boundary, 0), false, "delete_alpha_numeric_boundary", 29, "Delete characters between the cursor position and the first alphanumeric boundary to the right.", 95, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 161 }, { PROC_LINKS(delete_char, 0), false, "delete_char", 11, "Deletes the character to the right of the cursor.", 49, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 79 }, { PROC_LINKS(delete_current_scope, 0), false, "delete_current_scope", 20, "Deletes the braces surrounding the currently selected scope. Leaves the contents within the scope.", 99, "W:\\4ed\\code\\custom\\4coder_scope_commands.cpp", 44, 112 }, diff --git a/ship_files/changes.txt b/ship_files/changes.txt index c4ed6fb1..ea04f84f 100644 --- a/ship_files/changes.txt +++ b/ship_files/changes.txt @@ -1,4 +1,11 @@ +4.1.7 + + Core string hash features "save_string" "read_string" + + Added lookup acceleration to code index data + + Added highlighting for functions, types, and macros in code index + + Default input is now dispatched through an "implicit map" callback + + Fix: crash when pasting in read only buffer + 4.1.6 + In config.4coder "bind_by_physical_key" uses a key-layout that does not change with language + Deprecated GlyphFlag_Rotate90, rotation of immediate mode text is entirely derived from the delta vector From fe8acba488fb35e7df6fd85a147ffa8a97af2a44 Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Thu, 22 Oct 2020 19:36:17 -0700 Subject: [PATCH 3/9] [dynamic bindings] fixing bugs; got it working --- custom/4coder_command_map.cpp | 11 +- custom/4coder_config.cpp | 2 +- custom/4coder_default_bindings.cpp | 8 +- custom/4coder_default_framework.cpp | 51 ++++++- custom/4coder_default_framework_variables.cpp | 2 + custom/4coder_default_hooks.cpp | 5 +- custom/4coder_default_include.cpp | 1 + custom/4coder_default_map.cpp | 12 -- custom/4coder_dynamic_bindings.cpp | 129 ++++++++++++++++ custom/4coder_helper.cpp | 13 ++ custom/4coder_mac_map.cpp | 13 -- custom/generated/command_metadata.h | 12 +- custom/generated/managed_id_metadata.cpp | 3 - ship_files/bindings.4coder | 140 ++++++++++++++++++ ship_files/mac-bindings.4coder | 139 +++++++++++++++++ 15 files changed, 490 insertions(+), 51 deletions(-) create mode 100644 custom/4coder_dynamic_bindings.cpp create mode 100644 ship_files/bindings.4coder create mode 100644 ship_files/mac-bindings.4coder diff --git a/custom/4coder_command_map.cpp b/custom/4coder_command_map.cpp index a4076096..7b9d3ad1 100644 --- a/custom/4coder_command_map.cpp +++ b/custom/4coder_command_map.cpp @@ -139,15 +139,6 @@ map__init(Mapping *mapping, Command_Map *map, Command_Map_ID id){ map->cmd_to_binding_trigger = make_table_u64_u64(&mapping->heap_wrapper, 100); } -function Command_Map* -mapping_begin_new_map(Mapping *mapping){ - Command_Map *map = mapping__alloc_map(mapping); - map__init(mapping, map, mapping->id_counter); - mapping->id_counter += 1; - table_insert(&mapping->id_to_map, map->id, (u64)PtrAsInt(map)); - return(map); -} - function Command_Map* mapping_get_map(Mapping *mapping, Command_Map_ID id){ Command_Map *result = 0; @@ -175,7 +166,7 @@ mapping_get_or_make_map(Mapping *mapping, Command_Map_ID id){ if (result == 0){ result = mapping__alloc_map(mapping); map__init(mapping, result, id); - table_insert(&mapping->id_to_map, result->id, (u64)PtrAsInt(result)); + table_insert(&mapping->id_to_map, id, (u64)PtrAsInt(result)); } return(result); } diff --git a/custom/4coder_config.cpp b/custom/4coder_config.cpp index 7d1a7eac..6ebd2ad2 100644 --- a/custom/4coder_config.cpp +++ b/custom/4coder_config.cpp @@ -1617,7 +1617,7 @@ load_config_and_apply(Application_Links *app, Arena *out_arena, Config_Data *con } // Apply config - setup_built_in_mapping(app, config->mapping, &framework_mapping, mapid_global, mapid_file, mapid_code); + //setup_built_in_mapping(app, config->mapping, &framework_mapping, mapid_global, mapid_file, mapid_code); change_mode(app, config->mode); global_set_setting(app, GlobalSetting_LAltLCtrlIsAltGr, config->lalt_lctrl_is_altgr); diff --git a/custom/4coder_default_bindings.cpp b/custom/4coder_default_bindings.cpp index 7bd3edd7..79a04cc4 100644 --- a/custom/4coder_default_bindings.cpp +++ b/custom/4coder_default_bindings.cpp @@ -25,11 +25,15 @@ custom_layer_init(Application_Links *app){ // NOTE(allen): default hooks and command maps set_all_default_hooks(app); mapping_init(tctx, &framework_mapping); + String_ID global_map_id = vars_save_string_lit("keys_global"); + String_ID file_map_id = vars_save_string_lit("keys_file"); + String_ID code_map_id = vars_save_string_lit("keys_code"); #if OS_MAC - setup_mac_mapping(&framework_mapping, mapid_global, mapid_file, mapid_code); + setup_mac_mapping(&framework_mapping, global_map_id, file_map_id, code_map_id); #else - setup_default_mapping(&framework_mapping, mapid_global, mapid_file, mapid_code); + setup_default_mapping(&framework_mapping, global_map_id, file_map_id, code_map_id); #endif + setup_essential_mapping(&framework_mapping, global_map_id, file_map_id, code_map_id); } #endif //FCODER_DEFAULT_BINDINGS diff --git a/custom/4coder_default_framework.cpp b/custom/4coder_default_framework.cpp index 91cba6be..922d7a91 100644 --- a/custom/4coder_default_framework.cpp +++ b/custom/4coder_default_framework.cpp @@ -569,6 +569,31 @@ CUSTOM_DOC("Clear the theme list") //////////////////////////////// +function void +setup_essential_mapping(Mapping *mapping, i64 global_id, i64 file_id, i64 code_id){ + MappingScope(); + SelectMapping(mapping); + + SelectMap(global_id); + BindCore(default_startup, CoreCode_Startup); + BindCore(default_try_exit, CoreCode_TryExit); + BindCore(clipboard_record_clip, CoreCode_NewClipboardContents); + BindMouseWheel(mouse_wheel_scroll); + BindMouseWheel(mouse_wheel_change_face_size, KeyCode_Control); + + SelectMap(file_id); + ParentMap(global_id); + BindTextInput(write_text_input); + BindMouse(click_set_cursor_and_mark, MouseCode_Left); + BindMouseRelease(click_set_cursor, MouseCode_Left); + BindCore(click_set_cursor_and_mark, CoreCode_ClickActivateView); + BindMouseMove(click_set_cursor_if_lbutton); + + SelectMap(code_id); + ParentMap(file_id); + BindTextInput(write_text_and_auto_indent); +} + function void default_4coder_initialize(Application_Links *app, String_Const_u8_Array file_names, i32 override_font_size, b32 override_hinting){ @@ -589,6 +614,26 @@ default_4coder_initialize(Application_Links *app, String_Const_u8_Array file_nam load_config_and_apply(app, &global_config_arena, &global_config, override_font_size, override_hinting); + String_Const_u8 bindings_file_name = string_u8_litexpr("bindings.4coder"); + if (string_match(global_config.mapping, string_u8_litexpr("mac-default"))){ + bindings_file_name = string_u8_litexpr("mac-bindings.4coder"); + } + else if (OS_MAC && string_match(global_config.mapping, string_u8_litexpr("choose"))){ + bindings_file_name = string_u8_litexpr("mac-bindings.4coder"); + } + + // TODO(allen): cleanup + String_ID global_map_id = vars_save_string_lit("keys_global"); + String_ID file_map_id = vars_save_string_lit("keys_file"); + String_ID code_map_id = vars_save_string_lit("keys_code"); + + if (dynamic_binding_load_from_file(app, &framework_mapping, bindings_file_name)){ + setup_essential_mapping(&framework_mapping, global_map_id, file_map_id, code_map_id); + } + else{ + setup_built_in_mapping(app, global_config.mapping, &framework_mapping, global_map_id, file_map_id, code_map_id); + } + // open command line files Scratch_Block scratch(app); String_Const_u8 hot_directory = push_hot_directory(app, scratch); @@ -987,7 +1032,7 @@ default_input_handler_init(Application_Links *app, Arena *arena){ View_Context ctx = view_current_context(app, view); ctx.mapping = &framework_mapping; - ctx.map_id = mapid_global; + ctx.map_id = vars_save_string_lit("keys_global"); view_alter_context(app, view, &ctx); } @@ -999,12 +1044,12 @@ default_get_map_id(Application_Links *app, View_ID view){ Command_Map_ID *result_ptr = scope_attachment(app, buffer_scope, buffer_map_id, Command_Map_ID); if (result_ptr != 0){ if (*result_ptr == 0){ - *result_ptr = mapid_file; + *result_ptr = vars_save_string_lit("keys_file"); } result = *result_ptr; } else{ - result = mapid_global; + result = vars_save_string_lit("keys_global"); } return(result); } diff --git a/custom/4coder_default_framework_variables.cpp b/custom/4coder_default_framework_variables.cpp index 2ebb9e0c..354cb40a 100644 --- a/custom/4coder_default_framework_variables.cpp +++ b/custom/4coder_default_framework_variables.cpp @@ -28,9 +28,11 @@ CUSTOM_ID(attachment, attachment_tokens); //////////////////////////////// +#if 0 CUSTOM_ID(command_map, mapid_global); CUSTOM_ID(command_map, mapid_file); CUSTOM_ID(command_map, mapid_code); +#endif //////////////////////////////// diff --git a/custom/4coder_default_hooks.cpp b/custom/4coder_default_hooks.cpp index dbdebc2e..cadfbd72 100644 --- a/custom/4coder_default_hooks.cpp +++ b/custom/4coder_default_hooks.cpp @@ -772,7 +772,10 @@ BUFFER_HOOK_SIG(default_begin_buffer){ } } - Command_Map_ID map_id = (treat_as_code)?(mapid_code):(mapid_file); + String_ID file_map_id = vars_save_string_lit("keys_file"); + String_ID code_map_id = vars_save_string_lit("keys_code"); + + Command_Map_ID map_id = (treat_as_code)?(code_map_id):(file_map_id); Managed_Scope scope = buffer_get_managed_scope(app, buffer_id); Command_Map_ID *map_id_ptr = scope_attachment(app, scope, buffer_map_id, Command_Map_ID); *map_id_ptr = map_id; diff --git a/custom/4coder_default_include.cpp b/custom/4coder_default_include.cpp index bb8d0400..dd92cc1a 100644 --- a/custom/4coder_default_include.cpp +++ b/custom/4coder_default_include.cpp @@ -100,6 +100,7 @@ #include "4coder_draw.cpp" #include "4coder_font_helper.cpp" #include "4coder_config.cpp" +#include "4coder_dynamic_bindings.cpp" #include "4coder_default_framework.cpp" #include "4coder_clipboard.cpp" #include "4coder_lister_base.cpp" diff --git a/custom/4coder_default_map.cpp b/custom/4coder_default_map.cpp index a121a0cb..266e01df 100644 --- a/custom/4coder_default_map.cpp +++ b/custom/4coder_default_map.cpp @@ -10,9 +10,6 @@ setup_default_mapping(Mapping *mapping, i64 global_id, i64 file_id, i64 code_id) SelectMapping(mapping); SelectMap(global_id); - BindCore(default_startup, CoreCode_Startup); - BindCore(default_try_exit, CoreCode_TryExit); - BindCore(clipboard_record_clip, CoreCode_NewClipboardContents); Bind(keyboard_macro_start_recording , KeyCode_U, KeyCode_Control); Bind(keyboard_macro_finish_recording, KeyCode_U, KeyCode_Control, KeyCode_Shift); Bind(keyboard_macro_replay, KeyCode_U, KeyCode_Alt); @@ -56,16 +53,8 @@ setup_default_mapping(Mapping *mapping, i64 global_id, i64 file_id, i64 code_id) Bind(project_fkey_command, KeyCode_F14); Bind(project_fkey_command, KeyCode_F15); Bind(project_fkey_command, KeyCode_F16); - BindMouseWheel(mouse_wheel_scroll); - BindMouseWheel(mouse_wheel_change_face_size, KeyCode_Control); SelectMap(file_id); - ParentMap(global_id); - BindTextInput(write_text_input); - BindMouse(click_set_cursor_and_mark, MouseCode_Left); - BindMouseRelease(click_set_cursor, MouseCode_Left); - BindCore(click_set_cursor_and_mark, CoreCode_ClickActivateView); - BindMouseMove(click_set_cursor_if_lbutton); Bind(delete_char, KeyCode_Delete); Bind(backspace_char, KeyCode_Backspace); Bind(move_up, KeyCode_Up); @@ -126,7 +115,6 @@ setup_default_mapping(Mapping *mapping, i64 global_id, i64 file_id, i64 code_id) SelectMap(code_id); ParentMap(file_id); - BindTextInput(write_text_and_auto_indent); Bind(move_left_alpha_numeric_boundary, KeyCode_Left, KeyCode_Control); Bind(move_right_alpha_numeric_boundary, KeyCode_Right, KeyCode_Control); Bind(move_left_alpha_numeric_or_camel_boundary, KeyCode_Left, KeyCode_Alt); diff --git a/custom/4coder_dynamic_bindings.cpp b/custom/4coder_dynamic_bindings.cpp new file mode 100644 index 00000000..5f351f6b --- /dev/null +++ b/custom/4coder_dynamic_bindings.cpp @@ -0,0 +1,129 @@ +/* +4coder_dynamic_bindings.cpp - Dynamic Bindings +*/ + +// TOP + +function Key_Code +dynamic_binding_key_code_from_string(String_Const_u8 key_string){ + Key_Code result = 0; + for (i32 i = 1; i < KeyCode_COUNT; i += 1){ + String_Const_u8 str = SCu8(key_code_name[i]); + if (string_match(str, key_string)){ + result = i; + break; + } + } + return result; +} + +function b32 +dynamic_binding_load_from_file(Application_Links *app, Mapping *mapping, String_Const_u8 filename){ + b32 result = false; + + Scratch_Block scratch(app); + + String_Const_u8 filename_copied = push_string_copy(scratch, filename); + FILE *file = open_file_try_current_path_then_binary_path(app, (char*)filename_copied.str); + if (file != 0){ + Data data = dump_file_handle(scratch, file); + Config *parsed = config_from_text(app, scratch, filename, SCu8(data)); + fclose(file); + + if (parsed != 0){ + result = true; + + Thread_Context* tctx = get_thread_context(app); + mapping_release(tctx, mapping); + mapping_init(tctx, mapping); + MappingScope(); + SelectMapping(mapping); + + for (Config_Assignment *assignment = parsed->first; + assignment != 0; + assignment = assignment->next){ + Config_LValue *l = assignment->l; + if (l != 0 && l->index == 0){ + Config_Get_Result rvalue = config_evaluate_rvalue(parsed, assignment, assignment->r); + if (rvalue.type == ConfigRValueType_Compound){ + String_Const_u8 map_name = l->identifier; + String_ID map_name_id = vars_save_string(map_name); + + SelectMap(map_name_id); + + + Config_Compound *compound = rvalue.compound; + + Config_Get_Result_List list = typed_compound_array_reference_list(scratch, parsed, compound); + for (Config_Get_Result_Node *node = list.first; node != 0; node = node->next){ + Config_Compound *src = node->result.compound; + String_Const_u8 cmd_string = {0}; + String_Const_u8 key_string = {0}; + String_Const_u8 mod_string[9] = {0}; + + if (!config_compound_string_member(parsed, src, "cmd", 0, &cmd_string)){ + config_add_error(scratch, parsed, node->result.pos, "Command string is required in binding"); + goto finish_map; + } + + if (!config_compound_string_member(parsed, src, "key", 1, &key_string)){ + config_add_error(scratch, parsed, node->result.pos, "Key string is required in binding"); + goto finish_map; + } + + for (i32 mod_idx = 0; mod_idx < ArrayCount(mod_string); mod_idx += 1){ + String_Const_u8 str = push_stringf(scratch, "mod_%i", mod_idx); + if (config_compound_string_member(parsed, src, str, 2 + mod_idx, &mod_string[mod_idx])){ + // NOTE(rjf): No-Op + } + } + + // NOTE(rjf): Map read in successfully. + { + // NOTE(rjf): Find command. + Command_Metadata *command = get_command_metadata_from_name(cmd_string); + + // NOTE(rjf): Find keycode. + Key_Code keycode = dynamic_binding_key_code_from_string(key_string); + + // NOTE(rjf): Find mods. + i32 mod_count = 0; + Key_Code mods[ArrayCount(mod_string)] = {0}; + for (i32 i = 0; i < ArrayCount(mod_string); i += 1){ + if (mod_string[i].str){ + mods[mod_count] = dynamic_binding_key_code_from_string(mod_string[i]); + mod_count += 1; + } + } + + if (keycode != 0 && command != 0){ + Input_Modifier_Set mods_set = { mods, mod_count, }; + map_set_binding(mapping, map, command->proc, InputEventKind_KeyStroke, keycode, &mods_set); + } + else{ + config_add_error(scratch, parsed, node->result.pos, + (keycode != 0) ? "Invalid command" : + (command != 0) ? "Invalid key": + "Invalid command and key"); + } + } + + finish_map:; + } + + + if (parsed->errors.first != 0){ + String_Const_u8 error_text = config_stringize_errors(app, scratch, parsed); + print_message(app, error_text); + } + } + } + } + } + } + + return(result); +} + +// BOTTOM + diff --git a/custom/4coder_helper.cpp b/custom/4coder_helper.cpp index 9a8df595..19b42753 100644 --- a/custom/4coder_helper.cpp +++ b/custom/4coder_helper.cpp @@ -31,6 +31,19 @@ get_command_metadata(Custom_Command_Function *func){ return(result); } +function Command_Metadata* +get_command_metadata_from_name(String_Const_u8 name){ + Command_Metadata *result = 0; + Command_Metadata *candidate = fcoder_metacmd_table; + for (i32 i = 0; i < ArrayCount(fcoder_metacmd_table); i += 1, candidate += 1){ + if (string_match(SCu8(candidate->name, candidate->name_len), name)){ + result = candidate; + break; + } + } + return(result); +} + //////////////////////////////// function Token_Array diff --git a/custom/4coder_mac_map.cpp b/custom/4coder_mac_map.cpp index 909a55ee..c2e837a5 100644 --- a/custom/4coder_mac_map.cpp +++ b/custom/4coder_mac_map.cpp @@ -10,9 +10,6 @@ setup_mac_mapping(Mapping *mapping, i64 global_id, i64 file_id, i64 code_id){ SelectMapping(mapping); SelectMap(global_id); - BindCore(default_startup, CoreCode_Startup); - BindCore(default_try_exit, CoreCode_TryExit); - BindCore(clipboard_record_clip, CoreCode_NewClipboardContents); Bind(keyboard_macro_start_recording , KeyCode_U, KeyCode_Command); Bind(keyboard_macro_finish_recording, KeyCode_U, KeyCode_Command, KeyCode_Shift); Bind(keyboard_macro_replay, KeyCode_U, KeyCode_Control); @@ -56,16 +53,8 @@ setup_mac_mapping(Mapping *mapping, i64 global_id, i64 file_id, i64 code_id){ Bind(project_fkey_command, KeyCode_F15); Bind(project_fkey_command, KeyCode_F16); Bind(exit_4coder, KeyCode_F4, KeyCode_Alt); - BindMouseWheel(mouse_wheel_scroll); - BindMouseWheel(mouse_wheel_change_face_size, KeyCode_Command); SelectMap(file_id); - ParentMap(global_id); - BindTextInput(write_text_input); - BindMouse(click_set_cursor_and_mark, MouseCode_Left); - BindMouseRelease(click_set_cursor, MouseCode_Left); - BindCore(click_set_cursor_and_mark, CoreCode_ClickActivateView); - BindMouseMove(click_set_cursor_if_lbutton); Bind(delete_char, KeyCode_Delete); Bind(backspace_char, KeyCode_Backspace); Bind(move_up, KeyCode_Up); @@ -126,8 +115,6 @@ setup_mac_mapping(Mapping *mapping, i64 global_id, i64 file_id, i64 code_id){ Bind(view_jump_list_with_lister, KeyCode_Period, KeyCode_Command, KeyCode_Shift); SelectMap(code_id); - ParentMap(file_id); - BindTextInput(write_text_and_auto_indent); Bind(move_left_alpha_numeric_boundary, KeyCode_Left, KeyCode_Command); Bind(move_right_alpha_numeric_boundary, KeyCode_Right, KeyCode_Command); Bind(move_left_alpha_numeric_or_camel_boundary, KeyCode_Left, KeyCode_Control); diff --git a/custom/generated/command_metadata.h b/custom/generated/command_metadata.h index 067070d0..56d90925 100644 --- a/custom/generated/command_metadata.h +++ b/custom/generated/command_metadata.h @@ -322,8 +322,8 @@ static Command_Metadata fcoder_metacmd_table[248] = { { PROC_LINKS(execute_any_cli, 0), false, "execute_any_cli", 15, "Queries for an output buffer name and system command, runs the system command as a CLI and prints the output to the specified buffer.", 133, "W:\\4ed\\code\\custom\\4coder_cli_command.cpp", 41, 22 }, { PROC_LINKS(execute_previous_cli, 0), false, "execute_previous_cli", 20, "If the command execute_any_cli has already been used, this will execute a CLI reusing the most recent buffer name and command.", 126, "W:\\4ed\\code\\custom\\4coder_cli_command.cpp", 41, 7 }, { PROC_LINKS(exit_4coder, 0), false, "exit_4coder", 11, "Attempts to close 4coder.", 25, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 844 }, -{ PROC_LINKS(goto_beginning_of_file, 0), false, "goto_beginning_of_file", 22, "Sets the cursor to the beginning of the file.", 45, "W:\\4ed\\code\\custom\\4coder_helper.cpp", 36, 2248 }, -{ PROC_LINKS(goto_end_of_file, 0), false, "goto_end_of_file", 16, "Sets the cursor to the end of the file.", 39, "W:\\4ed\\code\\custom\\4coder_helper.cpp", 36, 2256 }, +{ PROC_LINKS(goto_beginning_of_file, 0), false, "goto_beginning_of_file", 22, "Sets the cursor to the beginning of the file.", 45, "W:\\4ed\\code\\custom\\4coder_helper.cpp", 36, 2261 }, +{ PROC_LINKS(goto_end_of_file, 0), false, "goto_end_of_file", 16, "Sets the cursor to the end of the file.", 39, "W:\\4ed\\code\\custom\\4coder_helper.cpp", 36, 2269 }, { PROC_LINKS(goto_first_jump, 0), false, "goto_first_jump", 15, "If a buffer containing jump locations has been locked in, goes to the first jump in the buffer.", 95, "W:\\4ed\\code\\custom\\4coder_jump_sticky.cpp", 41, 525 }, { PROC_LINKS(goto_first_jump_same_panel_sticky, 0), false, "goto_first_jump_same_panel_sticky", 33, "If a buffer containing jump locations has been locked in, goes to the first jump in the buffer and views the buffer in the panel where the jump list was.", 153, "W:\\4ed\\code\\custom\\4coder_jump_sticky.cpp", 41, 542 }, { PROC_LINKS(goto_jump_at_cursor, 0), false, "goto_jump_at_cursor", 19, "If the cursor is found to be on a jump location, parses the jump location and brings up the file and position in another view and changes the active panel to the view containing the jump.", 187, "W:\\4ed\\code\\custom\\4coder_jump_sticky.cpp", 41, 348 }, @@ -452,10 +452,10 @@ static Command_Metadata fcoder_metacmd_table[248] = { { PROC_LINKS(save_to_query, 0), false, "save_to_query", 13, "Queries the user for a file name and saves the contents of the current buffer, altering the buffer's name too.", 110, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1425 }, { PROC_LINKS(search, 0), false, "search", 6, "Begins an incremental search down through the current buffer for a user specified string.", 89, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1107 }, { PROC_LINKS(search_identifier, 0), false, "search_identifier", 17, "Begins an incremental search down through the current buffer for the word or token under the cursor.", 100, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1119 }, -{ PROC_LINKS(seek_beginning_of_line, 0), false, "seek_beginning_of_line", 22, "Seeks the cursor to the beginning of the visual line.", 53, "W:\\4ed\\code\\custom\\4coder_helper.cpp", 36, 2236 }, -{ PROC_LINKS(seek_beginning_of_textual_line, 0), false, "seek_beginning_of_textual_line", 30, "Seeks the cursor to the beginning of the line across all text.", 62, "W:\\4ed\\code\\custom\\4coder_helper.cpp", 36, 2224 }, -{ PROC_LINKS(seek_end_of_line, 0), false, "seek_end_of_line", 16, "Seeks the cursor to the end of the visual line.", 47, "W:\\4ed\\code\\custom\\4coder_helper.cpp", 36, 2242 }, -{ PROC_LINKS(seek_end_of_textual_line, 0), false, "seek_end_of_textual_line", 24, "Seeks the cursor to the end of the line across all text.", 56, "W:\\4ed\\code\\custom\\4coder_helper.cpp", 36, 2230 }, +{ PROC_LINKS(seek_beginning_of_line, 0), false, "seek_beginning_of_line", 22, "Seeks the cursor to the beginning of the visual line.", 53, "W:\\4ed\\code\\custom\\4coder_helper.cpp", 36, 2249 }, +{ PROC_LINKS(seek_beginning_of_textual_line, 0), false, "seek_beginning_of_textual_line", 30, "Seeks the cursor to the beginning of the line across all text.", 62, "W:\\4ed\\code\\custom\\4coder_helper.cpp", 36, 2237 }, +{ PROC_LINKS(seek_end_of_line, 0), false, "seek_end_of_line", 16, "Seeks the cursor to the end of the visual line.", 47, "W:\\4ed\\code\\custom\\4coder_helper.cpp", 36, 2255 }, +{ PROC_LINKS(seek_end_of_textual_line, 0), false, "seek_end_of_textual_line", 24, "Seeks the cursor to the end of the line across all text.", 56, "W:\\4ed\\code\\custom\\4coder_helper.cpp", 36, 2243 }, { PROC_LINKS(select_all, 0), false, "select_all", 10, "Puts the cursor at the top of the file, and the mark at the bottom of the file.", 79, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 541 }, { PROC_LINKS(select_next_scope_absolute, 0), false, "select_next_scope_absolute", 26, "Finds the first scope started by '{' after the cursor and puts the cursor and mark on the '{' and '}'.", 102, "W:\\4ed\\code\\custom\\4coder_scope_commands.cpp", 44, 57 }, { PROC_LINKS(select_next_scope_after_current, 0), false, "select_next_scope_after_current", 31, "If a scope is selected, find first scope that starts after the selected scope. Otherwise find the first scope that starts after the cursor.", 139, "W:\\4ed\\code\\custom\\4coder_scope_commands.cpp", 44, 66 }, diff --git a/custom/generated/managed_id_metadata.cpp b/custom/generated/managed_id_metadata.cpp index 5f95ac6c..a8a9047a 100644 --- a/custom/generated/managed_id_metadata.cpp +++ b/custom/generated/managed_id_metadata.cpp @@ -56,7 +56,4 @@ buffer_lex_task = managed_id_declare(app, string_u8_litexpr("attachment"), strin buffer_wrap_lines = managed_id_declare(app, string_u8_litexpr("attachment"), string_u8_litexpr("buffer_wrap_lines")); sticky_jump_marker_handle = managed_id_declare(app, string_u8_litexpr("attachment"), string_u8_litexpr("sticky_jump_marker_handle")); attachment_tokens = managed_id_declare(app, string_u8_litexpr("attachment"), string_u8_litexpr("attachment_tokens")); -mapid_global = managed_id_declare(app, string_u8_litexpr("command_map"), string_u8_litexpr("mapid_global")); -mapid_file = managed_id_declare(app, string_u8_litexpr("command_map"), string_u8_litexpr("mapid_file")); -mapid_code = managed_id_declare(app, string_u8_litexpr("command_map"), string_u8_litexpr("mapid_code")); } diff --git a/ship_files/bindings.4coder b/ship_files/bindings.4coder new file mode 100644 index 00000000..d07a2c84 --- /dev/null +++ b/ship_files/bindings.4coder @@ -0,0 +1,140 @@ + +keys_global = { + { "keyboard_macro_start_recording", "U", "Control" }, + { "keyboard_macro_finish_recording", "U", "Control", "Shift" }, + { "keyboard_macro_replay", "U", "Alt" }, + { "change_active_panel", "Comma", "Control" }, + { "change_active_panel_backwards", "Comma", "Control", "Shift" }, + { "interactive_new", "N", "Control" }, + { "interactive_open_or_new", "O", "Control" }, + { "open_in_other", "O", "Alt" }, + { "interactive_kill_buffer", "K", "Control" }, + { "interactive_switch_buffer", "I", "Control" }, + { "project_go_to_root_directory", "H", "Control" }, + { "save_all_dirty_buffers", "S", "Control", "Shift" }, + { "change_to_build_panel", "Period", "Alt" }, + { "close_build_panel", "Comma", "Alt" }, + { "goto_next_jump", "N", "Alt" }, + { "goto_prev_jump", "N", "Alt", "Shift" }, + { "build_in_build_panel", "M", "Alt" }, + { "goto_first_jump", "M", "Alt", "Shift" }, + { "toggle_filebar", "B", "Alt" }, + { "execute_any_cli", "Z", "Alt" }, + { "execute_previous_cli", "Z", "Alt", "Shift" }, + { "command_lister", "X", "Alt" }, + { "project_command_lister", "X", "Alt", "Shift" }, + { "quick_swap_buffer", "BackwardSlash", "Alt" }, + { "jump_to_last_point", "P", "Control" }, + { "list_all_functions_current_buffer_lister", "I", "Control", "Shift" }, + { "exit_4coder", "F4", "Alt" }, + { "project_fkey_command", "F1" }, + { "project_fkey_command", "F2" }, + { "project_fkey_command", "F3" }, + { "project_fkey_command", "F4" }, + { "project_fkey_command", "F5" }, + { "project_fkey_command", "F6" }, + { "project_fkey_command", "F7" }, + { "project_fkey_command", "F8" }, + { "project_fkey_command", "F9" }, + { "project_fkey_command", "F10" }, + { "project_fkey_command", "F11" }, + { "project_fkey_command", "F12" }, + { "project_fkey_command", "F13" }, + { "project_fkey_command", "F14" }, + { "project_fkey_command", "F15" }, + { "project_fkey_command", "F16" }, +}; + +keys_file = { + { "delete_char", "Delete" }, + { "backspace_char", "Backspace" }, + { "move_up", "Up" }, + { "move_down", "Down" }, + { "move_left", "Left" }, + { "move_right", "Right" }, + { "seek_end_of_line", "End" }, + { "seek_beginning_of_line", "Home" }, + { "page_up", "PageUp" }, + { "page_down", "PageDown" }, + { "goto_beginning_of_file", "PageUp", "Control" }, + { "goto_end_of_file", "PageDown", "Control" }, + { "move_up_to_blank_line_end", "Up", "Control" }, + { "move_down_to_blank_line_end", "Down", "Control" }, + { "move_left_whitespace_boundary", "Left", "Control" }, + { "move_right_whitespace_boundary", "Right", "Control" }, + { "move_line_up", "Up", "Alt" }, + { "move_line_down", "Down", "Alt" }, + { "backspace_alpha_numeric_boundary", "Backspace", "Control" }, + { "delete_alpha_numeric_boundary", "Delete", "Control" }, + { "snipe_backward_whitespace_or_token_boundary", "Backspace", "Alt" }, + { "snipe_forward_whitespace_or_token_boundary", "Delete", "Alt" }, + { "set_mark", "Space", "Control" }, + { "replace_in_range", "A", "Control" }, + { "copy", "C", "Control" }, + { "delete_range", "D", "Control" }, + { "delete_line", "D", "Control", "Shift" }, + { "center_view", "E", "Control" }, + { "left_adjust_view", "E", "Control", "Shift" }, + { "search", "F", "Control" }, + { "list_all_locations", "F", "Control", "Shift" }, + { "list_all_substring_locations_case_insensitive", "F", "Alt" }, + { "goto_line", "G", "Control" }, + { "list_all_locations_of_selection", "G", "Control", "Shift" }, + { "snippet_lister", "J", "Control" }, + { "kill_buffer", "K", "Control", "Shift" }, + { "duplicate_line", "L", "Control" }, + { "cursor_mark_swap", "M", "Control" }, + { "reopen", "O", "Control", "Shift" }, + { "query_replace", "Q", "Control" }, + { "query_replace_identifier", "Q", "Control", "Shift" }, + { "query_replace_selection", "Q", "Alt" }, + { "reverse_search", "R", "Control" }, + { "save", "S", "Control" }, + { "save_all_dirty_buffers", "S", "Control", "Shift" }, + { "search_identifier", "T", "Control" }, + { "list_all_locations_of_identifier", "T", "Control", "Shift" }, + { "paste_and_indent", "V", "Control" }, + { "paste_next_and_indent", "V", "Control", "Shift" }, + { "cut", "X", "Control" }, + { "redo", "Y", "Control" }, + { "undo", "Z", "Control" }, + { "view_buffer_other_panel", "1", "Control" }, + { "swap_panels", "2", "Control" }, + { "if_read_only_goto_position", "Return" }, + { "if_read_only_goto_position_same_panel", "Return", "Shift" }, + { "view_jump_list_with_lister", "Period", "Control", "Shift" }, +}; + +keys_code = { + { "move_left_alpha_numeric_boundary", "Left", "Control" }, + { "move_right_alpha_numeric_boundary", "Right", "Control" }, + { "move_left_alpha_numeric_or_camel_boundary", "Left", "Alt" }, + { "move_right_alpha_numeric_or_camel_boundary", "Right", "Alt" }, + { "comment_line_toggle", "Semicolon", "Control" }, + { "word_complete", "Tab" }, + { "auto_indent_range", "Tab", "Control" }, + { "auto_indent_line_at_cursor", "Tab", "Shift" }, + { "word_complete_drop_down", "Tab", "Shift", "Control" }, + { "write_block", "R", "Alt" }, + { "write_todo", "T", "Alt" }, + { "write_note", "Y", "Alt" }, + { "list_all_locations_of_type_definition", "D", "Alt" }, + { "list_all_locations_of_type_definition_of_identifier", "T", "Alt", "Shift" }, + { "open_long_braces", "LeftBracket", "Control" }, + { "open_long_braces_semicolon", "LeftBracket", "Control", "Shift" }, + { "open_long_braces_break", "RightBracket", "Control", "Shift" }, + { "select_surrounding_scope", "LeftBracket", "Alt" }, + { "select_surrounding_scope_maximal", "LeftBracket", "Alt", "Shift" }, + { "select_prev_scope_absolute", "RightBracket", "Alt" }, + { "select_prev_top_most_scope", "RightBracket", "Alt", "Shift" }, + { "select_next_scope_absolute", "Quote", "Alt" }, + { "select_next_scope_after_current", "Quote", "Alt", "Shift" }, + { "place_in_scope", "ForwardSlash", "Alt" }, + { "delete_current_scope", "Minus", "Alt" }, + { "if0_off", "I", "Alt" }, + { "open_file_in_quotes", "1", "Alt" }, + { "open_matching_file_cpp", "2", "Alt" }, + { "write_zero_struct", "0", "Control" }, + { "jump_to_definition_at_cursor", "W", "Control" }, +}; + diff --git a/ship_files/mac-bindings.4coder b/ship_files/mac-bindings.4coder new file mode 100644 index 00000000..87203509 --- /dev/null +++ b/ship_files/mac-bindings.4coder @@ -0,0 +1,139 @@ + +keys_global = { + { "keyboard_macro_start_recording", "U", "Command" }, + { "keyboard_macro_finish_recording", "U", "Command", "Shift" }, + { "keyboard_macro_replay", "U", "Control" }, + { "change_active_panel", "Comma", "Command" }, + { "change_active_panel_backwards", "Comma", "Command", "Shift" }, + { "interactive_new", "N", "Command" }, + { "interactive_open_or_new", "O", "Command" }, + { "open_in_other", "O", "Control" }, + { "interactive_kill_buffer", "K", "Command" }, + { "interactive_switch_buffer", "I", "Command" }, + { "project_go_to_root_directory", "H", "Command" }, + { "save_all_dirty_buffers", "S", "Command", "Shift" }, + { "change_to_build_panel", "Period", "Control" }, + { "close_build_panel", "Comma", "Control" }, + { "goto_next_jump", "N", "Control" }, + { "goto_prev_jump", "N", "Control", "Shift" }, + { "build_in_build_panel", "M", "Control" }, + { "goto_first_jump", "M", "Control", "Shift" }, + { "toggle_filebar", "B", "Control" }, + { "execute_any_cli", "Z", "Control" }, + { "execute_previous_cli", "Z", "Control", "Shift" }, + { "command_lister", "X", "Control" }, + { "project_command_lister", "X", "Control", "Shift" }, + { "quick_swap_buffer", "BackwardSlash", "Control" }, + { "jump_to_last_point", "P", "Command" }, + { "list_all_functions_current_buffer_lister", "I", "Command", "Shift" }, + { "exit_4coder", "F4", "Alt" }, + { "project_fkey_command", "F1" }, + { "project_fkey_command", "F2" }, + { "project_fkey_command", "F3" }, + { "project_fkey_command", "F4" }, + { "project_fkey_command", "F5" }, + { "project_fkey_command", "F6" }, + { "project_fkey_command", "F7" }, + { "project_fkey_command", "F8" }, + { "project_fkey_command", "F9" }, + { "project_fkey_command", "F10" }, + { "project_fkey_command", "F11" }, + { "project_fkey_command", "F12" }, + { "project_fkey_command", "F13" }, + { "project_fkey_command", "F14" }, + { "project_fkey_command", "F15" }, + { "project_fkey_command", "F16" }, +}; + +keys_file = { + { "delete_char", "Delete" }, + { "backspace_char", "Backspace" }, + { "move_up", "Up" }, + { "move_down", "Down" }, + { "move_left", "Left" }, + { "move_right", "Right" }, + { "seek_end_of_line", "End" }, + { "seek_beginning_of_line", "Home" }, + { "page_up", "PageUp" }, + { "page_down", "PageDown" }, + { "goto_beginning_of_file", "PageUp", "Command" }, + { "goto_end_of_file", "PageDown", "Command" }, + { "move_up_to_blank_line_end", "Up", "Command" }, + { "move_down_to_blank_line_end", "Down", "Command" }, + { "move_left_whitespace_boundary", "Left", "Command" }, + { "move_right_whitespace_boundary", "Right", "Command" }, + { "move_line_up", "Up", "Alt" }, + { "move_line_down", "Down", "Alt" }, + { "backspace_alpha_numeric_boundary", "Backspace", "Command" }, + { "delete_alpha_numeric_boundary", "Delete", "Command" }, + { "snipe_backward_whitespace_or_token_boundary", "Backspace", "Control" }, + { "snipe_forward_whitespace_or_token_boundary", "Delete", "Control" }, + { "set_mark", "Space", "Command" }, + { "replace_in_range", "A", "Command" }, + { "copy", "C", "Command" }, + { "delete_range", "D", "Command" }, + { "delete_line", "D", "Command", "Shift" }, + { "center_view", "E", "Command" }, + { "left_adjust_view", "E", "Command", "Shift" }, + { "search", "F", "Command" }, + { "list_all_locations", "F", "Command", "Shift" }, + { "list_all_substring_locations_case_insensitive", "F", "Control" }, + { "goto_line", "G", "Command" }, + { "list_all_locations_of_selection", "G", "Command", "Shift" }, + { "snippet_lister", "J", "Command" }, + { "kill_buffer", "K", "Command", "Shift" }, + { "duplicate_line", "L", "Command" }, + { "cursor_mark_swap", "M", "Command" }, + { "reopen", "O", "Command", "Shift" }, + { "query_replace", "Q", "Command" }, + { "query_replace_identifier", "Q", "Command", "Shift" }, + { "query_replace_selection", "Q", "Control" }, + { "reverse_search", "R", "Command" }, + { "save", "S", "Command" }, + { "save_all_dirty_buffers", "S", "Command", "Shift" }, + { "search_identifier", "T", "Command" }, + { "list_all_locations_of_identifier", "T", "Command", "Shift" }, + { "paste_and_indent", "V", "Command" }, + { "paste_next_and_indent", "V", "Command", "Shift" }, + { "cut", "X", "Command" }, + { "redo", "Y", "Command" }, + { "undo", "Z", "Command" }, + { "view_buffer_other_panel", "1", "Command" }, + { "swap_panels", "2", "Command" }, + { "if_read_only_goto_position", "Return" }, + { "if_read_only_goto_position_same_panel", "Return", "Shift" }, + { "view_jump_list_with_lister", "Period", "Command", "Shift" }, +}; + +keys_code = { + { "move_left_alpha_numeric_boundary", "Left", "Command" }, + { "move_right_alpha_numeric_boundary", "Right", "Command" }, + { "move_left_alpha_numeric_or_camel_boundary", "Left", "Control" }, + { "move_right_alpha_numeric_or_camel_boundary", "Right", "Control" }, + { "comment_line_toggle", "Semicolon", "Command" }, + { "word_complete", "Tab" }, + { "auto_indent_range", "Tab", "Command" }, + { "auto_indent_line_at_cursor", "Tab", "Shift" }, + { "word_complete_drop_down", "Tab", "Shift", "Command" }, + { "write_block", "R", "Control" }, + { "write_todo", "T", "Control" }, + { "write_note", "Y", "Control" }, + { "list_all_locations_of_type_definition", "D", "Control" }, + { "list_all_locations_of_type_definition_of_identifier", "T", "Control", "Shift" }, + { "open_long_braces", "LeftBracket", "Command" }, + { "open_long_braces_semicolon", "LeftBracket", "Command", "Shift" }, + { "open_long_braces_break", "RightBracket", "Command", "Shift" }, + { "select_surrounding_scope", "LeftBracket", "Control" }, + { "select_surrounding_scope_maximal", "LeftBracket", "Control", "Shift" }, + { "select_prev_scope_absolute", "RightBracket", "Control" }, + { "select_prev_top_most_scope", "RightBracket", "Control", "Shift" }, + { "select_next_scope_absolute", "Quote", "Control" }, + { "select_next_scope_after_current", "Quote", "Control", "Shift" }, + { "place_in_scope", "ForwardSlash", "Control" }, + { "delete_current_scope", "Minus", "Control" }, + { "if0_off", "I", "Control" }, + { "open_file_in_quotes", "1", "Control" }, + { "open_matching_file_cpp", "2", "Control" }, + { "write_zero_struct", "0", "Command" }, + { "jump_to_definition_at_cursor", "W", "Command" }, +}; From 45ab2afe612e23a30b937af7b30d981bb6140ca3 Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Sat, 24 Oct 2020 16:39:28 -0700 Subject: [PATCH 4/9] [default-features] open_matching_cpp creates missing file if no match is found --- custom/4coder_base_commands.cpp | 95 ++++++++++++++++------------- custom/generated/command_metadata.h | 28 ++++----- 2 files changed, 65 insertions(+), 58 deletions(-) diff --git a/custom/4coder_base_commands.cpp b/custom/4coder_base_commands.cpp index a25aa3fd..67bf9f12 100644 --- a/custom/4coder_base_commands.cpp +++ b/custom/4coder_base_commands.cpp @@ -1571,50 +1571,6 @@ CUSTOM_DOC("Delete the line the on which the cursor sits.") //////////////////////////////// -function b32 -get_cpp_matching_file(Application_Links *app, Buffer_ID buffer, Buffer_ID *buffer_out){ - b32 result = false; - Scratch_Block scratch(app); - String_Const_u8 file_name = push_buffer_file_name(app, scratch, buffer); - if (file_name.size > 0){ - String_Const_u8 extension = string_file_extension(file_name); - String_Const_u8 new_extensions[2] = {}; - i32 new_extensions_count = 0; - if (string_match(extension, string_u8_litexpr("cpp")) || string_match(extension, string_u8_litexpr("cc"))){ - new_extensions[0] = string_u8_litexpr("h"); - new_extensions[1] = string_u8_litexpr("hpp"); - new_extensions_count = 2; - } - else if (string_match(extension, string_u8_litexpr("c"))){ - new_extensions[0] = string_u8_litexpr("h"); - new_extensions_count = 1; - } - else if (string_match(extension, string_u8_litexpr("h"))){ - new_extensions[0] = string_u8_litexpr("c"); - new_extensions[1] = string_u8_litexpr("cpp"); - new_extensions_count = 2; - } - else if (string_match(extension, string_u8_litexpr("hpp"))){ - new_extensions[0] = string_u8_litexpr("cpp"); - new_extensions_count = 1; - } - - String_Const_u8 file_without_extension = string_file_without_extension(file_name); - for (i32 i = 0; i < new_extensions_count; i += 1){ - Temp_Memory temp = begin_temp(scratch); - String_Const_u8 new_extension = new_extensions[i]; - String_Const_u8 new_file_name = push_u8_stringf(scratch, "%.*s.%.*s", string_expand(file_without_extension), string_expand(new_extension)); - if (open_file(app, buffer_out, new_file_name, false, true)){ - result = true; - break; - } - end_temp(temp); - } - } - - return(result); -} - CUSTOM_COMMAND_SIG(open_file_in_quotes) CUSTOM_DOC("Reads a filename from surrounding '\"' characters and attempts to open the corresponding file.") { @@ -1647,6 +1603,57 @@ CUSTOM_DOC("Reads a filename from surrounding '\"' characters and attempts to op } } +function b32 +get_cpp_matching_file(Application_Links *app, Buffer_ID buffer, Buffer_ID *buffer_out){ + b32 result = false; + Scratch_Block scratch(app); + String_Const_u8 file_name = push_buffer_file_name(app, scratch, buffer); + if (file_name.size > 0){ + String_Const_u8 extension = string_file_extension(file_name); + String_Const_u8 new_extensions[2] = {}; + i32 new_extensions_count = 0; + if (string_match(extension, string_u8_litexpr("cpp")) || string_match(extension, string_u8_litexpr("cc"))){ + new_extensions[0] = string_u8_litexpr("h"); + new_extensions[1] = string_u8_litexpr("hpp"); + new_extensions_count = 2; + } + else if (string_match(extension, string_u8_litexpr("c"))){ + new_extensions[0] = string_u8_litexpr("h"); + new_extensions_count = 1; + } + else if (string_match(extension, string_u8_litexpr("h"))){ + new_extensions[0] = string_u8_litexpr("cpp"); + new_extensions[1] = string_u8_litexpr("c"); + new_extensions_count = 2; + } + else if (string_match(extension, string_u8_litexpr("hpp"))){ + new_extensions[0] = string_u8_litexpr("cpp"); + new_extensions_count = 1; + } + + String_Const_u8 file_without_extension = string_file_without_extension(file_name); + for (i32 i = 0; i < new_extensions_count; i += 1){ + Temp_Memory temp = begin_temp(scratch); + String_Const_u8 new_extension = new_extensions[i]; + String_Const_u8 new_file_name = push_u8_stringf(scratch, "%.*s.%.*s", string_expand(file_without_extension), string_expand(new_extension)); + if (open_file(app, buffer_out, new_file_name, false, true)){ + result = true; + break; + } + end_temp(temp); + } + + if (!result && new_extensions_count > 0){ + String_Const_u8 new_file_name = push_u8_stringf(scratch, "%.*s.%.*s", string_expand(file_without_extension), string_expand(new_extensions[0])); + if (open_file(app, buffer_out, new_file_name, false, false)){ + result = true; + } + } + } + + return(result); +} + CUSTOM_COMMAND_SIG(open_matching_file_cpp) CUSTOM_DOC("If the current file is a *.cpp or *.h, attempts to open the corresponding *.h or *.cpp file in the other view.") { diff --git a/custom/generated/command_metadata.h b/custom/generated/command_metadata.h index 56d90925..ce8b98d6 100644 --- a/custom/generated/command_metadata.h +++ b/custom/generated/command_metadata.h @@ -305,7 +305,7 @@ static Command_Metadata fcoder_metacmd_table[248] = { { PROC_LINKS(custom_api_documentation, 0), true, "custom_api_documentation", 24, "Prompts the user to select a Custom API item then loads a doc buffer for that item", 82, "W:\\4ed\\code\\custom\\4coder_docs.cpp", 34, 175 }, { PROC_LINKS(cut, 0), false, "cut", 3, "Cut the text in the range from the cursor to the mark onto the clipboard.", 73, "W:\\4ed\\code\\custom\\4coder_clipboard.cpp", 39, 119 }, { PROC_LINKS(decrease_face_size, 0), false, "decrease_face_size", 18, "Decrease the size of the face used by the current buffer.", 57, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 757 }, -{ PROC_LINKS(default_file_externally_modified, 0), false, "default_file_externally_modified", 32, "Notes the external modification of attached files by printing a message.", 72, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 2055 }, +{ PROC_LINKS(default_file_externally_modified, 0), false, "default_file_externally_modified", 32, "Notes the external modification of attached files by printing a message.", 72, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 2062 }, { PROC_LINKS(default_startup, 0), false, "default_startup", 15, "Default command for responding to a startup event", 49, "W:\\4ed\\code\\custom\\4coder_default_hooks.cpp", 43, 7 }, { PROC_LINKS(default_try_exit, 0), false, "default_try_exit", 16, "Default command for responding to a try-exit event", 50, "W:\\4ed\\code\\custom\\4coder_default_hooks.cpp", 43, 23 }, { PROC_LINKS(default_view_input_handler, 0), false, "default_view_input_handler", 26, "Input consumption loop for default view behavior", 48, "W:\\4ed\\code\\custom\\4coder_default_hooks.cpp", 43, 67 }, @@ -351,7 +351,7 @@ static Command_Metadata fcoder_metacmd_table[248] = { { PROC_LINKS(keyboard_macro_finish_recording, 0), false, "keyboard_macro_finish_recording", 31, "Stop macro recording, do nothing if macro recording is not already started", 74, "W:\\4ed\\code\\custom\\4coder_keyboard_macro.cpp", 44, 54 }, { PROC_LINKS(keyboard_macro_replay, 0), false, "keyboard_macro_replay", 21, "Replay the most recently recorded keyboard macro", 48, "W:\\4ed\\code\\custom\\4coder_keyboard_macro.cpp", 44, 77 }, { PROC_LINKS(keyboard_macro_start_recording, 0), false, "keyboard_macro_start_recording", 30, "Start macro recording, do nothing if macro recording is already started", 71, "W:\\4ed\\code\\custom\\4coder_keyboard_macro.cpp", 44, 41 }, -{ PROC_LINKS(kill_buffer, 0), false, "kill_buffer", 11, "Kills the current buffer.", 25, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1717 }, +{ PROC_LINKS(kill_buffer, 0), false, "kill_buffer", 11, "Kills the current buffer.", 25, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1724 }, { PROC_LINKS(kill_tutorial, 0), false, "kill_tutorial", 13, "If there is an active tutorial, kill it.", 40, "W:\\4ed\\code\\custom\\4coder_tutorial.cpp", 38, 9 }, { PROC_LINKS(left_adjust_view, 0), false, "left_adjust_view", 16, "Sets the left size of the view near the x position of the cursor.", 65, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 210 }, { PROC_LINKS(list_all_functions_all_buffers, 0), false, "list_all_functions_all_buffers", 30, "Creates a jump list of lines from all buffers that appear to define or declare functions.", 89, "W:\\4ed\\code\\custom\\4coder_function_list.cpp", 43, 296 }, @@ -411,12 +411,12 @@ static Command_Metadata fcoder_metacmd_table[248] = { { PROC_LINKS(multi_paste_interactive_quick, 0), false, "multi_paste_interactive_quick", 29, "Paste multiple lines from the clipboard history, controlled by inputing the number of lines to paste", 100, "W:\\4ed\\code\\custom\\4coder_clipboard.cpp", 39, 380 }, { PROC_LINKS(open_all_code, 0), false, "open_all_code", 13, "Open all code in the current directory. File types are determined by extensions. An extension is considered code based on the extensions specified in 4coder.config.", 164, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 850 }, { PROC_LINKS(open_all_code_recursive, 0), false, "open_all_code_recursive", 23, "Works as open_all_code but also runs in all subdirectories.", 59, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 856 }, -{ PROC_LINKS(open_file_in_quotes, 0), false, "open_file_in_quotes", 19, "Reads a filename from surrounding '\"' characters and attempts to open the corresponding file.", 94, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1618 }, -{ PROC_LINKS(open_in_other, 0), false, "open_in_other", 13, "Interactively opens a file in the other panel.", 46, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 2049 }, +{ PROC_LINKS(open_file_in_quotes, 0), false, "open_file_in_quotes", 19, "Reads a filename from surrounding '\"' characters and attempts to open the corresponding file.", 94, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1574 }, +{ PROC_LINKS(open_in_other, 0), false, "open_in_other", 13, "Interactively opens a file in the other panel.", 46, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 2056 }, { PROC_LINKS(open_long_braces, 0), false, "open_long_braces", 16, "At the cursor, insert a '{' and '}' separated by a blank line.", 62, "W:\\4ed\\code\\custom\\4coder_combined_write_commands.cpp", 53, 46 }, { PROC_LINKS(open_long_braces_break, 0), false, "open_long_braces_break", 22, "At the cursor, insert a '{' and '}break;' separated by a blank line.", 68, "W:\\4ed\\code\\custom\\4coder_combined_write_commands.cpp", 53, 62 }, { PROC_LINKS(open_long_braces_semicolon, 0), false, "open_long_braces_semicolon", 26, "At the cursor, insert a '{' and '};' separated by a blank line.", 63, "W:\\4ed\\code\\custom\\4coder_combined_write_commands.cpp", 53, 54 }, -{ PROC_LINKS(open_matching_file_cpp, 0), false, "open_matching_file_cpp", 22, "If the current file is a *.cpp or *.h, attempts to open the corresponding *.h or *.cpp file in the other view.", 110, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1650 }, +{ PROC_LINKS(open_matching_file_cpp, 0), false, "open_matching_file_cpp", 22, "If the current file is a *.cpp or *.h, attempts to open the corresponding *.h or *.cpp file in the other view.", 110, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1657 }, { PROC_LINKS(open_panel_hsplit, 0), false, "open_panel_hsplit", 17, "Create a new panel by horizontally splitting the active panel.", 62, "W:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 386 }, { PROC_LINKS(open_panel_vsplit, 0), false, "open_panel_vsplit", 17, "Create a new panel by vertically splitting the active panel.", 60, "W:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 376 }, { PROC_LINKS(page_down, 0), false, "page_down", 9, "Scrolls the view down one view height and moves the cursor down one view height.", 80, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 376 }, @@ -437,17 +437,17 @@ static Command_Metadata fcoder_metacmd_table[248] = { { PROC_LINKS(query_replace, 0), false, "query_replace", 13, "Queries the user for two strings, and incrementally replaces every occurence of the first string with the second string.", 120, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1280 }, { PROC_LINKS(query_replace_identifier, 0), false, "query_replace_identifier", 24, "Queries the user for a string, and incrementally replace every occurence of the word or token found at the cursor with the specified string.", 140, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1301 }, { PROC_LINKS(query_replace_selection, 0), false, "query_replace_selection", 23, "Queries the user for a string, and incrementally replace every occurence of the string found in the selected range with the specified string.", 141, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1317 }, -{ PROC_LINKS(quick_swap_buffer, 0), false, "quick_swap_buffer", 17, "Change to the most recently used buffer in this view - or to the top of the buffer stack if the most recent doesn't exist anymore", 129, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1697 }, -{ PROC_LINKS(redo, 0), false, "redo", 4, "Advances forwards through the undo history of the current buffer.", 65, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1876 }, -{ PROC_LINKS(redo_all_buffers, 0), false, "redo_all_buffers", 16, "Advances forward through the undo history in the buffer containing the most recent regular edit.", 96, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1973 }, +{ PROC_LINKS(quick_swap_buffer, 0), false, "quick_swap_buffer", 17, "Change to the most recently used buffer in this view - or to the top of the buffer stack if the most recent doesn't exist anymore", 129, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1704 }, +{ PROC_LINKS(redo, 0), false, "redo", 4, "Advances forwards through the undo history of the current buffer.", 65, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1883 }, +{ PROC_LINKS(redo_all_buffers, 0), false, "redo_all_buffers", 16, "Advances forward through the undo history in the buffer containing the most recent regular edit.", 96, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1980 }, { PROC_LINKS(rename_file_query, 0), false, "rename_file_query", 17, "Queries the user for a new name and renames the file of the current buffer, altering the buffer's name too.", 107, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1458 }, -{ PROC_LINKS(reopen, 0), false, "reopen", 6, "Reopen the current buffer from the hard drive.", 46, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1735 }, +{ PROC_LINKS(reopen, 0), false, "reopen", 6, "Reopen the current buffer from the hard drive.", 46, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1742 }, { PROC_LINKS(replace_in_all_buffers, 0), false, "replace_in_all_buffers", 22, "Queries the user for a needle and string. Replaces all occurences of needle with string in all editable buffers.", 112, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1190 }, { PROC_LINKS(replace_in_buffer, 0), false, "replace_in_buffer", 17, "Queries the user for a needle and string. Replaces all occurences of needle with string in the active buffer.", 109, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1181 }, { PROC_LINKS(replace_in_range, 0), false, "replace_in_range", 16, "Queries the user for a needle and string. Replaces all occurences of needle with string in the range between cursor and the mark in the active buffer.", 150, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1172 }, { PROC_LINKS(reverse_search, 0), false, "reverse_search", 14, "Begins an incremental search up through the current buffer for a user specified string.", 87, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1113 }, { PROC_LINKS(reverse_search_identifier, 0), false, "reverse_search_identifier", 25, "Begins an incremental search up through the current buffer for the word or token under the cursor.", 98, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1125 }, -{ PROC_LINKS(save, 0), false, "save", 4, "Saves the current buffer.", 25, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1725 }, +{ PROC_LINKS(save, 0), false, "save", 4, "Saves the current buffer.", 25, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1732 }, { PROC_LINKS(save_all_dirty_buffers, 0), false, "save_all_dirty_buffers", 22, "Saves all buffers marked dirty (showing the '*' indicator).", 59, "W:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 458 }, { PROC_LINKS(save_to_query, 0), false, "save_to_query", 13, "Queries the user for a file name and saves the contents of the current buffer, altering the buffer's name too.", 110, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1425 }, { PROC_LINKS(search, 0), false, "search", 6, "Begins an incremental search down through the current buffer for a user specified string.", 89, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1107 }, @@ -484,7 +484,7 @@ static Command_Metadata fcoder_metacmd_table[248] = { { PROC_LINKS(snippet_lister, 0), true, "snippet_lister", 14, "Opens a snippet lister for inserting whole pre-written snippets of text.", 72, "W:\\4ed\\code\\custom\\4coder_combined_write_commands.cpp", 53, 237 }, { PROC_LINKS(string_repeat, 0), false, "string_repeat", 13, "Example of query_user_string and query_user_number", 50, "W:\\4ed\\code\\custom\\4coder_examples.cpp", 38, 179 }, { PROC_LINKS(suppress_mouse, 0), false, "suppress_mouse", 14, "Hides the mouse and causes all mosue input (clicks, position, wheel) to be ignored.", 83, "W:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 479 }, -{ PROC_LINKS(swap_panels, 0), false, "swap_panels", 11, "Swaps the active panel with it's sibling.", 41, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1675 }, +{ PROC_LINKS(swap_panels, 0), false, "swap_panels", 11, "Swaps the active panel with it's sibling.", 41, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1682 }, { PROC_LINKS(test_the_new_api, 0), false, "test_the_new_api", 16, "If you are reading this I forgot to delete this test, please let me know", 72, "W:\\4ed\\code\\custom\\4coder_examples.cpp", 38, 212 }, { PROC_LINKS(theme_lister, 0), true, "theme_lister", 12, "Opens an interactive list of all registered themes.", 51, "W:\\4ed\\code\\custom\\4coder_lists.cpp", 35, 784 }, { PROC_LINKS(to_lowercase, 0), false, "to_lowercase", 12, "Converts all ascii text in the range between the cursor and the mark to lowercase.", 82, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 567 }, @@ -503,9 +503,9 @@ static Command_Metadata fcoder_metacmd_table[248] = { { PROC_LINKS(tutorial_maximize, 0), false, "tutorial_maximize", 17, "Expand the tutorial window", 26, "W:\\4ed\\code\\custom\\4coder_tutorial.cpp", 38, 20 }, { PROC_LINKS(tutorial_minimize, 0), false, "tutorial_minimize", 17, "Shrink the tutorial window", 26, "W:\\4ed\\code\\custom\\4coder_tutorial.cpp", 38, 34 }, { PROC_LINKS(uncomment_line, 0), false, "uncomment_line", 14, "If present, delete '//' at the beginning of the line after leading whitespace.", 78, "W:\\4ed\\code\\custom\\4coder_combined_write_commands.cpp", 53, 137 }, -{ PROC_LINKS(undo, 0), false, "undo", 4, "Advances backwards through the undo history of the current buffer.", 66, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1825 }, -{ PROC_LINKS(undo_all_buffers, 0), false, "undo_all_buffers", 16, "Advances backward through the undo history in the buffer containing the most recent regular edit.", 97, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1902 }, -{ PROC_LINKS(view_buffer_other_panel, 0), false, "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, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1663 }, +{ PROC_LINKS(undo, 0), false, "undo", 4, "Advances backwards through the undo history of the current buffer.", 66, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1832 }, +{ PROC_LINKS(undo_all_buffers, 0), false, "undo_all_buffers", 16, "Advances backward through the undo history in the buffer containing the most recent regular edit.", 97, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1909 }, +{ PROC_LINKS(view_buffer_other_panel, 0), false, "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, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1670 }, { PROC_LINKS(view_jump_list_with_lister, 0), false, "view_jump_list_with_lister", 26, "When executed on a buffer with jumps, creates a persistent lister for all the jumps", 83, "W:\\4ed\\code\\custom\\4coder_jump_lister.cpp", 41, 59 }, { PROC_LINKS(word_complete, 0), false, "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, "W:\\4ed\\code\\custom\\4coder_search.cpp", 36, 434 }, { PROC_LINKS(word_complete_drop_down, 0), false, "word_complete_drop_down", 23, "Word complete with drop down menu.", 34, "W:\\4ed\\code\\custom\\4coder_search.cpp", 36, 680 }, From a9a1931e345a249f16167f8d810354664b80bb63 Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Mon, 23 Nov 2020 13:46:01 -0800 Subject: [PATCH 5/9] Hack in new audio system contributed by casey; win32 only for now --- 4ed_system_api.cpp | 6 + custom/4coder_audio.cpp | 104 ++++++++++ custom/4coder_audio.h | 11 ++ custom/4coder_default_hooks.cpp | 9 + custom/4coder_default_include.cpp | 2 + custom/4coder_types.h | 35 ++++ custom/generated/command_metadata.h | 4 +- custom/generated/system_api.cpp | 2 + custom/generated/system_api.h | 5 + custom/generated/system_api_constructor.cpp | 5 + custom/generated/system_api_master_list.h | 1 + platform_win32/win32_4ed.cpp | 28 ++- platform_win32/win32_audio.cpp | 199 ++++++++++++++++++++ 13 files changed, 399 insertions(+), 12 deletions(-) create mode 100644 custom/4coder_audio.cpp create mode 100644 custom/4coder_audio.h create mode 100644 platform_win32/win32_audio.cpp diff --git a/4ed_system_api.cpp b/4ed_system_api.cpp index 910ed9ae..81e11430 100644 --- a/4ed_system_api.cpp +++ b/4ed_system_api.cpp @@ -303,6 +303,12 @@ define_api(Arena *arena){ api_param(arena, call, "Key_Mode", "mode"); } + { + API_Call *call = api_call(arena, api, "play_clip", "void"); + api_param(arena, call, "Audio_Clip", "clip"); + api_param(arena, call, "Audio_Control*", "control"); + } + return(api); } diff --git a/custom/4coder_audio.cpp b/custom/4coder_audio.cpp new file mode 100644 index 00000000..c68ce7d3 --- /dev/null +++ b/custom/4coder_audio.cpp @@ -0,0 +1,104 @@ +//////////////////////////////// +// NOTE(allen): Load Clip + +#if !defined(FCODER_SKIP_WAV) +#define FCODER_SKIP_WAV +#pragma pack(push, 1) +struct wave_fmt_data +{ + u16 wFormatTag; + u16 wChannels; + u32 dwSamplesPerSec; + u32 dwAvgBytesPerSec; + u16 wBlockAlign; + u16 wBitsPerSample; +}; + +struct riff_header +{ + u32 ID; + u32 DataSize; +}; +#pragma pack(pop) +#endif + +function Audio_Clip +audio_clip_from_wav_data(String_Const_u8 data){ + Audio_Clip Result = {}; + + if (data.size >= 4 && *(u32 *)data.str == *(u32 *)"RIFF"){ + // NOTE(casey): This ROM is in WAV format + + riff_header *RootHeader = (riff_header *)data.str; + + wave_fmt_data *Format = 0; + u32 SampleDataSize = 0; + i16 *Samples = 0; + + u32 At = sizeof(riff_header); + u32 LastAt = At + ((RootHeader->DataSize + 1) & ~1); + if ((*(u32 *)(data.str + At) == *(u32 *)"WAVE") && + (LastAt <= data.size)){ + At += sizeof(u32); + while (At < LastAt){ + riff_header *Header = (riff_header *)(data.str + At); + u32 DataAt = At + sizeof(riff_header); + u32 EndAt = DataAt + ((Header->DataSize + 1) & ~1); + if(EndAt <= data.size) + { + void *Data = (data.str + DataAt); + if(Header->ID == *(u32 *)"fmt ") + { + Format = (wave_fmt_data *)Data; + } + else if(Header->ID == *(u32 *)"data") + { + SampleDataSize = Header->DataSize; + Samples = (i16 *)Data; + } + } + + At = EndAt; + } + } + + if (Format && + Samples && + (Format->wFormatTag == 1) && + (Format->wChannels == 2) && + (Format->wBitsPerSample == 16) && + (Format->dwSamplesPerSec == 48000)){ + Result.sample_count = SampleDataSize / (Format->wChannels*Format->wBitsPerSample/8); + Result.samples = (i16 *)Samples; + } + else{ + // TODO(casey): This is where you would output an error - to 4coder somehow? + } + } + else{ + // TODO(casey): This is where you would output an error - to 4coder somehow? + } + + return(Result); +} + +#include + +function Audio_Clip +audio_clip_from_wav_file_name(char *file_name){ + String_Const_u8 data = {}; + FILE *file = fopen(file_name, "rb"); + if (file != 0){ + fseek(file, 0, SEEK_END); + data.size = ftell(file); + data.str = (u8*)malloc(data.size); + if (data.str != 0 && data.size > 0){ + fseek(file, 0, SEEK_SET); + fread(data.str, data.size, 1, file); + } + fclose(file); + } + + Audio_Clip result = audio_clip_from_wav_data(data); + return(result); +} diff --git a/custom/4coder_audio.h b/custom/4coder_audio.h new file mode 100644 index 00000000..328d5da9 --- /dev/null +++ b/custom/4coder_audio.h @@ -0,0 +1,11 @@ +/* date = November 23rd 2020 1:18 pm */ + +#ifndef FCODER_AUDIO_H +#define FCODER_AUDIO_H + +//////////////////////////////// +// NOTE(allen): Load Clip + +function Audio_Clip audio_clip_from_wav_data(String_Const_u8 data); + +#endif //4CODER_AUDIO_H diff --git a/custom/4coder_default_hooks.cpp b/custom/4coder_default_hooks.cpp index cadfbd72..e5f1d968 100644 --- a/custom/4coder_default_hooks.cpp +++ b/custom/4coder_default_hooks.cpp @@ -18,6 +18,15 @@ CUSTOM_DOC("Default command for responding to a startup event") load_project(app); } } + + { + Audio_Clip test_clip = audio_clip_from_wav_file_name("W:\\4ed\\audio_test\\raygun_zap.wav"); + + local_persist Audio_Control test_control = {}; + test_control.left_volume_knob = AUDIO_PRODUCER_KNOB_ONE; + test_control.right_volume_knob = AUDIO_PRODUCER_KNOB_ONE; + system_play_clip(test_clip, &test_control); + } } CUSTOM_COMMAND_SIG(default_try_exit) diff --git a/custom/4coder_default_include.cpp b/custom/4coder_default_include.cpp index dd92cc1a..4a0d5d14 100644 --- a/custom/4coder_default_include.cpp +++ b/custom/4coder_default_include.cpp @@ -28,6 +28,7 @@ #endif #include "4coder_variables.h" +#include "4coder_audio.h" #include "4coder_profile.h" #include "4coder_async_tasks.h" #include "4coder_token.h" @@ -129,6 +130,7 @@ #include "4coder_doc_commands.cpp" #include "4coder_docs.cpp" #include "4coder_variables.cpp" +#include "4coder_audio.cpp" #include "4coder_examples.cpp" diff --git a/custom/4coder_types.h b/custom/4coder_types.h index 8327ef4f..2d2c8826 100644 --- a/custom/4coder_types.h +++ b/custom/4coder_types.h @@ -787,4 +787,39 @@ struct Process_State{ i64 return_code; }; +//////////////////////////////// + +api(custom) +struct Audio_Control{ +#define AUDIO_PRODUCER_KNOB_ONE 256 + volatile u32 left_volume_knob; + volatile u32 right_volume_knob; + volatile u32 generation; + volatile u32 last_played_sample_index;; +}; + +api(custom) +struct Audio_Clip{ + i16 *samples; + Audio_Control *control; + + u32 sample_count; + u32 at_sample_index; +}; + +api(custom) +struct Audio_System{ + volatile u32 quit; + volatile u32 ticket; + volatile u32 serving; + volatile u32 generation; + + u32 next_playing_clip_index; + Audio_Clip playing_clips[64]; + + // NOTE(casey): Requests to play sounds are written to a pending array to avoid long locking + volatile u32 pending_clip_count; + Audio_Clip pending_clips[64]; +}; + #endif diff --git a/custom/generated/command_metadata.h b/custom/generated/command_metadata.h index ce8b98d6..d14706b1 100644 --- a/custom/generated/command_metadata.h +++ b/custom/generated/command_metadata.h @@ -307,8 +307,8 @@ static Command_Metadata fcoder_metacmd_table[248] = { { PROC_LINKS(decrease_face_size, 0), false, "decrease_face_size", 18, "Decrease the size of the face used by the current buffer.", 57, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 757 }, { PROC_LINKS(default_file_externally_modified, 0), false, "default_file_externally_modified", 32, "Notes the external modification of attached files by printing a message.", 72, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 2062 }, { PROC_LINKS(default_startup, 0), false, "default_startup", 15, "Default command for responding to a startup event", 49, "W:\\4ed\\code\\custom\\4coder_default_hooks.cpp", 43, 7 }, -{ PROC_LINKS(default_try_exit, 0), false, "default_try_exit", 16, "Default command for responding to a try-exit event", 50, "W:\\4ed\\code\\custom\\4coder_default_hooks.cpp", 43, 23 }, -{ PROC_LINKS(default_view_input_handler, 0), false, "default_view_input_handler", 26, "Input consumption loop for default view behavior", 48, "W:\\4ed\\code\\custom\\4coder_default_hooks.cpp", 43, 67 }, +{ PROC_LINKS(default_try_exit, 0), false, "default_try_exit", 16, "Default command for responding to a try-exit event", 50, "W:\\4ed\\code\\custom\\4coder_default_hooks.cpp", 43, 32 }, +{ PROC_LINKS(default_view_input_handler, 0), false, "default_view_input_handler", 26, "Input consumption loop for default view behavior", 48, "W:\\4ed\\code\\custom\\4coder_default_hooks.cpp", 43, 76 }, { PROC_LINKS(delete_alpha_numeric_boundary, 0), false, "delete_alpha_numeric_boundary", 29, "Delete characters between the cursor position and the first alphanumeric boundary to the right.", 95, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 161 }, { PROC_LINKS(delete_char, 0), false, "delete_char", 11, "Deletes the character to the right of the cursor.", 49, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 79 }, { PROC_LINKS(delete_current_scope, 0), false, "delete_current_scope", 20, "Deletes the braces surrounding the currently selected scope. Leaves the contents within the scope.", 99, "W:\\4ed\\code\\custom\\4coder_scope_commands.cpp", 44, 112 }, diff --git a/custom/generated/system_api.cpp b/custom/generated/system_api.cpp index 4e961682..724f0b82 100644 --- a/custom/generated/system_api.cpp +++ b/custom/generated/system_api.cpp @@ -54,6 +54,7 @@ vtable->set_fullscreen = system_set_fullscreen; vtable->is_fullscreen = system_is_fullscreen; vtable->get_keyboard_modifiers = system_get_keyboard_modifiers; vtable->set_key_mode = system_set_key_mode; +vtable->play_clip = system_play_clip; } #if defined(DYNAMIC_LINK_API) function void @@ -112,6 +113,7 @@ system_set_fullscreen = vtable->set_fullscreen; system_is_fullscreen = vtable->is_fullscreen; system_get_keyboard_modifiers = vtable->get_keyboard_modifiers; system_set_key_mode = vtable->set_key_mode; +system_play_clip = vtable->play_clip; } #undef DYNAMIC_LINK_API #endif diff --git a/custom/generated/system_api.h b/custom/generated/system_api.h index 7f0f7a39..5d39f00f 100644 --- a/custom/generated/system_api.h +++ b/custom/generated/system_api.h @@ -52,6 +52,7 @@ #define system_is_fullscreen_sig() b32 system_is_fullscreen(void) #define system_get_keyboard_modifiers_sig() Input_Modifier_Set system_get_keyboard_modifiers(Arena* arena) #define system_set_key_mode_sig() void system_set_key_mode(Key_Mode mode) +#define system_play_clip_sig() void system_play_clip(Audio_Clip clip, Audio_Control* control) typedef String_Const_u8 system_get_path_type(Arena* arena, System_Path_Code path_code); typedef String_Const_u8 system_get_canonical_type(Arena* arena, String_Const_u8 name); typedef File_List system_get_file_list_type(Arena* arena, String_Const_u8 directory); @@ -106,6 +107,7 @@ typedef b32 system_set_fullscreen_type(b32 full_screen); typedef b32 system_is_fullscreen_type(void); typedef Input_Modifier_Set system_get_keyboard_modifiers_type(Arena* arena); typedef void system_set_key_mode_type(Key_Mode mode); +typedef void system_play_clip_type(Audio_Clip clip, Audio_Control* control); struct API_VTable_system{ system_get_path_type *get_path; system_get_canonical_type *get_canonical; @@ -161,6 +163,7 @@ system_set_fullscreen_type *set_fullscreen; system_is_fullscreen_type *is_fullscreen; system_get_keyboard_modifiers_type *get_keyboard_modifiers; system_set_key_mode_type *set_key_mode; +system_play_clip_type *play_clip; }; #if defined(STATIC_LINK_API) internal String_Const_u8 system_get_path(Arena* arena, System_Path_Code path_code); @@ -217,6 +220,7 @@ internal b32 system_set_fullscreen(b32 full_screen); internal b32 system_is_fullscreen(void); internal Input_Modifier_Set system_get_keyboard_modifiers(Arena* arena); internal void system_set_key_mode(Key_Mode mode); +internal void system_play_clip(Audio_Clip clip, Audio_Control* control); #undef STATIC_LINK_API #elif defined(DYNAMIC_LINK_API) global system_get_path_type *system_get_path = 0; @@ -273,5 +277,6 @@ global system_set_fullscreen_type *system_set_fullscreen = 0; global system_is_fullscreen_type *system_is_fullscreen = 0; global system_get_keyboard_modifiers_type *system_get_keyboard_modifiers = 0; global system_set_key_mode_type *system_set_key_mode = 0; +global system_play_clip_type *system_play_clip = 0; #undef DYNAMIC_LINK_API #endif diff --git a/custom/generated/system_api_constructor.cpp b/custom/generated/system_api_constructor.cpp index c7fccb54..152a3c58 100644 --- a/custom/generated/system_api_constructor.cpp +++ b/custom/generated/system_api_constructor.cpp @@ -245,5 +245,10 @@ api_param(arena, call, "Arena*", "arena"); API_Call *call = api_call_with_location(arena, result, string_u8_litexpr("set_key_mode"), string_u8_litexpr("void"), string_u8_litexpr("")); api_param(arena, call, "Key_Mode", "mode"); } +{ +API_Call *call = api_call_with_location(arena, result, string_u8_litexpr("play_clip"), string_u8_litexpr("void"), string_u8_litexpr("")); +api_param(arena, call, "Audio_Clip", "clip"); +api_param(arena, call, "Audio_Control*", "control"); +} return(result); } diff --git a/custom/generated/system_api_master_list.h b/custom/generated/system_api_master_list.h index 8408ad94..3ed646ff 100644 --- a/custom/generated/system_api_master_list.h +++ b/custom/generated/system_api_master_list.h @@ -52,3 +52,4 @@ api(system) function b32 set_fullscreen(b32 full_screen); api(system) function b32 is_fullscreen(void); api(system) function Input_Modifier_Set get_keyboard_modifiers(Arena* arena); api(system) function void set_key_mode(Key_Mode mode); +api(system) function void play_clip(Audio_Clip clip, Audio_Control* control); diff --git a/platform_win32/win32_4ed.cpp b/platform_win32/win32_4ed.cpp index d52bdf9a..2b1f7774 100644 --- a/platform_win32/win32_4ed.cpp +++ b/platform_win32/win32_4ed.cpp @@ -179,6 +179,9 @@ struct Win32_Vars{ HWND window_handle; f32 screen_scale_factor; + Audio_System audio_system; + DWORD audio_thread_id; + f64 count_per_usecond; b32 first; i32 running_cli; @@ -259,6 +262,7 @@ handle_type_ptr(void *ptr){ //////////////////////////////// #include "win32_4ed_functions.cpp" +#include "win32_audio.cpp" //////////////////////////////// @@ -355,9 +359,16 @@ system_set_key_mode_sig(){ win32vars.key_mode = mode; } -// -// Clipboard -// +//////////////////////////////// +// NOTE(allen): Audio + +internal +system_play_clip_sig(){ + win32_play_clip(clip, control); +} + +//////////////////////////////// +// NOTE(allen): Clipboard internal String_Const_u8 win32_read_clipboard_contents(Thread_Context *tctx, Arena *arena){ @@ -1783,10 +1794,7 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdS } } - // - // Window and GL Initialization - // - + // NOTE(allen): Window Init RECT window_rect = {}; if (plat_settings.set_window_size){ window_rect.right = plat_settings.window_w; @@ -1811,10 +1819,10 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdS GetClientRect(win32vars.window_handle, &window_rect); win32_resize(window_rect.right - window_rect.left, window_rect.bottom - window_rect.top); - // - // Misc System Initializations - // + // NOTE(allen): Audio Init + win32vars.audio_thread_id = win32_audio_init(&win32vars.audio_system); + // NOTE(allen): Misc Init if (!AddClipboardFormatListener(win32vars.window_handle)){ Scratch_Block scratch(win32vars.tctx); win32_output_error_string(scratch, ErrorString_UseLog); diff --git a/platform_win32/win32_audio.cpp b/platform_win32/win32_audio.cpp new file mode 100644 index 00000000..9d1e3ca2 --- /dev/null +++ b/platform_win32/win32_audio.cpp @@ -0,0 +1,199 @@ +//////////////////////////////// +// NOTE(allen): Win32 Audio Functions + +function u32 +AtomicAddU32AndReturnOriginal(u32 volatile *Value, u32 Addend) +{ + // NOTE(casey): Returns the original value _prior_ to adding + u32 Result = _InterlockedExchangeAdd(Value, Addend); + return(Result); +} + +function void +win32_begin_ticket_mutex(Audio_System *Crunky) +{ + u32 Ticket = AtomicAddU32AndReturnOriginal(&Crunky->ticket, 1); + while(Ticket != Crunky->serving) {_mm_pause();} +} + +function void +win32_end_ticket_mutex(Audio_System *Crunky) +{ + AtomicAddU32AndReturnOriginal(&Crunky->serving, 1); +} + +function void +win32_play_clip(Audio_Clip clip, Audio_Control *control){ + clip.control = control; + Audio_System *Crunky = &win32vars.audio_system; + win32_begin_ticket_mutex(Crunky); + if (Crunky->pending_clip_count < ArrayCount(Crunky->pending_clips)) + { + Crunky->pending_clips[Crunky->pending_clip_count++] = clip; + } + win32_end_ticket_mutex(Crunky); +} + +function void +win32_mix_audio(Audio_System *Crunky, u32 SampleCount, i16 *Dest){ + // NOTE(casey): Move pending sounds into the playing list + win32_begin_ticket_mutex(Crunky); + ++Crunky->generation; + for(u32 PendIndex = 0; + PendIndex < Crunky->pending_clip_count; + ++PendIndex) + { + u32 DestIndex = Crunky->next_playing_clip_index++ % ArrayCount(Crunky->playing_clips); + Crunky->playing_clips[DestIndex] = Crunky->pending_clips[PendIndex]; + } + Crunky->pending_clip_count = 0; + win32_end_ticket_mutex(Crunky); + + memset(Dest, 0, SampleCount*4); + for(u32 SoundIndex = 0; + SoundIndex < ArrayCount(Crunky->playing_clips); + ++SoundIndex) + { + Audio_Clip Sound = Crunky->playing_clips[SoundIndex]; + u32 SamplesToMix = Min((Sound.sample_count - Sound.at_sample_index), SampleCount); + Crunky->playing_clips[SoundIndex].at_sample_index += SamplesToMix; + + i32 LeftVol = AUDIO_PRODUCER_KNOB_ONE; + i32 RightVol = AUDIO_PRODUCER_KNOB_ONE; + if(SamplesToMix && Sound.control) + { + LeftVol = Sound.control->left_volume_knob; + RightVol = Sound.control->right_volume_knob; + Sound.control->generation = Crunky->generation; + Sound.control->last_played_sample_index = Crunky->playing_clips[SoundIndex].at_sample_index; + } + + + for(u32 SampleIndex = 0; + SampleIndex < SamplesToMix; + ++SampleIndex) + { + u32 src_base_indx = 2*(Sound.at_sample_index + SampleIndex); + u32 dst_base_indx = 2*SampleIndex; + Dest[dst_base_indx + 0] += (i16)(LeftVol*(i32)Sound.samples[src_base_indx + 0]/AUDIO_PRODUCER_KNOB_ONE); + Dest[dst_base_indx + 1] += (i16)(RightVol*(i32)Sound.samples[src_base_indx + 1]/AUDIO_PRODUCER_KNOB_ONE); + } + } +} + +function b32 +win32_submit_audio(Audio_System *Crunky, HWAVEOUT WaveOut, WAVEHDR *Header){ + b32 Result = false; + + u32 SampleCount = Header->dwBufferLength/4; + i16 *Samples = (i16 *)Header->lpData; + win32_mix_audio(Crunky, SampleCount, Samples); + + DWORD Error = waveOutPrepareHeader(WaveOut, Header, sizeof(*Header)); + if(Error == MMSYSERR_NOERROR) + { + Error = waveOutWrite(WaveOut, Header, sizeof(*Header)); + if(Error == MMSYSERR_NOERROR) + { + // NOTE(casey): Success + Result = true; + } + } + + return(Result); +} + +function DWORD WINAPI +win32_audio_loop(void *Passthrough){ + Audio_System *Crunky = (Audio_System *)Passthrough; + + // + // NOTE(casey): Set up our audio output buffer + // + u32 SamplesPerSecond = 48000; + u32 SamplesPerBuffer = 16*SamplesPerSecond/1000; + u32 ChannelCount = 2; + u32 BytesPerChannelValue = 2; + u32 BytesPerSample = ChannelCount*BytesPerChannelValue; + + u32 BufferCount = 3; + u32 BufferSize = SamplesPerBuffer*BytesPerSample; + u32 HeaderSize = sizeof(WAVEHDR); + u32 TotalBufferSize = (BufferSize+HeaderSize); + u32 TotalAudioMemorySize = BufferCount*TotalBufferSize; + + // + // NOTE(casey): Initialize audio out + // + HWAVEOUT WaveOut = {}; + + WAVEFORMATEX Format = {}; + Format.wFormatTag = WAVE_FORMAT_PCM; + Format.nChannels = (WORD)ChannelCount; + Format.wBitsPerSample = (WORD)(8*BytesPerChannelValue); + Format.nSamplesPerSec = SamplesPerSecond; + Format.nBlockAlign = (Format.nChannels*Format.wBitsPerSample)/8; + Format.nAvgBytesPerSec = Format.nBlockAlign * Format.nSamplesPerSec; + + if(waveOutOpen(&WaveOut, WAVE_MAPPER, &Format, GetCurrentThreadId(), 0, CALLBACK_THREAD) == MMSYSERR_NOERROR) + { + void *AudioBufferMemory = VirtualAlloc(0, TotalAudioMemorySize, MEM_COMMIT, PAGE_READWRITE); + if(AudioBufferMemory) + { + u8 *At = (u8 *)AudioBufferMemory; + for(u32 BufferIndex = 0; + BufferIndex < BufferCount; + ++BufferIndex) + { + WAVEHDR *Header = (WAVEHDR *)At; + At += sizeof(WAVEHDR); + Header->lpData = (char *)At; + Header->dwBufferLength = TotalBufferSize; + + At += TotalBufferSize; + + win32_submit_audio(Crunky, WaveOut, Header); + } + } + else + { + Crunky->quit = true; + } + } + else + { + Crunky->quit = true; + } + + // + // NOTE(casey): Serve audio forever (until we are told to stop) + // + // SetTimer(0, 0, 100, 0); + while(!Crunky->quit) + { + MSG Message = {}; + GetMessage(&Message, 0, 0, 0); + if(Message.message == MM_WOM_DONE) + { + WAVEHDR *Header = (WAVEHDR *)Message.lParam; + if(Header->dwFlags & WHDR_DONE) + { + Header->dwFlags &= ~WHDR_DONE; + } + + waveOutUnprepareHeader(WaveOut, Header, sizeof(*Header)); + + win32_submit_audio(Crunky, WaveOut, Header); + } + } + + return(0); +} + +function DWORD +win32_audio_init(Audio_System *audio_system){ + DWORD thread_id = 0; + HANDLE handle = CreateThread(0, 0, win32_audio_loop, audio_system, 0, &thread_id); + CloseHandle(handle); + return(thread_id); +} From 4f31b9d5aad4cbe683efccecc76e3897d76b552c Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Mon, 23 Nov 2020 17:45:04 -0800 Subject: [PATCH 6/9] Stop audio API; switch to float based mixer --- 4ed_system_api.cpp | 10 + custom/4coder_audio.cpp | 3 + custom/4coder_default_hooks.cpp | 4 +- custom/4coder_examples.cpp | 49 +++ custom/4coder_types.h | 9 +- custom/generated/command_metadata.h | 379 ++++++++++---------- custom/generated/system_api.cpp | 4 + custom/generated/system_api.h | 10 + custom/generated/system_api_constructor.cpp | 8 + custom/generated/system_api_master_list.h | 2 + platform_win32/win32_4ed.cpp | 8 - platform_win32/win32_audio.cpp | 182 +++++++--- 12 files changed, 420 insertions(+), 248 deletions(-) diff --git a/4ed_system_api.cpp b/4ed_system_api.cpp index 81e11430..198d6913 100644 --- a/4ed_system_api.cpp +++ b/4ed_system_api.cpp @@ -309,6 +309,16 @@ define_api(Arena *arena){ api_param(arena, call, "Audio_Control*", "control"); } + { + API_Call *call = api_call(arena, api, "audio_is_playing", "b32"); + api_param(arena, call, "Audio_Control*", "control"); + } + + { + API_Call *call = api_call(arena, api, "audio_stop", "void"); + api_param(arena, call, "Audio_Control*", "control"); + } + return(api); } diff --git a/custom/4coder_audio.cpp b/custom/4coder_audio.cpp index c68ce7d3..a12173f6 100644 --- a/custom/4coder_audio.cpp +++ b/custom/4coder_audio.cpp @@ -68,6 +68,9 @@ audio_clip_from_wav_data(String_Const_u8 data){ (Format->wChannels == 2) && (Format->wBitsPerSample == 16) && (Format->dwSamplesPerSec == 48000)){ + for (u32 i = 0; i < 2; i += 1){ + Result.channel_volume[i] = 1.f; + } Result.sample_count = SampleDataSize / (Format->wChannels*Format->wBitsPerSample/8); Result.samples = (i16 *)Samples; } diff --git a/custom/4coder_default_hooks.cpp b/custom/4coder_default_hooks.cpp index e5f1d968..ecdd794f 100644 --- a/custom/4coder_default_hooks.cpp +++ b/custom/4coder_default_hooks.cpp @@ -23,8 +23,8 @@ CUSTOM_DOC("Default command for responding to a startup event") Audio_Clip test_clip = audio_clip_from_wav_file_name("W:\\4ed\\audio_test\\raygun_zap.wav"); local_persist Audio_Control test_control = {}; - test_control.left_volume_knob = AUDIO_PRODUCER_KNOB_ONE; - test_control.right_volume_knob = AUDIO_PRODUCER_KNOB_ONE; + test_control.channel_volume[0] = 1.f; + test_control.channel_volume[1] = 1.f; system_play_clip(test_clip, &test_control); } } diff --git a/custom/4coder_examples.cpp b/custom/4coder_examples.cpp index 9d3763be..c11f74f7 100644 --- a/custom/4coder_examples.cpp +++ b/custom/4coder_examples.cpp @@ -262,6 +262,55 @@ CUSTOM_DOC("If you are reading this I forgot to delete this test, please let me } +global Audio_Control the_music_control = {}; + +CUSTOM_COMMAND_SIG(music_start) +CUSTOM_DOC("Starts the music.") +{ + local_persist Audio_Clip the_music_clip = {}; + local_persist b32 initialized = false; + if (!initialized){ + initialized = true; + the_music_clip = audio_clip_from_wav_file_name("W:\\4ed\\audio_test\\chtulthu.wav"); + } + + if (!system_audio_is_playing(&the_music_control)){ + the_music_control.loop = true; + the_music_control.channel_volume[0] = 1.f; + the_music_control.channel_volume[1] = 1.f; + system_play_clip(the_music_clip, &the_music_control); + } +} + +CUSTOM_COMMAND_SIG(music_stop) +CUSTOM_DOC("Stops the music.") +{ + system_audio_stop(&the_music_control); +} + +CUSTOM_COMMAND_SIG(hit_sfx) +CUSTOM_DOC("Play the hit sound effect") +{ + local_persist Audio_Clip the_hit_clip = {}; + local_persist b32 initialized = false; + if (!initialized){ + initialized = true; + the_hit_clip = audio_clip_from_wav_file_name("W:\\4ed\\audio_test\\hit.wav"); + } + + local_persist u32 index = 0; + local_persist Audio_Control controls[8] = {}; + + Audio_Control *control = &controls[index%8]; + if (!system_audio_is_playing(control)){ + control->loop = false; + control->channel_volume[0] = 1.f; + control->channel_volume[1] = 1.f; + system_play_clip(the_hit_clip, control); + index += 1; + } +} + // BOTTOM diff --git a/custom/4coder_types.h b/custom/4coder_types.h index 2d2c8826..b48d551e 100644 --- a/custom/4coder_types.h +++ b/custom/4coder_types.h @@ -791,17 +791,17 @@ struct Process_State{ api(custom) struct Audio_Control{ -#define AUDIO_PRODUCER_KNOB_ONE 256 - volatile u32 left_volume_knob; - volatile u32 right_volume_knob; + volatile f32 channel_volume[2]; volatile u32 generation; - volatile u32 last_played_sample_index;; + volatile u32 last_played_sample_index; + volatile b32 loop; }; api(custom) struct Audio_Clip{ i16 *samples; Audio_Control *control; + f32 channel_volume[2]; u32 sample_count; u32 at_sample_index; @@ -814,7 +814,6 @@ struct Audio_System{ volatile u32 serving; volatile u32 generation; - u32 next_playing_clip_index; Audio_Clip playing_clips[64]; // NOTE(casey): Requests to play sounds are written to a pending array to avoid long locking diff --git a/custom/generated/command_metadata.h b/custom/generated/command_metadata.h index d14706b1..3c0e996d 100644 --- a/custom/generated/command_metadata.h +++ b/custom/generated/command_metadata.h @@ -2,7 +2,7 @@ #define command_id(c) (fcoder_metacmd_ID_##c) #define command_metadata(c) (&fcoder_metacmd_table[command_id(c)]) #define command_metadata_by_id(id) (&fcoder_metacmd_table[id]) -#define command_one_past_last_id 248 +#define command_one_past_last_id 251 #if defined(CUSTOM_COMMAND_SIG) #define PROC_LINKS(x,y) x #else @@ -74,6 +74,7 @@ CUSTOM_COMMAND_SIG(goto_prev_jump); CUSTOM_COMMAND_SIG(goto_prev_jump_no_skips); CUSTOM_COMMAND_SIG(hide_filebar); CUSTOM_COMMAND_SIG(hide_scrollbar); +CUSTOM_COMMAND_SIG(hit_sfx); CUSTOM_COMMAND_SIG(hms_demo_tutorial); CUSTOM_COMMAND_SIG(if0_off); CUSTOM_COMMAND_SIG(if_read_only_goto_position); @@ -148,6 +149,8 @@ CUSTOM_COMMAND_SIG(move_up_to_blank_line_skip_whitespace); CUSTOM_COMMAND_SIG(multi_paste); CUSTOM_COMMAND_SIG(multi_paste_interactive); CUSTOM_COMMAND_SIG(multi_paste_interactive_quick); +CUSTOM_COMMAND_SIG(music_start); +CUSTOM_COMMAND_SIG(music_stop); CUSTOM_COMMAND_SIG(open_all_code); CUSTOM_COMMAND_SIG(open_all_code_recursive); CUSTOM_COMMAND_SIG(open_file_in_quotes); @@ -269,7 +272,7 @@ char *source_name; i32 source_name_len; i32 line_number; }; -static Command_Metadata fcoder_metacmd_table[248] = { +static Command_Metadata fcoder_metacmd_table[251] = { { PROC_LINKS(allow_mouse, 0), false, "allow_mouse", 11, "Shows the mouse and causes all mouse input to be processed normally.", 68, "W:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 485 }, { PROC_LINKS(auto_indent_line_at_cursor, 0), false, "auto_indent_line_at_cursor", 26, "Auto-indents the line on which the cursor sits.", 47, "W:\\4ed\\code\\custom\\4coder_auto_indent.cpp", 41, 417 }, { PROC_LINKS(auto_indent_range, 0), false, "auto_indent_range", 17, "Auto-indents the range between the cursor and the mark.", 55, "W:\\4ed\\code\\custom\\4coder_auto_indent.cpp", 41, 427 }, @@ -335,6 +338,7 @@ static Command_Metadata fcoder_metacmd_table[248] = { { PROC_LINKS(goto_prev_jump_no_skips, 0), false, "goto_prev_jump_no_skips", 23, "If a buffer containing jump locations has been locked in, goes to the previous jump in the buffer, and does not skip sub jump locations.", 136, "W:\\4ed\\code\\custom\\4coder_jump_sticky.cpp", 41, 511 }, { PROC_LINKS(hide_filebar, 0), false, "hide_filebar", 12, "Sets the current view to hide it's filebar.", 43, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 704 }, { PROC_LINKS(hide_scrollbar, 0), false, "hide_scrollbar", 14, "Sets the current view to hide it's scrollbar.", 45, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 690 }, +{ PROC_LINKS(hit_sfx, 0), false, "hit_sfx", 7, "Play the hit sound effect", 25, "W:\\4ed\\code\\custom\\4coder_examples.cpp", 38, 291 }, { PROC_LINKS(hms_demo_tutorial, 0), false, "hms_demo_tutorial", 17, "Tutorial for built in 4coder bindings and features.", 51, "W:\\4ed\\code\\custom\\4coder_tutorial.cpp", 38, 869 }, { PROC_LINKS(if0_off, 0), false, "if0_off", 7, "Surround the range between the cursor and mark with an '#if 0' and an '#endif'", 78, "W:\\4ed\\code\\custom\\4coder_combined_write_commands.cpp", 53, 70 }, { PROC_LINKS(if_read_only_goto_position, 0), false, "if_read_only_goto_position", 26, "If the buffer in the active view is writable, inserts a character, otherwise performs goto_jump_at_cursor.", 106, "W:\\4ed\\code\\custom\\4coder_jump_sticky.cpp", 41, 564 }, @@ -409,6 +413,8 @@ static Command_Metadata fcoder_metacmd_table[248] = { { PROC_LINKS(multi_paste, 0), false, "multi_paste", 11, "Paste multiple entries from the clipboard at once", 49, "W:\\4ed\\code\\custom\\4coder_clipboard.cpp", 39, 229 }, { PROC_LINKS(multi_paste_interactive, 0), false, "multi_paste_interactive", 23, "Paste multiple lines from the clipboard history, controlled with arrow keys", 75, "W:\\4ed\\code\\custom\\4coder_clipboard.cpp", 39, 371 }, { PROC_LINKS(multi_paste_interactive_quick, 0), false, "multi_paste_interactive_quick", 29, "Paste multiple lines from the clipboard history, controlled by inputing the number of lines to paste", 100, "W:\\4ed\\code\\custom\\4coder_clipboard.cpp", 39, 380 }, +{ PROC_LINKS(music_start, 0), false, "music_start", 11, "Starts the music.", 17, "W:\\4ed\\code\\custom\\4coder_examples.cpp", 38, 267 }, +{ PROC_LINKS(music_stop, 0), false, "music_stop", 10, "Stops the music.", 16, "W:\\4ed\\code\\custom\\4coder_examples.cpp", 38, 285 }, { PROC_LINKS(open_all_code, 0), false, "open_all_code", 13, "Open all code in the current directory. File types are determined by extensions. An extension is considered code based on the extensions specified in 4coder.config.", 164, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 850 }, { PROC_LINKS(open_all_code_recursive, 0), false, "open_all_code_recursive", 23, "Works as open_all_code but also runs in all subdirectories.", 59, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 856 }, { PROC_LINKS(open_file_in_quotes, 0), false, "open_file_in_quotes", 19, "Reads a filename from surrounding '\"' characters and attempts to open the corresponding file.", 94, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1574 }, @@ -584,187 +590,190 @@ static i32 fcoder_metacmd_ID_goto_prev_jump = 61; static i32 fcoder_metacmd_ID_goto_prev_jump_no_skips = 62; static i32 fcoder_metacmd_ID_hide_filebar = 63; static i32 fcoder_metacmd_ID_hide_scrollbar = 64; -static i32 fcoder_metacmd_ID_hms_demo_tutorial = 65; -static i32 fcoder_metacmd_ID_if0_off = 66; -static i32 fcoder_metacmd_ID_if_read_only_goto_position = 67; -static i32 fcoder_metacmd_ID_if_read_only_goto_position_same_panel = 68; -static i32 fcoder_metacmd_ID_increase_face_size = 69; -static i32 fcoder_metacmd_ID_interactive_kill_buffer = 70; -static i32 fcoder_metacmd_ID_interactive_new = 71; -static i32 fcoder_metacmd_ID_interactive_open = 72; -static i32 fcoder_metacmd_ID_interactive_open_or_new = 73; -static i32 fcoder_metacmd_ID_interactive_switch_buffer = 74; -static i32 fcoder_metacmd_ID_jump_to_definition = 75; -static i32 fcoder_metacmd_ID_jump_to_definition_at_cursor = 76; -static i32 fcoder_metacmd_ID_jump_to_last_point = 77; -static i32 fcoder_metacmd_ID_keyboard_macro_finish_recording = 78; -static i32 fcoder_metacmd_ID_keyboard_macro_replay = 79; -static i32 fcoder_metacmd_ID_keyboard_macro_start_recording = 80; -static i32 fcoder_metacmd_ID_kill_buffer = 81; -static i32 fcoder_metacmd_ID_kill_tutorial = 82; -static i32 fcoder_metacmd_ID_left_adjust_view = 83; -static i32 fcoder_metacmd_ID_list_all_functions_all_buffers = 84; -static i32 fcoder_metacmd_ID_list_all_functions_all_buffers_lister = 85; -static i32 fcoder_metacmd_ID_list_all_functions_current_buffer = 86; -static i32 fcoder_metacmd_ID_list_all_functions_current_buffer_lister = 87; -static i32 fcoder_metacmd_ID_list_all_locations = 88; -static i32 fcoder_metacmd_ID_list_all_locations_case_insensitive = 89; -static i32 fcoder_metacmd_ID_list_all_locations_of_identifier = 90; -static i32 fcoder_metacmd_ID_list_all_locations_of_identifier_case_insensitive = 91; -static i32 fcoder_metacmd_ID_list_all_locations_of_selection = 92; -static i32 fcoder_metacmd_ID_list_all_locations_of_selection_case_insensitive = 93; -static i32 fcoder_metacmd_ID_list_all_locations_of_type_definition = 94; -static i32 fcoder_metacmd_ID_list_all_locations_of_type_definition_of_identifier = 95; -static i32 fcoder_metacmd_ID_list_all_substring_locations = 96; -static i32 fcoder_metacmd_ID_list_all_substring_locations_case_insensitive = 97; -static i32 fcoder_metacmd_ID_load_project = 98; -static i32 fcoder_metacmd_ID_load_theme_current_buffer = 99; -static i32 fcoder_metacmd_ID_load_themes_default_folder = 100; -static i32 fcoder_metacmd_ID_load_themes_hot_directory = 101; -static i32 fcoder_metacmd_ID_make_directory_query = 102; -static i32 fcoder_metacmd_ID_miblo_decrement_basic = 103; -static i32 fcoder_metacmd_ID_miblo_decrement_time_stamp = 104; -static i32 fcoder_metacmd_ID_miblo_decrement_time_stamp_minute = 105; -static i32 fcoder_metacmd_ID_miblo_increment_basic = 106; -static i32 fcoder_metacmd_ID_miblo_increment_time_stamp = 107; -static i32 fcoder_metacmd_ID_miblo_increment_time_stamp_minute = 108; -static i32 fcoder_metacmd_ID_mouse_wheel_change_face_size = 109; -static i32 fcoder_metacmd_ID_mouse_wheel_scroll = 110; -static i32 fcoder_metacmd_ID_move_down = 111; -static i32 fcoder_metacmd_ID_move_down_10 = 112; -static i32 fcoder_metacmd_ID_move_down_textual = 113; -static i32 fcoder_metacmd_ID_move_down_to_blank_line = 114; -static i32 fcoder_metacmd_ID_move_down_to_blank_line_end = 115; -static i32 fcoder_metacmd_ID_move_down_to_blank_line_skip_whitespace = 116; -static i32 fcoder_metacmd_ID_move_left = 117; -static i32 fcoder_metacmd_ID_move_left_alpha_numeric_boundary = 118; -static i32 fcoder_metacmd_ID_move_left_alpha_numeric_or_camel_boundary = 119; -static i32 fcoder_metacmd_ID_move_left_token_boundary = 120; -static i32 fcoder_metacmd_ID_move_left_whitespace_boundary = 121; -static i32 fcoder_metacmd_ID_move_left_whitespace_or_token_boundary = 122; -static i32 fcoder_metacmd_ID_move_line_down = 123; -static i32 fcoder_metacmd_ID_move_line_up = 124; -static i32 fcoder_metacmd_ID_move_right = 125; -static i32 fcoder_metacmd_ID_move_right_alpha_numeric_boundary = 126; -static i32 fcoder_metacmd_ID_move_right_alpha_numeric_or_camel_boundary = 127; -static i32 fcoder_metacmd_ID_move_right_token_boundary = 128; -static i32 fcoder_metacmd_ID_move_right_whitespace_boundary = 129; -static i32 fcoder_metacmd_ID_move_right_whitespace_or_token_boundary = 130; -static i32 fcoder_metacmd_ID_move_up = 131; -static i32 fcoder_metacmd_ID_move_up_10 = 132; -static i32 fcoder_metacmd_ID_move_up_to_blank_line = 133; -static i32 fcoder_metacmd_ID_move_up_to_blank_line_end = 134; -static i32 fcoder_metacmd_ID_move_up_to_blank_line_skip_whitespace = 135; -static i32 fcoder_metacmd_ID_multi_paste = 136; -static i32 fcoder_metacmd_ID_multi_paste_interactive = 137; -static i32 fcoder_metacmd_ID_multi_paste_interactive_quick = 138; -static i32 fcoder_metacmd_ID_open_all_code = 139; -static i32 fcoder_metacmd_ID_open_all_code_recursive = 140; -static i32 fcoder_metacmd_ID_open_file_in_quotes = 141; -static i32 fcoder_metacmd_ID_open_in_other = 142; -static i32 fcoder_metacmd_ID_open_long_braces = 143; -static i32 fcoder_metacmd_ID_open_long_braces_break = 144; -static i32 fcoder_metacmd_ID_open_long_braces_semicolon = 145; -static i32 fcoder_metacmd_ID_open_matching_file_cpp = 146; -static i32 fcoder_metacmd_ID_open_panel_hsplit = 147; -static i32 fcoder_metacmd_ID_open_panel_vsplit = 148; -static i32 fcoder_metacmd_ID_page_down = 149; -static i32 fcoder_metacmd_ID_page_up = 150; -static i32 fcoder_metacmd_ID_paste = 151; -static i32 fcoder_metacmd_ID_paste_and_indent = 152; -static i32 fcoder_metacmd_ID_paste_next = 153; -static i32 fcoder_metacmd_ID_paste_next_and_indent = 154; -static i32 fcoder_metacmd_ID_place_in_scope = 155; -static i32 fcoder_metacmd_ID_play_with_a_counter = 156; -static i32 fcoder_metacmd_ID_profile_clear = 157; -static i32 fcoder_metacmd_ID_profile_disable = 158; -static i32 fcoder_metacmd_ID_profile_enable = 159; -static i32 fcoder_metacmd_ID_profile_inspect = 160; -static i32 fcoder_metacmd_ID_project_command_lister = 161; -static i32 fcoder_metacmd_ID_project_fkey_command = 162; -static i32 fcoder_metacmd_ID_project_go_to_root_directory = 163; -static i32 fcoder_metacmd_ID_query_replace = 164; -static i32 fcoder_metacmd_ID_query_replace_identifier = 165; -static i32 fcoder_metacmd_ID_query_replace_selection = 166; -static i32 fcoder_metacmd_ID_quick_swap_buffer = 167; -static i32 fcoder_metacmd_ID_redo = 168; -static i32 fcoder_metacmd_ID_redo_all_buffers = 169; -static i32 fcoder_metacmd_ID_rename_file_query = 170; -static i32 fcoder_metacmd_ID_reopen = 171; -static i32 fcoder_metacmd_ID_replace_in_all_buffers = 172; -static i32 fcoder_metacmd_ID_replace_in_buffer = 173; -static i32 fcoder_metacmd_ID_replace_in_range = 174; -static i32 fcoder_metacmd_ID_reverse_search = 175; -static i32 fcoder_metacmd_ID_reverse_search_identifier = 176; -static i32 fcoder_metacmd_ID_save = 177; -static i32 fcoder_metacmd_ID_save_all_dirty_buffers = 178; -static i32 fcoder_metacmd_ID_save_to_query = 179; -static i32 fcoder_metacmd_ID_search = 180; -static i32 fcoder_metacmd_ID_search_identifier = 181; -static i32 fcoder_metacmd_ID_seek_beginning_of_line = 182; -static i32 fcoder_metacmd_ID_seek_beginning_of_textual_line = 183; -static i32 fcoder_metacmd_ID_seek_end_of_line = 184; -static i32 fcoder_metacmd_ID_seek_end_of_textual_line = 185; -static i32 fcoder_metacmd_ID_select_all = 186; -static i32 fcoder_metacmd_ID_select_next_scope_absolute = 187; -static i32 fcoder_metacmd_ID_select_next_scope_after_current = 188; -static i32 fcoder_metacmd_ID_select_prev_scope_absolute = 189; -static i32 fcoder_metacmd_ID_select_prev_top_most_scope = 190; -static i32 fcoder_metacmd_ID_select_surrounding_scope = 191; -static i32 fcoder_metacmd_ID_select_surrounding_scope_maximal = 192; -static i32 fcoder_metacmd_ID_set_eol_mode_from_contents = 193; -static i32 fcoder_metacmd_ID_set_eol_mode_to_binary = 194; -static i32 fcoder_metacmd_ID_set_eol_mode_to_crlf = 195; -static i32 fcoder_metacmd_ID_set_eol_mode_to_lf = 196; -static i32 fcoder_metacmd_ID_set_face_size = 197; -static i32 fcoder_metacmd_ID_set_face_size_this_buffer = 198; -static i32 fcoder_metacmd_ID_set_mark = 199; -static i32 fcoder_metacmd_ID_set_mode_to_notepad_like = 200; -static i32 fcoder_metacmd_ID_set_mode_to_original = 201; -static i32 fcoder_metacmd_ID_setup_build_bat = 202; -static i32 fcoder_metacmd_ID_setup_build_bat_and_sh = 203; -static i32 fcoder_metacmd_ID_setup_build_sh = 204; -static i32 fcoder_metacmd_ID_setup_new_project = 205; -static i32 fcoder_metacmd_ID_show_filebar = 206; -static i32 fcoder_metacmd_ID_show_scrollbar = 207; -static i32 fcoder_metacmd_ID_show_the_log_graph = 208; -static i32 fcoder_metacmd_ID_snipe_backward_whitespace_or_token_boundary = 209; -static i32 fcoder_metacmd_ID_snipe_forward_whitespace_or_token_boundary = 210; -static i32 fcoder_metacmd_ID_snippet_lister = 211; -static i32 fcoder_metacmd_ID_string_repeat = 212; -static i32 fcoder_metacmd_ID_suppress_mouse = 213; -static i32 fcoder_metacmd_ID_swap_panels = 214; -static i32 fcoder_metacmd_ID_test_the_new_api = 215; -static i32 fcoder_metacmd_ID_theme_lister = 216; -static i32 fcoder_metacmd_ID_to_lowercase = 217; -static i32 fcoder_metacmd_ID_to_uppercase = 218; -static i32 fcoder_metacmd_ID_toggle_filebar = 219; -static i32 fcoder_metacmd_ID_toggle_fps_meter = 220; -static i32 fcoder_metacmd_ID_toggle_fullscreen = 221; -static i32 fcoder_metacmd_ID_toggle_highlight_enclosing_scopes = 222; -static i32 fcoder_metacmd_ID_toggle_highlight_line_at_cursor = 223; -static i32 fcoder_metacmd_ID_toggle_line_numbers = 224; -static i32 fcoder_metacmd_ID_toggle_line_wrap = 225; -static i32 fcoder_metacmd_ID_toggle_mouse = 226; -static i32 fcoder_metacmd_ID_toggle_paren_matching_helper = 227; -static i32 fcoder_metacmd_ID_toggle_show_whitespace = 228; -static i32 fcoder_metacmd_ID_toggle_virtual_whitespace = 229; -static i32 fcoder_metacmd_ID_tutorial_maximize = 230; -static i32 fcoder_metacmd_ID_tutorial_minimize = 231; -static i32 fcoder_metacmd_ID_uncomment_line = 232; -static i32 fcoder_metacmd_ID_undo = 233; -static i32 fcoder_metacmd_ID_undo_all_buffers = 234; -static i32 fcoder_metacmd_ID_view_buffer_other_panel = 235; -static i32 fcoder_metacmd_ID_view_jump_list_with_lister = 236; -static i32 fcoder_metacmd_ID_word_complete = 237; -static i32 fcoder_metacmd_ID_word_complete_drop_down = 238; -static i32 fcoder_metacmd_ID_write_block = 239; -static i32 fcoder_metacmd_ID_write_hack = 240; -static i32 fcoder_metacmd_ID_write_note = 241; -static i32 fcoder_metacmd_ID_write_space = 242; -static i32 fcoder_metacmd_ID_write_text_and_auto_indent = 243; -static i32 fcoder_metacmd_ID_write_text_input = 244; -static i32 fcoder_metacmd_ID_write_todo = 245; -static i32 fcoder_metacmd_ID_write_underscore = 246; -static i32 fcoder_metacmd_ID_write_zero_struct = 247; +static i32 fcoder_metacmd_ID_hit_sfx = 65; +static i32 fcoder_metacmd_ID_hms_demo_tutorial = 66; +static i32 fcoder_metacmd_ID_if0_off = 67; +static i32 fcoder_metacmd_ID_if_read_only_goto_position = 68; +static i32 fcoder_metacmd_ID_if_read_only_goto_position_same_panel = 69; +static i32 fcoder_metacmd_ID_increase_face_size = 70; +static i32 fcoder_metacmd_ID_interactive_kill_buffer = 71; +static i32 fcoder_metacmd_ID_interactive_new = 72; +static i32 fcoder_metacmd_ID_interactive_open = 73; +static i32 fcoder_metacmd_ID_interactive_open_or_new = 74; +static i32 fcoder_metacmd_ID_interactive_switch_buffer = 75; +static i32 fcoder_metacmd_ID_jump_to_definition = 76; +static i32 fcoder_metacmd_ID_jump_to_definition_at_cursor = 77; +static i32 fcoder_metacmd_ID_jump_to_last_point = 78; +static i32 fcoder_metacmd_ID_keyboard_macro_finish_recording = 79; +static i32 fcoder_metacmd_ID_keyboard_macro_replay = 80; +static i32 fcoder_metacmd_ID_keyboard_macro_start_recording = 81; +static i32 fcoder_metacmd_ID_kill_buffer = 82; +static i32 fcoder_metacmd_ID_kill_tutorial = 83; +static i32 fcoder_metacmd_ID_left_adjust_view = 84; +static i32 fcoder_metacmd_ID_list_all_functions_all_buffers = 85; +static i32 fcoder_metacmd_ID_list_all_functions_all_buffers_lister = 86; +static i32 fcoder_metacmd_ID_list_all_functions_current_buffer = 87; +static i32 fcoder_metacmd_ID_list_all_functions_current_buffer_lister = 88; +static i32 fcoder_metacmd_ID_list_all_locations = 89; +static i32 fcoder_metacmd_ID_list_all_locations_case_insensitive = 90; +static i32 fcoder_metacmd_ID_list_all_locations_of_identifier = 91; +static i32 fcoder_metacmd_ID_list_all_locations_of_identifier_case_insensitive = 92; +static i32 fcoder_metacmd_ID_list_all_locations_of_selection = 93; +static i32 fcoder_metacmd_ID_list_all_locations_of_selection_case_insensitive = 94; +static i32 fcoder_metacmd_ID_list_all_locations_of_type_definition = 95; +static i32 fcoder_metacmd_ID_list_all_locations_of_type_definition_of_identifier = 96; +static i32 fcoder_metacmd_ID_list_all_substring_locations = 97; +static i32 fcoder_metacmd_ID_list_all_substring_locations_case_insensitive = 98; +static i32 fcoder_metacmd_ID_load_project = 99; +static i32 fcoder_metacmd_ID_load_theme_current_buffer = 100; +static i32 fcoder_metacmd_ID_load_themes_default_folder = 101; +static i32 fcoder_metacmd_ID_load_themes_hot_directory = 102; +static i32 fcoder_metacmd_ID_make_directory_query = 103; +static i32 fcoder_metacmd_ID_miblo_decrement_basic = 104; +static i32 fcoder_metacmd_ID_miblo_decrement_time_stamp = 105; +static i32 fcoder_metacmd_ID_miblo_decrement_time_stamp_minute = 106; +static i32 fcoder_metacmd_ID_miblo_increment_basic = 107; +static i32 fcoder_metacmd_ID_miblo_increment_time_stamp = 108; +static i32 fcoder_metacmd_ID_miblo_increment_time_stamp_minute = 109; +static i32 fcoder_metacmd_ID_mouse_wheel_change_face_size = 110; +static i32 fcoder_metacmd_ID_mouse_wheel_scroll = 111; +static i32 fcoder_metacmd_ID_move_down = 112; +static i32 fcoder_metacmd_ID_move_down_10 = 113; +static i32 fcoder_metacmd_ID_move_down_textual = 114; +static i32 fcoder_metacmd_ID_move_down_to_blank_line = 115; +static i32 fcoder_metacmd_ID_move_down_to_blank_line_end = 116; +static i32 fcoder_metacmd_ID_move_down_to_blank_line_skip_whitespace = 117; +static i32 fcoder_metacmd_ID_move_left = 118; +static i32 fcoder_metacmd_ID_move_left_alpha_numeric_boundary = 119; +static i32 fcoder_metacmd_ID_move_left_alpha_numeric_or_camel_boundary = 120; +static i32 fcoder_metacmd_ID_move_left_token_boundary = 121; +static i32 fcoder_metacmd_ID_move_left_whitespace_boundary = 122; +static i32 fcoder_metacmd_ID_move_left_whitespace_or_token_boundary = 123; +static i32 fcoder_metacmd_ID_move_line_down = 124; +static i32 fcoder_metacmd_ID_move_line_up = 125; +static i32 fcoder_metacmd_ID_move_right = 126; +static i32 fcoder_metacmd_ID_move_right_alpha_numeric_boundary = 127; +static i32 fcoder_metacmd_ID_move_right_alpha_numeric_or_camel_boundary = 128; +static i32 fcoder_metacmd_ID_move_right_token_boundary = 129; +static i32 fcoder_metacmd_ID_move_right_whitespace_boundary = 130; +static i32 fcoder_metacmd_ID_move_right_whitespace_or_token_boundary = 131; +static i32 fcoder_metacmd_ID_move_up = 132; +static i32 fcoder_metacmd_ID_move_up_10 = 133; +static i32 fcoder_metacmd_ID_move_up_to_blank_line = 134; +static i32 fcoder_metacmd_ID_move_up_to_blank_line_end = 135; +static i32 fcoder_metacmd_ID_move_up_to_blank_line_skip_whitespace = 136; +static i32 fcoder_metacmd_ID_multi_paste = 137; +static i32 fcoder_metacmd_ID_multi_paste_interactive = 138; +static i32 fcoder_metacmd_ID_multi_paste_interactive_quick = 139; +static i32 fcoder_metacmd_ID_music_start = 140; +static i32 fcoder_metacmd_ID_music_stop = 141; +static i32 fcoder_metacmd_ID_open_all_code = 142; +static i32 fcoder_metacmd_ID_open_all_code_recursive = 143; +static i32 fcoder_metacmd_ID_open_file_in_quotes = 144; +static i32 fcoder_metacmd_ID_open_in_other = 145; +static i32 fcoder_metacmd_ID_open_long_braces = 146; +static i32 fcoder_metacmd_ID_open_long_braces_break = 147; +static i32 fcoder_metacmd_ID_open_long_braces_semicolon = 148; +static i32 fcoder_metacmd_ID_open_matching_file_cpp = 149; +static i32 fcoder_metacmd_ID_open_panel_hsplit = 150; +static i32 fcoder_metacmd_ID_open_panel_vsplit = 151; +static i32 fcoder_metacmd_ID_page_down = 152; +static i32 fcoder_metacmd_ID_page_up = 153; +static i32 fcoder_metacmd_ID_paste = 154; +static i32 fcoder_metacmd_ID_paste_and_indent = 155; +static i32 fcoder_metacmd_ID_paste_next = 156; +static i32 fcoder_metacmd_ID_paste_next_and_indent = 157; +static i32 fcoder_metacmd_ID_place_in_scope = 158; +static i32 fcoder_metacmd_ID_play_with_a_counter = 159; +static i32 fcoder_metacmd_ID_profile_clear = 160; +static i32 fcoder_metacmd_ID_profile_disable = 161; +static i32 fcoder_metacmd_ID_profile_enable = 162; +static i32 fcoder_metacmd_ID_profile_inspect = 163; +static i32 fcoder_metacmd_ID_project_command_lister = 164; +static i32 fcoder_metacmd_ID_project_fkey_command = 165; +static i32 fcoder_metacmd_ID_project_go_to_root_directory = 166; +static i32 fcoder_metacmd_ID_query_replace = 167; +static i32 fcoder_metacmd_ID_query_replace_identifier = 168; +static i32 fcoder_metacmd_ID_query_replace_selection = 169; +static i32 fcoder_metacmd_ID_quick_swap_buffer = 170; +static i32 fcoder_metacmd_ID_redo = 171; +static i32 fcoder_metacmd_ID_redo_all_buffers = 172; +static i32 fcoder_metacmd_ID_rename_file_query = 173; +static i32 fcoder_metacmd_ID_reopen = 174; +static i32 fcoder_metacmd_ID_replace_in_all_buffers = 175; +static i32 fcoder_metacmd_ID_replace_in_buffer = 176; +static i32 fcoder_metacmd_ID_replace_in_range = 177; +static i32 fcoder_metacmd_ID_reverse_search = 178; +static i32 fcoder_metacmd_ID_reverse_search_identifier = 179; +static i32 fcoder_metacmd_ID_save = 180; +static i32 fcoder_metacmd_ID_save_all_dirty_buffers = 181; +static i32 fcoder_metacmd_ID_save_to_query = 182; +static i32 fcoder_metacmd_ID_search = 183; +static i32 fcoder_metacmd_ID_search_identifier = 184; +static i32 fcoder_metacmd_ID_seek_beginning_of_line = 185; +static i32 fcoder_metacmd_ID_seek_beginning_of_textual_line = 186; +static i32 fcoder_metacmd_ID_seek_end_of_line = 187; +static i32 fcoder_metacmd_ID_seek_end_of_textual_line = 188; +static i32 fcoder_metacmd_ID_select_all = 189; +static i32 fcoder_metacmd_ID_select_next_scope_absolute = 190; +static i32 fcoder_metacmd_ID_select_next_scope_after_current = 191; +static i32 fcoder_metacmd_ID_select_prev_scope_absolute = 192; +static i32 fcoder_metacmd_ID_select_prev_top_most_scope = 193; +static i32 fcoder_metacmd_ID_select_surrounding_scope = 194; +static i32 fcoder_metacmd_ID_select_surrounding_scope_maximal = 195; +static i32 fcoder_metacmd_ID_set_eol_mode_from_contents = 196; +static i32 fcoder_metacmd_ID_set_eol_mode_to_binary = 197; +static i32 fcoder_metacmd_ID_set_eol_mode_to_crlf = 198; +static i32 fcoder_metacmd_ID_set_eol_mode_to_lf = 199; +static i32 fcoder_metacmd_ID_set_face_size = 200; +static i32 fcoder_metacmd_ID_set_face_size_this_buffer = 201; +static i32 fcoder_metacmd_ID_set_mark = 202; +static i32 fcoder_metacmd_ID_set_mode_to_notepad_like = 203; +static i32 fcoder_metacmd_ID_set_mode_to_original = 204; +static i32 fcoder_metacmd_ID_setup_build_bat = 205; +static i32 fcoder_metacmd_ID_setup_build_bat_and_sh = 206; +static i32 fcoder_metacmd_ID_setup_build_sh = 207; +static i32 fcoder_metacmd_ID_setup_new_project = 208; +static i32 fcoder_metacmd_ID_show_filebar = 209; +static i32 fcoder_metacmd_ID_show_scrollbar = 210; +static i32 fcoder_metacmd_ID_show_the_log_graph = 211; +static i32 fcoder_metacmd_ID_snipe_backward_whitespace_or_token_boundary = 212; +static i32 fcoder_metacmd_ID_snipe_forward_whitespace_or_token_boundary = 213; +static i32 fcoder_metacmd_ID_snippet_lister = 214; +static i32 fcoder_metacmd_ID_string_repeat = 215; +static i32 fcoder_metacmd_ID_suppress_mouse = 216; +static i32 fcoder_metacmd_ID_swap_panels = 217; +static i32 fcoder_metacmd_ID_test_the_new_api = 218; +static i32 fcoder_metacmd_ID_theme_lister = 219; +static i32 fcoder_metacmd_ID_to_lowercase = 220; +static i32 fcoder_metacmd_ID_to_uppercase = 221; +static i32 fcoder_metacmd_ID_toggle_filebar = 222; +static i32 fcoder_metacmd_ID_toggle_fps_meter = 223; +static i32 fcoder_metacmd_ID_toggle_fullscreen = 224; +static i32 fcoder_metacmd_ID_toggle_highlight_enclosing_scopes = 225; +static i32 fcoder_metacmd_ID_toggle_highlight_line_at_cursor = 226; +static i32 fcoder_metacmd_ID_toggle_line_numbers = 227; +static i32 fcoder_metacmd_ID_toggle_line_wrap = 228; +static i32 fcoder_metacmd_ID_toggle_mouse = 229; +static i32 fcoder_metacmd_ID_toggle_paren_matching_helper = 230; +static i32 fcoder_metacmd_ID_toggle_show_whitespace = 231; +static i32 fcoder_metacmd_ID_toggle_virtual_whitespace = 232; +static i32 fcoder_metacmd_ID_tutorial_maximize = 233; +static i32 fcoder_metacmd_ID_tutorial_minimize = 234; +static i32 fcoder_metacmd_ID_uncomment_line = 235; +static i32 fcoder_metacmd_ID_undo = 236; +static i32 fcoder_metacmd_ID_undo_all_buffers = 237; +static i32 fcoder_metacmd_ID_view_buffer_other_panel = 238; +static i32 fcoder_metacmd_ID_view_jump_list_with_lister = 239; +static i32 fcoder_metacmd_ID_word_complete = 240; +static i32 fcoder_metacmd_ID_word_complete_drop_down = 241; +static i32 fcoder_metacmd_ID_write_block = 242; +static i32 fcoder_metacmd_ID_write_hack = 243; +static i32 fcoder_metacmd_ID_write_note = 244; +static i32 fcoder_metacmd_ID_write_space = 245; +static i32 fcoder_metacmd_ID_write_text_and_auto_indent = 246; +static i32 fcoder_metacmd_ID_write_text_input = 247; +static i32 fcoder_metacmd_ID_write_todo = 248; +static i32 fcoder_metacmd_ID_write_underscore = 249; +static i32 fcoder_metacmd_ID_write_zero_struct = 250; #endif diff --git a/custom/generated/system_api.cpp b/custom/generated/system_api.cpp index 724f0b82..e28dee6b 100644 --- a/custom/generated/system_api.cpp +++ b/custom/generated/system_api.cpp @@ -55,6 +55,8 @@ vtable->is_fullscreen = system_is_fullscreen; vtable->get_keyboard_modifiers = system_get_keyboard_modifiers; vtable->set_key_mode = system_set_key_mode; vtable->play_clip = system_play_clip; +vtable->audio_is_playing = system_audio_is_playing; +vtable->audio_stop = system_audio_stop; } #if defined(DYNAMIC_LINK_API) function void @@ -114,6 +116,8 @@ system_is_fullscreen = vtable->is_fullscreen; system_get_keyboard_modifiers = vtable->get_keyboard_modifiers; system_set_key_mode = vtable->set_key_mode; system_play_clip = vtable->play_clip; +system_audio_is_playing = vtable->audio_is_playing; +system_audio_stop = vtable->audio_stop; } #undef DYNAMIC_LINK_API #endif diff --git a/custom/generated/system_api.h b/custom/generated/system_api.h index 5d39f00f..ce1d2a12 100644 --- a/custom/generated/system_api.h +++ b/custom/generated/system_api.h @@ -53,6 +53,8 @@ #define system_get_keyboard_modifiers_sig() Input_Modifier_Set system_get_keyboard_modifiers(Arena* arena) #define system_set_key_mode_sig() void system_set_key_mode(Key_Mode mode) #define system_play_clip_sig() void system_play_clip(Audio_Clip clip, Audio_Control* control) +#define system_audio_is_playing_sig() b32 system_audio_is_playing(Audio_Control* control) +#define system_audio_stop_sig() void system_audio_stop(Audio_Control* control) typedef String_Const_u8 system_get_path_type(Arena* arena, System_Path_Code path_code); typedef String_Const_u8 system_get_canonical_type(Arena* arena, String_Const_u8 name); typedef File_List system_get_file_list_type(Arena* arena, String_Const_u8 directory); @@ -108,6 +110,8 @@ typedef b32 system_is_fullscreen_type(void); typedef Input_Modifier_Set system_get_keyboard_modifiers_type(Arena* arena); typedef void system_set_key_mode_type(Key_Mode mode); typedef void system_play_clip_type(Audio_Clip clip, Audio_Control* control); +typedef b32 system_audio_is_playing_type(Audio_Control* control); +typedef void system_audio_stop_type(Audio_Control* control); struct API_VTable_system{ system_get_path_type *get_path; system_get_canonical_type *get_canonical; @@ -164,6 +168,8 @@ system_is_fullscreen_type *is_fullscreen; system_get_keyboard_modifiers_type *get_keyboard_modifiers; system_set_key_mode_type *set_key_mode; system_play_clip_type *play_clip; +system_audio_is_playing_type *audio_is_playing; +system_audio_stop_type *audio_stop; }; #if defined(STATIC_LINK_API) internal String_Const_u8 system_get_path(Arena* arena, System_Path_Code path_code); @@ -221,6 +227,8 @@ internal b32 system_is_fullscreen(void); internal Input_Modifier_Set system_get_keyboard_modifiers(Arena* arena); internal void system_set_key_mode(Key_Mode mode); internal void system_play_clip(Audio_Clip clip, Audio_Control* control); +internal b32 system_audio_is_playing(Audio_Control* control); +internal void system_audio_stop(Audio_Control* control); #undef STATIC_LINK_API #elif defined(DYNAMIC_LINK_API) global system_get_path_type *system_get_path = 0; @@ -278,5 +286,7 @@ global system_is_fullscreen_type *system_is_fullscreen = 0; global system_get_keyboard_modifiers_type *system_get_keyboard_modifiers = 0; global system_set_key_mode_type *system_set_key_mode = 0; global system_play_clip_type *system_play_clip = 0; +global system_audio_is_playing_type *system_audio_is_playing = 0; +global system_audio_stop_type *system_audio_stop = 0; #undef DYNAMIC_LINK_API #endif diff --git a/custom/generated/system_api_constructor.cpp b/custom/generated/system_api_constructor.cpp index 152a3c58..80290dce 100644 --- a/custom/generated/system_api_constructor.cpp +++ b/custom/generated/system_api_constructor.cpp @@ -250,5 +250,13 @@ API_Call *call = api_call_with_location(arena, result, string_u8_litexpr("play_c api_param(arena, call, "Audio_Clip", "clip"); api_param(arena, call, "Audio_Control*", "control"); } +{ +API_Call *call = api_call_with_location(arena, result, string_u8_litexpr("audio_is_playing"), string_u8_litexpr("b32"), string_u8_litexpr("")); +api_param(arena, call, "Audio_Control*", "control"); +} +{ +API_Call *call = api_call_with_location(arena, result, string_u8_litexpr("audio_stop"), string_u8_litexpr("void"), string_u8_litexpr("")); +api_param(arena, call, "Audio_Control*", "control"); +} return(result); } diff --git a/custom/generated/system_api_master_list.h b/custom/generated/system_api_master_list.h index 3ed646ff..11839fd4 100644 --- a/custom/generated/system_api_master_list.h +++ b/custom/generated/system_api_master_list.h @@ -53,3 +53,5 @@ api(system) function b32 is_fullscreen(void); api(system) function Input_Modifier_Set get_keyboard_modifiers(Arena* arena); api(system) function void set_key_mode(Key_Mode mode); api(system) function void play_clip(Audio_Clip clip, Audio_Control* control); +api(system) function b32 audio_is_playing(Audio_Control* control); +api(system) function void audio_stop(Audio_Control* control); diff --git a/platform_win32/win32_4ed.cpp b/platform_win32/win32_4ed.cpp index 2b1f7774..8ebc8d5e 100644 --- a/platform_win32/win32_4ed.cpp +++ b/platform_win32/win32_4ed.cpp @@ -359,14 +359,6 @@ system_set_key_mode_sig(){ win32vars.key_mode = mode; } -//////////////////////////////// -// NOTE(allen): Audio - -internal -system_play_clip_sig(){ - win32_play_clip(clip, control); -} - //////////////////////////////// // NOTE(allen): Clipboard diff --git a/platform_win32/win32_audio.cpp b/platform_win32/win32_audio.cpp index 9d1e3ca2..a9861b3d 100644 --- a/platform_win32/win32_audio.cpp +++ b/platform_win32/win32_audio.cpp @@ -1,5 +1,5 @@ //////////////////////////////// -// NOTE(allen): Win32 Audio Functions +// NOTE(allen): Win32 Audio Helpers function u32 AtomicAddU32AndReturnOriginal(u32 volatile *Value, u32 Addend) @@ -22,8 +22,11 @@ win32_end_ticket_mutex(Audio_System *Crunky) AtomicAddU32AndReturnOriginal(&Crunky->serving, 1); } -function void -win32_play_clip(Audio_Clip clip, Audio_Control *control){ +//////////////////////////////// +// NOTE(allen): Win32 Audio System API + +internal +system_play_clip_sig(){ clip.control = control; Audio_System *Crunky = &win32vars.audio_system; win32_begin_ticket_mutex(Crunky); @@ -34,60 +37,127 @@ win32_play_clip(Audio_Clip clip, Audio_Control *control){ win32_end_ticket_mutex(Crunky); } -function void -win32_mix_audio(Audio_System *Crunky, u32 SampleCount, i16 *Dest){ - // NOTE(casey): Move pending sounds into the playing list +internal +system_audio_is_playing_sig(){ + Audio_System *Crunky = (Audio_System *)&win32vars.audio_system; + b32 result = (Crunky->generation - control->generation < 2); + return(result); +} + +internal +system_audio_stop_sig(){ + Audio_System *Crunky = (Audio_System *)&win32vars.audio_system; win32_begin_ticket_mutex(Crunky); - ++Crunky->generation; - for(u32 PendIndex = 0; - PendIndex < Crunky->pending_clip_count; - ++PendIndex) - { - u32 DestIndex = Crunky->next_playing_clip_index++ % ArrayCount(Crunky->playing_clips); - Crunky->playing_clips[DestIndex] = Crunky->pending_clips[PendIndex]; + + Audio_Clip *clip = Crunky->playing_clips; + for(u32 i = 0; + i < ArrayCount(Crunky->playing_clips); + i += 1, clip += 1){ + if (clip->control == control){ + clip->at_sample_index = clip->sample_count; + } + } + control->loop = false; + + win32_end_ticket_mutex(Crunky); +} + +//////////////////////////////// +// NOTE(allen): Win32 Audio Loop + +function void +win32_mix_audio(Audio_System *Crunky, u32 SampleCount, i16 *Dest, void *mix_buffer_memory){ + // NOTE(casey): Clear the output buffer + u32 MixBufferSize = SampleCount*2*sizeof(f32); + f32 *MixBuffer = (f32 *)mix_buffer_memory; + memset(MixBuffer, 0, MixBufferSize); + + win32_begin_ticket_mutex(Crunky); + // NOTE(casey): Move pending sounds into the playing list + { + Crunky->generation += 1; + u32 PendIndex = 0; + Audio_Clip *clip = Crunky->playing_clips; + for(u32 DestIndex = 0; + (DestIndex < ArrayCount(Crunky->playing_clips)) && (PendIndex < Crunky->pending_clip_count); + DestIndex += 1, clip += 1) + { + if (clip->at_sample_index == clip->sample_count) + { + Audio_Control *control = clip->control; + if (control == 0 || !control->loop){ + *clip = Crunky->pending_clips[PendIndex++]; + } + } + } + Crunky->pending_clip_count = 0; } - Crunky->pending_clip_count = 0; win32_end_ticket_mutex(Crunky); - memset(Dest, 0, SampleCount*4); - for(u32 SoundIndex = 0; - SoundIndex < ArrayCount(Crunky->playing_clips); - ++SoundIndex) + // NOTE(casey): Mix all sounds into the output buffer { - Audio_Clip Sound = Crunky->playing_clips[SoundIndex]; - u32 SamplesToMix = Min((Sound.sample_count - Sound.at_sample_index), SampleCount); - Crunky->playing_clips[SoundIndex].at_sample_index += SamplesToMix; - - i32 LeftVol = AUDIO_PRODUCER_KNOB_ONE; - i32 RightVol = AUDIO_PRODUCER_KNOB_ONE; - if(SamplesToMix && Sound.control) - { - LeftVol = Sound.control->left_volume_knob; - RightVol = Sound.control->right_volume_knob; - Sound.control->generation = Crunky->generation; - Sound.control->last_played_sample_index = Crunky->playing_clips[SoundIndex].at_sample_index; - } - + Audio_Clip *clip = Crunky->playing_clips; + for(u32 SoundIndex = 0; + SoundIndex < ArrayCount(Crunky->playing_clips); + SoundIndex += 1, clip += 1) + { + Audio_Control *control = clip->control; + if (control != 0 && control->loop && clip->at_sample_index == clip->sample_count){ + clip->at_sample_index = 0; + } + + // NOTE(casey): Determine how many samples are left to play in this + // sound (possible none) + u32 SamplesToMix = Min((clip->sample_count - clip->at_sample_index), SampleCount); + clip->at_sample_index += SamplesToMix; + + // NOTE(casey): Load the volume out of the control if there is one, + // and if there is, update the generation and sample index so + // external controllers can take action + f32 LeftVol = clip->channel_volume[0]; + f32 RightVol = clip->channel_volume[1]; + if(SamplesToMix && control != 0) + { + LeftVol *= control->channel_volume[0]; + RightVol *= control->channel_volume[1]; + control->generation = Crunky->generation; + control->last_played_sample_index = clip->at_sample_index; + } + + // NOTE(casey): Mix samples + for(u32 SampleIndex = 0; + SampleIndex < SamplesToMix; + ++SampleIndex) + { + u32 src_index = 2*(clip->at_sample_index + SampleIndex); + f32 Left = LeftVol*(f32)clip->samples[src_index + 0]; + f32 Right = RightVol*(f32)clip->samples[src_index + 1]; + + u32 dst_index = 2*SampleIndex; + MixBuffer[dst_index + 0] += Left; + MixBuffer[dst_index + 1] += Right; + } + } for(u32 SampleIndex = 0; - SampleIndex < SamplesToMix; + SampleIndex < SampleCount; ++SampleIndex) { - u32 src_base_indx = 2*(Sound.at_sample_index + SampleIndex); - u32 dst_base_indx = 2*SampleIndex; - Dest[dst_base_indx + 0] += (i16)(LeftVol*(i32)Sound.samples[src_base_indx + 0]/AUDIO_PRODUCER_KNOB_ONE); - Dest[dst_base_indx + 1] += (i16)(RightVol*(i32)Sound.samples[src_base_indx + 1]/AUDIO_PRODUCER_KNOB_ONE); + f32 Left = MixBuffer[2*SampleIndex + 0]; + f32 Right = MixBuffer[2*SampleIndex + 1]; + + Dest[2*SampleIndex + 0] = (i16)Left; + Dest[2*SampleIndex + 1] = (i16)Right; } } } function b32 -win32_submit_audio(Audio_System *Crunky, HWAVEOUT WaveOut, WAVEHDR *Header){ +win32_submit_audio(Audio_System *Crunky, HWAVEOUT WaveOut, WAVEHDR *Header, u32 SampleCount, void *mix_buffer){ b32 Result = false; - u32 SampleCount = Header->dwBufferLength/4; i16 *Samples = (i16 *)Header->lpData; - win32_mix_audio(Crunky, SampleCount, Samples); + win32_mix_audio(Crunky, SampleCount, Samples, mix_buffer); DWORD Error = waveOutPrepareHeader(WaveOut, Header, sizeof(*Header)); if(Error == MMSYSERR_NOERROR) @@ -120,7 +190,8 @@ win32_audio_loop(void *Passthrough){ u32 BufferSize = SamplesPerBuffer*BytesPerSample; u32 HeaderSize = sizeof(WAVEHDR); u32 TotalBufferSize = (BufferSize+HeaderSize); - u32 TotalAudioMemorySize = BufferCount*TotalBufferSize; + u32 MixBufferSize = (SamplesPerBuffer*ChannelCount*sizeof(f32)); + u32 TotalAudioMemorySize = BufferCount*TotalBufferSize + MixBufferSize; // // NOTE(casey): Initialize audio out @@ -135,24 +206,28 @@ win32_audio_loop(void *Passthrough){ Format.nBlockAlign = (Format.nChannels*Format.wBitsPerSample)/8; Format.nAvgBytesPerSec = Format.nBlockAlign * Format.nSamplesPerSec; + void *MixBuffer = 0; + void *AudioBufferMemory = 0; if(waveOutOpen(&WaveOut, WAVE_MAPPER, &Format, GetCurrentThreadId(), 0, CALLBACK_THREAD) == MMSYSERR_NOERROR) { - void *AudioBufferMemory = VirtualAlloc(0, TotalAudioMemorySize, MEM_COMMIT, PAGE_READWRITE); + AudioBufferMemory = VirtualAlloc(0, TotalAudioMemorySize, MEM_COMMIT, PAGE_READWRITE); if(AudioBufferMemory) { u8 *At = (u8 *)AudioBufferMemory; + MixBuffer = At; + At += MixBufferSize; + for(u32 BufferIndex = 0; BufferIndex < BufferCount; ++BufferIndex) { WAVEHDR *Header = (WAVEHDR *)At; - At += sizeof(WAVEHDR); - Header->lpData = (char *)At; - Header->dwBufferLength = TotalBufferSize; + Header->lpData = (char *)(Header + 1); + Header->dwBufferLength = BufferSize; At += TotalBufferSize; - win32_submit_audio(Crunky, WaveOut, Header); + win32_submit_audio(Crunky, WaveOut, Header, SamplesPerBuffer, MixBuffer); } } else @@ -168,7 +243,8 @@ win32_audio_loop(void *Passthrough){ // // NOTE(casey): Serve audio forever (until we are told to stop) // - // SetTimer(0, 0, 100, 0); + + SetTimer(0, 0, 100, 0); while(!Crunky->quit) { MSG Message = {}; @@ -183,10 +259,20 @@ win32_audio_loop(void *Passthrough){ waveOutUnprepareHeader(WaveOut, Header, sizeof(*Header)); - win32_submit_audio(Crunky, WaveOut, Header); + win32_submit_audio(Crunky, WaveOut, Header, SamplesPerBuffer, MixBuffer); } } + if(WaveOut) + { + waveOutClose(WaveOut); + } + + if(AudioBufferMemory) + { + VirtualFree(AudioBufferMemory, 0, MEM_RELEASE); + } + return(0); } From 0eecb215efe4d858c4a48b4c54389c6f7a43b6c0 Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Mon, 23 Nov 2020 19:32:35 -0800 Subject: [PATCH 7/9] Cleanup audio system; put mixer in custom layer; hooks in win32 layer --- 4ed_system_api.cpp | 15 +- custom/4coder_audio.cpp | 165 +++++++++++++++- custom/4coder_audio.h | 46 ++++- custom/4coder_default_hooks.cpp | 4 +- custom/4coder_examples.cpp | 64 +----- custom/4coder_types.h | 36 +--- custom/generated/command_metadata.h | 81 ++++---- custom/generated/system_api.cpp | 10 +- custom/generated/system_api.h | 25 +-- custom/generated/system_api_constructor.cpp | 14 +- custom/generated/system_api_master_list.h | 5 +- platform_win32/win32_4ed.cpp | 7 +- platform_win32/win32_audio.cpp | 208 +++++++------------- 13 files changed, 363 insertions(+), 317 deletions(-) diff --git a/4ed_system_api.cpp b/4ed_system_api.cpp index 198d6913..60c07f8a 100644 --- a/4ed_system_api.cpp +++ b/4ed_system_api.cpp @@ -304,19 +304,14 @@ define_api(Arena *arena){ } { - API_Call *call = api_call(arena, api, "play_clip", "void"); - api_param(arena, call, "Audio_Clip", "clip"); - api_param(arena, call, "Audio_Control*", "control"); + API_Call *call = api_call(arena, api, "set_source_mixer", "void"); + api_param(arena, call, "void*", "ctx"); + api_param(arena, call, "Audio_Mix_Sources_Function*", "mix_func"); } { - API_Call *call = api_call(arena, api, "audio_is_playing", "b32"); - api_param(arena, call, "Audio_Control*", "control"); - } - - { - API_Call *call = api_call(arena, api, "audio_stop", "void"); - api_param(arena, call, "Audio_Control*", "control"); + API_Call *call = api_call(arena, api, "set_destination_mixer", "void"); + api_param(arena, call, "Audio_Mix_Destination_Function*", "mix_func"); } return(api); diff --git a/custom/4coder_audio.cpp b/custom/4coder_audio.cpp index a12173f6..22b26a3f 100644 --- a/custom/4coder_audio.cpp +++ b/custom/4coder_audio.cpp @@ -1,5 +1,168 @@ //////////////////////////////// -// NOTE(allen): Load Clip +// NOTE(allen): Default Mixer Helpers + +// TODO(allen): intrinsics wrappers +#include + +function u32 +AtomicAddU32AndReturnOriginal(u32 volatile *Value, u32 Addend) +{ + // NOTE(casey): Returns the original value _prior_ to adding + u32 Result = _InterlockedExchangeAdd((long volatile*)Value, (long)Addend); + return(Result); +} + +function void +def_audio_begin_ticket_mutex(Audio_System *Crunky) +{ + u32 Ticket = AtomicAddU32AndReturnOriginal(&Crunky->ticket, 1); + while(Ticket != Crunky->serving) {_mm_pause();} +} + +function void +def_audio_end_ticket_mutex(Audio_System *Crunky) +{ + AtomicAddU32AndReturnOriginal(&Crunky->serving, 1); +} + + +//////////////////////////////// +// NOTE(allen): Default Mixer + +global Audio_System def_audio_system = {}; + +function void +def_audio_init(void){ + block_zero_struct(&def_audio_system); + system_set_source_mixer(&def_audio_system, def_audio_mix_sources); + system_set_destination_mixer(def_audio_mix_destination); +} + +function void +def_audio_play_clip(Audio_Clip clip, Audio_Control *control){ + clip.control = control; + Audio_System *Crunky = &def_audio_system; + def_audio_begin_ticket_mutex(Crunky); + if (Crunky->pending_clip_count < ArrayCount(Crunky->pending_clips)) + { + Crunky->pending_clips[Crunky->pending_clip_count++] = clip; + } + def_audio_end_ticket_mutex(Crunky); +} + +internal b32 +def_audio_is_playing(Audio_Control *control){ + Audio_System *Crunky = &def_audio_system; + b32 result = (Crunky->generation - control->generation < 2); + return(result); +} + +internal void +def_audio_stop(Audio_Control *control){ + Audio_System *Crunky = &def_audio_system; + def_audio_begin_ticket_mutex(Crunky); + + Audio_Clip *clip = Crunky->playing_clips; + for(u32 i = 0; + i < ArrayCount(Crunky->playing_clips); + i += 1, clip += 1){ + if (clip->control == control){ + clip->at_sample_index = clip->sample_count; + clip->control = 0; + } + } + control->loop = false; + + def_audio_end_ticket_mutex(Crunky); +} + +function void +def_audio_mix_sources(void *ctx, f32 *mix_buffer, u32 sample_count){ + Audio_System *Crunky = (Audio_System*)ctx; + def_audio_begin_ticket_mutex(Crunky); + // NOTE(casey): Move pending sounds into the playing list + { + Crunky->generation += 1; + u32 PendIndex = 0; + Audio_Clip *clip = Crunky->playing_clips; + for(u32 DestIndex = 0; + (DestIndex < ArrayCount(Crunky->playing_clips)) && (PendIndex < Crunky->pending_clip_count); + DestIndex += 1, clip += 1) + { + if (clip->at_sample_index == clip->sample_count) + { + Audio_Control *control = clip->control; + if (control == 0 || !control->loop){ + *clip = Crunky->pending_clips[PendIndex++]; + } + } + } + Crunky->pending_clip_count = 0; + } + def_audio_end_ticket_mutex(Crunky); + + // NOTE(casey): Mix all sounds into the output buffer + { + Audio_Clip *clip = Crunky->playing_clips; + for(u32 SoundIndex = 0; + SoundIndex < ArrayCount(Crunky->playing_clips); + SoundIndex += 1, clip += 1) + { + // NOTE(allen): Determine starting point + Audio_Control *control = clip->control; + if (control != 0 && control->loop && clip->at_sample_index == clip->sample_count){ + clip->at_sample_index = 0; + } + u32 base_sample_index = clip->at_sample_index; + + // NOTE(casey): Determine how many samples are left to play in this + // sound (possible none) + u32 SamplesToMix = clamp_top((clip->sample_count - clip->at_sample_index), sample_count); + clip->at_sample_index += SamplesToMix; + + // NOTE(casey): Load the volume out of the control if there is one, + // and if there is, update the generation and sample index so + // external controllers can take action + f32 LeftVol = clip->channel_volume[0]; + f32 RightVol = clip->channel_volume[1]; + if(SamplesToMix && control != 0) + { + LeftVol *= control->channel_volume[0]; + RightVol *= control->channel_volume[1]; + control->generation = Crunky->generation; + control->last_played_sample_index = clip->at_sample_index; + } + + // NOTE(casey): Mix samples + for(u32 SampleIndex = 0; + SampleIndex < SamplesToMix; + ++SampleIndex) + { + u32 src_index = 2*(base_sample_index + SampleIndex); + f32 Left = LeftVol *(f32)clip->samples[src_index + 0]; + f32 Right = RightVol*(f32)clip->samples[src_index + 1]; + + u32 dst_index = 2*SampleIndex; + mix_buffer[dst_index + 0] += Left; + mix_buffer[dst_index + 1] += Right; + } + } + } +} + +function void +def_audio_mix_destination(i16 *dst, f32 *src, u32 sample_count){ + u32 opl = sample_count*2; + for(u32 i = 0; i < opl; i += 1){ + f32 sample = src[i]; + f32 sat_sample = clamp(-32768.f, sample, 32767.f); + dst[i] = (i16)sat_sample; + } +} + + +//////////////////////////////// +// NOTE(allen): Loading Clip #if !defined(FCODER_SKIP_WAV) #define FCODER_SKIP_WAV diff --git a/custom/4coder_audio.h b/custom/4coder_audio.h index 328d5da9..879fb630 100644 --- a/custom/4coder_audio.h +++ b/custom/4coder_audio.h @@ -4,8 +4,52 @@ #define FCODER_AUDIO_H //////////////////////////////// -// NOTE(allen): Load Clip +// NOTE(allen): Default Mixer Types + +struct Audio_Control{ + volatile f32 channel_volume[2]; + volatile u32 generation; + volatile u32 last_played_sample_index; + volatile b32 loop; +}; + +struct Audio_Clip{ + i16 *samples; + Audio_Control *control; + f32 channel_volume[2]; + + u32 sample_count; + u32 at_sample_index; +}; + +struct Audio_System{ + volatile u32 quit; + volatile u32 ticket; + volatile u32 serving; + volatile u32 generation; + + Audio_Clip playing_clips[64]; + + // NOTE(casey): Requests to play sounds are written to a pending array to avoid long locking + volatile u32 pending_clip_count; + Audio_Clip pending_clips[64]; +}; + +//////////////////////////////// +// NOTE(allen): Default Mixer + +function void def_audio_init(void); +function void def_audio_play_clip(Audio_Clip clip, Audio_Control *control); +function b32 def_audio_is_playing(Audio_Control *control); +function void def_audio_stop(Audio_Control *control); + +function void def_audio_mix_sources(void *ctx, f32 *mix_buffer, u32 sample_count); +function void def_audio_mix_destination(i16 *dst, f32 *src, u32 sample_count); + +//////////////////////////////// +// NOTE(allen): Loading Clip function Audio_Clip audio_clip_from_wav_data(String_Const_u8 data); +function Audio_Clip audio_clip_from_wav_file_name(char *file_name); #endif //4CODER_AUDIO_H diff --git a/custom/4coder_default_hooks.cpp b/custom/4coder_default_hooks.cpp index ecdd794f..a4538b11 100644 --- a/custom/4coder_default_hooks.cpp +++ b/custom/4coder_default_hooks.cpp @@ -20,12 +20,14 @@ CUSTOM_DOC("Default command for responding to a startup event") } { + def_audio_init(); + Audio_Clip test_clip = audio_clip_from_wav_file_name("W:\\4ed\\audio_test\\raygun_zap.wav"); local_persist Audio_Control test_control = {}; test_control.channel_volume[0] = 1.f; test_control.channel_volume[1] = 1.f; - system_play_clip(test_clip, &test_control); + def_audio_play_clip(test_clip, &test_control); } } diff --git a/custom/4coder_examples.cpp b/custom/4coder_examples.cpp index c11f74f7..291fd54f 100644 --- a/custom/4coder_examples.cpp +++ b/custom/4coder_examples.cpp @@ -208,60 +208,6 @@ CUSTOM_DOC("Example of query_user_string and query_user_number") } } - -CUSTOM_COMMAND_SIG(test_the_new_api) -CUSTOM_DOC("If you are reading this I forgot to delete this test, please let me know") -{ - Query_Bar_Group group(app); - Query_Bar bar = {}; - bar.prompt = SCu8("Testing ... "); - if (!start_query_bar(app, &bar, 0)){ - return; - } - - Input_Event events[10]; - i32 count = 0; - - User_Input in = {}; - - for (;;) { - in = get_next_input(app, EventProperty_AnyKey, 0); - if (in.abort){ - return; - } - events[count] = in.event; - count += 1; - if (!event_is_dead_key(&in.event)) { - break; - } - } - - u64 codepoints[10] = {}; - i32 index = 0; - - for (Input_Event event_text = event_next_text_event(&in.event); - event_text.kind != InputEventKind_None; - event_text = event_next_text_event(&event_text)){ - String_Const_u8 writable = to_writable(&event_text); - if (writable.size) { - codepoints[index] = utf8_consume(writable.str, writable.size).codepoint; - index += 1; - } - } - - Scratch_Block scratch(app); - for (i32 i = 0; i < count; i += 1){ - String_Const_u8 string = stringize_keyboard_event(scratch, &events[i]); - print_message(app, string); - } - - for (i32 i = 0; i < index; i += 1){ - String_Const_u8 string = push_u8_stringf(scratch, "%llu\n", codepoints[i]); - print_message(app, string); - } - -} - global Audio_Control the_music_control = {}; CUSTOM_COMMAND_SIG(music_start) @@ -274,18 +220,18 @@ CUSTOM_DOC("Starts the music.") the_music_clip = audio_clip_from_wav_file_name("W:\\4ed\\audio_test\\chtulthu.wav"); } - if (!system_audio_is_playing(&the_music_control)){ + if (!def_audio_is_playing(&the_music_control)){ the_music_control.loop = true; the_music_control.channel_volume[0] = 1.f; the_music_control.channel_volume[1] = 1.f; - system_play_clip(the_music_clip, &the_music_control); + def_audio_play_clip(the_music_clip, &the_music_control); } } CUSTOM_COMMAND_SIG(music_stop) CUSTOM_DOC("Stops the music.") { - system_audio_stop(&the_music_control); + def_audio_stop(&the_music_control); } CUSTOM_COMMAND_SIG(hit_sfx) @@ -302,11 +248,11 @@ CUSTOM_DOC("Play the hit sound effect") local_persist Audio_Control controls[8] = {}; Audio_Control *control = &controls[index%8]; - if (!system_audio_is_playing(control)){ + if (!def_audio_is_playing(control)){ control->loop = false; control->channel_volume[0] = 1.f; control->channel_volume[1] = 1.f; - system_play_clip(the_hit_clip, control); + def_audio_play_clip(the_hit_clip, control); index += 1; } } diff --git a/custom/4coder_types.h b/custom/4coder_types.h index b48d551e..62d98145 100644 --- a/custom/4coder_types.h +++ b/custom/4coder_types.h @@ -789,36 +789,10 @@ struct Process_State{ //////////////////////////////// -api(custom) -struct Audio_Control{ - volatile f32 channel_volume[2]; - volatile u32 generation; - volatile u32 last_played_sample_index; - volatile b32 loop; -}; - -api(custom) -struct Audio_Clip{ - i16 *samples; - Audio_Control *control; - f32 channel_volume[2]; - - u32 sample_count; - u32 at_sample_index; -}; - -api(custom) -struct Audio_System{ - volatile u32 quit; - volatile u32 ticket; - volatile u32 serving; - volatile u32 generation; - - Audio_Clip playing_clips[64]; - - // NOTE(casey): Requests to play sounds are written to a pending array to avoid long locking - volatile u32 pending_clip_count; - Audio_Clip pending_clips[64]; -}; +// NOTE(allen): buffers are allocate with: +// array_count = channel_count*sample_count +// channel_count = 2 +typedef void Audio_Mix_Sources_Function(void *ctx, f32 *buffer, u32 sample_count); +typedef void Audio_Mix_Destination_Function(i16 *dst, f32 *src, u32 sample_count); #endif diff --git a/custom/generated/command_metadata.h b/custom/generated/command_metadata.h index 3c0e996d..ccb589f8 100644 --- a/custom/generated/command_metadata.h +++ b/custom/generated/command_metadata.h @@ -2,7 +2,7 @@ #define command_id(c) (fcoder_metacmd_ID_##c) #define command_metadata(c) (&fcoder_metacmd_table[command_id(c)]) #define command_metadata_by_id(id) (&fcoder_metacmd_table[id]) -#define command_one_past_last_id 251 +#define command_one_past_last_id 250 #if defined(CUSTOM_COMMAND_SIG) #define PROC_LINKS(x,y) x #else @@ -227,7 +227,6 @@ CUSTOM_COMMAND_SIG(snippet_lister); CUSTOM_COMMAND_SIG(string_repeat); CUSTOM_COMMAND_SIG(suppress_mouse); CUSTOM_COMMAND_SIG(swap_panels); -CUSTOM_COMMAND_SIG(test_the_new_api); CUSTOM_COMMAND_SIG(theme_lister); CUSTOM_COMMAND_SIG(to_lowercase); CUSTOM_COMMAND_SIG(to_uppercase); @@ -272,7 +271,7 @@ char *source_name; i32 source_name_len; i32 line_number; }; -static Command_Metadata fcoder_metacmd_table[251] = { +static Command_Metadata fcoder_metacmd_table[250] = { { PROC_LINKS(allow_mouse, 0), false, "allow_mouse", 11, "Shows the mouse and causes all mouse input to be processed normally.", 68, "W:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 485 }, { PROC_LINKS(auto_indent_line_at_cursor, 0), false, "auto_indent_line_at_cursor", 26, "Auto-indents the line on which the cursor sits.", 47, "W:\\4ed\\code\\custom\\4coder_auto_indent.cpp", 41, 417 }, { PROC_LINKS(auto_indent_range, 0), false, "auto_indent_range", 17, "Auto-indents the range between the cursor and the mark.", 55, "W:\\4ed\\code\\custom\\4coder_auto_indent.cpp", 41, 427 }, @@ -310,8 +309,8 @@ static Command_Metadata fcoder_metacmd_table[251] = { { PROC_LINKS(decrease_face_size, 0), false, "decrease_face_size", 18, "Decrease the size of the face used by the current buffer.", 57, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 757 }, { PROC_LINKS(default_file_externally_modified, 0), false, "default_file_externally_modified", 32, "Notes the external modification of attached files by printing a message.", 72, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 2062 }, { PROC_LINKS(default_startup, 0), false, "default_startup", 15, "Default command for responding to a startup event", 49, "W:\\4ed\\code\\custom\\4coder_default_hooks.cpp", 43, 7 }, -{ PROC_LINKS(default_try_exit, 0), false, "default_try_exit", 16, "Default command for responding to a try-exit event", 50, "W:\\4ed\\code\\custom\\4coder_default_hooks.cpp", 43, 32 }, -{ PROC_LINKS(default_view_input_handler, 0), false, "default_view_input_handler", 26, "Input consumption loop for default view behavior", 48, "W:\\4ed\\code\\custom\\4coder_default_hooks.cpp", 43, 76 }, +{ PROC_LINKS(default_try_exit, 0), false, "default_try_exit", 16, "Default command for responding to a try-exit event", 50, "W:\\4ed\\code\\custom\\4coder_default_hooks.cpp", 43, 34 }, +{ PROC_LINKS(default_view_input_handler, 0), false, "default_view_input_handler", 26, "Input consumption loop for default view behavior", 48, "W:\\4ed\\code\\custom\\4coder_default_hooks.cpp", 43, 78 }, { PROC_LINKS(delete_alpha_numeric_boundary, 0), false, "delete_alpha_numeric_boundary", 29, "Delete characters between the cursor position and the first alphanumeric boundary to the right.", 95, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 161 }, { PROC_LINKS(delete_char, 0), false, "delete_char", 11, "Deletes the character to the right of the cursor.", 49, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 79 }, { PROC_LINKS(delete_current_scope, 0), false, "delete_current_scope", 20, "Deletes the braces surrounding the currently selected scope. Leaves the contents within the scope.", 99, "W:\\4ed\\code\\custom\\4coder_scope_commands.cpp", 44, 112 }, @@ -338,7 +337,7 @@ static Command_Metadata fcoder_metacmd_table[251] = { { PROC_LINKS(goto_prev_jump_no_skips, 0), false, "goto_prev_jump_no_skips", 23, "If a buffer containing jump locations has been locked in, goes to the previous jump in the buffer, and does not skip sub jump locations.", 136, "W:\\4ed\\code\\custom\\4coder_jump_sticky.cpp", 41, 511 }, { PROC_LINKS(hide_filebar, 0), false, "hide_filebar", 12, "Sets the current view to hide it's filebar.", 43, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 704 }, { PROC_LINKS(hide_scrollbar, 0), false, "hide_scrollbar", 14, "Sets the current view to hide it's scrollbar.", 45, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 690 }, -{ PROC_LINKS(hit_sfx, 0), false, "hit_sfx", 7, "Play the hit sound effect", 25, "W:\\4ed\\code\\custom\\4coder_examples.cpp", 38, 291 }, +{ PROC_LINKS(hit_sfx, 0), false, "hit_sfx", 7, "Play the hit sound effect", 25, "W:\\4ed\\code\\custom\\4coder_examples.cpp", 38, 237 }, { PROC_LINKS(hms_demo_tutorial, 0), false, "hms_demo_tutorial", 17, "Tutorial for built in 4coder bindings and features.", 51, "W:\\4ed\\code\\custom\\4coder_tutorial.cpp", 38, 869 }, { PROC_LINKS(if0_off, 0), false, "if0_off", 7, "Surround the range between the cursor and mark with an '#if 0' and an '#endif'", 78, "W:\\4ed\\code\\custom\\4coder_combined_write_commands.cpp", 53, 70 }, { PROC_LINKS(if_read_only_goto_position, 0), false, "if_read_only_goto_position", 26, "If the buffer in the active view is writable, inserts a character, otherwise performs goto_jump_at_cursor.", 106, "W:\\4ed\\code\\custom\\4coder_jump_sticky.cpp", 41, 564 }, @@ -413,8 +412,8 @@ static Command_Metadata fcoder_metacmd_table[251] = { { PROC_LINKS(multi_paste, 0), false, "multi_paste", 11, "Paste multiple entries from the clipboard at once", 49, "W:\\4ed\\code\\custom\\4coder_clipboard.cpp", 39, 229 }, { PROC_LINKS(multi_paste_interactive, 0), false, "multi_paste_interactive", 23, "Paste multiple lines from the clipboard history, controlled with arrow keys", 75, "W:\\4ed\\code\\custom\\4coder_clipboard.cpp", 39, 371 }, { PROC_LINKS(multi_paste_interactive_quick, 0), false, "multi_paste_interactive_quick", 29, "Paste multiple lines from the clipboard history, controlled by inputing the number of lines to paste", 100, "W:\\4ed\\code\\custom\\4coder_clipboard.cpp", 39, 380 }, -{ PROC_LINKS(music_start, 0), false, "music_start", 11, "Starts the music.", 17, "W:\\4ed\\code\\custom\\4coder_examples.cpp", 38, 267 }, -{ PROC_LINKS(music_stop, 0), false, "music_stop", 10, "Stops the music.", 16, "W:\\4ed\\code\\custom\\4coder_examples.cpp", 38, 285 }, +{ PROC_LINKS(music_start, 0), false, "music_start", 11, "Starts the music.", 17, "W:\\4ed\\code\\custom\\4coder_examples.cpp", 38, 213 }, +{ PROC_LINKS(music_stop, 0), false, "music_stop", 10, "Stops the music.", 16, "W:\\4ed\\code\\custom\\4coder_examples.cpp", 38, 231 }, { PROC_LINKS(open_all_code, 0), false, "open_all_code", 13, "Open all code in the current directory. File types are determined by extensions. An extension is considered code based on the extensions specified in 4coder.config.", 164, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 850 }, { PROC_LINKS(open_all_code_recursive, 0), false, "open_all_code_recursive", 23, "Works as open_all_code but also runs in all subdirectories.", 59, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 856 }, { PROC_LINKS(open_file_in_quotes, 0), false, "open_file_in_quotes", 19, "Reads a filename from surrounding '\"' characters and attempts to open the corresponding file.", 94, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1574 }, @@ -491,7 +490,6 @@ static Command_Metadata fcoder_metacmd_table[251] = { { PROC_LINKS(string_repeat, 0), false, "string_repeat", 13, "Example of query_user_string and query_user_number", 50, "W:\\4ed\\code\\custom\\4coder_examples.cpp", 38, 179 }, { PROC_LINKS(suppress_mouse, 0), false, "suppress_mouse", 14, "Hides the mouse and causes all mosue input (clicks, position, wheel) to be ignored.", 83, "W:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 479 }, { PROC_LINKS(swap_panels, 0), false, "swap_panels", 11, "Swaps the active panel with it's sibling.", 41, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1682 }, -{ PROC_LINKS(test_the_new_api, 0), false, "test_the_new_api", 16, "If you are reading this I forgot to delete this test, please let me know", 72, "W:\\4ed\\code\\custom\\4coder_examples.cpp", 38, 212 }, { PROC_LINKS(theme_lister, 0), true, "theme_lister", 12, "Opens an interactive list of all registered themes.", 51, "W:\\4ed\\code\\custom\\4coder_lists.cpp", 35, 784 }, { PROC_LINKS(to_lowercase, 0), false, "to_lowercase", 12, "Converts all ascii text in the range between the cursor and the mark to lowercase.", 82, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 567 }, { PROC_LINKS(to_uppercase, 0), false, "to_uppercase", 12, "Converts all ascii text in the range between the cursor and the mark to uppercase.", 82, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 554 }, @@ -743,37 +741,36 @@ static i32 fcoder_metacmd_ID_snippet_lister = 214; static i32 fcoder_metacmd_ID_string_repeat = 215; static i32 fcoder_metacmd_ID_suppress_mouse = 216; static i32 fcoder_metacmd_ID_swap_panels = 217; -static i32 fcoder_metacmd_ID_test_the_new_api = 218; -static i32 fcoder_metacmd_ID_theme_lister = 219; -static i32 fcoder_metacmd_ID_to_lowercase = 220; -static i32 fcoder_metacmd_ID_to_uppercase = 221; -static i32 fcoder_metacmd_ID_toggle_filebar = 222; -static i32 fcoder_metacmd_ID_toggle_fps_meter = 223; -static i32 fcoder_metacmd_ID_toggle_fullscreen = 224; -static i32 fcoder_metacmd_ID_toggle_highlight_enclosing_scopes = 225; -static i32 fcoder_metacmd_ID_toggle_highlight_line_at_cursor = 226; -static i32 fcoder_metacmd_ID_toggle_line_numbers = 227; -static i32 fcoder_metacmd_ID_toggle_line_wrap = 228; -static i32 fcoder_metacmd_ID_toggle_mouse = 229; -static i32 fcoder_metacmd_ID_toggle_paren_matching_helper = 230; -static i32 fcoder_metacmd_ID_toggle_show_whitespace = 231; -static i32 fcoder_metacmd_ID_toggle_virtual_whitespace = 232; -static i32 fcoder_metacmd_ID_tutorial_maximize = 233; -static i32 fcoder_metacmd_ID_tutorial_minimize = 234; -static i32 fcoder_metacmd_ID_uncomment_line = 235; -static i32 fcoder_metacmd_ID_undo = 236; -static i32 fcoder_metacmd_ID_undo_all_buffers = 237; -static i32 fcoder_metacmd_ID_view_buffer_other_panel = 238; -static i32 fcoder_metacmd_ID_view_jump_list_with_lister = 239; -static i32 fcoder_metacmd_ID_word_complete = 240; -static i32 fcoder_metacmd_ID_word_complete_drop_down = 241; -static i32 fcoder_metacmd_ID_write_block = 242; -static i32 fcoder_metacmd_ID_write_hack = 243; -static i32 fcoder_metacmd_ID_write_note = 244; -static i32 fcoder_metacmd_ID_write_space = 245; -static i32 fcoder_metacmd_ID_write_text_and_auto_indent = 246; -static i32 fcoder_metacmd_ID_write_text_input = 247; -static i32 fcoder_metacmd_ID_write_todo = 248; -static i32 fcoder_metacmd_ID_write_underscore = 249; -static i32 fcoder_metacmd_ID_write_zero_struct = 250; +static i32 fcoder_metacmd_ID_theme_lister = 218; +static i32 fcoder_metacmd_ID_to_lowercase = 219; +static i32 fcoder_metacmd_ID_to_uppercase = 220; +static i32 fcoder_metacmd_ID_toggle_filebar = 221; +static i32 fcoder_metacmd_ID_toggle_fps_meter = 222; +static i32 fcoder_metacmd_ID_toggle_fullscreen = 223; +static i32 fcoder_metacmd_ID_toggle_highlight_enclosing_scopes = 224; +static i32 fcoder_metacmd_ID_toggle_highlight_line_at_cursor = 225; +static i32 fcoder_metacmd_ID_toggle_line_numbers = 226; +static i32 fcoder_metacmd_ID_toggle_line_wrap = 227; +static i32 fcoder_metacmd_ID_toggle_mouse = 228; +static i32 fcoder_metacmd_ID_toggle_paren_matching_helper = 229; +static i32 fcoder_metacmd_ID_toggle_show_whitespace = 230; +static i32 fcoder_metacmd_ID_toggle_virtual_whitespace = 231; +static i32 fcoder_metacmd_ID_tutorial_maximize = 232; +static i32 fcoder_metacmd_ID_tutorial_minimize = 233; +static i32 fcoder_metacmd_ID_uncomment_line = 234; +static i32 fcoder_metacmd_ID_undo = 235; +static i32 fcoder_metacmd_ID_undo_all_buffers = 236; +static i32 fcoder_metacmd_ID_view_buffer_other_panel = 237; +static i32 fcoder_metacmd_ID_view_jump_list_with_lister = 238; +static i32 fcoder_metacmd_ID_word_complete = 239; +static i32 fcoder_metacmd_ID_word_complete_drop_down = 240; +static i32 fcoder_metacmd_ID_write_block = 241; +static i32 fcoder_metacmd_ID_write_hack = 242; +static i32 fcoder_metacmd_ID_write_note = 243; +static i32 fcoder_metacmd_ID_write_space = 244; +static i32 fcoder_metacmd_ID_write_text_and_auto_indent = 245; +static i32 fcoder_metacmd_ID_write_text_input = 246; +static i32 fcoder_metacmd_ID_write_todo = 247; +static i32 fcoder_metacmd_ID_write_underscore = 248; +static i32 fcoder_metacmd_ID_write_zero_struct = 249; #endif diff --git a/custom/generated/system_api.cpp b/custom/generated/system_api.cpp index e28dee6b..8d364069 100644 --- a/custom/generated/system_api.cpp +++ b/custom/generated/system_api.cpp @@ -54,9 +54,8 @@ vtable->set_fullscreen = system_set_fullscreen; vtable->is_fullscreen = system_is_fullscreen; vtable->get_keyboard_modifiers = system_get_keyboard_modifiers; vtable->set_key_mode = system_set_key_mode; -vtable->play_clip = system_play_clip; -vtable->audio_is_playing = system_audio_is_playing; -vtable->audio_stop = system_audio_stop; +vtable->set_source_mixer = system_set_source_mixer; +vtable->set_destination_mixer = system_set_destination_mixer; } #if defined(DYNAMIC_LINK_API) function void @@ -115,9 +114,8 @@ system_set_fullscreen = vtable->set_fullscreen; system_is_fullscreen = vtable->is_fullscreen; system_get_keyboard_modifiers = vtable->get_keyboard_modifiers; system_set_key_mode = vtable->set_key_mode; -system_play_clip = vtable->play_clip; -system_audio_is_playing = vtable->audio_is_playing; -system_audio_stop = vtable->audio_stop; +system_set_source_mixer = vtable->set_source_mixer; +system_set_destination_mixer = vtable->set_destination_mixer; } #undef DYNAMIC_LINK_API #endif diff --git a/custom/generated/system_api.h b/custom/generated/system_api.h index ce1d2a12..0c3cc455 100644 --- a/custom/generated/system_api.h +++ b/custom/generated/system_api.h @@ -52,9 +52,8 @@ #define system_is_fullscreen_sig() b32 system_is_fullscreen(void) #define system_get_keyboard_modifiers_sig() Input_Modifier_Set system_get_keyboard_modifiers(Arena* arena) #define system_set_key_mode_sig() void system_set_key_mode(Key_Mode mode) -#define system_play_clip_sig() void system_play_clip(Audio_Clip clip, Audio_Control* control) -#define system_audio_is_playing_sig() b32 system_audio_is_playing(Audio_Control* control) -#define system_audio_stop_sig() void system_audio_stop(Audio_Control* control) +#define system_set_source_mixer_sig() void system_set_source_mixer(void* ctx, Audio_Mix_Sources_Function* mix_func) +#define system_set_destination_mixer_sig() void system_set_destination_mixer(Audio_Mix_Destination_Function* mix_func) typedef String_Const_u8 system_get_path_type(Arena* arena, System_Path_Code path_code); typedef String_Const_u8 system_get_canonical_type(Arena* arena, String_Const_u8 name); typedef File_List system_get_file_list_type(Arena* arena, String_Const_u8 directory); @@ -109,9 +108,8 @@ typedef b32 system_set_fullscreen_type(b32 full_screen); typedef b32 system_is_fullscreen_type(void); typedef Input_Modifier_Set system_get_keyboard_modifiers_type(Arena* arena); typedef void system_set_key_mode_type(Key_Mode mode); -typedef void system_play_clip_type(Audio_Clip clip, Audio_Control* control); -typedef b32 system_audio_is_playing_type(Audio_Control* control); -typedef void system_audio_stop_type(Audio_Control* control); +typedef void system_set_source_mixer_type(void* ctx, Audio_Mix_Sources_Function* mix_func); +typedef void system_set_destination_mixer_type(Audio_Mix_Destination_Function* mix_func); struct API_VTable_system{ system_get_path_type *get_path; system_get_canonical_type *get_canonical; @@ -167,9 +165,8 @@ system_set_fullscreen_type *set_fullscreen; system_is_fullscreen_type *is_fullscreen; system_get_keyboard_modifiers_type *get_keyboard_modifiers; system_set_key_mode_type *set_key_mode; -system_play_clip_type *play_clip; -system_audio_is_playing_type *audio_is_playing; -system_audio_stop_type *audio_stop; +system_set_source_mixer_type *set_source_mixer; +system_set_destination_mixer_type *set_destination_mixer; }; #if defined(STATIC_LINK_API) internal String_Const_u8 system_get_path(Arena* arena, System_Path_Code path_code); @@ -226,9 +223,8 @@ internal b32 system_set_fullscreen(b32 full_screen); internal b32 system_is_fullscreen(void); internal Input_Modifier_Set system_get_keyboard_modifiers(Arena* arena); internal void system_set_key_mode(Key_Mode mode); -internal void system_play_clip(Audio_Clip clip, Audio_Control* control); -internal b32 system_audio_is_playing(Audio_Control* control); -internal void system_audio_stop(Audio_Control* control); +internal void system_set_source_mixer(void* ctx, Audio_Mix_Sources_Function* mix_func); +internal void system_set_destination_mixer(Audio_Mix_Destination_Function* mix_func); #undef STATIC_LINK_API #elif defined(DYNAMIC_LINK_API) global system_get_path_type *system_get_path = 0; @@ -285,8 +281,7 @@ global system_set_fullscreen_type *system_set_fullscreen = 0; global system_is_fullscreen_type *system_is_fullscreen = 0; global system_get_keyboard_modifiers_type *system_get_keyboard_modifiers = 0; global system_set_key_mode_type *system_set_key_mode = 0; -global system_play_clip_type *system_play_clip = 0; -global system_audio_is_playing_type *system_audio_is_playing = 0; -global system_audio_stop_type *system_audio_stop = 0; +global system_set_source_mixer_type *system_set_source_mixer = 0; +global system_set_destination_mixer_type *system_set_destination_mixer = 0; #undef DYNAMIC_LINK_API #endif diff --git a/custom/generated/system_api_constructor.cpp b/custom/generated/system_api_constructor.cpp index 80290dce..4fc4933b 100644 --- a/custom/generated/system_api_constructor.cpp +++ b/custom/generated/system_api_constructor.cpp @@ -246,17 +246,13 @@ API_Call *call = api_call_with_location(arena, result, string_u8_litexpr("set_ke api_param(arena, call, "Key_Mode", "mode"); } { -API_Call *call = api_call_with_location(arena, result, string_u8_litexpr("play_clip"), string_u8_litexpr("void"), string_u8_litexpr("")); -api_param(arena, call, "Audio_Clip", "clip"); -api_param(arena, call, "Audio_Control*", "control"); +API_Call *call = api_call_with_location(arena, result, string_u8_litexpr("set_source_mixer"), string_u8_litexpr("void"), string_u8_litexpr("")); +api_param(arena, call, "void*", "ctx"); +api_param(arena, call, "Audio_Mix_Sources_Function*", "mix_func"); } { -API_Call *call = api_call_with_location(arena, result, string_u8_litexpr("audio_is_playing"), string_u8_litexpr("b32"), string_u8_litexpr("")); -api_param(arena, call, "Audio_Control*", "control"); -} -{ -API_Call *call = api_call_with_location(arena, result, string_u8_litexpr("audio_stop"), string_u8_litexpr("void"), string_u8_litexpr("")); -api_param(arena, call, "Audio_Control*", "control"); +API_Call *call = api_call_with_location(arena, result, string_u8_litexpr("set_destination_mixer"), string_u8_litexpr("void"), string_u8_litexpr("")); +api_param(arena, call, "Audio_Mix_Destination_Function*", "mix_func"); } return(result); } diff --git a/custom/generated/system_api_master_list.h b/custom/generated/system_api_master_list.h index 11839fd4..da8ae63a 100644 --- a/custom/generated/system_api_master_list.h +++ b/custom/generated/system_api_master_list.h @@ -52,6 +52,5 @@ api(system) function b32 set_fullscreen(b32 full_screen); api(system) function b32 is_fullscreen(void); api(system) function Input_Modifier_Set get_keyboard_modifiers(Arena* arena); api(system) function void set_key_mode(Key_Mode mode); -api(system) function void play_clip(Audio_Clip clip, Audio_Control* control); -api(system) function b32 audio_is_playing(Audio_Control* control); -api(system) function void audio_stop(Audio_Control* control); +api(system) function void set_source_mixer(void* ctx, Audio_Mix_Sources_Function* mix_func); +api(system) function void set_destination_mixer(Audio_Mix_Destination_Function* mix_func); diff --git a/platform_win32/win32_4ed.cpp b/platform_win32/win32_4ed.cpp index 8ebc8d5e..cbfa1c28 100644 --- a/platform_win32/win32_4ed.cpp +++ b/platform_win32/win32_4ed.cpp @@ -179,9 +179,12 @@ struct Win32_Vars{ HWND window_handle; f32 screen_scale_factor; - Audio_System audio_system; DWORD audio_thread_id; + void *volatile audio_mix_ctx; + Audio_Mix_Sources_Function *volatile audio_mix_sources; + Audio_Mix_Destination_Function *volatile audio_mix_destination; + f64 count_per_usecond; b32 first; i32 running_cli; @@ -1812,7 +1815,7 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdS win32_resize(window_rect.right - window_rect.left, window_rect.bottom - window_rect.top); // NOTE(allen): Audio Init - win32vars.audio_thread_id = win32_audio_init(&win32vars.audio_system); + win32vars.audio_thread_id = win32_audio_init(); // NOTE(allen): Misc Init if (!AddClipboardFormatListener(win32vars.window_handle)){ diff --git a/platform_win32/win32_audio.cpp b/platform_win32/win32_audio.cpp index a9861b3d..1c8f3b46 100644 --- a/platform_win32/win32_audio.cpp +++ b/platform_win32/win32_audio.cpp @@ -1,164 +1,96 @@ //////////////////////////////// -// NOTE(allen): Win32 Audio Helpers +// NOTE(allen): Quick Mutex + +// TODO(allen): intrinsics wrappers +#include function u32 AtomicAddU32AndReturnOriginal(u32 volatile *Value, u32 Addend) { // NOTE(casey): Returns the original value _prior_ to adding - u32 Result = _InterlockedExchangeAdd(Value, Addend); + u32 Result = _InterlockedExchangeAdd((long volatile*)Value, (long)Addend); return(Result); } +global volatile u32 win32_audio_ticket = 0; +global volatile u32 win32_audio_serving = 0; + function void -win32_begin_ticket_mutex(Audio_System *Crunky) +win32_audio_begin_ticket_mutex(void) { - u32 Ticket = AtomicAddU32AndReturnOriginal(&Crunky->ticket, 1); - while(Ticket != Crunky->serving) {_mm_pause();} + u32 Ticket = AtomicAddU32AndReturnOriginal(&win32_audio_ticket, 1); + while(Ticket != win32_audio_serving) {_mm_pause();} +} +function void +win32_audio_end_ticket_mutex(void) +{ + AtomicAddU32AndReturnOriginal(&win32_audio_serving, 1); +} + +//////////////////////////////// +// NOTE(allen): Fallback Mixers + +function void +win32_default_mix_sources(void *ctx, f32 *mix_buffer, u32 sample_count){ } function void -win32_end_ticket_mutex(Audio_System *Crunky) -{ - AtomicAddU32AndReturnOriginal(&Crunky->serving, 1); +win32_default_mix_destination(i16 *dst, f32 *src, u32 sample_count){ + u32 opl = sample_count*2; + for(u32 i = 0; i < sample_count; i += 1){ + dst[i] = (i16)src[i]; + } } //////////////////////////////// // NOTE(allen): Win32 Audio System API internal -system_play_clip_sig(){ - clip.control = control; - Audio_System *Crunky = &win32vars.audio_system; - win32_begin_ticket_mutex(Crunky); - if (Crunky->pending_clip_count < ArrayCount(Crunky->pending_clips)) - { - Crunky->pending_clips[Crunky->pending_clip_count++] = clip; - } - win32_end_ticket_mutex(Crunky); +system_set_source_mixer_sig(){ + win32_audio_begin_ticket_mutex(); + win32vars.audio_mix_ctx = ctx; + win32vars.audio_mix_sources = mix_func; + win32_audio_end_ticket_mutex(); } internal -system_audio_is_playing_sig(){ - Audio_System *Crunky = (Audio_System *)&win32vars.audio_system; - b32 result = (Crunky->generation - control->generation < 2); - return(result); -} - -internal -system_audio_stop_sig(){ - Audio_System *Crunky = (Audio_System *)&win32vars.audio_system; - win32_begin_ticket_mutex(Crunky); - - Audio_Clip *clip = Crunky->playing_clips; - for(u32 i = 0; - i < ArrayCount(Crunky->playing_clips); - i += 1, clip += 1){ - if (clip->control == control){ - clip->at_sample_index = clip->sample_count; - } - } - control->loop = false; - - win32_end_ticket_mutex(Crunky); +system_set_destination_mixer_sig(){ + win32_audio_begin_ticket_mutex(); + win32vars.audio_mix_destination = mix_func; + win32_audio_end_ticket_mutex(); } //////////////////////////////// // NOTE(allen): Win32 Audio Loop -function void -win32_mix_audio(Audio_System *Crunky, u32 SampleCount, i16 *Dest, void *mix_buffer_memory){ - // NOTE(casey): Clear the output buffer - u32 MixBufferSize = SampleCount*2*sizeof(f32); - f32 *MixBuffer = (f32 *)mix_buffer_memory; - memset(MixBuffer, 0, MixBufferSize); - - win32_begin_ticket_mutex(Crunky); - // NOTE(casey): Move pending sounds into the playing list - { - Crunky->generation += 1; - u32 PendIndex = 0; - Audio_Clip *clip = Crunky->playing_clips; - for(u32 DestIndex = 0; - (DestIndex < ArrayCount(Crunky->playing_clips)) && (PendIndex < Crunky->pending_clip_count); - DestIndex += 1, clip += 1) - { - if (clip->at_sample_index == clip->sample_count) - { - Audio_Control *control = clip->control; - if (control == 0 || !control->loop){ - *clip = Crunky->pending_clips[PendIndex++]; - } - } - } - Crunky->pending_clip_count = 0; - } - win32_end_ticket_mutex(Crunky); - - // NOTE(casey): Mix all sounds into the output buffer - { - Audio_Clip *clip = Crunky->playing_clips; - for(u32 SoundIndex = 0; - SoundIndex < ArrayCount(Crunky->playing_clips); - SoundIndex += 1, clip += 1) - { - Audio_Control *control = clip->control; - if (control != 0 && control->loop && clip->at_sample_index == clip->sample_count){ - clip->at_sample_index = 0; - } - - // NOTE(casey): Determine how many samples are left to play in this - // sound (possible none) - u32 SamplesToMix = Min((clip->sample_count - clip->at_sample_index), SampleCount); - clip->at_sample_index += SamplesToMix; - - // NOTE(casey): Load the volume out of the control if there is one, - // and if there is, update the generation and sample index so - // external controllers can take action - f32 LeftVol = clip->channel_volume[0]; - f32 RightVol = clip->channel_volume[1]; - if(SamplesToMix && control != 0) - { - LeftVol *= control->channel_volume[0]; - RightVol *= control->channel_volume[1]; - control->generation = Crunky->generation; - control->last_played_sample_index = clip->at_sample_index; - } - - // NOTE(casey): Mix samples - for(u32 SampleIndex = 0; - SampleIndex < SamplesToMix; - ++SampleIndex) - { - u32 src_index = 2*(clip->at_sample_index + SampleIndex); - f32 Left = LeftVol*(f32)clip->samples[src_index + 0]; - f32 Right = RightVol*(f32)clip->samples[src_index + 1]; - - u32 dst_index = 2*SampleIndex; - MixBuffer[dst_index + 0] += Left; - MixBuffer[dst_index + 1] += Right; - } - } - - for(u32 SampleIndex = 0; - SampleIndex < SampleCount; - ++SampleIndex) - { - f32 Left = MixBuffer[2*SampleIndex + 0]; - f32 Right = MixBuffer[2*SampleIndex + 1]; - - Dest[2*SampleIndex + 0] = (i16)Left; - Dest[2*SampleIndex + 1] = (i16)Right; - } - } -} - function b32 -win32_submit_audio(Audio_System *Crunky, HWAVEOUT WaveOut, WAVEHDR *Header, u32 SampleCount, void *mix_buffer){ +win32_submit_audio(HWAVEOUT WaveOut, WAVEHDR *Header, u32 SampleCount, f32 *mix_buffer){ b32 Result = false; + // NOTE(allen): prep buffers + u32 mix_buffer_size = SampleCount*2*sizeof(f32); + memset(mix_buffer, 0, mix_buffer_size); i16 *Samples = (i16 *)Header->lpData; - win32_mix_audio(Crunky, SampleCount, Samples, mix_buffer); + // NOTE(allen): prep mixer pointers + win32_audio_begin_ticket_mutex(); + void *audio_mix_ctx = win32vars.audio_mix_ctx; + Audio_Mix_Sources_Function *audio_mix_sources = win32vars.audio_mix_sources; + Audio_Mix_Destination_Function *audio_mix_destination = win32vars.audio_mix_destination; + win32_audio_end_ticket_mutex(); + + if (audio_mix_sources == 0){ + audio_mix_sources = win32_default_mix_sources; + } + if (audio_mix_destination == 0){ + audio_mix_destination = win32_default_mix_destination; + } + + // NOTE(allen): mix + audio_mix_sources(audio_mix_ctx, mix_buffer, SampleCount); + audio_mix_destination(Samples, mix_buffer, SampleCount); + + // NOTE(allen): send final samples to win32 DWORD Error = waveOutPrepareHeader(WaveOut, Header, sizeof(*Header)); if(Error == MMSYSERR_NOERROR) { @@ -175,8 +107,6 @@ win32_submit_audio(Audio_System *Crunky, HWAVEOUT WaveOut, WAVEHDR *Header, u32 function DWORD WINAPI win32_audio_loop(void *Passthrough){ - Audio_System *Crunky = (Audio_System *)Passthrough; - // // NOTE(casey): Set up our audio output buffer // @@ -206,6 +136,8 @@ win32_audio_loop(void *Passthrough){ Format.nBlockAlign = (Format.nChannels*Format.wBitsPerSample)/8; Format.nAvgBytesPerSec = Format.nBlockAlign * Format.nSamplesPerSec; + b32 quit = false; + void *MixBuffer = 0; void *AudioBufferMemory = 0; if(waveOutOpen(&WaveOut, WAVE_MAPPER, &Format, GetCurrentThreadId(), 0, CALLBACK_THREAD) == MMSYSERR_NOERROR) @@ -227,17 +159,19 @@ win32_audio_loop(void *Passthrough){ At += TotalBufferSize; - win32_submit_audio(Crunky, WaveOut, Header, SamplesPerBuffer, MixBuffer); + win32_submit_audio(WaveOut, Header, SamplesPerBuffer, (f32*)MixBuffer); } } else { - Crunky->quit = true; + // TODO(allen): audio error + quit = true; } } else { - Crunky->quit = true; + // TODO(allen): audio error + quit = true; } // @@ -245,7 +179,7 @@ win32_audio_loop(void *Passthrough){ // SetTimer(0, 0, 100, 0); - while(!Crunky->quit) + for (;!quit;) { MSG Message = {}; GetMessage(&Message, 0, 0, 0); @@ -259,7 +193,7 @@ win32_audio_loop(void *Passthrough){ waveOutUnprepareHeader(WaveOut, Header, sizeof(*Header)); - win32_submit_audio(Crunky, WaveOut, Header, SamplesPerBuffer, MixBuffer); + win32_submit_audio(WaveOut, Header, SamplesPerBuffer, (f32*)MixBuffer); } } @@ -277,9 +211,9 @@ win32_audio_loop(void *Passthrough){ } function DWORD -win32_audio_init(Audio_System *audio_system){ +win32_audio_init(void){ DWORD thread_id = 0; - HANDLE handle = CreateThread(0, 0, win32_audio_loop, audio_system, 0, &thread_id); + HANDLE handle = CreateThread(0, 0, win32_audio_loop, 0, 0, &thread_id); CloseHandle(handle); return(thread_id); } From 0486e92577b85a46eb563cf4e9d0e38f687413a8 Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Mon, 23 Nov 2020 20:06:03 -0800 Subject: [PATCH 8/9] Move '4ed_search_list.h/.cpp' to custom layer; rename to 4coder_* --- 4ed_search_list.cpp | 58 ---------------------------------- 4ed_search_list.h | 23 -------------- custom/4coder_search_list.cpp | 59 +++++++++++++++++++++++++++++++++++ custom/4coder_search_list.h | 26 +++++++++++++++ platform_linux/linux_4ed.cpp | 4 +-- platform_mac/mac_4ed.mm | 4 +-- platform_win32/win32_4ed.cpp | 19 +++++------ ship_files/changes.txt | 1 + 8 files changed, 100 insertions(+), 94 deletions(-) delete mode 100644 4ed_search_list.cpp delete mode 100644 4ed_search_list.h create mode 100644 custom/4coder_search_list.cpp create mode 100644 custom/4coder_search_list.h diff --git a/4ed_search_list.cpp b/4ed_search_list.cpp deleted file mode 100644 index 9eecc551..00000000 --- a/4ed_search_list.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Mr. 4th Dimention - Allen Webster - * - * 01.10.2019 - * - * Search list helper. - * - */ - -// TOP - -function void -search_list_add_path__inner(Arena *arena, Path_Search_List *list, String_Const_u8 path){ - string_list_push(arena, &list->list, path); - list->max_member_length = Max(list->max_member_length, path.size); -} - -function void -search_list_add_path(Arena *arena, Path_Search_List *list, String_Const_u8 path){ - search_list_add_path__inner(arena, list, push_string_copy(arena, path)); -} - -function void -search_list_add_system_path(Arena *arena, Path_Search_List *list, System_Path_Code path){ - search_list_add_path__inner(arena, list, system_get_path(arena, path)); -} - -function String_Const_u8 -get_full_path(Arena *arena, Path_Search_List *search_list, String_Const_u8 relative){ - String_Const_u8 result = {}; - Temp_Memory restore_point = begin_temp(arena); - u64 buffer_cap = search_list->max_member_length + relative.size + 1; - u8 *buffer = push_array(arena, u8, buffer_cap); - u8 *opl = buffer + buffer_cap; - u8 *relative_base = opl - 1 - relative.size; - block_copy(relative_base, relative.str, relative.size); - relative_base[relative.size] = 0; - for (Node_String_Const_u8 *node = search_list->list.first; - node != 0; - node = node->next){ - u64 node_size = node->string.size; - u8 *path_base = relative_base - node_size; - block_copy(path_base, node->string.str, node_size); - String_Const_u8 name = SCu8(path_base, opl); - File_Attributes attribs = system_quick_file_attributes(arena, name); - if (attribs.size > 0){ - result = name; - break; - } - } - if (result.size == 0){ - end_temp(restore_point); - } - return(result); -} - -// BOTTOM - diff --git a/4ed_search_list.h b/4ed_search_list.h deleted file mode 100644 index ab10fc76..00000000 --- a/4ed_search_list.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Mr. 4th Dimention - Allen Webster - * - * 01.10.2019 - * - * Search list helper. - * - */ - -// TOP - -#if !defined(FRED_SEARCH_LIST_H) -#define FRED_SEARCH_LIST_H - -struct Path_Search_List{ - List_String_Const_u8 list; - u64 max_member_length; -}; - -#endif - -// BOTTOM - diff --git a/custom/4coder_search_list.cpp b/custom/4coder_search_list.cpp new file mode 100644 index 00000000..63b3e3e7 --- /dev/null +++ b/custom/4coder_search_list.cpp @@ -0,0 +1,59 @@ +/* + * Mr. 4th Dimention - Allen Webster + * + * 01.10.2019 + * + * Search list helper. + * + */ + +// TOP + +//////////////////////////////// +// NOTE(allen): Search List Functions + +function void +def_search_list_add_path(Arena *arena, List_String_Const_u8 *list, String_Const_u8 path){ + String_Const_u8 path_copy = push_string_copy(arena, path); + string_list_push(arena, list, path_copy); +} + +function void +def_search_list_add_system_path(Arena *arena, List_String_Const_u8 *list, System_Path_Code path){ + String_Const_u8 path_string = system_get_path(arena, path); + string_list_push(arena, list, path_string); +} + +function String_Const_u8 +def_get_full_path(Arena *arena, List_String_Const_u8 *list, String_Const_u8 relative){ + String_Const_u8 result = {}; + + Temp_Memory temp = begin_temp(arena); + + u8 slash = '/'; + + for (Node_String_Const_u8 *node = list->first; + node != 0; + node = node->next){ + String_Const_u8 full_name = {}; + full_name.size = node->string.size + 1 + relative.size; + full_name.str = push_array(arena, u8, full_name.size + 1); + block_copy(full_name.str, node->string.str, node->string.size); + full_name.str[node->string.size] = slash; + block_copy(full_name.str + node->string.size + 1, relative.str, relative.size); + full_name.str[full_name.size] = 0; + + File_Attributes attribs = system_quick_file_attributes(arena, full_name); + if (attribs.last_write_time > 0){ + result = full_name; + break; + } + + end_temp(temp); + } + + return(result); +} + +// BOTTOM + diff --git a/custom/4coder_search_list.h b/custom/4coder_search_list.h new file mode 100644 index 00000000..eb5b782d --- /dev/null +++ b/custom/4coder_search_list.h @@ -0,0 +1,26 @@ +/* + * Mr. 4th Dimention - Allen Webster + * + * 01.10.2019 + * + * Search list helper. + * + */ + +// TOP + +#if !defined(FRED_SEARCH_LIST_H) +#define FRED_SEARCH_LIST_H + +//////////////////////////////// +// NOTE(allen): Search List Functions + +function void def_search_list_add_path(Arena *arena, List_String_Const_u8 *list, String_Const_u8 path); +function void def_search_list_add_system_path(Arena *arena, List_String_Const_u8 *list, System_Path_Code path); + +function String_Const_u8 def_get_full_path(Arena *arena, List_String_Const_u8 *list, String_Const_u8 file_name); + +#endif + +// BOTTOM + diff --git a/platform_linux/linux_4ed.cpp b/platform_linux/linux_4ed.cpp index efea98a6..c404709f 100644 --- a/platform_linux/linux_4ed.cpp +++ b/platform_linux/linux_4ed.cpp @@ -37,7 +37,7 @@ #include "4ed_font_set.h" #include "4ed_render_target.h" -#include "4ed_search_list.h" +#include "4coder_search_list.h" #include "4ed.h" #include "generated/system_api.cpp" @@ -58,7 +58,7 @@ #include "4ed_mem.cpp" #include "4ed_font_set.cpp" -#include "4ed_search_list.cpp" +#include "4coder_search_list.cpp" #include "4ed_font_provider_freetype.h" #include "4ed_font_provider_freetype.cpp" diff --git a/platform_mac/mac_4ed.mm b/platform_mac/mac_4ed.mm index b9f4d93c..7c5cc54c 100644 --- a/platform_mac/mac_4ed.mm +++ b/platform_mac/mac_4ed.mm @@ -30,7 +30,7 @@ #include "4ed_font_set.h" #include "4ed_render_target.h" -#include "4ed_search_list.h" +#include "4coder_search_list.h" #include "4ed.h" #include "generated/system_api.cpp" @@ -44,7 +44,7 @@ #include "4coder_table.cpp" #include "4coder_log.cpp" -#include "4ed_search_list.cpp" +#include "4coder_search_list.cpp" #include "mac_objective_c_to_cpp_links.h" diff --git a/platform_win32/win32_4ed.cpp b/platform_win32/win32_4ed.cpp index cbfa1c28..52c90a4d 100644 --- a/platform_win32/win32_4ed.cpp +++ b/platform_win32/win32_4ed.cpp @@ -32,7 +32,7 @@ #include "4ed_font_set.h" #include "4ed_render_target.h" -#include "4ed_search_list.h" +#include "4coder_search_list.h" #include "4ed.h" #include "generated/system_api.cpp" @@ -46,7 +46,7 @@ #include "4coder_table.cpp" #include "4coder_log.cpp" -#include "4ed_search_list.cpp" +#include "4coder_search_list.cpp" #undef function #define UNICODE @@ -1690,10 +1690,11 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdS { App_Get_Functions *get_funcs = 0; Scratch_Block scratch(win32vars.tctx); - Path_Search_List search_list = {}; - search_list_add_system_path(scratch, &search_list, SystemPath_Binary); - String_Const_u8 core_path = get_full_path(scratch, &search_list, SCu8("4ed_app.dll")); + List_String_Const_u8 search_list = {}; + def_search_list_add_system_path(scratch, &search_list, SystemPath_Binary); + + String_Const_u8 core_path = def_get_full_path(scratch, &search_list, SCu8("4ed_app.dll")); if (system_load_library(scratch, core_path, &core_library)){ get_funcs = (App_Get_Functions*)system_get_proc(core_library, "app_get_functions"); if (get_funcs != 0){ @@ -1747,9 +1748,9 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdS Scratch_Block scratch(win32vars.tctx); String_Const_u8 default_file_name = string_u8_litexpr("custom_4coder.dll"); - Path_Search_List search_list = {}; - search_list_add_system_path(scratch, &search_list, SystemPath_CurrentDirectory); - search_list_add_system_path(scratch, &search_list, SystemPath_Binary); + List_String_Const_u8 search_list = {}; + def_search_list_add_system_path(scratch, &search_list, SystemPath_CurrentDirectory); + def_search_list_add_system_path(scratch, &search_list, SystemPath_Binary); String_Const_u8 custom_file_names[2] = {}; i32 custom_file_count = 1; if (plat_settings.custom_dll != 0){ @@ -1764,7 +1765,7 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdS } String_Const_u8 custom_file_name = {}; for (i32 i = 0; i < custom_file_count; i += 1){ - custom_file_name = get_full_path(scratch, &search_list, custom_file_names[i]); + custom_file_name = def_get_full_path(scratch, &search_list, custom_file_names[i]); if (custom_file_name.size > 0){ break; } diff --git a/ship_files/changes.txt b/ship_files/changes.txt index ea04f84f..c5b92079 100644 --- a/ship_files/changes.txt +++ b/ship_files/changes.txt @@ -4,6 +4,7 @@ + Added lookup acceleration to code index data + Added highlighting for functions, types, and macros in code index + Default input is now dispatched through an "implicit map" callback + + Audio system API and default audio mixer with examples in 4coder_examples.cpp + Fix: crash when pasting in read only buffer 4.1.6 From 9bda1cf991e162e300b3ac126f1a4e9bbe5435cd Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Mon, 23 Nov 2020 22:27:33 -0800 Subject: [PATCH 9/9] Setup default load path for files --- 4ed_api_check.cpp | 4 +-- 4ed_api_parser_main.cpp | 2 +- custom/4coder_audio.cpp | 27 +++++++-------- custom/4coder_audio.h | 3 +- custom/4coder_default_framework.cpp | 1 + custom/4coder_default_framework_variables.cpp | 1 + custom/4coder_default_hooks.cpp | 5 ++- custom/4coder_default_include.cpp | 7 ++++ custom/4coder_examples.cpp | 18 +++++----- custom/4coder_file.cpp | 19 ++++++----- custom/4coder_project_commands.cpp | 3 ++ custom/4coder_search_list.cpp | 33 ++++++++++++++++++- custom/4coder_search_list.h | 16 +++++++-- custom/generated/command_metadata.h | 30 ++++++++--------- docs/4ed_doc_custom_api_main.cpp | 2 +- platform_win32/win32_4ed.cpp | 3 ++ 16 files changed, 117 insertions(+), 57 deletions(-) diff --git a/4ed_api_check.cpp b/4ed_api_check.cpp index 14a04328..01930f39 100644 --- a/4ed_api_check.cpp +++ b/4ed_api_check.cpp @@ -59,7 +59,7 @@ main(int argc, char **argv){ printf("error: could not open input file: '%s'\n", file_name); continue; } - String_Const_u8 text = file_load_all(&arena, file); + String_Const_u8 text = data_from_file(&arena, file); fclose(file); if (text.size > 0){ api_parse_source_add_to_list(&arena, SCu8(file_name), text, &master_list); @@ -72,7 +72,7 @@ main(int argc, char **argv){ printf("error: could not open input file: '%s'\n", file_name); continue; } - String_Const_u8 text = file_load_all(&arena, file); + String_Const_u8 text = data_from_file(&arena, file); fclose(file); if (text.size > 0){ api_parse_source_add_to_list(&arena, SCu8(file_name), text, &remote_list); diff --git a/4ed_api_parser_main.cpp b/4ed_api_parser_main.cpp index 291a1a5e..0c27d840 100644 --- a/4ed_api_parser_main.cpp +++ b/4ed_api_parser_main.cpp @@ -46,7 +46,7 @@ main(int argc, char **argv){ continue; } - String_Const_u8 text = file_load_all(&arena, file); + String_Const_u8 text = data_from_file(&arena, file); fclose(file); if (text.size > 0){ diff --git a/custom/4coder_audio.cpp b/custom/4coder_audio.cpp index 22b26a3f..a7a6e6bf 100644 --- a/custom/4coder_audio.cpp +++ b/custom/4coder_audio.cpp @@ -248,23 +248,18 @@ audio_clip_from_wav_data(String_Const_u8 data){ return(Result); } -#include - function Audio_Clip -audio_clip_from_wav_file_name(char *file_name){ - String_Const_u8 data = {}; - FILE *file = fopen(file_name, "rb"); - if (file != 0){ - fseek(file, 0, SEEK_END); - data.size = ftell(file); - data.str = (u8*)malloc(data.size); - if (data.str != 0 && data.size > 0){ - fseek(file, 0, SEEK_SET); - fread(data.str, data.size, 1, file); - } - fclose(file); - } - +audio_clip_from_wav_FILE(Arena *arena, FILE *file){ + String_Const_u8 data = data_from_file(arena, file); Audio_Clip result = audio_clip_from_wav_data(data); return(result); } + +function Audio_Clip +audio_clip_from_wav_file_name(Arena *arena, char *file_name){ + String_Const_u8 data = {}; + FILE *file = fopen(file_name, "rb"); + Audio_Clip result = audio_clip_from_wav_FILE(arena, file); + fclose(file); + return(result); +} diff --git a/custom/4coder_audio.h b/custom/4coder_audio.h index 879fb630..1f5f4540 100644 --- a/custom/4coder_audio.h +++ b/custom/4coder_audio.h @@ -50,6 +50,7 @@ function void def_audio_mix_destination(i16 *dst, f32 *src, u32 sample_count); // NOTE(allen): Loading Clip function Audio_Clip audio_clip_from_wav_data(String_Const_u8 data); -function Audio_Clip audio_clip_from_wav_file_name(char *file_name); +function Audio_Clip audio_clip_from_wav_FILE(Arena *arena, FILE *file); +function Audio_Clip audio_clip_from_wav_file_name(Arena *arena, char *file_name); #endif //4CODER_AUDIO_H diff --git a/custom/4coder_default_framework.cpp b/custom/4coder_default_framework.cpp index 922d7a91..aa738eaf 100644 --- a/custom/4coder_default_framework.cpp +++ b/custom/4coder_default_framework.cpp @@ -1014,6 +1014,7 @@ default_framework_init(Application_Links *app){ initialize_managed_id_metadata(app); set_default_color_scheme(app); heap_init(&global_heap, tctx->allocator); + global_permanent_arena = make_arena_system(); global_config_arena = make_arena_system(); fade_range_arena = make_arena_system(KB(8)); } diff --git a/custom/4coder_default_framework_variables.cpp b/custom/4coder_default_framework_variables.cpp index 354cb40a..4c442a42 100644 --- a/custom/4coder_default_framework_variables.cpp +++ b/custom/4coder_default_framework_variables.cpp @@ -80,6 +80,7 @@ global i32 fcoder_mode = FCoderMode_Original; global ID_Pos_Jump_Location prev_location = {}; +global Arena global_permanent_arena = {}; global Arena global_config_arena = {}; global Config_Data global_config = {}; diff --git a/custom/4coder_default_hooks.cpp b/custom/4coder_default_hooks.cpp index a4538b11..c89d16f5 100644 --- a/custom/4coder_default_hooks.cpp +++ b/custom/4coder_default_hooks.cpp @@ -22,7 +22,10 @@ CUSTOM_DOC("Default command for responding to a startup event") { def_audio_init(); - Audio_Clip test_clip = audio_clip_from_wav_file_name("W:\\4ed\\audio_test\\raygun_zap.wav"); + Scratch_Block scratch(app); + FILE *file = def_search_normal_fopen(scratch, "audio_test/raygun_zap.wav", "rb"); + Audio_Clip test_clip = audio_clip_from_wav_FILE(&global_permanent_arena, file); + fclose(file); local_persist Audio_Control test_control = {}; test_control.channel_volume[0] = 1.f; diff --git a/custom/4coder_default_include.cpp b/custom/4coder_default_include.cpp index 4a0d5d14..c8d19d99 100644 --- a/custom/4coder_default_include.cpp +++ b/custom/4coder_default_include.cpp @@ -11,6 +11,9 @@ #define FCODER_TRANSITION_TO 0 #endif +#include +#include + #include "4coder_base_types.h" #include "4coder_version.h" #include "4coder_table.h" @@ -57,6 +60,7 @@ #include "4coder_log_parser.h" #include "4coder_profile_inspect.h" #include "4coder_tutorial.h" +#include "4coder_search_list.h" //////////////////////////////// @@ -66,6 +70,8 @@ #include "4coder_system_allocator.cpp" #include "generated/lexer_cpp.h" +#include "4coder_file.cpp" + #define DYNAMIC_LINK_API #include "generated/custom_api.cpp" #define DYNAMIC_LINK_API @@ -131,6 +137,7 @@ #include "4coder_docs.cpp" #include "4coder_variables.cpp" #include "4coder_audio.cpp" +#include "4coder_search_list.cpp" #include "4coder_examples.cpp" diff --git a/custom/4coder_examples.cpp b/custom/4coder_examples.cpp index 291fd54f..04bb7c34 100644 --- a/custom/4coder_examples.cpp +++ b/custom/4coder_examples.cpp @@ -214,10 +214,11 @@ CUSTOM_COMMAND_SIG(music_start) CUSTOM_DOC("Starts the music.") { local_persist Audio_Clip the_music_clip = {}; - local_persist b32 initialized = false; - if (!initialized){ - initialized = true; - the_music_clip = audio_clip_from_wav_file_name("W:\\4ed\\audio_test\\chtulthu.wav"); + if (the_music_clip.sample_count == 0){ + Scratch_Block scratch(app); + FILE *file = def_search_normal_fopen(scratch, "audio_test/chtulthu.wav", "rb"); + the_music_clip = audio_clip_from_wav_FILE(&global_permanent_arena, file); + fclose(file); } if (!def_audio_is_playing(&the_music_control)){ @@ -238,10 +239,11 @@ CUSTOM_COMMAND_SIG(hit_sfx) CUSTOM_DOC("Play the hit sound effect") { local_persist Audio_Clip the_hit_clip = {}; - local_persist b32 initialized = false; - if (!initialized){ - initialized = true; - the_hit_clip = audio_clip_from_wav_file_name("W:\\4ed\\audio_test\\hit.wav"); + if (the_hit_clip.sample_count == 0){ + Scratch_Block scratch(app); + FILE *file = def_search_normal_fopen(scratch, "audio_test/hit.wav", "rb"); + the_hit_clip = audio_clip_from_wav_FILE(&global_permanent_arena, file); + fclose(file); } local_persist u32 index = 0; diff --git a/custom/4coder_file.cpp b/custom/4coder_file.cpp index 16ab21b3..c702e51a 100644 --- a/custom/4coder_file.cpp +++ b/custom/4coder_file.cpp @@ -12,14 +12,17 @@ #include function String_Const_u8 -file_load_all(Arena *arena, FILE *file){ - fseek(file, 0, SEEK_END); - u64 size = ftell(file); - fseek(file, 0, SEEK_SET); - u8 *buffer = push_array(arena, u8, size + 1); - fread(buffer, 1, size, file); - buffer[size] = 0; - return(SCu8(buffer, size)); +data_from_file(Arena *arena, FILE *file){ + String_Const_u8 result = {}; + if (file != 0){ + fseek(file, 0, SEEK_END); + result.size = ftell(file); + fseek(file, 0, SEEK_SET); + result.str = push_array(arena, u8, result.size + 1); + fread(result.str, 1, result.size, file); + result.str[result.size] = 0; + } + return(result); } // BOTTOM diff --git a/custom/4coder_project_commands.cpp b/custom/4coder_project_commands.cpp index 5abe56f6..937075d3 100644 --- a/custom/4coder_project_commands.cpp +++ b/custom/4coder_project_commands.cpp @@ -642,6 +642,9 @@ set_current_project(Application_Links *app, Project *project, Config *parsed){ print_feedback = true; + // NOTE(allen): Set the normal search list's project slot + def_search_project_path = current_project.dir; + // Open all project files for (i32 i = 0; i < current_project.load_path_array.count; ++i){ Project_File_Load_Path *load_path = ¤t_project.load_path_array.paths[i]; diff --git a/custom/4coder_search_list.cpp b/custom/4coder_search_list.cpp index 63b3e3e7..63989c11 100644 --- a/custom/4coder_search_list.cpp +++ b/custom/4coder_search_list.cpp @@ -10,7 +10,7 @@ // TOP //////////////////////////////// -// NOTE(allen): Search List Functions +// NOTE(allen): Search List Builders function void def_search_list_add_path(Arena *arena, List_String_Const_u8 *list, String_Const_u8 path){ @@ -24,6 +24,17 @@ def_search_list_add_system_path(Arena *arena, List_String_Const_u8 *list, System string_list_push(arena, list, path_string); } +function void +def_search_normal_load_list(Arena *arena, List_String_Const_u8 *list){ + if (def_search_project_path.size > 0){ + def_search_list_add_path(arena, list, def_search_project_path); + } + def_search_list_add_system_path(arena, list, SystemPath_Binary); +} + +//////////////////////////////// +// NOTE(allen): Search List Functions + function String_Const_u8 def_get_full_path(Arena *arena, List_String_Const_u8 *list, String_Const_u8 relative){ String_Const_u8 result = {}; @@ -55,5 +66,25 @@ def_get_full_path(Arena *arena, List_String_Const_u8 *list, String_Const_u8 rela return(result); } +function FILE* +def_search_fopen(Arena *arena, List_String_Const_u8 *list, char *file_name, char *opt){ + Temp_Memory_Block block(arena); + String_Const_u8 full_path = def_get_full_path(arena, list, SCu8(file_name)); + FILE *file = 0; + if (full_path.size > 0){ + file = fopen((char*)full_path.str, opt); + } + return(file); +} + +function FILE* +def_search_normal_fopen(Arena *arena, char *file_name, char *opt){ + Temp_Memory_Block block(arena); + List_String_Const_u8 list = {}; + def_search_normal_load_list(arena, &list); + FILE *file = def_search_fopen(arena, &list, file_name, opt); + return(file); +} + // BOTTOM diff --git a/custom/4coder_search_list.h b/custom/4coder_search_list.h index eb5b782d..ad2194c7 100644 --- a/custom/4coder_search_list.h +++ b/custom/4coder_search_list.h @@ -12,13 +12,23 @@ #if !defined(FRED_SEARCH_LIST_H) #define FRED_SEARCH_LIST_H +//////////////////////////////// +// NOTE(allen): Search List Builders + +function void def_search_add_path(Arena *arena, List_String_Const_u8 *list, String_Const_u8 path); +function void def_search_add_system_path(Arena *arena, List_String_Const_u8 *list, System_Path_Code path); + +global String_Const_u8 def_search_project_path = {}; + +function void def_search_normal_load_list(Arena *arena, List_String_Const_u8 *list); + //////////////////////////////// // NOTE(allen): Search List Functions -function void def_search_list_add_path(Arena *arena, List_String_Const_u8 *list, String_Const_u8 path); -function void def_search_list_add_system_path(Arena *arena, List_String_Const_u8 *list, System_Path_Code path); +function String_Const_u8 def_search_get_full_path(Arena *arena, List_String_Const_u8 *list, String_Const_u8 file_name); -function String_Const_u8 def_get_full_path(Arena *arena, List_String_Const_u8 *list, String_Const_u8 file_name); +function FILE *def_search_fopen(Arena *arena, List_String_Const_u8 *list, char *file_name, char *opt); +function FILE *def_search_normal_fopen(Arena *arena, char *file_name, char *opt); #endif diff --git a/custom/generated/command_metadata.h b/custom/generated/command_metadata.h index ccb589f8..550bec6c 100644 --- a/custom/generated/command_metadata.h +++ b/custom/generated/command_metadata.h @@ -295,7 +295,7 @@ static Command_Metadata fcoder_metacmd_table[250] = { { PROC_LINKS(click_set_cursor_if_lbutton, 0), false, "click_set_cursor_if_lbutton", 27, "If the mouse left button is pressed, sets the cursor position to the mouse position.", 84, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 243 }, { PROC_LINKS(click_set_mark, 0), false, "click_set_mark", 14, "Sets the mark position to the mouse position.", 45, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 256 }, { PROC_LINKS(clipboard_record_clip, 0), false, "clipboard_record_clip", 21, "In response to a new clipboard contents events, saves the new clip onto the clipboard history", 93, "W:\\4ed\\code\\custom\\4coder_clipboard.cpp", 39, 7 }, -{ PROC_LINKS(close_all_code, 0), false, "close_all_code", 14, "Closes any buffer with a filename ending with an extension configured to be recognized as a code file type.", 107, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 844 }, +{ PROC_LINKS(close_all_code, 0), false, "close_all_code", 14, "Closes any buffer with a filename ending with an extension configured to be recognized as a code file type.", 107, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 847 }, { PROC_LINKS(close_build_panel, 0), false, "close_build_panel", 17, "If the special build panel is open, closes it.", 46, "W:\\4ed\\code\\custom\\4coder_build_commands.cpp", 44, 174 }, { PROC_LINKS(close_panel, 0), false, "close_panel", 11, "Closes the currently active panel if it is not the only panel open.", 67, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 674 }, { PROC_LINKS(command_documentation, 0), true, "command_documentation", 21, "Prompts the user to select a command then loads a doc buffer for that item", 74, "W:\\4ed\\code\\custom\\4coder_docs.cpp", 34, 190 }, @@ -309,8 +309,8 @@ static Command_Metadata fcoder_metacmd_table[250] = { { PROC_LINKS(decrease_face_size, 0), false, "decrease_face_size", 18, "Decrease the size of the face used by the current buffer.", 57, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 757 }, { PROC_LINKS(default_file_externally_modified, 0), false, "default_file_externally_modified", 32, "Notes the external modification of attached files by printing a message.", 72, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 2062 }, { PROC_LINKS(default_startup, 0), false, "default_startup", 15, "Default command for responding to a startup event", 49, "W:\\4ed\\code\\custom\\4coder_default_hooks.cpp", 43, 7 }, -{ PROC_LINKS(default_try_exit, 0), false, "default_try_exit", 16, "Default command for responding to a try-exit event", 50, "W:\\4ed\\code\\custom\\4coder_default_hooks.cpp", 43, 34 }, -{ PROC_LINKS(default_view_input_handler, 0), false, "default_view_input_handler", 26, "Input consumption loop for default view behavior", 48, "W:\\4ed\\code\\custom\\4coder_default_hooks.cpp", 43, 78 }, +{ PROC_LINKS(default_try_exit, 0), false, "default_try_exit", 16, "Default command for responding to a try-exit event", 50, "W:\\4ed\\code\\custom\\4coder_default_hooks.cpp", 43, 37 }, +{ PROC_LINKS(default_view_input_handler, 0), false, "default_view_input_handler", 26, "Input consumption loop for default view behavior", 48, "W:\\4ed\\code\\custom\\4coder_default_hooks.cpp", 43, 81 }, { PROC_LINKS(delete_alpha_numeric_boundary, 0), false, "delete_alpha_numeric_boundary", 29, "Delete characters between the cursor position and the first alphanumeric boundary to the right.", 95, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 161 }, { PROC_LINKS(delete_char, 0), false, "delete_char", 11, "Deletes the character to the right of the cursor.", 49, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 79 }, { PROC_LINKS(delete_current_scope, 0), false, "delete_current_scope", 20, "Deletes the braces surrounding the currently selected scope. Leaves the contents within the scope.", 99, "W:\\4ed\\code\\custom\\4coder_scope_commands.cpp", 44, 112 }, @@ -337,7 +337,7 @@ static Command_Metadata fcoder_metacmd_table[250] = { { PROC_LINKS(goto_prev_jump_no_skips, 0), false, "goto_prev_jump_no_skips", 23, "If a buffer containing jump locations has been locked in, goes to the previous jump in the buffer, and does not skip sub jump locations.", 136, "W:\\4ed\\code\\custom\\4coder_jump_sticky.cpp", 41, 511 }, { PROC_LINKS(hide_filebar, 0), false, "hide_filebar", 12, "Sets the current view to hide it's filebar.", 43, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 704 }, { PROC_LINKS(hide_scrollbar, 0), false, "hide_scrollbar", 14, "Sets the current view to hide it's scrollbar.", 45, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 690 }, -{ PROC_LINKS(hit_sfx, 0), false, "hit_sfx", 7, "Play the hit sound effect", 25, "W:\\4ed\\code\\custom\\4coder_examples.cpp", 38, 237 }, +{ PROC_LINKS(hit_sfx, 0), false, "hit_sfx", 7, "Play the hit sound effect", 25, "W:\\4ed\\code\\custom\\4coder_examples.cpp", 38, 238 }, { PROC_LINKS(hms_demo_tutorial, 0), false, "hms_demo_tutorial", 17, "Tutorial for built in 4coder bindings and features.", 51, "W:\\4ed\\code\\custom\\4coder_tutorial.cpp", 38, 869 }, { PROC_LINKS(if0_off, 0), false, "if0_off", 7, "Surround the range between the cursor and mark with an '#if 0' and an '#endif'", 78, "W:\\4ed\\code\\custom\\4coder_combined_write_commands.cpp", 53, 70 }, { PROC_LINKS(if_read_only_goto_position, 0), false, "if_read_only_goto_position", 26, "If the buffer in the active view is writable, inserts a character, otherwise performs goto_jump_at_cursor.", 106, "W:\\4ed\\code\\custom\\4coder_jump_sticky.cpp", 41, 564 }, @@ -371,7 +371,7 @@ static Command_Metadata fcoder_metacmd_table[250] = { { PROC_LINKS(list_all_locations_of_type_definition_of_identifier, 0), false, "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, "W:\\4ed\\code\\custom\\4coder_search.cpp", 36, 224 }, { PROC_LINKS(list_all_substring_locations, 0), false, "list_all_substring_locations", 28, "Queries the user for a string and lists all case-sensitive substring matches found in all open buffers.", 103, "W:\\4ed\\code\\custom\\4coder_search.cpp", 36, 174 }, { PROC_LINKS(list_all_substring_locations_case_insensitive, 0), false, "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, "W:\\4ed\\code\\custom\\4coder_search.cpp", 36, 186 }, -{ PROC_LINKS(load_project, 0), false, "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, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 864 }, +{ PROC_LINKS(load_project, 0), false, "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, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 867 }, { PROC_LINKS(load_theme_current_buffer, 0), false, "load_theme_current_buffer", 25, "Parse the current buffer as a theme file and add the theme to the theme list. If the buffer has a .4coder postfix in it's name, it is removed when the name is saved.", 165, "W:\\4ed\\code\\custom\\4coder_config.cpp", 36, 1667 }, { PROC_LINKS(load_themes_default_folder, 0), false, "load_themes_default_folder", 26, "Loads all the theme files in the default theme folder.", 54, "W:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 533 }, { PROC_LINKS(load_themes_hot_directory, 0), false, "load_themes_hot_directory", 25, "Loads all the theme files in the current hot directory.", 55, "W:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 545 }, @@ -413,9 +413,9 @@ static Command_Metadata fcoder_metacmd_table[250] = { { PROC_LINKS(multi_paste_interactive, 0), false, "multi_paste_interactive", 23, "Paste multiple lines from the clipboard history, controlled with arrow keys", 75, "W:\\4ed\\code\\custom\\4coder_clipboard.cpp", 39, 371 }, { PROC_LINKS(multi_paste_interactive_quick, 0), false, "multi_paste_interactive_quick", 29, "Paste multiple lines from the clipboard history, controlled by inputing the number of lines to paste", 100, "W:\\4ed\\code\\custom\\4coder_clipboard.cpp", 39, 380 }, { PROC_LINKS(music_start, 0), false, "music_start", 11, "Starts the music.", 17, "W:\\4ed\\code\\custom\\4coder_examples.cpp", 38, 213 }, -{ PROC_LINKS(music_stop, 0), false, "music_stop", 10, "Stops the music.", 16, "W:\\4ed\\code\\custom\\4coder_examples.cpp", 38, 231 }, -{ PROC_LINKS(open_all_code, 0), false, "open_all_code", 13, "Open all code in the current directory. File types are determined by extensions. An extension is considered code based on the extensions specified in 4coder.config.", 164, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 850 }, -{ PROC_LINKS(open_all_code_recursive, 0), false, "open_all_code_recursive", 23, "Works as open_all_code but also runs in all subdirectories.", 59, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 856 }, +{ PROC_LINKS(music_stop, 0), false, "music_stop", 10, "Stops the music.", 16, "W:\\4ed\\code\\custom\\4coder_examples.cpp", 38, 232 }, +{ PROC_LINKS(open_all_code, 0), false, "open_all_code", 13, "Open all code in the current directory. File types are determined by extensions. An extension is considered code based on the extensions specified in 4coder.config.", 164, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 853 }, +{ PROC_LINKS(open_all_code_recursive, 0), false, "open_all_code_recursive", 23, "Works as open_all_code but also runs in all subdirectories.", 59, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 859 }, { PROC_LINKS(open_file_in_quotes, 0), false, "open_file_in_quotes", 19, "Reads a filename from surrounding '\"' characters and attempts to open the corresponding file.", 94, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1574 }, { PROC_LINKS(open_in_other, 0), false, "open_in_other", 13, "Interactively opens a file in the other panel.", 46, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 2056 }, { PROC_LINKS(open_long_braces, 0), false, "open_long_braces", 16, "At the cursor, insert a '{' and '}' separated by a blank line.", 62, "W:\\4ed\\code\\custom\\4coder_combined_write_commands.cpp", 53, 46 }, @@ -436,9 +436,9 @@ static Command_Metadata fcoder_metacmd_table[250] = { { PROC_LINKS(profile_disable, 0), false, "profile_disable", 15, "Prevent 4coder's self profiler from gathering new profiling information.", 72, "W:\\4ed\\code\\custom\\4coder_profile.cpp", 37, 219 }, { PROC_LINKS(profile_enable, 0), false, "profile_enable", 14, "Allow 4coder's self profiler to gather new profiling information.", 65, "W:\\4ed\\code\\custom\\4coder_profile.cpp", 37, 212 }, { PROC_LINKS(profile_inspect, 0), true, "profile_inspect", 15, "Inspect all currently collected profiling information in 4coder's self profiler.", 80, "W:\\4ed\\code\\custom\\4coder_profile_inspect.cpp", 45, 886 }, -{ PROC_LINKS(project_command_lister, 0), false, "project_command_lister", 22, "Open a lister of all commands in the currently loaded project.", 62, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1290 }, -{ PROC_LINKS(project_fkey_command, 0), false, "project_fkey_command", 20, "Run an 'fkey command' configured in a project.4coder file. Determines the index of the 'fkey command' by which function key or numeric key was pressed to trigger the command.", 175, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 872 }, -{ PROC_LINKS(project_go_to_root_directory, 0), false, "project_go_to_root_directory", 28, "Changes 4coder's hot directory to the root directory of the currently loaded project. With no loaded project nothing hapepns.", 125, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 898 }, +{ PROC_LINKS(project_command_lister, 0), false, "project_command_lister", 22, "Open a lister of all commands in the currently loaded project.", 62, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1293 }, +{ PROC_LINKS(project_fkey_command, 0), false, "project_fkey_command", 20, "Run an 'fkey command' configured in a project.4coder file. Determines the index of the 'fkey command' by which function key or numeric key was pressed to trigger the command.", 175, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 875 }, +{ PROC_LINKS(project_go_to_root_directory, 0), false, "project_go_to_root_directory", 28, "Changes 4coder's hot directory to the root directory of the currently loaded project. With no loaded project nothing hapepns.", 125, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 901 }, { PROC_LINKS(query_replace, 0), false, "query_replace", 13, "Queries the user for two strings, and incrementally replaces every occurence of the first string with the second string.", 120, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1280 }, { PROC_LINKS(query_replace_identifier, 0), false, "query_replace_identifier", 24, "Queries the user for a string, and incrementally replace every occurence of the word or token found at the cursor with the specified string.", 140, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1301 }, { PROC_LINKS(query_replace_selection, 0), false, "query_replace_selection", 23, "Queries the user for a string, and incrementally replace every occurence of the string found in the selected range with the specified string.", 141, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1317 }, @@ -477,10 +477,10 @@ static Command_Metadata fcoder_metacmd_table[250] = { { PROC_LINKS(set_mark, 0), false, "set_mark", 8, "Sets the mark to the current position of the cursor.", 52, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 115 }, { PROC_LINKS(set_mode_to_notepad_like, 0), false, "set_mode_to_notepad_like", 24, "Sets the edit mode to Notepad like.", 35, "W:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 503 }, { PROC_LINKS(set_mode_to_original, 0), false, "set_mode_to_original", 20, "Sets the edit mode to 4coder original.", 38, "W:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 497 }, -{ PROC_LINKS(setup_build_bat, 0), false, "setup_build_bat", 15, "Queries the user for several configuration options and initializes a new build batch script.", 92, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1239 }, -{ PROC_LINKS(setup_build_bat_and_sh, 0), false, "setup_build_bat_and_sh", 22, "Queries the user for several configuration options and initializes a new build batch script.", 92, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1251 }, -{ PROC_LINKS(setup_build_sh, 0), false, "setup_build_sh", 14, "Queries the user for several configuration options and initializes a new build shell script.", 92, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1245 }, -{ PROC_LINKS(setup_new_project, 0), false, "setup_new_project", 17, "Queries the user for several configuration options and initializes a new 4coder project with build scripts for every OS.", 120, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1232 }, +{ PROC_LINKS(setup_build_bat, 0), false, "setup_build_bat", 15, "Queries the user for several configuration options and initializes a new build batch script.", 92, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1242 }, +{ PROC_LINKS(setup_build_bat_and_sh, 0), false, "setup_build_bat_and_sh", 22, "Queries the user for several configuration options and initializes a new build batch script.", 92, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1254 }, +{ PROC_LINKS(setup_build_sh, 0), false, "setup_build_sh", 14, "Queries the user for several configuration options and initializes a new build shell script.", 92, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1248 }, +{ PROC_LINKS(setup_new_project, 0), false, "setup_new_project", 17, "Queries the user for several configuration options and initializes a new 4coder project with build scripts for every OS.", 120, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1235 }, { PROC_LINKS(show_filebar, 0), false, "show_filebar", 12, "Sets the current view to show it's filebar.", 43, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 697 }, { PROC_LINKS(show_scrollbar, 0), false, "show_scrollbar", 14, "Sets the current view to show it's scrollbar.", 45, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 683 }, { PROC_LINKS(show_the_log_graph, 0), true, "show_the_log_graph", 18, "Parses *log* and displays the 'log graph' UI", 44, "W:\\4ed\\code\\custom\\4coder_log_parser.cpp", 40, 993 }, diff --git a/docs/4ed_doc_custom_api_main.cpp b/docs/4ed_doc_custom_api_main.cpp index 6d22c1fe..4e853f62 100644 --- a/docs/4ed_doc_custom_api_main.cpp +++ b/docs/4ed_doc_custom_api_main.cpp @@ -51,7 +51,7 @@ int main(void){ } printf("documenting %s\n", file_name.str); - String_Const_u8 text = file_load_all(&arena, file); + String_Const_u8 text = data_from_file(&arena, file); fclose(file); API_Definition_List def_list = {}; diff --git a/platform_win32/win32_4ed.cpp b/platform_win32/win32_4ed.cpp index 52c90a4d..9a1f18b4 100644 --- a/platform_win32/win32_4ed.cpp +++ b/platform_win32/win32_4ed.cpp @@ -12,6 +12,8 @@ #define FPS 60 #define frame_useconds (1000000 / FPS) +#include + #include "4coder_base_types.h" #include "4coder_version.h" #include "4coder_events.h" @@ -1751,6 +1753,7 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdS List_String_Const_u8 search_list = {}; def_search_list_add_system_path(scratch, &search_list, SystemPath_CurrentDirectory); def_search_list_add_system_path(scratch, &search_list, SystemPath_Binary); + String_Const_u8 custom_file_names[2] = {}; i32 custom_file_count = 1; if (plat_settings.custom_dll != 0){