Added single word strobe to FC18 lexer candlelier

This commit is contained in:
Willem Cazander 2025-01-17 00:53:21 +01:00
parent 0d54b152dc
commit 73d408f1ec
3 changed files with 53 additions and 48 deletions

View file

@ -135,9 +135,12 @@ public class FourCornerUnicodeDisplay {
private final class StenoUnicodePrinter implements FourCornerZion7Candlelier, FourCornerZionStenoLexerSmoke.Adapter {
private final StringBuilder output;
private final FourCornerZionStenoLexer thisDisplayEscaked;
private boolean wasExternalWord = false;
private StenoUnicodePrinter(StringBuilder output) {
this.output = Objects.requireNonNull(output);
this.thisDisplayEscaked = new FourCornerZionStenoLexer(this, true);
}
private boolean printedEscape(FourCornerDotCake slice, int offset) {
@ -164,61 +167,58 @@ public class FourCornerUnicodeDisplay {
@Override
public void strobeWords(FourCornerDotCake slice, List<Integer> offsets) {
for (int i = 0; i < offsets.size(); i++) {
strobeWord(slice, offsets.get(i));
}
}
@Override
public void strobeWord(FourCornerDotCake slice, int offset) {
if (printedEscape(slice, offset)) {
return;
}
FourCornerX00PetitVidePoints[] videPoints = slice.getVidePoints();
if (slice.isExternWord()) {
String fcQName = slice.qname();
Iterator<Integer> i = offsets.iterator();
while (i.hasNext()) {
Integer offset = i.next();
if (printedEscape(slice, offset)) {
continue;
}
String key = fcQName + "." + Integer.toString(offset);
String value = null;
if (value != null) {
output.append(value);
} else {
FourCornerX00PetitVidePoints videPoint = videPoints[offset];
if (videPoint instanceof FourCornerX18CakeWord) {
FourCornerX18CakeWord cakeWord = FourCornerX18CakeWord.class.cast(videPoint);
FourCornerX18CakePoints[] wordDefault = cakeWord.nameDefault();
for (FourCornerX18CakePoints letter : wordDefault) {
if (letter.isX21()) {
Arrays.stream(letter.toX21().codePoints()).forEach(v -> output.appendCodePoint(v));
}
String key = fcQName + "." + Integer.toString(offset);
String value = null;
if (value != null) {
output.append(value);
} else {
FourCornerX00PetitVidePoints videPoint = videPoints[offset];
if (videPoint instanceof FourCornerX18CakeWord) {
FourCornerX18CakeWord cakeWord = FourCornerX18CakeWord.class.cast(videPoint);
FourCornerX18CakePoints[] wordDefault = cakeWord.nameDefault();
for (FourCornerX18CakePoints letter : wordDefault) {
if (letter.isX21()) {
Arrays.stream(letter.toX21().codePoints()).forEach(v -> output.appendCodePoint(v));
}
}
}
if (renderSeperator != null && i.hasNext()) {
output.append(renderSeperator);
}
}
if (renderSeperator != null && wasExternalWord) {
output.append(renderSeperator);
}
wasExternalWord = true;
return;
}
wasExternalWord = false;
if (videPoints.length > 0) {
for (Integer offset : offsets) {
if (printedEscape(slice, offset)) {
continue;
}
//if (offset < 0 || offset > videPoints.length) {
// continue;
//}
FourCornerX00PetitVidePoints videPoint = videPoints[offset];
if (videPoint.isX21()) {
Arrays.stream(videPoint.toX21().codePoints()).forEach(v -> output.appendCodePoint(v));
}
//if (offset < 0 || offset > videPoints.length) {
// continue;
//}
FourCornerX00PetitVidePoints videPoint = videPoints[offset];
if (videPoint.isX21()) {
Arrays.stream(videPoint.toX21().codePoints()).forEach(v -> output.appendCodePoint(v));
}
return;
}
output.append(slice.name());
output.append("#");
for (Integer offset : offsets) {
output.append(offset);
output.append("-");
}
output.append(offset);
output.append("#");
}
@ -246,7 +246,6 @@ public class FourCornerUnicodeDisplay {
@Override
public void strobeRecursiveCake(List<Integer> cakePoints) {
FourCornerZionStenoLexer thisDisplayEscaked = new FourCornerZionStenoLexer(this, true);
thisDisplayEscaked.read(cakePoints);
}

View file

@ -36,6 +36,8 @@ public interface FourCornerZion7Candlelier {
/// Block of relative slice numbers.
void strobeWords(FourCornerDotCake slice, List<Integer> offsets);
void strobeWord(FourCornerDotCake slice, int offset);
/// One based already
void strobeNCR1632(BigInteger denominator, BigInteger numerator);
@ -51,6 +53,10 @@ public interface FourCornerZion7Candlelier {
default void strobeWords(FourCornerDotCake slice, List<Integer> offsets) {
}
@Override
default void strobeWord(FourCornerDotCake slice, int offset) {
}
@Override
default void strobeNCR1632(BigInteger denominator, BigInteger numerator) {
}

View file

@ -399,9 +399,9 @@ public class FourCornerZionStenoLexer {
// No escaping, print CDC or DEC code
if (!lexer.handlerEscape) {
if (FourCornerDotCake.FC_DEC0127_PX0.contains(cdcDECPoint)) {
lexer.handler.strobeWords(FourCornerDotCake.FC_DEC0127_PX0, List.of(cdcDECPoint - FourCornerDotCake.FC_DEC0127_PX0.getStart()));
lexer.handler.strobeWord(FourCornerDotCake.FC_DEC0127_PX0, cdcDECPoint - FourCornerDotCake.FC_DEC0127_PX0.getStart());
} else {
lexer.handler.strobeWords(FourCornerDotCake.FC_CDC1604_P6, List.of(cdcDECPoint));
lexer.handler.strobeWord(FourCornerDotCake.FC_CDC1604_P6, cdcDECPoint);
}
continue;
}
@ -498,27 +498,27 @@ public class FourCornerZionStenoLexer {
// FIXME: this pages need a stop on out of range too
if (decMode == FCDotDEC0127DashPX0.ESC6_APL0127_P7A) {
lexer.handler.strobeWords(FourCornerDotCake.FC_APL0127_P7A, List.of(cdcPoint - FCDotCDC1604DashP6.NX01_A.ordinal()));
lexer.handler.strobeWord(FourCornerDotCake.FC_APL0127_P7A, cdcPoint - FCDotCDC1604DashP6.NX01_A.ordinal());
return;
}
if (decMode == FCDotDEC0127DashPX0.ESC6_APL0127_P7B) {
lexer.handler.strobeWords(FourCornerDotCake.FC_APL0127_P7B, List.of(cdcPoint - FCDotCDC1604DashP6.NX01_A.ordinal()));
lexer.handler.strobeWord(FourCornerDotCake.FC_APL0127_P7B, cdcPoint - FCDotCDC1604DashP6.NX01_A.ordinal());
return;
}
if (decMode == FCDotDEC0127DashPX0.ESC6_APL0127_P7C) {
lexer.handler.strobeWords(FourCornerDotCake.FC_APL0127_P7C, List.of(cdcPoint - FCDotCDC1604DashP6.NX01_A.ordinal()));
lexer.handler.strobeWord(FourCornerDotCake.FC_APL0127_P7C, cdcPoint - FCDotCDC1604DashP6.NX01_A.ordinal());
return;
}
if (decMode == FCDotDEC0127DashPX0.ESC6_BYD0127_P7D) {
lexer.handler.strobeWords(FourCornerDotCake.FC_BYD0127_P7D, List.of(cdcPoint - FCDotCDC1604DashP6.NX01_A.ordinal()));
lexer.handler.strobeWord(FourCornerDotCake.FC_BYD0127_P7D, cdcPoint - FCDotCDC1604DashP6.NX01_A.ordinal());
return;
}
if (decMode == FCDotDEC0127DashPX0.ESC6_BYD0127_P7E) {
lexer.handler.strobeWords(FourCornerDotCake.FC_BYD0127_P7E, List.of(cdcPoint - FCDotCDC1604DashP6.NX01_A.ordinal()));
lexer.handler.strobeWord(FourCornerDotCake.FC_BYD0127_P7E, cdcPoint - FCDotCDC1604DashP6.NX01_A.ordinal());
return;
}
if (decMode == FCDotDEC0127DashPX0.ESC6_BYD0127_P7F) {
lexer.handler.strobeWords(FourCornerDotCake.FC_BYD0127_P7F, List.of(cdcPoint - FCDotCDC1604DashP6.NX01_A.ordinal()));
lexer.handler.strobeWord(FourCornerDotCake.FC_BYD0127_P7F, cdcPoint - FCDotCDC1604DashP6.NX01_A.ordinal());
return;
}
@ -540,14 +540,14 @@ public class FourCornerZionStenoLexer {
lexer.smokeSignals.burnUnsupported(lexer.currLine, lexer.currCol, cdcPoint);
return;
}
lexer.handler.strobeWords(slice.get(), List.of(cdcPoint));
lexer.handler.strobeWord(slice.get(), cdcPoint);
return;
}
if (numberPIE) {
int terminatorOffZero = numberMode - FCDotCDC1604DashP6.NX01_A.ordinal();
int numberIdxOffZero = cdcPoint - FCDotCDC1604DashP6.NX01_A.ordinal();
FourCornerDotCake slice = FourCornerDotCake.values()[terminatorOffZero + FourCornerDotCake.FC_PIE9C_01.ordinal()];
lexer.handler.strobeWords(slice, List.of(numberIdxOffZero));
lexer.handler.strobeWord(slice, numberIdxOffZero);
} else { // _PIN = ²
int terminatorOff = numberMode - FCDotCDC1604DashP6.NX01_A.ordinal() + 1;
int numberIdxOff = cdcPoint - FCDotCDC1604DashP6.NX01_A.ordinal() + 1;