Scoop API

scoop:scoop.ui:0.1.0

src/accessibility/text.scoop

Selected production source · src/accessibility/text.scoop

1package scoop.ui
3import scoop.ui.text.NativeTextSource
5/** One real text host and its reusable native source, without retaining a second document. */
6internal class SemanticTextHost: Closeable {
7 var binding: SemanticTextBinding? = None
8 var source: NativeTextSource? = None
10 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 = None
19 }
22/** Binding identity prevents a discarded or detached host from republishing its geometry. */
23internal class SemanticTextBinding(
24 val handle: SemanticsHandle,
25 val host: SemanticTextHost
26): Closeable {
27 var path: Array<ScrollReveal>? = None
28 private var closed = false
29 val active: Boolean get() = !closed
31 public override fun close() {
32 if (!active)
33 return
34 closed = true
35 path = None
36 handle.textBinding = None
37 host.binding = None
38 host.source?.close()
39 host.source = None
40 if (handle.active) {
41 handle.resource.textDocument = None
42 @Unsafe
43 {
44 handle.resource.setTextGeometry(None)
45 }
46 handle.controller.changed()
47 }
48 }