Added limited support for big terminators

This commit is contained in:
Willem Cazander 2025-01-08 13:31:08 +01:00
parent 534d9861ea
commit dd563cdb9a
5 changed files with 80 additions and 3 deletions

View file

@ -162,11 +162,15 @@ public class FourCornerUnicodeDisplay {
public void renderFromInt18(List<Integer> chars, StringBuilder buf) { public void renderFromInt18(List<Integer> chars, StringBuilder buf) {
Iterator<Integer> cdc = chars.iterator(); Iterator<Integer> cdc = chars.iterator();
Integer numberModeLarge = null;
Integer numberMode = null; Integer numberMode = null;
boolean numberPIE = true; boolean numberPIE = true;
boolean prevWord = false; boolean prevWord = false;
while (cdc.hasNext()) { while (cdc.hasNext()) {
Integer cdcPoint = cdc.next(); 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()) { if (cdcPoint >= FourCornerDotCake.FC_DEC1604_P7.getStart() && cdcPoint <= FourCornerDotCake.FC_DEC1604_P7.getStop()) {
Integer decPoint = cdcPoint - FourCornerDotCake.FC_DEC1604_P7.getLength(); Integer decPoint = cdcPoint - FourCornerDotCake.FC_DEC1604_P7.getLength();
FCDotDEC1604DashP7 decCode = FCDotDEC1604DashP7.indexOf(decPoint); FCDotDEC1604DashP7 decCode = FCDotDEC1604DashP7.indexOf(decPoint);
@ -223,6 +227,30 @@ public class FourCornerUnicodeDisplay {
numberMode = null; // disable lookup 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<Integer> 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 (numberMode != null) {
if (numberPIE) { if (numberPIE) {

View file

@ -546,8 +546,12 @@ public enum FCDotNCR1632Dash0M implements FourCornerX18CakePoints {
NXX_512, NXX_512,
; ;
public int cakePoint() {
return FourCornerDotCake.FC_NCR1632_0M.getStart() + ordinal();
}
@Override @Override
public int[] cakePoints() { public int[] cakePoints() {
return new int[] {FourCornerDotCake.FC_NCR1632_0M.getStart() + ordinal()}; return new int[] {cakePoint()};
} }
} }

View file

@ -546,8 +546,12 @@ public enum FCDotNCR1632Dash1T implements FourCornerX18CakePoints {
NXX_512, NXX_512,
; ;
public int cakePoint() {
return FourCornerDotCake.FC_NCR1632_1T.getStart() + ordinal();
}
@Override @Override
public int[] cakePoints() { public int[] cakePoints() {
return new int[] {FourCornerDotCake.FC_NCR1632_1T.getStart() + ordinal()}; return new int[] {cakePoint()};
} }
} }

View file

@ -546,8 +546,12 @@ public enum FCDotNCR1632Dash1V implements FourCornerX18CakePoints {
NXX_512, NXX_512,
; ;
public int cakePoint() {
return FourCornerDotCake.FC_NCR1632_1V.getStart() + ordinal();
}
@Override @Override
public int[] cakePoints() { public int[] cakePoints() {
return new int[] {FourCornerDotCake.FC_NCR1632_1V.getStart() + ordinal()}; return new int[] {cakePoint()};
} }
} }

View file

@ -30,6 +30,9 @@ import org.junit.jupiter.api.Test;
import org.x4o.o2o.fc18.pie9c.FCDotPIE9CDash26; import org.x4o.o2o.fc18.pie9c.FCDotPIE9CDash26;
import org.x4o.o2o.fc18.zero33.FCDotCDC1604DashP6; import org.x4o.o2o.fc18.zero33.FCDotCDC1604DashP6;
import org.x4o.o2o.fc18.zero33.FCDotDEC1604DashP7; 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. * Tests four corner displayed as unicode.
@ -58,6 +61,40 @@ public class FourCornerUnicodeDisplayTest {
Assertions.assertEquals("X=␂ONEGOD;\n", FourCornerUnicodeDisplay.raw().renderFromX06(cdc)); Assertions.assertEquals("X=␂ONEGOD;\n", FourCornerUnicodeDisplay.raw().renderFromX06(cdc));
} }
@Test
public void testPINLarge() throws Exception {
List<Integer> 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<Integer> 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 @Test
public void testMixedCasing() throws Exception { public void testMixedCasing() throws Exception {
List<FourCornerX06BaklavaPoints> cdc = new ArrayList<>(); List<FourCornerX06BaklavaPoints> cdc = new ArrayList<>();