80 or 120 character forced wrap for run output on Windows with pty=true -and- 4096 chunck buffering for pty=false
The following are two related problems, both having to do with output of a run or debugged program in Clion on Windows.
Symptom `run.processes.with.pty=true`: Output of a running program is force wrapped to 80 or 120 characters no matter the size of the run output window.
Symptom `run.processes.with.pty=false`: Output of a running program is hidden until 4096 characters/bytes have been written to stdout.
#### pty=true ####
From what I've read, Clion uses `winpty` (https://github.com/rprichard/winpty) to emulate terminal interactions on Windows.
Clion's interaction with winpty can be seen visually seen by setting the following environment variable before starting Clion:
$env:WINPTY_SHOW_CONSOLE = 1
Then run a console program which produces long lines such as this one:
#include <chrono>
#include <thread>
#include <cstdio>
int main()
{
for ( int x = 0; x < 1000; ++x ) {
printf( "---------%i", x % 10 );
std::this_thread::sleep_for( std::chrono::seconds( 1 ) );
}
return 0;
}
UPDATE: It is worth noting that the "Terminal" tab doesn't have the same 80/120 character limit issue as the run/debug tabs and seems to automatically resize the hidden Winpty window behind the scenes when the tab changes size. Would it be possible to replicate that functionality to the "Run" and "Debug" tabs?
Related discussion here (https://youtrack.jetbrains.com/issue/IDEA-117552#focus=Comments-27-1275005.0-0) back in 2016. The author of winpty explains the limitations of winpty.
In order to get this resolved, do I need to wait for who knows how long for ConPTY API to be implemented (https://youtrack.jetbrains.com/issue/IDEA-225582)?
#### pty=false ####
I have seen alternative solutions online to set `run.processes.with.pty=false` in the registry. However, while this fixes the line wrapping problem, it causes a new problem for non-trivial programs which is that output is buffered into 4096 character chunks.
From this issue (https://youtrack.jetbrains.com/issue/CPP-1485#focus=Comments-27-829144.0-0) I found out that Windows only supports "no- or full-buffering, not line-buffering", which leads me to believe that this is the issue.
#### System Information: ####
CLion 2020.3.1
Build #CL-203.6682.181, built on December 30, 2020
Runtime version: 11.0.9.1+11-b1145.63 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Windows 10 10.0
GC: ParNew, ConcurrentMarkSweep
Memory: 4083M
Cores: 12
Registry: run.processes.with.pty=true, debugger.watches.in.variables=false
Any help with this is greatly appreciated!
请先登录再写评论。
Hello!
What toolchain do you use in CLion (`File | Settings | Build, Execution, Deployment | Toolchains`)?
I'm using the Visual Studio Build Tools toolchain:
Here is the related issue in our tracker: https://youtrack.jetbrains.com/issue/CPP-10624. Please comment or upvote it in order to get updates. See https://intellij-support.jetbrains.com/hc/en-us/articles/207241135-How-to-follow-YouTrack-issues-and-receive-notifications if you are not familiar with YouTrack.
We have https://youtrack.jetbrains.com/issue/CPP-1576 in the roadmap for CLion 2021.1 and we also are going to work on the same functionality for Windows (https://youtrack.jetbrains.com/issue/CPP-14077) soon. It might be helpful in your case, so feel free to follow those issues too.
Sorry for the inconvenience.
Thank you Anna for sharing those youtrack issues!