KiteStructuredText

Format-neutral structured text for a KitePage: the minimal blocks → lines → text model a viewer needs for extraction, search highlights and selection, without committing to a handler's internals.

All geometry is in the page's DISPLAY space: the top-left-origin, y-down [0, displayWidth] x [0, displayHeight] box that KitePage.displayToDeviceBase maps onto. Because Rectangle names its fields PDF-style (y-up), display rectangles here store the y-MIN (the edge nearest the page top) in Rectangle.bottom and the y-MAX in Rectangle.top, keeping width/height positive.

Constructors

Link copied to clipboard
constructor(blocks: List<KiteTextBlock>)

Properties

Link copied to clipboard
Link copied to clipboard

Number of positioned chars (charIndexAt's index space).

Link copied to clipboard

Flattened plain text: line breaks become \n, block breaks \n\n.

Functions

Link copied to clipboard

The flattened index of the char at a display-space point, or null when the point is on no text line. Within a line, x clamps to the nearest char, which is what a selection drag wants at the line's ends.

Link copied to clipboard
fun quadsFor(start: Int, endInclusive: Int): List<Rectangle>

Display-space quads (one per line touched) for the inclusive flattened range. Search hits use the same walker.

Link copied to clipboard
fun search(needle: String, ignoreCase: Boolean = true, pageIndex: Int = -1): List<KiteSearchHit>

Find needle in this page's text. Matches may cross line boundaries inside a block: a line break counts as one space, except after a line ending in a hyphen, which joins the halves directly with the hyphen dropped (so a hyphenated "compres-/sion" matches "compression"). Matches never cross block boundaries. Case-insensitive comparison uses per-position regionMatches, so indices stay aligned for any script.

Link copied to clipboard
fun textRange(start: Int, endInclusive: Int): String

The text of the inclusive flattened range start..endInclusive, with line breaks as \n and block breaks as \n\n (matching plainText).