1
1
package com.osfans.trime.core
2
2
3
+ import timber.log.Timber
4
+
3
5
data class SchemaListItem (
4
6
val schemaId : String? ,
5
7
val name : String? ,
@@ -9,3 +11,119 @@ data class CandidateListItem(
9
11
val comment : String ,
10
12
val text : String ,
11
13
)
14
+
15
+ /* * Rime編碼區 */
16
+ data class RimeComposition (
17
+ val length : Int = 0 ,
18
+ val cursorPos : Int = 0 ,
19
+ val selStart : Int = 0 ,
20
+ val selEnd : Int = 0 ,
21
+ val preedit : String? = " " ,
22
+ ) {
23
+ val selStartPos: Int
24
+ get() {
25
+ if (length == 0 ) return 0
26
+ return preedit?.let { String (it.toByteArray(), 0 , selStart).length } ? : 0
27
+ }
28
+
29
+ val selEndPos: Int
30
+ get() {
31
+ if (length == 0 ) return 0
32
+ return preedit?.let { String (it.toByteArray(), 0 , selEnd).length } ? : 0
33
+ }
34
+ }
35
+
36
+ /* * Rime候選區,包含多個[候選項][CandidateListItem] */
37
+ data class RimeMenu (
38
+ val pageSize : Int = 0 ,
39
+ val pageNo : Int = 0 ,
40
+ val isLastPage : Boolean = false ,
41
+ val highlightedCandidateIndex : Int = 0 ,
42
+ val numCandidates : Int = 0 ,
43
+ val candidates : Array <CandidateListItem > = arrayOf(),
44
+ ) {
45
+ // generated by Android Studio
46
+ override fun equals (other : Any? ): Boolean {
47
+ if (this == = other) return true
48
+ if (javaClass != other?.javaClass) return false
49
+
50
+ other as RimeMenu
51
+
52
+ if (pageSize != other.pageSize) return false
53
+ if (pageNo != other.pageNo) return false
54
+ if (isLastPage != other.isLastPage) return false
55
+ if (highlightedCandidateIndex != other.highlightedCandidateIndex) return false
56
+ if (numCandidates != other.numCandidates) return false
57
+ if (! candidates.contentEquals(other.candidates)) return false
58
+
59
+ return true
60
+ }
61
+
62
+ // generated by Android Studio
63
+ override fun hashCode (): Int {
64
+ var result = pageSize
65
+ result = 31 * result + pageNo
66
+ result = 31 * result + isLastPage.hashCode()
67
+ result = 31 * result + highlightedCandidateIndex
68
+ result = 31 * result + numCandidates
69
+ result = 31 * result + candidates.contentHashCode()
70
+ return result
71
+ }
72
+ }
73
+
74
+ /* * Rime上屏的字符串 */
75
+ data class RimeCommit (
76
+ val commitText : String = " " ,
77
+ )
78
+
79
+ /* * Rime環境,包括 [編碼區][RimeComposition] 、[候選區][RimeMenu] */
80
+ data class RimeContext (
81
+ val composition : RimeComposition ? = null ,
82
+ val menu : RimeMenu ? = null ,
83
+ val commitTextPreview : String? = " " ,
84
+ val selectLabels : Array <String > = arrayOf(),
85
+ ) {
86
+ val candidates: Array <CandidateListItem >
87
+ get() {
88
+ val numCandidates = menu?.numCandidates ? : 0
89
+ Timber .d(" RimeContext: getCandidate: numCandidates=$numCandidates " )
90
+ return if (numCandidates != 0 ) menu!! .candidates else arrayOf()
91
+ }
92
+
93
+ // generated by Android Studio
94
+ override fun equals (other : Any? ): Boolean {
95
+ if (this == = other) return true
96
+ if (javaClass != other?.javaClass) return false
97
+
98
+ other as RimeContext
99
+
100
+ if (composition != other.composition) return false
101
+ if (menu != other.menu) return false
102
+ if (commitTextPreview != other.commitTextPreview) return false
103
+ if (! selectLabels.contentEquals(other.selectLabels)) return false
104
+
105
+ return true
106
+ }
107
+
108
+ // generated by Android Studio
109
+ override fun hashCode (): Int {
110
+ var result = composition?.hashCode() ? : 0
111
+ result = 31 * result + (menu?.hashCode() ? : 0 )
112
+ result = 31 * result + commitTextPreview.hashCode()
113
+ result = 31 * result + selectLabels.contentHashCode()
114
+ return result
115
+ }
116
+ }
117
+
118
+ /* * Rime狀態 */
119
+ data class RimeStatus (
120
+ val schemaId : String = " " ,
121
+ val schemaName : String = " " ,
122
+ val isDisable : Boolean = true ,
123
+ val isComposing : Boolean = false ,
124
+ val isAsciiMode : Boolean = true ,
125
+ val isFullShape : Boolean = false ,
126
+ val isSimplified : Boolean = false ,
127
+ val isTraditional : Boolean = false ,
128
+ val isAsciiPunch : Boolean = true ,
129
+ )
0 commit comments