Skip to content

Commit

Permalink
Force decoding mouse position using UTF-8, fixes #284
Browse files Browse the repository at this point in the history
  • Loading branch information
gnodet committed Jun 8, 2018
1 parent 840d45e commit 5f97cca
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion terminal/src/main/java/org/jline/terminal/impl/MouseSupport.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@
import org.jline.terminal.MouseEvent;
import org.jline.terminal.Terminal;
import org.jline.utils.InfoCmp;
import org.jline.utils.InputStreamReader;

import java.io.EOFException;
import java.io.IOError;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.EnumSet;
import java.util.function.IntSupplier;

Expand Down Expand Up @@ -116,7 +118,14 @@ public static MouseEvent readMouse(IntSupplier reader, MouseEvent last) {

private static int readExt(Terminal terminal) {
try {
int c = terminal.reader().read();
// The coordinates are encoded in UTF-8, so if that's not the input encoding,
// we need to get around
int c;
if (terminal.encoding() != StandardCharsets.UTF_8) {
c = new InputStreamReader(terminal.input(), StandardCharsets.UTF_8).read();
} else {
c = terminal.reader().read();
}
if (c < 0) {
throw new EOFException();
}
Expand Down

0 comments on commit 5f97cca

Please sign in to comment.