Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ public DSR(final Terminal terminal) {
super(terminal);
}

@Override
public int[] defaultParameters(CSIState state) {
// Ps omitted (or 0) defaults to 5 — device status report. CSIManager substitutes
// this before execute, so a bare CSI n replies \033[0n instead of hanging the guest
// waiting for a status response that never comes (§36 m4).
return new int[] {5};
}

@Override
public void execute(int[] args, int argCount, CSIState state) {
if (args[0] == 5) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,32 @@ void vpaMovesRowOnly() {
assertEquals(6, terminal.y);
}

@Test
void dsrBareCsiNRepliesStatus() {
// §36 m4: DSR (CSI Ps n) with no Ps defaults to Ps=5 (device status). CSIManager
// substitutes the handler's defaultParameters before execute, so a bare CSI n
// replies \033[0n instead of hanging a guest waiting for a status response.
write(terminal, CSI + "n");
final ByteBuffer reply = terminal.io.getInput();
assertNotNull(reply, "bare CSI n must produce a status-report reply");
final byte[] bytes = new byte[reply.remaining()];
reply.get(bytes);
assertEquals("\033[0n", new String(bytes, StandardCharsets.US_ASCII),
"bare CSI n replies operating-status (\\033[0n)");
}

@Test
void dsrExplicitFiveStillRepliesStatus() {
// Explicit Ps=5 is unchanged by the defaultParameters fix — still a status report.
write(terminal, CSI + "5n");
final ByteBuffer reply = terminal.io.getInput();
assertNotNull(reply, "CSI 5n must produce a status-report reply");
final byte[] bytes = new byte[reply.remaining()];
reply.get(bytes);
assertEquals("\033[0n", new String(bytes, StandardCharsets.US_ASCII),
"CSI 5n replies operating-status (\\033[0n)");
}

@Test
void cudMovesCursorDownAndClampsSaturatedCount() {
// parseArgument saturates at Integer.MAX_VALUE; terminal.y + args[0] must not overflow to a
Expand Down