Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent post-linebreak garbage character insertion #34

Merged
merged 1 commit into from
May 28, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
61 changes: 0 additions & 61 deletions src/main/java/jline/console/ConsoleReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -1829,15 +1829,6 @@ private void moveInternal(final int where) throws IOException {
int oldLine = (cursor - where) / width;
int newLine = cursor / width;
if (newLine > oldLine) {
if (terminal.hasWeirdWrap()) {
// scroll up if at bottom
// note:
// on rxvt cywgin terminal.getHeight() is incorrect
// MacOs xterm does not seem to support scrolling
if (getCurrentAnsiRow() == terminal.getHeight()) {
printAnsiSequence((newLine - oldLine) + "S");
}
}
printAnsiSequence((newLine - oldLine) + "B");
}
printAnsiSequence(1 +(cursor % width) + "G");
Expand Down Expand Up @@ -3468,56 +3459,4 @@ private void printAnsiSequence(String sequence) throws IOException {
print(sequence);
flush(); // helps with step debugging
}

// return column position, reported by the terminal
private int getCurrentPosition() {
// check for ByteArrayInputStream to disable for unit tests
if (terminal.isAnsiSupported() && !(in instanceof ByteArrayInputStream)) {
try {
printAnsiSequence("6n");
flush();
StringBuffer b = new StringBuffer(8);
// position is sent as <ESC>[{ROW};{COLUMN}R
int r;
while((r = in.read()) > -1 && r != 'R') {
if (r != 27 && r != '[') {
b.append((char) r);
}
}
String[] pos = b.toString().split(";");
return Integer.parseInt(pos[1]);
} catch (Exception x) {
// no luck
}
}

return -1; // TODO: throw exception instead?
}

// return row position, reported by the terminal
// needed to know whether to scroll up on cursor move in last col for weird
// wrapping terminals - not tested for anything else
private int getCurrentAnsiRow() {
// check for ByteArrayInputStream to disable for unit tests
if (terminal.isAnsiSupported() && !(in instanceof ByteArrayInputStream)) {
try {
printAnsiSequence("6n");
flush();
StringBuffer b = new StringBuffer(8);
// position is sent as <ESC>[{ROW};{COLUMN}R
int r;
while((r = in.read()) > -1 && r != 'R') {
if (r != 27 && r != '[') {
b.append((char) r);
}
}
String[] pos = b.toString().split(";");
return Integer.parseInt(pos[0]);
} catch (Exception x) {
// no luck
}
}

return -1; // TODO: throw exception instead?
}
}