Beginner - How the customization works ?

Hello, I'm beginner and a create a custom_layer.cpp and I call buildsuper.bat

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include "4coder_default_include.cpp"

void custom_keys(Bind_Helper *context) {

	begin_map(context, mapid_file); {
		bind_vanilla_keys(context, write_character);

	} end_map(context);

	begin_map(context, default_code_map); {
		inherit_map(context, mapid_file);

	} end_map(context);

	begin_map(context, default_lister_ui_map); {
		bind_vanilla_keys(context, lister__write_character);

	} end_map(context);
}

extern "C" int32_t
get_bindings(void *data, int32_t size){
    Bind_Helper context_ = begin_bind_helper(data, size);
    Bind_Helper *context = &context_;
    
    set_all_default_hooks(context);

	custom_keys(context);

    int32_t result = end_bind_helper(context);
    return(result);
}


So when I launch 4Coder all default shortcut don't work anymore, why ?
Does it exist a function for bind default shortcut ?

Edited by Adrien on Reason: Initial post
I think you can call "default_keys(context);" before "custom_keys(context);" to have the default bindings and override the ones you want.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
extern "C" int32_t
get_bindings(void *data, int32_t size){
    Bind_Helper context_ = begin_bind_helper(data, size);
    Bind_Helper *context = &context_;
    
    set_all_default_hooks(context);

    default_keys(context);
    custom_keys(context);

    int32_t result = end_bind_helper(context);
    return(result);
}
Thank you !!!
But I have a last question if I want to use change_theme(Application_Links* app,
int32_t index)
.
1
change_theme(app, ..., ...);


App doesn't exist ?

Edited by Adrien on
If you want the set the default theme you should set it in the config.4coder file.

If you want to change it at run time, you can create a custom command, the first parameter of custom commands is always the Application_Links pointer.

1
2
3
4
5
6
7
8
CUSTOM_COMMAND_SIG( change_theme_command ) {
    change_theme( app, ... );
}

/*
That will create a function with this signature
void change_theme_command(struct Application_Links* app);
*/
Alternatively you can look in "4coder_default_hooks.cpp" and make your own version of the start hook, which will be able to call change_theme, and then bind that start hook in get_bindings after set_all_default_hooks.