Skip to content

Commit

Permalink
Merge pull request #412 from mattirn/issue-411
Browse files Browse the repository at this point in the history
Fix dumb terminal prompt, fixes issue #411
  • Loading branch information
gnodet committed Jul 7, 2019
2 parents a6862d6 + 2daaf11 commit d5037af
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions reader/src/main/java/org/jline/reader/impl/LineReaderImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -481,8 +481,7 @@ public String readLine(String prompt, String rightPrompt, MaskingCallback maskin
SignalHandler previousWinchHandler = null;
SignalHandler previousContHandler = null;
Attributes originalAttributes = null;
boolean dumb = Terminal.TYPE_DUMB.equals(terminal.getType())
|| Terminal.TYPE_DUMB_COLOR.equals(terminal.getType());
boolean dumb = isTerminalDumb();
try {

this.maskingCallback = maskingCallback;
Expand Down Expand Up @@ -665,6 +664,11 @@ public String readLine(String prompt, String rightPrompt, MaskingCallback maskin
startedReading.set(false);
}
}

private boolean isTerminalDumb(){
return Terminal.TYPE_DUMB.equals(terminal.getType())
|| Terminal.TYPE_DUMB_COLOR.equals(terminal.getType());
}

private void doDisplay(){
// Cache terminal size for the duration of the call to readLine()
Expand Down Expand Up @@ -3732,14 +3736,13 @@ protected void redisplay(boolean flush) {
if (!promptLines.isEmpty()) {
cursorNewLinesId = promptLines.size() - 1;
cursorColPos = promptLines.get(promptLines.size() - 1).columnLength();
cursorPos = size.cursorPos(promptLines.size() - 1,
promptLines.get(promptLines.size() - 1).columnLength());
cursorPos = size.cursorPos(cursorNewLinesId, cursorColPos);
}
}

List<AttributedString> newLinesToDisplay = new ArrayList<>();
int displaySize = size.getRows() - (status != null ? status.size() : 0);
if (newLines.size() > displaySize) {
if (newLines.size() > displaySize && !isTerminalDumb()) {
StringBuilder sb = new StringBuilder(">....");
// blanks are needed when displaying command completion candidate list
for (int i = sb.toString().length(); i < size.getColumns(); i++) {
Expand Down

0 comments on commit d5037af

Please sign in to comment.