Added support to display hidden controls
This commit is contained in:
parent
0de77ea719
commit
6bd01424d8
|
@ -69,22 +69,22 @@ import org.x4o.o2o.octal.PrimordialOctalOrangeJuiceCord;
|
||||||
/// @version 1.0 Dec 28, 2024
|
/// @version 1.0 Dec 28, 2024
|
||||||
public class FourCornerUnicodeDisplay {
|
public class FourCornerUnicodeDisplay {
|
||||||
|
|
||||||
static private final FourCornerUnicodeDisplay DISPLAY_6BIT = new FourCornerUnicodeDisplay(null);
|
private boolean renderHiddenControls = false;
|
||||||
static private final FourCornerUnicodeDisplay DISPLAY_8BIT = new FourCornerUnicodeDisplay(null);
|
|
||||||
private String renderSeperator = null;
|
private String renderSeperator = null;
|
||||||
private final Map<Integer, List<Integer>> int18To21 = new HashMap<>();
|
private final Map<Integer, List<Integer>> int18To21 = new HashMap<>();
|
||||||
|
|
||||||
private FourCornerUnicodeDisplay(String renderSeperator) {
|
private FourCornerUnicodeDisplay(boolean renderHiddenControls, String renderSeperator) {
|
||||||
|
this.renderHiddenControls = renderHiddenControls;
|
||||||
this.renderSeperator = renderSeperator;
|
this.renderSeperator = renderSeperator;
|
||||||
mapPoints();
|
mapPoints();
|
||||||
}
|
}
|
||||||
|
|
||||||
static FourCornerUnicodeDisplay simple() {
|
static FourCornerUnicodeDisplay text() {
|
||||||
return DISPLAY_6BIT;
|
return text(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
static FourCornerUnicodeDisplay mixed() {
|
static FourCornerUnicodeDisplay text(boolean renderHiddenControls) {
|
||||||
return DISPLAY_8BIT;
|
return new FourCornerUnicodeDisplay(renderHiddenControls, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
// static FourCornerUnicodeDisplay mixedᐧEskimo() {
|
// static FourCornerUnicodeDisplay mixedᐧEskimo() {
|
||||||
|
@ -163,21 +163,21 @@ public class FourCornerUnicodeDisplay {
|
||||||
|
|
||||||
if (numberMode != null) {
|
if (numberMode != null) {
|
||||||
if (numberPIE) {
|
if (numberPIE) {
|
||||||
int terminatorNum = numberMode - FCDotCDC1604DashP6.NX01_A.ordinal() + 1;
|
int terminatorOffOne = numberMode - FCDotCDC1604DashP6.NX01_A.ordinal() + 1;
|
||||||
int valueNumberZero = cdcPoint - FCDotCDC1604DashP6.NX01_A.ordinal();
|
int numberIdxOffZero = cdcPoint - FCDotCDC1604DashP6.NX01_A.ordinal();
|
||||||
int[] chs = pieTerminatorNumber(terminatorNum, valueNumberZero);
|
int[] chs = pieTerminatorNumber(terminatorOffOne, numberIdxOffZero);
|
||||||
Arrays.stream(chs).forEach(v -> buf.appendCodePoint(v));
|
Arrays.stream(chs).forEach(v -> buf.appendCodePoint(v));
|
||||||
} else { // _PIN = ²⁄₁₂
|
} else { // _PIN = ²⁄₁₂
|
||||||
int terminatorNum = numberMode - FCDotCDC1604DashP6.NX01_A.ordinal() + 1;
|
int terminatorOffOne = numberMode - FCDotCDC1604DashP6.NX01_A.ordinal() + 1;
|
||||||
int valueNumberOne = cdcPoint - FCDotCDC1604DashP6.NX01_A.ordinal() + 1;
|
int numberIdxOffOne = cdcPoint - FCDotCDC1604DashP6.NX01_A.ordinal() + 1;
|
||||||
List<Integer> math = new ArrayList<>();
|
List<Integer> math = new ArrayList<>();
|
||||||
FCDotPIE9CDash20.toScriptSuper(valueNumberOne).forEach(v -> {
|
FCDotPIE9CDash20.toScriptSuper(numberIdxOffOne).forEach(v -> {
|
||||||
for (int chr : v.cakePoints()) {
|
for (int chr : v.cakePoints()) {
|
||||||
math.add(chr);
|
math.add(chr);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
math.add(FCDotCDC1604DashP6.BAR_V_RIGHT.ordinal());
|
math.add(FCDotCDC1604DashP6.BAR_V_RIGHT.ordinal());
|
||||||
FCDotPIE9CDash20.toScriptSub(terminatorNum).forEach(v -> {
|
FCDotPIE9CDash20.toScriptSub(terminatorOffOne).forEach(v -> {
|
||||||
for (int chr : v.cakePoints()) {
|
for (int chr : v.cakePoints()) {
|
||||||
math.add(chr);
|
math.add(chr);
|
||||||
}
|
}
|
||||||
|
@ -218,13 +218,20 @@ public class FourCornerUnicodeDisplay {
|
||||||
}
|
}
|
||||||
FCDotDEC1604DashP7 decCode = FCDotDEC1604DashP7.indexOf(cdc.next());
|
FCDotDEC1604DashP7 decCode = FCDotDEC1604DashP7.indexOf(cdc.next());
|
||||||
if (FCDotDEC1604DashP7.__NUL_DEC.equals(decCode)) {
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
if (FCDotDEC1604DashP7.__ESC6_APL.equals(decCode)) {
|
if (FCDotDEC1604DashP7.__ESC6_APL.equals(decCode)) {
|
||||||
if (!cdc.hasNext()) {
|
if (!cdc.hasNext()) {
|
||||||
return null;
|
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());
|
FCDotAPL1604DashP8L aplCode = FCDotAPL1604DashP8L.indexOf(cdc.next());
|
||||||
Arrays.stream(aplCode.codePoints()).forEach(v -> buf.appendCodePoint(v));
|
Arrays.stream(aplCode.codePoints()).forEach(v -> buf.appendCodePoint(v));
|
||||||
return null;
|
return null;
|
||||||
|
@ -233,11 +240,19 @@ public class FourCornerUnicodeDisplay {
|
||||||
if (!cdc.hasNext()) {
|
if (!cdc.hasNext()) {
|
||||||
return null;
|
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());
|
FCDotBYD1604DashP8H bydCode = FCDotBYD1604DashP8H.indexOf(cdc.next());
|
||||||
Arrays.stream(bydCode.codePoints()).forEach(v -> buf.appendCodePoint(v));
|
Arrays.stream(bydCode.codePoints()).forEach(v -> buf.appendCodePoint(v));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (FCDotDEC1604DashP7.__ESC_STOP.equals(decCode)) {
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
if (FCDotDEC1604DashP7.__ESC68_FC18.equals(decCode)) {
|
if (FCDotDEC1604DashP7.__ESC68_FC18.equals(decCode)) {
|
||||||
|
|
|
@ -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.
|
/// Indicator for termination of pussy strings, which is the compatibility duel octal, with the CDC 1604 computers.
|
||||||
__NUL_DEC,
|
__NUL_DEC,
|
||||||
/// On 6 bit escape to the APL baklava.
|
/// On 6 bit escape to the APL baklava for single char.
|
||||||
__ESC6_APL,
|
__ESC6_APL,
|
||||||
/// On 6 bit escape to the BYD baklave.
|
/// On 6 bit escape to the BYD baklave for single char.
|
||||||
__ESC6_BYD,
|
__ESC6_BYD,
|
||||||
/// Duel escape stops the escaped PIE or PIN escape sequence data mode.
|
/// Duel escape stops the escaped PIE or PIN escape sequence data mode.
|
||||||
/// VT-100 Manual: "ESC also cancels any escape sequence".
|
/// VT-100 Manual: "ESC also cancels any escape sequence".
|
||||||
|
|
|
@ -47,7 +47,7 @@ public class FourCornerUnicodeDisplayTest {
|
||||||
cdc.add(FCDotCDC1604DashP6.NX03_C); // T003
|
cdc.add(FCDotCDC1604DashP6.NX03_C); // T003
|
||||||
cdc.add(FCDotCDC1604DashP6.NX01_A); // NXX_001
|
cdc.add(FCDotCDC1604DashP6.NX01_A); // NXX_001
|
||||||
|
|
||||||
String out = FourCornerUnicodeDisplay.simple().renderFromP6(cdc);
|
String out = FourCornerUnicodeDisplay.text().renderFromP6(cdc);
|
||||||
Assertions.assertEquals("X¹/₃", out);
|
Assertions.assertEquals("X¹/₃", out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,8 +81,8 @@ public class FourCornerUnicodeDisplayTest {
|
||||||
cdc.add(FCDotDEC1604DashP7.__ESC_STOP);
|
cdc.add(FCDotDEC1604DashP7.__ESC_STOP);
|
||||||
cdc.add(FCDotCDC1604DashP6.NX15_O);
|
cdc.add(FCDotCDC1604DashP6.NX15_O);
|
||||||
|
|
||||||
Assertions.assertEquals("ab B␃cD.jklmO", FourCornerUnicodeDisplay.simple().renderFromP6(cdc));
|
Assertions.assertEquals("ab B␃cD.jklmO", FourCornerUnicodeDisplay.text().renderFromP6(cdc));
|
||||||
Assertions.assertEquals("ab B␃cD.jklmO", FourCornerUnicodeDisplay.mixed().renderFromP6(cdc));
|
Assertions.assertEquals("ab B␃cD.jklm␃␃O", FourCornerUnicodeDisplay.text(true).renderFromP6(cdc));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -96,7 +96,7 @@ public class FourCornerUnicodeDisplayTest {
|
||||||
cdc.add(FCDotCDC1604DashP6._AT);
|
cdc.add(FCDotCDC1604DashP6._AT);
|
||||||
cdc.add(FCDotCDC1604DashP6.NX11_K); // = K
|
cdc.add(FCDotCDC1604DashP6.NX11_K); // = K
|
||||||
|
|
||||||
String out = FourCornerUnicodeDisplay.simple().renderFromP6(cdc);
|
String out = FourCornerUnicodeDisplay.text().renderFromP6(cdc);
|
||||||
Assertions.assertEquals("X^%@K", out);
|
Assertions.assertEquals("X^%@K", out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ public class FourCornerUnicodeDisplayTest {
|
||||||
cdc.add(FCDotCDC1604DashP6.NX04_D); // 3
|
cdc.add(FCDotCDC1604DashP6.NX04_D); // 3
|
||||||
cdc.add(FCDotCDC1604DashP6.NX11_K); // K
|
cdc.add(FCDotCDC1604DashP6.NX11_K); // K
|
||||||
|
|
||||||
String out = FourCornerUnicodeDisplay.simple().renderFromP6(cdc);
|
String out = FourCornerUnicodeDisplay.text().renderFromP6(cdc);
|
||||||
Assertions.assertEquals("B3K", out);
|
Assertions.assertEquals("B3K", out);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ public class FourCornerUnicodeImportTest {
|
||||||
Assertions.assertEquals(FCDotCDC1604DashP6.NX01_A, cdc.get(6));
|
Assertions.assertEquals(FCDotCDC1604DashP6.NX01_A, cdc.get(6));
|
||||||
Assertions.assertEquals(FCDotCDC1604DashP6.NX18_R, cdc.get(7));
|
Assertions.assertEquals(FCDotCDC1604DashP6.NX18_R, cdc.get(7));
|
||||||
|
|
||||||
String out = FourCornerUnicodeDisplay.simple().renderFromP6(cdc);
|
String out = FourCornerUnicodeDisplay.text().renderFromP6(cdc);
|
||||||
Assertions.assertEquals("foobar", out);
|
Assertions.assertEquals("foobar", out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ public class FourCornerUnicodeImportTest {
|
||||||
Assertions.assertEquals(FCDotCDC1604DashP6.NX01_A, cdc.get(8));
|
Assertions.assertEquals(FCDotCDC1604DashP6.NX01_A, cdc.get(8));
|
||||||
Assertions.assertEquals(FCDotCDC1604DashP6.NX18_R, cdc.get(9));
|
Assertions.assertEquals(FCDotCDC1604DashP6.NX18_R, cdc.get(9));
|
||||||
|
|
||||||
String out = FourCornerUnicodeDisplay.simple().renderFromP6(cdc);
|
String out = FourCornerUnicodeDisplay.text().renderFromP6(cdc);
|
||||||
Assertions.assertEquals("fooBAR", out);
|
Assertions.assertEquals("fooBAR", out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ public class FourCornerUnicodeImportTest {
|
||||||
List<FourCornerX06BaklavaPoints> cdc = FourCornerUnicodeImport.lossy().convertToP6(foobar);
|
List<FourCornerX06BaklavaPoints> cdc = FourCornerUnicodeImport.lossy().convertToP6(foobar);
|
||||||
Assertions.assertNotNull(cdc);
|
Assertions.assertNotNull(cdc);
|
||||||
Assertions.assertFalse(cdc.isEmpty());
|
Assertions.assertFalse(cdc.isEmpty());
|
||||||
Assertions.assertEquals("FOOBAR", FourCornerUnicodeDisplay.simple().renderFromP6(cdc));
|
Assertions.assertEquals("FOOBAR", FourCornerUnicodeDisplay.text().renderFromP6(cdc));
|
||||||
Assertions.assertThrows(IllegalArgumentException.class, () -> {
|
Assertions.assertThrows(IllegalArgumentException.class, () -> {
|
||||||
FourCornerUnicodeImport.strict().convertToP6(foobar);
|
FourCornerUnicodeImport.strict().convertToP6(foobar);
|
||||||
});
|
});
|
||||||
|
@ -105,7 +105,7 @@ public class FourCornerUnicodeImportTest {
|
||||||
Assertions.assertEquals(FCDotCDC1604DashP6.NX04_D, cdc.get(8)); // 3
|
Assertions.assertEquals(FCDotCDC1604DashP6.NX04_D, cdc.get(8)); // 3
|
||||||
Assertions.assertEquals(FCDotCDC1604DashP6.NX08_H, cdc.get(9)); // 7
|
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);
|
Assertions.assertEquals("01201337", out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ public class FourCornerUnicodeImportTest {
|
||||||
Assertions.assertEquals(FCDotCDC1604DashP6.NX04_D, cdc.get(6));
|
Assertions.assertEquals(FCDotCDC1604DashP6.NX04_D, cdc.get(6));
|
||||||
Assertions.assertEquals(FCDotCDC1604DashP6.__LINE, cdc.get(7));
|
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);
|
Assertions.assertEquals("A\nB\nC\nD\n", out);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -236,7 +236,7 @@ public class FourCornerWriteExampleMD {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int char18 = slice.getStart() + i;
|
int char18 = slice.getStart() + i;
|
||||||
String char18Str = FourCornerUnicodeDisplay.simple().renderFromInt18(List.of(char18));
|
String char18Str = FourCornerUnicodeDisplay.text().renderFromInt18(List.of(char18));
|
||||||
buf.append("<td>");
|
buf.append("<td>");
|
||||||
for (int c : char18Str.codePoints().toArray()) {
|
for (int c : char18Str.codePoints().toArray()) {
|
||||||
if (c == '\u0000') {
|
if (c == '\u0000') {
|
||||||
|
@ -265,7 +265,7 @@ public class FourCornerWriteExampleMD {
|
||||||
piNum.add(FCDotCDC1604DashP6.__PIN.ordinal());
|
piNum.add(FCDotCDC1604DashP6.__PIN.ordinal());
|
||||||
piNum.add(FCDotCDC1604DashP6.NX01_A.ordinal() + t);
|
piNum.add(FCDotCDC1604DashP6.NX01_A.ordinal() + t);
|
||||||
piNum.add(FCDotCDC1604DashP6.NX01_A.ordinal() + i);
|
piNum.add(FCDotCDC1604DashP6.NX01_A.ordinal() + i);
|
||||||
String char18Str = FourCornerUnicodeDisplay.simple().renderFromInt18(piNum);
|
String char18Str = FourCornerUnicodeDisplay.text().renderFromInt18(piNum);
|
||||||
buf.append("<td>");
|
buf.append("<td>");
|
||||||
for (int c : char18Str.codePoints().toArray()) {
|
for (int c : char18Str.codePoints().toArray()) {
|
||||||
if (c == '\u0000') {
|
if (c == '\u0000') {
|
||||||
|
|
Loading…
Reference in a new issue