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 class StenoUnicodePrinter implements FourCornerZion7Candlelier, FourCornerZionStenoLexerSmoke.Adapter {
private final StringBuilder output; private final StringBuilder output;
private final FourCornerZionStenoLexer thisDisplayEscaked;
private boolean wasExternalWord = false;
private StenoUnicodePrinter(StringBuilder output) { private StenoUnicodePrinter(StringBuilder output) {
this.output = Objects.requireNonNull(output); this.output = Objects.requireNonNull(output);
this.thisDisplayEscaked = new FourCornerZionStenoLexer(this, true);
} }
private boolean printedEscape(FourCornerDotCake slice, int offset) { private boolean printedEscape(FourCornerDotCake slice, int offset) {
@ -164,16 +167,20 @@ public class FourCornerUnicodeDisplay {
@Override @Override
public void strobeWords(FourCornerDotCake slice, List<Integer> offsets) { 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(); FourCornerX00PetitVidePoints[] videPoints = slice.getVidePoints();
if (slice.isExternWord()) { if (slice.isExternWord()) {
String fcQName = slice.qname(); 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 key = fcQName + "." + Integer.toString(offset);
String value = null; String value = null;
if (value != null) { if (value != null) {
@ -190,18 +197,15 @@ public class FourCornerUnicodeDisplay {
} }
} }
} }
if (renderSeperator != null && i.hasNext()) { if (renderSeperator != null && wasExternalWord) {
output.append(renderSeperator); output.append(renderSeperator);
} }
} wasExternalWord = true;
return; return;
} }
wasExternalWord = false;
if (videPoints.length > 0) { if (videPoints.length > 0) {
for (Integer offset : offsets) {
if (printedEscape(slice, offset)) {
continue;
}
//if (offset < 0 || offset > videPoints.length) { //if (offset < 0 || offset > videPoints.length) {
// continue; // continue;
//} //}
@ -209,16 +213,12 @@ public class FourCornerUnicodeDisplay {
if (videPoint.isX21()) { if (videPoint.isX21()) {
Arrays.stream(videPoint.toX21().codePoints()).forEach(v -> output.appendCodePoint(v)); Arrays.stream(videPoint.toX21().codePoints()).forEach(v -> output.appendCodePoint(v));
} }
}
return; return;
} }
output.append(slice.name()); output.append(slice.name());
output.append("#"); output.append("#");
for (Integer offset : offsets) {
output.append(offset); output.append(offset);
output.append("-");
}
output.append("#"); output.append("#");
} }
@ -246,7 +246,6 @@ public class FourCornerUnicodeDisplay {
@Override @Override
public void strobeRecursiveCake(List<Integer> cakePoints) { public void strobeRecursiveCake(List<Integer> cakePoints) {
FourCornerZionStenoLexer thisDisplayEscaked = new FourCornerZionStenoLexer(this, true);
thisDisplayEscaked.read(cakePoints); thisDisplayEscaked.read(cakePoints);
} }

View file

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

View file

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