(session_id, keycode, mask)
| 436 | return menu |
| 437 | |
| 438 | def processKey(session_id, keycode, mask): |
| 439 | print("process_key", keycode, "ret", rime.process_key(session_id, keycode, mask)) |
| 440 | status = RimeStatus() |
| 441 | if rime.get_status(session_id, status): |
| 442 | print("is_composing", status.is_composing) |
| 443 | print("is_ascii_mode", status.is_ascii_mode) |
| 444 | print("current_schema", status.schema_name.decode("UTF-8")) |
| 445 | rime.free_status(status) |
| 446 | |
| 447 | commit = RimeCommit() |
| 448 | if rime.get_commit(session_id, commit): |
| 449 | print("commit",commit.text.decode("UTF-8")) |
| 450 | rime.free_commit(commit) |
| 451 | |
| 452 | context = RimeContext() |
| 453 | if not rime.get_context(session_id, context) or context.composition.length == 0: |
| 454 | rime.free_context(context) |
| 455 | exit |
| 456 | |
| 457 | if context.commit_text_preview: |
| 458 | commit_text_preview = context.commit_text_preview.decode("UTF-8") |
| 459 | print("commit_text_preview",commit_text_preview) |
| 460 | |
| 461 | if context.composition.length: |
| 462 | print("preedit", context.composition.preedit.decode("UTF-8"), |
| 463 | "cursor_pos", context.composition.cursor_pos, |
| 464 | "sel_start", context.composition.sel_start, |
| 465 | "sel_end", context.composition.sel_end) |
| 466 | |
| 467 | if context.menu.page_size: |
| 468 | print("page_size",context.menu.page_size) |
| 469 | select_keys = b'' |
| 470 | if context.select_labels: |
| 471 | for i in range(context.menu.page_size): |
| 472 | select_keys += context.select_labels[i] |
| 473 | elif context.menu.select_keys: |
| 474 | select_keys = context.menu.select_keys |
| 475 | if select_keys: |
| 476 | print("select_keys",select_keys.decode("UTF-8")) |
| 477 | |
| 478 | if context.menu.num_candidates: |
| 479 | print("num_candidates", context.menu.num_candidates) |
| 480 | candidates = [] |
| 481 | for i in range(context.menu.num_candidates): |
| 482 | cand = context.menu.candidates[i] |
| 483 | s = cand.text |
| 484 | if cand.comment: |
| 485 | s += b' ' + cand.comment |
| 486 | candidates.append(s.decode("UTF-8")) |
| 487 | print(candidates) |
| 488 | rime.free_context(context) |
| 489 | |
| 490 | if __name__ == "__main__": |
| 491 | rimeInit() |
no test coverage detected