一、C編譯系統配置文件如下:
{
"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\""
}
]
}
其中決定最終輸出窗口是cmd的關鍵語句爲:
"cmd": "cmd /c g++ -fexec-charset=GBK ${file} -o ${file_path}/${file_base_name} && start cmd /c \"${file_path}/${file_base_name} && pause\"",
這句語句包含了編譯文件並運行生成的二進制文件兩個過程。
假設要編譯的文件是test.c文件,路徑爲D:\code\test.c,則以上命令的效果同以下手動在cmd窗口敲的命令等同:
g++ -fexec-charset=GBK D:\code\test.c -o D:\code\test && D:\code\test && pause
解釋:
1)-fexec-charset=GBK:爲了防止cmd窗口輸出中文亂碼
2)start cmd /c:重新啓動一個cmd窗口
二、python編譯系統配置文件如下:
{
"encoding":"cp936",
"shell":true,
"cmd": "start cmd /k python -u ${file}",
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.python"
}