问题描述
我正在创建一个小的 Java 应用程序,它应该有一个带有百分比的进度指示器.在每个循环中,它使用退格键 在显示下一个百分比之前删除显示的进度.
I'm creating a little Java application which should have a progress indicator with percentages. In every loop it uses backspace to remove the displayed progress before displaying the next percentage.
这是一个简化的例子:
public static void main(String[] args) throws Exception {
System.out.print("Progress: ");
for (int percentage = 0; percentage < 100; percentage++) {
System.out.print(percentage + "%");
Thread.sleep(10); // Stub for "long running task".
int length = String.valueOf(percentage).length() + 1;
while (length-- > 0) {
System.out.print('');
}
}
System.out.println("finished!");
}
这在命令提示符下运行良好,但在 Eclipse 的控制台(Galileo build 20090920-1017)中无法识别退格字符.而是显示一个表示未知字符的空方块.看截图:
This works perfectly in command prompt, but the backspace character isn't recognized in Eclipse's console (Galileo build 20090920-1017). It instead displays an empty square denoting an unknown character. See screenshot:
如何让 Eclipse 正确显示"退格键?IE.让它删除前一个字符.
How do I get Eclipse to "display" the backspace properly? I.e. let it remove the previous character.
这实际上不是什么showstopper,因为它只会在命令控制台中运行,但是让它在Eclipse中也能工作会很好:)
This is actually no showstopper since it will just be run in command console, but it would be just nice to get it to work in Eclipse as well :)
推荐答案
Eclipse Bug#76936. 我不会指望他们来修复它,并且没有列出任何解决方法.
Eclipse Bug #76936. I wouldn't count on them to fix it, and there are no workarounds listed.
您可能很幸运地找到了一个可以提供更高级控制台的插件.
You might have luck finding a plugin that contributes a more advanced console.
这篇关于如何让退格 在 Eclipse 的控制台中工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!