Configure source file directory in project.4coder

I tried to setup a 4coder project where the 4coder project file is in a misc folder and the sources are in a src folder. As I unterstand I have to open 4coder in the directory in which the project file is. If I try to open a file in 4coder the home directory is the misc folder. Is there any way to configure another home or the source directory within the 4coder configuration?

Edited by Jens Scharmann on Reason: Initial post
I'm not sure I understand properly what you're asking, and I don't usually use the 4coder project system but when you use the load_project command (alt + x > load_project), 4coder uses the current hot directory (the last folder where you opened a file). So you could open the project file and use load_project to load the project from the misc folder.

If your file structure is something like:


> misc
>> project.4coder
> src
>> main.c


Then in the load_paths "variable" in the project file you can specify a relative path (..\\src). For example using the default 4coder project (look at load_paths_custom ):
 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
version(1);
project_name = "4coder custom";

patterns = {
"*.c",
"*.cpp",
"*.h",
"*.m",
"*.mm",
"*.bat",
"*.sh",
"*.4coder",
"*.txt",
};
blacklist_patterns = {
".*",
};
load_paths_custom = {
 {"..\\src"},
};
load_paths = {
 { load_paths_custom, .os = "win"  },
 { load_paths_custom, .os = "linux"},
 { load_paths_custom, .os = "mac"  },
};

build_super_x64_win32 = "custom\\bin\\buildsuper_x64-win.bat";
build_super_x86_win32 = "custom\\bin\\buildsuper_x86-win.bat";
build_super_x64_linux  = "custom/bin/buildsuper_x64-linux.sh";
build_super_x86_linux  = "custom/bin/buildsuper_x86-linux.sh";
build_super_x64_mac  = "custom/bin/buildsuper_x64-mac.sh";

command_list = {
 { .name = "build super x64",
   .out = "*compilation*", .footer_panel = true, .save_dirty_files = true,
   .cmd = { {build_super_x64_win32, .os ="win"  },
            {build_super_x64_linux , .os ="linux"},
            {build_super_x64_mac , .os ="mac"  }, }, },

 { .name = "build super x86",
   .out = "*compilation*", .footer_panel = true, .save_dirty_files = true,
   .cmd = { {build_super_x86_win32, .os ="win" },
            {build_super_x86_linux, .os ="linux" }, }, },

 { .name = "build C++ lexer generator",
   .out = "*compilation*", .footer_panel = true, .save_dirty_files = true,
   .cmd = { {"custom\\bin\\build_one_time custom\\languages\\4coder_cpp_lexer_gen.cpp ..\\build", .os ="win" },
           }, },

 { .name = "build token tester",
   .out = "*compilation*", .footer_panel = true, .save_dirty_files = true,
   .cmd = { {"custom\\bin\\build_one_time custom\\languages\\4coder_cpp_lexer_test.cpp ..\\build", .os = "win" },
           }, },

 { .name = "run one time",
   .out = "*run*", .footer_panel = false, .save_dirty_files = false,
   .cmd = { {"pushd ..\\build & one_time", .os = "win" },
           }, },
};

fkey_command[1] = "build super x64";
fkey_command[2] = "build C++ lexer generator";
fkey_command[3] = "build token tester";
fkey_command[4] = "run one time";
fkey_command[5] = "build super x86";
Thanks for the reply. Your described project structure is exactly what I want but I hope to open 4coder without having to load the project file by hand or have to change from misc to src at the beginning. Yesterday I saw that files specified through load_paths or load_custom_paths are opened as a buffer in the background. This is enough at the moment but I would highly appreciate if I can set the home directory (the path initially selected by CTRL+O to the source directory whereas the project file is in misc.
If you have access to the customization layer you could use set_hot_directory to set the project path before and after loading the project file. If you enabled automatically_load_project in config.4coder it should load your project at startup.

In 4coder_default_hooks.cpp

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
CUSTOM_COMMAND_SIG(default_startup)
CUSTOM_DOC("Default command for responding to a startup event")
{
    ProfileScope(app, "default startup");

    set_hot_directory( app, string_u8_litexpr("D:\\project\\misc\\") );

    User_Input input = get_current_input(app);
    if (match_core_code(&input, CoreCode_Startup)){
        String_Const_u8_Array file_names = input.event.core.file_names;
        load_themes_default_folder(app);
        default_4coder_initialize(app, file_names);
        default_4coder_side_by_side_panels(app, file_names);
        if (global_config.automatically_load_project){
            load_project(app);
        }
    }

    set_hot_directory( app, string_u8_litexpr("D:\\project\\src\\") );
}


It might work with relative paths but I haven't tested.

Edited by Simon Anciaux on Reason: Double backslash in string literal
Thank you I will try it tomorrow
I find a few minutes to try it today. I cannot build the custom layer, I got an error that custom_4coder.dll could not be opened. It seems that the lib file is missing. I'm fairly new to C++ and other than C++ code itself, the build pipeline is a white map for me.
I have the paid version of 4coder 4.1 and Visual Studio 2019 Community Edition installed.
Shouldn't the customization layer be part of the paid version? I found your forum post and the wiki-page but they are for pre-4.1.
If you have the paid version you should be good to go.

You should be able to just run the build script that should be in 4coder/custom/bin. For example on windows 64bit run buildsuper_x64-win.bat.

Note that you should quit 4coder before running the script as it needs to overwrite custom_4coder.dll. Is that the error you're having ?
YES it is... Thanks a lot I will play a bit around with your suggest set_hot_directory method and maybe a few other things of the documentation. Thanks a lot.
Thanks again for your help. Relative paths didn't work but i managed to get the project directory so I stripped of the last folder (misc) and replaced it with my source folder (src) and then set it as hot directory, works like a charm.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
CUSTOM_COMMAND_SIG(default_startup)
CUSTOM_DOC("Default command for responding to a startup event")
{
    ProfileScope(app, "default startup");
    User_Input input = get_current_input(app);
    if (match_core_code(&input, CoreCode_Startup)){
        String_Const_u8_Array file_names = input.event.core.file_names;
        load_themes_default_folder(app);
        default_4coder_initialize(app, file_names);
        default_4coder_side_by_side_panels(app, file_names);
        if (global_config.automatically_load_project){
            load_project(app);
        }
    }
	
	Scratch_Block scratch(app);	
	String_Const_u8 project_Dir = current_project.dir;
	String_Const_u8 parent_Dir = string_remove_last_folder(project_Dir);
	set_hot_directory(app, push_u8_stringf(scratch, "%.*ssrc/", string_expand(parent_Dir)));
	
}