feat: ReservedProperty protocol for plugin→frontend coordination#1143
Conversation
Introduce ReservedProperty to track and preserve reserved comments across Rime updates, and avoid clearing them on caret/selection-only updates. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
| // │ the active InputController via handleReservedProperty│ | ||
| // └──────────────────────────────────────────────────────────────┘ | ||
| // | ||
| // The leading-underscore namespace marks the key as part of this |
There was a problem hiding this comment.
Keys with leading-underscore are "transient options/properties":
https://github.com/rime/librime/blob/d71168e9e8c8392ed219dca011dbc76b80727d6c/src/rime/context.cc#L313
Their lifetime are bound to the active input schema in the context.
There was a problem hiding this comment.
Thanks — corrected. The header now states that leading-underscore keys are librime transient properties whose lifetime is bound to the active input schema in the context (and cleared on schema change), and frames this protocol as reserving a subset of that namespace rather than inventing it. Fixed in b983b60.
- Document leading-underscore keys as librime transient properties whose lifetime is bound to the active input schema (per @lotem, context.cc). - Rename the bare-value shorthand field from `indices` to the neutral `value` so non-index keys can reuse the same scalar shorthand. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Rename short local bindings flagged by swiftlint and reposition a cyclomatic_complexity disable comment so it sits directly above the function declaration: - ReservedProperty.swift: n -> index - SquirrelApplicationDelegate.swift: eq -> eqIndex - SquirrelInputController.swift: move disable directive to the decl No behavioural change. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
I made some changes according to my review comments. @wyjrichhh @lotem Any objections? |
|
中 |
|
No objections, thanks! |
前端保留 property key 协议 (#1124) 已通过 rime/squirrel#1143 合并进 上游鼠须管 master,不再需要 fork。同步修正文档与协议细节: - README: fork 叙事改为「上游 master (含 #1143,未发版)」;协议 插件无关;补 payload 格式表 (_refresh_ui query string、 _comment_highlight 裸索引列表、_comment_warning 未发出);补 ContextBuilder 跳过 raw 类型的说明与刷新语义。 - frontend_protocol.h: _comment_highlight 编码注释改为前端归一化 到中性 value 字段;说明保留但未声明的 _comment_warning。 - context_builder.cc: 标点过滤改 Unicode range 匹配(覆盖整块 CJK/ fullwidth/general 标点,修复 )等泄漏);新增 IsPinyinPrompt 拒绝 非拼音段(裸标点/ASCII 符号/大写缩写)。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
如果仍然想改LOG_DIR的話再提一個PR吧,這個改動比較大,很多教程都要改,急不得 |
Summary
Introduces a
ReservedPropertyprotocol so a librime plugin can coordinatewith the Squirrel frontend over the existing
propertymessage channel,using reserved keys with a leading underscore (e.g.
_refresh_ui). Unknownreserved keys are silently ignored, so the wire format is backward-compatible.
The motivating use case (per #1124) is letting a plugin drive
semantic comment styling (accent / warning colors) on specific candidate
indices, and trigger a UI refresh without a keystroke.
Changes
sources/ReservedProperty.swift(new) — definesReservedPropertyKey,ReservedPropertyValue(URL-query-style parsing of the value payload), andindex-set decoding. This is the documented wire format and reserved-key table.
SquirrelApplicationDelegate.swift— routespropertymessages whose valuestarts with
_to the active input controller as reserved properties.SquirrelInputController.swift— addshandleReservedProperty(...)and astate-type reserved-property cache.
rimeUpdategains aclearReservedCommentsflag (defaulttrue) so reserved-comment indices setby the previous Compose() are dropped on ordinary state-changing updates and
preserved only for the
_refresh_ui-driven render.SquirrelPanel.swift/SquirrelTheme.swift— apply per-index semanticcomment colors (
accentCommentTextColor,warningCommentTextColor).Testing
missing
cangjie5*.dict.yamlresources and a CoreSimulator version mismatch,both unrelated to this change — CI build is the reliable signal here).