Skip to content

Commit

Permalink
Fix tmux binding reading in case there are still some characters avai…
Browse files Browse the repository at this point in the history
…lable
  • Loading branch information
gnodet committed Mar 23, 2017
1 parent f1bd29a commit 7e11039
Showing 1 changed file with 29 additions and 13 deletions.
42 changes: 29 additions & 13 deletions builtins/src/main/java/org/jline/builtins/Tmux.java
Original file line number Diff line number Diff line change
Expand Up @@ -162,22 +162,38 @@ private void setDirty() {
private void inputLoop() {
try {
BindingReader reader = new BindingReader(terminal.reader());
boolean first = true;
while (running.get()) {
Object b = reader.readBinding(keyMap);
Object b;
if (first) {
b = reader.readBinding(keyMap);
} else if (reader.peekCharacter(100) >= 0) {
b = reader.readBinding(keyMap, null, false);
} else {
b = null;
}
if (b == Binding.SelfInsert) {
active.getMasterInputOutput().write(reader.getLastBinding().getBytes());
active.getMasterInputOutput().flush();
} else if (b == Binding.Mouse) {
MouseEvent event = terminal.readMouseEvent();
//System.err.println(event.toString());
} else if (b instanceof String) {
ByteArrayOutputStream out = new ByteArrayOutputStream();
ByteArrayOutputStream err = new ByteArrayOutputStream();
try (PrintStream pout = new PrintStream(out);
PrintStream perr = new PrintStream(err)) {
execute(pout, perr, (String) b);
} catch (Exception e) {
// TODO: log
first = false;
} else {
if (first) {
first = false;
} else {
active.getMasterInputOutput().flush();
first = true;
}
if (b == Binding.Mouse) {
MouseEvent event = terminal.readMouseEvent();
//System.err.println(event.toString());
} else if (b instanceof String) {
ByteArrayOutputStream out = new ByteArrayOutputStream();
ByteArrayOutputStream err = new ByteArrayOutputStream();
try (PrintStream pout = new PrintStream(out);
PrintStream perr = new PrintStream(err)) {
execute(pout, perr, (String) b);
} catch (Exception e) {
// TODO: log
}
}
}
}
Expand Down

0 comments on commit 7e11039

Please # to comment.