File tree 2 files changed +20
-5
lines changed
main/java/org/fusesource/jansi
test/java/org/fusesource/jansi
2 files changed +20
-5
lines changed Original file line number Diff line number Diff line change @@ -236,7 +236,7 @@ public Ansi a(Attribute attribute) {
236
236
}
237
237
238
238
@ Override
239
- public Ansi cursor (int x , int y ) {
239
+ public Ansi cursor (int row , int column ) {
240
240
return this ;
241
241
}
242
242
@@ -494,8 +494,17 @@ public Ansi a(Attribute attribute) {
494
494
return this ;
495
495
}
496
496
497
- public Ansi cursor (final int x , final int y ) {
498
- return appendEscapeSequence ('H' , x , y );
497
+ /**
498
+ * Moves the cursor to row n, column m.
499
+ * The values are 1-based, and default to 1 (top left corner) if omitted.
500
+ * A sequence such as CSI ;5H is a synonym for CSI 1;5H as well as CSI 17;H is the same as CSI 17H and CSI 17;1H
501
+ *
502
+ * @param row row (1-based) from top
503
+ * @param column column (1 based) from left
504
+ * @return Ansi
505
+ */
506
+ public Ansi cursor (final int row , final int column ) {
507
+ return appendEscapeSequence ('H' , row , column );
499
508
}
500
509
501
510
public Ansi cursorToColumn (final int x ) {
Original file line number Diff line number Diff line change 26
26
*/
27
27
public class AnsiStringTest {
28
28
@ Test
29
- public void testNotEncoded () throws Exception {
29
+ public void testNotEncoded () {
30
30
AnsiString as = new AnsiString ("foo" );
31
31
assertEquals ("foo" , as .getEncoded ());
32
32
assertEquals ("foo" , as .getPlain ());
33
33
assertEquals (3 , as .length ());
34
34
}
35
35
36
36
@ Test
37
- public void testEncoded () throws Exception {
37
+ public void testEncoded () {
38
38
AnsiString as = new AnsiString (Ansi .ansi ().a (Ansi .Attribute .INTENSITY_BOLD ).a ("foo" ).reset ().toString ());
39
39
assertEquals ("foo" , as .getPlain ());
40
40
assertEquals (3 , as .length ());
41
41
}
42
+
43
+ @ Test
44
+ public void testCursorPosition () {
45
+ Ansi ansi = Ansi .ansi ().cursor ( 3 , 6 ).reset ();
46
+ assertEquals ("\u001B [3;6H\u001B [m" , ansi .toString ());
47
+ }
42
48
}
You can’t perform that action at this time.
0 commit comments