输出到控制台时防止换行
我已将缓冲区大小设置为窗口大小以消除滚动条。 现在,我试图用一个值填充控制台,但末尾总是添加一个新的空行,这会导致第一行从缓冲区中清除。
我知道为什么会发生这种情况,但是有什么办法可以阻止它发生吗?
我尝试过移动缓冲区,但正如我所说,添加空行时缓冲区的第一行会被清除,因此只会在顶部创建一个空行。
I've set the buffer size to the window size to get rid of the scroll bar. Now, I'm trying to fill the console with a value, but there is always a new blank line added to the end, which causes the first line to be cleared from the buffer.
I know why it's happening, but is there any way that I can prevent it?
I've tried moving the buffer area, but as I said, the first line of the buffer is cleared when the blank line is added, so that just creates a blank line at the top.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
.NET 控制台只是流入缓冲区,这可能不是您想要的。 您需要 P/Invoke 到 Windows API 才能完全控制控制台。
特别是,请查看 WriteConsoleOutput。 它允许您将控制台视为“像素”网格,并写入其中的特定块。
The .NET console just streams into the buffer, which is probably not what you want. You'll need to P/Invoke into the Windows API to have full control over the console.
In particular, check out WriteConsoleOutput. It allows you to treat the console as a grid of "pixels", and write to a specific block of them.