Scoop API

scoop:scoop.window:0.1.0

src/input/text_snapshot.scoop

Selected production source · src/input/text_snapshot.scoop

1package scoop.window
3/** Publishes applied text independently of drawing or candidate geometry. */
4public fun Window.publishTextInputState(
5 connection: TextInputConnection,
6 state: TextInputState,
7 after: TextInputOrigin? = None
8): Boolean {
9 checkTextConnection(connection)
10 state.validate()
11 val sequence =
12 when (after) {
13 case Some(val origin) -> {
14 requireWindow(
15 origin.connection == connection && origin.sequence > 0L,
16 "text batch belongs to another connection"
17 )
18 origin.sequence
19 }
20 case None -> 0L
21 }
22 return snapshotResult(platformPublishText(this, connection, state, sequence))
25/** Publishes geometry only for the current, fully applied document revision. */
26public fun Window.publishTextInputCaret(
27 connection: TextInputConnection,
28 revision: Long,
29 area: LogicalRect?
30): Boolean {
31 checkTextConnection(connection)
32 requireWindow(revision >= 0L, "negative text revision")
33 when (area) {
34 case Some(val value) -> checkImeCursorArea(value)
35 case None -> {}
36 }
37 return snapshotResult(platformPublishTextCaret(this, connection, revision, area))
40/** Makes the basic candidate rectangle unavailable until supplied again. */
41public fun Window.clearImeCursorArea() {
42 owner.requireOpen()
43 checkNativeStatus(platformClearImeCaret(this), "clear IME caret")
46internal fun Window.checkTextConnection(connection: TextInputConnection) {
47 owner.requireOpen()
48 requireWindow(
49 connection.window == id && connection.generation > 0L,
50 "text connection belongs to another window"
51 )
54private fun snapshotResult(code: Long): Boolean {
55 if (code == 1L)
56 return false
57 requireWindow(code != 2L, "invalid text snapshot revision or native batch sequence")
58 checkNativeStatus(code, "publish text input snapshot")
59 return true