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 e4f791f..09d9fbc 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 @@ -162,11 +162,15 @@ public class FourCornerUnicodeDisplay { public void renderFromInt18(List chars, StringBuilder buf) { Iterator cdc = chars.iterator(); + Integer numberModeLarge = null; Integer numberMode = null; boolean numberPIE = true; boolean prevWord = false; while (cdc.hasNext()) { Integer cdcPoint = cdc.next(); + if (numberModeLarge != null && cdcPoint <= FourCornerDotCake.FC_NCR1632_1V.getStart() && cdcPoint >= FourCornerDotCake.FC_NCR1632_1V.getStop()) { + numberModeLarge = null; + } if (cdcPoint >= FourCornerDotCake.FC_DEC1604_P7.getStart() && cdcPoint <= FourCornerDotCake.FC_DEC1604_P7.getStop()) { Integer decPoint = cdcPoint - FourCornerDotCake.FC_DEC1604_P7.getLength(); FCDotDEC1604DashP7 decCode = FCDotDEC1604DashP7.indexOf(decPoint); @@ -223,6 +227,30 @@ public class FourCornerUnicodeDisplay { numberMode = null; // disable lookup } } + if (cdcPoint >= FourCornerDotCake.FC_NCR1632_1T.getStart() && cdcPoint <= FourCornerDotCake.FC_NCR1632_1T.getStop()) { + numberModeLarge = cdcPoint - FourCornerDotCake.FC_NCR1632_1T.getStart(); + continue; + } + if (numberModeLarge != null) { + int terminatorOffOne = numberModeLarge + 1; + int numberIdxOffOne = cdcPoint - FourCornerDotCake.FC_NCR1632_1V.getStart() + 1; + if (numberIdxOffOne > 0) { + List math = new ArrayList<>(); + FCDotPIE9CDash20.toScriptSuper(numberIdxOffOne).forEach(v -> { + for (int chr : v.cakePoints()) { + math.add(chr); + } + }); + math.add(FCDotCDC1604DashP6.BAR_V_RIGHT.ordinal()); + FCDotPIE9CDash20.toScriptSub(terminatorOffOne).forEach(v -> { + for (int chr : v.cakePoints()) { + math.add(chr); + } + }); + renderFromInt18(math, buf); + continue; + } + } if (numberMode != null) { if (numberPIE) { diff --git a/nx01-x4o-o2o/src/main/java/org/x4o/o2o/fc18/zero33/FCDotNCR1632Dash0M.java b/nx01-x4o-o2o/src/main/java/org/x4o/o2o/fc18/zero33/FCDotNCR1632Dash0M.java index f95ce8d..798c4c3 100644 --- a/nx01-x4o-o2o/src/main/java/org/x4o/o2o/fc18/zero33/FCDotNCR1632Dash0M.java +++ b/nx01-x4o-o2o/src/main/java/org/x4o/o2o/fc18/zero33/FCDotNCR1632Dash0M.java @@ -546,8 +546,12 @@ public enum FCDotNCR1632Dash0M implements FourCornerX18CakePoints { NXX_512, ; + public int cakePoint() { + return FourCornerDotCake.FC_NCR1632_0M.getStart() + ordinal(); + } + @Override public int[] cakePoints() { - return new int[] {FourCornerDotCake.FC_NCR1632_0M.getStart() + ordinal()}; + return new int[] {cakePoint()}; } } diff --git a/nx01-x4o-o2o/src/main/java/org/x4o/o2o/fc18/zero33/FCDotNCR1632Dash1T.java b/nx01-x4o-o2o/src/main/java/org/x4o/o2o/fc18/zero33/FCDotNCR1632Dash1T.java index 6671b57..ada1bbf 100644 --- a/nx01-x4o-o2o/src/main/java/org/x4o/o2o/fc18/zero33/FCDotNCR1632Dash1T.java +++ b/nx01-x4o-o2o/src/main/java/org/x4o/o2o/fc18/zero33/FCDotNCR1632Dash1T.java @@ -546,8 +546,12 @@ public enum FCDotNCR1632Dash1T implements FourCornerX18CakePoints { NXX_512, ; + public int cakePoint() { + return FourCornerDotCake.FC_NCR1632_1T.getStart() + ordinal(); + } + @Override public int[] cakePoints() { - return new int[] {FourCornerDotCake.FC_NCR1632_1T.getStart() + ordinal()}; + return new int[] {cakePoint()}; } } diff --git a/nx01-x4o-o2o/src/main/java/org/x4o/o2o/fc18/zero33/FCDotNCR1632Dash1V.java b/nx01-x4o-o2o/src/main/java/org/x4o/o2o/fc18/zero33/FCDotNCR1632Dash1V.java index dd5d804..ad60bcc 100644 --- a/nx01-x4o-o2o/src/main/java/org/x4o/o2o/fc18/zero33/FCDotNCR1632Dash1V.java +++ b/nx01-x4o-o2o/src/main/java/org/x4o/o2o/fc18/zero33/FCDotNCR1632Dash1V.java @@ -546,8 +546,12 @@ public enum FCDotNCR1632Dash1V implements FourCornerX18CakePoints { NXX_512, ; + public int cakePoint() { + return FourCornerDotCake.FC_NCR1632_1V.getStart() + ordinal(); + } + @Override public int[] cakePoints() { - return new int[] {FourCornerDotCake.FC_NCR1632_1V.getStart() + ordinal()}; + return new int[] {cakePoint()}; } } 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 a411b75..e2197a4 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 @@ -30,6 +30,9 @@ import org.junit.jupiter.api.Test; import org.x4o.o2o.fc18.pie9c.FCDotPIE9CDash26; import org.x4o.o2o.fc18.zero33.FCDotCDC1604DashP6; import org.x4o.o2o.fc18.zero33.FCDotDEC1604DashP7; +import org.x4o.o2o.fc18.zero33.FCDotNCR1632Dash0M; +import org.x4o.o2o.fc18.zero33.FCDotNCR1632Dash1T; +import org.x4o.o2o.fc18.zero33.FCDotNCR1632Dash1V; /** * Tests four corner displayed as unicode. @@ -58,6 +61,40 @@ public class FourCornerUnicodeDisplayTest { Assertions.assertEquals("X=␂ONEGOD;\n", FourCornerUnicodeDisplay.raw().renderFromX06(cdc)); } + @Test + public void testPINLarge() throws Exception { + List cdc = new ArrayList<>(); + cdc.add(FCDotCDC1604DashP6.NX24_X.ordinal()); // = X + cdc.add(FCDotCDC1604DashP6.EQUALS.ordinal()); + cdc.add(FourCornerDotCake.FC_NCR1632_1T.getStart()); // T011 + cdc.add(FourCornerDotCake.FC_NCR1632_1V.getStart()); // NXX_011 + cdc.add(FourCornerDotCake.FC_NCR1632_1T.getStart() - 1 + 15); // T015 + cdc.add(FourCornerDotCake.FC_NCR1632_1V.getStart() - 1 + 14); // NXX_014 + cdc.add(FCDotNCR1632Dash1T.NXX_456.cakePoint()); // T456 + cdc.add(FCDotNCR1632Dash1V.NXX_123.cakePoint()); // NXX_123 + cdc.add(FCDotNCR1632Dash1V.NXX_004.cakePoint()); // NXX_004 + cdc.add(FCDotCDC1604DashP6.SEMICOLON.ordinal()); + cdc.add(FCDotCDC1604DashP6._LINE.ordinal()); + + Assertions.assertEquals("X=¹/₁¹⁴/₁₅¹²³/₄₅₆⁴/₄₅₆;\n", FourCornerUnicodeDisplay.text().renderFromInt18(cdc)); + } + + @Test + public void testPINLargest() throws Exception { + List cdc = new ArrayList<>(); + cdc.add(FCDotCDC1604DashP6.NX24_X.ordinal()); // = X + cdc.add(FCDotCDC1604DashP6.EQUALS.ordinal()); + cdc.add(FCDotNCR1632Dash0M.NXX_001.cakePoint()); // block size of 1T and 1V are x1 to x512 + cdc.add(FCDotNCR1632Dash1T.NXX_456.cakePoint()); // T456 + cdc.add(FCDotNCR1632Dash1V.NXX_123.cakePoint()); // NXX_123 + cdc.add(FCDotNCR1632Dash1V.NXX_004.cakePoint()); // NXX_004 + cdc.add(FCDotCDC1604DashP6.SEMICOLON.ordinal()); + cdc.add(FCDotCDC1604DashP6._LINE.ordinal()); + + // TODO: add support + //Assertions.assertEquals("X=¹²³/₄₅₆⁴/₄₅₆;\n", FourCornerUnicodeDisplay.text().renderFromInt18(cdc)); + } + @Test public void testMixedCasing() throws Exception { List cdc = new ArrayList<>();