Skip to content

Commit

Permalink
✨ Add :rime:keys's special
Browse files Browse the repository at this point in the history
  • Loading branch information
Freed-Wu committed Jul 27, 2024
1 parent a2d5751 commit f37b472
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,17 @@ zstyle -s ':rime:traits' app-name app_name ||
app_name=rime.zsh-rime
zstyle -s ':rime:traits' min-log-level min_log_level ||
min_log_level=3

zstyle -a ':rime:keys' special special ||
special=('^'{\?.._} '^['{\ ..~} '^[['{A..D}) &&
zmodload zsh/terminfo &&
for key in k{u,d,l,r,D,I,P,N,h,\;} @7 k{1..9} F{1..9} F{A..P}; do
special+=("$termcap[$key]")
done &&
zmodload zsh/termcap &&
for key in kcu{u,d,b,f}1 k{d,i}ch1 k{p,n}p k{home,end} kf{1..35}; do
special+=("$terminfo[$key]")
done
```

## Integrate
Expand Down
26 changes: 13 additions & 13 deletions rime-ime
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
autoload -Uz rime-process-key || return 1

local indices left right left_sep right_sep cursor preedit
local indices left right left_sep right_sep cursor special preedit
local -i prompt_len
zstyle -a ':rime:ui' indices indices ||
indices=(① ② ③ ④ ⑤ ⑥ ⑦ ⑧ ⑨ ⓪)
Expand All @@ -16,6 +16,16 @@ zstyle -s ':rime:ui' cursor cursor ||
cursor='|'
zstyle -s ':rime:ui' prompt-len prompt_len ||
prompt_len=2
zstyle -a ':rime:keys' special special ||
special=('^'{\?.._} '^['{\ ..~} '^[['{A..D}) &&
zmodload zsh/terminfo &&
for key in k{u,d,l,r,D,I,P,N,h,\;} @7 k{1..9} F{1..9} F{A..P}; do
special+=("$termcap[$key]")
done &&
zmodload zsh/termcap &&
for key in kcu{u,d,b,f}1 k{d,i}ch1 k{p,n}p k{home,end} kf{1..35}; do
special+=("$terminfo[$key]")
done

draw-ui() {
rime getContext $1 context_composition context_menu context_menu_candidates_text context_menu_candidates_comment
Expand Down Expand Up @@ -83,18 +93,8 @@ zle -A accept-line rime-ime

bindkey -N rime main
local key
for key in {\?.._} '['{\ ..~} '[['{A..D}; do
bindkey -M rime "^$key" self-insert
done
zmodload zsh/terminfo 2>/dev/null
for key in k{u,d,l,r,D,I,P,N,h,\;} @7 k{1..9} F{1..9} F{A..P}; do
[[ -n $termcap[$key] ]] &&
bindkey -M rime "$termcap[$key]" self-insert
done
zmodload zsh/termcap 2>/dev/null
for key in kcu{u,d,b,f}1 k{d,i}ch1 k{p,n}p k{home,end} kf{1..35}; do
[[ -n $terminfo[$key] ]] &&
bindkey -M rime "$terminfo[$key]" self-insert
for key in $special; do
bindkey -M rime "$key" self-insert
done

zle recursive-edit -K rime
Expand Down

0 comments on commit f37b472

Please sign in to comment.