Skip to content

Commit

Permalink
add status tips
Browse files Browse the repository at this point in the history
  • Loading branch information
amorphobia committed Oct 1, 2023
1 parent fd26962 commit f4e59f6
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 4 deletions.
7 changes: 3 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
Rime/build
Rime/*.userdb*
Rime/installation.yaml
Rime/user.yaml
Rime
*.exe
*.dll
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@

[GPL-3.0](LICENSE)

## 使用的开源项目

- [librime](https://github.com/rime/librime)
- [librime-ahk](https://github.com/amorphobia/librime-ahk)
- [GetCaretPos](https://github.com/Descolada/AHK-v2-libraries)
- [🌟️星空键道](https://github.com/amorphobia/rime-jiandao)
- [朙月拼音](https://github.com/rime/rime-luna-pinyin)

以及一些代码片段,在注释中注明了来源链接

## ⚠️正在施工⚠️

目前仅实现了一个原型,上下文界面使用 [ToolTip](https://www.autohotkey.com/docs/v2/lib/ToolTip.htm) 简单显示,但已经可以用来输入了,此 README 文件就是使用玉兔毫部署的[星空键道](https://github.com/amorphobia/rime-jiandao)方案编写。可以在 Actions 里找到自动打包的文件,解压后运行 `Rabbit.exe` 即可。
Expand All @@ -18,3 +28,4 @@
- 注册热键的问题,例如,上档键输入的字符似乎需要额外注册;热键过多,注册会比较耗时等问题(已取消 Win 键的相关注册,应该有所缓解)
- 并非使用系统的输入法接口,而是用热键的方式获取按键,可能导致一些问题,如,需要保留一个英文输入语言;退出玉兔毫时,可能无法恢复先前的输入法语言等
- 管理员权限打开的窗口应该不起作用
- Windows 远程桌面连接中,不应拦截切换 ascii mode 的热键,而是交给远程桌面控制
32 changes: 32 additions & 0 deletions Rabbit.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,39 @@ ProcessKey(key, mask, this_hotkey) {
if not code
return

static STATUS_TOOLTIP := 2
local status := rime.get_status(session_id)
local old_ascii_mode := status.is_ascii_mode
local old_full_shape := status.is_full_shape
local old_ascii_punct := status.is_ascii_punct
rime.free_status(status)

processed := rime.process_key(session_id, code, mask)

status := rime.get_status(session_id)
local new_ascii_mode := status.is_ascii_mode
local new_full_shape := status.is_full_shape
local new_ascii_punct := status.is_ascii_punct
rime.free_status(status)

local status_text := ""
local status_changed := false
if old_ascii_mode != new_ascii_mode {
status_changed := true
status_text := new_ascii_mode ? "En" : ""
} else if old_full_shape != new_full_shape {
status_changed := true
status_text := new_full_shape ? "" : ""
} else if old_ascii_punct != new_ascii_punct {
status_changed := true
status_text := new_ascii_punct ? ",." : ",。"
}

if status_changed {
ToolTip(status_text, , , STATUS_TOOLTIP)
SetTimer(() => ToolTip(, , , STATUS_TOOLTIP), -2000)
}

if commit := rime.get_commit(session_id) {
SendText(commit.text)
ToolTip()
Expand Down

0 comments on commit f4e59f6

Please sign in to comment.