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 KiteRectangle names its fields PDF-style (y-up), display rectangles here store the y-MIN (the edge nearest the page top) in KiteRectangle.bottom and the y-MAX in KiteRectangle.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
fun caretAt(index: Int, after: Boolean): KiteCaret?

Where a selection that starts at the flattened char index begins, or where one that ends at it ends when after is true: the char's logical edge, as a caret across its line. Lines keep their own direction, so the start of a right-to-left run is its right edge, and a caret in a vertical line runs across the column. Null for an index with no char.

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 copyText(start: Int, endInclusive: Int): String

The text of the inclusive flattened range as a reader copies it. Blocks are separated by \n\n, and the lines of one block join as their KiteTextLine.end says: a paragraph the layout wrapped copies as one line, a word it hyphenated copies whole, and a break the text holds stays \n. Lines that end KiteLineEnd.HARD, as every fixed-layout line does, copy as textRange gives them.

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

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.

fun search(needle: String, ignoreCase: Boolean = true, pageIndex: Int = -1, location: KiteLocation?): List<KiteSearchHit>

search with an explicit page location in the current layout. The caller owns the page coordinate: structured text alone cannot recover its chapter or page. pageIndex keeps its caller-supplied meaning and may be -1 when unknown. Neither the location nor the quads are a content anchor that survives reflow.

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).