KetraTerm
API · DevelopmentAll versions

readCluster

open fun readCluster(col: Int, dest: IntArray): Int

Copies all codepoints of the grapheme cluster at col into dest and returns the number of codepoints written.

The copy itself does not allocate. The caller owns capacity and may reuse dest while it remains large enough. Use getClusterLength to discover required capacity before copying, under the same uninterrupted serialization; core-owned lines retain at most 32 codepoints per cluster. Alternatively, use io.github.ketraterm.render.api.TerminalRenderFrame.copyLine with a io.github.ketraterm.render.api.TerminalRenderClusterDataSink. Its callback supplies the full length and a borrowed primitive range to copy before returning. Keep the owning terminal serialized for either read path. An insufficient destination is rejected by core-owned lines before any elements are changed.

Returns 0 for non-cluster cells; callers should check isCluster first or treat a return value of 0 as "use getCodepoint instead".

Return

Number of codepoints written, or 0 if the cell is not a cluster.

Parameters

col

Column index (0-based).

dest

Destination array. Must have capacity >= actual cluster length; core-owned lines are bounded by io.github.ketraterm.protocol.TerminalTextLimits.MAX_CLUSTER_CODEPOINTS.

Throws

when a core-owned cluster exceeds dest's capacity.