From 9187f82e4c74fa1d4deaf93810ff5f3e2b3be828 Mon Sep 17 00:00:00 2001 From: Willem Date: Thu, 9 Jan 2025 02:49:54 +0100 Subject: [PATCH] Moved esc below to nether to embed dark data with type header --- .../org/x4o/o2o/fc18/FourCornerDotCake.java | 12 ++++----- .../o2o/fc18/FourCornerUnicodeDisplay.java | 17 +++--------- .../x4o/o2o/fc18/pie9c/FCDotPIE9CDash10.java | 20 +++++++++++--- .../o2o/fc18/zero33/FCDotDEC1604DashP7.java | 27 +++++++++++++------ .../x4o/o2o/fc18/FourCornerDotCakeTest.java | 3 +++ .../fc18/FourCornerUnicodeDisplayTest.java | 7 +++-- .../fc18/zero33/FCDotDEC1604DashP7Test.java | 8 +++--- 7 files changed, 54 insertions(+), 40 deletions(-) diff --git a/nx01-x4o-o2o/src/main/java/org/x4o/o2o/fc18/FourCornerDotCake.java b/nx01-x4o-o2o/src/main/java/org/x4o/o2o/fc18/FourCornerDotCake.java index f3a9863..b7054b7 100644 --- a/nx01-x4o-o2o/src/main/java/org/x4o/o2o/fc18/FourCornerDotCake.java +++ b/nx01-x4o-o2o/src/main/java/org/x4o/o2o/fc18/FourCornerDotCake.java @@ -187,15 +187,13 @@ public enum FourCornerDotCake { __RESERVED_CLKSP(1 + FC_CLK1K_AMP.getStop(), 0x37000 - FC_CLK1K_AMP.getStop() - 1), /// Support lower 11 bit of unicode to be encoded with one cake point. - __RESERVED_UNI1102_1C(1 + __RESERVED_CLKSP.getStop(), 2048), + FC_UNI1102_1C(1 + __RESERVED_CLKSP.getStop(), 2048), /// Prefix "1C" cake with big indian 11 bit half words to get full 21 bit unicode-one point. - __RESERVED_UNI1102_2C(1 + __RESERVED_UNI1102_1C.getStop(), 2048), + FC_UNI1102_2C(1 + FC_UNI1102_1C.getStop(), 2048), - /// Big indian 9 bit parts of 72 bit Unicode-4, which stroke drawing without color. - /// and can contain the 21 bit unicode1 codePoint data within. - __RESERVED_UNI4072_4D(1 + __RESERVED_UNI1102_2C.getStop(), 512), - - __RESERVED_TAIL(1 + __RESERVED_UNI4072_4D.getStop(), 262144 - __RESERVED_UNI4072_4D.getStop() - 1), + /// MUST Prefix with __ESC18_NETHER, than pack big indian octals per 5, which is 15 bit data in one 18 bit cake point. + /// This can encode dark text data like icons, bitmap images or vector images and unicode4D/etc. + FC_NETHER(1 + FC_UNI1102_2C.getStop(), 262144 - FC_UNI1102_2C.getStop() - 1), ; private final int start; 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 c645799..442a67c 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 @@ -344,23 +344,12 @@ public class FourCornerUnicodeDisplay { if (FCDotDEC1604DashP7.__ESC68_FC18.equals(decCode)) { return decCode.ordinal(); // todo handle } - if (FCDotDEC1604DashP7.__ESC_BELOW.equals(decCode)) { + if (FCDotDEC1604DashP7.__ESC18_NETHER.equals(decCode)) { if (!cdc.hasNext()) { return null; } - int checkChr = cdc.next(); - int idx = checkChr - FCDotCDC1604DashP6.NX01_A.ordinal(); - if (idx > 26 || idx < 0) { - return checkChr; // can't handle this - } - 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)); + buf.append(FCDotCDC1604DashP6.escapeSignUnicode(FCDotCDC1604DashP6.__ESC6.ordinal()));// TODO: add new symbol + // TODO: eat header and eat data, as we can't display it return null; } if (!renderHiddenControls) { diff --git a/nx01-x4o-o2o/src/main/java/org/x4o/o2o/fc18/pie9c/FCDotPIE9CDash10.java b/nx01-x4o-o2o/src/main/java/org/x4o/o2o/fc18/pie9c/FCDotPIE9CDash10.java index 674724d..4d09ce7 100644 --- a/nx01-x4o-o2o/src/main/java/org/x4o/o2o/fc18/pie9c/FCDotPIE9CDash10.java +++ b/nx01-x4o-o2o/src/main/java/org/x4o/o2o/fc18/pie9c/FCDotPIE9CDash10.java @@ -27,6 +27,7 @@ import java.util.List; import java.util.PrimitiveIterator; import org.x4o.o2o.fc18.FourCornerDotCake; +import org.x4o.o2o.fc18.FourCornerX00PetitVidePoints; import org.x4o.o2o.fc18.FourCornerX06BaklavaPoints; import org.x4o.o2o.fc18.FourCornerX08MuffinPoints; import org.x4o.o2o.fc18.FourCornerX18CakePoints; @@ -78,14 +79,27 @@ public enum FCDotPIE9CDash10 implements FourCornerX06BaklavaPoints, FourCornerX0 return codePoints; } - static public List toDecimals(int value) { - List result = new ArrayList<>(); + static public List toDecimalsX06(int value) { + return toDecimalsX00(value); + } + + static public List toDecimalsX18(int value) { + return toDecimalsX00(value); + } + + @SuppressWarnings("unchecked") + static private List toDecimalsX00(int value) { + List result = new ArrayList<>(); String valueStr = Integer.toString(value); PrimitiveIterator.OfInt i = valueStr.codePoints().iterator(); while (i.hasNext()) { int chr = i.nextInt(); int num = chr - '0'; - result.add(values()[num]); + if (result.isEmpty()) { + result.add((T) values()[num]); // Add escaping only once + } else { + result.add((T) FCDotCDC1604DashP6.indexOf(FCDotCDC1604DashP6.NX01_A.ordinal() + num)); + } } return result; } 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 52ce5bf..0d23b38 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 @@ -34,7 +34,7 @@ import org.x4o.o2o.fc18.FourCornerX18CakePoints; * * A 8 or 18 or 144 bit computer uses this direct as the second 64 part page. (thus number 64 to 127) * - * NOTE: Old MSX is VT-52 see https://www.msx.org/wiki/MSX_Characters_and_Control_Codes#Escape_codes new MSX4 is VT-NX01 + * Defines VT-NX01 which are terminal escape sequences for text based applications. * * @author Willem Cazander * @version 1.0 Dec 24, 2024 @@ -50,17 +50,28 @@ public enum FCDotDEC1604DashP7 implements FourCornerX06BaklavaPoints, FourCorner /// Duel escape stops the escaped PIE or PIN escape sequence data mode. /// VT-100 Manual: "ESC also cancels any escape sequence". __ESC_STOP, - /// On 6/8 bit escape to 18 bit four corner. - /// Stream six octals as CDC chars in NX01_A to NX08_H, until any out of range P6. + /// On 6/8 bit escape to 18 bit four corner cake points. + /// Stream per six octals as CDC chars in NX01_A to NX08_H, until any out of range P6. __ESC68_FC18, - /// Escape below for VT-52 lower case escape code, the one next char is NX01_A to NX06_Z for all systems. - /// NOTE: Other lower case chars in escape sequence needs to be encoded normally via __PIE68 and NX26_Z chars. - __ESC_BELOW, + /// To escape the question of undefined behavior, we define it as dark nether space, so we can see it in C++ + /// Using dark mode nether requires 18 bit cake points as we embed 15 bit data point in the cake; + /// + /// __ESC18_NETHER + /// + ?VT_NX01_NEXT + ?slug (None or 72 to 576 bit Número2 Lingua tree key per 72 bit slug) + /// + ?VT_NX01_NEXT + ?slug (Up to 8 slug arguments to have max key) + /// + VT_NX01_EXECUTE + data-block as FC_NETHER in 15 bit embedded octals + /// + /// NOTE: key slug format is <6><6><6><9><6><6><6><6><6><6><9> encoded in FC_OCE0808_H6 and FC_OCE0808_H9 + /// + /// With dark nether space you can add unnamed and real dark(key is optional) undefined data segments in text. + /// With an nether DB enabled text editor, it can render for example vector graphics in source like HolyC of TempleOS. + /// The Número2 Lingua key is a sort of mime-type lookup, and later gets also definition structure and step code for type. + __ESC18_NETHER, /// VT-NX01 = __ESC6 ? = Next argument separator VT_NX01_NEXT, /// VT-NX01 = __ESC6 ! = End of P7 sequence started from NX01_A2Amp to execute the VT command. - /// NOTE: Escape sequences below A have no end of sequence behavior defined. + /// NOTE: Designed to only be used in escape sequences in the letter range A to AMP. VT_NX01_EXECUTE, UNDEFINED__TAG_CURLY_LEFT, @@ -139,7 +150,7 @@ public enum FCDotDEC1604DashP7 implements FourCornerX06BaklavaPoints, FourCorner /// VT-NX01 = __ESC6 & + ?num/s + VT_NX01_EXECUTE = Ring the bells per second, one is one ring and two is two rings in one time unit NX_BELL, - // MSX is simple VT-52 for reference; + // MSX is simple VT-52 for reference see https://www.msx.org/wiki/MSX_Characters_and_Control_Codes#Escape_codes // // ANSI CSI has dynamic termination; // - ESC [ diff --git a/nx01-x4o-o2o/src/test/java/org/x4o/o2o/fc18/FourCornerDotCakeTest.java b/nx01-x4o-o2o/src/test/java/org/x4o/o2o/fc18/FourCornerDotCakeTest.java index e5cbcee..19b07ca 100644 --- a/nx01-x4o-o2o/src/test/java/org/x4o/o2o/fc18/FourCornerDotCakeTest.java +++ b/nx01-x4o-o2o/src/test/java/org/x4o/o2o/fc18/FourCornerDotCakeTest.java @@ -35,10 +35,13 @@ public class FourCornerDotCakeTest { @Test public void testValues() throws Exception { + int sizeTotal = 0; for (FourCornerDotCake v : FourCornerDotCake.values()) { Assertions.assertNotNull(v); Assertions.assertTrue(v.getStart() <= v.getStop(), "Start is larger than stop in: " + v.name()); + sizeTotal += v.getLength(); System.out.println("Cake start: 0x" + Integer.toHexString(v.getStart()) + " end: 0" + Integer.toHexString(v.getStop()) + " of " + v.name() + " size: " + v.getLength()); } + Assertions.assertEquals(262144, sizeTotal); } } 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 92d1e0e..2c6ac0f 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 @@ -102,9 +102,8 @@ public class FourCornerUnicodeDisplayTest { cdc.add(FCDotPIE9CDash26.LOW_B); // if used as this per letter full escaping here.... cdc.add(FCDotCDC1604DashP6._SPACE); // out of range is end lower cdc.add(FCDotCDC1604DashP6.NX02_B); - cdc.add(FCDotDEC1604DashP7.__ESC_BELOW); // test escape code cdc.add(FCDotCDC1604DashP6.NX03_C); - cdc.add(FCDotCDC1604DashP6.NX04_D); // thus this upper case D + cdc.add(FCDotCDC1604DashP6.NX04_D); cdc.add(FCDotCDC1604DashP6.DOT); cdc.add(FCDotCDC1604DashP6.__PIE68); cdc.add(FCDotCDC1604DashP6.NX26_Z); // select lower case @@ -115,8 +114,8 @@ public class FourCornerUnicodeDisplayTest { cdc.add(FCDotDEC1604DashP7.__ESC_STOP); cdc.add(FCDotCDC1604DashP6.NX15_O); - Assertions.assertEquals("ab B␃cD.jklmO", FourCornerUnicodeDisplay.text().renderFromX06(cdc)); - Assertions.assertEquals("␁ZA␁ZB B␃CD.␁ZJKLM␃␃O", FourCornerUnicodeDisplay.raw().renderFromX06(cdc)); + Assertions.assertEquals("ab BCD.jklmO", FourCornerUnicodeDisplay.text().renderFromX06(cdc)); + Assertions.assertEquals("␁ZA␁ZB BCD.␁ZJKLM␃␃O", FourCornerUnicodeDisplay.raw().renderFromX06(cdc)); } @Test diff --git a/nx01-x4o-o2o/src/test/java/org/x4o/o2o/fc18/zero33/FCDotDEC1604DashP7Test.java b/nx01-x4o-o2o/src/test/java/org/x4o/o2o/fc18/zero33/FCDotDEC1604DashP7Test.java index 7edace2..9a7c53d 100644 --- a/nx01-x4o-o2o/src/test/java/org/x4o/o2o/fc18/zero33/FCDotDEC1604DashP7Test.java +++ b/nx01-x4o-o2o/src/test/java/org/x4o/o2o/fc18/zero33/FCDotDEC1604DashP7Test.java @@ -57,12 +57,12 @@ public class FCDotDEC1604DashP7Test { public void testCusorGoto() throws Exception { List cdc = new ArrayList<>(); cdc.add(FCDotDEC1604DashP7.NX_CURSOR_GOTO); - cdc.addAll(FCDotPIE9CDash10.toDecimals(123)); + cdc.addAll(FCDotPIE9CDash10.toDecimalsX06(123)); cdc.add(FCDotDEC1604DashP7.VT_NX01_NEXT); - cdc.addAll(FCDotPIE9CDash10.toDecimals(456)); + cdc.addAll(FCDotPIE9CDash10.toDecimalsX06(456)); cdc.add(FCDotDEC1604DashP7.VT_NX01_EXECUTE); - Assertions.assertEquals("␃Y␁JB␁JC␁JD␃?␁JE␁JF␁JG␃!", FourCornerUnicodeDisplay.raw().renderFromX06(cdc)); + Assertions.assertEquals("␃Y␁JBCD␃?␁JEFG␃!", FourCornerUnicodeDisplay.raw().renderFromX06(cdc)); Assertions.assertEquals("␃Y123␃?456␃!", FourCornerUnicodeDisplay.text().renderFromX06(cdc)); } @@ -70,7 +70,7 @@ public class FCDotDEC1604DashP7Test { public void testClearTop5Lines() throws Exception { List cdc = new ArrayList<>(); cdc.add(FCDotDEC1604DashP7.NX_CLEAR_TOP); - cdc.addAll(FCDotPIE9CDash10.toDecimals(5)); + cdc.addAll(FCDotPIE9CDash10.toDecimalsX06(5)); cdc.add(FCDotDEC1604DashP7.VT_NX01_EXECUTE); Assertions.assertEquals("␃E␁JF␃!", FourCornerUnicodeDisplay.raw().renderFromX06(cdc));