From 6bd01424d86f34e938819a70a29acc4c01c1aa97 Mon Sep 17 00:00:00 2001 From: Willem Date: Tue, 7 Jan 2025 17:40:30 +0100 Subject: [PATCH] Added support to display hidden controls --- .../o2o/fc18/FourCornerUnicodeDisplay.java | 45 ++++++++++++------- .../o2o/fc18/zero33/FCDotDEC1604DashP7.java | 4 +- .../fc18/FourCornerUnicodeDisplayTest.java | 10 ++--- .../o2o/fc18/FourCornerUnicodeImportTest.java | 10 ++--- .../o2o/fc18/FourCornerWriteExampleMD.java | 4 +- 5 files changed, 44 insertions(+), 29 deletions(-) diff --git a/nx01-x4o-o2o/src/main/java/org/x4o/o2o/fc18/FourCornerUnicodeDisplay.java b/nx01-x4o-o2o/src/main/java/org/x4o/o2o/fc18/FourCornerUnicodeDisplay.java index 8f68ba3..3f50254 100644 --- a/nx01-x4o-o2o/src/main/java/org/x4o/o2o/fc18/FourCornerUnicodeDisplay.java +++ b/nx01-x4o-o2o/src/main/java/org/x4o/o2o/fc18/FourCornerUnicodeDisplay.java @@ -69,22 +69,22 @@ import org.x4o.o2o.octal.PrimordialOctalOrangeJuiceCord; /// @version 1.0 Dec 28, 2024 public class FourCornerUnicodeDisplay { - static private final FourCornerUnicodeDisplay DISPLAY_6BIT = new FourCornerUnicodeDisplay(null); - static private final FourCornerUnicodeDisplay DISPLAY_8BIT = new FourCornerUnicodeDisplay(null); + private boolean renderHiddenControls = false; private String renderSeperator = null; private final Map> int18To21 = new HashMap<>(); - private FourCornerUnicodeDisplay(String renderSeperator) { + private FourCornerUnicodeDisplay(boolean renderHiddenControls, String renderSeperator) { + this.renderHiddenControls = renderHiddenControls; this.renderSeperator = renderSeperator; mapPoints(); } - static FourCornerUnicodeDisplay simple() { - return DISPLAY_6BIT; + static FourCornerUnicodeDisplay text() { + return text(false); } - static FourCornerUnicodeDisplay mixed() { - return DISPLAY_8BIT; + static FourCornerUnicodeDisplay text(boolean renderHiddenControls) { + return new FourCornerUnicodeDisplay(renderHiddenControls, null); } // static FourCornerUnicodeDisplay mixedᐧEskimo() { @@ -163,21 +163,21 @@ public class FourCornerUnicodeDisplay { if (numberMode != null) { if (numberPIE) { - int terminatorNum = numberMode - FCDotCDC1604DashP6.NX01_A.ordinal() + 1; - int valueNumberZero = cdcPoint - FCDotCDC1604DashP6.NX01_A.ordinal(); - int[] chs = pieTerminatorNumber(terminatorNum, valueNumberZero); + int terminatorOffOne = numberMode - FCDotCDC1604DashP6.NX01_A.ordinal() + 1; + int numberIdxOffZero = cdcPoint - FCDotCDC1604DashP6.NX01_A.ordinal(); + int[] chs = pieTerminatorNumber(terminatorOffOne, numberIdxOffZero); Arrays.stream(chs).forEach(v -> buf.appendCodePoint(v)); } else { // _PIN = ²⁄₁₂ - int terminatorNum = numberMode - FCDotCDC1604DashP6.NX01_A.ordinal() + 1; - int valueNumberOne = cdcPoint - FCDotCDC1604DashP6.NX01_A.ordinal() + 1; + int terminatorOffOne = numberMode - FCDotCDC1604DashP6.NX01_A.ordinal() + 1; + int numberIdxOffOne = cdcPoint - FCDotCDC1604DashP6.NX01_A.ordinal() + 1; List math = new ArrayList<>(); - FCDotPIE9CDash20.toScriptSuper(valueNumberOne).forEach(v -> { + FCDotPIE9CDash20.toScriptSuper(numberIdxOffOne).forEach(v -> { for (int chr : v.cakePoints()) { math.add(chr); } }); math.add(FCDotCDC1604DashP6.BAR_V_RIGHT.ordinal()); - FCDotPIE9CDash20.toScriptSub(terminatorNum).forEach(v -> { + FCDotPIE9CDash20.toScriptSub(terminatorOffOne).forEach(v -> { for (int chr : v.cakePoints()) { math.add(chr); } @@ -218,13 +218,20 @@ public class FourCornerUnicodeDisplay { } FCDotDEC1604DashP7 decCode = FCDotDEC1604DashP7.indexOf(cdc.next()); if (FCDotDEC1604DashP7.__NUL_DEC.equals(decCode)) { - buf.append(FCDotCDC1604DashP6.escapeSignUnicode(FCDotCDC1604DashP6.__NUL.ordinal())); + if (renderHiddenControls) { + buf.append(FCDotCDC1604DashP6.escapeSignUnicode(FCDotCDC1604DashP6.__ESC6.ordinal())); + buf.append(FCDotCDC1604DashP6.escapeSignUnicode(FCDotDEC1604DashP7.__NUL_DEC.ordinal())); + } return null; } if (FCDotDEC1604DashP7.__ESC6_APL.equals(decCode)) { if (!cdc.hasNext()) { return null; } + if (renderHiddenControls) { + buf.append(FCDotCDC1604DashP6.escapeSignUnicode(FCDotCDC1604DashP6.__ESC6.ordinal())); + buf.append(FCDotCDC1604DashP6.escapeSignUnicode(FCDotDEC1604DashP7.__ESC6_APL.ordinal())); + } FCDotAPL1604DashP8L aplCode = FCDotAPL1604DashP8L.indexOf(cdc.next()); Arrays.stream(aplCode.codePoints()).forEach(v -> buf.appendCodePoint(v)); return null; @@ -233,11 +240,19 @@ public class FourCornerUnicodeDisplay { if (!cdc.hasNext()) { return null; } + if (renderHiddenControls) { + buf.append(FCDotCDC1604DashP6.escapeSignUnicode(FCDotCDC1604DashP6.__ESC6.ordinal())); + buf.append(FCDotCDC1604DashP6.escapeSignUnicode(FCDotDEC1604DashP7.__ESC6_BYD.ordinal())); + } FCDotBYD1604DashP8H bydCode = FCDotBYD1604DashP8H.indexOf(cdc.next()); Arrays.stream(bydCode.codePoints()).forEach(v -> buf.appendCodePoint(v)); return null; } if (FCDotDEC1604DashP7.__ESC_STOP.equals(decCode)) { + if (renderHiddenControls) { + buf.append(FCDotCDC1604DashP6.escapeSignUnicode(FCDotCDC1604DashP6.__ESC6.ordinal())); + buf.append(FCDotCDC1604DashP6.escapeSignUnicode(FCDotDEC1604DashP7.__ESC_STOP.ordinal())); + } return null; } if (FCDotDEC1604DashP7.__ESC68_FC18.equals(decCode)) { diff --git a/nx01-x4o-o2o/src/main/java/org/x4o/o2o/fc18/zero33/FCDotDEC1604DashP7.java b/nx01-x4o-o2o/src/main/java/org/x4o/o2o/fc18/zero33/FCDotDEC1604DashP7.java index 91d019b..5a299e7 100644 --- a/nx01-x4o-o2o/src/main/java/org/x4o/o2o/fc18/zero33/FCDotDEC1604DashP7.java +++ b/nx01-x4o-o2o/src/main/java/org/x4o/o2o/fc18/zero33/FCDotDEC1604DashP7.java @@ -45,9 +45,9 @@ public enum FCDotDEC1604DashP7 implements FourCornerX06BaklavaPoints, FourCorner /// Indicator for termination of pussy strings, which is the compatibility duel octal, with the CDC 1604 computers. __NUL_DEC, - /// On 6 bit escape to the APL baklava. + /// On 6 bit escape to the APL baklava for single char. __ESC6_APL, - /// On 6 bit escape to the BYD baklave. + /// On 6 bit escape to the BYD baklave for single char. __ESC6_BYD, /// Duel escape stops the escaped PIE or PIN escape sequence data mode. /// VT-100 Manual: "ESC also cancels any escape sequence". diff --git a/nx01-x4o-o2o/src/test/java/org/x4o/o2o/fc18/FourCornerUnicodeDisplayTest.java b/nx01-x4o-o2o/src/test/java/org/x4o/o2o/fc18/FourCornerUnicodeDisplayTest.java index a1bf49a..cac25de 100644 --- a/nx01-x4o-o2o/src/test/java/org/x4o/o2o/fc18/FourCornerUnicodeDisplayTest.java +++ b/nx01-x4o-o2o/src/test/java/org/x4o/o2o/fc18/FourCornerUnicodeDisplayTest.java @@ -47,7 +47,7 @@ public class FourCornerUnicodeDisplayTest { cdc.add(FCDotCDC1604DashP6.NX03_C); // T003 cdc.add(FCDotCDC1604DashP6.NX01_A); // NXX_001 - String out = FourCornerUnicodeDisplay.simple().renderFromP6(cdc); + String out = FourCornerUnicodeDisplay.text().renderFromP6(cdc); Assertions.assertEquals("X¹/₃", out); } @@ -81,8 +81,8 @@ public class FourCornerUnicodeDisplayTest { cdc.add(FCDotDEC1604DashP7.__ESC_STOP); cdc.add(FCDotCDC1604DashP6.NX15_O); - Assertions.assertEquals("ab B␃cD.jklmO", FourCornerUnicodeDisplay.simple().renderFromP6(cdc)); - Assertions.assertEquals("ab B␃cD.jklmO", FourCornerUnicodeDisplay.mixed().renderFromP6(cdc)); + Assertions.assertEquals("ab B␃cD.jklmO", FourCornerUnicodeDisplay.text().renderFromP6(cdc)); + Assertions.assertEquals("ab B␃cD.jklm␃␃O", FourCornerUnicodeDisplay.text(true).renderFromP6(cdc)); } @Test @@ -96,7 +96,7 @@ public class FourCornerUnicodeDisplayTest { cdc.add(FCDotCDC1604DashP6._AT); cdc.add(FCDotCDC1604DashP6.NX11_K); // = K - String out = FourCornerUnicodeDisplay.simple().renderFromP6(cdc); + String out = FourCornerUnicodeDisplay.text().renderFromP6(cdc); Assertions.assertEquals("X^%@K", out); } @@ -111,7 +111,7 @@ public class FourCornerUnicodeDisplayTest { cdc.add(FCDotCDC1604DashP6.NX04_D); // 3 cdc.add(FCDotCDC1604DashP6.NX11_K); // K - String out = FourCornerUnicodeDisplay.simple().renderFromP6(cdc); + String out = FourCornerUnicodeDisplay.text().renderFromP6(cdc); Assertions.assertEquals("B3K", out); } } diff --git a/nx01-x4o-o2o/src/test/java/org/x4o/o2o/fc18/FourCornerUnicodeImportTest.java b/nx01-x4o-o2o/src/test/java/org/x4o/o2o/fc18/FourCornerUnicodeImportTest.java index 2686f4d..df6b594 100644 --- a/nx01-x4o-o2o/src/test/java/org/x4o/o2o/fc18/FourCornerUnicodeImportTest.java +++ b/nx01-x4o-o2o/src/test/java/org/x4o/o2o/fc18/FourCornerUnicodeImportTest.java @@ -51,7 +51,7 @@ public class FourCornerUnicodeImportTest { Assertions.assertEquals(FCDotCDC1604DashP6.NX01_A, cdc.get(6)); Assertions.assertEquals(FCDotCDC1604DashP6.NX18_R, cdc.get(7)); - String out = FourCornerUnicodeDisplay.simple().renderFromP6(cdc); + String out = FourCornerUnicodeDisplay.text().renderFromP6(cdc); Assertions.assertEquals("foobar", out); } @@ -72,7 +72,7 @@ public class FourCornerUnicodeImportTest { Assertions.assertEquals(FCDotCDC1604DashP6.NX01_A, cdc.get(8)); Assertions.assertEquals(FCDotCDC1604DashP6.NX18_R, cdc.get(9)); - String out = FourCornerUnicodeDisplay.simple().renderFromP6(cdc); + String out = FourCornerUnicodeDisplay.text().renderFromP6(cdc); Assertions.assertEquals("fooBAR", out); } @@ -82,7 +82,7 @@ public class FourCornerUnicodeImportTest { List cdc = FourCornerUnicodeImport.lossy().convertToP6(foobar); Assertions.assertNotNull(cdc); Assertions.assertFalse(cdc.isEmpty()); - Assertions.assertEquals("FOOBAR", FourCornerUnicodeDisplay.simple().renderFromP6(cdc)); + Assertions.assertEquals("FOOBAR", FourCornerUnicodeDisplay.text().renderFromP6(cdc)); Assertions.assertThrows(IllegalArgumentException.class, () -> { FourCornerUnicodeImport.strict().convertToP6(foobar); }); @@ -105,7 +105,7 @@ public class FourCornerUnicodeImportTest { Assertions.assertEquals(FCDotCDC1604DashP6.NX04_D, cdc.get(8)); // 3 Assertions.assertEquals(FCDotCDC1604DashP6.NX08_H, cdc.get(9)); // 7 - String out = FourCornerUnicodeDisplay.simple().renderFromP6(cdc); + String out = FourCornerUnicodeDisplay.text().renderFromP6(cdc); Assertions.assertEquals("01201337", out); } @@ -124,7 +124,7 @@ public class FourCornerUnicodeImportTest { Assertions.assertEquals(FCDotCDC1604DashP6.NX04_D, cdc.get(6)); Assertions.assertEquals(FCDotCDC1604DashP6.__LINE, cdc.get(7)); - String out = FourCornerUnicodeDisplay.simple().renderFromP6(cdc); + String out = FourCornerUnicodeDisplay.text().renderFromP6(cdc); Assertions.assertEquals("A\nB\nC\nD\n", out); } } diff --git a/nx01-x4o-o2o/src/test/java/org/x4o/o2o/fc18/FourCornerWriteExampleMD.java b/nx01-x4o-o2o/src/test/java/org/x4o/o2o/fc18/FourCornerWriteExampleMD.java index 0d8ded0..4e2e99e 100644 --- a/nx01-x4o-o2o/src/test/java/org/x4o/o2o/fc18/FourCornerWriteExampleMD.java +++ b/nx01-x4o-o2o/src/test/java/org/x4o/o2o/fc18/FourCornerWriteExampleMD.java @@ -236,7 +236,7 @@ public class FourCornerWriteExampleMD { continue; } int char18 = slice.getStart() + i; - String char18Str = FourCornerUnicodeDisplay.simple().renderFromInt18(List.of(char18)); + String char18Str = FourCornerUnicodeDisplay.text().renderFromInt18(List.of(char18)); buf.append(""); for (int c : char18Str.codePoints().toArray()) { if (c == '\u0000') { @@ -265,7 +265,7 @@ public class FourCornerWriteExampleMD { piNum.add(FCDotCDC1604DashP6.__PIN.ordinal()); piNum.add(FCDotCDC1604DashP6.NX01_A.ordinal() + t); piNum.add(FCDotCDC1604DashP6.NX01_A.ordinal() + i); - String char18Str = FourCornerUnicodeDisplay.simple().renderFromInt18(piNum); + String char18Str = FourCornerUnicodeDisplay.text().renderFromInt18(piNum); buf.append(""); for (int c : char18Str.codePoints().toArray()) { if (c == '\u0000') {