diff --git a/reader/src/main/java/org/jline/reader/impl/LineReaderImpl.java b/reader/src/main/java/org/jline/reader/impl/LineReaderImpl.java index b7c9d625..0b4e6700 100644 --- a/reader/src/main/java/org/jline/reader/impl/LineReaderImpl.java +++ b/reader/src/main/java/org/jline/reader/impl/LineReaderImpl.java @@ -292,6 +292,7 @@ protected enum BellType { protected String alternateIn; protected String alternateOut; + protected List currentLines; public LineReaderImpl(Terminal terminal) throws IOException { this(terminal, terminal.getName(), null); @@ -4176,6 +4177,16 @@ private AttributedString expandPromptPattern(String pattern, int padToWidth, Str case 'N': sb.append(getInt(LINE_OFFSET, 0) + line); break decode; + case 'C': + sb.append(getInt(LINE_OFFSET, 0) + (line + 1)); + break decode; + case '*': + if (getCurrentLineNo(this.currentLines) == line) { + sb.append("*"); + } else { + sb.append(" "); + } + break decode; case 'M': if (message != null) sb.append(message); break decode; @@ -4231,6 +4242,21 @@ private AttributedString expandPromptPattern(String pattern, int padToWidth, Str return AttributedString.join(null, parts); } + private int getCurrentLineNo(List lines) { + int currentLine = -1; + int cursor = buf.cursor(); + int start = 0; + for (int l = 0; l < lines.size(); l++) { + int end = start + lines.get(l).length(); + if (cursor >= start && cursor <= end) { + currentLine = l; + break; + } + start = end + 1; + } + return currentLine; + } + private AttributedString fromAnsi(String str) { return AttributedString.fromAnsi(str, Collections.singletonList(0), alternateIn, alternateOut); } @@ -4277,6 +4303,7 @@ private AttributedString insertSecondaryPrompts( buf.setLength(0); } int line = 0; + this.currentLines = lines; while (line < lines.size() - 1) { sb.append(lines.get(line)).append("\n"); buf.append(lines.get(line)).append("\n");