4coder/custom/4coder_default_bindings.cpp

65 lines
2.0 KiB
C++

/*
4coder_default_bidings.cpp - Supplies the default bindings used for default 4coder behavior.
*/
// TOP
#if !defined(FCODER_DEFAULT_BINDINGS_CPP)
#define FCODER_DEFAULT_BINDINGS_CPP
#include "4coder_default_include.cpp"
// NOTE(allen): Users can declare their own managed IDs here.
#include "4coder_default_map.cpp"
#include "4coder_mac_map.cpp"
#include "generated/managed_id_metadata.cpp"
void
custom_layer_init(Application_Links *app){
Thread_Context *tctx = get_thread_context(app);
// NOTE(allen): setup for default framework
async_task_handler_init(app, &global_async_system);
code_index_init();
buffer_modified_set_init();
Profile_Global_List *list = get_core_profile_list(app);
ProfileThreadName(tctx, list, string_u8_litexpr("main"));
initialize_managed_id_metadata(app);
set_default_color_scheme(app);
// NOTE(allen): default hooks and command maps
set_all_default_hooks(app);
mapping_init(tctx, &framework_mapping);
setup_default_mapping(&framework_mapping, mapid_global, mapid_file, mapid_code);
}
function void
setup_built_in_mapping(Application_Links *app, String_Const_u8 name, Mapping *mapping, i64 global_id, i64 file_id, i64 code_id){
Thread_Context *tctx = get_thread_context(app);
if (string_match(name, string_u8_litexpr("default"))){
mapping_release(tctx, mapping);
mapping_init(tctx, mapping);
setup_default_mapping(mapping, global_id, file_id, code_id);
}
else if (string_match(name, string_u8_litexpr("mac-default"))){
mapping_release(tctx, mapping);
mapping_init(tctx, mapping);
setup_mac_mapping(mapping, global_id, file_id, code_id);
}
else if (string_match(name, string_u8_litexpr("choose"))){
mapping_release(tctx, mapping);
mapping_init(tctx, mapping);
#if OS_MAC
setup_mac_mapping(mapping, global_id, file_id, code_id);
#else
setup_default_mapping(mapping, global_id, file_id, code_id);
#endif
}
}
#endif //FCODER_DEFAULT_BINDINGS
// BOTTOM