core-syntax-def.sh (7987B)
1 # -*- mode: sh; mode: sh-bash -*- 2 3 # 本体は lib/core-syntax.sh にある。遅延読み込みする。 4 5 #------------------------------------------------------------------------------ 6 # 公開変数 7 8 # exported variables 9 _ble_syntax_VARNAMES=( 10 _ble_syntax_text 11 _ble_syntax_lang 12 _ble_syntax_stat 13 _ble_syntax_nest 14 _ble_syntax_tree 15 _ble_syntax_attr 16 _ble_syntax_attr_umin 17 _ble_syntax_attr_umax 18 _ble_syntax_word_umin 19 _ble_syntax_word_umax 20 _ble_syntax_vanishing_word_umin 21 _ble_syntax_vanishing_word_umax 22 _ble_syntax_dbeg 23 _ble_syntax_dend) 24 _ble_syntax_lang=bash 25 26 function ble/syntax/initialize-vars { 27 _ble_syntax_text= 28 _ble_syntax_lang=bash 29 _ble_syntax_stat=() 30 _ble_syntax_nest=() 31 _ble_syntax_tree=() 32 _ble_syntax_attr=() 33 34 _ble_syntax_attr_umin=-1 _ble_syntax_attr_umax=-1 35 _ble_syntax_word_umin=-1 _ble_syntax_word_umax=-1 36 _ble_syntax_vanishing_word_umin=-1 37 _ble_syntax_vanishing_word_umax=-1 38 _ble_syntax_dbeg=-1 _ble_syntax_dend=-1 39 } 40 41 #------------------------------------------------------------------------------ 42 # 公開関数 43 44 # 関数 ble/syntax/parse は実際に import されるまで定義しない 45 46 # 関数 ble/highlight/layer:syntax/* は import されるまではダミーの実装にする 47 48 ## @fn ble/highlight/layer:syntax/update (暫定) 49 ## PREV_BUFF, PREV_UMIN, PREV_UMAX を変更せずにそのまま戻れば良い。 50 function ble/highlight/layer:syntax/update { true; } 51 ## @fn ble/highlight/layer:region/getg (暫定) 52 ## g を設定せず戻ればそのまま上のレイヤーに問い合わせが行く。 53 function ble/highlight/layer:syntax/getg { true; } 54 55 56 ## @fn ble/syntax:bash/is-complete 57 ## sytax がロードされる迄は常に真値。 58 function ble/syntax:bash/is-complete { true; } 59 60 61 # 以下の関数に関しては遅延せずにその場で lib/core-syntax.sh をロードする 62 ble/util/autoload "$_ble_base/lib/core-syntax.sh" \ 63 ble/syntax/parse \ 64 ble/syntax/highlight \ 65 ble/syntax/tree-enumerate \ 66 ble/syntax/tree-enumerate-children \ 67 ble/syntax/completion-context/generate \ 68 ble/syntax/highlight/cmdtype \ 69 ble/syntax/highlight/cmdtype1 \ 70 ble/syntax/highlight/filetype \ 71 ble/syntax/highlight/getg-from-filename \ 72 ble/syntax:bash/extract-command \ 73 ble/syntax:bash/simple-word/eval \ 74 ble/syntax:bash/simple-word/evaluate-path-spec \ 75 ble/syntax:bash/simple-word/is-never-word \ 76 ble/syntax:bash/simple-word/is-simple \ 77 ble/syntax:bash/simple-word/is-simple-or-open-simple \ 78 ble/syntax:bash/simple-word/reconstruct-incomplete-word \ 79 ble/syntax:bash/simple-word/get-rex_element 80 81 #------------------------------------------------------------------------------ 82 # グローバル変数の定義 (関数内からではできないのでここで先に定義) 83 84 bleopt/declare -v syntax_debug '' 85 86 bleopt/declare -v filename_ls_colors '' 87 88 bleopt/declare -v highlight_syntax 1 89 bleopt/declare -v highlight_filename 1 90 bleopt/declare -v highlight_variable 1 91 bleopt/declare -v highlight_timeout_sync 50 92 bleopt/declare -v highlight_timeout_async 5000 93 bleopt/declare -v syntax_eval_polling_interval 50 94 95 builtin eval -- "${_ble_util_gdict_declare//NAME/_ble_syntax_highlight_filetype}" 96 builtin eval -- "${_ble_util_gdict_declare//NAME/_ble_syntax_highlight_lscolors_ext}" 97 builtin eval -- "${_ble_util_gdict_declare//NAME/_ble_syntax_bash_simple_eval}" 98 builtin eval -- "${_ble_util_gdict_declare//NAME/_ble_syntax_bash_simple_eval_full}" 99 100 #------------------------------------------------------------------------------ 101 # face の定義 102 # 103 # プロンプトで face を参照していると最初のプロンプト表示時に initialize-faces 104 # が実行され、ユーザーが blerc に設定した setface も実行される。この時点では 105 # core-syntax.sh は未だ読み込まれていないので、face の定義が core-syntax.sh の 106 # 中にあると face が見つからないエラーになる。 107 108 function ble/syntax/attr2g { ble/color/initialize-faces && ble/syntax/attr2g "$@"; } 109 110 function ble/syntax/defface.onload { 111 function ble/syntax/attr2g { 112 local iface=${_ble_syntax_attr2iface[$1]:-_ble_faces__syntax_default} 113 g=${_ble_faces[iface]} 114 } 115 116 # Note: navy was replaced by 26 for dark background 117 # Note: gray was replaced by 242 for dark background 118 119 ble/color/defface syntax_default none 120 ble/color/defface syntax_command fg=brown 121 ble/color/defface syntax_quoted fg=green 122 ble/color/defface syntax_quotation fg=green,bold 123 ble/color/defface syntax_escape fg=magenta 124 ble/color/defface syntax_expr fg=26 125 ble/color/defface syntax_error bg=203,fg=231 # bg=224 126 ble/color/defface syntax_varname fg=202 127 ble/color/defface syntax_delimiter bold 128 ble/color/defface syntax_param_expansion fg=purple 129 ble/color/defface syntax_history_expansion bg=94,fg=231 130 ble/color/defface syntax_function_name fg=92,bold # fg=purple 131 ble/color/defface syntax_comment fg=242 132 ble/color/defface syntax_glob fg=198,bold 133 ble/color/defface syntax_brace fg=37,bold 134 ble/color/defface syntax_tilde fg=navy,bold 135 ble/color/defface syntax_document fg=94 136 ble/color/defface syntax_document_begin fg=94,bold 137 138 ble/color/defface command_builtin_dot fg=red,bold 139 ble/color/defface command_builtin fg=red 140 ble/color/defface command_alias fg=teal 141 ble/color/defface command_function fg=92 # fg=purple 142 ble/color/defface command_file fg=green 143 ble/color/defface command_keyword fg=blue 144 ble/color/defface command_jobs fg=red,bold 145 ble/color/defface command_directory fg=26,underline 146 ble/color/defface filename_directory underline,fg=26 147 ble/color/defface filename_directory_sticky underline,fg=white,bg=26 148 ble/color/defface filename_link underline,fg=teal 149 ble/color/defface filename_orphan underline,fg=teal,bg=224 150 ble/color/defface filename_setuid underline,fg=black,bg=220 151 ble/color/defface filename_setgid underline,fg=black,bg=191 152 ble/color/defface filename_executable underline,fg=green 153 ble/color/defface filename_other underline 154 ble/color/defface filename_socket underline,fg=cyan,bg=black 155 ble/color/defface filename_pipe underline,fg=lime,bg=black 156 ble/color/defface filename_character underline,fg=white,bg=black 157 ble/color/defface filename_block underline,fg=yellow,bg=black 158 ble/color/defface filename_warning underline,fg=red 159 ble/color/defface filename_url underline,fg=blue 160 ble/color/defface filename_ls_colors underline 161 ble/color/defface varname_unset fg=124 162 ble/color/defface varname_empty fg=31 163 ble/color/defface varname_number fg=64 164 ble/color/defface varname_expr fg=92,bold 165 ble/color/defface varname_array fg=orange,bold 166 ble/color/defface varname_hash fg=70,bold 167 ble/color/defface varname_readonly fg=200 168 ble/color/defface varname_transform fg=29,bold 169 ble/color/defface varname_export fg=200,bold 170 ble/color/defface argument_option fg=teal 171 ble/color/defface argument_error fg=black,bg=225 172 } 173 blehook/eval-after-load color_defface ble/syntax/defface.onload 174 175 #------------------------------------------------------------------------------ 176 # 遅延読み込みの設定 177 178 # lib/core-syntax.sh の変数または ble/syntax/parse を使用する必要がある場合は、 179 # 以下の関数を用いて lib/core-syntax.sh を必ずロードする様にする。 180 function ble/syntax/import { 181 ble/util/import "$_ble_base/lib/core-syntax.sh" 182 } 183 184 # Note: 初期化順序の都合で一番最後に実行する。lib/core-syntax 内で登録 185 # している ble/syntax/attr2iface/color_defface.onload は、上記で登録し 186 # ている ble/syntax/defface.onload よりも後に実行する必要がある為。 187 ble-import -d lib/core-syntax