scoop:scoop.ui:0.1.0
src/accessibility/text.scoop
Selected production source · src/accessibility/text.scoop
1
package scoop.ui3
import scoop.ui.text.NativeTextSource5
/** One real text host and its reusable native source, without retaining a second document. */6
internal class SemanticTextHost: Closeable {7
var binding: SemanticTextBinding? = None8
var source: NativeTextSource? = None10
fun replaceSource(value: NativeTextSource) {11
source?.close()12
source = Some(value)13
}15
public override fun close() {16
binding?.close()17
source?.close()18
source = None19
}20
}22
/** Binding identity prevents a discarded or detached host from republishing its geometry. */23
internal class SemanticTextBinding(24
val handle: SemanticsHandle,25
val host: SemanticTextHost26
): Closeable {27
var path: Array<ScrollReveal>? = None28
private var closed = false29
val active: Boolean get() = !closed31
public override fun close() {32
if (!active)33
return34
closed = true35
path = None36
handle.textBinding = None37
host.binding = None38
host.source?.close()39
host.source = None40
if (handle.active) {41
handle.resource.textDocument = None42
@Unsafe43
{44
handle.resource.setTextGeometry(None)45
}46
handle.controller.changed()47
}48
}49
}