Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "4coder_default_include.cpp"
- enum keymaps {
- keymap_works = 0,
- keymap_doesnt = 1,
- };
- CUSTOM_COMMAND_SIG(repro_unreachable) {
- Query_Bar qb = {0};
- qb.prompt = make_lit_string("/u/teryor ");
- qb.string = make_lit_string("is an idiot");
- start_query_bar(app, &qb, 0);
- User_Input in = get_user_input(app, EventOnAnyKey, EventOnEsc);
- }
- CUSTOM_COMMAND_SIG(repro_set_map_fail) {
- View_Summary view = get_active_view(app, AccessAll);
- Buffer_Summary buffer = get_buffer(app, view.buffer_id, AccessAll);
- // This should _NOT_ crash, as it fails silently
- Assert(buffer_set_setting(app, &buffer, BufferSetting_MapID, keymap_doesnt));
- int32_t mapid;
- buffer_get_setting(app, &buffer, BufferSetting_MapID, &mapid);
- // This _should_ crash
- Assert(mapid == keymap_doesnt);
- // Feel free to comment this out to verify that keymap_doesnt has indeed
- // not been set, and that no commands can be run anymore.
- }
- START_HOOK_SIG(repro_start) {
- Buffer_Summary buffer = get_buffer_by_name(app, literal("*scratch*"), AccessAll);
- buffer_set_setting(app, &buffer, BufferSetting_MapID, keymap_works);
- return 0;
- }
- extern "C" int32_t
- get_bindings(void *data, int32_t size){
- Bind_Helper context_ = begin_bind_helper(data, size);
- Bind_Helper *context = &context_;
- set_start_hook(context, repro_start);
- begin_map(context, keymap_works);
- bind(context, ' ', MDFR_NONE, repro_set_map_fail);
- end_map(context);
- // Keys can be bound to other maps without problem:
- begin_map(context, keymap_doesnt);
- bind(context, ' ', MDFR_NONE, repro_unreachable);
- end_map(context);
- int32_t result = end_bind_helper(context);
- return(result);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement