看了太多版本,到最后不能解决输入问题,网上很多版本都是在Windows下调用CMD的,在linux不能使用
经过半天的百度,还是决定去Google,成功找到大神解答。
网上给出的能解决输入问题的有这个方案:
"cmd": ["g++", "$file", "-o", "${file_path}/${file_base_name}"],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c, source.c++, source.cxx, source.cpp",
"variants":
[
{
"name": "Run",
"shell": true,
"cmd": ["gnome-terminal -e 'bash -c \"${file_path}/${file_base_name};echo;echo; echo Press ENTER to continue; read line;exit; exec bash\"'"]
}
]
}
但是我首先碰到了问题:
gnome-terminal没有安装,于是安装:
sudo apt-get remove gnome-terminal && sudo apt-get install gnome-terminal
随后出现问题:
(gnome-terminal:22242): Gtk-ERROR **: GTK+ 2.x symbols detected. Using GTK+ 2.x and GTK+ 3 in the same process is not supported
看网上大神说的意思是:
“由于我们安装的支持中文的库使用的是GTK2.0的图形库,而gnome-terminal使用的是GTK3.0的库”
于是Google得到答案,亲测可用:
{
"cmd": ["g++", "$file", "-o", "${file_path}/${file_base_name}"],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c, source.c++, source.cxx, source.cpp",
"variants":
[
{
"name": "Run",
//use this if you want to input other command after programm execution
// "shell_cmd": "xterm -e '${file_path}/${file_base_name}; bash'",
//or you can use the below setting if you just want to execute this program
"shell_cmd": "xterm -hold -e ${file_path}/${file_base_name}",
}
]
}