Class CursorLocator

java.lang.Object
org.aesh.readline.cursor.CursorLocator

public class CursorLocator extends Object
Map a command character index onto a cursor COL/ROW.
Author:
jdenise@redhat.com
  • Constructor Details

    • CursorLocator

      public CursorLocator(Buffer buffer)
      Creates a new cursor locator for the specified buffer.
      Parameters:
      buffer - the buffer to track cursor positions for
  • Method Details

    • addLine

      public void addLine(int size, int promptSize)
      Adds a line with the specified size and prompt size to the locator.
      Parameters:
      size - the size of the line content
      promptSize - the size of the prompt on this line
    • isLocationInvalidated

      public boolean isLocationInvalidated()
      Checks if the cursor location tracking has been invalidated.
      Returns:
      true if the location is invalidated, false otherwise
    • invalidateCursorLocation

      public void invalidateCursorLocation()
      Marks the cursor location as invalidated. This typically happens when the terminal state changes in a way that makes the stored line information unreliable.
    • locate

      public CursorLocation locate(int index, int width)
      The core logic of the locator. Map a command index onto an absolute COL/ROW cursor location.
      Parameters:
      index - The commnd index.
      width - The terminal width.
      Returns:
      the cursor location corresponding to the index, or null if the location is invalidated or out of bounds
    • clear

      public void clear()
      Clears all stored line information from the locator.