sistema_progs

Programas para customizar o meu entorno de traballo nos meus equipos persoais
Log | Files | Refs

keymap.vi_digraph.sh (1945B)


      1 #!/bin/bash
      2 
      3 # 2020-04-29 force update (rename ble-decode/keymap/.register)
      4 # 2021-04-26 force update (rename ble/decode/keymap#.register)
      5 
      6 _ble_keymap_vi_digraph__hook=
      7 
      8 function ble/widget/vi_digraph/.proc {
      9   local code=$1
     10   local hook=${_ble_keymap_vi_digraph__hook:-ble-decode-key}
     11   _ble_keymap_vi_digraph__hook=
     12   ble/decode/keymap/pop
     13   builtin eval -- "$hook $code"
     14 }
     15 
     16 function ble/widget/vi_digraph/defchar {
     17   ble/widget/vi_digraph/.proc "${KEYS[0]}"
     18 }
     19 
     20 function ble/widget/vi_digraph/default {
     21   local key=${KEYS[0]}
     22   local flag=$((key&_ble_decode_MaskFlag)) char=$((key&_ble_decode_MaskChar))
     23   if ((flag==_ble_decode_Ctrl&&63<=char&&char<128&&(char&0x1F)!=0)); then
     24     ((char=char==63?127:char&0x1F))
     25     ble/widget/vi_digraph/.proc "$char"
     26     return 0
     27   fi
     28 
     29   ble/widget/.bell
     30   return 0
     31 }
     32 
     33 function ble-decode/keymap:vi_digraph/define {
     34   ble-bind -f __defchar__ vi_digraph/defchar
     35   ble-bind -f __default__ vi_digraph/default
     36   ble-bind -f __line_limit__ nop
     37 
     38   local lines; ble/util/mapfile lines < "$_ble_base/lib/keymap.vi_digraph.txt"
     39 
     40   local line field ch1 ch2 code
     41   for line in "${lines[@]}"; do
     42     [[ $line == ??' '* ]] || continue
     43     ch1=${line::1}
     44     ch2=${line:1:1}
     45     code=${line:3}
     46     ble-bind -f "$ch1 $ch2" "vi_digraph/.proc $code"
     47   done
     48 }
     49 
     50 function ble-decode/keymap:vi_digraph/initialize {
     51   local fname_keymap_cache=$_ble_base_cache/keymap.vi_digraph
     52   if [[ -s $fname_keymap_cache &&
     53           $fname_keymap_cache -nt $_ble_base/lib/keymap.vi_digraph.sh &&
     54           $fname_keymap_cache -nt $_ble_base/lib/keymap.vi_digraph.txt ]]; then
     55     source "$fname_keymap_cache"
     56     return 0
     57   fi
     58 
     59   ble/edit/info/immediate-show text "ble.sh: updating cache/keymap.vi_digraph..."
     60 
     61   : >| "$fname_keymap_cache"
     62   ble/decode/keymap#load vi_digraph dump 3>> "$fname_keymap_cache"
     63 
     64   ble/edit/info/immediate-show text "ble.sh: updating cache/keymap.vi_digraph... done"
     65 }
     66 
     67 ble-decode/keymap:vi_digraph/initialize