Comments (2)
Currently, the API doesn't provide a way to clear the console. I will add this feature in the next release.
As a workaround, you can use the clearScreen
method shown in the code below:
import org.beryx.textio.TextIO;
import org.beryx.textio.TextIoFactory;
import org.beryx.textio.TextTerminal;
import org.beryx.textio.jline.JLineTextTerminal;
import org.beryx.textio.swing.SwingTextTerminal;
public class ClearTest {
public static void clearScreen(TextTerminal terminal) {
if (terminal instanceof JLineTextTerminal) {
terminal.print("\033[H\033[2J");
} else if (terminal instanceof SwingTextTerminal) {
((SwingTextTerminal) terminal).resetToOffset(0);
}
}
public static void main(String[] args) {
TextIO textIO = TextIoFactory.getTextIO();
TextTerminal terminal = textIO.getTextTerminal();
String user = textIO.newStringInputReader().read("Username");
clearScreen(terminal);
int age = textIO.newIntInputReader().read("Age");
textIO.dispose();
}
}
from text-io.
Thank you. Your given method saves the day.
from text-io.
Related Issues (20)
- How to restart gracefully HOT 4
- Error Message Provider for EnumInputReader with Numbered Values HOT 2
- Disable Event Expansion for Strings Containing Exclamation Marks '!' HOT 1
- Timed Wait for Input HOT 1
- Multi-line paste use case HOT 1
- Jline 3 support HOT 2
- Specific Maven example for WebTextTerminal HOT 3
- Cookies on WebTextTerminal HOT 5
- How to use MockTextTerminal HOT 7
- Allow cumulative possible values and properties configurators
- MockTextTerminal strips out new lines
- How to print also to log? HOT 4
- Change error messages HOT 2
- Input masking doesn't work with SystemTextTerminal HOT 2
- 👀
- Print empty line/whitespace
- java.lang.UnsatisfiedLinkError: /root/wag_inst/tools/jre-linux/lib/libawt_xawt.so: libXrender.so.1: cannot open shared object file: No such file or directory
- How minimize console to system tray?
- Java 21 breaks the terminal font HOT 1
- How to change the prompt for a EnumInputReader?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from text-io.