Added dirty raw mode code in unicode display methods

This commit is contained in:
Willem Cazander 2025-01-07 20:28:35 +01:00
parent 4122e24ad4
commit d528e8dd8c
2 changed files with 26 additions and 10 deletions

View file

@ -70,21 +70,27 @@ import org.x4o.o2o.octal.PrimordialOctalOrangeJuiceCord;
public class FourCornerUnicodeDisplay {
private boolean renderHiddenControls = false;
private boolean renderLookup = true;
private String renderSeperator = null;
private final Map<Integer, List<Integer>> int18To21 = new HashMap<>();
private FourCornerUnicodeDisplay(boolean renderHiddenControls, String renderSeperator) {
private FourCornerUnicodeDisplay(boolean renderHiddenControls, boolean renderLookup, String renderSeperator) {
this.renderHiddenControls = renderHiddenControls;
this.renderLookup = renderLookup;
this.renderSeperator = renderSeperator;
mapPoints();
}
static FourCornerUnicodeDisplay text() {
return text(false);
return text(false, true);
}
static FourCornerUnicodeDisplay text(boolean renderHiddenControls) {
return new FourCornerUnicodeDisplay(renderHiddenControls, null);
static FourCornerUnicodeDisplay raw() {
return text(true, false);
}
static FourCornerUnicodeDisplay text(boolean renderHiddenControls, boolean renderLookup) {
return new FourCornerUnicodeDisplay(renderHiddenControls, renderLookup, null);
}
// static FourCornerUnicodeDisplay mixedᐧEskimo() {
@ -201,13 +207,20 @@ public class FourCornerUnicodeDisplay {
} else {
buf.append(FCDotCDC1604DashP6.escapeSignUnicode(FCDotCDC1604DashP6.__PIN.ordinal()));
}
buf.appendCodePoint(FCDotCDC1604DashP6.indexOf(numberMode).codePoints()[0]);
if (renderLookup) { // is already printed when disabled
buf.appendCodePoint(FCDotCDC1604DashP6.indexOf(numberMode).codePoints()[0]);
}
}
if (numberMode < FCDotCDC1604DashP6.NX01_A.ordinal()) {
cdcPoint = numberMode; // print char
numberMode = null; // illegal number mode
if (renderLookup) {
if (numberMode != null && numberMode < FCDotCDC1604DashP6.NX01_A.ordinal()) {
cdcPoint = numberMode; // print char
numberMode = null; // illegal number mode
} else {
continue;
}
} else {
continue;
cdcPoint = numberMode; // print char
numberMode = null; // disable lookup
}
}
@ -315,6 +328,9 @@ public class FourCornerUnicodeDisplay {
if (!renderHiddenControls) {
buf.append(FCDotCDC1604DashP6.escapeSignUnicode(FCDotCDC1604DashP6.__ESC6.ordinal()));
}
if (!renderLookup) {
return checkChr;
}
FCDotPIE9CDash26 lowCode = FCDotPIE9CDash26.values()[idx];
Arrays.stream(lowCode.codePoints()).forEach(v -> buf.appendCodePoint(v));
return null;

View file

@ -82,7 +82,7 @@ public class FourCornerUnicodeDisplayTest {
cdc.add(FCDotCDC1604DashP6.NX15_O);
Assertions.assertEquals("ab B␃cD.jklmO", FourCornerUnicodeDisplay.text().renderFromX06(cdc));
Assertions.assertEquals("␁Za␁Zb B␃cD.␁Zjklm␃␃O", FourCornerUnicodeDisplay.text(true).renderFromX06(cdc));
Assertions.assertEquals("␁ZA␁ZB B␃CD.␁ZJKLM␃␃O", FourCornerUnicodeDisplay.raw().renderFromX06(cdc));
}
@Test