Skip to content

Commit e2d4679

Browse files
committed
fix: clipboard to send long candidates
1 parent 0cb8622 commit e2d4679

File tree

5 files changed

+29
-5
lines changed

5 files changed

+29
-5
lines changed

Lib/RabbitConfig.ahk

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class RabbitConfig {
2828
static schema_icon := Map()
2929
static fix_candidate_box := false
3030
static use_legacy_candidate_box := false
31+
static send_by_clipboard_length := 8
3132

3233
static load() {
3334
global rime, IS_DARK_MODE
@@ -43,6 +44,12 @@ class RabbitConfig {
4344
RabbitConfig.show_tips := false
4445
}
4546

47+
if rime.config_test_get_int(config, "send_by_clipboard_length", &result)
48+
; 0: always send by clipboard
49+
; >0: send by clipboard if length >= value
50+
; <0: never send by clipboard (65535 is large enough for candidates)
51+
RabbitConfig.send_by_clipboard_length := result >= 0 ? result : 65535
52+
4653
if rime.config_test_get_bool(config, "global_ascii", &result)
4754
RabbitConfig.global_ascii := !!result
4855

Lib/RabbitTrayMenu.ahk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#Include <RabbitCommon>
2020
#Include <RabbitConfig>
2121

22-
A_IconTip := "玉兔毫"
22+
A_IconTip := "玉兔毫(维护中)"
2323

2424
global TRAY_SCHEMA_NAME := ""
2525
global TRAY_ASCII_MODE := 0

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
1616
### 通过发布页面下载
1717

18-
正式发行版会在 [Release 页面](https://github.com/rimeinn/rabbit/releases) Assets 中,下载最新的 `rabbit-v<版本号>.zip`,解压到一个新建文件夹,运行 `Rabbit.exe` 即可。
18+
正式发行版会在 [Release](https://github.com/rimeinn/rabbit/releases) 页面的 Assets 中,下载最新的 `rabbit-v<版本号>.zip`,解压到一个新建文件夹,运行 `Rabbit.exe` 即可。
1919

2020
每夜构建版可在 [`latest`](https://github.com/rimeinn/rabbit/releases/tag/latest) 页面下载。
2121

@@ -68,7 +68,6 @@ rabbit/
6868
- [librime-ahk](https://github.com/rimeinn/librime-ahk)
6969
- [AHK-Direct2D](https://github.com/rawbx/AHK-Direct2D)
7070
- [OpenCC](https://github.com/BYVoid/OpenCC)
71-
- ~~[AHKv2-Gdip](https://github.com/buliasz/AHKv2-Gdip)~~
7271
- [GetCaretPos](https://github.com/Descolada/AHK-v2-libraries)
7372
- [GetCaretPosEx](https://github.com/Tebayaki/AutoHotkeyScripts/tree/main/lib/GetCaretPosEx)
7473
- [东风破](https://github.com/rime/plum)
@@ -78,7 +77,6 @@ rabbit/
7877

7978
## 已知问题
8079

81-
- 候选框图形界面较为简陋,有闪烁等问题
8280
- 某些情况无法获得输入光标的坐标
8381
- 桌面版 QQ 的密码输入框无法使用:[QQ密码输入框(防键盘钩子)原理分析](https://blog.csdn.net/muyedongfeng/article/details/49308993)
8482
[页面存档备份](https://web.archive.org/web/20240907052640/https://blog.csdn.net/muyedongfeng/article/details/49308993),存于互联网档案馆),可右键点击任务栏图标选择禁用/启用玉兔毫,或是在 `rabbit.custom.yaml` 里设置 `suspend_hotkey` 指定快捷键来禁用/启用玉兔毫

Rabbit.ahk

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,10 @@ ProcessKey(key, mask, this_hotkey) {
359359
last_is_hide := true
360360
else
361361
last_is_hide := false
362-
SendText(commit.text)
362+
if StrLen(commit.text) >= RabbitConfig.send_by_clipboard_length
363+
SendTextByClipboard(commit.text)
364+
else
365+
SendText(commit.text)
363366
box.Hide()
364367
rime.free_commit(commit)
365368
} else
@@ -530,3 +533,15 @@ UpdateWinAscii(target := false, use_target := false, proc_name := "", by_tray_ic
530533
UpdateTrayTip(, target)
531534
UpdateTrayIcon()
532535
}
536+
537+
; by rawbx (https://github.com/rimeinn/rabbit/issues/13#issuecomment-3072554342)
538+
SendTextByClipboard(text) {
539+
clip_prev := A_Clipboard
540+
A_Clipboard := text
541+
542+
if ClipWait(0.5, 0)
543+
Send('+{Insert}') ; or Send('^v')
544+
545+
; Restore clipboard
546+
SetTimer(() => A_Clipboard := clip_prev, -50)
547+
}

schemas/rabbit.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ suspend_hotkey: null
99
show_tips: true
1010
# How long a period tips shows
1111
show_tips_time: 1200
12+
# 0: always send by clipboard
13+
# >0: send by clipboard if length >= value
14+
# <0: never send by clipboard
15+
send_by_clipboard_length: 8
1216

1317
app_options:
1418
cmd.exe:

0 commit comments

Comments
 (0)