Class ConsolePrompt


  • @Deprecated(since="4.0.0",
                forRemoval=true)
    public class ConsolePrompt
    extends java.lang.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 org.jline.prompt.PrompterFactory#create(org.jline.terminal.Terminal) to create a 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  ConsolePrompt.UiConfig
      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 attributes
      Deprecated, for removal: This API element is subject to removal in a future version.
       
      protected ConsolePrompt.UiConfig config
      Deprecated, for removal: This API element is subject to removal in a future version.
       
      protected org.jline.utils.Display display
      Deprecated, for removal: This API element is subject to removal in a future version.
       
      protected java.util.List<org.jline.utils.AttributedString> header
      Deprecated, for removal: This API element is subject to removal in a future version.
       
      protected org.jline.reader.LineReader reader
      Deprecated, for removal: This API element is subject to removal in a future version.
       
      protected org.jline.terminal.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 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 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 org.jline.prompt.PrompterFactory#create(org.jline.terminal.Terminal, org.jline.prompt.PrompterConfig) instead.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      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.
      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​(java.lang.String message, java.lang.String response)
      Deprecated, for removal: This API element is subject to removal in a future version.
       
      PromptBuilder getPromptBuilder()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Use org.jline.prompt.Prompter#newBuilder() instead.
      protected void open()
      Deprecated, for removal: This API element is subject to removal in a future version.
       
      java.util.Map<java.lang.String,​PromptResultItemIF> prompt​(java.util.function.Function<java.util.Map<java.lang.String,​PromptResultItemIF>,​java.util.List<PromptableElementIF>> promptableElementLists)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Use org.jline.prompt.Prompter#prompt(java.util.List, java.util.function.Function) instead.
      java.util.Map<java.lang.String,​PromptResultItemIF> prompt​(java.util.List<PromptableElementIF> promptableElementList)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Use org.jline.prompt.Prompter#prompt(java.util.List, java.util.List) instead.
      java.util.Map<java.lang.String,​PromptResultItemIF> prompt​(java.util.List<org.jline.utils.AttributedString> headerIn, java.util.function.Function<java.util.Map<java.lang.String,​PromptResultItemIF>,​java.util.List<PromptableElementIF>> promptableElementLists)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Use org.jline.prompt.Prompter#prompt(java.util.List, java.util.function.Function) instead.
      java.util.Map<java.lang.String,​PromptResultItemIF> prompt​(java.util.List<org.jline.utils.AttributedString> header, java.util.List<PromptableElementIF> promptableElementList)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Use org.jline.prompt.Prompter#prompt(java.util.List, java.util.List) instead.
      protected void prompt​(java.util.List<org.jline.utils.AttributedString> headerIn, java.util.List<PromptableElementIF> promptableElementList, java.util.Map<java.lang.String,​PromptResultItemIF> resultMap)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Prompt a list of choices (questions).
      protected PromptResultItemIF promptElement​(java.util.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 Detail

      • 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.
      • header

        protected java.util.List<org.jline.utils.AttributedString> header
        Deprecated, for removal: This API element is subject to removal in a future version.
    • Constructor Detail

      • 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 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 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 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 Detail

      • 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 java.util.Map<java.lang.String,​PromptResultItemIF> prompt​(java.util.List<PromptableElementIF> promptableElementList)
                                                                        throws java.io.IOException,
                                                                               org.jline.reader.UserInterruptException
        Deprecated, for removal: This API element is subject to removal in a future version.
        Use 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:
        java.io.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 java.util.Map<java.lang.String,​PromptResultItemIF> prompt​(java.util.List<org.jline.utils.AttributedString> header,
                                                                               java.util.List<PromptableElementIF> promptableElementList)
                                                                        throws java.io.IOException,
                                                                               org.jline.reader.UserInterruptException
        Deprecated, for removal: This API element is subject to removal in a future version.
        Use 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:
        java.io.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 java.util.Map<java.lang.String,​PromptResultItemIF> prompt​(java.util.function.Function<java.util.Map<java.lang.String,​PromptResultItemIF>,​java.util.List<PromptableElementIF>> promptableElementLists)
                                                                        throws java.io.IOException
        Deprecated, for removal: This API element is subject to removal in a future version.
        Use 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:
        java.io.IOException - may be thrown by terminal
      • prompt

        @Deprecated(since="4.0.0",
                    forRemoval=true)
        public java.util.Map<java.lang.String,​PromptResultItemIF> prompt​(java.util.List<org.jline.utils.AttributedString> headerIn,
                                                                               java.util.function.Function<java.util.Map<java.lang.String,​PromptResultItemIF>,​java.util.List<PromptableElementIF>> promptableElementLists)
                                                                        throws java.io.IOException
        Deprecated, for removal: This API element is subject to removal in a future version.
        Use 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:
        java.io.IOException - may be thrown by terminal
      • prompt

        protected void prompt​(java.util.List<org.jline.utils.AttributedString> headerIn,
                              java.util.List<PromptableElementIF> promptableElementList,
                              java.util.Map<java.lang.String,​PromptResultItemIF> resultMap)
                       throws java.io.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:
        java.io.IOException - may be thrown by terminal
      • createMessage

        protected org.jline.utils.AttributedStringBuilder createMessage​(java.lang.String message,
                                                                        java.lang.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 org.jline.prompt.Prompter#newBuilder() instead.
        Creates a PromptBuilder.
        Returns:
        a new prompt builder object.