如何重绘控制台屏幕,使其在清除屏幕后出现? [英] How to redraw the console screen so it would appear as screen was cleared?

查看:53
本文介绍了如何重绘控制台屏幕,使其在清除屏幕后出现?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我想做的是模拟Eclipse终端的清除屏幕.

So what I am trying to do it so simulate clearing screen of Eclipse terminal.

我知道清除屏幕没有真正的解决方案,所以我知道我必须使用大量的空行来清除屏幕.

I know there isn't a real solution for clearing the screen so I know I must use tons of empty lines to clear the screen.

问题是当我输入大量的换行符时,指针将位于终端的底部.

The problem is that when I do tons of new line characters the pointer would be at the bottom of the terminal.

我该怎么做,这样我最终会在终端顶部出现指针,并且整个视图中都看不到任何文字?

How would I do this so I would end up with pointer at the top of terminal and entire view would appear clear of any text?

所以它看起来像Aircrack-ng一样的界面.屏幕不断变化,但只能通过向下滚动和更新内容等来实现.

So it would look like Aircrack-ng like interface. The screen keep changing but only by scrolling down and updating the content, etc.

推荐答案

您基本上想要模仿 clrtobot curses 函数.哪个:

What you want basically is to emulate the clrtobot curses function. Which:

从光标删除到屏幕结尾.也就是说,它们会擦除窗口中光标下方的所有行.此外,光标右边的当前行(包括首尾)也将被删除.

erase from the cursor to the end of screen. That is, they erase all lines below the cursor in the window. Also, the current line to the right of the cursor, inclusive, is erased.

window $ 中,有"cls"功能,因此您必须使用类似的

In window$, there's the "cls" function, so you must use something like

Runtime.getRuntime().exec("cls");

大多数 * nix 中都有清除"功能.但是请不要过分依赖此解决方案,因为这会有所不同,但是您可以使用类似以下内容的方法:

In most *nix there's the "clear" function. But please don't rely too much on this solution, because this varies, but you can use something like:

Runtime.getRuntime().exec("clear");

我还没有看到不依赖于操作系统的解决方案.

I'm yet to see a solution non OS dependent.

我希望它能对您有所帮助.欢呼声

I hope it helped. Cheers

这篇关于如何重绘控制台屏幕,使其在清除屏幕后出现?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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