First, the C compilation system configuration file is as follows:
{
"shell":true,
"cmd": "cmd /c g++ -fexec-charset=GBK ${file} -o ${file_path}/${file_base_name} && start cmd /c \"${file_path}/${file_base_name} && pause\"",
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c",
"variants":
[
{
"name": "Run",
"cmd": "cmd /c && start cmd /c \"${file_path}/${file_base_name} && pause\""
}
]
}
The key statement that determines the final output window is cmd is:
"cmd": "cmd /c g++ -fexec-charset=GBK ${file} -o ${file_path}/${file_base_name} && start cmd /c \"${file_path}/${file_base_name} && pause\"",
This sentence contains the two processes of compiling the file and running the generated binary file.
Assuming that the file to be compiled is test.c and the path is D: \ code \ test.c, the effect of the above command is the same as the following command manually typed in the cmd window:
g++ -fexec-charset=GBK D:\code\test.c -o D:\code\test && D:\code\test && pause
Explanation:
1) -fexec-charset = GBK: In order to prevent the Chinese character output from the cmd window
2) start cmd / c: restart a cmd window
Second, the Python compilation system configuration file is as follows:
{
"encoding":"cp936",
"shell":true,
"cmd": "start cmd /k python -u ${file}",
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.python"
}