clean up primary loops.

This commit is contained in:
sigonasr2, Sig, Sigo 2021-12-15 20:21:00 +00:00
parent 348c5cc051
commit c6d18273a9
2 changed files with 49 additions and 37 deletions

View File

@ -168,20 +168,8 @@ public class SigTerm{
System.out.println(RESET); System.out.println(RESET);
} }
static void RefreshScreen() { static void HandleInput(NonBlockingReader r) {
CursorLineDown(1);
ScrollUp(1);
}
public static void main(String[] args) {
try { try {
Terminal term = org.jline.terminal.TerminalBuilder.terminal();
term.enterRawMode();
NonBlockingReader r = term.reader();
System.out.println(term.getWidth()+"x"+term.getHeight()+" size detected.");
System.out.println("Done!");
RunTest();
while (RUNNING) {
int ch = r.peek(250); int ch = r.peek(250);
if (ch!=NonBlockingReader.READ_EXPIRED) { if (ch!=NonBlockingReader.READ_EXPIRED) {
if (!is27&&!is91&&ch==27) { if (!is27&&!is91&&ch==27) {
@ -215,8 +203,32 @@ public class SigTerm{
} }
r.read(); r.read();
} }
} catch (IOException e) {
e.printStackTrace();
}
}
static void Run(NonBlockingReader r) {
while (RUNNING) {
HandleInput(r);
RefreshScreen(); RefreshScreen();
} }
}
static void RefreshScreen() {
CursorLineDown(1);
ScrollUp(1);
}
public static void main(String[] args) {
try {
Terminal term = org.jline.terminal.TerminalBuilder.terminal();
term.enterRawMode();
NonBlockingReader r = term.reader();
System.out.println(term.getWidth()+"x"+term.getHeight()+" size detected.");
System.out.println("Done!");
//RunTest();
Run(r);
r.shutdown(); r.shutdown();
term.close(); term.close();
} catch (IOException e) { } catch (IOException e) {

Binary file not shown.