Skip to content

Commit

Permalink
decode (cmap/initialize): fix unquoted special chars in the cmap cache
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Sep 18, 2021
1 parent a30887f commit 7434d2d
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 22 deletions.
23 changes: 23 additions & 0 deletions lib/init-cmap.sh
Expand Up @@ -291,6 +291,29 @@ function ble/init:cmap/initialize {
ble/init:cmap/bind-single-csi '2 K' S-delete
ble/init:cmap/bind-single-csi 'P' delete

# kitty specific "CSI ... u" sequences
_ble_decode_csimap_kitty_u=(
[57358]=capslock [57359]=scrolllock [57360]=numlock [57361]=print [57362]=pause [57363]=menu

[57376]=f13 [57377]=f14 [57378]=f15 [57379]=f16 [57380]=f17 [57381]=f18 [57382]=f19 [57383]=f20
[57384]=f21 [57385]=f22 [57386]=f23 [57387]=f24 [57388]=f25 [57389]=f26 [57390]=f27 [57391]=f28
[57392]=f29 [57393]=f30 [57394]=f31 [57395]=f32 [57396]=f33 [57397]=f34 [57398]=f35

[57399]=0 [57400]=1 [57401]=2 [57402]=3 [57403]=4 [57404]=5 [57405]=6 [57406]=7 [57407]=8 [57408]=9
[57409]='.' [57410]='/' [57411]='*' [57412]='-' [57413]='+' [57414]=RET [57415]='=' [57416]=','
[57417]=left [57418]=right [57419]=up [57420]=down
[57421]=prior [57422]=next [57423]=home [57424]=end [57425]=insert [57426]=delete [57427]=begin

[57428]=media_play [57429]=media_pause [57430]=media_play_pause [57431]=media_reverse
[57432]=media_stop [57433]=media_fast_forward [57434]=media_rewind [57435]=media_track_next
[57436]=media_track_prev [57437]=media_record [57438]=lower_volume [57439]=raise_volume
[57440]=mute_volume

[57441]=lshift [57442]=lcontrol [57443]=lalter [57444]=lsuper [57445]=lhyper [57446]=lmeta
[57447]=rshift [57448]=rcontrol [57449]=ralter [57450]=rsuper [57451]=rhyper [57452]=rmeta
[57453]=iso_shift3 [57454]=iso_shift5
)

ble/edit/info/immediate-show text "ble/lib/init-cmap.sh: updating key sequences... done"
}

Expand Down
1 change: 1 addition & 0 deletions memo/ChangeLog.md
Expand Up @@ -160,6 +160,7 @@
- global: work around readonly `TMOUT` (reported by farmerbobathan) `#D1630` 44e6ec1
- complete: fix a task scheduling bug of referencing two different clocks (reported by rashil2000) `#D1636` fea5f5b
- canvas: update prompt trace on `char_width_mode` change (reported by Barbarossa93) `#D1642` 68ee111
- decode (`cmap/initialize`): fix unquoted special chars in the cmap cache `#D1647` 0000000

## Optimization

Expand Down
11 changes: 11 additions & 0 deletions note.txt
Expand Up @@ -5374,6 +5374,17 @@ bash_tips

2021-09-16

* decode: failglob で cmap 初期化時にエラーになる問題 [#D1647]

Solaris で試している時に気づいた。bashrc の中で ble-bind を実行して、cmap
initialization が其処で走ると failglob の時に cmap cache の読み取りに失敗す
る。

原因は _ble_decode_csimap_kitty_u に直接 keyname が格納されていて、中でも
'*' が悪さをしているという事だった。cache は declare -p による dump で生成
しているので本来は quote されている筈だが、容量を節約する為に quote を外し
ていたのが原因だった (kitty_u 以外は整数なので quote の必要はなかった)。

* edit: stdout.off で stderr だけ suppress という案について (motivated by rashil2000) [#D1646]
https://github.com/akinomyoga/ble.sh/issues/133#issuecomment-910543950

Expand Down
27 changes: 5 additions & 22 deletions src/decode.sh
Expand Up @@ -775,27 +775,9 @@ function ble-decode-char/csi/clear {
_ble_decode_csi_mode=0
}

_ble_decode_csimap_kitty_u=(
[57358]=capslock [57359]=scrolllock [57360]=numlock [57361]=print [57362]=pause [57363]=menu

[57376]=f13 [57377]=f14 [57378]=f15 [57379]=f16 [57380]=f17 [57381]=f18 [57382]=f19 [57383]=f20
[57384]=f21 [57385]=f22 [57386]=f23 [57387]=f24 [57388]=f25 [57389]=f26 [57390]=f27 [57391]=f28
[57392]=f29 [57393]=f30 [57394]=f31 [57395]=f32 [57396]=f33 [57397]=f34 [57398]=f35

[57399]=0 [57400]=1 [57401]=2 [57402]=3 [57403]=4 [57404]=5 [57405]=6 [57406]=7 [57407]=8 [57408]=9
[57409]='.' [57410]='/' [57411]='*' [57412]='-' [57413]='+' [57414]=RET [57415]='=' [57416]=','
[57417]=left [57418]=right [57419]=up [57420]=down
[57421]=prior [57422]=next [57423]=home [57424]=end [57425]=insert [57426]=delete [57427]=begin

[57428]=media_play [57429]=media_pause [57430]=media_play_pause [57431]=media_reverse
[57432]=media_stop [57433]=media_fast_forward [57434]=media_rewind [57435]=media_track_next
[57436]=media_track_prev [57437]=media_record [57438]=lower_volume [57439]=raise_volume
[57440]=mute_volume

[57441]=lshift [57442]=lcontrol [57443]=lalter [57444]=lsuper [57445]=lhyper [57446]=lmeta
[57447]=rshift [57448]=rcontrol [57449]=ralter [57450]=rsuper [57451]=rhyper [57452]=rmeta
[57453]=iso_shift3 [57454]=iso_shift5
)
# Initialized in lib/init-cmap.sh
_ble_decode_csimap_kitty_u=()

## @fn ble-decode/char/csi/.translate-kitty-csi-u
## @var[in,out] key
function ble-decode/char/csi/.translate-kitty-csi-u {
Expand Down Expand Up @@ -2621,7 +2603,8 @@ function ble/decode/cmap/initialize {
sub(/^-- +/, "");
}
/^_ble_decode_(cmap|csimap|kbd)/ {
gsub(/["'\'']/, "");
if (!($0 ~ /^_ble_decode_csimap_kitty_u/))
gsub(/["'\'']/, "");
print
}
' >| "$dump"
Expand Down

0 comments on commit 7434d2d

Please sign in to comment.