Skip to content

Commit 01969b5

Browse files
committed
Fix regression in public ConsoleReader#print() api
Fixes #243, #205
1 parent ddc5a64 commit 01969b5

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

src/main/java/jline/console/ConsoleReader.java

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ public void drawLine() throws IOException {
682682
rawPrint(prompt);
683683
}
684684

685-
print(buf.buffer, 0, buf.cursor, promptLen);
685+
fmtPrint(buf.buffer, 0, buf.cursor, promptLen);
686686

687687
// force drawBuffer to check for weird wrap (after clear screen)
688688
drawBuffer();
@@ -894,7 +894,7 @@ protected String expandEvents(String str) throws IOException {
894894
}
895895
String result = sb.toString();
896896
if (!str.equals(result)) {
897-
print(result);
897+
fmtPrint(result, getCursorPosition());
898898
println();
899899
flush();
900900
}
@@ -910,7 +910,7 @@ public void putString(final CharSequence str) throws IOException {
910910
buf.write(str);
911911
if (mask == null) {
912912
// no masking
913-
print(str, pos);
913+
fmtPrint(str, pos);
914914
} else if (mask == NULL_MASK) {
915915
// don't print anything
916916
} else {
@@ -936,7 +936,7 @@ private void drawBuffer(final int clear) throws IOException {
936936
nbChars = 0;
937937
}
938938
} else {
939-
print(buf.buffer, buf.cursor, buf.length());
939+
fmtPrint(buf.buffer, buf.cursor, buf.length());
940940
}
941941
}
942942
int cursorPos = promptLen + wcwidth(buf.buffer, 0, buf.length(), promptLen);
@@ -3434,20 +3434,18 @@ else if (!next && !history.previous()) {
34343434
// Printing
34353435
//
34363436

3437-
public static final String CR = Configuration.getLineSeparator();
3438-
34393437
/**
34403438
* Output the specified characters to the output stream without manipulating the current buffer.
34413439
*/
3442-
private int print(final CharSequence buff, int cursorPos) throws IOException {
3443-
return print(buff, 0, buff.length(), cursorPos);
3440+
private int fmtPrint(final CharSequence buff, int cursorPos) throws IOException {
3441+
return fmtPrint(buff, 0, buff.length(), cursorPos);
34443442
}
34453443

3446-
private int print(final CharSequence buff, int start, int end) throws IOException {
3447-
return print(buff, start, end, getCursorPosition());
3444+
private int fmtPrint(final CharSequence buff, int start, int end) throws IOException {
3445+
return fmtPrint(buff, start, end, getCursorPosition());
34483446
}
34493447

3450-
private int print(final CharSequence buff, int start, int end, int cursorPos) throws IOException {
3448+
private int fmtPrint(final CharSequence buff, int start, int end, int cursorPos) throws IOException {
34513449
checkNotNull(buff);
34523450
for (int i = start; i < end; i++) {
34533451
char c = buff.charAt(i);
@@ -3477,7 +3475,7 @@ private int print(final CharSequence buff, int start, int end, int cursorPos) th
34773475
* Output the specified string to the output stream (but not the buffer).
34783476
*/
34793477
public void print(final CharSequence s) throws IOException {
3480-
print(s, getCursorPosition());
3478+
rawPrint(s.toString());
34813479
}
34823480

34833481
public void println(final CharSequence s) throws IOException {

0 commit comments

Comments
 (0)