Skip to content

Commit 4e63a2d

Browse files
timfelansalond
authored andcommitted
don't force print the prompt when reading a line with the ConsoleHandler
(cherry picked from commit 0bd4d9c)
1 parent 6d0c7cb commit 4e63a2d

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

graalpython/com.oracle.graal.python.shell/src/com/oracle/graal/python/shell/ConsoleHandler.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,11 @@ public abstract class ConsoleHandler {
6363
/**
6464
* Read a line of input, newline is <b>NOT</b> included in result.
6565
*/
66-
public abstract String readLine();
66+
public final String readLine() {
67+
return readLine(true);
68+
}
69+
70+
public abstract String readLine(boolean prompt);
6771

6872
public abstract void setPrompt(String prompt);
6973

@@ -90,7 +94,7 @@ public InputStream createInputStream() {
9094
public int read() throws IOException {
9195
if (buffer == null) {
9296
pos = 0;
93-
String line = readLine();
97+
String line = readLine(false);
9498
if (line == null) {
9599
return -1;
96100
}

graalpython/com.oracle.graal.python.shell/src/com/oracle/graal/python/shell/DefaultConsoleHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ public DefaultConsoleHandler(InputStream in, OutputStream out) {
5959
}
6060

6161
@Override
62-
public String readLine() {
62+
public String readLine(boolean showPrompt) {
6363
try {
64-
if (prompt != null) {
64+
if (prompt != null && showPrompt) {
6565
out.print(prompt);
6666
}
6767
return in.readLine();

graalpython/com.oracle.graal.python.shell/src/com/oracle/graal/python/shell/JLineConsoleHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,10 +237,10 @@ public void setContext(Context context) {
237237
}
238238

239239
@Override
240-
public String readLine() {
240+
public String readLine(boolean showPrompt) {
241241
try {
242242
console.getTerminal().init();
243-
return console.readLine();
243+
return console.readLine(showPrompt ? console.getPrompt() : "");
244244
} catch (UserInterruptException e) {
245245
throw e;
246246
} catch (Exception ex) {

0 commit comments

Comments
 (0)