FC18: Moved Salah Sequence interface into zion candlelier
This commit is contained in:
parent
61dbed85df
commit
62eca0d4b9
8 changed files with 128 additions and 47 deletions
|
|
@ -24,6 +24,7 @@ package org.x4o.fc18;
|
|||
|
||||
import java.math.BigInteger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.PrimitiveIterator;
|
||||
|
|
@ -38,6 +39,7 @@ import org.x4o.fc18.cake2.pie9c.FCDotPIE9CDash20;
|
|||
import org.x4o.fc18.cake2.zero33.FCDotCDC1604DashP6;
|
||||
import org.x4o.fc18.cake2.zero33.dec1.FCDotDEC2701DashPX0;
|
||||
import org.x4o.fc18.octal8.PrimordialOctal;
|
||||
import org.x4o.fc18.zion7.FourCornerZion7SalahSequence;
|
||||
|
||||
/// Holds different lookup and conversion maps towards four corner int18 cake points.
|
||||
///
|
||||
|
|
@ -52,11 +54,55 @@ final public class FourCornerRecipe {
|
|||
private FourCornerRecipe() {
|
||||
}
|
||||
|
||||
static public List<Integer> embedSandWalker(List<PrimordialOctal> rhythm) {
|
||||
return embedSandWalker(new ArrayList<>(), rhythm);
|
||||
static public List<Integer> embedSalahSequenceX06(FourCornerZion7SalahSequence type, List<List<Integer>> arguments) {
|
||||
return embedSalahSequence(new ArrayList<>(), type, arguments, true);
|
||||
}
|
||||
|
||||
static public List<Integer> embedSandWalker(List<Integer> out, List<PrimordialOctal> rhythm) {
|
||||
static public List<Integer> embedSalahSequenceX18(FourCornerZion7SalahSequence type, List<List<Integer>> arguments) {
|
||||
return embedSalahSequence(new ArrayList<>(), type, arguments, false);
|
||||
}
|
||||
|
||||
static public List<Integer> embedSalahSequenceX06(List<Integer> out, FourCornerZion7SalahSequence type, List<List<Integer>> arguments) {
|
||||
return embedSalahSequence(out, type, arguments, true);
|
||||
}
|
||||
|
||||
static public List<Integer> embedSalahSequenceX18(List<Integer> out, FourCornerZion7SalahSequence type, List<List<Integer>> arguments) {
|
||||
return embedSalahSequence(out, type, arguments, false);
|
||||
}
|
||||
|
||||
static private List<Integer> embedSalahSequence(List<Integer> out, FourCornerZion7SalahSequence type, List<List<Integer>> arguments, boolean isSixBit) {
|
||||
Objects.requireNonNull(type);
|
||||
Objects.requireNonNull(arguments);
|
||||
if (FourCornerZion7SalahSequence.ESC_VT06.equals(type)) {
|
||||
if (isSixBit) {
|
||||
out.addAll(FCDotDEC2701DashPX0.ESC_VT06.baklavaPointSequence());
|
||||
} else {
|
||||
out.addAll(FCDotDEC2701DashPX0.ESC_VT06.cakePointSequence());
|
||||
}
|
||||
} else {
|
||||
if (isSixBit) {
|
||||
out.addAll(FCDotDEC2701DashPX0.valueOf(type.ordinal()).baklavaPointSequence());
|
||||
} else {
|
||||
out.addAll(FCDotDEC2701DashPX0.valueOf(type.ordinal()).cakePointSequence());
|
||||
}
|
||||
}
|
||||
Iterator<List<Integer>> argu = arguments.iterator();
|
||||
while (argu.hasNext()) {
|
||||
List<Integer> arguValue = argu.next();
|
||||
out.addAll(arguValue); // TODO: add range check
|
||||
if (argu.hasNext()) {
|
||||
out.add(FCDotCDC1604DashP6._RAKA_QUESTION.baklavaPointDotIndex());
|
||||
}
|
||||
}
|
||||
out.add(FCDotCDC1604DashP6._SALAH_EXCLAMATION.baklavaPointDotIndex());
|
||||
return out;
|
||||
}
|
||||
|
||||
static public List<Integer> embedSandWalkerX06(List<PrimordialOctal> rhythm) {
|
||||
return embedSandWalkerX06(new ArrayList<>(), rhythm);
|
||||
}
|
||||
|
||||
static public List<Integer> embedSandWalkerX06(List<Integer> out, List<PrimordialOctal> rhythm) {
|
||||
Objects.requireNonNull(rhythm);
|
||||
if (!FourCornerRecipe.SAND_WORM_SIGN.contains(rhythm.size())) {
|
||||
throw new IllegalArgumentException("Sand walker rhythm is not 72 bit aligned: " + rhythm.size());
|
||||
|
|
@ -73,13 +119,12 @@ final public class FourCornerRecipe {
|
|||
return out;
|
||||
}
|
||||
|
||||
static public List<Integer> embedSandWorm(List<PrimordialOctal> spice) {
|
||||
return embedSandWorm(new ArrayList<>(), spice);
|
||||
static public List<Integer> embedSandWormX06(List<PrimordialOctal> spice) {
|
||||
return embedSandWormX06(new ArrayList<>(), spice);
|
||||
}
|
||||
|
||||
static public List<Integer> embedSandWorm(List<Integer> out, List<PrimordialOctal> spice) {
|
||||
static public List<Integer> embedSandWormX06(List<Integer> out, List<PrimordialOctal> spice) {
|
||||
Objects.requireNonNull(spice);
|
||||
// TODO: redo for 18 bit FC this is 6 bit
|
||||
out.add(FCDotDEC2701DashPX0.ESC68_SAND_WORM.cakePointDotIndex());
|
||||
for (int i = spice.size(); i >= 0; i--) {
|
||||
PrimordialOctal octal = spice.get(i);
|
||||
|
|
@ -89,6 +134,15 @@ final public class FourCornerRecipe {
|
|||
return out;
|
||||
}
|
||||
|
||||
static public List<Integer> embedSandWormX18(List<PrimordialOctal> spice) {
|
||||
return embedSandWormX18(new ArrayList<>(), spice);
|
||||
}
|
||||
|
||||
static public List<Integer> embedSandWormX18(List<Integer> out, List<PrimordialOctal> spice) {
|
||||
Objects.requireNonNull(spice);
|
||||
return embedSandWormX06(out, spice); // TODO: write 18 bit version
|
||||
}
|
||||
|
||||
static public List<Integer> embedNCR1632Denominator(BigInteger value) {
|
||||
return embedNCR1632Value(new ArrayList<>(), value, FourCornerDotCake.FC_NCR1632_DEN.getStart());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,9 @@ package org.x4o.fc18;
|
|||
|
||||
import java.math.BigInteger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Consumer;
|
||||
|
|
@ -38,6 +40,7 @@ import org.x4o.fc18.cake2.pie9d.FCDotPIE9DDash09;
|
|||
import org.x4o.fc18.cake2.zero33.FCDotCDC1604DashP6;
|
||||
import org.x4o.fc18.octal8.PrimordialOctal;
|
||||
import org.x4o.fc18.zion7.FourCornerZion7Candlelier;
|
||||
import org.x4o.fc18.zion7.FourCornerZion7SalahSequence;
|
||||
import org.x4o.fc18.zion7.FourCornerZionStenoLexer;
|
||||
import org.x4o.fc18.zion7.FourCornerZionStenoLexerSmoke;
|
||||
|
||||
|
|
@ -50,6 +53,7 @@ public class FourCornerUnicodeDisplay {
|
|||
private boolean failPipeSmoke = false;
|
||||
private boolean handleEscape = true;
|
||||
private String renderSeperator = null;
|
||||
private final Map<FourCornerZion7SalahSequence, Consumer<List<List<Integer>>>> escHandlers = new HashMap<>();
|
||||
|
||||
public FourCornerUnicodeDisplay(boolean failPipeSmoke, boolean handleEscape, String renderSeperator) {
|
||||
this.failPipeSmoke = failPipeSmoke;
|
||||
|
|
@ -57,10 +61,15 @@ public class FourCornerUnicodeDisplay {
|
|||
this.renderSeperator = renderSeperator;
|
||||
}
|
||||
|
||||
public FourCornerUnicodeDisplay withEscapeHandler(FourCornerZion7SalahSequence type, Consumer<List<List<Integer>>> handler) {
|
||||
escHandlers.put(type, handler);
|
||||
return this;
|
||||
}
|
||||
|
||||
static public FourCornerUnicodeDisplay text() {
|
||||
return new FourCornerUnicodeDisplay(false, true, null);
|
||||
}
|
||||
|
||||
|
||||
static public FourCornerUnicodeDisplay raw() {
|
||||
return new FourCornerUnicodeDisplay(false, false, null);
|
||||
}
|
||||
|
|
@ -257,5 +266,13 @@ public class FourCornerUnicodeDisplay {
|
|||
output.append("]");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void strobeSalahSequence(FourCornerZion7SalahSequence type, List<List<Integer>> arguments) {
|
||||
Consumer<List<List<Integer>>> handler = escHandlers.get(type);
|
||||
if (handler != null) {
|
||||
handler.accept(arguments);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,31 +45,31 @@ public enum FCDotDEC2701DashPX0 implements FourCornerX06BaklavaPointSequence, Fo
|
|||
// =========== External escape sequence, who MUST terminate with !
|
||||
|
||||
/// _ESC6_X1 _ESC6_X1 _ESC6_X1 = 1
|
||||
_ESC_USER_1,
|
||||
ESC_USER_1,
|
||||
|
||||
/// _ESC6_X1 _ESC6_X1 _ESC6_X2 = 2
|
||||
_ESC_USER_2,
|
||||
ESC_USER_2,
|
||||
|
||||
/// _ESC6_X1 _ESC6_X1 _ESC6_X3 = 3
|
||||
_ESC_USER_3,
|
||||
ESC_USER_3,
|
||||
|
||||
/// _ESC6_X1 _ESC6_X2 _ESC6_X1 = 4
|
||||
_ESC_USER_4,
|
||||
ESC_USER_4,
|
||||
|
||||
/// _ESC6_X1 _ESC6_X2 _ESC6_X2 = 5
|
||||
_ESC_USER_5,
|
||||
ESC_USER_5,
|
||||
|
||||
/// _ESC6_X1 _ESC6_X2 _ESC6_X3 = 6
|
||||
_ESC_USER_6,
|
||||
ESC_USER_6,
|
||||
|
||||
/// _ESC6_X1 _ESC6_X3 _ESC6_X1 = 7
|
||||
_ESC_USER_7,
|
||||
__ESC_RESERVED_A7,
|
||||
|
||||
/// _ESC6_X1 _ESC6_X3 _ESC6_X2 = 8
|
||||
_ESC_USER_8,
|
||||
__ESC_RESERVED_A8,
|
||||
|
||||
/// _ESC6_X1 _ESC6_X3 _ESC6_X3 = 9
|
||||
_ESC_USER_9,
|
||||
__ESC_RESERVED_A9,
|
||||
|
||||
// =========== Internal escape sequence, to embed symbols,fractions and adult texts.
|
||||
|
||||
|
|
@ -162,7 +162,7 @@ public enum FCDotDEC2701DashPX0 implements FourCornerX06BaklavaPointSequence, Fo
|
|||
}
|
||||
|
||||
public boolean isExternal() {
|
||||
if (ordinal() <= _ESC_USER_9.ordinal()) {
|
||||
if (ordinal() <= ESC_USER_6.ordinal()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -48,6 +48,9 @@ public interface FourCornerZion7Candlelier {
|
|||
/// Octal sand worm spice
|
||||
void strobeSandWorm(List<PrimordialOctal> spice);
|
||||
|
||||
/// Handles the lexer salah sequence strobes
|
||||
void strobeSalahSequence(FourCornerZion7SalahSequence type, List<List<Integer>> arguments);
|
||||
|
||||
interface Adapter extends FourCornerZion7Candlelier {
|
||||
|
||||
@Override
|
||||
|
|
@ -69,5 +72,9 @@ public interface FourCornerZion7Candlelier {
|
|||
@Override
|
||||
default void strobeSandWorm(List<PrimordialOctal> spice) {
|
||||
}
|
||||
|
||||
@Override
|
||||
default void strobeSalahSequence(FourCornerZion7SalahSequence type, List<List<Integer>> arguments) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,20 +22,18 @@
|
|||
*/
|
||||
package org.x4o.fc18.zion7;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/// Handles the lexer salah sequence strobes.
|
||||
/// The salah sequence strobe supported external types.
|
||||
///
|
||||
/// @author Willem Cazander
|
||||
/// @version 1.0 Jan 11, 2025
|
||||
public interface FourCornerZion7SalahSequence extends FourCornerZion7Candlelier {
|
||||
public enum FourCornerZion7SalahSequence {
|
||||
|
||||
void strobeSalahSequence(int type, List<List<Integer>> arguments);
|
||||
|
||||
interface Adapter extends FourCornerZion7SalahSequence, FourCornerZion7Candlelier.Adapter {
|
||||
|
||||
@Override
|
||||
default void strobeSalahSequence(int type, List<List<Integer>> arguments) {
|
||||
}
|
||||
}
|
||||
ESC_USER_1,
|
||||
ESC_USER_2,
|
||||
ESC_USER_3,
|
||||
ESC_USER_4,
|
||||
ESC_USER_5,
|
||||
ESC_USER_6,
|
||||
ESC_VT06,
|
||||
;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@ import java.util.List;
|
|||
import java.util.Objects;
|
||||
|
||||
import org.x4o.fc18.FourCornerRecipe;
|
||||
import org.x4o.fc18.cake2.zero33.dec1.FCDotDEC2701DashPX0;
|
||||
import org.x4o.fc18.octal8.PrimordialOctal;
|
||||
|
||||
/// Write steno for zion.
|
||||
|
|
@ -44,7 +43,7 @@ public class FourCornerZionStenoGrapher {
|
|||
return new FourCornerWriter(out, false);
|
||||
}
|
||||
|
||||
static public final class FourCornerWriter implements FourCornerZion7AlphaOmega,FourCornerZion7SalahSequence,FourCornerZion7TempleScrolls {
|
||||
static public final class FourCornerWriter implements FourCornerZion7AlphaOmega,FourCornerZion7TempleScrolls {
|
||||
|
||||
private final List<Integer> out;
|
||||
private final boolean isSixBit;
|
||||
|
|
@ -71,8 +70,9 @@ public class FourCornerZionStenoGrapher {
|
|||
|
||||
@Override
|
||||
public void strobeWords(List<Integer> cakePoints) {
|
||||
for (Integer cakePoint : cakePoints) { // todo: remove iterator
|
||||
strobeWord(cakePoint);
|
||||
int cakeSize = cakePoints.size();
|
||||
for (int i = 0; i < cakeSize; i++) {
|
||||
strobeWord(cakePoints.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -84,17 +84,25 @@ public class FourCornerZionStenoGrapher {
|
|||
|
||||
@Override
|
||||
public void strobeSandWalker(List<PrimordialOctal> rhythm) {
|
||||
FourCornerRecipe.embedSandWalker(out, rhythm);
|
||||
FourCornerRecipe.embedSandWalkerX06(out, rhythm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void strobeSandWorm(List<PrimordialOctal> spice) {
|
||||
FourCornerRecipe.embedSandWorm(out, spice);
|
||||
if (isSixBit) {
|
||||
FourCornerRecipe.embedSandWormX06(out, spice);
|
||||
} else {
|
||||
FourCornerRecipe.embedSandWormX18(out, spice);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void strobeSalahSequence(int type, List<List<Integer>> arguments) {
|
||||
FCDotDEC2701DashPX0 cdcDECMode = FCDotDEC2701DashPX0.valueOf(type);
|
||||
public void strobeSalahSequence(FourCornerZion7SalahSequence type, List<List<Integer>> arguments) {
|
||||
if (isSixBit) {
|
||||
FourCornerRecipe.embedSalahSequenceX06(out, type, arguments);
|
||||
} else {
|
||||
FourCornerRecipe.embedSalahSequenceX18(out, type, arguments);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,12 +51,10 @@ public class FourCornerZionStenoLexer {
|
|||
private final static FourCornerZion7AlphaOmega CLEAN_BIBLE = new FourCornerZion7AlphaOmega.Adapter() {};
|
||||
private final static FourCornerZionStenoLexerFire CLEAN_FIRE = new FourCornerZionStenoLexerFire.Adapter() {};
|
||||
private final static FourCornerZionStenoLexerSmoke CLEAN_SMOKE = new FourCornerZionStenoLexerSmoke.Adapter() {};
|
||||
private final static FourCornerZion7SalahSequence CLEAN_PRAYER = new FourCornerZion7SalahSequence.Adapter() {};
|
||||
private final static List<StenoScanner> CAKE_SLICE_EATERS = new ArrayList<>();
|
||||
private final boolean handlerEscape;
|
||||
private final FourCornerZion7Candlelier handler;
|
||||
private final FourCornerZion7AlphaOmega handlerDocument;
|
||||
private final FourCornerZion7SalahSequence handlerSalahSequence;
|
||||
private final FourCornerZion7TempleScrolls handlerTempleScrolls;
|
||||
private final int denominatorBank[] = new int[64]; // <== is the terminator select are 6 bit of banks with 9 bit of values.
|
||||
private final int numeratorBank[] = new int[denominatorBank.length];
|
||||
|
|
@ -115,11 +113,6 @@ public class FourCornerZionStenoLexer {
|
|||
} else {
|
||||
this.handlerDocument = CLEAN_BIBLE;
|
||||
}
|
||||
if (handler instanceof FourCornerZion7SalahSequence) {
|
||||
this.handlerSalahSequence = FourCornerZion7SalahSequence.class.cast(handler);
|
||||
} else {
|
||||
this.handlerSalahSequence = CLEAN_PRAYER;
|
||||
}
|
||||
if (handler instanceof FourCornerZion7TempleScrolls) {
|
||||
this.handlerTempleScrolls = FourCornerZion7TempleScrolls.class.cast(handler);
|
||||
} else {
|
||||
|
|
@ -501,7 +494,11 @@ public class FourCornerZionStenoLexer {
|
|||
if (readOK == false) {
|
||||
return true; // point is eaten
|
||||
}
|
||||
lexer.handlerSalahSequence.strobeSalahSequence(cdcDECMode.ordinal(), args);
|
||||
if (FCDotDEC2701DashPX0.ESC_VT06.equals(cdcDECMode)) {
|
||||
lexer.handler.strobeSalahSequence(FourCornerZion7SalahSequence.ESC_VT06, args);
|
||||
} else {
|
||||
lexer.handler.strobeSalahSequence(FourCornerZion7SalahSequence.values()[cdcDECMode.ordinal()], args); // todo: use fast enum
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (FCDotDEC2701DashPX0.ESC68_2PIE9C.equals(cdcDECMode)) {
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ public class FCDotDEC0127DashPX0Test {
|
|||
@Test
|
||||
public void testBaklavaSequence() throws Exception {
|
||||
List<Integer> seq = null;
|
||||
seq = FCDotDEC2701DashPX0._ESC_USER_1.baklavaPointSequence();
|
||||
seq = FCDotDEC2701DashPX0.ESC_USER_1.baklavaPointSequence();
|
||||
Assertions.assertEquals(3, seq.size());
|
||||
Assertions.assertEquals(FCDotCDC1604DashP6._ESC6_X1.ordinal(), seq.get(0));
|
||||
Assertions.assertEquals(FCDotCDC1604DashP6._ESC6_X1.ordinal(), seq.get(1));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue