summaryrefslogtreecommitdiff
path: root/.local/src/blesh/keymap/vi_digraph.sh
diff options
context:
space:
mode:
authorSaumit Dinesan <justsaumit@protonmail.com>2022-05-22 00:37:40 +0530
committerSaumit Dinesan <justsaumit@protonmail.com>2022-05-22 00:37:40 +0530
commitc3362aefa2e762211409923cfff065541bebf9e7 (patch)
treee48e225190fc0bb1a2db18ae2510a89a6f0d8653 /.local/src/blesh/keymap/vi_digraph.sh
parent4df17a688ba54d710a1d46ee47cb65b5c9e75764 (diff)
ble.sh & z4h addition
Diffstat (limited to '.local/src/blesh/keymap/vi_digraph.sh')
-rw-r--r--.local/src/blesh/keymap/vi_digraph.sh51
1 files changed, 51 insertions, 0 deletions
diff --git a/.local/src/blesh/keymap/vi_digraph.sh b/.local/src/blesh/keymap/vi_digraph.sh
new file mode 100644
index 0000000..dce0bf4
--- /dev/null
+++ b/.local/src/blesh/keymap/vi_digraph.sh
@@ -0,0 +1,51 @@
+# this script is a part of blesh (https://github.com/akinomyoga/ble.sh) under BSD-3-Clause license
+_ble_keymap_vi_digraph__hook=
+function ble/widget/vi_digraph/.proc {
+ local code=$1
+ local hook=${_ble_keymap_vi_digraph__hook:-ble-decode-key}
+ _ble_keymap_vi_digraph__hook=
+ ble/decode/keymap/pop
+ builtin eval -- "$hook $code"
+}
+function ble/widget/vi_digraph/defchar {
+ ble/widget/vi_digraph/.proc "${KEYS[0]}"
+}
+function ble/widget/vi_digraph/default {
+ local key=${KEYS[0]}
+ local flag=$((key&_ble_decode_MaskFlag)) char=$((key&_ble_decode_MaskChar))
+ if ((flag==_ble_decode_Ctrl&&63<=char&&char<128&&(char&0x1F)!=0)); then
+ ((char=char==63?127:char&0x1F))
+ ble/widget/vi_digraph/.proc "$char"
+ return 0
+ fi
+ ble/widget/.bell
+ return 0
+}
+function ble-decode/keymap:vi_digraph/define {
+ ble-bind -f __defchar__ vi_digraph/defchar
+ ble-bind -f __default__ vi_digraph/default
+ ble-bind -f __line_limit__ nop
+ local lines; ble/util/mapfile lines < "$_ble_base/keymap/vi_digraph.txt"
+ local line field ch1 ch2 code
+ for line in "${lines[@]}"; do
+ [[ $line == ??' '* ]] || continue
+ ch1=${line::1}
+ ch2=${line:1:1}
+ code=${line:3}
+ ble-bind -f "$ch1 $ch2" "vi_digraph/.proc $code"
+ done
+}
+function ble-decode/keymap:vi_digraph/initialize {
+ local fname_keymap_cache=$_ble_base_cache/keymap.vi_digraph
+ if [[ -s $fname_keymap_cache &&
+ $fname_keymap_cache -nt $_ble_base/keymap/vi_digraph.sh &&
+ $fname_keymap_cache -nt $_ble_base/keymap/vi_digraph.txt ]]; then
+ source "$fname_keymap_cache"
+ return 0
+ fi
+ ble/edit/info/immediate-show text "ble.sh: updating cache/keymap.vi_digraph..."
+ : >| "$fname_keymap_cache"
+ ble/decode/keymap#load vi_digraph dump 3>> "$fname_keymap_cache"
+ ble/edit/info/immediate-show text "ble.sh: updating cache/keymap.vi_digraph... done"
+}
+ble-decode/keymap:vi_digraph/initialize