Skip to content

Commit

Permalink
Fix right prompt support
Browse files Browse the repository at this point in the history
This is actually
gnodet@8e92151
  • Loading branch information
PerBothner committed Nov 20, 2016
1 parent a335cee commit 8bbf2c7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/main/java/org/jline/reader/impl/LineReaderImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -3448,11 +3448,15 @@ private AttributedString addRightPrompt(AttributedString prompt, AttributedStrin
int nb = size.getColumns() - width - line.columnLength() - 3;
if (nb >= 0) {
AttributedStringBuilder sb = new AttributedStringBuilder(size.getColumns());
sb.append(line);
boolean endsWithNl = line.charAt(line.length() - 1) == '\n';
sb.append(line, 0, endsWithNl ? line.length() - 1 : line.length());
for (int j = 0; j < nb + 2; j++) {
sb.append(' ');
}
sb.append(prompt);
if (endsWithNl) {
sb.append('\n');
}
line = sb.toAttributedString();
}
return line;
Expand Down
9 changes: 6 additions & 3 deletions src/main/java/org/jline/utils/AttributedStringBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,12 @@ public AttributedStyle style() {
}

public AttributedStringBuilder append(AttributedString str) {
int l = str.length();
ensureCapacity(length + l);
for (int i = 0; i < l; i++) {
return append(str, 0, str.length());
}

public AttributedStringBuilder append(AttributedString str, int start, int end) {
ensureCapacity(length + end - start);
for (int i = start; i < end; i++) {
char c = str.charAt(i);
int s = str.styleCodeAt(i) & ~current.getMask() | current.getStyle();
if (tabs > 0 && c == '\t') {
Expand Down

0 comments on commit 8bbf2c7

Please sign in to comment.