Repository navigation
feat(qt): Qt 终端接入 IME 组合/提交/取消 (#155) - #205
Conversation
… refs #155 Enables WA_InputMethodEnabled, answers the ime cursor rectangle query, previews the preedit with an underline and sends only the committed UTF-8 text, so cancelling writes nothing.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dea60655db
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const QString commit = event->commitString(); | ||
| if (!commit.isEmpty()) { | ||
| model_.send(commit.toUtf8()); | ||
| preedit_.clear(); |
There was a problem hiding this comment.
Preserve the new preedit when an event also commits text
When an IME commits part of a composition while continuing the remainder, a single event can contain both a nonempty commitString() and a nonempty preeditString(). This handler first stores the new preedit, then unconditionally clears it, making the ongoing composition disappear until another preedit event arrives. Qt's event contract treats the commit and replacement preedit as separate operations. Forward the committed text while retaining the event's new preedit; an empty preedit already handles composition completion or cancellation.
Useful? React with 👍 / 👎.
| if (query == Qt::ImCursorRectangle && grid_ready_) { | ||
| const auto& screen = model_.screen(); | ||
| return QRect(margin + screen.column * cell_width_, margin + screen.row * cell_height_, cell_width_, cell_height_); |
There was a problem hiding this comment.
Notify the input method when the caret rectangle changes
During an active composition, shell output or a resize/font change can move the terminal caret, but refresh_session() only schedules painting and no code calls QGuiApplication::inputMethod()->update(...). Returning the latest rectangle from this query does not notify the platform that it changed: Qt requires input items to report query changes, and the pinned Qt 6.10.3 Windows implementation repositions the native candidate window through cursorRectangleChanged. Consequently, the preview can move while the candidate window remains at its previous position. Notify the input method with Qt::ImCursorRectangle when the focused terminal's caret geometry changes.
Useful? React with 👍 / 👎.
内容
#155 的第一个产品切片:让 Qt 终端接入输入法的组合、提交与取消。
Qt::WA_InputMethodEnabled(此前显式关闭);inputMethodQuery:返回光标格矩形(供候选窗定位)、空 surrounding text/selection;inputMethodEvent:preeditString()只作为界面预览(在光标处带下划线绘制),不写入会话;commitString()以 UTF-8 发送给会话,随后清空 preedit;边界
qt-cpp-windows作业负责编译验证。测试
本地无 Qt SDK 构建路径(configure 未找到 Qt),因此本 PR 的编译验证依赖 CI 的 Qt 作业;运行期验证列在 #155 的下一步。
Refs #155