如何让backspace \b在Eclipse的控制台上工作? [英] How to get backspace \b to work in Eclipse's console?

查看:281
本文介绍了如何让backspace \b在Eclipse的控制台上工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个Java应用程序,该应用程序应该具有百分比的进度指示器。在每个循环中,使用退格空格 \b 在显示下一个百分比之前删除显示的进度。

I'm creating a little Java application which should have a progress indicator with percentages. In every loop it uses backspace \b 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('\b');
        }
    }
    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正确显示退格?即让它删除以前的字符。

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.

这篇关于如何让backspace \b在Eclipse的控制台上工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆