(Terminal terminal,
LineReader lineReader,
Renderer renderer,
boolean allowEscCancel,
boolean spaciousPrompt)
| 22 | } |
| 23 | |
| 24 | static PromptInput read(Terminal terminal, |
| 25 | LineReader lineReader, |
| 26 | Renderer renderer, |
| 27 | boolean allowEscCancel, |
| 28 | boolean spaciousPrompt) |
| 29 | throws UserInterruptException, EndOfFileException { |
| 30 | if (spaciousPrompt) { |
| 31 | renderer.stream().println(); |
| 32 | } |
| 33 | renderer.beforeInput(); |
| 34 | try { |
| 35 | String prompt = renderer.inputPrompt(); |
| 36 | String rightPrompt = renderer.inputRightPrompt(); |
| 37 | if (!allowEscCancel) { |
| 38 | return PromptInput.submitted(lineReader.readLine(prompt, rightPrompt, (MaskingCallback) null, null)); |
| 39 | } |
| 40 | if (terminal != null && terminal.writer() != null) { |
| 41 | terminal.writer().print(prompt); |
| 42 | terminal.writer().flush(); |
| 43 | } else { |
| 44 | renderer.stream().print(prompt); |
| 45 | renderer.stream().flush(); |
| 46 | } |
| 47 | CliTerminalInput.PrefillResult prefill = CliTerminalInput.readPrefill(terminal, lineReader); |
| 48 | if (prefill == null) { |
| 49 | return PromptInput.submitted(lineReader.readLine("", rightPrompt, (MaskingCallback) null, null)); |
| 50 | } |
| 51 | if (prefill.canceled()) { |
| 52 | return PromptInput.canceledInput(); |
| 53 | } |
| 54 | if (prefill.submitted()) { |
| 55 | return PromptInput.submitted(""); |
| 56 | } |
| 57 | return PromptInput.submitted( |
| 58 | lineReader.readLine("", rightPrompt, (MaskingCallback) null, prefill.seedBuffer())); |
| 59 | } finally { |
| 60 | renderer.afterInput(); |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | static boolean defaultSpaciousPrompt(boolean statusBarAvailable) { |
| 65 | return false; |
no test coverage detected