kopia lustrzana https://github.com/maccasoft/z80-tools
Fixed cursor position and report sequences
rodzic
ad4ceddd1d
commit
1340425797
|
@ -10,17 +10,30 @@
|
|||
|
||||
package com.maccasoft.tools;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
public class TerminalTest extends DatabindingTestCase {
|
||||
|
||||
Shell shell;
|
||||
Terminal term;
|
||||
ByteArrayOutputStream out;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
shell = createShell();
|
||||
term = new Terminal(shell);
|
||||
|
||||
out = new ByteArrayOutputStream();
|
||||
|
||||
term = new Terminal(shell) {
|
||||
|
||||
@Override
|
||||
protected void writeByte(byte b) {
|
||||
out.write(b);
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -206,4 +219,23 @@ public class TerminalTest extends DatabindingTestCase {
|
|||
|
||||
assertEquals(Terminal.CURSOR_ON | Terminal.CURSOR_FLASH | Terminal.CURSOR_ULINE, term.cursor);
|
||||
}
|
||||
|
||||
public void testCursorReport() throws Exception {
|
||||
out = new ByteArrayOutputStream();
|
||||
term.print("\033[1;1f\033[6n");
|
||||
assertEquals("\033[1;1R", out.toString());
|
||||
|
||||
out = new ByteArrayOutputStream();
|
||||
term.print("\033[10;1f\033[6n");
|
||||
assertEquals("\033[10;1R", out.toString());
|
||||
|
||||
out = new ByteArrayOutputStream();
|
||||
term.print("\033[1;10f\033[6n");
|
||||
assertEquals("\033[1;10R", out.toString());
|
||||
}
|
||||
|
||||
public void testCursorPositionBounds() throws Exception {
|
||||
term.print("\033[100;100f\033[6n");
|
||||
assertEquals("\033[25;80R", out.toString());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -559,7 +559,13 @@ public class Terminal {
|
|||
}
|
||||
else if (argc >= 2) {
|
||||
cy = (args[0] > 0 ? (args[0] - 1) : 0) * font.getHeight();
|
||||
if (cy > (bounds.height - font.getHeight())) {
|
||||
cy = (bounds.height / font.getHeight() - 1) * font.getHeight();
|
||||
}
|
||||
cx = (args[1] > 0 ? (args[1] - 1) : 0) * font.getWidth();
|
||||
if (cx > (bounds.width - font.getWidth())) {
|
||||
cx = (bounds.width / font.getWidth() - 1) * font.getWidth();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'J': {
|
||||
|
@ -649,7 +655,7 @@ public class Terminal {
|
|||
writeByte((byte) 'n');
|
||||
}
|
||||
else if (args[0] == 6) {
|
||||
byte[] b = String.format("%c[%d;%dR", 0x1B, cy, cx).getBytes();
|
||||
byte[] b = String.format("%c[%d;%dR", 0x1B, (cy / font.getHeight()) + 1, (cx / font.getWidth()) + 1).getBytes();
|
||||
for (int i = 0; i < b.length; i++) {
|
||||
writeByte(b[i]);
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue