Salutations,
I've been trying to use the file path of the active buffer as a parameter for my build.bat. This means that whenever I hit my FKey command for building, it should also include the filepath of the buffer I was inside when I hit the F-key. This is useful for practising when I just want to compile one executable for one c/c++-file.
From 4coder_project_commands.cpp
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 | function void
prj_exec_command(Application_Links *app, Variable_Handle cmd_var){
Scratch_Block scratch(app);
String_ID os_id = vars_save_string_lit(OS_NAME);
String8 cmd = vars_string_from_var(scratch, vars_read_key(cmd_var, os_id));
if (cmd.size > 0){
// NOTE(Bobby): Uses the file path of the active buffer as a parameter
View_ID ActiveView = get_active_view(app, Access_Visible);
Buffer_ID ActiveBuffer = view_get_buffer(app, ActiveView, Access_Visible);
// NOTE(Bobby): Is this a bug?
// NOTE(Bobby): CmdWithBufferParam sometimes contains characters from BufferName
// or just junk data, why?
String_Const_u8 BufferName = push_buffer_file_name(app, scratch, ActiveBuffer);
String_Const_u8 CmdWithBufferParam = push_stringf(scratch, "%s %s", cmd.str, BufferName.str);
String_Const_u8 ch = SCu8("\n---------------------------\n");
log_string(app, ch);
log_string(app, CmdWithBufferParam);
log_string(app, ch);
...
cmd = CmdWithBufferParam;
}
...
}
|
Notice how the 'BufferName' string is always correct but 'cmd' string contains data from 'BufferName'.
| *log*:
---------------------------
build.batcoder_bC:\Program Files\4coder\4coder_bobby\4coder_bobby.cpp C:\Program Files\4coder\4coder_bobby\4coder_bobby.cpp
---------------------------
|
This happens for other c/cpp files as well. For instance, doing this from any cpp file from the custom folder in 4coder will also yield the same bug.
This is the correct output:
| *log*:
---------------------------
build.bat C:\Program Files\4coder\4coder_bobby\4coder_bobby.cpp
---------------------------
|
Sometimes it works, sometimes it doesn't. But I'm wondering, am I doing something wrong?