Class ConsolePrompt

java.lang.Object
org.jline.consoleui.prompt.ConsolePrompt

@Deprecated(since="4.0.0", forRemoval=true) public class ConsolePrompt extends Object
Deprecated, for removal: This API element is subject to removal in a future version.
This class is deprecated as of JLine 4.0.0. Please use the new jline-prompt module instead, which provides a cleaner, interface-based API. Use
invalid reference
org.jline.prompt.PrompterFactory#create(org.jline.terminal.Terminal)
to create a
invalid reference
org.jline.prompt.Prompter
instance.

Migration example:


             // Old API
             ConsolePrompt prompt = new ConsolePrompt(terminal);
             PromptBuilder builder = prompt.getPromptBuilder();

             // New API
             Prompter prompter = PrompterFactory.create(terminal);
             PromptBuilder builder = prompter.newBuilder();
             
ConsolePrompt encapsulates the prompting of a list of input questions for the user.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Deprecated, for removal: This API element is subject to removal in a future version.
    This class is deprecated along with ConsolePrompt.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected org.jline.terminal.Attributes
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    protected final ConsolePrompt.UiConfig
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    protected final org.jline.utils.Display
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    protected List<org.jline.utils.AttributedString>
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    protected final org.jline.reader.LineReader
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    protected final org.jline.terminal.Terminal
    Deprecated, for removal: This API element is subject to removal in a future version.
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    ConsolePrompt(org.jline.reader.LineReader reader, org.jline.terminal.Terminal terminal, ConsolePrompt.UiConfig config)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Use
    invalid reference
    org.jline.prompt.PrompterFactory#create(org.jline.reader.LineReader, org.jline.terminal.Terminal, org.jline.prompt.PrompterConfig)
    instead.
    ConsolePrompt(org.jline.terminal.Terminal terminal)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Use
    invalid reference
    org.jline.prompt.PrompterFactory#create(org.jline.terminal.Terminal)
    instead.
    ConsolePrompt(org.jline.terminal.Terminal terminal, ConsolePrompt.UiConfig config)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Use
    invalid reference
    org.jline.prompt.PrompterFactory#create(org.jline.terminal.Terminal, org.jline.prompt.PrompterConfig)
    instead.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    Deprecated, for removal: This API element is subject to removal in a future version.
    Exits raw mode and restores the terminal to its previous state.
    static int
    computePageSize(org.jline.terminal.Terminal terminal, int pageSize, PageSizeType sizeType)
    Deprecated, for removal: This API element is subject to removal in a future version.
    This method is deprecated along with the ConsolePrompt class.
    protected org.jline.utils.AttributedStringBuilder
    createMessage(String message, String response)
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    Deprecated, for removal: This API element is subject to removal in a future version.
    Use
    invalid reference
    org.jline.prompt.Prompter#newBuilder()
    instead.
    protected void
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    Deprecated, for removal: This API element is subject to removal in a future version.
    Use
    invalid reference
    org.jline.prompt.Prompter#prompt(java.util.List, java.util.function.Function)
    instead.
    prompt(List<PromptableElementIF> promptableElementList)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Use
    invalid reference
    org.jline.prompt.Prompter#prompt(java.util.List, java.util.List)
    instead.
    prompt(List<org.jline.utils.AttributedString> headerIn, Function<Map<String,PromptResultItemIF>,List<PromptableElementIF>> promptableElementLists)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Use
    invalid reference
    org.jline.prompt.Prompter#prompt(java.util.List, java.util.function.Function)
    instead.
    prompt(List<org.jline.utils.AttributedString> header, List<PromptableElementIF> promptableElementList)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Use
    invalid reference
    org.jline.prompt.Prompter#prompt(java.util.List, java.util.List)
    instead.
    protected void
    prompt(List<org.jline.utils.AttributedString> headerIn, List<PromptableElementIF> promptableElementList, Map<String,PromptResultItemIF> resultMap)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Prompt a list of choices (questions).
    promptElement(List<org.jline.utils.AttributedString> header, PromptableElementIF pe, PromptResultItemIF oldResult)
    Deprecated, for removal: This API element is subject to removal in a future version.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • reader

      protected final org.jline.reader.LineReader reader
      Deprecated, for removal: This API element is subject to removal in a future version.
    • terminal

      protected final org.jline.terminal.Terminal terminal
      Deprecated, for removal: This API element is subject to removal in a future version.
    • display

      protected final org.jline.utils.Display display
      Deprecated, for removal: This API element is subject to removal in a future version.
    • config

      protected final ConsolePrompt.UiConfig config
      Deprecated, for removal: This API element is subject to removal in a future version.
    • attributes

      protected org.jline.terminal.Attributes attributes
      Deprecated, for removal: This API element is subject to removal in a future version.
  • Constructor Details

    • ConsolePrompt

      @Deprecated(since="4.0.0", forRemoval=true) public ConsolePrompt(org.jline.terminal.Terminal terminal)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Use
      invalid reference
      org.jline.prompt.PrompterFactory#create(org.jline.terminal.Terminal)
      instead.
      Parameters:
      terminal - the terminal.
    • ConsolePrompt

      @Deprecated(since="4.0.0", forRemoval=true) public ConsolePrompt(org.jline.terminal.Terminal terminal, ConsolePrompt.UiConfig config)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Use
      invalid reference
      org.jline.prompt.PrompterFactory#create(org.jline.terminal.Terminal, org.jline.prompt.PrompterConfig)
      instead.
      Parameters:
      terminal - the terminal.
      config - ConsolePrompt cursor pointer and checkbox configuration
    • ConsolePrompt

      @Deprecated(since="4.0.0", forRemoval=true) public ConsolePrompt(org.jline.reader.LineReader reader, org.jline.terminal.Terminal terminal, ConsolePrompt.UiConfig config)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Use
      invalid reference
      org.jline.prompt.PrompterFactory#create(org.jline.reader.LineReader, org.jline.terminal.Terminal, org.jline.prompt.PrompterConfig)
      instead.
      Parameters:
      reader - the lineReader.
      terminal - the terminal.
      config - ConsolePrompt cursor pointer and checkbox configuration
  • Method Details

    • open

      protected void open()
      Deprecated, for removal: This API element is subject to removal in a future version.
    • close

      protected void close()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Exits raw mode and restores the terminal to its previous state.

      If the terminal is currently in raw mode, this updates the displayed header, restores the saved terminal attributes, disables keypad local mode, emits a newline to the terminal, and clears the saved raw-mode attributes.

    • prompt

      @Deprecated(since="4.0.0", forRemoval=true) public Map<String,PromptResultItemIF> prompt(List<PromptableElementIF> promptableElementList) throws IOException, org.jline.reader.UserInterruptException
      Deprecated, for removal: This API element is subject to removal in a future version.
      Use
      invalid reference
      org.jline.prompt.Prompter#prompt(java.util.List, java.util.List)
      instead.
      Prompt a list of choices (questions). This method takes a list of promptable elements, typically created with PromptBuilder. Each of the elements is processed and the user entries and answers are filled in to the result map. The result map contains the key of each promptable element and the user entry as an object implementing PromptResultItemIF.
      Parameters:
      promptableElementList - the list of questions / prompts to ask the user for.
      Returns:
      a map containing a result for each element of promptableElementList
      Throws:
      IOException - may be thrown by terminal
      org.jline.reader.UserInterruptException - if user interrupt handling is enabled and the user types the interrupt character (ctrl-C)
    • prompt

      @Deprecated(since="4.0.0", forRemoval=true) public Map<String,PromptResultItemIF> prompt(List<org.jline.utils.AttributedString> header, List<PromptableElementIF> promptableElementList) throws IOException, org.jline.reader.UserInterruptException
      Deprecated, for removal: This API element is subject to removal in a future version.
      Use
      invalid reference
      org.jline.prompt.Prompter#prompt(java.util.List, java.util.List)
      instead.
      Prompt a list of choices (questions). This method takes a list of promptable elements, typically created with PromptBuilder. Each of the elements is processed and the user entries and answers are filled in to the result map. The result map contains the key of each promptable element and the user entry as an object implementing PromptResultItemIF.
      Parameters:
      header - info to be displayed before first prompt.
      promptableElementList - the list of questions / prompts to ask the user for.
      Returns:
      a map containing a result for each element of promptableElementList
      Throws:
      IOException - may be thrown by terminal
      org.jline.reader.UserInterruptException - if user interrupt handling is enabled and the user types the interrupt character (ctrl-C)
    • prompt

      Deprecated, for removal: This API element is subject to removal in a future version.
      Use
      invalid reference
      org.jline.prompt.Prompter#prompt(java.util.List, java.util.function.Function)
      instead.
      Prompt a list of choices (questions). This method takes a function that given a map of interim results returns a list of promptable elements (typically created with PromptBuilder). Each list is then passed to prompt(List, List, Map) and the result added to the map of interim results. The function is then called again with the updated map of results until the function returns null. The final result map contains the key of each promptable element and the user entry as an object implementing PromptResultItemIF.
      Parameters:
      promptableElementLists - a function returning lists of questions / prompts to ask the user for.
      Throws:
      IOException - may be thrown by terminal
    • prompt

      @Deprecated(since="4.0.0", forRemoval=true) public Map<String,PromptResultItemIF> prompt(List<org.jline.utils.AttributedString> headerIn, Function<Map<String,PromptResultItemIF>,List<PromptableElementIF>> promptableElementLists) throws IOException
      Deprecated, for removal: This API element is subject to removal in a future version.
      Use
      invalid reference
      org.jline.prompt.Prompter#prompt(java.util.List, java.util.function.Function)
      instead.
      Prompt a list of choices (questions). This method takes a function that given a map of interim results returns a list of promptable elements (typically created with PromptBuilder). Each list is then passed to prompt(List, List, Map) and the result added to the map of interim results. The function is then called again with the updated map of results until the function returns null. The final result map contains the key of each promptable element and the user entry as an object implementing PromptResultItemIF.
      Parameters:
      headerIn - info to be displayed before first prompt.
      promptableElementLists - a function returning lists of questions / prompts to ask the user for.
      Throws:
      IOException - may be thrown by terminal
    • prompt

      protected void prompt(List<org.jline.utils.AttributedString> headerIn, List<PromptableElementIF> promptableElementList, Map<String,PromptResultItemIF> resultMap) throws IOException
      Deprecated, for removal: This API element is subject to removal in a future version.
      Prompt a list of choices (questions). This method takes a list of promptable elements, typically created with PromptBuilder. Each of the elements is processed and the user entries and answers are filled in to the result map. The result map contains the key of each promptable element and the user entry as an object implementing PromptResultItemIF.
      Parameters:
      headerIn - info to be displayed before first prompt.
      promptableElementList - the list of questions / prompts to ask the user for.
      resultMap - a map containing a result for each element of promptableElementList
      Throws:
      IOException - may be thrown by terminal
    • promptElement

      protected PromptResultItemIF promptElement(List<org.jline.utils.AttributedString> header, PromptableElementIF pe, PromptResultItemIF oldResult)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • createMessage

      protected org.jline.utils.AttributedStringBuilder createMessage(String message, String response)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • computePageSize

      @Deprecated(since="4.0.0", forRemoval=true) public static int computePageSize(org.jline.terminal.Terminal terminal, int pageSize, PageSizeType sizeType)
      Deprecated, for removal: This API element is subject to removal in a future version.
      This method is deprecated along with the ConsolePrompt class. Use the new jline-prompt module instead.
      Compute the number of terminal rows to use for paginated prompts.
      Parameters:
      terminal - the terminal from which to read the current row count
      pageSize - when sizeType is ABSOLUTE, the requested number of rows; when treated as a percentage, the requested percent (0-100)
      sizeType - determines whether pageSize is an absolute row count or a percentage of terminal rows
      Returns:
      the computed page size in rows; for ABSOLUTE, the smaller of the terminal's row count and pageSize; otherwise pageSize percent of the terminal's rows
    • getPromptBuilder

      @Deprecated(since="4.0.0", forRemoval=true) public PromptBuilder getPromptBuilder()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Use
      invalid reference
      org.jline.prompt.Prompter#newBuilder()
      instead.
      Creates a PromptBuilder.
      Returns:
      a new prompt builder object.