Added test for cursor goto

This commit is contained in:
Willem Cazander 2025-01-08 16:27:48 +01:00
parent 62e0fae79d
commit d3441a683c
3 changed files with 44 additions and 4 deletions

View file

@ -22,6 +22,10 @@
*/
package org.x4o.o2o.fc18.pie9c;
import java.util.ArrayList;
import java.util.List;
import java.util.PrimitiveIterator;
import org.x4o.o2o.fc18.FourCornerDotCake;
import org.x4o.o2o.fc18.FourCornerX06BaklavaPoints;
import org.x4o.o2o.fc18.FourCornerX08MuffinPoints;
@ -73,4 +77,16 @@ public enum FCDotPIE9CDash10 implements FourCornerX06BaklavaPoints, FourCornerX0
public int[] codePoints() {
return codePoints;
}
static public List<FCDotPIE9CDash10> toDecimals(int value) {
List<FCDotPIE9CDash10> 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]);
}
return result;
}
}

View file

@ -57,8 +57,11 @@ public enum FCDotDEC1604DashP7 implements FourCornerX06BaklavaPoints, FourCorner
/// NOTE: Other lower case chars in escape sequence needs to be encoded normally via __PIE68 and NX26_Z chars.
__ESC_BELOW,
UNDEFINED__QUESTION,
UNDEFINED__EXCLAMATION,
/// VT-MSX4: char ? = Next argument separator
MSX4_ARGU_NEXT,
/// VT-MSX4: char ! = Argument end indicator
MSX4_ARGU_END,
UNDEFINED__TAG_CURLY_LEFT,
UNDEFINED__TAG_CURLY_RIGHT,
/// ANSI C1 char [ = CSI = Control Sequence Introducer
@ -126,8 +129,9 @@ public enum FCDotDEC1604DashP7 implements FourCornerX06BaklavaPoints, FourCorner
UNDEFINED__NX22_V,
UNDEFINED__NX23_W,
UNDEFINED__NX24_X,
/// VT-52 = ESC Y = Set cursor position
@Deprecated // TODO: on 6 bit this 64-32 = max 32, if normal a-& = max 27, thus redo VT encoding
/// VT-52 = ESC Y = Set cursor position
/// OLD is (char - 32) as int
/// NEW is __PIE68NXX10_J + MSX4_ARGU_NEXT + __PIE68NXX10_J + MSX4_ARGU_END
MSX_CURSOR_GOTO,
UNDEFINED__NX26_Z,
UNDEFINED__NX27_AMPERSAND,

View file

@ -22,8 +22,14 @@
*/
package org.x4o.o2o.fc18.zero33;
import java.util.ArrayList;
import java.util.List;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.x4o.o2o.fc18.FourCornerUnicodeDisplay;
import org.x4o.o2o.fc18.FourCornerX06BaklavaPoints;
import org.x4o.o2o.fc18.pie9c.FCDotPIE9CDash10;
/**
* Tests FCDotCDC1604DashP6 encoding.
@ -46,4 +52,18 @@ public class FCDotDEC1604DashP7Test {
Assertions.assertEquals(FCDotCDC1604DashP6.__ESC6.ordinal(), seq[0]);
Assertions.assertEquals(FCDotCDC1604DashP6.NX25_Y.ordinal(), seq[1]);
}
@Test
public void testCusorGoto() throws Exception {
List<FourCornerX06BaklavaPoints> cdc = new ArrayList<>();
cdc.add(FCDotDEC1604DashP7.MSX_CURSOR_GOTO);
cdc.addAll(FCDotPIE9CDash10.toDecimals(123));
cdc.add(FCDotDEC1604DashP7.MSX4_ARGU_NEXT);
cdc.addAll(FCDotPIE9CDash10.toDecimals(456));
cdc.add(FCDotDEC1604DashP7.MSX4_ARGU_END);
Assertions.assertEquals("␃Y␁JB␁JC␁JD␃?␁JE␁JF␁JG␃!", FourCornerUnicodeDisplay.raw().renderFromX06(cdc));
Assertions.assertEquals("␃Y123␃?456␃!", FourCornerUnicodeDisplay.text().renderFromX06(cdc));
}
}