sublime text terminus build cancel does nothing - sublime-text-plugin

The title says it all, build cancel does nothing, command pallet does nothing, keybind does nothing. I have changed the keybind from prefrences with this:
{ "keys": ["ctrl+alt+c"], "command": "cancel_build" },
I have added my own Python terminus build:
{
"target": "terminus_exec",
"cancel": "terminus_cancel_build",
"focus": true,
"cmd": ["python3", "-u", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.python",
"env": {"PYTHONIOENCODING": "utf-8"},
"windows": {
"cmd": ["py", "-u", "$file"],
},
"variants":
[
{
"name": "Syntax Check",
"cmd": ["python3", "-m", "py_compile", "$file"],
"windows": {
"cmd": ["py", "-m", "py_compile", "$file"],
}
}
]
}
(I am really new to sublime text and also to coding) Thanks in advance.
Edit: I am using Windows 10, in python installer I have selected the add to PATH option and changing keybind does nothing. I use this as my test file:
while True:
print("Stop it!")

There was not even a problem, the code I was running was so hard on my system that cancelling took ages. (Props to #OdatNurd for finding it)

Related

Sublime Build system for c++ in linux allowing input from file

I am using sublime in linux I am trying to compile and run my c++ program from sublime directly with INPUT taken from a file rather than STDIN.
Please help me with the code to be written in sublime build-file.
I got this code but its not working i think its for windows not for linux:
{
"cmd" : ["g++", "$file_name", "-o", "${file_base_name}.exe"],
"selector" : "source.c",
"shell":true,
"working_dir" : "$file_path",
"variants": [
{
"cmd": ["${file_base_name}" , "<" , "input.txt"],
"shell": true,
"name": "Run",
"working_dir" : "$file_path"
}
]
}
This is the final code which one needs to write in build system of sublime to compile and run taking input from a file.
{
"cmd": ["g++ -Wall ${file} -o ${file_base_name}"],
"working_dir": "${file_path}",
"selector": "source.c++",
"shell": true,
"working_dir" : "$file_path",
"variants": [
{
"cmd": [ "${file_path}/${file_base_name}<input.txt"],
"shell": true,
"name": "Run",
"working_dir" : "$file_path"
}
]
}
Thanks a lot MattDMo.
I suspect the reason it's not working is because g++ is creating a .exe file, and the build system is only looking for the source.c scope, whereas your code may be source.c++. Change the first two lines to the following:
"cmd" : ["g++", "$file", "-o", "${file_path}/${file_base_name}"],
"selector" : "source.c, source.c++",
and you should be all set.
I'll just add a config I use to load input from the file and display output in Sublime console ("Run in") or send output to other file ("Run in out"). Maybe someone will find it useful. (works for both Windows and Ubuntu)
{
"shell_cmd": "g++ \"${file}\" -o \"${file_path}/${file_base_name}\"",
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c, source.c++",
"variants":
[
{
"name": "Run in",
"shell_cmd": "g++ \"${file}\" -o \"${file_path}/${file_base_name}\" && \"${file_path}/${file_base_name}\" <$file_base_name.in"
},
{
"name": "Run in out",
"shell_cmd": "g++ \"${file}\" -o \"${file_path}/${file_base_name}\" && \"${file_path}/${file_base_name}\" <$file_base_name.in >$file_base_name.txt"
}
]
}

sublimegdb not working on osx 10.8

I am trying to use sublimegdb with sublime text 3, on OSX 10.8
I check I have gdb , but could not start the gdb with sublimegdb plugin.
I am testing with a simple C++ program test.cpp, I build a debug version with name test in same directory .
my project settings are:
{
"build-system":
{
"cmd":
[
"g++",
"${file}",
"-g",
"-o",
"${file_path}/${file_base_name}"
],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"selector": "source.c, source.c++",
"working_dir": "${file_path}"
},
"folders":
[
{
"follow_symlinks": true,
"path": "."
}
],
"settings":
{
"sublimegdb_commandline": "gdb -nx -readnow -fullname --interpreter=mi -args ./test",
"sublimegdb_workingdir": "."
}
}

Sublime Text 2 How To Change Default Runtime Shell Command For C++?

I'm trying to run a c++ program through sublime text 2. I do not want to add bash to my PATH. I want to change the default cmd command to the following:
./${file}
I looked all around in the c++ packages folder but only found the build.
I appreciate some help!
[EDIT]
My program builds correctly, but upon runtime I get this:
[Error 2] The system cannot find the file specified
[cmd: [u'bash', u'-c', u"g++ 'C:...]
[dir: C:\Users\...]
[path: C:/.../
[Finished]
[EDIT] As per requested, my build file.
{
"cmd": ["g++", "${file}", "-o", "${file_path}/${file_base_name}"],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c, source.c++",
"variants":
[
{
"name": "Run",
"cmd": ["bash", "-c", "g++ '${file}' -o '${file_path}/${file_base_name}' && '${file_path}/${file_base_name}'"]
}
]
}
{
"cmd": ["g++", "${file}", "-o", "${file_path}/${file_base_name}"],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c, source.c++",
"variants":
[
{
"name": "Run",
"cmd": ["${file_path}/${file_base_name}"]
}
]
}
Just drop the compilation command and retain only the executable invocation part. But remember, you have to compile before running otherwise the executable would not have got generated.

Sublime Text 2 Build System

I managed to get this build system doing the trick for me:
{
"working_dir": "${file_path}",
"cmd": ["g++", "${file}"],
"variants":
[
{
"name": "Run",
"shell": true,
"working_dir": "${file_path}",
"cmd": ["start", "a.exe"]
}
]
}
But I don't want the shell to close once if finishes. I want it to display a message like "Build process complete. Press any key to exit...". Is there any way to accomplish this?
Not the best solution, but I found out that adding a
while(true){}
to the end of the file makes it not close. Still waiting for a better solution tho.

Can't build C++ program using Sublime Text 2

I think many of you are using or used to use Sublime Text 2 editor. I have strange error: C++ programs can't be built.
My C++.sublime-build:
{
"cmd": ["g++", "${file}", "-o", "${file_path}/${file_base_name}"],
"working_dir": "${file_path}",
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"selector": "source.c, source.c++",
"variants":
[
{
"name": "Run",
"cmd": ["bash", "-c", "g++ '${file}' -o '${file_path}/${file_base_name}' && '${file_path}/${file_base_name}'"]
}
]
}
I found that when the cmd array contains ANY substituted expression like ${file} or $file, build doesn't start. Otherwise it starts.
It doesn't matter from compiler. When I've tried "cmd": ["notify-osd", "$file"], it didn't work; but with "cmd": ["notify-osd", "sometexthere"] it worked.
Compiling by-hand works right.
My program:
#include <iostream>
int main() {
std::cout << "Hello World";
}
I use Ubuntu 12.04, 32bit. Version of Sublime Editor: 2.0.1.
If it isn't the place where I could ask this question, please tell me what's the right one.
Edit your C++.sublime-build file....works like a charm.
{
"cmd": ["g++", "-Wall", "-Wextra", "-pedantic", "-std=c++11", "${file}", "-o", "${file_path}/${file_base_name}"],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c, source.c++",
"variants":
[
{
"name": "Run",
"cmd": ["bash", "-c", "g++ -Wall -Wextra -pedantic -std=c++11 '${file}' -o '${file_path}/${file_base_name}' && '${file_path}/${file_base_name}'"]
}
]
}
I can provide a workaround solution to this problem: Use makefiles. Sublime Text 2 can run makefiles to compile c++ for you.
You would be more likely to get a better answer to this question by asking in the Sublime forums (http://www.sublimetext.com/forum/).
Even there they would probably be interested in knowing "how" it doesn't work (i.e. if nothing happens at all when pressing "Build", you might want to specify that).
It took me several hours to get C++ compiling working on Sublime Text, and I still have some slight problems (like the fact that Sublime Text can't apparently execute the program in an externe window/console).
Here's my config file:
{
"cmd": ["C:\\MinGW\\bin\\mingw32-g++.exe", "-Wall", "-time", "$file", "-o", "$file_base_name"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"working_dir": "${project_path:${folder}}",
"selector": "source.c",
"shell": true,
"encoding": "latin1"
}
(make sure to change the encoding to utf8 if the compiler doesn't work)
Also, add the MinGW's bin folder to your OS's Path variable (look up 'environment variable' in the start menu, and then look for the Path variable).