Class InBandResize

java.lang.Object
org.jline.keymap.InBandResize

public final class InBandResize extends Object
Shared utility for handling DEC private mode 2048 (in-band window resize notifications).

When mode 2048 is active, the terminal sends CSI 48 ; rows ; cols ; pixelHeight ; pixelWidth t whenever the window is resized. The KeyMap binding consumes the CSI 48 ; prefix (RESIZE_SEQ); the methods in this class handle the remainder of the sequence.

This was originally implemented inside org.jline.reader.impl.LineReaderImpl but is extracted here so that full-screen builtins (Nano, Less, Tmux) ? which bypass LineReader and read input directly via BindingReader ? can also handle in-band resize reports.

See Also:
  • Terminal.trackInBandResize(boolean)
  • Field Details

    • RESIZE_SEQ

      public static final String RESIZE_SEQ
      The CSI prefix that starts an in-band resize report. Bind this in a KeyMap to trigger resize handling.
      See Also:
  • Method Details

    • readResizeParams

      public static String readResizeParams(BindingReader reader)
      Reads resize parameters from the input until the final t byte.

      The KeyMap match has already consumed the RESIZE_SEQ prefix. This method reads the remaining characters ? digits and semicolons forming rows;cols[;pixelHeight;pixelWidth] ? up to the terminating t.

      Parameters:
      reader - the binding reader to read characters from
      Returns:
      the parameter string (e.g. "24;80"), or null if the sequence is malformed or too long
    • applyResizeParams

      public static void applyResizeParams(String params, org.jline.terminal.Terminal terminal)
      Parses rows;cols[;pixelHeight;pixelWidth] and applies the new terminal size, raising Terminal.Signal.WINCH.

      The pixel dimensions (if present) are currently ignored ? only the character-cell dimensions are applied. Rows and columns that exceed the built-in safety bounds (1000 rows, 5000 columns) are silently rejected to prevent unsafe redraw allocations.

      Parameters:
      params - the parameter string returned by readResizeParams(BindingReader)
      terminal - the terminal whose size should be updated
    • handleResize

      public static void handleResize(BindingReader reader, org.jline.terminal.Terminal terminal)
      Convenience method that reads and applies an in-band resize report in a single call.
      Parameters:
      reader - the binding reader to read characters from
      terminal - the terminal whose size should be updated