Interface Widget

  • All Superinterfaces:
    Binding
    All Known Implementing Classes:
    ConsoleEngine.WidgetCreator
    Functional Interface:
    This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

    @FunctionalInterface
    public interface Widget
    extends Binding
    A Widget represents an action that can be bound to a key sequence in the LineReader.

    Widgets are the fundamental building blocks of the line editor's functionality. Each widget implements a specific editing action or command that can be invoked by the user through key bindings. Examples include moving the cursor, deleting characters, searching history, and completing words.

    Widgets can be bound to key sequences using the LineReader's key maps. When the user presses a key sequence that is bound to a widget, the widget's apply() method is called to perform the associated action.

    JLine provides a set of built-in widgets that implement common editing functions, and applications can define custom widgets to extend the editor's functionality.

    This interface is designed as a functional interface, making it easy to implement widgets using lambda expressions.

    See Also:
    LineReader.getWidgets(), LineReader.getBuiltinWidgets(), LineReader.callWidget(String), Binding
    • Method Detail

      • apply

        boolean apply()
        Executes the action associated with this widget.

        This method is called when the key sequence bound to this widget is pressed. It should perform the widget's specific editing action or command.

        Returns:
        true if the widget was successfully applied, false otherwise