sistema_progs

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

core-complete-def.sh (5226B)


      1 #!/bin/bash
      2 
      3 ble/is-function ble/util/idle.push && ble-import -d "$_ble_base/lib/core-complete.sh"
      4 
      5 #------------------------------------------------------------------------------
      6 # 公開関数と公開関数
      7 
      8 ble/util/autoload "$_ble_base/lib/core-complete.sh" \
      9                   ble/widget/complete \
     10                   ble/widget/menu-complete \
     11                   ble/widget/auto-complete-enter \
     12                   ble/widget/sabbrev-expand \
     13                   ble/widget/dabbrev-expand
     14 
     15 function ble-sabbrev {
     16   # check arguments for printing
     17   local arg print=
     18   for arg; do
     19     if [[ $arg != -* && $arg != *=* ]]; then
     20       print=1
     21       break
     22     fi
     23   done
     24   if (($#==0)) || [[ $print ]]; then
     25     ble-import lib/core-complete && ble-sabbrev "$@"
     26     return "$?"
     27   fi
     28 
     29   local ret; ble/string#quote-command "$FUNCNAME" "$@"
     30   blehook/eval-after-load complete "$ret"
     31 }
     32 
     33 if ! declare -p _ble_complete_sabbrev_wordwise &>/dev/null; then # reload #D0875
     34   builtin eval -- "${_ble_util_gdict_declare//NAME/_ble_complete_sabbrev_wordwise}"
     35 fi
     36 
     37 declare -p _ble_complete_sabbrev_literal &>/dev/null ||
     38   builtin eval -- "${_ble_util_gdict_declare//NAME/_ble_complete_sabbrev_literal}"
     39 
     40 #------------------------------------------------------------------------------
     41 # 設定変数
     42 
     43 bleopt/declare -n complete_polling_cycle 50
     44 bleopt/declare -o complete_stdin_frequency complete_polling_cycle
     45 
     46 bleopt/declare -v complete_limit ''
     47 bleopt/declare -v complete_limit_auto 2000
     48 bleopt/declare -v complete_limit_auto_menu 100
     49 bleopt/declare -v complete_timeout_auto 5000
     50 bleopt/declare -v complete_timeout_compvar 200
     51 
     52 bleopt/declare -v complete_ambiguous 1
     53 bleopt/declare -v complete_contract_function_names 1
     54 bleopt/declare -v complete_auto_complete 1
     55 bleopt/declare -v complete_auto_complete_opts ''
     56 bleopt/declare -v complete_auto_history 1
     57 bleopt/declare -n complete_auto_delay 1
     58 bleopt/declare -v complete_auto_wordbreaks "$_ble_term_IFS"
     59 bleopt/declare -v complete_auto_menu ''
     60 bleopt/declare -v complete_allow_reduction ''
     61 bleopt/declare -v complete_requote_threshold 0
     62 
     63 ## @bleopt complete_menu_style
     64 ##   補完候補のリスト表示のスタイルを指定します。
     65 ##
     66 ##   dense, dense-nowrap, align, align-nowrap
     67 ##   desc, desc-text
     68 ##
     69 bleopt/declare -n complete_menu_style align-nowrap
     70 function bleopt/check:complete_menu_style {
     71   [[ $value == desc-raw ]] && value=desc
     72   if ! ble/is-function "ble/complete/menu-style:$value/construct-page"; then
     73     ble/util/print-lines \
     74       "bleopt: Invalid value complete_menu_style='$value'." \
     75       "  A function 'ble/complete/menu-style:$value/construct-page' is not defined." >&2
     76     return 1
     77   fi
     78   return 0
     79 }
     80 
     81 ble/util/autoload "$_ble_base/lib/core-complete.sh" \
     82                   ble/complete/menu-style:{align,dense}{,-nowrap}/construct-page \
     83                   ble/complete/menu-style:linewise/construct-page \
     84                   ble/complete/menu-style:desc{,-raw}/construct-page
     85 
     86 bleopt/declare -v complete_menu_complete 1
     87 bleopt/declare -v complete_menu_complete_opts 'insert-selection'
     88 bleopt/declare -v complete_menu_filter 1
     89 bleopt/declare -v complete_menu_maxlines '-1'
     90 
     91 bleopt/declare -v complete_skip_matched     on
     92 bleopt/declare -v complete_menu_color       on
     93 bleopt/declare -v complete_menu_color_match on
     94 function ble/complete/.init-bind-readline-variables {
     95   local _ble_local_rlvars; ble/util/rlvar#load
     96   ble/util/rlvar#bind-bleopt skip-completed-text       complete_skip_matched     bool
     97   ble/util/rlvar#bind-bleopt colored-stats             complete_menu_color       bool
     98   ble/util/rlvar#bind-bleopt colored-completion-prefix complete_menu_color_match bool
     99   builtin unset -f "$FUNCNAME"
    100 }
    101 ble/complete/.init-bind-readline-variables
    102 
    103 bleopt/declare -v menu_prefix ''
    104 bleopt/declare -v menu_align_prefix ''
    105 bleopt/declare -n menu_align_min 4
    106 bleopt/declare -n menu_align_max 20
    107 bleopt/declare -o complete_menu_align menu_align_max
    108 bleopt/declare -v menu_dense_prefix ''
    109 bleopt/declare -v menu_linewise_prefix ''
    110 bleopt/declare -v menu_desc_prefix ''
    111 bleopt/declare -v menu_desc_multicolumn_width 65
    112 
    113 ble/util/autoload "$_ble_base/lib/core-complete.sh" \
    114                   ble/complete/menu#start \
    115                   ble-decode/keymap:menu/define \
    116                   ble-decode/keymap:auto_complete/define \
    117                   ble-decode/keymap:menu_complete/define \
    118                   ble-decode/keymap:dabbrev/define \
    119                   ble/complete/sabbrev/expand \
    120                   ble/complete/alias/expand
    121 
    122 bleopt/declare -v complete_source_sabbrev_opts ''
    123 bleopt/declare -v complete_source_sabbrev_ignore ''
    124 
    125 _ble_complete_source_sabbrev_ignore=()
    126 function bleopt/check:complete_source_sabbrev_ignore {
    127   if [[ $value ]]; then
    128     ble/string#split _ble_complete_source_sabbrev_ignore : "$value"
    129   else
    130     _ble_complete_source_sabbrev_ignore=()
    131   fi
    132 }
    133 
    134 #------------------------------------------------------------------------------
    135 # 描画設定
    136 
    137 ble/color/defface auto_complete bg=254,fg=238
    138 ble/color/defface cmdinfo_cd_cdpath fg=26,bg=155
    139 
    140 # ble/color/defface menu_filter_fixed bg=247,bold
    141 # ble/color/defface menu_filter_input bg=147,bold
    142 ble/color/defface menu_filter_fixed bold
    143 ble/color/defface menu_filter_input fg=16,bg=229