Skip to content

Commit

Permalink
Display#update() should flush the terminal
Browse files Browse the repository at this point in the history
  • Loading branch information
gnodet committed May 18, 2017
1 parent fe928e4 commit 599c1cc
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 19 deletions.
1 change: 0 additions & 1 deletion builtins/src/main/java/org/jline/builtins/Less.java
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,6 @@ boolean display(boolean oneScreen) throws IOException {

display.resize(size.getRows(), size.getColumns());
display.update(newLines, -1);
terminal.flush();
return false;
}

Expand Down
5 changes: 0 additions & 5 deletions builtins/src/main/java/org/jline/builtins/Nano.java
Original file line number Diff line number Diff line change
Expand Up @@ -1858,11 +1858,6 @@ synchronized void display() {
buffer.getDisplayedCursor());
}
display.update(newLines, cursor);
flush();
}

protected void flush() {
terminal.flush();
}

protected List<AttributedString> computeFooter() {
Expand Down
1 change: 0 additions & 1 deletion builtins/src/main/java/org/jline/builtins/TTop.java
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,6 @@ private void display() throws IOException {
}

display.update(lines, 0);
terminal.flush();
}

private Comparator<Map<String, Comparable<?>>> buildComparator(List<String> sort) {
Expand Down
1 change: 0 additions & 1 deletion builtins/src/main/java/org/jline/builtins/Tmux.java
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,6 @@ protected synchronized void redraw() {
}
display.resize(size.getRows(), size.getColumns());
display.update(lines, size.cursorPos(cursor[1], cursor[0]));
terminal.flush();
}

private void print(long[] screen, VirtualConsole terminal, String id, int color) {
Expand Down
13 changes: 3 additions & 10 deletions reader/src/main/java/org/jline/reader/impl/LineReaderImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ public void putString(final CharSequence str) {
* keyboard) that we want the terminal to handle immediately.
*/
public void flush() {
terminal.writer().flush();
terminal.flush();
}

public boolean isKeyMap(String name) {
Expand Down Expand Up @@ -3335,10 +3335,7 @@ protected void redisplay(boolean flush) {
full = sb.toAttributedString();
}

display.update(Collections.singletonList(full), cursor - smallTerminalOffset);
if (flush) {
flush();
}
display.update(Collections.singletonList(full), cursor - smallTerminalOffset, flush);
return;
}

Expand Down Expand Up @@ -3391,11 +3388,7 @@ protected void redisplay(boolean flush) {
}
}

display.update(newLines, cursorPos);

if (flush) {
flush();
}
display.update(newLines, cursorPos, flush);
}

private void concat(List<AttributedString> lines, AttributedStringBuilder sb) {
Expand Down
15 changes: 14 additions & 1 deletion terminal/src/main/java/org/jline/utils/Display.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,19 @@ public void updateAnsi(List<String> newLines, int targetCursorPos) {
}

/**
* Update the display according to the new lines
* Update the display according to the new lines and flushes the output.
* @param targetCursorPos desired cursor position - see Size.cursorPos.
*/
public void update(List<AttributedString> newLines, int targetCursorPos) {
update(newLines, targetCursorPos, true);
}

/**
* Update the display according to the new lines.
* @param targetCursorPos desired cursor position - see Size.cursorPos.
* @param flush whether the output should be flushed or not
*/
public void update(List<AttributedString> newLines, int targetCursorPos, boolean flush) {
if (reset) {
terminal.puts(Capability.clear_screen);
oldLines.clear();
Expand Down Expand Up @@ -316,6 +325,10 @@ public void update(List<AttributedString> newLines, int targetCursorPos) {
moveVisualCursorTo(targetCursorPos < 0 ? currentPos : targetCursorPos, newLines);
}
oldLines = newLines;

if (flush) {
terminal.flush();
}
}

protected boolean deleteLines(int nb) {
Expand Down

1 comment on commit 599c1cc

@jdillon
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx

Please sign in to comment.