Class Widgets

java.lang.Object
com.guinetik.hexafun.examples.tui.Widgets

public final class Widgets extends Object
Reusable TUI widget builders.

All methods return Strings (pure functions), keeping side effects at the edges. Compose these with View for full screens.

Example:


 String header = Widgets.header("My App", 80, CYAN);
 String progress = Widgets.progressBar(75, 60, GREEN);
 String box = Widgets.box("Content here", 40, YELLOW);
 
  • Method Details

    • header

      public static String header(String title, String subtitle, int width, String borderColor)
      Render a boxed header with title and optional subtitle.
      Parameters:
      title - Main title text
      subtitle - Optional subtitle (can be null)
      width - Total width including borders
      borderColor - ANSI color for the border
      Returns:
      Rendered header string
    • header

      public static String header(String title, int width, String borderColor)
      Simple header without subtitle.
    • section

      public static String section(String label, int width)
      Section divider with label.
      Parameters:
      label - Section label
      width - Total width
      Returns:
      Rendered divider
    • progressBar

      public static String progressBar(int percent, int width, String fillColor)
      Render a progress bar.
      Parameters:
      percent - Completion percentage (0-100)
      width - Bar width in characters
      fillColor - Color for filled portion
      Returns:
      Rendered progress bar
    • segment

      public static String segment(String text, int width, String bgColor, String fgColor)
      Powerline-style segment for stats bars.
      Parameters:
      text - Segment text
      bgColor - Background color
      fgColor - Foreground color
      Returns:
      Rendered segment (without separator)
    • separator

      public static String separator(String fromColor, String toColor)
      Powerline separator arrow.
      Parameters:
      fromColor - Color of previous segment
      toColor - Color of next segment (or null for end)
      Returns:
      Rendered separator
    • box

      public static String box(String content, int width, String borderColor)
      Render content in a single-line box.
      Parameters:
      content - Content to box
      width - Box width
      borderColor - Border color
      Returns:
      Boxed content
    • box

      public static String box(List<String> lines, int width, String borderColor)
      Render multiple lines in a box.
      Parameters:
      lines - Content lines
      width - Box width
      borderColor - Border color
      Returns:
      Boxed content
    • hr

      public static String hr(int width)
      Horizontal rule/divider.
      Parameters:
      width - Total width
      Returns:
      Rendered divider
    • listItem

      public static String listItem(int index, String icon, String iconColor, String text, String textColor)
      Render a numbered list item.
      Parameters:
      index - Item number
      icon - Icon to display
      iconColor - Icon color
      text - Item text
      textColor - Text color
      Returns:
      Rendered list item
    • bulletItem

      public static String bulletItem(String text)
      Render a simple bullet item.
    • selectionItem

      public static String selectionItem(int index, String text)
      Render a numbered selection item (for menus).
    • prompt

      public static String prompt(String symbol, String promptColor)
      Input prompt.
      Parameters:
      symbol - Prompt symbol
      promptColor - Prompt color
      Returns:
      Rendered prompt
    • prompt

      public static String prompt(String promptColor)
      Default prompt with ">".
    • status

      public static String status(String message, String messageColor)
      Status message with arrow indicator.
      Parameters:
      message - Status message
      messageColor - Message color
      Returns:
      Rendered status
    • success

      public static String success(String message)
      Success message.
    • error

      public static String error(String message)
      Error message.
    • warning

      public static String warning(String message)
      Warning message.
    • info

      public static String info(String message)
      Info message.