9
我想在我的控制檯應用程序中創建過程動畫。是否有可能爲此需求重寫先前的行?我知道\r
,但它只適用於當前行。是否有可能在控制檯中重寫上一行?
如果不可能,我該如何存檔動畫效果?謝謝。
我的控制檯是標準的Ubuntu 12.04終端仿真器。
感謝@ MrSmith42我做了這個簡單的演示,它顯示的方式來覆蓋線:
public class Flush {
public static void main(String[] args) {
for(int i = 0; i < 5; i++) {
System.out.println("**********************************");
}
// ESC[5A - cursor up 5 times
// \r - cursor return to begin of line
// ESC[J - erase to end of screen
System.out.print("\033[5A\r\033[J");
for(int i = 0; i < 5; i++) {
System.out.println("##################################");
}
}
}
你能證明簡短的演示?我的控制檯是標準的Ubuntu 12.04終端模擬器。 – bsiamionau 2013-02-24 12:31:09
由於簡單的顏色測試,請嘗試'System.out.println(「Hallo \ 033 [32mgreen \ 033 [0m-text。」)' – MrSmith42 2013-02-24 12:41:07
它的工作原理。謝謝,我會嘗試使用它存檔動畫問題。 +1 – bsiamionau 2013-02-24 12:44:05