Interface Editor

  • All Known Implementing Classes:
    Nano

    public interface Editor
    Interface for launching external editors from within a JLine application.

    The Editor interface provides functionality for opening and editing files in an external text editor. This allows JLine applications to offer users the ability to edit content in their preferred editor rather than being limited to the line editing capabilities of the terminal.

    Typical use cases include:

    • Editing configuration files
    • Writing or modifying scripts
    • Composing long text content

    Implementations of this interface handle the details of launching the external editor process, waiting for it to complete, and potentially reading back the edited content.

    See Also:
    LineReader.editAndAddInBuffer(java.nio.file.Path)
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void open​(java.util.List<java.lang.String> files)
      Opens the specified files in the external editor.
      void run()
      Runs the editor process.
      void setRestricted​(boolean restricted)
      Sets whether the editor should run in restricted mode.
    • Method Detail

      • open

        void open​(java.util.List<java.lang.String> files)
           throws java.io.IOException
        Opens the specified files in the external editor.

        This method launches the external editor with the given files as arguments. The behavior depends on the specific editor implementation and configuration.

        Parameters:
        files - the list of files to open in the editor
        Throws:
        java.io.IOException - if an I/O error occurs while launching the editor
      • run

        void run()
          throws java.io.IOException
        Runs the editor process.

        This method starts the editor process and typically waits for it to complete. The specific behavior depends on the editor implementation.

        Throws:
        java.io.IOException - if an I/O error occurs while running the editor
      • setRestricted

        void setRestricted​(boolean restricted)
        Sets whether the editor should run in restricted mode.

        In restricted mode, the editor may have limited functionality or access to certain features or files. This is typically used for security reasons when the application needs to limit what the user can do in the editor.

        Parameters:
        restricted - true to enable restricted mode, false otherwise