Interface PrompterConfig

  • All Known Implementing Classes:
    DefaultPrompterConfig

    public interface PrompterConfig
    Configuration interface for customizing the visual appearance and behavior of prompts.

    The configuration controls various visual elements used in the prompt display, including indicators, checkbox symbols, and interaction behavior. The API provides platform-specific defaults that work well on different operating systems.

    Default Configurations:

    • Windows: ">", "( )", "(x)", "( )"
    • Unix/Linux/macOS: "?", "? ", "? ", "? "

    Example Custom Configuration:

    
     Prompter.Config config = new DefaultPrompter.DefaultConfig(
         "?",     // indicator
         "? ",    // unchecked box
         "? ",    // checked box
         "? "     // unavailable item
     );
    
     Prompter prompter = PrompterFactory.create(terminal, config);
     
    Since:
    3.30.0
    See Also:
    PrompterFactory.create(Terminal, PrompterConfig)
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String AN
      Answer text style
      static java.lang.String BD
      Box disabled style
      static java.lang.String BE
      Box enabled style
      static java.lang.String CB
      Checkbox style
      static java.lang.String CURSOR
      Cursor/selection indicator style
      static java.lang.String ERROR
      Error message style
      static java.lang.String FO
      Footer/description text style (dimmed)
      static java.lang.String ME
      Message text style
      static java.lang.String PR
      Prompt text style
      static java.lang.String SE
      Selected item style
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      boolean cancellableFirstPrompt()
      Whether the first prompt can be cancelled.
      java.lang.String checkedBox()
      Get the checked box character/string.
      static PrompterConfig custom​(java.lang.String indicator, java.lang.String uncheckedBox, java.lang.String checkedBox, java.lang.String unavailable, org.jline.utils.StyleResolver styleResolver, boolean cancellableFirstPrompt)
      Create a custom configuration with style resolver support.
      static PrompterConfig defaults()
      Create a configuration with platform-specific defaults.
      default int footerMaxRows()
      Maximum height, in rows, of the dimmed footer pane shown below list and checkbox prompts.
      java.lang.String indicator()
      Get the indicator character/string.
      default org.jline.utils.AttributedStyle style​(java.lang.String style)  
      default org.jline.utils.StyleResolver styleResolver()
      Get the style resolver for this configuration.
      java.lang.String unavailable()
      Get the unavailable item character/string.
      java.lang.String uncheckedBox()
      Get the unchecked box character/string.
      static PrompterConfig unix()
      Create a configuration with Unix/Linux-specific defaults.
      static PrompterConfig windows()
      Create a configuration with Windows-specific defaults.
      default PrompterConfig withCancellableFirstPrompt​(boolean cancellable)  
    • Method Detail

      • indicator

        java.lang.String indicator()
        Get the indicator character/string.
        Returns:
        the indicator
      • uncheckedBox

        java.lang.String uncheckedBox()
        Get the unchecked box character/string.
        Returns:
        the unchecked box
      • checkedBox

        java.lang.String checkedBox()
        Get the checked box character/string.
        Returns:
        the checked box
      • unavailable

        java.lang.String unavailable()
        Get the unavailable item character/string.
        Returns:
        the unavailable item
      • styleResolver

        default org.jline.utils.StyleResolver styleResolver()
        Get the style resolver for this configuration.
        Returns:
        the style resolver, or null if not available
      • cancellableFirstPrompt

        boolean cancellableFirstPrompt()
        Whether the first prompt can be cancelled.
        Returns:
        true if the first prompt can be cancelled
      • withCancellableFirstPrompt

        default PrompterConfig withCancellableFirstPrompt​(boolean cancellable)
      • defaults

        static PrompterConfig defaults()
        Create a configuration with platform-specific defaults.
        Returns:
        a configuration with platform defaults
      • windows

        static PrompterConfig windows()
        Create a configuration with Windows-specific defaults.
        Returns:
        a configuration with Windows defaults
      • unix

        static PrompterConfig unix()
        Create a configuration with Unix/Linux-specific defaults.
        Returns:
        a configuration with Unix defaults
      • custom

        static PrompterConfig custom​(java.lang.String indicator,
                                     java.lang.String uncheckedBox,
                                     java.lang.String checkedBox,
                                     java.lang.String unavailable,
                                     org.jline.utils.StyleResolver styleResolver,
                                     boolean cancellableFirstPrompt)
        Create a custom configuration with style resolver support.
        Parameters:
        indicator - the indicator character/string
        uncheckedBox - the unchecked box character/string
        checkedBox - the checked box character/string
        unavailable - the unavailable item character/string
        styleResolver - the style resolver for applying styles
        Returns:
        a custom configuration with styling support
      • style

        default org.jline.utils.AttributedStyle style​(java.lang.String style)
      • footerMaxRows

        default int footerMaxRows()
        Maximum height, in rows, of the dimmed footer pane shown below list and checkbox prompts.
        Returns:
        the maximum footer pane height in rows