Class Less

java.lang.Object
org.jline.builtins.Less

public class Less extends Object
A terminal pager similar to the 'less' Unix command.

This class provides a file viewer with features including:

  • Forward and backward navigation
  • Search functionality
  • Syntax highlighting
  • Line numbering
  • Status display
  • Multiple file support

The implementation supports many of the key bindings and features of the traditional Unix 'less' command, adapted for JLine's terminal handling.

  • Field Details

    • quitAtSecondEof

      public boolean quitAtSecondEof
    • quitAtFirstEof

      public boolean quitAtFirstEof
    • quitIfOneScreen

      public boolean quitIfOneScreen
    • printLineNumbers

      public boolean printLineNumbers
    • quiet

      public boolean quiet
    • veryQuiet

      public boolean veryQuiet
    • chopLongLines

      public boolean chopLongLines
    • ignoreCaseCond

      public boolean ignoreCaseCond
    • ignoreCaseAlways

      public boolean ignoreCaseAlways
    • noKeypad

      public boolean noKeypad
    • noInit

      public boolean noInit
    • tabs

      protected List<Integer> tabs
    • syntaxName

      protected String syntaxName
    • defaultPrompt

      protected String defaultPrompt
    • helpSource

      protected Source helpSource
    • terminal

      protected final Terminal terminal
    • display

      protected final Display display
    • bindingReader

      protected final BindingReader bindingReader
    • currentDir

      protected final Path currentDir
    • sources

      protected List<Source> sources
    • sourceIdx

      protected int sourceIdx
    • reader

      protected BufferedReader reader
    • keys

      protected KeyMap<Less.Operation> keys
    • firstLineInMemory

      protected int firstLineInMemory
    • lines

      protected List<AttributedString> lines
    • firstLineToDisplay

      protected int firstLineToDisplay
    • firstColumnToDisplay

      protected int firstColumnToDisplay
    • offsetInLine

      protected int offsetInLine
    • message

      protected String message
    • errorMessage

      protected String errorMessage
    • buffer

      protected final StringBuilder buffer
    • options

      protected final Map<String, Less.Operation> options
    • window

      protected int window
    • halfWindow

      protected int halfWindow
    • nbEof

      protected int nbEof
    • patternHistory

      protected Nano.PatternHistory patternHistory
    • pattern

      protected String pattern
    • displayPattern

      protected String displayPattern
    • size

      protected volatile Size size
  • Constructor Details

  • Method Details

    • usage

      public static String[] usage()
    • tabs

      public Less tabs(List<Integer> tabs)
    • defaultPrompt

      public Less defaultPrompt(String prompt)
      Sets a custom default prompt string displayed at the bottom of the screen when no message is active. If not set, the default ":" is shown. The prompt is rendered with inverse video style.
      Parameters:
      prompt - the prompt string to display
      Returns:
      this Less instance for chaining
    • helpSource

      public Less helpSource(Source helpSource)
      Sets a custom help source displayed when the user presses h or H. If not set, the built-in less-help.txt resource is shown. This is useful for applications that embed Less and want to provide context-specific help text instead of the default help, which references command-line options and uses the term "LESS".
      Parameters:
      helpSource - a Source providing the custom help content
      Returns:
      this Less instance for chaining
    • handle

      public void handle(Terminal.Signal signal)
    • run

      public void run(Source... sources) throws IOException, InterruptedException
      Throws:
      IOException
      InterruptedException
    • run

      public void run(List<Source> sources) throws IOException, InterruptedException
      Throws:
      IOException
      InterruptedException
    • openSource

      protected void openSource() throws IOException
      Throws:
      IOException
    • checkInterrupted

      public static void checkInterrupted() throws InterruptedException
      This is for long running commands to be interrupted by ctrl-c
      Throws:
      InterruptedException - if the thread has been interruped