Skip to content

Commit

Permalink
decode (ble-decode-kbd): support various specifications of key sequences
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Jan 1, 2021
1 parent 8379d4a commit 0f01cab
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 7 deletions.
1 change: 1 addition & 0 deletions memo/ChangeLog.md
Expand Up @@ -6,6 +6,7 @@
## New features

- complete/mandb: support mandb in FreeBSD `#D1432` 6c54f79
- decode (`ble-decode-kbd`): support various specifications of key sequences `#D1439` 0000000

## Changes

Expand Down
11 changes: 11 additions & 0 deletions note.txt
Expand Up @@ -3704,6 +3704,17 @@ bash_tips
Done (実装ログ)
-------------------------------------------------------------------------------

2021-01-01

* decode (ble-decode-kbd): support various keyseq specifications [#D1439]
https://github.com/urbainvaes/fzf-marks/pull/41
https://github.com/urbainvaes/fzf-marks/pull/43

上記で ble.sh 特有の binding を追加してもらったが、ble-bind がユーザーが自
由に対応キーを指定できる様に公開されている変数 FZF_MARKS_JUMP の形式に合わ
ない為に C-g 決め打ちになってしまっている。ble-bind でも bind と同様の形式
で keyseq を指定できる様にしたい。

2020-12-25

* edit: f1 で関数定義を表示する時に LESS=-r が効いていない [#D1438]
Expand Down
58 changes: 51 additions & 7 deletions src/decode.sh
Expand Up @@ -330,11 +330,46 @@ function ble-decode-kbd/.initialize {

ble-decode-kbd/.initialize

## 関数 ble-decode-kbd kspecs...
## @param[in] kspecs
## 関数 ble-decode-kbd [TYPE:]VALUE...
## @param[in] TYPE VALUE
## キー列を指定します。TYPE はキー列の解釈方法を指定します。
## TYPE の値に応じて VALUE には以下の物を指定します。TYPE の既定値は kbd です。
## kspecs ... kspecs を指定します。
## keyseq ... bash bind の keyseq を指定します。
## chars ... 文字コードの整数列を指定します。
## key ... キーコードの整数列を指定します。
## raw ... バイト列を直接文字列として指定します。
##
## @var[out] ret
## キー列を空白区切りの整数列として返します。
function ble-decode-kbd {
local kspecs; ble/string#split-words kspecs "$*"
local spec="$*"
case $spec in
(keys:*)
ret="${spec#*:}"
return ;;
(chars:*)
local chars
ble/string#split-words chars "${spec#*:}"
ble/decode/cmap/decode-chars "${ret[@]}"
ret="${keys[*]}"
return ;;
(keyseq:*) # i.e. untranslated keyseq
local keys
ble/util/keyseq2chars "${spec#*:}"
ble/decode/cmap/decode-chars "${ret[@]}"
ret="${keys[*]}"
return ;;
(raw:*) # i.e. translated keyseq
ble/util/s2chars "${spec#*:}"
ble/decode/cmap/decode-chars "${ret[@]}"
ret="${keys[*]}"
return ;;
(kspecs:*)
spec=${spec#*:} ;;
esac

local kspecs; ble/string#split-words kspecs "$spec"
local kspec code codes
codes=()
for kspec in "${kspecs[@]}"; do
Expand Down Expand Up @@ -2740,13 +2775,22 @@ function ble-bind/.initialize-kmap {
function ble-bind/option:help {
ble/util/cat <<EOF
ble-bind --help
ble-bind -k cspecs [kspec]
ble-bind --csi PsFt kspec
ble-bind [-m keymap] -fxc@s kspecs command
ble-bind [-m keymap] -T kspecs timeout
ble-bind -k [TYPE:]cspecs [[TYPE:]kspec]
ble-bind --csi PsFt [TYPE:]kspec
ble-bind [-m keymap] -fxc@s [TYPE:]kspecs command
ble-bind [-m keymap] -T [TYPE:]kspecs timeout
ble-bind [-m keymap]... (-PD|--print|--dump)
ble-bind (-L|--list-widgets)
TYPE:SPEC
TYPE specifies the format of SPEC. The default is "kspecs".
kspecs ble.sh keyboard spec
keys List of key codes
chars List of character codes in Unicode
keyseq Key sequence in the Readline format
raw Raw byte sequence
EOF
}

Expand Down

0 comments on commit 0f01cab

Please sign in to comment.