如何在 Eclipse 控制台中获得没有换行效果的回车?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14792478/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to get carriage return without line feed effect in Eclipse console?
提问by Dims
If I
如果我
System.out.print("something\r");
at console, I have cursor back at the beginning of line, and finally after
在控制台,我的光标回到行首,最后在
System.out.print("something\r");
System.out.print(" any\r");
I have
我有
anything
typed.
打字。
But at Eclipse console I get
但是在 Eclipse 控制台我得到
something
anything
as if it treated \r
as CR/LF.
好像它被\r
视为 CR/LF。
How can I setup this?
我该如何设置?
采纳答案by poitroae
As Nishant already pointed out in the comments, you've found a bughere.
正如 Nishant 已经在评论中指出的那样,您在这里发现了一个错误。
This bug initially was reported in 2004 (>9 years ago!?!!)and this bug seems not to be fixed very soon(or ever). I tested it on several Eclipse version, even on Eclipse Juno SR2, and the bug is still there.
这个错误最初是在 2004 年(> 9 年前!?!!)报告的,这个错误似乎不会很快(或永远)被修复。我在几个 Eclipse 版本上测试过它,甚至在Eclipse Juno SR2 上,但错误仍然存在。
回答by das Keks
It finally seems to be fixed in Mars!
好像终于在火星上修好了!
Version: Mars Release (4.5.0)
Build id: 20150621-1200
Used Java: jre1.8.0_60
Your code
你的代码
public class Main {
public static void main(String[] args) {
System.out.print("something\r");
System.out.print(" any\r");
}
}
Output
输出
anything
回答by John McClane
The bug is fixed by now (Eclipse 2020-03). Just go to
该错误现已修复(Eclipse 2020-03)。就去
Window ? Preferences ? Run/Debug ? Console
and make sure that both checkboxes
并确保两个复选框
Interpret ASCII control characters
and
和
Interpret Carriage Return (\r) as control character
are enabled.
已启用。