Skip to content

feat: add menu bar ascii_mode display#1130

Open
Cosss7 wants to merge 1 commit into
rime:masterfrom
Cosss7:feat/status-menubar
Open

feat: add menu bar ascii_mode display#1130
Cosss7 wants to merge 1 commit into
rime:masterfrom
Cosss7:feat/status-menubar

Conversation

@Cosss7
Copy link
Copy Markdown

@Cosss7 Cosss7 commented May 19, 2026

解决一个长久以来的用户体验问题: #118

本 PR 由 AI 编写,人工审核,如果有任何问题请 comment on PR ,我会及时修改,共同建设 RIME

功能摘要

在 macOS 菜单栏中显示当前输入法的中英文状态(如"中"/"A"),方便用户随时知晓当前输入模式。

实现细节

  • 新增 StatusBarManager.swift:管理 NSStatusItem 的生命周期和文本更新
  • SquirrelApplicationDelegate
    • 持有 StatusBarManager 实例
    • 读取 menubar_ascii_mode 配置(默认 true
    • showStatusMessage 中同步更新菜单栏状态
    • 应用关闭时调用 teardown() 清理菜单栏图标
  • SquirrelInputController
    • activateServer() 中查询当前 ascii_mode 并更新菜单栏显示
    • 新增 updateMenuBarStatus() 方法,通过 Rime API 获取状态标签
  • project.pbxproj:添加 StatusBarManager.swift 到编译目标

配置项

squirrel.yaml 中新增(向后兼容,默认开启):

menubar_ascii_mode: true  # 是否在菜单栏显示当前 ascii_mode 状态

测试计划

  • 启动输入法,菜单栏显示"中"或"A"
  • 切换中英文模式,菜单栏状态实时更新
  • 切换输入框(不同应用间),菜单栏状态正确同步
  • 设置 menubar_ascii_mode: false,菜单栏图标不显示
  • 重启输入法后配置生效

- 切换 app 时 menu bar 状态跟随当前 session 的 ascii_mode 更新
- 增加配置 squirrel.yaml 中 menubar_ascii_mode 默认 false
@Cosss7 Cosss7 force-pushed the feat/status-menubar branch from cd08941 to 1a37507 Compare May 19, 2026 01:52
Copy link
Copy Markdown
Member

@lotem lotem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感謝 PR。

如果功能與 #1122 相同,
可以考慮等等那邊的(我沒細看實現機制是不是一樣)。

func showStatusMessage(msgTextLong: String?, msgTextShort: String?) {
if !(msgTextLong ?? "").isEmpty || !(msgTextShort ?? "").isEmpty {
panel?.updateStatus(long: msgTextLong ?? "", short: msgTextShort ?? "")
statusBarManager.updateStatus(text: msgTextShort ?? "")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

除了 ascii_mode 也會顯示其他更新的狀態嗎


func updateMenuBarStatus() {
guard session != 0 else { return }
let isAsciiMode = rimeAPI.get_option(session, "ascii_mode")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

最好先檢查狀態圖標是否啓用,未啓用則不需要獲取當前狀態、簡寫等信息。

@Cosss7
Copy link
Copy Markdown
Author

Cosss7 commented May 20, 2026

感謝 PR。

如果功能與 #1122 相同, 可以考慮等等那邊的(我沒細看實現機制是不是一樣)。

他的更完善,我研究一下~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants