From c6d18273a9ede8adcba07c9b4fa43dadab6d5eb3 Mon Sep 17 00:00:00 2001 From: "sigonasr2, Sig, Sigo" Date: Wed, 15 Dec 2021 20:21:00 +0000 Subject: [PATCH] clean up primary loops. --- src/sig/SigTerm.java | 86 ++++++++++++++++++------------- target/classes/sig/SigTerm.class | Bin 6178 -> 6597 bytes 2 files changed, 49 insertions(+), 37 deletions(-) diff --git a/src/sig/SigTerm.java b/src/sig/SigTerm.java index 77c2b64..8e76990 100644 --- a/src/sig/SigTerm.java +++ b/src/sig/SigTerm.java @@ -168,6 +168,53 @@ public class SigTerm{ System.out.println(RESET); } + static void HandleInput(NonBlockingReader r) { + try { + int ch = r.peek(250); + if (ch!=NonBlockingReader.READ_EXPIRED) { + if (!is27&&!is91&&ch==27) { + is27=true; + } else + if (is27&&!is91&&ch==91) { + is91=true; + } else + if (is27&&is91) { + //Possible special code. + switch (ch) { + case 65:{ + Text("UP"); + }break; + case 66:{ + Text("DOWN"); + }break; + case 67:{ + Text("RIGHT"); + }break; + case 68:{ + Text("LEFT"); + }break; + } + is27=false; + is91=false; + } else + { + //Text(Integer.toString(ch)); + is27=is91=false; + } + r.read(); + } + } catch (IOException e) { + e.printStackTrace(); + } + } + + static void Run(NonBlockingReader r) { + while (RUNNING) { + HandleInput(r); + RefreshScreen(); + } + } + static void RefreshScreen() { CursorLineDown(1); ScrollUp(1); @@ -180,43 +227,8 @@ public class SigTerm{ 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); - if (ch!=NonBlockingReader.READ_EXPIRED) { - if (!is27&&!is91&&ch==27) { - is27=true; - } else - if (is27&&!is91&&ch==91) { - is91=true; - } else - if (is27&&is91) { - //Possible special code. - switch (ch) { - case 65:{ - Text("UP"); - }break; - case 66:{ - Text("DOWN"); - }break; - case 67:{ - Text("RIGHT"); - }break; - case 68:{ - Text("LEFT"); - }break; - } - is27=false; - is91=false; - } else - { - //Text(Integer.toString(ch)); - is27=is91=false; - } - r.read(); - } - RefreshScreen(); - } + //RunTest(); + Run(r); r.shutdown(); term.close(); } catch (IOException e) { diff --git a/target/classes/sig/SigTerm.class b/target/classes/sig/SigTerm.class index 4be41b85ff33b9372051d9470f3cbe43d34c4ca9..8c741ede3734b96c9f41ea3855fef8a69a87a4f7 100644 GIT binary patch literal 6597 zcmbVQ33yc175;Cwd6PUK%pjr@ae@L#AjE_KLQu#C3``P8CIktnlguL-n9Pi`uqfhE zTW#I7)q-``Ms3BK(Gb^K>r$ypZPhMnTerHj)~?c8tNrhNGbAZ9hEMn=_r7z_`Om#) zyXU?ApFQ{}fNHVHf-Hf8sK2M8&EMlOB7GL*2o!GiZuM3KyuqG|maff4cTB+2+TPsk zYF;iN)(cppu~5YDt@Q>3Z0=$1wphd;?5PpR@kgr`s9|BHKz3tWy}-EoP%s+v24fV9 z8ydzF%fZF^HkXEpeCVVaKGe4~G-{Y6kmVpHx3#gY(L<=Z7Iy==8(d8Sc`i?_+eJ)k zdvil$tJ~GwC@`U+rM=GGID(Q}$CXv&T2|ZUNzE1BvX*9I=CyfRU8^WMUJ*Tw>pb-> z?v_@8Ns3TcTfb^~YYP#RWV<3C)R3fFnrfFfHhXGmxH>mQP8*gJ&=z+G{6T;0WbVDB zbS)23AMzPi2$bl^MV^K-0m$dsIxNuSY>rMso}8VaBVY1VQO?nMLZ75n>o@|MhWUzC zsc0wam@H|F6s=0p7V9`t(x{oTa}{l=jwzB>r)brR)}Z4kNn1u^J36aOz!f@u^X~v!cycwADI_B#kzsaHY9JkB(y`QJ&V(xll2#(=k=j7(Ha1YZ5o;I93u* zRm5tOc)AX!Bz7s{Jd^0tQ7nm@OmTBVy*j2z;$~CaR36ZA95jZ5+aENV<9%I5#N+J> z7&1~r-QK`jZ^SR3lf=Bm$~*bU#u++7n9e=Ndi_zxt9wLVFs8NocqAH%w1>%2;woKh z#Ww7)VEd?iY1S|5eu2Q&QvKmRA)^-F2|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