Class InBandResize


  • public final class InBandResize
    extends java.lang.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 Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String RESIZE_SEQ
      The CSI prefix that starts an in-band resize report.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void applyResizeParams​(java.lang.String params, Terminal terminal)
      Parses rows;cols[;pixelHeight;pixelWidth] and applies the new terminal size, raising Terminal.Signal.WINCH.
      static void handleResize​(BindingReader reader, Terminal terminal)
      Convenience method that reads and applies an in-band resize report in a single call.
      static java.lang.String readResizeParams​(BindingReader reader)
      Reads resize parameters from the input until the final t byte.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • RESIZE_SEQ

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

      • readResizeParams

        public static java.lang.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​(java.lang.String params,
                                             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(org.jline.keymap.BindingReader)
        terminal - the terminal whose size should be updated
      • handleResize

        public static void handleResize​(BindingReader reader,
                                        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