@@ -28,6 +28,7 @@ final class SquirrelInputController: IMKInputController {
28
28
private var chordDuration : TimeInterval = 0
29
29
private var currentApp : String = " "
30
30
31
+ // swiftlint:disable:next cyclomatic_complexity
31
32
override func handle( _ event: NSEvent ! , client sender: Any ! ) -> Bool {
32
33
let modifiers = event. modifierFlags
33
34
let changes = lastModifiers. symmetricDifference ( modifiers)
@@ -128,6 +129,7 @@ final class SquirrelInputController: IMKInputController {
128
129
return success
129
130
}
130
131
132
+ // swiftlint:disable:next identifier_name
131
133
func page( up: Bool ) -> Bool {
132
134
var handled = false
133
135
handled = rimeAPI. change_page ( session, up)
@@ -282,7 +284,8 @@ private extension SquirrelInputController {
282
284
if chordKeyCount > 0 && session != 0 {
283
285
// simulate key-ups
284
286
for i in 0 ..< chordKeyCount {
285
- if rimeAPI. process_key ( session, Int32 ( chordKeyCodes [ i] ) , Int32 ( chordModifiers [ i] | kReleaseMask. rawValue) ) {
287
+ let handled = rimeAPI. process_key ( session, Int32 ( chordKeyCodes [ i] ) , Int32 ( chordModifiers [ i] | kReleaseMask. rawValue) )
288
+ if handled {
286
289
processedKeys = true
287
290
}
288
291
}
@@ -413,13 +416,15 @@ private extension SquirrelInputController {
413
416
}
414
417
}
415
418
419
+ // swiftlint:disable:next cyclomatic_complexity
416
420
func rimeUpdate( ) {
417
421
// print("[DEBUG] rimeUpdate")
418
422
rimeConsumeCommittedText ( )
419
423
420
424
var status = RimeStatus_stdbool . rimeStructInit ( )
421
425
if rimeAPI. get_status ( session, & status) {
422
426
// enable schema specific ui style
427
+ // swiftlint:disable:next identifier_name
423
428
if let schema_id = status. schema_id, schemaId == " " || schemaId != String ( cString: schema_id) {
424
429
schemaId = String ( cString: schema_id)
425
430
NSApp . squirrelAppDelegate. loadSettings ( for: schemaId)
@@ -484,15 +489,20 @@ private extension SquirrelInputController {
484
489
comments. append ( candidate. comment. map { String ( cString: $0) } ?? " " )
485
490
}
486
491
var labels = [ String] ( )
492
+ // swiftlint:disable identifier_name
487
493
if let select_keys = ctx. menu. select_keys {
488
- labels = Array ( arrayLiteral : String ( cString: select_keys) )
494
+ labels = String ( cString: select_keys) . map { String ( $0 ) }
489
495
} else if let select_labels = ctx. select_labels {
490
496
let pageSize = Int ( ctx. menu. page_size)
491
497
for i in 0 ..< pageSize {
492
498
labels. append ( select_labels [ i] . map { String ( cString: $0) } ?? " " )
493
499
}
494
500
}
495
- showPanel ( preedit: inlinePreedit ? " " : preedit, selRange: NSRange ( location: start. utf16Offset ( in: preedit) , length: preedit. utf16. distance ( from: start, to: end) ) , caretPos: caretPos. utf16Offset ( in: preedit) , candidates: candidates, comments: comments, labels: labels, highlighted: Int ( ctx. menu. highlighted_candidate_index) )
501
+ // swiftlint:enable identifier_name
502
+
503
+ let selRange = NSRange ( location: start. utf16Offset ( in: preedit) , length: preedit. utf16. distance ( from: start, to: end) )
504
+ showPanel ( preedit: inlinePreedit ? " " : preedit, selRange: selRange, caretPos: caretPos. utf16Offset ( in: preedit) ,
505
+ candidates: candidates, comments: comments, labels: labels, highlighted: Int ( ctx. menu. highlighted_candidate_index) )
496
506
_ = rimeAPI. free_context ( & ctx)
497
507
} else {
498
508
hidePalettes ( )
@@ -531,6 +541,7 @@ private extension SquirrelInputController {
531
541
client. setMarkedText ( attrString, selectionRange: NSRange ( location: caretPos, length: 0 ) , replacementRange: NSRange ( location: NSNotFound, length: 0 ) )
532
542
}
533
543
544
+ // swiftlint:disable:next function_parameter_count
534
545
func showPanel( preedit: String , selRange: NSRange , caretPos: Int , candidates: [ String ] , comments: [ String ] , labels: [ String ] , highlighted: Int ) {
535
546
// print("[DEBUG] showPanelWithPreedit:...:")
536
547
guard let client = client else { return }
0 commit comments