Skip to content

Commit edd2de9

Browse files
committedOct 12, 2023
Send both SCO and DEC command for save/restore cursor position (fixes #226) (#262)
1 parent d285234 commit edd2de9

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed
 

‎src/main/java/org/fusesource/jansi/Ansi.java

+29-3
Original file line numberDiff line numberDiff line change
@@ -716,19 +716,45 @@ public Ansi scrollDown(final int rows) {
716716
return rows > 0 ? appendEscapeSequence('T', rows) : rows < 0 ? scrollUp(-rows) : this;
717717
}
718718

719+
@Deprecated
720+
public Ansi restorCursorPosition() {
721+
return restoreCursorPosition();
722+
}
723+
719724
public Ansi saveCursorPosition() {
725+
saveCursorPositionSCO();
726+
return saveCursorPositionDEC();
727+
}
728+
729+
// SCO command
730+
public Ansi saveCursorPositionSCO() {
720731
return appendEscapeSequence('s');
721732
}
722733

723-
@Deprecated
724-
public Ansi restorCursorPosition() {
725-
return appendEscapeSequence('u');
734+
// DEC command
735+
public Ansi saveCursorPositionDEC() {
736+
builder.append(FIRST_ESC_CHAR);
737+
builder.append('7');
738+
return this;
726739
}
727740

728741
public Ansi restoreCursorPosition() {
742+
restoreCursorPositionSCO();
743+
return restoreCursorPositionDEC();
744+
}
745+
746+
// SCO command
747+
public Ansi restoreCursorPositionSCO() {
729748
return appendEscapeSequence('u');
730749
}
731750

751+
// DEC command
752+
public Ansi restoreCursorPositionDEC() {
753+
builder.append(FIRST_ESC_CHAR);
754+
builder.append('8');
755+
return this;
756+
}
757+
732758
public Ansi reset() {
733759
return a(Attribute.RESET);
734760
}

0 commit comments

Comments
 (0)
Please sign in to comment.