Most likely this is due to the fact that curses
is trying to determine what terminal type to use to do things like output colors and manipulate the cursor position.
When you use a standard build system in Sublime Text, all it does is capture the output of your program and dump it to a panel; that is, it's not a terminal at all. So there's likely no TERM
variable set, and even if there was it would be meaningless because curses
isn't going to work anyway.
An important note in this regard is that the "dumb terminal" that Sublime uses to dump output doesn't accept input, so if your program is expecting to gather some sort of input from the user to do something, that will also fail.
To solve both of these problems, you can do something like this:
- Install the Terminus package, which provides a terminal inside of Sublime
Open up your sublime-build
file and add the following keys inside of the { }
characters (anywhere within there is fine).
"target": "terminus_exec",
"cancel": "terminus_cancel_build",
Now when you run the build, Terminus will open an actual terminal and run your code inside. This is more the sort of environment that curses
is expecting, and is also needed if your program needs to be in any way interactive.
More details can be found in this video on making any build system interactive with Terminus if needed. This may be of particular benefit if you're not sure how to find and open the build file that you're using.