diff --git a/.local/share/blesh/ble.sh b/.local/share/blesh/ble.sh new file mode 100644 index 0000000..ad85567 --- /dev/null +++ b/.local/share/blesh/ble.sh @@ -0,0 +1,28187 @@ +# Copyright 2015 Koichi Murase . All rights reserved. +# This script is a part of blesh (https://github.com/akinomyoga/ble.sh) +# provided under the BSD-3-Clause license. Do not edit this file because this +# is not the original source code: Various pre-processing has been applied. +# Also, the code comments and blank lines are stripped off in the installation +# process. Please find the corresponding source file(s) in the repository +# "akinomyoga/ble.sh". +# +# Source: /ble.pp +# Source: /src/benchmark.sh +# Source: /src/canvas.GraphemeClusterBreak.sh +# Source: /src/canvas.c2w.musl.sh +# Source: /src/canvas.c2w.sh +# Source: /src/canvas.emoji.sh +# Source: /src/canvas.sh +# Source: /src/color.sh +# Source: /src/decode.sh +# Source: /src/def.sh +# Source: /src/edit.sh +# Source: /src/history.sh +# Source: /src/util.hook.sh +# Source: /src/util.sh +{ + _ble_init_version=0.4.0-nightly+75c4a84 + _ble_init_exit= + _ble_init_command= + for _ble_init_arg; do + case $_ble_init_arg in + --version) + _ble_init_exit=0 + echo "ble.sh (Bash Line Editor), version $_ble_init_version" ;; + --help) + _ble_init_exit=0 + printf '%s\n' \ + "# ble.sh (Bash Line Editor), version $_ble_init_version" \ + 'usage: source ble.sh [OPTION...]' \ + '' \ + 'OPTION' \ + '' \ + ' --help' \ + ' Show this help and exit' \ + ' --version' \ + ' Show version and exit' \ + ' --test' \ + ' Run test and exit' \ + ' --update' \ + ' Update ble.sh and exit' \ + ' --clear-cache' \ + ' Clear ble.sh cache and exit' \ + ' --install PREFIX' \ + ' Install ble.sh and exit' \ + '' \ + ' --rcfile=BLERC' \ + ' --init-file=BLERC' \ + ' Specify the ble init file. The default is ~/.blerc if any, or' \ + ' ~/.config/blesh/init.sh.' \ + '' \ + ' --norc' \ + ' Do not load the ble init file.' \ + '' \ + ' --attach=ATTACH' \ + ' --noattach' \ + ' The option "--attach" selects the strategy of "ble-attach" from the list:' \ + ' ATTACH = "attach" | "prompt" | "none". The default strategy is "prompt".' \ + ' When "attach" is specified, ble.sh immediately attaches to the session in' \ + ' "source ble.sh". When "prompt" is specified, ble.sh attaches to the' \ + ' session before the first prompt using PROMPT_COMMAND. When "none" is' \ + ' specified, ble.sh does not attach to the session automatically, so' \ + ' ble-attach needs to be called explicitly. The option "--noattach" is a' \ + ' synonym for "--attach=none".' \ + '' \ + ' --inputrc=TYPE' \ + ' --noinputrc' \ + ' The option "--inputrc" selects the strategy of reconstructing user' \ + ' keybindings from the list: "auto" (default), "diff", "all", "user", "none".' \ + ' When "diff" is specified, user keybindings are extracted by the diff of the' \ + ' outputs of the "bind" builtin between the current session and the plain' \ + ' Bash. When "all" is specified, the user keybindings are extracted from' \ + ' /etc/inputrc and ${INPUTRC:-~/.inputrc*}. When "user" is specified, the' \ + ' user keybindings are extracted from ${INPUTRC:-~/.inputrc*}. When "none"' \ + ' is specified, the user keybindings are not reconstructed from the state of' \ + ' Readline, and only the bindings by "ble-bind" are applied. The option' \ + ' "--noinputrc" is a synonym for "--inputrc=none".' \ + '' \ + ' --keep-rlvars' \ + ' Do not change readline settings for ble.sh' \ + '' \ + ' --bash-debug-version=TYPE' \ + ' This controls the warning mesage for the debug version of Bash. When' \ + ' "full" is specified to TYPE, ble.sh prints the full message to the terminal' \ + ' when it is loaded in a debug version of Bash. This is the default. When' \ + ' "short" is specified, a short version of the message is printed. When' \ + ' "once" is specified, the full message is printed only once for a specific' \ + ' version of debug Bash. When "ignore" is specified, the message is not' \ + ' printed even when ble.sh is loaded in a debug version of Bash.' \ + '' \ + ' -o BLEOPT=VALUE' \ + ' Set a value for the specified bleopt option.' \ + ' --debug-bash-output' \ + ' Internal settings for debugging' \ + '' ;; + --test | --update | --clear-cache | --lib | --install) _ble_init_command=1 ;; + esac + done + unset _ble_init_arg + if [ -n "$_ble_init_exit" ]; then + unset _ble_init_exit + unset _ble_init_command + unset _ble_init_version + return 0 2>/dev/null || exit 0 + fi +} 2>/dev/null # set -x 対策 #D0930 +if [ -z "${BASH_VERSION-}" ]; then + echo "ble.sh: This shell is not Bash. Please use this script with Bash." >&3 + unset _ble_init_exit + unset _ble_init_command + unset _ble_init_version + return 1 2>/dev/null || exit 1 +fi 3>&2 >/dev/null 2>&1 # set -x 対策 #D0930 +if [ -z "${BASH_VERSINFO-}" ] || [ "${BASH_VERSINFO-0}" -lt 3 ]; then + echo "ble.sh: Bash with a version under 3.0 is not supported." >&3 + unset -v _ble_init_exit _ble_init_command _ble_init_version + return 1 2>/dev/null || exit 1 +fi 3>&2 >/dev/null 2>&1 # set -x 対策 #D0930 +if [[ ! $_ble_init_command ]]; then + if [[ ${BASH_EXECUTION_STRING+set} ]]; then + _ble_init_exit=1 + elif ((BASH_SUBSHELL)); then + builtin echo "ble.sh: ble.sh cannot be loaded into a subshell." >&3 + _ble_init_exit=1 + elif [[ $- != *i* ]]; then + case " ${BASH_SOURCE[*]##*/} " in + (*' .bashrc '* | *' .bash_profile '* | *' .profile '* | *' bashrc '* | *' profile '*) ((0)) ;; + esac && + builtin echo "ble.sh: This is not an interactive session." >&3 || ((1)) + _ble_init_exit=1 + elif ! [[ -t 4 && -t 5 ]] && ! { [[ ${bleopt_connect_tty-} ]] && >/dev/tty; }; then + if [[ ${bleopt_connect_tty-} ]]; then + builtin echo "ble.sh: cannot find a controlling TTY/PTY in this session." >&3 + else + builtin echo "ble.sh: stdout/stdin are not connected to TTY/PTY." >&3 + fi + _ble_init_exit=1 + elif [[ ${NRF_CONNECT_VSCODE-} && ! -t 3 ]]; then + _ble_init_exit=1 + fi + if [[ $_ble_init_exit ]]; then + builtin unset -v _ble_init_exit _ble_init_command _ble_init_version + return 1 2>/dev/null || builtin exit 1 + fi +fi 3>&2 4<&0 5>&1 &>/dev/null # set -x 対策 #D0930 +{ + _ble_bash=$((BASH_VERSINFO[0]*10000+BASH_VERSINFO[1]*100+BASH_VERSINFO[2])) + _ble_bash_POSIXLY_CORRECT_adjusted=1 + _ble_bash_POSIXLY_CORRECT_set=${POSIXLY_CORRECT+set} + _ble_bash_POSIXLY_CORRECT=${POSIXLY_CORRECT-} + POSIXLY_CORRECT=y + _ble_bash_expand_aliases= + \shopt -q expand_aliases && + _ble_bash_expand_aliases=1 && + \shopt -u expand_aliases || ((1)) + _ble_bash_FUNCNEST_adjusted= + _ble_bash_FUNCNEST= + _ble_bash_FUNCNEST_set= + _ble_bash_FUNCNEST_adjust=' + if [[ ! $_ble_bash_FUNCNEST_adjusted ]]; then + _ble_bash_FUNCNEST_adjusted=1 + _ble_bash_FUNCNEST_set=${FUNCNEST+set} + _ble_bash_FUNCNEST=${FUNCNEST-} + \builtin unset -v FUNCNEST + fi 2>/dev/null' + _ble_bash_FUNCNEST_restore=' + if [[ $_ble_bash_FUNCNEST_adjusted ]]; then + _ble_bash_FUNCNEST_adjusted= + if [[ $_ble_bash_FUNCNEST_set ]]; then + FUNCNEST=$_ble_bash_FUNCNEST + else + \builtin unset -v FUNCNEST + fi + fi 2>/dev/null' + \builtin eval -- "$_ble_bash_FUNCNEST_adjust" + \builtin unset -v POSIXLY_CORRECT + _ble_bash_POSIXLY_CORRECT_adjust=' + if [[ ! ${_ble_bash_POSIXLY_CORRECT_adjusted-} ]]; then + _ble_bash_POSIXLY_CORRECT_adjusted=1 + _ble_bash_POSIXLY_CORRECT_set=${POSIXLY_CORRECT+set} + _ble_bash_POSIXLY_CORRECT=${POSIXLY_CORRECT-} + if [[ $_ble_bash_POSIXLY_CORRECT_set ]]; then + \builtin unset -v POSIXLY_CORRECT + fi + ble/base/workaround-POSIXLY_CORRECT + fi' + _ble_bash_POSIXLY_CORRECT_unset=' + if [[ ${POSIXLY_CORRECT+set} ]]; then + \builtin unset -v POSIXLY_CORRECT + ble/base/workaround-POSIXLY_CORRECT + fi' + _ble_bash_POSIXLY_CORRECT_local_adjust=' + \builtin local _ble_local_POSIXLY_CORRECT _ble_local_POSIXLY_CORRECT_set + _ble_local_POSIXLY_CORRECT_set=${POSIXLY_CORRECT+set} + _ble_local_POSIXLY_CORRECT=${POSIXLY_CORRECT-} + '$_ble_bash_POSIXLY_CORRECT_unset + _ble_bash_POSIXLY_CORRECT_local_leave=' + if [[ $_ble_local_POSIXLY_CORRECT_set ]]; then + POSIXLY_CORRECT=$_ble_local_POSIXLY_CORRECT + fi' + _ble_bash_POSIXLY_CORRECT_local_enter=' + _ble_local_POSIXLY_CORRECT_set=${POSIXLY_CORRECT+set} + _ble_local_POSIXLY_CORRECT=${POSIXLY_CORRECT-} + '$_ble_bash_POSIXLY_CORRECT_unset + _ble_bash_POSIXLY_CORRECT_local_return=' + \builtin local _ble_local_POSIXLY_CORRECT_ext=$? + if [[ $_ble_local_POSIXLY_CORRECT_set ]]; then + POSIXLY_CORRECT=$_ble_local_POSIXLY_CORRECT + fi + \return "$_ble_local_POSIXLY_CORRECT_ext"' +} 2>/dev/null +function ble/base/workaround-POSIXLY_CORRECT { + true +} +function ble/base/restore-POSIXLY_CORRECT { + if [[ ! $_ble_bash_POSIXLY_CORRECT_adjusted ]]; then return 0; fi # Note: set -e の為 || は駄目 + _ble_bash_POSIXLY_CORRECT_adjusted= + if [[ $_ble_bash_POSIXLY_CORRECT_set ]]; then + POSIXLY_CORRECT=$_ble_bash_POSIXLY_CORRECT + else + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_unset" + fi +} +function ble/base/is-POSIXLY_CORRECT { + [[ $_ble_bash_POSIXLY_CORRECT_adjusted && $_ble_bash_POSIXLY_CORRECT_set ]] +} +if ((_ble_bash>=40100)); then + function ble/base/list-shopt { shopt=$BASHOPTS; } +else + function ble/base/list-shopt { + shopt= + local name + for name; do + shopt -q "$name" 2>/dev/null && shopt=$shopt:$name + done + } +fi 2>/dev/null # set -x 対策 +function ble/base/evaldef { + local shopt + ble/base/list-shopt extglob expand_aliases + shopt -s extglob + shopt -u expand_aliases + builtin eval -- "$1"; local ext=$? + [[ :$shopt: == *:extglob:* ]] || shopt -u extglob + [[ :$shopt: != *:expand_aliases:* ]] || shopt -s expand_aliases + return "$ext" +} +{ + _ble_bash_builtins_adjusted= + _ble_bash_builtins_save= +} 2>/dev/null # set -x 対策 +function ble/base/adjust-builtin-wrappers/.assign { + if [[ ${_ble_util_assign_base-} ]]; then + local _ble_local_tmpfile; ble/util/assign/mktmp + builtin eval -- "$1" >| "$_ble_local_tmpfile" + local IFS= + ble/bash/read -d '' defs < "$_ble_local_tmpfile" + IFS=$_ble_term_IFS + ble/util/assign/rmtmp + else + defs=$(builtin eval -- "$1") + fi || ((1)) +} +function ble/base/adjust-builtin-wrappers/.impl1 { + unset -f builtin + builtin local builtins1 keywords1 + builtins1=(builtin unset enable unalias return break continue declare local typeset eval exec set) + keywords1=(if then elif else case esac while until for select do done '{' '}' '[[' function) + if [[ ! $_ble_bash_builtins_adjusted ]]; then + _ble_bash_builtins_adjusted=1 + builtin local defs + ble/base/adjust-builtin-wrappers/.assign ' + \builtin declare -f "${builtins1[@]}" || ((1)) + \builtin alias "${builtins1[@]}" "${keywords1[@]}" || ((1))' # set -e 対策 + _ble_bash_builtins_save=$defs + fi + builtin local POSIXLY_CORRECT=y + builtin unset -f "${builtins1[@]}" + builtin unalias "${builtins1[@]}" "${keywords1[@]}" || ((1)) # set -e 対策 + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_unset" +} +function ble/base/adjust-builtin-wrappers/.impl2 { + local defs + ble/base/adjust-builtin-wrappers/.assign 'LC_ALL= LC_MESSAGES=C builtin type :; alias :' || ((1)) # set -e 対策 + defs=${defs#$': is a shell builtin\n'} + _ble_bash_builtins_save=$_ble_bash_builtins_save$'\n'$defs + builtin unset -f : + builtin unalias : || ((1)) # set -e 対策 +} +function ble/base/adjust-builtin-wrappers { + ble/base/adjust-builtin-wrappers/.impl1 + builtin unset -v POSIXLY_CORRECT + ble/base/adjust-builtin-wrappers/.impl2 +} 2>/dev/null +function ble/base/restore-builtin-wrappers { + if [[ $_ble_bash_builtins_adjusted ]]; then + _ble_bash_builtins_adjusted= + ble/base/evaldef "$_ble_bash_builtins_save" + return 0 + fi +} +{ + ble/base/adjust-builtin-wrappers + if [[ $_ble_bash_expand_aliases ]]; then + shopt -s expand_aliases + fi +} 2>/dev/null # set -x 対策 +function ble/variable#copy-state { + local src=$1 dst=$2 + if [[ ${!src+set} ]]; then + builtin eval -- "$dst=\${$src}" + else + builtin unset -v "$dst[0]" 2>/dev/null || builtin unset -v "$dst" + fi +} +{ + _ble_bash_xtrace=() + _ble_bash_xtrace_debug_enabled= + _ble_bash_xtrace_debug_filename= + _ble_bash_xtrace_debug_fd= + _ble_bash_XTRACEFD= + _ble_bash_XTRACEFD_set= + _ble_bash_XTRACEFD_dup= + _ble_bash_PS4= +} 2>/dev/null # set -x 対策 +function ble/base/xtrace/.fdcheck { >&"$1"; } 2>/dev/null +function ble/base/xtrace/.fdnext { + local _ble_local_init=${_ble_util_openat_nextfd:=${bleopt_openat_base:-30}} + for (($1=_ble_local_init;$1<_ble_local_init+1024;$1++)); do + ble/base/xtrace/.fdcheck "${!1}" || break + done + (($1<_ble_local_init+1024)) || + { (($1=_ble_local_init,_ble_util_openat_nextfd++)); builtin eval "exec ${!1}>&-"; } || + ((1)) +} +function ble/base/xtrace/.log { + local open=---- close=---- + if ((_ble_bash>=40200)); then + builtin printf '%s [%(%F %T %Z)T] %s %s\n' "$open" -1 "$1" "$close" + else + builtin printf '%s [%s] %s %s\n' "$open" "$(date 2>/dev/null)" "$1" "$close" + fi >&"${BASH_XTRACEFD:-2}" +} +function ble/base/xtrace/adjust { + local level=${#_ble_bash_xtrace[@]} IFS=$' \t\n' + if [[ $- == *x* ]]; then + _ble_bash_xtrace[level]=1 + else + _ble_bash_xtrace[level]= + fi + set +x + ((_ble_bash>=40000&&level==0)) || return 0 + _ble_bash_xtrace_debug_enabled= + if [[ ${bleopt_debug_xtrace:-/dev/null} == /dev/null ]]; then + if [[ $_ble_bash_xtrace_debug_fd ]]; then + builtin eval "exec $_ble_bash_xtrace_debug_fd>&-" || return 0 # disable=#D2164 (here bash4+) + _ble_bash_xtrace_debug_filename= + _ble_bash_xtrace_debug_fd= + fi + else + if [[ $_ble_bash_xtrace_debug_filename != "$bleopt_debug_xtrace" ]]; then + _ble_bash_xtrace_debug_filename=$bleopt_debug_xtrace + [[ $_ble_bash_xtrace_debug_fd ]] || ble/base/xtrace/.fdnext _ble_bash_xtrace_debug_fd + builtin eval "exec $_ble_bash_xtrace_debug_fd>>\"$bleopt_debug_xtrace\"" || return 0 + fi + _ble_bash_XTRACEFD=${BASH_XTRACEFD-} + _ble_bash_XTRACEFD_set=${BASH_XTRACEFD+set} + if [[ ${BASH_XTRACEFD-} =~ ^[0-9]+$ ]] && ble/base/xtrace/.fdcheck "$BASH_XTRACEFD"; then + ble/base/xtrace/.fdnext _ble_bash_XTRACEFD_dup + builtin eval "exec $_ble_bash_XTRACEFD_dup>&$BASH_XTRACEFD" || return 0 + builtin eval "exec $BASH_XTRACEFD>&$_ble_bash_xtrace_debug_fd" || return 0 + else + _ble_bash_XTRACEFD_dup= + local newfd; ble/base/xtrace/.fdnext newfd + builtin eval "exec $newfd>&$_ble_bash_xtrace_debug_fd" || return 0 + BASH_XTRACEFD=$newfd + fi + ble/variable#copy-state PS4 _ble_base_PS4 + PS4=${bleopt_debug_xtrace_ps4:-'+ '} + _ble_bash_xtrace_debug_enabled=1 + ble/base/xtrace/.log "$FUNCNAME" + set -x + fi +} +function ble/base/xtrace/restore { + local level=$((${#_ble_bash_xtrace[@]}-1)) IFS=$' \t\n' + ((level>=0)) || return 0 + if [[ ${_ble_bash_xtrace[level]-} ]]; then + set -x + else + set +x + fi + builtin unset -v '_ble_bash_xtrace[level]' + ((_ble_bash>=40000&&level==0)) || return 0 + if [[ $_ble_bash_xtrace_debug_enabled ]]; then + ble/base/xtrace/.log "$FUNCNAME" + _ble_bash_xtrace_debug_enabled= + ble/variable#copy-state _ble_base_PS4 PS4 + if [[ $_ble_bash_XTRACEFD_dup ]]; then + builtin eval "exec $BASH_XTRACEFD>&$_ble_bash_XTRACEFD_dup" && + builtin eval "exec $_ble_bash_XTRACEFD_dup>&-" || ((1)) # disable=#D2164 (here bash4+) + else + if [[ $_ble_bash_XTRACEFD_set ]]; then + BASH_XTRACEFD=$_ble_bash_XTRACEFD + else + builtin unset -v BASH_XTRACEFD + fi + fi + fi +} +function ble/base/.adjust-bash-options { + builtin eval -- "$1=\$-" + set +evukT -B + ble/base/xtrace/adjust + [[ $2 == shopt ]] || local shopt + ble/base/list-shopt extdebug nocasematch + [[ $2 == shopt ]] || builtin eval -- "$2=\$shopt" + shopt -u extdebug + shopt -u nocasematch 2>/dev/null + return 0 +} 2>/dev/null # set -x 対策 +function ble/base/.restore-bash-options { + local set=${!1} shopt=${!2} + [[ :$shopt: == *:nocasematch:* ]] && shopt -s nocasematch + [[ :$shopt: == *:extdebug:* ]] && shopt -s extdebug + ble/base/xtrace/restore + [[ $set == *B* ]] || set +B + [[ $set == *T* ]] && set -T + [[ $set == *k* ]] && set -k + [[ $set == *u* ]] && set -u + [[ $set == *v* ]] && set -v + [[ $set == *e* ]] && set -e # set -e は最後 + return 0 +} 2>/dev/null # set -x 対策 +{ + : "${_ble_bash_options_adjusted=}" + _ble_bash_set=$- + _ble_bash_shopt=${BASHOPTS-} +} 2>/dev/null # set -x 対策 +function ble/base/adjust-bash-options { + [[ $_ble_bash_options_adjusted ]] && return 1 || ((1)) # set -e 対策 + _ble_bash_options_adjusted=1 + ble/base/.adjust-bash-options _ble_bash_set _ble_bash_shopt + _ble_bash_expand_aliases= + shopt -q expand_aliases 2>/dev/null && + _ble_bash_expand_aliases=1 + ble/variable#copy-state LC_ALL _ble_bash_LC_ALL + if [[ ${LC_ALL-} ]]; then + ble/variable#copy-state LC_CTYPE _ble_bash_LC_CTYPE + ble/variable#copy-state LC_MESSAGES _ble_bash_LC_MESSAGES + ble/variable#copy-state LC_NUMERIC _ble_bash_LC_NUMERIC + ble/variable#copy-state LC_TIME _ble_bash_LC_TIME + ble/variable#copy-state LANG _ble_bash_LANG + [[ ${LC_CTYPE-} ]] && LC_CTYPE=$LC_ALL + [[ ${LC_MESSAGES-} ]] && LC_MESSAGES=$LC_ALL + [[ ${LC_NUMERIC-} ]] && LC_NUMERIC=$LC_ALL + [[ ${LC_TIME-} ]] && LC_TIME=$LC_ALL + LANG=$LC_ALL + LC_ALL= + fi + ble/variable#copy-state LC_COLLATE _ble_bash_LC_COLLATE + LC_COLLATE=C + if local TMOUT= 2>/dev/null; then # #D1630 WA + _ble_bash_tmout_wa=() + else + _ble_bash_tmout_wa=(-t 2147483647) + fi +} 2>/dev/null # set -x 対策 #D0930 / locale 変更 +function ble/base/restore-bash-options { + [[ $_ble_bash_options_adjusted ]] || return 1 + _ble_bash_options_adjusted= + ble/variable#copy-state _ble_bash_LC_COLLATE LC_COLLATE + if [[ $_ble_bash_LC_ALL ]]; then + ble/variable#copy-state _ble_bash_LC_CTYPE LC_CTYPE + ble/variable#copy-state _ble_bash_LC_MESSAGES LC_MESSAGES + ble/variable#copy-state _ble_bash_LC_NUMERIC LC_NUMERIC + ble/variable#copy-state _ble_bash_LC_TIME LC_TIME + ble/variable#copy-state _ble_bash_LANG LANG + fi + ble/variable#copy-state _ble_bash_LC_ALL LC_ALL + [[ $_ble_bash_nocasematch ]] && shopt -s nocasematch + ble/base/.restore-bash-options _ble_bash_set _ble_bash_shopt +} 2>/dev/null # set -x 対策 #D0930 / locale 変更 +function ble/base/recover-bash-options { + if [[ $_ble_bash_expand_aliases ]]; then + shopt -s expand_aliases + else + shopt -u expand_aliases + fi +} +{ ble/base/adjust-bash-options; } &>/dev/null # set -x 対策 #D0930 +builtin bind &>/dev/null # force to load .inputrc +if [[ $OSTYPE == msys* ]]; then + [[ $(builtin bind -m emacs -p 2>/dev/null | grep '"\\C-?"') == '"\C-?": backward-kill-line' ]] && + builtin bind -m emacs '"\C-?": backward-delete-char' 2>/dev/null +fi +if [[ ! -o emacs && ! -o vi && ! $_ble_init_command ]]; then + builtin echo "ble.sh: ble.sh is not intended to be used with the line-editing mode disabled (--noediting)." >&2 + ble/base/restore-bash-options + ble/base/restore-builtin-wrappers + ble/base/restore-POSIXLY_CORRECT + builtin eval -- "$_ble_bash_FUNCNEST_restore" + builtin unset -v _ble_bash + return 1 2>/dev/null || builtin exit 1 +fi +if shopt -q restricted_shell; then + builtin echo "ble.sh: ble.sh is not intended to be used in restricted shells (--restricted)." >&2 + ble/base/restore-bash-options + ble/base/restore-builtin-wrappers + ble/base/restore-POSIXLY_CORRECT + builtin eval -- "$_ble_bash_FUNCNEST_restore" + builtin unset -v _ble_bash + return 1 2>/dev/null || builtin exit 1 +fi +function ble/init/adjust-IFS { + _ble_init_original_IFS_set=${IFS+set} + _ble_init_original_IFS=$IFS + IFS=$' \t\n' +} +function ble/init/restore-IFS { + if [[ $_ble_init_original_IFS_set ]]; then + IFS=$_ble_init_original_IFS + else + builtin unset -v IFS + fi + builtin unset -v _ble_init_original_IFS_set + builtin unset -v _ble_init_original_IFS +} +if ((_ble_bash>=50100)); then + _ble_bash_BASH_REMATCH_level=0 + _ble_bash_BASH_REMATCH=() + function ble/base/adjust-BASH_REMATCH { + ((_ble_bash_BASH_REMATCH_level++==0)) || return 0 + _ble_bash_BASH_REMATCH=("${BASH_REMATCH[@]}") + } + function ble/base/restore-BASH_REMATCH { + ((_ble_bash_BASH_REMATCH_level>0&& + --_ble_bash_BASH_REMATCH_level==0)) || return 0 + BASH_REMATCH=("${_ble_bash_BASH_REMATCH[@]}") + } +else + _ble_bash_BASH_REMATCH_level=0 + _ble_bash_BASH_REMATCH=() + _ble_bash_BASH_REMATCH_rex=none + function ble/base/adjust-BASH_REMATCH/increase { + local delta=$1 + ((delta)) || return 1 + ((i+=delta)) + if ((delta==1)); then + rex=$rex. + else + rex=$rex.{$delta} + fi + } + function ble/base/adjust-BASH_REMATCH/is-updated { + local i n=${#_ble_bash_BASH_REMATCH[@]} + ((n!=${#BASH_REMATCH[@]})) && return 0 + for ((i=0;i=0)) + } + function ble/base/adjust-BASH_REMATCH { + ((_ble_bash_BASH_REMATCH_level++==0)) || return 0 + ble/base/adjust-BASH_REMATCH/is-updated || return 1 + local size=${#BASH_REMATCH[@]} + if ((size==0)); then + _ble_bash_BASH_REMATCH=() + _ble_bash_BASH_REMATCH_rex=none + return 0 + fi + local rex= i=0 + local text=$BASH_REMATCH sub ret isub + local -a rparens=() + local isub rex i=0 count=0 + for ((isub=1;isub=1)); do + local end=${rparens[count-1]} + if ble/base/adjust-BASH_REMATCH/.find-substr "${text:i:end-i}" "$sub"; then + ble/base/adjust-BASH_REMATCH/increase "$ret" + ((rparens[count++]=i+${#sub})) + rex=$rex'(' + break + else + ble/base/adjust-BASH_REMATCH/increase "$((end-i))" + rex=$rex')' + builtin unset -v 'rparens[--count]' + fi + done + ((count>0)) && continue + if ble/base/adjust-BASH_REMATCH/.find-substr "${text:i}" "$sub"; then + ble/base/adjust-BASH_REMATCH/increase "$ret" + ((rparens[count++]=i+${#sub})) + rex=$rex'(' + else + break # 復元失敗 + fi + done + while ((count>=1)); do + local end=${rparens[count-1]} + ble/base/adjust-BASH_REMATCH/increase "$((end-i))" + rex=$rex')' + builtin unset -v 'rparens[--count]' + done + ble/base/adjust-BASH_REMATCH/increase "$((${#text}-i))" + _ble_bash_BASH_REMATCH=("${BASH_REMATCH[@]}") + _ble_bash_BASH_REMATCH_rex=$rex + } + function ble/base/restore-BASH_REMATCH { + ((_ble_bash_BASH_REMATCH_level>0&& + --_ble_bash_BASH_REMATCH_level==0)) || return 0 + [[ ${_ble_bash_BASH_REMATCH-} =~ $_ble_bash_BASH_REMATCH_rex ]] + } +fi +ble/init/adjust-IFS +ble/base/adjust-BASH_REMATCH +function ble/init/clean-up { + local ext=$? opts=$1 # preserve exit status + builtin unset -v _ble_init_version + builtin unset -v _ble_init_exit + builtin unset -v _ble_init_command + builtin unset -v _ble_init_attached + ble/base/restore-BASH_REMATCH + ble/init/restore-IFS + if [[ :$opts: != *:check-attach:* || ! $_ble_attached ]]; then + ble/base/restore-bash-options + ble/base/restore-POSIXLY_CORRECT + ble/base/restore-builtin-wrappers + builtin eval -- "$_ble_bash_FUNCNEST_restore" + fi + return "$ext" +} +function ble/util/put { builtin printf '%s' "$1"; } +function ble/util/print { builtin printf '%s\n' "$1"; } +function ble/util/print-lines { builtin printf '%s\n' "$@"; } +_ble_base_arguments_opts= +_ble_base_arguments_attach= +_ble_base_arguments_rcfile= +function ble/base/read-blesh-arguments { + local opts= + local opt_attach=prompt + local opt_inputrc=auto + builtin unset -v _ble_init_command # 再解析 + while (($#)); do + local arg=$1; shift + case $arg in + (--noattach|noattach) + opt_attach=none ;; + (--attach=*) opt_attach=${arg#*=} ;; + (--attach) + if (($#)); then + opt_attach=$1; shift + else + opt_attach=attach + opts=$opts:E + ble/util/print "ble.sh ($arg): an option argument is missing." >&2 + fi ;; + (--noinputrc) + opt_inputrc=none ;; + (--inputrc=*) opt_inputrc=${arg#*=} ;; + (--inputrc) + if (($#)); then + opt_inputrc=$1; shift + else + opt_inputrc=inputrc + opts=$opts:E + ble/util/print "ble.sh ($arg): an option argument is missing." >&2 + fi ;; + (--rcfile=*|--init-file=*|--rcfile|--init-file) + if [[ $arg != *=* ]]; then + local rcfile=$1; shift + else + local rcfile=${arg#*=} + fi + _ble_base_arguments_rcfile=${rcfile:-/dev/null} + if [[ ! $rcfile || ! -e $rcfile ]]; then + ble/util/print "ble.sh ($arg): '$rcfile' does not exist." >&2 + opts=$opts:E + elif [[ ! -r $rcfile ]]; then + ble/util/print "ble.sh ($arg): '$rcfile' is not readable." >&2 + opts=$opts:E + fi ;; + (--norc) + _ble_base_arguments_rcfile=/dev/null ;; + (--keep-rlvars) + opts=$opts:keep-rlvars ;; + (--bash-debug-version=*|--bash-debug-version) + local value= + if [[ $arg == *=* ]]; then + value=${arg#*=} + elif (($#)); then + value=$1; shift + else + opts=$opts:E + ble/util/print "ble.sh ($arg): an option argument is missing." >&2 + continue + fi + case $value in + (full|short|once|ignore) + opts=$opts:bash-debug-version=$value ;; + (*) + opts=$opts:E + ble/util/print "ble.sh ($arg): unrecognized value '$value'." >&2 + esac ;; + (--debug-bash-output) + bleopt_internal_suppress_bash_output= ;; + (--test | --update | --clear-cache | --lib | --install) + if [[ $_ble_init_command ]]; then + ble/util/print "ble.sh ($arg): the option '--$_ble_init_command' has already been specified." >&2 + opts=$opts:E + else + _ble_init_command=${arg#--} + fi ;; + (--*) + ble/util/print "ble.sh: unrecognized long option '$arg'" >&2 + opts=$opts:E ;; + (-?*) + local i c + for ((i=1;i<${#arg};i++)); do + c=${arg:i:1} + case -$c in + (-o) + if ((i+1<${#arg})); then + local oarg=${arg:i+1} + i=${#arg} + elif (($#)); then + local oarg=$1; shift + else + opts=$opts:E + i=${#arg} + continue + fi + local rex='^[_a-zA-Z][_a-zA-Z0-9]*=' + if [[ $oarg =~ $rex ]]; then + builtin eval -- "bleopt_${oarg%%=*}=\${oarg#*=}" + else + ble/util/print "ble.sh: unrecognized option '-o $oarg'" >&2 + opts=$opts:E + fi ;; + (-*) + ble/util/print "ble.sh: unrecognized option '-$c'" >&2 + opts=$opts:E ;; + esac + done + ;; + (*) + if [[ ${_ble_init_command-} ]]; then + _ble_init_command[${#_ble_init_command[@]}]=$arg + else + ble/util/print "ble.sh: unrecognized argument '$arg'" >&2 + opts=$opts:E + fi ;; + esac + done + _ble_base_arguments_opts=$opts + _ble_base_arguments_attach=$opt_attach + _ble_base_arguments_inputrc=$opt_inputrc + [[ :$opts: != *:E:* ]] +} +if ! ble/base/read-blesh-arguments "$@"; then + builtin echo "ble.sh: cancel initialization." >&2 + ble/init/clean-up 2>/dev/null # set -x 対策 #D0930 + builtin unset -v _ble_bash + return 2 2>/dev/null || builtin exit 2 +fi +if [[ ${_ble_base-} ]]; then + [[ $_ble_init_command ]] && _ble_init_attached=$_ble_attached + if ! ble/base/unload-for-reload; then + builtin echo "ble.sh: an old version of ble.sh seems to be already loaded." >&2 + ble/init/clean-up 2>/dev/null # set -x 対策 #D0930 + builtin unset -v _ble_bash + return 1 2>/dev/null || builtin exit 1 + fi +fi +_ble_bash_loaded_in_function=0 +local _ble_local_test 2>/dev/null && _ble_bash_loaded_in_function=1 +_ble_version=0 +BLE_VERSION=$_ble_init_version +function ble/base/initialize-version-variables { + local version=$BLE_VERSION + local hash= + if [[ $version == *+* ]]; then + hash=${version#*+} + version=${version%%+*} + fi + local status=release + if [[ $version == *-* ]]; then + status=${version#*-} + version=${version%%-*} + fi + local major=${version%%.*}; version=${version#*.} + local minor=${version%%.*}; version=${version#*.} + local patch=${version%%.*} + ((_ble_version=major*10000+minor*100+patch)) + BLE_VERSINFO=("$major" "$minor" "$patch" "$hash" "$status" noarch) + BLE_VER=$_ble_version +} +function ble/base/clear-version-variables { + builtin unset -v _ble_bash _ble_version BLE_VERSION BLE_VERSINFO BLE_VER +} +ble/base/initialize-version-variables +function ble/bash/read { + local TMOUT= 2>/dev/null # #D1630 WA readonly TMOUT + builtin read "${_ble_bash_tmout_wa[@]}" -r "$@" +} +function ble/bash/read-timeout { builtin read -t "$@"; } +_ble_bash_read_winch= +if ((50200<=_ble_bash&&_ble_bash<50300)); then + function ble/bash/read/.process-winch { + if [[ $_ble_bash_read_winch != - ]]; then + local _ble_local_handler=$_ble_bash_read_winch + local _ble_bash_read_winch= + builtin eval -- "$_ble_local_handler" + fi + } + function ble/bash/read { + local TMOUT= 2>/dev/null # #D1630 WA readonly TMOUT + local _ble_bash_read_winch=- + builtin read "${_ble_bash_tmout_wa[@]}" -r "$@"; local _ble_local_ext=$? + ble/bash/read/.process-winch + return "$_ble_local_ext" + } + function ble/bash/read-timeout { + local _ble_bash_read_winch=- + builtin read -t "$@"; local _ble_local_ext=$? + ble/bash/read/.process-winch + return "$_ble_local_ext" + } +fi +if ((_ble_bash>=50300)); then + function ble/util/assign { builtin eval "$1=\${ builtin eval -- \"\$2\"; }"; } +else + function ble/util/assign { builtin eval "$1=\$(builtin eval -- \"\$2\")"; } +fi +if ((_ble_bash>=40000)); then + function ble/bin#has { builtin type -t -- "$@" &>/dev/null; } +else + function ble/bin#has { + local cmd + for cmd; do builtin type -t -- "$cmd" || return 1; done &>/dev/null + return 0 + } +fi +function ble/bin#get-path { + local cmd=$1 + ble/util/assign path 'builtin type -P -- "$cmd" 2>/dev/null' && [[ $path ]] +} +function ble/bin/.default-utility-path { + local cmd + for cmd; do + builtin eval "function ble/bin/$cmd { command $cmd \"\$@\"; }" + done +} +function ble/bin#freeze-utility-path { + local cmd path q=\' Q="'\''" fail= flags= + for cmd; do + if [[ $cmd == -n ]]; then + flags=n$flags + continue + fi + [[ $flags == *n* ]] && ble/bin#has "ble/bin/$cmd" && continue + ble/bin#has "ble/bin/.frozen:$cmd" && continue + if ble/bin#get-path "$cmd"; then + [[ $path == ./* || $path == ../* ]] && path=$PWD/$path + builtin eval "function ble/bin/$cmd { '${path//$q/$Q}' \"\$@\"; }" + else + fail=1 + fi + done + ((!fail)) +} +_ble_init_posix_command_list=(sed date rm mkdir mkfifo sleep stty tty sort awk chmod grep cat wc mv sh od cp ps) +function ble/init/check-environment { + if ! ble/bin#has "${_ble_init_posix_command_list[@]}"; then + local cmd commandMissing= + for cmd in "${_ble_init_posix_command_list[@]}"; do + if ! type "$cmd" &>/dev/null; then + commandMissing="$commandMissing\`$cmd', " + fi + done + ble/util/print "ble.sh: insane environment: The command(s), ${commandMissing}not found. Check your environment variable PATH." >&2 + local default_path=$(command -p getconf PATH 2>/dev/null) + [[ $default_path ]] || return 1 + local original_path=$PATH + export PATH=${default_path}${PATH:+:}${PATH} + [[ :$PATH: == *:/bin:* ]] || PATH=/bin${PATH:+:}$PATH + [[ :$PATH: == *:/usr/bin:* ]] || PATH=/usr/bin${PATH:+:}$PATH + if ! ble/bin#has "${_ble_init_posix_command_list[@]}"; then + PATH=$original_path + return 1 + fi + ble/util/print "ble.sh: modified PATH=${PATH::${#PATH}-${#original_path}}\$PATH" >&2 + fi + if [[ ! ${USER-} ]]; then + ble/util/print "ble.sh: insane environment: \$USER is empty." >&2 + if USER=$(id -un 2>/dev/null) && [[ $USER ]]; then + export USER + ble/util/print "ble.sh: modified USER=$USER" >&2 + fi + fi + _ble_base_env_USER=$USER + if [[ ! ${HOSTNAME-} ]]; then + ble/util/print "ble.sh: suspicious environment: \$HOSTNAME is empty." + if HOSTNAME=$(uname -n 2>/dev/null) && [[ $HOSTNAME ]]; then + export HOSTNAME + ble/util/print "ble.sh: fixed HOSTNAME=$HOSTNAME" >&2 + fi + fi + _ble_base_env_HOSTNAME=$HOSTNAME + if [[ ! ${HOME-} ]]; then + ble/util/print "ble.sh: insane environment: \$HOME is empty." >&2 + local home + if home=$(getent passwd 2>/dev/null | awk -F : -v UID="$UID" '$3 == UID {print $6}') && [[ $home && -d $home ]] || + { [[ $USER && -d /home/$USER && -O /home/$USER ]] && home=/home/$USER; } || + { [[ $USER && -d /Users/$USER && -O /Users/$USER ]] && home=/Users/$USER; } || + { [[ $home && ! ( -e $home && -h $home ) ]] && ble/bin/mkdir -p "$home" 2>/dev/null; } + then + export HOME=$home + ble/util/print "ble.sh: modified HOME=$HOME" >&2 + fi + fi + if [[ ! ${LANG-} ]]; then + ble/util/print "ble.sh: suspicious environment: \$LANG is empty." >&2 + fi + if ((_ble_bash>=50200)); then + local error + ble/util/assign error '{ LC_ALL= LC_CTYPE=C ble/util/put; } 2>&1' + if [[ $error ]]; then + ble/util/print "$error" >&2 + ble/util/print "ble.sh: please check the locale settings (LANG and LC_*)." >&2 + ((_ble_bash>=50300)) || { LC_ALL= LC_CTYPE=C ble/util/put; } 2>/dev/null + local dummy + builtin read -et 0.000001 dummy &2 + ble/base/clear-version-variables + ble/init/clean-up 2>/dev/null # set -x 対策 #D0930 + return 1 +fi +_ble_bin_awk_type= +function ble/bin/awk/.instantiate { + local path q=\' Q="'\''" ext=1 + if ble/bin#get-path nawk; then + [[ $path == ./* || $path == ../* ]] && path=$PWD/$path + local version + ble/util/assign version '"$path" -W version' 2>/dev/null /dev/null; then + _ble_bin_awk_type=xpg4 + function ble/bin/awk { /usr/xpg4/bin/awk -v AWKTYPE=xpg4 "$@"; } && ext=0 + elif ble/bin#get-path awk; then + [[ $path == ./* || $path == ../* ]] && path=$PWD/$path + local version + ble/util/assign version '"$path" -W version || "$path" --version' 2>/dev/null /dev/null + /usr/bin/awk -v AWKTYPE=nawk "$@"; local ext=$? + ble/util/unlocal LC_ALL LC_CTYPE 2>/dev/null + return "$ext" + } + elif [[ $_ble_bin_awk_type == [gmn]awk ]] && ! ble/is-function "ble/bin/$_ble_bin_awk_type" ; then + builtin eval "function ble/bin/$_ble_bin_awk_type { '${path//$q/$Q}' -v AWKTYPE=$_ble_bin_awk_type \"\$@\"; }" + fi + fi + fi + return "$ext" +} +function ble/bin/awk { + if ble/bin/awk/.instantiate; then + ble/bin/awk "$@" + else + awk "$@" + fi +} +function ble/bin/.frozen:awk { return 0; } +function ble/bin/.frozen:nawk { return 0; } +function ble/bin/.frozen:mawk { return 0; } +function ble/bin/.frozen:gawk { return 0; } +function ble/bin/awk0.available/test { + local count=0 cmd_awk=$1 awk_script='BEGIN { RS = "\0"; } { count++; } END { print count; }' + ble/util/assign count 'printf "a\0b\0" | "$cmd_awk" "$awk_script"' + ((count==2)) +} +function ble/bin/awk0.available { + local awk + for awk in mawk gawk; do + if ble/bin#freeze-utility-path -n "$awk" && + ble/bin/awk0.available/test ble/bin/"$awk" && + builtin eval -- "function ble/bin/awk0 { ble/bin/$awk -v AWKTYPE=$awk \"\$@\"; }"; then + function ble/bin/awk0.available { return 0; } + return 0 + fi + done + if ble/bin/awk0.available/test ble/bin/awk && + function ble/bin/awk0 { ble/bin/awk "$@"; }; then + function ble/bin/awk0.available { return 0; } + return 0 + fi + function ble/bin/awk0.available { return 1; } + return 1 +} +function ble/base/is-msys1 { + local cr; cr=$'\r' + [[ $OSTYPE == msys && ! $cr ]] +} +function ble/util/mkd { + local dir + for dir; do + [[ -d $dir ]] && continue + [[ -e $dir || -L $dir ]] && ble/bin/rm -f "$dir" + ble/bin/mkdir -p "$dir" + done +} +if ((_ble_bash>=40000)); then + _ble_util_readlink_visited_init='local -A visited=()' + function ble/util/readlink/.visited { + [[ ${visited[$1]+set} ]] && return 0 + visited[$1]=1 + return 1 + } +else + _ble_util_readlink_visited_init="local -a visited=()" + function ble/util/readlink/.visited { + local key + for key in "${visited[@]}"; do + [[ $1 == "$key" ]] && return 0 + done + visited=("$1" "${visited[@]}") + return 1 + } +fi +function ble/util/readlink/.readlink { + local path=$1 + if ble/bin#has ble/bin/readlink; then + ble/util/assign link 'ble/bin/readlink -- "$path"' + [[ $link ]] + elif ble/bin#has ble/bin/ls; then + ble/util/assign link 'ble/bin/ls -ld -- "$path"' && + [[ $link == *" $path -> "?* ]] && + link=${link#*" $path -> "} + else + false + fi +} 2>/dev/null +function ble/util/readlink/.resolve-physical-directory { + [[ $path == */?* ]] || return 0 + local PWD=$PWD OLDPWD=$OLDPWD CDPATH= + if builtin cd -L .; then + local pwd=$PWD + builtin cd -P "${path%/*}/" && + path=${PWD%/}/${path##*/} + builtin cd "$pwd" + fi + return 0 +} +function ble/util/readlink/.resolve-loop { + local path=$ret + while [[ $path == ?*/ ]]; do path=${path%/}; done + builtin eval -- "$_ble_util_readlink_visited_init" + while [[ -h $path ]]; do + local link + ble/util/readlink/.visited "$path" && break + ble/util/readlink/.readlink "$path" || break + if [[ $link == /* || $path != */* ]]; then + path=$link + else + ble/util/readlink/.resolve-physical-directory + path=${path%/*}/$link + fi + while [[ $path == ?*/ ]]; do path=${path%/}; done + done + ret=$path +} +function ble/util/readlink/.resolve { + _ble_util_readlink_type= + case $OSTYPE in + (cygwin | msys | linux-gnu) + local readlink + ble/util/assign readlink 'type -P readlink' + case $readlink in + (/bin/readlink | /usr/bin/readlink) + _ble_util_readlink_type=readlink-f + builtin eval "function ble/util/readlink/.resolve { ble/util/assign ret '$readlink -f -- \"\$ret\"'; }" ;; + esac ;; + esac + if [[ ! $_ble_util_readlink_type ]]; then + _ble_util_readlink_type=loop + ble/bin#freeze-utility-path readlink ls + function ble/util/readlink/.resolve { ble/util/readlink/.resolve-loop; } + fi + ble/util/readlink/.resolve +} +function ble/util/readlink { + ret=$1 + if [[ -h $ret ]]; then ble/util/readlink/.resolve; fi +} +_ble_bash_path= +function ble/bin/.load-builtin { + local name=$1 path=$2 + if [[ ! $_ble_bash_path ]]; then + local ret; ble/util/readlink "$BASH" + _ble_bash_path=$ret + fi + if [[ ! $path ]]; then + local bash_prefix=${ret%/*/*} + path=$bash_prefix/lib/bash/$name + [[ -s $path ]] || return 1 + fi + if (enable -f "$path" "$name") &>/dev/null; then + enable -f "$path" "$name" + builtin eval -- "function ble/bin/$name { builtin $name \"\$@\"; }" + return 0 + else + return 1 + fi +} +function ble/base/.create-user-directory { + local var=$1 dir=$2 + if [[ ! -d $dir ]]; then + [[ ! -e $dir && -h $dir ]] && ble/bin/rm -f "$dir" + if [[ -e $dir || -h $dir ]]; then + ble/util/print "ble.sh: cannot create a directory '$dir' since there is already a file." >&2 + return 1 + fi + if ! (umask 077; ble/bin/mkdir -p "$dir" && [[ -O $dir ]]); then + ble/util/print "ble.sh: failed to create a directory '$dir'." >&2 + return 1 + fi + elif ! [[ -r $dir && -w $dir && -x $dir ]]; then + ble/util/print "ble.sh: permission of '$dir' is not correct." >&2 + return 1 + elif [[ ! -O $dir ]]; then + ble/util/print "ble.sh: owner of '$dir' is not correct." >&2 + return 1 + fi + builtin eval "$var=\$dir" +} +function ble/base/initialize-base-directory { + local src=$1 + local defaultDir=${2-} + _ble_base_blesh_raw=$src + if [[ -h $src ]]; then + local ret; ble/util/readlink "$src"; src=$ret + fi + _ble_base_blesh=$src + if [[ -s $src && $src != */* ]]; then + _ble_base=$PWD + elif [[ $src == */* ]]; then + local dir=${src%/*} + if [[ ! $dir ]]; then + _ble_base=/ + elif [[ $dir != /* ]]; then + _ble_base=$PWD/$dir + else + _ble_base=$dir + fi + else + _ble_base=${defaultDir:-$HOME/.local/share/blesh} + fi + [[ -d $_ble_base ]] +} +if ! ble/base/initialize-base-directory "${BASH_SOURCE[0]}"; then + ble/util/print "ble.sh: ble base directory not found!" >&2 + ble/base/clear-version-variables + ble/init/clean-up 2>/dev/null # set -x 対策 #D0930 + return 1 +fi +_ble_base_is_wsl_status= +function ble/base/initialize-runtime-directory/.is-wsl { + [[ $_ble_base_is_wsl_status ]] && return "$_ble_base_is_wsl_status" + _ble_base_is_wsl_status=1 + [[ -d /usr/lib/wsl/lib && -r /proc/version ]] || return 1 + local kernel_version + ble/bash/read kernel_version < /proc/version || return 1 + [[ $kernel_version == *-microsoft-* ]] || return 1 + _ble_base_is_wsl_status=0 +} +function ble/base/initialize-runtime-directory/.xdg { + local runtime_dir= + if [[ $XDG_RUNTIME_DIR ]]; then + if [[ ! -d $XDG_RUNTIME_DIR ]]; then + ble/util/print "ble.sh: XDG_RUNTIME_DIR='$XDG_RUNTIME_DIR' is not a directory." >&2 + return 1 + elif [[ -O $XDG_RUNTIME_DIR ]]; then + runtime_dir=$XDG_RUNTIME_DIR + else + false + fi + fi + if [[ ! $runtime_dir ]]; then + runtime_dir=/run/user/$UID + [[ -d $runtime_dir && -O $runtime_dir ]] || return 1 + fi + [[ $runtime_dir == /run/user/* ]] && + ble/base/initialize-runtime-directory/.is-wsl && + return 1 + if ! [[ -r $runtime_dir && -w $runtime_dir && -x $runtime_dir ]]; then + [[ $runtime_dir == "$XDG_RUNTIME_DIR" ]] && + ble/util/print "ble.sh: XDG_RUNTIME_DIR='$XDG_RUNTIME_DIR' doesn't have a proper permission." >&2 + return 1 + fi + ble/base/.create-user-directory _ble_base_run "$runtime_dir/blesh" +} +function ble/base/initialize-runtime-directory/.tmp { + [[ -r /tmp && -w /tmp && -x /tmp ]] || return 1 + ble/base/initialize-runtime-directory/.is-wsl && return 1 + local tmp_dir=/tmp/blesh + if [[ ! -d $tmp_dir ]]; then + [[ ! -e $tmp_dir && -h $tmp_dir ]] && ble/bin/rm -f "$tmp_dir" + if [[ -e $tmp_dir || -h $tmp_dir ]]; then + ble/util/print "ble.sh: cannot create a directory '$tmp_dir' since there is already a file." >&2 + return 1 + fi + ble/bin/mkdir -p "$tmp_dir" || return 1 + ble/bin/chmod a+rwxt "$tmp_dir" || return 1 + elif ! [[ -r $tmp_dir && -w $tmp_dir && -x $tmp_dir ]]; then + ble/util/print "ble.sh: permission of '$tmp_dir' is not correct." >&2 + return 1 + fi + ble/base/.create-user-directory _ble_base_run "$tmp_dir/$UID" +} +function ble/base/initialize-runtime-directory/.base { + local tmp_dir=$_ble_base/run + if [[ ! -d $tmp_dir ]]; then + ble/bin/mkdir -p "$tmp_dir" || return 1 + ble/bin/chmod a+rwxt "$tmp_dir" || return 1 + fi + ble/base/.create-user-directory _ble_base_run "$tmp_dir/${USER:-$UID}@$HOSTNAME" +} +function ble/base/initialize-runtime-directory/.home { + local cache_dir=${XDG_CACHE_HOME:-$HOME/.cache} + if [[ ! -d $cache_dir ]]; then + if [[ $XDG_CACHE_HOME ]]; then + ble/util/print "ble.sh: XDG_CACHE_HOME='$XDG_CACHE_HOME' is not a directory." >&2 + return 1 + else + ble/bin/mkdir -p "$cache_dir" || return 1 + fi + fi + if ! [[ -r $cache_dir && -w $cache_dir && -x $cache_dir ]]; then + if [[ $XDG_CACHE_HOME ]]; then + ble/util/print "ble.sh: XDG_CACHE_HOME='$XDG_CACHE_HOME' doesn't have a proper permission." >&2 + else + ble/util/print "ble.sh: '$cache_dir' doesn't have a proper permission." >&2 + fi + return 1 + fi + ble/base/.create-user-directory _ble_base_run "$cache_dir/blesh/run" +} +function ble/base/initialize-runtime-directory { + ble/base/initialize-runtime-directory/.xdg && return 0 + ble/base/initialize-runtime-directory/.tmp && return 0 + ble/base/initialize-runtime-directory/.base && return 0 + ble/base/initialize-runtime-directory/.home +} +if ! ble/base/initialize-runtime-directory; then + ble/util/print "ble.sh: failed to initialize \$_ble_base_run." >&2 + ble/base/clear-version-variables + ble/init/clean-up 2>/dev/null # set -x 対策 #D0930 + return 1 +fi +>| "$_ble_base_run/$$.load" +function ble/base/clean-up-runtime-directory { + local opts=$1 failglob= noglob= + if [[ $- == *f* ]]; then + noglob=1 + set +f + fi + if shopt -q failglob &>/dev/null; then + failglob=1 + shopt -u failglob + fi + local -a alive=() removed=() bgpids=() + [[ :$opts: == *:finalize:* ]] && alive[$$]=0 + local file pid iremoved=0 ibgpid=0 + for file in "$_ble_base_run"/[1-9]*.*; do + [[ -e $file || -h $file ]] || continue + pid=${file##*/}; pid=${pid%%.*} + [[ $pid && ! ${pid//[0-9]} ]] || continue + if [[ ! ${alive[pid]+set} ]]; then + builtin kill -0 "$pid" &>/dev/null + ((alive[pid]=$?==0)) + fi + ((alive[pid])) && continue + if [[ $file == *.pid && -s $file ]]; then + local run_pid IFS= + ble/bash/read run_pid < "$file" + if ble/string#match "$run_pid" '^-?[0-9]+$' && kill -0 "$run_pid" &>/dev/null; then + if ((pid==$$)); then + bgpids[ibgpid++]=$run_pid + else + builtin kill -- "$run_pid" &>/dev/null + ble/util/msleep 50 + builtin kill -0 "$run_pid" &>/dev/null && + (ble/util/nohup "ble/util/conditional-sync '' '((1))' 100 progressive-weight:pid=$run_pid:no-wait-pid:timeout=3000:SIGKILL") + fi + fi + fi + removed[iremoved++]=$file + done + ((iremoved)) && ble/bin/rm -rf "${removed[@]}" 2>/dev/null + ((ibgpid)) && (ble/util/nohup 'ble/bin/sleep 3; builtin kill -- "${bgpids[@]}" &>/dev/null') + [[ $failglob ]] && shopt -s failglob + [[ $noglob ]] && set -f + return 0 +} +function ble/base/initialize-cache-directory/.xdg { + [[ $_ble_base != */out ]] || return 1 + local cache_dir=${XDG_CACHE_HOME:-$HOME/.cache} + if [[ ! -d $cache_dir ]]; then + [[ $XDG_CACHE_HOME ]] && + ble/util/print "ble.sh: XDG_CACHE_HOME='$XDG_CACHE_HOME' is not a directory." >&2 + return 1 + fi + if ! [[ -r $cache_dir && -w $cache_dir && -x $cache_dir ]]; then + [[ $XDG_CACHE_HOME ]] && + ble/util/print "ble.sh: XDG_CACHE_HOME='$XDG_CACHE_HOME' doesn't have a proper permission." >&2 + return 1 + fi + local ver=${BLE_VERSINFO[0]}.${BLE_VERSINFO[1]} + ble/base/.create-user-directory _ble_base_cache "$cache_dir/blesh/$ver" +} +function ble/base/initialize-cache-directory { + ble/base/initialize-cache-directory/.xdg && return 0 + local cache_dir=$_ble_base/cache.d + if [[ ! -d $cache_dir ]]; then + ble/bin/mkdir -p "$cache_dir" || return 1 + ble/bin/chmod a+rwxt "$cache_dir" || return 1 + local old_cache_dir=$_ble_base/cache + if [[ -d $old_cache_dir && ! -h $old_cache_dir ]]; then + mv "$old_cache_dir" "$cache_dir/$UID" + ln -s "$cache_dir/$UID" "$old_cache_dir" + fi + fi + ble/base/.create-user-directory _ble_base_cache "$cache_dir/$UID" +} +function ble/base/migrate-cache-directory/.move { + local old=$1 new=$2 + [[ -e $old ]] || return 0 + if [[ -e $new || -L $old ]]; then + ble/bin/rm -rf "$old" + else + ble/bin/mv "$old" "$new" + fi +} +function ble/base/migrate-cache-directory/.check-old-prefix { + local old_prefix=$_ble_base_cache/$1 + local new_prefix=$_ble_base_cache/$2 + local file + for file in "$old_prefix"*; do + local old=$file + local new=$new_prefix${file#"$old_prefix"} + ble/base/migrate-cache-directory/.move "$old" "$new" + done +} +function ble/base/migrate-cache-directory { + local failglob= + shopt -q failglob && { failglob=1; shopt -u failglob; } + ble/base/migrate-cache-directory/.check-old-prefix cmap+default.binder-source decode.cmap.allseq + ble/base/migrate-cache-directory/.check-old-prefix cmap+default decode.cmap + ble/base/migrate-cache-directory/.check-old-prefix ble-decode-bind decode.bind + local file + for file in "$_ble_base_cache"/*.term; do + local old=$file + local new=$_ble_base_cache/term.${file#"$_ble_base_cache/"}; new=${new%.term} + ble/base/migrate-cache-directory/.move "$old" "$new" + done + ble/base/migrate-cache-directory/.move "$_ble_base_cache/man" "$_ble_base_cache/complete.mandb" + [[ $failglob ]] && shopt -s failglob +} +if ! ble/base/initialize-cache-directory; then + ble/util/print "ble.sh: failed to initialize \$_ble_base_cache." >&2 + ble/base/clear-version-variables + ble/init/clean-up 2>/dev/null # set -x 対策 #D0930 + return 1 +fi +ble/base/migrate-cache-directory +function ble/base/initialize-state-directory/.xdg { + local state_dir=${XDG_STATE_HOME:-$HOME/.local/state} + if [[ -e $state_dir || -L $state_dir ]]; then + if [[ ! -d $state_dir ]]; then + if [[ $XDG_STATE_HOME ]]; then + ble/util/print "ble.sh: XDG_STATE_HOME='$XDG_STATE_HOME' is not a directory." >&2 + else + ble/util/print "ble.sh: '$state_dir' is not a directory." >&2 + fi + return 1 + fi + if ! [[ -r $state_dir && -w $state_dir && -x $state_dir ]]; then + if [[ $XDG_STATE_HOME ]]; then + ble/util/print "ble.sh: XDG_STATE_HOME='$XDG_STATE_HOME' doesn't have a proper permission." >&2 + else + ble/util/print "ble.sh: '$state_dir' doesn't have a proper permission." >&2 + fi + return 1 + fi + fi + ble/base/.create-user-directory _ble_base_state "$state_dir/blesh" +} +function ble/base/initialize-state-directory { + ble/base/initialize-state-directory/.xdg && return 0 + local state_dir=$_ble_base/state.d + if [[ ! -d $state_dir ]]; then + ble/bin/mkdir -p "$state_dir" || return 1 + ble/bin/chmod a+rwxt "$state_dir" || return 1 + local old_state_dir=$_ble_base/state + if [[ -d $old_state_dir && ! -h $old_state_dir ]]; then + mv "$old_state_dir" "$state_dir/$UID" + ln -s "$state_dir/$UID" "$old_state_dir" + fi + fi + ble/util/print "ble.sh: using the non-standard position of the state directory: '$state_dir/$UID'" >&2 + ble/base/.create-user-directory _ble_base_state "$state_dir/$UID" +} +if ! ble/base/initialize-state-directory; then + ble/util/print "ble.sh: failed to initialize \$_ble_base_state." >&2 + ble/base/clear-version-variables + ble/init/clean-up 2>/dev/null # set -x 対策 #D0930 + return 1 +fi +function ble/base/print-usage-for-no-argument-command { + local name=${FUNCNAME[1]} desc=$1; shift + ble/util/print-lines \ + "usage: $name" \ + "$desc" >&2 + [[ $1 != --help ]] && return 2 + return 0 +} +function ble-reload { + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_local_adjust" + local -a options=() + [[ ! -e $_ble_base_rcfile ]] || + ble/array#push options --rcfile="${_ble_base_rcfile:-/dev/null}" + [[ $_ble_base_arguments_inputrc == auto ]] || + ble/array#push options --inputrc="$_ble_base_arguments_inputrc" + local name + for name in keep-rlvars; do + if [[ :$_ble_base_arguments_opts: == *:"$name":* ]]; then + ble/array#push options "--$name" + fi + done + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_local_leave" + source "$_ble_base/ble.sh" "${options[@]}" +} +_ble_base_repository=release:nightly-20240814+75c4a84 +_ble_base_branch=master +_ble_base_repository_url=https://github.com/akinomyoga/ble.sh +_ble_base_build_git_version="git version 2.46.0" +_ble_base_build_make_version="GNU Make 4.3" +_ble_base_build_gawk_version="GNU Awk 5.1.0, API: 3.0 (GNU MPFR 4.1.0, GNU MP 6.2.1)" +function ble-update/.check-install-directory-ownership { + if [[ ! -O $_ble_base ]]; then + ble/util/print 'ble-update: install directory is owned by another user:' >&2 + ls -ld "$_ble_base" + return 1 + elif [[ ! -r $_ble_base || ! -w $_ble_base || ! -x $_ble_base ]]; then + ble/util/print 'ble-update: install directory permission denied:' >&2 + ls -ld "$_ble_base" + return 1 + fi +} +function ble-update/.make { + local sudo= + if [[ $1 == --sudo ]]; then + sudo=1 + shift + fi + if ! "$make" -q "$@"; then + if [[ $sudo ]]; then + sudo "$make" "$@" + else + "$make" "$@" + fi + else + return 6 + fi +} +function ble-update/.reload { + local ext=$1 + if [[ $ext -eq 0 || $ext -eq 6 && $_ble_base/ble.sh -nt $_ble_base_run/$$.load ]]; then + if [[ ! -e $_ble_base/ble.sh ]]; then + ble/util/print "ble-update: new ble.sh not found at '$_ble_base/ble.sh'." >&2 + return 1 + elif [[ ! -s $_ble_base/ble.sh ]]; then + ble/util/print "ble-update: new ble.sh '$_ble_base/ble.sh' is empty." >&2 + return 1 + elif [[ $- == *i* && $_ble_attached ]] && ! ble/util/is-running-in-subshell; then + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_local_leave" + ble-reload + ext=$? + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_local_enter" + return "$ext" + fi + return 0 + fi + ((ext==6)) && ext=0 + return "$ext" +} +function ble-update/.download-nightly-build { + if ! ble/bin#has tar xz; then + local command + for command in tar xz; do + ble/bin#has "$command" || + ble/util/print "ble-update (nightly): '$command' command is not available." >&2 + done + return 1 + fi + if ((EUID!=0)) && ! ble-update/.check-install-directory-ownership; then + sudo "$BASH" "$_ble_base/ble.sh" --update && + ble-update/.reload 6 + return "$?" + fi + local tarname=ble-nightly.tar.xz + local url_tar=$_ble_base_repository_url/releases/download/nightly/$tarname + ( + ble/util/joblist/__suppress__ + set +f + shopt -u failglob nullglob + if ! ble/bin/mkdir -p "$_ble_base/src"; then + ble/util/print "ble-update (nightly): failed to create the directory '$_ble_base/src'" >&2 + return 1 + fi + if ! builtin cd "$_ble_base/src"; then + ble/util/print "ble-update (nightly): failed to enter the directory '$_ble_base/src'" >&2 + return 1 + fi + local ret + ble/file#hash "$tarname"; local ohash=$ret + local retry max_retry=5 + for ((retry=0;retry<=max_retry;retry++)); do + if ((retry>0)); then + local wait=$((retry<3?retry*10:30)) + ble/util/print "ble-update (nightly): retry downloading in $wait seconds... ($retry/$max_retry)" >&2 + ble/util/sleep "$wait" + fi + if ble/bin#has wget; then + wget -N "$url_tar" && break + elif ble/bin#has curl; then + curl -LRo "$tarname" -z "$tarname" "$url_tar" && break + else + ble/util/print "ble-update (nightly): command 'wget' nor 'curl' is available." >&2 + return 1 + fi + done + if ((retry>max_retry)); then + ble/util/print "ble-update (nightly): failed to download the archive from '$url_tar'." >&2 + return 7 + fi + ble/file#hash "$tarname"; local nhash=$ret + [[ $ohash == "$nhash" ]] && return 6 + ble/bin/rm -rf ble-nightly*/ + if ! tar xJf "$tarname"; then + ble/util/print 'ble-update (nightly): failed to extract the tarball. Removing possibly broken tarball.' >&2 + ble/bin/rm -rf "$tarname" + return 1 + fi + local extracted_dir=ble-nightly + if [[ ! -d $extracted_dir ]]; then + ble/util/print "ble-update (nightly): the directory 'ble-nightly' not found in the tarball '$PWD/$tarname'." >&2 + return 1 + fi + ble/bin/cp -Rf "$extracted_dir"/* "$_ble_base/" || return 1 + ble/bin/rm -rf "$extracted_dir" + ) && + ble-update/.reload +} +function ble-update/.check-build-dependencies { + make= + if ble/bin#has gmake; then + make=gmake + elif ble/bin#has make && make --version 2>&1 | ble/bin/grep -qiF 'GNU Make'; then + make=make + else + ble/util/print "ble-update: GNU Make is not available." >&2 + return 1 + fi + if ! ble/bin#has git gawk; then + local command + for command in git gawk; do + ble/bin#has "$command" || + ble/util/print "ble-update: '$command' command is not available." >&2 + done + return 1 + fi + return 0 +} +function ble-update/.check-repository { + if [[ ${_ble_base_repository-} && $_ble_base_repository != release:* ]]; then + if [[ ! -e $_ble_base_repository/.git ]]; then + ble/util/print "ble-update: git repository not found at '$_ble_base_repository'." >&2 + elif [[ ! -O $_ble_base_repository ]]; then + ble/util/print "ble-update: git repository is owned by another user:" >&2 + ls -ld "$_ble_base_repository" + elif [[ ! -r $_ble_base_repository || ! -w $_ble_base_repository || ! -x $_ble_base_repository ]]; then + ble/util/print 'ble-update: git repository permission denied:' >&2 + ls -ld "$_ble_base_repository" + else + return 0 + fi + fi + return 1 +} +function ble-update/.impl { + if (($#)); then + ble/base/print-usage-for-no-argument-command 'Update and reload ble.sh.' "$@" + return "$?" + fi + if [[ ${_ble_base_package_type-} ]] && ble/is-function ble/base/package:"$_ble_base_package_type"/update; then + ble/util/print "ble-update: delegate to '$_ble_base_package_type' package manager..." >&2 + ble/base/package:"$_ble_base_package_type"/update; local ext=$? + if ((ext==125)); then + ble/util/print 'ble-update: fallback to the default update process.' >&2 + else + ble-update/.reload "$ext" + return "$?" + fi + fi + if [[ ${_ble_base_repository-} == release:nightly-* ]]; then + if ble-update/.download-nightly-build; local ext=$?; ((ext==0||ext==6||ext==7)); then + if ((ext==6)); then + ble/util/print 'ble-update (nightly): Already up to date.' >&2 + elif ((ext==7)); then + ble/util/print 'ble-update (nightly): Remote temporarily unavailable. Try it again later.' >&2 + fi + return 0 + fi + fi + local make + ble-update/.check-build-dependencies || return 1 + local insdir_doc=$_ble_base/doc + [[ ! -d $insdir_doc && -d ${_ble_base%/*}/doc/blesh ]] && + insdir_doc=${_ble_base%/*}/doc/blesh + if ble-update/.check-repository; then + ( ble/util/print "cd into $_ble_base_repository..." >&2 && + builtin cd "$_ble_base_repository" && + git pull && git submodule update --recursive --remote && + if [[ $_ble_base == "$_ble_base_repository"/out ]]; then + ble-update/.make all + elif ((EUID!=0)) && ! ble-update/.check-install-directory-ownership; then + ble-update/.make all + ble-update/.make --sudo INSDIR="$_ble_base" INSDIR_DOC="$insdir_doc" install + else + ble-update/.make INSDIR="$_ble_base" INSDIR_DOC="$insdir_doc" install + fi ) + ble-update/.reload "$?" + return "$?" + fi + if ((EUID!=0)) && ! ble-update/.check-install-directory-ownership; then + sudo "$BASH" "$_ble_base/ble.sh" --update && + ble-update/.reload 6 + return "$?" + else + local branch=${_ble_base_branch:-master} + ( ble/bin/mkdir -p "$_ble_base/src" && builtin cd "$_ble_base/src" && + git clone --recursive --depth 1 "$_ble_base_repository_url" "$_ble_base/src/ble.sh" -b "$branch" && + builtin cd ble.sh && "$make" all && + "$make" INSDIR="$_ble_base" INSDIR_DOC="$insdir_doc" install ) && + ble-update/.reload + return "$?" + fi + return 1 +} +function ble-update { + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_local_adjust" + ble-update/.impl "$@" + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_local_return" +} +_ble_attached= +BLE_ATTACHED= +_ble_term_nl=$'\n' +_ble_term_FS=$'\034' +_ble_term_SOH=$'\001' +_ble_term_DEL=$'\177' +_ble_term_IFS=$' \t\n' +_ble_term_CR=$'\r' +_ble_term_space=$' \t' # WA #D2055 +function blehook/declare { + local name=$1 + builtin eval "_ble_hook_h_$name=()" + builtin eval "_ble_hook_c_$name=0" +} +blehook/declare EXIT +blehook/declare INT +blehook/declare internal_EXIT +blehook/declare internal_INT +blehook/declare internal_ERR +blehook/declare internal_RETURN +blehook/declare internal_DEBUG +blehook/declare unload +blehook/declare ATTACH +blehook/declare DETACH +blehook/declare term_DA1R +blehook/declare term_DA2R +blehook/declare idle_after_task +blehook/declare color_defface_load +blehook/declare color_setface_load +blehook/declare ADDHISTORY +blehook/declare history_reset_background +blehook/declare history_leave +blehook/declare history_change +blehook/declare history_message +blehook/declare WINCH +blehook/declare internal_WINCH +blehook/declare CHPWD +blehook/declare PRECMD +blehook/declare internal_PRECMD +blehook/declare PREEXEC +blehook/declare internal_PREEXEC +blehook/declare POSTEXEC +blehook/declare ERREXEC +blehook/declare widget_bell +blehook/declare textarea_render_defer +blehook/declare info_reveal +blehook/declare exec_register +blehook/declare exec_end +blehook/declare keymap_load +blehook/declare keymap_vi_load +blehook/declare keymap_emacs_load +blehook/declare syntax_load +blehook/declare complete_load +blehook/declare complete_insert +function blehook/.compatibility-ble-0.3 { + blehook keymap_load!='ble/util/invoke-hook _ble_keymap_default_load_hook' + blehook keymap_emacs_load!='ble/util/invoke-hook _ble_keymap_emacs_load_hook' + blehook keymap_vi_load!='ble/util/invoke-hook _ble_keymap_vi_load_hook' + blehook complete_load!='ble/util/invoke-hook _ble_complete_load_hook' +} +function blehook/.compatibility-ble-0.3/check { + if ble/is-array _ble_keymap_default_load_hook || + ble/is-array _ble_keymap_vi_load_hook || + ble/is-array _ble_keymap_emacs_load_hook || + ble/is-array _ble_complete_load_hook + then + ble/bin/cat << EOF +# [Change in ble-0.4.0] +# +# Please update your blerc settings for ble-0.4+. +# In ble-0.4+, use the following form: +# +# blehook/eval-after-load keymap SHELL-COMMAND +# blehook/eval-after-load keymap_vi SHELL-COMMAND +# blehook/eval-after-load keymap_emacs SHELL-COMMAND +# blehook/eval-after-load complete SHELL-COMMAND +# +# instead of the following older form: +# +# ble/array#push _ble_keymap_default_load_hook SHELL-COMMAND +# ble/array#push _ble_keymap_vi_load_hook SHELL-COMMAND +# ble/array#push _ble_keymap_emacs_load_hook SHELL-COMMAND +# ble/array#push _ble_complete_load_hook SHELL-COMMAND +# +# Note: "blehook/eval-after-load" should be called +# after you defined SHELL-COMMAND. +# +EOF + fi +} +function ble-edit/prompt/print { ble/prompt/print "$@"; } +function ble-edit/prompt/process-prompt-string { ble/prompt/process-prompt-string "$@"; } +function ble/widget/@nomarked { ble/decode/widget/dispatch "$@"; } +function ble/complete/action/inherit-from { + ble/complete/action#inherit-from "$@" +} +function bleopt/.read-arguments/process-option { + local name=$1 + case $name in + (help) + flags=H$flags ;; + (color|color=always) + flags=c${flags//[cn]} ;; + (color=never) + flags=n${flags//[cn]} ;; + (color=auto) + flags=${flags//[cn]} ;; + (color=*) + ble/util/print "bleopt: '${name#*=}': unrecognized option argument for '--color'." >&2 + flags=E$flags ;; + (reset) flags=r$flags ;; + (changed) flags=u$flags ;; + (initialize) flags=I$flags ;; + (*) + ble/util/print "bleopt: unrecognized long option '--$name'." >&2 + flags=E$flags ;; + esac +} +function bleopt/expand-variable-pattern { + ret=() + local pattern=$1 + if [[ $pattern == *[@*?]* ]]; then + builtin eval -- "ret=(\"\${!${pattern%%[@*?]*}@}\")" + ble/array#filter-by-glob ret "${pattern//@/*}" + elif [[ ${!pattern+set} || :$opts: == :allow-undefined: ]]; then + ret=("$pattern") + fi + ((${#ret[@]})) +} +function bleopt/.read-arguments { + flags= pvars=() specs=() + while (($#)); do + local arg=$1; shift + case $arg in + (--) + ble/array#push specs "$@" + break ;; + (-) + ble/util/print "bleopt: unrecognized argument '$arg'." >&2 + flags=E$flags ;; + (--*) + bleopt/.read-arguments/process-option "${arg:2}" ;; + (-*) + local i c + for ((i=1;i<${#arg};i++)); do + c=${arg:i:1} + case $c in + (r) bleopt/.read-arguments/process-option reset ;; + (u) bleopt/.read-arguments/process-option changed ;; + (I) bleopt/.read-arguments/process-option initialize ;; + (*) + ble/util/print "bleopt: unrecognized option '-$c'." >&2 + flags=E$flags ;; + esac + done ;; + (*) + if local rex='^([_a-zA-Z0-9@*?]+)(:?=|$)(.*)'; [[ $arg =~ $rex ]]; then + local name=${BASH_REMATCH[1]#bleopt_} + local var=bleopt_$name + local op=${BASH_REMATCH[2]} + local value=${BASH_REMATCH[3]} + if [[ $op == ':=' ]]; then + if [[ $var == *[@*?]* ]]; then + ble/util/print "bleopt: \`${var#bleopt_}': wildcard cannot be used in the definition." >&2 + flags=E$flags + continue + fi + else + local ret; bleopt/expand-variable-pattern "$var" + var=() + local v i=0 + for v in "${ret[@]}"; do + ble/is-function "bleopt/obsolete:${v#bleopt_}" && continue + var[i++]=$v + done + [[ ${#var[@]} == 0 ]] && var=("${ret[@]}") + if ((${#var[@]}==0)); then + ble/util/print "bleopt: option \`$name' not found" >&2 + flags=E$flags + continue + fi + fi + if [[ $op ]]; then + var=("${var[@]}") # #D1570: WA bash-3.0 ${scal[@]/x} bug + if ((_ble_bash>=40300)) && ! shopt -q compat42; then + ble/array#push specs "${var[@]/%/"=$value"}" # WA #D1570 #D1751 checked + else + ble/array#push specs "${var[@]/%/=$value}" # WA #D1570 #D1738 checked + fi + else + ble/array#push pvars "${var[@]}" + fi + else + ble/util/print "bleopt: unrecognized argument '$arg'" >&2 + flags=E$flags + fi ;; + esac + done +} +function bleopt/changed.predicate { + local cur=$1 def=_ble_opt_def_${1#bleopt_} + [[ ! ${!def+set} || ${!cur} != "${!def}" ]] +} +function bleopt/default { + local def=_ble_opt_def_${1#bleopt_} + ret=${!def} +} +function bleopt { + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_local_adjust" + local flags pvars specs + bleopt/.read-arguments "$@" + if [[ $flags == *E* ]]; then + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_local_leave" + return 2 + elif [[ $flags == *H* ]]; then + ble/util/print-lines \ + 'usage: bleopt [OPTION] [NAME|NAME=VALUE|NAME:=VALUE]...' \ + ' Set ble.sh options. Without arguments, this prints all the settings.' \ + '' \ + ' Options' \ + ' --help Print this help.' \ + ' -r, --reset Reset options to the default values' \ + ' -I, --initialize Re-initialize settings' \ + ' -u, --changed Only select changed options' \ + ' --color[=always|never|auto]' \ + ' Change color settings.' \ + '' \ + ' Arguments' \ + ' NAME Print the value of the option.' \ + ' NAME=VALUE Set the value to the option.' \ + ' NAME:=VALUE Set or create the value to the option.' \ + '' \ + ' NAME can contain "@", "*", and "?" as wildcards.' \ + '' + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_local_leave" + return 0 + fi + if ((${#pvars[@]}==0&&${#specs[@]}==0)); then + local var ip=0 + for var in "${!bleopt_@}"; do + ble/is-function "bleopt/obsolete:${var#bleopt_}" && continue + pvars[ip++]=$var + done + fi + [[ $flags == *u* ]] && + ble/array#filter pvars bleopt/changed.predicate + if [[ $flags == *r* ]]; then + local var + for var in "${pvars[@]}"; do + local name=${var#bleopt_} + ble/is-function bleopt/obsolete:"$name" && continue + local def=_ble_opt_def_$name + [[ ${!def+set} && ${!var-} != "${!def}" ]] && + ble/array#push specs "$var=${!def}" + done + pvars=() + elif [[ $flags == *I* ]]; then + local var + for var in "${pvars[@]}"; do + bleopt/reinitialize "${var#bleopt_}" + done + pvars=() + fi + if ((${#specs[@]})); then + local spec + for spec in "${specs[@]}"; do + local var=${spec%%=*} value=${spec#*=} + [[ ${!var+set} && ${!var} == "$value" ]] && continue + if ble/is-function bleopt/check:"${var#bleopt_}"; then + local bleopt_source=${BASH_SOURCE[1]} + local bleopt_lineno=${BASH_LINENO[0]} + if ! bleopt/check:"${var#bleopt_}"; then + flags=E$flags + continue + fi + fi + builtin eval -- "$var=\"\$value\"" + done + fi + if ((${#pvars[@]})); then + local sgr0= sgr1= sgr2= sgr3= + if [[ $flags == *c* || $flags != *n* && -t 1 ]]; then + local ret + ble/color/face2sgr command_function; sgr1=$ret + ble/color/face2sgr syntax_varname; sgr2=$ret + ble/color/face2sgr syntax_quoted; sgr3=$ret + sgr0=$_ble_term_sgr0 + fi + local var + for var in "${pvars[@]}"; do + local ret + ble/string#quote-word "${!var}" sgrq="$sgr3":sgr0="$sgr0" + ble/util/print "${sgr1}bleopt$sgr0 ${sgr2}${var#bleopt_}$sgr0=$ret" + done + fi + [[ $flags != *E* ]] + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_local_return" +} +function bleopt/declare/.check-renamed-option { + var=bleopt_$2 + local sgr0= sgr1= sgr2= sgr3= + if [[ -t 2 ]]; then + sgr0=$_ble_term_sgr0 + sgr1=${_ble_term_setaf[2]} + sgr2=${_ble_term_setaf[1]}$_ble_term_bold + sgr3=${_ble_term_setaf[4]}$_ble_term_bold + fi + local locate=$sgr1${BASH_SOURCE[3]-'(stdin)'}:${BASH_LINENO[2]}$sgr0 + ble/util/print "$locate (bleopt): The option '$sgr2$1$sgr0' has been renamed. Please use '$sgr3$2$sgr0' instead." >&2 + if ble/is-function bleopt/check:"$2"; then + bleopt/check:"$2" + return "$?" + fi + return 0 +} +function bleopt/declare { + local type=$1 name=bleopt_$2 default_value=$3 + case $type in + (-o) + builtin eval -- "$name='[obsolete: renamed to $3]'" + builtin eval -- "function bleopt/check:$2 { bleopt/declare/.check-renamed-option $2 $3; }" + builtin eval -- "function bleopt/obsolete:$2 { return 0; }" ;; + (-n) + builtin eval -- "_ble_opt_def_$2=\$3" + builtin eval -- ": \"\${$name:=\$default_value}\"" ;; + (*) + builtin eval -- "_ble_opt_def_$2=\$3" + builtin eval -- ": \"\${$name=\$default_value}\"" ;; + esac + return 0 +} +function bleopt/reinitialize { + local name=$1 + local defname=_ble_opt_def_$name + local varname=bleopt_$name + [[ ${!defname+set} ]] || return 1 + [[ ${!varname} == "${!defname}" ]] && return 0 + ble/is-function bleopt/obsolete:"$name" && return 0 + ble/is-function bleopt/check:"$name" || return 0 + local value=${!varname} + builtin eval -- "$varname=\$$defname" + bleopt/check:"$name" && + builtin eval "$varname=\$value" +} +bleopt/declare -n input_encoding UTF-8 +function bleopt/check:input_encoding { + if ! ble/is-function "ble/encoding:$value/decode"; then + ble/util/print "bleopt: Invalid value input_encoding='$value'." \ + "A function 'ble/encoding:$value/decode' is not defined." >&2 + return 1 + elif ! ble/is-function "ble/encoding:$value/b2c"; then + ble/util/print "bleopt: Invalid value input_encoding='$value'." \ + "A function 'ble/encoding:$value/b2c' is not defined." >&2 + return 1 + elif ! ble/is-function "ble/encoding:$value/c2bc"; then + ble/util/print "bleopt: Invalid value input_encoding='$value'." \ + "A function 'ble/encoding:$value/c2bc' is not defined." >&2 + return 1 + elif ! ble/is-function "ble/encoding:$value/generate-binder"; then + ble/util/print "bleopt: Invalid value input_encoding='$value'." \ + "A function 'ble/encoding:$value/generate-binder' is not defined." >&2 + return 1 + elif ! ble/is-function "ble/encoding:$value/is-intermediate"; then + ble/util/print "bleopt: Invalid value input_encoding='$value'." \ + "A function 'ble/encoding:$value/is-intermediate' is not defined." >&2 + return 1 + fi + if [[ $bleopt_input_encoding != "$value" ]]; then + local bleopt_input_encoding=$value + ble/decode/readline/rebind + fi + return 0 +} +bleopt/declare -v internal_stackdump_enabled 0 +bleopt/declare -n openat_base 30 +bleopt/declare -v pager '' +bleopt/declare -v editor '' +shopt -s checkwinsize +function ble/util/setexit { return "$1"; } +_ble_util_upvar_setup='local var=ret ret; [[ $1 == -v ]] && var=$2 && shift 2' +_ble_util_upvar='local "${var%%\[*\]}" && ble/util/upvar "$var" "$ret"' +if ((_ble_bash>=50000)); then + function ble/util/unlocal { + if shopt -q localvar_unset; then + shopt -u localvar_unset + builtin unset -v "$@" + shopt -s localvar_unset + else + builtin unset -v "$@" + fi + } + function ble/util/upvar { ble/util/unlocal "${1%%\[*\]}" && builtin eval "$1=\"\$2\""; } + function ble/util/uparr { ble/util/unlocal "$1" && builtin eval "$1=(\"\${@:2}\")"; } +else + function ble/util/unlocal { builtin unset -v "$@"; } + function ble/util/upvar { builtin unset -v "${1%%\[*\]}" && builtin eval "$1=\"\$2\""; } + function ble/util/uparr { builtin unset -v "$1" && builtin eval "$1=(\"\${@:2}\")"; } +fi +function ble/util/save-vars { + local __ble_name __ble_prefix=$1; shift + for __ble_name; do + if ble/is-array "$__ble_name"; then + builtin eval "$__ble_prefix$__ble_name=(\"\${$__ble_name[@]}\")" + else + builtin eval "$__ble_prefix$__ble_name=\"\$$__ble_name\"" + fi + done +} +function ble/util/restore-vars { + local __ble_name __ble_prefix=$1; shift + for __ble_name; do + if ble/is-array "$__ble_prefix$__ble_name"; then + builtin eval "$__ble_name=(\${$__ble_prefix$__ble_name[@]+\"\${$__ble_prefix$__ble_name[@]}\"})" + else + builtin eval "$__ble_name=\"\${$__ble_prefix$__ble_name-}\"" + fi + done +} +if ((_ble_bash>=40400)); then + function ble/variable#get-attr { + if [[ $1 == -v ]]; then + builtin eval -- "$2=\${!3@a}" + else + attr=${!1@a} + fi + } + function ble/variable#has-attr { [[ ${!1@a} == *["$2"]* ]]; } +else + function ble/variable#get-attr { + if [[ $1 == -v ]]; then + local __ble_var=$2 __ble_tmp=$3 + else + local __ble_var=attr __ble_tmp=$1 + fi + ble/util/assign __ble_tmp 'declare -p "$__ble_tmp" 2>/dev/null' + local rex='^declare -([a-zA-Z]*)'; [[ $__ble_tmp =~ $rex ]] + builtin eval -- "$__ble_var=\${BASH_REMATCH[1]-}" + return 0 + } + function ble/variable#has-attr { + local __ble_tmp=$1 + ble/util/assign __ble_tmp 'declare -p "$__ble_tmp" 2>/dev/null' + local rex='^declare -([a-zA-Z]*)' + [[ $__ble_tmp =~ $rex && ${BASH_REMATCH[1]} == *["$2"]* ]] + } +fi +function ble/is-inttype { ble/variable#has-attr "$1" i; } +function ble/is-readonly { ble/variable#has-attr "$1" r; } +function ble/is-transformed { ble/variable#has-attr "$1" luc; } +function ble/variable#is-declared { [[ ${!1+set} ]] || declare -p "$1" &>/dev/null; } +function ble/variable#is-global/.test { ! local "$1"; } +function ble/variable#is-global { + (builtin readonly "$1"; ble/variable#is-global/.test "$1") 2>/dev/null +} +function ble/variable#copy-state { + local src=$1 dst=$2 + if [[ ${!src+set} ]]; then + builtin eval -- "$dst=\${$src}" + else + builtin unset -v "$dst[0]" 2>/dev/null || builtin unset -v "$dst" + fi +} +_ble_array_prototype=() +function ble/array#reserve-prototype { + local n=$1 i + for ((i=${#_ble_array_prototype[@]};i=40400)); then + function ble/is-array { [[ ${!1@a} == *a* ]]; } + function ble/is-assoc { [[ ${!1@a} == *A* ]]; } +else + function ble/is-array { + local "decl$1" + ble/util/assign "decl$1" "declare -p $1" 2>/dev/null || return 1 + local rex='^declare -[b-zAB-Z]*a' + builtin eval "[[ \$decl$1 =~ \$rex ]]" + } + function ble/is-assoc { + local "decl$1" + ble/util/assign "decl$1" "declare -p $1" 2>/dev/null || return 1 + local rex='^declare -[ab-zB-Z]*A' + builtin eval "[[ \$decl$1 =~ \$rex ]]" + } + ((_ble_bash>=40000)) || + function ble/is-assoc { false; } +fi +function ble/array#set { builtin eval "$1=(\"\${@:2}\")"; } +if ((_ble_bash>=40000)); then + function ble/array#push { + builtin eval "$1+=(\"\${@:2}\")" + } +elif ((_ble_bash>=30100)); then + function ble/array#push { + IFS=$_ble_term_IFS builtin eval "$1+=(\"\${@:2}\")" + } +else + function ble/array#push { + while (($#>=2)); do + builtin eval -- "$1[\${#$1[@]}]=\"\$2\"" + set -- "$1" "${@:3}" + done + } +fi +function ble/array#pop { + builtin eval "local i$1=\$((\${#$1[@]}-1))" + if ((i$1>=0)); then + builtin eval "ret=\${$1[i$1]}" + builtin unset -v "$1[i$1]" + return 0 + else + ret= + return 1 + fi +} +function ble/array#unshift { + builtin eval -- "$1=(\"\${@:2}\" \"\${$1[@]}\")" +} +function ble/array#shift { + builtin eval -- "$1=(\"\${$1[@]:$((${2:-1}))}\")" +} +function ble/array#reverse { + builtin eval " + set -- \"\${$1[@]}\"; $1=() + local e$1 i$1=\$# + for e$1; do $1[--i$1]=\"\$e$1\"; done" +} +function ble/array#insert-at { + builtin eval "$1=(\"\${$1[@]::$2}\" \"\${@:3}\" \"\${$1[@]:$2}\")" +} +function ble/array#insert-after { + local _ble_local_script=' + local iNAME=0 eNAME aNAME= + for eNAME in "${NAME[@]}"; do + ((iNAME++)) + [[ $eNAME == "$2" ]] && aNAME=iNAME && break + done + [[ $aNAME ]] && ble/array#insert-at "$1" "$aNAME" "${@:3}" + '; builtin eval -- "${_ble_local_script//NAME/$1}" +} +function ble/array#insert-before { + local _ble_local_script=' + local iNAME=0 eNAME aNAME= + for eNAME in "${NAME[@]}"; do + [[ $eNAME == "$2" ]] && aNAME=iNAME && break + ((iNAME++)) + done + [[ $aNAME ]] && ble/array#insert-at "$1" "$aNAME" "${@:3}" + '; builtin eval -- "${_ble_local_script//NAME/$1}" +} +function ble/array#filter/.eval { + builtin eval -- "$_ble_local_predicate_cmd" +} +function ble/array#filter { + local _ble_local_predicate=$2 + if [[ $2 == *'$'* ]] || ! ble/is-function "$2"; then + _ble_local_predicate=ble/array#filter/.eval + _ble_local_predicate_cmd=$2 + fi + local _ble_local_script=' + local -a aNAME=() eNAME + for eNAME in "${NAME[@]}"; do + "$_ble_local_predicate" "$eNAME" && ble/array#push "aNAME" "$eNAME" + done + NAME=("${aNAME[@]}") + '; builtin eval -- "${_ble_local_script//NAME/$1}" +} +function ble/array#filter/not.predicate { ! "$_ble_local_pred" "$1"; } +function ble/array#remove-if { + local _ble_local_pred=$2 + ble/array#filter "$1" ble/array#filter/not.predicate +} +function ble/array#filter/regex.predicate { [[ $1 =~ $_ble_local_rex ]]; } +function ble/array#filter-by-regex { + local _ble_local_rex=$2 + local LC_ALL= LC_COLLATE=C 2>/dev/null + ble/array#filter "$1" ble/array#filter/regex.predicate + ble/util/unlocal LC_COLLATE LC_ALL 2>/dev/null +} +function ble/array#remove-by-regex { + local _ble_local_rex=$2 + local LC_ALL= LC_COLLATE=C 2>/dev/null + ble/array#remove-if "$1" ble/array#filter/regex.predicate + ble/util/unlocal LC_COLLATE LC_ALL 2>/dev/null +} +function ble/array#filter/glob.predicate { [[ $1 == $_ble_local_glob ]]; } +function ble/array#filter-by-glob { + local _ble_local_glob=$2 + local LC_ALL= LC_COLLATE=C 2>/dev/null + ble/array#filter "$1" ble/array#filter/glob.predicate + ble/util/unlocal LC_COLLATE LC_ALL 2>/dev/null +} +function ble/array#remove-by-glob { + local _ble_local_glob=$2 + local LC_ALL= LC_COLLATE=C 2>/dev/null + ble/array#remove-if "$1" ble/array#filter/glob.predicate + ble/util/unlocal LC_COLLATE LC_ALL 2>/dev/null +} +function ble/array#remove/.predicate { [[ $1 != "$_ble_local_value" ]]; } +function ble/array#remove { + local _ble_local_value=$2 + ble/array#filter "$1" ble/array#remove/.predicate +} +function ble/array#index { + local _ble_local_script=' + local eNAME iNAME=0 + for eNAME in "${NAME[@]}"; do + if [[ $eNAME == "$2" ]]; then ret=$iNAME; return 0; fi + ((++iNAME)) + done + ret=-1; return 1 + '; builtin eval -- "${_ble_local_script//NAME/$1}" +} +function ble/array#last-index { + local _ble_local_script=' + local eNAME iNAME=${#NAME[@]} + while ((iNAME--)); do + [[ ${NAME[iNAME]} == "$2" ]] && { ret=$iNAME; return 0; } + done + ret=-1; return 1 + '; builtin eval -- "${_ble_local_script//NAME/$1}" +} +function ble/array#remove-at { + local _ble_local_script=' + builtin unset -v "NAME[$2]" + NAME=("${NAME[@]}") + '; builtin eval -- "${_ble_local_script//NAME/$1}" +} +function ble/array#fill-range { + ble/array#reserve-prototype "$(($3-$2))" + local _ble_local_script=' + local -a sNAME; sNAME=("${_ble_array_prototype[@]::$3-$2}") + NAME=("${NAME[@]::$2}" "${sNAME[@]/#/$4}" "${NAME[@]:$3}")' # WA #D1570 #D1738 checked + ((_ble_bash>=40300)) && ! shopt -q compat42 && + _ble_local_script=${_ble_local_script//'$4'/'"$4"'} + builtin eval -- "${_ble_local_script//NAME/$1}" +} +function ble/idict#replace { + local _ble_local_script=' + local iNAME=0 extNAME=1 + for iNAME in "${!NAME[@]}"; do + [[ ${NAME[iNAME]} == "$2" ]] || continue + extNAME=0 + if (($#>=3)); then + NAME[iNAME]=$3 + else + builtin unset -v '\''NAME[iNAME]'\'' + fi + done + return "$extNAME" + '; builtin eval -- "${_ble_local_script//NAME/$1}" +} +function ble/idict#copy { + local _ble_script=' + '$1'=() + local i'$1$2' + for i'$1$2' in "${!'$2'[@]}"; do + '$1'[i'$1$2']=${'$2'[i'$1$2']} + done' + builtin eval -- "$_ble_script" +} +_ble_string_prototype=' ' +function ble/string#reserve-prototype { + local n=$1 c + for ((c=${#_ble_string_prototype};c${#b})) && local a=$b b=$a + b=${b::${#a}} + if [[ $a == "$b" ]]; then + ret=$a + return 0 + fi + local l=0 u=${#a} m + while ((l+1${#b})) && local a=$b b=$a + b=${b:${#b}-${#a}} + if [[ $a == "$b" ]]; then + ret=$a + return 0 + fi + local l=0 u=${#a} m + while ((l+1=40000)); then + function ble/string#split-lines { + mapfile -t "$1" <<< "$2" + } +else + function ble/string#split-lines { + ble/util/mapfile "$1" <<< "$2" + } +fi +function ble/string#count-char { + local text=$1 char=$2 + text=${text//[!"$char"]} + ret=${#text} +} +function ble/string#count-string { + local text=${1//"$2"} + ((ret=(${#1}-${#text})/${#2})) +} +function ble/string#index-of { + local haystack=$1 needle=$2 count=${3:-1} + ble/string#repeat '*"$needle"' "$count"; local pattern=$ret + builtin eval "local transformed=\${haystack#$pattern}" + ((ret=${#haystack}-${#transformed}-${#needle}, + ret<0&&(ret=-1),ret>=0)) +} +function ble/string#last-index-of { + local haystack=$1 needle=$2 count=${3:-1} + ble/string#repeat '"$needle"*' "$count"; local pattern=$ret + builtin eval "local transformed=\${haystack%$pattern}" + if [[ $transformed == "$haystack" ]]; then + ret=-1 + else + ret=${#transformed} + fi + ((ret>=0)) +} +_ble_util_string_lower_list=abcdefghijklmnopqrstuvwxyz +_ble_util_string_upper_list=ABCDEFGHIJKLMNOPQRSTUVWXYZ +function ble/string#islower { [[ $1 == ["$_ble_util_string_lower_list"] ]]; } +function ble/string#isupper { [[ $1 == ["$_ble_util_string_upper_list"] ]]; } +function ble/string#toggle-case { + local text=$1 ch i + local -a buff + for ((i=0;i<${#text};i++)); do + ch=${text:i:1} + if ble/string#isupper "$ch"; then + ch=${_ble_util_string_upper_list%%"$ch"*} + ch=${_ble_util_string_lower_list:${#ch}:1} + elif ble/string#islower "$ch"; then + ch=${_ble_util_string_lower_list%%"$ch"*} + ch=${_ble_util_string_upper_list:${#ch}:1} + fi + ble/array#push buff "$ch" + done + IFS= builtin eval 'ret="${buff[*]-}"' +} +if ((_ble_bash>=40000)); then + function ble/string#tolower { ret=${1,,}; } + function ble/string#toupper { ret=${1^^}; } +else + function ble/string#tolower { + local i text=$1 ch + local -a buff=() + for ((i=0;i<${#text};i++)); do + ch=${text:i:1} + if ble/string#isupper "$ch"; then + ch=${_ble_util_string_upper_list%%"$ch"*} + ch=${_ble_util_string_lower_list:${#ch}:1} + fi + ble/array#push buff "$ch" + done + IFS= builtin eval 'ret="${buff[*]-}"' + } + function ble/string#toupper { + local i text=$1 ch + local -a buff=() + for ((i=0;i<${#text};i++)); do + ch=${text:i:1} + if ble/string#islower "$ch"; then + ch=${_ble_util_string_lower_list%%"$ch"*} + ch=${_ble_util_string_upper_list:${#ch}:1} + fi + ble/array#push buff "$ch" + done + IFS= builtin eval 'ret="${buff[*]-}"' + } +fi +function ble/string#capitalize { + local tail=$1 + local rex='^[^a-zA-Z0-9]*' + [[ $tail =~ $rex ]] + local out=$BASH_REMATCH + tail=${tail:${#BASH_REMATCH}} + rex='^[a-zA-Z0-9]+[^a-zA-Z0-9]*' + while [[ $tail =~ $rex ]]; do + local rematch=$BASH_REMATCH + ble/string#toupper "${rematch::1}"; out=$out$ret + ble/string#tolower "${rematch:1}" ; out=$out$ret + tail=${tail:${#rematch}} + done + ret=$out$tail +} +function ble/string#trim { + ret=$1 + local rex=$'^[ \t\n]+' + [[ $ret =~ $rex ]] && ret=${ret:${#BASH_REMATCH}} + local rex=$'[ \t\n]+$' + [[ $ret =~ $rex ]] && ret=${ret::${#ret}-${#BASH_REMATCH}} +} +function ble/string#ltrim { + ret=$1 + local rex=$'^[ \t\n]+' + [[ $ret =~ $rex ]] && ret=${ret:${#BASH_REMATCH}} +} +function ble/string#rtrim { + ret=$1 + local rex=$'[ \t\n]+$' + [[ $ret =~ $rex ]] && ret=${ret::${#ret}-${#BASH_REMATCH}} +} +if ((_ble_bash>=50200)); then + function ble/string#escape-characters { + ret=$1 + if [[ $ret == *["$2"]* ]]; then + if [[ ! $3 ]]; then + local patsub_replacement= + shopt -q patsub_replacement && patsub_replacement=1 + shopt -s patsub_replacement + ret=${ret//["$2"]/\\&} # #D1738 patsub_replacement + [[ $patsub_replacement ]] || shopt -u patsub_replacement + else + local chars1=$2 chars2=${3:-$2} + local i n=${#chars1} a b + for ((i=0;i()!^' + [[ $2 != *G* ]] && chars=$chars'*?[' + [[ $2 == *c* ]] && chars=$chars'=:' + [[ $2 == *b* ]] && chars=$chars'{,}' + ble/string#escape-characters "$1" "$chars" + [[ $2 != *[HT]* && $ret == '~'* ]] && ret=\\$ret + [[ $2 != *H* && $ret == '#'* ]] && ret=\\$ret + if [[ $ret == *[$']\n\t']* ]]; then + local a b + a=']' b=\\$a ret=${ret//"$a"/"$b"} + a=$'\n' b="\$'\n'" ret=${ret//"$a"/"$b"} # WA #D1751 checked + a=$'\t' b=$'\\\t' ret=${ret//"$a"/"$b"} + fi + if [[ $2 == *G* ]] && shopt -q extglob; then + local a b + a='!\(' b='!(' ret=${ret//"$a"/"$b"} + a='@\(' b='@(' ret=${ret//"$a"/"$b"} + a='?\(' b='?(' ret=${ret//"$a"/"$b"} + a='*\(' b='*(' ret=${ret//"$a"/"$b"} + a='+\(' b='+(' ret=${ret//"$a"/"$b"} + fi +} +function ble/string#escape-for-display { + local head= tail=$1 opts=$2 + local sgr0= sgr1= + local rex_csi=$'\e\\[[ -?]*[@-~]' + if [[ :$opts: == *:revert:* ]]; then + ble/color/g2sgr "$_ble_color_gflags_Revert" + sgr1=$ret sgr0=$_ble_term_sgr0 + else + if local rex=':sgr1=(('$rex_csi'|[^:])*):'; [[ :$opts: =~ $rex ]]; then + sgr1=${BASH_REMATCH[1]} sgr0=$_ble_term_sgr0 + fi + if local rex=':sgr0=(('$rex_csi'|[^:])*):'; [[ :$opts: =~ $rex ]]; then + sgr0=${BASH_REMATCH[1]} + fi + fi + while [[ $tail ]]; do + if ble/util/isprint+ "$tail"; then + head=$head${BASH_REMATCH} + tail=${tail:${#BASH_REMATCH}} + else + ble/util/s2c "${tail::1}" + local code=$ret + if ((code<32)); then + ble/util/c2s "$((code+64))" + ret=$sgr1^$ret$sgr0 + elif ((code==127)); then + ret=$sgr1^?$sgr0 + elif ((128<=code&&code<160)); then + ble/util/c2s "$((code-64))" + ret=${sgr1}M-^$ret$sgr0 + else + ret=${tail::1} + fi + head=$head$ret + tail=${tail:1} + fi + done + ret=$head +} +if ((_ble_bash>=40400)); then + function ble/string#quote-words { + local IFS=$_ble_term_IFS + ret="${*@Q}" + } + function ble/string#quote-command { + local IFS=$_ble_term_IFS + ret=$1; shift + (($#)) && ret="$ret ${*@Q}" + } +else + function ble/string#quote-words { + local q=\' Q="'\''" IFS=$_ble_term_IFS + ret=("${@//$q/$Q}") + ret=("${ret[@]/%/$q}") # WA #D1570 #D1738 checked + ret="${ret[*]/#/$q}" # WA #D1570 #D1738 checked + } + function ble/string#quote-command { + if (($#<=1)); then + ret=$1 + return 0 + fi + local q=\' Q="'\''" IFS=$_ble_term_IFS + ret=("${@:2}") + ret=("${ret[@]//$q/$Q}") # WA #D1570 #D1738 checked + ret=("${ret[@]/%/$q}") # WA #D1570 #D1738 checked + ret="$1 ${ret[*]/#/$q}" # WA #D1570 #D1738 checked + } +fi +function ble/string#quote-word { + ret=${1-} + local rex_csi=$'\e\\[[ -?]*[@-~]' + local opts=${2-} sgrq= sgr0= + if [[ $opts ]]; then + local rex=':sgrq=(('$rex_csi'|[^:])*):' + if [[ :$opts: =~ $rex ]]; then + sgrq=${BASH_REMATCH[1]} sgr0=$_ble_term_sgr0 + fi + rex=':sgr0=(('$rex_csi'|[^:])*):' + if [[ :$opts: =~ $rex ]]; then + sgr0=${BASH_REMATCH[1]} + elif [[ :$opts: == *:ansi:* ]]; then + sgr0=$'\e[m' + fi + fi + if [[ ! $ret ]]; then + if [[ :$opts: == *:quote-empty:* ]]; then + ret=$sgrq\'\'$sgr0 + fi + return 0 + fi + local chars=$'\a\b\e\f\n\r\t\v\001-\037\177' + if [[ $ret == *[$chars]* ]]; then + ble/string#escape-for-bash-escape-string "$ret" + ret=$sgrq\$\'$ret\'$sgr0 + return 0 + fi + local chars=$_ble_term_IFS'"`$\<>()|&;*?[]!^=:{,}#~' q=\' + if [[ $ret == *["$chars"]* ]]; then + local Q="'$sgr0\'$sgrq'" + ret=$sgrq$q${ret//$q/$Q}$q$sgr0 + ret=${ret#"$sgrq$q$q$sgr0"} ret=${ret%"$sgrq$q$q$sgr0"} + elif [[ $ret == *["$q"]* ]]; then + local Q="\'" + ret=${ret//$q/$Q} + fi +} +function ble/string#match { [[ $1 =~ $2 ]]; } +function ble/string#match-safe/.impl { + local LC_ALL= LC_COLLATE=C + [[ $1 =~ $2 ]] +} +function ble/string#match-safe { + ble/string#match-safe/.impl "$@" 2>/dev/null # suppress locale error #D1440 +} +function ble/string#create-unicode-progress-bar/.block { + local block=$1 + if ((block<=0)); then + ble/util/c2w "$((0x2588))" + ble/string#repeat ' ' "$ret" + elif ((block>=8)); then + ble/util/c2s "$((0x2588))" + ((${#ret}==1)) || ret='*' # LC_CTYPE が非対応の文字の時 + else + ble/util/c2s "$((0x2590-block))" + if ((${#ret}!=1)); then + ble/util/c2w "$((0x2588))" + ble/string#repeat ' ' "$((ret-1))" + ret=$block$ret + fi + fi +} +function ble/string#create-unicode-progress-bar { + local value=$1 max=$2 width=$3 opts=:$4: + local opt_unlimited= + if [[ $opts == *:unlimited:* ]]; then + opt_unlimited=1 + ((value%=max,width--)) + fi + local progress=$((value*8*width/max)) + local progress_fraction=$((progress%8)) progress_integral=$((progress/8)) + local out= + if ((progress_integral)); then + if [[ $opt_unlimited ]]; then + ble/string#create-unicode-progress-bar/.block 0 + else + ble/string#create-unicode-progress-bar/.block 8 + fi + ble/string#repeat "$ret" "$progress_integral" + out=$ret + fi + if ((progress_fraction)); then + if [[ $opt_unlimited ]]; then + ble/string#create-unicode-progress-bar/.block "$progress_fraction" + out=$out$'\e[7m'$ret$'\e[27m' + fi + ble/string#create-unicode-progress-bar/.block "$progress_fraction" + out=$out$ret + ((progress_integral++)) + else + if [[ $opt_unlimited ]]; then + ble/string#create-unicode-progress-bar/.block 8 + out=$out$ret + fi + fi + if ((progress_integral/dev/null # suppress locale error #D1440 +} +function ble/util/substr.impl { + local LC_ALL= LC_CTYPE=C + ret=${1:$2:$3} +} +function ble/util/substr { + ble/util/substr.impl "$@" 2>/dev/null # suppress locale error #D1440 +} +function ble/path#append { + local _ble_local_script='opts=$opts${opts:+:}$2' + _ble_local_script=${_ble_local_script//opts/"$1"} + builtin eval -- "$_ble_local_script" +} +function ble/path#prepend { + local _ble_local_script='opts=$2${opts:+:}$opts' + _ble_local_script=${_ble_local_script//opts/"$1"} + builtin eval -- "$_ble_local_script" +} +function ble/path#remove { + [[ $2 ]] || return 1 + local _ble_local_script=' + opts=:${opts//:/::}: + opts=${opts//:"$2":} + opts=${opts//::/:} opts=${opts#:} opts=${opts%:}' + _ble_local_script=${_ble_local_script//opts/"$1"} + if shopt -q nocasematch 2>/dev/null; then + shopt -u nocasematch + _ble_local_script=$_ble_local_script';shopt -s nocasematch' + fi + builtin eval -- "$_ble_local_script" +} +function ble/path#remove-glob { + [[ $2 ]] || return 1 + local _ble_local_script=' + opts=:${opts//:/::}: + opts=${opts//:$2:} + opts=${opts//::/:} opts=${opts#:} opts=${opts%:}' + _ble_local_script=${_ble_local_script//opts/"$1"} + if shopt -q nocasematch 2>/dev/null; then + shopt -u nocasematch + _ble_local_script=$_ble_local_script';shopt -s nocasematch' + fi + builtin eval -- "$_ble_local_script" +} +function ble/path#contains { + builtin eval "[[ :\${$1}: == *:\"\$2\":* ]]" +} +function ble/opts#has { + local rex=':'$2'[=:]' + [[ :$1: =~ $rex ]] +} +function ble/opts#remove { + ble/path#remove "$@" +} +function ble/opts#append { + ble/util/set "$1" "${!1:+${!1}:}$2" +} +function ble/opts#append-unique { + [[ :${!1}: == *:"$2":* ]] || ble/opts#append "$1" "$2" +} +function ble/opts#extract-first-optarg { + ret= + local rex=':'$2'(=[^:]*)?:' + [[ :$1: =~ $rex ]] || return 1 + if [[ ${BASH_REMATCH[1]} ]]; then + ret=${BASH_REMATCH[1]:1} + elif [[ ${3+set} ]]; then + ret=$3 + fi + return 0 +} +function ble/opts#extract-last-optarg { + ret= + local rex='.*:'$2'(=[^:]*)?:' + [[ :$1: =~ $rex ]] || return 1 + if [[ ${BASH_REMATCH[1]} ]]; then + ret=${BASH_REMATCH[1]:1} + elif [[ ${3+set} ]]; then + ret=$3 + fi + return 0 +} +function ble/opts#extract-all-optargs { + ret=() + local value=:$1: rex=':'$2'(=[^:]*)?(:.*)$' count=0 + while [[ $value =~ $rex ]]; do + ((count++)) + if [[ ${BASH_REMATCH[1]} ]]; then + ble/array#push ret "${BASH_REMATCH[1]:1}" + elif [[ ${3+set} ]]; then + ble/array#push ret "$3" + fi + value=${BASH_REMATCH[2]} + done + ((count)) +} +if ((_ble_bash>=40000)); then + _ble_util_set_declare=(declare -A NAME) + function ble/set#add { builtin eval -- "$1[x\$2]=1"; } + function ble/set#remove { builtin unset -v "$1[x\$2]"; } + function ble/set#contains { builtin eval "[[ \${$1[x\$2]+set} ]]"; } +else + _ble_util_set_declare=(declare NAME) + function ble/set#.escape { + _ble_local_value=${_ble_local_value//$_ble_term_FS/"$_ble_term_FS$_ble_term_FS"} + _ble_local_value=${_ble_local_value//:/"$_ble_term_FS."} + } + function ble/set#add { + local _ble_local_value=$2; ble/set#.escape + ble/path#append "$1" "$_ble_local_value" + } + function ble/set#remove { + local _ble_local_value=$2; ble/set#.escape + ble/path#remove "$1" "$_ble_local_value" + } + function ble/set#contains { + local _ble_local_value=$2; ble/set#.escape + builtin eval "[[ :\$$1: == *:\"\$_ble_local_value\":* ]]" + } +fi +_ble_util_adict_declare='declare NAME NAME_keylist' +function ble/adict#.resolve { + _ble_local_key=$2 + _ble_local_key=${_ble_local_key//$_ble_term_FS/"$_ble_term_FS,"} + _ble_local_key=${_ble_local_key//:/"$_ble_term_FS."} + local keylist=${1}_keylist; keylist=:${!keylist} + local vec=${keylist%%:"$_ble_local_key":*} + if [[ $vec != "$keylist" ]]; then + vec=${vec//[!:]} + _ble_local_index=${#vec} + else + _ble_local_index=-1 + fi +} +function ble/adict#set { + local _ble_local_key _ble_local_index + ble/adict#.resolve "$1" "$2" + if ((_ble_local_index>=0)); then + builtin eval -- "$1[_ble_local_index]=\$3" + else + local _ble_local_script=' + local _ble_local_vec=${NAME_keylist//[!:]} + NAME[${#_ble_local_vec}]=$3 + NAME_keylist=$NAME_keylist$_ble_local_key: + ' + builtin eval -- "${_ble_local_script//NAME/$1}" + fi + return 0 +} +function ble/adict#get { + local _ble_local_key _ble_local_index + ble/adict#.resolve "$1" "$2" + if ((_ble_local_index>=0)); then + builtin eval -- "ret=\${$1[_ble_local_index]}; [[ \${$1[_ble_local_index]+set} ]]" + else + builtin eval -- ret= + return 1 + fi +} +function ble/adict#unset { + local _ble_local_key _ble_local_index + ble/adict#.resolve "$1" "$2" + ((_ble_local_index>=0)) && + builtin eval -- "builtin unset -v '$1[_ble_local_index]'" + return 0 +} +function ble/adict#has { + local _ble_local_key _ble_local_index + ble/adict#.resolve "$1" "$2" + ((_ble_local_index>=0)) && + builtin eval -- "[[ \${$1[_ble_local_index]+set} ]]" +} +function ble/adict#clear { + builtin eval -- "${1}_keylist= $1=()" +} +function ble/adict#keys { + local _ble_local_keylist=${1}_keylist + _ble_local_keylist=${!_ble_local_keylist%:} + ble/string#split ret : "$_ble_local_keylist" + if [[ $_ble_local_keylist == *"$_ble_term_FS"* ]]; then + ret=("${ret[@]//$_ble_term_FS./:}") # WA #D1570 checked + ret=("${ret[@]//$_ble_term_FS,/$_ble_term_FS}") # WA #D1570 #D1738 checked + fi + local _ble_local_keys _ble_local_i _ble_local_ref=$1[_ble_local_i] + _ble_local_keys=("${ret[@]}") ret=() + for _ble_local_i in "${!_ble_local_keys[@]}"; do + [[ ${_ble_local_ref+set} ]] && + ble/array#push ret "${_ble_local_keys[_ble_local_i]}" + done +} +if ((_ble_bash>=40000)); then + _ble_util_dict_declare='declare -A NAME' + function ble/dict#set { builtin eval -- "$1[x\$2]=\$3"; } + function ble/dict#get { builtin eval -- "ret=\${$1[x\$2]-}; [[ \${$1[x\$2]+set} ]]"; } + function ble/dict#unset { builtin eval -- "builtin unset -v '$1[x\$2]'"; } + function ble/dict#has { builtin eval -- "[[ \${$1[x\$2]+set} ]]"; } + function ble/dict#clear { builtin eval -- "$1=()"; } + function ble/dict#keys { builtin eval -- 'ret=("${!'"$1"'[@]}"); ret=("${ret[@]#x}")'; } +else + _ble_util_dict_declare='declare NAME NAME_keylist=' + function ble/dict#set { ble/adict#set "$@"; } + function ble/dict#get { ble/adict#get "$@"; } + function ble/dict#unset { ble/adict#unset "$@"; } + function ble/dict#has { ble/adict#has "$@"; } + function ble/dict#clear { ble/adict#clear "$@"; } + function ble/dict#keys { ble/adict#keys "$@"; } +fi +if ((_ble_bash>=40200)); then + _ble_util_gdict_declare='{ builtin unset -v NAME; declare -gA NAME; NAME=(); }' + function ble/gdict#set { ble/dict#set "$@"; } + function ble/gdict#get { ble/dict#get "$@"; } + function ble/gdict#unset { ble/dict#unset "$@"; } + function ble/gdict#has { ble/dict#has "$@"; } + function ble/gdict#clear { ble/dict#clear "$@"; } + function ble/gdict#keys { ble/dict#keys "$@"; } +elif ((_ble_bash>=40000)); then + _ble_util_gdict_declare='{ if ! ble/is-assoc NAME; then if local _ble_local_test 2>/dev/null; then NAME_keylist=; else builtin unset -v NAME NAME_keylist; declare -A NAME; fi fi; NAME=(); }' + function ble/gdict#.is-adict { + local keylist=${1}_keylist + [[ ${!keylist+set} ]] + } + function ble/gdict#set { if ble/gdict#.is-adict "$1"; then ble/adict#set "$@"; else ble/dict#set "$@"; fi; } + function ble/gdict#get { if ble/gdict#.is-adict "$1"; then ble/adict#get "$@"; else ble/dict#get "$@"; fi; } + function ble/gdict#unset { if ble/gdict#.is-adict "$1"; then ble/adict#unset "$@"; else ble/dict#unset "$@"; fi; } + function ble/gdict#has { if ble/gdict#.is-adict "$1"; then ble/adict#has "$@"; else ble/dict#has "$@"; fi; } + function ble/gdict#clear { if ble/gdict#.is-adict "$1"; then ble/adict#clear "$@"; else ble/dict#clear "$@"; fi; } + function ble/gdict#keys { if ble/gdict#.is-adict "$1"; then ble/adict#keys "$@"; else ble/dict#keys "$@"; fi; } +else + _ble_util_gdict_declare='{ builtin unset -v NAME NAME_keylist; NAME_keylist= NAME=(); }' + function ble/gdict#set { ble/adict#set "$@"; } + function ble/gdict#get { ble/adict#get "$@"; } + function ble/gdict#unset { ble/adict#unset "$@"; } + function ble/gdict#has { ble/adict#has "$@"; } + function ble/gdict#clear { ble/adict#clear "$@"; } + function ble/gdict#keys { ble/adict#keys "$@"; } +fi +function ble/dict/.print { + declare -p "$2" &>/dev/null || return 1 + local ret _ble_local_key _ble_local_value + ble/util/print "builtin eval -- \"\${_ble_util_${1}_declare//NAME/$2}\"" + ble/"$1"#keys "$2" + for _ble_local_key in "${ret[@]}"; do + ble/"$1"#get "$2" "$_ble_local_key" + ble/string#quote-word "$ret" quote-empty + _ble_local_value=$ret + ble/string#quote-word "$_ble_local_key" quote-empty + _ble_local_key=$ret + ble/util/print "ble/$1#set $2 $_ble_local_key $_ble_local_value" + done +} +function ble/dict#print { ble/dict/.print dict "$1"; } +function ble/adict#print { ble/dict/.print adict "$1"; } +function ble/gdict#print { ble/dict/.print gdict "$1"; } +function ble/dict/.copy { + local ret + ble/"$1"#keys "$2" + ble/"$1"#clear "$3" + local _ble_local_key + for _ble_local_key in "${ret[@]}"; do + ble/"$1"#get "$2" "$_ble_local_key" + ble/"$1"#set "$3" "$_ble_local_key" "$ret" + done +} +function ble/dict#cp { ble/dict/.copy dict "$1" "$2"; } +function ble/adict#cp { ble/dict/.copy adict "$1" "$2"; } +function ble/gdict#cp { ble/dict/.copy gdict "$1" "$2"; } +if ((_ble_bash>=40000)); then + function ble/util/readfile { # 155ms for man bash + local -a _ble_local_buffer=() + mapfile _ble_local_buffer < "$2"; local _ble_local_ext=$? + IFS= builtin eval "$1=\"\${_ble_local_buffer[*]-}\"" + return "$_ble_local_ext" + } + function ble/util/mapfile { + mapfile -t "$1" + } +else + function ble/util/readfile { # 465ms for man bash + [[ -r $2 && ! -d $2 ]] || return 1 + local IFS= + ble/bash/read -d '' "$1" < "$2" + return 0 + } + function ble/util/mapfile { + local IFS= + local _ble_local_i=0 _ble_local_val _ble_local_arr; _ble_local_arr=() + while ble/bash/read _ble_local_val || [[ $_ble_local_val ]]; do + _ble_local_arr[_ble_local_i++]=$_ble_local_val + done + builtin eval "$1=(\"\${_ble_local_arr[@]}\")" + } +fi +function ble/util/copyfile { + local src=$1 dst=$2 content + ble/util/readfile content "$1" || return "$?" + ble/util/put "$content" >| "$dst" +} +function ble/util/writearray/.read-arguments { + _ble_local_array= + _ble_local_nlfix= + _ble_local_delim=$'\n' + local flags= + while (($#)); do + local arg=$1; shift + if [[ $flags != *-* && $arg == -* ]]; then + case $arg in + (--nlfix) _ble_local_nlfix=1 ;; + (-d) + if (($#)); then + _ble_local_delim=$1; shift + else + ble/util/print "${FUNCNAME[1]}: '$arg': missing option argument." >&2 + flags=E$flags + fi ;; + (--) flags=-$flags ;; + (*) + ble/util/print "${FUNCNAME[1]}: '$arg': unrecognized option." >&2 + flags=E$flags ;; + esac + else + if local rex='^[_a-zA-Z][_a-zA-Z0-9]*$'; ! [[ $arg =~ $rex ]]; then + ble/util/print "${FUNCNAME[1]}: '$arg': invalid array name." >&2 + flags=E$flags + elif [[ $flags == *A* ]]; then + ble/util/print "${FUNCNAME[1]}: '$arg': an array name has been already specified." >&2 + flags=E$flags + else + _ble_local_array=$arg + flags=A$flags + fi + fi + done + [[ $_ble_local_nlfix ]] && _ble_local_delim=$'\n' + [[ $flags != *E* ]] +} +_ble_bin_awk_libES=' + function s2i_initialize(_, i) { + for (i = 0; i < 16; i++) + xdigit2int[sprintf("%x", i)] = i; + for (i = 10; i < 16; i++) + xdigit2int[sprintf("%X", i)] = i; + } + function s2i(s, base, _, i, n, r) { + if (!base) base = 10; + r = 0; + n = length(s); + for (i = 1; i <= n; i++) + r = r * base + xdigit2int[substr(s, i, 1)]; + return r; + } + function c2s_initialize(_, i, n, buff) { + if (sprintf("%c", 945) == "α") { + C2S_UNICODE_PRINTF_C = 1; + n = split(ENVIRON["__ble_rawbytes"], buff); + for (i = 1; i <= n; i++) + c2s_byte2raw[127 + i] = buff[i]; + } else { + C2S_UNICODE_PRINTF_C = 0; + for (i = 1; i <= 255; i++) + c2s_byte2char[i] = sprintf("%c", i); + } + } + function c2s(code, _, leadbyte_mark, leadbyte_sup, tail) { + if (C2S_UNICODE_PRINTF_C) + return sprintf("%c", code); + leadbyte_sup = 128; # 0x80 + leadbyte_mark = 0; + tail = ""; + while (leadbyte_sup && code >= leadbyte_sup) { + leadbyte_sup /= 2; + leadbyte_mark = leadbyte_mark ? leadbyte_mark / 2 : 65472; # 0xFFC0 + tail = c2s_byte2char[128 + int(code % 64)] tail; + code = int(code / 64); + } + return c2s_byte2char[(leadbyte_mark + code) % 256] tail; + } + function c2s_raw(code, _, ret) { + if (code >= 128 && C2S_UNICODE_PRINTF_C) { + ret = c2s_byte2raw[code]; + if (ret != "") return ret; + } + return sprintf("%c", code); + } + function es_initialize(_, c) { + s2i_initialize(); + c2s_initialize(); + es_control_chars["a"] = "\a"; + es_control_chars["b"] = "\b"; + es_control_chars["t"] = "\t"; + es_control_chars["n"] = "\n"; + es_control_chars["v"] = "\v"; + es_control_chars["f"] = "\f"; + es_control_chars["r"] = "\r"; + es_control_chars["e"] = "\033"; + es_control_chars["E"] = "\033"; + es_control_chars["?"] = "?"; + es_control_chars["'\''"] = "'\''"; + es_control_chars["\""] = "\""; + es_control_chars["\\"] = "\\"; + for (c = 32; c < 127; c++) + es_s2c[sprintf("%c", c)] = c; + } + function es_unescape(s, _, head, c) { + head = ""; + while (match(s, /^[^\\]*\\/)) { + head = head substr(s, 1, RLENGTH - 1); + s = substr(s, RLENGTH + 1); + if ((c = es_control_chars[substr(s, 1, 1)])) { + head = head c; + s = substr(s, 2); + } else if (match(s, /^[0-9]([0-9][0-9]?)?/)) { + head = head c2s_raw(s2i(substr(s, 1, RLENGTH), 8) % 256); + s = substr(s, RLENGTH + 1); + } else if (match(s, /^x[0-9a-fA-F][0-9a-fA-F]?/)) { + head = head c2s_raw(s2i(substr(s, 2, RLENGTH - 1), 16)); + s = substr(s, RLENGTH + 1); + } else if (match(s, /^U[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]([0-9a-fA-F]([0-9a-fA-F][0-9a-fA-F]?)?)?/)) { + head = head c2s(s2i(substr(s, 2, RLENGTH - 1), 16)); + s = substr(s, RLENGTH + 1); + } else if (match(s, /^[uU][0-9a-fA-F]([0-9a-fA-F]([0-9a-fA-F][0-9a-fA-F]?)?)?/)) { + head = head c2s(s2i(substr(s, 2, RLENGTH - 1), 16)); + s = substr(s, RLENGTH + 1); + } else if (match(s, /^c[ -~]/)) { + c = es_s2c[substr(s, 2, 1)]; + head = head c2s(_ble_bash >= 40400 && c == 63 ? 127 : c % 32); + s = substr(s, 3); + } else { + head = head "\\"; + } + } + return head s; + } +' +_ble_bin_awk_libNLFIX=' + function nlfix_begin(_, tmp) { + nlfix_rep_slash = "\\"; + if (AWKTYPE == "xpg4") nlfix_rep_slash = "\\\\"; + nlfix_rep_double_slash = "\\\\"; + sub(/.*/, nlfix_rep_double_slash, tmp); + if (tmp == "\\") nlfix_rep_double_slash = "\\\\\\\\"; + nlfix_indices = ""; + nlfix_index = 0; + } + function nlfix_push(elem, file) { + if (elem ~ /\n/) { + gsub(/\\/, nlfix_rep_double_slash, elem); + gsub(/'\''/, nlfix_rep_slash "'\''", elem); + gsub(/\007/, nlfix_rep_slash "a", elem); + gsub(/\010/, nlfix_rep_slash "b", elem); + gsub(/\011/, nlfix_rep_slash "t", elem); + gsub(/\012/, nlfix_rep_slash "n", elem); + gsub(/\013/, nlfix_rep_slash "v", elem); + gsub(/\014/, nlfix_rep_slash "f", elem); + gsub(/\015/, nlfix_rep_slash "r", elem); + if (file) + printf("$'\''%s'\''\n", elem) > file; + else + printf("$'\''%s'\''\n", elem); + nlfix_indices = nlfix_indices != "" ? nlfix_indices " " nlfix_index : nlfix_index; + } else { + if (file) + printf("%s\n", elem) > file; + else + printf("%s\n", elem); + } + nlfix_index++; + } + function nlfix_end(file) { + if (file) + printf("%s\n", nlfix_indices) > file; + else + printf("%s\n", nlfix_indices); + } +' +_ble_util_writearray_rawbytes= +function ble/util/writearray { + local _ble_local_array + local -x _ble_local_nlfix _ble_local_delim + ble/util/writearray/.read-arguments "$@" || return 2 + local __ble_awk=ble/bin/awk __ble_awktype=$_ble_bin_awk_type + if ble/is-function ble/bin/mawk; then + __ble_awk=ble/bin/mawk __ble_awktype=mawk + elif ble/is-function ble/bin/nawk; then + __ble_awk=ble/bin/nawk __ble_awktype=nawk + fi + if ((!_ble_local_nlfix)) && ! [[ _ble_bash -ge 50200 && $__ble_awktype == [mn]awk ]]; then + if [[ $_ble_local_delim ]]; then + if [[ $_ble_local_delim == *["%\'"]* ]]; then + local __ble_q=\' __ble_Q="'\''" + _ble_local_delim=${_ble_local_delim//'%'/'%%'} + _ble_local_delim=${_ble_local_delim//'\'/'\\'} + _ble_local_delim=${_ble_local_delim//$__ble_q/$__ble_Q} + fi + builtin eval "printf '%s$_ble_local_delim' \"\${$_ble_local_array[@]}\"" + else + builtin eval "printf '%s\0' \"\${$_ble_local_array[@]}\"" + fi + return "$?" + fi + local __ble_function_gensub_dummy= + [[ $__ble_awktype == gawk ]] || + __ble_function_gensub_dummy='function gensub(rex, rep, n, str) { exit 3; }' + if [[ ! $_ble_util_writearray_rawbytes ]]; then + local IFS=$_ble_term_IFS __ble_tmp; __ble_tmp=('\'{2,3}{0..7}{0..7}) + builtin eval "local _ble_util_writearray_rawbytes=\$'${__ble_tmp[*]}'" + fi + local -x __ble_rawbytes=$_ble_util_writearray_rawbytes + local __ble_rex_dq='^"([^\\"]|\\.)*"' + local __ble_rex_es='^\$'\''([^\\'\'']|\\.)*'\''' + local __ble_rex_sq='^'\''([^'\'']|'\'\\\\\'\'')*'\''' + local __ble_rex_normal=$'^[^'$_ble_term_space'$`"'\''()|&;<>\\]' # Note: []{}?*#!~^, @(), +() は quote されていなくても OK とする + declare -p "$_ble_local_array" | "$__ble_awk" -v _ble_bash="$_ble_bash" ' + '"$__ble_function_gensub_dummy"' + BEGIN { + DELIM = ENVIRON["_ble_local_delim"]; + FLAG_NLFIX = ENVIRON["_ble_local_nlfix"]; + if (FLAG_NLFIX) DELIM = "\n"; + IS_GAWK = AWKTYPE == "gawk"; + IS_XPG4 = AWKTYPE == "xpg4"; + REP_SL = "\\"; + if (IS_XPG4) REP_SL = "\\\\"; + es_initialize(); + decl = ""; + } + '"$_ble_bin_awk_libES"' + '"$_ble_bin_awk_libNLFIX"' + function str2rep(str) { + if (IS_XPG4) sub(/\\/, "\\\\\\\\", str); + return str; + } + function unquote_dq(s, _, head) { + if (IS_GAWK) { + return gensub(/\\([$`"\\])/, "\\1", "g", s); + } else { + if (s ~ /\\[$`"\\]/) { + gsub(/\\\$/, "$" , s); + gsub(/\\`/ , "`" , s); + gsub(/\\"/ , "\"", s); + gsub(/\\\\/, "\\", s); + } + return s; + } + } + function unquote_sq(s) { + gsub(/'\'\\\\\'\''/, "'\''", s); + return s; + } + function unquote_dqes(s) { + if (s ~ /^"/) + return unquote_dq(substr(s, 2, length(s) - 2)); + else + return es_unescape(substr(s, 3, length(s) - 3)); + } + function unquote(s) { + if (s ~ /^"/) + return unquote_dq(substr(s, 2, length(s) - 2)); + else if (s ~ /^\$/) + return es_unescape(substr(s, 3, length(s) - 3)); + else if (s ~ /^'\''/) + return unquote_sq(substr(s, 2, length(s) - 2)); + else if (s ~ /^\\/) + return substr(s, 2, 1); + else + return s; + } + function analyze_elements_dq(decl, _, arr, i, n) { + if (decl ~ /^\[[0-9]+\]="([^'$'\1\2''"\n\\]|\\.)*"( \[[0-9]+\]="([^\1\2"\\]|\\.)*")*$/) { + if (IS_GAWK) { + decl = gensub(/\[[0-9]+\]="(([^"\\]|\\.)*)" ?/, "\\1\001", "g", decl); + sub(/\001$/, "", decl); + decl = gensub(/\\([\\$"`])/, "\\1", decl); + } else { + gsub(/\[[0-9]+\]="([^"\\]|\\.)*" /, "&\001", decl); + gsub(/" \001\[[0-9]+\]="/, "\001", decl); + sub(/^\[[0-9]+\]="/, "", decl); + sub(/"$/, "", decl); + gsub(/\\\\/, "\002", decl); + gsub(/\\\$/, "$", decl); + gsub(/\\"/, "\"", decl); + gsub(/\\`/, "`", decl); + gsub(/\002/, REP_SL, decl); + } + if (DELIM != "") { + gsub(/\001/, str2rep(DELIM), decl); + printf("%s", decl DELIM); + } else { + n = split(decl, arr, /\001/); + for (i = 1; i <= n; i++) + printf("%s%c", arr[i], 0); + } + if (FLAG_NLFIX) printf("\n"); + return 1; + } + return 0; + } + function _process_elem(elem) { + if (FLAG_NLFIX) { + nlfix_push(elem); + } else if (DELIM != "") { + printf("%s", elem DELIM); + } else { + printf("%s%c", elem, 0); + } + } + function analyze_elements_general(decl, _, arr, i, n, str, elem, m) { + if (FLAG_NLFIX) + nlfix_begin(); + n = split(decl, arr, /\]=/); + str = " " arr[1]; + elem = ""; + first = 1; + for (i = 2; i <= n; i++) { + str = str "]=" arr[i]; + if (sub(/^ \[[0-9]+\]=/, "", str)) { + if (first) + first = 0; + else + _process_elem(elem); + elem = ""; + } + if (match(str, /('"$__ble_rex_dq"'|'"$__ble_rex_es"') /)) { + mlen = RLENGTH; + elem = elem unquote_dqes(substr(str, 1, mlen - 1)); + str = substr(str, mlen); + continue; + } else if (i == n || str !~ /^[\$"]/) { + while (match(str, /'"$__ble_rex_dq"'|'"$__ble_rex_es"'|'"$__ble_rex_sq"'|'"$__ble_rex_normal"'|^\\./)) { + mlen = RLENGTH; + elem = elem unquote(substr(str, 1, mlen)); + str = substr(str, mlen + 1); + } + } + } + _process_elem(elem); + if (FLAG_NLFIX) + nlfix_end(); + return 1; + } + function process_declaration(decl) { + sub(/^declare +(-[-aAilucnrtxfFgGI]+ +)?(-- +)?/, "", decl); + if (decl ~ /^([_a-zA-Z][_a-zA-Z0-9]*)='\''\(.*\)'\''$/) { + sub(/(=)'\''\(/, "=(", decl); + sub(/\)'\''$/, ")", decl); + gsub(/'\'\\\\\'\''/, "'\''", decl); + } + if (_ble_bash < 30100) gsub(/\\\n/, "\n", decl); + if (_ble_bash < 40400) { + gsub(/\001\001/, "\001", decl); + gsub(/\001\177/, "\177", decl); + } + sub(/^([_a-zA-Z][_a-zA-Z0-9]*)=\(['"$_ble_term_space"']*/, "", decl); + sub(/['"$_ble_term_space"']*\)['"$_ble_term_space"']*$/, "", decl); + if (decl == "") return 1; + if (AWKTYPE != "mawk" && analyze_elements_dq(decl)) return 1; + return analyze_elements_general(decl); + } + { decl = decl ? decl "\n" $0: $0; } + END { process_declaration(decl); } + ' +} +function ble/util/readarray { + local _ble_local_array + local -x _ble_local_nlfix _ble_local_delim + ble/util/writearray/.read-arguments "$@" || return 2 + if ((_ble_bash>=40400)); then + local _ble_local_script=' + mapfile -t -d "$_ble_local_delim" NAME' + elif ((_ble_bash>=40000)) && [[ $_ble_local_delim == $'\n' ]]; then + local _ble_local_script=' + mapfile -t NAME' + else + local _ble_local_script=' + local IFS= NAMEI=0; NAME=() + while ble/bash/read -d "$_ble_local_delim" "NAME[NAMEI++]"; do :; done' + fi + if [[ $_ble_local_nlfix ]]; then + _ble_local_script=$_ble_local_script' + local NAMEN=${#NAME[@]} NAMEF NAMEI + if ((NAMEN--)); then + ble/string#split-words NAMEF "${NAME[NAMEN]}" + builtin unset -v "NAME[NAMEN]" + for NAMEI in "${NAMEF[@]}"; do + builtin eval -- "NAME[NAMEI]=${NAME[NAMEI]}" + done + fi' + fi + builtin eval -- "${_ble_local_script//NAME/$_ble_local_array}" +} +_ble_util_assign_base=$_ble_base_run/$$.util.assign.tmp +_ble_util_assign_level=0 +if ((_ble_bash>=40000)); then + function ble/util/assign/mktmp { + _ble_local_tmpfile=$_ble_util_assign_base.$((_ble_util_assign_level++)) + ((BASH_SUBSHELL)) && _ble_local_tmpfile=$_ble_local_tmpfile.$BASHPID + } +else + function ble/util/assign/mktmp { + _ble_local_tmpfile=$_ble_util_assign_base.$((_ble_util_assign_level++)) + ((BASH_SUBSHELL)) && _ble_local_tmpfile=$_ble_local_tmpfile.$RANDOM + } +fi +function ble/util/assign/rmtmp { + ((_ble_util_assign_level--)) + if ((BASH_SUBSHELL)); then + printf 'caller %s\n' "${FUNCNAME[@]}" >| "$_ble_local_tmpfile" + else + >| "$_ble_local_tmpfile" + fi +} +if ((_ble_bash>=50300)); then + function ble/util/assign { + builtin eval "$1=\${ builtin eval -- \"\$2\"; }" + } +elif ((_ble_bash>=40000)); then + function ble/util/assign { + local _ble_local_tmpfile; ble/util/assign/mktmp + builtin eval -- "$2" >| "$_ble_local_tmpfile" + local _ble_local_ret=$? _ble_local_arr= + mapfile -t _ble_local_arr < "$_ble_local_tmpfile" + ble/util/assign/rmtmp + IFS=$'\n' builtin eval "$1=\"\${_ble_local_arr[*]}\"" + return "$_ble_local_ret" + } +else + function ble/util/assign { + local _ble_local_tmpfile; ble/util/assign/mktmp + builtin eval -- "$2" >| "$_ble_local_tmpfile" + local _ble_local_ret=$? IFS= + ble/bash/read -d '' "$1" < "$_ble_local_tmpfile" + ble/util/assign/rmtmp + builtin eval "$1=\${$1%\$_ble_term_nl}" + return "$_ble_local_ret" + } +fi +if ((_ble_bash>=40000)); then + function ble/util/assign-array { + local _ble_local_tmpfile; ble/util/assign/mktmp + builtin eval -- "$2" >| "$_ble_local_tmpfile" + local _ble_local_ret=$? + mapfile -t "$1" < "$_ble_local_tmpfile" + ble/util/assign/rmtmp + return "$_ble_local_ret" + } +else + function ble/util/assign-array { + local _ble_local_tmpfile; ble/util/assign/mktmp + builtin eval -- "$2" >| "$_ble_local_tmpfile" + local _ble_local_ret=$? + ble/util/mapfile "$1" < "$_ble_local_tmpfile" + ble/util/assign/rmtmp + return "$_ble_local_ret" + } +fi +if ! ((_ble_bash>=40400)); then + function ble/util/assign-array0 { + local _ble_local_tmpfile; ble/util/assign/mktmp + builtin eval -- "$2" >| "$_ble_local_tmpfile" + local _ble_local_ret=$? + mapfile -d '' -t "$1" < "$_ble_local_tmpfile" + ble/util/assign/rmtmp + return "$_ble_local_ret" + } +else + function ble/util/assign-array0 { + local _ble_local_tmpfile; ble/util/assign/mktmp + builtin eval -- "$2" >| "$_ble_local_tmpfile" + local _ble_local_ret=$? + local IFS= i=0 _ble_local_arr + while ble/bash/read -d '' "_ble_local_arr[i++]"; do :; done < "$_ble_local_tmpfile" + ble/util/assign/rmtmp + [[ ${_ble_local_arr[--i]} ]] || builtin unset -v "_ble_local_arr[i]" + ble/util/unlocal i IFS + builtin eval "$1=(\"\${_ble_local_arr[@]}\")" + return "$_ble_local_ret" + } +fi +function ble/util/assign.has-output { + local _ble_local_tmpfile; ble/util/assign/mktmp + builtin eval -- "$1" >| "$_ble_local_tmpfile" + [[ -s $_ble_local_tmpfile ]] + local _ble_local_ret=$? + ble/util/assign/rmtmp + return "$_ble_local_ret" +} +function ble/util/assign-words { + ble/util/assign "$1" "$2" + ble/string#split-words "$1" "${!1}" +} +ble/bin/awk/.instantiate +if ((_ble_bash>=30200)); then + function ble/is-function { + declare -F -- "$1" &>/dev/null + } +else + function ble/is-function { + local type + ble/util/type type "$1" + [[ $type == function ]] + } +fi +if ((_ble_bash>=30200)); then + function ble/function#getdef { + local name=$1 + ble/is-function "$name" || return 1 + if [[ -o posix ]]; then + ble/util/assign def 'builtin type -- "$name"' + def=${def#*$'\n'} + else + ble/util/assign def 'declare -f -- "$name"' + fi + } +else + function ble/function#getdef { + local name=$1 + ble/is-function "$name" || return 1 + ble/util/assign def 'builtin type -- "$name"' + def=${def#*$'\n'} + } +fi +function ble/function#evaldef { + ble/base/evaldef "$1" +} +builtin eval -- "${_ble_util_gdict_declare//NAME/_ble_util_function_traced}" +function ble/function#trace { + local func + for func; do + declare -ft -- "$func" &>/dev/null || continue + ble/gdict#set _ble_util_function_traced "$func" 1 + done +} +function ble/function#has-trace { + ble/gdict#has _ble_util_function_traced "$1" +} +function ble/function#has-attr { + local __ble_tmp=$1 + ble/util/assign-array __ble_tmp 'declare -pf -- "$__ble_tmp" 2>/dev/null' + local nline=${#__ble_tmp[@]} + ((nline)) && + ble/string#match "${__ble_tmp[nline-1]}" '^declare -([a-zA-Z]*)' && + [[ ${BASH_REMATCH[1]} == *["$2"]* ]] +} +function ble/function/is-global-trace-context { + local func depth=1 ndepth=${#FUNCNAME[*]} + for func in "${FUNCNAME[@]:1}"; do + local src=${BASH_SOURCE[depth]} + [[ $- == *T* && ( $func == ble || $func == ble[-/]* || $func == source && $src == "$_ble_base_blesh_raw" ) ]] || + [[ $func == source && depth -eq ndepth-1 && BASH_LINENO[depth] -eq 0 && ( ${src##*/} == .bashrc || ${src##*/} == .bash_profile || ${src##*/} == .profile ) ]] || + ble/gdict#has _ble_util_function_traced "$func" || return 1 + ((depth++)) + done + return 0 +} +function ble/function#try { + local lastexit=$? + ble/is-function "$1" || return 127 + ble/util/setexit "$lastexit" + "$@" +} +function ble/function#get-source-and-lineno { + local func=$1 ret unset_extdebug= + shopt -q extdebug || { unset_extdebug=1; shopt -s extdebug; } + ble/util/assign ret 'declare -F -- "$func" 2>/dev/null'; local ext=$? + [[ ! $unset_extdebug ]] || shopt -u extdebug + if ((ext==0)); then + ret=${ret#*' '} + lineno=${ret%%' '*} + source=${ret#*' '} + [[ $lineno && ! ${lineno//[0-9]} && $source ]] || return 1 + fi + return "$ext" +} +function ble/function#advice/do { + ble/util/setexit "$advice_lastexit" "$advice_lastarg" + ble/function#advice/original:"${ADVICE_WORDS[@]}" + ADVICE_EXIT=$? +} +function ble/function#advice/.proc { + local advice_lastexit=$? advice_lastarg=$_ + local ADVICE_WORDS ADVICE_EXIT=127 + ADVICE_WORDS=("$@") + local -a ADVICE_FUNCNAME=() + local func + for func in "${FUNCNAME[@]}"; do + [[ $func == ble/function#advice/* ]] || + ble/array#push ADVICE_FUNCNAME "$func" + done + ble/util/unlocal func + ble/function#try "ble/function#advice/before:$1" + if ble/is-function "ble/function#advice/around:$1"; then + "ble/function#advice/around:$1" + else + ble/function#advice/do + fi + ble/function#try "ble/function#advice/after:$1" + return "$ADVICE_EXIT" +} +function ble/function#advice { + local type=$1 name=$2 proc=$3 + if ! ble/is-function "$name"; then + local t=; ble/util/type t "$name" + case $t in + (builtin|file) builtin eval "function $name { : ZBe85Oe28nBdg; command $name \"\$@\"; }" ;; + (*) + ble/util/print "ble/function#advice: $name is not a function." >&2 + return 1 ;; + esac + fi + local def; ble/function#getdef "$name" + case $type in + (remove) + if [[ $def == *'ble/function#advice/.proc'* ]]; then + ble/function#getdef "ble/function#advice/original:$name" + if [[ $def ]]; then + if [[ $def == *ZBe85Oe28nBdg* ]]; then + builtin unset -f "$name" + else + ble/function#evaldef "${def#*:}" + fi + fi + fi + builtin unset -f ble/function#advice/{before,after,around,original}:"$name" 2>/dev/null + return 0 ;; + (before|after|around) + if [[ $def != *'ble/function#advice/.proc'* ]]; then + ble/function#evaldef "ble/function#advice/original:$def" + builtin eval "function $name { ble/function#advice/.proc \"\$FUNCNAME\" \"\$@\"; }" + fi + local q=\' Q="'\''" + builtin eval "ble/function#advice/$type:$name() { builtin eval '${proc//$q/$Q}'; }" + return 0 ;; + (*) + ble/util/print "ble/function#advice unknown advice type '$type'" >&2 + return 2 ;; + esac +} +function ble/function#push { + local name=$1 proc=$2 + if ble/is-function "$name"; then + local index=0 + while ble/is-function "ble/function#push/$index:$name"; do + ((++index)) + done + local def; ble/function#getdef "$name" + ble/function#evaldef "ble/function#push/$index:$def" + fi + if [[ $proc ]]; then + local q=\' Q="'\''" + builtin eval "function $name { builtin eval -- '${proc//$q/$Q}'; }" + else + builtin unset -f "$name" + fi + return 0 +} +function ble/function#pop { + local name=$1 proc=$2 + local index=-1 + while ble/is-function "ble/function#push/$((index+1)):$name"; do + ((++index)) + done + if ((index<0)); then + if ble/is-function "$name"; then + builtin unset -f "$name" + return 0 + elif ble/bin#has "$name"; then + ble/util/print "ble/function#pop: $name is not a function." >&2 + return 1 + else + return 0 + fi + else + local def; ble/function#getdef "ble/function#push/$index:$name" + ble/function#evaldef "${def#*:}" + builtin unset -f "ble/function#push/$index:$name" + return 0 + fi +} +function ble/function#push/call-top { + local func=${FUNCNAME[1]} + if ! ble/is-function "$func"; then + ble/util/print "ble/function#push/call-top: This function should be called from a function" >&2 + return 1 + fi + local index=0 + if [[ $func == ble/function#push/?*:?* ]]; then + index=${func#*/*/}; index=${index%%:*} + func=${func#*:} + else + while ble/is-function "ble/function#push/$index:$func"; do ((index++)); done + fi + if ((index==0)); then + command "$func" "$@" + else + "ble/function#push/$((index-1)):$func" "$@" + fi +} +: "${_ble_util_lambda_count:=0}" +function ble/function#lambda { + local _ble_local_q=\' _ble_local_Q="'\''" + ble/util/set "$1" ble/function#lambda/$((_ble_util_lambda_count++)) + builtin eval -- "function ${!1} { builtin eval -- '${2//$_ble_local_q/$_ble_local_Q}'; }" +} +function ble/function#suppress-stderr { + local name=$1 + if ! ble/is-function "$name"; then + ble/util/print "$FUNCNAME: '$name' is not a function name" >&2 + return 2 + fi + local lambda=ble/function#suppress-stderr:$name + if ! ble/is-function "$lambda"; then + local def; ble/function#getdef "$name" + ble/function#evaldef "ble/function#suppress-stderr:$def" + fi + builtin eval "function $name { $lambda \"\$@\" 2>/dev/null; }" + return 0 +} +if ((_ble_bash>=40100)); then + function ble/util/set { + builtin printf -v "$1" %s "$2" + } +else + function ble/util/set { + builtin eval -- "$1=\"\$2\"" + } +fi +if ((_ble_bash>=30100)); then + function ble/util/sprintf { + builtin printf -v "$@" + } +else + function ble/util/sprintf { + local -a args; args=("${@:2}") + ble/util/assign "$1" 'builtin printf "${args[@]}"' + } +fi +function ble/util/type { + ble/util/assign-array "$1" 'builtin type -a -t -- "$3" 2>/dev/null' "$2" +} +if ((_ble_bash>=40000)); then + function ble/is-alias { + [[ $1 && ${BASH_ALIASES[$1]+set} ]] + } + function ble/alias#active { + shopt -q expand_aliases && + [[ $1 && ${BASH_ALIASES[$1]+set} ]] + } + function ble/alias#expand { + ret=$1 + shopt -q expand_aliases && [[ $1 ]] && + ret=${BASH_ALIASES[$ret]-$ret} + } + function ble/alias/list { + ret=("${!BASH_ALIASES[@]}") + } +else + function ble/is-alias { + [[ $1 != *=* ]] && alias "$1" &>/dev/null + } + function ble/alias#active { + shopt -q expand_aliases && + [[ $1 != *=* ]] && alias "$1" &>/dev/null + } + function ble/alias#expand { + ret=$1 + local type; ble/util/type type "$ret" + [[ $type != alias ]] && return 1 + local data; ble/util/assign data 'LC_ALL=C alias "$ret"' &>/dev/null + [[ $data == 'alias '*=* ]] && builtin eval "ret=${data#alias *=}" + } + function ble/alias/list { + ret=() + local data iret=0 + ble/util/assign-array data 'alias -p' + for data in "${data[@]}"; do + [[ $data == 'alias '*=* ]] && + data=${data%%=*} && + builtin eval "ret[iret++]=${data#alias }" + done + } +fi +function ble/util/load-standard-builtin { + local ret; ble/util/readlink "$BASH" + local bash_prefix=${ret%/*/*} + if [[ -s $bash_prefix/lib/bash/$1 ]] && ( + enable -f "$bash_prefix/lib/bash/$1" "$1" && + help "$1" && + { [[ ! $2 ]] || builtin eval -- "$2"; } + ) &>/dev/null + then + enable -f "$bash_prefix/lib/bash/$1" "$1" + return 0 + else + return 1 + fi +} +if ((_ble_bash>=40000)); then + function ble/util/is-stdin-ready { + local IFS= LC_ALL= LC_CTYPE=C + builtin read -t 0 + } + ble/function#suppress-stderr ble/util/is-stdin-ready +else + function ble/util/is-stdin-ready { return "${1:-1}"; } +fi +if ((_ble_bash>=40000)); then + function ble/util/getpid { return 0; } + function ble/util/is-running-in-subshell { [[ $$ != $BASHPID ]]; } +else + function ble/util/getpid { + local command='echo $PPID' + ble/util/assign BASHPID 'ble/bin/sh -c "$command"' + } + function ble/util/is-running-in-subshell { + ((BASH_SUBSHELL==0)) || return 0 + local BASHPID; ble/util/getpid + [[ $$ != $BASHPID ]] + } +fi +_ble_util_fd_is_open_stdout= +_ble_util_fd_is_open_stderr= +if ((_ble_bash>=40000)) && [[ -d /proc/$BASHPID/fd ]]; then + function ble/fd#is-open { [[ $1 && -e /proc/$BASHPID/fd/$1 ]]; } + function ble/fd#is-open/.upgrade { builtin unset -f "$FUNCNAME"; } +else + function ble/fd#is-open { builtin : 9>&"$1"; } 2>/dev/null + function ble/fd#is-open/.upgrade { + if ! { [[ $_ble_util_fd_null ]] && ((1)) >&"$_ble_util_fd_null"; } 2>/dev/null; then + ble/util/print "$FUNCNAME: [FATAL] call this function after \$_ble_util_fd_null is ready" >&2 + return 1 + fi + local fd1 fd2 + ble/fd#alloc/.nextfd fd1 + ble/fd#alloc/.nextfd fd2 + _ble_util_fd_is_open_stdout=$fd1 + _ble_util_fd_is_open_stderr=$fd2 + builtin eval -- " + ble/fd#alloc/.exec $fd1 '>/dev/null' # disable=#D1835 + ble/fd#alloc/.exec $fd2 '>&$fd1' # disable=#D1835 + function ble/fd#is-open { + ble/string#match \"\$1\" '^[0-9]+$' || return 1 + [[ \$1 == $fd1 || \$1 == $fd2 || \$1 == $_ble_util_fd_null ]] && return 0 + ble/fd#alloc/.exec $fd2 '>&2' # disable=#D1835 + exec 2>&$_ble_util_fd_null # disable=#D1835 + ble/fd#alloc/.exec $fd1 \">&\$1\" # disable=#D1835 + local ext=\$? + exec 2>&$fd2 # disable=#D1835 + ble/fd#alloc/.exec $fd1 '>&$_ble_util_fd_null' # disable=#D1835 + ble/fd#alloc/.exec $fd2 '>&$fd1' # disable=#D1835 + return \"\$ext\" + } + " + builtin unset -f "$FUNCNAME" + } +fi +function ble/fd#alloc/.close { builtin eval "exec $1<&-"; } # disable=#D2164 +if ((30100<=_ble_bash&&_ble_bash<30200)); then + function ble/fd#alloc/.close/.upgrade { + if ! { [[ $_ble_util_fd_null ]] && ((1)) >&"$_ble_util_fd_null"; } 2>/dev/null; then + ble/util/print "$FUNCNAME: [FATAL] call this function after \$_ble_util_fd_null is ready" >&2 + return 1 + fi + builtin eval -- " + function ble/fd#alloc/.close { + ((\$1==$_ble_util_fd_null||\$1==2)) && return 1 + exec $_ble_util_fd_null<&\"\$1\"- + } 2>/dev/null" + builtin unset -f "$FUNCNAME" + } +else + function ble/fd#alloc/.close/.upgrade { builtin unset -f "$FUNCNAME"; } +fi +function ble/fd/.validate-shared-fds { + local -a close_fd=() + if [[ ${_ble_util_fdvars_export-} ]]; then + local ret var fd + ble/string#split ret : "$_ble_util_fdvars_export" + for var in "${ret[@]}"; do + ble/string#match "$var" '^[a-zA-Z_][a-zA-Z_0-9]*$' || continue + fd=${!var} + ble/string#match "$fd" '^[0-9]+$' || continue + if ! ble/fd#is-open "$fd"; then + ble/array#push close_fd "$fd" + builtin unset -v "$var" + fi + done + for var in "${!_ble_util_fd_@}"; do + fd=${!var} + ble/string#match "$fd" '^[0-9]{2,}$' || continue + if ! ble/fd#is-open "$fd"; then + ble/array#push close_fd "$fd" + builtin unset -v "$var" + fi + done + _ble_util_fdvars_export= + fi + if [[ ${_ble_util_fdlist_cloexec-} ]]; then + local ret fd + ble/string#split ret : "$_ble_util_fdlist_cloexec" + for fd in "${ret[@]}"; do + ble/string#match "$fd" '^([0-9]+)(=(.*))?' || continue + local fd=${BASH_REMATCH[1]} type=${BASH_REMATCH[3]-} + case $type in + (L*) + [[ -h /proc/$$/fd/$1 ]] && + ble/util/readlink "/proc/$$/fd/$1" && + [[ ${ret//:} == "${type#L}" ]] || continue ;; + (t) [[ -t $fd ]] || continue ;; + (o) [[ ! -t $fd ]] || continue ;; + esac + ble/array#push close_fd "$fd" + done + _ble_util_fdlist_cloexec= + fi + if ((${#close_fd[@]})); then + "${_ble_util_set_declare[@]//NAME/mark}" # disable=#D1570 + local fd + for fd in "${close_fd[@]}"; do + ble/set#contains mark "$fd" && continue + ble/set#add mark "$fd" + ble/fd#alloc/.close "$fd" + done + fi +} +ble/fd/.validate-shared-fds +_ble_util_fdlist_cloexit= +export _ble_util_fdlist_cloexec= +export _ble_util_fdvars_export= +_ble_util_openat_nextfd= +function ble/fd#alloc/.nextfd { + [[ $_ble_util_openat_nextfd ]] || + _ble_util_openat_nextfd=${bleopt_openat_base:-30} + local _ble_local_init=${2:-$_ble_util_openat_nextfd} + local _ble_local_limit=$((_ble_local_init+1024)) + local _ble_local_nextfd=$_ble_local_init + while ((_ble_local_nextfd<_ble_local_limit)) && + ble/fd#is-open "$_ble_local_nextfd"; do + ((_ble_local_nextfd++)) + done + if ((_ble_local_nextfd>=_ble_local_limit)); then + _ble_local_nextfd=$_ble_local_init + ble/fd#alloc/.close "$_ble_local_nextfd" + fi + (($1=_ble_local_nextfd++)) + [[ ${2-} || :${3-}: == *:no-increment:* ]] || + _ble_util_openat_nextfd=$_ble_local_nextfd +} +if [[ :$bleopt_connect_tty: == *:inherit:* ]]; then + if [[ ! ${_ble_util_fd_null-} ]] || ! ble/fd#is-open "$_ble_util_fd_null"; then + builtin eval "exec $_ble_util_fd_null<>/dev/null" + ble/opts#append-unique _ble_util_fdvars_export _ble_util_fd_null + export _ble_util_fd_null + ble/fd#alloc/.nextfd _ble_util_fd_null + fi +else + ble/fd#alloc/.nextfd _ble_util_fd_null + builtin eval "exec $_ble_util_fd_null<>/dev/null" + ble/opts#append-unique _ble_util_fdlist_cloexit "$_ble_util_fd_null" +fi +ble/fd#alloc/.close/.upgrade +function ble/fd#alloc/.exec { + ble/fd#alloc/.close "$1" + builtin eval "exec $1$2" +} +ble/fd#is-open/.upgrade +if [[ -d /proc/$$/fd ]]; then + function ble/fd#list/adjust-glob { + set=$- shopt= gignore=$GLOBIGNORE + ble/base/list-shopt failglob dotglob + shopt -u failglob + set +f + GLOBIGNORE= + } + function ble/fd#list/restore-glob { + GLOBIGNORE=$gignore + if [[ :$shopt: == *:dotglob:* ]]; then shopt -s dotglob; else shopt -u dotglob; fi + [[ $set == *f* ]] && set -f + [[ :$shopt: == *:failglob:* ]] && shopt -s failglob + } + function ble/fd#list { + ret=() + local set shopt gignore + ble/fd#list/adjust-glob + local pid=${1-} + if [[ ! $pid ]]; then + if ((_ble_bash<40000)); then + local BASHPID + ble/util/getpid + fi + pid=$BASHPID + fi + local fd + for fd in /proc/"$pid"/fd/[0-9]*; do + fd=${fd##*/} + [[ $fd && ! ${fd//[0-9]} ]] && + ble/array#push ret "$fd" + done + ble/fd#list/restore-glob + } +else + function ble/fd#list { + ret=() + local fd + for fd in {0..255}; do + ble/fd#is-open "$fd" && ble/array#push ret "$fd" + done + } +fi +if ((_ble_bash>=40400)) && ble/util/load-standard-builtin fdflags 'builtin fdflags 0; (($?<=2))'; then + function ble/fd#cloexec/.add { builtin fdflags -s +cloexec "$1"; } + function ble/fd#cloexec/.remove { builtin fdflags -s -cloexec "$1"; } +elif ((_ble_bash>=40000)); then + if [[ -d /proc/$$/fd ]]; then + function ble/fd#cloexec/.listfd { + local fd + for fd in /proc/"$$"/fd/*; do + fd=${fd##*/} + [[ $fd && ! ${fd//[0-9]} ]] && ble/util/set "$1[fd]" 1 + done + } + function ble/fd#cloexec/.probe { + local fdset2 + ble/fd#cloexec/.listfd fdset2 + local fd + for fd in "${!fdset1[@]}"; do builtin unset -v 'fdset2[fd]'; done + fd=("${!fdset2[@]}") + ((${#fd[@]}==1)) && + ble/fd#alloc/.nextfd ret '' no-increment && + builtin eval -- "exec $ret<&$fd" && + return 0 + ret= + return 1 + } + function ble/fd#cloexec/.dup-undo-redirection-fd { + local set shopt gignore + ble/fd#list/adjust-glob + local fd=$1 fdset1 + ble/fd#cloexec/.listfd fdset1 + builtin eval -- "ble/fd#cloexec/.probe $fd&- $fd>&$ret $ret>&-" # disable=#D2164 (here bash4+) + } 2>/dev/null + function ble/fd#cloexec/.remove { + local fd=$1 + if ((fd!=0)); then + builtin eval -- "exec 0<&$fd $fd<&- $fd<&0" &$fd $fd>&- $fd>&1" >/dev/null # disable=#D2164 (here bash4+) + fi + } +else + function ble/fd#cloexec/.add { false; } + function ble/fd#cloexec/.remove { false; } +fi +function ble/fd#add-cloexec { + ble/fd#cloexec/.add "$1" && return 0 + local type + if [[ -h /proc/$$/fd/$1 ]] && ble/util/readlink "/proc/$$/fd/$1"; then + type=L${ret//:} + elif [[ -t ${!1} ]]; then + type=t + else + type=o + fi + ble/opts#remove _ble_util_fdlist_cloexec "$1" + ble/opts#append _ble_util_fdlist_cloexec "$1=$type" +} +function ble/fd#remove-cloexec { + ble/fd#cloexec/.remove "$1" || return "$?" + ble/opts#remove _ble_util_fdlist_cloexec "$1" + return 0 +} +function ble/fd#alloc { + local _ble_local_opts=$3 + if [[ :$_ble_local_opts: == *:inherit:* ]]; then + [[ ${!1-} ]] && ble/fd#is-open "${!1}" && return 0 + _ble_local_opts=$_ble_local_opts:export + elif [[ :$_ble_local_opts: == *:inherit-tty:* ]]; then + [[ ${!1-} && -t ${!1-} ]] && return 0 + _ble_local_opts=$_ble_local_opts:export + fi + if [[ :$_ble_local_opts: == *:share:* ]]; then + if ble/string#match "$2" '[<>]&['"$_ble_term_IFS"']*([0-9]+)['"$_ble_term_IFS"']*$'; then + builtin eval -- "$1=${BASH_REMATCH[1]}" + return 0 + fi + fi + if [[ ${!1-} && :$_ble_local_opts: == *:overwrite:* ]]; then + _ble_local_opts=$_ble_local_opts:preserve + ble/fd#alloc/.exec "${!1}" "$2" + elif ((_ble_bash>=40100)) && [[ :$_ble_local_opts: != *:base:* ]]; then + builtin eval "exec {$1}$2" + else + ble/fd#alloc/.nextfd "$1" + ble/fd#alloc/.exec "${!1}" "$2" + fi; local _ble_local_ext=$? + if ((_ble_local_ext==0)); then + if [[ :$_ble_local_opts: == *:export:* ]]; then + export "$1" + ble/opts#append-unique _ble_util_fdvars_export "$1" + elif [[ :$_ble_local_opts: != *:preserve:* ]]; then + ble/opts#append-unique _ble_util_fdlist_cloexit "${!1}" + ble/fd#add-cloexec "${!1}" + fi + fi + return "$_ble_local_ext" +} +function ble/fd#finalize { + local fds fd + ble/string#split fds : "$_ble_util_fdlist_cloexit" + for fd in "${fds[@]}"; do + [[ $fd ]] || continue + ble/fd#alloc/.close "$fd" + done + _ble_util_fdlist_cloexit= + _ble_util_fdlist_cloexec= +} +function ble/fd#is-cloexit { + [[ :$_ble_util_fdlist_cloexit: == *:"$fd":* ]] +} +function ble/fd#close { + set -- "$(($1))" + (($1>=3)) || return 1 + ble/fd#alloc/.close "$1" + ble/opts#remove _ble_util_fdlist_cloexit "$1" + ble/opts#remove _ble_util_fdlist_cloexec "$1" + return 0 +} +bleopt/declare -v connect_tty 1 +export bleopt_connect_tty +ble/fd#add-cloexec "$_ble_util_fd_null" +_ble_util_fd_zero= +if [[ -c /dev/zero ]] && ! ble/base/is-msys1; then + if [[ :$bleopt_connect_tty: == *:inherit:* ]]; then + ble/fd#alloc _ble_util_fd_zero '< /dev/zero' base:inherit + else + ble/fd#alloc _ble_util_fd_zero '< /dev/zero' base + fi +fi +function ble/fd/.initialize-standard-stream { + local var_tty=_ble_util_fd_tty_$1 + local var_cmd=_ble_util_fd_cmd_$1 + local var_tui=_ble_util_fd_tui_$1 + local fd=${2::1} redir=${2:1} + ble/fd#alloc "$var_cmd" "$redir&$fd" base + if [[ -t $fd ]]; then + local alloc_opts=base + [[ $bleopt_connect_tty == inherit ]] && alloc_opts=$alloc_opts:overwrite:export + ble/fd#alloc "$var_tty" "$redir&$fd" "$alloc_opts" + ble/util/set "$var_tui" "${!var_tty}" + return 0 + fi + if [[ ! $_ble_init_command && $bleopt_connect_tty ]]; then + local alloc_opts=base + [[ $bleopt_connect_tty == inherit ]] && alloc_opts=$alloc_opts:inherit-tty + if ble/fd#alloc "$var_tty" "$redir /dev/tty" "$alloc_opts"; then + ble/util/set "$var_tui" "${!var_tty}" + builtin eval -- "exec $fd$redir&${!var_tui}" + return 0 + else + builtin unset -v "$var_tty" + fi + fi + ble/util/set "$var_tui" "${!var_cmd}" +} +ble/fd/.initialize-standard-stream stdin '0<' +ble/fd/.initialize-standard-stream stdout '1>' +ble/fd/.initialize-standard-stream stderr '2>' +function ble/fd/save-external-standard-streams { + ble/fd#alloc _ble_util_fd_cmd_stdin "<&${1:-0}" base:overwrite + ble/fd#alloc _ble_util_fd_cmd_stdout ">&${2:-1}" base:overwrite + ble/fd#alloc _ble_util_fd_cmd_stderr ">&${3:-2}" base:overwrite + ble/fd#add-cloexec "$_ble_util_fd_cmd_stdin" + ble/fd#add-cloexec "$_ble_util_fd_cmd_stdout" + ble/fd#add-cloexec "$_ble_util_fd_cmd_stderr" +} +function ble/fd#close-all-tty { + local ret + ble/fd#list + local fd + for fd in "${ret[@]}"; do + if ble/string#match "$fd" '^[0-9]+$' && [[ -t $fd ]]; then + ble/fd#alloc/.exec "$fd" ">&$_ble_util_fd_null" + ble/opts#remove _ble_util_fdlist_cloexit "$fd" + fi + done +} +function ble/util/nohup { + if ((!BASH_SUBSHELL)); then + (ble/util/nohup "$@") + return "$?" + fi + ble/fd#close-all-tty + shopt -u huponexit + builtin eval -- "$1" &>/dev/null =40000)); then + ble/util/assign __ble_decl "declare -p $__ble_name" 2>/dev/null + __ble_decl=${__ble_decl#declare -* } + else + ble/util/assign __ble_decl "ble/util/declare-print-definitions $__ble_name" 2>/dev/null + fi + if ble/is-array "$__ble_name"; then + __ble_decl="declare -a $__ble_decl" + else + __ble_decl="declare -A $__ble_decl" + fi + else + __ble_decl=${!__ble_name} + __ble_decl="declare $__ble_name='${__ble_decl//$__ble_q/$__ble_Q}'" + fi + ble/util/print "$__ble_decl" +} +function ble/util/print-global-definitions { + local __ble_opts= + [[ $1 == --hidden-only ]] && { __ble_opts=hidden-only; shift; } + ble/util/for-global-variables ble/util/print-global-definitions/.print-decl "$__ble_opts" "$@" +} +function ble/util/for-global-variables { + local __ble_proc=$1 __ble_opts=$2; shift 2 + local __ble_hidden_only= + [[ :$__ble_opts: == *:hidden-only:* ]] && __ble_hidden_only=1 + ( + ble/util/joblist/__suppress__ + ((_ble_bash>=50000)) && shopt -u localvar_unset + __ble_error= + __ble_q="'" __ble_Q="'\''" + __ble_MaxLoop=20 + builtin unset -v "${!_ble_processed_@}" + for __ble_name; do + [[ ${__ble_name//[_a-zA-Z0-9]} || $__ble_name == __ble_* ]] && continue + ((__ble_processed_$__ble_name)) && continue + ((__ble_processed_$__ble_name=1)) + __ble_found= + if ((_ble_bash>=40200)); then + declare -g -r "$__ble_name" + for ((__ble_i=0;__ble_i<__ble_MaxLoop;__ble_i++)); do + if ! builtin unset -v "$__ble_name"; then + if builtin readonly "$__ble_name"; ble/variable#is-global/.test "$__ble_name"; then + __ble_found=1 + [[ $__ble_hidden_only && $__ble_i == 0 ]] || + "$__ble_proc" "$__ble_name" + fi + break + fi + done + else + for ((__ble_i=0;__ble_i<__ble_MaxLoop;__ble_i++)); do + if ble/variable#is-global "$__ble_name"; then + __ble_found=1 + [[ $__ble_hidden_only && $__ble_i == 0 ]] || + "$__ble_proc" "$__ble_name" + break + fi + builtin unset -v "$__ble_name" || break + done + fi + if [[ ! $__ble_found ]]; then + __ble_error=1 + [[ $__ble_hidden_only && $__ble_i == 0 ]] || + "$__ble_proc" "$__ble_name" unset + fi + done + [[ ! $__ble_error ]] + ) 2>/dev/null +} +function ble/util/has-glob-pattern { + [[ $1 ]] || return 1 + local restore=: + if ! shopt -q nullglob 2>/dev/null; then + restore="$restore;shopt -u nullglob" + shopt -s nullglob + fi + if shopt -q failglob 2>/dev/null; then + restore="$restore;shopt -s failglob" + shopt -u failglob + fi + local dummy=$_ble_base_run/$$.dummy ret + builtin eval "ret=(\"\$dummy\"/${1#/})" 2>/dev/null + builtin eval -- "$restore" + [[ ! $ret ]] +} +function ble/util/is-cygwin-slow-glob { + [[ ( $OSTYPE == cygwin || $OSTYPE == msys ) && ${1#\'} == //* && ! -o noglob ]] && + ble/util/has-glob-pattern "$1" +} +function ble/util/eval-pathname-expansion { + ret=() + if ble/util/is-cygwin-slow-glob; then # Note: #D1168 + if shopt -q failglob &>/dev/null; then + return 1 + elif shopt -q nullglob &>/dev/null; then + return 0 + else + set -f + ble/util/eval-pathname-expansion "$1"; local ext=$1 + set +f + return "$ext" + fi + fi + local canon= + if [[ :$2: == *:canonical:* ]]; then + canon=1 + local set=$- shopt gignore=$GLOBIGNORE + ble/base/list-shopt failglob nullglob extglob dotglob + shopt -u failglob + shopt -s nullglob + shopt -s extglob + set +f + GLOBIGNORE= + fi + builtin eval "ret=($1)" 2>/dev/null; local ext=$? + if [[ $canon ]]; then + GLOBIGNORE=$gignore + if [[ :$shopt: == *:dotglob:* ]]; then shopt -s dotglob; else shopt -u dotglob; fi + [[ $set == *f* ]] && set -f + [[ :$shopt: != *:extglob:* ]] && shopt -u extglob + [[ :$shopt: != *:nullglob:* ]] && shopt -u nullglob + [[ :$shopt: == *:failglob:* ]] && shopt -s failglob + fi + return "$ext" +} +_ble_util_rex_isprint='^[ -~]+' +function ble/util/isprint+ { + local LC_ALL= LC_COLLATE=C + [[ $1 =~ $_ble_util_rex_isprint ]] +} +ble/function#suppress-stderr ble/util/isprint+ +_ble_util_mktime_tzdelta= +function ble/util/mktime { + if (($#==6||$#==7)); then + local tz=${7-} + if [[ ! $tz ]]; then + if [[ ! ${_ble_util_mktime_tzdelta-} ]]; then + ble/util/assign _ble_util_mktime_tzdelta 'ble/bin/date +%z' + fi + tz=$_ble_util_mktime_tzdelta + fi + local tzdelta + if ble/string#match "$tz" '^[-+]([0-9]{1,2})([0-9]{2})$'; then + tzdelta=${tz::1}$(((10#0${BASH_REMATCH[1]}*60+10#0${BASH_REMATCH[2]})*60)) + else + tzdelta=0 + fi + local Y=$((10#0$1)) m=$((10#0$2)) d=$((10#0$3)) + local H=$((10#0$4)) M=$((10#0$5)) S=$((10#0$6)) + ((m<3)) && ((Y--,m+=12)) + local day_delta=$((365*(Y-1970)+(Y/4-Y/100+Y/400-477)+(m+1)*306/10-63+(d-1))) + ((ret=((day_delta*24+H)*60+M)*60+S-tzdelta)) + return 0 + elif ble/string#match "${1-}" '^([0-9]{4})-([01]?[0-9])-([0-3]?[0-9]) ([0-2]?[0-9]):([0-5]?[0-9]):([0-5]?[0-9])( ([-+][0-9]{3,4}))?$'; then + ble/util/mktime "${BASH_REMATCH[@]:1:6}" "${BASH_REMATCH[8]-}" + else + ble/util/print "$FUNCNAME: invalid argument '${1-}'" >&2 + return 2 + fi +} +if ((_ble_bash>=40200)); then + function ble/util/strftime { + if [[ $1 = -v ]]; then + builtin printf -v "$2" "%($3)T" "${4:--1}" + else + builtin printf "%($1)T" "${2:--1}" + fi + } +else + function ble/util/strftime { + if [[ $1 = -v ]]; then + local fmt=$3 time=$4 + ble/util/assign "$2" "ble/bin/date +\"\$fmt\" $time" + else + ble/bin/date +"$1" $2 + fi + } +fi +if ((_ble_bash>=50000)); then + function ble/util/time { ret=$EPOCHSECONDS; } + function ble/util/timeval { ret=${EPOCHREALTIME//[!0-9]}; } +else + function ble/util/time { + if ble/util/strftime -v ret '%s' 2>/dev/null && ble/string#match '^[0-9]{3,}$'; then + function ble/util/time { ble/util/strftime -v ret '%s'; } + else + function ble/util/time { + ble/util/strftime -v ret '%F %T %z' + ble/util/mktime "$ret" + } + ble/util/time + fi + if ((_ble_bash<40200)) && ble/string#match "${SECONDS-}" '^[0-9]+$'; then + builtin readonly SECONDS + _ble_util_time_base=$((ret-SECONDS)) + function ble/util/time { ((ret=_ble_util_time_base+SECONDS)); } + fi + } + function ble/util/timeval { ble/util/time; ((ret*=1000000)); } +fi +function blehook/.print { + (($#)) || return 0 + local out= q=\' Q="'\''" nl=$'\n' + local sgr0= sgr1= sgr2= sgr3= + if [[ $flags == *c* ]]; then + local ret + ble/color/face2sgr command_function; sgr1=$ret + ble/color/face2sgr syntax_varname; sgr2=$ret + ble/color/face2sgr syntax_quoted; sgr3=$ret + sgr0=$_ble_term_sgr0 + Q=$q$sgr0"\'"$sgr3$q + fi + local elem op_assign code=' + if ((${#_ble_hook_h_NAME[@]})); then + op_assign== + for elem in "${_ble_hook_h_NAME[@]}"; do + out="${out}${sgr1}blehook$sgr0 ${sgr2}NAME$sgr0$op_assign${sgr3}$q${elem//$q/$Q}$q$sgr0$nl" + op_assign=+= + done + else + out="${out}${sgr1}blehook$sgr0 ${sgr2}NAME$sgr0=$nl" + fi' + local hookname + for hookname; do + ble/is-array "$hookname" || continue + builtin eval -- "${code//NAME/${hookname#_ble_hook_h_}}" + done + ble/util/put "$out" +} +function blehook/.print-help { + ble/util/print-lines \ + 'usage: blehook [NAME[[=|+=|-=|-+=]COMMAND]]...' \ + ' Add or remove hooks. Without arguments, this prints all the existing hooks.' \ + '' \ + ' Options:' \ + ' --help Print this help.' \ + ' -a, --all Print all hooks including the internal ones.' \ + ' --color[=always|never|auto]' \ + ' Change color settings.' \ + '' \ + ' Arguments:' \ + ' NAME Print the corresponding hooks.' \ + ' NAME=COMMAND Set hook after removing the existing hooks.' \ + ' NAME+=COMMAND Add hook.' \ + ' NAME-=COMMAND Remove hook.' \ + ' NAME!=COMMAND Add hook if the command is not registered.' \ + ' NAME-+=COMMAND Append the hook and remove the duplicates.' \ + ' NAME+-=COMMAND Prepend the hook and remove the duplicates.' \ + '' \ + ' NAME:' \ + ' The hook name. The characters "@", "*", and "?" may be used as wildcards.' \ + '' +} +function blehook/.read-arguments { + flags= print=() process=() + local opt_color=auto + while (($#)); do + local arg=$1; shift + if [[ $arg == -* ]]; then + case $arg in + (--help) + flags=H$flags ;; + (--color) opt_color=always ;; + (--color=always|--color=auto|--color=never) + opt_color=${arg#*=} ;; + (--color=*) + ble/util/print "blehook: '${arg#*=}': unrecognized option argument for '--color'." >&2 + flags=E$flags ;; + (--all) flags=a$flags ;; + (--*) + ble/util/print "blehook: unrecognized long option '$arg'." >&2 + flags=E$flags ;; + (-) + ble/util/print "blehook: unrecognized argument '$arg'." >&2 + flags=E$flags ;; + (*) + local i c + for ((i=1;i<${#arg};i++)); do + c=${arg:i:1} + case $c in + (a) flags=a$flags ;; + (*) + ble/util/print "blehook: unrecognized option '-$c'." >&2 + flags=E$flags ;; + esac + done ;; + esac + elif [[ $arg =~ $rex1 ]]; then + if [[ $arg == *[@*?]* ]] || ble/is-array "_ble_hook_h_$arg"; then + ble/array#push print "$arg" + else + ble/util/print "blehook: undefined hook '$arg'." >&2 + fi + elif [[ $arg =~ $rex2 ]]; then + local name=${BASH_REMATCH[1]} + if [[ $name == *[@*?]* ]]; then + if [[ ${BASH_REMATCH[2]} == :* ]]; then + ble/util/print "blehook: hook pattern cannot be combined with '${BASH_REMATCH[2]}'." >&2 + flags=E$flags + continue + fi + else + local var_counter=_ble_hook_c_$name + if [[ ! ${!var_counter+set} ]]; then + if [[ ${BASH_REMATCH[2]} == :* ]]; then + (($var_counter=0)) + else + ble/util/print "blehook: hook \"$name\" is not defined." >&2 + flags=E$flags + continue + fi + fi + fi + ble/array#push process "$arg" + else + ble/util/print "blehook: invalid hook spec \"$arg\"" >&2 + flags=E$flags + fi + done + local pat ret out; out=() + for pat in "${print[@]}"; do + if [[ $pat == *[@*?]* ]]; then + bleopt/expand-variable-pattern "_ble_hook_h_$pat" + ble/array#filter ret ble/is-array + [[ $pat == *[a-z]* || $flags == *a* ]] || + ble/array#remove-by-glob ret '_ble_hook_h_*[a-z]*' + if ((!${#ret[@]})); then + ble/util/print "blehook: '$pat': matching hook not found." >&2 + flags=E$flags + continue + fi + else + ret=("_ble_hook_h_$pat") + fi + ble/array#push out "${ret[@]}" + done + print=("${out[@]}") + out=() + for pat in "${process[@]}"; do + [[ $pat =~ $rex2 ]] + local name=${BASH_REMATCH[1]} + if [[ $name == *[@*?]* ]]; then + local type=${BASH_REMATCH[3]} + local value=${BASH_REMATCH[4]} + bleopt/expand-variable-pattern "_ble_hook_h_$pat" + ble/array#filter ret ble/is-array + [[ $pat == *[a-z]* || $flags == *a* ]] || + ble/array#remove-by-glob ret '_ble_hook_h_*[a-z]*' + if ((!${#ret[@]})); then + ble/util/print "blehook: '$pat': matching hook not found." >&2 + flags=E$flags + continue + fi + if ((_ble_bash>=40300)) && ! shopt -q compat42; then + ret=("${ret[@]/%/"$type$value"}") # WA #D1570 #D1751 checked + else + ret=("${ret[@]/%/$type$value}") # WA #D1570 #D1738 checked + fi + else + ret=("_ble_hook_h_$pat") + fi + ble/array#push out "${ret[@]}" + done + process=("${out[@]}") + [[ $opt_color == always || $opt_color == auto && -t 1 ]] && flags=c$flags +} +function blehook { + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_local_adjust" + local set shopt + ble/base/adjust-BASH_REMATCH + ble/base/.adjust-bash-options set shopt + local LC_ALL= LC_COLLATE=C 2>/dev/null # suppress locale error #D1440 + local flags print process + local rex1='^([_a-zA-Z@*?][_a-zA-Z0-9@*?]*)$' + local rex2='^([_a-zA-Z@*?][_a-zA-Z0-9@*?]*)(:?([-+!]|-\+|\+-)?=)(.*)$' + blehook/.read-arguments "$@" + if [[ $flags == *[HE]* ]]; then + if [[ $flags == *H* ]]; then + [[ $flags == *E* ]] && + ble/util/print >&2 + blehook/.print-help + fi + [[ $flags != *E* ]]; local ext=$? + ble/util/unlocal LC_ALL LC_COLLATE 2>/dev/null # suppress locale error #D1440 + ble/base/.restore-bash-options set shopt + ble/base/restore-BASH_REMATCH + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_local_leave" + return "$ext" + fi + if ((${#print[@]}==0&&${#process[@]}==0)); then + print=("${!_ble_hook_h_@}") + [[ $flags == *a* ]] || ble/array#remove-by-glob print '_ble_hook_h_*[a-z]*' + fi + local proc ext=0 + for proc in "${process[@]}"; do + [[ $proc =~ $rex2 ]] + local name=${BASH_REMATCH[1]} + local type=${BASH_REMATCH[3]} + local value=${BASH_REMATCH[4]} + local append=$value + case $type in + (*-*) # -=, -+=, +-= + local ret + ble/array#last-index "$name" "$value" + if ((ret>=0)); then + ble/array#remove-at "$name" "$ret" + elif [[ ${type#:} == '-=' ]]; then + ext=1 + fi + if [[ $type != -+ ]]; then + append= + [[ $type == +- ]] && + ble/array#unshift "$name" "$value" + fi ;; + ('!') # != + local ret + ble/array#last-index "$name" "$value" + ((ret>=0)) && append= ;; + ('') builtin eval "$name=()" ;; # = + ('+'|*) ;; # += + esac + [[ $append ]] && ble/array#push "$name" "$append" + done + if ((${#print[@]})); then + blehook/.print "${print[@]}" + fi + ble/util/unlocal LC_ALL LC_COLLATE 2>/dev/null # suppress locale error #D1440 + ble/base/.restore-bash-options set shopt + ble/base/restore-BASH_REMATCH + ble/util/setexit "$ext" + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_local_return" +} +blehook/.compatibility-ble-0.3 +function blehook/has-hook { + builtin eval "local count=\${#_ble_hook_h_$1[@]}" + ((count)) +} +function blehook/invoke.sandbox { + if ble/bin#has "$_ble_local_hook"; then + ble/util/setexit "$_ble_local_lastexit" "$_ble_local_lastarg" + "$_ble_local_hook" "$@" 2>&3 + else + ble/util/setexit "$_ble_local_lastexit" "$_ble_local_lastarg" + builtin eval -- "$_ble_local_hook" 2>&3 + fi +} +function blehook/invoke { + local _ble_local_lastexit=$? _ble_local_lastarg=$_ FUNCNEST= + ((_ble_hook_c_$1++)) + local -a _ble_local_hooks + builtin eval "_ble_local_hooks=(\"\${_ble_hook_h_$1[@]}\")"; shift + local _ble_local_hook _ble_local_ext=0 + for _ble_local_hook in "${_ble_local_hooks[@]}"; do + blehook/invoke.sandbox "$@" || _ble_local_ext=$? + done + return "$_ble_local_ext" +} 3>&2 2>/dev/null # set -x 対策 #D0930 +function blehook/eval-after-load { + local hook_name=${1}_load value=$2 + if ((_ble_hook_c_$hook_name)); then + builtin eval -- "$value" + else + blehook "$hook_name+=$value" + fi +} +_ble_builtin_trap_inside= # ble/builtin/trap 処理中かどうか +function ble/builtin/trap/.read-arguments { + flags= command= sigspecs=() + while (($#)); do + local arg=$1; shift + if [[ $arg == -?* && flags != *A* ]]; then + if [[ $arg == -- ]]; then + flags=A$flags + continue + elif [[ $arg == --* ]]; then + case $arg in + (--help) + flags=h$flags + continue ;; + (*) + ble/util/print "ble/builtin/trap: unknown long option \"$arg\"." >&2 + flags=E$flags + continue ;; + esac + fi + local i + for ((i=1;i<${#arg};i++)); do + case ${arg:i:1} in + (l) flags=l$flags ;; + (p) flags=p$flags ;; + (P) flags=P$flags ;; + (*) + ble/util/print "ble/builtin/trap: unknown option \"-${arg:i:1}\"." >&2 + flags=E$flags ;; + esac + done + else + if [[ $flags != *[pc]* ]]; then + command=$arg + flags=c$flags + else + ble/array#push sigspecs "$arg" + fi + fi + done + if [[ $flags != *[hlpPE]* ]]; then + if [[ $flags != *c* ]]; then + flags=p$flags + elif ((${#sigspecs[@]}==0)); then + sigspecs=("$command") + command=- + fi + elif [[ $flags == *p* && $flags == *P* ]]; then + ble/util/print "ble/builtin/trap: cannot specify both -p and -P" >&2 + flags=E${flags//[pP]} + fi +} +builtin eval -- "${_ble_util_gdict_declare//NAME/_ble_builtin_trap_name2sig}" +_ble_builtin_trap_sig_name=() +_ble_builtin_trap_sig_opts=() +_ble_builtin_trap_sig_base=1000 +_ble_builtin_trap_EXIT= +_ble_builtin_trap_DEBUG= +_ble_builtin_trap_RETURN= +_ble_builtin_trap_ERR= +function ble/builtin/trap/sig#register { + local sig=$1 name=$2 + _ble_builtin_trap_sig_name[sig]=$name + ble/gdict#set _ble_builtin_trap_name2sig "$name" "$sig" +} +function ble/builtin/trap/sig#reserve { + local ret + ble/builtin/trap/sig#resolve "$1" || return 1 + _ble_builtin_trap_sig_opts[ret]=${2:-1} +} +function ble/builtin/trap/sig#resolve { + ble/builtin/trap/sig#init + if [[ $1 && ! ${1//[0-9]} ]]; then + ret=$1 + return 0 + else + ble/gdict#get _ble_builtin_trap_name2sig "$1" + [[ $ret ]] && return 0 + ble/string#toupper "$1"; local upper=$ret + ble/gdict#get _ble_builtin_trap_name2sig "$upper" || + ble/gdict#get _ble_builtin_trap_name2sig "SIG$upper" || + return 1 + ble/gdict#set _ble_builtin_trap_name2sig "$1" "$ret" + return 0 + fi +} +function ble/builtin/trap/sig#new { + local name=$1 opts=$2 + local sig=$((_ble_builtin_trap_$name=_ble_builtin_trap_sig_base++)) + ble/builtin/trap/sig#register "$sig" "$name" + if [[ :$opts: != *:builtin:* ]]; then + ble/builtin/trap/sig#reserve "$sig" "$opts" + fi +} +function ble/builtin/trap/sig#init { + function ble/builtin/trap/sig#init { return 0; } + local ret i + ble/util/assign-words ret 'builtin trap -l' 2>/dev/null + for ((i=0;i<${#ret[@]};i+=2)); do + local index=${ret[i]%')'} + local name=${ret[i+1]} + ble/builtin/trap/sig#register "$index" "$name" + done + _ble_builtin_trap_EXIT=0 + ble/builtin/trap/sig#register "$_ble_builtin_trap_EXIT" EXIT + ble/builtin/trap/sig#new DEBUG builtin + ble/builtin/trap/sig#new RETURN builtin + ble/builtin/trap/sig#new ERR builtin +} +_ble_builtin_trap_handlers=() +_ble_builtin_trap_handlers_RETURN=() +function ble/builtin/trap/user-handler#load { + local sig=$1 name=${_ble_builtin_trap_sig_name[$1]} + if [[ $name == RETURN ]]; then + ble/builtin/trap/user-handler#load:RETURN + else + _ble_trap_handler=${_ble_builtin_trap_handlers[sig]-} + [[ ${_ble_builtin_trap_handlers[sig]+set} ]] + fi +} +function ble/builtin/trap/user-handler#save { + local sig=$1 name=${_ble_builtin_trap_sig_name[$1]} handler=$2 + if [[ $name == RETURN ]]; then + ble/builtin/trap/user-handler#save:RETURN "$handler" + else + if [[ $handler == - ]]; then + builtin unset -v '_ble_builtin_trap_handlers[sig]' + else + _ble_builtin_trap_handlers[sig]=$handler + fi + fi + return 0 +} +function ble/builtin/trap/user-handler#save:RETURN { + local handler=$1 + local offset= + for ((offset=1;offset<${#FUNCNAME[@]};offset++)); do + case ${FUNCNAME[offset]} in + (trap | ble/builtin/trap) ;; + (ble/builtin/trap/user-handler#save) ;; + (*) break ;; + esac + done + local current_level=$((${#FUNCNAME[@]}-offset)) + local level + for level in "${!_ble_builtin_trap_handlers_RETURN[@]}"; do + if ((level>current_level)); then + builtin unset -v '_ble_builtin_trap_handlers_RETURN[level]' + fi + done + if [[ $handler == - ]]; then + if [[ $- == *T* ]] || shopt -q extdebug; then + for ((level=current_level;level>=0;level--)); do + builtin unset -v '_ble_builtin_trap_handlers_RETURN[level]' + done + else + for ((level=current_level;level>=0;level--,offset++)); do + builtin unset -v '_ble_builtin_trap_handlers_RETURN[level]' + ((level)) && ble/function#has-attr "${FUNCNAME[offset]}" t || break + done + fi + else + _ble_builtin_trap_handlers_RETURN[current_level]=$handler + fi + return 0 +} +function ble/builtin/trap/user-handler#load:RETURN { + local offset= in_trap= + for ((offset=1;offset<${#FUNCNAME[@]};offset++)); do + case ${FUNCNAME[offset]} in + (trap | ble/builtin/trap) ;; + (ble/builtin/trap/.handler) ;; + (ble/builtin/trap/user-handler#load) ;; + (ble/builtin/trap/user-handler#has) ;; + (ble/builtin/trap/finalize) ;; + (ble/builtin/trap/install-hook) ;; + (ble/builtin/trap/invoke) ;; + (*) break ;; + esac + done + local search_level= + if [[ $- == *T* ]] || shopt -q extdebug; then + search_level=0 + else + for ((;offset<${#FUNCNAME[@]};offset++)); do + ble/function#has-attr "${FUNCNAME[offset]}" t || break + done + search_level=$((${#FUNCNAME[@]}-offset)) + fi + local level found= handler= + for level in "${!_ble_builtin_trap_handlers_RETURN[@]}"; do + ((level>=search_level)) || continue + found=1 handler=${_ble_builtin_trap_handlers_RETURN[level]} + done + _ble_trap_handler=$handler + [[ $found ]] +} +function ble/builtin/trap/user-handler#update:RETURN { + local offset=2 # ... ble/builtin/trap/.handler から直接呼び出されると仮定 + local current_level=$((${#FUNCNAME[@]}-offset)) + ((current_level>0)) || return 0 + local level found= handler= + for level in "${!_ble_builtin_trap_handlers_RETURN[@]}"; do + ((level>=current_level)) || continue + found=1 handler=${_ble_builtin_trap_handlers_RETURN[level]} + if ((level>=current_level)); then + builtin unset -v '_ble_builtin_trap_handlers_RETURN[level]' + fi + done + if [[ $found ]]; then + _ble_builtin_trap_handlers_RETURN[current_level-1]=$handler + fi +} +function ble/builtin/trap/user-handler#has { + local _ble_trap_handler + ble/builtin/trap/user-handler#load "$1" +} +function ble/builtin/trap/user-handler#init { + local script _ble_builtin_trap_user_handler_init=1 + ble/util/assign script 'builtin trap -p' + builtin eval -- "$script" +} +function ble/builtin/trap/user-handler/is-internal { + case $1 in + ('ble/builtin/trap/'*) return 0 ;; # ble-0.4 + ('ble/base/unload'*|'ble-edit/'*) return 0 ;; # bash-0.3 以前 + (*) return 1 ;; + esac +} +function ble/builtin/trap/finalize { + _ble_builtin_trap_handlers_reload=() + local sig unload_opts=$1 + for sig in "${!_ble_builtin_trap_sig_opts[@]}"; do + local name=${_ble_builtin_trap_sig_name[sig]} + local opts=${_ble_builtin_trap_sig_opts[sig]} + [[ $name && :$opts: == *:override-builtin-signal:* ]] || continue + if [[ :$opts: == *:readline:* && :$unload_opts: == *:reload:* ]]; then + if local _ble_trap_handler; ble/builtin/trap/user-handler#load "$sig"; then + local q=\' Q="'\''" + _ble_builtin_trap_handlers_reload[sig]="trap -- '${_ble_trap_handler//$q/$Q}' $name" + else + _ble_builtin_trap_handlers_reload[sig]= + fi + continue + fi + if local _ble_trap_handler; ble/builtin/trap/user-handler#load "$sig"; then + builtin trap -- "$_ble_trap_handler" "$name" + else + builtin trap -- - "$name" + fi + done +} +function ble/builtin/trap { + local set shopt; ble/base/.adjust-bash-options set shopt + local flags command sigspecs + ble/builtin/trap/.read-arguments "$@" + if [[ $flags == *h* ]]; then + builtin trap --help + ble/base/.restore-bash-options set shopt + return 2 + elif [[ $flags == *E* ]]; then + builtin trap --usage 2>&1 1>/dev/null | ble/bin/grep ^trap >&2 + ble/base/.restore-bash-options set shopt + return 2 + elif [[ $flags == *l* ]]; then + builtin trap -l + fi + [[ ! $_ble_attached || $_ble_edit_exec_inside_userspace ]] && + ble/base/adjust-BASH_REMATCH + if [[ $flags == *[pP]* ]]; then + local -a indices=() + if ((${#sigspecs[@]})); then + local spec ret + for spec in "${sigspecs[@]}"; do + if ! ble/builtin/trap/sig#resolve "$spec"; then + ble/util/print "ble/builtin/trap: invalid signal specification \"$spec\"." >&2 + continue + fi + ble/array#push indices "$ret" + done + else + indices=("${!_ble_builtin_trap_handlers[@]}" "$_ble_builtin_trap_RETURN") + fi + local q=\' Q="'\''" index _ble_trap_handler + for index in "${indices[@]}"; do + if ble/builtin/trap/user-handler#load "$index"; then + if [[ $flags == *p* ]]; then + local n=${_ble_builtin_trap_sig_name[index]} + _ble_trap_handler="trap -- '${_ble_trap_handler//$q/$Q}' $n" + fi + ble/util/print "$_ble_trap_handler" + fi + done + else + [[ $_ble_builtin_trap_user_handler_init ]] && + ble/builtin/trap/user-handler/is-internal "$command" && + return 0 + local _ble_builtin_trap_inside=1 + local spec ret + for spec in "${sigspecs[@]}"; do + if ! ble/builtin/trap/sig#resolve "$spec"; then + ble/util/print "ble/builtin/trap: invalid signal specification \"$spec\"." >&2 + continue + fi + local sig=$ret + local name=${_ble_builtin_trap_sig_name[sig]} + ble/builtin/trap/user-handler#save "$sig" "$command" + [[ $_ble_builtin_trap_user_handler_init ]] && continue + local trap_command='builtin trap -- "$command" "$spec"' + local install_opts=${_ble_builtin_trap_sig_opts[sig]} + if [[ $install_opts ]]; then + local custom_trap=ble/builtin/trap:$name + if ble/is-function "$custom_trap"; then + trap_command='"$custom_trap" "$command" "$spec"' + elif [[ :$install_opts: == *:readline:* ]] && ! ble/util/is-running-in-subshell; then + trap_command= + elif [[ $command == - ]]; then + if [[ :$install_opts: == *:inactive:* ]]; then + trap_command='builtin trap - "$spec"' + else + trap_command= + fi + elif [[ :$install_opts: == *:override-builtin-signal:* ]]; then + ble/builtin/trap/install-hook/.compose-trap_command "$sig" + trap_command="builtin $trap_command" + else + trap_command= + fi + fi + if [[ $trap_command ]]; then + if [[ $name == ERR && $command == - && $- != *E* ]]; then + command= + fi + builtin eval -- "$trap_command" + fi + done + fi + [[ ! $_ble_attached || $_ble_edit_exec_inside_userspace ]] && + ble/base/restore-BASH_REMATCH + ble/base/.restore-bash-options set shopt + return 0 +} +function trap { + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_local_adjust" + ble/builtin/trap "$@" + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_local_return" +} +ble/builtin/trap/user-handler#init +function ble/builtin/trap/.TRAPRETURN { + local IFS=$_ble_term_IFS + local backtrace=" ${BLE_TRAP_FUNCNAME[*]-} " + case $backtrace in + (' trap '* | ' ble/builtin/trap '*) return 126 ;; + (*' ble/builtin/trap/.handler '*) + case ${backtrace%%' ble/builtin/trap/.handler '*}' ' in + (' '*' blehook/invoke.sandbox '* | ' '*' ble/builtin/trap/invoke.sandbox '*) ;; + (*) return 126 ;; + esac ;; + (*' _ble_edit_exec_gexec__save_lastarg ' | ' _ble_edit_exec_gexec__TRAPDEBUG_adjust ') return 126 ;; + esac + return 0 +} +blehook internal_RETURN!=ble/builtin/trap/.TRAPRETURN +_ble_builtin_trap_user_lastcmd= +_ble_builtin_trap_user_lastarg= +_ble_builtin_trap_user_lastexit= +function ble/builtin/trap/invoke.sandbox { + local _ble_trap_count + for ((_ble_trap_count=0;_ble_trap_count<1;_ble_trap_count++)); do + _ble_trap_done=return + ble/util/setexit "$_ble_trap_lastexit" "$_ble_trap_lastarg" + builtin eval -- "$_ble_trap_handler"$'\n_ble_trap_lastexit=$? _ble_trap_lastarg=$_' 2>&3 + _ble_trap_done=done + return 0 + done + _ble_trap_lastexit=$? _ble_trap_lastarg=$_ + if ((_ble_trap_count==0)); then + _ble_trap_done=break + else + _ble_trap_done=continue + fi + return 0 +} +function ble/builtin/trap/invoke { + local _ble_trap_lastexit=$? _ble_trap_lastarg=$_ _ble_trap_sig=$1; shift + if [[ ${_ble_trap_sig//[0-9]} ]]; then + local ret + ble/builtin/trap/sig#resolve "$_ble_trap_sig" || return 1 + _ble_trap_sig=$ret + ble/util/unlocal ret + fi + local _ble_trap_handler + ble/builtin/trap/user-handler#load "$_ble_trap_sig" + [[ $_ble_trap_handler ]] || return 0 + if [[ $_ble_attached && ! $_ble_edit_exec_inside_userspace ]]; then + if [[ $_ble_builtin_trap_user_lastcmd != $_ble_edit_CMD ]]; then + _ble_builtin_trap_user_lastcmd=$_ble_edit_CMD + _ble_builtin_trap_user_lastexit=$_ble_edit_exec_lastexit + _ble_builtin_trap_user_lastarg=$_ble_edit_exec_lastarg + fi + _ble_trap_lastexit=$_ble_builtin_trap_user_lastexit + _ble_trap_lastarg=$_ble_builtin_trap_user_lastarg + fi + local _ble_trap_done= + ble/builtin/trap/invoke.sandbox "$@"; local ext=$? + case $_ble_trap_done in + (done) + _ble_builtin_trap_lastarg[_ble_trap_sig]=$_ble_trap_lastarg + _ble_builtin_trap_postproc[_ble_trap_sig]="ble/util/setexit $_ble_trap_lastexit" ;; + (break | continue) + _ble_builtin_trap_lastarg[_ble_trap_sig]=$_ble_trap_lastarg + if ble/string#match "$_ble_trap_lastarg" '^-?[0-9]+$'; then + _ble_builtin_trap_postproc[_ble_trap_sig]="$_ble_trap_done $_ble_trap_lastarg" + else + _ble_builtin_trap_postproc[_ble_trap_sig]=$_ble_trap_done + fi ;; + (return) + _ble_builtin_trap_lastarg[_ble_trap_sig]=$ext + _ble_builtin_trap_postproc[_ble_trap_sig]="return $ext" ;; + (exit) + _ble_builtin_trap_lastarg[_ble_trap_sig]=$_ble_trap_lastarg + _ble_builtin_trap_postproc[_ble_trap_sig]="ble/builtin/exit $_ble_trap_lastarg" ;; + esac + if [[ $_ble_attached && ! $_ble_edit_exec_inside_userspace ]]; then + _ble_builtin_trap_user_lastexit=$_ble_trap_lastexit + _ble_builtin_trap_user_lastarg=$_ble_trap_lastarg + fi + return 0 +} 3>&2 2>/dev/null # set -x 対策 #D0930 +_ble_builtin_trap_processing= +_ble_builtin_trap_postproc=() +_ble_builtin_trap_lastarg=() +function ble/builtin/trap/install-hook/.compose-trap_command { + local sig=$1 name=${_ble_builtin_trap_sig_name[$1]} + local handler='ble/builtin/trap/.handler SIGNUM "$BASH_COMMAND" "$@"; builtin eval -- "${_ble_builtin_trap_postproc[SIGNUM]}" \# "${_ble_builtin_trap_lastarg[SIGNUM]}"' + trap_command="trap -- '${handler//SIGNUM/$sig}' $name" # WA #D1738 checked (sig is integer) +} +_ble_trap_builtin_handler_DEBUG_filter= +function ble/builtin/trap/.handler { + local _ble_trap_lastexit=$? _ble_trap_lastarg=$_ FUNCNEST= IFS=$_ble_term_IFS + local _ble_trap_sig=$1 _ble_trap_bash_command=$2 + shift 2 + if [[ $_ble_bash_read_winch && ${_ble_builtin_trap_sig_name[_ble_trap_sig]} == SIGWINCH ]]; then + local ret + ble/string#quote-command "$FUNCNAME" "$_ble_trap_sig" "$_ble_trap_bash_command" "$@" + _ble_bash_read_winch=$ret$'\n''builtin eval -- "${_ble_builtin_trap_postproc['$_ble_trap_sig']}"' + return 0 + fi + if ((_ble_trap_sig==_ble_builtin_trap_DEBUG)) && + ! builtin eval -- "$_ble_trap_builtin_handler_DEBUG_filter"; then + _ble_builtin_trap_lastarg[_ble_trap_sig]=${_ble_trap_lastarg//*$_ble_term_nl*} + _ble_builtin_trap_postproc[_ble_trap_sig]="ble/util/setexit $_ble_trap_lastexit" + return 0 + fi + local _ble_trap_set _ble_trap_shopt; ble/base/.adjust-bash-options _ble_trap_set _ble_trap_shopt + local _ble_trap_name=${_ble_builtin_trap_sig_name[_ble_trap_sig]#SIG} + local -a _ble_trap_args; _ble_trap_args=("$@") + if [[ ! $_ble_trap_bash_command ]] || ((_ble_bash<30200)); then + if [[ $_ble_attached ]]; then + _ble_trap_bash_command=$_ble_edit_exec_BASH_COMMAND + else + ble/util/assign _ble_trap_bash_command 'HISTTIMEFORMAT=__ble_ext__ builtin history 1' + _ble_trap_bash_command=${_ble_trap_bash_command#*__ble_ext__} + fi + fi + local _ble_builtin_trap_processing=${BASH_SUBSHELL:-0}/$_ble_trap_sig + _ble_builtin_trap_lastarg[_ble_trap_sig]=$_ble_trap_lastarg + _ble_builtin_trap_postproc[_ble_trap_sig]="ble/util/setexit $_ble_trap_lastexit" + if [[ $_ble_builtin_exit_processing ]]; then + exec 1>&- 1>&"$_ble_builtin_exit_stdout" + exec 2>&- 2>&"$_ble_builtin_exit_stderr" + fi + local BLE_TRAP_FUNCNAME BLE_TRAP_SOURCE BLE_TRAP_LINENO + BLE_TRAP_FUNCNAME=("${FUNCNAME[@]:1}") + BLE_TRAP_SOURCE=("${BASH_SOURCE[@]:1}") + BLE_TRAP_LINENO=("${BASH_LINENO[@]}") + [[ $_ble_attached ]] && + BLE_TRAP_LINENO[${#BASH_LINENO[@]}-1]=$_ble_edit_LINENO + ble/util/joblist.check + ble/util/setexit "$_ble_trap_lastexit" "$_ble_trap_lastarg" + blehook/invoke "internal_$_ble_trap_name"; local internal_ext=$? + ble/util/joblist.check ignore-volatile-jobs + if ((internal_ext!=126)); then + if ! ble/util/is-running-in-subshell; then + ble/util/setexit "$_ble_trap_lastexit" "$_ble_trap_lastarg" + BASH_COMMAND=$_ble_trap_bash_command \ + blehook/invoke "$_ble_trap_name" + ble/util/joblist.check ignore-volatile-jobs + fi + local install_opts=${_ble_builtin_trap_sig_opts[_ble_trap_sig]} + if [[ :$install_opts: == *:user-trap-in-postproc:* ]]; then + local q=\' Q="'\''" _ble_trap_handler postproc= + ble/builtin/trap/user-handler#load "$_ble_trap_sig" + if [[ $_ble_trap_handler == *[![:space:]]* ]]; then + postproc="ble/util/setexit $_ble_trap_lastexit '${_ble_trap_lastarg//$q/$Q}'" + postproc=$postproc";LINENO=$BLE_TRAP_LINENO builtin eval -- '${_ble_trap_handler//$q/$Q}'" + else + postproc="ble/util/setexit $_ble_trap_lastexit" + fi + _ble_builtin_trap_postproc[_ble_trap_sig]=$postproc + else + ble/util/setexit "$_ble_trap_lastexit" "$_ble_trap_lastarg" + BASH_COMMAND=$_ble_trap_bash_command LINENO=$BLE_TRAP_LINENO \ + ble/builtin/trap/invoke "$_ble_trap_sig" "${_ble_trap_args[@]}" + fi + fi + if [[ $_ble_builtin_trap_processing == */exit:* && ${_ble_builtin_trap_postproc[_ble_trap_sig]} != 'ble/builtin/exit '* ]]; then + _ble_builtin_trap_postproc[_ble_trap_sig]="ble/builtin/exit ${_ble_builtin_trap_processing#*/exit:}" + fi + [[ ${_ble_builtin_trap_lastarg[_ble_trap_sig]} == *$'\n'* ]] && + _ble_builtin_trap_lastarg[_ble_trap_sig]= + if ((_ble_trap_sig==_ble_builtin_trap_EXIT)); then + ble/base/unload EXIT + elif ((_ble_trap_sig==_ble_builtin_trap_RETURN)); then + ble/builtin/trap/user-handler#update:RETURN + fi + ble/base/.restore-bash-options _ble_trap_set _ble_trap_shopt +} +function ble/builtin/trap/install-hook { + local ret opts=${2-} + ble/builtin/trap/sig#resolve "$1" + local sig=$ret name=${_ble_builtin_trap_sig_name[ret]} + ble/builtin/trap/sig#reserve "$sig" "override-builtin-signal:$opts" + local trap_command; ble/builtin/trap/install-hook/.compose-trap_command "$sig" + local trap_string; ble/util/assign trap_string "builtin trap -p $name" + if [[ :$opts: == *:readline:* ]] && ! ble/util/is-running-in-subshell; then + [[ $trap_command == "$trap_string" ]] && trap_command= trap_string= + [[ $trap_string ]] || trap_string=${_ble_builtin_trap_handlers_reload[sig]-} + fi + [[ ! $trap_command || :$opts: == *:inactive:* && ! $trap_string ]] || + builtin eval "builtin $trap_command"; local ext=$? + local q=\' + if [[ $trap_string == "trap -- '"* ]] && ! ble/builtin/trap/user-handler/is-internal "${trap_string#*$q}"; then + ((sig<1000)) && + ! ble/builtin/trap/user-handler#has "$sig" && + builtin eval -- "ble/builtin/$trap_string" + fi + return "$ext" +} +if ! builtin type ble/util/print &>/dev/null; then + function ble/util/unlocal { builtin unset -v "$@"; } + function ble/util/print { builtin printf '%s\n' "$1"; } + function ble/util/print-lines { builtin printf '%s\n' "$@"; } +fi +function ble-measure/.loop { + builtin eval "function _target { ${2:+"$2; "}return 0; }" + local __ble_i __ble_n=$1 + for ((__ble_i=0;__ble_i<__ble_n;__ble_i++)); do + _target + done +} +if ((BASH_VERSINFO[0]>=5)) || + { [[ ${ZSH_VERSION-} ]] && zmodload zsh/datetime &>/dev/null && [[ ${EPOCHREALTIME-} ]]; } || + [[ ${SECONDS-} == *.??? ]] +then + if [[ ${EPOCHREALTIME-} ]]; then + _ble_measure_resolution=1 # [usec] + function ble-measure/.get-realtime { + local LC_ALL= LC_NUMERIC=C + ret=$EPOCHREALTIME + } + else + _ble_measure_resolution=1000 # [usec] + function ble-measure/.get-realtime { + ret=$SECONDS + } + fi + function ble-measure/.time { + ble-measure/.get-realtime 2>/dev/null; local __ble_time1=$ret + ble-measure/.loop "$1" "$2" &>/dev/null + ble-measure/.get-realtime 2>/dev/null; local __ble_time2=$ret + local __ble_frac + [[ $__ble_time1 == *.* ]] || __ble_time1=${__ble_time1}. + __ble_frac=${__ble_time1##*.}000000 __ble_time1=${__ble_time1%%.*}${__ble_frac:0:6} + [[ $__ble_time2 == *.* ]] || __ble_time2=${__ble_time2}. + __ble_frac=${__ble_time2##*.}000000 __ble_time2=${__ble_time2%%.*}${__ble_frac:0:6} + ((ret=__ble_time2-__ble_time1)) + ((ret==0&&(ret=_ble_measure_resolution))) + ((ret>0)) + } +elif [[ ${ZSH_VERSION-} ]]; then + _ble_measure_resolution=1000 # [usec] + function ble-measure/.time { + local result= + result=$({ time ( ble-measure/.loop "$1" "$2" ; ) } 2>&1 ) + result=${result##*cpu } + local rex='(([0-9]+):)?([0-9]+)\.([0-9]+) total$' + if [[ $result =~ $rex ]]; then + if [[ -o KSH_ARRAYS ]]; then + local m=${match[1]} s=${match[2]} ms=${match[3]} + else + local m=${match[2]} s=${match[3]} ms=${match[4]} + fi + m=${m:-0} ms=${ms}000; ms=${ms:0:3} + ((ret=((10#0$m*60+10#0$s)*1000+10#0$ms)*1000)) + return 0 + else + builtin echo "ble-measure: failed to read the result of \`time': $result." >&2 + ret=0 + return 1 + fi + } +else + _ble_measure_resolution=1000 # [usec] + function ble-measure/.time { + ret=0 + local result TIMEFORMAT='[%R]' __ble_n=$1 __ble_command=$2 + if declare -f ble/util/assign &>/dev/null; then + ble/util/assign result '{ time ble-measure/.loop "$__ble_n" "$__ble_command" &>/dev/null;} 2>&1' + else + result=$({ time ble-measure/.loop "$1" "$2" &>/dev/null;} 2>&1) + fi + local rex='\[([0-9]+)(\.([0-9]+))?\]' + [[ $result =~ $rex ]] || return 1 + local s=${BASH_REMATCH[1]} + local ms=${BASH_REMATCH[3]}000; ms=${ms::3} + ((ret=(10#0$s*1000+10#0$ms)*1000)) + return 0 + } +fi +_ble_measure_base= # [nsec] +_ble_measure_base_nestcost=0 # [nsec/10] +_ble_measure_base_real=() +_ble_measure_base_guess=() +_ble_measure_count=1 # 同じ倍率で _ble_measure_count 回計測して最小を取る。 +_ble_measure_threshold=100000 # 一回の計測が threshold [usec] 以上になるようにする +function ble-measure/calibrate.0 { ble-measure -qc"$calibrate_count" ''; } +function ble-measure/calibrate.1 { ble-measure/calibrate.0; } +function ble-measure/calibrate.2 { ble-measure/calibrate.1; } +function ble-measure/calibrate.3 { ble-measure/calibrate.2; } +function ble-measure/calibrate.4 { ble-measure/calibrate.3; } +function ble-measure/calibrate.5 { ble-measure/calibrate.4; } +function ble-measure/calibrate.6 { ble-measure/calibrate.5; } +function ble-measure/calibrate.7 { ble-measure/calibrate.6; } +function ble-measure/calibrate.8 { ble-measure/calibrate.7; } +function ble-measure/calibrate.9 { ble-measure/calibrate.8; } +function ble-measure/calibrate.A { ble-measure/calibrate.9; } +function ble-measure/calibrate { + local ret= nsec= + local calibrate_count=1 + _ble_measure_base=0 + _ble_measure_base_nestcost=0 + local nest0=$((${#FUNCNAME[@]}+2)) + [[ ${ZSH_VERSION-} ]] && nest0=$((${#funcstack[@]}+2)) + ble-measure/calibrate.0; local x0=$nsec + ble-measure/calibrate.A; local xA=$nsec + local nest_cost=$((xA-x0)) + _ble_measure_base=$((x0-nest_cost*nest0/10)) + _ble_measure_base_nestcost=$nest_cost +} +function ble-measure/fit { + local ret nsec + _ble_measure_base=0 + _ble_measure_base_nestcost=0 + local calibrate_count=10 + local c= nest_level=${#FUNCNAME[@]} + for c in {0..9} A; do + "ble-measure/calibrate.$c" + ble/util/print "$((nest_level++)) $nsec" + done > ble-measure-fit.txt + gnuplot - <&2 + if ! ble-measure/.time "$n" "$command"; then + builtin eval -- "${_ble_bash_POSIXLY_CORRECT_local_leave-}" + return 1 + fi + [[ $flags != *V* ]] && printf '\r\e[2K' >&2 + ((utot=ret,utot>=measure_threshold||n==__ble_max_n)) || continue + prev_n=$n prev_utot=$utot + local min_utot=$utot + if [[ $count ]]; then + local sum_utot=$utot sum_count=1 i + for ((i=2;i<=count;i++)); do + [[ $flags != *V* ]] && printf '%s' "$command (x$n $i/$count)..." >&2 + if ble-measure/.time "$n" "$command"; then + ((utot=ret,utot&2 + done + if [[ $flags == *a* ]]; then + ((utot=sum_utot/sum_count)) + else + utot=$min_utot + fi + fi + if ((min_utot<0x7FFFFFFFFFFFFFFF/1000)); then + local __ble_real=$((min_utot*1000/n)) + [[ ${_ble_measure_base_real[__ble_level]} ]] && + ((__ble_real<_ble_measure_base_real[__ble_level])) && + _ble_measure_base_real[__ble_level]=$__ble_real + [[ ${_ble_measure_base_guess[__ble_level]} ]] && + ((__ble_real<_ble_measure_base_guess[__ble_level])) && + _ble_measure_base_guess[__ble_level]=$__ble_real + ((__ble_real<__ble_base)) && + __ble_base=$__ble_real + fi + local nsec0=$__ble_base + if [[ $flags != *q* ]]; then + local reso=$_ble_measure_resolution + local awk=ble/bin/awk + builtin type -- "$awk" &>/dev/null || awk=awk + local -x title="$command (x$n)" + "$awk" -v utot="$utot" -v nsec0="$nsec0" -v n="$n" -v reso="$reso" ' + function genround(x, mod) { return int(x / mod + 0.5) * mod; } + BEGIN { title = ENVIRON["title"]; printf("%12.3f usec/eval: %s\n", genround(utot / n - nsec0 / 1000, reso / 10.0 / n), title); exit }' + fi + local out + ((out=utot/n)) + if ((n>=1000)); then + ((nsec=utot/(n/1000))) + else + ((nsec=utot*1000/n)) + fi + ((out-=nsec0/1000,nsec-=nsec0)) + ret=$out + builtin eval -- "${_ble_bash_POSIXLY_CORRECT_local_leave-}" + return 0 + done + builtin eval -- "${_ble_bash_POSIXLY_CORRECT_local_return-}" +} +function ble/util/msleep/.check-sleep-decimal-support { + local version; ble/util/assign version 'LC_ALL=C ble/bin/sleep --version 2>&1' 2>/dev/null # suppress locale error #D1440 + [[ $version == *'GNU coreutils'* || $OSTYPE == darwin* && $version == 'usage: sleep seconds' ]] +} +_ble_util_msleep_delay=2000 # [usec] +function ble/util/msleep/.core { + local sec=${1%%.*} + ((10#0${1##*.}&&sec++)) # 小数部分は切り上げ + ble/bin/sleep "$sec" +} +function ble/util/msleep { + local v=$((1000*$1-_ble_util_msleep_delay)) + ((v<=0)) && v=0 + ble/util/sprintf v '%d.%06d' "$((v/1000000))" "$((v%1000000))" + ble/util/msleep/.core "$v" +} +_ble_util_msleep_calibrate_count=0 +function ble/util/msleep/.calibrate-loop { + local _ble_measure_threshold=10000 + local ret nsec _ble_measure_count=1 v=0 + _ble_util_msleep_delay=0 ble-measure -q 'ble/util/msleep 1' + local delay=$((nsec/1000-1000)) count=$_ble_util_msleep_calibrate_count + ((count<=0||delay<_ble_util_msleep_delay)) && _ble_util_msleep_delay=$delay # 最小値 +} +function ble/util/msleep/calibrate { + ble/util/msleep/.calibrate-loop &>/dev/null + ((++_ble_util_msleep_calibrate_count<5)) && + ble/util/idle.continue +} +function ble/util/msleep/.use-read-timeout { + local msleep_type=$1 opts=${2-} + _ble_util_msleep_fd= + case $msleep_type in + (socket) + _ble_util_msleep_delay1=10000 # short msleep にかかる時間 [usec] + _ble_util_msleep_delay2=50000 # /bin/sleep 0 にかかる時間 [usec] + function ble/util/msleep/.core2 { + ((v-=_ble_util_msleep_delay2)) + ble/bin/sleep "$((v/1000000))" + ((v%=1000000)) + } + function ble/util/msleep { + local v=$((1000*$1-_ble_util_msleep_delay1)) + ((v<=0)) && v=100 + ((v>1000000+_ble_util_msleep_delay2)) && + ble/util/msleep/.core2 + ble/util/sprintf v '%d.%06d' "$((v/1000000))" "$((v%1000000))" + ! ble/bash/read-timeout "$v" v < /dev/udp/0.0.0.0/80 + } + function ble/util/msleep/.calibrate-loop { + local _ble_measure_threshold=10000 + local ret nsec _ble_measure_count=1 v=0 + _ble_util_msleep_delay1=0 ble-measure 'ble/util/msleep 1' + local delay=$((nsec/1000-1000)) count=$_ble_util_msleep_calibrate_count + ((count<=0||delay<_ble_util_msleep_delay1)) && _ble_util_msleep_delay1=$delay # 最小値 + _ble_util_msleep_delay2=0 ble-measure 'ble/util/msleep/.core2' + local delay=$((nsec/1000)) + ((count<=0||delay<_ble_util_msleep_delay2)) && _ble_util_msleep_delay2=$delay # 最小値 + } ;; + (procsub) + _ble_util_msleep_delay=300 + ble/fd#alloc _ble_util_msleep_fd '< <( + [[ $- == *i* ]] && builtin trap -- '' INT QUIT + while kill -0 $$; do command sleep 300; done &>/dev/null + )' + function ble/util/msleep { + local v=$((1000*$1-_ble_util_msleep_delay)) + ((v<=0)) && v=100 + ble/util/sprintf v '%d.%06d' "$((v/1000000))" "$((v%1000000))" + ! ble/bash/read-timeout "$v" -u "$_ble_util_msleep_fd" v + } ;; + (*.*) + if local rex='^(fifo|zero|ptmx)\.(open|exec)([12])(-[_a-zA-Z0-9]+)?$'; [[ $msleep_type =~ $rex ]]; then + local file=${BASH_REMATCH[1]} + local open=${BASH_REMATCH[2]} + local direction=${BASH_REMATCH[3]} + local fall=${BASH_REMATCH[4]} + case $file in + (fifo) + _ble_util_msleep_tmp=$_ble_base_run/$$.util.msleep.pipe + if [[ ! -p $_ble_util_msleep_tmp ]]; then + [[ -e $_ble_util_msleep_tmp ]] && ble/bin/rm -rf "$_ble_util_msleep_tmp" + ble/bin/mkfifo "$_ble_util_msleep_tmp" + fi ;; + (zero) + open=dup + _ble_util_msleep_tmp=$_ble_util_fd_zero ;; + (ptmx) + _ble_util_msleep_tmp=/dev/ptmx ;; + esac + local redir='<' + ((direction==2)) && redir='<>' + if [[ $open == dup ]]; then + _ble_util_msleep_fd=$_ble_util_msleep_tmp + _ble_util_msleep_read='! ble/bash/read-timeout "$v" -u "$_ble_util_msleep_fd" v' + elif [[ $open == exec ]]; then + ble/fd#alloc _ble_util_msleep_fd "$redir \"\$_ble_util_msleep_tmp\"" base + _ble_util_msleep_read='! ble/bash/read-timeout "$v" -u "$_ble_util_msleep_fd" v' + else + _ble_util_msleep_read='! ble/bash/read-timeout "$v" v '$redir' "$_ble_util_msleep_tmp"' + fi + if [[ $fall == '-coreutil' ]]; then + _ble_util_msleep_switch=200 # [msec] + _ble_util_msleep_delay1=2000 # short msleep にかかる時間 [usec] + _ble_util_msleep_delay2=50000 # /bin/sleep 0 にかかる時間 [usec] + function ble/util/msleep { + if (($1<_ble_util_msleep_switch)); then + local v=$((1000*$1-_ble_util_msleep_delay1)) + ((v<=0)) && v=100 + ble/util/sprintf v '%d.%06d' "$((v/1000000))" "$((v%1000000))" + builtin eval -- "$_ble_util_msleep_read" + else + local v=$((1000*$1-_ble_util_msleep_delay2)) + ((v<=0)) && v=100 + ble/util/sprintf v '%d.%06d' "$((v/1000000))" "$((v%1000000))" + ble/bin/sleep "$v" + fi + } + function ble/util/msleep/.calibrate-loop { + local _ble_measure_threshold=10000 + local ret nsec _ble_measure_count=1 + _ble_util_msleep_switch=200 + _ble_util_msleep_delay1=0 ble-measure 'ble/util/msleep 1' + local delay=$((nsec/1000-1000)) count=$_ble_util_msleep_calibrate_count + ((count<=0||delay<_ble_util_msleep_delay1)) && _ble_util_msleep_delay1=$delay # 最小値を選択 + _ble_util_msleep_delay2=0 ble-measure 'ble/bin/sleep 0' + local delay=$((nsec/1000)) + ((count<=0||delay<_ble_util_msleep_delay2)) && _ble_util_msleep_delay2=$delay # 最小値を選択 + ((_ble_util_msleep_switch=_ble_util_msleep_delay2/1000+10)) + } + else + function ble/util/msleep { + local v=$((1000*$1-_ble_util_msleep_delay)) + ((v<=0)) && v=100 + ble/util/sprintf v '%d.%06d' "$((v/1000000))" "$((v%1000000))" + builtin eval -- "$_ble_util_msleep_read" + } + fi + fi ;; + esac + if [[ :$opts: == *:check:* && $_ble_util_msleep_fd ]]; then + if ble/bash/read-timeout 0.000001 -u "$_ble_util_msleep_fd" _ble_util_msleep_dummy 2>/dev/null; (($?<=128)); then + ble/fd#close _ble_util_msleep_fd + _ble_util_msleep_fd= + return 1 + fi + fi + return 0 +} +_ble_util_msleep_builtin_available= +if ((_ble_bash>=40400)) && ble/util/load-standard-builtin sleep; then + _ble_util_msleep_builtin_available=1 + _ble_util_msleep_delay=300 + function ble/util/msleep/.core { builtin sleep "$1"; } + function ble/builtin/sleep/.read-time { + a1=0 b1=0 + local unit= exp= + if local rex='^\+?([0-9]*)\.([0-9]*)([eE][-+]?[0-9]+)?([smhd]?)$'; [[ $1 =~ $rex ]]; then + a1=${BASH_REMATCH[1]} + b1=${BASH_REMATCH[2]}00000000000000 + b1=$((10#0${b1::14})) + exp=${BASH_REMATCH[3]} + unit=${BASH_REMATCH[4]} + elif rex='^\+?([0-9]+)([eE][-+]?[0-9]+)?([smhd]?)$'; [[ $1 =~ $rex ]]; then + a1=${BASH_REMATCH[1]} + exp=${BASH_REMATCH[2]} + unit=${BASH_REMATCH[3]} + else + ble/util/print "ble/builtin/sleep: invalid time spec '$1'" >&2 + flags=E$flags + return 2 + fi + if [[ $exp ]]; then + case $exp in + ([eE]-*) + ((exp=10#0${exp:2})) + while ((exp--)); do + ((b1=a1%10*frac_scale/10+b1/10,a1/=10)) + done ;; + ([eE]*) + exp=${exp:1} + ((exp=${exp#+})) + while ((exp--)); do + ((b1*=10,a1=a1*10+b1/frac_scale,b1%=frac_scale)) + done ;; + esac + fi + local scale= + case $unit in + (d) ((scale=24*3600)) ;; + (h) ((scale=3600)) ;; + (m) ((scale=60)) ;; + esac + if [[ $scale ]]; then + ((b1*=scale)) + ((a1=a1*scale+b1/frac_scale)) + ((b1%=frac_scale)) + fi + return 0 + } + function ble/builtin/sleep { + local set shopt; ble/base/.adjust-bash-options set shopt + local frac_scale=100000000000000 + local a=0 b=0 flags= + if (($#==0)); then + ble/util/print "ble/builtin/sleep: no argument" >&2 + flags=E$flags + fi + while (($#)); do + case $1 in + (--version) flags=v$flags ;; + (--help) flags=h$flags ;; + (-*) + flags=E$flags + ble/util/print "ble/builtin/sleep: unknown option '$1'" >&2 ;; + (*) + if local a1 b1; ble/builtin/sleep/.read-time "$1"; then + ((b+=b1)) + ((a=a+a1+b/frac_scale)) + ((b%=frac_scale)) + fi ;; + esac + shift + done + if [[ $flags == *h* ]]; then + ble/util/print-lines \ + 'usage: sleep NUMBER[SUFFIX]...' \ + 'Pause for the time specified by the sum of the arguments. SUFFIX is one of "s"' \ + '(seconds), "m" (minutes), "h" (hours) or "d" (days).' \ + '' \ + 'OPTIONS' \ + ' --help Show this help.' \ + ' --version Show version.' + fi + if [[ $flags == *v* ]]; then + ble/util/print "sleep (ble) $BLE_VERSION" + fi + if [[ $flags == *E* ]]; then + ble/util/setexit 2 + elif [[ $flags == *[vh]* ]]; then + ble/util/setexit 0 + else + b=00000000000000$b + b=${b:${#b}-14} + builtin sleep "$a.$b" + fi + local ext=$? + ble/base/.restore-bash-options set shopt 1 + return "$ext" + } + function sleep { + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_local_adjust" + ble/builtin/sleep "$@" + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_local_return" + } +elif [[ -f $_ble_base/lib/init-msleep.sh ]] && + source "$_ble_base/lib/init-msleep.sh" && + ble/util/msleep/.load-compiled-builtin +then + function ble/util/msleep { ble/builtin/msleep "$1"; } +elif ((40000<=_ble_bash&&!(40300<=_ble_bash&&_ble_bash<50200))) && + [[ $OSTYPE != cygwin* && $OSTYPE != mingw* && $OSTYPE != haiku* && $OSTYPE != minix* ]] +then + ble/util/msleep/.use-read-timeout fifo.exec2 +elif ((_ble_bash>=40000)) && ble/fd#is-open "$_ble_util_fd_zero"; then + ble/util/msleep/.use-read-timeout zero.exec1-coreutil +elif ble/bin#freeze-utility-path sleepenh; then + function ble/util/msleep/.core { ble/bin/sleepenh "$1" &>/dev/null; } +elif ble/bin#freeze-utility-path usleep; then + function ble/util/msleep { + local v=$((1000*$1-_ble_util_msleep_delay)) + ((v<=0)) && v=0 + ble/bin/usleep "$v" &>/dev/null + } +elif ble/util/msleep/.check-sleep-decimal-support; then + function ble/util/msleep/.core { ble/bin/sleep "$1"; } +fi +function ble/util/sleep { + local msec=$((${1%%.*}*1000)) + if [[ $1 == *.* ]]; then + frac=${1##*.}000 + ((msec+=10#0${frac::3})) + fi + ble/util/msleep "$msec" +} +function ble/util/conditional-sync/.collect-descendant-pids { + local pid=$1 awk_script=' + $1 ~ /^[0-9]+$/ && $2 ~ /^[0-9]+$/ { + child[$2,child[$2]++]=$1; + } + function print_recursive(pid, _, n, i) { + if (child[pid]) { + n = child[pid]; + child[pid] = 0; # avoid infinite loop + for (i = 0; i < n; i++) { + print_recursive(child[pid, i]); + } + } + print pid; + } + END { print_recursive(pid); } + ' + ble/util/assign ret 'ble/bin/ps -A -o pid,ppid' + ble/util/assign-array ret 'ble/bin/awk -v pid="$pid" "$awk_script" <<< "$ret"' +} +function ble/util/conditional-sync/.kill { + [[ $__ble_pid ]] || return 0 + local kill_pids + if [[ :$__ble_opts: == *:killall:* ]]; then + ble/util/conditional-sync/.collect-descendant-pids "$__ble_pid" + kill_pids=("${ret[@]}") + else + kill_pids=("$__ble_pid") + fi + if [[ $OSTYPE == cygwin* || $OSTYPE == msys* ]]; then + (ble/util/setexit 0) + fi + if [[ :$__ble_opts: == *:SIGKILL:* ]]; then + builtin kill -9 "${kill_pids[@]}" &>/dev/null + else + builtin kill -- "${kill_pids[@]}" &>/dev/null + fi +} &>/dev/null +function ble/util/conditional-sync { + local __ble_command=$1 + local __ble_continue=${2:-'! ble/decode/has-input'} + local __ble_weight=$3; ((__ble_weight<=0&&(__ble_weight=100))) + local __ble_opts=$4 + local __ble_timeout= __ble_rex=':timeout=([^:]+):' + [[ :$__ble_opts: =~ $__ble_rex ]] && ((__ble_timeout=BASH_REMATCH[1])) + [[ :$__ble_opts: == *:progressive-weight:* ]] && + local __ble_weight_max=$__ble_weight __ble_weight=1 + local ret + ble/opts#extract-last-optarg "$__ble_opts" pid + local __ble_pid=$ret + ble/util/unlocal ret + local sync_elapsed=0 + if [[ $__ble_timeout ]] && ((__ble_timeout<=0)); then + ble/util/conditional-sync/.kill + return 142 + fi + builtin eval -- "$__ble_continue" || return 148 + ( + ble/util/joblist/__suppress__ + [[ $__ble_pid ]] || { builtin eval -- "$__ble_command" & __ble_pid=$!; } + while + if [[ $__ble_timeout ]]; then + if ((__ble_timeout<=0)); then + ble/util/conditional-sync/.kill + return 142 + fi + ((__ble_weight>__ble_timeout)) && __ble_weight=$__ble_timeout + ((__ble_timeout-=__ble_weight)) + fi + ble/util/msleep "$__ble_weight" + ((sync_elapsed+=__ble_weight)) + [[ :$__ble_opts: == *:progressive-weight:* ]] && + ((__ble_weight<<=1,__ble_weight>__ble_weight_max&&(__ble_weight=__ble_weight_max))) + [[ ! $__ble_pid ]] || builtin kill -0 "$__ble_pid" &>/dev/null + do + if ! builtin eval -- "$__ble_continue"; then + ble/util/conditional-sync/.kill + return 148 + fi + done + [[ ! $__ble_pid || :$__ble_opts: == *:no-wait-pid:* ]] || wait "$__ble_pid" + ) +} +function ble/util/cat/.impl { + local content= IFS= + while ble/bash/read -d '' content; do + printf '%s\0' "$content" + done + [[ $content ]] && printf '%s' "$content" +} +function ble/util/cat { + if (($#)); then + local file + for file; do ble/util/cat/.impl < "$1"; done + else + ble/util/cat/.impl + fi +} +_ble_util_less_fallback= +function ble/util/get-pager { + if [[ ! $_ble_util_less_fallback ]]; then + if ble/bin#has less; then + _ble_util_less_fallback=less + elif ble/bin#has pager; then + _ble_util_less_fallback=pager + elif ble/bin#has more; then + _ble_util_less_fallback=more + else + _ble_util_less_fallback=cat + fi + fi + builtin eval "$1=\${bleopt_pager:-\${PAGER:-\$_ble_util_less_fallback}}" +} +function ble/util/pager { + local pager; ble/util/get-pager pager + builtin eval -- "$pager \"\$@\"" +} +_ble_util_file_stat= +function ble/file/has-stat { + if [[ ! $_ble_util_file_stat ]]; then + _ble_util_file_stat=- + if ble/bin#freeze-utility-path -n stat; then + if ble/bin/stat -c %Y / &>/dev/null; then + _ble_util_file_stat=c + elif ble/bin/stat -f %m / &>/dev/null; then + _ble_util_file_stat=f + fi + fi + fi + function ble/file/has-stat { [[ $_ble_util_file_stat != - ]]; } || return 1 + ble/file/has-stat +} +function ble/file#mtime { + function ble/file#mtime { ble/util/time; ret=("$ret"); } || return 1 + if ble/bin/date -r / +%s &>/dev/null; then + function ble/file#mtime { local file=$1; ble/util/assign-words ret 'ble/bin/date -r "$file" +"%s %N"' 2>/dev/null; } + elif ble/file/has-stat; then + case $_ble_util_file_stat in + (c) function ble/file#mtime { local file=$1; ble/util/assign ret 'ble/bin/stat -c %Y "$file"' 2>/dev/null; } ;; + (f) function ble/file#mtime { local file=$1; ble/util/assign ret 'ble/bin/stat -f %m "$file"' 2>/dev/null; } ;; + esac + fi + ble/file#mtime "$@" +} +function ble/file#inode { + function ble/file#inode { ret=; ((0)); } || return 1 + if ble/bin#freeze-utility-path -n ls && + ble/util/assign-words ret 'ble/bin/ls -di /' 2>/dev/null && + ((${#ret[@]}==2)) && ble/string#match "$ret" '^[0-9]+$' + then + function ble/file#inode { local file=$1; ble/util/assign-words ret 'ble/bin/ls -di "$file"' 2>/dev/null; } + elif ble/file/has-stat; then + case $_ble_util_file_stat in + (c) function ble/file#inode { local file=$1; ble/util/assign-words ret 'ble/bin/stat -c %i "$file"' 2>/dev/null; } ;; + (f) function ble/file#inode { local file=$1; ble/util/assign-words ret 'ble/bin/stat -f %i "$file"' 2>/dev/null; } ;; + esac + fi + ble/file#inode "$@" +} +function ble/file#hash { + local file=$1 size + if ! ble/util/assign size 'ble/bin/wc -c "$file" 2>/dev/null'; then + ret=error:$RANDOM + return 1 + fi + ble/string#split-words size "$size" + ble/file#hash/.impl +} +if ble/bin#freeze-utility-path -n git; then + function ble/file#hash/.impl { + ble/util/assign ret 'ble/bin/git hash-object "$file"' + ret="size:$size;hash:$ret" + } +elif ble/bin#freeze-utility-path -n openssl; then + function ble/file#hash/.impl { + ble/util/assign-words ret 'ble/bin/openssl sha1 -r "$file"' + ret="size:$size;sha1:$ret" + } +elif ble/bin#freeze-utility-path -n sha1sum; then + function ble/file#hash/.impl { + ble/util/assign-words ret 'ble/bin/sha1sum "$file"' + ret="size:$size;sha1:$ret" + } +elif ble/bin#freeze-utility-path -n sha1; then + function ble/file#hash/.impl { + ble/util/assign-words ret 'ble/bin/sha1 -r "$file"' + ret="size:$size;sha1:$ret" + } +elif ble/bin#freeze-utility-path -n md5sum; then + function ble/file#hash/.impl { + ble/util/assign-words ret 'ble/bin/md5sum "$file"' + ret="size:$size;md5:$ret" + } +elif ble/bin#freeze-utility-path -n md5; then + function ble/file#hash/.impl { + ble/util/assign-words ret 'ble/bin/md5 -r "$file"' + ret="size:$size;md5:$ret" + } +elif ble/bin#freeze-utility-path -n cksum; then + function ble/file#hash/.impl { + ble/util/assign-words ret 'ble/bin/cksum "$file"' + ret="size:$size;cksum:$ret" + } +else + function ble/file#hash/.impl { + ret="size:$size" + } +fi +_ble_util_buffer=() +function ble/util/buffer { + _ble_util_buffer[${#_ble_util_buffer[@]}]=$1 +} +function ble/util/buffer.print { + ble/util/buffer "$1"$'\n' +} +function ble/util/buffer.print-lines { + local line + for line; do + ble/util/buffer "$line"$'\n' + done +} +function ble/util/buffer.flush { + IFS= builtin eval 'local text="${_ble_util_buffer[*]-}"' + _ble_util_buffer=() + [[ $text ]] || return 0 + if [[ $_ble_term_state == internal ]]; then + if [[ $_ble_term_cursor_hidden_current == hidden ]]; then + text=$_ble_term_civis$text + else + text=$_ble_term_civis$text$_ble_term_rmcivis + fi + [[ $bleopt_term_synchronized_update_mode == on ]] && + text=$'\e[?2026h'$text$'\e[?2026l' + fi + ble/util/put "$text" >&"$_ble_util_fd_tui_stderr" +} +function ble/util/buffer.clear { + _ble_util_buffer=() +} +function ble/dirty-range#load { + local prefix= + if [[ $1 == --prefix=* ]]; then + prefix=${1#--prefix=} + ((beg=${prefix}beg, + end=${prefix}end, + end0=${prefix}end0)) + fi +} +function ble/dirty-range#clear { + local prefix= + if [[ $1 == --prefix=* ]]; then + prefix=${1#--prefix=} + shift + fi + ((${prefix}beg=-1, + ${prefix}end=-1, + ${prefix}end0=-1)) +} +function ble/dirty-range#update { + local prefix= + if [[ $1 == --prefix=* ]]; then + prefix=${1#--prefix=} + shift + [[ $prefix ]] && local beg end end0 + fi + local begB=$1 endB=$2 endB0=$3 + ((begB<0)) && return 1 + local begA endA endA0 + ((begA=${prefix}beg,endA=${prefix}end,endA0=${prefix}end0)) + local delta + if ((begA<0)); then + ((beg=begB, + end=endB, + end0=endB0)) + else + ((beg=begA0?(end+=delta):(end0-=delta))) + fi + fi + if [[ $prefix ]]; then + ((${prefix}beg=beg, + ${prefix}end=end, + ${prefix}end0=end0)) + fi +} +function ble/urange#clear { + local prefix= + if [[ $1 == --prefix=* ]]; then + prefix=${1#*=}; shift + fi + ((${prefix}umin=-1,${prefix}umax=-1)) +} +function ble/urange#update { + local prefix= + if [[ $1 == --prefix=* ]]; then + prefix=${1#*=}; shift + fi + local min=$1 max=$2 + ((0<=min&&min=0)) || return 1 + [[ $shift ]] || ((shift=dend-dend0)) + ((${prefix}umin>=0&&( + dbeg<=${prefix}umin&&(${prefix}umin<=dend0?(${prefix}umin=dend):(${prefix}umin+=shift)), + dbeg<=${prefix}umax&&(${prefix}umax<=dend0?(${prefix}umax=dbeg):(${prefix}umax+=shift))), + ${prefix}umin<${prefix}umax||( + ${prefix}umin=-1, + ${prefix}umax=-1))) +} +_ble_util_joblist_jobs= +_ble_util_joblist_list=() +_ble_util_joblist_events=() +function ble/util/joblist { + local opts=$1 jobs0 + ble/util/assign jobs0 'jobs' + ((_ble_bash>=50300)) && jobs >/dev/null + if [[ $jobs0 == "$_ble_util_joblist_jobs" ]]; then + joblist=("${_ble_util_joblist_list[@]}") + return 0 + elif [[ ! $jobs0 ]]; then + _ble_util_joblist_jobs= + _ble_util_joblist_list=() + joblist=() + return 0 + fi + local lines list ijob + ble/string#split lines $'\n' "$jobs0" + if ((${#lines[@]})); then + ble/util/joblist.split list "${lines[@]}" + else + list=() + fi + if [[ $jobs0 != "$_ble_util_joblist_jobs" ]]; then + for ijob in "${!list[@]}"; do + if [[ ${_ble_util_joblist_list[ijob]} && ${list[ijob]#'['*']'[-+ ]} != "${_ble_util_joblist_list[ijob]#'['*']'[-+ ]}" ]]; then + ble/array#push _ble_util_joblist_events "${list[ijob]}" + list[ijob]= + fi + done + fi + ble/util/assign _ble_util_joblist_jobs 'jobs' + _ble_util_joblist_list=() + if [[ $_ble_util_joblist_jobs != "$jobs0" ]]; then + ble/string#split lines $'\n' "$_ble_util_joblist_jobs" + ble/util/joblist.split _ble_util_joblist_list "${lines[@]}" + if [[ :$opts: != *:ignore-volatile-jobs:* ]]; then + for ijob in "${!list[@]}"; do + local job0=${list[ijob]} + if [[ $job0 && ! ${_ble_util_joblist_list[ijob]} ]]; then + ble/array#push _ble_util_joblist_events "$job0" + fi + done + fi + else + for ijob in "${!list[@]}"; do + [[ ${list[ijob]} ]] && + _ble_util_joblist_list[ijob]=${list[ijob]} + done + fi + joblist=("${_ble_util_joblist_list[@]}") +} 2>/dev/null +function ble/util/joblist/__suppress__ { return 0; } +function ble/util/joblist.split { + local arr=$1; shift + local line ijob= rex_ijob='^\[([0-9]+)\]' + local -a out=() + for line; do + [[ $line =~ $rex_ijob ]] && ijob=${BASH_REMATCH[1]} + [[ $ijob ]] && out[ijob]=${out[ijob]:+${out[ijob]}$_ble_term_nl}$line + done + for ijob in "${!out[@]}"; do + [[ ${out[ijob]} != *'ble/util/joblist/__suppress__'* ]] && + builtin eval -- "$arr[ijob]=\${out[ijob]}" + done +} +function ble/util/joblist.check { + local joblist + ble/util/joblist "$@" +} +function ble/util/joblist.has-events { + local joblist + ble/util/joblist + ((${#_ble_util_joblist_events[@]})) +} +function ble/util/joblist.flush { + local joblist + ble/util/joblist + ((${#_ble_util_joblist_events[@]})) || return 1 + printf '%s\n' "${_ble_util_joblist_events[@]}" + _ble_util_joblist_events=() +} +function ble/util/joblist.bflush { + local joblist out + ble/util/joblist + ((${#_ble_util_joblist_events[@]})) || return 1 + ble/util/sprintf out '%s\n' "${_ble_util_joblist_events[@]}" + ble/util/buffer "$out" + _ble_util_joblist_events=() +} +function ble/util/joblist.clear { + _ble_util_joblist_jobs= + _ble_util_joblist_list=() +} +function ble/util/save-editing-mode { + if [[ -o emacs ]]; then + builtin eval "$1=emacs" + elif [[ -o vi ]]; then + builtin eval "$1=vi" + else + builtin eval "$1=none" + fi +} +function ble/util/restore-editing-mode { + case ${!1} in + (emacs) set -o emacs ;; + (vi) set -o vi ;; + (none) set +o emacs ;; + esac +} +function ble/util/reset-keymap-of-editing-mode { + if [[ -o emacs ]]; then + set -o emacs + elif [[ -o vi ]]; then + set -o vi + fi +} +function ble/util/rlvar#load { + ble/util/assign _ble_local_rlvars 'builtin bind -v 2>/dev/null' + _ble_local_rlvars=$'\n'$_ble_local_rlvars +} +function ble/util/rlvar#has { + if [[ ! ${_ble_local_rlvars:-} ]]; then + local _ble_local_rlvars + ble/util/rlvar#load + fi + [[ $_ble_local_rlvars == *$'\n'"set $1 "* ]] +} +function ble/util/rlvar#test { + if [[ ! ${_ble_local_rlvars:-} ]]; then + local _ble_local_rlvars + ble/util/rlvar#load + fi + if [[ $_ble_local_rlvars == *$'\n'"set $1 on"* ]]; then + return 0 + elif [[ $_ble_local_rlvars == *$'\n'"set $1 off"* ]]; then + return 1 + elif (($#>=2)); then + (($2)) + return "$?" + else + return 2 + fi +} +function ble/util/rlvar#read { + [[ ${2+set} ]] && ret=$2 + if [[ ! ${_ble_local_rlvars:-} ]]; then + local _ble_local_rlvars + ble/util/rlvar#load + fi + local rhs=${_ble_local_rlvars#*$'\n'"set $1 "} + [[ $rhs != "$_ble_local_rlvars" ]] && ret=${rhs%%$'\n'*} +} +function ble/util/rlvar#bind-bleopt { + local name=$1 bleopt=$2 opts=$3 + if [[ ! ${_ble_local_rlvars:-} ]]; then + local _ble_local_rlvars + ble/util/rlvar#load + fi + if ble/util/rlvar#has "$name"; then + if [[ :$_ble_base_arguments_opts: == *:keep-rlvars:* ]]; then + local ret; ble/util/rlvar#read "$name" + [[ :$opts: == *:bool:* && $ret == off ]] && ret= + bleopt "$bleopt=$ret" + else + local var=bleopt_$bleopt val=off + [[ ${!var:-} ]] && val=on + builtin bind "set $name $val" 2>/dev/null + fi + local proc_original= + if ble/is-function "bleopt/check:$bleopt"; then + ble/function#push "bleopt/check:$bleopt" + proc_original='ble/function#push/call-top "$@" || return "$?"' + fi + local proc_set='builtin bind "set '$name' $value" 2>/dev/null' + if [[ :$opts: == *:bool:* ]]; then + proc_set=' + if [[ $value ]]; then + builtin bind "set '$name' on" 2>/dev/null + else + builtin bind "set '$name' off" 2>/dev/null + fi' + fi + builtin eval -- " + function bleopt/check:$bleopt { + $proc_original + $proc_set + return 0 + }" + fi + local proc_bleopt='bleopt '$bleopt'="$1"' + if [[ :$opts: == *:bool:* ]]; then + proc_bleopt=' + local value; ble/string#split-words value "$1" + if [[ ${value-} == 1 || ${value-} == [Oo][Nn] ]]; then + bleopt '$bleopt'="$value" + else + bleopt '$bleopt'= + fi' + fi + builtin eval -- " + function ble/builtin/bind/set:$name { + $proc_bleopt + return 0 + }" +} +function ble/util/invoke-hook { + local -a hooks; builtin eval "hooks=(\"\${$1[@]}\")" + local hook ext=0 + for hook in "${hooks[@]}"; do builtin eval -- "$hook \"\${@:2}\"" || ext=$?; done + return "$ext" +} +function ble/util/.read-arguments-for-no-option-command { + local commandname=$1; shift + flags= args=() + local flag_literal= + while (($#)); do + local arg=$1; shift + if [[ ! $flag_literal ]]; then + case $arg in + (--) flag_literal=1 ;; + (--help) flags=h$flags ;; + (-*) + ble/util/print "$commandname: unrecognized option '$arg'" >&2 + flags=e$flags ;; + (*) + ble/array#push args "$arg" ;; + esac + else + ble/array#push args "$arg" + fi + done +} +function ble/util/autoload { + local file=$1; shift + ble/util/import/is-loaded "$file" && return 0 + local q=\' Q="'\''" funcname + for funcname; do + builtin eval "function $funcname { + builtin unset -f $funcname + ble-import '${file//$q/$Q}' && + $funcname \"\$@\" + }" + done +} +function ble/util/autoload/.print-usage { + ble/util/print 'usage: ble-autoload SCRIPTFILE FUNCTION...' + ble/util/print ' Setup delayed loading of functions defined in the specified script file.' +} >&2 +function ble/util/autoload/.read-arguments { + file= flags= functions=() + local args + ble/util/.read-arguments-for-no-option-command ble-autoload "$@" + local arg index=0 + for arg in "${args[@]}"; do + if [[ ! $arg ]]; then + if ((index==0)); then + ble/util/print 'ble-autoload: the script filename should not be empty.' >&2 + else + ble/util/print 'ble-autoload: function names should not be empty.' >&2 + fi + flags=e$flags + fi + ((index++)) + done + [[ $flags == *h* ]] && return 0 + if ((${#args[*]}==0)); then + ble/util/print 'ble-autoload: script filename is not specified.' >&2 + flags=e$flags + elif ((${#args[*]}==1)); then + ble/util/print 'ble-autoload: function names are not specified.' >&2 + flags=e$flags + fi + file=${args[0]} functions=("${args[@]:1}") +} +function ble-autoload { + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_local_adjust" + local file flags + local -a functions=() + ble/util/autoload/.read-arguments "$@" + if [[ $flags == *[eh]* ]]; then + [[ $flags == *e* ]] && builtin printf '\n' + ble/util/autoload/.print-usage + local ext=0 + [[ $flags == *e* ]] && ext=2 + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_local_leave" + return "$ext" + fi + ble/util/autoload "$file" "${functions[@]}" + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_local_return" +} +_ble_util_import_files=() +bleopt/declare -n import_path "${XDG_DATA_HOME:-$HOME/.local/share}/blesh/local" +function ble/util/import/search/.check-directory { + local name=$1 dir=${2%/} + [[ -d ${dir:=/} ]] || return 1 + if [[ $name == lib/* ]]; then + [[ $dir == */lib ]] || return 1 + dir=${dir%/lib} + elif [[ $name == contrib/* ]]; then + [[ $dir == */contrib ]] || return 1 + dir=${dir%/contrib} + fi + if [[ -f $dir/$name ]]; then + ret=$dir/$name + return 0 + elif [[ $name != *.bash && -f $dir/$name.bash ]]; then + ret=$dir/$name.bash + return 0 + elif [[ $name != *.sh && -f $dir/$name.sh ]]; then + ret=$dir/$name.sh + return 0 + fi + return 1 +} +function ble/util/import/search { + ret=$1 + if [[ $ret != /* && $ret != ./* && $ret != ../* ]]; then + local -a dirs=() + if [[ $bleopt_import_path ]]; then + local tmp; ble/string#split tmp : "$bleopt_import_path" + ble/array#push dirs "${tmp[@]}" + fi + ble/array#push dirs "$_ble_base"{,/contrib,/lib} + "${_ble_util_set_declare[@]//NAME/checked}" # WA #D1570 checked + local path + for path in "${dirs[@]}"; do + ble/set#contains checked "$path" && continue + ble/set#add checked "$path" + ble/util/import/search/.check-directory "$ret" "$path" && break + done + fi + [[ -e $ret && ! -d $ret ]] +} +function ble/util/import/encode-filename { + ret=$1 + local chars=%$'\t\n !"$&\'();<>\\^`|' # + if [[ $ret == *["$chars"]* ]]; then + local i n=${#chars} reps a b + reps=(%{25,08,0A,2{0..2},24,2{6..9},3B,3C,3E,5C,5E,60,7C}) + for ((i=0;i&2 + flags=E$flags + fi ;; + (*) + ble/util/print "ble-import: unrecognized option '$arg'" >&2 + flags=E$flags ;; + esac + continue ;; + (-?*) + local i c + for ((i=1;i<${#arg};i++)); do + c=${arg:i:1} + case $c in + ([dfq]) flags=$c$flags ;; + (C) + if ((i+1<${#arg})); then + ble/array#push callbacks "${arg:i+1}" + elif (($#)); then + ble/array#push callbacks "$1" + shift + else + ble/util/print "ble-import: missing optarg for '-C'" >&2 + flags=E$flags + fi + break ;; + (*) + ble/util/print "ble-import: unrecognized option '-$c'" >&2 + flags=E$flags ;; + esac + done + continue ;; + esac + fi + local ret + if ! ble/util/import/search "$arg"; then + ble/array#push not_found "$arg" + continue + fi; local file=$ret + ble/array#push files "$file" + done + if ((${#not_found[@]})); then + flags=N$flags + if [[ $flags != *[fq]* ]]; then + local file + for file in "${not_found[@]}"; do + ble/util/print "ble-import: file '$file' not found" >&2 + done + flags=E$flags + fi + fi + return 0 +} +function ble/util/import { + local files file ext=0 ret enc + files=("$@") + set -- # Note #D1859: source によって引数が継承されるのを防ぐ + for file in "${files[@]}"; do + ble/util/import/encode-filename "$file"; enc=$ret + local guard=ble/util/import/guard:$enc + ble/is-function "$guard" && return 0 + [[ -e $file ]] || return 1 + source "$file" || { ext=$?; continue; } + builtin eval "function $guard { return 0; }" + ble/array#push _ble_util_import_files "$file" + local onload=ble/util/import/onload:$enc + ble/function#try "$onload" ble/util/invoke-hook + done + return "$ext" +} +function ble/util/import/option:query { + if [[ $flags == *N* ]]; then + return 127 + elif ((${#files[@]})); then + local file + for file in "${files[@]}"; do + ble/util/import/is-loaded "$file" || return 1 + done + return 0 + else + ble/util/print-lines "${_ble_util_import_files[@]}" + return "$?" + fi +} +function ble/util/import/.dispatch { + local files flags callbacks + ble/util/import/.read-arguments "$@" + if [[ $flags == *[Eh]* ]]; then + [[ $flags == *E* ]] && ble/util/print + ble/util/print-lines \ + 'usage: ble-import [-dfq|--delay|--force|--query]' \ + ' [-C CALLBACK|--callback=CALLBACK]+ [--] [SCRIPTFILE...]' \ + 'usage: ble-import --help' \ + '' \ + ' Search and source script files that have not yet been loaded. When none of' \ + ' -q, --query, -d, --delay, -C, --callback is specified, SCRIPTFILEs are' \ + ' sourced.' \ + '' \ + ' OPTIONS' \ + ' --help Show this help.' \ + ' -d, --delay Register SCRIPTFILEs for later loading in idle time.' \ + ' -f, --force Ignore non-existent files without errors.' \ + ' -q, --query When SCRIPTFILEs are specified, test if all of these files' \ + ' are already loaded. Without SCRIPTFILEs, print the list of' \ + ' already imported files.' \ + ' -C, --callback=CALLBACK' \ + ' Specify a command that will be evaluated when all of' \ + ' SCRIPTFILEs are loaded. If all of SCRIPTFILEs are already' \ + ' loaded, the callback is immediately evaluated.' \ + '' \ + >&2 + [[ $flags == *E* ]] && return 2 + return 0 + fi + if [[ $flags == *q* ]]; then + ble/util/import/option:query + return "$?" + fi + if ((!${#files[@]})); then + [[ $flags == *f* ]] && return 0 + ble/util/print 'ble-import: files are not specified.' >&2 + return 2 + fi + if ((${#callbacks[@]})); then + local file i q=\' Q="'\''" + for file in "${files[@]}"; do + ble/util/import/is-loaded "$file" && continue + for i in "${!callbacks[@]}"; do + callbacks[i]="ble/util/import/eval-after-load '${file//$q/$Q}' '${callbacks[i]//$q/$Q}'" + done + done + local cb + for cb in "${callbacks[@]}"; do + builtin eval -- "$cb" + done + fi + if [[ $flags == *d* ]] && ble/is-function ble/util/idle.push; then + local ret + ble/string#quote-command ble/util/import "${files[@]}" + ble/util/idle.push "$ret" + return 0 + fi + ((${#callbacks[@]})) || ble/util/import "${files[@]}" +} +function ble-import { + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_local_adjust" + ble/util/import/.dispatch "$@" + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_local_return" +} +_ble_util_import_onload_count=0 +function ble/util/import/eval-after-load { + local ret file + if ! ble/util/import/search "$1"; then + ble/util/print "ble-import: file '$1' not found." >&2 + return 2 + fi; file=$ret + ble/util/import/encode-filename "$file"; local enc=$ret + local guard=ble/util/import/guard:$enc + if ble/is-function "$guard"; then + builtin eval -- "$2" + else + local onload=ble/util/import/onload:$enc + if ! ble/is-function "$onload"; then + local q=\' Q="'\''" list=_ble_util_import_onload_$((_ble_util_import_onload_count++)) + builtin eval -- "$list=(); function $onload { \"\$1\" $list \"\${@:2}\"; }" + fi + "$onload" ble/array#push "$2" + fi +} +_ble_util_stackdump_title=stackdump +_ble_util_stackdump_start= +function ble/util/stackdump { + ((bleopt_internal_stackdump_enabled)) || return 1 + local message=$1 nl=$'\n' IFS=$_ble_term_IFS + message="$_ble_term_sgr0$_ble_util_stackdump_title: $message$nl" + local extdebug= iarg=$BASH_ARGC args= + shopt -q extdebug 2>/dev/null && extdebug=1 + local i i0=${_ble_util_stackdump_start:-1} iN=${#FUNCNAME[*]} + for ((i=i0;i&2 + [[ $flags == *e* ]] && ext=2 + return 1 + fi + return 0 +} +function ble-stackdump { + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_local_adjust" + local args ext + if ble/util/stackdump/.read-arguments "$@"; then + local _ble_util_stackdump_start=2 + local IFS=$_ble_term_IFS + ble/util/stackdump "${args[*]}" + ext=$? + fi + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_local_leave" + return "$ext" +} +function ble/util/assert { + local expr=$1 message=$2 + if ! builtin eval -- "$expr"; then + shift + local _ble_util_stackdump_title='assertion failure' + local _ble_util_stackdump_start=3 + ble/util/stackdump "$expr$_ble_term_nl$message" >&2 + return 1 + else + return 0 + fi +} +function ble/util/assert/.read-arguments { + ext=0 + local flags + ble/util/.read-arguments-for-no-option-command ble-assert "$@" + if [[ $flags != *h* ]]; then + if ((${#args[@]}==0)); then + ble/util/print 'ble-assert: command is not specified.' >&2 + flags=e$flags + fi + fi + if [[ $flags == *[eh]* ]]; then + [[ $flags == *e* ]] && ble/util/print + { + ble/util/print 'usage: ble-assert command [message]' + ble/util/print ' Evaluate command and print stackdump on fail.' + } >&2 + [[ $flags == *e* ]] && ext=2 + return 1 + fi + return 0 +} +function ble-assert { + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_local_adjust" + local args ext + if ble/util/assert/.read-arguments "$@"; then + local IFS=$_ble_term_IFS + ble/util/assert "${args[0]}" "${args[*]:1}" + ext=$? + fi + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_local_leave" + return "$ext" +} +bleopt/declare -v debug_idle '' +_ble_util_clock_base= +_ble_util_clock_reso= +_ble_util_clock_type= +function ble/util/clock/.initialize { + local LC_ALL= LC_NUMERIC=C + if ((_ble_bash>=50000)) && { + local now=$EPOCHREALTIME + [[ $now == *.???* && $now != $EPOCHREALTIME ]]; }; then + builtin readonly EPOCHREALTIME + _ble_util_clock_base=$((10#0${now%.*})) + _ble_util_clock_reso=1 + _ble_util_clock_type=EPOCHREALTIME + function ble/util/clock { + local LC_ALL= LC_NUMERIC=C + local now=$EPOCHREALTIME + local integral=$((10#0${now%%.*}-_ble_util_clock_base)) + local mantissa=${now#*.}000; mantissa=${mantissa::3} + ((ret=integral*1000+10#0$mantissa)) + } + ble/function#suppress-stderr ble/util/clock # locale + elif [[ -r /proc/uptime ]] && { + local uptime + ble/util/readfile uptime /proc/uptime + ble/string#split-words uptime "$uptime" + [[ $uptime == *.* ]]; }; then + _ble_util_clock_base=$((10#0${uptime%.*})) + _ble_util_clock_reso=10 + _ble_util_clock_type=uptime + function ble/util/clock { + local now + ble/util/readfile now /proc/uptime + ble/string#split-words now "$now" + local integral=$((10#0${now%%.*}-_ble_util_clock_base)) + local fraction=${now#*.}000; fraction=${fraction::3} + ((ret=integral*1000+10#0$fraction)) + } + elif ((_ble_bash>=40200)); then + local ret + ble/util/time + _ble_util_clock_base=$ret + _ble_util_clock_reso=1000 + _ble_util_clock_type=printf + function ble/util/clock { + ble/util/time + ((ret=(ret-_ble_util_clock_base)*1000)) + } + elif [[ $SECONDS && ! ${SECONDS//[0-9]} ]]; then + builtin readonly SECONDS + _ble_util_clock_base=$SECONDS + _ble_util_clock_reso=1000 + _ble_util_clock_type=SECONDS + function ble/util/clock { + local now=$SECONDS + ((ret=(now-_ble_util_clock_base)*1000)) + } + else + local ret + ble/util/time + _ble_util_clock_base=$ret + _ble_util_clock_reso=1000 + _ble_util_clock_type=date + function ble/util/clock { + ble/util/time + ((ret=(ret-_ble_util_clock_base)*1000)) + } + fi +} +ble/util/clock/.initialize 2>/dev/null +if ((_ble_bash>=40000)); then + function ble/util/idle/IS_IDLE { ! ble/util/is-stdin-ready; } + _ble_util_idle_sclock=0 + function ble/util/idle/.sleep { + local msec=$1 + ((msec<=0)) && return 0 + ble/util/msleep "$msec" + ((_ble_util_idle_sclock+=msec)) + } + function ble/util/idle.clock/.initialize { + function ble/util/idle.clock/.initialize { return 0; } + function ble/util/idle.clock/.restart { return 0; } + if [[ ! $_ble_util_clock_type || $_ble_util_clock_type == date ]]; then + function ble/util/idle.clock { + ret=$_ble_util_idle_sclock + } + elif ((_ble_util_clock_reso<=100)); then + function ble/util/idle.clock { + ble/util/clock + } + else + _ble_util_idle_aclock_shift= + _ble_util_idle_aclock_tick_rclock= + _ble_util_idle_aclock_tick_sclock= + function ble/util/idle.clock/.restart { + _ble_util_idle_aclock_shift= + _ble_util_idle_aclock_tick_rclock= + _ble_util_idle_aclock_tick_sclock= + } + function ble/util/idle/.adjusted-clock { + local resolution=$_ble_util_clock_reso + local sclock=$_ble_util_idle_sclock + local ret; ble/util/clock; local rclock=$((ret/resolution*resolution)) + if [[ $_ble_util_idle_aclock_tick_rclock != "$rclock" ]]; then + if [[ $_ble_util_idle_aclock_tick_rclock && ! $_ble_util_idle_aclock_shift ]]; then + local delta=$((sclock-_ble_util_idle_aclock_tick_sclock)) + ((_ble_util_idle_aclock_shift=delta50000)) && [[ $_ble_util_msleep_builtin_available ]] && interval=20 + bleopt/declare -v idle_interval "$interval" + } + ble/util/idle/.initialize-options + _ble_util_idle_task=() + _ble_util_idle_lasttask= + _ble_util_idle_SEP=$_ble_term_FS + function ble/util/idle.do { + local IFS=$_ble_term_IFS + ble/util/idle/IS_IDLE || return 1 + ((${#_ble_util_idle_task[@]}==0)) && return 1 + ble/util/buffer.flush + local ret + ble/util/idle.clock/.initialize + ble/util/idle.clock/.restart + ble/util/idle.clock + local _ble_idle_clock_start=$ret + local _ble_idle_sclock_start=$_ble_util_idle_sclock + local _ble_idle_is_first=1 + local _ble_idle_processed= + local _ble_idle_info_shown= + local _ble_idle_after_task=0 + while :; do + local _ble_idle_key + local _ble_idle_next_time= _ble_idle_next_itime= _ble_idle_running= _ble_idle_waiting= + for _ble_idle_key in "${!_ble_util_idle_task[@]}"; do + ble/util/idle/IS_IDLE || break 2 + local _ble_idle_to_process= + local _ble_idle_status=${_ble_util_idle_task[_ble_idle_key]%%"$_ble_util_idle_SEP"*} + case ${_ble_idle_status::1} in + (R) _ble_idle_to_process=1 ;; + (I) [[ $_ble_idle_is_first ]] && _ble_idle_to_process=1 ;; + (S) ble/util/idle.do/.check-clock "$_ble_idle_status" && _ble_idle_to_process=1 ;; + (W) ble/util/idle.do/.check-clock "$_ble_idle_status" && _ble_idle_to_process=1 ;; + (F) [[ -s ${_ble_idle_status:1} ]] && _ble_idle_to_process=1 ;; + (E) [[ -e ${_ble_idle_status:1} ]] && _ble_idle_to_process=1 ;; + (P) ! builtin kill -0 ${_ble_idle_status:1} &>/dev/null && _ble_idle_to_process=1 ;; + (C) builtin eval -- "${_ble_idle_status:1}" && _ble_idle_to_process=1 ;; + (Z) ;; + (*) builtin unset -v '_ble_util_idle_task[_ble_idle_key]' + esac + if [[ $_ble_idle_to_process ]]; then + local _ble_idle_command=${_ble_util_idle_task[_ble_idle_key]#*"$_ble_util_idle_SEP"} + _ble_idle_processed=1 + ble/util/idle.do/.call-task "$_ble_idle_command" + ((_ble_idle_after_task++)) + elif [[ $_ble_idle_status == [FEPC]* ]]; then + _ble_idle_waiting=1 + fi + done + _ble_idle_is_first= + ble/util/idle.do/.sleep-until-next; local ext=$? + ((ext==148)) && break + [[ $_ble_idle_next_itime$_ble_idle_next_time$_ble_idle_running$_ble_idle_waiting ]] || break + done + [[ $_ble_idle_info_shown ]] && + ble/edit/info/immediate-default + ble/util/idle.do/.do-after-task + [[ $_ble_idle_processed ]] + } + function ble/util/idle.do/.do-after-task { + if ((_ble_idle_after_task)); then + blehook/invoke idle_after_task + _ble_idle_after_task=0 + fi + } + function ble/util/idle.do/.call-task { + local _ble_local_command=$1 + local ble_util_idle_status= + local ble_util_idle_elapsed=$((_ble_util_idle_sclock-_ble_idle_sclock_start)) + if [[ $bleopt_debug_idle && ( $_ble_edit_info_scene == default || $_ble_idle_info_shown ) ]]; then + _ble_idle_info_shown=1 + ble/edit/info/immediate-show text "${EPOCHREALTIME:+[$EPOCHREALTIME] }idle: $_ble_local_command" + fi + builtin eval -- "$_ble_local_command"; local ext=$? + if ((ext==148)); then + _ble_util_idle_task[_ble_idle_key]=R$_ble_util_idle_SEP$_ble_local_command + elif [[ $ble_util_idle_status ]]; then + _ble_util_idle_task[_ble_idle_key]=$ble_util_idle_status$_ble_util_idle_SEP$_ble_local_command + if [[ $ble_util_idle_status == [WS]* ]]; then + local scheduled_time=${ble_util_idle_status:1} + if [[ $ble_util_idle_status == W* ]]; then + local next=_ble_idle_next_itime + else + local next=_ble_idle_next_time + fi + if [[ ! ${!next} ]] || ((scheduled_time0)) + do + local ble_util_idle_elapsed=$((_ble_util_idle_sclock-_ble_idle_sclock_start)) + ((sleep_amount>50)) && ble/util/idle.do/.do-after-task + local interval=$((bleopt_idle_interval)) + if [[ ! $sleep_amount ]] || ((intervalret)) || return 1 + fi + ble_util_idle_status=S$1 + } + function ble/util/idle.isleep-until { + [[ ${ble_util_idle_status+set} ]] || return 2 + if [[ :$2: == *:checked:* ]]; then + (($1>_ble_util_idle_sclock)) || return 1 + fi + ble_util_idle_status=W$1 + } + function ble/util/idle.wait-user-input { + [[ ${ble_util_idle_status+set} ]] || return 2 + ble_util_idle_status=I + } + function ble/util/idle.wait-process { + [[ ${ble_util_idle_status+set} ]] || return 2 + ble_util_idle_status=P$1 + } + function ble/util/idle.wait-file-content { + [[ ${ble_util_idle_status+set} ]] || return 2 + ble_util_idle_status=F$1 + } + function ble/util/idle.wait-filename { + [[ ${ble_util_idle_status+set} ]] || return 2 + ble_util_idle_status=E$1 + } + function ble/util/idle.wait-condition { + [[ ${ble_util_idle_status+set} ]] || return 2 + ble_util_idle_status=C$1 + } + function ble/util/idle.continue { + [[ ${ble_util_idle_status+set} ]] || return 2 + ble_util_idle_status=R + } + function ble/util/idle/.delare-external-modifier { + local name=$1 + builtin eval -- 'function ble/util/idle#'$name' { + local index=$1 + [[ ${_ble_util_idle_task[index]+set} ]] || return 2 + local ble_util_idle_status=${_ble_util_idle_task[index]%%"$_ble_util_idle_SEP"*} + local ble_util_idle_command=${_ble_util_idle_task[index]#*"$_ble_util_idle_SEP"} + ble/util/idle.'$name' "${@:2}" + _ble_util_idle_task[index]=$ble_util_idle_status$_ble_util_idle_SEP$ble_util_idle_command + }' + } + ble/util/idle/.delare-external-modifier suspend + ble/util/idle/.delare-external-modifier sleep + ble/util/idle/.delare-external-modifier isleep + ble/util/idle.push-background 'ble/util/msleep/calibrate' +else + function ble/util/idle.do { false; } +fi +_ble_util_fiberchain=() +_ble_util_fiberchain_prefix= +function ble/util/fiberchain#initialize { + _ble_util_fiberchain=() + _ble_util_fiberchain_prefix=$1 +} +function ble/util/fiberchain#resume/.core { + _ble_util_fiberchain=() + local fib_clock=0 + local fib_ntask=$# + while (($#)); do + ((fib_ntask--)) + local fiber=${1%%:*} fib_suspend= fib_kill= + local argv; ble/string#split-words argv "$fiber" + [[ $1 == *:* ]] && fib_suspend=${1#*:} + "$_ble_util_fiberchain_prefix/$argv.fib" "${argv[@]:1}" + if [[ $fib_kill ]]; then + break + elif [[ $fib_suspend ]]; then + _ble_util_fiberchain=("$fiber:$fib_suspend" "${@:2}") + return 148 + fi + shift + done +} +function ble/util/fiberchain#resume { + ble/util/fiberchain#resume/.core "${_ble_util_fiberchain[@]}" +} +function ble/util/fiberchain#push { + ble/array#push _ble_util_fiberchain "$@" +} +function ble/util/fiberchain#clear { + _ble_util_fiberchain=() +} +bleopt/declare -v vbell_default_message ' Wuff, -- Wuff!! ' +bleopt/declare -v vbell_duration 2000 +bleopt/declare -n vbell_align right +function ble/term:cygwin/initialize.hook { + printf '\eM\e[B' >&"$_ble_util_fd_tui_stderr" + _ble_term_ri=$'\e[A' + function ble/canvas/put-dl.draw { + local value=${1-1} i + ((value)) || return 1 + DRAW_BUFF[${#DRAW_BUFF[*]}]=$'\e[2K' + if ((value>1)); then + local ret + ble/string#repeat $'\e[B\e[2K' "$((value-1))"; local a=$ret + DRAW_BUFF[${#DRAW_BUFF[*]}]=$ret$'\e['$((value-1))'A' + fi + DRAW_BUFF[${#DRAW_BUFF[*]}]=${_ble_term_dl//'%d'/$value} + } +} +function ble/term/DA2R.hook { + blehook term_DA2R-=ble/term/DA2R.hook + case $_ble_term_TERM in + (contra:*) + _ble_term_cuu=$'\e[%dk' + _ble_term_cud=$'\e[%de' + _ble_term_cuf=$'\e[%da' + _ble_term_cub=$'\e[%dj' + _ble_term_cup=$'\e[%l;%cf' ;; + (cygwin:*) + ble/term:cygwin/initialize.hook ;; + esac +} +function ble/term/.initialize { + if [[ -s $_ble_base_cache/term.$TERM && $_ble_base_cache/term.$TERM -nt $_ble_base/lib/init-term.sh ]]; then + source "$_ble_base_cache/term.$TERM" + else + source "$_ble_base/lib/init-term.sh" + fi + ble/string#reserve-prototype "$_ble_term_it" + blehook term_DA2R!=ble/term/DA2R.hook +} +ble/term/.initialize +function ble/term/put { + BUFF[${#BUFF[@]}]=$1 +} +function ble/term/cup { + local x=$1 y=$2 esc=$_ble_term_cup + esc=${esc//'%x'/$x} + esc=${esc//'%y'/$y} + esc=${esc//'%c'/$((x+1))} + esc=${esc//'%l'/$((y+1))} + BUFF[${#BUFF[@]}]=$esc +} +function ble/term/flush { + IFS= builtin eval 'ble/util/put "${BUFF[*]}"' + BUFF=() +} +function ble/term/audible-bell { + ble/util/put '' >&2 +} +_ble_term_visible_bell_prev=() +_ble_term_visible_bell_ftime=$_ble_base_run/$$.visible-bell.time +_ble_term_visible_bell_show='%message%' +_ble_term_visible_bell_clear= +function ble/term/visible-bell:term/init { + if [[ ! $_ble_term_visible_bell_clear ]]; then + local -a BUFF=() + ble/term/put "$_ble_term_ri_or_cuu1$_ble_term_sc$_ble_term_sgr0" + ble/term/cup 0 0 + ble/term/put "$_ble_term_el%message%$_ble_term_sgr0$_ble_term_rc${_ble_term_cud//'%d'/1}" + IFS= builtin eval '_ble_term_visible_bell_show="${BUFF[*]}"' + BUFF=() + ble/term/put "$_ble_term_sc$_ble_term_sgr0" + ble/term/cup 0 0 + ble/term/put "$_ble_term_el2$_ble_term_rc" + IFS= builtin eval '_ble_term_visible_bell_clear="${BUFF[*]}"' + fi + local cols=${COLUMNS:-80} + ((_ble_term_xenl||cols--)) + local message=${1::cols} + _ble_term_visible_bell_prev=(term "$message") +} +function ble/term/visible-bell:term/show { + local sgr=$1 message=${_ble_term_visible_bell_prev[1]} + message=${_ble_term_visible_bell_show//'%message%'/"$sgr$message"} + ble/util/put "$message" >&2 +} +function ble/term/visible-bell:term/update { + ble/term/visible-bell:term/show "$@" +} +function ble/term/visible-bell:term/clear { + local sgr=$1 + ble/util/put "$_ble_term_visible_bell_clear" >&2 +} +function ble/term/visible-bell:canvas/init { + local message=$1 + local lines=1 cols=${COLUMNS:-80} + ((_ble_term_xenl||cols--)) + local x= y= + local ret sgr0= sgr1= + ble/canvas/trace-text "$message" nonewline:external-sgr + message=$ret + local x0=$((COLUMNS-1-x)) y0=0 + ((x0<0)) && x0=0 + case :$bleopt_vbell_align: in + (*:left:*) x0=0 ;; + (*:center:*) ((x0/=2)) ;; + esac + _ble_term_visible_bell_prev=(canvas "$message" "$x0" "$y0" "$x" "$y") +} +function ble/term/visible-bell:canvas/show { + local sgr=$1 opts=$2 + local message=${_ble_term_visible_bell_prev[1]} + local x0=${_ble_term_visible_bell_prev[2]} + local y0=${_ble_term_visible_bell_prev[3]} + local x=${_ble_term_visible_bell_prev[4]} + local y=${_ble_term_visible_bell_prev[5]} + local -a DRAW_BUFF=() + [[ :$opts: != *:update:* && $_ble_attached ]] && # WA #D1495 + [[ $_ble_term_ri || :$opts: != *:erased:* && :$opts: != *:update:* ]] && + ble/canvas/panel/ensure-tmargin.draw + if [[ $_ble_term_rc ]]; then + local ret= + [[ :$opts: != *:update:* && $_ble_attached ]] && ble/canvas/panel/save-position goto-top-dock # WA #D1495 + ble/canvas/put.draw "$_ble_term_ri_or_cuu1$_ble_term_sc$_ble_term_sgr0" + ble/canvas/put-cup.draw "$((y0+1))" "$((x0+1))" + ble/canvas/put.draw "$sgr$message$_ble_term_sgr0" + ble/canvas/put.draw "$_ble_term_rc" + ble/canvas/put-cud.draw 1 + [[ :$opts: != *:update:* && $_ble_attached ]] && ble/canvas/panel/load-position.draw "$ret" # WA #D1495 + else + ble/canvas/put.draw "$_ble_term_ri_or_cuu1$_ble_term_sgr0" + ble/canvas/put-hpa.draw "$((1+x0))" + ble/canvas/put.draw "$sgr$message$_ble_term_sgr0" + ble/canvas/put-cud.draw 1 + ble/canvas/put-hpa.draw "$((1+_ble_canvas_x))" + fi + ble/canvas/bflush.draw + ble/util/buffer.flush +} +function ble/term/visible-bell:canvas/update { + ble/term/visible-bell:canvas/show "$@" +} +function ble/term/visible-bell:canvas/clear { + local sgr=$1 + local x0=${_ble_term_visible_bell_prev[2]} + local y0=${_ble_term_visible_bell_prev[3]} + local x=${_ble_term_visible_bell_prev[4]} + local y=${_ble_term_visible_bell_prev[5]} + local -a DRAW_BUFF=() + if [[ $_ble_term_rc ]]; then + local ret= + ble/canvas/put.draw "$_ble_term_sc$_ble_term_sgr0" + ble/canvas/put-cup.draw "$((y0+1))" "$((x0+1))" + ble/canvas/put.draw "$sgr" + ble/canvas/put-spaces.draw "$x" + ble/canvas/put.draw "$_ble_term_sgr0$_ble_term_rc" + else + : # 親プロセスの _ble_canvas_x が分からないので座標がずれる + fi + ble/canvas/flush.draw >&2 +} +function ble/term/visible-bell/defface.hook { + ble/color/defface vbell reverse + ble/color/defface vbell_flash reverse,fg=green + ble/color/defface vbell_erase bg=252 +} +blehook color_defface_load+=ble/term/visible-bell/defface.hook +function ble/term/visible-bell/.show { + local bell_type=${_ble_term_visible_bell_prev[0]} + ble/term/visible-bell:"$bell_type"/show "$@" +} +function ble/term/visible-bell/.update { + local bell_type=${_ble_term_visible_bell_prev[0]} + ble/term/visible-bell:"$bell_type"/update "$1" "$2:update" +} +function ble/term/visible-bell/.clear { + local bell_type=${_ble_term_visible_bell_prev[0]} + ble/term/visible-bell:"$bell_type"/clear "$@" + >| "$_ble_term_visible_bell_ftime" +} +function ble/term/visible-bell/.erase-previous-visible-bell { + local ret workers + ble/util/eval-pathname-expansion '"$_ble_base_run/$$.visible-bell."*' canonical + workers=("${ret[@]}") + local workerfile + for workerfile in "${workers[@]}"; do + if [[ -s $workerfile && ! ( $workerfile -ot $_ble_term_visible_bell_ftime ) ]]; then + ble/term/visible-bell/.clear "$sgr0" + return 0 + fi + done + return 1 +} +function ble/term/visible-bell/.create-workerfile { + local i=0 + while + workerfile=$_ble_base_run/$$.visible-bell.$i + [[ -s $workerfile ]] + do ((i++)); done + ble/util/print 1 >| "$workerfile" +} +function ble/term/visible-bell/.worker { + ble/util/msleep 50 + [[ $workerfile -ot $_ble_term_visible_bell_ftime ]] && return 0 >| "$workerfile" + ble/term/visible-bell/.update "$sgr2" + if [[ :$opts: == *:persistent:* ]]; then + local dead_workerfile=$_ble_base_run/$$.visible-bell.Z + ble/util/print 1 >| "$dead_workerfile" + return 0 >| "$workerfile" + fi + local msec=$((bleopt_vbell_duration)) + ble/util/msleep "$msec" + [[ $workerfile -ot $_ble_term_visible_bell_ftime ]] && return 0 >| "$workerfile" + ble/term/visible-bell/.clear "$sgr0" + >| "$workerfile" +} +function ble/term/visible-bell { + local message=$1 opts=$2 + message=${message:-$bleopt_vbell_default_message} + ((LINES==1)) && return 0 + [[ :$bleopt_vbell_align: == *:panel:* ]] && + ble/function#try ble/edit/visible-bell "$message" "$opts" && + return 0 + local sgr0=$_ble_term_sgr0 + local sgr1=${_ble_term_setaf[2]}$_ble_term_rev + local sgr2=$_ble_term_rev + if ble/is-function ble/color/face2sgr; then + local ret + ble/color/face2sgr vbell_flash; sgr1=$ret + ble/color/face2sgr vbell; sgr2=$ret + ble/color/face2sgr vbell_erase; sgr0=$ret + fi + local show_opts= + ble/term/visible-bell/.erase-previous-visible-bell && show_opts=erased + if ble/is-function ble/canvas/trace-text; then + ble/term/visible-bell:canvas/init "$message" + else + ble/term/visible-bell:term/init "$message" + fi + ble/term/visible-bell/.show "$sgr1" "$show_opts" + local workerfile; ble/term/visible-bell/.create-workerfile + ( ble/util/joblist/__suppress__; ble/term/visible-bell/.worker 1>/dev/null & ) +} +function ble/term/visible-bell/cancel-erasure { + >| "$_ble_term_visible_bell_ftime" +} +function ble/term/visible-bell/erase { + local sgr0=$_ble_term_sgr0 + if ble/is-function ble/color/face2sgr; then + local ret + ble/color/face2sgr vbell_erase; sgr0=$ret + fi + ble/term/visible-bell/.erase-previous-visible-bell +} +[[ ${_ble_term_stty_save+set} ]] || _ble_term_stty_save= +bleopt/declare -v term_stty_restore '' +function bleopt/check:term_stty_restore { + if [[ $value && ! $_ble_term_stty_save ]]; then + ble/util/assign _ble_term_stty_save 'ble/bin/stty -g' + fi + return 0 +} +_ble_term_stty_state= +_ble_term_stty_flags_enter=() +_ble_term_stty_flags_leave=() +ble/array#push _ble_term_stty_flags_enter intr undef quit undef susp undef +ble/array#push _ble_term_stty_flags_leave intr '' quit '' susp '' +function ble/term/stty/.initialize-flags { + if [[ $TERM == minix ]]; then + local stty; ble/util/assign stty 'stty -a' + if [[ $stty == *' rprnt '* ]]; then + ble/array#push _ble_term_stty_flags_enter rprnt undef + ble/array#push _ble_term_stty_flags_leave rprnt '' + elif [[ $stty == *' reprint '* ]]; then + ble/array#push _ble_term_stty_flags_enter reprint undef + ble/array#push _ble_term_stty_flags_leave reprint '' + fi + fi +} +ble/term/stty/.initialize-flags +function ble/term/stty/initialize { + if [[ $bleopt_term_stty_restore ]]; then + [[ $_ble_term_stty_save ]] || + ble/util/assign _ble_term_stty_save 'ble/bin/stty -g' + fi + ble/bin/stty -ixon -echo -nl -icrnl -icanon \ + "${_ble_term_stty_flags_enter[@]}" + _ble_term_stty_state=1 +} +function ble/term/stty/leave { + [[ ! $_ble_term_stty_state ]] && return 0 + _ble_term_stty_state= + if [[ $bleopt_term_stty_restore && $_ble_term_stty_save ]]; then + ble/bin/stty "$_ble_term_stty_save" + else + ble/bin/stty echo -nl icanon "${_ble_term_stty_flags_leave[@]}" + fi +} +function ble/term/stty/enter { + [[ $_ble_term_stty_state ]] && return 0 + if [[ $bleopt_term_stty_restore ]]; then + ble/term/stty/initialize + else + ble/bin/stty -echo -nl -icrnl -icanon "${_ble_term_stty_flags_enter[@]}" + _ble_term_stty_state=1 + fi +} +function ble/term/stty/finalize { + ble/term/stty/leave + _ble_term_stty_save= +} +function ble/term/stty/TRAPEXIT { + if [[ $bleopt_term_stty_restore && $_ble_term_stty_save ]]; then + ble/bin/stty "$_ble_term_stty_save" + else + ble/bin/stty echo -nl "${_ble_term_stty_flags_leave[@]}" + fi +} +function ble/term/update-winsize { + if ((_ble_bash<50200||50300<=_ble_bash)); then + function ble/term/update-winsize { + if shopt -q checkwinsize; then + (:) + else + shopt -s checkwinsize + (:) + shopt -u checkwinsize + fi 2>&"$_ble_util_fd_tui_stderr" + } + ble/term/update-winsize + return 0 + fi + local ret + if ble/bin#freeze-utility-path tput; then + if ble/util/assign-words ret 'ble/bin/tput lines cols' 2>/dev/null && + [[ ${#ret[@]} -eq 2 && ${ret[0]} =~ ^[0-9]+$ && ${ret[1]} =~ ^[0-9]+$ ]] + then + LINES=${ret[0]} COLUMNS=${ret[1]} + function ble/term/update-winsize { + local -x ret LINES= COLUMNS= + ble/util/assign-words ret 'ble/bin/tput lines cols' 2>/dev/null + ble/util/unlocal LINES COLUMNS + [[ ${ret[0]} ]] && LINES=${ret[0]} + [[ ${ret[1]} ]] && COLUMNS=${ret[1]} + } + return 0 + elif ble/util/assign-words ret 'ble/bin/tput li co' 2>/dev/null && + [[ ${#ret[@]} -eq 2 && ${ret[0]} =~ ^[0-9]+$ && ${ret[1]} =~ ^[0-9]+$ ]] + then + LINES=${ret[0]} COLUMNS=${ret[1]} + function ble/term/update-winsize { + local -x ret LINES= COLUMNS= + ble/util/assign-words ret 'ble/bin/tput li co' 2>/dev/null + ble/util/unlocal LINES COLUMNS + [[ ${ret[0]} ]] && LINES=${ret[0]} + [[ ${ret[1]} ]] && COLUMNS=${ret[1]} + } + return 0 + fi + fi + if ble/util/assign-words ret 'ble/bin/stty size' 2>/dev/null && + [[ ${#ret[@]} -eq 2 && ${ret[0]} =~ ^[0-9]+$ && ${ret[1]} =~ ^[0-9]+$ ]] + then + LINES=${ret[0]} COLUMNS=${ret[1]} + function ble/term/update-winsize { + local ret + ble/util/assign-words ret 'ble/bin/stty size' 2>/dev/null + [[ ${ret[0]} ]] && LINES=${ret[0]} + [[ ${ret[1]} ]] && COLUMNS=${ret[1]} + } + return 0 + fi + if ble/bin#freeze-utility-path resize && + ble/util/assign ret 'ble/bin/resize' && + ble/string#match "$ret" 'COLUMNS=([0-9]+).*LINES=([0-9]+)' + then + LINES=${BASH_REMATCH[2]} COLUMNS=${BASH_REMATCH[1]} + function ble/term/update-winsize { + local ret + ble/util/assign ret 'ble/bin/resize' 2>/dev/null + ble/string#match ret 'COLUMNS=([0-9]+).*LINES=([0-9]+)' + [[ ${BASH_REMATCH[2]} ]] && LINES=${BASH_REMATCH[2]} + [[ ${BASH_REMATCH[1]} ]] && COLUMNS=${BASH_REMATCH[1]} + } + return 0 + fi + function ble/term/update-winsize { + local ret script='LINES= COLUMNS=; (:); [[ $COLUMNS && $LINES ]] && builtin echo "$LINES $COLUMNS"' + ble/util/assign-words ret '"$BASH" -O checkwinsize -c "$script"' 2>&"$_ble_util_fd_tui_stderr" + [[ ${ret[0]} ]] && LINES=${ret[0]} + [[ ${ret[1]} ]] && COLUMNS=${ret[1]} + } + ble/term/update-winsize + return 0 +} +if ((50200<=_ble_bash&&_ble_bash<50300)); then + function ble/term/update-winsize/.stty-enter.advice { + local ret stderr test_command='ble/bin/stty -echo -nl -icrnl -icanon "${_ble_term_stty_flags_enter[@]}" size' + if ble/util/assign stderr 'ble/util/assign-words ret "$test_command" 2>&1' && + [[ ! $stderr ]] && + ((${#ret[@]}==2)) && + [[ ${ret[0]} =~ ^[0-9]+$ && ${ret[1]} =~ ^[0-9]+$ ]] + then + LINES=${ret[0]} COLUMNS=${ret[1]} + function ble/term/stty/enter { + [[ $_ble_term_stty_state ]] && return 0 + local ret + if [[ $bleopt_term_stty_restore ]]; then + ble/term/stty/initialize + ble/util/assign-words ret 'ble/bin/stty size' + else + ble/util/assign-words ret 'ble/bin/stty -echo -nl -icrnl -icanon "${_ble_term_stty_flags_enter[@]}" size' + _ble_term_stty_state=1 + fi + [[ ${ret[0]} =~ ^[0-9]+$ ]] && LINES=${ret[0]} + [[ ${ret[1]} =~ ^[0-9]+$ ]] && COLUMNS=${ret[1]} + } + else + ble/term/update-winsize + ble/function#advice before ble/term/stty/enter ble/term/update-winsize + fi + builtin unset -f "$FUNCNAME" + } + ble/function#advice before ble/term/stty/enter ble/term/update-winsize/.stty-enter.advice +fi +bleopt/declare -v term_cursor_external 0 +_ble_term_cursor_current=unknown +_ble_term_cursor_internal=0 +_ble_term_cursor_hidden_current=unknown +_ble_term_cursor_hidden_internal=reveal +_ble_term_cursor_current=default +function ble/term/cursor-state/.update { + local state=$(($1)) + [[ ${_ble_term_cursor_current/default/0} == "$state" ]] && return 0 + if [[ ! $_ble_term_Ss ]]; then + case $_ble_term_TERM in + (mintty:*|xterm:*|RLogin:*|kitty:*|screen:*|tmux:*|contra:*|cygwin:*|wezterm:*|wt:*) + local _ble_term_Ss=$'\e[@1 q' ;; + esac + fi + local ret=${_ble_term_Ss//@1/"$state"} + if [[ $ret ]]; then + [[ $ret != $'\eP'*$'\e\\' ]] && + ble/term/quote-passthrough "$ret" '' all + ble/util/buffer "$ret" + fi + _ble_term_cursor_current=$state +} +function ble/term/cursor-state/set-internal { + _ble_term_cursor_internal=$1 + [[ $_ble_term_state == internal ]] && + ble/term/cursor-state/.update "$1" +} +function ble/term/cursor-state/.update-hidden { + local state=$1 + [[ $state != hidden ]] && state=reveal + _ble_term_cursor_hidden_current=$state +} +function ble/term/cursor-state/hide { + _ble_term_cursor_hidden_internal=hidden + [[ $_ble_term_state == internal ]] && + ble/term/cursor-state/.update-hidden hidden +} +function ble/term/cursor-state/reveal { + _ble_term_cursor_hidden_internal=reveal + [[ $_ble_term_state == internal ]] && + ble/term/cursor-state/.update-hidden reveal +} +function ble/term/bracketed-paste-mode/.init { + local _ble_local_rlvars; ble/util/rlvar#load + bleopt/declare -v term_bracketed_paste_mode on + if ((_ble_bash>=50100)) && ! ble/util/rlvar#test enable-bracketed-paste; then + bleopt term_bracketed_paste_mode= + elif [[ ${TERM%%-*} == eterm ]]; then + bleopt term_bracketed_paste_mode= + fi + function bleopt/check:term_bracketed_paste_mode { + if [[ $_ble_term_bracketedPasteMode_internal ]]; then + if [[ $value ]]; then + [[ $bleopt_term_bracketed_paste_mode ]] || ble/util/buffer $'\e[?2004h' + else + [[ ! $bleopt_term_bracketed_paste_mode ]] || ble/util/buffer $'\e[?2004l' + fi + fi + } + ble/util/rlvar#bind-bleopt enable-bracketed-paste term_bracketed_paste_mode bool + builtin unset -f "$FUNCNAME" +} +ble/term/bracketed-paste-mode/.init +_ble_term_bracketedPasteMode_internal= +function ble/term/bracketed-paste-mode/enter { + _ble_term_bracketedPasteMode_internal=1 + [[ ${bleopt_term_bracketed_paste_mode-} ]] && + ble/util/buffer $'\e[?2004h' +} +function ble/term/bracketed-paste-mode/leave { + _ble_term_bracketedPasteMode_internal= + [[ ${bleopt_term_bracketed_paste_mode-} ]] && + ble/util/buffer $'\e[?2004l' +} +if [[ $TERM == minix ]]; then + function ble/term/bracketed-paste-mode/enter { return 0; } + function ble/term/bracketed-paste-mode/leave { return 0; } +fi +bleopt/declare -v term_synchronized_update_mode auto +function ble/term/synchronized-update-mode/resolve-auto { + [[ $bleopt_term_synchronized_update_mode == auto ]] || return 0 + case $_ble_term_TERM in + (mintty:*|foot:*|wezterm:*|iTerm2:*|kitty:*|alacritty:*|zellij:*) + bleopt_term_synchronized_update_mode=on ;; + (*) + bleopt_term_synchronized_update_mode= ;; + esac +} +_ble_term_TERM=() +_ble_term_DA1R=() +_ble_term_DA2R=() +_ble_term_TERM_done= +function ble/term/DA2/request { + case $TERM in + (linux) + _ble_term_TERM=linux:- ;; + (st|st-*) + _ble_term_TERM=st:- ;; + (*) + ble/util/buffer $'\e[>c' # DA2 要求 (ble-decode-char/csi/.decode で受信) + esac +} +function ble/term/DA2/initialize-term { + local depth=$1 + local da2r=${_ble_term_DA2R[depth]} + local rex='^[0-9]*(;[0-9]*)*$'; [[ $da2r =~ $rex ]] || return 1 + local da2r_vec + ble/string#split da2r_vec ';' "$da2r" + da2r_vec=("${da2r_vec[@]/#/10#0}") # 0で始まっていても10進数で解釈; WA #D1570 checked (is-array) + case $da2r in + ('0;271;0') _ble_term_TERM[depth]=terminology:200 ;; # 2012-10-05 https://github.com/borisfaure/terminology/commit/500e7be8b2b876462ed567ef6c90527f37482adb + ('41;285;0') _ble_term_TERM[depth]=terminology:300 ;; # 2013-01-22 https://github.com/borisfaure/terminology/commit/526cc2aeacc0ae54825cbc3a3e2ab64f612f83c9 + ('61;337;0') _ble_term_TERM[depth]=terminology:10400 ;; # 2019-01-20 https://github.com/borisfaure/terminology/commit/96bbfd054b271f7ad7f31e699b13c12cb8fbb2e2 + ('0;0;0') _ble_term_TERM[depth]=wezterm:0 ;; + ('1;277;0') _ble_term_TERM[depth]=wezterm:20220408 ;; # 2022-04-07 https://github.com/wez/wezterm/commit/ad91e3776808507cbef9e6d758b89d7ca92a4c7e + ('0;115;0') _ble_term_TERM[depth]=konsole:30000 ;; # 2001-09-16 https://github.com/KDE/konsole/commit/2d93fed82aa27e89c9d7301d09d2e24e4fa4416d + ('1;115;0') _ble_term_TERM[depth]=konsole:220380 ;; # 2022-02-24 https://github.com/KDE/konsole/commit/0cc64dcf7b90075bd17e46653df3069208d6a590 + ('1;96;0') _ble_term_TERM[depth]=mlterm:30102 ;; + ('1;277;0') _ble_term_TERM[depth]=mlterm:30402 ;; # Note: wezterm:20220408 と同じ。wezterm の方を優先 + ('24;279;0') _ble_term_TERM[depth]=mlterm:30702 ;; + ('0;95;0') _ble_term_TERM[depth]=iTerm2:${LC_TERMINAL_VERSION-2.9+} ;; + ('41;2500;0') _ble_term_TERM[depth]=iTerm2:${LC_TERMINAL_VERSION-3.5+} ;; + ('0;10;1') # Windows Terminal + _ble_term_TERM[depth]=wt:0 ;; + ('0;'*';1') + if ((da2r_vec[1]>=3000)); then + _ble_term_TERM[depth]=zellij:$((da2r_vec[1])) + elif ((da2r_vec[1]>=1001)); then + _ble_term_TERM[depth]=alacritty:$((da2r_vec[1])) + fi ;; + ('1;0'?????';0') + _ble_term_TERM[depth]=foot:${da2r:3:5} ;; + ('1;'*) + if ((4000<=da2r_vec[1]&&da2r_vec[1]<=4009&&3<=da2r_vec[2])); then + _ble_term_TERM[depth]=kitty:$((da2r_vec[1]-4000)) + elif ((2000<=da2r_vec[1]&&da2r_vec[1]<5400&&da2r_vec[2]==0)); then + local version=$((da2r_vec[1])) + _ble_term_TERM[depth]=vte:$version + if ((version<4000)); then + _ble_term_Ss= + fi + fi ;; + ('65;'*) + if ((5300<=da2r_vec[1]&&da2r_vec[2]==1)); then + _ble_term_TERM[depth]=vte:$((da2r_vec[1])) + elif ((da2r_vec[1]>=100)); then + _ble_term_TERM[depth]=RLogin:$((da2r_vec[1])) + fi ;; + ('67;'*) + local rex='^67;[0-9]{3,};0$' + if [[ $TERM == cygwin && $da2r =~ $rex ]]; then + _ble_term_TERM[depth]=cygwin:$((da2r_vec[1])) + fi ;; + ('77;'*';0') + _ble_term_TERM[depth]=mintty:$((da2r_vec[1])) ;; + ('83;'*) + local rex='^83;[0-9]+;0$' + [[ $da2r =~ $rex ]] && _ble_term_TERM[depth]=screen:$((da2r_vec[1])) ;; + ('84;0;0') + _ble_term_TERM[depth]=tmux:0 ;; + ('99;'*) + _ble_term_TERM[depth]=contra:$((da2r_vec[1])) ;; + esac + [[ ${_ble_term_TERM[depth]} ]] && return 0 + if rex='^xterm(-|$)'; [[ $TERM =~ $rex ]]; then + local version=$((da2r_vec[1])) + if rex='^1;[0-9]+;0$'; [[ $da2r =~ $rex ]]; then + true + elif rex='^0;[0-9]+;0$'; [[ $da2r =~ $rex ]]; then + ((95<=version)) + elif rex='^(2|24|1[89]|41|6[145]);[0-9]+;0$'; [[ $da2r =~ $rex ]]; then + ((280<=version)) + elif rex='^32;[0-9]+;0$'; [[ $da2r =~ $rex ]]; then + ((354<=version&&version<2000)) + else + false + fi && { _ble_term_TERM[depth]=xterm:$version; return 0; } + fi + _ble_term_TERM[depth]=unknown:- + return 0 +} +function ble/term/DA1/notify { _ble_term_DA1R=$1; blehook/invoke term_DA1R; } +function ble/term/DA2/notify { + local depth=${#_ble_term_DA2R[@]} + if ((depth==0)) || ble/string#match "${_ble_term_TERM[depth-1]}" '^(screen|tmux):'; then + _ble_term_DA2R[depth]=$1 + ble/term/DA2/initialize-term "$depth" + local is_outermost=1 + case ${_ble_term_TERM[depth]} in + (screen:*|tmux:*) + local ret is_outermost= + ble/term/quote-passthrough $'\e[>c' "$((depth+1))" + ble/util/buffer "$ret" ;; + (contra:*) + if [[ ! ${_ble_term_Ss-} ]]; then + _ble_term_Ss=$'\e[@1 q' + fi ;; + (terminology:*) + _ble_term_sc=$'\e7' _ble_term_rc=$'\r\e8' ;; + esac + if ((depth==0)); then + ble/term/synchronized-update-mode/resolve-auto + fi + if [[ $is_outermost ]]; then + _ble_term_TERM_done=1 + ble/term/modifyOtherKeys/reset + fi + ((depth)) && return 0 + fi + blehook/invoke term_DA2R +} +function ble/term/quote-passthrough { + local seq=$1 level=${2:-$((${#_ble_term_DA2R[@]}-1))} opts=$3 + local all=; [[ :$opts: == *:all:* ]] && all=1 + ret=$seq + [[ $seq ]] || return 0 + local i + for ((i=level;--i>=0;)); do + if [[ ${_ble_term_TERM[i]} == tmux:* ]]; then + ret=$'\ePtmux;'${ret//$'\e'/$'\e\e'}$'\e\\'${all:+$seq} + else + ret=$'\eP'${ret//$'\e\\'/$'\e\e\\\eP\\'}$'\e\\'${all:+$seq} + fi + done +} +_ble_term_DECSTBM= +_ble_term_DECSTBM_reset= +function ble/term/test-DECSTBM.hook1 { + (($1==2)) && _ble_term_DECSTBM=$'\e[%s;%sr' +} +function ble/term/test-DECSTBM.hook2 { + if [[ $_ble_term_DECSTBM ]]; then + if (($1==2)); then + _ble_term_DECSTBM_reset=$'\e[r' + else + _ble_term_DECSTBM_reset=$'\e[;r' + fi + fi +} +function ble/term/test-DECSTBM { + local -a DRAW_BUFF=() + ble/canvas/panel/goto-top-dock.draw + ble/canvas/put.draw "$_ble_term_sc"$'\e[1;2r' + ble/canvas/put-cup.draw 2 1 + ble/canvas/put-cud.draw 1 + ble/term/CPR/request.draw ble/term/test-DECSTBM.hook1 + ble/canvas/put.draw $'\e[;r' + ble/canvas/put-cup.draw 2 1 + ble/canvas/put-cud.draw 1 + ble/term/CPR/request.draw ble/term/test-DECSTBM.hook2 + ble/canvas/put.draw $'\e[r'"$_ble_term_rc" + ble/canvas/bflush.draw +} +_ble_term_CPR_timeout=60 +_ble_term_CPR_last_seconds=$SECONDS +_ble_term_CPR_hook=() +function ble/term/CPR/request.buff { + ((SECONDS>_ble_term_CPR_last_seconds+_ble_term_CPR_timeout)) && + _ble_term_CPR_hook=() + _ble_term_CPR_last_seconds=$SECONDS + ble/array#push _ble_term_CPR_hook "$1" + ble/util/buffer $'\e[6n' + return 147 +} +function ble/term/CPR/request.draw { + ((SECONDS>_ble_term_CPR_last_seconds+_ble_term_CPR_timeout)) && + _ble_term_CPR_hook=() + _ble_term_CPR_last_seconds=$SECONDS + ble/array#push _ble_term_CPR_hook "$1" + ble/canvas/put.draw $'\e[6n' + return 147 +} +function ble/term/CPR/notify { + local hook=${_ble_term_CPR_hook[0]} + ble/array#shift _ble_term_CPR_hook + [[ ! $hook ]] || builtin eval -- "$hook $1 $2" +} +bleopt/declare -v term_modifyOtherKeys_external auto +bleopt/declare -v term_modifyOtherKeys_internal auto +bleopt/declare -v term_modifyOtherKeys_passthrough_kitty_protocol '' +_ble_term_modifyOtherKeys_current= +_ble_term_modifyOtherKeys_current_method= +_ble_term_modifyOtherKeys_current_TERM= +function ble/term/modifyOtherKeys/.update { + local IFS=$_ble_term_IFS state=${1%%:*} + [[ $1 == "$_ble_term_modifyOtherKeys_current" ]] && + [[ $state != 2 || "${_ble_term_TERM[*]}" == "$_ble_term_modifyOtherKeys_current_TERM" ]] && + return 0 + local previous=${_ble_term_modifyOtherKeys_current%%:*} method + if [[ $state == 2 ]]; then + case $_ble_term_TERM in + (RLogin:*) method=RLogin_modifyStringKeys ;; + (kitty:*) + local da2r_vec + ble/string#split da2r_vec ';' "$_ble_term_DA2R" + if ((da2r_vec[2]>=23)); then + method=kitty_keyboard_protocol + else + method=kitty_modifyOtherKeys + fi ;; + (screen:*|tmux:*) + method=modifyOtherKeys + if [[ $bleopt_term_modifyOtherKeys_passthrough_kitty_protocol ]]; then + local index=$((${#_ble_term_TERM[*]}-1)) + if [[ ${_ble_term_TERM[index]} == kitty:* ]]; then + local da2r_vec + ble/string#split da2r_vec ';' "${_ble_term_DA2R[index]}" + ((da2r_vec[2]>=23)) && method=kitty_keyboard_protocol + fi + fi ;; + (*) + method=modifyOtherKeys + if [[ $1 == *:auto ]]; then + ble/term/modifyOtherKeys/.supported || method=disabled + fi ;; + esac + [[ $MC_SID ]] && method=disabled + if ((previous>=2)) && + [[ $method != "$_ble_term_modifyOtherKeys_current_method" ]] + then + ble/term/modifyOtherKeys/.update 1 + previous=1 + fi + else + method=$_ble_term_modifyOtherKeys_current_method + fi + _ble_term_modifyOtherKeys_current=$1 + _ble_term_modifyOtherKeys_current_method=$method + _ble_term_modifyOtherKeys_current_TERM="${_ble_term_TERM[*]}" + case $method in + (RLogin_modifyStringKeys) + case $state in + (0) ble/util/buffer $'\e[>5;0m' ;; + (1) ble/util/buffer $'\e[>5;1m' ;; + (2) ble/util/buffer $'\e[>5;1m\e[>5;2m' ;; + esac + ;; # fallback to modifyOtherKeys + (kitty_modifyOtherKeys) + case $state in + (0|1) ble/util/buffer $'\e[>4;0m\e[>4m' ;; + (2) ble/util/buffer $'\e[>4;1m\e[>4;2m\e[m' ;; + esac + return 0 ;; + (kitty_keyboard_protocol) + local seq= + case $state in + (0|1) # pop keyboard mode + [[ $previous ]] || return 0 + ((previous>=2)) && seq=$'\e[=2)) || seq=$'\e[>1u' ;; + esac + if [[ $seq ]]; then + local ret + ble/term/quote-passthrough "$seq" + ble/util/buffer "$ret" + local level + for ((level=1;level<${#_ble_term_TERM[@]}-1;level++)); do + [[ ${_ble_term_TERM[level]} == tmux:* ]] || continue + case $state in + (0) seq=$'\e[>4;0m\e[m' ;; + (1) seq=$'\e[>4;1m\e[m' ;; + (2) seq=$'\e[>4;1m\e[>4;2m\e[m' ;; + esac + ble/term/quote-passthrough "$seq" "$level" + ble/util/buffer "$ret" + break + done + fi + return 0 ;; + (disabled) + return 0 ;; + esac + case $state in + (0) ble/util/buffer $'\e[>4;0m\e[m' ;; + (1) ble/util/buffer $'\e[>4;1m\e[m' ;; + (2) ble/util/buffer $'\e[>4;1m\e[>4;2m\e[m' ;; + esac +} +function ble/term/modifyOtherKeys/.supported { + [[ $_ble_term_TERM_done ]] || return 1 + [[ $_ble_term_TERM == vte:* ]] && return 1 + [[ $MWG_LOGINTERM == rosaterm ]] && return 1 + case $TERM in + (linux) + return 1 ;; + (minix|sun*) + return 1 ;; + (st|st-*) + return 1 ;; + esac + return 0 +} +function ble/term/modifyOtherKeys/enter { + local value=$bleopt_term_modifyOtherKeys_internal + if [[ $value == auto ]]; then + value=2:auto + fi + ble/term/modifyOtherKeys/.update "$value" +} +function ble/term/modifyOtherKeys/leave { + local value=$bleopt_term_modifyOtherKeys_external + if [[ $value == auto ]]; then + value=1:auto + fi + ble/term/modifyOtherKeys/.update "$value" +} +function ble/term/modifyOtherKeys/reset { + ble/term/modifyOtherKeys/.update "$_ble_term_modifyOtherKeys_current" +} +_ble_term_altscr_state= +function ble/term/enter-altscr { + [[ $_ble_term_altscr_state ]] && return 0 + _ble_term_altscr_state=("$_ble_canvas_x" "$_ble_canvas_y") + if [[ $_ble_term_rmcup ]]; then + ble/util/buffer "$_ble_term_smcup" + else + local -a DRAW_BUFF=() + ble/canvas/put.draw $'\e[?1049h' + ble/canvas/put-cup.draw "$LINES" 0 + ble/canvas/put-ind.draw "$LINES" + ble/canvas/bflush.draw + fi +} +function ble/term/leave-altscr { + [[ $_ble_term_altscr_state ]] || return 0 + if [[ $_ble_term_rmcup ]]; then + ble/util/buffer "$_ble_term_rmcup" + else + local -a DRAW_BUFF=() + ble/canvas/put-cup.draw "$LINES" 0 + ble/canvas/put-ind.draw + ble/canvas/put.draw $'\e[?1049l' + ble/canvas/bflush.draw + fi + _ble_canvas_x=${_ble_term_altscr_state[0]} + _ble_canvas_y=${_ble_term_altscr_state[1]} + _ble_term_altscr_state=() +} +_ble_term_rl_convert_meta_adjusted= +_ble_term_rl_convert_meta_external= +function ble/term/rl-convert-meta/enter { + [[ $_ble_term_rl_convert_meta_adjusted ]] && return 0 + _ble_term_rl_convert_meta_adjusted=1 + if ble/util/rlvar#test convert-meta; then + _ble_term_rl_convert_meta_external=on + builtin bind 'set convert-meta off' + else + _ble_term_rl_convert_meta_external=off + fi +} +function ble/term/rl-convert-meta/leave { + [[ $_ble_term_rl_convert_meta_adjusted ]] || return 1 + _ble_term_rl_convert_meta_adjusted= + [[ $_ble_term_rl_convert_meta_external == on ]] && + builtin bind 'set convert-meta on' +} +_ble_term_attached= +_ble_term_state=external +function ble/term/enter-for-widget { + ble/term/bracketed-paste-mode/enter + ble/term/modifyOtherKeys/enter + ble/term/cursor-state/.update "$_ble_term_cursor_internal" + ble/term/cursor-state/.update-hidden "$_ble_term_cursor_hidden_internal" + [[ :$1: == *:noflush:* ]] || ble/util/buffer.flush +} +function ble/term/leave-for-widget { + ble/term/visible-bell/erase + ble/term/bracketed-paste-mode/leave + ble/term/modifyOtherKeys/leave + ble/term/cursor-state/.update "$bleopt_term_cursor_external" + ble/term/cursor-state/.update-hidden reveal + ble/util/buffer.flush +} +function ble/term/enter { + [[ $_ble_term_state == internal ]] && return 0 + _ble_term_state=internal + ble/term/stty/enter + ble/term/rl-convert-meta/enter + ble/term/enter-for-widget "$1" +} +function ble/term/leave { + [[ $_ble_term_state == external ]] && return 0 + ble/term/stty/leave + ble/term/rl-convert-meta/leave + ble/term/leave-for-widget + [[ $_ble_term_cursor_current == default ]] || + _ble_term_cursor_current=unknown # vim は復元してくれない + _ble_term_cursor_hidden_current=unknown + _ble_term_state=external +} +function ble/term/initialize { + ble/term/DA2/request + ble/term/test-DECSTBM +} +function ble/term/attach { + [[ $_ble_term_attached ]] && return 0 + _ble_term_attached=1 + ble/term/stty/initialize + ble/term/enter "$1" +} +function ble/term/detach { + [[ $_ble_term_attached ]] || return 0 + _ble_term_attached= + ble/term/stty/finalize + ble/term/leave + ble/util/buffer.flush +} +_ble_util_s2c_table_enabled= +if ((_ble_bash>=50300)); then + function ble/util/s2c { + builtin printf -v ret %d "'$1" + } +elif ((_ble_bash>=40100)); then + function ble/util/s2c { + if ble/util/is-unicode-output; then + builtin printf -v ret %d "'μ" + else + builtin printf -v ret %d "'x" + fi + builtin printf -v ret %d "'$1" + } +elif ((_ble_bash>=40000&&!_ble_bash_loaded_in_function)); then + declare -A _ble_util_s2c_table + _ble_util_s2c_table_enabled=1 + function ble/util/s2c { + [[ $_ble_util_locale_triple != "$LC_ALL:$LC_CTYPE:$LANG" ]] && + ble/util/.cache/update-locale + local s=${1::1} + ret=${_ble_util_s2c_table[x$s]} + [[ $ret ]] && return 0 + ble/util/sprintf ret %d "'$s" + _ble_util_s2c_table[x$s]=$ret + } +elif ((_ble_bash>=40000)); then + function ble/util/s2c { + ble/util/sprintf ret %d "'${1::1}" + } +else + function ble/util/s2c { + local s=${1::1} + if [[ $s == [$'\x01'-$'\x7F'] ]]; then + if [[ $s == $'\x7F' ]]; then + ret=127 + else + ble/util/sprintf ret %d "'$s" + fi + return 0 + fi + local bytes byte + ble/util/assign bytes ' + local IFS= + while ble/bash/read -n 1 byte; do + builtin printf "%d " "'\''$byte" + done <<< "$s" + IFS=$_ble_term_IFS + ' + "ble/encoding:$bleopt_input_encoding/b2c" $bytes + } +fi +if ((_ble_bash>=40200)); then + function ble/util/.has-bashbug-printf-uffff { + ((40200<=_ble_bash&&_ble_bash<50000)) || return 1 + local LC_ALL=C.UTF-8 2>/dev/null + local ret + builtin printf -v ret '\uFFFF' + ((${#ret}==2)) + } + ble/function#suppress-stderr ble/util/.has-bashbug-printf-uffff + if ble/util/.has-bashbug-printf-uffff; then + function ble/util/c2s.impl { + if ((0xE000<=$1&&$1<=0xFFFF)) && [[ $_ble_util_locale_encoding == UTF-8 ]]; then + builtin printf -v ret '\\x%02x' "$((0xE0|$1>>12&0x0F))" "$((0x80|$1>>6&0x3F))" "$((0x80|$1&0x3F))" + else + builtin printf -v ret '\\U%08x' "$1" + fi + builtin eval "ret=\$'$ret'" + } + function ble/util/chars2s.impl { + if [[ $_ble_util_locale_encoding == UTF-8 ]]; then + local -a buff=() + local c i=0 + for c; do + ble/util/c2s.cached "$c" + buff[i++]=$ret + done + IFS= builtin eval 'ret="${buff[*]}"' + else + builtin printf -v ret '\\U%08x' "$@" + builtin eval "ret=\$'$ret'" + fi + } + else + function ble/util/c2s.impl { + builtin printf -v ret '\\U%08x' "$1" + builtin eval "ret=\$'$ret'" + } + function ble/util/chars2s.impl { + builtin printf -v ret '\\U%08x' "$@" + builtin eval "ret=\$'$ret'" + } + fi +else + _ble_text_xdigit=(0 1 2 3 4 5 6 7 8 9 A B C D E F) + _ble_text_hexmap=() + for ((i=0;i<256;i++)); do + _ble_text_hexmap[i]=${_ble_text_xdigit[i>>4&0xF]}${_ble_text_xdigit[i&0xF]} + done + function ble/util/c2s.impl { + if (($1<0x80)); then + builtin eval "ret=\$'\\x${_ble_text_hexmap[$1]}'" + return 0 + fi + local bytes i iN seq= + ble/encoding:"$_ble_util_locale_encoding"/c2b "$1" + for ((i=0,iN=${#bytes[@]};i/dev/null +function ble/util/c2keyseq { + local char=$(($1)) + case $char in + (7) ret='\a' ;; + (8) ret='\b' ;; + (9) ret='\t' ;; + (10) ret='\n' ;; + (11) ret='\v' ;; + (12) ret='\f' ;; + (13) ret='\r' ;; + (27) ret='\e' ;; + (92) ret='\\' ;; + (127) ret='\d' ;; + (28) ret='\x1c' ;; # workaround \C-\, \C-\\ + (156) ret='\x9c' ;; # workaround \M-\C-\, \M-\C-\\ + (*) + if ((char<32||128<=char&&char<160)); then + local char7=$((char&0x7F)) + if ((1<=char7&&char7<=26)); then + ble/util/c2s "$((char7+96))" + else + ble/util/c2s "$((char7+64))" + fi + ret='\C-'$ret + ((char&0x80)) && ret='\M-'$ret + else + ble/util/c2s "$char" + fi ;; + esac +} +function ble/util/chars2keyseq { + local char str= + for char; do + ble/util/c2keyseq "$char" + str=$str$ret + done + ret=$str +} +function ble/util/keyseq2chars { + local keyseq=$1 + local -a chars=() + local mods= + local rex='^([^\]+)|^\\([CM]-|[0-7]{1,3}|x[0-9a-fA-F]{1,2}|.)?' + while [[ $keyseq ]]; do + local text=${keyseq::1} esc + [[ $keyseq =~ $rex ]] && + text=${BASH_REMATCH[1]} esc=${BASH_REMATCH[2]} + if [[ $text ]]; then + keyseq=${keyseq:${#text}} + ble/util/s2chars "$text" + else + keyseq=${keyseq:1+${#esc}} + ret=() + case $esc in + ([CM]-) mods=$mods${esc::1}; continue ;; + (x?*) ret=$((16#${esc#x})) ;; + ([0-7]*) ret=$((8#$esc)) ;; + (a) ret=7 ;; + (b) ret=8 ;; + (t) ret=9 ;; + (n) ret=10 ;; + (v) ret=11 ;; + (f) ret=12 ;; + (r) ret=13 ;; + (e) ret=27 ;; + (d) ret=127 ;; + (*) ble/util/s2c "$esc" ;; + esac + fi + [[ $mods == *C* ]] && ((ret=ret==63?127:(ret&0x1F))) + [[ $mods == *M* ]] && ble/array#push chars 27 + mods= + ble/array#push chars "${ret[@]}" + done + if [[ $mods ]]; then + [[ $mods == *M* ]] && ble/array#push chars 27 + ble/array#push chars 0 + fi + ret=("${chars[@]}") +} +function ble/encoding:UTF-8/b2c { + local bytes b0 n i + bytes=("$@") + ret=0 + ((b0=bytes[0]&0xFF)) + ((n=b0>=0xF0 + ?(b0>=0xFC?5:(b0>=0xF8?4:3)) + :(b0>=0xE0?2:(b0>=0xC0?1:0)), + ret=n?b0&0x7F>>n:b0)) + for ((i=1;i<=n;i++)); do + ((ret=ret<<6|0x3F&bytes[i])) + done +} +function ble/encoding:UTF-8/c2b { + local code=$1 n i + ((code=code&0x7FFFFFFF, + n=code<0x80?0:( + code<0x800?1:( + code<0x10000?2:( + code<0x200000?3:( + code<0x4000000?4:5)))))) + if ((n==0)); then + bytes=("$code") + else + bytes=() + for ((i=n;i;i--)); do + ((bytes[i]=0x80|code&0x3F, + code>>=6)) + done + ((bytes[0]=code&0x3F>>n|0xFF80>>n&0xFF)) + fi +} +function ble/encoding:C/b2c { + local byte=$1 + ((ret=byte&0xFF)) +} +function ble/encoding:C/c2b { + local code=$1 + bytes=("$((code&0xFF))") +} +builtin eval -- "${_ble_util_gdict_declare//NAME/_ble_builtin_readonly_blacklist}" +function ble/builtin/readonly/.initialize-blacklist { + function ble/builtin/readonly/.initialize-blacklist { return 0; } + local -a list=() + ble/array#push list FUNCNEST IFS IGNOREEOF POSIXLY_CORRECT TMOUT # adjust + ble/array#push list PWD OLDPWD CDPATH # readlink + ble/array#push list BASHPID GLOBIGNORE MAPFILE REPLY # util + ble/array#push list INPUTRC # decode + ble/array#push list LINES COLUMNS # canvas + ble/array#push list HIST{CONTROL,IGNORE,SIZE,TIMEFORMAT} # history + ble/array#push list PROMPT_COMMAND PS1 # prompt + ble/array#push list BASH_COMMAND BASH_REMATCH HISTCMD LINENO PIPESTATUS TIMEFORMAT # exec + ble/array#push list BASH_XTRACEFD PS4 # debug + ble/array#push list CC LESS MANOPT MANPAGER PAGER PATH MANPATH + ble/array#push list BUFF # util + ble/array#push list KEYS KEYMAP WIDGET LASTWIDGET # decode + ble/array#push list DRAW_BUFF # canvas + ble/array#push list D{MIN,MAX,MAX0} {HIGHLIGHT,PREV}_{BUFF,UMAX,UMIN} LEVEL LAYER_{UMAX,UMIN} # color + ble/array#push list HISTINDEX_NEXT FILE LINE INDEX INDEX_FILE # history + ble/array#push list ARG FLAG REG # vi + ble/array#push list COMP{1,2,S,V} ACTION CAND DATA INSERT PREFIX_LEN # core-complete + ble/array#push list PRETTY_NAME NAME VERSION # edit (/etc/os-release) + local v + for v in "${list[@]}"; do ble/gdict#set _ble_builtin_readonly_blacklist "$v" 1; done +} +function ble/builtin/readonly/.check-variable-name { + ble/variable#is-global "$1" || return 0 + if [[ $1 == _* && $1 != _ble* && $1 != __ble* ]]; then + return 0 + fi + case $1 in + (?) return 1;; # single character variables + (BLE_*|ADVICE_*) return 1;; # ble.sh variables + (COMP_*|COMPREPLY) return 1;; # completion variables + (READLINE_*) return 1;; # readline variables + (LC_*|LANG) return 1;; # locale variables + esac + ble/builtin/readonly/.initialize-blacklist + if ble/gdict#has _ble_builtin_readonly_blacklist "$1"; then + return 1 + fi + if [[ $1 != *[a-z]* ]]; then + return 0 + fi + return 1 +} +builtin eval -- "${_ble_util_gdict_declare//NAME/_ble_builtin_readonly_mark}" +_ble_builtin_readonly_message_count=0 +blehook internal_PREEXEC!='_ble_builtin_readonly_message_count=0' +function ble/builtin/readonly/.print-warning { + [[ -t 2 ]] || return 0 + if [[ ! $_ble_local_caller ]]; then + _ble_local_caller=- + local i n=${#FUNCNAME[@]} + for ((i=1;i&2 + return 0 +} +function ble/builtin/readonly { + local _ble_local_set _ble_local_shopt + ble/base/.adjust-bash-options _ble_local_set _ble_local_shopt + local LC_ALL= LC_COLLATE=C 2>/dev/null # suppress locale error #D1440 + local _ble_local_flags= + local -a _ble_local_options=() + local _ble_local_caller= # used by print-warning + while (($#)); do + if ble/string#match "$1" '^([_a-zA-Z][_a-zA-Z0-9]*)($|=)'; then + _ble_local_flags=v$_ble_local_flags + local _ble_local_var=${BASH_REMATCH[1]} + if [[ ${BASH_REMATCH[2]} == = ]]; then + ble/util/sprintf "$_ble_local_var" "${1#*=}" + fi + if ble/builtin/readonly/.check-variable-name "$_ble_local_var"; then + _ble_local_flags=r$_ble_local_flags + ble/array#push _ble_local_options "$_ble_local_var" + else + ble/builtin/readonly/.print-warning "$1" + fi + else + ble/array#push _ble_local_options "$1" + fi + shift + done + if [[ $_ble_local_flags == *w* ]]; then + ble/util/print 'ble.sh: The global variables with unprefixed lowercase names or special names should not be made readonly. It can break arbitrary Bash configurations.' >&2 + fi + local _ble_local_ext=0 + if [[ $_ble_local_flags != *v* || $_ble_local_flags == *r* ]]; then + builtin readonly "${_ble_local_options[@]}" + _ble_local_ext=$? + fi + ble/util/unlocal LC_ALL LC_COLLATE 2>/dev/null # suppress locale error #D1440 + ble/base/.restore-bash-options _ble_local_set _ble_local_shopt + return "$?" +} +function readonly { + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_local_adjust" + ble/builtin/readonly "$@" + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_local_return" +} +>| "$_ble_base_run/$$.util.message-listening" +>> "$_ble_base_run/$$.util.message" +_ble_util_message_precmd=() +function ble/util/message/.encode-data { + local target=$1 data=$2 + if ((${#data}<256)); then + ble/string#quote-word "$data" + ret=eval:$ret + else + if ((_ble_bash<40000)); then + local BASHPID + ble/util/getpid + fi + local index=0 file + while + file=$_ble_base_run/$target.util.message.data-$BASHPID-$index + [[ -e $file ]] + do ((++index)); done + ble/util/put "$data" >| "$file" + ret=file:${file##*.} + fi +} +function ble/util/message/.decode-data { + ret=$1 + case $ret in + (eval:*) + local value=${ret#eval:} + ble/syntax:bash/simple-word/is-simple "$value" && + builtin eval -- "ret=($value)" ;; + (file:*) + local file=$_ble_base_run/$$.util.message.${ret#file:} + ble/util/readfile ret "$file" + ble/array#push _ble_local_remove "$file" + esac +} +function ble/util/message.post { + local target=${1:-$$} event=${2-} type=${3-} data=${4-} + if ! [[ $type && $type != *["$_ble_term_IFS"]* ]]; then + ble/util/print "ble/util/message: invalid message type format '$type'" >&2 + return 2 + elif [[ $target == $$ ]] && ! ble/is-function ble/util/message/handler:"$type"; then + ble/util/print "ble/util/message: unknown message type name '$type'" >&2 + return 2 + fi + case $event in + (precmd) ;; + (*) + ble/util/print "ble/util/message: unknown event type '$event'" >&2 + return 2 ;; + esac + if [[ $target == broadcast ]]; then + local ret file + ble/util/eval-pathname-expansion '"$_ble_base_run"/+([0-9]).util.message-listening' canonical + for file in "${ret[@]}"; do + file=${file%-listening} + local pid=${file##*/}; pid=${pid%%.*} + if builtin kill -0 "$pid"; then + ble/util/message/.encode-data "$pid" "$data" + ble/util/print "$event $type $ret" >> "$file" + fi + done + elif ble/string#match "$target" '^[0-9]+$'; then + if ! builtin kill -0 "$target"; then + ble/util/print "ble/util/message: target process $target is not found" >&2 + return 2 + elif [[ ! -f $_ble_base_run/$target.util.message-listening ]]; then + ble/util/print "ble/util/message: target process $target is not listening ble-messages" >&2 + return 2 + fi + local ret + ble/util/message/.encode-data "$target" "$data" + ble/util/print "$event $type $ret" >> "$_ble_base_run/$target.util.message" + else + ble/util/print "ble/util/message: unknown target '$target'" >&2 + return 2 + fi +} +function ble/util/message.check { + local file=$_ble_base_run/$$.util.message + while [[ -f $file && -s $file ]]; do + local fread=$file + ble/bin/mv -f "$file" "$file-reading" && fread=$file-reading + local IFS=$_ble_term_IFS event type data + while ble/bash/read event type data || [[ $event ]]; do + [[ $type ]] && ble/is-function ble/util/message/handler:"$type" || continue + case $event in + (precmd) ble/array#push _ble_util_message_precmd "$type $data" ;; + esac + done < "$fread" + >| "$fread" + done +} +function ble/util/message.process { + ble/util/message.check + local event=$1 + case $event in + (precmd) + local _ble_local_messages + _ble_local_messages=("${_ble_util_message_precmd[@]}") + _ble_util_message_precmd=() + local _ble_local_message + local -a _ble_local_remove=() + for _ble_local_message in "${_ble_local_messages[@]}"; do + local _ble_local_event=${_ble_local_message%%' '*} + local ret; ble/util/message/.decode-data "${_ble_local_message#* }" + local _ble_local_data=$ret + ble/util/unlocal ret + ble/util/message/handler:"$_ble_local_event" "$_ble_local_data" + done + ((${#_ble_local_remove[@]})) && ble/bin/rm -f "${_ble_local_remove[@]}" ;; + (*) + ble/util/print "ble/util/message: unknown event type '$event'" >&2 + return 2 ;; + esac +} +function ble/util/message/handler:print { + ble/edit/enter-command-layout # #D1800 pair=leave-command-layout + ble/util/print "$1" >&2 + ble/edit/leave-command-layout # #D1800 pair=enter-command-layout +} +blehook internal_PRECMD!='ble/util/message.process precmd' +bleopt/declare -v debug_xtrace '' +bleopt/declare -v debug_xtrace_ps4 '+ ' +ble/bin#freeze-utility-path "${_ble_init_posix_command_list[@]}" # <- this uses ble/util/assign. +ble/bin#freeze-utility-path man +ble/bin#freeze-utility-path groff nroff mandoc gzip bzcat lzcat xzcat # used by core-complete.sh +ble/function#trace trap ble/builtin/trap ble/builtin/trap/finalize +ble/function#trace ble/builtin/trap/.handler ble/builtin/trap/invoke ble/builtin/trap/invoke.sandbox +ble/builtin/trap/install-hook EXIT +ble/builtin/trap/install-hook INT +ble/builtin/trap/install-hook ERR inactive +ble/builtin/trap/install-hook RETURN inactive +function ble/base/initialize-session { + local ret + ble/string#split ret / "${_ble_base_session-}" + [[ ${ret[1]} == "$$" ]] && return 0 + ble/util/timeval; local start_time=$ret + ((start_time-=SECONDS*1000000)) + _ble_base_session=${start_time::${#start_time}-6}.${start_time:${#start_time}-6}/$$ + export BLE_SESSION_ID=$_ble_base_session +} +ble/base/initialize-session +function ble/base/check-bash-debug-version { + case ${BASH_VERSINFO[4]} in + (alp*|bet*|dev*|rc*|releng*|maint*) ;; + (*) return 0 ;; + esac + local type=check ret + ble/opts#extract-last-optarg "$_ble_base_arguments_opts" bash-debug-version check && type=$ret + [[ $type == ignore ]] && return 0 + local file=$_ble_base_cache/base.bash-debug-version-checked.txt + local -a checked=() + [[ ! -d $file && -r $file && -s $file ]] && ble/util/mapfile checked < "$file" + if ble/array#index checked "$BASH_VERSION"; then + [[ $type == once ]] && return 0 + else + ble/util/print "$BASH_VERSION" >> "$file" + fi + local sgr0=$_ble_term_sgr0 + local sgr1=${_ble_term_setaf[4]} + local sgr2=${_ble_term_setaf[6]} + local sgr3=${_ble_term_setaf[2]} + local sgrC=${_ble_term_setaf[8]} + local bold=$_ble_term_bold + if [[ $type == short || $_ble_init_command ]]; then + ble/util/print-lines \ + "Note: ble.sh can be very slow in a debug version of Bash: $sgr3$BASH_VERSION$sgr0" + else + ble/util/print-lines \ + "$bold# ble.sh with debug version of Bash$sgr0" \ + '' \ + 'ble.sh may become very slow because this is a debug version of Bash (version' \ + "\`$sgr3$BASH_VERSION$sgr0', release status: \`$sgr3${BASH_VERSINFO[4]}$sgr0'). We recommend using" \ + 'ble.sh with a release version of Bash. If you want to use ble.sh with a' \ + 'non-release version of Bash, it is highly recommended to build Bash with the' \ + "configure option \`$sgr2--with-bash-malloc=no$sgr0' for practical performance:" \ + '' \ + " $sgr1./configure $bold--with-bash-malloc=no$sgr0" \ + '' \ + 'To suppress this startup warning message, please specify the option' \ + "\`$sgr2--bash-debug-version=short$sgr0' or \`${sgr2}once$sgr0' or \`${sgr2}ignore$sgr0' to \`ble.sh':" \ + '' \ + " ${sgrC}# Show a short version of the message$sgr0" \ + " ${sgr1}source /path/to/ble.sh $bold--bash-debug-version=short$sgr0" \ + '' \ + " ${sgrC}# Do not print the warning message more than once$sgr0" \ + " ${sgr1}source /path/to/ble.sh $bold--bash-debug-version=once$sgr0" \ + '' \ + " ${sgrC}# Show the warning message only once for each debug version of Bash$sgr0" \ + " ${sgr1}source /path/to/ble.sh $bold--bash-debug-version=ignore$sgr0" \ + '' + fi +} +ble/base/check-bash-debug-version +bleopt/declare -v decode_error_char_abell '' +bleopt/declare -v decode_error_char_vbell 1 +bleopt/declare -v decode_error_char_discard '' +bleopt/declare -v decode_error_cseq_abell '' +bleopt/declare -v decode_error_cseq_vbell '' +bleopt/declare -v decode_error_cseq_discard 1 +bleopt/declare -v decode_error_kseq_abell 1 +bleopt/declare -v decode_error_kseq_vbell 1 +bleopt/declare -v decode_error_kseq_discard 1 +bleopt/declare -n default_keymap auto +function bleopt/check:default_keymap { + case $value in + (auto|emacs|vi|safe) + if [[ $_ble_decode_bind_state != none ]]; then + local bleopt_default_keymap=$value + ble/decode/reset-default-keymap + fi + return 0 ;; + (*) + ble/util/print "bleopt: Invalid value default_keymap='value'. The value should be one of \`auto', \`emacs', \`vi'." >&2 + return 1 ;; + esac +} +function bleopt/get:default_keymap { + ret=$bleopt_default_keymap + if [[ $ret == auto ]]; then + if [[ -o vi ]]; then + ret=vi + else + ret=emacs + fi + fi +} +bleopt/declare -n decode_isolated_esc auto +function bleopt/check:decode_isolated_esc { + case $value in + (meta|esc|auto) ;; + (*) + ble/util/print "bleopt: Invalid value decode_isolated_esc='$value'. One of the values 'auto', 'meta' or 'esc' is expected." >&2 + return 1 ;; + esac +} +function ble/decode/uses-isolated-esc { + if [[ $bleopt_decode_isolated_esc == esc ]]; then + return 0 + elif [[ $bleopt_decode_isolated_esc == auto ]]; then + if local ret; bleopt/get:default_keymap; [[ $ret == vi ]]; then + return 0 + elif [[ ! $_ble_decode_key__seq ]]; then + local dicthead=_ble_decode_${_ble_decode_keymap}_kmap_ key=$((_ble_decode_Ctrl|91)) + builtin eval "local ent=\${$dicthead$_ble_decode_key__seq[key]-}" + [[ ${ent:2} ]] && return 0 + fi + fi + return 1 +} +bleopt/declare -n decode_abort_char 28 +bleopt/declare -n decode_macro_limit 1024 +_ble_decode_Meta=0x08000000 +_ble_decode_Ctrl=0x04000000 +_ble_decode_Shft=0x02000000 +_ble_decode_Hypr=0x01000000 +_ble_decode_Supr=0x00800000 +_ble_decode_Altr=0x00400000 +_ble_decode_MaskChar=0x001FFFFF +_ble_decode_MaskFlag=0x7FC00000 +_ble_decode_Erro=0x40000000 +_ble_decode_Macr=0x20000000 +_ble_decode_Flag3=0x10000000 # unused +_ble_decode_FlagA=0x00200000 # unused +_ble_decode_IsolatedESC=$((0x07FC)) +_ble_decode_EscapedNUL=$((0x07FB)) # charlog#encode で用いる +_ble_decode_FunctionKeyBase=0x110000 +function ble/decode/mod2flag { + ret=0 + local mod=$1 + ((mod&0x01&&(ret|=_ble_decode_Shft), + mod&0x02&&(ret|=_ble_decode_Meta), + mod&0x04&&(ret|=_ble_decode_Ctrl), + mod&0x08&&(ret|=_ble_decode_Supr), + mod&0x10&&(ret|=_ble_decode_Hypr), + mod&0x20&&(ret|=_ble_decode_Altr))) +} +function ble/decode/flag2mod { + ret=0 + local flag=$1 + ((flag&_ble_decode_Shft&&(ret|=0x01), + flag&_ble_decode_Meta&&(ret|=0x02), + flag&_ble_decode_Ctrl&&(ret|=0x04), + flag&_ble_decode_Supr&&(ret|=0x08), + flag&_ble_decode_Hypr&&(ret|=0x10), + flag&_ble_decode_Altr&&(ret|=0x20))) +} +_ble_decode_kbd_ver=gdict +_ble_decode_kbd__n=0 +_ble_decode_kbd__c2k=() +builtin eval -- "${_ble_util_gdict_declare//NAME/_ble_decode_kbd__k2c}" +ble/is-assoc _ble_decode_kbd__k2c || _ble_decode_kbd_ver=adict +function ble-decode-kbd/.set-keycode { + local keyname=$1 + local code=$2 + : "${_ble_decode_kbd__c2k[code]:=$keyname}" + ble/gdict#set _ble_decode_kbd__k2c "$keyname" "$code" +} +function ble-decode-kbd/.get-keycode { + ble/gdict#get _ble_decode_kbd__k2c "$1" +} +function ble-decode-kbd/.get-keyname { + local keycode=$1 + ret=${_ble_decode_kbd__c2k[keycode]} + if [[ ! $ret ]] && ((keycode<_ble_decode_FunctionKeyBase)); then + ble/util/c2s "$keycode" + fi +} +function ble-decode-kbd/generate-keycode { + local keyname=$1 + if ((${#keyname}==1)); then + ble/util/s2c "$1" + elif [[ $keyname && ! ${keyname//[_a-zA-Z0-9]} ]]; then + ble-decode-kbd/.get-keycode "$keyname" + if [[ ! $ret ]]; then + ((ret=_ble_decode_FunctionKeyBase+_ble_decode_kbd__n++)) + ble-decode-kbd/.set-keycode "$keyname" "$ret" + fi + else + ret=-1 + return 1 + fi +} +function ble-decode-kbd/.initialize { + ble-decode-kbd/.set-keycode TAB 9 + ble-decode-kbd/.set-keycode RET 13 + ble-decode-kbd/.set-keycode NUL 0 + ble-decode-kbd/.set-keycode SOH 1 + ble-decode-kbd/.set-keycode STX 2 + ble-decode-kbd/.set-keycode ETX 3 + ble-decode-kbd/.set-keycode EOT 4 + ble-decode-kbd/.set-keycode ENQ 5 + ble-decode-kbd/.set-keycode ACK 6 + ble-decode-kbd/.set-keycode BEL 7 + ble-decode-kbd/.set-keycode BS 8 + ble-decode-kbd/.set-keycode HT 9 # aka TAB + ble-decode-kbd/.set-keycode LF 10 + ble-decode-kbd/.set-keycode VT 11 + ble-decode-kbd/.set-keycode FF 12 + ble-decode-kbd/.set-keycode CR 13 # aka RET + ble-decode-kbd/.set-keycode SO 14 + ble-decode-kbd/.set-keycode SI 15 + ble-decode-kbd/.set-keycode DLE 16 + ble-decode-kbd/.set-keycode DC1 17 + ble-decode-kbd/.set-keycode DC2 18 + ble-decode-kbd/.set-keycode DC3 19 + ble-decode-kbd/.set-keycode DC4 20 + ble-decode-kbd/.set-keycode NAK 21 + ble-decode-kbd/.set-keycode SYN 22 + ble-decode-kbd/.set-keycode ETB 23 + ble-decode-kbd/.set-keycode CAN 24 + ble-decode-kbd/.set-keycode EM 25 + ble-decode-kbd/.set-keycode SUB 26 + ble-decode-kbd/.set-keycode ESC 27 + ble-decode-kbd/.set-keycode FS 28 + ble-decode-kbd/.set-keycode GS 29 + ble-decode-kbd/.set-keycode RS 30 + ble-decode-kbd/.set-keycode US 31 + ble-decode-kbd/.set-keycode SP 32 + ble-decode-kbd/.set-keycode DEL 127 + ble-decode-kbd/.set-keycode PAD 128 + ble-decode-kbd/.set-keycode HOP 129 + ble-decode-kbd/.set-keycode BPH 130 + ble-decode-kbd/.set-keycode NBH 131 + ble-decode-kbd/.set-keycode IND 132 + ble-decode-kbd/.set-keycode NEL 133 + ble-decode-kbd/.set-keycode SSA 134 + ble-decode-kbd/.set-keycode ESA 135 + ble-decode-kbd/.set-keycode HTS 136 + ble-decode-kbd/.set-keycode HTJ 137 + ble-decode-kbd/.set-keycode VTS 138 + ble-decode-kbd/.set-keycode PLD 139 + ble-decode-kbd/.set-keycode PLU 140 + ble-decode-kbd/.set-keycode RI 141 + ble-decode-kbd/.set-keycode SS2 142 + ble-decode-kbd/.set-keycode SS3 143 + ble-decode-kbd/.set-keycode DCS 144 + ble-decode-kbd/.set-keycode PU1 145 + ble-decode-kbd/.set-keycode PU2 146 + ble-decode-kbd/.set-keycode STS 147 + ble-decode-kbd/.set-keycode CCH 148 + ble-decode-kbd/.set-keycode MW 149 + ble-decode-kbd/.set-keycode SPA 150 + ble-decode-kbd/.set-keycode EPA 151 + ble-decode-kbd/.set-keycode SOS 152 + ble-decode-kbd/.set-keycode SGCI 153 + ble-decode-kbd/.set-keycode SCI 154 + ble-decode-kbd/.set-keycode CSI 155 + ble-decode-kbd/.set-keycode ST 156 + ble-decode-kbd/.set-keycode OSC 157 + ble-decode-kbd/.set-keycode PM 158 + ble-decode-kbd/.set-keycode APC 159 + ble-decode-kbd/.set-keycode @ESC "$_ble_decode_IsolatedESC" + ble-decode-kbd/.set-keycode @NUL "$_ble_decode_EscapedNUL" + local ret + ble-decode-kbd/generate-keycode __batch_char__ + _ble_decode_KCODE_BATCH_CHAR=$ret + ble-decode-kbd/generate-keycode __defchar__ + _ble_decode_KCODE_DEFCHAR=$ret + ble-decode-kbd/generate-keycode __default__ + _ble_decode_KCODE_DEFAULT=$ret + ble-decode-kbd/generate-keycode __before_widget__ + _ble_decode_KCODE_BEFORE_WIDGET=$ret + ble-decode-kbd/generate-keycode __after_widget__ + _ble_decode_KCODE_AFTER_WIDGET=$ret + ble-decode-kbd/generate-keycode __attach__ + _ble_decode_KCODE_ATTACH=$ret + ble-decode-kbd/generate-keycode __detach__ + _ble_decode_KCODE_DETACH=$ret + ble-decode-kbd/generate-keycode shift + _ble_decode_KCODE_SHIFT=$ret + ble-decode-kbd/generate-keycode alter + _ble_decode_KCODE_ALTER=$ret + ble-decode-kbd/generate-keycode control + _ble_decode_KCODE_CONTROL=$ret + ble-decode-kbd/generate-keycode meta + _ble_decode_KCODE_META=$ret + ble-decode-kbd/generate-keycode super + _ble_decode_KCODE_SUPER=$ret + ble-decode-kbd/generate-keycode hyper + _ble_decode_KCODE_HYPER=$ret + ble-decode-kbd/generate-keycode __ignore__ + _ble_decode_KCODE_IGNORE=$ret + ble-decode-kbd/generate-keycode __error__ + _ble_decode_KCODE_ERROR=$ret + ble-decode-kbd/generate-keycode __line_limit__ + _ble_decode_KCODE_LINE_LIMIT=$ret + ble-decode-kbd/generate-keycode mouse + _ble_decode_KCODE_MOUSE=$ret + ble-decode-kbd/generate-keycode mouse_move + _ble_decode_KCODE_MOUSE_MOVE=$ret + ble-decode-kbd/generate-keycode auto_complete_enter +} +ble-decode-kbd/.initialize +function ble-decode-kbd { + local IFS=$_ble_term_IFS + local spec="$*" + case $spec in + (keys:*) + ret="${spec#*:}" + return 0 ;; + (chars:*) + local chars + ble/string#split-words chars "${spec#*:}" + ble/decode/cmap/decode-chars "${ret[@]}" + ret="${keys[*]}" + return 0 ;; + (keyseq:*) # i.e. untranslated keyseq + local keys + ble/util/keyseq2chars "${spec#*:}" + ble/decode/cmap/decode-chars "${ret[@]}" + ret="${keys[*]}" + return 0 ;; + (raw:*) # i.e. translated keyseq + ble/util/s2chars "${spec#*:}" + ble/decode/cmap/decode-chars "${ret[@]}" + ret="${keys[*]}" + return 0 ;; + (kspecs:*) + spec=${spec#*:} ;; + esac + local kspecs; ble/string#split-words kspecs "$spec" + local kspec code codes + codes=() + for kspec in "${kspecs[@]}"; do + code=0 + while [[ $kspec == ?-* ]]; do + case ${kspec::1} in + (S) ((code|=_ble_decode_Shft)) ;; + (C) ((code|=_ble_decode_Ctrl)) ;; + (M) ((code|=_ble_decode_Meta)) ;; + (A) ((code|=_ble_decode_Altr)) ;; + (s) ((code|=_ble_decode_Supr)) ;; + (H) ((code|=_ble_decode_Hypr)) ;; + (*) ((code|=_ble_decode_Erro)) ;; + esac + kspec=${kspec:2} + done + if [[ $kspec == ? ]]; then + ble/util/s2c "$kspec" + ((code|=ret)) + elif [[ $kspec && ! ${kspec//[@_a-zA-Z0-9]} ]]; then + ble-decode-kbd/.get-keycode "$kspec" + [[ $ret ]] || ble-decode-kbd/generate-keycode "$kspec" + ((code|=ret)) + elif [[ $kspec == ^? ]]; then + if [[ $kspec == '^?' ]]; then + ((code|=0x7F)) + elif [[ $kspec == '^`' ]]; then + ((code|=0x20)) + else + ble/util/s2c "${kspec:1}" + ((code|=ret&0x1F)) + fi + elif local rex='^U\+([0-9a-fA-F]+)$'; [[ $kspec =~ $rex ]]; then + ((code|=0x${BASH_REMATCH[1]})) + else + ((code|=_ble_decode_Erro)) + fi + codes[${#codes[@]}]=$code + done + ret="${codes[*]}" +} +function ble-decode-unkbd/.single-key { + local key=$1 + local f_unknown= + local char=$((key&_ble_decode_MaskChar)) + ble-decode-kbd/.get-keyname "$char" + if [[ ! $ret ]]; then + f_unknown=1 + ret=__UNKNOWN__ + fi + ((key&_ble_decode_Shft)) && ret=S-$ret + ((key&_ble_decode_Meta)) && ret=M-$ret + ((key&_ble_decode_Ctrl)) && ret=C-$ret + ((key&_ble_decode_Altr)) && ret=A-$ret + ((key&_ble_decode_Supr)) && ret=s-$ret + ((key&_ble_decode_Hypr)) && ret=H-$ret + [[ ! $f_unknown ]] +} +function ble-decode-unkbd { + local IFS=$_ble_term_IFS + local -a kspecs + local key + for key in $*; do + ble-decode-unkbd/.single-key "$key" + kspecs[${#kspecs[@]}]=$ret + done + ret="${kspecs[*]}" +} +function ble/decode/keys2chars { + local -a keys=() + local key + for key; do + local flag=$((key&_ble_decode_MaskFlag)) + local char=$((key&_ble_decode_MaskChar)) + if ((flag&_ble_decode_Meta)); then + ble/array#push keys 27 + ((flag&=~_ble_decode_Meta)) + fi + if ((flag==_ble_decode_Ctrl&&(char==63||char==64||91<=char&&char<=95||97<=char&&char<=122))); then + ble/array#push keys "$((char==63?127:(char&0x1F)))" + continue + fi + local mod_param= + if ((flag)); then + ble/decode/flag2mod "$flag" + mod_param=$((ret+1)) + fi + local csi=${_ble_decode_csimap_dict[char]-} + if [[ $csi == tilde:* ]]; then + local params=${csi#*:} + if [[ $mod_param ]]; then + params=$params';'$mod_param + fi + ble/util/s2chars "$params" + ble/array#push keys 27 91 "${ret[@]}" 126 + elif [[ $csi == alpha:* ]]; then + if [[ $mod_param ]]; then + ble/util/s2chars "1;$mod_param" + else + ret=() + fi + ble/array#push keys 27 91 "${ret[@]}" "${csi#*:}" + elif ((flag||char>=_ble_decode_FunctionKeyBase)); then + ble/util/s2chars "27;${mod_param:-1};$char" + ble/array#push keys 27 91 "${ret[@]}" 126 + else + ble/array#push keys "$char" + fi + done + ret=("${keys[@]}") +} +function ble-decode/PROLOGUE { return 0; } +function ble-decode/EPILOGUE { return 0; } +_ble_decode_input_buffer=() +_ble_decode_input_count=0 +_ble_decode_input_original_info=() +_ble_decode_show_progress_hook=ble-decode/.hook/show-progress +_ble_decode_erase_progress_hook=ble-decode/.hook/erase-progress +function ble-decode/.hook/show-progress { + if [[ $_ble_edit_info_scene == store ]]; then + _ble_decode_input_original_info=("${_ble_edit_info[@]}") + return 0 + elif [[ $_ble_edit_info_scene == default ]]; then + _ble_decode_input_original_info=() + elif [[ $_ble_edit_info_scene != decode_input_progress ]]; then + return 0 + fi + local progress_opts= opt_percentage=1 + if [[ $ble_batch_insert_count ]]; then + local total=$ble_batch_insert_count + local value=$ble_batch_insert_index + local label='constructing text...' + local sgr=$'\e[1;38;5;204;48;5;253m' + elif ((${#_ble_decode_input_buffer[@]})); then + local total=10000 + local value=$((${#_ble_decode_input_buffer[@]}%10000)) + local label="${#_ble_decode_input_buffer[@]} bytes received..." + local sgr=$'\e[1;38;5;135;48;5;253m' + progress_opts=unlimited + opt_percentage= + elif ((_ble_decode_input_count)); then + local total=${#chars[@]} + local value=$((total-_ble_decode_input_count-1)) + local label='decoding input...' + local sgr=$'\e[1;38;5;69;48;5;253m' + elif ((ble_decode_char_total)); then + local total=$ble_decode_char_total + local value=$((total-ble_decode_char_rest-1)) + local label='processing input...' + local sgr=$'\e[1;38;5;71;48;5;253m' + else + return 0 + fi + if [[ $opt_percentage ]]; then + local mill=$((value*1000/total)) + local cent=${mill::${#mill}-1} frac=${mill:${#mill}-1} + label="${cent:-0}.$frac% $label" + fi + local text="($label)" + if ble/util/is-unicode-output; then + local ret + ble/string#create-unicode-progress-bar "$value" "$total" 10 "$progress_opts" + text=$sgr$ret$'\e[m '$text + fi + ble/edit/info/show ansi "$text" + _ble_edit_info_scene=decode_input_progress +} +function ble-decode/.hook/erase-progress { + [[ $_ble_edit_info_scene == decode_input_progress ]] || return 1 + if ((${#_ble_decode_input_original_info[@]})); then + ble/edit/info/show store "${_ble_decode_input_original_info[@]}" + else + ble/edit/info/default + fi +} +function ble-decode/.check-abort { + if (($1==bleopt_decode_abort_char)); then + local nbytes=${#_ble_decode_input_buffer[@]} + local nchars=${#_ble_decode_char_buffer[@]} + ((nbytes||nchars)); return "$?" + fi + (($1==0x7e||$1==0x75)) || return 1 + local i=$((${#_ble_decode_input_buffer[@]}-1)) + local n + ((n=bleopt_decode_abort_char, + n+=(1<=n&&n<=26?96:64))) + if (($1==0x7e)); then + for ((;n;n/=10)); do + ((i>=0)) && ((_ble_decode_input_buffer[i--]==n%10+48)) || return 1 + done + ((i>=4)) || return 1 + ((_ble_decode_input_buffer[i--]==59)) || return 1 + ((_ble_decode_input_buffer[i--]==53)) || return 1 + ((_ble_decode_input_buffer[i--]==59)) || return 1 + ((_ble_decode_input_buffer[i--]==55)) || return 1 + ((_ble_decode_input_buffer[i--]==50)) || return 1 + elif (($1==0x75)); then + ((i>=1)) || return 1 + ((_ble_decode_input_buffer[i--]==53)) || return 1 + ((_ble_decode_input_buffer[i--]==59)) || return 1 + for ((;n;n/=10)); do + ((i>=0)) && ((_ble_decode_input_buffer[i--]==n%10+48)) || return 1 + done + fi + ((i>=0)) && ((_ble_decode_input_buffer[i]==62&&i--)) + ((i>=0)) || return 1 + if ((_ble_decode_input_buffer[i]==0x5B)); then + if ((i>=1&&_ble_decode_input_buffer[i-1]==0x1B)); then + ((i-=2)) + elif ((i>=2&&_ble_decode_input_buffer[i-1]==0x9B&&_ble_decode_input_buffer[i-2]==0xC0)); then + ((i-=3)) + else + return 1 + fi + elif ((_ble_decode_input_buffer[i]==0x9B)); then + ((--i>=0)) && ((_ble_decode_input_buffer[i--]==0xC2)) || return 1 + else + return 1 + fi + (((i>=0||${#_ble_decode_char_buffer[@]}))); return "$?" + return 0 +} +if ((_ble_bash>=40400)); then + function ble/decode/nonblocking-read { + local timeout=${1:-0.01} ntimeout=${2:-1} loop=${3:-100} + local LC_ALL= LC_CTYPE=C IFS= + local -a data=() + local line buff ext + while ((loop--)); do + ble/bash/read-timeout "$timeout" -r -d '' buff; ext=$? + [[ $buff ]] && line=$line$buff + if ((ext==0)); then + ble/array#push data "$line" + line= + elif ((ext>128)); then + ((--ntimeout)) || break + [[ $buff ]] || break + else + break + fi + done + ble/util/assign ret '{ + ((${#data[@]})) && printf %s\\0 "${data[@]}" + [[ $line ]] && printf %s "$line" + } | ble/bin/od -A n -t u1 -v' + ble/string#split-words ret "$ret" + } + ble/function#suppress-stderr ble/decode/nonblocking-read +elif ((_ble_bash>=40000)); then + function ble/decode/nonblocking-read { + local timeout=${1:-0.01} ntimeout=${2:-1} loop=${3:-100} + local LC_ALL= LC_CTYPE=C IFS= 2>/dev/null + local -a data=() + local line buff + while ((loop--)); do + builtin read -t 0 || break + ble/bash/read -d '' -n 1 buff || break + if [[ $buff ]]; then + line=$line$buff + else + ble/array#push data "$line" + line= + fi + done + ble/util/assign ret '{ + ((${#data[@]})) && printf %s\\0 "${data[@]}" + [[ $line ]] && printf %s "$line" + } | ble/bin/od -A n -t u1 -v' + ble/string#split-words ret "$ret" + } + ble/function#suppress-stderr ble/decode/nonblocking-read +fi +function ble-decode/.hook/adjust-volatile-options { + if [[ $_ble_bash_options_adjusted ]]; then + set +ev + fi +} +_ble_decode_hook_count=${_ble_decode_hook_count:+0} +_ble_decode_hook_Processing= +function _ble_decode_hook { + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_unset" + ((_ble_decode_hook_count++)) + if ble/util/is-stdin-ready; then + ble/array#push _ble_decode_input_buffer "$@" + local buflen=${#_ble_decode_input_buffer[@]} + if ((buflen%257==0&&buflen>=2000)); then + ble-decode/.hook/adjust-volatile-options + local IFS=$_ble_term_IFS + local _ble_decode_hook_Processing=prologue + ble-decode/PROLOGUE + _ble_decode_hook_Processing=body + local char=${_ble_decode_input_buffer[buflen-1]} + if ((_ble_bash<40000||char==0xC0||char==0xDF)); then + builtin eval -- "$_ble_decode_show_progress_hook" + else + while ble/util/is-stdin-ready; do + builtin eval -- "$_ble_decode_show_progress_hook" + local ret; ble/decode/nonblocking-read 0.02 1 527 + ble/array#push _ble_decode_input_buffer "${ret[@]}" + done + fi + _ble_decode_hook_Processing=epilogue + ble-decode/EPILOGUE + ble/util/unlocal _ble_decode_hook_Processing + local ret + ble/array#pop _ble_decode_input_buffer + _ble_decode_hook "$ret" + fi + return 0 + fi + ble-decode/.hook/adjust-volatile-options + local IFS=$_ble_term_IFS + local _ble_decode_hook_Processing=prologue + ble-decode/PROLOGUE + _ble_decode_hook_Processing=body + if ble-decode/.check-abort "$1"; then + _ble_decode_char__hook= + _ble_decode_input_buffer=() + _ble_decode_char_buffer=() + ble/term/visible-bell "Abort by 'bleopt decode_abort_char=$bleopt_decode_abort_char'" + shift + fi + local chars + ble/array#set chars "${_ble_decode_input_buffer[@]}" "$@" + _ble_decode_input_buffer=() + _ble_decode_input_count=${#chars[@]} + if ((_ble_decode_input_count>=200)); then + local i N=${#chars[@]} + local B=$((N/100)) + ((B<100)) && B=100 || ((B>1000)) && B=1000 + for ((i=0;i=0)); then + if ((33<=key&&key<_ble_decode_FunctionKeyBase)); then + local term=${_ble_term_TERM[0]+${_ble_term_TERM[${#_ble_term_TERM[@]}-1]}} + if (((mod&0x01)&&0x31<=key&&key<=0x39)) && [[ $term == RLogin:* ]]; then + ((key-=16,mod&=~0x01)) + elif ((mod==0x01)); then + if [[ $term != contra:* ]]; then + ((mod&=~0x01)) + fi + elif ((65<=key&&key<=90)); then + ((key|=0x20)) + fi + fi + local ret + ble/decode/mod2flag "$mod" + ((key|=ret)) + fi +} +function ble-decode-char/csi/.decode { + local char=$1 rex key + if ((char==126)); then # ~ + if rex='^>?27;([0-9]+);?([0-9]+)$' && [[ $_ble_decode_csi_args =~ $rex ]]; then + local param1=$((10#0${BASH_REMATCH[1]})) + local param2=$((10#0${BASH_REMATCH[2]})) + local key=$((param2&_ble_decode_MaskChar)) + ble-decode-char/csi/.modify-key "$param1" + csistat=$key + return 0 + fi + if rex='^>?([0-9]+)(;([0-9]+))?$' && [[ $_ble_decode_csi_args =~ $rex ]]; then + local param1=$((10#0${BASH_REMATCH[1]})) + local param3=$((10#0${BASH_REMATCH[3]})) + key=${_ble_decode_csimap_tilde[param1]} + if [[ $key ]]; then + ble-decode-char/csi/.modify-key "$param3" + csistat=$key + return 0 + fi + fi + elif ((char==117)); then # u + if rex='^([0-9]*)(;[0-9]*)?$'; [[ $_ble_decode_csi_args =~ $rex ]]; then + local rematch1=${BASH_REMATCH[1]} + if [[ $rematch1 != 1 ]]; then + local key=$((10#0$rematch1)) mods=$((10#0${BASH_REMATCH:${#rematch1}+1})) + [[ $_ble_term_TERM == kitty:* ]] && ble-decode/char/csi/.translate-kitty-csi-u + ble-decode-char/csi/.modify-key "$mods" + csistat=$key + fi + return 0 + fi + elif ((char==94||char==64)); then # ^, @ + if rex='^[0-9]+$' && [[ $_ble_decode_csi_args =~ $rex ]]; then + local param1=$((10#0${BASH_REMATCH[1]})) + local param3=$((10#0${BASH_REMATCH[3]})) + key=${_ble_decode_csimap_tilde[param1]} + if [[ $key ]]; then + ((key|=_ble_decode_Ctrl, + char==64&&(key|=_ble_decode_Shft))) + ble-decode-char/csi/.modify-key "$param3" + csistat=$key + return 0 + fi + fi + elif ((char==99)); then # c + if rex='^[?>]'; [[ $_ble_decode_csi_args =~ $rex ]]; then + if [[ $_ble_decode_csi_args == '?'* ]]; then + ble/term/DA1/notify "${_ble_decode_csi_args:1}" + else + ble/term/DA2/notify "${_ble_decode_csi_args:1}" + fi + csistat=$_ble_decode_KCODE_IGNORE + return 0 + fi + elif ((char==82||char==110)); then # R or n + if rex='^([0-9]+);([0-9]+)$'; [[ $_ble_decode_csi_args =~ $rex ]]; then + local param1=$((10#0${BASH_REMATCH[1]})) + local param2=$((10#0${BASH_REMATCH[2]})) + ble/term/CPR/notify "$param1" "$param2" + csistat=$_ble_decode_KCODE_IGNORE + return 0 + fi + elif ((char==77||char==109)); then # M or m + if rex='^<([0-9]+);([0-9]+);([0-9]+)$'; [[ $_ble_decode_csi_args =~ $rex ]]; then + local param1=$((10#0${BASH_REMATCH[1]})) + local param2=$((10#0${BASH_REMATCH[2]})) + local param3=$((10#0${BASH_REMATCH[3]})) + local button=$param1 + ((_ble_term_mouse_button=button&~0x1C, + char==109&&(_ble_term_mouse_button|=0x70), + _ble_term_mouse_x=param2-1, + _ble_term_mouse_y=param3-1)) + local key=$_ble_decode_KCODE_MOUSE + ((button&32)) && key=$_ble_decode_KCODE_MOUSE_MOVE + ble-decode-char/csi/.modify-key "$((button>>2&0x07))" + csistat=$key + return 0 + fi + elif ((char==116)); then # t + if rex='^<([0-9]+);([0-9]+)$'; [[ $_ble_decode_csi_args =~ $rex ]]; then + local param1=$((10#0${BASH_REMATCH[1]})) + local param2=$((10#0${BASH_REMATCH[2]})) + ((_ble_term_mouse_button=128, + _ble_term_mouse_x=param1-1, + _ble_term_mouse_y=param2-1)) + local key=$_ble_decode_KCODE_MOUSE + csistat=$key + fi + fi + key=${_ble_decode_csimap_alpha[char]} + if [[ $key ]]; then + if rex='^(1?|>?1;([0-9]+))$' && [[ $_ble_decode_csi_args =~ $rex ]]; then + local param2=$((10#0${BASH_REMATCH[2]})) + ble-decode-char/csi/.modify-key "$param2" + csistat=$key + return 0 + fi + fi + csistat=$_ble_decode_KCODE_ERROR +} +function ble-decode-char/csi/consume { + csistat= + ((_ble_decode_csi_mode==0&&$1!=27&&$1!=155)) && return 1 + local char=$1 + case $_ble_decode_csi_mode in + (0) + ((_ble_decode_csi_mode=$1==155?2:1)) + _ble_decode_csi_args= + csistat=_ ;; + (1) + if ((char!=91)); then + _ble_decode_csi_mode=0 + return 1 + else + _ble_decode_csi_mode=2 + _ble_decode_csi_args= + csistat=_ + fi ;; + (2) + if ((32<=char&&char<64)); then + local ret; ble/util/c2s "$char" + _ble_decode_csi_args=$_ble_decode_csi_args$ret + csistat=_ + elif ((64<=char&&char<127)); then + _ble_decode_csi_mode=0 + ble-decode-char/csi/.decode "$char" + ((csistat==27)) && csistat=$_ble_decode_IsolatedESC + else + _ble_decode_csi_mode=0 + fi ;; + esac +} +_ble_decode_char_buffer=() +function ble/decode/has-input-for-char { + ((_ble_decode_input_count)) || + ble/util/is-stdin-ready || + ble/encoding:"$bleopt_input_encoding"/is-intermediate +} +_ble_decode_char__hook= +_ble_decode_cmap_=() +_ble_decode_char2_seq= +_ble_decode_char2_reach_key= +_ble_decode_char2_reach_seq= +_ble_decode_char2_modifier= +_ble_decode_char2_modkcode= +_ble_decode_char2_modseq=() +function ble-decode-char { + if [[ $ble_decode_char_nest && ! $ble_decode_char_sync ]]; then + ble/array#push _ble_decode_char_buffer "$@" + return 148 + fi + local ble_decode_char_nest=1 + local iloop=0 + local ble_decode_char_total=$# + local ble_decode_char_rest=$# + local ble_decode_char_char= + local chars ichar char ent + chars=("$@") ichar=0 + while + if ((iloop++%50==0)); then + ((iloop>=200)) && builtin eval -- "$_ble_decode_show_progress_hook" + if [[ ! $ble_decode_char_sync ]] && ble/decode/has-input-for-char; then + ble/array#push _ble_decode_char_buffer "${chars[@]:ichar}" + return 148 + fi + fi + if ((${#_ble_decode_char_buffer[@]})); then + ((ble_decode_char_total+=${#_ble_decode_char_buffer[@]})) + ((ble_decode_char_rest+=${#_ble_decode_char_buffer[@]})) + ble/array#set chars "${_ble_decode_char_buffer[@]}" "${chars[@]:ichar}" + ichar=0 + _ble_decode_char_buffer=() + fi + ((ble_decode_char_rest)) + do + char=${chars[ichar]} + ble_decode_char_char=$char # 補正前 char (_ble_decode_Macr 判定の為) + ((ble_decode_char_rest--,ichar++)) + ((_ble_debug_keylog_enabled)) && ble/array#push _ble_debug_keylog_chars "$char" + if [[ $_ble_decode_keylog_chars_enabled ]]; then + if ! ((char&_ble_decode_Macr)); then + ble/array#push _ble_decode_keylog_chars "$char" + ((_ble_decode_keylog_chars_count++)) + fi + fi + ((char&=~_ble_decode_Macr)) + if ((char&_ble_decode_Erro)); then + ((char&=~_ble_decode_Erro)) + if [[ $bleopt_decode_error_char_vbell ]]; then + local name; ble/util/sprintf name 'U+%04x' "$char" + ble/term/visible-bell "received a misencoded char $name" + fi + [[ $bleopt_decode_error_char_abell ]] && ble/term/audible-bell + [[ $bleopt_decode_error_char_discard ]] && continue + fi + if [[ $_ble_decode_char__hook ]]; then + ((char==_ble_decode_IsolatedESC)) && char=27 # isolated ESC -> ESC + local hook=$_ble_decode_char__hook + _ble_decode_char__hook= + ble-decode/widget/.call-async-read "$hook $char" "$char" + continue + fi + ble-decode-char/.getent # -> ent + if [[ ! $ent ]]; then + if [[ $_ble_decode_char2_reach_key ]]; then + local key=$_ble_decode_char2_reach_key + local seq=$_ble_decode_char2_reach_seq + local rest=${_ble_decode_char2_seq:${#seq}} + ble/string#split-words rest "${rest//_/ } $ble_decode_char_char" + _ble_decode_char2_seq= + _ble_decode_char2_reach_key= + _ble_decode_char2_reach_seq= + ble-decode-char/csi/clear + ble/decode/send-unmodified-key "$key" "$seq" + ((ble_decode_char_total+=${#rest[@]})) + ((ble_decode_char_rest+=${#rest[@]})) + chars=("${rest[@]}" "${chars[@]:ichar}") ichar=0 + else + local ret + ble/decode/process-char/.convert-c0 "$char" + ble/decode/send-unmodified-key "$ret" "_$char" + fi + elif [[ $ent == *_ ]]; then + _ble_decode_char2_seq=${_ble_decode_char2_seq}_$char + if [[ ${ent%_} ]]; then + _ble_decode_char2_reach_key=${ent%_} + _ble_decode_char2_reach_seq=$_ble_decode_char2_seq + elif [[ ! $_ble_decode_char2_reach_key ]]; then + local ret + ble/decode/process-char/.convert-c0 "$char" + _ble_decode_char2_reach_key=$ret + _ble_decode_char2_reach_seq=$_ble_decode_char2_seq + fi + else + local seq=${_ble_decode_char2_seq}_$char + _ble_decode_char2_seq= + _ble_decode_char2_reach_key= + _ble_decode_char2_reach_seq= + ble-decode-char/csi/clear + ble/decode/send-unmodified-key "$ent" "$seq" + fi + done + return 0 +} +function ble/decode/char-hook/next-char { + ((ble_decode_char_rest)) || return 1 + ((char=chars[ichar]&~_ble_decode_Macr)) + ((char&_ble_decode_Erro)) && return 1 + ((iloop%1000==0)) && return 1 + ((char==_ble_decode_IsolatedESC)) && char=27 + ((ble_decode_char_rest--,ichar++,iloop++)) + return 0 +} +function ble-decode-char/.getent { + builtin eval "ent=\${_ble_decode_cmap_$_ble_decode_char2_seq[char]-}" + if [[ $ent == ?*_ || $ent == _ && $_ble_decode_char2_seq == _27 ]]; then + ble/decode/wait-input 5 char || ent=${ent%_} + fi + local csistat= + ble-decode-char/csi/consume "$char" + if [[ $csistat && ! ${ent%_} ]]; then + if ((csistat==_ble_decode_KCODE_ERROR)); then + if [[ $bleopt_decode_error_cseq_vbell ]]; then + local ret; ble-decode-unkbd ${_ble_decode_char2_seq//_/ } $char + ble/term/visible-bell "unrecognized CSI sequence: $ret" + fi + [[ $bleopt_decode_error_cseq_abell ]] && ble/term/audible-bell + if [[ $bleopt_decode_error_cseq_discard ]]; then + csistat=$_ble_decode_KCODE_IGNORE + else + csistat= + fi + fi + if [[ ! $ent ]]; then + ent=$csistat + else + ent=${csistat%_}_ + fi + fi +} +function ble/decode/process-char/.convert-c0 { + ret=$1 + if ((0<=ret&&ret<32)); then + ((ret|=(ret==0||ret>26?64:96)|_ble_decode_Ctrl)) + elif ((ret==127)); then # C-? + ((ret=63|_ble_decode_Ctrl)) + fi +} +function ble/decode/send-unmodified-key/.add-modifier { + local mflag1=$1 mflag=$_ble_decode_char2_modifier + if ((mflag1&mflag)); then + return 1 + else + ((_ble_decode_char2_modkcode=key|mflag, + _ble_decode_char2_modifier=mflag1|mflag)) + ble/array#push _ble_decode_char2_modseq "${seq[@]}" + return 0 + fi +} +function ble/decode/send-unmodified-key { + local key=$1 + ((key==_ble_decode_KCODE_IGNORE)) && return 0 + local seq + ble/string#split-words seq "${2//_/ }" + ((seq[0]==_ble_decode_IsolatedESC)) && seq[0]=27 + if [[ $2 == _27 ]]; then + ble/decode/send-unmodified-key/.add-modifier "$_ble_decode_Meta" && return 0 + fi + if + if ((key==_ble_decode_IsolatedESC)); then + if [[ $2 == "_$_ble_decode_IsolatedESC" ]]; then + key=$((_ble_decode_Ctrl|91)) + else + key=27 + fi + else + ((key==27)) + fi + then + if ! ble/decode/uses-isolated-esc; then + ble/decode/send-unmodified-key/.add-modifier "$_ble_decode_Meta" && return 0 + fi + fi + if ((_ble_decode_KCODE_SHIFT<=key&&key<=_ble_decode_KCODE_HYPER)); then + case $1 in + ($_ble_decode_KCODE_SHIFT) + ble/decode/send-unmodified-key/.add-modifier "$_ble_decode_Shft" && return 0 ;; + ($_ble_decode_KCODE_CONTROL) + ble/decode/send-unmodified-key/.add-modifier "$_ble_decode_Ctrl" && return 0 ;; + ($_ble_decode_KCODE_ALTER) + ble/decode/send-unmodified-key/.add-modifier "$_ble_decode_Altr" && return 0 ;; + ($_ble_decode_KCODE_META) + ble/decode/send-unmodified-key/.add-modifier "$_ble_decode_Meta" && return 0 ;; + ($_ble_decode_KCODE_SUPER) + ble/decode/send-unmodified-key/.add-modifier "$_ble_decode_Supr" && return 0 ;; + ($_ble_decode_KCODE_HYPER) + ble/decode/send-unmodified-key/.add-modifier "$_ble_decode_Hypr" && return 0 ;; + esac + fi + if [[ $_ble_decode_char2_modifier ]]; then + local mflag mcode mseq + mflag=$_ble_decode_char2_modifier + mcode=$_ble_decode_char2_modkcode + mseq=("${_ble_decode_char2_modseq[@]}") + _ble_decode_char2_modifier= + _ble_decode_char2_modkcode= + _ble_decode_char2_modseq=() + if ((key&mflag)); then + local _ble_decode_key__chars + _ble_decode_key__chars=("${mseq[@]}") + ble-decode-key "$mcode" + else + seq=("${mseq[@]}" "${seq[@]}") + ((key|=mflag)) + fi + fi + local _ble_decode_key__chars + _ble_decode_key__chars=("${seq[@]}") + ble-decode-key "$key" +} +function ble-decode-char/is-intermediate { [[ $_ble_decode_char2_seq ]]; } +function ble-decode-char/bind { + local -a seq; ble/string#split-words seq "$1" + local kc=$2 + local i iN=${#seq[@]} char tseq= + for ((i=0;i| "$delay" + fi +} +function ble/decode/keymap#load { + local opts=:$2: + ble/decode/keymap#registered "$1" && return 0 + local init=ble-decode/keymap:$1/define + ble/is-function "$init" || return 1 + ble/decode/keymap#.register "$1" + local ble_bind_keymap=$1 + if ! "$init" || ble/decode/keymap#is-empty "$1"; then + ble/decode/keymap#.unregister "$1" + return 1 + fi + [[ $opts == *:dump:* ]] && + ble/decode/keymap#dump "$1" >&3 + ble/decode/keymap#.onload "$1" + return 0 +} +function ble/decode/keymap#unload { + if (($#==0)); then + local list; ble/string#split-words list "${_ble_decode_keymap_list//:/ }" + set -- "${list[@]}" + fi + while (($#)); do + local array_names array_name + builtin eval -- "array_names=(\"\${!_ble_decode_${1}_kmap_@}\")" + for array_name in "${array_names[@]}"; do + builtin unset -v "$array_name" + done + ble/decode/keymap#.unregister "$1" + shift + done +} +if [[ ${_ble_decode_kmaps-} ]]; then + function ble/decode/keymap/cleanup-old-keymaps { + local -a list=() + local var + for var in "${!_ble_decode_@}"; do + [[ $var == _ble_decode_*_kmap_ ]] || continue + var=${var#_ble_decode_} + var=${var%_kmap_} + ble/array#push list "$var" + done + local keymap_name + for keymap_name in "${list[@]}"; do + ble/decode/keymap#unload "$keymap_name" + done + builtin unset -v _ble_decode_kmaps + } + ble/decode/keymap/cleanup-old-keymaps +fi +function ble/decode/keymap#dump { + if (($#)); then + local kmap=$1 arrays + builtin eval "arrays=(\"\${!_ble_decode_${kmap}_kmap_@}\")" + ble/util/print "ble/decode/keymap#.register $kmap" + ble/util/declare-print-definitions "${arrays[@]}" + ble/util/print "ble/decode/keymap#.onload $kmap" + else + local list; ble/string#split-words list "${_ble_decode_keymap_list//:/ }" + local keymap_name + for keymap_name in "${list[@]}"; do + ble/decode/keymap#dump "$keymap_name" + done + fi +} +function ble-decode/GET_BASEMAP { + [[ $1 == -v ]] || return 1 + local ret; bleopt/get:default_keymap + [[ $ret == vi ]] && ret=vi_imap + builtin eval "$2=\$ret" +} +function ble-decode/INITIALIZE_DEFMAP { + ble-decode/GET_BASEMAP "$@" && + ble/decode/keymap#load "${!2}" && + return 0 + ble/decode/keymap#load safe && + builtin eval -- "$2=safe" && + bleopt_default_keymap=safe +} +function ble/widget/.SHELL_COMMAND { local IFS=$_ble_term_IFS; builtin eval -- "$*"; } +function ble/widget/.EDIT_COMMAND { local IFS=$_ble_term_IFS; builtin eval -- "$*"; } +function ble-decode-key/bind { + if ! ble/decode/keymap#registered "$1"; then + ble/util/print-quoted-command "$FUNCNAME" "$@" >> "$_ble_base_run/$$.bind.delay.$1" + return 0 + fi + local kmap=$1 keys=$2 cmd=$3 + if local widget=${cmd%%[$_ble_term_IFS]*}; ! ble/is-function "$widget"; then + local message="ble-bind: Unknown widget \`${widget#'ble/widget/'}'." + [[ $command == ble/widget/ble/widget/* ]] && + message="$message Note: The prefix 'ble/widget/' is redundant." + ble/util/print "$message" >&2 + return 1 + fi + local dicthead=_ble_decode_${kmap}_kmap_ + local -a seq; ble/string#split-words seq "$keys" + local i iN=${#seq[@]} tseq= + for ((i=0;i> "$_ble_base_run/$$.bind.delay.$1" + return 0 + fi + local kmap=$1 keys=$2 timeout=$3 + local dicthead=_ble_decode_${kmap}_kmap_ + local -a seq; ble/string#split-words seq "$keys" + [[ $timeout == - ]] && timeout= + local i iN=${#seq[@]} + local key=${seq[iN-1]} + local tseq= + for ((i=0;i&2 + return 1 + fi +} +function ble-decode-key/unbind { + if ! ble/decode/keymap#registered "$1"; then + ble/util/print-quoted-command "$FUNCNAME" "$@" >> "$_ble_base_run/$$.bind.delay.$1" + return 0 + fi + local kmap=$1 keys=$2 + local dicthead=_ble_decode_${kmap}_kmap_ + local -a seq; ble/string#split-words seq "$keys" + local i iN=${#seq[@]} + local key=${seq[iN-1]} + local tseq= + for ((i=0;i> "$_ble_base_run/$$.bind.delay.$keymap" + return 0 + fi + builtin eval "_ble_decode_${keymap}_kmap_cursor=\$cursor" + if [[ $keymap == "$_ble_decode_keymap" && $cursor ]]; then + ble/term/cursor-state/set-internal "$((cursor))" + fi +} +function ble/decode/keymap#print { + local kmap + if (($#==0)); then + for kmap in ${_ble_decode_keymap_list//:/ }; do + ble/util/print "$sgrc# keymap $kmap$sgr0" + ble/decode/keymap#print "$kmap" + done + return 0 + fi + [[ $ble_bind_print ]] || local sgr0= sgrf= sgrq= sgrc= sgro= + local kmap=$1 tseq=$2 nseq=$3 + local dicthead=_ble_decode_${kmap}_kmap_ + local kmapopt= + [[ $kmap ]] && kmapopt=" $sgro-m$sgr0 $sgrq'$kmap'$sgr0" + local q=\' Q="'\''" + local key keys + builtin eval "keys=(\${!$dicthead$tseq[@]})" + for key in "${keys[@]}"; do + local ret; ble-decode-unkbd "$key" + local knames=$nseq${nseq:+ }$ret + builtin eval "local ent=\${$dicthead$tseq[key]}" + local qknames + if [[ $sgrq ]]; then + ble/string#quote-word "$knames" quote-empty:sgrq="$sgrq":sgr0="$sgr0"; qknames=$ret + else + qknames="'${knames//$q/$Q}'" + fi + if [[ $ent == *:* ]]; then + local cmd=${ent#*:} + local o v + case $cmd in + ('ble/widget/.SHELL_COMMAND '*) o=c v=${cmd#'ble/widget/.SHELL_COMMAND '}; builtin eval "v=$v" ;; + ('ble/widget/.EDIT_COMMAND '*) o=x v=${cmd#'ble/widget/.EDIT_COMMAND '} ; builtin eval "v=$v" ;; + ('ble/widget/.MACRO '*) o=s; ble/util/chars2keyseq ${cmd#*' '}; v=$ret ;; + ('ble/widget/'*) o=f v=${cmd#ble/widget/} ;; + (*) o=@ v=$cmd ;; + esac + local qv + if [[ $sgrq ]]; then + ble/string#quote-word "$v" quote-empty:sgrq="$sgrq":sgr0="$sgr0"; qv=$ret + else + qv="'${v//$q/$Q}'" + fi + ble/util/print "${sgrf}ble-bind$sgr0$kmapopt $sgro-$o$sgr0 $qknames $qv" + fi + if [[ ${ent::1} == _ ]]; then + ble/decode/keymap#print "$kmap" "${tseq}_$key" "$knames" + if [[ $ent == _[0-9]* ]]; then + local timeout=${ent%%:*}; timeout=${timeout:1} + ble/util/print "${sgrf}ble-bind$sgr0$kmapopt $sgro-T$sgr0 $qknames $timeout" + fi + fi + done +} +_ble_decode_keymap= +_ble_decode_keymap_stack=() +function ble/decode/keymap/push { + if ble/decode/keymap#registered "$1"; then + ble/array#push _ble_decode_keymap_stack "$_ble_decode_keymap" + _ble_decode_keymap=$1 + local cursor; ble/decode/keymap#get-cursor "$1" + [[ $cursor ]] && ble/term/cursor-state/set-internal "$((cursor))" + return 0 + elif ble/decode/keymap#load "$1" && ble/decode/keymap#registered "$1"; then + ble/decode/keymap/push "$1" # 再実行 + else + ble/util/print "[ble: keymap '$1' not found]" >&2 + return 1 + fi +} +function ble/decode/keymap/pop { + local count=${#_ble_decode_keymap_stack[@]} + local last=$((count-1)) + ble/util/assert '((last>=0))' || return 1 + local cursor + ble/decode/keymap#get-cursor "$_ble_decode_keymap" + if [[ $cursor ]]; then + local i + for ((i=last;i>=0;i--)); do + ble/decode/keymap#get-cursor "${_ble_decode_keymap_stack[i]}" + [[ $cursor ]] && break + done + ble/term/cursor-state/set-internal "$((${cursor:-0}))" + fi + local old_keymap=_ble_decode_keymap + _ble_decode_keymap=${_ble_decode_keymap_stack[last]} + builtin unset -v '_ble_decode_keymap_stack[last]' +} +function ble/decode/keymap/get-parent { + local len=${#_ble_decode_keymap_stack[@]} + if ((len)); then + ret=${_ble_decode_keymap_stack[len-1]} + else + ret= + fi +} +_ble_decode_key__chars=() +_ble_decode_key__seq= +_ble_decode_key__hook= +function ble-decode-key/is-intermediate { [[ $_ble_decode_key__seq ]]; } +_ble_decode_key_batch=() +function ble-decode-key/batch/flush { + ((${#_ble_decode_key_batch[@]})) || return 1 + local dicthead=_ble_decode_${_ble_decode_keymap}_kmap_ + builtin eval "local command=\${${dicthead}[_ble_decode_KCODE_BATCH_CHAR]-}" + command=${command:2} + if [[ $command ]]; then + local chars; chars=("${_ble_decode_key_batch[@]}") + _ble_decode_key_batch=() + ble/decode/widget/call-interactively "$command" "${chars[@]}"; local ext=$? + ((ext!=125)) && return 0 + fi + ble/decode/widget/call-interactively ble/widget/__batch_char__.default "${chars[@]}"; local ext=$? + return "$ext" +} +function ble/widget/__batch_char__.default { + builtin eval "local widget_defchar=\${${dicthead}[_ble_decode_KCODE_DEFCHAR]-}" + widget_defchar=${widget_defchar:2} + builtin eval "local widget_default=\${${dicthead}[_ble_decode_KCODE_DEFAULT]-}" + widget_default=${widget_default:2} + local -a unprocessed_chars=() + local key command + for key in "${KEYS[@]}"; do + if [[ $widget_defchar ]]; then + ble/decode/widget/call-interactively "$widget_defchar" "$key"; local ext=$? + ((ext!=125)) && continue + fi + if [[ $widget_default ]]; then + ble/decode/widget/call-interactively "$widget_default" "$key"; local ext=$? + ((ext!=125)) && continue + fi + ble/array#push unprocessed_chars "$key" + done + if ((${#unprocessed_chars[@]})); then + local ret; ble-decode-unkbd "${unprocessed_chars[@]}" + [[ $bleopt_decode_error_kseq_vbell ]] && ble/term/visible-bell "unprocessed chars: $ret" + [[ $bleopt_decode_error_kseq_abell ]] && ble/term/audible-bell + fi + return 0 +} +function ble-decode-key { + local CHARS + CHARS=("${_ble_decode_key__chars[@]}") + local key + while (($#)); do + key=$1; shift + ((_ble_debug_keylog_enabled)) && ble/array#push _ble_debug_keylog_keys "$key" + if [[ $_ble_decode_keylog_keys_enabled && $_ble_decode_keylog_depth == 0 ]]; then + ble/array#push _ble_decode_keylog_keys "$key" + ((_ble_decode_keylog_keys_count++)) + fi + local dicthead=_ble_decode_${_ble_decode_keymap}_kmap_ + if (((key&_ble_decode_MaskChar)==_ble_decode_KCODE_MOUSE_MOVE)); then + builtin eval "local command=\${${dicthead}[key]-}" + command=${command:2} + ble-decode/widget/.call-keyseq + continue + fi + if [[ $_ble_decode_key__hook ]]; then + local hook=$_ble_decode_key__hook + _ble_decode_key__hook= + ble-decode/widget/.call-async-read "$hook $key" "$key" + continue + fi + builtin eval "local ent=\${$dicthead$_ble_decode_key__seq[key]-}" + if [[ $ent == _[0-9]* ]]; then + local node_type=_ + if (($#==0)) && ! ble/decode/has-input; then + local timeout=${ent%%:*}; timeout=${timeout:1} + ble/decode/wait-input "$timeout" || node_type=1 + fi + if [[ $ent == *:* ]]; then + ent=$node_type:${ent#*:} + else + ent=$node_type + fi + fi + if [[ $ent == 1:* ]]; then + local command=${ent:2} + if [[ $command ]]; then + ble-decode/widget/.call-keyseq + else + _ble_decode_key__seq= + fi + elif [[ $ent == _ || $ent == _:* ]]; then + _ble_decode_key__seq=${_ble_decode_key__seq}_$key + else + ble-decode-key/.invoke-partial-match "$key" && continue + local kseq=${_ble_decode_key__seq}_$key ret + ble-decode-unkbd "${kseq//_/ }" + local kspecs=$ret + [[ $bleopt_decode_error_kseq_vbell ]] && ble/term/visible-bell "unbound keyseq: $kspecs" + [[ $bleopt_decode_error_kseq_abell ]] && ble/term/audible-bell + if [[ $_ble_decode_key__seq ]]; then + if [[ $bleopt_decode_error_kseq_discard ]]; then + _ble_decode_key__seq= + else + local -a keys + ble/string#split-words keys "${_ble_decode_key__seq//_/ } $key" + _ble_decode_key__seq= + ble-decode-key "${keys[@]:1}" + fi + fi + fi + done + if ((${#_ble_decode_key_batch[@]})); then + if ! ble/decode/has-input || ((${#_ble_decode_key_batch[@]}>=50)); then + ble-decode-key/batch/flush + fi + fi + return 0 +} +function ble-decode-key/.invoke-partial-match { + local dicthead=_ble_decode_${_ble_decode_keymap}_kmap_ + local next=$1 + if [[ $_ble_decode_key__seq ]]; then + local last=${_ble_decode_key__seq##*_} + _ble_decode_key__seq=${_ble_decode_key__seq%_*} + builtin eval "local ent=\${$dicthead$_ble_decode_key__seq[last]-}" + if [[ $ent == _*:* ]]; then + local command=${ent#*:} + if [[ $command ]]; then + ble-decode/widget/.call-keyseq + else + _ble_decode_key__seq= + fi + ble-decode-key "$next" + return 0 + else # ent = _ + if ble-decode-key/.invoke-partial-match "$last"; then + ble-decode-key "$next" + return 0 + else + _ble_decode_key__seq=${_ble_decode_key__seq}_$last + return 1 + fi + fi + else + local key=$1 + if ble-decode-key/ischar "$key"; then + if ble/decode/has-input && builtin eval "[[ \${${dicthead}[_ble_decode_KCODE_BATCH_CHAR]-} ]]"; then + ble/array#push _ble_decode_key_batch "$key" + return 0 + fi + builtin eval "local command=\${${dicthead}[_ble_decode_KCODE_DEFCHAR]-}" + command=${command:2} + if [[ $command ]]; then + local seq_save=$_ble_decode_key__seq + ble-decode/widget/.call-keyseq; local ext=$? + ((ext!=125)) && return 0 + _ble_decode_key__seq=$seq_save # 125 の時はまた元に戻して次の試行を行う + fi + fi + builtin eval "local command=\${${dicthead}[_ble_decode_KCODE_DEFAULT]-}" + command=${command:2} + ble-decode/widget/.call-keyseq; local ext=$? + ((ext!=125)) && return 0 + return 1 + fi +} +function ble-decode-key/ischar { + local key=$1 + (((key&_ble_decode_MaskFlag)==0&&32<=key&&key<_ble_decode_FunctionKeyBase)) +} +_ble_decode_widget_last= +function ble-decode/widget/.invoke-hook { + local key=$1 + local dicthead=_ble_decode_${_ble_decode_keymap}_kmap_ + builtin eval "local hook=\${$dicthead[key]-}" + hook=${hook:2} + [[ $hook ]] && builtin eval -- "$hook" +} +function ble-decode/widget/.call-keyseq { + ble-decode-key/batch/flush + [[ $command ]] || return 125 + local _ble_decode_keylog_depth=$((_ble_decode_keylog_depth+1)) + local WIDGET=$command KEYMAP=$_ble_decode_keymap LASTWIDGET=$_ble_decode_widget_last + local -a KEYS; ble/string#split-words KEYS "${_ble_decode_key__seq//_/ } $key" + _ble_decode_widget_last=$WIDGET + _ble_decode_key__seq= + ble-decode/widget/.invoke-hook "$_ble_decode_KCODE_BEFORE_WIDGET" + builtin eval -- "$WIDGET"; local ext=$? + ble-decode/widget/.invoke-hook "$_ble_decode_KCODE_AFTER_WIDGET" + ((_ble_decode_keylog_depth==1)) && + _ble_decode_keylog_chars_count=0 _ble_decode_keylog_keys_count=0 + return "$ext" +} +function ble-decode/widget/.call-async-read { + local _ble_decode_keylog_depth=$((_ble_decode_keylog_depth+1)) + local WIDGET=$1 KEYMAP=$_ble_decode_keymap LASTWIDGET=$_ble_decode_widget_last + local -a KEYS; ble/string#split-words KEYS "$2" + builtin eval -- "$WIDGET"; local ext=$? + ((_ble_decode_keylog_depth==1)) && + _ble_decode_keylog_chars_count=0 _ble_decode_keylog_keys_count=0 + return "$ext" +} +function ble/decode/widget/call-interactively { + local WIDGET=$1 KEYMAP=$_ble_decode_keymap LASTWIDGET=$_ble_decode_widget_last + local -a KEYS; KEYS=("${@:2}") + _ble_decode_widget_last=$WIDGET + ble-decode/widget/.invoke-hook "$_ble_decode_KCODE_BEFORE_WIDGET" + builtin eval -- "$WIDGET"; local ext=$? + ble-decode/widget/.invoke-hook "$_ble_decode_KCODE_AFTER_WIDGET" + return "$ext" +} +function ble/decode/widget/call { + local WIDGET=$1 KEYMAP=$_ble_decode_keymap LASTWIDGET=$_ble_decode_widget_last + local -a KEYS; KEYS=("${@:2}") + _ble_decode_widget_last=$WIDGET + builtin eval -- "$WIDGET" +} +function ble/decode/widget/dispatch { + local ret; ble/string#quote-command "ble/widget/${1#ble/widget/}" "${@:2}" + local WIDGET=$ret + _ble_decode_widget_last=$WIDGET + builtin eval -- "$WIDGET" +} +function ble/decode/widget/suppress-widget { + WIDGET= +} +function ble/decode/widget/redispatch-by-keys { + ble/decode/widget/skip-lastwidget + if ((_ble_decode_keylog_depth==1)); then + ble/decode/keylog#pop + _ble_decode_keylog_depth=0 + fi + ble-decode-key "$@" +} +function ble/decode/widget/redispatch { + ble/decode/widget/redispatch-by-keys "${KEYS[@]}" +} +function ble/decode/widget/skip-lastwidget { + _ble_decode_widget_last=$LASTWIDGET +} +function ble/decode/widget/keymap-dispatch { + local name=${FUNCNAME[1]#ble/widget/} + local widget=ble/widget/$_ble_decode_keymap/$name + ble/is-function "$widget" || widget=ble/widget/default/$name + "$widget" "$@" +} +function ble/decode/has-input { + ((_ble_decode_input_count||ble_decode_char_rest)) || + ble/util/is-stdin-ready || + ble/encoding:"$bleopt_input_encoding"/is-intermediate || + ble-decode-char/is-intermediate +} +function ble/decode/has-input-char { + ((_ble_decode_input_count||ble_decode_char_rest)) || + ble/util/is-stdin-ready || + ble/encoding:"$bleopt_input_encoding"/is-intermediate +} +function ble/decode/wait-input { + local timeout=$1 type=${2-} + if [[ $type == char ]]; then + ble/decode/has-input-char && return 0 + else + ble/decode/has-input && return 0 + fi + while ((timeout>0)); do + local w=$((timeout<20?timeout:20)) + ble/util/msleep "$w" + ((timeout-=w)) + ble/util/is-stdin-ready 0 && return 0 + done + return 1 +} +function ble/util/idle/IS_IDLE { + ! ble/decode/has-input +} +_ble_debug_keylog_enabled=0 +_ble_debug_keylog_bytes=() +_ble_debug_keylog_chars=() +_ble_debug_keylog_keys=() +function ble/debug/keylog#start { + _ble_debug_keylog_enabled=1 +} +function ble/debug/keylog#end { + { + local IFS=$_ble_term_IFS + ble/util/print '===== bytes =====' + ble/util/print "${_ble_debug_keylog_bytes[*]}" + ble/util/print + ble/util/print '===== chars =====' + local ret; ble-decode-unkbd "${_ble_debug_keylog_chars[@]}" + ble/string#split ret ' ' "$ret" + ble/util/print "${ret[*]}" + ble/util/print + ble/util/print '===== keys =====' + local ret; ble-decode-unkbd "${_ble_debug_keylog_keys[@]}" + ble/string#split ret ' ' "$ret" + ble/util/print "${ret[*]}" + ble/util/print + } | fold -w 40 + _ble_debug_keylog_enabled=0 + _ble_debug_keylog_bytes=() + _ble_debug_keylog_chars=() + _ble_debug_keylog_keys=() +} +_ble_decode_keylog_depth=0 +_ble_decode_keylog_keys_enabled= +_ble_decode_keylog_keys_count=0 +_ble_decode_keylog_keys=() +_ble_decode_keylog_chars_enabled= +_ble_decode_keylog_chars_count=0 +_ble_decode_keylog_chars=() +function ble/decode/keylog#start { + [[ $_ble_decode_keylog_keys_enabled ]] && return 1 + _ble_decode_keylog_keys_enabled=${1:-1} + _ble_decode_keylog_keys=() +} +function ble/decode/keylog#end { + ret=("${_ble_decode_keylog_keys[@]}") + _ble_decode_keylog_keys_enabled= + _ble_decode_keylog_keys=() +} +function ble/decode/keylog#pop { + [[ $_ble_decode_keylog_keys_enabled && $_ble_decode_keylog_depth == 1 ]] || return 1 + local new_size=$((${#_ble_decode_keylog_keys[@]}-_ble_decode_keylog_keys_count)) + ((new_size<0)) && new_size=0 + _ble_decode_keylog_keys=("${_ble_decode_keylog_keys[@]::new_size}") + _ble_decode_keylog_keys_count=0 +} +function ble/decode/charlog#start { + [[ $_ble_decode_keylog_chars_enabled ]] && return 1 + _ble_decode_keylog_chars_enabled=${1:-1} + _ble_decode_keylog_chars=() +} +function ble/decode/charlog#end { + [[ $_ble_decode_keylog_chars_enabled ]] || { ret=(); return 1; } + ret=("${_ble_decode_keylog_chars[@]}") + _ble_decode_keylog_chars_enabled= + _ble_decode_keylog_chars=() +} +function ble/decode/charlog#end-exclusive { + ret=() + [[ $_ble_decode_keylog_chars_enabled ]] || return 1 + local size=$((${#_ble_decode_keylog_chars[@]}-_ble_decode_keylog_chars_count)) + ((size>0)) && ret=("${_ble_decode_keylog_chars[@]::size}") + _ble_decode_keylog_chars_enabled= + _ble_decode_keylog_chars=() +} +function ble/decode/charlog#end-exclusive-depth1 { + if ((_ble_decode_keylog_depth==1)); then + ble/decode/charlog#end-exclusive + else + ble/decode/charlog#end + fi +} +function ble/decode/charlog#encode { + local -a buff=() + for char; do + ((char==0)) && char=$_ble_decode_EscapedNUL + ble/util/c2s "$char" + ble/array#push buff "$ret" + done + IFS= builtin eval 'ret="${buff[*]}"' +} +function ble/decode/charlog#decode { + local text=$1 n=${#1} i chars + chars=() + for ((i=0;i=bleopt_decode_macro_limit)); then + ((_ble_decode_macro_count==bleopt_decode_macro_limit+1)) && + ble/term/visible-bell "Macro invocation is canceled by decode_macro_limit" + return 1 + fi + else + _ble_decode_macro_count=0 + fi + local -a chars=() + local char + for char; do + ble/array#push chars "$((char|_ble_decode_Macr))" + done + ble-decode-char "${chars[@]}" +} +function ble/widget/.CHARS { + ble-decode-char "$@" +} +function ble/decode/c2dqs { + local i=$1 + if ((0<=i&&i<32)); then + if ((1<=i&&i<=26)); then + ble/util/c2s "$((i+96))" + ret="\\C-$ret" + elif ((i==27)); then + ret="\\e" + elif ((i==28)); then + ret="\\x1c" + else + ble/decode/c2dqs "$((i+64))" + ret="\\C-$ret" + fi + elif ((32<=i&&i<127)); then + ble/util/c2s "$i" + if ((i==34||i==92)); then + ret='\'"$ret" + fi + elif ((128<=i&&i<160)); then + ble/util/sprintf ret '\\%03o' "$i" + else + ble/util/sprintf ret '\\%03o' "$i" + fi +} +function ble/decode/cmap/.generate-binder-template { + local tseq=$1 qseq=$2 nseq=$3 depth=${4:-1} ccode + local apos="'" escapos="'\\''" + builtin eval "local -a ccodes; ccodes=(\${!_ble_decode_cmap_$tseq[@]})" + for ccode in "${ccodes[@]}"; do + local ret + ble/decode/c2dqs "$ccode" + local qseq1=$qseq$ret + local nseq1="$nseq $ccode" + builtin eval "local ent=\${_ble_decode_cmap_$tseq[ccode]}" + if [[ ${ent%_} ]]; then + if ((depth>=3)); then + ble/util/print "\$binder \"$qseq1\" \"${nseq1# }\"" + fi + fi + if [[ ${ent//[0-9]} == _ ]]; then + ble/decode/cmap/.generate-binder-template "${tseq}_$ccode" "$qseq1" "$nseq1" "$((depth+1))" + fi + done +} +function ble/decode/cmap/.emit-bindx { + local q="'" Q="'\''" + ble/util/print "builtin bind -x '\"${1//$q/$Q}\":_ble_decode_hook $2; builtin eval -- \"\$_ble_decode_bind_hook\"'" +} +function ble/decode/cmap/.emit-bindr { + ble/util/print "builtin bind -r \"$1\"" +} +_ble_decode_cmap_initialized= +function ble/decode/cmap/initialize { + [[ $_ble_decode_cmap_initialized ]] && return 0 + _ble_decode_cmap_initialized=1 + local init=$_ble_base/lib/init-cmap.sh + local dump=$_ble_base_cache/decode.cmap.$_ble_decode_kbd_ver.$TERM.dump + if [[ -s $dump && $dump -nt $init ]]; then + source "$dump" + else + ble/edit/info/immediate-show text 'ble.sh: generating "'"$dump"'"...' + source "$init" + ble-bind -D | ble/bin/awk ' + { + sub(/^declare +(-[aAilucnrtxfFgGI]+ +)?/, ""); + sub(/^-- +/, ""); + } + /^_ble_decode_(cmap|csimap|kbd)/ { + if (!($0 ~ /^_ble_decode_csimap_kitty_u/)) + gsub(/["'\'']/, ""); + print + } + ' >| "$dump" + fi + if ((_ble_bash>=40300)); then + local fbinder=$_ble_base_cache/decode.cmap.allseq + _ble_decode_bind_fbinder=$fbinder + if ! [[ -s $_ble_decode_bind_fbinder.bind && $_ble_decode_bind_fbinder.bind -nt $init && + -s $_ble_decode_bind_fbinder.unbind && $_ble_decode_bind_fbinder.unbind -nt $init ]]; then + ble/edit/info/immediate-show text 'ble.sh: initializing multi-character sequence binders... ' + ble/decode/cmap/.generate-binder-template >| "$fbinder" + binder=ble/decode/cmap/.emit-bindx source "$fbinder" >| "$fbinder.bind" + binder=ble/decode/cmap/.emit-bindr source "$fbinder" >| "$fbinder.unbind" + ble/edit/info/immediate-show text 'ble.sh: initializing multi-character sequence binders... done' + fi + fi +} +function ble/decode/cmap/decode-chars.hook { + ble/array#push ble_decode_bind_keys "$1" + _ble_decode_key__hook=ble/decode/cmap/decode-chars.hook +} +function ble/decode/cmap/decode-chars { + ble/decode/cmap/initialize + local _ble_decode_csi_mode=0 + local _ble_decode_csi_args= + local _ble_decode_char2_seq= + local _ble_decode_char2_reach_key= + local _ble_decode_char2_reach_seq= + local _ble_decode_char2_modifier= + local _ble_decode_char2_modkcode= + local -a _ble_decode_char2_modseq=() + local _ble_decode_char__hook= + local _ble_debug_keylog_enabled= + local _ble_decode_keylog_keys_enabled= + local _ble_decode_keylog_chars_enabled= + local _ble_decode_show_progress_hook= + local _ble_decode_erase_progress_hook= + local bleopt_decode_error_cseq_abell= + local bleopt_decode_error_cseq_vbell= + local bleopt_decode_error_cseq_discard= + local -a ble_decode_bind_keys=() + local _ble_decode_key__hook=ble/decode/cmap/decode-chars.hook + local ble_decode_char_sync=1 # ユーザ入力があっても中断しない + ble-decode-char "$@" "$_ble_decode_KCODE_IGNORE" + keys=("${ble_decode_bind_keys[@]}") + if [[ $_ble_decode_char2_modkcode ]]; then + ble/array#push keys "$_ble_decode_char2_modkcode" + fi +} +_ble_decode_bind_hook= +_ble_decode_bind__uvwflag= +function ble/decode/readline/adjust-uvw { + [[ $_ble_decode_bind__uvwflag ]] && return 0 + _ble_decode_bind__uvwflag=1 + builtin bind -x $'"\025":_ble_decode_hook 21; builtin eval -- "$_ble_decode_bind_hook"' # ^U + builtin bind -x $'"\026":_ble_decode_hook 22; builtin eval -- "$_ble_decode_bind_hook"' # ^V + builtin bind -x $'"\027":_ble_decode_hook 23; builtin eval -- "$_ble_decode_bind_hook"' # ^W + builtin bind -x $'"\177":_ble_decode_hook 127; builtin eval -- "$_ble_decode_bind_hook"' # ^? + builtin bind -x $'"\010":_ble_decode_hook 8; builtin eval -- "$_ble_decode_bind_hook"' # ^H +} +if ((_ble_bash>=50100)); then + function ble/base/workaround-POSIXLY_CORRECT { + [[ $_ble_decode_bind_state == none ]] && return 0 + builtin bind -x '"\C-i":_ble_decode_hook 9; builtin eval -- "$_ble_decode_bind_hook"' + } +fi +function ble/decode/readline/.generate-source-to-unbind-default { + { + if ((_ble_bash>=40300)); then + ble/util/print '__BINDX__' + builtin bind -X + fi + ble/util/print '__BINDP__' + builtin bind -sp + } | ble/decode/readline/.generate-source-to-unbind-default/.process +} 2>/dev/null +function ble/decode/readline/.generate-source-to-unbind-default/.process { + local q=\' Q="'\''" + LC_ALL=C ble/bin/awk -v q="$q" ' + BEGIN { + IS_XPG4 = AWKTYPE == "xpg4"; + rep_Q = str2rep(q "\\" q q); + rep_bslash = str2rep("\\"); + rep_kseq_1c5c = str2rep("\"\\x1c\\x5c\""); + rep_kseq_1c = str2rep("\"\\x1c\""); + mode = 1; + } + function str2rep(str) { + if (IS_XPG4) sub(/\\/, "\\\\\\\\", str); + return str; + } + function quote(text) { + gsub(q, rep_Q, text); + return q text q; + } + function unescape_control_modifier(str, _, i, esc, chr) { + for (i = 0; i < 32; i++) { + if (i == 0 || i == 31) + esc = sprintf("\\\\C-%c", i + 64); + else if (27 <= i && i <= 30) + esc = sprintf("\\\\C-\\%c", i + 64); + else + esc = sprintf("\\\\C-%c", i + 96); + chr = sprintf("%c", i); + gsub(esc, chr, str); + } + gsub(/\\C-\?/, sprintf("%c", 127), str); + return str; + } + function unescape(str) { + if (str ~ /\\C-/) + str = unescape_control_modifier(str); + gsub(/\\e/, sprintf("%c", 27), str); + gsub(/\\"/, "\"", str); + gsub(/\\\\/, rep_bslash, str); + return str; + } + function output_bindr(line0, _seq) { + if (match(line0, /^"(([^"\\]|\\.)+)"/) > 0) { + _seq = substr(line0, 2, RLENGTH - 2); + gsub(/\\M-/, "\\e", _seq); + print "builtin bind -r " quote(_seq); + } + } + /^__BINDP__$/ { mode = 1; next; } + /^__BINDX__$/ { mode = 2; next; } + mode == 1 && $0 ~ /^"/ { + sub(/^"\\C-\\\\\\"/, rep_kseq_1c5c); + sub(/^"\\C-\\\\?"/, rep_kseq_1c); + output_bindr($0); + print "builtin bind " quote($0) > "/dev/stderr"; + } + mode == 2 && $0 ~ /^"/ { + output_bindr($0); + line = $0; + if (line ~ /(^|[^[:alnum:]])(ble-decode\/.hook|_ble_decode_hook)($|[^[:alnum:]])/) next; + if (match(line, /^("([^"\\]|\\.)*":) "(([^"\\]|\\.)*)"/) > 0) { + rlen = RLENGTH; + match(line, /^"([^"\\]|\\.)*":/); + rlen1 = RLENGTH; + rlen2 = rlen - rlen1 - 3; + sequence = substr(line, 1 , rlen1); + command = substr(line, rlen1 + 3, rlen2); + if (command ~ /\\/) + command = unescape(command); + line = sequence command; + } + print "builtin bind -x " quote(line) > "/dev/stderr"; + } + ' 2>| "$_ble_base_run/$$.bind.save" +} +_ble_decode_bind_state=none +_ble_decode_bind_bindp= +_ble_decode_bind_encoding= +function ble/decode/readline/bind { + _ble_decode_bind_encoding=$bleopt_input_encoding + local file=$_ble_base_cache/decode.bind.$_ble_bash.$_ble_decode_bind_encoding.bind + [[ -s $file && $file -nt $_ble_base/lib/init-bind.sh ]] || source "$_ble_base/lib/init-bind.sh" + ble/term/rl-convert-meta/enter + source "$file" + _ble_decode_bind__uvwflag= + ble/util/assign _ble_decode_bind_bindp 'builtin bind -p' # TERM 変更検出用 +} +function ble/decode/readline/unbind { + ble/function#try ble/encoding:"$bleopt_input_encoding"/clear + source "$_ble_base_cache/decode.bind.$_ble_bash.$_ble_decode_bind_encoding.unbind" +} +function ble/decode/readline/rebind { + [[ $_ble_decode_bind_state == none ]] && return 0 + ble/decode/readline/unbind + ble/decode/readline/bind +} +function ble/decode/bind/.initialize-kmap { + [[ $kmap ]] && return 0 + ble-decode/GET_BASEMAP -v kmap + if ! ble/decode/is-keymap "$kmap"; then + ble/util/print "ble-bind: the default keymap '$kmap' is unknown." >&2 + flags=R$flags + return 1 + fi + return 0 +} +function ble/decode/bind/option:help { + ble/util/cat <=1)) || return 0 + if [[ $3 ]]; then + ((req--)) + ble/array#push optarg "${4-$3}" + fi + ((req>=1)) || return 0 + if ((${#args[@]}-iarg&2 + else + ble/util/print "ble-bind: the option \`$label' requires $req arguments." >&2 + fi + return 2 + fi + ble/array#push optarg "${args[@]:iarg:req}" + ((iarg+=req)) + return 0 +} +function ble/decode/bind/option:csi { + local ret key= + if [[ $2 ]]; then + ble-decode-kbd "$2" + ble/string#split-words key "$ret" + if ((${#key[@]}!=1)); then + ble/util/print "ble-bind --csi: the second argument is not a single key!" >&2 + return 1 + elif ((key&~_ble_decode_MaskChar)); then + ble/util/print "ble-bind --csi: the second argument should not have modifiers!" >&2 + return 1 + fi + fi + local rex + if rex='^([1-9][0-9]*)~$' && [[ $1 =~ $rex ]]; then + _ble_decode_csimap_tilde[BASH_REMATCH[1]]=$key + if [[ ! ${_ble_decode_csimap_dict[key]} ]]; then + _ble_decode_csimap_dict[key]=tilde:${BASH_REMATCH[1]} + fi + local -a cseq + cseq=(27 91) + local ret i iN num="${BASH_REMATCH[1]}\$" + for ((i=0,iN=${#num};i&2 + return 1 + fi +} +function ble/decode/bind/option:list-widgets { + declare -f | ble/bin/sed -n 's/^ble\/widget\/\([a-zA-Z][^.[:space:]();&|]\{1,\}\)[[:space:]]*()[[:space:]]*$/\1/p' +} +function ble/decode/bind/option:dump { + if (($#)); then + local keymap + for keymap; do + ble/decode/keymap#dump "$keymap" + done + else + ble/util/declare-print-definitions "${!_ble_decode_kbd__@}" "${!_ble_decode_cmap_@}" "${!_ble_decode_csimap_@}" + ble/decode/keymap#dump + fi +} +function ble/decode/bind/option:print { + local ble_bind_print=1 + local sgr0= sgrf= sgrq= sgrc= sgro= + if [[ $flags == *c* || $flags != *n* && -t 1 ]]; then + local ret + ble/color/face2sgr command_function; sgrf=$ret + ble/color/face2sgr syntax_quoted; sgrq=$ret + ble/color/face2sgr syntax_comment; sgrc=$ret + ble/color/face2sgr argument_option; sgro=$ret + sgr0=$_ble_term_sgr0 + fi + local keymap + ble-decode/INITIALIZE_DEFMAP -v keymap # 初期化を強制する + if (($#)); then + for keymap; do + ble/decode/keymap#print "$keymap" + done + else + ble-decode-char/csi/print + ble-decode-char/print + ble/decode/keymap#print + fi +} +function ble-bind { + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_local_adjust" + ble/decode/bind "$@" + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_local_return" +} +function ble/decode/bind { + local set shopt + [[ $_ble_bash_options_adjusted ]] || ble/base/.adjust-bash-options set shopt + local IFS=$_ble_term_IFS q=\' Q="''\'" + local flags= kmap=${ble_bind_keymap-} ret + local -a keymaps; keymaps=() + ble/decode/initialize + local -a args + args=("$@") + local iarg=0 arg c optarg + while ((iarg<$#)); do + local arg=${args[iarg++]} + if [[ $arg == --?* ]]; then + local name=${arg:2} has_optarg= optarg= + if [[ $name == *=* ]]; then + has_optarg=set + optarg=${name#*=} + name=${name%%=*} + fi + case $name in + (color) + if [[ ! $has_optarg || $optarg == always ]]; then + flags=c${flags//[cn]} + elif [[ $optarg == never ]]; then + flags=n${flags//[cn]} + elif [[ $optarg == auto ]]; then + flags=${flags//[cn]} + else + flags=E$flags + ble/util/print "ble-bind: unrecognized color '--color=$optarg'." >&2 + fi ;; + (help) + ble/decode/bind/option:help + flags=D$flags ;; + (csi) + flags=D$flags + ble/decode/bind/get-optarg --csi 2 "$has_optarg" "$optarg" || break + ble/decode/bind/option:csi "${optarg[0]}" "${optarg[1]}" ;; + (cursor) + flags=D$flags + ble/decode/bind/get-optarg --cursor 1 "$has_optarg" "$optarg" || break + ble/decode/bind/.initialize-kmap && + ble/decode/keymap#set-cursor "$kmap" "${optarg[0]}" ;; + (list-widgets|list-functions) + flags=D$flags + ble/decode/bind/option:list-widgets ;; + (dump) + flags=D$flags + ble/decode/bind/option:dump "${keymaps[@]}" ;; + (print) + flags=D$flags + ble/decode/bind/option:print "${keymaps[@]}" ;; + (*) + flags=E$flags + ble/util/print "ble-bind: unrecognized long option $arg" >&2 ;; + esac + elif [[ $arg == -?* ]]; then + arg=${arg:1} + while ((${#arg})); do + c=${arg::1} arg=${arg:1} + case $c in + (k) + flags=D$flags + ble/decode/bind/get-optarg -k 2 "$arg" || break 2 + arg= + ble-decode-kbd "${optarg[0]}"; local cseq=$ret + if [[ ${optarg[1]} && ${optarg[1]} != - ]]; then + ble-decode-kbd "${optarg[1]}"; local kc=$ret + ble-decode-char/bind "$cseq" "$kc" + else + ble-decode-char/unbind "$cseq" + fi ;; + (m) + ble/decode/bind/get-optarg -m 1 "$arg" || break 2 + arg= + if ! ble/decode/is-keymap "$optarg"; then + ble/util/print "ble-bind: the keymap '$optarg' is unknown." >&2 + flags=E$flags + continue + fi + kmap=$optarg + ble/array#push keymaps "$optarg" ;; + (D) + flags=D$flags + ble/decode/bind/option:dump "${keymaps[@]}" ;; + ([Pd]) + flags=D$flags + ble/decode/bind/option:print "${keymaps[@]}" ;; + (['fxc@s']) + flags=D$flags + [[ $c != f && $arg == f* ]] && arg=${arg:1} + ble/decode/bind/get-optarg "-$c" 2 "$arg" || break 2 + arg= + ble-decode-kbd "${optarg[0]}"; local kbd=$ret + if [[ ${optarg[1]} && ${optarg[1]} != - ]]; then + local command=${optarg[1]} + case $c in + (f) command=ble/widget/$command ;; # ble/widget/ 関数 + (x) command="ble/widget/.EDIT_COMMAND '${command//$q/$Q}'" ;; # 編集用の関数 + (c) command="ble/widget/.SHELL_COMMAND '${command//$q/$Q}'" ;; # コマンド実行 + (s) local ret; ble/util/keyseq2chars "$command"; command="ble/widget/.MACRO ${ret[*]}" ;; + ('@') ;; # 直接実行 + (*) + ble/util/print "error: unsupported binding type \`-$c'." >&2 + continue ;; + esac + ble/decode/bind/.initialize-kmap && + ble-decode-key/bind "$kmap" "$kbd" "$command" + else + ble/decode/bind/.initialize-kmap && + ble-decode-key/unbind "$kmap" "$kbd" + fi ;; + (T) + flags=D$flags + ble/decode/bind/get-optarg -T 2 "$arg" || break 2 + arg= + ble-decode-kbd "${optarg[0]}"; local kbd=$ret + ble/decode/bind/.initialize-kmap && + ble-decode-key/set-timeout "$kmap" "$kbd" "${optarg[1]}" ;; + (L) + flags=D$flags + ble/decode/bind/option:list-widgets ;; + (*) + ble/util/print "ble-bind: unrecognized short option \`-$c'." >&2 + flags=E$flags ;; + esac + done + else + ble/util/print "ble-bind: unrecognized argument \`$arg'." >&2 + flags=E$flags + fi + done + local ext=0 + case $flags in + (*E*) ext=2 ;; + (*R*) ext=1 ;; + (*D*) ;; + (*) ble/decode/bind/option:print "${keymaps[@]}" ;; + esac + [[ $_ble_bash_options_adjusted ]] || ble/base/.restore-bash-options set shopt + return "$ext" +} +function ble/decode/read-inputrc/test { + local text=$1 + if [[ ! $text ]]; then + ble/util/print "ble.sh (bind):\$if: test condition is not supplied." >&2 + return 1 + elif local rex=$'[ \t]*([<>]=?|[=!]?=)[ \t]*(.*)$'; [[ $text =~ $rex ]]; then + local op=${BASH_REMATCH[1]} + local rhs=${BASH_REMATCH[2]} + local lhs=${text::${#text}-${#BASH_REMATCH}} + else + local lhs=application + local rhs=$text + fi + case $lhs in + (application) + local ret; ble/string#tolower "$rhs" + [[ $ret == bash || $ret == blesh ]] + return "$?" ;; + (mode) + if [[ -o emacs ]]; then + builtin test emacs "$op" "$rhs" + elif [[ -o vi ]]; then + builtin test vi "$op" "$rhs" + else + false + fi + return "$?" ;; + (term) + if [[ $op == '!=' ]]; then + builtin test "$TERM" "$op" "$rhs" && builtin test "${TERM%%-*}" "$op" "$rhs" + else + builtin test "$TERM" "$op" "$rhs" || builtin test "${TERM%%-*}" "$op" "$rhs" + fi + return "$?" ;; + (version) + local lhs_major lhs_minor + if ((_ble_bash<40400)); then + ((lhs_major=2+_ble_bash/10000, + lhs_minor=_ble_bash/100%100)) + elif ((_ble_bash<50000)); then + ((lhs_major=7,lhs_minor=0)) + else + ((lhs_major=3+_ble_bash/10000, + lhs_minor=_ble_bash/100%100)) + fi + local rhs_major rhs_minor + if [[ $rhs == *.* ]]; then + local version + ble/string#split version . "$rhs" + rhs_major=${version[0]} + rhs_minor=${version[1]} + else + ((rhs_major=rhs,rhs_minor=0)) + fi + local lhs_ver=$((lhs_major*10000+lhs_minor)) + local rhs_ver=$((rhs_major*10000+rhs_minor)) + [[ $op == '=' ]] && op='==' + let "$lhs_ver$op$rhs_ver" + return "$?" ;; + (*) + if local ret; ble/util/rlvar#read "$lhs"; then + builtin test "$ret" "$op" "$rhs" + return "$?" + else + ble/util/print "ble.sh (bind):\$if: unknown readline variable '${lhs//$q/$Q}'." >&2 + return 1 + fi ;; + esac +} +function ble/decode/read-inputrc { + local file=$1 ref=$2 q=\' Q="''\'" + if [[ -f $ref && $ref == */* && $file != /* ]]; then + local relative_file=${ref%/*}/$file + [[ -f $relative_file ]] && file=$relative_file + fi + if [[ ! -f $file ]]; then + ble/util/print "ble.sh (bind):\$include: the file '${1//$q/$Q}' not found." >&2 + return 1 + fi + local -a script=() + local ret line= iline=0 + while ble/bash/read line || [[ $line ]]; do + ((++iline)) + ble/string#trim "$line"; line=$ret + [[ ! $line || $line == '#'* ]] && continue + if [[ $line == '$'* ]]; then + local directive=${line%%[$IFS]*} + case $directive in + ('$if') + local args=${line#'$if'} + ble/string#trim "$args"; args=$ret + ble/array#push script "if ble/decode/read-inputrc/test '${args//$q/$Q}'; then :" ;; + ('$else') ble/array#push script 'else :' ;; + ('$endif') ble/array#push script 'fi' ;; + ('$include') + local args=${line#'$include'} + ble/string#trim "$args"; args=$ret + ble/array#push script "ble/decode/read-inputrc '${args//$q/$Q}' '${file//$q/$Q}'" ;; + (*) + ble/util/print "ble.sh (bind):$file:$iline: unrecognized directive '$directive'." >&2 ;; + esac + else + ble/array#push script "ble/builtin/bind/.process -- '${line//$q/$Q}'" + fi + done < "$file" + IFS=$'\n' builtin eval 'script="${script[*]}"' + builtin eval -- "$script" +} +_ble_builtin_bind_keymap= +function ble/builtin/bind/set-keymap { + local opt_keymap= flags= + ble/builtin/bind/option:m "$1" && + _ble_builtin_bind_keymap=$opt_keymap + return 0 +} +function ble/builtin/bind/option:m { + local name=$1 + local ret; ble/string#tolower "$name"; local keymap=$ret + case $keymap in + (emacs|emacs-standard|emacs-meta|emacs-ctlx) ;; + (vi|vi-command|vi-move|vi-insert) ;; + (*) keymap= ;; + esac + if [[ ! $keymap ]]; then + ble/util/print "ble.sh (bind): unrecognized keymap name '$name'" >&2 + flags=e$flags + return 1 + else + opt_keymap=$keymap + return 0 + fi +} +function ble/builtin/bind/.unquote-macro-string { + local value=$1 q=\' Q="'\''" + local delim=${1::1} + if [[ $delim != [\"\'] ]]; then + ret=$value + fi + local rex='^'$delim'(([^\'$delim']|\\.)*)'$delim'['$_ble_term_IFS']*' + if ! [[ $value =~ $rex ]]; then + ble/util/print "ble.sh (bind): no closing '${delim//$q/$Q}' in spec: '${spec//$q/$Q}'" >&2 + return 1 + elif ((${#BASH_REMATCH}<${#value})); then + local fragment=${value:${#BASH_REMATCH}} + ble/util/print "ble.sh (bind): warning: unprocessed fragments '${fragment//$q/$Q}' in spec: '${spec//$q/$Q}'" >&2 + fi + ret=${BASH_REMATCH[1]} +} +function ble/builtin/bind/.decompose-pair.impl { + local LC_ALL= LC_CTYPE=C + local ret; ble/string#ltrim "$1" + local spec=$ret ifs=$_ble_term_IFS q=\' Q="'\''" + keyseq= value= + [[ ! $spec || $spec == 'set'["$ifs"]* ]] && return 3 + local rex_keyseq='^(("([^\"]|\\.)*"|[^":'$ifs'])*("([^\"]|\\.)*)?)' + if [[ :$2: == *:user-command:* ]]; then + if ! ble/string#match "$spec" "$rex_keyseq[$ifs]*[:$ifs]"; then + ble/util/print "ble.sh (bind): no colon or space after keyseq: '${spec//$q/$Q}'" >&3 + return 1 + fi + local rematch=$BASH_REMATCH + keyseq=${BASH_REMATCH[1]} + ble/string#ltrim "${spec:${#BASH_REMATCH}}" + if [[ $rematch == *: ]]; then + if [[ $ret == [\"\']* ]]; then + ble/builtin/bind/.unquote-macro-string "$ret" 2>&3 || return 1 + fi + else + if [[ $ret == \"* ]]; then + ble/builtin/bind/.unquote-macro-string "$ret" 2>&3 || return 1 + ble/util/keyseq2chars "$ret" + ble/util/chars2s "${ret[@]}" + else + ble/util/print "ble.sh (bind): the user command needs to be surrounded by \"..\": '${spec//$q/$Q}'" >&3 + return 1 + fi + fi + value=command:$ret + else + ble/string#match "$spec" "$rex_keyseq[$ifs]*(:[$ifs]*)?" + keyseq=${BASH_REMATCH[1]} + ble/string#trim "${spec:${#BASH_REMATCH}}" + if [[ $ret == [\"\']* ]]; then + ble/builtin/bind/.unquote-macro-string "$ret" 2>&3 || return 1 + value=macro:$ret + else + value=rlfunc:$ret + fi + fi + if [[ $keyseq == '$'* ]]; then + return 3 + elif [[ ! $keyseq ]]; then + ble/util/print "ble.sh (bind): empty keyseq in spec: '${spec//$q/$Q}'" >&3 + return 1 + elif ble/string#match "$keyseq" '^"([^\"]|\\.)*$'; then + ble/util/print "ble.sh (bind): no closing '\"' in keyseq: '${keyseq//$q/$Q}'" >&3 + return 1 + elif ble/string#match "$keyseq" '^"([^\"]|\\.)*"'; then + local rematch=${BASH_REMATCH[0]} + if ((${#rematch}<${#keyseq})); then + local fragment=${keyseq:${#rematch}} + ble/util/print "ble.sh (bind): warning: unprocessed fragments in keyseq '${fragment//$q/$Q}'" >&3 + fi + keyseq=$rematch + return 0 + else + return 0 + fi +} +function ble/builtin/bind/.decompose-pair { + ble/builtin/bind/.decompose-pair.impl "$@" 3>&2 2>/dev/null # suppress locale error #D1440 +} +function ble/builtin/bind/.parse-keyname { + local ret mflags= + ble/string#tolower "$1"; local lower=$ret + if [[ $1 == *-* ]]; then + ble/string#split ret - "$lower" + local mod + for mod in "${ret[@]::${#ret[@]}-1}"; do + case $mod in + (*m|*meta) mflags=m$mflags ;; + (*c|*ctrl|*control) mflags=c$mflags ;; + esac + done + fi + local name=${lower##*-} ch= + case $name in + (rubout|del) ch=$'\177' ;; + (escape|esc) ch=$'\033' ;; + (newline|lfd) ch=$'\n' ;; + (return|ret) ch=$'\r' ;; + (space|spc) ch=' ' ;; + (tab) ch=$'\t' ;; + (*) ble/util/substr "${1##*-}" 0 1; ch=$ret ;; + esac + ble/util/s2c "$ch"; local key=$ret + [[ $mflags == *c* ]] && ((key&=0x1F)) + [[ $mflags == *m* ]] && ((key|=0x80)) + chars=("$key") +} +function ble/builtin/bind/.initialize-kmap { + local keymap=$1 + kmap= + case $keymap in + (emacs|emacs-standard) kmap=emacs ;; + (emacs-ctlx) kmap=emacs; keys=(24 "${keys[@]}") ;; + (emacs-meta) kmap=emacs; keys=(27 "${keys[@]}") ;; + (vi-insert) kmap=vi_imap ;; + (vi|vi-command|vi-move) kmap=vi_nmap ;; + (*) ble-decode/GET_BASEMAP -v kmap ;; + esac + if ! ble/decode/is-keymap "$kmap"; then + ble/util/print "ble/builtin/bind: the keymap '$kmap' is unknown." >&2 + return 1 + fi + return 0 +} +function ble/builtin/bind/.initialize-keys-and-value { + local spec=$1 opts=$2 + keys= value= + local keyseq + ble/builtin/bind/.decompose-pair "$spec" "$opts" || return "$?" + local chars + if [[ $keyseq == \"*\" ]]; then + local ret; ble/util/keyseq2chars "${keyseq:1:${#keyseq}-2}" + chars=("${ret[@]}") + ((${#chars[@]})) || ble/util/print "ble.sh (bind): warning: empty keyseq" >&2 + else + [[ :$opts: == *:nokeyname:* ]] && + ble/util/print "ble.sh (bind): warning: readline \"bind -x\" does not support \"keyname\" spec" >&2 + ble/builtin/bind/.parse-keyname "$keyseq" + fi + ble/decode/cmap/decode-chars "${chars[@]}" +} +function ble/builtin/bind/option:x { + local q=\' Q="''\'" + local keys value kmap + if ! ble/builtin/bind/.initialize-keys-and-value "$1" nokeyname:user-command; then + ble/util/print "ble.sh (bind): unrecognized user-command spec '${1//$q/$Q}'." >&2 + flags=e$flags + return 1 + elif ! ble/builtin/bind/.initialize-kmap "$opt_keymap"; then + ble/util/print "ble.sh (bind): sorry, failed to initialize keymap:'$opt_keymap'." >&2 + flags=e$flags + return 1 + fi + value=${value#command:} + local command="ble/widget/.EDIT_COMMAND '${value//$q/$Q}'" + ble-decode-key/bind "$kmap" "${keys[*]}" "$command" +} +function ble/builtin/bind/option:r { + local keyseq=$1 + local ret chars keys + ble/util/keyseq2chars "$keyseq"; chars=("${ret[@]}") + ble/decode/cmap/decode-chars "${chars[@]}" + local kmap + ble/builtin/bind/.initialize-kmap "$opt_keymap" || return 1 + ble-decode-key/unbind "$kmap" "${keys[*]}" +} +_ble_decode_rlfunc2widget_emacs=() +_ble_decode_rlfunc2widget_vi_imap=() +_ble_decode_rlfunc2widget_vi_nmap=() +function ble/builtin/bind/rlfunc2widget { + local kmap=$1 rlfunc=$2 + local IFS=$_ble_term_IFS + local rlfunc_file= rlfunc_dict= + case $kmap in + (emacs) rlfunc_file=$_ble_base/lib/core-decode.emacs-rlfunc.txt + rlfunc_dict=_ble_decode_rlfunc2widget_emacs ;; + (vi_imap) rlfunc_file=$_ble_base/lib/core-decode.vi_imap-rlfunc.txt + rlfunc_dict=_ble_decode_rlfunc2widget_vi_imap ;; + (vi_nmap) rlfunc_file=$_ble_base/lib/core-decode.vi_nmap-rlfunc.txt + rlfunc_dict=_ble_decode_rlfunc2widget_vi_nmap ;; + esac + if [[ $rlfunc_file ]]; then + local dict script=' + ((${#NAME[@]})) || + ble/util/mapfile NAME < "$rlfunc_file" + dict=("${NAME[@]}") + '; builtin eval -- "${script//NAME/$rlfunc_dict}" + local line + for line in "${dict[@]}"; do + [[ $line == "$rlfunc "* ]] || continue + [[ $OSTYPE == msys* ]] && line=${line%$'\r'} + local rl widget; ble/bash/read rl widget <<< "$line" + if [[ $widget == - ]]; then + ble/util/print "ble.sh (bind): unsupported readline function '${rlfunc//$q/$Q}' for keymap '$kmap'." >&2 + return 1 + elif [[ $widget == '' ]]; then + return 2 + fi + ret=ble/widget/$widget + return 0 + done + fi + if ble/is-function ble/widget/"${rlfunc%%[$IFS]*}"; then + ret=ble/widget/$rlfunc + return 0 + fi + ble/util/print "ble.sh (bind): unsupported readline function '${rlfunc//$q/$Q}'." >&2 + return 1 +} +function ble/builtin/bind/option:u { + local rlfunc=$1 + local kmap + if ! ble/builtin/bind/.initialize-kmap "$opt_keymap" || ! ble/decode/keymap#load "$kmap"; then + ble/util/print "ble.sh (bind): sorry, failed to initialize keymap:'$opt_keymap'." >&2 + flags=e$flags + return 1 + fi + local ret + ble/builtin/bind/rlfunc2widget "$kmap" "$rlfunc" || return 0 + local command=$ret + local -a unbind_keys_list=() + ble/builtin/bind/option:u/search-recursive "$kmap" + local keys + for keys in "${unbind_keys_list[@]}"; do + ble-decode-key/unbind "$kmap" "$keys" + done +} +function ble/builtin/bind/option:u/search-recursive { + local kmap=$1 tseq=$2 + local dicthead=_ble_decode_${kmap}_kmap_ + local key keys + builtin eval "keys=(\${!$dicthead$tseq[@]})" + for key in "${keys[@]}"; do + builtin eval "local ent=\${$dicthead$tseq[key]}" + if [[ ${ent:2} == "$command" ]]; then + ble/array#push unbind_keys_list "${tseq//_/ } $key" + fi + if [[ ${ent::1} == _ ]]; then + ble/builtin/bind/option:u/search-recursive "$kmap" "${tseq}_$key" + fi + done +} +function ble/builtin/bind/option:- { + local ret; ble/string#trim "$1"; local arg=$ret + [[ ! $arg || $arg == '#'* ]] && return 0 + local ifs=$_ble_term_IFS + if [[ $arg == 'set'["$ifs"]* ]]; then + if [[ $_ble_decode_bind_state != none ]]; then + local variable= value= rex=$'^set[ \t]+([^ \t]+)[ \t]+([^ \t].*)$' + [[ $arg =~ $rex ]] && variable=${BASH_REMATCH[1]} value=${BASH_REMATCH[2]} + case $variable in + (keymap) + ble/builtin/bind/set-keymap "$value" + return 0 ;; + (editing-mode) + _ble_builtin_bind_keymap= ;; + esac + ble/function#try ble/builtin/bind/set:"$variable" "$value" && return 0 + builtin bind "$arg" + fi + return 0 + fi + local keys value kmap + if ! ble/builtin/bind/.initialize-keys-and-value "$arg"; then + local q=\' Q="''\'" + ble/util/print "ble.sh (bind): unrecognized readline command '${arg//$q/$Q}'." >&2 + flags=e$flags + return 1 + elif ! ble/builtin/bind/.initialize-kmap "$opt_keymap"; then + ble/util/print "ble.sh (bind): sorry, failed to initialize keymap:'$opt_keymap'." >&2 + flags=e$flags + return 1 + fi + if [[ $value == macro:* ]]; then + value=${value#macro:} + local bind_keys="${keys[*]}" + local ret chars; ble/util/keyseq2chars "$value"; chars=("${ret[@]}") + local command="ble/widget/.MACRO ${chars[*]}" + ble/decode/cmap/decode-chars "${chars[@]}" + [[ ${keys[*]} != "$bind_keys" ]] && + ble-decode-key/bind "$kmap" "$bind_keys" "$command" + elif [[ $value == rlfunc:?* ]]; then + value=${value#rlfunc:} + local ret; ble/builtin/bind/rlfunc2widget "$kmap" "$value"; local ext=$? + if ((ext==0)); then + local command=$ret + ble-decode-key/bind "$kmap" "${keys[*]}" "$command" + return 0 + elif ((ext==2)); then + return 0 + else + flags=e$flags + return 1 + fi + else + ble/util/print "ble.sh (bind): readline function name is not specified ($arg)." >&2 + return 1 + fi +} +function ble/builtin/bind/.process { + flags= + local IFS=$_ble_term_IFS + local opt_literal= opt_keymap=$_ble_builtin_bind_keymap opt_print= + local -a opt_queries=() + while (($#)); do + local arg=$1; shift + if [[ ! $opt_literal ]]; then + case $arg in + (--) opt_literal=1 + continue ;; + (--help) + if ((_ble_bash<40400)); then + ble/util/print "ble.sh (bind): unrecognized option $arg" >&2 + flags=e$flags + else + [[ $_ble_decode_bind_state != none ]] && + (builtin bind --help) + flags=h$flags + fi + continue ;; + (--*) + ble/util/print "ble.sh (bind): unrecognized option $arg" >&2 + flags=e$flags + continue ;; + (-*) + arg=${arg:1} + while [[ $arg ]]; do + local c=${arg::1} + arg=${arg:1} + case $c in + ([lpPsSvVX]) + opt_print=$opt_print$c ;; + ([mqurfx]) + local optarg=$arg + arg= + if [[ ! $optarg ]]; then + if (($#==0)); then + ble/util/print "ble.sh (bind): missing option argument for -$c" >&2 + flags=e$flags + break + fi + optarg=$1; shift + fi + case $c in + (m) ble/builtin/bind/option:m "$optarg" ;; + (x) ble/builtin/bind/option:x "$optarg" ;; + (r) ble/builtin/bind/option:r "$optarg" ;; + (u) ble/builtin/bind/option:u "$optarg" ;; + (q) ble/array#push opt_queries "$optarg" ;; + (f) ble/decode/read-inputrc "$optarg" ;; + (*) + ble/util/print "ble.sh (bind): unsupported option -$c $optarg" >&2 + flags=e$flags ;; + esac ;; + (*) + ble/util/print "ble.sh (bind): unrecognized option -$c" >&2 + flags=e$flags ;; + esac + done + continue ;; + esac + fi + ble/builtin/bind/option:- "$arg" + opt_literal=1 + done + if [[ $_ble_decode_bind_state != none ]]; then + if [[ $opt_print == *[pPsSX]* ]] || ((${#opt_queries[@]})); then + ( ble/decode/readline/unbind + [[ -s "$_ble_base_run/$$.bind.save" ]] && + source "$_ble_base_run/$$.bind.save" + [[ $opt_print ]] && + builtin bind ${opt_keymap:+-m $opt_keymap} -$opt_print + declare rlfunc + for rlfunc in "${opt_queries[@]}"; do + builtin bind ${opt_keymap:+-m $opt_keymap} -q "$rlfunc" + done ) + elif [[ $opt_print ]]; then + builtin bind ${opt_keymap:+-m $opt_keymap} -$opt_print + fi + fi + return 0 +} +_ble_builtin_bind_inputrc_done= +function ble/builtin/bind/initialize-inputrc { + [[ $_ble_builtin_bind_inputrc_done ]] && return 0 + _ble_builtin_bind_inputrc_done=1 + if [[ $1 == all ]]; then + local sys_inputrc=/etc/inputrc + [[ -e $sys_inputrc ]] && ble/decode/read-inputrc "$sys_inputrc" + fi + local inputrc=${INPUTRC:-$HOME/.inputrc} + [[ -e $inputrc ]] && ble/decode/read-inputrc "$inputrc" +} +_ble_builtin_bind_user_settings_loaded= +function ble/builtin/bind/read-user-settings/.collect { + local map + for map in vi-insert vi-command emacs; do + local cache=$_ble_base_cache/decode.readline.$_ble_bash.$map.txt + if ! [[ -s $cache && $cache -nt $_ble_base/ble.sh ]]; then + INPUTRC=/dev/null "$BASH" --noprofile --norc -i -c "builtin bind -m $map -p" 2>/dev/null | + LC_ALL= LC_CTYPE=C ble/bin/sed '/^#/d;s/"\\M-/"\\e/' >| "$cache.part" && + ble/bin/mv "$cache.part" "$cache" || continue + fi + local cache_content + ble/util/readfile cache_content "$cache" + ble/util/print __CLEAR__ + ble/util/print KEYMAP="$map" + ble/util/print __BIND0__ + ble/util/print "${cache_content%$_ble_term_nl}" + if ((_ble_bash>=40300)); then + ble/util/print __BINDX__ + builtin bind -m "$map" -X 2>/dev/null + fi + ble/util/print __BINDS__ + builtin bind -m "$map" -s 2>/dev/null + ble/util/print __BINDP__ + builtin bind -m "$map" -p 2>/dev/null + ble/util/print __PRINT__ + done +} +function ble/builtin/bind/read-user-settings/.reconstruct { + local collect q=\' + ble/util/assign collect ble/builtin/bind/read-user-settings/.collect + <<< "$collect" LC_ALL= LC_CTYPE=C ble/bin/awk -v q="$q" -v _ble_bash="$_ble_bash" ' + function keymap_register(key, val, type) { + if (!haskey[key]) { + keys[nkey++] = key; + haskey[key] = 1; + } + keymap[key] = val; + keymap_type[key] = type; + } + function keymap_clear(_, i, key) { + for(i = 0; i < nkey; i++) { + key = keys[i]; + delete keymap[key]; + delete keymap_type[key]; + delete keymap0[key]; + haskey[key] = 0; + } + nkey = 0; + } + function keymap_print(_, i, key, type, value, text, line) { + for (i = 0; i < nkey; i++) { + key = keys[i]; + type = keymap_type[key]; + value = keymap[key]; + if (type == "" && value == keymap0[key]) continue; + text = key ": " value; + gsub(/'$q'/, q "\\" q q, text); + line = "bind"; + if (KEYMAP != "") line = line " -m " KEYMAP; + if (type == "x") line = line " -x"; + line = line " " q text q; + print line; + } + } + /^__BIND0__$/ { mode = 0; next; } + /^__BINDX__$/ { mode = 1; next; } + /^__BINDS__$/ { mode = 2; next; } + /^__BINDP__$/ { mode = 3; next; } + /^__CLEAR__$/ { keymap_clear(); next; } + /^__PRINT__$/ { keymap_print(); next; } + sub(/^KEYMAP=/, "") { KEYMAP = $0; } + /(ble-decode\/.hook|_ble_decode_hook) / { next; } + function workaround_bashbug(keyseq, _, rex, out, unit) { + out = ""; + while (keyseq != "") { + if (mode == 0 || mode == 3) { + match(keyseq, /^\\C-\\(\\"$)?|^\\M-|^\\.|^./); + } else { + match(keyseq, /^\\[CM]-|^\\.|^./); + } + unit = substr(keyseq, 1, RLENGTH); + keyseq = substr(keyseq, 1 + RLENGTH); + if (unit == "\\C-\\") { + unit = unit "\\"; + } else if (unit == "\\M-") { + unit = "\\e"; + } + out = out unit; + } + return out; + } + function process_line(line, _, key, val) { + if (match(line, /^"(\\.|[^"])+": /)) { + key = substr(line, 1, RLENGTH - 2); + val = substr(line, 1 + RLENGTH); + } else if (mode == 1 && _ble_bash >= 50300 && match(line, /^"(\\.|[^"])+" /)) { + key = substr(line, 1, RLENGTH - 1); + val = substr(line, 1 + RLENGTH); + } else { + return 0; + } + if (_ble_bash < 50100) + key = workaround_bashbug(key); + if (mode) { + type = mode == 1 ? "x" : mode == 2 ? "s" : ""; + keymap_register(key, val, type); + } else { + keymap0[key] = val; + } + } + { process_line($0); } + ' 2>/dev/null # suppress LC_ALL error messages +} +function ble/builtin/bind/read-user-settings/.cache-enabled { + local keymap use_cache=1 + for keymap in emacs vi_imap vi_nmap; do + ble/decode/keymap#registered "$keymap" && return 1 + [[ -s $delay_prefix.$keymap ]] && return 1 + done + return 0 +} +function ble/builtin/bind/read-user-settings/.cache-alive { + [[ -e $cache_prefix.settings ]] || return 1 + [[ $cache_prefix.settings -nt $_ble_base/lib/init-cmap.sh ]] || return 1 + local keymap + for keymap in emacs vi_imap vi_nmap; do + [[ $cache_prefix.settings -nt $_ble_base/core-decode.$cache-rlfunc.txt ]] || return 1 + [[ -e $cache_prefix.$keymap ]] || return 1 + done + local content + ble/util/readfile content "$cache_prefix.settings" + [[ ${content%$'\n'} == "$settings" ]] +} +function ble/builtin/bind/read-user-settings/.cache-save { + local keymap content fail= + for keymap in emacs vi_imap vi_nmap; do + if [[ -s $delay_prefix.$keymap ]]; then + ble/util/copyfile "$delay_prefix.$keymap" "$cache_prefix.$keymap" + else + >| "$cache_prefix.$keymap" + fi || fail=1 + done + [[ $fail ]] && return 1 + ble/util/print "$settings" >| "$cache_prefix.settings" +} +function ble/builtin/bind/read-user-settings/.cache-load { + local keymap + for keymap in emacs vi_imap vi_nmap; do + ble/util/copyfile "$cache_prefix.$keymap" "$delay_prefix.$keymap" + done +} +function ble/builtin/bind/read-user-settings { + if [[ $_ble_decode_bind_state == none ]]; then + [[ $_ble_builtin_bind_user_settings_loaded ]] && return 0 + _ble_builtin_bind_user_settings_loaded=1 + builtin bind 2>/dev/null + local settings + ble/util/assign settings ble/builtin/bind/read-user-settings/.reconstruct + [[ $settings ]] || return 0 + local cache_prefix=$_ble_base_cache/decode.inputrc.$_ble_decode_kbd_ver.$TERM + local delay_prefix=$_ble_base_run/$$.bind.delay + if ble/builtin/bind/read-user-settings/.cache-enabled; then + if ble/builtin/bind/read-user-settings/.cache-alive; then + ble/builtin/bind/read-user-settings/.cache-load + else + builtin eval -- "$settings" 2>/dev/null # suppress "line editing not enabled" + ble/builtin/bind/read-user-settings/.cache-save + fi + else + builtin eval -- "$settings" 2>/dev/null # suppress "line editing not enabled" + fi + fi +} +function ble/builtin/bind { + local set shopt; ble/base/.adjust-bash-options set shopt + [[ ! $_ble_attached || $_ble_edit_exec_inside_userspace ]] && + ble/base/adjust-BASH_REMATCH + ble/decode/initialize + local flags= ext=0 + ble/builtin/bind/.process "$@" + if [[ $_ble_decode_bind_state == none ]]; then + builtin bind "$@"; ext=$? + elif [[ $flags == *[eh]* ]]; then + [[ $flags == *e* ]] && + builtin bind --usage 2>&1 1>/dev/null | ble/bin/grep ^bind >&2 + ext=2 + fi + [[ ! $_ble_attached || $_ble_edit_exec_inside_userspace ]] && + ble/base/restore-BASH_REMATCH + ble/base/.restore-bash-options set shopt + return "$ext" +} +function bind { + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_local_adjust" + ble/builtin/bind "$@" + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_local_return" +} +function ble/decode/initialize/.has-broken-suse-inputrc { + local content= + [[ -s /etc/inputrc.keys && -r /etc/os-release ]] && + ble/util/readfile content /etc/os-release && + [[ $content == *'SUSE'* ]] || return 1 + return 0 +} +_ble_decode_initialized= +_ble_decode_initialize_inputrc=auto +function ble/decode/initialize { + [[ $_ble_decode_initialized ]] && return 0 + _ble_decode_initialized=1 + ble/decode/cmap/initialize + if [[ $_ble_decode_initialize_inputrc == auto ]]; then + if ble/decode/initialize/.has-broken-suse-inputrc; then + [[ ${INPUTRC-} == /etc/inputrc || ${INPUTRC-} == /etc/inputrc.keys ]] && + local INPUTRC=~/.inputrc + _ble_decode_initialize_inputrc=user + else + _ble_decode_initialize_inputrc=diff + fi + fi + case $_ble_decode_initialize_inputrc in + (all) + ble/builtin/bind/initialize-inputrc all ;; + (user) + ble/builtin/bind/initialize-inputrc ;; + (diff) + ble/builtin/bind/read-user-settings ;; + esac +} +function ble/decode/reset-default-keymap { + local old_base_keymap=${_ble_decode_keymap_stack[0]:-$_ble_decode_keymap} + ble-decode/INITIALIZE_DEFMAP -v _ble_decode_keymap # 0ms + _ble_decode_keymap_stack=() + if [[ $_ble_decode_keymap != "$old_base_keymap" ]]; then + [[ $old_base_keymap ]] && + _ble_decode_keymap=$old_base_keymap ble-decode/widget/.invoke-hook "$_ble_decode_KCODE_DETACH" + ble-decode/widget/.invoke-hook "$_ble_decode_KCODE_ATTACH" # 7ms for vi-mode + local cursor; ble/decode/keymap#get-cursor "$_ble_decode_keymap" + [[ $cursor ]] && ble/term/cursor-state/set-internal "$((cursor))" + fi +} +function ble/decode/attach { + if ble/decode/keymap#is-empty "$_ble_decode_keymap"; then + ble/util/print "ble.sh: The keymap '$_ble_decode_keymap' is empty." >&2 + return 1 + fi + [[ $_ble_decode_bind_state != none ]] && return 0 + ble/util/save-editing-mode _ble_decode_bind_state + [[ $_ble_decode_bind_state == none ]] && return 1 + ble/term/attach # 3ms + ble/util/reset-keymap-of-editing-mode + builtin eval -- "$(ble/decode/readline/.generate-source-to-unbind-default)" # 21ms + ble/decode/readline/bind # 20ms + return 0 +} +function ble/decode/detach { + [[ $_ble_decode_bind_state != none ]] || return 1 + local current_editing_mode= + ble/util/save-editing-mode current_editing_mode + [[ $_ble_decode_bind_state == "$current_editing_mode" ]] || ble/util/restore-editing-mode _ble_decode_bind_state + ble/term/detach + ble/decode/readline/unbind + if [[ -s "$_ble_base_run/$$.bind.save" ]]; then + source "$_ble_base_run/$$.bind.save" + >| "$_ble_base_run/$$.bind.save" + fi + [[ $_ble_decode_bind_state == "$current_editing_mode" ]] || ble/util/restore-editing-mode current_editing_mode + _ble_decode_bind_state=none +} +function ble/encoding:UTF-8/generate-binder { return 0; } +_ble_encoding_utf8_decode_mode=0 +_ble_encoding_utf8_decode_code=0 +_ble_encoding_utf8_decode_table=( + 'M&&E,A[i++]='{0..127} + 'C=C<<6|'{0..63}',--M==0&&(A[i++]=C)' + 'M&&E,C='{0..31}',M=1' + 'M&&E,C='{0..15}',M=2' + 'M&&E,C='{0..7}',M=3' + 'M&&E,C='{0..3}',M=4' + 'M&&E,C='{0..1}',M=5' + 'M&&E,A[i++]=_ble_decode_Erro|'{254,255} +) +function ble/encoding:UTF-8/clear { + _ble_encoding_utf8_decode_mode=0 + _ble_encoding_utf8_decode_code=0 +} +function ble/encoding:UTF-8/is-intermediate { + ((_ble_encoding_utf8_decode_mode)) +} +function ble/encoding:UTF-8/decode { + local C=$_ble_encoding_utf8_decode_code + local M=$_ble_encoding_utf8_decode_mode + local E='M=0,A[i++]=_ble_decode_Erro|C' + local -a A=() + local i=0 b + for b; do + ((_ble_encoding_utf8_decode_table[b&255])) + done + _ble_encoding_utf8_decode_code=$C + _ble_encoding_utf8_decode_mode=$M + ((i)) && ble-decode-char "${A[@]}" +} +function ble/encoding:UTF-8/c2bc { + local code=$1 + ((ret=code<0x80?1: + (code<0x800?2: + (code<0x10000?3: + (code<0x200000?4:5))))) +} +function ble/encoding:C/generate-binder { + ble/init:bind/bind-s '"\C-@":"\x9B\x80"' + ble/init:bind/bind-s '"\e":"\x9B\x8B"' # isolated ESC (U+07FC) に後で変換 + local i ret + for i in {0..255}; do + ble/decode/c2dqs "$i" + ble/init:bind/bind-s "\"\e$ret\": \"\x9B\x9B$ret\"" + done +} +_ble_encoding_c_csi= +function ble/encoding:C/clear { + _ble_encoding_c_csi= +} +function ble/encoding:C/is-intermediate { + [[ $_ble_encoding_c_csi ]] +} +function ble/encoding:C/decode { + local -a A=() + local i=0 b + for b; do + if [[ $_ble_encoding_c_csi ]]; then + _ble_encoding_c_csi= + case $b in + (155) A[i++]=27 # ESC + continue ;; + (139) A[i++]=2044 # isolated ESC U+07FC + continue ;; + (128) A[i++]=0 # C-@ + continue ;; + esac + A[i++]=155 + fi + if ((b==155)); then + _ble_encoding_c_csi=1 + else + A[i++]=$b + fi + done + ((i)) && ble-decode-char "${A[@]}" +} +function ble/encoding:C/c2bc { + ret=1 +} +_ble_color_gflags_Bold=0x01 +_ble_color_gflags_Italic=0x02 +_ble_color_gflags_Underline=0x04 +_ble_color_gflags_Revert=0x08 +_ble_color_gflags_Invisible=0x10 +_ble_color_gflags_Strike=0x20 +_ble_color_gflags_Blink=0x40 +_ble_color_gflags_DecorationMask=0x77 +_ble_color_gflags_FgMask=0x00000000FFFFFF00 +_ble_color_gflags_BgMask=0x00FFFFFF00000000 +_ble_color_gflags_FgShift=8 +_ble_color_gflags_BgShift=32 +_ble_color_gflags_FgIndexed=0x0100000000000000 +_ble_color_gflags_BgIndexed=0x0200000000000000 +_ble_color_index_colors_default=$_ble_term_colors +if [[ $TERM == xterm* || $TERM == *-256color || $TERM == kterm* ]]; then + _ble_color_index_colors_default=256 +elif [[ $TERM == *-88color ]]; then + _ble_color_index_colors_default=88 +fi +bleopt/declare -v term_true_colors semicolon +bleopt/declare -v term_index_colors auto +function bleopt/check:term_true_colors { + ble/color/g2sgr/.clear-cache + return 0 +} +function bleopt/check:term_index_colors { + ble/color/g2sgr/.clear-cache + return 0 +} +function ble/color/initialize-term-colors { + local fields + ble/string#split fields \; "$_ble_term_DA2R" + if [[ $bleopt_term_true_colors == auto ]]; then + local value= + if [[ $TERM == *-24bit || $TERM == *-direct ]]; then + value=colon + elif [[ $TERM == *-24bits || $TERM == *-truecolor || $COLORTERM == *24bit* || $COLORTERM == *truecolor* ]]; then + value=semicolon + else + case ${fields[0]} in + (83) # screen (truecolor on にしている必要がある。判定方法は不明) + if ((fields[1]>=49900)); then + value=semicolon + fi ;; + (67) + if ((fields[1]>=100000)); then + : # cygwin terminal + else + value=colon + fi ;; + esac + fi + [[ $value ]] && + bleopt term_true_colors="$value" + fi +} +blehook term_DA2R!=ble/color/initialize-term-colors +function ble/color/palette/.print-indexed-colors { + local cols=$(((${COLUMNS:-80}-1)/4)) + ((cols<1?(cols=1):(cols>16&&(cols=16)))) + local bg bg0 bgN ret gflags=$((_ble_color_gflags_BgIndexed|_ble_color_gflags_FgIndexed)) + for ((bg0=0;bg0<256;bg0+=cols)); do + ((bgN=bg0+cols,bgN<256||(bgN=256))) + for ((bg=bg0;bg=12?3+p:p)) + for ((B=0;B<6;B++)); do + ((bg=16+R*36+G*6+B)) + ble/color/g2sgr "$((gflags|bg<<_ble_color_gflags_BgShift|(l%2?15:0)<<_ble_color_gflags_FgShift))" + printf '%s%03d ' "$ret" "$bg" + done + if ((p+1<3)); then + printf '%s ' "$_ble_term_sgr0" + else + printf '%s\n' "$_ble_term_sgr0" + fi + done + done + local l c K + for ((l=0;l<4;l++)); do + for ((c=0;c<12;c++)); do + ((K=l/2*12+c)) + ((bg=232+K)) + ble/color/g2sgr "$((gflags|bg<<_ble_color_gflags_BgShift|(l%2?15:0)<<_ble_color_gflags_FgShift))" + printf '%s%03d ' "$ret" "$bg" + done + printf '%s\n' "$_ble_term_sgr0" + done + return 0 +} +function ble-color-show { + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_local_adjust" + if (($#)); then + ble/base/print-usage-for-no-argument-command 'Update and reload ble.sh.' "$@" + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_local_leave" + return 2 + fi + ble/color/palette/.print-indexed-colors + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_local_return" +} +function ble-palette { + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_local_adjust" + if (($#)); then + ble/base/print-usage-for-no-argument-command 'Update and reload ble.sh.' "$@" + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_local_leave" + return 2 + fi + if ((${COLUMNS:-80}<80)); then + ble/color/palette/.print-indexed-colors + else + ble/color/palette/.print-xterm-256color + fi + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_local_return" +} +_ble_color_g2sgr_version=0 +_ble_color_g2sgr=() +_ble_color_g2sgr_ansi=() +function ble/color/g2sgr/.impl { + local g=$(($1)) + local sgr=0 + ((g&_ble_color_gflags_Bold)) && sgr="$sgr;${_ble_term_sgr_bold:-1}" + ((g&_ble_color_gflags_Italic)) && sgr="$sgr;${_ble_term_sgr_sitm:-3}" + ((g&_ble_color_gflags_Underline)) && sgr="$sgr;${_ble_term_sgr_smul:-4}" + ((g&_ble_color_gflags_Blink)) && sgr="$sgr;${_ble_term_sgr_blink:-5}" + ((g&_ble_color_gflags_Revert)) && sgr="$sgr;${_ble_term_sgr_rev:-7}" + ((g&_ble_color_gflags_Invisible)) && sgr="$sgr;${_ble_term_sgr_invis:-8}" + ((g&_ble_color_gflags_Strike)) && sgr="$sgr;${_ble_term_sgr_strike:-9}" + if ((g&_ble_color_gflags_FgIndexed)); then + local fg=$((g>>8&0xFF)) + ble/color/.color2sgrfg "$fg" + sgr="$sgr;$ret" + elif ((g&_ble_color_gflags_FgMask)); then + local rgb=$((1<<24|g>>8&0xFFFFFF)) + ble/color/.color2sgrfg "$rgb" + sgr="$sgr;$ret" + fi + if ((g&_ble_color_gflags_BgIndexed)); then + local bg=$((g>>32&0xFF)) + ble/color/.color2sgrbg "$bg" + sgr="$sgr;$ret" + elif ((g&_ble_color_gflags_BgMask)); then + local rgb=$((1<<24|g>>32&0xFFFFFF)) + ble/color/.color2sgrbg "$rgb" + sgr="$sgr;$ret" + fi + ret=$'\e['$sgr'm' + _ble_color_g2sgr[$1]=$ret +} +function ble/color/g2sgr/.clear-cache { + _ble_color_g2sgr=() + ((_ble_color_g2sgr_version++)) +} +function ble/color/g2sgr { + ret=${_ble_color_g2sgr[$1]} + [[ $ret ]] || ble/color/g2sgr/.impl "$1" +} +function ble/color/g2sgr-ansi/.impl { + local g=$(($1)) + local sgr=0 + ((g&_ble_color_gflags_Bold)) && sgr="$sgr;1" + ((g&_ble_color_gflags_Italic)) && sgr="$sgr;3" + ((g&_ble_color_gflags_Underline)) && sgr="$sgr;4" + ((g&_ble_color_gflags_Blink)) && sgr="$sgr;5" + ((g&_ble_color_gflags_Revert)) && sgr="$sgr;7" + ((g&_ble_color_gflags_Invisible)) && sgr="$sgr;8" + ((g&_ble_color_gflags_Strike)) && sgr="$sgr;9" + if ((g&_ble_color_gflags_FgIndexed)); then + local fg=$((g>>8&0xFF)) + sgr="$sgr;38:5:$fg" + elif ((g&_ble_color_gflags_FgMask)); then + local rgb=$((1<<24|g>>8&0xFFFFFF)) + local R=$((rgb>>16&0xFF)) G=$((rgb>>8&0xFF)) B=$((rgb&0xFF)) + sgr="$sgr;38:2::$R:$G:$B" + fi + if ((g&_ble_color_gflags_BgIndexed)); then + local bg=$((g>>32&0xFF)) + sgr="$sgr;48:5:$bg" + elif ((g&_ble_color_gflags_BgMask)); then + local rgb=$((1<<24|g>>32&0xFFFFFF)) + local R=$((rgb>>16&0xFF)) G=$((rgb>>8&0xFF)) B=$((rgb&0xFF)) + sgr="$sgr;48:2::$R:$G:$B" + fi + ret=$'\e['$sgr'm' + _ble_color_g2sgr_ansi[$1]=$ret +} +function ble/color/g2sgr-ansi { + ret=${_ble_color_g2sgr_ansi[$1]} + [[ $ret ]] || ble/color/g2sgr-ansi/.impl "$1" +} +function ble/color/g#setfg-clear { + (($1&=~(_ble_color_gflags_FgIndexed|_ble_color_gflags_FgMask))) +} +function ble/color/g#setbg-clear { + (($1&=~(_ble_color_gflags_BgIndexed|_ble_color_gflags_BgMask))) +} +function ble/color/g#setfg-index { + local _ble_local_color=$2 + (($1=$1&~_ble_color_gflags_FgMask|_ble_color_gflags_FgIndexed|(_ble_local_color&0xFF)<<8)) # index color +} +function ble/color/g#setbg-index { + local _ble_local_color=$2 + (($1=$1&~_ble_color_gflags_BgMask|_ble_color_gflags_BgIndexed|(_ble_local_color&0xFF)<<32)) # index color +} +function ble/color/g#setfg-rgb { + local _ble_local_R=$2 + local _ble_local_G=$3 + local _ble_local_B=$4 + ((_ble_local_R&=0xFF,_ble_local_G&=0xFF,_ble_local_B&=0xFF)) + if ((_ble_local_R==0&&_ble_local_G==0&&_ble_local_B==0)); then + ble/color/g#setfg-index "$1" 16 + else + (($1=$1&~(_ble_color_gflags_FgIndexed|_ble_color_gflags_FgMask)|_ble_local_R<<24|_ble_local_G<<16|_ble_local_B<<8)) # true color + fi +} +function ble/color/g#setbg-rgb { + local _ble_local_R=$2 + local _ble_local_G=$3 + local _ble_local_B=$4 + ((_ble_local_R&=0xFF,_ble_local_G&=0xFF,_ble_local_B&=0xFF)) + if ((_ble_local_R==0&&_ble_local_G==0&&_ble_local_B==0)); then + ble/color/g#setbg-index "$1" 16 + else + (($1=$1&~(_ble_color_gflags_BgIndexed|_ble_color_gflags_BgMask)|_ble_local_R<<48|_ble_local_G<<40|_ble_local_B<<32)) # true color + fi +} +function ble/color/g#setfg-cmyk { + local _ble_local_C=$2 + local _ble_local_M=$3 + local _ble_local_Y=$4 + local _ble_local_K=${5:-0} + ((_ble_local_K=~_ble_local_K&0xFF, + _ble_local_C=(~_ble_local_C&0xFF)*_ble_local_K/255, + _ble_local_M=(~_ble_local_M&0xFF)*_ble_local_K/255, + _ble_local_Y=(~_ble_local_Y&0xFF)*_ble_local_K/255)) + ble/color/g#setfg-rgb "$_ble_local_C" "$_ble_local_M" "$_ble_local_Y" +} +function ble/color/g#setbg-cmyk { + local _ble_local_C=$2 + local _ble_local_M=$3 + local _ble_local_Y=$4 + local _ble_local_K=${5:-0} + ((_ble_local_K=~_ble_local_K&0xFF, + _ble_local_C=(~_ble_local_C&0xFF)*_ble_local_K/255, + _ble_local_M=(~_ble_local_M&0xFF)*_ble_local_K/255, + _ble_local_Y=(~_ble_local_Y&0xFF)*_ble_local_K/255)) + ble/color/g#setbg-rgb "$1" "$_ble_local_C" "$_ble_local_M" "$_ble_local_Y" +} +function ble/color/g#setfg { + local _ble_local_color=$2 + if ((_ble_local_color<0)); then + ble/color/g#setfg-clear "$1" + elif ((_ble_local_color>=0x1000000)); then + if ((_ble_local_color==0x1000000)); then + ble/color/g#setfg-index "$1" 16 + else + (($1=$1&~(_ble_color_gflags_FgIndexed|_ble_color_gflags_FgMask)|(_ble_local_color&0xFFFFFF)<<8)) # true color + fi + else + ble/color/g#setfg-index "$1" "$_ble_local_color" + fi +} +function ble/color/g#setbg { + local _ble_local_color=$2 + if ((_ble_local_color<0)); then + ble/color/g#setbg-clear "$1" + elif ((_ble_local_color>=0x1000000)); then + if ((_ble_local_color==0x1000000)); then + ble/color/g#setbg-index "$1" 16 + else + (($1=$1&~(_ble_color_gflags_BgIndexed|_ble_color_gflags_BgMask)|(_ble_local_color&0xFFFFFF)<<32)) # true color + fi + else + ble/color/g#setbg-index "$1" "$_ble_local_color" + fi +} +function ble/color/g#append { + local _ble_local_g2=$2 + ((_ble_local_g2&(_ble_color_gflags_FgMask|_ble_color_gflags_FgIndexed))) && + (($1&=~(_ble_color_gflags_FgMask|_ble_color_gflags_FgIndexed))) + ((_ble_local_g2&(_ble_color_gflags_BgMask|_ble_color_gflags_BgIndexed))) && + (($1&=~(_ble_color_gflags_BgMask|_ble_color_gflags_BgIndexed))) + (($1|=_ble_local_g2)) +} +function ble/color/g#compose { + (($1=($2))) + local _ble_local_g2 + for _ble_local_g2 in "${@:3}"; do + ble/color/g#append "$1" "$_ble_local_g2" + done +} +function ble/color/g.setfg { ble/color/g#setfg g "$@"; } +function ble/color/g.setbg { ble/color/g#setbg g "$@"; } +function ble/color/g.setfg-clear { ble/color/g#setfg-clear g "$@"; } +function ble/color/g.setbg-clear { ble/color/g#setbg-clear g "$@"; } +function ble/color/g.setfg-index { ble/color/g#setfg-index g "$@"; } +function ble/color/g.setbg-index { ble/color/g#setbg-index g "$@"; } +function ble/color/g.setfg-rgb { ble/color/g#setfg-rgb g "$@"; } +function ble/color/g.setbg-rgb { ble/color/g#setbg-rgb g "$@"; } +function ble/color/g.setfg-cmyk { ble/color/g#setfg-cmyk g "$@"; } +function ble/color/g.setbg-cmyk { ble/color/g#setbg-cmyk g "$@"; } +function ble/color/g.append { ble/color/g#append g "$@"; } +function ble/color/g.compose { ble/color/g#compose g "$@"; } +function ble/color/g#getfg { + local g=$1 + if ((g&_ble_color_gflags_FgIndexed)); then + ((ret=g>>8&0xFF)) + elif ((g&_ble_color_gflags_FgMask)); then + ((ret=0x1000000|(g>>8&0xFFFFFF))) + else + ((ret=-1)) + fi +} +function ble/color/g#getbg { + local g=$1 + if ((g&_ble_color_gflags_BgIndexed)); then + ((ret=g>>32&0xFF)) + elif ((g&_ble_color_gflags_BgMask)); then + ((ret=0x1000000|(g>>32&0xFFFFFF))) + else + ((ret=-1)) + fi +} +function ble/color/g#compute-fg { + local g=$1 + if ((g&_ble_color_gflags_Invisible)); then + ble/color/g#compute-bg "$g" + elif ((g&_ble_color_gflags_Revert)); then + ble/color/g#getbg "$g" + else + ble/color/g#getfg "$g" + fi +} +function ble/color/g#compute-bg { + local g=$1 + if ((g&_ble_color_gflags_Revert)); then + ble/color/g#getfg "$g" + else + ble/color/g#getbg "$g" + fi +} +function ble/color/gspec2g { + local g=0 entry + for entry in ${1//,/ }; do + case $entry in + (bold) ((g|=_ble_color_gflags_Bold)) ;; + (underline) ((g|=_ble_color_gflags_Underline)) ;; + (blink) ((g|=_ble_color_gflags_Blink)) ;; + (invis) ((g|=_ble_color_gflags_Invisible)) ;; + (reverse) ((g|=_ble_color_gflags_Revert)) ;; + (strike) ((g|=_ble_color_gflags_Strike)) ;; + (italic) ((g|=_ble_color_gflags_Italic)) ;; + (standout) ((g|=_ble_color_gflags_Revert|_ble_color_gflags_Bold)) ;; + (fg=*) + ble/color/.name2color "${entry:3}" + ble/color/g.setfg "$ret" ;; + (bg=*) + ble/color/.name2color "${entry:3}" + ble/color/g.setbg "$ret" ;; + (none) + g=0 ;; + esac + done + ret=$g +} +function ble/color/g2gspec { + local g=$1 gspec= + if ((g&_ble_color_gflags_FgIndexed)); then + local fg=$((g>>8&0xFF)) + ble/color/.color2name "$fg" + gspec=$gspec,fg=$ret + elif ((g&_ble_color_gflags_FgMask)); then + local rgb=$((1<<24|g>>8&0xFFFFFF)) + ble/color/.color2name "$rgb" + gspec=$gspec,fg=$ret + fi + if ((g&_ble_color_gflags_BgIndexed)); then + local bg=$((g>>32&0xFF)) + ble/color/.color2name "$bg" + gspec=$gspec,bg=$ret + elif ((g&_ble_color_gflags_BgMask)); then + local rgb=$((1<<24|g>>32&0xFFFFFF)) + ble/color/.color2name "$rgb" + gspec=$gspec,bg=$ret + fi + ((g&_ble_color_gflags_Bold)) && gspec=$gspec,bold + ((g&_ble_color_gflags_Underline)) && gspec=$gspec,underline + ((g&_ble_color_gflags_Blink)) && gspec=$gspec,blink + ((g&_ble_color_gflags_Invisible)) && gspec=$gspec,invis + ((g&_ble_color_gflags_Revert)) && gspec=$gspec,reverse + ((g&_ble_color_gflags_Strike)) && gspec=$gspec,strike + ((g&_ble_color_gflags_Italic)) && gspec=$gspec,italic + gspec=${gspec#,} + ret=${gspec:-none} +} +function ble/color/gspec2sgr { + local sgr=0 entry + for entry in ${1//,/ }; do + case $entry in + (bold) sgr="$sgr;${_ble_term_sgr_bold:-1}" ;; + (underline) sgr="$sgr;${_ble_term_sgr_smul:-4}" ;; + (blink) sgr="$sgr;${_ble_term_sgr_blink:-5}" ;; + (invis) sgr="$sgr;${_ble_term_sgr_invis:-8}" ;; + (reverse) sgr="$sgr;${_ble_term_sgr_rev:-7}" ;; + (strike) sgr="$sgr;${_ble_term_sgr_strike:-9}" ;; + (italic) sgr="$sgr;${_ble_term_sgr_sitm:-3}" ;; + (standout) sgr="$sgr;${_ble_term_sgr_bold:-1};${_ble_term_sgr_rev:-7}" ;; + (fg=*) + ble/color/.name2color "${entry:3}" + ble/color/.color2sgrfg "$ret" + sgr="$sgr;$ret" ;; + (bg=*) + ble/color/.name2color "${entry:3}" + ble/color/.color2sgrbg "$ret" + sgr="$sgr;$ret" ;; + (none) + sgr=0 ;; + esac + done + ret="[${sgr}m" +} +function ble/color/.name2color/.clamp { + local text=$1 max=$2 + if [[ $text == *% ]]; then + ((ret=10#0${text%'%'}*max/100)) + else + ((ret=10#0$text)) + fi + ((ret>max)) && ret=max +} +function ble/color/.name2color/.wrap { + local text=$1 max=$2 + if [[ $text == *% ]]; then + ((ret=10#0${text%'%'}*max/100)) + else + ((ret=10#0$text)) + fi + ((ret%=max)) +} +function ble/color/.hxx2color { + local H=$1 Min=$2 Range=$3 Unit=$4 + local h1 h2 x=$Min y=$Min z=$Min + ((h1=H%120,h2=120-h1, + x+=Range*(h2<60?h2:60)/60, + y+=Range*(h1<60?h1:60)/60)) + ((x=x*255/Unit, + y=y*255/Unit, + z=z*255/Unit)) + case $((H/120)) in + (0) local R=$x G=$y B=$z ;; + (1) local R=$z G=$x B=$y ;; + (2) local R=$y G=$z B=$x ;; + esac + ((ret=1<<24|R<<16|G<<8|B)) +} +function ble/color/.hsl2color { + local H=$1 S=$2 L=$3 Unit=$4 + local Range=$((2*(L<=Unit/2?L:Unit-L)*S/Unit)) + local Min=$((L-Range/2)) + ble/color/.hxx2color "$H" "$Min" "$Range" "$Unit" +} +function ble/color/.hsb2color { + local H=$1 S=$2 B=$3 Unit=$4 + local Range=$((B*S/Unit)) + local Min=$((B-Range)) + ble/color/.hxx2color "$H" "$Min" "$Range" "$Unit" +} +function ble/color/.name2color { + local colorName=$1 + if [[ ! ${colorName//[0-9]} ]]; then + ((ret=10#0$colorName&255)) + elif [[ $colorName == '#'* ]]; then + if local rex='^#[0-9a-fA-F]{3}$'; [[ $colorName =~ $rex ]]; then + let "ret=1<<24|16#${colorName:1:1}*0x11<<16|16#${colorName:2:1}*0x11<<8|16#${colorName:3:1}*0x11" + elif rex='^#[0-9a-fA-F]{6}$'; [[ $colorName =~ $rex ]]; then + let "ret=1<<24|16#${colorName:1:2}<<16|16#${colorName:3:2}<<8|16#${colorName:5:2}" + else + ret=-1 + fi + elif [[ $colorName == *:* ]]; then + if local rex='^rgb:([0-9]+%?)/([0-9]+%?)/([0-9]+%?)$'; [[ $colorName =~ $rex ]]; then + ble/color/.name2color/.clamp "${BASH_REMATCH[1]}" 255; local R=$ret + ble/color/.name2color/.clamp "${BASH_REMATCH[2]}" 255; local G=$ret + ble/color/.name2color/.clamp "${BASH_REMATCH[3]}" 255; local B=$ret + ((ret=1<<24|R<<16|G<<8|B)) + elif + local rex1='^cmy:([0-9]+%?)/([0-9]+%?)/([0-9]+%?)$' + local rex2='^cmyk:([0-9]+%?)/([0-9]+%?)/([0-9]+%?)/([0-9]+%?)$' + [[ $colorName =~ $rex1 || $colorName =~ $rex2 ]] + then + ble/color/.name2color/.clamp "${BASH_REMATCH[1]}" 255; local C=$ret + ble/color/.name2color/.clamp "${BASH_REMATCH[2]}" 255; local M=$ret + ble/color/.name2color/.clamp "${BASH_REMATCH[3]}" 255; local Y=$ret + ble/color/.name2color/.clamp "${BASH_REMATCH[4]:-0}" 255; local K=$ret + local K=$((~K&0xFF)) + local R=$(((~C&0xFF)*K/255)) + local G=$(((~M&0xFF)*K/255)) + local B=$(((~Y&0xFF)*K/255)) + ((ret=1<<24|R<<16|G<<8|B)) + elif rex='^hs[lvb]:([0-9]+)/([0-9]+%)/([0-9]+%)$'; [[ $colorName =~ $rex ]]; then + ble/color/.name2color/.wrap "${BASH_REMATCH[1]}" 360; local H=$ret + ble/color/.name2color/.clamp "${BASH_REMATCH[2]}" 1000; local S=$ret + ble/color/.name2color/.clamp "${BASH_REMATCH[3]}" 1000; local X=$ret + if [[ $colorName == hsl:* ]]; then + ble/color/.hsl2color "$H" "$S" "$X" 1000 + else + ble/color/.hsb2color "$H" "$S" "$X" 1000 + fi + else + ret=-1 + fi + else + case $colorName in + (black) ret=0 ;; + (brown) ret=1 ;; + (green) ret=2 ;; + (olive) ret=3 ;; + (navy) ret=4 ;; + (purple) ret=5 ;; + (teal) ret=6 ;; + (silver) ret=7 ;; + (gr[ae]y) ret=8 ;; + (red) ret=9 ;; + (lime) ret=10 ;; + (yellow) ret=11 ;; + (blue) ret=12 ;; + (magenta) ret=13 ;; + (cyan) ret=14 ;; + (white) ret=15 ;; + (orange) ret=202 ;; + (transparent|default) ret=-1 ;; + (*) ret=-1 ;; + esac + fi +} +function ble/color/.color2name { + if (($1>=0x1000000)); then + ble/util/sprintf ret '#%06x' "$(($1&0xFFFFFF))" + return 0 + fi + ((ret=(10#0$1&255))) + case $ret in + (0) ret=black ;; + (1) ret=brown ;; + (2) ret=green ;; + (3) ret=olive ;; + (4) ret=navy ;; + (5) ret=purple ;; + (6) ret=teal ;; + (7) ret=silver ;; + (8) ret=gray ;; + (9) ret=red ;; + (10) ret=lime ;; + (11) ret=yellow ;; + (12) ret=blue ;; + (13) ret=magenta ;; + (14) ret=cyan ;; + (15) ret=white ;; + (202) ret=orange ;; + esac +} +function ble/color/convert-color88-to-color256 { + local color=$1 + if ((color>=16)); then + if ((color>=80)); then + local L=$((((color-80+1)*25+4)/9)) + ((color=L==0?16:(L==25?231:232+(L-1)))) + else + ((color-=16)) + local R=$((color/16)) G=$((color/4%4)) B=$((color%4)) + ((R=(R*5+1)/3,G=(G*5+1)/3,B=(B*5+1)/3, + color=16+R*36+G*6+B)) + fi + fi + ret=$color +} +function ble/color/convert-color256-to-color88 { + local color=$1 + if ((color>=16)); then + if ((color>=232)); then + local L=$((((color-232+1)*9+12)/25)) + ((color=L==0?16:(L==9?79:80+(L-1)))) + else + ((color-=16)) + local R=$((color/36)) G=$((color/6%6)) B=$((color%6)) + ((R=(R*3+2)/5,G=(G*3+2)/5,B=(B*3+2)/5, + color=16+R*16+G*4+B)) + fi + fi + ret=$color +} +function ble/color/convert-rgb24-to-color256 { + local R=$1 G=$2 B=$3 + if ((R!=G||G!=B)); then + local r=$((R<=47?0:(R<=95?1:(R-35)/40))) + local g=$((G<=47?0:(G<=95?1:(G-35)/40))) + local b=$((B<=47?0:(B<=95?1:(B-35)/40))) + if ((r!=g||g!=b)); then + ((ret=16+36*r+6*g+b)) + return 0 + fi + fi + local W=$(((R+G+B+1)/3)) + if ((W<=3)); then + ret=16 + elif ((W>=247)); then + ret=231 + elif ((W>=92&&(W-92)%40<5)); then + ((ret=59+43*(W-92)/40)) + else + local level=$(((W-3)/10)) + ((ret=232+(level<=23?level:23))) + fi +} +function ble/color/convert-rgb24-to-color88 { + local R=$1 G=$2 B=$3 + if ((R!=G||G!=B)); then + local r=$((R<=69?0:(R<=168?1:(R-52)/58))) + local g=$((G<=69?0:(G<=168?1:(G-52)/58))) + local b=$((B<=69?0:(B<=168?1:(B-52)/58))) + if ((r!=g||g!=b)); then + ((ret=16+16*r+4*g+b)) + return 0 + fi + fi + local W=$(((R+G+B+1)/3)) + if ((W<=22)); then + ret=16 # 4x4x4 cube (0,0,0)=0:0:0 + elif ((W>=239)); then + ret=79 # 4x4x4 cube (3,3,3)=255:255:255 + elif ((131<=W&&W<=142)); then + ret=37 # 4x4x4 cube (1,1,1)=139:139:139 + elif ((197<=W&&W<=208)); then + ret=58 # 4x4x4 cube (2,2,2)=197:197:197 + else + local level=$(((W-34)/25)) + ((ret=80+(level<=7?level:7))) + fi +} +_ble_color_color2sgr_filter= +function ble/color/.color2sgr-impl { + local ccode=$1 prefix=$2 # 3 for fg, 4 for bg + builtin eval -- "$_ble_color_color2sgr_filter" + if ((ccode<0)); then + ret=${prefix}9 + elif ((ccode<16&&ccode<_ble_term_colors)); then + if ((prefix==4)); then + ret=${_ble_term_sgr_ab[ccode]} + else + ret=${_ble_term_sgr_af[ccode]} + fi + elif ((ccode<256)); then + local index_colors=$_ble_color_index_colors_default + [[ $bleopt_term_index_colors == auto ]] || ((index_colors=bleopt_term_index_colors)) + if ((index_colors>=256)); then + ret="${prefix}8;5;$ccode" + elif ((index_colors>=88)); then + ble/color/convert-color256-to-color88 "$ccode" + ret="${prefix}8;5;$ret" + elif ((ccode=16||_ble_term_colors==8)); then + if ((ccode>=16)); then + if ((ccode>=232)); then + local L=$((((ccode-232+1)*3+12)/25)) + ((ccode=L==0?0:(L==1?8:(L==2?7:15)))) + else + ((ccode-=16)) + local R=$((ccode/36)) G=$((ccode/6%6)) B=$((ccode%6)) + if ((R==G&&G==B)); then + local L=$(((R*3+2)/5)) + ((ccode=L==0?0:(L==1?8:(L==2?7:15)))) + else + local min max + ((Rmax&&(max=B)))) + local Range=$((max-min)) + ((R=(R-min+Range/2)/Range, + G=(G-min+Range/2)/Range, + B=(B-min+Range/2)/Range, + ccode=R+G*2+B*4+(min+max>=5?8:0))) + fi + fi + fi + ((_ble_term_colors==8&&ccode>=8&&(ccode-=8))) + if ((prefix==4)); then + ret=${_ble_term_sgr_ab[ccode]} + else + ret=${_ble_term_sgr_af[ccode]} + fi + else + ret=${prefix}9 + fi + elif ((0x1000000<=ccode&&ccode<0x2000000)); then + local R=$((ccode>>16&0xFF)) G=$((ccode>>8&0xFF)) B=$((ccode&0xFF)) + if [[ $bleopt_term_true_colors == semicolon ]]; then + ret="${prefix}8;2;$R;$G;$B" + elif [[ $bleopt_term_true_colors == colon ]]; then + ret="${prefix}8:2::$R:$G:$B" + else + local index_colors=$_ble_color_index_colors_default + [[ $bleopt_term_index_colors == auto ]] || ((index_colors=bleopt_term_index_colors)) + local index= + if ((index_colors>=256)); then + ble/color/convert-rgb24-to-color256 "$R" "$G" "$B" + index=$ret + elif ((index_colors>=88)); then + ble/color/convert-rgb24-to-color88 "$R" "$G" "$B" + index=$ret + else + ble/color/convert-rgb24-to-color256 "$R" "$G" "$B" + if ((ret5)) && + ble/color/read-sgrspec/.arg-next -v S + ble/color/read-sgrspec/.arg-next -v R + ble/color/read-sgrspec/.arg-next -v G + ble/color/read-sgrspec/.arg-next -v B + ble/color/g.setfg-rgb "$R" "$G" "$B" + elif ((cspace==3||cspace==4)); then + local S C M Y K=0 + ((${#fields[@]}>2+cspace)) && + ble/color/read-sgrspec/.arg-next -v S + ble/color/read-sgrspec/.arg-next -v C + ble/color/read-sgrspec/.arg-next -v M + ble/color/read-sgrspec/.arg-next -v Y + ((cspace==4)) && + ble/color/read-sgrspec/.arg-next -v K + ble/color/g.setfg-cmyk "$C" "$M" "$Y" "$K" + else + ble/color/g.setfg-clear + fi + elif ((arg==48)); then + local j=1 color cspace + ble/color/read-sgrspec/.arg-next -v cspace + if ((cspace==5)); then + ble/color/read-sgrspec/.arg-next -v color + if [[ :$opts: != *:ansi:* ]] && ((bleopt_term_index_colors==88)); then + local ret; ble/color/convert-color88-to-color256 "$color"; color=$ret + fi + ble/color/g.setbg-index "$color" + elif ((cspace==2)); then + local S R G B + ((${#fields[@]}>5)) && + ble/color/read-sgrspec/.arg-next -v S + ble/color/read-sgrspec/.arg-next -v R + ble/color/read-sgrspec/.arg-next -v G + ble/color/read-sgrspec/.arg-next -v B + ble/color/g.setbg-rgb "$R" "$G" "$B" + elif ((cspace==3||cspace==4)); then + local S C M Y K=0 + ((${#fields[@]}>2+cspace)) && + ble/color/read-sgrspec/.arg-next -v S + ble/color/read-sgrspec/.arg-next -v C + ble/color/read-sgrspec/.arg-next -v M + ble/color/read-sgrspec/.arg-next -v Y + ((cspace==4)) && + ble/color/read-sgrspec/.arg-next -v K + ble/color/g.setbg-cmyk "$C" "$M" "$Y" "$K" + else + ble/color/g.setbg-clear + fi + elif ((arg==39)); then + ble/color/g.setfg-clear + elif ((arg==49)); then + ble/color/g.setbg-clear + fi + elif ((90<=arg&&arg<98)); then + local color=$((arg-90+8)) + ble/color/g.setfg-index "$color" + elif ((100<=arg&&arg<108)); then + local color=$((arg-100+8)) + ble/color/g.setbg-index "$color" + else + case $arg in + (1) ((g|=_ble_color_gflags_Bold)) ;; + (22) ((g&=~_ble_color_gflags_Bold)) ;; + (4) ((g|=_ble_color_gflags_Underline)) ;; + (24) ((g&=~_ble_color_gflags_Underline)) ;; + (7) ((g|=_ble_color_gflags_Revert)) ;; + (27) ((g&=~_ble_color_gflags_Revert)) ;; + (9807) ((g^=_ble_color_gflags_Revert)) ;; # toggle (for internal use) + (3) ((g|=_ble_color_gflags_Italic)) ;; + (23) ((g&=~_ble_color_gflags_Italic)) ;; + (5) ((g|=_ble_color_gflags_Blink)) ;; + (25) ((g&=~_ble_color_gflags_Blink)) ;; + (8) ((g|=_ble_color_gflags_Invisible)) ;; + (28) ((g&=~_ble_color_gflags_Invisible)) ;; + (9) ((g|=_ble_color_gflags_Strike)) ;; + (29) ((g&=~_ble_color_gflags_Strike)) ;; + esac + fi + done +} +function ble/color/sgrspec2g { + local g=0 + ble/color/read-sgrspec "$1" + ret=$g +} +function ble/color/ansi2g { + local x=0 y=0 g=0 + ble/function#try ble/canvas/trace "$1" # -> ret + ret=$g +} +if [[ ! ${_ble_faces_count-} ]]; then # reload #D0875 + _ble_faces_count=0 + _ble_faces=() +fi +function ble/color/setface/.check-argument { + local rex='^[_a-zA-Z0-9]+$' + [[ $# == 2 && $1 =~ $rex && $2 ]] && return 0 + local flags=a + while (($#)); do + local arg=$1; shift + case $arg in + (--help) flags=H$flags ;; + (--color|--color=always) flags=c${flags//[ac]} ;; + (--color=auto) flags=a${flags//[ac]} ;; + (--color=never) flags=${flags//[ac]} ;; + (-*) + ble/util/print "${FUNCNAME[1]}: unrecognized option '$arg'." >&2 + flags=E$flags ;; + (*) + ble/util/print "${FUNCNAME[1]}: unrecognized argument '$arg'." >&2 + flags=E$flags ;; + esac + done + if [[ $flags == *E* ]]; then + ext=2; return 1 + elif [[ $flags == *H* ]]; then + ble/util/print-lines \ + "usage: $name FACE_NAME [TYPE:]SPEC" \ + ' Set face.' \ + '' \ + ' TYPE Specifies the format of SPEC. The following values are available.' \ + ' gspec Comma separated graphic attribute list' \ + ' g Integer value' \ + ' ref Face name or id (reference)' \ + ' copy Face name or id (copy value)' \ + ' sgrspec Parameters to the control function SGR' \ + ' ansi ANSI Sequences' >&2 + ext=0; return 1 + fi + local opts= + [[ $flags == *c* || $flags == *a* && -t 1 ]] && opts=$opts:color + ble/color/list-faces "$opts"; ext=$?; return 1 +} +function ble-color-defface { + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_local_adjust" + local set shopt + [[ $_ble_bash_options_adjusted ]] || ble/base/.adjust-bash-options set shopt + if local ext; ble/color/setface/.check-argument "$@"; then + ble/color/defface "$@" + ext=$? + fi + [[ $_ble_bash_options_adjusted ]] || ble/base/.restore-bash-options set shopt + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_local_leave" + return "$ext" +} +function ble-color-setface { + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_local_adjust" + local set shopt + [[ $_ble_bash_options_adjusted ]] || ble/base/.adjust-bash-options set shopt + if local ext; ble/color/setface/.check-argument "$@"; then + ble/color/setface "$@" + ext=$? + fi + [[ $_ble_bash_options_adjusted ]] || ble/base/.restore-bash-options set shopt + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_local_leave" + return "$ext" +} +function ble/color/defface { local q=\' Q="'\''"; blehook color_defface_load+="ble/color/defface '${1//$q/$Q}' '${2//$q/$Q}'"; } +function ble/color/setface { local q=\' Q="'\''"; blehook color_setface_load+="ble/color/setface '${1//$q/$Q}' '${2//$q/$Q}'"; } +function ble/color/face2g { ble/color/initialize-faces && ble/color/face2g "$@"; } +function ble/color/face2sgr { ble/color/initialize-faces && ble/color/face2sgr "$@"; } +function ble/color/iface2g { ble/color/initialize-faces && ble/color/iface2g "$@"; } +function ble/color/iface2sgr { ble/color/initialize-faces && ble/color/iface2sgr "$@"; } +function ble/color/spec2g { ble/color/initialize-faces && ble/color/spec2g "$@"; } +function ble/color/face2sgr-ansi { ble/color/initialize-faces && ble/color/face2sgr "$@"; } +_ble_color_faces_initialized= +function ble/color/initialize-faces { + local _ble_color_faces_initializing=1 + local -a _ble_color_faces_errors=() + function ble/color/face2g { + ((ret=_ble_faces[_ble_faces__$1])) + } + function ble/color/face2sgr { ble/color/g2sgr "$((_ble_faces[_ble_faces__$1]))"; } + function ble/color/face2sgr-ansi { ble/color/g2sgr-ansi "$((_ble_faces[_ble_faces__$1]))"; } + function ble/color/iface2g { + ((ret=_ble_faces[$1])) + } + function ble/color/iface2sgr { + ble/color/g2sgr "$((_ble_faces[$1]))" + } + function ble/color/spec2g { + ble/color/setface/.spec2gexpr "$@" prefix-face + ((ret=ret)) + } + function ble/color/setface/.spec2gexpr { + local spec=$1 value=${1#*:} opts=$2 + case $spec in + (gspec:*) ble/color/gspec2g "$value" ;; + (g:*) ret=$(($value)) ;; + (ref:*) + if [[ ! ${value//[0-9]} ]]; then + ret=_ble_faces[$((value))] + else + ret=_ble_faces[_ble_faces__$value] + fi ;; + (copy:*|face:*|iface:*) + [[ $spec == copy:* || $spec == face:* && :$opts: == *:prefix-face:* ]] || + ble/util/print "ble-face: \"${spec%%:*}:*\" is obsoleted. Use \"copy:*\" instead." >&2 + if [[ ! ${value//[0-9]} ]]; then + ble/color/iface2g "$value" + else + ble/color/face2g "$value" + fi ;; + (sgrspec:*) ble/color/sgrspec2g "$value" ;; + (ansi:*) ble/color/ansi2g "$value" ;; + (*) ble/color/gspec2g "$spec" ;; + esac + } + function ble/color/defface { + local name=_ble_faces__$1 spec=$2 ret + (($name)) && return 0 + (($name=++_ble_faces_count)) + ble/color/setface/.spec2gexpr "$spec" + _ble_faces[$name]=$ret + _ble_faces_def[$name]=$ret + } + function ble/color/setface { + local name=_ble_faces__$1 spec=$2 ret + if [[ ${!name} ]]; then + ble/color/setface/.spec2gexpr "$spec"; _ble_faces[$name]=$ret + else + local message="ble.sh: the specified face \`$1' is not defined." + if [[ $_ble_color_faces_initializing ]]; then + ble/array#push _ble_color_faces_errors "$message" + else + ble/util/print "$message" >&2 + fi + return 1 + fi + } + _ble_color_faces_initialized=1 + blehook/invoke color_defface_load + blehook/invoke color_setface_load + blehook color_defface_load= + blehook color_setface_load= + if ((${#_ble_color_faces_errors[@]})); then + if ((_ble_edit_attached)) && [[ ! $_ble_textarea_invalidated && $_ble_term_state == internal ]]; then + IFS=$'\n' builtin eval 'local message="${_ble_color_faces_errors[*]}"' + ble/widget/print "$message" + else + printf '%s\n' "${_ble_color_faces_errors[@]}" >&2 + fi + return 1 + else + return 0 + fi +} +ble/function#try ble/util/idle.push ble/color/initialize-faces +function ble/color/list-faces { + local flags= + [[ :$1: == *:color:* ]] && flags=c + local ret sgr0= sgr1= sgr2= + if [[ $flags == *c* ]]; then + sgr0=$_ble_term_sgr0 + ble/color/face2sgr command_function; sgr1=$ret + ble/color/face2sgr syntax_varname; sgr2=$ret + fi + local key + for key in "${!_ble_faces__@}"; do + ble/color/face/.print-face "$key" + done +} +function ble/color/face/.read-arguments/process-set { + local o=$1 face=$2 value=$3 + if local rex='^[_a-zA-Z0-9@][_a-zA-Z0-9@]*$'; ! [[ $face =~ $rex ]]; then + ble/util/print "ble-face: invalid face name '$face'." >&2 + flags=E$flags + return 1 + elif [[ $o == '-d' && $face == *@* ]]; then + ble/util/print "ble-face: wildcards cannot be used in the face name '$face' for definition." >&2 + flags=E$flags + return 1 + fi + local assign='=' + [[ $o == -d ]] && assign=':=' + ble/array#push setface "$face$assign$value" +} +function ble/color/face/.read-arguments { + flags= setface=() print=() + local opt_color=auto + local args iarg narg=$#; args=("$@") + for ((iarg=0;iarg&2 + flags=E$flags + else + case $arg in + (--help) flags=H$flags ;; + (--color) + opt_color=always ;; + (--color=always|--color=auto|--color=never) + opt_color=${arg#*=} ;; + (--color=*) + ble/util/print "ble-face: '${arg#*=}': unrecognized option argument for '--color'." >&2 + flags=E$flags ;; + (--reset) flags=r$flags ;; + (--changed) flags=u$flags ;; + (--) flags=L$flags ;; + (--*) + ble/util/print "ble-face: unrecognized long option '$arg'." >&2 + flags=E$flags ;; + (-?*) + local i c + for ((i=1;i<${#arg};i++)); do + c=${arg:i:1} + case $c in + ([ru]) flags=$c$flags ;; + ([sd]) + if ((i+1<${#arg})); then + local lhs=${arg:i+1} + else + local lhs=${args[iarg++]} + fi + local rhs=${args[iarg++]} + if ((iarg>narg)); then + ble/util/print "ble-face: missing option argument for '-$c FACE SPEC'." >&2 + flags=E$flags + continue + fi + ble/color/face/.read-arguments/process-set "${arg::2}" "$lhs" "$rhs" + break ;; + (*) + ble/util/print "ble-face: unrecognized option '-$c'." >&2 + flags=E$flags ;; + esac + done ;; + (-) + ble/util/print "ble-face: unrecognized argument '$arg'." >&2 + flags=E$flags ;; + esac + fi + elif [[ $arg == *=* ]]; then + if local rex='^[_a-zA-Z@][_a-zA-Z0-9@]*:?='; [[ $arg =~ $rex ]]; then + ble/array#push setface "$arg" + else + local lhs=${arg%%=*}; lhs=${lhs%:} + ble/util/print "ble-face: invalid left-hand side '$lhs' ($arg)." >&2 + flags=E$flags + fi + else + if local rex='^[_a-zA-Z@][_a-zA-Z0-9@]*$'; [[ $arg =~ $rex ]]; then + ble/array#push print "$arg" + else + ble/util/print "ble-face: unrecognized form of argument '$arg'." >&2 + flags=E$flags + fi + fi + done + [[ $opt_color == auto && -t 1 || $opt_color == always ]] && flags=c$flags + [[ $flags != *E* ]] +} +function ble/color/face/.print-help { + ble/util/print-lines >&2 \ + 'ble-face --help' \ + 'ble-face [FACEPAT[:=|=][TYPE:]SPEC | -[sd] FACEPAT [TYPE:]SPEC]]...' \ + 'ble-face [-ur|--color[=WHEN]] [FACE...]' \ + '' \ + ' OPTIONS/ARGUMENTS' \ + '' \ + ' FACEPAT=[TYPE:]SPEC' \ + ' -s FACEPAT [TYPE:]SPEC' \ + ' Set a face. FACEPAT can include a wildcard @ which matches one or' \ + ' more characters.' \ + '' \ + ' FACE:=[TYPE:]SPEC' \ + ' -d FACE [TYPE:]SPEC' \ + ' Define a face' \ + '' \ + ' [-u | --color[=always|never|auto]]... FACEPAT...' \ + ' Print faces. If faces are not specified, all faces are selected.' \ + ' If -u is specified, only the faces with different values from their' \ + ' default will be printed. The option "--color" controls the output' \ + ' color settings. The default is "auto".' \ + '' \ + ' -r FACEPAT...' \ + ' Reset faces. If faces are not specified, all faces are selected.' \ + '' \ + ' FACEPAT Specifies a face name. The characters "@", "*", and "?" in the' \ + ' face name are treated as wildcards.' \ + '' \ + ' FACE Specifies a face name. The wildcards "@", "*", and "?" cannot be' \ + ' used.' \ + '' \ + ' TYPE Specifies the format of SPEC. The following values are available.' \ + ' gspec Comma separated graphic attribute list' \ + ' g Integer value' \ + ' ref Face name or id (reference)' \ + ' copy Face name or id (copy value)' \ + ' sgrspec Parameters to the control function SGR' \ + ' ansi ANSI Sequences' \ + '' + return 0 +} +function ble/color/face/.print-face { + local key=$1 ret + local name=${key#_ble_faces__} + local cur=${_ble_faces[key]} + if [[ $flags == *u* ]]; then + local def=_ble_faces_def[key] + [[ ${!def+set} && $cur == "${!def}" ]] && return 0 + fi + local def=${_ble_faces[key]} + if [[ $cur == '_ble_faces['*']' ]]; then + cur=${cur#'_ble_faces['} + cur=${cur%']'} + cur=ref:${cur#_ble_faces__} + else + ble/color/g2gspec "$((cur))"; cur=$ret + fi + if [[ $flags == *c* ]]; then + ble/color/iface2sgr "$((key))" + cur=$ret$cur$_ble_term_sgr0 + fi + printf '%s %s=%s\n' "${sgr1}ble-face$sgr0" "$sgr2$name$sgr0" "$cur" +} +function ble/color/face/.reset-face { + local key=$1 ret + [[ ${_ble_faces_def[key]+set} ]] && + _ble_faces[key]=${_ble_faces_def[key]} +} +function ble/color/face { + local set shopt reset= + if [[ ! $_ble_bash_options_adjusted ]]; then + ble/base/.adjust-bash-options set shopt + reset='ble/base/.restore-bash-options set shopt' + fi + local flags setface print + ble/color/face/.read-arguments "$@" + if [[ $flags == *H* ]]; then + ble/color/face/.print-help + builtin eval -- "$reset" + return 2 + elif [[ $flags == *E* ]]; then + builtin eval -- "$reset" + return 2 + fi + if ((!${#print[@]}&&!${#setface[@]})); then + print=('?@') + fi + ((${#print[@]})) && ble/color/initialize-faces + if [[ ! $_ble_color_faces_initialized ]]; then + local ret + ble/string#quote-command ble-face "${setface[@]}" + blehook color_setface_load+="$ret" + builtin eval -- "$reset" + return 0 + fi + local spec + for spec in "${setface[@]}"; do + if local rex='^([_a-zA-Z@*?][_a-zA-Z0-9@*?]*)(:?=)(.*)$'; ! [[ $spec =~ $rex ]]; then + ble/util/print "ble-face: unrecognized setting '$spec'" >&2 + flags=E$flags + continue + fi + local var=${BASH_REMATCH[1]} + local type=${BASH_REMATCH[2]} + local value=${BASH_REMATCH[3]} + if [[ $type == ':=' ]]; then + if [[ $var == *[@*?]* ]]; then + ble/util/print "ble-face: wildcards @*? cannot be used for face definition ($spec)." >&2 + flags=E$flags + else + ble/color/defface "$var" "$value" + fi + else + local ret face + if bleopt/expand-variable-pattern "_ble_faces__$var"; then + for face in "${ret[@]}"; do + ble/color/setface "${face#_ble_faces__}" "$value" + done + else + ble/util/print "ble-face: face '$var' not found" >&2 + flags=E$flags + fi + fi + done + if ((${#print[@]})); then + local ret sgr0= sgr1= sgr2= + if [[ $flags == *c* ]]; then + sgr0=$_ble_term_sgr0 + ble/color/face2sgr command_function; sgr1=$ret + ble/color/face2sgr syntax_varname; sgr2=$ret + fi + local spec + for spec in "${print[@]}"; do + local ret face + if bleopt/expand-variable-pattern "_ble_faces__$spec"; then + if [[ $flags == *r* ]]; then + for face in "${ret[@]}"; do + ble/color/face/.reset-face "$face" + done + else + for face in "${ret[@]}"; do + ble/color/face/.print-face "$face" + done + fi + else + ble/util/print "ble-face: face '$spec' not found" >&2 + flags=E$flags + fi + done + fi + [[ $flags != *E* ]] + local ext=$? + builtin eval -- "$reset" + return "$ext" +} +function ble-face { + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_local_adjust" + ble/color/face "$@" + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_local_return" +} +_ble_highlight_layer_list=(plain) +function ble/highlight/layer/update { + local text=$1 iN=${#1} opts=$2 + local DMIN=${3:-0} DMAX=${4:-$iN} DMAX0=${5:-0} + local PREV_BUFF=_ble_highlight_layer_plain_buff + local PREV_UMIN=-1 + local PREV_UMAX=-1 + local layer player=plain LEVEL + local nlevel=${#_ble_highlight_layer_list[@]} + for ((LEVEL=0;LEVELumin)&&(PREV_UMIN=umin), + (PREV_UMAX<0||PREV_UMAX=0)); then + ble/array#reserve-prototype "$((DMAX-DMIN))" + builtin eval " + $_ble_local_dstarr=( + \"\${$_ble_local_srcarr[@]::DMIN}\" + \"\${_ble_array_prototype[@]::DMAX-DMIN}\" + \"\${$_ble_local_srcarr[@]:DMAX0}\")" + else + [[ $_ble_local_dstarr != "$_ble_local_srcarr" ]] && + builtin eval -- "$_ble_local_dstarr=(\"\${$_ble_local_srcarr[@]}\")" + fi +} +function ble/highlight/layer/update/getg { + g= + local LEVEL=$LEVEL + while ((--LEVEL>=0)); do + "ble/highlight/layer:${_ble_highlight_layer_list[LEVEL]}/getg" "$1" + [[ $g ]] && return 0 + done + g=0 +} +function ble/highlight/layer/getg { + LEVEL=${#_ble_highlight_layer_list[*]} ble/highlight/layer/update/getg "$1" +} +_ble_highlight_layer_plain_VARNAMES=( + _ble_highlight_layer_plain_buff) +function ble/highlight/layer:plain/initialize-vars { + _ble_highlight_layer_plain_buff=() +} +ble/highlight/layer:plain/initialize-vars +function ble/highlight/layer:plain/update/.getch { + [[ $ch == [' '-'~'] ]] && return 0 + if [[ $ch == [$'\t\n\177'] ]]; then + if [[ $ch == $'\t' ]]; then + ch=${_ble_string_prototype::it} + elif [[ $ch == $'\n' ]]; then + ch=$_ble_term_el$_ble_term_nl + elif [[ $ch == $'\177' ]]; then + ch='^?' + fi + else + local ret; ble/util/s2c "$ch" + local cs=${_ble_unicode_GraphemeCluster_ControlRepresentation[ret]} + if [[ $cs ]]; then + ch=$cs + elif ((ret<0x20)); then + ble/util/c2s "$((ret+64))" + ch="^$ret" + elif ((0x80<=ret&&ret<=0x9F)); then + ble/util/c2s "$((ret-64))" + ch="M-^$ret" + fi + fi +} +function ble/highlight/layer:plain/update { + if ((DMIN>=0)); then + ble/highlight/layer/update/shift _ble_highlight_layer_plain_buff + local i text=$1 ch + local it=${bleopt_tab_width:-$_ble_term_it} + for ((i=DMIN;ip)&&(umin=p), + (umax<0||umax=0)); then + local k + for ((k=0;k=2&&sel[0]<=PREV_UMIN&&PREV_UMAX<=sel[1]))); then + if [[ ${sel[*]} == "${osel[*]}" && ${gflags[*]} == "${ogflags[*]}" ]]; then + [[ ${sel[*]} ]] && PREV_BUFF=${layer_prefix}buff + return 0 + fi + else + [[ ! ${sel[*]} && ! ${osel[*]} ]] && return 0 + fi + local umin=-1 umax=-1 + if ((rlen)); then + local rmin=${sel[0]} + local rmax=${sel[rlen-1]} + local -a buff=() + local g ret + local k=0 inext iprev=0 + for inext in "${sel[@]}"; do + if ((inext>iprev)); then + if ((k==0)); then + ble/array#push buff "\"\${$PREV_BUFF[@]::$inext}\"" + elif ((k%2)); then + ble/color/g2sgr "${gflags[k/2]}" + ble/array#push buff "\"$ret\${_ble_highlight_layer_plain_buff[@]:$iprev:$((inext-iprev))}\"" + else + ble/highlight/layer/update/getg "$iprev" + ble/color/g2sgr "$g" + ble/array#push buff "\"$ret\${$PREV_BUFF[@]:$iprev:$((inext-iprev))}\"" + fi + fi + ((iprev=inext,k++)) + done + ble/highlight/layer/update/getg "$iprev" + ble/color/g2sgr "$g" + ble/array#push buff "\"$ret\${$PREV_BUFF[@]:$iprev}\"" + builtin eval -- "${layer_prefix}buff=(${buff[*]})" + PREV_BUFF=${layer_prefix}buff + if ((DMIN>=0)); then + ble/highlight/layer:{selection}/.invalidate "$DMIN" "$DMAX" + fi + if ((olen==2&&rlen==2)); then + if [[ ${gflags[0]} != "${ogflags[0]}" ]]; then + ble/highlight/layer:{selection}/.invalidate "$omin" "$omax" + ble/highlight/layer:{selection}/.invalidate "$rmin" "$rmax" + else + ble/highlight/layer:{selection}/.invalidate "$omin" "$rmin" + ble/highlight/layer:{selection}/.invalidate "$omax" "$rmax" + fi + elif ((omin>=0)); then + local k m + local min_len=$((olenrlen?olen:rlen)) + for ((k=0;kosel[oind]?sel[rind]:osel[oind])) + ((smin=0;k-=2)); do + if ((sel[k+1]=4)); then + local l=0 u=$((olen-1)) m + while ((l+1_ble_edit_ind)); then + selection=("$_ble_edit_ind" "$_ble_edit_mark") + elif ((_ble_edit_mark<_ble_edit_ind)); then + selection=("$_ble_edit_mark" "$_ble_edit_ind") + fi + fi + local face=region + ble/function#try ble/highlight/layer:region/mark:"$_ble_edit_mark_active"/get-face + local ret; ble/color/face2g "$face"; local g=$ret + sel=("${selection[@]}") + ble/array#fill-range gflags 0 "$((${#selection[@]}/2))" "$g" + fi + ble/highlight/layer:{selection}/update region "$@" +} +function ble/highlight/layer:region/getg { + ble/highlight/layer:{selection}/getg region "$@" +} +_ble_highlight_layer_disabled_VARNAMES=( + _ble_highlight_layer_disabled_prev + _ble_highlight_layer_disabled_buff) +function ble/highlight/layer:disabled/initialize-vars { + _ble_highlight_layer_disabled_prev= + _ble_highlight_layer_disabled_buff=() +} +ble/highlight/layer:disabled/initialize-vars +function ble/highlight/layer:disabled/update { + if [[ $_ble_edit_line_disabled ]]; then + if ((DMIN>=0)) || [[ ! $_ble_highlight_layer_disabled_prev ]]; then + local ret; ble/color/face2sgr disabled; local sgr=$ret + _ble_highlight_layer_disabled_buff=("$sgr""${_ble_highlight_layer_plain_buff[@]}") + fi + PREV_BUFF=_ble_highlight_layer_disabled_buff + if [[ $_ble_highlight_layer_disabled_prev ]]; then + PREV_UMIN=$DMIN PREV_UMAX=$DMAX + else + PREV_UMIN=0 PREV_UMAX=${#1} + fi + else + if [[ $_ble_highlight_layer_disabled_prev ]]; then + PREV_UMIN=0 PREV_UMAX=${#1} + fi + fi + _ble_highlight_layer_disabled_prev=$_ble_edit_line_disabled +} +function ble/highlight/layer:disabled/getg { + if [[ $_ble_highlight_layer_disabled_prev ]]; then + local ret; ble/color/face2g disabled; g=$ret + fi +} +_ble_highlight_layer_overwrite_mode_VARNAMES=( + _ble_highlight_layer_overwrite_mode_index + _ble_highlight_layer_overwrite_mode_buff) +function ble/highlight/layer:overwrite_mode/initialize-vars { + _ble_highlight_layer_overwrite_mode_index=-1 + _ble_highlight_layer_overwrite_mode_buff=() +} +ble/highlight/layer:overwrite_mode/initialize-vars +function ble/highlight/layer:overwrite_mode/update { + local oindex=$_ble_highlight_layer_overwrite_mode_index + if ((DMIN>=0)); then + if ((oindex>=DMAX0)); then + ((oindex+=DMAX-DMAX0)) + elif ((oindex>=DMIN)); then + oindex=-1 + fi + fi + local index=-1 + if [[ $_ble_edit_overwrite_mode && ! $_ble_edit_mark_active ]]; then + local next=${_ble_edit_str:_ble_edit_ind:1} + if [[ $next && $next != [$'\n\t'] ]]; then + index=$_ble_edit_ind + local g ret + if ((PREV_UMIN<0&&oindex>=0)); then + ble/highlight/layer/update/getg "$oindex" + ble/color/g2sgr "$g" + _ble_highlight_layer_overwrite_mode_buff[oindex]=$ret${_ble_highlight_layer_plain_buff[oindex]} + else + builtin eval "_ble_highlight_layer_overwrite_mode_buff=(\"\${$PREV_BUFF[@]}\")" + fi + PREV_BUFF=_ble_highlight_layer_overwrite_mode_buff + ble/color/face2g overwrite_mode + ble/color/g2sgr "$ret" + _ble_highlight_layer_overwrite_mode_buff[index]=$ret${_ble_highlight_layer_plain_buff[index]} + if ((index+1<${#1})); then + ble/highlight/layer/update/getg "$((index+1))" + ble/color/g2sgr "$g" + _ble_highlight_layer_overwrite_mode_buff[index+1]=$ret${_ble_highlight_layer_plain_buff[index+1]} + fi + fi + fi + if ((index>=0)); then + ble/term/cursor-state/hide + else + ble/term/cursor-state/reveal + fi + if ((index!=oindex)); then + ((oindex>=0)) && ble/highlight/layer/update/add-urange "$oindex" "$((oindex+1))" + ((index>=0)) && ble/highlight/layer/update/add-urange "$index" "$((index+1))" + fi + _ble_highlight_layer_overwrite_mode_index=$index +} +function ble/highlight/layer:overwrite_mode/getg { + local index=$_ble_highlight_layer_overwrite_mode_index + if ((index>=0&&index==$1)); then + local ret; ble/color/face2g overwrite_mode; g=$ret + fi +} +_ble_highlight_layer_list=(plain syntax region overwrite_mode disabled) +bleopt/declare -v tab_width '' +function bleopt/check:tab_width { + local old_width=${bleopt_tab_width:-$_ble_term_it} + if [[ $value ]] && (((value=value)<=0)); then + ble/util/print "bleopt: an empty string or a positive value is required for tab_width." >&2 + return 1 + fi + if ((value!=old_width)); then + local ret + if ble/string#index-of "$_ble_edit_str" $'\t'; then + local beg=$ret + ble/string#last-index-of "$_ble_edit_str" $'\t' + ble-edit/content/.update-dirty-range "$beg" "$ret" "$ret" tab_width + fi + fi +} +function ble/arithmetic/sum { + IFS=+ builtin eval 'let "ret=$*+0"' +} +_ble_util_c2w=() +_ble_util_c2w_cache=() +function ble/util/c2w/clear-cache { + _ble_util_c2w_cache=() +} +bleopt/declare -n char_width_mode auto +function bleopt/check:char_width_mode { + if ! ble/is-function "ble/util/c2w:$value"; then + ble/util/print "bleopt: Invalid value char_width_mode='$value'. A function 'ble/util/c2w:$value' is not defined." >&2 + return 1 + fi + case $value in + (auto) + _ble_unicode_c2w_ambiguous=1 + ble && ble/util/c2w:auto/test.buff first-line ;; + (west) _ble_unicode_c2w_ambiguous=1 ;; + (east) _ble_unicode_c2w_ambiguous=2 ;; + esac + ((_ble_prompt_version++)) + ble/util/c2w/clear-cache +} +function ble/util/c2w { + ret=${_ble_util_c2w_cache[$1]:-${_ble_util_c2w[$1]}} + if [[ ! $ret ]]; then + "ble/util/c2w:$bleopt_char_width_mode" "$1" + _ble_util_c2w_cache[$1]=$ret + fi +} +function ble/util/c2w-edit { + local cs=${_ble_unicode_GraphemeCluster_ControlRepresentation[$1]} + if [[ $cs ]]; then + ret=${#cs} + elif (($1<32||127<=$1&&$1<160)); then + ret=2 + ((128<=$1&&(ret=4))) + else + ble/util/c2w "$1" + fi +} +function ble/util/s2w-edit { + local text=$1 iN=${#1} flags=$2 i + ret=0 + for ((i=0;i&2 + return 1 + fi +} +_ble_unicode_c2w_custom[173]=1 # U+00ad Cf A SHY(soft-hyphen) +let '_ble_unicode_c2w_custom['{1536..1541}']=1' # U+0600..0605 Cf 1 アラブの数字? +_ble_unicode_c2w_custom[1757]=1 # U+06dd Cf 1 ARABIC END OF AYAH +_ble_unicode_c2w_custom[1807]=1 # U+070f Cf 1 SYRIAC ABBREVIATION MARK +_ble_unicode_c2w_custom[2274]=1 # U+08e2 Cf 1 ARABIC DISPUTED END OF AYAH +_ble_unicode_c2w_custom[69821]=1 # U+110bd Cf 1 KAITHI NUMBER SIGN +_ble_unicode_c2w_custom[69837]=1 # U+110cd Cf 1 KAITHI NUMBER SIGN ABOVE +let '_ble_unicode_c2w_custom['{12872..12879}']=2' # U+3248..324f No A 囲み文字10-80 (8字) +let '_ble_unicode_c2w_custom['{19904..19967}']=2' # U+4dc0..4dff So 1 易経記号 (6字) +let '_ble_unicode_c2w_custom['{4448..4607}']=0' # U+1160..11ff Lo 1 HANGUL JAMO (160字) +let '_ble_unicode_c2w_custom['{55216..55238}']=0' # U+d7b0..d7c6 Lo 1 HANGUL JAMO EXTENDED-B (1) (23字) +let '_ble_unicode_c2w_custom['{55243..55291}']=0' # U+d7cb..d7fb Lo 1 HANGUL JAMO EXTENDED-B (2) (49字) +function ble/unicode/c2w { + local c=$1 + ret=${_ble_unicode_c2w_custom[c]} + [[ $ret ]] && return 0 + ret=${_ble_unicode_c2w[c]} + if [[ ! $ret ]]; then + ret=${_ble_unicode_c2w_index[c<0x20000?c>>8:((c>>12)-32+512)]} + if [[ $ret == *:* ]]; then + local l=${ret%:*} u=${ret#*:} m + while ((l+1&2 + return 1 + else + ble/util/print "bleopt: Unsupported emoji_version: '$value'." >&2 + return 1 + fi + fi + _ble_unicode_EmojiStatus_version=$ret + ((_ble_prompt_version++)) + ble/util/c2w/clear-cache + return 0 +} +function bleopt/check:emoji_width { ble/util/c2w/clear-cache; } +_ble_unicode_EmojiStatus_xIsEmoji='ret&&ret!=_ble_unicode_EmojiStatus_Unqualified' +function bleopt/check:emoji_opts { + _ble_unicode_EmojiStatus_xIsEmoji='ret' + [[ :$value: != *:unqualified:* ]] && + _ble_unicode_EmojiStatus_xIsEmoji=$_ble_unicode_EmojiStatus_xIsEmoji'&&ret!=_ble_unicode_EmojiStatus_Unqualified' + local rex=':min=U\+([0-9a-fA-F]+):' + [[ :$value: =~ $rex ]] && + _ble_unicode_EmojiStatus_xIsEmoji=$_ble_unicode_EmojiStatus_xIsEmoji'&&code>=0x'${BASH_REMATCH[1]} + ((_ble_prompt_version++)) + ble/util/c2w/clear-cache + return 0 +} +function ble/unicode/EmojiStatus { + local code=$1 V=$_ble_unicode_EmojiStatus_version + ret=${_ble_unicode_EmojiStatus[code]} + if [[ ! $ret ]]; then + ret=$_ble_unicode_EmojiStatus_None + if ((_ble_unicode_EmojiStatus_xmaybe)); then + local l=0 u=${#_ble_unicode_EmojiStatus_ranges[@]} m + while ((l+1=0x80?2:1 + ):(ah==0x2f?( + ret=2 + ):(ah==0x30?( + ret=al!=0x3f?2:1 + ):(ah==0xf9||ah==0xfa?( + ret=2 + ):(ah==0xfe?( + ret=0x30<=al&&al<0x70?2:1 + ):(ah==0xff?( + ret=0x01<=al&&al<0x61||0xE0<=al&&al<=0xE7?2:1 + ):(ret=1)))))))))) + )) + )) + [[ $tIndex ]] || return 0 + if ((tIndex<_ble_util_c2w_emacs_wranges[0])); then + ret=1 + return 0 + fi + local l=0 u=${#_ble_util_c2w_emacs_wranges[@]} m + while ((l+1&2 + return 1 ;; + esac +} +_ble_unicode_GraphemeClusterBreak_Count=18 +_ble_unicode_GraphemeClusterBreak_Other=0 +_ble_unicode_GraphemeClusterBreak_Control=1 +_ble_unicode_GraphemeClusterBreak_ZWJ=2 +_ble_unicode_GraphemeClusterBreak_Prepend=3 +_ble_unicode_GraphemeClusterBreak_Extend=4 +_ble_unicode_GraphemeClusterBreak_SpacingMark=5 +_ble_unicode_GraphemeClusterBreak_Regional_Indicator=6 +_ble_unicode_GraphemeClusterBreak_L=7 +_ble_unicode_GraphemeClusterBreak_V=8 +_ble_unicode_GraphemeClusterBreak_T=9 +_ble_unicode_GraphemeClusterBreak_LV=10 +_ble_unicode_GraphemeClusterBreak_LVT=11 +_ble_unicode_GraphemeClusterBreak_Pictographic=12 +_ble_unicode_GraphemeClusterBreak_HighSurrogate=13 +_ble_unicode_GraphemeClusterBreak_LowSurrogate=14 +_ble_unicode_GraphemeClusterBreak_InCB_Consonant=15 +_ble_unicode_GraphemeClusterBreak_InCB_Linker=16 +_ble_unicode_GraphemeClusterBreak_InCB_Extend=17 +_ble_unicode_GraphemeClusterBreak_MaxCode=921600 +_ble_unicode_GraphemeClusterBreak=( + [169]=12 [173]=1 [174]=12 [847]=4 [1160]=4 [1161]=4 [1470]=0 [1471]=17 [1472]=0 [1473]=17 [1474]=17 [1475]=0 [1476]=17 [1477]=17 [1478]=0 [1479]=17 + [1563]=0 [1564]=1 [1648]=17 [1757]=3 [1758]=0 [1765]=0 [1766]=0 [1767]=17 [1768]=17 [1769]=0 [1807]=3 [1808]=0 [1809]=17 [2045]=17 [2074]=0 [2084]=0 + [2088]=0 [2192]=3 [2193]=3 [2274]=3 [2307]=5 [2362]=4 [2363]=5 [2364]=17 [2365]=0 [2381]=16 [2382]=5 [2383]=5 [2384]=0 [2400]=0 [2401]=0 [2402]=4 + [2403]=4 [2432]=0 [2433]=4 [2434]=5 [2435]=5 [2473]=0 [2481]=0 [2482]=15 [2490]=0 [2491]=0 [2492]=17 [2493]=0 [2494]=4 [2495]=5 [2496]=5 [2501]=0 + [2502]=0 [2503]=5 [2504]=5 [2505]=0 [2506]=0 [2507]=5 [2508]=5 [2509]=16 [2519]=4 [2524]=15 [2525]=15 [2526]=0 [2527]=15 [2528]=0 [2529]=0 [2530]=4 + [2531]=4 [2544]=15 [2545]=15 [2558]=17 [2559]=0 [2560]=0 [2561]=4 [2562]=4 [2563]=5 [2620]=17 [2621]=0 [2625]=4 [2626]=4 [2631]=4 [2632]=4 [2633]=0 + [2634]=0 [2641]=4 [2672]=4 [2673]=4 [2677]=4 [2689]=4 [2690]=4 [2691]=5 [2729]=0 [2737]=0 [2738]=15 [2739]=15 [2740]=0 [2746]=0 [2747]=0 [2748]=17 + [2749]=0 [2758]=0 [2759]=4 [2760]=4 [2761]=5 [2762]=0 [2763]=5 [2764]=5 [2765]=16 [2786]=4 [2787]=4 [2809]=15 [2816]=0 [2817]=4 [2818]=5 [2819]=5 + [2857]=0 [2865]=0 [2866]=15 [2867]=15 [2868]=0 [2874]=0 [2875]=0 [2876]=17 [2877]=0 [2878]=4 [2879]=4 [2880]=5 [2885]=0 [2886]=0 [2887]=5 [2888]=5 + [2889]=0 [2890]=0 [2891]=5 [2892]=5 [2893]=16 [2908]=15 [2909]=15 [2910]=0 [2911]=15 [2912]=0 [2913]=0 [2914]=4 [2915]=4 [2929]=15 [2946]=4 [3006]=4 + [3007]=5 [3008]=4 [3009]=5 [3010]=5 [3017]=0 [3021]=4 [3031]=4 [3072]=4 [3076]=4 [3113]=0 [3130]=0 [3131]=0 [3132]=17 [3133]=0 [3141]=0 [3145]=0 + [3149]=16 [3157]=17 [3158]=17 [3159]=0 [3170]=4 [3171]=4 [3201]=4 [3202]=5 [3203]=5 [3260]=17 [3261]=0 [3262]=5 [3263]=4 [3264]=5 [3265]=5 [3266]=4 + [3267]=5 [3268]=5 [3269]=0 [3270]=4 [3271]=5 [3272]=5 [3273]=0 [3274]=5 [3275]=5 [3276]=4 [3277]=4 [3285]=4 [3286]=4 [3298]=4 [3299]=4 [3315]=5 + [3328]=4 [3329]=4 [3330]=5 [3331]=5 [3387]=17 [3388]=17 [3389]=0 [3390]=4 [3391]=5 [3392]=5 [3397]=0 [3401]=0 [3405]=16 [3406]=3 [3415]=4 [3426]=4 + [3427]=4 [3457]=4 [3458]=5 [3459]=5 [3530]=4 [3535]=4 [3536]=5 [3537]=5 [3541]=0 [3542]=4 [3543]=0 [3551]=4 [3570]=5 [3571]=5 [3633]=4 [3634]=0 + [3635]=5 [3655]=4 [3761]=4 [3762]=0 [3763]=5 [3771]=4 [3772]=4 [3864]=17 [3865]=17 [3893]=17 [3894]=0 [3895]=17 [3896]=0 [3897]=17 [3902]=5 [3903]=5 + [3953]=17 [3954]=17 [3955]=4 [3956]=17 [3966]=4 [3967]=5 [3968]=17 [3969]=4 [3973]=0 [3974]=17 [3975]=17 [3992]=0 [4038]=17 [4145]=5 [4151]=17 [4152]=0 + [4153]=17 [4154]=17 [4155]=5 [4156]=5 [4157]=4 [4158]=4 [4182]=5 [4183]=5 [4184]=4 [4185]=4 [4226]=4 [4227]=0 [4228]=5 [4229]=4 [4230]=4 [4237]=17 + [4253]=4 [5906]=4 [5907]=4 [5908]=17 [5909]=5 [5938]=4 [5939]=4 [5940]=5 [5970]=4 [5971]=4 [6002]=4 [6003]=4 [6068]=4 [6069]=4 [6070]=5 [6086]=4 + [6087]=5 [6088]=5 [6098]=17 [6099]=4 [6109]=17 [6158]=1 [6159]=4 [6277]=4 [6278]=4 [6313]=17 [6439]=4 [6440]=4 [6448]=5 [6449]=5 [6450]=4 [6679]=17 + [6680]=17 [6681]=5 [6682]=5 [6683]=4 [6741]=5 [6742]=4 [6743]=5 [6751]=0 [6752]=17 [6753]=0 [6754]=4 [6755]=0 [6756]=0 [6771]=4 [6772]=4 [6781]=0 + [6782]=0 [6783]=17 [6846]=4 [6916]=5 [6964]=17 [6971]=5 [6972]=4 [6978]=4 [6979]=5 [6980]=5 [7040]=4 [7041]=4 [7042]=5 [7073]=5 [7078]=5 [7079]=5 + [7080]=4 [7081]=4 [7082]=5 [7083]=17 [7084]=4 [7085]=4 [7142]=17 [7143]=5 [7144]=4 [7145]=4 [7149]=4 [7150]=5 [7154]=5 [7155]=5 [7220]=5 [7221]=5 + [7222]=4 [7223]=17 [7379]=0 [7393]=5 [7405]=17 [7412]=17 [7413]=0 [7414]=0 [7415]=5 [7416]=17 [7417]=17 [8203]=1 [8204]=4 [8205]=2 [8206]=1 [8207]=1 + [8252]=12 [8265]=12 [8417]=17 [8482]=12 [8505]=12 [8617]=12 [8618]=12 [8986]=12 [8987]=12 [9000]=12 [9096]=12 [9167]=12 [9410]=12 [9642]=12 [9643]=12 [9654]=12 + [9664]=12 [9727]=0 [9734]=0 [9747]=0 [9990]=0 [9991]=0 [10003]=0 [10004]=12 [10005]=0 [10006]=12 [10013]=12 [10017]=12 [10024]=12 [10035]=12 [10036]=12 [10052]=12 + [10053]=0 [10054]=0 [10055]=12 [10060]=12 [10061]=0 [10062]=12 [10070]=0 [10071]=12 [10145]=12 [10160]=12 [10175]=12 [10548]=12 [10549]=12 [11035]=12 [11036]=12 [11088]=12 + [11093]=12 [11647]=17 [12336]=12 [12349]=12 [12441]=17 [12442]=17 [12951]=12 [12952]=0 [12953]=12 [42607]=17 [42611]=0 [42654]=17 [42655]=17 [42736]=17 [42737]=17 [43010]=4 + [43014]=4 [43019]=4 [43043]=5 [43044]=5 [43045]=4 [43046]=4 [43047]=5 [43052]=17 [43136]=5 [43137]=5 [43204]=4 [43205]=4 [43263]=4 [43346]=5 [43347]=5 [43395]=5 + [43443]=17 [43444]=5 [43445]=5 [43450]=5 [43451]=5 [43452]=4 [43453]=4 [43493]=4 [43567]=5 [43568]=5 [43569]=4 [43570]=4 [43571]=5 [43572]=5 [43573]=4 [43574]=4 + [43587]=4 [43596]=4 [43597]=5 [43644]=4 [43696]=17 [43697]=0 [43701]=0 [43702]=0 [43703]=17 [43704]=17 [43710]=17 [43711]=17 [43712]=0 [43713]=17 [43755]=5 [43756]=4 + [43757]=4 [43758]=5 [43759]=5 [43765]=5 [43766]=17 [44003]=5 [44004]=5 [44005]=4 [44006]=5 [44007]=5 [44008]=4 [44009]=5 [44010]=5 [44011]=0 [44012]=5 [44013]=17 + [44032]=10 [44060]=10 [44088]=10 [44116]=10 [44144]=10 [44172]=10 [44200]=10 [44228]=10 [44256]=10 [44284]=10 [44312]=10 [44340]=10 [44368]=10 [44396]=10 [44424]=10 [44452]=10 + [44480]=10 [44508]=10 [44536]=10 [44564]=10 [44592]=10 [44620]=10 [44648]=10 [44676]=10 [44704]=10 [44732]=10 [44760]=10 [44788]=10 [44816]=10 [44844]=10 [44872]=10 [44900]=10 + [44928]=10 [44956]=10 [44984]=10 [45012]=10 [45040]=10 [45068]=10 [45096]=10 [45124]=10 [45152]=10 [45180]=10 [45208]=10 [45236]=10 [45264]=10 [45292]=10 [45320]=10 [45348]=10 + [45376]=10 [45404]=10 [45432]=10 [45460]=10 [45488]=10 [45516]=10 [45544]=10 [45572]=10 [45600]=10 [45628]=10 [45656]=10 [45684]=10 [45712]=10 [45740]=10 [45768]=10 [45796]=10 + [45824]=10 [45852]=10 [45880]=10 [45908]=10 [45936]=10 [45964]=10 [45992]=10 [46020]=10 [46048]=10 [46076]=10 [46104]=10 [46132]=10 [46160]=10 [46188]=10 [46216]=10 [46244]=10 + [46272]=10 [46300]=10 [46328]=10 [46356]=10 [46384]=10 [46412]=10 [46440]=10 [46468]=10 [46496]=10 [46524]=10 [46552]=10 [46580]=10 [46608]=10 [46636]=10 [46664]=10 [46692]=10 + [46720]=10 [46748]=10 [46776]=10 [46804]=10 [46832]=10 [46860]=10 [46888]=10 [46916]=10 [46944]=10 [46972]=10 [47000]=10 [47028]=10 [47056]=10 [47084]=10 [47112]=10 [47140]=10 + [47168]=10 [47196]=10 [47224]=10 [47252]=10 [47280]=10 [47308]=10 [47336]=10 [47364]=10 [47392]=10 [47420]=10 [47448]=10 [47476]=10 [47504]=10 [47532]=10 [47560]=10 [47588]=10 + [47616]=10 [47644]=10 [47672]=10 [47700]=10 [47728]=10 [47756]=10 [47784]=10 [47812]=10 [47840]=10 [47868]=10 [47896]=10 [47924]=10 [47952]=10 [47980]=10 [48008]=10 [48036]=10 + [48064]=10 [48092]=10 [48120]=10 [48148]=10 [48176]=10 [48204]=10 [48232]=10 [48260]=10 [48288]=10 [48316]=10 [48344]=10 [48372]=10 [48400]=10 [48428]=10 [48456]=10 [48484]=10 + [48512]=10 [48540]=10 [48568]=10 [48596]=10 [48624]=10 [48652]=10 [48680]=10 [48708]=10 [48736]=10 [48764]=10 [48792]=10 [48820]=10 [48848]=10 [48876]=10 [48904]=10 [48932]=10 + [48960]=10 [48988]=10 [49016]=10 [49044]=10 [49072]=10 [49100]=10 [49128]=10 [49156]=10 [49184]=10 [49212]=10 [49240]=10 [49268]=10 [49296]=10 [49324]=10 [49352]=10 [49380]=10 + [49408]=10 [49436]=10 [49464]=10 [49492]=10 [49520]=10 [49548]=10 [49576]=10 [49604]=10 [49632]=10 [49660]=10 [49688]=10 [49716]=10 [49744]=10 [49772]=10 [49800]=10 [49828]=10 + [49856]=10 [49884]=10 [49912]=10 [49940]=10 [49968]=10 [49996]=10 [50024]=10 [50052]=10 [50080]=10 [50108]=10 [50136]=10 [50164]=10 [50192]=10 [50220]=10 [50248]=10 [50276]=10 + [50304]=10 [50332]=10 [50360]=10 [50388]=10 [50416]=10 [50444]=10 [50472]=10 [50500]=10 [50528]=10 [50556]=10 [50584]=10 [50612]=10 [50640]=10 [50668]=10 [50696]=10 [50724]=10 + [50752]=10 [50780]=10 [50808]=10 [50836]=10 [50864]=10 [50892]=10 [50920]=10 [50948]=10 [50976]=10 [51004]=10 [51032]=10 [51060]=10 [51088]=10 [51116]=10 [51144]=10 [51172]=10 + [51200]=10 [51228]=10 [51256]=10 [51284]=10 [51312]=10 [51340]=10 [51368]=10 [51396]=10 [51424]=10 [51452]=10 [51480]=10 [51508]=10 [51536]=10 [51564]=10 [51592]=10 [51620]=10 + [51648]=10 [51676]=10 [51704]=10 [51732]=10 [51760]=10 [51788]=10 [51816]=10 [51844]=10 [51872]=10 [51900]=10 [51928]=10 [51956]=10 [51984]=10 [52012]=10 [52040]=10 [52068]=10 + [52096]=10 [52124]=10 [52152]=10 [52180]=10 [52208]=10 [52236]=10 [52264]=10 [52292]=10 [52320]=10 [52348]=10 [52376]=10 [52404]=10 [52432]=10 [52460]=10 [52488]=10 [52516]=10 + [52544]=10 [52572]=10 [52600]=10 [52628]=10 [52656]=10 [52684]=10 [52712]=10 [52740]=10 [52768]=10 [52796]=10 [52824]=10 [52852]=10 [52880]=10 [52908]=10 [52936]=10 [52964]=10 + [52992]=10 [53020]=10 [53048]=10 [53076]=10 [53104]=10 [53132]=10 [53160]=10 [53188]=10 [53216]=10 [53244]=10 [53272]=10 [53300]=10 [53328]=10 [53356]=10 [53384]=10 [53412]=10 + [53440]=10 [53468]=10 [53496]=10 [53524]=10 [53552]=10 [53580]=10 [53608]=10 [53636]=10 [53664]=10 [53692]=10 [53720]=10 [53748]=10 [53776]=10 [53804]=10 [53832]=10 [53860]=10 + [53888]=10 [53916]=10 [53944]=10 [53972]=10 [54000]=10 [54028]=10 [54056]=10 [54084]=10 [54112]=10 [54140]=10 [54168]=10 [54196]=10 [54224]=10 [54252]=10 [54280]=10 [54308]=10 + [54336]=10 [54364]=10 [54392]=10 [54420]=10 [54448]=10 [54476]=10 [54504]=10 [54532]=10 [54560]=10 [54588]=10 [54616]=10 [54644]=10 [54672]=10 [54700]=10 [54728]=10 [54756]=10 + [54784]=10 [54812]=10 [54840]=10 [54868]=10 [54896]=10 [54924]=10 [54952]=10 [54980]=10 [55008]=10 [55036]=10 [55064]=10 [55092]=10 [55120]=10 [55148]=10 [55176]=10 [64286]=17 + [65279]=1 [65438]=4 [65439]=4 [66045]=17 [66272]=17 [68100]=0 [68101]=4 [68102]=4 [68108]=4 [68109]=17 [68110]=4 [68111]=17 [68159]=17 [68325]=17 [68326]=17 [69291]=17 + [69292]=17 [69632]=5 [69633]=4 [69634]=5 [69744]=17 [69745]=0 [69746]=0 [69747]=4 [69748]=4 [69759]=17 [69760]=4 [69761]=4 [69762]=5 [69815]=5 [69816]=5 [69817]=4 + [69818]=17 [69819]=0 [69820]=0 [69821]=3 [69826]=4 [69837]=3 [69932]=5 [69939]=17 [69940]=17 [69957]=5 [69958]=5 [70003]=17 [70016]=4 [70017]=4 [70018]=5 [70079]=5 + [70080]=5 [70081]=0 [70082]=3 [70083]=3 [70089]=4 [70090]=17 [70091]=4 [70092]=4 [70093]=0 [70094]=5 [70095]=4 [70194]=5 [70195]=5 [70196]=4 [70197]=5 [70198]=17 + [70199]=4 [70206]=4 [70207]=0 [70208]=0 [70209]=4 [70367]=4 [70377]=17 [70378]=17 [70400]=4 [70401]=4 [70402]=5 [70403]=5 [70459]=17 [70460]=17 [70461]=0 [70462]=4 + [70463]=5 [70464]=4 [70469]=0 [70470]=0 [70471]=5 [70472]=5 [70473]=0 [70474]=0 [70487]=4 [70498]=5 [70499]=5 [70500]=0 [70501]=0 [70720]=5 [70721]=5 [70725]=5 + [70726]=17 [70750]=17 [70832]=4 [70833]=5 [70834]=5 [70841]=5 [70842]=4 [70843]=5 [70844]=5 [70845]=4 [70846]=5 [70847]=4 [70848]=4 [70849]=5 [70850]=4 [70851]=17 + [71087]=4 [71088]=5 [71089]=5 [71094]=0 [71095]=0 [71100]=4 [71101]=4 [71102]=5 [71103]=4 [71104]=17 [71132]=4 [71133]=4 [71227]=5 [71228]=5 [71229]=4 [71230]=5 + [71231]=4 [71232]=4 [71339]=4 [71340]=5 [71341]=4 [71342]=5 [71343]=5 [71350]=5 [71351]=17 [71456]=0 [71457]=0 [71462]=5 [71467]=17 [71736]=5 [71737]=4 [71738]=17 + [71984]=4 [71990]=0 [71991]=5 [71992]=5 [71993]=0 [71994]=0 [71995]=4 [71996]=4 [71997]=5 [71998]=17 [71999]=3 [72000]=5 [72001]=3 [72002]=5 [72003]=17 [72152]=0 + [72153]=0 [72154]=4 [72155]=4 [72160]=4 [72164]=5 [72243]=4 [72244]=17 [72249]=5 [72250]=3 [72263]=17 [72279]=5 [72280]=5 [72343]=5 [72344]=4 [72345]=17 [72751]=5 + [72759]=0 [72766]=5 [72767]=4 [72872]=0 [72873]=5 [72881]=5 [72882]=4 [72883]=4 [72884]=5 [72885]=4 [72886]=4 [73018]=4 [73019]=0 [73020]=4 [73021]=4 [73022]=0 + [73026]=17 [73027]=4 [73028]=17 [73029]=17 [73030]=3 [73031]=4 [73103]=0 [73104]=4 [73105]=4 [73106]=0 [73107]=5 [73108]=5 [73109]=4 [73110]=5 [73111]=17 [73459]=4 + [73460]=4 [73461]=5 [73462]=5 [73472]=4 [73473]=4 [73474]=3 [73475]=5 [73524]=5 [73525]=5 [73534]=5 [73535]=5 [73536]=4 [73537]=5 [73538]=17 [78912]=4 [94031]=4 + [94032]=0 [94180]=4 [94192]=5 [94193]=5 [113821]=4 [113822]=17 [113823]=0 [118574]=0 [118575]=0 [119141]=17 [119142]=5 [119149]=5 [119171]=0 [119172]=0 [121461]=4 [121476]=4 + [121504]=0 [122887]=0 [122905]=0 [122906]=0 [122914]=0 [122915]=17 [122916]=17 [122917]=0 [123023]=17 [123566]=17 [127279]=12 [127358]=12 [127359]=12 [127374]=12 [127375]=0 [127376]=0 + [127488]=0 [127514]=12 [127535]=12 [127536]=0 [127537]=0 [127547]=0 [129339]=0 [129350]=0 + [0]=1 [32]=0 [127]=1 [160]=0 [768]=17 [880]=0 [1155]=17 [1162]=0 [1425]=17 [1480]=0 [1536]=3 [1542]=0 [1552]=17 [1565]=0 [1611]=17 [1632]=0 + [1750]=17 [1774]=0 [1840]=17 [1867]=0 [1958]=4 [1969]=0 [2027]=17 [2036]=0 [2070]=17 [2094]=0 [2137]=17 [2140]=0 [2200]=17 [2208]=0 [2250]=17 [2304]=4 + [2308]=0 [2325]=15 [2366]=5 [2369]=4 [2377]=5 [2385]=17 [2389]=4 [2392]=15 [2404]=0 [2424]=15 [2436]=0 [2453]=15 [2483]=0 [2486]=15 [2497]=4 [2510]=0 + [2622]=5 [2627]=0 [2635]=4 [2638]=0 [2709]=15 [2750]=5 [2753]=4 [2766]=0 [2810]=4 [2820]=0 [2837]=15 [2881]=4 [2894]=0 [2901]=4 [2904]=0 [3014]=5 + [3022]=0 [3073]=5 [3077]=0 [3093]=15 [3134]=4 [3137]=5 [3142]=4 [3150]=0 [3160]=15 [3163]=0 [3349]=15 [3393]=4 [3398]=5 [3407]=0 [3538]=4 [3544]=5 + [3552]=0 [3636]=4 [3640]=17 [3643]=0 [3656]=17 [3660]=4 [3663]=0 [3764]=4 [3768]=17 [3773]=0 [3784]=17 [3788]=4 [3791]=0 [3957]=4 [3962]=17 [3976]=0 + [3981]=4 [4029]=0 [4141]=4 [4159]=0 [4190]=4 [4193]=0 [4209]=4 [4213]=0 [4352]=7 [4448]=8 [4520]=9 [4608]=0 [4957]=17 [4960]=0 [6071]=4 [6078]=5 + [6089]=4 [6100]=0 [6155]=4 [6160]=0 [6432]=4 [6435]=5 [6444]=0 [6451]=5 [6457]=17 [6460]=0 [6744]=4 [6765]=5 [6773]=17 [6784]=0 [6832]=17 [6863]=0 + [6912]=4 [6917]=0 [6965]=4 [6973]=5 [6981]=0 [7019]=17 [7028]=0 [7074]=4 [7086]=0 [7146]=5 [7151]=4 [7156]=0 [7204]=5 [7212]=4 [7224]=0 [7376]=17 + [7401]=0 [7616]=17 [7680]=0 [8232]=1 [8239]=0 [8288]=1 [8304]=0 [8400]=17 [8413]=4 [8421]=17 [8433]=0 [8596]=12 [8602]=0 [9193]=12 [9204]=0 [9208]=12 + [9211]=0 [9723]=12 [9862]=0 [9872]=12 [10007]=0 [10067]=12 [10072]=0 [10083]=12 [10088]=0 [10133]=12 [10136]=0 [11013]=12 [11016]=0 [11503]=17 [11506]=0 [11744]=17 + [11776]=0 [12330]=17 [12337]=0 [42608]=4 [42612]=17 [42622]=0 [43188]=5 [43206]=0 [43232]=17 [43250]=0 [43302]=4 [43307]=17 [43310]=0 [43335]=4 [43348]=0 [43360]=7 + [43389]=0 [43392]=4 [43396]=0 [43446]=4 [43454]=5 [43457]=0 [43561]=4 [43575]=0 [43698]=17 [43705]=0 [44033]=11 [55204]=0 [55216]=8 [55239]=0 [55243]=9 [55292]=0 + [55296]=13 [56320]=14 [57344]=0 [65024]=4 [65040]=0 [65056]=17 [65072]=0 [65520]=1 [65532]=0 [66422]=17 [66427]=0 [68097]=4 [68103]=0 [68152]=17 [68155]=0 [68900]=17 + [68904]=0 [69373]=17 [69376]=0 [69446]=17 [69457]=0 [69506]=17 [69510]=0 [69688]=4 [69703]=0 [69808]=5 [69811]=4 [69822]=0 [69888]=17 [69891]=0 [69927]=4 [69941]=0 + [70067]=5 [70070]=4 [70084]=0 [70188]=5 [70191]=4 [70200]=0 [70368]=5 [70371]=4 [70379]=0 [70465]=5 [70478]=0 [70502]=17 [70509]=0 [70512]=17 [70517]=0 [70709]=5 + [70712]=4 [70727]=0 [70835]=4 [70852]=0 [71090]=4 [71096]=5 [71105]=0 [71216]=5 [71219]=4 [71233]=0 [71344]=4 [71352]=0 [71453]=4 [71468]=0 [71724]=5 [71727]=4 + [71739]=0 [71985]=5 [72004]=0 [72145]=5 [72148]=4 [72156]=5 [72161]=0 [72193]=4 [72203]=0 [72245]=4 [72255]=0 [72273]=4 [72284]=0 [72324]=3 [72330]=4 [72346]=0 + [72752]=4 [72768]=0 [72850]=4 [72887]=0 [73009]=4 [73015]=0 [73023]=4 [73032]=0 [73098]=5 [73112]=0 [73526]=4 [73531]=0 [78896]=1 [78913]=0 [78919]=4 [78934]=0 + [92912]=17 [92917]=0 [92976]=17 [92983]=0 [94033]=5 [94088]=0 [94095]=4 [94099]=0 [113824]=1 [113828]=0 [118528]=4 [118599]=0 [119143]=17 [119146]=0 [119150]=17 [119155]=1 + [119163]=17 [119180]=0 [119210]=17 [119214]=0 [119362]=17 [119365]=0 [121344]=4 [121399]=0 [121403]=4 [121453]=0 [121499]=4 [121520]=0 [122880]=17 [122923]=0 [123184]=17 [123191]=0 + [123628]=17 [123632]=0 [124140]=17 [124144]=0 [125136]=17 [125143]=0 [125252]=17 [125259]=0 [126976]=12 [127232]=0 [127245]=12 [127248]=0 [127340]=12 [127346]=0 [127377]=12 [127387]=0 + [127405]=12 [127462]=6 [127489]=12 [127504]=0 [127538]=12 [127552]=0 [127561]=12 [127995]=4 [128000]=12 [128318]=0 [128326]=12 [128592]=0 [128640]=12 [128768]=0 [128884]=12 [128896]=0 + [128981]=12 [129024]=0 [129036]=12 [129040]=0 [129096]=12 [129104]=0 [129114]=12 [129120]=0 [129160]=12 [129168]=0 [129198]=12 [129280]=0 [129292]=12 [129792]=0 [130048]=12 [131070]=0 + [917504]=1 [917536]=4 [917632]=1 [917760]=4 [918000]=1 +) +_ble_unicode_GraphemeClusterBreak_ranges=( + 0 32 127 160 768 880 1155 1162 1425 1480 1536 1542 1552 1565 1611 1632 1750 1774 1840 1867 1958 1969 2027 2036 2070 2094 2137 2140 2200 2208 2250 2304 + 2308 2325 2366 2369 2377 2385 2389 2392 2404 2424 2436 2453 2483 2486 2497 2510 2622 2627 2635 2638 2709 2750 2753 2766 2810 2820 2837 2881 2894 2901 2904 3014 + 3022 3073 3077 3093 3134 3137 3142 3150 3160 3163 3349 3393 3398 3407 3538 3544 3552 3636 3640 3643 3656 3660 3663 3764 3768 3773 3784 3788 3791 3957 3962 3976 + 3981 4029 4141 4159 4190 4193 4209 4213 4352 4448 4520 4608 4957 4960 6071 6078 6089 6100 6155 6160 6432 6435 6444 6451 6457 6460 6744 6765 6773 6784 6832 6863 + 6912 6917 6965 6973 6981 7019 7028 7074 7086 7146 7151 7156 7204 7212 7224 7376 7401 7616 7680 8232 8239 8288 8304 8400 8413 8421 8433 8596 8602 9193 9204 9208 + 9211 9723 9862 9872 10007 10067 10072 10083 10088 10133 10136 11013 11016 11503 11506 11744 11776 12330 12337 42608 42612 42622 43188 43206 43232 43250 43302 43307 43310 43335 43348 43360 + 43389 43392 43396 43446 43454 43457 43561 43575 43698 43705 44033 55204 55216 55239 55243 55292 55296 56320 57344 65024 65040 65056 65072 65520 65532 66422 66427 68097 68103 68152 68155 68900 + 68904 69373 69376 69446 69457 69506 69510 69688 69703 69808 69811 69822 69888 69891 69927 69941 70067 70070 70084 70188 70191 70200 70368 70371 70379 70465 70478 70502 70509 70512 70517 70709 + 70712 70727 70835 70852 71090 71096 71105 71216 71219 71233 71344 71352 71453 71468 71724 71727 71739 71985 72004 72145 72148 72156 72161 72193 72203 72245 72255 72273 72284 72324 72330 72346 + 72752 72768 72850 72887 73009 73015 73023 73032 73098 73112 73526 73531 78896 78913 78919 78934 92912 92917 92976 92983 94033 94088 94095 94099 113824 113828 118528 118599 119143 119146 119150 119155 + 119163 119180 119210 119214 119362 119365 121344 121399 121403 121453 121499 121520 122880 122923 123184 123191 123628 123632 124140 124144 125136 125143 125252 125259 126976 127232 127245 127248 127340 127346 127377 127387 + 127405 127462 127489 127504 127538 127552 127561 127995 128000 128318 128326 128592 128640 128768 128884 128896 128981 129024 129036 129040 129096 129104 129114 129120 129160 129168 129198 129280 129292 129792 130048 131070 + 917504 917536 917632 917760 918000 921600 +) +_ble_unicode_GraphemeClusterBreak_rule=( + 0 0 1 0 1 2 0 0 0 0 0 0 0 0 0 0 1 1 + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 1 0 1 2 0 0 0 0 0 0 3 0 0 6 1 1 + 2 0 1 2 1 2 2 2 2 2 2 2 2 2 2 2 1 1 + 0 0 1 0 1 2 0 0 0 0 0 0 0 0 0 0 1 1 + 0 0 1 0 1 2 0 0 0 0 0 0 0 0 0 0 1 1 + 0 0 1 0 1 2 4 0 0 0 0 0 0 0 0 0 1 1 + 0 0 1 0 1 2 0 1 1 0 1 1 0 0 0 0 1 1 + 0 0 1 0 1 2 0 0 1 1 0 0 0 0 0 0 1 1 + 0 0 1 0 1 2 0 0 0 1 0 0 0 0 0 0 1 1 + 0 0 1 0 1 2 0 0 1 1 0 0 0 0 0 0 1 1 + 0 0 1 0 1 2 0 0 0 1 0 0 0 0 0 0 1 1 + 0 0 1 0 1 2 0 0 0 0 0 0 0 0 0 0 1 1 + 0 0 1 0 1 2 0 0 0 0 0 0 0 0 5 0 1 1 + 0 0 1 0 1 2 0 0 0 0 0 0 0 0 0 0 1 1 + 0 0 1 0 1 2 0 0 0 0 0 0 0 0 0 0 1 1 + 0 0 1 0 1 2 0 0 0 0 0 0 0 0 0 6 1 1 + 0 0 1 0 1 2 0 0 0 0 0 0 0 0 0 6 1 1 +) +_ble_unicode_GraphemeClusterBreak_custom[0x1F3FB]=$_ble_unicode_GraphemeClusterBreak_Pictographic +_ble_unicode_GraphemeClusterBreak_custom[0x1F3FC]=$_ble_unicode_GraphemeClusterBreak_Pictographic +_ble_unicode_GraphemeClusterBreak_custom[0x1F3FD]=$_ble_unicode_GraphemeClusterBreak_Pictographic +_ble_unicode_GraphemeClusterBreak_custom[0x1F3FE]=$_ble_unicode_GraphemeClusterBreak_Pictographic +_ble_unicode_GraphemeClusterBreak_custom[0x1F3FF]=$_ble_unicode_GraphemeClusterBreak_Pictographic +_ble_unicode_GraphemeClusterBreak_custom[0xFF9E]=$_ble_unicode_GraphemeClusterBreak_Other +_ble_unicode_GraphemeClusterBreak_custom[0xFF9F]=$_ble_unicode_GraphemeClusterBreak_Other +function ble/unicode/GraphemeCluster/c2break { + local code=$1 + ret=${_ble_unicode_GraphemeClusterBreak_custom[code]} + [[ $ret ]] && return 0 + ret=${_ble_unicode_GraphemeClusterBreak[code]} + [[ $ret ]] && return 0 + ((ret>_ble_unicode_GraphemeClusterBreak_MaxCode)) && { ret=0; return 0; } + local l=0 u=${#_ble_unicode_GraphemeClusterBreak_ranges[@]} m + while ((l+1/dev/null # suppress locale error #D1440 +ble/unicode/GraphemeCluster/s2break/.initialize +function ble/unicode/GraphemeCluster/s2break/.combine-surrogate { + local code1=$1 code2=$2 s=$3 + if ((0xDC00<=code2&&code2<=0xDFFF)); then + ((c=0x10000+(code1-0xD800)*1024+(code2&0x3FF))) + else + local ret + ble/util/s2bytes "$s" + ble/encoding:UTF-8/b2c "${ret[@]}" + c=$ret + fi +} +if ((_ble_unicode_GraphemeCluster_bomlen==2&&40300<=_ble_bash&&_ble_bash<50000)); then + function ble/unicode/GraphemeCluster/s2break/.wa-bash43bug-uFFFF { + local code=$1 + ((0xD7F8<=code&&code<0xD800)) && ble/util/is-unicode-output && + ret=$_ble_unicode_GraphemeClusterBreak_HighSurrogate + } +else + function ble/unicode/GraphemeCluster/s2break/.wa-bash43bug-uFFFF { ((0)); } +fi +if ((_ble_unicode_GraphemeCluster_ucs4len==2)); then + if ((_ble_bash<50000)); then + function ble/unicode/GraphemeCluster/s2break/.wa-cygwin-LSG { + local code=$1 + ((code==0)) && ble/util/is-unicode-output && + ret=$_ble_unicode_GraphemeClusterBreak_LowSurrogate + } + else + function ble/unicode/GraphemeCluster/s2break/.wa-cygwin-LSG { + local code=$1 + ((0x80<=code&&code<0xC0)) && ble/util/is-unicode-output && + ret=$_ble_unicode_GraphemeClusterBreak_LowSurrogate + } + fi +else + function ble/unicode/GraphemeCluster/s2break/.wa-cygwin-LSG { ((0)); } +fi +function ble/unicode/GraphemeCluster/s2break-left { + ret=0 + local s=$1 N=${#1} i=$2 opts=$3 sh=1 + ((i>0)) && ble/util/s2c "${s:i-1:2}"; local c=$ret code2=$ret # Note2 (上述) + ble/unicode/GraphemeCluster/c2break "$code2"; local break=$ret + ((i-1=0&&ret==_ble_unicode_GraphemeClusterBreak_LowSurrogate)); then + ble/util/s2c "${s:i-2:2}"; local code1=$ret # Note2 (上述) + ble/unicode/GraphemeCluster/c2break "$code1" + ble/unicode/GraphemeCluster/s2break/.wa-bash43bug-uFFFF "$code1" + if ((ret==_ble_unicode_GraphemeClusterBreak_HighSurrogate)); then + ble/unicode/GraphemeCluster/s2break/.combine-surrogate "$code1" "$code2" "${s:i-2:2}" + ble/unicode/GraphemeCluster/c2break "$c" + break=$ret + sh=2 + fi + elif ((i0;j-=shift)); do + ble/unicode/GraphemeCluster/s2break-left "$text" "$j" shift + ((_ble_unicode_GraphemeClusterBreak_isExtend[ret])) || break + done + if ((j==0||ret!=_ble_unicode_GraphemeClusterBreak_Pictographic)); then + ((ret=i)) + return 0 + else + ((i=j-shift,b1=ret)) + return 1 + fi +} +function ble/unicode/GraphemeCluster/find-previous-boundary/.RI { + if [[ :$bleopt_emoji_opts: != *:ri:* ]]; then + ((ret=i)) + return 0 + fi + local j1=$((i-shift)) + local j shift=1 countRI=1 + for ((j=j1;j>0;j-=shift,countRI++)); do + ble/unicode/GraphemeCluster/s2break-left "$text" "$j" shift + ((ret==_ble_unicode_GraphemeClusterBreak_Regional_Indicator)) || break + done + if ((j==j1)); then + ((i=j,b1=_ble_unicode_GraphemeClusterBreak_Regional_Indicator)) + return 1 + else + ((ret=countRI%2==1?j1:i)) + return 0 + fi +} +function ble/unicode/GraphemeCluster/find-previous-boundary/.InCB { + if [[ $bleopt_grapheme_cluster != extended ]] || ((_ble_unicode_c2w_version<17)); then + ret=$i + return 0 + fi + local out=$i j=$i count_linker=0 + local b1=$b1 shift=$shift + while + case $b1 in + ("$_ble_unicode_GraphemeClusterBreak_InCB_Consonant") + if ((count_linker)); then + count_linker=0 + ((out=j-shift)) + fi ;; + ("$_ble_unicode_GraphemeClusterBreak_InCB_Linker") + ((count_linker++)) ;; + ("$_ble_unicode_GraphemeClusterBreak_InCB_Extend"|"$_ble_unicode_GraphemeClusterBreak_ZWJ") ;; + (*) break ;; + esac + ((j-=shift,j>0)) + do + ble/unicode/GraphemeCluster/s2break-left "$text" "$j" shift + b1=$ret + done + if ((out0)); do + local b2=$b1 + ble/unicode/GraphemeCluster/s2break-left "$text" "$i" shift; local b1=$ret + case ${_ble_unicode_GraphemeClusterBreak_rule[b1*_ble_unicode_GraphemeClusterBreak_Count+b2]} in + (0) break ;; + (1) ((i-=shift)) ;; + (2) [[ $bleopt_grapheme_cluster != extended ]] && break; ((i-=shift)) ;; + (3) ble/unicode/GraphemeCluster/find-previous-boundary/.ZWJ && return 0 ;; + (4) ble/unicode/GraphemeCluster/find-previous-boundary/.RI && return 0 ;; + (6) ble/unicode/GraphemeCluster/find-previous-boundary/.InCB && return 0;; + (5) + ((i-=shift)) + ble/unicode/GraphemeCluster/s2break-right "$text" "$i"; b1=$ret ;; + esac + done + fi + ret=$i + return 0 +} +_ble_unicode_GraphemeClusterBreak_isCore=() +_ble_unicode_GraphemeClusterBreak_isCore[_ble_unicode_GraphemeClusterBreak_Other]=1 +_ble_unicode_GraphemeClusterBreak_isCore[_ble_unicode_GraphemeClusterBreak_Control]=1 +_ble_unicode_GraphemeClusterBreak_isCore[_ble_unicode_GraphemeClusterBreak_Regional_Indicator]=1 +_ble_unicode_GraphemeClusterBreak_isCore[_ble_unicode_GraphemeClusterBreak_L]=1 +_ble_unicode_GraphemeClusterBreak_isCore[_ble_unicode_GraphemeClusterBreak_V]=1 +_ble_unicode_GraphemeClusterBreak_isCore[_ble_unicode_GraphemeClusterBreak_T]=1 +_ble_unicode_GraphemeClusterBreak_isCore[_ble_unicode_GraphemeClusterBreak_LV]=1 +_ble_unicode_GraphemeClusterBreak_isCore[_ble_unicode_GraphemeClusterBreak_LVT]=1 +_ble_unicode_GraphemeClusterBreak_isCore[_ble_unicode_GraphemeClusterBreak_Pictographic]=1 +_ble_unicode_GraphemeClusterBreak_isCore[_ble_unicode_GraphemeClusterBreak_HighSurrogate]=1 +_ble_unicode_GraphemeClusterBreak_isCore[_ble_unicode_GraphemeClusterBreak_InCB_Consonant]=1 +_ble_unicode_GraphemeClusterBreak_isExtend=() +_ble_unicode_GraphemeClusterBreak_isExtend[_ble_unicode_GraphemeClusterBreak_Extend]=1 +_ble_unicode_GraphemeClusterBreak_isExtend[_ble_unicode_GraphemeClusterBreak_InCB_Extend]=1 +_ble_unicode_GraphemeClusterBreak_isExtend[_ble_unicode_GraphemeClusterBreak_InCB_Linker]=1 +function ble/unicode/GraphemeCluster/extend-ascii { + extend=0 + [[ $_ble_util_locale_encoding != UTF-8 || ! $bleopt_grapheme_cluster ]] && return 1 + local text=$1 iN=${#1} i=$2 ret shift=1 + for ((;i=iN)); then + c=0 w=0 cs= cb= extend=0 + return 1 + elif ! ble/util/is-unicode-output || [[ ! $bleopt_grapheme_cluster ]]; then + cs=${text:i:1} + ble/util/s2c "$cs"; c=$ret + if [[ $flags != *R* ]] && { + ble/unicode/GraphemeCluster/c2break "$c" + ((ret==_ble_unicode_GraphemeClusterBreak_Control)); }; then + ble/unicode/GraphemeCluster/.get-ascii-rep "$c" + w=${#cs} + else + ble/util/c2w "$c"; w=$ret + fi + extend=0 + return 0 + fi + local b0 b1 b2 c0 c2 shift code + ble/unicode/GraphemeCluster/s2break-right "$text" "$i" code:shift; c0=$code b0=$ret + local coreb= corec= npre=0 vs= ri= InCB_state= + c2=$c0 b2=$b0 + while ((j=17&&InCB_state)) || + break ;; + (5) + ble/unicode/GraphemeCluster/s2break-left "$text" "$((j+shift))" code; c2=$code b2=$ret ;; + esac + done + c=$corec cb=$coreb cs=${text:i:j-i} + ((extend=j-i-1)) + if [[ ! $corec ]]; then + if [[ $flags != *R* ]]; then + ((c=c0,cb=0,corec=0x25CC)) # 基底が存在しない時は点線円 + ble/util/c2s "$corec" + cs=${text:i:npre}$ret${text:i+npre:j-i-npre} + else + local code + ble/unicode/GraphemeCluster/s2break-right "$cs" 0 code + c=$code corec=$code cb=$ret + fi + fi + if ((cb==_ble_unicode_GraphemeClusterBreak_Control)); then + if [[ $flags != *R* ]]; then + ble/unicode/GraphemeCluster/.get-ascii-rep "$c" + w=${#cs} + else + w=0 + fi + else + if [[ $vs == tpvs && :$bleopt_emoji_opts: == *:tpvs:* ]]; then + bleopt_emoji_width= ble/util/c2w "$corec"; w=$ret + elif [[ $vs == epvs && :$bleopt_emoji_opts: == *:epvs:* ]]; then + w=${bleopt_emoji_width:-2} + else + ble/util/c2w "$corec"; w=$ret + fi + fi + return 0 +} +function ble/canvas/attach { + ble/util/c2w:auto/check +} +function ble/canvas/put.draw { + DRAW_BUFF[${#DRAW_BUFF[*]}]=$1 +} +function ble/canvas/put-ind.draw { + local count=${1-1} ind=$_ble_term_ind + [[ :$2: == *:true-ind:* ]] && ind=$'\eD' + local ret; ble/string#repeat "$ind" "$count" + DRAW_BUFF[${#DRAW_BUFF[*]}]=$ret +} +function ble/canvas/put-ri.draw { + local count=${1-1} + local ret; ble/string#repeat "$_ble_term_ri" "$count" + DRAW_BUFF[${#DRAW_BUFF[*]}]=$ret +} +function ble/canvas/put-il.draw { + local value=${1-1} + ((value>0)) || return 0 + DRAW_BUFF[${#DRAW_BUFF[*]}]=${_ble_term_il//'%d'/$value} + DRAW_BUFF[${#DRAW_BUFF[*]}]=$_ble_term_el2 # Note #D1214: 最終行対策 cygwin, linux +} +function ble/canvas/put-dl.draw { + local value=${1-1} + ((value>0)) || return 0 + DRAW_BUFF[${#DRAW_BUFF[*]}]=$_ble_term_el2 # Note #D1214: 最終行対策 cygwin, linux + DRAW_BUFF[${#DRAW_BUFF[*]}]=${_ble_term_dl//'%d'/$value} +} +if ((_ble_bash>=40000)) && [[ ( $OSTYPE == cygwin || $OSTYPE == msys ) && $TERM == xterm-256color ]]; then + function ble/canvas/.is-il-workaround-required { + local value=$1 opts=$2 + [[ ! $_ble_term_DA2R ]] || return 1 + ((value==1)) || return 1 + [[ :$opts: == *:vfill:* || :$opts: == *:no-lastline:* ]] && return 1 + [[ :$opts: == *:panel:* ]] && + ! ble/canvas/panel/is-last-line && + return 1 + return 0 + } + function ble/canvas/put-il.draw { + local value=${1-1} opts=$2 + ((value>0)) || return 0 + if ble/canvas/.is-il-workaround-required "$value" "$2"; then + if [[ :$opts: == *:panel:* ]]; then + DRAW_BUFF[${#DRAW_BUFF[*]}]=$_ble_term_el2 + else + DRAW_BUFF[${#DRAW_BUFF[*]}]=$'\e[S\e[A\e[L\e[B\e[T' + fi + else + DRAW_BUFF[${#DRAW_BUFF[*]}]=${_ble_term_il//'%d'/$value} + DRAW_BUFF[${#DRAW_BUFF[*]}]=$_ble_term_el2 # Note #D1214: 最終行対策 cygwin, linux + fi + } + function ble/canvas/put-dl.draw { + local value=${1-1} opts=$2 + ((value>0)) || return 0 + if ble/canvas/.is-il-workaround-required "$value" "$2"; then + if [[ :$opts: == *:panel:* ]]; then + DRAW_BUFF[${#DRAW_BUFF[*]}]=$_ble_term_el2 + else + DRAW_BUFF[${#DRAW_BUFF[*]}]=$'\e[S\e[A\e[M\e[B\e[T' + fi + else + DRAW_BUFF[${#DRAW_BUFF[*]}]=$_ble_term_el2 # Note #D1214: 最終行対策 cygwin, linux + DRAW_BUFF[${#DRAW_BUFF[*]}]=${_ble_term_dl//'%d'/$value} + fi + } +fi +function ble/canvas/put-cuu.draw { + local value=${1-1} + DRAW_BUFF[${#DRAW_BUFF[*]}]=${_ble_term_cuu//'%d'/$value} +} +function ble/canvas/put-cud.draw { + local value=${1-1} + DRAW_BUFF[${#DRAW_BUFF[*]}]=${_ble_term_cud//'%d'/$value} +} +function ble/canvas/put-cuf.draw { + local value=${1-1} + DRAW_BUFF[${#DRAW_BUFF[*]}]=${_ble_term_cuf//'%d'/$value} +} +function ble/canvas/put-cub.draw { + local value=${1-1} + DRAW_BUFF[${#DRAW_BUFF[*]}]=${_ble_term_cub//'%d'/$value} +} +function ble/canvas/put-cup.draw { + local l=${1-1} c=${2-1} + local out=$_ble_term_cup + out=${out//'%l'/$l} + out=${out//'%c'/$c} + out=${out//'%y'/$((l-1))} + out=${out//'%x'/$((c-1))} + DRAW_BUFF[${#DRAW_BUFF[*]}]=$out +} +function ble/canvas/put-hpa.draw { + local c=${1-1} + local out=$_ble_term_hpa + out=${out//'%c'/$c} + out=${out//'%x'/$((c-1))} + DRAW_BUFF[${#DRAW_BUFF[*]}]=$out +} +function ble/canvas/put-vpa.draw { + local l=${1-1} + local out=$_ble_term_vpa + out=${out//'%l'/$l} + out=${out//'%y'/$((l-1))} + DRAW_BUFF[${#DRAW_BUFF[*]}]=$out +} +function ble/canvas/put-ech.draw { + local value=${1:-1} esc + if [[ $_ble_term_ech ]]; then + esc=${_ble_term_ech//'%d'/$value} + else + ble/string#reserve-prototype "$value" + esc=${_ble_string_prototype::value}${_ble_term_cub//'%d'/$value} + fi + DRAW_BUFF[${#DRAW_BUFF[*]}]=$esc +} +function ble/canvas/put-spaces.draw { + local value=${1:-1} + ble/string#reserve-prototype "$value" + DRAW_BUFF[${#DRAW_BUFF[*]}]=${_ble_string_prototype::value} +} +function ble/canvas/put-move-x.draw { + local dx=$1 + ((dx)) || return 1 + if ((dx>0)); then + ble/canvas/put-cuf.draw "$dx" + else + ble/canvas/put-cub.draw "$((-dx))" + fi +} +function ble/canvas/put-move-y.draw { + local dy=$1 + ((dy)) || return 1 + if ((dy>0)); then + if [[ $MC_SID == $$ ]]; then + ble/canvas/put-ind.draw "$dy" true-ind + else + ble/canvas/put-cud.draw "$dy" + fi + else + ble/canvas/put-cuu.draw "$((-dy))" + fi +} +function ble/canvas/put-move.draw { + ble/canvas/put-move-x.draw "$1" + ble/canvas/put-move-y.draw "$2" +} +function ble/canvas/flush.draw { + IFS= builtin eval 'ble/util/put "${DRAW_BUFF[*]}"' + DRAW_BUFF=() +} +function ble/canvas/sflush.draw { + local _ble_local_var=ret + [[ $1 == -v ]] && _ble_local_var=$2 + IFS= builtin eval "$_ble_local_var=\"\${DRAW_BUFF[*]}\"" + DRAW_BUFF=() +} +function ble/canvas/bflush.draw { + IFS= builtin eval 'ble/util/buffer "${DRAW_BUFF[*]}"' + DRAW_BUFF=() +} +function ble/canvas/put-clear-lines.draw { + local old=${1:-1} + local new=${2:-$old} + if ((old==1&&new==1)); then + ble/canvas/put.draw "$_ble_term_el2" + else + ble/canvas/put-dl.draw "$old" "$3" + ble/canvas/put-il.draw "$new" "$3" + fi +} +function ble/canvas/trace/.put-sgr.draw { + local ret g=$1 + if ((g==0)); then + ble/canvas/put.draw "$opt_sgr0" + else + ble/color/g.compose "$opt_g0" "$g" + "$trace_g2sgr" "$g" + ble/canvas/put.draw "$ret" + fi +} +function ble/canvas/trace/.measure-point { + if [[ $flag_bbox ]]; then + ((x0)) || return 0 + if [[ $flag_gbox ]]; then + if [[ ! $gx1 ]]; then + ((gx1=gx2=x,gy1=gy2=y)) + else + ((xx2)) && x2=$x + [[ $flag_gbox ]] && ((x>gx2)) && gx2=$x + if ((x==cols&&!xenl)); then + ((y++,x=0)) + if [[ $flag_bbox ]]; then + ((xy2)) && y2=$y + fi + fi + else + if [[ $type == atomic ]]; then + ((y++,x=w0&&(x1=0))) + ((x2y2)) && y2=$y + fi + if [[ $flag_gbox ]]; then + ((gx1>0&&(gx1=0))) + ((gx2gy2)) && gy2=$y + fi + fi + ((x==0&&(lc=32,lg=0))) + return 0 +} +function ble/canvas/trace/.put-atomic.draw { + local c=$1 w=$2 + if [[ $flag_clip ]]; then + ((cy1<=y&&ycx2)) && value=${value::${#value}-(xR-cx2)} xR=$cx2 + ble/canvas/put-move.draw "$((x-cx))" "$((y-cy))" + ble/canvas/put.draw "$value" + ((cx=xR,cy=y)) + else + ble/canvas/put.draw "$value" + fi + ble/canvas/trace/.implicit-move "$w" +} +function ble/canvas/trace/.process-overflow { + [[ :$opts: == *:truncate:* ]] && i=$iN # stop + if ((y+1==lines)) && [[ :$opts: == *:ellipsis:* ]]; then + local ellipsis=... w=3 wmax=$xlimit + ((w>wmax)) && ellipsis=${ellipsis::wmax} w=$wmax + if ble/util/is-unicode-output; then + local symbol='…' ret + ble/util/s2c "$symbol" + ble/util/c2w "$ret" + ((ret<=wmax)) && ellipsis=$symbol w=$ret + fi + local ox=$x oy=$y + ble/canvas/trace/.goto "$((wmax-w))" "$((lines-1))" + ble/canvas/trace/.put-atomic.draw "$ellipsis" "$w" + ble/canvas/trace/.goto "$ox" "$oy" + fi +} +function ble/canvas/trace/.justify/inc-quote { + [[ $trace_flags == *J* ]] || return 0 + ((trace_sclevel++)) + flag_justify= +} +function ble/canvas/trace/.justify/dec-quote { + [[ $trace_flags == *J* ]] || return 0 + ((--trace_sclevel)) || flag_justify=1 +} +function ble/canvas/trace/.justify/begin-line { + ((jx0=x1=x2=x,jy0=y1=y2=y)) + gx1= gx2= gy1= gy2= + [[ $justify_align == *[cr]* ]] && + ble/canvas/trace/.justify/next-field +} +function ble/canvas/trace/.justify/next-field { + local sep=$1 wmin=0 + local esc; ble/canvas/sflush.draw -v esc + [[ $sep == ' ' ]] && wmin=1 + ble/array#push justify_fields "${sep:-\$}:$wmin:$jx0,$jy0,$x,$y:$x1,$y1,$x2,$y2:$gx1,$gy1,$gx2,$gy2:$esc" + ((x+=wmin,jx0=x1=x2=x,jy0=y1=y2=y)) +} +function ble/canvas/trace/.justify/unpack { + local data=$1 buff + sep=${data::1}; data=${data:2} + wmin=${data%%:*}; data=${data#*:} + ble/string#split buff , "${data%%:*}"; data=${data#*:} + xI=${buff[0]} yI=${buff[1]} xF=${buff[2]} yF=${buff[3]} + ble/string#split buff , "${data%%:*}"; data=${data#*:} + x1=${buff[0]} y1=${buff[1]} x2=${buff[2]} y2=${buff[3]} + ble/string#split buff , "${data%%:*}"; data=${data#*:} + gx1=${buff[0]} gy1=${buff[1]} gx2=${buff[2]} gy2=${buff[3]} + esc=$data +} +function ble/canvas/trace/.justify/end-line { + if [[ $trace_flags == *B* ]]; then + ((yjy2&&(jy2=y))) + fi + ((${#justify_fields[@]}||${#DRAW_BUFF[@]})) || return 0 + ble/canvas/trace/.justify/next-field + [[ $justify_align == *c* ]] && + ble/canvas/trace/.justify/next-field + local i width=0 ispan=0 has_content= + for ((i=0;i<${#justify_fields[@]};i++)); do + local sep wmin xI yI xF yF x1 y1 x2 y2 gx1 gy1 gx2 gy2 esc + ble/canvas/trace/.justify/unpack "${justify_fields[i]}" + ((width+=xF-xI)) + [[ $esc ]] && has_content=1 + ((i+1==${#justify_fields[@]})) && break + ((width+=wmin)) + ((ispan++)) + done + if [[ ! $has_content ]]; then + justify_fields=() + return 0 + fi + local nspan=$ispan + local -a DRAW_BUFF=() + local xlimit=$cols + [[ $_ble_term_xenl$opt_relative ]] || ((xlimit--)) + local span=$((xlimit-width)) + x= y= + local ispan=0 vx=0 spanx=0 + for ((i=0;i<${#justify_fields[@]};i++)); do + local sep wmin xI yI xF yF x1 y1 x2 y2 gx1 gy1 gx2 gy2 esc + ble/canvas/trace/.justify/unpack "${justify_fields[i]}" + if [[ ! $x ]]; then + x=$xI y=$yI + if [[ $justify_align == right ]]; then + ble/canvas/put-move-x.draw "$((cols-1-x))" + ((x=cols-1)) + fi + fi + if [[ $esc ]]; then + local delta=0 + ((vx+x1-xI<0)) && ((delta=-(vx+x1-xI))) + ((vx+x2-xI>xlimit)) && ((delta=xlimit-(vx+x2-xI))) + ble/canvas/put-move-x.draw "$((vx+delta-x))" + ((x=vx+delta)) + ble/canvas/put.draw "$esc" + if [[ $trace_flags == *B* ]]; then + ((x+x1-xIjx2&&(jx2=x+x2-xI))) + ((y+y2-yI>jy2&&(jy2=y+y2-yI))) + fi + if [[ $flag_gbox && $gx1 ]]; then + ((gx1+=x-xI,gx2+=x-xI)) + ((gy1+=y-yI,gy2+=y-yI)) + if [[ ! $jgx1 ]]; then + ((jgx1=gx1,jgy1=gy1,jgx2=gx2,jgy2=gy2)) + else + ((gx1jgx2&&(jgx2=gx2))) + ((gy2>jgy2&&(jgy2=gy2))) + fi + fi + ((x+=xF-xI,y+=yF-yI,vx+=xF-xI)) + fi + ((i+1==${#justify_fields[@]})) && break + local new_spanx=$((span*++ispan/nspan)) + local wfill=$((wmin+new_spanx-spanx)) + ((vx+=wfill,spanx=new_spanx)) + if [[ $sep == ' ' ]]; then + ble/string#reserve-prototype "$wfill" + ble/canvas/put.draw "${_ble_string_prototype::wfill}" + ((x+=wfill)) + fi + done + local ret + ble/canvas/sflush.draw + ble/array#push justify_buff "$ret" + justify_fields=() +} +function ble/canvas/trace/.decsc { + [[ ${trace_decsc[5]} ]] || ble/canvas/trace/.justify/inc-quote + trace_decsc=("$x" "$y" "$g" "$lc" "$lg" active) + if [[ ! $flag_clip ]]; then + [[ :$opts: == *:noscrc:* ]] || + ble/canvas/put.draw "$_ble_term_sc" + fi +} +function ble/canvas/trace/.decrc { + [[ ${trace_decsc[5]} ]] && ble/canvas/trace/.justify/dec-quote + if [[ ! $flag_clip ]]; then + ble/canvas/trace/.put-sgr.draw "${trace_decsc[2]}" # g を明示的に復元。 + if [[ :$opts: == *:noscrc:* ]]; then + ble/canvas/put-move.draw "$((trace_decsc[0]-x))" "$((trace_decsc[1]-y))" + else + ble/canvas/put.draw "$_ble_term_rc" + fi + fi + x=${trace_decsc[0]} + y=${trace_decsc[1]} + g=${trace_decsc[2]} + lc=${trace_decsc[3]} + lg=${trace_decsc[4]} + trace_decsc[5]= +} +function ble/canvas/trace/.scosc { + [[ ${trace_scosc[5]} ]] || ble/canvas/trace/.justify/inc-quote + trace_scosc=("$x" "$y" "$g" "$lc" "$lg" active) + if [[ ! $flag_clip ]]; then + [[ :$opts: == *:noscrc:* ]] || + ble/canvas/put.draw "$_ble_term_sc" + fi +} +function ble/canvas/trace/.scorc { + [[ ${trace_scosc[5]} ]] && ble/canvas/trace/.justify/dec-quote + if [[ ! $flag_clip ]]; then + ble/canvas/trace/.put-sgr.draw "$g" # g は変わらない様に。 + if [[ :$opts: == *:noscrc:* ]]; then + ble/canvas/put-move.draw "$((trace_scosc[0]-x))" "$((trace_scosc[1]-y))" + else + ble/canvas/put.draw "$_ble_term_rc" + fi + fi + x=${trace_scosc[0]} + y=${trace_scosc[1]} + lc=${trace_scosc[3]} + lg=${trace_scosc[4]} + trace_scosc[5]= +} +function ble/canvas/trace/.ps1sc { + ble/canvas/trace/.justify/inc-quote + trace_brack[${#trace_brack[*]}]="$x $y" +} +function ble/canvas/trace/.ps1rc { + local lastIndex=$((${#trace_brack[*]}-1)) + if ((lastIndex>=0)); then + ble/canvas/trace/.justify/dec-quote + local -a scosc + ble/string#split-words scosc "${trace_brack[lastIndex]}" + ((x=scosc[0])) + ((y=scosc[1])) + builtin unset -v "trace_brack[$lastIndex]" + fi +} +function ble/canvas/trace/.NEL { + if [[ $opt_nooverflow ]] && ((y+1>=lines)); then + ble/canvas/trace/.process-overflow + return 1 + fi + [[ $flag_justify ]] && + ble/canvas/trace/.justify/end-line + if [[ ! $flag_clip ]]; then + if [[ $opt_relative ]]; then + ((x)) && ble/canvas/put-cub.draw "$x" + ble/canvas/put-cud.draw 1 + else + ble/canvas/put.draw "$_ble_term_cr" + ble/canvas/put.draw "$_ble_term_nl" + fi + fi + ((y++,x=0,lc=32,lg=0)) + if [[ $flag_bbox ]]; then + ((xy2)) && y2=$y + fi + [[ $flag_justify ]] && + ble/canvas/trace/.justify/begin-line + return 0 +} +function ble/canvas/trace/.SGR { + local param=$1 seq=$2 specs i iN + if [[ ! $param ]]; then + g=0 + [[ $flag_clip ]] || ble/canvas/put.draw "$opt_sgr0" + return 0 + fi + if [[ $opt_terminfo ]]; then + ble/color/read-sgrspec "$param" + else + ble/color/read-sgrspec "$param" ansi + fi + [[ $flag_clip ]] || ble/canvas/trace/.put-sgr.draw "$g" +} +function ble/canvas/trace/.process-csi-sequence { + local seq=$1 seq1=${1:2} rex + local char=${seq1:${#seq1}-1:1} param=${seq1::${#seq1}-1} + if [[ ! ${param//[0-9:;]} ]]; then + case $char in + (m) # SGR + ble/canvas/trace/.SGR "$param" "$seq" + return 0 ;; + ([ABCDEFGIZ\`ade]) + local arg=0 + [[ $param =~ ^[0-9]+$ ]] && ((arg=10#0$param)) + ((arg==0&&(arg=1))) + local ox=$x oy=$y + if [[ $char == A ]]; then + ((y-=arg,y<0&&(y=0))) + ((!flag_clip&&y=lines&&(y=lines-1))) + ((!flag_clip&&y>oy)) && ble/canvas/put-cud.draw "$((y-oy))" + elif [[ $char == [Ca] ]]; then + ((x+=arg,x>=cols&&(x=cols-1))) + ((!flag_clip&&x>ox)) && ble/canvas/put-cuf.draw "$((x-ox))" + elif [[ $char == D ]]; then + ((x-=arg,x<0&&(x=0))) + ((!flag_clip&&x=lines&&(y=lines-1),x=0)) + if [[ ! $flag_clip ]]; then + ((y>oy)) && ble/canvas/put-cud.draw "$((y-oy))" + ble/canvas/put.draw "$_ble_term_cr" + fi + elif [[ $char == F ]]; then + ((y-=arg,y<0&&(y=0),x=0)) + if [[ ! $flag_clip ]]; then + ((y=cols&&(x=cols-1))) + if [[ ! $flag_clip ]]; then + if [[ $opt_relative ]]; then + ble/canvas/put-move-x.draw "$((x-ox))" + else + ble/canvas/put-hpa.draw "$((x+1))" + fi + fi + elif [[ $char == d ]]; then + ((y=arg-1,y<0&&(y=0),y>=lines&&(y=lines-1))) + if [[ ! $flag_clip ]]; then + if [[ $opt_relative ]]; then + ble/canvas/put-move-y.draw "$((y-oy))" + else + ble/canvas/put-vpa.draw "$((y+1))" + fi + fi + elif [[ $char == I ]]; then + local tx + ((tx=(x/it+arg)*it, + tx>=cols&&(tx=cols-1))) + if ((tx>x)); then + [[ $flag_clip ]] || ble/canvas/put-cuf.draw "$((tx-x))" + ((x=tx)) + fi + elif [[ $char == Z ]]; then + local tx + ((tx=((x+it-1)/it-arg)*it, + tx<0&&(tx=0))) + if ((tx=cols&&(dstx=cols-1), + dsty<0&&(dsty=0),dsty>=lines&&(dsty=lines-1))) + ble/canvas/trace/.goto "$dstx" "$dsty" + lc=-1 lg=0 + return 0 ;; + ([su]) # SCOSC SCORC + if [[ $char == s ]]; then + ble/canvas/trace/.scosc + else + ble/canvas/trace/.scorc + fi + return 0 ;; + esac + fi + ble/canvas/put.draw "$seq" +} +function ble/canvas/trace/.process-esc-sequence { + local seq=$1 char=${1:1} + case $char in + (7) # DECSC + ble/canvas/trace/.decsc + return 0 ;; + (8) # DECRC + ble/canvas/trace/.decrc + return 0 ;; + (D) # IND + [[ $opt_nooverflow ]] && ((y+1>=lines)) && return 0 + if [[ $flag_clip || $opt_relative || $flag_justify ]]; then + ((y+1>=lines)) && return 0 + ((y++)) + [[ $flag_clip ]] || + ble/canvas/put-cud.draw 1 + else + ((y++)) + ble/canvas/put.draw "$_ble_term_ind" + [[ $_ble_term_ind != $'\eD' ]] && + ble/canvas/put-hpa.draw "$((x+1))" # tput ind が唯の改行の時がある + fi + lc=-1 lg=0 + ble/canvas/trace/.measure-point + return 0 ;; + (M) # RI + [[ $opt_nooverflow ]] && ((y==0)) && return 0 + if [[ $flag_clip || $opt_relative || $flag_justify ]]; then + ((y==0)) && return 0 + ((y--)) + [[ $flag_clip ]] || + ble/canvas/put-cuu.draw 1 + else + ((y--)) + ble/canvas/put.draw "$_ble_term_ri" + fi + lc=-1 lg=0 + ble/canvas/trace/.measure-point + return 0 ;; + (E) # NEL + ble/canvas/trace/.NEL + return 0 ;; + esac + ble/canvas/put.draw "$seq" +} +function ble/canvas/trace/.impl { + local text=$1 opts=$2 + local LC_ALL= LC_COLLATE=C + local cols=${COLUMNS:-80} lines=${LINES:-25} + local it=${bleopt_tab_width:-$_ble_term_it} xenl=$_ble_term_xenl + ble/string#reserve-prototype "$it" + local ret rex + ble/util/c2s 156; local st=$ret # œ (ST) + ((${#st}>=2)) && st= + local xinit=$x yinit=$y ginit=$g + local trace_flags= + local opt_nooverflow=; [[ :$opts: == *:truncate:* || :$opts: == *:confine:* ]] && opt_nooverflow=1 + local opt_relative=; [[ :$opts: == *:relative:* ]] && trace_flags=R$trace_flags opt_relative=1 + [[ :$opts: == *:measure-bbox:* ]] && trace_flags=B$trace_flags + [[ :$opts: == *:measure-gbox:* ]] && trace_flags=G$trace_flags + [[ :$opts: == *:left-char:* ]] && trace_flags=L$trace_flags + local opt_terminfo=; [[ :$opts: == *:terminfo:* ]] && opt_terminfo=1 + if local rex=':(justify(=[^:]+)?|center|right):'; [[ :$opts: =~ $rex ]]; then + trace_flags=J$trace_flags + local jx0=$x jy0=$y + local justify_sep= justify_align= + local -a justify_buff=() + local -a justify_fields=() + case ${BASH_REMATCH[1]} in + (justify*) justify_sep=${BASH_REMATCH[2]:1}${BASH_REMATCH[2]:-' '} ;; + (center) justify_align=c ;; + (right) justify_align=r ;; + esac + fi + if local rex=':clip=([0-9]*),([0-9]*)([-+])([0-9]*),([0-9]*):'; [[ :$opts: =~ $rex ]]; then + local cx1 cy1 cx2 cy2 cx cy cg + trace_flags=C$trace_flags + cx1=${BASH_REMATCH[1]} cy1=${BASH_REMATCH[2]} + cx2=${BASH_REMATCH[4]} cy2=${BASH_REMATCH[5]} + [[ ${BASH_REMATCH[3]} == + ]] && ((cx2+=cx1,cy2+=cy1)) + ((cx1<=cx2)) || local cx1=$cx2 cx2=$cx1 + ((cy1<=cy2)) || local cy1=$cy2 cy2=$cy1 + ((cx1<0)) && cx1=0 + ((cy1<0)) && cy1=0 + ((cols0)); then + [[ $flag_clip ]] || ble/canvas/put.draw "$s" + ((x--,lc=32,lg=g)) + ble/canvas/trace/.measure-point + fi ;; + ($'\t') # HT + local tx + ((tx=(x+it)/it*it, + tx>=cols&&(tx=cols-1))) + if ((xwmax)) && w=$wmax is_overflow=1 + fi + local t=${s::w} + if [[ $flag_clip || $opt_relative || $flag_justify ]]; then + local tlen=$w len=$((cols-x)) + if ((tlen>len)); then + while ((tlen>len)); do + ble/canvas/trace/.put-ascii.draw "${t::len}" + t=${t:len} + ((x=cols,tlen-=len,len=cols)) + ble/canvas/trace/.NEL + done + w=${#t} + fi + fi + if [[ $flag_lchar ]]; then + local ret + ble/util/s2c "${s:w-1:1}" + lc=$ret lg=$g + fi + ble/canvas/trace/.put-ascii.draw "$t" + ((i+=${#s})) + if local extend; ble/unicode/GraphemeCluster/extend-ascii "$text" "$i"; then + ble/canvas/trace/.put-atomic.draw "${text:i:extend}" 0 + ((i+=extend)) + fi + else + local c w cs cb extend + ble/unicode/GraphemeCluster/match "$text" "$i" R + if [[ $opt_nooverflow ]] && ! ((x+w<=xlimit||y+1cols)); then + if [[ $flag_clip || $opt_relative || $flag_justify ]]; then + ble/canvas/trace/.NEL + else + ble/canvas/trace/.put-ascii.draw "${_ble_string_prototype::cols-x}" + fi + fi + lc=$c lg=$g + ble/canvas/trace/.put-atomic.draw "$cs" "$w" + fi + ((i+=1+extend)) + fi + [[ $is_overflow ]] && ble/canvas/trace/.process-overflow + done + if [[ $trace_flags == *J* ]]; then + if [[ ! $flag_justify ]]; then + [[ ${trace_scosc[5]} ]] && ble/canvas/trace/.scorc + [[ ${trace_decsc[5]} ]] && ble/canvas/trace/.decrc + while [[ ${trace_brack[0]} ]]; do ble/canvas/trace/.ps1rc; done + fi + ble/canvas/trace/.justify/end-line + DRAW_BUFF=("${justify_buff[@]}") + [[ $trace_flags == *B* ]] && + ((x1=jx1,y1=jy1,x2=jx2,y2=jy2)) + [[ $trace_flags == *G* ]] && + gx1=$jgx1 gy1=$jgy1 gx2=$jgx2 gy2=$jgy2 + if [[ $trace_flags == *C* ]]; then + ble/canvas/sflush.draw + x=$xinit y=$yinit g=$ginit + local trace_opts=clip=$cx1,$cy1-$cx2,$cy2 + [[ :$opts: == *:ansi:* ]] && trace_opts=$trace_opts:ansi + ble/canvas/trace/.impl "$ret" "$trace_opts" + cx=$x cy=$y cg=$g + fi + fi + [[ $trace_flags == *B* ]] && ((y2++)) + [[ $trace_flags == *G* ]] && ((gy2++)) + if [[ $trace_flags == *C* ]]; then + x=$cx y=$cy g=$cg + if [[ $trace_flags == *B* ]]; then + ((x1cx2)) && x1=$cx2 + ((x2cx2)) && x2=$cx2 + ((y1cy2)) && y1=$cy2 + ((y2cy2)) && y2=$cy2 + fi + if [[ $trace_flags == *G* ]]; then + if ((gx2<=cx1||cx2<=gx1||gy2<=cy1||cy2<=gy1)); then + gx1= gx2= gy1= gy2= + else + ((gx1cx2)) && gx2=$cx2 + ((gy1cy2)) && gy2=$cy2 + fi + fi + fi +} +function ble/canvas/trace.draw { + ble/canvas/trace/.impl "$@" 2>/dev/null # Note: suppress LC_COLLATE errors #D1205 #D1341 #D1440 +} +function ble/canvas/trace { + local -a DRAW_BUFF=() + ble/canvas/trace/.impl "$@" 2>/dev/null # Note: suppress LC_COLLATE errors #D1205 #D1341 #D1440 + ble/canvas/sflush.draw # -> ret +} +function ble/canvas/trace-text/.put-simple { + local nchar=$1 + ((nchar)) || return 0 + local nput=$((cols*lines-!_ble_term_xenl-(y*cols+x))) + ((nput>0)) || return 1 + ((nput>nchar)) && nput=$nchar + out=$out${2::nput} + ((x+=nput,y+=x/cols,x%=cols)) + ((_ble_term_xenl&&x==0&&(y--,x=cols))) + ((nput==nchar)); return "$?" +} +function ble/canvas/trace-text/.put-atomic { + local w=$1 c=$2 + ((y*cols+x+w<=cols*lines-!_ble_term_xenl)) || return 1 + if ((xlimit)); then + ble/string#reserve-prototype "$((limit-x))" + local pad=${_ble_string_prototype::limit-x} + out=$out$sgr1${pad//?/'#'}$sgr0 + x=$limit + ((y+10)); then + local ret + ble/unicode/GraphemeCluster/find-previous-boundary "$text" "$dbeg"; dbeg=$ret + local pos + ble/string#split-words pos "${_ble_textmap_pos[dbeg]}" + ((x=pos[0])) + ((y=pos[1])) + fi + fi + _ble_textmap_cols=$cols + _ble_textmap_length=$iN + ble/util/assert '((dbeg<0||(dbeg<=dend&&dbeg<=dend0)))' "($dbeg $dend $dend0) <- ($_ble_textmap_dbeg $_ble_textmap_dend $_ble_textmap_dend0)" + ble/array#reserve-prototype "$iN" + local -a old_pos old_ichg + old_pos=("${_ble_textmap_pos[@]:dend0:iN-dend+1}") + old_ichg=("${_ble_textmap_ichg[@]}") + _ble_textmap_pos=( + "${_ble_textmap_pos[@]::dbeg+1}" + "${_ble_array_prototype[@]::dend-dbeg}" + "${_ble_textmap_pos[@]:dend0+1:iN-dend}") + _ble_textmap_glyph=( + "${_ble_textmap_glyph[@]::dbeg}" + "${_ble_array_prototype[@]::dend-dbeg}" + "${_ble_textmap_glyph[@]:dend0:iN-dend}") + _ble_textmap_ichg=() + ble/urange#shift --prefix=_ble_textmap_ "$dbeg" "$dend" "$dend0" + local i extend + for ((i=dbeg;i=cols)); then + cs=' ' w=0 + ble/textmap#update/.wrap + else + local x2 + ((x2=(x/it+1)*it, + x2>=cols&&(x2=cols-1), + w=x2-x, + w!=it&&(changed=1))) + cs=${_ble_string_prototype::w} + fi + elif ((c==10)); then + w=0 + if [[ :$opts: == *:relative:* ]]; then + local pad=$((cols-x)) eraser= + if ((pad)); then + if [[ $_ble_term_ech ]]; then + eraser=${_ble_term_ech//'%d'/$pad} + else + eraser=${_ble_string_prototype::pad} + ((x=cols)) + fi + fi + local move=${_ble_term_cub//'%d'/$x}${_ble_term_cud//'%d'/1} + cs=$eraser$move + changed=1 + else + cs=$_ble_term_el$_ble_term_nl + fi + ((y++,x=0)) + fi + fi + local wrapping=0 + if ((w>0)); then + if ((xcols)); do + ((y++,x-=cols)) + done + if ((x==cols)); then + ble/textmap#update/.wrap + fi + fi + _ble_textmap_glyph[i]=$cs + ((changed)) && ble/array#push _ble_textmap_ichg "$i" + _ble_textmap_pos[i+1]="$x $y $wrapping" + ((i++)) + fi + while ((extend--)); do + _ble_textmap_glyph[i]= + _ble_textmap_pos[++i]="$x $y 0" + done + if ((i>=dend)); then + [[ ${old_pos[i-dend]} == "${_ble_textmap_pos[i]}" ]] && break + if [[ ${old_pos[i-dend]%%[$IFS]*} == "${_ble_textmap_pos[i]%%[$IFS]*}" ]]; then + local -a opos npos pos + opos=(${old_pos[i-dend]}) + npos=(${_ble_textmap_pos[i]}) + local ydelta=$((npos[1]-opos[1])) + while ((i=dend0)&&(ichg+=dend-dend0), + (0<=ichg&&ichg_ble_textmap_endy)); then + (($__ble_var=_ble_textmap_length)) + elif ((__ble_y<_ble_textmap_begy)); then + (($__ble_var=0)) + else + local __ble_l=0 __ble_u=$((_ble_textmap_length+1)) + local m mx my + while ((__ble_l+1<__ble_u)); do + ble/textmap#getxy.cur --prefix=m "$((m=(__ble_l+__ble_u)/2))" + (((__ble_yy||yh==y&&xh>x)); then + index=$end + lx=$x ly=$y + rx=$x ry=$y + elif "$getxy" "$beg"; ((yh0)) || continue + ((count++)) + ((min_delta<0||min_delta>delta)) && min_delta=$delta + done + ((count==0)) && break + if ((count*min_delta<=room)); then + for ((i=0;i0)) || continue + ((heights[i]+=min_delta)) + done + ((room-=count*min_delta)) + else + local delta=$((room/count)) rem=$((room%count)) count=0 + for ((i=0;i0)) || continue + ((heights[i]+=delta)) + ((count++=0;i--)); do + local sub=$((heights[i]-heights[i]*lines/min)) + if ((sub_ble_canvas_panel_height[i])) && + ble/canvas/panel#set-height.draw "$i" "${heights[i]}" + done +} +function ble/canvas/panel/is-last-line { + local ret + ble/arithmetic/sum "${_ble_canvas_panel_height[@]}" + ((_ble_canvas_y==ret-1)) +} +function ble/canvas/panel/goto-bottom-dock.draw { + if [[ ! $_ble_canvas_panel_bottom ]]; then + _ble_canvas_panel_bottom=1 + ble/canvas/excursion-start.draw + ble/canvas/put-cup.draw "$LINES" 0 # 一番下の行に移動 + ble/arithmetic/sum "${_ble_canvas_panel_height[@]}" + ((_ble_canvas_x=0,_ble_canvas_y=ret-1)) + fi +} +function ble/canvas/panel/goto-top-dock.draw { + if [[ $_ble_canvas_panel_bottom ]]; then + _ble_canvas_panel_bottom= + ble/canvas/excursion-end.draw + fi +} +function ble/canvas/panel/goto-vfill.draw { + ble/canvas/panel/has-bottom-dock || return 1 + local ret + ble/canvas/panel/goto-top-dock.draw + ble/arithmetic/sum "${_ble_canvas_panel_height[@]::_ble_canvas_panel_vfill}" + ble/canvas/goto.draw 0 "$ret" sgr0 + return 0 +} +function ble/canvas/panel/save-position { + ret=$_ble_canvas_x:$_ble_canvas_y:$_ble_canvas_panel_bottom + [[ :$2: == *:goto-top-dock:* ]] && + ble/canvas/panel/goto-top-dock.draw +} +function ble/canvas/panel/load-position { + local -a DRAW_BUFF=() + ble/canvas/panel/load-position.draw "$@" + ble/canvas/bflush.draw +} +function ble/canvas/panel/load-position.draw { + local data=$1 + local x=${data%%:*}; data=${data#*:} + local y=${data%%:*}; data=${data#*:} + local bottom=$data + if [[ $bottom ]]; then + ble/canvas/panel/goto-bottom-dock.draw + else + ble/canvas/panel/goto-top-dock.draw + fi + ble/canvas/goto.draw "$x" "$y" +} +function ble/canvas/panel/has-bottom-dock { + local ret; ble/canvas/panel/bottom-dock#height + ((ret)) +} +function ble/canvas/panel/bottom-dock#height { + ret=0 + [[ $_ble_canvas_panel_vfill && $_ble_term_rc ]] || return 0 + ble/arithmetic/sum "${_ble_canvas_panel_height[@]:_ble_canvas_panel_vfill}" +} +function ble/canvas/panel/top-dock#height { + if [[ $_ble_canvas_panel_vfill && $_ble_term_rc ]]; then + ble/arithmetic/sum "${_ble_canvas_panel_height[@]::_ble_canvas_panel_vfill}" + else + ble/arithmetic/sum "${_ble_canvas_panel_height[@]}" + fi +} +function ble/canvas/panel/bottom-dock#invalidate { + [[ $_ble_canvas_panel_vfill && $_ble_term_rc ]] || return 0 + local index n=${#_ble_canvas_panel_class[@]} + for ((index=_ble_canvas_panel_vfill;index=_ble_canvas_panel_vfill)) +} +function ble/canvas/panel#get-origin { + local ret index=$1 prefix= + [[ $2 == --prefix=* ]] && prefix=${2#*=} + ble/arithmetic/sum "${_ble_canvas_panel_height[@]::index}" + ((${prefix}x=0,${prefix}y=ret)) +} +function ble/canvas/panel#goto.draw { + local index=$1 x=${2-0} y=${3-0} opts=$4 ret + if ble/canvas/panel#is-bottom "$index"; then + ble/canvas/panel/goto-bottom-dock.draw + else + ble/canvas/panel/goto-top-dock.draw + fi + ble/arithmetic/sum "${_ble_canvas_panel_height[@]::index}" + ble/canvas/goto.draw "$x" "$((ret+y))" "$opts" +} +function ble/canvas/panel#put.draw { + ble/canvas/put.draw "$2" + ble/canvas/panel#report-cursor-position "$1" "$3" "$4" +} +function ble/canvas/panel#report-cursor-position { + local index=$1 x=${2-0} y=${3-0} ret + ble/arithmetic/sum "${_ble_canvas_panel_height[@]::index}" + ((_ble_canvas_x=x,_ble_canvas_y=ret+y)) +} +function ble/canvas/panel/increase-total-height.draw { + local delta=$1 + ((delta>0)) || return 1 + local ret + ble/canvas/panel/top-dock#height; local top_height=$ret + ble/canvas/panel/bottom-dock#height; local bottom_height=$ret + if ((bottom_height)); then + ble/canvas/panel/goto-top-dock.draw + if [[ $_ble_term_DECSTBM ]]; then + ble/canvas/excursion-start.draw + ble/canvas/put.draw $'\e[1;'$((LINES-bottom_height))'r' + ble/canvas/excursion-end.draw + ble/canvas/goto.draw 0 "$((top_height==0?0:top_height-1))" sgr0 + ble/canvas/put-ind.draw "$((top_height-1+delta-_ble_canvas_y))" + ((_ble_canvas_y=top_height-1+delta)) + ble/canvas/excursion-start.draw + ble/canvas/put.draw "$_ble_term_DECSTBM_reset" + ble/canvas/excursion-end.draw + return 0 + else + ble/canvas/panel/bottom-dock#invalidate + fi + fi + local old_height=$((top_height+bottom_height)) + local new_height=$((old_height+delta)) + ble/canvas/goto.draw 0 "$((top_height==0?0:top_height-1))" sgr0 + ble/canvas/put-ind.draw "$((new_height-1-_ble_canvas_y))"; ((_ble_canvas_y=new_height-1)) + ble/canvas/panel/goto-vfill.draw && + ble/canvas/put-il.draw "$delta" vfill +} +function ble/canvas/panel#set-height.draw { + local index=$1 new_height=$2 opts=$3 + ((new_height<0)) && new_height=0 + local old_height=${_ble_canvas_panel_height[index]} + local delta=$((new_height-old_height)) + if ((delta==0)); then + if [[ :$opts: == *:clear:* ]]; then + ble/canvas/panel#clear.draw "$index" + return "$?" + else + return 1 + fi + elif ((delta>0)); then + ble/canvas/panel/increase-total-height.draw "$delta" + ble/canvas/panel/goto-vfill.draw && + ble/canvas/put-dl.draw "$delta" vfill + ((_ble_canvas_panel_height[index]=new_height)) + case :$opts: in + (*:clear:*) + ble/canvas/panel#goto.draw "$index" 0 0 sgr0 + ble/canvas/put-clear-lines.draw "$old_height" "$new_height" panel ;; + (*:shift:*) # 先頭に行挿入 + ble/canvas/panel#goto.draw "$index" 0 0 sgr0 + ble/canvas/put-il.draw "$delta" panel ;; + (*) # 末尾に行挿入 + ble/canvas/panel#goto.draw "$index" 0 "$old_height" sgr0 + ble/canvas/put-il.draw "$delta" panel ;; + esac + else + ((delta=-delta)) + case :$opts: in + (*:clear:*) + ble/canvas/panel#goto.draw "$index" 0 0 sgr0 + ble/canvas/put-clear-lines.draw "$old_height" "$new_height" panel ;; + (*:shift:*) # 先頭を削除 + ble/canvas/panel#goto.draw "$index" 0 0 sgr0 + ble/canvas/put-dl.draw "$delta" panel ;; + (*) # 末尾を削除 + ble/canvas/panel#goto.draw "$index" 0 "$new_height" sgr0 + ble/canvas/put-dl.draw "$delta" panel ;; + esac + ((_ble_canvas_panel_height[index]=new_height)) + ble/canvas/panel/goto-vfill.draw && + ble/canvas/put-il.draw "$delta" vfill + fi + ble/function#try "${_ble_canvas_panel_class[index]}#panel::onHeightChange" "$index" + return 0 +} +function ble/canvas/panel#increase-height.draw { + local index=$1 delta=$2 opts=$3 + ble/canvas/panel#set-height.draw "$index" "$((_ble_canvas_panel_height[index]+delta))" "$opts" +} +function ble/canvas/panel#set-height-and-clear.draw { + local index=$1 new_height=$2 + ble/canvas/panel#set-height.draw "$index" "$new_height" clear +} +function ble/canvas/panel#clear.draw { + local index=$1 + local height=${_ble_canvas_panel_height[index]} + if ((height)); then + ble/canvas/panel#goto.draw "$index" 0 0 sgr0 + ble/canvas/put-clear-lines.draw "$height" + fi +} +function ble/canvas/panel#clear-after.draw { + local index=$1 x=$2 y=$3 + local height=${_ble_canvas_panel_height[index]} + ((yLINES)) && tmargin=$LINES + ((tmargin>0)) || return 0 + local ret + ble/canvas/panel/save-position; local pos=$ret + ble/canvas/panel/goto-top-dock.draw + ble/canvas/panel/top-dock#height; local top_height=$ret + ble/canvas/panel/bottom-dock#height; local bottom_height=$ret + if ((bottom_height)); then + if [[ $_ble_term_DECSTBM ]]; then + ble/canvas/excursion-start.draw + ble/canvas/put.draw $'\e[1;'$((LINES-bottom_height))'r' + ble/canvas/excursion-end.draw + ble/canvas/goto.draw 0 0 sgr0 + if [[ $_ble_term_ri ]]; then + ble/canvas/put-ri.draw "$tmargin" + ble/canvas/put-cud.draw "$tmargin" + else + ble/canvas/put-ind.draw "$((top_height-1+tmargin))" + ble/canvas/put-cuu.draw "$((top_height-1+tmargin))" + ble/canvas/excursion-start.draw + ble/canvas/put-cup.draw 1 1 + ble/canvas/put-il.draw "$tmargin" no-lastline + ble/canvas/excursion-end.draw + fi + ble/canvas/excursion-start.draw + ble/canvas/put.draw "$_ble_term_DECSTBM_reset" + ble/canvas/excursion-end.draw + ble/canvas/panel/load-position.draw "$pos" + return 0 + else + ble/canvas/panel/bottom-dock#invalidate + fi + fi + ble/canvas/goto.draw 0 0 sgr0 + if [[ $_ble_term_ri ]]; then + ble/canvas/put-ri.draw "$tmargin" + ble/canvas/put-cud.draw "$tmargin" + else + local total_height=$((top_height+bottom_height)) + ble/canvas/put-ind.draw "$((total_height-1+tmargin))" + ble/canvas/put-cuu.draw "$((total_height-1+tmargin))" + if [[ $_ble_term_rc ]]; then + ble/canvas/excursion-start.draw + ble/canvas/put-cup.draw 1 1 + ble/canvas/put-il.draw "$tmargin" no-lastline + ble/canvas/excursion-end.draw + else + ble/canvas/put-il.draw "$tmargin" no-lastline + fi + ble/canvas/put-cud.draw "$tmargin" + fi + ble/canvas/panel/load-position.draw "$pos" +} +bleopt/declare -v history_limit_length 10000 +_ble_history=() +_ble_history_edit=() +_ble_history_dirt=() +_ble_history_index=0 +_ble_history_count= +function ble/builtin/history/is-empty { + ! ble/util/assign.has-output 'builtin history 1' +} +if ((_ble_bash>=50000)); then + function ble/builtin/history/.check-timestamp-sigsegv { return 0; } +else + function ble/builtin/history/.check-timestamp-sigsegv { + local stat=$1 + ((stat)) || return 0 + local ret=11 + ble/builtin/trap/sig#resolve SIGSEGV + ((stat==128+ret)) || return 0 + local msg="bash: SIGSEGV: suspicious timestamp in HISTFILE" + local histfile=${HISTFILE-} + if [[ -s $histfile ]]; then + msg="$msg='$histfile'" + local rex_broken_timestamp='^#[0-9]\{12\}' + ble/util/assign line 'ble/bin/grep -an "$rex_broken_timestamp" "$histfile"' + ble/string#split line : "$line" + [[ $line =~ ^[0-9]+$ ]] && msg="$msg (line $line)" + fi + if [[ ${_ble_edit_io_fname2-} ]]; then + ble/util/print $'\n'"$msg" >> "$_ble_edit_io_fname2" + else + ble/util/print "$msg" >&2 + fi + } +fi +if ((_ble_bash<40000)); then + function ble/builtin/history/.dump.proc { + local LC_ALL= LC_MESSAGES=C 2>/dev/null + builtin history "${args[@]}" + ble/util/unlocal LC_ALL LC_MESSAGES 2>/dev/null + } + function ble/builtin/history/.dump { + local -a args; args=("$@") + ble/util/conditional-sync \ + ble/builtin/history/.dump.proc \ + true 100 progressive-weight:timeout=3000:SIGKILL + local ext=$? + if ((ext==142)); then + printf 'ble.sh: timeout: builtin history %s' "$*" >&"$_ble_util_fd_tui_stderr" + local ret=11 + ble/builtin/trap/sig#resolve SIGSEGV + ((ext=128+ret)) + fi + ble/builtin/history/.check-timestamp-sigsegv "$ext" + return "$ext" + } +else + function ble/builtin/history/.dump { + local LC_ALL= LC_MESSAGES=C 2>/dev/null + builtin history "$@" + ble/util/unlocal LC_ALL LC_MESSAGES 2>/dev/null + } +fi +if ((_ble_bash>=50200)); then + function ble/builtin/history/.get-min { + if ((${_ble_trap_sig-0}==_ble_builtin_trap_EXIT)); then + ble/string#split-words min "$(builtin history | ble/bin/sed -n '1{p;q;}')" + else + ble/util/assign-words min 'builtin history | ble/bin/sed -n "1{p;q;}"' + fi + min=${min/'*'} + } +elif ((_ble_bash>=40000)); then + function ble/builtin/history/.get-min { + ble/util/assign-words min 'builtin history | ble/bin/sed -n "1{p;q;}"' + min=${min/'*'} + } +else + function ble/builtin/history/.get-min { + ble/util/assign-words min 'ble/builtin/history/.dump | ble/bin/sed -n "1{p;q;}"' + min=${min/'*'} + } +fi +function ble/builtin/history/.get-max { + ble/util/assign-words max 'builtin history 1' + max=${max/'*'} +} +_ble_history_load_done= +function ble/history:bash/clear-background-load { + blehook/invoke history_reset_background +} +if ((_ble_bash>=40000)); then + _ble_history_load_resume=0 + _ble_history_load_bgpid= + function ble/history:bash/load/.background-initialize { + if ble/builtin/history/is-empty; then + builtin history -n + fi + local HISTTIMEFORMAT=__ble_ext__ + local -x INDEX_FILE=$history_indfile + local -x opt_source= opt_null= + if [[ $load_strategy == source ]]; then + opt_source=1 + elif [[ $load_strategy == mapfile ]]; then + opt_null=1 + fi + if [[ ! $_ble_util_writearray_rawbytes ]]; then + local IFS=$_ble_term_IFS __ble_tmp; __ble_tmp=('\'{2,3}{0..7}{0..7}) + builtin eval "local _ble_util_writearray_rawbytes=\$'${__ble_tmp[*]}'" + fi + local -x __ble_rawbytes=$_ble_util_writearray_rawbytes # used by _ble_bin_awk_libES + local -x fname_stderr=${_ble_edit_io_fname2:-} + local apos=\' + ble/builtin/history/.dump ${arg_count:+"$arg_count"} | ble/bin/awk -v apos="$apos" -v arg_offset="$arg_offset" -v _ble_bash="$_ble_bash" ' + '"$_ble_bin_awk_libES"' + BEGIN { + es_initialize(); + INDEX_FILE = ENVIRON["INDEX_FILE"]; + opt_null = ENVIRON["opt_null"]; + opt_source = ENVIRON["opt_source"]; + if (!opt_null && !opt_source) + printf("") > INDEX_FILE; # create file + fname_stderr = ENVIRON["fname_stderr"]; + fname_stderr_count = 0; + n = 0; + hindex = arg_offset; + } + function flush_line() { + if (n < 1) return; + if (opt_null) { + if (t ~ /^eval -- \$'"$apos"'([^'"$apos"'\\]|\\.)*'"$apos"'$/) + t = es_unescape(substr(t, 11, length(t) - 11)); + printf("%s%c", t, 0); + } else if (opt_source) { + if (t ~ /^eval -- \$'"$apos"'([^'"$apos"'\\]|\\.)*'"$apos"'$/) + t = es_unescape(substr(t, 11, length(t) - 11)); + gsub(/'"$apos"'/, "'"$apos"'\\'"$apos$apos"'", t); + print "_ble_history[" hindex "]=" apos t apos; + } else { + if (n == 1) { + if (t ~ /^eval -- \$'"$apos"'([^'"$apos"'\\]|\\.)*'"$apos"'$/) + print hindex > INDEX_FILE; + } else { + gsub(/['"$apos"'\\]/, "\\\\&", t); + gsub(/\n/, "\\n", t); + print hindex > INDEX_FILE; + t = "eval -- $" apos t apos; + } + print t; + } + hindex++; + n = 0; + t = ""; + } + function check_invalid_timestamp(line) { + if (line ~ /^ *[0-9]+\*? +.+: invalid timestamp/ && fname_stderr != "") { + sub(/^ *0*/, "bash: history !", line); + sub(/: invalid timestamp.*$/, ": invalid timestamp", line); + if (fname_stderr_count++ == 0) + print "" >> fname_stderr; + print line >> fname_stderr; + } + } + { + check_invalid_timestamp($0); + if (sub(/^ *[0-9]+\*? +(__ble_ext__|\?\?|.+: invalid timestamp)/, "", $0)) + flush_line(); + t = ++n == 1 ? $0 : t "\n" $0; + } + END { flush_line(); } + ' >| "$history_tmpfile.part" + ble/builtin/history/.check-timestamp-sigsegv "${PIPESTATUS[0]}" + ble/bin/mv -f "$history_tmpfile.part" "$history_tmpfile" + } + function ble/history:bash/load { + local opts=$1 + local opt_async=; [[ :$opts: == *:async:* ]] && opt_async=1 + local load_strategy=mapfile + if [[ $OSTYPE == cygwin* || $OSTYPE == msys* ]]; then + load_strategy=source + elif ((_ble_bash<50200)); then + load_strategy=nlfix + fi + local arg_count= arg_offset=0 + [[ :$opts: == *:append:* ]] && + arg_offset=${#_ble_history[@]} + local rex=':count=([0-9]+):'; [[ :$opts: =~ $rex ]] && arg_count=${BASH_REMATCH[1]} + local history_tmpfile=$_ble_base_run/$$.history.load + local history_indfile=$_ble_base_run/$$.history.multiline-index + [[ $opt_async || :$opts: == *:init:* ]] || _ble_history_load_resume=0 + [[ ! $opt_async ]] && ((_ble_history_load_resume<6)) && + blehook/invoke history_message "loading history ..." + while :; do + case $_ble_history_load_resume in + (0) # 履歴ファイル生成を Background で開始 + if [[ $_ble_history_load_bgpid ]]; then + builtin kill -9 "$_ble_history_load_bgpid" &>/dev/null + _ble_history_load_bgpid= + fi + >| "$history_tmpfile" + if [[ $opt_async ]]; then + _ble_history_load_bgpid=$(ble/util/nohup 'ble/history:bash/load/.background-initialize' print-bgpid) + function ble/history:bash/load/.background-initialize-completed { + local history_tmpfile=$_ble_base_run/$$.history.load + [[ -s $history_tmpfile ]] || ! builtin kill -0 "$_ble_history_load_bgpid" + } &>/dev/null + ((_ble_history_load_resume++)) + else + ble/history:bash/load/.background-initialize + ((_ble_history_load_resume+=3)) + fi ;; + (1) if [[ $opt_async ]] && ble/util/is-running-in-idle; then + ble/util/idle.wait-condition ble/history:bash/load/.background-initialize-completed + ((_ble_history_load_resume++)) + return 147 + fi + ((_ble_history_load_resume++)) ;; + (2) while ! ble/history:bash/load/.background-initialize-completed; do + ble/util/msleep 50 + [[ $opt_async ]] && ! ble/util/idle/IS_IDLE && return 148 + done + ((_ble_history_load_resume++)) ;; + (3) _ble_history_load_bgpid= + ((arg_offset==0)) && _ble_history=() + if [[ $load_strategy == source ]]; then + source "$history_tmpfile" + elif [[ $load_strategy == nlfix ]]; then + builtin mapfile -O "$arg_offset" -t _ble_history < "$history_tmpfile" + else + builtin mapfile -O "$arg_offset" -t -d '' _ble_history < "$history_tmpfile" + fi + ble/builtin/history/erasedups/update-base + ((_ble_history_load_resume++)) ;; + (4) ((arg_offset==0)) && _ble_history_edit=() + if [[ $load_strategy == source ]]; then + _ble_history_edit=("${_ble_history[@]}") + elif [[ $load_strategy == nlfix ]]; then + builtin mapfile -O "$arg_offset" -t _ble_history_edit < "$history_tmpfile" + else + builtin mapfile -O "$arg_offset" -t -d '' _ble_history_edit < "$history_tmpfile" + fi + >| "$history_tmpfile" + if [[ $load_strategy != nlfix ]]; then + ((_ble_history_load_resume+=3)) + continue + else + ((_ble_history_load_resume++)) + fi ;; + (5) local -a indices_to_fix + ble/util/mapfile indices_to_fix < "$history_indfile" + local i rex='^eval -- \$'\''([^\'\'']|\\.)*'\''$' + for i in "${indices_to_fix[@]}"; do + [[ ${_ble_history[i]} =~ $rex ]] && + builtin eval "_ble_history[i]=${_ble_history[i]:8}" + done + ((_ble_history_load_resume++)) ;; + (6) local -a indices_to_fix + [[ ${indices_to_fix+set} ]] || + ble/util/mapfile indices_to_fix < "$history_indfile" + local i + for i in "${indices_to_fix[@]}"; do + [[ ${_ble_history_edit[i]} =~ $rex ]] && + builtin eval "_ble_history_edit[i]=${_ble_history_edit[i]:8}" + done + ((_ble_history_load_resume++)) ;; + (7) [[ $opt_async ]] || blehook/invoke history_message + ((_ble_history_load_resume++)) + return 0 ;; + (*) return 1 ;; + esac + [[ $opt_async ]] && ! ble/util/idle/IS_IDLE && return 148 + done + } + blehook history_reset_background!=_ble_history_load_resume=0 +else + function ble/history:bash/load/.generate-source { + if ble/builtin/history/is-empty; then + builtin history -n + fi + local HISTTIMEFORMAT=__ble_ext__ + local apos="'" + ble/builtin/history/.dump ${arg_count:+"$arg_count"} | ble/bin/awk -v apos="'" ' + BEGIN { n = ""; } + /^ *[0-9]+\*? +(__ble_ext__|\?\?)#[0-9]/ { next; } + /^ *[0-9]+\*? +(__ble_ext__|\?\?|.+: invalid timestamp)/ { + if (n != "") { + n = ""; + print " " apos t apos; + } + n = $1; t = ""; + sub(/^ *[0-9]+\*? +(__ble_ext__|\?\?|.+: invalid timestamp)/, "", $0); + } + { + line = $0; + if (line ~ /^eval -- \$'"$apos"'([^'"$apos"'\\]|\\.)*'"$apos"'$/) + line = apos substr(line, 9) apos; + else + gsub(apos, apos "\\" apos apos, line); + gsub(/\001/, "'"$apos"'${_ble_term_SOH}'"$apos"'", line); + gsub(/\177/, "'"$apos"'${_ble_term_DEL}'"$apos"'", line); + gsub(/\015/, "'"$apos"'${_ble_term_CR}'"$apos"'", line); + t = t != "" ? t "\n" line : line; + } + END { + if (n != "") { + n = ""; + print " " apos t apos; + } + } + ' + } + function ble/history:bash/load { + local opts=$1 + local opt_append= + [[ :$opts: == *:append:* ]] && opt_append=1 + local arg_count= rex=':count=([0-9]+):' + [[ :$opts: =~ $rex ]] && arg_count=${BASH_REMATCH[1]} + blehook/invoke history_message "loading history..." + local result=$(ble/history:bash/load/.generate-source) + local IFS=$_ble_term_IFS + if [[ $opt_append ]]; then + if ((_ble_bash>=30100)); then + builtin eval -- "_ble_history+=($result)" + builtin eval -- "_ble_history_edit+=($result)" + else + local -a A; builtin eval -- "A=($result)" + _ble_history=("${_ble_history[@]}" "${A[@]}") + _ble_history_edit=("${_ble_history[@]}" "${A[@]}") + fi + else + builtin eval -- "_ble_history=($result)" + _ble_history_edit=("${_ble_history[@]}") + fi + ble/builtin/history/erasedups/update-base + ble/util/unlocal IFS + blehook/invoke history_message + } +fi +function ble/history:bash/initialize { + [[ $_ble_history_load_done ]] && return 0 + ble/history:bash/load "init:$@"; local ext=$? + ((ext)) && return "$ext" + local old_count=$_ble_history_count new_count=${#_ble_history[@]} + _ble_history_load_done=1 + _ble_history_count=$new_count + _ble_history_index=$_ble_history_count + ble/history/.update-position + local delta=$((new_count-old_count)) + ((delta>0)) && blehook/invoke history_change insert "$old_count" "$delta" +} +if ((_ble_bash>=30100)); then + _ble_history_mlfix_done= + _ble_history_mlfix_resume=0 + _ble_history_mlfix_bgpid= + function ble/history:bash/resolve-multiline/.awk { + local ret + ble/util/time + local -x epoch=$ret + local -x reason=$1 + local apos=\' + ble/bin/awk -v apos="$apos" -v _ble_bash="$_ble_bash" ' + BEGIN { + q = apos; + Q = apos "\\" apos apos; + reason = ENVIRON["reason"]; + is_resolve = reason == "resolve"; + TMPBASE = ENVIRON["tmpfile_base"]; + filename_source = TMPBASE ".part"; + if (is_resolve) + print "builtin history -c" > filename_source + entry_nline = 0; + entry_text = ""; + entry_time = ""; + if (_ble_bash >= 40400) + entry_time = ENVIRON["epoch"]; + command_count = 0; + multiline_count = 0; + modification_count = 0; + read_section_count = 0; + } + function write_flush(_, i, filename_section, t, c) { + if (command_count == 0) return; + if (command_count >= 2 || entry_time) { + filename_section = TMPBASE "." read_section_count++ ".part"; + for (i = 0; i < command_count; i++) { + t = command_time[i]; + c = command_text[i]; + if (t) print "#" t > filename_section; + print c > filename_section; + } + print "HISTTIMEFORMAT=%s builtin history -r " filename_section > filename_source; + } else { + for (i = 0; i < command_count; i++) { + c = command_text[i]; + gsub(/'"$apos"'/, Q, c); + print "builtin history -s -- " q c q > filename_source; + } + } + command_count = 0; + } + function write_complex(value) { + write_flush(); + print "builtin history -s -- " value > filename_source; + } + function register_command(cmd) { + command_time[command_count] = entry_time; + command_text[command_count] = cmd; + command_count++; + } + function is_escaped_command(cmd) { + return cmd ~ /^eval -- \$'"$apos"'([^'"$apos"'\\]|\\[\\'"$apos"'nt])*'"$apos"'$/; + } + function unescape_command(cmd) { + cmd = substr(cmd, 11, length(cmd) - 11); + gsub(/\\\\/, "\\q", cmd); + gsub(/\\n/, "\n", cmd); + gsub(/\\t/, "\t", cmd); + gsub(/\\'"$apos"'/, "'"$apos"'", cmd); + gsub(/\\q/, "\\", cmd); + return cmd; + } + function register_escaped_command(cmd) { + multiline_count++; + modification_count++; + if (_ble_bash >= 40400) { + register_command(unescape_command(cmd)); + } else { + write_complex(substr(cmd, 9)); + } + } + function register_multiline_command(cmd) { + multiline_count++; + if (_ble_bash >= 40040) { + register_command(cmd); + } else { + gsub(/'"$apos"'/, Q, cmd); + write_complex(q cmd q); + } + } + function flush_entry() { + if (entry_nline < 1) return; + if (is_escaped_command(entry_text)) { + register_escaped_command(entry_text) + } else if (entry_nline > 1) { + register_multiline_command(entry_text); + } else { + register_command(entry_text); + } + entry_nline = 0; + entry_text = ""; + } + function save_timestamp(line) { + if (is_resolve) { + if (line ~ /^ *[0-9]+\*? +__ble_time_[0-9]*__/) { + sub(/^ *[0-9]+\*? +__ble_time_/, "", line); + sub(/__.*$/, "", line); + entry_time = line; + } + } else { + if (line ~ /^#[0-9]/) { + sub(/^#/, "", line); + sub(/[^0-9].*$/, "", line); + entry_time = line; + } + } + } + { + if (is_resolve) { + save_timestamp($0); + if (sub(/^ *[0-9]+\*? +(__ble_time_[0-9]*__|\?\?|.+: invalid timestamp)/, "", $0)) + flush_entry(); + entry_text = ++entry_nline == 1 ? $0 : entry_text "\n" $0; + } else { + if ($0 ~ /^#[0-9]/) { + save_timestamp($0); + next; + } else { + flush_entry(); + entry_text = $0; + entry_nline = 1; + } + } + } + END { + flush_entry(); + write_flush(); + if (is_resolve) + print "builtin history -a /dev/null" > filename_source + print "multiline_count=" multiline_count; + print "modification_count=" modification_count; + } + ' + } + function ble/history:bash/resolve-multiline/.cleanup { + local file + for file in "$tmpfile_base".*; do >| "$file"; done + } + function ble/history:bash/resolve-multiline/.worker { + local HISTTIMEFORMAT=__ble_time_%s__ + local -x tmpfile_base=$_ble_base_run/$$.history.mlfix + local multiline_count=0 modification_count=0 + builtin eval -- "$(ble/builtin/history/.dump | ble/history:bash/resolve-multiline/.awk resolve 2>/dev/null)" + if ((modification_count)); then + ble/bin/mv -f "$tmpfile_base.part" "$tmpfile_base.sh" + else + ble/util/print : >| "$tmpfile_base.sh" + fi + } + function ble/history:bash/resolve-multiline/.load { + local tmpfile_base=$_ble_base_run/$$.history.mlfix + local HISTCONTROL= HISTSIZE= HISTIGNORE= + source "$tmpfile_base.sh" + ble/history:bash/resolve-multiline/.cleanup + } + function ble/history:bash/resolve-multiline.impl { + local opts=$1 + local opt_async=; [[ :$opts: == *:async:* ]] && opt_async=1 + local history_tmpfile=$_ble_base_run/$$.history.mlfix.sh + [[ $opt_async || :$opts: == *:init:* ]] || _ble_history_mlfix_resume=0 + [[ ! $opt_async ]] && ((_ble_history_mlfix_resume<=4)) && + blehook/invoke history_message "resolving multiline history ..." + while :; do + case $_ble_history_mlfix_resume in + (0) if [[ $opt_async ]] && ble/builtin/history/is-empty; then + ble/util/idle.wait-user-input + ((_ble_history_mlfix_resume++)) + return 147 + fi + ((_ble_history_mlfix_resume++)) ;; + (1) # 履歴ファイル生成を Background で開始 + if [[ $_ble_history_mlfix_bgpid ]]; then + builtin kill -9 "$_ble_history_mlfix_bgpid" &>/dev/null + _ble_history_mlfix_bgpid= + fi + >| "$history_tmpfile" + if [[ $opt_async ]]; then + _ble_history_mlfix_bgpid=$(ble/util/nohup 'ble/history:bash/resolve-multiline/.worker' print-bgpid) + function ble/history:bash/resolve-multiline/.worker-completed { + local history_tmpfile=$_ble_base_run/$$.history.mlfix.sh + [[ -s $history_tmpfile ]] || ! builtin kill -0 "$_ble_history_mlfix_bgpid" + } &>/dev/null + ((_ble_history_mlfix_resume++)) + else + ble/history:bash/resolve-multiline/.worker + ((_ble_history_mlfix_resume+=3)) + fi ;; + (2) if [[ $opt_async ]] && ble/util/is-running-in-idle; then + ble/util/idle.wait-condition ble/history:bash/resolve-multiline/.worker-completed + ((_ble_history_mlfix_resume++)) + return 147 + fi + ((_ble_history_mlfix_resume++)) ;; + (3) while ! ble/history:bash/resolve-multiline/.worker-completed; do + ble/util/msleep 50 + [[ $opt_async ]] && ! ble/util/idle/IS_IDLE && return 148 + done + ((_ble_history_mlfix_resume++)) ;; + (4) _ble_history_mlfix_bgpid= + ble/history:bash/resolve-multiline/.load + [[ $opt_async ]] || blehook/invoke history_message + ((_ble_history_mlfix_resume++)) + return 0 ;; + (*) return 1 ;; + esac + [[ $opt_async ]] && ! ble/util/idle/IS_IDLE && return 148 + done + } + function ble/history:bash/resolve-multiline { + [[ $_ble_history_mlfix_done ]] && return 0 + if [[ $1 == sync ]]; then + ((_ble_bash>=40000)) && [[ $BASHPID != $$ ]] && return 0 + ble/builtin/history/is-empty && return 0 + fi + ble/history:bash/resolve-multiline.impl "$@"; local ext=$? + ((ext)) && return "$ext" + _ble_history_mlfix_done=1 + return 0 + } + ((_ble_bash>=40000)) && + ble/util/idle.push 'ble/history:bash/resolve-multiline async' + blehook history_reset_background!=_ble_history_mlfix_resume=0 + function ble/history:bash/resolve-multiline/readfile { + local filename=$1 + local -x tmpfile_base=$_ble_base_run/$$.history.read + ble/history:bash/resolve-multiline/.awk read < "$filename" &>/dev/null + source "$tmpfile_base.part" + ble/history:bash/resolve-multiline/.cleanup + } +else + function ble/history:bash/resolve-multiline/readfile { builtin history -r "$filename"; } + function ble/history:bash/resolve-multiline { return 0; } +fi +function ble/history:bash/unload.hook { + ble/util/is-running-in-subshell && return 0 + if shopt -q histappend &>/dev/null; then + ble/builtin/history -a + else + ble/builtin/history -w + fi +} +blehook unload!=ble/history:bash/unload.hook +function ble/history:bash/reset { + if ((_ble_bash>=40000)); then + _ble_history_load_done= + ble/history:bash/clear-background-load + ble/util/idle.push 'ble/history:bash/initialize async' + elif ((_ble_bash>=30100)) && [[ $bleopt_history_lazyload ]]; then + _ble_history_load_done= + else + ble/history:bash/initialize + fi +} +function ble/builtin/history/.touch-histfile { + local touch=$_ble_base_run/$$.history.touch + >| "$touch" +} +if [[ ! ${_ble_builtin_history_initialized+set} ]]; then + _ble_builtin_history_initialized= + _ble_builtin_history_histnew_count=0 + _ble_builtin_history_histapp_count=0 + _ble_builtin_history_wskip=0 + _ble_builtin_history_prevmax=0 + builtin eval -- "${_ble_util_gdict_declare//NAME/_ble_builtin_history_rskip_dict}" + function ble/builtin/history/.get-rskip { + local file=$1 ret + ble/gdict#get _ble_builtin_history_rskip_dict "$file" + rskip=$ret + } + function ble/builtin/history/.set-rskip { + local file=$1 + ble/gdict#set _ble_builtin_history_rskip_dict "$file" "$2" + } + function ble/builtin/history/.add-rskip { + local file=$1 ret + ble/gdict#get _ble_builtin_history_rskip_dict "$file" + ((ret+=$2)) + ble/gdict#set _ble_builtin_history_rskip_dict "$file" "$ret" + } +fi +function ble/builtin/history/.initialize { + [[ $_ble_builtin_history_initialized ]] && return 0 + local line; ble/util/assign line 'builtin history 1' + [[ ! $_ble_decode_hook_count && ! $line && :$1: == *:skip0:* ]] && return 1 + _ble_builtin_history_initialized=1 + local histnew=$_ble_base_run/$$.history.new + >| "$histnew" + if [[ $line ]]; then + local histini=$_ble_base_run/$$.history.ini + local histapp=$_ble_base_run/$$.history.app + HISTTIMEFORMAT=1 builtin history -a "$histini" + if [[ -s $histini ]]; then + ble/bin/sed '/^#\([0-9].*\)/{s// 0 __ble_time_\1__/;N;s/\n//;}' "$histini" >> "$histapp" + >| "$histini" + fi + else + ble/builtin/history/option:r + fi + local histfile=${HISTFILE-} rskip=0 + [[ -e $histfile ]] && rskip=$(ble/bin/wc -l "$histfile" 2>/dev/null) + ble/string#split-words rskip "$rskip" + local min; ble/builtin/history/.get-min + local max; ble/builtin/history/.get-max + ((max&&max-min+1=50000&&beg=beg;i--)); do + builtin history -d "$i" + done + fi +} +function ble/builtin/history/.check-uncontrolled-change { + [[ $_ble_decode_bind_state == none ]] && return 0 + local filename=${1-} opts=${2-} prevmax=$_ble_builtin_history_prevmax + local max; ble/builtin/history/.get-max + if ((max!=prevmax)); then + if [[ $filename && :$opts: == *:append:* ]] && ((_ble_builtin_history_wskip0)) || return 0 + if [[ ! $_ble_history_load_done ]]; then + ble/history:bash/clear-background-load + _ble_history_count= + return 0 + fi + if ((_ble_bash>=40000&&delta>=10000)); then + ble/history:bash/reset + return 0 + fi + ble/history:bash/load append:count=$delta + local ocount=$_ble_history_count ncount=${#_ble_history[@]} + ((_ble_history_index==_ble_history_count)) && _ble_history_index=$ncount + _ble_history_count=$ncount + ble/history/.update-position + blehook/invoke history_change insert "$ocount" "$delta" +} +function ble/builtin/history/.read { + local file=$1 skip=${2:-0} fetch=$3 + local -x histnew=$_ble_base_run/$$.history.new + if [[ -s $file ]]; then + local script=$(ble/bin/awk -v skip="$skip" ' + BEGIN { histnew = ENVIRON["histnew"]; count = 0; } + NR <= skip { next; } + { print $0 >> histnew; count++; } + END { + print "ble/builtin/history/.set-rskip \"$file\" " NR; + print "((_ble_builtin_history_histnew_count+=" count "))"; + } + ' "$file") + builtin eval -- "$script" + else + ble/builtin/history/.set-rskip "$file" 0 + fi + if [[ ! $fetch && -s $histnew ]]; then + local nline=$_ble_builtin_history_histnew_count + ble/history:bash/resolve-multiline/readfile "$histnew" + >| "$histnew" + _ble_builtin_history_histnew_count=0 + ble/builtin/history/.load-recent-entries "$nline" + local max; ble/builtin/history/.get-max + _ble_builtin_history_wskip=$max + _ble_builtin_history_prevmax=$max + fi +} +function ble/builtin/history/.write { + local -x file=$1 skip=${2:-0} opts=$3 + local -x histapp=$_ble_base_run/$$.history.app + declare -p HISTTIMEFORMAT &>/dev/null + local -x flag_timestamp=$(($?==0)) + local min; ble/builtin/history/.get-min + local max; ble/builtin/history/.get-max + ((skip0)); then + local HISTTIMEFORMAT=__ble_time_%s__ + if [[ :$opts: == *:append:* ]]; then + ble/builtin/history/.dump "$delta" >> "$histapp" + ((_ble_builtin_history_histapp_count+=delta)) + else + ble/builtin/history/.dump "$delta" >| "$histapp" + _ble_builtin_history_histapp_count=$delta + fi + fi + if [[ ! -e $file ]]; then + (umask 077; >| "$file") + elif [[ :$opts: != *:append:* ]]; then + >| "$file" + fi + if [[ :$opts: != *:fetch:* && -s $histapp ]]; then + local apos=\' + < "$histapp" ble/bin/awk ' + BEGIN { + file = ENVIRON["file"]; + flag_timestamp = ENVIRON["flag_timestamp"]; + timestamp = ""; + mode = 0; + } + function flush_line() { + if (!mode) return; + mode = 0; + if (text ~ /\n/) { + gsub(/['"$apos"'\\]/, "\\\\&", text); + gsub(/\n/, "\\n", text); + gsub(/\t/, "\\t", text); + text = "eval -- $'"$apos"'" text "'"$apos"'" + } + if (timestamp != "") + print timestamp >> file; + print text >> file; + } + function extract_timestamp(line) { + if (!sub(/^ *[0-9]+\*? +__ble_time_/, "", line)) return ""; + if (!sub(/__.*$/, "", line)) return ""; + if (!(line ~ /^[0-9]+$/)) return ""; + return "#" line; + } + /^ *[0-9]+\*? +(__ble_time_[0-9]*__|\?\?|.+: invalid timestamp)?/ { + flush_line(); + mode = 1; + text = ""; + if (flag_timestamp) + timestamp = extract_timestamp($0); + sub(/^ *[0-9]+\*? +(__ble_time_[0-9]*__|\?\?|.+: invalid timestamp)?/, "", $0); + } + { text = text != "" ? text "\n" $0 : $0; } + END { flush_line(); } + ' + ble/builtin/history/.add-rskip "$file" "$_ble_builtin_history_histapp_count" + >| "$histapp" + _ble_builtin_history_histapp_count=0 + fi + _ble_builtin_history_wskip=$max + _ble_builtin_history_prevmax=$max +} +function ble/builtin/history/array#delete-hindex { + local array_name=$1; shift + local script=' + local -a out=() + local i shift=0 + for i in "${!NAME[@]}"; do + local delete= + while (($#)); do + if [[ $1 == *-* ]]; then + local b=${1%-*} e=${1#*-} + ((imax&&(beg=max)))) + ((end<0)) && ((end+=max+1)); ((endmax&&(end=max)))) + ((beg<=end)) || return 0 + ble/builtin/history/.delete-range "$beg" "$end" + if ((_ble_builtin_history_wskip>=end)); then + ((_ble_builtin_history_wskip-=end-beg+1)) + elif ((_ble_builtin_history_wskip>beg-1)); then + ((_ble_builtin_history_wskip=beg-1)) + fi + if [[ $_ble_decode_bind_state != none ]]; then + if [[ $_ble_history_load_done ]]; then + local N=${#_ble_history[@]} + local b=$((beg-1+N-max)) e=$((end+N-max)) + blehook/invoke history_change delete "$b-$e" + if ((_ble_history_index>=e)); then + ((_ble_history_index-=e-b)) + elif ((_ble_history_index>=b)); then + _ble_history_index=$b + fi + _ble_history=("${_ble_history[@]::b}" "${_ble_history[@]:e}") + _ble_history_edit=("${_ble_history_edit[@]::b}" "${_ble_history_edit[@]:e}") + _ble_history_count=${#_ble_history[@]} + else + ble/history:bash/clear-background-load + _ble_history_count= + fi + ble/history/.update-position + fi + local max; ble/builtin/history/.get-max + _ble_builtin_history_prevmax=$max +} +function ble/builtin/history/.get-histfile { + histfile=${1:-${HISTFILE-}} + if [[ ! $histfile ]]; then + local opt=-a + [[ ${FUNCNAME[1]} == *:[!:] ]] && opt=-${FUNCNAME[1]##*:} + if [[ ${1+set} ]]; then + ble/util/print "ble/builtin/history $opt: the history filename is empty." >&2 + else + ble/util/print "ble/builtin/history $opt: the history file is not specified." >&2 + fi + return 1 + fi +} +function ble/builtin/history/option:a { + ble/builtin/history/.initialize skip0 || return "$?" + local histfile; ble/builtin/history/.get-histfile "$@" || return "$?" + ble/builtin/history/.check-uncontrolled-change "$histfile" append + local rskip; ble/builtin/history/.get-rskip "$histfile" + ble/builtin/history/.write "$histfile" "$_ble_builtin_history_wskip" append:fetch + [[ -r $histfile ]] && ble/builtin/history/.read "$histfile" "$rskip" fetch + ble/builtin/history/.write "$histfile" "$_ble_builtin_history_wskip" append + builtin history -a /dev/null # Bash 終了時に書き込まない +} +function ble/builtin/history/option:n { + local histfile; ble/builtin/history/.get-histfile "$@" || return "$?" + if [[ $histfile == ${HISTFILE-} ]]; then + local touch=$_ble_base_run/$$.history.touch + [[ $touch -nt ${HISTFILE-} ]] && return 0 + >| "$touch" + fi + ble/builtin/history/.initialize + local rskip; ble/builtin/history/.get-rskip "$histfile" + ble/builtin/history/.read "$histfile" "$rskip" +} +function ble/builtin/history/option:w { + ble/builtin/history/.initialize skip0 || return "$?" + local histfile; ble/builtin/history/.get-histfile "$@" || return "$?" + local rskip; ble/builtin/history/.get-rskip "$histfile" + [[ -r $histfile ]] && ble/builtin/history/.read "$histfile" "$rskip" fetch + ble/builtin/history/.write "$histfile" 0 + builtin history -a /dev/null # Bash 終了時に書き込まない +} +function ble/builtin/history/option:r { + local histfile; ble/builtin/history/.get-histfile "$@" || return "$?" + ble/builtin/history/.initialize + ble/builtin/history/.read "$histfile" 0 +} +function ble/builtin/history/option:p { + ((_ble_bash>=40000)) || ble/builtin/history/is-empty || + ble/history:bash/resolve-multiline sync + local line1= line2= + ble/util/assign line1 'HISTTIMEFORMAT= builtin history 1' + builtin history -p -- '' &>/dev/null + ble/util/assign line2 'HISTTIMEFORMAT= builtin history 1' + if [[ $line1 != "$line2" ]]; then + local rex_head='^[[:space:]]*[0-9]+\*?[[:space:]]*' + [[ $line1 =~ $rex_head ]] && + line1=${line1:${#BASH_REMATCH}} + if ((_ble_bash<30100)); then + local tmp=$_ble_base_run/$$.history.tmp + printf '%s\n' "$line1" "$line1" >| "$tmp" + builtin history -r "$tmp" + else + builtin history -s -- "$line1" + builtin history -s -- "$line1" + fi + fi + builtin history -p -- "$@" +} +bleopt/declare -v history_erasedups_limit 0 +: "${_ble_history_erasedups_base=}" +function ble/builtin/history/erasedups/update-base { + if [[ ! ${_ble_history_erasedups_base:-} ]]; then + _ble_history_erasedups_base=${#_ble_history[@]} + else + local value=${#_ble_history[@]} + ((value<_ble_history_erasedups_base&&(_ble_history_erasedups_base=value))) + fi +} +function ble/builtin/history/erasedups/.impl-for { + local cmd=$1 + delete_indices=() + shift_histindex_next=0 + shift_wskip=0 + local i + for ((i=0;i| "$itmp1" & local pid1=$! + ble/util/writearray "${writearray_options[@]}" _ble_history_edit >| "$itmp2" + wait "$pid1" ) + local -x erasedups_cmd=$cmd + local -x erasedups_out1=$otmp1 + local -x erasedups_out2=$otmp2 + local -x erasedups_histindex_next=$HISTINDEX_NEXT + local -x erasedups_wskip=$_ble_builtin_history_wskip + local awk_script=' + '"$_ble_bin_awk_libES"' + '"$_ble_bin_awk_libNLFIX"' + BEGIN { + NLFIX_READ = ENVIRON["erasedups_nlfix_read"] != ""; + cmd = ENVIRON["erasedups_cmd"]; + out1 = ENVIRON["erasedups_out1"]; + out2 = ENVIRON["erasedups_out2"]; + histindex_next = ENVIRON["erasedups_histindex_next"]; + wskip = ENVIRON["erasedups_wskip"]; + if (NLFIX_READ) + es_initialize(); + else + RS = "\0"; + NLFIX_WRITE = _ble_bash < 50200; + if (NLFIX_WRITE) nlfix_begin(); + hist_index = 0; + edit_index = 0; + delete_count = 0; + shift_histindex_next = 0; + shift_wskip = 0; + } + function process_hist(elem) { + if (hist_index < N - 1 && elem == cmd) { + delete_indices[delete_count++] = hist_index; + delete_table[hist_index] = 1; + if (hist_index < wskip ) shift_wskip++; + if (hist_index < histindex_next) shift_histindex_next++; + } else { + if (NLFIX_WRITE) + nlfix_push(elem, out1); + else + printf("%s%c", elem, 0) > out1; + } + hist_index++; + } + function process_edit(elem) { + if (delete_count == 0) exit; + if (NLFIX_WRITE) { + if (edit_index == 0) { + nlfix_end(out1); + nlfix_begin(); + } + if (!delete_table[edit_index++]) + nlfix_push(elem, out2); + } else { + if (!delete_table[edit_index++]) + printf("%s%c", elem, 0) > out2; + } + } + mode == "edit" { + if (NLFIX_READ) { + edit[edit_index++] = $0; + } else { + process_edit($0); + } + next; + } + { + if (NLFIX_READ) + hist[hist_index++] = $0; + else + process_hist($0); + } + END { + if (NLFIX_READ) { + n = split(hist[hist_index - 1], indices) + for (i = 1; i <= n; i++) { + elem = hist[indices[i]]; + if (elem ~ /^\$'\''.*'\''/) + hist[indices[i]] = es_unescape(substr(elem, 3, length(elem) - 3)); + } + n = hist_index - 1; + hist_index = 0; + for (i = 0; i < n; i++) + process_hist(hist[i]); + n = split(edit[edit_index - 1], indices) + for (i = 1; i <= n; i++) { + elem = edit[indices[i]]; + if (elem ~ /^\$'\''.*'\''/) + edit[indices[i]] = es_unescape(substr(elem, 3, length(elem) - 3)); + } + n = edit_index - 1; + edit_index = 0; + for (i = 0; i < n; i++) + process_edit(edit[i]); + } + if (NLFIX_WRITE) nlfix_end(out2); + line = "delete_indices=(" + for (i = 0; i < delete_count; i++) { + if (i != 0) line = line " "; + line = line delete_indices[i]; + } + line = line ")"; + print line; + print "shift_wskip=" shift_wskip; + print "shift_histindex_next=" shift_histindex_next; + } + ' + local awk_result + ble/util/assign awk_result '"$awk" -v _ble_bash="$_ble_bash" -v N="$N" "$awk_script" "$itmp1" mode=edit "$itmp2"' + builtin eval -- "$awk_result" + if ((${#delete_indices[@]})); then + if ((_ble_bash<50200)); then + ble/util/readarray --nlfix _ble_history < "$otmp1" + ble/util/readarray --nlfix _ble_history_edit < "$otmp2" + else + mapfile -d '' -t _ble_history < "$otmp1" + mapfile -d '' -t _ble_history_edit < "$otmp2" + fi + fi + _ble_local_tmpfile=$itmp2 ble/util/assign/rmtmp + _ble_local_tmpfile=$itmp1 ble/util/assign/rmtmp + _ble_local_tmpfile=$otmp2 ble/util/assign/rmtmp + _ble_local_tmpfile=$otmp1 ble/util/assign/rmtmp +} +function ble/builtin/history/erasedups/.impl-ranged { + local cmd=$1 beg=$2 + delete_indices=() + shift_histindex_next=0 + shift_wskip=0 + ble/path#remove HISTCONTROL erasedups + HISTCONTROL=$HISTCONTROL:ignoredups + local i j=$beg + for ((i=beg;i=0;i--)); do + builtin history -d "$((delete_indices[i]-max_index+max))" + done + fi +} +function ble/builtin/history/erasedups { + local cmd=$1 + local beg=0 N=${#_ble_history[@]} + if [[ $bleopt_history_erasedups_limit ]]; then + local limit=$((bleopt_history_erasedups_limit)) + if ((limit<=0)); then + ((beg=_ble_history_erasedups_base+limit)) + else + ((beg=N-1-limit)) + fi + ((beg<0)) && beg=0 + fi + local delete_indices shift_histindex_next shift_wskip + if ((beg>=N)); then + ble/path#remove HISTCONTROL erasedups + return 0 + elif ((beg>0)); then + ble/builtin/history/erasedups/.impl-ranged "$cmd" "$beg" + else + if ((_ble_bash>=40000&&N>=20000)); then + ble/builtin/history/erasedups/.impl-awk "$cmd" + else + ble/builtin/history/erasedups/.impl-for "$cmd" + fi + fi + if ((${#delete_indices[@]})); then + blehook/invoke history_change delete "${delete_indices[@]}" + ((_ble_builtin_history_wskip-=shift_wskip)) + [[ ${HISTINDEX_NEXT+set} ]] && ((HISTINDEX_NEXT-=shift_histindex_next)) + else + ((N)) && [[ ${_ble_history[N-1]} == "$cmd" ]] && return 9 + fi +} +function ble/builtin/history/option:s { + ble/builtin/history/.initialize + if [[ $_ble_decode_bind_state == none ]]; then + builtin history -s -- "$@" + return 0 + fi + local cmd=$1 + if [[ $HISTIGNORE ]]; then + local pats pat + ble/string#split pats : "$HISTIGNORE" + for pat in "${pats[@]}"; do + [[ $cmd == $pat ]] && return 0 + done + local HISTIGNORE= + fi + local HISTCONTROL=$HISTCONTROL + if [[ $HISTCONTROL ]]; then + [[ :$HISTCONTROL: == *:ignoreboth:* ]] && + HISTCONTROL=$HISTCONTROL:ignorespace:ignoredups + if [[ :$HISTCONTROL: == *:ignorespace:* ]]; then + [[ $cmd == [' ']* ]] && return 0 + fi + if [[ :$HISTCONTROL: == *:strip:* ]]; then + local ret + ble/string#rtrim "$cmd" + ble/string#match "$ret" $'^[ \t]*(\n([ \t]*\n)*)?' + cmd=${ret:${#BASH_REMATCH}} + [[ $BASH_REMATCH == *$'\n'* && $cmd == *$'\n'* ]] && cmd=$'\n'$cmd + fi + fi + local use_bash300wa= + if [[ $_ble_history_load_done ]]; then + if [[ $HISTCONTROL ]]; then + if [[ :$HISTCONTROL: == *:ignoredups:* ]]; then + local lastIndex=$((${#_ble_history[@]}-1)) + ((lastIndex>=0)) && [[ $cmd == "${_ble_history[lastIndex]}" ]] && return 0 + fi + if [[ :$HISTCONTROL: == *:erasedups:* ]]; then + ble/builtin/history/erasedups "$cmd" + (($?==9)) && return 0 + fi + fi + local topIndex=${#_ble_history[@]} + _ble_history[topIndex]=$cmd + _ble_history_edit[topIndex]=$cmd + _ble_history_count=$((topIndex+1)) + _ble_history_index=$_ble_history_count + ((_ble_bash<30100)) && use_bash300wa=1 + else + if [[ $HISTCONTROL ]]; then + _ble_history_count= + else + [[ $_ble_history_count ]] && + ((_ble_history_count++)) + fi + fi + ble/history/.update-position + if [[ $use_bash300wa ]]; then + if [[ $cmd == *$'\n'* ]]; then + ble/util/sprintf cmd 'eval -- %q' "$cmd" + fi + local tmp=$_ble_base_run/$$.history.tmp + [[ ${HISTFILE-} && ! $bleopt_history_share ]] && + ble/util/print "$cmd" >> "${HISTFILE-}" + ble/util/print "$cmd" >| "$tmp" + builtin history -r "$tmp" + else + ble/history:bash/clear-background-load + builtin history -s -- "$cmd" + fi + local max; ble/builtin/history/.get-max + _ble_builtin_history_prevmax=$max +} +function ble/builtin/history { + local set shopt; ble/base/.adjust-bash-options set shopt + local opt_d= flag_error= + local opt_c= opt_p= opt_s= + local opt_a= flags= + while [[ $1 == -* ]]; do + local arg=$1; shift + [[ $arg == -- ]] && break + if [[ $arg == --help ]]; then + flags=h$flags + continue + fi + local i n=${#arg} + for ((i=1;i&2 + flag_error=1 + elif ((i+1&2 + flag_error=1 + elif ((i+1&2 + flag_error=1 ;; + esac + done + done + if [[ $flag_error ]]; then + builtin history --usage 2>&1 1>/dev/null | ble/bin/grep ^history >&2 + ble/base/.restore-bash-options set shopt + return 2 + fi + if [[ $flags == *h* ]]; then + builtin history --help + local ext=$? + ble/base/.restore-bash-options set shopt + return "$ext" + fi + [[ ! $_ble_attached || $_ble_edit_exec_inside_userspace ]] && + ble/base/adjust-BASH_REMATCH + local flag_processed= + if [[ $opt_c ]]; then + ble/builtin/history/option:c + flag_processed=1 + fi + if [[ $opt_s ]]; then + local IFS=$_ble_term_IFS + ble/builtin/history/option:s "$*" + flag_processed=1 + elif [[ $opt_d ]]; then + ble/builtin/history/option:d "$opt_d" + flag_processed=1 + elif [[ $opt_a ]]; then + ble/builtin/history/option:"$opt_a" "$@" + flag_processed=1 + fi + if [[ $flag_processed ]]; then + ble/base/.restore-bash-options set shopt + return 0 + fi + if [[ $opt_p ]]; then + ble/builtin/history/option:p "$@" + else + builtin history "$@" + fi; local ext=$? + [[ ! $_ble_attached || $_ble_edit_exec_inside_userspace ]] && + ble/base/restore-BASH_REMATCH + ble/base/.restore-bash-options set shopt + return "$ext" +} +function history { + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_local_adjust" + ble/builtin/history "$@" + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_local_return" +} +_ble_history_prefix= +function ble/history/set-prefix { + _ble_history_prefix=$1 + ble/history/.update-position +} +_ble_history_COUNT= +_ble_history_INDEX= +function ble/history/.update-position { + if [[ $_ble_history_prefix ]]; then + builtin eval -- "_ble_history_COUNT=\${#${_ble_history_prefix}_history[@]}" + ((_ble_history_INDEX=${_ble_history_prefix}_history_index)) + else + if [[ ! $_ble_history_load_done ]]; then + if [[ ! $_ble_history_count ]]; then + local min max + ble/builtin/history/.get-min + ble/builtin/history/.get-max + ((_ble_history_count=max-min+1)) + fi + _ble_history_index=$_ble_history_count + fi + _ble_history_COUNT=$_ble_history_count + _ble_history_INDEX=$_ble_history_index + fi +} +function ble/history/update-position { + [[ $_ble_history_prefix$_ble_history_load_done ]] || + ble/history/.update-position +} +function ble/history/onleave.fire { + blehook/invoke history_leave "$@" +} +function ble/history/initialize { + [[ ! $_ble_history_prefix ]] && + ble/history:bash/initialize +} +function ble/history/get-count { + local _ble_local_var=count + [[ $1 == -v ]] && { _ble_local_var=$2; shift 2; } + ble/history/.update-position + (($_ble_local_var=_ble_history_COUNT)) +} +function ble/history/get-index { + local _ble_local_var=index + [[ $1 == -v ]] && { _ble_local_var=$2; shift 2; } + ble/history/.update-position + (($_ble_local_var=_ble_history_INDEX)) +} +function ble/history/set-index { + _ble_history_INDEX=$1 + ((${_ble_history_prefix:-_ble}_history_index=_ble_history_INDEX)) +} +function ble/history/get-entry { + local _ble_local_var=entry + [[ $1 == -v ]] && { _ble_local_var=$2; shift 2; } + if [[ $_ble_history_prefix$_ble_history_load_done ]]; then + builtin eval -- "$_ble_local_var=\${${_ble_history_prefix:-_ble}_history[\$1]}" + else + builtin eval -- "$_ble_local_var=" + fi +} +function ble/history/get-edited-entry { + local _ble_local_var=entry + [[ $1 == -v ]] && { _ble_local_var=$2; shift 2; } + if [[ $_ble_history_prefix$_ble_history_load_done ]]; then + builtin eval -- "$_ble_local_var=\${${_ble_history_prefix:-_ble}_history_edit[\$1]}" + else + builtin eval -- "$_ble_local_var=\$_ble_edit_str" + fi +} +function ble/history/set-edited-entry { + ble/history/initialize + local index=$1 str=$2 + local code=' + if [[ ! ${PREFIX_history_edit[index]+set} || ${PREFIX_history_edit[index]} != "$str" ]]; then + PREFIX_history_edit[index]=$str + PREFIX_history_dirt[index]=1 + fi' + builtin eval -- "${code//PREFIX/${_ble_history_prefix:-_ble}}" +} +function ble/history/.add-command-history { + [[ -o history ]] || ((_ble_bash<30200)) || return 1 + [[ $MC_SID == $$ && $_ble_edit_LINENO -le 2 && ( $1 == *PROMPT_COMMAND=* || $1 == *PS1=* ) ]] && return 1 + if [[ $_ble_history_load_done ]]; then + _ble_history_index=${#_ble_history[@]} + ble/history/.update-position + local index + for index in "${!_ble_history_dirt[@]}"; do + _ble_history_edit[index]=${_ble_history[index]} + done + _ble_history_dirt=() + ble-edit/undo/clear-all + fi + if [[ $bleopt_history_share ]]; then + ble/builtin/history/option:n + ble/builtin/history/option:s "$1" + ble/builtin/history/option:a + ble/builtin/history/.touch-histfile + else + ble/builtin/history/option:s "$1" + fi +} +function ble/history/add { + local command=$1 + ((bleopt_history_limit_length>0&&${#command}>bleopt_history_limit_length)) && return 1 + if [[ $_ble_history_prefix ]]; then + local code=' + local index + for index in "${!PREFIX_history_dirt[@]}"; do + PREFIX_history_edit[index]=${PREFIX_history[index]} + done + PREFIX_history_dirt=() + local topIndex=${#PREFIX_history[@]} + PREFIX_history[topIndex]=$command + PREFIX_history_edit[topIndex]=$command + PREFIX_history_index=$((++topIndex)) + _ble_history_COUNT=$topIndex + _ble_history_INDEX=$topIndex' + builtin eval -- "${code//PREFIX/$_ble_history_prefix}" + else + blehook/invoke ADDHISTORY "$command" && + ble/history/.add-command-history "$command" + fi +} +function ble/history/.read-isearch-options { + local opts=$1 + search_type=fixed + case :$opts: in + (*:regex:*) search_type=regex ;; + (*:glob:*) search_type=glob ;; + (*:head:*) search_type=head ;; + (*:tail:*) search_type=tail ;; + (*:condition:*) search_type=condition ;; + (*:predicate:*) search_type=predicate ;; + esac + [[ :$opts: != *:stop_check:* ]]; has_stop_check=$? + [[ :$opts: != *:progress:* ]]; has_progress=$? + [[ :$opts: != *:backward:* ]]; has_backward=$? +} +function ble/history/isearch-backward-blockwise { + local opts=$1 + local search_type has_stop_check has_progress has_backward + ble/history/.read-isearch-options "$opts" + ble/history/initialize + if [[ $_ble_history_prefix ]]; then + local -a _ble_history_edit + builtin eval "_ble_history_edit=(\"\${${_ble_history_prefix}_history_edit[@]}\")" + fi + local isearch_block=1000 # 十分高速なのでこれぐらい大きくてOK + local isearch_quantum=$((isearch_block*2)) # 倍数である必要有り + local irest block j i=$index + index= + local flag_icase=; [[ :$opts: == *:ignore-case:* ]] && flag_icase=1 + local flag_cycled= range_min range_max + while :; do + if ((i<=start)); then + range_min=0 range_max=$start + else + flag_cycled=1 + range_min=$((start+1)) range_max=$i + fi + while ((i>=range_min)); do + ((block=range_max-i, + block<5&&(block=5), + block>i+1-range_min&&(block=i+1-range_min), + irest=isearch_block-isearch_time%isearch_block, + block>irest&&(block=irest))) + [[ $flag_icase ]] && shopt -s nocasematch + case $search_type in + (regex) for ((j=i-block;++j<=i;)); do + [[ ${_ble_history_edit[j]} =~ $needle ]] && index=$j + done ;; + (glob) for ((j=i-block;++j<=i;)); do + [[ ${_ble_history_edit[j]} == $needle ]] && index=$j + done ;; + (head) for ((j=i-block;++j<=i;)); do + [[ ${_ble_history_edit[j]} == "$needle"* ]] && index=$j + done ;; + (tail) for ((j=i-block;++j<=i;)); do + [[ ${_ble_history_edit[j]} == *"$needle" ]] && index=$j + done ;; + (condition) builtin eval "function ble-edit/isearch/.search-block.proc { + local LINE INDEX + for ((j=i-block;++j<=i;)); do + LINE=\${_ble_history_edit[j]} INDEX=\$j + { $needle; } && index=\$j + done + }" + ble-edit/isearch/.search-block.proc ;; + (predicate) for ((j=i-block;++j<=i;)); do + "$needle" "${_ble_history_edit[j]}" "$j" && index=$j + done ;; + (*) for ((j=i-block;++j<=i;)); do + [[ ${_ble_history_edit[j]} == *"$needle"* ]] && index=$j + done ;; + esac + [[ $flag_icase ]] && shopt -u nocasematch + ((isearch_time+=block)) + [[ $index ]] && return 0 + ((i-=block)) + if ((has_stop_check&&isearch_time%isearch_block==0)) && ble/decode/has-input; then + index=$i + return 148 + elif ((has_progress&&isearch_time%isearch_quantum==0)); then + "$isearch_progress_callback" "$i" + fi + done + if [[ ! $flag_cycled && :$opts: == *:cyclic:* ]]; then + ((i=${#_ble_history_edit[@]}-1)) + ((start=start)); then + expr_cond="index<${#_ble_history_edit[@]}" expr_incr='index++' + else + expr_cond="indexstart)) || return 1 + else + ((index=0)) + ((index&2 + return 1 + fi +} +function ble/edit/performs-on-graphical-line { + [[ $edit_line_type == graphical ]] || return 1 + ble/textmap#is-up-to-date && return 0 + ((bleopt_edit_forced_textmap)) || return 1 + ble/widget/.update-textmap + return 0 +} +bleopt/declare -n info_display top +function bleopt/check:info_display { + case $value in + (top) + [[ $_ble_canvas_panel_vfill == 4 ]] && return 0 + _ble_canvas_panel_vfill=4 + [[ $_ble_attached ]] && ble/canvas/panel/clear + return 0 ;; + (bottom) + [[ $_ble_canvas_panel_vfill == 2 ]] && return 0 + _ble_canvas_panel_vfill=2 + [[ $_ble_attached ]] && ble/canvas/panel/clear + return 0 ;; + (*) + ble/util/print "bleopt: Invalid value for 'info_display': $value" + return 1 ;; + esac +} +bleopt/declare -v prompt_ps1_final '' +bleopt/declare -v prompt_ps1_transient '' +bleopt/declare -v prompt_rps1 '' +bleopt/declare -v prompt_rps1_final '' +bleopt/declare -v prompt_rps1_transient '' +bleopt/declare -v prompt_xterm_title '' +bleopt/declare -v prompt_screen_title '' +bleopt/declare -v prompt_term_status '' +bleopt/declare -o rps1 prompt_rps1 +bleopt/declare -o rps1_transient prompt_rps1_transient +bleopt/declare -v prompt_eol_mark $'\e[94m[ble: EOF]\e[m' +bleopt/declare -v prompt_ruler '' +bleopt/declare -v prompt_status_line '' +bleopt/declare -n prompt_status_align $'justify=\r' +ble/color/defface prompt_status_line fg=231,bg=240 +bleopt/declare -v prompt_command_changes_layout '' +function bleopt/check:prompt_status_align { + case $value in + (left|right|center|justify|justify=?*) + ble/prompt/unit#clear _ble_prompt_status hash + return 0 ;; + (*) + ble/util/print "bleopt prompt_status_align: unsupported value: '$value'" >&2 + return 1 ;; + esac +} +bleopt/declare -n internal_exec_type gexec +function bleopt/check:internal_exec_type { + if ! ble/is-function "ble-edit/exec:$value/process"; then + ble/util/print "bleopt: Invalid value internal_exec_type='$value'. A function 'ble-edit/exec:$value/process' is not defined." >&2 + return 1 + fi +} +bleopt/declare -v internal_exec_int_trace '' +bleopt/declare -v internal_suppress_bash_output 1 +bleopt/declare -n internal_ignoreeof_trap 'Use "exit" to leave the shell.' +bleopt/declare -v allow_exit_with_jobs '' +bleopt/declare -v history_share '' +bleopt/declare -v accept_line_threshold 5 +bleopt/declare -v exec_restore_pipestatus '' +bleopt/declare -v edit_marker $'\e[94m[ble: %s]\e[m' +bleopt/declare -v edit_marker_error $'\e[91m[ble: %s]\e[m' +function ble/edit/marker#get { + local msg=$1 opts=${2-} + ret=$msg + if [[ :$opts: != *:bare:* ]]; then + if [[ :$opts: == *:error:* ]]; then + ble/util/sprintf ret "$bleopt_edit_marker_error" "$ret" + else + ble/util/sprintf ret "$bleopt_edit_marker" "$ret" + fi + fi + if [[ ! $ret && $msg && :$opts: == *:non-empty:* ]]; then + if [[ :$opts: == *:error:* ]]; then + ret=$'\e[91m[ble: '$msg$']\e[m' + else + ret=$'\e[94m[ble: '$msg$']\e[m' + fi + fi + [[ $ret ]] +} +function ble/edit/marker#instantiate { + ble/edit/marker#get "$@" + if [[ $ret ]]; then + ret=${ret%$'\e[m'}$'\e[m' + x=0 y=0 g=0 LINES=1 ble/canvas/trace "$ret" confine:truncate + fi + [[ $ret ]] +} +function ble/edit/marker#declare-config { + local name=$1 value=$2 opts=$3 + if [[ :$opts: == *:error:* ]]; then + value=$'\e[91m[ble: '$value$']\e[m' + else + value=$'\e[94m[ble: '$value$']\e[m' + fi + bleopt/declare -v "$name" "$value" +} +function ble/edit/marker#get-config { + bleopt/default "$1" + local default_value=$ret + local current_ref=bleopt_$1 + local current_value=${!current_ref} + ret=$current_value + if [[ $current_value == "$default_value" ]]; then + if ble/string#match "$current_value" $'^\e\[94m\[ble: (.*)]\e\[m$'; then + ble/util/sprintf ret "$bleopt_edit_marker" "${BASH_REMATCH[1]}" + elif ble/string#match "$current_value" $'^\e\[91m\[ble: (.*)\]\e\[m$'; then + ble/util/sprintf ret "$bleopt_edit_marker_error" "${BASH_REMATCH[1]}" + fi + fi + [[ $ret ]] +} +function ble/edit/marker#instantiate-config { + ble/edit/marker#get-config "$1" && + ret=${ret%$'\e[m'}$'\e[m' && + x=0 y=0 g=0 LINES=1 ble/canvas/trace "$ret" confine:truncate + [[ $ret ]] +} +ble/edit/marker#declare-config exec_errexit_mark 'exit %d' error +ble/edit/marker#declare-config exec_elapsed_mark 'elapsed %s (CPU %s%%)' +bleopt/declare -v exec_elapsed_enabled 'usr+sys>=10000' +ble/edit/marker#declare-config exec_exit_mark 'exit' +bleopt/declare -v line_limit_length 10000 +bleopt/declare -v line_limit_type none +_ble_app_render_mode=panel +_ble_app_winsize=() +function ble/application/.set-up-render-mode { + [[ $1 == "$_ble_app_render_mode" ]] && return 0 + case $1 in + (panel) + ble/term/leave-altscr + ble/canvas/panel/invalidate ;; + (forms:*) + ble/term/enter-altscr + ble/util/buffer "$_ble_term_clear" + ble/util/buffer $'\e[H' + _ble_canvas_x=0 _ble_canvas_y=0 ;; + (*) + ble/util/print "ble/edit: unrecognized render mode '$1'." + return 1 ;; + esac +} +function ble/application/push-render-mode { + ble/application/.set-up-render-mode "$1" || return 1 + ble/array#unshift _ble_app_render_mode "$1" +} +function ble/application/pop-render-mode { + [[ ${_ble_app_render_mode[1]} ]] || return 1 + ble/application/.set-up-render-mode "${_ble_app_render_mode[1]}" + ble/array#shift _ble_app_render_mode +} +function ble/application/render { + if [[ $_ble_app_onwinch_Deferred ]]; then + ble/application/onwinch + return "$?" + fi + local _ble_app_onwinch_Suppress=1 + { + local render=$_ble_app_render_mode + case $render in + (panel) + local _ble_prompt_update=owner + ble/prompt/update + ble/canvas/panel/render ;; + (forms:*) + ble/forms/render "${render#*:}" ;; # NYI + esac + _ble_app_winsize=("$COLUMNS" "$LINES") + ble/util/buffer.flush + } + ble/util/unlocal _ble_app_onwinch_Suppress + if [[ $_ble_app_onwinch_Deferred ]]; then + ble/application/onwinch + fi +} +blehook idle_after_task!=ble/application/render +function ble/application/onwinch/panel.process-redraw-here { + local old_w=${_ble_app_winsize[0]} + local -a DRAW_BUFF=() + if ((COLUMNS>old_w)); then + ble/canvas/panel/goto-top-dock.draw + local i npanel=${#_ble_canvas_panel_class[@]} + local y0=0 + local nchar=0 + for ((i=0;i=y0)) && + ((nchar+=(_ble_canvas_y-y0)*(old_w-1)*_ble_canvas_x)) + local new_y_min=$(((nchar-1)/COLUMNS)) + ((_ble_canvas_y>new_y_min)) && + _ble_canvas_y=$new_y_min + fi + ble/canvas/panel#goto.draw 0 0 0 + ble/canvas/bflush.draw + return 0 +} +_ble_app_onwinch_Suppress= +_ble_app_onwinch_Deferred= +function ble/application/onwinch { + if [[ $_ble_app_onwinch_Suppress || $_ble_decode_hook_Processing == body || $_ble_decode_hook_Processing == prologue ]]; then + _ble_app_onwinch_Deferred=1 + return 0 + fi + local _ble_app_onwinch_Suppress=1 + _ble_app_onwinch_Deferred= + _ble_textmap_cols= + local old_size= i + for ((i=0;i<20;i++)); do + (ble/util/msleep 50) + if ble/util/is-running-in-subshell || ((50200<=_ble_bash&&_ble_bash<50300)); then + ble/term/update-winsize + fi + ble/util/joblist.check ignore-volatile-jobs + local size=$LINES:$COLUMNS + [[ $size == "$old_size" ]] && break + old_size=$size + local render=$_ble_app_render_mode + case $render in + (panel) + case $bleopt_canvas_winch_action in + (clear) + _ble_prompt_trim_opwd= + ble/util/buffer "$_ble_term_clear" ;; + (redraw-here) + ble/application/onwinch/panel.process-redraw-here ;; + (redraw-prev) + local -a DRAW_BUFF=() + ble/canvas/panel#goto.draw 0 0 0 + ble/canvas/bflush.draw ;; + (redraw-safe) ;; + esac + ble/canvas/panel/invalidate height ;; + (forms:*) + ble/forms/invalidate "${render#*:}" ;; # NYI + esac + ble/application/render + done + ble/util/unlocal _ble_app_onwinch_Suppress + if [[ $_ble_app_onwinch_Deferred ]]; then + ble/application/onwinch + fi +} +_ble_canvas_panel_focus=0 +_ble_canvas_panel_class=(ble/textarea ble/textarea ble/edit/info ble/edit/visible-bell ble/prompt/status) +_ble_canvas_panel_height=(1 0 0 0 0) +_ble_canvas_panel_vfill=4 +_ble_edit_command_layout_level=0 +function ble/edit/enter-command-layout { + ((_ble_edit_command_layout_level++==0)) || return 0 + ble/edit/info#collapse "$_ble_edit_info_panel" + ble/edit/visible-bell#collapse + ble/prompt/status#collapse +} +function ble/edit/leave-command-layout { + ((_ble_edit_command_layout_level>0&& + --_ble_edit_command_layout_level==0)) || return 0 + blehook/invoke info_reveal + ble/edit/info/default +} +function ble/edit/clear-command-layout { + ((_ble_edit_command_layout_level>0)) || return 0 + _ble_edit_command_layout_level=1 + ble/edit/leave-command-layout +} +function ble/edit/is-command-layout { + ((_ble_edit_command_layout_level>0)) +} +_ble_prompt_status_panel=4 +_ble_prompt_status_dirty= +_ble_prompt_status_data=() +_ble_prompt_status_bbox=() +function ble/prompt/status#panel::invalidate { + _ble_prompt_status_dirty=1 +} +function ble/prompt/status#panel::render { + [[ $_ble_prompt_status_dirty ]] || return 0 + _ble_prompt_status_dirty= + local index=$1 + local height; ble/prompt/status#panel::getHeight "$index" + [[ ${height#*:} == 1 ]] || return 0 + local -a DRAW_BUFF=() + height=$3 + if ((height!=1)); then + ble/canvas/panel/reallocate-height.draw + ble/canvas/bflush.draw + height=${_ble_canvas_panel_height[index]} + ((height==0)) && return 0 + fi + local esc=${_ble_prompt_status_data[10]} + if [[ $esc ]]; then + local prox=${_ble_prompt_status_data[11]} + local proy=${_ble_prompt_status_data[12]} + ble/canvas/panel#goto.draw "$_ble_prompt_status_panel" + ble/canvas/panel#put.draw "$_ble_prompt_status_panel" "$esc" "$prox" "$proy" + else + ble/canvas/panel#clear.draw "$_ble_prompt_status_panel" + fi + ble/canvas/bflush.draw +} +function ble/prompt/status#panel::getHeight { + if ble/edit/is-command-layout || [[ ! ${_ble_prompt_status_data[10]} ]]; then + height=0:0 + else + height=0:1 + fi +} +function ble/prompt/status#panel::onHeightChange { + ble/prompt/status#panel::invalidate +} +function ble/prompt/status#collapse { + local -a DRAW_BUFF=() + ble/canvas/panel#set-height.draw "$_ble_prompt_status_panel" 0 + ble/canvas/bflush.draw +} +_ble_edit_vbell_panel=3 +_ble_edit_vbell_state=('' '' 0) +function ble/edit/visible-bell#panel::getHeight { + if [[ ${_ble_edit_vbell_state[0]} ]]; then + height=0:1 + else + height=0:0 + fi +} +function ble/edit/visible-bell#panel::invalidate { + (($1!=_ble_edit_vbell_panel)) && return 0 + _ble_edit_vbell_state[2]=1 +} +function ble/edit/visible-bell#panel::render { + (($1!=_ble_edit_vbell_panel)) && return 0 + ble/edit/is-command-layout && return 0 + ((_ble_edit_vbell_state[2]==1)) || return 0 + local message=${_ble_edit_vbell_state[0]} + local -a DRAW_BUFF=() + if [[ ! $message ]]; then + ble/canvas/panel#set-height.draw "$_ble_edit_vbell_panel" 0 + else + ble/canvas/panel/reallocate-height.draw + local panel_height=${_ble_canvas_panel_height[$1]} + if ((panel_height>=1)); then + local ret + ble/canvas/panel/save-position; local pos=$ret + ble/canvas/put.draw "$_ble_term_sgr0" + ble/canvas/panel#clear.draw "$_ble_edit_vbell_panel" + ble/canvas/panel#goto.draw "$_ble_edit_vbell_panel" + local lines=1 cols=${COLUMNS:-80} + ((_ble_term_xenl||COLUMNS--)) + if ((cols!=_ble_edit_vbell_state[5])); then + local x=0 y=0 ret= sgr0= sgr1= + ble/canvas/trace-text "$message" nonewline:external-sgr + _ble_edit_vbell_state[4]=$ret + _ble_edit_vbell_state[5]=$cols + _ble_edit_vbell_state[6]=$x + fi + local sgr=${_ble_edit_vbell_state[3]} + local esc=${_ble_edit_vbell_state[4]} + local esc_w=${_ble_edit_vbell_state[6]} + local margin=$((cols-esc_w)) + case :$bleopt_vbell_align: in + (*:left:*) margin=0;; + (*:center:*) ((margin/=2)) ;; + (*:right:*) ;; + esac + ble/canvas/put.draw "$_ble_term_cr" + ((margin>0)) && ble/canvas/put-cuf.draw "$margin" + ble/canvas/put.draw "$sgr$esc" + ((_ble_canvas_x=margin+esc_w)) + ble/canvas/panel/load-position.draw "$pos" + fi + fi + ble/canvas/bflush.draw + _ble_edit_vbell_state[2]=0 +} +function ble/edit/visible-bell#collapse { + ble/util/idle.cancel ble/edit/visible-bell/.async-1.idle + ble/util/idle.cancel ble/edit/visible-bell/.async-2.idle + _ble_edit_vbell_state=('' '' 0) + local -a DRAW_BUFF=() + ble/canvas/panel#set-height.draw "$_ble_edit_vbell_panel" 0 + ble/canvas/bflush.draw +} +function ble/edit/visible-bell/.show { + [[ ${_ble_edit_vbell_state[0]} ]] || return 0 + local ret + ble/color/face2sgr "$1"; local sgr=$ret + if [[ $sgr != "${_ble_edit_vbell_state[2]}" ]]; then + _ble_edit_vbell_state[2]=1 # invalidate + _ble_edit_vbell_state[3]=$sgr + fi + ble/edit/visible-bell#panel::render "$_ble_edit_vbell_panel" + ble/util/buffer.flush +} +function ble/edit/visible-bell/.clear { + ble/edit/visible-bell#collapse + ble/util/buffer.flush +} +function ble/edit/visible-bell { + [[ $_ble_attached ]] || return 1 + ble/util/is-running-in-subshell && return 1 + ble/is-function ble/util/idle.push || return 1 + ble/util/is-running-in-idle && return 1 + local message=$1 opts=$2 + if [[ ! $message ]]; then + ble/edit/visible-bell/.clear + return 0 + fi + ble/util/idle.cancel ble/edit/visible-bell/.async-1.idle + ble/util/idle.cancel ble/edit/visible-bell/.async-2.idle + _ble_edit_vbell_state=("$message" "$opts" 1) + ble/edit/visible-bell/.show vbell_flash + ble/util/idle.push --sleep=50 ble/edit/visible-bell/.async-1.idle + return 0 +} +function ble/edit/visible-bell/.async-1.idle { + ble/edit/visible-bell/.show vbell + if [[ :${_ble_edit_vbell_state[1]}: != *:persistent:* ]]; then + local msec=$((bleopt_vbell_duration)) + ble/util/idle.push --sleep="$msec" ble/edit/visible-bell/.async-2.idle + fi + return 0 +} +function ble/edit/visible-bell/.async-2.idle { + ble/edit/visible-bell/.clear + return 0 +} +_ble_prompt_hash= +_ble_prompt_version=0 +function ble/prompt/.escape-control-characters { + ret=$1 + local ctrl=$'\001-\037\177' + case $_ble_util_locale_encoding in + (UTF-8) ctrl=$ctrl$'\302\200-\302\237' ;; + (C) ctrl=$ctrl$'\200-\237' ;; + esac + local LC_ALL= LC_COLLATE=C glob_ctrl=[$ctrl] + [[ $ret == *$glob_ctrl* ]] || return 0 + local out= head tail=$ret cs + while head=${tail%%$glob_ctrl*}; [[ $head != "$tail" ]]; do + ble/util/s2c "${tail:${#head}:1}" + ble/unicode/GraphemeCluster/.get-ascii-rep "$ret" # -> cs + out=$out$head$'\e[9807m'$cs$'\e[9807m' + tail=${tail#*$glob_ctrl} + done + ret=$out$tail +} +ble/function#suppress-stderr ble/prompt/.escape-control-characters # LC_COLLATE +function ble/prompt/.initialize-constant { + local _ble_local_ps=$1 + local _ble_local_defeval=$2 + local _ble_local_opts=$3 + if ((_ble_bash>=40400)); then + ret=${_ble_local_ps@P} + else + builtin eval -- "$_ble_local_defeval" + fi + if [[ $_ble_local_opts == *:escape:* ]]; then + if ((_ble_bash>=50200)); then + if [[ $ret == *\^['A'-'Z[\]^_?']* ]]; then + builtin eval -- "$_ble_local_defeval" + ble/prompt/.escape-control-characters "$ret" + elif [[ $ret == *$'\t'* ]]; then + ble/prompt/.escape-control-characters "$ret" + fi + else + ble/prompt/.escape-control-characters "$_ble_prompt_const_s" + fi + fi +} +function ble/prompt/initialize { + local ret + ble/prompt/.initialize-constant '\H' 'ret=${HOSTNAME:-$_ble_base_env_HOSTNAME}' escape + _ble_prompt_const_H=$ret + if local rex='^[0-9]+(\.[0-9]){3}$'; [[ $_ble_prompt_const_H =~ $rex ]]; then + _ble_prompt_const_h=$_ble_prompt_const_H + else + _ble_prompt_const_h=${_ble_prompt_const_H%%.*} + fi + ble/prompt/.initialize-constant '\l' 'ble/util/assign ret "ble/bin/tty 2>/dev/null";ret=${ret##*/}' + _ble_prompt_const_l=$ret + ble/prompt/.initialize-constant '\s' 'ret=${0##*/}' escape + _ble_prompt_const_s=$ret + ble/prompt/.initialize-constant '\u' 'ret=${USER:-$_ble_base_env_USER}' escape + _ble_prompt_const_u=$ret + ble/util/sprintf _ble_prompt_const_v '%d.%d' "${BASH_VERSINFO[0]}" "${BASH_VERSINFO[1]}" + ble/util/sprintf _ble_prompt_const_V '%d.%d.%d' "${BASH_VERSINFO[0]}" "${BASH_VERSINFO[1]}" "${BASH_VERSINFO[2]}" + if [[ $EUID -eq 0 ]]; then + _ble_prompt_const_root='#' + else + _ble_prompt_const_root='$' + fi + if [[ $OSTYPE == cygwin* ]]; then + local windir=/cygdrive/c/Windows + if [[ $WINDIR == [a-zA-Z]:\\* ]]; then + local bsl='\' sl=/ + local c=${WINDIR::1} path=${WINDIR:3} + if ble/string#isupper "$c"; then + if ((_ble_bash>=40000)); then + c=${c,?} + else + local ret + ble/util/s2c "$c" + ble/util/c2s "$((ret+32))" + c=$ret + fi + fi + windir=/cygdrive/$c/${path//"$bsl"/"$sl"} + fi + if [[ -e $windir && -w $windir ]]; then + _ble_prompt_const_root='#' + fi + elif [[ $OSTYPE == msys* ]]; then + if ble/bin#has id getent; then + local id getent + ble/util/assign id 'id -G' + ble/util/assign getent 'getent -w group S-1-16-12288' + ble/string#split getent : "$getent" + [[ " $id " == *" ${getent[1]} "* ]] && + _ble_prompt_const_root='#' + fi + fi +} +function ble/prompt/unit#update { + local unit=$1 + local prompt_unit_changed= + local prompt_unit_expired= + local ohashref=${unit}_data[1]; ohashref=${!ohashref-} + if [[ ! $ohashref ]]; then + prompt_unit_expired=1 + else + ble/prompt/unit#update/.update-dependencies "$ohashref" + local ohash=${unit}_data[2]; ohash=${!ohash} + builtin eval -- "local nhash=\"$ohashref\"" 2>/dev/null + [[ $nhash != "$ohash" ]] && prompt_unit_expired=1 + fi + if [[ $prompt_unit_expired ]]; then + local prompt_unit=$unit + local prompt_hashref_dep= # プロンプト間依存性 + local prompt_hashref_var= # 変数に対する依存性 + ble/prompt/unit:"$unit"/update "$unit" && + ((prompt_unit_changed=1,${unit}_data[0]++)) + local hashref=${prompt_hashref_base-'$_ble_prompt_version'}:$prompt_hashref_dep:$prompt_hashref_var + builtin eval -- "${unit}_data[1]=\$hashref" + builtin eval -- "${unit}_data[2]=\"$hashref\"" 2>/dev/null + ble/util/unlocal prompt_unit prompt_hashref_dep + fi + if [[ $prompt_unit ]]; then + local ref1='$'$unit'_data' + [[ ,$prompt_hashref_dep, != *,"$ref1",* ]] && + prompt_hashref_dep=$prompt_hashref_dep${prompt_hashref_dep:+,}$ref1 + fi + [[ $prompt_unit_changed ]] +} +function ble/prompt/unit#update/.update-dependencies { + local ohashref=$1 + local otree=${ohashref#*:}; otree=${otree%%:*} + if [[ $otree ]]; then + ble/string#split otree , "$otree" + if [[ ! $ble_prompt_unit_processing ]]; then + local ble_prompt_unit_processing=1 + "${_ble_util_set_declare[@]//NAME/ble_prompt_unit_mark}" # WA #D1570 checked + elif ble/set#contains ble_prompt_unit_mark "$unit"; then + ble/util/print "ble/prompt: FATAL: detected cyclic dependency ($unit required by $ble_prompt_unit_parent)" >&"$_ble_util_fd_tui_stderr" + return 1 + fi + local ble_prompt_unit_parent=$unit + ble/set#add ble_prompt_unit_mark "$unit" + local prompt_unit= # 依存関係の登録はしない + local child + for child in "${otree[@]}"; do + [[ $child == '$'?*'_data' ]] || continue + child=${child:1:${#child}-6} + ble/is-function ble/prompt/unit:"$child"/update && + ble/prompt/unit#update "$child" + done + ble/set#remove ble_prompt_unit_mark "$unit" + fi +} +function ble/prompt/unit#clear { + local prefix=$1 + builtin eval -- "${prefix}_data[2]=" +} +function ble/prompt/unit/assign { + local var=$1 value=$2 + [[ $value == "${!var}" ]] && return 1 + prompt_unit_changed=1 + builtin eval -- "$var=\$value" +} +function ble/prompt/unit/add-hash { + [[ $prompt_unit && ,$prompt_hashref_var, != *,"$1",* ]] && + prompt_hashref_var=$prompt_hashref_var${prompt_hashref_var:+,}$1 + return 0 +} +_ble_prompt_ps1_dirty= +_ble_prompt_ps1_data=(0 '' '' 0 0 0 32 0 '' '') +_ble_prompt_ps1_bbox=() +_ble_prompt_rps1_dirty= +_ble_prompt_rps1_data=() +_ble_prompt_rps1_gbox=() +_ble_prompt_rps1_shown= +_ble_prompt_xterm_title_dirty= +_ble_prompt_xterm_title_data=() +_ble_prompt_screen_title_dirty= +_ble_prompt_screen_title_data=() +_ble_prompt_term_status_dirty= +_ble_prompt_term_status_data=() +function ble/prompt/print { + local ret=$1 + [[ $prompt_noesc ]] || + ble/string#escape-characters "$ret" '\$"`' + ble/canvas/put.draw "$ret" +} +function ble/prompt/process-prompt-string { + local ps1=$1 + local i=0 iN=${#ps1} + local rex_letters='^[^\]+|\\$' + while ((i=0)) && ble/widget/.update-textmap + local fmt=${1:-'(%s,%s)'} pos + ble/prompt/unit/add-hash '${_ble_textmap_pos[_ble_edit_ind]}' + ble/string#split-words pos "${_ble_textmap_pos[_ble_edit_ind]}" + ble/util/sprintf pos "$fmt" "$((pos[1]+1))" "$((pos[0]+1))" + ble/prompt/print "$pos" +} +function ble/prompt/backslash:row { + ((_ble_textmap_dbeg>=0)) && ble/widget/.update-textmap + local pos + ble/prompt/unit/add-hash '${_ble_textmap_pos[_ble_edit_ind]}' + ble/string#split-words pos "${_ble_textmap_pos[_ble_edit_ind]}" + ble/prompt/print "$((pos[1]+1))" +} +function ble/prompt/backslash:column { + ((_ble_textmap_dbeg>=0)) && ble/widget/.update-textmap + local pos + ble/prompt/unit/add-hash '${_ble_textmap_pos[_ble_edit_ind]}' + ble/string#split-words pos "${_ble_textmap_pos[_ble_edit_ind]}" + ble/prompt/print "$((pos[0]+1))" +} +function ble/prompt/backslash:point { + ble/prompt/unit/add-hash '$_ble_edit_ind' + ble/prompt/print "$_ble_edit_ind" +} +function ble/prompt/backslash:mark { + ble/prompt/unit/add-hash '$_ble_edit_mark' + ble/prompt/print "$_ble_edit_mark" +} +function ble/prompt/backslash:history-index { + ble/prompt/unit/add-hash '$_ble_history_INDEX' + ble/canvas/put.draw "$((_ble_history_INDEX+1))" +} +function ble/prompt/backslash:history-percentile { + ble/prompt/unit/add-hash '$_ble_history_INDEX' + ble/prompt/unit/add-hash '$_ble_history_COUNT' + local index=$_ble_history_INDEX + local count=$_ble_history_COUNT + ((count||count++)) + ble/canvas/put.draw "$((index*100/count))%" +} +function ble/prompt/.update-working-directory { + [[ $prompt_cache_wd ]] && return 0 + if [[ ! ${PWD//'/'} ]]; then + prompt_cache_wd=$PWD + return 0 + fi + local head= body=${PWD%/} + if [[ $body == "$HOME" ]]; then + prompt_cache_wd='~' + return 0 + elif [[ $body == "$HOME"/* ]]; then + head='~/' + body=${body#"$HOME"/} + fi + if [[ $PROMPT_DIRTRIM ]]; then + local dirtrim=$((PROMPT_DIRTRIM)) + local pat='[^/]' + local count=${body//$pat} + if ((${#count}>=dirtrim)); then + local ret + ble/string#repeat '/*' "$dirtrim" + local omit=${body%$ret} + ((${#omit}>3)) && + body=...${body:${#omit}} + fi + fi + prompt_cache_wd=$head$body +} +function ble/prompt/.escape/check-double-quotation { + if [[ $tail == '"'* ]]; then + if [[ ! $nest ]]; then + out=$out'\"' + tail=${tail:1} + else + out=$out'"' + tail=${tail:1} + nest=\"$nest + ble/prompt/.escape/update-rex_skip + fi + return 0 + else + return 1 + fi +} +function ble/prompt/.escape/check-command-substitution { + if [[ $tail == '$('* ]]; then + out=$out'$(' + tail=${tail:2} + nest=')'$nest + ble/prompt/.escape/update-rex_skip + return 0 + else + return 1 + fi +} +function ble/prompt/.escape/check-parameter-expansion { + if [[ $tail == '${'* ]]; then + out=$out'${' + tail=${tail:2} + nest='}'$nest + ble/prompt/.escape/update-rex_skip + return 0 + else + return 1 + fi +} +function ble/prompt/.escape/check-incomplete-quotation { + if [[ $tail == '`'* ]]; then + local rex='^`([^\`]|\\.)*\\$' + [[ $tail =~ $rex ]] && tail=$tail'\' + out=$out$tail'`' + tail= + return 0 + elif [[ $nest == ['})']* && $tail == \'* ]]; then + out=$out$tail$q + tail= + return 0 + elif [[ $nest == ['})']* && $tail == \$\'* ]]; then + local rex='^\$'$q'([^\'$q']|\\.)*\\$' + [[ $tail =~ $rex ]] && tail=$tail'\' + out=$out$tail$q + tail= + return 0 + elif [[ $tail == '\' ]]; then + out=$out'\\' + tail= + return 0 + else + return 1 + fi +} +function ble/prompt/.escape/update-rex_skip { + if [[ $nest == \)* ]]; then + rex_skip=$rex_skip_paren + elif [[ $nest == \}* ]]; then + rex_skip=$rex_skip_brace + else + rex_skip=$rex_skip_dquot + fi +} +function ble/prompt/.escape { + local tail=$1 out= nest= + local q=\' + local rex_bq='`([^\`]|\\.)*`' + local rex_sq=$q'[^'$q']*'$q'|\$'$q'([^\'$q']|\\.)*'$q + local rex_skip + local rex_skip_dquot='^([^\"$`]|'$rex_bq'|\\.)+' + local rex_skip_brace='^([^\"$`'$q'}]|'$rex_bq'|'$rex_sq'|\\.)+' + local rex_skip_paren='^([^\"$`'$q'()]|'$rex_bq'|'$rex_sq'|\\.)+' + ble/prompt/.escape/update-rex_skip + while [[ $tail ]]; do + if [[ $tail =~ $rex_skip ]]; then + out=$out$BASH_REMATCH + tail=${tail:${#BASH_REMATCH}} + elif [[ $nest == ['})"']* && $tail == "${nest::1}"* ]]; then + out=$out${nest::1} + tail=${tail:1} + nest=${nest:1} + ble/prompt/.escape/update-rex_skip + elif [[ $nest == \)* && $tail == \(* ]]; then + out=$out'(' + tail=${tail:1} + nest=')'$nest + elif ble/prompt/.escape/check-double-quotation; then + continue + elif ble/prompt/.escape/check-command-substitution; then + continue + elif ble/prompt/.escape/check-parameter-expansion; then + continue + elif ble/prompt/.escape/check-incomplete-quotation; then + continue + else + out=$out${tail::1} + tail=${tail:1} + fi + done + ret=$out$nest +} +function ble/prompt/.get-keymap-for-current-mode { + ble/prompt/unit/add-hash '$_ble_decode_keymap,${_ble_decode_keymap_stack[*]}' + keymap=$_ble_decode_keymap + local index=${#_ble_decode_keymap_stack[@]} + while :; do + case $keymap in (vi_?map|emacs) return 0 ;; esac + ((--index<0)) && break + keymap=${_ble_decode_keymap_stack[index]} + done + return 1 +} +function ble/prompt/.uses-builtin-prompt-expansion { + ((_ble_bash>=40400)) || return 1 + local ps=$1 + local chars_safe_esc='][0-7aenrdtAT@DhHjlsuvV!$\wW' + [[ ( $OSTYPE == cygwin || $OSTYPE == msys ) && $_ble_prompt_const_root == '#' ]] && + chars_safe_esc=${chars_safe_esc//'$'} # Note: cygwin では ble.sh 独自の方法で \$ を処理する。 + [[ $ps == *'\'[!"$chars_safe_esc"]* ]] && return 1 + local glob_ctrl=$'[\001-\037\177]' + [[ $ps == *'\'[wW]* && $PWD == *$glob_ctrl* ]] && return 1 + [[ $ps == *'\s'* && $_ble_prompt_const_s == *$'\e'* ]] && return 1 + [[ $ps == *'\u'* && $_ble_prompt_const_u == *$'\e'* ]] && return 1 + [[ $ps == *'\h'* && $_ble_prompt_const_h == *$'\e'* ]] && return 1 + [[ $ps == *'\H'* && $_ble_prompt_const_H == *$'\e'* ]] && return 1 + return 0 +} +function ble/prompt/.instantiate { + trace_hash= esc= x=0 y=0 g=0 lc=32 lg=0 + local ps=$1 opts=$2 x0=$3 y0=$4 g0=$5 lc0=$6 lg0=$7 esc0=$8 trace_hash0=$9 + [[ ! $ps ]] && return 0 + local expanded= + if ble/prompt/.uses-builtin-prompt-expansion "$ps"; then + [[ $ps == *'\'[wW]* ]] && ble/prompt/unit/add-hash '$PWD' + ble-edit/exec/.setexit "$_ble_edit_exec_lastarg" + LINENO=$_ble_edit_LINENO \ + BASH_COMMAND=$_ble_edit_exec_BASH_COMMAND \ + builtin eval 'expanded=${ps@P}' + else + local prompt_noesc= + shopt -q promptvars &>/dev/null || prompt_noesc=1 + local -a DRAW_BUFF=() + ble/prompt/process-prompt-string "$ps" + local processed; ble/canvas/sflush.draw -v processed + if [[ ! $prompt_noesc ]]; then + local ret + ble/prompt/.escape "$processed"; local escaped=$ret + expanded=${trace_hash0#*:} # Note: これは次行が失敗した時の既定値 + ble-edit/exec/.setexit "$_ble_edit_exec_lastarg" + LINENO=$_ble_edit_LINENO \ + BASH_COMMAND=$_ble_edit_exec_BASH_COMMAND \ + builtin eval "expanded=\"$escaped\"" + else + expanded=$processed + fi + fi + if [[ :$opts: == *:show-mode-in-prompt:* ]]; then + if ble/util/rlvar#test show-mode-in-prompt; then + local keymap; ble/prompt/.get-keymap-for-current-mode + local ret= + case $keymap in + (vi_imap) ble/util/rlvar#read vi-ins-mode-string '(ins)' ;; # Note: bash-4.3 では '+' + (vi_[noxs]map) ble/util/rlvar#read vi-cmd-mode-string '(cmd)' ;; # Note: bash-4.3 では ':' + (emacs) ble/util/rlvar#read emacs-mode-string '@' ;; + esac + [[ $ret ]] && expanded=$ret$expanded + fi + fi + if [[ :$opts: == *:no-trace:* ]]; then + x=0 y=0 g=0 lc=32 lg=0 + esc=$expanded + elif + local ret g0=0 + if ble/string#match ":$opts:" ':g0=([^:]+):'; then + ((g0=BASH_REMATCH[1])) + elif ble/string#match ":$opts:" ':face0=([^:]+):'; then + ble/color/face2g "${BASH_REMATCH[1]}" && g0=$ret + fi + local rows=${prompt_rows:-${LINES:-25}} + local cols=${prompt_cols:-${COLUMNS:-80}} + local color=$_ble_color_g2sgr_version + local bleopt=$bleopt_char_width_mode,$bleopt_char_width_version,$bleopt_emoji_version,$bleopt_emoji_opts + trace_hash=$opts#$rows,$cols,$color,$g0#$bleopt#$expanded + [[ $trace_hash != "$trace_hash0" ]] + then + local trace_opts=$opts:prompt + [[ $bleopt_internal_suppress_bash_output ]] || trace_opts=$trace_opts:left-char + x=0 y=0 g=0 lc=32 lg=0 + local ret + LINES=$rows COLUMNS=$cols ble/canvas/trace "$expanded" "$trace_opts"; local traced=$ret + ((lc<0&&(lc=0))) + esc=$traced + return 0 + else + x=$x0 y=$y0 g=$g0 lc=$lc0 lg=$lg0 + esc=$esc0 + return 2 + fi +} +function ble/prompt/unit:{section}/clear { + local prefix=$1 type=${2:-hash:draw} + [[ :$type: == *:hash:* ]] && + builtin eval -- "${prefix}_data[2]=" + [[ :$type: == *:tail:* ]] && + builtin eval -- "${prefix}_data=(\"\${${prefix}_data[@]::10}\")" + [[ :$type: == *:draw:* ]] && + builtin eval -- "${prefix}_dirty=1" + [[ :$type: == *:all:* ]] && + builtin eval -- "${prefix}_data=(\"\${${prefix}_data[0]}\")" + return 0 +} +function ble/prompt/unit:{section}/get { + local ref=${1}_data[8]; ret=${!ref} +} +function ble/prompt/unit:{section}/update { + local prefix=$1 ps=$2 opts=$3 + local -a vars; vars=(data dirty) + [[ :$opts: == *:measure-bbox:* ]] && ble/array#push vars bbox + [[ :$opts: == *:measure-gbox:* ]] && ble/array#push vars gbox + local "${vars[@]/%/=}" # WA #D1570 checked + ble/util/restore-vars "${prefix}_" "${vars[@]}" + local has_changed= + if [[ $prompt_unit_expired ]]; then + local original_esc=${data[8]}:${data[9]}:${data[10]} # esc:trace_hash:tailor + if [[ $ps ]]; then + [[ :$opts: == *:measure-bbox:* ]] && + local x1=${bbox[0]} y1=${bbox[1]} x2=${bbox[2]} y2=${bbox[3]} + [[ :$opts: == *:measure-gbox:* ]] && + local gx1=${gbox[0]} gy1=${gbox[1]} gx2=${gbox[2]} gy2=${gbox[3]} + local trace_hash esc x y g lc lg + ble/prompt/.instantiate "$ps" "$opts" "${data[@]:3:7}" + data=("${data[0]:-0}" '' '' "$x" "$y" "$g" "$lc" "$lg" "$esc" "$trace_hash" "${data[@]:10}") + [[ :$opts: == *:measure-bbox:* ]] && + bbox=("$x1" "$y1" "$x2" "$y2") + [[ :$opts: == *:measure-gbox:* ]] && + gbox=("$gx1" "$gy1" "$gx2" "$gy2") + else + data=("${data[0]:-0}" '' '' 0 0 0 32 0 '' '' "${data[@]:10}") + [[ :$opts: == *:measure-bbox:* ]] && bbox=() + [[ :$opts: == *:measure-gbox:* ]] && gbox=() + fi + [[ ${data[8]}:${data[9]}:${data[10]} != "$original_esc" ]] && has_changed=1 + fi + [[ $has_changed ]] && ((dirty=1)) + ble/util/save-vars "${prefix}_" "${vars[@]}" + [[ $has_changed ]] +} +function ble/prompt/unit:_ble_prompt_ps1/update { + ble/prompt/unit/add-hash '$prompt_ps1' + ble/prompt/unit:{section}/update _ble_prompt_ps1 "$prompt_ps1" show-mode-in-prompt:measure-bbox +} +function ble/prompt/unit:_ble_prompt_rps1/update { + ble/prompt/unit/add-hash '$prompt_rps1' + ble/prompt/unit/add-hash '$_ble_prompt_ps1_data' + local cols=${COLUMNS-80} + local ps1x=${_ble_prompt_ps1_data[3]} + local ps1y=${_ble_prompt_ps1_data[4]} + local prompt_rows=$((ps1y+1)) prompt_cols=$cols + ble/prompt/unit:{section}/update _ble_prompt_rps1 "$prompt_rps1" confine:relative:right:measure-gbox || return 1 + local esc=${_ble_prompt_rps1_data[8]} width= + if [[ $esc ]]; then + ((width=_ble_prompt_rps1_gbox[2]-_ble_prompt_rps1_gbox[0])) + ((width&&20+width0)); then + ((x+=xshift)) + ble/canvas/put-cuf.draw "$xshift" + fi + ble/canvas/put.draw "$esc" + ble/canvas/sflush.draw -v esc + _ble_prompt_status_data[10]=$esc + _ble_prompt_status_data[11]=$x + _ble_prompt_status_data[12]=$y + else + _ble_prompt_status_data[10]= + _ble_prompt_status_data[11]= + _ble_prompt_status_data[12]= + fi + return 0 +} +if ble/is-function ble/util/idle.push; then + _ble_prompt_timeout_task= + _ble_prompt_timeout_lineno= + function ble/prompt/timeout/process { + ble/util/idle.suspend # exit に失敗した時の為 task を suspend にする + ble/edit/marker#instantiate 'auto-logout' non-empty + local msg="$ret timed out waiting for input" + ble/widget/.internal-print-command ' + ble/util/print "$msg" + _ble_builtin_exit_processing=1 ble/builtin/exit 0' pre-flush + return 1 # exit に失敗した時 + } >&"$_ble_util_fd_tui_stdout" 2>&"$_ble_util_fd_tui_stderr" + function ble/prompt/timeout/check { + [[ $_ble_edit_lineno == "$_ble_prompt_timeout_lineno" ]] && return 0 + _ble_prompt_timeout_lineno=$_ble_edit_lineno + if [[ ${TMOUT:-} =~ ^[0-9]+ ]] && ((BASH_REMATCH>0)); then + if [[ ! $_ble_prompt_timeout_task ]]; then + ble/util/idle.push -Z 'ble/prompt/timeout/process' + _ble_prompt_timeout_task=$_ble_util_idle_lasttask + fi + ble/util/idle#sleep "$_ble_prompt_timeout_task" "$((BASH_REMATCH*1000))" + elif [[ $_ble_prompt_timeout_task ]]; then + ble/util/idle#suspend "$_ble_prompt_timeout_task" + fi + } +else + function ble/prompt/timeout/check { return 0; } +fi +function ble/prompt/update/.has-prompt_command { + [[ ${_ble_edit_PROMPT_COMMAND[*]} == *[![:space:]]* ]] +} +function _ble_prompt_update__eval_prompt_command_1 { + local _ble_edit_exec_TRAPDEBUG_enabled=1 + ble-edit/exec/.setexit "$_ble_edit_exec_lastarg" + LINENO=$_ble_edit_LINENO \ + BASH_COMMAND=$_ble_edit_exec_BASH_COMMAND \ + builtin eval -- "$1" +} +ble/function#trace _ble_prompt_update__eval_prompt_command_1 +function ble/prompt/update/.eval-prompt_command { + ((${#PROMPT_COMMAND[@]})) || return 0 + local _ble_local_command _ble_edit_exec_TRAPDEBUG_adjusted=1 + ble-edit/exec:gexec/.TRAPDEBUG/restore filter + for _ble_local_command in "${PROMPT_COMMAND[@]}"; do + [[ $_ble_local_command ]] || continue + _ble_prompt_update__eval_prompt_command_1 "$_ble_local_command" + done + _ble_edit_exec_gexec__TRAPDEBUG_adjust +} +_ble_prompt_update= +_ble_prompt_update_dirty= +_ble_prompt_rps1_enabled= +function ble/prompt/update { + local opts=:$1: dirty= + local count; ble/history/get-count + local version=$COLUMNS:$_ble_edit_lineno:$count + if [[ :$opts: == *:check-dirty:* && $_ble_prompt_update == owner ]]; then + if [[ $_ble_prompt_update_dirty && :$opts: != *:leave:* && $_ble_prompt_hash == "$version" ]]; then + [[ $_ble_prompt_update_dirty == dirty ]]; local ext=$? + _ble_prompt_update_dirty=done + return "$ext" + fi + fi + ble/prompt/timeout/check + _ble_prompt_rps1_enabled= + if ((_ble_textarea_panel==0)); then # 補助プロンプトに対しては PROMPT_COMMAND は実行しない + if [[ ${_ble_prompt_hash%:*} != "${version%:*}" && $opts != *:leave:* ]]; then + ble-edit/exec:gexec/invoke-hook-with-setexit internal_PRECMD + if ble/prompt/update/.has-prompt_command || blehook/has-hook PRECMD; then + if [[ $bleopt_prompt_command_changes_layout ]]; then + ble/edit/enter-command-layout # #D1800 pair=leave-command-layout + local -a DRAW_BUFF=() + ble/canvas/panel#goto.draw 0 0 0 sgr0 + ble/canvas/bflush.draw + ble/util/buffer.flush + fi + ((_ble_edit_attached)) && ble-edit/restore-PS1 + ble-edit/exec:gexec/invoke-hook-with-setexit PRECMD + ble/prompt/update/.eval-prompt_command + ((_ble_edit_attached)) && ble-edit/adjust-PS1 + if [[ $bleopt_prompt_command_changes_layout ]]; then + ble/edit/leave-command-layout # #D1800 pair=enter-command-layout + fi + fi + fi + fi + local prompt_opts= + local prompt_ps1=$_ble_edit_PS1 + local prompt_rps1=$bleopt_prompt_rps1 + if [[ $opts == *:leave:* ]]; then + local ps1f=$bleopt_prompt_ps1_final + local rps1f=$bleopt_prompt_rps1_final + local ps1t=$bleopt_prompt_ps1_transient + [[ :$ps1t: == *:trim:* || :$ps1t: == *:same-dir:* && $PWD != $_ble_prompt_trim_opwd ]] && ps1t= + if [[ $ps1f || $rps1f || $ps1t ]]; then + prompt_opts=$prompt_opts:leave-rewrite + [[ $ps1f || $ps1t ]] && prompt_ps1=$ps1f + [[ $rps1f ]] && prompt_rps1=$rps1f + ble/textarea#invalidate + fi + fi + if [[ :$prompt_opts: == *:leave-rewrite:* || $_ble_prompt_hash != "$version" ]]; then + _ble_prompt_hash=$version + ((_ble_prompt_version++)) + fi + ble/history/update-position + local prompt_hashref_base='$_ble_prompt_version' + local prompt_rows=${LINES:-25} + local prompt_cols=${COLUMNS:-80} + local "${_ble_prompt_cache_vars[@]/%/=}" # WA #D1570 checked + local ble_prompt_unit_processing=1 + "${_ble_util_set_declare[@]//NAME/ble_prompt_unit_mark}" # disable=#D1570 + local prompt_unit= + ble/prompt/unit#update _ble_prompt_ps1 && dirty=1 + if [[ _ble_textarea_panel -ne 0 || $ble_attach_first_prompt || $MC_SID == $$ ]]; then + [[ $dirty ]] + return "$?" + fi + if [[ :$opts: == *:leave:* && ! $rps1f && $bleopt_prompt_rps1_transient ]]; then + [[ ${_ble_prompt_rps1_data[10]} ]] && dirty=1 _ble_prompt_rps1_enabled=erase + else + [[ $prompt_rps1 || ${_ble_prompt_rps1_data[10]} ]] && + ble/prompt/unit#update _ble_prompt_rps1 && dirty=1 + [[ ${_ble_prompt_rps1_data[10]} ]] && _ble_prompt_rps1_enabled=1 + fi + case ${_ble_term_TERM:-$TERM:-} in + (sun*|minix*|eterm*) ;; # black list + (*) + [[ $bleopt_prompt_xterm_title || ${_ble_prompt_xterm_title_data[10]} ]] && + ble/prompt/unit#update _ble_prompt_xterm_title && dirty=1 ;; + esac + case ${_ble_term_TERM:-$TERM:-} in + (screen:*|tmux:*|contra:*|screen.*|screen-*) + [[ $bleopt_prompt_screen_title || ${_ble_prompt_screen_title_data[10]} ]] && + ble/prompt/unit#update _ble_prompt_screen_title && dirty=1 ;; + esac + if [[ $_ble_term_tsl && $_ble_term_fsl ]]; then + [[ $bleopt_prompt_term_status || ${_ble_prompt_term_status_data[10]} ]] && + ble/prompt/unit#update _ble_prompt_term_status && dirty=1 + fi + [[ $bleopt_prompt_status_line || ${_ble_prompt_status_data[10]} ]] && + ble/prompt/unit#update _ble_prompt_status && dirty=1 + [[ $dirty ]] && _ble_prompt_update_dirty=dirty + [[ $dirty ]] +} +function ble/prompt/clear { + _ble_prompt_hash= + ble/textarea#invalidate +} +_ble_prompt_ruler=('' '' 0) +function ble/prompt/print-ruler.draw { + [[ $bleopt_prompt_ruler ]] || return 0 + local command=$1 opts=$2 cols=$COLUMNS + local rex_eval_prefix='(([!{]|time|if|then|elif|while|until|do|exec|eval|command|env|nice|nohup|xargs|sudo)[[:space:]]+)?' + local rex_clear_command='(tput[[:space:]]+)?(clear|reset)' + local rex=$'(^|[\n;&|(])[[:space:]]*'$rex_eval_prefix$rex_clear_command'([ \t\n;&|)]|$)' + [[ $command =~ $rex ]] && return 0 + if [[ :$opts: == *:keep-info:* ]]; then + ble/canvas/panel#increase-height.draw "$_ble_textarea_panel" 1 + ble/canvas/panel#goto.draw "$_ble_textarea_panel" 0 0 + ((_ble_canvas_panel_height[_ble_textarea_panel]--)) + fi + if [[ $bleopt_prompt_ruler == empty-line ]]; then + ble/canvas/put.draw $'\n' + else + if [[ $bleopt_prompt_ruler != "${_ble_prompt_ruler[0]}" ]]; then + if [[ $bleopt_prompt_ruler ]]; then + local ret= x=0 y=0 g=0 x1=0 x2=0 y1=0 y2=0 + LINES=1 COLUMNS=$cols ble/canvas/trace "$bleopt_prompt_ruler" truncate:measure-bbox + _ble_prompt_ruler=("$bleopt_prompt_ruler" "$ret" "$x2") + if ((!_ble_prompt_ruler[2])); then + _ble_prompt_ruler[1]=${_ble_prompt_ruler[1]}' ' + ((_ble_prompt_ruler[2]++)) + fi + else + _ble_prompt_ruler=('' '' 0) + fi + fi + local w=${_ble_prompt_ruler[2]} + local repeat=$((cols/w)) + ble/string#repeat "${_ble_prompt_ruler[1]}" "$repeat" + ble/canvas/put.draw "$ret" + ble/string#repeat ' ' "$((cols-repeat*w))" + ble/canvas/put.draw "$ret" + ((_ble_term_xenl)) && ble/canvas/put.draw $'\n' + fi +} +function ble/prompt/print-ruler.buff { + local -a DRAW_BUFF=() + ble/prompt/print-ruler.draw "$@" + ble/canvas/bflush.draw +} +function ble/edit/info/.initialize-size { + local ret + ble/canvas/panel/layout/.get-available-height "$_ble_edit_info_panel" + cols=${COLUMNS-80} lines=$ret +} +_ble_edit_info_panel=2 +_ble_edit_info=(0 0 "") +_ble_edit_info_invalidated= +function ble/edit/info#panel::getHeight { + (($1!=_ble_edit_info_panel)) && return 0 + if ble/edit/is-command-layout || [[ ! ${_ble_edit_info[2]} ]]; then + height=0:0 + else + height=1:$((_ble_edit_info[1]+1)) + fi +} +function ble/edit/info#panel::invalidate { + (($1!=_ble_edit_info_panel)) && return 0 + _ble_edit_info_invalidated=1 +} +function ble/edit/info#panel::render { + (($1!=_ble_edit_info_panel)) && return 0 + ble/edit/is-command-layout && return 0 + [[ $_ble_edit_info_invalidated ]] || return 0 + local x=${_ble_edit_info[0]} y=${_ble_edit_info[1]} content=${_ble_edit_info[2]} + local -a DRAW_BUFF=() + if [[ ! $content ]]; then + ble/canvas/panel#set-height.draw "$_ble_edit_info_panel" 0 + else + ble/canvas/panel/reallocate-height.draw + if ((y<_ble_canvas_panel_height[$1])); then + ble/canvas/panel#clear.draw "$_ble_edit_info_panel" + ble/canvas/panel#goto.draw "$_ble_edit_info_panel" + ble/canvas/put.draw "$content" + ((_ble_canvas_y+=y,_ble_canvas_x=x)) + else + _ble_edit_info=(0 0 "") + ble/canvas/panel#set-height.draw "$_ble_edit_info_panel" 0 + fi + fi + ble/canvas/bflush.draw + _ble_edit_info_invalidated= +} +function ble/edit/info#collapse { + local panel=${1-$_ble_prompt_info_panel} + ((panel!=_ble_edit_info_panel)) && return 0 + local -a DRAW_BUFF=() + ble/canvas/panel#set-height.draw "$panel" 0 + ble/canvas/bflush.draw + _ble_edit_info_invalidated=1 +} +function ble/edit/info/.construct-content { + local cols lines + ble/edit/info/.initialize-size + x=0 y=0 content= + local type=$1 text=$2 + case $1 in + (clear) ;; + (ansi|esc) + local trace_opts=truncate + [[ $bleopt_info_display == bottom ]] && trace_opts=$trace_opts:noscrc + [[ $1 == esc ]] && trace_opts=$trace_opts:terminfo + local ret= g=0 + LINES=$lines ble/canvas/trace "$text" "$trace_opts" + content=$ret ;; + (text) + local ret + ble/canvas/trace-text "$text" + content=$ret ;; + (store) + x=$2 y=$3 content=$4 + ((y&2 ;; + esac +} +function ble/edit/info/.render-content { + local x=$1 y=$2 content=$3 opts=$4 + if [[ $content != "${_ble_edit_info[2]}" ]]; then + _ble_edit_info=("$x" "$y" "$content") + _ble_edit_info_invalidated=1 + fi + [[ :$opts: == *:defer:* ]] && return 0 + [[ $_ble_app_render_mode == panel ]] || return 0 + ble/edit/info#panel::render "$_ble_edit_info_panel" +} +_ble_edit_info_default=(0 0 "") +_ble_edit_info_scene=default +function ble/edit/info/show { + local type=$1 text=$2 + if [[ $text ]]; then + local x y content= + ble/edit/info/.construct-content "$@" + ble/edit/info/.render-content "$x" "$y" "$content" + ble/util/buffer.flush + _ble_edit_info_scene=show + else + ble/edit/info/default + fi +} +function ble/edit/info/set-default { + local type=$1 text=$2 + local x y content + ble/edit/info/.construct-content "$type" "$text" + _ble_edit_info_default=("$x" "$y" "$content") + [[ $_ble_edit_info_scene == default ]] && + ble/edit/info/.render-content "${_ble_edit_info_default[@]}" defer +} +function ble/edit/info/default { + _ble_edit_info_scene=default + if (($#)); then + ble/edit/info/set-default "$@" + else + ble/edit/info/.render-content "${_ble_edit_info_default[@]}" defer + fi + return 0 +} +function ble/edit/info/clear { + [[ ${_ble_edit_info[2]} ]] || return 1 + [[ $_ble_app_render_mode == panel ]] || return 0 + _ble_edit_info_scene=clear + ble/edit/info/.render-content 0 0 "" +} +function ble/edit/info/immediate-show { + local ret; ble/canvas/panel/save-position + ble/edit/info/show "$@" + ble/canvas/panel/load-position "$ret" + ble/util/buffer.flush +} +function ble/edit/info/immediate-default { + local ret; ble/canvas/panel/save-position + ble/edit/info/default + ble/edit/info/.render-content "${_ble_edit_info_default[@]}" + ble/canvas/panel/load-position "$ret" + ble/util/buffer.flush +} +_ble_edit_VARNAMES=( + _ble_edit_str + _ble_edit_ind + _ble_edit_mark + _ble_edit_mark_active + _ble_edit_overwrite_mode + _ble_edit_line_disabled + _ble_edit_arg + _ble_edit_dirty_draw_beg + _ble_edit_dirty_draw_end + _ble_edit_dirty_draw_end0 + _ble_edit_dirty_syntax_beg + _ble_edit_dirty_syntax_end + _ble_edit_dirty_syntax_end0 + _ble_edit_dirty_observer + _ble_edit_kill_index + _ble_edit_kill_ring + _ble_edit_kill_type) +_ble_edit_str= +_ble_edit_ind=0 +_ble_edit_mark=0 +_ble_edit_mark_active= +_ble_edit_overwrite_mode= +_ble_edit_line_disabled= +_ble_edit_arg= +_ble_edit_kill_index=0 +_ble_edit_kill_ring=() +_ble_edit_kill_type=() +function ble-edit/content/replace { + local beg=$1 end=$2 + local ins=$3 reason=${4:-edit} + _ble_edit_str="${_ble_edit_str::beg}""$ins""${_ble_edit_str:end}" + ble-edit/content/.update-dirty-range "$beg" "$((beg+${#ins}))" "$end" "$reason" + ble/util/assert \ + '((0<=_ble_edit_dirty_syntax_beg&&_ble_edit_dirty_syntax_end<=${#_ble_edit_str}))' \ + "0 <= beg=$_ble_edit_dirty_syntax_beg <= end=$_ble_edit_dirty_syntax_end <= len=${#_ble_edit_str}; beg=$beg, end=$end, ins(${#ins})=$ins" || + { + _ble_edit_dirty_syntax_beg=0 + _ble_edit_dirty_syntax_end=${#_ble_edit_str} + _ble_edit_dirty_syntax_end0=0 + local olen=$((${#_ble_edit_str}-${#ins}+end-beg)) + ((olen<0&&(olen=0), + _ble_edit_ind>olen&&(_ble_edit_ind=olen), + _ble_edit_mark>olen&&(_ble_edit_mark=olen))) + } +} +function ble-edit/content/reset { + local str=$1 reason=${2:-edit} + local beg=0 end=${#str} end0=${#_ble_edit_str} + _ble_edit_str=$str + ble-edit/content/.update-dirty-range "$beg" "$end" "$end0" "$reason" + ble/util/assert \ + '((0<=_ble_edit_dirty_syntax_beg&&_ble_edit_dirty_syntax_end<=${#_ble_edit_str}))' \ + "0 <= beg=$_ble_edit_dirty_syntax_beg <= end=$_ble_edit_dirty_syntax_end <= len=${#_ble_edit_str}; str(${#str})=$str" || + { + _ble_edit_dirty_syntax_beg=0 + _ble_edit_dirty_syntax_end=${#_ble_edit_str} + _ble_edit_dirty_syntax_end0=0 + } +} +function ble-edit/content/reset-and-check-dirty { + local str=$1 reason=${2:-edit} + [[ $_ble_edit_str == "$str" ]] && return 0 + local ret pref suff + ble/string#common-prefix "$_ble_edit_str" "$str"; pref=$ret + local dmin=${#pref} + ble/string#common-suffix "${_ble_edit_str:dmin}" "${str:dmin}"; suff=$ret + local dmax0=$((${#_ble_edit_str}-${#suff})) dmax=$((${#str}-${#suff})) + _ble_edit_str=$str + ble-edit/content/.update-dirty-range "$dmin" "$dmax" "$dmax0" "$reason" +} +function ble-edit/content/replace-limited { + insert=$3 + if [[ $bleopt_line_limit_type == discard ]]; then + local ibeg=$1 iend=$2 opts=:$4: + local limit=$((bleopt_line_limit_length)) + if ((limit)); then + local inslimit=$((limit-${#_ble_edit_str}+(iend-ibeg))) + ((inslimitinslimit)) && insert=${insert::inslimit} + if [[ ! $insert ]] && ((ibeg==iend)); then + [[ $opts == *:nobell:* ]] || + ble/widget/.bell "ble: reached line_limit_length=$limit" + return 1 + fi + fi + fi + ble-edit/content/replace "$1" "$2" "$insert" +} +function ble-edit/content/check-limit { + local opts=:${1:-truncate:editor}: + if [[ $opts == *:${bleopt_line_limit_type:-none}:* ]]; then + local limit=$((bleopt_line_limit_length)) + if ((limit>0&&${#_ble_edit_str}>limit)); then + local ble_edit_line_limit=$limit + ble-decode-key "$_ble_decode_KCODE_LINE_LIMIT" + fi + fi +} +function ble/widget/__line_limit__ { + local editor=ble/widget/${1:-edit-and-execute-command.impl} + local limit=$ble_edit_line_limit + case ${bleopt_line_limit_type:-none} in + (editor) + local content=$_ble_edit_str + ble-edit/content/reset "# reached line_limit_length=$limit" + _ble_edit_ind=0 _ble_edit_mark=0 + "$editor" "$content" + (($?==127)) && + ble-edit/content/reset "${content::limit}" + return 1 ;; + (truncate|*) + ble-edit/content/replace "$limit" "${#_ble_edit_str}" '' + ((_ble_edit_ind>limit&&(_ble_edit_ind=limit))) + ((_ble_edit_mark>limit&&(_ble_edit_mark=limit))) + return 1 ;; + esac + return 0 +} +_ble_edit_dirty_draw_beg=-1 +_ble_edit_dirty_draw_end=-1 +_ble_edit_dirty_draw_end0=-1 +_ble_edit_dirty_syntax_beg=0 +_ble_edit_dirty_syntax_end=0 +_ble_edit_dirty_syntax_end0=1 +_ble_edit_dirty_observer=() +function ble-edit/content/.update-dirty-range { + ble/dirty-range#update --prefix=_ble_edit_dirty_draw_ "${@:1:3}" + ble/dirty-range#update --prefix=_ble_edit_dirty_syntax_ "${@:1:3}" + ble/textmap#update-dirty-range "${@:1:3}" + local obs + for obs in "${_ble_edit_dirty_observer[@]}"; do "$obs" "$@"; done +} +function ble-edit/content/update-syntax { + if ble/util/import/is-loaded "$_ble_base/lib/core-syntax.sh"; then + local beg end end0 + ble/dirty-range#load --prefix=_ble_edit_dirty_syntax_ + if ((beg>=0)); then + ble/dirty-range#clear --prefix=_ble_edit_dirty_syntax_ + ble/syntax/parse "$_ble_edit_str" '' "$beg" "$end" "$end0" + fi + fi +} +function ble-edit/content/eolp { + local pos=${1:-$_ble_edit_ind} + ((pos==${#_ble_edit_str})) || [[ ${_ble_edit_str:pos:1} == $'\n' ]] +} +function ble-edit/content/bolp { + local pos=${1:-$_ble_edit_ind} + ((pos<=0)) || [[ ${_ble_edit_str:pos-1:1} == $'\n' ]] +} +function ble-edit/content/find-logical-eol { + local index=${1:-$_ble_edit_ind} offset=${2:-0} + if ((offset>0)); then + local text=${_ble_edit_str:index} + local rex=$'^([^\n]*\n){0,'$((offset-1))$'}([^\n]*\n)?[^\n]*' + [[ $text =~ $rex ]] + ((ret=index+${#BASH_REMATCH})) + [[ ${BASH_REMATCH[2]} ]] + elif ((offset<0)); then + local text=${_ble_edit_str::index} + local rex=$'(\n[^\n]*){0,'$((-offset-1))$'}(\n[^\n]*)?$' + [[ $text =~ $rex ]] + if [[ $BASH_REMATCH ]]; then + ((ret=index-${#BASH_REMATCH})) + [[ ${BASH_REMATCH[2]} ]] + else + ble-edit/content/find-logical-eol "$index" 0 + return 1 + fi + else + local text=${_ble_edit_str:index} + text=${text%%$'\n'*} + ((ret=index+${#text})) + return 0 + fi +} +function ble-edit/content/find-logical-bol { + local index=${1:-$_ble_edit_ind} offset=${2:-0} + if ((offset>0)); then + local rex=$'^([^\n]*\n){0,'$((offset-1))$'}([^\n]*\n)?' + [[ ${_ble_edit_str:index} =~ $rex ]] + if [[ $BASH_REMATCH ]]; then + ((ret=index+${#BASH_REMATCH})) + [[ ${BASH_REMATCH[2]} ]] + else + ble-edit/content/find-logical-bol "$index" 0 + return 1 + fi + elif ((offset<0)); then + ble-edit/content/find-logical-eol "$index" "$offset"; local ext=$? + ble-edit/content/find-logical-bol "$ret" 0 + return "$ext" + else + local text=${_ble_edit_str::index} + text=${text##*$'\n'} + ((ret=index-${#text})) + return 0 + fi +} +function ble-edit/content/find-non-space { + local bol=$1 + local rex=$'^[ \t]*'; [[ ${_ble_edit_str:bol} =~ $rex ]] + ret=$((bol+${#BASH_REMATCH})) +} +function ble-edit/content/is-single-line { + [[ $_ble_edit_str != *$'\n'* ]] +} +function ble-edit/content/get-arg { + local default_value=$1 + local value=$_ble_edit_arg + _ble_edit_arg= + if [[ $value == +* ]]; then + if [[ $value == + ]]; then + arg=4 + return 0 + fi + value=${value#+} + fi + if [[ $value == -* ]]; then + if [[ $value == - ]]; then + arg=-1 + else + arg=$((-10#0${value#-})) + fi + else + if [[ $value ]]; then + arg=$((10#0$value)) + else + arg=$default_value + fi + fi +} +function ble-edit/content/clear-arg { + _ble_edit_arg= +} +function ble-edit/content/toggle-arg { + if [[ $_ble_edit_arg == + ]]; then + _ble_edit_arg= + elif [[ $_ble_edit_arg && $_ble_edit_arg != +* ]]; then + _ble_edit_arg=+$_ble_edit_arg + else + _ble_edit_arg=+ + fi +} +function ble/keymap:generic/get-arg { + if [[ $_ble_decode_keymap == vi_[noxs]map ]]; then + local ARG FLAG REG + ble/keymap:vi/get-arg "$1" + arg=$ARG + else + ble-edit/content/get-arg "$1" + fi +} +function ble/keymap:generic/clear-arg { + if [[ $_ble_decode_keymap == vi_[noxs]map ]]; then + ble/keymap:vi/clear-arg + else + ble-edit/content/clear-arg + fi +} +function ble/widget/append-arg-or { + ble/function#try ble/widget/complete/.select-menu-with-arg "${2-}" && return 0 + local n=${#KEYS[@]}; ((n&&n--)) + local code=$((KEYS[n]&_ble_decode_MaskChar)) + ((code==0)) && return 1 + local ret; ble/util/c2s "$code"; local ch=$ret + if + if [[ $_ble_edit_arg == + ]]; then + [[ $ch == [-0-9] ]] && _ble_edit_arg= + elif [[ $_ble_edit_arg == +* ]]; then + false + elif [[ $_ble_edit_arg ]]; then + [[ $ch == [0-9] ]] + else + ((KEYS[n]&_ble_decode_MaskFlag)) + fi + then + ble/decode/widget/skip-lastwidget + _ble_edit_arg=$_ble_edit_arg$ch + else + ble/widget/"$1" + fi +} +function ble/widget/append-arg { + ble/widget/append-arg-or self-insert "$@" +} +function ble/widget/universal-arg { + ble/decode/widget/skip-lastwidget + ble-edit/content/toggle-arg +} +function ble-edit/content/prepend-kill-ring { + _ble_edit_kill_index=0 + local otext=${_ble_edit_kill_ring[0]-} ntext=$1 + local otype=${_ble_edit_kill_type[0]-} ntype=$2 + if [[ $otype == L || $ntype == L ]]; then + ntext=${ntext%$'\n'}$'\n' + otext=${otext%$'\n'}$'\n' + _ble_edit_kill_ring[0]=$ntext$otext + _ble_edit_kill_type[0]=L + elif [[ $otype == B:* ]]; then + if [[ $ntype != B:* ]]; then + ntext=${ntext%$'\n'}$'\n' + local ret; ble/string#count-char "$ntext" $'\n' + ble/string#repeat '0 ' "$ret" + ntype=B:${ret%' '} + fi + _ble_edit_kill_ring[0]=$ntext$otext + _ble_edit_kill_type[0]="B:${ntype#B:} ${otype#B:}" + else + _ble_edit_kill_ring[0]=$ntext$otext + _ble_edit_kill_type[0]=$otype + fi +} +function ble-edit/content/append-kill-ring { + _ble_edit_kill_index=0 + local otext=${_ble_edit_kill_ring[0]-} ntext=$1 + local otype=${_ble_edit_kill_type[0]-} ntype=$2 + if [[ $otype == L || $ntype == L ]]; then + ntext=${ntext%$'\n'}$'\n' + otext=${otext%$'\n'}$'\n' + _ble_edit_kill_ring[0]=$otext$ntext + _ble_edit_kill_type[0]=L + elif [[ $otype == B:* ]]; then + if [[ $ntype != B:* ]]; then + ntext=${ntext%$'\n'}$'\n' + local ret; ble/string#count-char "$ntext" $'\n' + ble/string#repeat '0 ' "$ret" + ntype=B:${ret%' '} + fi + _ble_edit_kill_ring[0]=$otext$ntext + _ble_edit_kill_type[0]="B:${otype#B:} ${ntype#B:}" + else + _ble_edit_kill_ring[0]=$otext$ntext + _ble_edit_kill_type[0]=$otype + fi +} +function ble-edit/content/push-kill-ring { + if ((${#_ble_edit_kill_ring[@]})) && [[ ${LASTWIDGET#ble/widget/} == kill-* || ${LASTWIDGET#ble/widget/} == copy-* ]]; then + local proc= + local name; ble/string#split-words name "${WIDGET#ble/widget/}" + if [[ $3 == backward || $name == kill-backward-* || $name == copy-backward-* ]]; then + proc=ble-edit/content/prepend-kill-ring + elif [[ $3 == forward || $name == kill-forward-* || $name == copy-forward-* ]]; then + proc=ble-edit/content/append-kill-ring + elif [[ $name == kill-region* || $name == copy-region* ]]; then + proc= + elif [[ $3 == [0-9]*:[0-9]* ]] && ((${3##*:}<=_ble_edit_ind)); then + proc=ble-edit/content/prepend-kill-ring + else + proc=ble-edit/content/append-kill-ring + fi + if [[ $proc ]]; then + "$proc" "$1" "$2" + return "$?" + fi + fi + _ble_edit_kill_index=0 + ble/array#unshift _ble_edit_kill_ring "$1" + ble/array#unshift _ble_edit_kill_type "$2" +} +_ble_edit_PS1_adjusted= +_ble_edit_PS1='\s-\v\$ ' +_ble_edit_PROMPT_COMMAND= +function ble-edit/adjust-PS1 { + [[ $_ble_edit_PS1_adjusted ]] && return 0 + _ble_edit_PS1_adjusted=1 + _ble_edit_PS1=$PS1 + if [[ $bleopt_internal_suppress_bash_output ]]; then + PS1='[ble: press RET to continue]' + else + PS1= + fi + if ble/is-array PROMPT_COMMAND; then + ble/idict#copy _ble_edit_PROMPT_COMMAND PROMPT_COMMAND + else + ble/variable#copy-state PROMPT_COMMAND _ble_edit_PROMPT_COMMAND + fi + builtin unset -v PROMPT_COMMAND +} +function ble-edit/restore-PS1 { + [[ $_ble_edit_PS1_adjusted ]] || return 1 + _ble_edit_PS1_adjusted= + PS1=$_ble_edit_PS1 + if ble/is-array _ble_edit_PROMPT_COMMAND; then + ble/idict#copy PROMPT_COMMAND _ble_edit_PROMPT_COMMAND + else + ble/variable#copy-state _ble_edit_PROMPT_COMMAND PROMPT_COMMAND + fi +} +_ble_edit_IGNOREEOF_adjusted= +_ble_edit_IGNOREEOF= +function ble-edit/adjust-IGNOREEOF { + [[ $_ble_edit_IGNOREEOF_adjusted ]] && return 0 + _ble_edit_IGNOREEOF_adjusted=1 + if [[ ${IGNOREEOF+set} ]]; then + _ble_edit_IGNOREEOF=$IGNOREEOF + else + builtin unset -v _ble_edit_IGNOREEOF + fi + if ((_ble_bash>=40000)); then + builtin unset -v IGNOREEOF + else + IGNOREEOF=9999 + fi +} +function ble-edit/restore-IGNOREEOF { + [[ $_ble_edit_IGNOREEOF_adjusted ]] || return 1 + _ble_edit_IGNOREEOF_adjusted= + if [[ ${_ble_edit_IGNOREEOF+set} ]]; then + IGNOREEOF=$_ble_edit_IGNOREEOF + else + builtin unset -v IGNOREEOF + fi +} +_ble_edit_READLINE=() +function ble-edit/adjust-READLINE { + [[ $_ble_edit_READLINE ]] && return 0 + _ble_edit_READLINE=1 + ble/variable#copy-state READLINE_LINE '_ble_edit_READLINE[1]' + ble/variable#copy-state READLINE_POINT '_ble_edit_READLINE[2]' + ble/variable#copy-state READLINE_MARK '_ble_edit_READLINE[3]' +} +function ble-edit/restore-READLINE { + [[ $_ble_edit_READLINE ]] || return 0 + _ble_edit_READLINE= + ble/variable#copy-state '_ble_edit_READLINE[1]' READLINE_LINE + ble/variable#copy-state '_ble_edit_READLINE[2]' READLINE_POINT + ble/variable#copy-state '_ble_edit_READLINE[3]' READLINE_MARK +} +function ble-edit/eval-IGNOREEOF { + local value= + if [[ $_ble_edit_IGNOREEOF_adjusted ]]; then + value=${_ble_edit_IGNOREEOF-0} + else + value=${IGNOREEOF-0} + fi + if [[ $value && ! ${value//[0-9]} ]]; then + ret=$((10#0$value)) + else + ret=10 + fi +} +bleopt/declare -n canvas_winch_action redraw-here +function ble-edit/attach/TRAPWINCH { + ((_ble_edit_attached)) && [[ $_ble_term_state == internal ]] && + ! ble/edit/is-command-layout && ! ble/util/is-running-in-subshell || + return 0 + ble/application/onwinch 2>&"$_ble_util_fd_tui_stderr" +} +_ble_edit_attached=0 +function ble-edit/attach/.attach { + ((_ble_edit_attached)) && return 0 + _ble_edit_attached=1 + if [[ ! ${_ble_edit_LINENO+set} ]]; then + _ble_edit_LINENO=${BASH_LINENO[${#BASH_LINENO[@]}-1]} + ((_ble_edit_LINENO<0)) && _ble_edit_LINENO=0 + ((_ble_edit_CMD<=_ble_edit_LINENO+1)) && ((_ble_edit_CMD=_ble_edit_LINENO+1)) + fi + ble/builtin/trap/install-hook WINCH readline + blehook internal_WINCH!=ble-edit/attach/TRAPWINCH + ble-edit/adjust-PS1 + ble-edit/adjust-READLINE + ble-edit/adjust-IGNOREEOF + [[ $bleopt_internal_exec_type == exec ]] && _ble_edit_IFS=$IFS +} +function ble-edit/attach/.detach { + ((!_ble_edit_attached)) && return 0 + ble-edit/restore-PS1 + ble-edit/restore-READLINE + ble-edit/restore-IGNOREEOF + [[ $bleopt_internal_exec_type == exec ]] && IFS=$_ble_edit_IFS + _ble_edit_attached=0 +} +_ble_textarea_VARNAMES=( + _ble_textarea_buffer + _ble_textarea_bufferName + _ble_textarea_cur + _ble_textarea_panel + _ble_textarea_scroll + _ble_textarea_scroll_new + _ble_textarea_gendx + _ble_textarea_gendy + _ble_textarea_invalidated + _ble_textarea_version + _ble_textarea_caret_state + _ble_textarea_cache + _ble_textarea_render_defer) +_ble_textarea_local_VARNAMES=() +function ble/textarea#panel::getHeight { + if [[ $1 == "$_ble_textarea_panel" ]]; then + local min=$((_ble_prompt_ps1_data[4]+1)) max=$((_ble_textmap_endy+1)) + ((min=_ble_app_winsize[0])) && return 1 + local height=${_ble_canvas_panel_height[ipanel]} + local proy=${_ble_prompt_ps1_data[4]} + local newline= reflow= offset= + if ((y<=proy)); then + ((newline=y,reflow=0,offset=x)) + elif ((y=6&&rnline>rheight+2?2:1)) + local smin smax + ((smin=rcy-rheight+margin, + smin>nline-height&&(smin=nline-height), + smax=rcy-margin, + smax<0&&(smax=0))) + if ((scroll>smax)); then + scroll=$smax + elif ((scrollwmax&&(umax=wmax))) + else + scroll= + if ! ble/util/assert '((height==nline))'; then + ble/canvas/panel#set-height.draw "$_ble_textarea_panel" "$nline" + height=$nline + fi + fi +} +function ble/textarea#render/.perform-scroll { + local new_scroll=$1 + if ((new_scroll!=_ble_textarea_scroll)); then + local scry=$((begy+1)) + local scrh=$((height-scry)) + local fmin fmax index + if ((_ble_textarea_scroll>new_scroll)); then + local shift=$((_ble_textarea_scroll-new_scroll)) + local draw_shift=$((shift=0)); then + dirty=1 + elif [[ $_ble_textarea_invalidated ]]; then + dirty=1 + elif [[ $_ble_textarea_caret_state != "$caret_state" ]]; then + dirty=1 + elif [[ $_ble_textarea_scroll != "$_ble_textarea_scroll_new" ]]; then + dirty=1 + elif [[ :$opts: == *:leave:* || :$opts: == *:update:* ]]; then + dirty=1 + fi + if [[ ! $dirty ]]; then + ble/textarea#focus + return 0 + fi + local cols=${COLUMNS-80} + local subprompt_enabled= + ((_ble_textarea_panel==0)) && subprompt_enabled=1 + local rps1_enabled=$_ble_prompt_rps1_enabled + local rps1_width=${_ble_prompt_rps1_data[11]} + if [[ $rps1_enabled ]]; then + ((cols-=rps1_width+1,_ble_term_xenl||cols--)) + if [[ $rps1_enabled == erase ]]; then + ble/textarea#render/.erase-rprompt + rps1_enabled= + fi + fi + local text=$_ble_edit_str index=$_ble_edit_ind + local iN=${#text} + ((index<0?(index=0):(index>iN&&(index=iN)))) + local umin=-1 umax=-1 + local x=${_ble_prompt_ps1_data[3]} + local y=${_ble_prompt_ps1_data[4]} + local render_opts= + [[ $rps1_enabled ]] && render_opts=relative + COLUMNS=$cols ble/textmap#update "$text" "$render_opts" # [ref] x y + ble/urange#update "$_ble_textmap_umin" "$_ble_textmap_umax" # [ref] umin umax + ble/urange#clear --prefix=_ble_textmap_ + if [[ :$opts: == *:leave:* ]]; then + local _ble_complete_menu_active= # suppress layer:menu_filter + local _ble_edit_mark_active= # suppress layer:region + local _ble_edit_overwrite_mode= # suppress layer:overwrite_mode + fi + local DMIN=$_ble_edit_dirty_draw_beg + ble-edit/content/update-syntax + ble/textarea#update-text-buffer # [in] text index [ref] lc lg; + local lc=32 lg=0 + [[ $bleopt_internal_suppress_bash_output ]] || + ble/textarea#update-left-char "$index" + local -a DRAW_BUFF=() + local begx=$_ble_textmap_begx begy=$_ble_textmap_begy + local endx=$_ble_textmap_endx endy=$_ble_textmap_endy + local cx cy + ble/textmap#getxy.cur --prefix=c "$index" # → cx cy + local cols=$_ble_textmap_cols + local height=${_ble_canvas_panel_height[_ble_textarea_panel]} + local scroll=${_ble_textarea_scroll_new:-$_ble_textarea_scroll} + ble/textarea#render/.determine-scroll # update: height scroll umin umax + local gend gendx gendy + if [[ $scroll ]]; then + ble/textmap#get-index-at "$cols" "$((height+scroll-1))"; gend=$index + ble/textmap#getxy.out --prefix=gend "$gend" + ((gendy-=scroll)) + else + gend=$iN gendx=$endx gendy=$endy + fi + _ble_textarea_gendx=$gendx _ble_textarea_gendy=$gendy + local ret esc_line= esc_line_set= + if [[ ! $_ble_textarea_invalidated ]]; then + [[ ! $rps1_enabled && $_ble_prompt_rps1_shown || $rps1_enabled && $_ble_prompt_rps1_dirty ]] && + ble/textarea#render/.cleanup-trailing-spaces-after-newline + ble/textarea#render/.perform-scroll "$scroll" # update: umin umax + _ble_textarea_scroll_new=$_ble_textarea_scroll + [[ $rps1_enabled ]] && ble/textarea#render/.show-rprompt + ble/textarea#render/.show-prompt + if [[ $subprompt_enabled ]]; then + ble/textarea#render/.show-control-string _ble_prompt_xterm_title + ble/textarea#render/.show-control-string _ble_prompt_screen_title + ble/textarea#render/.show-control-string _ble_prompt_term_status + fi + if ((umin=0)); then + local endY=$((endy-_ble_textarea_scroll)) + if ((endY0)) && ble/canvas/put-cub.draw "$ret" + ble/util/c2bc "$lc" + READLINE_POINT=$ret + fi + ble/color/g2sgr "$lg" + ble/canvas/put.draw "$ret" + fi +} +function ble/textarea#save-state { + local prefix=$1 + local -a vars=() + ble/array#push vars _ble_edit_PS1 _ble_prompt_ps1_data + ble/array#push vars "${_ble_edit_VARNAMES[@]}" + ble/array#push vars "${_ble_textmap_VARNAMES[@]}" + ble/array#push vars _ble_highlight_layer_list + local layer names + for layer in "${_ble_highlight_layer_list[@]}"; do + local _ble_local_script=' + if [[ ${_ble_highlight_layer_LAYER_VARNAMES[@]-} ]]; then + ble/array#push vars "${_ble_highlight_layer_LAYER_VARNAMES[@]}" + else + ble/array#push vars "${!_ble_highlight_layer_LAYER_@}" + fi' + builtin eval -- "${_ble_local_script//LAYER/$layer}" + done + ble/array#push vars "${_ble_textarea_VARNAMES[@]}" + ble/array#push vars "${_ble_syntax_VARNAMES[@]}" + ble/array#push vars "${_ble_textarea_local_VARNAMES[@]}" + builtin eval -- "${prefix}_VARNAMES=(\"\${vars[@]}\")" + ble/util/save-vars "$prefix" "${vars[@]}" +} +function ble/textarea#restore-state { + local prefix=$1 + if builtin eval "[[ \$prefix && \${${prefix}_VARNAMES+set} ]]"; then + builtin eval "ble/util/restore-vars $prefix \"\${${prefix}_VARNAMES[@]}\"" + else + ble/util/print "ble/textarea#restore-state: unknown prefix '$prefix'." >&2 + return 1 + fi +} +function ble/textarea#clear-state { + local prefix=$1 + if [[ $prefix ]]; then + local vars=${prefix}_VARNAMES + builtin eval "builtin unset -v \"\${$vars[@]/#/$prefix}\" $vars" + else + ble/util/print "ble/textarea#restore-state: unknown prefix '$prefix'." >&2 + return 1 + fi +} +_ble_textarea_render_defer= +function ble/textarea#render-defer.idle { + ble/util/idle.wait-user-input + [[ $_ble_textarea_render_defer ]] || return 0 + local ble_textarea_render_defer_running=1 + ble/util/buffer.flush + _ble_textarea_render_defer= + blehook/invoke textarea_render_defer + ble/textarea#render update + [[ $_ble_textarea_render_defer ]] && + ble/util/idle.continue + return 0 +} +ble/function#try ble/util/idle.push-background ble/textarea#render-defer.idle +function ble/widget/.update-textmap { + local cols=${COLUMNS:-80} render_opts= + if [[ $_ble_prompt_rps1_enabled ]]; then + local rps1_width=${_ble_prompt_rps1_data[11]} + render_opts=relative + ((cols-=rps1_width+1,_ble_term_xenl||cols--)) + fi + local x=$_ble_textmap_begx y=$_ble_textmap_begy + COLUMNS=$cols ble/textmap#update "$_ble_edit_str" "$render_opts" +} +function ble/widget/do-lowercase-version { + local n=${#KEYS[@]}; ((n&&n--)) + local flag=$((KEYS[n]&_ble_decode_MaskFlag)) + local char=$((KEYS[n]&_ble_decode_MaskChar)) + if ((65<=char&&char<=90)); then + ble/decode/widget/redispatch-by-keys "$((flag|char+32))" "${KEYS[@]:1}" + else + return 125 + fi +} +function ble/widget/redraw-line { + ble-edit/content/clear-arg + ble/textarea#invalidate +} +function ble/widget/clear-screen { + ble-edit/content/clear-arg + ble/edit/enter-command-layout # #D1800 pair=leave-command-layout + _ble_prompt_trim_opwd= + ble/textarea#invalidate + local -a DRAW_BUFF=() + ble/canvas/panel/goto-top-dock.draw + ble/canvas/bflush.draw + ble/util/buffer "$_ble_term_clear" + _ble_canvas_x=0 _ble_canvas_y=0 + ble/term/visible-bell/cancel-erasure + ble/edit/leave-command-layout # #D1800 pair=enter-command-layout +} +function ble/widget/clear-display { + ble/util/buffer $'\e[3J' + ble/widget/clear-screen +} +function ble/edit/display-version/git-rev-parse { + ret= + local git_base opts=$2 + case $1 in + (.) git_base=$PWD ;; + (./*) git_base=$PWD/${1#./} ;; + (..|../*) git_base=$PWD/$1 ;; + (*) git_base=$1 ;; + esac + "${_ble_util_set_declare[@]//NAME/visited}" # WA #D1570 checked + until [[ -s $git_base/HEAD || -s $git_base/.git/HEAD ]]; do + ble/set#contains visited "$git_base" && return 1 + ble/set#add visited "$git_base" + if [[ -f $git_base/.git ]]; then + local content + ble/util/mapfile content < "$git_base/.git" + if ble/string#match "$content" '^gitdir: (.*)'; then + git_base=$git_base/${BASH_REMATCH[1]} + continue + fi + fi + if [[ :$opts: == *:parent:* && $git_base == */* ]]; then + git_base=${git_base%/*} + continue + fi + break + done + [[ -s $git_base/HEAD ]] || git_base=$git_base/.git + local head=$git_base/HEAD + if [[ -f $head ]]; then + local content + ble/util/mapfile content < "$head" + if ble/string#match "$content" '^ref: (.*)$'; then + head=$git_base/${BASH_REMATCH[1]} + ble/util/mapfile content < "$head" + fi + if ble/string#match "$content" '^[a-f0-9]+$'; then + content=${content::8} + fi + ret=$content + [[ $ret ]] + return "$?" + fi + return 1 +} +function ble/edit/display-version/git-hash-object { + local file=$1 size + if ! ble/util/assign size 'ble/bin/wc -c "$file" 2>/dev/null'; then + ret='error' + return 1 + fi + ble/string#split-words size "$size" + if ble/bin#has git; then + ble/util/assign ret 'git hash-object "$file"' + ret="hash:$ret, $size bytes" + elif ble/bin#has sha1sum; then + local _ble_local_tmpfile; ble/util/assign/mktmp + { printf 'blob %d\0' "$size"; ble/bin/cat "$file"; } >| "$_ble_local_tmpfile" + blob_data=$_ble_local_tmpfile ble/util/assign ret 'sha1sum "$blob_data"' + ble/util/assign/rmtmp + ble/string#split-words ret "$ret" + ret="sha1:$ret, $size bytes" + elif ble/bin#has cksum; then + ble/util/assign-words ret 'cksum "$file"' + ble/util/sprintf ret 'cksum:%08x, %d bytes' "$ret" "$size" + else + ret=size:$size + fi +} +function ble/edit/display-version/add-line { + lines[iline++]=$1 +} +function ble/edit/display-version/check:bash-completion { + [[ ${BASH_COMPLETION_VERSINFO[0]-} ]] || return 1 + local patch=${BASH_COMPLETION_VERSINFO[2]-} + local version=${BASH_COMPLETION_VERSINFO[0]}.${BASH_COMPLETION_VERSINFO[1]:-y}${patch:+.$patch} + local source lineno ret + if ble/function#get-source-and-lineno _init_completion; then + if ble/edit/display-version/git-rev-parse "${source%/*}"; then + version=$sgrV$version+$ret$sgr0 + elif ble/edit/display-version/git-hash-object "$source"; then + version="$sgrV$version$sgr0 ($ret)" + fi + fi + ble/edit/display-version/add-line "${sgrF}bash-completion$sgr0, version $version$label_noarch" +} +function ble/edit/display-version/check:bash-preexec { + local source lineno ret + ble/function#get-source-and-lineno __bp_preexec_invoke_exec || return 1 + local version="${source/#$HOME/~}$label_noarch" + if ble/edit/display-version/git-rev-parse "${source%/*}"; then + version="version $sgrV+$ret$sgr0$label_noarch" + elif ble/edit/display-version/git-hash-object "$source"; then + version="($ret)$label_noarch" + fi + local file=${source##*/} + if [[ $file == bash-preexec.sh || $file == bash-preexec.bash ]]; then + file= + else + file=" ($file)" + fi + local integ= + ble/util/import/is-loaded contrib/bash-preexec && integ=$label_integration + ble/edit/display-version/add-line "${sgrF}bash-preexec$sgr0$file, $version$integ" +} +function ble/edit/display-version/check:fzf { + local source lineno ret + if ble/function#get-source-and-lineno __fzf_select__; then + local version="${source/#$HOME/~}$label_noarch" + if ble/edit/display-version/git-rev-parse "${source%/*}" parent; then + version="version $sgrV+$ret$sgr0$label_noarch" + elif ble/edit/display-version/git-hash-object "$source"; then + version="($ret)$label_noarch" + fi + local integ= + ble/util/import/is-loaded integration/fzf-key-bindings && integ=$label_integration + ble/edit/display-version/add-line "${sgrC}fzf$sgr0 ${sgrF}key-bindings$sgr0, $version$integ" + [[ $integ ]] || ble/edit/display-version/add-line "$label_warning: fzf integration \"integration/fzf-key-bindings\" is not activated." + fi + if ble/function#get-source-and-lineno __fzf_orig_completion; then + local version="${source/#$HOME/~}$label_noarch" + if ble/edit/display-version/git-rev-parse "${source%/*}" parent; then + version="version $sgrV+$ret$sgr0$label_noarch" + elif ble/edit/display-version/git-hash-object "$source"; then + version="($ret)$label_noarch" + fi + local integ= + ble/util/import/is-loaded integration/fzf-completion && integ=$label_integration + ble/edit/display-version/add-line "${sgrC}fzf$sgr0 ${sgrF}completion$sgr0, $version$integ" + [[ $integ ]] || ble/edit/display-version/add-line "$label_warning: fzf integration \"integration/fzf-completion\" is not activated." + fi +} +function ble/edit/display-version/check:starship { + local source lineno + ble/function#get-source-and-lineno starship_precmd || return 1 + local starship sed_script='s/^[[:space:]]*PS1="\$(\(.\{1,\}\) prompt .*)";\{0,1\}$/\1/p' + ble/util/assign-array starship 'declare -f starship_precmd | ble/bin/sed -n "$sed_script"' + if ! ble/bin#has "$starship"; then + { builtin eval -- "starship=$starship" && ble/bin#has "$starship"; } || + { starship=starship; ble/bin#has "$starship"; } || return 1 + fi + local awk_script=' + sub(/^starship /, "") { version = $0; next; } + sub(/^branch:/, "") { gsub(/['"$_ble_term_space"']/, "_"); if ($0 != "") version = version "-" $0; next; } + sub(/^commit_hash:/, "") { gsub(/['"$_ble_term_space"']/, "_"); if ($0 != "") version = version "+" $0; next; } + sub(/^build_time:/, "") { build_time = $0; } + sub(/^build_env:/, "") { build_env = $0; } + END { + if (version != "") { + print version; + print build_env, build_time + } + } + ' + local version= + ble/util/assign-array version '"$starship" --version | ble/bin/awk "$awk_script"' + [[ $version ]] || return 1 + local ret; ble/string#trim "${version[1]}"; local build=$ret + ble/edit/display-version/add-line "${sgrF}starship${sgr0}, version $sgrV$version$sgr0${build:+ ($build)}" +} +function ble/edit/display-version/check:bash-it { + [[ ${BASH_IT-} ]] && ble/is-function bash-it || return 1 + local version= ret + if ble/edit/display-version/git-rev-parse "$BASH_IT"; then + version="version $sgrV+$ret$sgr0$label_noarch" + elif ble/edit/display-version/git-hash-object "$BASH_IT/bash_it.sh"; then + version="($ret)$label_noarch" + else + version="(bash-it version)" + fi + local modules= + if ble/is-function _bash-it-component-item-is-enabled; then + local category subdir suffix + for category in aliases:alias completion plugins:plugin; do + local subdir=${category%:*} suffix=${category#*:} list + list=() + local file name + for file in "$BASH_IT/$subdir/available"/*.*.bash; do + name=${file##*/} + name=${name%."$suffix"*.bash} + _bash-it-component-item-is-enabled "$suffix" "$name" && ble/array#push list "$name" + done + modules="$modules, $suffix(${list[*]})" + done + fi + ble/edit/display-version/add-line "${sgrF}bash-it$sgr0${theme:+ ($theme)}, $version$modules" +} +function ble/edit/display-version/check:oh-my-bash { + local source lineno ret version= + if [[ ${OMB_VERSINFO-set} ]] && ble/function#get-source-and-lineno _omb_module_require; then + version=${OMB_VERSINFO[0]}.${OMB_VERSINFO[1]}.${OMB_VERSINFO[2]} + if ble/edit/display-version/git-rev-parse "${source%/*}"; then + version="version $sgrV$version+$ret$sgr0$label_noarch" + elif ble/edit/display-version/git-hash-object "$source"; then + version="version $sgrV$version$sgr0 ($ret)$label_noarch" + else + version="version $sgrV$version$sgr0$label_noarch" + fi + elif [[ ${OSH_CUSTOM-set} ]] && ble/function#get-source-and-lineno is_plugin; then + version="${source/#$HOME/~}$label_noarch" + if ble/edit/display-version/git-rev-parse "${source%/*}" parent; then + version="version $sgrV+$ret$sgr0$label_noarch" + elif ble/edit/display-version/git-hash-object "$source"; then + version="($ret)$label_noarch" + fi + fi + if [[ $version ]]; then + local theme=${OMB_THEME-${OSH_THEME-}} + local modules="aliases(${aliases[*]}), completions(${completions[*]}), plugins(${plugins[*]})" + ble/edit/display-version/add-line "${sgrF}oh-my-bash$sgr0${theme:+ ($theme)}, $version, $modules" + fi +} +function ble/edit/display-version/check:sbp { + local source lineno ret + ble/function#get-source-and-lineno _sbp_set_prompt || return 1 + local version="${source/#$HOME/~}$label_noarch" + if ble/edit/display-version/git-rev-parse "${source%/*}"; then + version="version $sgrV+$ret$sgr0$label_noarch" + elif ble/edit/display-version/git-hash-object "$source"; then + version="($ret)$label_noarch" + fi + local hooks="hooks(${settings_hooks[*]-${SBP_HOOKS[*]}})" + local left="left(${settings_segments_left[*]-${SBP_SEGMENTS_LEFT[*]}})" + local right="right(${settings_segments_right[*]-${RBP_SEGMENTS_RIGHT[*]}})" + local modules="$hooks, $left, $right" + ble/edit/display-version/add-line "${sgrF}sbp$sgr0, $version, $modules" +} +function ble/edit/display-version/check:gitstatus { + local source lineno ret + ble/function#get-source-and-lineno gitstatus_query || return 1 + local version="${source/#$HOME/~}$label_noarch" + if ble/edit/display-version/git-rev-parse "${source%/*}"; then + version="version $sgrV+$ret$sgr0$label_noarch" + elif ble/edit/display-version/git-hash-object "$source"; then + version="($ret)$label_noarch" + fi + ble/edit/display-version/add-line "${sgrF}romkatv/gitstatus$sgr0, $version" +} +function ble/edit/display-version/check:zoxide { + ble/is-function __zoxide_hook || return 1 + local path= + ble/bin#get-path zoxide || return 1 + local version= + ble/util/assign-array version '\command zoxide --version' + [[ $version ]] || return 1 + version=${version#zoxide } + version=${version#v} + local integ= + ble/util/import/is-loaded contrib/integration/zoxide && integ=$label_integration + ble/edit/display-version/add-line "${sgrF}zoxide${sgr0}, version $sgrV$version$sgr0 ($path)$integ" +} +function ble/edit/display-version/check:atuin { + ble/is-function _atuin_precmd || ble/is-function __atuin_precmd || return 1 + local path= + ble/bin#get-path atuin || return 1 + local version= + ble/util/assign-array version '\command atuin --version' + [[ $version ]] || return 1 + version=${version#atuin } + version=${version#v} + ble/edit/display-version/add-line "${sgrF}atuin${sgr0}, version $sgrV$version$sgr0 ($path)" +} +function ble/widget/display-shell-version { + ble-edit/content/clear-arg + local set shopt + [[ $_ble_bash_options_adjusted ]] || ble/base/.adjust-bash-options set shopt + local sgrC= sgrF= sgrV= sgrA= sgr2= sgr3= sgr0= bold= + if [[ -t 1 ]]; then + bold=$_ble_term_bold + sgr0=$_ble_term_sgr0 + ble/color/face2sgr command_file; sgrC=$ret + ble/color/face2sgr command_function; sgrF=$ret + ble/color/face2sgr syntax_expr; sgrV=$ret + ble/color/face2sgr varname_readonly; sgrA=$ret + ble/color/face2sgr syntax_varname; sgr2=$ret + ble/color/face2sgr syntax_quoted; sgr3=$ret + fi + local label_noarch=" (${sgrA}noarch$sgr0)" + local label_integration=" $_ble_term_bold(integration: on)$sgr0" + local label_warning="${bold}WARNING$sgr0" + local os_release= + if [[ -s /etc/os-release ]]; then + ble/util/assign os_release '( + builtin unset -v PRETTY_NAME NAME VERSION + source /etc/os-release + ble/util/print "${PRETTY_NAME:-${NAME:+$NAME${VERSION:+ $VERSION}}}")' 2>/dev/null + fi + if [[ ! $os_release && -s /etc/release ]]; then + local ret + ble/util/mapfile ret < /etc/release + ble/string#trim "$ret" + os_release=$ret + fi + local lines="${sgrC}GNU bash$sgr0, version $sgrV$BASH_VERSION$sgr0 ($sgrA$MACHTYPE$sgr0)${os_release:+ [$os_release]}" iline=1 + local ble_build_info="${_ble_base_build_git_version/#git version/git}, $_ble_base_build_make_version, $_ble_base_build_gawk_version" + lines[iline++]="${sgrF}ble.sh$sgr0, version $sgrV$BLE_VERSION$sgr0$label_noarch [$ble_build_info]" + ble/edit/display-version/check:bash-completion + ble/edit/display-version/check:fzf + ble/edit/display-version/check:bash-preexec + ble/edit/display-version/check:starship + ble/edit/display-version/check:bash-it + ble/edit/display-version/check:oh-my-bash + ble/edit/display-version/check:sbp + ble/edit/display-version/check:gitstatus + ble/edit/display-version/check:zoxide + ble/edit/display-version/check:atuin + local q=\' + local ret='(unset)' + local var line=${_ble_term_bold}locale$sgr0: + for var in _ble_bash_LANG "${!_ble_bash_LC_@}" LANG "${!LC_@}"; do + case $var in + (LC_ALL|LC_COLLATE) continue ;; + (LANG|LC_CTYPE|LC_MESSAGES|LC_NUMERIC|LC_TIME) + [[ ${_ble_bash_LC_ALL-} ]] && continue ;; + esac + [[ ${!var+set} ]] || continue + ble/string#quote-word "${!var}" quote-empty:sgrq="$sgr3":sgr0="$sgr0" + line="$line $sgr2${var#_ble_bash_}$sgrV=$sgr0$ret" + done + lines[iline++]=$line + ret='(unset)' + [[ ${TERM+set} ]] && ble/string#quote-word "$TERM" quote-empty:sgrq="$sgr3":sgr0="$sgr0" + local i line="${_ble_term_bold}terminal$sgr0: ${sgr2}TERM$sgrV=$sgr0$ret" + line="$line ${sgr2}wcwidth$sgrV=$sgr0$bleopt_char_width_version-$bleopt_char_width_mode${bleopt_emoji_width:+/$bleopt_emoji_version-$bleopt_emoji_width+$bleopt_emoji_opts}" + [[ ${MC_SID-} ]] && line="$line, ${sgrC}mc$sgr0 (${sgrV}MC_SID:$MC_SID$sgr0)" + for i in "${!_ble_term_DA2R[@]}"; do + line="$line, $sgrC${_ble_term_TERM[i]-unknown}$sgr0 ($sgrV${_ble_term_DA2R[i]}$sgr0)" + done + lines[iline++]=$line + ble/widget/print "${lines[@]}" + [[ $_ble_bash_options_adjusted ]] || ble/base/.restore-bash-options set shopt +} +function ble/widget/readline-dump-functions { + ble-edit/content/clear-arg + local ret + ble/util/assign ret 'ble/builtin/bind -P' + ble/widget/print "$ret" +} +function ble/widget/readline-dump-macros { + ble-edit/content/clear-arg + local ret + ble/util/assign ret 'ble/builtin/bind -S' + ble/widget/print "$ret" +} +function ble/widget/readline-dump-variables { + ble-edit/content/clear-arg + local ret + ble/util/assign ret 'ble/builtin/bind -V' + ble/widget/print "$ret" +} +function ble/widget/re-read-init-file { + ble-edit/content/clear-arg + local inputrc=$INPUTRC + [[ $inputrc && -e $inputrc ]] || inputrc=~/.inputrc + [[ -e $inputrc ]] || return 0 + ble/decode/read-inputrc "$inputrc" + _ble_builtin_bind_keymap= +} +_ble_edit_rlfunc_history=() +_ble_edit_rlfunc_history_edit=() +_ble_edit_rlfunc_history_dirt=() +_ble_edit_rlfunc_history_index=0 +function ble/widget/execute-named-command/accept.hook { + local ret rlfunc error= + ble/string#split-words rlfunc "$1" + if ble/util/assign error 'ble/builtin/bind/rlfunc2widget "$_ble_decode_keymap" "$rlfunc" 2>&1'; then + ble/decode/widget/dispatch "$ret" "${rlfunc[@]:1}" + elif [[ $error ]]; then + ble/widget/bell "$error" + fi +} +function ble/widget/execute-named-command { + ble/edit/async-read-mode 'ble/widget/execute-named-command/accept.hook' + _ble_edit_async_read_before_widget=ble/edit/async-read-mode/empty-cancel.hook + ble/history/set-prefix _ble_edit_rlfunc + _ble_edit_PS1='!' + return 147 +} +function ble/widget/overwrite-mode { + ble-edit/content/clear-arg + if [[ $_ble_edit_overwrite_mode ]]; then + _ble_edit_overwrite_mode= + else + _ble_edit_overwrite_mode=1 + fi +} +function ble/widget/set-mark { + ble-edit/content/clear-arg + _ble_edit_mark=$_ble_edit_ind + _ble_edit_mark_active=1 +} +function ble/widget/kill-forward-text { + ble-edit/content/clear-arg + ((_ble_edit_ind>=${#_ble_edit_str})) && return 0 + ble-edit/content/push-kill-ring "${_ble_edit_str:_ble_edit_ind}" '' forward + ble-edit/content/replace "$_ble_edit_ind" "${#_ble_edit_str}" '' + ((_ble_edit_mark>_ble_edit_ind&&(_ble_edit_mark=_ble_edit_ind))) +} +function ble/widget/kill-backward-text { + ble-edit/content/clear-arg + ((_ble_edit_ind==0)) && return 0 + ble-edit/content/push-kill-ring "${_ble_edit_str::_ble_edit_ind}" '' backward + ble-edit/content/replace 0 "$_ble_edit_ind" '' + ((_ble_edit_mark=_ble_edit_mark<=_ble_edit_ind?0:_ble_edit_mark-_ble_edit_ind)) + _ble_edit_ind=0 +} +function ble/widget/exchange-point-and-mark { + ble-edit/content/clear-arg + local m=$_ble_edit_mark p=$_ble_edit_ind + _ble_edit_ind=$m _ble_edit_mark=$p +} +function ble/widget/@marked { + local index=$_ble_edit_ind + ble/decode/widget/dispatch "$@" + if ((_ble_edit_ind!=index)); then + _ble_edit_mark=$index + _ble_edit_mark_active=S + ble/decode/keymap/push selection + fi +} +function ble/widget/selection/exit-default { + ble/decode/keymap/pop + ble/decode/widget/redispatch + local ext=$? + [[ $_ble_edit_mark_active == S && $_ble_decode_keymap != selection ]] && + _ble_edit_mark_active= + return "$ext" +} +function ble-decode/keymap:selection/bind-shift { + local marked=${1:+$1 } + ble-decode/keymap:safe/.bind 'S-C-f' "${marked}forward-char" + ble-decode/keymap:safe/.bind 'S-right' "${marked}forward-char" + ble-decode/keymap:safe/.bind 'S-C-b' "${marked}backward-char" + ble-decode/keymap:safe/.bind 'S-left' "${marked}backward-char" + ble-decode/keymap:safe/.bind 'S-C-right' "${marked}forward-cword" + ble-decode/keymap:safe/.bind 'M-F' "${marked}forward-cword" + ble-decode/keymap:safe/.bind 'M-S-f' "${marked}forward-cword" + ble-decode/keymap:safe/.bind 'S-C-left' "${marked}backward-cword" + ble-decode/keymap:safe/.bind 'M-B' "${marked}backward-cword" + ble-decode/keymap:safe/.bind 'M-S-b' "${marked}backward-cword" + ble-decode/keymap:safe/.bind 'M-S-right' "${marked}forward-sword" + ble-decode/keymap:safe/.bind 'M-S-left' "${marked}backward-sword" + ble-decode/keymap:safe/.bind 'S-C-a' "${marked}beginning-of-line" + ble-decode/keymap:safe/.bind 'S-home' "${marked}beginning-of-line" + ble-decode/keymap:safe/.bind 'S-C-e' "${marked}end-of-line" + ble-decode/keymap:safe/.bind 'S-end' "${marked}end-of-line" + ble-decode/keymap:safe/.bind 'S-C-p' "${marked}backward-line" + ble-decode/keymap:safe/.bind 'S-up' "${marked}backward-line" + ble-decode/keymap:safe/.bind 'S-C-n' "${marked}forward-line" + ble-decode/keymap:safe/.bind 'S-down' "${marked}forward-line" + ble-decode/keymap:safe/.bind 'S-C-home' "${marked}beginning-of-text" + ble-decode/keymap:safe/.bind 'S-C-end' "${marked}end-of-text" + ble-decode/keymap:safe/.bind 'M-S-m' "${marked}non-space-beginning-of-line" + ble-decode/keymap:safe/.bind 'M-M' "${marked}non-space-beginning-of-line" +} +function ble-decode/keymap:selection/define { + ble-bind -f __default__ 'selection/exit-default' + ble-bind -f __line_limit__ nop + ble-decode/keymap:selection/bind-shift +} +function ble/widget/.process-range-argument { + p0=$1 p1=$2 len=${#_ble_edit_str} + local pt + (( + p0>len?(p0=len):p0<0&&(p0=0), + p1>len?(p1=len):p0<0&&(p1=0), + p10 + )) +} +function ble/widget/.delete-range { + local p0 p1 len + ble/widget/.process-range-argument "${@:1:2}" || return 1 + if ((len)); then + ble-edit/content/replace "$p0" "$p1" '' + (( + _ble_edit_ind>p1? (_ble_edit_ind-=len): + _ble_edit_ind>p0&&(_ble_edit_ind=p0), + _ble_edit_mark>p1? (_ble_edit_mark-=len): + _ble_edit_mark>p0&&(_ble_edit_mark=p0) + )) + fi + return 0 +} +function ble/widget/.kill-range { + local p0 p1 len + ble/widget/.process-range-argument "${@:1:2}" || return 1 + ble-edit/content/push-kill-ring "${_ble_edit_str:p0:len}" "$4" "$p0:$p1" + if ((len)); then + ble-edit/content/replace "$p0" "$p1" '' + (( + _ble_edit_ind>p1? (_ble_edit_ind-=len): + _ble_edit_ind>p0&&(_ble_edit_ind=p0), + _ble_edit_mark>p1? (_ble_edit_mark-=len): + _ble_edit_mark>p0&&(_ble_edit_mark=p0) + )) + fi + return 0 +} +function ble/widget/.copy-range { + local p0 p1 len + ble/widget/.process-range-argument "${@:1:2}" || return 1 + ble-edit/content/push-kill-ring "${_ble_edit_str:p0:len}" "$4" "$p0:$p1" +} +function ble/widget/.replace-range { + local p0 p1 len + ble/widget/.process-range-argument "${@:1:2}" + local insert; ble-edit/content/replace-limited "$p0" "$p1" "$3" + local inslen=${#insert} delta + ((delta=inslen-len)) && + ((_ble_edit_ind>p1?(_ble_edit_ind+=delta): + _ble_edit_ind>=p0&&(_ble_edit_ind=p0+inslen), + _ble_edit_mark>p1?(_ble_edit_mark+=delta): + _ble_edit_mark>p0&&(_ble_edit_mark=p0))) + return 0 +} +function ble/widget/delete-region { + ble-edit/content/clear-arg + ble/widget/.delete-range "$_ble_edit_mark" "$_ble_edit_ind" + _ble_edit_mark_active= +} +function ble/widget/kill-region { + ble-edit/content/clear-arg + ble/widget/.kill-range "$_ble_edit_mark" "$_ble_edit_ind" + _ble_edit_mark_active= +} +function ble/widget/copy-region { + ble-edit/content/clear-arg + ble/widget/.copy-range "$_ble_edit_mark" "$_ble_edit_ind" + _ble_edit_mark_active= +} +function ble/widget/delete-region-or { + if [[ $_ble_edit_mark_active ]]; then + ble/widget/delete-region + else + ble/decode/widget/dispatch "$@" + fi +} +function ble/widget/kill-region-or { + if [[ $_ble_edit_mark_active ]]; then + ble/widget/kill-region + else + ble/decode/widget/dispatch "$@" + fi +} +function ble/widget/copy-region-or { + if [[ $_ble_edit_mark_active ]]; then + ble/widget/copy-region + else + ble/decode/widget/dispatch "$@" + fi +} +function ble/widget/yank { + local arg; ble-edit/content/get-arg 1 + local nkill=${#_ble_edit_kill_ring[@]} + if ((nkill==0)); then + ble/widget/.bell 'no strings in kill-ring' + _ble_edit_yank_index= + return 1 + fi + local index=$_ble_edit_kill_index + local delta=$((arg-1)) + if ((delta)); then + ((index=(index+delta)%nkill, + index=(index+nkill)%nkill)) + _ble_edit_kill_index=$index + fi + local insert=${_ble_edit_kill_ring[index]} + _ble_edit_yank_index=$index + if [[ $insert ]]; then + ble-edit/content/replace-limited "$_ble_edit_ind" "$_ble_edit_ind" "$insert" + ((_ble_edit_mark=_ble_edit_ind, + _ble_edit_ind+=${#insert})) + _ble_edit_mark_active= + fi +} +_ble_edit_yank_index= +function ble/edit/yankpop.impl { + local arg=$1 + local nkill=${#_ble_edit_kill_ring[@]} + ((_ble_edit_yank_index=(_ble_edit_yank_index+arg)%nkill, + _ble_edit_yank_index=(_ble_edit_yank_index+nkill)%nkill)) + local insert=${_ble_edit_kill_ring[_ble_edit_yank_index]} + ble-edit/content/replace-limited "$_ble_edit_mark" "$_ble_edit_ind" "$insert" + ((_ble_edit_ind=_ble_edit_mark+${#insert})) +} +function ble/widget/yank-pop { + local opts=$1 + local arg; ble-edit/content/get-arg 1 + if ! [[ $_ble_edit_yank_index && ${LASTWIDGET%%' '*} == ble/widget/yank ]]; then + ble/widget/.bell + return 1 + fi + [[ :$opts: == *:backward:* ]] && ((arg=-arg)) + ble/edit/yankpop.impl "$arg" + _ble_edit_mark_active=insert + ble/decode/keymap/push yankpop +} +function ble/widget/yankpop/next { + local arg; ble-edit/content/get-arg 1 + ble/edit/yankpop.impl "$arg" +} +function ble/widget/yankpop/prev { + local arg; ble-edit/content/get-arg 1 + ble/edit/yankpop.impl "$((-arg))" +} +function ble/widget/yankpop/exit { + ble/decode/keymap/pop + _ble_edit_mark_active= +} +function ble/widget/yankpop/cancel { + ble-edit/content/replace "$_ble_edit_mark" "$_ble_edit_ind" '' + _ble_edit_ind=$_ble_edit_mark + ble/widget/yankpop/exit +} +function ble/widget/yankpop/exit-default { + ble/widget/yankpop/exit + ble/decode/widget/redispatch +} +function ble-decode/keymap:yankpop/define { + ble-decode/keymap:safe/bind-arg yankpop/exit-default + ble-bind -f __default__ 'yankpop/exit-default' + ble-bind -f __line_limit__ nop + ble-bind -f 'C-g' 'yankpop/cancel' + ble-bind -f 'C-x C-g' 'yankpop/cancel' + ble-bind -f 'C-M-g' 'yankpop/cancel' + ble-bind -f 'M-y' 'yankpop/next' + ble-bind -f 'M-S-y' 'yankpop/prev' + ble-bind -f 'M-Y' 'yankpop/prev' +} +_ble_term_DECSCNM_state= +function ble/widget/.bell { + [[ :$bleopt_edit_bell: == *:vbell:* ]] && ble/term/visible-bell "$1" + [[ :$bleopt_edit_bell: == *:abell:* ]] && ble/term/audible-bell + if [[ :$bleopt_edit_bell: == *:visual:* ]]; then + ble/util/buffer $'\e[?5h' + ble/util/buffer.flush + _ble_term_DECSCNM_state=1 + if ble/is-function ble/util/idle.push; then + ble/util/idle.push --sleep=50 ble/widget/.bell/.clear-DECSCNM + else + ble/util/msleep 50 + ble/widget/.bell/.clear-DECSCNM + fi + fi + return 0 +} +function ble/widget/.bell/.clear-DECSCNM { + [[ $_ble_term_DECSCNM_state ]] || return "$?" + _ble_term_DECSCNM_state= + ble/util/buffer $'\e[?5l' + ble/util/buffer.flush +} +function ble/widget/bell { + ble-edit/content/clear-arg + _ble_edit_mark_active= + _ble_edit_arg= + blehook/invoke widget_bell + ble/widget/.bell "$1" +} +function ble/widget/nop { return 0; } +function ble/widget/insert-string { + local IFS=$_ble_term_IFS + local content="$*" + local arg; ble-edit/content/get-arg 1 + if ((arg<0)); then + ble/widget/.bell "negative repetition number $arg" + return 1 + elif ((arg==0)); then + return 0 + elif ((arg>1)); then + local ret; ble/string#repeat "$content" "$arg"; content=$ret + fi + ble/widget/.insert-string "$content" +} +function ble/widget/.insert-string { + local insert=$1 + [[ $insert ]] || return 1 + ble-edit/content/replace-limited "$_ble_edit_ind" "$_ble_edit_ind" "$insert" + local dx=${#insert} + (( + _ble_edit_mark>_ble_edit_ind&&(_ble_edit_mark+=dx), + _ble_edit_ind+=dx + )) + _ble_edit_mark_active= +} +if [[ -c /dev/clipboard ]]; then + function ble/widget/paste-from-clipboard { + local clipboard + if ! ble/util/readfile clipboard /dev/clipboard; then + ble/widget/.bell + return 1 + fi + ble/widget/insert-string "$clipboard" + return 0 + } +fi +_ble_edit_lastarg_index= +_ble_edit_lastarg_delta= +_ble_edit_lastarg_nth= +function ble/widget/insert-arg.impl { + local beg=$1 end=$2 index=$3 delta=$4 nth=$5 + ((delta)) || delta=1 + ble/history/initialize + local hit= lastarg= + local decl=$( + local original=${_ble_edit_str:beg:end-beg} + local count=; ((delta>0)) && count=_ble_history_COUNT + while :; do + if ((delta>0)); then + ((index+1>=count)) && break + ((index+=delta,delta=1)) + ((index>=count&&(index=count-1))) + else + ((index-1<0)) && break + ((index+=delta,delta=-1)) + ((index<0&&(index=0))) + fi + local entry; ble/history/get-edited-entry "$index" + builtin history -s -- "$entry" + local ret + if ble/edit/histexpand '!!:'"$nth" && [[ $ret != "$original" ]]; then + hit=1 lastarg=$ret + ble/util/declare-print-definitions hit lastarg + break + fi + done + _ble_edit_lastarg_index=$index + _ble_edit_lastarg_delta=$delta + _ble_edit_lastarg_nth=$nth + ble/util/declare-print-definitions \ + _ble_edit_lastarg_index \ + _ble_edit_lastarg_delta \ + _ble_edit_lastarg_nth + ) + builtin eval -- "$decl" + if [[ $hit ]]; then + local insert; ble-edit/content/replace-limited "$beg" "$end" "$lastarg" + ((_ble_edit_mark=beg,_ble_edit_ind=beg+${#insert})) + return 0 + else + ble/widget/.bell + return 1 + fi +} +function ble/widget/insert-nth-argument { + ble/history/initialize + local arg; ble-edit/content/get-arg '^' + local beg=$_ble_edit_ind end=$_ble_edit_ind + local index=$_ble_history_INDEX + local delta=-1 nth=$arg + ble/widget/insert-arg.impl "$beg" "$end" "$index" "$delta" "$nth" +} +function ble/widget/insert-last-argument { + ble/history/initialize + local arg; ble-edit/content/get-arg '$' + local beg=$_ble_edit_ind end=$_ble_edit_ind + local index=$_ble_history_INDEX + local delta=-1 nth=$arg + ble/widget/insert-arg.impl "$beg" "$end" "$index" "$delta" "$nth" || return "$?" + _ble_edit_mark_active=insert + ble/decode/keymap/push lastarg +} +function ble/widget/lastarg/next { + local arg; ble-edit/content/get-arg 1 + local beg=$_ble_edit_mark + local end=$_ble_edit_ind + local index=$_ble_edit_lastarg_index + local delta + if [[ $arg ]]; then + delta=$((-arg)) + else + ((delta=_ble_edit_lastarg_delta>=0?1:-1)) + fi + local nth=$_ble_edit_lastarg_nth + ble/widget/insert-arg.impl "$beg" "$end" "$index" "$delta" "$nth" +} +function ble/widget/lastarg/exit { + ble/decode/keymap/pop + _ble_edit_mark_active= +} +function ble/widget/lastarg/cancel { + ble-edit/content/replace "$_ble_edit_mark" "$_ble_edit_ind" '' + _ble_edit_ind=$_ble_edit_mark + ble/widget/lastarg/exit +} +function ble/widget/lastarg/exit-default { + ble/widget/lastarg/exit + ble/decode/widget/redispatch +} +function ble/highlight/layer:region/mark:insert/get-face { + face=region_insert +} +function ble-decode/keymap:lastarg/define { + ble-decode/keymap:safe/bind-arg lastarg/exit-default + ble-bind -f __default__ 'lastarg/exit-default' + ble-bind -f __line_limit__ nop + ble-bind -f 'C-g' 'lastarg/cancel' + ble-bind -f 'C-x C-g' 'lastarg/cancel' + ble-bind -f 'C-M-g' 'lastarg/cancel' + ble-bind -f 'M-.' 'lastarg/next' + ble-bind -f 'M-_' 'lastarg/next' +} +function ble/widget/self-insert/.get-code { + if ((${#KEYS[@]})); then + code=${KEYS[${#KEYS[@]}-1]} + local flag=$((code&_ble_decode_MaskFlag)) + local char=$((code&_ble_decode_MaskChar)) + if ((flag==0&&char<_ble_decode_FunctionKeyBase)); then + code=$char + return 0 + elif ((flag==_ble_decode_Ctrl&&(char==63||91<=char&&char<=122)&&(char&0x1F)!=0)); then + ((char=char==63?127:char&0x1F)) + code=$char + return 0 + fi + fi + if ((${#CHARS[@]})); then + code=${CHARS[${#CHARS[@]}-1]} + return 0 + fi + code=0 + return 1 +} +function ble/widget/self-insert { + local code; ble/widget/self-insert/.get-code + ((code==0)) && return 0 + ((code==127&&_ble_bash<30100)) && return 0 + local ibeg=$_ble_edit_ind iend=$_ble_edit_ind + local ret ins; ble/util/c2s "$code"; ins=$ret + local arg; ble-edit/content/get-arg 1 + if ((arg<0)); then + ble/widget/.bell "negative repetition number $arg" + return 1 + elif ((arg==0)) || [[ ! $ins ]]; then + arg=0 ins= + elif ((arg>1)); then + ble/string#repeat "$ins" "$arg"; ins=$ret + fi + if [[ $bleopt_delete_selection_mode && $_ble_edit_mark_active ]]; then + ((_ble_edit_mark<_ble_edit_ind?(ibeg=_ble_edit_mark):(iend=_ble_edit_mark), + _ble_edit_ind=ibeg)) + ((arg==0&&ibeg==iend)) && return 0 + elif [[ $_ble_edit_overwrite_mode ]] && ((code!=10&&code!=9)); then + ((arg==0)) && return 0 + local removed_width + if [[ $_ble_edit_overwrite_mode == R ]]; then + local removed_text=${_ble_edit_str:ibeg:arg} + removed_text=${removed_text%%[$'\n\t']*} + removed_width=${#removed_text} + ((iend+=removed_width)) + else + local ret w; ble/util/c2w-edit "$code"; w=$((arg*ret)) + local iN=${#_ble_edit_str} + for ((removed_width=0;removed_widthw)) && ins=$ins${_ble_string_prototype::removed_width-w} + fi + if [[ :$ble_widget_self_insert_opts: == *:nolineext:* ]]; then + if ((removed_widthibeg&&( + _ble_edit_mark=2000)) || return 1 + local ble_batch_insert_index=$index + local ble_batch_insert_count=$N + builtin eval -- "$_ble_decode_show_progress_hook" +} +function ble/widget/batch-insert { + local -a chars; chars=("${KEYS[@]}") + local -a KEYS=() + local index=0 N=${#chars[@]} + if [[ $_ble_edit_overwrite_mode ]]; then + while ((index=limit)); then + chars=("${chars[@]::limit-${#_ble_edit_str}}") + N=${#chars[@]} + ((index=5)); then + IFS=: builtin eval '_ble_edit_bracketed_paste=("${_ble_edit_bracketed_paste[*]}")' + chars=:$_ble_edit_bracketed_paste + if [[ $chars == *:50:48:49:126 ]]; then + if [[ $chars == *:27:91:50:48:49:126 ]]; then # ESC [ 2 0 1 ~ + chars=${chars%:27:91:50:48:49:126} is_end=1 + elif [[ $chars == *:155:50:48:49:126 ]]; then # CSI 2 0 1 ~ + chars=${chars%:155:50:48:49:126} is_end=1 + fi + fi + fi + [[ $is_end ]] || return 1 + _ble_decode_char__hook= + chars=:${chars//:/::}: + chars=${chars//:13::10:/:10:} # CR LF -> LF + chars=${chars//:13:/:10:} # CR -> LF + ble/string#split-words chars "${chars//:/ }" + local proc=$_ble_edit_bracketed_paste_proc + _ble_edit_bracketed_paste_proc= + [[ $proc ]] && builtin eval -- "$proc \"\${chars[@]}\"" + return 0 +} +function ble/widget/bracketed-paste.hook { + ((_ble_edit_bracketed_paste_count%1000==0)) && + IFS=: builtin eval '_ble_edit_bracketed_paste=("${_ble_edit_bracketed_paste[*]}")' # contract + _ble_edit_bracketed_paste[_ble_edit_bracketed_paste_count++]=$1 + (($1==126)) && ble/widget/bracketed-paste.hook/check-end && return 0 + if ((!_ble_debug_keylog_enabled)) && [[ ! $_ble_decode_keylog_chars_enabled ]]; then + local char + while ble/decode/char-hook/next-char; do + _ble_edit_bracketed_paste[_ble_edit_bracketed_paste_count++]=$char + ((char==126)) && ble/widget/bracketed-paste.hook/check-end && return 0 + done + fi + _ble_decode_char__hook=ble/widget/bracketed-paste.hook + return 147 +} +function ble/widget/bracketed-paste.proc { + local -a KEYS; KEYS=("$@") + ble/widget/batch-insert +} +function ble/widget/transpose-chars { + local arg; ble-edit/content/get-arg '' + if ((arg==0)); then + [[ ! $arg ]] && ble-edit/content/eolp && + ((_ble_edit_ind>0&&_ble_edit_ind--)) + arg=1 + fi + local p q r + if ((arg>0)); then + ((p=_ble_edit_ind-1, + q=_ble_edit_ind, + r=_ble_edit_ind+arg)) + else # arg<0 + ((p=_ble_edit_ind-1+arg, + q=_ble_edit_ind, + r=_ble_edit_ind+1)) + fi + if ((p<0||${#_ble_edit_str}=_ble_edit_ind&&(_ble_edit_mark+=w))) + fi + fi + fi + ble-edit/content/replace "$((_ble_edit_ind-a))" "$_ble_edit_ind" "$ins" + ((_ble_edit_ind-=a, + _ble_edit_ind+a<_ble_edit_mark?(_ble_edit_mark-=a): + _ble_edit_ind<_ble_edit_mark&&(_ble_edit_mark=_ble_edit_ind))) + return 0 +} +function ble/widget/.delete-char { + local a=${1:-1} + if ((a>0)); then + if ((${#_ble_edit_str}<_ble_edit_ind+a)); then + return 1 + else + ble-edit/content/replace "$_ble_edit_ind" "$((_ble_edit_ind+a))" '' + fi + elif ((a<0)); then + ble/widget/.delete-backward-char "$((-a))"; return "$?" + else + if ((${#_ble_edit_str}==0)); then + return 1 + elif ((_ble_edit_ind<${#_ble_edit_str})); then + ble-edit/content/replace "$_ble_edit_ind" "$((_ble_edit_ind+1))" '' + else + _ble_edit_ind=${#_ble_edit_str} + ble/widget/.delete-backward-char 1; return "$?" + fi + fi + ((_ble_edit_mark>_ble_edit_ind&&_ble_edit_mark--)) + return 0 +} +function ble/widget/delete-forward-char { + local arg; ble-edit/content/get-arg 1 + ((arg==0)) && return 0 + ble/widget/.delete-char "$arg" || ble/widget/.bell +} +function ble/widget/delete-backward-char { + local arg; ble-edit/content/get-arg 1 + ((arg==0)) && return 0 + [[ $_ble_decode_keymap == vi_imap ]] && ble/keymap:vi/undo/add more + ble/widget/.delete-char "$((-arg))" || ble/widget/.bell + [[ $_ble_decode_keymap == vi_imap ]] && ble/keymap:vi/undo/add more +} +_ble_edit_exit_count=0 +function ble/widget/exit { + ble-edit/content/clear-arg + if [[ $WIDGET == "$LASTWIDGET" ]]; then + ((_ble_edit_exit_count++)) + else + _ble_edit_exit_count=1 + fi + local ret; ble-edit/eval-IGNOREEOF + if ((_ble_edit_exit_count<=ret)); then + local remain=$((ret-_ble_edit_exit_count+1)) + ble/widget/.bell 'IGNOREEOF' + ble/widget/print "IGNOREEOF($remain): Use \"exit\" to leave the shell." + return 0 + fi + local opts=$1 + ((_ble_bash>=40000)) && shopt -q checkjobs &>/dev/null && opts=$opts:checkjobs + if [[ $bleopt_allow_exit_with_jobs ]]; then + local ret + if ble/util/assign ret 'compgen -A stopped -- ""' 2>/dev/null; [[ $ret ]]; then + opts=$opts:twice + elif [[ :$opts: == *:checkjobs:* ]]; then + if ble/util/assign ret 'compgen -A running -- ""' 2>/dev/null; [[ $ret ]]; then + opts=$opts:twice + fi + else + opts=$opts:force + fi + fi + if ! [[ :$opts: == *:force:* || :$opts: == *:twice:* && _ble_edit_exit_count -ge 2 ]]; then + local joblist + ble/util/joblist + if ((${#joblist[@]})); then + ble/widget/.bell "exit: There are remaining jobs." + local q=\' Q="'\''" message= + if [[ :$opts: == *:twice:* ]]; then + message='There are remaining jobs. Input the same key to exit the shell anyway.' + else + message='There are remaining jobs. Use "exit" to leave the shell.' + fi + local ret + ble/edit/marker#instantiate "$message" non-empty + ble/widget/internal-command "ble/util/print '${ret//$q/$Q}'; jobs" + return "$?" + fi + elif [[ :$opts: == *:checkjobs:* ]]; then + local joblist + ble/util/joblist + ((${#joblist[@]})) && printf '%s\n' "${#joblist[@]}" + fi + _ble_edit_line_disabled=1 ble/textarea#render + ble/edit/enter-command-layout # #D1800 pair=leave-command-layout + local -a DRAW_BUFF=() + ble/canvas/panel#goto.draw "$_ble_textarea_panel" "$_ble_textarea_gendx" "$_ble_textarea_gendy" + ble/canvas/bflush.draw + ble/edit/marker#instantiate-config exec_exit_mark + ble/util/buffer.print "$ret" + ble/util/buffer.flush + _ble_builtin_exit_processing=1 ble/builtin/exit 0 + ble/edit/leave-command-layout # #D1800 pair=enter-command-layout + return 1 +} +function ble/widget/delete-forward-char-or-exit { + if [[ $_ble_edit_str ]]; then + ble/widget/delete-forward-char + else + ble/widget/exit + fi +} +function ble/widget/delete-forward-backward-char { + ble-edit/content/clear-arg + ble/widget/.delete-char 0 || ble/widget/.bell +} +function ble/widget/delete-forward-char-or-list { + local right=${_ble_edit_str:_ble_edit_ind} + if [[ ! $right || $right == $'\n'* ]]; then + ble/widget/complete show_menu + else + ble/widget/delete-forward-char + fi +} +function ble/widget/delete-horizontal-space { + local arg; ble-edit/content/get-arg '' + local b=0 rex=$'[ \t]+$' + [[ ${_ble_edit_str::_ble_edit_ind} =~ $rex ]] && + b=${#BASH_REMATCH} + local a=0 rex=$'^[ \t]+' + [[ ! $arg && ${_ble_edit_str:_ble_edit_ind} =~ $rex ]] && + a=${#BASH_REMATCH} + ble/widget/.delete-range "$((_ble_edit_ind-b))" "$((_ble_edit_ind+a))" +} +function ble/widget/.forward-char { + ((_ble_edit_ind+=${1:-1})) + if ((_ble_edit_ind>${#_ble_edit_str})); then + _ble_edit_ind=${#_ble_edit_str} + return 1 + elif ((_ble_edit_ind<0)); then + _ble_edit_ind=0 + return 1 + fi +} +function ble/widget/forward-char { + local arg; ble-edit/content/get-arg 1 + ((arg==0)) && return 0 + ble/widget/.forward-char "$arg" || ble/widget/.bell +} +function ble/widget/backward-char { + local arg; ble-edit/content/get-arg 1 + ((arg==0)) && return 0 + ble/widget/.forward-char "$((-arg))" || ble/widget/.bell +} +_ble_edit_character_search_arg= +function ble/widget/character-search-forward { + local arg; ble-edit/content/get-arg 1 + _ble_edit_character_search_arg=$arg + _ble_edit_mark_active= + _ble_decode_char__hook=ble/widget/character-search.hook +} +function ble/widget/character-search-backward { + local arg; ble-edit/content/get-arg 1 + ((_ble_edit_character_search_arg=-arg)) + _ble_edit_mark_active= + _ble_decode_char__hook=ble/widget/character-search.hook +} +function ble/widget/character-search.hook { + local char=${KEYS[0]} + local ret; ble/util/c2s "${KEYS[0]}"; local c=$ret + [[ $c ]] || return 1 # Note: C-@ の時は無視 + local arg=$_ble_edit_character_search_arg + if ((arg>0)); then + local right=${_ble_edit_str:_ble_edit_ind+1} + if ble/string#index-of "$right" "$c" "$arg"; then + ((_ble_edit_ind=_ble_edit_ind+1+ret)) + elif ble/string#last-index-of "$right" "$c"; then + ble/widget/.bell "${arg}th character not found" + ((_ble_edit_ind=_ble_edit_ind+1+ret)) + else + ble/widget/.bell 'character not found' + return 1 + fi + elif ((arg<0)); then + local left=${_ble_edit_str::_ble_edit_ind} + if ble/string#last-index-of "$left" "$c" "$((-arg))"; then + _ble_edit_ind=$ret + elif ble/string#index-of "$left" "$c"; then + ble/widget/.bell "$((-arg))th last character not found" + _ble_edit_ind=$ret + else + ble/widget/.bell 'character not found' + return 1 + fi + fi + return 0 +} +function ble/widget/.locate-forward-byte { + local delta=$1 ret + if ((delta==0)); then + return 0 + elif ((delta>0)); then + local right=${_ble_edit_str:index:delta} + local rlen=${#right} + ble/util/strlen "$right"; local rsz=$ret + if ((delta>=rsz)); then + ((index+=rlen)) + ((delta==rsz)); return "$?" + else + while ((delta&&rlen>=2)); do + local mlen=$((rlen/2)) + local m=${right::mlen} + ble/util/strlen "$m"; local msz=$ret + if ((delta>=msz)); then + right=${right:mlen} + ((index+=mlen, + rlen-=mlen, + delta-=msz)) + ((rlen>delta)) && + right=${right::delta} rlen=$delta + else + right=$m rlen=$mlen + fi + done + ((delta&&rlen&&index++)) + return 0 + fi + elif ((delta<0)); then + ((delta=-delta)) + local left=${_ble_edit_str::index} + local llen=${#left} + ((llen>delta)) && left=${left:llen-delta} llen=$delta + ble/util/strlen "$left"; local lsz=$ret + if ((delta>=lsz)); then + ((index-=llen)) + ((delta==lsz)); return "$?" + else + while ((delta&&llen>=2)); do + local mlen=$((llen/2)) + local m=${left:llen-mlen} + ble/util/strlen "$m"; local msz=$ret + if ((delta>=msz)); then + left=${left::llen-mlen} + ((index-=mlen, + llen-=mlen, + delta-=msz)) + ((llen>delta)) && + left=${left:llen-delta} llen=$delta + else + left=$m llen=$mlen + fi + done + ((delta&&llen&&index--)) + return 0 + fi + fi +} +function ble/widget/forward-byte { + local arg; ble-edit/content/get-arg 1 + ((arg==0)) && return 0 + local index=$_ble_edit_ind + ble/widget/.locate-forward-byte "$arg" || ble/widget/.bell + _ble_edit_ind=$index +} +function ble/widget/backward-byte { + local arg; ble-edit/content/get-arg 1 + ((arg==0)) && return 0 + local index=$_ble_edit_ind + ble/widget/.locate-forward-byte "$((-arg))" || ble/widget/.bell + _ble_edit_ind=$index +} +function ble/widget/end-of-text { + local arg; ble-edit/content/get-arg '' + if [[ $arg ]]; then + if ((arg>=10)); then + _ble_edit_ind=0 + else + ((arg<0&&(arg=0))) + local index=$(((19-2*arg)*${#_ble_edit_str}/20)) + local ret; ble-edit/content/find-logical-bol "$index" + _ble_edit_ind=$ret + fi + else + _ble_edit_ind=${#_ble_edit_str} + fi +} +function ble/widget/beginning-of-text { + local arg; ble-edit/content/get-arg '' + if [[ $arg ]]; then + if ((arg>=10)); then + _ble_edit_ind=${#_ble_edit_str} + else + ((arg<0&&(arg=0))) + local index=$(((2*arg+1)*${#_ble_edit_str}/20)) + local ret; ble-edit/content/find-logical-bol "$index" + _ble_edit_ind=$ret + fi + else + _ble_edit_ind=0 + fi +} +function ble/widget/beginning-of-logical-line { + local arg; ble-edit/content/get-arg 1 + local ret; ble-edit/content/find-logical-bol "$_ble_edit_ind" "$((arg-1))" + _ble_edit_ind=$ret +} +function ble/widget/end-of-logical-line { + local arg; ble-edit/content/get-arg 1 + local ret; ble-edit/content/find-logical-eol "$_ble_edit_ind" "$((arg-1))" + _ble_edit_ind=$ret +} +function ble/widget/kill-backward-logical-line { + local arg; ble-edit/content/get-arg '' + if [[ $arg ]]; then + local ret; ble-edit/content/find-logical-eol "$_ble_edit_ind" "$((-arg))"; local index=$ret + if ((arg>0)); then + if ((_ble_edit_ind<=index)); then + index=0 + else + ble/string#count-char "${_ble_edit_str:index:_ble_edit_ind-index}" $'\n' + ((ret0)); then + if ((index<=_ble_edit_ind)); then + index=${#_ble_edit_str} + else + ble/string#count-char "${_ble_edit_str:_ble_edit_ind:index-_ble_edit_ind}" $'\n' + ((ret0?(eofs=arg-1):(arg<0&&(bofs=arg+1)))) + ble-edit/content/find-logical-bol "$_ble_edit_ind" "$bofs" && local bol=$ret + ble-edit/content/find-logical-eol "$_ble_edit_ind" "$eofs" && local eol=$ret + [[ ${_ble_edit_str:eol:1} == $'\n' ]] && ((eol++)) + ((bol0?arg:-arg)) + if ((arg>0)); then + if [[ ! $_ble_history_prefix && ! $_ble_history_load_done ]]; then + ble/widget/.bell 'end of history' + return 1 + fi + fi + ble/history/initialize + local index=$_ble_history_INDEX + local expr_next='--index>=0' + if ((arg>0)); then + local count=$_ble_history_COUNT + expr_next="++index<=$count" + fi + while ((expr_next)); do + if ((--rest<=0)); then + ble-edit/history/goto "$index" # 位置は goto に任せる + return "$?" + fi + local entry; ble/history/get-edited-entry "$index" + if [[ $entry == *$'\n'* ]]; then + local ret; ble/string#count-char "$entry" $'\n' + if ((rest<=ret)); then + ble-edit/history/goto "$index" + if ((arg>0)); then + ble-edit/content/find-logical-eol 0 "$rest" + else + ble-edit/content/find-logical-eol "${#entry}" "$((-rest))" + fi + _ble_edit_ind=$ret + return 0 + fi + ((rest-=ret)) + fi + done + if ((arg>0)); then + ble-edit/history/goto "$count" + _ble_edit_ind=${#_ble_edit_str} + ble/widget/.bell 'end of history' + else + ble-edit/history/goto 0 + _ble_edit_ind=0 + ble/widget/.bell 'beginning of history' + fi + return 0 +} +function ble/widget/forward-logical-line.impl { + local arg=$1 opts=$2 + ((arg==0)) && return 0 + local ind=$_ble_edit_ind + if ((arg>0)); then + ((ind<${#_ble_edit_str})) || return 1 + else + ((ind>0)) || return 1 + fi + local ret; ble-edit/content/find-logical-bol "$ind" "$arg"; local bol2=$ret + if ((arg>0)); then + if ((indbol2)); then + ble/string#count-char "${_ble_edit_str:bol2:ind-bol2}" $'\n' + ((arg+=ret)) + fi + fi + if ((arg==0)); then + ble-edit/content/find-logical-bol "$ind" ; local bol1=$ret + ble-edit/content/find-logical-eol "$bol2"; local eol2=$ret + local dst=$((bol2+ind-bol1)) + ((_ble_edit_ind=dst0)); then + ble-edit/content/find-logical-eol "$bol2" + else + ret=$bol2 + fi + _ble_edit_ind=$ret + if [[ :$opts: == *:history:* && ! $_ble_edit_mark_active ]]; then + ble/widget/forward-history-line.impl "$arg" + return "$?" + fi + if ((arg>0)); then + ble/widget/.bell 'end of string' + else + ble/widget/.bell 'beginning of string' + fi + return 0 +} +function ble/widget/forward-logical-line { + local opts=$1 + local arg; ble-edit/content/get-arg 1 + ble/widget/forward-logical-line.impl "$arg" "$opts" +} +function ble/widget/backward-logical-line { + local opts=$1 + local arg; ble-edit/content/get-arg 1 + ble/widget/forward-logical-line.impl "$((-arg))" "$opts" +} +function ble/keymap:emacs/find-graphical-eol { + local axis=${1:-$_ble_edit_ind} arg=${2:-0} + local x y index + ble/textmap#getxy.cur "$axis" + ble/textmap#get-index-at 0 "$((y+arg+1))" + if ((index>0)); then + local ax ay + ble/textmap#getxy.cur --prefix=a "$index" + ((ay>y+arg&&index--)) + fi + ret=$index +} +function ble/widget/beginning-of-graphical-line { + ble/textmap#is-up-to-date || ble/widget/.update-textmap + local arg; ble-edit/content/get-arg 1 + local x y index + ble/textmap#getxy.cur "$_ble_edit_ind" + ble/textmap#get-index-at 0 "$((y+arg-1))" + _ble_edit_ind=$index +} +function ble/widget/end-of-graphical-line { + ble/textmap#is-up-to-date || ble/widget/.update-textmap + local arg; ble-edit/content/get-arg 1 + local ret; ble/keymap:emacs/find-graphical-eol "$_ble_edit_ind" "$((arg-1))" + _ble_edit_ind=$ret +} +function ble/widget/kill-backward-graphical-line { + ble/textmap#is-up-to-date || ble/widget/.update-textmap + local arg; ble-edit/content/get-arg '' + if [[ ! $arg ]]; then + local x y index + ble/textmap#getxy.cur "$_ble_edit_ind" + ble/textmap#get-index-at 0 "$y" + ((index==_ble_edit_ind&&index>0&&index--)) + ble/widget/.kill-range "$index" "$_ble_edit_ind" + else + local ret; ble/keymap:emacs/find-graphical-eol "$_ble_edit_ind" "$((-arg))" + ble/widget/.kill-range "$ret" "$_ble_edit_ind" + fi +} +function ble/widget/kill-forward-graphical-line { + ble/textmap#is-up-to-date || ble/widget/.update-textmap + local arg; ble-edit/content/get-arg '' + local x y index ax ay + ble/textmap#getxy.cur "$_ble_edit_ind" + ble/textmap#get-index-at 0 "$((y+${arg:-1}))" + if [[ ! $arg ]] && ((_ble_edit_indy&&index--)) + fi + ble/widget/.kill-range "$_ble_edit_ind" "$index" +} +function ble/widget/kill-graphical-line { + ble/textmap#is-up-to-date || ble/widget/.update-textmap + local arg; ble-edit/content/get-arg 0 + local bofs=0 eofs=0 + ((arg>0?(eofs=arg-1):(arg<0&&(bofs=arg+1)))) + local x y index ax ay + ble/textmap#getxy.cur "$_ble_edit_ind" + ble/textmap#get-index-at 0 "$((y+bofs))" ; local bol=$index + ble/textmap#get-index-at 0 "$((y+eofs+1))"; local eol=$index + ((bol0)); then + ble/widget/.bell 'end of string' + else + ble/widget/.bell 'beginning of string' + fi + return 0 +} +function ble/widget/forward-graphical-line { + local opts=$1 + local arg; ble-edit/content/get-arg 1 + ble/widget/forward-graphical-line.impl "$arg" "$opts" +} +function ble/widget/backward-graphical-line { + local opts=$1 + local arg; ble-edit/content/get-arg 1 + ble/widget/forward-graphical-line.impl "$((-arg))" "$opts" +} +function ble/widget/beginning-of-line { + if ble/edit/performs-on-graphical-line; then + ble/widget/beginning-of-graphical-line + else + ble/widget/beginning-of-logical-line + fi +} +function ble/widget/non-space-beginning-of-line { + local old=$_ble_edit_ind + ble/widget/beginning-of-logical-line + local bol=$_ble_edit_ind ret= + ble-edit/content/find-non-space "$bol" + [[ $ret == $old ]] && ret=$bol # toggle + _ble_edit_ind=$ret + return 0 +} +function ble/widget/end-of-line { + if ble/edit/performs-on-graphical-line; then + ble/widget/end-of-graphical-line + else + ble/widget/end-of-logical-line + fi +} +function ble/widget/kill-backward-line { + if ble/edit/performs-on-graphical-line; then + ble/widget/kill-backward-graphical-line + else + ble/widget/kill-backward-logical-line + fi +} +function ble/widget/kill-forward-line { + if ble/edit/performs-on-graphical-line; then + ble/widget/kill-forward-graphical-line + else + ble/widget/kill-forward-logical-line + fi +} +function ble/widget/kill-line { + if ble/edit/performs-on-graphical-line; then + ble/widget/kill-graphical-line + else + ble/widget/kill-logical-line + fi +} +function ble/widget/forward-line { + if ble/edit/use-textmap; then + ble/widget/forward-graphical-line "$@" + else + ble/widget/forward-logical-line "$@" + fi +} +function ble/widget/backward-line { + if ble/edit/use-textmap; then + ble/widget/backward-graphical-line "$@" + else + ble/widget/backward-logical-line "$@" + fi +} +function ble/edit/word:eword/setup { + word_class=set2 word_set='a-zA-Z0-9' word_sep="$_ble_term_IFS" +} +function ble/edit/word:cword/setup { + word_class=set2 word_set='_a-zA-Z0-9' word_sep="$_ble_term_IFS" +} +function ble/edit/word:uword/setup { + word_class=set word_sep="$_ble_term_IFS" word_set="^$word_sep" +} +function ble/edit/word:sword/setup { + word_class=set word_sep=$'|&;()<> \t\n' word_set="^$word_sep" +} +function ble/edit/word:fword/setup { + word_class=set word_sep="/$_ble_term_IFS" word_set="^$word_sep" +} +function ble/edit/word/skip-backward { + local set=$1 head=${_ble_edit_str::x} + head=${head##*[$set]} + ((x-=${#head},${#head})) +} +function ble/edit/word/skip-forward { + local set=$1 tail=${_ble_edit_str:x} + tail=${tail%%[$set]*} + ((x+=${#tail},${#tail})) +} +function ble/edit/word/class:set/find-backward-word { + ble/edit/word/skip-backward "$word_set" +} +function ble/edit/word/class:set/find-backward-space { + ble/edit/word/skip-backward "$word_sep" +} +function ble/edit/word/class:set/find-forward-word { + ble/edit/word/skip-forward "$word_set" +} +function ble/edit/word/class:set/find-forward-space { + ble/edit/word/skip-forward "$word_sep" +} +function ble/edit/word/class:set2/find-backward-word { + ble/edit/word/skip-backward "!$word_sep" +} +function ble/edit/word/class:set2/find-backward-space { + case ${_ble_edit_str::x} in + (*[$word_sep]) return 1 ;; + (*[$word_set]) ble/edit/word/skip-backward "!$word_set" ;; + (*?) ble/edit/word/skip-backward "$word_set$word_sep" ;; + esac +} +function ble/edit/word/class:set2/find-forward-word { + ble/edit/word/skip-forward "!$word_sep" +} +function ble/edit/word/class:set2/find-forward-space { + case ${_ble_edit_str:x} in + ([$word_sep]*) return 1 ;; + ([$word_set]*) ble/edit/word/skip-forward "!$word_set" ;; + (?*) ble/edit/word/skip-forward "$word_set$word_sep" ;; + esac +} +function ble/edit/word/locate-backward { + local x=${1:-$_ble_edit_ind} arg=${2:-1} + while ((arg--)); do + ble/edit/word/class:"$word_class"/find-backward-word; c=$x + ble/edit/word/class:"$word_class"/find-backward-space; b=$x + done + ble/edit/word/class:"$word_class"/find-backward-word; a=$x +} +function ble/edit/word/locate-forward { + local x=${1:-$_ble_edit_ind} arg=${2:-1} + while ((arg--)); do + ble/edit/word/class:"$word_class"/find-forward-word; s=$x + ble/edit/word/class:"$word_class"/find-forward-space; t=$x + done + ble/edit/word/class:"$word_class"/find-forward-word; u=$x +} +function ble/edit/word/forward-range { + local arg=$1; ((arg)) || arg=1 + if ((arg<0)); then + ble/edit/word/backward-range "$((-arg))" + return "$?" + fi + local s t u; ble/edit/word/locate-forward "$x" "$arg"; y=$t +} +function ble/edit/word/backward-range { + local arg=$1; ((arg)) || arg=1 + if ((arg<0)); then + ble/edit/word/forward-range "$((-arg))" + return "$?" + fi + local a b c; ble/edit/word/locate-backward "$x" "$arg"; y=$b +} +function ble/edit/word/current-range { + local arg=$1; ((arg)) || arg=1 + if ((arg>0)); then + local a b c; ble/edit/word/locate-backward "$x" + local s t u; ble/edit/word/locate-forward "$a" "$arg" + ((y=a,x0)); then + x=$e1 + ble/edit/word/class:"$word_class"/find-forward-word; local b2=$x + while ble/edit/word/class:"$word_class"/find-forward-space || return 1; ((--arg>0)); do + ble/edit/word/class:"$word_class"/find-forward-word + done; local e2=$x + else + x=$b1 + ble/edit/word/class:"$word_class"/find-backward-word; local e2=$x + while ble/edit/word/class:"$word_class"/find-backward-space || return 1; ((++arg<0)); do + ble/edit/word/class:"$word_class"/find-backward-word + done; local b2=$x + fi + fi + ((b1>b2)) && local b1=$b2 e1=$e2 b2=$b1 e2=$e1 + ((b1=0)); then + ((arg==0)) && arg=1 + if ble/string#index-of "${_ble_edit_str:_ble_edit_ind}" "$char" "$arg"; then + ble/widget/.kill-range "$_ble_edit_ind" "$((_ble_edit_ind+ret+${#char}))" + return "$?" + fi + else + if ble/string#last-index-of "${_ble_edit_str::_ble_edit_ind}" "$char" "$((-arg))"; then + ble/widget/.kill-range "$ret" "$_ble_edit_ind" + return "$?" + fi + fi + if ((arg>0)); then + if ((arg==-1)); then + ble/widget/.bell "last char '$char' not found" + else + ble/widget/.bell "$((-arg))th last char '$char' not found" + fi + else + if ((arg==1)); then + ble/widget/.bell "next char '$char' not found" + else + ble/widget/.bell "$arg-th next char '$char' not found" + fi + fi + return 0 +} +function ble/widget/zap-to-char { + _ble_edit_mark_active= + _ble_decode_key__hook=ble/widget/zap-to-char.hook + return 147 +} +_ble_edit_exec_lines=() +_ble_edit_exec_lastexit=0 +_ble_edit_exec_lastarg=$BASH +_ble_edit_exec_lastparams=() +_ble_edit_exec_BASH_COMMAND=$BASH +_ble_edit_exec_PIPESTATUS=() +function ble-edit/exec/register { + local command=$1 + if [[ $command != *[!"$_ble_term_IFS"]* ]]; then + ble/edit/leave-command-layout + return 1 + fi + local command_id=$((_ble_edit_CMD++)) # Exposed to blehook exec_register + local lineno=$((_ble_edit_LINENO+1)) # Exposed to blehook exec_register + ble/array#push _ble_edit_exec_lines "$command_id,$lineno:$command" + blehook/invoke exec_register "$command" +} +function ble-edit/exec/has-pending-commands { + ((${#_ble_edit_exec_lines[@]})) +} +function ble-edit/exec/.setexit { + return "$_ble_edit_exec_lastexit" +} +_ble_prompt_eol_mark=('' '' 0) +function ble-edit/exec/.adjust-eol { + local cols=${COLUMNS:-80} + local -a DRAW_BUFF=() + if [[ $bleopt_prompt_eol_mark ]]; then + if [[ $bleopt_prompt_eol_mark != "${_ble_prompt_eol_mark[0]}" ]]; then + if [[ $bleopt_prompt_eol_mark ]]; then + local ret= x=0 y=0 g=0 x1=0 x2=0 y1=0 y2=0 + LINES=1 COLUMNS=80 ble/canvas/trace "$bleopt_prompt_eol_mark" truncate:measure-bbox + _ble_prompt_eol_mark=("$bleopt_prompt_eol_mark" "$ret" "$x2") + else + _ble_prompt_eol_mark=('' '' 0) + fi + fi + local eol_mark=${_ble_prompt_eol_mark[1]} + ble/canvas/put.draw "$_ble_term_sgr0$_ble_term_sc" + local width=${_ble_prompt_eol_mark[2]} limit=$cols + [[ $_ble_term_rc ]] || ((limit--)) + if ((width>limit)); then + local x=0 y=0 g=0 + LINES=1 COLUMNS=$limit ble/canvas/trace.draw "$bleopt_prompt_eol_mark" truncate + width=$x + else + ble/canvas/put.draw "$eol_mark" + fi + [[ $_ble_term_rc ]] || ble/canvas/put-cub.draw "$width" + ble/canvas/put.draw "$_ble_term_sgr0$_ble_term_rc" + fi + local advance=$((_ble_term_xenl?cols-2:cols-3)) + if [[ $_ble_term_TERM == cygwin:* ]]; then + while ((advance)); do + ble/canvas/put-cuf.draw "$((advance-advance/2))" + ((advance/=2)) + done + else + ble/canvas/put-cuf.draw "$advance" + fi + ble/canvas/put.draw " $_ble_term_cr$_ble_term_el" + ble/canvas/bflush.draw +} +_ble_prompt_ps10_data=() +function ble/prompt/unit:_ble_prompt_ps10/update { + ble/prompt/unit:{section}/update _ble_prompt_ps10 "$PS0" '' +} +function ble-edit/exec/print-PS0 { + if [[ $PS0 ]]; then + local version=$COLUMNS,$_ble_edit_lineno,$_ble_history_count,$_ble_edit_CMD + local prompt_hashref_base='$version' + local prompt_rows=${LINES:-25} + local prompt_cols=${COLUMNS:-80} + local "${_ble_prompt_cache_vars[@]/%/=}" # WA #D1570 checked + ble/prompt/unit#update _ble_prompt_ps10 + local ret; ble/prompt/unit:{section}/get _ble_prompt_ps10 + ble/util/put "$ret" + fi +} +_ble_builtin_exit_processing= +function ble/builtin/exit/.read-arguments { + [[ ! $_ble_attached || $_ble_edit_exec_inside_userspace ]] && + ble/base/adjust-BASH_REMATCH + while (($#)); do + local arg=$1; shift + if [[ $arg == --help ]]; then + opt_flags=${opt_flags}H + elif local rex='^[-+]?[0-9]+$'; [[ $arg =~ $rex ]]; then + ble/array#push opt_args "$arg" + else + ble/util/print "exit: unrecognized argument '$arg'" >&2 + opt_flags=${opt_flags}E + fi + done + if ((${#opt_args[@]}>=2)); then + ble/util/print "exit: too many arguments" >&2 + opt_flags=${opt_flags}E + fi + [[ ! $_ble_attached || $_ble_edit_exec_inside_userspace ]] && + ble/base/restore-BASH_REMATCH +} +function ble/builtin/exit { + local ext=$? + local trap_processing=$_ble_builtin_trap_processing + [[ $_ble_builtin_trap_processing == "${BASH_SUBSHELL:-0}"/* ]] || trap_processing= + if [[ ! $trap_processing ]] && { ble/util/is-running-in-subshell || [[ $_ble_decode_bind_state == none ]]; }; then + (($#)) || set -- "$ext" + builtin exit "$@" + return "$?" # オプションの指定間違いなどで失敗する可能性がある。 + fi + local set shopt; ble/base/.adjust-bash-options set shopt + local opt_flags= + local -a opt_args=() + ble/builtin/exit/.read-arguments "$@" + if [[ $opt_flags == *[EH]* ]]; then + [[ $opt_flags == *H* ]] && builtin exit --help + ble/base/.restore-bash-options set shopt + return 2 + fi + ((${#opt_args[@]})) || ble/array#push opt_args "$ext" + if [[ $trap_processing ]]; then + shopt -s extdebug + _ble_edit_exec_TRAPDEBUG_EXIT=$opt_args + ble-edit/exec:gexec/.TRAPDEBUG/trap + return 0 + fi + if [[ ! $_ble_builtin_exit_processing ]]; then + local joblist + ble/util/joblist + if ((${#joblist[@]})); then + local ret + while + local cancel_reason= + if ble/util/assign ret 'compgen -A stopped -- ""' 2>/dev/null; [[ $ret ]]; then + cancel_reason='stopped jobs' + elif [[ :$opts: == *:checkjobs:* ]]; then + if ble/util/assign ret 'compgen -A running -- ""' 2>/dev/null; [[ $ret ]]; then + cancel_reason='running jobs' + fi + fi + [[ $cancel_reason ]] + do + jobs + ble/builtin/read -ep "\e[38;5;12m[ble: There are $cancel_reason]\e[m Leave the shell anyway? [yes/No] " ret + case $ret in + ([yY]|[yY][eE][sS]) break ;; + ([nN]|[nN][oO]|'') + ble/base/.restore-bash-options set shopt + return 0 ;; + esac + done + fi + local ret + ble/edit/marker#instantiate-config exec_exit_mark && + ble/util/print "$ret" >&2 + fi + if ((40400<=_ble_bash&&_ble_bash<50200)); then + local global_TIMEFORMAT local_TIMEFORMAT + ble/util/assign global_TIMEFORMAT 'ble/util/print-global-definitions TIMEFORMAT' + if [[ $global_TIMEFORMAT == 'declare TIMEFORMAT; builtin unset -v TIMEFORMAT' ]]; then + global_TIMEFORMAT='declare -g TIMEFORMAT=$'\''\nreal\t%3lR\nuser\t%3lU\nsys %3lS'\' + else + global_TIMEFORMAT="declare -g ${global_TIMEFORMAT#declare }" + fi + ble/variable#copy-state TIMEFORMAT local_TIMEFORMAT + declare -g TIMEFORMAT= + TIMEFORMAT= + fi + ble/base/.restore-bash-options set shopt + _ble_builtin_exit_processing=1 + ble/fd#alloc _ble_builtin_exit_stdout '>&1' # EXIT trap で stdin/stdout を復元する + ble/fd#alloc _ble_builtin_exit_stderr '>&2' + builtin exit "${opt_args[@]}" &>/dev/null + builtin exit "${opt_args[@]}" &>/dev/null + _ble_builtin_exit_processing= + ble/fd#close _ble_builtin_exit_stdout + ble/fd#close _ble_builtin_exit_stderr + if ((40400<=_ble_bash&&_ble_bash<50200)); then + builtin eval -- "$global_TIMEFORMAT" + ble/variable#copy-state local_TIMEFORMAT TIMEFORMAT + fi + return 1 # exit できなかった場合は 1 らしい +} +function exit { + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_local_adjust" + ble/builtin/exit "$@" + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_local_return" +} +_ble_exec_time_TIMEFILE=$_ble_base_run/$$.exec.time +_ble_exec_time_TIMEFORMAT= +_ble_exec_time_tot= +_ble_exec_time_usr= +_ble_exec_time_sys= +function ble/exec/time#adjust-TIMEFORMAT { + if [[ ${TIMEFORMAT+set} ]]; then + _ble_exec_time_TIMEFORMAT=$TIMEFORMAT + else + builtin unset -v _ble_exec_time_TIMEFORMAT + fi + TIMEFORMAT='%R %U %S' +} +function ble/exec/time#restore-TIMEFORMAT { + if [[ ${_ble_exec_time_TIMEFORMAT+set} ]]; then + TIMEFORMAT=$_ble_exec_time_TIMEFORMAT + else + builtin unset -v 'TIMEFORMAT[0]' + fi + local tot usr sys dummy + while IFS=' ' ble/bash/read tot usr sys dummy; do + ble/string#match "$tot" '^[0-9.ms]+$' && break + done < "$_ble_exec_time_TIMEFILE" + ((_ble_exec_time_tot=10#0${tot//[!0-9]})) + ((_ble_exec_time_usr=10#0${usr//[!0-9]})) + ((_ble_exec_time_sys=10#0${sys//[!0-9]})) +} +_ble_exec_time_TIMES=$_ble_base_run/$$.exec.times +_ble_exec_time_usr_self= +_ble_exec_time_sys_self= +function ble/exec/time/times.parse-time { + local rex='^([0-9]+m)?([0-9]*)([^0-9ms][0-9]{3})?s?$' + [[ $1 =~ $rex ]] || return 1 + local min=$((10#0${BASH_REMATCH[1]%m})) + local sec=$((10#0${BASH_REMATCH[2]})) + local msc=$((10#0${BASH_REMATCH[3]#?})) + ((ret=(min*60+sec)*1000+msc)) + return 0 +} +function ble/exec/time/times.start { + builtin times >| "$_ble_exec_time_TIMES" +} +function ble/exec/time/times.end { + builtin times >> "$_ble_exec_time_TIMES" + local times + ble/util/readfile times "$_ble_exec_time_TIMES" + ble/string#split-words times "$times" + _ble_exec_time_usr_self= + _ble_exec_time_sys_self= + local ret= t1 t2 + ble/exec/time/times.parse-time "${times[0]}" && t1=$ret && + ble/exec/time/times.parse-time "${times[4]}" && t2=$ret && + ((_ble_exec_time_usr_self=t2>t1?t2-t1:0, + _ble_exec_time_usr_self>_ble_exec_time_usr&&( + _ble_exec_time_usr_self=_ble_exec_time_usr))) + ble/exec/time/times.parse-time "${times[1]}" && t1=$ret && + ble/exec/time/times.parse-time "${times[5]}" && t2=$ret && + ((_ble_exec_time_sys_self=t2>t1?t2-t1:0, + _ble_exec_time_sys_self>_ble_exec_time_sys&&( + _ble_exec_time_sys_self=_ble_exec_time_sys))) + return 0 +} +function ble/exec/time#mark-enabled { + local real=$_ble_exec_time_tot + local usr=$_ble_exec_time_usr usr_self=$_ble_exec_time_usr_self + local sys=$_ble_exec_time_sys sys_self=$_ble_exec_time_sys_self + local usr_child=$((usr-usr_self)) + local sys_child=$((sys-sys_self)) + local cpu=$((real>0?(usr+sys)*100/real:0)) + ((bleopt_exec_elapsed_enabled)) +} +_ble_exec_time_beg= +_ble_exec_time_end= +_ble_exec_time_ata= +function ble/exec/time#start { + if ((_ble_bash>=50000)); then + _ble_exec_time_EPOCHREALTIME_delay=0 + _ble_exec_time_EPOCHREALTIME_beg= + _ble_exec_time_EPOCHREALTIME_end= + function ble/exec/time#start { + ble/exec/time/times.start + _ble_exec_time_EPOCHREALTIME_beg= + _ble_exec_time_EPOCHREALTIME_end= + } + function ble/exec/time#end { + local beg=${_ble_exec_time_EPOCHREALTIME_beg//[!0-9]} + local end=${_ble_exec_time_EPOCHREALTIME_end//[!0-9]} + ((beg+=delay,beg>end)) && beg=$end + _ble_exec_time_beg=$beg + _ble_exec_time_end=$end + _ble_exec_time_ata=$((end-beg)) + _ble_exec_time_LINENO=$_ble_edit_LINENO + ble/exec/time/times.end + } + function ble/exec/time#calibrate.restore-lastarg { + _ble_exec_time_EPOCHREALTIME_beg=$EPOCHREALTIME + return "$_ble_edit_exec_lastexit" + } + function ble/exec/time#calibrate.save-lastarg { + _ble_exec_time_EPOCHREALTIME_end=$EPOCHREALTIME + ble/exec/time#adjust-TIMEFORMAT + } + function ble/exec/time#calibrate { + local _ble_edit_exec_lastexit=0 + local _ble_edit_exec_lastarg=hello + local _ble_exec_time_EPOCHREALTIME_beg= + local _ble_exec_time_EPOCHREALTIME_end= + local _ble_exec_time_tot= + local _ble_exec_time_usr= + local _ble_exec_time_sys= + local TIMEFORMAT= + local script1='ble/exec/time#calibrate.restore-lastarg "$_ble_edit_exec_lastarg"' + local script2='{ ble/exec/time#calibrate.save-lastarg; } 4>&1 5>&2 &>/dev/null' + local script=$script1$_ble_term_nl$script2$_ble_term_nl + local -a hist=() + local i + for i in {00..99}; do + { time LINENO=$i builtin eval -- "$script" 0<&"$_ble_util_fd_cmd_stdin" 1>&"$_ble_util_fd_cmd_stdout" 2>&"$_ble_util_fd_cmd_stderr"; } 2>| "$_ble_exec_time_TIMEFILE" + ble/exec/time#restore-TIMEFORMAT + local beg=${_ble_exec_time_EPOCHREALTIME_beg//[!0-9]} + local end=${_ble_exec_time_EPOCHREALTIME_end//[!0-9]} + ((hist[end-beg]++)) + done + local -a keys; keys=("${!hist[@]}") + keys=("${keys[@]::(${#keys[@]}+1)/2}") # Remove outliers + local s=0 n=0 t + for t in "${keys[@]}"; do ((s+=t*hist[t],n+=hist[t])); done + ((_ble_exec_time_EPOCHREALTIME_delay=s/n)) + } + ble/exec/time#calibrate + builtin unset -f ble/exec/time#calibrate + builtin unset -f ble/exec/time#calibrate.restore-lastarg + builtin unset -f ble/exec/time#calibrate.save-lastarg + else + _ble_exec_time_CLOCK_base=0 + _ble_exec_time_CLOCK_beg= + _ble_exec_time_CLOCK_end= + function ble/exec/time#end.adjust { + ((_ble_exec_time_beg/dev/null && ble/string#match "$ret" '^[0-9]+$'; then + function ble/exec/time#start { + ble/exec/time/times.start + _ble_exec_time_CLOCK_beg= + _ble_exec_time_CLOCK_end= + ble/util/assign _ble_exec_time_CLOCK_beg 'ble/bin/date +%s%6N' + } + function ble/exec/time#end { + ble/util/assign _ble_exec_time_CLOCK_end 'ble/bin/date +%s%6N' + local prev_end=$_ble_exec_time_end + _ble_exec_time_beg=$_ble_exec_time_CLOCK_beg + _ble_exec_time_end=$_ble_exec_time_CLOCK_end + _ble_exec_time_ata=$((_ble_exec_time_tot*1000)) + ble/exec/time#end.adjust + ble/exec/time/times.end + } + fi ;; + esac + fi + ble/exec/time#start +} +_ble_edit_exec_TRAPDEBUG_enabled= +_ble_edit_exec_TRAPDEBUG_INT= +_ble_edit_exec_TRAPDEBUG_EXIT= +_ble_edit_exec_inside_begin= +_ble_edit_exec_inside_prologue= +_ble_edit_exec_inside_userspace= +ble/builtin/trap/sig#reserve DEBUG override-builtin-signal:user-trap-in-postproc +function ble-edit/exec:gexec/.TRAPDEBUG/trap { + local trap_command + ble/builtin/trap/install-hook/.compose-trap_command "$_ble_builtin_trap_DEBUG" + builtin eval -- "builtin $trap_command" +} +_ble_edit_exec_TRAPDEBUG_adjusted= +function _ble_edit_exec_gexec__TRAPDEBUG_adjust { + builtin trap - DEBUG + _ble_edit_exec_TRAPDEBUG_adjusted=1 +} +ble/function#trace _ble_edit_exec_gexec__TRAPDEBUG_adjust +function ble-edit/exec:gexec/.TRAPDEBUG/restore { + _ble_edit_exec_TRAPDEBUG_adjusted= + local opts=$1 + if ble/builtin/trap/user-handler#has "$_ble_builtin_trap_DEBUG"; then + ble-edit/exec:gexec/.TRAPDEBUG/trap "$opts" + fi +} +function ble-edit/exec:gexec/.TRAPDEBUG/.filter { + [[ $_ble_edit_exec_TRAPDEBUG_enabled || ! $_ble_attached ]] || return 1 + [[ $_ble_trap_bash_command != *ble-edit/exec:gexec/.* ]] || return 1 + [[ ! ( ${FUNCNAME[1]-} == _ble_prompt_update__eval_prompt_command_1 && ( $_ble_trap_bash_command == 'ble-edit/exec/.setexit '* || $_ble_trap_bash_command == 'BASH_COMMAND='*' builtin eval -- '* ) ) ]] || return 1 + [[ ! ${_ble_builtin_trap_inside-} ]] || return 1 + return 0 +} +_ble_trap_builtin_handler_DEBUG_filter=ble-edit/exec:gexec/.TRAPDEBUG/.filter +function ble-edit/exec:gexec/.TRAPDEBUG { + if [[ $_ble_edit_exec_TRAPDEBUG_EXIT ]]; then + local flag_clear= flag_exit= postproc= + ble/util/unlocal _ble_builtin_trap_processing + if [[ ! $_ble_builtin_trap_processing ]] || ((${#BLE_TRAP_FUNCNAME[*]}==0)); then + flag_clear=2 + flag_exit=$_ble_edit_exec_TRAPDEBUG_EXIT + else + case " ${BLE_TRAP_FUNCNAME[*]} " in + (' ble/builtin/trap/invoke.sandbox ble/builtin/trap/invoke '*) + ble/util/unlocal _ble_trap_lastarg # declared in ble/builtin/trap/.handler for DEBUG + _ble_trap_done=exit # declared in ble/builtin/trap/invoke for the other signal + _ble_trap_lastarg=$_ble_edit_exec_TRAPDEBUG_EXIT # declared in ble/builtin/trap/invoke for the other signal + postproc='ble/util/setexit 2' + shopt -q extdebug || postproc='return 0' ;; + (' blehook/invoke.sandbox blehook/invoke ble/builtin/trap/.handler '*) + _ble_local_ext=$_ble_edit_exec_TRAPDEBUG_EXIT + _ble_builtin_trap_processing=${_ble_builtin_trap_processing%%/*}/exit:$_ble_edit_exec_TRAPDEBUG_EXIT + postproc='ble/util/setexit 2' + shopt -q extdebug || postproc='return 0' ;; + (' ble/builtin/trap/invoke '* | ' blehook/invoke '*) + flag_clear=1 ;; + (' ble/builtin/trap/.handler '* | ' ble-edit/exec:gexec/.TRAPDEBUG '*) + flag_clear=2 ;; + (*) + postproc='ble/util/setexit 2' + shopt -q extdebug || postproc='return 128' ;; + esac + fi + if [[ $flag_clear ]]; then + [[ $flag_clear == 2 ]] || shopt -u extdebug + _ble_edit_exec_TRAPDEBUG_EXIT= + if ! ble/builtin/trap/user-handler#has "$_ble_trap_sig"; then + postproc="builtin trap - DEBUG${postproc:+;$postproc}" + fi + if [[ $flag_exit ]]; then + builtin exit "$flag_exit" + fi + fi + _ble_builtin_trap_postproc[_ble_trap_sig]=$postproc + return 126 # skip user hooks/traps + elif [[ $_ble_edit_exec_TRAPDEBUG_INT ]]; then + ble/util/setexit "$_ble_trap_lastexit" "$_ble_trap_lastarg" + BASH_COMMAND=$_ble_trap_bash_command LINENO=$BLE_TRAP_LINENO \ + ble/builtin/trap/invoke "$_ble_trap_sig" "${_ble_trap_args[@]}" + local depth=${#BLE_TRAP_FUNCNAME[*]} + if ((depth>=1)) && ! ble/string#match "${BLE_TRAP_FUNCNAME[*]}" '^ble-edit/exec:gexec/\.|(^| )ble/builtin/trap/\.handler'; then + if [[ ${bleopt_internal_exec_int_trace-} ]]; then + local source=${_ble_term_setaf[5]}${BLE_TRAP_SOURCE[0]} + local sep=${_ble_term_setaf[6]}: + local lineno=${_ble_term_setaf[2]}${BLE_TRAP_LINENO[0]} + local func=${_ble_term_setaf[6]}' ('${_ble_term_setaf[4]}${BLE_TRAP_FUNCNAME[0]}${1:+ $1}${_ble_term_setaf[6]}')' + ble/util/print "${_ble_term_setaf[9]}[SIGINT]$_ble_term_sgr0 $source$sep$lineno$func$_ble_term_sgr0" >&"$_ble_util_fd_tui_stderr" + fi + _ble_builtin_trap_postproc[_ble_trap_sig]="{ return $_ble_edit_exec_TRAPDEBUG_INT || break; } &>/dev/null" + elif ((depth==0)) && ! ble/string#match "$_ble_trap_bash_command" '^ble-edit/exec:gexec/\.'; then + if [[ ${bleopt_internal_exec_int_trace-} ]]; then + local source=${_ble_term_setaf[5]}global + local sep=${_ble_term_setaf[6]}: + ble/util/print "${_ble_term_setaf[9]}[SIGINT]$_ble_term_sgr0 $source$sep$_ble_term_sgr0 $_ble_trap_bash_command" >&"$_ble_util_fd_tui_stderr" + fi + _ble_builtin_trap_postproc[_ble_trap_sig]="break &>/dev/null" + fi + return 126 # skip user hooks/traps + elif ! ble/builtin/trap/user-handler#has "$_ble_trap_sig"; then + _ble_builtin_trap_postproc[_ble_trap_sig]='builtin trap -- - DEBUG' + return 126 # skip user hooks/traps + fi + return 0 +} +blehook internal_DEBUG!=ble-edit/exec:gexec/.TRAPDEBUG +_ble_builtin_trap_DEBUG_userTrapInitialized= +function ble/builtin/trap:DEBUG { + _ble_builtin_trap_DEBUG_userTrapInitialized=1 + if [[ $1 != - && ( $_ble_edit_exec_TRAPDEBUG_enabled || ! $_ble_attached ) ]]; then + ble-edit/exec:gexec/.TRAPDEBUG/trap + fi +} +function _ble_builtin_trap_DEBUG__initialize { + if [[ $_ble_builtin_trap_DEBUG_userTrapInitialized ]]; then + builtin eval -- "function $FUNCNAME { return 0; }" + return 0 + elif [[ $1 == force ]] || ble/function/is-global-trace-context; then + _ble_builtin_trap_DEBUG_userTrapInitialized=1 + builtin eval -- "function $FUNCNAME { return 0; }" + local _ble_local_tmpfile; ble/util/assign/mktmp + builtin trap -p DEBUG >| "$_ble_local_tmpfile" + local content; ble/util/readfile content "$_ble_local_tmpfile" + ble/util/assign/rmtmp + case ${content#"trap -- '"} in + (ble-edit/exec:gexec/.TRAPDEBUG*|ble/builtin/trap/.handler*) ;; # ble-0.4 + (ble-edit/exec:exec/.eval-TRAPDEBUG*|ble-edit/exec:gexec/.eval-TRAPDEBUG*) ;; # ble-0.2 + (.ble-edit/exec:exec/eval-TRAPDEBUG*|.ble-edit/exec:gexec/eval-TRAPDEBUG*) ;; # ble-0.1 + (*) builtin eval -- "$content" ;; # ble/builtin/trap に処理させる + esac + return 0 + fi +} +ble/function#trace _ble_builtin_trap_DEBUG__initialize +_ble_builtin_trap_DEBUG__initialize +function ble-edit/exec:gexec/.TRAPINT { + local ret; ble/builtin/trap/sig#resolve INT + ble/builtin/trap/user-handler#has "$ret" && return 0 + local ext=130 + ((_ble_bash>=40300)) || ext=128 # bash-4.2 以下は 128 + if [[ $_ble_attached ]]; then + if [[ ${bleopt_internal_exec_int_trace-} ]]; then + ble/util/print "$_ble_term_bold^C$_ble_term_sgr0" >&"$_ble_util_fd_tui_stderr" + fi + _ble_edit_exec_TRAPDEBUG_INT=$ext + ble-edit/exec:gexec/.TRAPDEBUG/trap + else + _ble_builtin_trap_postproc="{ return $ext || break; } 2>&$_ble_util_fd_tui_stderr" + fi +} +function ble-edit/exec:gexec/.TRAPINT/reset { + blehook internal_INT-='ble-edit/exec:gexec/.TRAPINT' +} +function ble-edit/exec:gexec/invoke-hook-with-setexit { + local -a BLE_PIPESTATUS + BLE_PIPESTATUS=("${_ble_edit_exec_PIPESTATUS[@]}") + ble-edit/exec/.setexit "$_ble_edit_exec_lastarg" + LINENO=${_ble_edit_LINENO:-${BASH_LINENO[${#BASH_LINENO[@]}-1]}} \ + BASH_COMMAND=$_ble_edit_exec_BASH_COMMAND \ + blehook/invoke "$@" +} >&"$_ble_util_fd_tui_stdout" 2>&"$_ble_util_fd_tui_stderr" +function ble-edit/exec:gexec/.TRAPERR { + if [[ $_ble_attached ]]; then + [[ $_ble_edit_exec_inside_userspace ]] || return 126 + [[ $_ble_trap_bash_command != *'return "$_ble_edit_exec_lastexit"'* ]] || return 126 + fi + return 0 +} +blehook internal_ERR!='ble-edit/exec:gexec/.TRAPERR' +_ble_edit_exec_TERM= +function ble-edit/exec:gexec/TERM/is-dirty { + [[ $TERM != "$_ble_edit_exec_TERM" ]] && return 0 + local bindp + ble/util/assign bindp 'builtin bind -p' + [[ $bindp != "$_ble_decode_bind_bindp" ]] +} +function ble-edit/exec:gexec/TERM/leave { + _ble_edit_exec_TERM=$TERM +} +function ble-edit/exec:gexec/TERM/enter { + if [[ $_ble_decode_bind_state != none ]] && ble-edit/exec:gexec/TERM/is-dirty; then + ble/edit/info/immediate-show text 'ble: TERM has changed. rebinding...' + ble/decode/detach + if ! ble/decode/attach; then + ble-detach + ble-edit/bind/.check-detach && return 1 + fi + ble/edit/info/immediate-default + fi +} +function ble-edit/exec:gexec/.begin { + _ble_edit_exec_inside_begin=1 + local IFS=$_ble_term_IFS + _ble_edit_exec_PWD=$PWD + ble-edit/exec:gexec/TERM/leave + ble/term/leave + ble-edit/bind/stdout.on + ble/util/buffer.flush + ble/builtin/trap/install-hook INT # 何故か改めて実行しないと有効にならない + blehook internal_INT!='ble-edit/exec:gexec/.TRAPINT' + ble-edit/exec:gexec/.TRAPDEBUG/restore +} +function ble-edit/exec:gexec/.end { + _ble_edit_exec_inside_begin= + local IFS=$_ble_term_IFS + ble-edit/exec:gexec/.TRAPINT/reset + builtin trap -- - DEBUG + blehook/invoke exec_end + [[ $PWD != "$_ble_edit_exec_PWD" ]] && blehook/invoke CHPWD + ble/util/joblist.flush >&"$_ble_util_fd_tui_stderr" + ble-edit/bind/.check-detach && return 0 + ble/term/enter + ble-edit/exec:gexec/TERM/enter || return 0 # rebind に失敗した時 .tail せずに抜ける + ble/util/c2w:auto/check + ble/edit/clear-command-layout + [[ $1 == restore ]] && return 0 # Note: 前回の呼出で .end に失敗した時 #D1170 + ble-edit/bind/.tail # flush will be called here +} +function ble-edit/exec:gexec/.prologue { + _ble_edit_exec_inside_prologue=1 + local IFS=$_ble_term_IFS + _ble_edit_exec_BASH_COMMAND=$1 + _ble_edit_exec_command_id=$2 + BLE_COMMAND_ID=$2 + BLE_PIPESTATUS=("${_ble_edit_exec_PIPESTATUS[@]}") + _ble_edit_exec_BASH_COMMAND_eval=$_ble_edit_exec_BASH_COMMAND + if [[ $bleopt_exec_restore_pipestatus ]] && ((${#BLE_PIPESTATUS[@]} > 0)); then + local i pipe= + for ((i=0;i<${#BLE_PIPESTATUS[@]};i++)); do + pipe=$pipe'| (exit '${BLE_PIPESTATUS[i]}')' + done + _ble_edit_exec_BASH_COMMAND_eval="${pipe:2}; $_ble_edit_exec_BASH_COMMAND_eval" + fi + ble-edit/restore-PS1 + ble-edit/restore-READLINE + ble-edit/restore-IGNOREEOF + builtin unset -v HISTCMD; ble/history/get-count -v HISTCMD + _ble_edit_exec_TRAPDEBUG_INT= + ble/util/joblist.clear + ble-edit/exec:gexec/invoke-hook-with-setexit internal_PREEXEC "$_ble_edit_exec_BASH_COMMAND" + ble-edit/exec:gexec/invoke-hook-with-setexit PREEXEC "$_ble_edit_exec_BASH_COMMAND" + ble-edit/exec/print-PS0 >&"$_ble_util_fd_tui_stdout" 2>&"$_ble_util_fd_tui_stderr" + ble/exec/time#start + ble/base/restore-BASH_REMATCH +} +function ble-edit/exec:gexec/.restore-lastarg { + ble/base/restore-bash-options + ble/base/restore-builtin-wrappers + ble/base/restore-POSIXLY_CORRECT + builtin eval -- "$_ble_bash_FUNCNEST_restore" + _ble_edit_exec_TRAPDEBUG_enabled=1 + _ble_edit_exec_inside_userspace=1 + _ble_exec_time_EPOCHREALTIME_beg=$EPOCHREALTIME + return "$_ble_edit_exec_lastexit" # set $? +} &>/dev/null # set -x 対策 #D0930 +function _ble_edit_exec_gexec__save_lastarg { + _ble_exec_time_EPOCHREALTIME_end=$EPOCHREALTIME \ + _ble_edit_exec_lastexit=$? \ + _ble_edit_exec_lastarg=$_ \ + _ble_edit_exec_PIPESTATUS=("${PIPESTATUS[@]}") \ + _ble_edit_exec_lastparams=("$@") + _ble_edit_exec_inside_userspace= + _ble_edit_exec_TRAPDEBUG_enabled= + builtin eval -- "$_ble_bash_FUNCNEST_adjust" + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_adjust" + ble/base/adjust-bash-options + ble/exec/time#adjust-TIMEFORMAT + ble/fd/save-external-standard-streams 0 4 5 + return "$_ble_edit_exec_lastexit" +} +function _ble_edit_exec_gexec__epilogue { + _ble_exec_time_EPOCHREALTIME_end=${_ble_exec_time_EPOCHREALTIME_end:-$EPOCHREALTIME} \ + _ble_edit_exec_lastexit=$? + _ble_edit_exec_inside_userspace= + _ble_edit_exec_TRAPDEBUG_enabled= + builtin eval -- "$_ble_bash_FUNCNEST_adjust" + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_adjust" + ble/base/adjust-builtin-wrappers + if [[ $_ble_edit_exec_TRAPDEBUG_INT ]]; then + if ((_ble_edit_exec_lastexit==0)); then + _ble_edit_exec_lastexit=$_ble_edit_exec_TRAPDEBUG_INT + fi + _ble_edit_exec_TRAPDEBUG_INT= + fi + local IFS=$_ble_term_IFS + builtin trap -- - DEBUG + ble/base/adjust-bash-options + ble/base/adjust-BASH_REMATCH + ble-edit/adjust-IGNOREEOF + ble-edit/adjust-READLINE + ble/exec/time#restore-TIMEFORMAT + ble/exec/time#end + ble/util/reset-keymap-of-editing-mode + ble-edit/exec/.adjust-eol + _ble_edit_exec_inside_prologue= + ble/util/buffer.flush + ble-edit/exec:gexec/invoke-hook-with-setexit POSTEXEC "$_ble_edit_exec_BASH_COMMAND" + local msg= + if ((_ble_edit_exec_lastexit)); then + ble-edit/exec:gexec/invoke-hook-with-setexit ERREXEC "$_ble_edit_exec_BASH_COMMAND" + if local ret; ble/edit/marker#get-config exec_errexit_mark; then + ble/util/sprintf ret "$ret" "$_ble_edit_exec_lastexit" + msg=$ret + fi + fi + ble-edit/adjust-PS1 + if ble/exec/time#mark-enabled; then + if local ret; ble/edit/marker#get-config exec_elapsed_mark; then + local format=$ret + local ata=$((_ble_exec_time_ata/1000)) + if ((ata<1000)); then + ata="${ata}ms" + elif ((ata<1000*1000)); then + ata="${ata::${#ata}-3}.${ata:${#ata}-3}s" + elif ((ata/=1000,ata<3600*100)); then # ata [s] + local min + ((min=ata/60,ata%=60)) + if ((min<100)); then + ata="${min}m${ata}s" + else + ata="$((min/60))h$((min%60))m${ata}s" + fi + else + local hour + ((ata/=60,hour=ata/60,ata%=60)) + ata="$((hour/24))d$((hour%24))h${ata}m" + fi + local cpu='--.-' + if ((_ble_exec_time_tot)); then + cpu=$(((_ble_exec_time_usr+_ble_exec_time_sys)*1000/_ble_exec_time_tot)) + cpu=$((cpu/10)).$((cpu%10)) + fi + local ret + ble/util/sprintf ret "$format" "$ata" "$cpu" + msg=$msg$ret + ble/string#ltrim "$_ble_edit_exec_BASH_COMMAND" + msg="$msg $ret" + fi + fi + local ret + ble/edit/marker#instantiate "$msg" bare && ble/util/buffer.print "$ret" + local -a DRAW_BUFF=() + ble/prompt/print-ruler.draw "$_ble_edit_exec_BASH_COMMAND" + ble/canvas/bflush.draw +} +function ble-edit/exec:gexec/.setup { + ((${#_ble_edit_exec_lines[@]})) || [[ ! $_ble_edit_exec_TRAPDEBUG_adjusted ]] || return 1 + local buff='_ble_decode_bind_hook=' ibuff=1 + if [[ ! $_ble_edit_exec_TRAPDEBUG_adjusted ]]; then + buff[ibuff++]='_ble_builtin_trap_DEBUG__initialize force' + buff[ibuff++]=_ble_edit_exec_gexec__TRAPDEBUG_adjust + fi + local count=${#_ble_edit_exec_lines[@]} + if ((count)); then + ble/util/buffer.flush + local q=\' Q="'\''" cmd cmd_id lineno + buff[ibuff++]=ble-edit/exec:gexec/.begin + for cmd in "${_ble_edit_exec_lines[@]}"; do + cmd_id=${cmd%%,*} cmd=${cmd#*,} + lineno=${cmd%%:*} cmd=${cmd#*:} + buff[ibuff++]="ble-edit/exec:gexec/.prologue '${cmd//$q/$Q}' $cmd_id" + buff[ibuff++]='{ time LINENO='$lineno' eval -- "ble-edit/exec:gexec/.restore-lastarg \"\$_ble_edit_exec_lastarg\"' + buff[ibuff++]='$_ble_edit_exec_BASH_COMMAND_eval' + buff[ibuff++]='{ _ble_edit_exec_gexec__save_lastarg \"\$@\"; } 4>&1 5>&2 &>/dev/null' # Note: &>/dev/null は set -x 対策 #D0930 + buff[ibuff++]='" 0<&"$_ble_util_fd_cmd_stdin" 1>&"$_ble_util_fd_cmd_stdout" 2>&"$_ble_util_fd_cmd_stderr"; } 2>| "$_ble_exec_time_TIMEFILE"' + buff[ibuff++]='{ _ble_edit_exec_gexec__epilogue; } 3>&2 &>/dev/null' + done + _ble_edit_exec_lines=() + buff[ibuff++]=_ble_edit_exec_gexec__TRAPDEBUG_adjust + buff[ibuff++]=ble-edit/exec:gexec/.end + fi + if ((ibuff>=2)); then + IFS=$'\n' builtin eval '_ble_decode_bind_hook="${buff[*]}"' + fi + ((count>=1)); return "$?" +} +function ble-edit/exec:gexec/process { + ble-edit/exec:gexec/.setup + return "$?" +} +function ble-edit/exec:gexec/restore-state { + [[ $_ble_edit_exec_inside_prologue ]] && _ble_edit_exec_gexec__epilogue 3>&2 &>/dev/null + [[ $_ble_edit_exec_inside_begin ]] && ble-edit/exec:gexec/.end restore +} +: "${_ble_edit_lineno:=0}" +_ble_prompt_trim_opwd= +function ble/edit/.relocate-textarea { + ble/textarea#render leave + ble/edit/.allocate-textarea "$1" +} +function ble/edit/.allocate-textarea { + local opts=$1 + local -a DRAW_BUFF=() + if [[ :$opts: == *:keep-info:* && $_ble_textarea_panel == 0 ]] && + ! ble/util/joblist.has-events + then + local textarea_height=${_ble_canvas_panel_height[_ble_textarea_panel]} + ble/canvas/panel#increase-height.draw "$_ble_textarea_panel" 1 + ble/canvas/panel#goto.draw "$_ble_textarea_panel" 0 "$textarea_height" sgr0 + ble/canvas/bflush.draw + else + ble/edit/enter-command-layout # #D1800 checked=ble/edit/.relocate-textarea + ble/canvas/panel#goto.draw "$_ble_textarea_panel" "$_ble_textarea_gendx" "$_ble_textarea_gendy" sgr0 + ble/canvas/put.draw "$_ble_term_nl" + ble/canvas/bflush.draw + ble/util/joblist.bflush + [[ :$opts: == *:keep-info:* ]] && ble/edit/leave-command-layout + fi + ((_ble_edit_lineno++)) + _ble_prompt_trim_opwd=$PWD + ble/textarea#invalidate + _ble_canvas_x=0 _ble_canvas_y=0 + _ble_textarea_gendx=0 _ble_textarea_gendy=0 + _ble_canvas_panel_height[_ble_textarea_panel]=1 +} +function ble/widget/.hide-current-line { + local opts=$1 y_erase=0 + [[ :$opts: == *:keep-header:* ]] && y_erase=${_ble_prompt_ps1_data[4]} + local -a DRAW_BUFF=() + if ((y_erase)); then + ble/canvas/panel#clear-after.draw "$_ble_textarea_panel" 0 "$y_erase" + else + ble/canvas/panel#clear.draw "$_ble_textarea_panel" + fi + ble/canvas/panel#goto.draw "$_ble_textarea_panel" 0 "$y_erase" + ble/canvas/bflush.draw + ble/textarea#invalidate + _ble_canvas_x=0 _ble_canvas_y=$y_erase + _ble_textarea_gendx=0 _ble_textarea_gendy=$y_erase + ((_ble_canvas_panel_height[_ble_textarea_panel]=1+y_erase)) +} +function ble/widget/.newline/clear-content { + [[ $_ble_edit_overwrite_mode ]] && + ble/term/cursor-state/reveal + ble-edit/content/reset '' newline + _ble_edit_ind=0 + _ble_edit_mark=0 + _ble_edit_mark_active= + _ble_edit_overwrite_mode= +} +function ble/widget/.newline { + local opts=$1 + _ble_edit_mark_active= + if [[ $_ble_complete_menu_active ]]; then + [[ $_ble_highlight_layer_menu_filter_beg ]] && + ble/textarea#invalidate str # (#D0995) + fi + ble/edit/.allocate-textarea "$opts" # #D1800 checked=.newline + local ret; ble/string#count-char "$_ble_edit_str" $'\n' + ((_ble_edit_LINENO+=1+ret)) + ble/history/onleave.fire + ble/widget/.newline/clear-content +} +function ble/widget/discard-line { + ble-edit/content/clear-arg + [[ $bleopt_history_share ]] && ble/builtin/history/option:n + _ble_edit_line_disabled=1 ble/textarea#render leave + ble/widget/.newline keep-info + ble/textarea#render +} +function ble/edit/histexpand/run { + local shopt=$- + set -H + ble/builtin/history/option:p "$command"; local ext=$? + [[ $shopt == *H* ]] || set +H + return "$ext" +} +function ble/edit/histexpand/.impl { + ble/edit/histexpand/run 2>/dev/null; local ext=$? + ((ext)) && ble/util/print "$command" + ble/util/put : + return "$ext" +} +function ble/edit/histexpand { + local command=$1 + if [[ ! ${command//[ ]} ]]; then + ret=$command + return 0 + elif ble/util/assign ret 'ble/edit/histexpand/.impl'; then + ret=${ret%$_ble_term_nl:} + return 0 + else + ret=$command + return 1 + fi +} +_ble_edit_integration_mc_precmd_stop= +function ble/widget/accept-line/.is-mc-init { + [[ $MC_SID == $$ ]] && ((_ble_edit_LINENO<=5)) || return 1 + ((_ble_edit_LINENO==0)) && return 0 + if [[ $_ble_edit_str == *'PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND'* ]]; then + if ble/string#match "$_ble_edit_str" 'pwd>&[0-9]+;kill -STOP \$\$'; then + _ble_edit_integration_mc_precmd_stop=1 + ble/edit/info/set-default clear + fi + return 0 + fi + if ble/string#match "$_ble_edit_str" 'bind -x '\''"\\e\+":"([^"'\'']+)"'\'''; then + function ble/widget/.mc_exec_command { + ble/textarea#redraw + ble/util/buffer.flush + builtin eval -- "$1" + } + local str=${_ble_edit_str//"$BASH_REMATCH"/"ble-bind -f M-+ '.mc_exec_command '\''${BASH_REMATCH[1]}'\'''"} && + [[ $str != "$_ble_edit_str" ]] && + ble-edit/content/reset-and-check-dirty "$str" + fi + return 1 +} +function ble/widget/accept-line { + ble/decode/widget/keymap-dispatch "$@" +} +function ble/widget/default/accept-line/.prepare-verify { + local new_str=$1 new_ind=$2 + ble-edit/content/reset-and-check-dirty "$old_str" + _ble_edit_ind=$old_ind + _ble_edit_line_disabled=1 ble/edit/.relocate-textarea keep-info + ble-edit/content/reset-and-check-dirty "$new_str" + _ble_edit_ind=$new_ind + _ble_edit_mark=0 + _ble_edit_mark_active= + return 0 +} +function ble/widget/default/accept-line { + if [[ :$1: == *:syntax:* ]] || ble/widget/accept-line/.is-mc-init; then + ble-edit/content/update-syntax + if ! ble/syntax:bash/is-complete; then + ble/widget/newline + return "$?" + fi + fi + ble-edit/content/clear-arg + local command=$_ble_edit_str + if [[ ! ${command//["$_ble_term_IFS"]} ]]; then + [[ $bleopt_history_share ]] && + ble/builtin/history/option:n + ble/textarea#render leave + ble/widget/.newline keep-info + ble/prompt/print-ruler.buff '' keep-info + ble/textarea#render + ble/util/buffer.flush + return 0 + fi + local is_line_expanded= + local orig_str=$_ble_edit_str orig_ind=$_ble_edit_ind + if [[ :$bleopt_edit_magic_accept: == *:sabbrev:* ]]; then + local old_str=$_ble_edit_str old_ind=$_ble_edit_ind + if ble/complete/sabbrev/expand; then + if [[ :$bleopt_edit_magic_accept: == *:verify:* ]]; then + ble/widget/default/accept-line/.prepare-verify "$_ble_edit_str" "$_ble_edit_ind" + return 0 + fi + command=$_ble_edit_str + is_line_expanded=1 + elif (($?==147)); then + return 147 # We entered menu-complete + fi + fi + local expand_type + for expand_type in alias autocd; do + if [[ :$bleopt_edit_magic_accept: == *:"$expand_type":* ]]; then + local old_str=$_ble_edit_str old_ind=$_ble_edit_ind + if ble/complete/expand:"$expand_type"; then + if [[ :$bleopt_edit_magic_accept: == *:verify:* ]]; then + ble/widget/default/accept-line/.prepare-verify "$_ble_edit_str" "$_ble_edit_ind" + return 0 + fi + command=$_ble_edit_str + is_line_expanded=1 + fi + fi + done + if [[ -o histexpand || :$bleopt_edit_magic_accept: == *:history:* ]]; then + local old_str=$_ble_edit_str old_ind=$_ble_edit_ind + if local ret; ble/edit/histexpand "$command"; then + local expanded=$ret + else + ble/widget/.internal-print-command \ + 'ble/edit/histexpand/run 1>/dev/null' pre-flush # エラーメッセージを表示 + shopt -q histreedit &>/dev/null || ble/widget/.newline/clear-content + return "$?" + fi + if [[ $expanded != "$command" ]]; then + if shopt -q histverify &>/dev/null; then + ble/widget/default/accept-line/.prepare-verify "$expanded" "${#expanded}" + return 0 + fi + is_line_expanded=1 + command=$expanded + if [[ :$bleopt_edit_magic_accept: == *:history-inline:* ]]; then + ble-edit/content/reset-and-check-dirty "$command" + _ble_edit_ind=${#command} + fi + fi + fi + if [[ $is_line_expanded && :$bleopt_edit_magic_accept: == *:verify-syntax:* ]]; then + if [[ $command != "$_ble_edit_str" ]]; then + ble-edit/content/reset-and-check-dirty "$command" + _ble_edit_ind=${#command} + fi + ble-edit/content/update-syntax + if ! ble/syntax:bash/is-complete; then + local old_str=$orig_str old_ind=$orig_ind + ble/widget/default/accept-line/.prepare-verify "$_ble_edit_str" "$_ble_edit_ind" + return 0 + fi + fi + ble/textarea#render leave + ble-edit/exec/register "$command" + ble/history/add "$command" + local show_expanded + [[ $command != "$_ble_edit_str" ]] && show_expanded=1 + ble/widget/.newline # #D1800 register + if [[ $show_expanded ]]; then + local ret + ble/edit/marker#instantiate 'expand' non-empty + ble/util/buffer.print "$ret $command" + fi +} +function ble/widget/accept-and-next { + ble-edit/content/clear-arg + ble/history/initialize + local index=$_ble_history_INDEX + local count=$_ble_history_COUNT + if ((index+1/dev/null; then + ble-edit/content/update-syntax + ble/syntax:bash/is-complete || return 1 + fi + return 0 +} +function ble/widget/accept-single-line-or { + ble/decode/widget/keymap-dispatch "$@" +} +function ble/widget/default/accept-single-line-or { + if ble-edit/is-single-complete-line; then + ble/widget/accept-line + else + ble/widget/"$@" + fi +} +function ble/widget/accept-single-line-or-newline { + ble/widget/accept-single-line-or newline +} +function ble/widget/edit-and-execute-command.edit { + local content=$1 opts=:$2: + local file=$_ble_base_run/$$.blesh-fc.bash + ble/util/print "$content" >| "$file" + local fallback=vi + if ble/bin#has emacs; then + fallback='emacs -nw' + elif ble/bin#has vim; then + fallback=vim + elif ble/bin#has nano; then + fallback=nano + fi + if [[ $opts != *:no-newline:* ]]; then + _ble_edit_line_disabled=1 ble/textarea#render leave + ble/widget/.newline # #D1800 (呼び出し元で exec/register) + fi + ble/term/leave + ${bleopt_editor:-${VISUAL:-${EDITOR:-$fallback}}} "$file"; local ext=$? + ble/term/enter + if ((ext)); then + ble/widget/.bell + return 127 + fi + ble/util/readfile ret "$file" + return 0 +} +function ble/widget/edit-and-execute-command.impl { + local ret= + ble/widget/edit-and-execute-command.edit "$1" + local command=$ret + ble/string#match "$command" $'[\n]+$' && + command=${command::${#command}-${#BASH_REMATCH}} + if [[ $command != *[!"$_ble_term_IFS"]* ]]; then + ble/edit/leave-command-layout + ble/widget/.bell + return 1 + fi + ble/edit/marker#instantiate 'fc' non-empty + ble/util/buffer.print "$ret $command" + ble-edit/exec/register "$command" + ble/history/add "$command" +} +function ble/widget/edit-and-execute-command { + ble-edit/content/clear-arg + ble/widget/edit-and-execute-command.impl "$_ble_edit_str" +} +function ble/widget/insert-comment/.remove-comment { + local comment_begin=$1 + ret= + [[ $comment_begin ]] || return 1 + ble/string#escape-for-extended-regex "$comment_begin"; local rex_comment_begin=$ret + local rex1=$'([ \t]*'$rex_comment_begin$')[^\n]*(\n|$)|[ \t]+(\n|$)|\n' + local rex=$'^('$rex1')*$'; [[ $_ble_edit_str =~ $rex ]] || return 1 + local tail=$_ble_edit_str out= + while [[ $tail && $tail =~ ^$rex1 ]]; do + local rematch1=${BASH_REMATCH[1]} + if [[ $rematch1 ]]; then + out=$out${rematch1%?}${BASH_REMATCH:${#rematch1}} + else + out=$out$BASH_REMATCH + fi + tail=${tail:${#BASH_REMATCH}} + done + [[ $tail ]] && return 1 + ret=$out +} +function ble/widget/insert-comment/.insert { + local arg=$1 + local ret; ble/util/rlvar#read comment-begin '#' + local comment_begin=${ret::1} + local text= + if [[ $arg ]] && ble/widget/insert-comment/.remove-comment "$comment_begin"; then + text=$ret + else + text=$comment_begin${_ble_edit_str//$'\n'/$'\n'"$comment_begin"} + fi + ble-edit/content/reset-and-check-dirty "$text" +} +function ble/widget/insert-comment { + local arg; ble-edit/content/get-arg '' + ble/widget/insert-comment/.insert "$arg" + ble/widget/accept-line +} +function ble/widget/alias-expand-line.proc { + if ((tchild>=0)); then + ble/syntax/tree-enumerate-children \ + ble/widget/alias-expand-line.proc + elif [[ $wtype && ! ${wtype//[0-9]} ]] && ((wtype==_ble_ctx_CMDI)); then + local word=${_ble_edit_str:wbegin:wlen} + local ret; ble/alias#expand "$word" + [[ $word == "$ret" ]] && return 0 + changed=1 + ble/widget/.replace-range "$wbegin" "$((wbegin+wlen))" "$ret" + fi +} +function ble/widget/alias-expand-line { + ble-edit/content/clear-arg + ble-edit/content/update-syntax + local iN= changed= + ble/syntax/tree-enumerate ble/widget/alias-expand-line.proc + [[ $changed ]] && _ble_edit_mark_active= +} +function ble/widget/tilde-expand { + ble-edit/content/clear-arg + ble-edit/content/update-syntax + local len=${#_ble_edit_str} + local i=$len j=$len + while ((--i>=0)); do + ((_ble_syntax_attr[i])) || continue + if ((_ble_syntax_attr[i]==_ble_attr_TILDE)); then + local word=${_ble_edit_str:i:j-i} + builtin eval "local path=$word" + [[ $path != "$word" ]] && + ble/widget/.replace-range "$i" "$j" "$path" + fi + j=$i + done +} +_ble_edit_shell_expand_ExpandWtype=() +function ble/widget/shell-expand-line.initialize { + function ble/widget/shell-expand-line.initialize { return 0; } + _ble_edit_shell_expand_ExpandWtype[_ble_ctx_CMDI]=1 + _ble_edit_shell_expand_ExpandWtype[_ble_ctx_ARGI]=1 + _ble_edit_shell_expand_ExpandWtype[_ble_ctx_ARGEI]=1 + _ble_edit_shell_expand_ExpandWtype[_ble_ctx_ARGVI]=1 + _ble_edit_shell_expand_ExpandWtype[_ble_ctx_RDRF]=1 + _ble_edit_shell_expand_ExpandWtype[_ble_ctx_RDRD]=1 + _ble_edit_shell_expand_ExpandWtype[_ble_ctx_RDRS]=1 + _ble_edit_shell_expand_ExpandWtype[_ble_ctx_VALI]=1 + _ble_edit_shell_expand_ExpandWtype[_ble_ctx_CONDI]=1 +} +function ble/widget/shell-expand-line.expand-word { + local word=$1 + ble/widget/shell-expand-line.initialize + if [[ ! ${_ble_edit_shell_expand_ExpandWtype[wtype]} ]]; then + ret=$word + return 0 + fi + ret=$word; [[ $ret == '~'* ]] && ret='\'$word + ble/syntax:bash/simple-word/eval "$ret" noglob + if [[ $word != $ret || ${#ret[@]} -ne 1 ]]; then + [[ $opts == *:quote:* ]] && flags=${flags}q + return 0 + fi + if ((wtype==_ble_ctx_CMDI)); then + ble/alias#expand "$word" + [[ $word != $ret ]] && return 0 + fi + ret=$word +} +function ble/widget/shell-expand-line.proc { + [[ $wtype ]] || return 0 + if [[ ${wtype//[0-9]} ]]; then + ble/syntax/tree-enumerate-children ble/widget/shell-expand-line.proc + return 0 + fi + local word=${_ble_edit_str:wbegin:wlen} + local rex='^[_a-zA-Z][_a-zA-Z0-9]*=+?\(' + if ((wtype==_ble_attr_VAR)) && [[ $word =~ $rex ]]; then + ble/syntax/tree-enumerate-children ble/widget/shell-expand-line.proc + return 0 + fi + local flags= + local -a ret=() words=() + ble/widget/shell-expand-line.expand-word "$word" + words=("${ret[@]}") + [[ ${#words[@]} -eq 1 && $word == "$ret" ]] && return 0 + if ((wtype==_ble_ctx_RDRF||wtype==_ble_ctx_RDRD||wtype==_ble_ctx_RDRS)); then + local IFS=$_ble_term_IFS + words=("${words[*]}") + fi + local q=\' Q="'\''" specialchars='\ ["'\''`$|&;<>()*?!^{,}' + local w index=0 out= + for w in "${words[@]}"; do + ((index++)) && out=$out' ' + [[ $flags == *q* && $w == *["$specialchars"]* ]] && w=$q${w//$q/$Q}$q + out=$out$w + done + changed=1 + ble/widget/.replace-range "$wbegin" "$((wbegin+wlen))" "$out" +} +function ble/widget/shell-expand-line { + local opts=:$1: + ble-edit/content/clear-arg + ble/widget/history-expand-line + ble-edit/content/update-syntax + local iN= changed= + ble/syntax/tree-enumerate ble/widget/shell-expand-line.proc + [[ $changed ]] && _ble_edit_mark_active= +} +_ble_edit_undo=() +_ble_edit_undo_index=0 +_ble_edit_undo_history=() +_ble_edit_undo_hindex= +ble/array#push _ble_textarea_local_VARNAMES \ + _ble_edit_undo \ + _ble_edit_undo_index \ + _ble_edit_undo_history \ + _ble_edit_undo_hindex +function ble-edit/undo/.check-hindex { + local hindex; ble/history/get-index -v hindex + [[ $_ble_edit_undo_hindex == "$hindex" ]] && return 0 + if [[ $_ble_edit_undo_hindex ]]; then + local uindex=${_ble_edit_undo_index:-${#_ble_edit_undo[@]}} + local ret; ble/string#quote-words "$uindex" "${_ble_edit_undo[@]}" + _ble_edit_undo_history[_ble_edit_undo_hindex]=$ret + fi + if [[ ${_ble_edit_undo_history[hindex]} ]]; then + local data; builtin eval -- "data=(${_ble_edit_undo_history[hindex]})" + _ble_edit_undo=("${data[@]:1}") + _ble_edit_undo_index=${data[0]} + else + _ble_edit_undo=() + _ble_edit_undo_index=0 + fi + _ble_edit_undo_hindex=$hindex +} +function ble-edit/undo/clear-all { + _ble_edit_undo=() + _ble_edit_undo_index=0 + _ble_edit_undo_history=() + _ble_edit_undo_hindex= +} +function ble-edit/undo/history-change.hook { + local kind=$1; shift + case $kind in + (delete) + ble/builtin/history/array#delete-hindex _ble_edit_undo_history "$@" + _ble_edit_undo_hindex= ;; + (clear) + ble-edit/undo/clear-all ;; + (insert) + ble/builtin/history/array#insert-range _ble_edit_undo_history "$@" + local beg=$1 len=$2 + [[ $_ble_edit_undo_hindex ]] && + ((_ble_edit_undo_hindex>=beg)) && + ((_ble_edit_undo_hindex+=len)) ;; + esac +} +blehook history_change!=ble-edit/undo/history-change.hook +function ble-edit/undo/.get-current-state { + if ((_ble_edit_undo_index==0)); then + str= + if [[ $_ble_history_prefix || $_ble_history_load_done ]]; then + local index; ble/history/get-index + ble/history/get-entry -v str "$index" + fi + ind=${#entry} + else + local entry=${_ble_edit_undo[_ble_edit_undo_index-1]} + str=${entry#*:} ind=${entry%%:*} + fi +} +function ble-edit/undo/add { + ble-edit/undo/.check-hindex + local str ind; ble-edit/undo/.get-current-state + [[ $str == "$_ble_edit_str" ]] && return 0 + _ble_edit_undo[_ble_edit_undo_index++]=$_ble_edit_ind:$_ble_edit_str + if ((${#_ble_edit_undo[@]}>_ble_edit_undo_index)); then + _ble_edit_undo=("${_ble_edit_undo[@]::_ble_edit_undo_index}") + fi +} +function ble-edit/undo/.load { + local str ind; ble-edit/undo/.get-current-state + if [[ $bleopt_undo_point == end || $bleopt_undo_point == beg ]]; then + local old=$_ble_edit_str new=$str ret + if [[ $bleopt_undo_point == end ]]; then + ble/string#common-suffix "${old:_ble_edit_ind}" "$new"; local s1=${#ret} + local old=${old::${#old}-s1} new=${new::${#new}-s1} + ble/string#common-prefix "${old::_ble_edit_ind}" "$new"; local p1=${#ret} + local old=${old:p1} new=${new:p1} + ble/string#common-suffix "$old" "$new"; local s2=${#ret} + local old=${old::${#old}-s2} new=${new::${#new}-s2} + ble/string#common-prefix "$old" "$new"; local p2=${#ret} + else + ble/string#common-prefix "${old::_ble_edit_ind}" "$new"; local p1=${#ret} + local old=${old:p1} new=${new:p1} + ble/string#common-suffix "${old:_ble_edit_ind-p1}" "$new"; local s1=${#ret} + local old=${old::${#old}-s1} new=${new::${#new}-s1} + ble/string#common-prefix "$old" "$new"; local p2=${#ret} + local old=${old:p2} new=${new:p2} + ble/string#common-suffix "$old" "$new"; local s2=${#ret} + fi + local beg=$((p1+p2)) end0=$((${#_ble_edit_str}-s1-s2)) end=$((${#str}-s1-s2)) + ble-edit/content/replace "$beg" "$end0" "${str:beg:end-beg}" + if [[ $bleopt_undo_point == end ]]; then + ind=$end + else + ind=$beg + fi + else + ble-edit/content/reset-and-check-dirty "$str" + fi + _ble_edit_ind=$ind + return 0 +} +function ble-edit/undo/undo { + local arg=${1:-1} + ble-edit/undo/.check-hindex + ble-edit/undo/add # 最後に add/load してから変更があれば記録 + ((_ble_edit_undo_index)) || return 1 + ((_ble_edit_undo_index-=arg)) + ((_ble_edit_undo_index<0&&(_ble_edit_undo_index=0))) + ble-edit/undo/.load +} +function ble-edit/undo/redo { + local arg=${1:-1} + ble-edit/undo/.check-hindex + ble-edit/undo/add # 最後に add/load してから変更があれば記録 + local ucount=${#_ble_edit_undo[@]} + ((_ble_edit_undo_index=ucount&&(_ble_edit_undo_index=ucount))) + ble-edit/undo/.load +} +function ble-edit/undo/revert { + ble-edit/undo/.check-hindex + ble-edit/undo/add # 最後に add/load してから変更があれば記録 + ((_ble_edit_undo_index)) || return 1 + ((_ble_edit_undo_index=0)) + ble-edit/undo/.load +} +function ble-edit/undo/revert-toggle { + local arg=${1:-1} + ((arg%2==0)) && return 0 + ble-edit/undo/.check-hindex + ble-edit/undo/add # 最後に add/load してから変更があれば記録 + if ((_ble_edit_undo_index)); then + ((_ble_edit_undo_index=0)) + ble-edit/undo/.load + elif ((${#_ble_edit_undo[@]})); then + ((_ble_edit_undo_index=${#_ble_edit_undo[@]})) + ble-edit/undo/.load + else + return 1 + fi +} +_ble_edit_kbdmacro_record= +_ble_edit_kbdmacro_last=() +_ble_edit_kbdmacro_onplay= +function ble/widget/start-keyboard-macro { + ble/keymap:generic/clear-arg + [[ $_ble_edit_kbdmacro_onplay ]] && return 0 # 再生中は無視 + if ! ble/decode/charlog#start kbd-macro; then + if [[ $_ble_decode_keylog_chars_enabled == kbd-macro ]]; then + ble/widget/.bell 'kbd-macro: recording is already started' + else + ble/widget/.bell 'kbd-macro: the logging system is currently busy' + fi + return 1 + fi + _ble_edit_kbdmacro_record=1 + if [[ $_ble_decode_keymap == emacs ]]; then + ble/keymap:emacs/update-mode-indicator + elif [[ $_ble_decode_keymap == vi_nmap ]]; then + ble/keymap:vi/adjust-command-mode + fi + return 0 +} +function ble/widget/end-keyboard-macro { + ble/keymap:generic/clear-arg + [[ $_ble_edit_kbdmacro_onplay ]] && return 0 # 再生中は無視 + if [[ $_ble_decode_keylog_chars_enabled != kbd-macro ]]; then + ble/widget/.bell 'kbd-macro: recording is not running' + return 1 + fi + _ble_edit_kbdmacro_record= + ble/decode/charlog#end-exclusive-depth1 + _ble_edit_kbdmacro_last=("${ret[@]}") + if [[ $_ble_decode_keymap == emacs ]]; then + ble/keymap:emacs/update-mode-indicator + elif [[ $_ble_decode_keymap == vi_nmap ]]; then + ble/keymap:vi/adjust-command-mode + fi + return 0 +} +function ble/widget/call-keyboard-macro { + local arg; ble-edit/content/get-arg 1 + ble/keymap:generic/clear-arg + ((arg>0)) || return 1 + [[ $_ble_edit_kbdmacro_onplay ]] && return 0 # 再生中は無視 + local _ble_edit_kbdmacro_onplay=1 + if ((arg==1)); then + ble/widget/.MACRO "${_ble_edit_kbdmacro_last[@]}" + else + local -a chars=() + while ((arg-->0)); do + ble/array#push chars "${_ble_edit_kbdmacro_last[@]}" + done + ble/widget/.MACRO "${chars[@]}" + fi + [[ $_ble_decode_keymap == vi_nmap ]] && + ble/keymap:vi/adjust-command-mode +} +function ble/widget/print-keyboard-macro { + ble/keymap:generic/clear-arg + local ret; ble/decode/charlog#encode "${_ble_edit_kbdmacro_last[@]}" + ble/edit/info/show text "kbd-macro: $ret" + [[ $_ble_decode_keymap == vi_nmap ]] && + ble/keymap:vi/adjust-command-mode + return 0 +} +bleopt/declare -v history_preserve_point '' +function ble-edit/history/goto { + ble/history/initialize + local histlen=$_ble_history_COUNT + local index0=$_ble_history_INDEX + local index1=$1 + ((index0==index1)) && return 0 + if ((index1>histlen)); then + index1=$histlen + ble/widget/.bell + elif ((index1<0)); then + index1=0 + ble/widget/.bell + fi + ((index0==index1)) && return 0 + if [[ $bleopt_history_share && ! $_ble_history_prefix && $_ble_decode_keymap != isearch ]]; then + if ((index0==histlen||index1==histlen)); then + ble/builtin/history/option:n + local histlen2=$_ble_history_COUNT + if ((histlen!=histlen2)); then + ble/textarea#invalidate + ble-edit/history/goto "$((index1==histlen?histlen:index1))" + return "$?" + fi + fi + fi + ble/history/set-edited-entry "$index0" "$_ble_edit_str" + ble/history/onleave.fire + ble/history/set-index "$index1" + local entry; ble/history/get-edited-entry -v entry "$index1" + ble-edit/content/reset "$entry" history + if [[ $bleopt_history_preserve_point ]]; then + if ((_ble_edit_ind>${#_ble_edit_str})); then + _ble_edit_ind=${#_ble_edit_str} + fi + else + if ((index1=0)); then + ((beg=end=start)) + return 0 + fi + fi + fi + elif [[ :$opts: == *:B:* ]]; then + local start=$((has_extend?_ble_edit_ind:_ble_edit_ind-1)) + ((start<0)) && return 1 + if ((has_regex)); then + ble-edit/isearch/.shift-backward-references + local rex="^.{0,$start}($needle)" + ((start==0)) && rex="^($needle)" + if ble-edit/isearch/search/.match "$_ble_edit_str" "$rex"; then + local rematch1=${BASH_REMATCH[1]} + if [[ $rematch1 || :$opts: == *:allow_empty:* ]]; then + ((end=${#BASH_REMATCH}, + beg=end-${#rematch1})) + return 0 + else + flag_empty_retry=1 + fi + fi + else + if [[ $needle ]]; then + ble-edit/isearch/search/.last-index "${_ble_edit_str::start+${#needle}}" "$needle" && return 0 + else + if [[ :$opts: == *:allow_empty:* ]] && ((--start>=0)); then + ((beg=end=start)) + return 0 + fi + fi + fi + else + local start=$((has_extend?_ble_edit_mark:_ble_edit_ind)) + if ((has_regex)); then + ble-edit/isearch/.shift-backward-references + local rex="($needle).*\$" + ((start)) && rex=".{$start}$rex" + if ble-edit/isearch/search/.match "$_ble_edit_str" "$rex"; then + local rematch1=${BASH_REMATCH[1]} + if [[ $rematch1 || :$opts: == *:allow_empty:* ]]; then + ((beg=${#_ble_edit_str}-${#BASH_REMATCH}+start)) + ((end=beg+${#rematch1})) + return 0 + else + flag_empty_retry=1 + fi + fi + else + if [[ $needle ]]; then + ble-edit/isearch/search/.index "$_ble_edit_str" "$needle" "$start" && return 0 + else + if [[ :$opts: == *:allow_empty:* ]] || ((++start<=${#_ble_edit_str})); then + ((beg=end=start)) + return 0 + fi + fi + fi + fi + if [[ $flag_empty_retry ]]; then + if [[ :$opts: == *:[-B]:* ]]; then + if ((--start>=0)); then + local mark=$_ble_edit_mark; ((mark&&mark--)) + local ind=$_ble_edit_ind; ((ind&&ind--)) + opts=$opts:allow_empty + _ble_edit_mark=$mark _ble_edit_ind=$ind ble-edit/isearch/search "$needle" "$opts" + return 0 + fi + else + if ((++start<=${#_ble_edit_str})); then + local mark=$_ble_edit_mark; ((mark<${#_ble_edit_str}&&mark++)) + local ind=$_ble_edit_ind; ((ind<${#_ble_edit_str}&&ind++)) + opts=$opts:allow_empty + _ble_edit_mark=$mark _ble_edit_ind=$ind ble-edit/isearch/search "$needle" "$opts" + return 0 + fi + fi + fi + return 1 +} +function ble-edit/isearch/.shift-backward-references { + local rex_cc='\[[@][^]@]+[@]\]' # [:space:] [=a=] [.a.] など。 + local rex_bracket_expr='\[\^?]?('${rex_cc//@/:}'|'${rex_cc//@/=}'|'${rex_cc//@/.}'|[^][]|\[[^]:=.])*\[?\]' + local rex='^('$rex_bracket_expr'|\\[^1-8])*\\[1-8]' + local buff= + while [[ $needle =~ $rex ]]; do + local mlen=${#BASH_REMATCH} + buff=$buff${BASH_REMATCH::mlen-1}$((10#0${BASH_REMATCH:mlen-1}+1)) + needle=${needle:mlen} + done + needle=$buff$needle +} +_ble_edit_isearch_opts= +_ble_edit_isearch_str= +_ble_edit_isearch_dir=- +_ble_edit_isearch_arr=() +_ble_edit_isearch_old= +function ble-edit/isearch/status/append-progress-bar { + ble/util/is-unicode-output || return 1 + local pos=$1 count=$2 dir=$3 + [[ :$dir: == *:-:* || :$dir: == *:backward:* ]] && ((pos=count-1-pos)) + local ret; ble/string#create-unicode-progress-bar "$pos" "$count" 5 + text=$text$' \e[1;38;5;69;48;5;253m'$ret$'\e[m ' +} +function ble-edit/isearch/.show-status-with-progress.fib { + local ll rr + if [[ $_ble_edit_isearch_dir == - ]]; then + ll=\<\< rr=" " + else + ll=" " rr=">>" + fi + local index; ble/history/get-index + local histIndex='!'$((index+1)) + local text="(${#_ble_edit_isearch_arr[@]}: $ll $histIndex $rr) \`$_ble_edit_isearch_str'" + if [[ $1 ]]; then + local pos=$1 + local count; ble/history/get-count + text=$text' searching...' + ble-edit/isearch/status/append-progress-bar "$pos" "$count" "$_ble_edit_isearch_dir" + local percentage=$((count?pos*1000/count:1000)) + text=$text" @$pos ($((percentage/10)).$((percentage%10))%)" + fi + ((fib_ntask)) && text="$text *$fib_ntask" + ble/edit/info/show ansi "$text" +} +function ble-edit/isearch/.show-status.fib { + ble-edit/isearch/.show-status-with-progress.fib +} +function ble-edit/isearch/show-status { + local fib_ntask=${#_ble_util_fiberchain[@]} + ble-edit/isearch/.show-status.fib +} +function ble-edit/isearch/erase-status { + ble/edit/info/default +} +function ble-edit/isearch/.set-region { + local beg=$1 end=$2 + if ((beg=0)) && [[ ${_ble_edit_isearch_arr[ilast]} == "$ind:"[-+]":$hash" ]]; then + builtin unset -v "_ble_edit_isearch_arr[$ilast]" + return 0 + fi + local oind; ble/history/get-index -v oind + local obeg=$_ble_edit_ind oend=$_ble_edit_mark + [[ $_ble_edit_mark_active ]] || oend=$obeg + ((obeg>oend)) && local obeg=$oend oend=$obeg + local oneedle=$_ble_edit_isearch_str + local ohash=$obeg:$oend:$oneedle + [[ $ind == "$oind" && $hash == "$ohash" ]] && return 0 + ble/array#push _ble_edit_isearch_arr "$oind:$_ble_edit_isearch_dir:$ohash" +} +function ble-edit/isearch/.goto-match.fib { + local ind=$1 beg=$2 end=$3 needle=$4 + ble-edit/isearch/.push-isearch-array + _ble_edit_isearch_str=$needle + [[ $needle ]] && _ble_edit_isearch_old=$needle + local oind; ble/history/get-index -v oind + ((oind!=ind)) && ble-edit/history/goto "$ind" + ble-edit/isearch/.set-region "$beg" "$end" + ble-edit/isearch/.show-status.fib + ble/textarea#redraw +} +function ble-edit/isearch/.next.fib { + local opts=$1 + if [[ ! $fib_suspend ]]; then + if [[ :$opts: == *:forward:* || :$opts: == *:backward:* ]]; then + if [[ :$opts: == *:forward:* ]]; then + _ble_edit_isearch_dir=+ + else + _ble_edit_isearch_dir=- + fi + fi + local needle=${2-$_ble_edit_isearch_str} + local beg= end= search_opts=$_ble_edit_isearch_dir + if [[ :$opts: == *:append:* ]]; then + search_opts=$search_opts:extend + ble/path#remove opts append + fi + [[ :$opts: == *:ignore-case:* ]] && + search_opts=$search_opts:ignore-case + if [[ $needle ]] && ble-edit/isearch/search "$needle" "$search_opts"; then + local ind; ble/history/get-index -v ind + ble-edit/isearch/.goto-match.fib "$ind" "$beg" "$end" "$needle" + return 0 + fi + fi + ble-edit/isearch/.next-history.fib "$opts" "$needle" +} +function ble-edit/isearch/.next-history.fib { + local opts=$1 + if [[ $fib_suspend ]]; then + local needle=${fib_suspend#*:} isAdd= + local index start; builtin eval -- "${fib_suspend%%:*}" + fib_suspend= + else + local needle=${2-$_ble_edit_isearch_str} isAdd= + [[ :$opts: == *:append:* ]] && isAdd=1 + ble/history/initialize + local start=$_ble_history_INDEX + local index=$start + fi + if ((!isAdd)); then + if [[ $_ble_edit_isearch_dir == - ]]; then + ((index--)) + else + ((index++)) + fi + fi + local isearch_progress_callback=ble-edit/isearch/.show-status-with-progress.fib + local isearch_opts=stop_check:progress + [[ :$opts: == *:ignore-case:* ]] && isearch_opts=$isearch_opts:ignore-case + if [[ $_ble_edit_isearch_dir == - ]]; then + ble/history/isearch-backward-blockwise "$isearch_opts" + else + ble/history/isearch-forward "$isearch_opts" + fi + local ext=$? + if ((ext==0)); then + local str; ble/history/get-edited-entry -v str "$index" + if [[ $needle ]]; then + local ndl=$needle + if [[ :$opts: == *:ignore-case:* ]]; then + local ret + ble/string#tolower "$str"; str=$ret + ble/string#tolower "$ndl"; ndl=$ret + fi + if [[ $_ble_edit_isearch_dir == - ]]; then + local prefix=${str%"$ndl"*} + else + local prefix=${str%%"$ndl"*} + fi + local beg=${#prefix} end=$((${#prefix}+${#ndl})) + else + local beg=${#str} end=${#str} + fi + ble-edit/isearch/.goto-match.fib "$index" "$beg" "$end" "$needle" + elif ((ext==148)); then + fib_suspend="index=$index start=$start:$needle" + return 0 + else + ble/widget/.bell "isearch: \`$needle' not found" + return 0 + fi +} +function ble-edit/isearch/forward.fib { + if [[ ! $_ble_edit_isearch_str ]]; then + ble-edit/isearch/.next.fib "$_ble_edit_isearch_opts:forward" "$_ble_edit_isearch_old" + else + ble-edit/isearch/.next.fib "$_ble_edit_isearch_opts:forward" + fi +} +function ble-edit/isearch/backward.fib { + if [[ ! $_ble_edit_isearch_str ]]; then + ble-edit/isearch/.next.fib "$_ble_edit_isearch_opts:backward" "$_ble_edit_isearch_old" + else + ble-edit/isearch/.next.fib "$_ble_edit_isearch_opts:backward" + fi +} +function ble-edit/isearch/self-insert.fib { + local needle= + if [[ ! $fib_suspend ]]; then + local code=$1 + ((code==0)) && return 0 + local ret; ble/util/c2s "$code" + needle=$_ble_edit_isearch_str$ret + fi + ble-edit/isearch/.next.fib "$_ble_edit_isearch_opts:append" "$needle" +} +function ble-edit/isearch/insert-string.fib { + local needle= + [[ ! $fib_suspend ]] && + needle=$_ble_edit_isearch_str$1 + ble-edit/isearch/.next.fib "$_ble_edit_isearch_opts:append" "$needle" +} +function ble-edit/isearch/history-forward.fib { + _ble_edit_isearch_dir=+ + ble-edit/isearch/.next-history.fib "$_ble_edit_isearch_opts" +} +function ble-edit/isearch/history-backward.fib { + _ble_edit_isearch_dir=- + ble-edit/isearch/.next-history.fib "$_ble_edit_isearch_opts" +} +function ble-edit/isearch/history-self-insert.fib { + local needle= + if [[ ! $fib_suspend ]]; then + local code=$1 + ((code==0)) && return 0 + local ret; ble/util/c2s "$code" + needle=$_ble_edit_isearch_str$ret + fi + ble-edit/isearch/.next-history.fib "$_ble_edit_isearch_opts:append" "$needle" +} +function ble-edit/isearch/prev { + local sz=${#_ble_edit_isearch_arr[@]} + ((sz==0)) && return 0 + local ilast=$((sz-1)) + local top=${_ble_edit_isearch_arr[ilast]} + builtin unset -v '_ble_edit_isearch_arr[ilast]' + local ind dir beg end + ind=${top%%:*}; top=${top#*:} + dir=${top%%:*}; top=${top#*:} + beg=${top%%:*}; top=${top#*:} + end=${top%%:*}; top=${top#*:} + _ble_edit_isearch_dir=$dir + ble-edit/history/goto "$ind" + ble-edit/isearch/.set-region "$beg" "$end" + _ble_edit_isearch_str=$top + [[ $top ]] && _ble_edit_isearch_old=$top + ble-edit/isearch/show-status +} +function ble-edit/isearch/process { + local isearch_time=0 + ble/util/fiberchain#resume + ble-edit/isearch/show-status +} +function ble/widget/isearch/forward { + ble/util/fiberchain#push forward + ble-edit/isearch/process +} +function ble/widget/isearch/backward { + ble/util/fiberchain#push backward + ble-edit/isearch/process +} +function ble/widget/isearch/self-insert { + local code; ble/widget/self-insert/.get-code + ((code==0)) && return 0 + ble/util/fiberchain#push "self-insert $code" + ble-edit/isearch/process +} +function ble/widget/isearch/history-forward { + ble/util/fiberchain#push history-forward + ble-edit/isearch/process +} +function ble/widget/isearch/history-backward { + ble/util/fiberchain#push history-backward + ble-edit/isearch/process +} +function ble/widget/isearch/history-self-insert { + local code; ble/widget/self-insert/.get-code + ((code==0)) && return 0 + ble/util/fiberchain#push "history-self-insert $code" + ble-edit/isearch/process +} +function ble/widget/isearch/prev { + local nque + if ((nque=${#_ble_util_fiberchain[@]})); then + local ret; ble/array#pop _ble_util_fiberchain + ble-edit/isearch/process + else + ble-edit/isearch/prev + fi +} +function ble/widget/isearch/.restore-mark-state { + local old_mark_active=${_ble_edit_isearch_save[3]} + if [[ $old_mark_active ]]; then + local index; ble/history/get-index + if ((index==_ble_edit_isearch_save[0])); then + _ble_edit_mark=${_ble_edit_isearch_save[2]} + if [[ $old_mark_active != S ]] || ((_ble_edit_ind==_ble_edit_isearch_save[1])); then + _ble_edit_mark_active=$old_mark_active + fi + fi + fi +} +function ble/widget/isearch/exit.impl { + ble/decode/keymap/pop + _ble_edit_isearch_arr=() + _ble_edit_isearch_dir= + _ble_edit_isearch_str= + ble-edit/isearch/erase-status +} +function ble/widget/isearch/exit-with-region { + ble/widget/isearch/exit.impl + if [[ $_ble_edit_mark_active ]]; then + _ble_edit_mark_active=S + ble/decode/keymap/push selection + fi +} +function ble/widget/isearch/exit { + ble/widget/isearch/exit.impl + _ble_edit_mark_active= + ble/widget/isearch/.restore-mark-state +} +function ble/widget/isearch/cancel { + if ((${#_ble_util_fiberchain[@]})); then + ble/util/fiberchain#clear + ble-edit/isearch/show-status # 進捗状況だけ消去 + else + if ((${#_ble_edit_isearch_arr[@]})); then + local step + ble/string#split step : "${_ble_edit_isearch_arr[0]}" + ble-edit/history/goto "${step[0]}" + fi + ble/widget/isearch/exit.impl + _ble_edit_ind=${_ble_edit_isearch_save[1]} + _ble_edit_mark=${_ble_edit_isearch_save[2]} + _ble_edit_mark_active=${_ble_edit_isearch_save[3]} + fi +} +function ble/widget/isearch/exit-default { + ble/widget/isearch/exit-with-region + ble/decode/widget/redispatch +} +function ble/widget/isearch/accept-line { + if ((${#_ble_util_fiberchain[@]})); then + ble/widget/.bell "isearch: now searching..." + else + ble/widget/isearch/exit + ble-decode-key 13 # RET + fi +} +function ble/widget/isearch/exit-delete-forward-char { + ble/widget/isearch/exit + ble/widget/delete-forward-char +} +function ble/widget/history-isearch.impl { + local opts=$1 + ble/keymap:generic/clear-arg + ble/decode/keymap/push isearch + ble/util/fiberchain#initialize ble-edit/isearch + local index; ble/history/get-index + _ble_edit_isearch_save=("$index" "$_ble_edit_ind" "$_ble_edit_mark" "$_ble_edit_mark_active") + _ble_edit_isearch_opts= + ble/util/rlvar#test search-ignore-case 0 && + _ble_edit_isearch_opts=ignore-case + if [[ :$opts: == *:forward:* ]]; then + _ble_edit_isearch_dir=+ + else + _ble_edit_isearch_dir=- + fi + _ble_edit_isearch_arr=() + _ble_edit_mark=$_ble_edit_ind + ble-edit/isearch/show-status +} +function ble/widget/history-isearch-backward { + ble/widget/history-isearch.impl backward +} +function ble/widget/history-isearch-forward { + ble/widget/history-isearch.impl forward +} +function ble-decode/keymap:isearch/define { + ble-bind -f __defchar__ isearch/self-insert + ble-bind -f __line_limit__ nop + ble-bind -f C-r isearch/backward + ble-bind -f C-s isearch/forward + ble-bind -f 'C-?' isearch/prev + ble-bind -f 'DEL' isearch/prev + ble-bind -f 'C-h' isearch/prev + ble-bind -f 'BS' isearch/prev + ble-bind -f __default__ isearch/exit-default + ble-bind -f 'C-g' isearch/cancel + ble-bind -f 'C-x C-g' isearch/cancel + ble-bind -f 'C-M-g' isearch/cancel + ble-bind -f C-m isearch/exit + ble-bind -f RET isearch/exit + ble-bind -f C-j isearch/accept-line + ble-bind -f C-RET isearch/accept-line +} +_ble_edit_nsearch_input= +_ble_edit_nsearch_needle= +_ble_edit_nsearch_index0= +_ble_edit_nsearch_opts= +_ble_edit_nsearch_stack=() +_ble_edit_nsearch_match= +_ble_edit_nsearch_index= +_ble_edit_nsearch_prev= +function ble/highlight/layer:region/mark:nsearch/get-face { + face=region_match +} +function ble/highlight/layer:region/mark:nsearch/get-selection { + local beg=$_ble_edit_mark + local end=$((_ble_edit_mark+${#_ble_edit_nsearch_needle})) + selection=("$beg" "$end") +} +function ble-edit/nsearch/.show-status.fib { + [[ :$_ble_edit_nsearch_opts: == *:hide-status:* ]] && return 0 + local ll=\<\< rr=">>" # Note: Emacs workaround: '<<' や "<<" と書けない。 + local match=$_ble_edit_nsearch_match index0=$_ble_edit_nsearch_index0 + if ((match>index0)); then + ll=" " + elif ((match=2)); then + local record_type=${_ble_edit_nsearch_stack[nstack-1]%%,*} + if + if [[ $opt_forward ]]; then + [[ $record_type == backward ]] + else + [[ $record_type == forward ]] + fi + then + local ret; ble/array#pop _ble_edit_nsearch_stack + local record line=${ret#*:} + ble/string#split record , "${ret%%:*}" + if [[ :$opts: == *:action=load:* ]]; then + ble-edit/content/reset-and-check-dirty "$line" + else + ble-edit/history/goto "${record[1]}" + fi + _ble_edit_nsearch_match=${record[1]} + _ble_edit_nsearch_index=${record[1]} + _ble_edit_ind=${record[2]} + _ble_edit_mark=${record[3]} + if ((_ble_edit_mark!=_ble_edit_ind)); then + _ble_edit_mark_active=nsearch + else + _ble_edit_mark_active= + fi + ble-edit/nsearch/.show-status.fib + ble/textarea#redraw + fib_suspend= + return 0 + fi + fi + local index start opt_resume= + if [[ $fib_suspend ]]; then + opt_resume=1 + builtin eval -- "$fib_suspend" + fib_suspend= + else + local index=$_ble_edit_nsearch_index + if ((nstack==1)); then + local index0=$_ble_edit_nsearch_index0 + ((opt_forward?indexindex0)) && + index=$index0 + fi + local start=$index + fi + local needle=$_ble_edit_nsearch_needle + if + if [[ $opt_forward ]]; then + local count; ble/history/get-count + [[ $opt_resume ]] || ((++index)) + ((index<=count)) + else + [[ $opt_resume ]] || ((--index)) + ((index>=0)) + fi + then + local isearch_time=$fib_clock + local isearch_progress_callback=ble-edit/nsearch/.show-status.fib + local isearch_opts=stop_check:progress + [[ :$opts: != *:substr:* ]] && isearch_opts=$isearch_opts:head + [[ :$opts: == *:ignore-case:* ]] && isearch_opts=$isearch_opts:ignore-case + if [[ $opt_forward ]]; then + ble/history/isearch-forward "$isearch_opts"; local ext=$? + else + ble/history/isearch-backward-blockwise "$isearch_opts"; local ext=$? + fi + fib_clock=$isearch_time + else + local ext=1 + fi + if ((ext==0)); then + ble-edit/nsearch/.goto-match "$index" "$opts" + ble-edit/nsearch/.show-status.fib + ble/textarea#redraw + elif ((ext==148)); then + fib_suspend="index=$index start=$start" + return 148 + else + ble/widget/.bell "ble.sh: nsearch: '$needle' not found" + ble-edit/nsearch/.show-status.fib + if [[ $opt_forward ]]; then + local count; ble/history/get-count + ((_ble_edit_nsearch_index=count-1)) + else + ((_ble_edit_nsearch_index=0)) + fi + return "$ext" + fi +} +function ble-edit/nsearch/forward.fib { + ble-edit/nsearch/.search.fib "$_ble_edit_nsearch_opts:forward" +} +function ble-edit/nsearch/backward.fib { + ble-edit/nsearch/.search.fib "$_ble_edit_nsearch_opts:backward" +} +function ble-edit/nsearch/.test { + local str=$1 ndl=$2 opts=$3 + [[ :$opts: == *:ignore-case:* ]] && + shopt -s nocasematch + if [[ :$opts: == *:substr:* ]]; then + [[ $str == *"$ndl"* ]] + else + [[ $str == "$ndl"* ]] + fi; local ext=$? + shopt -u nocasematch + return "$ext" +} +function ble/widget/history-search { + local opts=$1 + if [[ :$opts: == *:input:* || :$opts: == *:again:* && ! $_ble_edit_nsearch_input ]]; then + ble/builtin/read -ep "nsearch> " _ble_edit_nsearch_needle || return 1 + _ble_edit_nsearch_input=$_ble_edit_nsearch_needle + elif [[ :$opts: == *:again:* ]]; then + _ble_edit_nsearch_needle=$_ble_edit_nsearch_input + else + local len=$_ble_edit_ind + if [[ $_ble_decode_keymap == vi_[noxs]map ]]; then + ble-edit/content/eolp || ((len++)) + fi + _ble_edit_nsearch_needle=${_ble_edit_str::len} + fi + if [[ ! $_ble_edit_nsearch_needle ]]; then + local empty=empty-search + local rex='.*:empty=([^:]*):' + [[ :$opts: =~ $rex ]] && empty=${BASH_REMATCH[1]} + case $empty in + (history-move) + if [[ :$opts: == *:forward:* ]]; then + ble/widget/history-next + else + ble/widget/history-prev + fi && _ble_edit_ind=0 + return "$?" ;; + (hide-status) + opts=$opts:hide-status ;; + (emulate-readline) + opts=hide-status:point=end:immediate-accept:$opts ;; + (previous-search) + _ble_edit_nsearch_needle=$_ble_edit_nsearch_prev ;; + esac + fi + _ble_edit_nsearch_prev=$_ble_edit_nsearch_needle + ble/keymap:generic/clear-arg + [[ :$opts: != *:ignore-case:* && :$opts: != *:match-case:* ]] && + ble/util/rlvar#test search-ignore-case 0 && + opts=$opts:ignore-case + _ble_edit_nsearch_stack=() + local index; ble/history/get-index + _ble_edit_nsearch_index0=$index + _ble_edit_nsearch_opts=$opts + ble/path#remove _ble_edit_nsearch_opts forward + ble/path#remove _ble_edit_nsearch_opts backward + _ble_edit_nsearch_match=$index + _ble_edit_nsearch_index=$index + _ble_edit_mark_active= + ble/decode/keymap/push nsearch + if ble-edit/nsearch/.test "$_ble_edit_str" "$_ble_edit_nsearch_needle" "$opts"; then + ble-edit/nsearch/.goto-match '' "$opts" + fi + ble/util/fiberchain#initialize ble-edit/nsearch + if [[ :$opts: == *:forward:* ]]; then + ble/util/fiberchain#push forward + else + ble/util/fiberchain#push backward + fi + ble/util/fiberchain#resume +} +function ble/widget/history-nsearch-backward { + ble/widget/history-search "input:substr:backward:$1" +} +function ble/widget/history-nsearch-forward { + ble/widget/history-search "input:substr:forward:$1" +} +function ble/widget/history-nsearch-backward-again { + ble/widget/history-search "again:substr:backward:$1" +} +function ble/widget/history-nsearch-forward-again { + ble/widget/history-search "again:substr:forward:$1" +} +function ble/widget/history-search-backward { + ble/widget/history-search "backward:$1" +} +function ble/widget/history-search-forward { + ble/widget/history-search "forward:$1" +} +function ble/widget/history-substring-search-backward { + ble/widget/history-search "substr:backward:$1" +} +function ble/widget/history-substring-search-forward { + ble/widget/history-search "substr:forward:$1" +} +function ble/widget/nsearch/forward { + local ntask=${#_ble_util_fiberchain[@]} + if ((ntask>=1)) && [[ ${_ble_util_fiberchain[ntask-1]%%:*} == backward ]]; then + local ret; ble/array#pop _ble_util_fiberchain + else + ble/util/fiberchain#push forward + fi + ble/util/fiberchain#resume +} +function ble/widget/nsearch/backward { + local ntask=${#_ble_util_fiberchain[@]} + if ((ntask>=1)) && [[ ${_ble_util_fiberchain[ntask-1]%%:*} == forward ]]; then + local ret; ble/array#pop _ble_util_fiberchain + else + ble/util/fiberchain#push backward + fi + ble/util/fiberchain#resume +} +function ble/widget/nsearch/.exit { + ble/decode/keymap/pop + _ble_edit_mark_active= + ble-edit/nsearch/erase-status +} +function ble/widget/nsearch/exit { + if [[ :$_ble_edit_nsearch_opts: == *:immediate-accept:* ]]; then + ble/widget/nsearch/accept-line + else + ble/widget/nsearch/.exit + fi +} +function ble/widget/nsearch/exit-default { + ble/widget/nsearch/.exit + ble/decode/widget/redispatch +} +function ble/widget/nsearch/cancel { + if ((${#_ble_util_fiberchain[@]})); then + ble/util/fiberchain#clear + ble-edit/nsearch/show-status + else + ble/widget/nsearch/.exit + local record=${_ble_edit_nsearch_stack[0]} + if [[ $record ]]; then + local line=${record#*:} + ble/string#split record , "${record%%:*}" + if [[ :$_ble_edit_nsearch_opts: == *:action=load:* ]]; then + ble-edit/content/reset-and-check-dirty "$line" + else + ble-edit/history/goto "$_ble_edit_nsearch_index0" + fi + _ble_edit_ind=${record[2]} + _ble_edit_mark=${record[3]} + fi + fi +} +function ble/widget/nsearch/accept-line { + if ((${#_ble_util_fiberchain[@]})); then + ble/widget/.bell "nsearch: now searching..." + else + ble/widget/nsearch/.exit + ble-decode-key 13 # RET + fi +} +function ble-decode/keymap:nsearch/define { + ble-bind -f __default__ nsearch/exit-default + ble-bind -f __line_limit__ nop + ble-bind -f 'C-g' nsearch/cancel + ble-bind -f 'C-x C-g' nsearch/cancel + ble-bind -f 'C-M-g' nsearch/cancel + ble-bind -f C-m nsearch/exit + ble-bind -f RET nsearch/exit + ble-bind -f C-j nsearch/accept-line + ble-bind -f C-RET nsearch/accept-line + ble-bind -f C-r nsearch/backward + ble-bind -f C-s nsearch/forward + ble-bind -f C-p nsearch/backward + ble-bind -f C-n nsearch/forward + ble-bind -f up nsearch/backward + ble-bind -f down nsearch/forward + ble-bind -f prior nsearch/backward + ble-bind -f next nsearch/forward +} +function ble-decode/keymap:safe/.bind { + [[ $ble_bind_nometa && $1 == *M-* ]] && return 0 + ble-bind -f "$1" "$2" +} +function ble-decode/keymap:safe/bind-common { + ble-decode/keymap:safe/.bind insert 'overwrite-mode' + ble-decode/keymap:safe/.bind __batch_char__ 'batch-insert' + ble-decode/keymap:safe/.bind __defchar__ 'self-insert' + ble-decode/keymap:safe/.bind 'C-q' 'quoted-insert' + ble-decode/keymap:safe/.bind 'C-v' 'quoted-insert' + ble-decode/keymap:safe/.bind 'M-C-m' 'newline' + ble-decode/keymap:safe/.bind 'M-RET' 'newline' + ble-decode/keymap:safe/.bind paste_begin 'bracketed-paste' + ble-decode/keymap:safe/.bind 'C-@' 'set-mark' + ble-decode/keymap:safe/.bind 'C-SP' 'set-mark' + ble-decode/keymap:safe/.bind 'NUL' 'set-mark' + ble-decode/keymap:safe/.bind 'M-SP' 'set-mark' + ble-decode/keymap:safe/.bind 'C-x C-x' 'exchange-point-and-mark' + ble-decode/keymap:safe/.bind 'C-w' 'kill-region-or kill-backward-uword' + ble-decode/keymap:safe/.bind 'M-w' 'copy-region-or copy-backward-uword' + ble-decode/keymap:safe/.bind 'C-y' 'yank' + ble-decode/keymap:safe/.bind 'M-y' 'yank-pop' + ble-decode/keymap:safe/.bind 'M-S-y' 'yank-pop backward' + ble-decode/keymap:safe/.bind 'M-Y' 'yank-pop backward' + ble-decode/keymap:safe/.bind 'S-delete' 'kill-region-or kill-backward-uword' + ble-decode/keymap:safe/.bind 'C-insert' 'copy-region-or copy-backward-uword' + ble-decode/keymap:safe/.bind 'S-insert' 'yank' + ble-decode/keymap:safe/.bind 'M-\' 'delete-horizontal-space' + ble-decode/keymap:selection/bind-shift @marked + ble-decode/keymap:safe/.bind 'C-f' 'forward-char' + ble-decode/keymap:safe/.bind 'C-b' 'backward-char' + ble-decode/keymap:safe/.bind 'right' 'forward-char' + ble-decode/keymap:safe/.bind 'left' 'backward-char' + ble-decode/keymap:safe/.bind 'C-d' 'delete-region-or delete-forward-char' + ble-decode/keymap:safe/.bind 'delete' 'delete-region-or delete-forward-char' + ble-decode/keymap:safe/.bind 'C-?' 'delete-region-or delete-backward-char' + ble-decode/keymap:safe/.bind 'DEL' 'delete-region-or delete-backward-char' + ble-decode/keymap:safe/.bind 'C-h' 'delete-region-or delete-backward-char' + ble-decode/keymap:safe/.bind 'BS' 'delete-region-or delete-backward-char' + ble-decode/keymap:safe/.bind 'C-t' 'transpose-chars' + ble-decode/keymap:safe/.bind 'C-right' 'forward-cword' + ble-decode/keymap:safe/.bind 'C-left' 'backward-cword' + ble-decode/keymap:safe/.bind 'M-right' 'forward-sword' + ble-decode/keymap:safe/.bind 'M-left' 'backward-sword' + ble-decode/keymap:safe/.bind 'M-d' 'kill-forward-cword' + ble-decode/keymap:safe/.bind 'M-h' 'kill-backward-cword' + ble-decode/keymap:safe/.bind 'C-delete' 'delete-forward-cword' + ble-decode/keymap:safe/.bind 'C-_' 'delete-backward-cword' + ble-decode/keymap:safe/.bind 'C-DEL' 'delete-backward-cword' + ble-decode/keymap:safe/.bind 'C-BS' 'delete-backward-cword' + ble-decode/keymap:safe/.bind 'M-delete' 'copy-forward-sword' + ble-decode/keymap:safe/.bind 'M-C-?' 'copy-backward-sword' + ble-decode/keymap:safe/.bind 'M-DEL' 'copy-backward-sword' + ble-decode/keymap:safe/.bind 'M-C-h' 'copy-backward-sword' + ble-decode/keymap:safe/.bind 'M-BS' 'copy-backward-sword' + ble-decode/keymap:safe/.bind 'M-f' 'forward-cword' + ble-decode/keymap:safe/.bind 'M-b' 'backward-cword' + ble-decode/keymap:safe/.bind 'M-c' 'capitalize-eword' + ble-decode/keymap:safe/.bind 'M-l' 'downcase-eword' + ble-decode/keymap:safe/.bind 'M-u' 'upcase-eword' + ble-decode/keymap:safe/.bind 'M-t' 'transpose-ewords' + ble-decode/keymap:safe/.bind 'C-a' 'beginning-of-line' + ble-decode/keymap:safe/.bind 'C-e' 'end-of-line' + ble-decode/keymap:safe/.bind 'home' 'beginning-of-line' + ble-decode/keymap:safe/.bind 'end' 'end-of-line' + ble-decode/keymap:safe/.bind 'M-m' 'non-space-beginning-of-line' + ble-decode/keymap:safe/.bind 'C-p' 'backward-line' # overwritten by bind-history + ble-decode/keymap:safe/.bind 'up' 'backward-line' # overwritten by bind-history + ble-decode/keymap:safe/.bind 'C-n' 'forward-line' # overwritten by bind-history + ble-decode/keymap:safe/.bind 'down' 'forward-line' # overwritten by bind-history + ble-decode/keymap:safe/.bind 'C-k' 'kill-forward-line' + ble-decode/keymap:safe/.bind 'C-u' 'kill-backward-line' + ble-decode/keymap:safe/.bind 'C-home' 'beginning-of-text' + ble-decode/keymap:safe/.bind 'C-end' 'end-of-text' + ble-decode/keymap:safe/.bind 'C-x (' 'start-keyboard-macro' + ble-decode/keymap:safe/.bind 'C-x )' 'end-keyboard-macro' + ble-decode/keymap:safe/.bind 'C-x e' 'call-keyboard-macro' + ble-decode/keymap:safe/.bind 'C-x P' 'print-keyboard-macro' + ble-decode/keymap:safe/.bind 'C-]' 'character-search-forward' + ble-decode/keymap:safe/.bind 'M-C-]' 'character-search-backward' + ble-decode/keymap:safe/.bind 'M-x' 'execute-named-command' +} +function ble-decode/keymap:safe/bind-history { + ble-decode/keymap:safe/.bind 'C-r' 'history-isearch-backward' + ble-decode/keymap:safe/.bind 'C-s' 'history-isearch-forward' + ble-decode/keymap:safe/.bind 'M-<' 'history-beginning' + ble-decode/keymap:safe/.bind 'M->' 'history-end' + ble-decode/keymap:safe/.bind 'C-prior' 'history-beginning' + ble-decode/keymap:safe/.bind 'C-next' 'history-end' + ble-decode/keymap:safe/.bind 'C-p' 'backward-line history' + ble-decode/keymap:safe/.bind 'up' 'backward-line history' + ble-decode/keymap:safe/.bind 'C-n' 'forward-line history' + ble-decode/keymap:safe/.bind 'down' 'forward-line history' + ble-decode/keymap:safe/.bind 'prior' 'history-search-backward' # bash-5.2 + ble-decode/keymap:safe/.bind 'next' 'history-search-forward' # bash-5.2 + ble-decode/keymap:safe/.bind 'C-x C-p' 'history-search-backward' + ble-decode/keymap:safe/.bind 'C-x up' 'history-search-backward' + ble-decode/keymap:safe/.bind 'C-x C-n' 'history-search-forward' + ble-decode/keymap:safe/.bind 'C-x down' 'history-search-forward' + ble-decode/keymap:safe/.bind 'C-x p' 'history-substring-search-backward' + ble-decode/keymap:safe/.bind 'C-x n' 'history-substring-search-forward' + ble-decode/keymap:safe/.bind 'C-x <' 'history-nsearch-backward' + ble-decode/keymap:safe/.bind 'C-x >' 'history-nsearch-forward' + ble-decode/keymap:safe/.bind 'C-x ,' 'history-nsearch-backward-again' + ble-decode/keymap:safe/.bind 'C-x .' 'history-nsearch-forward-again' + ble-decode/keymap:safe/.bind 'M-.' 'insert-last-argument' + ble-decode/keymap:safe/.bind 'M-_' 'insert-last-argument' + ble-decode/keymap:safe/.bind 'M-C-y' 'insert-nth-argument' +} +function ble-decode/keymap:safe/bind-complete { + ble-decode/keymap:safe/.bind 'C-i' 'complete' + ble-decode/keymap:safe/.bind 'TAB' 'complete' + ble-decode/keymap:safe/.bind 'M-?' 'complete show_menu' + ble-decode/keymap:safe/.bind 'M-*' 'complete insert_all' + ble-decode/keymap:safe/.bind 'M-{' 'complete insert_braces' + ble-decode/keymap:safe/.bind 'C-TAB' 'menu-complete' + ble-decode/keymap:safe/.bind 'S-C-i' 'menu-complete backward' + ble-decode/keymap:safe/.bind 'S-TAB' 'menu-complete backward' + ble-decode/keymap:safe/.bind 'auto_complete_enter' 'auto-complete-enter' + ble-decode/keymap:safe/.bind 'M-/' 'complete context=filename' + ble-decode/keymap:safe/.bind 'M-~' 'complete context=username' + ble-decode/keymap:safe/.bind 'M-$' 'complete context=variable' + ble-decode/keymap:safe/.bind 'M-@' 'complete context=hostname' + ble-decode/keymap:safe/.bind 'M-!' 'complete context=command' + ble-decode/keymap:safe/.bind 'C-x /' 'complete show_menu:context=filename' + ble-decode/keymap:safe/.bind 'C-x ~' 'complete show_menu:context=username' + ble-decode/keymap:safe/.bind 'C-x $' 'complete show_menu:context=variable' + ble-decode/keymap:safe/.bind 'C-x @' 'complete show_menu:context=hostname' + ble-decode/keymap:safe/.bind 'C-x !' 'complete show_menu:context=command' + ble-decode/keymap:safe/.bind "M-'" 'sabbrev-expand' + ble-decode/keymap:safe/.bind "C-x '" 'sabbrev-expand' + ble-decode/keymap:safe/.bind 'C-x C-r' 'dabbrev-expand' + ble-decode/keymap:safe/.bind 'M-g' 'complete context=glob' + ble-decode/keymap:safe/.bind 'C-x *' 'complete insert_all:context=glob' + ble-decode/keymap:safe/.bind 'C-x g' 'complete show_menu:context=glob' + ble-decode/keymap:safe/.bind 'M-C-i' 'complete context=dynamic-history' + ble-decode/keymap:safe/.bind 'M-TAB' 'complete context=dynamic-history' +} +function ble-decode/keymap:safe/bind-arg { + local append_arg=append-arg${1:+'-or '}$1 + ble-decode/keymap:safe/.bind M-C-u 'universal-arg' + ble-decode/keymap:safe/.bind M-- "$append_arg" + ble-decode/keymap:safe/.bind M-0 "$append_arg" + ble-decode/keymap:safe/.bind M-1 "$append_arg" + ble-decode/keymap:safe/.bind M-2 "$append_arg" + ble-decode/keymap:safe/.bind M-3 "$append_arg" + ble-decode/keymap:safe/.bind M-4 "$append_arg" + ble-decode/keymap:safe/.bind M-5 "$append_arg" + ble-decode/keymap:safe/.bind M-6 "$append_arg" + ble-decode/keymap:safe/.bind M-7 "$append_arg" + ble-decode/keymap:safe/.bind M-8 "$append_arg" + ble-decode/keymap:safe/.bind M-9 "$append_arg" + ble-decode/keymap:safe/.bind C-- "$append_arg" + ble-decode/keymap:safe/.bind C-0 "$append_arg" + ble-decode/keymap:safe/.bind C-1 "$append_arg" + ble-decode/keymap:safe/.bind C-2 "$append_arg" + ble-decode/keymap:safe/.bind C-3 "$append_arg" + ble-decode/keymap:safe/.bind C-4 "$append_arg" + ble-decode/keymap:safe/.bind C-5 "$append_arg" + ble-decode/keymap:safe/.bind C-6 "$append_arg" + ble-decode/keymap:safe/.bind C-7 "$append_arg" + ble-decode/keymap:safe/.bind C-8 "$append_arg" + ble-decode/keymap:safe/.bind C-9 "$append_arg" + ble-decode/keymap:safe/.bind - "$append_arg" + ble-decode/keymap:safe/.bind 0 "$append_arg" + ble-decode/keymap:safe/.bind 1 "$append_arg" + ble-decode/keymap:safe/.bind 2 "$append_arg" + ble-decode/keymap:safe/.bind 3 "$append_arg" + ble-decode/keymap:safe/.bind 4 "$append_arg" + ble-decode/keymap:safe/.bind 5 "$append_arg" + ble-decode/keymap:safe/.bind 6 "$append_arg" + ble-decode/keymap:safe/.bind 7 "$append_arg" + ble-decode/keymap:safe/.bind 8 "$append_arg" + ble-decode/keymap:safe/.bind 9 "$append_arg" +} +function ble/widget/safe/__attach__ { + ble/edit/info/set-default text '' +} +function ble-decode/keymap:safe/define { + local ble_bind_nometa= + ble-decode/keymap:safe/bind-common + ble-decode/keymap:safe/bind-history + ble-decode/keymap:safe/bind-complete + ble-bind -f 'C-d' 'delete-region-or delete-forward-char-or-exit' + ble-bind -f 'SP' magic-space + ble-bind -f '/' magic-slash + ble-bind -f 'M-^' history-expand-line + ble-bind -f __attach__ safe/__attach__ + ble-bind -f __line_limit__ __line_limit__ + ble-bind -f 'C-c' discard-line + ble-bind -f 'C-j' accept-line + ble-bind -f 'C-RET' accept-line + ble-bind -f 'C-m' accept-single-line-or-newline + ble-bind -f 'RET' accept-single-line-or-newline + ble-bind -f 'C-o' accept-and-next + ble-bind -f 'C-x C-e' edit-and-execute-command + ble-bind -f 'M-#' insert-comment + ble-bind -f 'M-C-e' shell-expand-line + ble-bind -f 'M-&' tilde-expand + ble-bind -f 'C-g' bell + ble-bind -f 'C-x C-g' bell + ble-bind -f 'C-M-g' bell + ble-bind -f 'C-l' clear-screen + ble-bind -f 'C-M-l' redraw-line + ble-bind -f 'f1' command-help + ble-bind -f 'C-x C-v' display-shell-version + ble-bind -c 'C-z' fg + ble-bind -f 'M-z' zap-to-char +} +function ble-edit/bind/load-editing-mode:safe { + ble/decode/keymap#load safe +} +ble/util/autoload "lib/keymap.emacs.sh" \ + ble-decode/keymap:emacs/define +ble/util/autoload "lib/keymap.vi.sh" \ + ble-decode/keymap:vi_{i,n,o,x,s,c}map/define +ble/util/autoload "lib/keymap.vi_digraph.sh" \ + ble-decode/keymap:vi_digraph/define +function ble/widget/.change-editing-mode { + [[ $_ble_decode_bind_state == none ]] && return 0 + local mode=$1 + if [[ $bleopt_default_keymap == auto ]]; then + if [[ ! -o $mode ]]; then + set -o "$mode" + ble/decode/reset-default-keymap + ble/decode/detach + ble/decode/attach || ble-detach + fi + else + bleopt default_keymap="$mode" + fi +} +function ble/widget/emacs-editing-mode { + ble/widget/.change-editing-mode emacs +} +function ble/widget/vi-editing-mode { + ble/widget/.change-editing-mode vi +} +_ble_edit_read_accept= +_ble_edit_read_result= +function ble/widget/read/accept { + if [[ $_ble_edit_async_read_prefix ]]; then + local prefix=$_ble_edit_async_read_prefix + local hook=${prefix}_accept_hook; hook=${!hook} + ble/util/set "${prefix}_accept_hook" '' + ble/util/set "${prefix}_cancel_hook" '' + ble/util/set "${prefix}_before_widget" '' + local ret + ble/edit/async-read-mode/accept + [[ ! $hook ]] || "$hook" "$ret" + else + _ble_edit_read_accept=1 + _ble_edit_read_result=$_ble_edit_str + ble/decode/keymap/pop + fi +} +function ble/widget/read/cancel { + if [[ $_ble_edit_async_read_prefix ]]; then + local hook=${_ble_edit_async_read_prefix}_cancel_hook + ble/util/set "${_ble_edit_async_read_prefix}_accept_hook" "${!hook}" + ble/widget/read/accept + else + ble/widget/read/accept + _ble_edit_read_accept=2 + fi +} +function ble/widget/read/delete-forward-char-or-cancel { + if [[ $_ble_edit_str ]]; then + ble/widget/delete-forward-char + else + ble/widget/read/cancel + fi +} +function ble/widget/read/__line_limit__.edit { + local content=$1 + ble/widget/edit-and-execute-command.edit "$content" no-newline; local ext=$? + ((ext==127)) && return "$ext" + ble-edit/content/reset "$ret" + ble/widget/read/accept +} +function ble/widget/read/__line_limit__ { + ble/widget/__line_limit__ read/__line_limit__.edit +} +function ble/widget/read/__before_widget__ { + if [[ $_ble_edit_async_read_prefix ]]; then + local hook=${_ble_edit_async_read_prefix}_before_widget + builtin eval -- "${!hook}" + fi +} +function ble-decode/keymap:read/define { + local ble_bind_nometa= + ble-decode/keymap:safe/bind-common + ble-decode/keymap:safe/bind-history + ble-bind -f __before_widget__ read/__before_widget__ + ble-bind -f __line_limit__ read/__line_limit__ + ble-bind -f 'C-c' read/cancel + ble-bind -f 'C-\' read/cancel + ble-bind -f 'C-m' read/accept + ble-bind -f 'RET' read/accept + ble-bind -f 'C-j' read/accept + ble-bind -f 'C-d' 'delete-region-or read/delete-forward-char-or-cancel' + ble-bind -f 'C-g' bell + ble-bind -f 'C-l' redraw-line + ble-bind -f 'C-M-l' redraw-line + ble-bind -f 'C-x C-v' display-shell-version + ble-bind -f 'C-^' bell +} +_ble_edit_read_history=() +_ble_edit_read_history_edit=() +_ble_edit_read_history_dirt=() +_ble_edit_read_history_index=0 +function ble/builtin/read/.process-option { + case $1 in + (-e) opt_flags=${opt_flags}r ;; + (-i) opt_default=$2 ;; + (-p) opt_prompt=$2 ;; + (-u) opt_fd=$2 + ble/array#push opts_in "$@" ;; + (-t) opt_timeout=$2 ;; + (*) ble/array#push opts "$@" ;; + esac +} +function ble/builtin/read/.read-arguments { + local is_normal_args= + vars=() + opts=() + while (($#)); do + local arg=$1; shift + if [[ $is_normal_args || $arg != -* ]]; then + ble/array#push vars "$arg" + elif [[ $arg == -- ]]; then + is_normal_args=1 + elif [[ $arg == --* ]]; then + case $arg in + (--help) + opt_flags=${opt_flags}H ;; + (*) + ble/util/print "read: unrecognized long option '$arg'" >&2 + opt_flags=${opt_flags}E ;; + esac + else + local i n=${#arg} c + for ((i=1;i&2 + opt_flags=${opt_flags}E + fi + break ;; + ([adinNptu]*) ble/builtin/read/.process-option -$c "${arg:i+1}"; break ;; + ([ers]*) ble/builtin/read/.process-option -$c ;; + (*) + ble/util/print "read: unrecognized option '-$c'" >&2 + opt_flags=${opt_flags}E ;; + esac + done + fi + done +} +function ble/builtin/read/.set-up-textarea { + ble/decode/keymap/push read || return 1 + [[ $_ble_edit_read_context == external ]] && + _ble_canvas_panel_height[0]=0 + _ble_textarea_panel=1 + _ble_canvas_panel_focus=1 + ble/textarea#invalidate + ble/edit/info/set-default ansi '' + _ble_edit_PS1=$opt_prompt + _ble_prompt_ps1_data=(0 '' '' 0 0 0 32 0 "" "") + _ble_edit_dirty_observer=() + ble/widget/.newline/clear-content + _ble_edit_arg= + ble-edit/content/reset "$opt_default" newline + _ble_edit_ind=${#opt_default} + ble-edit/undo/clear-all + ble/history/set-prefix _ble_edit_read_ + _ble_syntax_lang=text + _ble_highlight_layer_list=(plain region overwrite_mode disabled) + return 0 +} +function ble/builtin/read/TRAPWINCH { + local IFS=$_ble_term_IFS + ble/application/onwinch +} +function ble/builtin/read/.loop { + set +m # ジョブ管理を無効にする + shopt -u failglob + _ble_edit_async_read_prefix= + local ret; ble/canvas/panel/save-position; local pos0=$ret + ble/builtin/read/.set-up-textarea || return 1 + ble/builtin/trap/install-hook WINCH readline + blehook internal_WINCH=ble/builtin/read/TRAPWINCH + local ret= timeout= + if [[ $opt_timeout ]]; then + ble/util/clock; local start_time=$ret + ((start_time&&(start_time-=_ble_util_clock_reso-1))) + if [[ $opt_timeout == *.* ]]; then + local mantissa=${opt_timeout%%.*} + local fraction=${opt_timeout##*.}000 + ((timeout=mantissa*1000+10#0${fraction::3})) + else + ((timeout=opt_timeout*1000)) + fi + ((timeout<0)) && timeout= + fi + ble/application/render + local _ble_decode_input_count=0 + local ble_decode_char_nest= + local -a _ble_decode_char_buffer=() + local char= + local _ble_edit_read_accept= + local _ble_edit_read_result= + while [[ ! $_ble_edit_read_accept ]]; do + local timeout_option= + if [[ $timeout ]]; then + if ((_ble_bash>=40000)); then + local timeout_frac=000$((timeout%1000)) + timeout_option="-t $((timeout/1000)).${timeout_frac:${#timeout_frac}-3}" + else + timeout_option="-t $((timeout/1000))" + fi + fi + IFS= ble/bash/read -d '' -n 1 $timeout_option char "${opts_in[@]}"; local ext=$? + if ((ext>128)); then + _ble_edit_read_accept=142 + break + fi + if [[ $timeout ]]; then + ble/util/clock; local current_time=$ret + ((timeout-=current_time-start_time)) + if ((timeout<=0)); then + _ble_edit_read_accept=142 + break + fi + start_time=$current_time + fi + ble/util/s2c "$char" + ble-decode-char "$ret" + [[ $_ble_edit_read_accept ]] && break + ble/util/is-stdin-ready && continue + ble-edit/content/check-limit + ble-decode/.hook/erase-progress + ble/application/render + done + if [[ $_ble_edit_read_context == internal ]]; then + local -a DRAW_BUFF=() + ble/canvas/panel#set-height.draw "$_ble_textarea_panel" 0 + ble/canvas/panel/load-position.draw "$pos0" + ble/canvas/bflush.draw + else + if ((_ble_edit_read_accept==1)); then + ble/edit/.relocate-textarea # #D1800 (既に外部状態なのでOK) + else + _ble_edit_line_disabled=1 ble/edit/.relocate-textarea # #D1800 (既に外部状態なのでOK) + fi + fi + ble/util/buffer.flush + ble/term/visible-bell/erase + if ((_ble_edit_read_accept==1)); then + local q=\' Q="'\''" + printf %s "__ble_input='${_ble_edit_read_result//$q/$Q}'" + elif ((_ble_edit_read_accept==142)); then + return "$ext" + else + return 1 + fi +} +function ble/builtin/read/.impl { + local -a opts=() vars=() opts_in=() + local opt_flags= opt_prompt= opt_default= opt_timeout= opt_fd=0 + local rex1='^[0-9]+(\.[0-9]*)?$|^\.[0-9]+$' rex2='^[0.]+$' + [[ $TMOUT =~ $rex1 && ! ( $TMOUT =~ $rex2 ) ]] && opt_timeout=$TMOUT + ble/builtin/read/.read-arguments "$@" + if [[ $opt_flags == *[HE]* ]]; then + if [[ $opt_flags == *H* ]]; then + builtin read --help + elif [[ $opt_flags == *E* ]]; then + builtin read --usage 2>&1 1>/dev/null | ble/bin/grep ^read >&2 + fi + return 2 + fi + if ! [[ $opt_flags == *r* && -t $opt_fd ]]; then + [[ $opt_prompt ]] && ble/array#push opts -p "$opt_prompt" + [[ $opt_timeout ]] && ble/array#push opts -t "$opt_timeout" + __ble_args=("${opts[@]}" "${opts_in[@]}" -- "${vars[@]}") + __ble_command='ble/bash/read "${__ble_args[@]}"' + return 0 + fi + ble/decode/keymap#load read + local result _ble_edit_read_context=$_ble_term_state + ble/util/buffer.flush + [[ $_ble_edit_read_context == external ]] && ble/term/enter # 外側にいたら入る + result=$(ble/builtin/read/.loop); local ext=$? + [[ $_ble_edit_read_context == external ]] && ble/term/leave # 元の状態に戻る + [[ $_ble_edit_read_context == internal ]] && ((_ble_canvas_panel_height[1]=0)) + if ((ext==0)); then + builtin eval -- "$result" + __ble_args=("${opts[@]}" -- "${vars[@]}") + __ble_command='ble/bash/read "${__ble_args[@]}" <<< "$__ble_input"' + fi + return "$ext" +} +function ble/builtin/read { + if [[ $_ble_decode_bind_state == none ]]; then + builtin read "$@" + return "$?" + fi + local _ble_local_set _ble_local_shopt + ble/base/.adjust-bash-options _ble_local_set _ble_local_shopt + [[ $_ble_builtin_read_hook ]] && + builtin eval -- "$_ble_builtin_read_hook" + local __ble_command= __ble_args= __ble_input= + [[ ! $_ble_attached || $_ble_edit_exec_inside_userspace ]] && ble/base/adjust-BASH_REMATCH + ble/builtin/read/.impl "$@"; local __ble_ext=$? + [[ ! $_ble_attached || $_ble_edit_exec_inside_userspace ]] && ble/base/restore-BASH_REMATCH + ble/base/.restore-bash-options _ble_local_set _ble_local_shopt + [[ $__ble_command ]] || return "$__ble_ext" + builtin eval -- "$__ble_command" +} +function read { + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_local_adjust" + ble/builtin/read "$@" + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_local_return" +} +_ble_edit_async_read_prefix= +_ble_edit_async_read_accept_hook= +_ble_edit_async_read_cancel_hook= +_ble_edit_async_read_before_widget= +_ble_edit_async_read_history=() +_ble_edit_async_read_history_edit=() +_ble_edit_async_read_history_dirt=() +_ble_edit_async_read_history_index=0 +function ble/edit/async-read-mode { + local hook=$1 prefix=${2:-_ble_edit_async_read} keymap=${3:-read} + ble/util/assert '[[ ! $_ble_edit_async_read_prefix ]]' 'it is already inside the async-read mode.' || return 1 + _ble_edit_async_read_prefix=$prefix + ble/util/set "${prefix}_accept_hook" "$hook" + ble/util/set "${prefix}_cancel_hook" '' + ble/textarea#render + ble/textarea#save-state "$prefix" + ble/util/save-vars "$prefix" _ble_canvas_panel_focus + ble/util/set "${prefix}_history_prefix" "$_ble_history_prefix" + ble/decode/keymap/push "$keymap" + ble/edit/info/default text '' + _ble_textarea_panel=1 + _ble_canvas_panel_focus=1 + ble/textarea#invalidate + _ble_edit_PS1=$PS2 + _ble_prompt_ps1_data=(0 '' '' 0 0 0 32 0 '' '') + _ble_edit_dirty_observer=() + ble/widget/.newline/clear-content + _ble_edit_arg= + ble-edit/undo/clear-all + ble/history/set-prefix "$prefix" + _ble_syntax_lang=text + _ble_highlight_layer_list=(plain region overwrite_mode) + return 147 +} +function ble/edit/async-read-mode/accept { + local prefix=$_ble_edit_async_read_prefix + ble/util/assert '[[ $prefix ]]' 'it is not inside the async-read mode.' || return 1 + ret=$_ble_edit_str + [[ $ret ]] && ble/history/add "$ret" # Note: cancel でも登録する + local -a DRAW_BUFF=() + ble/canvas/panel#set-height.draw "$_ble_textarea_panel" 0 + ble/canvas/bflush.draw + ble/textarea#restore-state "$prefix" + ble/textarea#clear-state "$prefix" + ble/util/restore-vars "$prefix" _ble_canvas_panel_focus + [[ $_ble_edit_overwrite_mode ]] && ble/util/buffer "$_ble_term_civis" + local old_history_prefix_ref=${prefix}_history_prefix + ble/history/set-prefix "${!old_history_prefix_ref}" + ble/decode/keymap/pop + _ble_edit_async_read_prefix= +} +_ble_edit_async_read_is_cancel_key[63|_ble_decode_Ctrl]=1 # C-? +_ble_edit_async_read_is_cancel_key[127]=1 # DEL +_ble_edit_async_read_is_cancel_key[104|_ble_decode_Ctrl]=1 # C-h +_ble_edit_async_read_is_cancel_key[8]=1 # BS +function ble/edit/async-read-mode/empty-cancel.hook { + if [[ ! $_ble_edit_str ]] && ((_ble_edit_async_read_is_cancel_key[KEYS[0]])); then + ble/widget/read/cancel + ble/decode/widget/suppress-widget + fi +} +function ble/widget/command-help/.read-man { + local -x _ble_local_tmpfile; ble/util/assign/mktmp + local pager="sh -c 'cat >| \"\$_ble_local_tmpfile\"'" + MANPAGER=$pager PAGER=$pager MANOPT= man "$@" 2>/dev/null; local ext=$? # 668ms + ble/util/readfile man_content "$_ble_local_tmpfile" # 80ms + ble/util/assign/rmtmp + return "$ext" +} +function ble/widget/command-help/.locate-in-man-bash { + local command=$1 + local ret rex + local rex_esc=$'(\e\\[[ -?]*[@-~]||.\b)' cr=$'\r' + local pager; ble/util/get-pager pager + local pager_cmd=${pager%%["$_ble_term_IFS"]*} + [[ ${pager_cmd##*/} == less ]] || return 1 + local awk=ble/bin/awk; ble/bin#has gawk && awk=gawk + local man_content; ble/widget/command-help/.read-man bash || return 1 # 733ms (3 fork: man, sh, cat) + local cmd_awk + case $command in + ('function') cmd_awk='name () compound-command' ;; + ('until') cmd_awk=while ;; + ('command') cmd_awk='command [' ;; + ('source') cmd_awk=. ;; + ('typeset') cmd_awk=declare ;; + ('readarray') cmd_awk=mapfile ;; + ('[') cmd_awk=test ;; + (*) cmd_awk=$command ;; + esac + ble/string#escape-for-awk-regex "$cmd_awk"; local rex_awk=$ret + rex='\b$'; [[ $awk == gawk && $cmd_awk =~ $rex ]] && rex_awk=$rex_awk'\y' + local awk_script='{ + gsub(/'"$rex_esc"'/, ""); + if (!par && $0 ~ /^['"$_ble_term_space"']*'"$rex_awk"'/) { print NR; exit; } + par = !($0 ~ /^['"$_ble_term_space"']*$/); + }' + local awk_out; ble/util/assign awk_out '"$awk" "$awk_script" 2>/dev/null <<< "$man_content"' || return 1 # 206ms (1 fork) + local iline=${awk_out%$'\n'}; [[ $iline ]] || return 1 + ble/string#escape-for-extended-regex "$command"; local rex_ext=$ret + rex='\b$'; [[ $command =~ $rex ]] && rex_ext=$rex_ext'\b' + rex='^\b'; [[ $command =~ $rex ]] && rex_ext="($rex_esc|\b)$rex_ext" + local manpager="$pager -r +'/$rex_ext$cr$((iline-1))g'" + builtin eval -- "$manpager" <<< "$man_content" # 1 fork +} +function ble/widget/command-help/.show-bash-script { + local _ble_local_pipeline=$1 + local -x LESS="${LESS:+$LESS }-r" # Note: Bash のバグで tempenv builtin eval は消滅するので #D1438 + ble/bin#has source-highlight && + _ble_local_pipeline='source-highlight -s sh -f esc | '$_ble_local_pipeline + builtin eval -- "$_ble_local_pipeline" +} +function ble/widget/command-help/.locate-function-in-source { + local func=$1 source lineno line + ble/function#get-source-and-lineno "$func" || return 1 + [[ -f $source && -s $source ]] || return 1 # pipe 等は読み取らない + local pager; ble/util/get-pager pager + local pager_cmd=${pager%%["$_ble_term_IFS"]*} + [[ ${pager_cmd##*/} == less ]] || return 1 + ble/util/assign line 'ble/bin/sed -n "${lineno}{p;q;}" "$source"' + [[ $line == *"$func"* ]] || return 1 + ble/widget/command-help/.show-bash-script '"$pager" +"${lineno}g"' < "$source" +} +function ble/widget/command-help.core { + ble/function#try ble/cmdinfo/help:"$command" && return 0 + ble/function#try ble/cmdinfo/help "$command" && return 0 + if [[ $type == builtin || $type == keyword ]]; then + ble/widget/command-help/.locate-in-man-bash "$command" && return 0 + elif [[ $type == function ]]; then + ble/widget/command-help/.locate-function-in-source "$command" && return 0 + local def; ble/function#getdef "$command" + ble/widget/command-help/.show-bash-script ble/util/pager <<< "$def" && return 0 + fi + if ble/is-function ble/bin/man; then + MANOPT= ble/bin/man "${command##*/}" 2>/dev/null && return 0 + fi + if local content; content=$("$command" --help 2>&1) && [[ $content ]]; then + ble/util/print "$content" | ble/util/pager + return 0 + fi + ble/util/print "ble: help of \`$command' not found" >&2 + return 1 +} +function ble/widget/command-help/.type/.resolve-alias { + local literal=$1 command=$2 type=alias + local last_literal=$1 last_command=$2 + while + [[ $command == "$literal" ]] || break # Note: type=alias + local alias_def + ble/util/assign alias_def "alias $command" + builtin unalias "$command" + builtin eval "alias_def=${alias_def#*=}" # remove quote + literal=${alias_def%%["$_ble_term_IFS"]*} command= type= + local ret; ble/syntax:bash/simple-word/safe-eval "$literal" nonull || break # Note: type= + command=$ret + ble/util/type type "$command" + [[ $type ]] || break # Note: type= + last_literal=$literal + last_command=$command + [[ $type == alias ]] + do :; done + if [[ ! $type || $type == alias ]]; then + literal=$last_literal + command=$last_command + builtin unalias "$command" &>/dev/null + ble/util/type type "$command" + fi + local q="'" Q="'\''" + printf "type='%s'\n" "${type//$q/$Q}" + printf "literal='%s'\n" "${literal//$q/$Q}" + printf "command='%s'\n" "${command//$q/$Q}" + return 0 +} 2>/dev/null +function ble/widget/command-help/.type { + local literal=$1 + type= command= + local ret; ble/syntax:bash/simple-word/safe-eval "$literal" nonull || return 1; command=$ret + ble/util/type type "$command" + if [[ $type == alias ]]; then + builtin eval -- "$(ble/widget/command-help/.type/.resolve-alias "$literal" "$command")" + fi + if [[ $type == keyword && $command != "$literal" ]]; then + if [[ $command == %* ]] && jobs -- "$command" &>/dev/null; then + type=jobs + else + type=${type[1]} + [[ $type ]] || return 1 + fi + fi +} +function ble/widget/command-help.impl { + local literal=$1 + if [[ ! $literal ]]; then + ble/widget/.bell + return 1 + fi + local type command; ble/widget/command-help/.type "$literal" + if [[ ! $type ]]; then + ble/widget/.bell "command \`$command' not found" + return 1 + fi + ble/widget/external-command ble/widget/command-help.core +} +function ble/widget/command-help { + ble-edit/content/clear-arg + local comp_cword comp_words comp_line comp_point + if ble/syntax:bash/extract-command "$_ble_edit_ind"; then + local cmd=${comp_words[0]} + else + local args; ble/string#split-words args "$_ble_edit_str" + local cmd=${args[0]} + fi + ble/widget/command-help.impl "$cmd" +} +function ble-edit/bind/stdout.on { :;} +function ble-edit/bind/stdout.off { ble/util/buffer.flush;} +function ble-edit/bind/stdout.finalize { :;} +if [[ $bleopt_internal_suppress_bash_output ]]; then + _ble_edit_io_fname2=$_ble_base_run/$$.stderr + function ble-edit/bind/stdout.on { + exec 2>&"$_ble_util_fd_tui_stderr" + } + function ble-edit/bind/stdout.off { + ble/util/buffer.flush + ble-edit/io/check-stderr + exec 2>>"$_ble_edit_io_fname2" + } + function ble-edit/bind/stdout.finalize { + ble-edit/bind/stdout.on + [[ -f $_ble_edit_io_fname2 ]] && >| "$_ble_edit_io_fname2" + } + function ble-edit/io/check-stderr { + local file=${1:-$_ble_edit_io_fname2} + if ble/is-function ble/term/visible-bell; then + if [[ -f $file && -s $file ]]; then + local message= line + while IFS= ble/bash/read line || [[ $line ]]; do + if [[ $line == 'bash: '* || $line == "${BASH##*/}: "* || $line == "ble.sh ("*"): "* ]]; then + message="$message${message:+; }$line" + fi + done < "$file" + [[ $message ]] && ble/term/visible-bell "$message" + >| "$file" + fi + fi + } + if ((_ble_bash<40000)); then + function ble-edit/io/TRAPUSR1 { + [[ $_ble_term_state == internal ]] || return 1 + local FUNCNEST= + local IFS=$_ble_term_IFS + local file=$_ble_edit_io_fname2.proc + if [[ -s $file ]]; then + local content cmd + ble/util/readfile content "$file" + >| "$file" + for cmd in $content; do + case $cmd in + (eof) + _ble_decode_hook 4 + builtin eval -- "$_ble_decode_bind_hook" ;; + esac + done + fi + ble/builtin/trap/invoke USR1 + } + blehook/declare internal_USR1 + blehook internal_USR1!=ble-edit/io/TRAPUSR1 + ble/builtin/trap/install-hook USR1 + function ble-edit/io/check-ignoreeof-message { + local line=$1 + [[ ( $bleopt_internal_ignoreeof_trap && $line == *$bleopt_internal_ignoreeof_trap* ) || + $line == *'Use "exit" to leave the shell.'* || + $line == *'ログアウトする為には exit を入力して下さい'* || + $line == *'シェルから脱出するには "exit" を使用してください。'* || + $line == *'シェルから脱出するのに "exit" を使いなさい.'* || + $line == *'Gebruik Kaart na Los Tronk'* ]] && return 0 + [[ $line == *exit* ]] && ble/bin/grep -q -F "$line" "$_ble_base"/lib/core-edit.ignoreeof-messages.txt + } + function ble-edit/io/check-ignoreeof-loop { + local line opts=:$1: + while IFS= ble/bash/read line; do + if [[ $line == *[^$_ble_term_IFS]* ]]; then + ble/util/print "$line" >> "$_ble_edit_io_fname2" + fi + if ble-edit/io/check-ignoreeof-message "$line"; then + ble/util/print eof >> "$_ble_edit_io_fname2.proc" + kill -USR1 $$ + ble/util/msleep 100 # 連続で送ると bash が落ちるかも (落ちた事はないが念の為) + fi + done + } &>/dev/null + ble/bin/rm -f "$_ble_edit_io_fname2.pipe" + if ble/bin/mkfifo "$_ble_edit_io_fname2.pipe" 2>/dev/null; then + { + ble-edit/io/check-ignoreeof-loop fifo < "$_ble_edit_io_fname2.pipe" & disown + } &>/dev/null + ble/fd#alloc _ble_edit_io_fd2 '> "$_ble_edit_io_fname2.pipe"' + function ble-edit/bind/stdout.off { + ble/util/buffer.flush + ble-edit/io/check-stderr + exec 2>&"$_ble_edit_io_fd2" + } + elif . "$_ble_base/lib/init-msys1.sh"; ble-edit/io:msys1/start-background; then + function ble-edit/bind/stdout.off { + ble/util/buffer.flush + ble-edit/io/check-stderr + exec 2>/dev/null + exec 2>>"$_ble_edit_io_fname2.buff" + } + fi + fi +fi +[[ ${_ble_edit_detach_flag-} != reload ]] && + _ble_edit_detach_flag= +function ble-edit/bind/.exit-TRAPRTMAX { + local FUNCNEST= + ble/base/unload + builtin exit 0 +} +function ble-edit/bind/.check-detach { + if [[ ! -o emacs && ! -o vi ]]; then + local ret + ble/edit/marker#instantiate 'unsupported' error:non-empty + ble/util/print "$ret Sorry, ble.sh is supported only with some editing mode (set -o emacs/vi)." >&2 + ble-detach + fi + [[ $_ble_edit_detach_flag == prompt-attach ]] && return 1 + if [[ $_ble_edit_detach_flag || ! $_ble_attached ]]; then + type=$_ble_edit_detach_flag + _ble_edit_detach_flag= + local attached=$_ble_attached + [[ $attached ]] && ble-detach/impl + if [[ $type == exit ]]; then + local ret + ble/edit/marker#instantiate-config exec_exit_mark && + ble-detach/message "$ret" + builtin trap 'ble-edit/bind/.exit-TRAPRTMAX' RTMAX + kill -RTMAX $$ + else + local ret + ble/edit/marker#instantiate 'detached' non-empty + ble-detach/message \ + ${ret+"$ret"} \ + "Please run \`stty sane' to recover the correct TTY state." + if ((_ble_bash>=40000)); then + READLINE_LINE=' stty sane;' READLINE_POINT=11 READLINE_MARK=0 + printf %s "$READLINE_LINE" + fi + fi + if [[ $attached ]]; then + ble/base/restore-BASH_REMATCH + ble/base/restore-bash-options + ble/base/restore-builtin-wrappers + ble/base/restore-POSIXLY_CORRECT + builtin eval -- "$_ble_bash_FUNCNEST_restore" # これ以降関数は呼び出せない + else + ble-edit/exec:"$bleopt_internal_exec_type"/.prologue + _ble_edit_exec_inside_prologue= + fi + return 0 + else + local state=$_ble_decode_bind_state + if [[ ( $state == emacs || $state == vi ) && ! -o $state ]]; then + ble/decode/reset-default-keymap + ble/decode/detach + if ! ble/decode/attach; then + ble-detach + ble-edit/bind/.check-detach # 改めて終了処理 + return "$?" + fi + fi + return 1 + fi +} +if ((_ble_bash>=40100)); then + function ble-edit/bind/.head/adjust-bash-rendering { + ble/textarea#redraw-cache + ble/util/buffer.flush + } +else + function ble-edit/bind/.head/adjust-bash-rendering { + ((_ble_canvas_y++,_ble_canvas_x=0)) + local -a DRAW_BUFF=() + ble/canvas/panel#goto.draw "$_ble_textarea_panel" "${_ble_textarea_cur[0]}" "${_ble_textarea_cur[1]}" + ble/canvas/flush.draw + } +fi +function ble-edit/bind/.head { + ble-edit/bind/stdout.on + ble/base/recover-bash-options + [[ $bleopt_internal_suppress_bash_output ]] || + ble-edit/bind/.head/adjust-bash-rendering +} +function ble-edit/bind/.tail-without-draw { + ble-edit/bind/stdout.off +} +if ((_ble_bash>=40000)); then + function ble-edit/bind/.tail { + ble/application/render + ble/util/idle.do + ble/textarea#adjust-for-bash-bind # bash-4.0+ + ble-edit/bind/stdout.off + } +else + function ble-edit/bind/.tail { + ble/application/render + ble/util/idle.do + ble-edit/bind/stdout.off + } +fi +function ble-decode/PROLOGUE { + ble-edit/exec:gexec/restore-state + ble-edit/bind/.head + ble/decode/readline/adjust-uvw + ble/term/enter +} +function ble-decode/EPILOGUE { + if ((_ble_bash>=40000)); then + if ble/decode/has-input && ! ble-edit/exec/has-pending-commands; then + ble-edit/bind/.tail-without-draw + return 0 + fi + fi + ble-edit/content/check-limit + ble-edit/exec:"$bleopt_internal_exec_type"/process && return 0 + ble-edit/bind/.tail + return 0 +} +function ble/widget/.internal-print-command { + local _ble_local_command=$1 _ble_command_opts=$2 + _ble_edit_line_disabled=1 ble/edit/.relocate-textarea # #D1800 pair=leave-command-layout + [[ :$_ble_command_opts: != *:pre-flush:* ]] || ble/util/buffer.flush + BASH_COMMAND=$_ble_local_command builtin eval -- "$_ble_local_command" + ble/edit/leave-command-layout # #D1800 pair=ble/edit/.relocate-textarea + [[ :$_ble_command_opts: != *:post-flush:* ]] || ble/util/buffer.flush +} +function ble/widget/print { + ble-edit/content/clear-arg + local message="$*" lines + [[ ${message//["$_ble_term_IFS"]} ]] || return 1 + lines=("$@") + if [[ ! ${_ble_attached-} || ${_ble_edit_exec_inside_begin-} ]]; then + ble/util/print-lines "${lines[@]}" + else + ble/widget/.internal-print-command ' + ble/util/buffer.print-lines "${lines[@]}" + ble/util/buffer.flush' pre-flush + fi +} +function ble/widget/internal-command { + ble-edit/content/clear-arg + local command=$1 + [[ ${command//[$_ble_term_IFS]} ]] || return 1 + ble/widget/.internal-print-command "$command" +} +function ble/widget/external-command { + ble-edit/content/clear-arg + local _ble_local_command=$1 + [[ ${_ble_local_command//[$_ble_term_IFS]} ]] || return 1 + ble/edit/enter-command-layout # #D1800 pair=leave-command-layout + ble/textarea#invalidate + local -a DRAW_BUFF=() + ble/canvas/panel#set-height.draw "$_ble_textarea_panel" 0 + ble/canvas/panel#goto.draw "$_ble_textarea_panel" 0 0 sgr0 + ble/canvas/bflush.draw + ble/term/leave + ble/util/buffer.flush + BASH_COMMAND=$_ble_local_command builtin eval -- "$_ble_local_command"; local ext=$? + ble/term/enter + ble/edit/leave-command-layout # #D1800 pair=enter-command-layout + return "$ext" +} +function ble/widget/execute-command { + ble-edit/content/clear-arg + local command=$1 + if [[ $command != *[!"$_ble_term_IFS"]* ]]; then + _ble_edit_line_disabled=1 ble/edit/.relocate-textarea keep-info + return 1 + fi + _ble_edit_line_disabled=1 ble/edit/.relocate-textarea # #D1800 pair=exec/register + ble-edit/exec/register "$command" +} +function ble/widget/.SHELL_COMMAND { ble/widget/execute-command "$@"; } +function ble/widget/.EDIT_COMMAND { + local command=$1 + local -x READLINE_LINE=$_ble_edit_str + local -x READLINE_POINT=$_ble_edit_ind + local -x READLINE_MARK=$_ble_edit_mark + [[ $_ble_edit_arg ]] && + local -x READLINE_ARGUMENT=$_ble_edit_arg + ble/edit/enter-command-layout # #D1800 pair=leave-command-layout + ble/widget/.hide-current-line keep-header + ble-edit/restore-PS1 + ble/term/leave-for-widget + builtin eval -- "$command"; local ext=$? + ble/term/enter-for-widget + ble-edit/adjust-PS1 + ble-edit/content/clear-arg + ble/edit/leave-command-layout # #D1800 pair=enter-command-layout + [[ $READLINE_LINE != "$_ble_edit_str" ]] && + ble-edit/content/reset-and-check-dirty "$READLINE_LINE" + ((_ble_edit_ind=READLINE_POINT)) + ((_ble_edit_mark=READLINE_MARK)) + local N=${#_ble_edit_str} + ((_ble_edit_ind<0?_ble_edit_ind=0:(_ble_edit_ind>N&&(_ble_edit_ind=N)))) + ((_ble_edit_mark<0?_ble_edit_mark=0:(_ble_edit_mark>N&&(_ble_edit_mark=N)))) + return "$ext" +} +function ble-decode/INITIALIZE_DEFMAP { + local ret + bleopt/get:default_keymap; local defmap=$ret + if ble-edit/bind/load-editing-mode "$defmap"; then + local base_keymap=$defmap + [[ $defmap == vi ]] && base_keymap=vi_imap + builtin eval -- "$2=\$base_keymap" + ble/decode/is-keymap "$base_keymap" && return 0 + fi + ble/edit/marker#instantiate "The definition of the default keymap \"$defmap\" is not found. ble.sh uses \"safe\" keymap instead." error + local msg=$ret + ble/edit/enter-command-layout # #D1800 pair=leave-command-layout + ble/widget/.hide-current-line + local -a DRAW_BUFF=() + ble/canvas/put.draw "$_ble_term_cr$_ble_term_el$msg$_ble_term_nl" + ble/canvas/bflush.draw + ble/util/buffer.flush + ble/edit/leave-command-layout # #D1800 pair=enter-command-layout + ble-edit/bind/load-editing-mode safe && + ble/decode/keymap#load safe && + builtin eval -- "$2=safe" && + bleopt_default_keymap=safe +} +function ble-edit/bind/load-editing-mode { + local name=$1 + if ble/is-function ble-edit/bind/load-editing-mode:"$name"; then + ble-edit/bind/load-editing-mode:"$name" + else + ble/util/import "$_ble_base/lib/keymap.$name.sh" + fi +} +function ble-edit/bind/clear-keymap-definition-loader { + builtin unset -f ble-edit/bind/load-editing-mode:safe + builtin unset -f ble-edit/bind/load-editing-mode:emacs + builtin unset -f ble-edit/bind/load-editing-mode:vi +} +function ble-edit/initialize { + ble/prompt/initialize +} +function ble-edit/attach { + _ble_builtin_trap_DEBUG__initialize + [[ $_ble_builtin_trap_DEBUG_userTrapInitialized ]] && + _ble_edit_exec_gexec__TRAPDEBUG_adjust + ble-edit/attach/.attach + _ble_canvas_x=0 _ble_canvas_y=0 + ble/util/buffer "$_ble_term_cr" +} +function ble-edit/detach { + ble-edit/bind/stdout.finalize + ble-edit/attach/.detach + ble-edit/exec:gexec/.TRAPDEBUG/restore +} +ble/function#trace ble-edit/attach +function ble/util/message/handler:edit/append-line { + local data=${1%$'\n'}; data=${data#$'\n'} + [[ ${_ble_edit_str##*$'\n'} ]] && data=$'\n'$data + local len=${#_ble_edit_str} + ble-edit/content/replace-limited "$len" "$len" "$data" nobell + _ble_edit_ind=${#_ble_edit_str} + return 0 +} +function ble-append-line { + local data="${*-}" + [[ $data ]] || return 0 + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_local_adjust" + ble/util/message.post "$$" precmd edit/append-line "$data" + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_local_return" +} +function ble/cmdspec/initialize { ble-import "$_ble_base/lib/core-cmdspec.sh"; } +ble/is-function ble/util/idle.push && ble-import -d "$_ble_base/lib/core-cmdspec.sh" +builtin eval -- "${_ble_util_gdict_declare//NAME/_ble_cmdspec_opts}" +function ble/cmdspec/opts { + local spec=$1 command; shift + for command; do + local spec1=$spec + if [[ $spec1 == +* ]]; then + local ret= + ble/gdict#get _ble_cmdspec_opts "$command" "$spec1" + spec1=${ret:+$ret:}${spec1:1} + fi + ble/gdict#set _ble_cmdspec_opts "$command" "$spec1" + done +} +function ble/cmdspec/opts#load { + cmdspec_opts=$2 + local ret= + if ble/gdict#get _ble_cmdspec_opts "$1" || + { [[ $1 == */*[!/] ]] && ble/gdict#get _ble_cmdspec_opts "${1##*/}"; } + then + cmdspec_opts=$ret + fi +} +_ble_syntax_VARNAMES=( + _ble_syntax_text + _ble_syntax_lang + _ble_syntax_stat + _ble_syntax_nest + _ble_syntax_tree + _ble_syntax_attr + _ble_syntax_attr_umin + _ble_syntax_attr_umax + _ble_syntax_word_umin + _ble_syntax_word_umax + _ble_syntax_vanishing_word_umin + _ble_syntax_vanishing_word_umax + _ble_syntax_dbeg + _ble_syntax_dend) +_ble_syntax_lang=bash +function ble/syntax/initialize-vars { + _ble_syntax_text= + _ble_syntax_lang=bash + _ble_syntax_stat=() + _ble_syntax_nest=() + _ble_syntax_tree=() + _ble_syntax_attr=() + _ble_syntax_attr_umin=-1 _ble_syntax_attr_umax=-1 + _ble_syntax_word_umin=-1 _ble_syntax_word_umax=-1 + _ble_syntax_vanishing_word_umin=-1 + _ble_syntax_vanishing_word_umax=-1 + _ble_syntax_dbeg=-1 _ble_syntax_dend=-1 +} +function ble/highlight/layer:syntax/update { true; } +function ble/highlight/layer:syntax/getg { true; } +function ble/syntax:bash/is-complete { true; } +ble/util/autoload "$_ble_base/lib/core-syntax.sh" \ + ble/syntax/parse \ + ble/syntax/highlight \ + ble/syntax/tree-enumerate \ + ble/syntax/tree-enumerate-children \ + ble/syntax/completion-context/generate \ + ble/syntax/highlight/cmdtype \ + ble/syntax/highlight/cmdtype1 \ + ble/syntax/highlight/filetype \ + ble/syntax/highlight/getg-from-filename \ + ble/syntax:bash/extract-command \ + ble/syntax:bash/simple-word/eval \ + ble/syntax:bash/simple-word/evaluate-path-spec \ + ble/syntax:bash/simple-word/is-never-word \ + ble/syntax:bash/simple-word/is-simple \ + ble/syntax:bash/simple-word/is-simple-or-open-simple \ + ble/syntax:bash/simple-word/reconstruct-incomplete-word \ + ble/syntax:bash/simple-word/get-rex_element +bleopt/declare -v syntax_debug '' +bleopt/declare -v filename_ls_colors '' +bleopt/declare -v highlight_syntax 1 +bleopt/declare -v highlight_filename 1 +bleopt/declare -v highlight_variable 1 +bleopt/declare -v highlight_timeout_sync 50 +bleopt/declare -v highlight_timeout_async 5000 +bleopt/declare -v syntax_eval_polling_interval 50 +builtin eval -- "${_ble_util_gdict_declare//NAME/_ble_syntax_highlight_filetype}" +builtin eval -- "${_ble_util_gdict_declare//NAME/_ble_syntax_highlight_lscolors_ext}" +builtin eval -- "${_ble_util_gdict_declare//NAME/_ble_syntax_highlight_lscolors_suffix}" +builtin eval -- "${_ble_util_gdict_declare//NAME/_ble_syntax_bash_simple_eval}" +builtin eval -- "${_ble_util_gdict_declare//NAME/_ble_syntax_bash_simple_eval_full}" +function ble/syntax/attr2g { ble/color/initialize-faces && ble/syntax/attr2g "$@"; } +function ble/syntax/defface.onload { + function ble/syntax/attr2g { + local iface=${_ble_syntax_attr2iface[$1]:-_ble_faces__syntax_default} + g=${_ble_faces[iface]} + } + ble/color/defface syntax_default none + ble/color/defface syntax_command fg=brown + ble/color/defface syntax_quoted fg=green + ble/color/defface syntax_quotation fg=green,bold + ble/color/defface syntax_escape fg=magenta + ble/color/defface syntax_expr fg=26 + ble/color/defface syntax_error bg=203,fg=231 # bg=224 + ble/color/defface syntax_varname fg=202 + ble/color/defface syntax_delimiter bold + ble/color/defface syntax_param_expansion fg=purple + ble/color/defface syntax_history_expansion bg=94,fg=231 + ble/color/defface syntax_function_name fg=92,bold # fg=purple + ble/color/defface syntax_comment fg=242 + ble/color/defface syntax_glob fg=198,bold + ble/color/defface syntax_brace fg=37,bold + ble/color/defface syntax_tilde fg=navy,bold + ble/color/defface syntax_document fg=94 + ble/color/defface syntax_document_begin fg=94,bold + ble/color/defface command_builtin_dot fg=red,bold + ble/color/defface command_builtin fg=red + ble/color/defface command_alias fg=teal + ble/color/defface command_function fg=92 # fg=purple + ble/color/defface command_file fg=green + ble/color/defface command_keyword fg=blue + ble/color/defface command_jobs fg=red,bold + ble/color/defface command_directory fg=26,underline + ble/color/defface command_suffix fg=white,bg=green + ble/color/defface command_suffix_new fg=white,bg=brown + ble/color/defface filename_directory underline,fg=26 + ble/color/defface filename_directory_sticky underline,fg=white,bg=26 + ble/color/defface filename_link underline,fg=teal + ble/color/defface filename_orphan underline,fg=teal,bg=224 + ble/color/defface filename_setuid underline,fg=black,bg=220 + ble/color/defface filename_setgid underline,fg=black,bg=191 + ble/color/defface filename_executable underline,fg=green + ble/color/defface filename_other underline + ble/color/defface filename_socket underline,fg=cyan,bg=black + ble/color/defface filename_pipe underline,fg=lime,bg=black + ble/color/defface filename_character underline,fg=white,bg=black + ble/color/defface filename_block underline,fg=yellow,bg=black + ble/color/defface filename_warning underline,fg=red + ble/color/defface filename_url underline,fg=blue + ble/color/defface filename_ls_colors underline + ble/color/defface varname_unset fg=124 + ble/color/defface varname_empty fg=31 + ble/color/defface varname_number fg=64 + ble/color/defface varname_expr fg=92,bold + ble/color/defface varname_array fg=orange,bold + ble/color/defface varname_hash fg=70,bold + ble/color/defface varname_readonly fg=200 + ble/color/defface varname_transform fg=29,bold + ble/color/defface varname_export fg=200,bold + ble/color/defface argument_option fg=teal + ble/color/defface argument_error fg=black,bg=225 +} +blehook/eval-after-load color_defface ble/syntax/defface.onload +function ble/syntax/import { + ble/util/import "$_ble_base/lib/core-syntax.sh" +} +ble-import -d lib/core-syntax +ble/is-function ble/util/idle.push && ble-import -d "$_ble_base/lib/core-complete.sh" +ble/util/autoload "$_ble_base/lib/core-complete.sh" \ + ble/widget/complete \ + ble/widget/menu-complete \ + ble/widget/auto-complete-enter \ + ble/widget/sabbrev-expand \ + ble/widget/dabbrev-expand +function ble-sabbrev { + local arg print= + for arg; do + if [[ $arg != -* && $arg != *=* ]]; then + print=1 + break + fi + done + if (($#==0)) || [[ $print ]]; then + ble-import lib/core-complete && ble-sabbrev "$@" + return "$?" + fi + local ret; ble/string#quote-command "$FUNCNAME" "$@" + blehook/eval-after-load complete "$ret" +} +if ! declare -p _ble_complete_sabbrev &>/dev/null; then # reload #D0875 + _ble_complete_sabbrev_version=0 + builtin eval -- "${_ble_util_gdict_declare//NAME/_ble_complete_sabbrev}" +fi +bleopt/declare -n complete_polling_cycle 50 +bleopt/declare -o complete_stdin_frequency complete_polling_cycle +bleopt/declare -v complete_limit '' +bleopt/declare -v complete_limit_auto 2000 +bleopt/declare -v complete_limit_auto_menu 100 +bleopt/declare -v complete_timeout_auto 5000 +bleopt/declare -v complete_timeout_compvar 200 +bleopt/declare -v complete_ambiguous 1 +bleopt/declare -v complete_contract_function_names 1 +bleopt/declare -v complete_auto_complete 1 +bleopt/declare -v complete_auto_complete_opts '' +bleopt/declare -v complete_auto_history 1 +bleopt/declare -n complete_auto_delay 1 +bleopt/declare -v complete_auto_wordbreaks "$_ble_term_IFS" +bleopt/declare -v complete_auto_menu '' +bleopt/declare -v complete_allow_reduction '' +bleopt/declare -v complete_requote_threshold 0 +bleopt/declare -n complete_menu_style align-nowrap +function bleopt/check:complete_menu_style { + [[ $value == desc-raw ]] && value=desc + if ! ble/is-function "ble/complete/menu-style:$value/construct-page"; then + ble/util/print-lines \ + "bleopt: Invalid value complete_menu_style='$value'." \ + " A function 'ble/complete/menu-style:$value/construct-page' is not defined." >&2 + return 1 + fi + return 0 +} +ble/util/autoload "$_ble_base/lib/core-complete.sh" \ + ble/complete/menu-style:{align,dense}{,-nowrap}/construct-page \ + ble/complete/menu-style:linewise/construct-page \ + ble/complete/menu-style:desc{,-text,-raw}/construct-page +bleopt/declare -v complete_menu_complete 1 +bleopt/declare -v complete_menu_complete_opts 'insert-selection' +bleopt/declare -v complete_menu_filter 1 +bleopt/declare -v complete_menu_maxlines '-1' +function bleopt/check:complete_menu_complete_opts { + if [[ :$value: == *:hidden:* && :$value: != *:insert-selection:* ]]; then + value=$value:insert-selection + fi + return 0 +} +bleopt/declare -v complete_skip_matched on +bleopt/declare -v complete_menu_color on +bleopt/declare -v complete_menu_color_match on +function ble/complete/.init-bind-readline-variables { + local _ble_local_rlvars; ble/util/rlvar#load + ble/util/rlvar#bind-bleopt skip-completed-text complete_skip_matched bool + ble/util/rlvar#bind-bleopt colored-stats complete_menu_color bool + ble/util/rlvar#bind-bleopt colored-completion-prefix complete_menu_color_match bool + builtin unset -f "$FUNCNAME" +} +ble/complete/.init-bind-readline-variables +bleopt/declare -v menu_prefix '' +bleopt/declare -v menu_align_prefix '' +bleopt/declare -n menu_align_min 4 +bleopt/declare -n menu_align_max 20 +bleopt/declare -o complete_menu_align menu_align_max +bleopt/declare -v menu_dense_prefix '' +bleopt/declare -v menu_linewise_prefix '' +bleopt/declare -v menu_desc_prefix '' +bleopt/declare -v menu_desc_multicolumn_width 65 +ble/util/autoload "$_ble_base/lib/core-complete.sh" \ + ble/complete/menu#start \ + ble-decode/keymap:menu/define \ + ble-decode/keymap:auto_complete/define \ + ble-decode/keymap:menu_complete/define \ + ble-decode/keymap:dabbrev/define \ + ble/complete/sabbrev/expand \ + ble/complete/expand:alias \ + ble/complete/expand:autocd +bleopt/declare -v complete_source_sabbrev_opts '' +bleopt/declare -v complete_source_sabbrev_ignore '' +_ble_complete_source_sabbrev_ignore=() +function bleopt/check:complete_source_sabbrev_ignore { + if [[ $value ]]; then + ble/string#split _ble_complete_source_sabbrev_ignore : "$value" + else + _ble_complete_source_sabbrev_ignore=() + fi +} +ble/color/defface auto_complete bg=254,fg=238 +ble/color/defface cmdinfo_cd_cdpath fg=26,bg=155 +ble/color/defface menu_filter_fixed bold +ble/color/defface menu_filter_input fg=16,bg=229 +ble/color/defface menu_desc_default none +ble/color/defface menu_desc_type ref:syntax_delimiter +ble/color/defface menu_desc_quote ref:syntax_quoted +ble/util/autoload "$_ble_base/lib/core-debug.sh" \ + ble/debug/setdbg \ + ble/debug/print \ + ble/debug/print-variables \ + ble/debug/stopwatch/start \ + ble/debug/stopwatch/stop \ + ble/debug/profiler/start \ + ble/debug/profiler/stop +bleopt/declare -v debug_profiler_opts line:func +bleopt/declare -n debug_profiler_tree_threshold 5.0 +function ble/contrib/integration:bash-preexec/loader { + if [[ ${bash_preexec_imported-${__bp_imported}} ]]; then + blehook ATTACH-=ble/contrib/integration:bash-preexec/loader + blehook POSTEXEC-=ble/contrib/integration:bash-preexec/loader + if ble/util/import/is-loaded contrib/bash-preexec; then + ble/contrib/integration:bash-preexec/attach.hook + else + ble-import contrib/integration/bash-preexec + fi + fi +} +if [[ ${bash_preexec_imported-${__bp_imported}} ]]; then + ble-import contrib/integration/bash-preexec +else + blehook ATTACH!=ble/contrib/integration:bash-preexec/loader + blehook POSTEXEC!=ble/contrib/integration:bash-preexec/loader +fi +ble/function#try ble/util/idle.push ble/base/clean-up-runtime-directory +bleopt -I +ble/bin#freeze-utility-path ble +function ble/dispatch/.help { + ble/util/print-lines \ + 'usage: ble [SUBCOMMAND [ARGS...]]' \ + '' \ + 'SUBCOMMAND' \ + ' # Manage ble.sh' \ + ' attach ... alias of ble-attach' \ + ' detach ... alias of ble-detach' \ + ' update ... alias of ble-update' \ + ' reload ... alias of ble-reload' \ + ' help ... Show this help' \ + ' version ... Show version' \ + ' check ... Run unit tests' \ + '' \ + ' # Configuration' \ + ' opt ... alias of bleopt' \ + ' bind ... alias of ble-bind' \ + ' face ... alias of ble-face' \ + ' hook ... alias of blehook' \ + ' sabbrev ... alias of ble-sabbrev' \ + ' palette ... alias of ble-color-show' \ + '' +} +function ble/dispatch { + if (($#==0)); then + [[ $_ble_attached && ! $_ble_edit_exec_inside_userspace ]] + return "$?" + fi + local cmd=$1; shift + case $cmd in + (attach) ble-attach "$@" ;; + (detach) ble-detach "$@" ;; + (update) ble-update "$@" ;; + (reload) ble-reload "$@" ;; + (face) ble-face "$@" ;; + (bind) ble-bind "$@" ;; + (opt) bleopt "$@" ;; + (hook) blehook "$@" ;; + (sabbrev) ble-sabbrev "$@" ;; + (palette) ble-palette "$@" ;; + (help|--help) ble/dispatch/.help "$@" ;; + (version|--version) ble/util/print "ble.sh, version $BLE_VERSION (noarch)" ;; + (check|--test) ble/base/sub:test "$@" ;; + (*) + if ble/string#match "$cmd" '^[-a-zA-Z0-9]+$' && ble/is-function "ble-$cmd"; then + "ble-$cmd" "$@" + elif ble/is-function ble/bin/ble; then + ble/bin/ble "$cmd" "$@" + else + ble/util/print "ble (ble.sh): unrecognized subcommand '$cmd'." >&2 + return 2 + fi + esac +} +function ble { + case ${1-} in + (attach|detach|update|reload) + "ble-$@" ;; + (*) + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_local_adjust" + ble/dispatch "$@" + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_local_return" ;; + esac +} +_ble_base_rcfile= +_ble_base_rcfile_initialized= +function ble/base/load-rcfile { + [[ $_ble_base_rcfile_initialized ]] && return 0 + _ble_base_rcfile_initialized=1 + if [[ ! $_ble_base_rcfile ]]; then + { _ble_base_rcfile=$HOME/.blerc; [[ -f $_ble_base_rcfile ]]; } || + { _ble_base_rcfile=${XDG_CONFIG_HOME:-$HOME/.config}/blesh/init.sh; [[ -f $_ble_base_rcfile ]]; } || + _ble_base_rcfile=$HOME/.blerc + fi + if [[ -s $_ble_base_rcfile ]]; then + source "$_ble_base_rcfile" + blehook/.compatibility-ble-0.3/check + fi +} +function ble-attach { + if (($# >= 2)); then + builtin printf '%s\n' \ + 'usage: ble-attach [opts]' \ + 'Attach to ble.sh.' >&2 + [[ $1 != --help ]] && return 2 + return 0 + fi + if [[ $_ble_edit_detach_flag ]]; then + case $_ble_edit_detach_flag in + (exit) return 0 ;; + (*) _ble_edit_detach_flag= ;; # cancel "detach" + esac + fi + [[ ! $_ble_attached ]] || return 0 + _ble_attached=1 + BLE_ATTACHED=1 + builtin eval -- "$_ble_bash_FUNCNEST_adjust" + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_adjust" + ble/base/adjust-builtin-wrappers + ble/base/adjust-bash-options + ble/base/adjust-BASH_REMATCH + if [[ ${IN_NIX_SHELL-} ]]; then + if [[ "${BASH_SOURCE[*]}" == */rc && $1 != *:force:* ]]; then + ble/base/install-prompt-attach + _ble_attached= + BLE_ATTACHED= + ble/base/restore-BASH_REMATCH + ble/base/restore-bash-options + ble/base/restore-builtin-wrappers + ble/base/restore-POSIXLY_CORRECT + builtin eval -- "$_ble_bash_FUNCNEST_restore" + return 0 + fi + local ret + ble/util/readlink "/proc/$$/exe" + [[ -x $ret ]] && BASH=$ret + fi + ble/fd/save-external-standard-streams + exec 0<&"$_ble_util_fd_tui_stdin" + exec 1>&"$_ble_util_fd_tui_stdout" + exec 2>&"$_ble_util_fd_tui_stderr" + ble/term/initialize # 0.4ms + ble/term/attach noflush # 2.5ms (起動時のずれ防止の為 stty -echo は早期に) + ble/canvas/attach # 1.8ms (requests for char_width_mode=auto) + ble/util/buffer.flush # 0.3ms + ble-edit/initialize # 0.3ms + ble-edit/attach # 2.1ms (_ble_edit_PS1 他の初期化) + ble_attach_first_prompt=1 \ + ble/canvas/panel/render # 42ms + ble/util/buffer.flush # 0.2ms + local IFS=$_ble_term_IFS + ble/decode/initialize # 7ms + ble/decode/reset-default-keymap # 264ms (keymap/vi.sh) + if ! ble/decode/attach; then # 53ms + _ble_attached= + BLE_ATTACHED= + ble-edit/detach + ble/term/leave + ble/base/restore-BASH_REMATCH + ble/base/restore-bash-options + ble/base/restore-builtin-wrappers + ble/base/restore-POSIXLY_CORRECT + builtin eval -- "$_ble_bash_FUNCNEST_restore" + return 1 + fi + ble/history:bash/reset # 27s for bash-3.0 + ble-edit/restore-PS1 + blehook/invoke ATTACH + ble-edit/adjust-PS1 + ble/textarea#redraw + ble/edit/info/default + ble-edit/bind/.tail +} +function ble-detach { + if (($#)); then + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_local_adjust" + ble/base/print-usage-for-no-argument-command 'Detach from ble.sh.' "$@" + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_local_leave" + return 2 + fi + [[ $_ble_attached && ! $_ble_edit_detach_flag ]] || return 1 + _ble_edit_detach_flag=${1:-detach} # schedule detach +} +function ble-detach/impl { + [[ $_ble_attached ]] || return 1 + _ble_attached= + BLE_ATTACHED= + blehook/invoke DETACH + ble-edit/detach + ble/decode/detach + READLINE_LINE='' READLINE_POINT=0 +} +function ble-detach/message { + ble/util/buffer.print-lines "$@" + ble/util/buffer.flush + ble/edit/info/clear + ble/textarea#render + ble/util/buffer.flush +} +function ble/base/unload-for-reload { + if [[ $_ble_attached ]]; then + ble-detach/impl + local ret + ble/edit/marker#instantiate 'reload' && + ble/util/print "$ret" >&"$_ble_util_fd_tui_stderr" + [[ $_ble_edit_detach_flag ]] || + _ble_edit_detach_flag=reload + fi + local _ble_bash=$_ble_bash + ble/base/unload reload + return 0 +} +function ble/base/unload { + ble/util/is-running-in-subshell && return 1 + local IFS=$_ble_term_IFS + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_adjust" + ble/base/adjust-builtin-wrappers + ble/base/adjust-bash-options + ble/base/adjust-BASH_REMATCH + ble-edit/bind/clear-keymap-definition-loader + ble/widget/.bell/.clear-DECSCNM + ble/decode/keymap#unload + ble/term/stty/TRAPEXIT "$1" + ble/term/leave + ble/util/buffer.flush + blehook/invoke unload + ble/builtin/trap/finalize "$1" + ble/util/import/finalize + ble/base/clean-up-runtime-directory finalize + ble/fd#finalize # this is used by the above function + ble/base/clear-version-variables + return 0 +} 0<&"$_ble_util_fd_tui_stdin" 1>&"$_ble_util_fd_tui_stdout" 2>&"$_ble_util_fd_tui_stderr" +_ble_base_attach_from_prompt= +((${#_ble_base_attach_PROMPT_COMMAND[@]})) || + _ble_base_attach_PROMPT_COMMAND=() +function ble/base/install-prompt-attach { + [[ ! $_ble_base_attach_from_prompt ]] || return 0 + _ble_base_attach_from_prompt=1 + if ((_ble_bash>=50100)); then + ((${#PROMPT_COMMAND[@]})) || PROMPT_COMMAND[0]= + ble/array#push PROMPT_COMMAND ble/base/attach-from-PROMPT_COMMAND + if [[ $_ble_edit_detach_flag == reload ]]; then + _ble_edit_detach_flag=prompt-attach + blehook internal_PRECMD!=ble/base/attach-from-PROMPT_COMMAND + fi + else + local save_index=${#_ble_base_attach_PROMPT_COMMAND[@]} + _ble_base_attach_PROMPT_COMMAND[save_index]=${PROMPT_COMMAND-} + ble/function#lambda PROMPT_COMMAND \ + "ble/base/attach-from-PROMPT_COMMAND $save_index \"\$FUNCNAME\"" + ble/function#trace "$PROMPT_COMMAND" + if [[ $_ble_edit_detach_flag == reload ]]; then + _ble_edit_detach_flag=prompt-attach + blehook internal_PRECMD!="$PROMPT_COMMAND" + fi + fi +} +_ble_base_attach_from_prompt_lastexit= +_ble_base_attach_from_prompt_lastarg= +_ble_base_attach_from_prompt_PIPESTATUS=() +function ble/base/attach-from-PROMPT_COMMAND { + { + _ble_base_attach_from_prompt_lastexit=$? \ + _ble_base_attach_from_prompt_lastarg=$_ \ + _ble_base_attach_from_prompt_PIPESTATUS=("${PIPESTATUS[@]}") + if ((BASH_LINENO[${#BASH_LINENO[@]}-1]>=1)); then + _ble_edit_exec_lastexit=$_ble_base_attach_from_prompt_lastexit + _ble_edit_exec_lastarg=$_ble_base_attach_from_prompt_lastarg + _ble_edit_exec_PIPESTATUS=("${_ble_base_attach_from_prompt_PIPESTATUS[@]}") + _ble_edit_exec_BASH_COMMAND=$FUNCNAME + fi + local is_last_PROMPT_COMMAND=1 + if (($#==0)); then + if local ret; ble/array#index PROMPT_COMMAND ble/base/attach-from-PROMPT_COMMAND; then + local keys; keys=("${!PROMPT_COMMAND[@]}") + ((ret==keys[${#keys[@]}-1])) || is_last_PROMPT_COMMAND= + ble/idict#replace PROMPT_COMMAND ble/base/attach-from-PROMPT_COMMAND + fi + blehook internal_PRECMD-=ble/base/attach-from-PROMPT_COMMAND || ((1)) # set -e 対策 + else + local save_index=$1 lambda=$2 + local PROMPT_COMMAND=${_ble_base_attach_PROMPT_COMMAND[save_index]} + local ble_base_attach_from_prompt_command=processing + ble/prompt/update/.eval-prompt_command 2>&"$_ble_util_fd_tui_stderr" + ble/util/unlocal ble_base_attach_from_prompt_command + _ble_base_attach_PROMPT_COMMAND[save_index]=$PROMPT_COMMAND + ble/util/unlocal PROMPT_COMMAND + blehook internal_PRECMD-="$lambda" || ((1)) # set -e 対策 + if [[ $PROMPT_COMMAND == "$lambda" ]]; then + PROMPT_COMMAND=${_ble_base_attach_PROMPT_COMMAND[save_index]} + else + is_last_PROMPT_COMMAND= + fi + [[ ${ble_base_attach_from_prompt_command-} != processing ]] || return 0 + fi + [[ $_ble_base_attach_from_prompt ]] || return 0 + _ble_base_attach_from_prompt= + if [[ $is_last_PROMPT_COMMAND ]]; then + ble-edit/exec:gexec/invoke-hook-with-setexit internal_PRECMD + ble-edit/exec:gexec/invoke-hook-with-setexit PRECMD + _ble_prompt_hash=$COLUMNS:$_ble_edit_lineno:prompt_attach + fi + } 2>/dev/null # set -x 対策 #D0930 + ble-attach force + ble/util/joblist.flush &>/dev/null + ble/util/joblist.check +} +function ble/base/process-blesh-arguments { + local opts=$_ble_base_arguments_opts + local attach=$_ble_base_arguments_attach + local inputrc=$_ble_base_arguments_inputrc + _ble_base_rcfile=$_ble_base_arguments_rcfile + _ble_decode_initialize_inputrc=$inputrc + ble/base/load-rcfile # blerc + ble/util/invoke-hook BLE_ONLOAD + case $attach in + (attach) ble-attach ;; + (prompt) ble/base/install-prompt-attach ;; + (none) ;; + (*) ble/util/print "ble.sh: unrecognized attach method --attach='$attach'." ;; + esac +} +function ble/base/sub:test { + local error= logfile= + [[ ${LANG-} ]] || local LANG=en_US.UTF-8 + ble-import lib/core-test + if (($#==0)); then + set -- bash main util canvas decode edit syntax complete keymap.vi + logfile=$_ble_base_cache/test.$(date +'%Y%m%d.%H%M%S').log + >| "$logfile" + ble/test/log#open "$logfile" + fi + if ((!_ble_make_command_check_count)); then + ble/test/log "MACHTYPE: $MACHTYPE" + ble/test/log "BLE_VERSION: $BLE_VERSION" + fi + ble/test/log "BASH_VERSION: $BASH_VERSION" + local line='locale:' var ret + for var in LANG "${!LC_@}"; do + ble/string#quote-word "${!var}" + line="$line $var=$ret" + done + ble/test/log "$line" + local _ble_test_section_failure_count=0 + local section + for section; do + local file=$_ble_base/lib/test-$section.sh + if [[ -f $file ]]; then + source "$file" + else + ble/test/log "ERROR: Test '$section' is not defined." + error=1 + fi + done + ((_ble_test_section_failure_count)) && error=1 + if [[ $logfile ]]; then + ble/test/log#close + ble/util/print "ble.sh: The test log was saved to '${_ble_term_setaf[4]}$logfile$_ble_term_sgr0'." + fi + [[ ! $error ]] +} +function ble/base/sub:update { ble-update; } +function ble/base/sub:clear-cache { + (shopt -u failglob; ble/bin/rm -rf "$_ble_base_cache"/*) +} +function ble/base/sub:install { + local insdir=${1:-${XDG_DATA_HOME:-$HOME/.local/share}}/blesh + local dir=$insdir sudo= + [[ $dir == /* ]] || dir=./$dir + while [[ $dir && ! -d $dir ]]; do + dir=${dir%/*} + done + [[ $dir ]] || dir=/ + if ! [[ -r $dir && -w $dir && -x $dir ]]; then + if ((EUID!=0)) && [[ ! -O $dir ]] && ble/bin#has sudo; then + sudo=1 + else + ble/util/print "ble.sh --install: $dir: permission denied" >&2 + return 1 + fi + fi + if [[ ${_ble_base_repository-} == release:nightly-* ]]; then + if [[ $insdir == "$_ble_base" ]]; then + ble/util/print "ble.sh --install: already installed" >&2 + return 1 + fi + local ret + ble/string#quote-word "$insdir"; local qinsdir=$ret + ble/string#quote-word "$_ble_base"; local qbase=$ret + if [[ $sudo ]]; then + ble/util/print "\$ sudo mkdir -p $qinsdir" + sudo mkdir -p "$insdir" + ble/util/print "\$ sudo cp -Rf $qbase/* $qinsdir/" + sudo cp -Rf "$_ble_base"/* "$insdir/" + ble/util/print "\$ sudo rm -rf $qinsdir/{cache.d,run}" + sudo rm -rf "$insdir"/{cache.d,run} + else + ble/util/print "\$ mkdir -p $qinsdir" + ble/bin/mkdir -p "$insdir" + ble/util/print "\$ cp -Rf $qbase/* $qinsdir/" + ble/bin/cp -Rf "$_ble_base"/* "$insdir/" + ble/util/print "\$ rm -rf $qinsdir/cache.d/*" + ble/bin/rm -rf "$insdir/cache.d"/* + fi + elif local make; ble-update/.check-build-dependencies && ble-update/.check-repository; then + ( ble/util/print "cd into $_ble_base_repository..." >&2 && + builtin cd "$_ble_base_repository" && + ble-update/.make ${sudo:+--sudo} install INSDIR="$insdir" ) + else + ble/util/print "ble.sh --install: not supported." >&2 + return 1 + fi +} +function ble/base/sub:lib { return 0; } # do nothing +ble/function#trace ble-attach +ble/function#trace ble +ble/function#trace ble/dispatch +ble/function#trace ble/base/attach-from-PROMPT_COMMAND +ble/function#trace ble/base/unload +ble-import -f lib/_package +if [[ $_ble_init_command ]]; then + ble/base/sub:"${_ble_init_command[@]}"; _ble_init_exit=$? + [[ $_ble_init_attached ]] && ble-attach + ble/util/setexit "$_ble_init_exit" +else + ble/base/process-blesh-arguments "$@" +fi +ble/init/clean-up check-attach 2>/dev/null # set -x 対策 #D0930 +{ builtin eval "return $? || exit $?"; } 2>/dev/null # set -x 対策 #D0930 diff --git a/.local/share/blesh/contrib/airline/alduin.bash b/.local/share/blesh/contrib/airline/alduin.bash new file mode 100644 index 0000000..d6b52c6 --- /dev/null +++ b/.local/share/blesh/contrib/airline/alduin.bash @@ -0,0 +1,29 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/alduin.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Author: Danilo Augusto +# Script: Alduin (vim-airline version) +# License: MIT + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:alduin/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=222,bg=60 # fg=#ffdf87,bg=#5f5f87 + ble-face -s vim_airline_a_inactive fg=241,bg=138 # fg=#666666,bg=#af8787 + ble-face -s vim_airline_a_insert fg=231,bg=105 # fg=#ffffff,bg=#878787 + ble-face -s vim_airline_a_replace fg=101,bg=234 # fg=#87875f,bg=#1c1c1c + ble-face -s vim_airline_a_visual fg=231,bg=101 # fg=#ffffff,bg=#87875f + ble-face -s vim_airline_b fg=231,bg=138 # fg=#ffffff,bg=#af8787 + ble-face -s vim_airline_b_inactive fg=180,bg=235 # fg=#dfaf87,bg=#2a2a2a + ble-face -s vim_airline_c fg=180,bg=240 # fg=#dfaf87,bg=#545454 + ble-face -s vim_airline_c_inactive fg=180,bg=235 # fg=#dfaf87,bg=#2a2a2a + ble-face -s vim_airline_c_inactive_modified fg=222,bg=0 # fg=#ffdf87,bg=0 + ble-face -s vim_airline_c_insert fg=231,bg=138 # fg=#ffffff,bg=#af8787 + ble-face -s vim_airline_c_insert_modified fg=222,bg=0 # fg=#ffdf87,bg=0 + ble-face -s vim_airline_c_normal_modified fg=222,bg=0 # fg=#ffdf87,bg=0 + ble-face -s vim_airline_c_replace_modified fg=222,bg=0 # fg=#ffdf87,bg=0 + ble-face -s vim_airline_c_visual fg=231,bg=138 # fg=#ffffff,bg=#af8787 + ble-face -s vim_airline_c_visual_modified fg=222,bg=0 # fg=#ffdf87,bg=0 +} diff --git a/.local/share/blesh/contrib/airline/angr.bash b/.local/share/blesh/contrib/airline/angr.bash new file mode 100644 index 0000000..a742e1a --- /dev/null +++ b/.local/share/blesh/contrib/airline/angr.bash @@ -0,0 +1,31 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/angr.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Color palette + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:angr/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=236,bg=24 # fg=#303030,bg=#005f87 + ble-face -s vim_airline_a_inactive fg=249,bg=238 # fg=#b2b2b2,bg=#444444 + ble-face -s vim_airline_a_insert fg=238,bg=110 # fg=#444444,bg=#87afd7 + ble-face -s vim_airline_a_replace fg=236,bg=174 # fg=#303030,bg=#d78787 + ble-face -s vim_airline_a_visual fg=236,bg=182 # fg=#303030,bg=#d7afd7 + ble-face -s vim_airline_b fg=249,bg=237 # fg=#b2b2b2,bg=#3a3a3a + ble-face -s vim_airline_b_inactive fg=249,bg=238 # fg=#b2b2b2,bg=#444444 + ble-face -s vim_airline_c fg=249,bg=238 # fg=#b2b2b2,bg=#444444 + ble-face -s vim_airline_c_inactive_modified fg=216,bg=0 # fg=#ffaf87,bg=0 + ble-face -s vim_airline_c_insert fg=110,bg=238 # fg=#87afd7,bg=#444444 + ble-face -s vim_airline_c_insert_modified fg=216,bg=238 # fg=#ffaf87,bg=#444444 + ble-face -s vim_airline_c_normal_modified fg=216,bg=238 # fg=#ffaf87,bg=#444444 + ble-face -s vim_airline_c_replace fg=174,bg=238 # fg=#d78787,bg=#444444 + ble-face -s vim_airline_c_replace_modified fg=216,bg=238 # fg=#ffaf87,bg=#444444 + ble-face -s vim_airline_c_visual fg=182,bg=238 # fg=#d7afd7,bg=#444444 + ble-face -s vim_airline_c_visual_modified fg=216,bg=238 # fg=#ffaf87,bg=#444444 + ble-face -s vim_airline_error fg=231,bg=196 # fg=#ffffff,bg=#ff0000 + ble-face -s vim_airline_error_inactive fg=16,bg=88 # fg=#000000,bg=#990000 + ble-face -s vim_airline_warning fg=231,bg=196 # fg=#ffffff,bg=#ff0000 + ble-face -s vim_airline_warning_inactive fg=16,bg=166 # fg=#000000,bg=#df5f00 +} diff --git a/.local/share/blesh/contrib/airline/apprentice.bash b/.local/share/blesh/contrib/airline/apprentice.bash new file mode 100644 index 0000000..22e8ce2 --- /dev/null +++ b/.local/share/blesh/contrib/airline/apprentice.bash @@ -0,0 +1,34 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/apprentice.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# vim-airline theme for Apprentice +# +# Author: pt307 (based on work by romainl) +# License: MIT License + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:apprentice/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=235,bg=101 # fg=#262626,bg=#87875f + ble-face -s vim_airline_a_inactive fg=235,bg=240 # fg=#262626,bg=#585858 + ble-face -s vim_airline_a_insert fg=235,bg=65 # fg=#262626,bg=#5f875f + ble-face -s vim_airline_a_replace fg=235,bg=131 # fg=#262626,bg=#af5f5f + ble-face -s vim_airline_a_visual fg=235,bg=229 # fg=#262626,bg=#ffffaf + ble-face -s vim_airline_b fg=235,bg=240 # fg=#262626,bg=#585858 + ble-face -s vim_airline_b_inactive fg=240,bg=235 # fg=#585858,bg=#262626 + ble-face -s vim_airline_c fg=250,bg=235 # fg=#bcbcbc,bg=#262626 + ble-face -s vim_airline_c_inactive fg=240,bg=235 # fg=#585858,bg=#262626 + ble-face -s vim_airline_c_inactive_modified fg=208,bg=0 # fg=#ff8700,bg=0 + ble-face -s vim_airline_c_insert_modified fg=208,bg=0 # fg=#ff8700,bg=0 + ble-face -s vim_airline_c_normal_modified fg=208,bg=0 # fg=#ff8700,bg=0 + ble-face -s vim_airline_c_replace_modified fg=208,bg=0 # fg=#ff8700,bg=0 + ble-face -s vim_airline_c_visual_modified fg=208,bg=0 # fg=#ff8700,bg=0 + ble-face -s vim_airline_error fg=235,bg=131 # fg=#262626,bg=#af5f5f + ble-face -s vim_airline_error_inactive fg=16,bg=88 # fg=#000000,bg=#990000 + ble-face -s vim_airline_error_inactive_modified fg=235,bg=131 # fg=#262626,bg=#af5f5f + ble-face -s vim_airline_warning fg=235,bg=208 # fg=#262626,bg=#ff8700 + ble-face -s vim_airline_warning_inactive fg=16,bg=166 # fg=#000000,bg=#df5f00 + ble-face -s vim_airline_warning_inactive_modified fg=235,bg=208 # fg=#262626,bg=#ff8700 +} diff --git a/.local/share/blesh/contrib/airline/atomic.bash b/.local/share/blesh/contrib/airline/atomic.bash new file mode 100644 index 0000000..2a05808 --- /dev/null +++ b/.local/share/blesh/contrib/airline/atomic.bash @@ -0,0 +1,42 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/atomic.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +#---------------------------------------------------------------- +# ___ __ _ +# / | / /_____ ____ ___ (_)____ +# / /| |/ __/ __ \/ __ `__ \/ / ___/ +# / ___ / /_/ /_/ / / / / / / / /__ +# /_/ |_\__/\____/_/ /_/ /_/_/\___/ +# +#---------------------------------------------------------------- +# Theme : Atomic +# Version : 2.1.0 +# License : MIT +# Author : Gerard Bajona +# URL : https://github.com/gerardbm/atomic +# ---------------------------------------------------------------- +# Colors will be adapted to the current colorscheme. For better +# contrast use the atomic colorscheme: it has ten color palettes +# with sixteen colors selected procedurally (algorithms). +# +# Atomic colorscheme: https://github.com/gerardbm/vim-atomic +# ---------------------------------------------------------------- + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:atomic/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=-1,bg=-1 # fg=-1,bg=-1 + ble-face -s vim_airline_a_inactive fg=124,bg=-1 # fg=#a52a2a,bg=-1 + ble-face -s vim_airline_a_insert fg=-1,bg=29 # fg=-1,bg=#2e8b57 + ble-face -s vim_airline_a_replace fg=-1,bg=231 # fg=-1,bg=#ffffff + ble-face -s vim_airline_a_visual fg=-1,bg=196 # fg=-1,bg=#ff0000 + ble-face -s vim_airline_b fg=-1,bg=124 # fg=-1,bg=#a52a2a + ble-face -s vim_airline_b_inactive fg=124,bg=-1 # fg=#a52a2a,bg=-1 + ble-face -s vim_airline_c fg=-1,bg=-1 # fg=-1,bg=-1 + ble-face -s vim_airline_c_inactive fg=124,bg=-1 # fg=#a52a2a,bg=-1 + ble-face -s vim_airline_c_insert fg=29,bg=-1 # fg=#2e8b57,bg=-1 + ble-face -s vim_airline_c_replace fg=231,bg=-1 # fg=#ffffff,bg=-1 + ble-face -s vim_airline_c_visual fg=196,bg=-1 # fg=#ff0000,bg=-1 +} diff --git a/.local/share/blesh/contrib/airline/ayu_dark.bash b/.local/share/blesh/contrib/airline/ayu_dark.bash new file mode 100644 index 0000000..8e60b28 --- /dev/null +++ b/.local/share/blesh/contrib/airline/ayu_dark.bash @@ -0,0 +1,25 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/ayu_dark.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Normal mode +# (Dark) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:ayu_dark/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=238,bg=149 # fg=#3d424d,bg=#c2d94c + ble-face -s vim_airline_a_inactive fg=149,bg=233 # fg=#c2d94c,bg=#0a0e14 + ble-face -s vim_airline_a_insert fg=238,bg=74 # fg=#3d424d,bg=#39bae6 + ble-face -s vim_airline_a_replace fg=238,bg=203 # fg=#3d424d,bg=#ff3333 + ble-face -s vim_airline_a_visual fg=238,bg=209 # fg=#3d424d,bg=#ff8f40 + ble-face -s vim_airline_b fg=149,bg=238 # fg=#c2d94c,bg=#304357 + ble-face -s vim_airline_b_inactive fg=149,bg=233 # fg=#c2d94c,bg=#0a0e14 + ble-face -s vim_airline_b_insert fg=74,bg=238 # fg=#39bae6,bg=#304357 + ble-face -s vim_airline_b_replace fg=149,bg=238 # fg=#c2d94c,bg=#304357 + ble-face -s vim_airline_b_visual fg=209,bg=238 # fg=#ff8f40,bg=#304357 + ble-face -s vim_airline_c fg=149,bg=233 # fg=#b3b1ad,bg=#0a0e14 + ble-face -s vim_airline_c_inactive fg=149,bg=233 # fg=#c2d94c,bg=#0a0e14 + ble-face -s vim_airline_z_replace fg=238,bg=149 # fg=#3d424d,bg=#c2d94c +} diff --git a/.local/share/blesh/contrib/airline/ayu_light.bash b/.local/share/blesh/contrib/airline/ayu_light.bash new file mode 100644 index 0000000..af5f3e3 --- /dev/null +++ b/.local/share/blesh/contrib/airline/ayu_light.bash @@ -0,0 +1,25 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/ayu_light.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Normal mode +# (Dark) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:ayu_light/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=66,bg=106 # fg=#6c7680,bg=#86b300 + ble-face -s vim_airline_a_inactive fg=106,bg=231 # fg=#86b300,bg=#fafafa + ble-face -s vim_airline_a_insert fg=66,bg=74 # fg=#6c7680,bg=#55b4d4 + ble-face -s vim_airline_a_replace fg=66,bg=196 # fg=#6c7680,bg=#f51818 + ble-face -s vim_airline_a_visual fg=66,bg=209 # fg=#6c7680,bg=#fa8d3e + ble-face -s vim_airline_b fg=106,bg=66 # fg=#86b300,bg=#6c7680 + ble-face -s vim_airline_b_inactive fg=106,bg=231 # fg=#86b300,bg=#fafafa + ble-face -s vim_airline_b_insert fg=74,bg=66 # fg=#55b4d4,bg=#6c7680 + ble-face -s vim_airline_b_replace fg=106,bg=66 # fg=#86b300,bg=#6c7680 + ble-face -s vim_airline_b_visual fg=209,bg=66 # fg=#fa8d3e,bg=#6c7680 + ble-face -s vim_airline_c fg=66,bg=231 # fg=#6c7680,bg=#fafafa + ble-face -s vim_airline_c_inactive fg=106,bg=231 # fg=#86b300,bg=#fafafa + ble-face -s vim_airline_z_replace fg=66,bg=106 # fg=#6c7680,bg=#86b300 +} diff --git a/.local/share/blesh/contrib/airline/ayu_mirage.bash b/.local/share/blesh/contrib/airline/ayu_mirage.bash new file mode 100644 index 0000000..4c83199 --- /dev/null +++ b/.local/share/blesh/contrib/airline/ayu_mirage.bash @@ -0,0 +1,24 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/ayu_mirage.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Normal mode +# (Dark) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:ayu_mirage/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=17,bg=150 # fg=#212733,bg=#bbe67e + ble-face -s vim_airline_a_inactive fg=150,bg=17 # fg=#bbe67e,bg=#212733 + ble-face -s vim_airline_a_insert fg=17,bg=117 # fg=#212733,bg=#80d4ff + ble-face -s vim_airline_a_replace fg=17,bg=204 # fg=#212733,bg=#f07178 + ble-face -s vim_airline_a_visual fg=17,bg=215 # fg=#212733,bg=#ffae57 + ble-face -s vim_airline_b fg=150,bg=17 # fg=#bbe67e,bg=#212733 + ble-face -s vim_airline_b_insert fg=117,bg=17 # fg=#80d4ff,bg=#212733 + ble-face -s vim_airline_b_replace fg=150,bg=17 # fg=#bbe67e,bg=#212733 + ble-face -s vim_airline_b_visual fg=215,bg=17 # fg=#ffae57,bg=#212733 + ble-face -s vim_airline_c fg=253,bg=17 # fg=#e6e1cf,bg=#212733 + ble-face -s vim_airline_c_inactive fg=150,bg=17 # fg=#bbe67e,bg=#212733 + ble-face -s vim_airline_z_replace fg=17,bg=150 # fg=#212733,bg=#bbe67e +} diff --git a/.local/share/blesh/contrib/airline/badwolf.bash b/.local/share/blesh/contrib/airline/badwolf.bash new file mode 100644 index 0000000..5b9e6f6 --- /dev/null +++ b/.local/share/blesh/contrib/airline/badwolf.bash @@ -0,0 +1,32 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/badwolf.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:badwolf/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=233,bg=154 # fg=#141413,bg=#aeee00 + ble-face -s vim_airline_a_inactive fg=235,bg=238 # fg=#242321,bg=#45413b + ble-face -s vim_airline_a_insert fg=233,bg=39 # fg=#141413,bg=#0a9dff + ble-face -s vim_airline_a_replace fg=233,bg=217 # fg=#141413,bg=#ff9eb8 + ble-face -s vim_airline_a_visual fg=233,bg=214 # fg=#141413,bg=#ffa724 + ble-face -s vim_airline_b fg=222,bg=238 # fg=#f4cf86,bg=#45413b + ble-face -s vim_airline_b_inactive fg=235,bg=238 # fg=#242321,bg=#45413b + ble-face -s vim_airline_b_insert fg=222,bg=27 # fg=#f4cf86,bg=#005fff + ble-face -s vim_airline_b_normal_modified fg=222,bg=241 # fg=#f4cf86,bg=#666462 + ble-face -s vim_airline_b_visual fg=16,bg=221 # fg=#000000,bg=#fade3e + ble-face -s vim_airline_c fg=121,bg=235 # fg=#8cffba,bg=#242321 + ble-face -s vim_airline_c_inactive fg=235,bg=238 # fg=#242321,bg=#45413b + ble-face -s vim_airline_c_inactive_modified fg=214,bg=0 # fg=#ffa724,bg=0 + ble-face -s vim_airline_c_insert fg=39,bg=235 # fg=#0a9dff,bg=#242321 + ble-face -s vim_airline_c_insert_modified fg=214,bg=238 # fg=#ffa724,bg=#45413b + ble-face -s vim_airline_c_normal_modified fg=214,bg=238 # fg=#ffa724,bg=#45413b + ble-face -s vim_airline_c_replace_modified fg=214,bg=238 # fg=#ffa724,bg=#45413b + ble-face -s vim_airline_c_visual fg=16,bg=137 # fg=#000000,bg=#b88853 + ble-face -s vim_airline_c_visual_modified fg=16,bg=173 # fg=#000000,bg=#c7915b + ble-face -s vim_airline_term_normal_modified fg=121,bg=235 # fg=#8cffba,bg=#242321 + ble-face -s vim_airline_term_visual_modified fg=16,bg=221 # fg=#000000,bg=#fade3e + ble-face -s vim_airline_z_replace fg=233,bg=39 # fg=#141413,bg=#0a9dff +} diff --git a/.local/share/blesh/contrib/airline/base16.bash b/.local/share/blesh/contrib/airline/base16.bash new file mode 100644 index 0000000..1aa28da --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=196,bg=-1 # fg=#ff0000,bg=-1 + ble-face -s vim_airline_a_inactive fg=-1,bg=-1 # fg=-1,bg=-1 + ble-face -s vim_airline_a_replace fg=196,bg=196 # fg=#ff0000,bg=#ff0000 + ble-face -s vim_airline_a_visual fg=196,bg=201 # fg=#ff0000,bg=#ff00ff + ble-face -s vim_airline_b fg=-1,bg=252 # fg=-1,bg=#d3d3d3 + ble-face -s vim_airline_b_inactive fg=-1,bg=-1 # fg=-1,bg=-1 + ble-face -s vim_airline_c fg=-1,bg=254 # fg=-1,bg=#e5e5e5 + ble-face -s vim_airline_c_inactive fg=-1,bg=-1 # fg=-1,bg=-1 + ble-face -s vim_airline_c_insert_modified fg=124,bg=0 # fg=#a52a2a,bg=0 + ble-face -s vim_airline_c_normal_modified fg=124,bg=0 # fg=#a52a2a,bg=0 + ble-face -s vim_airline_c_replace_modified fg=124,bg=0 # fg=#a52a2a,bg=0 + ble-face -s vim_airline_c_visual_modified fg=124,bg=0 # fg=#a52a2a,bg=0 + ble-face -s vim_airline_error fg=196,bg=231 # fg=#ff0000,bg=#ffffff + ble-face -s vim_airline_error_inactive fg=16,bg=88 # fg=#000000,bg=#990000 + ble-face -s vim_airline_warning fg=-1,bg=196 # fg=-1,bg=#ff0000 + ble-face -s vim_airline_warning_inactive fg=16,bg=166 # fg=#000000,bg=#df5f00 +} diff --git a/.local/share/blesh/contrib/airline/base16_3024.bash b/.local/share/blesh/contrib/airline/base16_3024.bash new file mode 100644 index 0000000..2d8bb3f --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_3024.bash @@ -0,0 +1,21 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_3024.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# vim-airline template by chartoin (http://github.com/chartoin) +# Base 16 3024 Scheme by Jan T. Sott (http://github.com/idleberg) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_3024/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=237,bg=35 # fg=#3a3432,bg=#01a252 + ble-face -s vim_airline_a_inactive fg=248,bg=237 # fg=#a5a2a2,bg=#3a3432 + ble-face -s vim_airline_a_insert fg=237,bg=38 # fg=#3a3432,bg=#01a0e4 + ble-face -s vim_airline_a_replace fg=237,bg=160 # fg=#3a3432,bg=#db2d20 + ble-face -s vim_airline_a_visual fg=237,bg=132 # fg=#3a3432,bg=#a16a94 + ble-face -s vim_airline_b fg=189,bg=238 # fg=#d6d5d4,bg=#4a4543 + ble-face -s vim_airline_b_inactive fg=248,bg=237 # fg=#a5a2a2,bg=#3a3432 + ble-face -s vim_airline_c fg=182,bg=237 # fg=#e8bbd0,bg=#3a3432 + ble-face -s vim_airline_c_inactive fg=248,bg=237 # fg=#a5a2a2,bg=#3a3432 +} diff --git a/.local/share/blesh/contrib/airline/base16_adwaita.bash b/.local/share/blesh/contrib/airline/base16_adwaita.bash new file mode 100644 index 0000000..52068da --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_adwaita.bash @@ -0,0 +1,21 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_adwaita.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# vim-airline template by chartoin (http://github.com/chartoin) +# Base 16 Adwaita Scheme by Rory Bradford (https://github.com/roryrjb) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_adwaita/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=237,bg=84 # fg=#33393b,bg=#6fee91 + ble-face -s vim_airline_a_inactive fg=251,bg=237 # fg=#c5c6c5,bg=#33393b + ble-face -s vim_airline_a_insert fg=237,bg=97 # fg=#33393b,bg=#916fb4 + ble-face -s vim_airline_a_replace fg=237,bg=214 # fg=#33393b,bg=#ffa500 + ble-face -s vim_airline_a_visual fg=237,bg=204 # fg=#33393b,bg=#ee6f91 + ble-face -s vim_airline_b fg=188,bg=239 # fg=#d3d4d5,bg=#4b5356 + ble-face -s vim_airline_b_inactive fg=251,bg=237 # fg=#c5c6c5,bg=#33393b + ble-face -s vim_airline_c fg=227,bg=237 # fg=#ffff60,bg=#33393b + ble-face -s vim_airline_c_inactive fg=251,bg=237 # fg=#c5c6c5,bg=#33393b +} diff --git a/.local/share/blesh/contrib/airline/base16_apathy.bash b/.local/share/blesh/contrib/airline/base16_apathy.bash new file mode 100644 index 0000000..85d1cfa --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_apathy.bash @@ -0,0 +1,21 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_apathy.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# vim-airline template by chartoin (http://github.com/chartoin) +# Base 16 Apathy Scheme by Jannik Siebert (https://github.com/janniks) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_apathy/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=22,bg=96 # fg=#0b342d,bg=#883e96 + ble-face -s vim_airline_a_inactive fg=109,bg=22 # fg=#81b5ac,bg=#0b342d + ble-face -s vim_airline_a_insert fg=22,bg=101 # fg=#0b342d,bg=#96883e + ble-face -s vim_airline_a_replace fg=22,bg=66 # fg=#0b342d,bg=#3e9688 + ble-face -s vim_airline_a_visual fg=22,bg=65 # fg=#0b342d,bg=#4c963e + ble-face -s vim_airline_b fg=152,bg=23 # fg=#a7cec8,bg=#184e45 + ble-face -s vim_airline_b_inactive fg=109,bg=22 # fg=#81b5ac,bg=#0b342d + ble-face -s vim_airline_c fg=66,bg=22 # fg=#3e7996,bg=#0b342d + ble-face -s vim_airline_c_inactive fg=109,bg=22 # fg=#81b5ac,bg=#0b342d +} diff --git a/.local/share/blesh/contrib/airline/base16_ashes.bash b/.local/share/blesh/contrib/airline/base16_ashes.bash new file mode 100644 index 0000000..bc84259 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_ashes.bash @@ -0,0 +1,21 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_ashes.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# vim-airline template by chartoin (http://github.com/chartoin) +# Base 16 Ashes Scheme by Jannik Siebert (https://github.com/janniks) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_ashes/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=238,bg=115 # fg=#393f45,bg=#95c7ae + ble-face -s vim_airline_a_inactive fg=252,bg=238 # fg=#c7ccd1,bg=#393f45 + ble-face -s vim_airline_a_insert fg=238,bg=140 # fg=#393f45,bg=#ae95c7 + ble-face -s vim_airline_a_replace fg=238,bg=180 # fg=#393f45,bg=#c7ae95 + ble-face -s vim_airline_a_visual fg=238,bg=175 # fg=#393f45,bg=#c795ae + ble-face -s vim_airline_b fg=254,bg=61 # fg=#dfe2e5,bg=#565e65 + ble-face -s vim_airline_b_inactive fg=252,bg=238 # fg=#c7ccd1,bg=#393f45 + ble-face -s vim_airline_c fg=186,bg=238 # fg=#c7c795,bg=#393f45 + ble-face -s vim_airline_c_inactive fg=252,bg=238 # fg=#c7ccd1,bg=#393f45 +} diff --git a/.local/share/blesh/contrib/airline/base16_atelier_cave.bash b/.local/share/blesh/contrib/airline/base16_atelier_cave.bash new file mode 100644 index 0000000..57aa8c1 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_atelier_cave.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_atelier_cave.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Atelier Cave vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Bram de Haan (http://atelierbramdehaan.nl) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_atelier_cave/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=235,bg=244 # fg=#26232a,bg=#7e7887 + ble-face -s vim_airline_a_inactive fg=235,bg=235 # fg=#26232a,bg=#26232a + ble-face -s vim_airline_a_insert fg=235,bg=30 # fg=#26232a,bg=#2a9292 + ble-face -s vim_airline_a_replace fg=235,bg=98 # fg=#26232a,bg=#955ae7 + ble-face -s vim_airline_a_visual fg=235,bg=131 # fg=#26232a,bg=#aa573c + ble-face -s vim_airline_b fg=244,bg=240 # fg=#7e7887,bg=#585260 + ble-face -s vim_airline_b_inactive fg=244,bg=235 # fg=#7e7887,bg=#26232a + ble-face -s vim_airline_c fg=244,bg=235 # fg=#7e7887,bg=#26232a + ble-face -s vim_airline_c_inactive fg=245,bg=235 # fg=#8b8792,bg=#26232a + ble-face -s vim_airline_c_insert_modified fg=255,bg=235 # fg=#efecf4,bg=#26232a + ble-face -s vim_airline_c_normal_modified fg=255,bg=235 # fg=#efecf4,bg=#26232a + ble-face -s vim_airline_c_replace_modified fg=255,bg=235 # fg=#efecf4,bg=#26232a + ble-face -s vim_airline_c_visual_modified fg=255,bg=235 # fg=#efecf4,bg=#26232a +} diff --git a/.local/share/blesh/contrib/airline/base16_atelier_cave_light.bash b/.local/share/blesh/contrib/airline/base16_atelier_cave_light.bash new file mode 100644 index 0000000..ef2386c --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_atelier_cave_light.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_atelier_cave_light.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Atelier Cave Light vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Bram de Haan (http://atelierbramdehaan.nl) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_atelier_cave_light/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=254,bg=241 # fg=#e2dfe7,bg=#655f6d + ble-face -s vim_airline_a_inactive fg=254,bg=254 # fg=#e2dfe7,bg=#e2dfe7 + ble-face -s vim_airline_a_insert fg=254,bg=30 # fg=#e2dfe7,bg=#2a9292 + ble-face -s vim_airline_a_replace fg=254,bg=98 # fg=#e2dfe7,bg=#955ae7 + ble-face -s vim_airline_a_visual fg=254,bg=131 # fg=#e2dfe7,bg=#aa573c + ble-face -s vim_airline_b fg=241,bg=245 # fg=#655f6d,bg=#8b8792 + ble-face -s vim_airline_b_inactive fg=241,bg=254 # fg=#655f6d,bg=#e2dfe7 + ble-face -s vim_airline_c fg=241,bg=254 # fg=#655f6d,bg=#e2dfe7 + ble-face -s vim_airline_c_inactive fg=240,bg=254 # fg=#585260,bg=#e2dfe7 + ble-face -s vim_airline_c_insert_modified fg=234,bg=254 # fg=#19171c,bg=#e2dfe7 + ble-face -s vim_airline_c_normal_modified fg=234,bg=254 # fg=#19171c,bg=#e2dfe7 + ble-face -s vim_airline_c_replace_modified fg=234,bg=254 # fg=#19171c,bg=#e2dfe7 + ble-face -s vim_airline_c_visual_modified fg=234,bg=254 # fg=#19171c,bg=#e2dfe7 +} diff --git a/.local/share/blesh/contrib/airline/base16_atelier_dune.bash b/.local/share/blesh/contrib/airline/base16_atelier_dune.bash new file mode 100644 index 0000000..17db305 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_atelier_dune.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_atelier_dune.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Atelier Dune vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Bram de Haan (http://atelierbramdehaan.nl) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_atelier_dune/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=235,bg=246 # fg=#292824,bg=#999580 + ble-face -s vim_airline_a_inactive fg=235,bg=235 # fg=#292824,bg=#292824 + ble-face -s vim_airline_a_insert fg=235,bg=71 # fg=#292824,bg=#60ac39 + ble-face -s vim_airline_a_replace fg=235,bg=134 # fg=#292824,bg=#b854d4 + ble-face -s vim_airline_a_visual fg=235,bg=130 # fg=#292824,bg=#b65611 + ble-face -s vim_airline_b fg=246,bg=242 # fg=#999580,bg=#6e6b5e + ble-face -s vim_airline_b_inactive fg=246,bg=235 # fg=#999580,bg=#292824 + ble-face -s vim_airline_c fg=246,bg=235 # fg=#999580,bg=#292824 + ble-face -s vim_airline_c_inactive fg=144,bg=235 # fg=#a6a28c,bg=#292824 + ble-face -s vim_airline_c_insert_modified fg=231,bg=235 # fg=#fefbec,bg=#292824 + ble-face -s vim_airline_c_normal_modified fg=231,bg=235 # fg=#fefbec,bg=#292824 + ble-face -s vim_airline_c_replace_modified fg=231,bg=235 # fg=#fefbec,bg=#292824 + ble-face -s vim_airline_c_visual_modified fg=231,bg=235 # fg=#fefbec,bg=#292824 +} diff --git a/.local/share/blesh/contrib/airline/base16_atelier_dune_light.bash b/.local/share/blesh/contrib/airline/base16_atelier_dune_light.bash new file mode 100644 index 0000000..2b7b8ce --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_atelier_dune_light.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_atelier_dune_light.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Atelier Dune Light vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Bram de Haan (http://atelierbramdehaan.nl) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_atelier_dune_light/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=253,bg=101 # fg=#e8e4cf,bg=#7d7a68 + ble-face -s vim_airline_a_inactive fg=253,bg=253 # fg=#e8e4cf,bg=#e8e4cf + ble-face -s vim_airline_a_insert fg=253,bg=71 # fg=#e8e4cf,bg=#60ac39 + ble-face -s vim_airline_a_replace fg=253,bg=134 # fg=#e8e4cf,bg=#b854d4 + ble-face -s vim_airline_a_visual fg=253,bg=130 # fg=#e8e4cf,bg=#b65611 + ble-face -s vim_airline_b fg=101,bg=144 # fg=#7d7a68,bg=#a6a28c + ble-face -s vim_airline_b_inactive fg=101,bg=253 # fg=#7d7a68,bg=#e8e4cf + ble-face -s vim_airline_c fg=101,bg=253 # fg=#7d7a68,bg=#e8e4cf + ble-face -s vim_airline_c_inactive fg=242,bg=253 # fg=#6e6b5e,bg=#e8e4cf + ble-face -s vim_airline_c_insert_modified fg=234,bg=253 # fg=#20201d,bg=#e8e4cf + ble-face -s vim_airline_c_normal_modified fg=234,bg=253 # fg=#20201d,bg=#e8e4cf + ble-face -s vim_airline_c_replace_modified fg=234,bg=253 # fg=#20201d,bg=#e8e4cf + ble-face -s vim_airline_c_visual_modified fg=234,bg=253 # fg=#20201d,bg=#e8e4cf +} diff --git a/.local/share/blesh/contrib/airline/base16_atelier_estuary.bash b/.local/share/blesh/contrib/airline/base16_atelier_estuary.bash new file mode 100644 index 0000000..2cde666 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_atelier_estuary.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_atelier_estuary.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Atelier Estuary vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Bram de Haan (http://atelierbramdehaan.nl) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_atelier_estuary/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=52,bg=244 # fg=#302f27,bg=#878573 + ble-face -s vim_airline_a_inactive fg=52,bg=52 # fg=#302f27,bg=#302f27 + ble-face -s vim_airline_a_insert fg=52,bg=100 # fg=#302f27,bg=#7d9726 + ble-face -s vim_airline_a_replace fg=52,bg=66 # fg=#302f27,bg=#5f9182 + ble-face -s vim_airline_a_visual fg=52,bg=136 # fg=#302f27,bg=#ae7313 + ble-face -s vim_airline_b fg=244,bg=240 # fg=#878573,bg=#5f5e4e + ble-face -s vim_airline_b_inactive fg=244,bg=52 # fg=#878573,bg=#302f27 + ble-face -s vim_airline_c fg=244,bg=52 # fg=#878573,bg=#302f27 + ble-face -s vim_airline_c_inactive fg=245,bg=52 # fg=#929181,bg=#302f27 + ble-face -s vim_airline_c_insert_modified fg=255,bg=52 # fg=#f4f3ec,bg=#302f27 + ble-face -s vim_airline_c_normal_modified fg=255,bg=52 # fg=#f4f3ec,bg=#302f27 + ble-face -s vim_airline_c_replace_modified fg=255,bg=52 # fg=#f4f3ec,bg=#302f27 + ble-face -s vim_airline_c_visual_modified fg=255,bg=52 # fg=#f4f3ec,bg=#302f27 +} diff --git a/.local/share/blesh/contrib/airline/base16_atelier_estuary_light.bash b/.local/share/blesh/contrib/airline/base16_atelier_estuary_light.bash new file mode 100644 index 0000000..7991bad --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_atelier_estuary_light.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_atelier_estuary_light.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Atelier Estuary Light vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Bram de Haan (http://atelierbramdehaan.nl) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_atelier_estuary_light/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=254,bg=241 # fg=#e7e6df,bg=#6c6b5a + ble-face -s vim_airline_a_inactive fg=254,bg=254 # fg=#e7e6df,bg=#e7e6df + ble-face -s vim_airline_a_insert fg=254,bg=100 # fg=#e7e6df,bg=#7d9726 + ble-face -s vim_airline_a_replace fg=254,bg=66 # fg=#e7e6df,bg=#5f9182 + ble-face -s vim_airline_a_visual fg=254,bg=136 # fg=#e7e6df,bg=#ae7313 + ble-face -s vim_airline_b fg=241,bg=245 # fg=#6c6b5a,bg=#929181 + ble-face -s vim_airline_b_inactive fg=241,bg=254 # fg=#6c6b5a,bg=#e7e6df + ble-face -s vim_airline_c fg=241,bg=254 # fg=#6c6b5a,bg=#e7e6df + ble-face -s vim_airline_c_inactive fg=240,bg=254 # fg=#5f5e4e,bg=#e7e6df + ble-face -s vim_airline_c_insert_modified fg=234,bg=254 # fg=#22221b,bg=#e7e6df + ble-face -s vim_airline_c_normal_modified fg=234,bg=254 # fg=#22221b,bg=#e7e6df + ble-face -s vim_airline_c_replace_modified fg=234,bg=254 # fg=#22221b,bg=#e7e6df + ble-face -s vim_airline_c_visual_modified fg=234,bg=254 # fg=#22221b,bg=#e7e6df +} diff --git a/.local/share/blesh/contrib/airline/base16_atelier_forest.bash b/.local/share/blesh/contrib/airline/base16_atelier_forest.bash new file mode 100644 index 0000000..3382a81 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_atelier_forest.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_atelier_forest.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Atelier Forest vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Bram de Haan (http://atelierbramdehaan.nl) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_atelier_forest/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=235,bg=138 # fg=#2c2421,bg=#9c9491 + ble-face -s vim_airline_a_inactive fg=235,bg=235 # fg=#2c2421,bg=#2c2421 + ble-face -s vim_airline_a_insert fg=235,bg=100 # fg=#2c2421,bg=#7b9726 + ble-face -s vim_airline_a_replace fg=235,bg=62 # fg=#2c2421,bg=#6666ea + ble-face -s vim_airline_a_visual fg=235,bg=166 # fg=#2c2421,bg=#df5320 + ble-face -s vim_airline_b fg=138,bg=241 # fg=#9c9491,bg=#68615e + ble-face -s vim_airline_b_inactive fg=138,bg=235 # fg=#9c9491,bg=#2c2421 + ble-face -s vim_airline_c fg=138,bg=235 # fg=#9c9491,bg=#2c2421 + ble-face -s vim_airline_c_inactive fg=248,bg=235 # fg=#a8a19f,bg=#2c2421 + ble-face -s vim_airline_c_insert_modified fg=255,bg=235 # fg=#f1efee,bg=#2c2421 + ble-face -s vim_airline_c_normal_modified fg=255,bg=235 # fg=#f1efee,bg=#2c2421 + ble-face -s vim_airline_c_replace_modified fg=255,bg=235 # fg=#f1efee,bg=#2c2421 + ble-face -s vim_airline_c_visual_modified fg=255,bg=235 # fg=#f1efee,bg=#2c2421 +} diff --git a/.local/share/blesh/contrib/airline/base16_atelier_forest_light.bash b/.local/share/blesh/contrib/airline/base16_atelier_forest_light.bash new file mode 100644 index 0000000..90043eb --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_atelier_forest_light.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_atelier_forest_light.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Atelier Forest Light vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Bram de Haan (http://atelierbramdehaan.nl) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_atelier_forest_light/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=254,bg=95 # fg=#e6e2e0,bg=#766e6b + ble-face -s vim_airline_a_inactive fg=254,bg=254 # fg=#e6e2e0,bg=#e6e2e0 + ble-face -s vim_airline_a_insert fg=254,bg=100 # fg=#e6e2e0,bg=#7b9726 + ble-face -s vim_airline_a_replace fg=254,bg=62 # fg=#e6e2e0,bg=#6666ea + ble-face -s vim_airline_a_visual fg=254,bg=166 # fg=#e6e2e0,bg=#df5320 + ble-face -s vim_airline_b fg=95,bg=248 # fg=#766e6b,bg=#a8a19f + ble-face -s vim_airline_b_inactive fg=95,bg=254 # fg=#766e6b,bg=#e6e2e0 + ble-face -s vim_airline_c fg=95,bg=254 # fg=#766e6b,bg=#e6e2e0 + ble-face -s vim_airline_c_inactive fg=241,bg=254 # fg=#68615e,bg=#e6e2e0 + ble-face -s vim_airline_c_insert_modified fg=234,bg=254 # fg=#1b1918,bg=#e6e2e0 + ble-face -s vim_airline_c_normal_modified fg=234,bg=254 # fg=#1b1918,bg=#e6e2e0 + ble-face -s vim_airline_c_replace_modified fg=234,bg=254 # fg=#1b1918,bg=#e6e2e0 + ble-face -s vim_airline_c_visual_modified fg=234,bg=254 # fg=#1b1918,bg=#e6e2e0 +} diff --git a/.local/share/blesh/contrib/airline/base16_atelier_heath.bash b/.local/share/blesh/contrib/airline/base16_atelier_heath.bash new file mode 100644 index 0000000..4a425e9 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_atelier_heath.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_atelier_heath.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Atelier Heath vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Bram de Haan (http://atelierbramdehaan.nl) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_atelier_heath/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=235,bg=139 # fg=#292329,bg=#9e8f9e + ble-face -s vim_airline_a_inactive fg=235,bg=235 # fg=#292329,bg=#292329 + ble-face -s vim_airline_a_insert fg=235,bg=101 # fg=#292329,bg=#918b3b + ble-face -s vim_airline_a_replace fg=235,bg=97 # fg=#292329,bg=#7b59c0 + ble-face -s vim_airline_a_visual fg=235,bg=130 # fg=#292329,bg=#a65926 + ble-face -s vim_airline_b fg=139,bg=241 # fg=#9e8f9e,bg=#695d69 + ble-face -s vim_airline_b_inactive fg=139,bg=235 # fg=#9e8f9e,bg=#292329 + ble-face -s vim_airline_c fg=139,bg=235 # fg=#9e8f9e,bg=#292329 + ble-face -s vim_airline_c_inactive fg=248,bg=235 # fg=#ab9bab,bg=#292329 + ble-face -s vim_airline_c_insert_modified fg=255,bg=235 # fg=#f7f3f7,bg=#292329 + ble-face -s vim_airline_c_normal_modified fg=255,bg=235 # fg=#f7f3f7,bg=#292329 + ble-face -s vim_airline_c_replace_modified fg=255,bg=235 # fg=#f7f3f7,bg=#292329 + ble-face -s vim_airline_c_visual_modified fg=255,bg=235 # fg=#f7f3f7,bg=#292329 +} diff --git a/.local/share/blesh/contrib/airline/base16_atelier_heath_light.bash b/.local/share/blesh/contrib/airline/base16_atelier_heath_light.bash new file mode 100644 index 0000000..9190a97 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_atelier_heath_light.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_atelier_heath_light.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Atelier Heath Light vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Bram de Haan (http://atelierbramdehaan.nl) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_atelier_heath_light/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=252,bg=96 # fg=#d8cad8,bg=#776977 + ble-face -s vim_airline_a_inactive fg=252,bg=252 # fg=#d8cad8,bg=#d8cad8 + ble-face -s vim_airline_a_insert fg=252,bg=101 # fg=#d8cad8,bg=#918b3b + ble-face -s vim_airline_a_replace fg=252,bg=97 # fg=#d8cad8,bg=#7b59c0 + ble-face -s vim_airline_a_visual fg=252,bg=130 # fg=#d8cad8,bg=#a65926 + ble-face -s vim_airline_b fg=96,bg=248 # fg=#776977,bg=#ab9bab + ble-face -s vim_airline_b_inactive fg=96,bg=252 # fg=#776977,bg=#d8cad8 + ble-face -s vim_airline_c fg=96,bg=252 # fg=#776977,bg=#d8cad8 + ble-face -s vim_airline_c_inactive fg=241,bg=252 # fg=#695d69,bg=#d8cad8 + ble-face -s vim_airline_c_insert_modified fg=234,bg=252 # fg=#1b181b,bg=#d8cad8 + ble-face -s vim_airline_c_normal_modified fg=234,bg=252 # fg=#1b181b,bg=#d8cad8 + ble-face -s vim_airline_c_replace_modified fg=234,bg=252 # fg=#1b181b,bg=#d8cad8 + ble-face -s vim_airline_c_visual_modified fg=234,bg=252 # fg=#1b181b,bg=#d8cad8 +} diff --git a/.local/share/blesh/contrib/airline/base16_atelier_lakeside.bash b/.local/share/blesh/contrib/airline/base16_atelier_lakeside.bash new file mode 100644 index 0000000..1fa943d --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_atelier_lakeside.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_atelier_lakeside.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Atelier Lakeside vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Bram de Haan (http://atelierbramdehaan.nl) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_atelier_lakeside/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=235,bg=67 # fg=#1f292e,bg=#7195a8 + ble-face -s vim_airline_a_inactive fg=235,bg=235 # fg=#1f292e,bg=#1f292e + ble-face -s vim_airline_a_insert fg=235,bg=65 # fg=#1f292e,bg=#568c3b + ble-face -s vim_airline_a_replace fg=235,bg=61 # fg=#1f292e,bg=#6b6bb8 + ble-face -s vim_airline_a_visual fg=235,bg=94 # fg=#1f292e,bg=#935c25 + ble-face -s vim_airline_b fg=67,bg=60 # fg=#7195a8,bg=#516d7b + ble-face -s vim_airline_b_inactive fg=67,bg=235 # fg=#7195a8,bg=#1f292e + ble-face -s vim_airline_c fg=67,bg=235 # fg=#7195a8,bg=#1f292e + ble-face -s vim_airline_c_inactive fg=109,bg=235 # fg=#7ea2b4,bg=#1f292e + ble-face -s vim_airline_c_insert_modified fg=255,bg=235 # fg=#ebf8ff,bg=#1f292e + ble-face -s vim_airline_c_normal_modified fg=255,bg=235 # fg=#ebf8ff,bg=#1f292e + ble-face -s vim_airline_c_replace_modified fg=255,bg=235 # fg=#ebf8ff,bg=#1f292e + ble-face -s vim_airline_c_visual_modified fg=255,bg=235 # fg=#ebf8ff,bg=#1f292e +} diff --git a/.local/share/blesh/contrib/airline/base16_atelier_lakeside_light.bash b/.local/share/blesh/contrib/airline/base16_atelier_lakeside_light.bash new file mode 100644 index 0000000..5377473 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_atelier_lakeside_light.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_atelier_lakeside_light.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Atelier Lakeside Light vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Bram de Haan (http://atelierbramdehaan.nl) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_atelier_lakeside_light/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=153,bg=66 # fg=#c1e4f6,bg=#5a7b8c + ble-face -s vim_airline_a_inactive fg=153,bg=153 # fg=#c1e4f6,bg=#c1e4f6 + ble-face -s vim_airline_a_insert fg=153,bg=65 # fg=#c1e4f6,bg=#568c3b + ble-face -s vim_airline_a_replace fg=153,bg=61 # fg=#c1e4f6,bg=#6b6bb8 + ble-face -s vim_airline_a_visual fg=153,bg=94 # fg=#c1e4f6,bg=#935c25 + ble-face -s vim_airline_b fg=66,bg=109 # fg=#5a7b8c,bg=#7ea2b4 + ble-face -s vim_airline_b_inactive fg=66,bg=153 # fg=#5a7b8c,bg=#c1e4f6 + ble-face -s vim_airline_c fg=66,bg=153 # fg=#5a7b8c,bg=#c1e4f6 + ble-face -s vim_airline_c_inactive fg=60,bg=153 # fg=#516d7b,bg=#c1e4f6 + ble-face -s vim_airline_c_insert_modified fg=234,bg=153 # fg=#161b1d,bg=#c1e4f6 + ble-face -s vim_airline_c_normal_modified fg=234,bg=153 # fg=#161b1d,bg=#c1e4f6 + ble-face -s vim_airline_c_replace_modified fg=234,bg=153 # fg=#161b1d,bg=#c1e4f6 + ble-face -s vim_airline_c_visual_modified fg=234,bg=153 # fg=#161b1d,bg=#c1e4f6 +} diff --git a/.local/share/blesh/contrib/airline/base16_atelier_plateau.bash b/.local/share/blesh/contrib/airline/base16_atelier_plateau.bash new file mode 100644 index 0000000..1bca55b --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_atelier_plateau.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_atelier_plateau.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Atelier Plateau vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Bram de Haan (http://atelierbramdehaan.nl) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_atelier_plateau/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=235,bg=243 # fg=#292424,bg=#7e7777 + ble-face -s vim_airline_a_inactive fg=235,bg=235 # fg=#292424,bg=#292424 + ble-face -s vim_airline_a_insert fg=235,bg=66 # fg=#292424,bg=#4b8b8b + ble-face -s vim_airline_a_replace fg=235,bg=98 # fg=#292424,bg=#8464c4 + ble-face -s vim_airline_a_visual fg=235,bg=131 # fg=#292424,bg=#b45a3c + ble-face -s vim_airline_b fg=243,bg=240 # fg=#7e7777,bg=#585050 + ble-face -s vim_airline_b_inactive fg=243,bg=235 # fg=#7e7777,bg=#292424 + ble-face -s vim_airline_c fg=243,bg=235 # fg=#7e7777,bg=#292424 + ble-face -s vim_airline_c_inactive fg=105,bg=235 # fg=#8a8585,bg=#292424 + ble-face -s vim_airline_c_insert_modified fg=255,bg=235 # fg=#f4ecec,bg=#292424 + ble-face -s vim_airline_c_normal_modified fg=255,bg=235 # fg=#f4ecec,bg=#292424 + ble-face -s vim_airline_c_replace_modified fg=255,bg=235 # fg=#f4ecec,bg=#292424 + ble-face -s vim_airline_c_visual_modified fg=255,bg=235 # fg=#f4ecec,bg=#292424 +} diff --git a/.local/share/blesh/contrib/airline/base16_atelier_plateau_light.bash b/.local/share/blesh/contrib/airline/base16_atelier_plateau_light.bash new file mode 100644 index 0000000..021c3a2 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_atelier_plateau_light.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_atelier_plateau_light.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Atelier Plateau Light vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Bram de Haan (http://atelierbramdehaan.nl) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_atelier_plateau_light/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=254,bg=63 # fg=#e7dfdf,bg=#655d5d + ble-face -s vim_airline_a_inactive fg=254,bg=254 # fg=#e7dfdf,bg=#e7dfdf + ble-face -s vim_airline_a_insert fg=254,bg=66 # fg=#e7dfdf,bg=#4b8b8b + ble-face -s vim_airline_a_replace fg=254,bg=98 # fg=#e7dfdf,bg=#8464c4 + ble-face -s vim_airline_a_visual fg=254,bg=131 # fg=#e7dfdf,bg=#b45a3c + ble-face -s vim_airline_b fg=63,bg=105 # fg=#655d5d,bg=#8a8585 + ble-face -s vim_airline_b_inactive fg=63,bg=254 # fg=#655d5d,bg=#e7dfdf + ble-face -s vim_airline_c fg=63,bg=254 # fg=#655d5d,bg=#e7dfdf + ble-face -s vim_airline_c_inactive fg=240,bg=254 # fg=#585050,bg=#e7dfdf + ble-face -s vim_airline_c_insert_modified fg=234,bg=254 # fg=#1b1818,bg=#e7dfdf + ble-face -s vim_airline_c_normal_modified fg=234,bg=254 # fg=#1b1818,bg=#e7dfdf + ble-face -s vim_airline_c_replace_modified fg=234,bg=254 # fg=#1b1818,bg=#e7dfdf + ble-face -s vim_airline_c_visual_modified fg=234,bg=254 # fg=#1b1818,bg=#e7dfdf +} diff --git a/.local/share/blesh/contrib/airline/base16_atelier_savanna.bash b/.local/share/blesh/contrib/airline/base16_atelier_savanna.bash new file mode 100644 index 0000000..ef9bb71 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_atelier_savanna.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_atelier_savanna.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Atelier Savanna vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Bram de Haan (http://atelierbramdehaan.nl) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_atelier_savanna/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=235,bg=244 # fg=#232a25,bg=#78877d + ble-face -s vim_airline_a_inactive fg=235,bg=235 # fg=#232a25,bg=#232a25 + ble-face -s vim_airline_a_insert fg=235,bg=65 # fg=#232a25,bg=#489963 + ble-face -s vim_airline_a_replace fg=235,bg=67 # fg=#232a25,bg=#55859b + ble-face -s vim_airline_a_visual fg=235,bg=131 # fg=#232a25,bg=#9f713c + ble-face -s vim_airline_b fg=244,bg=240 # fg=#78877d,bg=#526057 + ble-face -s vim_airline_b_inactive fg=244,bg=235 # fg=#78877d,bg=#232a25 + ble-face -s vim_airline_c fg=244,bg=235 # fg=#78877d,bg=#232a25 + ble-face -s vim_airline_c_inactive fg=245,bg=235 # fg=#87928a,bg=#232a25 + ble-face -s vim_airline_c_insert_modified fg=255,bg=235 # fg=#ecf4ee,bg=#232a25 + ble-face -s vim_airline_c_normal_modified fg=255,bg=235 # fg=#ecf4ee,bg=#232a25 + ble-face -s vim_airline_c_replace_modified fg=255,bg=235 # fg=#ecf4ee,bg=#232a25 + ble-face -s vim_airline_c_visual_modified fg=255,bg=235 # fg=#ecf4ee,bg=#232a25 +} diff --git a/.local/share/blesh/contrib/airline/base16_atelier_savanna_light.bash b/.local/share/blesh/contrib/airline/base16_atelier_savanna_light.bash new file mode 100644 index 0000000..a2dbcc3 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_atelier_savanna_light.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_atelier_savanna_light.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Atelier Savanna Light vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Bram de Haan (http://atelierbramdehaan.nl) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_atelier_savanna_light/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=254,bg=241 # fg=#dfe7e2,bg=#5f6d64 + ble-face -s vim_airline_a_inactive fg=254,bg=254 # fg=#dfe7e2,bg=#dfe7e2 + ble-face -s vim_airline_a_insert fg=254,bg=65 # fg=#dfe7e2,bg=#489963 + ble-face -s vim_airline_a_replace fg=254,bg=67 # fg=#dfe7e2,bg=#55859b + ble-face -s vim_airline_a_visual fg=254,bg=131 # fg=#dfe7e2,bg=#9f713c + ble-face -s vim_airline_b fg=241,bg=245 # fg=#5f6d64,bg=#87928a + ble-face -s vim_airline_b_inactive fg=241,bg=254 # fg=#5f6d64,bg=#dfe7e2 + ble-face -s vim_airline_c fg=241,bg=254 # fg=#5f6d64,bg=#dfe7e2 + ble-face -s vim_airline_c_inactive fg=240,bg=254 # fg=#526057,bg=#dfe7e2 + ble-face -s vim_airline_c_insert_modified fg=234,bg=254 # fg=#171c19,bg=#dfe7e2 + ble-face -s vim_airline_c_normal_modified fg=234,bg=254 # fg=#171c19,bg=#dfe7e2 + ble-face -s vim_airline_c_replace_modified fg=234,bg=254 # fg=#171c19,bg=#dfe7e2 + ble-face -s vim_airline_c_visual_modified fg=234,bg=254 # fg=#171c19,bg=#dfe7e2 +} diff --git a/.local/share/blesh/contrib/airline/base16_atelier_seaside.bash b/.local/share/blesh/contrib/airline/base16_atelier_seaside.bash new file mode 100644 index 0000000..3cb7039 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_atelier_seaside.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_atelier_seaside.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Atelier Seaside vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Bram de Haan (http://atelierbramdehaan.nl) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_atelier_seaside/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=235,bg=106 # fg=#242924,bg=#809980 + ble-face -s vim_airline_a_inactive fg=235,bg=235 # fg=#242924,bg=#242924 + ble-face -s vim_airline_a_insert fg=235,bg=34 # fg=#242924,bg=#29a329 + ble-face -s vim_airline_a_replace fg=235,bg=129 # fg=#242924,bg=#ad2bee + ble-face -s vim_airline_a_visual fg=235,bg=94 # fg=#242924,bg=#87711d + ble-face -s vim_airline_b fg=106,bg=241 # fg=#809980,bg=#5e6e5e + ble-face -s vim_airline_b_inactive fg=106,bg=235 # fg=#809980,bg=#242924 + ble-face -s vim_airline_c fg=106,bg=235 # fg=#809980,bg=#242924 + ble-face -s vim_airline_c_inactive fg=108,bg=235 # fg=#8ca68c,bg=#242924 + ble-face -s vim_airline_c_insert_modified fg=255,bg=235 # fg=#f4fbf4,bg=#242924 + ble-face -s vim_airline_c_normal_modified fg=255,bg=235 # fg=#f4fbf4,bg=#242924 + ble-face -s vim_airline_c_replace_modified fg=255,bg=235 # fg=#f4fbf4,bg=#242924 + ble-face -s vim_airline_c_visual_modified fg=255,bg=235 # fg=#f4fbf4,bg=#242924 +} diff --git a/.local/share/blesh/contrib/airline/base16_atelier_seaside_light.bash b/.local/share/blesh/contrib/airline/base16_atelier_seaside_light.bash new file mode 100644 index 0000000..c0ca2a2 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_atelier_seaside_light.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_atelier_seaside_light.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Atelier Seaside Light vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Bram de Haan (http://atelierbramdehaan.nl) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_atelier_seaside_light/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=191,bg=65 # fg=#cfe8cf,bg=#687d68 + ble-face -s vim_airline_a_inactive fg=191,bg=191 # fg=#cfe8cf,bg=#cfe8cf + ble-face -s vim_airline_a_insert fg=191,bg=34 # fg=#cfe8cf,bg=#29a329 + ble-face -s vim_airline_a_replace fg=191,bg=129 # fg=#cfe8cf,bg=#ad2bee + ble-face -s vim_airline_a_visual fg=191,bg=94 # fg=#cfe8cf,bg=#87711d + ble-face -s vim_airline_b fg=65,bg=108 # fg=#687d68,bg=#8ca68c + ble-face -s vim_airline_b_inactive fg=65,bg=191 # fg=#687d68,bg=#cfe8cf + ble-face -s vim_airline_c fg=65,bg=191 # fg=#687d68,bg=#cfe8cf + ble-face -s vim_airline_c_inactive fg=241,bg=191 # fg=#5e6e5e,bg=#cfe8cf + ble-face -s vim_airline_c_insert_modified fg=233,bg=191 # fg=#131513,bg=#cfe8cf + ble-face -s vim_airline_c_normal_modified fg=233,bg=191 # fg=#131513,bg=#cfe8cf + ble-face -s vim_airline_c_replace_modified fg=233,bg=191 # fg=#131513,bg=#cfe8cf + ble-face -s vim_airline_c_visual_modified fg=233,bg=191 # fg=#131513,bg=#cfe8cf +} diff --git a/.local/share/blesh/contrib/airline/base16_atelier_sulphurpool.bash b/.local/share/blesh/contrib/airline/base16_atelier_sulphurpool.bash new file mode 100644 index 0000000..1474b3b --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_atelier_sulphurpool.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_atelier_sulphurpool.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Atelier Sulphurpool vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Bram de Haan (http://atelierbramdehaan.nl) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_atelier_sulphurpool/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=23,bg=103 # fg=#293256,bg=#898ea4 + ble-face -s vim_airline_a_inactive fg=23,bg=23 # fg=#293256,bg=#293256 + ble-face -s vim_airline_a_insert fg=23,bg=137 # fg=#293256,bg=#ac9739 + ble-face -s vim_airline_a_replace fg=23,bg=68 # fg=#293256,bg=#6679cc + ble-face -s vim_airline_a_visual fg=23,bg=166 # fg=#293256,bg=#c76b29 + ble-face -s vim_airline_b fg=103,bg=60 # fg=#898ea4,bg=#5e6687 + ble-face -s vim_airline_b_inactive fg=103,bg=23 # fg=#898ea4,bg=#293256 + ble-face -s vim_airline_c fg=103,bg=23 # fg=#898ea4,bg=#293256 + ble-face -s vim_airline_c_inactive fg=109,bg=23 # fg=#979db4,bg=#293256 + ble-face -s vim_airline_c_insert_modified fg=231,bg=23 # fg=#f5f7ff,bg=#293256 + ble-face -s vim_airline_c_normal_modified fg=231,bg=23 # fg=#f5f7ff,bg=#293256 + ble-face -s vim_airline_c_replace_modified fg=231,bg=23 # fg=#f5f7ff,bg=#293256 + ble-face -s vim_airline_c_visual_modified fg=231,bg=23 # fg=#f5f7ff,bg=#293256 +} diff --git a/.local/share/blesh/contrib/airline/base16_atelier_sulphurpool_light.bash b/.local/share/blesh/contrib/airline/base16_atelier_sulphurpool_light.bash new file mode 100644 index 0000000..535b97f --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_atelier_sulphurpool_light.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_atelier_sulphurpool_light.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Atelier Sulphurpool Light vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Bram de Haan (http://atelierbramdehaan.nl) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_atelier_sulphurpool_light/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=189,bg=66 # fg=#dfe2f1,bg=#6b7394 + ble-face -s vim_airline_a_inactive fg=189,bg=189 # fg=#dfe2f1,bg=#dfe2f1 + ble-face -s vim_airline_a_insert fg=189,bg=137 # fg=#dfe2f1,bg=#ac9739 + ble-face -s vim_airline_a_replace fg=189,bg=68 # fg=#dfe2f1,bg=#6679cc + ble-face -s vim_airline_a_visual fg=189,bg=166 # fg=#dfe2f1,bg=#c76b29 + ble-face -s vim_airline_b fg=66,bg=109 # fg=#6b7394,bg=#979db4 + ble-face -s vim_airline_b_inactive fg=66,bg=189 # fg=#6b7394,bg=#dfe2f1 + ble-face -s vim_airline_c fg=66,bg=189 # fg=#6b7394,bg=#dfe2f1 + ble-face -s vim_airline_c_inactive fg=60,bg=189 # fg=#5e6687,bg=#dfe2f1 + ble-face -s vim_airline_c_insert_modified fg=17,bg=189 # fg=#202746,bg=#dfe2f1 + ble-face -s vim_airline_c_normal_modified fg=17,bg=189 # fg=#202746,bg=#dfe2f1 + ble-face -s vim_airline_c_replace_modified fg=17,bg=189 # fg=#202746,bg=#dfe2f1 + ble-face -s vim_airline_c_visual_modified fg=17,bg=189 # fg=#202746,bg=#dfe2f1 +} diff --git a/.local/share/blesh/contrib/airline/base16_atelierdune.bash b/.local/share/blesh/contrib/airline/base16_atelierdune.bash new file mode 100644 index 0000000..2f45dff --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_atelierdune.bash @@ -0,0 +1,25 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_atelierdune.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# vim-airline template by chartoin (http://github.com/chartoin) +# Base 16 Atelier Dune Scheme by Bram de Haan (http://atelierbram.github.io/syntax-highlighting/atelier-schemes/dune) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_atelierdune/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=235,bg=71 # fg=#292824,bg=#60ac39 + ble-face -s vim_airline_a_inactive fg=144,bg=235 # fg=#a6a28c,bg=#292824 + ble-face -s vim_airline_a_insert fg=235,bg=68 # fg=#292824,bg=#6684e1 + ble-face -s vim_airline_a_replace fg=235,bg=167 # fg=#292824,bg=#d73737 + ble-face -s vim_airline_a_visual fg=235,bg=134 # fg=#292824,bg=#b854d4 + ble-face -s vim_airline_b fg=253,bg=242 # fg=#e8e4cf,bg=#6e6b5e + ble-face -s vim_airline_b_inactive fg=144,bg=235 # fg=#a6a28c,bg=#292824 + ble-face -s vim_airline_c fg=130,bg=235 # fg=#b65611,bg=#292824 + ble-face -s vim_airline_c_inactive fg=144,bg=235 # fg=#a6a28c,bg=#292824 + ble-face -s vim_airline_error fg=231,bg=167 # fg=#fefbec,bg=#d73737 + ble-face -s vim_airline_error_inactive fg=16,bg=88 # fg=#000000,bg=#990000 + ble-face -s vim_airline_warning fg=235,bg=178 # fg=#292824,bg=#cfb017 + ble-face -s vim_airline_warning_inactive fg=16,bg=166 # fg=#000000,bg=#df5f00 +} diff --git a/.local/share/blesh/contrib/airline/base16_atelierforest.bash b/.local/share/blesh/contrib/airline/base16_atelierforest.bash new file mode 100644 index 0000000..ba6b9a0 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_atelierforest.bash @@ -0,0 +1,21 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_atelierforest.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# vim-airline template by chartoin (http://github.com/chartoin) +# Base 16 Atelier Forest Scheme by Bram de Haan (http://atelierbram.github.io/syntax-highlighting/atelier-schemes/forest) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_atelierforest/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=235,bg=71 # fg=#2c2421,bg=#5ab738 + ble-face -s vim_airline_a_inactive fg=248,bg=235 # fg=#a8a19f,bg=#2c2421 + ble-face -s vim_airline_a_insert fg=235,bg=68 # fg=#2c2421,bg=#407ee7 + ble-face -s vim_airline_a_replace fg=235,bg=197 # fg=#2c2421,bg=#f22c40 + ble-face -s vim_airline_a_visual fg=235,bg=62 # fg=#2c2421,bg=#6666ea + ble-face -s vim_airline_b fg=254,bg=241 # fg=#e6e2e0,bg=#68615e + ble-face -s vim_airline_b_inactive fg=248,bg=235 # fg=#a8a19f,bg=#2c2421 + ble-face -s vim_airline_c fg=166,bg=235 # fg=#df5320,bg=#2c2421 + ble-face -s vim_airline_c_inactive fg=248,bg=235 # fg=#a8a19f,bg=#2c2421 +} diff --git a/.local/share/blesh/contrib/airline/base16_atelierheath.bash b/.local/share/blesh/contrib/airline/base16_atelierheath.bash new file mode 100644 index 0000000..d980649 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_atelierheath.bash @@ -0,0 +1,21 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_atelierheath.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# vim-airline template by chartoin (http://github.com/chartoin) +# Base 16 Atelier Heath Scheme by Bram de Haan (http://atelierbram.github.io/syntax-highlighting/atelier-schemes/heath) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_atelierheath/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=235,bg=65 # fg=#292329,bg=#379a37 + ble-face -s vim_airline_a_inactive fg=248,bg=235 # fg=#ab9bab,bg=#292329 + ble-face -s vim_airline_a_insert fg=235,bg=63 # fg=#292329,bg=#516aec + ble-face -s vim_airline_a_replace fg=235,bg=166 # fg=#292329,bg=#ca402b + ble-face -s vim_airline_a_visual fg=235,bg=97 # fg=#292329,bg=#7b59c0 + ble-face -s vim_airline_b fg=252,bg=241 # fg=#d8cad8,bg=#695d69 + ble-face -s vim_airline_b_inactive fg=248,bg=235 # fg=#ab9bab,bg=#292329 + ble-face -s vim_airline_c fg=130,bg=235 # fg=#a65926,bg=#292329 + ble-face -s vim_airline_c_inactive fg=248,bg=235 # fg=#ab9bab,bg=#292329 +} diff --git a/.local/share/blesh/contrib/airline/base16_atelierlakeside.bash b/.local/share/blesh/contrib/airline/base16_atelierlakeside.bash new file mode 100644 index 0000000..158311c --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_atelierlakeside.bash @@ -0,0 +1,21 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_atelierlakeside.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# vim-airline template by chartoin (http://github.com/chartoin) +# Base 16 Atelier Lakeside Scheme by Bram de Haan (http://atelierbram.github.io/syntax-highlighting/atelier-schemes/lakeside/) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_atelierlakeside/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=235,bg=65 # fg=#1f292e,bg=#568c3b + ble-face -s vim_airline_a_inactive fg=109,bg=235 # fg=#7ea2b4,bg=#1f292e + ble-face -s vim_airline_a_insert fg=235,bg=31 # fg=#1f292e,bg=#257fad + ble-face -s vim_airline_a_replace fg=235,bg=161 # fg=#1f292e,bg=#d22d72 + ble-face -s vim_airline_a_visual fg=235,bg=61 # fg=#1f292e,bg=#5d5db1 + ble-face -s vim_airline_b fg=153,bg=60 # fg=#c1e4f6,bg=#516d7b + ble-face -s vim_airline_b_inactive fg=109,bg=235 # fg=#7ea2b4,bg=#1f292e + ble-face -s vim_airline_c fg=94,bg=235 # fg=#935c25,bg=#1f292e + ble-face -s vim_airline_c_inactive fg=109,bg=235 # fg=#7ea2b4,bg=#1f292e +} diff --git a/.local/share/blesh/contrib/airline/base16_atelierseaside.bash b/.local/share/blesh/contrib/airline/base16_atelierseaside.bash new file mode 100644 index 0000000..cc6232b --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_atelierseaside.bash @@ -0,0 +1,21 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_atelierseaside.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# vim-airline template by chartoin (http://github.com/chartoin) +# Base 16 Atelier Seaside Scheme by Bram de Haan (http://atelierbram.github.io/syntax-highlighting/atelier-schemes/seaside/) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_atelierseaside/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=235,bg=34 # fg=#242924,bg=#29a329 + ble-face -s vim_airline_a_inactive fg=108,bg=235 # fg=#8ca68c,bg=#242924 + ble-face -s vim_airline_a_insert fg=235,bg=63 # fg=#242924,bg=#3d62f5 + ble-face -s vim_airline_a_replace fg=235,bg=161 # fg=#242924,bg=#e6193c + ble-face -s vim_airline_a_visual fg=235,bg=129 # fg=#242924,bg=#ad2bee + ble-face -s vim_airline_b fg=191,bg=241 # fg=#cfe8cf,bg=#5e6e5e + ble-face -s vim_airline_b_inactive fg=108,bg=235 # fg=#8ca68c,bg=#242924 + ble-face -s vim_airline_c fg=94,bg=235 # fg=#87711d,bg=#242924 + ble-face -s vim_airline_c_inactive fg=108,bg=235 # fg=#8ca68c,bg=#242924 +} diff --git a/.local/share/blesh/contrib/airline/base16_atlas.bash b/.local/share/blesh/contrib/airline/base16_atlas.bash new file mode 100644 index 0000000..985522e --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_atlas.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_atlas.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Atlas vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Alex Lende (https://ajlende.com) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_atlas/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=23,bg=246 # fg=#00384d,bg=#869696 + ble-face -s vim_airline_a_inactive fg=23,bg=23 # fg=#00384d,bg=#00384d + ble-face -s vim_airline_a_insert fg=23,bg=107 # fg=#00384d,bg=#7fc06e + ble-face -s vim_airline_a_replace fg=23,bg=97 # fg=#00384d,bg=#9a70a4 + ble-face -s vim_airline_a_visual fg=23,bg=209 # fg=#00384d,bg=#f08e48 + ble-face -s vim_airline_b fg=246,bg=66 # fg=#869696,bg=#517f8d + ble-face -s vim_airline_b_inactive fg=246,bg=23 # fg=#869696,bg=#00384d + ble-face -s vim_airline_c fg=246,bg=23 # fg=#869696,bg=#00384d + ble-face -s vim_airline_c_inactive fg=144,bg=23 # fg=#a1a19a,bg=#00384d + ble-face -s vim_airline_c_insert_modified fg=231,bg=23 # fg=#fafaf8,bg=#00384d + ble-face -s vim_airline_c_normal_modified fg=231,bg=23 # fg=#fafaf8,bg=#00384d + ble-face -s vim_airline_c_replace_modified fg=231,bg=23 # fg=#fafaf8,bg=#00384d + ble-face -s vim_airline_c_visual_modified fg=231,bg=23 # fg=#fafaf8,bg=#00384d +} diff --git a/.local/share/blesh/contrib/airline/base16_bespin.bash b/.local/share/blesh/contrib/airline/base16_bespin.bash new file mode 100644 index 0000000..bf38499 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_bespin.bash @@ -0,0 +1,21 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_bespin.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# vim-airline template by chartoin (http://github.com/chartoin) +# Base 16 Bespin Scheme by Jan T. Sott + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_bespin/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=58,bg=70 # fg=#36312e,bg=#54be0d + ble-face -s vim_airline_a_inactive fg=106,bg=58 # fg=#8a8986,bg=#36312e + ble-face -s vim_airline_a_insert fg=58,bg=74 # fg=#36312e,bg=#5ea6ea + ble-face -s vim_airline_a_replace fg=58,bg=167 # fg=#36312e,bg=#cf6a4c + ble-face -s vim_airline_a_visual fg=58,bg=139 # fg=#36312e,bg=#9b859d + ble-face -s vim_airline_b fg=144,bg=60 # fg=#9d9b97,bg=#5e5d5c + ble-face -s vim_airline_b_inactive fg=106,bg=58 # fg=#8a8986,bg=#36312e + ble-face -s vim_airline_c fg=173,bg=58 # fg=#cf7d34,bg=#36312e + ble-face -s vim_airline_c_inactive fg=106,bg=58 # fg=#8a8986,bg=#36312e +} diff --git a/.local/share/blesh/contrib/airline/base16_black_metal.bash b/.local/share/blesh/contrib/airline/base16_black_metal.bash new file mode 100644 index 0000000..efe0aca --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_black_metal.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_black_metal.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Black Metal vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By metalelf0 (https://github.com/metalelf0) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_black_metal/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=233,bg=247 # fg=#121212,bg=#999999 + ble-face -s vim_airline_a_inactive fg=233,bg=233 # fg=#121212,bg=#121212 + ble-face -s vim_airline_a_insert fg=233,bg=174 # fg=#121212,bg=#dd9999 + ble-face -s vim_airline_a_replace fg=233,bg=247 # fg=#121212,bg=#999999 + ble-face -s vim_airline_a_visual fg=233,bg=248 # fg=#121212,bg=#aaaaaa + ble-face -s vim_airline_b fg=247,bg=235 # fg=#999999,bg=#222222 + ble-face -s vim_airline_b_inactive fg=247,bg=233 # fg=#999999,bg=#121212 + ble-face -s vim_airline_c fg=247,bg=233 # fg=#999999,bg=#121212 + ble-face -s vim_airline_c_inactive fg=251,bg=233 # fg=#c1c1c1,bg=#121212 + ble-face -s vim_airline_c_insert_modified fg=251,bg=233 # fg=#c1c1c1,bg=#121212 + ble-face -s vim_airline_c_normal_modified fg=251,bg=233 # fg=#c1c1c1,bg=#121212 + ble-face -s vim_airline_c_replace_modified fg=251,bg=233 # fg=#c1c1c1,bg=#121212 + ble-face -s vim_airline_c_visual_modified fg=251,bg=233 # fg=#c1c1c1,bg=#121212 +} diff --git a/.local/share/blesh/contrib/airline/base16_black_metal_bathory.bash b/.local/share/blesh/contrib/airline/base16_black_metal_bathory.bash new file mode 100644 index 0000000..6de3f96 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_black_metal_bathory.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_black_metal_bathory.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Black Metal (Bathory) vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By metalelf0 (https://github.com/metalelf0) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_black_metal_bathory/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=233,bg=247 # fg=#121212,bg=#999999 + ble-face -s vim_airline_a_inactive fg=233,bg=233 # fg=#121212,bg=#121212 + ble-face -s vim_airline_a_insert fg=233,bg=222 # fg=#121212,bg=#fbcb97 + ble-face -s vim_airline_a_replace fg=233,bg=247 # fg=#121212,bg=#999999 + ble-face -s vim_airline_a_visual fg=233,bg=248 # fg=#121212,bg=#aaaaaa + ble-face -s vim_airline_b fg=247,bg=235 # fg=#999999,bg=#222222 + ble-face -s vim_airline_b_inactive fg=247,bg=233 # fg=#999999,bg=#121212 + ble-face -s vim_airline_c fg=247,bg=233 # fg=#999999,bg=#121212 + ble-face -s vim_airline_c_inactive fg=251,bg=233 # fg=#c1c1c1,bg=#121212 + ble-face -s vim_airline_c_insert_modified fg=251,bg=233 # fg=#c1c1c1,bg=#121212 + ble-face -s vim_airline_c_normal_modified fg=251,bg=233 # fg=#c1c1c1,bg=#121212 + ble-face -s vim_airline_c_replace_modified fg=251,bg=233 # fg=#c1c1c1,bg=#121212 + ble-face -s vim_airline_c_visual_modified fg=251,bg=233 # fg=#c1c1c1,bg=#121212 +} diff --git a/.local/share/blesh/contrib/airline/base16_black_metal_burzum.bash b/.local/share/blesh/contrib/airline/base16_black_metal_burzum.bash new file mode 100644 index 0000000..b469f85 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_black_metal_burzum.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_black_metal_burzum.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Black Metal (Burzum) vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By metalelf0 (https://github.com/metalelf0) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_black_metal_burzum/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=233,bg=247 # fg=#121212,bg=#999999 + ble-face -s vim_airline_a_inactive fg=233,bg=233 # fg=#121212,bg=#121212 + ble-face -s vim_airline_a_insert fg=233,bg=194 # fg=#121212,bg=#ddeecc + ble-face -s vim_airline_a_replace fg=233,bg=247 # fg=#121212,bg=#999999 + ble-face -s vim_airline_a_visual fg=233,bg=248 # fg=#121212,bg=#aaaaaa + ble-face -s vim_airline_b fg=247,bg=235 # fg=#999999,bg=#222222 + ble-face -s vim_airline_b_inactive fg=247,bg=233 # fg=#999999,bg=#121212 + ble-face -s vim_airline_c fg=247,bg=233 # fg=#999999,bg=#121212 + ble-face -s vim_airline_c_inactive fg=251,bg=233 # fg=#c1c1c1,bg=#121212 + ble-face -s vim_airline_c_insert_modified fg=251,bg=233 # fg=#c1c1c1,bg=#121212 + ble-face -s vim_airline_c_normal_modified fg=251,bg=233 # fg=#c1c1c1,bg=#121212 + ble-face -s vim_airline_c_replace_modified fg=251,bg=233 # fg=#c1c1c1,bg=#121212 + ble-face -s vim_airline_c_visual_modified fg=251,bg=233 # fg=#c1c1c1,bg=#121212 +} diff --git a/.local/share/blesh/contrib/airline/base16_black_metal_dark_funeral.bash b/.local/share/blesh/contrib/airline/base16_black_metal_dark_funeral.bash new file mode 100644 index 0000000..87f02d7 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_black_metal_dark_funeral.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_black_metal_dark_funeral.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Black Metal (Dark Funeral) vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By metalelf0 (https://github.com/metalelf0) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_black_metal_dark_funeral/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=233,bg=247 # fg=#121212,bg=#999999 + ble-face -s vim_airline_a_inactive fg=233,bg=233 # fg=#121212,bg=#121212 + ble-face -s vim_airline_a_insert fg=233,bg=189 # fg=#121212,bg=#d0dfee + ble-face -s vim_airline_a_replace fg=233,bg=247 # fg=#121212,bg=#999999 + ble-face -s vim_airline_a_visual fg=233,bg=248 # fg=#121212,bg=#aaaaaa + ble-face -s vim_airline_b fg=247,bg=235 # fg=#999999,bg=#222222 + ble-face -s vim_airline_b_inactive fg=247,bg=233 # fg=#999999,bg=#121212 + ble-face -s vim_airline_c fg=247,bg=233 # fg=#999999,bg=#121212 + ble-face -s vim_airline_c_inactive fg=251,bg=233 # fg=#c1c1c1,bg=#121212 + ble-face -s vim_airline_c_insert_modified fg=251,bg=233 # fg=#c1c1c1,bg=#121212 + ble-face -s vim_airline_c_normal_modified fg=251,bg=233 # fg=#c1c1c1,bg=#121212 + ble-face -s vim_airline_c_replace_modified fg=251,bg=233 # fg=#c1c1c1,bg=#121212 + ble-face -s vim_airline_c_visual_modified fg=251,bg=233 # fg=#c1c1c1,bg=#121212 +} diff --git a/.local/share/blesh/contrib/airline/base16_black_metal_gorgoroth.bash b/.local/share/blesh/contrib/airline/base16_black_metal_gorgoroth.bash new file mode 100644 index 0000000..c41320a --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_black_metal_gorgoroth.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_black_metal_gorgoroth.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Black Metal (Gorgoroth) vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By metalelf0 (https://github.com/metalelf0) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_black_metal_gorgoroth/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=233,bg=247 # fg=#121212,bg=#999999 + ble-face -s vim_airline_a_inactive fg=233,bg=233 # fg=#121212,bg=#121212 + ble-face -s vim_airline_a_insert fg=233,bg=138 # fg=#121212,bg=#9b8d7f + ble-face -s vim_airline_a_replace fg=233,bg=247 # fg=#121212,bg=#999999 + ble-face -s vim_airline_a_visual fg=233,bg=248 # fg=#121212,bg=#aaaaaa + ble-face -s vim_airline_b fg=247,bg=235 # fg=#999999,bg=#222222 + ble-face -s vim_airline_b_inactive fg=247,bg=233 # fg=#999999,bg=#121212 + ble-face -s vim_airline_c fg=247,bg=233 # fg=#999999,bg=#121212 + ble-face -s vim_airline_c_inactive fg=251,bg=233 # fg=#c1c1c1,bg=#121212 + ble-face -s vim_airline_c_insert_modified fg=251,bg=233 # fg=#c1c1c1,bg=#121212 + ble-face -s vim_airline_c_normal_modified fg=251,bg=233 # fg=#c1c1c1,bg=#121212 + ble-face -s vim_airline_c_replace_modified fg=251,bg=233 # fg=#c1c1c1,bg=#121212 + ble-face -s vim_airline_c_visual_modified fg=251,bg=233 # fg=#c1c1c1,bg=#121212 +} diff --git a/.local/share/blesh/contrib/airline/base16_black_metal_immortal.bash b/.local/share/blesh/contrib/airline/base16_black_metal_immortal.bash new file mode 100644 index 0000000..c3911cb --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_black_metal_immortal.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_black_metal_immortal.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Black Metal (Immortal) vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By metalelf0 (https://github.com/metalelf0) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_black_metal_immortal/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=233,bg=247 # fg=#121212,bg=#999999 + ble-face -s vim_airline_a_inactive fg=233,bg=233 # fg=#121212,bg=#121212 + ble-face -s vim_airline_a_insert fg=233,bg=103 # fg=#121212,bg=#7799bb + ble-face -s vim_airline_a_replace fg=233,bg=247 # fg=#121212,bg=#999999 + ble-face -s vim_airline_a_visual fg=233,bg=248 # fg=#121212,bg=#aaaaaa + ble-face -s vim_airline_b fg=247,bg=235 # fg=#999999,bg=#222222 + ble-face -s vim_airline_b_inactive fg=247,bg=233 # fg=#999999,bg=#121212 + ble-face -s vim_airline_c fg=247,bg=233 # fg=#999999,bg=#121212 + ble-face -s vim_airline_c_inactive fg=251,bg=233 # fg=#c1c1c1,bg=#121212 + ble-face -s vim_airline_c_insert_modified fg=251,bg=233 # fg=#c1c1c1,bg=#121212 + ble-face -s vim_airline_c_normal_modified fg=251,bg=233 # fg=#c1c1c1,bg=#121212 + ble-face -s vim_airline_c_replace_modified fg=251,bg=233 # fg=#c1c1c1,bg=#121212 + ble-face -s vim_airline_c_visual_modified fg=251,bg=233 # fg=#c1c1c1,bg=#121212 +} diff --git a/.local/share/blesh/contrib/airline/base16_black_metal_khold.bash b/.local/share/blesh/contrib/airline/base16_black_metal_khold.bash new file mode 100644 index 0000000..9403421 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_black_metal_khold.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_black_metal_khold.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Black Metal (Khold) vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By metalelf0 (https://github.com/metalelf0) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_black_metal_khold/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=233,bg=247 # fg=#121212,bg=#999999 + ble-face -s vim_airline_a_inactive fg=233,bg=233 # fg=#121212,bg=#121212 + ble-face -s vim_airline_a_insert fg=233,bg=230 # fg=#121212,bg=#eceee3 + ble-face -s vim_airline_a_replace fg=233,bg=247 # fg=#121212,bg=#999999 + ble-face -s vim_airline_a_visual fg=233,bg=248 # fg=#121212,bg=#aaaaaa + ble-face -s vim_airline_b fg=247,bg=235 # fg=#999999,bg=#222222 + ble-face -s vim_airline_b_inactive fg=247,bg=233 # fg=#999999,bg=#121212 + ble-face -s vim_airline_c fg=247,bg=233 # fg=#999999,bg=#121212 + ble-face -s vim_airline_c_inactive fg=251,bg=233 # fg=#c1c1c1,bg=#121212 + ble-face -s vim_airline_c_insert_modified fg=251,bg=233 # fg=#c1c1c1,bg=#121212 + ble-face -s vim_airline_c_normal_modified fg=251,bg=233 # fg=#c1c1c1,bg=#121212 + ble-face -s vim_airline_c_replace_modified fg=251,bg=233 # fg=#c1c1c1,bg=#121212 + ble-face -s vim_airline_c_visual_modified fg=251,bg=233 # fg=#c1c1c1,bg=#121212 +} diff --git a/.local/share/blesh/contrib/airline/base16_black_metal_marduk.bash b/.local/share/blesh/contrib/airline/base16_black_metal_marduk.bash new file mode 100644 index 0000000..214c13e --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_black_metal_marduk.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_black_metal_marduk.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Black Metal (Marduk) vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By metalelf0 (https://github.com/metalelf0) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_black_metal_marduk/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=233,bg=247 # fg=#121212,bg=#999999 + ble-face -s vim_airline_a_inactive fg=233,bg=233 # fg=#121212,bg=#121212 + ble-face -s vim_airline_a_insert fg=233,bg=248 # fg=#121212,bg=#a5aaa7 + ble-face -s vim_airline_a_replace fg=233,bg=247 # fg=#121212,bg=#999999 + ble-face -s vim_airline_a_visual fg=233,bg=248 # fg=#121212,bg=#aaaaaa + ble-face -s vim_airline_b fg=247,bg=235 # fg=#999999,bg=#222222 + ble-face -s vim_airline_b_inactive fg=247,bg=233 # fg=#999999,bg=#121212 + ble-face -s vim_airline_c fg=247,bg=233 # fg=#999999,bg=#121212 + ble-face -s vim_airline_c_inactive fg=251,bg=233 # fg=#c1c1c1,bg=#121212 + ble-face -s vim_airline_c_insert_modified fg=251,bg=233 # fg=#c1c1c1,bg=#121212 + ble-face -s vim_airline_c_normal_modified fg=251,bg=233 # fg=#c1c1c1,bg=#121212 + ble-face -s vim_airline_c_replace_modified fg=251,bg=233 # fg=#c1c1c1,bg=#121212 + ble-face -s vim_airline_c_visual_modified fg=251,bg=233 # fg=#c1c1c1,bg=#121212 +} diff --git a/.local/share/blesh/contrib/airline/base16_black_metal_mayhem.bash b/.local/share/blesh/contrib/airline/base16_black_metal_mayhem.bash new file mode 100644 index 0000000..6768fe4 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_black_metal_mayhem.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_black_metal_mayhem.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Black Metal (Mayhem) vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By metalelf0 (https://github.com/metalelf0) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_black_metal_mayhem/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=233,bg=247 # fg=#121212,bg=#999999 + ble-face -s vim_airline_a_inactive fg=233,bg=233 # fg=#121212,bg=#121212 + ble-face -s vim_airline_a_insert fg=233,bg=230 # fg=#121212,bg=#f3ecd4 + ble-face -s vim_airline_a_replace fg=233,bg=247 # fg=#121212,bg=#999999 + ble-face -s vim_airline_a_visual fg=233,bg=248 # fg=#121212,bg=#aaaaaa + ble-face -s vim_airline_b fg=247,bg=235 # fg=#999999,bg=#222222 + ble-face -s vim_airline_b_inactive fg=247,bg=233 # fg=#999999,bg=#121212 + ble-face -s vim_airline_c fg=247,bg=233 # fg=#999999,bg=#121212 + ble-face -s vim_airline_c_inactive fg=251,bg=233 # fg=#c1c1c1,bg=#121212 + ble-face -s vim_airline_c_insert_modified fg=251,bg=233 # fg=#c1c1c1,bg=#121212 + ble-face -s vim_airline_c_normal_modified fg=251,bg=233 # fg=#c1c1c1,bg=#121212 + ble-face -s vim_airline_c_replace_modified fg=251,bg=233 # fg=#c1c1c1,bg=#121212 + ble-face -s vim_airline_c_visual_modified fg=251,bg=233 # fg=#c1c1c1,bg=#121212 +} diff --git a/.local/share/blesh/contrib/airline/base16_black_metal_nile.bash b/.local/share/blesh/contrib/airline/base16_black_metal_nile.bash new file mode 100644 index 0000000..f71d799 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_black_metal_nile.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_black_metal_nile.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Black Metal (Nile) vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By metalelf0 (https://github.com/metalelf0) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_black_metal_nile/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=233,bg=247 # fg=#121212,bg=#999999 + ble-face -s vim_airline_a_inactive fg=233,bg=233 # fg=#121212,bg=#121212 + ble-face -s vim_airline_a_insert fg=233,bg=138 # fg=#121212,bg=#aa9988 + ble-face -s vim_airline_a_replace fg=233,bg=247 # fg=#121212,bg=#999999 + ble-face -s vim_airline_a_visual fg=233,bg=248 # fg=#121212,bg=#aaaaaa + ble-face -s vim_airline_b fg=247,bg=235 # fg=#999999,bg=#222222 + ble-face -s vim_airline_b_inactive fg=247,bg=233 # fg=#999999,bg=#121212 + ble-face -s vim_airline_c fg=247,bg=233 # fg=#999999,bg=#121212 + ble-face -s vim_airline_c_inactive fg=251,bg=233 # fg=#c1c1c1,bg=#121212 + ble-face -s vim_airline_c_insert_modified fg=251,bg=233 # fg=#c1c1c1,bg=#121212 + ble-face -s vim_airline_c_normal_modified fg=251,bg=233 # fg=#c1c1c1,bg=#121212 + ble-face -s vim_airline_c_replace_modified fg=251,bg=233 # fg=#c1c1c1,bg=#121212 + ble-face -s vim_airline_c_visual_modified fg=251,bg=233 # fg=#c1c1c1,bg=#121212 +} diff --git a/.local/share/blesh/contrib/airline/base16_black_metal_venom.bash b/.local/share/blesh/contrib/airline/base16_black_metal_venom.bash new file mode 100644 index 0000000..9efaf19 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_black_metal_venom.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_black_metal_venom.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Black Metal (Venom) vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By metalelf0 (https://github.com/metalelf0) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_black_metal_venom/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=233,bg=247 # fg=#121212,bg=#999999 + ble-face -s vim_airline_a_inactive fg=233,bg=233 # fg=#121212,bg=#121212 + ble-face -s vim_airline_a_insert fg=233,bg=255 # fg=#121212,bg=#f8f7f2 + ble-face -s vim_airline_a_replace fg=233,bg=247 # fg=#121212,bg=#999999 + ble-face -s vim_airline_a_visual fg=233,bg=248 # fg=#121212,bg=#aaaaaa + ble-face -s vim_airline_b fg=247,bg=235 # fg=#999999,bg=#222222 + ble-face -s vim_airline_b_inactive fg=247,bg=233 # fg=#999999,bg=#121212 + ble-face -s vim_airline_c fg=247,bg=233 # fg=#999999,bg=#121212 + ble-face -s vim_airline_c_inactive fg=251,bg=233 # fg=#c1c1c1,bg=#121212 + ble-face -s vim_airline_c_insert_modified fg=251,bg=233 # fg=#c1c1c1,bg=#121212 + ble-face -s vim_airline_c_normal_modified fg=251,bg=233 # fg=#c1c1c1,bg=#121212 + ble-face -s vim_airline_c_replace_modified fg=251,bg=233 # fg=#c1c1c1,bg=#121212 + ble-face -s vim_airline_c_visual_modified fg=251,bg=233 # fg=#c1c1c1,bg=#121212 +} diff --git a/.local/share/blesh/contrib/airline/base16_brewer.bash b/.local/share/blesh/contrib/airline/base16_brewer.bash new file mode 100644 index 0000000..878991d --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_brewer.bash @@ -0,0 +1,21 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_brewer.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# vim-airline template by chartoin (http://github.com/chartoin) +# Base 16 Brewer Scheme by Timothée Poisot (http://github.com/tpoisot) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_brewer/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=17,bg=71 # fg=#2e2f30,bg=#31a354 + ble-face -s vim_airline_a_inactive fg=250,bg=17 # fg=#b7b8b9,bg=#2e2f30 + ble-face -s vim_airline_a_insert fg=17,bg=67 # fg=#2e2f30,bg=#3182bd + ble-face -s vim_airline_a_replace fg=17,bg=160 # fg=#2e2f30,bg=#e31a1c + ble-face -s vim_airline_a_visual fg=17,bg=97 # fg=#2e2f30,bg=#756bb1 + ble-face -s vim_airline_b fg=253,bg=239 # fg=#dadbdc,bg=#515253 + ble-face -s vim_airline_b_inactive fg=250,bg=17 # fg=#b7b8b9,bg=#2e2f30 + ble-face -s vim_airline_c fg=166,bg=17 # fg=#e6550d,bg=#2e2f30 + ble-face -s vim_airline_c_inactive fg=250,bg=17 # fg=#b7b8b9,bg=#2e2f30 +} diff --git a/.local/share/blesh/contrib/airline/base16_bright.bash b/.local/share/blesh/contrib/airline/base16_bright.bash new file mode 100644 index 0000000..7ff5915 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_bright.bash @@ -0,0 +1,21 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_bright.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# vim-airline template by chartoin (http://github.com/chartoin) +# Base 16 Bright Scheme by Chris Kempson (http://chriskempson.com) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_bright/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=236,bg=149 # fg=#303030,bg=#a1c659 + ble-face -s vim_airline_a_inactive fg=254,bg=236 # fg=#e0e0e0,bg=#303030 + ble-face -s vim_airline_a_insert fg=236,bg=74 # fg=#303030,bg=#6fb3d2 + ble-face -s vim_airline_a_replace fg=236,bg=196 # fg=#303030,bg=#fb0120 + ble-face -s vim_airline_a_visual fg=236,bg=176 # fg=#303030,bg=#d381c3 + ble-face -s vim_airline_b fg=255,bg=239 # fg=#f5f5f5,bg=#505050 + ble-face -s vim_airline_b_inactive fg=254,bg=236 # fg=#e0e0e0,bg=#303030 + ble-face -s vim_airline_c fg=202,bg=236 # fg=#fc6d24,bg=#303030 + ble-face -s vim_airline_c_inactive fg=254,bg=236 # fg=#e0e0e0,bg=#303030 +} diff --git a/.local/share/blesh/contrib/airline/base16_brogrammer.bash b/.local/share/blesh/contrib/airline/base16_brogrammer.bash new file mode 100644 index 0000000..fbf83de --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_brogrammer.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_brogrammer.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Brogrammer vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Vik Ramanujam (http://github.com/piggyslasher) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_brogrammer/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=196,bg=32 # fg=#f81118,bg=#2a84d2 + ble-face -s vim_airline_a_inactive fg=196,bg=196 # fg=#f81118,bg=#f81118 + ble-face -s vim_airline_a_insert fg=196,bg=214 # fg=#f81118,bg=#f3bd09 + ble-face -s vim_airline_a_replace fg=196,bg=32 # fg=#f81118,bg=#0f7ddb + ble-face -s vim_airline_a_visual fg=196,bg=166 # fg=#f81118,bg=#de352e + ble-face -s vim_airline_b fg=32,bg=41 # fg=#2a84d2,bg=#2dc55e + ble-face -s vim_airline_b_inactive fg=32,bg=196 # fg=#2a84d2,bg=#f81118 + ble-face -s vim_airline_c fg=32,bg=196 # fg=#2a84d2,bg=#f81118 + ble-face -s vim_airline_c_inactive fg=61,bg=196 # fg=#4e5ab7,bg=#f81118 + ble-face -s vim_airline_c_insert_modified fg=253,bg=196 # fg=#d6dbe5,bg=#f81118 + ble-face -s vim_airline_c_normal_modified fg=253,bg=196 # fg=#d6dbe5,bg=#f81118 + ble-face -s vim_airline_c_replace_modified fg=253,bg=196 # fg=#d6dbe5,bg=#f81118 + ble-face -s vim_airline_c_visual_modified fg=253,bg=196 # fg=#d6dbe5,bg=#f81118 +} diff --git a/.local/share/blesh/contrib/airline/base16_brushtrees.bash b/.local/share/blesh/contrib/airline/base16_brushtrees.bash new file mode 100644 index 0000000..66b2f18 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_brushtrees.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_brushtrees.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Brush Trees vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Abraham White <abelincoln.white@gmail.com> + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_brushtrees/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=189,bg=103 # fg=#c9dbdc,bg=#8299a1 + ble-face -s vim_airline_a_inactive fg=189,bg=189 # fg=#c9dbdc,bg=#c9dbdc + ble-face -s vim_airline_a_insert fg=189,bg=108 # fg=#c9dbdc,bg=#87b386 + ble-face -s vim_airline_a_replace fg=189,bg=139 # fg=#c9dbdc,bg=#b386b2 + ble-face -s vim_airline_a_visual fg=189,bg=181 # fg=#c9dbdc,bg=#d8bba2 + ble-face -s vim_airline_b fg=103,bg=152 # fg=#8299a1,bg=#b0c5c8 + ble-face -s vim_airline_b_inactive fg=103,bg=189 # fg=#8299a1,bg=#c9dbdc + ble-face -s vim_airline_c fg=103,bg=189 # fg=#8299a1,bg=#c9dbdc + ble-face -s vim_airline_c_inactive fg=66,bg=189 # fg=#6d828e,bg=#c9dbdc + ble-face -s vim_airline_c_insert_modified fg=240,bg=189 # fg=#485867,bg=#c9dbdc + ble-face -s vim_airline_c_normal_modified fg=240,bg=189 # fg=#485867,bg=#c9dbdc + ble-face -s vim_airline_c_replace_modified fg=240,bg=189 # fg=#485867,bg=#c9dbdc + ble-face -s vim_airline_c_visual_modified fg=240,bg=189 # fg=#485867,bg=#c9dbdc +} diff --git a/.local/share/blesh/contrib/airline/base16_brushtrees_dark.bash b/.local/share/blesh/contrib/airline/base16_brushtrees_dark.bash new file mode 100644 index 0000000..072b361 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_brushtrees_dark.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_brushtrees_dark.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Brush Trees Dark vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Abraham White <abelincoln.white@gmail.com> + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_brushtrees_dark/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=60,bg=109 # fg=#5a6d7a,bg=#98afb5 + ble-face -s vim_airline_a_inactive fg=60,bg=60 # fg=#5a6d7a,bg=#5a6d7a + ble-face -s vim_airline_a_insert fg=60,bg=108 # fg=#5a6d7a,bg=#87b386 + ble-face -s vim_airline_a_replace fg=60,bg=139 # fg=#5a6d7a,bg=#b386b2 + ble-face -s vim_airline_a_visual fg=60,bg=181 # fg=#5a6d7a,bg=#d8bba2 + ble-face -s vim_airline_b fg=109,bg=66 # fg=#98afb5,bg=#6d828e + ble-face -s vim_airline_b_inactive fg=109,bg=60 # fg=#98afb5,bg=#5a6d7a + ble-face -s vim_airline_c fg=109,bg=60 # fg=#98afb5,bg=#5a6d7a + ble-face -s vim_airline_c_inactive fg=152,bg=60 # fg=#b0c5c8,bg=#5a6d7a + ble-face -s vim_airline_c_insert_modified fg=195,bg=60 # fg=#e3efef,bg=#5a6d7a + ble-face -s vim_airline_c_normal_modified fg=195,bg=60 # fg=#e3efef,bg=#5a6d7a + ble-face -s vim_airline_c_replace_modified fg=195,bg=60 # fg=#e3efef,bg=#5a6d7a + ble-face -s vim_airline_c_visual_modified fg=195,bg=60 # fg=#e3efef,bg=#5a6d7a +} diff --git a/.local/share/blesh/contrib/airline/base16_chalk.bash b/.local/share/blesh/contrib/airline/base16_chalk.bash new file mode 100644 index 0000000..76bedb4 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_chalk.bash @@ -0,0 +1,21 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_chalk.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# vim-airline template by chartoin (http://github.com/chartoin) +# Base 16 Chalk Scheme by Chris Kempson (http://chriskempson.com) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_chalk/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=234,bg=143 # fg=#202020,bg=#acc267 + ble-face -s vim_airline_a_inactive fg=252,bg=234 # fg=#d0d0d0,bg=#202020 + ble-face -s vim_airline_a_insert fg=234,bg=75 # fg=#202020,bg=#6fc2ef + ble-face -s vim_airline_a_replace fg=234,bg=217 # fg=#202020,bg=#fb9fb1 + ble-face -s vim_airline_a_visual fg=234,bg=183 # fg=#202020,bg=#e1a3ee + ble-face -s vim_airline_b fg=254,bg=236 # fg=#e0e0e0,bg=#303030 + ble-face -s vim_airline_b_inactive fg=252,bg=234 # fg=#d0d0d0,bg=#202020 + ble-face -s vim_airline_c fg=216,bg=234 # fg=#eda987,bg=#202020 + ble-face -s vim_airline_c_inactive fg=252,bg=234 # fg=#d0d0d0,bg=#202020 +} diff --git a/.local/share/blesh/contrib/airline/base16_circus.bash b/.local/share/blesh/contrib/airline/base16_circus.bash new file mode 100644 index 0000000..e87daa4 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_circus.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_circus.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Circus vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Stephan Boyer (https://github.com/stepchowfun) and Esther Wang (https://github.com/ewang12) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_circus/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=234,bg=239 # fg=#202020,bg=#505050 + ble-face -s vim_airline_a_inactive fg=234,bg=234 # fg=#202020,bg=#202020 + ble-face -s vim_airline_a_insert fg=234,bg=108 # fg=#202020,bg=#84b97c + ble-face -s vim_airline_a_replace fg=234,bg=140 # fg=#202020,bg=#b888e2 + ble-face -s vim_airline_a_visual fg=234,bg=73 # fg=#202020,bg=#4bb1a7 + ble-face -s vim_airline_b fg=239,bg=236 # fg=#505050,bg=#303030 + ble-face -s vim_airline_b_inactive fg=239,bg=234 # fg=#505050,bg=#202020 + ble-face -s vim_airline_c fg=239,bg=234 # fg=#505050,bg=#202020 + ble-face -s vim_airline_c_inactive fg=248,bg=234 # fg=#a7a7a7,bg=#202020 + ble-face -s vim_airline_c_insert_modified fg=231,bg=234 # fg=#ffffff,bg=#202020 + ble-face -s vim_airline_c_normal_modified fg=231,bg=234 # fg=#ffffff,bg=#202020 + ble-face -s vim_airline_c_replace_modified fg=231,bg=234 # fg=#ffffff,bg=#202020 + ble-face -s vim_airline_c_visual_modified fg=231,bg=234 # fg=#ffffff,bg=#202020 +} diff --git a/.local/share/blesh/contrib/airline/base16_classic.bash b/.local/share/blesh/contrib/airline/base16_classic.bash new file mode 100644 index 0000000..2b2a831 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_classic.bash @@ -0,0 +1,21 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_classic.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# vim-airline template by chartoin (http://github.com/chartoin) +# Base 16 Classic Scheme by Jason Heeris (http://heeris.id.au) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_classic/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=234,bg=107 # fg=#202020,bg=#90a959 + ble-face -s vim_airline_a_inactive fg=252,bg=234 # fg=#d0d0d0,bg=#202020 + ble-face -s vim_airline_a_insert fg=234,bg=73 # fg=#202020,bg=#6a9fb5 + ble-face -s vim_airline_a_replace fg=234,bg=131 # fg=#202020,bg=#ac4142 + ble-face -s vim_airline_a_visual fg=234,bg=139 # fg=#202020,bg=#aa759f + ble-face -s vim_airline_b fg=254,bg=236 # fg=#e0e0e0,bg=#303030 + ble-face -s vim_airline_b_inactive fg=252,bg=234 # fg=#d0d0d0,bg=#202020 + ble-face -s vim_airline_c fg=173,bg=234 # fg=#d28445,bg=#202020 + ble-face -s vim_airline_c_inactive fg=252,bg=234 # fg=#d0d0d0,bg=#202020 +} diff --git a/.local/share/blesh/contrib/airline/base16_classic_dark.bash b/.local/share/blesh/contrib/airline/base16_classic_dark.bash new file mode 100644 index 0000000..2de8e9c --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_classic_dark.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_classic_dark.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Classic Dark vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Jason Heeris (http://heeris.id.au) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_classic_dark/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=234,bg=149 # fg=#202020,bg=#b0b0b0 + ble-face -s vim_airline_a_inactive fg=234,bg=234 # fg=#202020,bg=#202020 + ble-face -s vim_airline_a_insert fg=234,bg=107 # fg=#202020,bg=#90a959 + ble-face -s vim_airline_a_replace fg=234,bg=139 # fg=#202020,bg=#aa759f + ble-face -s vim_airline_a_visual fg=234,bg=173 # fg=#202020,bg=#d28445 + ble-face -s vim_airline_b fg=149,bg=236 # fg=#b0b0b0,bg=#303030 + ble-face -s vim_airline_b_inactive fg=149,bg=234 # fg=#b0b0b0,bg=#202020 + ble-face -s vim_airline_c fg=149,bg=234 # fg=#b0b0b0,bg=#202020 + ble-face -s vim_airline_c_inactive fg=252,bg=234 # fg=#d0d0d0,bg=#202020 + ble-face -s vim_airline_c_insert_modified fg=255,bg=234 # fg=#f5f5f5,bg=#202020 + ble-face -s vim_airline_c_normal_modified fg=255,bg=234 # fg=#f5f5f5,bg=#202020 + ble-face -s vim_airline_c_replace_modified fg=255,bg=234 # fg=#f5f5f5,bg=#202020 + ble-face -s vim_airline_c_visual_modified fg=255,bg=234 # fg=#f5f5f5,bg=#202020 +} diff --git a/.local/share/blesh/contrib/airline/base16_classic_light.bash b/.local/share/blesh/contrib/airline/base16_classic_light.bash new file mode 100644 index 0000000..8cd4fe9 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_classic_light.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_classic_light.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Classic Light vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Jason Heeris (http://heeris.id.au) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_classic_light/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=254,bg=239 # fg=#e0e0e0,bg=#505050 + ble-face -s vim_airline_a_inactive fg=254,bg=254 # fg=#e0e0e0,bg=#e0e0e0 + ble-face -s vim_airline_a_insert fg=254,bg=107 # fg=#e0e0e0,bg=#90a959 + ble-face -s vim_airline_a_replace fg=254,bg=139 # fg=#e0e0e0,bg=#aa759f + ble-face -s vim_airline_a_visual fg=254,bg=173 # fg=#e0e0e0,bg=#d28445 + ble-face -s vim_airline_b fg=239,bg=252 # fg=#505050,bg=#d0d0d0 + ble-face -s vim_airline_b_inactive fg=239,bg=254 # fg=#505050,bg=#e0e0e0 + ble-face -s vim_airline_c fg=239,bg=254 # fg=#505050,bg=#e0e0e0 + ble-face -s vim_airline_c_inactive fg=236,bg=254 # fg=#303030,bg=#e0e0e0 + ble-face -s vim_airline_c_insert_modified fg=233,bg=254 # fg=#151515,bg=#e0e0e0 + ble-face -s vim_airline_c_normal_modified fg=233,bg=254 # fg=#151515,bg=#e0e0e0 + ble-face -s vim_airline_c_replace_modified fg=233,bg=254 # fg=#151515,bg=#e0e0e0 + ble-face -s vim_airline_c_visual_modified fg=233,bg=254 # fg=#151515,bg=#e0e0e0 +} diff --git a/.local/share/blesh/contrib/airline/base16_codeschool.bash b/.local/share/blesh/contrib/airline/base16_codeschool.bash new file mode 100644 index 0000000..2ec6871 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_codeschool.bash @@ -0,0 +1,21 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_codeschool.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# vim-airline template by chartoin (http://github.com/chartoin) +# Base 16 Codeschool Scheme by brettof86 + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_codeschool/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=23,bg=30 # fg=#1c3657,bg=#237986 + ble-face -s vim_airline_a_inactive fg=248,bg=23 # fg=#9ea7a6,bg=#1c3657 + ble-face -s vim_airline_a_insert fg=23,bg=60 # fg=#1c3657,bg=#484d79 + ble-face -s vim_airline_a_replace fg=23,bg=24 # fg=#1c3657,bg=#2a5491 + ble-face -s vim_airline_a_visual fg=23,bg=172 # fg=#1c3657,bg=#c59820 + ble-face -s vim_airline_b fg=151,bg=23 # fg=#a7cfa3,bg=#2a343a + ble-face -s vim_airline_b_inactive fg=248,bg=23 # fg=#9ea7a6,bg=#1c3657 + ble-face -s vim_airline_c fg=64,bg=23 # fg=#43820d,bg=#1c3657 + ble-face -s vim_airline_c_inactive fg=248,bg=23 # fg=#9ea7a6,bg=#1c3657 +} diff --git a/.local/share/blesh/contrib/airline/base16_colors.bash b/.local/share/blesh/contrib/airline/base16_colors.bash new file mode 100644 index 0000000..65f9128 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_colors.bash @@ -0,0 +1,21 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_colors.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# vim-airline template by chartoin (http://github.com/chartoin) +# Base 16 Colors Scheme by mrmrs (http://clrs.cc) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_colors/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=236,bg=41 # fg=#333333,bg=#2ecc40 + ble-face -s vim_airline_a_inactive fg=250,bg=236 # fg=#bbbbbb,bg=#333333 + ble-face -s vim_airline_a_insert fg=236,bg=32 # fg=#333333,bg=#0074d9 + ble-face -s vim_airline_a_replace fg=236,bg=203 # fg=#333333,bg=#ff4136 + ble-face -s vim_airline_a_visual fg=236,bg=128 # fg=#333333,bg=#b10dc9 + ble-face -s vim_airline_b fg=253,bg=240 # fg=#dddddd,bg=#555555 + ble-face -s vim_airline_b_inactive fg=250,bg=236 # fg=#bbbbbb,bg=#333333 + ble-face -s vim_airline_c fg=208,bg=236 # fg=#ff851b,bg=#333333 + ble-face -s vim_airline_c_inactive fg=250,bg=236 # fg=#bbbbbb,bg=#333333 +} diff --git a/.local/share/blesh/contrib/airline/base16_cupcake.bash b/.local/share/blesh/contrib/airline/base16_cupcake.bash new file mode 100644 index 0000000..6a300a6 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_cupcake.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_cupcake.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Cupcake vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Chris Kempson (http://chriskempson.com) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_cupcake/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=255,bg=248 # fg=#f2f1f4,bg=#a59daf + ble-face -s vim_airline_a_inactive fg=255,bg=255 # fg=#f2f1f4,bg=#f2f1f4 + ble-face -s vim_airline_a_insert fg=255,bg=143 # fg=#f2f1f4,bg=#a3b367 + ble-face -s vim_airline_a_replace fg=255,bg=139 # fg=#f2f1f4,bg=#bb99b4 + ble-face -s vim_airline_a_visual fg=255,bg=216 # fg=#f2f1f4,bg=#ebb790 + ble-face -s vim_airline_b fg=248,bg=253 # fg=#a59daf,bg=#d8d5dd + ble-face -s vim_airline_b_inactive fg=248,bg=255 # fg=#a59daf,bg=#f2f1f4 + ble-face -s vim_airline_c fg=248,bg=255 # fg=#a59daf,bg=#f2f1f4 + ble-face -s vim_airline_c_inactive fg=245,bg=255 # fg=#8b8198,bg=#f2f1f4 + ble-face -s vim_airline_c_insert_modified fg=240,bg=255 # fg=#585062,bg=#f2f1f4 + ble-face -s vim_airline_c_normal_modified fg=240,bg=255 # fg=#585062,bg=#f2f1f4 + ble-face -s vim_airline_c_replace_modified fg=240,bg=255 # fg=#585062,bg=#f2f1f4 + ble-face -s vim_airline_c_visual_modified fg=240,bg=255 # fg=#585062,bg=#f2f1f4 +} diff --git a/.local/share/blesh/contrib/airline/base16_cupertino.bash b/.local/share/blesh/contrib/airline/base16_cupertino.bash new file mode 100644 index 0000000..4359575 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_cupertino.bash @@ -0,0 +1,25 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_cupertino.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Cupertino vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Defman21 + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_cupertino/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=250,bg=244 # fg=#c0c0c0,bg=#808080 + ble-face -s vim_airline_a_inactive fg=250,bg=250 # fg=#c0c0c0,bg=#c0c0c0 + ble-face -s vim_airline_a_insert fg=250,bg=28 # fg=#c0c0c0,bg=#007400 + ble-face -s vim_airline_a_replace fg=250,bg=126 # fg=#c0c0c0,bg=#a90d91 + ble-face -s vim_airline_a_visual fg=250,bg=208 # fg=#c0c0c0,bg=#eb8500 + ble-face -s vim_airline_b fg=244,bg=250 # fg=#808080,bg=#c0c0c0 + ble-face -s vim_airline_c fg=244,bg=250 # fg=#808080,bg=#c0c0c0 + ble-face -s vim_airline_c_inactive fg=238,bg=250 # fg=#404040,bg=#c0c0c0 + ble-face -s vim_airline_c_insert_modified fg=61,bg=250 # fg=#5e5e5e,bg=#c0c0c0 + ble-face -s vim_airline_c_normal_modified fg=61,bg=250 # fg=#5e5e5e,bg=#c0c0c0 + ble-face -s vim_airline_c_replace_modified fg=61,bg=250 # fg=#5e5e5e,bg=#c0c0c0 + ble-face -s vim_airline_c_visual_modified fg=61,bg=250 # fg=#5e5e5e,bg=#c0c0c0 +} diff --git a/.local/share/blesh/contrib/airline/base16_darktooth.bash b/.local/share/blesh/contrib/airline/base16_darktooth.bash new file mode 100644 index 0000000..34b64bc --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_darktooth.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_darktooth.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Darktooth vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Jason Milkins (https://github.com/jasonm23) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_darktooth/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=58,bg=244 # fg=#32302f,bg=#928374 + ble-face -s vim_airline_a_inactive fg=58,bg=58 # fg=#32302f,bg=#32302f + ble-face -s vim_airline_a_insert fg=58,bg=108 # fg=#32302f,bg=#95c085 + ble-face -s vim_airline_a_replace fg=58,bg=96 # fg=#32302f,bg=#8f4673 + ble-face -s vim_airline_a_visual fg=58,bg=208 # fg=#32302f,bg=#fe8625 + ble-face -s vim_airline_b fg=244,bg=239 # fg=#928374,bg=#504945 + ble-face -s vim_airline_b_inactive fg=244,bg=58 # fg=#928374,bg=#32302f + ble-face -s vim_airline_c fg=244,bg=58 # fg=#928374,bg=#32302f + ble-face -s vim_airline_c_inactive fg=138,bg=58 # fg=#a89984,bg=#32302f + ble-face -s vim_airline_c_insert_modified fg=229,bg=58 # fg=#fdf4c1,bg=#32302f + ble-face -s vim_airline_c_normal_modified fg=229,bg=58 # fg=#fdf4c1,bg=#32302f + ble-face -s vim_airline_c_replace_modified fg=229,bg=58 # fg=#fdf4c1,bg=#32302f + ble-face -s vim_airline_c_visual_modified fg=229,bg=58 # fg=#fdf4c1,bg=#32302f +} diff --git a/.local/share/blesh/contrib/airline/base16_decaf.bash b/.local/share/blesh/contrib/airline/base16_decaf.bash new file mode 100644 index 0000000..ab38a7a --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_decaf.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_decaf.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Decaf vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Alex Mirrington (https://github.com/alexmirrington) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_decaf/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=237,bg=249 # fg=#393939,bg=#b4b7b4 + ble-face -s vim_airline_a_inactive fg=237,bg=237 # fg=#393939,bg=#393939 + ble-face -s vim_airline_a_insert fg=237,bg=150 # fg=#393939,bg=#beda78 + ble-face -s vim_airline_a_replace fg=237,bg=219 # fg=#393939,bg=#efb3f7 + ble-face -s vim_airline_a_visual fg=237,bg=215 # fg=#393939,bg=#ffbf70 + ble-face -s vim_airline_b fg=249,bg=239 # fg=#b4b7b4,bg=#515151 + ble-face -s vim_airline_b_inactive fg=249,bg=237 # fg=#b4b7b4,bg=#393939 + ble-face -s vim_airline_c fg=249,bg=237 # fg=#b4b7b4,bg=#393939 + ble-face -s vim_airline_c_inactive fg=252,bg=237 # fg=#cccccc,bg=#393939 + ble-face -s vim_airline_c_insert_modified fg=231,bg=237 # fg=#ffffff,bg=#393939 + ble-face -s vim_airline_c_normal_modified fg=231,bg=237 # fg=#ffffff,bg=#393939 + ble-face -s vim_airline_c_replace_modified fg=231,bg=237 # fg=#ffffff,bg=#393939 + ble-face -s vim_airline_c_visual_modified fg=231,bg=237 # fg=#ffffff,bg=#393939 +} diff --git a/.local/share/blesh/contrib/airline/base16_default.bash b/.local/share/blesh/contrib/airline/base16_default.bash new file mode 100644 index 0000000..4f307aa --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_default.bash @@ -0,0 +1,21 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_default.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# vim-airline template by chartoin (http://github.com/chartoin) +# Base 16 Default Scheme by Chris Kempson (http://chriskempson.com) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_default/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=235,bg=143 # fg=#282828,bg=#a1b56c + ble-face -s vim_airline_a_inactive fg=192,bg=235 # fg=#d8d8d8,bg=#282828 + ble-face -s vim_airline_a_insert fg=235,bg=109 # fg=#282828,bg=#7cafc2 + ble-face -s vim_airline_a_replace fg=235,bg=131 # fg=#282828,bg=#ab4642 + ble-face -s vim_airline_a_visual fg=235,bg=139 # fg=#282828,bg=#ba8baf + ble-face -s vim_airline_b fg=254,bg=237 # fg=#e8e8e8,bg=#383838 + ble-face -s vim_airline_b_inactive fg=192,bg=235 # fg=#d8d8d8,bg=#282828 + ble-face -s vim_airline_c fg=173,bg=235 # fg=#dc9656,bg=#282828 + ble-face -s vim_airline_c_inactive fg=192,bg=235 # fg=#d8d8d8,bg=#282828 +} diff --git a/.local/share/blesh/contrib/airline/base16_default_dark.bash b/.local/share/blesh/contrib/airline/base16_default_dark.bash new file mode 100644 index 0000000..4844af5 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_default_dark.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_default_dark.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Default Dark vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Chris Kempson (http://chriskempson.com) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_default_dark/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=235,bg=250 # fg=#282828,bg=#b8b8b8 + ble-face -s vim_airline_a_inactive fg=235,bg=235 # fg=#282828,bg=#282828 + ble-face -s vim_airline_a_insert fg=235,bg=143 # fg=#282828,bg=#a1b56c + ble-face -s vim_airline_a_replace fg=235,bg=139 # fg=#282828,bg=#ba8baf + ble-face -s vim_airline_a_visual fg=235,bg=173 # fg=#282828,bg=#dc9656 + ble-face -s vim_airline_b fg=250,bg=237 # fg=#b8b8b8,bg=#383838 + ble-face -s vim_airline_b_inactive fg=250,bg=235 # fg=#b8b8b8,bg=#282828 + ble-face -s vim_airline_c fg=250,bg=235 # fg=#b8b8b8,bg=#282828 + ble-face -s vim_airline_c_inactive fg=192,bg=235 # fg=#d8d8d8,bg=#282828 + ble-face -s vim_airline_c_insert_modified fg=231,bg=235 # fg=#f8f8f8,bg=#282828 + ble-face -s vim_airline_c_normal_modified fg=231,bg=235 # fg=#f8f8f8,bg=#282828 + ble-face -s vim_airline_c_replace_modified fg=231,bg=235 # fg=#f8f8f8,bg=#282828 + ble-face -s vim_airline_c_visual_modified fg=231,bg=235 # fg=#f8f8f8,bg=#282828 +} diff --git a/.local/share/blesh/contrib/airline/base16_default_light.bash b/.local/share/blesh/contrib/airline/base16_default_light.bash new file mode 100644 index 0000000..d365deb --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_default_light.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_default_light.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Default Light vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Chris Kempson (http://chriskempson.com) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_default_light/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=254,bg=240 # fg=#e8e8e8,bg=#585858 + ble-face -s vim_airline_a_inactive fg=254,bg=254 # fg=#e8e8e8,bg=#e8e8e8 + ble-face -s vim_airline_a_insert fg=254,bg=143 # fg=#e8e8e8,bg=#a1b56c + ble-face -s vim_airline_a_replace fg=254,bg=139 # fg=#e8e8e8,bg=#ba8baf + ble-face -s vim_airline_a_visual fg=254,bg=173 # fg=#e8e8e8,bg=#dc9656 + ble-face -s vim_airline_b fg=240,bg=192 # fg=#585858,bg=#d8d8d8 + ble-face -s vim_airline_b_inactive fg=240,bg=254 # fg=#585858,bg=#e8e8e8 + ble-face -s vim_airline_c fg=240,bg=254 # fg=#585858,bg=#e8e8e8 + ble-face -s vim_airline_c_inactive fg=237,bg=254 # fg=#383838,bg=#e8e8e8 + ble-face -s vim_airline_c_insert_modified fg=234,bg=254 # fg=#181818,bg=#e8e8e8 + ble-face -s vim_airline_c_normal_modified fg=234,bg=254 # fg=#181818,bg=#e8e8e8 + ble-face -s vim_airline_c_replace_modified fg=234,bg=254 # fg=#181818,bg=#e8e8e8 + ble-face -s vim_airline_c_visual_modified fg=234,bg=254 # fg=#181818,bg=#e8e8e8 +} diff --git a/.local/share/blesh/contrib/airline/base16_dracula.bash b/.local/share/blesh/contrib/airline/base16_dracula.bash new file mode 100644 index 0000000..3e7696e --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_dracula.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_dracula.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Dracula vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Mike Barkmin (http://github.com/mikebarkmin) based on Dracula Theme (http://github.com/dracula) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_dracula/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=238,bg=80 # fg=#3a3c4e,bg=#62d6e8 + ble-face -s vim_airline_a_inactive fg=238,bg=238 # fg=#3a3c4e,bg=#3a3c4e + ble-face -s vim_airline_a_insert fg=238,bg=228 # fg=#3a3c4e,bg=#ebff87 + ble-face -s vim_airline_a_replace fg=238,bg=134 # fg=#3a3c4e,bg=#b45bcf + ble-face -s vim_airline_a_visual fg=238,bg=134 # fg=#3a3c4e,bg=#b45bcf + ble-face -s vim_airline_b fg=80,bg=240 # fg=#62d6e8,bg=#4d4f68 + ble-face -s vim_airline_b_inactive fg=80,bg=238 # fg=#62d6e8,bg=#3a3c4e + ble-face -s vim_airline_c fg=80,bg=238 # fg=#62d6e8,bg=#3a3c4e + ble-face -s vim_airline_c_inactive fg=189,bg=238 # fg=#e9e9f4,bg=#3a3c4e + ble-face -s vim_airline_c_insert_modified fg=231,bg=238 # fg=#f7f7fb,bg=#3a3c4e + ble-face -s vim_airline_c_normal_modified fg=231,bg=238 # fg=#f7f7fb,bg=#3a3c4e + ble-face -s vim_airline_c_replace_modified fg=231,bg=238 # fg=#f7f7fb,bg=#3a3c4e + ble-face -s vim_airline_c_visual_modified fg=231,bg=238 # fg=#f7f7fb,bg=#3a3c4e +} diff --git a/.local/share/blesh/contrib/airline/base16_edge_dark.bash b/.local/share/blesh/contrib/airline/base16_edge_dark.bash new file mode 100644 index 0000000..5f83268 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_edge_dark.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_edge_dark.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Edge Dark vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Sainnhepark (https://github.com/sainnhe) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_edge_dark/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=103,bg=110 # fg=#88909f,bg=#73b3e7 + ble-face -s vim_airline_a_inactive fg=103,bg=103 # fg=#88909f,bg=#88909f + ble-face -s vim_airline_a_insert fg=103,bg=144 # fg=#88909f,bg=#a1bf78 + ble-face -s vim_airline_a_replace fg=103,bg=176 # fg=#88909f,bg=#d390e7 + ble-face -s vim_airline_a_visual fg=103,bg=167 # fg=#88909f,bg=#e77171 + ble-face -s vim_airline_b fg=110,bg=146 # fg=#73b3e7,bg=#b7bec9 + ble-face -s vim_airline_b_inactive fg=110,bg=103 # fg=#73b3e7,bg=#88909f + ble-face -s vim_airline_c fg=110,bg=103 # fg=#73b3e7,bg=#88909f + ble-face -s vim_airline_c_inactive fg=146,bg=103 # fg=#b7bec9,bg=#88909f + ble-face -s vim_airline_c_insert_modified fg=238,bg=103 # fg=#3e4249,bg=#88909f + ble-face -s vim_airline_c_normal_modified fg=238,bg=103 # fg=#3e4249,bg=#88909f + ble-face -s vim_airline_c_replace_modified fg=238,bg=103 # fg=#3e4249,bg=#88909f + ble-face -s vim_airline_c_visual_modified fg=238,bg=103 # fg=#3e4249,bg=#88909f +} diff --git a/.local/share/blesh/contrib/airline/base16_edge_light.bash b/.local/share/blesh/contrib/airline/base16_edge_light.bash new file mode 100644 index 0000000..692a84f --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_edge_light.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_edge_light.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Edge Light vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Sainnhepark (https://github.com/sainnhe) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_edge_light/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=107,bg=67 # fg=#7c9f4b,bg=#6587bf + ble-face -s vim_airline_a_inactive fg=107,bg=107 # fg=#7c9f4b,bg=#7c9f4b + ble-face -s vim_airline_a_insert fg=107,bg=107 # fg=#7c9f4b,bg=#7c9f4b + ble-face -s vim_airline_a_replace fg=107,bg=134 # fg=#7c9f4b,bg=#b870ce + ble-face -s vim_airline_a_visual fg=107,bg=167 # fg=#7c9f4b,bg=#db7070 + ble-face -s vim_airline_b fg=67,bg=172 # fg=#6587bf,bg=#d69822 + ble-face -s vim_airline_b_inactive fg=67,bg=107 # fg=#6587bf,bg=#7c9f4b + ble-face -s vim_airline_c fg=67,bg=107 # fg=#6587bf,bg=#7c9f4b + ble-face -s vim_airline_c_inactive fg=241,bg=107 # fg=#5e646f,bg=#7c9f4b + ble-face -s vim_airline_c_insert_modified fg=241,bg=107 # fg=#5e646f,bg=#7c9f4b + ble-face -s vim_airline_c_normal_modified fg=241,bg=107 # fg=#5e646f,bg=#7c9f4b + ble-face -s vim_airline_c_replace_modified fg=241,bg=107 # fg=#5e646f,bg=#7c9f4b + ble-face -s vim_airline_c_visual_modified fg=241,bg=107 # fg=#5e646f,bg=#7c9f4b +} diff --git a/.local/share/blesh/contrib/airline/base16_eighties.bash b/.local/share/blesh/contrib/airline/base16_eighties.bash new file mode 100644 index 0000000..c1b244c --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_eighties.bash @@ -0,0 +1,21 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_eighties.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# vim-airline template by chartoin (http://github.com/chartoin) +# Base 16 Eighties Scheme by Chris Kempson (http://chriskempson.com) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_eighties/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=237,bg=114 # fg=#393939,bg=#99cc99 + ble-face -s vim_airline_a_inactive fg=252,bg=237 # fg=#d3d0c8,bg=#393939 + ble-face -s vim_airline_a_insert fg=237,bg=68 # fg=#393939,bg=#6699cc + ble-face -s vim_airline_a_replace fg=237,bg=210 # fg=#393939,bg=#f2777a + ble-face -s vim_airline_a_visual fg=237,bg=176 # fg=#393939,bg=#cc99cc + ble-face -s vim_airline_b fg=254,bg=239 # fg=#e8e6df,bg=#515151 + ble-face -s vim_airline_b_inactive fg=252,bg=237 # fg=#d3d0c8,bg=#393939 + ble-face -s vim_airline_c fg=209,bg=237 # fg=#f99157,bg=#393939 + ble-face -s vim_airline_c_inactive fg=252,bg=237 # fg=#d3d0c8,bg=#393939 +} diff --git a/.local/share/blesh/contrib/airline/base16_embers.bash b/.local/share/blesh/contrib/airline/base16_embers.bash new file mode 100644 index 0000000..804ff5e --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_embers.bash @@ -0,0 +1,21 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_embers.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# vim-airline template by chartoin (http://github.com/chartoin) +# Base 16 Embers Scheme by Jannik Siebert (https://github.com/janniks) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_embers/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=235,bg=65 # fg=#2c2620,bg=#57826d + ble-face -s vim_airline_a_inactive fg=138,bg=235 # fg=#a39a90,bg=#2c2620 + ble-face -s vim_airline_a_insert fg=235,bg=60 # fg=#2c2620,bg=#6d5782 + ble-face -s vim_airline_a_replace fg=235,bg=95 # fg=#2c2620,bg=#826d57 + ble-face -s vim_airline_a_visual fg=235,bg=95 # fg=#2c2620,bg=#82576d + ble-face -s vim_airline_b fg=249,bg=237 # fg=#beb6ae,bg=#433b32 + ble-face -s vim_airline_b_inactive fg=138,bg=235 # fg=#a39a90,bg=#2c2620 + ble-face -s vim_airline_c fg=101,bg=235 # fg=#828257,bg=#2c2620 + ble-face -s vim_airline_c_inactive fg=138,bg=235 # fg=#a39a90,bg=#2c2620 +} diff --git a/.local/share/blesh/contrib/airline/base16_espresso.bash b/.local/share/blesh/contrib/airline/base16_espresso.bash new file mode 100644 index 0000000..900dc19 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_espresso.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_espresso.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Espresso vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Alex Mirrington (https://github.com/alexmirrington) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_espresso/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=237,bg=249 # fg=#393939,bg=#b4b7b4 + ble-face -s vim_airline_a_inactive fg=237,bg=237 # fg=#393939,bg=#393939 + ble-face -s vim_airline_a_insert fg=237,bg=143 # fg=#393939,bg=#a5c261 + ble-face -s vim_airline_a_replace fg=237,bg=176 # fg=#393939,bg=#d197d9 + ble-face -s vim_airline_a_visual fg=237,bg=215 # fg=#393939,bg=#f9a959 + ble-face -s vim_airline_b fg=249,bg=239 # fg=#b4b7b4,bg=#515151 + ble-face -s vim_airline_b_inactive fg=249,bg=237 # fg=#b4b7b4,bg=#393939 + ble-face -s vim_airline_c fg=249,bg=237 # fg=#b4b7b4,bg=#393939 + ble-face -s vim_airline_c_inactive fg=252,bg=237 # fg=#cccccc,bg=#393939 + ble-face -s vim_airline_c_insert_modified fg=231,bg=237 # fg=#ffffff,bg=#393939 + ble-face -s vim_airline_c_normal_modified fg=231,bg=237 # fg=#ffffff,bg=#393939 + ble-face -s vim_airline_c_replace_modified fg=231,bg=237 # fg=#ffffff,bg=#393939 + ble-face -s vim_airline_c_visual_modified fg=231,bg=237 # fg=#ffffff,bg=#393939 +} diff --git a/.local/share/blesh/contrib/airline/base16_flat.bash b/.local/share/blesh/contrib/airline/base16_flat.bash new file mode 100644 index 0000000..4466c5b --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_flat.bash @@ -0,0 +1,21 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_flat.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# vim-airline template by chartoin (http://github.com/chartoin) +# Base 16 Flat Scheme by Chris Kempson (http://chriskempson.com) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_flat/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=239,bg=41 # fg=#34495e,bg=#2ecc71 + ble-face -s vim_airline_a_inactive fg=254,bg=239 # fg=#e0e0e0,bg=#34495e + ble-face -s vim_airline_a_insert fg=239,bg=68 # fg=#34495e,bg=#3498db + ble-face -s vim_airline_a_replace fg=239,bg=167 # fg=#34495e,bg=#e74c3c + ble-face -s vim_airline_a_visual fg=239,bg=133 # fg=#34495e,bg=#9b59b6 + ble-face -s vim_airline_b fg=255,bg=106 # fg=#f5f5f5,bg=#7f8c8d + ble-face -s vim_airline_b_inactive fg=254,bg=239 # fg=#e0e0e0,bg=#34495e + ble-face -s vim_airline_c fg=172,bg=239 # fg=#e67e22,bg=#34495e + ble-face -s vim_airline_c_inactive fg=254,bg=239 # fg=#e0e0e0,bg=#34495e +} diff --git a/.local/share/blesh/contrib/airline/base16_framer.bash b/.local/share/blesh/contrib/airline/base16_framer.bash new file mode 100644 index 0000000..5999c88 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_framer.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_framer.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Framer vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Framer (Maintained by Jesse Hoyos) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_framer/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=233,bg=250 # fg=#151515,bg=#b9b9b9 + ble-face -s vim_airline_a_inactive fg=233,bg=233 # fg=#151515,bg=#151515 + ble-face -s vim_airline_a_insert fg=233,bg=80 # fg=#151515,bg=#32ccdc + ble-face -s vim_airline_a_replace fg=233,bg=141 # fg=#151515,bg=#ba8cfc + ble-face -s vim_airline_a_visual fg=233,bg=203 # fg=#151515,bg=#fc4769 + ble-face -s vim_airline_b fg=250,bg=238 # fg=#b9b9b9,bg=#464646 + ble-face -s vim_airline_b_inactive fg=250,bg=233 # fg=#b9b9b9,bg=#151515 + ble-face -s vim_airline_c fg=250,bg=233 # fg=#b9b9b9,bg=#151515 + ble-face -s vim_airline_c_inactive fg=252,bg=233 # fg=#d0d0d0,bg=#151515 + ble-face -s vim_airline_c_insert_modified fg=255,bg=233 # fg=#eeeeee,bg=#151515 + ble-face -s vim_airline_c_normal_modified fg=255,bg=233 # fg=#eeeeee,bg=#151515 + ble-face -s vim_airline_c_replace_modified fg=255,bg=233 # fg=#eeeeee,bg=#151515 + ble-face -s vim_airline_c_visual_modified fg=255,bg=233 # fg=#eeeeee,bg=#151515 +} diff --git a/.local/share/blesh/contrib/airline/base16_fruit_soda.bash b/.local/share/blesh/contrib/airline/base16_fruit_soda.bash new file mode 100644 index 0000000..2f83d50 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_fruit_soda.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_fruit_soda.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Fruit Soda vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By jozip + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_fruit_soda/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=254,bg=246 # fg=#e0dee0,bg=#979598 + ble-face -s vim_airline_a_inactive fg=254,bg=254 # fg=#e0dee0,bg=#e0dee0 + ble-face -s vim_airline_a_insert fg=254,bg=83 # fg=#e0dee0,bg=#47f74c + ble-face -s vim_airline_a_replace fg=254,bg=56 # fg=#e0dee0,bg=#611fce + ble-face -s vim_airline_a_visual fg=254,bg=202 # fg=#e0dee0,bg=#fe6d08 + ble-face -s vim_airline_b fg=246,bg=190 # fg=#979598,bg=#d8d5d5 + ble-face -s vim_airline_b_inactive fg=246,bg=254 # fg=#979598,bg=#e0dee0 + ble-face -s vim_airline_c fg=246,bg=254 # fg=#979598,bg=#e0dee0 + ble-face -s vim_airline_c_inactive fg=239,bg=254 # fg=#515151,bg=#e0dee0 + ble-face -s vim_airline_c_insert_modified fg=236,bg=254 # fg=#2d2c2c,bg=#e0dee0 + ble-face -s vim_airline_c_normal_modified fg=236,bg=254 # fg=#2d2c2c,bg=#e0dee0 + ble-face -s vim_airline_c_replace_modified fg=236,bg=254 # fg=#2d2c2c,bg=#e0dee0 + ble-face -s vim_airline_c_visual_modified fg=236,bg=254 # fg=#2d2c2c,bg=#e0dee0 +} diff --git a/.local/share/blesh/contrib/airline/base16_gigavolt.bash b/.local/share/blesh/contrib/airline/base16_gigavolt.bash new file mode 100644 index 0000000..6452de9 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_gigavolt.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_gigavolt.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Gigavolt vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Aidan Swope (http://github.com/Whillikers) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_gigavolt/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=23,bg=189 # fg=#2d303d,bg=#cad3ff + ble-face -s vim_airline_a_inactive fg=23,bg=23 # fg=#2d303d,bg=#2d303d + ble-face -s vim_airline_a_insert fg=23,bg=223 # fg=#2d303d,bg=#f2e6a9 + ble-face -s vim_airline_a_replace fg=23,bg=141 # fg=#2d303d,bg=#ae94f9 + ble-face -s vim_airline_a_visual fg=23,bg=48 # fg=#2d303d,bg=#19f988 + ble-face -s vim_airline_b fg=189,bg=63 # fg=#cad3ff,bg=#5a576e + ble-face -s vim_airline_b_inactive fg=189,bg=23 # fg=#cad3ff,bg=#2d303d + ble-face -s vim_airline_c fg=189,bg=23 # fg=#cad3ff,bg=#2d303d + ble-face -s vim_airline_c_inactive fg=254,bg=23 # fg=#e9e7e1,bg=#2d303d + ble-face -s vim_airline_c_insert_modified fg=231,bg=23 # fg=#f2fbff,bg=#2d303d + ble-face -s vim_airline_c_normal_modified fg=231,bg=23 # fg=#f2fbff,bg=#2d303d + ble-face -s vim_airline_c_replace_modified fg=231,bg=23 # fg=#f2fbff,bg=#2d303d + ble-face -s vim_airline_c_visual_modified fg=231,bg=23 # fg=#f2fbff,bg=#2d303d +} diff --git a/.local/share/blesh/contrib/airline/base16_github.bash b/.local/share/blesh/contrib/airline/base16_github.bash new file mode 100644 index 0000000..faf3c95 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_github.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_github.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Github vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Defman21 + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_github/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=255,bg=254 # fg=#f5f5f5,bg=#e8e8e8 + ble-face -s vim_airline_a_inactive fg=255,bg=255 # fg=#f5f5f5,bg=#f5f5f5 + ble-face -s vim_airline_a_insert fg=255,bg=24 # fg=#f5f5f5,bg=#183691 + ble-face -s vim_airline_a_replace fg=255,bg=125 # fg=#f5f5f5,bg=#a71d5d + ble-face -s vim_airline_a_visual fg=255,bg=31 # fg=#f5f5f5,bg=#0086b3 + ble-face -s vim_airline_b fg=254,bg=189 # fg=#e8e8e8,bg=#c8c8fa + ble-face -s vim_airline_b_inactive fg=254,bg=255 # fg=#e8e8e8,bg=#f5f5f5 + ble-face -s vim_airline_c fg=254,bg=255 # fg=#e8e8e8,bg=#f5f5f5 + ble-face -s vim_airline_c_inactive fg=236,bg=255 # fg=#333333,bg=#f5f5f5 + ble-face -s vim_airline_c_insert_modified fg=231,bg=255 # fg=#ffffff,bg=#f5f5f5 + ble-face -s vim_airline_c_normal_modified fg=231,bg=255 # fg=#ffffff,bg=#f5f5f5 + ble-face -s vim_airline_c_replace_modified fg=231,bg=255 # fg=#ffffff,bg=#f5f5f5 + ble-face -s vim_airline_c_visual_modified fg=231,bg=255 # fg=#ffffff,bg=#f5f5f5 +} diff --git a/.local/share/blesh/contrib/airline/base16_google.bash b/.local/share/blesh/contrib/airline/base16_google.bash new file mode 100644 index 0000000..b004098 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_google.bash @@ -0,0 +1,21 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_google.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# vim-airline template by chartoin (http://github.com/chartoin) +# Base 16 Google Scheme by Seth Wright (http://sethawright.com) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_google/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=236,bg=29 # fg=#282a2e,bg=#198844 + ble-face -s vim_airline_a_inactive fg=251,bg=236 # fg=#c5c8c6,bg=#282a2e + ble-face -s vim_airline_a_insert fg=236,bg=63 # fg=#282a2e,bg=#3971ed + ble-face -s vim_airline_a_replace fg=236,bg=166 # fg=#282a2e,bg=#cc342b + ble-face -s vim_airline_a_visual fg=236,bg=134 # fg=#282a2e,bg=#a36ac7 + ble-face -s vim_airline_b fg=254,bg=237 # fg=#e0e0e0,bg=#373b41 + ble-face -s vim_airline_b_inactive fg=251,bg=236 # fg=#c5c8c6,bg=#282a2e + ble-face -s vim_airline_c fg=203,bg=236 # fg=#f96a38,bg=#282a2e + ble-face -s vim_airline_c_inactive fg=251,bg=236 # fg=#c5c8c6,bg=#282a2e +} diff --git a/.local/share/blesh/contrib/airline/base16_google_dark.bash b/.local/share/blesh/contrib/airline/base16_google_dark.bash new file mode 100644 index 0000000..009d4d4 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_google_dark.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_google_dark.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Google Dark vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Seth Wright (http://sethawright.com) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_google_dark/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=236,bg=249 # fg=#282a2e,bg=#b4b7b4 + ble-face -s vim_airline_a_inactive fg=236,bg=236 # fg=#282a2e,bg=#282a2e + ble-face -s vim_airline_a_insert fg=236,bg=29 # fg=#282a2e,bg=#198844 + ble-face -s vim_airline_a_replace fg=236,bg=134 # fg=#282a2e,bg=#a36ac7 + ble-face -s vim_airline_a_visual fg=236,bg=203 # fg=#282a2e,bg=#f96a38 + ble-face -s vim_airline_b fg=249,bg=237 # fg=#b4b7b4,bg=#373b41 + ble-face -s vim_airline_b_inactive fg=249,bg=236 # fg=#b4b7b4,bg=#282a2e + ble-face -s vim_airline_c fg=249,bg=236 # fg=#b4b7b4,bg=#282a2e + ble-face -s vim_airline_c_inactive fg=251,bg=236 # fg=#c5c8c6,bg=#282a2e + ble-face -s vim_airline_c_insert_modified fg=231,bg=236 # fg=#ffffff,bg=#282a2e + ble-face -s vim_airline_c_normal_modified fg=231,bg=236 # fg=#ffffff,bg=#282a2e + ble-face -s vim_airline_c_replace_modified fg=231,bg=236 # fg=#ffffff,bg=#282a2e + ble-face -s vim_airline_c_visual_modified fg=231,bg=236 # fg=#ffffff,bg=#282a2e +} diff --git a/.local/share/blesh/contrib/airline/base16_google_light.bash b/.local/share/blesh/contrib/airline/base16_google_light.bash new file mode 100644 index 0000000..6ef4a87 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_google_light.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_google_light.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Google Light vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Seth Wright (http://sethawright.com) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_google_light/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=254,bg=246 # fg=#e0e0e0,bg=#969896 + ble-face -s vim_airline_a_inactive fg=254,bg=254 # fg=#e0e0e0,bg=#e0e0e0 + ble-face -s vim_airline_a_insert fg=254,bg=29 # fg=#e0e0e0,bg=#198844 + ble-face -s vim_airline_a_replace fg=254,bg=134 # fg=#e0e0e0,bg=#a36ac7 + ble-face -s vim_airline_a_visual fg=254,bg=203 # fg=#e0e0e0,bg=#f96a38 + ble-face -s vim_airline_b fg=246,bg=251 # fg=#969896,bg=#c5c8c6 + ble-face -s vim_airline_b_inactive fg=246,bg=254 # fg=#969896,bg=#e0e0e0 + ble-face -s vim_airline_c fg=246,bg=254 # fg=#969896,bg=#e0e0e0 + ble-face -s vim_airline_c_inactive fg=237,bg=254 # fg=#373b41,bg=#e0e0e0 + ble-face -s vim_airline_c_insert_modified fg=234,bg=254 # fg=#1d1f21,bg=#e0e0e0 + ble-face -s vim_airline_c_normal_modified fg=234,bg=254 # fg=#1d1f21,bg=#e0e0e0 + ble-face -s vim_airline_c_replace_modified fg=234,bg=254 # fg=#1d1f21,bg=#e0e0e0 + ble-face -s vim_airline_c_visual_modified fg=234,bg=254 # fg=#1d1f21,bg=#e0e0e0 +} diff --git a/.local/share/blesh/contrib/airline/base16_grayscale.bash b/.local/share/blesh/contrib/airline/base16_grayscale.bash new file mode 100644 index 0000000..4612620 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_grayscale.bash @@ -0,0 +1,21 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_grayscale.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# vim-airline template by chartoin (http://github.com/chartoin) +# Base 16 Grayscale Scheme by Alexandre Gavioli (https://github.com/Alexx2/) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_grayscale/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=235,bg=245 # fg=#252525,bg=#8e8e8e + ble-face -s vim_airline_a_inactive fg=250,bg=235 # fg=#b9b9b9,bg=#252525 + ble-face -s vim_airline_a_insert fg=235,bg=242 # fg=#252525,bg=#686868 + ble-face -s vim_airline_a_replace fg=235,bg=244 # fg=#252525,bg=#7c7c7c + ble-face -s vim_airline_a_visual fg=235,bg=243 # fg=#252525,bg=#747474 + ble-face -s vim_airline_b fg=254,bg=238 # fg=#e3e3e3,bg=#464646 + ble-face -s vim_airline_b_inactive fg=250,bg=235 # fg=#b9b9b9,bg=#252525 + ble-face -s vim_airline_c fg=247,bg=235 # fg=#999999,bg=#252525 + ble-face -s vim_airline_c_inactive fg=250,bg=235 # fg=#b9b9b9,bg=#252525 +} diff --git a/.local/share/blesh/contrib/airline/base16_grayscale_dark.bash b/.local/share/blesh/contrib/airline/base16_grayscale_dark.bash new file mode 100644 index 0000000..fcac9f7 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_grayscale_dark.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_grayscale_dark.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Grayscale Dark vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Alexandre Gavioli (https://github.com/Alexx2/) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_grayscale_dark/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=235,bg=248 # fg=#252525,bg=#ababab + ble-face -s vim_airline_a_inactive fg=235,bg=235 # fg=#252525,bg=#252525 + ble-face -s vim_airline_a_insert fg=235,bg=245 # fg=#252525,bg=#8e8e8e + ble-face -s vim_airline_a_replace fg=235,bg=243 # fg=#252525,bg=#747474 + ble-face -s vim_airline_a_visual fg=235,bg=247 # fg=#252525,bg=#999999 + ble-face -s vim_airline_b fg=248,bg=238 # fg=#ababab,bg=#464646 + ble-face -s vim_airline_b_inactive fg=248,bg=235 # fg=#ababab,bg=#252525 + ble-face -s vim_airline_c fg=248,bg=235 # fg=#ababab,bg=#252525 + ble-face -s vim_airline_c_inactive fg=250,bg=235 # fg=#b9b9b9,bg=#252525 + ble-face -s vim_airline_c_insert_modified fg=231,bg=235 # fg=#f7f7f7,bg=#252525 + ble-face -s vim_airline_c_normal_modified fg=231,bg=235 # fg=#f7f7f7,bg=#252525 + ble-face -s vim_airline_c_replace_modified fg=231,bg=235 # fg=#f7f7f7,bg=#252525 + ble-face -s vim_airline_c_visual_modified fg=231,bg=235 # fg=#f7f7f7,bg=#252525 +} diff --git a/.local/share/blesh/contrib/airline/base16_grayscale_light.bash b/.local/share/blesh/contrib/airline/base16_grayscale_light.bash new file mode 100644 index 0000000..1d9f4b5 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_grayscale_light.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_grayscale_light.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Grayscale Light vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Alexandre Gavioli (https://github.com/Alexx2/) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_grayscale_light/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=254,bg=239 # fg=#e3e3e3,bg=#525252 + ble-face -s vim_airline_a_inactive fg=254,bg=254 # fg=#e3e3e3,bg=#e3e3e3 + ble-face -s vim_airline_a_insert fg=254,bg=245 # fg=#e3e3e3,bg=#8e8e8e + ble-face -s vim_airline_a_replace fg=254,bg=243 # fg=#e3e3e3,bg=#747474 + ble-face -s vim_airline_a_visual fg=254,bg=247 # fg=#e3e3e3,bg=#999999 + ble-face -s vim_airline_b fg=239,bg=250 # fg=#525252,bg=#b9b9b9 + ble-face -s vim_airline_b_inactive fg=239,bg=254 # fg=#525252,bg=#e3e3e3 + ble-face -s vim_airline_c fg=239,bg=254 # fg=#525252,bg=#e3e3e3 + ble-face -s vim_airline_c_inactive fg=238,bg=254 # fg=#464646,bg=#e3e3e3 + ble-face -s vim_airline_c_insert_modified fg=233,bg=254 # fg=#101010,bg=#e3e3e3 + ble-face -s vim_airline_c_normal_modified fg=233,bg=254 # fg=#101010,bg=#e3e3e3 + ble-face -s vim_airline_c_replace_modified fg=233,bg=254 # fg=#101010,bg=#e3e3e3 + ble-face -s vim_airline_c_visual_modified fg=233,bg=254 # fg=#101010,bg=#e3e3e3 +} diff --git a/.local/share/blesh/contrib/airline/base16_greenscreen.bash b/.local/share/blesh/contrib/airline/base16_greenscreen.bash new file mode 100644 index 0000000..43ef4ca --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_greenscreen.bash @@ -0,0 +1,20 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_greenscreen.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# vim-airline template by chartoin (http://github.com/chartoin) +# Base 16 Green Screen Scheme by Chris Kempson (http://chriskempson.com) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_greenscreen/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=22,bg=34 # fg=#003300,bg=#00bb00 + ble-face -s vim_airline_a_inactive fg=34,bg=22 # fg=#00bb00,bg=#003300 + ble-face -s vim_airline_a_insert fg=22,bg=28 # fg=#003300,bg=#009900 + ble-face -s vim_airline_a_replace fg=22,bg=28 # fg=#003300,bg=#007700 + ble-face -s vim_airline_b fg=40,bg=22 # fg=#00dd00,bg=#005500 + ble-face -s vim_airline_b_inactive fg=34,bg=22 # fg=#00bb00,bg=#003300 + ble-face -s vim_airline_c fg=28,bg=22 # fg=#009900,bg=#003300 + ble-face -s vim_airline_c_inactive fg=34,bg=22 # fg=#00bb00,bg=#003300 +} diff --git a/.local/share/blesh/contrib/airline/base16_gruvbox_dark_hard.bash b/.local/share/blesh/contrib/airline/base16_gruvbox_dark_hard.bash new file mode 100644 index 0000000..32d648d --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_gruvbox_dark_hard.bash @@ -0,0 +1,24 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_gruvbox_dark_hard.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# vim-airline template by ronald2wing (https://github.com/ronald2wing) +# Base 16 Gruvbox Dark Hard Scheme by Dawid Kurek (https://github.com/dawikur) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_gruvbox_dark_hard/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=237,bg=142 # fg=#3c3836,bg=#b8bb26 + ble-face -s vim_airline_a_inactive fg=187,bg=237 # fg=#d5c4a1,bg=#3c3836 + ble-face -s vim_airline_a_insert fg=237,bg=108 # fg=#3c3836,bg=#83a598 + ble-face -s vim_airline_a_replace fg=237,bg=203 # fg=#3c3836,bg=#fb4934 + ble-face -s vim_airline_a_visual fg=237,bg=175 # fg=#3c3836,bg=#d3869b + ble-face -s vim_airline_b fg=223,bg=239 # fg=#ebdbb2,bg=#504945 + ble-face -s vim_airline_b_inactive fg=187,bg=237 # fg=#d5c4a1,bg=#3c3836 + ble-face -s vim_airline_c fg=208,bg=237 # fg=#fe8019,bg=#3c3836 + ble-face -s vim_airline_c_inactive fg=187,bg=237 # fg=#d5c4a1,bg=#3c3836 + ble-face -s vim_airline_term fg=208,bg=237 # fg=#fe8019,bg=#3c3836 + ble-face -s vim_airline_term_inactive fg=158,bg=234 # fg=#9cffd3,bg=#202020 + ble-face -s vim_airline_term_insert fg=158,bg=234 # fg=#9cffd3,bg=#202020 +} diff --git a/.local/share/blesh/contrib/airline/base16_gruvbox_dark_medium.bash b/.local/share/blesh/contrib/airline/base16_gruvbox_dark_medium.bash new file mode 100644 index 0000000..c22f521 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_gruvbox_dark_medium.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_gruvbox_dark_medium.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Gruvbox dark, medium vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Dawid Kurek (dawikur@gmail.com), morhetz (https://github.com/morhetz/gruvbox) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_gruvbox_dark_medium/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=237,bg=144 # fg=#3c3836,bg=#bdae93 + ble-face -s vim_airline_a_inactive fg=237,bg=237 # fg=#3c3836,bg=#3c3836 + ble-face -s vim_airline_a_insert fg=237,bg=142 # fg=#3c3836,bg=#b8bb26 + ble-face -s vim_airline_a_replace fg=237,bg=175 # fg=#3c3836,bg=#d3869b + ble-face -s vim_airline_a_visual fg=237,bg=208 # fg=#3c3836,bg=#fe8019 + ble-face -s vim_airline_b fg=144,bg=239 # fg=#bdae93,bg=#504945 + ble-face -s vim_airline_b_inactive fg=144,bg=237 # fg=#bdae93,bg=#3c3836 + ble-face -s vim_airline_c fg=144,bg=237 # fg=#bdae93,bg=#3c3836 + ble-face -s vim_airline_c_inactive fg=187,bg=237 # fg=#d5c4a1,bg=#3c3836 + ble-face -s vim_airline_c_insert_modified fg=230,bg=237 # fg=#fbf1c7,bg=#3c3836 + ble-face -s vim_airline_c_normal_modified fg=230,bg=237 # fg=#fbf1c7,bg=#3c3836 + ble-face -s vim_airline_c_replace_modified fg=230,bg=237 # fg=#fbf1c7,bg=#3c3836 + ble-face -s vim_airline_c_visual_modified fg=230,bg=237 # fg=#fbf1c7,bg=#3c3836 +} diff --git a/.local/share/blesh/contrib/airline/base16_gruvbox_dark_pale.bash b/.local/share/blesh/contrib/airline/base16_gruvbox_dark_pale.bash new file mode 100644 index 0000000..d51e929 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_gruvbox_dark_pale.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_gruvbox_dark_pale.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Gruvbox dark, pale vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Dawid Kurek (dawikur@gmail.com), morhetz (https://github.com/morhetz/gruvbox) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_gruvbox_dark_pale/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=237,bg=246 # fg=#3a3a3a,bg=#949494 + ble-face -s vim_airline_a_inactive fg=237,bg=237 # fg=#3a3a3a,bg=#3a3a3a + ble-face -s vim_airline_a_insert fg=237,bg=142 # fg=#3a3a3a,bg=#afaf00 + ble-face -s vim_airline_a_replace fg=237,bg=175 # fg=#3a3a3a,bg=#d485ad + ble-face -s vim_airline_a_visual fg=237,bg=208 # fg=#3a3a3a,bg=#ff8700 + ble-face -s vim_airline_b fg=246,bg=239 # fg=#949494,bg=#4e4e4e + ble-face -s vim_airline_b_inactive fg=246,bg=237 # fg=#949494,bg=#3a3a3a + ble-face -s vim_airline_c fg=246,bg=237 # fg=#949494,bg=#3a3a3a + ble-face -s vim_airline_c_inactive fg=180,bg=237 # fg=#dab997,bg=#3a3a3a + ble-face -s vim_airline_c_insert_modified fg=223,bg=237 # fg=#ebdbb2,bg=#3a3a3a + ble-face -s vim_airline_c_normal_modified fg=223,bg=237 # fg=#ebdbb2,bg=#3a3a3a + ble-face -s vim_airline_c_replace_modified fg=223,bg=237 # fg=#ebdbb2,bg=#3a3a3a + ble-face -s vim_airline_c_visual_modified fg=223,bg=237 # fg=#ebdbb2,bg=#3a3a3a +} diff --git a/.local/share/blesh/contrib/airline/base16_gruvbox_dark_soft.bash b/.local/share/blesh/contrib/airline/base16_gruvbox_dark_soft.bash new file mode 100644 index 0000000..dcb618d --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_gruvbox_dark_soft.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_gruvbox_dark_soft.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Gruvbox dark, soft vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Dawid Kurek (dawikur@gmail.com), morhetz (https://github.com/morhetz/gruvbox) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_gruvbox_dark_soft/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=237,bg=144 # fg=#3c3836,bg=#bdae93 + ble-face -s vim_airline_a_inactive fg=237,bg=237 # fg=#3c3836,bg=#3c3836 + ble-face -s vim_airline_a_insert fg=237,bg=142 # fg=#3c3836,bg=#b8bb26 + ble-face -s vim_airline_a_replace fg=237,bg=175 # fg=#3c3836,bg=#d3869b + ble-face -s vim_airline_a_visual fg=237,bg=208 # fg=#3c3836,bg=#fe8019 + ble-face -s vim_airline_b fg=144,bg=239 # fg=#bdae93,bg=#504945 + ble-face -s vim_airline_b_inactive fg=144,bg=237 # fg=#bdae93,bg=#3c3836 + ble-face -s vim_airline_c fg=144,bg=237 # fg=#bdae93,bg=#3c3836 + ble-face -s vim_airline_c_inactive fg=187,bg=237 # fg=#d5c4a1,bg=#3c3836 + ble-face -s vim_airline_c_insert_modified fg=230,bg=237 # fg=#fbf1c7,bg=#3c3836 + ble-face -s vim_airline_c_normal_modified fg=230,bg=237 # fg=#fbf1c7,bg=#3c3836 + ble-face -s vim_airline_c_replace_modified fg=230,bg=237 # fg=#fbf1c7,bg=#3c3836 + ble-face -s vim_airline_c_visual_modified fg=230,bg=237 # fg=#fbf1c7,bg=#3c3836 +} diff --git a/.local/share/blesh/contrib/airline/base16_gruvbox_light_hard.bash b/.local/share/blesh/contrib/airline/base16_gruvbox_light_hard.bash new file mode 100644 index 0000000..5dac3d3 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_gruvbox_light_hard.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_gruvbox_light_hard.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Gruvbox light, hard vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Dawid Kurek (dawikur@gmail.com), morhetz (https://github.com/morhetz/gruvbox) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_gruvbox_light_hard/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=223,bg=60 # fg=#ebdbb2,bg=#665c54 + ble-face -s vim_airline_a_inactive fg=223,bg=223 # fg=#ebdbb2,bg=#ebdbb2 + ble-face -s vim_airline_a_insert fg=223,bg=100 # fg=#ebdbb2,bg=#79740e + ble-face -s vim_airline_a_replace fg=223,bg=95 # fg=#ebdbb2,bg=#8f3f71 + ble-face -s vim_airline_a_visual fg=223,bg=130 # fg=#ebdbb2,bg=#af3a03 + ble-face -s vim_airline_b fg=60,bg=187 # fg=#665c54,bg=#d5c4a1 + ble-face -s vim_airline_b_inactive fg=60,bg=223 # fg=#665c54,bg=#ebdbb2 + ble-face -s vim_airline_c fg=60,bg=223 # fg=#665c54,bg=#ebdbb2 + ble-face -s vim_airline_c_inactive fg=239,bg=223 # fg=#504945,bg=#ebdbb2 + ble-face -s vim_airline_c_insert_modified fg=235,bg=223 # fg=#282828,bg=#ebdbb2 + ble-face -s vim_airline_c_normal_modified fg=235,bg=223 # fg=#282828,bg=#ebdbb2 + ble-face -s vim_airline_c_replace_modified fg=235,bg=223 # fg=#282828,bg=#ebdbb2 + ble-face -s vim_airline_c_visual_modified fg=235,bg=223 # fg=#282828,bg=#ebdbb2 +} diff --git a/.local/share/blesh/contrib/airline/base16_gruvbox_light_medium.bash b/.local/share/blesh/contrib/airline/base16_gruvbox_light_medium.bash new file mode 100644 index 0000000..202c594 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_gruvbox_light_medium.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_gruvbox_light_medium.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Gruvbox light, medium vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Dawid Kurek (dawikur@gmail.com), morhetz (https://github.com/morhetz/gruvbox) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_gruvbox_light_medium/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=223,bg=60 # fg=#ebdbb2,bg=#665c54 + ble-face -s vim_airline_a_inactive fg=223,bg=223 # fg=#ebdbb2,bg=#ebdbb2 + ble-face -s vim_airline_a_insert fg=223,bg=100 # fg=#ebdbb2,bg=#79740e + ble-face -s vim_airline_a_replace fg=223,bg=95 # fg=#ebdbb2,bg=#8f3f71 + ble-face -s vim_airline_a_visual fg=223,bg=130 # fg=#ebdbb2,bg=#af3a03 + ble-face -s vim_airline_b fg=60,bg=187 # fg=#665c54,bg=#d5c4a1 + ble-face -s vim_airline_b_inactive fg=60,bg=223 # fg=#665c54,bg=#ebdbb2 + ble-face -s vim_airline_c fg=60,bg=223 # fg=#665c54,bg=#ebdbb2 + ble-face -s vim_airline_c_inactive fg=239,bg=223 # fg=#504945,bg=#ebdbb2 + ble-face -s vim_airline_c_insert_modified fg=235,bg=223 # fg=#282828,bg=#ebdbb2 + ble-face -s vim_airline_c_normal_modified fg=235,bg=223 # fg=#282828,bg=#ebdbb2 + ble-face -s vim_airline_c_replace_modified fg=235,bg=223 # fg=#282828,bg=#ebdbb2 + ble-face -s vim_airline_c_visual_modified fg=235,bg=223 # fg=#282828,bg=#ebdbb2 +} diff --git a/.local/share/blesh/contrib/airline/base16_gruvbox_light_soft.bash b/.local/share/blesh/contrib/airline/base16_gruvbox_light_soft.bash new file mode 100644 index 0000000..e9b4470 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_gruvbox_light_soft.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_gruvbox_light_soft.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Gruvbox light, soft vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Dawid Kurek (dawikur@gmail.com), morhetz (https://github.com/morhetz/gruvbox) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_gruvbox_light_soft/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=223,bg=60 # fg=#ebdbb2,bg=#665c54 + ble-face -s vim_airline_a_inactive fg=223,bg=223 # fg=#ebdbb2,bg=#ebdbb2 + ble-face -s vim_airline_a_insert fg=223,bg=100 # fg=#ebdbb2,bg=#79740e + ble-face -s vim_airline_a_replace fg=223,bg=95 # fg=#ebdbb2,bg=#8f3f71 + ble-face -s vim_airline_a_visual fg=223,bg=130 # fg=#ebdbb2,bg=#af3a03 + ble-face -s vim_airline_b fg=60,bg=187 # fg=#665c54,bg=#d5c4a1 + ble-face -s vim_airline_b_inactive fg=60,bg=223 # fg=#665c54,bg=#ebdbb2 + ble-face -s vim_airline_c fg=60,bg=223 # fg=#665c54,bg=#ebdbb2 + ble-face -s vim_airline_c_inactive fg=239,bg=223 # fg=#504945,bg=#ebdbb2 + ble-face -s vim_airline_c_insert_modified fg=235,bg=223 # fg=#282828,bg=#ebdbb2 + ble-face -s vim_airline_c_normal_modified fg=235,bg=223 # fg=#282828,bg=#ebdbb2 + ble-face -s vim_airline_c_replace_modified fg=235,bg=223 # fg=#282828,bg=#ebdbb2 + ble-face -s vim_airline_c_visual_modified fg=235,bg=223 # fg=#282828,bg=#ebdbb2 +} diff --git a/.local/share/blesh/contrib/airline/base16_harmonic16.bash b/.local/share/blesh/contrib/airline/base16_harmonic16.bash new file mode 100644 index 0000000..b3acef7 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_harmonic16.bash @@ -0,0 +1,21 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_harmonic16.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# vim-airline template by chartoin (http://github.com/chartoin) +# Base 16 harmonic16 Scheme by Jannik Siebert (https://github.com/janniks) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_harmonic16/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=23,bg=72 # fg=#223b54,bg=#56bf8b + ble-face -s vim_airline_a_inactive fg=190,bg=23 # fg=#cbd6e2,bg=#223b54 + ble-face -s vim_airline_a_insert fg=23,bg=97 # fg=#223b54,bg=#8b56bf + ble-face -s vim_airline_a_replace fg=23,bg=137 # fg=#223b54,bg=#bf8b56 + ble-face -s vim_airline_a_visual fg=23,bg=132 # fg=#223b54,bg=#bf568b + ble-face -s vim_airline_b fg=195,bg=60 # fg=#e5ebf1,bg=#405c79 + ble-face -s vim_airline_b_inactive fg=190,bg=23 # fg=#cbd6e2,bg=#223b54 + ble-face -s vim_airline_c fg=143,bg=23 # fg=#bfbf56,bg=#223b54 + ble-face -s vim_airline_c_inactive fg=190,bg=23 # fg=#cbd6e2,bg=#223b54 +} diff --git a/.local/share/blesh/contrib/airline/base16_harmonic_dark.bash b/.local/share/blesh/contrib/airline/base16_harmonic_dark.bash new file mode 100644 index 0000000..95a131a --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_harmonic_dark.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_harmonic_dark.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Harmonic16 Dark vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Jannik Siebert (https://github.com/janniks) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_harmonic_dark/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=23,bg=146 # fg=#223b54,bg=#aabcce + ble-face -s vim_airline_a_inactive fg=23,bg=23 # fg=#223b54,bg=#223b54 + ble-face -s vim_airline_a_insert fg=23,bg=72 # fg=#223b54,bg=#56bf8b + ble-face -s vim_airline_a_replace fg=23,bg=132 # fg=#223b54,bg=#bf568b + ble-face -s vim_airline_a_visual fg=23,bg=143 # fg=#223b54,bg=#bfbf56 + ble-face -s vim_airline_b fg=146,bg=60 # fg=#aabcce,bg=#405c79 + ble-face -s vim_airline_b_inactive fg=146,bg=23 # fg=#aabcce,bg=#223b54 + ble-face -s vim_airline_c fg=146,bg=23 # fg=#aabcce,bg=#223b54 + ble-face -s vim_airline_c_inactive fg=190,bg=23 # fg=#cbd6e2,bg=#223b54 + ble-face -s vim_airline_c_insert_modified fg=231,bg=23 # fg=#f7f9fb,bg=#223b54 + ble-face -s vim_airline_c_normal_modified fg=231,bg=23 # fg=#f7f9fb,bg=#223b54 + ble-face -s vim_airline_c_replace_modified fg=231,bg=23 # fg=#f7f9fb,bg=#223b54 + ble-face -s vim_airline_c_visual_modified fg=231,bg=23 # fg=#f7f9fb,bg=#223b54 +} diff --git a/.local/share/blesh/contrib/airline/base16_harmonic_light.bash b/.local/share/blesh/contrib/airline/base16_harmonic_light.bash new file mode 100644 index 0000000..ca0ea50 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_harmonic_light.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_harmonic_light.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Harmonic16 Light vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Jannik Siebert (https://github.com/janniks) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_harmonic_light/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=195,bg=66 # fg=#e5ebf1,bg=#627e99 + ble-face -s vim_airline_a_inactive fg=195,bg=195 # fg=#e5ebf1,bg=#e5ebf1 + ble-face -s vim_airline_a_insert fg=195,bg=72 # fg=#e5ebf1,bg=#56bf8b + ble-face -s vim_airline_a_replace fg=195,bg=132 # fg=#e5ebf1,bg=#bf568b + ble-face -s vim_airline_a_visual fg=195,bg=143 # fg=#e5ebf1,bg=#bfbf56 + ble-face -s vim_airline_b fg=66,bg=190 # fg=#627e99,bg=#cbd6e2 + ble-face -s vim_airline_b_inactive fg=66,bg=195 # fg=#627e99,bg=#e5ebf1 + ble-face -s vim_airline_c fg=66,bg=195 # fg=#627e99,bg=#e5ebf1 + ble-face -s vim_airline_c_inactive fg=60,bg=195 # fg=#405c79,bg=#e5ebf1 + ble-face -s vim_airline_c_insert_modified fg=234,bg=195 # fg=#0b1c2c,bg=#e5ebf1 + ble-face -s vim_airline_c_normal_modified fg=234,bg=195 # fg=#0b1c2c,bg=#e5ebf1 + ble-face -s vim_airline_c_replace_modified fg=234,bg=195 # fg=#0b1c2c,bg=#e5ebf1 + ble-face -s vim_airline_c_visual_modified fg=234,bg=195 # fg=#0b1c2c,bg=#e5ebf1 +} diff --git a/.local/share/blesh/contrib/airline/base16_heetch.bash b/.local/share/blesh/contrib/airline/base16_heetch.bash new file mode 100644 index 0000000..4f34bda --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_heetch.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_heetch.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Heetch Dark vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Geoffrey Teale (tealeg@gmail.com) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_heetch/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=53,bg=139 # fg=#392551,bg=#9c92a8 + ble-face -s vim_airline_a_inactive fg=53,bg=53 # fg=#392551,bg=#392551 + ble-face -s vim_airline_a_insert fg=53,bg=168 # fg=#392551,bg=#c33678 + ble-face -s vim_airline_a_replace fg=53,bg=89 # fg=#392551,bg=#82034c + ble-face -s vim_airline_a_visual fg=53,bg=73 # fg=#392551,bg=#5ba2b6 + ble-face -s vim_airline_b fg=139,bg=240 # fg=#9c92a8,bg=#5a496e + ble-face -s vim_airline_b_inactive fg=139,bg=53 # fg=#9c92a8,bg=#392551 + ble-face -s vim_airline_c fg=139,bg=53 # fg=#9c92a8,bg=#392551 + ble-face -s vim_airline_c_inactive fg=146,bg=53 # fg=#bdb6c5,bg=#392551 + ble-face -s vim_airline_c_insert_modified fg=231,bg=53 # fg=#feffff,bg=#392551 + ble-face -s vim_airline_c_normal_modified fg=231,bg=53 # fg=#feffff,bg=#392551 + ble-face -s vim_airline_c_replace_modified fg=231,bg=53 # fg=#feffff,bg=#392551 + ble-face -s vim_airline_c_visual_modified fg=231,bg=53 # fg=#feffff,bg=#392551 +} diff --git a/.local/share/blesh/contrib/airline/base16_heetch_light.bash b/.local/share/blesh/contrib/airline/base16_heetch_light.bash new file mode 100644 index 0000000..1f523db --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_heetch_light.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_heetch_light.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Heetch Light vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Geoffrey Teale (tealeg@gmail.com) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_heetch_light/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=53,bg=253 # fg=#392551,bg=#ddd6e5 + ble-face -s vim_airline_a_inactive fg=53,bg=53 # fg=#392551,bg=#392551 + ble-face -s vim_airline_a_insert fg=53,bg=197 # fg=#392551,bg=#f80059 + ble-face -s vim_airline_a_replace fg=53,bg=125 # fg=#392551,bg=#bd0152 + ble-face -s vim_airline_a_visual fg=53,bg=146 # fg=#392551,bg=#bdb6c5 + ble-face -s vim_airline_b fg=253,bg=96 # fg=#ddd6e5,bg=#7b6d8b + ble-face -s vim_airline_b_inactive fg=253,bg=53 # fg=#ddd6e5,bg=#392551 + ble-face -s vim_airline_c fg=253,bg=53 # fg=#ddd6e5,bg=#392551 + ble-face -s vim_airline_c_inactive fg=240,bg=53 # fg=#5a496e,bg=#392551 + ble-face -s vim_airline_c_insert_modified fg=17,bg=53 # fg=#190134,bg=#392551 + ble-face -s vim_airline_c_normal_modified fg=17,bg=53 # fg=#190134,bg=#392551 + ble-face -s vim_airline_c_replace_modified fg=17,bg=53 # fg=#190134,bg=#392551 + ble-face -s vim_airline_c_visual_modified fg=17,bg=53 # fg=#190134,bg=#392551 +} diff --git a/.local/share/blesh/contrib/airline/base16_helios.bash b/.local/share/blesh/contrib/airline/base16_helios.bash new file mode 100644 index 0000000..f590d87 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_helios.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_helios.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Helios vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Alex Meyer (https://github.com/reyemxela) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_helios/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=237,bg=252 # fg=#383c3e,bg=#cdcdcd + ble-face -s vim_airline_a_inactive fg=237,bg=237 # fg=#383c3e,bg=#383c3e + ble-face -s vim_airline_a_insert fg=237,bg=106 # fg=#383c3e,bg=#88b92d + ble-face -s vim_airline_a_replace fg=237,bg=131 # fg=#383c3e,bg=#be4264 + ble-face -s vim_airline_a_visual fg=237,bg=208 # fg=#383c3e,bg=#eb8413 + ble-face -s vim_airline_b fg=252,bg=240 # fg=#cdcdcd,bg=#53585b + ble-face -s vim_airline_b_inactive fg=252,bg=237 # fg=#cdcdcd,bg=#383c3e + ble-face -s vim_airline_c fg=252,bg=237 # fg=#cdcdcd,bg=#383c3e + ble-face -s vim_airline_c_inactive fg=189,bg=237 # fg=#d5d5d5,bg=#383c3e + ble-face -s vim_airline_c_insert_modified fg=254,bg=237 # fg=#e5e5e5,bg=#383c3e + ble-face -s vim_airline_c_normal_modified fg=254,bg=237 # fg=#e5e5e5,bg=#383c3e + ble-face -s vim_airline_c_replace_modified fg=254,bg=237 # fg=#e5e5e5,bg=#383c3e + ble-face -s vim_airline_c_visual_modified fg=254,bg=237 # fg=#e5e5e5,bg=#383c3e +} diff --git a/.local/share/blesh/contrib/airline/base16_hopscotch.bash b/.local/share/blesh/contrib/airline/base16_hopscotch.bash new file mode 100644 index 0000000..0c16025 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_hopscotch.bash @@ -0,0 +1,21 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_hopscotch.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# vim-airline template by chartoin (http://github.com/chartoin) +# Base 16 Hopscotch Scheme by Jan T. Sott + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_hopscotch/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=238,bg=107 # fg=#433b42,bg=#8fc13e + ble-face -s vim_airline_a_inactive fg=250,bg=238 # fg=#b9b5b8,bg=#433b42 + ble-face -s vim_airline_a_insert fg=238,bg=31 # fg=#433b42,bg=#1290bf + ble-face -s vim_airline_a_replace fg=238,bg=167 # fg=#433b42,bg=#dd464c + ble-face -s vim_airline_a_visual fg=238,bg=168 # fg=#433b42,bg=#c85e7c + ble-face -s vim_airline_b fg=188,bg=240 # fg=#d5d3d5,bg=#5c545b + ble-face -s vim_airline_b_inactive fg=250,bg=238 # fg=#b9b5b8,bg=#433b42 + ble-face -s vim_airline_c fg=208,bg=238 # fg=#fd8b19,bg=#433b42 + ble-face -s vim_airline_c_inactive fg=250,bg=238 # fg=#b9b5b8,bg=#433b42 +} diff --git a/.local/share/blesh/contrib/airline/base16_horizon_dark.bash b/.local/share/blesh/contrib/airline/base16_horizon_dark.bash new file mode 100644 index 0000000..dfa365f --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_horizon_dark.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_horizon_dark.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Horizon Dark vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Michaël Ball (http://github.com/michael-ball/) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_horizon_dark/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=17,bg=247 # fg=#232530,bg=#9da0a2 + ble-face -s vim_airline_a_inactive fg=17,bg=17 # fg=#232530,bg=#232530 + ble-face -s vim_airline_a_insert fg=17,bg=216 # fg=#232530,bg=#efaf8e + ble-face -s vim_airline_a_replace fg=17,bg=134 # fg=#232530,bg=#b072d1 + ble-face -s vim_airline_a_visual fg=17,bg=174 # fg=#232530,bg=#e58d7d + ble-face -s vim_airline_b fg=247,bg=23 # fg=#9da0a2,bg=#2e303e + ble-face -s vim_airline_b_inactive fg=247,bg=17 # fg=#9da0a2,bg=#232530 + ble-face -s vim_airline_c fg=247,bg=17 # fg=#9da0a2,bg=#232530 + ble-face -s vim_airline_c_inactive fg=252,bg=17 # fg=#cbced0,bg=#232530 + ble-face -s vim_airline_c_insert_modified fg=189,bg=17 # fg=#e3e6ee,bg=#232530 + ble-face -s vim_airline_c_normal_modified fg=189,bg=17 # fg=#e3e6ee,bg=#232530 + ble-face -s vim_airline_c_replace_modified fg=189,bg=17 # fg=#e3e6ee,bg=#232530 + ble-face -s vim_airline_c_visual_modified fg=189,bg=17 # fg=#e3e6ee,bg=#232530 +} diff --git a/.local/share/blesh/contrib/airline/base16_horizon_light.bash b/.local/share/blesh/contrib/airline/base16_horizon_light.bash new file mode 100644 index 0000000..6449933 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_horizon_light.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_horizon_light.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Horizon Light vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Michaël Ball (http://github.com/michael-ball/) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_horizon_light/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=224,bg=245 # fg=#fadad1,bg=#948c8a + ble-face -s vim_airline_a_inactive fg=224,bg=224 # fg=#fadad1,bg=#fadad1 + ble-face -s vim_airline_a_insert fg=224,bg=115 # fg=#fadad1,bg=#94e1b0 + ble-face -s vim_airline_a_replace fg=224,bg=30 # fg=#fadad1,bg=#1d8991 + ble-face -s vim_airline_a_visual fg=224,bg=202 # fg=#fadad1,bg=#f6661e + ble-face -s vim_airline_b fg=245,bg=223 # fg=#948c8a,bg=#f9cbbe + ble-face -s vim_airline_b_inactive fg=245,bg=224 # fg=#948c8a,bg=#fadad1 + ble-face -s vim_airline_c fg=245,bg=224 # fg=#948c8a,bg=#fadad1 + ble-face -s vim_airline_c_inactive fg=237,bg=224 # fg=#403c3d,bg=#fadad1 + ble-face -s vim_airline_c_insert_modified fg=234,bg=224 # fg=#201c1d,bg=#fadad1 + ble-face -s vim_airline_c_normal_modified fg=234,bg=224 # fg=#201c1d,bg=#fadad1 + ble-face -s vim_airline_c_replace_modified fg=234,bg=224 # fg=#201c1d,bg=#fadad1 + ble-face -s vim_airline_c_visual_modified fg=234,bg=224 # fg=#201c1d,bg=#fadad1 +} diff --git a/.local/share/blesh/contrib/airline/base16_horizon_terminal_dark.bash b/.local/share/blesh/contrib/airline/base16_horizon_terminal_dark.bash new file mode 100644 index 0000000..3e605ef --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_horizon_terminal_dark.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_horizon_terminal_dark.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Horizon Dark vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Michaël Ball (http://github.com/michael-ball/) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_horizon_terminal_dark/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=17,bg=247 # fg=#232530,bg=#9da0a2 + ble-face -s vim_airline_a_inactive fg=17,bg=17 # fg=#232530,bg=#232530 + ble-face -s vim_airline_a_insert fg=17,bg=42 # fg=#232530,bg=#29d398 + ble-face -s vim_airline_a_replace fg=17,bg=205 # fg=#232530,bg=#ee64ac + ble-face -s vim_airline_a_visual fg=17,bg=216 # fg=#232530,bg=#fab795 + ble-face -s vim_airline_b fg=247,bg=23 # fg=#9da0a2,bg=#2e303e + ble-face -s vim_airline_b_inactive fg=247,bg=17 # fg=#9da0a2,bg=#232530 + ble-face -s vim_airline_c fg=247,bg=17 # fg=#9da0a2,bg=#232530 + ble-face -s vim_airline_c_inactive fg=252,bg=17 # fg=#cbced0,bg=#232530 + ble-face -s vim_airline_c_insert_modified fg=189,bg=17 # fg=#e3e6ee,bg=#232530 + ble-face -s vim_airline_c_normal_modified fg=189,bg=17 # fg=#e3e6ee,bg=#232530 + ble-face -s vim_airline_c_replace_modified fg=189,bg=17 # fg=#e3e6ee,bg=#232530 + ble-face -s vim_airline_c_visual_modified fg=189,bg=17 # fg=#e3e6ee,bg=#232530 +} diff --git a/.local/share/blesh/contrib/airline/base16_horizon_terminal_light.bash b/.local/share/blesh/contrib/airline/base16_horizon_terminal_light.bash new file mode 100644 index 0000000..c0201c6 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_horizon_terminal_light.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_horizon_terminal_light.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Horizon Light vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Michaël Ball (http://github.com/michael-ball/) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_horizon_terminal_light/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=224,bg=245 # fg=#fadad1,bg=#948c8a + ble-face -s vim_airline_a_inactive fg=224,bg=224 # fg=#fadad1,bg=#fadad1 + ble-face -s vim_airline_a_insert fg=224,bg=42 # fg=#fadad1,bg=#29d398 + ble-face -s vim_airline_a_replace fg=224,bg=205 # fg=#fadad1,bg=#ee64ac + ble-face -s vim_airline_a_visual fg=224,bg=224 # fg=#fadad1,bg=#f9cec3 + ble-face -s vim_airline_b fg=245,bg=223 # fg=#948c8a,bg=#f9cbbe + ble-face -s vim_airline_b_inactive fg=245,bg=224 # fg=#948c8a,bg=#fadad1 + ble-face -s vim_airline_c fg=245,bg=224 # fg=#948c8a,bg=#fadad1 + ble-face -s vim_airline_c_inactive fg=237,bg=224 # fg=#403c3d,bg=#fadad1 + ble-face -s vim_airline_c_insert_modified fg=234,bg=224 # fg=#201c1d,bg=#fadad1 + ble-face -s vim_airline_c_normal_modified fg=234,bg=224 # fg=#201c1d,bg=#fadad1 + ble-face -s vim_airline_c_replace_modified fg=234,bg=224 # fg=#201c1d,bg=#fadad1 + ble-face -s vim_airline_c_visual_modified fg=234,bg=224 # fg=#201c1d,bg=#fadad1 +} diff --git a/.local/share/blesh/contrib/airline/base16_ia_dark.bash b/.local/share/blesh/contrib/airline/base16_ia_dark.bash new file mode 100644 index 0000000..a2e4dfe --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_ia_dark.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_ia_dark.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 iA Dark vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By iA Inc. (modified by aramisgithub) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_ia_dark/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=235,bg=250 # fg=#222222,bg=#b8b8b8 + ble-face -s vim_airline_a_inactive fg=235,bg=235 # fg=#222222,bg=#222222 + ble-face -s vim_airline_a_insert fg=235,bg=107 # fg=#222222,bg=#83a471 + ble-face -s vim_airline_a_replace fg=235,bg=139 # fg=#222222,bg=#b98eb2 + ble-face -s vim_airline_a_visual fg=235,bg=167 # fg=#222222,bg=#d86868 + ble-face -s vim_airline_b fg=250,bg=23 # fg=#b8b8b8,bg=#1d414d + ble-face -s vim_airline_b_inactive fg=250,bg=235 # fg=#b8b8b8,bg=#222222 + ble-face -s vim_airline_c fg=250,bg=235 # fg=#b8b8b8,bg=#222222 + ble-face -s vim_airline_c_inactive fg=252,bg=235 # fg=#cccccc,bg=#222222 + ble-face -s vim_airline_c_insert_modified fg=231,bg=235 # fg=#f8f8f8,bg=#222222 + ble-face -s vim_airline_c_normal_modified fg=231,bg=235 # fg=#f8f8f8,bg=#222222 + ble-face -s vim_airline_c_replace_modified fg=231,bg=235 # fg=#f8f8f8,bg=#222222 + ble-face -s vim_airline_c_visual_modified fg=231,bg=235 # fg=#f8f8f8,bg=#222222 +} diff --git a/.local/share/blesh/contrib/airline/base16_ia_light.bash b/.local/share/blesh/contrib/airline/base16_ia_light.bash new file mode 100644 index 0000000..6a516c4 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_ia_light.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_ia_light.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 iA Light vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By iA Inc. (modified by aramisgithub) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_ia_light/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=253,bg=243 # fg=#dedede,bg=#767676 + ble-face -s vim_airline_a_inactive fg=253,bg=253 # fg=#dedede,bg=#dedede + ble-face -s vim_airline_a_insert fg=253,bg=64 # fg=#dedede,bg=#38781c + ble-face -s vim_airline_a_replace fg=253,bg=132 # fg=#dedede,bg=#a94598 + ble-face -s vim_airline_a_visual fg=253,bg=166 # fg=#dedede,bg=#c43e18 + ble-face -s vim_airline_b fg=243,bg=153 # fg=#767676,bg=#bde5f2 + ble-face -s vim_airline_b_inactive fg=243,bg=253 # fg=#767676,bg=#dedede + ble-face -s vim_airline_c fg=243,bg=253 # fg=#767676,bg=#dedede + ble-face -s vim_airline_c_inactive fg=234,bg=253 # fg=#181818,bg=#dedede + ble-face -s vim_airline_c_insert_modified fg=231,bg=253 # fg=#f8f8f8,bg=#dedede + ble-face -s vim_airline_c_normal_modified fg=231,bg=253 # fg=#f8f8f8,bg=#dedede + ble-face -s vim_airline_c_replace_modified fg=231,bg=253 # fg=#f8f8f8,bg=#dedede + ble-face -s vim_airline_c_visual_modified fg=231,bg=253 # fg=#f8f8f8,bg=#dedede +} diff --git a/.local/share/blesh/contrib/airline/base16_icy.bash b/.local/share/blesh/contrib/airline/base16_icy.bash new file mode 100644 index 0000000..96b528c --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_icy.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_icy.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Icy Dark vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By icyphox (https://icyphox.ga) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_icy/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=233,bg=23 # fg=#031619,bg=#064048 + ble-face -s vim_airline_a_inactive fg=233,bg=233 # fg=#031619,bg=#031619 + ble-face -s vim_airline_a_insert fg=233,bg=80 # fg=#031619,bg=#4dd0e1 + ble-face -s vim_airline_a_replace fg=233,bg=37 # fg=#031619,bg=#00acc1 + ble-face -s vim_airline_a_visual fg=233,bg=159 # fg=#031619,bg=#b3ebf2 + ble-face -s vim_airline_b fg=23,bg=234 # fg=#064048,bg=#041f23 + ble-face -s vim_airline_b_inactive fg=23,bg=233 # fg=#064048,bg=#031619 + ble-face -s vim_airline_c fg=23,bg=233 # fg=#064048,bg=#031619 + ble-face -s vim_airline_c_inactive fg=23,bg=233 # fg=#095b67,bg=#031619 + ble-face -s vim_airline_c_insert_modified fg=37,bg=233 # fg=#109cb0,bg=#031619 + ble-face -s vim_airline_c_normal_modified fg=37,bg=233 # fg=#109cb0,bg=#031619 + ble-face -s vim_airline_c_replace_modified fg=37,bg=233 # fg=#109cb0,bg=#031619 + ble-face -s vim_airline_c_visual_modified fg=37,bg=233 # fg=#109cb0,bg=#031619 +} diff --git a/.local/share/blesh/contrib/airline/base16_irblack.bash b/.local/share/blesh/contrib/airline/base16_irblack.bash new file mode 100644 index 0000000..71a6002 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_irblack.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_irblack.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 IR Black vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Timothée Poisot (http://timotheepoisot.fr) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_irblack/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=235,bg=245 # fg=#242422,bg=#918f88 + ble-face -s vim_airline_a_inactive fg=235,bg=235 # fg=#242422,bg=#242422 + ble-face -s vim_airline_a_insert fg=235,bg=155 # fg=#242422,bg=#a8ff60 + ble-face -s vim_airline_a_replace fg=235,bg=213 # fg=#242422,bg=#ff73fd + ble-face -s vim_airline_a_visual fg=235,bg=179 # fg=#242422,bg=#e9c062 + ble-face -s vim_airline_b fg=245,bg=238 # fg=#918f88,bg=#484844 + ble-face -s vim_airline_b_inactive fg=245,bg=235 # fg=#918f88,bg=#242422 + ble-face -s vim_airline_c fg=245,bg=235 # fg=#918f88,bg=#242422 + ble-face -s vim_airline_c_inactive fg=249,bg=235 # fg=#b5b3aa,bg=#242422 + ble-face -s vim_airline_c_insert_modified fg=231,bg=235 # fg=#fdfbee,bg=#242422 + ble-face -s vim_airline_c_normal_modified fg=231,bg=235 # fg=#fdfbee,bg=#242422 + ble-face -s vim_airline_c_replace_modified fg=231,bg=235 # fg=#fdfbee,bg=#242422 + ble-face -s vim_airline_c_visual_modified fg=231,bg=235 # fg=#fdfbee,bg=#242422 +} diff --git a/.local/share/blesh/contrib/airline/base16_isotope.bash b/.local/share/blesh/contrib/airline/base16_isotope.bash new file mode 100644 index 0000000..23693db --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_isotope.bash @@ -0,0 +1,21 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_isotope.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# vim-airline template by chartoin (http://github.com/chartoin) +# Base 16 Isotope Scheme by Jan T. Sott + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_isotope/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=238,bg=82 # fg=#404040,bg=#33ff00 + ble-face -s vim_airline_a_inactive fg=252,bg=238 # fg=#d0d0d0,bg=#404040 + ble-face -s vim_airline_a_insert fg=238,bg=27 # fg=#404040,bg=#0066ff + ble-face -s vim_airline_a_replace fg=238,bg=196 # fg=#404040,bg=#ff0000 + ble-face -s vim_airline_a_visual fg=238,bg=165 # fg=#404040,bg=#cc00ff + ble-face -s vim_airline_b fg=254,bg=63 # fg=#e0e0e0,bg=#606060 + ble-face -s vim_airline_b_inactive fg=252,bg=238 # fg=#d0d0d0,bg=#404040 + ble-face -s vim_airline_c fg=208,bg=238 # fg=#ff9900,bg=#404040 + ble-face -s vim_airline_c_inactive fg=252,bg=238 # fg=#d0d0d0,bg=#404040 +} diff --git a/.local/share/blesh/contrib/airline/base16_londontube.bash b/.local/share/blesh/contrib/airline/base16_londontube.bash new file mode 100644 index 0000000..a1df9bb --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_londontube.bash @@ -0,0 +1,21 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_londontube.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# vim-airline template by chartoin (http://github.com/chartoin) +# Base 16 London Tube Scheme by Jan T. Sott + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_londontube/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=24,bg=29 # fg=#1c3f95,bg=#00853e + ble-face -s vim_airline_a_inactive fg=192,bg=24 # fg=#d9d8d8,bg=#1c3f95 + ble-face -s vim_airline_a_insert fg=24,bg=38 # fg=#1c3f95,bg=#009ddc + ble-face -s vim_airline_a_replace fg=24,bg=196 # fg=#1c3f95,bg=#ee2e24 + ble-face -s vim_airline_a_visual fg=24,bg=89 # fg=#1c3f95,bg=#98005d + ble-face -s vim_airline_b fg=254,bg=240 # fg=#e7e7e8,bg=#5a5758 + ble-face -s vim_airline_b_inactive fg=192,bg=24 # fg=#d9d8d8,bg=#1c3f95 + ble-face -s vim_airline_c fg=211,bg=24 # fg=#f386a1,bg=#1c3f95 + ble-face -s vim_airline_c_inactive fg=192,bg=24 # fg=#d9d8d8,bg=#1c3f95 +} diff --git a/.local/share/blesh/contrib/airline/base16_macintosh.bash b/.local/share/blesh/contrib/airline/base16_macintosh.bash new file mode 100644 index 0000000..543cf45 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_macintosh.bash @@ -0,0 +1,25 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_macintosh.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Macintosh vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Rebecca Bettencourt (http://www.kreativekorp.com) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_macintosh/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=238,bg=244 # fg=#404040,bg=#808080 + ble-face -s vim_airline_a_inactive fg=238,bg=238 # fg=#404040,bg=#404040 + ble-face -s vim_airline_a_insert fg=238,bg=34 # fg=#404040,bg=#1fb714 + ble-face -s vim_airline_a_replace fg=238,bg=55 # fg=#404040,bg=#4700a5 + ble-face -s vim_airline_a_visual fg=238,bg=202 # fg=#404040,bg=#ff6403 + ble-face -s vim_airline_b fg=244,bg=238 # fg=#808080,bg=#404040 + ble-face -s vim_airline_c fg=244,bg=238 # fg=#808080,bg=#404040 + ble-face -s vim_airline_c_inactive fg=250,bg=238 # fg=#c0c0c0,bg=#404040 + ble-face -s vim_airline_c_insert_modified fg=231,bg=238 # fg=#ffffff,bg=#404040 + ble-face -s vim_airline_c_normal_modified fg=231,bg=238 # fg=#ffffff,bg=#404040 + ble-face -s vim_airline_c_replace_modified fg=231,bg=238 # fg=#ffffff,bg=#404040 + ble-face -s vim_airline_c_visual_modified fg=231,bg=238 # fg=#ffffff,bg=#404040 +} diff --git a/.local/share/blesh/contrib/airline/base16_marrakesh.bash b/.local/share/blesh/contrib/airline/base16_marrakesh.bash new file mode 100644 index 0000000..cd0805f --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_marrakesh.bash @@ -0,0 +1,21 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_marrakesh.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# vim-airline template by chartoin (http://github.com/chartoin) +# Base 16 Marrakesh Scheme by Alexandre Gavioli (http://github.com/Alexx2/) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_marrakesh/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=52,bg=29 # fg=#302e00,bg=#18974e + ble-face -s vim_airline_a_inactive fg=101,bg=52 # fg=#948e48,bg=#302e00 + ble-face -s vim_airline_a_insert fg=52,bg=67 # fg=#302e00,bg=#477ca1 + ble-face -s vim_airline_a_replace fg=52,bg=167 # fg=#302e00,bg=#c35359 + ble-face -s vim_airline_a_visual fg=52,bg=97 # fg=#302e00,bg=#8868b3 + ble-face -s vim_airline_b fg=186,bg=58 # fg=#ccc37a,bg=#5f5b17 + ble-face -s vim_airline_b_inactive fg=101,bg=52 # fg=#948e48,bg=#302e00 + ble-face -s vim_airline_c fg=131,bg=52 # fg=#b36144,bg=#302e00 + ble-face -s vim_airline_c_inactive fg=101,bg=52 # fg=#948e48,bg=#302e00 +} diff --git a/.local/share/blesh/contrib/airline/base16_materia.bash b/.local/share/blesh/contrib/airline/base16_materia.bash new file mode 100644 index 0000000..e356988 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_materia.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_materia.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Materia vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Defman21 + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_materia/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=23,bg=252 # fg=#2c393f,bg=#c9ccd3 + ble-face -s vim_airline_a_inactive fg=23,bg=23 # fg=#2c393f,bg=#2c393f + ble-face -s vim_airline_a_insert fg=23,bg=113 # fg=#2c393f,bg=#8bd649 + ble-face -s vim_airline_a_replace fg=23,bg=111 # fg=#2c393f,bg=#82aaff + ble-face -s vim_airline_a_visual fg=23,bg=173 # fg=#2c393f,bg=#ea9560 + ble-face -s vim_airline_b fg=252,bg=238 # fg=#c9ccd3,bg=#37474f + ble-face -s vim_airline_b_inactive fg=252,bg=23 # fg=#c9ccd3,bg=#2c393f + ble-face -s vim_airline_c fg=252,bg=23 # fg=#c9ccd3,bg=#2c393f + ble-face -s vim_airline_c_inactive fg=189,bg=23 # fg=#cdd3de,bg=#2c393f + ble-face -s vim_airline_c_insert_modified fg=231,bg=23 # fg=#ffffff,bg=#2c393f + ble-face -s vim_airline_c_normal_modified fg=231,bg=23 # fg=#ffffff,bg=#2c393f + ble-face -s vim_airline_c_replace_modified fg=231,bg=23 # fg=#ffffff,bg=#2c393f + ble-face -s vim_airline_c_visual_modified fg=231,bg=23 # fg=#ffffff,bg=#2c393f +} diff --git a/.local/share/blesh/contrib/airline/base16_material.bash b/.local/share/blesh/contrib/airline/base16_material.bash new file mode 100644 index 0000000..975fd3a --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_material.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_material.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Material vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Nate Peterson + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_material/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=23,bg=152 # fg=#2e3c43,bg=#b2ccd6 + ble-face -s vim_airline_a_inactive fg=23,bg=23 # fg=#2e3c43,bg=#2e3c43 + ble-face -s vim_airline_a_insert fg=23,bg=186 # fg=#2e3c43,bg=#c3e88d + ble-face -s vim_airline_a_replace fg=23,bg=176 # fg=#2e3c43,bg=#c792ea + ble-face -s vim_airline_a_visual fg=23,bg=209 # fg=#2e3c43,bg=#f78c6c + ble-face -s vim_airline_b fg=152,bg=238 # fg=#b2ccd6,bg=#314549 + ble-face -s vim_airline_b_inactive fg=152,bg=23 # fg=#b2ccd6,bg=#2e3c43 + ble-face -s vim_airline_c fg=152,bg=23 # fg=#b2ccd6,bg=#2e3c43 + ble-face -s vim_airline_c_inactive fg=231,bg=23 # fg=#eeffff,bg=#2e3c43 + ble-face -s vim_airline_c_insert_modified fg=231,bg=23 # fg=#ffffff,bg=#2e3c43 + ble-face -s vim_airline_c_normal_modified fg=231,bg=23 # fg=#ffffff,bg=#2e3c43 + ble-face -s vim_airline_c_replace_modified fg=231,bg=23 # fg=#ffffff,bg=#2e3c43 + ble-face -s vim_airline_c_visual_modified fg=231,bg=23 # fg=#ffffff,bg=#2e3c43 +} diff --git a/.local/share/blesh/contrib/airline/base16_material_darker.bash b/.local/share/blesh/contrib/airline/base16_material_darker.bash new file mode 100644 index 0000000..49163f4 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_material_darker.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_material_darker.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Material Darker vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Nate Peterson + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_material_darker/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=236,bg=152 # fg=#303030,bg=#b2ccd6 + ble-face -s vim_airline_a_inactive fg=236,bg=236 # fg=#303030,bg=#303030 + ble-face -s vim_airline_a_insert fg=236,bg=186 # fg=#303030,bg=#c3e88d + ble-face -s vim_airline_a_replace fg=236,bg=176 # fg=#303030,bg=#c792ea + ble-face -s vim_airline_a_visual fg=236,bg=209 # fg=#303030,bg=#f78c6c + ble-face -s vim_airline_b fg=152,bg=237 # fg=#b2ccd6,bg=#353535 + ble-face -s vim_airline_b_inactive fg=152,bg=236 # fg=#b2ccd6,bg=#303030 + ble-face -s vim_airline_c fg=152,bg=236 # fg=#b2ccd6,bg=#303030 + ble-face -s vim_airline_c_inactive fg=231,bg=236 # fg=#eeffff,bg=#303030 + ble-face -s vim_airline_c_insert_modified fg=231,bg=236 # fg=#ffffff,bg=#303030 + ble-face -s vim_airline_c_normal_modified fg=231,bg=236 # fg=#ffffff,bg=#303030 + ble-face -s vim_airline_c_replace_modified fg=231,bg=236 # fg=#ffffff,bg=#303030 + ble-face -s vim_airline_c_visual_modified fg=231,bg=236 # fg=#ffffff,bg=#303030 +} diff --git a/.local/share/blesh/contrib/airline/base16_material_lighter.bash b/.local/share/blesh/contrib/airline/base16_material_lighter.bash new file mode 100644 index 0000000..bc6c5ff --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_material_lighter.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_material_lighter.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Material Lighter vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Nate Peterson + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_material_lighter/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=189,bg=103 # fg=#e7eaec,bg=#8796b0 + ble-face -s vim_airline_a_inactive fg=189,bg=189 # fg=#e7eaec,bg=#e7eaec + ble-face -s vim_airline_a_insert fg=189,bg=107 # fg=#e7eaec,bg=#91b859 + ble-face -s vim_airline_a_replace fg=189,bg=99 # fg=#e7eaec,bg=#7c4dff + ble-face -s vim_airline_a_visual fg=189,bg=203 # fg=#e7eaec,bg=#f76d47 + ble-face -s vim_airline_b fg=103,bg=254 # fg=#8796b0,bg=#cceae7 + ble-face -s vim_airline_b_inactive fg=103,bg=189 # fg=#8796b0,bg=#e7eaec + ble-face -s vim_airline_c fg=103,bg=189 # fg=#8796b0,bg=#e7eaec + ble-face -s vim_airline_c_inactive fg=116,bg=189 # fg=#80cbc4,bg=#e7eaec + ble-face -s vim_airline_c_insert_modified fg=231,bg=189 # fg=#ffffff,bg=#e7eaec + ble-face -s vim_airline_c_normal_modified fg=231,bg=189 # fg=#ffffff,bg=#e7eaec + ble-face -s vim_airline_c_replace_modified fg=231,bg=189 # fg=#ffffff,bg=#e7eaec + ble-face -s vim_airline_c_visual_modified fg=231,bg=189 # fg=#ffffff,bg=#e7eaec +} diff --git a/.local/share/blesh/contrib/airline/base16_material_palenight.bash b/.local/share/blesh/contrib/airline/base16_material_palenight.bash new file mode 100644 index 0000000..8c3b973 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_material_palenight.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_material_palenight.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Material Palenight vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Nate Peterson + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_material_palenight/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=239,bg=103 # fg=#444267,bg=#8796b0 + ble-face -s vim_airline_a_inactive fg=239,bg=239 # fg=#444267,bg=#444267 + ble-face -s vim_airline_a_insert fg=239,bg=186 # fg=#444267,bg=#c3e88d + ble-face -s vim_airline_a_replace fg=239,bg=176 # fg=#444267,bg=#c792ea + ble-face -s vim_airline_a_visual fg=239,bg=209 # fg=#444267,bg=#f78c6c + ble-face -s vim_airline_b fg=103,bg=237 # fg=#8796b0,bg=#32374d + ble-face -s vim_airline_b_inactive fg=103,bg=239 # fg=#8796b0,bg=#444267 + ble-face -s vim_airline_c fg=103,bg=239 # fg=#8796b0,bg=#444267 + ble-face -s vim_airline_c_inactive fg=110,bg=239 # fg=#959dcb,bg=#444267 + ble-face -s vim_airline_c_insert_modified fg=231,bg=239 # fg=#ffffff,bg=#444267 + ble-face -s vim_airline_c_normal_modified fg=231,bg=239 # fg=#ffffff,bg=#444267 + ble-face -s vim_airline_c_replace_modified fg=231,bg=239 # fg=#ffffff,bg=#444267 + ble-face -s vim_airline_c_visual_modified fg=231,bg=239 # fg=#ffffff,bg=#444267 +} diff --git a/.local/share/blesh/contrib/airline/base16_material_vivid.bash b/.local/share/blesh/contrib/airline/base16_material_vivid.bash new file mode 100644 index 0000000..7498f79 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_material_vivid.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_material_vivid.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Material Vivid vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By joshyrobot + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_material_vivid/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=235,bg=242 # fg=#27292c,bg=#676c71 + ble-face -s vim_airline_a_inactive fg=235,bg=235 # fg=#27292c,bg=#27292c + ble-face -s vim_airline_a_insert fg=235,bg=42 # fg=#27292c,bg=#00e676 + ble-face -s vim_airline_a_replace fg=235,bg=61 # fg=#27292c,bg=#673ab7 + ble-face -s vim_airline_a_visual fg=235,bg=208 # fg=#27292c,bg=#ff9800 + ble-face -s vim_airline_b fg=242,bg=237 # fg=#676c71,bg=#323639 + ble-face -s vim_airline_b_inactive fg=242,bg=235 # fg=#676c71,bg=#27292c + ble-face -s vim_airline_c fg=242,bg=235 # fg=#676c71,bg=#27292c + ble-face -s vim_airline_c_inactive fg=104,bg=235 # fg=#80868b,bg=#27292c + ble-face -s vim_airline_c_insert_modified fg=231,bg=235 # fg=#ffffff,bg=#27292c + ble-face -s vim_airline_c_normal_modified fg=231,bg=235 # fg=#ffffff,bg=#27292c + ble-face -s vim_airline_c_replace_modified fg=231,bg=235 # fg=#ffffff,bg=#27292c + ble-face -s vim_airline_c_visual_modified fg=231,bg=235 # fg=#ffffff,bg=#27292c +} diff --git a/.local/share/blesh/contrib/airline/base16_mellow_purple.bash b/.local/share/blesh/contrib/airline/base16_mellow_purple.bash new file mode 100644 index 0000000..a5a757f --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_mellow_purple.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_mellow_purple.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Mellow Purple vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By gidsi + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_mellow_purple/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=234,bg=96 # fg=#1a092d,bg=#873582 + ble-face -s vim_airline_a_inactive fg=234,bg=234 # fg=#1a092d,bg=#1a092d + ble-face -s vim_airline_a_insert fg=234,bg=40 # fg=#1a092d,bg=#05cb0d + ble-face -s vim_airline_a_replace fg=234,bg=103 # fg=#1a092d,bg=#8991bb + ble-face -s vim_airline_a_visual fg=234,bg=127 # fg=#1a092d,bg=#aa00a3 + ble-face -s vim_airline_b fg=96,bg=53 # fg=#873582,bg=#331354 + ble-face -s vim_airline_b_inactive fg=96,bg=234 # fg=#873582,bg=#1a092d + ble-face -s vim_airline_c fg=96,bg=234 # fg=#873582,bg=#1a092d + ble-face -s vim_airline_c_inactive fg=231,bg=234 # fg=#ffeeff,bg=#1a092d + ble-face -s vim_airline_c_insert_modified fg=219,bg=234 # fg=#f8c0ff,bg=#1a092d + ble-face -s vim_airline_c_normal_modified fg=219,bg=234 # fg=#f8c0ff,bg=#1a092d + ble-face -s vim_airline_c_replace_modified fg=219,bg=234 # fg=#f8c0ff,bg=#1a092d + ble-face -s vim_airline_c_visual_modified fg=219,bg=234 # fg=#f8c0ff,bg=#1a092d +} diff --git a/.local/share/blesh/contrib/airline/base16_mexico_light.bash b/.local/share/blesh/contrib/airline/base16_mexico_light.bash new file mode 100644 index 0000000..d93ffe2 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_mexico_light.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_mexico_light.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Mexico Light vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Sheldon Johnson + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_mexico_light/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=254,bg=240 # fg=#e8e8e8,bg=#585858 + ble-face -s vim_airline_a_inactive fg=254,bg=254 # fg=#e8e8e8,bg=#e8e8e8 + ble-face -s vim_airline_a_insert fg=254,bg=65 # fg=#e8e8e8,bg=#538947 + ble-face -s vim_airline_a_replace fg=254,bg=97 # fg=#e8e8e8,bg=#96609e + ble-face -s vim_airline_a_visual fg=254,bg=173 # fg=#e8e8e8,bg=#dc9656 + ble-face -s vim_airline_b fg=240,bg=192 # fg=#585858,bg=#d8d8d8 + ble-face -s vim_airline_b_inactive fg=240,bg=254 # fg=#585858,bg=#e8e8e8 + ble-face -s vim_airline_c fg=240,bg=254 # fg=#585858,bg=#e8e8e8 + ble-face -s vim_airline_c_inactive fg=237,bg=254 # fg=#383838,bg=#e8e8e8 + ble-face -s vim_airline_c_insert_modified fg=234,bg=254 # fg=#181818,bg=#e8e8e8 + ble-face -s vim_airline_c_normal_modified fg=234,bg=254 # fg=#181818,bg=#e8e8e8 + ble-face -s vim_airline_c_replace_modified fg=234,bg=254 # fg=#181818,bg=#e8e8e8 + ble-face -s vim_airline_c_visual_modified fg=234,bg=254 # fg=#181818,bg=#e8e8e8 +} diff --git a/.local/share/blesh/contrib/airline/base16_mocha.bash b/.local/share/blesh/contrib/airline/base16_mocha.bash new file mode 100644 index 0000000..f76f629 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_mocha.bash @@ -0,0 +1,21 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_mocha.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# vim-airline template by chartoin (http://github.com/chartoin) +# Base 16 Mocha Scheme by Chris Kempson (http://chriskempson.com) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_mocha/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=238,bg=143 # fg=#534636,bg=#beb55b + ble-face -s vim_airline_a_inactive fg=251,bg=238 # fg=#d0c8c6,bg=#534636 + ble-face -s vim_airline_a_insert fg=238,bg=109 # fg=#534636,bg=#8ab3b5 + ble-face -s vim_airline_a_replace fg=238,bg=168 # fg=#534636,bg=#cb6077 + ble-face -s vim_airline_a_visual fg=238,bg=248 # fg=#534636,bg=#a89bb9 + ble-face -s vim_airline_b fg=254,bg=239 # fg=#e9e1dd,bg=#645240 + ble-face -s vim_airline_b_inactive fg=251,bg=238 # fg=#d0c8c6,bg=#534636 + ble-face -s vim_airline_c fg=173,bg=238 # fg=#d28b71,bg=#534636 + ble-face -s vim_airline_c_inactive fg=251,bg=238 # fg=#d0c8c6,bg=#534636 +} diff --git a/.local/share/blesh/contrib/airline/base16_monokai.bash b/.local/share/blesh/contrib/airline/base16_monokai.bash new file mode 100644 index 0000000..69ac089 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_monokai.bash @@ -0,0 +1,21 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_monokai.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# vim-airline template by chartoin (http://github.com/chartoin) +# Base 16 Monokai Scheme by Wimer Hazenberg (http://www.monokai.nl) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_monokai/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=237,bg=148 # fg=#383830,bg=#a6e22e + ble-face -s vim_airline_a_inactive fg=255,bg=237 # fg=#f8f8f2,bg=#383830 + ble-face -s vim_airline_a_insert fg=237,bg=81 # fg=#383830,bg=#66d9ef + ble-face -s vim_airline_a_replace fg=237,bg=197 # fg=#383830,bg=#f92672 + ble-face -s vim_airline_a_visual fg=237,bg=141 # fg=#383830,bg=#ae81ff + ble-face -s vim_airline_b fg=255,bg=238 # fg=#f5f4f1,bg=#49483e + ble-face -s vim_airline_b_inactive fg=255,bg=237 # fg=#f8f8f2,bg=#383830 + ble-face -s vim_airline_c fg=208,bg=237 # fg=#fd971f,bg=#383830 + ble-face -s vim_airline_c_inactive fg=255,bg=237 # fg=#f8f8f2,bg=#383830 +} diff --git a/.local/share/blesh/contrib/airline/base16_nord.bash b/.local/share/blesh/contrib/airline/base16_nord.bash new file mode 100644 index 0000000..8320af4 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_nord.bash @@ -0,0 +1,23 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_nord.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# vim-airline theme by gretzky (https://github.com/gretzky) +# nord scheme by arcticstudio +# (https://github.com/arcticicestudio/nord) +# base 16 from (https://github.com/ada-lovecraft/base16-nord-scheme/blob/master/nord.yaml) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_nord/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=238,bg=131 # fg=#3b4252,bg=#bf616a + ble-face -s vim_airline_a_inactive fg=189,bg=238 # fg=#e5e9f0,bg=#3b4252 + ble-face -s vim_airline_a_insert fg=238,bg=222 # fg=#3b4252,bg=#ebcb8b + ble-face -s vim_airline_a_replace fg=238,bg=110 # fg=#3b4252,bg=#88c0d0 + ble-face -s vim_airline_a_visual fg=238,bg=144 # fg=#3b4252,bg=#a3be8c + ble-face -s vim_airline_b fg=255,bg=239 # fg=#eceff4,bg=#434c5e + ble-face -s vim_airline_b_inactive fg=189,bg=238 # fg=#e5e9f0,bg=#3b4252 + ble-face -s vim_airline_c fg=109,bg=238 # fg=#81a1c1,bg=#3b4252 + ble-face -s vim_airline_c_inactive fg=189,bg=238 # fg=#e5e9f0,bg=#3b4252 +} diff --git a/.local/share/blesh/contrib/airline/base16_nova.bash b/.local/share/blesh/contrib/airline/base16_nova.bash new file mode 100644 index 0000000..3c759d4 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_nova.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_nova.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Nova vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By George Essig (https://github.com/gessig), Trevor D. Miller (https://trevordmiller.com) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_nova/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=60,bg=109 # fg=#556873,bg=#899ba6 + ble-face -s vim_airline_a_inactive fg=60,bg=60 # fg=#556873,bg=#556873 + ble-face -s vim_airline_a_insert fg=60,bg=110 # fg=#556873,bg=#7fc1ca + ble-face -s vim_airline_a_replace fg=60,bg=104 # fg=#556873,bg=#9a93e1 + ble-face -s vim_airline_a_visual fg=60,bg=110 # fg=#556873,bg=#7fc1ca + ble-face -s vim_airline_b fg=109,bg=66 # fg=#899ba6,bg=#6a7d89 + ble-face -s vim_airline_b_inactive fg=109,bg=60 # fg=#899ba6,bg=#556873 + ble-face -s vim_airline_c fg=109,bg=60 # fg=#899ba6,bg=#556873 + ble-face -s vim_airline_c_inactive fg=252,bg=60 # fg=#c5d4dd,bg=#556873 + ble-face -s vim_airline_c_insert_modified fg=60,bg=60 # fg=#556873,bg=#556873 + ble-face -s vim_airline_c_normal_modified fg=60,bg=60 # fg=#556873,bg=#556873 + ble-face -s vim_airline_c_replace_modified fg=60,bg=60 # fg=#556873,bg=#556873 + ble-face -s vim_airline_c_visual_modified fg=60,bg=60 # fg=#556873,bg=#556873 +} diff --git a/.local/share/blesh/contrib/airline/base16_ocean.bash b/.local/share/blesh/contrib/airline/base16_ocean.bash new file mode 100644 index 0000000..89a561c --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_ocean.bash @@ -0,0 +1,21 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_ocean.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# vim-airline template by chartoin (http://github.com/chartoin) +# Base 16 Ocean Scheme by Chris Kempson (http://chriskempson.com) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_ocean/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=237,bg=144 # fg=#343d46,bg=#a3be8c + ble-face -s vim_airline_a_inactive fg=152,bg=237 # fg=#c0c5ce,bg=#343d46 + ble-face -s vim_airline_a_insert fg=237,bg=109 # fg=#343d46,bg=#8fa1b3 + ble-face -s vim_airline_a_replace fg=237,bg=131 # fg=#343d46,bg=#bf616a + ble-face -s vim_airline_a_visual fg=237,bg=139 # fg=#343d46,bg=#b48ead + ble-face -s vim_airline_b fg=254,bg=240 # fg=#dfe1e8,bg=#4f5b66 + ble-face -s vim_airline_b_inactive fg=152,bg=237 # fg=#c0c5ce,bg=#343d46 + ble-face -s vim_airline_c fg=173,bg=237 # fg=#d08770,bg=#343d46 + ble-face -s vim_airline_c_inactive fg=152,bg=237 # fg=#c0c5ce,bg=#343d46 +} diff --git a/.local/share/blesh/contrib/airline/base16_oceanicnext.bash b/.local/share/blesh/contrib/airline/base16_oceanicnext.bash new file mode 100644 index 0000000..dc12df9 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_oceanicnext.bash @@ -0,0 +1,21 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_oceanicnext.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# vim-airline template by chartoin (http://github.com/chartoin) +# Base 16 Oceanic Next Scheme by Chris Kempson (http://chriskempson.com) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_oceanicnext/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=237,bg=114 # fg=#343d46,bg=#99c794 + ble-face -s vim_airline_a_inactive fg=152,bg=237 # fg=#c0c5ce,bg=#343d46 + ble-face -s vim_airline_a_insert fg=237,bg=68 # fg=#343d46,bg=#6699cc + ble-face -s vim_airline_a_replace fg=237,bg=203 # fg=#343d46,bg=#ec5f67 + ble-face -s vim_airline_a_visual fg=237,bg=176 # fg=#343d46,bg=#c594c5 + ble-face -s vim_airline_b fg=189,bg=240 # fg=#cdd3de,bg=#4f5b66 + ble-face -s vim_airline_b_inactive fg=152,bg=237 # fg=#c0c5ce,bg=#343d46 + ble-face -s vim_airline_c fg=209,bg=237 # fg=#f99157,bg=#343d46 + ble-face -s vim_airline_c_inactive fg=152,bg=237 # fg=#c0c5ce,bg=#343d46 +} diff --git a/.local/share/blesh/contrib/airline/base16_one_light.bash b/.local/share/blesh/contrib/airline/base16_one_light.bash new file mode 100644 index 0000000..64f5360 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_one_light.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_one_light.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 One Light vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Daniel Pfeifer (http://github.com/purpleKarrot) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_one_light/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=255,bg=60 # fg=#f0f0f1,bg=#696c77 + ble-face -s vim_airline_a_inactive fg=255,bg=255 # fg=#f0f0f1,bg=#f0f0f1 + ble-face -s vim_airline_a_insert fg=255,bg=71 # fg=#f0f0f1,bg=#50a14f + ble-face -s vim_airline_a_replace fg=255,bg=127 # fg=#f0f0f1,bg=#a626a4 + ble-face -s vim_airline_a_visual fg=255,bg=166 # fg=#f0f0f1,bg=#d75f00 + ble-face -s vim_airline_b fg=60,bg=254 # fg=#696c77,bg=#e5e5e6 + ble-face -s vim_airline_b_inactive fg=60,bg=255 # fg=#696c77,bg=#f0f0f1 + ble-face -s vim_airline_c fg=60,bg=255 # fg=#696c77,bg=#f0f0f1 + ble-face -s vim_airline_c_inactive fg=237,bg=255 # fg=#383a42,bg=#f0f0f1 + ble-face -s vim_airline_c_insert_modified fg=232,bg=255 # fg=#090a0b,bg=#f0f0f1 + ble-face -s vim_airline_c_normal_modified fg=232,bg=255 # fg=#090a0b,bg=#f0f0f1 + ble-face -s vim_airline_c_replace_modified fg=232,bg=255 # fg=#090a0b,bg=#f0f0f1 + ble-face -s vim_airline_c_visual_modified fg=232,bg=255 # fg=#090a0b,bg=#f0f0f1 +} diff --git a/.local/share/blesh/contrib/airline/base16_onedark.bash b/.local/share/blesh/contrib/airline/base16_onedark.bash new file mode 100644 index 0000000..043885c --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_onedark.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_onedark.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 OneDark vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Lalit Magant (http://github.com/tilal6991) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_onedark/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=237,bg=60 # fg=#353b45,bg=#565c64 + ble-face -s vim_airline_a_inactive fg=237,bg=237 # fg=#353b45,bg=#353b45 + ble-face -s vim_airline_a_insert fg=237,bg=114 # fg=#353b45,bg=#98c379 + ble-face -s vim_airline_a_replace fg=237,bg=176 # fg=#353b45,bg=#c678dd + ble-face -s vim_airline_a_visual fg=237,bg=173 # fg=#353b45,bg=#d19a66 + ble-face -s vim_airline_b fg=60,bg=238 # fg=#565c64,bg=#3e4451 + ble-face -s vim_airline_b_inactive fg=60,bg=237 # fg=#565c64,bg=#353b45 + ble-face -s vim_airline_c fg=60,bg=237 # fg=#565c64,bg=#353b45 + ble-face -s vim_airline_c_inactive fg=249,bg=237 # fg=#abb2bf,bg=#353b45 + ble-face -s vim_airline_c_insert_modified fg=252,bg=237 # fg=#c8ccd4,bg=#353b45 + ble-face -s vim_airline_c_normal_modified fg=252,bg=237 # fg=#c8ccd4,bg=#353b45 + ble-face -s vim_airline_c_replace_modified fg=252,bg=237 # fg=#c8ccd4,bg=#353b45 + ble-face -s vim_airline_c_visual_modified fg=252,bg=237 # fg=#c8ccd4,bg=#353b45 +} diff --git a/.local/share/blesh/contrib/airline/base16_outrun_dark.bash b/.local/share/blesh/contrib/airline/base16_outrun_dark.bash new file mode 100644 index 0000000..98d828d --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_outrun_dark.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_outrun_dark.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Outrun Dark vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Hugo Delahousse (http://github.com/hugodelahousse/) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_outrun_dark/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=17,bg=146 # fg=#20204a,bg=#b0b0da + ble-face -s vim_airline_a_inactive fg=17,bg=17 # fg=#20204a,bg=#20204a + ble-face -s vim_airline_a_insert fg=17,bg=84 # fg=#20204a,bg=#59f176 + ble-face -s vim_airline_a_replace fg=17,bg=198 # fg=#20204a,bg=#f10596 + ble-face -s vim_airline_a_visual fg=17,bg=208 # fg=#20204a,bg=#fc8d28 + ble-face -s vim_airline_b fg=146,bg=237 # fg=#b0b0da,bg=#30305a + ble-face -s vim_airline_b_inactive fg=146,bg=17 # fg=#b0b0da,bg=#20204a + ble-face -s vim_airline_c fg=146,bg=17 # fg=#b0b0da,bg=#20204a + ble-face -s vim_airline_c_inactive fg=189,bg=17 # fg=#d0d0fa,bg=#20204a + ble-face -s vim_airline_c_insert_modified fg=231,bg=17 # fg=#f5f5ff,bg=#20204a + ble-face -s vim_airline_c_normal_modified fg=231,bg=17 # fg=#f5f5ff,bg=#20204a + ble-face -s vim_airline_c_replace_modified fg=231,bg=17 # fg=#f5f5ff,bg=#20204a + ble-face -s vim_airline_c_visual_modified fg=231,bg=17 # fg=#f5f5ff,bg=#20204a +} diff --git a/.local/share/blesh/contrib/airline/base16_papercolor_dark.bash b/.local/share/blesh/contrib/airline/base16_papercolor_dark.bash new file mode 100644 index 0000000..94056c3 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_papercolor_dark.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_papercolor_dark.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 PaperColor Dark vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Jon Leopard (http://github.com/jonleopard) based on PaperColor Theme (https://github.com/NLKNguyen/papercolor-theme) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_papercolor_dark/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=125,bg=74 # fg=#af005f,bg=#5fafd7 + ble-face -s vim_airline_a_inactive fg=125,bg=125 # fg=#af005f,bg=#af005f + ble-face -s vim_airline_a_insert fg=125,bg=140 # fg=#af005f,bg=#af87d7 + ble-face -s vim_airline_a_replace fg=125,bg=37 # fg=#af005f,bg=#00afaf + ble-face -s vim_airline_a_visual fg=125,bg=71 # fg=#af005f,bg=#5faf5f + ble-face -s vim_airline_b fg=74,bg=70 # fg=#5fafd7,bg=#5faf00 + ble-face -s vim_airline_b_inactive fg=74,bg=125 # fg=#5fafd7,bg=#af005f + ble-face -s vim_airline_c fg=74,bg=125 # fg=#5fafd7,bg=#af005f + ble-face -s vim_airline_c_inactive fg=244,bg=125 # fg=#808080,bg=#af005f + ble-face -s vim_airline_c_insert_modified fg=252,bg=125 # fg=#d0d0d0,bg=#af005f + ble-face -s vim_airline_c_normal_modified fg=252,bg=125 # fg=#d0d0d0,bg=#af005f + ble-face -s vim_airline_c_replace_modified fg=252,bg=125 # fg=#d0d0d0,bg=#af005f + ble-face -s vim_airline_c_visual_modified fg=252,bg=125 # fg=#d0d0d0,bg=#af005f +} diff --git a/.local/share/blesh/contrib/airline/base16_papercolor_light.bash b/.local/share/blesh/contrib/airline/base16_papercolor_light.bash new file mode 100644 index 0000000..802cc3b --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_papercolor_light.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_papercolor_light.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 PaperColor Light vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Jon Leopard (http://github.com/jonleopard) based on PaperColor Theme (https://github.com/NLKNguyen/papercolor-theme) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_papercolor_light/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=124,bg=31 # fg=#af0000,bg=#0087af + ble-face -s vim_airline_a_inactive fg=124,bg=124 # fg=#af0000,bg=#af0000 + ble-face -s vim_airline_a_insert fg=124,bg=91 # fg=#af0000,bg=#8700af + ble-face -s vim_airline_a_replace fg=124,bg=25 # fg=#af0000,bg=#005faf + ble-face -s vim_airline_a_visual fg=124,bg=160 # fg=#af0000,bg=#d70000 + ble-face -s vim_airline_b fg=31,bg=28 # fg=#0087af,bg=#008700 + ble-face -s vim_airline_b_inactive fg=31,bg=124 # fg=#0087af,bg=#af0000 + ble-face -s vim_airline_c fg=31,bg=124 # fg=#0087af,bg=#af0000 + ble-face -s vim_airline_c_inactive fg=105,bg=124 # fg=#878787,bg=#af0000 + ble-face -s vim_airline_c_insert_modified fg=238,bg=124 # fg=#444444,bg=#af0000 + ble-face -s vim_airline_c_normal_modified fg=238,bg=124 # fg=#444444,bg=#af0000 + ble-face -s vim_airline_c_replace_modified fg=238,bg=124 # fg=#444444,bg=#af0000 + ble-face -s vim_airline_c_visual_modified fg=238,bg=124 # fg=#444444,bg=#af0000 +} diff --git a/.local/share/blesh/contrib/airline/base16_paraiso.bash b/.local/share/blesh/contrib/airline/base16_paraiso.bash new file mode 100644 index 0000000..41e6dc9 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_paraiso.bash @@ -0,0 +1,21 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_paraiso.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# vim-airline template by chartoin (http://github.com/chartoin) +# Base 16 Paraiso Scheme by Jan T. Sott + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_paraiso/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=237,bg=72 # fg=#41323f,bg=#48b685 + ble-face -s vim_airline_a_inactive fg=247,bg=237 # fg=#a39e9b,bg=#41323f + ble-face -s vim_airline_a_insert fg=237,bg=39 # fg=#41323f,bg=#06b6ef + ble-face -s vim_airline_a_replace fg=237,bg=203 # fg=#41323f,bg=#ef6155 + ble-face -s vim_airline_a_visual fg=237,bg=97 # fg=#41323f,bg=#815ba4 + ble-face -s vim_airline_b fg=249,bg=239 # fg=#b9b6b0,bg=#4f424c + ble-face -s vim_airline_b_inactive fg=247,bg=237 # fg=#a39e9b,bg=#41323f + ble-face -s vim_airline_c fg=214,bg=237 # fg=#f99b15,bg=#41323f + ble-face -s vim_airline_c_inactive fg=247,bg=237 # fg=#a39e9b,bg=#41323f +} diff --git a/.local/share/blesh/contrib/airline/base16_phd.bash b/.local/share/blesh/contrib/airline/base16_phd.bash new file mode 100644 index 0000000..d3c0733 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_phd.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_phd.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 PhD vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Hennig Hasemann (http://leetless.de/vim.html) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_phd/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=23,bg=103 # fg=#2a3448,bg=#9a99a3 + ble-face -s vim_airline_a_inactive fg=23,bg=23 # fg=#2a3448,bg=#2a3448 + ble-face -s vim_airline_a_insert fg=23,bg=107 # fg=#2a3448,bg=#99bf52 + ble-face -s vim_airline_a_replace fg=23,bg=104 # fg=#2a3448,bg=#9989cc + ble-face -s vim_airline_a_visual fg=23,bg=214 # fg=#2a3448,bg=#f0a000 + ble-face -s vim_airline_b fg=103,bg=240 # fg=#9a99a3,bg=#4d5666 + ble-face -s vim_airline_b_inactive fg=103,bg=23 # fg=#9a99a3,bg=#2a3448 + ble-face -s vim_airline_c fg=103,bg=23 # fg=#9a99a3,bg=#2a3448 + ble-face -s vim_airline_c_inactive fg=250,bg=23 # fg=#b8bbc2,bg=#2a3448 + ble-face -s vim_airline_c_insert_modified fg=231,bg=23 # fg=#ffffff,bg=#2a3448 + ble-face -s vim_airline_c_normal_modified fg=231,bg=23 # fg=#ffffff,bg=#2a3448 + ble-face -s vim_airline_c_replace_modified fg=231,bg=23 # fg=#ffffff,bg=#2a3448 + ble-face -s vim_airline_c_visual_modified fg=231,bg=23 # fg=#ffffff,bg=#2a3448 +} diff --git a/.local/share/blesh/contrib/airline/base16_pico.bash b/.local/share/blesh/contrib/airline/base16_pico.bash new file mode 100644 index 0000000..a61910e --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_pico.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_pico.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Pico vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By PICO-8 (http://www.lexaloffle.com/pico-8.php) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_pico/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=17,bg=131 # fg=#1d2b53,bg=#ab5236 + ble-face -s vim_airline_a_inactive fg=17,bg=17 # fg=#1d2b53,bg=#1d2b53 + ble-face -s vim_airline_a_insert fg=17,bg=41 # fg=#1d2b53,bg=#00e756 + ble-face -s vim_airline_a_replace fg=17,bg=211 # fg=#1d2b53,bg=#ff77a8 + ble-face -s vim_airline_a_visual fg=17,bg=214 # fg=#1d2b53,bg=#ffa300 + ble-face -s vim_airline_b fg=131,bg=89 # fg=#ab5236,bg=#7e2553 + ble-face -s vim_airline_b_inactive fg=131,bg=17 # fg=#ab5236,bg=#1d2b53 + ble-face -s vim_airline_c fg=131,bg=17 # fg=#ab5236,bg=#1d2b53 + ble-face -s vim_airline_c_inactive fg=240,bg=17 # fg=#5f574f,bg=#1d2b53 + ble-face -s vim_airline_c_insert_modified fg=230,bg=17 # fg=#fff1e8,bg=#1d2b53 + ble-face -s vim_airline_c_normal_modified fg=230,bg=17 # fg=#fff1e8,bg=#1d2b53 + ble-face -s vim_airline_c_replace_modified fg=230,bg=17 # fg=#fff1e8,bg=#1d2b53 + ble-face -s vim_airline_c_visual_modified fg=230,bg=17 # fg=#fff1e8,bg=#1d2b53 +} diff --git a/.local/share/blesh/contrib/airline/base16_pop.bash b/.local/share/blesh/contrib/airline/base16_pop.bash new file mode 100644 index 0000000..b5b9247 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_pop.bash @@ -0,0 +1,21 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_pop.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# vim-airline template by chartoin (http://github.com/chartoin) +# Base 16 Pop Scheme by Chris Kempson (http://chriskempson.com) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_pop/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=234,bg=71 # fg=#202020,bg=#37b349 + ble-face -s vim_airline_a_inactive fg=252,bg=234 # fg=#d0d0d0,bg=#202020 + ble-face -s vim_airline_a_insert fg=234,bg=24 # fg=#202020,bg=#0e5a94 + ble-face -s vim_airline_a_replace fg=234,bg=198 # fg=#202020,bg=#eb008a + ble-face -s vim_airline_a_visual fg=234,bg=126 # fg=#202020,bg=#b31e8d + ble-face -s vim_airline_b fg=254,bg=236 # fg=#e0e0e0,bg=#303030 + ble-face -s vim_airline_b_inactive fg=252,bg=234 # fg=#d0d0d0,bg=#202020 + ble-face -s vim_airline_c fg=209,bg=234 # fg=#f29333,bg=#202020 + ble-face -s vim_airline_c_inactive fg=252,bg=234 # fg=#d0d0d0,bg=#202020 +} diff --git a/.local/share/blesh/contrib/airline/base16_porple.bash b/.local/share/blesh/contrib/airline/base16_porple.bash new file mode 100644 index 0000000..cdf0927 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_porple.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_porple.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Porple vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Niek den Breeje (https://github.com/AuditeMarlow) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_porple/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=237,bg=250 # fg=#333344,bg=#b8b8b8 + ble-face -s vim_airline_a_inactive fg=237,bg=237 # fg=#333344,bg=#333344 + ble-face -s vim_airline_a_insert fg=237,bg=113 # fg=#333344,bg=#95c76f + ble-face -s vim_airline_a_replace fg=237,bg=132 # fg=#333344,bg=#b74989 + ble-face -s vim_airline_a_visual fg=237,bg=173 # fg=#333344,bg=#d28e5d + ble-face -s vim_airline_b fg=250,bg=239 # fg=#b8b8b8,bg=#474160 + ble-face -s vim_airline_b_inactive fg=250,bg=237 # fg=#b8b8b8,bg=#333344 + ble-face -s vim_airline_c fg=250,bg=237 # fg=#b8b8b8,bg=#333344 + ble-face -s vim_airline_c_inactive fg=192,bg=237 # fg=#d8d8d8,bg=#333344 + ble-face -s vim_airline_c_insert_modified fg=231,bg=237 # fg=#f8f8f8,bg=#333344 + ble-face -s vim_airline_c_normal_modified fg=231,bg=237 # fg=#f8f8f8,bg=#333344 + ble-face -s vim_airline_c_replace_modified fg=231,bg=237 # fg=#f8f8f8,bg=#333344 + ble-face -s vim_airline_c_visual_modified fg=231,bg=237 # fg=#f8f8f8,bg=#333344 +} diff --git a/.local/share/blesh/contrib/airline/base16_railscasts.bash b/.local/share/blesh/contrib/airline/base16_railscasts.bash new file mode 100644 index 0000000..aed3ce2 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_railscasts.bash @@ -0,0 +1,21 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_railscasts.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# vim-airline template by chartoin (http://github.com/chartoin) +# Base 16 Railscasts Scheme by Ryan Bates (http://railscasts.com) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_railscasts/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=17,bg=143 # fg=#272935,bg=#a5c261 + ble-face -s vim_airline_a_inactive fg=254,bg=17 # fg=#e6e1dc,bg=#272935 + ble-face -s vim_airline_a_insert fg=17,bg=73 # fg=#272935,bg=#6d9cbe + ble-face -s vim_airline_a_replace fg=17,bg=167 # fg=#272935,bg=#da4939 + ble-face -s vim_airline_a_visual fg=17,bg=147 # fg=#272935,bg=#b6b3eb + ble-face -s vim_airline_b fg=255,bg=238 # fg=#f4f1ed,bg=#3a4055 + ble-face -s vim_airline_b_inactive fg=254,bg=17 # fg=#e6e1dc,bg=#272935 + ble-face -s vim_airline_c fg=173,bg=17 # fg=#cc7833,bg=#272935 + ble-face -s vim_airline_c_inactive fg=254,bg=17 # fg=#e6e1dc,bg=#272935 +} diff --git a/.local/share/blesh/contrib/airline/base16_rebecca.bash b/.local/share/blesh/contrib/airline/base16_rebecca.bash new file mode 100644 index 0000000..794419f --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_rebecca.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_rebecca.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Rebecca vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Victor Borja (http://github.com/vic) based on Rebecca Theme (http://github.com/vic/rebecca-theme) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_rebecca/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=60,bg=146 # fg=#663399,bg=#a0a0c5 + ble-face -s vim_airline_a_inactive fg=60,bg=60 # fg=#663399,bg=#663399 + ble-face -s vim_airline_a_insert fg=60,bg=86 # fg=#663399,bg=#6dfedf + ble-face -s vim_airline_a_replace fg=60,bg=111 # fg=#663399,bg=#7aa5ff + ble-face -s vim_airline_a_visual fg=60,bg=223 # fg=#663399,bg=#efe4a1 + ble-face -s vim_airline_b fg=146,bg=238 # fg=#a0a0c5,bg=#383a62 + ble-face -s vim_airline_b_inactive fg=146,bg=60 # fg=#a0a0c5,bg=#663399 + ble-face -s vim_airline_c fg=146,bg=60 # fg=#a0a0c5,bg=#663399 + ble-face -s vim_airline_c_inactive fg=255,bg=60 # fg=#f1eff8,bg=#663399 + ble-face -s vim_airline_c_insert_modified fg=240,bg=60 # fg=#53495d,bg=#663399 + ble-face -s vim_airline_c_normal_modified fg=240,bg=60 # fg=#53495d,bg=#663399 + ble-face -s vim_airline_c_replace_modified fg=240,bg=60 # fg=#53495d,bg=#663399 + ble-face -s vim_airline_c_visual_modified fg=240,bg=60 # fg=#53495d,bg=#663399 +} diff --git a/.local/share/blesh/contrib/airline/base16_sandcastle.bash b/.local/share/blesh/contrib/airline/base16_sandcastle.bash new file mode 100644 index 0000000..24456af --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_sandcastle.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_sandcastle.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Sandcastle vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By George Essig (https://github.com/gessig) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_sandcastle/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=23,bg=244 # fg=#2c323b,bg=#928374 + ble-face -s vim_airline_a_inactive fg=23,bg=23 # fg=#2c323b,bg=#2c323b + ble-face -s vim_airline_a_insert fg=23,bg=66 # fg=#2c323b,bg=#528b8b + ble-face -s vim_airline_a_replace fg=23,bg=167 # fg=#2c323b,bg=#d75f5f + ble-face -s vim_airline_a_visual fg=23,bg=137 # fg=#2c323b,bg=#a07e3b + ble-face -s vim_airline_b fg=244,bg=238 # fg=#928374,bg=#3e4451 + ble-face -s vim_airline_b_inactive fg=244,bg=23 # fg=#928374,bg=#2c323b + ble-face -s vim_airline_c fg=244,bg=23 # fg=#928374,bg=#2c323b + ble-face -s vim_airline_c_inactive fg=138,bg=23 # fg=#a89984,bg=#2c323b + ble-face -s vim_airline_c_insert_modified fg=229,bg=23 # fg=#fdf4c1,bg=#2c323b + ble-face -s vim_airline_c_normal_modified fg=229,bg=23 # fg=#fdf4c1,bg=#2c323b + ble-face -s vim_airline_c_replace_modified fg=229,bg=23 # fg=#fdf4c1,bg=#2c323b + ble-face -s vim_airline_c_visual_modified fg=229,bg=23 # fg=#fdf4c1,bg=#2c323b +} diff --git a/.local/share/blesh/contrib/airline/base16_seti.bash b/.local/share/blesh/contrib/airline/base16_seti.bash new file mode 100644 index 0000000..3f728a8 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_seti.bash @@ -0,0 +1,21 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_seti.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# vim-airline template by chartoin (http://github.com/chartoin) +# Base16 Seti UI by + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_seti/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=235,bg=149 # fg=#282a2b,bg=#9fca56 + ble-face -s vim_airline_a_inactive fg=190,bg=235 # fg=#d6d6d6,bg=#282a2b + ble-face -s vim_airline_a_insert fg=235,bg=74 # fg=#282a2b,bg=#55b5db + ble-face -s vim_airline_a_replace fg=235,bg=167 # fg=#282a2b,bg=#cd3f45 + ble-face -s vim_airline_a_visual fg=235,bg=140 # fg=#282a2b,bg=#a074c4 + ble-face -s vim_airline_b fg=255,bg=66 # fg=#eeeeee,bg=#3b758c + ble-face -s vim_airline_b_inactive fg=190,bg=235 # fg=#d6d6d6,bg=#282a2b + ble-face -s vim_airline_c fg=173,bg=235 # fg=#db7b55,bg=#282a2b + ble-face -s vim_airline_c_inactive fg=190,bg=235 # fg=#d6d6d6,bg=#282a2b +} diff --git a/.local/share/blesh/contrib/airline/base16_shapeshifter.bash b/.local/share/blesh/contrib/airline/base16_shapeshifter.bash new file mode 100644 index 0000000..6aeb9c1 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_shapeshifter.bash @@ -0,0 +1,21 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_shapeshifter.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# vim-airline template by chartoin (http://github.com/chartoin) +# Base 16 shapeshifter Scheme by Tyler Benziger (http://tybenz.com) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_shapeshifter/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=232,bg=41 # fg=#040404,bg=#0ed839 + ble-face -s vim_airline_a_inactive fg=248,bg=232 # fg=#ababab,bg=#040404 + ble-face -s vim_airline_a_insert fg=232,bg=62 # fg=#040404,bg=#3b48e3 + ble-face -s vim_airline_a_replace fg=232,bg=160 # fg=#040404,bg=#e92f2f + ble-face -s vim_airline_a_visual fg=232,bg=212 # fg=#040404,bg=#f996e2 + ble-face -s vim_airline_b fg=254,bg=234 # fg=#e0e0e0,bg=#102015 + ble-face -s vim_airline_b_inactive fg=248,bg=232 # fg=#ababab,bg=#040404 + ble-face -s vim_airline_c fg=173,bg=232 # fg=#e09448,bg=#040404 + ble-face -s vim_airline_c_inactive fg=248,bg=232 # fg=#ababab,bg=#040404 +} diff --git a/.local/share/blesh/contrib/airline/base16_shell.bash b/.local/share/blesh/contrib/airline/base16_shell.bash new file mode 100644 index 0000000..9e9cba2 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_shell.bash @@ -0,0 +1,28 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_shell.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# This theme has been improved and renamed to base16_vim. The following is +# provided for backward compatibility. + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_shell/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=234,bg=143 # fg=#181818,bg=#a1b56c + ble-face -s vim_airline_a_inactive fg=240,bg=235 # fg=#585858,bg=#282828 + ble-face -s vim_airline_a_insert fg=235,bg=109 # fg=#282828,bg=#7cafc2 + ble-face -s vim_airline_a_replace fg=235,bg=131 # fg=#282828,bg=#ab4642 + ble-face -s vim_airline_a_visual fg=235,bg=139 # fg=#282828,bg=#ba8baf + ble-face -s vim_airline_b fg=250,bg=237 # fg=#b8b8b8,bg=#383838 + ble-face -s vim_airline_b_inactive fg=240,bg=235 # fg=#585858,bg=#282828 + ble-face -s vim_airline_c fg=143,bg=235 # fg=#a1b56c,bg=#282828 + ble-face -s vim_airline_c_inactive fg=240,bg=235 # fg=#585858,bg=#282828 + ble-face -s vim_airline_c_inactive_modified fg=173,bg=0 # fg=#dc9656,bg=0 + ble-face -s vim_airline_c_insert fg=109,bg=235 # fg=#7cafc2,bg=#282828 + ble-face -s vim_airline_c_insert_modified fg=173,bg=235 # fg=#dc9656,bg=#282828 + ble-face -s vim_airline_c_normal_modified fg=173,bg=235 # fg=#dc9656,bg=#282828 + ble-face -s vim_airline_c_replace fg=131,bg=235 # fg=#ab4642,bg=#282828 + ble-face -s vim_airline_c_replace_modified fg=173,bg=235 # fg=#dc9656,bg=#282828 + ble-face -s vim_airline_c_visual fg=139,bg=235 # fg=#ba8baf,bg=#282828 +} diff --git a/.local/share/blesh/contrib/airline/base16_snazzy.bash b/.local/share/blesh/contrib/airline/base16_snazzy.bash new file mode 100644 index 0000000..b508cbf --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_snazzy.bash @@ -0,0 +1,36 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_snazzy.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# base16-snazzy +# theme format modified from wombat +# colors from sindresorhus/hyper-snazzy & h404bi/base16-snazzy-scheme/ +# Made by Ayush Shenoy (masala-man) +# +# BASE16-SNAZZY XTERM + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_snazzy/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=17,bg=81 # fg=#282a36,bg=#57c7ff + ble-face -s vim_airline_a_inactive fg=244,bg=17 # fg=244,bg=#282a36 + ble-face -s vim_airline_a_insert fg=17,bg=84 # fg=#282a36,bg=#5af78e + ble-face -s vim_airline_a_replace fg=17,bg=203 # fg=#282a36,bg=#ff5c57 + ble-face -s vim_airline_a_visual fg=17,bg=229 # fg=#282a36,bg=#f3f99d + ble-face -s vim_airline_b fg=81,bg=17 # fg=#57c7ff,bg=#282a36 + ble-face -s vim_airline_b_inactive fg=244,bg=17 # fg=244,bg=#282a36 + ble-face -s vim_airline_b_insert fg=84,bg=17 # fg=#5af78e,bg=#282a36 + ble-face -s vim_airline_b_replace fg=203,bg=17 # fg=#ff5c57,bg=#282a36 + ble-face -s vim_airline_b_visual fg=229,bg=17 # fg=#f3f99d,bg=#282a36 + ble-face -s vim_airline_c fg=81,bg=17 # fg=#57c7ff,bg=#282a36 + ble-face -s vim_airline_c_inactive fg=244,bg=17 # fg=244,bg=#282a36 + ble-face -s vim_airline_c_inactive_modified fg=81,bg=0 # fg=#57c7ff,bg=0 + ble-face -s vim_airline_c_insert fg=84,bg=17 # fg=#5af78e,bg=#282a36 + ble-face -s vim_airline_c_replace fg=203,bg=17 # fg=#ff5c57,bg=#282a36 + ble-face -s vim_airline_c_visual fg=229,bg=17 # fg=#f3f99d,bg=#282a36 + ble-face -s vim_airline_error fg=17,bg=203 # fg=#282a36,bg=#ff5c57 + ble-face -s vim_airline_error_inactive fg=16,bg=88 # fg=#000000,bg=#990000 + ble-face -s vim_airline_warning fg=17,bg=229 # fg=#282a36,bg=#f3f99d + ble-face -s vim_airline_warning_inactive fg=16,bg=166 # fg=#000000,bg=#df5f00 +} diff --git a/.local/share/blesh/contrib/airline/base16_solarflare.bash b/.local/share/blesh/contrib/airline/base16_solarflare.bash new file mode 100644 index 0000000..7d78c5c --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_solarflare.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_solarflare.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Solar Flare vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Chuck Harmston (https://chuck.harmston.ch) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_solarflare/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=17,bg=103 # fg=#222e38,bg=#85939e + ble-face -s vim_airline_a_inactive fg=17,bg=17 # fg=#222e38,bg=#222e38 + ble-face -s vim_airline_a_insert fg=17,bg=113 # fg=#222e38,bg=#7cc844 + ble-face -s vim_airline_a_replace fg=17,bg=134 # fg=#222e38,bg=#a363d5 + ble-face -s vim_airline_a_visual fg=17,bg=166 # fg=#222e38,bg=#e66b2b + ble-face -s vim_airline_b fg=103,bg=60 # fg=#85939e,bg=#586875 + ble-face -s vim_airline_b_inactive fg=103,bg=17 # fg=#85939e,bg=#222e38 + ble-face -s vim_airline_c fg=103,bg=17 # fg=#85939e,bg=#222e38 + ble-face -s vim_airline_c_inactive fg=148,bg=17 # fg=#a6afb8,bg=#222e38 + ble-face -s vim_airline_c_insert_modified fg=231,bg=17 # fg=#f5f7fa,bg=#222e38 + ble-face -s vim_airline_c_normal_modified fg=231,bg=17 # fg=#f5f7fa,bg=#222e38 + ble-face -s vim_airline_c_replace_modified fg=231,bg=17 # fg=#f5f7fa,bg=#222e38 + ble-face -s vim_airline_c_visual_modified fg=231,bg=17 # fg=#f5f7fa,bg=#222e38 +} diff --git a/.local/share/blesh/contrib/airline/base16_solarized.bash b/.local/share/blesh/contrib/airline/base16_solarized.bash new file mode 100644 index 0000000..ec45a61 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_solarized.bash @@ -0,0 +1,21 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_solarized.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# vim-airline template by chartoin (http://github.com/chartoin) +# Base 16 Solarized Scheme by Ethan Schoonover (http://ethanschoonover.com/solarized) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_solarized/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=23,bg=100 # fg=#073642,bg=#859900 + ble-face -s vim_airline_a_inactive fg=109,bg=23 # fg=#93a1a1,bg=#073642 + ble-face -s vim_airline_a_insert fg=23,bg=32 # fg=#073642,bg=#268bd2 + ble-face -s vim_airline_a_replace fg=23,bg=166 # fg=#073642,bg=#dc322f + ble-face -s vim_airline_a_visual fg=23,bg=62 # fg=#073642,bg=#6c71c4 + ble-face -s vim_airline_b fg=224,bg=60 # fg=#eee8d5,bg=#586e75 + ble-face -s vim_airline_b_inactive fg=109,bg=23 # fg=#93a1a1,bg=#073642 + ble-face -s vim_airline_c fg=166,bg=23 # fg=#cb4b16,bg=#073642 + ble-face -s vim_airline_c_inactive fg=109,bg=23 # fg=#93a1a1,bg=#073642 +} diff --git a/.local/share/blesh/contrib/airline/base16_solarized_dark.bash b/.local/share/blesh/contrib/airline/base16_solarized_dark.bash new file mode 100644 index 0000000..0648ec2 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_solarized_dark.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_solarized_dark.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Solarized Dark vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Ethan Schoonover (modified by aramisgithub) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_solarized_dark/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=23,bg=246 # fg=#073642,bg=#839496 + ble-face -s vim_airline_a_inactive fg=23,bg=23 # fg=#073642,bg=#073642 + ble-face -s vim_airline_a_insert fg=23,bg=100 # fg=#073642,bg=#859900 + ble-face -s vim_airline_a_replace fg=23,bg=62 # fg=#073642,bg=#6c71c4 + ble-face -s vim_airline_a_visual fg=23,bg=166 # fg=#073642,bg=#cb4b16 + ble-face -s vim_airline_b fg=246,bg=60 # fg=#839496,bg=#586e75 + ble-face -s vim_airline_b_inactive fg=246,bg=23 # fg=#839496,bg=#073642 + ble-face -s vim_airline_c fg=246,bg=23 # fg=#839496,bg=#073642 + ble-face -s vim_airline_c_inactive fg=109,bg=23 # fg=#93a1a1,bg=#073642 + ble-face -s vim_airline_c_insert_modified fg=230,bg=23 # fg=#fdf6e3,bg=#073642 + ble-face -s vim_airline_c_normal_modified fg=230,bg=23 # fg=#fdf6e3,bg=#073642 + ble-face -s vim_airline_c_replace_modified fg=230,bg=23 # fg=#fdf6e3,bg=#073642 + ble-face -s vim_airline_c_visual_modified fg=230,bg=23 # fg=#fdf6e3,bg=#073642 +} diff --git a/.local/share/blesh/contrib/airline/base16_solarized_light.bash b/.local/share/blesh/contrib/airline/base16_solarized_light.bash new file mode 100644 index 0000000..7a0a677 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_solarized_light.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_solarized_light.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Solarized Light vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Ethan Schoonover (modified by aramisgithub) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_solarized_light/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=224,bg=66 # fg=#eee8d5,bg=#657b83 + ble-face -s vim_airline_a_inactive fg=224,bg=224 # fg=#eee8d5,bg=#eee8d5 + ble-face -s vim_airline_a_insert fg=224,bg=100 # fg=#eee8d5,bg=#859900 + ble-face -s vim_airline_a_replace fg=224,bg=62 # fg=#eee8d5,bg=#6c71c4 + ble-face -s vim_airline_a_visual fg=224,bg=166 # fg=#eee8d5,bg=#cb4b16 + ble-face -s vim_airline_b fg=66,bg=109 # fg=#657b83,bg=#93a1a1 + ble-face -s vim_airline_b_inactive fg=66,bg=224 # fg=#657b83,bg=#eee8d5 + ble-face -s vim_airline_c fg=66,bg=224 # fg=#657b83,bg=#eee8d5 + ble-face -s vim_airline_c_inactive fg=60,bg=224 # fg=#586e75,bg=#eee8d5 + ble-face -s vim_airline_c_insert_modified fg=17,bg=224 # fg=#002b36,bg=#eee8d5 + ble-face -s vim_airline_c_normal_modified fg=17,bg=224 # fg=#002b36,bg=#eee8d5 + ble-face -s vim_airline_c_replace_modified fg=17,bg=224 # fg=#002b36,bg=#eee8d5 + ble-face -s vim_airline_c_visual_modified fg=17,bg=224 # fg=#002b36,bg=#eee8d5 +} diff --git a/.local/share/blesh/contrib/airline/base16_spacemacs.bash b/.local/share/blesh/contrib/airline/base16_spacemacs.bash new file mode 100644 index 0000000..041850f --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_spacemacs.bash @@ -0,0 +1,29 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_spacemacs.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# vim-airline base16-spacemacs theme by Peter Meehan (http://github.com/22a) +# Base16 Spacemacs by Chris Kempson (http://chriskempson.com) +# Spacemacs scheme by Nasser Alshammari (https://github.com/nashamri/spacemacs-theme) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_spacemacs/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=231,bg=68 # fg=#f8f8f8,bg=#4f97d7 + ble-face -s vim_airline_a_inactive fg=250,bg=239 # fg=#b8b8b8,bg=#444155 + ble-face -s vim_airline_a_insert fg=231,bg=70 # fg=#f8f8f8,bg=#67b11d + ble-face -s vim_airline_a_replace fg=231,bg=196 # fg=#f8f8f8,bg=#f2241f + ble-face -s vim_airline_a_visual fg=231,bg=214 # fg=#f8f8f8,bg=#ffa500 + ble-face -s vim_airline_b fg=254,bg=239 # fg=#e8e8e8,bg=#444155 + ble-face -s vim_airline_b_inactive fg=250,bg=239 # fg=#b8b8b8,bg=#444155 + ble-face -s vim_airline_c fg=254,bg=234 # fg=#e8e8e8,bg=#1f2022 + ble-face -s vim_airline_c_inactive fg=250,bg=239 # fg=#b8b8b8,bg=#444155 + ble-face -s vim_airline_c_insert fg=70,bg=234 # fg=#67b11d,bg=#1f2022 + ble-face -s vim_airline_c_replace fg=254,bg=234 # fg=#e8e8e8,bg=#1f2022 + ble-face -s vim_airline_c_visual fg=214,bg=234 # fg=#ffa500,bg=#1f2022 + ble-face -s vim_airline_error fg=231,bg=196 # fg=#f8f8f8,bg=#f2241f + ble-face -s vim_airline_error_inactive fg=16,bg=88 # fg=#000000,bg=#990000 + ble-face -s vim_airline_warning fg=231,bg=214 # fg=#f8f8f8,bg=#ffa500 + ble-face -s vim_airline_warning_inactive fg=16,bg=166 # fg=#000000,bg=#df5f00 +} diff --git a/.local/share/blesh/contrib/airline/base16_summerfruit.bash b/.local/share/blesh/contrib/airline/base16_summerfruit.bash new file mode 100644 index 0000000..8a1a723 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_summerfruit.bash @@ -0,0 +1,21 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_summerfruit.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# vim-airline template by chartoin (http://github.com/chartoin) +# Base 16 Summerfruit Scheme by Christopher Corley (http://cscorley.github.io/) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_summerfruit/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=234,bg=40 # fg=#202020,bg=#00c918 + ble-face -s vim_airline_a_inactive fg=252,bg=234 # fg=#d0d0d0,bg=#202020 + ble-face -s vim_airline_a_insert fg=234,bg=68 # fg=#202020,bg=#3777e6 + ble-face -s vim_airline_a_replace fg=234,bg=198 # fg=#202020,bg=#ff0086 + ble-face -s vim_airline_a_visual fg=234,bg=127 # fg=#202020,bg=#ad00a1 + ble-face -s vim_airline_b fg=254,bg=236 # fg=#e0e0e0,bg=#303030 + ble-face -s vim_airline_b_inactive fg=252,bg=234 # fg=#d0d0d0,bg=#202020 + ble-face -s vim_airline_c fg=208,bg=234 # fg=#fd8900,bg=#202020 + ble-face -s vim_airline_c_inactive fg=252,bg=234 # fg=#d0d0d0,bg=#202020 +} diff --git a/.local/share/blesh/contrib/airline/base16_summerfruit_dark.bash b/.local/share/blesh/contrib/airline/base16_summerfruit_dark.bash new file mode 100644 index 0000000..9f88f79 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_summerfruit_dark.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_summerfruit_dark.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Summerfruit Dark vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Christopher Corley (http://christop.club/) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_summerfruit_dark/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=234,bg=149 # fg=#202020,bg=#b0b0b0 + ble-face -s vim_airline_a_inactive fg=234,bg=234 # fg=#202020,bg=#202020 + ble-face -s vim_airline_a_insert fg=234,bg=40 # fg=#202020,bg=#00c918 + ble-face -s vim_airline_a_replace fg=234,bg=127 # fg=#202020,bg=#ad00a1 + ble-face -s vim_airline_a_visual fg=234,bg=208 # fg=#202020,bg=#fd8900 + ble-face -s vim_airline_b fg=149,bg=236 # fg=#b0b0b0,bg=#303030 + ble-face -s vim_airline_b_inactive fg=149,bg=234 # fg=#b0b0b0,bg=#202020 + ble-face -s vim_airline_c fg=149,bg=234 # fg=#b0b0b0,bg=#202020 + ble-face -s vim_airline_c_inactive fg=252,bg=234 # fg=#d0d0d0,bg=#202020 + ble-face -s vim_airline_c_insert_modified fg=231,bg=234 # fg=#ffffff,bg=#202020 + ble-face -s vim_airline_c_normal_modified fg=231,bg=234 # fg=#ffffff,bg=#202020 + ble-face -s vim_airline_c_replace_modified fg=231,bg=234 # fg=#ffffff,bg=#202020 + ble-face -s vim_airline_c_visual_modified fg=231,bg=234 # fg=#ffffff,bg=#202020 +} diff --git a/.local/share/blesh/contrib/airline/base16_summerfruit_light.bash b/.local/share/blesh/contrib/airline/base16_summerfruit_light.bash new file mode 100644 index 0000000..d6c757d --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_summerfruit_light.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_summerfruit_light.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Summerfruit Light vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Christopher Corley (http://christop.club/) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_summerfruit_light/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=254,bg=16 # fg=#e0e0e0,bg=#000000 + ble-face -s vim_airline_a_inactive fg=254,bg=254 # fg=#e0e0e0,bg=#e0e0e0 + ble-face -s vim_airline_a_insert fg=254,bg=40 # fg=#e0e0e0,bg=#00c918 + ble-face -s vim_airline_a_replace fg=254,bg=127 # fg=#e0e0e0,bg=#ad00a1 + ble-face -s vim_airline_a_visual fg=254,bg=208 # fg=#e0e0e0,bg=#fd8900 + ble-face -s vim_airline_b fg=16,bg=252 # fg=#000000,bg=#d0d0d0 + ble-face -s vim_airline_b_inactive fg=16,bg=254 # fg=#000000,bg=#e0e0e0 + ble-face -s vim_airline_c fg=16,bg=254 # fg=#000000,bg=#e0e0e0 + ble-face -s vim_airline_c_inactive fg=233,bg=254 # fg=#101010,bg=#e0e0e0 + ble-face -s vim_airline_c_insert_modified fg=234,bg=254 # fg=#202020,bg=#e0e0e0 + ble-face -s vim_airline_c_normal_modified fg=234,bg=254 # fg=#202020,bg=#e0e0e0 + ble-face -s vim_airline_c_replace_modified fg=234,bg=254 # fg=#202020,bg=#e0e0e0 + ble-face -s vim_airline_c_visual_modified fg=234,bg=254 # fg=#202020,bg=#e0e0e0 +} diff --git a/.local/share/blesh/contrib/airline/base16_synth_midnight_dark.bash b/.local/share/blesh/contrib/airline/base16_synth_midnight_dark.bash new file mode 100644 index 0000000..809bc5a --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_synth_midnight_dark.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_synth_midnight_dark.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Synth Midnight Dark vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Michaël Ball (http://github.com/michael-ball/) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_synth_midnight_dark/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=233,bg=250 # fg=#141414,bg=#bfbbbf + ble-face -s vim_airline_a_inactive fg=233,bg=233 # fg=#141414,bg=#141414 + ble-face -s vim_airline_a_insert fg=233,bg=41 # fg=#141414,bg=#06ea61 + ble-face -s vim_airline_a_replace fg=233,bg=170 # fg=#141414,bg=#ea5ce2 + ble-face -s vim_airline_a_visual fg=233,bg=166 # fg=#141414,bg=#e4600e + ble-face -s vim_airline_b fg=250,bg=235 # fg=#bfbbbf,bg=#242424 + ble-face -s vim_airline_b_inactive fg=250,bg=233 # fg=#bfbbbf,bg=#141414 + ble-face -s vim_airline_c fg=250,bg=233 # fg=#bfbbbf,bg=#141414 + ble-face -s vim_airline_c_inactive fg=253,bg=233 # fg=#dfdbdf,bg=#141414 + ble-face -s vim_airline_c_insert_modified fg=231,bg=233 # fg=#fffbff,bg=#141414 + ble-face -s vim_airline_c_normal_modified fg=231,bg=233 # fg=#fffbff,bg=#141414 + ble-face -s vim_airline_c_replace_modified fg=231,bg=233 # fg=#fffbff,bg=#141414 + ble-face -s vim_airline_c_visual_modified fg=231,bg=233 # fg=#fffbff,bg=#141414 +} diff --git a/.local/share/blesh/contrib/airline/base16_tomorrow.bash b/.local/share/blesh/contrib/airline/base16_tomorrow.bash new file mode 100644 index 0000000..a85445b --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_tomorrow.bash @@ -0,0 +1,21 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_tomorrow.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# vim-airline template by chartoin (http://github.com/chartoin) +# Base 16 Tomorrow Scheme by Chris Kempson (http://chriskempson.com) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_tomorrow/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=236,bg=143 # fg=#282a2e,bg=#b5bd68 + ble-face -s vim_airline_a_inactive fg=251,bg=236 # fg=#c5c8c6,bg=#282a2e + ble-face -s vim_airline_a_insert fg=236,bg=109 # fg=#282a2e,bg=#81a2be + ble-face -s vim_airline_a_replace fg=236,bg=167 # fg=#282a2e,bg=#cc6666 + ble-face -s vim_airline_a_visual fg=236,bg=139 # fg=#282a2e,bg=#b294bb + ble-face -s vim_airline_b fg=254,bg=237 # fg=#e0e0e0,bg=#373b41 + ble-face -s vim_airline_b_inactive fg=251,bg=236 # fg=#c5c8c6,bg=#282a2e + ble-face -s vim_airline_c fg=173,bg=236 # fg=#de935f,bg=#282a2e + ble-face -s vim_airline_c_inactive fg=251,bg=236 # fg=#c5c8c6,bg=#282a2e +} diff --git a/.local/share/blesh/contrib/airline/base16_tomorrow_night.bash b/.local/share/blesh/contrib/airline/base16_tomorrow_night.bash new file mode 100644 index 0000000..8377536 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_tomorrow_night.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_tomorrow_night.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Tomorrow Night vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Chris Kempson (http://chriskempson.com) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_tomorrow_night/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=236,bg=249 # fg=#282a2e,bg=#b4b7b4 + ble-face -s vim_airline_a_inactive fg=236,bg=236 # fg=#282a2e,bg=#282a2e + ble-face -s vim_airline_a_insert fg=236,bg=143 # fg=#282a2e,bg=#b5bd68 + ble-face -s vim_airline_a_replace fg=236,bg=139 # fg=#282a2e,bg=#b294bb + ble-face -s vim_airline_a_visual fg=236,bg=173 # fg=#282a2e,bg=#de935f + ble-face -s vim_airline_b fg=249,bg=237 # fg=#b4b7b4,bg=#373b41 + ble-face -s vim_airline_b_inactive fg=249,bg=236 # fg=#b4b7b4,bg=#282a2e + ble-face -s vim_airline_c fg=249,bg=236 # fg=#b4b7b4,bg=#282a2e + ble-face -s vim_airline_c_inactive fg=251,bg=236 # fg=#c5c8c6,bg=#282a2e + ble-face -s vim_airline_c_insert_modified fg=231,bg=236 # fg=#ffffff,bg=#282a2e + ble-face -s vim_airline_c_normal_modified fg=231,bg=236 # fg=#ffffff,bg=#282a2e + ble-face -s vim_airline_c_replace_modified fg=231,bg=236 # fg=#ffffff,bg=#282a2e + ble-face -s vim_airline_c_visual_modified fg=231,bg=236 # fg=#ffffff,bg=#282a2e +} diff --git a/.local/share/blesh/contrib/airline/base16_tomorrow_night_eighties.bash b/.local/share/blesh/contrib/airline/base16_tomorrow_night_eighties.bash new file mode 100644 index 0000000..4a4070d --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_tomorrow_night_eighties.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_tomorrow_night_eighties.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Tomorrow Night vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Chris Kempson (http://chriskempson.com) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_tomorrow_night_eighties/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=237,bg=249 # fg=#393939,bg=#b4b7b4 + ble-face -s vim_airline_a_inactive fg=237,bg=237 # fg=#393939,bg=#393939 + ble-face -s vim_airline_a_insert fg=237,bg=114 # fg=#393939,bg=#99cc99 + ble-face -s vim_airline_a_replace fg=237,bg=176 # fg=#393939,bg=#cc99cc + ble-face -s vim_airline_a_visual fg=237,bg=209 # fg=#393939,bg=#f99157 + ble-face -s vim_airline_b fg=249,bg=239 # fg=#b4b7b4,bg=#515151 + ble-face -s vim_airline_b_inactive fg=249,bg=237 # fg=#b4b7b4,bg=#393939 + ble-face -s vim_airline_c fg=249,bg=237 # fg=#b4b7b4,bg=#393939 + ble-face -s vim_airline_c_inactive fg=252,bg=237 # fg=#cccccc,bg=#393939 + ble-face -s vim_airline_c_insert_modified fg=231,bg=237 # fg=#ffffff,bg=#393939 + ble-face -s vim_airline_c_normal_modified fg=231,bg=237 # fg=#ffffff,bg=#393939 + ble-face -s vim_airline_c_replace_modified fg=231,bg=237 # fg=#ffffff,bg=#393939 + ble-face -s vim_airline_c_visual_modified fg=231,bg=237 # fg=#ffffff,bg=#393939 +} diff --git a/.local/share/blesh/contrib/airline/base16_tube.bash b/.local/share/blesh/contrib/airline/base16_tube.bash new file mode 100644 index 0000000..a43c5f8 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_tube.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_tube.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 London Tube vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Jan T. Sott + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_tube/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=24,bg=109 # fg=#1c3f95,bg=#959ca1 + ble-face -s vim_airline_a_inactive fg=24,bg=24 # fg=#1c3f95,bg=#1c3f95 + ble-face -s vim_airline_a_insert fg=24,bg=29 # fg=#1c3f95,bg=#00853e + ble-face -s vim_airline_a_replace fg=24,bg=89 # fg=#1c3f95,bg=#98005d + ble-face -s vim_airline_a_visual fg=24,bg=211 # fg=#1c3f95,bg=#f386a1 + ble-face -s vim_airline_b fg=109,bg=240 # fg=#959ca1,bg=#5a5758 + ble-face -s vim_airline_b_inactive fg=109,bg=24 # fg=#959ca1,bg=#1c3f95 + ble-face -s vim_airline_c fg=109,bg=24 # fg=#959ca1,bg=#1c3f95 + ble-face -s vim_airline_c_inactive fg=192,bg=24 # fg=#d9d8d8,bg=#1c3f95 + ble-face -s vim_airline_c_insert_modified fg=231,bg=24 # fg=#ffffff,bg=#1c3f95 + ble-face -s vim_airline_c_normal_modified fg=231,bg=24 # fg=#ffffff,bg=#1c3f95 + ble-face -s vim_airline_c_replace_modified fg=231,bg=24 # fg=#ffffff,bg=#1c3f95 + ble-face -s vim_airline_c_visual_modified fg=231,bg=24 # fg=#ffffff,bg=#1c3f95 +} diff --git a/.local/share/blesh/contrib/airline/base16_twilight.bash b/.local/share/blesh/contrib/airline/base16_twilight.bash new file mode 100644 index 0000000..76bc4db --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_twilight.bash @@ -0,0 +1,21 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_twilight.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# vim-airline template by chartoin (http://github.com/chartoin) +# Base 16 Twilight Scheme by David Hart (http://hart-dev.com) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_twilight/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=237,bg=107 # fg=#323537,bg=#8f9d6a + ble-face -s vim_airline_a_inactive fg=248,bg=237 # fg=#a7a7a7,bg=#323537 + ble-face -s vim_airline_a_insert fg=237,bg=103 # fg=#323537,bg=#7587a6 + ble-face -s vim_airline_a_replace fg=237,bg=167 # fg=#323537,bg=#cf6a4c + ble-face -s vim_airline_a_visual fg=237,bg=139 # fg=#323537,bg=#9b859d + ble-face -s vim_airline_b fg=251,bg=239 # fg=#c3c3c3,bg=#464b50 + ble-face -s vim_airline_b_inactive fg=248,bg=237 # fg=#a7a7a7,bg=#323537 + ble-face -s vim_airline_c fg=179,bg=237 # fg=#cda869,bg=#323537 + ble-face -s vim_airline_c_inactive fg=248,bg=237 # fg=#a7a7a7,bg=#323537 +} diff --git a/.local/share/blesh/contrib/airline/base16_unikitty_dark.bash b/.local/share/blesh/contrib/airline/base16_unikitty_dark.bash new file mode 100644 index 0000000..5548546 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_unikitty_dark.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_unikitty_dark.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Unikitty Dark vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Josh W Lewis (@joshwlewis) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_unikitty_dark/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=239,bg=247 # fg=#4a464d,bg=#9f9da2 + ble-face -s vim_airline_a_inactive fg=239,bg=239 # fg=#4a464d,bg=#4a464d + ble-face -s vim_airline_a_insert fg=239,bg=36 # fg=#4a464d,bg=#17ad98 + ble-face -s vim_airline_a_replace fg=239,bg=134 # fg=#4a464d,bg=#bb60ea + ble-face -s vim_airline_a_visual fg=239,bg=166 # fg=#4a464d,bg=#d65407 + ble-face -s vim_airline_b fg=247,bg=241 # fg=#9f9da2,bg=#666369 + ble-face -s vim_airline_b_inactive fg=247,bg=239 # fg=#9f9da2,bg=#4a464d + ble-face -s vim_airline_c fg=247,bg=239 # fg=#9f9da2,bg=#4a464d + ble-face -s vim_airline_c_inactive fg=250,bg=239 # fg=#bcbabe,bg=#4a464d + ble-face -s vim_airline_c_insert_modified fg=255,bg=239 # fg=#f5f4f7,bg=#4a464d + ble-face -s vim_airline_c_normal_modified fg=255,bg=239 # fg=#f5f4f7,bg=#4a464d + ble-face -s vim_airline_c_replace_modified fg=255,bg=239 # fg=#f5f4f7,bg=#4a464d + ble-face -s vim_airline_c_visual_modified fg=255,bg=239 # fg=#f5f4f7,bg=#4a464d +} diff --git a/.local/share/blesh/contrib/airline/base16_unikitty_light.bash b/.local/share/blesh/contrib/airline/base16_unikitty_light.bash new file mode 100644 index 0000000..9fae40e --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_unikitty_light.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_unikitty_light.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Unikitty Light vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Josh W Lewis (@joshwlewis) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_unikitty_light/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=254,bg=245 # fg=#e1e1e2,bg=#89878b + ble-face -s vim_airline_a_inactive fg=254,bg=254 # fg=#e1e1e2,bg=#e1e1e2 + ble-face -s vim_airline_a_insert fg=254,bg=36 # fg=#e1e1e2,bg=#17ad98 + ble-face -s vim_airline_a_replace fg=254,bg=128 # fg=#e1e1e2,bg=#aa17e6 + ble-face -s vim_airline_a_visual fg=254,bg=166 # fg=#e1e1e2,bg=#d65407 + ble-face -s vim_airline_b fg=245,bg=251 # fg=#89878b,bg=#c4c3c5 + ble-face -s vim_airline_b_inactive fg=245,bg=254 # fg=#89878b,bg=#e1e1e2 + ble-face -s vim_airline_c fg=245,bg=254 # fg=#89878b,bg=#e1e1e2 + ble-face -s vim_airline_c_inactive fg=242,bg=254 # fg=#6c696e,bg=#e1e1e2 + ble-face -s vim_airline_c_insert_modified fg=53,bg=254 # fg=#322d34,bg=#e1e1e2 + ble-face -s vim_airline_c_normal_modified fg=53,bg=254 # fg=#322d34,bg=#e1e1e2 + ble-face -s vim_airline_c_replace_modified fg=53,bg=254 # fg=#322d34,bg=#e1e1e2 + ble-face -s vim_airline_c_visual_modified fg=53,bg=254 # fg=#322d34,bg=#e1e1e2 +} diff --git a/.local/share/blesh/contrib/airline/base16_vim.bash b/.local/share/blesh/contrib/airline/base16_vim.bash new file mode 100644 index 0000000..7b5d1c5 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_vim.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_vim.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_vim/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=234,bg=143 # fg=#181818,bg=#a1b56c + ble-face -s vim_airline_a_inactive fg=240,bg=235 # fg=#585858,bg=#282828 + ble-face -s vim_airline_a_insert fg=235,bg=109 # fg=#282828,bg=#7cafc2 + ble-face -s vim_airline_a_replace fg=235,bg=131 # fg=#282828,bg=#ab4642 + ble-face -s vim_airline_a_visual fg=235,bg=139 # fg=#282828,bg=#ba8baf + ble-face -s vim_airline_b fg=250,bg=237 # fg=#b8b8b8,bg=#383838 + ble-face -s vim_airline_b_inactive fg=240,bg=235 # fg=#585858,bg=#282828 + ble-face -s vim_airline_c fg=143,bg=235 # fg=#a1b56c,bg=#282828 + ble-face -s vim_airline_c_inactive fg=240,bg=235 # fg=#585858,bg=#282828 + ble-face -s vim_airline_c_inactive_modified fg=173,bg=0 # fg=#dc9656,bg=0 + ble-face -s vim_airline_c_insert fg=109,bg=235 # fg=#7cafc2,bg=#282828 + ble-face -s vim_airline_c_insert_modified fg=173,bg=235 # fg=#dc9656,bg=#282828 + ble-face -s vim_airline_c_normal_modified fg=173,bg=235 # fg=#dc9656,bg=#282828 + ble-face -s vim_airline_c_replace fg=131,bg=235 # fg=#ab4642,bg=#282828 + ble-face -s vim_airline_c_replace_modified fg=173,bg=235 # fg=#dc9656,bg=#282828 + ble-face -s vim_airline_c_visual fg=139,bg=235 # fg=#ba8baf,bg=#282828 +} diff --git a/.local/share/blesh/contrib/airline/base16_woodland.bash b/.local/share/blesh/contrib/airline/base16_woodland.bash new file mode 100644 index 0000000..ff02d5f --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_woodland.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_woodland.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Woodland vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Jay Cornwall (https://jcornwall.com) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_woodland/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=52,bg=144 # fg=#302b25,bg=#b4a490 + ble-face -s vim_airline_a_inactive fg=52,bg=52 # fg=#302b25,bg=#302b25 + ble-face -s vim_airline_a_insert fg=52,bg=143 # fg=#302b25,bg=#b7ba53 + ble-face -s vim_airline_a_replace fg=52,bg=140 # fg=#302b25,bg=#bb90e2 + ble-face -s vim_airline_a_visual fg=52,bg=173 # fg=#302b25,bg=#ca7f32 + ble-face -s vim_airline_b fg=144,bg=238 # fg=#b4a490,bg=#48413a + ble-face -s vim_airline_b_inactive fg=144,bg=52 # fg=#b4a490,bg=#302b25 + ble-face -s vim_airline_c fg=144,bg=52 # fg=#b4a490,bg=#302b25 + ble-face -s vim_airline_c_inactive fg=181,bg=52 # fg=#cabcb1,bg=#302b25 + ble-face -s vim_airline_c_insert_modified fg=189,bg=52 # fg=#e4d4c8,bg=#302b25 + ble-face -s vim_airline_c_normal_modified fg=189,bg=52 # fg=#e4d4c8,bg=#302b25 + ble-face -s vim_airline_c_replace_modified fg=189,bg=52 # fg=#e4d4c8,bg=#302b25 + ble-face -s vim_airline_c_visual_modified fg=189,bg=52 # fg=#e4d4c8,bg=#302b25 +} diff --git a/.local/share/blesh/contrib/airline/base16_xcode_dusk.bash b/.local/share/blesh/contrib/airline/base16_xcode_dusk.bash new file mode 100644 index 0000000..ece8fc7 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_xcode_dusk.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_xcode_dusk.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 XCode Dusk vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By Elsa Gonsiorowski (https://github.com/gonsie) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_xcode_dusk/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=238,bg=244 # fg=#3d4048,bg=#7e8086 + ble-face -s vim_airline_a_inactive fg=238,bg=238 # fg=#3d4048,bg=#3d4048 + ble-face -s vim_airline_a_insert fg=238,bg=160 # fg=#3d4048,bg=#df0002 + ble-face -s vim_airline_a_replace fg=238,bg=126 # fg=#3d4048,bg=#b21889 + ble-face -s vim_airline_a_visual fg=238,bg=98 # fg=#3d4048,bg=#786dc5 + ble-face -s vim_airline_b fg=244,bg=240 # fg=#7e8086,bg=#53555d + ble-face -s vim_airline_b_inactive fg=244,bg=238 # fg=#7e8086,bg=#3d4048 + ble-face -s vim_airline_c fg=244,bg=238 # fg=#7e8086,bg=#3d4048 + ble-face -s vim_airline_c_inactive fg=246,bg=238 # fg=#939599,bg=#3d4048 + ble-face -s vim_airline_c_insert_modified fg=250,bg=238 # fg=#bebfc2,bg=#3d4048 + ble-face -s vim_airline_c_normal_modified fg=250,bg=238 # fg=#bebfc2,bg=#3d4048 + ble-face -s vim_airline_c_replace_modified fg=250,bg=238 # fg=#bebfc2,bg=#3d4048 + ble-face -s vim_airline_c_visual_modified fg=250,bg=238 # fg=#bebfc2,bg=#3d4048 +} diff --git a/.local/share/blesh/contrib/airline/base16_zenburn.bash b/.local/share/blesh/contrib/airline/base16_zenburn.bash new file mode 100644 index 0000000..a0482d6 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16_zenburn.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16_zenburn.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Base16 Zenburn vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes) +# For vim-airline (https://github.com/vim-airline/vim-airline) +# By elnawe + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16_zenburn/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=238,bg=244 # fg=#404040,bg=#808080 + ble-face -s vim_airline_a_inactive fg=238,bg=238 # fg=#404040,bg=#404040 + ble-face -s vim_airline_a_insert fg=238,bg=65 # fg=#404040,bg=#5f7f5f + ble-face -s vim_airline_a_replace fg=238,bg=176 # fg=#404040,bg=#dc8cc3 + ble-face -s vim_airline_a_visual fg=238,bg=180 # fg=#404040,bg=#dfaf8f + ble-face -s vim_airline_b fg=244,bg=63 # fg=#808080,bg=#606060 + ble-face -s vim_airline_b_inactive fg=244,bg=238 # fg=#808080,bg=#404040 + ble-face -s vim_airline_c fg=244,bg=238 # fg=#808080,bg=#404040 + ble-face -s vim_airline_c_inactive fg=191,bg=238 # fg=#dcdccc,bg=#404040 + ble-face -s vim_airline_c_insert_modified fg=231,bg=238 # fg=#ffffff,bg=#404040 + ble-face -s vim_airline_c_normal_modified fg=231,bg=238 # fg=#ffffff,bg=#404040 + ble-face -s vim_airline_c_replace_modified fg=231,bg=238 # fg=#ffffff,bg=#404040 + ble-face -s vim_airline_c_visual_modified fg=231,bg=238 # fg=#ffffff,bg=#404040 +} diff --git a/.local/share/blesh/contrib/airline/base16color.bash b/.local/share/blesh/contrib/airline/base16color.bash new file mode 100644 index 0000000..f8073c0 --- /dev/null +++ b/.local/share/blesh/contrib/airline/base16color.bash @@ -0,0 +1,40 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/base16color.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Normal mode +# [ guifg, guibg, ctermfg, ctermbg, opts ] + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:base16color/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=233,bg=186 # fg=#141413,bg=#cae682 + ble-face -s vim_airline_a_inactive fg=243,bg=235 # fg=#767676,bg=#242424 + ble-face -s vim_airline_a_insert fg=233,bg=221 # fg=#141413,bg=#fde76e + ble-face -s vim_airline_a_insert_modified fg=233,bg=221 # fg=#141413,bg=#fade3e + ble-face -s vim_airline_a_normal_modified fg=233,bg=114 # fg=#141413,bg=#86cd74 + ble-face -s vim_airline_a_replace fg=233,bg=173 # fg=#141413,bg=#e5786d + ble-face -s vim_airline_a_replace_modified fg=233,bg=167 # fg=#141413,bg=#e55345 + ble-face -s vim_airline_a_visual fg=233,bg=153 # fg=#141413,bg=#b5d3f3 + ble-face -s vim_airline_a_visual_modified fg=233,bg=110 # fg=#141413,bg=#7cb0e6 + ble-face -s vim_airline_b fg=186,bg=58 # fg=#cae682,bg=#32322f + ble-face -s vim_airline_b_inactive fg=243,bg=235 # fg=#767676,bg=#242424 + ble-face -s vim_airline_b_insert fg=221,bg=58 # fg=#fde76e,bg=#32322f + ble-face -s vim_airline_b_insert_modified fg=221,bg=238 # fg=#fade3e,bg=#40403c + ble-face -s vim_airline_b_normal_modified fg=114,bg=238 # fg=#86cd74,bg=#40403c + ble-face -s vim_airline_b_replace fg=173,bg=58 # fg=#e5786d,bg=#32322f + ble-face -s vim_airline_b_replace_modified fg=167,bg=238 # fg=#e55345,bg=#40403c + ble-face -s vim_airline_b_visual fg=153,bg=58 # fg=#b5d3f3,bg=#32322f + ble-face -s vim_airline_b_visual_modified fg=110,bg=238 # fg=#7cb0e6,bg=#40403c + ble-face -s vim_airline_c fg=186,bg=235 # fg=#cae682,bg=#242424 + ble-face -s vim_airline_c_inactive fg=243,bg=235 # fg=#767676,bg=#242424 + ble-face -s vim_airline_c_inactive_modified fg=114,bg=0 # fg=#86cd74,bg=0 + ble-face -s vim_airline_c_insert fg=221,bg=235 # fg=#fde76e,bg=#242424 + ble-face -s vim_airline_c_insert_modified fg=221,bg=235 # fg=#fade3e,bg=#242424 + ble-face -s vim_airline_c_normal_modified fg=114,bg=235 # fg=#86cd74,bg=#242424 + ble-face -s vim_airline_c_replace fg=173,bg=235 # fg=#e5786d,bg=#242424 + ble-face -s vim_airline_c_replace_modified fg=167,bg=235 # fg=#e55345,bg=#242424 + ble-face -s vim_airline_c_visual fg=153,bg=235 # fg=#b5d3f3,bg=#242424 + ble-face -s vim_airline_c_visual_modified fg=110,bg=235 # fg=#7cb0e6,bg=#242424 +} diff --git a/.local/share/blesh/contrib/airline/behelit.bash b/.local/share/blesh/contrib/airline/behelit.bash new file mode 100644 index 0000000..345e39a --- /dev/null +++ b/.local/share/blesh/contrib/airline/behelit.bash @@ -0,0 +1,27 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/behelit.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:behelit/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=233,bg=69 # fg=#121212,bg=#5f87ff + ble-face -s vim_airline_a_inactive fg=239,bg=234 # fg=#4e4e4e,bg=#1c1c1c + ble-face -s vim_airline_a_insert fg=233,bg=48 # fg=#121212,bg=#00ff87 + ble-face -s vim_airline_a_replace fg=233,bg=161 # fg=#121212,bg=#d70057 + ble-face -s vim_airline_a_visual fg=233,bg=83 # fg=#121212,bg=#5fff5f + ble-face -s vim_airline_b fg=69,bg=235 # fg=#5f87ff,bg=#262626 + ble-face -s vim_airline_b_inactive fg=239,bg=235 # fg=#4e4e4e,bg=#262626 + ble-face -s vim_airline_c fg=69,bg=234 # fg=#5f87ff,bg=#1c1c1c + ble-face -s vim_airline_c_inactive fg=239,bg=234 # fg=#4e4e4e,bg=#1c1c1c + ble-face -s vim_airline_c_inactive_modified fg=60,bg=234 # fg=#5f5f87,bg=#1c1c1c + ble-face -s vim_airline_c_insert_modified fg=161,bg=234 # fg=#d7005f,bg=#1c1c1c + ble-face -s vim_airline_c_normal_modified fg=161,bg=234 # fg=#d7005f,bg=#1c1c1c + ble-face -s vim_airline_c_replace_modified fg=161,bg=234 # fg=#d7005f,bg=#1c1c1c + ble-face -s vim_airline_c_visual_modified fg=161,bg=234 # fg=#d7005f,bg=#1c1c1c + ble-face -s vim_airline_warning fg=233,bg=161 # fg=#121212,bg=#d7005f + ble-face -s vim_airline_warning_inactive fg=16,bg=166 # fg=#000000,bg=#df5f00 + ble-face -s vim_airline_z_replace fg=233,bg=48 # fg=#121212,bg=#00ff87 +} diff --git a/.local/share/blesh/contrib/airline/biogoo.bash b/.local/share/blesh/contrib/airline/biogoo.bash new file mode 100644 index 0000000..24d1dba --- /dev/null +++ b/.local/share/blesh/contrib/airline/biogoo.bash @@ -0,0 +1,30 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/biogoo.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Name: biogoo (vim-airline version) +# Author: Benjamin Esham (https://esham.io) +# Last Change: 2017-10-20 +# +# You can find more information on the Biogoo theme at . + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:biogoo/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=231,bg=24 # fg=#ffffff,bg=#295498 + ble-face -s vim_airline_a_inactive fg=242,bg=231 # fg=#676767,bg=#ffffff + ble-face -s vim_airline_a_insert fg=231,bg=34 # fg=#ffffff,bg=#00a000 + ble-face -s vim_airline_a_replace fg=231,bg=160 # fg=#ffffff,bg=#d11518 + ble-face -s vim_airline_a_visual fg=231,bg=166 # fg=#ffffff,bg=#cc6600 + ble-face -s vim_airline_b fg=24,bg=254 # fg=#295498,bg=#e5e5e5 + ble-face -s vim_airline_b_inactive fg=242,bg=231 # fg=#676767,bg=#ffffff + ble-face -s vim_airline_c fg=24,bg=231 # fg=#295498,bg=#ffffff + ble-face -s vim_airline_c_inactive fg=242,bg=231 # fg=#676767,bg=#ffffff + ble-face -s vim_airline_c_inactive_modified fg=34,bg=231 # fg=#00a000,bg=#ffffff + ble-face -s vim_airline_c_insert_modified fg=34,bg=231 # fg=#00a000,bg=#ffffff + ble-face -s vim_airline_c_normal_modified fg=34,bg=231 # fg=#00a000,bg=#ffffff + ble-face -s vim_airline_c_replace_modified fg=34,bg=231 # fg=#00a000,bg=#ffffff + ble-face -s vim_airline_c_visual_modified fg=34,bg=231 # fg=#00a000,bg=#ffffff + ble-face -s vim_airline_term fg=231,bg=242 # fg=#ffffff,bg=#676767 +} diff --git a/.local/share/blesh/contrib/airline/blood_red.bash b/.local/share/blesh/contrib/airline/blood_red.bash new file mode 100644 index 0000000..5d6117d --- /dev/null +++ b/.local/share/blesh/contrib/airline/blood_red.bash @@ -0,0 +1,22 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/blood_red.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:blood_red/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=250,bg=160 # fg=#bcbcbc,bg=#d62929 + ble-face -s vim_airline_a_inactive fg=160,bg=237 # fg=#d62929,bg=#3a3a3a + ble-face -s vim_airline_a_insert fg=231,bg=88 # fg=#fffdfa,bg=#8b0000 + ble-face -s vim_airline_a_replace fg=251,bg=161 # fg=#c6c6c6,bg=#d62962 + ble-face -s vim_airline_a_visual fg=231,bg=161 # fg=#fffdfa,bg=#d62962 + ble-face -s vim_airline_b fg=231,bg=88 # fg=#ffffff,bg=#8b0000 + ble-face -s vim_airline_b_inactive fg=160,bg=237 # fg=#d62929,bg=#3a3a3a + ble-face -s vim_airline_b_insert fg=231,bg=160 # fg=#ffffff,bg=#c50000 + ble-face -s vim_airline_b_replace fg=231,bg=88 # fg=#ffffff,bg=#8b0000 + ble-face -s vim_airline_c fg=251,bg=237 # fg=#c6c6c6,bg=#3a3a3a + ble-face -s vim_airline_c_inactive fg=160,bg=237 # fg=#d62929,bg=#3a3a3a + ble-face -s vim_airline_z_replace fg=250,bg=160 # fg=#bcbcbc,bg=#d62929 +} diff --git a/.local/share/blesh/contrib/airline/bubblegum.bash b/.local/share/blesh/contrib/airline/bubblegum.bash new file mode 100644 index 0000000..5b1697c --- /dev/null +++ b/.local/share/blesh/contrib/airline/bubblegum.bash @@ -0,0 +1,28 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/bubblegum.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Color palette + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:bubblegum/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=236,bg=150 # fg=#303030,bg=#afd787 + ble-face -s vim_airline_a_inactive fg=249,bg=238 # fg=#b2b2b2,bg=#444444 + ble-face -s vim_airline_a_insert fg=238,bg=110 # fg=#444444,bg=#87afd7 + ble-face -s vim_airline_a_replace fg=236,bg=174 # fg=#303030,bg=#d78787 + ble-face -s vim_airline_a_visual fg=236,bg=182 # fg=#303030,bg=#d7afd7 + ble-face -s vim_airline_b fg=249,bg=237 # fg=#b2b2b2,bg=#3a3a3a + ble-face -s vim_airline_b_inactive fg=249,bg=238 # fg=#b2b2b2,bg=#444444 + ble-face -s vim_airline_c fg=150,bg=238 # fg=#afd787,bg=#444444 + ble-face -s vim_airline_c_inactive fg=249,bg=238 # fg=#b2b2b2,bg=#444444 + ble-face -s vim_airline_c_inactive_modified fg=179,bg=0 # fg=#d7af5f,bg=0 + ble-face -s vim_airline_c_insert fg=110,bg=238 # fg=#87afd7,bg=#444444 + ble-face -s vim_airline_c_insert_modified fg=179,bg=238 # fg=#d7af5f,bg=#444444 + ble-face -s vim_airline_c_normal_modified fg=179,bg=238 # fg=#d7af5f,bg=#444444 + ble-face -s vim_airline_c_replace fg=174,bg=238 # fg=#d78787,bg=#444444 + ble-face -s vim_airline_c_replace_modified fg=179,bg=238 # fg=#d7af5f,bg=#444444 + ble-face -s vim_airline_c_visual fg=182,bg=238 # fg=#d7afd7,bg=#444444 + ble-face -s vim_airline_c_visual_modified fg=179,bg=238 # fg=#d7af5f,bg=#444444 +} diff --git a/.local/share/blesh/contrib/airline/cobalt2.bash b/.local/share/blesh/contrib/airline/cobalt2.bash new file mode 100644 index 0000000..4d6e238 --- /dev/null +++ b/.local/share/blesh/contrib/airline/cobalt2.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/cobalt2.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:cobalt2/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=231,bg=32 # fg=#ffffff,bg=#1f7ad8 + ble-face -s vim_airline_a_inactive fg=239,bg=23 # fg=#4e4e4e,bg=#204458 + ble-face -s vim_airline_a_insert fg=241,bg=221 # fg=#666d51,bg=#fee533 + ble-face -s vim_airline_a_replace fg=231,bg=174 # fg=#ffffff,bg=#ea9299 + ble-face -s vim_airline_a_visual fg=228,bg=214 # fg=#ffff9a,bg=#ff9d00 + ble-face -s vim_airline_b fg=231,bg=111 # fg=#ffffff,bg=#8cc2fd + ble-face -s vim_airline_b_inactive fg=239,bg=23 # fg=#4e4e4e,bg=#204458 + ble-face -s vim_airline_c fg=231,bg=23 # fg=#ffffff,bg=#204458 + ble-face -s vim_airline_c_inactive fg=239,bg=23 # fg=#4e4e4e,bg=#204458 + ble-face -s vim_airline_c_inactive_modified fg=125,bg=0 # fg=#b42839,bg=0 + ble-face -s vim_airline_c_insert_modified fg=241,bg=221 # fg=#666d51,bg=#fee533 + ble-face -s vim_airline_c_normal_modified fg=231,bg=32 # fg=#ffffff,bg=#1f7ad8 + ble-face -s vim_airline_c_replace_modified fg=231,bg=174 # fg=#ffffff,bg=#ea9299 + ble-face -s vim_airline_c_visual_modified fg=228,bg=214 # fg=#ffff9a,bg=#ff9d00 + ble-face -s vim_airline_warning fg=23,bg=231 # fg=#204458,bg=#ffffff + ble-face -s vim_airline_warning_inactive fg=16,bg=166 # fg=#000000,bg=#df5f00 +} diff --git a/.local/share/blesh/contrib/airline/cool.bash b/.local/share/blesh/contrib/airline/cool.bash new file mode 100644 index 0000000..c5891e9 --- /dev/null +++ b/.local/share/blesh/contrib/airline/cool.bash @@ -0,0 +1,25 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/cool.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:cool/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=240,bg=254 # fg=#585858,bg=#e4e4e4 + ble-face -s vim_airline_b fg=254,bg=31 # fg=#e4e4e4,bg=#0087af + ble-face -s vim_airline_b_inactive fg=254,bg=60 # fg=#e4e4e4,bg=#466d79 + ble-face -s vim_airline_b_insert fg=254,bg=70 # fg=#e4e4e4,bg=#47af00 + ble-face -s vim_airline_b_replace fg=254,bg=130 # fg=#e4e4e4,bg=#af5f00 + ble-face -s vim_airline_b_visual fg=254,bg=124 # fg=#e4e4e4,bg=#af2800 + ble-face -s vim_airline_c fg=255,bg=24 # fg=#eeeeee,bg=#005f87 + ble-face -s vim_airline_c_inactive fg=255,bg=238 # fg=#eeeeee,bg=#324e59 + ble-face -s vim_airline_c_insert fg=255,bg=28 # fg=#eeeeee,bg=#2e8700 + ble-face -s vim_airline_c_replace fg=255,bg=94 # fg=#eeeeee,bg=#875300 + ble-face -s vim_airline_c_visual fg=255,bg=88 # fg=#eeeeee,bg=#872800 + ble-face -s vim_airline_term fg=255,bg=24 # fg=#eeeeee,bg=#005f87 + ble-face -s vim_airline_term_inactive fg=158,bg=234 # fg=#9cffd3,bg=#202020 + ble-face -s vim_airline_term_insert fg=158,bg=234 # fg=#9cffd3,bg=#202020 + ble-face -s vim_airline_term_visual fg=255,bg=88 # fg=#eeeeee,bg=#872800 +} diff --git a/.local/share/blesh/contrib/airline/cyberpunk.bash b/.local/share/blesh/contrib/airline/cyberpunk.bash new file mode 100644 index 0000000..83f948d --- /dev/null +++ b/.local/share/blesh/contrib/airline/cyberpunk.bash @@ -0,0 +1,43 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/cyberpunk.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# vim-airline template by danrneal (http://github.com/danrneal) +# Cyberpunk by Tai Groot + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:cyberpunk/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=32,bg=220 # fg=#0197dd,bg=#ffd302 + ble-face -s vim_airline_a_commandline fg=234,bg=196 # fg=#191919,bg=#ff0000 + ble-face -s vim_airline_a_inactive fg=234,bg=238 # fg=#191919,bg=#414c3b + ble-face -s vim_airline_a_insert fg=220,bg=32 # fg=#ffd302,bg=#0197dd + ble-face -s vim_airline_a_replace fg=234,bg=196 # fg=#191919,bg=#ff0000 + ble-face -s vim_airline_a_visual fg=234,bg=64 # fg=#191919,bg=#408000 + ble-face -s vim_airline_b fg=241,bg=238 # fg=#666666,bg=#414c3b + ble-face -s vim_airline_b_commandline_modified fg=45,bg=234 # fg=#0eeafa,bg=#191919 + ble-face -s vim_airline_b_inactive_modified fg=45,bg=234 # fg=#0eeafa,bg=#191919 + ble-face -s vim_airline_b_insert_modified fg=45,bg=234 # fg=#0eeafa,bg=#191919 + ble-face -s vim_airline_b_normal_modified fg=45,bg=234 # fg=#0eeafa,bg=#191919 + ble-face -s vim_airline_b_replace_modified fg=45,bg=234 # fg=#0eeafa,bg=#191919 + ble-face -s vim_airline_b_visual_modified fg=45,bg=234 # fg=#0eeafa,bg=#191919 + ble-face -s vim_airline_c fg=32,bg=220 # fg=#0197dd,bg=#ffd302 + ble-face -s vim_airline_c_commandline fg=234,bg=196 # fg=#191919,bg=#ff0000 + ble-face -s vim_airline_c_inactive fg=238,bg=234 # fg=#414c3b,bg=#191919 + ble-face -s vim_airline_c_insert fg=220,bg=32 # fg=#ffd302,bg=#0197dd + ble-face -s vim_airline_c_replace fg=234,bg=196 # fg=#191919,bg=#ff0000 + ble-face -s vim_airline_c_visual fg=234,bg=64 # fg=#191919,bg=#408000 + ble-face -s vim_airline_error fg=196,bg=25 # fg=#ff0000,bg=#0c35bf + ble-face -s vim_airline_error_inactive fg=16,bg=88 # fg=#000000,bg=#990000 + ble-face -s vim_airline_error_inactive_modified fg=196,bg=25 # fg=#ff0000,bg=#0c35bf + ble-face -s vim_airline_warning fg=118,bg=25 # fg=#87f025,bg=#0c35bf + ble-face -s vim_airline_warning_inactive fg=16,bg=166 # fg=#000000,bg=#df5f00 + ble-face -s vim_airline_warning_inactive_modified fg=118,bg=25 # fg=#87f025,bg=#0c35bf + ble-face -s vim_airline_y_commandline_modified fg=45,bg=234 # fg=#0eeafa,bg=#191919 + ble-face -s vim_airline_y_inactive_modified fg=45,bg=234 # fg=#0eeafa,bg=#191919 + ble-face -s vim_airline_y_insert_modified fg=45,bg=234 # fg=#0eeafa,bg=#191919 + ble-face -s vim_airline_y_normal_modified fg=45,bg=234 # fg=#0eeafa,bg=#191919 + ble-face -s vim_airline_y_replace_modified fg=45,bg=234 # fg=#0eeafa,bg=#191919 + ble-face -s vim_airline_y_visual_modified fg=45,bg=234 # fg=#0eeafa,bg=#191919 +} diff --git a/.local/share/blesh/contrib/airline/dark.bash b/.local/share/blesh/contrib/airline/dark.bash new file mode 100644 index 0000000..cdb53e3 --- /dev/null +++ b/.local/share/blesh/contrib/airline/dark.bash @@ -0,0 +1,30 @@ +# From github:vim-airline/vim-airline/autoload/airline/themes/dark.vim +# The MIT License (MIT) +# Copyright (c) 2013-2021 Bailey Ling et al. +# + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:dark/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=17,bg=190 # fg=#00005f,bg=#dfff00 + ble-face -s vim_airline_a_commandline fg=17,bg=40 # fg=#00005f,bg=#00d700 + ble-face -s vim_airline_a_inactive fg=239,bg=234 # fg=#4e4e4e,bg=#1c1c1c + ble-face -s vim_airline_a_insert fg=17,bg=45 # fg=#00005f,bg=#00dfff + ble-face -s vim_airline_a_replace fg=231,bg=124 # fg=#ffffff,bg=#af0000 + ble-face -s vim_airline_a_visual fg=16,bg=214 # fg=#000000,bg=#ffaf00 + ble-face -s vim_airline_b fg=231,bg=238 # fg=#ffffff,bg=#444444 + ble-face -s vim_airline_b_inactive fg=239,bg=235 # fg=#4e4e4e,bg=#262626 + ble-face -s vim_airline_b_insert fg=231,bg=27 # fg=#ffffff,bg=#005fff + ble-face -s vim_airline_b_visual fg=16,bg=202 # fg=#000000,bg=#ff5f00 + ble-face -s vim_airline_c fg=158,bg=234 # fg=#9cffd3,bg=#202020 + ble-face -s vim_airline_c_inactive fg=239,bg=236 # fg=#4e4e4e,bg=#303030 + ble-face -s vim_airline_c_inactive_modified fg=97,bg=0 # fg=#875faf,bg=0 + ble-face -s vim_airline_c_insert fg=231,bg=18 # fg=#ffffff,bg=#000080 + ble-face -s vim_airline_c_insert_modified fg=231,bg=53 # fg=#ffffff,bg=#5f005f + ble-face -s vim_airline_c_normal_modified fg=231,bg=53 # fg=#ffffff,bg=#5f005f + ble-face -s vim_airline_c_replace_modified fg=231,bg=53 # fg=#ffffff,bg=#5f005f + ble-face -s vim_airline_c_visual fg=231,bg=52 # fg=#ffffff,bg=#5f0000 + ble-face -s vim_airline_c_visual_modified fg=231,bg=53 # fg=#ffffff,bg=#5f005f + ble-face -s vim_airline_z_replace fg=17,bg=45 # fg=#00005f,bg=#00dfff +} diff --git a/.local/share/blesh/contrib/airline/dark_minimal.bash b/.local/share/blesh/contrib/airline/dark_minimal.bash new file mode 100644 index 0000000..2285147 --- /dev/null +++ b/.local/share/blesh/contrib/airline/dark_minimal.bash @@ -0,0 +1,13 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/dark_minimal.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:dark_minimal/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=17,bg=190 # fg=#00005f,bg=#dfff00 + ble-face -s vim_airline_b fg=231,bg=238 # fg=#ffffff,bg=#444444 + ble-face -s vim_airline_c fg=158,bg=234 # fg=#9cffd3,bg=#202020 +} diff --git a/.local/share/blesh/contrib/airline/desertink.bash b/.local/share/blesh/contrib/airline/desertink.bash new file mode 100644 index 0000000..800132e --- /dev/null +++ b/.local/share/blesh/contrib/airline/desertink.bash @@ -0,0 +1,36 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/desertink.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Based on powerlinish +# +# Theme to mimic the default colorscheme of powerline +# Not 100% the same so it's powerline... ish. +# +# Differences from default powerline: +# * Paste indicator isn't colored different +# * Far right hand section matches the color of the mode indicator +# +# Differences from other airline themes: +# * No color differences when you're in a modified buffer +# * Visual mode only changes the mode section. Otherwise +# it appears the same as normal mode + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:desertink/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=22,bg=148 # fg=#005f00,bg=#afd700 + ble-face -s vim_airline_a_inactive fg=243,bg=239 # fg=#777777,bg=#4a4a4a + ble-face -s vim_airline_a_insert fg=231,bg=23 # fg=#ffffff,bg=#004866 + ble-face -s vim_airline_a_normal_modified fg=88,bg=208 # fg=#870000,bg=#ff8700 + ble-face -s vim_airline_a_replace fg=231,bg=167 # fg=#ffffff,bg=#d74444 + ble-face -s vim_airline_a_visual fg=232,bg=214 # fg=#080808,bg=#ffaf00 + ble-face -s vim_airline_b fg=250,bg=238 # fg=#bbbbbb,bg=#444444 + ble-face -s vim_airline_b_inactive fg=243,bg=237 # fg=#777777,bg=#3a3a3a + ble-face -s vim_airline_b_insert fg=117,bg=31 # fg=#99ddff,bg=#0087af + ble-face -s vim_airline_b_replace fg=250,bg=238 # fg=#bbbbbb,bg=#444444 + ble-face -s vim_airline_c fg=231,bg=236 # fg=#ffffff,bg=#303030 + ble-face -s vim_airline_c_inactive fg=247,bg=236 # fg=#999999,bg=#303030 + ble-face -s vim_airline_z_normal_modified fg=88,bg=208 # fg=#870000,bg=#ff8700 +} diff --git a/.local/share/blesh/contrib/airline/deus.bash b/.local/share/blesh/contrib/airline/deus.bash new file mode 100644 index 0000000..b31d295 --- /dev/null +++ b/.local/share/blesh/contrib/airline/deus.bash @@ -0,0 +1,30 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/deus.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:deus/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=17,bg=114 # fg=#282c34,bg=#98c379 + ble-face -s vim_airline_a_inactive fg=17,bg=249 # fg=#282c34,bg=#abb2bf + ble-face -s vim_airline_a_insert fg=17,bg=75 # fg=#282c34,bg=#61afef + ble-face -s vim_airline_a_replace fg=17,bg=168 # fg=#282c34,bg=#e06c75 + ble-face -s vim_airline_a_visual fg=17,bg=176 # fg=#282c34,bg=#c678dd + ble-face -s vim_airline_b fg=249,bg=238 # fg=#abb2bf,bg=#3e4452 + ble-face -s vim_airline_c fg=114,bg=17 # fg=#98c379,bg=#282c34 + ble-face -s vim_airline_c_inactive fg=249,bg=238 # fg=#abb2bf,bg=#3e4452 + ble-face -s vim_airline_c_inactive_modified fg=-1,bg=0 # fg=-1,bg=0 + ble-face -s vim_airline_c_insert fg=75,bg=17 # fg=#61afef,bg=#282c34 + ble-face -s vim_airline_c_insert_modified fg=-1,bg=0 # fg=-1,bg=0 + ble-face -s vim_airline_c_normal_modified fg=-1,bg=0 # fg=-1,bg=0 + ble-face -s vim_airline_c_replace fg=168,bg=17 # fg=#e06c75,bg=#282c34 + ble-face -s vim_airline_c_replace_modified fg=-1,bg=0 # fg=-1,bg=0 + ble-face -s vim_airline_c_visual fg=176,bg=17 # fg=#c678dd,bg=#282c34 + ble-face -s vim_airline_c_visual_modified fg=-1,bg=0 # fg=-1,bg=0 + ble-face -s vim_airline_error fg=17,bg=168 # fg=#282c34,bg=#e06c75 + ble-face -s vim_airline_error_inactive fg=16,bg=88 # fg=#000000,bg=#990000 + ble-face -s vim_airline_warning fg=17,bg=180 # fg=#282c34,bg=#e5c07b + ble-face -s vim_airline_warning_inactive fg=16,bg=166 # fg=#000000,bg=#df5f00 +} diff --git a/.local/share/blesh/contrib/airline/distinguished.bash b/.local/share/blesh/contrib/airline/distinguished.bash new file mode 100644 index 0000000..ba116e7 --- /dev/null +++ b/.local/share/blesh/contrib/airline/distinguished.bash @@ -0,0 +1,32 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/distinguished.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# vim-airline companion theme of distinguished +# (https://github.com/Lokaltog/vim-distinguished) +# I have nothing to do with the original +# distinguished theme other than being a big fan. +# this theme was shamelessly created by modifying +# the Ubaryd airline theme. + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:distinguished/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=16,bg=245 # fg=#000000,bg=#8a8a8a + ble-face -s vim_airline_a_inactive fg=238,bg=234 # fg=#444444,bg=#1c1c1c + ble-face -s vim_airline_a_insert fg=16,bg=143 # fg=#000000,bg=#afaf5f + ble-face -s vim_airline_a_normal_modified fg=0,bg=166 # fg=0,bg=#d75f00 + ble-face -s vim_airline_a_replace fg=16,bg=67 # fg=#000000,bg=#5f87af + ble-face -s vim_airline_a_visual fg=16,bg=131 # fg=#000000,bg=#af5f5f + ble-face -s vim_airline_b fg=250,bg=238 # fg=#bcbcbc,bg=#444444 + ble-face -s vim_airline_b_inactive fg=238,bg=234 # fg=#444444,bg=#1c1c1c + ble-face -s vim_airline_c fg=245,bg=234 # fg=#8a8a8a,bg=#1c1c1c + ble-face -s vim_airline_c_inactive fg=238,bg=234 # fg=#444444,bg=#1c1c1c + ble-face -s vim_airline_c_insert fg=143,bg=234 # fg=#afaf5f,bg=#1c1c1c + ble-face -s vim_airline_c_normal_modified fg=166,bg=0 # fg=#d75f00,bg=0 + ble-face -s vim_airline_c_replace fg=67,bg=234 # fg=#5f87af,bg=#1c1c1c + ble-face -s vim_airline_c_visual fg=131,bg=234 # fg=#af5f5f,bg=#1c1c1c + ble-face -s vim_airline_x_normal_modified fg=166,bg=0 # fg=#d75f00,bg=0 + ble-face -s vim_airline_z_normal_modified fg=0,bg=166 # fg=0,bg=#d75f00 +} diff --git a/.local/share/blesh/contrib/airline/durant.bash b/.local/share/blesh/contrib/airline/durant.bash new file mode 100644 index 0000000..6d341bb --- /dev/null +++ b/.local/share/blesh/contrib/airline/durant.bash @@ -0,0 +1,28 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/durant.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:durant/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=22,bg=148 # fg=#005f00,bg=#afd700 + ble-face -s vim_airline_a_inactive fg=239,bg=234 # fg=#4e4e4e,bg=#1c1c1c + ble-face -s vim_airline_a_insert fg=231,bg=29 # fg=#ffffff,bg=#00875f + ble-face -s vim_airline_a_replace fg=247,bg=124 # fg=#9e9e9e,bg=#af0000 + ble-face -s vim_airline_a_visual fg=234,bg=231 # fg=#1a1a18,bg=#ffffff + ble-face -s vim_airline_b fg=109,bg=60 # fg=#93a1a1,bg=#586e75 + ble-face -s vim_airline_b_inactive fg=239,bg=235 # fg=#4e4e4e,bg=#262626 + ble-face -s vim_airline_b_insert fg=247,bg=236 # fg=#9e9e9e,bg=#303030 + ble-face -s vim_airline_b_visual fg=231,bg=238 # fg=#ffffff,bg=#44403a + ble-face -s vim_airline_c fg=109,bg=23 # fg=#93a1a1,bg=#073642 + ble-face -s vim_airline_c_inactive fg=239,bg=236 # fg=#4e4e4e,bg=#303030 + ble-face -s vim_airline_c_inactive_modified fg=97,bg=0 # fg=#875faf,bg=0 + ble-face -s vim_airline_c_insert fg=117,bg=24 # fg=#87d7ff,bg=#005f87 + ble-face -s vim_airline_c_insert_modified fg=231,bg=53 # fg=#ffffff,bg=#5f005f + ble-face -s vim_airline_c_replace_modified fg=231,bg=53 # fg=#ffffff,bg=#5f005f + ble-face -s vim_airline_c_visual fg=108,bg=236 # fg=#90a680,bg=#2e2d2a + ble-face -s vim_airline_c_visual_modified fg=231,bg=53 # fg=#ffffff,bg=#5f005f + ble-face -s vim_airline_z_replace fg=231,bg=29 # fg=#ffffff,bg=#00875f +} diff --git a/.local/share/blesh/contrib/airline/fairyfloss.bash b/.local/share/blesh/contrib/airline/fairyfloss.bash new file mode 100644 index 0000000..b1d97fa --- /dev/null +++ b/.local/share/blesh/contrib/airline/fairyfloss.bash @@ -0,0 +1,27 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/fairyfloss.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Color palette + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:fairyfloss/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=255,bg=141 # fg=#f8f8f0,bg=#ae81ff + ble-face -s vim_airline_a_inactive fg=103,bg=238 # fg=#8076aa,bg=#49483e + ble-face -s vim_airline_a_insert fg=238,bg=121 # fg=#49483e,bg=#80ffbd + ble-face -s vim_airline_a_replace fg=197,bg=238 # fg=#f92672,bg=#49483e + ble-face -s vim_airline_a_visual fg=255,bg=197 # fg=#f8f8f0,bg=#f92672 + ble-face -s vim_airline_b fg=255,bg=238 # fg=#f8f8f0,bg=#49483e + ble-face -s vim_airline_b_inactive fg=103,bg=237 # fg=#8076aa,bg=#3b3a32 + ble-face -s vim_airline_c fg=237,bg=141 # fg=#3b3a32,bg=#ae81ff + ble-face -s vim_airline_c_inactive fg=103,bg=237 # fg=#8076aa,bg=#3b3a32 + ble-face -s vim_airline_c_inactive_modified fg=218,bg=0 # fg=#ffb8d1,bg=0 + ble-face -s vim_airline_c_insert fg=255,bg=238 # fg=#f8f8f0,bg=#49483e + ble-face -s vim_airline_c_insert_modified fg=218,bg=0 # fg=#ffb8d1,bg=0 + ble-face -s vim_airline_c_normal_modified fg=218,bg=0 # fg=#ffb8d1,bg=0 + ble-face -s vim_airline_c_replace_modified fg=218,bg=0 # fg=#ffb8d1,bg=0 + ble-face -s vim_airline_c_visual fg=255,bg=238 # fg=#f8f8f0,bg=#49483e + ble-face -s vim_airline_c_visual_modified fg=218,bg=0 # fg=#ffb8d1,bg=0 +} diff --git a/.local/share/blesh/contrib/airline/fruit_punch.bash b/.local/share/blesh/contrib/airline/fruit_punch.bash new file mode 100644 index 0000000..c21b518 --- /dev/null +++ b/.local/share/blesh/contrib/airline/fruit_punch.bash @@ -0,0 +1,28 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/fruit_punch.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Fruitpunch - A fruity airline theme! +# vim: tw=80 et sw=2 ts=2 + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:fruit_punch/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=236,bg=217 # fg=#303030,bg=#f29db4 + ble-face -s vim_airline_a_inactive fg=249,bg=238 # fg=#b2b2b2,bg=#444444 + ble-face -s vim_airline_a_insert fg=236,bg=222 # fg=#303030,bg=#fce78d + ble-face -s vim_airline_a_replace fg=236,bg=203 # fg=#303030,bg=#f97070 + ble-face -s vim_airline_a_visual fg=236,bg=116 # fg=#303030,bg=#79e5e0 + ble-face -s vim_airline_b fg=249,bg=237 # fg=#b2b2b2,bg=#3a3a3a + ble-face -s vim_airline_b_inactive fg=249,bg=238 # fg=#b2b2b2,bg=#444444 + ble-face -s vim_airline_c fg=217,bg=238 # fg=#f29db4,bg=#444444 + ble-face -s vim_airline_c_inactive fg=249,bg=238 # fg=#b2b2b2,bg=#444444 + ble-face -s vim_airline_c_insert fg=222,bg=238 # fg=#fce78d,bg=#444444 + ble-face -s vim_airline_c_normal_modified fg=222,bg=238 # fg=#fce78d,bg=#444444 + ble-face -s vim_airline_c_replace fg=203,bg=238 # fg=#f97070,bg=#444444 + ble-face -s vim_airline_c_replace_modified fg=222,bg=238 # fg=#fce78d,bg=#444444 + ble-face -s vim_airline_c_visual fg=116,bg=238 # fg=#79e5e0,bg=#444444 + ble-face -s vim_airline_c_visual_modified fg=222,bg=238 # fg=#fce78d,bg=#444444 + ble-face -s vim_airline_warning fg=236,bg=179 # fg=#303030,bg=#e8a15a +} diff --git a/.local/share/blesh/contrib/airline/google_dark.bash b/.local/share/blesh/contrib/airline/google_dark.bash new file mode 100644 index 0000000..28f66cd --- /dev/null +++ b/.local/share/blesh/contrib/airline/google_dark.bash @@ -0,0 +1,28 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/google_dark.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# vim-airline template by danrneal (http://github.com/danrneal) +# Google Scheme by Lisie Michel (https://github.com/google/vim-colorscheme-primary/) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:google_dark/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=235,bg=71 # fg=#202124,bg=#34a853 + ble-face -s vim_airline_a_inactive fg=235,bg=241 # fg=#202124,bg=#5f6368 + ble-face -s vim_airline_a_insert fg=235,bg=69 # fg=#202124,bg=#4285f4 + ble-face -s vim_airline_a_replace fg=235,bg=167 # fg=#202124,bg=#ea4335 + ble-face -s vim_airline_a_visual fg=235,bg=214 # fg=#202124,bg=#fbbc04 + ble-face -s vim_airline_b fg=189,bg=241 # fg=#e8eaed,bg=#5f6368 + ble-face -s vim_airline_c fg=71,bg=235 # fg=#34a853,bg=#202124 + ble-face -s vim_airline_c_inactive fg=241,bg=235 # fg=#5f6368,bg=#202124 + ble-face -s vim_airline_c_inactive_modified fg=231,bg=235 # fg=#ffffff,bg=#202124 + ble-face -s vim_airline_c_insert fg=69,bg=235 # fg=#4285f4,bg=#202124 + ble-face -s vim_airline_c_insert_modified fg=231,bg=235 # fg=#ffffff,bg=#202124 + ble-face -s vim_airline_c_normal_modified fg=231,bg=235 # fg=#ffffff,bg=#202124 + ble-face -s vim_airline_c_replace fg=167,bg=235 # fg=#ea4335,bg=#202124 + ble-face -s vim_airline_c_replace_modified fg=231,bg=235 # fg=#ffffff,bg=#202124 + ble-face -s vim_airline_c_visual fg=214,bg=235 # fg=#fbbc04,bg=#202124 + ble-face -s vim_airline_c_visual_modified fg=231,bg=235 # fg=#ffffff,bg=#202124 +} diff --git a/.local/share/blesh/contrib/airline/google_light.bash b/.local/share/blesh/contrib/airline/google_light.bash new file mode 100644 index 0000000..c564902 --- /dev/null +++ b/.local/share/blesh/contrib/airline/google_light.bash @@ -0,0 +1,28 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/google_light.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# vim-airline template by danrneal (http://github.com/danrneal) +# Google Scheme by Lisie Michel (https://github.com/google/vim-colorscheme-primary/) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:google_light/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=231,bg=71 # fg=#ffffff,bg=#34a853 + ble-face -s vim_airline_a_inactive fg=231,bg=189 # fg=#ffffff,bg=#e8eaed + ble-face -s vim_airline_a_insert fg=231,bg=69 # fg=#ffffff,bg=#4285f4 + ble-face -s vim_airline_a_replace fg=231,bg=167 # fg=#ffffff,bg=#ea4335 + ble-face -s vim_airline_a_visual fg=231,bg=214 # fg=#ffffff,bg=#fbbc04 + ble-face -s vim_airline_b fg=241,bg=189 # fg=#5f6368,bg=#e8eaed + ble-face -s vim_airline_c fg=71,bg=231 # fg=#34a853,bg=#ffffff + ble-face -s vim_airline_c_inactive fg=189,bg=231 # fg=#e8eaed,bg=#ffffff + ble-face -s vim_airline_c_inactive_modified fg=235,bg=231 # fg=#202124,bg=#ffffff + ble-face -s vim_airline_c_insert fg=69,bg=231 # fg=#4285f4,bg=#ffffff + ble-face -s vim_airline_c_insert_modified fg=235,bg=231 # fg=#202124,bg=#ffffff + ble-face -s vim_airline_c_normal_modified fg=235,bg=231 # fg=#202124,bg=#ffffff + ble-face -s vim_airline_c_replace fg=167,bg=231 # fg=#ea4335,bg=#ffffff + ble-face -s vim_airline_c_replace_modified fg=235,bg=231 # fg=#202124,bg=#ffffff + ble-face -s vim_airline_c_visual fg=214,bg=231 # fg=#fbbc04,bg=#ffffff + ble-face -s vim_airline_c_visual_modified fg=235,bg=231 # fg=#202124,bg=#ffffff +} diff --git a/.local/share/blesh/contrib/airline/hybrid.bash b/.local/share/blesh/contrib/airline/hybrid.bash new file mode 100644 index 0000000..3677681 --- /dev/null +++ b/.local/share/blesh/contrib/airline/hybrid.bash @@ -0,0 +1,24 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/hybrid.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# vim-airline companion theme of Hybrid +# (https://github.com/w0ng/vim-hybrid) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:hybrid/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=-1,bg=152 # fg=-1,bg=#add8e6 + ble-face -s vim_airline_a_inactive fg=-1,bg=-1 # fg=-1,bg=-1 + ble-face -s vim_airline_a_insert fg=-1,bg=196 # fg=-1,bg=#ff0000 + ble-face -s vim_airline_a_replace fg=-1,bg=213 # fg=-1,bg=#ff8bff + ble-face -s vim_airline_a_visual fg=-1,bg=195 # fg=-1,bg=#e0ffff + ble-face -s vim_airline_b fg=-1,bg=254 # fg=-1,bg=#e5e5e5 + ble-face -s vim_airline_b_inactive fg=-1,bg=-1 # fg=-1,bg=-1 + ble-face -s vim_airline_c fg=-1,bg=213 # fg=-1,bg=#ff8bff + ble-face -s vim_airline_c_inactive fg=-1,bg=-1 # fg=-1,bg=-1 + ble-face -s vim_airline_warning fg=-1,bg=-1 # fg=-1,bg=-1 + ble-face -s vim_airline_warning_inactive fg=16,bg=166 # fg=#000000,bg=#df5f00 + ble-face -s vim_airline_warning_inactive_modified fg=-1,bg=-1 # fg=-1,bg=-1 +} diff --git a/.local/share/blesh/contrib/airline/hybridline.bash b/.local/share/blesh/contrib/airline/hybridline.bash new file mode 100644 index 0000000..3fd4656 --- /dev/null +++ b/.local/share/blesh/contrib/airline/hybridline.bash @@ -0,0 +1,29 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/hybridline.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# vim-airline theme based on vim-hybrid and powerline +# (https://github.com/w0ng/vim-hybrid) +# (https://github.com/Lokaltog/powerline) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:hybridline/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=22,bg=143 # fg=#005f00,bg=#b5bd68 + ble-face -s vim_airline_a_inactive fg=239,bg=234 # fg=#4e4e4e,bg=#1c1c1c + ble-face -s vim_airline_a_insert fg=23,bg=109 # fg=#005f5f,bg=#8abeb7 + ble-face -s vim_airline_a_replace fg=16,bg=167 # fg=#000000,bg=#cc6666 + ble-face -s vim_airline_a_visual fg=16,bg=173 # fg=#000000,bg=#de935f + ble-face -s vim_airline_b fg=251,bg=237 # fg=#c5c8c6,bg=#373b41 + ble-face -s vim_airline_b_inactive fg=239,bg=235 # fg=#4e4e4e,bg=#262626 + ble-face -s vim_airline_b_insert fg=251,bg=31 # fg=#c5c8c6,bg=#0087af + ble-face -s vim_airline_b_replace fg=251,bg=237 # fg=#c5c8c6,bg=#373b41 + ble-face -s vim_airline_c fg=231,bg=236 # fg=#ffffff,bg=#282a2e + ble-face -s vim_airline_c_inactive fg=239,bg=236 # fg=#4e4e4e,bg=#303030 + ble-face -s vim_airline_c_insert fg=231,bg=24 # fg=#ffffff,bg=#005f87 + ble-face -s vim_airline_c_replace fg=231,bg=236 # fg=#ffffff,bg=#282a2e + ble-face -s vim_airline_z_normal fg=236,bg=251 # fg=#282a2e,bg=#c5c8c6 + ble-face -s vim_airline_z_replace fg=236,bg=251 # fg=#282a2e,bg=#c5c8c6 + ble-face -s vim_airline_z_visual fg=236,bg=251 # fg=#282a2e,bg=#c5c8c6 +} diff --git a/.local/share/blesh/contrib/airline/jellybeans.bash b/.local/share/blesh/contrib/airline/jellybeans.bash new file mode 100644 index 0000000..3964ef6 --- /dev/null +++ b/.local/share/blesh/contrib/airline/jellybeans.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/jellybeans.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Color palette + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:jellybeans/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=254,bg=25 # fg=#d8dee9,bg=#0d61ac + ble-face -s vim_airline_a_inactive fg=241,bg=235 # fg=#666666,bg=#262626 + ble-face -s vim_airline_a_insert fg=231,bg=58 # fg=#ffffff,bg=#437019 + ble-face -s vim_airline_a_replace fg=88,bg=233 # fg=#870000,bg=#151515 + ble-face -s vim_airline_a_visual fg=231,bg=88 # fg=#ffffff,bg=#870000 + ble-face -s vim_airline_b fg=231,bg=235 # fg=#ffffff,bg=#262626 + ble-face -s vim_airline_b_inactive fg=240,bg=233 # fg=#4f5b66,bg=#151515 + ble-face -s vim_airline_c fg=240,bg=233 # fg=#4f5b66,bg=#151515 + ble-face -s vim_airline_c_inactive_modified fg=215,bg=0 # fg=#ffb964,bg=0 + ble-face -s vim_airline_c_insert fg=231,bg=233 # fg=#ffffff,bg=#151515 + ble-face -s vim_airline_c_insert_modified fg=215,bg=0 # fg=#ffb964,bg=0 + ble-face -s vim_airline_c_normal_modified fg=215,bg=0 # fg=#ffb964,bg=0 + ble-face -s vim_airline_c_replace_modified fg=215,bg=0 # fg=#ffb964,bg=0 + ble-face -s vim_airline_c_visual fg=231,bg=233 # fg=#ffffff,bg=#151515 + ble-face -s vim_airline_c_visual_modified fg=215,bg=0 # fg=#ffb964,bg=0 +} diff --git a/.local/share/blesh/contrib/airline/jet.bash b/.local/share/blesh/contrib/airline/jet.bash new file mode 100644 index 0000000..81c72ec --- /dev/null +++ b/.local/share/blesh/contrib/airline/jet.bash @@ -0,0 +1,24 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/jet.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +#Originally based on Jellybeans theme. +# Modified to resemble the orclord colorscheme. + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:jet/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=254,bg=25 # fg=#d8dee9,bg=#0d61ac + ble-face -s vim_airline_a_inactive fg=233,bg=235 # fg=#151515,bg=#262626 + ble-face -s vim_airline_a_insert fg=231,bg=58 # fg=#ffffff,bg=#437019 + ble-face -s vim_airline_a_replace fg=88,bg=235 # fg=#870000,bg=#262626 + ble-face -s vim_airline_a_visual fg=231,bg=88 # fg=#ffffff,bg=#870000 + ble-face -s vim_airline_b fg=231,bg=235 # fg=#ffffff,bg=#262626 + ble-face -s vim_airline_b_inactive fg=240,bg=233 # fg=#4f5b66,bg=#151515 + ble-face -s vim_airline_b_insert fg=240,bg=235 # fg=#4f5b66,bg=#262626 + ble-face -s vim_airline_b_visual fg=240,bg=235 # fg=#4f5b66,bg=#262626 + ble-face -s vim_airline_c fg=240,bg=233 # fg=#4f5b66,bg=#151515 + ble-face -s vim_airline_c_insert fg=231,bg=235 # fg=#ffffff,bg=#262626 + ble-face -s vim_airline_c_visual fg=231,bg=235 # fg=#ffffff,bg=#262626 +} diff --git a/.local/share/blesh/contrib/airline/kalisi.bash b/.local/share/blesh/contrib/airline/kalisi.bash new file mode 100644 index 0000000..d9fd1e4 --- /dev/null +++ b/.local/share/blesh/contrib/airline/kalisi.bash @@ -0,0 +1,29 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/kalisi.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# +# Colorscheme: Kalisi for airline. Inspired by powerline. +# Arthur Jaron +# hifreeo@gmail.com +# 24.10.2014 + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:kalisi/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=22,bg=148 # fg=#005f00,bg=#afd700 + ble-face -s vim_airline_a_inactive fg=-1,bg=-1 # fg=-1,bg=-1 + ble-face -s vim_airline_a_insert fg=231,bg=160 # fg=#ffffff,bg=#e80000 + ble-face -s vim_airline_a_replace fg=171,bg=231 # fg=#d75fff,bg=#ffffff + ble-face -s vim_airline_a_visual fg=33,bg=231 # fg=#0087ff,bg=#ffffff + ble-face -s vim_airline_b fg=148,bg=22 # fg=#afd700,bg=#005f00 + ble-face -s vim_airline_b_inactive fg=-1,bg=-1 # fg=-1,bg=-1 + ble-face -s vim_airline_b_insert fg=196,bg=52 # fg=#ff0000,bg=#5f0000 + ble-face -s vim_airline_b_replace fg=53,bg=171 # fg=#5f005f,bg=#d75fff + ble-face -s vim_airline_b_visual fg=25,bg=75 # fg=#005faf,bg=#5fafff + ble-face -s vim_airline_c fg=-1,bg=-1 # fg=-1,bg=-1 + ble-face -s vim_airline_c_inactive_modified fg=190,bg=-1 # fg=#d7ff00,bg=-1 + ble-face -s vim_airline_c_replace fg=213,bg=91 # fg=#ff87ff,bg=#8700af + ble-face -s vim_airline_c_visual fg=117,bg=25 # fg=#87d7ff,bg=#005faf +} diff --git a/.local/share/blesh/contrib/airline/kolor.bash b/.local/share/blesh/contrib/airline/kolor.bash new file mode 100644 index 0000000..d9ff025 --- /dev/null +++ b/.local/share/blesh/contrib/airline/kolor.bash @@ -0,0 +1,27 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/kolor.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:kolor/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=254,bg=60 # fg=#e2e2e2,bg=#4f3598 + ble-face -s vim_airline_a_inactive fg=249,bg=239 # fg=#b2b2b2,bg=#4a4a4a + ble-face -s vim_airline_a_insert fg=235,bg=111 # fg=#242322,bg=#7eaefd + ble-face -s vim_airline_a_replace fg=116,bg=23 # fg=#75d7d8,bg=#005154 + ble-face -s vim_airline_a_visual fg=235,bg=174 # fg=#242322,bg=#e6987a + ble-face -s vim_airline_b fg=206,bg=235 # fg=#ff5fd7,bg=#242322 + ble-face -s vim_airline_b_inactive fg=249,bg=239 # fg=#b2b2b2,bg=#4a4a4a + ble-face -s vim_airline_b_insert fg=116,bg=235 # fg=#75d7d8,bg=#242322 + ble-face -s vim_airline_b_visual fg=185,bg=235 # fg=#dbc570,bg=#242322 + ble-face -s vim_airline_c fg=254,bg=239 # fg=#e2e2e2,bg=#4a4a4a + ble-face -s vim_airline_c_inactive fg=249,bg=239 # fg=#b2b2b2,bg=#4a4a4a + ble-face -s vim_airline_c_inactive_modified fg=97,bg=0 # fg=#875faf,bg=0 + ble-face -s vim_airline_c_insert_modified fg=235,bg=111 # fg=#242322,bg=#7eaefd + ble-face -s vim_airline_c_normal_modified fg=254,bg=60 # fg=#e2e2e2,bg=#4f3598 + ble-face -s vim_airline_c_replace_modified fg=254,bg=23 # fg=#e2e2e2,bg=#005154 + ble-face -s vim_airline_c_visual_modified fg=235,bg=174 # fg=#242322,bg=#e6987a + ble-face -s vim_airline_z_replace fg=235,bg=111 # fg=#242322,bg=#7eaefd +} diff --git a/.local/share/blesh/contrib/airline/laederon.bash b/.local/share/blesh/contrib/airline/laederon.bash new file mode 100644 index 0000000..1998473 --- /dev/null +++ b/.local/share/blesh/contrib/airline/laederon.bash @@ -0,0 +1,43 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/laederon.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# vim-airline companion theme of Laederon +# (https://github.com/Donearm/Laederon) +# +# Author: Gianluca fiore +# Version: 1.12 +# License: MIT + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:laederon/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=18,bg=255 # fg=#081c8c,bg=#f8f6f2 + ble-face -s vim_airline_a_inactive fg=255,bg=236 # fg=#f8f6f2,bg=#2e2d2a + ble-face -s vim_airline_a_insert fg=255,bg=131 # fg=#f8f6f2,bg=#ab3e5b + ble-face -s vim_airline_a_insert_modified fg=255,bg=31 # fg=#f8f6f2,bg=#1693a5 + ble-face -s vim_airline_a_normal_modified fg=18,bg=18 # fg=#081c8c,bg=#081c8c + ble-face -s vim_airline_a_replace fg=108,bg=255 # fg=#90a680,bg=#f8f6f2 + ble-face -s vim_airline_a_replace_modified fg=108,bg=108 # fg=#90a680,bg=#90a680 + ble-face -s vim_airline_a_visual fg=22,bg=255 # fg=#005f00,bg=#f8f6f2 + ble-face -s vim_airline_a_visual_modified fg=22,bg=58 # fg=#005f00,bg=#594512 + ble-face -s vim_airline_b fg=31,bg=255 # fg=#1693a5,bg=#f8f6f2 + ble-face -s vim_airline_b_inactive fg=255,bg=236 # fg=#f8f6f2,bg=#2e2d2a + ble-face -s vim_airline_b_insert fg=235,bg=131 # fg=#242321,bg=#ab3e5b + ble-face -s vim_airline_b_insert_modified fg=31,bg=235 # fg=#1693a5,bg=#242321 + ble-face -s vim_airline_b_normal_modified fg=18,bg=235 # fg=#081c8c,bg=#242321 + ble-face -s vim_airline_b_replace fg=108,bg=235 # fg=#90a680,bg=#242321 + ble-face -s vim_airline_b_visual fg=255,bg=22 # fg=#f8f6f2,bg=#005f00 + ble-face -s vim_airline_b_visual_modified fg=58,bg=235 # fg=#594512,bg=#242321 + ble-face -s vim_airline_c fg=108,bg=236 # fg=#90a680,bg=#2e2d2a + ble-face -s vim_airline_c_inactive fg=255,bg=236 # fg=#f8f6f2,bg=#2e2d2a + ble-face -s vim_airline_c_inactive_modified fg=18,bg=0 # fg=#081c8c,bg=0 + ble-face -s vim_airline_c_insert fg=31,bg=255 # fg=#1693a5,bg=#f8f6f2 + ble-face -s vim_airline_c_insert_modified fg=31,bg=236 # fg=#1693a5,bg=#2e2d2a + ble-face -s vim_airline_c_normal_modified fg=18,bg=236 # fg=#081c8c,bg=#2e2d2a + ble-face -s vim_airline_c_replace fg=255,bg=108 # fg=#f8f6f2,bg=#90a680 + ble-face -s vim_airline_c_replace_modified fg=108,bg=236 # fg=#90a680,bg=#2e2d2a + ble-face -s vim_airline_c_visual fg=58,bg=255 # fg=#594512,bg=#f8f6f2 + ble-face -s vim_airline_c_visual_modified fg=58,bg=236 # fg=#594512,bg=#2e2d2a +} diff --git a/.local/share/blesh/contrib/airline/landscape.bash b/.local/share/blesh/contrib/airline/landscape.bash new file mode 100644 index 0000000..d3154ac --- /dev/null +++ b/.local/share/blesh/contrib/airline/landscape.bash @@ -0,0 +1,34 @@ +# From github:itchyny/landscape.vim/autoload/airline/themes/landscape.vim +# The MIT License (MIT) +# Copyright (c) 2012-2015 itchyny. +# + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:landscape/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=21,bg=231 # fg=#0000ff,bg=#ffffff + ble-face -s vim_airline_a_inactive fg=236,bg=233 # fg=#303030,bg=#121212 + ble-face -s vim_airline_a_insert fg=22,bg=231 # fg=#005f00,bg=#ffffff + ble-face -s vim_airline_a_replace fg=124,bg=231 # fg=#af0000,bg=#ffffff + ble-face -s vim_airline_a_visual fg=57,bg=231 # fg=#5f00ff,bg=#ffffff + ble-face -s vim_airline_b fg=231,bg=21 # fg=#ffffff,bg=#0000ff + ble-face -s vim_airline_b_inactive fg=236,bg=233 # fg=#303030,bg=#121212 + ble-face -s vim_airline_b_insert fg=231,bg=22 # fg=#ffffff,bg=#005f00 + ble-face -s vim_airline_b_replace fg=231,bg=124 # fg=#ffffff,bg=#af0000 + ble-face -s vim_airline_b_visual fg=231,bg=57 # fg=#ffffff,bg=#5f00ff + ble-face -s vim_airline_c fg=231,bg=236 # fg=#ffffff,bg=#303030 + ble-face -s vim_airline_c_inactive fg=236,bg=233 # fg=#303030,bg=#121212 + ble-face -s vim_airline_x_insert fg=250,bg=240 # fg=#bcbcbc,bg=#585858 + ble-face -s vim_airline_x_normal fg=250,bg=240 # fg=#bcbcbc,bg=#585858 + ble-face -s vim_airline_x_replace fg=250,bg=240 # fg=#bcbcbc,bg=#585858 + ble-face -s vim_airline_x_visual fg=250,bg=240 # fg=#bcbcbc,bg=#585858 + ble-face -s vim_airline_y_insert fg=236,bg=245 # fg=#303030,bg=#8a8a8a + ble-face -s vim_airline_y_normal fg=236,bg=245 # fg=#303030,bg=#8a8a8a + ble-face -s vim_airline_y_replace fg=236,bg=245 # fg=#303030,bg=#8a8a8a + ble-face -s vim_airline_y_visual fg=236,bg=245 # fg=#303030,bg=#8a8a8a + ble-face -s vim_airline_z_insert fg=236,bg=252 # fg=#303030,bg=#d0d0d0 + ble-face -s vim_airline_z_normal fg=236,bg=252 # fg=#303030,bg=#d0d0d0 + ble-face -s vim_airline_z_replace fg=236,bg=252 # fg=#303030,bg=#d0d0d0 + ble-face -s vim_airline_z_visual fg=236,bg=252 # fg=#303030,bg=#d0d0d0 +} diff --git a/.local/share/blesh/contrib/airline/lessnoise.bash b/.local/share/blesh/contrib/airline/lessnoise.bash new file mode 100644 index 0000000..64a7864 --- /dev/null +++ b/.local/share/blesh/contrib/airline/lessnoise.bash @@ -0,0 +1,41 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/lessnoise.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# vim: et:ts=2:sts:sw=2 +# Author: @bekcpear +# https://gist.github.com/bekcpear/41fb86e0817dfb6620b757daf1e2aab0 + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:lessnoise/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=233,bg=159 # fg=#121212,bg=#afffff + ble-face -s vim_airline_a_inactive fg=242,bg=236 # fg=#6c6c6c,bg=#303030 + ble-face -s vim_airline_a_insert fg=233,bg=218 # fg=#121212,bg=#ffafd7 + ble-face -s vim_airline_a_replace fg=233,bg=203 # fg=#121212,bg=#ff5f5f + ble-face -s vim_airline_a_visual fg=233,bg=229 # fg=#121212,bg=#ffffaf + ble-face -s vim_airline_b fg=255,bg=236 # fg=#eeeeee,bg=#303030 + ble-face -s vim_airline_b_commandline fg=159,bg=159 # fg=#afffff,bg=#afffff + ble-face -s vim_airline_b_inactive fg=242,bg=236 # fg=#6c6c6c,bg=#303030 + ble-face -s vim_airline_c fg=247,bg=236 # fg=#9e9e9e,bg=#303030 + ble-face -s vim_airline_c_commandline fg=233,bg=159 # fg=#121212,bg=#afffff + ble-face -s vim_airline_c_inactive fg=242,bg=236 # fg=#6c6c6c,bg=#303030 + ble-face -s vim_airline_c_inactive_modified fg=249,bg=236 # fg=#b2b2b2,bg=#303030 + ble-face -s vim_airline_c_insert_modified fg=249,bg=236 # fg=#b2b2b2,bg=#303030 + ble-face -s vim_airline_c_normal_modified fg=249,bg=236 # fg=#b2b2b2,bg=#303030 + ble-face -s vim_airline_c_replace_modified fg=249,bg=236 # fg=#b2b2b2,bg=#303030 + ble-face -s vim_airline_c_visual_modified fg=249,bg=236 # fg=#b2b2b2,bg=#303030 + ble-face -s vim_airline_x_insert fg=242,bg=236 # fg=#6c6c6c,bg=#303030 + ble-face -s vim_airline_x_normal fg=242,bg=236 # fg=#6c6c6c,bg=#303030 + ble-face -s vim_airline_x_replace fg=242,bg=236 # fg=#6c6c6c,bg=#303030 + ble-face -s vim_airline_x_visual fg=242,bg=236 # fg=#6c6c6c,bg=#303030 + ble-face -s vim_airline_y_inactive fg=236,bg=236 # fg=#303030,bg=#303030 + ble-face -s vim_airline_y_insert fg=236,bg=236 # fg=#303030,bg=#303030 + ble-face -s vim_airline_y_normal fg=236,bg=236 # fg=#303030,bg=#303030 + ble-face -s vim_airline_y_replace fg=236,bg=236 # fg=#303030,bg=#303030 + ble-face -s vim_airline_y_visual fg=236,bg=236 # fg=#303030,bg=#303030 + ble-face -s vim_airline_z_insert fg=242,bg=236 # fg=#6c6c6c,bg=#303030 + ble-face -s vim_airline_z_normal fg=242,bg=236 # fg=#6c6c6c,bg=#303030 + ble-face -s vim_airline_z_replace fg=242,bg=236 # fg=#6c6c6c,bg=#303030 +} diff --git a/.local/share/blesh/contrib/airline/light.bash b/.local/share/blesh/contrib/airline/light.bash new file mode 100644 index 0000000..3031b89 --- /dev/null +++ b/.local/share/blesh/contrib/airline/light.bash @@ -0,0 +1,34 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/light.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:light/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=231,bg=27 # fg=#ffffff,bg=#005fff + ble-face -s vim_airline_a_inactive fg=241,bg=249 # fg=#666666,bg=#b2b2b2 + ble-face -s vim_airline_a_insert fg=231,bg=29 # fg=#ffffff,bg=#00875f + ble-face -s vim_airline_a_replace fg=22,bg=196 # fg=#005f00,bg=#ff0000 + ble-face -s vim_airline_a_visual fg=231,bg=202 # fg=#ffffff,bg=#ff5f00 + ble-face -s vim_airline_b fg=18,bg=45 # fg=#000087,bg=#00dfff + ble-face -s vim_airline_b_inactive fg=245,bg=252 # fg=#8a8a8a,bg=#d0d0d0 + ble-face -s vim_airline_b_insert fg=22,bg=42 # fg=#005f00,bg=#00df87 + ble-face -s vim_airline_b_visual fg=52,bg=214 # fg=#5f0000,bg=#ffaf00 + ble-face -s vim_airline_c fg=27,bg=159 # fg=#005fff,bg=#afffff + ble-face -s vim_airline_c_inactive fg=248,bg=231 # fg=#a8a8a8,bg=#ffffff + ble-face -s vim_airline_c_inactive_modified fg=160,bg=0 # fg=#df0000,bg=0 + ble-face -s vim_airline_c_insert fg=23,bg=156 # fg=#005f5f,bg=#afff87 + ble-face -s vim_airline_c_insert_modified fg=160,bg=224 # fg=#df0000,bg=#ffdfdf + ble-face -s vim_airline_c_normal_modified fg=160,bg=224 # fg=#df0000,bg=#ffdfdf + ble-face -s vim_airline_c_replace_modified fg=160,bg=224 # fg=#df0000,bg=#ffdfdf + ble-face -s vim_airline_c_visual fg=166,bg=228 # fg=#df5f00,bg=#ffff87 + ble-face -s vim_airline_c_visual_modified fg=160,bg=224 # fg=#df0000,bg=#ffdfdf + ble-face -s vim_airline_term fg=27,bg=159 # fg=#005fff,bg=#afffff + ble-face -s vim_airline_term_inactive fg=158,bg=234 # fg=#9cffd3,bg=#202020 + ble-face -s vim_airline_term_insert fg=158,bg=234 # fg=#9cffd3,bg=#202020 + ble-face -s vim_airline_term_normal_modified fg=160,bg=224 # fg=#df0000,bg=#ffdfdf + ble-face -s vim_airline_term_visual fg=158,bg=234 # fg=#9cffd3,bg=#202020 + ble-face -s vim_airline_z_replace fg=231,bg=29 # fg=#ffffff,bg=#00875f +} diff --git a/.local/share/blesh/contrib/airline/lighthaus.bash b/.local/share/blesh/contrib/airline/lighthaus.bash new file mode 100644 index 0000000..66c38ea --- /dev/null +++ b/.local/share/blesh/contrib/airline/lighthaus.bash @@ -0,0 +1,30 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/lighthaus.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Lighthaus Color theme for Vim Airline +# GIT: https://github.com/lighthaus-theme/vim +# Author: Adhiraj Sirohi (https://github.com/brutuski) +# Vasundhara Sharma (https://github.com/vasundhasauras) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:lighthaus/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=235,bg=37 # fg=#21252d,bg=#00bfa4 + ble-face -s vim_airline_a_inactive fg=252,bg=235 # fg=#cccccc,bg=#21252d + ble-face -s vim_airline_a_insert fg=235,bg=71 # fg=#21252d,bg=#50c16e + ble-face -s vim_airline_a_replace fg=235,bg=203 # fg=#21252d,bg=#ff5050 + ble-face -s vim_airline_a_visual fg=235,bg=202 # fg=#21252d,bg=#ed722e + ble-face -s vim_airline_b fg=230,bg=233 # fg=#fffade,bg=#090b26 + ble-face -s vim_airline_b_inactive fg=252,bg=235 # fg=#cccccc,bg=#21252d + ble-face -s vim_airline_c fg=37,bg=235 # fg=#00bfa4,bg=#21252d + ble-face -s vim_airline_c_inactive fg=252,bg=235 # fg=#cccccc,bg=#21252d + ble-face -s vim_airline_c_insert fg=71,bg=235 # fg=#50c16e,bg=#21252d + ble-face -s vim_airline_c_insert_modified fg=166,bg=235 # fg=#e25600,bg=#21252d + ble-face -s vim_airline_c_normal_modified fg=175,bg=235 # fg=#d68eb2,bg=#21252d + ble-face -s vim_airline_c_replace fg=203,bg=235 # fg=#ff5050,bg=#21252d + ble-face -s vim_airline_c_replace_modified fg=226,bg=235 # fg=#ffff00,bg=#21252d + ble-face -s vim_airline_c_visual fg=202,bg=235 # fg=#ed722e,bg=#21252d + ble-face -s vim_airline_c_visual_modified fg=202,bg=235 # fg=#ff4d00,bg=#21252d +} diff --git a/.local/share/blesh/contrib/airline/lucius.bash b/.local/share/blesh/contrib/airline/lucius.bash new file mode 100644 index 0000000..1abaf5c --- /dev/null +++ b/.local/share/blesh/contrib/airline/lucius.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/lucius.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:lucius/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=-1,bg=-1 # fg=-1,bg=-1 + ble-face -s vim_airline_a_insert fg=-1,bg=152 # fg=-1,bg=#add8e6 + ble-face -s vim_airline_a_replace fg=-1,bg=213 # fg=-1,bg=#ff8bff + ble-face -s vim_airline_b fg=18,bg=252 # fg=#00008b,bg=#d3d3d3 + ble-face -s vim_airline_b_inactive fg=-1,bg=-1 # fg=-1,bg=-1 + ble-face -s vim_airline_c fg=-1,bg=254 # fg=-1,bg=#e5e5e5 + ble-face -s vim_airline_c_inactive fg=-1,bg=-1 # fg=-1,bg=-1 + ble-face -s vim_airline_c_inactive_modified fg=124,bg=0 # fg=#a52a2a,bg=0 + ble-face -s vim_airline_c_insert_modified fg=124,bg=0 # fg=#a52a2a,bg=0 + ble-face -s vim_airline_c_normal_modified fg=124,bg=0 # fg=#a52a2a,bg=0 + ble-face -s vim_airline_c_replace_modified fg=124,bg=0 # fg=#a52a2a,bg=0 + ble-face -s vim_airline_c_visual_modified fg=124,bg=0 # fg=#a52a2a,bg=0 + ble-face -s vim_airline_error fg=21,bg=195 # fg=#0000ff,bg=#e0ffff + ble-face -s vim_airline_error_inactive fg=16,bg=88 # fg=#000000,bg=#990000 + ble-face -s vim_airline_warning fg=-1,bg=213 # fg=-1,bg=#ff8bff + ble-face -s vim_airline_warning_inactive fg=16,bg=166 # fg=#000000,bg=#df5f00 +} diff --git a/.local/share/blesh/contrib/airline/luna.bash b/.local/share/blesh/contrib/airline/luna.bash new file mode 100644 index 0000000..e12e9d2 --- /dev/null +++ b/.local/share/blesh/contrib/airline/luna.bash @@ -0,0 +1,29 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/luna.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# vim-airline companion theme of Luna +# (https://github.com/Pychimp/vim-luna) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:luna/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=231,bg=23 # fg=#ffffff,bg=#005252 + ble-face -s vim_airline_a_inactive fg=239,bg=234 # fg=#4e4e4e,bg=#002b2b + ble-face -s vim_airline_a_insert fg=231,bg=106 # fg=#ffffff,bg=#789f00 + ble-face -s vim_airline_a_replace fg=231,bg=88 # fg=#ffffff,bg=#920000 + ble-face -s vim_airline_a_visual fg=228,bg=209 # fg=#ffff9a,bg=#ff8036 + ble-face -s vim_airline_b fg=231,bg=23 # fg=#ffffff,bg=#003f3f + ble-face -s vim_airline_b_inactive fg=239,bg=234 # fg=#4e4e4e,bg=#002b2b + ble-face -s vim_airline_c fg=231,bg=234 # fg=#ffffff,bg=#002b2b + ble-face -s vim_airline_c_inactive fg=239,bg=234 # fg=#4e4e4e,bg=#002b2b + ble-face -s vim_airline_c_inactive_modified fg=160,bg=0 # fg=#e20000,bg=0 + ble-face -s vim_airline_c_insert_modified fg=231,bg=23 # fg=#ffffff,bg=#005e5e + ble-face -s vim_airline_c_normal_modified fg=231,bg=52 # fg=#ffffff,bg=#450000 + ble-face -s vim_airline_c_replace_modified fg=231,bg=23 # fg=#ffffff,bg=#005e5e + ble-face -s vim_airline_c_visual_modified fg=231,bg=52 # fg=#ffffff,bg=#450000 + ble-face -s vim_airline_warning fg=231,bg=52 # fg=#ffffff,bg=#5f0000 + ble-face -s vim_airline_warning_inactive fg=16,bg=166 # fg=#000000,bg=#df5f00 + ble-face -s vim_airline_z_replace fg=231,bg=106 # fg=#ffffff,bg=#789f00 +} diff --git a/.local/share/blesh/contrib/airline/minimalist.bash b/.local/share/blesh/contrib/airline/minimalist.bash new file mode 100644 index 0000000..22d6bf3 --- /dev/null +++ b/.local/share/blesh/contrib/airline/minimalist.bash @@ -0,0 +1,28 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/minimalist.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Minimalist Airline - A Material Color Scheme +# +# Author: Diki Ananta +# Repository: https://github.com/dikiaap/minimalist +# Version: 2.0 +# License: MIT + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:minimalist/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=239,bg=249 # fg=#4d4d4d,bg=#b3b3b3 + ble-face -s vim_airline_a_inactive fg=235,bg=252 # fg=#262626,bg=#cccccc + ble-face -s vim_airline_b fg=236,bg=247 # fg=#333333,bg=#999999 + ble-face -s vim_airline_b_inactive fg=235,bg=252 # fg=#262626,bg=#cccccc + ble-face -s vim_airline_c fg=236,bg=252 # fg=#333333,bg=#cccccc + ble-face -s vim_airline_c_inactive fg=235,bg=252 # fg=#262626,bg=#cccccc + ble-face -s vim_airline_error fg=234,bg=167 # fg=#1c1c1c,bg=#d75f5f + ble-face -s vim_airline_error_inactive fg=16,bg=88 # fg=#000000,bg=#990000 + ble-face -s vim_airline_term fg=234,bg=249 # fg=#1c1c1c,bg=#b3b3b3 + ble-face -s vim_airline_term_inactive fg=158,bg=234 # fg=#9cffd3,bg=#202020 + ble-face -s vim_airline_warning fg=234,bg=215 # fg=#1c1c1c,bg=#ffaf5f + ble-face -s vim_airline_warning_inactive fg=16,bg=166 # fg=#000000,bg=#df5f00 +} diff --git a/.local/share/blesh/contrib/airline/molokai.bash b/.local/share/blesh/contrib/airline/molokai.bash new file mode 100644 index 0000000..fa67e1e --- /dev/null +++ b/.local/share/blesh/contrib/airline/molokai.bash @@ -0,0 +1,24 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/molokai.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:molokai/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=232,bg=186 # fg=#080808,bg=#e6db74 + ble-face -s vim_airline_a_inactive fg=234,bg=239 # fg=#1b1d1e,bg=#465457 + ble-face -s vim_airline_a_insert fg=232,bg=81 # fg=#080808,bg=#66d9ef + ble-face -s vim_airline_a_replace fg=232,bg=197 # fg=#080808,bg=#f92672 + ble-face -s vim_airline_a_visual fg=232,bg=148 # fg=#080808,bg=#a6e22e + ble-face -s vim_airline_b fg=255,bg=235 # fg=#f8f8f0,bg=#232526 + ble-face -s vim_airline_b_inactive fg=234,bg=239 # fg=#1b1d1e,bg=#465457 + ble-face -s vim_airline_c fg=255,bg=239 # fg=#f8f8f0,bg=#465457 + ble-face -s vim_airline_c_inactive fg=234,bg=239 # fg=#1b1d1e,bg=#465457 + ble-face -s vim_airline_c_inactive_modified fg=255,bg=0 # fg=#f8f8f0,bg=0 + ble-face -s vim_airline_c_insert_modified fg=232,bg=81 # fg=#080808,bg=#66d9ef + ble-face -s vim_airline_c_normal_modified fg=232,bg=186 # fg=#080808,bg=#e6db74 + ble-face -s vim_airline_c_replace_modified fg=232,bg=197 # fg=#080808,bg=#f92672 + ble-face -s vim_airline_c_visual_modified fg=232,bg=148 # fg=#080808,bg=#a6e22e +} diff --git a/.local/share/blesh/contrib/airline/monochrome.bash b/.local/share/blesh/contrib/airline/monochrome.bash new file mode 100644 index 0000000..4fe3b99 --- /dev/null +++ b/.local/share/blesh/contrib/airline/monochrome.bash @@ -0,0 +1,19 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/monochrome.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:monochrome/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=-1,bg=-1 # fg=-1,bg=-1 + ble-face -s vim_airline_b fg=-1,bg=-1 # fg=-1,bg=-1 + ble-face -s vim_airline_c fg=-1,bg=-1 # fg=-1,bg=-1 + ble-face -s vim_airline_error fg=-1,bg=-1 # fg=-1,bg=-1 + ble-face -s vim_airline_error_inactive fg=16,bg=88 # fg=#000000,bg=#990000 + ble-face -s vim_airline_term fg=-1,bg=-1 # fg=-1,bg=-1 + ble-face -s vim_airline_term_inactive fg=158,bg=234 # fg=#9cffd3,bg=#202020 + ble-face -s vim_airline_warning fg=-1,bg=-1 # fg=-1,bg=-1 + ble-face -s vim_airline_warning_inactive fg=16,bg=166 # fg=#000000,bg=#df5f00 +} diff --git a/.local/share/blesh/contrib/airline/murmur.bash b/.local/share/blesh/contrib/airline/murmur.bash new file mode 100644 index 0000000..27ab9e2 --- /dev/null +++ b/.local/share/blesh/contrib/airline/murmur.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/murmur.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:murmur/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=231,bg=69 # fg=#ffffff,bg=#5f87ff + ble-face -s vim_airline_a_inactive fg=239,bg=234 # fg=#4e4e4e,bg=#1c1c1c + ble-face -s vim_airline_a_insert fg=231,bg=107 # fg=#ffffff,bg=#87af5f + ble-face -s vim_airline_a_replace fg=231,bg=88 # fg=#ffffff,bg=#870000 + ble-face -s vim_airline_a_visual fg=231,bg=208 # fg=#ffffff,bg=#ff8c00 + ble-face -s vim_airline_b fg=144,bg=62 # fg=#afaf87,bg=#5f5f5f + ble-face -s vim_airline_b_inactive fg=239,bg=234 # fg=#4e4e4e,bg=#1c1c1c + ble-face -s vim_airline_c fg=255,bg=234 # fg=#f5f5f5,bg=#1c1c1c + ble-face -s vim_airline_c_inactive fg=239,bg=234 # fg=#4e4e4e,bg=#1c1c1c + ble-face -s vim_airline_c_insert fg=107,bg=234 # fg=#87af5f,bg=#1c1c1c + ble-face -s vim_airline_c_insert_modified fg=88,bg=234 # fg=#870000,bg=#1c1c1c + ble-face -s vim_airline_c_normal_modified fg=88,bg=234 # fg=#870000,bg=#1c1c1c + ble-face -s vim_airline_c_replace fg=144,bg=234 # fg=#afaf87,bg=#1c1c1c + ble-face -s vim_airline_c_replace_modified fg=88,bg=234 # fg=#870000,bg=#1c1c1c + ble-face -s vim_airline_c_visual fg=208,bg=234 # fg=#ff8c00,bg=#1c1c1c + ble-face -s vim_airline_c_visual_modified fg=88,bg=234 # fg=#870000,bg=#1c1c1c +} diff --git a/.local/share/blesh/contrib/airline/night_owl.bash b/.local/share/blesh/contrib/airline/night_owl.bash new file mode 100644 index 0000000..4121593 --- /dev/null +++ b/.local/share/blesh/contrib/airline/night_owl.bash @@ -0,0 +1,27 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/night_owl.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Port/inspired from https://github.com/sdras/night-owl-vscode-theme +# Jared Ramirez + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:night_owl/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=17,bg=116 # fg=#282c34,bg=#83dcc8 + ble-face -s vim_airline_a_inactive fg=17,bg=176 # fg=#282c34,bg=#c792ea + ble-face -s vim_airline_a_insert fg=17,bg=149 # fg=#282c34,bg=#afd75f + ble-face -s vim_airline_a_replace fg=17,bg=222 # fg=#282c34,bg=#ffd787 + ble-face -s vim_airline_a_visual fg=17,bg=111 # fg=#282c34,bg=#81aaff + ble-face -s vim_airline_b fg=17,bg=73 # fg=#282c34,bg=#68b0a0 + ble-face -s vim_airline_b_inactive fg=176,bg=17 # fg=#c792ea,bg=#282c34 + ble-face -s vim_airline_b_insert fg=17,bg=107 # fg=#282c34,bg=#8cac4c + ble-face -s vim_airline_b_replace fg=17,bg=179 # fg=#282c34,bg=#ccac6c + ble-face -s vim_airline_b_visual fg=17,bg=68 # fg=#282c34,bg=#6788cc + ble-face -s vim_airline_c fg=116,bg=17 # fg=#83dcc8,bg=#282c34 + ble-face -s vim_airline_c_inactive fg=176,bg=17 # fg=#c792ea,bg=#282c34 + ble-face -s vim_airline_c_insert fg=149,bg=17 # fg=#afd75f,bg=#282c34 + ble-face -s vim_airline_c_replace fg=222,bg=17 # fg=#ffd787,bg=#282c34 + ble-face -s vim_airline_c_visual fg=111,bg=17 # fg=#81aaff,bg=#282c34 +} diff --git a/.local/share/blesh/contrib/airline/nord_minimal.bash b/.local/share/blesh/contrib/airline/nord_minimal.bash new file mode 100644 index 0000000..25144cc --- /dev/null +++ b/.local/share/blesh/contrib/airline/nord_minimal.bash @@ -0,0 +1,13 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/nord_minimal.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:nord_minimal/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=109,bg=239 # fg=#81a1c1,bg=#434c5e + ble-face -s vim_airline_b fg=109,bg=239 # fg=#81a1c1,bg=#434c5e + ble-face -s vim_airline_c fg=109,bg=239 # fg=#81a1c1,bg=#434c5e +} diff --git a/.local/share/blesh/contrib/airline/onedark.bash b/.local/share/blesh/contrib/airline/onedark.bash new file mode 100644 index 0000000..1bd9550 --- /dev/null +++ b/.local/share/blesh/contrib/airline/onedark.bash @@ -0,0 +1,38 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/onedark.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# [onedark.vim](https://github.com/joshdick/onedark.vim/) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:onedark/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=17,bg=114 # fg=#282c34,bg=#98c379 + ble-face -s vim_airline_a_inactive fg=17,bg=249 # fg=#282c34,bg=#abb2bf + ble-face -s vim_airline_a_insert fg=17,bg=75 # fg=#282c34,bg=#61afef + ble-face -s vim_airline_a_replace fg=17,bg=168 # fg=#282c34,bg=#e06c75 + ble-face -s vim_airline_a_visual fg=17,bg=176 # fg=#282c34,bg=#c678dd + ble-face -s vim_airline_b fg=249,bg=238 # fg=#abb2bf,bg=#3e4452 + ble-face -s vim_airline_c fg=114,bg=17 # fg=#98c379,bg=#282c34 + ble-face -s vim_airline_c_inactive fg=249,bg=238 # fg=#abb2bf,bg=#3e4452 + ble-face -s vim_airline_c_inactive_modified fg=-1,bg=0 # fg=-1,bg=0 + ble-face -s vim_airline_c_insert fg=75,bg=17 # fg=#61afef,bg=#282c34 + ble-face -s vim_airline_c_insert_modified fg=-1,bg=0 # fg=-1,bg=0 + ble-face -s vim_airline_c_normal_modified fg=-1,bg=0 # fg=-1,bg=0 + ble-face -s vim_airline_c_replace fg=168,bg=17 # fg=#e06c75,bg=#282c34 + ble-face -s vim_airline_c_replace_modified fg=-1,bg=0 # fg=-1,bg=0 + ble-face -s vim_airline_c_visual fg=176,bg=17 # fg=#c678dd,bg=#282c34 + ble-face -s vim_airline_c_visual_modified fg=-1,bg=0 # fg=-1,bg=0 + ble-face -s vim_airline_error fg=17,bg=168 # fg=#282c34,bg=#e06c75 + ble-face -s vim_airline_error_inactive fg=16,bg=88 # fg=#000000,bg=#990000 + ble-face -s vim_airline_term fg=114,bg=17 # fg=#98c379,bg=#282c34 + ble-face -s vim_airline_term_inactive fg=249,bg=238 # fg=#abb2bf,bg=#3e4452 + ble-face -s vim_airline_term_insert fg=158,bg=234 # fg=#9cffd3,bg=#202020 + ble-face -s vim_airline_term_insert_modified fg=176,bg=17 # fg=#c678dd,bg=#282c34 + ble-face -s vim_airline_term_normal_modified fg=176,bg=17 # fg=#c678dd,bg=#282c34 + ble-face -s vim_airline_term_replace_modified fg=176,bg=17 # fg=#c678dd,bg=#282c34 + ble-face -s vim_airline_term_visual fg=176,bg=17 # fg=#c678dd,bg=#282c34 + ble-face -s vim_airline_warning fg=17,bg=180 # fg=#282c34,bg=#e5c07b + ble-face -s vim_airline_warning_inactive fg=16,bg=166 # fg=#000000,bg=#df5f00 +} diff --git a/.local/share/blesh/contrib/airline/ouo.bash b/.local/share/blesh/contrib/airline/ouo.bash new file mode 100644 index 0000000..94ab30c --- /dev/null +++ b/.local/share/blesh/contrib/airline/ouo.bash @@ -0,0 +1,37 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/ouo.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Author: Huang Po-Hsuan +# Filename: ouo.vim +# Last Modified: 2018-10-21 19:59:41 +# Vim: enc=utf-8 + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:ouo/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=231,bg=27 # fg=#ffffff,bg=#005fff + ble-face -s vim_airline_a_inactive fg=239,bg=234 # fg=#4e4e4e,bg=#1c1c1c + ble-face -s vim_airline_a_insert fg=231,bg=70 # fg=#ffffff,bg=#5faf00 + ble-face -s vim_airline_a_replace fg=231,bg=160 # fg=#ffffff,bg=#d70000 + ble-face -s vim_airline_a_visual fg=231,bg=166 # fg=#ffffff,bg=#d75f00 + ble-face -s vim_airline_b fg=144,bg=237 # fg=#afaf87,bg=#3a3a3a + ble-face -s vim_airline_b_inactive fg=239,bg=234 # fg=#4e4e4e,bg=#1c1c1c + ble-face -s vim_airline_c fg=39,bg=234 # fg=#00afff,bg=#1c1c1c + ble-face -s vim_airline_c_inactive fg=239,bg=234 # fg=#4e4e4e,bg=#1c1c1c + ble-face -s vim_airline_c_inactive_modified fg=124,bg=234 # fg=#af0000,bg=#1c1c1c + ble-face -s vim_airline_c_insert fg=70,bg=234 # fg=#5faf00,bg=#1c1c1c + ble-face -s vim_airline_c_insert_modified fg=124,bg=234 # fg=#af0000,bg=#1c1c1c + ble-face -s vim_airline_c_normal_modified fg=124,bg=234 # fg=#af0000,bg=#1c1c1c + ble-face -s vim_airline_c_replace fg=144,bg=234 # fg=#afaf87,bg=#1c1c1c + ble-face -s vim_airline_c_replace_modified fg=124,bg=234 # fg=#af0000,bg=#1c1c1c + ble-face -s vim_airline_c_visual fg=166,bg=234 # fg=#d75f00,bg=#1c1c1c + ble-face -s vim_airline_c_visual_modified fg=124,bg=234 # fg=#af0000,bg=#1c1c1c + ble-face -s vim_airline_error fg=231,bg=160 # fg=#ffffff,bg=#d70000 + ble-face -s vim_airline_error_inactive fg=239,bg=234 # fg=#4e4e4e,bg=#1c1c1c + ble-face -s vim_airline_error_inactive_modified fg=231,bg=160 # fg=#ffffff,bg=#d70000 + ble-face -s vim_airline_warning fg=231,bg=166 # fg=#ffffff,bg=#d75f00 + ble-face -s vim_airline_warning_inactive fg=239,bg=234 # fg=#4e4e4e,bg=#1c1c1c + ble-face -s vim_airline_warning_inactive_modified fg=231,bg=166 # fg=#ffffff,bg=#d75f00 +} diff --git a/.local/share/blesh/contrib/airline/owo.bash b/.local/share/blesh/contrib/airline/owo.bash new file mode 100644 index 0000000..c14e85d --- /dev/null +++ b/.local/share/blesh/contrib/airline/owo.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/owo.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:owo/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=236,bg=117 # fg=#303030,bg=#87d7ff + ble-face -s vim_airline_a_inactive fg=249,bg=238 # fg=#b2b2b2,bg=#444444 + ble-face -s vim_airline_a_insert fg=238,bg=110 # fg=#444444,bg=#87afd7 + ble-face -s vim_airline_a_replace fg=236,bg=105 # fg=#303030,bg=#8787ff + ble-face -s vim_airline_a_visual fg=236,bg=114 # fg=#303030,bg=#87d787 + ble-face -s vim_airline_b fg=249,bg=237 # fg=#b2b2b2,bg=#3a3a3a + ble-face -s vim_airline_b_inactive fg=249,bg=238 # fg=#b2b2b2,bg=#444444 + ble-face -s vim_airline_c fg=117,bg=238 # fg=#87d7ff,bg=#444444 + ble-face -s vim_airline_c_inactive fg=249,bg=238 # fg=#b2b2b2,bg=#444444 + ble-face -s vim_airline_c_inactive_modified fg=110,bg=238 # fg=#87afd7,bg=#444444 + ble-face -s vim_airline_c_insert fg=110,bg=238 # fg=#87afd7,bg=#444444 + ble-face -s vim_airline_c_normal_modified fg=110,bg=238 # fg=#87afd7,bg=#444444 + ble-face -s vim_airline_c_replace fg=105,bg=238 # fg=#8787ff,bg=#444444 + ble-face -s vim_airline_c_replace_modified fg=110,bg=238 # fg=#87afd7,bg=#444444 + ble-face -s vim_airline_c_visual fg=114,bg=238 # fg=#87d787,bg=#444444 + ble-face -s vim_airline_c_visual_modified fg=110,bg=238 # fg=#87afd7,bg=#444444 +} diff --git a/.local/share/blesh/contrib/airline/papercolor.bash b/.local/share/blesh/contrib/airline/papercolor.bash new file mode 100644 index 0000000..952557d --- /dev/null +++ b/.local/share/blesh/contrib/airline/papercolor.bash @@ -0,0 +1,22 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/papercolor.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:papercolor/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=240,bg=254 # fg=#585858,bg=#e4e4e4 + ble-face -s vim_airline_a_replace fg=161,bg=254 # fg=#d7005f,bg=#e4e4e4 + ble-face -s vim_airline_a_visual fg=24,bg=254 # fg=#005f87,bg=#e4e4e4 + ble-face -s vim_airline_b fg=254,bg=31 # fg=#e4e4e4,bg=#0087af + ble-face -s vim_airline_b_inactive fg=240,bg=254 # fg=#585858,bg=#e4e4e4 + ble-face -s vim_airline_b_visual fg=0,bg=31 # fg=0,bg=#0087af + ble-face -s vim_airline_c fg=255,bg=24 # fg=#eeeeee,bg=#005f87 + ble-face -s vim_airline_c_inactive fg=254,bg=31 # fg=#e4e4e4,bg=#0087af + ble-face -s vim_airline_c_inactive_modified fg=240,bg=254 # fg=#585858,bg=#e4e4e4 + ble-face -s vim_airline_c_visual fg=254,bg=24 # fg=#e4e4e4,bg=#005f87 + ble-face -s vim_airline_x_inactive fg=240,bg=254 # fg=#585858,bg=#e4e4e4 + ble-face -s vim_airline_z_replace fg=240,bg=254 # fg=#585858,bg=#e4e4e4 +} diff --git a/.local/share/blesh/contrib/airline/peaksea.bash b/.local/share/blesh/contrib/airline/peaksea.bash new file mode 100644 index 0000000..ea29a05 --- /dev/null +++ b/.local/share/blesh/contrib/airline/peaksea.bash @@ -0,0 +1,30 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/peaksea.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# peaksea Airline theme +# +# Author: Jonathan Dion +# Version: 1.0 +# License: MIT + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:peaksea/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=237,bg=153 # fg=#3a3a3a,bg=#c0d8f8 + ble-face -s vim_airline_a_inactive fg=241,bg=235 # fg=#666666,bg=#262626 + ble-face -s vim_airline_a_insert fg=237,bg=84 # fg=#3a3a3a,bg=#60f080 + ble-face -s vim_airline_a_replace fg=237,bg=186 # fg=#3a3a3a,bg=#d0d090 + ble-face -s vim_airline_a_visual fg=237,bg=219 # fg=#3a3a3a,bg=#f0c0f0 + ble-face -s vim_airline_b fg=254,bg=239 # fg=#e4e4e4,bg=#4e4e4e + ble-face -s vim_airline_b_inactive fg=241,bg=235 # fg=#666666,bg=#262626 + ble-face -s vim_airline_c fg=255,bg=235 # fg=#eeeeee,bg=#262626 + ble-face -s vim_airline_c_inactive fg=241,bg=235 # fg=#666666,bg=#262626 + ble-face -s vim_airline_error fg=234,bg=167 # fg=#1c1c1c,bg=167 + ble-face -s vim_airline_error_inactive fg=16,bg=88 # fg=#000000,bg=#990000 + ble-face -s vim_airline_term fg=234,bg=237 # fg=#1c1c1c,bg=#3a3a3a + ble-face -s vim_airline_term_inactive fg=158,bg=234 # fg=#9cffd3,bg=#202020 + ble-face -s vim_airline_warning fg=234,bg=179 # fg=#1c1c1c,bg=#e0c060 + ble-face -s vim_airline_warning_inactive fg=16,bg=166 # fg=#000000,bg=#df5f00 +} diff --git a/.local/share/blesh/contrib/airline/powerlineish.bash b/.local/share/blesh/contrib/airline/powerlineish.bash new file mode 100644 index 0000000..da65ab9 --- /dev/null +++ b/.local/share/blesh/contrib/airline/powerlineish.bash @@ -0,0 +1,34 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/powerlineish.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Theme to mimic the default colorscheme of powerline +# Not 100% the same so it's powerline... ish. +# +# Differences from default powerline: +# * Paste indicator isn't colored different +# * Far right hand section matches the color of the mode indicator +# +# Differences from other airline themes: +# * No color differences when you're in a modified buffer +# * Visual mode only changes the mode section. Otherwise +# it appears the same as normal mode + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:powerlineish/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=22,bg=148 # fg=#005f00,bg=#afd700 + ble-face -s vim_airline_a_inactive fg=247,bg=233 # fg=#9e9e9e,bg=#121212 + ble-face -s vim_airline_a_insert fg=23,bg=231 # fg=#005f5f,bg=#ffffff + ble-face -s vim_airline_a_replace fg=231,bg=160 # fg=#ffffff,bg=#d70000 + ble-face -s vim_airline_a_visual fg=232,bg=214 # fg=#080808,bg=#ffaf00 + ble-face -s vim_airline_b fg=247,bg=236 # fg=#9e9e9e,bg=#303030 + ble-face -s vim_airline_b_inactive fg=247,bg=233 # fg=#9e9e9e,bg=#121212 + ble-face -s vim_airline_b_insert fg=74,bg=31 # fg=#5fafd7,bg=#0087af + ble-face -s vim_airline_b_replace fg=247,bg=236 # fg=#9e9e9e,bg=#303030 + ble-face -s vim_airline_c fg=231,bg=233 # fg=#ffffff,bg=#121212 + ble-face -s vim_airline_c_inactive fg=247,bg=233 # fg=#9e9e9e,bg=#121212 + ble-face -s vim_airline_c_insert fg=117,bg=24 # fg=#87d7ff,bg=#005f87 + ble-face -s vim_airline_c_replace fg=231,bg=233 # fg=#ffffff,bg=#121212 +} diff --git a/.local/share/blesh/contrib/airline/qwq.bash b/.local/share/blesh/contrib/airline/qwq.bash new file mode 100644 index 0000000..93d21fc --- /dev/null +++ b/.local/share/blesh/contrib/airline/qwq.bash @@ -0,0 +1,30 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/qwq.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# github: https://github.com/LuciusChen + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:qwq/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=23,bg=230 # fg=#0e3b4f,bg=#ffeee5 + ble-face -s vim_airline_a_inactive fg=23,bg=231 # fg=#0e3b4f,bg=#fefcf9 + ble-face -s vim_airline_a_insert fg=23,bg=230 # fg=#0e3b4f,bg=#fff5d9 + ble-face -s vim_airline_a_replace fg=23,bg=158 # fg=#0e3b4f,bg=#c1f9cd + ble-face -s vim_airline_b fg=23,bg=224 # fg=#0e3b4f,bg=#ffd3cb + ble-face -s vim_airline_b_inactive fg=23,bg=187 # fg=#0e3b4f,bg=#ddc6af + ble-face -s vim_airline_b_insert fg=23,bg=186 # fg=#0e3b4f,bg=#dde58e + ble-face -s vim_airline_b_replace fg=23,bg=122 # fg=#0e3b4f,bg=#8befc7 + ble-face -s vim_airline_b_visual fg=23,bg=217 # fg=#0e3b4f,bg=#ff9da5 + ble-face -s vim_airline_c fg=231,bg=209 # fg=#ffffff,bg=#f7846e + ble-face -s vim_airline_c_inactive fg=231,bg=138 # fg=#ffffff,bg=#a28e79 + ble-face -s vim_airline_c_inactive_modified fg=231,bg=0 # fg=#ffffff,bg=0 + ble-face -s vim_airline_c_insert fg=231,bg=150 # fg=#ffffff,bg=#9ed47b + ble-face -s vim_airline_c_insert_modified fg=231,bg=71 # fg=#ffffff,bg=#6bad3f + ble-face -s vim_airline_c_normal_modified fg=231,bg=203 # fg=#ffffff,bg=#ff5d4f + ble-face -s vim_airline_c_replace fg=231,bg=38 # fg=#ffffff,bg=#04bec3 + ble-face -s vim_airline_c_replace_modified fg=231,bg=30 # fg=#ffffff,bg=#008492 + ble-face -s vim_airline_c_visual fg=231,bg=203 # fg=#ffffff,bg=#ff5b6f + ble-face -s vim_airline_c_visual_modified fg=231,bg=197 # fg=#ffffff,bg=#ff003f +} diff --git a/.local/share/blesh/contrib/airline/raven.bash b/.local/share/blesh/contrib/airline/raven.bash new file mode 100644 index 0000000..e9c373e --- /dev/null +++ b/.local/share/blesh/contrib/airline/raven.bash @@ -0,0 +1,30 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/raven.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:raven/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=251,bg=236 # fg=#c8c8c8,bg=#2e2e2e + ble-face -s vim_airline_a_inactive fg=61,bg=235 # fg=#5e5e5e,bg=#222222 + ble-face -s vim_airline_a_insert fg=36,bg=236 # fg=#11c279,bg=#2e2e2e + ble-face -s vim_airline_a_replace fg=160,bg=236 # fg=#e60000,bg=#2e2e2e + ble-face -s vim_airline_a_visual fg=63,bg=236 # fg=#6565ff,bg=#2e2e2e + ble-face -s vim_airline_b fg=251,bg=236 # fg=#c8c8c8,bg=#2e2e2e + ble-face -s vim_airline_b_inactive fg=61,bg=235 # fg=#5e5e5e,bg=#222222 + ble-face -s vim_airline_b_insert fg=36,bg=236 # fg=#11c279,bg=#2e2e2e + ble-face -s vim_airline_b_visual fg=63,bg=236 # fg=#6565ff,bg=#2e2e2e + ble-face -s vim_airline_c fg=251,bg=236 # fg=#c8c8c8,bg=#2e2e2e + ble-face -s vim_airline_c_inactive fg=61,bg=235 # fg=#5e5e5e,bg=#222222 + ble-face -s vim_airline_c_inactive_modified fg=166,bg=0 # fg=#e25000,bg=0 + ble-face -s vim_airline_c_insert fg=36,bg=236 # fg=#11c279,bg=#2e2e2e + ble-face -s vim_airline_c_insert_modified fg=166,bg=236 # fg=#e25000,bg=#2e2e2e + ble-face -s vim_airline_c_normal_modified fg=166,bg=236 # fg=#e25000,bg=#2e2e2e + ble-face -s vim_airline_c_replace_modified fg=166,bg=236 # fg=#e25000,bg=#2e2e2e + ble-face -s vim_airline_c_visual fg=63,bg=236 # fg=#6565ff,bg=#2e2e2e + ble-face -s vim_airline_c_visual_modified fg=166,bg=236 # fg=#e25000,bg=#2e2e2e + ble-face -s vim_airline_warning fg=196,bg=236 # fg=#ff0000,bg=#2e2e2e + ble-face -s vim_airline_warning_inactive fg=16,bg=166 # fg=#000000,bg=#df5f00 +} diff --git a/.local/share/blesh/contrib/airline/ravenpower.bash b/.local/share/blesh/contrib/airline/ravenpower.bash new file mode 100644 index 0000000..48505ad --- /dev/null +++ b/.local/share/blesh/contrib/airline/ravenpower.bash @@ -0,0 +1,22 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/ravenpower.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Pretty much powerlineish clone, and some +# of the hex colours was borrowed from raven + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:ravenpower/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=22,bg=234 # fg=#005f00,bg=#1d1f21 + ble-face -s vim_airline_a_inactive fg=236,bg=236 # fg=#303030,bg=#2e2e2e + ble-face -s vim_airline_a_insert fg=117,bg=234 # fg=#87d7ff,bg=#1d1f21 + ble-face -s vim_airline_a_replace fg=231,bg=160 # fg=#ffffff,bg=#d70000 + ble-face -s vim_airline_a_visual fg=232,bg=214 # fg=#080808,bg=#ffaf00 + ble-face -s vim_airline_b fg=247,bg=236 # fg=#9e9e9e,bg=#303030 + ble-face -s vim_airline_b_inactive fg=236,bg=236 # fg=#303030,bg=#2e2e2e + ble-face -s vim_airline_c fg=251,bg=236 # fg=#c8c8c8,bg=#2e2e2e + ble-face -s vim_airline_c_inactive fg=236,bg=236 # fg=#303030,bg=#2e2e2e + ble-face -s vim_airline_z_replace fg=22,bg=234 # fg=#005f00,bg=#1d1f21 +} diff --git a/.local/share/blesh/contrib/airline/seagull.bash b/.local/share/blesh/contrib/airline/seagull.bash new file mode 100644 index 0000000..6a334a8 --- /dev/null +++ b/.local/share/blesh/contrib/airline/seagull.bash @@ -0,0 +1,36 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/seagull.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Airline theme for Seabird/Seagull: +# https://github.com/nightsense/seabird/blob/master/colors/seagull.vim +# +# Based on Solarized theme code: +# https://github.com/vim-airline/vim-airline-themes/blob/master/autoload/airline/themes/solarized.vim + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:seagull/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=189,bg=66 # fg=#e6eaed,bg=#6d767d + ble-face -s vim_airline_a_inactive fg=189,bg=244 # fg=#e6eaed,bg=#787e82 + ble-face -s vim_airline_a_insert fg=189,bg=37 # fg=#e6eaed,bg=#00a5ab + ble-face -s vim_airline_a_replace fg=189,bg=203 # fg=#e6eaed,bg=#ff4053 + ble-face -s vim_airline_a_visual fg=189,bg=34 # fg=#e6eaed,bg=#11ab00 + ble-face -s vim_airline_b fg=189,bg=102 # fg=#e6eaed,bg=#808487 + ble-face -s vim_airline_b_inactive fg=189,bg=244 # fg=#e6eaed,bg=#787e82 + ble-face -s vim_airline_c fg=102,bg=189 # fg=#808487,bg=#e6eaed + ble-face -s vim_airline_c_inactive fg=189,bg=244 # fg=#e6eaed,bg=#787e82 + ble-face -s vim_airline_c_inactive_modified fg=235,bg=0 # fg=#1d252b,bg=0 + ble-face -s vim_airline_c_insert_modified fg=60,bg=189 # fg=#61707a,bg=#e6eaed + ble-face -s vim_airline_c_normal_modified fg=60,bg=189 # fg=#61707a,bg=#e6eaed + ble-face -s vim_airline_c_replace_modified fg=60,bg=189 # fg=#61707a,bg=#e6eaed + ble-face -s vim_airline_c_visual_modified fg=60,bg=189 # fg=#61707a,bg=#e6eaed + ble-face -s vim_airline_error fg=231,bg=202 # fg=#ffffff,bg=#ff6200 + ble-face -s vim_airline_error_inactive fg=16,bg=88 # fg=#000000,bg=#990000 + ble-face -s vim_airline_error_insert fg=16,bg=88 # fg=#000000,bg=#990000 + ble-face -s vim_airline_error_normal_modified fg=16,bg=88 # fg=#000000,bg=#990000 + ble-face -s vim_airline_error_visual fg=16,bg=88 # fg=#000000,bg=#990000 + ble-face -s vim_airline_warning fg=231,bg=202 # fg=#ffffff,bg=#ff6200 + ble-face -s vim_airline_warning_inactive fg=16,bg=166 # fg=#000000,bg=#df5f00 +} diff --git a/.local/share/blesh/contrib/airline/selenized.bash b/.local/share/blesh/contrib/airline/selenized.bash new file mode 100644 index 0000000..c34b1e9 --- /dev/null +++ b/.local/share/blesh/contrib/airline/selenized.bash @@ -0,0 +1,30 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/selenized.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# MIT License. Copyright (c) 2021 novenary +# vim: et ts=2 sts=2 sw=2 tw=80 + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:selenized/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=254,bg=64 # fg=#e9e4d0,bg=#489100 + ble-face -s vim_airline_a_inactive fg=246,bg=187 # fg=#909995,bg=#cfcebe + ble-face -s vim_airline_a_insert fg=254,bg=26 # fg=#e9e4d0,bg=#0072d4 + ble-face -s vim_airline_a_replace fg=254,bg=160 # fg=#e9e4d0,bg=#d2212d + ble-face -s vim_airline_a_visual fg=254,bg=98 # fg=#e9e4d0,bg=#8762c6 + ble-face -s vim_airline_b fg=241,bg=187 # fg=#53676d,bg=#cfcebe + ble-face -s vim_airline_b_inactive fg=246,bg=187 # fg=#909995,bg=#cfcebe + ble-face -s vim_airline_c fg=246,bg=254 # fg=#909995,bg=#e9e4d0 + ble-face -s vim_airline_c_inactive fg=246,bg=187 # fg=#909995,bg=#cfcebe + ble-face -s vim_airline_c_inactive_modified fg=136,bg=187 # fg=#ad8900,bg=#cfcebe + ble-face -s vim_airline_c_insert_modified fg=136,bg=254 # fg=#ad8900,bg=#e9e4d0 + ble-face -s vim_airline_c_normal_modified fg=136,bg=254 # fg=#ad8900,bg=#e9e4d0 + ble-face -s vim_airline_c_replace_modified fg=136,bg=254 # fg=#ad8900,bg=#e9e4d0 + ble-face -s vim_airline_c_visual_modified fg=136,bg=254 # fg=#ad8900,bg=#e9e4d0 + ble-face -s vim_airline_error fg=254,bg=160 # fg=#e9e4d0,bg=#cc1729 + ble-face -s vim_airline_error_inactive fg=16,bg=88 # fg=#000000,bg=#990000 + ble-face -s vim_airline_warning fg=254,bg=136 # fg=#e9e4d0,bg=#a78300 + ble-face -s vim_airline_warning_inactive fg=16,bg=166 # fg=#000000,bg=#df5f00 +} diff --git a/.local/share/blesh/contrib/airline/selenized_bw.bash b/.local/share/blesh/contrib/airline/selenized_bw.bash new file mode 100644 index 0000000..f5e95f4 --- /dev/null +++ b/.local/share/blesh/contrib/airline/selenized_bw.bash @@ -0,0 +1,30 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/selenized_bw.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# MIT License. Copyright (c) 2021 novenary +# vim: et ts=2 sts=2 sw=2 tw=80 + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:selenized_bw/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=255,bg=28 # fg=#ebebeb,bg=#1d9700 + ble-face -s vim_airline_a_inactive fg=105,bg=252 # fg=#878787,bg=#cdcdcd + ble-face -s vim_airline_a_insert fg=255,bg=26 # fg=#ebebeb,bg=#0064e4 + ble-face -s vim_airline_a_replace fg=255,bg=160 # fg=#ebebeb,bg=#d6000c + ble-face -s vim_airline_a_visual fg=255,bg=98 # fg=#ebebeb,bg=#7f51d6 + ble-face -s vim_airline_b fg=238,bg=252 # fg=#474747,bg=#cdcdcd + ble-face -s vim_airline_b_inactive fg=105,bg=252 # fg=#878787,bg=#cdcdcd + ble-face -s vim_airline_c fg=105,bg=255 # fg=#878787,bg=#ebebeb + ble-face -s vim_airline_c_inactive fg=105,bg=252 # fg=#878787,bg=#cdcdcd + ble-face -s vim_airline_c_inactive_modified fg=172,bg=252 # fg=#c49700,bg=#cdcdcd + ble-face -s vim_airline_c_insert_modified fg=172,bg=255 # fg=#c49700,bg=#ebebeb + ble-face -s vim_airline_c_normal_modified fg=172,bg=255 # fg=#c49700,bg=#ebebeb + ble-face -s vim_airline_c_replace_modified fg=172,bg=255 # fg=#c49700,bg=#ebebeb + ble-face -s vim_airline_c_visual_modified fg=172,bg=255 # fg=#c49700,bg=#ebebeb + ble-face -s vim_airline_error fg=255,bg=124 # fg=#ebebeb,bg=#bf0000 + ble-face -s vim_airline_error_inactive fg=16,bg=88 # fg=#000000,bg=#990000 + ble-face -s vim_airline_warning fg=255,bg=136 # fg=#ebebeb,bg=#af8500 + ble-face -s vim_airline_warning_inactive fg=16,bg=166 # fg=#000000,bg=#df5f00 +} diff --git a/.local/share/blesh/contrib/airline/seoul256.bash b/.local/share/blesh/contrib/airline/seoul256.bash new file mode 100644 index 0000000..10a16f8 --- /dev/null +++ b/.local/share/blesh/contrib/airline/seoul256.bash @@ -0,0 +1,28 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/seoul256.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Created by JB Kopecky (https://github.com/jbkopecky), based on seoul256 themed +# by Junegunn Choi (https://github.com/junegunn/seoul256.vim) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:seoul256/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=-1,bg=-1 # fg=-1,bg=-1 + ble-face -s vim_airline_a_inactive fg=-1,bg=254 # fg=-1,bg=#e5e5e5 + ble-face -s vim_airline_a_replace fg=-1,bg=29 # fg=-1,bg=#2e8b57 + ble-face -s vim_airline_a_visual fg=-1,bg=196 # fg=-1,bg=#ff0000 + ble-face -s vim_airline_b fg=-1,bg=-1 # fg=-1,bg=-1 + ble-face -s vim_airline_b_inactive fg=-1,bg=254 # fg=-1,bg=#e5e5e5 + ble-face -s vim_airline_c fg=-1,bg=254 # fg=-1,bg=#e5e5e5 + ble-face -s vim_airline_c_inactive_modified fg=62,bg=0 # fg=#6a5acd,bg=0 + ble-face -s vim_airline_c_insert fg=-1,bg=-1 # fg=-1,bg=-1 + ble-face -s vim_airline_c_insert_modified fg=62,bg=0 # fg=#6a5acd,bg=0 + ble-face -s vim_airline_c_normal_modified fg=62,bg=0 # fg=#6a5acd,bg=0 + ble-face -s vim_airline_c_replace_modified fg=62,bg=0 # fg=#6a5acd,bg=0 + ble-face -s vim_airline_c_visual fg=-1,bg=-1 # fg=-1,bg=-1 + ble-face -s vim_airline_c_visual_modified fg=-1,bg=0 # fg=-1,bg=0 + ble-face -s vim_airline_warning fg=136,bg=255 # fg=#af8500,bg=#ebebeb + ble-face -s vim_airline_warning_inactive fg=16,bg=166 # fg=#000000,bg=#df5f00 +} diff --git a/.local/share/blesh/contrib/airline/serene.bash b/.local/share/blesh/contrib/airline/serene.bash new file mode 100644 index 0000000..2c27cf9 --- /dev/null +++ b/.local/share/blesh/contrib/airline/serene.bash @@ -0,0 +1,24 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/serene.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:serene/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=45,bg=232 # fg=#00dfff,bg=#080808 + ble-face -s vim_airline_a_inactive fg=239,bg=232 # fg=#4e4e4e,bg=#080808 + ble-face -s vim_airline_a_insert fg=82,bg=232 # fg=#5fff00,bg=#080808 + ble-face -s vim_airline_a_replace fg=82,bg=124 # fg=#5fff00,bg=#af0000 + ble-face -s vim_airline_a_visual fg=184,bg=232 # fg=#dfdf00,bg=#080808 + ble-face -s vim_airline_b fg=202,bg=232 # fg=#ff5f00,bg=#080808 + ble-face -s vim_airline_b_inactive fg=239,bg=236 # fg=#4e4e4e,bg=#303030 + ble-face -s vim_airline_c fg=243,bg=232 # fg=#767676,bg=#080808 + ble-face -s vim_airline_c_inactive fg=239,bg=236 # fg=#4e4e4e,bg=#303030 + ble-face -s vim_airline_c_inactive_modified fg=160,bg=232 # fg=#df0000,bg=#080808 + ble-face -s vim_airline_c_insert_modified fg=160,bg=232 # fg=#df0000,bg=#080808 + ble-face -s vim_airline_c_normal_modified fg=160,bg=232 # fg=#df0000,bg=#080808 + ble-face -s vim_airline_c_replace_modified fg=160,bg=232 # fg=#df0000,bg=#080808 + ble-face -s vim_airline_c_visual_modified fg=160,bg=232 # fg=#df0000,bg=#080808 +} diff --git a/.local/share/blesh/contrib/airline/sierra.bash b/.local/share/blesh/contrib/airline/sierra.bash new file mode 100644 index 0000000..3f70966 --- /dev/null +++ b/.local/share/blesh/contrib/airline/sierra.bash @@ -0,0 +1,30 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/sierra.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# File: sierra.vim +# Author: Danilo Augusto +# Date: 2017-02-26 +# License: MIT + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:sierra/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=231,bg=180 # fg=#ffffff,bg=#dfaf87 + ble-face -s vim_airline_a_inactive fg=241,bg=131 # fg=#666666,bg=#af5f5f + ble-face -s vim_airline_a_insert fg=231,bg=152 # fg=#ffffff,bg=#afd7d7 + ble-face -s vim_airline_a_replace fg=242,bg=236 # fg=#686868,bg=#303030 + ble-face -s vim_airline_a_visual fg=231,bg=242 # fg=#ffffff,bg=#686868 + ble-face -s vim_airline_b fg=231,bg=131 # fg=#ffffff,bg=#af5f5f + ble-face -s vim_airline_b_inactive fg=167,bg=235 # fg=#d75f5f,bg=#2a2a2a + ble-face -s vim_airline_c fg=167,bg=240 # fg=#d75f5f,bg=#545454 + ble-face -s vim_airline_c_inactive fg=167,bg=235 # fg=#d75f5f,bg=#2a2a2a + ble-face -s vim_airline_c_inactive_modified fg=223,bg=0 # fg=#f7e4c0,bg=0 + ble-face -s vim_airline_c_insert fg=231,bg=131 # fg=#ffffff,bg=#af5f5f + ble-face -s vim_airline_c_insert_modified fg=223,bg=0 # fg=#f7e4c0,bg=0 + ble-face -s vim_airline_c_normal_modified fg=223,bg=0 # fg=#f7e4c0,bg=0 + ble-face -s vim_airline_c_replace_modified fg=223,bg=0 # fg=#f7e4c0,bg=0 + ble-face -s vim_airline_c_visual fg=231,bg=131 # fg=#ffffff,bg=#af5f5f + ble-face -s vim_airline_c_visual_modified fg=223,bg=0 # fg=#f7e4c0,bg=0 +} diff --git a/.local/share/blesh/contrib/airline/silver.bash b/.local/share/blesh/contrib/airline/silver.bash new file mode 100644 index 0000000..3aa6450 --- /dev/null +++ b/.local/share/blesh/contrib/airline/silver.bash @@ -0,0 +1,30 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/silver.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:silver/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=238,bg=254 # fg=#414141,bg=#e1e1e1 + ble-face -s vim_airline_a_inactive fg=247,bg=253 # fg=#a1a1a1,bg=#dddddd + ble-face -s vim_airline_a_insert fg=29,bg=254 # fg=#0d935c,bg=#e1e1e1 + ble-face -s vim_airline_a_replace fg=124,bg=254 # fg=#b30000,bg=#e1e1e1 + ble-face -s vim_airline_a_visual fg=19,bg=254 # fg=#0000b3,bg=#e1e1e1 + ble-face -s vim_airline_b fg=238,bg=254 # fg=#414141,bg=#e1e1e1 + ble-face -s vim_airline_b_inactive fg=247,bg=253 # fg=#a1a1a1,bg=#dddddd + ble-face -s vim_airline_b_insert fg=29,bg=254 # fg=#0d935c,bg=#e1e1e1 + ble-face -s vim_airline_b_visual fg=19,bg=254 # fg=#0000b3,bg=#e1e1e1 + ble-face -s vim_airline_c fg=238,bg=254 # fg=#414141,bg=#e1e1e1 + ble-face -s vim_airline_c_inactive fg=247,bg=253 # fg=#a1a1a1,bg=#dddddd + ble-face -s vim_airline_c_inactive_modified fg=166,bg=0 # fg=#e25000,bg=0 + ble-face -s vim_airline_c_insert fg=29,bg=254 # fg=#0d935c,bg=#e1e1e1 + ble-face -s vim_airline_c_insert_modified fg=166,bg=254 # fg=#e25000,bg=#e1e1e1 + ble-face -s vim_airline_c_normal_modified fg=166,bg=254 # fg=#e25000,bg=#e1e1e1 + ble-face -s vim_airline_c_replace_modified fg=166,bg=254 # fg=#e25000,bg=#e1e1e1 + ble-face -s vim_airline_c_visual fg=19,bg=254 # fg=#0000b3,bg=#e1e1e1 + ble-face -s vim_airline_c_visual_modified fg=166,bg=254 # fg=#e25000,bg=#e1e1e1 + ble-face -s vim_airline_warning fg=196,bg=254 # fg=#ff0000,bg=#e1e1e1 + ble-face -s vim_airline_warning_inactive fg=16,bg=166 # fg=#000000,bg=#df5f00 +} diff --git a/.local/share/blesh/contrib/airline/simple.bash b/.local/share/blesh/contrib/airline/simple.bash new file mode 100644 index 0000000..aed24d4 --- /dev/null +++ b/.local/share/blesh/contrib/airline/simple.bash @@ -0,0 +1,24 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/simple.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:simple/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=232,bg=45 # fg=#080808,bg=#00dfff + ble-face -s vim_airline_a_inactive fg=239,bg=232 # fg=#4e4e4e,bg=#080808 + ble-face -s vim_airline_a_insert fg=232,bg=82 # fg=#080808,bg=#5fff00 + ble-face -s vim_airline_a_replace fg=232,bg=124 # fg=#080808,bg=#af0000 + ble-face -s vim_airline_a_visual fg=232,bg=184 # fg=#080808,bg=#dfdf00 + ble-face -s vim_airline_b fg=202,bg=234 # fg=#ff5f00,bg=#1c1c1c + ble-face -s vim_airline_b_inactive fg=239,bg=234 # fg=#4e4e4e,bg=#1c1c1c + ble-face -s vim_airline_c fg=243,bg=232 # fg=#767676,bg=#080808 + ble-face -s vim_airline_c_inactive fg=239,bg=234 # fg=#4e4e4e,bg=#1c1c1c + ble-face -s vim_airline_c_inactive_modified fg=160,bg=0 # fg=#df0000,bg=0 + ble-face -s vim_airline_c_insert_modified fg=160,bg=232 # fg=#df0000,bg=#080808 + ble-face -s vim_airline_c_normal_modified fg=160,bg=232 # fg=#df0000,bg=#080808 + ble-face -s vim_airline_c_replace_modified fg=160,bg=232 # fg=#df0000,bg=#080808 + ble-face -s vim_airline_c_visual_modified fg=160,bg=232 # fg=#df0000,bg=#080808 +} diff --git a/.local/share/blesh/contrib/airline/soda.bash b/.local/share/blesh/contrib/airline/soda.bash new file mode 100644 index 0000000..3c425b2 --- /dev/null +++ b/.local/share/blesh/contrib/airline/soda.bash @@ -0,0 +1,24 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/soda.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:soda/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=231,bg=97 # fg=#ffffff,bg=#875faf + ble-face -s vim_airline_a_inactive fg=243,bg=231 # fg=#767676,bg=#ffffff + ble-face -s vim_airline_a_insert fg=231,bg=22 # fg=#ffffff,bg=#005f00 + ble-face -s vim_airline_a_replace fg=243,bg=227 # fg=#767676,bg=#ffff5f + ble-face -s vim_airline_a_visual fg=243,bg=227 # fg=#767676,bg=#ffff5f + ble-face -s vim_airline_b fg=231,bg=96 # fg=#ffffff,bg=#875f87 + ble-face -s vim_airline_b_inactive fg=243,bg=231 # fg=#767676,bg=#ffffff + ble-face -s vim_airline_b_insert fg=231,bg=28 # fg=#ffffff,bg=#008700 + ble-face -s vim_airline_b_visual fg=243,bg=221 # fg=#767676,bg=#ffd75f + ble-face -s vim_airline_c fg=231,bg=54 # fg=#ffffff,bg=#5f0087 + ble-face -s vim_airline_c_inactive fg=243,bg=231 # fg=#767676,bg=#ffffff + ble-face -s vim_airline_c_inactive_modified fg=231,bg=160 # fg=#ffffff,bg=#df0000 + ble-face -s vim_airline_c_insert fg=231,bg=34 # fg=#ffffff,bg=#00af00 + ble-face -s vim_airline_c_visual fg=243,bg=215 # fg=#767676,bg=#ffaf5f +} diff --git a/.local/share/blesh/contrib/airline/sol.bash b/.local/share/blesh/contrib/airline/sol.bash new file mode 100644 index 0000000..a3be0b5 --- /dev/null +++ b/.local/share/blesh/contrib/airline/sol.bash @@ -0,0 +1,32 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/sol.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# vim-airline companion theme of Sol +# (https://github.com/Pychimp/vim-sol) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:sol/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=236,bg=247 # fg=#343434,bg=#a0a0a0 + ble-face -s vim_airline_a_inactive fg=243,bg=251 # fg=#777777,bg=#c7c7c7 + ble-face -s vim_airline_a_insert fg=255,bg=23 # fg=#eeeeee,bg=#09643f + ble-face -s vim_airline_a_replace fg=255,bg=196 # fg=#eeeeee,bg=#ff2121 + ble-face -s vim_airline_a_visual fg=228,bg=202 # fg=#ffff9a,bg=#ff6003 + ble-face -s vim_airline_b fg=236,bg=249 # fg=#343434,bg=#b3b3b3 + ble-face -s vim_airline_b_inactive fg=243,bg=251 # fg=#777777,bg=#c7c7c7 + ble-face -s vim_airline_b_insert fg=236,bg=248 # fg=#343434,bg=#a3a3a3 + ble-face -s vim_airline_b_visual fg=236,bg=248 # fg=#343434,bg=#a3a3a3 + ble-face -s vim_airline_c fg=236,bg=251 # fg=#343434,bg=#c7c7c7 + ble-face -s vim_airline_c_inactive fg=243,bg=251 # fg=#777777,bg=#c7c7c7 + ble-face -s vim_airline_c_inactive_modified fg=203,bg=0 # fg=#ff3535,bg=0 + ble-face -s vim_airline_c_insert fg=236,bg=149 # fg=#343434,bg=#b0b0b0 + ble-face -s vim_airline_c_insert_modified fg=236,bg=224 # fg=#343434,bg=#ffdbc7 + ble-face -s vim_airline_c_normal_modified fg=231,bg=203 # fg=#ffffff,bg=#ff6868 + ble-face -s vim_airline_c_replace_modified fg=236,bg=224 # fg=#343434,bg=#ffdbc7 + ble-face -s vim_airline_c_visual fg=236,bg=149 # fg=#343434,bg=#b0b0b0 + ble-face -s vim_airline_c_visual_modified fg=236,bg=224 # fg=#343434,bg=#ffdbc7 + ble-face -s vim_airline_warning fg=255,bg=166 # fg=#eeeeee,bg=#e33900 + ble-face -s vim_airline_warning_inactive fg=16,bg=166 # fg=#000000,bg=#df5f00 +} diff --git a/.local/share/blesh/contrib/airline/solarized.bash b/.local/share/blesh/contrib/airline/solarized.bash new file mode 100644 index 0000000..3f9e9e4 --- /dev/null +++ b/.local/share/blesh/contrib/airline/solarized.bash @@ -0,0 +1,31 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/solarized.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:solarized/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=224,bg=66 # fg=#eee8d5,bg=#657b83 + ble-face -s vim_airline_a_inactive fg=224,bg=246 # fg=#eee8d5,bg=#839496 + ble-face -s vim_airline_a_insert fg=224,bg=136 # fg=#eee8d5,bg=#b58900 + ble-face -s vim_airline_a_replace fg=224,bg=166 # fg=#eee8d5,bg=#dc322f + ble-face -s vim_airline_a_visual fg=224,bg=168 # fg=#eee8d5,bg=#d33682 + ble-face -s vim_airline_b fg=224,bg=109 # fg=#eee8d5,bg=#93a1a1 + ble-face -s vim_airline_b_inactive fg=224,bg=246 # fg=#eee8d5,bg=#839496 + ble-face -s vim_airline_c fg=109,bg=224 # fg=#93a1a1,bg=#eee8d5 + ble-face -s vim_airline_c_inactive fg=224,bg=246 # fg=#eee8d5,bg=#839496 + ble-face -s vim_airline_c_inactive_modified fg=23,bg=0 # fg=#073642,bg=0 + ble-face -s vim_airline_c_insert_modified fg=60,bg=224 # fg=#586e75,bg=#eee8d5 + ble-face -s vim_airline_c_normal_modified fg=60,bg=224 # fg=#586e75,bg=#eee8d5 + ble-face -s vim_airline_c_replace_modified fg=60,bg=224 # fg=#586e75,bg=#eee8d5 + ble-face -s vim_airline_c_visual_modified fg=60,bg=224 # fg=#586e75,bg=#eee8d5 + ble-face -s vim_airline_error fg=230,bg=166 # fg=#fdf6e3,bg=#cb4b16 + ble-face -s vim_airline_error_inactive fg=16,bg=88 # fg=#000000,bg=#990000 + ble-face -s vim_airline_error_insert fg=16,bg=88 # fg=#000000,bg=#990000 + ble-face -s vim_airline_error_normal_modified fg=16,bg=88 # fg=#000000,bg=#990000 + ble-face -s vim_airline_error_visual fg=16,bg=88 # fg=#000000,bg=#990000 + ble-face -s vim_airline_warning fg=230,bg=166 # fg=#fdf6e3,bg=#cb4b16 + ble-face -s vim_airline_warning_inactive fg=16,bg=166 # fg=#000000,bg=#df5f00 +} diff --git a/.local/share/blesh/contrib/airline/solarized_flood.bash b/.local/share/blesh/contrib/airline/solarized_flood.bash new file mode 100644 index 0000000..2726fe9 --- /dev/null +++ b/.local/share/blesh/contrib/airline/solarized_flood.bash @@ -0,0 +1,49 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/solarized_flood.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Name: Solarized Flood +# Changed: June 3 2018 +# Maintainer: https://github.com/Neur1n +# Description: +# A vim-airline theme made based on and tested with the Solarized colorscheme +# (https://github.com/frankier/neovim-colors-solarized-truecolor-only) in +# Windows 10 OS and GVim 8.1. +# +# This script is based on the 'dark' theme. The 'inactive' and 'ctrlp' parts +# were not changed. +# +# It is call 'flood' since the statusline and the tabline will be highlighted +# with the 'base03' color in Solarized (dark). If you use the dark Solarized +# colorscheme for Vim and, in Windows, set 'Personalization-Colors-Choose +# your color - Custom color' to be '#002B36' (*), then most parts of the GVim +# window will be 'flooded' with the color. +# NOTE: This will make some components of the airline less distinguishable +# from the others. If anyone has better ideas, I will be happy to take +# a conversation with you. :) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:solarized_flood/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=17,bg=100 # fg=#002b36,bg=#859900 + ble-face -s vim_airline_a_inactive fg=239,bg=234 # fg=#4e4e4e,bg=#1c1c1c + ble-face -s vim_airline_a_insert fg=17,bg=36 # fg=#002b36,bg=#2aa198 + ble-face -s vim_airline_a_replace fg=17,bg=166 # fg=#002b36,bg=#dc322f + ble-face -s vim_airline_a_visual fg=17,bg=136 # fg=#002b36,bg=#b58900 + ble-face -s vim_airline_b fg=109,bg=17 # fg=#93a1a1,bg=#002b36 + ble-face -s vim_airline_b_inactive fg=239,bg=235 # fg=#4e4e4e,bg=#262626 + ble-face -s vim_airline_c fg=36,bg=17 # fg=#2aa198,bg=#002b36 + ble-face -s vim_airline_c_inactive fg=239,bg=236 # fg=#4e4e4e,bg=#303030 + ble-face -s vim_airline_c_inactive_modified fg=97,bg=0 # fg=#875faf,bg=0 + ble-face -s vim_airline_c_insert fg=32,bg=17 # fg=#268bd2,bg=#002b36 + ble-face -s vim_airline_c_insert_modified fg=168,bg=17 # fg=#d33682,bg=#002b36 + ble-face -s vim_airline_c_normal_modified fg=168,bg=17 # fg=#d33682,bg=#002b36 + ble-face -s vim_airline_c_replace_modified fg=168,bg=17 # fg=#d33682,bg=#002b36 + ble-face -s vim_airline_c_visual fg=166,bg=17 # fg=#dc322f,bg=#002b36 + ble-face -s vim_airline_c_visual_modified fg=168,bg=17 # fg=#d33682,bg=#002b36 + ble-face -s vim_airline_z_insert fg=36,bg=17 # fg=#2aa198,bg=#002b36 + ble-face -s vim_airline_z_normal fg=100,bg=17 # fg=#859900,bg=#002b36 + ble-face -s vim_airline_z_replace fg=36,bg=17 # fg=#2aa198,bg=#002b36 + ble-face -s vim_airline_z_visual fg=136,bg=17 # fg=#b58900,bg=#002b36 +} diff --git a/.local/share/blesh/contrib/airline/supernova.bash b/.local/share/blesh/contrib/airline/supernova.bash new file mode 100644 index 0000000..42641c9 --- /dev/null +++ b/.local/share/blesh/contrib/airline/supernova.bash @@ -0,0 +1,26 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/supernova.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:supernova/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=235,bg=73 # fg=#262626,bg=#5fafaf + ble-face -s vim_airline_a_inactive fg=252,bg=238 # fg=#d0d0d0,bg=#444444 + ble-face -s vim_airline_a_insert fg=254,bg=54 # fg=#e4e4e4,bg=#5f0087 + ble-face -s vim_airline_a_replace fg=254,bg=89 # fg=#e4e4e4,bg=#87005f + ble-face -s vim_airline_a_visual fg=235,bg=32 # fg=#262626,bg=#0087d7 + ble-face -s vim_airline_b fg=252,bg=240 # fg=#d0d0d0,bg=#585858 + ble-face -s vim_airline_b_inactive fg=252,bg=238 # fg=#d0d0d0,bg=#444444 + ble-face -s vim_airline_b_visual fg=0,bg=240 # fg=0,bg=#585858 + ble-face -s vim_airline_c fg=248,bg=235 # fg=#a8a8a8,bg=#262626 + ble-face -s vim_airline_c_inactive fg=252,bg=240 # fg=#d0d0d0,bg=#585858 + ble-face -s vim_airline_c_inactive_modified fg=255,bg=238 # fg=#eeeeee,bg=#444444 + ble-face -s vim_airline_c_insert_modified fg=255,bg=235 # fg=#eeeeee,bg=#262626 + ble-face -s vim_airline_c_normal_modified fg=255,bg=235 # fg=#eeeeee,bg=#262626 + ble-face -s vim_airline_c_replace_modified fg=255,bg=235 # fg=#eeeeee,bg=#262626 + ble-face -s vim_airline_c_visual_modified fg=255,bg=235 # fg=#eeeeee,bg=#262626 + ble-face -s vim_airline_x_inactive fg=252,bg=238 # fg=#d0d0d0,bg=#444444 +} diff --git a/.local/share/blesh/contrib/airline/term.bash b/.local/share/blesh/contrib/airline/term.bash new file mode 100644 index 0000000..f9d09b7 --- /dev/null +++ b/.local/share/blesh/contrib/airline/term.bash @@ -0,0 +1,38 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/term.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:term/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=233,bg=186 # fg=#141413,bg=#cae682 + ble-face -s vim_airline_a_inactive fg=243,bg=235 # fg=#767676,bg=#242424 + ble-face -s vim_airline_a_insert fg=233,bg=221 # fg=#141413,bg=#fde76e + ble-face -s vim_airline_a_insert_modified fg=233,bg=221 # fg=#141413,bg=#fade3e + ble-face -s vim_airline_a_normal_modified fg=233,bg=114 # fg=#141413,bg=#86cd74 + ble-face -s vim_airline_a_replace fg=233,bg=173 # fg=#141413,bg=#e5786d + ble-face -s vim_airline_a_replace_modified fg=233,bg=167 # fg=#141413,bg=#e55345 + ble-face -s vim_airline_a_visual fg=233,bg=153 # fg=#141413,bg=#b5d3f3 + ble-face -s vim_airline_a_visual_modified fg=233,bg=110 # fg=#141413,bg=#7cb0e6 + ble-face -s vim_airline_b fg=186,bg=58 # fg=#cae682,bg=#32322f + ble-face -s vim_airline_b_inactive fg=243,bg=235 # fg=#767676,bg=#242424 + ble-face -s vim_airline_b_insert fg=221,bg=58 # fg=#fde76e,bg=#32322f + ble-face -s vim_airline_b_insert_modified fg=221,bg=238 # fg=#fade3e,bg=#40403c + ble-face -s vim_airline_b_normal_modified fg=114,bg=238 # fg=#86cd74,bg=#40403c + ble-face -s vim_airline_b_replace fg=173,bg=58 # fg=#e5786d,bg=#32322f + ble-face -s vim_airline_b_replace_modified fg=167,bg=238 # fg=#e55345,bg=#40403c + ble-face -s vim_airline_b_visual fg=153,bg=58 # fg=#b5d3f3,bg=#32322f + ble-face -s vim_airline_b_visual_modified fg=110,bg=238 # fg=#7cb0e6,bg=#40403c + ble-face -s vim_airline_c fg=186,bg=235 # fg=#cae682,bg=#242424 + ble-face -s vim_airline_c_inactive fg=243,bg=235 # fg=#767676,bg=#242424 + ble-face -s vim_airline_c_inactive_modified fg=114,bg=0 # fg=#86cd74,bg=0 + ble-face -s vim_airline_c_insert fg=221,bg=235 # fg=#fde76e,bg=#242424 + ble-face -s vim_airline_c_insert_modified fg=221,bg=235 # fg=#fade3e,bg=#242424 + ble-face -s vim_airline_c_normal_modified fg=114,bg=235 # fg=#86cd74,bg=#242424 + ble-face -s vim_airline_c_replace fg=173,bg=235 # fg=#e5786d,bg=#242424 + ble-face -s vim_airline_c_replace_modified fg=167,bg=235 # fg=#e55345,bg=#242424 + ble-face -s vim_airline_c_visual fg=153,bg=235 # fg=#b5d3f3,bg=#242424 + ble-face -s vim_airline_c_visual_modified fg=110,bg=235 # fg=#7cb0e6,bg=#242424 +} diff --git a/.local/share/blesh/contrib/airline/term_light.bash b/.local/share/blesh/contrib/airline/term_light.bash new file mode 100644 index 0000000..d15af1b --- /dev/null +++ b/.local/share/blesh/contrib/airline/term_light.bash @@ -0,0 +1,38 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/term_light.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:term_light/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=255,bg=114 # fg=#f0f0f0,bg=#86cd74 + ble-face -s vim_airline_a_inactive fg=243,bg=106 # fg=#767676,bg=#888a85 + ble-face -s vim_airline_a_insert fg=255,bg=221 # fg=#f0f0f0,bg=#fade3e + ble-face -s vim_airline_a_insert_modified fg=233,bg=221 # fg=#141413,bg=#fde76e + ble-face -s vim_airline_a_normal_modified fg=233,bg=186 # fg=#141413,bg=#cae682 + ble-face -s vim_airline_a_replace fg=255,bg=167 # fg=#f0f0f0,bg=#e55345 + ble-face -s vim_airline_a_replace_modified fg=233,bg=173 # fg=#141413,bg=#e5786d + ble-face -s vim_airline_a_visual fg=255,bg=110 # fg=#f0f0f0,bg=#7cb0e6 + ble-face -s vim_airline_a_visual_modified fg=233,bg=153 # fg=#141413,bg=#b5d3f3 + ble-face -s vim_airline_b fg=114,bg=253 # fg=#86cd74,bg=#deded9 + ble-face -s vim_airline_b_inactive fg=243,bg=106 # fg=#767676,bg=#888a85 + ble-face -s vim_airline_b_insert fg=221,bg=253 # fg=#fade3e,bg=#deded9 + ble-face -s vim_airline_b_insert_modified fg=221,bg=238 # fg=#fde76e,bg=#40403c + ble-face -s vim_airline_b_normal_modified fg=186,bg=238 # fg=#cae682,bg=#40403c + ble-face -s vim_airline_b_replace fg=167,bg=253 # fg=#e55345,bg=#deded9 + ble-face -s vim_airline_b_replace_modified fg=173,bg=238 # fg=#e5786d,bg=#40403c + ble-face -s vim_airline_b_visual fg=110,bg=253 # fg=#7cb0e6,bg=#deded9 + ble-face -s vim_airline_b_visual_modified fg=153,bg=238 # fg=#b5d3f3,bg=#40403c + ble-face -s vim_airline_c fg=114,bg=106 # fg=#86cd74,bg=#888a85 + ble-face -s vim_airline_c_inactive fg=243,bg=106 # fg=#767676,bg=#888a85 + ble-face -s vim_airline_c_inactive_modified fg=186,bg=0 # fg=#cae682,bg=0 + ble-face -s vim_airline_c_insert fg=221,bg=106 # fg=#fade3e,bg=#888a85 + ble-face -s vim_airline_c_insert_modified fg=221,bg=106 # fg=#fde76e,bg=#888a85 + ble-face -s vim_airline_c_normal_modified fg=186,bg=106 # fg=#cae682,bg=#888a85 + ble-face -s vim_airline_c_replace fg=167,bg=106 # fg=#e55345,bg=#888a85 + ble-face -s vim_airline_c_replace_modified fg=173,bg=106 # fg=#e5786d,bg=#888a85 + ble-face -s vim_airline_c_visual fg=110,bg=106 # fg=#7cb0e6,bg=#888a85 + ble-face -s vim_airline_c_visual_modified fg=153,bg=106 # fg=#b5d3f3,bg=#888a85 +} diff --git a/.local/share/blesh/contrib/airline/tomorrow.bash b/.local/share/blesh/contrib/airline/tomorrow.bash new file mode 100644 index 0000000..2bb1e4f --- /dev/null +++ b/.local/share/blesh/contrib/airline/tomorrow.bash @@ -0,0 +1,27 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/tomorrow.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:tomorrow/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=-1,bg=21 # fg=-1,bg=#0000ff + ble-face -s vim_airline_a_inactive fg=21,bg=254 # fg=#0000ff,bg=#e5e5e5 + ble-face -s vim_airline_a_insert fg=-1,bg=29 # fg=-1,bg=#2e8b57 + ble-face -s vim_airline_a_replace fg=231,bg=196 # fg=#ffffff,bg=#ff0000 + ble-face -s vim_airline_a_visual fg=-1,bg=201 # fg=-1,bg=#ff00ff + ble-face -s vim_airline_b fg=-1,bg=213 # fg=-1,bg=#ff8bff + ble-face -s vim_airline_b_inactive fg=21,bg=254 # fg=#0000ff,bg=#e5e5e5 + ble-face -s vim_airline_b_insert fg=29,bg=-1 # fg=#2e8b57,bg=-1 + ble-face -s vim_airline_b_replace fg=-1,bg=213 # fg=-1,bg=#ff8bff + ble-face -s vim_airline_b_visual fg=201,bg=-1 # fg=#ff00ff,bg=-1 + ble-face -s vim_airline_c fg=-1,bg=254 # fg=-1,bg=#e5e5e5 + ble-face -s vim_airline_c_inactive fg=21,bg=254 # fg=#0000ff,bg=#e5e5e5 + ble-face -s vim_airline_c_inactive_modified fg=-1,bg=0 # fg=-1,bg=0 + ble-face -s vim_airline_c_insert_modified fg=-1,bg=0 # fg=-1,bg=0 + ble-face -s vim_airline_c_normal_modified fg=-1,bg=0 # fg=-1,bg=0 + ble-face -s vim_airline_c_replace_modified fg=-1,bg=0 # fg=-1,bg=0 + ble-face -s vim_airline_c_visual_modified fg=-1,bg=0 # fg=-1,bg=0 +} diff --git a/.local/share/blesh/contrib/airline/transparent.bash b/.local/share/blesh/contrib/airline/transparent.bash new file mode 100644 index 0000000..4a58274 --- /dev/null +++ b/.local/share/blesh/contrib/airline/transparent.bash @@ -0,0 +1,31 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/transparent.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +#FROM https://github.com/khatiba + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:transparent/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=103,bg=-1 # fg=#8d96a1,bg=-1 + ble-face -s vim_airline_a_inactive fg=234,bg=-1 # fg=#1d1f21,bg=-1 + ble-face -s vim_airline_a_insert fg=234,bg=150 # fg=#1d1f21,bg=#bbe67e + ble-face -s vim_airline_a_normal_modified fg=234,bg=215 # fg=#1d1f21,bg=#ffae57 + ble-face -s vim_airline_a_replace fg=234,bg=183 # fg=#1d1f21,bg=#d4bfff + ble-face -s vim_airline_a_visual fg=234,bg=204 # fg=#1d1f21,bg=#f07178 + ble-face -s vim_airline_b fg=239,bg=-1 # fg=#3f4b59,bg=-1 + ble-face -s vim_airline_b_inactive fg=234,bg=-1 # fg=#1d1f21,bg=-1 + ble-face -s vim_airline_c fg=239,bg=-1 # fg=#3f4b59,bg=-1 + ble-face -s vim_airline_c_inactive_modified fg=215,bg=-1 # fg=#ffae57,bg=-1 + ble-face -s vim_airline_error fg=234,bg=204 # fg=#1d1f21,bg=#f07178 + ble-face -s vim_airline_error_inactive fg=16,bg=88 # fg=#000000,bg=#990000 + ble-face -s vim_airline_warning fg=234,bg=215 # fg=#1d1f21,bg=#ffae57 + ble-face -s vim_airline_warning_inactive fg=16,bg=166 # fg=#000000,bg=#df5f00 + ble-face -s vim_airline_x_inactive fg=234,bg=-1 # fg=#1d1f21,bg=-1 + ble-face -s vim_airline_z_insert fg=150,bg=-1 # fg=#bbe67e,bg=-1 + ble-face -s vim_airline_z_normal fg=239,bg=-1 # fg=#3f4b59,bg=-1 + ble-face -s vim_airline_z_normal_modified fg=215,bg=-1 # fg=#ffae57,bg=-1 + ble-face -s vim_airline_z_replace fg=183,bg=-1 # fg=#d4bfff,bg=-1 + ble-face -s vim_airline_z_visual fg=204,bg=-1 # fg=#f07178,bg=-1 +} diff --git a/.local/share/blesh/contrib/airline/ubaryd.bash b/.local/share/blesh/contrib/airline/ubaryd.bash new file mode 100644 index 0000000..09f40ea --- /dev/null +++ b/.local/share/blesh/contrib/airline/ubaryd.bash @@ -0,0 +1,43 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/ubaryd.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# vim-airline companion theme of Ubaryd +# (https://github.com/Donearm/Ubaryd) +# +# Author: Gianluca fiore +# Version: 1.12 +# License: MIT + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:ubaryd/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=22,bg=255 # fg=#005f00,bg=#f8f6f2 + ble-face -s vim_airline_a_inactive fg=22,bg=235 # fg=#005f00,bg=#242321 + ble-face -s vim_airline_a_insert fg=255,bg=168 # fg=#f8f6f2,bg=#e25a74 + ble-face -s vim_airline_a_insert_modified fg=255,bg=222 # fg=#f8f6f2,bg=#f4cf86 + ble-face -s vim_airline_a_normal_modified fg=22,bg=22 # fg=#005f00,bg=#005f00 + ble-face -s vim_airline_a_replace fg=235,bg=255 # fg=#242321,bg=#f8f6f2 + ble-face -s vim_airline_a_replace_modified fg=235,bg=214 # fg=#242321,bg=#ffa724 + ble-face -s vim_airline_a_visual fg=60,bg=255 # fg=#416389,bg=#f8f6f2 + ble-face -s vim_airline_a_visual_modified fg=60,bg=94 # fg=#416389,bg=#9a4820 + ble-face -s vim_airline_b fg=255,bg=22 # fg=#f8f6f2,bg=#005f00 + ble-face -s vim_airline_b_inactive fg=22,bg=235 # fg=#005f00,bg=#242321 + ble-face -s vim_airline_b_insert fg=235,bg=131 # fg=#242321,bg=#c14c3d + ble-face -s vim_airline_b_insert_modified fg=222,bg=235 # fg=#f4cf86,bg=#242321 + ble-face -s vim_airline_b_normal_modified fg=22,bg=235 # fg=#005f00,bg=#242321 + ble-face -s vim_airline_b_replace fg=214,bg=241 # fg=#ffa724,bg=#666462 + ble-face -s vim_airline_b_replace_modified fg=214,bg=235 # fg=#ffa724,bg=#242321 + ble-face -s vim_airline_b_visual fg=60,bg=222 # fg=#416389,bg=#f4cf86 + ble-face -s vim_airline_b_visual_modified fg=94,bg=235 # fg=#9a4820,bg=#242321 + ble-face -s vim_airline_c fg=137,bg=235 # fg=#b88853,bg=#242321 + ble-face -s vim_airline_c_inactive fg=22,bg=235 # fg=#005f00,bg=#242321 + ble-face -s vim_airline_c_inactive_modified fg=22,bg=0 # fg=#005f00,bg=0 + ble-face -s vim_airline_c_insert fg=222,bg=235 # fg=#f4cf86,bg=#242321 + ble-face -s vim_airline_c_normal_modified fg=22,bg=235 # fg=#005f00,bg=#242321 + ble-face -s vim_airline_c_replace fg=255,bg=208 # fg=#f8f6f2,bg=#ff7400 + ble-face -s vim_airline_c_replace_modified fg=214,bg=235 # fg=#ffa724,bg=#242321 + ble-face -s vim_airline_c_visual fg=94,bg=255 # fg=#9a4820,bg=#f8f6f2 + ble-face -s vim_airline_c_visual_modified fg=94,bg=235 # fg=#9a4820,bg=#242321 +} diff --git a/.local/share/blesh/contrib/airline/understated.bash b/.local/share/blesh/contrib/airline/understated.bash new file mode 100644 index 0000000..23ec18f --- /dev/null +++ b/.local/share/blesh/contrib/airline/understated.bash @@ -0,0 +1,23 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/understated.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:understated/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=231,bg=69 # fg=#ffffff,bg=#5f87ff + ble-face -s vim_airline_a_inactive fg=239,bg=234 # fg=#4e4e4e,bg=#1c1c1c + ble-face -s vim_airline_a_insert fg=231,bg=107 # fg=#ffffff,bg=#87af5f + ble-face -s vim_airline_a_replace fg=231,bg=88 # fg=#ffffff,bg=#870000 + ble-face -s vim_airline_a_visual fg=231,bg=130 # fg=#ffffff,bg=#af5f00 + ble-face -s vim_airline_b fg=144,bg=62 # fg=#afaf87,bg=#5f5f5f + ble-face -s vim_airline_b_inactive fg=239,bg=234 # fg=#4e4e4e,bg=#1c1c1c + ble-face -s vim_airline_c fg=144,bg=62 # fg=#afaf87,bg=#5f5f5f + ble-face -s vim_airline_c_inactive fg=239,bg=234 # fg=#4e4e4e,bg=#1c1c1c + ble-face -s vim_airline_c_inactive_modified fg=239,bg=0 # fg=#4e4e4e,bg=0 + ble-face -s vim_airline_c_normal_modified fg=231,bg=53 # fg=#ffffff,bg=#5f005f + ble-face -s vim_airline_c_visual_modified fg=144,bg=53 # fg=#afaf87,bg=#5f005f + ble-face -s vim_airline_z_replace fg=231,bg=107 # fg=#ffffff,bg=#87af5f +} diff --git a/.local/share/blesh/contrib/airline/violet.bash b/.local/share/blesh/contrib/airline/violet.bash new file mode 100644 index 0000000..68dd911 --- /dev/null +++ b/.local/share/blesh/contrib/airline/violet.bash @@ -0,0 +1,21 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/violet.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Normal mode " guifg guibg ctermfg ctermbg + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:violet/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=250,bg=97 # fg=#bcbcbc,bg=#875faf + ble-face -s vim_airline_a_inactive fg=97,bg=237 # fg=#875faf,bg=#3a3a3a + ble-face -s vim_airline_a_insert fg=252,bg=29 # fg=#cacfd2,bg=#009966 + ble-face -s vim_airline_a_replace fg=251,bg=168 # fg=#c6c6c6,bg=#ce537a + ble-face -s vim_airline_a_visual fg=52,bg=205 # fg=#5f0000,bg=#ff5faf + ble-face -s vim_airline_b fg=170,bg=239 # fg=#d75fd7,bg=#4e4e4e + ble-face -s vim_airline_b_inactive fg=97,bg=237 # fg=#875faf,bg=#3a3a3a + ble-face -s vim_airline_c fg=251,bg=237 # fg=#c6c6c6,bg=#3a3a3a + ble-face -s vim_airline_c_inactive fg=97,bg=237 # fg=#875faf,bg=#3a3a3a + ble-face -s vim_airline_z_replace fg=250,bg=97 # fg=#bcbcbc,bg=#875faf +} diff --git a/.local/share/blesh/contrib/airline/wombat.bash b/.local/share/blesh/contrib/airline/wombat.bash new file mode 100644 index 0000000..d8ba061 --- /dev/null +++ b/.local/share/blesh/contrib/airline/wombat.bash @@ -0,0 +1,40 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/wombat.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# vim-airline companion theme of Wombat +# looks great with wombat256 vim colorscheme + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:wombat/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=233,bg=186 # fg=#141413,bg=#cae682 + ble-face -s vim_airline_a_inactive fg=243,bg=235 # fg=#767676,bg=#242424 + ble-face -s vim_airline_a_insert fg=233,bg=221 # fg=#141413,bg=#fde76e + ble-face -s vim_airline_a_insert_modified fg=233,bg=221 # fg=#141413,bg=#fade3e + ble-face -s vim_airline_a_normal_modified fg=233,bg=114 # fg=#141413,bg=#86cd74 + ble-face -s vim_airline_a_replace fg=233,bg=173 # fg=#141413,bg=#e5786d + ble-face -s vim_airline_a_replace_modified fg=233,bg=167 # fg=#141413,bg=#e55345 + ble-face -s vim_airline_a_visual fg=233,bg=153 # fg=#141413,bg=#b5d3f3 + ble-face -s vim_airline_a_visual_modified fg=233,bg=110 # fg=#141413,bg=#7cb0e6 + ble-face -s vim_airline_b fg=186,bg=58 # fg=#cae682,bg=#32322f + ble-face -s vim_airline_b_inactive fg=243,bg=235 # fg=#767676,bg=#242424 + ble-face -s vim_airline_b_insert fg=221,bg=58 # fg=#fde76e,bg=#32322f + ble-face -s vim_airline_b_insert_modified fg=221,bg=238 # fg=#fade3e,bg=#40403c + ble-face -s vim_airline_b_normal_modified fg=114,bg=238 # fg=#86cd74,bg=#40403c + ble-face -s vim_airline_b_replace fg=173,bg=58 # fg=#e5786d,bg=#32322f + ble-face -s vim_airline_b_replace_modified fg=167,bg=238 # fg=#e55345,bg=#40403c + ble-face -s vim_airline_b_visual fg=153,bg=58 # fg=#b5d3f3,bg=#32322f + ble-face -s vim_airline_b_visual_modified fg=110,bg=238 # fg=#7cb0e6,bg=#40403c + ble-face -s vim_airline_c fg=186,bg=235 # fg=#cae682,bg=#242424 + ble-face -s vim_airline_c_inactive fg=243,bg=235 # fg=#767676,bg=#242424 + ble-face -s vim_airline_c_inactive_modified fg=114,bg=0 # fg=#86cd74,bg=0 + ble-face -s vim_airline_c_insert fg=221,bg=235 # fg=#fde76e,bg=#242424 + ble-face -s vim_airline_c_insert_modified fg=221,bg=235 # fg=#fade3e,bg=#242424 + ble-face -s vim_airline_c_normal_modified fg=114,bg=235 # fg=#86cd74,bg=#242424 + ble-face -s vim_airline_c_replace fg=173,bg=235 # fg=#e5786d,bg=#242424 + ble-face -s vim_airline_c_replace_modified fg=167,bg=235 # fg=#e55345,bg=#242424 + ble-face -s vim_airline_c_visual fg=153,bg=235 # fg=#b5d3f3,bg=#242424 + ble-face -s vim_airline_c_visual_modified fg=110,bg=235 # fg=#7cb0e6,bg=#242424 +} diff --git a/.local/share/blesh/contrib/airline/xtermlight.bash b/.local/share/blesh/contrib/airline/xtermlight.bash new file mode 100644 index 0000000..f8d23c1 --- /dev/null +++ b/.local/share/blesh/contrib/airline/xtermlight.bash @@ -0,0 +1,29 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/xtermlight.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:xtermlight/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=255,bg=27 # fg=#eeeeee,bg=#005fff + ble-face -s vim_airline_a_inactive fg=242,bg=249 # fg=#6c6c6c,bg=#b2b2b2 + ble-face -s vim_airline_a_insert fg=255,bg=29 # fg=#eeeeee,bg=#00875f + ble-face -s vim_airline_a_replace fg=22,bg=196 # fg=#005f00,bg=#ff0000 + ble-face -s vim_airline_a_visual fg=255,bg=202 # fg=#eeeeee,bg=#ff5f00 + ble-face -s vim_airline_b fg=18,bg=45 # fg=#000087,bg=#00d7ff + ble-face -s vim_airline_b_inactive fg=245,bg=252 # fg=#8a8a8a,bg=#d0d0d0 + ble-face -s vim_airline_b_insert fg=22,bg=42 # fg=#005f00,bg=#00d787 + ble-face -s vim_airline_b_visual fg=52,bg=214 # fg=#5f0000,bg=#ffaf00 + ble-face -s vim_airline_c fg=27,bg=159 # fg=#005fff,bg=#afffff + ble-face -s vim_airline_c_inactive fg=248,bg=255 # fg=#a8a8a8,bg=#eeeeee + ble-face -s vim_airline_c_inactive_modified fg=160,bg=0 # fg=#d70000,bg=0 + ble-face -s vim_airline_c_insert fg=23,bg=156 # fg=#005f5f,bg=#afff87 + ble-face -s vim_airline_c_insert_modified fg=160,bg=224 # fg=#d70000,bg=#ffdfdf + ble-face -s vim_airline_c_normal_modified fg=160,bg=224 # fg=#d70000,bg=#ffdfdf + ble-face -s vim_airline_c_replace_modified fg=160,bg=224 # fg=#d70000,bg=#ffdfdf + ble-face -s vim_airline_c_visual fg=166,bg=228 # fg=#d75f00,bg=#ffff87 + ble-face -s vim_airline_c_visual_modified fg=160,bg=224 # fg=#d70000,bg=#ffdfdf + ble-face -s vim_airline_z_replace fg=255,bg=29 # fg=#eeeeee,bg=#00875f +} diff --git a/.local/share/blesh/contrib/airline/zenburn.bash b/.local/share/blesh/contrib/airline/zenburn.bash new file mode 100644 index 0000000..239a1c1 --- /dev/null +++ b/.local/share/blesh/contrib/airline/zenburn.bash @@ -0,0 +1,21 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/zenburn.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:zenburn/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=-1,bg=18 # fg=-1,bg=#00008b + ble-face -s vim_airline_a_inactive fg=21,bg=-1 # fg=#0000ff,bg=-1 + ble-face -s vim_airline_a_insert fg=-1,bg=201 # fg=-1,bg=#ff00ff + ble-face -s vim_airline_a_replace fg=-1,bg=21 # fg=-1,bg=#0000ff + ble-face -s vim_airline_a_visual fg=-1,bg=30 # fg=-1,bg=#008b8b + ble-face -s vim_airline_b fg=18,bg=252 # fg=#00008b,bg=#d3d3d3 + ble-face -s vim_airline_b_inactive fg=21,bg=-1 # fg=#0000ff,bg=-1 + ble-face -s vim_airline_b_insert fg=201,bg=252 # fg=#ff00ff,bg=#d3d3d3 + ble-face -s vim_airline_b_replace fg=21,bg=252 # fg=#0000ff,bg=#d3d3d3 + ble-face -s vim_airline_b_visual fg=30,bg=252 # fg=#008b8b,bg=#d3d3d3 + ble-face -s vim_airline_c fg=21,bg=-1 # fg=#0000ff,bg=-1 +} diff --git a/.local/share/blesh/contrib/bash-preexec.bash b/.local/share/blesh/contrib/bash-preexec.bash new file mode 100644 index 0000000..ac74c19 --- /dev/null +++ b/.local/share/blesh/contrib/bash-preexec.bash @@ -0,0 +1,180 @@ +# ble/contrib/integration/bash-preexec.bash (C) 2022-2023, akinomyoga + +## @arr[in] precmd_functions +## @arr[in] preexec_functions +## The functions registered to these arrays are executed on PRECMD and +## PREEXEC hooks, respectively. +## +## @fn[in] precmd +## @fn[in] preexec +## If these functions are defined, they are executed on PRECMD and PREEXEC +## hooks, respectively, through "precmd_functions" and "preexec_functions". +## +## +## * Integration with bash-preexec.sh (https://github.com/rcaloras/bash-preexec) +## +## Although this script works without bash-preexec, it provides a better +## integration with bash-preexec when bash-preexec is loaded. The +## integration relies on the following public API of bash-preexec. +## +## @fn __bp_precmd_invoke_functions lastexit lastarg +## @fn __bp_preexec_invoke_functions lastexit lastarg this_command +## @fn __bp_uninstall +## @var __bp_trapdebug_string +## @var __bp_install_string + +function ble/contrib/integration:bash-preexec/add-convenience-functions { + ble/array#remove precmd_functions precmd + ble/array#remove preexec_functions preexec + ble/array#unshift precmd_functions precmd + ble/array#unshift preexec_functions preexec +} + +function ble/contrib/integration:bash-preexec/precmd.hook { + local _ble_local_lastexit=$? _ble_local_lastarg=$_ + + # Emulate bash-preexec variables + __bp_last_ret_value=$_ble_local_lastexit + __bp_last_argument_prev_command=$_ble_local_lastarg + BP_PIPESTATUS=("${BLE_PIPESTATUS[@]}") + local __bp_inside_precmd=1 + + # local __bp_blesh_invoking_through_blesh=1 # XXX + if ble/is-function __bp_precmd_invoke_functions; then + __bp_precmd_invoke_functions "$_ble_local_lastexit" "$_ble_local_lastarg" + else + # For older bash-preexec.sh / without bash-preexec.sh + local _ble_local_hook + for _ble_local_hook in "${precmd_functions[@]}"; do + if ble/bin#has "$_ble_local_hook"; then + ble/util/setexit "$_ble_local_lastexit" "$_ble_local_lastarg" + "$_ble_local_hook" + fi + done + fi +} + +function ble/contrib/integration:bash-preexec/preexec.hook { + local _ble_local_lastexit=$? _ble_local_lastarg=$_ _ble_local_command=$1 + + # Emulate bash-preexec variables + local __bp_inside_preexec=1 + + # local __bp_blesh_invoking_through_blesh=1 # XXX + if ble/is-function __bp_preexec_invoke_functions; then + __bp_preexec_invoke_functions "$_ble_local_lastexit" "$_ble_local_lastarg" + else + # For older bash-preexec.sh / without bash-preexec.sh + local _ble_local_hook + for _ble_local_hook in "${preexec_functions[@]}"; do + if ble/bin#has "$_ble_local_hook"; then + ble/util/setexit "$_ble_local_lastexit" "$_ble_local_lastarg" + "$_ble_local_hook" "$_ble_local_command" + fi + done + fi +} + +## @fn ble/contrib/integration:bash-preexec/attach.hook +## Remove bash-preexec hooks +function ble/contrib/integration:bash-preexec/attach.hook { + local BP_TRAPDEBUG_STRING=${__bp_trapdebug_string:-'__bp_preexec_invoke_exec "$_"'} + + # Remove bash-preexec preexec hook in builtin DEBUG trap. + local trap_string q="'" Q="'\''" + ble/util/assign trap_string 'builtin trap -p DEBUG' + if [[ $trap_string == "trap -- '${BP_TRAPDEBUG_STRING//$q/$Q}' DEBUG" ]]; then + if [[ ${__bp_trap_string-} ]]; then + builtin eval -- "builtin $__bp_trap_string" + else + builtin trap - DEBUG + fi + fi + + if ble/is-function __bp_uninstall; then + __bp_uninstall + else + # For older bash-preexec.sh + + local BP_INSTALL_STRING=${__bp_install_string:-$'__bp_trap_string="$(trap -p DEBUG)"\ntrap - DEBUG\n__bp_install'} + local BP_PROMPT_COMMAND_PREFIX=__bp_precmd_invoke_cmd + local BP_PROMPT_COMMAND_SUFFIX=__bp_interactive_mode + + # Remove __bp_install hook from PROMPT_COMMAND + if [[ ${PROMPT_COMMAND-} == *"$__bp_install_string"* ]]; then + PROMPT_COMMAND="${PROMPT_COMMAND//$BP_INSTALL_STRING[;$'\n']}" # Edge case of appending to PROMPT_COMMAND + PROMPT_COMMAND="${PROMPT_COMMAND//$BP_INSTALL_STRING}" + fi + + # Remove precmd hook from PROMPT_COMMAND + local i prompt_command + for i in "${!PROMPT_COMMAND[@]}"; do + prompt_command=${PROMPT_COMMAND[i]} + case $prompt_command in + ("$BP_PROMPT_COMMAND_PREFIX"|"$BP_PROMPT_COMMAND_SUFFIX") + prompt_command= ;; + (*) + prompt_command=${prompt_command/#"$BP_PROMPT_COMMAND_PREFIX"$'\n'/$'\n'} + prompt_command=${prompt_command%$'\n'"$BP_PROMPT_COMMAND_SUFFIX"} + prompt_command=${prompt_command#$'\n'} + esac + PROMPT_COMMAND[i]=$prompt_command + done + + # Remove preexec hook in the DEBUG trap + local q="'" Q="'\''" trap_string + ble/util/assign trap_string 'trap -p DEBUG' + if [[ $trap_string == "trap -- '${BP_TRAPDEBUG_STRING//$q/$Q}' DEBUG" ]]; then + if [[ ${__bp_trap_string-} ]]; then + builtin eval -- "$__bp_trap_string" + else + trap - DEBUG + fi + fi + fi +} +ble/function#trace ble/contrib/integration:bash-preexec/attach.hook + +## @fn ble/contrib/integration:bash-preexec/detach.hook +function ble/contrib/integration:bash-preexec/detach.hook { + # Reinstall bash-preexec hooks + local BP_INSTALL_STRING=${__bp_install_string-} + [[ ! $BP_INSTALL_STRING ]] && ble/is-function __bp_install && + BP_INSTALL_STRING=$'__bp_trap_string="$(trap -p DEBUG)"\ntrap - DEBUG\n__bp_install' + + builtin eval -- "$__bp_install_string" + + # Note: 重複して登録される (古い bash-preexec.sh) かもしれないし、全 + # く登録されない (bash-preexec.sh をロードしていない時) かもしれない + # ので、ble.sh 側で末尾で一回呼び出す形に修正する。 + ble/contrib/integration:bash-preexec/add-convenience-functions +} + +ble/contrib/integration:bash-preexec/add-convenience-functions +blehook PRECMD!=ble/contrib/integration:bash-preexec/precmd.hook +blehook PREEXEC!=ble/contrib/integration:bash-preexec/preexec.hook +blehook ATTACH!=ble/contrib/integration:bash-preexec/attach.hook +blehook DETACH!=ble/contrib/integration:bash-preexec/detach.hook +if [[ ${bash_preexec_imported-${__bp_imported-}} ]]; then + ble/contrib/integration:bash-preexec/attach.hook +fi + +# prevent bash-preexec.sh to be loaded +blehook ATTACH-=ble/contrib/integration:bash-preexec/loader +blehook POSTEXEC-=ble/contrib/integration:bash-preexec/loader +bash_preexec_imported=defined +__bp_imported=defined + +# XXX: 以下は uninstall で削除しきれなかった時の為の保険。今の所不要に思われる。 +# __bp_blesh_check() { +# if [[ $BLE_ATTACHED && ! ${__bp_blesh_invoking_through_blesh-} ]]; then +# ble/contrib/integration:bash-preexec/attach.hook +# fi +# } +# precmd_function+=(__bp_blesh_check) +# preexec_function+=(__bp_blesh_check) + +# Some settings rely on the internal APIs of bash-preexec. For example, iTerm2 +# shell integration uses "__bp_set_ret_value" and +# "$__bp_last_argument_prev_command". +function __bp_set_ret_value { return ${1:+"$1"}; } diff --git a/.local/share/blesh/contrib/colorglass.bash b/.local/share/blesh/contrib/colorglass.bash new file mode 100644 index 0000000..b1f48ce --- /dev/null +++ b/.local/share/blesh/contrib/colorglass.bash @@ -0,0 +1,415 @@ +# bash + +bleopt/declare -v colorglass_gamma 0 +bleopt/declare -v colorglass_contrast 0 +bleopt/declare -v colorglass_rotate 0 +bleopt/declare -v colorglass_saturation 0 +bleopt/declare -v colorglass_brightness 0 +bleopt/declare -v colorglass_alpha 255 +bleopt/declare -v colorglass_color 0x8888FF +#bleopt/declare -v colorglass_color 0xFF8888 + +function bleopt/check:colorglass_gamma { + if ! ((value=value,value>-100)); then + ble/util/print "bleopt colorglass_gamma: invalid value '$value'" >&2 + return 1 + fi + ble/color/g2sgr/.clear-cache + _ble_contrib_colorglass_gamma=() + return 0 +} +function bleopt/check:colorglass_contrast { + if ! ((value=value,-100<=value&&value<=100)); then + ble/util/print "bleopt colorglass_contrast: invalid value '$value'" >&2 + return 1 + fi + ble/color/g2sgr/.clear-cache + _ble_contrib_colorglass_contrast=() + return 0 +} +function bleopt/check:colorglass_rotate { + ((value=value%360,value<0&&(value+=360))) + ble/color/g2sgr/.clear-cache + return 0 +} +function bleopt/check:colorglass_saturation { + if ! ((value=value,-100<=value&&value<=100)); then + ble/util/print "bleopt colorglass_saturation: invalid value '$value'" >&2 + return 1 + fi + ble/color/g2sgr/.clear-cache + return 0 +} +function bleopt/check:colorglass_brightness { + if ! ((value=value,-100<=value&&value<=100)); then + ble/util/print "bleopt colorglass_brightness: invalid value '$value'" >&2 + return 1 + fi + ble/color/g2sgr/.clear-cache + return 0 +} +function bleopt/check:colorglass_color { + ble/color/g2sgr/.clear-cache + return 0 +} +function bleopt/check:colorglass_alpha { ble/color/g2sgr/.clear-cache; return 0; } + +bleopt -I colorglass_@ + +_ble_contrib_colorglass_gamma=() +function ble/contrib/colorglass/.gamma { + local x=$1 + ret=${_ble_contrib_colorglass_gamma[x]-} + [[ $ret ]] && return 0 + local g=$(((100+bleopt_colorglass_gamma)*_ble_fixed_unit/100)) + ble/fixed-point#pow "$((x*_ble_fixed_unit/255))" "$g" + ble/fixed-point#round "$((ret*255))" + ((ret=ret/_ble_fixed_unit,ret<0?(ret=0):(ret>255&&(ret=255)))) + _ble_contrib_colorglass_gamma[x]=$ret +} + +_ble_contrib_colorglass_contrast=() +function ble/contrib/colorglass/.contrast { + local x=$1 + ret=${_ble_contrib_colorglass_contrast[x]-} + [[ $ret ]] && return 0 + + local c=$bleopt_colorglass_contrast + if ((c==-100)); then + ((ret=x==0?-_ble_fixed_unit:(x==255?_ble_fixed_unit:0))) + else + if ((c>0)); then + ((c=_ble_fixed_unit-c*_ble_fixed_unit/100)) + else + ((c=_ble_fixed_unit*_ble_fixed_unit/(_ble_fixed_unit+c*_ble_fixed_unit/100))) + fi + ble/fixed-point#pow "$((2*x*_ble_fixed_unit/255-_ble_fixed_unit))" "$c" + fi + ble/fixed-point#round "$(((ret+_ble_fixed_unit)*255/2))" + ((ret=ret/_ble_fixed_unit,ret<0?(ret=0):(ret>255&&(ret=255)))) + _ble_contrib_colorglass_contrast[x]=$ret +} + +## @fn ble/contrib/colorglass.filter +## @var[ref] ccode +function ble/contrib/colorglass.filter { + # 24bit color + local R= G= B= dirty= + if ((ccode<16)); then + if ((ccode==7)); then + ((R=G=B=0xAA)) + elif ((ccode==8)); then + ((R=G=B=0x55)) + else + local L=$((ccode>=8?0xFF:0x80)) + ((R=(ccode&1)?L:0)) + ((G=(ccode&2)?L:0)) + ((B=(ccode&4)?L:0)) + fi + elif ((ccode<256)); then + local index_colors=$_ble_color_index_colors_default + [[ $bleopt_term_index_colors == auto ]] || ((index_colors=bleopt_term_index_colors)) + if ((index_colors==88)); then + # xterm-88color (16+4x4x4+8grey) + if ((ccode>=80)); then + ((R=G=B=46+25*(ccode-80))) + else + local k + ((k=(ccode-16)/16 ,R=k?81+k*58:0)) + ((k=(ccode-16)/4%4,G=k?81+k*58:0)) + ((k=(ccode-16)%4 ,B=k?81+k*58:0)) + fi + else + # xterm-256color (16+6x6x6+24grey) + if ((ccode>=232)); then + ((R=G=B=8+10*(ccode-232))) + else + local k + ((k=(ccode-16)/36 ,R=k?55+k*40:0)) + ((k=(ccode-16)/6%6,G=k?55+k*40:0)) + ((k=(ccode-16)%6 ,B=k?55+k*40:0)) + fi + fi + elif ((0x1000000<=ccode&&ccode<=0x1FFFFFF)); then + ((R=0xFF&ccode>>16)) + ((G=0xFF&ccode>>8)) + ((B=0xFF&ccode)) + fi + + local rot=$((bleopt_colorglass_rotate)) + local sat=$((bleopt_colorglass_saturation)) + local bright=$((bleopt_colorglass_brightness)) + if ((rot||sat||bright)); then + dirty=1 + local Min x y h + case $((R<=B?(R<=G?0:1):(G<=B?1:2))) in + (0) Min=$R x=$((G-Min)) y=$((B-Min)) h=1200 ;; + (1) Min=$G x=$((B-Min)) y=$((R-Min)) h=2400 ;; + (2) Min=$B x=$((R-Min)) y=$((G-Min)) h=0 ;; + esac + local Range=$((x>y?x:y)) + if ((Range)); then + if ((x>y)); then + ((h+=y*600/x)) + else + ((h+=1200-x*600/y)) + fi + fi + ((h=(h+rot*10)%3600)) + + if ((bright)); then + ((bright=_ble_fixed_unit*bright/100)) + if ((bright<0)); then + ((bright=_ble_fixed_unit+bright)) + ((Min=Min*bright/_ble_fixed_unit)) + ((Range=Range*bright/_ble_fixed_unit)) + else + ((bright=_ble_fixed_unit-bright)) + ((Min=255-(255-Min)*bright/_ble_fixed_unit)) + ((Range=Range*bright/_ble_fixed_unit)) + fi + fi + + if ((sat)); then + ((sat=_ble_fixed_unit*sat/100)) + if ((sat<0)); then + ((sat=-sat)) + ((Min+=Range*sat/(2*_ble_fixed_unit))) + ((Range=Range*(_ble_fixed_unit-sat)/_ble_fixed_unit)) + else + local delta=$(((255-Range)*sat/_ble_fixed_unit)) Max + ((Max=Min+Range+delta/2,Max>255&&(Max=255))) + ((Min-=delta/2,Min<0&&(Min=0))) + ((Range=Max-Min)) + fi + fi + + local h1 h2 x=$Min y=$Min z=$Min + ((h1=h%1200,h2=1200-h1, + x+=Range*(h2<600?h2:600)/600, + y+=Range*(h1<600?h1:600)/600)) + case $((h/1200)) in + (0) R=$x G=$y B=$z ;; + (1) R=$z G=$x B=$y ;; + (2) R=$y G=$z B=$x ;; + esac + fi + + local alpha=$((bleopt_colorglass_alpha)) + if ((alpha!=255)); then + dirty=1 + local min max ofac + if ((RB?G:B)) + else + ((min=GB?R:B)) + fi + ((ofac=max<255-min?max:255-min)) + ((ofac=ofac*2<255?ofac*2:255)) + ((alpha=alpha*ofac/255)) + if ((alpha)); then + local c1=$((bleopt_colorglass_color)) + local r1=$((0xFF&c1>>16)) + local g1=$((0xFF&c1>>8)) + local b1=$((0xFF&c1)) + ((R=r1+(R-r1)*alpha/255)) + ((G=g1+(G-g1)*alpha/255)) + ((B=b1+(B-b1)*alpha/255)) + fi + fi + + if ((bleopt_colorglass_contrast)); then + dirty=1 + local ret + ble/contrib/colorglass/.contrast "$R"; R=$ret + ble/contrib/colorglass/.contrast "$G"; G=$ret + ble/contrib/colorglass/.contrast "$B"; B=$ret + fi + + if ((bleopt_colorglass_gamma)); then + dirty=1 + local ret + ble/contrib/colorglass/.gamma "$R"; R=$ret + ble/contrib/colorglass/.gamma "$G"; G=$ret + ble/contrib/colorglass/.gamma "$B"; B=$ret + fi + + ((dirty)) && ((ccode=0x1000000|R<<16|G<<8|B)) + return 0 +} +_ble_color_color2sgr_filter=ble/contrib/colorglass.filter + +_ble_fixed_unit=0x10000 +_ble_fixed_e=$((0x2b7e1)) +_ble_fixed_ln2=$((0xb172)) +_ble_fixed_log2=$((0x4d10)) + +function ble/fixed-point#tostr { + ret=$1 + ((ret=(ret*1000000+5)/(_ble_fixed_unit*10))) + ret=0000$ret + ret=${ret::${#ret}-5}.${ret:${#ret}-5} + ble/string#match "$ret" '^0+' && + ret=${ret:${#BASH_REMATCH}} + ret=${ret/#./0.} +} + +function ble/fixed-point#round { + local x=$1 + ((x+=x>=0?_ble_fixed_unit/2:-_ble_fixed_unit/2, + ret=x/_ble_fixed_unit*_ble_fixed_unit)) +} + +function ble/fixed-point#mul { + if (($#)); then + ret=$1; shift + local a + for a; do ((ret=ret*a/_ble_fixed_unit)); done + else + ret=$_ble_fixed_unit + fi +} + +_ble_fixed_sqrt=() +function ble/fixed-point#sqrt { + local x=$1 + if ((x<=0)); then + ret=0 + elif [[ ${_ble_fixed_sqrt[x]} ]]; then + ret=${_ble_fixed_sqrt[x]} + else + local y=$x c=0 dy + while ((c++<=16&&(dy=(x*_ble_fixed_unit-y*y)/(2*y)))); do + ((y+=dy)) + done + + # 微修正 + local res=$((x*_ble_fixed_unit-y*y)) + if ((res<0)); then + while ((res+y<=0)); do + ((res+=2*y---1)) + done + elif ((res>0)); then + while ((0>=1)); do + ((xx=xx*xx/_ble_fixed_unit)) + done + ((x>_ble_fixed_unit)) && ble/array#reverse fac + ble/fixed-point#mul "${fac[@]}" + ((out=out*ret/_ble_fixed_unit)) + fi + + if ((p=y&0xFFFF)); then + xx=$x fac=() + while + ble/fixed-point#sqrt "$xx" + xx=$ret + (((p<<=1)&_ble_fixed_unit)) && ble/array#push fac "$xx" + ((p&0xFFFF)) + do :; done + ((x<_ble_fixed_unit)) && ble/array#reverse fac + ble/fixed-point#mul "${fac[@]}" + ((out=out*ret/_ble_fixed_unit)) + fi + fi + ((ret=out*sgn)) +} +function ble/fixed-point#exp { + ble/fixed-point#pow "$_ble_fixed_e" "$1" +} + +function ble/fixed-point#lb { + local x=$1 + ((x<0&&(x=-x))) + if ((x==0)); then + ((ret=-32*_ble_fixed_unit)) + elif ((x==_ble_fixed_unit)); then + ret=0 + else + local p=0 + if ((x>=_ble_fixed_unit)); then + while ((x>=256*_ble_fixed_unit)); do ((p+=8,x>>=8)); done + while ((x>=8*_ble_fixed_unit)); do ((p+=3,x>>=3)); done + while ((x>=2*_ble_fixed_unit)); do ((p+=1,x>>=1)); done + else + while ((x<256)); do ((p-=8,x<<=8)); done + while ((x<_ble_fixed_unit/8)); do ((p-=3,x<<=3)); done + while ((x<_ble_fixed_unit)); do ((p--,x<<=1)); done + fi + local out=$((p*_ble_fixed_unit)) + + local bit=$_ble_fixed_unit l + ((ret=2*_ble_fixed_unit)) + for l in {1..8}; do + ((bit/=2)) + ble/fixed-point#sqrt "$ret" + ((x>=ret)) && ((x=x*_ble_fixed_unit/ret,out+=bit)) + done + ((x-=_ble_fixed_unit)) + ((out+=(_ble_fixed_unit-x/2)*x/_ble_fixed_unit*_ble_fixed_unit/_ble_fixed_ln2)) + ret=$out + fi +} +function ble/fixed-point#ln { + ble/fixed-point#lb "$1" + ((ret=ret*_ble_fixed_ln2/_ble_fixed_unit)) +} +function ble/fixed-point#log { + ble/fixed-point#lb "$1" + ((ret=ret*_ble_fixed_log2/_ble_fixed_unit)) +} + +# --- test codes --- + +# ble/fixed-point#lb "$((e=2718281828*_ble_fixed_unit/1000000000))" +# printf "lb e = %x\n" "$ret" +# ble/fixed-point#tostr "$((_ble_fixed_unit*_ble_fixed_unit/ret))" +# echo "ln 2 = $ret" +# ble/fixed-point#log "$((2*_ble_fixed_unit))" +# ble/fixed-point#tostr "$ret" +# echo "$ret" + +# ble/fixed-point#sqrt $((0x0100)) +# time for a in {0..256}; do +# ble/fixed-point#sqrt "$((a*_ble_fixed_unit/256))" +# sqrt[a]=$ret +# # ble/fixed-point#tostr "$((ret*ret*256/_ble_fixed_unit))" +# # printf "$a -> %x -> $ret\n" "$sqrt" +# done +# ble/fixed-point#pow $((2*_ble_fixed_unit)) $((3*_ble_fixed_unit)) +# ble/fixed-point#tostr "$ret" +# echo "$ret" +# ble/fixed-point#pow $((2*_ble_fixed_unit)) $((_ble_fixed_unit/2)) +# ble/fixed-point#tostr "$ret" +# echo "$ret" + +# for x in {0..256}; do +# for y in {0..256}; do +# ble/fixed-point#pow "$((x*256))" "$((y*256))" +# ble/fixed-point#tostr "$ret" +# echo "$x $y $ret" +# done +# echo +# done | awk 'NF == 3 {print $1,$2,$3,($1/256)^($2/256);next}{print}' > colorglass.pow.txt diff --git a/.local/share/blesh/contrib/config/execmark.bash b/.local/share/blesh/contrib/config/execmark.bash new file mode 100644 index 0000000..d14e7c4 --- /dev/null +++ b/.local/share/blesh/contrib/config/execmark.bash @@ -0,0 +1,155 @@ +# blesh/contrib/config/execmark.bash (C) 2022, Koichi Murase +# +# Example setup +# +# ```bash +# # blerc +# ble-import -d contrib/config/execmark +# bleopt exec_elapsed_enabled='_ble_exec_time_tot>=1000' +# ``` +# + +_ble_contrib_config_execmark_status_name=( + [0]=EXIT_SUCCESS + [1]=EXIT_FAILURE + [2]=usage_error + + # Used by bash + [124]=progcomp_restart + [126]=permisson_denied + [127]=command_not_found + + # From /usr/include/sysexits.h + [64]=EX_USAGE + [65]=EX_DATAERR + [66]=EX_NOINPUT + [67]=EX_NOUSER + [68]=EX_NOHOST + [69]=EX_UNAVAILABLE + [70]=EX_SOFTWARE + [71]=EX_OSERR + [72]=EX_OSFILE + [73]=EX_CANTCREAT + [74]=EX_IOERR + [75]=EX_TEMPFAIL + [76]=EX_PROTOCOL + [77]=EX_NOPERM + [78]=EX_CONFIG +) +function ble/contrib/config:execmark/.statusname { + name= + if [[ ${name:=${_ble_contrib_config_execmark_status_name[exit]}} ]]; then + return 0 + elif ((128<=exit&&exit<=255)) && [[ ${name:=${_ble_builtin_trap_sig_name[exit&127]}} ]]; then + return 0 + else + return 1 + fi +} + +function ble/contrib/config:execmark/.getsec { + local msec=$1 sec + if ((msec==0)); then + ret=0 + elif ((msec<1000)); then + ret=${msec}ms + else + ((sec=msec/1000,msec%=1000)) + msec=000$msec msec=${msec:${#msec}-3} + ret=$sec.$msec + fi +} + +function ble/contrib/config:execmark/postexec.hook { + local command=$_ble_edit_exec_BASH_COMMAND + + if ((_ble_edit_exec_lastexit)) || ble/exec/time#mark-enabled; then + local ret + local sgr=$'\e[;94m' sgrC=$'\e[38:5:244m' sgr0=$'\e[m' + ble/color/face2sgr-ansi syntax_varname; local sgrV=$ret + ble/color/face2sgr-ansi command_function; local sgrS=$ret + ble/color/face2sgr-ansi varname_number; local sgrN=$ret + + # exit + if ((_ble_edit_exec_lastexit)); then + local sgrE=$'\e[;91m' + local exit=$_ble_edit_exec_lastexit name= + if ble/contrib/config:execmark/.statusname; then + exit=$'\e[1m'"$name"$'\e[22m'" ($sgrN$exit$sgrE)" + else + exit="exit $sgrN$exit$sgrE" + fi + local mark=$sgrE'[ble: '$exit']'$sgr0 + x=0 y=0 g=0 LINES=1 ble/canvas/trace "$mark" confine:truncate + ble/util/buffer.print "$ret" + fi + + # ata + local ata=$_ble_exec_time_ata + local d=${#ata} sec min hour + if ((d<=3)); then + ata=${ata}us + elif ((d<=5)); then + ata=${ata::d-3}.${ata:d-3:6-d}ms + elif ((d<=6)); then + ata=${ata::3}ms + elif ((d<=9)); then + ata=${ata::${#ata}-6}.${ata:${#ata}-6:3}s + elif ((sec=ata/(1000*1000),min=sec/60,sec%=60,min<100)); then + ata="${min}m${sec}s" + elif ((hour=min/60,min%=60,hour<100)); then + ata="${hour}h${min}m${sec}s" + else + ata="$((hour/24))d$((hour%24))h${min}m" + fi + ata="${sgrV}elapsed$sgr $sgrN$ata$sgr" + + # cpu + local cpu='--.-%' + if ((_ble_exec_time_tot)); then + cpu=$(((_ble_exec_time_usr+_ble_exec_time_sys)*1000/_ble_exec_time_tot)) + cpu=$((cpu/10)).$((cpu%10))% + fi + cpu="${sgrV}CPU$sgr $sgrN$cpu$sgr" + if [[ $_ble_exec_time_usr_self && $_ble_exec_time_sys_self ]]; then + local usr0=$_ble_exec_time_usr_self + local sys0=$_ble_exec_time_sys_self + local usr1=$((_ble_exec_time_usr-_ble_exec_time_usr_self)) + local sys1=$((_ble_exec_time_sys-_ble_exec_time_sys_self)) + + local ret max=0 + ble/contrib/config:execmark/.getsec "$usr0"; local usr0s=$ret + ble/contrib/config:execmark/.getsec "$sys0"; local sys0s=$ret + ((usr0>max)) && max=$usr0 + ((sys0>max)) && max=$sys0 + if ((usr1||sys1)); then + ble/contrib/config:execmark/.getsec "$usr1"; local usr1s=$ret + ble/contrib/config:execmark/.getsec "$sys1"; local sys1s=$ret + ((usr1>max)) && max=$usr1 + ((sys1>max)) && max=$sys1 + fi + + ((usr0==max)) && usr0s=$'\e[1m'$usr0s$'\e[22m' + ((sys0==max)) && sys0s=$'\e[1m'$sys0s$'\e[22m' + cpu="$cpu $sgrS(self)${sgrV}usr$sgrN$usr0s$sgr/${sgrV}sys$sgrN$sys0s$sgr" + if ((usr1||sys1)); then + ((usr1==max)) && usr1s=$'\e[1m'$usr1s$'\e[22m' + ((sys1==max)) && sys1s=$'\e[1m'$sys1s$'\e[22m' + cpu="$cpu+$sgrS(child)${sgrV}usr$sgrN${usr1s}$sgr/${sgrV}sys$sgrN${sys1s}$sgr" + fi + else + local ret + ble/contrib/config:execmark/.getsec "$_ble_exec_time_usr"; local usr=$ret + ble/contrib/config:execmark/.getsec "$_ble_exec_time_sys"; local sys=$ret + cpu="$cpu ${usr}usr/${sys}sys" + fi + + local msg=$sgr'[ble: '$ata', '$cpu']'$sgr0 + local ret; ble/string#ltrim "$command"; msg="$msg${ret:+ $sgrC$ret$sgr0}" + x=0 y=0 g=0 LINES=1 ble/canvas/trace "$msg" confine:truncate + ble/util/buffer.print "$ret" + fi +} +bleopt exec_errexit_mark= +bleopt exec_elapsed_mark= +blehook POSTEXEC!=ble/contrib/config:execmark/postexec.hook diff --git a/.local/share/blesh/contrib/config/github265-prompt-path-level-colors.bash b/.local/share/blesh/contrib/config/github265-prompt-path-level-colors.bash new file mode 100644 index 0000000..0187307 --- /dev/null +++ b/.local/share/blesh/contrib/config/github265-prompt-path-level-colors.bash @@ -0,0 +1,31 @@ +# blesh-contrib/config/github265-prompt-path-level-colors.bash (C) 2022, Koichi Murase +# +# Example: +# +# ble-import /config/github265-prompt-path-level-colors +# PS1='[\u@\h \q{github265/pwd}]\$ ' +# +_ble_contrib_config_github265_pwd_gspecs=(fg=27 fg=57 fg=141 fg=63) + +function ble/prompt/backslash:github265/pwd { + ble/prompt/unit/add-hash '$PWD' + ble/prompt/.update-working-directory + local str=$prompt_cache_wd + + local -a dirs=() + while ble/string#match "$str" '^([^/]*/|[^/]+$)'; do + ble/array#push dirs "$BASH_REMATCH" + str=${str:${#BASH_REMATCH}} + done + + local count=${#dirs[@]} + local n=${#_ble_contrib_config_github265_pwd_gspecs[@]} index ret + for dir in "${dirs[@]}"; do + ((index=--count,index + +# The option "bleopt complete_source_sabbrev_command_ignore" specifies a +# colon-separated list of glob patterns of command names for which the sabbrev +# completion should be suppressed. +bleopt/declare -v complete_source_sabbrev_command_ignore '' + +_ble_contrib_config_github288_command_ignore_patterns=() +function bleopt/check:complete_source_sabbrev_command_ignore { + if [[ $value ]]; then + ble/string#split _ble_contrib_config_github288_command_ignore_patterns : "$value" + else + _ble_contrib_config_github288_command_ignore_patterns=() + fi +} +bleopt -I complete_source_sabbrev_command_ignore + +# This is an "advice" function for the exiting function +# "ble/complete/source:sabbrev", i.e., the function to modify the behavior of +# the original function. We insert some codes before starting the original +# processing. +function ble/contrib/config:github288/filter-sabbrev-completion.advice { + # If we are generating sabbrevs as a part of argument completions and if + # there are any ignore patterns for the command names in + # "complete_source_sabbrev_command_ignore", we make the sabbrev completions + # inactive for the commands matching an ignore pattern. + if [[ ${ADVICE_FUNCNAME[1]} == ble/complete/source:argument ]]; then + if ((${#_ble_contrib_config_github288_command_ignore_patterns[@]})); then + # Extract the command name and arguments on the current caret position. + local comp_words comp_line comp_point comp_cword + ble/syntax:bash/extract-command "$_ble_edit_ind" || return 1 + + # If the command word is simple enough, we evaluate the command word to + # resolve quoting and parameter expansions. + local cmd=${comp_words[0]} ret + ble/syntax:bash/simple-word/safe-eval "$cmd" nonull && cmd=$ret + + # If the command name matches any pattern of the ignored list, we return + # the function without calling the original function. + ble/complete/string#match-patterns "$cmd" "${_ble_contrib_config_github288_command_ignore_patterns[@]}" && + return 1 + fi + fi + + # We call the original "ble/complete/source:sabbrev" here. The original + # function, i.e., the advice target, can be called by ble/function#advice/do. + ble/function#advice/do +} + +function ble/contrib/config:github288/initialize.hook { + # We hook the above "advice" function to "ble/complete/source:sabbrev". + ble/function#advice around ble/complete/source:sabbrev ble/contrib/config:github288/filter-sabbrev-completion.advice +} +blehook/eval-after-load complete ble/contrib/config:github288/initialize.hook diff --git a/.local/share/blesh/contrib/config/github296-named-execmark.bash b/.local/share/blesh/contrib/config/github296-named-execmark.bash new file mode 100644 index 0000000..fe98094 --- /dev/null +++ b/.local/share/blesh/contrib/config/github296-named-execmark.bash @@ -0,0 +1,21 @@ +# blesh/contrib/config/github296-named-execmark.bash (C) 2023, Koichi Murase + +function ble/contrib/config:github296/named-execmark.hook { + local lastexit=$? command=$1 + + if ((lastexit)) && ! ble/string#match "$command" $'^[[:space:]]*#[^\n]+$'; then + local sgr=$'\e[;94m' sgr0=$'\e[m' sgrE=$'\e[;91m' ret + ble/color/face2sgr-ansi varname_number; local sgrN=$ret + + local exit=$lastexit name= + if ((exit>=128)) && [[ ${name:=${_ble_builtin_trap_sig_name[exit&127]}} ]]; then + exit=$'\e[1m'"$name"$'\e[22m'" ($sgrN$exit$sgrE)" + else + exit="exit $sgrN$exit$sgrE" + fi + local mark=$sgrE'[ble: '$exit']'$sgr0 + ble/util/buffer.print "$mark" + fi +} +bleopt exec_errexit_mark= +blehook POSTEXEC!=ble/contrib/config:github296/named-execmark.hook diff --git a/.local/share/blesh/contrib/config/github302-perlre-server.bash b/.local/share/blesh/contrib/config/github302-perlre-server.bash new file mode 100644 index 0000000..70f8bc1 --- /dev/null +++ b/.local/share/blesh/contrib/config/github302-perlre-server.bash @@ -0,0 +1,76 @@ +# ble.sh contrib/config/github302-perlre-server.bash +# Copyright 2023 Britton Kerin +# Copyright 2023 Koichi Murase + +# This file illustrates an example usage of "ble/util/bgproc#open" from module +# "util.bgproc". The server code in the shell function +# "ble/contrib/config:github302/perlre-server" was taken from the report by +# Britton Kerin at Ref. [1]. +# +# [1] https://lists.gnu.org/archive/html/help-bash/2023-03/msg00068.html +# +# Note: This example does not consider the case that the background process +# terminates by an error, crashes, etc. + +ble-import util.bgproc + +function ble/contrib/config:github302/perlre-server { + exec perl <(cat <<' END_PERL' + use strict; use warnings; + $| = 1; + while ( 1 ) { + my $rex = <>; + chomp($rex); + my $str = <>; + if ( $str =~ m/$rex/ ) { + # FIXME: Sadly this die argument doesn't show anywhere: + defined($1) or die 'group $1 unexpectedly undefined'; + print length($1); + } + print "\n"; + } + END_PERL + ) 2>/dev/tty +} + +if ble/util/bgproc#open perlre_server ble/contrib/config:github302/perlre-server; then + # The main shell can send a request to fd ${perlre_server_bgproc[1]} and can + # read from fd ${perlre_server_bgproc[0]}. + ble/util/print "ble/contrib/config:github30: perlre-server (${perlre_server_bgproc[4]}) has started." >&2 +else + ble/util/print 'ble/contrib/config:github30: failed to start perlre-server' >&2 + return 1 +fi + +## @fn ble/contrib/config:github302/perlre-match rex str +## Matches the regex REX against the string STR and returns the length of the +## string captured by the first matching group ($1). +## +## @param[in] rex +## The regex to match in "perlre" syntax. +## @param[in] str +## The string to be matched by REX. +## @var[out] ret +## The resulting length of the string matched by the first capture group is +## stored in this variable. When REX does not match STR, an empty value is +## stored in this variable. +## @exit 0 if REX successfully matches STR, or otherwise 1. +## +function ble/contrib/config:github302/perlre-match { + local IFS=$' \t\n' + + # Only takes the first lines of both because newlines in requests confuse the + # server. + local rex=${1%%$'\n'*} str=${2%%$'\n'*} + + # We send the requests to fd ${perlre_server_bgproc[1]}. + ble/util/print-lines "$rex" "$str" >&"${perlre_server_bgproc[1]}" + + # We can read the resposnes from fd ${perlre_server_bgproc[0]}. We set a + # timeout to `read' so that it doesn't lock forever in case that the expected + # output is not obtained by accident (e.g., for the reason that REX did not + # contain any capturing group accessible through $1). + ble/bash/read-timeout 1 -r -u "${perlre_server_bgproc[0]}" ret + + [[ $ret ]] +} diff --git a/.local/share/blesh/contrib/fzf-completion.bash b/.local/share/blesh/contrib/fzf-completion.bash new file mode 100644 index 0000000..5f83287 --- /dev/null +++ b/.local/share/blesh/contrib/fzf-completion.bash @@ -0,0 +1,62 @@ +# ble/contrib/integration/fzf-completion.bash (C) 2020-2023, akinomyoga + +ble-import contrib/integration/fzf-initialize + +[[ $- == *i* ]] || return 0 + +# fzf/shell/completion.bash を未ロードの時のみロードする +if ! ble/is-function _fzf_complete; then + if [[ -f $_ble_contrib_fzf_base/completion.bash ]]; then + source "$_ble_contrib_fzf_base/completion.bash" + elif [[ -f $_ble_contrib_fzf_base/shell/completion.bash ]]; then + source "$_ble_contrib_fzf_base/shell/completion.bash" + elif [[ $_ble_contrib_fzf_base == */share/fzf && -f /etc/bash_completion.d/fzf ]]; then + source /etc/bash_completion.d/fzf + fi +fi + +# clear blesh completer for cd +blehook/eval-after-load complete 'builtin unset -f ble/cmdinfo/complete:cd' + +# patch fzf functions +ble/function#advice around __fzf_generic_path_completion _fzf_complete.advice +ble/function#advice around _fzf_complete _fzf_complete.advice +ble/function#advice around _fzf_complete_kill _fzf_complete.advice +function _fzf_complete.advice { + if [[ ! ${_ble_attached-} ]]; then + ble/function#push caller 'builtin caller ${1+"$(($1+6))"}' + ble/function#advice/do + ble/function#pop caller + return 0 + fi + + [[ :$comp_type: == *:auto:* || :$comp_type: == *:[maA]:* ]] && return 0 + compopt -o ble/syntax-raw + if [[ ! ${_ble_contrib_fzf_comp_words_raw-} ]]; then + local _ble_contrib_fzf_comp_words_raw=1 + local COMP_WORDS; COMP_WORDS=("${comp_words[@]}") + local COMP_CWORD=$comp_cword + local COMP_LINE=$comp_line COMP_POINT=$comp_point + fi + ble/function#push printf '[[ $1 == "\e[5n" ]] || builtin printf "$@"' + ble/function#push caller 'builtin caller ${1+"$(($1+6))"}' + ble/term/leave-for-widget + if [[ ${ADVICE_WORDS[0]} == _fzf_complete ]]; then + ble/function#advice/do >&"${_ble_util_fd_tty_stdout:-1}" 2>&"${_ble_util_fd_tty_stderr:-2}" + else + ble/function#advice/do >&"${_ble_util_fd_tty_stdout:-1}" 2>&"${_ble_util_fd_tty_stderr:-2}" <&"${_ble_util_fd_tty_stdin:-0}" + fi + ble/term/enter-for-widget + ble/function#pop caller + ble/function#pop printf + ble/textarea#invalidate + + # 単一候補生成の場合は他の候補 (sabbrev 等) を消去して単一確定させる + if ((ADVICE_EXIT==0&&${#COMPREPLY[@]}==1)); then + compopt -o ble/no-default + ble/complete/candidates/clear + [[ $old_cand_count ]] && + ! ble/variable#is-global old_cand_count && + old_cand_count=0 + fi +} diff --git a/.local/share/blesh/contrib/fzf-git.bash b/.local/share/blesh/contrib/fzf-git.bash new file mode 100644 index 0000000..059b70d --- /dev/null +++ b/.local/share/blesh/contrib/fzf-git.bash @@ -0,0 +1,322 @@ +# Copyright (c) 2016, 2022 Junegunn Choi +# ble/contrib/integration/fzf-git.bash (C) 2020, 2023, akinomyoga +# +# 2020-04-16 https://gist.github.com/junegunn/8b572b8d4b5eddd8b85e5f4d40f17236 (Revision 2019-03-14) +# 2023-06-30 https://gist.github.com/junegunn/8b572b8d4b5eddd8b85e5f4d40f17236 (Revision 2022-08-16) +# 2023-06-30 https://github.com/junegunn/fzf-git.sh/commit/4bc0323b4822b3426989863996cc266c52c7f25a +# 2023-06-30 https://github.com/junegunn/fzf-git.sh/commit/b6192ec86609afea761c7d3954f9b539a512dc80 +# 2023-11-09 https://github.com/junegunn/fzf-git.sh/blob/aacab4ae557657e0f9de288d688f312a28b86d21/fzf-git.sh + +if [[ $- != *i* ]]; then + if (($# == 1)); then + function ble/contrib/integration:fzf-git/sub:branches { + git branch "$@" --sort=-committerdate --sort=-HEAD --format=$'%(HEAD) %(color:yellow)%(refname:short) %(color:green)(%(committerdate:relative))\t%(color:blue)%(subject)%(color:reset)' --color=always | column -ts$'\t' + } + function ble/contrib/integration:fzf-git/sub:refs { + git for-each-ref --sort=-creatordate --sort=-HEAD --color=always --format=$'%(refname) %(color:green)(%(creatordate:relative))\t%(color:blue)%(subject)%(color:reset)' | + builtin eval -- "$1" | + sed 's#^refs/remotes/#\x1b[95mremote-branch\t\x1b[33m#; s#^refs/heads/#\x1b[92mbranch\t\x1b[33m#; s#^refs/tags/#\x1b[96mtag\t\x1b[33m#; s#refs/stash#\x1b[91mstash\t\x1b[33mrefs/stash#' | + column -ts$'\t' + } + case $1 in + (branches) + printf '%s\n' $'CTRL-O (open in browser) ╱ ALT-A (show all branches)\n' + ble/contrib/integration:fzf-git/sub:branches + ;; + (all-branches) + printf '%s\n' $'CTRL-O (open in browser)\n' + ble/contrib/integration:fzf-git/sub:branches -a + ;; + (refs) + printf '%s\n' $'CTRL-O (open in browser) ╱ ALT-E (examine in editor) ╱ ALT-A (show all refs)\n' + ble/contrib/integration:fzf-git/sub:refs 'grep -v ^refs/remotes' + ;; + (all-refs) + printf '%s\n' $'CTRL-O (open in browser) ╱ ALT-E (examine in editor)\n' + ble/contrib/integration:fzf-git/sub:refs 'cat' + ;; + (nobeep) ;; + (*) exit 1 ;; + esac + elif (($# > 1)); then + set -e + + branch=$(git rev-parse --abbrev-ref HEAD 2> /dev/null) + if [[ $branch = HEAD ]]; then + branch=$(git describe --exact-match --tags 2> /dev/null || git rev-parse --short HEAD) + fi + + # Only supports GitHub for now + case $1 in + (commit) + hash=$(grep -o "[a-f0-9]\{7,\}" <<< "$2") + path=/commit/$hash + ;; + (branch|remote-branch) + branch=$(sed 's/^[* ]*//' <<< "$2" | cut -d' ' -f1) + remote=$(git config branch."${branch}".remote || printf 'origin\n') + branch=${branch#$remote/} + path=/tree/$branch + ;; + (remote) + remote=$2 + path=/tree/$branch + ;; + (file) path=/blob/$branch/$(git rev-parse --show-prefix)$2 ;; + (tag) path=/releases/tag/$2 ;; + (*) exit 1 ;; + esac + + remote=${remote:-$(git config branch."${branch}".remote || printf 'origin\n')} + remote_url=$(git remote get-url "$remote" 2> /dev/null || printf '%s\n' "$remote") + + if [[ $remote_url =~ ^git@ ]]; then + url=${remote_url%.git} + url=${url#git@} + url=https://${url/://} + elif [[ $remote_url =~ ^http ]]; then + url=${remote_url%.git} + fi + + case $(uname -s) in + (Darwin) open "$url$path" ;; + (*) xdg-open "$url$path" ;; + esac + fi + exit 0 +fi + +#------------------------------------------------------------------------------ + +ble-import contrib/integration/fzf-initialize + +[[ $- == *i* ]] || return 0 + +## @fn ble/contrib/integration:fzf-git/initialize bash_source +## @param[in] bash_source +## @var[out] __fzf_git +function ble/contrib/integration:fzf-git/initialize { + local ret + ble/util/readlink "$1" + __fzf_git=$ret +} +ble/contrib/integration:fzf-git/initialize "${BASH_SOURCE[0]:-}" + +# GIT heart FZF +# ------------- + +#------------------------------------------------------------------------------ +# Redefine this function to change the options +_fzf_git_fzf() { + fzf-tmux -p80%,60% -- \ + --layout=reverse --multi --height=50% --min-height=20 --border \ + --border-label-pos=2 \ + --color='header:italic:underline,label:blue' \ + --preview-window='right,50%,border-left' \ + --bind='ctrl-/:change-preview-window(down,50%,border-top|hidden|)' "$@" +} + +function ble/contrib/integration:fzf-git/fzf { + [[ $_ble_term_state == internal ]] && ble/term/leave-for-widget + _fzf_git_fzf "$@" + local ext=$? + [[ $_ble_term_state == internal ]] && ble/term/enter-for-widget + return "$ext" +} + +_fzf_git_check() { + git rev-parse HEAD > /dev/null 2>&1 && return 0 + + [[ -n $TMUX ]] && tmux display-message "Not in a git repository" + return 1 +} + +if [[ -z $_fzf_git_cat ]]; then + # Sometimes bat is installed as batcat + export _fzf_git_cat="cat" + _fzf_git_bat_options="--style='${BAT_STYLE:-full}' --color=always --pager=never" + if command -v batcat > /dev/null; then + _fzf_git_cat="batcat $_fzf_git_bat_options" + elif command -v bat > /dev/null; then + _fzf_git_cat="bat $_fzf_git_bat_options" + fi +fi + +_fzf_git_files() { + _fzf_git_check || return "$?" + (git -c color.status=always status --short --no-branch + git ls-files | grep -vxFf <(git status -s | grep '^[^?]' | cut -c4-; ble/util/print :) | sed 's/^/ /') | + ble/contrib/integration:fzf-git/fzf -m --ansi --nth 2..,.. \ + --border-label '📁 Files' \ + --header $'CTRL-O (open in browser) ╱ ALT-E (open in editor)\n\n' \ + --bind "ctrl-o:execute-silent:bash $__fzf_git file {-1}" \ + --bind "alt-e:execute:${EDITOR:-vim} {-1} > /dev/tty" \ + --preview "git diff --no-ext-diff --color=always -- {-1} | sed 1,4d; $_fzf_git_cat {-1}" "$@" | + cut -c4- | sed 's/.* -> //' +} + +_fzf_git_branches() { + _fzf_git_check || return "$?" + bash "$__fzf_git" branches | + ble/contrib/integration:fzf-git/fzf --ansi \ + --border-label '🌲 Branches' \ + --header-lines 2 \ + --tiebreak begin \ + --preview-window down,border-top,40% \ + --color hl:underline,hl+:underline \ + --no-hscroll \ + --bind 'ctrl-/:change-preview-window(down,70%|hidden|)' \ + --bind "ctrl-o:execute-silent:bash $__fzf_git branch {}" \ + --bind "alt-a:change-prompt(🌳 All branches> )+reload:bash \"$__fzf_git\" all-branches" \ + --preview 'git log --oneline --graph --date=short --color=always --pretty="format:%C(auto)%cd %h%d %s" $(sed s/^..// <<< {} | cut -d" " -f1)' "$@" | + sed 's/^..//' | cut -d' ' -f1 +} + +_fzf_git_tags() { + _fzf_git_check || return "$?" + git tag --sort -version:refname | + ble/contrib/integration:fzf-git/fzf --preview-window right,70% \ + --border-label '📛 Tags' \ + --header $'CTRL-O (open in browser)\n\n' \ + --bind "ctrl-o:execute-silent:bash $__fzf_git tag {}" \ + --preview 'git show --color=always {}' "$@" +} + +_fzf_git_hashes() { + _fzf_git_check || return "$?" + git log --date=short --format="%C(green)%C(bold)%cd %C(auto)%h%d %s (%an)" --graph --color=always | + ble/contrib/integration:fzf-git/fzf --ansi --no-sort --bind 'ctrl-s:toggle-sort' \ + --border-label '🍡 Hashes' \ + --header $'CTRL-O (open in browser) ╱ CTRL-D (diff) ╱ CTRL-S (toggle sort)\n\n' \ + --bind "ctrl-o:execute-silent:bash $__fzf_git commit {}" \ + --bind 'ctrl-d:execute:grep -o "[a-f0-9]\{7,\}" <<< {} | head -n 1 | xargs git diff > /dev/tty' \ + --color hl:underline,hl+:underline \ + --preview 'grep -o "[a-f0-9]\{7,\}" <<< {} | head -n 1 | xargs git show --color=always' "$@" | + awk 'match($0, /[a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9]*/) { print substr($0, RSTART, RLENGTH) }' +} + +_fzf_git_remotes() { + _fzf_git_check || return "$?" + git remote -v | awk '{print $1 "\t" $2}' | uniq | + ble/contrib/integration:fzf-git/fzf --tac \ + --border-label '📡 Remotes' \ + --header $'CTRL-O (open in browser)\n\n' \ + --bind "ctrl-o:execute-silent:bash $__fzf_git remote {1}" \ + --preview-window right,70% \ + --preview 'git log --oneline --graph --date=short --color=always --pretty="format:%C(auto)%cd %h%d %s" {1}/"$(git rev-parse --abbrev-ref HEAD)"' "$@" | + cut -d$'\t' -f1 +} + +_fzf_git_stashes() { + _fzf_git_check || return "$?" + git stash list | ble/contrib/integration:fzf-git/fzf \ + --border-label '🥡 Stashes' \ + --header $'CTRL-X (drop stash)\n\n' \ + --bind 'ctrl-x:execute-silent(git stash drop {1})+reload(git stash list)' \ + -d: --preview 'git show --color=always {1}' "$@" | + cut -d: -f1 +} + +_fzf_git_lreflogs() { + _fzf_git_check || return "$?" + git reflog --color=always --format="%C(blue)%gD %C(yellow)%h%C(auto)%d %gs" | ble/contrib/integration:fzf-git/fzf --ansi \ + --border-label '📒 Reflogs' \ + --preview 'git show --color=always {1}' "$@" | + awk '{print $1}' +} + +_fzf_git_each_ref() { + _fzf_git_check || return "$?" + bash "$__fzf_git" refs | ble/contrib/integration:fzf-git/fzf --ansi \ + --nth 2,2.. \ + --tiebreak begin \ + --border-label '☘️ Each ref' \ + --header-lines 2 \ + --preview-window down,border-top,40% \ + --color hl:underline,hl+:underline \ + --no-hscroll \ + --bind 'ctrl-/:change-preview-window(down,70%|hidden|)' \ + --bind "ctrl-o:execute-silent:bash $__fzf_git {1} {2}" \ + --bind "alt-e:execute:${EDITOR:-vim} <(git show {2}) > /dev/tty" \ + --bind "alt-a:change-prompt(🍀 Every ref> )+reload:bash \"$__fzf_git\" all-refs" \ + --preview 'git log --oneline --graph --date=short --color=always --pretty="format:%C(auto)%cd %h%d %s" {2}' "$@" | + awk '{print $2}' +} +#------------------------------------------------------------------------------ + +# export FZF_DEFAULT_OPTS=--no-unicode + +: "${_ble_contrib_fzf_git_config=key-binding}" + +# original +function ble/contrib:integration/fzf-git/type:original/init { + ble/builtin/bind '"\er": redraw-current-line' +} +function ble/contrib:integration/fzf-git/type:original { + local binding='"\C-g\C-'$1'": "$(_fzf_git_'$2')\e\C-e\er"' + ble/builtin/bind "$binding" +} +# function ble/contrib:integration/fzf-git/type:original { +# local binding='"\C-g\C-'$1'": "$(_fzf_git_'$2')\M-\C-e\M-\C-l"' +# bind "$binding" +# } + +function ble/widget/fzf-git { + ble/widget/insert-string "$(_fzf_git_$1)" + ble/textarea#invalidate +} + +# key-binding +function ble/contrib:integration/fzf-git/type:key-binding { + ble-bind -f "C-g C-$1" "fzf-git $2" +} + +# sabbrev +function ble/contrib:integration/fzf-git/type:sabbrev/init { + function fzf-git.sabbrev { + COMPREPLY=$(_fzf_git_$1) + ble/textarea#invalidate + } +} +function ble/contrib:integration/fzf-git/type:sabbrev { + ble-sabbrev -m "g$1"="fzf-git.sabbrev $2" +} + +# arpeggio +function ble/contrib:integration/fzf-git/type:arpeggio/init { + ble-import 'lib/vim-arpeggio.sh' +} +function ble/contrib:integration/fzf-git/type:arpeggio { + ble/lib/vim-arpeggio.sh/bind -f "g$1" "fzf-git $2" +} + +# old-functions +function ble/contrib:integration/fzf-git/type:old-functions/init { + function is_in_git_repo { _fzf_git_check "$@"; } + function fzf-down { ble/contrib/integration:fzf-git/fzf "$@"; } +} +function ble/contrib:integration/fzf-git/type:old-functions { + # Note: To suppress duplicate adjustment of the terminal states, we override + # "_ble_term_state" with the temporary environment. I.e., when fzf is called + # through these old function names, we never adjust the terminal states. + builtin eval "function g$1 { _ble_term_state= _fzf_git_$2 \"\$@\"; }" +} + +function ble/contrib:integration/fzf-git/initialize { + local type + for type in original key-binding sabbrev arpeggio old-functions; do + [[ :$_ble_contrib_fzf_git_config: == *:"$type":* ]] || continue + + ble/function#try ble/contrib:integration/fzf-git/type:"$type"/init + ble/contrib:integration/fzf-git/type:"$type" f files + ble/contrib:integration/fzf-git/type:"$type" b branches + ble/contrib:integration/fzf-git/type:"$type" t tags + ble/contrib:integration/fzf-git/type:"$type" h hashes + ble/contrib:integration/fzf-git/type:"$type" r remotes + ble/contrib:integration/fzf-git/type:"$type" s stashes + ble/contrib:integration/fzf-git/type:"$type" l lreflogs + ble/contrib:integration/fzf-git/type:"$type" e each_ref + done + builtin unset -f "$FUNCNAME" +} +ble/contrib:integration/fzf-git/initialize diff --git a/.local/share/blesh/contrib/fzf-initialize.bash b/.local/share/blesh/contrib/fzf-initialize.bash new file mode 100644 index 0000000..8a5761c --- /dev/null +++ b/.local/share/blesh/contrib/fzf-initialize.bash @@ -0,0 +1,53 @@ +# ble/contrib/integration/fzf-initialize.bash (C) 2020-2023, akinomyoga + +# Usage: Please write the following lines in blerc +# +# ```bash +# _ble_contrib_fzf_base=/path/to/fzf-base-directory +# ble-import -d integration/fzf-initialize +# ``` + +function ble/contrib/integration:fzf-completion/initialize { + if [[ -d $_ble_contrib_fzf_base ]]; then + if [[ -d $_ble_contrib_fzf_base/bin && :$PATH: != *:"$_ble_contrib_fzf_base/bin":* ]]; then + export PATH="${PATH:+${PATH}:}$_ble_contrib_fzf_base/bin" + fi + if ! ble/bin#has fzf; then + ble/util/print 'ble/contrib/integration:fzf-initialize: "fzf" not found.' >&2 + return 1 + fi + else + local path + if ! ble/bin#get-path fzf; then + ble/util/print 'ble/contrib/integration:fzf: "fzf" not found.' >&2 + return 1 + fi + local ret + ble/util/readlink "$path" + ret=${ret%/*} # fzf, fzf-linux_amd64, etc. + ret=${ret%/bin} # repo/bin/ + ret=${ret%/target} # repo/target (compile directory) + if [[ -s $ret/shell/key-bindings.bash ]]; then + _ble_contrib_fzf_base=$ret + elif [[ -d $ret/share/fzf/shell ]]; then + _ble_contrib_fzf_base=$ret/share/fzf + elif [[ -s $ret/share/fzf/key-bindings.bash ]]; then + # NixOS package (https://github.com/akinomyoga/blesh-contrib/pull/5#issuecomment-1019394821) + _ble_contrib_fzf_base=$ret/share/fzf + elif [[ -s $ret/share/doc/fzf/examples/key-bindings.bash ]]; then + # Ubuntu fzf package (https://github.com/akinomyoga/blesh-contrib/pull/5#issuecomment-1019394821) + _ble_contrib_fzf_base=$ret/share/doc/fzf/examples + elif [[ -d /usr/share/fzf/shell ]]; then + _ble_contrib_fzf_base=/usr/share/fzf + elif [[ -d /usr/share/doc/fzf/examples/key-bindings.bash ]]; then + # Ubuntu fzf package (https://github.com/akinomyoga/blesh-contrib/pull/5#issuecomment-1019394821) + _ble_contrib_fzf_base=/usr/share/doc/fzf/examples + else + ble/util/print 'ble/contrib/integration:fzf: failed to find "fzf" base directory' >&2 + return 1 + fi + fi + return 0 +} + +ble/contrib/integration:fzf-completion/initialize || return 1 diff --git a/.local/share/blesh/contrib/fzf-key-bindings.bash b/.local/share/blesh/contrib/fzf-key-bindings.bash new file mode 100644 index 0000000..fdb0133 --- /dev/null +++ b/.local/share/blesh/contrib/fzf-key-bindings.bash @@ -0,0 +1,40 @@ +# ble/contrib/integration/fzf-key-bindings.bash (C) 2020-2023, akinomyoga + +ble-import contrib/integration/fzf-initialize + +[[ $- == *i* ]] || return 0 + +ble/function#push bind : +if [[ -f $_ble_contrib_fzf_base/key-bindings.bash ]]; then + source "$_ble_contrib_fzf_base/key-bindings.bash" +elif [[ -f $_ble_contrib_fzf_base/shell/key-bindings.bash ]]; then + source "$_ble_contrib_fzf_base/shell/key-bindings.bash" +fi +ble/function#pop bind + +function ble/contrib/integration:fzf-key-bindings/is-fzf-above-7c447bbd { + local def; ble/function#getdef __fzf_history__ + [[ $def == *READLINE_LINE=* ]] +} + +# CTRL-T - Paste the selected file path into the command line +ble-bind -m emacs -x C-t fzf-file-widget +ble-bind -m vi_imap -x C-t fzf-file-widget +ble-bind -m vi_nmap -s C-t 'i\C-t' + +# CTRL-R - Paste the selected command from history into the command line +ble-bind -m emacs -x C-r fzf-history-widget +ble-bind -m vi_imap -x C-r fzf-history-widget +ble-bind -m vi_nmap -s C-r 'i\C-r' +function fzf-history-widget { + READLINE_LINE=$(history -p "$(__fzf_history__)") + READLINE_POINT=${#READLINE_LINE} +} +((_ble_bash>=40000)) && + ble/contrib/integration:fzf-key-bindings/is-fzf-above-7c447bbd && + function fzf-history-widget { __fzf_history__; } + +# ALT-C - cd into the selected directory +ble-bind -m emacs -c M-c 'builtin eval -- "$(__fzf_cd__)"' +ble-bind -m vi_imap -c M-c 'builtin eval -- "$(__fzf_cd__)"' +ble-bind -m vi_nmap -c M-c 'builtin eval -- "$(__fzf_cd__)"' diff --git a/.local/share/blesh/contrib/histdb.bash b/.local/share/blesh/contrib/histdb.bash new file mode 100644 index 0000000..dbc84e2 --- /dev/null +++ b/.local/share/blesh/contrib/histdb.bash @@ -0,0 +1,1603 @@ +# blesh/contrib/histdb (C) 2023, Koichi Murase + +ble/util/assign _ble_histdb_sqlite3 'builtin type -P sqlite3 2>/dev/null' +if [[ ! -x $_ble_histdb_sqlite3 ]]; then + ble/util/print 'contrib/histdb: "sqlite3" is required for this module.' >&2 + return 1 +fi + +ble-import util.bgproc + +_ble_histdb_version=3 + +#------------------------------------------------------------------------------ +# histdb_remarks + +bleopt/declare -v histdb_remarks 'git: \q{contrib/histdb-remarks-git}' + +_ble_histdb_remarks_data=() +function ble/prompt/unit:_ble_histdb_remarks/update { + ble/prompt/unit/add-hash '$bleopt_histdb_remarks' + ble/prompt/unit:{section}/update _ble_histdb_remarks "$bleopt_histdb_remarks" no-trace +} + +## @fn ble/histdb/.get-remarks +## @var[out] remarks +function ble/histdb/.get-remarks { + remarks= + if [[ $bleopt_histdb_remarks ]]; then + local ret + ble/prompt/unit#update _ble_histdb_remarks "$bleopt_histdb_remarks" + ble/prompt/unit:{section}/get _ble_histdb_remarks + remarks=$ret + fi +} + +function ble/prompt/backslash:contrib/histdb-remarks-git { + ble-import prompt-git + + function ble/prompt/backslash:contrib/histdb-remarks-git { + local "${_ble_contrib_prompt_git_vars[@]/%/=}" # WA #D1570 checked + ble/contrib/prompt-git/initialize || return 0 + ble/contrib/prompt-git/update-head-information + local state; ble/contrib/prompt-git/get-state + local dirty_mark; ble/contrib/prompt-git/get-dirty-mark + + local path=${git_base%.git} + path=${path%/} + path=${path##*?/} + [[ $PWD == "$git_base"/?* ]] && + path="$path/${PWD#$git_base/}" + + ble/prompt/print "git: ${branch:-(detached)} ${hash:-(orphan)}$dirty_mark${state:+ $state} @ ${path:-/}" + } && "$FUNCNAME" +} + +#------------------------------------------------------------------------------ +# background sqlite3 process + +bleopt/declare -v histdb_ignore '' +bleopt/declare -v histdb_file '' + +function ble/histdb/.get-filename { + local basename=${bleopt_histdb_file%.sqlite3} + local hostname=${HOSTNAME:-$_ble_base_env_HOSTNAME} + hostname=${hostname//'/'/'%'} # filename cannot contian / + ret=${basename:-$_ble_base_state/history}${hostname:+@$hostname}.sqlite3 +} + +## @var _ble_histdb_file +_ble_histdb_file= + +## @arr _ble_histdb_bgproc=(fd_response fd_request - bgpid) +## +_ble_histdb_bgproc=() +_ble_histdb_bgproc_fname=() +_ble_histdb_timeout=5000 +_ble_histdb_keepalive=1800 # sec + +function ble/histdb/escape-for-sqlite-glob { + ret=$1 + if [[ $ret == *["[*?"]* ]]; then + local a b + for a in '[' '*' '?'; do + b=[$a] ret=${ret//"$a"/"$b"} + done + fi +} + +function ble/histdb/sqlite3.flush { + if [[ ${_ble_histdb_bgproc[0]} && _ble_bash -ge 40000 ]]; then + local line IFS= + ble/bash/read-timeout 0.001 -r -d '' line <&"${_ble_histdb_bgproc[0]}" + fi +} +function ble/histdb/sqlite3.request { + ble/histdb/sqlite3.open + if [[ ${_ble_histdb_bgproc[1]} ]]; then + ble/histdb/sqlite3.flush + ble/util/print "$1" >&"${_ble_histdb_bgproc[1]}" + else + [[ $1 == .exit ]] && return 0 + "$_ble_histdb_sqlite3" -quote "$_ble_histdb_file" ".timeout $_ble_histdb_timeout" "$1" + fi +} + +function ble/histdb/read-single-value { + local line nl=$'\n' q=\' qq=\'\' Q="'\''" + local IFS= + if ble/bash/read line && [[ $line == \'* ]]; then + local out=$line ext=0 + while ((ext==0)) && ! ble/string#match "$out" '^'"$q"'([^'\'']|'"$qq"')*'"$q"'$'; do + ble/bash/read line; ext=$? + out=$out$nl$line + done + line=$out + fi + line=${line#$q} + line=${line%$q} + line=${line//$qq/$q} + line=$q${line//$q/$Q}$q + ble/util/print "ret=$line" +} + +function ble/histdb/sqlite3.request-single-value { + local query=$1 opts=$2 + ble/histdb/sqlite3.open + if [[ ${_ble_histdb_bgproc[1]} && _ble_bash -ge 40000 ]]; then + ble/histdb/sqlite3.flush + ble/util/print "$query" >&"${_ble_histdb_bgproc[1]}" + + local sync_command='ble/histdb/read-single-value <&"${_ble_histdb_bgproc[0]}"' + local sync_condition='((sync_elapsed<200)) || ! ble/complete/check-cancel' + local sync_opts=progressive-weight + [[ :$opts: == *:auto:* && $bleopt_complete_timeout_auto ]] && + sync_opts=$sync_opts:timeout=$((bleopt_complete_timeout_auto)) + ble/util/assign ret 'ble/util/conditional-sync "$sync_command" "$sync_condition" "" "$sync_opts"' &>/dev/null; local ext=$? + builtin eval -- "$ret" + ((ext==142)) && ext=148 + return "$ext" + else + local out q=\' qq=\'\' + ble/util/assign out '"$_ble_histdb_sqlite3" -quote "$_ble_histdb_file" ".timeout $_ble_histdb_timeout" "$query"' + out=${out#$q} + out=${out%$q} + ret=${out//$qq/$q} + fi +} + +function ble/histdb/sqlite3.proc { + exec "$_ble_histdb_sqlite3" -quote -cmd "-- [ble: $BLE_SESSION_ID]" "$_ble_histdb_file" +} + +_ble_histdb_keepalive_enabled= +ble/is-function ble/util/idle.push && + _ble_histdb_keepalive_enabled=1 + +## @fn ble/histdb/sqlite3.open +## @var[ref] _ble_histdb_file +## @arr[out] _ble_histdb_bgproc +## @arr[out] _ble_histdb_bgproc_fname +function ble/histdb/sqlite3.open { + if [[ $_ble_histdb_file ]]; then + # background process に依らないモードの時は OK + ble/util/bgproc#opened _ble_histdb || return 0 + + ble/util/bgproc#alive _ble_histdb; local state=$? + if ((state==0)); then + ble/util/bgproc#keepalive _ble_histdb + return 0 + else + if ((state==3)); then + # background process が死んでいる時は再度開き直す。 + ble/util/print 'histdb: background sqlite3 is inactive.' >&2 + fi + ble/util/bgproc#start _ble_histdb + return "$?" + fi + fi + + local ret; ble/histdb/.get-filename + _ble_histdb_file=$ret + + local session_id=$_ble_base_session + local start_time=${session_id%%/*} + + IFS=, builtin eval 'local groups="${GROUPS[*]}"' + local user=${USER:-$_ble_base_env_USER} + local hostname=${HOSTNAME:-$_ble_base_env_HOSTNAME} + + local screen_info= ssh_info= + [[ $STY ]] && screen_info="$STY $WINDOW" + [[ $SSH_TTY ]] && ssh_info="$SSH_TTY $SSH_CONNECTION" + + local bgproc_opts=owner-close-on-unload:kill-timeout=60000 + [[ $_ble_histdb_keepalive_enabled ]] && + bgproc_opts=$bgproc_opts:timeout=$((_ble_histdb_keepalive*1000)) + if ble/util/bgproc#open _ble_histdb ble/histdb/sqlite3.proc "$bgproc_opts"; (($?!=0&&$?!=3)); then + # Note: システムが元々サポートしていない場合 ($? == 3) はエラーメッセージは + # 出さない。 + local msg='[ble histdb: background sqlite3 failed to start]' + ble/util/print "${_ble_term_setaf[9]}$msg$_ble_term_sgr0" >&2 + fi + + local ret q=\' qq=\'\' + ble/histdb/sqlite3.request-single-value " + BEGIN IMMEDIATE TRANSACTION; + CREATE TABLE IF NOT EXISTS misc(key TEXT PRIMARY KEY, value INTEGER); + INSERT OR IGNORE INTO misc values('version', $_ble_histdb_version); + CREATE TABLE IF NOT EXISTS sessions( + session_id TEXT PRIMARY KEY, pid INTEGER, ppid INTEGER, + hostname TEXT, user TEXT, uid INTEGER, euid INTEGER, groups TEXT, + start_time INTEGER, start_wd TEXT, + bash_path TEXT, bash_version TEXT, shlvl INTEGER, + blesh_path TEXT, blesh_version TEXT, + term TEXT, lang TEXT, display TEXT, screen_info TEXT, ssh_info TEXT, + tty TEXT, last_time INTEGER, last_wd TEXT); + CREATE TABLE IF NOT EXISTS command_history( + session_id TEXT, command_id INTEGER, + lineno INTEGER, history_index INTEGER, + command TEXT, cwd TEXT, inode INTEGER, issue_time INTEGER, + status INTEGER, + pipestatus TEXT, + lastarg TEXT, + bgpid INTEGER, + exec_time INTEGER, + exec_time_beg INTEGER, + exec_time_end INTEGER, + exec_time_real INTEGER, + exec_time_usr INTEGER, + exec_time_sys INTEGER, + exec_time_cpu INTEGER, + exec_time_usr_self INTEGER, + exec_time_sys_self INTEGER, + exec_time_usr_chld INTEGER, + exec_time_sys_chld INTEGER, + remarks TEXT, + PRIMARY KEY (session_id, command_id)); + CREATE TABLE IF NOT EXISTS words( + word TEXT PRIMARY KEY, count INTEGER, ctime INTEGER, mtime INTEGER); + INSERT OR IGNORE INTO + sessions( + session_id, pid, ppid, + hostname, user, uid, euid, groups, + start_time, start_wd, + bash_path, bash_version, shlvl, + blesh_path, blesh_version, + term, lang, display, screen_info, ssh_info, + tty) + VALUES( + '${session_id//$q/$qq}', '${$//$q/$qq}', '${PPID//$q/$qq}', + '${hostname//$q/$q}', '${user//$q/$qq}', '${UID//$q/$qq}', '${EUID/$q/$qq}', '${groups//$q/$qq}', + '${start_time//$q/$qq}', '${PWD//$q/$qq}', + '${BASH//$q/$qq}', '${BASH_VERSION//$q/$qq}', '${SHLVL//$q/$qq}', + '${_ble_base_blesh//$q/$qq}', '${BLE_VERSION//$q/$qq}', + '${TERM//$q/$qq}', '${LANG//$q/$qq}', '${DISPLAY//$q/$qq}', '${screen_info//$q/$qq}', '${ssh_info//$q/$qq}', + '${_ble_prompt_const_l//$q/$qq}'); + COMMIT; + SELECT VALUE FROM misc WHERE key = 'version';" + local version=$ret + + if [[ $version ]] && ((version<_ble_histdb_version)); then + local query= + ((version<2)) && + query=$query$_ble_term_nl"ALTER TABLE command_history ADD COLUMN inode INTEGER;" + ((version<3)) && + query=$query$_ble_term_nl"ALTER TABLE command_history ADD COLUMN remarks TEXT;" + query=$query$_ble_term_nl"UPDATE misc SET value = $_ble_histdb_version WHERE key = 'version';" + ble/histdb/sqlite3.request "$query" + fi +} + +function ble/util/bgproc/onstart:_ble_histdb { + ble/util/bgproc#post _ble_histdb ".timeout $_ble_histdb_timeout" +} + +function ble/util/bgproc/onstop:_ble_histdb { + ble/util/bgproc#post _ble_histdb '.exit' +} + +function ble/histdb/sqlite3.close { + [[ $_ble_histdb_file ]] || return 0 + local session_id=$_ble_base_session ret + ble/util/time; local time=$ret + ble/histdb/sqlite3.request " + UPDATE sessions SET + last_time = '${time//$q/$qq}', + last_wd = '${PWD//$q/$qq}' + WHERE session_id = '${session_id//$q/$qq}';" + + ble/util/bgproc#close _ble_histdb + _ble_histdb_file= +} + +_ble_histdb_exec_ignore=() +_ble_histdb_exec_cwd= +_ble_histdb_exec_cwd_inode= + +function ble/histdb/update-cwd-inode { + [[ $PWD == "$_ble_histdb_exec_cwd" ]] && return 0 + + _ble_histdb_exec_cwd=$PWD + _ble_histdb_exec_cwd_inode= + if local ret; ble/file#inode "$PWD" && ble/string#match "$ret" '^[0-9]+$'; then + _ble_histdb_exec_cwd_inode=$ret + fi +} + +function ble/histdb/collect-words.proc { + [[ $wtype && ! ${wtype//[0-9]} ]] && + ble/array#push collect_words "${_ble_edit_str:wbeg:wlen}" +} +function ble/histdb/collect-words { + ble-edit/content/update-syntax + local -a collect_words=() + ble/syntax/tree-enumerate-in-range 0 "${#_ble_edit_str}" ble/histdb/collect-words.proc + ble/array#reverse collect_words + + ret=() + local word + "${_ble_util_set_declare[@]//NAME/mark}" # WA #D1570 checked + for word in "${collect_words[@]}"; do + # Note (#D1958): Even if the same words appeared in a single command, we + # only count 1 for one command. This is because the "words" table is + # used for the word completion, where the count is used as an importance + # measure. We count the number of commands where the word appears + # because the same word can easily appear in a single command multiple + # times. + ble/set#contains mark "$word" && return 0 + + ble/set#add mark "$word" + ble/array#push ret "$word" + done +} + +## @fn ble/histdb/exec_register.hook command +## @var[in] command_id +## @var[in] lineno +## これらの変数は exec_register の側で用意される。 +function ble/histdb/exec_register.hook { + local command=$1 + if [[ $bleopt_histdb_ignore ]]; then + local patterns pattern + ble/string#split patterns : "$bleopt_histdb_ignore" + for pattern in "${patterns[@]}"; do + if [[ $command == $pattern ]]; then + _ble_histdb_exec_ignore[command_id]=1 + return 0 + fi + done + fi + builtin unset -v '_ble_histdb_exec_ignore[command_id]' + + local q=\' qq=\'\' + local session_id=$_ble_base_session ret + ble/util/time; local issue_time=$ret + + # @var history_index ... history index: The current command might not be + # registered to the command history, but we always pick up the index of the + # last entry because there is no way to check it reliably. We could compare + # the top element with BASH_COMMAND, but the history entry might be + # transformed by HISTCONTROL=strip, etc. + local history_index; ble/history/get-count -v history_index + ((history_index++)) + + # Expand "bleopt histdb_remarks" + local remarks + ble/histdb/.get-remarks + + local ret word extra_query= + ble/histdb/collect-words + for word in "${ret[@]}"; do + extra_query=$extra_query"INSERT OR REPLACE INTO words(word, count, ctime, mtime) + VALUES('${word//$q/$qq}', + coalesce((SELECT count FROM words WHERE word = '${word//$q/$qq}'), 0) + 1, + coalesce((SELECT ctime FROM words WHERE word = '${word//$q/$qq}'), $issue_time), + $issue_time);" + done + + ble/histdb/update-cwd-inode + local inode=$_ble_histdb_exec_cwd_inode + + ble/histdb/sqlite3.request " + BEGIN IMMEDIATE TRANSACTION; + UPDATE sessions SET + last_time = '${issue_time//$q/$qq}', + last_wd = '${PWD//$q/$qq}' + WHERE session_id = '${session_id//$q/$qq}'; + -- Update duplicate command_id + UPDATE command_history SET + command_id = min(0, (SELECT command_id FROM command_history WHERE session_id = '${session_id//$q/$qq}')) - 1 + WHERE session_id = '${session_id//$q/$qq}' AND command_id = $command_id; + -- Add command_history entry + INSERT INTO command_history( + session_id, command_id, + lineno, history_index, + command, cwd, inode, issue_time, remarks) + VALUES( + '${session_id//$q/$qq}', '${command_id//$q/$qq}', + '${lineno//$q/$qq}', '${history_index//$q/$qq}', + '${command//$q/$qq}', '${PWD//$q/$qq}', ${inode:-None}, '${issue_time//$q/$qq}', '${remarks//$q/$qq}'); + $extra_query + COMMIT;" +} + +function ble/histdb/postexec.hook { + local session_id=$_ble_base_session + local command_id=$_ble_edit_exec_command_id + if [[ ${_ble_histdb_exec_ignore[command_id]+set} ]]; then + builtin unset -v '_ble_histdb_exec_ignore[command_id]' + return 0 + fi + + local ret + ble/util/time; local last_time=$ret + + IFS=, builtin eval 'local pipestatus="${_ble_edit_exec_PIPESTATUS[*]}"' + local lastarg=$_ble_edit_exec_lastarg + ((${#lastarg}>=1000)) && lastarg=${lastarg::997}... + + local real=$_ble_exec_time_tot + local usr=$_ble_exec_time_usr + local sys=$_ble_exec_time_sys + local cpu=$((real>0?(usr+sys)/real:0)) + local usr_chld=$((usr-_ble_exec_time_usr_self)) + local sys_chld=$((sys-_ble_exec_time_sys_self)) + + local q=\' qq=\'\' + ble/histdb/sqlite3.request " + UPDATE sessions SET + last_time = '${last_time//$q/$qq}', + last_wd = '${PWD//$q/$qq}' + WHERE session_id = '${session_id//$q/$qq}'; + UPDATE command_history SET + status = '${_ble_edit_exec_lastexit//$q/$qq}', + pipestatus = '${pipestatus//$q/$qq}', + lastarg = '${lastarg//$q/$qq}', + bgpid = '${!//$q/$qq}', + exec_time = '${_ble_exec_time_ata//$q/$qq}', + exec_time_beg = '${_ble_exec_time_beg//$q/$qq}', + exec_time_end = '${_ble_exec_time_end//$q/$qq}', + exec_time_real = '${real//$q/$qq}', + exec_time_usr = '${usr//$q/$qq}', + exec_time_sys = '${sys//$q/$qq}', + exec_time_cpu = '${cpu//$q/$qq}', + exec_time_usr_self = '${_ble_exec_time_usr_self//$q/$qq}', + exec_time_sys_self = '${_ble_exec_time_sys_self//$q/$qq}', + exec_time_usr_chld = '${usr_chld//$q/$qq}', + exec_time_sys_chld = '${sys_chld//$q/$qq}' + WHERE session_id = '${session_id//$q/$qq}' AND command_id = $command_id;" +} + +function ble/histdb/backup { + local file=$1 + ble/bin#freeze-utility-path -n gzip || return 1 + + local backup=${file%.sqlite3}.backup.sqlite3 q=\' qq=\'\' + if [[ -s $backup.gz ]]; then + # If there is already an up-to-date backup file, we skip the backup. + local ret now + ble/util/time; now=$ret + ble/file#mtime "$backup.gz" || return 1 + ((now>ret+24*3600)) || return 1 + fi + + "$_ble_histdb_sqlite3" "$file" \ + ".timeout $_ble_histdb_timeout" \ + "PRAGMA quick_check;" \ + ".backup '${backup//$q/$qq}'" \ + "ATTACH DATABASE '${backup//$q/$qq}' AS backup; + PRAGMA backup.quick_check;" >/dev/null && + ble/bin/gzip -c "$backup" >| "$backup.gz.part" && + [[ -s $backup.gz.part ]] && + ble/bin/mv -f "$backup.gz.part" "$backup.gz" && + ble/bin/rm -f "$backup" +} + +function ble/histdb/unload.hook { + if [[ $_ble_histdb_file ]]; then + local file=$_ble_histdb_file + ble/histdb/sqlite3.close + ble/histdb/backup "$file" + fi +} + +# 設定が変化して記録先の history.sqlite3 のパスが変わったら現在のファイルは閉じ +# る。必要になった時に初めて新しいファイルを開く。 +function ble/histdb/exec_end.hook { + local ret; ble/histdb/.get-filename + [[ $ret == "$_ble_histdb_file" ]] || + ((${#_ble_edit_exec_lines[@]})) || + ble/histdb/sqlite3.close +} + +blehook exec_register!=ble/histdb/exec_register.hook +blehook POSTEXEC!=ble/histdb/postexec.hook +blehook exec_end!=ble/histdb/exec_end.hook +blehook unload!=ble/histdb/unload.hook + +#------------------------------------------------------------------------------ +# auto-complete + +function ble/complete/auto-complete/source:histdb-history { + local limit=$((bleopt_line_limit_length)) limit_condition= + if ((limit)); then + ((limit-=${#_ble_edit_str},limit>0)) || return 1 + limit_condition=" AND length(command) <= $limit" + fi + + local ret + ble/histdb/escape-for-sqlite-glob "$_ble_edit_str"; local pat=$ret?* + + ble/histdb/update-cwd-inode + local inode=$_ble_histdb_exec_cwd_inode + + local q=\' qq=\'\' + ble/histdb/sqlite3.request-single-value " + SELECT coalesce( + (SELECT command FROM (SELECT command, max(issue_time) FROM command_history WHERE command GLOB '${pat//$q/$qq}' AND cwd = '${PWD//$q/$qq}$limit_condition')), + ${inode:+(SELECT command FROM (SELECT command, max(issue_time) FROM command_history WHERE command GLOB '${pat//$q/$qq}' AND inode = $inode$limit_condition)),} + '');" + [[ $ret == "$_ble_edit_str"?* ]] || return 1 + ble/complete/auto-complete/enter h 0 "${ret:${#_ble_edit_str}}" '' "$ret" +} + +function ble/complete/auto-complete/source:histdb-word { + local iN=${#_ble_edit_str} + ((_ble_edit_ind>0)) || return 1 + + local limit=$((bleopt_line_limit_length)) limit_condition= + if ((limit)); then + ((limit-=iN,limit>0)) || return 1 + limit_condition=" AND length(word) <= $limit" + fi + + local -a wbegins=() + if ((_ble_edit_ind=0)); then + ble/array#push wbegins "$((istat-wlen))" + elif [[ ${_ble_syntax_bash_command_EndWtype[stat[0]]:-} ]]; then + # 単語の始まりの時 (_ble_syntax_bash_command_EndWtype で判定できるのかは実は非自明) + ble/array#push wbegins "$istat" + fi + fi + + else + # 閉じていない入れ子に対する列挙 + + local -a stat nest tree + ble/string#split-words stat "${_ble_syntax_stat[iN]}" + local wlen tclen + if (((wlen=stat[1])>=0)); then + ble/array#push wbegins "$((iN-wlen))" + elif (((tclen=stat[4])>=0)); then + local wend=$((iN-tclen)) + ble/string#split-words tree "${_ble_syntax_tree[wend-1]}" + local wtype=${tree[0]} wlen=${tree[1]} + [[ $wtype && ! ${wtype//[0-9]} && wlen -ge 0 ]] && + ble/array#push wbegins "$((wend-wlen))" + fi + + local inest=$iN nlen=${stat[3]} + while ((nlen>0)); do + ((inest-=nlen)) + ble/string#split-words nest "${_ble_syntax_nest[inest]}" + (((wlen=nest[1])>=0)) && + ble/array#push wbegins "$((inest-wlen))" + nlen=${nest[3]} + done + fi + ((${#wbegins[@]})) || return 1 + + local -a sqls=() + + local i q=\' qq=\'\' + for i in "${wbegins[@]}"; do + local word=${_ble_edit_str:i:_ble_edit_ind-i} + [[ $word ]] || continue + local ret; ble/histdb/escape-for-sqlite-glob "$word" + local pat=$ret?* + ble/array#push sqls "SELECT '$i:' || word FROM (SELECT word, max(mtime) FROM words WHERE word GLOB '${pat//$q/$qq}'$limit_condition)" + done + ((${#sqls[@]})) || return 1 + + ble/array#reverse sqls + sqls=("${sqls[@]/#/(}") # WA #D1570 checked + sqls=("${sqls[@]/%/)}") # WA #D1570 checked + ble/array#push sqls "''" + IFS=, builtin eval 'local query="select coalesce(${sqls[*]});"' + + local ret + ble/histdb/sqlite3.request-single-value "$query" auto || return 1 + [[ $ret == *:* ]] || return 1 + + local index=${ret%%:*} insert=${ret#*:} + if local comps=${_ble_edit_str:index:_ble_edit_ind-index}; [[ $insert == "$comps"* ]]; then + local ins=${insert:_ble_edit_ind-index} + ble/complete/auto-complete/enter c "$_ble_edit_ind" "$ins" "$insert" "$ins" "$ins" ' ' + else + ble/complete/auto-complete/enter r "$index" " [$insert] " "$insert" "$insert" "$insert" ' ' + fi +} +ble/util/import/eval-after-load core-complete ' + ble/array#insert-before _ble_complete_auto_source history histdb-history + ble/array#push _ble_complete_auto_source histdb-word' +[[ $_ble_histdb_keepalive_enabled ]] && + ble/util/idle.push ble/histdb/sqlite3.open + +#------------------------------------------------------------------------------ +# ble histdb command + +function ble-histdb { + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_local_adjust" + local set shopt ext + ble/base/.adjust-bash-options set shopt + if (($#==0)); then + ble/histdb/sub:query 'select command from command_history;' + ext=$? + elif ble/is-function "ble/histdb/sub:$1"; then + "ble/histdb/sub:$@" + ext=$? + else + builtin printf 'ble-histdb: unknown command "%s"\n' "$1" + ext=2 + fi + ble/base/.restore-bash-options set shopt + ble/util/setexit "$ext" + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_local_return" +} + +# 一般的な補完のフレームワークを作っても良いのではないかという気がしてきたが、 +# それは後で。 +function ble/cmdinfo/complete:ble-histdb { + if ((comp_cword==1)); then + local ret sub + ble/util/assign-array ret 'compgen -A function -- ble/histdb/sub:' + ((${#ret[@]})) || return 0 + + local cands + for sub in "${ret[@]#ble/histdb/sub:}"; do + if [[ $sub != */* && $sub == "$COMPV"* ]]; then + ble/array#push cands "$sub" + fi + done + + if ((${#cands[@]})); then + local "${_ble_complete_yield_varnames[@]/%/=}" # disable=#D1570 + ble/complete/cand/yield.initialize word + ble/complete/cand/yield.batch word + fi + fi +} + +function ble/histdb/sub:query { + local ret + ble/histdb/.get-filename; local histdb_file=$ret + "$_ble_histdb_sqlite3" "$histdb_file" '.timeout 1000' "$@" +} + +#------------------------------------------------------------------------------ + +function ble/histdb/count2si { + local si + si=('' k M G T P E Z Y R Q) + + local count=$1 i + for ((i=0;i<${#si[@]}-1;i++,count/=1000)); do + if ((count<1000)); then + ret=$count${si[i]} + return 0 + elif ((count<100000)); then + count=${count%???}.${count:${#count}-3} + ret=${count::4}${si[i+1]} + return 0 + fi + done + ret=$count${si[${#si[@]}-1]} +} + +# modified ble/contrib/prompt-elapsed/output-sec.ps +function ble/histdb/usec2s { + local usec=${1:-0} + if ((usec<1000)); then + ret=${usec}us + elif ((usec<100000)); then + usec=${usec%???}.${usec:${#usec}-3} + ret=${usec::4}ms + else + ble/histdb/msec2s "$((usec/1000))" + fi +} + +function ble/histdb/msec2s { + local msec=${1:-0} + if ((msec<1000)); then + ret=${msec}ms + elif ((msec<100000)); then + msec=${msec%???}.${msec:${#msec}-3} + ret=${msec::4}s + else + ble/histdb/sec2s "$((msec/1000))" + fi +} + +function ble/histdb/sec2s { + local sec=${1:-0} min + ((min=sec/60,sec%=60)) + if ((min<100)); then + ret=${min}m${sec}s + return 0 + fi + + local hour; ((hour=min/60,min%=60)) + if ((hour<100)); then + ret="${hour}h:${min}m:${sec}s" + return 0 + fi + + local day; ((day=hour/24,hour%=24)) + if ((day<365)); then + ret="${day}d-${hour}h:${min}m" + return 0 + fi + + local year; ((year=day/365,day%=365)) + ret="${year}y-${day}d-${hour}h" + return 0 +} + +#------------------------------------------------------------------------------ +# usage: ble histdb stats + +bleopt/declare -v histdb_stats_items 'commands unique-commands successful-commands exec-time exec-cpu-time words sessions directories' + +function ble/histdb/sub:stats/get-user-name { + ble/bin#has git && ble/util/assign ret ' + git config user.name 2>/dev/null + ' && [[ $ret ]] && return 0 + + ble/bin#has getenv && ble/util/assign ret ' + getent passwd 2>/dev/null | ble/bin/awk -F : -v UID="$UID" '\'' + $3==UID { + sub(/[[:space:]]*[<>].*$/, "", $5); + print $5; + } + '\'' + ' && [[ $ret ]] && return 0 + + ret=${USER:-$_ble_base_env_USER}@${HOSTNAME:-$_ble_base_env_HOSTNAME} +} + +## @fn ble/histdb/sub:stats/where.check condition +## @param[in] condition +## @var[ref] where +function ble/histdb/sub:stats/where.check { + where="${where:- WHERE}${where:+ AND} $1" +} +## @fn ble/histdb/sub:stats/where.check-datetime column +## @param[in] column +## @var[in] time_beg time_end +## @var[ref] where +function ble/histdb/sub:stats/where.check-datetime { + [[ $time_beg ]] && ble/histdb/sub:stats/where.check "$1 >= $time_beg" + [[ $time_end ]] && ble/histdb/sub:stats/where.check "$1 < $time_end" +} + +function ble/histdb/sub:stats/item:commands { + case $1 in + (init) + local where= + ble/histdb/sub:stats/where.check-datetime issue_time + ble/array#push queries "SELECT count(*) FROM command_history$where;" ;; + (get) + ble/array#push names 'Total commands' + local ret + ble/histdb/count2si "$2" + ble/array#push values "$ret" ;; + esac +} + +function ble/histdb/sub:stats/item:unique-commands { + case $1 in + (init) + local where= + ble/histdb/sub:stats/where.check-datetime issue_time + ble/array#push queries "SELECT count(*) FROM (SELECT DISTINCT command FROM command_history$where);" ;; + (get) + ble/array#push names 'Total unique commands' + local ret + ble/histdb/count2si "$2" + ble/array#push values "$ret" ;; + esac +} + +function ble/histdb/sub:stats/item:successful-commands { + case $1 in + (init) + local where= + ble/histdb/sub:stats/where.check 'status == 0' + ble/histdb/sub:stats/where.check-datetime issue_time + ble/array#push queries "SELECT count(*) FROM (SELECT command FROM command_history$where);" ;; + (get) + ble/array#push names 'Total successful commands' + local ret + ble/histdb/count2si "$2" + ble/array#push values "$ret" ;; + esac +} + +function ble/histdb/sub:stats/item:sessions { + case $1 in + (init) + local where= + if [[ $time_end ]]; then + ble/histdb/sub:stats/where.check-datetime start_time + else + ble/histdb/sub:stats/where.check-datetime last_time + fi + ble/array#push queries "SELECT count(*) FROM sessions$where;" ;; + (get) + ble/array#push names 'Total sessions' + local ret + ble/histdb/count2si "$2" + ble/array#push values "$ret" ;; + esac +} + +function ble/histdb/sub:stats/item:words { + case $1 in + (init) + local where= + if [[ $time_end ]]; then + ble/histdb/sub:stats/where.check-datetime ctime + else + ble/histdb/sub:stats/where.check-datetime mtime + fi + ble/array#push queries "SELECT count(*) FROM words$where;" ;; + (get) + ble/array#push names 'Total distinct words' + local ret + ble/histdb/count2si "$2" + ble/array#push values "$ret" ;; + esac +} + +function ble/histdb/sub:stats/item:directories { + case $1 in + (init) + local where= + ble/histdb/sub:stats/where.check-datetime issue_time + ble/array#push queries "SELECT count(*) FROM (SELECT DISTINCT cwd FROM command_history$where);" ;; + (get) + ble/array#push names 'Total directories' + local ret + ble/histdb/count2si "$2" + ble/array#push values "$ret" ;; + esac +} + +function ble/histdb/sub:stats/item:exec-time { + case $1 in + (init) + local where= + ble/histdb/sub:stats/where.check-datetime issue_time + ble/array#push queries "SELECT sum(exec_time) FROM command_history$where;" ;; + (get) + ble/array#push names 'Total execution time' + local ret + ble/histdb/usec2s "$2" + ble/array#push values "$ret" ;; + esac +} + +function ble/histdb/sub:stats/item:exec-cpu-time { + case $1 in + (init) + local where= + ble/histdb/sub:stats/where.check-datetime issue_time + ble/array#push queries "SELECT sum(exec_time_usr + exec_time_sys) FROM command_history$where;" ;; + (get) + ble/array#push names 'Total CPU time' + local ret + ble/histdb/msec2s "$2" + ble/array#push values "$ret" ;; + esac +} + +function ble/histdb/sub:stats { + local period=${1-} + + local time_beg= time_end= + + if [[ $period ]]; then + local ret + if ble/string#match "$period" '^([0-9]+)([smhdMy])$'; then + local delta=${BASH_REMATCH[1]} + case ${BASH_REMATCH[2]} in + (m) ((delta*=60)) ;; + (h) ((delta*=3600)) ;; + (d) ((delta*=3600*24)) ;; + (M) ((delta*=3600*24*30)) ;; + (y) ((delta*=3600*24*365)) ;; + esac + ble/util/time + ((time_beg=ret-delta)) + elif ble/string#match "$period" '^2[0-9]{3}(-(0[1-9]|1[0-2])(-(0[1-9]|[12][0-9]|3[01]))?)?$'; then + local y=${period::4} m=${BASH_REMATCH[2]-} d=${BASH_REMATCH[4]-} + if [[ $d ]]; then + m=${m#0} d=${d#0} + ble/util/mktime "$y-$m-$d 00:00:00" + time_beg=$ret + # Note: we here assume that 01-32 is equivalent to 02-01, etc. + ble/util/mktime "$y-$m-$((d+1)) 00:00:00" + time_end=$ret + elif [[ $m ]]; then + m=${m#0} + ble/util/mktime "$y-$m-01 00:00:00" + time_beg=$ret + ble/util/mktime "$((y+m/12))-$((m%12+1))-01 00:00:00" + time_end=$ret + else + ble/util/mktime "$y-01-01 00:00:00" + time_beg=$ret + ble/util/mktime "$((y+1))-01-01 00:00:00" + time_end=$ret + fi + else + ble/util/print "ble-histdb-stats: unrecognized argument '$period'" 2>/dev/null + return 2 + fi + fi + + local -a queries=() + local items item + ble/string#split-words items "$bleopt_histdb_stats_items" + for item in "${items[@]}"; do + ble/histdb/sub:stats/item:"$item" init + done + + local IFS=$_ble_term_IFS + ble/histdb/sub:query -separator ' ' "${queries[*]}" | { + local result + ble/util/mapfile result + + local ret sgr0=$_ble_term_sgr0 + ble/color/gspec2sgr 'fg=27,bold'; local sgr1=$ret + ble/histdb/sub:stats/get-user-name + ble/util/print "$sgr1$ret's Shell Stats${period:+ ($period)}$sgr0" + + local -a names=() values=() + local i=0 + for item in "${items[@]}"; do + ble/histdb/sub:stats/item:"$item" get "${result[i++]}" + done + + local name max_name_width=0 + for name in "${names[@]}"; do + local w=$((${#name}+1)) + ((max_name_width&2 + elif [[ $opt == -? ]]; then + opt=${opt:1} + getopts_short_options=$getopts_short_options'('\'${opt//$q/$Q}\'') + if [[ ${arg:1} ]]; then + '$var'=${arg:1} arg= + elif (($#)); then + '$var'=$1 + shift + else + ble/util/print "$_getopts_label: missing option argument for '\''-$arg'\''" >&2 + flags=E$flags + fi ;; + ' + fi +} +function ble/getopts/scan-definition:parser/arguments { + local var=${1:-args} + getopts_arguments=$getopts_arguments' + ble/array#push '$var' "$arg" + ' +} + +function ble/getopts/generate-parser { + local getopts_finalize= + local getopts_initialize= + local getopts_label= + local getopts_long_options= + local getopts_short_options= + local getopts_arguments= + + ble/getopts/scan-definition parser "$2" + + if [[ ! $getopts_arguments ]]; then + getopts_arguments=' + ble/util/print "$_getopt_label: unrecognized argument '\''$arg'\''" >&2 + flags=E$flags + ' + fi + + local getopts_script=' + local _ble_local_set _ble_local_shopt + ble/base/.adjust-bash-options _ble_local_set _ble_local_shopt + local LC_ALL= LC_COLLATE=C 2>/dev/null + + local _getopts_label='$q${getopts_label//$q/$Q}$q' + + flags= + '$getopts_initialize' + while (($#)); do + local arg=$1; shift + if [[ $arg == -?* && $flags != *-* ]]; then + if [[ $arg == --* ]]; then + case $arg in + (--) flags=-$flags ;; + '$getopts_long_options' + (*) + ble/util/print "$_getopts_label: unrecognized long option '\''$arg'\''" >&2 + flags=E$flags ;; + esac + else + arg=${arg:1} + while [[ $arg ]]; do + case ${arg::1} in + '$getopts_short_options' + (*) + ble/util/print "$_getopts_label: unrecognized option '\''-${arg::1}'\''" >&2 + flags=E$flags ;; + esac + arg=${arg:1} + done + fi + continue + fi + + '$getopts_arguments' + done + '$getopts_finalize' + + ble/util/unlocal LC_ALL LC_COLLATE 2>/dev/null + ble/base/.restore-bash-options _ble_local_set _ble_local_shopt + [[ $flags != *E* ]] + ' + + builtin eval -- "function $1 { $getopts_script }" +} + +#------------------------------------------------------------------------------ +# lib: ble/histdb/graph + +## @fn ble/histdb/graph/board/initialize +## @arr[out] grboard_export +function ble/histdb/graph/board/initialize { + local -a colors + ble/histdb/graph/palette "$2" + + local mark=$1 + if [[ ! $mark ]]; then + if ble/util/is-unicode-output; then + mark='■' + else + mark='##' + fi + fi + + grboard_export=() + ble/array#push grboard_export "grboard_nlevel=${#colors[@]}" + + local i ret + for i in "${!colors[@]}"; do + ble/color/gspec2sgr "fg=${colors[i]}" + ble/array#push grboard_export "grboard_unit$i=$ret$mark$_ble_term_sgr0" + done + + local ret + ble/util/s2w "$mark"; local w=$ret + ble/string#reserve-prototype "$w" + ble/array#push grboard_export "grboard_unit_white=${_ble_string_prototype::w}" +} +_ble_histdb_grboard_awk_lib=' + function grboard_initialize(_, i) { + grboard_nlevel = ENVIRON["grboard_nlevel"]; + grboard_unit[-1] = ENVIRON["grboard_unit_white"]; + for (i = 0; i < grboard_nlevel; i++) + grboard_unit[i] = ENVIRON["grboard_unit" i]; + } + function grboard__score2unit(score, score_max) { + if (score == "" || score < 0) + return grboard_unit[-1]; + else if (score == 0) + return grboard_unit[0]; + else + return grboard_unit[1 + int((grboard_nlevel - 1) * score / (score_max + 1))]; + } + function grboard_render(lines, table, w, h, _, x, y, maxv, v, line) { + maxv = 0; + for (y = 0; y < h; y++) + for (x = 0; x < w; x++) + if (table[y, x] > maxv) + maxv = table[y, x]; + + for (y = 0; y < h; y++) { + line = ""; + for (x = 0; x < w; x++) { + v = table[y, x]; + line = line grboard__score2unit(v, maxv); + } + lines[y] = line; + } + } +' + +## @fn ble/histdb/graph/vbar/initialize [palette] +## @var[out] grvbar_declare +function ble/histdb/graph/vbar/initialize { + local -a colors + ble/histdb/graph/palette "$1" + local gspec=${colors[0]} + + grvbar_declare=() + + local ret sgr1= sgr0= + if ble/util/is-unicode-output; then + local nlevel=8 + if [[ $gspec ]]; then + ble/color/gspec2sgr "fg=$gspec" + sgr1=$ret sgr0=$_ble_term_sgr0 + fi + ble/util/c2w "$((0x2581))"; local w=$ret + ble/array#push grvbar_declare grvbar_nlevel="$nlevel" grvbar_unit0=' ' + local i + for ((i=1;i<=nlevel;i++)); do + ble/util/c2s "$((0x2580+i))" + ((w==1)) && ret=$ret$ret + ble/array#push grvbar_declare "grvbar_unit$i=$sgr1$ret$sgr0" + done + else + if [[ $gspec ]]; then + ble/color/gspec2sgr "bg=$gspec" + sgr1=$ret sgr0=$_ble_term_sgr0 + fi + ble/array#push grvbar_declare grvbar_nlevel=1 grvbar_unit0=' ' grvbar_unit1="$sgr1 $sgr0" + fi +} +_ble_histdb_grvbar_awk_lib=' + function grvbar_initialize(_, i) { + grvbar_nlevel = ENVIRON["grvbar_nlevel"]; + grvbar_unit[-1] = ENVIRON["grvbar_unit_white"]; + for (i = 0; i <= grvbar_nlevel; i++) + grvbar_unit[i] = ENVIRON["grvbar_unit" i]; + } + function grvbar__score2unit(score, score_max) { + if (score <= 0) + return grvbar_unit[0]; + else + return grvbar_unit[1 + int((grvbar_nlevel - 1) * score / (score_max + 1))]; + } + function grvbar__clamp(x, l, u) { + return x < l ? l : x > u ? u : x; + } + function grvbar_render(lines, list, w, h, _, x, y, maxv, line, s) { + maxv = 0; + for (x = 0; x < w; x++) + if (list[x] > maxv) + maxv = list[x]; + for (y = 0; y < h; y++) { + line = "" + for (x = 0; x < w; x++) { + s = int((grvbar_nlevel * h + 1) * list[x] / (maxv + 1)); + line = line grvbar_unit[grvbar__clamp(s - y * grvbar_nlevel, 0, grvbar_nlevel)]; + } + lines[h - 1 - y] = line; + } + } +' + +function ble/histdb/graph/palette { + local palette=$1 + + local index= + if ble/string#match "$palette" '\[([0-9]+)\]$'; then + index=${BASH_REMATCH[1]} + palette=${palette::${#palette}-${#BASH_REMATCH}} + fi + if [[ ! $palette ]]; then + local ret + ble/util/strftime -v ret '%m' + case ${ret#0} in + (10) palette=github-halloween ;; + (12) palette=github-winter ;; + (*) palette=github-light ;; + esac + fi + + # https://github.com/orgs/community/discussions/7078 + case $palette in + (github-light24) colors=('#ebedf0' '#9be9a8' '#30c463' '#30a14e' '#216e39') ;; + (github-dark24) colors=('#161b22' '#0e4429' '#006d32' '#26a641' '#39d353') ;; + (halloween-light24) colors=('#ebedf0' '#ffee4a' '#ffc501' '#fe9600' '#03001c') ;; + (halloween-dark24) colors=('#161b22' '#631c03' '#bd561d' '#fa7a18' '#fddf68') ;; + (winter-light24) colors=('#ebedf0' '#b6e3ff' '#54aeff' '#0969da' '#0a3069') ;; + (winter-dark24) colors=('#161b22' '#0a3069' '#0969da' '#54aeff' '#b6e3ff') ;; + (github-light) colors=(255 151 77 71 23) ;; + (github-dark) colors=(234 22 23 35 77) ;; + (halloween-light) colors=(255 227 220 208 232) ;; + (halloween-dark) colors=(234 52 130 208 221) ;; + (winter-light) colors=(255 153 75 26 23) ;; + (winter-dark) colors=(234 23 26 75 153) ;; + (rainbow) + colors=({196..220..6} {190..46..36}) ;; + (rainbow2) + colors=({16..21} {21..45..6} {51..46} {82..190..36} {220..196..6}) ;; + (*) + ble/string#split colors , "$z1" + esac + + # specify one color + if [[ $index ]]; then + colors=("${colors[index<${#colors[@]}?index:0]}") + fi +} + +## @fn ble/histdb/graph/hbar/initialize [palette] +## @var[out] grhbar_declare +function ble/histdb/graph/hbar/initialize { + local -a colors + ble/histdb/graph/palette "$1" + + grhbar_declare=() + + local -a sgr=() + local ret + if ble/util/is-unicode-output; then + local nlevel=8 + if ((${#colors[@]})); then + sgr[0]=$_ble_term_sgr0 + local color + for color in "${colors[@]}"; do + ble/color/gspec2sgr "fg=$color" + ble/array#push sgr "$ret" + done + fi + + ble/util/c2w "$((0x2588))"; local w=$ret + ble/array#push grhbar_declare grhbar_wfactor="$((w==1?2:1))" + + local i unit + unit[0]=' ' + for ((i=1;i<=nlevel;i++)); do + ble/util/c2s "$((0x2590-i))" + ble/array#push unit "$ret" + done + + ble/array#push grhbar_declare grhbar_unit0=' ' + for ((i=1;i<=nlevel;i++)); do + ble/array#push grhbar_declare "grhbar_unit$i=${unit[i]}" + done + ble/array#push grhbar_declare grhbar_nlevel="$nlevel" + else + if ((${#colors[@]})); then + sgr[0]=$_ble_term_sgr0 + local color + for color in "${colors[@]}"; do + ble/color/gspec2sgr "bg=$color" + ble/array#push sgr "$ret" + done + fi + ble/array#push grhbar_declare grhbar_nlevel=1 grhbar_unit0=' ' grhbar_unit1=' ' + ble/array#push grhbar_declare grhbar_wfactor=2 + fi + + local glevel=$((${#sgr[@]}-1)) + ble/array#push grhbar_declare grhbar_glevel="$glevel" + for ((i=0;i<=glevel;i++)); do + ble/array#push grhbar_declare "grhbar_sgr$i=${sgr[i]}" + done +} +_ble_histdb_grhbar_awk_lib=' + function grhbar_initialize(_, i) { + grhbar_wfactor = ENVIRON["grhbar_wfactor"]; + + grhbar_nlevel = ENVIRON["grhbar_nlevel"]; + for (i = 0; i <= grhbar_nlevel; i++) + grhbar_unit[i] = ENVIRON["grhbar_unit" i]; + + grhbar_glevel = ENVIRON["grhbar_glevel"]; + if (grhbar_glevel > 0) { + for (i = 0; i <= grhbar_glevel; i++) + grhbar_sgr[i] = ENVIRON["grhbar_sgr" i]; + } else { + grhbar_glevel = 0; + grhbar_sgr[0] = ""; + grhbar_sgr[1] = ""; + } + } + function grhbar__score2unit(score, score_max) { + if (score <= 0) + return grhbar_unit[0]; + else + return grhbar_unit[1 + int((grhbar_nlevel - 1) * score / (score_max + 1))]; + } + function grhbar__clamp(x, l, u) { + return x < l ? l : x > u ? u : x; + } + function grhbar_render(lines, list, w, h, _, x, y, maxv, line, s, sunit, color) { + w *= grhbar_wfactor; + maxv = 0; + for (y = 0; y < w; y++) + if (list[y] > maxv) + maxv = list[y]; + for (y = 0; y < h; y++) { + line = "" + s = int((grhbar_nlevel * w + 1) * list[y] / (maxv + 1)); + for (x = 0; x < w; x++) { + sunit = grhbar__clamp(s - x * grhbar_nlevel, 0, grhbar_nlevel); + color = grhbar_sgr[sunit ? grhbar__clamp(1 + int(grhbar_glevel * x / (w - 1)), 1, grhbar_glevel): 0]; + line = line color grhbar_unit[sunit]; + } + lines[y] = line grhbar_sgr[0]; + } + } +' + +#------------------------------------------------------------------------------ +# usage: ble-histdb top [-x regex|-s regex] + +function ble/histdb/sub:top/define { + label 'ble-histdb-top' + option exclude -x + option has_subcommand -s + option count -c +} +ble/getopts/generate-parser ble/histdb/sub:top/read-arguments ble/histdb/sub:top/define + +function ble/histdb/sub:top { + local flags= + local -x exclude= has_subcommand= count=20 + ble/histdb/sub:top/read-arguments "$@" || return 2 + + local grhbar_declare + ble/histdb/graph/hbar/initialize rainbow + local -x "${grhbar_declare[@]}" # disable=#D1566 + + local ret + ble/color/gspec2sgr 'bold' + local -x sgr_cmd=$ret + local -x sgr0=$_ble_term_sgr0 + + ble-histdb | ble/bin/awk ' + BEGIN { + has_subcommand = "^(" ENVIRON["has_subcommand"] ")$"; + to_exclude = "^(" ENVIRON["exclude"] ")$"; + } + { + sub(/^[[:space:]]+/, ""); + sub(/^\(\(?/, "& "); + if ($1 ~ to_exclude) next; + + subcommand = ""; + if ($1 ~ has_subcommand) { + for (i = 2; i <= NF; i++) { + if ($i ~ /^-.+/) continue; + subcommand = $i + break; + } + } + + if (subcommand != "") { + print $1 " " subcommand; + } else { + print $1; + } + } + ' | ble/bin/sort | uniq -c | ble/bin/sort -nr | ble/bin/awk -v count="$count" ' + '"$_ble_histdb_grhbar_awk_lib"' + BEGIN { + grhbar_initialize(); + g_entry_count = 0; + sgr_cmd = ENVIRON["sgr_cmd"]; + sgr0 = ENVIRON["sgr0"]; + } + { + i = g_entry_count++; + g_score[i] = $1; + g_command[i] = $0; + if (g_entry_count >= count) exit; + } + END { + grhbar_render(lines_hbar, g_score, 6, g_entry_count); + for (i = 0; i < g_entry_count; i++) { + sub(/[0-9]+ /, "&[" lines_hbar[i] "] " sgr_cmd, g_command[i]); + print g_command[i] sgr0; + } + } + ' +} + +#------------------------------------------------------------------------------ +# usage: ble-histdb calendar +# usage: ble-histdb week + +function ble/histdb/sub:calendar { + local palette=$1 + + local grboard_export + ble/histdb/graph/board/initialize '' "$palette" + local -x "${grboard_export[@]}" # disable=#D1566 + + local grvbar_declare + ble/histdb/graph/vbar/initialize "$palette[2]" + local -x "${grvbar_declare[@]}" # disable=#D1566 + + local awk + if ble/is-function ble/bin/mawk; then + awk=ble/bin/mawk + elif ble/is-function ble/bin/gawk; then + awk=ble/bin/mawk + else + printf 'ble-histdb-calendar: gawk or mawk is needed.' >&2 + return 1 + fi + + ble/histdb/sub:query -separator ' ' "SELECT strftime('%Y %j %w', issue_time, 'unixepoch', 'localtime') AS date FROM command_history;" | + sort | uniq -c | "$awk" ' + '"$_ble_histdb_grboard_awk_lib"' + '"$_ble_histdb_grvbar_awk_lib"' + + BEGIN { + grboard_initialize(); + grvbar_initialize(); + + split("Sun,Mon,Tue,Wed,Thu,Fri,Sat, ", c_weekday, ","); + split("Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec", c_month, ","); + } + function initialize_year(year, _, i) { + g_year = year; + g_year_nday = 0 + strftime("%j", mktime(year " 12 31 01 00 00")); + g_year_wday_offset = 0 + strftime("%w", mktime(year " 01 01 01 00 00")); + g_score_max = 0; + g_score_total = 0; + for (i = -g_year_wday_offset; i < g_year_nday; i++) + g_score[i] = 0; + } + function flush_year(_, line, i, x, y, w, m, iday, iweek, lines, score_table, score_weekly) { + if (g_year == "" || g_year == 1970) return; + + print "\x1b[1m# " g_year " (total = " g_score_total ", max = " g_score_max ")\x1b[m"; + print ""; + + line = c_weekday[8]; + x = 0; + for (m = 1; m <= 12; m++) { + iday = strftime("%j", mktime(g_year sprintf(" %02d 01 01 00 00", m))) - 1; + iweek = int((iday + g_year_wday_offset) / 7); + line = line sprintf("%*s", iweek * 2 - x, "") c_month[m]; + x = iweek * 2 + length(c_month[m]); + } + print line; + + # Fill score_table and score_weekly + w = 0; + for (i = -g_year_wday_offset; i < g_year_nday; i++) { + y = (i + g_year_wday_offset) % 7; + x = int((i + g_year_wday_offset) / 7); + if (x >= w) w = x + 1; + + score_table[y, x] = i < 0 ? -1 : g_score[i]; + score_weekly[x] += g_score[i]; + } + + grboard_render(lines, score_table, w, 7); + for (y = 0; y < 7; y++) print c_weekday[1 + y] lines[y]; + + grvbar_render(lines, score_weekly, w, 3); + for (y = 0; y < 3; y++) print c_weekday[8] lines[y]; + + print ""; + } + + $2 != g_year { + flush_year(); + initialize_year($2); + } + { + yday = $3 - 1; + g_score[yday] = $1; + g_score_total += $1; + if ($1 > g_score_max) + g_score_max = $1; + } + + END { + flush_year(); + } + ' +} + +function ble/histdb/sub:week { + local palette=$1 + + local grboard_export + ble/histdb/graph/board/initialize '●' "$palette" + local -x "${grboard_export[@]}" # disable=#D1566 + + local grvbar_declare + ble/histdb/graph/vbar/initialize "$palette[2]" + local -x "${grvbar_declare[@]}" # disable=#D1566 + + local grhbar_declare + ble/histdb/graph/hbar/initialize "$palette[2]" + local -x "${grhbar_declare[@]}" # disable=#D1566 + + ble/histdb/sub:query -separator ' ' "SELECT strftime('%w %H', issue_time, 'unixepoch', 'localtime') AS date FROM command_history;" | + sort | uniq -c | ble/bin/awk ' + '"$_ble_histdb_grboard_awk_lib"' + '"$_ble_histdb_grvbar_awk_lib"' + '"$_ble_histdb_grhbar_awk_lib"' + + BEGIN { + grboard_initialize(); + grvbar_initialize(); + grhbar_initialize(); + split("Sun,Mon,Tue,Wed,Thu,Fri,Sat, ", c_weekday, ","); + } + { + y = $2 + 0; + x = $3 + 0; + g_score[y, x] += $1; + g_score[x] += $1; + g_score_wday[y] += $1; + } + END { + line = c_weekday[8]; + for (h = 0; h < 24; h++) + line = line sprintf(h % 3 == 0 ? "%02d" : " ", h); + print line; + + grboard_render(lines, g_score, 24, 7); + grhbar_render(lines_hbar, g_score_wday, 4, 7); + for (y = 0; y < 7; y++) print c_weekday[1 + y] lines[y] lines_hbar[y]; + + grvbar_render(lines, g_score, 24, 3); + for (y = 0; y < 3; y++) print c_weekday[8] lines[y]; + } + ' +} diff --git a/.local/share/blesh/contrib/integration/bash-preexec.bash b/.local/share/blesh/contrib/integration/bash-preexec.bash new file mode 100644 index 0000000..ac74c19 --- /dev/null +++ b/.local/share/blesh/contrib/integration/bash-preexec.bash @@ -0,0 +1,180 @@ +# ble/contrib/integration/bash-preexec.bash (C) 2022-2023, akinomyoga + +## @arr[in] precmd_functions +## @arr[in] preexec_functions +## The functions registered to these arrays are executed on PRECMD and +## PREEXEC hooks, respectively. +## +## @fn[in] precmd +## @fn[in] preexec +## If these functions are defined, they are executed on PRECMD and PREEXEC +## hooks, respectively, through "precmd_functions" and "preexec_functions". +## +## +## * Integration with bash-preexec.sh (https://github.com/rcaloras/bash-preexec) +## +## Although this script works without bash-preexec, it provides a better +## integration with bash-preexec when bash-preexec is loaded. The +## integration relies on the following public API of bash-preexec. +## +## @fn __bp_precmd_invoke_functions lastexit lastarg +## @fn __bp_preexec_invoke_functions lastexit lastarg this_command +## @fn __bp_uninstall +## @var __bp_trapdebug_string +## @var __bp_install_string + +function ble/contrib/integration:bash-preexec/add-convenience-functions { + ble/array#remove precmd_functions precmd + ble/array#remove preexec_functions preexec + ble/array#unshift precmd_functions precmd + ble/array#unshift preexec_functions preexec +} + +function ble/contrib/integration:bash-preexec/precmd.hook { + local _ble_local_lastexit=$? _ble_local_lastarg=$_ + + # Emulate bash-preexec variables + __bp_last_ret_value=$_ble_local_lastexit + __bp_last_argument_prev_command=$_ble_local_lastarg + BP_PIPESTATUS=("${BLE_PIPESTATUS[@]}") + local __bp_inside_precmd=1 + + # local __bp_blesh_invoking_through_blesh=1 # XXX + if ble/is-function __bp_precmd_invoke_functions; then + __bp_precmd_invoke_functions "$_ble_local_lastexit" "$_ble_local_lastarg" + else + # For older bash-preexec.sh / without bash-preexec.sh + local _ble_local_hook + for _ble_local_hook in "${precmd_functions[@]}"; do + if ble/bin#has "$_ble_local_hook"; then + ble/util/setexit "$_ble_local_lastexit" "$_ble_local_lastarg" + "$_ble_local_hook" + fi + done + fi +} + +function ble/contrib/integration:bash-preexec/preexec.hook { + local _ble_local_lastexit=$? _ble_local_lastarg=$_ _ble_local_command=$1 + + # Emulate bash-preexec variables + local __bp_inside_preexec=1 + + # local __bp_blesh_invoking_through_blesh=1 # XXX + if ble/is-function __bp_preexec_invoke_functions; then + __bp_preexec_invoke_functions "$_ble_local_lastexit" "$_ble_local_lastarg" + else + # For older bash-preexec.sh / without bash-preexec.sh + local _ble_local_hook + for _ble_local_hook in "${preexec_functions[@]}"; do + if ble/bin#has "$_ble_local_hook"; then + ble/util/setexit "$_ble_local_lastexit" "$_ble_local_lastarg" + "$_ble_local_hook" "$_ble_local_command" + fi + done + fi +} + +## @fn ble/contrib/integration:bash-preexec/attach.hook +## Remove bash-preexec hooks +function ble/contrib/integration:bash-preexec/attach.hook { + local BP_TRAPDEBUG_STRING=${__bp_trapdebug_string:-'__bp_preexec_invoke_exec "$_"'} + + # Remove bash-preexec preexec hook in builtin DEBUG trap. + local trap_string q="'" Q="'\''" + ble/util/assign trap_string 'builtin trap -p DEBUG' + if [[ $trap_string == "trap -- '${BP_TRAPDEBUG_STRING//$q/$Q}' DEBUG" ]]; then + if [[ ${__bp_trap_string-} ]]; then + builtin eval -- "builtin $__bp_trap_string" + else + builtin trap - DEBUG + fi + fi + + if ble/is-function __bp_uninstall; then + __bp_uninstall + else + # For older bash-preexec.sh + + local BP_INSTALL_STRING=${__bp_install_string:-$'__bp_trap_string="$(trap -p DEBUG)"\ntrap - DEBUG\n__bp_install'} + local BP_PROMPT_COMMAND_PREFIX=__bp_precmd_invoke_cmd + local BP_PROMPT_COMMAND_SUFFIX=__bp_interactive_mode + + # Remove __bp_install hook from PROMPT_COMMAND + if [[ ${PROMPT_COMMAND-} == *"$__bp_install_string"* ]]; then + PROMPT_COMMAND="${PROMPT_COMMAND//$BP_INSTALL_STRING[;$'\n']}" # Edge case of appending to PROMPT_COMMAND + PROMPT_COMMAND="${PROMPT_COMMAND//$BP_INSTALL_STRING}" + fi + + # Remove precmd hook from PROMPT_COMMAND + local i prompt_command + for i in "${!PROMPT_COMMAND[@]}"; do + prompt_command=${PROMPT_COMMAND[i]} + case $prompt_command in + ("$BP_PROMPT_COMMAND_PREFIX"|"$BP_PROMPT_COMMAND_SUFFIX") + prompt_command= ;; + (*) + prompt_command=${prompt_command/#"$BP_PROMPT_COMMAND_PREFIX"$'\n'/$'\n'} + prompt_command=${prompt_command%$'\n'"$BP_PROMPT_COMMAND_SUFFIX"} + prompt_command=${prompt_command#$'\n'} + esac + PROMPT_COMMAND[i]=$prompt_command + done + + # Remove preexec hook in the DEBUG trap + local q="'" Q="'\''" trap_string + ble/util/assign trap_string 'trap -p DEBUG' + if [[ $trap_string == "trap -- '${BP_TRAPDEBUG_STRING//$q/$Q}' DEBUG" ]]; then + if [[ ${__bp_trap_string-} ]]; then + builtin eval -- "$__bp_trap_string" + else + trap - DEBUG + fi + fi + fi +} +ble/function#trace ble/contrib/integration:bash-preexec/attach.hook + +## @fn ble/contrib/integration:bash-preexec/detach.hook +function ble/contrib/integration:bash-preexec/detach.hook { + # Reinstall bash-preexec hooks + local BP_INSTALL_STRING=${__bp_install_string-} + [[ ! $BP_INSTALL_STRING ]] && ble/is-function __bp_install && + BP_INSTALL_STRING=$'__bp_trap_string="$(trap -p DEBUG)"\ntrap - DEBUG\n__bp_install' + + builtin eval -- "$__bp_install_string" + + # Note: 重複して登録される (古い bash-preexec.sh) かもしれないし、全 + # く登録されない (bash-preexec.sh をロードしていない時) かもしれない + # ので、ble.sh 側で末尾で一回呼び出す形に修正する。 + ble/contrib/integration:bash-preexec/add-convenience-functions +} + +ble/contrib/integration:bash-preexec/add-convenience-functions +blehook PRECMD!=ble/contrib/integration:bash-preexec/precmd.hook +blehook PREEXEC!=ble/contrib/integration:bash-preexec/preexec.hook +blehook ATTACH!=ble/contrib/integration:bash-preexec/attach.hook +blehook DETACH!=ble/contrib/integration:bash-preexec/detach.hook +if [[ ${bash_preexec_imported-${__bp_imported-}} ]]; then + ble/contrib/integration:bash-preexec/attach.hook +fi + +# prevent bash-preexec.sh to be loaded +blehook ATTACH-=ble/contrib/integration:bash-preexec/loader +blehook POSTEXEC-=ble/contrib/integration:bash-preexec/loader +bash_preexec_imported=defined +__bp_imported=defined + +# XXX: 以下は uninstall で削除しきれなかった時の為の保険。今の所不要に思われる。 +# __bp_blesh_check() { +# if [[ $BLE_ATTACHED && ! ${__bp_blesh_invoking_through_blesh-} ]]; then +# ble/contrib/integration:bash-preexec/attach.hook +# fi +# } +# precmd_function+=(__bp_blesh_check) +# preexec_function+=(__bp_blesh_check) + +# Some settings rely on the internal APIs of bash-preexec. For example, iTerm2 +# shell integration uses "__bp_set_ret_value" and +# "$__bp_last_argument_prev_command". +function __bp_set_ret_value { return ${1:+"$1"}; } diff --git a/.local/share/blesh/contrib/integration/fzf-completion.bash b/.local/share/blesh/contrib/integration/fzf-completion.bash new file mode 100644 index 0000000..5f83287 --- /dev/null +++ b/.local/share/blesh/contrib/integration/fzf-completion.bash @@ -0,0 +1,62 @@ +# ble/contrib/integration/fzf-completion.bash (C) 2020-2023, akinomyoga + +ble-import contrib/integration/fzf-initialize + +[[ $- == *i* ]] || return 0 + +# fzf/shell/completion.bash を未ロードの時のみロードする +if ! ble/is-function _fzf_complete; then + if [[ -f $_ble_contrib_fzf_base/completion.bash ]]; then + source "$_ble_contrib_fzf_base/completion.bash" + elif [[ -f $_ble_contrib_fzf_base/shell/completion.bash ]]; then + source "$_ble_contrib_fzf_base/shell/completion.bash" + elif [[ $_ble_contrib_fzf_base == */share/fzf && -f /etc/bash_completion.d/fzf ]]; then + source /etc/bash_completion.d/fzf + fi +fi + +# clear blesh completer for cd +blehook/eval-after-load complete 'builtin unset -f ble/cmdinfo/complete:cd' + +# patch fzf functions +ble/function#advice around __fzf_generic_path_completion _fzf_complete.advice +ble/function#advice around _fzf_complete _fzf_complete.advice +ble/function#advice around _fzf_complete_kill _fzf_complete.advice +function _fzf_complete.advice { + if [[ ! ${_ble_attached-} ]]; then + ble/function#push caller 'builtin caller ${1+"$(($1+6))"}' + ble/function#advice/do + ble/function#pop caller + return 0 + fi + + [[ :$comp_type: == *:auto:* || :$comp_type: == *:[maA]:* ]] && return 0 + compopt -o ble/syntax-raw + if [[ ! ${_ble_contrib_fzf_comp_words_raw-} ]]; then + local _ble_contrib_fzf_comp_words_raw=1 + local COMP_WORDS; COMP_WORDS=("${comp_words[@]}") + local COMP_CWORD=$comp_cword + local COMP_LINE=$comp_line COMP_POINT=$comp_point + fi + ble/function#push printf '[[ $1 == "\e[5n" ]] || builtin printf "$@"' + ble/function#push caller 'builtin caller ${1+"$(($1+6))"}' + ble/term/leave-for-widget + if [[ ${ADVICE_WORDS[0]} == _fzf_complete ]]; then + ble/function#advice/do >&"${_ble_util_fd_tty_stdout:-1}" 2>&"${_ble_util_fd_tty_stderr:-2}" + else + ble/function#advice/do >&"${_ble_util_fd_tty_stdout:-1}" 2>&"${_ble_util_fd_tty_stderr:-2}" <&"${_ble_util_fd_tty_stdin:-0}" + fi + ble/term/enter-for-widget + ble/function#pop caller + ble/function#pop printf + ble/textarea#invalidate + + # 単一候補生成の場合は他の候補 (sabbrev 等) を消去して単一確定させる + if ((ADVICE_EXIT==0&&${#COMPREPLY[@]}==1)); then + compopt -o ble/no-default + ble/complete/candidates/clear + [[ $old_cand_count ]] && + ! ble/variable#is-global old_cand_count && + old_cand_count=0 + fi +} diff --git a/.local/share/blesh/contrib/integration/fzf-git.bash b/.local/share/blesh/contrib/integration/fzf-git.bash new file mode 100644 index 0000000..059b70d --- /dev/null +++ b/.local/share/blesh/contrib/integration/fzf-git.bash @@ -0,0 +1,322 @@ +# Copyright (c) 2016, 2022 Junegunn Choi +# ble/contrib/integration/fzf-git.bash (C) 2020, 2023, akinomyoga +# +# 2020-04-16 https://gist.github.com/junegunn/8b572b8d4b5eddd8b85e5f4d40f17236 (Revision 2019-03-14) +# 2023-06-30 https://gist.github.com/junegunn/8b572b8d4b5eddd8b85e5f4d40f17236 (Revision 2022-08-16) +# 2023-06-30 https://github.com/junegunn/fzf-git.sh/commit/4bc0323b4822b3426989863996cc266c52c7f25a +# 2023-06-30 https://github.com/junegunn/fzf-git.sh/commit/b6192ec86609afea761c7d3954f9b539a512dc80 +# 2023-11-09 https://github.com/junegunn/fzf-git.sh/blob/aacab4ae557657e0f9de288d688f312a28b86d21/fzf-git.sh + +if [[ $- != *i* ]]; then + if (($# == 1)); then + function ble/contrib/integration:fzf-git/sub:branches { + git branch "$@" --sort=-committerdate --sort=-HEAD --format=$'%(HEAD) %(color:yellow)%(refname:short) %(color:green)(%(committerdate:relative))\t%(color:blue)%(subject)%(color:reset)' --color=always | column -ts$'\t' + } + function ble/contrib/integration:fzf-git/sub:refs { + git for-each-ref --sort=-creatordate --sort=-HEAD --color=always --format=$'%(refname) %(color:green)(%(creatordate:relative))\t%(color:blue)%(subject)%(color:reset)' | + builtin eval -- "$1" | + sed 's#^refs/remotes/#\x1b[95mremote-branch\t\x1b[33m#; s#^refs/heads/#\x1b[92mbranch\t\x1b[33m#; s#^refs/tags/#\x1b[96mtag\t\x1b[33m#; s#refs/stash#\x1b[91mstash\t\x1b[33mrefs/stash#' | + column -ts$'\t' + } + case $1 in + (branches) + printf '%s\n' $'CTRL-O (open in browser) ╱ ALT-A (show all branches)\n' + ble/contrib/integration:fzf-git/sub:branches + ;; + (all-branches) + printf '%s\n' $'CTRL-O (open in browser)\n' + ble/contrib/integration:fzf-git/sub:branches -a + ;; + (refs) + printf '%s\n' $'CTRL-O (open in browser) ╱ ALT-E (examine in editor) ╱ ALT-A (show all refs)\n' + ble/contrib/integration:fzf-git/sub:refs 'grep -v ^refs/remotes' + ;; + (all-refs) + printf '%s\n' $'CTRL-O (open in browser) ╱ ALT-E (examine in editor)\n' + ble/contrib/integration:fzf-git/sub:refs 'cat' + ;; + (nobeep) ;; + (*) exit 1 ;; + esac + elif (($# > 1)); then + set -e + + branch=$(git rev-parse --abbrev-ref HEAD 2> /dev/null) + if [[ $branch = HEAD ]]; then + branch=$(git describe --exact-match --tags 2> /dev/null || git rev-parse --short HEAD) + fi + + # Only supports GitHub for now + case $1 in + (commit) + hash=$(grep -o "[a-f0-9]\{7,\}" <<< "$2") + path=/commit/$hash + ;; + (branch|remote-branch) + branch=$(sed 's/^[* ]*//' <<< "$2" | cut -d' ' -f1) + remote=$(git config branch."${branch}".remote || printf 'origin\n') + branch=${branch#$remote/} + path=/tree/$branch + ;; + (remote) + remote=$2 + path=/tree/$branch + ;; + (file) path=/blob/$branch/$(git rev-parse --show-prefix)$2 ;; + (tag) path=/releases/tag/$2 ;; + (*) exit 1 ;; + esac + + remote=${remote:-$(git config branch."${branch}".remote || printf 'origin\n')} + remote_url=$(git remote get-url "$remote" 2> /dev/null || printf '%s\n' "$remote") + + if [[ $remote_url =~ ^git@ ]]; then + url=${remote_url%.git} + url=${url#git@} + url=https://${url/://} + elif [[ $remote_url =~ ^http ]]; then + url=${remote_url%.git} + fi + + case $(uname -s) in + (Darwin) open "$url$path" ;; + (*) xdg-open "$url$path" ;; + esac + fi + exit 0 +fi + +#------------------------------------------------------------------------------ + +ble-import contrib/integration/fzf-initialize + +[[ $- == *i* ]] || return 0 + +## @fn ble/contrib/integration:fzf-git/initialize bash_source +## @param[in] bash_source +## @var[out] __fzf_git +function ble/contrib/integration:fzf-git/initialize { + local ret + ble/util/readlink "$1" + __fzf_git=$ret +} +ble/contrib/integration:fzf-git/initialize "${BASH_SOURCE[0]:-}" + +# GIT heart FZF +# ------------- + +#------------------------------------------------------------------------------ +# Redefine this function to change the options +_fzf_git_fzf() { + fzf-tmux -p80%,60% -- \ + --layout=reverse --multi --height=50% --min-height=20 --border \ + --border-label-pos=2 \ + --color='header:italic:underline,label:blue' \ + --preview-window='right,50%,border-left' \ + --bind='ctrl-/:change-preview-window(down,50%,border-top|hidden|)' "$@" +} + +function ble/contrib/integration:fzf-git/fzf { + [[ $_ble_term_state == internal ]] && ble/term/leave-for-widget + _fzf_git_fzf "$@" + local ext=$? + [[ $_ble_term_state == internal ]] && ble/term/enter-for-widget + return "$ext" +} + +_fzf_git_check() { + git rev-parse HEAD > /dev/null 2>&1 && return 0 + + [[ -n $TMUX ]] && tmux display-message "Not in a git repository" + return 1 +} + +if [[ -z $_fzf_git_cat ]]; then + # Sometimes bat is installed as batcat + export _fzf_git_cat="cat" + _fzf_git_bat_options="--style='${BAT_STYLE:-full}' --color=always --pager=never" + if command -v batcat > /dev/null; then + _fzf_git_cat="batcat $_fzf_git_bat_options" + elif command -v bat > /dev/null; then + _fzf_git_cat="bat $_fzf_git_bat_options" + fi +fi + +_fzf_git_files() { + _fzf_git_check || return "$?" + (git -c color.status=always status --short --no-branch + git ls-files | grep -vxFf <(git status -s | grep '^[^?]' | cut -c4-; ble/util/print :) | sed 's/^/ /') | + ble/contrib/integration:fzf-git/fzf -m --ansi --nth 2..,.. \ + --border-label '📁 Files' \ + --header $'CTRL-O (open in browser) ╱ ALT-E (open in editor)\n\n' \ + --bind "ctrl-o:execute-silent:bash $__fzf_git file {-1}" \ + --bind "alt-e:execute:${EDITOR:-vim} {-1} > /dev/tty" \ + --preview "git diff --no-ext-diff --color=always -- {-1} | sed 1,4d; $_fzf_git_cat {-1}" "$@" | + cut -c4- | sed 's/.* -> //' +} + +_fzf_git_branches() { + _fzf_git_check || return "$?" + bash "$__fzf_git" branches | + ble/contrib/integration:fzf-git/fzf --ansi \ + --border-label '🌲 Branches' \ + --header-lines 2 \ + --tiebreak begin \ + --preview-window down,border-top,40% \ + --color hl:underline,hl+:underline \ + --no-hscroll \ + --bind 'ctrl-/:change-preview-window(down,70%|hidden|)' \ + --bind "ctrl-o:execute-silent:bash $__fzf_git branch {}" \ + --bind "alt-a:change-prompt(🌳 All branches> )+reload:bash \"$__fzf_git\" all-branches" \ + --preview 'git log --oneline --graph --date=short --color=always --pretty="format:%C(auto)%cd %h%d %s" $(sed s/^..// <<< {} | cut -d" " -f1)' "$@" | + sed 's/^..//' | cut -d' ' -f1 +} + +_fzf_git_tags() { + _fzf_git_check || return "$?" + git tag --sort -version:refname | + ble/contrib/integration:fzf-git/fzf --preview-window right,70% \ + --border-label '📛 Tags' \ + --header $'CTRL-O (open in browser)\n\n' \ + --bind "ctrl-o:execute-silent:bash $__fzf_git tag {}" \ + --preview 'git show --color=always {}' "$@" +} + +_fzf_git_hashes() { + _fzf_git_check || return "$?" + git log --date=short --format="%C(green)%C(bold)%cd %C(auto)%h%d %s (%an)" --graph --color=always | + ble/contrib/integration:fzf-git/fzf --ansi --no-sort --bind 'ctrl-s:toggle-sort' \ + --border-label '🍡 Hashes' \ + --header $'CTRL-O (open in browser) ╱ CTRL-D (diff) ╱ CTRL-S (toggle sort)\n\n' \ + --bind "ctrl-o:execute-silent:bash $__fzf_git commit {}" \ + --bind 'ctrl-d:execute:grep -o "[a-f0-9]\{7,\}" <<< {} | head -n 1 | xargs git diff > /dev/tty' \ + --color hl:underline,hl+:underline \ + --preview 'grep -o "[a-f0-9]\{7,\}" <<< {} | head -n 1 | xargs git show --color=always' "$@" | + awk 'match($0, /[a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9]*/) { print substr($0, RSTART, RLENGTH) }' +} + +_fzf_git_remotes() { + _fzf_git_check || return "$?" + git remote -v | awk '{print $1 "\t" $2}' | uniq | + ble/contrib/integration:fzf-git/fzf --tac \ + --border-label '📡 Remotes' \ + --header $'CTRL-O (open in browser)\n\n' \ + --bind "ctrl-o:execute-silent:bash $__fzf_git remote {1}" \ + --preview-window right,70% \ + --preview 'git log --oneline --graph --date=short --color=always --pretty="format:%C(auto)%cd %h%d %s" {1}/"$(git rev-parse --abbrev-ref HEAD)"' "$@" | + cut -d$'\t' -f1 +} + +_fzf_git_stashes() { + _fzf_git_check || return "$?" + git stash list | ble/contrib/integration:fzf-git/fzf \ + --border-label '🥡 Stashes' \ + --header $'CTRL-X (drop stash)\n\n' \ + --bind 'ctrl-x:execute-silent(git stash drop {1})+reload(git stash list)' \ + -d: --preview 'git show --color=always {1}' "$@" | + cut -d: -f1 +} + +_fzf_git_lreflogs() { + _fzf_git_check || return "$?" + git reflog --color=always --format="%C(blue)%gD %C(yellow)%h%C(auto)%d %gs" | ble/contrib/integration:fzf-git/fzf --ansi \ + --border-label '📒 Reflogs' \ + --preview 'git show --color=always {1}' "$@" | + awk '{print $1}' +} + +_fzf_git_each_ref() { + _fzf_git_check || return "$?" + bash "$__fzf_git" refs | ble/contrib/integration:fzf-git/fzf --ansi \ + --nth 2,2.. \ + --tiebreak begin \ + --border-label '☘️ Each ref' \ + --header-lines 2 \ + --preview-window down,border-top,40% \ + --color hl:underline,hl+:underline \ + --no-hscroll \ + --bind 'ctrl-/:change-preview-window(down,70%|hidden|)' \ + --bind "ctrl-o:execute-silent:bash $__fzf_git {1} {2}" \ + --bind "alt-e:execute:${EDITOR:-vim} <(git show {2}) > /dev/tty" \ + --bind "alt-a:change-prompt(🍀 Every ref> )+reload:bash \"$__fzf_git\" all-refs" \ + --preview 'git log --oneline --graph --date=short --color=always --pretty="format:%C(auto)%cd %h%d %s" {2}' "$@" | + awk '{print $2}' +} +#------------------------------------------------------------------------------ + +# export FZF_DEFAULT_OPTS=--no-unicode + +: "${_ble_contrib_fzf_git_config=key-binding}" + +# original +function ble/contrib:integration/fzf-git/type:original/init { + ble/builtin/bind '"\er": redraw-current-line' +} +function ble/contrib:integration/fzf-git/type:original { + local binding='"\C-g\C-'$1'": "$(_fzf_git_'$2')\e\C-e\er"' + ble/builtin/bind "$binding" +} +# function ble/contrib:integration/fzf-git/type:original { +# local binding='"\C-g\C-'$1'": "$(_fzf_git_'$2')\M-\C-e\M-\C-l"' +# bind "$binding" +# } + +function ble/widget/fzf-git { + ble/widget/insert-string "$(_fzf_git_$1)" + ble/textarea#invalidate +} + +# key-binding +function ble/contrib:integration/fzf-git/type:key-binding { + ble-bind -f "C-g C-$1" "fzf-git $2" +} + +# sabbrev +function ble/contrib:integration/fzf-git/type:sabbrev/init { + function fzf-git.sabbrev { + COMPREPLY=$(_fzf_git_$1) + ble/textarea#invalidate + } +} +function ble/contrib:integration/fzf-git/type:sabbrev { + ble-sabbrev -m "g$1"="fzf-git.sabbrev $2" +} + +# arpeggio +function ble/contrib:integration/fzf-git/type:arpeggio/init { + ble-import 'lib/vim-arpeggio.sh' +} +function ble/contrib:integration/fzf-git/type:arpeggio { + ble/lib/vim-arpeggio.sh/bind -f "g$1" "fzf-git $2" +} + +# old-functions +function ble/contrib:integration/fzf-git/type:old-functions/init { + function is_in_git_repo { _fzf_git_check "$@"; } + function fzf-down { ble/contrib/integration:fzf-git/fzf "$@"; } +} +function ble/contrib:integration/fzf-git/type:old-functions { + # Note: To suppress duplicate adjustment of the terminal states, we override + # "_ble_term_state" with the temporary environment. I.e., when fzf is called + # through these old function names, we never adjust the terminal states. + builtin eval "function g$1 { _ble_term_state= _fzf_git_$2 \"\$@\"; }" +} + +function ble/contrib:integration/fzf-git/initialize { + local type + for type in original key-binding sabbrev arpeggio old-functions; do + [[ :$_ble_contrib_fzf_git_config: == *:"$type":* ]] || continue + + ble/function#try ble/contrib:integration/fzf-git/type:"$type"/init + ble/contrib:integration/fzf-git/type:"$type" f files + ble/contrib:integration/fzf-git/type:"$type" b branches + ble/contrib:integration/fzf-git/type:"$type" t tags + ble/contrib:integration/fzf-git/type:"$type" h hashes + ble/contrib:integration/fzf-git/type:"$type" r remotes + ble/contrib:integration/fzf-git/type:"$type" s stashes + ble/contrib:integration/fzf-git/type:"$type" l lreflogs + ble/contrib:integration/fzf-git/type:"$type" e each_ref + done + builtin unset -f "$FUNCNAME" +} +ble/contrib:integration/fzf-git/initialize diff --git a/.local/share/blesh/contrib/integration/fzf-initialize.bash b/.local/share/blesh/contrib/integration/fzf-initialize.bash new file mode 100644 index 0000000..8a5761c --- /dev/null +++ b/.local/share/blesh/contrib/integration/fzf-initialize.bash @@ -0,0 +1,53 @@ +# ble/contrib/integration/fzf-initialize.bash (C) 2020-2023, akinomyoga + +# Usage: Please write the following lines in blerc +# +# ```bash +# _ble_contrib_fzf_base=/path/to/fzf-base-directory +# ble-import -d integration/fzf-initialize +# ``` + +function ble/contrib/integration:fzf-completion/initialize { + if [[ -d $_ble_contrib_fzf_base ]]; then + if [[ -d $_ble_contrib_fzf_base/bin && :$PATH: != *:"$_ble_contrib_fzf_base/bin":* ]]; then + export PATH="${PATH:+${PATH}:}$_ble_contrib_fzf_base/bin" + fi + if ! ble/bin#has fzf; then + ble/util/print 'ble/contrib/integration:fzf-initialize: "fzf" not found.' >&2 + return 1 + fi + else + local path + if ! ble/bin#get-path fzf; then + ble/util/print 'ble/contrib/integration:fzf: "fzf" not found.' >&2 + return 1 + fi + local ret + ble/util/readlink "$path" + ret=${ret%/*} # fzf, fzf-linux_amd64, etc. + ret=${ret%/bin} # repo/bin/ + ret=${ret%/target} # repo/target (compile directory) + if [[ -s $ret/shell/key-bindings.bash ]]; then + _ble_contrib_fzf_base=$ret + elif [[ -d $ret/share/fzf/shell ]]; then + _ble_contrib_fzf_base=$ret/share/fzf + elif [[ -s $ret/share/fzf/key-bindings.bash ]]; then + # NixOS package (https://github.com/akinomyoga/blesh-contrib/pull/5#issuecomment-1019394821) + _ble_contrib_fzf_base=$ret/share/fzf + elif [[ -s $ret/share/doc/fzf/examples/key-bindings.bash ]]; then + # Ubuntu fzf package (https://github.com/akinomyoga/blesh-contrib/pull/5#issuecomment-1019394821) + _ble_contrib_fzf_base=$ret/share/doc/fzf/examples + elif [[ -d /usr/share/fzf/shell ]]; then + _ble_contrib_fzf_base=/usr/share/fzf + elif [[ -d /usr/share/doc/fzf/examples/key-bindings.bash ]]; then + # Ubuntu fzf package (https://github.com/akinomyoga/blesh-contrib/pull/5#issuecomment-1019394821) + _ble_contrib_fzf_base=/usr/share/doc/fzf/examples + else + ble/util/print 'ble/contrib/integration:fzf: failed to find "fzf" base directory' >&2 + return 1 + fi + fi + return 0 +} + +ble/contrib/integration:fzf-completion/initialize || return 1 diff --git a/.local/share/blesh/contrib/integration/fzf-key-bindings.bash b/.local/share/blesh/contrib/integration/fzf-key-bindings.bash new file mode 100644 index 0000000..fdb0133 --- /dev/null +++ b/.local/share/blesh/contrib/integration/fzf-key-bindings.bash @@ -0,0 +1,40 @@ +# ble/contrib/integration/fzf-key-bindings.bash (C) 2020-2023, akinomyoga + +ble-import contrib/integration/fzf-initialize + +[[ $- == *i* ]] || return 0 + +ble/function#push bind : +if [[ -f $_ble_contrib_fzf_base/key-bindings.bash ]]; then + source "$_ble_contrib_fzf_base/key-bindings.bash" +elif [[ -f $_ble_contrib_fzf_base/shell/key-bindings.bash ]]; then + source "$_ble_contrib_fzf_base/shell/key-bindings.bash" +fi +ble/function#pop bind + +function ble/contrib/integration:fzf-key-bindings/is-fzf-above-7c447bbd { + local def; ble/function#getdef __fzf_history__ + [[ $def == *READLINE_LINE=* ]] +} + +# CTRL-T - Paste the selected file path into the command line +ble-bind -m emacs -x C-t fzf-file-widget +ble-bind -m vi_imap -x C-t fzf-file-widget +ble-bind -m vi_nmap -s C-t 'i\C-t' + +# CTRL-R - Paste the selected command from history into the command line +ble-bind -m emacs -x C-r fzf-history-widget +ble-bind -m vi_imap -x C-r fzf-history-widget +ble-bind -m vi_nmap -s C-r 'i\C-r' +function fzf-history-widget { + READLINE_LINE=$(history -p "$(__fzf_history__)") + READLINE_POINT=${#READLINE_LINE} +} +((_ble_bash>=40000)) && + ble/contrib/integration:fzf-key-bindings/is-fzf-above-7c447bbd && + function fzf-history-widget { __fzf_history__; } + +# ALT-C - cd into the selected directory +ble-bind -m emacs -c M-c 'builtin eval -- "$(__fzf_cd__)"' +ble-bind -m vi_imap -c M-c 'builtin eval -- "$(__fzf_cd__)"' +ble-bind -m vi_nmap -c M-c 'builtin eval -- "$(__fzf_cd__)"' diff --git a/.local/share/blesh/contrib/integration/nix-completion.bash b/.local/share/blesh/contrib/integration/nix-completion.bash new file mode 100644 index 0000000..a229730 --- /dev/null +++ b/.local/share/blesh/contrib/integration/nix-completion.bash @@ -0,0 +1,27 @@ +# ble/contrib/integration/nix-completion.bash (C) 2023, akinomyoga + +[[ $- == *i* ]] || return 0 + +function ble/contrib/integration:nix-completion/_complete_nix.advice { + if [[ ${_ble_attached-} && " ${FUNCNAME[*]} " == *" ble/complete/progcomp/.compgen "* && ${COMP_WORDS[0]-} != *[\'\"\\]* ]]; then + local _ble_nix_cmd=${COMP_WORDS[0]-nix} ret + ble/function#push "$_ble_nix_cmd" ' + local IFS=$_ble_term_IFS + local -a args; args=("$@") + ble/util/conditional-sync "exec $_ble_nix_cmd \"\${args[@]}\"" \ + "! ble/complete/check-cancel <&$_ble_util_fd_tui_stdin" 128 progressive-weight:killall' + ble/function#advice/do + ble/function#pop "$_ble_nix_cmd" + else + ble/function#advice/do + return 0 + fi +} + +function ble/contrib/integration:nix-completion/adjust { + if ble/is-function _complete_nix; then + ble/function#advice around _complete_nix ble/contrib/integration:nix-completion/_complete_nix.advice + fi +} + +ble/contrib/integration:nix-completion/adjust diff --git a/.local/share/blesh/contrib/integration/zoxide.bash b/.local/share/blesh/contrib/integration/zoxide.bash new file mode 100644 index 0000000..7eaf0ab --- /dev/null +++ b/.local/share/blesh/contrib/integration/zoxide.bash @@ -0,0 +1,61 @@ +# ble/contrib/integration/zoxide.bash (C) 2022, akinomyoga + +function ble/contrib/integration:zoxide/completion.advice { + if [[ ! ${_ble_attached-} ]]; then + ble/function#advice/do + return 0 + fi + + [[ :$comp_type: == *:auto:* || :$comp_type: == *:[maA]:* ]] && return 0 + compopt -o noquote + + ble/term/leave-for-widget + ble/function#advice/do >/dev/null + ble/term/enter-for-widget + ble/textarea#invalidate + + # 単一候補生成の場合は他の候補 (sabbrev 等) を消去して単一確定させる + if ((ADVICE_EXIT==0&&${#COMPREPLY[@]}==1)); then + ble/complete/candidates/clear + [[ $old_cand_count ]] && + ! ble/variable#is-global old_cand_count && + old_cand_count=0 + fi +} + +function ble/contrib/integration:zoxide/command.advice { + if [[ ${_ble_attached-} && ${READLINE_MARK+set} ]]; then + ble/bin/stty icanon + ble/function#advice/do + ble/bin/stty -icanon + else + ble/function#advice/do + fi +} + +function ble/contrib/integration:zoxide/adjust { + local found= + if ble/is-function _z; then + ble/function#advice around _z ble/contrib/integration:zoxide/completion.advice + found=1 + fi + if ble/is-function __zoxide_z_complete; then + ble/function#advice around __zoxide_z_complete ble/contrib/integration:zoxide/completion.advice + found=1 + fi + if ble/is-function __zoxide_z; then + ble/function#advice around __zoxide_z ble/contrib/integration:zoxide/command.advice + found=1 + fi + if ble/is-function __zoxide_zi; then + ble/function#advice around __zoxide_zi ble/contrib/integration:zoxide/command.advice + found=1 + fi + [[ $found ]] +} + +if ! ble/contrib/integration:zoxide/adjust; then + ble/bin#has zoxide || return 1 + builtin eval -- "$(zoxide init bash)" + ble/contrib/integration:zoxide/adjust +fi diff --git a/.local/share/blesh/contrib/layer/pattern.bash b/.local/share/blesh/contrib/layer/pattern.bash new file mode 100644 index 0000000..8486566 --- /dev/null +++ b/.local/share/blesh/contrib/layer/pattern.bash @@ -0,0 +1,317 @@ +# ble/contrib/layer/pattern.bash (C) 2023, akinomyoga +# +# @fn ble/highlight/layer:{pattern}/declare name [type] +# Define a new layer named `name`. +# +# @param[in] name +# The name of the layer. +# @param[in,opt] type +# This specifies the type of the pattern of this layer. One of the +# following values. The default is `regexp`. +# +# regexp +# Regular expression +# glob +# Extended glob pattern +# glob-shortest +# Extended glob pattern. This tries to find the shortest match. +# +# @fn ble/highlight/layer:{pattern}/register name pattern gspec +# Register a pattern to the layer specified by `name`. +# +# @param[in] name +# The name of the layer. +# @param[in] pattern +# The pattern. The type of the pattern is specified by the argument `type` +# when the layer is created by `ble/highlight/layer:{pattern}/declare`. +# @param[in] gspec +# A string specifying the graphic style. See the description of +# ble/color/gspec2g. +# +# +# ```bash +# # blerc +# +# ble-import layer/pattern +# +# ble/highlight/layer:{pattern}/declare pattern1 +# ble/highlight/layer:{pattern}/register pattern1 'rm -rf [^;&|]*' 'fg=white,bold,bg=red' +# ble/array#insert-after _ble_highlight_layer_list syntax pattern1 +# +# ble/highlight/layer:{pattern}/declare pattern2 +# ble/highlight/layer:{pattern}/register pattern2 "$USER" 'fg=blue,bold' +# ble/highlight/layer:{pattern}/register pattern2 "$HOSTNAME" 'fg=green,bold' +# ble/highlight/layer:{pattern}/register pattern2 '[0-9]+' 'bg=216,fg=black' +# ble/array#insert-after _ble_highlight_layer_list pattern1 pattern2 +# ``` + +function ble/highlight/layer:{pattern}/declare { + local layer_name=$1 type=${2-regexp} + case $type in + (regexp | glob) ;; + (glob-shortest) type=sglob ;; + (*) + ble/util/print "$FUNCNAME: unrecognized pattern type '$type'." >&2 + return 2 ;; + esac + + # define dynamic variables + local layer_prefix=_ble_highlight_layer_${layer_name}_ + ble/highlight/layer:{selection}/declare "$layer_name" + ble/array#push "${layer_prefix}VARNAMES" "${layer_prefix}text" + ble/util/set "${layer_prefix}text" '' + + # define settings + local keys=${layer_prefix}keys + local dict=${layer_prefix}dict + builtin eval -- " + ${layer_prefix}type=$type + $keys=() + ${_ble_util_gdict_declare//NAME/$dict}" + + # define functions + local _ble_local_script=' + function ble/highlight/layer:LAYER/initialize-vars { + ble/highlight/layer:{pattern}/initialize-vars LAYER + } + function ble/highlight/layer:LAYER/update { + ble/highlight/layer:{pattern}/update LAYER "$@" + } + function ble/highlight/layer:LAYER/getg { + ble/highlight/layer:{pattern}/getg LAYER "$@" + }' + builtin eval -- "${_ble_local_script//LAYER/$layer_name}" +} + +function ble/highlight/layer:{pattern}/initialize-vars { + local layer_name=$1 + ble/highlight/layer:{selection}/initialize-vars "$layer_name" + ble/util/set "_ble_highlight_layer_${layer_name}_text" '' +} + +function ble/highlight/layer:{pattern}/register { + local layer_name=$1 pattern=$2 spec=${3-} + local keys=_ble_highlight_layer_${layer_name}_keys + local dict=_ble_highlight_layer_${layer_name}_dict + if [[ ${3+set} ]]; then + local ret + ble/color/gspec2g "$spec" + ble/gdict#has "$dict" "$pattern" || + ble/array#push "$keys" "$pattern" + ble/gdict#set "$dict" "$pattern" "$ret" + else + ble/array#remove "$keys" "$pattern" + ble/gdict#unset "$dict" "$pattern" + fi +} + +##----------------------------------------------------------------------------- +## Pattern types +## +## Each pattern layer instance is associated with a pattern type, and the +## pattern type defines how the pattern specified to layer:{pattern}/register +## should be treated. Currently, three types `regexp`, `glob`, and `sglob` are +## defined. To define a new pattern type, the following three functions should +## be prepared. +## +## @fn ble/highlight/layer:{pattern}/pattern:/create-gpat +## This function composes a pattern matching any of the registered patterns +## +## @arr[in] keys +## The list of patterns registered to the current layer. +## @var[out] gpat +## Stores a pattern that matches any of the registered pattern. +## +## @fn ble/highlight/layer:{pattern}/pattern:/match text pat +## This function tries to match PAT in TEXT and, if matching, stores the +## matched range in [MBEG, MEND) and returns the unmatched suffix in +## NEW_TAIL. +## +## @param[in] text +## The string where a matching substring is searched. +## @param[in] pat +## The pattern +## @var[out] mbeg mend +## Stores the matched range in TEXT. MBEG and MEND are the beginning and +## the end of the range, respectively. +## @var[out] new_tail +## Stores the unmatched remaining part of TEXT. In particular, the +## substring after MEND. +## @exit +## 0 if a matching is found, or otherwise 1. +## +## @fn ble/highlight/layer:{pattern}/pattern:regexp/match1 str pat +## This function tests if the specified string exactly matches the pattern. +## +## @param[in] str +## The string to be matched. +## @param[in] pat +## The pattern to matched STR. +## @exit +## 0 if the string matches the pattern, or otherwise 1 +## + +# pattern type: regexp + +function ble/highlight/layer:{pattern}/pattern:regexp/create-gpat { + IFS='|' builtin eval -- 'gpat="(${keys[*]})"' +} +function ble/highlight/layer:{pattern}/pattern:regexp/match { + ble/string#match "$1" "$2(.*)\$" || return 1 + new_tail=${BASH_REMATCH[${#BASH_REMATCH[@]}-1]} + mbeg=$((${#1}-${#BASH_REMATCH})) + mend=$((${#1}-${#new_tail})) + return 0 +} +function ble/highlight/layer:{pattern}/pattern:regexp/match1 { + [[ $1 =~ ^($2)$ ]] +} + +# pattern type: glob (longest extended glob matching) + +function ble/highlight/layer:{pattern}/pattern:glob/create-gpat { + IFS='|' builtin eval -- 'gpat="@(${keys[*]})"' +} +function ble/highlight/layer:{pattern}/pattern:glob/match { + local extglob= + shopt -q extglob && extglob=1 + shopt -s extglob + local prefix=${1%%$2*} ext=1 + if [[ $prefix != "$1" ]]; then + mbeg=${#prefix} + new_tail=${1:mbeg} + new_tail=${new_tail##$2} + ((mend=${#1}-${#new_tail})) + ext=0 + fi + [[ $extglob ]] || shopt -u extglob + return "$ext" +} +function ble/highlight/layer:{pattern}/pattern:glob/match1 { + [[ $1 == $2 ]] +} + +# pattern type: sglob (shortest extended glob matching) + +function ble/highlight/layer:{pattern}/pattern:sglob/create-gpat { + ble/highlight/layer:{pattern}/pattern:glob/create-gpat +} +function ble/highlight/layer:{pattern}/pattern:sglob/match { + local extglob= + shopt -q extglob && extglob=1 + shopt -s extglob + local prefix=${1%%$2*} ext=1 + if [[ $prefix != "$1" ]]; then + mbeg=${#prefix} + new_tail=${1:mbeg} + new_tail=${new_tail#$2} + ((mend=${#1}-${#new_tail})) + ext=0 + fi + [[ $extglob ]] || shopt -u extglob + return "$ext" +} +function ble/highlight/layer:{pattern}/pattern:sglob/match1 { + ble/highlight/layer:{pattern}/pattern:glob/match1 "$@" +} + +##----------------------------------------------------------------------------- + +function ble/highlight/layer:{pattern}/.match { + # If the text has the same content as the previous time, we skip the + # matching. + # + # Note: Initially, ((DMIN<0)) was used for the condition but turned out to be + # unusable for this purpose. DMIN only changes when the full content + # including the auto_complete insertion is changed. Even if the substantial + # part (excluding the auto_complete insertion) changes, DMIN can be negative + # when the full content does not change. + local rtext=_ble_highlight_layer_${1}_text + local text=$2 otext=${!rtext} + [[ $otext && $text == "$otext" ]] && return 0 + ble/util/set "$rtext" "$text" + + local ret + local dict=_ble_highlight_layer_${1}_dict + sel=() gflags=() + + # Retrieve regular expressions + local keys type + ble/util/restore-vars "_ble_highlight_layer_${1}_" keys type + ((${#keys[@]})) || return 0 + + local gpat + ble/highlight/layer:{pattern}/pattern:"$type"/create-gpat + local g0= + if ((${#keys[@]}==1)); then + ble/gdict#get "$dict" "${keys[0]}" && g0=$ret + fi + + local offset=0 tail=$text new_tail mbeg mend m + while [[ $tail ]] && ble/highlight/layer:{pattern}/pattern:"$type"/match "$tail" "$gpat"; do + ((mbeg+=offset,mend+=offset)) + if ((mbega||sel[i]==a&&i%2==0)) && ((sel[i]+=b-a)) + done + fi + + ble/highlight/layer:{selection}/update "$layer_name" "$text" +} + +function ble/highlight/layer:{pattern}/getg { + ble/highlight/layer:{selection}/getg "$@" +} diff --git a/.local/share/blesh/contrib/layer/sample.RandomColor.bash b/.local/share/blesh/contrib/layer/sample.RandomColor.bash new file mode 100644 index 0000000..b291fae --- /dev/null +++ b/.local/share/blesh/contrib/layer/sample.RandomColor.bash @@ -0,0 +1,35 @@ +# ble/contrib/layer/sample.RandomColor.bash (C) 2015, akinomyoga +# +# This is a sample implementation of a highlighting layer. This defines a +# random-color layer named `RandomColor'. To use the layer, the layer name can +# be inserted in the array `_ble_highlight_layer_list`: +# +# ```bash +# ble-import layer/sample.RandomColor +# ble/array#insert-before _ble_highlight_layer_list syntax RandomColor +# ``` +# +# Note: This code was first introduced in commit ec3f3661b@akinomyoga/ble.sh +# (2015-02-23) but later moved to contrib in refactoring on 2023-09-19. + +_ble_highlight_layer_RandomColor_buff=() + +function ble/highlight/layer:RandomColor/update { + local text=$1 ret i + _ble_highlight_layer_RandomColor_buff=() + for ((i=0;i<${#text};i++)); do + # _ble_highlight_layer_RandomColor_buff[i] に "<表示文字>" を設定する。 + # "<表示文字>" は ${_ble_highlight_layer_plain_buff[i]} でなければならない + # (或いはそれと文字幅が同じ物…ただそれが反映される保証はない)。 + ble/color/gspec2sgr "fg=$((RANDOM%256))" + _ble_highlight_layer_RandomColor_buff[i]=$ret${_ble_highlight_layer_plain_buff[i]} + done + PREV_BUFF=_ble_highlight_layer_RandomColor_buff + ((PREV_UMIN=0,PREV_UMAX=${#text})) +} +function ble/highlight/layer:RandomColor/getg { + # ここでは乱数を返しているが、実際は + # PREV_BUFF=_ble_highlight_layer_RandomColor_buff + # に設定した物に対応する物を指定しないと表示が変になる。 + local ret; ble/color/gspec2g "fg=$((RANDOM%256))"; g=$ret +} diff --git a/.local/share/blesh/contrib/layer/sample.RandomColor2.bash b/.local/share/blesh/contrib/layer/sample.RandomColor2.bash new file mode 100644 index 0000000..b9001e9 --- /dev/null +++ b/.local/share/blesh/contrib/layer/sample.RandomColor2.bash @@ -0,0 +1,34 @@ +# ble/contrib/layer/sample.RandomColor2.bash (C) 2015, akinomyoga +# +# This is a sample implementation of a highlighting layer. This defines a +# random-color layer named `RandomColor2'. To use the layer, the layer name can +# be inserted in the array `_ble_highlight_layer_list`: +# +# ```bash +# ble-import layer/sample.RandomColor2 +# ble/array#insert-before _ble_highlight_layer_list syntax RandomColor2 +# ``` +# +# Note: This code was first introduced in commit ec3f3661b@akinomyoga/ble.sh +# (2015-02-23) but later moved to contrib in refactoring on 2023-09-19. + +_ble_highlight_layer_RandomColor2_buff=() + +function ble/highlight/layer:RandomColor2/update { + local text=$1 ret i x + ble/highlight/layer/update/shift _ble_highlight_layer_RandomColor2_buff + for ((i=DMIN;i=0&&LAYER_UMIN>PREV_UMIN&&(LAYER_UMIN=PREV_UMIN), + PREV_UMAX>=0&&LAYER_UMAX=iN&&(i2=iN-1))) + + # update char buffer + ble/highlight/layer/update/shift _ble_highlight_layer_adapter_buff + local i g gprev=0 ctx=0 ret + ((i1>0)) && { ble/highlight/layer/getg "$((i1-1))"; gprev=$g; } + # ble/edit/info/show text "layer:adapter u = $i1-$i2" + for ((i=i1;i<=i2;i++)); do + local ch + if [[ ${_ble_region_highlight_table[i]} ]]; then + ch=${_ble_highlight_layer_plain_buff[i]} + ((g=_ble_region_highlight_table[i])) + if ((ctx!=0||g!=gprev)); then + ((ctx=0,gprev=g)) + ble/color/g2sgr "$g" + ch=$ret$ch + fi + else + builtin eval "ch=\${$PREV_BUFF[i]}" + if ((ctx!=1)); then + ((ctx=1,gprev=-1)) + ble/highlight/layer/update/getg + ble/color/g2sgr "$g" + ch=$ret$ch + fi + fi + + _ble_highlight_layer_adapter_buff[i]=$ch + done + + PREV_BUFF=_ble_highlight_layer_adapter_buff + if ((LAYER_UMIN_ble_edit_ind)); then + ble/syntax-highlight/append "$_ble_edit_ind $_ble_edit_mark bg=60,fg=white" + elif ((_ble_edit_mark<_ble_edit_ind)); then + ble/syntax-highlight/append "$_ble_edit_mark $_ble_edit_ind bg=60,fg=white" + fi + fi +} + +function ble/syntax-highlight+test { + local text=$1 + local i iN=${#text} w + local mode=cmd + for ((i=0;i/dev/null; then + type=jobs + else + type=error + fi ;; + (*) + type=error ;; + esac +} + +function ble/syntax-highlight+default { + local rex IFS=$_ble_term_IFS + local text=$1 + local i iN=${#text} w + local mode=cmd + for ((i=0;i'\''"\]|\\.)+' && [[ $tail =~ $rex ]]; then + # ■ time'hello' 等の場合に time だけが切り出されてしまう + + local word=${BASH_REMATCH[0]} + builtin eval "local cmd=${word}" + + # この部分の判定で fork を沢山する \if 等に対しては 4fork+2exec になる。 + # ■キャッシュ(accept-line 時に clear)するなどした方が良いかもしれない。 + local type; ble/util/type type "$cmd" + ble/syntax-highlight+default/type "$type" "$cmd" # -> type + if [[ $type = alias && $cmd != "$word" ]]; then + # alias を \ で無効化している場合 + # → unalias して再度 check (2fork) + type=$( + builtin unalias "$cmd" + ble/util/type type "$cmd" + ble/syntax-highlight+default/type "$type" "$cmd" # -> type + ble/util/put "$type") + elif [[ "$type" = keyword && "$cmd" != "$word" ]]; then + # keyword (time do if function else elif fi の類) を \ で無効化している場合 + # →file, function, builtin, jobs のどれかになる。以下 3fork+2exec + ble/util/joblist.check + if [[ ! ${cmd##%*} ]] && jobs "$cmd" &>/dev/null; then + # %() { :; } として 関数を定義できるが jobs の方が優先される。 + # (% という名の関数を呼び出す方法はない?) + # でも % で始まる物が keyword になる事はそもそも無いような。 + type=jobs + elif ble/is-function "$cmd"; then + type=function + elif enable -p | ble/bin/grep -q -F -x "enable $cmd" &>/dev/null; then + type=builtin + elif which "$cmd" &>/dev/null; then + type=file + else + type=error + fi + fi + + case $type in + (file) + ble/syntax-highlight/append "$i $((i+${#word})) fg=green" ;; + (alias) + ble/syntax-highlight/append "$i $((i+${#word})) fg=teal" ;; + (function) + ble/syntax-highlight/append "$i $((i+${#word})) fg=navy" ;; + (builtin) + ble/syntax-highlight/append "$i $((i+${#word})) fg=red" ;; + (builtin_bold) + ble/syntax-highlight/append "$i $((i+${#word})) fg=red,bold" ;; + (keyword) + ble/syntax-highlight/append "$i $((i+${#word})) fg=blue" ;; + (jobs) + ble/syntax-highlight/append "$i $((i+1)) fg=red" ;; + (error|*) + ble/syntax-highlight/append "$i $((i+${#word})) bg=224" ;; + esac + + ((i+=${#BASH_REMATCH})) + if rex='^keyword:([!{]|time|do|if|then|else|while|until)$|^builtin:eval$' && [[ $type:$cmd =~ $rex ]]; then + mode=cmd + else + mode=arg + fi + + continue + fi + elif [[ $mode == arg ]]; then + if rex='^([^"$'"$IFS"'|&;()<>'\''"`\]|\\.)+' && [[ $tail =~ $rex ]]; then + # ■ time'hello' 等の場合に time だけが切り出されてしまう + local arg=${BASH_REMATCH[0]} + + local file=$arg + [[ ( $file == '~' || $file = '~/'* ) && ! ( -e $file || -h $file ) ]] && file=$HOME${file:1} + if [[ -d $file ]]; then + ble/syntax-highlight/append "$i $((i+${#arg})) fg=navy,underline" + elif [[ -h $file ]]; then + ble/syntax-highlight/append "$i $((i+${#arg})) fg=teal,underline" + elif [[ -x $file ]]; then + ble/syntax-highlight/append "$i $((i+${#arg})) fg=green,underline" + elif [[ -f $file ]]; then + ble/syntax-highlight/append "$i $((i+${#arg})) underline" + fi + + ((i+=${#arg})) + continue + fi + fi + + # /^'([^'])*'|^\$'([^\']|\\.)*'|^`([^\`]|\\.)*`|^\\./ + if rex='^'\''([^'\''])*'\''|^\$'\''([^\'\'']|\\.)*'\''|^`([^\`]|\\.)*`|^\\.' && [[ $tail =~ $rex ]]; then + ble/syntax-highlight/append "$i $((i+${#BASH_REMATCH})) fg=green" + ((i+=${#BASH_REMATCH})) + mode=arg_ + continue + elif rex='^['"$IFS"']+' && [[ $tail =~ $rex ]]; then + ((i+=${#BASH_REMATCH})) + local spaces=${BASH_REMATCH[0]} + if [[ $spaces =~ $'\n' ]]; then + mode=cmd + else + [[ $mode = arg_ ]] && mode=arg + fi + continue + elif rex='^;;?|^;;&$|^&&?|^\|\|?' && [[ $tail =~ $rex ]]; then + if [[ $mode = cmd ]]; then + ble/syntax-highlight/append "$i $((i+${#BASH_REMATCH})) bg=224" + fi + ((i+=${#BASH_REMATCH})) + mode=cmd + continue + elif rex='^(&?>>?|<>?|[<>]&)' && [[ $tail =~ $rex ]]; then + ble/syntax-highlight/append "$i $((i+${#BASH_REMATCH})) bold" + ((i+=${#BASH_REMATCH})) + mode=arg + continue + elif rex='^(' && [[ $tail =~ $rex ]]; then + ((i+=${#BASH_REMATCH})) + mode=cmd + continue + fi + # 他 "...", ${}, $... arg と共通 + + ((i++)) + # a[]=... の引数は、${} や "" を考慮に入れるだけでなく [] の数を数える。 + done + + ble/syntax-highlight+region "$@" +} diff --git a/.local/share/blesh/contrib/prompt-defer.bash b/.local/share/blesh/contrib/prompt-defer.bash new file mode 100644 index 0000000..63161bd --- /dev/null +++ b/.local/share/blesh/contrib/prompt-defer.bash @@ -0,0 +1,150 @@ +# blesh/contrib/prompt-defer.bash (C) 2021, akinomyoga + +function ble/contrib/prompt-defer/.worker { + local prefix=$1 + local tmpfile=$_ble_base_run/$$.prompt.defer.$prefix + ble/contrib/prompt-defer:"$prefix"/worker + ble/util/put "$?" >| "$tmpfile" +} + +function ble/contrib/prompt-defer/.finalize { + local prefix=$1 + local tmpfile=$_ble_base_run/$$.prompt.defer.$prefix + ble/util/set "${prefix}_DEFER_bgpid" '' + + local ext + ble/util/readfile ext "$tmpfile" + ble/util/setexit "$ext" + ble/contrib/prompt-defer:"$prefix"/callback + + local ret; ble/util/clock + ble/util/set "${prefix}_DEFER_clock" "$ret" +} + +function ble/contrib/prompt-defer/clear { + local prefix=$1 script=' + [[ $PREFIX_DEFER_bgpid ]] && + builtin kill -9 "$PREFIX_DEFER_bgpid" &>/dev/null + PREFIX_DEFER_index= + PREFIX_DEFER_hash1= + PREFIX_DEFER_hash2= + PREFIX_DEFER_clock= + PREFIX_DEFER_bgpid=' + builtin eval -- "${script//PREFIX/$prefix}" +} + +## @fn ble/contrib/prompt-defer/submit prefix [hash1] [hash2] [opts] +## @param[in] prefix +## 関連変数の接頭辞を指定します。 +## +## @fn ble/comtrib/prompt-defer:$prefix/clear +## これまでに取得した情報を初期化します。後述の hash1 が前回の呼 +## び出しと異なる際に親シェルで呼び出されます。 +## +## @fn ble/comtrib/prompt-defer:$prefix/worker +## バックグラウンドの別プロセスで実行する処理を記述します。bash +## 4.0 以降ではサブシェルで呼び出されます。bash 4.0 未満では非同 +## 期に処理できない為、親シェルで実行されます。 +## +## @fn ble/comtrib/prompt-defer:$prefix/callback +## バックグラウンドの処理が完了した時に親シェルで呼び出される関 +## 数です。$? に worker の終了ステータスが設定された状態で呼び出 +## されます。 +## +## @var[internal] ${prefix}_DEFER_index +## @var[internal] ${prefix}_DEFER_hash1 +## @var[internal] ${prefix}_DEFER_hash2 +## @var[internal] ${prefix}_DEFER_clock +## @var[internal] ${prefix}_DEFER_bgpid +## 内部で使用する変数です。 +## +## @param[in] hash1 +## この値が前回の呼び出しと異なる時に強制的に情報の更新を行います。 +## +## @param[in] hash2 +## この値が前回の呼び出しと異なりかつ前回の呼び出しから十分時間が +## 経っている時に情報の更新を行います。 +## +## @param[in,opt] opts +## コロン区切りのオプションです。 +## +## cooling=NUM +## ミリ秒(整数)で情報のタイムアウトを指定します。プロンプト番号 +## または hash2 が前回と異なりかつ此処で指定した時間経過している +## 場合に再度情報更新を行います。 +## +## cooling-lines=NUM +## プロンプト更新回数を指定します。プロンプト番号が此処で指定し +## た回数以上変化している場合に再度情報更新を行います。 +## +## expires[=NUM] +## ミリ秒(整数)で情報のタイムアウトを指定します。プロンプト更新 +## の際に指定した時間経過している場合、強制的に情報更新を行いま +## す。既定値は 60000 (1分) です。 +## +## sync=NUM +## ミリ秒(整数)で同期的な情報取得のタイムアウトを指定します。 +## +function ble/contrib/prompt-defer/submit { + local prefix=$1 opts=$4 + local tmpfile=$_ble_base_run/$$.prompt.defer.$prefix + local rbgpid=${prefix}_DEFER_bgpid + + local opt_cooling=1000 opt_expires=none opt_nprompt=10 opt_sync=5 ret + ble/opts#extract-last-optarg "$opts" cooling && opt_cooling=$ret + ble/opts#extract-last-optarg "$opts" cooling-lines && opt_nprompt=$ret + ble/opts#extract-last-optarg "$opts" expires 60000 && opt_expires=$ret + ble/opts#extract-last-optarg "$opts" sync 60000 && opt_sync=$ret + + local oindex=${prefix}_DEFER_index; oindex=${!oindex-} + local ohash1=${prefix}_DEFER_hash1; ohash1=${!ohash1-} + local ohash2=${prefix}_DEFER_hash2; ohash2=${!ohash2-} + local oclock=${prefix}_DEFER_clock; oclock=${!oclock-} + + local nindex=$_ble_prompt_version + local nhash1=${2-done} # 強制 update を誘起する hashref + local nhash2=${3-done} # + + local update= + if [[ $nhash1 != "$ohash1" ]]; then + update=1 + ble/contrib/prompt-defer:"$prefix"/clear + elif [[ ! ${!rbgpid} ]]; then + if [[ $nindex:$nhash2 != "$oindex:$ohash2" ]]; then + if ((nindex<=oindex-opt_nprompt||oindex+opt_nprompt<=nindex)) || { local ret; ble/util/clock; ((ret>=oclock+opt_cooling)); }; then + update=1 + fi + elif [[ $opt_expires && $opt_expires != none ]]; then + if local ret; ble/util/clock; ((ret>=oclock+opt_expires)); then + update=1 + fi + fi + fi + + if [[ $update ]]; then + ble/util/set "${prefix}_DEFER_index" "$nindex" + ble/util/set "${prefix}_DEFER_hash1" "$nhash1" + ble/util/set "${prefix}_DEFER_hash2" "$nhash2" + + if ble/is-function ble/util/idle.push; then + if [[ ${!rbgpid} ]]; then + builtin kill -9 "${!rbgpid}" &>/dev/null + ble/util/idle.cancel "ble/contrib/prompt-defer/.finalize $prefix" + ble/util/set "$rbgpid" '' + fi + + >| "$tmpfile" + ble/util/set "$rbgpid" "$(ble/util/nohup 'ble/contrib/prompt-defer/.worker $prefix' print-bgpid)" + ((opt_sync>0)) && ble/util/msleep "$opt_sync" + if [[ -s $tmpfile ]]; then + ble/contrib/prompt-defer/.finalize "$prefix" + else + ble/util/idle.push -F "$tmpfile" "ble/contrib/prompt-defer/.finalize $prefix" + fi + + else + ble/contrib/prompt-defer:"$prefix"/worker + ble/contrib/prompt-defer:"$prefix"/callback + fi + fi +} diff --git a/.local/share/blesh/contrib/prompt-elapsed.bash b/.local/share/blesh/contrib/prompt-elapsed.bash new file mode 100644 index 0000000..38bcf26 --- /dev/null +++ b/.local/share/blesh/contrib/prompt-elapsed.bash @@ -0,0 +1,91 @@ +# blesh/contrib/prompt-elapsed.bash (C) 2022, Koichi Murase + +function ble/contrib/prompt-elapsed/output-sec.ps { + local sec=$1 min + ((min=sec/60,sec%=60)) + if ((min<100)); then + ble/prompt/print "${min}m${sec}s" + return 0 + fi + + local hour; ((hour=min/60,min%=60)) + if ((hour<100)); then + ble/prompt/print "${hour}h${min}m${sec}s" + return 0 + fi + + local day; ((day=hour/24,hour%=24)) + if ((day<365)); then + ble/prompt/print "${day}d${hour}h${min}m" + return 0 + fi + + local year; ((year=day/365,day%=365)) + ble/prompt/print "${year}y${day}d${hour}h" + return 0 +} + +function ble/contrib/prompt-elapsed/output-time-format.ps { + local msec=$1 + local d=${#msec} + if ((d<=3)); then + ble/prompt/print "${msec}msec" + return 0 + elif ((d<=5)); then + ble/prompt/print "${msec::d-3}.${msec:d-36-d}sec" + return 0 + fi + + local sec=$((msec/1000)) min + ((msec%=1000,min=sec/60,sec%=60)) + msec=000${msec}; msec=${msec:${#msec}-3} + if ((min<100)); then + ble/prompt/print "${min}m${sec}.${msec}s" + return 0 + fi + + ble/contrib/prompt-elapsed/output-sec.ps "$((min*60+sec))" +} + +function ble/prompt/backslash:contrib/elapsed { + [[ $_ble_exec_time_ata ]] || return 1 + + local ata=$_ble_exec_time_ata + local d=${#ata} + if ((d<=3)); then + ble/prompt/print "${ata}usec" + return 0 + elif ((d<=6)); then + if ((d<=5)); then + ble/prompt/print "${ata::d-3}.${ata:d-3:6-d}msec" + else + ble/prompt/print "${ata::3}msec" + fi + return 0 + elif ((d<=8)); then + ble/prompt/print "${ata::d-6}.${ata:d-6:3}sec" + return 0 + fi + + ble/contrib/prompt-elapsed/output-sec.ps "$((ata/1000000))" +} + +function ble/prompt/backslash:contrib/elapsed-real { + [[ $_ble_exec_time_ata ]] || return 1 + ble/contrib/prompt-elapsed/output-time-format.ps "$_ble_exec_time_tot" +} +function ble/prompt/backslash:contrib/elapsed-user { + [[ $_ble_exec_time_ata ]] || return 1 + ble/contrib/prompt-elapsed/output-time-format.ps "$_ble_exec_time_usr" +} +function ble/prompt/backslash:contrib/elapsed-sys { + [[ $_ble_exec_time_ata ]] || return 1 + ble/contrib/prompt-elapsed/output-time-format.ps "$_ble_exec_time_sys" +} +function ble/prompt/backslash:contrib/elapsed-cpu { + ((_ble_exec_time_tot)) || return 1 + + local pk=$(((_ble_exec_time_usr+_ble_exec_time_sys)*1000/_ble_exec_time_tot)) + ble/prompt/print "$((pk/10)).$((pk%10))%" + return 0 +} diff --git a/.local/share/blesh/contrib/prompt-git.bash b/.local/share/blesh/contrib/prompt-git.bash new file mode 100644 index 0000000..16a06a4 --- /dev/null +++ b/.local/share/blesh/contrib/prompt-git.bash @@ -0,0 +1,348 @@ +# blesh/contrib/prompt-git.bash (C) 2020-2021, akinomyoga + +# bleopt prompt_rps1='\q{contrib/git-info}' +# bleopt prompt_rps1='\q{contrib/git-name}' +# bleopt prompt_rps1='\q{contrib/git-hash}' +# bleopt prompt_rps1='\q{contrib/git-branch}' +# bleopt prompt_rps1='\q{contrib/git-path}' + +ble-import contrib/prompt-defer + +#------------------------------------------------------------------------------ + +_ble_contrib_prompt_git_data=() +_ble_contrib_prompt_git_base= +_ble_contrib_prompt_git_base_dir= +_ble_contrib_prompt_git_vars=(git_base git_base_dir hash branch) + +## @fn ble/contrib/prompt-git/.check-gitdir path +## @var[out] git_base git_base_dir +function ble/contrib/prompt-git/.check-gitdir { + local path=$1 + [[ -f $path/.git/HEAD ]] || return 1 + ble/prompt/unit/assign _ble_contrib_prompt_git_base "$path" + ble/prompt/unit/assign _ble_contrib_prompt_git_base_dir "$path/.git" + return 0 +} +## @fn ble/contrib/prompt-git/.check-submodule path +## @var[out] git_base git_base_dir +function ble/contrib/prompt-git/.check-submodule { + local path=$1 content + [[ -f $path/.git ]] || return 1 + ble/util/mapfile content < "$path/.git" + [[ $content == 'gitdir:'* ]] || return 1 + local git_base=$path + local git_base_dir=${content#'gitdir:'} + git_base_dir=${git_base_dir#' '} + [[ $git_base_dir == /* ]] || + git_base_dir=$path/$git_base_dir + [[ -f $git_base_dir/HEAD ]] + ble/prompt/unit/assign _ble_contrib_prompt_git_base "$git_base" + ble/prompt/unit/assign _ble_contrib_prompt_git_base_dir "$git_base_dir" + return 0 +} +function ble/prompt/unit:_ble_contrib_prompt_git/update { + ble/prompt/unit/add-hash '$PWD' + + ble/bin#has git || return 1 + # [[ $(git rev-parse --is-inside-work-tree 2> /dev/null) ]] + local path=$PWD found= + while + if ble/contrib/prompt-git/.check-gitdir "$path"; then + [[ $prompt_unit_changed ]] + return "$?" + elif ble/contrib/prompt-git/.check-submodule "$path"; then + [[ $prompt_unit_changed ]] + return "$?" + fi + [[ $path == */* ]] + do path=${path%/*}; done + + ble/prompt/unit/assign _ble_contrib_prompt_git_base '' + [[ $prompt_unit_changed ]] +} + +## @fn ble/contrib/prompt-git/initialize +## @var[out] git_base git_base_dir +function ble/contrib/prompt-git/initialize { + ble/prompt/unit#update _ble_contrib_prompt_git + ble/util/restore-vars _ble_contrib_prompt_ git_base git_base_dir + [[ $git_base ]] +} + +## @fn ble/contrib/prompt-git/check-dirty +## 現在の working tree に編輯があるかどうかを非同期で取得します。 +## @var[in] git_base +_ble_contrib_prompt_git_dirty=0 +ble/contrib/prompt-defer/clear _ble_contrib_prompt_git_dirty +function ble/contrib/prompt-defer:_ble_contrib_prompt_git_dirty/clear { _ble_contrib_prompt_git_dirty=0; } +function ble/contrib/prompt-defer:_ble_contrib_prompt_git_dirty/worker { + # git 1.7.2 (2010-09) supports --ignore-submodules=untracked + git status --porcelain --ignore-submodules=untracked | ble/bin/awk ' + /^[^ ?]./ { staged = 1;} + /^.[^ ?]/ { unstaged = 1;} + /^\?\?/ { untracked = 1; } + END { + if (unstaged) exit 1; + if (staged) exit 2; + if (untracked) exit 3; + exit 0 + } + ' +} +function ble/contrib/prompt-defer:_ble_contrib_prompt_git_dirty/callback { _ble_contrib_prompt_git_dirty=$?; } +function ble/contrib/prompt-git/check-dirty { + [[ $_ble_contrib_prompt_git_base ]] || return 0 + ble/contrib/prompt-defer/submit _ble_contrib_prompt_git_dirty "$_ble_contrib_prompt_git_base" '' + ble/prompt/unit/add-hash '$_ble_contrib_prompt_git_dirty' + return "$_ble_contrib_prompt_git_dirty" +} +function ble/contrib/prompt-git/is-dirty { ble/contrib/prompt-git/check-dirty; (($?!=0&&$?!=3)); } +function ble/contrib/prompt-git/get-dirty-mark { + dirty_mark= + ble/contrib/prompt-git/check-dirty; local ext=$? + if [[ :$1: == *:colored:* ]]; then + case $ext in + (1) dirty_mark=$'\e[1;38:5:202m*\e[m' ;; + (2) dirty_mark=$'\e[1;32m*\e[m' ;; + (3) dirty_mark=$'\e[1;94m+\e[m' ;; + esac + else + case $ext in + (1) dirty_mark='*' ;; + (2) dirty_mark='^' ;; + (3) dirty_mark='+' ;; + esac + fi +} + +## @fn ble/contrib/prompt-git/update-head-information +## @var[out] hash branch +function ble/contrib/prompt-git/update-head-information { + [[ $hash || $branch ]] && return 0 + + local head_file=$git_base_dir/HEAD + [[ -s $head_file ]] || return 0 + local content; ble/util/mapfile content < "$head_file" + + if [[ $content == *'ref: refs/heads/'* ]]; then + branch=${content#*refs/heads/} + content= + + local branch_file=$git_base_dir/refs/heads/$branch + if [[ -s $branch_file ]]; then + ble/util/mapfile content < "$branch_file" + elif local refs_file=$git_base_dir/info/refs; [[ -s $refs_file ]]; then + local lines line + ble/util/mapfile lines < "$refs_file" + for line in "${lines[@]}"; do + if [[ $line == *["$_ble_term_IFS"]refs/heads/"$branch" ]]; then + content=${line%%[$_ble_term_IFS]*} + break + fi + done + fi + fi + + [[ $content && ! ${content//[0-9a-fA-F]} ]] && hash=$content + return 0 +} +## @fn ble/contrib/prompt-git/get-tag-name +## @var[out] tag +function ble/contrib/prompt-git/get-tag-name { + # ble/util/assign-array tag 'git describe --tags --exact-match 2>/dev/null' + tag= + ble/contrib/prompt-git/update-head-information # -> hash, branch + [[ $hash ]] || return 1 + + local file tagsdir=$git_base_dir/refs/tags hash1 + local files ret; ble/util/eval-pathname-expansion '"$tagsdir"/*'; files=("${ret[@]}") + for file in "${files[@]}"; do + local tag1=${file#$tagsdir/} + [[ -s $file ]] || continue + ble/util/mapfile hash1 < "$file" + if [[ $hash1 == "$hash" ]]; then + tag=$tag1 + return 0 + fi + done + + if local refs_file=$git_base_dir/info/refs; [[ -s $refs_file ]]; then + local lines line + ble/util/mapfile lines < "$refs_file" + for line in "${lines[@]}"; do + if [[ $line == "$hash"["$_ble_term_IFS"]refs/tags/* ]]; then + tag=${line##refs/tags/*} + return 0 + fi + done + fi +} + +## @fn ble/contrib/prompt-git/get-state opts +## @var[out] ret +function ble/contrib/prompt-git/get-state { + local opts=$1 + # https://github.com/git/git/blob/4fd6c5e44459e6444c2cd93383660134c95aabd1/contrib/completion/git-prompt.sh#L452-L475 + # https://github.com/git/git/blob/4fd6c5e44459e6444c2cd93383660134c95aabd1/contrib/completion/git-prompt.sh#L312-L333 + if [[ -d $git_base_dir/rebase-merge ]]; then + ret=REBASE + elif [[ -d $git_base_dir/rebase-apply ]]; then + if [[ -f $git_base_dir/rebase-apply/rebasing ]]; then + ret=REBASE + elif [[ -f $git_base_dir/rebase-apply/applying ]]; then + ret=AM + else + ret=AM/REBASE + fi + elif [[ -f $git_base_dir/MERGE_HEAD ]]; then + ret=MERGING + elif [[ -f $git_base_dir/CHERRY_PICK_HEAD ]]; then + ret=CHERRY-PICKING + elif [[ -f $git_base_dir/REVERT_HEAD ]]; then + ret=REVERTING + elif + local todo= rest IFS=$_ble_term_IFS + [[ -f $git_base_dir/sequencer/todo ]] && + ble/bash/read todo rest < "$git_base_dir/sequencer/todo" + [[ $todo == p || $todo == pick ]]; then + ret=CHERRY-PICKING + elif [[ $todo == revert ]]; then + ret=REVERTING + elif [[ -f $git_base_dir/BISECT_LOG ]]; then + ret=BISECTING + elif ble/contrib/prompt-git/update-head-information; [[ ! $branch ]]; then + ret=DETACHED + elif [[ $branch && ! $hash ]]; then + ret=ORPHAN + else + ret= + fi + + if [[ :$opts: == *:colored:* ]]; then + case $ret in + (REBASE) ret=$'\e[1;48;5;27;38;5;231m '$ret$' \e[m' ;; + (AM | AM/REBASE) ret=$'\e[1;48;5;34;38;5;231m '$ret$' \e[m' ;; + (MERGING) ret=$'\e[1;48;5;172;38;5;231m '$ret$' \e[m' ;; + (CHERRY-PICKING) ret=$'\e[1;48;5;200;38;5;231m '$ret$' \e[m' ;; + (REVERTING) ret=$'\e[1;48;5;124;38;5;231m '$ret$' \e[m' ;; + (BISECTING) ret=$'\e[1;48;5;93;38;5;231m '$ret$' \e[m' ;; + (DETACHED) ret=$'\e[91m'$ret$'\e[m' ;; + (ORPHAN) ret=$'\e[38;5;70m'$ret$'\e[m' ;; + (?*) ret=$'\e[1;48;5;242;38;5;231m '$ret$' \e[m' ;; + esac + fi + + [[ $ret ]] +} + +function ble/contrib/prompt-git/describe-head { + local opts=:$1: + ret= + + local dirty_mark= + [[ $opts == *:check-dirty:* ]] && + ble/contrib/prompt-git/get-dirty-mark colored + + ble/contrib/prompt-git/update-head-information # -> hash, branch + if [[ $branch ]]; then + local sgr=$'\e[1;34m' sgr0=$'\e[m' + local out=$sgr$branch$sgr0 + if [[ $opts == *:add-hash:* && $hash ]]; then + out="$out (${hash::7}$dirty_mark)" + else + out=$out$dirty_mark + fi + + [[ $opts == *:check-state:* ]] && + ble/contrib/prompt-git/get-state colored && + out="$ret $out" + ret=$out + return 0 + fi + + local tag + ble/contrib/prompt-git/get-tag-name + if [[ $tag ]]; then + local sgr=$'\e[1;32m' sgr0=$'\e[m' + local out=$sgr$tag$sgr0 + [[ $opts == *:add-hash:* && $hash ]] && + out="$out ${hash::7}" + out=$out$dirty_mark + [[ $opts == *:check-state:* ]] && + ble/contrib/prompt-git/get-state colored && + out="$ret ($out)" + ret=$out + return 0 + fi + + # "master~23" 等の分かりにくい説明なのでこれは使わない + # ble/util/assign-array ret 'git describe --contains --all 2>/dev/null' + # if [[ $ret ]]; then + # local label_detached=$'\e[91mDETACHED\e[m' + # local sgr=$'\e[32m' sgr0=$'\e[m' + # ret="($label_detached at $sgr$ret$sgr0)" + # return 0 + # fi + + if [[ $hash ]]; then + local out=${hash::7}$dirty_mark + [[ $opts == *:check-state:* ]] && + ble/contrib/prompt-git/get-state colored && + out="$ret ($out)" + ret=$out + return 0 + fi + + ret=$'\e[91mUNKNOWN\e[m' +} + +#------------------------------------------------------------------------------ + +function ble/prompt/backslash:contrib/git-info { + local "${_ble_contrib_prompt_git_vars[@]/%/=}" # WA #D1570 checked + if ble/contrib/prompt-git/initialize; then + local sgr=$'\e[1m' sgr0=$'\e[m' + local name=$sgr${git_base##*?/}$sgr0 + local ret; ble/contrib/prompt-git/describe-head add-hash:check-dirty:check-state; local branch=$ret + ble/prompt/print "$name $branch" + [[ $PWD == "$git_base"/?* ]] && + ble/prompt/print " /${PWD#$git_base/}" + return 0 + else + return 1 + fi +} +function ble/prompt/backslash:contrib/git-name { + local "${_ble_contrib_prompt_git_vars[@]/%/=}" # WA #D1570 checked + if ble/contrib/prompt-git/initialize; then + local name=${git_base%.git} + name=${name%/} + name=${name##*?/} + ble/prompt/print "${git_base##*?/}" + fi +} +function ble/prompt/backslash:contrib/git-hash { + local "${_ble_contrib_prompt_git_vars[@]/%/=}" # WA #D1570 checked + if ble/contrib/prompt-git/initialize; then + ble/contrib/prompt-git/update-head-information + ble/prompt/print "${hash::${1:-7}}" + fi +} +function ble/prompt/backslash:contrib/git-branch { + local "${_ble_contrib_prompt_git_vars[@]/%/=}" # WA #D1570 checked + if ble/contrib/prompt-git/initialize; then + local ret; ble/contrib/prompt-git/describe-head check-dirty + ble/prompt/print "$ret" + fi +} +function ble/prompt/backslash:contrib/git-path { + local "${_ble_contrib_prompt_git_vars[@]/%/=}" # WA #D1570 checked + if ble/contrib/prompt-git/initialize; then + if [[ $PWD == "$git_base"/?* ]]; then + ble/prompt/print "/${PWD#$git_base/}" + elif [[ $PWD == "$git_base" ]]; then + ble/prompt/print / + fi + fi +} diff --git a/.local/share/blesh/contrib/prompt-vim-mode.bash b/.local/share/blesh/contrib/prompt-vim-mode.bash new file mode 100644 index 0000000..f1574f3 --- /dev/null +++ b/.local/share/blesh/contrib/prompt-vim-mode.bash @@ -0,0 +1,20 @@ +# ble/contrib/prompt-vim-mode.bash (C) 2020-2021, akinomyoga + +# \q{contrib/vim-mode} (Prompt escape sequence) +# +# Example: +# +# ble-import contrib/prompt-vim-mode +# PS1='[\u@\h \W]\q{contrib/vim-mode}\$ ' +# bleopt keymap_vi_mode_show:= +# + +function ble/prompt/backslash:contrib/vim-mode { + local mode; ble/keymap:vi/script/get-mode + case $mode in + ([iR]*) ble/prompt/print '(ins)' ;; + (*n) ble/prompt/print '(cmd)' ;; + (*x) ble/prompt/print '(vis)' ;; + (*s) ble/prompt/print '(sel)' ;; + esac +} diff --git a/.local/share/blesh/doc/CONTRIBUTING.md b/.local/share/blesh/doc/CONTRIBUTING.md new file mode 100644 index 0000000..dd7817b --- /dev/null +++ b/.local/share/blesh/doc/CONTRIBUTING.md @@ -0,0 +1,348 @@ +# Contribution Guide + +## How to contribute + +### Issues + +You can freely create an issue using the following links: + +- Report and fixes for bugs and performance issues [[Here]](https://github.com/akinomyoga/ble.sh/issues/new?template=bug_report.md) +- Questions on usage [[Here]](https://github.com/akinomyoga/ble.sh/issues/new?template=feature_request.md) +- Feature request [[Here]](https://github.com/akinomyoga/ble.sh/issues/new?template=help.md) +- Others (suggestions, projects, discussion, complaints, news, information or anything) [[Here]](https://github.com/akinomyoga/ble.sh/issues/new?template=free_style.md) + +### Pull requests + +We always welcome the following types of pull requests. Any changes will be considered to be provided under the BSD 3-Clause License. +If you do not know whether your changes would be appropriate for merge, please feel free to create a pull request and let us talk with each other! + +- Better translation to English, typo fixes +- Fixes, optimization, test cases +- New features +- New color themes ... We accept new themes in [`contrib`](https://github.com/akinomyoga/blesh-contrib/pulls) repository. +- Others + +### Wiki + +You can freely edit [wiki pages](https://github.com/akinomyoga/ble.sh/wiki). + +- Translations +- Typo fixes +- Create new pages + +## For package maintainers + +If you are a package maintainer for a repository of Linux distribution, etc. +you may provide a package-specific setting by preparing +a file `/path/to/blesh/lib/_package.sh` (e.g. `/usr/share/blesh/lib/_package.sh`) +which will be sourced after the load of `ble.sh` just before sourcing user's configuration (`~/.blerc`). + +- In the file, the shell variable `_ble_base_package_type=TYPE` should be + set up to have a repository-specific name (such as `AUR`). + +- The function named `ble/base/package:TYPE/update` (where `TYPE` + matches with a value assigned to `_ble_base_package_type`) may be + provided to define a custom updating procedure. The exit status of the function can be + - `0` ... when the update succeeded + - `6` ... when the update was skipped because the package was up to date. + - `125` ... when it wants to fall back to the built-in updating procedure of `ble.sh`. + - Other ... when the update failed + +An example `lib/_package.sh` might be + +```bash +_ble_base_package_type=apt + +function ble/base/package:apt/update { + sudo apt upgrade blesh +} +``` + +You can also find a real example for AUR (Arch User Repository) [here](https://aur.archlinux.org/cgit/aur.git/tree/blesh-update.sh?h=blesh-git). + +## Summary of codebase + +The core script file `ble.sh` is generated by combining the following files: + +- `ble.pp` ... Basic initialiation +- `src/def.sh` ... Prototype definitions +- `src/util.sh` ... Basic utility functions +- `src/decode.sh` ... User-input decoder and keybindings +- `src/color.sh` ... Terminal graphic attributes +- `src/canvas.sh` ... Terminal layout engine + - `src/canvas.emoji.sh` ... Emoji database +- `src/history.sh` ... Command history management +- `src/edit.sh` ... Line editor +- `src/benchmark.sh` ... Measure processing time +- `lib/core-completion.sh` ... Prototype definition for completions +- `lib/core-syntax.sh` ... Prototype definitions for syntax analyzer + +Useful features are implemented in separate modules: + +- `lib/keymap.vi.sh` ... Vim mode + - `lib/vim-arpeggio.sh` ... `vim-arpeggio`-like plugin + - `lib/vim-surround.sh` ... `vim-surround`-like plugin +- `lib/keymap.emacs.sh` ... Emacs mode +- `lib/core-syntax.sh` ... Shell parser and syntax highlighting + - `lib/core-syntax-ctx.def` ... Definition of parser states +- `lib/core-complete.sh` ... Completions including `menu-complete`, `auto-complete`, `menu-filter`, `dabbrev`, `sabbrev`, etc. + +The following files are initialization scripts: + +- `lib/init-term.sh` ... Initialize terminal escape sequences (host-to-terminal, i.e. control sequences) +- `lib/init-cmap.sh` ... Initialize terminal escape sequences (terminal-to-host, i.e. key sequences) +- `lib/init-bind.sh` ... Initialize readline attacher +- `lib/init-msys1.sh` ... Workaround for MSYS1 with broken pipes + - `lib/init-msys1-helper.c` ... Helper C program for the workaround of broken pipes + +The contrib repository contains configurations built on top of the `ble.sh` framework + +- `contrib/config/*.bash` are specific configurations whose details may depend on the user's preferences. These are expected to work just by `ble-import` but at the same time serve as examples for the user's personal versions. +- `contrib/sample/*.bash` are examples to explain interfaces for configurations. These are just explanation of the interface so would not actually function. +- `contrib/airline/*.bash` are the themes for `vim-airline`. +- `contrib/integration/*.bash` are codes needed for the adjustments with other framework. +- `contrib/*.bash` are other miscellaneous configurations. Usually one needs additional configuration after `ble-import`. These files may be moved to another directory in the future. + +## Tests + +Tests can be run by one of the following commands: + +```bash +$ make check +$ make check-all +$ bash out/ble.sh --test + +``` + +Currently, test coverage is very small +partly because the testing for interactive behavior and terminal rendering results is hard. +Nevertheless, the tests are defined in the following files: + +- `lib/core-test.sh` ... Library for tests +- `lib/test-bash.sh` +- `lib/test-main.sh` +- `lib/test-util.sh` +- `lib/test-canvas.sh` +- `lib/test-edit.sh` +- `lib/test-complete.sh` +- `lib/test-syntax.sh` + +## Coding styles + +These styles are not required for the initial PR as these are too complicated. +The maintainer(s) will apply the styles before merging. +Nevertheless, it would be useful to follow the styles when you are going to submit PRs many times. + +### Naming convention for functions + +The function names roughly have the following structure, but the rule is ambiguous to some extent, and there are also many exceptions in the codebase. + +```ebnf +function_name = (namespace '/')* function_basename ; + +namespace = function_basename ; + +function_basename = name ext? (* namespace function *) + | class '.' name ext? (* class method *) + | class '#' name ext? (* instance method *) + | class '#' class '::' name ext? (* instance method (override) *) + | type ':' name ext? ; (* customization point *) + +name = hyphenated_name (* public *) + | '.' hyphenated_name ; (* private *) + +ext = '.hook' (* hook functions for blehook *) + | '.draw' (* function operating on DRAW_BUFF *) + | '.fib' (* worker for ble/util/fiberchain *) + | '.proc' (* callback functions *) + | '.impl' ; (* internal implementation *) + (* ... (and more extensions) *) + +class = name ; + +type = hyphenated_name ; + +hyphenated_name = (word '-')* word ; + +word = /[_a-zA-Z0-9]+/ ; +``` + +The function names are basically hyphenated words (such as `foo-bar-baz` instead of `foo_bar_baz`, `fooBarBaz`, or `FooBarBaz`). + +**Namespace**--The function names can be prefixed by namespaces of the form `/`. +Except for the functions intended to be called from the command line or the user configuration, all the functions should be defined in a namespace. +The interface of the functions defined in a namespace is subject to change in the future. +A function name can also be used as the namespace name for the helper functions to implement the function. +For the functions defined in external modules, the following namespace should be used to avoid conflicts: + +| Types | Namespace | +|:----------------------------------------------------|----------------------------------------| +| `contrib/*.bash` | `ble/contrib/` | +| `contrib/config/*.bash` | `ble/contrib/config:` | +| `contrib/integration/*.bash` | `ble/contrib/integration:` | +| User's public config | e.g. `` | +| User's private config | e.g. `` or `my` | +| User's private config in Bash initialization file | e.g. ``, `my` or `bashrc` | +| User's private config in ble.sh initialization file | e.g. ``, `my` or `blerc` | + +**Private**--The function basename started with `.` is considered private within the namespace. All the other functions are public. + +**Method**--The function basename of the form `#` is considered an instance method. +The function basename of the form `.` is considered a class method. +The difference between the two is the latter assumes a single global state while the former assumes that an instance is specified by the first argument or by other means. +The way to specify the instance depends on the class. +For example, `ble/array#*` receives the variable name as the first argument while `ble/string#*` directly receives the string value as the first argument. +For `ble/textarea#*`, the target instance is selected by the shell variable `_ble_textarea_panel`. +The function basename of the form `#::` is used to define a virtual function called by the base class `` at the side of the derived class ``. + +**Customization point**--The function basename of the form `:` is used to provide the customization point for dynamic values. +This function is typically called as `:"$var"` with `var` contains a value that depends on the context including the currently selected class, user configuration, etc. + +**Extension**--The extension `` can be used to mark the specific types of functions. + +### Naming convention for variables + +The variable names roughly have the following structure. + +```ebnf +local_variable_name = varname + | '__ble_' varname + | '_ble_local_' varname ; + +global_variable_name = ('_' namespace)* '_' varname ; + +namespace = word ; +varname = (word '_')* word ; +word = /[a-zA-Z0-9]+/ ; +``` + +The variable names are basically lowercase underscored words such as `foo_bar_baz` (instead of `fooBarBaz` or `FooBarBaz`). +Some global constants and the exported variables have all-uppercase names, but the lowercase should be basically used. + +**Local variables**--The local variables that are only used in the declared function should be basically unprefixed by an underscore. +When the function reads/returns a value through an arbitrary name of in/out variables, +the local variable declared within the function should be prefixed by `__ble_` or `_ble_local_` to avoid the name conflicts between the local and in/out variables. + +**Global variables**--All the global variables, except for the variables that are intended to be directly modified from the command line, should be prefixed by `_`. +Currently, there are no variables intended to be directly modified from the command line[Note 1]. +The variables defined in external modules should be namespaced by the module name. +The variables in modules in the `contrib` repository should have the prefix `_ble_contrib__` + +- [Note 1] In the initial implementation of ble.sh, the ble.sh options are provided as shell variables `bleopt_*`. +As remnant or for backward compatibility, the values of ble.sh options are still stored in the variables of the name `bleopt_*`, +but these variables for the ble.sh options will be renamed in the future. + +### Function interface + +The success/failure states should be returned by the exit status. + +**`ret`**--All the other values should be basically returned through shell variables. +This is because, if a function returned its result through the standard output, +the caller would need to capture the results by a command substitution which involves a fork of a subshell and thus is slow. +Here, efficiency is the primary interest, so there are exceptions where the standard output can be more efficient: +For example, when the output needs to be saved to a file for later use or to be passed to a different process, +or when the output needs to be processed by the external commands that read the standard input. +The variable name to return a value should be basically `ret` unless the purpose of the function is to store values. +When the function basename has the form `get-`, one should consider returning the result through the shell variable named ``. +When a function returning multiple values is called from many places, the function may receive an array name as the first argument and store the result in the specified array. +When the out variable names are specified in the arguments, they should come first in the list of the arguments. + +**`opts`**--The argument position should be basically fixed (e.g., never shifted by optional arguments like `-f` or `-o name`). +The optional arguments can be specified by colon-separated fields (like `SHELLOPTS` or `BASHOPTS`) +instead of the Unix-style flags and options like `-f` and `-o optarg`. +This is because the parsing of the Unix-style arguments (with or without `getopts`) is usually slow. +The local variable that receives the colon-separated option typically has the name `opts` or `*opts` (e.g. `local opts=$2`). +A single option has the form `name` or `name=value`, +where `name` should be hyphenated words like `foo-bar-baz`. +The former form without the value is called a flag option. +One can test a flag option by `[[ :$opts: == *:flag-name:* ]]`. +An option of the form `name=value` can be matched by `ble/opts#extract-first-optarg`, `ble/opts#extract-last-optarg`, or `ble/opts#extract-all-optargs`. +The function `ble/opts#has` can be used to test if either `name` or `name=value` is contained + +**`$*`**--The functions that receive a string should not allow a variable number of arguments that are joined inside the function. +A variable number of arguments should be used only when each argument is really processed separately. +If necessary, the joining should be performed at the caller side. +This is because `IFS` in the caller context affects the joining `$*`, so the handling of `IFS` should be properly done at the caller side. +Another reason is for the future extension, e.g., to add another optional argument. + +### Variable declarations + +Local variables should be declared by `local` (instead of `declare` or `typeset`). +Variables should be always initialized before referencing their values. This is because uninitialized variables can have random values when `shopt -s localvar_inherit` is turned on. + +The declaration and the initialization of an array variable should be separated as far as the initializer values contain any expansions or spaces. +There is a bug in Bash 3.0 that the values are separated by whitespaces even when the values are quoted. +When the declaration and the initialization of an array variable are made in a single command, the option `-a` needs to be specified. +Without `-a`, the entire list `(...)` including the surrounding parens will be treated as a scalar string in Bash 3.0. + +```bash +local v; v=("$var") +local -a v=() + +# The following may not work as expected +# local v=() # Bash 3.0 will initialize a scalar with the value v='()' #D0184 +# local -a v=("a b") # Bash 3.0 will split it into the two elements "a" and "b" #D0525 +``` + +Defining local readonly variables should be avoided +because they will hide global variables from the utilities `ble/variable#is-global`, `ble/util/print-global-definitions`, etc. +Global readonly variables should never be defined. +The background is described in the Limitation section of README. + +### Conditional commands `[[ ... ]]` + +Do not use `[ ... ]` or `test` unless it is intended to be a POSIX script. Always use `[[ ... ]]`. + +Use `[[ word ]]` and `[[ ! word ]]` instead of `[[ -n word ]]` and `[[ -z word ]]`. + +Use `==` instead of the operator `=` inside conditional commands. + +**Quoting**--The right-hand sides of `==` and `!=` inside conditional commands `[[ ... ]]` should be properly quoted. +The right-hand sides of `=~` inside the conditional commands `[[ ... ]]` should be specified by a single parameter expansion +as `[[ word =~ $rex ]]`, or one can use `ble/string#match 'word' "$rex"` instead. +In other contexts, the arguments of the conditional command should not be quoted +unless raw special characters ``[[:space:]|&;<>\`"$]`` are contained in the argument. + +**No `-eq` etc**--Basically use arithmetic commands `((expr))` +instead of the operators `-eq`, `-ne`, `-gt`, `-ge`, `-lt`, and `-le` of the conditional command. +They might be used when the test is used as a part of complicated conditions in the conditional commands. +For example, `[[ -f $file || $word && word -eq 0 ]]` can be used instead of `[[ -f $file ]] || { [[ $word ]] && ((word == 0)); }` because sticking with the arithmetic command would unnecessarily complicate the code in this case. + +### Other styles + +**Function definition**--There are two forms of function definitions, the POSIX style `func()` and the ksh style `function func`, as well as the mixed form. +We always use the ksh style of the function definition. +The reasons are that it is easier to search by the keyword `function ` and that it is protected by the aliases of the same name as the function (unless the user defines an alias with the same name as the keyword `function`). +The function body is always the compound command `{ ... }` (instead of any other compound commands such as `( ... )`, `for`, `if`, etc.), and the opening brace `{` is placed on the first line. + +```bash +function function-name { + : do_something +} +``` + +**`ble/util/print`**--Use `ble/util/print` instead of `echo`. Use `ble/util/put` instead of `echo -n`. +The control characters should be directly specified by the escape string literal `$'...'` instead of relying on the conversion by `echo -e`. +This is because the builtin `echo` can change its behavior depending on the shell option `shopt -s xpg_echo`, where the backslashes in the arguments might have special meaning. +`ble.sh` is intended to work under any possible user options. + +**Quote/unquote**--The arguments where the word splitting and pathname expansions can take place need to be always quoted. +When the subject word of the `case` statement and the right-hand sides of variable assignments +(including those specified to assignment builtins `declare`, `typeset`, `local`, `export`, and `readonly`) +contains `$*`, `${arr[*]}`, or raw special characters ``[[:space:]|&;<>\`"$]``, they need to be quoted. +In other contexts, the subject word of `case` and the right-hand sides of variable assignments should not be quoted. +In these contexts, the word splitting and pathname expansions will never happen, so the quoting is unnecessary. + + +Array subscripts are arithmetic context, so the arithmetic expansions `$((expr))` inside the array subscripts are redundant. One should simply write it as `arr[expr]` instead of `arr[$((expr))]`. + +**`ble/util/assign`**--Use `ble/util/assign`, `ble/util/assign-array`, and `ble/util/assign-words` instead of `var=$(cmd)`, `mapfile -t var <<< "$(cmd)"`, and `var=($(cmd))`, respectively. +The command substitutions `$(...)` are slow because they involve the forks of subshells. + +**External commands**--Implement it using built-in Bash features as much as possible. +If the same result can be obtained by built-in Bash features efficiently, do not use the external commands. +When the external command is used, first freeze the path by calling `ble/bin#freeze-utility-path ''` and call the commands through `ble/bin/`. +Or save the path of the external command in a variable, and call the command through the variable as `"$_saved_cmd" args...`. +The POSIX commands should be basically used. If non-POSIX commands are used, a POSIX fallback should be always prepared. +Please combine multiple calls of external commands into a single call of the command as much as possible. +Usually, a single call of `sed` and `awk` is preferred over the chain of simple commands. diff --git a/.local/share/blesh/doc/ChangeLog.md b/.local/share/blesh/doc/ChangeLog.md new file mode 100644 index 0000000..b1ed031 --- /dev/null +++ b/.local/share/blesh/doc/ChangeLog.md @@ -0,0 +1,3198 @@ + +# ble-0.4.0-devel4 + +2023-04-03... (`#D2030`...) 1a5c451c... + +## New features + +- Bash 5.3 support + - syntax: support bash-5.3 function subst `${ list; }` `#2045` 0906fd95 71272a4b + - decode(bind): support the colonless form of `bind -x` of bash-5.3 `#D2106` 78d7d2e3 + - util(joblist): fix job detection in Bash 5.3 `#D2157` 6d835818 + - util(joblist): exclude more foreground dead jobs in Bash 5.3 `#D2174` 8a321424 + - global: work around function names with slashes in Bash 5.3 POSIX mode `#D2221` 48c7bbee + - main: fix workaround for the posix vi-insert C-i binding in `bash <= 5.0` (reported by vasi786) `#D2243` xxxxxxxx + - main: update the startup message for debug versions of Bash `#D2222` afb29073 + - main: shorten the startup message for debug versions `#D2241` 0bc8610a + - decode(read-user-settings): read the colonless form of `bind -x` of Bash 5.3 `#D2233` 62b23b69 +- bgproc: support opts `kill9-timeout=TIMEOUT` `#D2034` 3ab41652 +- progcomp(cd): change display name and support mandb desc (requested by EmilySeville7cfg) `#D2039` 74402098 +- cmdspec: add completion options for builtins (motivated by EmilySeville7cfg) `#D2040` 9bd24691 +- complete: support `bleopt complete_requote_threshold` (requested by rauldipeas) `#2048` bb7e118e +- menu (`ble/widget/menu/append-arg`): add option `bell` (motivated by bkerin) `#D2066` 3f31be18 bbf3fed3 +- make: support `make uninstall` `#D2068` a39a4a89 +- edit: support `bleopt {edit_marker{,_error},exec_exit_mark}` `#D2079` e4e1c874 +- edit: add widget `zap-to-char` `#D2082` ce7ce403 +- keymap/vi: split widget `text-object` into `text-object-{inner,outer}` (requested by Darukutsu) `#D2093` 11cf118a +- keymap/vi: implement text-object in xmap for brackets (requested by Darukutsu) `#D2095` 7d80167c +- util: support `ble-import -C callback` (motivated by Dominiquini) `#D2102` 0fdbe3b0 +- mandb: look for git subcommands (motivated by bkerin) `#D2112` 9641c3b8 +- edit (`display-shell-version`): show the `atuin` version `#D2124` 9045fb87 +- complete: add widgets `auto_complete/insert-?word` (requested by Tommimon) `#D2127` 0c4b6772 + - auto-complete: insert word only when the cursor is at the end of line `#D2212` b72d78a9 +- edit: add widgets `execute-named-command` and `history-goto` `#D2144` aa92b42a +- keymap/vi_nmap: support `shell-expand-line` `#D2145` aa92b42a + - decode: fix quoting of `WIDGET` and `LASTWIDGET` (reported by 3ximus) `#D2205` 1313390b +- main: support `bash ble.sh --install` `#D2169` 986d26a3 3801a87e +- util(stty): support `bleopt term_stty_restore` (requested by TheFantasticWarrior) `#D2170` e64b02b7 + - util: update workaround of Bash 5.2 `checkwinsize` for `term_stty_restore` (reported by TheFantasticWarrior) `#D2184` ef8272a4 +- magic expansions + - edit: support `bleopt edit_magic_accept` (requested by pl643, bkerin) `#D2175` 3e9d8907 + - edit: support `bleopt edit_magic_accept=verify-syntax` `#D2178` ac84c153 + - edit: support `bleopt edit_magic_{expand,accept}=autocd` (motivated by Jai-JAP) `#D2187` b6344b3b +- main: support shell variable `BLE_VER` `#D2177` a12dedab +- util(bleopt, blehook, ble-face): support wildcards `*` and `?` and change `@` to match an empty string `#D2182` bf595293 +- complete(cd): complete variable names for `cdable_vars` `#D2190` 10527901 +- sabbrev: support suffix sabbrev to emulate Zsh's suffix aliases `#D2191` d66e05d2 + - sabbrev: fix bugs in sabbrev matching and positioning (reported by dgudim) `#D2198` 70a325f9 +- complete: support `ble-face menu_desc_{default,type,quote}` (requested by romaia) `#D2193` b3e7237e +- complete: support `bleopt complete_menu_complete_opts=hidden` and menu-style switching (requested by CamRatliff) `#D2199` 16ff7df7 +- syntax: support `ln=target` in `bleopt filename_ls_colors` (requested by akhilkedia) `#D2213` e169e31d +- syntax: support arbitrary suffixes in `bleopt filename_ls_colors` `#D2213` e169e31d +- util(vbell): support `bleopt vbell_align=panel` (requested by bb010g) `#D2228` fe85e0dd +- highlight: reflect the top-level positional parameters `#D2246` xxxxxxxx + +## Changes + +- edit: clear character highlighting for overwriting mode (requested by mozirilla213) `#D2052` 1afc616b +- history (`ble/builtin/history -w`): write file even without any new entries (requested by Jai-JAP) `#D2053` c78e5c9f +- auto-complete: overwrite subsequent characters with self-insert in overwrite mode `#D2059` 7044b2db +- complete: move face definitions `menu_filter_*` to `core-complete-def.sh` `#D2060` af022266 +- make: add `INSDIR_LICENSE` for install location of licenses (reported by willemw) `#D2064` d39998f0 acf3b091 +- prompt: show prompt ruler after markers (motivated by U-Labs) `#D2067` e4a90378 +- complete: suffix a space to non-filenames with `compopt -o filenames` (reported by Dominiquini) `#D2096` aef8927f +- edit: distinguish space and delimiters in `cword` and `eword` `#D2121` 4f453710 +- prompt: update status line on face change (motivated by Vosjedev) `#D2134` f3e7e386 +- decode: specify the default keymap for the keymap load hooks `#D2141` 4a34ccf2 +- progcomp(compopt): refactor the completion option `ble/{no- => }default` `#D2155` 51f9f4f6 +- main: export `BLE_SESSION_ID` `#D2188` 5871fea2 +- menu-complete: adjust cursor position with `insert-selection` disabled (reported by gvlassis) `#D2206` 341179d1 +- decode (`ble-bind`): do not convert registered C0 (motivated by gvlassis) `#D2210` cbf87fdc + - decode: process @ESC generated by CSI sequence (reported by gvlassis, 10b14224cc, lokxii) `#D2214` 365101cf +- decode (`ble-bind`): support combined option arguments of the forms `--long=OPTARG` and `-kOPTARG` `#D2211` 1b16d399 +- canvas: use `_ble_term_invis` to hide characters used to determine char-width modes (requested by tessus) `#D2223` 8bb302e0 + - canvas: hide cursor during char-width detection (requested by tessus) `#D2232` 0ff29b26 + +## Fixes + +- util (`conditional-sync`): fix bugs when `pid=PID` is specified (contributed by bkerin) `#D2031` 09f5cec2 `#D2034` 09f5cec2 + - util (`conditional-sync`): fix wrong command grouping overwriting `pid=PID` (reported by dragonde, georglauterbach) `#D2122` +- bgproc: return status of bgproc process `#D2036` 887d92dd +- mandb: replace TAB with 4 spaces before removing control characters (reported by EmilySeville7cfg) `#D2038` 313cfb25 +- menu(desc): fix a bug that prefix is not shown with menu-filter `#D2039` e92b78d6 +- progcomp: make option unique after applying mandb description `#D2042` 308ceeed +- util (`ble/util/idle`): fix an infinite loop `#D2043` 5f4c0afd +- main: fix `--inputrc=TYPE` not applied on startup `#D2044` 1b15b851 0adce7c9 +- stty: suggest `stty sane` after exiting from bash >= 5.2 to non-ble session `#D2046` b57ab2d6 +- util (`ble/builtin/readonly`): adjust bash options (reported by dongxi8) `#D2050` 1f3cbc01 +- history (`ble/builtin/history`): fix error message on the empty `HISTFILE` `#D2061` a2e2c4b6 +- complete: exit auto-complete mode on complete self-insert `#D2075` 2783d3d0 +- complete: fix error messages on empty command names `#D2085` dab8dd04 +- complete: fix parsing the output of `complete -p` in bash-5.2 (reported by maheis) `#D2088` a7eb5d04 +- make: specify bash to search the awk path using `type -p` (reported by rashil2000) `#D2089` 26826354 +- keymap/vi: fix the behavior of text-object for quotes in xmap (reported by Darukutsu) `#D2094` 5f9a44ec +- edit(redo): fix broken common prefix/suffix determination (reported by Darukutsu) `#D2098` c920ea65 +- keymap/vi: improve text-object in omap for brackets (reported by Darukutsu) `#D2100` d1a1d538 +- decode(bind): fix command-line argument parsing `#D2107` 57a13c3c +- edit(gexec): fix a bug that `LINENO` is vanishing `#D2108` b5776596 +- mandb: fix extraction of option description in format 5 (reported by bkerin) `#D2110` 90a992cc +- decode: fix handling of @ESC in quoted-insert `#D2119` 0bbc3639 +- syntax: save stat after command name for consistent completion-context `#D2126` 50d6f1bb +- term: fix control sequences for hiding cursor (reported by n87) `#D2130` f9b9aea8 + - term: fix `_ble_term_rmcivis` for `TERM=linux` `#D2197` 56765251 +- highlight: fix inconsistent tab width in plain layer (reported by dgudim) `#D2132` f9072c40 +- decode: consume incomplete keyseq in macros `#D2137` 27e6309e +- keymap/vi: fix conflicting binding to C-RET in `vi_imap` `#D2146` 0b18f3c2 +- decode: force updating cache for @ESC `#D2148` 6154d71c +- progcomp(compopt): support printing the current options (reported by bkerin) `#D2154` 51f9f4f6 +- progcomp(compopt): properly handle dynamically specified `plusdirs` `#D2156` 51f9f4f6 +- edit: fix `BLE_COMMAND_ID` starting from `2` `#D2160` 8f4bf62a +- util(vbell): fix previous vbell not fully cleared `#D2181` 6c740a94 +- decode(rlfunc): fix widget name `vi-command/edit-and-execute-{line => command}` (fixed by alexandregv) 6aa8ba67 +- util(ble/util/idle.push): fix uninitialized `ble/util/idle.clock` (reported by Anyborr) `#D2189` 83ceb124 +- prompt: clear list for the cylic dependency detection (reported by micimize, neilbags) `#D2200` 61968497 00cae745b +- util.hook: fix user DEBUG trap not executed at the top-level context `#D2202` 828fcfc1 +- keymap/vi(relative-line.impl): fix uninitialized variable `nmove` `#D2203` 4268650d +- edit: render the final prompt before updating command history (motivated by pallaswept) `#D2207` 911a4051 + - debug: support `bleopt debug_profiler_opts=tree` `#D2216` a453f373 + - edit: fix leftover region after command execution `#D2247` xxxxxxxx +- keymap/vi: fix C-w not saving the word into kill ring `#D2208` aa7ca45d +- edit: fix standard streams in `EXIT` trap with `ble/widget/exit` `#D2217` 89f0dab8 +- util(`ble/fd#cloexec`): check `fdflags` compatibility to avoid crash `#D2227` c3b3aaf8 +- util(`ble/function#evaldef`): suppress alias expansions (reported by 103sbavert) `#D2240` 51e762fe + - main: fix a bug that `_ble_bash` is missing (reported by tessus and Knusper) `#D2242` bb2dae6e a9b962d2 +- mandb: fix incorrect use of `groff` in place of `nroff` `#D2245` xxxxxxxx + +## Compatibility + +- main: check `nawk` version explicitly `#D2037` 0ff7bca1 +- mandb: inject in bash-completion-2.12 interfaces `#D2041` dabc8553 +- complete: determine comp prefix from `COMPS` when `ble/syntax-raw` is specified (reported by teutat3s) `#D2049` f16c0d80 +- syntax: allow double-quotes in `$(())` in bash-4.4 (requested by mozirilla213) `#D2051` 611c1d93 +- syntax: support version-dependent arithmetic backslash `#D2051` 611c1d93 +- util: work around mawk 1.3.3-20090705 regex (reported by dongxi8, Frezrik) `#D2055` 4089c4e1 +- complete: update a workaround for cobra-1.5.0 (reported by 3ximus) `#D2057` a24435d3 +- make: work around ecryptfs bug (reported by juanejot) `#D2058` 969a763e dc0cdb30 +- edit: update mc-4.8.29 integration (reported by mooreye) `#D2062` 2c4194a2 68c5c5c4 +- make: work around `make-3.81` bug of pattern rules `#D2065` f7ec170b +- decode: work around `convert-meta on` in bash >= 5.2 with broken locale (reported by 3ximus) `#D2069` 226f9718 +- canvas: adjust GraphemeClusterBreak of hankaku-kana voiced marks `#D2077` 31d168cc +- canvas: update tables and grapheme clusters for Unicode 15.1.0 `#D2078` 503bb38b 9d84b424 9d84b424 +- complete: use conditional-sync for cobraV2 completions (reported by sebhoss) `#D2084` 595f905b +- term: add workarounds for `eterm` `#D2087` a643f0ea +- global: adjust bash options for utilities outside the ble context (motivated by jkemp814) `#D2092` 6b144de7 +- decode,syntax: quote `$#` in arguments properly `#D2097` 40a625d3 +- global: work around case-interleaving collation (reported by dongxi8) `#D2103` a3b94bb3 +- nsearch: set `immediate-accept` for `empty=emulate-readline` (reported by blackteahamburger) `#D2104` 870ecef7 +- decode, vi_digraph: trim CR of text resources in MSYS `#D2105` 6f4badf4 +- progcomp: conditionally suffix space for git completion (reported by bkerin) `#D2111` 2c7cca2f +- main: fix initialization errors with `set -u` `#D2116` b503887a +- progcomp: work around slow `make` completion in large repository (reported by blackteahamburger) `#D2117` 5f3a0010 +- util(TRAPEXIT): fix condition for `stty sane` in Cygwin `#D2118` a7f604e1 +- progcomp: fix the detection of the zoxide completion (reported by 6801318d8d) `#D2120` 29cd8f10 +- progcomp: pass original command path to completion functions (reported by REmerald) `#D2125` 0cf0383a +- main: work around nRF Connect initialization (requested by liyafe1997) `#D2129` 2df3b109 +- main(unload): redirect streams to work around trap `EXIT` in bash-5.2 (reported by ragnarov) `#D2142` 38a8d571 +- complete: call the `docker` command through `ble/util/conditional-sync` `#D2150` 6c3f824a +- util,complete: work around regex `/=.../` failing in Solaris nawk `#D2162` 46fdf44a +- main: fix issues in MSYS1 `#D2163` 5f0b88fb +- util: work around bash-3.1 bug that `10>&-` fails to close the fd `#D2164` b5938192 +- decode: fix the problem that key always timed out in bash-3 `#D2173` 0b176e76 +- term: adjust the result of `tput clear` for `ncurses >= 6.1` (reported by cmndrsp0ck) `#D2185` 18dd51ab +- main: work around WSL's permission issue on `/run/user/1000` (reported by antonioetv and geoffreyvanwyk) `#D2195` fb826ab6 +- util: detect Zellij heuristically `#D2219` 86034398 +- decode: exclude `/etc/inputrc` in SUSE as well as in openSUSE (reported by Anyborr) `#D2220` 63be48df +- term: detect iTerm2 `#D2224` da6e71db +- mandb: support man page format of `rg` (requested by pallaswept) `#D2225` 063bf66b +- mandb: restore ASCII hyphens from Unicode hyphens before analysis (reported by pallaswept) `#D2230` f160b8f0 +- main: work around the issue WSL clears `/tmp` after Bash starts (reported by LeonardoMor) `#D2235` fcbf1ed0 +- decode(`ble/builtin/bind`): support single quotes in the macro/command strings `#D2236` 2f90120e +- mandb: process less formatting sequences in parsing `--help` `#D2244` xxxxxxxx + +## Contrib + +- histdb + - fix(histdb): show error message only when bgproc crashed `#D2036` 887d92dd + - util: add `ble/util/{time,timeval,mktime}` `#D2133` 34a886fe + - histdb: suppress outputs from `PRAGMA quick_check;` `#D2147` 6154d71c + - histdb: fix variable leak of `ret` `#D2152` 98a2ae15 + - util: fix `ble/util/time` in `bash < 4.2` `#D2161` 623dba91 + - histdb: support subcommands `#D2167` 4d7dd1ee + - histdb: support `top`, `stats`, `calendar`, and `week` `#D2167` 4d7dd1ee + - histdb: unify the color palette selection `#D2167` 4d7dd1ee +- contrib/fzf-git: update to be consistent with the upstream (motivated by arnoldmashava) `#D2054` c78e5c9f +- contrib/layer/pattern: add `{pattern}` layer `#D2074` 449d92ca +- contrib/fzf-git: fix unsupported command modes (reported by dgudim) `#D2083` ba2b8865 +- contrib/bash-preexec: support the latest version of `bash-preexec` (reported by mcarans) `#D2128` 50af4d9c +- contrib/config/execmark: output error status through `ble/canvas/trace` `#D2136` 64cdcd01 +- contrib/airline: remove dummy faces (reported by alexalekseyenko) `#D2204` 59787ee5 +- contrib/airline: update themes `#D2204` 59787ee5 +- contrib/fzf-git: fix unadjusted terminal states in calling `fzf` (reported by tessus) `#D2237` b154058a +- contrib/bash-preexec: support `__bp_set_ret_value` (requested by Comnenus) `#D2238` b154058a +- contrib/colorglass: fix fixed-point round `#D2239` b154058a + +## Documentation + +- docs(CONTRIBUTING): add styleguide (motivated by bkerin) `#D2056` 44cf6756 +- docs(README): fix dead links to blerc.template (fixed by weskeiser) e0f3ac28 +- github: add FUNDING `#D2080` 3f133936 +- blerc: describe keybinding to accept autosuggestion by TAB (motivated by TehFunkWagnalls) `#D2090` cd069860 +- docs: apply Grammarly and fix typos `#D2099` 8b3f6f8c +- docs(README): add sabbrev example for named directories `#D2115` a9a21a0e +- docs(README): note `bleopt prompt_command_changes_layout=1` `#D2196` 208eaa9d + +## Test + +- test(bash): fix condition for bash bug of history expansion `#D2071` aacf1462 +- test(main): fix delimiter of `MSYS` in adding `winsymlinks` `#D2071` aacf1462 +- test(util,vi): adjust `ble/util/is-stdin-ready` while testing `#D2105` 23a05827 6f4badf4 +- test(vi): suppress warnings for non-interactive sessions `#D2113` b8b7ba0c +- test(bash,util): fix tests in interactive session `#D2123` 06ad3a6c +- test(vi): fix broken states after test `#D2123` 06ad3a6c +- test(bash): fix test cases for history expansion `#D2131` 838b4652 +- test(bash): add tests for bash array bugs `#D2149` 6154d71c +- github/workflows: update versions of GitHub Actions `#D2186` 0c42c8bd 433ac7c2 +- test: skip tests on `ble/test/chdir` failure `#D2234` 467ec48b + +## Internal changes + +- refactor: move files `{keymap/ => lib/keymap.}*` f4c973b8 +- global: fix coding style `#D2072` bdcecbbf +- memo: add recent configs and create directories `#D2073` 99cb5e81 +- highlight: generalize `region` layer `#D2074` 449d92ca +- keymap/vi: integrate vi tests into the test framework `#D2101` d16b8438 +- global(leakvar): fix variable leak `#D2114` d3e1232d +- make(scan): apply builtin checks to `contrib` `#D2135` 2f16d985 + - contrib/fzf-git: do not use `ble/util/print` in a script mode (reported by dgudim) `#D2166` 8f0dfe9b +- decode: change Isolated ESC to U+07FC `#D2138` 82bfa665 +- edit: introduce `selection` keymap for more flexible shift selection `#D2139` 2cac11ad + - edit: fix a regression that delete-selection does not work (reported by cmndrsp0ck) `#D2151` 98a2ae15 +- util: support `bleopt connect_tty` `#D2140` f940696f + - util: support `ble/fd#add-cloexec` and add `O_CLOEXEC` by default `#D2158` 785267e1 + - util: fix error of bad file descriptors (reported by ragnarov) `#D2159` 785267e1 + - util: work around macOS/FreeBSD failure on `exec 32>&2` (reported by tessus, jon-hotaisle) `#D2165` 8f0dfe9b + - main: record external file descriptors on `ble-attach` `#D2183` a508a827 + - util: check leftovers of CLOEXEC fds more strictly `#D2215` 79fe2483 +- main: fix unprocessed `-PGID` in `*.pid` for cleanup `#D2143` a5da23c0 +- history: prevent `SIGPIPE` from reverting the TTY state in trap `EXIT` `#D2153` 4b8a0799 + - history: fix initially shifted history index `#D2180` e425dc56 +- edit: support `bleopt internal_exec_int_trace` (motivated by tessus) `#D2171` cebea478 3801a87e +- global: avoid using the builtin `:` `#D2192` f2fd2955 +- global: pass `--` to `type` and `declare` before arbitrary arguments `#D2194` 5c0efcf6 +- global: fix spelling mistakes `#D2201` 86815f61 +- util (`ble/util/buffer.flush`): write to the TUI stderr `#D2218` b5c88947 +- util (`ble/util/buffer.flush`): use DECSET(2026) in terminals with the support `#D2226` c3df08be +- main: refactor initialization sequence `#D2231` cc9d7f39 + + +# ble-0.4.0-devel3 + +2020-12-02...2023-04-03 (`#D1427`...`#D2030`) 276baf2...1a5c451c + +## New features + +- decode (`ble-decode-kbd`): support various specifications of key sequences `#D1439` 0f01cab +- edit: support new options `bleopt edit_line_type={logical,graphical}` (motivated by 3ximus) `#D1442` 40ae242 +- complete: support new options `bleopt complete_limit{,_auto}` (contributed by timjrd) `#D1445` b13f114 5504bbc + - complete: update the default value of `bleopt complete_limit{,auto}` `#D1500` aae553c + - complete: inject user interruption and complete limits into `bash-completion` through `read` (motivated by timjrd) `#D1504` 856cec2 `#D1507` 4fc51ae +- edit (kill/copy): combine multiple kills and copies (suggested by 3ximus) `#D1443` 66564e1 + - edit (`{kill,copy}-region-or`): fix unconditionally combined kills/copies (reported by 3ximus) `#D1447` 1631751 +- canvas: update emoji database and support `bleopt emoji_version` (motivated by endorfina) `#D1454` d1f8c27 + - emoji: unify emoji tables of different versions `#D1671` af82662 +- canvas, edit: support `bleopt info_display` (suggested by 0neGuyDev) `#D1458` 69228fa + - canvas (panel): always call `panel::render` to update height `#D1472` 51d2c05 + - util (visible-bell): work around coordinate mismatches in subshells `#D1495` 01cfb10 + - canvas: work around kitty's quirk not recognizing DECSTBM (CSI ; r) `#D1503` eca2976 +- prompt: support `bleopt prompt_status_{line,align}` and `face prompt_status_line` `#D1462` cca1cbc + - prompt: fix missing height allocation for status line `#D1487` b424fa5 + - prompt: support `bleopt prompt_status_align=justify` `#D1494` c30a0db +- syntax: properly support case patterns `#D1474` `#D1475` `#D1476` 64b55b7 +- keymap/vi: add `ble/keymap:vi/script/get-mode` for user-defined mode strings `#D1488` f25a6e8 462918d +- prompt: support multiline `prompt_rps1` `#D1502` 4fa139a + - canvas: fix wrong coordinate calculation on linefolding (reported by telometto) `#D1602` 9badb5f + - prompt: fix coordinates after `prompt_rps1` `#D1972` e128801 + - prompt: clear remaining SGR after `prompt_rps1` (reported by linwaytin) `#D2003` ea99d944 +- syntax: support tilde expansions in parameter expansions `#D1513` 0506df2 +- decode: support `ble-bind -m KEYMAP --cursor DECSCUSR` (motivated by jmederosalvarado) `#D1514` `#D1515` `#D1516` 79d671d + - decode: reflect changes after `ble-bind --cursor` `#D1873` 39efcf9 +- edit: support `nsearch` options (motivated by Alyetama, rashil2000, carv-silva) `#D1517` 9125795 + - edit: support `nsearch` opts `empty=emulate-readline` (motivated by jainpratik163) `#D1661` d68ba61 + - edit: support bash-5.2 binding of `prior/next` to `history-search-{for,back}ward` `#D1661` d26a6e1 +- syntax: support the deprecated redirection `>& file` `#D1539` b9b0de4 +- complete: complete file descriptors and heredoc words after redirections `#D1539` b9b0de4 +- main: support `blehook ATTACH DETACH`, `BLE_ONLOAD`, `BLE_ATTACHED` `#D1543` 750ca38 +- main: support `ble` `#D1544` 750ca38 +- main (`ble-update`): support package updates and `sudo` updates (motivated by huresche, oc1024) `#D1548` 0bc2660 + - main (`ble-update`): fix help message (contributed by NoahGorny) 50288bf +- syntax: support undocumented `${a~}` and `${a~~}` `#D1561` 4df29a6 +- lib: support `lib/vim-airline` (motivated by huresche) `#D1565` da1d0ff + - util (`ble/gdict`): refactor `#D1569` 7732eed + - vim-airline: support `bleopt vim_airline_theme` `#D1589` 73b037f + - prompt: track dependencies and detect changes `#D1590` `#D1591` cf8d949 + - prompt: preserve `LINES` and `COLUMNS` for custom sequences `#D1592` 040016d + - color: fix the face initialiation order for uses in prompts (motivated by jmederosalvarado) `#D1593` 321371f + - prompt (`contrib/prompt-git`): support dirty checking `#D1601` b2713d9 + - prompt (`contrib/prompt-git`): do not use `ble/util/idle` in Bash 3 `#D1606` 959cf27 + - util (`bleopt`): add new option `-I` to reinitialize user settings on reload `#D1607` 959cf27 + - vi (vi_cmap): fix wrong prompt calculations by the outdated initial values `#D1653` 2710b23 + - vim-airline: measure separator widths and fix layout of status line `#D1999` 1ce0d1ad 478c9a10 +- util, color: refactor configuration interfaces (`bleopt`, `blehook`, `ble-face`) `#D1568` c94d292 + - color: support new face setting function `ble-face` + - util (`bleopt`): support option `-r` and `-u` and wildcards in option names + - util (`blehook`): hide internal hooks by default and support option `-a` + - util, color: fix argument analysis of `bleopt`, `blehook`, and `ble-face` (fixup c94d292) `#D1571` bb53271 + - util (`blehook`): show explicitly specified internal hooks `#D1594` f4312df + - util (`bleopt`): do no select obsoleted options by wildcards `#D1595` f4312df + - util (`bleopt`): fix error messages for unknown options `#D1610` 66df3e2 + - util (`bleopt`, `bind`): fix error message and exit status, respectively `#D1640` b663cee + - util (`blehook`): support wildcards `#D1861` 480b7b3 +- progcomp: support quoted commands and better `progcomp_alias` `#D1581` `#D1583` dbe87c3 + - progcomp: fix a bug that command names may stray into completer function names `#D1611` 1f2d45f +- syntax: highlight quotes of the `\?` form `#D1584` 5076a03 + - syntax: recognize escape \" in double-quoted strings `#D1641` 4b71449 +- prompt: support a new backslash sequence `\g{...}` `#D1609` be31391 + - prompt: accept more general `[TYPE:]SPEC` in `\g{...}` like `ble-face` `#D1963` 81b3b0e + - prompt: fix non-working 24-bit color in `\g{...}` `#D1977` 881ec25 +- complete: add a new option `bleopt complete_limit_auto_menu` `#D1618` 1829d80 +- canvas: support grapheme clusters (motivated by huresche) `#D1619` c0d997b + - canvas (`ble/util/c2w`): use `EastAsianWidth` and `GeneralCategory` to mimic `wcwidth` `#D1645` 9a132b7 + - canvas (c2w:auto): work around combining chars applied to the previous line `#D1649` 1cbbecb + - canvas (c2w:auto): avoid duplicate requests `#D1649` 1cbbecb a3047f56 + - canvas (c2w:auto): send DSR(6) in the internal state `#D1664` a3047f5 + - canvas (c2w): support `bleopt char_width_mode=musl` `#D1668` 05b258f `#D1672` af82662 + - canvas (c2w:auto): detect `emacs` and `musl` `#D1668` 05b258f +- rlfunc: support vi word operations in `emacs` keymap (requested by SolarAquarion) `#D1624` 21d636a +- edit: support `TMOUT` for the session timeout `#D1631` 0e16dbd +- edit: support bash-5.2 `READLINE_ARGUMENT` `#D1638` d347fb3 +- complete: support `complete [-DI]` in old versions of Bash through `_DefaultCmD_` and `_InitialWorD_` `#D1639` 925b2cd +- rlfunc: support nsearch widgets in `vi_nmap` keymap (requested by cornfeedhobo) `#D1651` 9a7c8b1 +- prompt: support `bleopt prompt_ruler` (motivated by Barbarossa93) `#D1666` 05cf638 + - prompt: fix hanging by a zero-width `prompt_ruler` `#D1673` 9033f29 +- edit: support `bleopt canvas_winch_action` (requested by Johann-Goncalves-Pereira, guptapriyanshu7) `#D1679` 2243e91 + - blerc: fix the name of the option `bleopt canvas_winch_action` (reported by Knusper) b1be640 + - edit: go back to the previous lines with `redraw-here` more aggressively `#D1966` a125187 +- menu (menu-style:desc): improve descriptions (motivated by Shahabaz-Bagwan) `#D1685` 4de1b45 +- menu (menu-style:desc): support multicolumns (motivated by Shahabaz-Bagwan) `#D1686` 231dc39 + - menu (menu-style:desc): fix not working `bleopt menu_desc_multicolumn_width=` `#D1727` 2140d1e +- term: let DECSCUSR pass through terminal multiplexers (motivated by cmplstofB) `#D1697` a3349e4 + - util: refactor `_ble_term_TERM` `#D1746` 63fba6b +- complete: requote for more compact representations on full completions `#D1700` a1859b6 + - complete (requote): requote from optarg/rhs starting point `#D1786` 93c2786 +- complete: improve support for `declare` and `[[ ... ]]` `#D1701` da38404 + - syntax: fix completion and highlighting of `declare` with assignment arguments `#D1704` `#D1705` e12bae4 + - cmdspec: refactor `{mandb => cmdspec}_opts` `#D1706` `#D1707` 0786e92 +- complete (menu-style:align): refactor `complete_menu_align => menu_align_{min,max}` (motivated by banoris) `#D1717` 22a2449 +- prompt: support `bleopt prompt_command_changes_layout` `#D1750` e199bee +- exec: measure execution times `#D1756` 2b28bec + - edit: work around a bash-4.4..5.1 bug of `exit` outputting time to stderr of exit context `#D1765` 3de751e e61dbaa + - edit (`exec_elapsed_mark`): show hours and days `#D1793` 699dabb +- util: preserve original traps and restore them on unload `#D1775` `#D1776` `#D1777` 398e404 + - util (trap): fix a bug of restoring original traps `#D1850` 8d918b6 +- progcomp: support `compopt -o ble/no-default` to suppress default completions `#D1789` 7b70a0e +- sabbrev: support options `-r` and `--reset` to remove entries `#D1790` 29b8be3 +- util (blehook): support `hook!=handler` and `hook+-=handler` `#D1791` 0b8c097 +- prompt: escape control characters in `\w` and `\W` `#D1798` 8940434 a9551e5 + - prompt: fix wrongly escaped UTF-8 chars in `\w` and `\W` `#D1806` d340233 + - prompt: fix a bug that `\u` is expanded to the shell name `#D1975` fe339c3 +- emacs: support `bleopt keymap_emacs_mode_string_multiline` (motivated by ArianaAsl) `#D1818` 8e9d273 +- util: synchronize rlvars with `bleopt complete_{menu_color{,_match},skip_matched} term_bracketed_paste_mode` (motivated by ArianaAsl) `#D1819` 6d20f51 + - util: suppress false warnings of `bind` inside non-interactive shells (reported by wukuan405) `#D1823` 1e19a67 +- history: support `bleopt history_erasedups_limit` (motivated by SuperSandro2000) `#D1822` e4afb5a 3110967 +- prompt: support `bleopt prompt_{emacs,vi}_mode_indicator` (motivated by ferdinandyb) `#D1843` 2b905f8 +- util (`ble-import`): support option `-q` `#D1859` 1ca87a9 +- history: support extension `HISTCONTROL=strip` (motivated by aiotter) `#D1874` 021e033 +- benchmark (ble-measure): support an option `-V` `#D1881` 571ecec +- color: allow setting color filter by `_ble_color_color2sgr_filter` `#D1902` 88e74cc +- auto-complete: add `bleopt complete_auto_complete_opts` (motivated by DUOLabs333) `#D1901` `#D1911` 1478a04 6a21ebb +- menu-complete: add `bleopt complete_menu_complete_opts` (requested by DUOLabs333) `#D1911` 6a21ebb +- edit (`magic-space`): support `bleopt edit_magic_expand=...:alias` (requested by telometto) `#D1912` 63da2ac + - auto-complete: cancel auto-complete for `magic-space` `#D1913` 01b4f67 +- complete: support ambiguous completion for command paths `#D1922` 8a716ad +- complete: preserve original path segments as long as possible `#D1923` `#D1924` e3cdb9d +- main: support `BLE_SESSION_ID` and `BLE_COMMAND_ID` `#D1925` 44d9e10 `#D1947` 46ac426 `#D1954` 651c70c +- main: support an option `--inputrc={diff,all,user,none}` `#D1926` 92f2006 +- util (`ble/builtin/trap`): support Bash 5.2 `trap -P` `#D1937` 826a275 +- syntax: highlight `\?` in here documents `#D1959` e619e73 +- syntax: recognize history expansion in here documents, `"...!"` (bash <= 4.2), and `$!` (bash <= 4.1) `#D1959` e619e73 +- syntax: support context after `((...))` and `[[ ... ]]` in bash-5.2 `#D1962` 67cb967 +- edit: support the readline variable `search-ignore-case` of bash-5.3 `#D1976` e3ad110 +- menu-complete: add `insert_unique` option to the `complete` widget `#D1995` 36efbb7 +- syntax: check alias expansions of `coproc` variable names `#D1996` 92ce433 +- syntax: support new parameter transformation `"${arr@k}"` `#D1998` 1dd7e385 +- edit: support a user command `ble append-line` (requested by mozirilla213) `#D2001` 2a524f34 +- decode: accept isolated ESC \ (requested by mozirilla213) `#D2004` d7210494 +- sabbrev: add widget `magic-slash` to approximate Zsh named directories (motivated by mozirilla213) `#D2008` e6b9581c +- sabbrev: support inline and linewise sabbre with `ble-sabbrev -il` `#D2012` 56208534 +- complete: add `bleopt complete_source_sabbrev_{opts,ignore}` (motivated by mozirilla213) `#D2013` f95eb0cc `#D2016` 45c76746 +- util.bgproc: separate `ble/util/bgproc` from `histdb` (motivated by bkerin) `#D2017` 7803305f + - util.bgproc: fix use of `ble/util/idle` in bash-3 `#D2026` 79a6bd41 + - util.bgproc: increase frequency of bgproc termination check (motivated by bkerin) `#D2027` 8d623c19 + - util.bgproc: fix an `fd#alloc` failure in bash-4.2 `#D2029` 7c4ff7bc +- menu-complete: support selection by index (requested by bkerin) `#D2023` b91b8bc8 + +## Changes + +- syntax: exclude \\ + LF at the word beginning from words (motivated by cmplstofB) `#D1431` 67e62d6 +- complete: do not quote `:` and `=` in non-filename completions generated by progcomp (reported by 3ximus) `#D1434` d82535e +- edit: preserve the state of `READLINE_{LINE,POINT,MARK}` `#D1437` 8379d4a +- edit: change default behavior of C-w and M-w to operate on backward words `#D1448` 47a3301 +- prompt: rename `bleopt prompt_{status_line => term_status}` `#D1462` cca1cbc +- edit (`ble/builtin/read`): cancel by C-d on an empty line `#D1473` ecb8888 +- syntax: change syntax context after `time ;` and `! ;` for Bash 4.4 `#D1477` 4628370 +- decode (rlfunc): update mapping `vi-replace` in `imap` and `vi-editing-mode` in `nmap` (reported by onelittlehope) `#D1484` f2ca811 +- prompt: invalidate prompt and textarea on prompt setting changes `#D1492` 1f55913 +- README: update informations on stable versions `#D1509` c8e658e +- README: update the description of how to uninstall `#D1510` c8e658e +- util (`bleopt`): validate initial user settings `#D1511` 82c5ece + - util (`bleopt`): fix a bug that old values are double-expanded on init (fixup 82c5ece) `#D1521` f795c07 + - util (`bleopt`): do not validate obsoleted initial settings `#D1527` 032f6b2 +- main: preserve user-space overridden builtins `#D1519` 0860be0 + - util (`ble/util/type`): fix a bug that aliases are not properly highlighted (reported by 3ximus) `#D1526` 45b30a7 + - main: preserve user's `expand_aliases` and allow aliases in internal space (fixup 0860be0) `#D1574` afc4112 + - main: main: fix expand_aliases unset on ble-reload (fixup afc4112) `#D1577` 3417388 +- main: accept non-regular files as `blerc` and add option `--norc` `#D1530` 7244e2f +- prompt: let `stderr` pass through to tty in evaluating `PS0` (reported by tycho-kirchner) `#D1541` 24a88ce +- prompt: adjust behavior of `LINENO` and prompt sequence `\#` (reported by tycho-kirchner) `#D1542` 8b0257e + - prompt: update `PS0` between multiple commands (motivated by tycho-kirchner) `#D1560` 8f29203 +- edit (`widget:display-shell-version`): include `ble.sh` version `#D1545` 750ca38 + - edit (`display-shell-version`): detect configurations and print details `#D1781` 5015cb56 + - edit (`display-shell-version`): show information of the OS distribution and properly handle saved locales `#D1854` 066ec63 bdb7dd6 + - edit (`display-shell-version`): show `gawk`, `make`, and `git` versions of the build time `#D1892` e618133 + - edit (`display-shell-version`): support running as a user command (reported by DhruvaG2000) `#D1893` e618133 + - edit (`display-shell-version`): show warnings for fzf-integration `#D1907` 3bc3bea + - edit (`display-shell-version`): show the `zoxide` version `#D1907` 3bc3bea +- complete (`ble-sabbrev`): support colored output `#D1546` 750ca38 +- decode (`ble-bind`): support colored output `#D1547` 750ca38 + - decode (`ble-bind`): output bindings of the specified keymaps with `ble-bind -m KEYMAP` (fixup 750ca38) `#D1559` 6e0245a +- keymap/vi: update mode names on change of `bleopt keymap_vi_mode_name_*` (motivated by huresche) `#D1565` 11ac106 +- main: show notifications against debug versions of Bash `#D1612` 8f974aa +- term: terminal identification + - term (`_ble_term_TERM`): update `vte` identification `#D1620` 00e74d8 + - term (`_ble_term_TERM`): detect wezterm-20220408 `#D1909` 486564a + - term (`_ble_term_TERM`): detect konsole `#D1988` 600e845 ed53858 +- edit: suppress only `stderr` with `internal_suppress_bash_output` (motivated by rashil2000) `#D1646` a30887f +- prompt: do not evaluate `PROMPT_COMMAND` for subprompts `#D1654` 08e903e +- Makefile: work around the case the repository is cloned without `--recursive` `#D1655` 22ace5f +- repo: add subdirectories `make` and `docs` `#D1657` 75bd04c +- util: time out CPR requests `#D1669` 1481d48 + - util (CPR): fix the problem of always timing out (fixup 1481d48) `#D1792` 9b331c4 +- main: suppress non-interactive warnings from manually sourced startup files (reported by andreclerigo) `#D1676` 0525528 88e2df5 +- mandb: integrate `mandb` with `bash-completion` (motivated by Shahabaz-Bagwan, bbyfacekiller and EmilySeville7cfg) `#D1688` c1cd666 +- syntax: do not start argument completions immediately after previous word (reported by EmilySeville7cfg) `#D1690` 371a5a4 + - syntax: revert 371a5a4 and generate empty completion source on syntax error `#D1609` e09fcab +- syntax: strictly check variable names of `for`-statements `#D1692` d056547 +- widget `self-insert`: untranslate control chars and insert the last character `#D1696` 5ff3021 +- complete (`source:command`): exclude inactive aliases `#D1715` d6242a7 +- complete (`source:command`): not quote aliases and keywords `#D1715` d6242a7 +- highlight (`wtype=CTX_CMDI`): check alias names before shell expansions `#D1715` d6242a7 + - util (`ble/is-alias`): fix a bug of unredirected error messages for bash-3.2 (fixup d6242a7) `#D1730` 31372cb +- edit (`history_share`): update history on `discard-line` (reported by SuperSandro2000) `#D1742` 8dbefe0 +- canvas: do not insert explicit newlines on line folding if possible (reported by banoris) `#D1745` 02b9da6 dc3827b + - edit: fix layout with `prompt_rps1` caused by missing `opts=relative` for `ble/textmap#update` `#D1769` f6af802 +- edit (`ble-bind -x`): preserve multiline prompts on execution of `bind -x` commands (requested by SuperSandro2000) `#D1755` 7d05a28 +- util (`ble/util/buffer`): hide cursor in rendering `#D1758` e332dc5 +- complete (`action:file`): always suffix `/` to complete symlinked directory names (reported by SuperSandro2000) `#D1759` 397ac1f +- edit (command-help): show source files for functions `#D1779` 7683ab9 +- edit (`ble/builtin/exit`): defer exit in trap handlers (motivated by SuperSandro2000) `#D1782` f62fc04 6fdabf3 + - util (`blehook`): fix a bug that the the hook arguments are lost (reported by SuperSandro2000) `#D1804` 479795d + - edit: fix a bug of `ble/builtin/exit` inside subshells in the `EXIT` trap `#D1973` 0451521 +- complete (`source:command/get-desc`): show function location and body `#D1788` 496e798 +- edit (`ble-detach`): prepend a space to `stty sane` for `HISTIGNORE=' *'` `#D1796` 26b532e +- decode (`bind`): do not treat non-beginning `#` as comments `#D1820` 65c4138 +- history: disable the history file when `HISTFILE` is empty `#D1836` 9549e83 +- complete: generate options by empty-word copmletion after filenames (reported by geekscrapy) `#D1846` 6954b13 + - complete: do not show option descriptions for the empty-word completion (requested by geekscrapy) `#D1846` 1c7f7a1 +- syntax (`extract-command`): extract unexpected command names as commands `#D1848` 5b63459 +- main (`ble-reload`): preserve the original initialization options `#D1852` d8c92cc + - main (`ble-reload`): fix a bug that the default rcfile is not loaded `#D1914` 85b5828 +- blehook: print reusable code to restore the user hooks `#D1857` b763677 + - blehook: separate internal and user hooks `#D1856` b763677 + - blehook: prefer the uniq `!=` to the addition `+=` `#D1871` fe7abd4 + - blehook: print hooks with `--color=auto` by default `#D1875` 3953afe +- util (`ble/builtin/trap`): refactor + - trap,blehook: rename `ERR{ => EXEC}` and separate from the `ERR` trap `#D1858` 94d1371 + - trap: remove the support for the shell function `TRAPERR` `#D1858` 94d1371 + - trap: preserve `BASH_COMMAND` in trap handlers `#D1858` 94d1371 + - util (`ble/builtin/trap`): run EXIT trap in subshells `#D1862` 5b351e8 + - util (`ble/builtin/trap`): fix the RETURN trap `#D1863` 793dfad + - trap,blehook: move to a new file `util.hook.sh` `#D1864` 55a182b + - trap (`trap -p`): fix unprinted existing user traps `#D1864` 55a182b + - trap (`ble/builtin/trap/finalize`): fix a failure of restoring the original trap `#D1864` 55a182b + - trap (`trap -p`): print also custom traps `#D1864` 55a182b + - trap: preserve positional parameters for user trap handlers `#D1865` 9e2963c + - trap: suppress `INT` processing with user traps `#D1866` 5c28387 + - trap: unify handling of `DEBUG` and the other traps `#D1867` a22c25b + - trap: work around possible interferences by recursive traps `#D1867` a22c25b + - trap: ignore `RETURN` for `ble/builtin/trap/.handler` `#D1867` a22c25b + - trap: fix a bug that `DEBUG` for internal commands clears `$?` `#D1867` a22c25b + - trap: use `ble/util/assign/.mktmp` to read the `DEBUG` trap `#D1910` 1de9a1e +- progcomp: reproduce arguments of completion functions passed by Bash `#D1872` 4d2dd35 +- prompt: preserve transient prompt with `same-dir` after `clear-screen` `#D1876` 69013d9 +- color: let `bleopt term_index_colors` override the default if specified `#D1878` 7d238c0 +- canvas: update Unicode version 15.0.0 `#D1880` 49e55f4 +- decode (`vi_imap-rlfunc.txt`): update the widget for `backward-kill-word` as `kill-backward-{u => c}word` `#D1896` e19b796 +- color: rearrange color table by `ble palette` (suggested by stackoverflow/caoanan) `#D1961` bb8541d +- util (`ble/util/idle`): process events before idle sleep `#D1980` 559d64b +- keymap/vi (`decompose-meta`): translate S-a to A `#D1988` 600e845 +- sabbrev: apply sabbrev to right-hand sides of variable assignments `#D2006` 41faa494 +- complete (`source:argument`): fallback to rhs completion also for `name+=rhs` `#D2006` 41faa494 +- auto-complete: limit the line length for auto-complete `#D2009` 5bfbd6f2 +- complete (`source:argument`): generate sabbrev completions after normal completions (motivated by mozirilla213) `#D2011` a6f168d0 +- complete (`source:option`): carve out `ble/complete/source:option/generate-for-command` (requested by mozirilla213) `#D2014` 54ace59c + +## Fixes + +- term: fix a bug that VTE based terminals are not recognized `#D1427` 7e16d9d +- complete: fix a problem that candidates are not updated after menu-filter (reported by 3ximus) `#D1428` 98fbc1c +- complete/mandb-related fixes + - mandb: support mandb in FreeBSD `#D1432` 6c54f79 + - mandb: fix BS contamination used by nroff to represent bold (reported by rlnore) `#D1429` b5c875a + - mandb: fix an encoding prpblem of utf8 manuals `#D1446` 7a4a480 + - mandb: improve extraction and cache for each locale `#D1480` 3588158 + - mandb: fix an infinite loop by a leak variable (reported by rlanore, riblo) `#D1550` 0efcb65 + - mandb: work around old groff in macOS (reported by killermoehre) `#D1551` d4f816b + - mandb: use `manpath` and `man -w`, and read `/etc/man_db.conf` and `~/.manpath` `#D1637` 2365e09 + - mandb: support the formats of the man pages of `awk` and `sed` (reported by bbyfacekiller) `#D1687` 6932018 + - mandb: generate completions of options also for the empty word `#D1689` b90ac78 + - mandb: support the man-page formats of `wget`, `fish`, and `ping` (reported by bbyfacekiller) `#D1687` a79280e + - mandb: carry optarg for e.g. `-a, --accept=LIST` `#D1687` 23d5657 + - mandb: parse `--help` for specified commands `#D1693` e1ad2f1 + - mandb: fix small issues of man-page analysis `#D1708` caa77bc + - mandb: insert a comma in brace expansions instead of a space `#D1719` 0ac7f03 + - mandb: support man-page format of `rsync` `#D1733` 7900144 + - mandb: fix a bug that the description is inserted for `--no-OPTION` `#D1761` 88614b8 + - mandb: fix a bug that the man page is not correctly searched (fixup 2365e09) `#D1794` 65ffe70 + - mandb: support the man-page formats of `man ls` in coreutils/Japanese and in macOS `#D1847` fa32829 + - mandb: include short name in the longname description `#D1879` 60b6989 +- edit: work around the wrong job information of Bash in trap handlers (reported by 3ximus) `#D1435` `#D1436` bc4735e +- edit (command-help): work around the Bash bug that tempenv vanishes with `builtin eval` `#D1438` 8379d4a +- global: suppress missing locale errors (reported by 3ximus) `#D1440` 4d3c595 +- edit (sword): fix definition of `sword` (shell words) `#D1441` f923388 +- edit (`kill-forward-logical-line`): fix a bug not deleting newline at the end of the line `#D1443` 09cf7f1 +- util (`ble/util/msleep`): fix hang in Cygwin by swithing from `/dev/udp/0.0.0.0/80` to `/dev/zero` `#D1452` d4d718a + - util (`ble/util/msleep`): work around the bash-4.3 bug of `read -t` (reported by 3ximus) `#D1468` `#D1469` 4ca9b2e +- syntax: fix broken AST with `[[` keyword `#D1454` 69658ef +- benchmark (`ble-measure`): work around a locale-dependent decimal point of `EPOCHREALTIME` (reported by 3ximus) `#D1460` 1aa471b +- global: work around bash-4.2 bug of `declare -gA` (reported by 0xC0ncord) `#D1470` 8856a04 + - global: fix declaration of associative arrays for `ble-reload` (reported by 0xC0ncord) `#D1471` 3cae6e4 + - global: use a better workaround of bash-4.2 `declare -gA` by separating assignment `#D1567` 2408a20 +- bind: work around broken `cmd_xmap` after switching the editing mode `#D1478` 8d354c1 + - decode (`encoding:C`): fix initialization for isolated ESC `#D1839` c3bba5b +- edit: clear graphic rendition on newlines and external commands `#D1479` 18bb2d5 +- decode (rlfunc): work around incomplete bytes in keyseq (reported by onelittlehope) `#D1483` 3559658 beb0383 37363be +- main: fix a bug that unset `IFS` is not correctly restored `#D1489` 808f6f7 + - edit: fix error messages on accessing undo records in emacs mode (reported by rux616) `#D1497` 61a57c0 e9be69e +- canvas: fix a glitch that SGR at the end of command line is applied to new lines `#D1498` 4bdfdbf +- syntax: fix a bug that `eval() { :; }`, `declare() { :; }` are not treated as function definition `#D1529` b429095 +- decode: fix a hang on attach failure by cache corruption `#D1531` 24ea379 +- edit, etc: add workarounds for `localvar_inherit` `#D1532` 7b63c60 + - edit: fix a bug that `command-help` doesn't work `#D1635` 0f6a083 +- progcomp: fix non-working `complete -C prog` (reported by Archehandoro) `#D1535` 026432d +- bind: fix a problem that `bind '"seq":"key"'` causes a loop macro `bind -s key key` (reported by thanosz) `#D1536` ea05fc5 + - bind: fix errors on readline macros (reported by RakibFiha) `#D1537` c257299 +- main: work around sourcing `ble.sh` inside subshells `#D1554` bbc2a90 + - main: fix exit status for `bash ble.sh --test` (fixup bbc2a90) `#D1558` 641238a + - main: fix reloading after ble-update (fixup bbc2a90) (fixed by oc1024) `#D1558` 9372670 +- main: work around `. ble.sh --{test,update,clear-cache}` in intereactive sessions `#D1555` bbc2a90 +- Makefile: create `run` directory instead of `tmp` `#D1557` 9bdb37d +- main: fix the workaround for `set -e` `#D1564` ab2f70b + - main: fix the workaround for `set -u` `#D1575` 76073a9 + - main: fix the workaround for `set -eu` and refactor `#D1743` 6a946f0 + - decode: fix the workaround for `set -e` with `--prompt=attach` `#D1832` 5111323 +- util: work around bash-3.0 bug `"${scal[@]/xxx}"` `#D1570` 24f79da +- sabbrev (`ble-sabbrev`): fix delayed output before the initialization `#D1573` 5d85238 +- history: fix the workaround for bash-3.0 bug of reducing histories `#D1576` 15c9133 +- syntax: fix a bug that argument completion is attempted in nested commands (reported by huresche) `#D1579` 301d40f +- edit (brackated-paste): fix incomplete `CR => LF` conversion (reported by alborotogarcia) `#D1587` 8d6da16 +- main (adjust-bash-options): adjust `LC_COLLATE=C` `#D1588` e87ac21 +- highlight (`layer:region`): fix blocked lower-layer changes without selection changes `#D1596` 5ede3c6 +- complete (`auto-menu`): fix sleep loops by clock/sclock difference `#D1597` 53dd018 +- history: fix a bug that history data is cleared on `history -r` `#D1605` 72c274e +- util (`ble/string#quote-command`): remove redundant trailing spaces for single word command `#D1613` 94556b4 +- util: work around the Bash 3 bug of array assignments with `^A` and `^?` in Bash 3.2 `#D1614` b9f7611 +- benchmark (`ble-measure`): fix a bug that the result is always 0 in Bash 3 and 4 (fixup bbc2a904) `#D1615` a034c91 +- complete: fix a bug that the shopt settings are not restored correctly (reported by Lun4m) `#D1623` 899c114 +- decode, canvas, etc.: explicitly treat CSI arguments as decimal numbers (reported by GorrillaRibs) `#D1625` c6473b7 2ea48d7 +- history: fix the vanishing history entry used for `ble-attach` `#D1629` eb34061 +- 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` 7434d2d +- decode: fix a bug that the characters input while initialization are delayed `#D1670` 430f449 +- util (`ble/util/readfile`): fix a bug of always exiting with 1 in `bash <= 3.2` (reported by laoshaw) `#D1678` 61705bf +- trace: fix wrong positioning of the ellipses on overflow `#D1684` b90ac78 +- complete: do not generate keywords for quoted command names `#D1691` 60d244f +- menu (menu-style:align): fix the failure of delaying `ble/canvas/trace` on items (motivated by banoris) `#D1710` acc9661 +- complete: fix empty completions with `FIGNORE` (reported by seanfarley) `#D1711` 144ea5d +- main: fix the message of owner errors of cache directories (reported by zim0369) `#D1712` b547a41 +- util (`ble/string#escape-for-bash-specialchars`): fix escaping of TAB `#D1713` 7db3d2b +- complete: fix failglob messages while progcomp for commands containing globchars `#D1716` e26a3a8 + - complete: fix a bug that the default progcomp does not work properly `#D1722` 01643fa +- highlight: fix a bug that arrays without the element `0` is not highlighted `#D1721` b0a0b6f +- util (visible-bell): erase visible-bell before running external commands `#D1723` 0da0c1c + - util(`ble/util/eval-pathname-expansion`): fix restoring shopt options in bash-4.0 `#D1825` 736f4da +- util (`ble/function`): work around `shopt -u extglob` `#D1725` 952c388 +- syntax: fix uninitialized syntax-highlighting in bash-3.2 `#D1731` e3f5bf7 +- make: fix a bug that config update messages are removed on install `#D1736` 72d968f +- util: fix bugs in conversions from `'` to `\''` `#D1739` 6d15782 +- canvas: fix unupdated prompt on async wcwidth resolution `#D1740` e14fa5d +- progcomp: retry completions on `$? == 124` also for non-default completions (reported by SuperSandro2000) `#D1759` 82b9c01 +- app: work around data corruption by WINCH on intermediate state `#D1762` 5065fda +- util (`ble/util/import`): work around filenames with bash special characters `#D1763` b27f758 +- edit: fix the restore failure of `PS1` and `PROMPT_COMMAND` on `ble-detach` `#D1784` b9fdaab +- complete: do not attempt an independent rhs completion for arguments (reported by rsteube) `#D1787` f8bbe2c +- history: fix the unsaved history in the detached state `#D1795` 344168e +- edit: fix an unexpected leave from the command layout on `read` `#D1800` 4dbf16f + - edit: fix the command layout remaining after job information (reported by mozirilla213) `#D1991` dcfb067 +- history: work around possible dirty prefix `*` in the history output `#D1808` 64a740d +- decode (`ble-bind`): fix the printed definition of `-c`/`-x` bindings `#D1821` 94de078 +- command-help (`.read-man`): add missing `ble/util/assign/.rmtmp` `#D1840` 937a164 +- complete: fix wrong `COMP_POINT` with `progcomp_alias` `#D1841` 369f7c0 +- main (`ble-update`): fix error message with system-wide installation of `ble.sh` (fixed by tars0x9752) 1d2a9c1 a450775 +- main. util: fix problems of readlink etc. found by test in macOS (reported by aiotter) `#D1849` fa955c1 `#D1855` a22e145 +- progcomp: fix a bug that `COMP_WORDBREAKS` is ignored `#D1872` 4d2dd35 +- global: quote `return $?` `#D1884` 801d14a +- canvas (`ble/canvas/trace`): fix text justification for empty lines (reported by rashil2000) `#D1894` cdf74c2 +- main: fix adjustments of bash options (reported by rashil2000) `#D1895` 138c476 +- complete: suppress error messages for non-bash_completion `_parse_help` (reported by nik312123) `#D1900` 267de7f +- prompt: fix the marker position for the readline variable `show-mode-in-prompt` (reported by Strykar) `#D1903` 09bb4d3 +- highlight: fix a bug that `bleopt filename_ls_colors` is not working (reported by qoreQyaS) `#D1919` b568ade +- bind: fix M-C-@, C-x C-@, and M-C-x (`bash-4.2 -o emacs`) `#D1920` a410b03 +- complete (action:file): support `ble/syntax-raw` in the filename extraction (reported by qoreQyaS) `#D1921` 32277da +- decode: fix a bug that the tab completion do not work with bash-4.4 and lower `#D1928` 7da9bce +- complete: fix non-working ambiguous path completion with `..` and `.` in the path `#D1930` 632e90a +- main (`ble-reload`): fix failure by non-existent rcfile `#D1931` b7ae2fa +- syntax (`ble/syntax/highlight/vartype`): check variable in global scope `#D1932` b7026de +- menu (linewise): fix layout calculation with variable width of line prefix (reported by bkerin) `#D1979` cc852dc +- edit (`ble/textarea#render`): fix interleaving outputs to `_ble_util_buffer` and `DRAW_BUFF` `#D1987` 6d61388 +- keymap/vi (`expand-range-for-linewise-operator`): fix the end point being not extended `#D1994` bce2033 +- keymap/vi (`operator:filter`): do not append newline at the end of line `#D1994` bce2033 +- highlight: fix shifted error marks after delayed `core-syntax` `#D2000` f4145f16 +- syntax: fix unrecognized variable assignment of the form `echo arr[i]+=rhs` `#D2007` 41faa494 +- menu (linewise): fix clipping of long line (reported by bkerin) `#D2025` 4c6a4775 + +## Documentation + +- blerc: add all the missing options `#D1667` 0228d76 +- blerc: add missing faces `argument_option` and `cmdinfo_cd_cdpath` (reported by Prikalel) `#D1675` 26aaf87 +- README: describe how to invoke multiple widgets with a keybinding (motivated by michaelmob) `#D1699` 6123551 +- README: add links to `bash-it` and `oh-my-bash` `#D1724` 4a2575f +- README: mention the Guix package (motivated by kiasoc5) `#D1888` 0f7c04b +- blerc: add frequently used keybindings (motivated by KiaraGrouwstra, micimize) `#D1896` `#D1897` e19b796 +- wiki/Q&A: add item for defining a widget calling multiple widgets (motivated by micimize) `#D1898` e19b796 +- blerc: rename from `blerc` to `blerc.template` `#D1899` e19b796 +- README: add a link to the explanation on the "more reliable setup" of bashrc (motivated by telometto) `#D1905` 09bb4d3 +- README: describe `contrib/fzf` integration (reported by SuperSandro2000, tbagrel1) `#D1907` 3bc3bea b568ade +- README: add links to Manual pages for *kspec* and `modifyOtherKeys` `#D1917` fb7bd0b1 b568ade +- README: explain the build process `#D1964` `#D1965` 14ca1e5 + +## Optimization + +- syntax (`layer:syntax/word`): perform pathname expansions in background subshells (motivated by 3ximus) `#D1449` 13e7bdd + - syntax (`simple-word/is-simple-noglob`): suppress error messages on expansions `#D1461` a56873f + - syntax (`simple-word/eval`): fix unperformed tilde expansions in the background (reported by 3ximus) `#D1463` 6ebec48 + - syntax (`simple-word/eval`): propagate timeouts in sync highlighting (reported by 3ximus) `#D1465` c2555e2 + - edit: change the priority of `render-defer` and `menu-filter` `#D1501` aae553c +- complete: perform pathname expansions in subshells (motivated by 3ximus) `#D1450` d511896 +- complete: support `bleopt complete_timeout_compvar` to time out pathname expansions for `COMP_WORDS` / `COMP_LINE` `#D1457` cc2881a +- complete (`ble/complete/source:file`): remove slow old codes (reported by timjrd) `#D1512` e5be0c1 +- syntax (`ble/syntax:bash/simple-word/eval`): optimize large array passing (motivated by timjrd) `#D1522` c89aa23 + - syntax (`ble/syntax:bash/simple-word/eval`): use `mapfile -d ''` for Bash 5.2 `#D1604` 72c274e +- main: prefer `nawk` over `mawk` and `gawk` `#D1523` `#D1524` c89aa23 + - main (`ble/bin/.freeze-utility-path`): fix unupdated temporary implementations `#D1528` c70a3b4 + - util (`ble/util/assign`): work around subshell conflicts `#D1578` 6e4bb12 +- history: use `mapfile -d ''` to load history in Bash 5.2 `#D1603` 72c274e +- prompt: use `${PS1@P}` when the prompt contains only safe prompt sequences `#D1617` 8b5da08 + - prompt: fix not properly set `$?` in `${PS1@P}` evaluation (reported by nihilismus) `#D1644` 521aff9 + - prompt: fix a bug that the special treatment of `\$` in Cygwin/MSYS is disabled `#D1741` 4782a33 +- decode: cache `inputrc` translations `#D1652` 994e2a5 +- complete: use `awk` for batch `quote-insert` (motivated by banoris) `#D1714` a0b2ad2 92d9734 + - complete (quote-insert.batch): fix regex escaping in bracket expr of awk (reported by telometto) `#D1729` 8039b77 +- prompt: reduce redundant evaluation of `PROMPT_COMMAND` on the startup `#D1778` 042376b +- main: run `ble/base/unload` directly at the end of `EXIT` handler `#D1797` 115baec +- util: optimize `ble/util/writearray` `#D1816` 96e9bf8 +- history: optimize processing of `erasedups` (motivated by SuperSandro2000) `#D1817` 944d48e +- debug: add `ble/debug/profiler` (motivated by SuperSandro2000) `#D1824` f629698 11aa4ab 7bb10a7 + - util (`ble/string#split`): optimize `#D1826` 7bb10a7 + - global: avoid passing arbitrary strings through `awk -v var=value` `#D1827` 82232de + - edit: properly set `LINENO` for `PS1`, `PROMPT_COMMAND`, and `DEBUG` `#D1830` 4d24f84 + +## Compatibility + +- term: work around quirks of Solaris xpg4 awk `#D1481` 6ca0b8c +- term: support key sequences and control sequences of Solaris console `#D1481` 6ca0b8c +- term: work around Cygwin-console bug of bottom `IL`/`DL` `#D1482` 5dce0b8 +- term: work around leaked DA2R in screen from outside terminal `#D1485` e130619 +- complete: work around `fzf` completion settings loaded automatically `#D1508` 4fc51ae +- complete: work around `bash-completion` bugs (reported by oc1024) `#D1533` 9d4ad56 +- main: work around MSYS2 .inputrc (reported by n1kk) `#D1534` 9e786ae +- util (`modifyOtherKeys`): work around a quirk of kitty (reported by NoahGorny) `#D1549` f599525 + - util (`modifyOtherKeys`): update the workaround for a new quiark of kitty `#D1627` 3e4ecf5 + - util (`modifyOtherKeys`): use the kitty protocol for kitty 0.23+ which removes the support of `modifyOtherKeys` (reported by kovidgoyal) `#D1681` ec91574 + - util (`modifyOtherKeys`): set up `modifyOtherKeys` only after `DA2` (reported by dongxi8) `#D1885` 149eee9 +- global: work around empty `vi_imap` cache by `tmux-resurrect` `#D1562` 560160b +- decode: identify `kitty` and treat `\e[27u` as isolated ESC (reported by lyiriyah) `#D1585` c2a84a2 +- complete: suppress known error messages of `bash-completion` (reported by oc1024, Lun4m) `#D1622` d117973 +- decode: work around kitty keypad keys in modifyOtherKeys (reported by Nudin) `#D1626` 27c80f9 +- main: work around `set -B` and `set -k` `#D1628` a860769 +- term: disable `modifyOtherKeys` and do not send `DA2` for `st` (requested by Shahabaz-Bagwan) `#D1632` 92c7b26 +- cmap: add `st`-specific escape sequences for cursor keys `#D1633` acfb879 +- cmap: distinguish find/select from home/end for openSUSE `inputrc.keys` (reported by cornfeedhobo) `#D1648` c4d28f4 + - cmap: freeze the internal codes of find/select and kitty special keys `#D1674` fdfe62a +- main: work around self-modifying `PROMPT_COMMAND` by `bash-preexec` (reported by cornfeedhobo) `#D1650` 39ebf53 + - main: fix an infinite loop on `ble-reload` with externally saved `PROMPT_COMMAND` (reported by tars0x9752) `#D1851` 53af663 +- decode: work around openSUSE broken `/etc/inputrc` `#D1662` e5b0c86 +- decode: work around the overwritten builtin `set` (reported by eadmaster) `#D1680` a6b4e2c +- complete: work around the variable leaks by `virsh` completion from `libvirt` (reported by telometto) `#D1682` f985b9a +- stty: do not remove keydefs for C-u, C-v, C-w, and C-? (reported by laoshaw) `#D1683` 82f74f0 +- builtin: print usages of emulated builtins on option errors `#D1694` 6f74021 +- decode (`ble/builtin/bind`): improve compatibility of the deprecated form `bind key:rlfunc` (motivated by cmplstofB) `#D1698` b6fc4f0 + - decode (`ble/builtin/bind`): fix a bug that only lowercase is accepted for deprecated form `bind key:rlfunc` (reported by returntrip) `#D1726` a67458e e363f1b +- complete: work around a false warning messages of gawk-4.0.2 `#D1709` 9771693 +- main: work around `XDG_RUNTIME_DIR` of a different user by `su` (reported by zim0369) `#D1712` 8d37048 +- main (`ble/util/readlink`): work around non-standard or missing `readlink` (motivated by peterzky) `#D1720` a41279e + - util (`ble/function#pop`): allow popping unset function `#D1834` c0abc95 +- menu (`menu-style:desc`): work around xenl quirks for relative cursor movements (reported by telometto) `#D1728` 3e136a6 +- global: work around the arithmetic syntax error of `10#` in Bash-5.1 `#D1734` 7545ea3 +- global: adjust implementations for Bash 5.2 `patsub_replacement` `#D1738` 4590997 + - global: work around `compat42` quoting of `"${v/pat/"$rep"}"` `#D1751` a75bb25 + - prompt: fix a bug of `ble/prompt/print` redundantly quoting `$` `#D1752` a75bb25 + - global: identify bash-4.2 bug that internal quoting of `${v/%$empty/"$rep"}` remains `#D1753` a75bb25 + - global: work around `shopt -s compat42` `#D1754` a75bb25 +- global (`ble/builtin/*`): work around `set -eu` in NixOS initialization (reported by SuperSandro2000) `#D1743` 001c595 +- util, edit, contrib: add support for `bash-preexec` (motivated by SuperSandro2000) `#D1744` e85f52c + - util (`ble/builtin/trap`): fix resetting `$?` and `$_` (reported by SuperSandro2000) `#D1757` dfc6221 + - util (`ble/builtin/trap`): fix a failure of setting the trap-handler exit status (reported by SuperSandro2000) `#D1771` c513ed4 + - edit (`TRAPDEBUG`): partially restore `$_` after `DEBUG` trap (reported by aiotter) `#D1853` 0b95d5d +- main: check `IN_NIX_SHELL` to inactivate ble.sh in nix-shell (suggested by SuperSandro2000) `#D1747` b4bd955 + - main: force prompt-attach inside the nix-shell `rc` `#D1766` ceb2e7c +- canvas: test the terminal for the sequence of clearing `DECSTBM` `#D1748` 4b1601d +- main: check `/dev/tty` on startup (reported by andychu) `#D1749` 711c69f + - main: fix the check of tty on stdin/stdout `#D1833` 80f09c9 +- util: add identification of Windows Terminal `wt` `#D1758` e332dc5 +- complete: evaluate words for `noquote` (motivated by SuperSandro2000) `#D1767` 0a42299 +- edit (TRAPDEBUG): preserve original `DEBUG` trap and enabled it in `PROMPT_COMMAND` (motivated by ammarooo) `#D1772` `#D1773` ec2a67a + - main, trap: fix initialization order of `{save,restore}-BASH_REMATCH` (reported by SuperSandro2000) `#D1780` 689534d +- global: work around bash-3.0 bug that single quotes remains for `"${v-$''}"` `#D1774` 9b96578 +- util: work around old `vte` not supporting `DECSCUSR` yet setting `TERM=xterm` (reported by dongxi8) `#D1785` 70277d0 +- progcomp: work around the cobra V2 description hack (reported by SuperSandro2000) `#D1803` 71d0736 +- complete: work around blocking `_scp_remote_files` and `_dnf` (reported by iantra) `#D1807` a4a779e 46f5c13 +- history: work around broken timestamps in `HISTFILE` (reported by johnyaku) `#D1831` 5ef28eb +- progcomp: disable `command_not_found_handle` (reported by telometto, wisnoskij) `#D1834` 64d471a d5fe1d1 973ae8c +- util (`modifyOtherKeys`): work around delayed terminal identification `#D1842` 14f3c81 + - util (`modifyOtherKeys`): fix a bug that kitty protocol is never activated `#D1842` 14f3c81 +- util (`modifyOtherKeys`): pass-through kitty protocol sequences (motivated by ferdinandyb) `#D1845` f66e0c1 +- main: show warning for empty locale (movivated by Ultra980) `#D1927` 92f2006 +- main: never load `/etc/inputrc` in openSUSE (motivated by Ultra980) `#D1926` 92f2006 0ceb0cb +- canvas: refine detection of `bleopt char_width_mode=musl` `#D1929` b0c16dd +- term (`terminology`): work around terminal glitches `#D1946` 9a1b4f9 +- main (`ble/bin/awk`): add workaround for macOS `awk-32` `#D1974` e2ec89c +- util.hook: workaround bash-5.2 bug of nested read by `WINCH` `#D1981` a5b10e8 + - main (`ble/base/adjust-builtin-wrappers`): fix persistent tempenv `IFS=` in bash-5.0 (reported by pt12lol) `#D2030` 5baf6f63 +- edit: always adjust the terminal states with `bind -x` (reported by linwaytin) `#D1983` 5d14cf1 + - edit: restore `PS1` while processing `bind -x` (reported by adoyle-h) `#D2024` 2eadcd5b +- syntax: suppress brace expansions in designated array initialization in Bash 5.3 `#D1989` 1e7b884 +- progcomp: work around slow `nix` completion `#D1997` 2c1aacf +- complete: suppress error messages from `_adb` (reported by mozirilla213) `#D2005` f2aa32b0 + +## Test + +- github/workflows: add CI checks in macOS and msys2 (requested by aiotter) `##D1881` c5ddacc + - github/workflows (nightly): add check for macOS (contributed by aiotter) `#D1881` 4cb0baa + - github/workflows (nightly, test): interchange setup `#D1881` 4cb0baa + - github/workflows: add `test.yml` `#D1881` 824dc53 + - fix for macOS tests + - test (ble/util/c2s): fix locale settings in tests `#D1881` 26ed622 + - test (ble/util/msleep): loosen the condition `#D1881` 26ed622 + - test (ble/util/msleep): skip test in CI `#D1881` 26ed622 + - fix for msys2 tests + - test: ensure a non-empty locale `#D1881` c5d1b82 + - test (ble/util/readlink): work around msys symlinks `#D1881` c5d1b82 + - test (ble/util/declare-print-definitions): skip array assignments involing CR in msys `#D1881` c5d1b82 + - test (ble/util/is-stdin-ready): skip test in the CI msys `#D1881` c5d1b82 + - main (bind): suppress non-interactive warning in msys `#D1881` c5d1b82 + - canvas (GraphemeClusterBreak): handle surrogate pairs for UCS-2 `wchar_t` `#D1881` 18bf121 + - util (ble/encoding:UTF-8/b2c): fix interpretation of leading byte `#D1881` 2e1a7c1 + - util (ble/util/s2c): work around intermediate mbstate of bash <= 5.2 `#D1881` 2e1a7c1 + - util (ble/util/s2bytes): clear locale cache `#D1881` 2e1a7c1 + - complete: fix syntax error for bash-3.0 `#D1881` 0b3e611 + - github/workflows: work around grep-3.0 which crashes in windows-latest `#D1915` fb7bd0b +- test (ble/util/writearray): use `ble/file#hash` instead of `sha256sum` `#D1882` b76e21e +- test (ble/util/readlink): work around external aliases `#D1890` 0c6291f + +## Internal changes and fixes + +- main: include hostname in local runtime directory `#D1444` 6494836 +- global: update the style of document comments ff4c4e7 +- util: add function `ble/string#quote-words` `#D1451` f03b87b +- syntax (`ble/syntax:bash/simple-word/eval`): cache `#D1453` 6d8311e + - syntax (`simple-word/eval`): support `opts=single` for a better cache performance (motivated by 3ximus) `#D1464` 10caaa4 +- global: refactor `setup => set up / set-up` `#D1456` c37a9dd +- global: clean up helps of user functions `#D1459` 33c283e +- benchmark (`ble-measure`): support `-T TIME` and `-B TIME` option `#D1460` 1aa471b +- util, color (`bleopt`, `blehook`, `ble-color-setface`): support `--color` and fix `sgr0` contamination in non-color output `#D1466` 69248ff +- global: fix status check for read timeout `#D1467` e886883 +- decode: move `{keymap/*. => lib/core-decode.*-}rlfunc.txt` and clean up files `#D1486` f7323b4 + - Makefile: fix up f7323b4: restore rule for `keymap/*.txt` `#D1496` 054e5c1 +- util, etc: ensure each function to work with arbitrary `IFS` `#D1490` `#D1491` 5f9adfe +- tui, canvas (`ble/canvas/trace`): support `opts=clip` `#D1493` 61ce90c +- tui, edit: add a new render mode for full-screen applications 817889d +- test (`test-canvas`): fix dependency on `ext/contra` `#D1525` c89aa23 +- util: inherit special file descriptors `#D1552` 98835b5 + - util: fix a bug that old tty is used in new sessions `#D1586` 0e55b8e +- global: use `_ble_term_IFS` `#D1557` d23ad3c +- global: work around `localvar_inherit` for varname-list init `#D1566` 5c2edfc +- util: fix `ble/util/dense-array#fill-range` a46fdaf +- util: fix leak variables `buff`, `trap`, `{x,y}{1,2}` `#D1572` 5967d6c +- util: fix leak variables `#D1643` fcf634b +- edit (`command-help`): use `ble/util/assign/.mktmp` to determine the temporary filename `#D1663` 1af0800 +- make: update lint check `#D1709` 7e26dcd +- test: save the test log to a file `#D1735` d8e6ea7 +- benchmark: improve determination of the base time `#D1737` ad866c1 +- make: add fallback Makefile for BSD make `#D1805` e5d8d00c +- main: support `bleopt debug_xtrace` (requested by SuperSandro2000) `#D1810` 022d38b +- test: clean up check failures by `make check` and `make scan` `#D1812` bb3e0a3 +- util (`fd#alloc`): limit the search range of free fds `#D1813` 43be0e4 4c90072 +- github/workflows: define an action for the nightly builds (contributed by uyha) `#D1814` a3082a0 +- global: quote numbers for unexpected `IFS` `#D1835` 0179afc +- history: refactor hooks `history_{{delete,clear,insert} => change}` `#D1860` c393c93 +- history: rename the hook `history_{on => }leave` `#D1860` c393c93 +- make: check necessary `.git` `#D1887` 0f7c04b +- benchmark (zsh): fix for `KSH_ARRAYS` `#D1886` a144ffa 8cb9b84 +- benchmark: support for ksh as `benchmark.ksh` `#D1886` 5dae4da +- github/workflows (build): rename directory in `ble-nightly.tar.xz` to `ble-nightly` (reported by Harduex) `#D1891` f20854f 4ea2e23 43c6d4b +- edit: update prompts on g2sgr change `#D1906` 40625ac +- util, decode, vi: fix leak variables `#D1933` 8d5cab8 +- util: support `bleopt debug_idle` `#D1945` fa10184 +- global: work around bash-4.4 no-argument return in trap `#D1970` eb4ffce +- util: replace builtin `readonly` with a shell function (requested by mozirilla213) `#D1985` 8683c84 e4758db + - util (`ble/builtin/readonly`): show file and line in warnings `#D2015` 467fa448 2c9b56d7 +- global: avoid directly using `/dev/tty` `#D1986` a835b83 +- util: add `ble/util/message` `#D2001` 2a524f34 +- global: normalize bracket expressions to `_a-zA-Z` / `_a-zA-Z0-9` `#D2006` 41faa494 +- global: fix leak variables `#D2018` 6f5604de +- edit: handle nested WINCH properly `#D2020` a6b2c078 +- make: include the source filenames in the installed files (suggested by bkerin) `#D2027` 610fab39 + +## Contrib + +- prompt-git: detect staged changes `#D1718` 2b48e31 +- prompt-git: fix a bug that information is not updated on reload `#D1732` 361e9c5 +- config/execmark: show exit status in a separate line `#D1828` 4d24f84 + - config/execmark: add names of exit statuses `#D2019` a6b2c078 +- prompt-git: ignore untracked files in submodules `#D1829` 4d24f84 +- integration/fzf + - fzf-completion: fix integration (reported by ferdinandyb) `#D1837` 12c022b + - fzf-completion: remove `noquote` (reported by MK-Alias) `#D1889` 0c6291f + - fzf-initialize: check directory existence before adding it to `PATH` (reported by Strykar) `#D1904` 09bb4d3 + - fzf-key-bindings: fix a problem that `modifyOtherKeys` is not reflected (reported by SuperSandro2000) `#D1908` 486564a + - fzf-completion: quote only with `filenames` when `ble/syntax-raw` is specified (reported by christianknauer) `#D1978` 8965b61 +- integration/zoxide + - complete, contrib: add completion integration with `zoxide` (reported by ferdinandyb) `#D1838` a96bafe + - zoxide: update `contrib/integration/zoxide` for zoxide v0.8.1 `#D1907` 3bc3bea + - zoxide: adjust `zoxide icanon` (reported by linwaytin) `#D1993` dc7de6b +- README: update description on `_ble_contrib_fzf_base` (reported by Strykar) `#D1904` 09bb4d3 +- colorglass: add color filter `#D1902` 88e74cc + - colorglass: add `bleopt colorglass_{saturation,brightness}` (motivated by auwsom) `#D1906` 40625ac +- add `histdb` `#D1925` 44d9e10 + - histdb: support auto-complete source `histdb-word` `#D1938` 00cae74 + - histdb: automatically upgrade histdb version `#D1940` 4fac1e3 + - histdb: support auto-complete source `histdb-history` `#D1941` 4fac1e3 + - histdb: handle multiple exec lines for `histdb_ignore` `#D1942` 36e1c89 + - histdb: kill orphan `sqlite3` processes `#D1943` 36e1c89 + - histdb: back up the database `#D1944` 36e1c89 + - histdb: fix miscellaneous SQL query errors `#D1947` 46ac426 + - histdb: output error messages to tty `#D1952` 651c70c + - histdb: fix remaining debug function name "assign{2 => }" in bash <= 3.2 `#D1953` 651c70c + - histdb: fix a problem that the background process fails to start in bash-3.0 `#D1956` 651c70c + - histdb: fix a bug that history search fails with a single quote in the commandline `#D1957` 651c70c + - histdb: fix `histdb-word` completions in the middle of the commandline `#D1968` adaec05 + - histdb: support `bleopt histdb_remarks` `#D1968` adaec05 + - histdb: support timeout of background processes `#D1971` e0566bd + - histdb: enable database timeout for transactions `#D1982` a5b10e8 + - histdb: fix `.timeout` not set for background `sqlite3` `#D1982` 20b42fa + - histdb: suppress color codes in the default `histdb_remarks` `#D1968` 20b42fa + - histdb: disable timeout of background processes in Bash 3.2 `#D1992` 20b42fa + - histdb: rewrite to use `ble/util/bgproc` `#D2017` 7803305f +- integration: move `fzf` and `bash-preexec` integrations to subdir `#D1939` 86d9467 + + +# ble-0.4.0-devel2 + +2020-01-12 -- 2020-12-02 (`#D1215`...`#D1426`) c74abc5...276baf2 + +## New features + +- complete: support `bleopt complete_auto_wordbreaks` (suggestion by dylankb) `#D1219` c294e31 +- main: check `~/.config/blesh/init.sh` `#D1224` a82f961 +- progcolor: support programmable highlighting `#D1218` 0770234 `#D1244` 9cb3583 `#D1245` 8e8a296 `#D1247` 154f638 `#D1269` fa0036c +- decode/kbd: support U+XXXX, @ESC and @NUL for keynames `#D1251` 441117c ef23ad1 +- syntax: support `coproc` `#D1252` 7ff68d2 +- vi/nmap: support readline widgets for M-left, M-right, C-delete, # and & `#D1258` 846e0be +- complete: add `compopt -o quote/default` for `fzf` (motivated by dylankb) `#D1275` 58e1be4 +- util (`ble-import`): support an option `-d` (`--delay`) `#D1285` 9673e4e +- syntax: support parameter expansion of the form `${var/#pat}`, `${var/%pat}` `#D1286` e2f4809 +- edit: support `bleopt editor line_limit_{type,length} history_limit_length` `#D1295` 2f9a000 +- edit: support widgets `{vi,emacs}-editing-mode` `#D1301` 0c6c76e +- syntax: allow unquoted `[!` and `[^` in `simple-word` (reported by cmplstofB) `#D1303` 1efe833 +- util (`ble/util/print-global-definitions`): support arrays and unset variables (test-util) 6e85f1c +- util (`ble/util/cat`): support NUL and multiple files (test-util) d19a9af +- edit: support Bash 5.1 `READLINE_MARK` and `PROMPT_COMMANDS` `#D1328` e97a858 `#D1338` 657bea5 + - edit, main: support array PROMPT_COMMAND in bash-5.1 `#D1380` b852a4f +- syntax: support confusing parameter expansions like `${#@}`, etc. `#D1330` b7b42eb +- contrib: add contrib for user settings `#D1335` f290115 +- syntax: support `${var@UuLK}` in Bash 5.1 `#D1336` 04da4dd +- main: add an option `--test` `#D1340` 1410c72 +- util (`ble/builtin/trap`): support `return` in `INT`/`EXIT`/`WINCH` `#D1347` `#D1348` 3865488 +- history: support timestamp (reported by rux616) `#D1351` 4bcbd71 `#D1356` 350bb15 `#D1364` 1d8adf9 +- edit: support Bash 4.4 `PS0` `#D1357` 23a1ac5 +- vi: support `bleopt keymap_vi_mode_{update_prompt,show,name_*}` (suggested by Dave-Elec) `#D1365` 76be6f1 +- prompt: support prompt sequence `\q{...}` `#D1365` 76be6f1 +- edit: support `bind 'set show-mode-in-prompt'` `#D1365` 76be6f1 + - prompt: fix a bug that mode string is not shown in `auto_complete` and other sub-modes (reported by tigger04) `#D1371` f6fc7ff + - prompt: redraw prompts on the prompt content change (reported by tigger04) `#D1371` 1954a1e +- prompt: support `bleopt prompt_{{ps1,rps1}{_final,_transient}}` (suggested by Dave-Elec) `#D1366` 06381c9 + - prompt: fix a bug that prompt are always re-insntiated for every rendering `#D1374` 0770cda + - prompt: fix a bug that rprompt is not cleared when `bleopt prompt_rps1` is reset `#D1377` 1904b1d + - prompt: fix a bug that prompts updated by `PROMPT_COMMAND` are not reflected immediately (reported by 3ximus) `#D1426` bbda197 +- edit: support Bash 5.1 widgets `#D1368` e747ee3 +- color: support `TERM=*-direct` `#D1369` 0d38897 `#D1370` f7dc477 +- complete: support `bleopt complete_auto_menu` `#D1373` 77bfabd + - complete: fix a problem of frequent bells with auto-menu activated `#D1381` 3b1d8ac +- complete: support `bleopt complete_menu_maxlines` `#D1375` 8e81cd7 +- prompt: support `_ble_prompt_update` `#D1376` 0fa8739 +- prompt: support `bleopt prompt_{xterm_title,screen_title,status_line}` `#D1378` 5c3f6fe + - prompt: check `TERM` for prompt window titles when `_ble_term_TERM` is unavailable `#D1388` 3c88869 +- syntax: support options `bleopt highlight_{syntax,filename,vartype}` to turn off highlighting (requested by pjmp) `#D1379` 0116f8b +- complete: support `shopt progcomp_alias` `#D1397` d68afa5 +- complete: generate completions of options based on man pages `#D1405` 8183455 + - complete (mandb): fix a bug that `bleopt complete_menu_style` is globally changed `#D1412` b91fd10 +- highlight: support colon separated lists of paths `#D1409` 2f40422 + - highlight: fix a bug that non-simple words are always highlighted as `syntax_error` (reported by cmplstofB) `#D1411` 46e2ac6 + - highlight: fix a bug that words are sometimes unhighlighted `#D1418` 4395484 + - highlight: fix a bug that non-existent directories are not highlighted in the command name context `#D1419` 4395484 +- highlight: support options `#D1410` 2f40422 + - highlight: support highlighting of `declare` command options `#D1420` f0df481 + - highlight: fix unhighlighted tilde expansions `~+` (reported by cmplstofB) `#D1424` a32962e + +## Changes + +- highlight: highlight symlink directories as symlinks `#D1249` 25e8a72 +- auto-complete: bind `insert-on-end` to `C-e` `#D1250` 90b45eb +- edit (`widget/shell-expand-line`): not quote expanded results by default `#D1255` a9b7810 +- decode: refactor + - decode: delay bind until keymap initialization `#D1258` 0beac33 + - decode: read user settings from `bind -Xsp` `#D1259` eef14d0 + - decode: fix a bug of `ble-bind` with uninitialized cmap `#D1260` 5d98210 + - decode: fix error messages of BSD `sed` rejecting unencoded bytes from `bind -p` (reported by dylankb) `#D1277` 0cc9160 +- edit: provide proper `$BASH_COMMAND` and `$_` for PS1, PROMPT_COMMAND, PRECMD, etc. `#D1276` 7db48dc +- edit (quoted-insert): insert literal key sequence `#D1291` 420c933 +- decode: support `decode_abort_char` for `modifyOtherKeys` `#D1293` ad98416 +- edit (edit-and-execute): disable highlighting of old command line content `#D1295` 2f9a000 +- util (`bleopt`): fail when a specified bleopt variable does not exist (test-util) 5966f22 +- builtin: let redefined builtins return 2 for `--help` `#D1323` 731896c +- edit: preserve `PS1` when `internal_suppress_bash_output` is set `#D1344` 6ede0c7 +- complete: complete param expan in additional contexts `#D1358` 3683305 +- main: reload on ble-update when ble.sh is already updated `#D1359` a441d4d +- main (`ble-update`): clone github repository if the original repository is not found `#D1363` 6e3b3b5 +- util (bleopt): change output format d4b12cd +- syntax: allow `time -- command` for Bash 5.1 `#D1367` 00d0e93 +- menu: preserve columns with `{forward,backward}-line` `#D1396` 3d5a341 +- syntax: rename `ble_debug` to `bleopt syntax_debug` `#D1398` 3cda58b +- syntax: change a style of buffer contents in `bleopt syntax_debug` `#D1399` 3cda58b +- complete: change to generate filenames starting from `.` by default (motivated by cmplstofB) `#D1425` 987436d + +## Fix + +- util (ble/builtin/trap): fix argument analysis for the form `trap INT` (reported by dylankb) `#D1221` db8b0c2 +- main: fix an error message on ristricted shells `#D1220` b726225 +- edit: fix a bug that the shell hangs with `source ble.sh --noattach && ble-attach` (reported by dylankb) `#D1223` 59c1ce4 3031007 +- edit: fix a bug that the textarea state is not properly saved (reported by cmplstofB) `#D1227` 06ae2b1 +- syntax: support hexadecimal literals for arithmetic expression (reported by cmplstofB) `#D1228` 90e4f35 +- history: fix a bug that history append does not work with `set -C` (reported by cmplstofB) `#D1229` 604bb8b +- decode (`ble/builtin/bind`): fix widget mapping for `default_keymap=safe` `#D1234` 750a9f5 +- main (ble-update): fix a bug that the check of `make` does not work in Bash 3.2 `#D1236` 08ced81 +- syntax: fix a infinite loop for variable assignments and parameter expansions `#D1239` 327661f +- complete: clear menu on history move `#D1248` 06cc7de +- syntax: fix a bug that arguments of `eval` are not highlighted `#D1254` 5046d14 +- decode: fix error message `command=${[key]-}` for mouse input `#D1263` 09bb274 +- [ble-0.3] reload: fix a bug that the state is broken by `ble-reload` `#D1266` f2f30d1 +- decode (`ble/builtin/bind`): remove comment from bind argument `#D1267` 880bb2c +- decode: use `BRE` instead of `ERE` for `POSIX sed` (reported by dylankb) `#D1283` 2184739 +- decode: fix strange behaviors after `fzf` (convert DEL to C-?) `#D1281` 744c8e8 +- edit: work around Bash rebinding on `TERM` change `#D1287` ac7ab55 7a99bf3 +- term: work around terminfo/termcap entry collisions in `tput` (reported by killermoehre) `#D1289` f8c54ef +- complete: clear menu on discard-line (reported by animecyc) `#D1290` fb794b3 `#D1315` 99880ef +- vi (vi-command/nth-column): fix a bug in arithmetic expansion (reported by andychu) `#D1292` da6cc47 +- complete: fix a bug that insert-word does not for with ambiguous candidates `#D1295` 2f9a000 +- complete: fix a bug that menu-filter is only partially turned off by `complete_menu_filter` `#D1298` b3654e2 +- decode: fix error messages for unsupported readline functions `#D1301` 91bdb64 +- global: work around `shopt -s assoc_expand_once` `#D1305` 31908e1 +- global: work around `TMOUT` for `builtin read` `#D1306` 1c22a9d +- syntax: fix failglob errors of heredocs of the form `<<$(echo A)` `#D1308` 3212fd2 +- decode (`ble-bind`): fix an error message `#D1311` c868b6d +- util (`bleopt`): fix a bug that a new setting is not defined with `name:=` (test-util) `#D1312` c757b92 +- util (`ble/util/{save,restore}-vars`): fix a bug that `name` and `prefix` cannot be saved/restored (test-util) 5f2480c +- util: fix `ble/is-{inttype,readonly,transformed}` (test-util) 485e1ac +- util (`ble/path#remove{,-glob}`): fix corner cases (test-util) ccbc9f8 +- history: fix a problem that the history is doubled by `history -a` in `bashrc` `#D1314` 34821fe +- util (`ble/variable#get-attr`): fix an error message with special variable names such as `?` and `*` `#D1321` 557b774 +- util (has-glob-pattern): fix abort in subshells (test-util) `#D1326` dc292a2 +- edit: fix a bug that `set +H` is cancelled on command execution `#D1332` 02bdf4e +- syntax (`ble/syntax/parse/shift`): fix a bug of shift skip in nested words `#D1333` 65fbba0 +- global: work around Bash-4.4 `return` in trap handlers `#D1334` aa09d15 +- util (`ble-stackdump`): fix a shift of line numbers `#D1337` a14b72f d785b64 +- edit (`ble-bind -x`): check range of `READLINE_{POINT,MARK}` `#D1339` efe1e81 +- main: fix a bug that `~/.config/blesh/init.sh` is not detected (GitHub #53 by rux616) 61f9e10 +- util (`ble/string#to{upper,lower}`): work around `LC_COLLATE=en_US.utf8` (test-util) `#D1341` 1f6b44e `#D1355` 4da6103 5f0d49f +- util (encoding, keyseq): fix miscelleneous encoding bugs (test-util) 435bd16 + - `ble/util/c2keyseq`: work around bash ambiguous keyseq `\M-\C-\\` + - `ble/util/c2keyseq`: fix a bug that `C1` characters are not properly encoded + - `ble/util/keyseq2chars`: fix a bug that `\xHH` is not properly processed + - `ble/encoding:UTF-8/b2c`: work around Bash-4.2 arithmetic crash + - `ble/encoding:UTF-8/b2c`: fix a bug that `G0` characters lose its seventh bit + - `ble/encoding:UTF-8/c2b`: fix a bug that the first byte gets redundant bits +- edit: work around `WINCH` not updating `COLUMNS`/`LINES` after `ble-reload` `#D1345` a190455 +- complete: initialize `bleopt complete_menu_style` options before `complete_load` hook (reported by rux616) `#D1352` 8a9a386 +- main: fix problems caused by multiple `source ble.sh` in bashrc `#D1354` 5476933 +- syntax: allow single-character variable name in named redirections `{a}<>` `#D1360` 4760409 +- complete: quote `#` and `~` at the beginning of word `#D1362` f62fe54 +- decode (`bind`): work around `shopt -s nocasematch` (reported by tigger04) `#D1372` 855cacf +- syntax (tree-enumerate): fix unmodified `wtype` of reconstructed words at the end `#D1385` 98576c7 +- complete: fix a bug that progcomp retry by 124 caused the default completion again `#D1386` 98576c7 +- complete: fix bugs that quotation disappears on ambiguous completion `#D1387` 98576c7 +- complete: fix a bug of duplicated completions of filenames with spaces `#D1390` 98576c7 +- complete: fix superlinear performace of ambiguous matching globpat `#D1389` 71afaba +- prompt: fix extra spaces on line folding before double width character `#D1400` d84bcd8 +- prompt: fix a bug that lonig rps1 is not correctly turned off `#D1401` d84bcd8 +- syntax (glob bracket expression): fix a bug of unsupported POSIX brackets `#D1402` 6fd9e22 +- syntax (`ble/syntax:bash/simple-word/evaluate-path-spec`): fix a bug of unrecognized `[!...]` and `[^...]` `#D1403` 0b842f5 +- complete (`cd`): fix duplicate candidates by `CDPATH` (reported by Lennart00 at `oh-my-bash`) `#D1415` 5777d7f +- complete (`source:file`): fix a bug that tilde expansion candidates are always filtered out `#D1416` 5777d7f +- complete: fix a problem of redundant unmatched ambiguous part with tilde expansions in the common prefix `#D1417` 5777d7f +- highlight: fix remaininig highlighting of vanishing words `#D1421` `#D1422` 1066653 +- complete: fix a problem that the user setting `dotglob` is changed `#D1425` 987436d + +## Compatibility + +- main: work around cygwin uninitialized environment `#D1225` `#D1226` b9278bc +- global: work around Bash 3.2 bug of array initialization with SOH/DEL `#D1238` defdbd4 `#D1241` 1720ec0 +- term: support `TERM=minix` `#D1262` ae0b80f +- msys2: support2 MSYS (motivated by SUCHMOKUO) `#D1264` 47e2863 + - edit: support `\$` in `PS1` for MSYS2 `#D1265` f6f8956 + - msys2: work around MSYS2 Bash bug of missing CR `#D1270` 71f3498 + - cygwin, msys2: support widget `paste-from-clipboard` `#D1271` cd26c65 +- msys1: support MSYS1 `#D1272` 630d659 + - msys1: work around missing named pipes in MSYS1 `#D1273` 6f6c2e5 +- term: support contra `SPD` `#D1288` 1e65f2c +- decode: work around Bash-4.1 bug that locale not applied with `LC_CTYPE=C eval command` (test-util) b2c7d1c +- util (`ble/variable#get-attr`): fix a bug that attributes are not obtained in Bash <= 4.3 (test-util) b2c7d1c +- decode: work around Bash-3.1 bug of `declare -f` rejecting special characters in function names (test-util) b2c7d1c +- edit (`ble/widget/bracketed-paste`): fix error messages on `paste_end` in older version of Bash (test-util) b2c7d1c +- decode: work around Bash-4.1 arithmetic bug of array subscripts evaluated in discarded branches `#D1320` 557b774 +- complete: follow Bash-5.1 change of arithmetic literal `10#` `#D1322` 557b774 +- decode: fix a bug of broken cmap cache found in ble-0.3 `#D1327` 16b56bf +- util (strftime): fix a bug not working with `-v var` option in Bash <= 4.1 (test-util) f1a2818 +- complete: work around slow `compgen -c` in Cygwin `#D1329` 5327f5d +- edit: work around problems with `mc` (reported by onelittlehope) `#D1392` e97aa07 + - highlight: fix a problem that the attribute of the last character is applied till EOL `#D1393` 2ddb1ba `#D1395` ef09932 + +## Internal changes and fixes + +- util: merge `ble/util/{save,restore}-{arrs => vars}` `#D1217` 6acb9a3 +- internal: merge subdir `test` into `memo` `#D1230` f0c38b6 +- ble-measure: improve calibration `DD1231` d3a7a52 +- vi_test: fix a bug that test fails to restore the original state `#D1232` 4b882fb +- decode (ble/builtin/bind): skip checking stdin in parsing the keyseq `#D1235` 5f949e8 +- syntax: delay load of `ble/syntax/parse` for syntax highlighting `#D1237` bb31b11 +- memo: split `memo.txt` -> `note.txt`, `done.txt` and `ChangeLog.md` `#D1243` 31bc9aa 8b0fe34 419155e +- global: check isolated identifiers and leak variables `#D1246` 19cc99d 2e74b6d +- util: add `ble/function#{advice,push,pop}` to patch functions (motivated by dylankb) `#D1275` fbe531a +- util (`ble/util/stackdump`): output to `stdout` instead of `stderr` `#D1279` 9d3c50d +- complete (`ble-sabbrev`): delay initialization `#D1282` dfc4f66 +- test: update `lib/test-{core => util}.sh` (reported by andychu) `#D1294` e835b0d +- edit: improve performance of bracketed-paste `#D1296` 0a45596 `#D1300` 3f33dab `#D1302` 5ee06c8 10ad274 +- decode: improve performance of `ble-decode-char` `#D1297` 0d9d867 +- ext: update `mwg_pp.awk` (for branch osh) 978ea32 +- test: add `lib/core-test.sh` `#D1309` 68f8077 +- global: do not use `local -i` `#D1310` f9f0f9b +- global: normalize calls of builtins `#D1313` b3b06f7 +- test: refactor test `#D1316` `#D1317` 6c2f863 +- util (`ble/util/openat`): change to open unused fds `#D1318` 6c2f863 +- util: rename `ble/{util/openat => fd#alloc}` `#D1319` 6c2f863 +- util (`ble/function#advice remove`): restore original command 149a640 +- edit: rename `ble-edit/prompt/*` -> `ble/prompt/*` `#D1365` 76be6f1 +- main: use `PROMPT_COMMAND` in bash-5.1 for prompt attach `#D1380` b852a4f +- main: unset `BLE_VERSION`, `_ble_bash`, etc. on `ble-unload` `#D1382` 6b615b6 +- util: revisit `ble/variable#is-global` implementation `#D1383` 6b5468f +- cmap: recognize SS3 O as blur `#D1384` 445a5ad +- edit (`ble/widget/{accept-line,newline}`): automatically switch widgets by the keymap `#D1391` 5bed6e6 +- complete: perform filter in `ble/complete/cand/yield` `#D1404` 7c6b67b 83fa830 + - complete: fix a bug that `ble/cmdinfo/complete:cd` candidates are unfiltered (reported by cmplstofB) `#D1413` 5c17a31 + - complete: fix unfiltered tilde expansions `#D1414` 5777d7f + - complete: fix candidate filter failure in dynamic sabbrev expansion (reported by darrSonik) `#D1423` dabc515 +- syntax, edit: use `type -a -t -- cmd` to get command types hidden by keywords `#D1406` ef2d912 +- edit, complete: replace some external commands with Bash builtin `#D1407` 5386e93 + + +# ble-0.4.0-devel1 + +2019-03-21 -- 2020-01-12 (#D1015...#D1215) df4feaa...c74abc5 + +## New features + +- emacs: support widgets `forward-byte` and `backward-byte` `#D1017` b2951ef +- emacs: support arguments of word wise operations `#D1020` 719092c +- emacs: support widgets `{capitalize,downcase,upcase}-xword` `#D1019` 719092c +- emacs: support widgets `alias-expand-line` and `history-and-alias-expand-line` `#D1024` fdaf579 +- emacs: support keyboard macros `#D1028` 284668a + - decode: workaround recursive charlog/keylog `#D1030` ea421a3 +- complete: define `menu` keymap `#D1033` abfd060 +- emacs: support widgets `kill{,-graphical,-logical}-line` `#D1037` 3bb3d33 +- emacs: support a widget `re-read-init-file` `#D1038` ebe2928 +- emacs: support widgets `readline-dump-{functions,macros,variables}` `#D1039` 49256a9 +- emacs: support widgets `character-search-{for,back}ward` and `delete-forward-char-or-list` `#D1040` 2b20c88 +- emacs: support widgets `insert-comment` and `do-lowercase-version` `#D1041` 7aae37b +- main: support options `--version` and `--help` `#D1042` b5ab789 +- main: read `.inputrc` as `ble.sh` settings `#D1042` b5ab789 + - decode: fix a bug of error messages on reading `.inputrc` `#D1062` e163b9a +- complete: support widget `menu-complete insert_braces` `#D1043` 3d29c8d + - complete (insert_braces): reimplement range contraction `#D1044` dc586da + - complete (insert_braces): remove empty quotations `#D1045` `#D1046` dc586da + - complete (insert_braces): fix support of replacement of existing part `#D1047` dc586da +- complete: support `complete context=dynamic-history` `#D1048` 4f7b284 +- emacs: support a widget `edit-and-execute-command` `#D1050` ca5fe08 +- emacs: support widgets `insert-{last,nth}-argument` `#D1051` 24458be +- complete: support `menu-complete backward` `#D1052` 2b0c7e8 +- emacs: `history-nsearch-{for,back}ward-again` `#D1053` 60dde2c +- emacs: support widgets `tab-insert`, `tilde-expand` and `shell-expand-line` `#D1054` 156b76e +- emacs: support a widget `transpose-{c,u,s,f,e}words` `#D1055` d72c2d4 +- emacs: support `bleopt decode_error_cseq_{abell,vbell,discard}` `#D1056` ab1b8b0 + - decode: fix a bug that cmap cache update is not triggered for `#D1073` f1e7674 +- emacs: support a widget `universal-arg` `#D1057` 8b1dd07 +- emacs: support kill ring and a widget `yank-pop` `#D1059` 8c9b6e8 +- highlight: support job names by `auto_resume` `#D1065` ce46024 +- decode: add support for `S8C1T` key sequences `#D1083` 9b7939b +- history: support `bleopt history_share` `#D1100` `#D1099` 305b89f `#D1193` 4838a46 +- history: support full multiline history `#D1120` 8cf17f7 + - history: do not synchronize multiline resolution on "history -p" `#D1121` 9e56b7b + - history.mlfix: suppress errors on Bash 3 `#D1122` 4fe7a0c + - history: suppress error messages trying to kill background worker on reattach `#D1125` f045fec +- highlight: support dirname colors with pathname expansion, failglob and command names `#D1134` edaf495 +- util: introduce `blehook` `#D1139` d1a78fb + - blehook: support `blehook PRECMD PREEXEC POSTEXEC CHPWD ADDHISTORY` `#D1142` bedc2ba + - blehook: add `blehook/eval-after-load` `#D1145` c1f7aa9 + - blehook: fix a bug that the definition of specified hooks are not printed `#D1146` a4a7cbc +- highlight: highlight word with the form of URL `#D1150` f48f2d7 +- syntax: support syntax/globpat in param expansions `#D1157` `#D1158` 051222e `#D1160` 57b42ba + - syntax: fix attr of nested extglob in param expansions `#D1159` 2d019f0 +- decode: support `ble-bind -T kspecs timeout` for timeout and `lib/vim-arpeggio.sh` (request by divramod) `#D1174` 272344e +- complete: use `WORD*` pathname expansion for candidates on failglob with `WORD` `#D1177` c1b0532 +- edit: support `bleopt accept_line_threshold` `#D1178` a3385f6 82a1e0b +- complete: support `bleopt complete_allow_reduction` `#D1181` 03040b7 +- edit: support `bleopt exec_errexit_mark` `#D1182` 6adc2df +- color: support true colors `#D1184` bd631ce 5dd6b03 +- color (`ble-color-setface`): support reference to another face (reported by cmplstofB) `#D1188` 1885b54 `#D1206` 7e31ad3 +- edit: support `shopt -u promptvars` `#D1189` 269ba09 +- highlight: highlight variable names and numbers according to its state `#D1210` `#D1211` 93dab7b +- highlight: support `${var@op}` (for bash 4.4) `#D1212` a85bdb8 + +## Changes + +- edit: erase in page on `SIGWINCH` `#D1016` 7625ebe +- edit: the widgets `{kill,copy,delete}-region-or` now receives widgets as arguments `#D1021` bbbd155 +- edit: disable aliases for builtins and keywords `#D1023` 61da093 +- edit: disable `rps1` in secondary textareas `#D1027` b86709a +- edit: support `$?` in `PROMPT_COMMAND` and `PS1` evaluation `#D1074` 43f2967 +- main: change default attach strategy to `--attach=prompt` `#D1076` 197f752 +- main: change exit status of `ble-update` when it is already up to date `#D1081` d94f691 +- progcomp: improve treatment of `COMP_WORDBREAKS` `#D1094` f6740b5 `#D1098` 6c6bae5 +- history: replace builtin `history` `#D1101` 655d73e + - history: synchronize undo/mark/dirty data with history changes `#D1102` `#D1103` `#D1104` 5367360 + - history: improve performance of `history -r` `#D1105` `#D1106` f204bc7 + - history: fix a problem that history file is doubled with `history -cr` in `PROMPT_COMMAND` `#D1110` e64edb7 + - history: suppress errors on new history file `#D1111` e64edb7 `#D1113` 91f07b6 + - history: fix a problem that `_ble_edit_history` is not synchronized with `history -r` `#D1112` e64edb7 + - history: do not process `_ble_edit_history` in detached state `#D1115` bf3b014 + - history: move history item on delete of current item with `history -d` `#D1114` bf3b014 + - history: fix a problem that history before load of ble.sh is lost `#D1126` 37cd154 + - history: fix problems of history output after `ble-reload` `#D1129` 9c8d858 +- history: improve performance of `erasedups` `#D1107` 518e2ee +- history: correctly handle `HISTSIZE` overflow `#D1108` 7be255c +- sabbrev: support sabbrev expansion in wider contexts (reported by cmplstofB) `#D1117` ca6e03d +- main: change loading point of `.inputrc` `#D1127` af758e5 +- highlight: do not split command names with `:` and `=` `#D1133` 8a1bd8f +- decode: support DA1 responses sent by some terminals (reported by miba072) `#D1135` 362ab05 +- highlight: make brace expansions active for RHS of variable-assignment-form arguments `#D1138` 93cc8da +- main: adjust readline variables for `ble.sh` `#D1148` 36312f7 +- edit: update prompt after execution of command through `ble-bind` `#D1151` 27208ea +- blehook: replace builtin `trap` `#D1152` d6c555e 7d4fd03 + - blehook: suppress extra `DEBUG` trap calls `#D1155` 25c3e19 +- syntax: allow `},fi,done,esac,then,...` after subshell `()` `#D1165` fdb49f3 +- edit: support options `--help` for `read` and `exit` `#D1173` faccc6b +- color (`ble-color-{set,def}face`): list faces without arguments `#D1180` 50327c3 +- complete: search completion settings through alias expansion `#D1187` c472809 +- history (`ble/builtin/history`): support an option `--help` `#D1192` d4c26c5 + +## Fixes + +- decode: workaround Poderosa that returns `DSR` instead of `CPR` in reply to `DSR(6)` `#D1018` 8e22c17 +- isearch: fix a bug to match with the old content of the current line `#D1025` 605dcd0 +- vi: fix a bug that quoted-insert is not properly recorded with `qx...q` `#D1026` 06698a4 +- decode: fix a bug that chars from nested widgets are not processed immediately `#D1028` c79d89b +- menu: fix a bug that fails to retrieve menu item description `#D1031` c936db8 +- menu: fix a bug that menu item color is disabled `#D1032` c936db8 +- vbell: fix a bug that persistent vbell is not erased before next vbell `#D1034` a3af6c0 +- menu-complete: fix a bug that candidates from menu only contained visible ones `#D1036` 275779f +- menu-complete: fix a bug that original texts were lost on cancel `#D1049` 3bbfef6 +- edit: fix a bug that rendering is caused twice `#D1053` c7599a2 +- color (layer:region): fix a bug that highlighting is cleared without dirty ranges `#D1053` 23796bc +- edit (nsearch): fix a bug that the search range is narrowed after fail `#D1053` 3b2237e +- edit (nsearch): fix a bug of messages on search fail `#D1053` 3b2237e +- util: fix a bug that SGR of visible-bell remains 799f6d3 +- decode: fix a bug of infinite loops on `ble-reload` `#D1077` 0f01bcf `#D1079` fee22b1 +- decode: workaround a bash-5.0 bug of `bind -p` `#D1078` b52da28 +- complete: workaround slow command candidates generation in Cygwin `#D1080` 376bfe7 +- syntax: fix false error highlighting of commands after `}`, `fi`, `done` or `esac` `#D1082` 4ce2753 +- decode: fix a bug that modifyOtherKeys did not work at all 1666ec2 +- edit: fix a problem that status line vanishes on window resize `#D1085` 467b7a4 + - edit: recalculate prompts after resize `#D1088` b29f248 + - edit: fix the position of cursor after resize `#D1089` b29f248 +- decode: fix a bug that `ble-update` breaks keymap cache `#D1086` ab8dad2 +- edit (`ble/builtin/read`): suppress noisy job messages and delay caused by vbell `#D1087` 309b9e4 +- edit (`ble/builtin/read`): workaround failglob crash on vbell inside `read` `#D1090` 2e6f44c +- edit: workaround a bash bug that history entries are removed by `history -p` `#D1091` 146f9e7 +- edit (self-insert): workaround Bash-3.0 bug that ^? cannot be handled properly `#D1093` e09c7b5 +- highlight: fix a bug that quoted tilde expansions are processed for filename highlighting `#D1095` 3f1f472 +- menu-complete: fix a bug that word is expanded on cancel `#D1097` 001b914 +- highlight: fix a problem that empty arguments are highlighted as errors `#D1116` 64ae8ce +- sabbrev: fix a bug that menu-filter is not canceled on some sabbrev expansion `#D1118` 30cc31c +- main: fix a bug that `source ble.sh --noattach` in `ble.sh` sessions hangs `#D1130` d35682a caa46c2 `#D1199` +- syntax: workaround bashbug 3.1/3.2 that `eval` ending with \ + LF causes error messages `#D1132` a4b7e00 +- term: workaround `cygwin` console glitches `#D1143` b79c35f `#D1144` ef19d17 +- main: fix a bug that error messages for unsupported shells are not printed `#D1149` 34bd6f8 +- main: workaround `set -ex` `#D1153` 06ebf9f +- main: workaround shell variable `FUNCNEST` `#D1154` fa2aa47 +- highlight: fix error messages on the command line `a=[` `#D1156` b159ea2 +- util: fix a bug of "ble/builtin/trap" not recognizing "-" `#D1161` 11fddba +- init-bind: workaround a bash-5.0 bug that `bind '"\C-\\": ...'` does not work `#D1162` 80edf44 +- init-bind: do not use workaround of `C-x` in vi mode `#D1163` e6a3d33 +- vi_test: fix test for the macro playing `#D1164` 636517c +- exec: fix a problem that the shell hangs with failglob in pipe `#D1166` ac8ba6e +- complete: fix a problem of delay with path `//` in Cygwin `#D1168` 2cf8cc7 +- prompt: fix the expansion of `\w` and `\W` in `PS1` for working directories with double slashes `#D1169` d1288dd +- exec: workaround termination of command execution on syntax error in array subscripts `#D1170` 4f442d0 +- history: fix a bug that garbage `__ble_edt__` is added in front of history entries 61f4bd1 +- decode: remove debug messages for `ble-bind -s` 64a17c3 +- syntax: fix highlighting of `${!var@}` `#D1176` 161ed80 +- term: fix `Ss` (`DECSCUSR`) 0c773da +- term: workaround linux console CSI \>, CSI M, CSI L `#D1213` `#D1214` 0ec6f0c +- edit: fix exit status of Bash by key binding C-d `#D1215` a9756e9 + +## Support macOS, FreeBSD, Arch Linux, Solaris, Haiku, Minix + +- util: fix the error message "usage: sleep seconds" on macOS bash 3.2 `#D1194` (reported by dylankb) 6ff4d2b +- decode: recover the terminal states after failing the default keymap initialization `#D1195` (reported by dylankb) 846f284 +- main (`ble-update`): use shallow clone `#D1196` 2a20d9c +- main (`$_ble_base_cache`): use different directories for different ble versions `#D1197` 55951d1 +- edit (`ble/builtin/read`): fix argument analysis with user-provided `IFS` in Bash 3.2 (reported by dylankb) `#D1198` 7411f06 +- global: fix subshell detection in Bash 3.2 `#D1200` ca8df8a +- syntax: workaround Bash-4.1 arithmetic bug `#D1201` f248c52 +- Makefile: fix "install" for BSD sed `#D1202` 32c2e1a +- term: support "tput" based on termcap `#D1203` `#D1204` 161af07 +- global: adjust for FreeBSD and Arch Linux `#D1205` 6ac5b8c +- global: workaround Solaris awk `#D1207` 74d438d +- util: support Haiku `#D1208` e3de373 + - ble/util/msleep: do not use `read -t time` for Haiku + - ble/term/stty: check available character settings + - init-cmap: check termcap settings for home +- util: support Minix `#D1209` 49e6457 + - ble/util/msleep: do not use `read -t time -u FD` in Minix + - ble-edit/prompt: does not abbreviate IPv4 address for `\h` + - Makefile: create directory `dist` for `make dist` + +## Internal changes + +- complete: isolate menu related codes `#D1029` 43bb074 +- global: use `builtin echo` explicitly `#D1035` a6232c2 +- decode: re-implement rlfunc2widget without fork `#D1063` d2e7dbe +- blerc: add descriptions `#D1064` d61b6af +- decode: decode mouse events `#D1084` 51fae67 +- history: move history related codes to `src/history.sh` `#D1119` 1bfc8eb e5b1980 + - history: move codes related to history prefixes and history searches to `history.sh` `#D1136` 1cda6ff 20024d2 + - history: use common "_ble_history_onleave" for different histories `#D1137` ec19d51 +- keymap/vi: deal with textarea local data properly `#D1123` 2ea7cfd +- edit: remove `ble-edit/exec:exec` `#D1131` 0cb9c6d +- global: distinguish exit status 147 and 148 `#D1141` d1a78fb +- global: follow bash syntactic changes on arithmetic command 16e0f0e +- decode: check `bind -X` first to store the original bindings `#D1179` 4057ff0 +- complete: resolve collision of flag chars with `shopt -s nocaseglob` `#D1186` 550fb14 +- color: change return variable of `ble/color/{,i}face2{g,sgr}` to `ret` `#D1188` 1885b54 +- global: workaround `shopt -s xpg_echo` `#D1191` e46f9a3 + + +# 2019-03-21 + +2019-02-09..2019-03-21 (#D0915...#D1015) 949e9a8...df4feaa + +## New features + +- auto-complete: support end at the end of line a374635 +- decode: replace builtin `bind` for `ble.sh` settings `#D0915` 90ca3be `#D0918` e0cdd15 + - decode: update mapping of rl-functions and widgets for vi_imap and vi_nmap `#D1012` 7fec4b6 + - decode: support `bind [-psPSX] [-quf arg]` `#D1013` 9265f8a +- edit: support C-x C-g, C-M-g for `bell` and `cancel` `#D0919` 2e83120 +- syntax: support `set +B` `#D0931` 12f80dd +- syntax: support aliased keywords `#D0936` 7054e28 +- complete: support `ble-sabbrev -m key=function` `#D0942` bcdf843 +- complete: support description of candidates `#D0945` `#D0946` 0fa73bf `#D0977` 96fe498 + - canvas: use ... instead of … when unicode is not available `#D0979` 51e600a + - canvas (`ble/canvas/trace`): support `opts=truncate:confine` `#D0981` 79916d2 +- complete: support insertion of ambiguous common part `#D0947` 3644a8e +- complete: support three levels of ambiguous matching `#D0948` 3644a8e +- complete: support menu item highlight of ambiguous matching `#D0949` 3644a8e +- complete: support menu pages `#D0958` ff43e01 a488e01 `#D0990` 32aeef0 + - menu-complete: show page numbers with `visible-bell` `#D0980` 6297e65 + - menu-complete: fix a bug that height of `menu` is too large (<= bash-4.1) `#D0983` 129a1f0 +- edit: support `bleopt rps1=` for the right prompt `#D0959` 90a8915 `#D0964` fa2a874 `#D0970` 87c8348 + - rps1: fix coordinate calculations for rps1 `#D0982` 129a1f0 + - canvas (`ble/canvas/trace`): fix a bug that `measure-bbox` does not work (<= bash-3.1) `#D0988` 7f880de + - canvas (`ble/canvas/trace`): fix a bug that `x1` and `y1` is not properly updated `#D0988` 7f880de + - edit: support `bleopt rps1_transient` `#D0993` 44edd38 + - edit: fix a bug that `rps1` is cleared on execution of the command `#D1003` 5780154 + - edit: erase trailing spaces after newlines when `rps1_transient` is enabled `#D1004` 5780154 + - edit: support multiline `rps1` (Note: still restricted to fit in lines of `PS1`) `#D1005` 5780154 +- complete: support "bleopt complete_menu_style=desc-raw" `#D0965` 1fd7a3e +- complete: support prior, next, home, end in `menu_complete` keymap `#D0966` b729d23 +- edit: support `bleopt prompt_eol_mark=$'\e[94m[ble: EOF]\e[m'` `#D0968` 6c8b52a +- complete: highlight active ranges of `menu-filter` `#D0969` 500f702 `#D0971` aae8b26 + - menu-filter: cancel `menu-filter` when the word ends `#D0974` 6ce2ad2 + - menu-filter: improve highlight `#D0975` b89f39f +- isearch: show progress bar using unicode chars `#D0978` 51e600a +- main: support `ble-reload` ef51490 +- complete: support `source:sabbrev` `#D0994` 5c9e579 +- complete: clear menu on C-g `#D0995` e0f93a2 +- vi_imap: support `bleopt keymap_vi_imap_undo=more` `#D0996` 50f8ad2 +- util: support `bleopt vbell_align` and `ble-color-setface vbell{,_flash,_erase}` for vbell `#D0997` 325883e + - vbell: fix a bug that garbages remain on short messages just after longer messages `#D1010` 3e9ff85 +- decode: support "bleopt decode_abort_char=28" `#D0998` b110cb9 +- complete: support `visible-stats` and `mark-directories` `#D1006` b389b3b +- complete: support `mark-symlinked-directories`, `match-hidden-files` and `menu-complete-display-prefix` `#D1007` fd66194 +- canvas: support `bleopt char_width_mode=auto` `#D1011` 3978df3 + +## Changes + +- prompt: support correct handling of escapes `#D0923` 22f9b56 +- util (`ble/util/sleep`): adjust delay `#D0934` `#D0935` 5fd5cd6 ad1208b 188cd98 +- complete: use candidates in menu if present `#D0939` 52eaf01 + - complete: fix a bug that menu-complete is disabled after `menu-filter` `#D0951` 08cba07 + - complete: fix a bug that wrong action is performed after `menu-filter` `#D0952` 08cba07 + - complete: fix a bug that extra TAB is needed to enter `menu-complete` `#D0956` aa6bd73 + - complete: fix a bug that candidates are not regenerated on function name completions `#D0961` bbea72e + - complete: fix a problem that the menu style is reset on `menu-complete` `#D0972` 47c28ff + - menu-filter: explicitly call `ble/complete/menu-filter` (<= bash-3.2) `#D0986` 1b14b11 +- syntax: allow variable assignment in arguments of `eval` `#D0941` 2f2f0eb +- highlight: do not highlight overwrite modes when mark is active `#D0950` 4efe1a9 + - highlight: disable `layer:menu_filter` (<= bash-3.2) `#D0987` 1b14b11 +- complete: disable `auto-complete` inside the active range of `menu-filter` `#D0957` +- util (visible-bell): truncate long messages to fit into a line `#D0973` e55ff86 +- edit: render prompt immediately on newline `#D0991` cdb8acb `#D1003` 5780154 +- syntax: detect syntax errors of `CTX_CMDX1` immediately followed by terminating keywords `#D1001` 7ea02b7 +- complete: improve support of `bind 'completion-ignore-case on'` `#D1002` 25ebc55 +- complete: preserve original path specifications on ambiguous completion `#D1014` a39d1ac +- complete: append `,` instead of ` ` after completion in brace expansions `#D1015` df4feaa + +## Fixes + +- main: workaround `set -evx` `#D0930` 698517d +- edit (widget `delete-horizontal-space`): fix a bug that spaces before the cursor is not removed `#D0932` 9290adb +- bleopt: fix a bug that false error messages are output on reload when `failglob` is set `#D0933` 64cdcba c62db26 +- decode: fix a bug that \\ cannot be input after reattach `#D0937` a46ada0 +- reload: fix a bug that `PS1` is lost on reload with `--attach=prompt` `#D0938` 1107ca8 +- main (`--attach=prompt`): workaround rewrite of `PROMPT_COMMAND` `#D0940` 863fd7b +- vi_nmap (`/`, `?`, `n`, `N`): fix search progress `#D0944` f20f840 +- complete: fix a problem of slow ambiguous filename matching in nested directories `#D0960` 7b3ee55 +- util: improve performance of `ble/{util/{mapfile,assign-array},string#split-lines}` (<= bash-3.2) `#D0985` ae176b2 `#D0989` 36b9a8f f199215 +- sabbrev: fix a bug that sabbrev is disabled (<= bash-3.2) `#D0985` 840af29 +- util (ble/util/msleep): suppress warnings from `usleep` `#D0984` 8e4180c +- util: fix a problem that C-d cannot be input in nested Bash 3.1 `#D0992` 88a1b0f +- edit: fix a bug of a redundant newline on `read -e` `#D0999` 700bc91 + +## Internal changes + +- [refactor] info: rename info type `raw` -> `esc` `#D0954` ac86f10 +- [refactor] do not use brace expansions for `VARNAMES` `#D0955` 711e7df +- [refactor] `ble-{highlight,complete,syntax}` -> `ble/*` 7aaa660 ae6be66 8ea903c +- [refactor] `ble-edit/info/.construct-text` -> `ble/canvas/trace-text` `#D0973` e55ff86 +- rename `ble/complete/action:*/getg` -> `ble/complete/action:*/init-menu-item` `#D1006` b389b3b + + +# 2019-02-09 + +2018-10-05 -- 2019-02-09 (#D0858..#D0914) 6ed51e7..949e9a8 + +## New features + +- color (`ble-color-setface`): support various spec such as SGR params `#D0860` 82fe96d `#D0861` 257c16d `#D0864` 2eaf2a9 +- syntax: `bleopt filename_ls_colors` に対応 `#D0862` c7ff302 `#D0863` 3c5bacf ec31aab +- vi_omap: support v, V, C-v `#D0865` 54942e0 `#D0866` a9a1638 `#D0867` d3d8ea3 `#D0868` eb848dc +- main: improve support of `[[ -o posix ]]` `#D0871` 07ae3cc `#D0872` 513c543 +- main: do not load ble.sh when bash is started by `bash -i -c command` `#D0873` fc23a6d +- main: support `ble-update` `#D0874` fc45be6 `#D0875` 0b50974 `#D0891` d010300 `#D0910` 4743c00 2dc3a3f +- vi_nmap: support C-d, C-u, C-e, C-y, C-f, next, C-b, prior `#D0886` +- isearch: use previous needle for empty string search `#D0889` 362fce3 +- vi_imap: add a function `ble-decode/keymap:vi_imap/define-meta-bindings` `#D0892` a21d22f +- progcomp: support `complete -I` for Bash 5.0 `#D0895` `#D0896` +- progcomp: support candidates which replace the original text before the cursor `#D0897` 41b8cbb +- progcomp: support `compopt -o nosort|noquote|plusdirs` `#D0898` cc48539 +- edit: support M-* `#D0899` 3fd7d6e +- edit: support M-g, C-x *, C-x g `#D0902` 41797c6 +- progcomp: support `COMP_WORDBREAKS` `#D0903` 7cfe425 +- complete: support completion of tilde expansion `#D0907` b4fc40c `#D0908` 9fafdb3 +- main: support `BLE_VERSION` and `BLE_VERSINFO` (suggested by cmplstofB) `#D0909` +- global: support `--help` for public functions `ble-*` (suggested by cmplstofB) `#D0911` 77d459d f4d03f6 1d191c7 1209ac6 `#D0913` 92d9038 + +## Changes + +- edit: change cursor position after u `#D0877` 9d5c945 +- edit: handle panel layouts `#D0878`--`D0882` 6a26894 `#D0888` c8e0d28 +- vi_nmap: support z z, z t, z b, z ., z RET, z C-m, z +, z - `#D0886` +- emacs: change M-m M-S-m from `beginning-of-line` to `non-space-beginning-of-line` f77f1aa +- bleopt: rename internal settings to `internal_{ignore_trap,suppress_bash_output,exec_type,stackdump_enabled}` fd042d8 +- vi_nmap: change the behavior of C-home, C-end to match with those of vim 8682f98 +- util (`ble/util/unlocal`): add workaround for Bash-5.0 `localvar_unset` `#D0904` 8677a71 +- sabbrev: quote key in printing definitions by `ble-sabbrev` `#D0912` 2994d80 + +### Fixes + +- info: fix a bug that coordinates calculation breaks with Japanese text `#D0858` 67c77dc +- syntax (`extract-command`): fix a bug that extraction of nested commands always fails `#D0859` c3270f6 +- complete: fix a bug that the settings `complete -c` does not work `#D0870` 1ca5386 82bb154 +- main: fix a bug that the determination of `_ble_base` fails when loaded as `source ble.sh` without specifying the directory of `ble.sh` 201deae +- util: `ble/util/assign` が正しい戻り値を返さないバグの修正 bd14982 +- util: `ble/util/assign-array` の入れ子の呼び出しで内容が混ざり合う問題の修正 bd14982 +- progcomp: fix a bug that bash-completion does not work properly due to wrong `COMP_POINT` `#D0897` 41b8cbb +- global: fix leak variables `#D0900` 244f965 `#D0906` b8dcbfe 9892d63 +- progcomp: fix a problem that completion functions can consume stdin `#D0903` 7cfe425 + +## Internal changes + +- global: properly quote rhs of `[[ lhs == rhs ]]` f1c56ab +- syntax: rename variables `BLE_{ATTR,CTX,SYNTAX}_*` -> `_ble_{attr,ctx,syntax}_*` 1fbcd8b (ref #D0909) + + +# 2018-10-05 + +2018-09-24 -- 2018-10-05 (#D0825..#D0857 6ed51e7) + +## 新機能 + - highlight: 変数代入の右辺及び配列要素の着色に対応 `#D0839` 854c3b4 + - nsearch: (非インクリメンタル)履歴検索に対応 C-x {C-,}{p,n} `history-{,substring-,n}search-{for,back}ward` `#D0843` e3b7d8b 0d31cd9 253b52e + - isearch: 検索前に選択状態でがあれば検索後に復元する `#D0845` 93f3a0f + - decode: 貼り付け時など大量の入力があった時に処理の進行状況を表示 `#D0848` c2d6100 + - decode: 貼り付け時などの高速化の為に一括の文字列挿入に対応 (`batch-insert`) `#D0849` 48eeb03 + - decode: `bleopt decode_isolated_esc=auto` でキーマップに応じて単独 ESC の取扱を切り替え `#D0852` 9b20b45 edd481c + - complete: `bleopt complete_{auto_complete,menu_filter}=` で自動補完・候補絞り込みの無効化に対応 `#D0852` 4425d12 + - vi: テキストオブジェクト単語の再実装 (reported by cmplstofB) `#D0855` 9f2a973 ad308ae 3a5c456 6ebcb35 + - vi: オペレータ `d` の特殊ルールに対応 `#D0855` fa0d3d3 + +## バグ・問題修正 + - decode: `ble-bind -d` に於いて `-c` 及び `-x` の引数の引用符が二重になっている問題の修正 `#D0850` + - auto-complete: 構文エラーが自動補完により解決される時 RET でコマンド実行が抑止されない問題の修正 `#D0827` daf360e + - highlight: `shopt -s failglob` で配列の指示初期化子がエラー着色される問題の修正 (reported by cmplstofB) `#D0838` d6fe413 + - complete: プログラム補完に対して曖昧補完が効かない時の対策 `#D0841` 713e95d + - isearch: ユーザ入力による割り込みで検索位置の記録に失敗していたバグの修正 `#D0843` + - isearch: キャンセル時に位置とマークが正確に復元されない問題の修正 `#D0847` + - isearch, dabbrev: 検索処理中にユーザが何か入力するまで現在行が更新されない問題の修正 `#D0847` + - decode: 未ロードのキーマップに対して `ble-bind -m -P` `ble-bind -m kmap -f kspecs -` が使えない問題の修正 66e202a + - auto-complete: C-j が単なる "確定" になっていたのを "確定して実行" に修正 `#D0852` 01476a7 + - edit: M-S-f, M-S-b を束縛するべきところ M-C-f, M-C-b を束縛している箇所を修正 `#D0852` c68e7d7 + - color: Bash 3.0 で算術式内の `<()` がプロセス置換と解釈される問題の対策 `#D0853` 520184d + - syntax: コメント上の単語が何故か除去されないバグの修正 (reported by cmplstofB) `#D0854` 641583f + - vi: Bash 3.1 及び 3.2 で C-d 受信の為のリダイレクトに失敗する問題の修正 `#D0857` d4b39b3 + +## 動作変更 + - sabbrev, vi_imap: `sabbrev-expand` を C-x ' ではなく C-] から束縛 `#D0825` e5969b7 + - core: `bleopt` に設定名を指定子て設定内容を表示させる時、設定名の存在を確認する `#D0850` 725d09c + - isearch: C-d で現在の選択範囲を削除する様に変更 `#D0826` c3bb69e `#D0852` db28f74 + - isearch: C-m (RET) で確定した時は選択範囲を解除する様に変更 `#D0826` c3bb69e + - decode: `ble-bind` のオプションを再構成 `#D0850` f7f1ec8 64ad962 + - decode: 組み込みコマンド `bind` を上書きして `ble.sh` の動作が阻害されない様に引数をチェックして実行 `#D0850` + - complete: autoload `ble-sabbrev` (`core-complete.sh`), `ble-syntax:bash/is-complete` (`core-syntax.sh`) `#D0842` df0b769 + - isearch: 編集関数 `isearch/accept-line` が RET 以外から束縛されていても RET を実行する様に変更 `#D0843` + - vi, [in]search: mark 名を整理 (`char`/`line`/`block`/`search` に接頭辞 `vi_` 付加し、新しい mark 名を `search` とする) `#D0843` + - edit: 関数名変更 `ble/widget/accept-single-line-or/accepts` → `ble-edit/is-single-complete-line` `#D0844` + - isearch: 空文字列で検索した時の振る舞いを再考 `#D0847` d05705e + - decode: 入力のキー復号の各種調整 `#D0850` dc013ad + - dabbrev: C-m, RET で展開終了、C-j, C-RET でコマンド実行 `#D0852` 01476a7 + +## 内部的変更 + - isearch, dabbrev: `ble/util/fiberchain` による再実装 `#D0843`, `#D0846` 2c695cf bdf8072 95268c1 + - edit, vi: 選択範囲の種類を表す mark 名を整理 a1a6272 + - edit: 関数名変更 `ble/widget/accept-single-line-or/accepts` → `ble-edit/is-single-complete-line` `#D0844` 63ec9fe + - refactor: ファイルの整理 5e07e7f 1a03da2 673bd1d 55c4224 9ce944c 9a47c57 25487a7 5679ffc b7291a7 + - refactor: 関数名・変数名の整理 `#D0851` d1b780c 9129c47 4d1181a + + +# 2018-09-23 + +2018-09-03 -- 2018-09-23 (#D0766..#D0824 8584e82) + +### 補完: 新機能 + - complete: 自動補完において履歴からの検索に対応 `#D0766`, `#D0769` `#D0784` (fix) + - complete: 自動補完時の M-f C-f 等に対応 `#D0767` + - complete: `"$hello"` などの引用符中のパラメータ展開がある場合でも補完に対応 `#D0768` + - complete: 配列要素代入の右辺での補完に対応 `#D0773` + - complete: ブレース展開の途中での補完に対応 `#D0774` + - auto-complete: `ble/widget/auto_complete/accept-and-execute` 対応 `#D0811` + - complete: 補完関係の設定をする為の load hook の追加 `#D0812` + - complete: 種類を指定した補完に対応 `#D0820` `#D0819` (fix) + - complete: 静的略語展開に対応 (`ble-sabbrev key=value` で設定) `#D0820` + - complete: 動的略語展開に対応 `#D0820` + +## 補完: バグ・問題点修正 + - complete: 一意確定した直後の補完ですぐにメニュー補完に入るバグの修正 `#D0771` + - complete: `function fun [` 直後の補完で `[\[` が挿入される問題の修正 `#D0772` + - complete: 曖昧補完で補完を実行しようとすると入力済みの部分が削除されるバグの修正 `#D0775` + - complete: 自動補完が起動しなくなっているバグの修正 `#D0776` + - complete: プログラム補完関数が `failglob` で失敗するとシェルが終了する問題の対策 (reported by cmplstofB) `#D0781` + - complete: `failglob` の時コマンド補完候補に `*` が含まれてしまう問題の修正 (reported by cmplstofB) `#D0783` + - complete: 候補一覧にて入力済み範囲の強調が絞り込みにより無効化されるバグの修正 `#D0790` + - complete: 自動補完を抜けた後のマーク位置が誤っているバグの修正 `#D0798` + - complete: `for a in @` や `do @` の位置の補完でエラーメッセージが表示されるバグの修正 `#D0810` + +## 補完: 動作変更 + - complete: 入力済み部分の評価方法の内部変更 `#D0777` + - complete: 自動補完の着色の変更 `#D0780` `#D0792` + - complete: プログラム補完で提供するコマンドライン (`COMP_*`) にて、補完開始点に単語の切れ目を入れる様に変更 `#D0793` + - auto-complete: C-RET で補完を確定してコマンド実行 `#D0822` + +## 他: 新機能 + - edit: `IGNOREEOF` に対応 `#D0787` + - edit: コマンド `exit` にて、ジョブが残っている場合はユーザに尋ねて終了 `#D0789`, `#D0805` (bugfix) + - term: 256色対応のない端末での減色の実装 `#D0824` + +## 他: バグ・問題点修正 + - isearch: 非同期検索ができなくなっていたバグの修正 + - color: `ble-color-setface` の遅延初期化順序のバグを修正 (reported by cmplstofB) `#D0779` + - decode: CentOS 7 で `LC_ALL=C.UTF-8` に対してエラーメッセージが出る問題の対策 `#D0785` + - edit: ジョブがある時の終了 C-d について `bleopt allow_exit_with_jobs` 対応 (request by cmplstofB) `#D0786` + - edit: Bash 3.* で C-d によるプログラム実行 (`ble-edit/exec:gexec`) が遅延するバグの修正 + - syntax: Bash 3.2--4.1 の算術式バグによる関数定義の構文解析に失敗する問題の対策 `#D0788` + - highlight: `region` レイヤーの着色範囲が改行を跨ぐ場合に既定の着色になるバグの修正 `#D0791` + - isearch: 空の検索文字列による一致に C-h で戻った時に全体が選択されるバグの修正 `#D0794` + - decode: `failglob` の時 `ble-bind -d` に失敗する問題の修正 `#D0795` + - edit: `command-help` のコマンド名抽出に失敗するバグの修正 (reported by cmplstofB) `#D0799` + - syntax: 履歴展開の置換指示子の解析が正確でない問題の修正 (report by cmplstofB) `#D0800` + - edit: Bash 3.0 で履歴展開 `:&` が使えない問題の修正 `#D0801` + - idle: 負の `sleep` を試みてエラーメッセージが出る問題の修正 `#D0802` + - bind: `ble-detach` 時に、Bash 3.0 の " のバインディングを破壊するバグの修正 `#D0803` + - edit: `ble-detach` 直後にコマンドラインに設定される `stty sane` が表示されない問題の対策 `#D0804` + - core: Bash-3.0 で補完候補がない場合にエラーメッセージが表示されるバグの修正 `#D0807` + - edit: コマンド実行中にウィンドウサイズが変更された時にプロンプトが表示されてしまう問題の解消 `#D0809` + - edit: widget 内で `read -e` を使用した時・`read -e` がタイムアウトした時に表示が乱れる問題の解消 `#D0809` + - edit: `read -e` でタイムアウトが効かないバグの修正 `#D0809` + - term: 16色の端末で色が化けるバグの修正 `#D0823` + +## 他: 動作変更 + - edit: `read -e` がキャンセル・タイムアウトによって終了した時に入力文字列を灰色で再表示 `#D0809` + - decode: キーマップの既定の初期化を最初の `ble-bind` 時に確認する様に変更 `#D0813` + - core: `ble/util/clock` 導入 `#D0814` + - edit: `ble-edit/read -e -t timeout` において、タイムアウトをより高精度で処理 (`ble/util/clock`) `#D0814` + - color: `face` が定義されていない時のエラーメッセージの表示方法を変更 `#D0815` + - edit: コマンド実行時に現在のカーソル位置より下に表示されている端末の内容を上書きする様に変更 `#D0816` + - edit: `accept-line` において、ちらつき防止の為、実際のコマンド実行が伴わない時は info の再描画を行わない `#D0816` + - edit: `ble/widget/history-expand-line` は C-RET ではなく M-^ から束縛される様に変更 `#D0820` + - edit: `ble/widget/magic-space` で履歴展開が行われなかった時、現在位置で静的略語展開を試みる様に変更 `#D0820` + - isearch: RET でコマンド実行ではなく検索を終了するだけに変更。C-RET でコマンド実行 `#D0822` + +## 他 + - Makefile: 依存ファイルを `.PHONY` target として出力 `#D0778` + - core: `ble/util/assign` をリエントラントに修正 `#D0782` + - 議論 complete: `#D0770` edit: `#D0796` vi: `#D0796` + - `blerc` の更新 + +## 以下は widget 名変更の一覧 + - `menu_complete/accept` → `menu_complete/exit` + - `auto_complete/accept` → `auto_complete/insert` + - `auto_complete/accept-on-end` → `auto_complete/insert-on-end` + - `auto_complete/accept-word` → `auto_complete/insert-word` + - `auto_complete/accept-and-execute` → `auto_complete/accept-line` + - `isearch/accept` → `isearch/accept-line` + + +# 2018-09-02 + +2018-07-29 - 2018-09-02 (#D0684..#D0765 0c28ed9) + +## 補完: 新機能 + - complete: 曖昧補完 `#D0707` `#D0708` `#D0710` `#D0713` `#D0743` (fix) + - complete: Readline 設定 `completion-ignore-case` に対応 `#D0709` `#D0710` + - complete: `ble/cmdinfo/complete:$command_name` 対応 `#D0711` + - complete: `path:...` などと入力した時の続きの補完に対応 `#D0715` + - complete: 引用符内のエスケープなどを適切に処理する `#D0717` + - complete: 自動補完に対応 `#D0724`, `#D0728`, `#D0734` & `#D0735` (vim-mode), `#D0766` (history) + - complete: カーソルの右側に補完結果の一部が含まれる時にスキップする機能 (`bind set skip-completed-text`) `#D0736` + - complete: 引用符の中で補完した時に引用符を閉じる機能 `#D0738` + - complete: 算術式内部での変数名の補完に対応 `#D0742` + - complete: 候補一覧表示の整列と着色 `#D0746` `#D0747` `#D0762` `#D0765` + - complete: menu-completion (メニュー補完) 対応 `#D0749` `#D0757` `#D0764` + - complete: menu-filter (候補絞り込み) 対応 `#D0751` + - complete: vi_cmap に於ける補完 `#D0761` + +## 補完: バグ修正・対策 + - complete: Cygwin でのコマンド名補完に於いて `.exe` の途中まで入力した時に正しく補完できない問題の修正 `#D0703` + - complete: `complete` によって登録されたプログラム補完に対して変数 `COMP_*` が正しく設定されない問題の修正 `#D0711` + - complete: `"` や `'` を含むファイル名の補完が正しくできない問題の修正 `#D0712` `#D0714` + - complete: 補完中に特殊キーを入力しても中断しない問題の解消 `#D0729` + - complete: クォートを認識しないプログラム補完関数に対する対策 `#D0739` + - complete: 引数の途中からのプログラム補完の不整合の修正 `#D0742` `#D0744` + - complete: パラメータ展開 `${var}` 直後からの補完が正しく実行できる様に修正 `#D0742` + +## 補完: 動作変更 + - complete: 補完候補生成直前の `shopt -s force_fignore` を参照して候補を制限する様に変更 `#D0704` + - complete: `FIGNORE` はエスケープされた挿入文字列に対してではなくて、候補文字列に対して判定する様に変更 `#D0704` + - complete: 関数名補完を `/` で区切られた単位で行う `#D0706` `#D0724` (曖昧一致の時は抑制) + - complete: パラメータ展開で厳密一致で一意確定の時は他の補完文脈を使うように変更 `#D0740` + - complete: パラメータ展開の補完後に挿入する文字を文脈に依存して変更 `#D0741` + - complete: パラメータ展開の直後に補完で挿入する際のエスケープを文脈に依存して変更 + - complete: プログラム補完による生成候補でディレクトリ名を省略 `#D0755` + +## 他: 新機能 + - edit (`RET`): 文法的に不完全のときに改行を挿入 `#D0684` + - core (`ble/util/idle`): 簡易タスクスケジューラの実装 `#D0721` + - core: add a function `ble/function#try` `#D0725` + - idle: `ble/util/idle` でバックグラウンドジョブ待ち機能を実装 `#D0731` `#D0745` (history bugfix) + - base: `--attach=prompt` 対応 `#D0737` + - base: 初回初期化時の順序の変更と過程の info による表示 + - decode: modifyOtherKeys 対応の改善 `#D0752` `#D0756` `#D0758` `#D0759` + - core (`ble/util/assing`): 第3引数以降にコマンドに対する引数を指定できるように変更 `#D763` + +## 他: バグ修正・対策 + - highlight: 単語着色が乱れるバグの修正 `#D0686` + - syntax: bash-3.2 以下で `_ble_syntax_attr: bad array subscript` のエラーが出るバグの修正 `#D0687` + - prompt: PS1 で \v が空文字列になるバグの修正 `#D0688` + - highlight: 上書きモードにおいてコマンドをキャンセルしても `disabled` レイヤーの着色が無視されるバグの修正 `#D0689` + - core (ble/term/visible-bell): 横幅の計算を誤っているバグの修正 `#D0690` + - decode: "set -o vi/emacs" で編集モードを切り替えた直後に "stty" が変になる問題の修正 `D0691` + - core: LANG=C とすると動かなくなる問題の対処 `#D0698` `#D0699` `#D0700` + - history: Cygwin で履歴の初期化に時間がかかる問題の対策 `#D0701` + - history: bashrc 読み込み直後に謎の待ち時間が発生する問題の対策 `#D0702` + - emacs: 貼り付け (bracketed paste) で文字列が二重に挿入されるバグの修正 `#D0720` + - main: POSIXLY_CORRECT が設定されている時の対策 `#D0722` `#D0726` `#D0727` + - edit: POSIXLY_CORRECT を用いた組み込みコマンド上書き対策 `#D0722` + - decode: 連想配列に依る実装のバグを修正し bash-4.0, 4.1 においても連想配列を使用 '#D0730' + - decode: `ble-bind -c` でシェルの特殊文字を含むコマンドが正しく実行できないバグの修正 + - edit: 履歴項目の数が倍増するバグの修正 `#D0732` + - vi: キーボードマクロで特殊キーが再生されないバグの修正 `#D0733` + - isearch: 現在位置の表示時の 0 除算のバグの修正 + - vi: `!!` をキャンセルしても操作範囲を示す着色が消えないバグの修正 `#D0760` + +## 他 + - refactor: `#D0725` `#D0750` `#D0753` `#D0754` + - bash-bug: Bash に対するバグ報告 `#D0692` `D0695` `D0697` + + +# 2018-03-15 + +2018-03-15 (#D0644..#D0683 7d365d5) + +## 新機能 + - undo: vi-mode `u` `` `U` (`#D0644` `#D0648`); emacs `#D0649`; `#D0662` + - vi-mode (nmap/xmap): `f1` で `command-help` 呼び出し + - vi-mode (nmap): `C-a` `C-x` 対応 (nmap `#D0650`, xmap `#D0661`) + - vi-mode (operator): 各種オペレータ対応 `#D0655` (`gq`, `gw` `#D0652`; `!` `#D0653`; `g@` `#D0654`) + - vi-mode (operator): 追加入力のあるオペレータで作用対象を着色 `#D0656` + - vi-mode (registers): registers `"[0-9%:-]` `#D0666` `#D0668`, `:reg` `#D0665` + - vi-mode (smap): 選択モード `#D0672` + - emacs: 主要なコマンドで引数に対応 `#D0646` + - emacs: 複数行モードの時にモード名を表示。引数も表示。 `#D0683` + - edit: `safe` keymap + - edit: 絵文字の文字幅 `bleopt emoji_width=2` `#D0645` + - core: 誤った `PATH` に対する対策 `#D0651` + +## 動作修正 + - vi-mode (nmap/xmap/omap ``): 引数を無視するように変更 + - vi-mode (map `/` `?` `n` `N`): 検索の一致の仕方を vim と同様のものに変更 `#D0658` + - vi-mode (omap): `g~?` で検索して一致した範囲まで大文字・小文字を切り替えるように変更 `#D0659` + - vi-mode (map): 最終行付近で `+` `_` `g_` などを呼び出したときの振る舞いを vim と同様のものに変更 `#D0663` + - vi-mode (xmap): テキストオブジェクト `[ia]['"]` の xmap での正しい振る舞い `#D0670` + - vi-mode (nmap): `Y` で行頭に動かないように変更 `#D0673` + - vi-mode (xmap): 矩形範囲抽出の効率化 `#D0677` + - core: `ble.sh` ロード時間の改善 `#D0675`, `#D0682`, (遅延読込 `#D0678` `#D0679` `#D0680`, 裏で履歴読込 `#D0681`) + +## バグ修正 + - vi-mode (omap): `cw` や `y?` が動かなくなっていたバグの修正 + - vi-mode: マクロで記録される内容に空白が挿入されるバグの修正 `#D0667` (テスト追加 `#D0669`) + - vi-mode: 行指向の貼り付けが動かなくなっていたバグの修正 `#D0674` + - complete: コマンド名によって第一引数の補完が正しく実行されないことがあるバグの修正 `#D0664` + - syntax: ヒアストリングで $ret を指定するとエラーメッセージが現れたバグの修正 `#D0660` + - syntax: bash-3.0 でコマンドの着色が常にエラーになっていたバグの修正 `#D0676` + - decode: ble-decode-unkbd があらゆる文字について ESC を返す様になっていたバグの修正 `#D0657` + - Makefile: 削除したファイル isearch.sh が要求されるバグの修正 + - Makefile: 最新の gawk で動かないバグの修正 + + +# 2017-12-03 + +## 新機能 + - edit, vi-mode: bracketed paste mode に対応 `#D0639` + +## 動作修正 + - core: 端末の状態設定・復元とカーソル形状の内部管理 `#D0638` + - 外部コマンドを呼び出すときに既定のカーソル形状にする + - 外部コマンドから戻ったときにカーソル形状を復元する + - syntax (extract-command): より下の構文階層にいてもコマンドを見つけられるように修正 `#D0635` + これによりリダイレクトの単語などの上でも `command-help` (nmap `K`, emacs `f1`) が動くように。 + - syntax (チルダ展開): 変数代入の形式を持つ通常単語内部でのチルダ展開に対応 `#D0636` + - syntax: [...] 内部でチルダ展開が起こったとき [...] は意味を失う `#D0637` + - vi-mode (cmap ``): imap `` と同様に vim の動きに変更 + +## バグ修正 + - complete: 補完候補がない時に空文字列で確定するバグの修正 `#D0631` + - complete, highlight: `failglob` 周りのバグの修正 (3) `#D0633` `#D0634` + - vi-mode: `ret` グローバル変数が汚染されていたバグの修正 `#D0632` + - highlight: 読み取り専用の変数名を入力するとエラーメッセージが出るバグの修正 + - decode: `__defchar__` から呼び出された widget が 125 を返したとき + `__default__` から呼び出された widget にキー列が渡されないバグの修正 + - core: set -u にすると全く動かないバグの修正 `#D0642` + - edit: ble.sh ロード中に `read -e` が動かないバグの修正 `#D0643` + + +# 2017-11-26 + +## バグ修正 + - general: failglob で問題が生じるバグの修正 `#D0630` + - keymap/vi (nmap q): bash-3.0 で動かなかったバグの修正 + - keymap/vi (cmap): C-d で終了してしまうバグを修正 `#D0629` + - edit (ble/widget/command-help): エイリアスの上でヘルプを実行しようとすると無限ループになるバグを修正 + - edit (ble/util/type): "-" で始まる名前のコマンドの種類の判定に失敗し着色されなかったバグの修正 + - complete: 変数代入の右辺やリダイレクト先で補完できないことがあるバグの修正 `#D0627` + - complete: 補完する単語にパラメータ展開が含まれるとき ble.sh のローカル変数の値を参照している問題の修正 `#D0628` + +## 動作変更 + - bind/decode: 孤立 ESC の読み取り方法を変更。 で単体 が入力されるように修正 + - bind/decode: input_encoding=C の時の孤立 ESC および C-@ の読み取りに対応 + - complete: 重複して列挙される候補を統合する `#D0606` + - complete: 厳密一致するディレクトリ名が何故かコマンド候補に現れる問題の修正 `#D0608` + - edit (command-help): 幾つかの組み込みコマンド・予約語について man bash の正しい位置に移動するように修正 `#D0609` + - edit (command-help): クォートなどを除去してからコマンドのヘルプを探索するように変更 `#D0610` + - core: 条件コマンドの比較で右辺をクォートし忘れていた箇所を修正 `#D0618` + - highlight: `shopt -s failglob` の時、失敗する単語にエラー着色をする `#D0630` + +## 構文解析変更 + - syntax: `> a.txt; echo` は構文エラーではないことに対応 `#D0591` + - syntax: 変数代入・リダイレクトの後では予約語は意味を失いコマンドとして扱われることに対応 `#D0592` + - syntax: `time` や `time -p` は構文的に正しいことに対応 `#D0593` + - syntax: `echo $(echo > )` などの `>` の引数がない構文エラーにより `$()` が閉じず別の構文エラーを引き起こしていたのを抑制 `#D0601` + - syntax: `function hello (())` は bash-4.2 未満では構文エラーとして扱うように変更 `#D0603` + - syntax: `time -p -- command` を独立した文脈で解析するように変更 `#D0604` + - complete: これにより `time` の引数のコマンド補完ができなかった問題は解消した `#D0605` + - syntax: extglob 内部のプロセス置換 `@(<(echo))` に対応 `#D0611` + - syntax: `[...]` によるパターンの解析に対応 `#D0612` + - syntax: 変数代入の右辺にある不活性になった extglob の入れ子 `@(@())` も不活性にする `#D0613` + - syntax: `shopt -u extglob` の時でも `*` や `?` を着色する `#D0616` + - syntax: ブレース展開の着色に対応 `#D0622` + - syntax: チルダ展開の着色に対応 `#D0626` + - syntax: `for var in args...` の `args` におけるリダイレクトの禁止 `#D0623` + - highlight: ヒアストリングの場合はパス名展開・ブレース展開を行わない `#D0624` + - highlight: リダイレクト先ファイル名が複数語に展開されたらエラー着色 `#D0625` + +## 構文解析修正 + - syntax: `$({ echo; })` や `$(while false; do :; done)` において `}`, `done` 等の後にコマンドがないと構文エラーになっていたバグの修正 `#D0593` + - syntax: `-` で始まる名前のコマンド・関数名が正しく着色されないバグの修正 `#D0595` + - syntax: `if :; then :; fi $(echo)` などの構文エラー着色が実行されないバグの修正 `#D0597` + - syntax: 先読みによる不整合が起こるバグの修正・先読みの枠組みの整備 `#D0601` + - プロセス置換周りで部分更新により不整合が生じるバグを修正 + - `function hello (())` としておいて `) (` を挿入して `function hello () (())` にすると不整合が生じるバグを修正 `#D0602` + - syntax: 途中で `shopt -u extglob` にしても `_ble_syntax_bashc` が更新されないバグの修正 `#D0615` + + +# 2017-11-09 + +## 新機能 + - vi-mode (nmap): `*` `#` `qx...q` `@x` + - vi-mode (cmap): 履歴 + - core: bleopt 変数 `pager` (既定値 `''`) に対応。`ble.sh` の使うページャとして `${bleopt_pager:-${PAGER:-適当に探索}}` を使用する。 + - vi-mode (nmap `K`): `ble/cmdinfo/help:$cmd`, `ble/cmdinfo/help` に対応。 + +## バグ修正 + - vi-mode (cmap ``): コマンドラインモードをキャンセルするキーマップが `bell` で上書きされていたバグの修正 + - decode: `shopt -s failglob`, `shopt -s nullglob` で `unset` が正しく動かないバグの修正 + - vi-mode (nmap `K`): `MANOPT=-a` で操作できなくなるバグの修正 + +## 動作変更 + - edit (`ble/widget/command-help`), vi-mode (nmap `K`): カーソル位置のコマンドの `man` を表示するように変更 + - base: キャッシュディレクトリ・一時ディレクトリの決定で、それぞれ `XDG_CACHE_HOME`, `XDG_RUNTIME_DIR` を参照するように変更 + - Makefile: インストール先ディレクトリで、`XDG_DATA_DIR` を参照するように変更 + - isearch: 実際に必要になるまでコマンド履歴のロードを遅延するように変更 + - vi-mode (nmap `K`): 組み込みコマンド・キーワードは `man bash` を表示する。 + - vi-mode (nmap `K`): シェル関数は関数定義を表示する。 + + +# 2017-11-05 + +## 新機能 + - vi-mode (exclusive motion): `:help exclusive-linewise` 特別規則 (exclusive -> inclusive, exclusive -> linewise) に対応 + - vi-mode (omap): `C-c` `C-[` で明示的にキャンセル + - vi-mode: keymap/vi_test.sh 追加。regression が酷いので vi-mode の動作テストを自動化 + - complete: bleopt 変数 `complete_stdin_frequency` (既定値 `50`) 追加 + +## 動作変更 + - vi-mode (nmap `e`, `E`): 移動先が最終行の最後の文字の空白のとき、omap なら bell を鳴らさないように変更 + - vi-mode (omap/xmap ``, ``, ``): 改行の数え方を変更 + - vi-mode (nmap `cw`, `cW`): 単語の最後の文字、および空白の上にいるときの振る舞いの変更 + - decode (ble-bind): `ble-bind -D` でキーマップの内部状態も出力するように変更 + - term: `_ble_term_SS` の既定値を空文字列に変更 + - complete: `shopt -s no_empty_cmd_completion` では補完を (コマンドの補完以外も) 全く行わないように変更 + - edit (ble/widget/exit): 編集中の文字列が残っているとき、灰色で再描画してから exit するように変更 + + +# 2017-11-03 + +## 破壊的変更 + - vi-mode (widget): 名称変更 blw/widget/vi-insert/* → ble/widget/vi_imap/* + - vi-mode (bleopt 変数): 名称変更 bleopt keymap_vi_normal_mode_name → keymap_vi_nmap_name + - vi-mode (imap): vi-insert/magic-space 廃止。代わりに magic-space を直接用いる。 + +## 新機能 + - vi-mode (xmap): `o` `O` + - vi-mode (nmap): `.` 取り敢えず完成? + - vi-mode (xmap/nmap): `gv` + +## バグ修正 + - vi-mode (mark `` `x `` `'x`): オペレータが呼び出されないバグの修正 + - vi-mode (txtobj `[ia]w`): 英数字と _ の連続ではなく英字と _ だけの連続を単語としていたバグの修正 + - vi-mode (imap): `{count}i...` において `x` `x` が正しく繰り返されなかったバグの修正 + - vi-mode (imap): `{count}i...` において繰り返しが有効になっていたバグの修正 + - vi-mode (nmap `{N}%`): 目的の行に移動しなくなっていたバグの修正 + - vi-mode (nmap `_`): `d_` 及び `d1_` が linewise になっていないバグの修正 + - vi-mode (xmap `I` `A`): 動かなくなっていたバグの修正 + - vi-mode (xmap `I` `A`): 実行後のカーソル位置がずれていたバグの修正 + - vi-mode (xmap `I` `A` `c` `s` `C`): 矩形挿入の後の編集範囲 `` `[`] `` から1行目が抜けているバグの修正 + - vi-mode (xmap `?`): 検索 `?` が operator `g?` になっているバグの修正 + - vi-mode (xmap `/` `?` `n` `N`): ビジュアルモードの選択範囲が検索の一致範囲で上書きされるバグの修正 + - vi-mode (xmap `/` `?` `n` `N`): 現在の履歴項目の中で一致しない時、別の履歴項目にビジュアルモードのまま移動するバグの修正 + - lib/vim-surround (nmap `cs` `cS`): nmap `.` 対応時に引数とレジスタが効かなくなっていたバグの修正 + - lib/vim-surround (xmap `S`): `v` によるビジュアルモードで改行が前後に挿入されていたバグの修正 + +## 動作変更 + - vi-mode (imap ``): vim の単語区切り (`w`) による削除に変更 + - vi-mode (nmap `[rRfFtT]x`): `` でキャンセルするように変更 + - vi-mode (nmap `w` `b` `e` `ge`): 非英数字 ASCII の連続と、Unicode 文字の連続 をそれぞれ別の単語と扱うように変更 + - vi-mode (xmap `c` `s` `C`): `I`, `A` と同様の矩形挿入に対応 + + +# 2017-10-30 + +## 破壊的変更 + - vi-mode: キーマップの名称変更 vi_command -> vi_nmap, vi_insert -> vi_imap + - vi-mode: 一部の widget の名称変更 + - ble/widget/{no,}marked -> ble/widget/@{no,}marked + - ble/widget/vi-command/* (一部) -> ble/widget/vi_nmap/* + - vi-mode: ble/widget/vi-insert/@norepeat 廃止。別の方法 (_ble_keymap_vi_imap_white_list) を用いる。 + +## 新しい機能 + - vi-mode (nmap): . は実装途中 (現状 nmap/omap におけるオペレータ経由の変更のみ記録) + - vi-mode (mode): bleopt 変数 `term_vi_[inoxc]map` + - decode: 孤立 ESC のタイムアウトに対応 + - edit: shopt -s histverify, shopt -s histreedit に対応 #D0548 + +## バグ修正 + - vi-mode (xmap): `p`, `P` が正しく動作しないバグを修正 + - vi-mode (imap): 挿入モードに入るときに指定した引数 (繰り返し回数) が常にキャンセルされていたバグの修正 + - vi-mode (txtobj; nmap `gg`, `G`): レジスター指定が消失していたバグの修正 + - lib/vim-surround (nmap ds): 引数が内部使用のオペレータ `y`, `d` に正しく渡っていなかったバグの修正 + - prompt: `PROMPT_COMMAND` で設定された `PS1` が永続化されていなかったバグの修正 + - decode: bind -x で曖昧な登録があって bash_execute_unix_command エラーになっていた問題の修正 #D0545 + - decode: `vi.sh`, `emacs.sh` において `default.sh` が多重に呼び出されていた無駄の修正 #D0546 + - core: bash-3.0 において ble/util/assign が壊れていたバグの修正 + +## 動作変更 + - vi-mode (nmap `x`, ``, `s`, `X`, `C`, `D`): support registers + - source ble.sh において無事にロードされたときに終了ステータス 0 を返すことを保証 + - widget marked, nomarked を @marked, @nomarked に改名。元の widget は非推奨 (削除予定) + - ble.sh: Linux 以外でも (`readlink -f` が動かないときも) シンボリックリンクを通したロードに対応 #D0544 + + +# 2017-10-22 + +## 新機能 + - vi-mode (mark): `mx` `x 'x (`x` = [][<>`'a-zA-Z"^.]) + - vi-mode (nmap): `gi` `` (空文字列のとき exit) `"x` (registers) + - vi-mode (xmap): `I` `A` `p` `P` `J` `gJ` `aw` `iw` + - lib/vim-surround.sh: nmap `yS` `ySS` `ySs` `cS`, xmap `S` `gS` + - タブ・インデントの制御 + - bleopt tab_width= (タブの表示幅) + - bleopt indent_offset=4 (`>` や `<` のインデントの幅) + - bleopt indent_tabs=1 (`>` や `<` のインデントにタブを用いるかどうか) + - 既定のインデントの幅は 8 から 4 に変更 + +## バグ修正 + - vi-mode: 挿入モードに繰り返し回数を指定したとき `ESC ?` も一緒に繰り返されていたバグの修正 + - vi-mode: オペレータ `g?` が動かなくなっていたのを修正 + - vi-mode (nmap `/` `?`): 検索対象の入力中に `C-c` してもキャンセルされないバグの修正 + - vi-mode (xmap `r` (visual char/line)): 全体を置換したものが選択範囲に挿入されていたバグの修正 + - vi-mode (xmap `$`): 行末で `$` をしたときに表示が更新されないバグの修正 + - vi-mode (motion `0`): オペレータを認識していなかったバグを修正 + - isearch: 一度一致したら同じものに一致し続けるバグを前回の `/` `?` `n` `N` 対応の際に埋め込んでいたので修正 + - complete: `complete -F something -D` で登録されている補完関数が正しく実行されていなかったのを修正 + - prompt: PROMPT_COMMAND によって設定された PS1 を拾っていなかったバグを修正 + - textarea: 端末の下部で複数行編集時に `C-z` (`fz`) すると描画高さを正しく確保できていないバグの修正 + +## 動作変更 + - vi-mode (operator `<` `>`): Visual block での正しい振る舞い + - vi-mode (nmap `:` `/` `?`): 文字列入力中に空文字列で DEL or C-h することでキャンセルできるように修正 + - vi-mode (nmap `J`, `gJ`): 引数に対応 + - vi-mode (nmap `p`): 最後の行で挿入するときに余分な行が入らないように修正 + - vi-mode (xmap `Y` `D` `R`): 記録するビジュアルモードの種類を修正 + - lib/vim-surround.sh: タグ名入力中に '>' で確定するように修正 + - widget (.SHELL_COMMAND): 実行しないコマンドに色がついているのはややこしいのでグレーアウトする様に変更 + +## 他の変更 + - magic-space: 空白を挿入してから履歴展開していた順番を逆転 + +---- + +# 2015-03-06..2017-10-09 (Git Commit Log) + +## 2017-10-09 +* keymap/vi: support specialized handling of keys for cmap + - vi (nmap / ?): treatment of C-h and DEL on input of search targets + - vim-surround.sh (nmap ys cs): treatment of > on input of tag names + +## 2017-10-07 +* keymap/vi_xmap: add tentative text object implementation +* lib/vim-surround: accept user input of tag names with the replacement being t, T, < +* keymap/vi_command: support search / ? n N + +## 2017-10-05 +* keymap/vi_command: fix behavior of yy, dd, D, etc. on the last line with count arg +* keymap/vi_xmap: support x C D X R Y +* keymap/vi_xmap: support r s +* keymap/vi-command: support : and few commands +* ble-core: fix a bug that conditions for assotiative arrays are inverted + +## 2017-10-04 +* [refactor] ble-edit (ble-edit/render -> ble/textarea): support "ble/textarea#{save,restore,clear}-state" +* [refactor] ble-edit (text/update/positions -> ble/textmap): support any time updates of text positions +* keymap/vi_command: support _ g0 g g^ g$ g gm go g_ ge gE +* check: fix "local lines=()" in vi_digraph.sh and update "check" +* (ble-highlight-layer:region): fix a bug that the "region" face is sometimes applied to intervals between selections + +## 2017-10-03 +* keymap/vi (visual mode): support previous selections +* keymap/vi (nmap p, P for block): convert HTs under inserting points to spaces +* (ble-decode-key/dump): fix a bug that pathname expansions internally occurred +* ble-core: add ble/string#split-lines +* keymap/vi (visual block): improve performance of block extraction +* keymap/vi_command (linewise operator d): go to the previous line on deleting the last line +* keymap/vi (operator d c g~ gu gU g?): support block +* keymap/vi (nmap p, operator y): support block + +## 2017-10-02 +* keymap/vi_xmap: support count arg for operators +* keymap/vi_command: fix a bug that linewise < > operators produce an error +* keymap/vi_command: perform EOL fix on history traveling with normal mode +* keymap/vi_xmap: support block selection + +## 2017-10-01 +* keymap/vi_xmap: support visual mode swithing +* keymap/vi: support visual mode + +## 2017-09-28 +* ble-edit: add a condition to accept-single-line-or +* keymap/vi_command: support gj gk + +## 2017-09-27 +* ble-edit: restore BASH_REMATCH +* ble-edit: do not execute pasted multiline texts +* ble-edit: support scrolling +* bleopt: implement value checking on assignment + +## 2017-09-24 +* ilb/vim-surround.sh: do not refer bleopt "vim_surruond_{char}" for digit replacement char +* keymap/vi: show configurable string (defaulted to be ~) on the normal mode +* keymap/vi_command: support % N% +* keymap/vi_command: support indentation for o O +* keymap/vi_command: reimplement text object is as +* keymap/vi (linewise-range.impl): fix a bug that the line ranges are reverted, fix behavior to go to nol + +## 2017-09-23 +* keymap/vi_command: support text object ip ap +* keymap/vi_command: support text object is as +* keymap/vi_insert: support indentation for C-m, C-h, DEL +* ble-edit: erase garbage input echo during initialization of ble.sh +* ble-edit (bleopt char_width=emacs): fix a bug that U+2000 - U+2600 are always treated as width 1 +* keymap/vi: fix a bug that selection is not cleared on entering the normal mode during isearch + +## 2017-09-22 +* keymap/vi_command (r, gr): highlight on waiting replacement +* keymap/vi_command: support text object it at + +## 2017-09-20 +* ble-edit/exec: fix handling of $? and $_ and add a workaround for "set -o verbose" + +## 2017-09-18 +* lib/vim-surround: support configurable replacements with bleopt vi_surround_45:=tmpl vi_surround_q:=tmpl +* (bleopt): support the form "var:=value" which skips existence checks of variables +* lib/vim-surround: support ds cs +* ble-decode: fix stty settings for command execution +* keymap/vi_omap: fix mode transition from vi_omap to vi_insert +* [m] lib/vim-surround: remove redundant codes + +## 2017-09-17 +* keymap/vi (text object i[bB]): exclude newlines around the range and transform to linewise +* [m] keymap/vi (text object i"): behave the same as a" with arg >= 2 specified +* [m] keymap/vi: rename functions +* keymap/vi_insert: change the default of C-k to kill-forward-line +* keymap/vi_command: support digraphs for arg of f, F, t, T, r, gr +* keymap/vi: support digraph +* (ble-bind): support "ble-bind -@f kspec command" +* (ble-decode-kbd): fix a bug that keys "*" and "?" cannot be properly encoded + +## 2017-09-16 +* keymap/vi_command (operators): fix a bug that arg is cleared before the use +* lib/vim-surround: support b B r a C-] C-} as replacements +* keymap/vi: rename operator flag for < and > +* (ble/widget/self-insert): explicitly return 0 +* ble-decode (ble-decode-key/.invoke-command): propagate exit status of widgets +* keymap/vi_omap: decompose M-* +* add ilb/vim-surround.sh, support operator "ys" and "yss" +* keymap/vi: add new keymap "vi_omap" + +## 2017-09-15 +* keymap/vi_command: support operators < > +* keymap/vi_command: support g~~ guu gUU g?? +* keymap/vi_command: handle meta flags of input keys +* keymap/vi_command: support ~ +* keymap/vi_command: fix the text object "aw" +* keymap/vi_command: rename widgets + +## 2017-09-13 +* ble-edit/info: fix cursor position calculations in rendering +* (ble-form/panel#set-height-and-clear.draw): fix to add lines on an increased height +* keymap/vi_command: support text objects [ia][][{}()<>bBwW'"`] + +## 2017-09-12 +* add ble-form.sh and introduce ble-form/panel +* ble-edit: rename functions +* keymap/vi_command: support text object iw +* ble-edit/info: show default contents at the end of bind +* ble.pp: fix PATH if standard utilities are not found on load +* keymap/vi_command: add operators g~ gu gU g? +* keymap/vi_command: refactor ydc operators +* ble-decode (ble-bind): fix check of redundant "ble/widget" prefix + +## 2017-09-11 +* ble-edit (ble/widget/clear-screen): show info after the clear +* keymap/vi_command (C-o): fix cusor positions after first-non-space commands +* keymap/vi: fix the initial position of "-- INSERT --" +* keymap/vi_command: support C-o +* ble-core: add string functions +* keymap/vi_insert: change mode names on "insert" +* keymap/vi: show current modes in the info area +* ble-edit: support ble-edit/info/set-default +* ble-edit: clear info on exit +* memo.txt: add comments from @B-bar +* ble-decode: check existence of keymaps + +## 2017-09-10 +* keymap/vi_command: fix C D +* keymap/vi_command: support arg for insert modes +* ble-decode: fix ble-decode-key and support __before_command__ and __after_command__ +* keymap/vi_command: update bindings and support z{char} clear screens + +## 2017-09-09 +* keymap/vi_command: fix R and support gR +* keymap/vi_command: support f F t T ; , +* ble-edit: suppress unnecessary history loads on history-next +* ble.pp: support loading ble.sh from inside of functions +* keymap/vi_command: support J gJ o O +* fix leak variables +* keymap/vi_command: support r gr + +## 2017-09-08 +* keymap/vi_command: fix mode change widgets and support gI +* keymap/vi_command: support G H L gg +* keymap/vi_command: fix behavior of [dcy][-+jk] +* keymap/vi_command: update memo.txt and support K +* keymap/vi_command (RET, C-m): fix to behave as + if the line contains LF +* keymap/vi_command: support w W b B e E + +## 2017-09-07 +* keymap/vi_command: support s S +* ble-edit: rename ble-edit/text/getxy -> ble-edit/text/getxy.out +* keymap/vi_command: support C-h DEL SP +* (ble/widget/vi-command/{forward,backward}-line): fix +* keymap/vi_command: return to insert mode on accept-line +* keymap/vi_command: support | +* keymap/vi_command: clear arg on mode changes +* keymap/vi_command: support I +* keymap/vi_command: support Y D C +* keymap/vi_command: support x X +* keymap/vi_command: support p P +* keymap/vi_command: check unknown flags +* keymap/vi_command: support A +* keymap/vi_command: add basic bash operations +* keymap/vi_command (+ -): travel history +* keymap/vi_command: support ^ + - $ +* keymap/vi_command: fix behavior of "yh" and "yl" +* keymap/vi_command: support dd yy cc 0 +* ble-edit: partial revert 35098f0 where necessary ble-edit/history/load calls were removed +* ble-edit (ble/widget/{for,back}ward-line, etc): fix a bug that the destination cursor pos was based on possible old layout +* keymap/vi.sh: support hjkl +* ble-edit: remove redundant ble-edit/history/load calls +* (ble/widget/.bell): fix exit status + +## 2017-09-06 +* check: add check codes for bashbug workarounds +* (ble-edit/text/get*): check if the cached text positions are up to date + +## 2017-09-05 +* keymap/vi: support mode switching +* (ble/widget/.goto-char): simplify +* (ble-edit/load-keymap-definition): workaround for bash-3.0 +* (ble-decode-key): accept multiple keys +* ble-edit: support the value bleopt_default_keymap=vi + +## 2017-09-04 +* add keymap/vi.sh and switch keymap on editing mode change +* ble-decode: split and refactor external settings +* ble-decode: support bleopt_default_keymap=auto + +## 2017-09-03 +* ble.pp: remove the check enforcing "set -o emacs" +* ble-decode (ble-decode-{attach,detach}): support attached editing modes +* ble-decode: update spacing of an awk script +* ble.pp: fix "set -o emacs" checks +* ble-syntax: fix a bug that here strings are interpreted as here documents +* complete.sh: suppress error messages on internal compgen calls + +## 2017-08-30 +* ble-edit: check editing mode + +## 2017-08-19 +* cmap/default.sh: disable modifier keys "CAN @ ?" which is ambiguous with "C-x C-x" +* ble-edit: support "bleopt delete_selection_mode=1" + +## 2017-06-09 +* ble-syntax: workaround for the bash-4.2 arithmetic bug resulting in segfaults + +## 2017-05-20 +* ble.pp: guard double ble-attach + +## 2017-04-21 +* bind.sh: bash-4.4 workaroud: fix a bug C-x ? is not bound + +## 2017-03-17 +* README: update color settings and translate tips +* README: add a hint on editing multiline commands + +## 2017-03-16 +* (ble-color-gspec2g): change to recognize 0 padded color indices as decimal numbers +* README: bump release 0.1.7 + +## 2017-03-15 +* README: update heading syntax of GitHub flavored markdown + +## 2017-03-13 +* suppress error messages caused by incorrect user LC_*/LANG values + +## 2017-03-06 +* complete: fix a bug that backquotes, newlines and tabs in completed words were not escaped + +## 2017-03-05 +* ble.pp ($_ble_init_original_IFS): \minor, fix unset +* ble-core.sh ($ble_util_upvar_setup): add "local ret" declartion +* (ble-syntax:bash/ctx-heredoc-word): use ctx-redirect to read keyword of here documents +* ble-color: move deprecated "ble-highlight-layer:adapter" codes to layer/adapter.sh as a sample +* save/restore IFS to protect ble functions from user's IFS +* memo.txt: assign numbers of the form "#D????" to old items +* (ble-syntax:bash): :new: support "select var in ..." +* (ble-syntax:bash): fix a recent bug that semicolons after "for (())" was not allowed +* (ble-syntax:bash): :new: support here documents + +## 2017-03-04 +* (ble-syntax:bash): fix a bug that semicolons are not allowed after "}", "fi", "done", etc. +* (ble-syntax:bash): support the construct with the form "for name do ...; done" +* (ble-syntax:bash): accept "do" immediately after "for (())" without semicolons +* Makefile: add a prerequisite "install" +* (ble-edit-attach): output CR before showing prompt + +## 2017-03-02 +* (ble-syntax:bash): allow `then, elif, else, do' after `}, etc.' +* (ble-syntax:bash): improve checks of quotes in parameter expansion and arithmetic expansion + - change so that quotes are processed always in the syntax level + - introduce new nest-types, ntype='$((' and ntype='$[', for CTX_EXPR (arithmetic expressions) + - introduce a new nest-type ntype='NQ(' to support nesting in quote-removal-less contexts + - fix so that quotes '...' in parameter expansions such as `${var#text}' are always enabled +* \clean: format memo.txt and document comments, etc. +* (ble-syntax:bash): add a work around of a bash-4.2 bug in arithmetic expressions + +## 2017-03-01 +* (ble-edit/info/draw-text): change to truncate overflow contents +* ble-edit: fix bugs that line representation is broken at the last line of terminals + - \fix, use IND to ensure size of the edit area + - \fix, clear _ble_line_{beg,end}{x,y} on newline + - ble-edit.sh: add a function ble-edit/draw/put.ind + - ble-edit.sh: add a function ble/widget/.insert-newline + - (ble/widget/redraw-line): \clean, 無駄な _ble_line_cur 初期化を削除。ble-edit/render/invalidate を呼び出すだけで充分。 + - (ble-edit/exec/.adjust-eol): \clean, 無駄な _ble_line_x=0 _ble_line_y=0 を消去。元からそうなっている前提である。 + - (ble-edit/exec/.adjust-eol): \fix, 直接 stderr に出力していたのを ble/util/buffer に出す様に変更。 +* (ble-syntax:bash): support `} }', etc. +* (ble-syntax:bash): :new: support `for ((;;)) { ... }' +* (ble-syntax:bash): support `((echo)>/dev/null)' and `$((echo)>/dev/null)' +* complete: support completion of "in" keywords for "for var in"/"case arg in" +* (ble-syntax:bash): :new: support `for var in ...' and `case arg in' +* (ble-syntax:bash/ctx-command): [refactor] split into functions, use arrays for ctx settings +* (ble-syntax:bash): fix a bug that redirection accepted comments +* (ble-highlight-layer:syntax): fix a bug that causes error on a word beginning with # + - Note: words beginning with '#' can be formed when `shopt -u interactive_comments' +* (ble-syntax:bash): fix a bug that beginning of process substitutions splitted words + +## 2017-02-28 +* ble-edit: [refact] rename ble/edit/prompt/update/update-cache_wd -> ble-edit/prompt/update/update-cache_wd +* ble-edit: [refact] rename ble/widget functions +* ble-edit: [refact] rename ble-edit functions +* ble-edit: use ble/util/buffer to suppress flicker +* ble-core: add variable "ble_util_upvar{,_setup}" + +## 2017-02-25 +* (ble-syntax/parse/shift): fix a bug that caused duplicated shifts +* (ble-syntax/print-status/.dump-arrays): add consistency checks + +## 2017-02-14 +* ble-syntax.sh: fix a bug that attempts "continue" out side of loop + +## 2017-02-13 +* ble-edit (ble/widget/isearch): fix a bug that isearch does not work in bash-4.4 + +## 2016-12-21 +* ble-edit (exec): default value of the parameter "$_" is "$BASH" +* ble-edit (exec): support parameter "$_" + +## 2016-12-06 +* ble-core (ble/string#split): add a work around for "shopt -s nullglob" + +## 2016-11-08 +* Makefile: detect correct path of gawk for mwg_pp.awk + +## 2016-11-07 +* ble-core.sh: add a work around of bashbug to accept inputs of hankaku kana + +## 2016-09-20 +* (ble/util/sleep in Cygwin): check parent processes of blocking process substitutions + +## 2016-09-16 +* README: update +* (ble/util/upvar): fixed a bug that array elements cannot be exported + +## 2016-09-14 +* ble-core: add a function ble/util/upvar +* _ble_edit_str.replace: improve error correction of _ble_edit_ind and _ble_edit_mark + +## 2016-09-11 +* (ble/widget/isearch/cancel): return to the original position, i.e. restore _ble_edit_{ind,mark} +* (ble-syntax:bash/check-dollar): fixed a bug that isolated dollars generate syntax errors +* (ble/widget/accept-and-next): fixed a bug that the next line is not loaded on accepting the last histentry +* ble.sh (ble-edit/history/add): fixed a bug that erasedups is performed even if a new entry is rejected by ignorespace +* isearch: fixed a bug that words in the current line is not matched incrementally + +## 2016-08-24 +* complete.sh: recognize dangling symbolic links in completion and syntax-highlighting + +## 2016-08-08 +* term.sh: fixed a bug that xenl cap was always disabled. + +## 2016-08-07 +* ble-edit/prompt: improved admin privileges checks on Cygwin + +## 2016-08-05 +* (ble-edit/history/add): fixed a bug that history entries are not registered after certain operations. +* syntax: fixed a bug that causes an fatal error for param expansions with offset in quotes like "${v:1}" +* (ble/util/sleep): do not use /dev/tcp which generates error messages on Win10 Cygwin. + +## 2016-07-16 +* (ble/util/array-push): \refactor, rename, support multiple elements to append. + - rename ble/util/array-push -> ble/array#push + - rename ble/util/array-reverse -> ble/array#reverse + +## 2016-07-15 +* complete: enable completion of variable names in "..." and ${...}. +* complete.sh: insert '=' after the completion of variable name of assignment. + - (ble/widget/complete): + completion-context にて source の引数をコロン区切で指定できるように拡張する。 + - ble-complete/source/variable: + 引数に応じて確定時に挿入する接尾辞を選択する様に変更する。 + - ble-syntax.sh (ble-syntax/completion-context): + 文脈に応じて variable 候補源に引数 '=' を指定して、補完確定時に何を挿入するべきか指定する。 +* complete.sh: fixes and clean up; a new fn ble/string#split. + - ble-core.sh: a new function ble/string#split to replace "GLOBIGNORE=* IFS=... eval 'arr=(...)'". + - complete.sh: (ble-complete/.fignore/filter): fixed a bug that local variable pat was leaked. + - complete.sh: (ble/widget/complete): fixed a bug that "shopt -s force_fignore" was ineffective. + +## 2016-07-14 +* (ble/util/sleep): add fallbacks to sleepenh and usleep for bash-3.*. +* isearch: fixed a bug that a new range overlapped with the current match cannot be matched incrementally. +* (bleopt): fixed a bug in printing variables. + +## 2016-07-09 +* (ble/history/add): work around for bash-3.0 to add history entries to bash command history. +* (ble/history/add): fixed a bug that command history was always disabled under bash-3.2. + +## 2016-07-08 +* ble-syntax.sh, complete.sh (shopt -q autocd): fixed a bug that error messages were output to stderr on completions in bash-3.*. +* ble-edit (prompt): :new: support shell variable PROMPT_DIRTRIM for PS1 instantiation. +* ble-edit: Now, the history index \! in PS1 is the index of the editted line. + - isearch: also, the position shown while isearch is changed to the history index. + +## 2016-07-07 +* README: move language options to the top. add icons of the languages. +* update README and LICENSE +* ble-edit.sh (ble-edit/isearch/backward): improve the performance (work around for slow bash arrays). + +## 2016-07-06 +* ble-edit.sh (_ble_edit_history_edit): changed to hold the whole editted history data. +* ble-syntax: glob patterns are not active in variable assignments. +* ble-edit.sh: 修正: ジョブ状態の変更を標準出力に確実に出力 + - fixed a bug that job state changes are not output when PS1 contains '\j'. + - fixed a bug that the changes are not output immediately. +* minor fixes in visible-bell and check-stderr. + - ble-core.sh (ble-term/visible-bell): fixed a bug in subsecond treatment. + - ble-edit.sh (.ble-edit/stdout/check-stderr): fixed a bug that lines without LF were not processed. + +* (ble/util/joblist): use ble/util/joblist for internal usage of jobs. + - ble-core.sh (ble/util/joblist): bugfix: + 誤って _ble_util_joblist_jobs を _ble_util_joblist_list として使用している箇所が 4 箇所。 + - ble-core.sh (ble/util/joblist): bugfix: + - (直前のジョブ) や - (一つ前のジョブ) の変化も変化として検知していた。 + - これはジョブ状態の本質的な変化とは言いがたいので無視する。 + - ble-core.sh (ble/util/joblist): bugfix: add ble/util/joblist.clear + bash 自身によってジョブ状態の変化が報告された後に、 + 二重に状態変化が報告される場合があるので、その様な場合にはキャッシュを消去する。 + - ble-edit.sh の各 jobs を呼び出すところで、ble/util/joblist を代わりに呼び出す。 + - ble-syntax.sh, ble-color.sh で jobs を使用してジョブの存在確認している箇所では、 + 先に ble/util/joblist を呼び出してジョブの状態変更を確認してから目的の jobs 呼び出しを行う。 +* ble-core.sh: add a new function ble/util/joblist. + +## 2016-07-05 +* ble-core: add option bleopt_stackdump_enabled + - bleopt_stackdump_enabled が非零の値に設定されている時にだけ + stackdump を出力する様にする。既定では 0 (出力しない) とする。 + +## 2016-07-04 +* ble-decode.sh (ble-decode-attach): fixed a bug that makes C-{u,v,w,?} ineffective after the second ble-attach. + - 2回目以降の ble-attach でも ble-decode-bind/uvw が動作する様に + ble-decode-attach で source "~.bind" した直後に _ble_decode_bind__uvwflag をクリアする。 + +## 2016-06-27 +* ble-core.sh ($_ble_base/cache): move to _ble_base_cache="$_ble_base/cache.d/$UID" for user separation. +* ble-core.sh ($_ble_base_tmp): change to use /tmp/blesh/$UID if it is available. + - 今迄は ble.sh と同じディレクトリに一時ファイルを配置していた。 + しかし、ble_util_assign.tmp などのファイルは速度を考えれば tmpfs (RAM上) に配置したい。 + 従って、一時ファイルは /tmp の上に配置するように変更する。 +* ble-core.sh: add ble/util/sleep to provide subsecond sleep. + +## 2016-06-25 +* ble-edit.sh (_ble_edit_str.replace debug codes): resume from wrong state. + +## 2016-06-23 +* ble-core.sh (ble/util/array-reverse): improve performance. + +## 2016-06-22 +* ble-edit/isearch: show progress of search. + +## 2016-06-19 +* ble-edit/isearch: ble/widget/isearch/prev cancel a task in que, ble/widget/isearch/accept is not effective while a search. + - ble/widget/isearch/prev: 現在実行中のタスク (_ble_edit_isearch_que) がある場合には一つずつキャンセルする。 + - ble/widget/isearch/accept: 現在実行中のタスクがある場合には bell を鳴らすだけで動作をスキップする。 + - ble-edit/isearch/.goto-match: 一致があった場合には is-stdin-ready でも強制的に描画を実行する。 +* ble-edit/isearch: check is-stdin-ready on history search to suspend. + +## 2016-05-21 +* update README.md for v0.1.5 +* ble-edit.sh: bugfix, incorrect _ble_edit_ind caused by the inconsistensy of history/isearch targets. + - _ble_edit_history を履歴検索して _ble_edit_history_edit をロードしていた事による _ble_edit_ind 不整合 + これにより、dirty-range の不整合が生じエラーが発生していた。長年の謎のバグがこれで潰れたと思われる。 + +## 2016-04-07 +* ble-syntax.sh (ble-syntax/parse/shift.impl2): bugfix 制御構造の欠陥による shift 漏れ。 + +## 2016-01-24 +* ble-syntax.sh: \debug add debug codes for dirty-range bug + - ble-edit.sh: dirty range checks + - ble-syntax.sh (ble-syntax/parse): remove readonly flag of `beg' and `end' for dirty-range bug + +## 2015-12-30 +* modify README: use -O option for curl; release v0.1.4. + +## 2015-12-26 +* (ble-color/faces): preserve orders of addhook-onload, and ble-color-{def,set}face. + - ble-color/faces 初期化前に呼び出した ble-color/faces/addhook-onload, + ble-color-defface, ble-color-setface を独立に記録していた為、 + 実際に呼び出された順序と異なる順序で処理が実行されてしまっていた。 + 記録を一つの配列 _ble_faces_lazy_loader にまとめ、順序が保存される様にした。 + +## 2015-12-25 +* (ble-color) \change ble-color-{def,set}face の処理も遅延する。 +* functions/getopt.sh: \add description. + +## 2015-12-24 +* (ble-syntax:bash): :new:, support option `-p` for keyword `time`. +* (ble-syntax:bash): \new, support `a=([key]=value)` and `a+=([key]+=delta)`. + * (ble-syntax): \new local variable `parse_suppressNextStat` in ble-syntax/parse. + * (ble-syntax:bash): \bugfix, correct resume for `var+`, `arr[...]+` -> `var+=`, `arr[...]+=`. + * (ble-syntax:bash): \new, support `a=([key]=value)` and `a+=([key]+=delta)`. +* (ble-syntax:bash): \new context CTX_CASE. +* (ble-syntax:bash): \new CTX_COND{X,I}; \change unexpected '(' is treated as extglob '@(' instead of sub-shell '('; + * ble-syntax.sh: `CTX_VAL{X,I}` から `CTX_COND{X,I}` を分離。 + * ble-syntax.sh: コマンド中に現れる '(' を extglob の括弧として取り扱う事にする。 + 今迄は暫定的に sub-shell として取り扱っていたが、 + エラーが多く出てうるさいのでエラーの少ない extglob 括弧として取り扱う事にする。 +* ble-edit.sh: \bugfix histexpand condition [[ -o histexpand ]] inverted. + * \bugfix 履歴展開が効かなくなっていた。 + 条件判定の誤りだった: [[ -o histexpand ]] → [[ ! -o histexpand ]] + * \bugfix 履歴展開に失敗した時に : が実行される。 + 履歴展開が失敗すると history -p は標準出力に何も出力しないためであった。 + 失敗した時は echo "$BASH_COMMAND" により手動で出力する。 +* (ble-syntax:bash): \support shopt -s extglob; \bugfix error on {delimiter after redirect,'<' redirect}; + * extglob 対応: `CTX_GLOB`, `ATTR_GLOB`, `ctx-glob`, `check-glob` 追加。 + * \bugfix redirect 直後に redirect/delimiter があった時に解析データ書き込み違反。 + * \cleanup: 共通の正規表現の整理: + `$_ble_syntax_bash_rex_spaces`, + `$_ble_syntax_bash_rex_IFSs`, + `$_ble_syntax_bash_rex_delimiters`. + * \bugfix `$_ble_syntax_bash_rex_redirect`: < が抜けていた。 + +## 2015-12-23 +* (ble-syntax:bash): special treatment of arguments of `declare`. + * (ble-syntax:bash): declare, typeset, local, export, alias コマンドの引数を文法的に特別に扱う。特に配列構文 =() を許容する。 + その為に新しい文脈値 `CTX_ARGVX`, `CTX_ARGVI` を追加する。 + * (ble-syntax:bash): `CTX_ARGVI` に対する補完候補は変数名。等号 '=' 以降の部分についてはファイル名の補完候補を列挙する。 + * (ble-syntax:bash): 通常の代入構文における配列構文の動作を変更。 + 今迄は a=(1 2 3)echo などとすると a=(1 2 3) を配列代入と解釈し echo の部分をコマンドと解釈する様にしていた。 + その為に配列構文の nest-pop 時にすぐに単語を抜けて cxt==CTX_CMDXV になる様に構成していた。 + しかし、実際の bash の動作を確認してみると、a=(1 2 3)echo は a='(1 2 3)echo' の様に、全体が代入文の右辺と解釈される様である。 + 実際の bash の動作に合わせて、nest-pop 時に特別な動作を特にしない様に変更した。 + +## 2015-12-21 +* (ble-syntax:bash): 算術式終了条件修正、bash-3.0 で += 無効; (completion-context): a+= 直後の補完候補生成。 + * ble-syntax.sh (ble-syntax:bash): 算術式の終了条件を修正する。 + $((...)) ((...)) の中では '(', ')' を数えて終了判定を行う。 + $[...]、${arr[...]} arr[...]= の中では '[', ']' を数えて終了判定を行う。 + ${var:...:...} では '}' が来たらすぐに終了する。 + * ble-syntax.sh (completion-context): a+= の直後でも補完候補生成を行う。 + * ble-syntax.sh (ble-syntax:bash): disable += under bash-3.1. +* ble-edit.sh: bugfix failure of catch C-d in bash-3.0. + +## 2015-12-20 +* (ble-highlight-layer:syntax): color of special files, permission of files in redirection. + - ble-syntax.sh: bugfix of assertion test in ble-syntax/parse/tree-append. + - ble-syntax.sh (ble-highlight-layer:syntax): color filenames of block device, character device, pipe, and socket. + - ble-syntax.sh (ble-highlight-layer:syntax): redirection: check permissions. +* (ble-syntax:bash): bugfix, tree-structure corruption on edit of array subscripts in array-element assignment. + - ble-syntax.sh: 配列添字の書き換え時に解析木の破壊が起こる。 + 配列添字の終了 ']=' において nest-pop を先頭位置で行っていた。 + これが為に、過去の解析結果を書き換えている事になっていた為に、 + shift の際に設置した情報が消滅したりしていた。 +* ble-edit.sh: add support `set +o history`; ble-syntax.sh: check file existence on '<' redirection. + - ble-edit.sh: add support `set +o history` + - ble-syntax.sh (ble-highlight-layer:syntax): check filename of `<` redirections. + - ble-syntax.sh (constants): refact, + definition of `local rex_redirect` -> global `_ble_syntax_bash_rex_redirect`. + rename `_BLE_SYNTAX_CSPACE` -> `_ble_syntax_bash_cspace`. + - ble-edit.sh: refact, rename functions `.ble-edit[./]history[./]*` -> `ble-edit/history/*`. +* complete: 候補生成箇所の追加・修正、コマンド補完候補としてサブディレクトリも列挙 + - ble-syntax.sh (complete): bugfix, 単語の間の空白で complete を実行しようとしても候補が生成されなかった。 + - ble-syntax.sh (complete): generate filenames after `VAR='. + - ble-syntax.sh (complete): generate filenames just after the redirection. + - complete.sh: コマンドの補完候補として現在のディレクトリのサブディレクトリも列挙する様に修正する。 + サブディレクトリにある実行属性のファイルを実行したい場合がある為である。 + +## 2015-12-19 +* complete.sh: support `FIGNORE`, `shopt -s force_fignore`. + - Makefile: bugfix, remove `ble-getopt.sh` from the required files to generate ble.sh. + - complete.sh: support `FIGNORE` and `shopt -s force_fignore`. +* functions/*: move unused file ble-getopt.sh to `functions/`. Add new impl of getopt. +* ble-syntax.sh (ble-syntax:bash): redirections: bugfix '<<<', support '>|', overwrite check of files, etc. + - ble-syntax.sh (ble-highlight-layer:syntax): Support `set -o noclobber`; Check overwrites of target files of redirections for '>', '&>', and '<>' redirect. + - ble-{core,decode,edit}.sh, bind.sh, term.sh, emacs.sh: change redirection '>' -> '>|' for the case of the noclobber option on. + - ble-syntax.sh (ble-syntax:bash): support the redirect using `>|`. + - ble-syntax.sh (ble-syntax:bash): bugfix false syntax error of `<<<`. + - ble-syntax.sh (ble-syntax:bash): bugfix redundant skip on unexpected termination of redirect by an end of command or another redirection. + - ble-syntax.sh (ble-syntax:bash): bugfix, do not allow newline after the redirection introducers. +* ble.pp, ble-core.sh: Check and modify dependencies on external commands. + - ble.pp (ble/.check-environment): Remove tput (POSIX UP option) which is not necessarily required. + - ble-core.sh (ble-term/visible-bell): Add a function `ble/util/getmtime` to get modified time of files in a compatible way. + - ble-edit.sh (ble/widget/command-help): Select available pager from any of $PAGER, less, more, and cat. +* ble-syntax.sh: syntax: quotations in words in parameter expansion (shopt -u extquote, etc.). + - ble-syntax.sh: support single quotation in parameter expansion. + - ble-syntax.sh: support shopt -u extquote. +* clean up & minor behavior change: Check bash opts --{posix,noediting,restricted}, Unset mark on accept-line. + * bug fix + - ble-syntax.sh (ble-syntax:bash/extract-command/.construct-proc): remove a debug code which prints the message "clear words". + * minor behavior change + - ble-edit.sh (ble/widget/accept-line): redraw without mark. + - ble.pp (startup check): do not load ble.sh for bash --posix, --noediting, or --restricted. + * clean up + - ble-decode.sh (ble-decode-byte:bind/EPILOGUE): use ble/util/is-stdin-ready instead of the direct use of `read`. + - ble-core.sh (ble/util/is-stdin-ready): use LANG instead of LC_ALL. + - ble-edit.sh, ble-syntax.sh: use [[ -o histexpand ]] rather than [[ $- == *H* ]]. + - ble-syntax.sh (test): remove unused functions `.ble-shopt-extglob-push`, and `.ble-shopt-extglob-pop` for test. + - ble-edit.sh: remove old complete functions: + - .ble-edit-comp.initialize-vars + - .ble-edit-comp.common-part + - .ble-edit-comp.complete-filename + - ble/widget/complete + - ble/widget/complete-F + - ble-syntax.sh, complete.sh: no need of redirection for `shopt -q optname`. + +## 2015-12-09 +* Refactoring ble-edit.sh/ble-line-prompt. + * .ble-line-prompt -> ble-edit/prompt. + * `_ble_cursor_prompt`, `_ble_line_prompt` -> `_ble_edit_prompt`. +* Refactoring ble-core.sh, ble-color.sh, cmap/xterm.sh. + * ble-core.sh: .ble-text.* -> ble/util/*. + * ble-color.sh: .ble-color.* -> ble-color/.*. + * cmap/xterm.sh: .ble-bind.function-key.* -> ble-bind/cmap:xterm/*. +* Refactoring ble-decode.sh. + * ble-core.sh: .ble-term.{visible,audible}-bell -> ble-term/{visible,audible}-bell. + * ble-decode.sh: .ble-stty.* -> ble-stty/*. + * ble-decode.sh: .ble-decode-* -> 適切な名称に変更。 +* Refactoring and clean up. + * ble-edit.sh, etc: 'ble-edit+' -> 'ble/widget/. + * 'ble-edit.sh: ble-edit/exec 関数名整理。 + * ble-decode.sh: ble-decode-byte 関数名整理、ble-edit 依存性分離。 + * README-ja_JP.md: 日本語説明修正。 + * README.md: 英語修正。 + * ble-syntax.sh: コードコメント @fn -> 関数 に統一。 + +## 2015-12-06 +* ble-core.sh: Add function ble/util/cat to replace /bin/cat. + - ble-core.sh: 関数 ble/util/cat。command cat の単純な呼出と同じ機能を builtin read で実装。 + - ble-decode.sh (ble-bind --help): 外部コマンドの cat を呼び出していたが、bash の組込コマンドで実現できるので置き換え。 + - README.md: gmake/make について説明を追加。 +* Update README-ja_JP.md +* ble-bind: New option `-L, --list-functions`, ble-color.sh bugfix initialization of faces:region,disabled,overwrite_mode. + - ble-color.sh: bugfix, 色初期化 (region disabled overwrite_mode) 遅延ロードに登録していなかった。 + - ble-decode.sh (ble-bind): New option `-L, --list-functions` to list edit functions. + +## 2015-12-03 +* Changed default value of bleopt_char_width_mode from `emacs` to `east`. +* Update README-ja_JP.md. +* Add README-ja_JP.md. 日本語の説明。 +* optimization: lazy init of faces (ble-{syntax,color}.sh), removal of temporary files (ble-core.sh). + * ble-syntax.sh, ble-core.sh: lazy initialization of `_ble_faces_*`. + * minor: modify messgese: initialization message, the header of the script ble.sh. + * ble.pp: Add pp switch `measure_load_time` to identify the initialization bottle neck. + * ble-core.sh (`_ble_base_tmp.wipe`): optimization, use parameter expansion instead of regex captures. +* Support here string, shopt -q progcomp; Bugfix ble-syntax/parse/nest-equals. + * ble-syntax.sh: support here string. + * ble.htm: comment out outdated descriptions. + * ble-syntax.sh (ble-syntax/parse/nest-equals): bugfix, 前回の bugfix で onest[3]<0 の場合を考えていなかった。 + * complete.sh: shopt -q progcomp によるプログラム補完の有効・無効の切り替え。 +* update version numbers. +* ble-syntax.sh (ble-syntax/parse/nest-equals): fatal bugfix, misjudge on nest equality test causing nest structure corruption. + * Note: _ble_syntax_nest の要素に含まれている nest 開始位置は相対位置で記録されているにも拘わらず、絶対位置の変数に直接代入していた事が原因であった。 + * 他 ble-syntax.sh, ble-color.sh: compatibility fix., fgrep to command grep -F. +* README.md: correct download links. +* `*.sh`: Add `command` for external command execution. +* (ble-edit/stderr for bash-3.0): Add ignoreeof-message.txt for C-d message i18n. +* `*.sh`: New marker `__ENCODING__` for 文字コード依存部分 + +## 2015-11-30 +* complete.sh (ble-complete/source/argument): minor bugfix, default behavior using comp_opts exported by func .../.compgen. + * 他 ble.pp: check chmod. +* Makefile: a phony target `dist`. +* memo.txt: todo 整理. +* complete.sh: bugfix, completion doesn't work on an argument without complete -D spec. +* ble-edit.sh (ble-edit+isearch/next): bugfix, didn't match locally on self-insert of forward isearch. +* ble-decode.sh (generate-source-to-unbind-default): bugfix, need of LANG=C. + * LANG=C を設定しないと bind -sp の出力に変なバイトが含まれている為に解釈に失敗する。 + (utf-8 の様な ASCII 文字を含まない様な文字コード体系の場合にはこれで問題ないが。 + memo.txt に Note(2015-11-30) として追加する。) +* Update README.md +* ble-edit.sh: remove dependency on GNU awk. + * ble.pp: 念の為 gawk に戻す事ができる様に use_gawk (PP変数) を用意する。 + * ble.pp (ble/.check-environment): check awk. + * ble-core.sh (ble/util/array-reverse):(awk scripts): + + uninitialized variable `decl` を初期化する。 + + locale dependent な /[a-z]/ の類を POSIX 括弧 (/[[:alpha:]]/, /[[:alnum:]]/) に置き換え。 + * ble-edit.sh (.ble-edit/history/generate-source-to-load-history):(awk scripts): uninitialized variable `n`. + * ble-decode.sh (.ble-decode-bind/generate-source-to-unbind-default):(awk scripts): + + 引数名と大域変数が被らない様にする。 + + gawk 特有の機能 (/\y/, match 第三引数) を使わない。 + + bugfix, gsub の対象の変数が指定されていない箇所があった。 + * それぞれ gawk --lint 及び nawk でも動作を確認した。 + +## 2015-11-29 +* ble-edit/isearch: 現在のコマンド内も検索対象に。 + * 旧来の履歴項目検索機能を改名: + - ble-edit+isearch/forward -> ble-edit+isearch/history-forward, + - ble-edit+isearch/backward -> ble-edit+isearch/history-backward, + - ble-edit+isearch/self-insert -> ble-edit+isearch/history-self-insert. + * 検索履歴 (_ble_edit_isearch_arr) に一致範囲も記録する様に変更 + * 現在の位置からコマンド内を検索する関数を追加・旧関数を置換: + - ble-edit+isearch/forward, + - ble-edit+isearch/backward, + - ble-edit+isearch/self-insert. +* ble-edit.sh (+isearch/next): 一致範囲を囲む。 + * ble-edit.sh (+isearch/next), set region to matched range. + * ble-edit.sh: pattern matching using [[ text == pattern ]] instead of case statement. + * ble-color.sh (ble-syntax-layer:region/update): bugfix, PREV_UMIN/PREV_UMAX out of range due to the shift failure of omin/omax. +* ble-core.sh: full support for bleopt_input_encoding=C + * ble-core.sh: Add functions: ble-text-b2c+C, and ble-text-c2b+C. + * ble-core.sh (.ble-text.c2bc): rename .ble-text.c2bc -> ble-text-c2bc. + * .gitignore: 古い物を整理。/wiki 追加。 + +## 2015-11-28 +* Update README.md +* ble-decode.sh, ble-edit.sh: support `bind -xf`. + * ble-core.sh: Add functions ble/string#common-{prefix,suffix}. + * ble-decode.sh, ble-edit.sh: support `bind -xf COMMAND`. + * ble-edit.sh:714: ^M が直接埋め込まれていると GitHub が改行位置を勘違いする様なので $'\r' に修正する。 + * complete.sh: embedded sed scripts, POSIX compliance. +* ble-color.sh: Add a function ble-color-show. +* README.md: Add animation gif. +* README.md: settings for syntax highlighting. +* README.md: Add some description of settings. + +## 2015-11-27 +* Create LICENSE.md +* Update README.md + +## 2015-11-24 +* ble-edit.sh (+magic-space): bugfix, 現在のカーソル位置よりも前の部分に対して履歴展開する。 +* complete.sh: behavior of source/argument, compopt -o/+o, bugfix. + - complete.sh (ble-complete/source/argument): complete -o ..., compopt -o option +o option の読み取り。 + - complete.sh (ble-complete/util/escape-regexchars): bugfix. + - complete.sh: Add action/plain, action/argument, action/argument-nospace. + - complete.sh: Add source/dir. + - complete.sh (ble-complete/source/argument): support -o nospace, -o dirnames. +* complete.sh (ble-complete/source/argument): bugfixes. + * ble-complete/source/argument/.compgen-helper-prog: Export `COMP_LINE` `COMP_POINT` `COMP_KEY` `COMP_TYPE` + * ble-complete/source/argument/.compgen-helper-{prog,func}: Pass arguments `command`, `cur`, and `prev` for program/function. + * ble-complete/source/argument: Fix option -F, -C interruption failure. + * ble-complete/source/argument: Fix -F <-> -C miss arrangement. + * ble-complete/source/argument: Correct IFS when compgen is called. + * ble-complete/source/argument: `return 1` if no candidates are generated. + * ble-complete/source/argument: Evaluate `compgen` in the original shell (i.e., not in a sub-shell). + * ble-complete/source/argument: Filter and modify candidates generated by `compgen` using `sed`. + +## 2015-11-23 +* ble-edit.sh (ble-decode): show the message to run "stty sane" after "ble-detach". +* ble-syntax (ble-syntax:bash/extract-command): bugfix, 出力用の変数が local 指定になっていたのを削除。 + - 他: complete.sh: compgen -F prog -C cmd の際に compgen が警告を出すので compgen 2>/dev/null とする。 +* complete.sh: complete -p による補完の基本実装。 + * ble-core.sh: Create function ble/util/array-reverse. + * ble-decode.sh (.ble-decode-keys, .ble-decode-key/invoke-command): bash-3.0 workaround, local -a keys=(), local -a KEYS=() を2行に分ける。 + * ble-syntax.sh: complete 用の整備。 + * 関数追加 ble-syntax/tree-enumerate-break: "((tprev=-1))" は意図が分かりにくいので。 + * 関数追加 ble-syntax:bash/extract-command: + * ble-syntax/tree-enumerate: シェル変数 iN の既定値を _ble_syntax_text の末端に。 + * ble-syntax/completion-context: CTX_VALI, CTX_VALX に対応。 + * ble-syntax/completion-context: 一部の補完文脈を file から argument に変更。 + * complete.sh: complete -p 設定に基づく補完。 + * ble-complete/source/argument: 追加 + +## 2015-11-22 +* ble-syntax.sh: bash 文法関連の関数名整理。 + * ble-decode.sh (ble-bind): error message に . を追加。古いコメントを削除。 + * ble-syntax.sh (ble-syntax/parse/{check,ctx}-*): bash 文法特有の関数の名称を整理。 + +## 2015-11-21 +* cmap/cmap+*.sh: Update for current ble-decode.sh. +* ble-edit.sh (ble-edit+magic-space): Add edit function magic-space. + +## 2015-11-19 +* Support of PROMPT_COMMAND, and function bleopt. + * ble-edit.sh: easy support of PROMT_COMMAND. + * ble-core.sh: bleopt 関数追加。 + * ble-decode.sh (.ble-decode-initialize-cmap): POSIX sed BRE does not support the quantifiers: \+, \?. +* ble-syntax.sh: 履歴展開をより正確に。 + * histchars に応じた履歴展開の解析 + * extglob が設定されている時は !( は履歴展開と解釈しない + * 文字列 "~" 中の履歴展開は " の直前で終わる +* ble-core.sh: workaround for bash-3.0 regex in _ble_base_tmp.wipe. + +## 2015-11-17 +* `ext/mwg_pp.awk`: Include mwg_pp.awk in ext; Makefile (listf): renamed to list-functions and modified. +* ble-syntax.sh (ble-syntax/parse/nest-equals): bugfix (operater associativity), incorrect break of loops. + +## 2015-11-09 +* ble-core.sh (_ble_base_tmp.wipe): bugfix, correct iteration of old tmp files. + +## 2015-11-08 +* complete.sh: ユーザ入力があった時の候補列挙の中断に対応 (bash-4.0 以降); ble-syntax.sh: コメント判定の修正。 + * ble-core.sh (ble/util/is-stdin-ready): 関数追加。標準入力に未処理の文字が残っているかどうかを判定。ユーザの入力が待ち状態になっているかどうかを判定する為の物。 + * ble-syntax.sh (ble-syntax/parse/check-comment): コマンドライン解析時 shopt -u interactive_comments の時にはコメントは無効とする。 + * ble-syntax.sh (ble-syntax/parse/check-comment): bugfix コメント開始判定(単語頭)。単語開始の判定が単語頭ではなく「単語頭または単語内部の解析開始点の位置」という事になっていた。 + * complete.sh (ble-complete/source/command/gen, ble-edit+complete): コマンド候補の列挙・一致判定には時間が掛かるので ble/util/is-stdin-ready を用いて中断の判定を実行する。 + +## 2015-11-07 +* Update README.md +* ble.pp: check environment for required commands, ble-edit.sh: 'M-\'. + * ble.pp: check required commands. + * ble-core.sh: remove dependencies on `touch' command. + * ble-edit.sh, keymap/emacs.sh: Add edit function: delete-horizontal-space ('M-\'). + +## 2015-11-06 +* ble-syntax.sh: cleanup debug codes. +* ble-syntax.sh (ble-syntax/parse/shift.nest): bugfix, parse error by shift failure of _ble_syntax_nest. + +## 2015-11-25 +* Create README.md + +## 2015-08-25 +* m, bugfixes. + * PS1 の '!' の処理、 + * PS1 の \w の処理、 + * (bash-3.0) history '!1' &>/dev/null によるチェックでエラーメッセージが漏れていた。 +* bugfix, specify explicit collation order for regs and globs. + * Character ranges in regular expressions and glob patterns are dependent on collation order. + * To obtain the desired results for ascii characters, `local LC_COLLATE=C' should be explicitly specified. + +## 2015-08-24 +* ble-edit.sh (.ble-edit.history-add): bugfix, handling of HISTCONTROL. + +## 2015-08-19 +* bin/ble-edit.sh: bugfix for bash-3.0, history -s が正しく動作しないので修正。 + +## 2015-08-18 +* bugfix and cleanups. + * ble-core.sh (ble-assert): bugfix, correct return value. + * ble-edit.sh, ble-synta.sh: bash-3.0 bugfix, `local arr=(...)' form cannot be used in bash-3.0. + * ble-edit.sh (hist_expanded.initialize): renamed to `ble-edit/hist_expanded.initialize'. + +## 2015-08-16 +* 消滅単語に対する色解除の対策(暫定)。 + * ble-syntax.sh (ble-syntax/parse): 消滅単語の範囲集計。 + * ble-syntax.sh: 範囲更新・並進の整理。関数 ble/util/[uw]range#{update,shift} の追加。 +* 表示系統 bug fixes. + * ble-edit.sh (ble-edit/dirty-range/update): bugfix, endA0 の読み出しに誤り、変数名 delta/del に誤り。 + * ble-syntax.sh (ble-highlight-layer:syntax/update-attribute-table): bugfix in umin/umax update, umax の更新に使う変数名を誤っていた。 +* 組込コマンド上書き対策。ble-syntax shift bufgix for bash-4.2 算術式。 + * ble-syntax.sh (bash-4.2): bugfix, ble-syntax/parse/shift.{tree1,nest} の算術式で bash-4.2 をクラッシュされる形式の物が見付かった。 + * ble-core.sh: ble/util/set 関数を追加。 + * ble-edit.sh: builtin 上書きを防ぐ為に unset -f builtin を実行 (builtin, unset 両方上書きされると駄目だが)。 + * ble-edit.sh: return/break/continue も上書きを禁止する。 + * ble-*.sh: test の代わりに [[ ]] を使用。 +* 貼付時の再描画抑制 (read -t 0 による判定)。\x80-\x9F を M-^? で表示。 + * ble-edit.sh: 編集文字列内の \x80-\x9F の表示を M-^? に。表示が乱れていた。 + * ble-edit.sh (ble-decode-byte:bind): 次の文字が来ている時に再描画を抑制。 + * ble-edit.sh: exec/gexec 周りの関数名を整理。 + * ble-edit.sh: 関数削除 .ble-edit-isearch.create-visible-text + +## 2015-08-14 +* 構文 function ... に対応、履歴展開 bugfix. + * ble/src: .srcoption 追加。 + * ble-syntax.sh: defface 関数の色の変更。 + * ble-syntax.sh: 構文 `function ...` に対応。 + * ble-syntax.sh: `function ...`, `hoge ()` の直後に来るコマンドを compound-commands に制限。 + * ble-edit.sh: bugfix, set +H の時も履歴展開が有効になっていた。history -p は set +H と関係なく展開を行う。 + * ble-edit.sh: bugfix, 関数 echo を定義するとコマンドがそれ以上実行できなくなる。echo/printf を builtin を介して呼び出す様に変更。 +* ble/util/assign cleanup, ble/util/type add, .ble-line-prompt/update bugfix. + * ble-core.sh (ble/util/assign): cleanup, ble/util/sprintf, ble/util/type, ble/util/isfunction でも仕様, + * ble-core.sh: ble/util/type 追加。$(type -t) はこれを用いて処理する様に変更, + * ble-edit.sh (.ble-line-prompt/update): bugfix, 地の文の '$' や '`' が escape されてしまい展開されない. +* ble-edit.sh: プロンプト更新最適化。 +* ble-core.sh (ble/util/assign): $(...) 高速化用関数。 +* shift 高速化、入れ子構造を考慮に入れた単語着色に対応。 + * ble-syntax.sh (ble-syntax/parse/shift): 入れ子構造を考慮に入れた shift, + * ble-syntax.sh (_ble_syntax_tree): 単語毎の着色情報をデータ配列内に保持するように変更, + * ble-syntax.sh (ble-highlight-layer:syntax/update-word-table): 入れ子構造を考慮に入れた着色. +* leak variables: g cs +* cleanup, leak variables 処置. +* ble-syntax.sh: 終端していない節も列挙対象に含める。他整理。 + * ble-syntax.sh (ble-syntax/print-status): prints unterminated nodes. + * ble-syntax.sh: add new functions ble-syntax/tree-enumerate, ble-syntax/tree-enumerate-children. + * ble-syntax.sh: rename shell variable: _ble_syntax_word -> _ble_syntax_tree. + * ble-syntax.sh: cleanup. + +## 2015-08-13 +* ble-syntax.sh: clenup, print-status/dump-tree. +* ble-syntax.sh (_ble_syntax_stat): 解析状態に tchild, tprev (兄・子へのoffset情報) を追加。 +* ble-syntax.sh (_ble_syntax_word): 形式変更。兄・子へのoffset情報はその場で計算する暫定方式。 + +## 2015-08-12 +* memo.txt: _ble_syntax_word 形式変更の計画, ble-syntax.sh: clean up + +## 2015-08-11 +* ble-syntax.sh (`_ble_syntax_nest[]`): 形式変更 → "ctx wlen wtype nlen type" +* ble-syntax.sh (`_ble_syntax_stat[]`): 形式の変更 → "ctx wlen wtype nlen" +* ble-syntax.sh (`_ble_syntax_word[i]`): 要素の形式を wtype wbegin から wtype wlen に変更 +* ble-edit.sh (.ble-line-info.draw): 制御文字も入れられる様に, +* ble-syntax.sh (ble-syntax/print-status): Added, +* ble.pp: 二重起動対策, +* ble-edit.sh: history load. + +## 2015-08-08 +* ble-syntex.sh (ble-syntax/completion-context/check-prefix): completion at redirect filenames. + +## 2015-07-10 +* memo.txt: Added todos. + +## 2015-06-15 +* modified complete.sh + +## 2015-03-22 +* ble-decode.sh: bugfix, bash-4.1 でも ESC [ を翻訳しないと駄目 +* ble-decode.sh: bugfix, bash-4.1 でも ESC * に登録しないと駄目 +* ble-core.sh, etc.: 一時ファイルを tmp/$UID に置く事にする。 + +## 2015-03-12 +* ble-syntax.sh (ble-syntax/parse): stat の設定されていない箇所に word があり、shift されていなかった。 + +## 2015-03-08 +* ble-edit.sh (ble-edit/draw/trace): bugfix, LC_COLLATE を設定して正規表現を使用する様に修正。 +* bashbug related bugfix: 幾つかの bugfix, 全て bash のバグが関係していた…。 + - `` bash-4.1 以下でカーソルの表示位置がずれている。 + - `` bash-4.2, 4.0, 3.2, 不完全な編集内容に対してエラーが出る + - `` bash-4.0, 4.1 でプロンプトが表示されない + - `` bash-4.1 以下でプロンプトの色が着かない +* ble-decode.sh (.ble-decode-char): control/alter/meta/shift/super/hyper prefix が、 + その場で自身に適用されて出力されていた。 +* ble-core.sh (ble/util/declare-print-definitions): 連想配列に対応 +* ble-decode.sh, 他: オプション名 ble_opt を bleopt に統一 +* ble-decode.sh: .ble-decode-char 再実装 + - 修飾機能を send-modified-key (旧 sendkey-mod) に合流 + - C-x @ S 等、ESC 以外の修飾にも対応 + - .ble-decode-char/csi/* による CSI sequence の解釈 + - 新実装に対応する様に cmap/default.sh を書き直し + +## 2015-03-06 +* ble-decode.sh (stty): -icanon の設定。 +* ble-edit.sh (PS1): bugfix, job count, 時刻その他の更新。 +* ble-edit.sh (.ble-line-text/update/postion) + - bugfix: ascii printable characters の行末で \n を付加した時 ichg に登録していなかった。 + - bugfix: _ble_util_string_prototype の長さ指定に 0 を指定していた + - bugfix, 行末付近での tab の取り扱い + - 制御文字も追い出しの対象に。 + - xenl の時、行末で必ず \n を追加する (追い出しの場合なども含め)。 + - 追い出しがあった場合にそれを記録する。 +* ble-edit.sh (.ble-line-text/getxy.cur): カーソル位置を取得する為の getxy を新規作成。 +* ble-edit.sh (ble-edit/draw/trace): 描画属性 + - term.sh: 描画属性について terminfo から読み取る様に。 + - ble-color.sh: 描画属性の点滅、不可視、イタリック、打ち消し線に対応。 + - ble-color.sh: sgr 構築で term.sh の結果を利用する様に変更。 + - ble-edit.sh (.ble-line-prompt): ble-color-g2sgr で端末に依存しない PS1 を書ける様に変更。 +* ble-decode.sh (ble-decode-kbd): bugfix, 複数キーがある場合に正しく処理できていなかった +* overwrite-mode に対応 +* ble-syntax.sh, ble-color.sh: layer:syntax による色付けを face を介した物に変更。 +* ble-decode.sh, ble-edit.sh: 条件コマンドの統一。test や [ 等を [[ に統一。 + +---- + + +# Old ChangeLog + +## 2015-03-03 + + * ble-edit.sh, ble-edit.color: discard-line の際に着色 + * ble-edit.sh, ble-core.sh, etc: echo を builtin echo に。 + * ble-edit.sh: bugfix, 複数行で上に行けない + * ble-edit.sh: bugfix, 複数行なのに空行の accept-line でのずれ量が1行になっている + * プロンプト再実装 + - ble-edit.sh (ble-edit/draw/trace): escape sequences が含まれている文字列の位置追跡。 + - ble-edit.sh (.ble-line-prompt/update): プロンプトの構築を再実装。$() がある場合なども正しい計算。 + * ble-complete.sh (source/command): shopt -s autocd の時にディレクトリ名も候補として列挙。 + * ble-complete.sh: 補完候補の選択の方法を変更。より近くの開始点の物を優先。 + +## 2015-03-01 + + * ble-edit.sh: .ble-edit-draw.goto-xy, .ble-edit-draw.put 廃止 + * complete.sh: 関数名に / が入っていると compgen -c で列挙されないので、別に列挙する。 + +## 2015-02-28 + + * 初期化の最適化 + - ble-decode.sh: ble-decode-kbd 書き直し、ble-bind 書き直し + - ble-getopt.sh: 多少最適化 + - ble-decode.sh: bash-4.3 でも ESC [ を utf-8 2-byte code で受信する様に変更。 + - ble-decode.sh (.ble-decode-bind/generate-source-to-unbind-default): awk 呼出を一回に統合。 + - ble-decode.sh (.ble-decode-key.bind/unbind): [[ ]] による書き換え、bugfix。 + - ble-decode.sh, bind.sh: bind -x を生成する為のコードを bind.sh に分離。 + - ble-edit.sh, keymap.emacs.sh: keymap 初期化部分の分離、キャッシュ化。 + - ble-edit.sh: history 遅延ロード対応 + * ble-core.sh, ble-color.sh: .ble-shopt-extglob-push/pop/pop-all 廃止 + * ble-edit.sh: bugfix, .ble-line-info.clear で位置がずれる + * ble-edit.sh: ble-edit/draw/put.il, ble-edit/draw/put.dl + * ble-color.sh (ble-highlight-layer/update/shift): 長さが変わらない場合でも shift する。 + * ble.pp (include ble-getopt.sh): 現在使っている所がないので取り敢えず外す。 + * ble-syntax.sh (completion-context): 簡単なパラメータ展開に対する対応。 + +## 2015-02-27 + + * [bug] TAB 等の変更文字があった場合に文字列が表示されなくなる + * bash-3.0, 3.1 対応 + "[bug] bash-3.1 日本語の色付け・描画が変だ" + - ble-edit.sh, 他: @bash-3.1 bashbug workaround, ${param//%d/x} などは効かないので %d を '' で囲む。 + - ble-syntax.sh, 他: @bash-3.1 bashbug workaround, x${#arr[n]} はバイト数を返す様なので一旦通常変数に入れて ${#var} とする。 + - *.sh: @bash-3.0: += 演算子の置き換え、配列宣言の修正。 + - term.sh: @bash-3.0: bashbug workaround, declare -p で出力すると誤った物になる。 + * ble-edit.sh (.ble-line-text/update/slice): bugfix, 変更文字がある時にもう存在しないローカル変数を参照していた。 + * ble-core.sh: ble-load, ble-autoload + * complete.sh:, ble-syntax.sh, ble-edit.sh: 文脈依存補完の実装 + +## 2015-02-26 + + * ble-syntax.sh: a+=( a=( に対応 + +## 2015-02-25 + + * ble/term.sh: TERM 依存の部分を分離。キャッシュ化。完全移行ではないが徐々に。 + * ble-decode.sh: + - [bug] $_ble_base/cache の代わりに $_ble_bash/cache を作成していた + - [bug] accept-single-line-or-newline が二回目以降常に accept + * ble-edit.sh: + - [bug] 複数行の編集時に履歴移動をすると表示が乱れる + - printf %()T を用いた実装の導入、PS1 \D{...} に対応 + - [bug] 表示の属性の更新がうまく行かない事がある。 + - [bug] 編集文字列の行数が変わった時に info.draw の内容がずれる + * カーソル移動 + - ble-edit: 複数行編集と項目内でのカーソル移動に対応 + - ble-edit.sh: 複数行コマンドの履歴に対応。 + * ble-syntax.sh: ble-syntax-highlight+syntax を ble-highlight-layer:syntax に書き換え + * ble-syntax.sh: + - 関数定義 func() の形式に対応、 + - 条件式 [[ ... ]] と配列初期化子内の文脈に対応。 + - コメントに対応。 + - $[...] の形式に対応 (何故か bash の説明には一切載っていないが使える)。 + - [bug] invalid nest " $()" の先頭に for を挿入した時 + +## 2015-02-24 + + * ble-edit.sh 出力の部分更新に対応 (描画ちらつき対策) + * ble-syntax.sh: _ble_syntax_word, _ble_syntax_stat の形式の変更 + * ble-syntax.sh: 今迄行っていた dirty-range 拡大の方法を止めて、単に stat の削除を行う。 + * ble-syntax.sh: 及び上記の変更に伴う数々の bugfix + - [bug] 文字削除時 invalid nest の assertion に引っかかる。 + - [bug] 編集内容が零文字になった瞬間に改行が起こって表示が消える。 + - [bug] 改行しても先頭がコマンドになっていない + - [bug] _ble_region_highlight_table で空欄になっている箇所がある。 + - [bug] 単語の属性適用が後ろに続く単語にも続いている。 + - [bug] _ble_syntax_attr の中に "BLE_ATTR_ERR" の文字列が混入している。 + - 残っている dirty 拡大と _ble_syntax_word[] の廃止された形式に対する処理の + コメントアウトされた部分を削除。dirty 拡大の変更に伴う効率化の確認と、 + shift が遅いという事の ToDo 項目の追加。 + * ble-decode.sh: [bug] $_ble_base/cache の代わりに $_ble_bash/cache を作成していた + * ble-edit.sh: ble-edit+delete-backward-xword の類の動作を変更。 + +## 2015-02-23 + + * ble-core.sh: ble-stackdump, ble-assert + * [bug] update-positions で dend-dbeg が負になると警告が出る + * [bug] info.draw で特殊文字が改行に跨っている時の座標計算 + +## 2015-02-22 + + * ble-edit.sh: [bug] .ble-line-info.draw を使った時行がずれる + * ble-syntax.sh: [bug] for や do に色が着かない? + * レイヤー化 + - ble-color.sh: レイヤーの仕組み、レイヤ region, adapter, plain + RandomColor + - ble-edit.sh: レイヤーに対応した表示文字列構築関数。古い構築関数の削除。出力関数の変更。 + - ble-syntax.sh: 多少の変更。 + +## 2015-02-21 + + * 描画の高速化 + - ble-syntax.sh: 属性値の変更範囲に応じて適用を行い、変更範囲を LAYER_MIN, LAYER_MAX に返す様に。 + - ble-edit.sh: 表示用の文字列の構築部分を書き直して部分更新に対応。 + - ble-syntax.sh: 内容に変化のあった word の範囲も記録する様に変更。 + - ble-syntax.sh (parse): _ble_syntax_attr_umin (属性値の変更範囲), + _ble_syntax_word_umin (word の変更範囲) の累積に対応する為に、これらについても shift を実行する。 + +## 2015-02-20 + + * ble-decode.sh: bind 周り + - bash-4.3 C-@ を utf-8 2-byte code で受信する様に変更 + - bash-3.1 ESC [ を utf-8 2-byte code で受信する様に変更 + - bugfix, \C-\\ \C-_ \C-^ \C-] に bind できなくなっていた。 + - bind の version 分岐について整理。 + - 既存の bind を ESC に関係なく bind -r する。 + * ble-decode.sh: .ble-decode-key 部分一致探索の処理の再実装。変な動作だった。 + * ble-decode.sh: bugfix, 8bit 文字を正しく bind できていない。c2s で8bit文字が符号化されていた。 + * ble-syntax.sh: 履歴展開は $- に H がある時のみ有効に。 + * ble-syntax.sh: bugfix, bash-4.2 のバグの work around。配列を参照する算術式の書き換え。 + * ble-core.sh: c2s を bash の機能だけで実装できたので fallback を replace。 + * ble-core.sh: bash-4.0 で .ble-text.s2c を連想配列でメモ化 + * ble-edit.sh: bugfix, bash-4.0 で ret に予め特定の値が入っていると c2w に失敗する。 + * ble-edit.sh: bugfix, bind -x 直前のプロンプトの取り扱いは bash-4.0 では bash-3 系と同じ。 + * ble-edit.sh (.ble-line-text.construct 周り): lc lg を後で計算する様に変更。一区切り。一旦 commit する。 + +## 2015-02-19 + * ble-syntax.sh: 履歴展開に対応。 + * ble-decode.sh: bugfix, bind -X から bind -x を生成するコード。 + bind -X の出力する形式は再利用不可能な形式でエスケープされているのでこれを変換。 + * ble.pp, etc: noattach 引数に対応。ble-attach/ble-detach 関数の定義。detach の bugfix。 + * ble-edit.sh: bug, bleopt_suppress_bash_output= にした時にプロンプトが二重になる + +## 2015-02-18 + + * ble.pp, ...: ディレクトリの構成を変更 + * ble-syntax.sh: 文法の対応 + - プロセス置換を単語として扱う様に変更 + - リダイレクトの後の引数に対応 + - リダイレクトの前の fd 部分に対応 + * bash-3.1 対応 + - ble-edit.sh: bash-3.1 で C-d を捕捉できる様に(結構無理のある方法だが)。 + - ble-edit.sh, ble-decode.sh: bugfix, bash-3 でカーソルキーの類が動かない。履歴が読み込まれていない。 + - ble-edis.sh: bash-3.1, bleopt_suppress_bash_output=1 の方が安定して動いているのでこちらで行く。 + - ble-edit.sh: bash-3.1, カーソルキーが効かない。例によって ESC [ ... に関係するコマンドで + keymap が見付からないエラーになっている。これは ESC [ を CSI (utf-8) に変換してから読み取る事にした。 + - ble-syntax.sh: bash-3.2.48 のバグの work-around, (()) 内で配列要素を参照すると制御が無条件に其処に跳ぶ。 + +## 2015-02-17 + * ble-edit.sh (ble-edit/dirty-range): 範囲更新の仕組みを追加。 + _ble_edit_dirty はプロンプト再描画の判定も兼ねているので取り敢えず残す。 + * ble-edit.sh: 変数リーク (グローバル変数の汚染) の修正。line i + * ble-syntax.sh (ctx-command/check-word-end): 単語終了判定の処理タイミングを変更。 + * ble-syntax.sh: context の追加。CTX_CMDXF CTX_CMDX1 CTX_CMDXV CTX_ARGX0 + より正確な文脈判定・エラー検知。 + * ble-syntax.sh: 他にも多くの修正がある。未だ修正が続きそうなので一旦 commit する。 + + * ble-edit.sh (accept-line): bug, - で始まるコマンドを実行できない。 + * ble-color.sh: [bug] bg=black を設定しても反映されない。 + "未設定" と "黒" を区別する様に修正。 + * ble-syntax (ble-syntax-highlight+syntax): 入れ子エラーの色の範囲 + * ble-syntax: m, ;& は ;; ;;& 等と同じ取り扱い + * ble-syntax, etc: bash-3 正規表現対策。bash-3/4 の正規表現の違いに依存しない書き方に変更。 + +## 2015-02-16 + * ble-syntax.sh: bugfix, incremental に更新した時に word の長さが更新されない。 + _ble_syntax_word への格納の際に失敗していた。 + +## 2015-02-15 + * ble-synatax.sh: bash の文法に従った incremental な解析と色付け。 + +## 2015-02-14 + * ble-edit.sh (.ble-line-info.draw): 表示が遅いので修正。 + ASCII 文字は特別扱いする様に改良。劇的に速くなった。 + +## 2015-02-13 + * ble-edit.sh (keymap emacs): 既定の keymap に emacs の名を付与。 + * ble-edit.sh (accept-line.exec): bugfix, C-c で再帰呼び出しのループから抜けられない。 + trap DEBUG を用いて再帰呼び出しから抜けられる様に exec 周りを整理・実装し直し。 + * ble-edit.sh: オプション名の変更、各オプションの整理・説明の追加。 + * ble-edit.sh (.ble-edit/gexec): グローバルな文脈でコマンドを実行する仕組み。 + 再帰呼出に対する C-c にも対応。bleopt_exec_type で実行の方法を切り替えられる様に。 + exec が従来の方法で gexec がこの新しい方法。 + +## 2015-02-12 + * ble-decode.sh: bugfix, exit 後に stty が壊れているのを修正 + これに伴って ble の detach 機能の実装も行った。 + * ble-decode.sh: bugfix, bash-4.3 で三文字以上のシーケンスが悉く聞かない。 + keymap が見付からないエラーになってしまうので全てのシーケンスについて bind -x する事にした。 + * ble-core.sh: bugfix, builtin printf \U.... の使えない環境で command printf fallback が働かない。 + printf のパスを修正。また ASCII に対しては printf は使わない様に変更。 + * ble-color.sh (ble-syntax-highlight+default): + 追加・修正。また選択範囲の反転を ble-syntax-highlight+region として実装し、それを呼び出す形に。 + * ble.pp: 起動時に interactive モードかどうかのチェックを行う様に。 + +## 2015-02-11 + * ble-edit.sh (_ble_edit_io_*): ちらつきを抑える為に stdout/stderr を切り替える事にした。 + ちらつくのは bash の既定の出力によって ble の表示がクリアされ、bash の表示したい物が表示されるから。 + これに対抗して ble は bash の出力の直後に上書き再描画して何とか表示していた。 + bash の既定の出力を抑える為に、exec で出力先を切り替える事にした。 + bash の出力はファイルに書き込まれる様にし向ける。出力先ファイルを逐次確認して、 + エラーが出力されていれば visible-bell で表示する事にした。 + `bleopt_suppress_bash_output=1` の時にこの新しい方法を実験的に用いる。 + `bleopt_suppress_bash_output=` の時は従来のちらつく方法。 + +## 2015-02-10 + * ble-edit.sh (accept-line.exec): bash-4.3 で内部からグローバル変数を定義できる様に + declare 及び typeset を上書きして -g オプションを指定する様に変更。 + また、これに関係する注意点を ble.htm に記述。 + * ble-edit.sh (history): ロードに時間が掛かるので最適化。 + * 全般: bugfix, 文字列分割で GLOBIGNORE='*' を設定していないとパス名展開されて危険 + * ble-color.sh (ble-syntax-highlight+default): より良い色づけ。 + * ble-edit.sh (accept-line.exec): ble-bind -cf で bind されたコマンドの実行コンテキストを変更。 + accept-line で実行されるのと同じコンテキストで実行する。 + * ble-edit.sh (keymap default): C-z M-z を fg に bind。 + +## 2015-02-09 + * git repos + * ble-edit: bugfix, locate-xword マクロが展開されていなかった + * ble-decode: bash-4.3 に対応する為に色々変更 + - bind 指定の場合分けを整理 + - bugfix, ESC ?, ESC [ ? に対して全て bind + - bugfix, 場合によって全く bind -r できていない + →"bind -sp | fgrep" が "バイナリ" という結果になる事がある様だ。 + fgrep に -a を指定する。 + - bugfix, 日本語が入力できない。8bit 文字が認識されない。 + →8bit 文字はエスケープシーケンスで bind に指定する様に変更。 + +## 2013-06-12 + * ble-edit: history-beginning, history-end, accept-and-next + +## 2013-06-12 + * ble-edit: + kill-forward-fword, kill-backward-fword, kill-fword, + copy-forward-fword, copy-backward-fword, copy-fword, + delete-forward-fword, delete-backward-fword, delete-fword, + forward-fword, backward-fword + * ble-edit: history-expand-line, display-shell-version + +## 2013-06-10 + * ble-edit: + kill-forward-uword, kill-backward-uword, kill-uword, kill-region-or-uword, + copy-forward-uword, copy-backward-uword, copy-uword, copy-region-or-uword, + forward-uword, backward-uword + + * ble-edit: + delete-forward-uword, delete-backward-uword, delete-uword, delete-region-or-uword, + delete-forward-sword, delete-backward-sword, delete-sword, delete-region-or-sword, + delete-forward-cword, delete-backward-cword, delete-cword, delete-region-or-cword + + * ble-edit: + 以下の編集関数を廃止: + delete-region-or-uword, kill-region-or-uword, copy-region-or-uword, + delete-region-or-sword, kill-region-or-sword, copy-region-or-sword, + delete-region-or-cword, kill-region-or-cword, copy-region-or-cword. + 代わりに以下の編集関数を用いる: + delete-region-or type, kill-region-or type, copy-region-or type. + +## 2013-06-09 + * ble-edit: kill-region, copy-region + * ble-edit: + kill-forward-sword, kill-backward-sword, kill-sword, kill-region-or-sword, + copy-forward-sword, copy-backward-sword, copy-sword, copy-region-or-sword + * ble-edit: + kill-forward-cword, kill-backward-cword, kill-cword, kill-region-or-cword, + copy-forward-cword, copy-backward-cword, copy-cword, copy-region-or-cword + * ble-edit: forward-sword, backward-sword, forward-cword, backward-cword + +## 2013-06-06 + * ble-edit-bind: 全ての文字・キーが入力可能に。 + * complete: 候補一覧の表示 (簡易版) + * ble-color.sh: 色付け機能を highlight.sh から移植 + +## 2013-06-05 + * ble-edit: history-isearch-backward, history-isearch-forward, + isearch/self-insert, + isearch/next, isearch/forward, isearch/backward, + isearch/exit, isearch/cancel, isearch/default, + isearch/prev, isearch/accept + * ble-edit: yank + * ble-bind -d で今迄に bind した物を表示できる様に。 + * ble-edit: complete, 取り敢えずファイル名補完だけ + * ble-edit: command-help + +## 2013-06-04 + * ble-edit: discard-line, accept-line + * ble-edit: history-prev, history-next + * ble-edit: set-mark, kill-line, kill-backward-line, exchange-point-and-mark + * ble-edit: clear-screen + * ble-edit: transpose-chars + * ble-edit: insert-string + +## 2013-06-03 + * ble-edit: bell, self-insert, redraw-line, + * ble-edit: delete-char, delete-backward-char, delete-char-or-exit, + delete-forward-backward-char + * ble-edit: forward-char, backward-char, end-of-line, beginning-of-line + * ble-edit: quoted-insert + * ble.sh: 取り敢えず簡単に文字列を入力できる程度までは完成 + +## 2013-06-02 + * ble-getopt.sh: bugfixes + * ble-getopt.sh: 無事に完了した場合に OPTARGS を unset する様に変更 + * ble-decode-kbd, ble-decode-unkbd + +## 2013-05-31 + * ble-getopt.sh: created + * ble-decode: 大枠が完成 + +## 2013-05-30 + * highlight.sh: 取り敢えず簡単な色付け + * ble.sh: + + -- 経緯 -- + highlight.sh の方針だと bash が表示する編集中の内容を消す事が出来ないし、 + カーソルの位置も bash が表示する物の場所を指している。 + 色を付けて表示した物は、補助的に bash が表示する物の下に並べて表示する + ぐらいしか方法がない。 + + また readline 関数をスクリプトから呼び出す事が出来ないので、 + 結局、色付けを更新したいタイミングで READLINE_LINE や READLINE_POINT の動作を + スクリプトの側で全て模倣して再現しなければならない。 + READLINE_LINE, READLINE_POINT の bash の仕様が変な所為で、日本語など + のマルチバイトで正しく処理する為に、色々と汚い事をしなければならない。 + + 以上の事から、文字列の編集などの操作からスクリプトの実行まで + 全部自分で好きな様に実装して bash readline の機能を全て上書きする事にした。 + その為に、スクリプトを新しく書き直す。zle を真似て ble (bash line editor) + と名付ける。 + + -- 方針としては -- + a. read -n 1 を用いて 1 文字ずつ標準入力から文字を取り出してそれを処理していく + b. bash の bind で全ての文字に ble のバイト受信関数を繋げて、 + バイト列を受信しながら処理する。 + + highlight.sh の延長線上で b. の方針にしたが、 + もしかすると a. の方針も可能かも知れない。 + +## 2013-05-29 + * highlight.sh: 作成 diff --git a/.local/share/blesh/doc/LICENSE.md b/.local/share/blesh/doc/LICENSE.md new file mode 100644 index 0000000..60789a4 --- /dev/null +++ b/.local/share/blesh/doc/LICENSE.md @@ -0,0 +1,12 @@ +Copyright (c) 2013, 2015-2023, K. Murase @akinomyoga , +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/.local/share/blesh/doc/README-ja_JP.md b/.local/share/blesh/doc/README-ja_JP.md new file mode 100644 index 0000000..28f8959 --- /dev/null +++ b/.local/share/blesh/doc/README-ja_JP.md @@ -0,0 +1,768 @@ +[ Languages: [English](README.md) (英語) | **日本語** ] + +

ble.sh (/blɛʃ/) ―Bash Line Editor―

+

+[ README | 説明書 | +Q&A | +contrib | +逆引き ] +

+ +`ble.sh` (*Bash Line Editor*) はピュア Bash スクリプトで書かれたコマンドラインエディタで、標準の GNU Readline を置き換える形で動作します。 + +現在の開発バージョンは 0.4 です。 +このスクリプトは Bash 3.0 以降で利用できますが、速度・機能などの観点から 4.0 以降のリリース版 Bash でお使い頂くことがお薦めです。 +現時点では、文字コードとして `UTF-8` のみの対応です。 +このスクリプトは [**BSD License**](LICENSE.md) (3条項 BSD ライセンス) の下で提供されます。 + +免責: ラインエディタ本体は **ピュア Bash** で書かれていますが、 +ユーザーコマンド実行時には TTY 設定の為に `stty` (POSIX) を呼び出します。 +他にも処理の高速化の為に、初期化・終了処理、 +巨大なデータの処理 (補完、貼り付けなど) の局面でPOSIX 標準コマンドを利用しています。 + +呼称: `ble.sh` はお好きな様に読んでいただいて問題ありませんが、一番短いのは標記の /blɛʃ/ になりましょう。 +しかし個人的には脳裡で /biːɛliː/ または /biːɛliː dɑt ɛseɪtʃ/ と読んでいるものですから、標記の読み方は飽くまで参考と受け止めていただければ幸いです。 + +## 簡単設定 + +`ble.sh` をお使いいただくには Bash 3.0 以上 (及び POSIX の基本的なコマンド) が必要です。 + +`ble.sh` を取得するには主に2つの方法があります: `git` を用いてソースを取得しビルドする方法と `curl` または `wget` を用いて nightly ビルドをダウンロードする方法です。 +詳細は、試用またはインストールに関しては [節1.1](#get-from-source) と [節1.2](#get-from-tarball) を、 +`~/.bashrc` の設定に関しては [節1.3](#set-up-bashrc) を御覧ください。 + +> [!NOTE] +> `fzf` を `ble.sh` と組み合わせてお使いの場合は [節2.8](#set-up-bashrc) を必ず +> 御覧ください。 + +
git を用いてソースを取得し ble.sh を生成 + +この方法では `git`, `make` (GNU make), 及び `gawk` が必要です。 +以下、GNU make が `gmake` として提供されているシステム (BSD など) では、`make` を `gmake` に置き換えて実行してください。 + +```bash +# 簡単お試し (インストールせずにお試しいただけます) + +git clone --recursive --depth 1 --shallow-submodules https://github.com/akinomyoga/ble.sh.git +make -C ble.sh +source ble.sh/out/ble.sh + +# インストール & .bashrc 簡単設定 (動かない場合は節1.3を御参照下さい) + +git clone --recursive --depth 1 --shallow-submodules https://github.com/akinomyoga/ble.sh.git +make -C ble.sh install PREFIX=~/.local +echo 'source ~/.local/share/blesh/ble.sh' >> ~/.bashrc +``` + +生成過程では、複数のBashスクリプトファイルを前処理・結合することで `ble.sh` を生成し、 +他の関連ファイルを正しく配置し、またソースコード中のコードコメントを削除してロードを最適化します。 + +※生成過程は、C/C++ のコンパイルも伴わずバイナリも生成しませんので、コンパイラを準備していただく必要はありません。 +
+ +
curl を用いて nightly ビルドをダウンロード + +この方法では `curl`, `tar` (オプション `J` に対応), 及び `xz` (XZ Utils) が必要です。 + +```bash +# 簡単お試し (インストールせずにお試しいただけます) + +curl -L https://github.com/akinomyoga/ble.sh/releases/download/nightly/ble-nightly.tar.xz | tar xJf - +source ble-nightly/ble.sh + +# インストール & .bashrc 簡単設定 (動かない場合は節1.3を御参照下さい) + +curl -L https://github.com/akinomyoga/ble.sh/releases/download/nightly/ble-nightly.tar.xz | tar xJf - +bash ble-nightly/ble.sh --install ~/.local/share +echo 'source ~/.local/share/blesh/ble.sh' >> ~/.bashrc +``` + +インストール後はディレクトリ `ble-nightly` は削除して問題ありません。 +
+ +
wget を用いて nightly ビルドをダウンロード + +この方法では `wget`, `tar` (オプション `J` に対応), 及び `xz` (XZ Utils) が必要です。 + +```bash +# 簡単お試し (インストールせずにお試しいただけます) + +wget -O - https://github.com/akinomyoga/ble.sh/releases/download/nightly/ble-nightly.tar.xz | tar xJf - +source ble-nightly/ble.sh + +# インストール & .bashrc 簡単設定 (動かない場合は節1.3を御参照下さい) + +wget -O - https://github.com/akinomyoga/ble.sh/releases/download/nightly/ble-nightly.tar.xz | tar xJf - +bash ble-nightly/ble.sh --install ~/.local/share +echo 'source ~/.local/share/blesh/ble.sh' >> ~/.bashrc +``` + +インストール後はディレクトリ `ble-nightly` は削除して問題ありません。 +
+ +
パッケージ管理システムを通じてパッケージをインストール (現在限られたパッケージのみ) + +この方法では対応するパッケージ管理ツールのみが必要です。 + +- [AUR (Arch Linux)](https://github.com/akinomyoga/ble.sh/wiki/Manual-A1-Installation#user-content-AUR) `blesh-git` (devel), `blesh` (stable 0.3.4) +- [NixOS (nixpkgs)](https://github.com/akinomyoga/ble.sh/wiki/Manual-A1-Installation#user-content-nixpkgs) `blesh` (devel) +- [Guix](https://packages.guix.gnu.org/packages/blesh/0.4.0-devel2/) `blesh` (0.4.0-devel2) +
+ +
既存の ble.sh を更新 + +```bash +# 更新 (ble.sh をロードした状態で) + +ble-update + +# 更新 (ble.sh 外部から) + +bash /path/to/ble.sh --update +``` +
+ +
ble.sh のパッケージ作成 + +`ble.sh` は単にシェルスクリプトの集合ですので環境に依存せずにお使いいただけます (いわゆる "`noarch`") ので、 +単にリリースページからビルド済みの tar ボールをダウンロードし中身を `/tmp/blesh-package/usr/local` など所定の位置に配置するだけで問題ありません。 +それでも何らかの理由により自前でビルドする必要がある場合には以下のコマンドをお使いください。 +ビルドの為には git リポジトリ (`.git`) が必要になることにご注意ください。 + +```bash +# ビルド & パッケージ作成用コマンド + +git clone --recursive --depth 1 --shallow-submodules https://github.com/akinomyoga/ble.sh.git +make -C ble.sh install DESTDIR=/tmp/blesh-package PREFIX=/usr/local +``` + +パッケージ管理システムを用いたパッケージ更新方法を指定すると `ble-update` でそれが呼び出されます。 +更新方法を指定するにはスクリプトファイルを `${prefix}/share/blesh/lib/_package.bash` に配置します。 +スクリプトは次の様な変数と関数を定義します。但し `XXX` はパッケージ管理システムの名前に置き換えてください。 + +```bash +# ${prefix}/share/blesh/lib/_package.bash + +_ble_base_package_type=XXX + +function ble/base/package:XXX/update { + update-the-package-in-a-proper-way + return 0 +} +``` + +シェル関数がステータス 0 で終了した場合、更新が成功した事を表し `ble.sh` のリロードが自動的に行われます。 +シェル関数がステータス 6 で終了した場合、`ble.sh` のタイムスタンプが確認され、`ble.sh` が現セッションの開始時刻よりも新しい時に限りリロードが行われます。 +シェル関数がステータス 125 で終了した場合、`ble.sh` に組み込みの更新処理が試みられます。 +それ以外の場合には更新処理が中断されます。この場合、シェル関数が状況を説明するメッセージを出力するようにして下さい。 +具体例として `AUR` パッケージの [`_package.bash`](https://aur.archlinux.org/cgit/aur.git/tree/blesh-update.sh?h=blesh-git) も参考にしていただければ幸いです。 +
+ +## 機能概要 + +- **構文着色**: `fish` や `zsh-syntax-highlighting` のような文法構造に従った着色を行います。 + `zsh-syntax-highlighting` のような単純な着色ではなく、構文の入れ子構造や複数のヒアドキュメントなども正しく解析して着色します。 + 着色は[全て設定可能](https://github.com/akinomyoga/ble.sh/wiki/%E8%AA%AC%E6%98%8E%E6%9B%B8-%C2%A72-%E6%8F%8F%E7%94%BB)です。 +- **補完増強**: [補完](https://github.com/akinomyoga/ble.sh/wiki/%E8%AA%AC%E6%98%8E%E6%9B%B8-%C2%A77-%E8%A3%9C%E5%AE%8C)を大幅に増強します。 + **文法構造に応じた補完**、クォートやパラメータ展開を展開した上でのプログラム補完、**曖昧補完**に対応しています。 + また、候補をカーソルキーや TAB, S-TAB で選択できる + [**メニュー補完**](https://github.com/akinomyoga/ble.sh/wiki/%E8%AA%AC%E6%98%8E%E6%9B%B8-%C2%A77-%E8%A3%9C%E5%AE%8C#user-content-sec-menu-complete)、 + `fish` や `zsh-autosuggestions` のような + [**自動補完**](https://github.com/akinomyoga/ble.sh/wiki/%E8%AA%AC%E6%98%8E%E6%9B%B8-%C2%A77-%E8%A3%9C%E5%AE%8C#user-content-sec-auto-complete) + (Bash 4.0 以上) の機能もあります。 + 更に、従来 `peco` や `fzf` を呼び出さなければならなかった補完候補の絞り込みも + [**メニュー絞り込み**](https://github.com/akinomyoga/ble.sh/wiki/%E8%AA%AC%E6%98%8E%E6%9B%B8-%C2%A77-%E8%A3%9C%E5%AE%8C#user-content-sec-menu-filter) + (Bash 4.0 以上) として自然な形で組み込んでいます。 + 他に、[**動的略語展開**](https://github.com/akinomyoga/ble.sh/wiki/%E8%AA%AC%E6%98%8E%E6%9B%B8-%C2%A77-%E8%A3%9C%E5%AE%8C#user-content-sec-dabbrev) + や、[*zsh abbreviations*](https://unix.stackexchange.com/questions/6152/zsh-alias-expansion)・[`zsh-abbr`](https://github.com/olets/zsh-abbr) のような + [**静的略語展開**](https://github.com/akinomyoga/ble.sh/wiki/%E8%AA%AC%E6%98%8E%E6%9B%B8-%C2%A77-%E8%A3%9C%E5%AE%8C#user-content-sec-sabbrev) + にも対応しています。 +- **Vim編集モード**: `set -o vi` による編集モードを増強します。 + 挿入・ノーマルモードの他に(行・矩形)ビジュアルモード、置換モードなどの各種モードに対応しています。 + テキストオブジェクト・各種レジスタ・オペレータ・キーボードマクロなどにも対応しています。 + 拡張として `vim-surround` も提供しています。 +- 他にも + [**ステータス行**](https://github.com/akinomyoga/ble.sh/wiki/%E8%AA%AC%E6%98%8E%E6%9B%B8-%C2%A74-%E7%B7%A8%E9%9B%86#user-content-bleopt-prompt_status_line), + [**コマンド履歴共有**](https://github.com/akinomyoga/ble.sh/wiki/%E8%AA%AC%E6%98%8E%E6%9B%B8-%C2%A74-%E7%B7%A8%E9%9B%86#user-content-bleopt-history_share), + [**右プロンプト**](https://github.com/akinomyoga/ble.sh/wiki/%E8%AA%AC%E6%98%8E%E6%9B%B8-%C2%A74-%E7%B7%A8%E9%9B%86#user-content-bleopt-prompt_rps1), + [**過渡的プロンプト**](https://github.com/akinomyoga/ble.sh/wiki/%E8%AA%AC%E6%98%8E%E6%9B%B8-%C2%A74-%E7%B7%A8%E9%9B%86#user-content-bleopt-prompt_ps1_transient), + [**xterm タイトル**](https://github.com/akinomyoga/ble.sh/wiki/%E8%AA%AC%E6%98%8E%E6%9B%B8-%C2%A74-%E7%B7%A8%E9%9B%86#user-content-bleopt-prompt_xterm_title), + など様々な機能に対応しています。 + +注意: `ble.sh` は、(プロンプト (`PS1`)、エイリアス、関数などを提供する) 典型的な Bash 設定集と異なります。 +`ble.sh` はより低層の基盤を提供するもので、ユーザは自分でプロンプトやエイリアスを設定する必要があります。 +勿論 [`bash-it`](https://github.com/Bash-it/bash-it) や [`oh-my-bash`](https://github.com/ohmybash/oh-my-bash) の様な他の Bash 設定と一緒に使っていただくことも可能です。 + +> デモ +> +> ![ble.sh demo gif](https://github.com/akinomyoga/ble.sh/wiki/images/trial1.gif) + +## 来し方行く末 + +このプロジェクトは初めは `.bashrc` の片隅で行われた小さな実験からスタートしました。 +2013年5月に `zsh-syntax-highlighting` のとある記事に触発されたのがきっかけでした。 +初めは数百行のコードを書けば構文着色が簡単に実現できるのではないかと思って始めた実験ですが、 +すぐに行エディタを根本から書き直さなければ実現できないのではないかということが分かり、 +独立したファイルにコードを移動した後に `ble.sh` という名前を与えました。 +この名前は Zsh の行エディタ (*ZLE* (*Zsh Line Editor*)) を真似て、 +但しシェルで書かれているという事を意識して `.sh` という拡張子にしたように記憶しています。 +`ble.sh` の読み方について屡々訊かれるのですが、最初に書いたように特に定まった読み方はありません。 +最初の実験は2週間程コードを弄って原理的に行エディタを作れるという事を結論づけて終わりました。 +本格的な実装が始まったのは2015年2月の事で12月には公開しました。 +その時点で行エディタとしては普段遣いに堪える程度に完成していました。 +Vimモードの実装は2017年9月に始まり2018年3月に一先ず完成としました。 +続いて補完の拡張は2018年8月に始まり2019年2月には一通り完成しました。 +現在は漫然とメンテナンスしている所でいつになるかは分かりませんが、以下に挙げるような機能も加えたいと何となく考えています。 + +- 2013-06 v0.0 -- 実験 +- 2015-12 v0.1 -- 構文着色 [[v0.1.15](https://github.com/akinomyoga/ble.sh/releases/tag/v0.1.15)] +- 2018-03 v0.2 -- Vim モード [[v0.2.7](https://github.com/akinomyoga/ble.sh/releases/tag/v0.2.7)] +- 2019-02 v0.3 -- 拡張補完 [[v0.3.4](https://github.com/akinomyoga/ble.sh/releases/tag/v0.3.4)] +- 20xx-xx v0.4 (plan) -- プログラム着色 [[nightly build](https://github.com/akinomyoga/ble.sh/releases/tag/nightly)] +- 20xx-xx v0.5 (plan) -- TUI設定画面 +- 20xx-xx v0.6 (plan) -- エラー診断? + +## 制限および前提 + +`ble.sh` の実装形態から来る制限があります。 +ユーザー設定や他の Bash の枠組みとの干渉によって問題が起こる可能性があります。 + +- 既定では、実行コストの都合上、`ble.sh` は前回のコマンドライン実行後の `PIPESTATUS` を設定しません。代わりに `BLE_PIPESTATUS` を参照することができます。 + もし本当に `PIPESTATUS` 経由でこれらの値を利用する必要がある場合には設定 `bleopt exec_restore_pipestatus=1` を使用して下さい。 +- 既定では、よりなめらかな描画の為に、`ble.sh` は `PROMPT_COMMAND` および `PRECMD` フックが端末内のカーソル位置およびレイアウトを変更しないことを想定します。 + `PROMPT_COMMAND` および `PRECMD` で出力を行うまたはカーソル位置を変更する設定をお持ちの場合は、設定 `bleopt prompt_command_changes_layout=1` を使用してください。 +- `ble.sh` は一般的な変数名のシェル変数や環境変数 (`LC_*` など) がグローバルで読み込み専用変数になっていないことを想定します。 + Bash ではグローバル変数の読み込み専用属性は関数のローカルスコープに於いても制限を与えます。 + つまり、同名の異なるローカル変数さえ定義することができません。 + この問題は `ble.sh` 固有の制限ではなく、あらゆる Bash の枠組みがグローバルの読み込み専用変数に影響を受けます。 + 一般的にグローバルスコープに読み込み変数を設定することはセキュリティ的な理由がない限りは非推奨と考えられています (参照 [[1]](https://lists.gnu.org/archive/html/bug-bash/2019-03/threads.html#00150), [[2]](https://lists.gnu.org/archive/html/bug-bash/2020-04/threads.html#00200), [[3]](https://mywiki.wooledge.org/BashProgramming?highlight=%28%22readonly%22%20flag,%20or%20an%20%22integer%22%20flag,%20but%20these%20are%20mostly%20useless,%20and%20serious%20scripts%20shouldn%27t%20be%20using%20them%29#Variables))。 + また、`ble.sh` はビルトインコマンド `readonly` をシェル関数で置き換え、グローバル変数を読み込み専用にするのをブロックします。 + 例外として、全て大文字の変数 (`ble.sh` が内部使用するものを除く) および `_*` の形の変数 (`_ble_*` および `__ble_*` を除く) を読み込み専用にすることは可能です。 +- `ble.sh` は Bash のビルトインコマンド (`trap`, `readonly`, `bind`, `history`, `read`, `exit`) をシェル関数で上書きし、`ble.sh` と干渉しないようにその振る舞いを調整します。 + ユーザーまたは他の枠組みが元のビルトインを直接呼び出した場合、または `ble.sh` の定義したシェル関数を別のシェル関数で上書きした場合、正しい動作を保証できません。 +- シェル及び端末の設定はラインエディタ用とコマンド実行用で異なります。`ble.sh` + はラインエディタ向けに必要な調整を行い、ユーザが指定したコマンド実行用の設定 + をできるだけ復元します。但し、様々な理由により、一部の設定については意図的に + 復元しない場合や復元することができない場合があります。詳細については + [wiki](https://github.com/akinomyoga/ble.sh/wiki/Internals#internal-and-external) + (英語) に情報があります。 + +# 1 使い方 + +## 1.1 最新の git repository のソースから生成して試す (バージョン ble-0.4) + +### ble.sh 生成 + +`ble.sh` を生成する為には `gawk` (GNU awk) と `gmake` (GNU make) が必要です。 +以下のコマンドで生成できます。 +GNU make が `gmake` という名前でインストールされている場合は、`make` の代わりに `gmake` として下さい。 +```console +$ git clone --recursive https://github.com/akinomyoga/ble.sh.git +$ cd ble.sh +$ make +``` +スクリプトファイル `ble.sh` がサブディレクトリ `ble.sh/out` 内に生成されます。 + +### 試用 + +生成された `ble.sh` は `source` コマンドを用いてお試しいただけます。 + +```console +$ source out/ble.sh +``` + +### インストール + +指定したディレクトリにインストールするには `make install` コマンドを使用します。 + +```bash +# ~/.local/share/blesh にインストール +make install + +# 指定したディレクトリにインストール +make install INSDIR=/path/to/blesh + +# パッケージ作成用 (パッケージ管理者用) +make install DESTDIR=/tmp/blesh-package PREFIX=/usr/local +``` + +Make 変数 `DESTDIR` または `PREFIX` が指定されている時、`ble.sh` は `$DESTDIR/$PREFIX/share/blesh` にコピーされます。 +それ以外で Make 変数 `INSDIR` が指定されている時、直接 `$INSDIR` にインストールされます。 +更にそれ以外で環境変数 `$XDG_DATA_HOME` が指定されている時、`$XDG_DATA_HOME/blesh` にインストールされます。 +以上の変数が何れも指定されていない時の既定のインストール先は `~/.local/share/blesh` です。 + +インストール時にコード中のコメントは自動で削除されますが、コメントを保持したい場合は `strip_comment=no` を `make` の引数に指定して下さい。 + +`.bashrc` の設定に関しては[節1.3](#set-up-bashrc)を御覧ください。 + +## 1.2 GitHub Releases から tar をダウンロードして使う + +ダウンロード・試用・インストールの方法については各リリースページの説明を御覧ください。 +現在、安定版は開発版に比べてかなり古いので様々な機能が欠けている事にご注意下さい。 + +- 開発版 [v0.4.0-devel3](https://github.com/akinomyoga/ble.sh/releases/tag/v0.4.0-devel3) (2020-12), [nightly build](https://github.com/akinomyoga/ble.sh/releases/tag/nightly) +- 安定版 [v0.3.4](https://github.com/akinomyoga/ble.sh/releases/tag/v0.3.4) (2019-02 fork) 拡張補完 +- 安定版 [v0.2.7](https://github.com/akinomyoga/ble.sh/releases/tag/v0.2.7) (2018-03 fork) Vim モード +- 安定版 [v0.1.15](https://github.com/akinomyoga/ble.sh/releases/tag/v0.1.15) (2015-12 fork) 構文着色 + +## 1.3 `.bashrc` に設定する + +対話シェルで常用する場合には `.bashrc` に設定を行います。 +単に `ble.sh` を `source` して頂くだけでも大抵の場合動作しますが、 +より確実に動作させる為には以下の様にコードを記述します。 +```bash +# bashrc + +# .bashrc の先頭近くに以下を追加して下さい。 +[[ $- == *i* ]] && source /path/to/blesh/ble.sh --noattach + +# 間に通常の bashrc の内容を既述します。 + +# .bashrc の末端近くに以下を追加して下さい。 +[[ ${BLE_VERSION-} ]] && ble-attach +``` + +`source /path/to/ble.sh` 及び `ble-attach` を呼び出す時は、 +標準ストリーム (`stdin`, `stdout`, `stderr`) が現在のセッションの制御端末とは別の物にリダイレクトされていない様にして下さい。 +`source /path/to/ble.sh` をシェル関数の中から実行するのは避けて下さい。 +この「より確実な設定」が必要になる詳細な条件については [Discussion #254 への回答 (英語)](https://github.com/akinomyoga/ble.sh/discussions/254#discussioncomment-4284757) で説明されています。 + +## 1.4 初期化スクリプト `~/.blerc` について + +ユーザー設定は初期化スクリプト `~/.blerc` (またはもし `~/.blerc` が見つからなければ `${XDG_CONFIG_HOME:-$HOME/.config}/blesh/init.sh`) に記述します。 +テンプレートとしてリポジトリの [`blerc.template`](https://github.com/akinomyoga/ble.sh/blob/master/blerc.template) というファイルを利用できます。 +初期化スクリプトは `ble.sh` ロード時に自動で読み込まれる Bash スクリプトなので、Bash で使えるコマンドを初期化スクリプトの中で利用できます。 +初期化スクリプトの位置を変更する場合には、`source ble.sh` 時に `--rcfile INITFILE` を指定します。以下に例を挙げます。 + +```bash +# in bashrc + +# Example 1: ~/.blerc will be used by default +[[ $- == *i* ]] && source /path/to/blesh/ble.sh --noattach + +# Example 2: /path/to/your/blerc will be used +[[ $- == *i* ]] && source /path/to/blesh/ble.sh --noattach --rcfile /path/to/your/blerc +``` + +## 1.5 アップデート + +Git (`git'), GNU awk (`gawk`), 及び GNU make (`make`) が必要になります。 +`ble-0.3` 以上をお使いの場合は `ble.sh` をロードした状態で `ble-update` を実行して下さい。 + +```bash +$ ble-update +``` + +`ble-0.4` 以上をお使いの場合は `ble.sh` をロードしなくても以下のコマンドで更新可能です。 + +```bash +$ bash /path/to/ble.sh --update +``` + +それ以外の場合には、以下のように `git pull` で最新版を入手・インストールできます。 + +```bash +cd ble.sh # ※既に持っている git リポジトリに入る +git pull +git submodule update --recursive --remote +make +make INSDIR="$HOME/.local/share/blesh" install +``` + +## 1.6 アンインストール + +基本的に `ble.sh` ディレクトリとユーザの追加した設定を単に削除していただければ問題ありません。 + +- 全ての `ble.sh` セッション (`ble.sh` をロードしている Bash 対話セッション) を終了します。 +- 関連するユーザーデータを削除します。これらのデータを保持しておきたい場合は必要に応じてスキップしてください。 + - `.bashrc` に追加した行があれば削除します。 + - `blerc` 設定ファイル (`~/.blerc` または `~/.config/blesh/init.sh`) があれば削除します。 + - 状態ディレクトリ `~/.cache/blesh` が生成されていればそれを削除します。 +- `ble.sh` をインストールしたディレクトリを削除します。git リポジトリ内の + `out/ble.sh` を直接ご使用の場合はインストールしたディレクトリは、git リポジト + リ自体です。`make intall` を用いてインストールした場合は、インストールしたディ + レクトリは `/share/blesh` です。但し、`` (既定値: `~/.local`) + は `make install` に指定した `PREFIX` の値です。生成済み tarball をご利用の際 + には、インストールしたディレクトリは tarball を展開して得られたディレクトリを + 配置した場所です。 +- キャッシュディレクトリ `~/.cache/blesh` が生成されていればそれを削除します。 +- 一時ディレクトリ `/tmp/blesh` が生成されていればそれを削除します。これは `/tmp` の内容が自動的にクリアされないシステムで必要です。 + +# 2 基本設定 + +ここでは `~/.blerc` に記述する基本的な設定を幾つか紹介します。 +[質問と回答](https://github.com/akinomyoga/ble.sh/wiki/%E8%B3%AA%E5%95%8F%E3%81%A8%E5%9B%9E%E7%AD%94)、 +[逆引きレシピ](https://github.com/akinomyoga/ble.sh/wiki/%E9%80%86%E5%BC%95%E3%81%8D%E3%83%AC%E3%82%B7%E3%83%94)、 +[`contrib` リポジトリ](https://github.com/akinomyoga/blesh-contrib/blob/master/README-ja.md) にも便利な設定があります。 +その他の全ての設定項目はテンプレート [`blerc.template`](https://github.com/akinomyoga/ble.sh/blob/master/blerc.template) に含まれています。 +詳細な説明に関しては[説明書](https://github.com/akinomyoga/ble.sh/wiki/%E7%9B%AE%E6%AC%A1)を参照して下さい。 + +## 2.1 Vim モード + +Vim モードについては [Wiki の説明ページ](https://github.com/akinomyoga/ble.sh/wiki/Vi-(Vim)-editing-mode) を御覧ください。 + +## 2.2 各機能の無効化 + +よくお尋ね頂くご質問の一つにそれぞれの機能をどのように無効化すれば良いのかというものが御座います。 +各機能の無効化方法を以下にまとめます。 + +```bash +# 構文着色を無効化 +bleopt highlight_syntax= + +# ファイル名に基づく構文着色を無効化 +bleopt highlight_filename= + +# 変数の種類に基づく構文着色の無効化 +bleopt highlight_variable= + +# 自動補完の無効化 (自動補完は Bash 4.0 以降にて既定で有効です) +bleopt complete_auto_complete= +# Tip: 代わりに自動補完の起動遅延をミリ秒単位でご指定いただくこともできます。 +bleopt complete_auto_delay=300 + +# コマンド履歴に基づく自動補完の無効化 +bleopt complete_auto_history= + +# 曖昧補完の無効化 +bleopt complete_ambiguous= + +# TAB によるメニュー補完の無効化 +bleopt complete_menu_complete= + +# メニュー自動絞り込みの無効化 (Bash 4.0 以降にて既定で有効化されます) +bleopt complete_menu_filter= + +# 行末マーカー "[ble: EOF]" の無効化 +bleopt prompt_eol_mark='' +# Tip: 代わりに他の文字列をご指定頂くこともできます。 +bleopt prompt_eol_mark='⏎' + +# 終了ステータスマーカー "[ble: exit %d]" の無効化 +bleopt exec_errexit_mark= +# Tip: 代わりに他の文字列をご指定頂くこともできます。 +bleopt exec_errexit_mark=$'\e[91m[error %d]\e[m' + +# コマンド実行時間マーカー "[ble: elapsed 1.203s (CPU 0.4%)]" の無効化 +bleopt exec_elapsed_mark= +# Tip: 代わりに別の文字列をご指定いただくこともできます。 +bleopt exec_elapsed_mark=$'\e[94m[%ss (%s %%)]\e[m' +# Tip: マーカーを表示する条件を変更することも可能です。 +bleopt exec_elapsed_enabled='sys+usr>=10*60*1000' # 例: 合計CPU時間が 10 分以上の時に表示 + +# 終了マーカー "[ble: exit]" の無効化 +bleopt exec_exit_mark= + +# その他のマーカー "[ble: ...]" の無効化 +bleopt edit_marker= +bleopt edit_marker_error= +``` + +## 2.3 曖昧文字幅 + +設定 `char_width_mode` を用いて、曖昧文字幅を持つ文字 (Unicode 参考特性 `East_Asian_Width` が `A` (Ambiguous) の文字) の幅を制御できます。 +現在は 4 つの選択肢 `emacs`, `west`, `east`, `auto` が用意されています。 +設定値 `emacs` を指定した場合、GNU Emacs における既定の文字幅と同じ物を使います。 +設定値 `west` を指定した場合、全ての曖昧文字幅を 1 (半角) と解釈します。 +設定値 `east` を指定した場合、全ての曖昧文字幅を 2 (全角) と解釈します。 +設定値 `auto` を指定した場合、`west` か `east` かを端末とのやり取りに基づいて自動判定します。 +既定値は `auto` です。この設定項目は、利用している端末の振る舞いに応じて適切に設定する必要があります。 +例えば `west` に設定する場合は以下の様にします: + +```bash +bleopt char_width_mode='west' +``` + +## 2.4 文字コード + +設定 `input_encoding` は入力の文字コードを制御するのに使います。現在 `UTF-8` と `C` のみに対応しています。 +設定値 `C` を指定した場合は、受信したバイト値が直接文字コードであると解釈されます。 +既定値は `UTF-8` です。`C` に設定を変更する場合には以下の様にします: + +```bash +bleopt input_encoding='C' +``` + +## 2.5 ベル + +設定 `edit_bell` は編集関数 `bell` の振る舞いを制御するコロン区切りのリストです。 +値 `abell`, `vbell`, `visual` はそれぞれ対応するベルの提示方法を有効化します。 +値 `abell` は音による通知に対応し、制御文字の BEL (0x07) を `stderr` に出力します。 +値 `vbell` は画面での通知に対応し、端末画面上にメッセージを表示します。 +値 `visual` は画面の反転に対応し、DECSCNM を用いて端末画面を瞬間的に反転します。 +既定では音による通知のみが有効になっています。 + +設定 `vbell_default_message` は画面での通知で使用するメッセージ文字列を指定します。既定値は `' Wuff, -- Wuff!! '` です。 +設定 `vbell_duration` は画面での通知を表示する時間の長さを指定します。単位はミリ秒です。既定値は `2000` です。 +設定 `vbell_align` は画面での通知の表示位置を指定します。`left`, `center`, `right` が指定できます。 + +例えば、以下の設定によって、音による通知を無効化して画面での通知を設定・有効化できます。 + +```bash +bleopt edit_bell=vbell vbell_{default_message=' BEL ',duration=3000,align=right} +``` + +## 2.6 着色の設定 + +構文に従った着色で使用される、各文法要素の色と属性は `ble-face` シェル関数で設定します。 +既定の設定は以下のコードに対応します: +```bash +# 編集に関連する着色の設定 +ble-face -s region bg=60,fg=white +ble-face -s region_target bg=153,fg=black +ble-face -s region_match bg=55,fg=white +ble-face -s region_insert fg=12,bg=252 +ble-face -s disabled fg=242 +ble-face -s overwrite_mode fg=black,bg=51 +ble-face -s vbell reverse +ble-face -s vbell_erase bg=252 +ble-face -s vbell_flash fg=green,reverse +ble-face -s prompt_status_line fg=231,bg=240 + +# 構文着色の設定 +ble-face -s syntax_default none +ble-face -s syntax_command fg=brown +ble-face -s syntax_quoted fg=green +ble-face -s syntax_quotation fg=green,bold +ble-face -s syntax_escape fg=magenta +ble-face -s syntax_expr fg=26 +ble-face -s syntax_error bg=203,fg=231 +ble-face -s syntax_varname fg=202 +ble-face -s syntax_delimiter bold +ble-face -s syntax_param_expansion fg=purple +ble-face -s syntax_history_expansion bg=94,fg=231 +ble-face -s syntax_function_name fg=92,bold +ble-face -s syntax_comment fg=242 +ble-face -s syntax_glob fg=198,bold +ble-face -s syntax_brace fg=37,bold +ble-face -s syntax_tilde fg=navy,bold +ble-face -s syntax_document fg=94 +ble-face -s syntax_document_begin fg=94,bold +ble-face -s command_builtin_dot fg=red,bold +ble-face -s command_builtin fg=red +ble-face -s command_alias fg=teal +ble-face -s command_function fg=92 +ble-face -s command_file fg=green +ble-face -s command_keyword fg=blue +ble-face -s command_jobs fg=red +ble-face -s command_directory fg=26,underline +ble-face -s command_suffix fg=white,bg=green +ble-face -s command_suffix_new fg=white,bg=brown +ble-face -s filename_directory underline,fg=26 +ble-face -s filename_directory_sticky underline,fg=white,bg=26 +ble-face -s filename_link underline,fg=teal +ble-face -s filename_orphan underline,fg=teal,bg=224 +ble-face -s filename_executable underline,fg=green +ble-face -s filename_setuid underline,fg=black,bg=220 +ble-face -s filename_setgid underline,fg=black,bg=191 +ble-face -s filename_other underline +ble-face -s filename_socket underline,fg=cyan,bg=black +ble-face -s filename_pipe underline,fg=lime,bg=black +ble-face -s filename_character underline,fg=white,bg=black +ble-face -s filename_block underline,fg=yellow,bg=black +ble-face -s filename_warning underline,fg=red +ble-face -s filename_url underline,fg=blue +ble-face -s filename_ls_colors underline +ble-face -s varname_array fg=orange,bold +ble-face -s varname_empty fg=31 +ble-face -s varname_export fg=200,bold +ble-face -s varname_expr fg=92,bold +ble-face -s varname_hash fg=70,bold +ble-face -s varname_number fg=64 +ble-face -s varname_readonly fg=200 +ble-face -s varname_transform fg=29,bold +ble-face -s varname_unset fg=124 +ble-face -s argument_option fg=teal +ble-face -s argument_error fg=black,bg=225 + +# 補完の着色 +ble-face -s auto_complete fg=238,bg=254 +ble-face -s menu_desc_default none +ble-face -s menu_desc_type ref:syntax_delimiter +ble-face -s menu_desc_quote ref:syntax_quoted +ble-face -s menu_filter_fixed bold +ble-face -s menu_filter_input fg=16,bg=229 +``` + +現在の描画設定の一覧は以下のコマンドでも確認できます (`ble-face` を無引数で呼び出す)。 +```console +$ ble-face +``` + +色コードはシェル関数 `ble-color-show` (`ble.sh` 内で定義) で確認できます。 +```console +$ ble-color-show +``` + +## 2.7 キーバインディング + +キーバインディングはシェル関数 `ble-bind` を使って変更できます。 +例えば C-x h を入力した時に "Hello, world!" と挿入させたければ以下のようにします。 +```bash +ble-bind -f 'C-x h' 'insert-string "Hello, world!"' +``` + +上記の C-x h の様なキー表記については +[マニュアル §3.1](https://github.com/akinomyoga/ble.sh/wiki/%E8%AA%AC%E6%98%8E%E6%9B%B8-%C2%A73-%E3%82%AD%E3%83%BC%E3%83%90%E3%82%A4%E3%83%B3%E3%83%87%E3%82%A3%E3%83%B3%E3%82%B0#user-content-sec-kspecs) で詳細に説明されています。 +スペース・タブ・エンター・バックスペース・エスケープなどの特殊キーの表記については +[マニュアル §3.1.1](https://github.com/akinomyoga/ble.sh/wiki/%E8%AA%AC%E6%98%8E%E6%9B%B8-%C2%A73-%E3%82%AD%E3%83%BC%E3%83%90%E3%82%A4%E3%83%B3%E3%83%87%E3%82%A3%E3%83%B3%E3%82%B0#user-content-sec-kspecs-ret) で説明されています: +スペースは SP と表現します。 +タブキーは端末によって C-i または TAB と表現します。 +エンター・リターンキーは端末によって C-m または RET と表現します。 +バックスペースは端末によって C-?, DEL, C-h, または BS 等様々な表現があります。 +Ctrl+ReturnShift+Return などの修飾された特殊キーの取り扱いについては +[マニュアル §3.6.4](https://github.com/akinomyoga/ble.sh/wiki/%E8%AA%AC%E6%98%8E%E6%9B%B8-%C2%A73-%E3%82%AD%E3%83%BC%E3%83%90%E3%82%A4%E3%83%B3%E3%83%87%E3%82%A3%E3%83%B3%E3%82%B0#user-content-sec-modifyOtherKeys-manual) で説明されています。 +お使いの端末が `modifyOtherKeys` に対応していない場合、手動で各キーの組み合わせに対応するエスケープシーケンスを設定する必要があります。 + + +M-c を入力した時にコマンドを実行するには以下のようにします。 + +```bash +ble-bind -c 'M-c' 'my-command' +``` + +C-r を入力した時に、ユーザー定義編集関数 (Bash の `bind -x` で指定するのと同様の物) を実行するには以下のようにします。 + +```bash +ble-bind -x 'C-r' 'my-edit-function' +``` + +既存のキーバインディングは以下のコマンドで確認できます。 +```console +$ ble-bind -P +``` + +以下のコマンドでキーバインディングに使える編集関数一覧を確認できます。 +```console +$ ble-bind -L +``` + +一つのキーで複数の編集関数を呼び出したい場合は、以下の例の様に、 +`ble/widget/編集関数の名前` という名前のシェル関数を通して新しい編集関数を定義できます。 +既存の標準の編集関数と名前が重複しない様に、 +編集関数の名前は `ユーザー名/`, `my/`, `blerc/`, `dotfiles/` などで始める事が強く推奨されます。 + +```bash +# C-t で複数の操作を行う例 +function ble/widget/my/example1 { + ble/widget/beginning-of-logical-line + ble/widget/insert-string 'echo $(' + ble/widget/end-of-logical-line + ble/widget/insert-string ')' +} +ble-bind -f C-t my/example1 +``` + +## 2.8 fzf との統合 + +`fzf` を `ble.sh` と一緒にお使いいただく場合には、[`contrib/fzf` 統合機能](https://github.com/akinomyoga/blesh-contrib#pencil-fzf-integration) を用いて `fzf` を設定していただく必要があります。 +詳細についてはリンク先の説明を御覧ください。 + +```bash +# blerc + +# 注意: fzf を bash_completion と組み合わせて使用する場合は、fzf-completion よ +# りも先に bash_completion をロードしておく必要があります。これは ble.sh と関係 +# なく必要です。 +source /etc/profile.d/bash_completion.sh + +ble-import -d integration/fzf-completion +ble-import -d integration/fzf-key-bindings +``` + +上記 `ble-import` に指定されているオプション `-d` は指定したファイルの読み込み +を遅延させます。このように設定した場合、指定したファイルはプロンプトが表示され +た後にバックグランドで読み込まれます。詳細に関しては [`ble-import` - 説明書 +§8](https://github.com/akinomyoga/ble.sh/wiki/Manual-%C2%A78-Miscellaneous#user-content-fn-ble-import) +を御覧ください。もし fzf の設定を読み込んだ後で更に設定を行うには、四つの方法が +ございます。最も単純な方法はオプション `-d` を指定しない方法 [1] です。或いは、 +`ble-import -d` [2] または `ble/util/idle.push` [3] を用いて追加設定も同様に遅 +延させることができます。または、fzf 設定ファイルの読み込み完了に対して +`ble-import -C` [4] を用いてフックを設定することもできます。 + +```bash +# [1] オプション -d を使用しない +ble-import integration/fzf-completion +ble-import integration/fzf-key-bindings + + +# [2] 追加設定も ble-import -d を使う +ble-import -d integration/fzf-completion +ble-import -d integration/fzf-key-bindings +ble-import -d '' + +# [3] 追加設定を ble/util/idle.push で登録 +ble-import -d integration/fzf-completion +ble-import -d integration/fzf-key-bindings +ble/util/idle.push '' + +# [4] 追加設定を ble-import -C で登録 +ble-import -d integration/fzf-completion +ble-import -d integration/fzf-key-bindings +ble-import -C '' integration/fzf-key-bindings +``` + +# 3 ヒント + +## 3.1 複数行モード + +コマンドラインに改行が含まれている場合、複数行モード (MULTILINE モード) になります。 + +C-v C-j または C-q C-j とすると改行をコマンドラインの一部として入力できます。 +複数行モードでは、RET (C-m) はコマンドの実行ではなく新しい改行の挿入になります。 +複数行モードでは、C-j を用いてコマンドを実行して下さい。 + +`shopt -s cmdhist` が設定されているとき (既定)、もし RET (C-m) を押した時にコマンドラインが構文的に閉じていなければ、コマンドの実行ではなく改行の挿入を行います。 + +## 3.2 Vim モード + +`.bashrc` に `set -o vi` が設定されているとき、または `.inputrc` に `set editing-mode vi` が設定されているとき、vim モードが有効になります。 +Vim モードの詳細な設定については [Wiki のページ (英語)](https://github.com/akinomyoga/ble.sh/wiki/Vi-(Vim)-editing-mode) を御覧ください。 + +## 3.3 自動補完 + +Bash 4.0 以降では自動補完が有効になり、予測候補が表示されます。 +候補を確定するには S-RET を入力します (編集文字列の末尾にいる時は right, C-f または end でも確定できます)。 +表示されている候補の初めの単語だけ部分的に確定する時は M-f または M-right を入力します。 +現在の候補で確定しそのままコマンドを実行する場合には C-RET (※お使いの端末が対応している時) を入力します。 +お使いの端末が対応していない時は [マニュアル §3.6.4](https://github.com/akinomyoga/ble.sh/wiki/Manual-%C2%A73-Key-Binding#user-content-sec-modifyOtherKeys-manual) を参照して下さい。 + + +## 3.4 静的略語展開 + +特定の単語を静的略語展開に登録することで好きな文字列に展開することができます。 +登録済み単語に一致する単語の直後で SP を入力した時に静的略語展開が起きます。 +例えば、以下の設定をしておくと `command L` まで入力した状態で SP を押した時に、コマンドラインが `command | less` に展開されます。 + +```bash +# blerc +ble-sabbrev L='| less' +``` + +実際に実行したいコマンドに含まれる可能性の低い単語として、`\` で始まる単語を静的略語展開に登録することもお薦めです。 + +```bash +# blerc +ble-sabbrev '\L'='| less' +``` + +`~` で始まる静的略語展開は / でも展開されます。これは Zsh の名前付きディレクトリ (named directories) に模した使い方ができます。 +例えば、以下の設定の下で `~mybin/` と入力すると、`/home/user/bin/` など (`HOME=/home/user` の場合) に展開されます。 + +```bash +# blerc + +ble-sabbrev "~mybin=$HOME/bin" +``` + +# 4 謝辞 + +GitHub の Issue/PR を通して多くの方からフィードバックを頂き、皆様に本当に感謝しております。 +特に以下の方には大きな寄与を受けたので言及させていただきます。 + +- [`@cmplstofB`](https://github.com/cmplstofB) 様には vim モードの実装において初期よりテスト及び様々な提案をしていただきました。 +- [`@dylankb`](https://github.com/dylankb) 様には `fzf` との互換性や `ble.sh` 初期化に関連して様々な問題報告をいただきました。 +- [`@rux616`](https://github.com/rux616) 様には幾つかの問題報告および `.blerc` の既定パス解決のバグ修正をいただきました。 +- [`@timjrd`](https://github.com/timjrd) 様には補完の枠組みの高速化に関する PR をいただきました。 +- [`@3ximus`](https://github.com/3ximus) 様には広範囲に渡る様々な問題について報告いただきました。 +- [`@SuperSandro2000`](https://github.com/SuperSandro2000) 様には NixOS 関係を始め様々なご報告をいただきました。 diff --git a/.local/share/blesh/doc/README.md b/.local/share/blesh/doc/README.md new file mode 100644 index 0000000..7411f94 --- /dev/null +++ b/.local/share/blesh/doc/README.md @@ -0,0 +1,792 @@ +[ Languages: **English** | [日本語](README-ja_JP.md) (Japanese) ] + +

ble.sh (/blɛʃ/) ―Bash Line Editor―

+

+[ README | Manual | +Q&A | +contrib | +Recipes ] +

+ +*Bash Line Editor* (`ble.sh`) is a command line editor written in pure Bash which replaces the default GNU Readline. + +The current devel version is 0.4. +This script supports Bash 3.0 or higher although we recommend using `ble.sh` with release versions of **Bash 4.0 or higher**. +Currently, only `UTF-8` encoding is supported for non-ASCII characters. +This script is provided under the [**BSD License**](LICENSE.md) (3-clause BSD license). + +Disclaimer: The core part of the line editor is written in **pure Bash**, but +`ble.sh` relies on POSIX `stty` to set up TTY states before and after the execution of user commands. +It also uses other POSIX utilities for acceleration +in some parts of initialization and cleanup code, +processing of large data in completions, pasting large data, etc. + +Pronunciation: The easiest pronunciation of `ble.sh` that users use is /blɛʃ/, but you can pronounce it as you like. +I do not specify the canonical way of pronouncing `ble.sh`. +In fact, I personally call it simply /biːɛliː/ or verbosely read it as /biːɛliː dɑt ɛseɪtʃ/ in my head. + +## Quick instructions + +To use `ble.sh`, Bash 3.0+ and POSIX standard utilities are required. + +There are two ways to get `ble.sh`: to download and build `ble.sh` using `git`, or to download the nightly build using `curl` or `wget`. +For the detailed descriptions, see [Sec 1.1](#get-from-source) and [Sec 1.2](#get-from-tarball) for trial/installation, +and [Sec 1.3](#set-up-bashrc) for the setup of your `~/.bashrc`. + +> [!NOTE] +> If you want to **use fzf with `ble.sh`**, you need to check [Sec +> 2.8](#fzf-integration). + +
Download and generate ble.sh using git + +This requires the commands `git`, `make` (GNU make), and `gawk` (GNU awk). +In the following, please replace `make` with `gmake` if your system provides GNU make as `gmake` (such as in BSD). + +```bash +# TRIAL without installation + +git clone --recursive --depth 1 --shallow-submodules https://github.com/akinomyoga/ble.sh.git +make -C ble.sh +source ble.sh/out/ble.sh + +# Quick INSTALL to BASHRC (If this doesn't work, please follow Sec 1.3) + +git clone --recursive --depth 1 --shallow-submodules https://github.com/akinomyoga/ble.sh.git +make -C ble.sh install PREFIX=~/.local +echo 'source ~/.local/share/blesh/ble.sh' >> ~/.bashrc +``` + +The build process integrates multiple Bash script files into a single Bash script `ble.sh` with pre-processing, +places other module files in appropriate places, and strips code comments for a shorter initialization time. + +Note: This does not involve any C/C++/Fortran compilations and generating binaries, so C/C++/Fortran compilers are not needed. +Some people seem to believe that one always needs to use `make` with C/C++/Fortran compilers to generate binaries. +They complain about `ble.sh`'s make process, but it comes from the lack of knowledge on the general principle of `make`. +You may find C/C++ programs in the repository, but they are used to update the Unicode character table from the Unicode database when a new Unicode standard appears. +The generated table is included in the repository: +[`canvas.GraphemeClusterBreak.sh`](https://github.com/akinomyoga/ble.sh/blob/master/src/canvas.GraphemeClusterBreak.sh), +[`canvas.c2w.musl.sh`](https://github.com/akinomyoga/ble.sh/blob/master/src/canvas.c2w.musl.sh), +[`canvas.c2w.sh`](https://github.com/akinomyoga/ble.sh/blob/master/src/canvas.c2w.sh), +and [`canvas.emoji.sh`](https://github.com/akinomyoga/ble.sh/blob/master/src/canvas.emoji.sh), +so there is no need to run these C/C++ programs in the build process. +Another C file is used as an adapter in an old system MSYS1, +which is used with an old compiler toolchain in Windows, but it will never be used in Unix-like systems. +Each file used in the build process is explained in [`make/README.md`](make/README.md). +
+ +
Download the nightly build with curl + +This requires the commands `curl`, `tar` (with the support for the `J` flag), and `xz` (XZ Utils). + +```bash +# TRIAL without installation + +curl -L https://github.com/akinomyoga/ble.sh/releases/download/nightly/ble-nightly.tar.xz | tar xJf - +source ble-nightly/ble.sh + +# Quick INSTALL to BASHRC (If this doesn't work, please follow Sec 1.3) + +curl -L https://github.com/akinomyoga/ble.sh/releases/download/nightly/ble-nightly.tar.xz | tar xJf - +bash ble-nightly/ble.sh --install ~/.local/share +echo 'source ~/.local/share/blesh/ble.sh' >> ~/.bashrc +``` + +After the installation, the directory `ble-nightly` can be removed. +
+ +
Download the nightly build with wget + +This requires the commands `wget`, `tar` (with the support for the `J` flag), and `xz` (XZ Utils). + +```bash +# TRIAL without installation + +wget -O - https://github.com/akinomyoga/ble.sh/releases/download/nightly/ble-nightly.tar.xz | tar xJf - +source ble-nightly/ble.sh + +# Quick INSTALL to BASHRC (If this doesn't work, please follow Sec 1.3) + +wget -O - https://github.com/akinomyoga/ble.sh/releases/download/nightly/ble-nightly.tar.xz | tar xJf - +bash ble-nightly/ble.sh --install ~/.local/share +echo 'source ~/.local/share/blesh/ble.sh' >> ~/.bashrc +``` + +After the installation, the directory `ble-nightly` can be removed. +
+ +
Install a package using a package manager (currently only a few packages) + +This only requires the corresponding package manager. + +- [AUR (Arch Linux)](https://github.com/akinomyoga/ble.sh/wiki/Manual-A1-Installation#user-content-AUR) `blesh-git` (devel), `blesh` (stable 0.3.4) +- [NixOS (nixpkgs)](https://github.com/akinomyoga/ble.sh/wiki/Manual-A1-Installation#user-content-nixpkgs) `blesh` (devel) +- [Guix](https://packages.guix.gnu.org/packages/blesh) `blesh` (devel) +
+ +
Update an existing copy of ble.sh + +```bash +# UPDATE (in a ble.sh session) + +ble-update + +# UPDATE (outside ble.sh sessions) + +bash /path/to/ble.sh --update +``` +
+ +
Create a package of ble.sh + +Since `ble.sh` is just a set of shell scripts and do not contain any binary (i.e., "`noarch`"), +you may just download the pre-built tarball from release pages and put the extracted contents in e.g. `/tmp/blesh-package/usr/local`. +Nevertheless, if you need to build the package from the source, please use the following commands. +Note that the git repository (`.git`) is required for the build. + +```bash +# BUILD & PACKAGE (for package maintainers) + +git clone --recursive https://github.com/akinomyoga/ble.sh.git +make -C ble.sh install DESTDIR=/tmp/blesh-package PREFIX=/usr/local +``` + +When you would like to tell `ble.sh` the way to update the package for `ble-update`, +you can place `_package.bash` at `${prefix}/share/blesh/lib/_package.bash`. +The file `_package.bash` is supposed to define a shell variable and a shell function +as illustrated in the following example (please replace `XXX` with the package management system): + +```bash +# ${prefix}/share/blesh/lib/_package.bash + +_ble_base_package_type=XXX + +function ble/base/package:XXX/update { + update-the-package-in-a-proper-way + return 0 +} +``` + +When the shell function returns exit status 0, it means that the update has been successfully done, and the reload of `ble.sh` will be automatically happen. +When the shell function returns exit status 6, the timestamp of `ble.sh` is checked, and the reload of `ble.sh` only happens when `ble.sh` is actually update. +When the shell function returns exit status 125, the default `ble.sh` update procedure is attempted. +Otherwise, the updating procedure is canceled, where any message explaining situation should be output by the shell function. +An example `_package.bash` for `AUR` can be found [here](https://aur.archlinux.org/cgit/aur.git/tree/blesh-update.sh?h=blesh-git). +
+ +## Features + +- **Syntax highlighting**: Highlight command lines input by users as in `fish` and `zsh-syntax-highlighting`. + Unlike the simple highlighting in `zsh-syntax-highlighting`, `ble.sh` performs syntactic analysis + to enable the correct highlighting of complex structures such as nested command substitutions, multiple here documents, etc. + Highlighting colors and styles are [fully configurable](https://github.com/akinomyoga/ble.sh/wiki/Manual-%C2%A72-Graphics). +- **Enhanced completion**: + Extend [completion](https://github.com/akinomyoga/ble.sh/wiki/Manual-%C2%A77-Completion) + by **syntax-aware completion**, completion with quotes and parameter expansions in prefix texts, **ambiguous candidate generation**, etc. + Also, [**menu-complete**](https://github.com/akinomyoga/ble.sh/wiki/Manual-%C2%A77-Completion#user-content-sec-menu-complete) + supports the selection of candidates in the menu (candidate list) by cursor keys, TAB, and S-TAB. + The feature [**auto-complete**](https://github.com/akinomyoga/ble.sh/wiki/Manual-%C2%A77-Completion#user-content-sec-auto-complete) + supports the automatic suggestion of completed texts as in `fish` and `zsh-autosuggestions` (with Bash 4.0+). + The feature [**menu-filter**](https://github.com/akinomyoga/ble.sh/wiki/Manual-%C2%A77-Completion#user-content-sec-menu-filter) + integrates automatic filtering of candidates into menu completion (with Bash 4.0+). + There are other functionalities such as + [**dabbrev**](https://github.com/akinomyoga/ble.sh/wiki/Manual-%C2%A77-Completion#user-content-sec-dabbrev) and + [**sabbrev**](https://github.com/akinomyoga/ble.sh/wiki/Manual-%C2%A77-Completion#user-content-sec-sabbrev) like + [*zsh abbreviations*](https://unix.stackexchange.com/questions/6152/zsh-alias-expansion) or [`zsh-abbr`](https://github.com/olets/zsh-abbr). +- **Vim editing mode**: Enhance `readline`'s vi editing mode available with `set -o vi`. + Vim editing mode supports various vim modes such as char/line/block visual/select mode, replace mode, + command mode, operator pending mode as well as insert mode and normal mode. + Vim editing mode supports various operators, text objects, registers, keyboard macros, marks, etc. + It also provides `vim-surround` as an option. +- Other interesting features include + [**status line**](https://github.com/akinomyoga/ble.sh/wiki/Manual-%C2%A74-Editing#user-content-bleopt-prompt_status_line), + [**history share**](https://github.com/akinomyoga/ble.sh/wiki/Manual-%C2%A74-Editing#user-content-bleopt-history_share), + [**right prompt**](https://github.com/akinomyoga/ble.sh/wiki/Manual-%C2%A74-Editing#user-content-bleopt-prompt_rps1), + [**transient prompt**](https://github.com/akinomyoga/ble.sh/wiki/Manual-%C2%A74-Editing#user-content-bleopt-prompt_ps1_transient), + [**xterm title**](https://github.com/akinomyoga/ble.sh/wiki/Manual-%C2%A74-Editing#user-content-bleopt-prompt_xterm_title), etc. + +Note: ble.sh does not provide specific settings of the prompt, aliases, functions, etc. +ble.sh provides a more fundamental infrastructure so that users can set up their own prompt, aliases, functions, etc. +Of course ble.sh can be used in combination with other Bash configurations such as [`bash-it`](https://github.com/Bash-it/bash-it) and [`oh-my-bash`](https://github.com/ohmybash/oh-my-bash). + +> Demo (version 0.2) +> +> ![ble.sh demo gif](https://github.com/akinomyoga/ble.sh/wiki/images/trial1.gif) + +## History and roadmap + +My little experiment took place in one corner of my `bashrc` at the end of May 2013 after I enjoyed an article on `zsh-syntax-highlighting`. +I initially thought something could be achieved by writing a few hundred lines of code +but soon realized that everything needs to be re-implemented for the authentic support of syntax highlighting in Bash. +I decided to make it as an independent script `ble.sh`. +The name stemmed from that of Zsh's line editor, *ZLE* (*Zsh Line Editor*), but suffixed with `.sh` for the implication of being written in a shell script. +I'm occasionally asked about the pronunciation of `ble.sh`, but you can pronounce it as you like. +After the two-week experiment, I was satisfied with my conclusion that it is *possible* to implement a full-featured line editor in Bash that satisfies the actual daily uses. +The real efforts to improve the prototype implementation for real uses started in February 2015. +I released the initial version in the next December. Until then, the basic part of the line editor was completed. +The implementation of vim mode was started in September 2017 and completed in the next March. +I started working on the enhancement of the completion in August 2018 and released it in the next February. + +- 2013-06 v0.0 -- prototype +- 2015-12 v0.1 -- Syntax highlighting [[v0.1.15](https://github.com/akinomyoga/ble.sh/releases/tag/v0.1.15)] +- 2018-03 v0.2 -- Vim mode [[v0.2.7](https://github.com/akinomyoga/ble.sh/releases/tag/v0.2.7)] +- 2019-02 v0.3 -- Enhanced completion [[v0.3.4](https://github.com/akinomyoga/ble.sh/releases/tag/v0.3.4)] +- 20xx-xx v0.4 (plan) -- programmable highlighting [[nightly build](https://github.com/akinomyoga/ble.sh/releases/tag/nightly)] +- 20xx-xx v0.5 (plan) -- TUI configuration +- 20xx-xx v0.6 (plan) -- error diagnostics? + +## Limitations and assumptions + +There are some limitations due to the way `ble.sh` is implemented. +Also, some user configurations or other Bash frameworks may conflict with ble.sh. +For example, + +- By default, `ble.sh` does not set `PIPESTATUS` for the previous command line + because it adds extra execution costs. Instead, the array `BLE_PIPESTATUS` + contains the values of `PIPESTATUS` of the previous command line. If you + need to access the values directly through the variable `PIPESTATUS`, please + set the option `bleopt exec_restore_pipestatus=1`. +- By default, `ble.sh` assumes that `PROMPT_COMMAND` and `PRECMD` hooks do not + change the cursor position and the layout in the terminal display to offer + smooth rendering. If you have settings that output texts or changes the + cursor position in `PROMPT_COMMAND` and `PRECMD`, please set the option + `bleopt prompt_command_changes_layout=1`. +- `ble.sh` assumes that common variable names and environment variables (such as `LC_*`) are not used for the global readonly variables. + In Bash, global readonly variables take effect in any scope including the local scope of the function, which means that we cannot even define a local variable that has the same name as a global readonly variable. + This is not the problem specific to `ble.sh`, but any Bash framework may suffer from the global readonly variables. + It is generally not recommended to define global readonly variables in Bash except for the security reasoning + (Refs. [[1]](https://lists.gnu.org/archive/html/bug-bash/2019-03/threads.html#00150), [[2]](https://lists.gnu.org/archive/html/bug-bash/2020-04/threads.html#00200), [[3]](https://mywiki.wooledge.org/BashProgramming?highlight=%28%22readonly%22%20flag,%20or%20an%20%22integer%22%20flag,%20but%20these%20are%20mostly%20useless,%20and%20serious%20scripts%20shouldn%27t%20be%20using%20them%29#Variables)). + Also, `ble.sh` overrides the builtin `readonly` with a shell function to prevent it from making global variables readonly. + It allows only uppercase global variables and `_*` to become readonly except `_ble_*`, `__ble_*`, and some special uppercase variables. +- `ble.sh` overrides Bash's built-in commands (`trap`, `readonly`, `bind`, `history`, `read`, and `exit`) with shell functions to adjust the behavior of each built-in command and prevent them from interfering with `ble.sh`. + If the user or another framework directly calls the original builtins through `builtin BUILTIN`, or if the user or another framework replaces the shell functions, the behavior is undefined. +- The shell and terminal settings for the line editor and the command execution + are different. `ble.sh` adjusts them for the line editor and try to restore + the settings for the command execution. However, there are settings that + cannot be restored or are intentionally not restored for various reasons. + Some of them are summarlized on [a wiki + page](https://github.com/akinomyoga/ble.sh/wiki/Internals#internal-and-external). + +# 1 Usage + +## 1.1 Try `ble.sh` generated from source (version ble-0.4 devel) + +### Generate + +To generate `ble.sh`, `gawk` (GNU awk) and `gmake` (GNU make) (in addition to Bash and POSIX standard utilities) are required. +The file `ble.sh` can be generated using the following commands. +If you have GNU make installed on `gmake`, please use `gmake` instead of `make`. +```bash +git clone --recursive https://github.com/akinomyoga/ble.sh.git +cd ble.sh +make +``` + +A script file `ble.sh` will be generated in the directory `ble.sh/out`. + +### Try + +Then, you can load `ble.sh` in the Bash session using the `source` command: +```bash +source out/ble.sh +``` + +### Install + +To install `ble.sh` in a specified directory, use `make install`. + +```bash +# INSTALL to ~/.local/share/blesh +make install + +# INSTALL to a specified directory +make install INSDIR=/path/to/blesh + +# PACKAGE (for package maintainers) +make install DESTDIR=/tmp/blesh-package PREFIX=/usr/local +``` + +If either the make variables `DESTDIR` or `PREFIX` is supplied, `ble.sh` will be copied to `$DESTDIR/$PREFIX/share/blesh`. +Otherwise, if the make variables `INSDIR` is specified, it will be installed directly on `$INSDIR`. +Otherwise, if the environment variable `$XDG_DATA_HOME` is defined, the install location will be `$XDG_DATA_HOME/blesh`. +If none of these variables are specified, the default install location is `~/.local/share/blesh`. + +The comment lines and blank lines in the script files are stripped in the installation process. +If you would like to keep these lines in the script files, please specify the argument `strip_comment=no` to `make`. + +To set up `.bashrc` see [Sec. 1.3](#set-up-bashrc). + +## 1.2 Or, use a tar ball of `ble.sh` obtained from GitHub releases + +For download, trial and install, see the description at each release page. +The stable versions are significantly old compared to the devel version, so many features are unavailable. + +- Devel [v0.4.0-devel3](https://github.com/akinomyoga/ble.sh/releases/tag/v0.4.0-devel3) (2020-12), [nightly build](https://github.com/akinomyoga/ble.sh/releases/tag/nightly) +- Stable [v0.3.4](https://github.com/akinomyoga/ble.sh/releases/tag/v0.3.4) (2019-02 fork) Enhanced completions +- Stable [v0.2.7](https://github.com/akinomyoga/ble.sh/releases/tag/v0.2.7) (2018-03 fork) Vim mode +- Stable [v0.1.15](https://github.com/akinomyoga/ble.sh/releases/tag/v0.1.15) (2015-12 fork) Syntax highlighting + +## 1.3 Set up `.bashrc` + +If you want to load `ble.sh` in interactive sessions of `bash` by default, usually one can just source `ble.sh` in `~/.bashrc`, +but a more reliable way is to add the following codes to your `.bashrc` file: + +```bash +# bashrc + +# Add this lines at the top of .bashrc: +[[ $- == *i* ]] && source /path/to/blesh/ble.sh --noattach + +# your bashrc settings come here... + +# Add this line at the end of .bashrc: +[[ ${BLE_VERSION-} ]] && ble-attach +``` + +Basically, when `source /path/to/ble.sh` and `ble-attach` are performed, +standard streams (`stdin`, `stdout`, and `stderr`) should not be redirected but should be connected to the controlling TTY of the current session. +Also, please avoid calling `source /path/to/ble.sh` in shell functions. +The detailed conditions where the above *more reliable setup* is needed are explained in [an answer in Discussion #254](https://github.com/akinomyoga/ble.sh/discussions/254#discussioncomment-4284757). + +## 1.4 User settings `~/.blerc` + +User settings can be placed in the init script `~/.blerc` (or `${XDG_CONFIG_HOME:-$HOME/.config}/blesh/init.sh` if `~/.blerc` is not available) +whose template is available as the file [`blerc.template`](https://github.com/akinomyoga/ble.sh/blob/master/blerc.template) in the repository. +The init script is a Bash script that is sourced during the load of `ble.sh`, so any shell commands can be used in `~/.blerc`. +If you want to change the default path of the init script, you can add the option `--rcfile INITFILE` to `source ble.sh` as the following example: + +```bash +# in bashrc + +# Example 1: ~/.blerc will be used by default +[[ $- == *i* ]] && source /path/to/blesh/ble.sh --noattach + +# Example 2: /path/to/your/blerc will be used +[[ $- == *i* ]] && source /path/to/blesh/ble.sh --noattach --rcfile /path/to/your/blerc +``` + +## 1.5 Update + +You need Git (`git`), GNU awk (`gawk`) and GNU make (`make`). +For `ble-0.3+`, you can run `ble-update` in the session with `ble.sh` loaded: + +```bash +$ ble-update +``` + +For `ble.0.4+`, you can also update it outside the `ble.sh` session using + +```bash +$ bash /path/to/ble.sh --update +``` + +You can instead download the latest version by `git pull` and install it: + +```bash +cd ble.sh # <-- enter the git repository you already have +git pull +git submodule update --recursive --remote +make +make INSDIR="$HOME/.local/share/blesh" install +``` + +## 1.6 Uninstall + +Basically you can simply delete the installed directory and the settings that the user added. + +- Close all the `ble.sh` sessions (the Bash interactive sessions with `ble.sh`) +- Remove related user data. If you would like to keep them, you can skip these steps. + - Remove the added lines in `.bashrc`. + - Remove `blerc` files (`~/.blerc` or `~/.config/blesh/init.sh`) if any. + - Remove the state directory `~/.local/state/blesh` if any. +- Remove the directory where `ble.sh` is installed. When you use `out/ble.sh` + inside the working tree of the git repository, the installed directory is the + directory of the repository. When you use `ble.sh` installed by `make + install`, the installed directory is `/share/blesh` where `` + (default: `~/.local`) is the prefix specified to `make install` in the + installation stage. When you use the version extracted from a tarball, the + directory created by extracting the tarball is the installed directory. +- Remove the cache directory `~/.cache/blesh` if any. +- Remove the temporary directory `/tmp/blesh` if any [ Only needed when your system does not automatically clear `/tmp` ]. + +# 2 Basic settings + +Here, some of the settings for `~/.blerc` are picked up. +You can find useful settings also in [Q\&A](https://github.com/akinomyoga/ble.sh/wiki/Q&A), +[Recipes](https://github.com/akinomyoga/ble.sh/wiki/Recipes), +and [`contrib` repository](https://github.com/akinomyoga/blesh-contrib). +The complete list of setting items can be found in the file [`blerc.template`](https://github.com/akinomyoga/ble.sh/blob/master/blerc.template). +For detailed explanations please refer to [Manual](https://github.com/akinomyoga/ble.sh/wiki). + +## 2.1 Vim mode + +For the vi/vim mode, check [the wiki page](https://github.com/akinomyoga/ble.sh/wiki/Vi-(Vim)-editing-mode). + +## 2.2 Disable features + +One of frequently asked questions is the way to disable a specific feature that `ble.sh` adds. +Here the settings for disabling features are summarized. + +```bash +# Disable syntax highlighting +bleopt highlight_syntax= + +# Disable highlighting based on filenames +bleopt highlight_filename= + +# Disable highlighting based on variable types +bleopt highlight_variable= + +# Disable auto-complete (Note: auto-complete is enabled by default in bash-4.0+) +bleopt complete_auto_complete= +# Tip: you may instead specify the delay of auto-complete in millisecond +bleopt complete_auto_delay=300 + +# Disable auto-complete based on the command history +bleopt complete_auto_history= + +# Disable ambiguous completion +bleopt complete_ambiguous= + +# Disable menu-complete by TAB +bleopt complete_menu_complete= + +# Disable menu filtering (Note: auto-complete is enabled by default in bash-4.0+) +bleopt complete_menu_filter= + +# Disable EOF marker like "[ble: EOF]" +bleopt prompt_eol_mark='' +# Tip: you may instead specify another string: +bleopt prompt_eol_mark='⏎' + +# Disable error exit marker like "[ble: exit %d]" +bleopt exec_errexit_mark= +# Tip: you may instead specify another string: +bleopt exec_errexit_mark=$'\e[91m[error %d]\e[m' + +# Disable elapsed-time marker like "[ble: elapsed 1.203s (CPU 0.4%)]" +bleopt exec_elapsed_mark= +# Tip: you may instead specify another string +bleopt exec_elapsed_mark=$'\e[94m[%ss (%s %%)]\e[m' +# Tip: you may instead change the threshold of showing the mark +bleopt exec_elapsed_enabled='sys+usr>=10*60*1000' # e.g. ten minutes for total CPU usage + +# Disable exit marker like "[ble: exit]" +bleopt exec_exit_mark= + +# Disable some other markers like "[ble: ...]" +bleopt edit_marker= +bleopt edit_marker_error= +``` + +## 2.3 CJK Width + +The option `char_width_mode` controls the width of the Unicode characters with `East_Asian_Width=A` (Ambiguous characters). +Currently, four values `emacs`, `west`, `east`, and `auto` are supported. With the value `emacs`, the default width in emacs is used. +With `west`, all the ambiguous characters have width 1 (Hankaku). With `east`, all the ambiguous characters have width 2 (Zenkaku). +With `auto`, the width mode `west` or `east` is automatically chosen based on the terminal behavior. +The default value is `auto`. The appropriate value should be chosen in accordance with your terminal behavior. +For example, the value can be changed to `west` as: + +```bash +bleopt char_width_mode='west' +``` + +## 2.4 Input Encoding + +The option `input_encoding` controls the encoding scheme used in the decode of input. Currently `UTF-8` and `C` are available. With the value `C`, byte values are directly interpreted as character codes. The default value is `UTF-8`. For example, the value can be changed to `C` as: + +```bash +bleopt input_encoding='C' +``` + +## 2.5 Bell + +The option `edit_bell` controls the behavior of the edit function (widget) +called `bell`. It is a colon-separated list of the values `vbell`, `abell`, +and `visual`. When a value is contained, the corresponding type of the bell is +enabled. The value `abell` corresponds to the audible bell, which prints ASCII +Control Character BEL (0x07) will be written to `stderr`. The value +`vbell` corresponds to the visible bell, which shows the message in the +terminal display. The value `visual` corresponds to the visual bell, which +flashes the terminal screen by turning on the DECSCNM mode for a +short moment. By default, only the audible bell is enabled. + +The option `vbell_default_message` specifies the default message shown by the +visual bell. The default value of this setting is `' Wuff, -- Wuff!! '`. The +option `vbell_duration` specifies the display duration of the visual-bell +message. The unit is a millisecond. The default value is `2000`. The option +`vbell_align` specifies the position of `vbell` by `left`, `center`, or +`right`. + +For example, the audible bell can be disabled, and the visual bell can be set +up as: + +```bash +bleopt edit_bell=vbell vbell_{default_message=' BEL ',duration=3000,align=right} +``` + +## 2.6 Highlight Colors + +The colors and attributes used in the syntax highlighting are controlled by the function `ble-face`. The following code reproduces the default configuration: +```bash +# highlighting related to editing +ble-face -s region bg=60,fg=white +ble-face -s region_target bg=153,fg=black +ble-face -s region_match bg=55,fg=white +ble-face -s region_insert fg=12,bg=252 +ble-face -s disabled fg=242 +ble-face -s overwrite_mode fg=black,bg=51 +ble-face -s vbell reverse +ble-face -s vbell_erase bg=252 +ble-face -s vbell_flash fg=green,reverse +ble-face -s prompt_status_line fg=231,bg=240 + +# syntax highlighting +ble-face -s syntax_default none +ble-face -s syntax_command fg=brown +ble-face -s syntax_quoted fg=green +ble-face -s syntax_quotation fg=green,bold +ble-face -s syntax_escape fg=magenta +ble-face -s syntax_expr fg=26 +ble-face -s syntax_error bg=203,fg=231 +ble-face -s syntax_varname fg=202 +ble-face -s syntax_delimiter bold +ble-face -s syntax_param_expansion fg=purple +ble-face -s syntax_history_expansion bg=94,fg=231 +ble-face -s syntax_function_name fg=92,bold +ble-face -s syntax_comment fg=242 +ble-face -s syntax_glob fg=198,bold +ble-face -s syntax_brace fg=37,bold +ble-face -s syntax_tilde fg=navy,bold +ble-face -s syntax_document fg=94 +ble-face -s syntax_document_begin fg=94,bold +ble-face -s command_builtin_dot fg=red,bold +ble-face -s command_builtin fg=red +ble-face -s command_alias fg=teal +ble-face -s command_function fg=92 +ble-face -s command_file fg=green +ble-face -s command_keyword fg=blue +ble-face -s command_jobs fg=red +ble-face -s command_directory fg=26,underline +ble-face -s command_suffix fg=white,bg=green +ble-face -s command_suffix_new fg=white,bg=brown +ble-face -s filename_directory underline,fg=26 +ble-face -s filename_directory_sticky underline,fg=white,bg=26 +ble-face -s filename_link underline,fg=teal +ble-face -s filename_orphan underline,fg=teal,bg=224 +ble-face -s filename_executable underline,fg=green +ble-face -s filename_setuid underline,fg=black,bg=220 +ble-face -s filename_setgid underline,fg=black,bg=191 +ble-face -s filename_other underline +ble-face -s filename_socket underline,fg=cyan,bg=black +ble-face -s filename_pipe underline,fg=lime,bg=black +ble-face -s filename_character underline,fg=white,bg=black +ble-face -s filename_block underline,fg=yellow,bg=black +ble-face -s filename_warning underline,fg=red +ble-face -s filename_url underline,fg=blue +ble-face -s filename_ls_colors underline +ble-face -s varname_array fg=orange,bold +ble-face -s varname_empty fg=31 +ble-face -s varname_export fg=200,bold +ble-face -s varname_expr fg=92,bold +ble-face -s varname_hash fg=70,bold +ble-face -s varname_number fg=64 +ble-face -s varname_readonly fg=200 +ble-face -s varname_transform fg=29,bold +ble-face -s varname_unset fg=124 +ble-face -s argument_option fg=teal +ble-face -s argument_error fg=black,bg=225 + +# highlighting for completions +ble-face -s auto_complete fg=238,bg=254 +ble-face -s menu_desc_default none +ble-face -s menu_desc_type ref:syntax_delimiter +ble-face -s menu_desc_quote ref:syntax_quoted +ble-face -s menu_filter_fixed bold +ble-face -s menu_filter_input fg=16,bg=229 +``` + +The current list of faces can be obtained by the following command (`ble-face` without arguments): +```console +$ ble-face +``` + +The color codes can be checked in output of the function `ble-color-show` (defined in `ble.sh`): +```console +$ ble-color-show +``` + +## 2.7 Key Bindings + +Key bindings can be controlled with the shell function, `ble-bind`. +For example, with the following setting, "Hello, world!" will be inserted on typing C-x h +```bash +ble-bind -f 'C-x h' 'insert-string "Hello, world!"' +``` + +The details on the key representation, such as C-x h in the above example, +are described in [Manual §3.1](https://github.com/akinomyoga/ble.sh/wiki/Manual-%C2%A73-Key-Binding#user-content-sec-kspecs). +The representations of Space, Tab, Enter, Backspace, Escape, etc. are described +in [Manual §3.1.1](https://github.com/akinomyoga/ble.sh/wiki/Manual-%C2%A73-Key-Binding#user-content-sec-kspecs-ret): +The space is represented as SP, +the tab key is represented as C-i or TAB depending on the terminal, +the enter/return key is represented as C-m or RET depending on the terminal, +and the backspace key is represented as C-?, DEL, C-h, or BS depending on the terminal. +The representations of modified special keys such as Ctrl+Return and Shift+Return are described +in [Manual §3.6.4](https://github.com/akinomyoga/ble.sh/wiki/Manual-%C2%A73-Key-Binding#user-content-sec-modifyOtherKeys-manual): +If your terminal does not support `modifyOtherKeys`, you need to manually configure the escape sequences of modified special keys. + + +For another example, if you want to invoke a command on typing M-c, you can write it as follows: + +```bash +ble-bind -c 'M-c' 'my-command' +``` + +Or, if you want to invoke a edit function (designed for Bash `bind -x`) on typing C-r, you can write it as follows: + +```bash +ble-bind -x 'C-r' 'my-edit-function' +``` + +The existing key bindings are shown by the following command: +```console +$ ble-bind -P +``` + +The list of widgets is shown by the following command: +```console +$ ble-bind -L +``` + +If you want to run multiple widgets with a key, you can define your own widget by creating a function of the name `ble/widget/YOUR_WIDGET_NAME` +as illustrated in the following example. +It is highly recommended to prefix the widget name with `YOUR_NAME/`, `my/`, `blerc/`, `dotfiles/`, etc. +in order not to conflict with the names of the existing standard widgets. + +```bash +# Example of calling multiple widgets with the key C-t +function ble/widget/my/example1 { + ble/widget/beginning-of-logical-line + ble/widget/insert-string 'echo $(' + ble/widget/end-of-logical-line + ble/widget/insert-string ')' +} +ble-bind -f C-t my/example1 +``` + +## 2.8 fzf integration + +If you would like to use `fzf` in combination with `ble.sh`, you need to configure `fzf` using [the `contrib/fzf` integration](https://github.com/akinomyoga/blesh-contrib#pencil-fzf-integration). +Please follow the instructions in the link for the detailed description. + +```bash +# blerc + +# Note: If you want to combine fzf-completion with bash_completion, you need to +# load bash_completion earilier than fzf-completion. This is required +# regardless of whether to use ble.sh or not. +source /etc/profile.d/bash_completion.sh + +ble-import -d integration/fzf-completion +ble-import -d integration/fzf-key-bindings +``` + +The option `-d` of `ble-import` delays the initialization. In this way, the +fzf settings are loaded in background after the prompt is shown. See +[`ble-import` - Manual §8](https://github.com/akinomyoga/ble.sh/wiki/Manual-%C2%A78-Miscellaneous#user-content-fn-ble-import) +for details. If you would like to additionally configure the fzf settings +after loading them, there are four options. The easiest way is to drop the +`-d` option (Option 1 below). As another option, you may also delay the +additional settings with `ble-import -d` [2] or `ble/util/idle.push` [3]. Or, +you can hook into the loading of the fzf settings by `ble-import -C` [4]. + +```bash +# [1] Drop -d +ble-import integration/fzf-completion +ble-import integration/fzf-key-bindings + + +# [2] Use ble-import -d for additional settings +ble-import -d integration/fzf-completion +ble-import -d integration/fzf-key-bindings +ble-import -d '' + +# [3] Use "ble/util/idle.push" for additional settings +ble-import -d integration/fzf-completion +ble-import -d integration/fzf-key-bindings +ble/util/idle.push '' + +# [4] Use "ble-import -C" for additional settings +ble-import -d integration/fzf-completion +ble-import -d integration/fzf-key-bindings +ble-import -C '' integration/fzf-key-bindings +``` + +# 3 Tips + +## 3.1 Use multiline mode + +When the command line string contains a newline character, `ble.sh` enters the MULTILINE mode. + +By typing C-v C-j or C-q C-j, you can insert a newline character in the command line string. +In the MULTILINE mode, RET (C-m) causes the insertion of a new newline character. +In the MULTILINE mode, the command can be executed by typing C-j. + +When the shell option `shopt -s cmdhist` is set (which is the default), +RET (C-m) inserts a newline if the current command line string is syntactically incomplete. + +## 3.2 Use vim editing mode + +If `set -o vi` is specified in `.bashrc` or `set editing-mode vi` is specified in `.inputrc`, the vim mode is enabled. +For details, please check [the wiki page](https://github.com/akinomyoga/ble.sh/wiki/Vi-(Vim)-editing-mode). + +## 3.3 Use `auto-complete` + +The feature `auto-complete` is available in Bash 4.0 or later. `auto-complete` automatically suggests a possible completion on user input. +The suggested contents can be inserted by typing S-RET +(when the cursor is at the end of the command line, you can also use right, C-f, or end to insert the suggestion). +If you want to insert only the first word of the suggested contents, you can use M-right or M-f. +If you want to accept the suggestion and immediately run the command, you can use C-RET +(if your terminal does not support special key combinations like C-RET, please check +[Manual §3.6.4](https://github.com/akinomyoga/ble.sh/wiki/Manual-%C2%A73-Key-Binding#user-content-sec-modifyOtherKeys-manual)). + +## 3.4 Use `sabbrev` (static abbrev expansions) + +By registering words to `sabbrev`, the words can be expanded to predefined strings. +When the cursor is just after a registered word, typing SP causes the `sabbrev` expansion. +For example, with the following settings, when you type SP after the string `command L`, the command line will be expanded to `command | less`. + +```bash +# blerc +ble-sabbrev L='| less' +``` + +The sabbrev names that start with `\` plus alphabetical letters are also recommended since it is unlikely to conflict with real words that are a part of the executed command. + +```bash +# blerc +ble-sabbrev '\L'='| less' +``` + +The sabbrevs starting with `~` can be expanded also by /. This can be used to approximate Zsh's named directories. +For example, with the following settings, typing `~mybin/` expands it to e.g. `/home/user/bin/` (where we assumed `HOME=/home/user`). + +```bash +# blerc + +ble-sabbrev "~mybin=$HOME/bin" +``` + +# 4 Contributors + +I received many feedbacks from many people in GitHub Issues/PRs. +I thank all such people for supporting the project. +Among them, the following people have made particularly significant contributions. + +- [`@cmplstofB`](https://github.com/cmplstofB) helped me implement vim-mode by testing it and giving me a lot of suggestions. +- [`@dylankb`](https://github.com/dylankb) reported many issues with the fzf integration, initialization, etc. +- [`@rux616`](https://github.com/rux616) reported several issues and created a PR for fixing the default path of `.blerc` +- [`@timjrd`](https://github.com/timjrd) suggested and contributed to performance improvements in completion. +- [`@3ximus`](https://github.com/3ximus) reported many issues for a wide variety of problems. +- [`@SuperSandro2000`](https://github.com/SuperSandro2000) reported many issues related to NixOS and others diff --git a/.local/share/blesh/doc/Release.md b/.local/share/blesh/doc/Release.md new file mode 100644 index 0000000..c3fe066 --- /dev/null +++ b/.local/share/blesh/doc/Release.md @@ -0,0 +1,797 @@ +# ble-0.4.0-devel3 + +## Usage + +**Prerequisites** + +Bash 3.0+ and basic POSIX utilities are required. + +**Download ble-0.4.0-devel3.tar.xz** + +https://github.com/akinomyoga/ble.sh/releases/download/v0.4.0-devel3/ble-0.4.0-devel3.tar.xz + +```bash +# DOWNLOAD with wget +wget https://github.com/akinomyoga/ble.sh/releases/download/v0.4.0-devel3/ble-0.4.0-devel3.tar.xz + +# DOWNLOAD with curl +curl -LO https://github.com/akinomyoga/ble.sh/releases/download/v0.4.0-devel3/ble-0.4.0-devel3.tar.xz +``` + +**Trial & Install** + +```bash +# TRIAL +tar xJf ble-0.4.0-devel3.tar.xz +source ble-0.4.0-devel3/ble.sh + +# INSTALL (quick) +tar xJf ble-0.4.0-devel3.tar.xz -C ~/.local/share/blesh +echo 'source ~/.local/share/blesh' >> ~/.bashrc + +# INSTALL (more robust) +tar xJf ble-0.4.0-devel3.tar.xz -C ~/.local/share/blesh +# Add the following line near the top of ~/.bashrc +[[ $- == *i* ]] && source ~/.local/share/blesh/ble.sh --attach=none +# Add the following line at the end of ~/.bashrc +[[ ${BLE_VERSION-} ]] && ble-attach +``` + +-------------------------------------------------------------------------------- +# ble-0.3.4 + +## Usage + +**Prerequisites** + +Bash 3.0+ and basic POSIX utilities are required. + +**Download ble-0.3.4.tar.xz** + +https://github.com/akinomyoga/ble.sh/releases/download/v0.3.4/ble-0.3.4.tar.xz + +```bash +# DOWNLOAD with wget +wget https://github.com/akinomyoga/ble.sh/releases/download/v0.3.4/ble-0.3.4.tar.xz + +# DOWNLOAD with curl +curl -LO https://github.com/akinomyoga/ble.sh/releases/download/v0.3.4/ble-0.3.4.tar.xz +``` + +**Trial & Install** + +```bash +# TRIAL +tar xJf ble-0.3.4.tar.xz +source ble-0.3.4/ble.sh + +# INSTALL +tar xJf ble-0.3.4.tar.xz -C ~/.local/share/blesh +# Add the following line near the top of ~/.bashrc +[[ $- == *i* ]] && source ~/.local/share/blesh/ble.sh --attach=none +# Add the following line at the end of ~/.bashrc +[[ ${BLE_VERSION-} ]] && ble-attach +``` + +## blesh-0.3 Fixes +- decode: fix `bind` emulation in .bashrc (v0.3) 742777e +- global: pick fixes and changes from ble-0.1..0.2 backports 78bbc5e +- bump 0.3.4 9da6774 + +## Fixes +- complete: fix a problem that candidates are not updated after menu-filter (reported by 3ximus) `#D1428` 1c7786e (master: 98fbc1c) +- edit: work around the wrong job information of Bash in trap handlers (reported by 3ximus) `#D1435` `#D1436` d40847f (master: bc4735e) +- edit (command-help): work around the Bash bug that tempenv vanishes with `builtin eval` `#D1438` cc8ca96 (master: 8379d4a) +- global: suppress missing locale errors (reported by 3ximus) `#D1440` b52a798 (master: 4d3c595) +- edit (sword): fix definition of `sword` (shell words) `#D1441` 2370bce (master: f923388) +- edit (`kill-forward-logical-line`): fix a bug not deleting newline at the end of the line `#D1443` 2a8a7f6 (master: 09cf7f1) +- global: work around bash-4.2 bug of `declare -gA` (reported by 0xC0ncord) `#D1470` 2f85ed3 (master: 8856a04) +- global: fix declaration of associative arrays for `ble-reload` (reported by 0xC0ncord) `#D1471` 422de69 (master: 3cae6e4) +- util (`ble/util/msleep`): fix hang in Cygwin by swithing from `/dev/udp/0.0.0.0/80` to `/dev/zero` `#D1452` 5ace564 (master: d4d718a) +- syntax: fix broken AST with `[[` keyword `#D1454` 1d48e79 (master: 69658ef) +- benchmark (`ble-measure`): work around a locale-dependent decimal point of `EPOCHREALTIME` (reported by 3ximus) `#D1460` f3833ad (master: 1aa471b) +- util (`ble/util/msleep`): work around the bash-4.3 bug of `read -t` (reported by 3ximus) `#D1468` `#D1469` 70797cf (master: 4ca9b2e) +- bind: work around broken `cmd_xmap` after switching the editing mode `#D1478` 909f461 (master: 8d354c1) +- edit: clear graphic rendition on newlines and external commands `#D1479` 59ede5c (master: 18bb2d5) +- decode (rlfunc): work around incomplete bytes in keyseq (reported by onelittlehope) `#D1483` 948a38d (master: 3559658) beb0383 37363be +- canvas: fix a glitch that SGR at the end of command line is applied to new lines `#D1498` 6871634 (master: 4bdfdbf) +- syntax: fix a bug that `eval() { :; }`, `declare() { :; }` are not treated as function definition `#D1529` 6c1d295 (master: b429095) +- decode: fix a hang on attach failure by cache corruption `#D1531` d4b0700 (master: 24ea379) +- progcomp: fix non-working `complete -C prog` (reported by Archehandoro) `#D1535` 47b3ade (master: 026432d) +- bind: fix a problem that `bind '"seq":"key"'` causes a loop macro `bind -s key key` (reported by thanosz) `#D1536` e2a502d (master: ea05fc5) +- main: work around `. ble.sh --{test,update,clear-cache}` in intereactive sessions `#D1555` 500915f (master: bbc2a90) +- main: fix reloading after ble-update (fixup 500915f (master: bbc2a90)) (fixed by oc1024) `#D1558` 9372670 +- main: fix exit status for `bash ble.sh --test` (fixup 500915f (master: bbc2a90)) `#D1558` 641238a +- main: work around sourcing `ble.sh` inside subshells `#D1554` 500915f (master: bbc2a90) +- global: use a better workaround of bash-4.2 `declare -gA` by separating assignment `#D1567` 40827ef (master: 2408a20) +- util: work around bash-3.0 bug `"${scal[@]/xxx}"` `#D1570` 7e10cf4 (master: 24f79da) +- syntax: fix a bug that argument completion is attempted in nested commands (reported by huresche) `#D1579` 6987ae8 (master: 301d40f) +- edit (brackated-paste): fix incomplete `CR => LF` conversion (reported by alborotogarcia) `#D1587` 2651c8e (master: 8d6da16) +- main (adjust-bash-options): adjust `LC_COLLATE=C` `#D1588` 94cc9d2 (master: e87ac21) +- highlight (`layer:region`): fix blocked lower-layer changes without selection changes `#D1596` d40d42a (master: 5ede3c6) +- complete (`auto-menu`): fix sleep loops by clock/sclock difference `#D1597` 0abc15b (master: 53dd018) +- util: work around the Bash 3 bug of array assignments with `^A` and `^?` in Bash 3.2 `#D1614` 0eac4df (master: b9f7611) +- benchmark (`ble-measure`): fix a bug that the result is always 0 in Bash 3 and 4 (fixup bbc2a904) `#D1615` bc3cdab (master: a034c91) +- decode, canvas, etc.: explicitly treat CSI arguments as decimal numbers (reported by GorrillaRibs) `#D1625` 97bce68 (master: c6473b7) 2ea48d7 +- edit: fix a bug that `command-help` doesn't work `#D1635` c375fbb (master: 0f6a083) +- complete: fix a task scheduling bug of referencing two different clocks (reported by rashil2000) `#D1636` df9f932 (master: fea5f5b) +- canvas: update prompt trace on `char_width_mode` change (reported by Barbarossa93) `#D1642` 00f9ce8 (master: 68ee111) +- decode: fix a bug that the characters input while initialization are delayed `#D1670` 734bd50 (master: 430f449) +- util (`ble/util/readfile`): fix a bug of always exiting with 1 in `bash <= 3.2` (reported by laoshaw) `#D1678` 51d244a (master: 61705bf) +- trace: fix wrong positioning of the ellipses on overflow `#D1684` dea87c7 (master: b90ac78) +- mandb: generate completions of options also for the empty word `#D1689` dea87c7 (master: b90ac78) +- complete: do not generate keywords for quoted command names `#D1691` 5b1e5be (master: 60d244f) +- menu (menu-style:align): fix the failure of delaying `ble/canvas/trace` on items (motivated by banoris) `#D1710` 3d56593 (master: acc9661) +- complete: fix empty completions with `FIGNORE` (reported by seanfarley) `#D1711` 49e75ee (master: 144ea5d) +- main: fix the message of owner errors of cache directories (reported by zim0369) `#D1712` 02aeb4a (master: b547a41) +- util (`ble/string#escape-for-bash-specialchars`): fix escaping of TAB `#D1713` accf8f3 (master: 7db3d2b) +- util (visible-bell): erase visible-bell before running external commands `#D1723` 72a11ae (master: 0da0c1c) +- util (`ble/function`): work around `shopt -u extglob` `#D1725` 3819e83 (master: 952c388) +- syntax: fix uninitialized syntax-highlighting in bash-3.2 `#D1731` 7bd03a5 (master: e3f5bf7) +- main: fix the workaround for `set -eu` and refactor `#D1743` a949af0 (master: 6a946f0) +- progcomp: retry completions on `$? == 124` also for non-default completions (reported by SuperSandro2000) `#D1759` e217932 (master: 82b9c01) +- util (`ble/util/import`): work around filenames with bash special characters `#D1763` 4179e3d (master: b27f758) +- edit: fix the restore failure of `PS1` and `PROMPT_COMMAND` on `ble-detach` `#D1784` 4f4c924 (master: b9fdaab) +- complete: do not attempt an independent rhs completion for arguments (reported by rsteube) `#D1787` 7bf32ca (master: f8bbe2c) +- history: work around possible dirty prefix `*` in the history output `#D1808` 84184ce (master: 64a740d) +- util(`ble/util/eval-pathname-expansion`): fix restoring shopt options in bash-4.0 `#D1825` d3b3f7b (master: 736f4da) +- decode: fix the workaround for `set -e` with `--prompt=attach` `#D1832` 51cb735 (master: 5111323) +- decode (`encoding:C`): fix initialization for isolated ESC `#D1839` aaa74b5 (master: c3bba5b) +- main. util: fix problems of readlink etc. found by test in macOS (reported by aiotter) `#D1849` a1adc7f (master: fa955c1) `#D1855` a22e145 +- progcomp: fix a bug that `COMP_WORDBREAKS` is ignored `#D1872` b338066 (master: 4d2dd35) +- global: quote `return $?` `#D1884` 4f14f7a (master: 801d14a) +- main: fix adjustments of bash options (reported by rashil2000) `#D1895` 7bd25c9 (master: 138c476) +- decode: fix a bug that the tab completion do not work with bash-4.4 and lower `#D1928` 6351e7f (master: 7da9bce) +- bind: fix M-C-@, C-x C-@, and M-C-x (`bash-4.2 -o emacs`) `#D1920` 02f45f3 (master: a410b03) +- complete: fix non-working ambiguous path completion with `..` and `.` in the path `#D1930` fdb76e9 (master: 632e90a) +- main (ble-reload): fix failure by non-existent rcfile `#D1931` 58de996 (master: b7ae2fa) +- util: fix ble/util/clock in bash-4.2 [main: fix the timestamp in the session ID in bash-4.2] `#D1954` 9a24b1e (master: 651c70c1) +- edit (`ble/textarea#render`): fix interleaving outputs to `_ble_util_buffer` and `DRAW_BUFF` `#D1987` 62519a7 (master: 6d61388) +- keymap/vi (`operator:filter`): do not append newline at the end of line `#D1994` 8207d4f (master: bce2033) +- keymap/vi (`expand-range-for-linewise-operator`): fix the end point being not extended `#D1994` 8207d4f (master: bce2033) +- syntax: fix unrecognized asignment `echo arr[i]+=rhs` [sabbrev: apply sabbrev to right-hand sides of variable assignments] `#D2007` 948f50f (master: 41faa494) + +## Changes +- syntax: exclude \\ + LF at the word beginning from words (motivated by cmplstofB) `#D1431` 1b00fd2 (master: 67e62d6) +- edit: preserve the state of `READLINE_{LINE,POINT,MARK}` `#D1437` cc8ca96 (master: 8379d4a) +- edit: change default behavior of C-w and M-w to operate on backward words `#D1448` b1fd84a (master: 47a3301) +- edit (`ble/builtin/read`): cancel by C-d on an empty line `#D1473` 4fae77a (master: ecb8888) +- syntax: change syntax context after `time ;` and `! ;` for Bash 4.4 `#D1477` e55e3df (master: 4628370) +- decode (rlfunc): update mapping `vi-replace` in `imap` and `vi-editing-mode` in `nmap` (reported by onelittlehope) `#D1484` 3a2d0fe (master: f2ca811) +- prompt: invalidate prompt and textarea on prompt setting changes `#D1492` e28f330 (master: 1f55913) +- main: accept non-regular files as `blerc` and add option `--norc` `#D1530` 4b0eb87 (master: 7244e2f) +- prompt: adjust behavior of `LINENO` and prompt sequence `\#` (reported by tycho-kirchner) `#D1542` f3668ba (master: 8b0257e) +- main: show notifications against debug versions of Bash `#D1612` 0ee8415 (master: 8f974aa) +- edit: suppress only `stderr` with `internal_suppress_bash_output` (motivated by rashil2000) `#D1646` b0a9021 (master: a30887f) +- prompt: do not evaluate `PROMPT_COMMAND` for subprompts `#D1654` 9c0e515 (master: 08e903e) +- main: suppress non-interactive warnings from manually sourced startup files (reported by andreclerigo) `#D1676` a602876 (master: 0525528) 88e2df5 +- main: suppress non-interactive warnings from manually sourced startup files (reported by andreclerigo) `#D1676` 0525528 79efd42 (master: 88e2df5) +- syntax: revert 99f2234 (master: 371a5a4) and generate empty completion source on syntax error `#D1609` e09fcab +- syntax: do not start argument completions immediately after previous word (reported by EmilySeville7cfg) `#D1690` 99f2234 (master: 371a5a4) +- syntax: revert 371a5a4 and generate empty completion source on syntax error `#D1609` a1d1286 (master: e09fcab) +- canvas: do not insert explicit newlines on line folding if possible (reported by banoris) `#D1745` d878fce (master: 02b9da6) dc3827b +- edit (`ble-bind -x`): preserve multiline prompts on execution of `bind -x` commands (requested by SuperSandro2000) `#D1755` 240bfaa (master: 7d05a28) +- util (`ble/util/buffer`): hide cursor in rendering `#D1758` 5907567 (master: e332dc5) +- complete (`action:file`): always suffix `/` to complete symlinked directory names (reported by SuperSandro2000) `#D1759` ebdc58b (master: 397ac1f) +- edit: fix layout with `prompt_rps1` caused by missing `opts=relative` for `ble/textmap#update` `#D1769` e799191 (master: f6af802) +- edit (`ble-detach`): prepend a space to `stty sane` for `HISTIGNORE=' *'` `#D1796` 31bc2b7 (master: 26b532e) +- edit: the widgets `{kill,copy,delete}-region-or` now receives widgets as arguments `#D1021` e222c48 (master: bbbd155) +- decode (`bind`): do not treat non-beginning `#` as comments `#D1820` f9db7d8 (master: 65c4138) +- history: disable the history file when `HISTFILE` is empty `#D1836` 7153250 (master: 9549e83) +- main (`ble-reload`): preserve the original initialization options `#D1852` 8912d81 (master: d8c92cc) +- progcomp: reproduce arguments of completion functions passed by Bash `#D1872` b338066 (master: 4d2dd35) +- color: let `bleopt term_index_colors` override the default if specified `#D1878` e7c657c (master: 7d238c0) +- decode (`vi_imap-rlfunc.txt`): update the widget for `backward-kill-word` as `kill-backward-{u => c}word` `#D1896` 3c4e3a4 (master: e19b796) +- term (`_ble_term_TERM`): detect wezterm-20220408 `#D1909` f3a8382 (master: 486564a) +- keymap/vi (`decompose-meta`): translate S-a to A `#D1988` 9e0c187 (master: 600e845) +- term (`_ble_term_TERM`): detect konsole `#D1988` 9e0c187 (master: 600e845) ed53858 + +## Compatibility +- term: work around leaked DA2R in screen from outside terminal `#D1485` 4d77fab (master: e130619) +- util (`modifyOtherKeys`): work around a quirk of kitty (reported by NoahGorny) `#D1549` 823eb83 (master: f599525) +- global: work around empty `vi_imap` cache by `tmux-resurrect` `#D1562` d7d2a23 (master: 560160b) +- decode: identify `kitty` and treat `\e[27u` as isolated ESC (reported by lyiriyah) `#D1585` 2f7404e (master: c2a84a2) +- complete: suppress known error messages of `bash-completion` (reported by oc1024, Lun4m) `#D1622` 558322c (master: d117973) +- util (`modifyOtherKeys`): update the workaround for a new quiark of kitty `#D1627` 90d9284 (master: 3e4ecf5) +- main: work around `set -B` and `set -k` `#D1628` 55494eb (master: a860769) +- term: disable `modifyOtherKeys` and do not send `DA2` for `st` (requested by Shahabaz-Bagwan) `#D1632` 7e08766 (master: 92c7b26) +- cmap: add `st`-specific escape sequences for cursor keys `#D1633` 1391c90 (master: acfb879) +- cmap: distinguish find/select from home/end for openSUSE `inputrc.keys` (reported by cornfeedhobo) `#D1648` 886cc07 (master: c4d28f4) +- cmap: freeze the internal codes of find/select and kitty special keys `#D1674` 7d02058 (master: fdfe62a) +- decode: work around the overwritten builtin `set` (reported by eadmaster) `#D1680` 5acb117 (master: a6b4e2c) +- util (`modifyOtherKeys`): use the kitty protocol for kitty 0.23+ which removes the support of `modifyOtherKeys` (reported by kovidgoyal) `#D1681` 696264b (master: ec91574) +- complete: work around the variable leaks by `virsh` completion from `libvirt` (reported by telometto) `#D1682` 7a65fc3 (master: f985b9a) +- stty: do not remove keydefs for C-u, C-v, C-w, and C-? (reported by laoshaw) `#D1683` ff8fb83 (master: 82f74f0) +- decode (`ble/builtin/bind`): improve compatibility of the deprecated form `bind key:rlfunc` (motivated by cmplstofB) `#D1698` c3904ff (master: b6fc4f0) +- main: work around `XDG_RUNTIME_DIR` of a different user by `su` (reported by zim0369) `#D1712` dbf58e4 (master: 8d37048) +- main (`ble/util/readlink`): work around non-standard or missing `readlink` (motivated by peterzky) `#D1720` 60595bd (master: a41279e) +- decode (`ble/builtin/bind`): fix a bug that only lowercase is accepted for deprecated form `bind key:rlfunc` (reported by returntrip) `#D1726` 43cf9b9 (master: a67458e) e363f1b +- decode (`ble/builtin/bind`): fix a bug that only lowercase is accepted for deprecated form `bind key:rlfunc` (reported by returntrip) `#D1726` a67458e dd358d7 (master: e363f1b) +- global: work around the arithmetic syntax error of `10#` in Bash-5.1 `#D1734` b321b57 (master: 7545ea3) +- global: adjust implementations for Bash 5.2 `patsub_replacement` `#D1738` 66ae615 (master: 4590997) +- main: check `/dev/tty` on startup (reported by andychu) `#D1749` e6c2855 (master: 711c69f) +- global: work around `shopt -s compat42` `#D1754` 1f254b5 (master: a75bb25) +- global: identify bash-4.2 bug that internal quoting of `${v/%$empty/"$rep"}` remains `#D1753` 1f254b5 (master: a75bb25) +- prompt: fix a bug of `ble/prompt/print` redundantly quoting `$` `#D1752` 1f254b5 (master: a75bb25) +- global: work around `compat42` quoting of `"${v/pat/"$rep"}"` `#D1751` 1f254b5 (master: a75bb25) +- util: add identification of Windows Terminal `wt` `#D1758` 5907567 (master: e332dc5) +- global: work around bash-3.0 bug that single quotes remains for `"${v-$''}"` `#D1774` 30440b2 (master: 9b96578) +- util (`modifyOtherKeys`): fix a bug that kitty protocol is never activated `#D1842` f8aeb51 (master: 14f3c81) +- util (`modifyOtherKeys`): work around delayed terminal identification `#D1842` f8aeb51 (master: 14f3c81) +- main: resolve empty `HOSTNAME` [originally: contrib: add `histdb`] `#D1925` e82230e (master: 44d9e104) +- main: warn empty `LANG` [originally: main: support an option `--inputrc={diff,all,user,none}`] `#D1926` ede4ee7 (master: 92f2006) +- term (`terminology`): work around terminal glitches `#D1946` ccb93a5 (master: 9a1b4f9) +- edit: always adjust the terminal states with `bind -x` (reported by linwaytin) `#D1983` 992131c (master: 5d14cf1) +- syntax: suppress brace expansions in designated array initialization in Bash 5.3 `#D1989` 1f0d8e1 (master: 1e7b884) +- util (function#evaldef): work around `set -e` [progcomp: work around slow `nix` completion] `#D1997` 2ab4e4b (master: 2c1aacfc) +- util (`string#quote-word`): work around `set -ue` [util, edit: add `ble/util/message` and `ble append-line`] `#D2001` 2317562 (master: 2a524f34) +- complete: suppress error messages from `_adb` `#D2005` 2f77171 (master: f2aa32b) +- edit: restore `PS1` while processing `bind -x` `#D2024` 604c092 (master: 2eadcd5) + +## Optimization +- complete (`ble/complete/source:file`): remove slow old codes (reported by timjrd) `#D1512` 60a33e2 (master: e5be0c1) +- util (`ble/util/assign`): work around subshell conflicts `#D1578` 4117d1b (master: 6e4bb12) +- prompt: fix not properly set `$?` in `${PS1@P}` evaluation (reported by nihilismus) `#D1644` a3cfd0d (master: 521aff9) +- util (`ble/string#split`): optimize `#D1826` 9dcbbd4 (master: 7bb10a7) +- debug: add `ble/debug/profiler` (motivated by SuperSandro2000) `#D1824` f629698 11aa4ab 9dcbbd4 (master: 7bb10a7) +- global: avoid passing arbitrary strings through `awk -v var=value` `#D1827` 9edb1aa (master: 82232de) + +## Internal changes and fixes +- main: include hostname in local runtime directory `#D1444` 3e648a9 (master: 6494836) +- benchmark (`ble-measure`): support `-T TIME` and `-B TIME` option `#D1460` f3833ad (master: 1aa471b) +- global: fix status check for read timeout `#D1467` f190f9a (master: e886883) +- util, etc: ensure each function to work with arbitrary `IFS` `#D1490` `#D1491` c33fad0 (master: 5f9adfe) +- global: work around `localvar_inherit` for varname-list init `#D1566` 8c67b79 (master: 5c2edfc) +- util: fix `ble/util/dense-array#fill-range` e397120 (master: a46fdaf) +- util: fix leak variables `buff`, `trap`, `{x,y}{1,2}` `#D1572` 82113e9 (master: 5967d6c) +- util: fix leak variables `#D1643` 0817df6 (master: fcf634b) +- edit (`command-help`): use `ble/util/assign/.mktmp` to determine the temporary filename `#D1663` 2ff6078 (master: 1af0800) +- Makefile: add fallback Makefile for BSD make `#D1805` ea8b966 (master: e5d8d00) +- util, decode, vi: fix leak variables `#D1933` 9e2e823 (master: 8d5cab8) +- syntax: fix code formatting [originally: complete: support auto-complete sources] `#D1938` 450f70b (master: 00cae745) +- main: use builtin for ":" [histdb: support timeout of background processes] `#D1971` 482ddb5 (master: e0566bdc) +- global: normalize to `_a-zA-Z` [sabbrev: apply sabbrev to right-hand sides of variable assignments] `#D2006` a101fe6 (master: 41faa494) +- util (restore-vars): work around `set -u` [lib: add `util.bgproc` for `ble/util/bgproc`] `#D2017` 8787ca5 (master: 7803305f) +- util: update `ble/util/conditional-sync` [util.bgproc: increase frequency of bgproc termination check] `#D2027` 79fd13c (master: 8d623c1) + +## Test +- util (ble/util/s2bytes): clear locale cache `#D1881` 45f3df3 (master: 2e1a7c1) +- util (ble/util/s2c): work around intermediate mbstate of bash <= 5.2 `#D1881` 45f3df3 (master: 2e1a7c1) +- util (ble/encoding:UTF-8/b2c): fix interpretation of leading byte `#D1881` 45f3df3 (master: 2e1a7c1) +- complete: fix syntax error for bash-3.0 `#D1881` b534799 (master: 0b3e611) + +## Documentation +- blerc: rename from `blerc` to `blerc.template` `#D1899` 3c4e3a4 (master: e19b796) +- wiki/Q&A: add item for defining a widget calling multiple widgets (motivated by micimize) `#D1898` 3c4e3a4 (master: e19b796) +- blerc: add frequently used keybindings (motivated by KiaraGrouwstra, micimize) `#D1896` `#D1897` 3c4e3a4 (master: e19b796) + +## Contrib +- fzf-key-bindings: fix a problem that `modifyOtherKeys` is not reflected (reported by SuperSandro2000) `#D1908` f3a8382 (master: 486564a) + +## New features +- canvas: update emoji database and support `bleopt emoji_version` (motivated by endorfina) `#D1454` 3f6c9b9 (master: d1f8c27) +- syntax: support tilde expansions in parameter expansions `#D1513` e32914f (master: 0506df2) +- prompt (`contrib/prompt-git`): support dirty checking `#D1601` 50a0094 (master: b2713d9) +- util (`bleopt`, `bind`): fix error message and exit status, respectively `#D1640` 29728b1 (master: b663cee) +- edit: support bash-5.2 binding of `prior/next` to `history-search-{for,back}ward` `#D1661` a3a353e (master: d26a6e1) +- util: suppress false warnings of `bind` inside non-interactive shells (reported by wukuan405) `#D1823` 82c9934 (master: 1e19a67) +- auto-complete: cancel auto-complete for `magic-space` `#D1913` 05c0888 (master: 01b4f67) +- complete: support ambiguous completion for command paths `#D1922` 6d1e1ba (master: 8a716ad) +- syntax: support context after `((...))` and `[[ ... ]]` in bash-5.2 `#D1962` 57d7674 (master: 67cb967) + +-------------------------------------------------------------------------------- +# ble-0.2.7 + +## Usage + +**Prerequisites** + +Bash 3.0+ and basic POSIX utilities are required. + +**Download ble-0.2.7.tar.xz** + +https://github.com/akinomyoga/ble.sh/releases/download/v0.2.7/ble-0.2.7.tar.xz + +```bash +# DOWNLOAD with wget +wget https://github.com/akinomyoga/ble.sh/releases/download/v0.2.7/ble-0.2.7.tar.xz + +# DOWNLOAD with curl +curl -LO https://github.com/akinomyoga/ble.sh/releases/download/v0.2.7/ble-0.2.7.tar.xz +``` + +**Trial & Install** + +```bash +# TRIAL +tar xJf ble-0.2.7.tar.xz +source ble-0.2.7/ble.sh + +# INSTALL +tar xJf ble-0.2.7.tar.xz -C ~/.local/share/blesh +# Add the following line near the top of ~/.bashrc +[[ $- == *i* ]] && source ~/.local/share/blesh/ble.sh --noattach +# Add the following line at the end of ~/.bashrc +((_ble_bash)) && ble-attach +``` + +## blesh-0.2 fixes +- global: fix `ble/{is- => util/is}function` 5e82ca7a +- global: pick fixes and changes from ble-0.1 backports 013eb1cd +- complete: fix up 4df15e1e f02bd2a5 +- bump 0.2.7 1118c803 + +## Fixes +- edit: work around the wrong job information of Bash in trap handlers (reported by 3ximus) `#D1435` `#D1436` 795a647c (master: bc4735e0) +- edit (sword): fix definition of `sword` (shell words) `#D1441` 5e73cf6b (master: f9233889) +- edit (`kill-forward-logical-line`): fix a bug not deleting newline at the end of the line `#D1443` 03787a2d (master: 09cf7f14) +- global: work around bash-4.2 bug of `declare -gA` (reported by 0xC0ncord) `#D1470` a2ace444 (master: 8856a04f) +- global: fix declaration of associative arrays for `ble-reload` (reported by 0xC0ncord) `#D1471` 533eba77 (master: 3cae6e4d) +- util (`ble/util/msleep`): fix hang in Cygwin by swithing from `/dev/udp/0.0.0.0/80` to `/dev/zero` `#D1452` 46992e79 (master: d4d718ab) +- syntax: fix broken AST with `[[` keyword `#D1454` 0482bf64 (master: 69658efc) +- util (`ble/util/msleep`): work around the bash-4.3 bug of `read -t` (reported by 3ximus) `#D1468` `#D1469` fad78ea5 (master: 4ca9b2e2) +- bind: work around broken `cmd_xmap` after switching the editing mode `#D1478` 97ca1171 (master: 8d354c1b) +- edit: clear graphic rendition on newlines and external commands `#D1479` 759b96dd (master: 18bb2d5c) +- canvas: fix a glitch that SGR at the end of command line is applied to new lines `#D1498` a6ac1216 (master: 4bdfdbf8) +- syntax: fix a bug that `eval() { :; }`, `declare() { :; }` are not treated as function definition `#D1529` a4cda9c3 (master: b4290958) +- decode: fix a hang on attach failure by cache corruption `#D1531` a4c13ab8 (master: 24ea3792) +- benchmark (`ble-measure`): fix a bug that the result is always 0 in Bash 3 and 4 (fixup 8eb493a9 (master: bbc2a904)) `#D1615` a034c91 +- main: work around `. ble.sh --{test,update,clear-cache}` in intereactive sessions `#D1555` 8eb493a9 (master: bbc2a904) +- main: fix reloading after ble-update (fixup 8eb493a9 (master: bbc2a904)) (fixed by oc1024) `#D1558` 9372670 +- main: fix exit status for `bash ble.sh --test` (fixup 8eb493a9 (master: bbc2a904)) `#D1558` 641238a +- main: work around sourcing `ble.sh` inside subshells `#D1554` 8eb493a9 (master: bbc2a904) +- global: use a better workaround of bash-4.2 `declare -gA` by separating assignment `#D1567` 0b7de999 (master: 2408a207) +- edit (brackated-paste): fix incomplete `CR => LF` conversion (reported by alborotogarcia) `#D1587` ac738bb4 (master: 8d6da161) +- highlight (`layer:region`): fix blocked lower-layer changes without selection changes `#D1596` 650140ff (master: 5ede3c69) +- util: work around the Bash 3 bug of array assignments with `^A` and `^?` in Bash 3.2 `#D1614` 0ed7f6dc (master: b9f76118) +- benchmark (`ble-measure`): fix a bug that the result is always 0 in Bash 3 and 4 (fixup bbc2a904) `#D1615` 28e8dfed (master: a034c91a) +- decode, canvas, etc.: explicitly treat CSI arguments as decimal numbers (reported by GorrillaRibs) `#D1625` c9e4198b (master: c6473b78) 2ea48d7 +- edit: fix a bug that `command-help` doesn't work `#D1635` b992bb5d (master: 0f6a0834) +- canvas: update prompt trace on `char_width_mode` change (reported by Barbarossa93) `#D1642` 56b77a83 (master: 68ee1112) +- util (`ble/util/readfile`): fix a bug of always exiting with 1 in `bash <= 3.2` (reported by laoshaw) `#D1678` 5b843bb6 (master: 61705bf6) +- complete: do not generate keywords for quoted command names `#D1691` 7211b1ec (master: 60d244fe) +- complete: fix empty completions with `FIGNORE` (reported by seanfarley) `#D1711` 90f388aa (master: 144ea5db) +- main: fix the message of owner errors of cache directories (reported by zim0369) `#D1712` d2bf86c1 (master: b547a41a) +- syntax: fix uninitialized syntax-highlighting in bash-3.2 `#D1731` 6aa12c82 (master: e3f5bf74) +- progcomp: retry completions on `$? == 124` also for non-default completions (reported by SuperSandro2000) `#D1759` c641fb1b (master: 82b9c011) +- util (`ble/util/import`): work around filenames with bash special characters `#D1763` 7da5f048 (master: b27f7585) +- edit: fix the restore failure of `PS1` and `PROMPT_COMMAND` on `ble-detach` `#D1784` 47dfdd94 (master: b9fdaabd) +- history: work around possible dirty prefix `*` in the history output `#D1808` cc14f59c (master: 64a740d7) +- decode: fix the workaround for `set -e` with `--prompt=attach` `#D1832` 958aae6b (master: 51113237) +- main. util: fix problems of readlink etc. found by test in macOS (reported by aiotter) `#D1849` 8f0acf3d (master: fa955c1a) `#D1855` a22e145 +- global: quote `return $?` `#D1884` 9e10b54b (master: 801d14af) +- bind: fix M-C-@, C-x C-@, and M-C-x (`bash-4.2 -o emacs`) `#D1920` 342826f3 (master: a410b038) +- keymap/vi (`operator:filter`): do not append newline at the end of line `#D1994` 2a8e746f (master: bce20339) +- keymap/vi (`expand-range-for-linewise-operator`): fix the end point being not extended `#D1994` 2a8e746f (master: bce20339) +- syntax: fix unrecognized asignment `echo arr[i]+=rhs` [sabbrev: apply sabbrev to right-hand sides of variable assignments] `#D2006` 4ed4fd4f (master: 41faa494) +- syntax: fix unrecognized variable assignment of the form `echo arr[i]+=rhs` `#D2007` 4ed4fd4f (master: 41faa494) + +## Changes +- syntax: exclude \\ + LF at the word beginning from words (motivated by cmplstofB) `#D1431` 6044a485 (master: 67e62d64) +- edit: change default behavior of C-w and M-w to operate on backward words `#D1448` 787ff57f (master: 47a3301a) +- edit: the widgets `{kill,copy,delete}-region-or` now receives widgets as arguments `#D1021` 8f48aff1 (master: bbbd155f) +- edit (`ble/builtin/read`): cancel by C-d on an empty line `#D1473` 551bde3a (master: ecb8888d) +- syntax: change syntax context after `time ;` and `! ;` for Bash 4.4 `#D1477` 0b66cf4a (master: 46283706) +- prompt: invalidate prompt and textarea on prompt setting changes `#D1492` 54d310df (master: 1f559135) +- prompt: adjust behavior of `LINENO` and prompt sequence `\#` (reported by tycho-kirchner) `#D1542` 4b63b164 (master: 8b0257e2) +- main: show notifications against debug versions of Bash `#D1612` 608ac2ad (master: 8f974aa1) +- prompt: do not evaluate `PROMPT_COMMAND` for subprompts `#D1654` 5c0cfdef (master: 08e903e0) +- main: suppress non-interactive warnings from manually sourced startup files (reported by andreclerigo) `#D1676` 2587bb01 (master: 05255282) 88e2df5 +- main: suppress non-interactive warnings from manually sourced startup files (reported by andreclerigo) `#D1676` 0525528 5f638563 (master: 88e2df51) +- util (`ble/util/buffer`): hide cursor in rendering `#D1758` 4ecbbdc2 (master: e332dc5f) +- edit (`ble-detach`): prepend a space to `stty sane` for `HISTIGNORE=' *'` `#D1796` bd903716 (master: 26b532e7) +- history: disable the history file when `HISTFILE` is empty `#D1836` d97ca100 (master: 9549e831) +- keymap/vi (`decompose-meta`): translate S-a to A `#D1988` eaf66c7c (master: 600e845e) +- term (`_ble_term_TERM`): detect konsole `#D1988` eaf66c7c (master: 600e845e) ed53858 +- complete (`source:argument`): fallback to rhs completion also for `name+=rhs` `#D2006` 4ed4fd4f (master: 41faa494) + +## Compatibility +- highlight: fix a problem that the attribute of the last character is applied till EOL `#D1393` 36f9d809 (master: 2ddb1ba2) `#D1395` ef09932 +- highlight: fix a problem that the attribute of the last character is applied till EOL `#D1393` 2ddb1ba `#D1395` 6bcb4053 (master: ef099326) +- global: work around empty `vi_imap` cache by `tmux-resurrect` `#D1562` d7130d55 (master: 560160b0) +- main: work around `set -B` and `set -k` `#D1628` 3c97ae84 (master: a8607692) +- cmap: add `st`-specific escape sequences for cursor keys `#D1633` bf46e344 (master: acfb8790) +- cmap: distinguish find/select from home/end for openSUSE `inputrc.keys` (reported by cornfeedhobo) `#D1648` ad675556 (master: c4d28f40) +- cmap: freeze the internal codes of find/select and kitty special keys `#D1674` f41b8004 (master: fdfe62a4) +- decode: work around the overwritten builtin `set` (reported by eadmaster) `#D1680` 93ae08d0 (master: a6b4e2ca) +- complete: work around the variable leaks by `virsh` completion from `libvirt` (reported by telometto) `#D1682` ee2ac075 (master: f985b9a4) +- stty: do not remove keydefs for C-u, C-v, C-w, and C-? (reported by laoshaw) `#D1683` c01487bf (master: 82f74f0a) +- main: work around `XDG_RUNTIME_DIR` of a different user by `su` (reported by zim0369) `#D1712` e5501a31 (master: 8d370486) +- main (`ble/util/readlink`): work around non-standard or missing `readlink` (motivated by peterzky) `#D1720` d785f5db (master: a41279ed) +- global: work around the arithmetic syntax error of `10#` in Bash-5.1 `#D1734` 2b55aa16 (master: 7545ea31) +- global: adjust implementations for Bash 5.2 `patsub_replacement` `#D1738` 359a3891 (master: 4590997a) +- main: check `/dev/tty` on startup (reported by andychu) `#D1749` 19fa0924 (master: 711c69f1) +- global: work around `shopt -s compat42` `#D1754` e7adfb34 (master: a75bb25a) +- global: identify bash-4.2 bug that internal quoting of `${v/%$empty/"$rep"}` remains `#D1753` e7adfb34 (master: a75bb25a) +- prompt: fix a bug of `ble/prompt/print` redundantly quoting `$` `#D1752` e7adfb34 (master: a75bb25a) +- global: work around `compat42` quoting of `"${v/pat/"$rep"}"` `#D1751` e7adfb34 (master: a75bb25a) +- util: add identification of Windows Terminal `wt` `#D1758` 4ecbbdc2 (master: e332dc5f) +- global: work around bash-3.0 bug that single quotes remains for `"${v-$''}"` `#D1774` fb607ad6 (master: 9b96578c) +- main: resolve empty `HOSTNAME` [add `histdb`] `#D1925` 5812f2ef (master: 44d9e104) +- main: warn empty `LANG` [main: support an option `--inputrc={diff,all,user,none}`] `#D1926` 3f29bee3 (master: 92f20063) +- main: never load `/etc/inputrc` in openSUSE (motivated by Ultra980) `#D1926` 3f29bee3 (master: 92f20063) 0ceb0cb +- main: show warning for empty locale (movivated by Ultra980) `#D1927` 3f29bee3 (master: 92f20063) +- term (`terminology`): work around terminal glitches `#D1946` 2d4caa67 (master: 9a1b4f9f) +- edit: always adjust the terminal states with `bind -x` (reported by linwaytin) `#D1983` cdda7c44 (master: 5d14cf17) +- syntax: suppress brace expansions in designated array initialization in Bash 5.3 `#D1989` 78dd47ee (master: 1e7b884d) +- edit: restore `PS1` while processing `bind -x` (reported by adoyle-h) `#D2024` c46f4230 (master: 2eadcd5b) + +## Optimization +- util (`ble/util/assign`): work around subshell conflicts `#D1578` 59d6355c (master: 6e4bb126) +- prompt: fix not properly set `$?` in `${PS1@P}` evaluation (reported by nihilismus) `#D1644` 66fd10b7 (master: 521aff9b) +- util (`ble/string#split`): optimize `#D1826` 5b3fc89c (master: 7bb10a79) +- debug: add `ble/debug/profiler` (motivated by SuperSandro2000) `#D1824` f629698 11aa4ab 5b3fc89c (master: 7bb10a79) +- global: avoid passing arbitrary strings through `awk -v var=value` `#D1827` 4571695a (master: 82232de5) + +## Internal changes and fixes +- main: include hostname in local runtime directory `#D1444` d19ab298 (master: 64948361) +- global: fix status check for read timeout `#D1467` 0bcc12c9 (master: e886883b) +- util, etc: ensure each function to work with arbitrary `IFS` `#D1490` `#D1491` 2fe60b64 (master: 5f9adfe8) +- util: fix `ble/util/dense-array#fill-range` b708ee29 (master: a46fdaf4) +- util: fix leak variables `buff`, `trap`, `{x,y}{1,2}` `#D1572` 36d151e2 (master: 5967d6ce) +- make: add fallback Makefile for BSD make `#D1805` 6498a5d3 (master: e5d8d00c) +- util, decode, vi: fix leak variables `#D1933` 002dda7f (master: 8d5cab85) +- syntax: fix code formatting [histdb: support auto-complete source `histdb-word`] `#D1938` edd48d1c (master: 00cae745) +- main: use builtin for `:` [histdb: support timeout of background processes] `#D1971` 8640dc41 (master: e0566bdc) +- global: normalize bracket expressions to `_a-zA-Z` / `_a-zA-Z0-9` `#D2006` 4ed4fd4f (master: 41faa494) +- util (restore-vars): work around `set -u` [util.bgproc: separate `ble/util/bgproc` from `histdb`] `#D2017` d60758ae (master: 7803305f) + +## Test +- util (ble/util/s2bytes): clear locale cache `#D1881` 99e217d3 (master: 2e1a7c17) +- util (ble/util/s2c): work around intermediate mbstate of bash <= 5.2 `#D1881` 99e217d3 (master: 2e1a7c17) +- util (ble/encoding:UTF-8/b2c): fix interpretation of leading byte `#D1881` 99e217d3 (master: 2e1a7c17) + +## New features +- syntax: support context after `((...))` and `[[ ... ]]` in bash-5.2 `#D1962` 74af9e60 (master: 67cb967a) + +-------------------------------------------------------------------------------- +# ble-0.1.15 + +## Usage + +**Prerequisites** + +Bash 3.0+ and basic POSIX utilities are required. + +**Download ble-0.1.15.tar.xz** + +https://github.com/akinomyoga/ble.sh/releases/download/v0.1.15/ble-0.1.15.tar.xz + +```bash +# DOWNLOAD with wget +wget https://github.com/akinomyoga/ble.sh/releases/download/v0.1.15/ble-0.1.15.tar.xz + +# DOWNLOAD with curl +curl -LO https://github.com/akinomyoga/ble.sh/releases/download/v0.1.15/ble-0.1.15.tar.xz +``` + +**Trial & Install** + +```bash +# TRIAL +tar xJf ble-0.1.15.tar.xz +source ble-0.1.15/ble.sh + +# INSTALL +tar xJf ble-0.1.15.tar.xz -C ~/.local/share/blesh +# Add the following line near the top of ~/.bashrc +[[ $- == *i* ]] && source ~/.local/share/blesh/ble.sh --noattach +# Add the following line at the end of ~/.bashrc +((_ble_bash)) && ble-attach +``` + +## blesh-0.1 fixes +- edit,highlight: backport changes in rebased commits dfac242 +- bump 0.1.15 3f4d866 + +## Fixes +- edit (sword): fix definition of `sword` (shell words) `#D1441` 03980f1 (master: f923388) +- bind: work around broken `cmd_xmap` after switching the editing mode `#D1478` 847e602 (master: 8d354c1) +- benchmark (`ble-measure`): fix a bug that the result is always 0 in Bash 3 and 4 (fixup 4759768 (master: bbc2a90)) `#D1615` a034c91 +- main: work around `. ble.sh --{test,update,clear-cache}` in intereactive sessions `#D1555` 4759768 (master: bbc2a90) +- main: fix reloading after ble-update (fixup 4759768 (master: bbc2a90)) (fixed by oc1024) `#D1558` 9372670 +- main: fix exit status for `bash ble.sh --test` (fixup 4759768 (master: bbc2a90)) `#D1558` 641238a +- main: work around sourcing `ble.sh` inside subshells `#D1554` 4759768 (master: bbc2a90) +- util: work around the Bash 3 bug of array assignments with `^A` and `^?` in Bash 3.2 `#D1614` 9648bd4 (master: b9f7611) +- decode, canvas, etc.: explicitly treat CSI arguments as decimal numbers (reported by GorrillaRibs) `#D1625` 40a0ec9 (master: c6473b7) 2ea48d7 +- edit: fix a bug that `command-help` doesn't work `#D1635` c99e2f1 (master: 0f6a083) +- canvas: update prompt trace on `char_width_mode` change (reported by Barbarossa93) `#D1642` 5b22cd6 (master: 68ee111) +- complete: do not generate keywords for quoted command names `#D1691` cd75f39 (master: 60d244f) +- progcomp: retry completions on `$? == 124` also for non-default completions (reported by SuperSandro2000) `#D1759` a66b547 (master: 82b9c01) +- edit: fix the restore failure of `PS1` and `PROMPT_COMMAND` on `ble-detach` `#D1784` a0f6594 (master: b9fdaab) +- history: work around possible dirty prefix `*` in the history output `#D1808` 0ed2ffb (master: 64a740d) +- main. util: fix problems of readlink etc. found by test in macOS (reported by aiotter) `#D1849` 1dc5938 (master: fa955c1) `#D1855` a22e145 +- global: quote `return $?` `#D1884` c2ba90b (master: 801d14a) +- bind: fix M-C-@, C-x C-@, and M-C-x (`bash-4.2 -o emacs`) `#D1920` de577dc (master: a410b03) + +## Changes +- syntax: exclude \\ + LF at the word beginning from words (motivated by cmplstofB) `#D1431` 69156f1 (master: 67e62d6) +- edit: change default behavior of C-w and M-w to operate on backward words `#D1448` 0a07c13 (master: 47a3301) +- edit: the widgets `{kill,copy,delete}-region-or` now receives widgets as arguments `#D1021` ec16708 (master: bbbd155) +- main: show notifications against debug versions of Bash `#D1612` 8f989e4 (master: 8f974aa) +- main: suppress non-interactive warnings from manually sourced startup files (reported by andreclerigo) `#D1676` 2a045d8 (master: 0525528) 88e2df5 +- main: suppress non-interactive warnings from manually sourced startup files (reported by andreclerigo) `#D1676` 0525528 4ef844e (master: 88e2df5) +- util (`ble/util/buffer`): hide cursor in rendering `#D1758` 444abff (master: e332dc5) +- edit (`ble-detach`): prepend a space to `stty sane` for `HISTIGNORE=' *'` `#D1796` acb7c08 (master: 26b532e) +- history: disable the history file when `HISTFILE` is empty `#D1836` a79095a (master: 9549e83) + +## Compatibility +- global: work around empty `vi_imap` cache by `tmux-resurrect` `#D1562` b0cc0a3 (master: 560160b) +- cmap: add `st`-specific escape sequences for cursor keys `#D1633` ae298f1 (master: acfb879) +- cmap: distinguish find/select from home/end for openSUSE `inputrc.keys` (reported by cornfeedhobo) `#D1648` 603cf41 (master: c4d28f4) +- cmap: freeze the internal codes of find/select and kitty special keys `#D1674` 66263c4 (master: fdfe62a) +- decode: work around the overwritten builtin `set` (reported by eadmaster) `#D1680` 43dcb66 (master: a6b4e2c) +- complete: work around the variable leaks by `virsh` completion from `libvirt` (reported by telometto) `#D1682` d13ce5b (master: f985b9a) +- stty: do not remove keydefs for C-u, C-v, C-w, and C-? (reported by laoshaw) `#D1683` 6335dc2 (master: 82f74f0) +- main (`ble/util/readlink`): work around non-standard or missing `readlink` (motivated by peterzky) `#D1720` 94137b7 (master: a41279e) +- global: work around the arithmetic syntax error of `10#` in Bash-5.1 `#D1734` 7c2463e (master: 7545ea3) +- global: adjust implementations for Bash 5.2 `patsub_replacement` `#D1738` f1599ee (master: 4590997) +- main: check `/dev/tty` on startup (reported by andychu) `#D1749` 28e9c44 (master: 711c69f) +- global: work around `shopt -s compat42` `#D1754` 59075cc (master: a75bb25) +- global: identify bash-4.2 bug that internal quoting of `${v/%$empty/"$rep"}` remains `#D1753` 59075cc (master: a75bb25) +- prompt: fix a bug of `ble/prompt/print` redundantly quoting `$` `#D1752` 59075cc (master: a75bb25) +- global: work around `compat42` quoting of `"${v/pat/"$rep"}"` `#D1751` 59075cc (master: a75bb25) +- util: add identification of Windows Terminal `wt` `#D1758` 444abff (master: e332dc5) +- global: work around bash-3.0 bug that single quotes remains for `"${v-$''}"` `#D1774` d0dc13e (master: 9b96578) +- highlight: fix a problem that the attribute of the last character is applied till EOL `#D1393` 2ddb1ba `#D1395` 8c33557 (master: ef09932) +- main: resolve empty `HOSTNAME` [add `histdb`] `#D1925` e6cc6c3 (master: 44d9e10) +- main: warn empty `LANG` [main: support an option `--inputrc={diff,all,user,none}`] `#D1926` 2bd1544 (master: 92f2006) +- term (`terminology`): work around terminal glitches `#D1946` c5c3bc9 (master: 9a1b4f9) +- edit: restore `PS1` while processing `bind -x` (reported by adoyle-h) `#D2024` 94db09b (master: 2eadcd5) + +## Optimization +- prompt: fix not properly set `$?` in `${PS1@P}` evaluation (reported by nihilismus) `#D1644` a7b5c4b (master: 521aff9) + +## Internal changes and fixes +- main: include hostname in local runtime directory `#D1444` 1a5e90a (master: 6494836) +- global: fix status check for read timeout `#D1467` b56d638 (master: e886883) +- util, etc: ensure each function to work with arbitrary `IFS` `#D1490` `#D1491` 7228fd0 (master: 5f9adfe) +- util: fix leak variables `buff`, `trap`, `{x,y}{1,2}` `#D1572` de71ada (master: 5967d6c) +- make: add fallback Makefile for BSD make `#D1805` 2cb758f (master: e5d8d00) +- util, decode, vi: fix leak variables `#D1933` a2197a6 (master: 8d5cab8) +- syntax: fix code formatting [histdb: support auto-complete source `histdb-word`] `#D1938` 492349f (master: 00cae74) + +## Test +- util (ble/util/s2bytes): clear locale cache `#D1881` a8d7fd7 (master: 2e1a7c1) +- util (ble/util/s2c): work around intermediate mbstate of bash <= 5.2 `#D1881` a8d7fd7 (master: 2e1a7c1) +- util (ble/encoding:UTF-8/b2c): fix interpretation of leading byte `#D1881` a8d7fd7 (master: 2e1a7c1) + +-------------------------------------------------------------------------------- +# ble-0.4.0-devel2 + +## Usage + +**Prerequisites** + +Bash 3.0+ and basic POSIX utilities are required. + +**Download ble-0.4.0-devel2.tar.xz** + +https://github.com/akinomyoga/ble.sh/releases/download/v0.4.0-devel2/ble-0.4.0-devel2.tar.xz + +```bash +# DOWNLOAD with wget +wget https://github.com/akinomyoga/ble.sh/releases/download/v0.4.0-devel2/ble-0.4.0-devel2.tar.xz + +# DOWNLOAD with curl +curl -LO https://github.com/akinomyoga/ble.sh/releases/download/v0.4.0-devel2/ble-0.4.0-devel2.tar.xz +``` + +**Trial & Install** + +```bash +# TRIAL +tar xJf ble-0.4.0-devel2.tar.xz +source ble-0.4.0-devel2/ble.sh + +# INSTALL (quick) +tar xJf ble-0.4.0-devel2.tar.xz -C ~/.local/share/blesh +echo 'source ~/.local/share/blesh' >> ~/.bashrc + +# INSTALL (more robust) +tar xJf ble-0.4.0-devel2.tar.xz -C ~/.local/share/blesh +# Add the following line near the top of ~/.bashrc +[[ $- == *i* ]] && source ~/.local/share/blesh/ble.sh --attach=none +# Add the following line at the end of ~/.bashrc +[[ ${BLE_VERSION-} ]] && ble-attach +``` + +-------------------------------------------------------------------------------- + +# ble-0.3.3 + +## Usage + +**Prerequisites** + +Bash 3.0+ and basic POSIX utilities are required. + +**Download ble-0.3.3.tar.xz** + +https://github.com/akinomyoga/ble.sh/releases/download/v0.3.3/ble-0.3.3.tar.xz + +```bash +# DOWNLOAD with wget +wget https://github.com/akinomyoga/ble.sh/releases/download/v0.3.3/ble-0.3.3.tar.xz + +# DOWNLOAD with curl +curl -LO https://github.com/akinomyoga/ble.sh/releases/download/v0.3.3/ble-0.3.3.tar.xz +``` + +**Trial & Install** + +```bash +# TRIAL +tar xJf ble-0.3.3.tar.xz +source ble-0.3.3/ble.sh + +# INSTALL +tar xJf ble-0.3.3.tar.xz -C ~/.local/share/blesh +# Add the following line near the top of ~/.bashrc +[[ $- == *i* ]] && source ~/.local/share/blesh/ble.sh --attach=none +# Add the following line at the end of ~/.bashrc +[[ ${BLE_VERSION-} ]] && ble-attach +``` + +## New features + +- syntax: allow unquoted `[!` and `[^` in `simple-word` (reported by cmplstofB) `#D1303` 4bf8b86 (master: 1efe833) + +## Changes + +- auto-complete: bind `insert-on-end` to `C-e` `#D1250` 1070aba (master: 90b45eb) +- util (`bleopt`): fail when a specified bleopt variable does not exist (test-util) 0a51044 (master: 5966f22) +- edit: preserve `PS1` when `internal_suppress_bash_output` is set `#D1344` 537acf2 (master: 6ede0c7) +- complete: change to generate filenames starting from `.` by default `#D1425` e26867d (master: 987436d) + +## Fix + +- [ble-0.3] reload: fix a bug that the state is broken by `ble-reload` `#D1266` f2f30d1 (master: N/A) +- decode (`ble/builtin/bind`): remove comment from bind argument `#D1267` 82f4aaa (master: 880bb2c) +- complete: clear menu on history move `#D1248` 04fddd6 (master: 06cc7de) +- syntax: fix a bug that arguments of `eval` are not highlighted `#D1254` 38a7fc7 (master: 5046d14) +- decode: use `BRE` instead of `ERE` for `POSIX sed` (reported by dylankb) `#D1283` a577ec4 (master: 2184739) +- vi (vi-command/nth-column): fix a bug in arithmetic expansion (reported by andychu) `#D1292` ea2fa8e (master: da6cc47) +- complete: fix a bug that menu-filter is only partially turned off by `complete_menu_filter` `#D1298` 7278e27 (master: b3654e2) +- syntax: fix failglob errors of heredocs of the form `<<$(echo A)` `#D1308` 5ba9400 (master: 3212fd2) +- util (`bleopt`): fix a bug that a new setting is not defined with `name:=` (test-util) `#D1312` f2dbad0 (master: c757b92) +- util (`ble/util/{save,restore}-vars`): fix a bug that `name` and `prefix` cannot be saved/restored (test-util) f91f7ed (master: 5f2480c) +- util (`ble/path#remove{,-glob}`): fix corner cases (test-util) 2ba1d42 (master: ccbc9f8) +- util (`ble/variable#get-attr`): fix an error message with special variable names such as `?` and `*` `#D1321` b58f006 (master: 557b774) +- edit: fix a bug that `set +H` is cancelled on command execution `#D1332` bc454a2 (master: 02bdf4e) +- syntax (`ble/syntax/parse/shift`): fix a bug of shift skip in nested words `#D1333` 78e2170 (master: 65fbba0) +- util (`ble-stackdump`): fix a shift of line numbers `#D1337` 1505a5b (master: a14b72f) +- edit (`ble-bind -x`): check range of `READLINE_{POINT,MARK}` `#D1339` 1bc1ff6 (master: efe1e81) +- main: fix a bug that `~/.config/blesh/init.sh` is not detected (GitHub #53 by rux616) 9f74da6 (master: 61f9e10) +- util (`ble/string#to{upper,lower}`): work around `LC_COLLATE=en_US.utf8` (test-util) `#D1341` 5d9aa64 (master: 1f6b44e) `#D1355` 4e67719 (master: 4da6103) + - fixup 5d9aa64 fef40eb (master: N/A) +- util (encoding, keyseq): fix miscelleneous encoding bugs (test-util) 6d72d2a (master: 435bd16) +- edit: work around `WINCH` not updating `COLUMNS`/`LINES` after `ble-reload` `#D1345` e2d54a2 (master: a190455) +- complete: initialize `bleopt complete_menu_style` options before `complete_load` hook (reported by rux616) `#D1352` 15ba24f (master: 8a9a386) +- main: fix problems caused by multiple `source ble.sh` in bashrc `#D1354` 983e8a9 (master: 5476933) +- syntax: allow single-character variable name in named redirections `{a}<>` `#D1360` 52de342 (master: 4760409) +- decode (`bind`): work around `shopt -s nocasematch` (reported by tigger04) `#D1372` b34ad58 (master: 855cacf) +- prompt: fix a bug that rprompt is not cleared when `bleopt prompt_rps1` is reset `#D1377` c736bd5 (master: 1904b1d) +- complete: fix a bug of duplicated completions of filenames with spaces `#D1390` 048f17e (master: 98576c7) +- complete: fix bugs that quotation disappears on ambiguous completion `#D1387` 048f17e (master: 98576c7) +- complete: fix a bug that progcomp retry by 124 caused the default completion again `#D1386` 048f17e (master: 98576c7) +- syntax (tree-enumerate): fix unmodified `wtype` of reconstructed words at the end `#D1385` 048f17e (master: 98576c7) +- complete: fix superlinear performace of ambiguous matching globpat `#D1389` bd4657a (master: 71afaba) +- prompt: fix a bug that lonig rps1 is not correctly turned off `#D1401` 9266961 (master: d84bcd8) +- prompt: fix extra spaces on line folding before double width character `#D1400` 9266961 (master: d84bcd8) +- syntax (glob bracket expression): fix a bug of unsupported POSIX brackets `#D1402` e1eca65 (master: 6fd9e22) +- syntax (`ble/syntax:bash/simple-word/evaluate-path-spec`): fix a bug of unrecognized `[!...]` and `[^...]` `#D1403` 50fcd03 (master: 0b842f5) +- highlight: fix remaininig highlighting of vanishing words `#D1421` `#D1422` 0f85719 (master: 1066653) +- highlight: fix unhighlighted tilde expansions `~+` (reported by cmplstofB) `#D1424` 1f9abf6 (master: a32962e) +- complete: fix a problem that the user setting `dotglob` is changed `#D1425` e26867d (master: 987436d) +- complete: fix a problem of redundant unmatched ambiguous part with tilde expansions in the common prefix `#D1417` 20cb6af (master: 5777d7f) +- complete (`source:file`): fix a bug that tilde expansion candidates are always filtered out `#D1416` 20cb6af (master: 5777d7f) +- complete (`cd`): fix duplicate candidates by `CDPATH` (reported by Lennart00 at `oh-my-bash`) `#D1415` 20cb6af (master: 5777d7f) + +## Compatibility + +- msys2: support2 MSYS (motivated by SUCHMOKUO) `#D1264` 500e051 (master: 47e2863) + - edit: support `\$` in `PS1` for MSYS2 `#D1265` b8c2ca6 (master: f6f8956) + - edit: fixup b8c2ca6 fe78bd6 (master: N/A) + - msys2: work around MSYS2 Bash bug of missing CR `#D1270` 8c09190 (master: 71f3498) +- edit (`ble/widget/bracketed-paste`): fix error messages on `paste_end` in older version of Bash (test-util) 1631069 (master: b2c7d1c) +- decode: work around Bash-3.1 bug of `declare -f` rejecting special characters in function names (test-util) 1631069 (master: b2c7d1c) +- util (`ble/variable#get-attr`): fix a bug that attributes are not obtained in Bash <= 4.3 (test-util) 1631069 (master: b2c7d1c) +- decode: work around Bash-4.1 bug that locale not applied with `LC_CTYPE=C eval command` (test-util) 1631069 (master: b2c7d1c) +- complete: follow Bash-5.1 change of arithmetic literal `10#` `#D1322` b58f006 (master: 557b774) +- decode: work around Bash-4.1 arithmetic bug of array subscripts evaluated in discarded branches `#D1320` b58f006 (master: 557b774) +- decode: fix a bug of broken cmap cache found in ble-0.3 `#D1327` 4b15993 (master: 16b56bf) +- util (strftime): fix a bug not working with `-v var` option in Bash <= 4.1 (test-util) 360211c (master: f1a2818) +- complete: work around slow `compgen -c` in Cygwin `#D1329` 185a443 (master: 5327f5d) +- edit: work around problems with `mc` (reported by onelittlehope) `#D1392` 4d534b4 (master: e97aa07) + - highlight: fix a problem that the attribute of the last character is applied till EOL `#D1393` f47a5b8 (master: 2ddb1ba) `#D1395` 8c1e17c (master: ef09932) + +## Internal + +- global: check isolated identifiers and leak variables `#D1246` f92ba5c (master: 19cc99d) 9461953 (master: 2e74b6d) +- main: unset `BLE_VERSION`, `_ble_bash`, etc. on `ble-unload` `#D1382` 2bbd0fb (master: 6b615b6) + - complete: fix unfiltered tilde expansions `#D1414` 20cb6af (master: 5777d7f) + +------------------------------------------------------------------------------- +# ble-0.2.6 + +## New features + +- syntax: allow unquoted `[!` and `[^` in `simple-word` (reported by cmplstofB) `#D1303` 5cff40f (master: 1efe833) + +## Changes + +- edit: preserve `PS1` when `internal_suppress_bash_output` is set `#D1344` 72ae9c6 (master: 6ede0c7) + +## Fix + +- decode: use `BRE` instead of `ERE` for `POSIX sed` (reported by dylankb) `#D1283` bca4598 (master: 2184739) +- vi (vi-command/nth-column): fix a bug in arithmetic expansion (reported by andychu) `#D1292` 4260bc2 (master: da6cc47) +- syntax: fix failglob errors of heredocs of the form `<<$(echo A)` `#D1308` 1f874ba (master: 3212fd2) +- util (`bleopt`): fix a bug that a new setting is not defined with `name:=` (test-util) `#D1312` a9eb0e9 (master: c757b92) +- util (`ble/util/{save,restore}-vars`): fix a bug that `name` and `prefix` cannot be saved/restored (test-util) 49841db (master: 5f2480c) +- edit: fix a bug that `set +H` is cancelled on command execution `#D1332` 2ff6d06 (master: 02bdf4e) +- syntax (`ble/syntax/parse/shift`): fix a bug of shift skip in nested words `#D1333` bc935bd (master: 65fbba0) +- util (`ble-stackdump`): fix a shift of line numbers `#D1337` b597e90 (master: a14b72f) +- edit (`ble-bind -x`): check range of `READLINE_{POINT,MARK}` `#D1339` 47a93e8 (master: efe1e81) +- util (`ble/string#to{upper,lower}`): work around `LC_COLLATE=en_US.utf8` (test-util) `#D1341` 5b32621 (master: 1f6b44e) `#D1355` b38ef10 (master: 4da6103) +- util (encoding, keyseq): fix miscelleneous encoding bugs (test-util) 03c0b44 (master: 435bd16) +- edit: work around `WINCH` not updating `COLUMNS`/`LINES` after `ble-reload` `#D1345` 50af6a5 (master: a190455) +- syntax: allow single-character variable name in named redirections `{a}<>` `#D1360` f81734f (master: 4760409) +- syntax (glob bracket expression): fix a bug of unsupported POSIX brackets `#D1402` b7ea892 (master: 6fd9e22) +- highlight: fix remaininig highlighting of vanishing words `#D1421` `#D1422` cc5e4d1 (master: 1066653) +- highlight: fix unhighlighted tilde expansions `~+` (reported by cmplstofB) `#D1424` 3f7f044 (master: a32962e) + +## Compatibility + +- msys2: support2 MSYS (motivated by SUCHMOKUO) `#D1264` 7cf81c0 (master: 47e2863) + - edit: support `\$` in `PS1` for MSYS2 `#D1265` 8f44624 (master: f6f8956) + - msys2: work around MSYS2 Bash bug of missing CR `#D1270` bbe1b61 (master: 71f3498) +- edit (`ble/widget/bracketed-paste`): fix error messages on `paste_end` in older version of Bash (test-util) a80f1d1 (master: b2c7d1c) +- decode: work around Bash-3.1 bug of `declare -f` rejecting special characters in function names (test-util) a80f1d1 (master: b2c7d1c) +- util (`ble/variable#get-attr`): fix a bug that attributes are not obtained in Bash <= 4.3 (test-util) a80f1d1 (master: b2c7d1c) +- decode: work around Bash-4.1 bug that locale not applied with `LC_CTYPE=C eval command` (test-util) a80f1d1 (master: b2c7d1c) +- decode: fix a bug of broken cmap cache found in ble-0.3 `#D1327` 366e8c1 (master: 16b56bf) +- util (strftime): fix a bug not working with `-v var` option in Bash <= 4.1 (test-util) 4f11463 (master: f1a2818) +- complete: work around slow `compgen -c` in Cygwin `#D1329` 887be6e (master: 5327f5d) +- edit: work around problems with `mc` (reported by onelittlehope) `#D1392` a2d6099 (master: e97aa07) + +## Internal + +- global: check isolated identifiers and leak variables `#D1246` 146c98b (master: 19cc99d) + +------------------------------------------------------------------------------- +# ble-0.1.14 + +## Change + +- edit: preserve `PS1` when `internal_suppress_bash_output` is set `#D1344` 549f8f5 (master: 6ede0c7) + +## Fix + +- fixup ab01ceb 8129816 (v0.2: 51bde60) +- decode: use `BRE` instead of `ERE` for `POSIX sed` (reported by dylankb) `#D1283` 1244d86 (master: 2184739) +- edit: fix a bug that `set +H` is cancelled on command execution `#D1332` ba3687a (master: 02bdf4e) +- syntax (`ble/syntax/parse/shift`): fix a bug of shift skip in nested words `#D1333` 16fb351 (master: 65fbba0) +- util (`ble-stackdump`): fix a shift of line numbers `#D1337` 5d5b86b (master: a14b72f) +- edit (`ble-bind -x`): check range of `READLINE_{POINT,MARK}` `#D1339` 6909cc0 (master: efe1e81) +- util (`ble/string#to{upper,lower}`): work around `LC_COLLATE=en_US.utf8` (test-util) `#D1341` 31476cc (master: 1f6b44e) `#D1355` 65cab5c (master: 4da6103) +- util (encoding, keyseq): fix miscelleneous encoding bugs (test-util) 11d8db7 (master: 435bd16) +- edit: work around `WINCH` not updating `COLUMNS`/`LINES` after `ble-reload` `#D1345` e15c5a6 (master: a190455) +- syntax: allow single-character variable name in named redirections `{a}<>` `#D1360` 6bbed24 (master: 4760409) +- highlight: fix remaininig highlighting of vanishing words `#D1421` `#D1422` bf8fdc8 (master: 1066653) + +## Compatibility + +- global: work around Bash 3.2 bug of array initialization with SOH/DEL `#D1238` 566f53e (master: defdbd4) `#D1241` +- msys2: support2 MSYS (motivated by SUCHMOKUO) `#D1264` 19a36ea (master: 47e2863) + - edit: support `\$` in `PS1` for MSYS2 `#D1265` 8658738 (master: f6f8956) + - msys2: work around MSYS2 Bash bug of missing CR `#D1270` b72c063 (master: 71f3498) +- decode: fix a bug of broken cmap cache found in ble-0.3 `#D1327` fc6ded3 (master: 16b56bf) +- util (strftime): fix a bug not working with `-v var` option in Bash <= 4.1 (test-util) cb2389c (master: f1a2818) +- complete: work around slow `compgen -c` in Cygwin `#D1329` d6d49cc (master: 5327f5d) +- edit: work around problems with `mc` (reported by onelittlehope) `#D1392` 15111cf (master: e97aa07) + +## Internal + +- global: check isolated identifiers and leak variables `#D1246` 03b3204 (master: 19cc99d) 2e74b6d diff --git a/.local/share/blesh/doc/contrib/LICENSE b/.local/share/blesh/doc/contrib/LICENSE new file mode 100644 index 0000000..074fea0 --- /dev/null +++ b/.local/share/blesh/doc/contrib/LICENSE @@ -0,0 +1,28 @@ +Copyright (c) 2020-2021, K. Murase @akinomyoga , +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from this + software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. diff --git a/.local/share/blesh/doc/contrib/README-ja.md b/.local/share/blesh/doc/contrib/README-ja.md new file mode 100644 index 0000000..f827c57 --- /dev/null +++ b/.local/share/blesh/doc/contrib/README-ja.md @@ -0,0 +1,97 @@ +\[ Language: [English](README.md) | **日本語** ] + +# blesh-contrib +[akinomyoga/ble.sh](https://github.com/akinomyoga/ble.sh)向けの設定 + +特に指定のない限りこのリポジトリのファイルは [3条項 BSD ライセンス](LICENSE) で提供されます。 +サブディレクトリ `airline` 以下のファイルは MIT ライセンスで提供されます。 + +〔訳註: これは[2020年5月20日(日本標準時)時点のREADME.md](https://github.com/akinomyoga/blesh-contrib/blob/8d89d469bd46d9d1158ab5295cd48a3df6942074/README.md) (8d89d46)の,技術的内容を変更しない日本語訳です〕 + +## :pencil: fzfとの統合 + +### 選択肢その1: `~/.fzf.bash`内で設定する + +fzfを`ble.sh`と共に用いたい場合,`.fzf.bash`を次のように書き直します(`/path/to/fzf`は fzf ディレクトリへのパスに置き換えてください。※fzf バイナリではなくて **fzf ディレクトリ**へのパスです)。 + +```bash +# fzf.bash + +# fzfの設定 +# --------- + +_ble_contrib_fzf_base=/path/to/fzf +if [[ ! "$PATH" == *"$_ble_contrib_fzf_base/bin"* ]]; then + export PATH="${PATH:+${PATH}:}/path/to/fzf/bin" +fi + +# 自動補完 +# --------------- +if [[ ${BLE_VERSION-} ]]; then + ble-import -d integration/fzf-completion +else + [[ $- == *i* ]] && source "$_ble_contrib_fzf_base/shell/completion.bash" 2> /dev/null +fi + +# キー束縛 +# ------------ +if [[ ${BLE_VERSION-} ]]; then + ble-import -d integration/fzf-key-bindings +else + source "$_ble_contrib_fzf_base/shell/key-bindings.bash" +fi +``` + +### 選択肢その2: `~/.blerc`内で設定する + +別の方法として,`blerc`において次のように直接設定を書くこともできます(`/path/to/fzf`は各人のfzfへのパスに置き換えてください)。 +この場合,`.fzf.bash`を`.bashrc`の中で呼び出さ(`source`コマンドを用い)ないでください。 + +```bash +# blerc + +# fzfの設定 +_ble_contrib_fzf_base=/path/to/fzf +ble-import -d integration/fzf-completion +ble-import -d integration/fzf-key-bindings +``` + +## :pencil: fzf-git + +[fzf-git](https://gist.github.com/junegunn/8b572b8d4b5eddd8b85e5f4d40f17236)での設定を`ble.sh`と共に用いるには,次のように設定してください。 + +```bash +# bashrc / fzf.bash +if [[ ${BLE_VERSION-} ]]; then + _ble_contrib_fzf_base=/path/to/fzf + _ble_contrib_fzf_git_config=key-binding:sabbrev:arpeggio + ble-import -d integration/fzf-git +fi +``` + +または,`~/.blerc`内でも構成できます: + +```bash +# blerc +_ble_contrib_fzf_base=/path/to/fzf +_ble_contrib_fzf_git_config=key-binding:sabbrev:arpeggio +ble-import -d integration/fzf-git +``` + +シェル変数`$_ble_contrib_fzf_git_config`には,有効にする束縛の種別をコロン区切りで列挙します。 +`key-binding`という値で,次の形式のキー束縛を有効にします: C-g C-f, C-g C-b, C-g C-t, C-g C-h及びC-g C-r。 +`sabbrev`という値で,次の語に対する静的略語展開を有効にします: `gf`, `gb`, `gt`, `gh`及び`gr`。 +`arpeggio`という値で,次のキーの組み合わせを同時に押下できるようにします: g f, g b, g t, g h及びg r。 + +## :pencil: プロンプトシーケンス + +### プロンプトシーケンス `\q{contrib/vim-mode}` + +この指定はVimのモード名に展開されます。 + +```bash +# blerc(例) +ble-import contrib/prompt-vim-mode +PS1='[\u@\h \W]\q{contrib/vim-mode}\$ ' # PS1にモード名を表示 +bleopt keymap_vi_mode_show:= # モード行を表示しない +``` diff --git a/.local/share/blesh/doc/contrib/README.md b/.local/share/blesh/doc/contrib/README.md new file mode 100644 index 0000000..df7ac6b --- /dev/null +++ b/.local/share/blesh/doc/contrib/README.md @@ -0,0 +1,305 @@ +[ Languages: **English** | [日本語](README-ja.md) (Japanese) ] + +# blesh-contrib +Settings for [akinomyoga/ble.sh](https://github.com/akinomyoga/ble.sh) + +Unless otherwise specified, files in this repository are licensed by [BSD 3-clause license](LICENSE). +The files in `airline` are licensed by the MIT License. + +## :pencil: fzf integration + +Source: [`fzf-completion.bash`](https://github.com/akinomyoga/blesh-contrib/blob/master/integration/fzf-completion.bash), + [`fzf-key-bindings.bash`](https://github.com/akinomyoga/blesh-contrib/blob/master/integration/fzf-key-bindings.bash) + +Note: If you would like to integrate `fzf-completion` with `bash-completion`, `bash-completion` needs to be loaded before `fzf-completion` is loaded. + +### Option 1: Setup in `~/.fzf.bash` + +If you would like to use fzf with `ble.sh`, for example, you can rewrite your `.fzf.bash` in the following way. +In this case, `.fzf.bash` needs to be sourced after `ble.sh`. +Please replace `/path/to/fzf-directory`, `/path/to/fzf/...`, and `/path/to/bash_completion.sh` if necessary. + +```bash +# fzf.bash + +# If ble/contrib/integration/fzf cannot find the fzf directory, please set the +# following variable "_ble_contrib_fzf_base" manually. The value +# "/path/to/fzf-directory" should be replaced by a path to the fzf directory +# such as "$HOME/.fzf" or "/usr/share/fzf" that contain +# "shell/{completion,key-bindings}.bash" or "{completion,key-bindings}.bash". + +#_ble_contrib_fzf_base=/path/to/fzf-directory + +# Setup fzf +# --------- +if [[ ! "$PATH" == *"/path/to/fzf/bin"* ]]; then + export PATH="${PATH:+${PATH}:}/path/to/fzf/bin" +fi + +# Auto-completion +# --------------- +if [[ $- == *i* ]]; then + # Note: If you would like to combine fzf-completion with bash_completion, you + # need to load bash_completion earlier than fzf-completion. + + #source /path/to/bash_completion.sh + + if [[ ${BLE_VERSION-} ]]; then + ble-import -d integration/fzf-completion + else + source /path/to/fzf/shell/completion.bash 2> /dev/null + fi +fi + +# Key bindings +# ------------ +if [[ ${BLE_VERSION-} ]]; then + ble-import -d integration/fzf-key-bindings +else + source /path/to/fzf/shell/key-bindings.bash +fi +``` + +### Option 2: Setup in `~/.blerc` + +Or, you can directly write settings in your `blerc` as follows. +In this case, do not source `.fzf.bash` in your `.bashrc`. + +```bash +# blerc + +# If ble/contrib/integration/fzf cannot find the fzf directory, please set the +# following variable "_ble_contrib_fzf_base" manually. The value +# "/path/to/fzf-directory" should be replaced by a path to the fzf directory +# such as "$HOME/.fzf" or "/usr/share/fzf" that contain +# "shell/{completion,key-bindings}.bash" or "{completion,key-bindings}.bash". + +#_ble_contrib_fzf_base=/path/to/fzf-directory + + +# Note: If you would like to combine fzf-completion with bash_completion, you +# need to load bash_completion earlier than fzf-completion. + +#source /path/to/bash_completion.sh + + +# Setup fzf +ble-import -d integration/fzf-completion +ble-import -d integration/fzf-key-bindings +``` + +Note: the option `-d` for `ble-import` means the asynchronous loading of the +modules. If you need to immediately load the module, please drop the option +`-d`. For example, if the user needs to call a function defined in a module, +the module can be loaded immediately, so that the user can use the function. + +```bash +ble-import integration/fzf-completion +_fzf_setup_completion foo bar +``` + +However, in most cases, the user would probably want to reserve the execution +of the commands relying on the module by using the `-C callback` option. In +this way, the reserved command is evaluated when the module is successfully +loaded. + +```bash +ble-import -d integration/fzf-completion \ + -C '_fzf_setup_completion foo bar' +``` + +## :pencil: `integration/fzf-git` + +Source: [`fzf-git.bash`](https://github.com/akinomyoga/blesh-contrib/blob/master/integration/fzf-git.bash) + +You can use the [`junegunn/fzf-git.sh`](https://gist.github.com/junegunn/8b572b8d4b5eddd8b85e5f4d40f17236) settings for `ble.sh` with the following setup. + +```bash +# bashrc / fzf.bash +if [[ ${BLE_VERSION-} ]]; then + # If needed. See above for details: + #_ble_contrib_fzf_base=/path/to/fzf-directory + + _ble_contrib_fzf_git_config=key-binding:sabbrev:arpeggio + ble-import -d integration/fzf-git +fi +``` + +Or you can configure it in `~/.blerc`: + +```bash +# blerc + +# If needed. See above for details: +#_ble_contrib_fzf_base=/path/to/fzf-directory + +_ble_contrib_fzf_git_config=key-binding:sabbrev:arpeggio +ble-import -d integration/fzf-git +``` + +The shell variable `_ble_contrib_fzf_git_config` is a colon-separated list of the enabled types of bindings. +The value `key-binding` enables the key bindings of the form C-g C-f, C-g C-b, C-g C-t, C-g C-h, C-g C-r, and C-g C-s. +The value `sabbrev` enables the sabbrev expansion for the words `gf`, `gb`, `gt`, `gh`, `gr`, and `gs`. +The value `arpeggio` enables the simultaneous key combinations of g f, g b, g t, g h, g r, and g s. +The value `old-functions` enables old function names: `is_in_git_repo`, `fzf-down`, `gh`, `gb`, `gt`, `gh`, `gr`, and `gs`. + +# ⚙ Prompt sequences + +## :pencil: `contrib/prompt-vim-mode` + +Source: [`prompt-vim-mode.bash`](https://github.com/akinomyoga/blesh-contrib/blob/master/prompt-vim-mode.bash) + +### Prompt sequence `\q{contrib/vim-mode}` + +This prompt sequence expands to the vim mode name. + +```bash +# blerc (example) + +ble-import contrib/prompt-vim-mode +PS1='[\u@\h \W]\q{contrib/vim-mode}\$ ' # show mode name in PS1 +bleopt keymap_vi_mode_show:= # hide mode line +``` + +## :pencil: `contrib/prompt-git` + +Source: [`prompt-git.bash`](https://github.com/akinomyoga/blesh-contrib/blob/master/prompt-git.bash) + +```bash +# blerc (example) + +ble-import contrib/prompt-git +bleopt prompt_rps1='\q{contrib/git-info}' +``` + +### Prompt sequence `\q{contrib/git-info}` + +This expands to a string that explains the current git status. + +### Prompt sequence `\q{contrib/git-name}` + +This expands to the directory name of the repository. + +### Prompt sequence `\q{contrib/git-hash N}` + +This expands to the commit hash. +The hash is truncated to the length `N`. +The default value for `N` is `7`. + +### Prompt sequence `\q{contrib/git-branch}` + +This expands to the branch name (or tag name or hash) of `HEAD`. + +### Prompt sequence `\q{contrib/git-path}` + +This expands to the current path relative to the root directory of the repository. + +## :pencil: `contrib/prompt-elapsed` + +Source: [`prompt-elapsed.bash`](https://github.com/akinomyoga/blesh-contrib/blob/master/prompt-elapsed.bash) + +Measures the time of the previous command execution. + +```bash +# blerc (example) + +ble-import contrib/prompt-elapsed +bleopt prompt_rps1='\g{fg=69,italic}\q{contrib/elapsed}' +``` + +### Prompt sequence `\q{contrib/elapsed}` + +This expands to the high-resolution elapsed time for the command execution. + +### Prompt sequence `\q{contrib/elapsed-real}` + +This expands to the `real` time of `time`. + +### Prompt sequence `\q{contrib/elapsed-user}` + +This expands to the `user` time of `time`. + +### Prompt sequence `\q{contrib/elapsed-sys}` + +This expands to the `sys` time of `time`. + +### Prompt sequence `\q{contrib/elapsed-cpu}` + +This expands to the average cpu usage. + +## :pencil: colorglass + +If your terminal supports 24-bit color, you can adjust the theme colors by specifying gamma, contrast, hue rotation, etc. +This also works for the terminals without the 24-bit color support if `bleopt term_index_colors` is properly set up, but the resulting colors would be reduced to a smaller number of colors. + +```bash +ble-import contrib/colorglass + +# If your terminal does not support the 24-bit colors, please explicitly +# configure it by putting the following line: +#bleopt term_true_colors= +``` + +### Blopet colorglass_gamma + +This option specifies the change of gamma by percentage. +For example, `bleopt colorglass_gamma=5` performs the gamma correction with $\gamma=1.05$, and `bleopt colorglass_gamma=-5` performs the gamma correction with $\gamma=0.95$ + +```bash +# default +bleopt colorglass_gamma=0 +``` + +### Blopet colorglass_contrast + +This option specifies the contrast modification in the range -100..100. + +```bash +# default +bleopt colorglass_contrast=0 +``` + +### Blopet colorglass_rotate + +This option specifies the angle of hue rotation in degrees. + +```bash +# default +bleopt colorglass_rotate=0 +``` + +### Blopet colorglass_saturation + +This option specifies the change of saturation in the range -100..100. + +```bash +# default +bleopt colorglass_saturation=0 +``` + +### Blopet colorglass_brightness + +This option specifies the change of brightness in the range -100..100. + +```bash +# default +bleopt colorglass_brightness=0 +``` + +### Blopet colorglass_alpha + +This option specifies the opacity in the range 0..255 when the color is synthesized with the background color specified by `bleopt colorglass_color`. + +```bash +# defualt +bleopt colorglass_alpha=255 +``` + +### Blopet colorglass_color + +This option specifies the background color used by the color synthesis by `bleopt colorglass_alpha`. + +```bash +# defualt +bleopt colorglass_color=0x8888FF +``` diff --git a/.local/share/blesh/lib/benchmark.ksh b/.local/share/blesh/lib/benchmark.ksh new file mode 100644 index 0000000..2e52556 --- /dev/null +++ b/.local/share/blesh/lib/benchmark.ksh @@ -0,0 +1,306 @@ +#!/usr/bin/env ksh + +#!/bin/bash + +_ble_measure_target=ksh +if ! type _ble_util_print &>/dev/null; then + _ble_util_unlocal() { unset -v "$@"; } + function _ble_util_print { printf '%s\n' "$1"; } + function _ble_util_print_lines { printf '%s\n' "$@"; } +fi + +function _ble_measure__loop { + # Note: ksh requires to quote ; + eval "function _target { ${2:+"$2; "}return 0; }" + typeset __ble_i __ble_n=$1 + for ((__ble_i=0;__ble_i<__ble_n;__ble_i++)); do + _target + done +} + +## @fn _ble_measure__time n command +## @param[in] n command +## @var[out] ret +## 計測にかかった総時間を μs 単位で返します。 +if ((BASH_VERSINFO[0]>=5)) || + { [[ ${ZSH_VERSION-} ]] && zmodload zsh/datetime &>/dev/null && [[ ${EPOCHREALTIME-} ]]; } || + [[ ${SECONDS-} == *.??? ]] +then + ## @fn _ble_measure__get_realtime + ## @var[out] ret + if [[ ${EPOCHREALTIME-} ]]; then + _ble_measure_resolution=1 # [usec] + _ble_measure__get_realtime() { + typeset LC_ALL= LC_NUMERIC=C + ret=$EPOCHREALTIME + } + else + # Note: ksh does not have "local"-equivalent for the POSIX-style functions, + # so we do not set the locale here. Anyway, we do not care the + # interference with outer-scope variables since this script is used + # limitedly in ksh. + _ble_measure_resolution=1000 # [usec] + _ble_measure__get_realtime() { + ret=$SECONDS + } + fi + _ble_measure__time() { + _ble_measure__get_realtime 2>/dev/null; typeset __ble_time1=$ret + _ble_measure__loop "$1" "$2" &>/dev/null + _ble_measure__get_realtime 2>/dev/null; typeset __ble_time2=$ret + + # convert __ble_time1 and __ble_time2 to usec + # Note: ksh does not support empty index as ${__ble_frac::6}. + typeset __ble_frac + [[ $__ble_time1 == *.* ]] || __ble_time1=${__ble_time1}. + __ble_frac=${__ble_time1##*.}000000 __ble_time1=${__ble_time1%%.*}${__ble_frac:0:6} + [[ $__ble_time2 == *.* ]] || __ble_time2=${__ble_time2}. + __ble_frac=${__ble_time2##*.}000000 __ble_time2=${__ble_time2%%.*}${__ble_frac:0:6} + + ((ret=__ble_time2-__ble_time1)) + ((ret==0&&(ret=_ble_measure_resolution))) + ((ret>0)) + } +elif [[ ${ZSH_VERSION-} ]]; then + _ble_measure_resolution=1000 # [usec] + # [ksh incompatible code stripped] +else + _ble_measure_resolution=1000 # [usec] + # [ksh incompatible code stripped] +fi + +_ble_measure_base= # [nsec] +_ble_measure_base_nestcost=0 # [nsec/10] +typeset -a _ble_measure_base_real +typeset -a _ble_measure_base_guess +_ble_measure_count=1 # 同じ倍率で _ble_measure_count 回計測して最小を取る。 +_ble_measure_threshold=100000 # 一回の計測が threshold [usec] 以上になるようにする + + +## @fn _ble_measure__read_arguments_get_optarg +## @var[in] args arg i c +## @var[in,out] iarg +## @var[out] optarg +_ble_measure__read_arguments_get_optarg() { + if ((i+1<${#arg})); then + optarg=${arg:$((i+1))} + i=${#arg} + return 0 + elif ((iarg<${#args[@]})); then + optarg=${args[iarg++]} + return 0 + else + _ble_util_print "ble_measure: missing option argument for '-$c'." + flags=E$flags + return 1 + fi +} + +## @fn _ble_measure__read_arguments args +## @var[out] flags +## @var[out] command count +_ble_measure__read_arguments() { + typeset -a args; args=("$@") + typeset iarg=0 optarg= + [[ ${ZSH_VERSION-} && ! -o KSH_ARRAYS ]] && iarg=1 + while [[ ${args[iarg]} == -* ]]; do + typeset arg=${args[iarg++]} + case $arg in + (--) break ;; + (--help) flags=h$flags ;; + (--no-print-progress) flags=V$flags ;; + (--*) + _ble_util_print "ble_measure: unrecognized option '$arg'." + flags=E$flags ;; + (-?*) + typeset i= c= # Note: zsh prints the values with just "local i c" + for ((i=1;i<${#arg};i++)); do + c=${arg:$i:1} + case $c in + (q) flags=qV$flags ;; + ([ca]) + [[ $c == a ]] && flags=a$flags + _ble_measure__read_arguments_get_optarg && count=$optarg ;; + (T) + _ble_measure__read_arguments_get_optarg && + measure_threshold=$optarg ;; + (B) + _ble_measure__read_arguments_get_optarg && + __ble_base=$optarg ;; + (*) + _ble_util_print "ble_measure: unrecognized option '-$c'." + flags=E$flags ;; + esac + done ;; + (-) + _ble_util_print "ble_measure: unrecognized option '$arg'." + flags=E$flags ;; + esac + done + typeset IFS=$' \t\n' + if [[ ${ZSH_VERSION-} ]]; then + command="${args[$iarg,-1]}" + else + command="${args[*]:$iarg}" + fi + [[ $flags != *E* ]] +} + +## @fn ble_measure [-q|-ac COUNT] command +## command を繰り返し実行する事によりその実行時間を計測します。 +## -q を指定した時、計測結果を出力しません。 +## -c COUNT を指定した時 COUNT 回計測して最小値を採用します。 +## -a COUNT を指定した時 COUNT 回計測して平均値を採用します。 +## +## @var[out] ret +## 実行時間を usec 単位で返します。 +## @var[out] nsec +## 実行時間を nsec 単位で返します。 +ble_measure() { + eval -- "${_ble_bash_POSIXLY_CORRECT_local_adjust-}" + typeset __ble_level=${#FUNCNAME[@]} __ble_base= + [[ ${ZSH_VERSION-} ]] && __ble_level=${#funcstack[@]} + typeset flags= command= count=$_ble_measure_count + typeset measure_threshold=$_ble_measure_threshold + _ble_measure__read_arguments "$@"; typeset ext=$? + if ((ext)); then + eval -- "${_ble_bash_POSIXLY_CORRECT_local_leave-}" + return "$ext" + fi + + if [[ $flags == *h* ]]; then + _ble_util_print_lines \ + 'usage: ble_measure [-q|-ac COUNT|-TB TIME] [--] COMMAND' \ + ' Measure the time of command.' \ + '' \ + ' Options:' \ + ' -q Do not print results to stdout.' \ + ' -a COUNT Measure COUNT times and average.' \ + ' -c COUNT Measure COUNT times and take minimum.' \ + ' -T TIME Set minimal measuring time.' \ + ' -B BASE Set base time (overhead of ble_measure).' \ + ' -- The rest arguments are treated as command.' \ + ' --help Print this help.' \ + '' \ + ' Arguments:' \ + ' COMMAND Command to be executed repeatedly.' \ + '' \ + ' Exit status:' \ + ' Returns 1 for the failure in measuring the time. Returns 2 after printing' \ + ' help. Otherwise, returns 0.' + eval -- "${_ble_bash_POSIXLY_CORRECT_local_leave-}" + return 2 + fi + + if [[ ! $__ble_base ]]; then + if [[ $_ble_measure_base ]]; then + # ble_measure/calibrate 実行済みの時 + __ble_base=$((_ble_measure_base+_ble_measure_base_nestcost*__ble_level/10)) + else + # それ以外の時は __ble_level 毎に計測 + if [[ ! $_ble_measure_calibrate && ! ${_ble_measure_base_guess[__ble_level]} ]]; then + if [[ ! ${_ble_measure_base_real[__ble_level+1]} ]]; then + if [[ ${_ble_measure_target-} == ksh ]]; then + # Note: In ksh, we cannot do recursive call with dynamic scoping, + # so we directly call the measuring function + _ble_measure__time 50000 '' + ((nsec=ret*1000/50000)) + else + typeset _ble_measure_calibrate=1 + ble_measure -qc3 -B 0 '' + _ble_util_unlocal _ble_measure_calibrate + fi + _ble_measure_base_real[__ble_level+1]=$nsec + _ble_measure_base_guess[__ble_level+1]=$nsec + fi + + # 上の実測値は一つ上のレベル (__ble_level+1) での結果になるので現在のレベル + # (__ble_level) の値に補正する。レベル毎の時間が chatoyancy での線形フィッ + # トの結果に比例する仮定して補正を行う。 + # + # linear-fit result with $f(x) = A x + B$ in chatoyancy + # A = 65.9818 pm 2.945 (4.463%) + # B = 4356.75 pm 19.97 (0.4585%) + typeset cA=6598 cB=435675 + nsec=${_ble_measure_base_real[__ble_level+1]} + _ble_measure_base_guess[__ble_level]=$((nsec*(cB+cA*(__ble_level-1))/(cB+cA*__ble_level))) + _ble_util_unlocal cA cB + fi + __ble_base=${_ble_measure_base_guess[__ble_level]:-0} + fi + fi + + typeset __ble_max_n=500000 + typeset prev_n= prev_utot= + typeset -i n + for n in {1,10,100,1000,10000,100000}\*{1,2,5}; do + [[ $prev_n ]] && ((n/prev_n<=10 && prev_utot*n/prev_n&2 + if ! _ble_measure__time "$n" "$command"; then + eval -- "${_ble_bash_POSIXLY_CORRECT_local_leave-}" + return 1 + fi + [[ $flags != *V* ]] && printf '\r\e[2K' >&2 + ((utot=ret,utot>=measure_threshold||n==__ble_max_n)) || continue + + prev_n=$n prev_utot=$utot + typeset min_utot=$utot + + # 繰り返し計測して最小値 (-a の時は平均値) を採用 + if [[ $count ]]; then + typeset sum_utot=$utot sum_count=1 i + for ((i=2;i<=count;i++)); do + [[ $flags != *V* ]] && printf '%s' "$command (x$n $i/$count)..." >&2 + if _ble_measure__time "$n" "$command"; then + ((utot=ret,utot&2 + done + if [[ $flags == *a* ]]; then + ((utot=sum_utot/sum_count)) + else + utot=$min_utot + fi + fi + + # update base if the result is shorter than base + if ((min_utot<0x7FFFFFFFFFFFFFFF/1000)); then + typeset __ble_real=$((min_utot*1000/n)) + [[ ${_ble_measure_base_real[__ble_level]} ]] && + ((__ble_real<_ble_measure_base_real[__ble_level])) && + _ble_measure_base_real[__ble_level]=$__ble_real + [[ ${_ble_measure_base_guess[__ble_level]} ]] && + ((__ble_real<_ble_measure_base_guess[__ble_level])) && + _ble_measure_base_guess[__ble_level]=$__ble_real + ((__ble_real<__ble_base)) && + __ble_base=$__ble_real + fi + + typeset nsec0=$__ble_base + if [[ $flags != *q* ]]; then + typeset reso=$_ble_measure_resolution + typeset awk=ble/bin/awk + type -- "$awk" &>/dev/null || awk=awk + typeset -x title="$command (x$n)" + "$awk" -v utot="$utot" -v nsec0="$nsec0" -v n="$n" -v reso="$reso" ' + function genround(x, mod) { return int(x / mod + 0.5) * mod; } + BEGIN { title = ENVIRON["title"]; printf("%12.3f usec/eval: %s\n", genround(utot / n - nsec0 / 1000, reso / 10.0 / n), title); exit }' + fi + + typeset out + ((out=utot/n)) + if ((n>=1000)); then + ((nsec=utot/(n/1000))) + else + ((nsec=utot*1000/n)) + fi + ((out-=nsec0/1000,nsec-=nsec0)) + ret=$out + eval -- "${_ble_bash_POSIXLY_CORRECT_local_leave-}" + return 0 + done + eval -- "${_ble_bash_POSIXLY_CORRECT_local_return-}" +} diff --git a/.local/share/blesh/lib/core-cmdspec.sh b/.local/share/blesh/lib/core-cmdspec.sh new file mode 100644 index 0000000..b9bcb1d --- /dev/null +++ b/.local/share/blesh/lib/core-cmdspec.sh @@ -0,0 +1,170 @@ +# Copyright 2015 Koichi Murase . All rights reserved. +# This script is a part of blesh (https://github.com/akinomyoga/ble.sh) +# provided under the BSD-3-Clause license. Do not edit this file because this +# is not the original source code: Various pre-processing has been applied. +# Also, the code comments and blank lines are stripped off in the installation +# process. Please find the corresponding source file(s) in the repository +# "akinomyoga/ble.sh". +# +# Source: /lib/core-cmdspec.sh +function ble/cmdspec/initialize { return 0; } +function ble/complete/opts/initialize { + ble/cmdspec/opts mandb-disable-man:no-options : false true + ble/cmdspec/opts mandb-disable-man times + ble/cmdspec/opts mandb-disable-man:mandb-help=%'help "$command"':stop-options-postarg pwd suspend + local help_opt_help= + if ((_ble_bash>=40400)); then + help_opt_help=' --help Show help.' + ble/cmdspec/opts +mandb-help=@"$help_opt_help" times pwd suspend + fi + local help_opt_basic=$help_opt_help' + -- (indicate the end of options)' + ble/cmdspec/opts mandb-disable-man:mandb-help=%'help "$command"':mandb-help=@"$help_opt_basic":stop-options-postarg \ + alias bind cd command compgen complete compopt declare dirs disown enable \ + exec export fc getopts hash help history jobs kill mapfile popd printf \ + pushd read readonly set shopt trap type ulimit umask unalias unset wait + ble/cmdspec/opts mandb-disable-man:mandb-help=@"$help_opt_basic":stop-options-postarg . source fg bg builtin caller eval let + ble/cmdspec/opts mandb-disable-man:mandb-help=@"$help_opt_basic":stop-options-postarg break continue exit logout return shift + local conditional_operators=' + -eq (NUM1 -eq NUM2) Arithmetic comparison ==. + -ne (NUM1 -ne NUM2) Arithmetic comparison !=. + -lt (NUM1 -lt NUM2) Arithmetic comparison < . + -le (NUM1 -le NUM2) Arithmetic comparison <=. + -gt (NUM1 -gt NUM2) Arithmetic comparison > . + -ge (NUM1 -ge NUM2) Arithmetic comparison >=. + -nt (FILE1 -nt FILE2) True if file1 is newer than file2 (according to modification date). + -ot (FILE1 -ot FILE2) True if file1 is older than file2. + -ef (FILE1 -ef FILE2) True if file1 is a hard link to file2.' + ble/cmdspec/opts disable-double-hyphen:mandb-help=%'help test':mandb-help=@"$conditional_operators" '[[' + local test_operators=$conditional_operators' + -a (EXPR1 -a EXPR2) True if both expr1 AND expr2 are true. + -a (EXPR1 -o EXPR2) True if either expr1 OR expr2 is true.' + ble/cmdspec/opts disable-double-hyphen:mandb-help=%'help test':mandb-help=@"$test_operators":mandb-exclude='^--' 'test' '[' + ble/cmdspec/opts +plus-options:mandb-exclude='^[-+]N$' dirs popd pushd + local complete_flags=' + -A action The action may be one of the following to generate a list + of possible completions---alias, arrayvar, binding, + builtin, command, directory, disabled, enabled, export, + file, function, group, helptopic, hostname, job, keyword, + running, service, setopt, shopt, signal, stopped, user, + variable. + -o option Set completion option OPTION for each NAME + -a Alias names. May also be specified as `-A alias'\''. + -b Names of shell builtin commands. May also be specified as + `-A builtin'\''. + -c Command names. May also be specified as `-A command'\''. + -d Directory names. May also be specified as `-A + directory'\''. + -e Names of exported shell variables. May also be specified + as `-A export'\''. + -f File names. May also be specified as `-A file'\''. + -g Group names. May also be specified as `-A group'\''. + -j Job names, if job control is active. May also be specified + as `-A job'\''. + -k Shell reserved words. May also be specified as `-A + keyword'\''. + -s Service names. May also be specified as `-A service'\''. + -u User names. May also be specified as `-A user'\''. + -v Names of all shell variables. May also be specified as `-A + variable'\''. + -C command command is executed in a subshell environment, and its + output is used as the possible completions. Arguments are + passed as with the -F option. + -F function The shell function function is executed in the current + shell environment. When the function is executed, the + first argument ($1) is the name of the command whose + arguments are being completed, the second argument ($2) is + the word being completed, and the third argument ($3) is + the word preceding the word being completed on the current + command line. When it finishes, the possible completions + are retrieved from the value of the COMPREPLY array + variable. + -G globpat The pathname expansion pattern globpat is expanded to + generate the possible completions. + -P prefix prefix is added at the beginning of each possible + completion after all other options have been applied. + -S suffix suffix is appended to each possible completion after all + other options have been applied. + -W wordlist The wordlist is split using the characters in the IFS + special variable as delimiters, and each resultant word is + expanded. Shell quoting is honored within wordlist, in + order to provide a mechanism for the words to contain shell + metacharacters or characters in the value of IFS. The + possible completions are the members of the resultant list + which match the word being completed. + -X filterpat filterpat is a pattern as used for pathname expansion. It + is applied to the list of possible completions generated by + the preceding options and arguments, and each completion + matching filterpat is removed from the list. A leading ! + in filterpat negates the pattern; in this case, any + completion not matching filterpat is removed.' + ble/cmdspec/opts +mandb-help-usage:mandb-help=@"$complete_flags" complete compgen + ble/cmdspec/opts +plus-options=o compopt + ble/cmdspec/opts mandb-disable-man:mandb-help=%'help declare':mandb-help=@"$help_opt_basic":stop-options-postarg typeset local + ble/cmdspec/opts +plus-options=aAilnrtux declare typeset local + ble/cmdspec/opts mandb-disable-man:mandb-help=%'help echo':stop-options-unless='^-[neE]+$' echo + ble/cmdspec/opts +mandb-help=@' + -s With the `fc -s [pat=rep ...] [command]'\'' format, COMMAND + is re-executed after the substitution OLD=NEW is performed.' fc + ble/cmdspec/opts +mandb-help=@' + -x If -x is supplied, COMMAND is run after all job + specifications that appear in ARGS have been replaced with + the process ID of that job'\''s process group leader.' jobs + ble/cmdspec/opts mandb-disable-man:mandb-help=%'help mapfile':mandb-help=@"$help_opt_basic":stop-options-postarg readarray + ble/cmdspec/opts +plus-options=abefhkmnptuvxBCEHPTo set + ((_ble_bash>=40300)) && + ble/cmdspec/opts +mandb-help-usage:mandb-help=@' + -n waits for a single job from the list of IDs, or, if no IDs + are supplied, for the next job to complete and returns its + exit status.' wait + ((_ble_bash>=50000)) && + ble/cmdspec/opts +mandb-help-usage:mandb-help=@' + -f If job control is enabled, waits for the specified ID to + terminate, instead of waiting for it to change status.' wait + ((_ble_bash>=50100)) && + ble/cmdspec/opts +mandb-help-usage:mandb-help=@' + -p the process or job identifier of the job for which the exit + status is returned is assigned to the variable VAR named by + the option argument. The variable will be unset initially, + before any assignment. This is useful only when the -n + option is supplied.' wait + ble/cmdspec/opts mandb-help rsync +} +ble/complete/opts/initialize +function ble/cmdinfo/cmd:declare/chroma.wattr { + local ret + if ((wtype==_ble_attr_VAR)); then + ble/syntax:bash/find-rhs "$wtype" "$wbeg" "$wlen" element-assignment && + ble/progcolor/highlight-filename.wattr "$ret" "$wend" + else + ble/progcolor/eval-word || return "$?" + local wval=$ret + if ble/string#match "$wval" '^([_a-zA-Z][_a-zA-Z0-9]*)(\[.+\])?$'; then + local varname=${BASH_REMATCH[1]} + ble/syntax/highlight/vartype "$varname" global + ble/progcolor/wattr#setattr "$wbeg" "$ret" + ble/progcolor/wattr#setattr "$((wbeg+${#varname}))" d + elif ble/string#match "$wval" '^[-+]' && ble/progcolor/is-option-context; then + local ret; ble/color/face2g argument_option + ble/progcolor/wattr#setg "$wbeg" "$ret" + else + local ret; ble/color/face2g argument_error + ble/progcolor/wattr#setg "$wbeg" "$ret" + fi + fi + return 0 +} +function ble/cmdinfo/cmd:declare/chroma { + local i "${_ble_syntax_progcolor_vars[@]/%/=}" # WA #D1570 checked + for ((i=1;i<${#comp_words[@]};i++)); do + local ref=${tree_words[i]} + [[ $ref ]] || continue + local progcolor_iword=$i + ble/progcolor/load-word-data "$ref" + ble/progcolor/@wattr ble/cmdinfo/cmd:declare/chroma.wattr + done +} +function ble/cmdinfo/cmd:typeset/chroma { ble/cmdinfo/cmd:declare/chroma "$@"; } +function ble/cmdinfo/cmd:local/chroma { ble/cmdinfo/cmd:declare/chroma "$@"; } +function ble/cmdinfo/cmd:readonly/chroma { ble/cmdinfo/cmd:declare/chroma "$@"; } +function ble/cmdinfo/cmd:export/chroma { ble/cmdinfo/cmd:declare/chroma "$@"; } diff --git a/.local/share/blesh/lib/core-complete.sh b/.local/share/blesh/lib/core-complete.sh new file mode 100644 index 0000000..12bd0af --- /dev/null +++ b/.local/share/blesh/lib/core-complete.sh @@ -0,0 +1,7520 @@ +# Copyright 2015 Koichi Murase . All rights reserved. +# This script is a part of blesh (https://github.com/akinomyoga/ble.sh) +# provided under the BSD-3-Clause license. Do not edit this file because this +# is not the original source code: Various pre-processing has been applied. +# Also, the code comments and blank lines are stripped off in the installation +# process. Please find the corresponding source file(s) in the repository +# "akinomyoga/ble.sh". +# +# Source: /lib/core-complete.sh +ble/util/import "$_ble_base/lib/core-syntax.sh" +function ble/complete/string#search-longest-suffix-in { + local needle=$1 haystack=$2 + local l=0 u=${#needle} + while ((l0;j--)); do + ret=${rhs::j} + [[ $lhs == *"$ret" ]] && return 0 + done + ret= + fi +} +function ble/complete/string#match-patterns { + local s=$1 found= pattern; shift + for pattern; do + if [[ $s == $pattern ]]; then + return 0 + fi + done + return 1 +} +function ble/complete/get-wordbreaks { + wordbreaks=$_ble_term_IFS$COMP_WORDBREAKS + [[ $wordbreaks == *'('* ]] && wordbreaks=${wordbreaks//['()']}'()' + [[ $wordbreaks == *']'* ]] && wordbreaks=']'${wordbreaks//']'} + [[ $wordbreaks == *'-'* ]] && wordbreaks=${wordbreaks//'-'}'-' +} +_ble_complete_menu_items=() +_ble_complete_menu_class= +_ble_complete_menu_param= +_ble_complete_menu_page_style= +_ble_complete_menu_page_index= +_ble_complete_menu_page_offset= +_ble_complete_menu_page_icons=() +_ble_complete_menu_page_infodata=() +_ble_complete_menu_selected=-1 +function ble/complete/menu#check-cancel { + ((menu_iloop++%menu_interval==0)) && + [[ :$menu_construct_opts: != *:sync:* ]] && + ble/decode/has-input +} +_ble_complete_menu_style_hash= +_ble_complete_menu_style_measure=() +_ble_complete_menu_style_icons=() +_ble_complete_menu_style_pages=() +function ble/complete/menu#render-item { + if ble/is-function "$menu_class"/render-item; then + "$menu_class"/render-item "$@" + return "$?" + fi + local item=$1 opts=$2 + local sgr0=$_ble_term_sgr0 sgr1=$_ble_term_rev + [[ :$opts: == *:selected:* ]] && local sgr0=$sgr1 sgr1=$sgr0 + ble/canvas/trace-text "$item" nonewline:external-sgr + ret=$sgr0$ret$_ble_term_sgr0 +} +function ble/complete/menu#get-prefix-width { + prefix_width=0 + prefix_format=${1:-$bleopt_menu_prefix} + if [[ $prefix_format ]]; then + local prefix1 column_width=$2 + ble/util/sprintf prefix1 "$prefix_format" "${#menu_items[@]}" + local x1 y1 x2 y2 g=0 + LINES=1 COLUMNS=$column_width x=0 y=0 ble/canvas/trace "$prefix1" truncate:measure-bbox + if ((x2<=column_width/2)); then + prefix_width=$x2 + ble/string#reserve-prototype "$prefix_width" + fi + fi +} +function ble/complete/menu#render-prefix { + prefix_esc= + local index=$1 + if ((prefix_width)); then + local prefix1; ble/util/sprintf prefix1 "$prefix_format" "$((index+1))" + local x=0 y=0 g=0 + LINES=1 COLUMNS=$prefix_width ble/canvas/trace "$prefix1" truncate:relative + prefix_esc=$ret$_ble_term_sgr0 + if ((xcols&&(max_wcell=cols))) + ((wcell=bleopt_menu_align_min,wcell<2&&(wcell=2))) + local ncell=0 index=$begin + local item ret esc1 w + for item in "${menu_items[@]:begin}"; do + ble/complete/menu#check-cancel && return 148 + local wcell_old=$wcell + local w=${_ble_complete_menu_style_measure[index]%%:*} + if [[ ! $w ]]; then + local prefix_esc + ble/complete/menu#render-prefix "$index" + local x=$prefix_width y=0 + ble/complete/menu#render-item "$item"; esc1=$ret + local w=$((y*cols+x)) + _ble_complete_menu_style_measure[index]=$w:${#item},${#esc1}:$item$esc1$prefix_esc + fi + local wcell_request=$((w++,w<=max_wcell?w:max_wcell)) + ((wcell0&&x1+w>=cols)); then + ((ncell=ncell_eol+cand_ncell)) + elif ((x1+wncell_eol&&(ncell=ncell_eol))) + else + ((ncell+=cand_ncell)) + fi + else + ((ncell+=cand_ncell)) + fi + local max_ncell=$((line_ncell*lines)) + ((index&&ncell>max_ncell)) && { wcell=$wcell_old; break; } + ((index++)) + done + end=$index +} +function ble/complete/menu-style:align/construct-page { + x=0 y=0 esc= + local prefix_width prefix_format + ble/complete/menu#get-prefix-width "$bleopt_menu_align_prefix" "$bleopt_menu_align_max" + local wcell=2 + ble/complete/menu-style:align/construct/.measure-candidates-in-page + (($?==148)) && return 148 + local ncell=$((cols/wcell)) + local index=$begin entry + for entry in "${_ble_complete_menu_style_measure[@]:begin:end-begin}"; do + ble/complete/menu#check-cancel && return 148 + local w=${entry%%:*}; entry=${entry#*:} + local s=${entry%%:*}; entry=${entry#*:} + local len; ble/string#split len , "$s" + local item=${entry::len[0]} esc1=${entry:len[0]:len[1]} prefix_esc=${entry:len[0]+len[1]} + local x0=$x y0=$y + if ((x==0||x+w=lines&&(x=x0,y=y0,1))) && break + else + if [[ $menu_style == align-nowrap ]]; then + ((y+1>=lines)) && break + esc=$esc$'\n' + ((x0=x=0,y0=++y)) + ((x=w%cols,y+=w/cols)) + ((y>=lines&&(x=x0,y=y0,1))) && break + else + ((x+=prefix_width)) + ble/complete/menu#render-item "$item" || + ((begin==index)) || # [Note: 少なくとも1個ははみ出ても表示する] + { x=$x0 y=$y0; break; }; esc1=$ret + fi + fi + _ble_complete_menu_style_icons[index]=$((x0+prefix_width)),$y0,$x,$y,${#item},${#esc1}:$item$esc1 + esc=$esc$prefix_esc$esc1 + if ((++index=lines)) && break + esc=$esc$'\n' + ((x=0,++y)) + fi + fi + done + end=$index +} +function ble/complete/menu-style:align-nowrap/construct-page { + ble/complete/menu-style:align/construct-page "$@" +} +function ble/complete/menu-style:dense/construct-page { + local prefix_width prefix_format + ble/complete/menu#get-prefix-width "$bleopt_menu_dense_prefix" "$cols" + x=0 y=0 esc= + local item index=$begin N=${#menu_items[@]} + for item in "${menu_items[@]:begin}"; do + ble/complete/menu#check-cancel && return 148 + local x0=$x y0=$y + local prefix_esc esc1 + ble/complete/menu#render-prefix "$index" + ((x+=prefix_width,x>cols&&(y+=x/cols,x%=cols))) + ble/complete/menu#render-item "$item" || + ((index==begin)) || + { x=$x0 y=$y0; break; }; esc1=$ret + if [[ $menu_style == dense-nowrap ]]; then + if ((y>y0&&x>0||y>y0+1)); then + ((++y0>=lines)) && break + esc=$esc$'\n' + ((y=y0,x0=0,x=prefix_width)) + ble/complete/menu#render-item "$item" || + ((begin==index)) || + { x=$x0 y=$y0; break; }; esc1=$ret + fi + fi + local x1=$((x0+prefix_width)) y1=$y0 + ((x1>=cols)) && ((y1+=x1/cols,x1%=cols)) + _ble_complete_menu_style_icons[index]=$x1,$y1,$x,$y,${#item},${#esc1}:$item$esc1 + esc=$esc$prefix_esc$esc1 + if ((++index=lines)) && break + esc=$esc$'\n' + ((x=0,++y)) + fi + fi + done + end=$index +} +function ble/complete/menu-style:dense-nowrap/construct-page { + ble/complete/menu-style:dense/construct-page "$@" +} +function ble/complete/menu-style:linewise/construct-page { + local opts=$1 ret + local max_icon_width=$((cols-1)) + local prefix_width prefix_format + ble/complete/menu#get-prefix-width "$bleopt_menu_linewise_prefix" "$max_icon_width" + local item x0 y0 esc1 index=$begin + end=$begin x=0 y=0 esc= + for item in "${menu_items[@]:begin:lines}"; do + ble/complete/menu#check-cancel && return 148 + local prefix_esc= + ble/complete/menu#render-prefix "$index" "$max_icon_width" + esc=$esc$prefix_esc + ((x=prefix_width)) + ((x0=x,y0=y)) + local lines1=1 cols1=$max_icon_width + lines=$lines1 cols=$cols1 y=0 ble/complete/menu#render-item "$item"; esc1=$ret + _ble_complete_menu_style_icons[index]=$x0,$y0,$x,$y,${#item},${#esc1},"$x0 0 $cols1 $lines1":$item$esc1 + ((index++)) + esc=$esc$esc1 + ((y+1>=lines)) && break + ((x=0,++y)) + esc=$esc$'\n' + done + end=$index +} +function ble/complete/menu-style:linewise/guess { + ((ipage=scroll/lines, + begin=ipage*lines, + end=begin)) +} +_ble_complete_menu_desc_pageheight=() +function ble/complete/menu-style:desc/construct-page { + local opts=$1 ret + local opt_raw=; [[ $menu_style != desc-text ]] && opt_raw=1 + end=$begin esc= x=0 y=0 + local colsep=' | ' + local desc_sgr0=$'\e[m' + ble/color/face2sgr-ansi menu_desc_quote; local desc_sgrq=$ret + ble/color/face2sgr-ansi menu_desc_type; local desc_sgrt=$ret + local ncolumn=1 nline=$lines + local nrest_item=$((${#menu_items[@]}-begin)) + if [[ $bleopt_menu_desc_multicolumn_width ]]; then + ncolumn=$((cols/bleopt_menu_desc_multicolumn_width)) + if ((ncolumn<1)); then + ncolumn=1 + elif ((ncolumn>nrest_item)); then + ncolumn=$nrest_item + fi + fi + ((nline=(${#menu_items[@]}-begin+ncolumn-1)/ncolumn, + nline>lines&&(nline=lines))) + local ncolumn_max=$(((nrest_item+nline-1)/nline)) + ((ncolumn>ncolumn_max&&(ncolumn=ncolumn_max))) + local available_width=$cols + case $_ble_term_TERM in + (screen:*|tmux:*|kitty:*|contra:*) ;; + (*) ((available_width--)) ;; + esac + local wcolumn=$(((available_width-${#colsep}*(ncolumn-1))/ncolumn)) + local prefix_width prefix_format + ble/complete/menu#get-prefix-width "$bleopt_menu_desc_prefix" "$wcolumn" + ((wcolumn>=prefix_width+15)) || prefix_width=0 + local wcand_limit=$(((wcolumn-prefix_width+1)*2/3)) + ((wcand_limit<10&&(wcand_limit=wcolumn-prefix_width))) + local -a DRAW_BUFF=() + local index=$begin icolumn ymax=0 + for ((icolumn=0;icolumnmax_width&&(max_width=w))) + ble/array#push measure "$w:${#pack}:$pack$esc1" + done + local cand_width=$max_width + local desc_x=$((prefix_width+cand_width+1)); ((desc_x>wcolumn&&(desc_x=wcolumn))) + local desc_prefix=; ((wcolumn-prefix_width-desc_x>30)) && desc_prefix=': ' + local xcolumn=$((icolumn*(wcolumn+${#colsep}))) + x=0 y=0 + local entry w s pack esc1 x0 y0 pad + for entry in "${measure[@]}"; do + ble/complete/menu#check-cancel && return 148 + w=${entry%%:*} entry=${entry#*:} + s=${entry%%:*} entry=${entry#*:} + pack=${entry::s} esc1=${entry:s} + local prefix_esc + ble/complete/menu#render-prefix "$index" + ble/canvas/put.draw "$prefix_esc" + ((x+=prefix_width)) + ((x0=x,y0=y,x+=w)) + _ble_complete_menu_style_icons[index]=$((xcolumn+x0)),$y0,$((xcolumn+x)),$y,${#pack},${#esc1},"0 0 $wcand_limit 1":$pack$esc1 + ((index++)) + ble/canvas/put.draw "$esc1" + ble/canvas/put-spaces.draw "$((pad=desc_x-x))" + ble/canvas/put.draw "$desc_prefix" + ((x+=pad+${#desc_prefix})) + local desc=$desc_sgrt'(no description)'$desc_sgr0 + ble/function#try "$menu_class"/get-desc "$pack" + if [[ $opt_raw ]]; then + y=0 g=0 lc=0 lg=0 LINES=1 COLUMNS=$wcolumn ble/canvas/trace.draw "$desc" truncate:relative:ellipsis:face0=menu_desc_default + else + ble/color/face2sgr menu_desc_default + ble/canvas/put.draw "$ret" + y=0 lines=1 cols=$wcolumn ble/canvas/trace-text "$desc" nonewline + ble/canvas/put.draw "$ret" + fi + ble/canvas/put.draw "$_ble_term_sgr0" + ((y+1>=nline)) && break + ble/canvas/put-move.draw "$((-x))" 1 + ((x=0,++y)) + done + ((y>ymax)) && ymax=$y + if ((icolumn+1end)); then + ((ret=end)) + fi + return 0 +} +function ble/complete/menu-style:desc-text/construct-page { ble/complete/menu-style:desc/construct-page "$@"; } +function ble/complete/menu-style:desc-text/guess { ble/complete/menu-style:desc/guess; } +function ble/complete/menu-style:desc-text/locate { ble/complete/menu-style:desc/locate "$@"; } +function ble/complete/menu-style:desc-raw/construct-page { ble/complete/menu-style:desc/construct-page "$@"; } +function ble/complete/menu-style:desc-raw/guess { ble/complete/menu-style:desc/guess; } +function ble/complete/menu-style:desc-raw/locate { ble/complete/menu-style:desc/locate "$@"; } +function ble/complete/menu#construct/.initialize-size { + ble/edit/info/.initialize-size + local maxlines=$((bleopt_complete_menu_maxlines)) + ((maxlines>0&&lines>maxlines)) && lines=$maxlines +} +function ble/complete/menu#construct { + local menu_construct_opts=$1 + local menu_iloop=0 + local menu_interval=$bleopt_complete_polling_cycle + _ble_complete_menu_items=("${menu_items[@]}") + _ble_complete_menu_class=$menu_class + _ble_complete_menu_param=$menu_param + _ble_complete_menu_selected=-1 + local nitem=${#menu_items[@]} + if [[ :$menu_construct_opts: == *:hidden:* ]]; then + ble/array#reserve-prototype "$nitem" + _ble_complete_menu_page_style= + _ble_complete_menu_page_index= + _ble_complete_menu_page_offset= + _ble_complete_menu_page_icons=("${_ble_array_prototype[@]::nitem}") + _ble_complete_menu_page_infodata=(store 0 0 '') + return 0 + elif ((nitem==0)); then + _ble_complete_menu_page_style= + _ble_complete_menu_page_index=0 + _ble_complete_menu_page_offset=0 + _ble_complete_menu_page_icons=() + _ble_complete_menu_page_infodata=(ansi $'\e[38;5;242m(no items)\e[m') + return 0 + fi + local cols lines + ble/complete/menu#construct/.initialize-size + local hash=$nitem,$lines,$cols:$menu_style + local scroll=0 rex=':scroll=([0-9]+):' use_cache= + if [[ :$menu_construct_opts: =~ $rex ]]; then + scroll=${BASH_REMATCH[1]} + ((nitem&&(scroll%=nitem))) + [[ $hash == "$_ble_complete_menu_style_hash" ]] && use_cache=1 + fi + if [[ ! $use_cache ]]; then + _ble_complete_menu_style_measure=() + _ble_complete_menu_style_icons=() + _ble_complete_menu_style_pages=() + fi + _ble_complete_menu_style_hash=$hash + local begin=0 end=0 ipage=0 x y esc + ble/function#try ble/complete/menu-style:"$menu_style"/guess + while ((end=0&&!(visible_beg<=nsel&&nsel=0)); then + ble/complete/menu#select/.erase-item-selection.draw "$((osel-visible_beg))" + fi + local value= + if ((nsel>=0)); then + [[ :$opts: == *:goto-page-top:* ]] && nsel=$visible_beg + ble/complete/menu#select/.render-item-selection.draw "$((nsel-visible_beg))" + _ble_complete_menu_selected=$nsel + else + _ble_complete_menu_selected=-1 + value=$_ble_complete_menu_original + fi + ble/canvas/panel/load-position.draw "$pos0" + ble/canvas/bflush.draw + ble/function#try "$menu_class"/onselect "$nsel" "$osel" + return 0 +} +function ble/widget/menu/forward { + local opts=$1 + local nsel=$((_ble_complete_menu_selected+1)) + local ncand=${#_ble_complete_menu_items[@]} + if ((nsel>=ncand)); then + if [[ :$opts: == *:cyclic:* ]] && ((ncand>=2)); then + nsel=0 + else + ble/widget/.bell "menu: no more candidates" + return 1 + fi + fi + ble/complete/menu#select "$nsel" +} +function ble/widget/menu/backward { + local opts=$1 + local nsel=$((_ble_complete_menu_selected-1)) + if ((nsel<0)); then + local ncand=${#_ble_complete_menu_items[@]} + if [[ :$opts: == *:cyclic:* ]] && ((ncand>=2)); then + ((nsel=ncand-1)) + else + ble/widget/.bell "menu: no more candidates" + return 1 + fi + fi + ble/complete/menu#select "$nsel" +} +function ble/widget/menu/forward-column { + local osel=$((_ble_complete_menu_selected)) + if local ret; ble/function#try ble/complete/menu-style:"$_ble_complete_menu_page_style"/locate right "$osel"; then + local nsel=$ret ncand=${#_ble_complete_menu_items[@]} + if ((0<=nsel&&nsel=0)) || return 1 + local entry=${_ble_complete_menu_page_icons[osel-offset]} + local fields; ble/string#split fields , "${entry%%:*}" + local ox=${fields[0]} oy=${fields[1]} + local nsel=-1 + if ((oxcolumn)); then + local i=$osel + while ((--i>=offset)); do + entry=${_ble_complete_menu_page_icons[i-offset]} + ble/string#split fields , "${entry%%:*}" + local x=${fields[0]} y=${fields[1]} + ((y=0&&nsel!=osel)) && + ble/complete/menu#select "$nsel" +} +function ble/widget/menu/forward-line { + local offset=$_ble_complete_menu_page_offset + local osel=$_ble_complete_menu_selected + ((osel>=0)) || return 1 + local nsel=-1 goto_column= + if local ret; ble/function#try ble/complete/menu-style:"$_ble_complete_menu_page_style"/locate down "$osel"; then + nsel=$ret + else + local entry=${_ble_complete_menu_page_icons[osel-offset]} + local fields; ble/string#split fields , "${entry%%:*}" + local ox=${fields[0]} oy=${fields[1]} + ble/widget/menu/.check-last-column + local i=$osel nsel=-1 is_next_page= + for entry in "${_ble_complete_menu_page_icons[@]:osel+1-offset}"; do + ble/string#split fields , "${entry%%:*}" + local x=${fields[0]} y=${fields[1]} + ((y<=oy||y==oy+1&&x<=ox||nsel<0)) || break + ((++i,y>oy&&(nsel=i))) + done + ((nsel<0&&(is_next_page=1,nsel=offset+${#_ble_complete_menu_page_icons[@]}))) + ((is_next_page)) && goto_column=$ox + fi + local ncand=${#_ble_complete_menu_items[@]} + if ((0<=nsel&&nsel=0)) || return 1 + local nsel=-1 goto_column= + if local ret; ble/function#try ble/complete/menu-style:"$_ble_complete_menu_page_style"/locate up "$osel"; then + nsel=$ret + else + local entry=${_ble_complete_menu_page_icons[osel-offset]} + local fields; ble/string#split fields , "${entry%%:*}" + local ox=${fields[0]} oy=${fields[1]} + ble/widget/menu/.check-last-column + local nsel=$osel + while ((--nsel>=offset)); do + entry=${_ble_complete_menu_page_icons[nsel-offset]} + ble/string#split fields , "${entry%%:*}" + local x=${fields[0]} y=${fields[1]} + ((y0)); then + ble/complete/menu#select "$((_ble_complete_menu_page_offset-1))" goto-page-top + else + ble/widget/.bell "menu: this is the first page." + return 1 + fi +} +function ble/widget/menu/forward-page { + local next=$((_ble_complete_menu_page_offset+${#_ble_complete_menu_page_icons[@]})) + if ((next<${#_ble_complete_menu_items[@]})); then + ble/complete/menu#select "$next" + else + ble/widget/.bell "menu: this is the last page." + return 1 + fi +} +function ble/widget/menu/beginning-of-page { + ble/complete/menu#select "$_ble_complete_menu_page_offset" +} +function ble/widget/menu/end-of-page { + local nicon=${#_ble_complete_menu_page_icons[@]} + ((nicon)) && ble/complete/menu#select "$((_ble_complete_menu_page_offset+nicon-1))" +} +function ble/widget/menu/cancel { + ble/decode/keymap/pop + ble/complete/menu#clear + "$_ble_complete_menu_class"/oncancel +} +function ble/widget/menu/accept { + ble/decode/keymap/pop + ble/complete/menu#clear + local nsel=$_ble_complete_menu_selected + local hook=$_ble_complete_menu_accept_hook + _ble_complete_menu_accept_hook= + if ((nsel>=0)); then + "$_ble_complete_menu_class"/onaccept "$nsel" "${_ble_complete_menu_items[nsel]}" + else + "$_ble_complete_menu_class"/onaccept "$nsel" + fi +} +function ble-decode/keymap:menu/define { + ble-bind -f __default__ 'bell' + ble-bind -f __line_limit__ nop + ble-bind -f C-m 'menu/accept' + ble-bind -f RET 'menu/accept' + ble-bind -f C-g 'menu/cancel' + ble-bind -f 'C-x C-g' 'menu/cancel' + ble-bind -f 'C-M-g' 'menu/cancel' + ble-bind -f C-f 'menu/forward-column' + ble-bind -f right 'menu/forward-column' + ble-bind -f C-i 'menu/forward cyclic' + ble-bind -f TAB 'menu/forward cyclic' + ble-bind -f C-b 'menu/backward-column' + ble-bind -f left 'menu/backward-column' + ble-bind -f C-S-i 'menu/backward cyclic' + ble-bind -f S-TAB 'menu/backward cyclic' + ble-bind -f C-n 'menu/forward-line' + ble-bind -f down 'menu/forward-line' + ble-bind -f C-p 'menu/backward-line' + ble-bind -f up 'menu/backward-line' + ble-bind -f prior 'menu/backward-page' + ble-bind -f next 'menu/forward-page' + ble-bind -f home 'menu/beginning-of-page' + ble-bind -f end 'menu/end-of-page' +} +function ble/complete/menu.class/onaccept { + local hook=$_ble_complete_menu_accept_hook + _ble_complete_menu_accept_hook= + "$hook" "$@" +} +function ble/complete/menu.class/oncancel { + local hook=$_ble_complete_menu_cancel_hook + _ble_complete_menu_cancel_hook= + "$hook" "$@" +} +function ble/complete/menu#start { + _ble_complete_menu_accept_hook=$1; shift + _ble_complete_menu_cancel_hook= + local menu_style=linewise + local menu_items; menu_items=("$@") + local menu_class=ble/complete/menu.class menu_param= + ble/complete/menu#construct sync || return "$?" + ble/complete/menu#show + ble/complete/menu#select 0 + ble/decode/keymap/push menu + return 147 +} +function ble/complete/check-cancel { + [[ :$comp_type: != *:sync:* ]] && ble/decode/has-input +} +function ble/complete/string#escape-for-completion-context { + local str=$1 escape_flags=$2 + case $comps_flags in + (*S*) ble/string#escape-for-bash-single-quote "$str" ;; + (*E*) ble/string#escape-for-bash-escape-string "$str" ;; + (*[DI]*) ble/string#escape-for-bash-double-quote "$str" ;; + (*) + if [[ $comps_fixed ]]; then + ble/string#escape-for-bash-specialchars "$str" "b$escape_flags" + else + ble/string#escape-for-bash-specialchars "$str" "$escape_flags" + fi ;; + esac +} +function ble/complete/action/complete.addtail { + suffix=$suffix$1 +} +function ble/complete/action/complete.mark-directory { + [[ :$comp_type: == *:markdir:* && $CAND != */ ]] && + [[ ! -h $CAND || ( $insert == "$COMPS" || :$comp_type: == *:marksymdir:* ) ]] && + ble/complete/action/complete.addtail / +} +function ble/complete/action/complete.close-quotation { + case $comps_flags in + (*[SE]*) ble/complete/action/complete.addtail \' ;; + (*[DI]*) ble/complete/action/complete.addtail \" ;; + esac +} +_ble_complete_quote_insert_varnames=( + quote_action + quote_escape_flags + quote_cont_cutbackslash + quote_paramx_comps + quote_trav_prefix + quote_fixed_comps + quote_fixed_compv + quote_fixed_comps_len + quote_fixed_compv_len) +function ble/complete/action/quote-insert.initialize { + quote_action=$1 + quote_escape_flags=c + if [[ $quote_action == command ]]; then + quote_escape_flags= + elif [[ $quote_action == progcomp ]]; then + [[ $comp_opts != *:filenames:* ]] && + quote_escape_flags=${quote_escape_flags//c} + fi + [[ $comps_fixed ]] && quote_escape_flags=b$quote_escape_flags + quote_cont_cutbackslash= + [[ $comps_flags == *B* && $COMPS == *'\' ]] && + quote_cont_cutbackslash=1 + quote_paramx_comps=$COMPS + if [[ $comps_flags == *p* ]]; then + [[ $comps_flags == *B* && $quote_paramx_comps == *'\' ]] && + quote_paramx_comps=${quote_paramx_comps%'\'} + case $comps_flags in + (*[DI]*) + if [[ $COMPS =~ $rex_raw_paramx ]]; then + local rematch1=${BASH_REMATCH[1]} + quote_paramx_comps=$rematch1'${'${COMPS:${#rematch1}+1}'}' + else + quote_paramx_comps=$quote_paramx_comps'""' + fi ;; + (*) + quote_paramx_comps=$quote_paramx_comps'\' ;; + esac + fi + quote_trav_prefix= + case $comps_flags in + (*S*) quote_trav_prefix=\' ;; + (*E*) quote_trav_prefix=\$\' ;; + (*D*) quote_trav_prefix=\" ;; + (*I*) quote_trav_prefix=\$\" ;; + esac + quote_fixed_comps=('') + quote_fixed_compv=('') + quote_fixed_comps_len=('') + quote_fixed_compv_len=('') + if [[ $comps_fixed ]]; then + quote_fixed_compv=${comps_fixed#*:} + quote_fixed_compv_len=${#quote_fixed_compv} + quote_fixed_comps_len=${comps_fixed%%:*} + quote_fixed_comps=${COMPS::quote_fixed_comps_len} + fi + local i v + for ((i=1;i<${#comps_fixed[@]};i++)); do + v=${comps_fixed[i]#*:} + quote_fixed_compv[i]=$v + quote_fixed_compv_len[i]=${#v} + quote_fixed_comps_len[i]=${comps_fixed[i]%%:*} + quote_fixed_comps[i]=${COMPS::quote_fixed_comps_len[i]} + done +} +function ble/complete/action/quote-insert { + if [[ ! $quote_action ]]; then + local "${_ble_complete_quote_insert_varnames[@]/%/=}" # WA #D1570 checked + ble/complete/action/quote-insert.initialize "${1:-plain}" + fi + local escape_flags=$quote_escape_flags + if [[ $quote_action == command ]]; then + [[ $DATA == *:noquote:* || $COMPS == "$COMPV" && ( $CAND == '[[' || $CAND == '!' ) ]] && return 0 + elif [[ $quote_action == progcomp ]]; then + [[ $comp_opts == *:noquote:* ]] && return 0 + [[ $comp_opts == *:ble/syntax-raw:* && $comp_opts != *:filenames:* ]] && return 0 + [[ $comp_opts == *:nospace:* && $CAND == *' ' && ! -f $CAND ]] && return 0 + [[ $CAND == '~'* && ! ( $comp_opts == *:filenames:* && -e $CAND ) ]] && + escape_flags=T$escape_flags + fi + if [[ $comps_flags == *v* && $CAND == "$COMPV"* ]]; then + local ins ret + ble/complete/string#escape-for-completion-context "${CAND:${#COMPV}}" "$escape_flags"; ins=$ret + if [[ $comps_flags == *p* && $ins == [_a-zA-Z0-9]* ]]; then + INSERT=$quote_paramx_comps$ins + else + [[ $quote_cont_cutbackslash ]] && ins=${ins#'\'} + INSERT=$COMPS$ins; + fi + return 0 + fi + local i=${#quote_fixed_comps[@]} + while ((--i>=0)); do + if [[ ${quote_fixed_comps[i]} && $CAND == "${quote_fixed_compv[i]}"* ]]; then + local ret; ble/complete/string#escape-for-completion-context "${CAND:quote_fixed_compv_len[i]}" "$escape_flags" + INSERT=${quote_fixed_comps[i]}$quote_trav_prefix$ret + return 0 + fi + done + local ret; ble/complete/string#escape-for-completion-context "$CAND" "$escape_flags" + INSERT=$quote_trav_prefix$ret +} +function ble/complete/action/quote-insert.batch/awk { + local q=\' + local -x comp_opts=$comp_opts + local -x comps=$COMPS + local -x compv=$COMPV + local -x comps_flags=$comps_flags + local -x quote_action=$quote_action + local -x quote_escape_flags=$quote_escape_flags + local -x quote_paramx_comps=$quote_paramx_comps + local -x quote_cont_cutbackslash=$quote_cont_cutbackslash + local -x quote_trav_prefix=$quote_trav_prefix + local -x quote_fixed_count=${#quote_fixed_comps[@]} + local i + for ((i=0;i()!^*?[]/, "\\\\&", text); + if (escape_c) gsub(/[=:]/, "\\\\&", text); + if (escape_b) gsub(/[{,}]/, "\\\\&", text); + if (ret ~ /^~/ && (escape_tilde_always || escape_tilde_exists && exists(cand))) + text = "\\" text; + gsub(/\n/, "$" q REP_SL "n" q, text); + gsub(/\t/, "$" q REP_SL "t" q, text); + } + return text; + } + function quote_insert(cand, _, i) { + if (quote_action == "command") { + if (comps == compv && cand ~ /^(\[\[|]]|!)$/) return cand; + } else if (quote_action == "progcomp") { + if (is_noquote || is_syntaxraw) return cand; + if (is_nospace && cand ~ / $/ && !is_file(cand)) return cand; + } + if (comps_v && substr(cand, 1, compv_len) == compv) { + ins = escape_for_completion_context(substr(cand, compv_len + 1)); + if (comps_p && ins ~ /^[_a-zA-Z0-9]/) { + return quote_paramx_comps ins; + } else { + if (quote_cont_cutbackslash) sub(/^\\/, "", ins); + return comps ins; + } + } + for (i = quote_fixed_count; --i >= 0; ) { + if (quote_fixed_comps_len[i] && substr(cand, 1, quote_fixed_compv_len[i]) == quote_fixed_compv[i]) { + ins = substr(cand, quote_fixed_compv_len[i] + 1); + return quote_fixed_comps[i] quote_trav_prefix escape_for_completion_context(ins); + } + } + return quote_trav_prefix escape_for_completion_context(cand); + } + { + cand = substr($0, 3); + insert = quote_insert(cand); + printf("%s%c", insert, DELIM); + } + ' +} +function ble/complete/action/quote-insert.batch/proc { + local _ble_local_tmpfile; ble/util/assign/mktmp + local delim='\n' + [[ $quote_batch_nulsep ]] && delim='\0' + if [[ $quote_action == progcomp ]]; then + local cand file exist + for cand in "${cands[@]}"; do + ((cand_iloop++%bleopt_complete_polling_cycle==0)) && ble/complete/check-cancel && return 148 + f=0 e=0 + [[ -e $cand ]] && e=1 + [[ -f $cand ]] && f=1 + printf "$e$f%s$delim" "$cand" + done + else + printf "00%s$delim" "${cands[@]}" + fi >| "$_ble_local_tmpfile" + local fname_cands=$_ble_local_tmpfile + ble/util/conditional-sync \ + 'ble/complete/action/quote-insert.batch/awk < "$fname_cands"' \ + '! ble/complete/check-cancel <&"$_ble_util_fd_tui_stdin"' '' progressive-weight + local ext=$? + ble/util/assign/rmtmp + return "$ext" +} +function ble/complete/action/quote-insert.batch { + local opts=$1 + local quote_batch_nulsep= + local quote_batch_awk=ble/bin/awk + if [[ :$opts: != *:newline:* ]]; then + if ((_ble_bash>=40400)); then + if [[ $_ble_bin_awk_type == [mg]awk ]]; then + quote_batch_nulsep=1 + elif ble/bin#has mawk; then + quote_batch_nulsep=1 + quote_batch_awk=mawk + elif ble/bin#has gawk; then + quote_batch_nulsep=1 + quote_batch_awk=gawk + fi + fi + [[ ! $quote_batch_nulsep ]] && + [[ "${cands[*]}" == *$'\n'* ]] && + return 1 + fi + if [[ $quote_batch_nulsep ]]; then + ble/util/assign-array0 inserts ble/complete/action/quote-insert.batch/proc + else + ble/util/assign-array inserts ble/complete/action/quote-insert.batch/proc + fi + return "$?" +} +function ble/complete/action/requote-final-insert { + local threshold=$((bleopt_complete_requote_threshold)) + ((threshold>=0)) || return 0 + local comps_prefix= check_optarg= + if [[ $insert == "$COMPS"* ]]; then + [[ $comps_flags == *[SEDI]* ]] && return 0 + [[ $COMPS != *[!':/={,'] ]] && comps_prefix=$COMPS + check_optarg=$COMPS + else + check_optarg=$insert + fi + if [[ $check_optarg ]]; then + if ble/string#match "$check_optarg" '^([_a-zA-Z][_a-zA-Z0-9]*|-[-a-zA-Z0-9.]+)=(([^\'\''"`${}]*|\\.)*:)?'; then + comps_prefix=$BASH_REMATCH + elif [[ $COMP_PREFIX == -[!'-=:/\'\''"$`{};&|<>!^{}'] && $check_optarg == "$COMP_PREFIX"* ]]; then + comps_prefix=${check_optarg::2} + fi + fi + if [[ $comps_fixed ]]; then + local comps_fixed_part=${COMPS::${comps_fixed%%:*}} + [[ $comps_prefix == "$comps_fixed_part"* ]] || + comps_prefix=$comps_fixed_part + fi + if [[ $insert == "$comps_prefix"* && $comps_prefix != *[!':/={,'] ]]; then + local ret ins=${insert:${#comps_prefix}} + if ! ble/syntax:bash/simple-word/is-literal "$ins" && + ble/syntax:bash/simple-word/safe-eval "$ins" && + ((${#ret[@]}==1)) + then + ble/string#quote-word "$ret" quote-empty + ((${#ret}+threshold<=${#ins})) || return 0 + insert=$comps_prefix$ret + [[ $insert == "$COMPS"* ]] || insert_flags=r$insert_flags # 遡って書き換えた + fi + fi + return 0 +} +function ble/complete/action#inherit-from { + local dst=$1 src=$2 + local member srcfunc dstfunc + for member in initialize{,.batch} complete getg get-desc init-menu-item; do + srcfunc=ble/complete/action:$src/$member + dstfunc=ble/complete/action:$dst/$member + ble/is-function "$srcfunc" && builtin eval "function $dstfunc { $srcfunc \"\$@\"; }" + done +} +function ble/complete/action:plain/initialize { + ble/complete/action/quote-insert +} +function ble/complete/action:plain/initialize.batch { + ble/complete/action/quote-insert.batch +} +function ble/complete/action:plain/complete { + ble/complete/action/requote-final-insert +} +function ble/complete/action:literal-substr/initialize { return 0; } +function ble/complete/action:literal-substr/initialize.batch { inserts=("${cands[@]}"); } +function ble/complete/action:literal-substr/complete { return 0; } +function ble/complete/action:substr/initialize { + ble/complete/action/quote-insert +} +function ble/complete/action:substr/initialize.batch { + ble/complete/action/quote-insert.batch +} +function ble/complete/action:substr/complete { + ble/complete/action/requote-final-insert +} +function ble/complete/action:literal-word/initialize { return 0; } +function ble/complete/action:literal-word/initialize.batch { inserts=("${cands[@]}"); } +function ble/complete/action:literal-word/complete { + if [[ $comps_flags == *x* ]]; then + ble/complete/action/complete.addtail ',' + else + ble/complete/action/complete.addtail ' ' + fi +} +function ble/complete/action:word/initialize { + ble/complete/action/quote-insert +} +function ble/complete/action:word/initialize.batch { + ble/complete/action/quote-insert.batch +} +function ble/complete/action:word/complete { + ble/complete/action/requote-final-insert + ble/complete/action/complete.close-quotation + ble/complete/action:literal-word/complete +} +function ble/complete/action:word/get-desc { + [[ $DATA ]] && desc=$DATA +} +function ble/complete/action:file/.get-filename { + ret=$CAND + if [[ $ACTION == progcomp && :$DATA: == *:ble/syntax-raw:* && $ret == '~'* ]]; then + local tilde=${ret%%/*} chars='\ "'\''`$|&;<>()!^*?[=:{,}' + [[ $tilde == *["$chars"]* ]] && return 0 + builtin eval "local expand=$tilde" + [[ $expand == "$tilde" ]] && return 0 + ret=$expand${ret:${#tilde}} + fi +} +function ble/complete/action:file/initialize { + ble/complete/action/quote-insert +} +function ble/complete/action:file/initialize.batch { + ble/complete/action/quote-insert.batch +} +function ble/complete/action:file/complete { + local ret + ble/complete/action:file/.get-filename + if [[ -e $ret || -h $ret ]]; then + if [[ -d $ret ]]; then + ble/complete/action/requote-final-insert + ble/complete/action/complete.mark-directory + else + ble/complete/action:word/complete + fi + else + ble/complete/action:word/complete + fi +} +function ble/complete/action:file/init-menu-item { + local ret + ble/complete/action:file/.get-filename; local file=$ret + ble/syntax/highlight/getg-from-filename "$file" + [[ $g ]] || { local ret; ble/color/face2g filename_warning; g=$ret; } + if [[ :$comp_type: == *:vstat:* ]]; then + if [[ -h $file ]]; then + suffix='@' + elif [[ -d $file ]]; then + suffix='/' + elif [[ -x $file ]]; then + suffix='*' + fi + fi +} +function ble/complete/action:file_rhs/initialize { + ble/complete/action:file/initialize +} +function ble/complete/action:file_rhs/initialize.batch { + ble/complete/action:file/initialize.batch +} +function ble/complete/action:file_rhs/complete { + CAND=${CAND:${#DATA}} ble/complete/action:file/complete +} +function ble/complete/action:file_rhs/init-menu-item { + CAND=${CAND:${#DATA}} ble/complete/action:file/init-menu-item +} +_ble_complete_action_file_desc[_ble_attr_FILE_LINK]='symbolic link' +_ble_complete_action_file_desc[_ble_attr_FILE_ORPHAN]='symbolic link (orphan)' +_ble_complete_action_file_desc[_ble_attr_FILE_DIR]='directory' +_ble_complete_action_file_desc[_ble_attr_FILE_STICKY]='directory (sticky)' +_ble_complete_action_file_desc[_ble_attr_FILE_SETUID]='file (setuid)' +_ble_complete_action_file_desc[_ble_attr_FILE_SETGID]='file (setgid)' +_ble_complete_action_file_desc[_ble_attr_FILE_EXEC]='file (executable)' +_ble_complete_action_file_desc[_ble_attr_FILE_FILE]='file' +_ble_complete_action_file_desc[_ble_attr_FILE_CHR]='character device' +_ble_complete_action_file_desc[_ble_attr_FILE_FIFO]='named pipe' +_ble_complete_action_file_desc[_ble_attr_FILE_SOCK]='socket' +_ble_complete_action_file_desc[_ble_attr_FILE_BLK]='block device' +_ble_complete_action_file_desc[_ble_attr_FILE_URL]='URL' +function ble/complete/action:file/get-desc { + local type; ble/syntax/highlight/filetype "$CAND" + desc=${_ble_complete_action_file_desc[type]:-'file (???)'} +} +function ble/complete/action:progcomp/initialize/.reconstruct-from-noquote { + local simple_flags simple_ibrace ret count + ble/syntax:bash/simple-word/is-simple-or-open-simple "$INSERT" && + ble/syntax:bash/simple-word/reconstruct-incomplete-word "$INSERT" && + ble/complete/source/eval-simple-word "$ret" single:count && + ((count==1)) || return 0 + CAND=$ret + if [[ $quote_fixed_comps && $CAND == "$quote_fixed_compv"* ]]; then + local ret; ble/complete/string#escape-for-completion-context "${CAND:quote_fixed_compv_len}" "$escape_flags" + INSERT=$quote_fixed_comps$quote_trav_prefix$ret + return 3 + fi + return 0 +} +function ble/complete/action:progcomp/initialize { + if [[ :$DATA: == *:noquote:* ]]; then + local progcomp_resolve_brace=$quote_fixed_comps + [[ :$DATA: == *:ble/syntax-raw:* ]] && progcomp_resolve_brace= + ble/complete/action:progcomp/initialize/.reconstruct-from-noquote + return 0 + else + ble/complete/action/quote-insert progcomp + fi +} +function ble/complete/action:progcomp/initialize.batch { + if [[ :$DATA: == *:noquote:* ]]; then + inserts=("${cands[@]}") + local progcomp_resolve_brace=$quote_fixed_comps + [[ :$DATA: == *:ble/syntax-raw:* ]] && progcomp_resolve_brace= + cands=() + local INSERT simple_flags simple_ibrace ret count icand=0 + for INSERT in "${inserts[@]}"; do + ((cand_iloop++%bleopt_complete_polling_cycle==0)) && ble/complete/check-cancel && return 148 + local CAND=$INSERT + ble/complete/action:progcomp/initialize/.reconstruct-from-noquote || + inserts[icand]=$INSERT # INSERT を上書きした時 ($?==3) + cands[icand++]=$CAND + done + else + ble/complete/action/quote-insert.batch newline + fi +} +function ble/complete/action:progcomp/complete { + if [[ $DATA == *:filenames:* ]]; then + ble/complete/action:file/complete + else + if [[ $DATA != *:ble/no-mark-directories:* && -d $CAND ]]; then + ble/complete/action/requote-final-insert + ble/complete/action/complete.mark-directory + else + ble/complete/action:word/complete + fi + fi + [[ $DATA == *:nospace:* ]] && suffix=${suffix%' '} + [[ $DATA == *:ble/no-mark-directories:* && -d $CAND ]] && suffix=${suffix%/} +} +function ble/complete/action:progcomp/init-menu-item { + if [[ $DATA == *:filenames:* ]]; then + ble/complete/action:file/init-menu-item + fi +} +function ble/complete/action:progcomp/get-desc { + if [[ $DATA == *:filenames:* ]]; then + ble/complete/action:file/get-desc + fi +} +function ble/complete/action:command/initialize { + ble/complete/action/quote-insert command +} +function ble/complete/action:command/initialize.batch { + ble/complete/action/quote-insert.batch newline +} +function ble/complete/action:command/complete { + if [[ -d $CAND ]]; then + ble/complete/action/complete.mark-directory + elif ! ble/bin#has "$CAND"; then + if [[ $CAND == */ ]]; then + insert_flags=${insert_flags}n + fi + else + ble/complete/action:word/complete + fi +} +function ble/complete/action:command/init-menu-item { + if [[ -d $CAND ]]; then + local ret; ble/color/face2g filename_directory; g=$ret + else + local type + if [[ $CAND != "$INSERT" ]]; then + ble/syntax/highlight/cmdtype "$CAND" "$INSERT" + else + local type; ble/util/type type "$CAND" + ble/syntax/highlight/cmdtype1 "$type" "$CAND" + fi + if [[ $CAND == */ ]] && ((type==_ble_attr_ERR)); then + type=_ble_attr_CMD_FUNCTION + fi + ble/syntax/attr2g "$type" + fi +} +_ble_complete_action_command_desc[_ble_attr_CMD_BOLD]=builtin +_ble_complete_action_command_desc[_ble_attr_CMD_BUILTIN]=builtin +_ble_complete_action_command_desc[_ble_attr_CMD_ALIAS]=alias +_ble_complete_action_command_desc[_ble_attr_CMD_FUNCTION]=function +_ble_complete_action_command_desc[_ble_attr_CMD_FILE]=file +_ble_complete_action_command_desc[_ble_attr_KEYWORD]=command +_ble_complete_action_command_desc[_ble_attr_CMD_JOBS]=job +_ble_complete_action_command_desc[_ble_attr_ERR]='command ???' +_ble_complete_action_command_desc[_ble_attr_CMD_DIR]=directory +function ble/complete/action:command/get-desc { + local title= value= + if [[ -d $CAND ]]; then + title=directory + else + local type; ble/util/type type "$CAND" + ble/syntax/highlight/cmdtype1 "$type" "$CAND" + case $type in + ($_ble_attr_CMD_ALIAS) + local ret + ble/alias#expand "$CAND" + title=alias value=$ret ;; + ($_ble_attr_CMD_FILE) + local path; ble/bin#get-path "$CAND" + [[ $path == ?*/"$CAND" ]] && path="from ${path%/"$CAND"}" + title=file value=$path ;; + ($_ble_attr_CMD_FUNCTION) + local source lineno + ble/function#get-source-and-lineno "$CAND" + local def; ble/function#getdef "$CAND" + ble/string#match "$def" '^[^()]*\(\)[[:space:]]*\{[[:space:]]+(.*[^[:space:]])[[:space:]]+\}[[:space:]]*$' && + def=${BASH_REMATCH[1]} # 関数の中身を抽出する + local ret sgr0=$'\e[27m' sgr1=$'\e[7m' # Note: sgr-ansi で生成 + lines=1 cols=${COLUMNS:-80} x=0 y=0 ble/canvas/trace-text "$def" external-sgr + title=function value="${source##*/}:$lineno $desc_sgrq$ret" ;; + ($_ble_attr_CMD_JOBS) + ble/util/joblist.check + local job; ble/util/assign job 'jobs -- "$CAND" 2>/dev/null' || job='???' + title=job value=${job:-(ambiguous)} ;; + ($_ble_attr_ERR) + if [[ $CAND == */ ]]; then + title='function namespace' + else + title=${_ble_complete_action_command_desc[_ble_attr_ERR]} + fi ;; + (*) + title=${_ble_complete_action_command_desc[type]:-'???'} ;; + esac + fi + desc=${title:+$desc_sgrt($title)$desc_sgr0}${value:+ $value} +} +function ble/complete/action:variable/initialize { ble/complete/action/quote-insert; } +function ble/complete/action:variable/initialize.batch { ble/complete/action/quote-insert.batch newline; } +function ble/complete/action:variable/complete { + case $DATA in + (assignment) + ble/complete/action/complete.addtail '=' ;; + (braced) + ble/complete/action/complete.addtail '}' ;; + (word) ble/complete/action:word/complete ;; + (arithmetic|nosuffix) ;; # do nothing + esac +} +function ble/complete/action:variable/init-menu-item { + local ret; ble/color/face2g syntax_varname; g=$ret +} +function ble/complete/action:variable/get-desc { + local _ble_local_title=variable + if ble/is-array "$CAND"; then + _ble_local_title=array + elif ble/is-assoc "$CAND"; then + _ble_local_title=assoc + fi + local _ble_local_value= + if [[ $_ble_local_title == array || $_ble_local_title == assoc ]]; then + builtin eval "local count=\${#$CAND[@]}" + if ((count==0)); then + count=empty + else + count="$count items" + fi + _ble_local_value=$'\e[94m['$count$']\e[m' + else + local ret; ble/string#quote-word "${!CAND}" ansi:sgrq="$desc_sgrq":quote-empty + _ble_local_value=$ret + fi + desc="$desc_sgrt($_ble_local_title)$desc_sgr0 $_ble_local_value" +} +function ble/complete/source/test-limit { + local value=$1 limit= + if [[ :$comp_type: == *:auto_menu:* && $bleopt_complete_limit_auto_menu ]]; then + limit=$bleopt_complete_limit_auto_menu + elif [[ :$comp_type: == *:auto:* && $bleopt_complete_limit_auto ]]; then + limit=$bleopt_complete_limit_auto + else + limit=$bleopt_complete_limit + fi + if [[ $limit && value -gt limit ]]; then + cand_limit_reached=1 + [[ :$comp_type: == *:auto_menu: ]] && cand_limit_reached=cancel + return 1 + else + return 0 + fi +} +function ble/complete/source/eval-simple-word { + local word=$1 opts=$2 + if [[ :$comp_type: != *:sync:* && :$opts: != *:noglob:* ]]; then + opts=$opts:stopcheck:cached + [[ :$comp_type: == *:auto:* && $bleopt_complete_timeout_auto ]] && + opts=$opts:timeout=$((bleopt_complete_timeout_auto)) + fi + ble/syntax:bash/simple-word/eval "$word" "$opts"; local ext=$? + ((ext==142)) && return 148 + return "$ext" +} +function ble/complete/source/evaluate-path-spec { + local word=$1 sep=$2 opts=$3 + if [[ :$comp_type: != *:sync:* && :$opts: != *:noglob:* ]]; then + opts=$opts:stopcheck:cached:single + [[ :$comp_type: == *:auto:* && $bleopt_complete_timeout_auto ]] && + opts=$opts:timeout=$((bleopt_complete_timeout_auto)) + fi + ble/syntax:bash/simple-word/evaluate-path-spec "$word" "$sep" "$opts"; local ext=$? + ((ext==142)) && return 148 + return "$ext" +} +function ble/complete/source/reduce-compv-for-ambiguous-match { + [[ :$comp_type: == *:[maA]:* ]] || return 0 + local comps=$COMPS compv=$COMPV + local comps_prefix= compv_prefix= + if [[ $comps_fixed ]]; then + comps_prefix=${comps::${comps_fixed%%:*}} + compv_prefix=${comps_fixed#*:} + compv=${COMPV:${#compv_prefix}} + fi + case $comps_flags in + (*S*) comps_prefix=$comps_prefix\' ;; + (*E*) comps_prefix=$comps_prefix\$\' ;; + (*D*) comps_prefix=$comps_prefix\" ;; + (*I*) comps_prefix=$comps_prefix\$\" ;; + esac + if [[ $compv && :$comp_type: == *:a:* ]]; then + compv=${compv::1} + ble/complete/string#escape-for-completion-context "$compv" + comps=$ret + else + compv= comps= + fi + COMPV=$compv_prefix$compv + COMPS=$comps_prefix$comps +} +_ble_complete_yield_varnames=("${_ble_complete_quote_insert_varnames[@]}") +function ble/complete/cand/yield.initialize { + ble/complete/action/quote-insert.initialize "$1" +} +function ble/complete/cand/yield { + local ACTION=$1 CAND=$2 DATA=$3 + [[ $flag_force_fignore ]] && ! ble/complete/.fignore/filter "$CAND" && return 0 + [[ $flag_source_filter ]] || ble/complete/candidates/filter#test "$CAND" || return 0 + local INSERT=$CAND + ble/complete/action:"$ACTION"/initialize || return "$?" + local PREFIX_LEN=0 + [[ $CAND == "$COMP_PREFIX"* ]] && PREFIX_LEN=${#COMP_PREFIX} + local icand + ((icand=cand_count++)) + cand_cand[icand]=$CAND + cand_word[icand]=$INSERT + cand_pack[icand]=$ACTION:${#CAND},${#INSERT},$PREFIX_LEN:$CAND$INSERT$DATA +} +function ble/complete/cand/yield.batch { + local ACTION=$1 DATA=$2 + local inserts threshold=500 + [[ $OSTYPE == cygwin* || $OSTYPE == msys* ]] && threshold=2000 + if ((${#cands[@]}>=threshold)) && ble/function#try ble/complete/action:"$ACTION"/initialize.batch; then + local i n=${#cands[@]} + for ((i=0;i0)); then + ble/array#push joblist %% %+ + ((job_count>=2)) && + ble/array#push joblist %- + fi + builtin compgen -W '"${joblist[@]}"' -- "$compv_quoted" + fi +} +function ble/complete/source:command { + [[ $comps_flags == *v* ]] || return 1 + [[ ! $COMPV ]] && shopt -q no_empty_cmd_completion && return 1 + [[ $COMPV =~ ^.+/ ]] && COMP_PREFIX=${BASH_REMATCH[0]} + local arg=$1 + { + local old_cand_count=$cand_count + local comp_opts=: + ble/complete/source:argument/.generate-user-defined-completion initial; local ext=$? + ((ext==148)) && return "$ext" + if ((ext==0)); then + ((cand_count>old_cand_count)) && return "$ext" + fi + } + ble/complete/source:sabbrev + local arr + local compgen + ble/util/assign compgen 'ble/complete/source:command/gen "$arg"' + [[ $compgen ]] || return 1 + ble/util/assign-array arr 'ble/bin/sort -u <<< "$compgen"' # 1 fork/exec + ble/complete/source/test-limit "${#arr[@]}" || return 1 + local action=command "${_ble_complete_yield_varnames[@]/%/=}" # WA #D1570 checked + ble/complete/cand/yield.initialize "$action" + local is_quoted= + [[ $COMPS != "$COMPV" ]] && is_quoted=1 + local rex_keyword='^(if|then|else|elif|fi|case|esac|for|select|while|until|do|done|function|time|[!{}]|\[\[|coproc|\]\]|in)$' + local expand_aliases= + shopt -q expand_aliases && expand_aliases=1 + local cand icand=0 cands + for cand in "${arr[@]}"; do + ((cand_iloop++%bleopt_complete_polling_cycle==0)) && ble/complete/check-cancel && return 148 + [[ $cand != */ && -d $cand ]] && ! ble/bin#has "$cand" && continue + if [[ $is_quoted ]]; then + local disable_count= + [[ $cand =~ $rex_keyword ]] && ((disable_count++)) + [[ $expand_aliases ]] && ble/is-alias "$cand" && ((disable_count++)) + if [[ $disable_count ]]; then + local type; ble/util/type type "$cand" + ((${#type[@]}>disable_count)) || continue + fi + else + [[ $cand == ']]' || $cand == in ]] && + ! { [[ $expand_aliases ]] && ble/is-alias "$cand"; } && + continue + if [[ ! $expand_aliases ]]; then + ble/is-alias "$cand" && ! ble/bin#has "$cand" && continue + fi + if ble/string#match "$cand" '[][*?{,}!^~#]' && ble/is-alias "$cand"; then + ble/complete/cand/yield "$action" "$cand" :noquote: + continue + fi + fi + cands[icand++]=$cand + done + ble/complete/cand/yield.batch "$action" + local ret + if ble/complete/sabbrev/suffix.construct-regex; then + local source_file_regex=$ret + local source_file_filter=ble/complete/source:command/.is-suffix-sabbrev + ble/complete/source:file filter:action=suffix-sabbrev + fi +} +function ble/complete/util/eval-pathname-expansion/.print-def { + local pattern=$1 ret + IFS= builtin eval "ret=($pattern)" 2>/dev/null + ble/string#quote-words "${ret[@]}" + ble/util/print "ret=($ret)" +} +function ble/complete/util/eval-pathname-expansion { + local pattern=$1 + local -a dtor=() + if [[ -o noglob ]]; then + set +f + ble/array#push dtor 'set -f' + fi + if ! shopt -q nullglob; then + shopt -s nullglob + ble/array#push dtor 'shopt -u nullglob' + fi + if ! shopt -q dotglob; then + shopt -s dotglob + ble/array#push dtor 'shopt -u dotglob' + else + ble/array#push dtor 'shopt -s dotglob' + fi + if ! shopt -q extglob; then + shopt -s extglob + ble/array#push dtor 'shopt -u extglob' + fi + if [[ :$comp_type: == *:i:* ]]; then + if ! shopt -q nocaseglob; then + shopt -s nocaseglob + ble/array#push dtor 'shopt -u nocaseglob' + fi + else + if shopt -q nocaseglob; then + shopt -u nocaseglob + ble/array#push dtor 'shopt -s nocaseglob' + fi + fi + if ble/util/is-cygwin-slow-glob "$pattern"; then # Note: #D1168 + if shopt -q failglob &>/dev/null || shopt -q nullglob &>/dev/null; then + pattern= + else + set -f + ble/array#push dtor 'set +f' + fi + fi + if [[ $GLOBIGNORE ]]; then + local GLOBIGNORE_save=$GLOBIGNORE + GLOBIGNORE= + ble/array#push dtor 'GLOBIGNORE=$GLOBIGNORE_save' + fi + ble/array#reverse dtor + ret=() + if [[ :$comp_type: == *:sync:* ]]; then + IFS= builtin eval "ret=($pattern)" 2>/dev/null + else + local sync_command='ble/complete/util/eval-pathname-expansion/.print-def "$pattern"' + local sync_opts=progressive-weight + [[ :$comp_type: == *:auto:* && $bleopt_complete_timeout_auto ]] && + sync_opts=$sync_opts:timeout=$((bleopt_complete_timeout_auto)) + local def + ble/util/assign def 'ble/util/conditional-sync "$sync_command" "" "" "$sync_opts"' &>/dev/null; local ext=$? + if ((ext==148)) || ble/complete/check-cancel <&"$_ble_util_fd_tui_stdin"; then + ble/util/invoke-hook dtor + return 148 + fi + builtin eval -- "$def" + fi + ble/util/invoke-hook dtor + return 0 +} +function ble/complete/source:file/.construct-ambiguous-pathname-pattern { + local path=$1 fixlen=${2:-1} + local pattern= i=0 j + local names; ble/string#split names / "$1" + local name + for name in "${names[@]}"; do + ((i++)) && pattern=$pattern/ + if [[ $name == .. || $name == . && i -lt ${#names[@]} ]]; then + pattern=$pattern$name + elif [[ $name ]]; then + ble/string#quote-word "${name::fixlen}" + pattern=$pattern$ret* + for ((j=fixlen;j<${#name};j++)); do + ble/string#quote-word "${name:j:1}" + if [[ $_ble_bash -lt 50000 && $pattern == *\* ]]; then + pattern=$pattern'([!'$ret'])' + fi + pattern=$pattern$ret* + done + fi + done + [[ $pattern == *'*' ]] || pattern=$pattern* + ret=$pattern +} +function ble/complete/source:file/.construct-pathname-pattern { + local path=$1 pattern + case :$comp_type: in + (*:a:*) ble/complete/source:file/.construct-ambiguous-pathname-pattern "$path"; pattern=$ret ;; + (*:A:*) ble/complete/source:file/.construct-ambiguous-pathname-pattern "$path" 0; pattern=$ret ;; + (*:m:*) ble/string#quote-word "$path"; pattern=*$ret* ;; + (*) ble/string#quote-word "$path"; pattern=$ret* + esac + ret=$pattern +} +function ble/complete/source:file { + local opts=$1 + [[ $comps_flags == *v* ]] || return 1 + [[ :$comp_type: != *:[maA]:* && $COMPV =~ ^.+/ ]] && COMP_PREFIX=${BASH_REMATCH[0]} + [[ :$comp_type: == *:[maA]:* && ! $COMPV ]] && return 1 + ble/complete/source:tilde; local ext=$? + ((ext==148||ext==0)) && return "$ext" + local -a candidates=() + local ret + ble/complete/source:file/.construct-pathname-pattern "$COMPV" + [[ :$opts: == *:directory:* ]] && ret=$ret/ + ble/complete/util/eval-pathname-expansion "$ret"; (($?==148)) && return 148 + ble/complete/source/test-limit "${#ret[@]}" || return 1 + if [[ :$opts: == *:directory:* ]]; then + candidates=("${ret[@]%/}") + else + candidates=("${ret[@]}") + fi + [[ :$opts: == *:no-fd:* ]] && + ble/array#remove-by-regex candidates '^[0-9]+-?$|^-$' + [[ :$opts: == *:filter-by-regex:* ]] && + ble/array#filter-by-regex candidates "$source_file_regex" + [[ :$opts: == *:filter:* ]] && + ble/array#filter candidates "$source_file_filter" + local action=file ret= + ble/opts#extract-last-optarg "$opts" action + [[ $ret ]] && action=$ret + local flag_source_filter=1 + ble/complete/cand/yield-filenames "$action" "${candidates[@]}" +} +function ble/complete/source:dir { + ble/complete/source:file "directory:$1" +} +function ble/complete/source:rhs { ble/complete/source:file; } +function ble/complete/action:tilde/initialize { + CAND=${CAND#\~} ble/complete/action/quote-insert + INSERT=\~$INSERT + local rex='^~[^/'\''"$`\!:]*$'; [[ $INSERT =~ $rex ]] +} +function ble/complete/action:tilde/complete { + ble/complete/action/complete.mark-directory +} +function ble/complete/action:tilde/init-menu-item { + local ret + ble/color/face2g filename_directory; g=$ret +} +function ble/complete/action:tilde/get-desc { + if [[ $CAND == '~+' ]]; then + desc='current directory (tilde expansion)' + elif [[ $CAND == '~-' ]]; then + desc='previous directory (tilde expansion)' + elif local rex='^~[0-9]$'; [[ $CAND =~ $rex ]]; then + desc='DIRSTACK directory (tilde expansion)' + else + desc='user directory (tilde expansion)' + fi +} +function ble/complete/source:tilde/.generate { + local pattern=${COMPS#\~} + [[ :$comp_type: == *:[maA]:* ]] && pattern= + builtin compgen -P \~ -u -- "$pattern" + printf '%s\n' '~' '~+' '~-' + local dirstack_max=$((${#DIRSTACK[@]}-1)) + ((dirstack_max>=0)) && + builtin eval "printf '%s\n' '~'{0..$dirstack_max}" +} +function ble/complete/source:tilde { + local rex='^~[^/'\''"$`\!:]*$'; [[ $COMPS =~ $rex ]] || return 1 + local compgen candidates + ble/util/assign compgen ble/complete/source:tilde/.generate + [[ $compgen ]] || return 1 + ble/util/assign-array candidates 'ble/bin/sort -u <<< "$compgen"' + local flag_source_filter=1 + if [[ $COMPS == '~'?* ]]; then + local filter_type=$comp_filter_type + [[ $filter_type == none ]] && filter_type=head + local comp_filter_type + local comp_filter_pattern + ble/complete/candidates/filter#init "$filter_type" "$COMPS" + ble/array#filter candidates ble/complete/candidates/filter#test + fi + ((${#candidates[@]})) || return 1 + local old_cand_count=$cand_count + ble/complete/cand/yield-filenames tilde "${candidates[@]}"; local ext=$? + return "$((ext?ext:cand_count>old_cand_count))" +} +function ble/complete/source:fd { + [[ $comp_filter_type == none ]] && + local comp_filter_type=head + local old_cand_count=$cand_count + local action=word "${_ble_complete_yield_varnames[@]/%/=}" # WA #D1570 checked + ble/complete/cand/yield.initialize "$action" + ble/complete/cand/yield "$action" - + if [[ -d /proc/self/fd ]]; then + local ret + ble/complete/util/eval-pathname-expansion '/proc/self/fd/*' + local fd + for fd in "${ret[@]}"; do + fd=${fd#/proc/self/fd/} + [[ ${fd//[0-9]} ]] && continue + ble/fd#is-cloexit "$fd" && continue + ble/complete/cand/yield "$action" "$fd" + ble/complete/cand/yield "$action" "$fd-" + done + else + local fd + for ((fd=0;fd<10;fd++)); do + ble/fd#is-open "$fd" || continue + ble/complete/cand/yield "$action" "$fd" + ble/complete/cand/yield "$action" "$fd-" + done + fi + return "$((cand_count>old_cand_count))" +} +function ble/complete/progcomp/.compvar-initialize-wordbreaks { + local ifs=$_ble_term_IFS q=\'\" delim=';&|<>()' glob='[*?' hist='!^{' esc='`$\' + local escaped=$ifs$q$delim$glob$hist$esc + wordbreaks=${COMP_WORDBREAKS//[$escaped]} # =: +} +function ble/complete/progcomp/.compvar-perform-wordbreaks { + local word=$1 + if [[ ! $word ]]; then + ret=('') + return 0 + fi + ret=() + while local head=${word%%["$wordbreaks"]*}; [[ $head != $word ]]; do + ble/array#push ret "$head" + word=${word:${#head}} + head=${word%%[!"$wordbreaks"]*} + ble/array#push ret "$head" + word=${word:${#head}} + done + ble/array#push ret "$word" +} +function ble/complete/progcomp/.compvar-eval-word { + local opts=$2:single + if [[ :$opts: == *:noglob:* ]]; then + ble/syntax:bash/simple-word/eval "$1" "$opts" + else + [[ $bleopt_complete_timeout_compvar ]] && + opts=timeout=$((bleopt_complete_timeout_compvar)):retry-noglob-on-timeout:$opts + ble/complete/source/eval-simple-word "$1" "$opts" + fi +} +function ble/complete/progcomp/.compvar-generate-subwords/impl1 { + local word=$1 ret simple_flags simple_ibrace + if [[ $point ]]; then + local left=${word::point} right=${word:point} + else + local left=$word right= + local point= # hide + fi + ble/syntax:bash/simple-word/reconstruct-incomplete-word "$left" || return 1 + left=$ret + if [[ $right ]]; then + case $simple_flags in + (*I*) right=\$\"$right ;; + (*D*) right=\"$right ;; + (*E*) right=\$\'$right ;; + (*S*) right=\'$right ;; + (*B*) right=\\$right ;; + esac + ble/syntax:bash/simple-word/reconstruct-incomplete-word "$right" || return 1 + right=$ret + fi + point=0 words=() + local eval_opts=noglob + ((${#ret[@]}==1)) && eval_opts= + ble/syntax:bash/simple-word#break-word "$left" "$wordbreaks" + local subword + for subword in "${ret[@]}"; do + ble/complete/progcomp/.compvar-eval-word "$subword" "$eval_opts" + ble/array#push words "$ret" + ((point+=${#ret})) + done + if [[ $right ]]; then + ble/syntax:bash/simple-word#break-word "$right" "$wordbreaks" + local subword isfirst=1 + for subword in "${ret[@]}"; do + ble/complete/progcomp/.compvar-eval-word "$subword" noglob + if [[ $isfirst ]]; then + isfirst= + local iword=${#words[@]}; ((iword&&iword--)) + words[iword]=${words[iword]}$ret + else + ble/array#push words "$ret" + fi + done + fi + return 0 +} +function ble/complete/progcomp/.compvar-generate-subwords/impl2 { + local word=$1 + ble/syntax:bash/simple-word/reconstruct-incomplete-word "$word" || return 1 + ble/complete/progcomp/.compvar-eval-word "$ret"; (($?==148)) && return 148; local value1=$ret + if [[ $point ]]; then + if ((point==${#word})); then + point=${#value1} + elif ble/syntax:bash/simple-word/reconstruct-incomplete-word "${word::point}"; then + ble/complete/progcomp/.compvar-eval-word "$ret"; (($?==148)) && return 148 + point=${#ret} + fi + fi + ble/complete/progcomp/.compvar-perform-wordbreaks "$value1"; words=("${ret[@]}") + return 0 +} +function ble/complete/progcomp/.compvar-generate-subwords { + local word1=$1 ret simple_flags simple_ibrace + if [[ ! $word1 ]]; then + subword_flags=E + words=('') + elif [[ $word1 == '~' ]]; then + subword_flags=Q + words=('~') + elif ble/complete/progcomp/.compvar-generate-subwords/impl1 "$word1"; then + subword_flags=E + elif ble/complete/progcomp/.compvar-generate-subwords/impl2 "$word1"; then + subword_flags=E + else + ble/complete/progcomp/.compvar-perform-wordbreaks "$word1"; words=("${ret[@]}") + fi +} +function ble/complete/progcomp/.compvar-quote-subword { + local word=$1 to_quote= is_evaluated= is_quoted= + if [[ $subword_flags == *[EQ]* ]]; then + [[ $subword_flags == *E* ]] && to_quote=1 + elif ble/syntax:bash/simple-word/reconstruct-incomplete-word "$word"; then + is_evaluated=1 + ble/complete/progcomp/.compvar-eval-word "$ret"; (($?==148)) && return 148; word=$ret + to_quote=1 + fi + if [[ $to_quote ]]; then + local shell_specialchars=']\ ["'\''`$|&;<>()*?{}!^'$'\n\t' q="'" Q="'\''" qq="''" + if ((index>0)) && [[ $word == *["$shell_specialchars"]* || $word == [#~]* ]]; then + is_quoted=1 + word="'${w//$q/$Q}'" word=${word#"$qq"} word=${word%"$qq"} + fi + fi + if [[ $p && $word != "$1" ]]; then + if ((p==${#1})); then + p=${#word} + else + local left=${word::p} + if [[ $is_evaluated ]]; then + if ble/syntax:bash/simple-word/reconstruct-incomplete-word "$left"; then + ble/complete/progcomp/.compvar-eval-word "$ret"; (($?==148)) && return 148; left=$ret + fi + fi + if [[ $is_quoted ]]; then + left="'${left//$q/$Q}" left=${left#"$qq"} + fi + p=${#left} + fi + fi + ret=$word +} +builtin unset -v _ble_complete_progcomp_cur_wordbreaks +_ble_complete_progcomp_cur_rex_simple= +_ble_complete_progcomp_cur_rex_break= +function ble/complete/progcomp/.compvar-reduce-cur { + if [[ ! ${_ble_complete_progcomp_cur_wordbreaks+set} || $COMP_WORDBREAKS != "$_ble_complete_progcomp_cur_wordbreaks" ]]; then + _ble_complete_progcomp_cur_wordbreaks=$COMP_WORDBREAKS + _ble_complete_progcomp_cur_rex_simple='^([^\"'\'']|\\.|"([^\"]|\\.)*"|'\''[^'\'']*'\'')*' + local chars=${COMP_WORDBREAKS//[\'\"]/} rex_break= + [[ $chars == *\\* ]] && chars=${chars//\\/} rex_break='\\(.|$)' + [[ $chars == *\$* ]] && chars=${chars//\$/} rex_break+=${rex_break:+'|'}'\$([^$'\'${rex_break:+\\}']|$)' + if [[ $chars == '^' ]]; then + rex_break+=${rex_break:+'|'}'\^' + elif [[ $chars ]]; then + [[ $chars == ?*']'* ]] && chars=']'${chars//']'/} + [[ $chars == '^'* ]] && chars=${chars:1}${chars::1} + [[ $chars == *'-'*? ]] && chars=${chars//'-'/}'-' + rex_break+=${rex_break:+'|'}[$chars] + fi + _ble_complete_progcomp_cur_rex_break='^([^\"'\''$]|\$*\\.|\$*"([^\"]|\\.)*"|'\''[^'\'']*'\''|\$+'\''([^'\''\]|\\.)*'\''|\$+([^'\'']|$))*\$*('${rex_break:-'^$'}')' + fi + cur=$1 + if [[ $cur =~ $_ble_complete_progcomp_cur_rex_simple && ${cur:${#BASH_REMATCH}} == [\'\"]* ]]; then + cur=${cur:${#BASH_REMATCH}+1} + elif [[ $cur =~ $_ble_complete_progcomp_cur_rex_break ]]; then + cur=${cur:${#BASH_REMATCH}} + case ${BASH_REMATCH[5]} in (\$*|@|\\?) cur=${BASH_REMATCH[5]#\\}$cur ;; esac + fi +} +function ble/complete/progcomp/.compvar-initialize { + COMP_TYPE=9 + COMP_KEY=9 + ((${#KEYS[@]})) && COMP_KEY=${KEYS[${#KEYS[@]}-1]:-9} # KEYS defined in ble-decode/widget/.call-keyseq + local wordbreaks + ble/complete/progcomp/.compvar-initialize-wordbreaks + progcomp_prefix= + COMP_CWORD= + COMP_POINT= + COMP_LINE= + COMP_WORDS=() + cmd=${comp_words[0]} + cur= prev= + local ret simple_flags simple_ibrace + local word1 index=0 offset=0 sep= + for word1 in "${comp_words[@]}"; do + local offset_dst=${#COMP_LINE} + local point=$((comp_point-offset)) + ((0<=point&&point<=${#word1})) || point= + ((offset+=${#word1})) + local words subword_flags= + ble/complete/progcomp/.compvar-generate-subwords "$word1" + local w wq i=0 o=0 p + for w in "${words[@]}"; do + p= + if [[ $point ]]; then + ((p=point-o)) + ((i%2==0?p<=${#w}:p<${#w})) || p= + ((o+=${#w},i++)) + fi + [[ $p ]] && point= + [[ $point ]] && progcomp_prefix=$progcomp_prefix$w + ble/complete/progcomp/.compvar-quote-subword "$w"; local wq=$ret + if [[ $p ]]; then + COMP_CWORD=${#COMP_WORDS[*]} + ((COMP_POINT=${#COMP_LINE}+${#sep}+p)) + ble/complete/progcomp/.compvar-reduce-cur "${COMP_LINE:offset_dst}${wq::p}" + prev=${COMP_WORDS[COMP_CWORD-1]} + fi + ble/array#push COMP_WORDS "$wq" + COMP_LINE=$COMP_LINE$sep$wq + sep= + done + sep=' ' + ((offset++)) + ((index++)) + done +} +function ble/complete/progcomp/.compgen-helper-prog { + if [[ $comp_prog ]]; then + local COMP_WORDS COMP_CWORD cmd cur prev + local -x COMP_LINE COMP_POINT COMP_TYPE COMP_KEY + ble/complete/progcomp/.compvar-initialize + if [[ $comp_opts == *:ble/prog-trim:* ]]; then + local compreply + ble/util/assign compreply '"$comp_prog" "$cmd" "$cur" "$prev" < /dev/null' + ble/bin/sed "s/[[:space:]]\{1,\}\$//" <<< "$compreply" + else + "$comp_prog" "$cmd" "$cur" "$prev" < /dev/null + fi + fi +} +function ble/complete/progcomp/compopt/.error { + if ((_ble_bash>=40000&&$#>=2)); then + builtin compopt "${@:2}" + else + ble/util/print "ble.sh: compopt: $1" >&2 + fi + has_error=1 +} +function ble/complete/progcomp/compopt/.enable { + if [[ $1 == ble/no-default ]]; then + ble/complete/progcomp/compopt/.disable ble/default + return "$?" + elif [[ ! $1 || $1 == *:* ]]; then + ble/complete/progcomp/compopt/.error "$1: invalid option name" -o "$1" + return "$?" + fi + ble/array#push ospec "-$1" + ble/array#push compopt_args -o "$1" +} +function ble/complete/progcomp/compopt/.disable { + if [[ $1 == ble/no-default ]]; then + ble/complete/progcomp/compopt/.enable ble/default + return "$?" + elif [[ ! $1 || $1 == *:* ]]; then + ble/complete/progcomp/compopt/.error "$1: invalid option name" +o "$1" + return "$?" + fi + ble/array#push ospec "+$1" + ble/array#push compopt_args +o "$1" +} +function ble/complete/progcomp/compopt/.read-arguments { + ospec=() has_cmd= compopt_args=() + local has_error= has_stop= has_help= + while (($#)); do + local arg=$1; shift + if [[ $arg == [-+]?* && ! $has_stop ]]; then + case $arg in + (--?*) + case $arg in + (--help) has_help=1 ;; + (*) + ble/complete/progcomp/compopt/.error "unrecognized long option '$arg'" ;; + esac ;; + (--) has_stop=1 ;; + (-*) + arg=${arg:1} + while [[ $arg ]]; do + local c=${arg::1} + arg=${arg:1} + case $c in + (o) + if [[ ! $arg ]]; then + if (($#)); then + arg=$1; shift + else + ble/complete/progcomp/compopt/.error '-o: option requires an argument' -o + break 2 + fi + fi + ble/complete/progcomp/compopt/.enable "$arg" + arg= ;; + ([DEI]) + ble/array#push compopt_args "-$c" + has_cmd=1 ;; + (*) + ble/complete/progcomp/compopt/.error "-$c: invalid option" "-$c" ;; + esac + done ;; + (+o) + arg=${arg:2} + if [[ ! $arg ]]; then + if (($#)); then + arg=$1; shift + else + ble/complete/progcomp/compopt/.error '+o: option requires an argument' +o + break + fi + fi + ble/complete/progcomp/compopt/.disable "$arg" ;; + (*) + ble/complete/progcomp/compopt/.error "$arg: invalid option" "$arg" ;; + esac + else + ble/array#push compopt_args "$arg" + has_cmd=1 + has_stop=1 # Bash's compopt stops parsing options on any name + fi + done + if [[ $has_error ]]; then + return 2 + elif [[ $has_help ]]; then + if ((_ble_bash>=40000)); then + builtin help compopt + else + ble/util/print-lines \ + 'compopt: compopt [-o|+o option] [-DEI] [name ...]' \ + ' Modify or display completion options.' '' >&2 + fi + return 2 + fi + return 0 +} +function ble/complete/progcomp/compopt { + local ospec has_cmd compopt_args + ble/complete/progcomp/compopt/.read-arguments "$@" || return 2 + if ((${#ospec[@]})); then + local s + for s in "${ospec[@]}"; do + case $s in + (-*) comp_opts=${comp_opts//:"${s:1}":/:}${s:1}: ;; + (+*) comp_opts=${comp_opts//:"${s:1}":/:} ;; + esac + done + elif [[ $has_cmd ]]; then + builtin compopt "${compopt_args[@]}" + else + local option options out='compopt' + ble/string#split options : "${comp_opts%:}" + "${_ble_util_set_declare[@]//NAME/mark}" # WA #D1570 checked + ble/set#add mark '' + for option in "${options[@]}"; do + ble/set#contains mark "$option" && continue + ble/set#add mark "$option" + out="$out -o $option" + done + ble/util/print "$out" + fi +} +function ble/complete/progcomp/.check-limits { + ((cand_iloop++%bleopt_complete_polling_cycle==0)) && + [[ ! -t 0 ]] && ble/complete/check-cancel <&"$_ble_util_fd_tui_stdin" && + return 148 + ble/complete/source/test-limit "$((progcomp_read_count++))" + return "$?" +} +function ble/complete/progcomp/.compgen-helper-func { + [[ $comp_func ]] || return 1 + local -a COMP_WORDS + local COMP_LINE COMP_POINT COMP_CWORD COMP_TYPE COMP_KEY cmd cur prev + ble/complete/progcomp/.compvar-initialize + local progcomp_read_count=0 + local _ble_builtin_read_hook='ble/complete/progcomp/.check-limits || { ble/bash/read "$@" < /dev/null; return 148; }' + ble/function#push compopt 'ble/complete/progcomp/compopt "$@"' + ble/function#push ssh ' + local IFS=$_ble_term_IFS + if [[ " ${FUNCNAME[*]} " == *" ble/complete/progcomp/.compgen "* ]]; then + local -a args; args=("$@") + ble/util/conditional-sync "exec ssh \"\${args[@]}\"" \ + "! ble/complete/check-cancel <&$_ble_util_fd_tui_stdin" 128 progressive-weight:killall + else + ble/function#push/call-top "$@" + fi' + ble/function#push command_not_found_handle + builtin eval '"$comp_func" "$cmd" "$cur" "$prev"' < /dev/null >&"$_ble_util_fd_tui_stdout" 2>&"$_ble_util_fd_tui_stderr"; local ret=$? + ble/function#pop command_not_found_handle + ble/function#pop ssh + ble/function#pop compopt + [[ $ret == 124 ]] && progcomp_retry=1 + return 0 +} +function ble/complete/progcomp/.parse-complete/next { + if [[ $compdef =~ $rex ]]; then + builtin eval "arg=$BASH_REMATCH" + compdef=${compdef:${#BASH_REMATCH}} + return 0 + elif [[ ${compdef%%' '*} ]]; then + arg=${compdef%%' '*} + compdef=${compdef#*' '} + return 0 + else + return 1 + fi +} +function ble/complete/progcomp/.parse-complete/optarg { + optarg= + if ((ic+1<${#arg})); then + optarg=${arg:ic+1} + ic=${#arg} + return 0 + elif [[ $compdef =~ $rex ]]; then + builtin eval "optarg=$BASH_REMATCH" + compdef=${compdef:${#BASH_REMATCH}} + return 0 + else + return 2 + fi +} +function ble/complete/progcomp/.parse-complete { + compoptions=() + comp_prog= + comp_func= + flag_noquote= + local compdef=${1#'complete '} + local arg optarg rex='^([^][*?;&|[:space:]<>()\`$"'\''{}#^!]|\\.|'\''[^'\'']*'\'')+[[:space:]]+' # #D1709 safe (WA gawk 4.0.2) + while ble/complete/progcomp/.parse-complete/next; do + case $arg in + (-*) + local ic c + for ((ic=1;ic<${#arg};ic++)); do + c=${arg:ic:1} + case $c in + ([abcdefgjksuvE]) + case $c in + (c) flag_noquote=1 ;; + (d) ((_ble_bash>=40300)) && flag_noquote=1 ;; + (f) ((40000<=_ble_bash&&_ble_bash<40200)) && flag_noquote=1 ;; + esac + ble/array#push compoptions "-$c" ;; + ([pr]) + ;; # 無視 (-p 表示 -r 削除) + ([AGWXPS]) + ble/complete/progcomp/.parse-complete/optarg || break 2 + if [[ $c == A ]]; then + case $optarg in + (command) flag_noquote=1 ;; + (directory) ((_ble_bash>=40300)) && flag_noquote=1 ;; + (file) ((40000<=_ble_bash&&_ble_bash<40200)) && flag_noquote=1 ;; + esac + fi + ble/array#push compoptions "-$c" "$optarg" ;; + (o) + ble/complete/progcomp/.parse-complete/optarg || break 2 + comp_opts=${comp_opts//:"$optarg":/:}$optarg: + ble/array#push compoptions "-$c" "$optarg" ;; + (C) + if ((_ble_bash<40000)); then + comp_prog=${compdef%' '} + compdef= + else + ble/complete/progcomp/.parse-complete/optarg || break 2 + comp_prog=$optarg + fi + ble/array#push compoptions "-$c" ble/complete/progcomp/.compgen-helper-prog ;; + (F) + if ((_ble_bash<40000)) && [[ $compdef == *' -C '* ]]; then + comp_prog=${compdef#*' -C '} + comp_prog=${comp_prog%' '} + ble/array#push compoptions '-C' ble/complete/progcomp/.compgen-helper-prog + comp_func=${compdef%%' -C '*} + else + comp_func=${compdef%' '} + ((_ble_bash>=50200)) && builtin eval "comp_func=($comp_func)" + fi + compdef= + ble/array#push compoptions "-$c" ble/complete/progcomp/.compgen-helper-func ;; + (*) + esac + done ;; + (*) + ;; # 無視 + esac + done +} +function ble/complete/progcomp/.filter-and-split-compgen { + flag_mandb= + local sed_script= + { + if [[ $comp_opts == *:ble/filter-by-prefix:* ]]; then + local ret; ble/string#escape-for-sed-regex "$COMPV"; local rex_compv=$ret + sed_script='!/^'$rex_compv'/d' + fi + [[ $use_workaround_for_git ]] && + sed_script=${sed_script:+$sed_script;}'s/[[:space:]]\{1,\}$//' + } + local out= + [[ $sed_script ]] && ble/util/assign out 'ble/bin/sed "$sed_script;/^\$/d" <<< "$compgen"' + [[ $out ]] || out=$compgen + local require_awk= + if [[ $comp_opts != *:nosort:* ]]; then + ble/util/assign out 'ble/bin/sort -u <<< "$out"' + else + require_awk=1 # for uniq + fi + local -a args_mandb=() + if [[ $comp_cword -gt 0 && $COMPV != [!-]* ]]; then + local cmd=$compcmd + if [[ $cmd == _DefaultCmD_ || $cmd == _InitialWorD_ || $cmd == -[DI] ]]; then + cmd=${comp_words[0]} + local ret + ble/syntax:bash/simple-word/safe-eval "$cmd" nonull && cmd=$ret + fi + local man_page=${cmd##*/} + if [[ $man_page == git ]]; then + local isubcmd + for ((isubcmd=1;isubcmd 0) + entry = substr(entry, 1, RLENGTH - 2) "=" substr(entry, RLENGTH); + if (name2index[name] != "") { + if (length(display) <= length(name2display[name])) return; + name2display[name] = display; + entries[name2index[name]] = entry; + } else { + name2index[name] = mandb_count; + name2display[name] = display; + entries[mandb_count++] = entry; + } + } + !hash[$0]++ { + if (/^$/) next; + name = $0 + sub(/(=)$/, "", name); + if (mandb[name]) { + register_mandb_entry(name, $0, mandb[name]); + next; + } else if (sub(/^--no-/, "--", name)) { + if ((entry = mandb[name]) || (entry = mandb[substr(name, 2)])) { + split(entry, record, FS); + if ((desc = record[4])) { + desc = "\033[1mReverse[\033[m " desc " \033[;1m]\033[m"; + if (match($0, /['"$_ble_term_space"']*[:=[]/)) { + option = substr($0, 1, RSTART - 1); + optarg = substr($0, RSTART); + suffix = substr($0, RSTART, 1); + if (suffix == "[") suffix = ""; + } else { + option = $0; + optarg = ""; + suffix = " "; + } + register_mandb_entry(name, $0, option FS optarg FS suffix FS desc); + } + next; + } + } + print $0; + } + END { + if (mandb_count) { + for (i = 0; i < mandb_count; i++) + print entries[i]; + exit 10; + } + } + ' + ble/util/assign-array "$1" 'ble/bin/awk -F "$_ble_term_FS" "$awk_script" "${args_mandb[@]}" mode=compgen - <<< "$out"' + (($?==10)) && flag_mandb=1 + else + ble/string#split-lines "$1" "$out" + fi + return 0 +} 2>/dev/null +function ble/complete/progcomp/patch:bash-completion/_comp_cmd_make.advice { + if [[ ${BLE_ATTACHED-} ]]; then + ble/function#push "${ADVICE_WORDS[1]}" ' + local -a make_args; make_args=("${ADVICE_WORDS[1]}" "$@") + ble/util/conditional-sync \ + '\''command "${make_args[@]}"'\'' \ + "! ble/complete/check-cancel <&$_ble_util_fd_tui_stdin" 128 progressive-weight:killall' + ble/function#advice/do + ble/function#pop "${ADVICE_WORDS[1]}" + else + ble/function#advice/do + fi +} +function ble/complete/progcomp/patch:cobraV2/extract_activeHelp.patch { + local cobra_version=$1 + if ((cobra_version<10500)); then + local -a completions + completions=("${out[@]}") + fi + local prefix=$cur + [[ $comps_flags == *v* ]] && prefix=$COMPV + local unprocessed has_desc= + unprocessed=() + local lines line cand desc + for lines in "${out[@]}"; do + ble/string#split-lines lines "$lines" + for line in "${lines[@]}"; do + if [[ $line == *$'\t'* ]]; then + cand=${line%%$'\t'*} + desc=${line#*$'\t'} + [[ $cand == "$prefix"* ]] || continue + ble/complete/cand/yield word "$cand" "$desc" + has_desc=1 + elif [[ $line ]]; then + ble/array#push unprocessed "$line" + fi + done + done + [[ $has_desc ]] && bleopt complete_menu_style=desc + if ((${#unprocessed[@]})); then + if ((cobra_version>=10500)); then + completions=("${unprocessed[@]}") + else + out=("${unprocessed[@]}") + fi + ble/function#advice/do + fi +} +function ble/complete/progcomp/patch:cobraV2/get_completion_results.advice { + local -a orig_words + orig_words=("${words[@]}") + local -a words + words=(ble/complete/progcomp/patch:cobraV2/get_completion_results.invoke "${orig_words[@]:1}") + ble/function#advice/do +} +function ble/complete/progcomp/patch:cobraV2/get_completion_results.invoke { + local -a invoke_args; invoke_args=("$@") + ble/util/conditional-sync \ + "${orig_words[0]} \"\${invoke_args[@]}\"" \ + "! ble/complete/check-cancel <&$_ble_util_fd_tui_stdin" 128 progressive-weight:killall +} +function ble/complete/progcomp/call-by-conditional-sync { + ble/is-function "$1" || return 0 + ble/function#advice around "$1" ' + ble/util/conditional-sync \ + ble/function#advice/do \ + "! ble/complete/check-cancel <&$_ble_util_fd_tui_stdin" 128 progressive-weight:killall' +} +function ble/complete/progcomp/.compgen { + local opts=$1 + local compcmd= is_special_completion= + local -a alias_args=() + if [[ :$opts: == *:initial:* ]]; then + if ((_ble_bash>=50000)); then + is_special_completion=1 + compcmd='-I' + else + compcmd=_InitialWorD_ + fi + elif [[ :$opts: == *:default:* ]]; then + if ((_ble_bash>=40100)); then + builtin complete -p -D &>/dev/null || return 1 + is_special_completion=1 + compcmd='-D' + else + builtin complete -p _DefaultCmD_ &>/dev/null || return 1 + compcmd=_DefaultCmD_ + fi + else + compcmd=${cmd:-${comp_words[0]}} + fi + local compdef + if [[ $is_special_completion ]]; then + ble/util/assign compdef 'builtin complete -p "$compcmd" 2>/dev/null' + elif ble/syntax:bash/simple-word/is-simple "$compcmd"; then + ble/util/assign compdef "builtin complete -p -- $compcmd 2>/dev/null" + local ret; ble/syntax:bash/simple-word/eval "$compcmd"; compcmd=$ret + else + ble/util/assign compdef 'builtin complete -p -- "$compcmd" 2>/dev/null' + fi + compdef=${compdef%"${compcmd:-''}"} + compdef=${compdef%' '}' ' + local comp_prog comp_func compoptions flag_noquote + ble/complete/progcomp/.parse-complete "$compdef" + local comp_opts_parsed=$comp_opts + if [[ $comp_func ]]; then + [[ $comp_func == _fzf_* ]] && + ble-import -f contrib/integration/fzf-completion + if ble/is-function _comp_initialize; then + ble/complete/mandb:bash-completion/inject + elif ble/is-function _quote_readline_by_ref; then + function _quote_readline_by_ref { + if [[ $1 == \'* ]]; then + printf -v "$2" %s "${1:1}" + else + printf -v "$2" %q "$1" + [[ ${!2} == \$* ]] && builtin eval "$2=${!2}" + fi + } + ble/function#suppress-stderr _filedir 2>/dev/null + ble/function#suppress-stderr _find 2>/dev/null + ble/function#suppress-stderr _scp_remote_files 2>/dev/null + ble/function#suppress-stderr _function 2>/dev/null + ble/complete/mandb:bash-completion/inject + fi + if [[ $comp_func == _make || $comp_func == _comp_cmd_make ]] && ble/is-function "$comp_func"; then + ble/function#advice around "$comp_func" ble/complete/progcomp/patch:bash-completion/_comp_cmd_make.advice + fi + if [[ $comp_func == __start_* ]]; then + local target=__${comp_func#__start_}_handle_completion_types + if ble/is-function "$target"; then + local cobra_version= + if ble/is-function "__${comp_func#__start_}_extract_activeHelp"; then + cobra_version=10500 # v1.5.0 (Release 2022-06-21) + fi + ble/function#advice around "$target" "ble/complete/progcomp/patch:cobraV2/extract_activeHelp.patch $cobra_version" + fi + local target=__${comp_func#__start_}_get_completion_results + if ble/is-function "$target"; then + ble/function#advice around "$target" ble/complete/progcomp/patch:cobraV2/get_completion_results.advice + fi + fi + [[ $comp_func == _dnf ]] && + ble/complete/progcomp/call-by-conditional-sync _dnf_commands_helper + if [[ $comp_func == _z || $comp_func == __zoxide_z_complete ]]; then + ble-import -f contrib/integration/zoxide + ble/contrib/integration:zoxide/adjust + fi + if [[ $comp_func == _complete_nix ]]; then + ble-import -f integration/nix-completion + ble/contrib/integration:nix-completion/adjust + fi + ble/function#suppress-stderr _adb 2>/dev/null + [[ $comp_func == _docker ]] && + ble/complete/progcomp/call-by-conditional-sync __docker_q + [[ $comp_func == _docker_compose ]] && + ble/complete/progcomp/call-by-conditional-sync __docker_compose_q + fi + if [[ $comp_prog ]]; then + if [[ $comp_prog == aws_completer ]]; then + comp_opts=${comp_opts}ble/no-mark-directories:ble/prog-trim: + fi + fi + ble/complete/check-cancel && return 148 + local compgen compgen_compv=$COMPV + if [[ ! $flag_noquote && :$comp_opts: != *:noquote:* ]]; then + local q="'" Q="'\''" + compgen_compv="'${compgen_compv//$q/$Q}'" + fi + local progcomp_prefix= progcomp_retry= + IFS=$IFS word= ble/util/assign compgen 'builtin compgen "${compoptions[@]}" -- "$compgen_compv" 2>/dev/null' + if [[ $progcomp_retry && ! $_ble_complete_retry_guard ]]; then + local _ble_complete_retry_guard=1 + opts=:$opts: + opts=${opts//:default:/:} + ble/complete/progcomp/.compgen "$opts" + return "$?" + fi + if [[ $comp_opts_parsed != *:plusdirs:* && $comp_opts == *:plusdirs:* ]]; then + local compgen_plusdirs= + ble/util/assign compgen_plusdirs 'builtin compgen -o plusdirs -- "$compgen_compv" 2>/dev/null' + [[ $compgen_plusdirs ]] && compgen=$compgen$'\n'$compgen_plusdirs + fi + [[ $compgen ]] || return 1 + local use_workaround_for_git= + if [[ $comp_func == __git* && $comp_opts == *:nospace:* ]]; then + use_workaround_for_git=1 + ble/string#match "$compgen" $'(^|\n|[^[:space:]])(\n|$)' || + comp_opts=${comp_opts//:nospace:/:} + fi + local cands flag_mandb= + ble/complete/progcomp/.filter-and-split-compgen cands # compgen (comp_opts, etc) -> cands, flag_mandb + ble/complete/source/test-limit "${#cands[@]}" || return 1 + if [[ $comp_opts == *:filenames:* ]]; then + if [[ $comp_opts == *:ble/syntax-raw:* ]]; then + [[ $COMPS == */* ]] && COMP_PREFIX=${COMPS%/*}/ + else + [[ $COMPV == */* ]] && COMP_PREFIX=${COMPV%/*}/ + fi + fi + local old_cand_count=$cand_count + local action=progcomp "${_ble_complete_yield_varnames[@]/%/=}" # WA #D1570 checked + ble/complete/cand/yield.initialize "$action" + if [[ $flag_mandb ]]; then + local -a entries; entries=("${cands[@]}") + cands=() + local fs=$_ble_term_FS has_desc= icand=0 entry + for entry in "${entries[@]}"; do + ((cand_iloop++%bleopt_complete_polling_cycle==0)) && ble/complete/check-cancel && return 148 + if [[ $entry == -*"$fs"*"$fs"*"$fs"* ]]; then + local cand=${entry%%"$fs"*} + ble/complete/cand/yield mandb "$cand" "$entry" + [[ $entry == *"$fs"*"$fs"*"$fs"?* ]] && has_desc=1 + else + cands[icand++]=$progcomp_prefix$entry + fi + done + [[ $has_desc ]] && bleopt complete_menu_style=desc + else + [[ $progcomp_prefix ]] && + if ((_ble_bash>=40300)) && ! shopt -q compat42; then + cands=("${cands[@]/#/"$progcomp_prefix"}") # WA #D1570 #D1751 checked + else + cands=("${cands[@]/#/$progcomp_prefix}") # WA #D1570 #D1738 checked + fi + fi + ble/complete/cand/yield.batch "$action" "$comp_opts" + ((cand_count>old_cand_count)) +} +function ble/complete/progcomp/.compline-rewrite-command { + local ocmd=${comp_words[0]} + [[ $1 != "$ocmd" ]] || (($#>=2)) || return 1 + local IFS=$_ble_term_IFS + local ins="$*" + if (($#==0)); then + local ret; ble/string#ltrim "${comp_line:${#ocmd}}" + ((comp_point-=${#comp_line}-${#ret})) + comp_line=$ret + else + comp_line=$ins${comp_line:${#ocmd}} + ((comp_point-=${#ocmd})) + fi + ((comp_point<0&&(comp_point=0),comp_point+=${#ins})) + comp_words=("$@" "${comp_words[@]:1}") + ((comp_cword&&(comp_cword+=$#-1))) +} +function ble/complete/progcomp/.split-alias-words { + local tail=$1 + local rex_redir='^'$_ble_syntax_bash_RexRedirect + local rex_word='^'$_ble_syntax_bash_simple_rex_element'+' + local rex_delim=$'^[\n;|&]' + local rex_spaces=$'^[ \t]+' + local rex_misc='^[<>()]+' + local -a words=() + while [[ $tail ]]; do + if [[ $tail =~ $rex_redir && $tail != ['<>']'('* ]]; then + ble/array#push words "$BASH_REMATCH" + tail=${tail:${#BASH_REMATCH}} + elif [[ $tail =~ $rex_word ]]; then + local w=$BASH_REMATCH + tail=${tail:${#w}} + if [[ $tail && $tail != ["$_ble_term_IFS;|&<>()"]* ]]; then + local s=${tail%%["$_ble_term_IFS"]*} + tail=${tail:${#s}} + w=$w$s + fi + ble/array#push words "$w" + elif [[ $tail =~ $rex_delim ]]; then + words=() + tail=${tail:${#BASH_REMATCH}} + elif [[ $tail =~ $rex_spaces ]]; then + tail=${tail:${#BASH_REMATCH}} + elif [[ $tail =~ $rex_misc ]]; then + ble/array#push words "$BASH_REMATCH" + tail=${tail:${#BASH_REMATCH}} + else + local w=${tail%%["$_ble_term_IFS"]*} + ble/array#push words "$w" + tail=${tail:${#w}} + fi + done + local i=0 rex_assign='^[_a-zA-Z0-9]+(\['$_ble_syntax_bash_simple_rex_element'*\])?\+?=' + while ((i<${#words[@]})); do + if [[ ${words[i]} =~ $rex_assign ]]; then + ((i++)) + elif [[ ${words[i]} =~ $rex_redir && ${words[i]} != ['<>']'('* ]]; then + ((i+=2)) + else + break + fi + done + ret=("${words[@]:i}") +} +function ble/complete/progcomp/.try-load-completion { + if ble/is-function _comp_load; then + ble/function#push command_not_found_handle + _comp_load -- "$1" < /dev/null &>/dev/null; local ext=$? + ble/function#pop command_not_found_handle + elif ble/is-function __load_completion; then + ble/function#push command_not_found_handle + __load_completion "$1" < /dev/null &>/dev/null; local ext=$? + ble/function#pop command_not_found_handle + else + return 1 + fi + ((ext==0)) || return "$ext" + builtin complete -p -- "$1" &>/dev/null +} +function ble/complete/progcomp { + local cmd=${1-${comp_words[0]}} opts=$2 + local orig_comp_words orig_comp_cword=$comp_cword orig_comp_line=$comp_line orig_comp_point=$comp_point + orig_comp_words=("${comp_words[@]}") + local comp_words comp_cword=$comp_cword comp_line=$comp_line comp_point=$comp_point + comp_words=("${orig_comp_words[@]}") + [[ $cmd == "${orig_comp_words[0]}" ]] || + ble/complete/progcomp/.compline-rewrite-command "$cmd" + local orig_qcmds_set= + local -a orig_qcmds=() + local -a alias_args=() + [[ :$opts: == *:__recursive__:* ]] || + local alias_checked=' ' + while :; do + local ret ucmd qcmds + ucmd=$cmd qcmds=("$cmd") + if ble/syntax:bash/simple-word/is-simple "$cmd"; then + if ble/syntax:bash/simple-word/eval "$cmd" noglob && + [[ $ret != "$cmd" || ${#ret[@]} -ne 1 ]]; then + ucmd=${ret[0]} qcmds=() + local word + for word in "${ret[@]}"; do + ble/string#quote-word "$word" quote-empty + ble/array#push qcmds "$ret" + done + else + ble/string#quote-word "$cmd" quote-empty + qcmds=("$ret") + fi + [[ $cmd == "${orig_comp_words[0]}" ]] && + orig_qcmds_set=1 orig_qcmds=("${qcmds[@]}") + fi + if ble/is-function "ble/cmdinfo/complete:$ucmd"; then + ble/complete/progcomp/.compline-rewrite-command "${qcmds[@]}" "${alias_args[@]}" + "ble/cmdinfo/complete:$ucmd" "$opts" + return "$?" + elif [[ $ucmd == */?* ]] && ble/is-function "ble/cmdinfo/complete:${ucmd##*/}"; then + ble/string#quote-word "${ucmd##*/}"; qcmds[0]=$ret + ble/complete/progcomp/.compline-rewrite-command "${qcmds[@]}" "${alias_args[@]}" + "ble/cmdinfo/complete:${ucmd##*/}" "$opts" + return "$?" + elif builtin complete -p -- "$ucmd" &>/dev/null; then + cmd=$ucmd + ble/complete/progcomp/.compline-rewrite-command "${qcmds[@]}" "${alias_args[@]}" + ble/complete/progcomp/.compgen "$opts" + return "$?" + elif [[ $ucmd == */?* ]] && builtin complete -p -- "${ucmd##*/}" &>/dev/null; then + cmd=${ucmd##*/} + ble/string#quote-word "$ucmd"; qcmds[0]=$ret + ble/complete/progcomp/.compline-rewrite-command "${qcmds[@]}" "${alias_args[@]}" + ble/complete/progcomp/.compgen "$opts" + return "$?" + elif ble/complete/progcomp/.try-load-completion "${ucmd##*/}"; then + cmd=${ucmd##*/} + ble/string#quote-word "$ucmd"; qcmds[0]=$ret + ble/complete/progcomp/.compline-rewrite-command "${qcmds[@]}" "${alias_args[@]}" + ble/complete/progcomp/.compgen "$opts" + return "$?" + fi + alias_checked=$alias_checked$cmd' ' + ((_ble_bash<50000)) || shopt -q progcomp_alias || break + local ret + ble/alias#expand "$cmd" + [[ $ret == "$cmd" ]] && break + ble/complete/progcomp/.split-alias-words "$ret" + if ((${#ret[@]}==0)); then + ble/complete/progcomp/.compline-rewrite-command "${alias_args[@]}" + if ((${#comp_words[@]})); then + if ((comp_cword==0)); then + ble/complete/source:command + else + ble/complete/progcomp "${comp_words[0]}" "__recursive__:$opts" + fi + fi + return "$?" + fi + [[ $alias_checked != *" $ret "* ]] || break + cmd=$ret + ((${#ret[@]}>=2)) && + alias_args=("${ret[@]:1}" "${alias_args[@]}") + done + comp_words=("${orig_comp_words[@]}") + comp_cword=$orig_comp_cword + comp_line=$orig_comp_line + comp_point=$orig_comp_point + [[ $orig_qcmds_set ]] && + ble/complete/progcomp/.compline-rewrite-command "${orig_qcmds[@]}" + ble/complete/progcomp/.compgen "default:$opts" +} +_ble_complete_option_chars='_!#$%&:;.,^~|\\?\/*a-zA-Z0-9@' +function ble/complete/action:mandb/initialize { + ble/complete/action/quote-insert +} +function ble/complete/action:mandb/initialize.batch { + ble/complete/action/quote-insert.batch newline +} +function ble/complete/action:mandb/complete { + ble/complete/action/complete.close-quotation + local fields + ble/string#split fields "$_ble_term_FS" "$DATA" + local tail=${fields[2]} + [[ $tail == ' ' && $comps_flags == *x* ]] && tail=',' + ble/complete/action/complete.addtail "$tail" +} +function ble/complete/action:mandb/init-menu-item { + local ret; ble/color/face2g argument_option; g=$ret + local fields + ble/string#split fields "$_ble_term_FS" "$DATA" + suffix=${fields[1]} +} +function ble/complete/action:mandb/get-desc { + local fields + ble/string#split fields "$_ble_term_FS" "$DATA" + desc=${fields[3]} +} +function ble/complete/mandb/load-mandb-conf { + [[ -s $1 ]] || return 0 + local line words + while ble/bash/read line || [[ $line ]]; do + ble/string#split-words words "${line%%'#'*}" + case ${words[0]} in + (MANDATORY_MANPATH) + [[ -d ${words[1]} ]] && + ble/array#push manpath_mandatory "${words[1]}" ;; + (MANPATH_MAP) + ble/dict#set manpath_map "${words[1]}" "${words[2]}" ;; + esac + done < "$1" +} +_ble_complete_mandb_default_manpath=() +function ble/complete/mandb/initialize-manpath { + ((${#_ble_complete_mandb_default_manpath[@]})) && return 0 + local manpath + MANPATH= ble/util/assign manpath 'manpath || ble/bin/man -w' 2>/dev/null + ble/string#split manpath : "$manpath" + if ((${#manpath[@]}==0)); then + local -a manpath_mandatory=() + builtin eval -- "${_ble_util_dict_declare//NAME/manpath_map}" + ble/complete/mandb/load-mandb-conf /etc/man_db.conf + ble/complete/mandb/load-mandb-conf ~/.manpath + if ((${#manpath_mandatory[@]}==0)); then + local ret + ble/complete/util/eval-pathname-expansion '~/*/share/man' + ble/array#push manpath_mandatory "${ret[@]}" + ble/complete/util/eval-pathname-expansion '~/@(opt|.opt)/*/share/man' + ble/array#push manpath_mandatory "${ret[@]}" + for ret in /usr/local/share/man /usr/local/man /usr/share/man; do + [[ -d $ret ]] && ble/array#push manpath_mandatory "$ret" + done + fi + builtin eval -- "${_ble_util_dict_declare//NAME/mark}" + local paths path ret + ble/string#split paths : "$PATH" + for path in "${paths[@]}"; do + [[ -d $path ]] || continue + [[ $path == *?/ ]] && path=${path%/} + if ble/dict#get manpath_map "$path"; then + path=$ret + else + path=${path%/bin}/share/man + fi + if [[ -d $path ]] && ! ble/set#contains mark "$path"; then + ble/set#add mark "$path" + ble/array#push manpath "$path" + fi + done + for path in "${manpath_mandatory[@]}"; do + if [[ -d $path ]] && ! ble/set#contains mark "$path"; then + ble/set#add mark "$path" + ble/array#push manpath "$path" + fi + done + fi + _ble_complete_mandb_default_manpath=("${manpath[@]}") +} +function ble/complete/mandb/search-file/.extract-path { + local command=$1 + [[ $_ble_complete_mandb_lang ]] && + local LC_ALL=$$_ble_complete_mandb_lang + ble/util/assign path 'ble/bin/man -w "$command"' 2>/dev/null +} +ble/function#suppress-stderr ble/complete/mandb/search-file/.extract-path +function ble/complete/mandb/search-file/.check { + local path=$1 + if [[ $path && -s $path ]]; then + ret=$path + return 0 + else + return 1 + fi +} +function ble/complete/mandb/search-file { + local command=$1 + local path + ble/complete/mandb/search-file/.extract-path "$command" + ble/complete/mandb/search-file/.check "$path" && return 0 + ble/string#split ret : "$MANPATH" + ((${#ret[@]})) || ret=('') + local -a manpath=() + for path in "${ret[@]}"; do + if [[ $path ]]; then + ble/array#push manpath "$path" + else + ble/complete/mandb/initialize-manpath + ble/array#push manpath "${_ble_complete_mandb_default_manpath[@]}" + fi + done + local path + for path in "${manpath[@]}"; do + [[ -d $path ]] || continue + ble/complete/mandb/search-file/.check "$path/man1/$command.1" && return 0 + ble/complete/mandb/search-file/.check "$path/man1/$command.8" && return 0 + if ble/is-function ble/bin/gzip; then + ble/complete/mandb/search-file/.check "$path/man1/$command.1.gz" && return 0 + ble/complete/mandb/search-file/.check "$path/man1/$command.8.gz" && return 0 + fi + if ble/is-function ble/bin/bzcat; then + ble/complete/mandb/search-file/.check "$path/man1/$command.1.bz" && return 0 + ble/complete/mandb/search-file/.check "$path/man1/$command.1.bz2" && return 0 + ble/complete/mandb/search-file/.check "$path/man1/$command.8.bz" && return 0 + ble/complete/mandb/search-file/.check "$path/man1/$command.8.bz2" && return 0 + fi + if ble/is-function ble/bin/xzcat; then + ble/complete/mandb/search-file/.check "$path/man1/$command.1.xz" && return 0 + ble/complete/mandb/search-file/.check "$path/man1/$command.8.xz" && return 0 + fi + if ble/is-function ble/bin/lzcat; then + ble/complete/mandb/search-file/.check "$path/man1/$command.1.lzma" && return 0 + ble/complete/mandb/search-file/.check "$path/man1/$command.8.lzma" && return 0 + fi + done + return 1 +} +if ble/bin#freeze-utility-path preconv; then + function ble/complete/mandb/.preconv { ble/bin/preconv; } +else + function ble/complete/mandb/.preconv { + ble/bin/od -A n -t u1 -v | ble/bin/awk ' + BEGIN { + ECHAR = 65533; # U+FFFD + byte = 0; + for (i = 0; byte < 128; byte++) { mtable[byte] = 0; vtable[byte] = i++; } + for (i = 0; byte < 192; byte++) { mtable[byte] = 0; vtable[byte] = ECHAR; } + for (i = 0; byte < 224; byte++) { mtable[byte] = 1; vtable[byte] = i++; } + for (i = 0; byte < 240; byte++) { mtable[byte] = 2; vtable[byte] = i++; } + for (i = 0; byte < 248; byte++) { mtable[byte] = 3; vtable[byte] = i++; } + for (i = 0; byte < 252; byte++) { mtable[byte] = 4; vtable[byte] = i++; } + for (i = 0; byte < 254; byte++) { mtable[byte] = 5; vtable[byte] = i++; } + for (i = 0; byte < 256; byte++) { mtable[byte] = 0; vtable[byte] = ECHAR; } + M = 0; C = 0; + } + function put_uchar(uchar) { + if (uchar < 128) + printf("%c", uchar); + else + printf("\\[u%04X]", uchar); + } + function process_byte(byte) { + if (M) { + if (128 <= byte && byte < 192) { + C = C * 64 + byte % 64; + if (--M == 0) put_uchar(C); + return; + } else { + put_uchar(ECHAR); + M = 0; + } + } + M = mtable[byte]; + C = vtable[byte]; + if (M == 0) put_uchar(C); + } + { for (i = 1; i <= NF; i++) process_byte($i); } + ' + } +fi +_ble_complete_mandb_lang= +if ble/is-function ble/bin/groff; then + _ble_complete_mandb_convert_type=man + function ble/complete/mandb/convert-mandoc { + if [[ $_ble_util_locale_encoding == UTF-8 ]]; then + ble/bin/groff -k -Tutf8 -man + else + ble/bin/groff -Tascii -man + fi + } + if [[ $OSTYPE == darwin* ]] && ! ble/bin/groff -k -Tutf8 -man &>/dev/null <<< 'α'; then + if ble/bin/groff -T utf8 -m man &>/dev/null <<< '\[u03B1]'; then + function ble/complete/mandb/convert-mandoc { + if [[ $_ble_util_locale_encoding == UTF-8 ]]; then + ble/complete/mandb/.preconv | ble/bin/groff -T utf8 -m man + else + ble/bin/groff -T ascii -m man + fi + } + else + _ble_complete_mandb_lang=C + function ble/complete/mandb/convert-mandoc { + ble/bin/groff -T ascii -m man + } + fi + fi +elif ble/is-function ble/bin/nroff; then + _ble_complete_mandb_convert_type=man + function ble/complete/mandb/convert-mandoc { + if [[ $_ble_util_locale_encoding == UTF-8 ]]; then + ble/bin/nroff -Tutf8 -man + else + ble/bin/nroff -Tascii -man + fi + } +elif ble/is-function ble/bin/mandoc; then + _ble_complete_mandb_convert_type=mdoc + function ble/complete/mandb/convert-mandoc { + ble/bin/mandoc -mdoc + } +fi +function ble/complete/mandb/.generate-cache-from-man { + ble/is-function ble/bin/man && + ble/is-function ble/complete/mandb/convert-mandoc || return 1 + local command=$1 + local ret + ble/complete/mandb/search-file "$command" || return 1 + local LC_ALL= LC_COLLATE=C 2>/dev/null + local path=$ret + case $ret in + (*.gz) ble/bin/gzip -cd "$path" ;; + (*.bz|*.bz2) ble/bin/bzcat "$path" ;; + (*.lzma) ble/bin/lzcat "$path" ;; + (*.xz) ble/bin/xzcat "$path" ;; + (*) ble/bin/cat "$path" ;; + esac | ble/bin/awk -v type="$_ble_complete_mandb_convert_type" ' + BEGIN { + g_keys_count = 0; + g_desc = ""; + if (type == "man") { + print ".TH __ble_ignore__ 1 __ble_ignore__ __ble_ignore__"; + print ".ll 9999" + topic_start = ".TP"; + } + mode = "begin"; + fmt3_state = ""; + fmt5_state = ""; + fmt6_state = ""; + } + function output_pair(key, desc) { + print ""; + print "__ble_key__"; + if (topic_start != "") print topic_start; + print key; + print ""; + print "__ble_desc__"; + print ""; + print desc; + } + function all_flush(_, i) { + stage_flush(); + fmt3_flush(); + fmt5_flush(); + fmt6_flush(); + } + function all_reset() { + g_keys_count = 0; + g_desc = ""; + mode = "none"; + prev_line = ""; + fmt3_state = ""; + fmt5_state = ""; + fmt6_state = ""; + } + mode == "begin" && /^\.(Dd|Nm)['"$_ble_term_space"']/ { + if (type == "man" && /^\.Dd['"$_ble_term_space"']+\$Mdoc/) topic_start = ""; + print $0; + } + function stage_key(key) { + g_keys[g_keys_count++] = key; + g_desc = ""; + } + function stage_desc(desc) { + if (g_desc != "") g_desc = g_desc "\n"; + g_desc = g_desc desc; + } + function stage_flush() { + if (g_keys_count == 0) return; + for (i = 0; i < g_keys_count; i++) + output_pair(g_keys[i], g_desc); + g_keys_count = 0; + g_desc = ""; + mode = "none"; + } + /^\.ig/ { mode = "ignore"; next; } + mode == "ignore" { + if (/^\.\.['"$_ble_term_space"']*/) mode = "none"; + next; + } + { + sub(/['"$_ble_term_space"']+$/, ""); + REQ = match($0, /^\.[_a-zA-Z0-9]+/) ? substr($0, 2, RLENGTH - 1) : ""; + } + REQ ~ /^(S[Ss]|S[Hh]|Pp)$/ { all_flush(); next; } + function fmt7_check_start() { + if (prev_line == "") return 0; + if (g_keys_count || mode !~ /^(begin|none)$/) return 0; + if (fmt3_state != "") return 0; + if (fmt5_state !~ /^$|^key$/) return 0; + if (fmt6_state != "") return 0; + fmt5_state = "desc"; + fmt5_key = prev_line; + fmt5_desc = ""; + return 1; + } + REQ == "RS" && fmt7_check_start() { next; } + REQ == "PP" { + all_flush(); + fmt5_state = "key"; + fmt5_key = ""; + fmt5_desc = ""; + next; + } + fmt5_state { + if (fmt5_state == "key") { + if (/^\.RS([^_a-zA-Z0-9]|$)/) + fmt5_state = "desc"; + else if (/^\.RE([^_a-zA-Z0-9]|$)/) + fmt5_state = ""; + else + fmt5_key = (fmt5_key ? fmt5_key "\n" : "") $0; + } else if (fmt5_state == "desc") { + if (/^\.RE([^_a-zA-Z0-9]|$)/) { + fmt5_flush(); + all_reset(); + } else { + fmt5_desc = (fmt5_desc ? fmt5_desc "\n" : "") $0; + } + } + } + function fmt5_flush() { + if (fmt5_state == "desc") { + stage_key(fmt5_key); + stage_desc(fmt5_desc); + stage_flush(); + } + fmt5_state = ""; + } + REQ == "HP" { + all_flush(); + fmt3_state = "key"; + fmt3_key_count = 0; + fmt3_desc = ""; + next; + } + function fmt3_process(_, key) { + if (REQ == "TP") { fmt3_switch(); return; } + if (REQ == "PD") return; + if (fmt3_state == "key") { + if (REQ == "IP") { fmt3_state = "desc"; return; } + if (match($0, /( | )['"$_ble_term_space"']*/)) { + fmt3_keys[fmt3_key_count++] = substr($0, 1, RSTART - 1); + fmt3_desc = substr($0, RSTART + RLENGTH); + fmt3_state = "desc"; + } else { + fmt3_keys[fmt3_key_count++] = $0; + } + } else if (fmt3_state == "desc") { + if (fmt3_desc != "") fmt3_desc = fmt3_desc "\n"; + fmt3_desc = fmt3_desc $0; + } + } + function fmt3_switch(_, i) { + if (fmt3_state == "desc" && fmt3_key_count > 0) { + for (i = 0; i < fmt3_key_count; i++) + stage_key(fmt3_keys[i]); + stage_desc(fmt3_desc); + mode = "desc"; # switch to normal "desc" processing + } + fmt3_state = ""; + fmt3_key_count = 0; + fmt3_desc = ""; + } + function fmt3_flush() { + fmt3_switch(); + stage_flush(); + } + fmt3_state { fmt3_process(); } + /^\.IP['"$_ble_term_space"']+".*"(['"$_ble_term_space"']+[0-9]+)?$/ && fmt3_state != "key" { + fmt6_init(); + fmt4_init(); + next; + } + function fmt4_init() { + if (mode != "fmt4_desc") + if (!(g_keys_count && g_desc == "")) all_flush(); + gsub(/^\.IP['"$_ble_term_space"']+"|"(['"$_ble_term_space"']+[0-9]+)?$/, ""); + stage_key($0); + mode = "fmt4_desc"; + } + mode == "fmt4_desc" { + if ($0 == "") { all_flush(); mode = "none"; next; } + if (g_keys_count == 1 && g_keys[0] == "\\(bu" && match($0, /^\\fC[^\\]+\\fP( or \\fC[^\\]+\\fP)?/) > 0) { + _key = substr($0, 1, RLENGTH); + _desc = substr($0, RLENGTH + 1); + if (match(_key, / or \\fC[^\\]+\\fP/) > 0) + _key = substr(_key, 1, RSTART - 1) ", " substr(_key, RSTART + 4); + g_keys[0] = _key; + g_desc = _desc; + next; + } + if (REQ == "PD") next; + if (/^\.IX['"$_ble_term_space"']+Item['"$_ble_term_space"']+/) next; + stage_desc($0); + } + function fmt6_init() { + fmt6_flush(); + fmt6_state = "desc" + fmt6_key = $0; + fmt6_desc = ""; + } + fmt6_state { + if (REQ == "IX") { + fmt6_state = ""; + } else if (REQ == "IP") { + fmt6_flush(); + } else { + fmt6_desc = fmt6_desc $0 "\n"; + } + } + function fmt6_flush() { + if (!fmt6_state) return; + fmt6_state = ""; + if (fmt6_desc) + output_pair(fmt6_key, fmt6_desc); + } + /^\.It Fl([^_a-zA-Z0-9]|$)/ { + if (g_keys_count && g_desc != "") all_flush(); + sub(/^\.It Fl/, ".Fl"); + if ($0 ~ / Xo$/) { + g_current_key = $0; + mode = "fmt2_keyc" + } else { + stage_key($0); + mode = "desc"; + } + next; + } + mode == "fmt2_keyc" { + if (/^\.PD['"$_ble_term_space"']*([0-9]+['"$_ble_term_space"']*)?$/) next; + g_current_key = g_current_key "\n" $0; + if (REQ == "Xc") { + stage_key(g_current_key); + mode = "desc"; + } + next; + } + type == "man" && REQ == "TP" { + if (g_keys_count && g_desc != "") all_flush(); + mode = "key1"; + next; + } + function fmt1_process_key(line, _, key, desc) { + if (match(line, /['"$_ble_term_space"']['"$_ble_term_space"']['"$_ble_term_space"']/) > 0) { + key = substr(line, 1, RSTART - 1) + desc = substr(line, RSTART); + sub(/^['"$_ble_term_space"']+/, "", desc); + stage_key(key); + stage_desc(desc); + } else { + stage_key(line); + } + mode = "desc"; + } + mode == "key1" { + if (/^\.PD['"$_ble_term_space"']*([0-9]+['"$_ble_term_space"']*)?$/) next; + fmt1_process_key($0); + next; + } + mode == "desc" { + if (REQ == "PD") next; + stage_desc($0); + next; + } + { prev_line = $0; } + END { all_flush(); } + ' | ble/complete/mandb/convert-mandoc 2>/dev/null | ble/bin/awk -F "$_ble_term_FS" ' + function flush_pair(_, i, desc, prev_opt) { + if (g_option_count) { + gsub(/\034/, "\x1b[7m^\\\x1b[27m", g_desc); + sub(/(\. |; ).*/, ".", g_desc); # Long descriptions are truncated. + for (i = 0; i < g_option_count; i++) { + desc = g_desc; + if (i > 0 && g_options[i] ~ /^--/) { + prev_opt = g_options[i - 1]; + sub(/\034.*/, "", prev_opt); + if (prev_opt ~ /^-[^-]$/) + desc = "\033[1m[\033[0;36m" prev_opt "\033[0;1m]\033[m " desc; + } + print g_options[i] FS desc; + } + } + g_option_count = 0; + g_desc = ""; + } + function process_key(line, _, n, specs, i, spec, option, optarg, suffix) { + gsub(/^['"$_ble_term_space"']+|['"$_ble_term_space"']+$/, "", line); + if (line == "") return; + gsub(/\x1b\[[ -?]*[@-~]/, "", line); # CSI seq + gsub(/\x1b[ -\/]*[0-~]/, "", line); # ESC seq + gsub(/\t/, " ", line); # HT + gsub(/.\x08/, "", line); # CHAR BS + gsub(/\x0E/, "", line); # SO + gsub(/\x0F/, "", line); # SI + gsub(/[\x00-\x1F]/, "", line); # Give up all the other control chars + gsub(/^['"$_ble_term_space"']*|['"$_ble_term_space"']*$/, "", line); + gsub(/['"$_ble_term_space"']+/, " ", line); + if (line !~ /^[-+]./) return; + n = split(line, specs, /,(['"$_ble_term_space"']+|$)| or /); + prev_optarg = ""; + for (i = n; i > 0; i--) { + spec = specs[i]; + sub(/,['"$_ble_term_space"']+$/, "", spec); + if (spec !~ /^[-+]/ || spec ~ /\034/) { specs[i] = ""; continue; } + if (match(spec, /\[[:=]?|[:='"$_ble_term_space"']/)) { + option = substr(spec, 1, RSTART - 1); + optarg = substr(spec, RSTART); + suffix = substr(spec, RSTART + RLENGTH - 1, 1); + if (suffix == "[") suffix = ""; + prev_optarg = optarg; + } else { + option = spec; + optarg = ""; + suffix = " "; + if (prev_optarg ~ /[A-Z]|<.+>/) { + optarg = prev_optarg; + if (option ~ /^[-+].$/) { + sub(/^\[=/, "[", optarg); + sub(/^=/, "", optarg); + sub(/^[^'"$_ble_term_space"'[]/, " &", optarg); + } else { + if (optarg ~ /^\[[^:=]/) + sub(/^\[/, "[=", optarg); + else if (optarg ~ /^[^:='"$_ble_term_space"'[]/) + optarg = " " optarg; + } + if (match(optarg, /^\[[:=]?|^[:='"$_ble_term_space"']/)) { + suffix = substr(optarg, RSTART + RLENGTH - 1, 1); + if (suffix == "[") suffix = ""; + } + } + } + specs[i] = option FS optarg FS suffix; + } + for (i = 1; i <= n; i++) { + if (specs[i] == "") continue; + option = substr(specs[i], 1, index(specs[i], FS) - 1); + if (!g_hash[option]++) + g_options[g_option_count++] = specs[i]; + } + } + function process_desc(line) { + gsub(/^['"$_ble_term_space"']*|['"$_ble_term_space"']*$/, "", line); + if (line == "") { + if (g_desc != "") return 0; + return 1; + } + gsub(/['"$_ble_term_space"']['"$_ble_term_space"']+/, " ", line); + if (g_desc != "") g_desc = g_desc " "; + g_desc = g_desc line; + return 1; + } + function process_string_fragment(str) { + if (mode == "key") { + process_key(str); + } else if (mode == "desc") { + if (!process_desc(str)) mode = ""; + } + } + function process_line(line, _, head, m0) { + gsub(/‐|‑|⁃|−|﹣/, "-", line); + while (match(line, /__ble_(key|desc)__/) > 0) { + head = substr(line, 1, RSTART - 1); + m0 = substr(line, RSTART, RLENGTH); + line = substr(line, RSTART + RLENGTH); + process_string_fragment(head); + if (m0 == "__ble_key__") { + flush_pair(); + mode = "key"; + } else { + mode = "desc"; + } + } + process_string_fragment(line); + } + { process_line($0); } + END { flush_pair(); } + ' | ble/bin/sort -t "$_ble_term_FS" -k 1 + ble/util/unlocal LC_COLLATE LC_ALL 2>/dev/null +} +function ble/complete/mandb:help/generate-cache { + local opts=$1 + local -x cfg_usage= cfg_help=1 cfg_plus= cfg_plus_generate= + [[ :$opts: == *:mandb-help-usage:* ]] && cfg_usage=1 + [[ :$opts: == *:mandb-usage:* ]] && cfg_usage=1 cfg_help= + ble/string#match ":$opts:" ':plus-options(=[^:]+)?:' && + cfg_plus=1 cfg_plus_generate=${BASH_REMATCH[1]:1} + local space=$' \t' # for #D1709 (WA gawk 4.0.2) + local rex_argsep='(\[?[:=]| ?|\[)' + local rex_option='[-+](,|[^]:='$space',[]+)('$rex_argsep'(<[^<>]+>|\([^()]+\)|\[[^][]+\]|[^-'"$_ble_term_space"'、。][^'"$_ble_term_space"'、。]*))?([,'"$_ble_term_space"']|$)' + local LC_ALL= LC_COLLATE=C 2>/dev/null + ble/bin/awk -F "$_ble_term_FS" ' + BEGIN { + cfg_help = ENVIRON["cfg_help"]; + g_help_indent = -1; + g_help_score = -1; # score based on indent and the interval between the + g_help_keys_count = 0; + g_help_desc = ""; + cfg_usage = ENVIRON["cfg_usage"]; + g_usage_count = 0; + cfg_plus_generate = ENVIRON["cfg_plus_generate"]; + cfg_plus = ENVIRON["cfg_plus"] cfg_plus_generate; + entries_init(); + } + function entries_init() { + entries_count = 0; + } + function entries_register(entry, score, _, name, ientry) { + name = entry; + sub(/'"$_ble_term_FS"'.*$/, "", name); + if (name ~ /^\+/ && !cfg_plus) return; + if (entries_index[name] != "") { + if (score >= entries_score[name]) return; + ientry = entries_index[name]; + } else { + ientry = entries_count++; + entries_keys[ientry] = name; + } + entries_index[name] = ientry; + entries_entry[name] = entry; + entries_score[name] = score; + } + function entries_dump(_, ientry, name) { + for (ientry = 0; ientry < entries_count; ientry++) { + name = entries_keys[ientry]; + print entries_entry[name]; + } + } + function str_convert_bs2ansi(str, _, head, n, a, c, flag_bold, flag_underline, i, prefix, suffix) { + if (str !~ /\x08/) return str; + print "str = " str >> "./a.txt" + head = ""; + while (match(str, /(.\x08)+./) > 0) { + n = split(substr(str, RSTART, RLENGTH), a, "\x08"); + c = a[1]; + flag_bold = 0; + flag_underline = 0; + for (i = 2; i <= n; i++) { + if (a[i] == "_") { + if (c == "_" && !flag_bold) + flag_bold = 1; + else + flag_underline = 1; + } else { + if (a[i] == c) + flag_bold = 1; + else { + if (c == "_") + flag_underline = 1; + c = a[i]; + } + } + } + if (flag_bold || flag_underline) { + prefix = ""; + suffix = ""; + if (flag_bold) { + prefix = "1"; + suffix = "22"; + } + if (flag_underline) { + prefix = prefix != "" ? prefix ";4" : "4"; + suffix = suffix != "" ? suffix ";24" : "24"; + } + c = "\x1b[" prefix "m" c "\x1b[" suffix "m"; + } + head = head substr(str, 1, RSTART - 1) c; + str = substr(str, RSTART + RLENGTH); + } + return head str; + } + function split_option_optarg_suffix(optspec, _, key, suffix, optarg) { + if (index(optspec, FS) != 0) return ""; + if ((pos = match(optspec, /'"$rex_argsep"'/)) > 0) { + key = substr(optspec, 1, pos - 1); + suffix = substr(optspec, pos + RLENGTH - 1, 1); + if (suffix == "[") suffix = ""; + optarg = substr(optspec, pos); + gsub(/.\x08/, "", optarg); + } else { + key = optspec; + optarg = ""; + suffix = " "; + } + if (key ~ /[^-+'"$_ble_complete_option_chars"']/) return ""; + return key FS optarg FS suffix; + } + { + gsub(/\x1b\[[ -?]*[@-~]/, ""); # CSI seq + gsub(/\x1b[ -\/]*[0-~]/, ""); # ESC seq + gsub(/\t/, " "); # HT + gsub(/[\x00-\x1F]/, ""); # Remove all the other C0 chars + } + function generate_plus(_, i, n) { + if (!cfg_plus_generate) return; + n = length(cfg_plus_generate); + for (i = 1; i <= n; i++) + entries_register("+" substr(cfg_plus_generate, i, 1) FS FS FS, 999); + } + function usage_parse(line, _, optspec, optspec1, option, optarg, n, i, o) { + while (match(line, /\[['"$_ble_term_space"']*([^][]|\[[^][]*\])+['"$_ble_term_space"']*\]/)) { + optspec = substr(line, RSTART + 1, RLENGTH - 2); + line = substr(line, RSTART + RLENGTH); + while (match(optspec, /([^][|]|\[[^][]*\])+/)) { + optspec1 = substr(optspec, RSTART, RLENGTH); + optspec = substr(optspec, RSTART + RLENGTH); + gsub(/^['"$_ble_term_space"']+|['"$_ble_term_space"']+$/, "", optspec1); + if (match(optspec1, /^[-+][^]:='"$space"'[]+/)) { + option = substr(optspec1, RSTART, RLENGTH); + optarg = substr(optspec1, RSTART + RLENGTH); + n = RLENGTH; + if (option ~ /^-.*-/) { + if ((keyinfo = split_option_optarg_suffix(optspec1)) != "") + g_usage[g_usage_count++] = keyinfo; + } else { + o = substr(option, 1, 1); + for (i = 2; i <= n; i++) + if ((keyinfo = split_option_optarg_suffix(o substr(option, i, 1) optarg)) != "") + g_usage[g_usage_count++] = keyinfo; + } + } + } + } + } + function usage_generate(_, i) { + for (i = 0; i < g_usage_count; i++) + entries_register(g_usage[i] FS, 999); + } + cfg_usage { + if (NR <= 20 && (g_usage_start || $0 ~ /^[_a-zA-Z0-9]|^[^-'"$_ble_term_space"'][^'"$_ble_term_space"']*(: |:)/) ) { + g_usage_start = 1; + usage_parse($0); + } else if (/^['"$_ble_term_space"']*$/) + cfg_usage = 0; + } + function get_indent(text, _, i, n, ret) { + ret = 0; + n = length(text); + for (i = 1; i <= n; i++) { + c = substr(text, i, 1); + if (c == " ") + ret++; + else if (c == "\t") + ret = (int(ret / 8) + 1) * 8; + else + break; + } + return ret; + } + function help_flush(_, i, desc, prev_opt) { + if (g_help_indent < 0) return; + for (i = 0; i < g_help_keys_count; i++) { + desc = g_help_desc; + if (i > 0 && g_help_keys[i] ~ /^--/) { + prev_opt = g_help_keys[i - 1]; + sub(/\034.*/, "", prev_opt); + if (prev_opt ~ /^-[^-]$/) { + desc = "\033[1m[\033[0;36m" prev_opt "\033[0;1m]\033[m " desc; + } + } + entries_register(g_help_keys[i] FS desc, g_help_score); + } + g_help_indent = -1; + g_help_keys_count = 0; + g_help_desc = ""; + } + function help_start(keydef, _, key, keyinfo, keys, nkey, i, optarg) { + if (g_help_desc != "") help_flush(); + g_help_indent = get_indent(keydef); + g_help_score = g_help_indent; + nkey = 0; + for (;;) { + sub(/^,?['"$_ble_term_space"']+/, "", keydef); + if (match(keydef, /^'"$rex_option"'/) <= 0) break; + key = substr(keydef, 1, RLENGTH); + keydef = substr(keydef, RLENGTH + 1); + sub(/[,'"$_ble_term_space"']$/, "", key); + keys[nkey++] = key; + } + if (nkey >= 2) { + optarg = ""; + for (i = nkey; --i >= 0; ) { + if (match(keys[i], /'"$rex_argsep"'/) > 0) { + optarg = substr(keys[i], RSTART); + sub(/^['"$_ble_term_space"']+/, "", optarg); + if (optarg !~ /[A-Z]|<.+>/) optarg = ""; + } else if (optarg != ""){ + if (keys[i] ~ /^[-+].$/) { + optarg2 = optarg; + sub(/^\[=/, "[", optarg2); + sub(/^=/, "", optarg2); + sub(/^[^'"$_ble_term_space"'[]/, " &", optarg2); + keys[i] = keys[i] optarg2; + } else { + optarg2 = optarg; + if (optarg2 ~ /^\[[^:=]/) + sub(/^\[/, "[=", optarg2); + else if (optarg2 ~ /^[^:='"$_ble_term_space"'[]/) + optarg2 = " " optarg2; + keys[i] = keys[i] optarg2; + } + } + } + } + for (i = 0; i < nkey; i++) + if ((keyinfo = split_option_optarg_suffix(keys[i])) != "") + g_help_keys[g_help_keys_count++] = keyinfo; + } + function help_append_desc(desc) { + gsub(/^['"$_ble_term_space"']+|['"$_ble_term_space"']$/, "", desc); + if (desc == "") return; + desc = str_convert_bs2ansi(desc); + if (g_help_desc == "") + g_help_desc = desc; + else + g_help_desc = g_help_desc " " desc; + } + cfg_help && match($0, /^['"$_ble_term_space"']*'"$rex_option"'((['"$_ble_term_space"']['"$_ble_term_space"']?)?'"$rex_option"')*/) { + key = substr($0, 1, RLENGTH); + desc = substr($0, RLENGTH + 1); + if (desc ~ /^,/) next; + help_start(key); + help_append_desc(desc); + if (desc !~ /^['"$_ble_term_space"']/) g_help_score += 100; + next; + } + g_help_indent >= 0 { + sub(/['"$_ble_term_space"']+$/, ""); + indent = get_indent($0); + if (indent <= g_help_indent) + help_flush(); + else + help_append_desc($0); + } + END { + help_flush(); + usage_generate(); + generate_plus(); + entries_dump(); + } + ' | ble/bin/sort -t "$_ble_term_FS" -k 1 + ble/util/unlocal LC_COLLATE LC_ALL 2>/dev/null +} +function ble/complete/mandb:bash-completion/inject { + if ble/is-function _comp_compgen_help; then + ble/function#advice after _comp_compgen_help__get_help_lines 'ble/complete/mandb:bash-completion/_get_help_lines.advice' && + { ble/function#advice before _comp_complete_longopt 'ble/complete/mandb:bash-completion/_parse_help.advice "${ADVICE_WORDS[1]}"' || + ble/function#advice before _comp_longopt 'ble/complete/mandb:bash-completion/_parse_help.advice "${ADVICE_WORDS[1]}"'; } && + function ble/complete/mandb:bash-completion/inject { return 0; } + elif ble/is-function _parse_help; then + ble/function#advice before _parse_help 'ble/complete/mandb:bash-completion/_parse_help.advice "${ADVICE_WORDS[1]}" "${ADVICE_WORDS[2]}"' && + ble/function#advice before _longopt 'ble/complete/mandb:bash-completion/_parse_help.advice "${ADVICE_WORDS[1]}"' && + ble/function#advice before _parse_usage 'ble/complete/mandb:bash-completion/_parse_help.advice "${ADVICE_WORDS[1]}" "${ADVICE_WORDS[2]}"' && + function ble/complete/mandb:bash-completion/inject { return 0; } + fi +} 2>/dev/null # _parse_help が別の枠組みで定義されている事がある? #D1900 +function ble/string#hash-pjw { + local size=${2:-32} + local S=${3:-$(((size+7)/8))} # shift 4 + local C=$((size-2*S)) # co-shift 24 + local M=$(((1<>C&N)&M)) + done + ret=$h +} +function ble/complete/mandb:bash-completion/.alloc-subcache { + ret= + [[ $_ble_attached ]] || return 1 + local command=$1 hash=$2 opts=$3 + if [[ :$opts: == *:dequote:* ]]; then + ble/syntax:bash/simple-word/safe-eval "$command" noglob:nonull && + command=$ret + fi + [[ $command ]] || return 1 + [[ $command == ble*/* ]] || command=${1##*/} + ble/string#hash-pjw "$args" 64; local hash=$ret + local lc_messages=${LC_ALL:-${LC_MESSAGES:-${LANG:-C}}} + local mandb_cache_dir=$_ble_base_cache/complete.mandb/${lc_messages//'/'/%} + ble/util/sprintf ret '%s.%014x' "$mandb_cache_dir/_parse_help.d/$command" "$hash" + [[ -s $ret && $ret -nt $_ble_base/lib/core-complete.sh ]] && return 1 + ble/util/mkd "${ret%/*}" +} +function ble/complete/mandb:bash-completion/_parse_help.advice { + local cmd=$1 args=$2 func=$ADVICE_FUNCNAME + local command=${COMP_WORDS[0]-} hash="${ADVICE_WORDS[*]}" ret + ble/complete/mandb:bash-completion/.alloc-subcache "$command" "$hash" dequote || return 0 + local subcache=$ret + local default_option=--help help_opts= + [[ $func == _parse_usage ]] && + default_option=--usage help_opts=mandb-usage + if [[ ( $func == _parse_help || $func == _parse_usage ) && $cmd == - ]]; then + ble/complete/mandb:help/generate-cache "$help_opts" >| "$subcache" + LC_ALL= LC_COLLATE=C ble/bin/awk -F "$_ble_term_FS" ' + BEGIN { entry_count = 0; } + { + entries[entry_count++] = $1; + desc = $4; + gsub(/\033\[[ -?]*[@-~]/, "", desc); + if (match(desc, /^\[[^]'"$_ble_term_space"'[]*\] /) > 0) { # #D1709 safe + short_opt = substr(desc, 2, RLENGTH - 3); + excludes[short_opt] =1; + } + } + END { + for (i = 0; i < entry_count; i++) + if (!excludes[entries[i]]) + print entries[i]; + } + ' "$subcache" 2>/dev/null # suppress locale error #D1440 + else + local cmd_args + ble/string#split-words cmd_args "${args:-$default_option}" + "$cmd" "${cmd_args[@]}" 2>&1 | ble/complete/mandb:help/generate-cache "$help_opts" >| "$subcache" + fi +} +function ble/complete/mandb:bash-completion/_get_help_lines.advice { + ((${#_lines[@]})) || return 0 + local cmd=${_comp_args[0]-${COMP_WORDS[0]-}} hash="${ADVICE_WORDS[*]}" + ble/complete/mandb:bash-completion/.alloc-subcache "$cmd" "$hash" dequote || return 0 + local subcache=$ret + local help_opts= + [[ ${ADVICE_FUNCNAME[1]} == *_usage ]] && help_opts=mandb-usage + printf '%s\n' "${_lines[@]}" | ble/complete/mandb:help/generate-cache "$help_opts" >| "$subcache" +} +function ble/complete/mandb/generate-cache { + local command=${1##*/} opts=${2-} + [[ $command ]] || return 1 + local lc_messages=${LC_ALL:-${LC_MESSAGES:-${LANG:-C}}} + local mandb_cache_dir=$_ble_base_cache/complete.mandb/${lc_messages//'/'/%} + local fcache=$mandb_cache_dir/$command + local cmdspec_opts; ble/cmdspec/opts#load "$command" + [[ :$cmdspec_opts: == *:no-options:* ]] && return 1 + if ble/opts#extract-all-optargs "$cmdspec_opts" mandb-help --help; then + local -a helpspecs; helpspecs=("${ret[@]}") + local subcache=$mandb_cache_dir/help.d/$command + if ! [[ -s $subcache && $subcache -nt $_ble_base/lib/core-complete.sh ]]; then + ble/util/mkd "${subcache%/*}" + local helpspec + for helpspec in "${helpspecs[@]}"; do + if [[ $helpspec == %* ]]; then + builtin eval -- "${helpspec:1}" + elif [[ $helpspec == @* ]]; then + ble/util/print "${helpspec:1}" + else + ble/string#split-words helpspec "${helpspec#+}" + "$command" "${helpspec[@]}" 2>&1 + fi + done | ble/complete/mandb:help/generate-cache "$cmdspec_opts" >| "$subcache" + fi + fi + if [[ :$cmdspec_opts: != *:mandb-disable-man:* ]] && { + ble/opts#extract-last-optarg "$opts" bin + local path=${ret:-"$1"} + ble/bin#has "$path"; }; then + local subcache=$mandb_cache_dir/man.d/$command + if ! [[ -s $subcache && $subcache -nt $_ble_base/lib/core-complete.sh ]]; then + ble/util/mkd "${subcache%/*}" + ble/complete/mandb/.generate-cache-from-man "$command" >| "$subcache" + fi + fi + local -a subcaches=() + local subcache update= + ble/complete/util/eval-pathname-expansion '"$mandb_cache_dir"/_parse_help.d/"$command".??????????????' + for subcache in "${ret[@]}" "$mandb_cache_dir"/{help,man}.d/"$command"; do + if [[ -s $subcache && $subcache -nt $_ble_base/lib/core-complete.sh ]]; then + ble/array#push subcaches "$subcache" + [[ $fcache -nt $subcache ]] || update=1 + fi + done + if [[ $update ]]; then + local -x exclude= + ble/opts#extract-last-optarg "$cmdspec_opts" mandb-exclude && exclude=$ret + local fs=$_ble_term_FS + ble/bin/awk -F "$_ble_term_FS" ' + BEGIN { + plus_count = 0; + nodesc_count = 0; + exclude = ENVIRON["exclude"]; + } + function emit(name, entry) { + hash[name] = entry; + if (exclude != "" && name ~ exclude) return; + print entry; + } + $4 == "" { + if ($1 ~ /^\+/) { + plus_name[plus_count] = $1; + plus_entry[plus_count] = $0; + plus_count++; + } else { + nodesc_name[nodesc_count] = $1; + nodesc_entry[nodesc_count] = $0; + nodesc_count++; + } + next; + } + !hash[$1] { emit($1, $0); } + END { + for (i = 0; i < nodesc_count; i++) + if (!hash[nodesc_name[i]]) + emit(nodesc_name[i], nodesc_entry[i]); + for (i = 0; i < plus_count; i++) { + name = plus_name[i]; + if (hash[name]) continue; + split(plus_entry[i], record, FS); + optarg = record[2]; + suffix = record[3]; + desc = ""; + mname = name; + sub(/^\+/, "-", mname); + if (hash[mname]) { + if (!optarg) { + split(hash[mname], record, FS); + optarg = record[2]; + suffix = record[3]; + } + desc = hash[mname]; + sub(/^[^'$fs']*'$fs'[^'$fs']*'$fs'[^'$fs']*'$fs'/, "", desc); + if (desc) desc = "\033[1mReverse[\033[m " desc " \033[;1m]\033[m"; + } + if (!desc) desc = "reverse of \033[4m" mname "\033[m"; + emit(name, name FS optarg FS suffix FS desc); + } + } + ' "${subcaches[@]}" >| "$fcache" + fi + ret=$fcache + [[ -s $fcache ]] +} +function ble/complete/mandb/load-cache { + ret=() + ble/complete/mandb/generate-cache "$@" && + ble/util/mapfile ret < "$ret" +} +function ble/complete/source:option/.is-option-context { + local rexrej rexreq stopat + ble/progcolor/stop-option#init "$cmdspec_opts" + if [[ $stopat ]] && ((stopat<=$#)); then + return 1 + elif [[ ! $rexrej$rexreq ]]; then + return 0 + fi + local word ret + for word; do + ble/syntax:bash/simple-word/safe-eval "$word" noglob && + ble/progcolor/stop-option#test "$ret" && + return 1 + done + return 0 +} +function ble/complete/source:option { + local opts=$1 + if [[ :$opts: == *:empty:* ]]; then + [[ ! $COMPV ]] || return 0 + else + local rex='^-[-+'$_ble_complete_option_chars']*$|^\+[_'$_ble_complete_option_chars']*$' + [[ $COMPV =~ $rex ]] || return 0 + fi + local COMPS=$COMPS COMPV=$COMPV + ble/complete/source/reduce-compv-for-ambiguous-match + [[ :$comp_type: == *:[maA]:* ]] && local COMP2=$COMP1 + local comp_words comp_line comp_point comp_cword + ble/syntax:bash/extract-command "$COMP2" || return 1 + ble/complete/source:option/generate-for-command "${comp_words[@]::comp_cword}" +} +function ble/complete/source:option/generate-for-command { + local cmd=$1 prev_args + prev_args=("${@:2}") + local alias_checked=' ' + while + local ret cmdv=$cmd + ble/syntax:bash/simple-word/safe-eval "$cmd" nonull && cmdv=$ret + ! ble/complete/mandb/load-cache "$cmdv" + do + alias_checked=$alias_checked$cmd' ' + ble/alias#expand "$cmd" || return 1 + local words; ble/string#split-words ret "$ret"; words=("${ret[@]}") + local iword=0 rex='^[_a-zA-Z][_a-zA-Z0-9]*\+?=' + while [[ ${words[iword]} =~ $rex ]]; do ((iword++)); done + [[ ${words[iword]} && $alias_checked != *" ${words[iword]} "* ]] || return 1 + prev_args=("${words[@]:iword+1}" "${prev_args[@]}") + cmd=${words[iword]} + done + local -a entries; entries=("${ret[@]}") + if [[ ${cmdv##*/} == git ]]; then + local isubcmd + for ((isubcmd=0;isubcmd<${#prev_args[@]};isubcmd++)); do + local subcmd=${prev_args[isubcmd]} + if ble/syntax:bash/simple-word/safe-eval "$subcmd"; then + ((${#ret[@]}==0)) || continue + subcmd=$ret + fi + if [[ $subcmd != -* ]] && ble/complete/mandb/load-cache "git-$subcmd"; then + cmdv=git-$subcmd + entries=("${ret[@]}") + prev_args=("${prev_args[@]:isubcmd+1}") + break + fi + done + fi + local cmdspec_opts= + ble/cmdspec/opts#load "$cmdv" + ble/complete/source:option/.is-option-context "${prev_args[@]}" || return 1 + local "${_ble_complete_yield_varnames[@]/%/=}" # WA #D1570 checked + ble/complete/cand/yield.initialize mandb + local entry fs=$_ble_term_FS has_desc= + for entry in "${entries[@]}"; do + ((cand_iloop++%bleopt_complete_polling_cycle==0)) && + ble/complete/check-cancel && return 148 + local CAND=${entry%%$fs*} + [[ $CAND == "$COMPV"* ]] || continue + ble/complete/cand/yield mandb "$CAND" "$entry" + [[ $entry == *"$fs"*"$fs"*"$fs"?* ]] && has_desc=1 + done + [[ $has_desc && :$opts: != *:empty:* ]] && bleopt complete_menu_style=desc +} +function ble/complete/source:argument/.generate-user-defined-completion { + shopt -q progcomp || return 1 + [[ :$comp_type: == *:[maA]:* ]] && local COMP2=$COMP1 + local comp_words comp_line comp_point comp_cword + ble/syntax:bash/extract-command "$COMP2" || return 1 + local forward_words= + ((comp_cword)) && IFS=' ' builtin eval 'forward_words="${comp_words[*]::comp_cword} "' + local comp2_in_word=$((comp_point-${#forward_words})) + local comp1_in_word=$((comp2_in_word-(COMP2-COMP1))) + if ((comp1_in_word>0)); then + local w=${comp_words[comp_cword]} + comp_words=("${comp_words[@]::comp_cword}" "${w::comp1_in_word}" "${w:comp1_in_word}" "${comp_words[@]:comp_cword+1}") + IFS=' ' builtin eval 'comp_line="${comp_words[*]}"' + ((comp_cword++,comp_point++)) + ((comp2_in_word=COMP2-COMP1,comp1_in_word=0)) + fi + if [[ $COMPV && :$comp_type: == *:[maA]:* ]]; then + local oword=${comp_words[comp_cword]::comp2_in_word} ins + local ins=; [[ :$comp_type: == *:a:* ]] && ins=${COMPV::1} + local ret comps_flags= comps_fixed= # referenced in ble/complete/string#escape-for-completion-context + if [[ $oword ]]; then + local simple_flags simple_ibrace + ble/syntax:bash/simple-word/reconstruct-incomplete-word "$oword" || return 1 + comps_flags=v$simple_flags + ((${simple_ibrace%:*})) && comps_fixed=1 + fi + ble/complete/string#escape-for-completion-context "$ins" c; ins=$ret + ble/util/unlocal comps_flags comps_fixed + ((comp_point+=${#ins})) + comp_words=("${comp_words[@]::comp_cword}" "$oword$ins" "${comp_words[@]:comp_cword+1}") + IFS=' ' builtin eval 'comp_line="${comp_words[*]}"' + ((comp2_in_word+=${#ins})) + fi + local opts=$1 + if [[ :$opts: == *:initial:* ]]; then + ble/complete/progcomp/.compgen initial + else + ble/complete/progcomp "${comp_words[0]}" + fi +} +function ble/complete/source:argument/generate { + local old_cand_count=$cand_count + ble/complete/source:argument/.generate-user-defined-completion; local ext=$? + ((ext==148||cand_count>old_cand_count)) && return "$ext" + if [[ $comp_opts != *:ble/default:* ]]; then + if [[ $comp_opts == *:dirnames:* ]]; then + ble/complete/source:dir; ext=$? + ((ext==148||cand_count>old_cand_count)) && return "$ext" + fi + if [[ $comp_opts == *:default:* ]]; then + ble/complete/source:file; ext=$? + ((ext==148||cand_count>old_cand_count)) && return "$ext" + fi + return "$ext" + fi + ble/complete/source:option; local ext=$? + ((ext==148)) && return "$ext" + local old_cand_count_dirnames=$cand_count + if [[ $comp_opts == *:dirnames:* ]]; then + ble/complete/source:dir; ext=$? + ((ext==148)) && return "$ext" + fi + if ((cand_count==old_cand_count_dirnames)); then + ble/complete/source:file; ext=$? + ((ext==148)) && return "$ext" + fi + ble/complete/source:option empty; local ext=$? + ((ext==148||cand_count>old_cand_count)) && return "$ext" + if local rex='^/?[-_a-zA-Z0-9.]+\+?[:=]|^-[^-/=:]'; [[ $COMPV =~ $rex ]]; then + local prefix=$BASH_REMATCH value=${COMPV:${#BASH_REMATCH}} + local COMP_PREFIX=$prefix + [[ :$comp_type: != *:[maA]:* && $value =~ ^.+/ ]] && + COMP_PREFIX=$prefix${BASH_REMATCH[0]} + local ret cand "${_ble_complete_yield_varnames[@]/%/=}" # WA #D1570 checked + ble/complete/source:file/.construct-pathname-pattern "$value" + ble/complete/util/eval-pathname-expansion "$ret"; (($?==148)) && return 148 + ble/complete/source/test-limit "${#ret[@]}" || return 1 + ble/complete/cand/yield.initialize file_rhs + for cand in "${ret[@]}"; do + ((cand_iloop++%bleopt_complete_polling_cycle==0)) && ble/complete/check-cancel && return 148 + [[ -e $cand || -h $cand ]] || continue + [[ $FIGNORE ]] && ! ble/complete/.fignore/filter "$cand" && continue + ble/complete/cand/yield file_rhs "$prefix$cand" "$prefix" + done + fi + ((cand_count>old_cand_count)) +} +function ble/complete/source:argument { + local comp_opts=:ble/default: + if [[ $comps_flags == *f* && $COMPS != *\* && :$comp_type: != *:[maA]:* ]]; then + local ret simple_flags simple_ibrace + ble/syntax:bash/simple-word/reconstruct-incomplete-word "$COMPS" + ble/complete/source/eval-simple-word "$ret*" && ((${#ret[*]})) && + ble/complete/cand/yield-filenames file "${ret[@]}" + (($?==148)) && return 148 + fi + ble/complete/source:argument/generate + local ext=$? + ((ext==148)) && return 148 + [[ $comp_opts == *:ble/default:* ]] || return "$ext" + ble/complete/source:sabbrev +} +function ble/complete/source/compgen { + [[ $comps_flags == *v* ]] || return 1 + local COMPS=$COMPS COMPV=$COMPV + ble/complete/source/reduce-compv-for-ambiguous-match + local compgen_action=$1 + local action=$2 + local data=$3 + local q="'" Q="'\''" + local compv_quoted="'${COMPV//$q/$Q}'" + local arr + ble/util/assign-array arr 'builtin compgen -A "$compgen_action" -- "$compv_quoted"' + ble/complete/source/test-limit "${#arr[@]}" || return 1 + [[ $1 != '=' && ${#arr[@]} == 1 && $arr == "$COMPV" ]] && return 0 + local cand "${_ble_complete_yield_varnames[@]/%/=}" # WA #D1570 checked + ble/complete/cand/yield.initialize "$action" + for cand in "${arr[@]}"; do + ((cand_iloop++%bleopt_complete_polling_cycle==0)) && ble/complete/check-cancel && return 148 + ble/complete/cand/yield "$action" "$cand" "$data" + done +} +function ble/complete/source:variable { + local data= + case $1 in + ('=') data=assignment ;; + ('b') data=braced ;; + ('a') data=arithmetic ;; + ('n') data=nosuffix ;; + ('w'|*) data=word ;; + esac + ble/complete/source/compgen variable variable "$data" +} +function ble/complete/source:user { + ble/complete/source/compgen user word +} +function ble/complete/source:hostname { + ble/complete/source/compgen hostname word +} +function ble/complete/complete/determine-context-from-opts { + local opts=$1 + context=syntax + if local rex=':context=([^:]+):'; [[ :$opts: =~ $rex ]]; then + local rematch1=${BASH_REMATCH[1]} + if ble/is-function ble/complete/context:"$rematch1"/generate-sources; then + context=$rematch1 + else + ble/util/print "ble/widget/complete: unknown context '$rematch1'" >&2 + fi + fi +} +function ble/complete/context/filter-prefix-sources { + local -a filtered_sources=() + local src asrc + for src in "${sources[@]}"; do + ble/string#split-words asrc "$src" + local comp1=${asrc[1]} + ((comp1=fixlen)) && ble/array#push buff '.*' + ch=${text:i:1} + if [[ $ch == [a-zA-Z] ]]; then + if [[ $opt_icase ]]; then + ble/string#toggle-case "$ch" + ch=[$ch$ret] + fi + else + ble/string#escape-for-extended-regex "$ch"; ch=$ret + fi + ble/array#push buff "$ch" + done + IFS= builtin eval 'ret="${buff[*]}"' +} +function ble/complete/util/construct-glob-pattern { + local text=$1 + if [[ :$comp_type: == *:i:* ]]; then + local i n=${#text} c + local -a buff=() + for ((i=0;i1)); then + local unset_nocasematch= flag_tolower= + if [[ :$comp_type: == *:i:* ]]; then + if ((_ble_bash<30100)); then + flag_tolower=1 + ble/string#tolower "$common"; common=$ret + else + unset_nocasematch=1 + shopt -s nocasematch + fi + fi + local word loop=0 + for word in "${cand_word[@]:1}"; do + ((loop++%bleopt_complete_polling_cycle==0)) && ble/complete/check-cancel && break + if [[ $flag_tolower ]]; then + ble/string#tolower "$word"; word=$ret + fi + ((clen>${#word}&&(clen=${#word}))) + while [[ ${word::clen} != "${common::clen}" ]]; do + ((clen--)) + done + common=${common::clen} + done + [[ $unset_nocasematch ]] && shopt -u nocasematch + ble/complete/check-cancel && return 148 + [[ $flag_tolower ]] && common=${cand_word[0]::${#common}} + fi + if [[ $common != "$COMPS"* && ! ( $cand_count -eq 1 && $comp_type == *:i:* ) ]]; then + if ! ble/completion/candidates/determine-common-prefix/.is-progcomp-raw; then + ble/complete/candidates/determine-common-prefix/.apply-partial-comps + fi + fi + if ((cand_count>1)) && [[ $common != "$COMPS"* ]]; then + local common0=$common + common=$COMPS # 取り敢えず補完挿入をキャンセル + if [[ :$comp_type: == *:[maAi]:* ]]; then + local simple_flags simple_ibrace + if ble/syntax:bash/simple-word/reconstruct-incomplete-word "$common0"; then + local common_reconstructed=$ret + local value=$ret filter_type=head + case :$comp_type: in + (*:m:*) filter_type=substr ;; + (*:a:*) filter_type=hsubseq ;; + (*:A:*) filter_type=subseq ;; + esac + local is_processed= + ble/complete/source/eval-simple-word "$common_reconstructed" single; local ext=$? + ((ext==148)) && return 148 + if ((ext==0)) && ble/complete/candidates/filter:"$filter_type"/count-match-chars "$ret"; then + if [[ $filter_type == head ]] && ((ret<${#COMPV})); then + is_processed=1 + [[ $bleopt_complete_allow_reduction ]] && common=$common0 + elif ((ret)); then + is_processed=1 + ble/string#escape-for-bash-specialchars "${COMPV:ret}" c + common=$common0$ret + fi + fi + if [[ ! $is_processed ]] && + local notilde=\'\' && + ble/syntax:bash/simple-word/safe-eval "$notilde$COMPS" reconstruct:noglob && + local compv_notilde=$ret && + ble/syntax:bash/simple-word/eval "$notilde$common_reconstructed" noglob && + local commonv_notilde=$ret && + COMPV=$compv_notilde ble/complete/candidates/filter:"$filter_type"/count-match-chars "$commonv_notilde" + then + if [[ $filter_type == head ]] && ((ret<${#COMPV})); then + is_processed=1 + [[ $bleopt_complete_allow_reduction ]] && common=$common0 + elif ((ret)); then + is_processed=1 + ble/string#escape-for-bash-specialchars "${compv_notilde:ret}" TG + common=$common0$ret + fi + fi + [[ $is_processed ]] || common=$common0$COMPS + fi + else + if ble/syntax:bash/simple-word/is-simple-or-open-simple "$common"; then + local flag_reduction= + if [[ $bleopt_complete_allow_reduction ]]; then + flag_reduction=1 + else + local simple_flags simple_ibrace + ble/syntax:bash/simple-word/reconstruct-incomplete-word "$common0" && + ble/complete/source/eval-simple-word "$ret" single && + [[ $ret == "$COMPV"* ]] && + flag_reduction=1 + (($?==148)) && return 148 + fi + [[ $flag_reduction ]] && common=$common0 + fi + fi + fi + ret=$common +} +_ble_complete_menu_active= +_ble_complete_menu_style= +_ble_complete_menu_opts= +_ble_complete_menu0_beg= +_ble_complete_menu0_end= +_ble_complete_menu0_str= +_ble_complete_menu_common_part= +_ble_complete_menu0_comp=() +_ble_complete_menu0_pack=() +_ble_complete_menu_comp=() +function ble/complete/menu-complete.class/render-item { + local opts=$2 + if [[ :$opts: == *:selected:* ]]; then + local COMP1=${_ble_complete_menu_comp[0]} + local COMP2=${_ble_complete_menu_comp[1]} + local COMPS=${_ble_complete_menu_comp[2]} + local COMPV=${_ble_complete_menu_comp[3]} + local comp_type=${_ble_complete_menu_comp[4]} + local comps_flags=${_ble_complete_menu0_comp[5]} + local comps_fixed=${_ble_complete_menu0_comp[6]} + local menu_common_part=$_ble_complete_menu_common_part + fi + local "${_ble_complete_cand_varnames[@]/%/=}" # WA #D1570 checked + ble/complete/cand/unpack "$1" + local prefix_len=$PREFIX_LEN + [[ :$comp_type: == *:menu-show-prefix:* ]] && prefix_len=0 + local filter_target=${CAND:prefix_len} + if [[ ! $filter_target ]]; then + ret= + return 0 + fi + local g=0 show=$filter_target suffix= prefix= + ble/function#try ble/complete/action:"$ACTION"/init-menu-item + local g0=$g; [[ :$comp_type: == *:menu-color:* ]] || g0=0 + local m + if [[ :$comp_type: == *:menu-color-match:* && $_ble_complete_menu_common_part && $show == *"$filter_target"* ]]; then + local filter_type=head + case :$comp_type: in + (*:m:*) filter_type=substr ;; + (*:a:*) filter_type=hsubseq ;; + (*:A:*) filter_type=subseq ;; + esac + local needle=${_ble_complete_menu_common_part:prefix_len} + ble/complete/candidates/filter:"$filter_type"/match "$needle" "$filter_target"; m=("${ret[@]}") + if [[ $show != "$filter_target" ]]; then + local show_prefix=${show%%"$filter_target"*} + local offset=${#show_prefix} + local i n=${#m[@]} + for ((i=0;i=0)); then + local "${_ble_complete_cand_varnames[@]/%/=}" # WA #D1570 checked + ble/complete/cand/unpack "${_ble_complete_menu_items[nsel]}" + insert=$INSERT + fi + if [[ :$bleopt_complete_menu_complete_opts: == *:insert-selection:* ]]; then + ble-edit/content/replace-limited "$_ble_complete_menu0_beg" "$_ble_edit_ind" "$insert" + ((_ble_edit_ind=_ble_complete_menu0_beg+${#insert})) + fi +} +function ble/complete/menu/clear { + if [[ $_ble_complete_menu_active ]]; then + _ble_complete_menu_active= + ble/complete/menu#clear + [[ $_ble_highlight_layer_menu_filter_beg ]] && + ble/textarea#invalidate str # layer:menu_filter 解除 (#D0995) + fi + return 0 +} +blehook widget_bell!=ble/complete/menu/clear +blehook history_leave!=ble/complete/menu/clear +function ble/complete/menu/get-footprint { + footprint=$_ble_edit_ind:$_ble_edit_mark_active:${_ble_edit_mark_active:+$_ble_edit_mark}:$_ble_edit_overwrite_mode:$_ble_edit_str +} +function ble/complete/menu/show { + local opts=$1 + [[ :$opts: == *:init:* ]] && opts=$opts:update-items + if [[ :$opts: != *:update-items:* ]]; then + local comp_type=${_ble_complete_menu_comp[4]} + local cand_pack; cand_pack=("${_ble_complete_menu_items[@]}") + local menu_common_part=$_ble_complete_menu_common_part + fi + local menu_style=$_ble_complete_menu_style + local menu_opts=$_ble_complete_menu_opts + if [[ ! $_ble_complete_menu_style || :$opts: == *:init:* ]]; then + menu_style=$bleopt_complete_menu_style + menu_opts= + [[ :$bleopt_complete_menu_complete_opts: == *:hidden:* && :$opts: != *:show_menu:* ]] && + menu_opts=$menu_opts:hidden + _ble_complete_menu_style=$menu_style + _ble_complete_menu_opts=$menu_opts + fi + local menu_items; menu_items=("${cand_pack[@]}") + _ble_complete_menu_common_part=$menu_common_part + local menu_class=ble/complete/menu-complete.class menu_param= + local menu_construct_opts=$opts + [[ :$comp_type: == *:sync:* ]] && + menu_construct_opts=$menu_construct_opts:sync + [[ :$_ble_complete_menu_opts: == *:hidden:* ]] && + menu_construct_opts=$menu_construct_opts:hidden + ble/complete/menu#construct "$menu_construct_opts" || return "$?" + ble/complete/menu#show + case :$opts: in + (*:init:*) + local beg=$COMP1 end=$_ble_edit_ind # COMP2 でなく補完挿入後の位置 + local str=$_ble_edit_str + [[ $_ble_decode_keymap == auto_complete ]] && + str=${str::_ble_edit_ind}${str:_ble_edit_mark} + local footprint; ble/complete/menu/get-footprint + _ble_complete_menu_active=1 + _ble_complete_menu0_beg=$beg + _ble_complete_menu0_end=$end + _ble_complete_menu0_str=$str + _ble_complete_menu0_comp=("$COMP1" "$COMP2" "$COMPS" "$COMPV" "$comp_type" "$comps_flags" "$comps_fixed") + _ble_complete_menu0_pack=("${cand_pack[@]}") + _ble_complete_menu_comp=("$COMP1" "$COMP2" "$COMPS" "$COMPV" "$comp_type") + _ble_complete_menu_footprint=$footprint ;; + (*:update-context:*) + local left0=${_ble_complete_menu0_str::_ble_complete_menu0_end} + local left1=${_ble_edit_str::_ble_edit_ind} + local ret; ble/string#common-prefix "$left0" "$left1"; left0=$ret + local right0=${_ble_complete_menu0_str:_ble_complete_menu0_end} + local right1=${_ble_edit_str:_ble_edit_ind} + local ret; ble/string#common-suffix "$right0" "$right1"; right0=$ret + local footprint; ble/complete/menu/get-footprint + _ble_complete_menu0_str=$left0$right0 + _ble_complete_menu0_end=${#left0} + _ble_complete_menu_footprint=$footprint ;; + esac + return 0 +} +function ble/complete/menu/redraw { + if [[ $_ble_complete_menu_active ]]; then + ble/complete/menu#show + fi +} +function ble/complete/menu/get-active-range { + [[ $_ble_complete_menu_active ]] || return 1 + local str=${1-$_ble_edit_str} ind=${2-$_ble_edit_ind} + local mbeg=$_ble_complete_menu0_beg + local mend=$_ble_complete_menu0_end + local left=${_ble_complete_menu0_str::mend} + local right=${_ble_complete_menu0_str:mend} + if [[ ${str::_ble_edit_ind} == "$left"* && ${str:_ble_edit_ind} == *"$right" ]]; then + ((beg=mbeg,end=${#str}-${#right})) + return 0 + else + ble/complete/menu/clear + return 1 + fi +} +function ble/complete/menu/generate-candidates-from-menu { + COMP1=${_ble_complete_menu_comp[0]} + COMP2=${_ble_complete_menu_comp[1]} + COMPS=${_ble_complete_menu_comp[2]} + COMPV=${_ble_complete_menu_comp[3]} + comp_type=${_ble_complete_menu_comp[4]} + comps_flags=${_ble_complete_menu0_comp[5]} + comps_fixed=${_ble_complete_menu0_comp[6]} + cand_count=${#_ble_complete_menu_items[@]} + cand_cand=() cand_word=() cand_pack=() + local pack "${_ble_complete_cand_varnames[@]/%/=}" # WA #D1570 checked + for pack in "${_ble_complete_menu_items[@]}"; do + ble/complete/cand/unpack "$pack" + ble/array#push cand_cand "$CAND" + ble/array#push cand_word "$INSERT" + ble/array#push cand_pack "$pack" + done + ((cand_count)) +} +function ble/complete/generate-candidates-from-opts { + local opts=$1 + local context; ble/complete/complete/determine-context-from-opts "$opts" + comp_type= + [[ :$opts: == *:auto_menu:* ]] && comp_type=auto_menu + local comp_text=$_ble_edit_str comp_index=$_ble_edit_ind + local sources + ble/complete/context:"$context"/generate-sources "$comp_text" "$comp_index" || return "$?" + ble/complete/candidates/generate "$opts" +} +function ble/complete/insert { + local insert_beg=$1 insert_end=$2 + local insert=$3 suffix=$4 + local original_text=${_ble_edit_str:insert_beg:insert_end-insert_beg} + local ret + local insert_replace= + if [[ $insert == "$original_text"* ]]; then + insert=${insert:insert_end-insert_beg} + ((insert_beg=insert_end)) + else + ble/string#common-prefix "$insert" "$original_text" + if [[ $ret ]]; then + insert=${insert:${#ret}} + ((insert_beg+=${#ret})) + fi + fi + if [[ $bleopt_complete_skip_matched ]]; then + if [[ $insert ]]; then + local right_text=${_ble_edit_str:insert_end} + right_text=${right_text%%[$IFS]*} + if ble/string#common-prefix "$insert" "$right_text"; [[ $ret ]]; then + ((insert_end+=${#ret})) + elif ble/complete/string#common-suffix-prefix "$insert" "$right_text"; [[ $ret ]]; then + ((insert_end+=${#ret})) + fi + fi + if [[ $suffix ]]; then + local right_text=${_ble_edit_str:insert_end} + if ble/string#common-prefix "$suffix" "$right_text"; [[ $ret ]]; then + ((insert_end+=${#ret})) + elif ble/complete/string#common-suffix-prefix "$suffix" "$right_text"; [[ $ret ]]; then + ((insert_end+=${#ret})) + fi + fi + fi + local ins=$insert$suffix + ble/widget/.replace-range "$insert_beg" "$insert_end" "$ins" + ((_ble_edit_ind=insert_beg+${#ins}, + _ble_edit_ind>${#_ble_edit_str}&& + (_ble_edit_ind=${#_ble_edit_str}))) +} +function ble/complete/insert-common { + local ret + ble/complete/candidates/determine-common-prefix; (($?==148)) && return 148 + local insert=$ret suffix= + local insert_beg=$COMP1 insert_end=$COMP2 + local insert_flags= + [[ $insert == "$COMPS"* ]] || insert_flags=r + if ((cand_count==1)); then + local ACTION=${cand_pack[0]%%:*} + if ble/is-function ble/complete/action:"$ACTION"/complete; then + local "${_ble_complete_cand_varnames[@]/%/=}" # WA #D1570 checked + ble/complete/cand/unpack "${cand_pack[0]}" + ble/complete/action:"$ACTION"/complete + (($?==148)) && return 148 + fi + else + insert_flags=${insert_flags}m + fi + local do_insert=1 + if ((cand_count>1)) && [[ $insert_flags == *r* ]]; then + if [[ :$comp_type: != *:[maAi]:* ]]; then + do_insert= + fi + elif [[ $insert$suffix == "$COMPS" ]]; then + do_insert= + fi + if [[ $do_insert ]]; then + ble/complete/insert "$insert_beg" "$insert_end" "$insert" "$suffix" + blehook/invoke complete_insert + fi + if [[ $insert_flags == *m* ]]; then + local menu_common_part=$COMPV + local ret simple_flags simple_ibrace + if ble/syntax:bash/simple-word/reconstruct-incomplete-word "$insert"; then + ble/complete/source/eval-simple-word "$ret" single + (($?==148)) && return 148 + menu_common_part=$ret + fi + ble/complete/menu/show "$menu_show_opts" || return "$?" + elif [[ $insert_flags == *n* ]]; then + ble/widget/complete show_menu:regenerate || return "$?" + else + _ble_complete_state=complete + ble/complete/menu/clear + fi + return 0 +} +function ble/complete/insert-all { + local "${_ble_complete_cand_varnames[@]/%/=}" # WA #D1570 checked + local pack beg=$COMP1 end=$COMP2 insert= suffix= insert_flags= index=0 + for pack in "${cand_pack[@]}"; do + ble/complete/cand/unpack "$pack" + insert=$INSERT suffix= insert_flags= + if ble/is-function ble/complete/action:"$ACTION"/complete; then + ble/complete/action:"$ACTION"/complete + (($?==148)) && return 148 + fi + [[ $suffix != *' ' ]] && suffix="$suffix " + ble/complete/insert "$beg" "$end" "$insert" "$suffix" + blehook/invoke complete_insert + beg=$_ble_edit_ind end=$_ble_edit_ind + ((index++)) + done + _ble_complete_state=complete + ble/complete/menu/clear + return 0 +} +function ble/complete/insert-braces/.compose { + if ble/bin/awk0.available; then + local printf_format='%s\0' char_RS='"\0"' awk=ble/bin/awk0 + else + local printf_format='%s\x1E' char_RS='"\x1E"' awk=ble/bin/awk + fi + local q=\' + local -x rex_atom='^(\\.|[0-9]+|.)' del_close= del_open= quote_type= + local -x COMPS=$COMPS + if [[ :$comp_type: != *:[maAi]:* ]]; then + local rex_brace='[,{}]|\{[-a-zA-Z0-9]+\.\.[-a-zA-Z0-9]+\}' + case $comps_flags in + (*S*) rex_atom='^('$q'(\\'$q'|'$rex_brace')'$q'|[0-9]+|.)' # '...' + del_close=\' del_open=\' quote_type=S ;; + (*E*) rex_atom='^(\\.|'$q'('$rex_brace')\$'$q'|[0-9]+|.)' # $'...' + del_close=\' del_open=\$\' quote_type=E ;; + (*[DI]*) rex_atom='^(\\[\"$`]|"('$rex_brace')"|[0-9]+|.)' # "...", $"..." + del_close=\" del_open=\" quote_type=D ;; + esac + fi + printf "$printf_format" "$@" | "$awk" ' + function starts_with(str, head) { + return substr(str, 1, length(head)) == head; + } + function islower(s) { + return s == tolower(s); + } + BEGIN { + RS = '"$char_RS"'; + rex_atom = ENVIRON["rex_atom"]; + del_close = ENVIRON["del_close"]; + del_open = ENVIRON["del_open"]; + quote_type = ENVIRON["quote_type"]; + COMPS = ENVIRON["COMPS"]; + BRACE_OPEN = del_close "{" del_open; + BRACE_CLOS = del_close "}" del_open; + } + function to_atoms(str, arr, _, chr, atom, level, count, rex) { + count = 0; + while (match(str, rex_atom) > 0) { + chr = substr(str, 1, RLENGTH); + str = substr(str, RLENGTH + 1); + if (chr == BRACE_OPEN) { + atom = chr; + level = 1; + while (match(str, rex_atom) > 0) { + chr = substr(str, 1, RLENGTH); + str = substr(str, RLENGTH + 1); + atom = atom chr; + if (chr == BRACE_OPEN) + level++; + else if (chr == BRACE_CLOS && --level==0) + break; + } + } else { + atom = chr; + } + arr[count++] = atom; + } + return count; + } + function remove_empty_quote(str, _, rex_quote_first, rex_quote, out, empty, m) { + if (quote_type == "S" || quote_type == "E") { + rex_quote_first = "^[^'$q']*'$q'"; + rex_quote = "'$q'[^'$q']*'$q'|(\\\\.|[^'$q'])+"; + } else if (quote_type == "D") { + rex_quote_first = "^[^\"]*\""; + rex_quote = "\"([^\\\"]|\\\\.)*\"|(\\\\.|[^\"])+"; + } else return str; + empty = del_open del_close; + out = ""; + if (starts_with(str, COMPS)) { + out = COMPS; + str = substr(str, length(COMPS) + 1); + if (match(str, rex_quote_first) > 0) { + out = out substr(str, 1, RLENGTH); + str = substr(str, RLENGTH + 1); + } + } + while (match(str, rex_quote) > 0) { + m = substr(str, 1, RLENGTH); + if (m != empty) out = out m; + str = substr(str, RLENGTH + 1); + } + if (str == del_open) + return out; + else + return out str del_close; + } + function zpad(value, width, _, wpad, i, pad) { + wpad = width - length(value); + pad = ""; + for (i = 0; i < wpad; i++) pad = "0" pad; + if (value < 0) + return "-" pad (-value); + else + return pad value; + } + function zpad_remove(value) { + if (value ~ /^0+$/) + value = "0"; + else if (value ~ /^-/) + sub(/^-0+/, "-", value); + else + sub(/^0+/, "", value); + return value; + } + function zpad_a2i(text) { + sub(/^-0+/, "-", text) || sub(/^0+/, "", text); + return 0 + text; + } + function range_contract(arr, len, _, i, value, alpha, lower, upper, keys, ikey, dict, b, e, beg, end, tmp) { + lower = "abcdefghijklmnopqrstuvwxyz"; + upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + for (i = 0; i < len; i++) { + value = arr[i]; + if (dict[value]) { + dict[value]++; + } else { + keys[ikey++] = value; + dict[value] = 1; + } + } + len = 0; + for (i = 0; i < ikey; i++) { + while (dict[value = keys[i]]--) { + if (value ~ /^([a-zA-Z])$/) { + alpha = islower(value) ? lower : upper; + beg = end = value; + b = e = index(alpha, value); + while (b > 1 && dict[tmp = substr(alpha, b - 1, 1)]) { + dict[beg = tmp]--; + b--; + } + while (e < 26 && dict[tmp = substr(alpha, e + 1, 1)]) { + dict[end = tmp]--; + e++; + } + if (e == b) { + arr[len++] = beg; + } else if (e == b + 1) { + arr[len++] = beg; + arr[len++] = end; + } else { + arr[len++] = del_close "{" beg ".." end "}" del_open; + } + } else if (value ~ /^(0+|-?0*[1-9][0-9]*)$/) { + beg = end = value; + b = e = zpad_a2i(value); + wmax = wmin = length(value); + if (value ~ /^(0|-?[1-9][0-9]*)$/) { + while (dict[b - 1]) dict[--b]--; + while (dict[e + 1]) dict[++e]--; + tmp = length(beg = "" b); + if (tmp < wmin) wmin = tmp; + else if (tmp > wmax) wmax = tmp; + tmp = length(end = "" e); + if (tmp < wmin) wmin = tmp; + else if (tmp > wmax) wmax = tmp; + } + if (wmax == wmin) { + while (length(tmp = zpad(b - 1, wmin)) == wmin && dict[tmp]) { dict[tmp]--; --b; } + while (length(tmp = zpad(e + 1, wmin)) == wmin && dict[tmp]) { dict[tmp]--; ++e; } + beg = zpad(b, wmin); + end = zpad(e, wmin); + } + if (e == b) { + arr[len++] = beg; + } else if (e == b + 1) { + arr[len++] = beg; + arr[len++] = end; + } else if (b < 0 && e < 0) { + arr[len++] = del_close "-{" substr(end, 2) ".." substr(beg, 2) "}" del_open; + } else { + arr[len++] = del_close "{" beg ".." end "}" del_open; + } + } else { + arr[len++] = value; + } + } + } + return len; + } + function simple_brace(arr, len, _, ret, i) { + if (len == 0) return ""; + len = range_contract(arr, len); + if (len == 1) return arr[0]; + ret = BRACE_OPEN arr[0]; + for (i = 1; i < len; i++) + ret = ret del_close "," del_open arr[i]; + return ret BRACE_CLOS; + } + function rfrag_strlen_common(a, b, _, la, lb, tmp, i, n) { + ret = 0; + alen = to_atoms(a, abuf); + blen = to_atoms(b, bbuf); + while (alen > 0 && blen > 0) { + if (abuf[alen - 1] != bbuf[blen - 1]) break; + ret += length(abuf[alen - 1]); + alen--; + blen--; + } + return ret; + } + function rfrag_get_level(str, _, len, i, rfrag0, rfrag0len, rfrag1) { + len = length(str); + rfrag_matching_offset = len; + for (i = 0; i < rfrag_depth - 1; i++) { + rfrag0 = rfrag[i]; + rfrag0len = length(rfrag0); + rfrag1 = substr(str, len - rfrag0len + 1); + str = substr(str, 1, len -= rfrag0len); + if (rfrag0 != rfrag1) break; + rfrag_matching_offset -= rfrag0len; + } + while (i && rfrag[i - 1] == "") i--; # empty fragment + return i; + } + function rfrag_reduce(new_depth, _, c, i, brace, frags) { + while (rfrag_depth > new_depth) { + rfrag_depth--; + c = rfrag_count[rfrag_depth]; + for (i = 0; i < c; i++) + frags[i] = rfrag[rfrag_depth, i]; + frags[c] = rfrag[rfrag_depth]; + brace = simple_brace(frags, c + 1); + if (rfrag_depth == 0) + return brace; + else + rfrag[rfrag_depth - 1] = brace rfrag[rfrag_depth - 1]; + } + } + function rfrag_register(str, level, _, rfrag0, rfrag1, len) { + if (level == rfrag_depth) { + rfrag_depth = level + 1; + rfrag[level] = ""; + rfrag_count[level] = 0; + } else if (rfrag_depth != level + 1) { + print "ERR(rfrag)"; + } + rfrag0 = rfrag[level]; + rfrag1 = substr(str, 1, rfrag_matching_offset); + len = rfrag_strlen_common(rfrag0, rfrag1); + if (len == 0) { + rfrag[level, rfrag_count[level]++] = rfrag0; + rfrag[level] = rfrag1; + } else { + rfrag[level] = substr(rfrag0, length(rfrag0) - len + 1); + rfrag[level + 1, 0] = substr(rfrag0, 1, length(rfrag0) - len); + rfrag[level + 1] = substr(rfrag1, 1, length(rfrag1) - len); + rfrag_count[level + 1] = 1; + rfrag_depth++; + } + } + function rfrag_dump(_, i, j, prefix) { + print "depth = " rfrag_depth; + for (i = 0; i < rfrag_depth; i++) { + prefix = ""; + for (j = 0; j < i; j++) prefix = prefix " "; + for (j = 0; j < rfrag_count[i]; j++) + print prefix "rfrag[" i "," j "] = " rfrag[i,j]; + print prefix "rfrag[" i "] = " rfrag[i]; + } + } + function rfrag_brace(arr, len, _, i, level) { + if (len == 0) return ""; + if (len == 1) return arr[0]; + rfrag_depth = 1; + rfrag[0] = arr[0]; + rfrag_count[0] = 0; + for (i = 1; i < len; i++) { + level = rfrag_get_level(arr[i]); + rfrag_reduce(level + 1); + rfrag_register(arr[i], level); + } + return rfrag_reduce(0); + } + function lfrag_strlen_common(a, b, _, ret, abuf, bbuf, alen, blen, ia, ib) { + ret = 0; + alen = to_atoms(a, abuf); + blen = to_atoms(b, bbuf); + for (ia = ib = 0; ia < alen && ib < blen; ia++ + ib++) { + if (abuf[ia] != bbuf[ib]) break; + ret += length(abuf[ia]); + } + return ret; + } + function lfrag_get_level(str, _, i, frag0, frag0len, frag1) { + lfrag_matching_offset = 0; + for (i = 0; i < lfrag_depth - 1; i++) { + frag0 = frag[i] + frag0len = length(frag0); + frag1 = substr(str, lfrag_matching_offset + 1, frag0len); + if (frag0 != frag1) break; + lfrag_matching_offset += frag0len; + } + while (i && frag[i - 1] == "") i--; # empty fragment + return i; + } + function lfrag_reduce(new_depth, _, c, i, brace, frags) { + while (lfrag_depth > new_depth) { + lfrag_depth--; + c = frag_count[lfrag_depth]; + for (i = 0; i < c; i++) + frags[i] = frag[lfrag_depth, i]; + frags[c] = frag[lfrag_depth]; + brace = rfrag_brace(frags, c + 1); + if (lfrag_depth == 0) + return brace; + else + frag[lfrag_depth - 1] = frag[lfrag_depth - 1] brace; + } + } + function lfrag_register(str, level, _, frag0, frag1, len) { + if (lfrag_depth == level) { + lfrag_depth = level + 1; + frag[level] = ""; + frag_count[level] = 0; + } else if (lfrag_depth != level + 1) { + print "ERR"; + } + frag0 = frag[level]; + frag1 = substr(str, lfrag_matching_offset + 1); + len = lfrag_strlen_common(frag0, frag1); + if (len == 0) { + frag[level, frag_count[level]++] = frag0; + frag[level] = frag1; + } else { + frag[level] = substr(frag0, 1, len); + frag[level + 1, 0] = substr(frag0, len + 1); + frag[level + 1] = substr(frag1, len + 1); + frag_count[level + 1] = 1; + lfrag_depth++; + } + } + function lfrag_dump(_, i, j, prefix) { + print "depth = " lfrag_depth; + for (i = 0; i < lfrag_depth; i++) { + prefix = ""; + for (j = 0; j < i; j++) prefix = prefix " "; + for (j = 0; j < frag_count[i]; j++) + print prefix "frag[" i "," j "] = " frag[i,j]; + print prefix "frag[" i "] = " frag[i]; + } + } + NR == 1 { + lfrag_depth = 1; + frag[0] = $0; + frag_count[0] = 0; + next + } + { + level = lfrag_get_level($0); + lfrag_reduce(level + 1); + lfrag_register($0, level); + } + END { + result = lfrag_reduce(0); + result = remove_empty_quote(result); + print result; + } + ' +} +function ble/complete/insert-braces { + if ((cand_count==1)); then + ble/complete/insert-common; return "$?" + fi + local comps_len=${#COMPS} loop=0 + local -a tails=() + local common=${cand_word[0]} + ble/array#push tails "${common:comps_len}" + local word clen=${#common} + for word in "${cand_word[@]:1}"; do + ((loop++%bleopt_complete_polling_cycle==0)) && ble/complete/check-cancel && return 148 + ((clen>${#word}&&(clen=${#word}))) + while [[ ${word::clen} != "${common::clen}" ]]; do + ((clen--)) + done + common=${common::clen} + ble/array#push tails "${word:comps_len}" + done + local fixed=$COMPS + if [[ $common != "$COMPS"* ]]; then + tails=() + local fixed= fixval= + { + [[ $comps_fixed ]] && + fixed=${COMPS::${comps_fixed%%:*}} fixval=${comps_fixed#*:} + local ret simple_flags simple_ibrace + ble/complete/candidates/determine-common-prefix/.apply-partial-comps # var[in,out] common + if ble/syntax:bash/simple-word/reconstruct-incomplete-word "$common"; then + ble/complete/source/eval-simple-word "$ret" single + (($?==148)) && return 148 + fixed=$common fixval=$ret + fi + } + local cand ret fixval_len=${#fixval} + for cand in "${cand_cand[@]}"; do + ((loop++%bleopt_complete_polling_cycle==0)) && ble/complete/check-cancel && return 148 + [[ $cand == "$fixval"* ]] || continue + ble/complete/string#escape-for-completion-context "${cand:fixval_len}" + case $comps in + (*S*) cand=\'$ret\' ;; + (*E*) cand=\$\'$ret\' ;; + (*D*) cand=\"$ret\" ;; + (*I*) cand=\$\"$ret\" ;; + (*) cand=$ret ;; + esac + ble/array#push tails "$cand" + done + fi + local tail; ble/util/assign tail 'ble/complete/insert-braces/.compose "${tails[@]}"' + local beg=$COMP1 end=$COMP2 insert=$fixed$tail suffix= + if [[ $comps_flags == *x* ]]; then + ble/complete/action/complete.addtail ',' + else + ble/complete/action/complete.addtail ' ' + fi + ble/complete/insert "$beg" "$end" "$insert" "$suffix" + blehook/invoke complete_insert + _ble_complete_state=complete + ble/complete/menu/clear + return 0 +} +_ble_complete_state= +function ble/widget/complete { + local opts=$1 + ble-edit/content/clear-arg + local state=$_ble_complete_state + _ble_complete_state=start + local ret + ble/opts#extract-last-optarg "$opts" menu-style && + [[ $ret ]] && ble/is-function ble/complete/menu-style:"$ret"/construct && + local bleopt_complete_menu_style=$ret + case :$opts: in + (*:insert_*:*) ;; + (*:toggle_menu:*) + if [[ $_ble_complete_menu_active ]]; then + ble/widget/menu_complete/toggle-hidden + return 0 + else + opts=$opts:show_menu + fi ;; + (*:show_menu:*) ;; + (*:enter_menu:*) + [[ $_ble_complete_menu_active && :$opts: != *:context=*:* ]] && + ble/complete/menu-complete/enter "$opts" && return 0 ;; + (*) + if [[ $bleopt_complete_menu_complete ]]; then + if [[ $_ble_complete_menu_active && :$opts: != *:context=*:* ]]; then + local footprint; ble/complete/menu/get-footprint + [[ $footprint == "$_ble_complete_menu_footprint" ]] && + ble/complete/menu-complete/enter "$opts" && return 0 + fi + [[ $WIDGET == "$LASTWIDGET" && $state != complete ]] && opts=$opts:enter_menu + fi ;; + esac + local COMP1 COMP2 COMPS COMPV + local comp_type comps_flags comps_fixed + local cand_count cand_cand cand_word cand_pack + ble/complete/candidates/clear + local menu_show_opts=init + local cand_limit_reached= + if [[ $_ble_complete_menu_active && :$opts: != *:regenerate:* && + :$opts: != *:context=*:* && ${#_ble_complete_menu_items[@]} -gt 0 ]] + then + if [[ $_ble_complete_menu_filter_enabled && $bleopt_complete_menu_filter ]] || { + ble/complete/menu-filter; local ext=$? + ((ext==148)) && return 148 + ((ext==0)); }; then + ble/complete/menu/generate-candidates-from-menu; local ext=$? + ((ext==148)) && return 148 + if ((ext==0&&cand_count)); then + menu_show_opts=update-context:update-items + fi + fi + fi + if ((cand_count==0)); then + local bleopt_complete_menu_style=$bleopt_complete_menu_style # source 等に一次変更を認める。 + ble/complete/generate-candidates-from-opts "$opts"; local ext=$? + if ((ext==148)); then + return 148 + fi + if [[ $cand_limit_reached ]]; then + [[ :$opts: != *:no-bell:* ]] && + ble/widget/.bell 'complete: limit reached' + if [[ $cand_limit_reached == cancel ]]; then + ble/edit/info/default + return 1 + fi + fi + if ((ext!=0||cand_count==0)); then + [[ :$opts: != *:no-bell:* && ! $cand_limit_reached ]] && + ble/widget/.bell 'complete: no completions' + ble/edit/info/default + return 1 + fi + fi + if [[ :$opts: == *:insert_common:* || :$opts: == *:insert_unique:* && cand_count -eq 1 ]]; then + ble/complete/insert-common; return "$?" + elif [[ :$opts: == *:insert_braces:* ]]; then + ble/complete/insert-braces; return "$?" + elif [[ :$opts: == *:insert_all:* ]]; then + ble/complete/insert-all; return "$?" + elif [[ :$opts: == *:enter_menu:* ]]; then + local menu_common_part=$COMPV + ble/complete/menu/show "$menu_show_opts" || return "$?" + ble/complete/menu-complete/enter "$opts"; local ext=$? + ((ext==148)) && return 148 + ((ext)) && [[ :$opts: != *:no-bell:* ]] && + ble/widget/.bell 'menu-complete: no completions' + return 0 + elif [[ :$opts: == *:show_menu:* ]]; then + local menu_common_part=$COMPV + ble/complete/menu/show "$menu_show_opts:show_menu" + return "$?" # exit status of ble/complete/menu/show + fi + ble/complete/insert-common; return "$?" +} +function ble/widget/complete-insert { + local original=$1 insert=$2 suffix=$3 + [[ ${_ble_edit_str::_ble_edit_ind} == *"$original" ]] || return 1 + local insert_beg=$((_ble_edit_ind-${#original})) + local insert_end=$_ble_edit_ind + ble/complete/insert "$insert_beg" "$insert_end" "$insert" "$suffix" +} +function ble/widget/menu-complete { + local opts=$1 + ble/widget/complete enter_menu:insert_unique:$opts +} +function ble/widget/complete/.select-menu-with-arg { + [[ $bleopt_complete_menu_complete && $_ble_complete_menu_active ]] || return 1 + local footprint; ble/complete/menu/get-footprint + [[ $footprint == "$_ble_complete_menu_footprint" ]] || return 1 + local arg_opts= opts=$1 + [[ :$opts: == *:enter-menu:* ]] && arg_opts=always + [[ :$opts: == *:nobell:* ]] && arg_opts=$arg_opts:nobell + ble/widget/menu/append-arg/.is-argument "$arg_opts" || return 1 + ble/complete/menu-complete/enter + ble/widget/menu/append-arg "$arg_opts" + return 0 +} +function ble/complete/menu-filter/.filter-candidates { + cand_pack=() + local iloop=0 interval=$bleopt_complete_polling_cycle + local filter_type pack "${_ble_complete_cand_varnames[@]/%/=}" # WA #D1570 checked + for filter_type in head substr hsubseq subseq; do + ble/path#remove-glob comp_type '[maA]' + case $filter_type in + (substr) comp_type=${comp_type}:m ;; + (hsubseq) comp_type=${comp_type}:a ;; + (subseq) comp_type=${comp_type}:A ;; + esac + local comp_filter_type + local comp_filter_pattern + ble/complete/candidates/filter#init "$filter_type" "$COMPV" + for pack in "${_ble_complete_menu0_pack[@]}"; do + ((iloop++%interval==0)) && ble/complete/check-cancel && return 148 + ble/complete/cand/unpack "$pack" + ble/complete/candidates/filter#test "$CAND" && + ble/array#push cand_pack "$pack" + done + ((${#cand_pack[@]}!=0)) && return 0 + done +} +function ble/complete/menu-filter/.get-filter-target { + if [[ $_ble_decode_keymap == emacs || $_ble_decode_keymap == vi_[ic]map ]]; then + ret=$_ble_edit_str + elif [[ $_ble_decode_keymap == auto_complete ]]; then + ret=${_ble_edit_str::_ble_edit_ind}${_ble_edit_str:_ble_edit_mark} + else + return 1 + fi +} +function ble/complete/menu-filter { + [[ $_ble_decode_keymap == menu_complete ]] && return 0 + local ret; ble/complete/menu-filter/.get-filter-target || return 1; local str=$ret + local beg end; ble/complete/menu/get-active-range "$str" "$_ble_edit_ind" || return 1 + local input=${str:beg:end-beg} + [[ $input == "${_ble_complete_menu_comp[2]}" ]] && return 0 + local simple_flags simple_ibrace + if ! ble/syntax:bash/simple-word/reconstruct-incomplete-word "$input"; then + ble/syntax:bash/simple-word/is-never-word "$input" && return 1 + return 0 + fi + [[ $simple_ibrace ]] && ((${simple_ibrace%%:*}>10#0${_ble_complete_menu0_comp[6]%%:*})) && return 1 # 別のブレース展開要素に入った時 + ble/syntax:bash/simple-word/eval "$ret" single; (($?==148)) && return 148 + local COMPV=$ret + local comp_type=${_ble_complete_menu0_comp[4]} cand_pack + ble/complete/menu-filter/.filter-candidates; (($?==148)) && return 148 + local menu_common_part=$COMPV + ble/complete/menu/show update-items || return "$?" + _ble_complete_menu_comp=("$beg" "$end" "$input" "$COMPV" "$comp_type") + return 0 +} +function ble/complete/menu-filter.idle { + ble/util/idle.wait-user-input + [[ $bleopt_complete_menu_filter ]] || return 1 + [[ $_ble_complete_menu_active ]] || return 1 + ble/complete/menu-filter; local ext=$? + ((ext==148)) && return 148 + ((ext)) && ble/complete/menu/clear + return 0 +} +function ble/highlight/layer/buff#operate-gflags { + local BUFF=$1 beg=$2 end=$3 mask=$4 gflags=$5 + ((beg=0)); then + ((DMAX0<=obeg?(obeg+=DMAX-DMAX0):(DMIN=1)) || return 1 + local beg end; ble/complete/menu/get-active-range || return 1 + local opts=$1 + _ble_edit_mark=$beg + _ble_edit_ind=$end + local comps_fixed=${_ble_complete_menu0_comp[6]} + if [[ $comps_fixed ]]; then + local comps_fixed_length=${comps_fixed%%:*} + ((_ble_edit_mark+=comps_fixed_length)) + fi + if [[ :$opts: == *:insert_unique:* ]] && ((${#_ble_complete_menu_items[@]}==1)); then + ble/complete/menu#select 0 + ble/decode/keymap/push menu_complete + ble/widget/menu_complete/exit complete + return 0 + fi + _ble_complete_menu_original=${_ble_edit_str:beg:end-beg} + ble/complete/menu/redraw + if [[ :$opts: == *:backward:* ]]; then + ble/complete/menu#select "$((${#_ble_complete_menu_items[@]}-1))" + else + ble/complete/menu#select 0 + fi + _ble_edit_mark_active=insert + ble/decode/keymap/push menu_complete + return 0 +} +function ble/widget/menu_complete/exit { + local opts=$1 + ble/decode/keymap/pop + if ((_ble_complete_menu_selected>=0)); then + local new=${_ble_edit_str:_ble_complete_menu0_beg:_ble_edit_ind-_ble_complete_menu0_beg} + if [[ :$bleopt_complete_menu_complete_opts: != *:insert-selection:* ]]; then + local "${_ble_complete_cand_varnames[@]/%/=}" # WA #D1570 checked + ble/complete/cand/unpack "${_ble_complete_menu_items[_ble_complete_menu_selected]}" + new=$INSERT + fi + local old=$_ble_complete_menu_original + local comp_text=${_ble_edit_str::_ble_complete_menu0_beg}$old${_ble_edit_str:_ble_edit_ind} + local insert_beg=$_ble_complete_menu0_beg + local insert_end=$((_ble_complete_menu0_beg+${#old})) + local insert=$new + local insert_flags= + local suffix= + if [[ :$opts: == *:complete:* ]]; then + local icon=${_ble_complete_menu_page_icons[_ble_complete_menu_selected-_ble_complete_menu_page_offset]} + local icon_data=${icon#*:} icon_fields + ble/string#split icon_fields , "${icon%%:*}" + local pack=${icon_data::icon_fields[4]} + local ACTION=${pack%%:*} + if ble/is-function ble/complete/action:"$ACTION"/complete; then + local COMP1=${_ble_complete_menu0_comp[0]} + local COMP2=${_ble_complete_menu0_comp[1]} + local COMPS=${_ble_complete_menu0_comp[2]} + local COMPV=${_ble_complete_menu0_comp[3]} + local comp_type=${_ble_complete_menu0_comp[4]} + local comps_flags=${_ble_complete_menu0_comp[5]} + local comps_fixed=${_ble_complete_menu0_comp[6]} + local "${_ble_complete_cand_varnames[@]/%/=}" # WA #D1570 checked + ble/complete/cand/unpack "$pack" + ble/complete/action:"$ACTION"/complete + fi + ble/complete/insert "$_ble_complete_menu0_beg" "$_ble_edit_ind" "$insert" "$suffix" + fi + blehook/invoke complete_insert + fi + ble/complete/menu/clear + _ble_edit_mark_active= + _ble_complete_menu_original= +} +function ble/widget/menu_complete/cancel { + ble/decode/keymap/pop + ble/complete/menu#select -1 + _ble_edit_mark_active= + _ble_complete_menu_original= +} +function ble/widget/menu_complete/accept { + ble/widget/menu_complete/exit complete +} +function ble/widget/menu_complete/exit-default { + ble/widget/menu_complete/exit + ble/decode/widget/redispatch +} +_ble_complete_menu_switch_styles=(align-nowrap desc linewise dense-nowrap) +function ble/widget/menu_complete/switch-style { + local menu_style + if [[ $1 && $1 != [-+] ]]; then + menu_style=$1 + else + local ret nstyle=${#_ble_complete_menu_switch_styles[@]} shift=${1:-+}1 + if ble/array#index _ble_complete_menu_switch_styles "$_ble_complete_menu_style"; then + ((ret=(ret+shift+nstyle)%nstyle)) + else + ((ret=shift<0?nstyle-1:0)) + fi + menu_style=${_ble_complete_menu_switch_styles[ret]} + fi + [[ $menu_style != "$_ble_complete_menu_style" ]] || return 0 + _ble_complete_menu_style=$menu_style + bleopt complete_menu_style="$menu_style" + local sel=$_ble_complete_menu_selected + ble/complete/menu/show scroll="$sel" + ble/complete/menu#select "$sel" +} +function ble/widget/menu_complete/toggle-hidden { + if [[ :$_ble_complete_menu_opts: == *:hidden:* ]]; then + ble/opts#remove _ble_complete_menu_opts hidden + else + _ble_complete_menu_opts=$_ble_complete_menu_opts:hidden + fi + local sel=$_ble_complete_menu_selected + ble/complete/menu/show scroll="$sel" + ble/complete/menu#select "$sel" +} +function ble-decode/keymap:menu_complete/define { + ble-bind -f __default__ 'menu_complete/exit-default' + ble-bind -f __line_limit__ nop + ble-bind -f C-m 'menu_complete/accept' + ble-bind -f RET 'menu_complete/accept' + ble-bind -f C-g 'menu_complete/cancel' + ble-bind -f 'C-x C-g' 'menu_complete/cancel' + ble-bind -f 'C-M-g' 'menu_complete/cancel' + ble-bind -f C-f 'menu/forward-column' + ble-bind -f right 'menu/forward-column' + ble-bind -f C-i 'menu/forward cyclic' + ble-bind -f TAB 'menu/forward cyclic' + ble-bind -f C-b 'menu/backward-column' + ble-bind -f left 'menu/backward-column' + ble-bind -f C-S-i 'menu/backward cyclic' + ble-bind -f S-TAB 'menu/backward cyclic' + ble-bind -f C-n 'menu/forward-line' + ble-bind -f down 'menu/forward-line' + ble-bind -f C-p 'menu/backward-line' + ble-bind -f up 'menu/backward-line' + ble-bind -f prior 'menu/backward-page' + ble-bind -f next 'menu/forward-page' + ble-bind -f home 'menu/beginning-of-page' + ble-bind -f end 'menu/end-of-page' + ble-bind -f 'C-x SP' 'menu_complete/toggle-hidden' + ble-bind -f 'C-x right' 'menu_complete/switch-style +' + ble-bind -f 'C-x C-n' 'menu_complete/switch-style +' + ble-bind -f 'C-x left' 'menu_complete/switch-style -' + ble-bind -f 'C-x C-p' 'menu_complete/switch-style -' + ble-bind -f 'C-x a' 'menu_complete/switch-style align-nowrap' + ble-bind -f 'C-x c' 'menu_complete/switch-style dense-nowrap' + ble-bind -f 'C-x d' 'menu_complete/switch-style desc' + ble-bind -f 'C-x l' 'menu_complete/switch-style linewise' + local key + for key in {,M-,C-}{0..9}; do + ble-bind -f "$key" 'menu/append-arg' + done +} +_ble_complete_menu_arg= +function ble/widget/menu/append-arg { + [[ ${LASTWIDGET%%' '*} == */append-arg ]] || _ble_complete_menu_arg= + local i=${#KEYS[@]}; ((i&&i--)) + local flag=$((KEYS[i]&_ble_decode_MaskFlag)) + if ! [[ :$1: == *:always:* || flag -ne 0 || $_ble_complete_menu_arg ]]; then + ble/widget/menu_complete/exit-default + return "$?" + fi + local code=$((KEYS[i]&_ble_decode_MaskChar)) + ((48<=code&&code<=57)) || return 1 + local ret; ble/util/c2s "$code"; local ch=$ret + ((_ble_complete_menu_arg=10#0$_ble_complete_menu_arg$ch)) + local count=${#_ble_complete_menu_items[@]} + while ((_ble_complete_menu_arg>count)); do + ((_ble_complete_menu_arg=10#0${_ble_complete_menu_arg:1})) + done + if ! ((_ble_complete_menu_arg)); then + [[ :$1: == *:nobell:* ]] || + ble/widget/.bell 'menu: out of range' + return 0 + fi + ble/complete/menu#select "$((_ble_complete_menu_arg-1))" +} +function ble/widget/menu/append-arg/.is-argument { + local i=${#KEYS[@]}; ((i&&i--)) + local flag=$((KEYS[i]&_ble_decode_MaskFlag)) + local code=$((KEYS[i]&_ble_decode_MaskChar)) + [[ :$1: == *:always:* ]] || ((flag)) || return 1 + ((48<=code&&code<=57)) +} +function ble/complete/auto-complete/initialize { + local ret + ble-decode-kbd/generate-keycode auto_complete_enter + _ble_complete_KCODE_ENTER=$ret +} +ble/complete/auto-complete/initialize +function ble/highlight/layer:region/mark:auto_complete/get-face { + face=auto_complete +} +_ble_complete_ac_type= +_ble_complete_ac_comp1= +_ble_complete_ac_cand= +_ble_complete_ac_word= +_ble_complete_ac_insert= +_ble_complete_ac_suffix= +function ble/complete/auto-complete/enter { + local type=$1 COMP1=$2 suggest=$3 cand=$4 word=$5 insert1=${6-$5} suffix=${7-} + local limit=$((bleopt_line_limit_length)) + if ((limit&&${#_ble_edit_str}+${#suggest}>limit)); then + return 1 + fi + local insert; ble-edit/content/replace-limited "$_ble_edit_ind" "$_ble_edit_ind" "$suggest" nobell + ((_ble_edit_mark=_ble_edit_ind+${#suggest})) + _ble_complete_ac_type=$type + _ble_complete_ac_comp1=$COMP1 + _ble_complete_ac_cand=$cand + _ble_complete_ac_word=$word + _ble_complete_ac_insert=$insert1 + _ble_complete_ac_suffix=$suffix + _ble_edit_mark_active=auto_complete + ble/decode/keymap/push auto_complete + ble-decode-key "$_ble_complete_KCODE_ENTER" # dummy key input to record keyboard macros + return 0 +} +function ble/complete/auto-complete/source:history/.search-light { + [[ $_ble_history_prefix ]] && return 1 + local text=$1 + [[ ! $text ]] && return 1 + local wordbreaks="<>();&|:$_ble_term_IFS" + local word= expand + if [[ $text != [-0-9#?!]* ]]; then + word=${text%%[$wordbreaks]*} + command='!'$word ble/util/assign expand 'ble/edit/histexpand/run' &>/dev/null || return 1 + if [[ $expand == "$text"* ]]; then + ret=$expand + return 0 + fi + fi + if [[ $word != "$text" ]]; then + local fragments; ble/string#split fragments '?' "$text" + local frag longest_fragments len=0; longest_fragments=('') + for frag in "${fragments[@]}"; do + local len1=${#frag} + ((len1>len&&(len=len1))) && longest_fragments=() + ((len1==len)) && ble/array#push longest_fragments "$frag" + done + for frag in "${longest_fragments[@]}"; do + command='!?'$frag ble/util/assign expand 'ble/edit/histexpand/run' &>/dev/null || return 1 + [[ $expand == "$text"* ]] || continue + ret=$expand + return 0 + done + fi + return 1 +} +_ble_complete_ac_history_needle= +_ble_complete_ac_history_index= +_ble_complete_ac_history_start= +function ble/complete/auto-complete/source:history/.search-heavy { + local text=$1 + local count; ble/history/get-count -v count + local start=$((count-1)) + local index=$((count-1)) + local needle=$text + ((start==_ble_complete_ac_history_start)) && + [[ $needle == "$_ble_complete_ac_history_needle"* ]] && + index=$_ble_complete_ac_history_index + local isearch_time=0 isearch_ntask=1 + local isearch_opts=head + [[ :$comp_type: == *:sync:* ]] || isearch_opts=$isearch_opts:stop_check + ble/history/isearch-backward-blockwise "$isearch_opts"; local ext=$? + _ble_complete_ac_history_start=$start + _ble_complete_ac_history_index=$index + _ble_complete_ac_history_needle=$needle + ((ext)) && return "$ext" + ble/history/get-edited-entry -v ret "$index" + return 0 +} +function ble/complete/auto-complete/source:history/.impl { + local opts=$1 + local searcher=.search-heavy + [[ :$opts: == *:light:* ]] && searcher=.search-light + local ret + ((_ble_edit_ind==${#_ble_edit_str})) || return 1 + ble/complete/auto-complete/source:history/"$searcher" "$_ble_edit_str" || return "$?" # 0, 1 or 148 + local command=$ret + [[ $command == "$_ble_edit_str" ]] && return 1 + ble/complete/auto-complete/enter h 0 "${command:${#_ble_edit_str}}" '' "$command" +} +function ble/complete/auto-complete/source:history { + [[ $bleopt_complete_auto_history ]] || return 1 + ble/complete/auto-complete/source:history/.impl light; local ext=$? + ((ext==0||ext==148)) && return "$ext" + [[ $_ble_history_prefix || $_ble_history_load_done ]] && + ble/complete/auto-complete/source:history/.impl; local ext=$? + ((ext==0||ext==148)) && return "$ext" +} +function ble/complete/auto-complete/source:syntax { + local sources + ble/complete/context:syntax/generate-sources "$comp_text" "$comp_index" && + ble/complete/context/filter-prefix-sources || return 1 + local bleopt_complete_contract_function_names= + local bleopt_complete_menu_style=$bleopt_complete_menu_style # source local settings + ((bleopt_complete_polling_cycle>25)) && + local bleopt_complete_polling_cycle=25 + local COMP1 COMP2 COMPS COMPV + local comps_flags comps_fixed + local cand_count cand_cand cand_word cand_pack + local cand_limit_reached= + ble/complete/candidates/generate; local ext=$? + [[ $COMPV ]] || return 1 + ((ext)) && return "$ext" + ((cand_count)) || return 1 + local word=${cand_word[0]} cand=${cand_cand[0]} + [[ $word == "$COMPS" ]] && return 1 + local insert=$word suffix= + local ACTION=${cand_pack[0]%%:*} + if ble/is-function ble/complete/action:"$ACTION"/complete; then + local "${_ble_complete_cand_varnames[@]/%/=}" # WA #D1570 checked + ble/complete/cand/unpack "${cand_pack[0]}" + local insert_beg=$COMP1 insert_end=$COMP2 insert_flags= + ble/complete/action:"$ACTION"/complete + fi + local type= suggest= + if [[ $insert == "$COMPS"* ]]; then + [[ ${comp_text:COMP1} == "$insert"* ]] && return 1 + type=c + suggest="${insert:${#COMPS}}" + else + case :$comp_type: in + (*:a:*) type=a ;; + (*:m:*) type=m ;; + (*:A:*) type=A ;; + (*) type=r ;; + esac + suggest=" [$insert] " + fi + ble/complete/auto-complete/enter "$type" "$COMP1" "$suggest" "$cand" "$word" "$insert" "$suffix" +} +_ble_complete_auto_source=(history syntax) +function ble/complete/auto-complete.impl { + local opts=$1 + local comp_type=auto + [[ :$opts: == *:sync:* ]] && comp_type=${comp_type}:sync + local comp_text=$_ble_edit_str comp_index=$_ble_edit_ind + [[ $comp_text ]] || return 0 + if local beg end; ble/complete/menu/get-active-range "$_ble_edit_str" "$_ble_edit_ind"; then + ((_ble_edit_ind0)) || return 1 + case $_ble_decode_widget_last in + (ble/widget/self-insert|ble/widget/magic-slash) ;; + (ble/widget/complete) ;; + (ble/widget/vi_imap/complete) ;; + (ble/widget/auto_complete/self-insert) ;; + (*) return 0 ;; + esac + [[ $_ble_edit_str ]] || return 0 + local until=$((_ble_idle_clock_start+bleopt_complete_auto_menu)) + ble/util/idle.sleep-until "$until" checked && return 0 + ble/widget/complete auto_menu:show_menu:no-empty:no-bell +} +ble/function#try ble/util/idle.push-background ble/complete/auto-complete.idle +ble/function#try ble/util/idle.push-background ble/complete/auto-menu.idle +function ble/widget/auto-complete-enter { + ble/complete/auto-complete.impl sync +} +function ble/widget/auto_complete/cancel { + ble/decode/keymap/pop + ble-edit/content/replace "$_ble_edit_ind" "$_ble_edit_mark" '' + _ble_edit_mark=$_ble_edit_ind + _ble_edit_mark_active= + _ble_complete_ac_insert= + _ble_complete_ac_suffix= +} +function ble/widget/auto_complete/insert { + ble/decode/keymap/pop + ble-edit/content/replace "$_ble_edit_ind" "$_ble_edit_mark" '' + _ble_edit_mark=$_ble_edit_ind + local comp_text=$_ble_edit_str + local insert_beg=$_ble_complete_ac_comp1 + local insert_end=$_ble_edit_ind + local insert=$_ble_complete_ac_insert + local suffix=$_ble_complete_ac_suffix + ble/complete/insert "$insert_beg" "$insert_end" "$insert" "$suffix" + blehook/invoke complete_insert + _ble_edit_mark_active= + _ble_complete_ac_insert= + _ble_complete_ac_suffix= + ble/complete/menu/clear + ble-edit/content/clear-arg + return 0 +} +function ble/widget/auto_complete/cancel-default { + ble/widget/auto_complete/cancel + ble/decode/widget/redispatch +} +function ble/widget/auto_complete/self-insert/.is-magic-space { + ((${#KEYS[@]}==1)) || return 1 + local ikeymap=$((${#_ble_decode_keymap_stack[@]}-1)) + ((ikeymap>=0)) || return 1 + local dicthead=_ble_decode_${_ble_decode_keymap_stack[ikeymap]}_kmap_ + builtin eval "local ent=\${$dicthead$_ble_decode_key__seq[KEYS[0]]-}" + local command=${ent#*:} + [[ $command == ble/widget/magic-space || $command == ble/widget/magic-slash ]] +} +function ble/widget/auto_complete/self-insert { + if [[ $_ble_edit_overwrite_mode ]] || ble/widget/auto_complete/self-insert/.is-magic-space; then + ble/widget/auto_complete/cancel-default + return "$?" + fi + local code; ble/widget/self-insert/.get-code + ((code==0)) && return 0 + local ret + ble/util/c2s "$code"; local ins=$ret + local comps_cur=${_ble_edit_str:_ble_complete_ac_comp1:_ble_edit_ind-_ble_complete_ac_comp1} + local comps_new=$comps_cur$ins + local processed= + if [[ $_ble_complete_ac_type == [ch] ]]; then + if [[ $_ble_complete_ac_word == "$comps_new"* ]]; then + ((_ble_edit_ind+=${#ins})) + [[ $_ble_complete_ac_word == "$comps_new" ]] && ble/widget/auto_complete/cancel + processed=1 + fi + elif [[ $_ble_complete_ac_type == [rmaA] && $ins != [{,}] ]]; then + if local ret simple_flags simple_ibrace; ble/syntax:bash/simple-word/reconstruct-incomplete-word "$comps_new"; then + if ble/complete/source/eval-simple-word "$ret" single && local compv_new=$ret; then + local filter_type=head + case $_ble_complete_ac_type in + (*m*) filter_type=substr ;; + (*a*) filter_type=hsubseq ;; + (*A*) filter_type=subseq ;; + esac + local comps_fixed= + local comp_filter_type + local comp_filter_pattern + ble/complete/candidates/filter#init "$filter_type" "$compv_new" + if ble/complete/candidates/filter#test "$_ble_complete_ac_cand"; then + local insert; ble-edit/content/replace-limited "$_ble_edit_ind" "$_ble_edit_ind" "$ins" + ((_ble_edit_ind+=${#insert},_ble_edit_mark+=${#insert})) + [[ $_ble_complete_ac_cand == "$compv_new" ]] && + ble/widget/auto_complete/cancel + processed=1 + fi + fi + fi + fi + if [[ $processed ]]; then + local comp_text= insert_beg=0 insert_end=0 insert=$ins suffix= + blehook/invoke complete_insert + return 0 + else + ble/widget/auto_complete/cancel + ble/decode/widget/redispatch + fi +} +function ble/widget/auto_complete/@end { + if ((_ble_edit_mark!=${#_ble_edit_str})); then + ble/widget/auto_complete/cancel-default + else + ble/widget/auto_complete/"$@" + fi +} +function ble/widget/auto_complete/insert-on-end { + ble/widget/auto_complete/@end insert +} +function ble/widget/auto_complete/.insert-prefix { + local ins + if [[ $_ble_complete_ac_type == [ch] ]]; then + ins=${_ble_edit_str:_ble_edit_ind:_ble_edit_mark-_ble_edit_ind} + else + ins=$_ble_complete_ac_insert + fi + local ret + ble/complete/auto-complete/insert-prefix:"$1" "$ins" "${@:2}" + local prefix=$ret + [[ $prefix || ! $ins ]] || return 1 + if [[ $_ble_complete_ac_type == [ch] ]]; then + if [[ $prefix == "$ins" ]]; then + ble/widget/auto_complete/insert + return 0 + else + local ins=$prefix + ((_ble_edit_ind+=${#ins})) + local comp_text=$_ble_edit_str + local insert_beg=$_ble_complete_ac_comp1 + local insert_end=$_ble_edit_ind + local insert=${_ble_edit_str:insert_beg:insert_end-insert_beg}$ins + local suffix= + blehook/invoke complete_insert + return 0 + fi + elif [[ $_ble_complete_ac_type == [rmaA] ]]; then + if [[ $prefix == "$ins" ]]; then + ble/widget/auto_complete/insert + return 0 + else + local ins=$prefix + _ble_complete_ac_type=c + ble-edit/content/replace "$_ble_complete_ac_comp1" "$_ble_edit_mark" "$_ble_complete_ac_insert" + ((_ble_edit_ind=_ble_complete_ac_comp1+${#ins}, + _ble_edit_mark=_ble_complete_ac_comp1+${#_ble_complete_ac_insert})) + local comp_text=$_ble_edit_str + local insert_beg=$_ble_complete_ac_comp1 + local insert_end=$_ble_edit_ind + local insert=$ins + local suffix= + blehook/invoke complete_insert + return 0 + fi + fi + return 1 +} +function ble/complete/auto-complete/insert-prefix:word { + local breaks=${bleopt_complete_auto_wordbreaks:-$_ble_term_IFS} + local rex='^['$breaks']*([^'$breaks']+['$breaks']*)?' + [[ $1 =~ $rex ]] + ret=$BASH_REMATCH +} +function ble/widget/auto_complete/insert-word { + ble/widget/auto_complete/.insert-prefix word +} +function ble/complete/auto-complete/insert-prefix:xword { + local wtype=$2 word_class word_set word_sep + ble/edit/word:"$wtype"/setup + local x=0 y=0 + _ble_edit_str=$1 ble/edit/word/forward-range 1 + ret=${1::y?y:${#1}} +} +function ble/widget/auto_complete/insert-eword { ble/widget/auto_complete/.insert-prefix xword eword; } +function ble/widget/auto_complete/insert-cword { ble/widget/auto_complete/.insert-prefix xword cword; } +function ble/widget/auto_complete/insert-uword { ble/widget/auto_complete/.insert-prefix xword uword; } +function ble/widget/auto_complete/insert-sword { ble/widget/auto_complete/.insert-prefix xword sword; } +function ble/widget/auto_complete/insert-fword { ble/widget/auto_complete/.insert-prefix xword fword; } +function ble/widget/auto_complete/accept-line { + ble/widget/auto_complete/insert + ble-decode-key 13 +} +function ble/widget/auto_complete/notify-enter { + ble/decode/widget/skip-lastwidget +} +function ble-decode/keymap:auto_complete/define { + ble-bind -f __defchar__ auto_complete/self-insert + ble-bind -f __default__ auto_complete/cancel-default + ble-bind -f __line_limit__ nop + ble-bind -f 'C-g' auto_complete/cancel + ble-bind -f 'C-x C-g' auto_complete/cancel + ble-bind -f 'C-M-g' auto_complete/cancel + ble-bind -f S-RET auto_complete/insert + ble-bind -f S-C-m auto_complete/insert + ble-bind -f C-f 'auto_complete/@end insert' + ble-bind -f right 'auto_complete/@end insert' + ble-bind -f C-e 'auto_complete/@end insert' + ble-bind -f end 'auto_complete/@end insert' + ble-bind -f M-f 'auto_complete/@end insert-cword' + ble-bind -f C-right 'auto_complete/@end insert-cword' + ble-bind -f M-right 'auto_complete/@end insert-word' + ble-bind -f C-j auto_complete/accept-line + ble-bind -f C-RET auto_complete/accept-line + ble-bind -f auto_complete_enter auto_complete/notify-enter +} +function ble/complete/sabbrev/.initialize-print { + sgr0= sgr1= sgr2= sgr3= sgro= + if [[ $flags == *c* || $flags != *n* && -t 1 ]]; then + local ret + ble/color/face2sgr command_function; sgr1=$ret + ble/color/face2sgr syntax_varname; sgr2=$ret + ble/color/face2sgr syntax_quoted; sgr3=$ret + ble/color/face2sgr argument_option; sgro=$ret + sgr0=$_ble_term_sgr0 + fi +} +function ble/complete/sabbrev/.print-definition { + local key=$1 type=${2%%:*} value=${2#*:} + local option= + [[ $type != w ]] && option=$sgro'-'$type$sgr0' ' + local ret + ble/string#quote-word "$key" quote-empty:sgrq="$sgr3":sgr0="$sgr2" + key=$sgr2$ret$sgr0 + ble/string#quote-word "$value" sgrq="$sgr3":sgr0="$sgr0" + value=$ret + ble/util/print "${sgr1}ble-sabbrev$sgr0 $option$key=$value" +} +function ble/complete/sabbrev/register { + local key=$1 value=$2 + ((_ble_complete_sabbrev_version++)) + ble/gdict#set _ble_complete_sabbrev "$key" "$value" +} +function ble/complete/sabbrev/list { + local type=$1; shift + local keys ret; keys=("$@") + if ((${#keys[@]}==0)); then + if [[ $type ]]; then + local ret key + ble/gdict#keys _ble_complete_sabbrev + for key in "${ret[@]}"; do + ble/gdict#get _ble_complete_sabbrev "$key" && [[ $ret == "$type":* ]] || continue + ble/array#push keys "$key" + done + else + ble/gdict#keys _ble_complete_sabbrev + keys=("${ret[@]}") + fi + ((${#keys[@]})) || return 0 + fi + local sgr0 sgr1 sgr2 sgr3 sgro + ble/complete/sabbrev/.initialize-print + local key ext=0 + for key in "${keys[@]}"; do + if ble/gdict#get _ble_complete_sabbrev "$key"; then + ble/complete/sabbrev/.print-definition "$key" "$ret" + else + ble/util/print "ble-sabbrev: $key: not found." >&2 + ext=1 + fi + done + return "$ext" +} +function ble/complete/sabbrev/reset { + local type=$1; shift + if (($#)); then + local key + for key; do + ble/gdict#unset _ble_complete_sabbrev "$key" + done + ((_ble_complete_sabbrev_version++)) + elif [[ $type ]]; then + local ret key + ble/gdict#keys _ble_complete_sabbrev + if ((${#ret[@]})); then + for key in "${ret[@]}"; do + ble/gdict#get _ble_complete_sabbrev "$key" && [[ $ret == "$type":* ]] || continue + ble/gdict#unset _ble_complete_sabbrev "$key" + done + ((_ble_complete_sabbrev_version++)) + fi + else + ble/gdict#clear _ble_complete_sabbrev + ((_ble_complete_sabbrev_version++)) + fi + return 0 +} +function ble/complete/sabbrev#get { + local key=$1 + ble/gdict#get _ble_complete_sabbrev "$key" && + [[ ! ${2-} || $ret == ["$2"]:* ]] +} +function ble/complete/sabbrev#get-keys { + keys=() + local type=${1-} ret + ble/gdict#keys _ble_complete_sabbrev + if [[ $type ]]; then + local key + for key in "${ret[@]}"; do + ble/gdict#get _ble_complete_sabbrev "$key" && + [[ $ret == ["$type"]:* ]] && + ble/array#push keys "$key" + done + else + keys=("${ret[@]}") + fi +} +function ble/complete/sabbrev/wordwise.get-keys { + ble/complete/sabbrev#get-keys 'wm' +} +_ble_complete_sabbrev_suffix_regex=() +function ble/complete/sabbrev/suffix.construct-regex { + if [[ ${_ble_complete_sabbrev_suffix_regex[1]} != "$_ble_complete_sabbrev_version" ]]; then + local keys out= + ble/complete/sabbrev#get-keys 's' + if ((${#keys[@]})); then + local key + for key in "${keys[@]}"; do + if [[ $key ]]; then + ble/string#escape-for-extended-regex "$key" + out=${out:+$out'|'}$ret + fi + done + fi + _ble_complete_sabbrev_suffix_regex[0]=${out:+'\.('$out')$'} + _ble_complete_sabbrev_suffix_regex[1]=$_ble_complete_sabbrev_version + fi + ret=${_ble_complete_sabbrev_suffix_regex[0]} + [[ $ret ]] +} +function ble/complete/sabbrev/literal.find { + local str=$1 opts=$2 + ble/complete/sabbrev#match "$str" 'il' "$opts" +} +function ble/complete/sabbrev/suffix.is-normal-command { + ble/bin#has "$1" || + { ble/util/joblist.check; jobs -- "$1" &>/dev/null; } || + { [[ -d $1 ]] && shopt -q autocd &>/dev/null; } +} +function ble/complete/sabbrev/suffix.find { + key1= ent1= + local file=$1 opts=$2 ret + [[ :$opts: != *:literal:* ]] && + ble/syntax:bash/simple-word/safe-eval "$file" && + file=$ret + [[ $file == *.* ]] || return 1 + ble/complete/sabbrev/suffix.is-normal-command "$file" && return 1 + ble/complete/sabbrev#match "$file" 's' "$opts" +} +function ble/complete/sabbrev#match { + key1= ent1= + local target=$1 type=$2 opts=$3 keys + ble/complete/sabbrev#get-keys "$type" + local key2 ent2 ret + for key2 in "${keys[@]}"; do + ((${#key2}>${#key1})) || continue + ble/gdict#get _ble_complete_sabbrev "$key2" || continue; ent2=$ret + case $ent2 in + (i:*) [[ $target == *"$key2" ]] ;; + (l:*) [[ $target == *"$key2" ]] && ble/string#match "${target%"$key2"}" $'(^|\n)[ \t]*$' ;; + (s:*) [[ $target == *."$key2" ]] ;; + (*) [[ $target == "$key2" ]] ;; + esac || continue + [[ :$opts: == *:filter-by-patterns:* ]] && + ((${#patterns[@]})) && + ! ble/complete/string#match-patterns "$key2" "${patterns[@]}" && + continue + key1=$key2 ent1=$ent2 + done + [[ $key1 ]] +} +function ble/complete/sabbrev/read-arguments/.set-type { + local new_type + case $1 in + (--type=wordwise | -w) new_type=w ;; + (--type=dynamic | -m) new_type=m ;; + (--type=inline | -i) new_type=i ;; + (--type=linewise | -l) new_type=l ;; + (--type=suffix | -s) new_type=s ;; + (*) + ble/util/print "ble-sabbrev: unknown sabbrev type '${1#--type=}'." >&2 + flags=E$flags + return 1 ;; + esac + if [[ $type && $type != "$new_type" ]]; then + ble/util/print "ble-sabbrev: arg $1: a conflicting sabbrev type (-$type) has already been specified." >&2 + flags=E$flags + fi + type=$new_type +} +function ble/complete/sabbrev/read-arguments { + specs=() print=() + flags= type= + while (($#)); do + local arg=$1; shift + if [[ $flags != L && $arg == -* ]]; then + case $arg in + (--) + flags=L$flags ;; + (--help) + flags=H$flags ;; + (--reset) + flags=r$flags + (--color|--color=always) + flags=c${flags//[cn]} ;; + (--color=never) + flags=n${flags//[cn]} ;; + (--color=auto) + flags=${flags//[cn]} ;; + (--color=*) + ble/util/print "ble-sabbrev: unknown color type '$arg'." >&2 + flags=E$flags ;; + (--type=*) + ble/complete/sabbrev/read-arguments/.set-type "$arg" ;; + (--type) + if ((!$#)); then + ble/util/print "ble-sabbrev: option argument for '$arg' is missing" >&2 + flags=E$flags + else + ble/complete/sabbrev/read-arguments/.set-type "--type=$1"; shift + fi ;; + (--*) + ble/util/print "ble-sabbrev: unknown option '$arg'." >&2 + flags=E$flags ;; + (-*) + local i n=${#arg} c + for ((i=1;i&2 + flags=E$flags ;; + esac + done ;; + esac + else + if [[ $arg == ?*=* ]]; then + ble/array#push specs "$arg" + else + ble/array#push print "$arg" + fi + fi + done + return 0 +} +function ble/complete/sabbrev { + local flags type specs print + ble/complete/sabbrev/read-arguments "$@" + if [[ $flags == *H* || $flags == *E* ]]; then + [[ $flags == *E* ]] && ble/util/print + ble/util/print-lines \ + 'usage: ble-sabbrev [--type=TYPE|-wmils] [KEY=VALUE]...' \ + 'usage: ble-sabbrev [-r|--reset] [--type=TYPE|-wmils|KEY...]' \ + 'usage: ble-sabbrev [--color[=auto|always|never]] [--type=TYPE|-wmils|KEY...]' \ + 'usage: ble-sabbrev --help' \ + ' Register sabbrev expansion.' \ + '' \ + 'OPTIONS' \ + ' -w, --type=wordwise replace matching word.' \ + ' -m, --type=dynamic run command and replace matching word.' \ + ' -i, --type=inline replace matching suffix.' \ + ' -l, --type=linewise replace matching line.' \ + ' -s, --type=suffix replace word with extension in the command position.' \ + '' \ + ' -r, --reset remove specified set of sabbrev.' \ + '' \ + ' --color=always enable color output.' \ + ' --color=never disable color output.' \ + ' --color, --color=auto automatically determine color output (default).' \ + '' + [[ ! $flags == *E* ]]; return "$?" + fi + local ext=0 + if ((${#specs[@]}==0||${#print[@]})); then + if [[ $flags == *r* ]]; then + ble/complete/sabbrev/reset "$type" "${print[@]}" + else + ble/complete/sabbrev/list "$type" "${print[@]}" + fi || ext=$? + fi + local spec key value + for spec in "${specs[@]}"; do + key=${spec%%=*} value=${spec#*=} + ble/complete/sabbrev/register "$key" "${type:-w}:$value" + done + return "$ext" +} +function ble-sabbrev { + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_local_adjust" + ble/complete/sabbrev "$@" + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_local_return" +} +function ble/complete/sabbrev/locate-key { + pos=$comp_index + local rex_source_type='^('$1')$' + local sources src asrc + ble/complete/context:syntax/generate-sources + for src in "${sources[@]}"; do + ble/string#split-words asrc "$src" + [[ ${asrc[0]} =~ $rex_source_type ]] || continue + if [[ ${asrc[0]} == argument ]]; then + local wtype=$_ble_attr_VAR wbeg=${asrc[1]} wlen=$((comp_index-asrc[1])) ret + ble/syntax:bash/find-rhs "$wtype" "$wbeg" "$wlen" long-option && + asrc[0]=rhs asrc[1]=$ret + fi + if [[ ${asrc[0]} == rhs ]]; then + local rex_element + ble/syntax:bash/simple-word/get-rex_element : + local rex='^:*('$rex_element':+)' + [[ ${_ble_edit_str:asrc[1]:comp_index-asrc[1]} =~ $rex ]] && + ((asrc[1]+=${#BASH_REMATCH})) + fi + ((asrc[1]${#key})) && key=$key1 ent=$ret pos_wbegin=$pos + fi + if [[ :$opts: == *:suffix:* ]]; then + local pos key1 ent1 + ble/complete/sabbrev/locate-key 'command' && + ble/complete/sabbrev/suffix.find "${_ble_edit_str:pos:comp_index-pos}" filter-by-patterns && + ((${#key1}>${#key})) && key=$key1 ent=$ent1 pos_wbegin=$pos + fi + if [[ :$opts: == *:literal:* ]]; then + local key1 ent1 + ble/complete/sabbrev/literal.find "${_ble_edit_str::comp_index}" filter-by-patterns && + ((${#key1}>${#key})) && key=$key1 ent=$ent1 + fi + [[ $key ]] || return 1 + local type=${ent%%:*} value=${ent#*:} + local exit=0 + if [[ :$opts: == *:type-status:* ]]; then + local ret + ble/util/s2c "$type" + exit=$ret + fi + case $type in + ([wil]) + [[ :$opts: == *:strip-slash:* ]] && value=${value%/} + local pos=$((comp_index-${#key})) + ble/widget/.replace-range "$pos" "$comp_index" "$value" + ((_ble_edit_ind=pos+${#value})) ;; + (s) + ble/widget/.replace-range "$pos_wbegin" "$pos_wbegin" "$value " + ((_ble_edit_ind=comp_index+${#value}+1)) ;; + (m) + local pos=$pos_wbegin + local comp_type= comps_flags= comps_fixed= + local COMP1=$pos COMP2=$pos COMPS=$key COMPV= + ble/complete/candidates/comp_type#read-rl-variables + local flag_force_fignore= + local flag_source_filter=1 + local cand_count cand_cand cand_word cand_pack + ble/complete/candidates/clear + local COMP_PREFIX= + local bleopt_sabbrev_menu_style=$bleopt_complete_menu_style + local bleopt_sabbrev_menu_opts= + local -a COMPREPLY=() + builtin eval -- "$value" + local cand action=word "${_ble_complete_yield_varnames[@]/%/=}" # WA #D1570 checked + ble/complete/cand/yield.initialize "$action" + for cand in "${COMPREPLY[@]}"; do + ble/complete/cand/yield "$action" "$cand" "" + done + if ((cand_count==0)); then + return 1 + elif ((cand_count==1)); then + local value=${cand_word[0]} + [[ :$opts: == *:strip-slash:* ]] && value=${value%/} + ble/widget/.replace-range "$pos" "$comp_index" "$value" + ((_ble_edit_ind=pos+${#value})) + return "$exit" + fi + ble/widget/.replace-range "$pos" "$comp_index" '' + local bleopt_complete_menu_style=$bleopt_sabbrev_menu_style + local menu_common_part= + ble/complete/menu/show init || return "$?" + [[ :$bleopt_sabbrev_menu_opts: == *:enter_menu:* ]] && + ble/complete/menu-complete/enter "$bleopt_sabbrev_menu_opts" + return 147 ;; + (*) return 1 ;; + esac + return "$exit" +} +function ble/widget/sabbrev-expand { + ble/complete/sabbrev/expand; local ext=$? + ((ext)) && ble/widget/.bell + return "$ext" +} +function ble/complete/action:sabbrev/initialize { CAND=$value; } +function ble/complete/action:sabbrev/complete { return 0; } +function ble/complete/action:sabbrev/init-menu-item { + local ret; ble/color/face2g command_alias; g=$ret + show=$INSERT +} +function ble/complete/action:sabbrev/get-desc { + local ret; ble/complete/sabbrev#get "$INSERT" + desc="$desc_sgrt(sabbrev)$desc_sgr0 $ret" +} +function ble/complete/source:sabbrev { + local opts=$bleopt_complete_source_sabbrev_opts + [[ ! $COMPS && :$opts: == *:no-empty-completion:* ]] && return 1 + local keys; ble/complete/sabbrev/wordwise.get-keys "$opts" + local filter_type=$comp_filter_type + [[ $filter_type == none ]] && filter_type=head + local comps_fixed= + local comp_filter_type + local comp_filter_pattern + ble/complete/candidates/filter#init "$filter_type" "$COMPS" + local cand action=sabbrev "${_ble_complete_yield_varnames[@]/%/=}" # WA #D1570 checked + ble/complete/cand/yield.initialize "$action" + for cand in "${keys[@]}"; do + ble/complete/candidates/filter#test "$cand" || continue + ble/complete/string#match-patterns "$cand" "${_ble_complete_source_sabbrev_ignore[@]}" && continue + local ret simple_flags simple_ibrace + ble/syntax:bash/simple-word/reconstruct-incomplete-word "$cand" && + ble/complete/source/eval-simple-word "$ret" single || continue + local value=$ret # referenced in "ble/complete/action:sabbrev/initialize" + local flag_source_filter=1 + ble/complete/cand/yield "$action" "$cand" + done +} +function ble/complete/expand:alias { + local pos comp_index=$_ble_edit_ind comp_text=$_ble_edit_str + ble/complete/sabbrev/locate-key 'command' + ((pos=0)) || ble/history/get-count -v start + else + local start index pos; builtin eval -- "$fib_suspend" + fib_suspend= + fi + local dabbrev_match= + local dabbrev_pos=$pos + local dabbrev_current_match=${_ble_edit_str:_ble_edit_mark:_ble_edit_ind-_ble_edit_mark} + local line; ble/history/get-edited-entry -v line "$index" + if ! ble/complete/dabbrev/search-in-history-entry "$line" "$index"; then + ((index--,dabbrev_pos=0)) + local isearch_time=0 + local isearch_opts=stop_check:cyclic + isearch_opts=$isearch_opts:condition + local dabbrev_original=$_ble_complete_dabbrev_original + local dabbrev_regex1=$_ble_complete_dabbrev_regex1 + local needle='[[ $LINE =~ $dabbrev_regex1 ]] && ble/complete/dabbrev/search-in-history-entry "$LINE" "$INDEX"' + [[ $dabbrev_original ]] && needle='[[ $LINE == *"$dabbrev_original"* ]] && '$needle + isearch_opts=$isearch_opts:progress + local isearch_progress_callback=ble/complete/dabbrev/.show-status.fib + ble/history/isearch-backward-blockwise "$isearch_opts"; local ext=$? + ((ext==148)) && fib_suspend="start=$start index=$index pos=$pos" + if ((ext)); then + if ((${#_ble_complete_dabbrev_stack[@]})); then + ble/widget/.bell # 周回したので鳴らす + return 0 + else + return "$ext" + fi + fi + fi + local rec=$_ble_complete_dabbrev_index,$_ble_complete_dabbrev_pos,$_ble_edit_ind,$_ble_edit_mark + ble/array#push _ble_complete_dabbrev_stack "$rec:$_ble_edit_str" + local insert; ble-edit/content/replace-limited "$_ble_edit_mark" "$_ble_edit_ind" "$dabbrev_match" + ((_ble_edit_ind=_ble_edit_mark+${#insert})) + ((index>_ble_complete_dabbrev_index)) && + ble/widget/.bell # 周回 + _ble_complete_dabbrev_index=$index + _ble_complete_dabbrev_pos=$dabbrev_match_pos + ble/textarea#redraw +} +function ble/complete/dabbrev/next.fib { + ble/complete/dabbrev/.search.fib; local ext=$? + if ((ext==0)); then + _ble_edit_mark_active=insert + ble/complete/dabbrev/.show-status.fib + elif ((ext==148)); then + ble/complete/dabbrev/.show-status.fib + else + ble/widget/.bell + ble/widget/dabbrev/exit + ble/complete/dabbrev/reset + fib_kill=1 + fi + return "$ext" +} +function ble/widget/dabbrev-expand { + ble/complete/dabbrev/initialize-variables + ble/decode/keymap/push dabbrev + ble/util/fiberchain#initialize ble/complete/dabbrev + ble/util/fiberchain#push next + ble/util/fiberchain#resume +} +function ble/widget/dabbrev/next { + ble/util/fiberchain#push next + ble/util/fiberchain#resume +} +function ble/widget/dabbrev/prev { + if ((${#_ble_util_fiberchain[@]})); then + local ret; ble/array#pop _ble_util_fiberchain + if ((${#_ble_util_fiberchain[@]})); then + ble/util/fiberchain#resume + else + ble/complete/dabbrev/show-status + fi + elif ((${#_ble_complete_dabbrev_stack[@]})); then + local ret; ble/array#pop _ble_complete_dabbrev_stack + local rec str=${ret#*:} + ble/string#split rec , "${ret%%:*}" + ble-edit/content/reset-and-check-dirty "$str" + _ble_edit_ind=${rec[2]} + _ble_edit_mark=${rec[3]} + _ble_complete_dabbrev_index=${rec[0]} + _ble_complete_dabbrev_pos=${rec[1]} + ble/complete/dabbrev/show-status + else + ble/widget/.bell + return 1 + fi +} +function ble/widget/dabbrev/cancel { + if ((${#_ble_util_fiberchain[@]})); then + ble/util/fiberchain#clear + ble/complete/dabbrev/show-status + else + ble/widget/dabbrev/exit + ble/complete/dabbrev/reset + fi +} +function ble/widget/dabbrev/exit { + ble/decode/keymap/pop + _ble_edit_mark_active= + ble/complete/dabbrev/erase-status +} +function ble/widget/dabbrev/exit-default { + ble/widget/dabbrev/exit + ble/decode/widget/redispatch +} +function ble/widget/dabbrev/accept-line { + ble/widget/dabbrev/exit + ble-decode-key 13 +} +function ble-decode/keymap:dabbrev/define { + ble-bind -f __default__ 'dabbrev/exit-default' + ble-bind -f __line_limit__ nop + ble-bind -f 'C-g' 'dabbrev/cancel' + ble-bind -f 'C-x C-g' 'dabbrev/cancel' + ble-bind -f 'C-M-g' 'dabbrev/cancel' + ble-bind -f C-r 'dabbrev/next' + ble-bind -f C-s 'dabbrev/prev' + ble-bind -f RET 'dabbrev/exit' + ble-bind -f C-m 'dabbrev/exit' + ble-bind -f C-RET 'dabbrev/accept-line' + ble-bind -f C-j 'dabbrev/accept-line' +} +ble/complete/action#inherit-from mandb.flag mandb +function ble/complete/action:mandb.flag/initialize { + ble/complete/action:mandb/initialize "$@" +} +function ble/complete/action:mandb.flag/init-menu-item { + ble/complete/action:mandb/init-menu-item + prefix=${CAND::!!PREFIX_LEN} +} +function ble/cmdinfo/complete/yield-flag { + local cmd=$1 flags=$2 opts=$3 + [[ $COMPV != [!-]* && $COMPV != --* && $flags ]] || return 1 + local "${_ble_complete_yield_varnames[@]/%/=}" # WA #D1570 checked + ble/complete/cand/yield.initialize mandb + local ret + if [[ ${COMPV:1} ]] && ble/opts#extract-last-optarg "$opts" dedup "$flags"; then + local specified_flags=${ret//[!"${COMPV:1}"]} + flags=${flags//["$specified_flags"]} + fi + if ble/opts#extract-last-optarg "$opts" hasarg; then + [[ $COMPV == -*["$ret"]* ]] && return 1 + fi + if [[ ! $flags ]]; then + [[ :$opts: == *:cancel-on-empty:* ]] && return 1 + local "${_ble_complete_yield_varnames[@]/%/=}" # WA #D1570 checked + ble/complete/cand/yield.initialize word + ble/complete/cand/yield word "$COMPV" + return "$?" + fi + local COMP_PREFIX=$COMPV + local has_desc= + if local ret; ble/complete/mandb/load-cache "$cmd"; then + local entry fs=$_ble_term_FS + for entry in "${ret[@]}"; do + ((cand_iloop++%bleopt_complete_polling_cycle==0)) && + ble/complete/check-cancel && return 148 + local option=${entry%%$fs*} + [[ $option == -? && ${option:1} == ["$flags"] ]] || continue + ble/complete/cand/yield mandb.flag "$COMPV${option:1}" "$entry" + [[ $entry == *"$fs"*"$fs"*"$fs"?* ]] && has_desc=1 + flags=${flags//${option:1}} + done + [[ $has_desc ]] && bleopt complete_menu_style=desc + fi + local i + for ((i=0;i<${#flags};i++)); do + ble/complete/cand/yield mandb.flag "$COMPV${flags:i:1}" + done +} +function ble/complete/action:cdpath/initialize { + DATA=$cdpath_basedir + ble/complete/action:file/initialize +} +function ble/complete/action:cdpath/complete { + CAND=$DATA$CAND ble/complete/action:file/complete +} +function ble/complete/action:cdpath/init-menu-item { + ble/color/face2g cmdinfo_cd_cdpath; g=$ret + if [[ :$comp_type: == *:vstat:* ]]; then + if [[ -h $CAND ]]; then + suffix='@' + elif [[ -d $CAND ]]; then + suffix='/' + fi + fi +} +function ble/complete/action:cdpath/get-desc { + local sgr0=$_ble_term_sgr0 sgr1= sgr2= + local g ret g1 g2 + ble/syntax/highlight/getg-from-filename "$DATA$CAND"; g1=$g + [[ $g1 ]] || { ble/color/face2g filename_warning; g1=$ret; } + ((g2=g1^_ble_color_gflags_Revert)) + ble/color/g2sgr "$g1"; sgr1=$ret + ble/color/g2sgr "$g2"; sgr2=$ret + ble/string#escape-for-display "$DATA$CAND" sgr1="$sgr2":sgr0="$sgr1" + local filename=$sgr1$ret$sgr0 + CAND=$DATA$CAND ble/complete/action:file/get-desc + desc="CDPATH $filename ($desc)" +} +function ble/cmdinfo/complete:cd/generate-cdable_vars { + shopt -q cdable_vars || return 1 + ble/string#match "$COMPV" '^[_a-zA-Z0-9][_a-zA-Z0-9]*$' || return 1 + local arr + ble/util/assign-array arr 'builtin compgen -vX "_ble*" -- "$COMPV"' + ble/complete/source/test-limit "${#arr[@]}" || return 1 + local action=file old_cand_count=$cand_count + local cand "${_ble_complete_yield_varnames[@]/%/=}" # WA #D1570 checked + ble/complete/cand/yield.initialize "$action" + for cand in "${arr[@]}"; do + ((cand_iloop++%bleopt_complete_polling_cycle==0)) && ble/complete/check-cancel && return 148 + [[ $cand == "$COMPV"?* && -d ${!cand-} ]] && + ble/complete/cand/yield "$action" "$cand" "$data" + done + ((cand_count>old_cand_count)) +} +function ble/cmdinfo/complete:cd/.impl { + local type=$1 + [[ $comps_flags == *v* ]] || return 1 + local old_cand_count=$cand_count + case $type in + (pushd|popd|dirs) + if [[ $COMPV == [-+]* ]]; then + local flags=n + [[ $type == dirs ]] && flags=clpv + ble/cmdinfo/complete/yield-flag "$type" "$flags" dedup:hasarg=0123456789:cancel-on-empty + local "${_ble_complete_yield_varnames[@]/%/=}" # WA #D1570 checked + ble/complete/cand/yield.initialize word + local ret + ble/color/face2sgr-ansi filename_directory + local sgr1=$ret sgr0=$'\e[m' + local i n=${#DIRSTACK[@]} + for ((i=0;i=40200)) && list=${list}e + ((_ble_bash>=40300)) && list=${list}@ + ble/cmdinfo/complete/yield-flag cd "$list" dedup + local "${_ble_complete_yield_varnames[@]/%/=}" # WA #D1570 checked + ble/complete/cand/yield.initialize word + if [[ ${OLDPWD:-} && $COMPV == - ]]; then + local ret + ble/color/face2sgr-ansi filename_directory + local sgr1=$ret sgr0=$'\e[m' + ble/complete/cand/yield word - "OLDPWD $sgr1$OLDPWD$sgr0" + fi + [[ -- == "$COMPV"* ]] && + ble/complete/cand/yield word -- '(indicate the end of options)' + return 0 + fi + esac + [[ :$comp_type: != *:[maA]:* && $COMPV =~ ^.+/ ]] && COMP_PREFIX=${BASH_REMATCH[0]} + [[ :$comp_type: == *:[maA]:* && ! $COMPV ]] && return 1 + if [[ ! $CDPATH ]]; then + ble/complete/source:dir || return "$?" + ((cand_count>old_cand_count)) && return 0 + ble/cmdinfo/complete:cd/generate-cdable_vars + return "$?" + fi + ble/complete/source:tilde; local ext=$? + ((ext==148||ext==0)) && return "$ext" + local is_pwd_visited= is_cdpath_generated= + "${_ble_util_set_declare[@]//NAME/visited}" # WA #D1570 checked + local name names; ble/string#split names : "$CDPATH" + for name in "${names[@]}"; do + [[ $name ]] || continue + name=${name%/}/ + local action=cdpath + [[ ${name%/} == . || ${name%/} == "${PWD%/}" ]] && + is_pwd_visited=1 action=file + local -a candidates=() + local ret cand + ble/complete/source:file/.construct-pathname-pattern "$COMPV" + ble/complete/util/eval-pathname-expansion "$name$ret"; (($?==148)) && return 148 + ble/complete/source/test-limit "${#ret[@]}" || return 1 + for cand in "${ret[@]}"; do + ((cand_iloop++%bleopt_complete_polling_cycle==0)) && + ble/complete/check-cancel && return 148 + [[ $cand && -d $cand ]] || continue + [[ $cand == / ]] || cand=${cand%/} + cand=${cand#"$name"} + ble/set#contains visited "$cand" && continue + ble/set#add visited "$cand" + ble/array#push candidates "$cand" + done + ((${#candidates[@]})) || continue + local flag_source_filter=1 + local cdpath_basedir=$name + ble/complete/cand/yield-filenames "$action" "${candidates[@]}"; local ext=$? + ((ext==148)) && return "$ext" + [[ $action == cdpath ]] && is_cdpath_generated=1 + done + [[ $is_cdpath_generated ]] && + bleopt complete_menu_style=desc + if [[ ! $is_pwd_visited ]]; then + local -a candidates=() + local ret cand + ble/complete/source:file/.construct-pathname-pattern "$COMPV" + ble/complete/util/eval-pathname-expansion "${ret%/}/"; (($?==148)) && return 148 + ble/complete/source/test-limit "${#ret[@]}" || return 1 + for cand in "${ret[@]}"; do + ((cand_iloop++%bleopt_complete_polling_cycle==0)) && + ble/complete/check-cancel && return 148 + [[ -d $cand ]] || continue + [[ $cand == / ]] || cand=${cand%/} + ble/set#contains visited "$cand" && continue + ble/array#push candidates "$cand" + done + local flag_source_filter=1 + ble/complete/cand/yield-filenames file "${candidates[@]}"; local ext=$? + ((ext==148)) && return "$ext" + fi + ((cand_count>old_cand_count)) && return 0 + ble/cmdinfo/complete:cd/generate-cdable_vars +} +function ble/cmdinfo/complete:cd { + ble/cmdinfo/complete:cd/.impl cd +} +function ble/cmdinfo/complete:pushd { + ble/cmdinfo/complete:cd/.impl pushd +} +function ble/cmdinfo/complete:popd { + ble/cmdinfo/complete:cd/.impl popd +} +function ble/cmdinfo/complete:dirs { + ble/cmdinfo/complete:cd/.impl dirs +} +blehook/invoke complete_load +blehook complete_load= +return 0 diff --git a/.local/share/blesh/lib/core-debug.sh b/.local/share/blesh/lib/core-debug.sh new file mode 100644 index 0000000..87f4d55 --- /dev/null +++ b/.local/share/blesh/lib/core-debug.sh @@ -0,0 +1,721 @@ +# Copyright 2015 Koichi Murase . All rights reserved. +# This script is a part of blesh (https://github.com/akinomyoga/ble.sh) +# provided under the BSD-3-Clause license. Do not edit this file because this +# is not the original source code: Various pre-processing has been applied. +# Also, the code comments and blank lines are stripped off in the installation +# process. Please find the corresponding source file(s) in the repository +# "akinomyoga/ble.sh". +# +# Source: /lib/core-debug.sh +function ble/debug/setdbg { + ble/bin/rm -f "$_ble_base_run/dbgerr" + local ret + ble/util/readlink /proc/self/fd/3 3>&1 + ln -s "$ret" "$_ble_base_run/dbgerr" +} +function ble/debug/print { + if [[ -e $_ble_base_run/dbgerr ]]; then + ble/util/print "$1" >> "$_ble_base_run/dbgerr" + else + ble/util/print "$1" >&2 + fi +} +_ble_debug_check_leak_variable='local @var=__t1wJltaP9nmow__' +function ble/debug/leakvar#reset { + builtin eval "$1=__t1wJltaP9nmow__" +} +function ble/debug/leakvar#check { + local ext=$? + if [[ ${!1} != __t1wJltaP9nmow__ ]] && ble/variable#is-global "$1"; then + local IFS=$_ble_term_IFS + ble/util/print "$1=${!1}:${*:2} [${FUNCNAME[*]:1:5}]" >> ~/a.txt # DEBUG_LEAKVAR + builtin eval "$1=__t1wJltaP9nmow__" + fi + return "$?" +} +function ble/debug/leakvar#list { + local _ble_local_exclude_file=${_ble_base_repository:-$_ble_base}/make/debug.leakvar.exclude-list.txt + if [[ ! -f $_ble_local_exclude_file ]]; then + ble/util/print "$_ble_local_exclude_file: not found." >&2 + return 1 + fi + set | ble/bin/grep -Eavf "$_ble_local_exclude_file" | ble/bin/grep -Eao '^[[:alnum:]_]+=' + return 0 +} +function ble/debug/print-variables/.append { + local q=\' Q="'\''" + _ble_local_out=$_ble_local_out"$1='${2//$q/$Q}'" +} +function ble/debug/print-variables/.append-array { + local ret; ble/string#quote-words "${@:2}" + _ble_local_out=$_ble_local_out"$1=($ret)" +} +function ble/debug/print-variables { + (($#)) || return 0 + local flags= tag= arg + local -a _ble_local_vars=() + while (($#)); do + arg=$1; shift + case $arg in + (-t) tag=$1; shift ;; + (-*) ble/util/print "print-variables: unknown option '$arg'" >&2 + flags=${flags}e ;; + (*) ble/array#push _ble_local_vars "$arg" ;; + esac + done + [[ $flags == *e* ]] && return 1 + local _ble_local_out= _ble_local_var= + [[ $tag ]] && _ble_local_out="$tag: " + ble/util/unlocal flags tag arg + for _ble_local_var in "${_ble_local_vars[@]}"; do + if ble/is-array "$_ble_local_var"; then + builtin eval -- "ble/debug/print-variables/.append-array \"\$_ble_local_var\" \"\${$_ble_local_var[@]}\"" + else + ble/debug/print-variables/.append "$_ble_local_var" "${!_ble_local_var}" + fi + _ble_local_out=$_ble_local_out' ' + done + ble/debug/print "${_ble_local_out%' '}" +} +_ble_debug_stopwatch=() +function ble/debug/stopwatch/start { + ble/array#push _ble_debug_stopwatch "${EPOCHREALTIME:-$SECONDS.000000}" +} +function ble/debug/stopwatch/stop { + local end=${EPOCHREALTIME:-$SECONDS.000000} + if local ret; ble/array#pop _ble_debug_stopwatch; then + local usec=$(((${end%%[.,]*}-${ret%%[,.]*})*1000000+(10#0${end#*[.,]}-10#0${ret#*[,.]}))) + printf '[%3d.%06d sec] %s\n' "$((usec/1000000))" "$((usec%1000000))" "$1" + else + printf '[---.------ sec] %s\n' "$1" + fi +} +_ble_debug_profiler_magic=__GdWfuwABAUmlg__ +_ble_debug_profiler_prefix= +_ble_debug_profiler_original_xtrace= +_ble_debug_profiler_original_xtrace_ps4= +function ble/debug/profiler/start { + [[ ! $_ble_debug_profiler_prefix ]] || return 1 + if ((_ble_bash<50000)); then + ble/util/print "ble.sh: profiler is only supported in Bash 5.0+." >&2 + return 2 + fi + local prefix=${1:-prof.$$} + [[ $prefix == /* ]] || prefix=$PWD/$prefix + _ble_debug_profiler_prefix=$prefix + _ble_debug_profiler_original_xtrace=$bleopt_debug_xtrace + _ble_debug_profiler_original_xtrace_ps4=$bleopt_debug_xtrace_ps4 + bleopt debug_xtrace="$prefix.xtrace" + bleopt debug_xtrace_ps4='+${#BASH_LINENO[@]} ${BASHPID:-$$} ${EPOCHREALTIME:-SECONDS} ${FUNCNAME:-(global)} ${LINENO:--} ${BASH_SOURCE:--} '"$_ble_debug_profiler_magic"' ' + blehook EXIT!=ble/debug/profiler/stop +} +function ble/debug/profiler/stop { + [[ $_ble_debug_profiler_prefix ]] || return 1 + local prefix=$_ble_debug_profiler_prefix + _ble_debug_profiler_prefix= + bleopt debug_xtrace="$_ble_debug_profiler_original_xtrace" + bleopt debug_xtrace_ps4="$_ble_debug_profiler_original_xtrace_ps4" + local -a awk_args=() + local opts=$bleopt_debug_profiler_opts ret + local -x profiler_line_output= + local -x profiler_line_html= + if ble/opts#extract-last-optarg "$opts" line; then + local file=$prefix.line.txt + [[ -s $file ]] && ble/array#push awk_args mode=line_stat "$file" + profiler_line_output=$file.part + [[ $ret == html ]] && + profiler_line_html=$prefix.line.html + fi + local -x profiler_func_output= + local -x profiler_func_html= + if ble/opts#extract-last-optarg "$opts" func; then + local file=$prefix.func.txt + [[ -s $file ]] && ble/array#push awk_args mode=func_stat "$file" + profiler_func_output=$file.part + [[ $ret == html ]] && + profiler_func_html=$prefix.func.html + fi + local -x profiler_tree_output= + local -x profiler_tree_threshold_duration= + if [[ :$opts: == *:tree:* ]]; then + profiler_tree_output=$prefix.tree.txt + profiler_tree_threshold_duration=${bleopt_debug_profiler_tree_threshold:-1.0} # [ms] + fi + local f1=$prefix.xtrace + ble/array#push awk_args mode=xtrace "$f1" + local nline + ble/util/print "ble/debug/profiler: counting lines..." >&2 + ble/util/assign-words nline 'ble/bin/wc -l "$f1" 2>/dev/null' + ble/util/print $'\e[A\rble/debug/profiler: counting lines... '"$nline" >&2 + ble/bin/awk -v magic="$_ble_debug_profiler_magic" -v nline="$nline" ' + BEGIN { + xtrace_debug_enabled = 1; + print "ble/debug/profiler: collecting information..." >"/dev/stderr"; + if (nline) progress_interval = int(nline / 100); + ipid = 0; + ilabel = 0; + ifname = 0; + _usec_sec0 = ""; + lines_initialize(); + funcs_initialize(); + tree_initialize(); + } + function to_percentage(value) { + value *= 100; + if (value >= 100) return sprintf("%d%%", int(value)); + if (value >= 10) return sprintf("%.2f%%", value); + if (value >= 0.1) return sprintf("%.3f%%", value); + if (value >= 0.0001) return sprintf(".%04d%%", int(value * 10000)); + return "0.0%"; + } + function pids_register(pid) { + if (pid_mark[pid] == "") { + pid_mark[pid] = ipid; + pids[ipid++] = pid; + } + } + function pids_clear() { + ipid = 0; + delete pids; + delete pid_mark; + } + function parse_usec(text, _, sec, usec) { + sec = text; + usec = 0; + if (sub(/[.,].*/, "", sec)) { + usec = text + sub(/^.*[.,]0*/, "", usec); + } + if (_usec_sec0 == "") + _usec_sec0 = sec; + sec -= _usec_sec0; + return sec * 1000000 + usec; + } + function parse_line(_, s) { + s = $1; + level = gsub(/\+/, "", s); + depth = 1 + (s > 0 ? s : 0); + level += depth - 1; + pid = $2; + epoch = $3; + usec = parse_usec($3); + fname = $4; + lineno = $5; + source = $6; + for (i = 7; $i != magic && i <= NF; i++) + source = source " " $i; + label = sprintf("\x1b[35m%s\x1b[36m (%s:\x1b[32m%s\x1b[36m):\x1b[m", source, fname, lineno); + command = ""; + if ($i == magic) { + command = $(++i); + for (i++; i <= NF; i++) + command = command " " $i; + } + } + function str_strip_ansi(str) { + gsub(/\x1b\[[ -?]*[@-~]/, "", str); + gsub(/\x1b[ -\/]*[0-~]/, "", str); + gsub(/[\x01-\x1F\x7F]/, "", str); + return str; + } + function str_html_escape(str) { + gsub(/&/, "\\&", str); + gsub(//, "\\>", str); + return str; + } + function str_ansi_escape(str) { + if (str ~ /[\x01-\x1F]/) { + gsub(/\x1b/, "\x1b[7m^[\x1b[27m", str); + gsub(/\x07/, "\x1b[7m^G\x1b[27m", str); + gsub(/\x08/, "\x1b[7m^H\x1b[27m", str); + gsub(/\x09/, "\x1b[7m^I\x1b[27m", str); + gsub(/\x0a/, "\x1b[7m^J\x1b[27m", str); + gsub(/\x0b/, "\x1b[7m^K\x1b[27m", str); + gsub(/\x0c/, "\x1b[7m^L\x1b[27m", str); + gsub(/\x0d/, "\x1b[7m^M\x1b[27m", str); + gsub(/[\x01-\x1A\x1C-\x1F]/ ,"?", str); + } + return str; + } + function lines_initialize() { + c_lines_output = ENVIRON["profiler_line_output"]; + c_lines_enabled = c_lines_output != ""; + if (!c_lines_enabled) return; + c_lines_html = ENVIRON["profiler_line_html"]; + } + function lines_level_push(pid, level, usec, label, command, _, lv) { + if (!line_stat[label, "count"]++) + labels[ilabel++] = label; + lines_level_pop(pid, level, usec); + stk[pid, level, "label"] = label; + stk[pid, level, "begin"] = usec; + stk[pid, level, "child"] = 0.0; + stk[pid, level, "allstep_count"] = 0; + stk[pid, level, "substep_count"] = 0; + stk[pid, level, "substep_time"] = 0.0; + stk[pid, level, "command"] = command; + ilevel[pid] = level; + } + function lines_level_getParent(pid, lv) { + for (lv--; lv >= 1; lv--) + if (stk[pid, lv, "label"] != "") break; + return lv; + } + function lines_level_pop(pid, level, usec, _, lv, label, elapsed, plv) { + for (lv = ilevel[pid]; lv >= level; lv--) { + label = stk[pid, lv, "label"]; + stk[pid, lv, "label"] = ""; + if (label == "") continue; + elapsed = usec - stk[pid, lv, "begin"]; + if (elapsed < 0) { + elapsed = 0.0; + } + line_stat[label, "total"] += elapsed; + line_stat[label, "child"] += stk[pid, lv, "child"]; + if (lv >= 3) + stk[pid, lv - 2, "child"] += elapsed; + line_stat[label, "allstep_count"] += stk[pid, lv, "allstep_count"]; + line_stat[label, "substep_count"] += stk[pid, lv, "substep_count"]; + line_stat[label, "substep_time"] += stk[pid, lv, "substep_time"]; + if ((plv = lines_level_getParent(pid, lv))) { + stk[pid, plv, "allstep_count"] += 1 + stk[pid, lv, "allstep_count"]; + stk[pid, plv, "substep_count"]++; + stk[pid, plv, "substep_time"] += elapsed; + } + max_time = line_stat[label, "max_time"]; + if (max_time == "" || elapsed > max_time) { + line_stat[label, "max_command"] = stk[pid, lv, "command"]; + line_stat[label, "max_time"] = elapsed; + line_stat[label, "max_child"] = stk[pid, lv, "child"]; + } + } + ilevel[pid] = lv; + } + function lines_text_header(_, line) { + line = sprintf("# %6s %8s %8s", "count", "subcount", "allcount"); + line = line sprintf(" %10s %-6s %10s %-6s %10s", "total_msec", "TOTAL%", "self_msec", "SELF%", "child_msec"); + line = line sprintf(" %10s %10s %10s", "max_msec", "max_self", "max_child"); + printf("%s %s%s\n", line, "\x1b[35mSOURCE\x1b[36m (FUNCNAME):\x1b[32mLINENO\x1b[36m:\x1b[m", "COMMAND") > c_lines_output; + } + function lines_text_print(info, _, line) { + line = sprintf("%8d %8d %8d", info["count"], info["substep_count"], info["allstep_count"]); + line = line sprintf(" %10.3f %-6s %10.3f %-6s %10.3f", info["total_time"], info["total_time_percentage"], info["total_self"], info["total_self_percentage"], info["total_child"]); + line = line sprintf(" %10.3f %10.3f %10.3f", info["max_time"], info["max_self"], info["max_child"]); + printf("%s %s%s\n", line, info["label"], info["command"]) > c_lines_output; + } + function lines_html_header(_, line) { + line = sprintf("\n"); + line = line sprintf("ble.sh xtrace profiling result\n"); + line = line sprintf("\n"); + line = line sprintf("\n"); + line = line sprintf("\n"); + line = line sprintf(" \n"); + line = line sprintf(" \n"); + line = line sprintf(" \n"); + line = line sprintf(" \n"); + line = line sprintf(" \n"); + line = line sprintf(" \n"); + line = line sprintf(" \n"); + line = line sprintf(" \n"); + line = line sprintf("\n"); + line = line sprintf("\n"); + line = line sprintf(" \n"); + line = line sprintf(" \n"); + line = line sprintf(" \n"); + line = line sprintf(" \n"); + line = line sprintf(" \n"); + line = line sprintf(" \n"); + line = line sprintf(" \n"); + line = line sprintf(" \n"); + line = line sprintf(" \n"); + line = line sprintf("\n"); + printf("%s", line) > c_lines_html; + } + function lines_html_print(info, _, line, label) { + label = str_strip_ansi(info["label"]); + sub(/:$/, "", label); + line = sprintf("\n"); + line = line sprintf(" \n", info["count"]); + line = line sprintf(" \n", info["substep_count"]); + line = line sprintf(" \n", info["allstep_count"]); + line = line sprintf(" \n", info["total_time"]); + line = line sprintf(" \n", info["total_self"]); + line = line sprintf(" \n", info["total_child"]); + line = line sprintf(" \n", info["average_time"]); + line = line sprintf(" \n", info["average_self"]); + line = line sprintf(" \n", info["average_child"]) + line = line sprintf(" \n", info["max_time"]); + line = line sprintf(" \n", info["max_self"]); + line = line sprintf(" \n", info["max_child"]); + line = line sprintf(" \n", str_html_escape(info["command"])); + line = line sprintf(" \n", str_html_escape(label)); + line = line sprintf("\n"); + printf("%s", line) > c_lines_html; + } + function lines_html_footer() { + printf("
countsubstepallsteptotal (msec)average (msec)max (msec)commandlocation
sumselfchildsumselfchildsumselfchild
%d%d%d%.3f%.3f%.3f%.3f%.3f%.3f%.3f%.3f%.3f%s%s
\n") > c_lines_html; + } + function lines_save(_, i, label, count, info, total_time) { + lines_text_header(); + if (c_lines_html) lines_html_header(); + total_time = 0.0; + for (i = 0; i < ilabel; i++) { + label = labels[i]; + total_time += line_stat[label, "total"] - line_stat[label, "child"]; + } + total_time *= 0.001; + for (i = 0; i < ilabel; i++) { + label = labels[i]; + count = line_stat[label, "count"]; + info["count"] = count; + info["allstep_count"] = line_stat[label, "allstep_count"]; + info["substep_count"] = line_stat[label, "substep_count"]; + info["substep_time"] = line_stat[label, "substep_time"] * 0.001; + info["total_time"] = line_stat[label, "total"] * 0.001; + info["total_child"] = line_stat[label, "child"] * 0.001; + info["total_self"] = info["total_time"] - info["total_child"]; + info["total_time_percentage"] = to_percentage(info["total_time"] / total_time); + info["total_self_percentage"] = to_percentage(info["total_self"] / total_time); + info["average_time"] = info["total_time"] / count; + info["average_self"] = info["total_self"] / count; + info["average_child"] = info["total_child"] / count + info["max_time"] = line_stat[label, "max_time"] * 0.001; + info["max_child"] = line_stat[label, "max_child"] * 0.001; + info["max_self"] = info["max_time"] - info["max_child"]; + info["label"] = label; + info["command"] = line_stat[label, "max_command"]; + lines_text_print(info); + if (c_lines_html) lines_html_print(info); + } + if (c_lines_html) lines_html_footer(); + } + function lines_load_line(_, i, s, label, old_max_time, new_max_time) { + s = substr($0, index($0, "\x1b[35m")); + i = index(s, "\x1b[m"); + label = substr(s, 1, i + 2); + if (!line_stat[label, "count"]) + labels[ilabel++] = label; + line_stat[label, "count"] += $1; + line_stat[label, "substep_count"] += $2; + line_stat[label, "allstep_count"] += $3; + line_stat[label, "substep_time"] += 0.0; # not saved + line_stat[label, "total"] += int($4 * 1000 + 0.5); + line_stat[label, "child"] += int($8 * 1000 + 0.5); + old_max_time = line_stat[label, "max_time"]; + new_max_time = int($9 * 1000 + 0.5); + if (old_max_time == "" || new_max_time > old_max_time) { + line_stat[label, "max_command"] = substr(s, i + 3); + line_stat[label, "max_time"] = new_max_time; + line_stat[label, "max_child"] = int($11 * 1000 + 0.5); + } + } + function lines_finalize() { + if (c_lines_enabled) + lines_save(); + } + function funcs_initialize() { + c_funcs_output = ENVIRON["profiler_func_output"]; + c_funcs_enabled = c_funcs_output != ""; + if (!c_funcs_enabled) return; + c_funcs_html = ENVIRON["profiler_func_html"]; + } + function funcs_depth_push(pid, depth, usec, fname, source, _, old_depth) { + if (!func_stat[fname, "mark"]++) + fnames[ifname++] = fname; + if (funcs_depth_pop(pid, depth, usec)) { + func_stk[pid, depth, "fname"] = fname; + func_stk[pid, depth, "begin"] = usec; + func_stk[pid, depth, "child"] = 0.0; + func_stk[pid, depth, "allcall_count"] = 0; + func_stk[pid, depth, "subcall_count"] = 0; + func_stk[pid, depth, "source"] = source; + idepth[pid] = depth; + } + } + function funcs_depth_getParent(pid, dep) { + for (dep--; dep >= 1; dep--) + if (func_stk[pid, dep, "fname"] != "") break; + return dep; + } + function funcs_depth_pop(pid, depth, usec, fname, _, dp, label, elapsed, pdp) { + for (dp = idepth[pid]; dp >= depth; dp--) { + if (dp == depth && fname == func_stk[pid, dp, "fname"]) { + idepth[pid] = dp; + return 0; # 前の関数の続き + } + fname = func_stk[pid, dp, "fname"]; + func_stk[pid, dp, "fname"] = ""; + if (fname == "") continue; + elapsed = usec - func_stk[pid, dp, "begin"]; + if (elapsed < 0) elapsed = 0.0; + func_stat[fname, "count"]++; + func_stat[fname, "total"] += elapsed; + func_stat[fname, "child"] += func_stk[pid, dp, "child"]; + func_stat[fname, "allcall_count"] += func_stk[pid, dp, "allcall_count"]; + func_stat[fname, "subcall_count"] += func_stk[pid, dp, "subcall_count"]; + if ((pdp = funcs_depth_getParent(pid, dp))) { + func_stk[pid, pdp, "child"] += elapsed; + func_stk[pid, pdp, "allcall_count"] += 1 + func_stk[pid, dp, "allcall_count"]; + func_stk[pid, pdp, "subcall_count"]++; + } + func_stat[fname, "source"] = func_stk[pid, dp, "source"]; # always overwrite + max_time = func_stat[fname, "max_time"]; + if (max_time == "" || elapsed > max_time) { + func_stat[fname, "max_time"] = elapsed; + func_stat[fname, "max_child"] = func_stk[pid, dp, "child"]; + } + } + idepth[pid] = dp; + return 1; + } + function funcs_text_header(_, line) { + line = sprintf("# %6s %8s %8s", "count", "subcall", "allcall"); + line = line sprintf(" %10s %-6s %10s %-6s %10s", "total_msec", "TOTAL%", "self_msec", "SELF%", "child_msec"); + line = line sprintf(" %10s %10s %10s", "max_msec", "max_self", "max_child"); + printf("%s %s (\x1b[35m%s\x1b[m)\n", line, "FUNCNAME", "SOURCE") > c_funcs_output; + } + function funcs_text_print(info, _, line) { + line = sprintf("%8d %8d %8d", info["count"], info["subcall_count"], info["allcall_count"]); + line = line sprintf(" %10.3f %-6s %10.3f %-6s %10.3f", info["total_time"], info["total_time_percentage"], info["total_self"], info["total_self_percentage"], info["total_child"]); + line = line sprintf(" %10.3f %10.3f %10.3f", info["max_time"], info["max_self"], info["max_child"]); + printf("%s %s (\x1b[35m%s\x1b[m)\n", line, info["fname"], info["source"]) > c_funcs_output; + } + function funcs_html_header(_, line) { + line = sprintf("\n"); + line = line sprintf("ble.sh xtrace profiling result\n"); + line = line sprintf("\n"); + line = line sprintf("\n"); + line = line sprintf("\n"); + line = line sprintf(" \n"); + line = line sprintf(" \n"); + line = line sprintf(" \n"); + line = line sprintf(" \n"); + line = line sprintf(" \n"); + line = line sprintf(" \n"); + line = line sprintf(" \n"); + line = line sprintf(" \n"); + line = line sprintf("\n"); + line = line sprintf("\n"); + line = line sprintf(" \n"); + line = line sprintf(" \n"); + line = line sprintf(" \n"); + line = line sprintf(" \n"); + line = line sprintf(" \n"); + line = line sprintf(" \n"); + line = line sprintf(" \n"); + line = line sprintf(" \n"); + line = line sprintf("\n"); + printf("%s", line) > c_funcs_html; + } + function funcs_html_print(info, _, line) { + line = sprintf("\n"); + line = line sprintf(" \n", info["count"], info["subcall_count"], info["allcall_count"]); + line = line sprintf(" \n", info["total_time"], info["total_time_percentage"], info["max_time"]); + line = line sprintf(" \n", info["total_self"], info["total_self_percentage"], info["max_self"]); + line = line sprintf(" \n", info["total_child"], info["max_child"]); + line = line sprintf(" \n", info["fname"], info["source"]); + line = line sprintf("\n"); + printf("%s", line) > c_funcs_html; + } + function funcs_html_footer() { + printf("
countsubcallallcalltotal (ms)self (ms)child (ms)functionlocation
sum%%maxsum%%maxsummax
%s%s%s%s%s%s%s%s%s%s%s%s%s
\n") > c_funcs_html; + } + function funcs_save(_, i, fname, count, info, total_time) { + funcs_text_header(); + if (c_funcs_html) funcs_html_header(); + total_time = 0.0; + for (i = 0; i < ifname; i++) { + fname = fnames[i]; + total_time += func_stat[fname, "total"] - func_stat[fname, "child"]; + } + total_time *= 0.001; + for (i = 0; i < ifname; i++) { + fname = fnames[i]; + count = func_stat[fname, "count"]; + info["count"] = count; + info["allcall_count"] = func_stat[fname, "allcall_count"]; + info["subcall_count"] = func_stat[fname, "subcall_count"]; + info["total_time"] = func_stat[fname, "total"] * 0.001; + info["total_child"] = func_stat[fname, "child"] * 0.001; + info["total_self"] = info["total_time"] - info["total_child"]; + info["total_time_percentage"] = to_percentage(info["total_time"] / total_time); + info["total_self_percentage"] = to_percentage(info["total_self"] / total_time); + info["average_time"] = info["total_time"] / count; + info["average_self"] = info["total_self"] / count; + info["average_child"] = info["total_child"] / count + info["max_time"] = func_stat[fname, "max_time"] * 0.001; + info["max_child"] = func_stat[fname, "max_child"] * 0.001; + info["max_self"] = info["max_time"] - info["max_child"]; + info["fname"] = fname; + info["source"] = func_stat[fname, "source"]; + funcs_text_print(info); + if (c_funcs_html) funcs_html_print(info); + } + if (c_funcs_html) funcs_html_footer(); + } + function funcs_load_line(_, fname, i, s, old_max_time, new_max_time) { + fname = $12; + if (!func_stat[fname, "mark"]) { + fnames[ifname++] = fname; + func_stat[fname, "mark"]++; + } + i = index($0, "\x1b[35m"); + if (i > 0) { + s = substr($0, i + 5); + i = index(s, "\x1b[m"); + func_stat[fname, "source"] = substr(s, 1, i - 1); + } + func_stat[fname, "count"] += $1; + func_stat[fname, "subcall_count"] += $2; + func_stat[fname, "allcall_count"] += $3; + func_stat[fname, "total"] += int($4 * 1000 + 0.5); + func_stat[fname, "child"] += int($8 * 1000 + 0.5); + old_max_time = func_stat[fname, "max_time"]; + new_max_time = int($9 * 1000 + 0.5); + if (old_max_time == "" || new_max_time > old_max_time) { + func_stat[fname, "max_time"] = new_max_time; + func_stat[fname, "max_child"] = int($11 * 1000 + 0.5); + } + } + function funcs_finalize() { + if (c_funcs_enabled) + funcs_save(); + } + function tree_initialize() { + c_tree_output = ENVIRON["profiler_tree_output"]; + c_tree_enabled = c_tree_output != ""; + if (!c_tree_enabled) return; + c_tree_threshold_duration = ENVIRON["profiler_tree_threshold_duration"] * 1000; + g_tree_min_level = ""; + } + function tree_flush_command(level, now_usec, _, start_time, clk_start, clk_end, dur_usec, prev_cmd, prev_source, prev_lineno, prev_func, line, child, i, n) { + if (g_tree_record[level] == "") return; + start_time = g_tree_record[level, "epoch"]; + clk_start = g_tree_record[level, "start"]; + clk_end = now_usec; + dur_usec = clk_end - clk_start; + prev_cmd = str_ansi_escape(g_tree_record[level]); + prev_source = g_tree_record[level, "source"]; + prev_lineno = g_tree_record[level, "lineno"]; + prev_func = g_tree_record[level, "func"]; + if (prev_cmd == "???") { + prev_source = ""; + } else if (prev_source == "" && prev_func == "") { + prev_source = sprintf(" [(global):%d]", prev_lineno); + } else { + prev_source = sprintf(" [%s:%d (%s)]", prev_source, prev_lineno, prev_func); + } + n = 0 + g_tree_record[level, "#child"]; + g_tree_record[level] = ""; + g_tree_record[level, "#child"] = 0; + if (dur_usec < c_tree_threshold_duration) return; + line = sprintf("%17.6f %10.3fms %2d __tree__\x1b[1m%s\x1b[;34m%s\x1b[m", start_time, dur_usec * 0.001, level, prev_cmd, prev_source); + for (i = 0; i < n; i++) { + child = g_tree_record[level, "child", i]; + gsub(/__tree__/, i < n - 1 ? "&| " : "& ", child); + sub(/__tree__.../, "__tree__+- ", child); + line = line "\n" child; + } + if (level > g_tree_min_level) { + if (g_tree_record[level - 1] == "") { + g_tree_record[level - 1] = "???"; + g_tree_record[level - 1, "start"] = start_time; + g_tree_record[level - 1, "start"] = clk_start; + g_tree_record[level - 1, "#child"] = 0; + } + i = 0 + g_tree_record[level - 1, "#child"]; + g_tree_record[level - 1, "child", i] = line; + g_tree_record[level - 1, "#child"] = i + 1; + } else { + gsub(/__tree__/, "", line); + print line >> c_tree_output; + } + } + function tree_flush_level(level, now_usec) { + for (; g_tree_level >= level; g_tree_level--) + tree_flush_command(g_tree_level, now_usec); + g_tree_level = level; + } + function tree_process_line(level, epoch, usec, source, lineno, funcname, command) { + tree_flush_level(level, usec); + if (g_tree_min_level == "" || g_tree_min_level > level) + g_tree_min_level = level; + g_tree_record[level] = command; + g_tree_record[level, "epoch"] = epoch; + g_tree_record[level, "start"] = usec; + g_tree_record[level, "source"] = source; + g_tree_record[level, "lineno"] = lineno; + g_tree_record[level, "func"] = funcname; + g_tree_last_usec = usec; + } + function tree_finalize() { + if (c_tree_enabled) + tree_flush_level(1, g_tree_last_usec); + } + function flush_stack(_, i) { + for (i = 0; i < ipid; i++) { + if (c_lines_enabled) lines_level_pop(pids[i], 1, proc[pids[i], "time"]); + if (c_funcs_enabled) funcs_depth_pop(pids[i], 1, proc[pids[i], "time"]); + } + pids_clear(); + } + mode == "line_stat" { if ($0 ~ /^['"$_ble_term_space"']*[^#'"$_ble_term_space"']/) lines_load_line(); next; } + mode == "func_stat" { if ($0 ~ /^['"$_ble_term_space"']*[^#'"$_ble_term_space"']/) funcs_load_line(); next; } + progress_interval && ++iline % progress_interval == 0 { + print "\x1b[A\rble/debug/profiler: collecting information... " int((iline * 100) / nline) "%" >"/dev/stderr"; + } + /^\+/ && index($0, magic) { + if (!xtrace_debug_enabled) next; + parse_line(); + if (fname == "(global)") { + if (command ~ /^(ble-decode\/.hook|_ble_decode_hook) [0-9]+$/) flush_stack(); + label = command; + sub(/^['"$_ble_term_space"']+|['"$_ble_term_space"'].*/, "", label); + label = sprintf("\x1b[35m%s\x1b[36m:\x1b[32m%s\x1b[36m (%s):\x1b[m", source, lineno, label); + } + pids_register(pid); + if (c_lines_enabled) + lines_level_push(pid, level, usec, label, command); + if (c_funcs_enabled) + funcs_depth_push(pid, depth, usec, fname, source); + if (c_tree_enabled) + tree_process_line(level, epoch, usec, source, lineno, fname, command); + proc[pid, "time"] = usec; + next; + } + /^---- \[.*\] ble\/base\/xtrace\/restore/ { + flush_stack(); + xtrace_debug_enabled = 0; + } + /^---- \[.*\] ble\/base\/xtrace\/adjust/ { + xtrace_debug_enabled = 1; + } + END { + flush_stack(); + print "ble/debug/profiler: writing result..." >"/dev/stderr"; + lines_finalize(); + funcs_finalize(); + tree_finalize(); + } + ' "${awk_args[@]}" || return "$?" + local -a files_to_remove + files_to_remove=("$f1") + if [[ $profiler_line_output == *.part ]]; then + local file=${profiler_line_output%.part} + { + LANG=C ble/bin/grep '^#' "$file.part" + LANG=C ble/bin/grep -v '^#' "$file.part" | ble/bin/sort -nrk4 + } >| "$file" && + ble/array#push files_to_remove "$file.part" + fi + if [[ $profiler_func_output == *.part ]]; then + local file=${profiler_func_output%.part} + { + LANG=C ble/bin/grep '^#' "$file.part" + LANG=C ble/bin/grep -v '^#' "$file.part" | ble/bin/sort -nrk4 + } >| "$file" && + ble/array#push files_to_remove "$file.part" + fi + ble/bin/rm -f "${files_to_remove[@]}" +} diff --git a/.local/share/blesh/lib/core-decode.emacs-rlfunc.txt b/.local/share/blesh/lib/core-decode.emacs-rlfunc.txt new file mode 100644 index 0000000..b14c647 --- /dev/null +++ b/.local/share/blesh/lib/core-decode.emacs-rlfunc.txt @@ -0,0 +1,172 @@ +abort bell +accept-line accept-line +alias-expand-line alias-expand-line +arrow-key-prefix - +backward-byte backward-byte +backward-char backward-char +backward-delete-char delete-region-or delete-backward-char +backward-kill-line kill-backward-line +backward-kill-word kill-backward-cword +backward-word backward-cword +beginning-of-history history-beginning +beginning-of-line beginning-of-line +bracketed-paste-begin bracketed-paste +call-last-kbd-macro call-keyboard-macro +capitalize-word capitalize-eword +character-search character-search-forward +character-search-backward character-search-backward +clear-display clear-display +clear-screen clear-screen +complete complete +complete-command complete context=command +complete-filename complete context=filename +complete-hostname complete context=hostname +complete-into-braces complete insert_braces +complete-username complete context=username +complete-variable complete context=variable +copy-backward-word copy-backward-cword +copy-forward-word copy-forward-cword +copy-region-as-kill copy-region +dabbrev-expand dabbrev-expand +delete-char delete-forward-char +delete-char-or-list delete-forward-char-or-list +delete-horizontal-space delete-horizontal-space +digit-argument append-arg +display-shell-version display-shell-version +do-lowercase-version do-lowercase-version +downcase-word downcase-eword +dump-functions readline-dump-functions +dump-macros readline-dump-macros +dump-variables readline-dump-variables +dynamic-complete-history complete context=dynamic-history +edit-and-execute-command edit-and-execute-command +emacs-editing-mode nop +end-kbd-macro end-keyboard-macro +end-of-history history-end +end-of-line end-of-line +exchange-point-and-mark exchange-point-and-mark +execute-named-command emacs/execute-named-command +fetch-history history-goto +forward-backward-delete-char delete-forward-backward-char +forward-byte forward-byte +forward-char forward-char +forward-search-history history-isearch-forward +forward-word forward-cword +glob-complete-word complete context=glob +glob-expand-word complete context=glob:insert-all +glob-list-expansions complete context=glob:show_menu +history-and-alias-expand-line history-and-alias-expand-line +history-expand-line history-expand-line +history-search-backward history-search-backward empty=emulate-readline +history-search-forward history-search-forward empty=emulate-readline +history-substring-search-backward history-substring-search-backward +history-substring-search-forward history-substring-search-forward +insert-comment insert-comment +insert-completions complete insert_all +insert-last-argument insert-last-argument +kill-line kill-forward-line +kill-region kill-region-or kill-uword +kill-whole-line kill-line +kill-word kill-forward-cword +magic-space magic-space +menu-complete menu-complete +menu-complete-backward menu-complete backward +next-history history-next +next-screen-line forward-graphical-line +non-incremental-forward-search-history history-nsearch-forward +non-incremental-forward-search-history-again history-nsearch-forward-again +non-incremental-reverse-search-history history-nsearch-backward +non-incremental-reverse-search-history-again history-nsearch-backward-again +old-menu-complete menu-complete +operate-and-get-next accept-and-next +overwrite-mode overwrite-mode +possible-command-completions complete show_menu:context=command +possible-completions complete show_menu +possible-filename-completions complete show_menu:context=filename +possible-hostname-completions complete show_menu:context=hostname +possible-username-completions complete show_menu:context=username +possible-variable-completions complete show_menu:context=variable +previous-history history-prev +previous-screen-line backward-graphical-line +print-last-kbd-macro print-keyboard-macro +quoted-insert quoted-insert +re-read-init-file re-read-init-file +redraw-current-line redraw-line +reverse-search-history history-isearch-backward +revert-line emacs/revert +self-insert self-insert +set-mark set-mark +shell-backward-kill-word kill-backward-sword +shell-backward-word backward-sword +shell-expand-line shell-expand-line +shell-forward-word forward-sword +shell-kill-word kill-forward-sword +shell-transpose-words transpose-swords +skip-csi-sequence +start-kbd-macro start-keyboard-macro +tab-insert tab-insert +tilde-expand tilde-expand +transpose-chars transpose-chars +transpose-words transpose-ewords +tty-status - +undo emacs/undo +universal-argument universal-arg +unix-filename-rubout kill-backward-fword +unix-line-discard kill-backward-line +unix-word-rubout kill-backward-uword +upcase-word upcase-eword +vi-append-eol - +vi-append-mode - +vi-arg-digit - +vi-prev-word vi-rlfunc/prev-word +vi-backward-word vi-command/backward-vword +vi-backward-bigword vi-command/backward-uword +vi-bword vi-command/backward-vword +vi-bWord vi-command/backward-uword +vi-end-word vi-rlfunc/end-word +vi-end-bigword vi-command/forward-uword-end +vi-eword vi-command/forward-vword-end +vi-eWord vi-command/forward-uword-end +vi-next-word vi-rlfunc/next-word +vi-forward-word vi-command/forward-vword +vi-forward-bigword vi-command/forward-uword +vi-fword vi-command/forward-vword +vi-fWord vi-command/forward-uword +vi-back-to-indent - +vi-change-case - +vi-change-char - +vi-change-to - +vi-char-search - +vi-column - +vi-complete - +vi-delete - +vi-delete-to - +vi-editing-mode vi-editing-mode +vi-eof-maybe - +vi-fetch-history history-goto +vi-first-print - +vi-goto-mark - +vi-insert-beg - +vi-insertion-mode - +vi-match - +vi-movement-mode - +vi-overstrike - +vi-overstrike-delete - +vi-put - +vi-redo - +vi-replace - +vi-rubout - +vi-search - +vi-search-again - +vi-set-mark - +vi-subst - +vi-tilde-expand - +vi-unix-word-rubout - +vi-yank-arg - +vi-yank-pop - +vi-yank-to - +yank yank +yank-last-arg insert-last-argument +yank-nth-arg insert-nth-argument +yank-pop yank-pop +paste-from-clipboard paste-from-clipboard diff --git a/.local/share/blesh/lib/core-decode.vi_imap-rlfunc.txt b/.local/share/blesh/lib/core-decode.vi_imap-rlfunc.txt new file mode 100644 index 0000000..a5159a6 --- /dev/null +++ b/.local/share/blesh/lib/core-decode.vi_imap-rlfunc.txt @@ -0,0 +1,171 @@ +abort bell +accept-line accept-single-line-or-newline +alias-expand-line alias-expand-line +arrow-key-prefix - +backward-byte backward-byte +backward-char backward-char +backward-delete-char vi_imap/delete-region-or vi_imap/delete-backward-indent-or delete-backward-char +backward-kill-line kill-backward-line +backward-kill-word kill-backward-cword +backward-word backward-sword +beginning-of-history history-beginning +beginning-of-line beginning-of-line +bracketed-paste-begin vi_imap/bracketed-paste +call-last-kbd-macro call-keyboard-macro +capitalize-word capitalize-eword +character-search character-search-forward +character-search-backward character-search-backward +clear-display clear-display +clear-screen clear-screen +complete complete +complete-command complete context=command +complete-filename complete context=filename +complete-hostname complete context=hostname +complete-into-braces complete insert_braces +complete-username complete context=username +complete-variable complete context=variable +copy-backward-word copy-backward-sword +copy-forward-word copy-forward-sword +copy-region-as-kill copy-region-or copy-uword +dabbrev-expand dabbrev-expand +delete-char vi_imap/delete-region-or delete-forward-char +delete-char-or-list delete-forward-char-or-list +delete-horizontal-space delete-horizontal-space +digit-argument append-arg +display-shell-version display-shell-version +do-lowercase-version do-lowercase-version +downcase-word downcase-eword +dump-functions readline-dump-functions +dump-macros readline-dump-macros +dump-variables readline-dump-variables +dynamic-complete-history complete context=dynamic-history +edit-and-execute-command edit-and-execute-command +emacs-editing-mode emacs-editing-mode +end-kbd-macro end-keyboard-macro +end-of-history history-end +end-of-line end-of-line +exchange-point-and-mark exchange-point-and-mark +execute-named-command vi-command/execute-named-command +fetch-history history-goto +forward-backward-delete-char delete-forward-backward-char +forward-byte forward-byte +forward-char forward-char +forward-search-history history-isearch-forward +forward-word forward-uword +glob-complete-word complete context=glob +glob-expand-word complete context=glob:insert-all +glob-list-expansions complete context=glob:show_menu +history-and-alias-expand-line history-and-alias-expand-line +history-expand-line history-expand-line +history-search-backward history-search-backward empty=emulate-readline +history-search-forward history-search-forward empty=emulate-readline +history-substring-search-backward history-substring-search-backward +history-substring-search-forward history-substring-search-forward +insert-comment insert-comment +insert-completions complete insert_all +insert-last-argument insert-last-argument +kill-line kill-forward-line +kill-region kill-region-or kill-uword +kill-whole-line kill-line +kill-word kill-forward-uword +magic-space magic-space +menu-complete menu-complete +menu-complete-backward menu-complete backward +next-history history-next +next-screen-line forward-graphical-line +non-incremental-forward-search-history history-nsearch-forward +non-incremental-forward-search-history-again history-nsearch-forward-again +non-incremental-reverse-search-history history-nsearch-backward +non-incremental-reverse-search-history-again history-nsearch-backward-again +old-menu-complete menu-complete +operate-and-get-next accept-and-next +overwrite-mode vi_imap/overwrite-mode +possible-command-completions complete show_menu:context=command +possible-completions complete show_menu +possible-filename-completions complete show_menu:context=filename +possible-hostname-completions complete show_menu:context=hostname +possible-username-completions complete show_menu:context=username +possible-variable-completions complete show_menu:context=variable +previous-history history-prev +previous-screen-line backward-graphical-line +print-last-kbd-macro print-keyboard-macro +quoted-insert vi_imap/quoted-insert +re-read-init-file re-read-init-file +redraw-current-line redraw-line +reverse-search-history history-isearch-backward +revert-line - +self-insert self-insert +set-mark set-mark +shell-backward-kill-word kill-backward-sword +shell-backward-word backward-sword +shell-expand-line shell-expand-line +shell-forward-word forward-sword +shell-kill-word kill-forward-sword +shell-transpose-words transpose-swords +skip-csi-sequence +start-kbd-macro start-keyboard-macro +tab-insert tab-insert +tilde-expand tilde-expand +transpose-chars transpose-chars +transpose-words transpose-ewords +tty-status - +undo - +universal-argument universal-arg +unix-filename-rubout kill-backward-fword +unix-line-discard kill-backward-line +unix-word-rubout kill-backward-uword +upcase-word upcase-eword +vi-append-eol - +vi-append-mode - +vi-arg-digit - +vi-back-to-indent - +vi-prev-word vi-rlfunc/prev-word +vi-backward-word vi-command/backward-vword +vi-backward-bigword vi-command/backward-uword +vi-bword vi-command/backward-vword +vi-bWord vi-command/backward-uword +vi-end-word vi-rlfunc/end-word +vi-end-bigword vi-command/forward-uword-end +vi-eword vi-command/forward-vword-end +vi-eWord vi-command/forward-uword-end +vi-next-word vi-rlfunc/next-word +vi-forward-word vi-command/forward-vword +vi-forward-bigword vi-command/forward-uword +vi-fword vi-command/forward-vword +vi-fWord vi-command/forward-uword +vi-change-case - +vi-change-char - +vi-change-to - +vi-char-search - +vi-column - +vi-complete - +vi-delete - +vi-delete-to - +vi-editing-mode nop +vi-eof-maybe - +vi-fetch-history history-goto +vi-first-print - +vi-goto-mark - +vi-insert-beg - +vi-insertion-mode nop +vi-match - +vi-movement-mode vi_imap/normal-mode +vi-overstrike - +vi-overstrike-delete - +vi-put - +vi-redo - +vi-replace vi_imap/overwrite-mode +vi-rubout - +vi-search - +vi-search-again - +vi-set-mark - +vi-subst - +vi-tilde-expand - +vi-unix-word-rubout vi_imap/delete-backward-word +vi-yank-arg - +vi-yank-pop - +vi-yank-to - +yank yank +yank-last-arg insert-last-argument +yank-nth-arg insert-nth-argument +yank-pop yank-pop diff --git a/.local/share/blesh/lib/core-decode.vi_nmap-rlfunc.txt b/.local/share/blesh/lib/core-decode.vi_nmap-rlfunc.txt new file mode 100644 index 0000000..1525f4c --- /dev/null +++ b/.local/share/blesh/lib/core-decode.vi_nmap-rlfunc.txt @@ -0,0 +1,172 @@ +abort bell +accept-line accept-single-line-or vi-command/forward-first-non-space +alias-expand-line vi_nmap/@edit alias-expand-line +arrow-key-prefix - +backward-byte vi-command/backward-byte +backward-char vi-command/backward-char +backward-delete-char - +backward-kill-line - +backward-kill-word - +backward-word vi-command/backward-vword +beginning-of-history vi-command/history-beginning +beginning-of-line vi-command/beginning-of-line +bracketed-paste-begin vi-command/bracketed-paste +call-last-kbd-macro call-keyboard-macro +capitalize-word vi_nmap/capitalize-eword +character-search vi_nmap/@motion character-search-forward +character-search-backward vi_nmap/@motion character-search-backward +clear-display clear-display +clear-screen clear-screen +complete - +complete-command - +complete-filename - +complete-hostname - +complete-into-braces - +complete-username - +complete-variable - +copy-backward-word - +copy-forward-word - +copy-region-as-kill - +dabbrev-expand - +delete-char vi_nmap/kill-forward-char +delete-char-or-list - +delete-horizontal-space - +digit-argument vi-command/append-arg +display-shell-version vi_nmap/@adjust display-shell-version +do-lowercase-version do-lowercase-version +downcase-word vi_nmap/downcase-eword +dump-functions vi_nmap/@adjust readline-dump-functions +dump-macros vi_nmap/@adjust readline-dump-macros +dump-variables vi_nmap/@adjust readline-dump-variables +dynamic-complete-history - +edit-and-execute-command vi-command/edit-and-execute-command +emacs-editing-mode emacs-editing-mode +end-kbd-macro end-keyboard-macro +end-of-history vi-command/history-end +end-of-line vi-command/forward-eol +exchange-point-and-mark - +execute-named-command vi-command/execute-named-command +fetch-history history-goto +forward-backward-delete-char - +forward-byte vi-command/forward-byte +forward-char vi-command/forward-char +forward-search-history history-isearch-forward +forward-word vi-command/forward-vword +glob-complete-word - +glob-expand-word - +glob-list-expansions - +history-and-alias-expand-line vi_nmap/@edit history-and-alias-expand-line +history-expand-line vi_nmap/@edit history-expand-line +history-search-backward history-search-backward empty=emulate-readline +history-search-forward history-search-forward empty=emulate-readline +history-substring-search-backward history-substring-search-backward +history-substring-search-forward history-substring-search-forward +insert-comment vi-rlfunc/insert-comment +insert-completions - +insert-last-argument - +kill-line vi_nmap/kill-forward-line +kill-region - +kill-whole-line - +kill-word vi-rlfunc/kill-word +magic-space - +menu-complete - +menu-complete-backward - +next-history vi-command/history-next +next-screen-line - +non-incremental-forward-search-history history-nsearch-forward +non-incremental-forward-search-history-again history-nsearch-forward-again +non-incremental-reverse-search-history history-nsearch-backward +non-incremental-reverse-search-history-again history-nsearch-backward-again +old-menu-complete - +operate-and-get-next - +overwrite-mode vi_nmap/replace-mode +possible-command-completions complete show_menu:context=command +possible-completions complete show_menu +possible-filename-completions complete show_menu:context=filename +possible-hostname-completions complete show_menu:context=hostname +possible-username-completions complete show_menu:context=username +possible-variable-completions complete show_menu:context=variable +previous-history vi-command/history-prev +previous-screen-line - +print-last-kbd-macro print-keyboard-macro +quoted-insert vi-rlfunc/quoted-insert +re-read-init-file vi_nmap/@adjust re-read-init-file +redraw-current-line redraw-line +reverse-search-history history-isearch-backward +revert-line vi_nmap/revert +self-insert - +set-mark vi_nmap/charwise-visual-mode +shell-backward-kill-word - +shell-backward-word - +shell-expand-line vi_nmap/@edit shell-expand-line +shell-forward-word - +shell-kill-word - +shell-transpose-words - +skip-csi-sequence +start-kbd-macro start-keyboard-macro +tab-insert - +tilde-expand vi_nmap/@edit tilde-expand +transpose-chars transpose-chars +transpose-words - +tty-status - +undo vi_nmap/undo +universal-argument - +unix-filename-rubout - +unix-line-discard vi-rlfunc/unix-line-discard +unix-word-rubout - +upcase-word vi_nmap/upcase-eword +vi-append-eol vi_nmap/append-mode-at-end-of-line +vi-append-mode vi_nmap/append-mode +vi-arg-digit vi-command/append-arg +vi-prev-word vi-rlfunc/prev-word +vi-backward-word vi-command/backward-vword +vi-backward-bigword vi-command/backward-uword +vi-bword vi-command/backward-vword +vi-bWord vi-command/backward-uword +vi-end-word vi-rlfunc/end-word +vi-end-bigword vi-command/forward-uword-end +vi-eword vi-command/forward-vword-end +vi-eWord vi-command/forward-uword-end +vi-next-word vi-rlfunc/next-word +vi-forward-word vi-command/forward-vword +vi-forward-bigword vi-command/forward-uword +vi-fword vi-command/forward-vword +vi-fWord vi-command/forward-uword +vi-back-to-indent - +vi-change-case vi-command/operator toggle_case +vi-change-char vi_nmap/replace-char +vi-change-to vi-rlfunc/change-to +vi-char-search vi-rlfunc/char-search +vi-column vi-command/nth-column +vi-complete - +vi-delete vi_nmap/kill-forward-char +vi-delete-to vi-rlfunc/delete-to +vi-editing-mode vi_nmap/insert-mode +vi-eof-maybe vi-rlfunc/eof-maybe +vi-fetch-history vi-command/history-goto +vi-first-print vi-command/first-non-space +vi-goto-mark vi-command/goto-mark +vi-insert-beg vi_nmap/insert-mode-at-first-non-space +vi-insertion-mode vi_nmap/insert-mode +vi-match vi-command/search-matchpair-or vi-command/percentage-line +vi-movement-mode nop +vi-overstrike - +vi-overstrike-delete - +vi-put vi-rlfunc/put +vi-redo vi_nmap/repeat +vi-replace vi_nmap/replace-mode +vi-rubout vi_nmap/kill-backward-char +vi-search vi-rlfunc/search +vi-search-again vi-rlfunc/search-again +vi-set-mark vi-command/set-mark +vi-subst vi-rlfunc/subst +vi-tilde-expand - +vi-undo vi_nmap/undo +vi-unix-word-rubout - +vi-yank-arg vi-rlfunc/yank-arg +vi-yank-pop - +vi-yank-to vi-rlfunc/yank-to +yank yank +yank-last-arg - +yank-nth-arg - +yank-pop - diff --git a/.local/share/blesh/lib/core-edit.ignoreeof-messages.txt b/.local/share/blesh/lib/core-edit.ignoreeof-messages.txt new file mode 100644 index 0000000..6588f87 --- /dev/null +++ b/.local/share/blesh/lib/core-edit.ignoreeof-messages.txt @@ -0,0 +1,32 @@ +Gebruik Kaart na Los Tronk +Използвайте „exit“, за да излезете от обвивката. +Utilitzeu ?exit? per a eixir de l'int?rpret d'ordres. +Shell lze ukončit příkazem „exit“. +Brug "exit" for at forlade skallen. +Benutze "exit" um die Shell zu verlassen. +Χρήση «exit» για έξοδο από το κέλυφος. +Use “exit” to leave the shell. +Use “exit” to leave the shell. +Uzu «exit» por eliri el la ŝelo. +Use "exit" para dejar el shell. +Kirjoita ”exit” poistuaksesi komentotulkista. +Utilisez « exit » pour quitter le shell. +Úsáid "exit" le scoir den mblaosc. +Use «exit» para deixar o shell. +Koristite „exit” za napuštanje ljuske. +„exit” használatával lehet elhagyni a parancsértelmezőt. +Gunakan "exit" untuk meninggalkan shell. +Usare "exit" per uscire dalla shell. +シェルから脱出するには "exit" を使用してください。 +Naudokite „exit“, jei norite išeiti iš ap. +Gebruik "exit" om de shell te verlaten. +Użyj "exit", aby opuścić tę powłokę. +Use "exit" para sair da `shell'. +Na opustenie shellu použite „exit“. +Uporabite "exit", če želite zapustiti lupino. +Користите „exit“ да напустите шкољку. +Använd "exit" fär att lämna skalet. +Kabuğu bırakmak için "exit" kullanın. +Використовуйте "exit", щоб вийти з оболонки. +Dùng "exit" để rời hệ vỏ. +使用 "exit" 退出 shell 。 diff --git a/.local/share/blesh/lib/core-syntax.sh b/.local/share/blesh/lib/core-syntax.sh new file mode 100644 index 0000000..39194cb --- /dev/null +++ b/.local/share/blesh/lib/core-syntax.sh @@ -0,0 +1,5627 @@ +# Copyright 2015 Koichi Murase . All rights reserved. +# This script is a part of blesh (https://github.com/akinomyoga/ble.sh) +# provided under the BSD-3-Clause license. Do not edit this file because this +# is not the original source code: Various pre-processing has been applied. +# Also, the code comments and blank lines are stripped off in the installation +# process. Please find the corresponding source file(s) in the repository +# "akinomyoga/ble.sh". +# +# Source: /lib/core-syntax.sh +function ble/syntax/util/is-directory { + local path=$1 + if [[ ( $OSTYPE == cygwin || $OSTYPE == msys ) && $path == //* ]]; then + [[ $path == // ]] + else + [[ -d $path ]] + fi +} +function ble/syntax/urange#update { + local prefix=$1 + local p1=$2 p2=${3:-$2} + ((0<=p1&&p1p1)&&(${prefix}umin=p1), + (${prefix}umax<0||${prefix}umaxp1)&&(${prefix}umin=p1), + (${prefix}umax<0||${prefix}umax=end0?(${prefix}umin+=shift):( + ${prefix}umin>=beg&&(${prefix}umin=end)), + ${prefix}umax>end0?(${prefix}umax+=shift):( + ${prefix}umax>beg&&(${prefix}umax=beg)), + ${prefix}umin>=${prefix}umax&& + (${prefix}umin=${prefix}umax=-1))) +} +function ble/syntax/wrange#shift { + local prefix=$1 + ((${prefix}umin>=end0?(${prefix}umin+=shift):( + ${prefix}umin>beg&&(${prefix}umin=end)), + ${prefix}umax>=end0?(${prefix}umax+=shift):( + ${prefix}umax>=beg&&(${prefix}umax=beg)), + ${prefix}umin==0&&++${prefix}umin, + ${prefix}umin>${prefix}umax&& + (${prefix}umin=${prefix}umax=-1))) +} +_ble_syntax_text= +_ble_syntax_lang=bash +_ble_syntax_stat=() +_ble_syntax_nest=() +_ble_syntax_tree=() +_ble_syntax_attr=() +_ble_syntax_TREE_WIDTH=5 +function ble/syntax/tree-enumerate/.add-root-element { + local wtype=$1 wlen=$2 tclen=$3 tplen=$4 + [[ ! ${wtype//[0-9]} && ${_ble_syntax_bash_command_EndWtype[wtype]} ]] && + wtype=${_ble_syntax_bash_command_EndWtype[wtype]} + TE_root="$wtype $wlen $tclen $tplen -- $TE_root" +} +function ble/syntax/tree-enumerate/.initialize { + if [[ ! ${_ble_syntax_stat[iN]} ]]; then + TE_root= TE_i=-1 TE_nofs=0 + return 0 + fi + local -a stat nest + ble/string#split-words stat "${_ble_syntax_stat[iN]}" + local wtype=${stat[2]} + local wlen=${stat[1]} + local nlen=${stat[3]} inest + ((inest=nlen<0?nlen:iN-nlen)) + local tclen=${stat[4]} + local tplen=${stat[5]} + TE_root= + ((iN>0)) && TE_root=${_ble_syntax_tree[iN-1]} + while + if ((wlen>=0)); then + ble/syntax/tree-enumerate/.add-root-element "$wtype" "$wlen" "$tclen" "$tplen" + tclen=0 + fi + ((inest>=0)) + do + ble/util/assert '[[ ${_ble_syntax_nest[inest]} ]]' "$FUNCNAME/FATAL1" || break + ble/string#split-words nest "${_ble_syntax_nest[inest]}" + local olen=$((iN-inest)) + tplen=${nest[4]} + ((tplen>=0&&(tplen+=olen))) + ble/syntax/tree-enumerate/.add-root-element "${nest[7]}" "$olen" "$tclen" "$tplen" + wtype=${nest[2]} wlen=${nest[1]} nlen=${nest[3]} tclen=0 tplen=${nest[5]} + ((wlen>=0&&(wlen+=olen), + tplen>=0&&(tplen+=olen), + nlen>=0&&(nlen+=olen), + inest=nlen<0?nlen:iN-nlen)) + ble/util/assert '((nlen<0||nlen>olen))' "$FUNCNAME/FATAL2" || break + done + if [[ $TE_root ]]; then + ((TE_i=iN)) + else + ((TE_i=tclen>=0?iN-tclen:tclen)) + fi + ((TE_nofs=0)) +} +function ble/syntax/tree-enumerate/.impl { + local islast=1 + while ((TE_i>0)); do + local -a node + if ((TE_i=beg;TE_i--)); do + ((TE_i>0)) && [[ ${_ble_syntax_tree[TE_i-1]} ]] || continue + ble/string#split-words node "${_ble_syntax_tree[TE_i-1]}" + local flagUpdateNode= + for ((TE_nofs=0;TE_nofs<${#node[@]};TE_nofs+=_ble_syntax_TREE_WIDTH)); do + local wtype=${node[TE_nofs]} wlen=${node[TE_nofs+1]} wattr=${node[TE_nofs+4]} + local wbeg=$((wlen<0?wlen:TE_i-wlen)) wend=$TE_i + "${@:3}" + done + done +} +function ble/syntax/print-status/.graph { + local char=$1 + if ble/util/isprint+ "$char"; then + graph="'$char'" + return 0 + else + local ret + ble/util/s2c "$char" + local code=$ret + if ((code<32)); then + ble/util/c2s "$((code+64))" + graph="$_ble_term_rev^$ret$_ble_term_sgr0" + elif ((code==127)); then + graph="$_ble_term_rev^?$_ble_term_sgr0" + elif ((128<=code&&code<160)); then + ble/util/c2s "$((code-64))" + graph="${_ble_term_rev}M-^$ret$_ble_term_sgr0" + else + graph="'$char' ($code)" + fi + fi +} +function ble/syntax/print-status/.tree-prepend { + local j=$1 + local value=$2${tree[j]} + tree[j]=$value + ((max_tree_width<${#value}&&(max_tree_width=${#value}))) +} +function ble/syntax/print-status/.dump-arrays/.append-attr-char { + if (($?==0)); then + attr="${attr}$1" + else + attr="${attr} " + fi +} +function ble/syntax/print-status/ctx#get-text { + local sgr + ble/syntax/ctx#get-name "$1" + ret=${ret#BLE_} + if [[ ! $ret ]]; then + ble/color/face2sgr syntax_error + ret="${ret}CTX$1$_ble_term_sgr0" + fi +} +function ble/syntax/print-status/word.get-text { + local index=$1 + ble/string#split-words word "${_ble_syntax_tree[index]}" + local out= ret + if [[ $word ]]; then + local nofs=$((${#word[@]}/_ble_syntax_TREE_WIDTH*_ble_syntax_TREE_WIDTH)) + while (((nofs-=_ble_syntax_TREE_WIDTH)>=0)); do + local axis=$((index+1)) + local wtype=${word[nofs]} + if [[ $wtype =~ ^[0-9]+$ ]]; then + ble/syntax/print-status/ctx#get-text "$wtype"; wtype=$ret + elif [[ $wtype =~ ^n* ]]; then + wtype=$sgr_quoted\"${wtype:1}\"$_ble_term_sgr0 + else + wtype=$sgr_error${wtype}$_ble_term_sgr0 + fi + local b=$((axis-word[nofs+1])) e=$axis + local sprev=${word[nofs+3]} schild=${word[nofs+2]} + if ((sprev>=0)); then + sprev="@$((axis-sprev-1))>" + else + sprev= + fi + if ((schild>=0)); then + schild=">@$((axis-schild-1))" + else + schild= + fi + local wattr=${word[nofs+4]} + if [[ $wattr != - ]]; then + wattr="/(wattr=$wattr)" + else + wattr= + fi + out=" word=$wtype:$sprev$b-$e$schild$wattr$out" + for ((;b=0)); then + ble/syntax/print-status/ctx#get-text "${nest[2]}"; local swtype=$ret + local wbegin=$((index-nest[1])) + nword="$swtype:$wbegin-" + fi + local nnest=- + ((nest[3]>=0)) && nnest="'${nest[7]}':$((index-nest[3]))-" + local nchild=- + if ((nest[4]>=0)); then + local tchild=$((index-nest[4])) + nchild='$'$tchild + if ! ((0=0)); then + local tprev=$((index-nest[5])) + nprev='$'$tprev + if ! ((0=0)); then + ble/syntax/print-status/ctx#get-text "${stat[2]}"; local stat_wtype=$ret + stat_word="$stat_wtype:$((index-stat[1]))-" + fi + local stat_inest=- + if ((stat[3]>=0)); then + local inest=$((index-stat[3])) + stat_inest="@$inest" + if ((inest<0)) || [[ ! ${_ble_syntax_nest[inest]} ]]; then + stat_inest=$sgr_error$stat_inest$_ble_term_sgr0 + fi + fi + local stat_child=- + if ((stat[4]>=0)); then + local tchild=$((index-stat[4])) + stat_child='$'$tchild + if ! ((0=0)); then + local tprev=$((index-stat[5])) + stat_prev='$'$tprev + if ! ((0ilook&&(ilook=i+$1))) +} +function ble/syntax/parse/tree-append { + [[ $debug_p1 ]] && ble/util/assert '((i-1>=debug_p1))' "Wrong call of tree-append: Condition violation (p1=$debug_p1 i=$i iN=$iN)." + local type=$1 + local beg=$2 end=$i + local len=$((end-beg)) + ((len==0)) && return 0 + local tchild=$3 tprev=$4 + local ochild=-1 oprev=-1 + ((tchild>=0&&(ochild=i-tchild))) + ((tprev>=0&&(oprev=i-tprev))) + [[ $type =~ ^[0-9]+$ ]] && ble/syntax/parse/touch-updated-word "$i" + _ble_syntax_tree[i-1]="$type $len $ochild $oprev - ${_ble_syntax_tree[i-1]}" +} +function ble/syntax/parse/word-push { + wtype=$1 wbegin=$2 tprev=$tchild tchild=-1 +} +function ble/syntax/parse/word-pop { + ble/syntax/parse/tree-append "$wtype" "$wbegin" "$tchild" "$tprev" + ((wbegin=-1,wtype=-1,tchild=i)) + ble/syntax/parse/nest-reset-tprev +} +function ble/syntax/parse/word-cancel { + local -a word + ble/string#split-words word "${_ble_syntax_tree[i-1]}" + local wlen=${word[1]} tplen=${word[3]} + local wbegin=$((i-wlen)) + tchild=$((tplen<0?tplen:i-tplen)) + ble/array#fill-range _ble_syntax_tree "$wbegin" "$i" '' +} +function ble/syntax/parse/nest-push { + local wlen=$((wbegin<0?wbegin:i-wbegin)) + local nlen=$((inest<0?inest:i-inest)) + local tclen=$((tchild<0?tchild:i-tchild)) + local tplen=$((tprev<0?tprev:i-tprev)) + _ble_syntax_nest[i]="$ctx $wlen $wtype $nlen $tclen $tplen ${nparam:-none} ${2:-none}" + ((ctx=$1,inest=i,wbegin=-1,wtype=-1,tprev=tchild,tchild=-1)) + nparam= +} +function ble/syntax/parse/nest-pop { + ((inest<0)) && return 1 + local -a parentNest + ble/string#split-words parentNest "${_ble_syntax_nest[inest]}" + local ntype=${parentNest[7]} nbeg=$inest + ble/syntax/parse/tree-append "n$ntype" "$nbeg" "$tchild" "$tprev" + local wlen=${parentNest[1]} nlen=${parentNest[3]} tplen=${parentNest[5]} + ((ctx=parentNest[0])) + ((wtype=parentNest[2])) + ((wbegin=wlen<0?wlen:nbeg-wlen, + inest=nlen<0?nlen:nbeg-nlen, + tchild=i, + tprev=tplen<0?tplen:nbeg-tplen)) + nparam=${parentNest[6]} + [[ $nparam == none ]] && nparam= +} +function ble/syntax/parse/nest-type { + local _ble_local_var=ntype + [[ $1 == -v ]] && _ble_local_var=$2 + if ((inest<0)); then + builtin eval "$_ble_local_var=" + return 1 + else + builtin eval "$_ble_local_var=\"\${_ble_syntax_nest[inest]##* }\"" + fi +} +function ble/syntax/parse/nest-ctx { + nctx= + ((inest>=0)) || return 1 + nctx=${_ble_syntax_nest[inest]%% *} +} +function ble/syntax/parse/nest-reset-tprev { + if ((inest<0)); then + tprev=-1 + else + local -a nest + ble/string#split-words nest "${_ble_syntax_nest[inest]}" + local tclen=${nest[4]} + ((tprev=tclen<0?tclen:inest-tclen)) + fi +} +function ble/syntax/parse/nest-equals { + local parent_inest=$1 + while :; do + ((parent_inest0))" "invalid word position $1" + ble/syntax/wrange#update _ble_syntax_word_ "$1" +} +_ble_ctx_UNSPECIFIED=0 +_ble_ctx_ARGX=3 +_ble_ctx_ARGX0=18 +_ble_ctx_ARGI=4 +_ble_ctx_ARGQ=61 +_ble_ctx_CMDX=1 +_ble_ctx_CMDX0=82 +_ble_ctx_CMDX1=17 +_ble_ctx_CMDXT=49 +_ble_ctx_CMDXC=26 +_ble_ctx_CMDXE=43 +_ble_ctx_CMDXD0=38 +_ble_ctx_CMDXD=68 +_ble_ctx_CMDXV=13 +_ble_ctx_CMDI=2 +_ble_ctx_VRHS=11 +_ble_ctx_QUOT=5 +_ble_ctx_EXPR=8 +_ble_attr_ERR=6 +_ble_attr_VAR=7 +_ble_attr_QDEL=9 +_ble_attr_QESC=81 +_ble_attr_DEF=10 +_ble_attr_DEL=12 +_ble_attr_HISTX=21 +_ble_attr_FUNCDEF=22 +_ble_ctx_PARAM=14 +_ble_ctx_PWORD=15 +_ble_ctx_PWORDE=73 +_ble_ctx_PWORDR=72 +_ble_ctx_RDRF=19 +_ble_ctx_RDRD=20 +_ble_ctx_RDRD2=80 +_ble_ctx_RDRS=27 +_ble_ctx_VALX=23 +_ble_ctx_VALI=24 +_ble_ctx_VALR=65 +_ble_ctx_VALQ=66 +_ble_attr_COMMENT=25 +_ble_ctx_ARGVX=28 +_ble_ctx_ARGVI=29 +_ble_ctx_ARGVR=62 +_ble_ctx_CONDX=32 +_ble_ctx_CONDI=33 +_ble_ctx_CONDQ=67 +_ble_ctx_CASE=34 +_ble_ctx_CPATX=76 +_ble_ctx_CPATI=77 +_ble_ctx_CPATQ=79 +_ble_ctx_CPATX0=78 +_ble_ctx_PATN=30 +_ble_attr_GLOB=31 +_ble_ctx_BRAX=54 +_ble_attr_BRACE=55 +_ble_ctx_BRACE1=56 +_ble_ctx_BRACE2=57 +_ble_attr_TILDE=60 +_ble_ctx_FARGX1=16 +_ble_ctx_FARGI1=35 +_ble_ctx_FARGX2=36 +_ble_ctx_FARGI2=37 +_ble_ctx_FARGX3=58 +_ble_ctx_FARGI3=59 +_ble_ctx_FARGQ3=63 +_ble_ctx_SARGX1=48 +_ble_ctx_CARGX1=39 +_ble_ctx_CARGI1=40 +_ble_ctx_CARGQ1=64 +_ble_ctx_CARGX2=41 +_ble_ctx_CARGI2=42 +_ble_ctx_TARGX1=50 +_ble_ctx_TARGI1=51 +_ble_ctx_TARGX2=52 +_ble_ctx_TARGI2=53 +_ble_ctx_RDRH=44 +_ble_ctx_RDRI=45 +_ble_ctx_HERE0=46 +_ble_ctx_HERE1=47 +_ble_ctx_ARGEX=69 +_ble_ctx_ARGEI=70 +_ble_ctx_ARGER=71 +_ble_ctx_COARGX=74 +_ble_ctx_COARGI=75 +_ble_attr_CMD_BOLD=101 +_ble_attr_CMD_BUILTIN=102 +_ble_attr_CMD_ALIAS=103 +_ble_attr_CMD_FUNCTION=104 +_ble_attr_CMD_FILE=105 +_ble_attr_KEYWORD=106 +_ble_attr_KEYWORD_BEGIN=118 +_ble_attr_KEYWORD_END=119 +_ble_attr_KEYWORD_MID=120 +_ble_attr_CMD_JOBS=107 +_ble_attr_CMD_DIR=112 +_ble_attr_CMD_SUFFIX=135 +_ble_attr_CMD_SUFFIX_NEW=136 +_ble_attr_FILE_DIR=108 +_ble_attr_FILE_STICKY=124 +_ble_attr_FILE_LINK=109 +_ble_attr_FILE_ORPHAN=121 +_ble_attr_FILE_FILE=111 +_ble_attr_FILE_SETUID=122 +_ble_attr_FILE_SETGID=123 +_ble_attr_FILE_EXEC=110 +_ble_attr_FILE_FIFO=114 +_ble_attr_FILE_CHR=115 +_ble_attr_FILE_BLK=116 +_ble_attr_FILE_SOCK=117 +_ble_attr_FILE_WARN=113 +_ble_attr_FILE_URL=125 +_ble_attr_VAR_UNSET=126 +_ble_attr_VAR_EMPTY=127 +_ble_attr_VAR_NUMBER=128 +_ble_attr_VAR_EXPR=129 +_ble_attr_VAR_ARRAY=130 +_ble_attr_VAR_HASH=132 +_ble_attr_VAR_READONLY=131 +_ble_attr_VAR_TRANSFORM=133 +_ble_attr_VAR_EXPORT=134 +_ble_syntax_bash_ctx_names=( + [0]=_ble_ctx_UNSPECIFIED + [3]=_ble_ctx_ARGX + [18]=_ble_ctx_ARGX0 + [4]=_ble_ctx_ARGI + [61]=_ble_ctx_ARGQ + [1]=_ble_ctx_CMDX + [82]=_ble_ctx_CMDX0 + [17]=_ble_ctx_CMDX1 + [49]=_ble_ctx_CMDXT + [26]=_ble_ctx_CMDXC + [43]=_ble_ctx_CMDXE + [38]=_ble_ctx_CMDXD0 + [68]=_ble_ctx_CMDXD + [13]=_ble_ctx_CMDXV + [2]=_ble_ctx_CMDI + [11]=_ble_ctx_VRHS + [5]=_ble_ctx_QUOT + [8]=_ble_ctx_EXPR + [6]=_ble_attr_ERR + [7]=_ble_attr_VAR + [9]=_ble_attr_QDEL + [81]=_ble_attr_QESC + [10]=_ble_attr_DEF + [12]=_ble_attr_DEL + [21]=_ble_attr_HISTX + [22]=_ble_attr_FUNCDEF + [14]=_ble_ctx_PARAM + [15]=_ble_ctx_PWORD + [73]=_ble_ctx_PWORDE + [72]=_ble_ctx_PWORDR + [19]=_ble_ctx_RDRF + [20]=_ble_ctx_RDRD + [80]=_ble_ctx_RDRD2 + [27]=_ble_ctx_RDRS + [23]=_ble_ctx_VALX + [24]=_ble_ctx_VALI + [65]=_ble_ctx_VALR + [66]=_ble_ctx_VALQ + [25]=_ble_attr_COMMENT + [28]=_ble_ctx_ARGVX + [29]=_ble_ctx_ARGVI + [62]=_ble_ctx_ARGVR + [32]=_ble_ctx_CONDX + [33]=_ble_ctx_CONDI + [67]=_ble_ctx_CONDQ + [34]=_ble_ctx_CASE + [76]=_ble_ctx_CPATX + [77]=_ble_ctx_CPATI + [79]=_ble_ctx_CPATQ + [78]=_ble_ctx_CPATX0 + [30]=_ble_ctx_PATN + [31]=_ble_attr_GLOB + [54]=_ble_ctx_BRAX + [55]=_ble_attr_BRACE + [56]=_ble_ctx_BRACE1 + [57]=_ble_ctx_BRACE2 + [60]=_ble_attr_TILDE + [16]=_ble_ctx_FARGX1 + [35]=_ble_ctx_FARGI1 + [36]=_ble_ctx_FARGX2 + [37]=_ble_ctx_FARGI2 + [58]=_ble_ctx_FARGX3 + [59]=_ble_ctx_FARGI3 + [63]=_ble_ctx_FARGQ3 + [48]=_ble_ctx_SARGX1 + [39]=_ble_ctx_CARGX1 + [40]=_ble_ctx_CARGI1 + [64]=_ble_ctx_CARGQ1 + [41]=_ble_ctx_CARGX2 + [42]=_ble_ctx_CARGI2 + [50]=_ble_ctx_TARGX1 + [51]=_ble_ctx_TARGI1 + [52]=_ble_ctx_TARGX2 + [53]=_ble_ctx_TARGI2 + [44]=_ble_ctx_RDRH + [45]=_ble_ctx_RDRI + [46]=_ble_ctx_HERE0 + [47]=_ble_ctx_HERE1 + [69]=_ble_ctx_ARGEX + [70]=_ble_ctx_ARGEI + [71]=_ble_ctx_ARGER + [74]=_ble_ctx_COARGX + [75]=_ble_ctx_COARGI + [101]=_ble_attr_CMD_BOLD + [102]=_ble_attr_CMD_BUILTIN + [103]=_ble_attr_CMD_ALIAS + [104]=_ble_attr_CMD_FUNCTION + [105]=_ble_attr_CMD_FILE + [106]=_ble_attr_KEYWORD + [118]=_ble_attr_KEYWORD_BEGIN + [119]=_ble_attr_KEYWORD_END + [120]=_ble_attr_KEYWORD_MID + [107]=_ble_attr_CMD_JOBS + [112]=_ble_attr_CMD_DIR + [135]=_ble_attr_CMD_SUFFIX + [136]=_ble_attr_CMD_SUFFIX_NEW + [108]=_ble_attr_FILE_DIR + [124]=_ble_attr_FILE_STICKY + [109]=_ble_attr_FILE_LINK + [121]=_ble_attr_FILE_ORPHAN + [111]=_ble_attr_FILE_FILE + [122]=_ble_attr_FILE_SETUID + [123]=_ble_attr_FILE_SETGID + [110]=_ble_attr_FILE_EXEC + [114]=_ble_attr_FILE_FIFO + [115]=_ble_attr_FILE_CHR + [116]=_ble_attr_FILE_BLK + [117]=_ble_attr_FILE_SOCK + [113]=_ble_attr_FILE_WARN + [125]=_ble_attr_FILE_URL + [126]=_ble_attr_VAR_UNSET + [127]=_ble_attr_VAR_EMPTY + [128]=_ble_attr_VAR_NUMBER + [129]=_ble_attr_VAR_EXPR + [130]=_ble_attr_VAR_ARRAY + [132]=_ble_attr_VAR_HASH + [131]=_ble_attr_VAR_READONLY + [133]=_ble_attr_VAR_TRANSFORM + [134]=_ble_attr_VAR_EXPORT +) +function ble/syntax/ctx#get-name { + ret=${_ble_syntax_bash_ctx_names[$1]#_ble_ctx_} +} +_ble_syntax_context_proc=() +_ble_syntax_context_end=() +function ble/syntax:text/ctx-unspecified { + ((i+=${#tail})) + return 0 +} +_ble_syntax_context_proc[_ble_ctx_UNSPECIFIED]=ble/syntax:text/ctx-unspecified +function ble/syntax:text/initialize-ctx { ctx=$_ble_ctx_UNSPECIFIED; } +function ble/syntax:text/initialize-vars { return 0; } +_ble_syntax_bash_RexSpaces=$'[ \t]+' +_ble_syntax_bash_RexIFSs="[$_ble_term_IFS]+" +_ble_syntax_bash_RexDelimiter="[$_ble_term_IFS;|&<>()]" +_ble_syntax_bash_RexRedirect='((\{[_a-zA-Z][_a-zA-Z0-9]*\}|[0-9]+)?(&?>>?|>[|&]|<[>&]?|<<[-<]?))[ ]*' +_ble_syntax_bash_chars=() +_ble_syntax_bashc_seed= +function ble/syntax:bash/cclass/update/reorder { + builtin eval "local a=\"\${$1}\"" + [[ $a == *']'* ]] && a="]${a//]}" + [[ $a == *'-'* ]] && a="${a//-}-" + builtin eval "$1=\$a" +} +function ble/syntax:bash/cclass/update { + local seed=$_ble_syntax_bash_histc12 + shopt -q extglob && seed=${seed}x + [[ $seed == "$_ble_syntax_bashc_seed" ]] && return 1 + _ble_syntax_bashc_seed=$seed + local key modified= + if [[ $_ble_syntax_bash_histc12 == '!^' ]]; then + for key in "${!_ble_syntax_bash_charsDef[@]}"; do + _ble_syntax_bash_chars[key]=${_ble_syntax_bash_charsDef[key]} + done + _ble_syntax_bashc_simple=$_ble_syntax_bash_chars_simpleDef + else + modified=1 + local histc1=${_ble_syntax_bash_histc12:0:1} + local histc2=${_ble_syntax_bash_histc12:1:1} + for key in "${!_ble_syntax_bash_charsFmt[@]}"; do + local a=${_ble_syntax_bash_charsFmt[key]} + a=${a//@h/"$histc1"} + a=${a//@q/"$histc2"} + _ble_syntax_bash_chars[key]=$a + done + local a=$_ble_syntax_bash_chars_simpleFmt + a=${a//@h/"$histc1"} + a=${a//@q/"$histc2"} + _ble_syntax_bashc_simple=$a + fi + if [[ $seed == *x ]]; then + local extglob='@+!' # *? は既に登録されている筈 + _ble_syntax_bash_chars[_ble_ctx_ARGI]=${_ble_syntax_bash_chars[_ble_ctx_ARGI]}$extglob + _ble_syntax_bash_chars[_ble_ctx_PATN]=${_ble_syntax_bash_chars[_ble_ctx_PATN]}$extglob + _ble_syntax_bash_chars[_ble_ctx_PWORD]=${_ble_syntax_bash_chars[_ble_ctx_PWORD]}$extglob + _ble_syntax_bash_chars[_ble_ctx_PWORDE]=${_ble_syntax_bash_chars[_ble_ctx_PWORDE]}$extglob + _ble_syntax_bash_chars[_ble_ctx_PWORDR]=${_ble_syntax_bash_chars[_ble_ctx_PWORDR]}$extglob + fi + if [[ $modified ]]; then + for key in "${!_ble_syntax_bash_chars[@]}"; do + ble/syntax:bash/cclass/update/reorder _ble_syntax_bash_chars[key] + done + ble/syntax:bash/cclass/update/reorder _ble_syntax_bashc_simple + fi + return 0 +} +_ble_syntax_bash_charsDef=() +_ble_syntax_bash_charsFmt=() +_ble_syntax_bash_chars_simpleDef= +_ble_syntax_bash_chars_simpleFmt= +function ble/syntax:bash/cclass/initialize { + local delimiters="$_ble_term_IFS;|&()<>" + local expansions="\$\"\`\\'" + local glob='[*?' + local tilde='~:' + _ble_syntax_bash_charsDef[_ble_ctx_ARGI]="$delimiters$expansions$glob{$tilde^!" + _ble_syntax_bash_charsDef[_ble_ctx_PATN]="$expansions$glob(|)<>{!" # <> はプロセス置換のため。 + _ble_syntax_bash_charsDef[_ble_ctx_QUOT]="\$\"\`\\!" # 文字列 "~" で特別な意味を持つのは $ ` \ " のみ。+履歴展開の ! も。 + _ble_syntax_bash_charsDef[_ble_ctx_EXPR]="][}()$expansions!" # ()[] は入れ子を数える為。} は ${var:ofs:len} の為。 + _ble_syntax_bash_charsDef[_ble_ctx_PWORD]="}$expansions$glob!" # パラメータ展開 ${~} + _ble_syntax_bash_charsDef[_ble_ctx_PWORDE]="}$expansions$glob!" # パラメータ展開 ${~} エラー + _ble_syntax_bash_charsDef[_ble_ctx_PWORDR]="}/$expansions$glob!" # パラメータ展開 ${~} 置換前 + _ble_syntax_bash_charsDef[_ble_ctx_RDRH]="$delimiters$expansions" + _ble_syntax_bash_charsDef[_ble_ctx_HERE1]="\\\$\`$_ble_term_nl!" + _ble_syntax_bash_charsFmt[_ble_ctx_ARGI]="$delimiters$expansions$glob{$tilde@q@h" + _ble_syntax_bash_charsFmt[_ble_ctx_PATN]="$expansions$glob(|)<>{@h" + _ble_syntax_bash_charsFmt[_ble_ctx_QUOT]="\$\"\`\\@h" + _ble_syntax_bash_charsFmt[_ble_ctx_EXPR]="][}()$expansions@h" + _ble_syntax_bash_charsFmt[_ble_ctx_PWORD]="}$expansions$glob@h" + _ble_syntax_bash_charsFmt[_ble_ctx_PWORDE]="}$expansions$glob@h" + _ble_syntax_bash_charsFmt[_ble_ctx_PWORDR]="}/$expansions$glob@h" + _ble_syntax_bash_charsFmt[_ble_ctx_RDRH]=${_ble_syntax_bash_charsDef[_ble_ctx_RDRH]} + _ble_syntax_bash_charsFmt[_ble_ctx_HERE1]="\\\$\`$_ble_term_nl@h" + _ble_syntax_bash_chars_simpleDef="$delimiters$expansions^!" + _ble_syntax_bash_chars_simpleFmt="$delimiters$expansions@q@h" + _ble_syntax_bash_histc12='!^' + ble/syntax:bash/cclass/update +} +ble/syntax:bash/cclass/initialize +_ble_syntax_bash_simple_rex_letter= +_ble_syntax_bash_simple_rex_param= +_ble_syntax_bash_simple_rex_bquot= +_ble_syntax_bash_simple_rex_squot= +_ble_syntax_bash_simple_rex_dquot= +_ble_syntax_bash_simple_rex_literal= +_ble_syntax_bash_simple_rex_element= +_ble_syntax_bash_simple_rex_word= +_ble_syntax_bash_simple_rex_open_word= +_ble_syntax_bash_simple_rex_open_dquot= +_ble_syntax_bash_simple_rex_open_squot= +_ble_syntax_bash_simple_rex_incomplete_word1= +_ble_syntax_bash_simple_rex_incomplete_word2= +_ble_syntax_bash_simple_rex_noglob_word1= +_ble_syntax_bash_simple_rex_noglob_word2= +function ble/syntax:bash/simple-word/update { + local q="'" + local letter='\[[!^]|[^'${_ble_syntax_bashc_simple}']' + local param1='\$([-*@#?$!0_]|[1-9][0-9]*|[_a-zA-Z][_a-zA-Z0-9]*)' + local param2='\$\{(#?[-*@#?$!0]|[#!]?([1-9][0-9]*|[_a-zA-Z][_a-zA-Z0-9]*))\}' # ${!!} ${!$} はエラーになる。履歴展開の所為? + local param=$param1'|'$param2 + local bquot='\\.' + local squot=$q'[^'$q']*'$q'|\$'$q'([^'$q'\]|\\.)*'$q + local dquot='\$?"([^'${_ble_syntax_bash_chars[_ble_ctx_QUOT]}']|\\.|'$param')*"' + _ble_syntax_bash_simple_rex_letter=$letter # 0 groups + _ble_syntax_bash_simple_rex_param=$param # 3 groups + _ble_syntax_bash_simple_rex_bquot=$bquot # 0 groups + _ble_syntax_bash_simple_rex_squot=$squot # 1 groups + _ble_syntax_bash_simple_rex_dquot=$dquot # 4 groups + _ble_syntax_bash_simple_rex_literal='^('$letter')+$' + _ble_syntax_bash_simple_rex_element='('$bquot'|'$squot'|'$dquot'|'$param'|'$letter')' + _ble_syntax_bash_simple_rex_word='^'$_ble_syntax_bash_simple_rex_element'+$' + local open_squot=$q'[^'$q']*|\$'$q'([^'$q'\]|\\.)*' + local open_dquot='\$?"([^'${_ble_syntax_bash_chars[_ble_ctx_QUOT]}']|\\.|'$param')*' + _ble_syntax_bash_simple_rex_open_word='^('$_ble_syntax_bash_simple_rex_element'*)(\\|'$open_squot'|'$open_dquot')$' + _ble_syntax_bash_simple_rex_open_squot=$open_squot + _ble_syntax_bash_simple_rex_open_dquot=$open_dquot + local letter1='\[[!^]|[^{'${_ble_syntax_bashc_simple}']' + local letter2='\[[!^]|[^'${_ble_syntax_bashc_simple}']' + _ble_syntax_bash_simple_rex_incomplete_word1='^('$bquot'|'$squot'|'$dquot'|'$param'|'$letter1')+' + _ble_syntax_bash_simple_rex_incomplete_word2='^(('$bquot'|'$squot'|'$dquot'|'$param'|'$letter2')*)(\\|'$open_squot'|'$open_dquot')?$' + local noglob_letter='[^[?*'${_ble_syntax_bashc_simple}']' + _ble_syntax_bash_simple_rex_noglob_word1='^('$bquot'|'$squot'|'$dquot'|'$noglob_letter')+$' + _ble_syntax_bash_simple_rex_noglob_word2='^('$bquot'|'$squot'|'$dquot'|'$param'|'$noglob_letter')+$' +} +ble/syntax:bash/simple-word/update +function ble/syntax:bash/simple-word/is-literal { + [[ $1 =~ $_ble_syntax_bash_simple_rex_literal ]] +} +function ble/syntax:bash/simple-word/is-simple { + [[ $1 =~ $_ble_syntax_bash_simple_rex_word ]] +} +function ble/syntax:bash/simple-word/is-simple-or-open-simple { + [[ $1 =~ $_ble_syntax_bash_simple_rex_word || $1 =~ $_ble_syntax_bash_simple_rex_open_word ]] +} +function ble/syntax:bash/simple-word/is-never-word { + ble/syntax:bash/simple-word/is-simple-or-open-simple && return 1 + local rex=${_ble_syntax_bash_simple_rex_word%'$'}'[ |&;<>()]|^[ |&;<>()]' + [[ $1 =~ $rex ]] +} +function ble/syntax:bash/simple-word/is-simple-noglob { + [[ $1 =~ $_ble_syntax_bash_simple_rex_noglob_word1 ]] && return 0 + if [[ $1 =~ $_ble_syntax_bash_simple_rex_noglob_word2 ]]; then + builtin eval -- "local expanded=$1" 2>/dev/null + local rex='[*?]|\[.+\]|[*?@+!]\(.*\)' + [[ $expanded =~ $rex ]] || return 0 + fi + return 1 +} +function ble/syntax:bash/simple-word/evaluate-last-brace-expansion { + local value=$1 + local bquot=$_ble_syntax_bash_simple_rex_bquot + local squot=$_ble_syntax_bash_simple_rex_squot + local dquot=$_ble_syntax_bash_simple_rex_dquot + local param=$_ble_syntax_bash_simple_rex_param + local letter='\[[!^]|[^{,}'${_ble_syntax_bashc_simple}']' + local symbol='[{,}]' + local rex_range_expansion='^(([-+]?[0-9]+)\.\.\.[-+]?[0-9]+|([a-zA-Z])\.\.[a-zA-Z])(\.\.[-+]?[0-9]+)?$' + local rex0='^('$bquot'|'$squot'|'$dquot'|'$param'|'$letter')+' + local stack; stack=() + local out= comma= index=0 iopen=0 no_brace_length=0 + while [[ $value ]]; do + if [[ $value =~ $rex0 ]]; then + local len=${#BASH_REMATCH} + ((index+=len,no_brace_length+=len)) + out=$out${value::len} + value=${value:len} + elif [[ $value == '{'* ]]; then + ((iopen=++index,no_brace_length=0)) + value=${value:1} + ble/array#push stack "$comma:$out" + out= comma= + elif ((${#stack[@]})) && [[ $value == '}'* ]]; then + ((++index)) + value=${value:1} + ble/array#pop stack + local out0=${ret#*:} comma0=${ret%%:*} + if [[ $comma ]]; then + ((iopen=index,no_brace_length=0)) + out=$out0$out + comma=$comma0 + elif [[ $out =~ $rex_range_expansion ]]; then + ((iopen=index,no_brace_length=0)) + out=$out0${2#+}$3 + comma=$comma0 + else + ((++no_brace_length)) + ble/array#push stack "$comma0:$out0" # cancel pop + out=$out'}' + fi + elif ((${#stack[@]})) && [[ $value == ','* ]]; then + ((iopen=++index,no_brace_length=0)) + value=${value:1} + out= comma=1 + else + ((++index,++no_brace_length)) + out=$out${value::1} + value=${value:1} + fi + done + while ((${#stack[@]})); do + ble/array#pop stack + local out0=${ret#*:} comma0=${ret%%:*} + out=$out0$out + done + ret=$out simple_ibrace=$iopen:$((${#out}-no_brace_length)) +} +function ble/syntax:bash/simple-word/reconstruct-incomplete-word { + local word=$1 + ret= simple_flags= simple_ibrace=0:0 + [[ $word ]] || return 0 + if [[ $word =~ $_ble_syntax_bash_simple_rex_incomplete_word1 ]]; then + ret=${word::${#BASH_REMATCH}} + word=${word:${#BASH_REMATCH}} + [[ $word ]] || return 0 + fi + if [[ $word =~ $_ble_syntax_bash_simple_rex_incomplete_word2 ]]; then + local out=$ret + local m_brace=${BASH_REMATCH[1]} + local m_quote=${word:${#m_brace}} + if [[ $m_brace ]]; then + ble/syntax:bash/simple-word/evaluate-last-brace-expansion "$m_brace" + simple_ibrace=$((${#out}+${simple_ibrace%:*})):$((${#out}+${simple_ibrace#*:})) + out=$out$ret + fi + if [[ $m_quote ]]; then + case $m_quote in + ('$"'*) out=$out$m_quote\" simple_flags=I ;; + ('"'*) out=$out$m_quote\" simple_flags=D ;; + ("$'"*) out=$out$m_quote\' simple_flags=E ;; + ("'"*) out=$out$m_quote\' simple_flags=S ;; + ('\') simple_flags=B ;; + (*) return 1 ;; + esac + fi + ret=$out + return 0 + fi + return 1 +} +function ble/syntax:bash/simple-word/extract-parameter-names { + ret=() + local letter=$_ble_syntax_bash_simple_rex_letter + local bquot=$_ble_syntax_bash_simple_rex_bquot + local squot=$_ble_syntax_bash_simple_rex_squot + local dquot=$_ble_syntax_bash_simple_rex_dquot + local param=$_ble_syntax_bash_simple_rex_param + local value=$1 + local rex0='^('$letter'|'$bquot'|'$squot')+' + local rex1='^('$dquot')' + local rex2='^('$param')' + while [[ $value ]]; do + [[ $value =~ $rex0 ]] && value=${value:${#BASH_REMATCH}} + if [[ $value =~ $rex1 ]]; then + value=${value:${#BASH_REMATCH}} + ble/syntax:bash/simple-word/extract-parameter-names/.process-dquot "$BASH_REMATCH" + fi + [[ $value =~ $rex2 ]] || break + value=${value:${#BASH_REMATCH}} + local var=${BASH_REMATCH[2]}${BASH_REMATCH[3]} + [[ $var == [_a-zA-Z]* ]] && ble/array#push ret "$var" + done +} +function ble/syntax:bash/simple-word/extract-parameter-names/.process-dquot { + local value=$1 + if [[ $value == '$"'*'"' ]]; then + value=${value:2:${#value}-3} + elif [[ $value == '"'*'"' ]]; then + value=${value:1:${#value}-2} + else + return 0 + fi + local rex0='^([^'${_ble_syntax_bash_chars[_ble_ctx_QUOT]}']|\\.)+' + local rex2='^('$param')' + while [[ $value ]]; do + [[ $value =~ $rex0 ]] && value=${value:${#BASH_REMATCH}} + [[ $value =~ $rex2 ]] || break + value=${value:${#BASH_REMATCH}} + local var=${BASH_REMATCH[2]}${BASH_REMATCH[3]} + [[ $var == [_a-zA-Z]* ]] && ble/array#push ret "$var" + done +} +function ble/syntax:bash/simple-word/eval/.set-result { __ble_ret=("$@"); } +function ble/syntax:bash/simple-word/eval/.print-result { + if (($#>=1000)) && [[ $OSTYPE != cygwin ]]; then + if ((_ble_bash>=50200)); then + printf '%s\0' "$@" >| "$__ble_simple_word_tmpfile" + ble/util/print 'ble/util/readarray -d "" __ble_ret < "$__ble_simple_word_tmpfile"' + return 0 + elif ((_ble_bash>=40000)); then + ret=("$@") + ble/util/writearray --nlfix ret >| "$__ble_simple_word_tmpfile" + ble/util/print 'ble/util/readarray --nlfix __ble_ret < "$__ble_simple_word_tmpfile"' + return 0 + fi + fi + local ret; ble/string#quote-words "$@" + ble/util/print "__ble_ret=($ret)" +} +function ble/syntax:bash/simple-word/eval/.eval-set { + if [[ ${_ble_edit_exec_lastparams[0]+set} ]]; then + set -- "${_ble_edit_exec_lastparams[@]}" + else + set -- + fi + local ext=0 + builtin eval -- "ble/syntax:bash/simple-word/eval/.set-result $__ble_simple_word" &>/dev/null; ext=$? + builtin eval : # Note: bash 3.1/3.2 eval バグ対策 (#D1132) + return "$ext" +} +function ble/syntax:bash/simple-word/eval/.eval-print { + if [[ ${_ble_edit_exec_lastparams[0]+set} ]]; then + set -- "${_ble_edit_exec_lastparams[@]}" + else + set -- + fi + builtin eval -- "ble/syntax:bash/simple-word/eval/.print-result $__ble_simple_word" +} +function ble/syntax:bash/simple-word/eval/.impl { + local __ble_word=$1 __ble_opts=$2 __ble_flags= + local -a ret=() + ble/syntax:bash/simple-word/extract-parameter-names "$__ble_word" + if ((${#ret[@]})); then + local __ble_defs + ble/util/assign __ble_defs 'ble/util/print-global-definitions --hidden-only "${ret[@]}"' + builtin eval -- "$__ble_defs" &>/dev/null # 読み取り専用の変数のこともある + fi + if [[ $- != *f* ]] && ! ble/syntax:bash/simple-word/is-simple-noglob "$1"; then + if [[ :$__ble_opts: == *:noglob:* ]]; then + set -f + __ble_flags=f + elif ble/util/is-cygwin-slow-glob "$1"; then # Note: #D1168 + if shopt -q failglob &>/dev/null; then + __ble_ret=() + return 1 + elif shopt -q nullglob &>/dev/null; then + __ble_ret=() + return 0 + else + set -f + __ble_flags=f + fi + elif [[ :$__ble_opts: == *:stopcheck:* ]]; then + ble/decode/has-input && return 148 + if ((_ble_bash>=40000)); then + __ble_flags=s + elif shopt -q globstar &>/dev/null; then + if builtin eval "[[ $__ble_word == *'**'* ]]"; then + [[ :$__ble_opts: == *:timeout=*:* ]] && return 142 + return 148 + fi + fi + fi + fi + __ble_ret=() + local __ble_simple_word=$__ble_word + if [[ $__ble_flags == *s* ]]; then + local __ble_sync_command=ble/syntax:bash/simple-word/eval/.eval-print + local __ble_sync_opts=progressive-weight + local __ble_sync_weight=$bleopt_syntax_eval_polling_interval + local __ble_sync_timeout=$_ble_syntax_bash_simple_eval_timeout + if [[ $_ble_syntax_bash_simple_eval_timeout_carry ]]; then + __ble_sync_timeout=0 + elif local __ble_rex=':timeout=([^:]*):'; [[ :$__ble_opts: =~ $__ble_rex ]]; then + __ble_sync_timeout=${BASH_REMATCH[1]} + fi + [[ $__ble_sync_timeout ]] && + __ble_sync_opts=$__ble_sync_opts:timeout=$((__ble_sync_timeout)) + local _ble_local_tmpfile; ble/util/assign/mktmp + local __ble_simple_word_tmpfile=$_ble_local_tmpfile + local __ble_script + ble/util/assign __ble_script 'ble/util/conditional-sync "$__ble_sync_command" "" "$__ble_sync_weight" "$__ble_sync_opts"' &>/dev/null; local ext=$? + builtin eval -- "$__ble_script" + ble/util/assign/rmtmp + else + ble/syntax:bash/simple-word/eval/.eval-set; local ext=$? + fi + [[ $__ble_flags == *f* ]] && set +f + return "$ext" +} +_ble_syntax_bash_simple_eval_hash= +function ble/syntax:bash/simple-word/eval/.cache-clear { + ble/gdict#clear _ble_syntax_bash_simple_eval + ble/gdict#clear _ble_syntax_bash_simple_eval_full +} +function ble/syntax:bash/simple-word/eval/.cache-update { + local hash=$-:${BASHOPTS-}:$_ble_edit_lineno:$_ble_textarea_version:$PWD + if [[ $hash != "$_ble_syntax_bash_simple_eval_hash" ]]; then + _ble_syntax_bash_simple_eval_hash=$hash + ble/syntax:bash/simple-word/eval/.cache-clear + fi +} +function ble/syntax:bash/simple-word/eval/.cache-save { + ((ext==148||ext==142)) && return 0 + local ret; ble/string#quote-words "$3" + ble/gdict#set _ble_syntax_bash_simple_eval "$1" "ext=$2 count=$(($#-2)) ret=$ret" + local ret; ble/string#quote-words "${@:3}" + ble/gdict#set _ble_syntax_bash_simple_eval_full "$1" "ext=$2 count=$(($#-2)) ret=($ret)" +} +function ble/syntax:bash/simple-word/eval/.cache-load { + ext= ret= + if [[ :$2: == *:single:* ]]; then + ble/gdict#get _ble_syntax_bash_simple_eval "$1" || return 1 + else + ble/gdict#get _ble_syntax_bash_simple_eval_full "$1" || return 1 + fi + builtin eval -- "$ret" + return 0 +} +_ble_syntax_bash_simple_eval_timeout= +_ble_syntax_bash_simple_eval_timeout_carry= +function ble/syntax:bash/simple-word/eval { + [[ :$2: != *:count:* ]] && local count + if [[ :$2: == *:cached:* && :$2: != *:noglob:* ]]; then + ble/syntax:bash/simple-word/eval/.cache-update + local ext; ble/syntax:bash/simple-word/eval/.cache-load "$1" "$2" && return "$ext" + fi + local __ble_ret + ble/syntax:bash/simple-word/eval/.impl "$1" "$2"; local ext=$? + ret=("${__ble_ret[@]}") + count=${#ret[@]} + if [[ :$2: == *:cached:* && :$2: != *:noglob:* ]]; then + ble/syntax:bash/simple-word/eval/.cache-save "$1" "$ext" "${ret[@]}" + fi + if ((ext==142)); then + [[ :$2: == *:timeout-carry:* ]] && + _ble_syntax_bash_simple_eval_timeout_carry=1 + if [[ :$2: == *:retry-noglob-on-timeout:* ]]; then + ble/syntax:bash/simple-word/eval "$1" "$2:noglob" + return "$?" + fi + fi + return "$ext" +} +function ble/syntax:bash/simple-word/safe-eval { + if [[ :$2: == *:reconstruct:* ]]; then + local simple_flags simple_ibrace + ble/syntax:bash/simple-word/reconstruct-incomplete-word "$1" || return 1 + ble/util/unlocal simple_flags simple_ibrace + else + ble/syntax:bash/simple-word/is-simple "$1" || return 1 + fi + ble/syntax:bash/simple-word/eval "$1" && + { [[ :$2: != *:nonull:* ]] || ((${#ret[@]})); } +} +function ble/syntax:bash/simple-word/get-rex_element { + local sep=$1 + local param=$_ble_syntax_bash_simple_rex_param + local bquot=$_ble_syntax_bash_simple_rex_bquot + local squot=$_ble_syntax_bash_simple_rex_squot + local dquot=$_ble_syntax_bash_simple_rex_dquot + local letter1='\[[!^]|[^'$sep$_ble_syntax_bashc_simple']' + rex_element='('$bquot'|'$squot'|'$dquot'|'$param'|'$letter1')+' +} +function ble/syntax:bash/simple-word/evaluate-path-spec { + local word=$1 sep=${2:-'/:='} opts=$3 + ret=() spec=() path=() + [[ $word ]] || return 0 + local eval_opts=$opts notilde= + [[ :$opts: == *:notilde:* ]] && notilde=\'\' # チルダ展開の抑制 + local fixlen + ble/opts#extract-last-optarg "$opts" fixlen 0 + local rex_element; ble/syntax:bash/simple-word/get-rex_element "$sep" + local rex='^['$sep']?'$rex_element'|^['$sep']' + [[ :$opts: == *:after-sep:* ]] && + local rex='^'$rex_element'['$sep']?|^['$sep']' + local tail=${word:fixlen} s=${word::fixlen} p= ext=0 + while [[ $tail =~ $rex ]]; do + local rematch=$BASH_REMATCH + s=$s$rematch + ble/syntax:bash/simple-word/eval "$notilde$s" "$eval_opts"; ext=$? + ((ext==148||ext==142)) && return "$ext" + p=$ret + tail=${tail:${#rematch}} + ble/array#push spec "$s" + ble/array#push path "$p" + done + [[ $tail ]] && return 1 + ((ext)) && return "$ext" + return 0 +} +function ble/syntax:bash/simple-word/detect-separated-path { + local word=$1 sep=${2:-':'} opts=$3 + [[ $word ]] || return 1 + local rex_url='^[a-z]+://' + [[ :$opts: == *:url:* ]] && ble/string#match-safe "$word" "$rex_url" && return 1 + local eval_opts=$opts notilde= + [[ :$opts: == *:notilde:* ]] && notilde=\'\' # チルダ展開の抑制 + local rex_element + ble/syntax:bash/simple-word/get-rex_element / + local rex='^'$rex_element'/?|^/' + local tail=$word head= + while [[ $tail =~ $rex ]]; do + local rematch=$BASH_REMATCH + ble/syntax:bash/simple-word/locate-filename/.exists "$notilde$head$rematch"; local ext=$? + ((ext==148)) && return 148 + ((ext==0)) || break + head=$head$rematch + tail=${tail:${#rematch}} + done + ret= + local i + for ((i=0;i<${#sep};i++)); do + local sep1=${sep:i:1} + ble/syntax:bash/simple-word/get-rex_element "$sep1" + local rex_nocolon='^('$rex_element')?$' + local rex_hascolon='^('$rex_element')?['$sep1']' + [[ $head =~ $rex_nocolon && $tail =~ $rex_hascolon ]] && ret=$ret$sep1 + done + [[ $ret ]] +} +function ble/syntax:bash/simple-word/locate-filename/.exists { + local word=$1 ret + ble/syntax:bash/simple-word/eval "$word" "$eval_opts" || return "$?" + local path=$ret + if [[ ( $OSTYPE == cygwin || $OSTYPE == msys ) && $path == //* ]]; then + [[ $path == // ]] + else + [[ -e $path || -h $path ]] + fi || [[ :$opts: == *:url:* ]] && ble/string#match-safe "$path" "$rex_url" +} +function ble/syntax:bash/simple-word/locate-filename { + local word=$1 sep=${2:-':='} opts=$3 + ret=0 + [[ $word ]] || return 0 + local eval_opts=$opts + local rex_element; ble/syntax:bash/simple-word/get-rex_element "$sep" + local rex='^'$rex_element'['$sep']|^['$sep']' + local rex_url='^[a-z]+://' + local -a seppos=() + local tail=$word p=0 + while [[ $tail =~ $rex ]]; do + ((p+=${#BASH_REMATCH})) + tail=${tail:${#BASH_REMATCH}} + ble/array#push seppos "$((p-1))" + done + ble/syntax:bash/simple-word/is-simple "$tail" && + ble/array#push seppos "$((p+${#tail}))" + local -a out=() + for ((i=0;i<${#seppos[@]};i++)); do + local j0=$i + [[ :$opts: == *:greedy:* ]] && j0=${#seppos[@]}-1 + local j + for ((j=j0;j>=i;j--)); do + local f1=0 f2=${seppos[j]} + ((i)) && ((f1=seppos[i-1]+1)) + if ((j>i)); then + ble/syntax:bash/simple-word/locate-filename/.exists "${word:f1:f2-f1}" "$opts"; local ext=$? + ((ext==148)) && return 148 + if ((ext==0)); then + ble/array#push out "$f1" "$f2" + ((i=j)) + fi + else + if [[ :$opts: != *:exists:* ]] || + { ble/syntax:bash/simple-word/locate-filename/.exists "${word:f1:f2-f1}" "$opts" + local ext=$?; ((ext==148)) && return 148; ((ext==0)); }; then + ble/array#push out "$f1" "$f2" + fi + fi + done + done + ret=("${out[@]}") + return 0 +} +function ble/syntax:bash/simple-word#break-word { + local word=$1 sep=${2:-':='} + if [[ ! $word ]]; then + ret=('') + return 0 + fi + sep=${sep//[\"\'\$\`]} + local rex_element; ble/syntax:bash/simple-word/get-rex_element "$sep" + local rex='^('$rex_element')?['$sep']+' + local -a out=() + local tail=$word p=0 + while [[ $tail =~ $rex ]]; do + local rematch1=${BASH_REMATCH[1]} + ble/array#push out "$rematch1" + ble/array#push out "${BASH_REMATCH:${#rematch1}}" + tail=${tail:${#BASH_REMATCH}} + done + ble/array#push out "$tail" + ret=("${out[@]}") + return 0 +} +function ble/syntax:bash/initialize-ctx { + ctx=$_ble_ctx_CMDX # _ble_ctx_CMDX が ble/syntax:bash の最初の文脈 +} +function ble/syntax:bash/initialize-vars { + local histc12 + if [[ ${histchars+set} ]]; then + histc12=${histchars::2} + else + histc12='!^' + fi + _ble_syntax_bash_histc12=$histc12 + if ble/syntax:bash/cclass/update; then + ble/syntax:bash/simple-word/update + fi + local histstop=$' \t\n=' + shopt -q extglob && histstop="$histstop(" + _ble_syntax_bash_histstop=$histstop +} +function ble/syntax/highlight/vartype/.impl { + if [[ ! $bleopt_highlight_variable ]]; then + __ble_vartype_ret=$_ble_attr_VAR + return 0 + fi + local __ble_name=$1 __ble_opts=$2 __ble_tail=$3 + if ble/string#match "$__ble_name" '^[1-9][0-9]*$'; then + if [[ ${_ble_edit_exec_lastparams[0]+set} ]]; then + set -- "${_ble_edit_exec_lastparams[@]}" + else + set -- + fi + fi + local __ble_attr; ble/variable#get-attr -v __ble_attr "$__ble_name" + if [[ ${!__ble_name+set} || $__ble_attr == *[aA]* ]]; then + local __ble_rex='^-?[0-9]+(#[_a-zA-Z0-9@]*)?$' + if [[ ${!__ble_name-} && :$__ble_opts: == *:expr:* && ! ( ${!__ble_name} =~ $__ble_rex ) ]]; then + __ble_vartype_ret=$_ble_attr_VAR_EXPR + elif [[ ${!__ble_name+set} && $__ble_attr == *x* ]]; then + __ble_vartype_ret=$_ble_attr_VAR_EXPORT + elif [[ $__ble_attr == *a* ]]; then + __ble_vartype_ret=$_ble_attr_VAR_ARRAY + elif [[ $__ble_attr == *A* ]]; then + __ble_vartype_ret=$_ble_attr_VAR_HASH + elif [[ $__ble_attr == *r* && :$__ble_opts: != *:no-readonly:* ]]; then + __ble_vartype_ret=$_ble_attr_VAR_READONLY + elif [[ $__ble_attr == *i* ]]; then + __ble_vartype_ret=$_ble_attr_VAR_NUMBER + elif [[ $__ble_attr == *[luc]* ]]; then + __ble_vartype_ret=$_ble_attr_VAR_TRANSFORM + elif [[ ! ${!__ble_name} ]]; then + __ble_vartype_ret=$_ble_attr_VAR_EMPTY + else + __ble_vartype_ret=$_ble_attr_VAR + fi + else + if [[ :$__ble_opts: == *:readvar:* && $_ble_bash_set == *u* ]]; then + if [[ ! $__ble_tail ]] || { + local __ble_rex='^:?[-+?=]' + [[ $__ble_tail == :* ]] && __ble_vartype_ret[1]=2 + ! [[ $__ble_tail =~ $__ble_rex ]]; } + then + __ble_vartype_ret=$_ble_attr_ERR + return 0 + fi + fi + __ble_vartype_ret=$_ble_attr_VAR_UNSET + fi +} +function ble/syntax/highlight/vartype/.print { + if [[ :$2: == *:unset:* ]]; then + ble/util/print "$_ble_attr_VAR" + else + local -a __ble_vartype_ret=() + ble/syntax/highlight/vartype/.impl "$1" "$_ble_highlight_vartype_opts" "$_ble_highlight_vartype_tail" + ble/util/print "${__ble_vartype_ret[@]}" + fi +} +function ble/syntax/highlight/vartype { + local -a __ble_vartype_ret=() + if [[ :$2: == *:global:* && $1 != __ble_* ]] && ! ble/variable#is-global "$1"; then + local _ble_highlight_vartype_name=$1 + local _ble_highlight_vartype_opts=$__ble_opts:no-readonly + local _ble_highlight_vartype_tail=$__ble_tail + ble/util/assign-words __ble_vartype_ret 'ble/util/for-global-variables ble/syntax/highlight/vartype/.print "" "$_ble_highlight_vartype_name"' + else + ble/syntax/highlight/vartype/.impl "$@" + fi + ret=${__ble_vartype_ret:-$_ble_attr_VAR} + [[ ${__ble_vartype_ret[1]+set} ]] && lookahead=${__ble_vartype_ret[1]} + return 0 +} +function ble/syntax:bash/check-plain-with-escape { + local rex='^('$1'|\\.)' is_quote=$2 + [[ $tail =~ $rex ]] || return 1 + if [[ $BASH_REMATCH == '\'? && + ( ! $is_quote || $BASH_REMATCH == '\'[$'\\`$\n"'] ) ]]; then + ((_ble_syntax_attr[i]=_ble_attr_QESC)) + else + ((_ble_syntax_attr[i]=ctx)) + fi + ((i+=${#BASH_REMATCH})) + return 0 +} +function ble/syntax:bash/check-dollar { + [[ $tail == '$'* ]] || return 1 + local rex + if [[ $tail == '${'* ]]; then + local rex1='^(\$\{#)([-*@#?$!0]\}?|[1-9][0-9]*\}?|[_a-zA-Z][_a-zA-Z0-9]*[[}]?)' + local rex2='^(\$\{!?)([-*@#?$!0]|[1-9][0-9]*|[_a-zA-Z][_a-zA-Z0-9]*\[?)' + if + [[ $tail =~ $rex1 ]] && { + [[ ${BASH_REMATCH[2]} == *['[}'] || $BASH_REMATCH == "$tail" ]] || + { ble/syntax/parse/set-lookahead "$((${#BASH_REMATCH}+1))"; false; } } || + [[ $tail =~ $rex2 ]] + then + local rematch1=${BASH_REMATCH[1]} + local rematch2=${BASH_REMATCH[2]} + local varname=${rematch2%['[}']} + local ntype='${' + if ((ctx==_ble_ctx_QUOT)); then + ntype='"${' + elif ((ctx==_ble_ctx_PWORD||ctx==_ble_ctx_PWORDE||ctx==_ble_ctx_PWORDR||ctx==_ble_ctx_EXPR)); then + local ntype2; ble/syntax/parse/nest-type -v ntype2 + [[ $ntype2 == '"${' ]] && ntype='"${' + fi + local ret lookahead= tail2=${tail:${#rematch1}+${#varname}} + ble/syntax/highlight/vartype "$varname" readvar:global "$tail2"; local attr=$ret + ble/syntax/parse/nest-push "$_ble_ctx_PARAM" "$ntype" + ((_ble_syntax_attr[i]=ctx, + i+=${#rematch1}, + _ble_syntax_attr[i]=attr, + i+=${#varname})) + [[ $lookahead ]] && ble/syntax/parse/set-lookahead "$lookahead" + if rex='^\$\{![_a-zA-Z][_a-zA-Z0-9]*[*@]\}?'; [[ $tail =~ $rex ]]; then + ble/syntax/parse/set-lookahead 2 + if [[ $BASH_REMATCH == *'}' ]]; then + ((i++,ctx=_ble_ctx_PWORDE)) + fi + elif [[ $rematch2 == *'[' ]]; then + ble/syntax/parse/nest-push "$_ble_ctx_EXPR" 'v[' + ((_ble_syntax_attr[i++]=_ble_ctx_EXPR)) + fi + return 0 + elif ((_ble_bash>=50300)) && [[ $tail == '${'[$' \t\n|']* ]]; then + ((_ble_syntax_attr[i]=_ble_ctx_PARAM)) + ble/syntax/parse/nest-push "$_ble_ctx_CMDX" 'cmdsub_nofork' + ((i+=2)) + [[ $tail == '${|'* ]] && ((i++)) + return 0 + else + ((_ble_syntax_attr[i]=_ble_attr_ERR,i+=2)) + return 0 + fi + elif [[ $tail == '$(('* ]]; then + ((_ble_syntax_attr[i]=_ble_ctx_PARAM)) + ble/syntax/parse/nest-push "$_ble_ctx_EXPR" '$((' + ((i+=3)) + return 0 + elif [[ $tail == '$['* ]]; then + ((_ble_syntax_attr[i]=_ble_ctx_PARAM)) + ble/syntax/parse/nest-push "$_ble_ctx_EXPR" '$[' + ((i+=2)) + return 0 + elif [[ $tail == '$('* ]]; then + ((_ble_syntax_attr[i]=_ble_ctx_PARAM)) + ble/syntax/parse/nest-push "$_ble_ctx_CMDX" '$(' + ((i+=2)) + return 0 + elif rex='^\$([-*@#?$!0_]|[1-9]|[_a-zA-Z][_a-zA-Z0-9]*)' && [[ $tail =~ $rex ]]; then + local rematch=$BASH_REMATCH rematch1=${BASH_REMATCH[1]} + ((_ble_syntax_attr[i++]=_ble_ctx_PARAM)) + if ((_ble_bash<40200)) && local tail=${tail:1} && + ble/syntax:bash/starts-with-histchars && ble/syntax:bash/check-history-expansion; then + return 0 + else + local ret; ble/syntax/highlight/vartype "$rematch1" readvar:global + ((_ble_syntax_attr[i]=ret,i+=${#rematch}-1)) + return 0 + fi + else + ((_ble_syntax_attr[i++]=ctx)) + return 0 + fi +} +function ble/syntax:bash/check-quotes { + local rex aqdel=$_ble_attr_QDEL aquot=$_ble_ctx_QUOT + if ((ctx==_ble_ctx_EXPR)) && [[ $tail != \`* ]]; then + local ntype + ble/syntax/parse/nest-type + case $ntype in + ('${') + if ((_ble_bash<50200)) || [[ $tail == \'* || $tail == \$\'* ]]; then + ((aqdel=_ble_attr_ERR,aquot=_ble_ctx_EXPR)) + fi ;; + ('$['|'$(('|expr-paren-ax) + if [[ $tail == \'* ]] || ((_ble_bash<40400)); then + ((aqdel=_ble_attr_ERR,aquot=_ble_ctx_EXPR)) + fi ;; + ('(('|expr-paren|expr-brack) + if [[ $tail == \'* ]] && ((_ble_bash>=50100)); then + ((aqdel=_ble_attr_ERR,aquot=_ble_ctx_EXPR)) + fi ;; + ('a['|'v['|expr-paren-ai|expr-brack-ai) + if [[ $tail == \'* ]] && ((_ble_bash>=40400)); then + ((aqdel=_ble_attr_ERR,aquot=_ble_ctx_EXPR)) + fi ;; + ('"${') + if ! { [[ $tail == '$'[\'\"]* ]] && shopt -q extquote; }; then + ((aqdel=_ble_attr_ERR,aquot=_ble_ctx_EXPR)) + fi ;; + esac + elif ((ctx==_ble_ctx_PWORD||ctx==_ble_ctx_PWORDE||ctx==_ble_ctx_PWORDR)); then + if [[ $tail == '$'[\'\"]* ]] && ! shopt -q extquote; then + local ntype + ble/syntax/parse/nest-type + if [[ $ntype == '"${' ]]; then + ((aqdel=ctx,aquot=ctx)) + fi + fi + fi + if rex='^`([^`\]|\\(.|$))*(`?)|^'\''[^'\'']*('\''?)' && [[ $tail =~ $rex ]]; then + ((_ble_syntax_attr[i]=aqdel, + _ble_syntax_attr[i+1]=aquot, + i+=${#BASH_REMATCH}, + _ble_syntax_attr[i-1]=${#BASH_REMATCH[3]}||${#BASH_REMATCH[4]}?aqdel:_ble_attr_ERR)) + return 0 + fi + if ((ctx!=_ble_ctx_QUOT)); then + if rex='^(\$?")([^'"${_ble_syntax_bash_chars[_ble_ctx_QUOT]}"']*)("?)' && [[ $tail =~ $rex ]]; then + local rematch1=${BASH_REMATCH[1]} # for bash-3.1 ${#arr[n]} bug + if [[ ${BASH_REMATCH[3]} ]]; then + ((_ble_syntax_attr[i]=aqdel, + _ble_syntax_attr[i+${#rematch1}]=aquot, + i+=${#BASH_REMATCH}, + _ble_syntax_attr[i-1]=aqdel)) + else + ble/syntax/parse/nest-push "$_ble_ctx_QUOT" + if (((ctx==_ble_ctx_PWORD||ctx==_ble_ctx_PWORDE||ctx==_ble_ctx_PWORDR)&&aqdel!=_ble_attr_QDEL)); then + ((_ble_syntax_attr[i]=aqdel, + _ble_syntax_attr[i+${#rematch1}-1]=_ble_attr_QDEL, + _ble_syntax_attr[i+${#rematch1}]=_ble_ctx_QUOT, + i+=${#BASH_REMATCH})) + else + ((_ble_syntax_attr[i]=aqdel, + _ble_syntax_attr[i+${#rematch1}]=_ble_ctx_QUOT, + i+=${#BASH_REMATCH})) + fi + fi + return 0 + elif rex='^\$'\''(([^'\''\]|\\(.|$))*)('\''?)' && [[ $tail =~ $rex ]]; then + ((_ble_syntax_attr[i]=aqdel,i+=2)) + local t=${BASH_REMATCH[1]} rematch4=${BASH_REMATCH[4]} + local rex='\\[abefnrtvE"'\''\?]|\\[0-7]{1,3}|\\c.|\\x[0-9a-fA-F]{1,2}' + ((_ble_bash>=40200)) && rex=$rex'|\\u[0-9a-fA-F]{1,4}|\\U[0-9a-fA-F]{1,8}' + local rex='^([^'\''\]*)('$rex'|(\\.))' + while [[ $t =~ $rex ]]; do + local m1=${BASH_REMATCH[1]} m2=${BASH_REMATCH[2]} + [[ $m1 ]] && ((_ble_syntax_attr[i]=aquot,i+=${#m1})) + if [[ ${BASH_REMATCH[3]} ]]; then + ((_ble_syntax_attr[i]=aquot)) + else + ((_ble_syntax_attr[i]=_ble_attr_QESC)) + fi + ((i+=${#m2})) + t=${t:${#BASH_REMATCH}} + done + [[ $t ]] && ((_ble_syntax_attr[i]=aquot,i+=${#t})) + if [[ $rematch4 ]]; then + ((_ble_syntax_attr[i++]=aqdel)) + else + ((_ble_syntax_attr[i-1]=_ble_attr_ERR)) + fi + return 0 + fi + fi + return 1 +} +function ble/syntax:bash/check-process-subst { + if [[ $tail == ['<>']'('* ]]; then + ble/syntax/parse/nest-push "$_ble_ctx_CMDX" '(' + ((_ble_syntax_attr[i]=_ble_attr_DEL,i+=2)) + return 0 + fi + return 1 +} +function ble/syntax:bash/check-comment { + if shopt -q interactive_comments; then + if ((wbegin<0||wbegin==i)) && local rex=$'^#[^\n]*' && [[ $tail =~ $rex ]]; then + ((_ble_syntax_attr[i]=_ble_attr_COMMENT, + i+=${#BASH_REMATCH})) + return 0 + fi + fi + return 1 +} +function ble/syntax:bash/check-glob { + [[ $tail == ['[?*@+!()|']* ]] || return 1 + local ntype= force_attr= + if ((ctx==_ble_ctx_VRHS||ctx==_ble_ctx_ARGVR||ctx==_ble_ctx_ARGER||ctx==_ble_ctx_VALR||ctx==_ble_ctx_RDRS)); then + force_attr=$ctx + ntype="glob_attr=$force_attr" + elif ((ctx==_ble_ctx_FARGX1||ctx==_ble_ctx_FARGI1)); then + force_attr=$_ble_attr_ERR + ntype="glob_attr=$force_attr" + elif ((ctx==_ble_ctx_PWORD||ctx==_ble_ctx_PWORDE||ctx==_ble_ctx_PWORDR)); then + ntype="glob_ctx=$ctx" + elif ((ctx==_ble_ctx_PATN||ctx==_ble_ctx_BRAX)); then + ble/syntax/parse/nest-type + local exit_attr= + if [[ $ntype == glob_attr=* ]]; then + force_attr=${ntype#*=} + exit_attr=$force_attr + elif ((ctx==_ble_ctx_BRAX)); then + force_attr=$ctx + ntype="glob_attr=$force_attr" + elif ((ctx==_ble_ctx_PATN)); then + ((exit_attr=_ble_syntax_attr[inest])) + [[ $ntype != glob_ctx=* ]] && ntype= + else + ntype= + fi + elif [[ $1 == assign ]]; then + ntype='a[' + fi + if [[ $tail == ['?*@+!']'('* ]] && shopt -q extglob; then + ble/syntax/parse/nest-push "$_ble_ctx_PATN" "$ntype" + ((_ble_syntax_attr[i]=${force_attr:-_ble_attr_GLOB},i+=2)) + return 0 + fi + local histc1=${_ble_syntax_bash_histc12::1} + [[ $histc1 && $tail == "$histc1"* ]] && return 1 + if [[ $tail == '['* ]]; then + if ((ctx==_ble_ctx_BRAX)); then + ((_ble_syntax_attr[i++]=force_attr)) + [[ $tail == '[!'* ]] && ((i++)) + return 0 + fi + ble/syntax/parse/nest-push "$_ble_ctx_BRAX" "$ntype" + ((_ble_syntax_attr[i++]=${force_attr:-_ble_attr_GLOB})) + [[ $tail == '[!'* ]] && ((i++)) + if [[ ${text:i:1} == ']' ]]; then + ((_ble_syntax_attr[i++]=${force_attr:-_ble_ctx_BRAX})) + elif [[ ${text:i:1} == '[' ]]; then + if [[ ${text:i+1:1} == [:=.] ]]; then + ble/syntax/parse/set-lookahead 2 + else + ((_ble_syntax_attr[i++]=${force_attr:-_ble_ctx_BRAX})) + [[ ${text:i:1} == '!'* ]] && ((i++)) + fi + fi + return 0 + elif [[ $tail == ['?*']* ]]; then + ((_ble_syntax_attr[i++]=${force_attr:-_ble_attr_GLOB})) + return 0 + elif [[ $tail == ['@+!']* ]]; then + ((_ble_syntax_attr[i++]=${force_attr:-ctx})) + return 0 + elif ((ctx==_ble_ctx_PATN||ctx==_ble_ctx_BRAX)); then + if [[ $tail == '('* ]]; then + ble/syntax/parse/nest-push "$_ble_ctx_PATN" "$ntype" + ((_ble_syntax_attr[i++]=${force_attr:-ctx})) + return 0 + elif [[ $tail == ')'* ]]; then + if ((ctx==_ble_ctx_PATN)); then + ((_ble_syntax_attr[i++]=exit_attr)) + ble/syntax/parse/nest-pop + else + ((_ble_syntax_attr[i++]=${force_attr:-ctx})) + fi + return 0 + elif [[ $tail == '|'* ]]; then + ((_ble_syntax_attr[i++]=${force_attr:-_ble_attr_GLOB})) + return 0 + fi + fi + return 1 +} +_ble_syntax_bash_histexpand_RexWord= +_ble_syntax_bash_histexpand_RexMods= +_ble_syntax_bash_histexpand_RexEventDef= +_ble_syntax_bash_histexpand_RexQuicksubDef= +_ble_syntax_bash_histexpand_RexEventFmt= +_ble_syntax_bash_histexpand_RexQuicksubFmt= +function ble/syntax:bash/check-history-expansion/.initialize { + local spaces=$_ble_term_IFS nl=$'\n' + local rex_event='-?[0-9]+|[!#]|[^-$^*%:'$spaces'=?!#;&|<>()]+|\?[^?'$nl']*\??' + _ble_syntax_bash_histexpand_RexEventDef='^!('$rex_event')' + local rex_word1='([0-9]+|[$%^])' + local rex_wordsA=':('$rex_word1'?-'$rex_word1'?|\*|'$rex_word1'\*?)' + local rex_wordsB='([$%^]?-'$rex_word1'?|\*|[$^%][*-]?)' + _ble_syntax_bash_histexpand_RexWord='('$rex_wordsA'|'$rex_wordsB')?' + local rex_modifier=':[htrepqx]|:[gGa]?&|:[gGa]?s(/([^\/]|\\.)*){0,2}(/|$)' + _ble_syntax_bash_histexpand_RexMods='('$rex_modifier')*' + _ble_syntax_bash_histexpand_RexQuicksubDef='\^([^^\]|\\.)*\^([^^\]|\\.)*\^' + _ble_syntax_bash_histexpand_RexQuicksubFmt='@A([^@C\]|\\.)*@A([^@C\]|\\.)*@A' + _ble_syntax_bash_histexpand_RexEventFmt='^@A('$rex_event'|@A)' +} +ble/syntax:bash/check-history-expansion/.initialize +function ble/syntax:bash/check-history-expansion/.initialize-event { + local histc1=${_ble_syntax_bash_histc12::1} + if [[ $histc1 == '!' ]]; then + rex_event=$_ble_syntax_bash_histexpand_RexEventDef + else + local A="[$histc1]" + [[ $histc1 == '^' ]] && A='\^' + rex_event=$_ble_syntax_bash_histexpand_RexEventFmt + rex_event=${rex_event//@A/"$A"} + fi +} +function ble/syntax:bash/check-history-expansion/.initialize-quicksub { + local histc2=${_ble_syntax_bash_histc12:1:1} + if [[ $histc2 == '^' ]]; then + rex_quicksub=$_ble_syntax_bash_histexpand_RexQuicksubDef + else + rex_quicksub=$_ble_syntax_bash_histexpand_RexQuicksubFmt + rex_quicksub=${rex_quicksub//@A/"[$histc2]"} + rex_quicksub=${rex_quicksub//@C/"$histc2"} + fi +} +function ble/syntax:bash/check-history-expansion/.check-modifiers { + [[ ${text:i} =~ $_ble_syntax_bash_histexpand_RexMods ]] && + ((i+=${#BASH_REMATCH})) + if local rex='^:[gGa]?s(.)'; [[ ${text:i} =~ $rex ]]; then + local del=${BASH_REMATCH[1]} + local A="[$del]" B="[^$del]" + [[ $del == '^' || $del == ']' ]] && A='\'$del + [[ $del != '\' ]] && B=$B'|\\.' + local rex_substitute='^:[gGa]?s('$A'('$B')*){0,2}('$A'|$)' + if [[ ${text:i} =~ $rex_substitute ]]; then + ((i+=${#BASH_REMATCH})) + ble/syntax:bash/check-history-expansion/.check-modifiers + return 0 + fi + fi + if [[ ${text:i} == ':'[gGa]* ]]; then + ((_ble_syntax_attr[i+1]=_ble_attr_ERR,i+=2)) + elif [[ ${text:i} == ':'* ]]; then + ((_ble_syntax_attr[i]=_ble_attr_ERR,i++)) + fi +} +function ble/syntax:bash/check-history-expansion { + [[ -o histexpand ]] || return 1 + local histc1=${_ble_syntax_bash_histc12:0:1} + local histc2=${_ble_syntax_bash_histc12:1:1} + if [[ $histc1 && $tail == "$histc1"[^"$_ble_syntax_bash_histstop"]* ]]; then + if ((_ble_bash>=40300&&ctx==_ble_ctx_QUOT)); then + local tail=${tail%%'"'*} + [[ $tail == '!' ]] && return 1 + fi + ((_ble_syntax_attr[i]=_ble_attr_HISTX)) + local rex_event + ble/syntax:bash/check-history-expansion/.initialize-event + if [[ $tail =~ $rex_event ]]; then + ((i+=${#BASH_REMATCH})) + elif [[ $tail == "$histc1"['-:0-9^$%*']* ]]; then + ((_ble_syntax_attr[i]=_ble_attr_HISTX,i++)) + else + ((_ble_syntax_attr[i+1]=_ble_attr_ERR,i+=2)) + return 0 + fi + [[ ${text:i} =~ $_ble_syntax_bash_histexpand_RexWord ]] && + ((i+=${#BASH_REMATCH})) + ble/syntax:bash/check-history-expansion/.check-modifiers + return 0 + elif ((i==0)) && [[ $histc2 && $tail == "$histc2"* ]]; then + ((_ble_syntax_attr[i]=_ble_attr_HISTX)) + local rex_quicksub + ble/syntax:bash/check-history-expansion/.initialize-quicksub + if [[ $tail =~ $rex_quicksub ]]; then + ((i+=${#BASH_REMATCH})) + ble/syntax:bash/check-history-expansion/.check-modifiers + return 0 + else + ((i+=${#tail})) + return 0 + fi + fi + return 1 +} +function ble/syntax:bash/starts-with-histchars { + [[ $_ble_syntax_bash_histc12 && $tail == ["$_ble_syntax_bash_histc12"]* ]] +} +_ble_syntax_context_proc[_ble_ctx_QUOT]=ble/syntax:bash/ctx-quot +function ble/syntax:bash/ctx-quot { + if ble/syntax:bash/check-plain-with-escape "[^${_ble_syntax_bash_chars[_ble_ctx_QUOT]}]+" 1; then + return 0 + elif [[ $tail == '"'* ]]; then + ((_ble_syntax_attr[i]=_ble_attr_QDEL, + i+=1)) + ble/syntax/parse/nest-pop + return 0 + elif ble/syntax:bash/check-quotes; then + return 0 + elif ble/syntax:bash/check-dollar; then + return 0 + elif ble/syntax:bash/starts-with-histchars; then + ble/syntax:bash/check-history-expansion || + ((_ble_syntax_attr[i]=ctx,i++)) + return 0 + fi + return 1 +} +_ble_syntax_context_proc[_ble_ctx_CASE]=ble/syntax:bash/ctx-case +function ble/syntax:bash/ctx-case { + if [[ $tail =~ ^$_ble_syntax_bash_RexIFSs ]]; then + ((_ble_syntax_attr[i]=ctx,i+=${#BASH_REMATCH})) + return 0 + elif [[ $tail == '('* ]]; then + ((_ble_syntax_attr[i++]=_ble_attr_GLOB,ctx=_ble_ctx_CPATX)) + return 0 + elif [[ $tail == 'esac'$_ble_syntax_bash_RexDelimiter* || $tail == 'esac' ]]; then + ((ctx=_ble_ctx_CMDX)) + ble/syntax:bash/ctx-command + else + ((ctx=_ble_ctx_CPATX)) + ble/syntax:bash/ctx-command-case-pattern-expect + fi +} +_ble_syntax_context_proc[_ble_ctx_PATN]=ble/syntax:bash/ctx-globpat +_ble_syntax_context_end[_ble_ctx_PATN]=ble/syntax:bash/ctx-globpat.end +function ble/syntax:bash/ctx-globpat/get-stop-chars { + chars=${_ble_syntax_bash_chars[_ble_ctx_PATN]} + local ntype; ble/syntax/parse/nest-type + if [[ $ntype == glob_ctx=* ]]; then + local gctx=${ntype#glob_ctx=} + if ((gctx==_ble_ctx_PWORD||gctx==_ble_ctx_PWORDE)); then + chars=}$chars + elif ((gctx==_ble_ctx_PWORDR)); then + chars=}/$chars + fi + fi +} +function ble/syntax:bash/ctx-globpat { + local chars; ble/syntax:bash/ctx-globpat/get-stop-chars + if ble/syntax:bash/check-plain-with-escape "[^$chars]+"; then + return 0 + elif ble/syntax:bash/check-process-subst; then + return 0 + elif [[ $tail == ['<>']* ]]; then + ((_ble_syntax_attr[i++]=ctx)) + return 0 + elif ble/syntax:bash/check-quotes; then + return 0 + elif ble/syntax:bash/check-dollar; then + return 0 + elif ble/syntax:bash/check-glob; then + return 0 + elif ble/syntax:bash/check-brace-expansion; then + return 0 + elif ble/syntax:bash/starts-with-histchars; then + ble/syntax:bash/check-history-expansion || + ((_ble_syntax_attr[i]=ctx,i++)) + return 0 + fi + return 1 +} +function ble/syntax:bash/ctx-globpat.end { + local is_end= tail=${text:i} + local ntype; ble/syntax/parse/nest-type + if [[ $ntype == glob_ctx=* ]]; then + local gctx=${ntype#glob_ctx=} + if ((gctx==_ble_ctx_PWORD||gctx==_ble_ctx_PWORDE)); then + [[ ! $tail || $tail == '}'* ]] && is_end=1 + elif ((gctx==_ble_ctx_PWORDR)); then + [[ ! $tail || $tail == ['/}']* ]] && is_end=1 + fi + fi + if [[ $is_end ]]; then + ble/syntax/parse/nest-pop + ble/syntax/parse/check-end + return 0 + fi + return 0 +} +_ble_syntax_context_proc[_ble_ctx_BRAX]=ble/syntax:bash/ctx-bracket-expression +_ble_syntax_context_end[_ble_ctx_BRAX]=ble/syntax:bash/ctx-bracket-expression.end +function ble/syntax:bash/ctx-bracket-expression { + local nctx; ble/syntax/parse/nest-ctx + if ((nctx==_ble_ctx_PATN)); then + local chars; ble/syntax:bash/ctx-globpat/get-stop-chars + elif ((nctx==_ble_ctx_PWORD||nctx==_ble_ctx_PWORDE||nctx==_ble_ctx_PWORDR)); then + local chars=${_ble_syntax_bash_chars[nctx]} + else + local chars=${_ble_syntax_bash_chars[_ble_ctx_ARGI]//'~'} + fi + chars="][${chars#']'}" + local ntype; ble/syntax/parse/nest-type + local force_attr=; [[ $ntype == glob_attr=* ]] && force_attr=${ntype#*=} + local rex + if [[ $tail == ']'* ]]; then + ((_ble_syntax_attr[i++]=${force_attr:-_ble_attr_GLOB})) + ble/syntax/parse/nest-pop + if [[ $ntype == 'a[' ]]; then + local is_assign= + if [[ $tail == ']='* ]]; then + ((_ble_syntax_attr[i++]=ctx,is_assign=1)) + elif [[ $tail == ']+'* ]]; then + ble/syntax/parse/set-lookahead 2 + [[ $tail == ']+='* ]] && ((_ble_syntax_attr[i]=ctx,i+=2,is_assign=1)) + fi + if [[ $is_assign ]]; then + ble/util/assert '[[ ${_ble_syntax_bash_command_CtxAssign[ctx]} ]]' + ((ctx=_ble_syntax_bash_command_CtxAssign[ctx])) + if local tail=${text:i}; [[ $tail == '~'* ]]; then + ble/syntax:bash/check-tilde-expansion rhs + fi + fi + fi + return 0 + elif [[ $tail == '['* ]]; then + rex='^\[@([^'$chars']+(@\]?)?)?' + rex=${rex//@/:}'|'${rex//@/'\.'}'|'${rex//@/=}'|^\[' + [[ $tail =~ $rex ]] + ((_ble_syntax_attr[i]=${force_attr:-ctx}, + i+=${#BASH_REMATCH})) + return 0 + elif ctx=${force_attr:-$ctx} ble/syntax:bash/check-plain-with-escape "[^$chars]+"; then + return 0 + elif ble/syntax:bash/check-process-subst; then + return 0 + elif ble/syntax:bash/check-quotes; then + return 0 + elif ble/syntax:bash/check-dollar; then + return 0 + elif ble/syntax:bash/check-glob; then + return 0 + elif ble/syntax:bash/check-brace-expansion; then + return 0 + elif ble/syntax:bash/check-tilde-expansion; then + return 0 + elif ble/syntax:bash/starts-with-histchars; then + ble/syntax:bash/check-history-expansion || + ((_ble_syntax_attr[i++]=${force_attr:-ctx})) + return 0 + elif ((nctx==_ble_ctx_PATN)) && [[ $tail == ['<>']* ]]; then + ((_ble_syntax_attr[i++]=${force_attr:-ctx})) + return 0 + fi + return 1 +} +function ble/syntax:bash/ctx-bracket-expression.end { + local is_end= + local tail=${text:i} + if [[ ! $tail ]]; then + is_end=1 + else + local nctx; ble/syntax/parse/nest-ctx + local external_ctx=$nctx + if ((nctx==_ble_ctx_PATN)); then + local ntype; ble/syntax/parse/nest-type + [[ $ntype == glob_ctx=* ]] && + external_ctx=${ntype#glob_ctx=} + fi + if ((external_ctx==_ble_ctx_PATN)); then + [[ $tail == ')'* ]] && is_end=1 + elif ((external_ctx==_ble_ctx_PWORD||external_ctx==_ble_ctx_PWORDE)); then + [[ $tail == '}'* ]] && is_end=1 + elif ((external_ctx==_ble_ctx_PWORDR)); then + [[ $tail == ['}/']* ]] && is_end=1 + else + if ble/syntax:bash/check-word-end/is-delimiter; then + is_end=1 + elif [[ $tail == ':'* && ${_ble_syntax_bash_command_IsAssign[ctx]} ]]; then + is_end=1 + fi + fi + fi + if [[ $is_end ]]; then + ble/syntax/parse/nest-pop + ble/syntax/parse/check-end + return "$?" + fi + return 0 +} +_ble_syntax_context_proc[_ble_ctx_PARAM]=ble/syntax:bash/ctx-param +_ble_syntax_context_proc[_ble_ctx_PWORD]=ble/syntax:bash/ctx-pword +_ble_syntax_context_proc[_ble_ctx_PWORDR]=ble/syntax:bash/ctx-pword +_ble_syntax_context_proc[_ble_ctx_PWORDE]=ble/syntax:bash/ctx-pword-error +function ble/syntax:bash/ctx-param { + if [[ $tail == '}'* ]]; then + ((_ble_syntax_attr[i]=_ble_syntax_attr[inest])) + ((i+=1)) + ble/syntax/parse/nest-pop + return 0 + fi + local rex='##?|%%?|:?[-?=+]|:|/[/#%]?' + ((_ble_bash>=40000)) && rex=$rex'|,,?|\^\^?|~~?' + if ((_ble_bash>=50200)); then + rex=$rex'|@[QEPAaUuLKk]?' + elif ((_ble_bash>=50100)); then + rex=$rex'|@[QEPAaUuLK]?' + elif ((_ble_bash>=40400)); then + rex=$rex'|@[QEPAa]?' + fi + rex='^('$rex')' + if [[ $tail =~ $rex ]]; then + ((_ble_syntax_attr[i]=_ble_ctx_PARAM, + i+=${#BASH_REMATCH})) + if [[ $BASH_REMATCH == '/'* ]]; then + ((ctx=_ble_ctx_PWORDR)) + elif [[ $BASH_REMATCH == : ]]; then + ((ctx=_ble_ctx_EXPR,_ble_syntax_attr[i-1]=_ble_ctx_EXPR)) + elif [[ $BASH_REMATCH == @* ]]; then + ((ctx=_ble_ctx_PWORDE)) + else + ((ctx=_ble_ctx_PWORD)) + [[ $BASH_REMATCH == [':-+=?#%']* ]] && + tail=${text:i} ble/syntax:bash/check-tilde-expansion pword + fi + return 0 + else + local i0=$i + ((ctx=_ble_ctx_PWORD)) + ble/syntax:bash/ctx-pword || return 1 + if ((i0+2<=i)); then + ((_ble_syntax_attr[i0+1])) || + ((_ble_syntax_attr[i0+1]=_ble_syntax_attr[i0])) + fi + ((_ble_syntax_attr[i0]=_ble_attr_ERR)) + return 0 + fi +} +function ble/syntax:bash/ctx-pword { + if ble/syntax:bash/check-plain-with-escape "[^${_ble_syntax_bash_chars[ctx]}]+"; then + return 0 + elif ((ctx==_ble_ctx_PWORDR)) && [[ $tail == '/'* ]]; then + ((_ble_syntax_attr[i++]=_ble_ctx_PARAM,ctx=_ble_ctx_PWORD)) + return 0 + elif [[ $tail == '}'* ]]; then + ((_ble_syntax_attr[i]=_ble_syntax_attr[inest])) + ((i+=1)) + ble/syntax/parse/nest-pop + return 0 + elif ble/syntax:bash/check-quotes; then + return 0 + elif ble/syntax:bash/check-dollar; then + return 0 + elif ble/syntax:bash/check-glob; then + return 0 + elif ble/syntax:bash/starts-with-histchars; then + ble/syntax:bash/check-history-expansion || + ((_ble_syntax_attr[i]=ctx,i++)) + return 0 + fi + return 1 +} +function ble/syntax:bash/ctx-pword-error { + local i0=$i + if ble/syntax:bash/ctx-pword; then + [[ $tail == '}'* ]] || + ((_ble_syntax_attr[i0]=_ble_attr_ERR)) + return 0 + else + return 1 + fi +} +_ble_syntax_context_proc[_ble_ctx_EXPR]=ble/syntax:bash/ctx-expr +function ble/syntax:bash/ctx-expr/.count-paren { + if [[ $char == ')' ]]; then + if [[ $ntype == '((' || $ntype == '$((' ]]; then + if [[ $tail == '))'* ]]; then + ((_ble_syntax_attr[i]=_ble_syntax_attr[inest])) + ((i+=2)) + ble/syntax/parse/nest-pop + else + ((ctx=_ble_ctx_ARGX0, + _ble_syntax_attr[i++]=_ble_syntax_attr[inest])) + fi + return 0 + elif [[ $ntype == expr-paren* ]]; then + ((_ble_syntax_attr[i++]=ctx)) + ble/syntax/parse/nest-pop + return 0 + fi + elif [[ $char == '(' ]]; then + local ntype2= + case $ntype in + ('((') + ntype2=expr-paren ;; + ('$((') + ntype2=expr-paren-ax ;; + (expr-paren|expr-paren-ax|expr-paren-ai|expr-paren-di) + ntype2=$ntype ;; + ('$['|'a['|'v['|'d['|expr-brack|expr-brack-ai|expr-brack-di|'${'|'"${'|*) + ble/util/assert 'false' "unexpected ntype='$ntype' here" ;; + esac + ble/syntax/parse/nest-push "$_ble_ctx_EXPR" "$ntype2" + ((_ble_syntax_attr[i++]=ctx)) + return 0 + fi + return 1 +} +function ble/syntax:bash/ctx-expr/.count-bracket { + if [[ $char == ']' ]]; then + if [[ $ntype == expr-brack* || $ntype == '$[' ]]; then + ((_ble_syntax_attr[i]=_ble_syntax_attr[inest])) + ((i++)) + ble/syntax/parse/nest-pop + return 0 + elif [[ $ntype == [ad]'[' ]]; then + ((_ble_syntax_attr[i++]=_ble_ctx_EXPR)) + ble/syntax/parse/nest-pop + if [[ $tail == ']='* ]]; then + ((i++)) + tail=${text:i} ble/syntax:bash/check-tilde-expansion rhs + elif ((_ble_bash>=30100)) && [[ $tail == ']+'* ]]; then + ble/syntax/parse/set-lookahead 2 + if [[ $tail == ']+='* ]]; then + ((i+=2)) + tail=${text:i} ble/syntax:bash/check-tilde-expansion rhs + fi + else + if [[ $ntype == 'a[' ]]; then + if ((ctx==_ble_ctx_VRHS)); then + ((ctx=_ble_ctx_CMDI,wtype=_ble_ctx_CMDI)) + elif ((ctx==_ble_ctx_ARGVR)); then + ((ctx=_ble_ctx_ARGVI,wtype=_ble_ctx_ARGVI)) + elif ((ctx==_ble_ctx_ARGER)); then + ((ctx=_ble_ctx_ARGEI,wtype=_ble_ctx_ARGEI)) + fi + else # ntype == 'd[' + ((ctx=_ble_ctx_VALI,wtype=_ble_ctx_VALI)) + fi + fi + return 0 + elif [[ $ntype == 'v[' ]]; then + ((_ble_syntax_attr[i++]=_ble_ctx_EXPR)) + ble/syntax/parse/nest-pop + return 0 + fi + elif [[ $char == '[' ]]; then + local ntype2= + case $ntype in + ('$['|'a['|'v[') + ntype2=expr-brack-ai ;; + ('d[') + ntype2=expr-brack-di ;; + (expr-brack|expr-brack-ai|expr-brack-di) + ntype2=$ntype ;; + ('(('|'$(('|expr-paren|expr-paren-ax|expr-paren-ai|expr-paren-di|'${'|'"${'|*) + ble/util/assert 'false' "unexpected ntype='$ntype' here" ;; + esac + ble/syntax/parse/nest-push "$_ble_ctx_EXPR" "$ntype2" + ((_ble_syntax_attr[i++]=ctx)) + return 0 + fi + return 1 +} +function ble/syntax:bash/ctx-expr/.count-brace { + if [[ $char == '}' ]]; then + ((_ble_syntax_attr[i]=_ble_syntax_attr[inest])) + ((i++)) + ble/syntax/parse/nest-pop + return 0 + fi + return 1 +} +function ble/syntax:bash/ctx-expr/.check-plain-with-escape { + local i0=$i + ble/syntax:bash/check-plain-with-escape "$@" || return 1 + if [[ $tail == '\'* ]]; then + case $ntype in + ('$(('|'$['|expr-paren-ax|'${'|'"${') + _ble_syntax_attr[i0]=$_ble_attr_ERR ;; + ('(('|expr-paren|expr-brack) + if ((_ble_bash>=50100)); then + _ble_syntax_attr[i0]=$_ble_attr_ERR + fi ;; + ('a['|'v['|expr-paren-ai|expr-brack-ai) + if ((_ble_bash>=40400)); then + _ble_syntax_attr[i0]=$_ble_attr_ERR + fi ;; + esac + fi + return 0 +} +function ble/syntax:bash/ctx-expr { + local rex + if rex='^[_a-zA-Z][_a-zA-Z0-9]*'; [[ $tail =~ $rex ]]; then + local rematch=$BASH_REMATCH + local ret; ble/syntax/highlight/vartype "$BASH_REMATCH" readvar:expr:global + ((_ble_syntax_attr[i]=ret,i+=${#rematch})) + return 0 + elif rex='^0[xX][0-9a-fA-F]*|^[0-9]+(#[_a-zA-Z0-9@]*)?'; [[ $tail =~ $rex ]]; then + ((_ble_syntax_attr[i]=_ble_attr_VAR_NUMBER,i+=${#BASH_REMATCH})) + return 0 + fi + local ntype + ble/syntax/parse/nest-type + if ble/syntax:bash/ctx-expr/.check-plain-with-escape "[^${_ble_syntax_bash_chars[ctx]}_a-zA-Z0-9]+" 1; then + return 0 + elif [[ $tail == ['][()}']* ]]; then + local char=${tail::1} + if [[ $ntype == *'(' || $ntype == expr-paren* ]]; then + ble/syntax:bash/ctx-expr/.count-paren && return 0 + elif [[ $ntype == *'[' || $ntype == expr-brack* ]]; then + ble/syntax:bash/ctx-expr/.count-bracket && return 0 + elif [[ $ntype == '${' || $ntype == '"${' ]]; then + ble/syntax:bash/ctx-expr/.count-brace && return 0 + else + ble/util/assert 'false' "unexpected ntype=$ntype for arithmetic expression" + fi + ((_ble_syntax_attr[i++]=ctx)) + return 0 + elif ble/syntax:bash/check-quotes; then + return 0 + elif ble/syntax:bash/check-dollar; then + return 0 + elif ble/syntax:bash/starts-with-histchars; then + ble/syntax:bash/check-history-expansion || + ((_ble_syntax_attr[i]=ctx,i++)) + return 0 + fi + return 1 +} +function ble/syntax:bash/check-brace-expansion { + [[ $tail == '{'* ]] || return 1 + local rex='^\{[-+a-zA-Z0-9.]*(\}?)' + [[ $tail =~ $rex ]] + local str=$BASH_REMATCH + local force_attr= inactive= + if [[ $- != *B* ]]; then + inactive=1 + elif ((ctx==_ble_ctx_CONDI||ctx==_ble_ctx_CONDQ||ctx==_ble_ctx_RDRS||ctx==_ble_ctx_VRHS)); then + inactive=1 + elif ((_ble_bash>=50300&&ctx==_ble_ctx_VALR)); then + inactive=1 + elif ((ctx==_ble_ctx_PATN||ctx==_ble_ctx_BRAX)); then + local ntype; ble/syntax/parse/nest-type + if [[ $ntype == glob_attr=* ]]; then + force_attr=${ntype#*=} + (((force_attr==_ble_ctx_RDRS||force_attr==_ble_ctx_VRHS||force_attr==_ble_ctx_ARGVR||force_attr==_ble_ctx_ARGER||force_attr==_ble_ctx_VALR)&&(inactive=1))) + elif ((ctx==_ble_ctx_BRAX)); then + local nctx; ble/syntax/parse/nest-ctx + (((nctx==_ble_ctx_CONDI||octx==_ble_ctx_CONDQ)&&(inactive=1))) + fi + elif ((ctx==_ble_ctx_BRACE1||ctx==_ble_ctx_BRACE2)); then + local ntype; ble/syntax/parse/nest-type + if [[ $ntype == glob_attr=* ]]; then + force_attr=${ntype#*=} + fi + fi + if [[ $inactive ]]; then + ((_ble_syntax_attr[i]=${force_attr:-ctx},i+=${#str})) + return 0 + fi + [[ ${_ble_syntax_bash_command_IsAssign[ctx]} ]] && + ctx=${_ble_syntax_bash_command_IsAssign[ctx]} + if rex='^\{(([-+]?[0-9]+)\.\.[-+]?[0-9]+|[a-zA-Z]\.\.[a-zA-Z])(\.\.[-+]?[0-9]+)?\}$'; [[ $str =~ $rex ]]; then + if [[ $force_attr ]]; then + ((_ble_syntax_attr[i]=force_attr,i+=${#str})) + else + local rematch1=${BASH_REMATCH[1]} + local rematch2=${BASH_REMATCH[2]} + local rematch3=${BASH_REMATCH[3]} + local len2=${#rematch2}; ((len2||(len2=1))) + local attr=$_ble_attr_BRACE + if ((ctx==_ble_ctx_RDRF||ctx==_ble_ctx_RDRD||ctx==_ble_ctx_RDRD2)); then + local lhs=${rematch1::len2} rhs=${rematch1:len2+2} + if [[ $rematch2 ]]; then + local lhs1=$((10#0${lhs#[-+]})); [[ $lhs == -* ]] && ((lhs1=-lhs1)) + local rhs1=$((10#0${rhs#[-+]})); [[ $rhs == -* ]] && ((rhs1=-rhs1)) + lhs=$lhs1 rhs=$rhs1 + fi + [[ $lhs != "$rhs" ]] && ((attr=_ble_attr_ERR)) + fi + ((_ble_syntax_attr[i++]=attr)) + ((_ble_syntax_attr[i]=ctx,i+=len2, + _ble_syntax_attr[i]=_ble_attr_BRACE,i+=2, + _ble_syntax_attr[i]=ctx,i+=${#rematch1}-len2-2)) + if [[ $rematch3 ]]; then + ((_ble_syntax_attr[i]=_ble_attr_BRACE,i+=2, + _ble_syntax_attr[i]=ctx,i+=${#rematch3}-2)) + fi + ((_ble_syntax_attr[i++]=attr)) + fi + return 0 + fi + local ntype= + ((ctx==_ble_ctx_RDRF||ctx==_ble_ctx_RDRD||ctx==_ble_ctx_RDRD2)) && force_attr=$ctx + [[ $force_attr ]] && ntype="glob_attr=$force_attr" + ble/syntax/parse/nest-push "$_ble_ctx_BRACE1" "$ntype" + local len=$((${#str}-1)) + ((_ble_syntax_attr[i++]=${force_attr:-_ble_attr_BRACE}, + len&&(_ble_syntax_attr[i]=${force_attr:-ctx},i+=len))) + return 0 +} +_ble_syntax_context_proc[_ble_ctx_BRACE1]=ble/syntax:bash/ctx-brace-expansion +_ble_syntax_context_proc[_ble_ctx_BRACE2]=ble/syntax:bash/ctx-brace-expansion +_ble_syntax_context_end[_ble_ctx_BRACE1]=ble/syntax:bash/ctx-brace-expansion.end +_ble_syntax_context_end[_ble_ctx_BRACE2]=ble/syntax:bash/ctx-brace-expansion.end +function ble/syntax:bash/ctx-brace-expansion { + if [[ $tail == '}'* ]] && ((ctx==_ble_ctx_BRACE2)); then + local force_attr= + local ntype; ble/syntax/parse/nest-type + [[ $ntype == glob_attr=* ]] && force_attr=$_ble_attr_ERR # ※${ntype#*=} ではなくエラー + ((_ble_syntax_attr[i++]=${force_attr:-_ble_attr_BRACE})) + ble/syntax/parse/nest-pop + return 0 + elif [[ $tail == ','* ]]; then + local force_attr= + local ntype; ble/syntax/parse/nest-type + [[ $ntype == glob_attr=* ]] && force_attr=${ntype#*=} + ((_ble_syntax_attr[i++]=${force_attr:-_ble_attr_BRACE})) + ((ctx=_ble_ctx_BRACE2)) + return 0 + fi + local chars=",${_ble_syntax_bash_chars[_ble_ctx_ARGI]//'~:'}" + ((ctx==_ble_ctx_BRACE2)) && chars="}$chars" + ble/syntax:bash/cclass/update/reorder chars + if ble/syntax:bash/check-plain-with-escape "[^$chars]+"; then + return 0 + elif ble/syntax:bash/check-process-subst; then + return 0 + elif ble/syntax:bash/check-quotes; then + return 0 + elif ble/syntax:bash/check-dollar; then + return 0 + elif ble/syntax:bash/check-glob; then + return 0 + elif ble/syntax:bash/check-brace-expansion; then + return 0 + elif ble/syntax:bash/starts-with-histchars; then + ble/syntax:bash/check-history-expansion || + ((_ble_syntax_attr[i++]=ctx)) + return 0 + fi + return 1 +} +function ble/syntax:bash/ctx-brace-expansion.end { + if ((i==${#text})) || ble/syntax:bash/check-word-end/is-delimiter; then + ble/syntax/parse/nest-pop + ble/syntax/parse/check-end + return "$?" + fi + return 0 +} +function ble/syntax:bash/check-tilde-expansion { + [[ $tail == ['~:']* ]] || return 1 + local rhs_enabled= + { ((ctx==_ble_ctx_VRHS||ctx==_ble_ctx_ARGVR||ctx==_ble_ctx_VALR||ctx==_ble_ctx_ARGER)) || + ! ble/base/is-POSIXLY_CORRECT; } && rhs_enabled=1 + local tilde_enabled=$((i==wbegin||ctx==_ble_ctx_PWORD)) + [[ $1 == rhs && $rhs_enabled ]] && tilde_enabled=1 # = の直後 + if [[ $tail == ':'* ]]; then + _ble_syntax_attr[i++]=$ctx + if [[ $rhs_enabled ]]; then + if ! ((tilde_enabled=_ble_syntax_bash_command_IsAssign[ctx])); then + if ((ctx==_ble_ctx_BRAX)); then + local nctx; ble/syntax/parse/nest-ctx + ((tilde_enabled=_ble_syntax_bash_command_IsAssign[nctx])) + fi + fi + fi + local tail=${text:i} + [[ $tail == '~'* ]] || return 0 + fi + if ((tilde_enabled)); then + local chars="${_ble_syntax_bash_chars[_ble_ctx_ARGI]}/:" + ((ctx==_ble_ctx_PWORD)) && chars=${chars/'{'/'{}'} + ble/syntax:bash/cclass/update/reorder chars + local delimiters="$_ble_term_IFS;|&)<>" + local rex='^(~\+|~[^'$chars']*)([^'$delimiters'/:]?)'; [[ $tail =~ $rex ]] + local str=${BASH_REMATCH[1]} + local path attr=$ctx + builtin eval "path=$str" + if [[ ! ${BASH_REMATCH[2]} && $path != "$str" ]]; then + ((attr=_ble_attr_TILDE)) + if ((ctx==_ble_ctx_BRAX)); then + ble/util/assert 'ble/util/unlocal tail; [[ $tail == ":~"* ]]' + ble/syntax/parse/nest-pop + fi + else + if [[ $str == '~+' ]]; then + ble/syntax/parse/set-lookahead 3 + str='~' + fi + fi + ((_ble_syntax_attr[i]=attr,i+=${#str})) + else + ((_ble_syntax_attr[i]=ctx,i++)) # skip tilde + local chars=${_ble_syntax_bash_chars[_ble_ctx_ARGI]} + ble/syntax:bash/check-plain-with-escape "[^$chars]+" # 追加(失敗してもOK) + fi + return 0 +} +_ble_syntax_bash_command_CtxAssign[_ble_ctx_CMDI]=$_ble_ctx_VRHS +_ble_syntax_bash_command_CtxAssign[_ble_ctx_COARGI]=$_ble_ctx_VRHS +_ble_syntax_bash_command_CtxAssign[_ble_ctx_ARGVI]=$_ble_ctx_ARGVR +_ble_syntax_bash_command_CtxAssign[_ble_ctx_ARGEI]=$_ble_ctx_ARGER +_ble_syntax_bash_command_CtxAssign[_ble_ctx_ARGI]=$_ble_ctx_ARGQ +_ble_syntax_bash_command_CtxAssign[_ble_ctx_FARGI3]=$_ble_ctx_FARGQ3 +_ble_syntax_bash_command_CtxAssign[_ble_ctx_CARGI1]=$_ble_ctx_CARGQ1 +_ble_syntax_bash_command_CtxAssign[_ble_ctx_CPATI]=$_ble_ctx_CPATQ +_ble_syntax_bash_command_CtxAssign[_ble_ctx_VALI]=$_ble_ctx_VALQ +_ble_syntax_bash_command_CtxAssign[_ble_ctx_CONDI]=$_ble_ctx_CONDQ +_ble_syntax_bash_command_IsAssign[_ble_ctx_VRHS]=$_ble_ctx_CMDI +_ble_syntax_bash_command_IsAssign[_ble_ctx_ARGVR]=$_ble_ctx_ARGVI +_ble_syntax_bash_command_IsAssign[_ble_ctx_ARGER]=$_ble_ctx_ARGEI +_ble_syntax_bash_command_IsAssign[_ble_ctx_ARGQ]=$_ble_ctx_ARGI +_ble_syntax_bash_command_IsAssign[_ble_ctx_FARGQ3]=$_ble_ctx_FARGI3 +_ble_syntax_bash_command_IsAssign[_ble_ctx_CARGQ1]=$_ble_ctx_CARGI1 +_ble_syntax_bash_command_IsAssign[_ble_ctx_CPATQ]=$_ble_ctx_CPATI +_ble_syntax_bash_command_IsAssign[_ble_ctx_VALR]=$_ble_ctx_VALI +_ble_syntax_bash_command_IsAssign[_ble_ctx_VALQ]=$_ble_ctx_VALI +_ble_syntax_bash_command_IsAssign[_ble_ctx_CONDQ]=$_ble_ctx_CONDI +function ble/syntax:bash/check-variable-assignment { + ((wbegin==i)) || return 1 + if ((ctx==_ble_ctx_VALI)) && [[ $tail == '['* ]]; then + ((ctx=_ble_ctx_VALR)) + ble/syntax/parse/nest-push "$_ble_ctx_EXPR" 'd[' + ((_ble_syntax_attr[i++]=ctx)) + return 0 + fi + [[ ${_ble_syntax_bash_command_CtxAssign[ctx]} ]] || return 1 + local suffix='[=[]' + ((_ble_bash>=30100)) && suffix=$suffix'|\+=?' + local rex_assign="^([_a-zA-Z][_a-zA-Z0-9]*)($suffix)" + [[ $tail =~ $rex_assign ]] || return 1 + local rematch=$BASH_REMATCH + local rematch1=${BASH_REMATCH[1]} # for bash-3.1 ${#arr[n]} bug + local rematch2=${BASH_REMATCH[2]} # for bash-3.1 ${#arr[n]} bug + if [[ $rematch2 == '+' ]]; then + ble/syntax/parse/set-lookahead "$((${#rematch}+1))" + return 1 + fi + local variable_assign= + if ((ctx==_ble_ctx_CMDI||ctx==_ble_ctx_ARGVI||ctx==_ble_ctx_ARGEI&&${#rematch2})); then + local ret; ble/syntax/highlight/vartype "$rematch1" global + ((wtype=_ble_attr_VAR, + _ble_syntax_attr[i]=ret, + i+=${#rematch}, + ${#rematch2}&&(_ble_syntax_attr[i-${#rematch2}]=_ble_ctx_EXPR), + variable_assign=1, + ctx=_ble_syntax_bash_command_CtxAssign[ctx])) + else + ((_ble_syntax_attr[i]=ctx, + i+=${#rematch})) + fi + if [[ $rematch2 == '[' ]]; then + if [[ $variable_assign ]]; then + i=$((i-1)) ble/syntax/parse/nest-push "$_ble_ctx_EXPR" 'a[' + else + ((i--)) + tail=${text:i} ble/syntax:bash/check-glob assign + fi + elif [[ $rematch2 == *'=' ]]; then + if [[ $variable_assign && ${text:i} == '('* ]]; then + ble/syntax:bash/ctx-values/enter + ((_ble_syntax_attr[i++]=_ble_attr_DEL)) + else + [[ $variable_assign ]] || ((ctx=_ble_syntax_bash_command_CtxAssign[ctx])) + if local tail=${text:i}; [[ $tail == '~'* ]]; then + ble/syntax:bash/check-tilde-expansion rhs + fi + fi + fi + return 0 +} +_ble_syntax_context_proc[_ble_ctx_ARGX]=ble/syntax:bash/ctx-command +_ble_syntax_context_proc[_ble_ctx_ARGX0]=ble/syntax:bash/ctx-command +_ble_syntax_context_proc[_ble_ctx_CMDX]=ble/syntax:bash/ctx-command +_ble_syntax_context_proc[_ble_ctx_CMDX0]=ble/syntax:bash/ctx-command +_ble_syntax_context_proc[_ble_ctx_CMDX1]=ble/syntax:bash/ctx-command +_ble_syntax_context_proc[_ble_ctx_CMDXT]=ble/syntax:bash/ctx-command +_ble_syntax_context_proc[_ble_ctx_CMDXC]=ble/syntax:bash/ctx-command +_ble_syntax_context_proc[_ble_ctx_CMDXE]=ble/syntax:bash/ctx-command +_ble_syntax_context_proc[_ble_ctx_CMDXD]=ble/syntax:bash/ctx-command +_ble_syntax_context_proc[_ble_ctx_CMDXD0]=ble/syntax:bash/ctx-command +_ble_syntax_context_proc[_ble_ctx_CMDXV]=ble/syntax:bash/ctx-command +_ble_syntax_context_proc[_ble_ctx_ARGI]=ble/syntax:bash/ctx-command +_ble_syntax_context_proc[_ble_ctx_ARGQ]=ble/syntax:bash/ctx-command +_ble_syntax_context_proc[_ble_ctx_CMDI]=ble/syntax:bash/ctx-command +_ble_syntax_context_proc[_ble_ctx_VRHS]=ble/syntax:bash/ctx-command +_ble_syntax_context_proc[_ble_ctx_ARGVR]=ble/syntax:bash/ctx-command +_ble_syntax_context_proc[_ble_ctx_ARGER]=ble/syntax:bash/ctx-command +_ble_syntax_context_end[_ble_ctx_CMDI]=ble/syntax:bash/ctx-command/check-word-end +_ble_syntax_context_end[_ble_ctx_ARGI]=ble/syntax:bash/ctx-command/check-word-end +_ble_syntax_context_end[_ble_ctx_ARGQ]=ble/syntax:bash/ctx-command/check-word-end +_ble_syntax_context_end[_ble_ctx_VRHS]=ble/syntax:bash/ctx-command/check-word-end +_ble_syntax_context_end[_ble_ctx_ARGVR]=ble/syntax:bash/ctx-command/check-word-end +_ble_syntax_context_end[_ble_ctx_ARGER]=ble/syntax:bash/ctx-command/check-word-end +_ble_syntax_context_proc[_ble_ctx_ARGVX]=ble/syntax:bash/ctx-command +_ble_syntax_context_proc[_ble_ctx_ARGVI]=ble/syntax:bash/ctx-command +_ble_syntax_context_end[_ble_ctx_ARGVI]=ble/syntax:bash/ctx-command/check-word-end +_ble_syntax_context_proc[_ble_ctx_ARGEX]=ble/syntax:bash/ctx-command +_ble_syntax_context_proc[_ble_ctx_ARGEI]=ble/syntax:bash/ctx-command +_ble_syntax_context_end[_ble_ctx_ARGEI]=ble/syntax:bash/ctx-command/check-word-end +_ble_syntax_context_proc[_ble_ctx_SARGX1]=ble/syntax:bash/ctx-command-compound-expect +_ble_syntax_context_proc[_ble_ctx_FARGX1]=ble/syntax:bash/ctx-command-compound-expect +_ble_syntax_context_proc[_ble_ctx_FARGX2]=ble/syntax:bash/ctx-command-compound-expect +_ble_syntax_context_proc[_ble_ctx_FARGX3]=ble/syntax:bash/ctx-command +_ble_syntax_context_proc[_ble_ctx_FARGI1]=ble/syntax:bash/ctx-command +_ble_syntax_context_proc[_ble_ctx_FARGI2]=ble/syntax:bash/ctx-command +_ble_syntax_context_proc[_ble_ctx_FARGI3]=ble/syntax:bash/ctx-command +_ble_syntax_context_proc[_ble_ctx_FARGQ3]=ble/syntax:bash/ctx-command +_ble_syntax_context_end[_ble_ctx_FARGI1]=ble/syntax:bash/ctx-command/check-word-end +_ble_syntax_context_end[_ble_ctx_FARGI2]=ble/syntax:bash/ctx-command/check-word-end +_ble_syntax_context_end[_ble_ctx_FARGI3]=ble/syntax:bash/ctx-command/check-word-end +_ble_syntax_context_end[_ble_ctx_FARGQ3]=ble/syntax:bash/ctx-command/check-word-end +_ble_syntax_context_proc[_ble_ctx_CARGX1]=ble/syntax:bash/ctx-command-compound-expect +_ble_syntax_context_proc[_ble_ctx_CARGX2]=ble/syntax:bash/ctx-command-compound-expect +_ble_syntax_context_proc[_ble_ctx_CPATX]=ble/syntax:bash/ctx-command-case-pattern-expect +_ble_syntax_context_proc[_ble_ctx_CPATX0]=ble/syntax:bash/ctx-command-case-pattern-expect +_ble_syntax_context_proc[_ble_ctx_CARGI1]=ble/syntax:bash/ctx-command +_ble_syntax_context_proc[_ble_ctx_CARGQ1]=ble/syntax:bash/ctx-command +_ble_syntax_context_proc[_ble_ctx_CARGI2]=ble/syntax:bash/ctx-command +_ble_syntax_context_proc[_ble_ctx_CPATI]=ble/syntax:bash/ctx-command +_ble_syntax_context_proc[_ble_ctx_CPATQ]=ble/syntax:bash/ctx-command +_ble_syntax_context_end[_ble_ctx_CARGI1]=ble/syntax:bash/ctx-command/check-word-end +_ble_syntax_context_end[_ble_ctx_CARGQ1]=ble/syntax:bash/ctx-command/check-word-end +_ble_syntax_context_end[_ble_ctx_CARGI2]=ble/syntax:bash/ctx-command/check-word-end +_ble_syntax_context_end[_ble_ctx_CPATI]=ble/syntax:bash/ctx-command/check-word-end +_ble_syntax_context_end[_ble_ctx_CPATQ]=ble/syntax:bash/ctx-command/check-word-end +_ble_syntax_context_proc[_ble_ctx_TARGX1]=ble/syntax:bash/ctx-command-time-expect +_ble_syntax_context_proc[_ble_ctx_TARGX2]=ble/syntax:bash/ctx-command-time-expect +_ble_syntax_context_proc[_ble_ctx_TARGI1]=ble/syntax:bash/ctx-command +_ble_syntax_context_proc[_ble_ctx_TARGI2]=ble/syntax:bash/ctx-command +_ble_syntax_context_end[_ble_ctx_TARGI1]=ble/syntax:bash/ctx-command/check-word-end +_ble_syntax_context_end[_ble_ctx_TARGI2]=ble/syntax:bash/ctx-command/check-word-end +_ble_syntax_context_proc[_ble_ctx_COARGX]=ble/syntax:bash/ctx-command-compound-expect +_ble_syntax_context_end[_ble_ctx_COARGI]=ble/syntax:bash/ctx-coproc/check-word-end +function ble/syntax:bash/starts-with-delimiter-or-redirect { + local delimiters=$_ble_syntax_bash_RexDelimiter + local redirect=$_ble_syntax_bash_RexRedirect + [[ ( $tail =~ ^$delimiters || $wbegin -lt 0 && $tail =~ ^$redirect || $wbegin -lt 0 && $tail == $'\\\n'* ) && $tail != ['<>']'('* ]] +} +function ble/syntax:bash/starts-with-delimiter { + [[ $tail == ["$_ble_term_IFS;|&<>()"]* && $tail != ['<>']'('* ]] +} +function ble/syntax:bash/check-word-end/is-delimiter { + local tail=${text:i} + if [[ $tail == [!"$_ble_term_IFS;|&<>()"]* ]]; then + return 1 + elif [[ $tail == ['<>']* ]]; then + ble/syntax/parse/set-lookahead 2 + [[ $tail == ['<>']'('* ]] && return 1 + fi + return 0 +} +function ble/syntax:bash/check-here-document-from { + local spaces=$1 + [[ $nparam && $spaces == *$'\n'* ]] || return 1 + local rex="$_ble_term_FS@([RI][QH][^$_ble_term_FS]*)(.*$)" && [[ $nparam =~ $rex ]] || return 1 + local rematch1=${BASH_REMATCH[1]} + local rematch2=${BASH_REMATCH[2]} + local padding=${spaces%%$'\n'*} + ((_ble_syntax_attr[i]=ctx,i+=${#padding})) + nparam=${nparam::${#nparam}-${#BASH_REMATCH}}${nparam:${#nparam}-${#rematch2}} + ble/syntax/parse/nest-push "$_ble_ctx_HERE0" + ((i++)) + nparam=$rematch1 + return 0 +} +function ble/syntax:bash/ctx-coproc/.is-next-compound { + local p=$i ahead=1 tail=${text:i} + if local rex=$'^[ \t]+'; [[ $tail =~ $rex ]]; then + ((p+=${#BASH_REMATCH})) + ahead=1 tail=${text:p} + fi + local is_compound= + if [[ $tail == '('* ]]; then + is_compound=1 + elif rex='^[a-z]+|^\[\[?|^[{}!]'; [[ $tail =~ $rex ]]; then + local rematch=$BASH_REMATCH + ((p+=${#rematch})) + [[ $rematch == ['{}!'] || $rematch == '[[' ]]; ahead=$? + rex='^(\[\[|for|select|case|if|while|until|fi|done|esac|then|elif|else|do|[{}!]|coproc|function)$' + if [[ $rematch =~ $rex ]]; then + if rex='^[;|&()'$_ble_term_IFS']|^$|^[<>]\(?' ahead=1; [[ ${text:p} =~ $rex ]]; then + local rematch=$BASH_REMATCH + ((p+=${#rematch})) + [[ $rematch && $rematch != ['<>'] ]]; ahead=$? + [[ $rematch != ['<>']'(' ]] && is_compound=1 + fi + fi + fi + ble/syntax/parse/set-lookahead "$((p+ahead-i))" + [[ $is_compound ]] +} +function ble/syntax:bash/ctx-coproc/check-word-end { + ble/util/assert '((ctx==_ble_ctx_COARGI))' + ((wbegin<0)) && return 1 + ble/syntax:bash/check-word-end/is-delimiter || return 1 + local wbeg=$wbegin wlen=$((i-wbegin)) wend=$i + local word=${text:wbegin:wlen} + local wt=$wtype + if local rex='^[_a-zA-Z][_a-zA-Z0-9]*$'; [[ $word =~ $rex ]]; then + if ble/syntax:bash/ctx-coproc/.is-next-compound; then + local attr=$_ble_attr_VAR + if ble/alias#active "$word"; then + attr= + local ret; ble/alias#expand "$word" + case $word in + ('if'|'while'|'until'|'for'|'select'|'case'|'{'|'[[') ;; + ('fi'|'done'|'esac'|'then'|'elif'|'else'|'do'|'}'|'!'|'coproc'|'function'|'in') ;; + (*) + if ble/string#match "$word" '^[_a-zA-Z][_a-zA-Z0-9]*$'; then + attr=$_ble_attr_CMD_ALIAS + else + attr=$_ble_attr_ERR + fi + esac + fi + if [[ $attr ]]; then + _ble_syntax_attr[wbegin]=$attr + ((ctx=_ble_ctx_CMDXC,wtype=_ble_ctx_ARGVI)) + ble/syntax/parse/word-pop + return 0 + fi + fi + fi + ((ctx=_ble_ctx_CMDI,wtype=_ble_ctx_CMDX)) + ble/syntax:bash/ctx-command/check-word-end +} +_ble_syntax_bash_command_EndCtx=() +_ble_syntax_bash_command_EndCtx[_ble_ctx_ARGI]=$_ble_ctx_ARGX +_ble_syntax_bash_command_EndCtx[_ble_ctx_ARGQ]=$_ble_ctx_ARGX +_ble_syntax_bash_command_EndCtx[_ble_ctx_ARGVI]=$_ble_ctx_ARGVX +_ble_syntax_bash_command_EndCtx[_ble_ctx_ARGVR]=$_ble_ctx_ARGVX +_ble_syntax_bash_command_EndCtx[_ble_ctx_ARGEI]=$_ble_ctx_ARGEX +_ble_syntax_bash_command_EndCtx[_ble_ctx_ARGER]=$_ble_ctx_ARGEX +_ble_syntax_bash_command_EndCtx[_ble_ctx_VRHS]=$_ble_ctx_CMDXV +_ble_syntax_bash_command_EndCtx[_ble_ctx_FARGI1]=$_ble_ctx_FARGX2 +_ble_syntax_bash_command_EndCtx[_ble_ctx_FARGI2]=$_ble_ctx_FARGX3 +_ble_syntax_bash_command_EndCtx[_ble_ctx_FARGI3]=$_ble_ctx_FARGX3 +_ble_syntax_bash_command_EndCtx[_ble_ctx_FARGQ3]=$_ble_ctx_FARGX3 +_ble_syntax_bash_command_EndCtx[_ble_ctx_CARGI1]=$_ble_ctx_CARGX2 +_ble_syntax_bash_command_EndCtx[_ble_ctx_CARGQ1]=$_ble_ctx_CARGX2 +_ble_syntax_bash_command_EndCtx[_ble_ctx_CARGI2]=$_ble_ctx_CASE +_ble_syntax_bash_command_EndCtx[_ble_ctx_CPATI]=$_ble_ctx_CPATX0 +_ble_syntax_bash_command_EndCtx[_ble_ctx_CPATQ]=$_ble_ctx_CPATX0 +_ble_syntax_bash_command_EndCtx[_ble_ctx_TARGI1]=$((_ble_bash>=40200?_ble_ctx_TARGX2:_ble_ctx_CMDXT)) #1 +_ble_syntax_bash_command_EndCtx[_ble_ctx_TARGI2]=$_ble_ctx_CMDXT +_ble_syntax_bash_command_EndWtype[_ble_ctx_ARGX]=$_ble_ctx_ARGI +_ble_syntax_bash_command_EndWtype[_ble_ctx_ARGX0]=$_ble_ctx_ARGI +_ble_syntax_bash_command_EndWtype[_ble_ctx_ARGVX]=$_ble_ctx_ARGVI +_ble_syntax_bash_command_EndWtype[_ble_ctx_ARGEX]=$_ble_ctx_ARGEI +_ble_syntax_bash_command_EndWtype[_ble_ctx_CMDX]=$_ble_ctx_CMDI +_ble_syntax_bash_command_EndWtype[_ble_ctx_CMDX0]=$_ble_ctx_CMDX0 +_ble_syntax_bash_command_EndWtype[_ble_ctx_CMDX1]=$_ble_ctx_CMDI +_ble_syntax_bash_command_EndWtype[_ble_ctx_CMDXT]=$_ble_ctx_CMDI +_ble_syntax_bash_command_EndWtype[_ble_ctx_CMDXC]=$_ble_ctx_CMDI +_ble_syntax_bash_command_EndWtype[_ble_ctx_CMDXE]=$_ble_ctx_CMDI +_ble_syntax_bash_command_EndWtype[_ble_ctx_CMDXD]=$_ble_ctx_CMDI +_ble_syntax_bash_command_EndWtype[_ble_ctx_CMDXD0]=$_ble_ctx_CMDI +_ble_syntax_bash_command_EndWtype[_ble_ctx_CMDXV]=$_ble_ctx_CMDI +_ble_syntax_bash_command_EndWtype[_ble_ctx_FARGX1]=$_ble_ctx_FARGI1 # 変数名 +_ble_syntax_bash_command_EndWtype[_ble_ctx_SARGX1]=$_ble_ctx_ARGI +_ble_syntax_bash_command_EndWtype[_ble_ctx_FARGX2]=$_ble_ctx_FARGI2 # in +_ble_syntax_bash_command_EndWtype[_ble_ctx_FARGX3]=$_ble_ctx_ARGI # in +_ble_syntax_bash_command_EndWtype[_ble_ctx_CARGX1]=$_ble_ctx_ARGI +_ble_syntax_bash_command_EndWtype[_ble_ctx_CARGX2]=$_ble_ctx_CARGI2 # in +_ble_syntax_bash_command_EndWtype[_ble_ctx_CPATX]=$_ble_ctx_CPATI +_ble_syntax_bash_command_EndWtype[_ble_ctx_CPATX0]=$_ble_ctx_CPATI +_ble_syntax_bash_command_EndWtype[_ble_ctx_TARGX1]=$_ble_ctx_ARGI # -p +_ble_syntax_bash_command_EndWtype[_ble_ctx_TARGX2]=$_ble_ctx_ARGI # -- +_ble_syntax_bash_command_Expect=() +_ble_syntax_bash_command_Expect[_ble_ctx_CMDXC]='^(\(|\{|\(\(|\[\[|for|select|case|if|while|until)$' +_ble_syntax_bash_command_Expect[_ble_ctx_CMDXE]='^(\}|fi|done|esac|then|elif|else|do)$' +_ble_syntax_bash_command_Expect[_ble_ctx_CMDXD]='^(\{|do)$' +_ble_syntax_bash_command_Expect[_ble_ctx_CMDXD0]='^(\{|do)$' +function ble/syntax:bash/ctx-command/check-word-end { + ((wbegin<0)) && return 1 + ble/syntax:bash/check-word-end/is-delimiter || return 1 + local wbeg=$wbegin wlen=$((i-wbegin)) wend=$i + local word=${text:wbegin:wlen} + local stat_wt=$wtype # 単語解析中の wtype + [[ ${_ble_syntax_bash_command_EndWtype[stat_wt]} ]] && + wtype=${_ble_syntax_bash_command_EndWtype[stat_wt]} + local rex_expect_command=${_ble_syntax_bash_command_Expect[stat_wt]} + if [[ $rex_expect_command ]]; then + [[ $word =~ $rex_expect_command ]] || ((wtype=_ble_ctx_CMDX0)) + elif ((stat_wt==_ble_ctx_ARGX0||stat_wt==_ble_ctx_CPATX0)); then + ((wtype=_ble_attr_ERR)) + elif ((stat_wt==_ble_ctx_CMDX1)); then + local rex='^(then|elif|else|do|\}|done|fi|esac)$' + [[ $word =~ $rex ]] && ((wtype=_ble_ctx_CMDX0)) + fi + local tree_wt=$wtype # 実際に単語として登録された wtype + ble/syntax/parse/word-pop + if ((ctx==_ble_ctx_CMDI)); then + local ret + ble/alias#expand "$word"; local word_expanded=$ret + if ((tree_wt==_ble_ctx_CMDX0)); then + ((_ble_syntax_attr[wbeg]=_ble_attr_ERR,ctx=_ble_ctx_ARGX)) + return 0 + elif ((stat_wt!=_ble_ctx_CMDXV)); then # Note: 変数代入の直後はキーワードは処理しない + local processed= + case $word_expanded in + ('[[') + ble/syntax/parse/touch-updated-attr "$wbeg" + ((_ble_syntax_attr[wbeg]=_ble_attr_DEL, + ctx=_ble_bash>=50200?_ble_ctx_CMDXE:_ble_ctx_ARGX0)) + ble/syntax/parse/word-cancel # 単語 "[[" (とその内部のノード全て) を削除 + if [[ $word == '[[' ]]; then + _ble_syntax_attr[wbeg+1]= # 角括弧式として着色されているのを消去 + fi + i=$wbeg ble/syntax/parse/nest-push "$_ble_ctx_CONDX" + i=$wbeg ble/syntax/parse/word-push "$_ble_ctx_CMDI" "$wbeg" + ble/syntax/parse/word-pop + return 0 ;; + ('time') ((ctx=_ble_ctx_TARGX1)); processed=keyword ;; + ('!') ((ctx=_ble_ctx_CMDXT)) ; processed=keyword ;; + ('if'|'while'|'until') ((ctx=_ble_ctx_CMDX1)) ; processed=begin ;; + ('for') ((ctx=_ble_ctx_FARGX1)); processed=begin ;; + ('select') ((ctx=_ble_ctx_SARGX1)); processed=begin ;; + ('case') ((ctx=_ble_ctx_CARGX1)); processed=begin ;; + ('{') + ble/syntax/parse/touch-updated-attr "$wbeg" + if ((stat_wt==_ble_ctx_CMDXD||stat_wt==_ble_ctx_CMDXD0)); then + attr=$_ble_attr_KEYWORD_MID # "for ...; {" などの時 + else + attr=$_ble_attr_KEYWORD_BEGIN + fi + ((_ble_syntax_attr[wbeg]=attr)) + ble/syntax/parse/word-cancel + ((ctx=_ble_ctx_CMDXE)) + i=$wbeg ble/syntax/parse/nest-push "$_ble_ctx_CMDX1" 'cmd_brace' + i=$wbeg ble/syntax/parse/word-push "$_ble_ctx_CMDI" "$wbeg" + ble/syntax/parse/word-pop + return 0 ;; + ('then'|'elif'|'else'|'do') ((ctx=_ble_ctx_CMDX1)); processed=middle ;; + ('done'|'fi'|'esac') ((ctx=_ble_ctx_CMDXE)); processed=end ;; + ('}') + if local ntype; ble/syntax/parse/nest-type; [[ $ntype == 'cmd_brace' ]]; then + ble/syntax/parse/touch-updated-attr "$wbeg" + ((_ble_syntax_attr[wbeg]=_ble_attr_KEYWORD_END)) + ble/syntax/parse/nest-pop + else + ble/syntax/parse/touch-updated-attr "$wbeg" + ((_ble_syntax_attr[wbeg]=_ble_attr_ERR)) + ((ctx=_ble_ctx_CMDXE)) + fi + return 0 ;; + ('coproc') + if ((_ble_bash>=40000)); then + if ble/syntax:bash/ctx-coproc/.is-next-compound; then + ((ctx=_ble_ctx_CMDXC)) + else + ((ctx=_ble_ctx_COARGX)) + fi + processed=keyword + fi ;; + ('function') + ((ctx=_ble_ctx_ARGX)) + local isfuncsymx=$'\t\n'' "$&'\''();<>\`|' rex_space=$'[ \t]' rex + if rex="^$rex_space+" && [[ ${text:i} =~ $rex ]]; then + ((_ble_syntax_attr[i]=_ble_ctx_ARGX,i+=${#BASH_REMATCH},ctx=_ble_ctx_ARGX)) + if rex="^([^#$isfuncsymx][^$isfuncsymx]*)($rex_space*)(\(\(|\($rex_space*\)?)?" && [[ ${text:i} =~ $rex ]]; then + local rematch1=${BASH_REMATCH[1]} + local rematch2=${BASH_REMATCH[2]} + local rematch3=${BASH_REMATCH[3]} + ((_ble_syntax_attr[i]=_ble_attr_FUNCDEF,i+=${#rematch1}, + ${#rematch2}&&(_ble_syntax_attr[i]=_ble_ctx_CMDX1,i+=${#rematch2}))) + if [[ $rematch3 == '('*')' ]]; then + ((_ble_syntax_attr[i]=_ble_attr_DEL,i+=${#rematch3},ctx=_ble_ctx_CMDXC)) + elif ((_ble_bash>=40200)) && [[ $rematch3 == '((' ]]; then + ble/syntax/parse/set-lookahead 2 + ((ctx=_ble_ctx_CMDXC)) + elif [[ $rematch3 == '('* ]]; then + ((_ble_syntax_attr[i]=_ble_attr_ERR,ctx=_ble_ctx_ARGX0)) + ble/syntax/parse/nest-push "$_ble_ctx_CMDX1" '(' + ((${#rematch3}>=2&&(_ble_syntax_attr[i+1]=_ble_ctx_CMDX1),i+=${#rematch3})) + else + ((ctx=_ble_ctx_CMDXC)) + fi + processed=keyword + fi + fi + [[ $processed ]] || ((_ble_syntax_attr[i-1]=_ble_attr_ERR)) ;; + esac + if [[ $processed ]]; then + local attr= + case $processed in + (keyword) attr=$_ble_attr_KEYWORD ;; + (begin) attr=$_ble_attr_KEYWORD_BEGIN ;; + (end) attr=$_ble_attr_KEYWORD_END ;; + (middle) attr=$_ble_attr_KEYWORD_MID ;; + esac + if [[ $attr ]]; then + ble/syntax/parse/touch-updated-attr "$wbeg" + ((_ble_syntax_attr[wbeg]=attr)) + fi + return 0 + fi + fi + ((ctx=_ble_ctx_ARGX)) + if local rex='^([ ]*)(\([ ]*\)?)?'; [[ ${text:i} =~ $rex && $BASH_REMATCH ]]; then + local rematch1=${BASH_REMATCH[1]} + local rematch2=${BASH_REMATCH[2]} + if [[ $rematch2 == '('*')' ]]; then + ((tree_wt==_ble_ctx_CMDX0)) || + _ble_syntax_tree[i-1]="$_ble_attr_FUNCDEF ${_ble_syntax_tree[i-1]#* }" + ((_ble_syntax_attr[i]=_ble_ctx_CMDX1,i+=${#rematch1}, + _ble_syntax_attr[i]=_ble_attr_DEL,i+=${#rematch2}, + ctx=_ble_ctx_CMDXC)) + elif [[ $rematch2 == '('* ]]; then + ((_ble_syntax_attr[i]=_ble_ctx_ARGX0,i+=${#rematch1}, + _ble_syntax_attr[i]=_ble_attr_ERR, + ctx=_ble_ctx_ARGX0)) + ble/syntax/parse/nest-push "$_ble_ctx_PATN" + ((${#rematch2}>=2&&(_ble_syntax_attr[i+1]=_ble_ctx_CMDXC), + i+=${#rematch2})) + else + ble/syntax/parse/set-lookahead "$((${#rematch1}+1))" + fi + fi + case $word_expanded in + ('declare'|'readonly'|'typeset'|'local'|'export'|'alias') + ((ctx=_ble_ctx_ARGVX)) ;; + ('eval') + ((ctx=_ble_ctx_ARGEX)) ;; + esac + return 0 + fi + if ((ctx==_ble_ctx_FARGI2)); then + if [[ $word == do ]]; then + ((ctx=_ble_ctx_CMDX1)) + return 0 + fi + fi + if ((ctx==_ble_ctx_FARGI2||ctx==_ble_ctx_CARGI2)); then + if [[ $word != in ]]; then + ble/syntax/parse/touch-updated-attr "$wbeg" + ((_ble_syntax_attr[wbeg]=_ble_attr_ERR)) + fi + fi + if ((_ble_syntax_bash_command_EndCtx[ctx])); then + ((ctx=_ble_syntax_bash_command_EndCtx[ctx])) + fi + return 0 +} +_ble_syntax_bash_command_Opt=() +_ble_syntax_bash_command_Opt[_ble_ctx_ARGX]=1 +_ble_syntax_bash_command_Opt[_ble_ctx_ARGX0]=1 +_ble_syntax_bash_command_Opt[_ble_ctx_ARGVX]=1 +_ble_syntax_bash_command_Opt[_ble_ctx_ARGEX]=1 +_ble_syntax_bash_command_Opt[_ble_ctx_CMDX0]=1 +_ble_syntax_bash_command_Opt[_ble_ctx_CMDXV]=1 +_ble_syntax_bash_command_Opt[_ble_ctx_CMDXE]=1 +_ble_syntax_bash_command_Opt[_ble_ctx_CMDXD0]=1 +_ble_syntax_bash_is_command_form_for= +function ble/syntax:bash/ctx-command/.check-delimiter-or-redirect { + if [[ $tail =~ ^$_ble_syntax_bash_RexIFSs || $wbegin -lt 0 && $tail == $'\\\n'* ]]; then + local spaces=$BASH_REMATCH + if [[ $tail == $'\\\n'* ]]; then + spaces=$'\\\n' + elif [[ $spaces == *$'\n'* ]]; then + ble/syntax:bash/check-here-document-from "$spaces" && return 0 + if ((ctx==_ble_ctx_ARGX||ctx==_ble_ctx_ARGX0||ctx==_ble_ctx_ARGVX||ctx==_ble_ctx_ARGEX||ctx==_ble_ctx_CMDX0||ctx==_ble_ctx_CMDXV||ctx==_ble_ctx_CMDXT||ctx==_ble_ctx_CMDXE)); then + ((ctx=_ble_ctx_CMDX)) + elif ((ctx==_ble_ctx_FARGX2||ctx==_ble_ctx_FARGX3||ctx==_ble_ctx_CMDXD0)); then + ((ctx=_ble_ctx_CMDXD)) + fi + fi + ((_ble_syntax_attr[i]=ctx,i+=${#spaces})) + return 0 + elif [[ $tail =~ ^$_ble_syntax_bash_RexRedirect ]]; then + local len=${#BASH_REMATCH} + local rematch1=${BASH_REMATCH[1]} + local rematch3=${BASH_REMATCH[3]} + ((_ble_syntax_attr[i]=_ble_attr_DEL, + ${#rematch1}&' ]]; then + ble/syntax/parse/nest-push "$_ble_ctx_RDRD2" "$rematch3" + elif [[ $rematch1 == *'&' ]]; then + ble/syntax/parse/nest-push "$_ble_ctx_RDRD" "$rematch3" + elif [[ $rematch1 == *'<<<' ]]; then + ble/syntax/parse/nest-push "$_ble_ctx_RDRS" "$rematch3" + elif [[ $rematch1 == *\<\< ]]; then + ble/syntax/parse/nest-push "$_ble_ctx_RDRH" "$rematch3" + elif [[ $rematch1 == *\<\<- ]]; then + ble/syntax/parse/nest-push "$_ble_ctx_RDRI" "$rematch3" + else + ble/syntax/parse/nest-push "$_ble_ctx_RDRF" "$rematch3" + fi + fi + ((i+=len)) + return 0 + elif local rex='^(&&|\|[|&]?)|^;(;&?|&)|^[;&]' + ((_ble_bash<40000)) && rex='^(&&|\|\|?)|^;(;)|^[;&]' + [[ $tail =~ $rex ]] + then + if [[ $BASH_REMATCH == ';' ]]; then + if ((ctx==_ble_ctx_FARGX2||ctx==_ble_ctx_FARGX3||ctx==_ble_ctx_CMDXD0)); then + ((_ble_syntax_attr[i++]=_ble_attr_DEL,ctx=_ble_ctx_CMDXD)) + return 0 + elif ((ctx==_ble_ctx_CMDXT)); then + ((_ble_syntax_attr[i++]=_ble_attr_DEL,ctx=_ble_bash>=40400?_ble_ctx_CMDX:_ble_ctx_CMDXE)) + return 0 + fi + fi + local rematch1=${BASH_REMATCH[1]} rematch2=${BASH_REMATCH[2]} + ((_ble_syntax_attr[i]=_ble_attr_DEL, + (_ble_syntax_bash_command_Opt[ctx]||ctx==_ble_ctx_CMDX&&${#rematch2})|| + (_ble_syntax_attr[i]=_ble_attr_ERR))) + ((ctx=${#rematch1}?_ble_ctx_CMDX1:( + ${#rematch2}?_ble_ctx_CASE: + _ble_ctx_CMDX))) + ((i+=${#BASH_REMATCH})) + return 0 + elif local rex='^\(\(?' && [[ $tail =~ $rex ]]; then + local m=${BASH_REMATCH[0]} + if ((ctx==_ble_ctx_CMDX||ctx==_ble_ctx_CMDX1||ctx==_ble_ctx_CMDXT||ctx==_ble_ctx_CMDXC)); then + ((_ble_syntax_attr[i]=_ble_attr_DEL)) + ((ctx=_ble_bash>=50200||${#m}==1?_ble_ctx_CMDXE:_ble_ctx_ARGX0)) + [[ $_ble_syntax_bash_is_command_form_for && $tail == '(('* ]] && ((ctx=_ble_ctx_CMDXD0)) + ble/syntax/parse/nest-push "$((${#m}==1?_ble_ctx_CMDX1:_ble_ctx_EXPR))" "$m" + ((i+=${#m})) + else + ble/syntax/parse/nest-push "$_ble_ctx_PATN" + ((_ble_syntax_attr[i++]=_ble_attr_ERR)) + fi + return 0 + elif [[ $tail == ')'* ]]; then + local ntype + ble/syntax/parse/nest-type + local attr= + if [[ $ntype == '(' || $ntype == '$(' || $ntype == '((' || $ntype == '$((' ]]; then + ((attr=_ble_syntax_attr[inest])) + fi + if [[ $attr ]]; then + ((_ble_syntax_attr[i]=(ctx==_ble_ctx_CMDX||ctx==_ble_ctx_CMDX0||ctx==_ble_ctx_CMDXV||ctx==_ble_ctx_CMDXE||ctx==_ble_ctx_ARGX||ctx==_ble_ctx_ARGX0||ctx==_ble_ctx_ARGVX||ctx==_ble_ctx_ARGEX)?attr:_ble_attr_ERR, + i+=1)) + ble/syntax/parse/nest-pop + return 0 + fi + fi + return 1 +} +_ble_syntax_bash_command_BeginCtx=() +_ble_syntax_bash_command_BeginCtx[_ble_ctx_ARGX]=$_ble_ctx_ARGI +_ble_syntax_bash_command_BeginCtx[_ble_ctx_ARGX0]=$_ble_ctx_ARGI +_ble_syntax_bash_command_BeginCtx[_ble_ctx_ARGVX]=$_ble_ctx_ARGVI +_ble_syntax_bash_command_BeginCtx[_ble_ctx_ARGEX]=$_ble_ctx_ARGEI +_ble_syntax_bash_command_BeginCtx[_ble_ctx_CMDX]=$_ble_ctx_CMDI +_ble_syntax_bash_command_BeginCtx[_ble_ctx_CMDX0]=$_ble_ctx_CMDI +_ble_syntax_bash_command_BeginCtx[_ble_ctx_CMDX1]=$_ble_ctx_CMDI +_ble_syntax_bash_command_BeginCtx[_ble_ctx_CMDXT]=$_ble_ctx_CMDI +_ble_syntax_bash_command_BeginCtx[_ble_ctx_CMDXC]=$_ble_ctx_CMDI +_ble_syntax_bash_command_BeginCtx[_ble_ctx_CMDXE]=$_ble_ctx_CMDI +_ble_syntax_bash_command_BeginCtx[_ble_ctx_CMDXD]=$_ble_ctx_CMDI +_ble_syntax_bash_command_BeginCtx[_ble_ctx_CMDXD0]=$_ble_ctx_CMDI +_ble_syntax_bash_command_BeginCtx[_ble_ctx_CMDXV]=$_ble_ctx_CMDI +_ble_syntax_bash_command_BeginCtx[_ble_ctx_FARGX1]=$_ble_ctx_FARGI1 +_ble_syntax_bash_command_BeginCtx[_ble_ctx_SARGX1]=$_ble_ctx_FARGI1 +_ble_syntax_bash_command_BeginCtx[_ble_ctx_FARGX2]=$_ble_ctx_FARGI2 +_ble_syntax_bash_command_BeginCtx[_ble_ctx_FARGX3]=$_ble_ctx_FARGI3 +_ble_syntax_bash_command_BeginCtx[_ble_ctx_CARGX1]=$_ble_ctx_CARGI1 +_ble_syntax_bash_command_BeginCtx[_ble_ctx_CARGX2]=$_ble_ctx_CARGI2 +_ble_syntax_bash_command_BeginCtx[_ble_ctx_CPATX]=$_ble_ctx_CPATI +_ble_syntax_bash_command_BeginCtx[_ble_ctx_CPATX0]=$_ble_ctx_CPATI +_ble_syntax_bash_command_BeginCtx[_ble_ctx_TARGX1]=$_ble_ctx_TARGI1 +_ble_syntax_bash_command_BeginCtx[_ble_ctx_TARGX2]=$_ble_ctx_TARGI2 +_ble_syntax_bash_command_BeginCtx[_ble_ctx_COARGX]=$_ble_ctx_COARGI +_ble_syntax_bash_command_isARGI[_ble_ctx_CMDI]=1 +_ble_syntax_bash_command_isARGI[_ble_ctx_VRHS]=1 +_ble_syntax_bash_command_isARGI[_ble_ctx_ARGI]=1 +_ble_syntax_bash_command_isARGI[_ble_ctx_ARGQ]=1 +_ble_syntax_bash_command_isARGI[_ble_ctx_ARGVI]=1 +_ble_syntax_bash_command_isARGI[_ble_ctx_ARGVR]=1 +_ble_syntax_bash_command_isARGI[_ble_ctx_ARGEI]=1 +_ble_syntax_bash_command_isARGI[_ble_ctx_ARGER]=1 +_ble_syntax_bash_command_isARGI[_ble_ctx_FARGI1]=1 # var +_ble_syntax_bash_command_isARGI[_ble_ctx_FARGI2]=1 # in +_ble_syntax_bash_command_isARGI[_ble_ctx_FARGI3]=1 # args... +_ble_syntax_bash_command_isARGI[_ble_ctx_FARGQ3]=1 # args... (= の後) +_ble_syntax_bash_command_isARGI[_ble_ctx_CARGI1]=1 # value +_ble_syntax_bash_command_isARGI[_ble_ctx_CARGQ1]=1 # value (= の後) +_ble_syntax_bash_command_isARGI[_ble_ctx_CARGI2]=1 # in +_ble_syntax_bash_command_isARGI[_ble_ctx_CPATI]=1 # pattern +_ble_syntax_bash_command_isARGI[_ble_ctx_CPATQ]=1 # pattern +_ble_syntax_bash_command_isARGI[_ble_ctx_TARGI1]=1 # -p +_ble_syntax_bash_command_isARGI[_ble_ctx_TARGI2]=1 # -- +_ble_syntax_bash_command_isARGI[_ble_ctx_COARGI]=1 # var (coproc の後) +function ble/syntax:bash/ctx-command/.check-funsub-end { + ((_ble_bash>=50300)) || return 1 + ((wbegin<0&&_ble_syntax_bash_command_BeginCtx[ctx]==_ble_ctx_CMDI)) || return 1 + [[ $tail == '}'* ]] || return 1 + local ntype + ble/syntax/parse/nest-type + [[ $ntype == 'cmdsub_nofork' ]] || return 1 + ((_ble_syntax_attr[i++]=_ble_syntax_attr[inest])) + ble/syntax/parse/nest-pop + return 0 +} +function ble/syntax:bash/ctx-command/.check-word-begin { + if ((wbegin<0)); then + local octx + ((octx=ctx, + wtype=octx, + ctx=_ble_syntax_bash_command_BeginCtx[ctx])) + ble/util/assert '((ctx!=0))' "invalid ctx=$octx at the beginning of words" || + ((ctx=wtype=_ble_ctx_ARGI)) + ble/syntax/parse/word-push "$wtype" "$i" + ((octx!=_ble_ctx_ARGX0&&octx!=_ble_ctx_CPATX0)); return "$?" # return unexpectedWbegin + fi + ble/util/assert '((_ble_syntax_bash_command_isARGI[ctx]))' "invalid ctx=$ctx in words" + return 0 +} +function ble/syntax:bash/ctx-command { + if ble/syntax:bash/starts-with-delimiter-or-redirect; then + ble/util/assert ' + ((ctx==_ble_ctx_ARGX||ctx==_ble_ctx_ARGX0||ctx==_ble_ctx_ARGVX||ctx==_ble_ctx_ARGEX|| + ctx==_ble_ctx_FARGX2||ctx==_ble_ctx_FARGX3||ctx==_ble_ctx_COARGX|| + ctx==_ble_ctx_CMDX||ctx==_ble_ctx_CMDX0||ctx==_ble_ctx_CMDX1||ctx==_ble_ctx_CMDXT||ctx==_ble_ctx_CMDXC|| + ctx==_ble_ctx_CMDXE||ctx==_ble_ctx_CMDXD||ctx==_ble_ctx_CMDXD0||ctx==_ble_ctx_CMDXV))' "invalid ctx=$ctx @ i=$i" + ble/util/assert '((wbegin<0&&wtype<0))' "invalid word-context (wtype=$wtype wbegin=$wbegin) on non-word char." + ble/syntax:bash/ctx-command/.check-delimiter-or-redirect; return "$?" + fi + ble/syntax:bash/check-comment && return 0 + ble/syntax:bash/ctx-command/.check-funsub-end && return 0 + local unexpectedWbegin=-1 + ble/syntax:bash/ctx-command/.check-word-begin || ((unexpectedWbegin=i)) + local wtype0=$wtype i0=$i + local flagConsume=0 + if ble/syntax:bash/check-variable-assignment; then + flagConsume=1 + elif local rex='^([^'${_ble_syntax_bash_chars[_ble_ctx_ARGI]}']+|\\.)'; [[ $tail =~ $rex ]]; then + local rematch=$BASH_REMATCH + local attr=$ctx + [[ $BASH_REMATCH == '\'? ]] && attr=$_ble_attr_QESC + ((_ble_syntax_attr[i]=attr,i+=${#rematch})) + flagConsume=1 + elif ble/syntax:bash/check-process-subst; then + flagConsume=1 + elif ble/syntax:bash/check-quotes; then + flagConsume=1 + elif ble/syntax:bash/check-dollar; then + flagConsume=1 + elif ble/syntax:bash/check-glob; then + flagConsume=1 + elif ble/syntax:bash/check-brace-expansion; then + flagConsume=1 + elif ble/syntax:bash/check-tilde-expansion; then + flagConsume=1 + elif ble/syntax:bash/starts-with-histchars; then + ble/syntax:bash/check-history-expansion || + ((_ble_syntax_attr[i]=ctx,i++)) + flagConsume=1 + fi + if ((flagConsume)); then + ble/util/assert '((wtype0>=0))' + if ((ctx==_ble_ctx_FARGI1)); then + local rex='^[_a-zA-Z][_a-zA-Z0-9]*$' attr=$_ble_attr_ERR + if ((i0==wbegin)) && [[ ${text:i0:i-i0} =~ $rex ]]; then + local ret; ble/syntax/highlight/vartype "$BASH_REMATCH" global; attr=$ret + fi + ((_ble_syntax_attr[i0]=attr)) + fi + [[ ${_ble_syntax_bash_command_Expect[wtype0]} ]] && + ((_ble_syntax_attr[i0]=_ble_attr_ERR)) + if ((unexpectedWbegin>=0)); then + ble/syntax/parse/touch-updated-attr "$unexpectedWbegin" + ((_ble_syntax_attr[unexpectedWbegin]=_ble_attr_ERR)) + fi + return 0 + else + return 1 + fi +} +function ble/syntax:bash/ctx-command-compound-expect { + ble/util/assert '((ctx==_ble_ctx_FARGX1||ctx==_ble_ctx_SARGX1||ctx==_ble_ctx_CARGX1||ctx==_ble_ctx_FARGX2||ctx==_ble_ctx_CARGX2||ctx==_ble_ctx_COARGX))' + local _ble_syntax_bash_is_command_form_for= + if ble/syntax:bash/starts-with-delimiter-or-redirect; then + if ((ctx==_ble_ctx_FARGX2)) && [[ $tail == [$';\n']* ]]; then + ble/syntax:bash/ctx-command + return "$?" + elif ((ctx==_ble_ctx_FARGX1)) && [[ $tail == '(('* ]]; then + ((ctx=_ble_ctx_CMDX1,_ble_syntax_bash_is_command_form_for=1)) + elif [[ $tail == $'\n'* ]]; then + if ((ctx==_ble_ctx_CARGX2)); then + ((_ble_syntax_attr[i++]=_ble_ctx_ARGX)) + else + ((_ble_syntax_attr[i++]=_ble_attr_ERR,ctx=_ble_ctx_ARGX)) + fi + return 0 + elif [[ $tail =~ ^$_ble_syntax_bash_RexSpaces ]]; then + ((_ble_syntax_attr[i]=ctx,i+=${#BASH_REMATCH})) + return 0 + elif ((ctx!=_ble_ctx_COARGX)); then + local i0=$i + ((ctx=_ble_ctx_ARGX)) + ble/syntax:bash/ctx-command/.check-delimiter-or-redirect || ((i++)) + ((_ble_syntax_attr[i0]=_ble_attr_ERR)) + return 0 + fi + fi + local i0=$i + if ble/syntax:bash/check-comment; then + if ((ctx==_ble_ctx_FARGX1||ctx==_ble_ctx_SARGX1||ctx==_ble_ctx_CARGX1||ctx==_ble_ctx_COARGX)); then + ((_ble_syntax_attr[i0]=_ble_attr_ERR)) + fi + return 0 + fi + ble/syntax:bash/ctx-command +} +function ble/syntax:bash/ctx-command-expect/.match-word { + local word=$1 len=${#1} + if [[ $tail == "$word"* ]]; then + ble/syntax/parse/set-lookahead "$((len+1))" + if ((${#tail}==len)) || i=$((i+len)) ble/syntax:bash/check-word-end/is-delimiter; then + return 0 + fi + fi + return 1 +} +function ble/syntax:bash/ctx-command-time-expect { + ble/util/assert '((ctx==_ble_ctx_TARGX1||ctx==_ble_ctx_TARGX2))' + if ble/syntax:bash/starts-with-delimiter-or-redirect; then + ble/util/assert '((wbegin<0&&wtype<0))' + if [[ $tail =~ ^$_ble_syntax_bash_RexSpaces ]]; then + ((_ble_syntax_attr[i]=ctx,i+=${#BASH_REMATCH})) + return 0 + else + ((ctx=_ble_ctx_CMDXT)) + ble/syntax:bash/ctx-command/.check-delimiter-or-redirect; return "$?" + fi + fi + if ((ctx==_ble_ctx_TARGX1)); then + ble/syntax:bash/ctx-command-expect/.match-word '-p' || + ((ctx=_ble_bash>=50100?_ble_ctx_TARGX2:_ble_ctx_CMDXT)) + fi + if ((ctx==_ble_ctx_TARGX2)); then + ble/syntax:bash/ctx-command-expect/.match-word '--' || + ((ctx=_ble_ctx_CMDXT)) + fi + ble/syntax:bash/ctx-command +} +function ble/syntax:bash/ctx-command-case-pattern-expect { + ble/util/assert '((ctx==_ble_ctx_CPATX||ctx==_ble_ctx_CPATX0))' + if ble/syntax:bash/starts-with-delimiter-or-redirect; then + local delimiter=$BASH_REMATCH + if [[ $tail =~ ^$_ble_syntax_bash_RexSpaces ]]; then + ((_ble_syntax_attr[i]=ctx,i+=${#BASH_REMATCH})) + elif [[ $tail == '|'* ]]; then + ((_ble_syntax_attr[i++]=ctx==_ble_ctx_CPATX?_ble_attr_ERR:_ble_attr_GLOB,ctx=_ble_ctx_CPATX)) + elif [[ $tail == ')'* ]]; then + ((_ble_syntax_attr[i++]=ctx==_ble_ctx_CPATX?_ble_attr_ERR:_ble_attr_GLOB,ctx=_ble_ctx_CMDX)) + elif [[ $tail == '('* ]]; then + ble/syntax:bash/ctx-command/.check-delimiter-or-redirect + else + ((_ble_syntax_attr[i]=_ble_attr_ERR,i+=${#delimiter})) + fi + return "$?" + fi + local i0=$i + if ble/syntax:bash/check-comment; then + ((_ble_syntax_attr[i0]=_ble_attr_ERR)) + return 0 + fi + ble/syntax:bash/ctx-command +} +_ble_syntax_context_proc[_ble_ctx_VALX]=ble/syntax:bash/ctx-values +_ble_syntax_context_proc[_ble_ctx_VALI]=ble/syntax:bash/ctx-values +_ble_syntax_context_end[_ble_ctx_VALI]=ble/syntax:bash/ctx-values/check-word-end +_ble_syntax_context_proc[_ble_ctx_VALR]=ble/syntax:bash/ctx-values +_ble_syntax_context_end[_ble_ctx_VALR]=ble/syntax:bash/ctx-values/check-word-end +_ble_syntax_context_proc[_ble_ctx_VALQ]=ble/syntax:bash/ctx-values +_ble_syntax_context_end[_ble_ctx_VALQ]=ble/syntax:bash/ctx-values/check-word-end +function ble/syntax:bash/ctx-values/enter { + local outer_nparam=$nparam + ble/syntax/parse/nest-push "$_ble_ctx_VALX" + nparam=$outer_nparam +} +function ble/syntax:bash/ctx-values/leave { + local inner_nparam=$nparam + ble/syntax/parse/nest-pop + nparam=$inner_nparam +} +function ble/syntax:bash/ctx-values/check-word-end { + ((wbegin<0)) && return 1 + [[ ${text:i:1} == [!"$_ble_term_IFS;|&<>()"] ]] && return 1 + local wbeg=$wbegin wlen=$((i-wbegin)) wend=$i + local word=${text:wbegin:wlen} + ble/syntax/parse/word-pop + ble/util/assert '((ctx==_ble_ctx_VALI||ctx==_ble_ctx_VALR||ctx==_ble_ctx_VALQ))' 'invalid context' + ((ctx=_ble_ctx_VALX)) + return 0 +} +function ble/syntax:bash/ctx-values { + if ble/syntax:bash/starts-with-delimiter; then + ble/util/assert '((ctx==_ble_ctx_VALX))' "invalid ctx=$ctx @ i=$i" + ble/util/assert '((wbegin<0&&wtype<0))' "invalid word-context (wtype=$wtype wbegin=$wbegin) on non-word char." + if [[ $tail =~ ^$_ble_syntax_bash_RexIFSs ]]; then + local spaces=$BASH_REMATCH + ble/syntax:bash/check-here-document-from "$spaces" && return 0 + ((_ble_syntax_attr[i]=ctx,i+=${#spaces})) + return 0 + elif [[ $tail == ')'* ]]; then + ((_ble_syntax_attr[i++]=_ble_attr_DEL)) + ble/syntax:bash/ctx-values/leave + return 0 + elif [[ $type == ';'* ]]; then + ((_ble_syntax_attr[i++]=_ble_attr_ERR)) + return 0 + else + ((_ble_syntax_attr[i++]=_ble_attr_ERR)) + return 0 + fi + fi + if ble/syntax:bash/check-comment; then + return 0 + fi + if ((wbegin<0)); then + ((ctx=_ble_ctx_VALI)) + ble/syntax/parse/word-push "$ctx" "$i" + fi + ble/util/assert '((ctx==_ble_ctx_VALI||ctx==_ble_ctx_VALR||ctx==_ble_ctx_VALQ))' "invalid context ctx=$ctx" + if ble/syntax:bash/check-variable-assignment; then + return 0 + elif ble/syntax:bash/check-plain-with-escape "[^${_ble_syntax_bash_chars[_ble_ctx_ARGI]}]+"; then + return 0 + elif ble/syntax:bash/check-process-subst; then + return 0 + elif ble/syntax:bash/check-quotes; then + return 0 + elif ble/syntax:bash/check-dollar; then + return 0 + elif ble/syntax:bash/check-glob; then + return 0 + elif ble/syntax:bash/check-brace-expansion; then + return 0 + elif ble/syntax:bash/check-tilde-expansion; then + return 0 + elif ble/syntax:bash/starts-with-histchars; then + ble/syntax:bash/check-history-expansion || + ((_ble_syntax_attr[i]=ctx,i++)) + return 0 + fi + return 1 +} +_ble_syntax_context_proc[_ble_ctx_CONDX]=ble/syntax:bash/ctx-conditions +_ble_syntax_context_proc[_ble_ctx_CONDI]=ble/syntax:bash/ctx-conditions +_ble_syntax_context_end[_ble_ctx_CONDI]=ble/syntax:bash/ctx-conditions/check-word-end +_ble_syntax_context_proc[_ble_ctx_CONDQ]=ble/syntax:bash/ctx-conditions +_ble_syntax_context_end[_ble_ctx_CONDQ]=ble/syntax:bash/ctx-conditions/check-word-end +function ble/syntax:bash/ctx-conditions/check-word-end { + ((wbegin<0)) && return 1 + [[ ${text:i:1} == [!"$_ble_term_IFS;|&<>()"] ]] && return 1 + local wbeg=$wbegin wlen=$((i-wbegin)) wend=$i + local word=${text:wbegin:wlen} + ble/syntax/parse/word-pop + ble/util/assert '((ctx==_ble_ctx_CONDI||ctx==_ble_ctx_CONDQ))' 'invalid context' + if [[ $word == ']]' ]]; then + ble/syntax/parse/touch-updated-attr "$wbeg" + ((_ble_syntax_attr[wbeg]=_ble_attr_DEL)) + ble/syntax/parse/nest-pop + else + ((ctx=_ble_ctx_CONDX)) + fi + return 0 +} +function ble/syntax:bash/ctx-conditions { + if ble/syntax:bash/starts-with-delimiter; then + ble/util/assert '((ctx==_ble_ctx_CONDX))' "invalid ctx=$ctx @ i=$i" + ble/util/assert '((wbegin<0&&wtype<0))' "invalid word-context (wtype=$wtype wbegin=$wbegin) on non-word char." + if [[ $tail =~ ^$_ble_syntax_bash_RexIFSs ]]; then + ((_ble_syntax_attr[i]=ctx,i+=${#BASH_REMATCH})) + return 0 + else + ((_ble_syntax_attr[i++]=_ble_ctx_CONDI)) + return 0 + fi + fi + ble/syntax:bash/check-comment && return 0 + if ((wbegin<0)); then + ((ctx=_ble_ctx_CONDI)) + ble/syntax/parse/word-push "$ctx" "$i" + fi + ble/util/assert '((ctx==_ble_ctx_CONDI||ctx==_ble_ctx_CONDQ))' "invalid context ctx=$ctx" + if ble/syntax:bash/check-variable-assignment; then + return 0 + elif ble/syntax:bash/check-plain-with-escape "[^${_ble_syntax_bash_chars[_ble_ctx_ARGI]}]+"; then + return 0 + elif ble/syntax:bash/check-process-subst; then + return 0 + elif ble/syntax:bash/check-quotes; then + return 0 + elif ble/syntax:bash/check-dollar; then + return 0 + elif ble/syntax:bash/check-glob; then + return 0 + elif ble/syntax:bash/check-brace-expansion; then + return 0 + elif ble/syntax:bash/check-tilde-expansion; then + return 0 + elif ble/syntax:bash/starts-with-histchars; then + ble/syntax:bash/check-history-expansion || + ((_ble_syntax_attr[i++]=ctx)) + return 0 + else + ((_ble_syntax_attr[i++]=ctx)) + return 0 + fi + return 1 +} +_ble_syntax_context_proc[_ble_ctx_RDRF]=ble/syntax:bash/ctx-redirect +_ble_syntax_context_proc[_ble_ctx_RDRD]=ble/syntax:bash/ctx-redirect +_ble_syntax_context_proc[_ble_ctx_RDRD2]=ble/syntax:bash/ctx-redirect +_ble_syntax_context_proc[_ble_ctx_RDRS]=ble/syntax:bash/ctx-redirect +_ble_syntax_context_end[_ble_ctx_RDRF]=ble/syntax:bash/ctx-redirect/check-word-end +_ble_syntax_context_end[_ble_ctx_RDRD]=ble/syntax:bash/ctx-redirect/check-word-end +_ble_syntax_context_end[_ble_ctx_RDRD2]=ble/syntax:bash/ctx-redirect/check-word-end +_ble_syntax_context_end[_ble_ctx_RDRS]=ble/syntax:bash/ctx-redirect/check-word-end +function ble/syntax:bash/ctx-redirect/check-word-begin { + if ((wbegin<0)); then + ble/syntax/parse/word-push "$ctx" "$i" + ble/syntax/parse/touch-updated-word "$i" #■これは不要では? + fi +} +function ble/syntax:bash/ctx-redirect/check-word-end { + ((wbegin<0)) && return 1 + ble/syntax:bash/check-word-end/is-delimiter || return 1 + ble/syntax/parse/word-pop + ble/syntax/parse/nest-pop + ble/util/assert '((!_ble_syntax_bash_command_isARGI[ctx]))' "invalid ctx=$ctx in words" + return 0 +} +function ble/syntax:bash/ctx-redirect { + if ble/syntax:bash/starts-with-delimiter-or-redirect; then + ((_ble_syntax_attr[i++]=_ble_attr_ERR)) + [[ ${tail:1} =~ ^$_ble_syntax_bash_RexSpaces ]] && + ((_ble_syntax_attr[i]=ctx,i+=${#BASH_REMATCH})) + return 0 + fi + if local i0=$i; ble/syntax:bash/check-comment; then + ((_ble_syntax_attr[i0]=_ble_attr_ERR)) + return 0 + fi + ble/syntax:bash/ctx-redirect/check-word-begin + if ble/syntax:bash/check-plain-with-escape "[^${_ble_syntax_bash_chars[_ble_ctx_ARGI]}]+"; then + return 0 + elif ble/syntax:bash/check-process-subst; then + return 0 + elif ble/syntax:bash/check-quotes; then + return 0 + elif ble/syntax:bash/check-dollar; then + return 0 + elif ble/syntax:bash/check-glob; then + return 0 + elif ble/syntax:bash/check-brace-expansion; then + return 0 + elif ble/syntax:bash/check-tilde-expansion; then + return 0 + elif ble/syntax:bash/starts-with-histchars; then + ble/syntax:bash/check-history-expansion || + ((_ble_syntax_attr[i]=ctx,i++)) + return 0 + fi + return 1 +} +_ble_syntax_bash_heredoc_EscSP='\040' +_ble_syntax_bash_heredoc_EscHT='\011' +_ble_syntax_bash_heredoc_EscLF='\012' +_ble_syntax_bash_heredoc_EscFS='\034' +function ble/syntax:bash/ctx-heredoc-word/initialize { + local ret + ble/util/s2c ' ' + ble/util/sprintf _ble_syntax_bash_heredoc_EscSP '\\%03o' "$ret" + ble/util/s2c $'\t' + ble/util/sprintf _ble_syntax_bash_heredoc_EscHT '\\%03o' "$ret" + ble/util/s2c $'\n' + ble/util/sprintf _ble_syntax_bash_heredoc_EscLF '\\%03o' "$ret" + ble/util/s2c "$_ble_term_FS" + ble/util/sprintf _ble_syntax_bash_heredoc_EscFS '\\%03o' "$ret" +} +ble/syntax:bash/ctx-heredoc-word/initialize +function ble/syntax:bash/ctx-heredoc-word/remove-quotes { + local text=$1 result= + local rex='^[^\$"'\'']+|^\$?["'\'']|^\\.?|^.' + while [[ $text && $text =~ $rex ]]; do + local rematch=$BASH_REMATCH + if [[ $rematch == \" || $rematch == \$\" ]]; then + if rex='^\$?"(([^\"]|\\.)*)(\\?$|")'; [[ $text =~ $rex ]]; then + local str=${BASH_REMATCH[1]} + local a b + b='\`' a='`'; str=${str//"$b"/"$a"} + b='\"' a='"'; str=${str//"$b"/"$a"} # WA #D1751 checked + b='\$' a='$'; str=${str//"$b"/"$a"} + b='\\' a='\'; str=${str//"$b"/"$a"} + result=$result$str + text=${text:${#BASH_REMATCH}} + continue + fi + elif [[ $rematch == \' ]]; then + if rex="^('[^']*)'?"; [[ $text =~ $rex ]]; then + builtin eval "result=\$result${BASH_REMATCH[1]}'" + text=${text:${#BASH_REMATCH}} + continue + fi + elif [[ $rematch == \$\' ]]; then + if rex='^(\$'\''([^\'\'']|\\.)*)('\''|\\?$)'; [[ $text =~ $rex ]]; then + builtin eval "result=\$result${BASH_REMATCH[1]}'" + text=${text:${#BASH_REMATCH}} + continue + fi + elif [[ $rematch == \\* ]]; then + result=$result${rematch:1} + text=${text:${#rematch}} + continue + fi + result=$result$rematch + text=${text:${#rematch}} + done + delimiter=$result$text +} +function ble/syntax:bash/ctx-heredoc-word/escape-delimiter { + local ret=$1 + if [[ $ret == *[\\\'$_ble_term_IFS$_ble_term_FS]* ]]; then + local a b fs=$_ble_term_FS + a=\\ ; b='\'$a; ret=${ret//"$a"/"$b"} + a=\' ; b='\'$a; ret=${ret//"$a"/"$b"} + a=' ' ; b=$_ble_syntax_bash_heredoc_EscSP; ret=${ret//"$a"/"$b"} + a=$'\t'; b=$_ble_syntax_bash_heredoc_EscHT; ret=${ret//"$a"/"$b"} + a=$'\n'; b=$_ble_syntax_bash_heredoc_EscLF; ret=${ret//"$a"/"$b"} + a=$fs ; b=$_ble_syntax_bash_heredoc_EscFS; ret=${ret//"$a"/"$b"} + fi + escaped=$ret +} +function ble/syntax:bash/ctx-heredoc-word/unescape-delimiter { + builtin eval "delimiter=\$'$1'" +} +_ble_syntax_context_proc[_ble_ctx_RDRH]=ble/syntax:bash/ctx-heredoc-word +_ble_syntax_context_end[_ble_ctx_RDRH]=ble/syntax:bash/ctx-heredoc-word/check-word-end +_ble_syntax_context_proc[_ble_ctx_RDRI]=ble/syntax:bash/ctx-heredoc-word +_ble_syntax_context_end[_ble_ctx_RDRI]=ble/syntax:bash/ctx-heredoc-word/check-word-end +function ble/syntax:bash/ctx-heredoc-word/check-word-end { + ((wbegin<0)) && return 1 + ble/syntax:bash/check-word-end/is-delimiter || return 1 + local octx=$ctx word=${text:wbegin:i-wbegin} + ble/syntax/parse/word-pop + ble/syntax/parse/nest-pop + local I + if ((octx==_ble_ctx_RDRI)); then I=I; else I=R; fi + local Q delimiter + if [[ $word == *[\'\"\\]* ]]; then + Q=Q; ble/syntax:bash/ctx-heredoc-word/remove-quotes "$word" + else + Q=H; delimiter=$word + fi + local escaped; ble/syntax:bash/ctx-heredoc-word/escape-delimiter "$delimiter" + nparam=$nparam$_ble_term_FS@$I$Q$escaped + return 0 +} +function ble/syntax:bash/ctx-heredoc-word { + ble/syntax:bash/ctx-redirect +} +_ble_syntax_context_proc[_ble_ctx_HERE0]=ble/syntax:bash/ctx-heredoc-content +_ble_syntax_context_proc[_ble_ctx_HERE1]=ble/syntax:bash/ctx-heredoc-content +function ble/syntax:bash/ctx-heredoc-content { + local indented= quoted= delimiter= + ble/syntax:bash/ctx-heredoc-word/unescape-delimiter "${nparam:2}" + [[ ${nparam::1} == I ]] && indented=1 + [[ ${nparam:1:1} == Q ]] && quoted=1 + local rex ht=$'\t' lf=$'\n' + if ((ctx==_ble_ctx_HERE0)); then + rex="^${indented:+$ht*}"$'([^\n]+\n?|\n)' + [[ $tail =~ $rex ]] || return 1 + local line=${BASH_REMATCH%"$lf"} + local rematch1=${BASH_REMATCH[1]} + if [[ ${rematch1%"$lf"} == "$delimiter" ]]; then + local indent + ((indent=${#BASH_REMATCH}-${#rematch1}, + _ble_syntax_attr[i]=_ble_ctx_HERE0, + _ble_syntax_attr[i+indent]=_ble_ctx_RDRH, + i+=${#line})) + ble/syntax/parse/nest-pop + return 0 + fi + fi + if [[ $quoted ]]; then + ble/util/assert '((ctx==_ble_ctx_HERE0))' + ((_ble_syntax_attr[i]=_ble_ctx_HERE0,i+=${#BASH_REMATCH})) + return 0 + else + ((ctx=_ble_ctx_HERE1)) + if rex='^(\\[\$`'$lf'])|^([^'${_ble_syntax_bash_chars[_ble_ctx_HERE1]}']|\\[^\$`'$lf'])+'$lf'?|^'$lf && [[ $tail =~ $rex ]]; then + if [[ ${BASH_REMATCH[1]} ]]; then + ((_ble_syntax_attr[i]=_ble_attr_QESC)) + else + ((_ble_syntax_attr[i]=_ble_ctx_HERE0)) + [[ $BASH_REMATCH == *"$lf" ]] && ((ctx=_ble_ctx_HERE0)) + fi + ((i+=${#BASH_REMATCH})) + return 0 + fi + if ble/syntax:bash/check-dollar; then + return 0 + elif [[ $tail == '`'* ]] && ble/syntax:bash/check-quotes; then + return 0 + elif ble/syntax:bash/starts-with-histchars; then + ble/syntax:bash/check-history-expansion || + ((_ble_syntax_attr[i]=_ble_ctx_HERE0,i++)) + return 0 + else + ((_ble_syntax_attr[i]=_ble_ctx_HERE0,i++)) + return 0 + fi + fi +} +function ble/syntax:bash/is-complete { + local iN=${#_ble_syntax_text} + ((iN>0)) && ((_ble_syntax_attr[iN-1]==_ble_attr_ERR)) && return 1 + local stat=${_ble_syntax_stat[iN]} + if [[ $stat ]]; then + ble/string#split-words stat "$stat" + local nlen=${stat[3]}; ((nlen>=0)) && return 1 + local nparam=${stat[6]}; [[ $nparam == none ]] && nparam= + local rex="$_ble_term_FS@([RI][QH][^$_ble_term_FS]*)(.*$)" + [[ $nparam =~ $rex ]] && return 1 + local ctx=${stat[0]} + ((ctx==_ble_ctx_ARGX||ctx==_ble_ctx_ARGX0||ctx==_ble_ctx_ARGVX||ctx==_ble_ctx_ARGEX|| + ctx==_ble_ctx_CMDX||ctx==_ble_ctx_CMDX0||ctx==_ble_ctx_CMDXT||ctx==_ble_ctx_CMDXE||ctx==_ble_ctx_CMDXV|| + ctx==_ble_ctx_TARGX1||ctx==_ble_ctx_TARGX2)) || return 1 + fi + local attrs ret + IFS= builtin eval 'attrs="::${_ble_syntax_attr[*]/%/::}"' # WA #D1570 checked + ble/string#count-string "$attrs" ":$_ble_attr_KEYWORD_BEGIN:"; local nbeg=$ret + ble/string#count-string "$attrs" ":$_ble_attr_KEYWORD_END:"; local nend=$ret + ((nbeg>nend)) && return 1 + return 0 +} +function ble/syntax:bash/find-end-of-array-index { + local beg=$1 end=$2 + ret= + local inest0=$beg nest0 + [[ ${_ble_syntax_nest[inest0]} ]] || return 1 + local q stat1 nlen1 inest1 r= + for ((q=inest0+1;q=limit)); do + [[ $bleopt_syntax_debug ]] && _ble_syntax_stat_shift[shift2_j+shift]=1 + ble/syntax/parse/shift.stat + ble/syntax/parse/shift.nest + ((shift2_j--)) + done +} +function ble/syntax/parse/shift.impl2/.proc1 { + if ((TE_iend0&&wbegin>end0)) && [[ ${wtype//[0-9]} ]]; then + [[ $bleopt_syntax_debug ]] && _ble_syntax_stat_shift[shift2_j+shift]=1 + ble/syntax/parse/shift.stat + ble/syntax/parse/shift.nest + ((shift2_j=wbegin)) # skip + elif ((tchild>=0)); then + ble/syntax/tree-enumerate-children ble/syntax/parse/shift.impl2/.proc1 + fi +} +function ble/syntax/parse/shift.method1 { + local i j + for ((i=i2,j=j2;i<=iN;i++,j++)); do + local shift2_j=$j + ble/syntax/parse/shift.stat + ((j>0)) && ble/syntax/parse/shift.tree + ((i=end0&&(i1+=shift), + i2=_ble_syntax_dend,i2>=end0&&(i2+=shift), + (i1<0||begiN)&&(i2=iN), + j2=i2-shift)) + if ((flagSeekStat)); then + local lookahead='stat[7]' + local -a stat + while ((i1>0)); do + if [[ ${_ble_syntax_stat[--i1]} ]]; then + ble/string#split-words stat "${_ble_syntax_stat[i1]}" + ((i1+lookahead<=beg)) && break + fi + done + fi + ble/util/assert '((0<=i1&&i1<=beg&&end<=i2&&i2<=iN))' "X2 0 <= $i1 <= $beg <= $end <= $i2 <= $iN" +} +function ble/syntax/parse/check-end { + [[ ${_ble_syntax_context_end[ctx]} ]] && "${_ble_syntax_context_end[ctx]}" +} +function ble/syntax/parse { + local text=$1 iN=${#1} + local opts=$2 + local beg=${3:-0} end=${4:-$iN} end0=${5:-0} + ((end==beg&&end0==beg&&_ble_syntax_dbeg<0)) && return 0 + local IFS=$_ble_term_IFS + local shift=$((end-end0)) + ble/util/assert \ + '((0<=beg&&beg<=end&&end<=iN&&beg<=end0))' \ + "X1 0 <= beg:$beg <= end:$end <= iN:$iN, beg:$beg <= end0:$end0 (shift=$shift text=$text)" || + ((beg=0,end=iN)) + local i1 i2 j2 + ble/syntax/parse/determine-parse-range + ble/syntax/vanishing-word/register _ble_syntax_tree 0 "$i1" "$j2" 0 "$i2" + ble/syntax/parse/shift + local ctx wbegin wtype inest tchild tprev nparam ilook + if ((i1>0)) && [[ ${_ble_syntax_stat[i1]} ]]; then + local -a stat + ble/string#split-words stat "${_ble_syntax_stat[i1]}" + local wlen=${stat[1]} nlen=${stat[3]} tclen=${stat[4]} tplen=${stat[5]} + ctx=${stat[0]} + wbegin=$((wlen<0?wlen:i1-wlen)) + wtype=${stat[2]} + inest=$((nlen<0?nlen:i1-nlen)) + tchild=$((tclen<0?tclen:i1-tclen)) + tprev=$((tplen<0?tplen:i1-tplen)) + nparam=${stat[6]}; [[ $nparam == none ]] && nparam= + ilook=$((i1+${stat[7]:-1})) + else + ctx=$_ble_ctx_UNSPECIFIED ##!< 現在の解析の文脈 + ble/syntax:"$_ble_syntax_lang"/initialize-ctx # ctx 初期化 + wbegin=-1 ##!< シェル単語内にいる時、シェル単語の開始位置 + wtype=-1 ##!< シェル単語内にいる時、シェル単語の種類 + inest=-1 ##!< 入れ子の時、親の開始位置 + tchild=-1 + tprev=-1 + nparam= + ilook=1 + fi + local -a tail_syntax_stat tail_syntax_tree tail_syntax_nest tail_syntax_attr + tail_syntax_stat=("${_ble_syntax_stat[@]:j2:iN-i2+1}") + tail_syntax_tree=("${_ble_syntax_tree[@]:j2:iN-i2}") + tail_syntax_nest=("${_ble_syntax_nest[@]:j2:iN-i2}") + tail_syntax_attr=("${_ble_syntax_attr[@]:j2:iN-i2}") + ble/array#reserve-prototype "$iN" + _ble_syntax_stat=("${_ble_syntax_stat[@]::i1}" "${_ble_array_prototype[@]:i1:iN-i1}") # 再開用データ + _ble_syntax_tree=("${_ble_syntax_tree[@]::i1}" "${_ble_array_prototype[@]:i1:iN-i1}") # 単語 + _ble_syntax_nest=("${_ble_syntax_nest[@]::i1}" "${_ble_array_prototype[@]:i1:iN-i1}") # 入れ子の親 + _ble_syntax_attr=("${_ble_syntax_attr[@]::i1}" "${_ble_array_prototype[@]:i1:iN-i1}") # 文脈・色とか + ble/syntax:"$_ble_syntax_lang"/initialize-vars + _ble_syntax_text=$text + local i sstat tail + local debug_p1 + for ((i=i1;i=i2)) && [[ ${tail_syntax_stat[i-i2]} == "$sstat" ]]; then + if ble/syntax/parse/nest-equals "$inest"; then + _ble_syntax_stat=("${_ble_syntax_stat[@]::i}" "${tail_syntax_stat[@]:i-i2}") + _ble_syntax_tree=("${_ble_syntax_tree[@]::i}" "${tail_syntax_tree[@]:i-i2}") + _ble_syntax_nest=("${_ble_syntax_nest[@]::i}" "${tail_syntax_nest[@]:i-i2}") + _ble_syntax_attr=("${_ble_syntax_attr[@]::i}" "${tail_syntax_attr[@]:i-i2}") + break + fi + fi + _ble_syntax_stat[i]=$sstat + tail=${text:i} + debug_p1=$i + "${_ble_syntax_context_proc[ctx]}" || ((_ble_syntax_attr[i]=_ble_attr_ERR,i++)) + ble/syntax/parse/check-end + done + builtin unset -v debug_p1 + ble/syntax/vanishing-word/register tail_syntax_tree "$((-i2))" "$((i2+1))" "$i" 0 "$i" + ble/syntax/urange#update _ble_syntax_attr_ "$i1" "$i" + (((i>=i2)?( + _ble_syntax_dbeg=_ble_syntax_dend=-1 + ):( + _ble_syntax_dbeg=i,_ble_syntax_dend=i2))) + if ((i>=iN)); then + ((i=iN)) + ble/syntax/parse/serialize-stat + _ble_syntax_stat[i]=$sstat + if ((inest>0)); then + ((_ble_syntax_attr[iN-1]=_ble_attr_ERR)) + while ((inest>=0)); do + ((i=inest)) + ble/syntax/parse/nest-pop + ((inest>=i&&(inest=i-1))) + done + fi + fi + ble/util/assert \ + '((${#_ble_syntax_stat[@]}==iN+1))' \ + "unexpected array length #arr=${#_ble_syntax_stat[@]} (expected to be $iN), #proto=${#_ble_array_prototype[@]} should be >= $iN" +} +function ble/syntax/highlight { + local text=$1 lang=${2:-bash} cache_prefix=$3 + local -a _ble_highlight_layer_list=(plain syntax) + local -a vars=() + ble/array#push vars "${_ble_syntax_VARNAMES[@]}" + ble/array#push vars "${_ble_highlight_layer_plain_VARNAMES[@]}" + ble/array#push vars "${_ble_highlight_layer_syntax_VARNAMES[@]}" + local "${vars[@]/%/=}" # WA #D1570 checked + if [[ $cache_prefix ]] && ((${cache_prefix}_INITIALIZED++)); then + ble/util/restore-vars "$cache_prefix" "${vars[@]}" + ble/string#common-prefix "$_ble_syntax_text" "$text" + local beg=${#ret} + ble/string#common-suffix "${_ble_syntax_text:beg}" "${text:beg}" + local end=$((${#text}-${#ret})) end0=$((${#_ble_syntax_text}-${#ret})) + else + ble/syntax/initialize-vars + ble/highlight/layer:plain/initialize-vars + ble/highlight/layer:syntax/initialize-vars + _ble_syntax_lang=$lang + local beg=0 end=${#text} end0=0 + fi + ble/syntax/parse "$text" '' "$beg" "$end" "$end0" + local HIGHLIGHT_BUFF HIGHLIGHT_UMIN HIGHLIGHT_UMAX + ble/highlight/layer/update "$text" '' "$beg" "$end" "$end0" + IFS= builtin eval "ret=\"\${$HIGHLIGHT_BUFF[*]}\"" + [[ $cache_prefix ]] && + ble/util/save-vars "$cache_prefix" "${vars[@]}" + return 0 +} +function ble/syntax/completion-context/.add { + local source=$1 + local comp1=$2 + ble/util/assert '[[ $source && comp1 -ge 0 ]]' + sources[${#sources[*]}]="$source $comp1" +} +function ble/syntax/completion-context/.check/parameter-expansion { + local rex_paramx='^(\$(\{[!#]?)?)([_a-zA-Z][_a-zA-Z0-9]*)?$' + if [[ ${text:istat:index-istat} =~ $rex_paramx ]]; then + local rematch1=${BASH_REMATCH[1]} + local source=variable + if [[ $rematch1 == '${'* ]]; then + source=variable:b # suffix } + elif ((ctx==_ble_ctx_BRACE1||ctx==_ble_ctx_BRACE2)); then + source=variable:n # no suffix + fi + ble/syntax/completion-context/.add "$source" "$((istat+${#rematch1}))" + fi +} +_ble_syntax_bash_complete_check_prefix[_ble_ctx_CMDI]=inside-command +function ble/syntax/completion-context/.check-prefix/ctx:inside-command { + if ((wlen>=0)); then + ble/syntax/completion-context/.add command "$wbeg" + if [[ ${text:wbeg:index-wbeg} =~ $rex_param ]]; then + ble/syntax/completion-context/.add variable:= "$wbeg" + fi + fi + ble/syntax/completion-context/.check/parameter-expansion +} +_ble_syntax_bash_complete_check_prefix[_ble_ctx_ARGI]='inside-argument argument' +_ble_syntax_bash_complete_check_prefix[_ble_ctx_ARGQ]='inside-argument argument' +_ble_syntax_bash_complete_check_prefix[_ble_ctx_FARGI1]='inside-argument variable:w' +_ble_syntax_bash_complete_check_prefix[_ble_ctx_FARGI3]='inside-argument argument' +_ble_syntax_bash_complete_check_prefix[_ble_ctx_FARGQ3]='inside-argument argument' +_ble_syntax_bash_complete_check_prefix[_ble_ctx_CARGI1]='inside-argument argument' +_ble_syntax_bash_complete_check_prefix[_ble_ctx_CARGQ1]='inside-argument argument' +_ble_syntax_bash_complete_check_prefix[_ble_ctx_CPATI]='inside-argument argument' +_ble_syntax_bash_complete_check_prefix[_ble_ctx_CPATQ]='inside-argument argument' +_ble_syntax_bash_complete_check_prefix[_ble_ctx_COARGI]='inside-argument variable command' +_ble_syntax_bash_complete_check_prefix[_ble_ctx_VALI]='inside-argument sabbrev file' +_ble_syntax_bash_complete_check_prefix[_ble_ctx_VALQ]='inside-argument sabbrev file' +_ble_syntax_bash_complete_check_prefix[_ble_ctx_CONDI]='inside-argument sabbrev file option' +_ble_syntax_bash_complete_check_prefix[_ble_ctx_CONDQ]='inside-argument sabbrev file' +_ble_syntax_bash_complete_check_prefix[_ble_ctx_ARGVI]='inside-argument sabbrev variable:=' +_ble_syntax_bash_complete_check_prefix[_ble_ctx_ARGEI]='inside-argument command:D variable:= file' +function ble/syntax/completion-context/.check-prefix/ctx:inside-argument { + if ((wlen>=0)); then + local source + for source; do + ble/syntax/completion-context/.add "$source" "$wbeg" + if [[ $source != argument ]]; then + local sub=${text:wbeg:index-wbeg} + if [[ $sub == *[=:]* ]]; then + sub=${sub##*[=:]} + ble/syntax/completion-context/.add "$source" "$((index-${#sub}))" + fi + fi + done + fi + ble/syntax/completion-context/.check/parameter-expansion +} +_ble_syntax_bash_complete_check_prefix[_ble_ctx_CMDX]=next-command +_ble_syntax_bash_complete_check_prefix[_ble_ctx_CMDX1]=next-command +_ble_syntax_bash_complete_check_prefix[_ble_ctx_CMDXT]=next-command +_ble_syntax_bash_complete_check_prefix[_ble_ctx_CMDXV]=next-command +function ble/syntax/completion-context/.check-prefix/.test-redirection { + local word=$1 + [[ $word =~ ^$_ble_syntax_bash_RexRedirect$ ]] || return 1 + ((ctx==_ble_ctx_CMDXC||ctx==_ble_ctx_CMDXD||ctx==_ble_ctx_CMDXD0||ctx==_ble_ctx_FARGX3)) && return 0 + local rematch3=${BASH_REMATCH[3]} + case $rematch3 in + ('>&') + ble/syntax/completion-context/.add fd "$index" + ble/syntax/completion-context/.add file:no-fd "$index" ;; + (*'&') + ble/syntax/completion-context/.add fd "$index" ;; + ('<<'|'<<-') + ble/syntax/completion-context/.add wordlist:EOF:END:HERE "$index" ;; + ('<<<'|*) + ble/syntax/completion-context/.add file "$index" ;; + esac + return 0 +} +function ble/syntax/completion-context/.check-prefix/ctx:next-command { + local word=${text:istat:index-istat} + if ble/syntax:bash/simple-word/is-simple-or-open-simple "$word"; then + ble/syntax/completion-context/.add command "$istat" + if local rex='^[_a-zA-Z][_a-zA-Z0-9]*(\+?=)?$' && [[ $word =~ $rex ]]; then + if [[ $word == *= ]]; then + if ((_ble_bash>=30100)) || [[ $word != *+= ]]; then + ble/syntax/completion-context/.add argument "$index" + fi + else + ble/syntax/completion-context/.add variable:= "$istat" + fi + fi + elif ble/syntax/completion-context/.check-prefix/.test-redirection; then + true + elif [[ $word =~ ^$_ble_syntax_bash_RexSpaces$ ]]; then + shopt -q no_empty_cmd_completion || + ble/syntax/completion-context/.add command "$index" + fi + ble/syntax/completion-context/.check/parameter-expansion +} +_ble_syntax_bash_complete_check_prefix[_ble_ctx_ARGX]=next-argument +_ble_syntax_bash_complete_check_prefix[_ble_ctx_CARGX1]=next-argument +_ble_syntax_bash_complete_check_prefix[_ble_ctx_CPATX]=next-argument +_ble_syntax_bash_complete_check_prefix[_ble_ctx_FARGX3]=next-argument +_ble_syntax_bash_complete_check_prefix[_ble_ctx_COARGX]=next-argument +_ble_syntax_bash_complete_check_prefix[_ble_ctx_ARGVX]=next-argument +_ble_syntax_bash_complete_check_prefix[_ble_ctx_ARGEX]=next-argument +_ble_syntax_bash_complete_check_prefix[_ble_ctx_VALX]=next-argument +_ble_syntax_bash_complete_check_prefix[_ble_ctx_CONDX]=next-argument +_ble_syntax_bash_complete_check_prefix[_ble_ctx_RDRS]=next-argument +function ble/syntax/completion-context/.check-prefix/ctx:next-argument { + local source + if ((ctx==_ble_ctx_ARGX||ctx==_ble_ctx_CARGX1||ctx==_ble_ctx_FARGX3)); then + source=(argument) + elif ((ctx==_ble_ctx_COARGX)); then + source=(command variable) + elif ((ctx==_ble_ctx_ARGVX)); then + source=(sabbrev variable:= option) + elif ((ctx==_ble_ctx_ARGEX)); then + source=(command:D variable:= file) + elif ((ctx==_ble_ctx_CONDX)); then + source=(sabbrev file option) + else + source=(sabbrev file) + fi + local word=${text:istat:index-istat} + if ble/syntax:bash/simple-word/is-simple-or-open-simple "$word"; then + local src + for src in "${source[@]}"; do + ble/syntax/completion-context/.add "$src" "$istat" + done + if [[ ${source[0]} != argument ]]; then + local rex="^([^='\"\$\\{}]|\\.)*=" + if [[ $word =~ $rex ]]; then + word=${word:${#BASH_REMATCH}} + ble/syntax/completion-context/.add rhs "$((index-${#word}))" + fi + fi + elif ble/syntax/completion-context/.check-prefix/.test-redirection "$word"; then + true + elif [[ $word =~ ^$_ble_syntax_bash_RexSpaces$ ]]; then + local src + for src in "${source[@]}"; do + ble/syntax/completion-context/.add "$src" "$index" + done + fi + ble/syntax/completion-context/.check/parameter-expansion +} +_ble_syntax_bash_complete_check_prefix[_ble_ctx_CMDXC]=next-compound +function ble/syntax/completion-context/.check-prefix/ctx:next-compound { + local rex word=${text:istat:index-istat} + if [[ ${text:istat:index-istat} =~ $rex_param ]]; then + ble/syntax/completion-context/.add wordlist:-r:'for:select:case:if:while:until' "$istat" + elif rex='^[[({]+$'; [[ $word =~ $rex ]]; then + ble/syntax/completion-context/.add wordlist:-r:'(:{:((:[[' "$istat" + fi +} +_ble_syntax_bash_complete_check_prefix[_ble_ctx_FARGX1]="next-identifier variable:w" # _ble_ctx_FARGX1 → (( でなければ 変数名 +_ble_syntax_bash_complete_check_prefix[_ble_ctx_SARGX1]="next-identifier variable:w" +function ble/syntax/completion-context/.check-prefix/ctx:next-identifier { + local source=$1 word=${text:istat:index-istat} + if [[ $word =~ $rex_param ]]; then + ble/syntax/completion-context/.add "$source" "$istat" + elif [[ $word =~ ^$_ble_syntax_bash_RexSpaces$ ]]; then + ble/syntax/completion-context/.add "$source" "$index" + else + ble/syntax/completion-context/.add none "$istat" + fi +} +_ble_syntax_bash_complete_check_prefix[_ble_ctx_ARGX0]="next-word sabbrev" +_ble_syntax_bash_complete_check_prefix[_ble_ctx_CMDX0]="next-word sabbrev" +_ble_syntax_bash_complete_check_prefix[_ble_ctx_CPATX0]="next-word sabbrev" +_ble_syntax_bash_complete_check_prefix[_ble_ctx_CMDXD0]="next-word wordlist:-rs:';:{:do'" +_ble_syntax_bash_complete_check_prefix[_ble_ctx_CMDXD]="next-word wordlist:-rs:'{:do'" +_ble_syntax_bash_complete_check_prefix[_ble_ctx_CMDXE]="next-word wordlist:-rs:'}:fi:done:esac:then:elif:else:do'" +_ble_syntax_bash_complete_check_prefix[_ble_ctx_CARGX2]="next-word wordlist:-rs:'in'" +_ble_syntax_bash_complete_check_prefix[_ble_ctx_CARGI2]="next-word wordlist:-rs:'in'" +_ble_syntax_bash_complete_check_prefix[_ble_ctx_FARGX2]="next-word wordlist:-rs:'in:do'" +_ble_syntax_bash_complete_check_prefix[_ble_ctx_FARGI2]="next-word wordlist:-rs:'in:do'" +function ble/syntax/completion-context/.check-prefix/ctx:next-word { + local source=$1 word=${text:istat:index-istat} rex=$'^[^ \t]*$' + if [[ $word =~ ^$_ble_syntax_bash_RexSpaces$ ]]; then + ble/syntax/completion-context/.add "$source" "$index" + else + ble/syntax/completion-context/.add "$source" "$istat" + fi +} +_ble_syntax_bash_complete_check_prefix[_ble_ctx_TARGX1]=time-argument +_ble_syntax_bash_complete_check_prefix[_ble_ctx_TARGI1]=time-argument +_ble_syntax_bash_complete_check_prefix[_ble_ctx_TARGX2]=time-argument +_ble_syntax_bash_complete_check_prefix[_ble_ctx_TARGI2]=time-argument +function ble/syntax/completion-context/.check-prefix/ctx:time-argument { + ble/syntax/completion-context/.check/parameter-expansion + ble/syntax/completion-context/.add command "$istat" + if ((ctx==_ble_ctx_TARGX1)); then + local rex='^-p?$' words='-p' + ((_ble_bash>=50100)) && + rex='^-[-p]?$' words='-p':'--' + [[ ${text:istat:index-istat} =~ $rex ]] && + ble/syntax/completion-context/.add wordlist:--:"$words" "$istat" + elif ((ctx==_ble_ctx_TARGX2)); then + local rex='^--?$' + [[ ${text:istat:index-istat} =~ $rex ]] && + ble/syntax/completion-context/.add wordlist:--:'--' "$istat" + fi +} +_ble_syntax_bash_complete_check_prefix[_ble_ctx_QUOT]=quote +function ble/syntax/completion-context/.check-prefix/ctx:quote { + ble/syntax/completion-context/.check/parameter-expansion + ble/syntax/completion-context/.check-prefix/ctx:quote/.check-container-word +} +function ble/syntax/completion-context/.check-prefix/ctx:quote/.check-container-word { + local nlen=${stat[3]}; ((nlen>=0)) || return 1 + local inest=$((nlen<0?nlen:istat-nlen)) + local nest; ble/string#split-words nest "${_ble_syntax_nest[inest]}" + [[ ${nest[0]} ]] || return 1 + local wlen2=${nest[1]}; ((wlen2>=0)) || return 1 + local wbeg2=$((wlen2<0?wlen2:inest-wlen2)) + if ble/syntax:bash/simple-word/is-simple-or-open-simple "${text:wbeg2:index-wbeg2}"; then + local wt=${nest[2]} + [[ ${_ble_syntax_bash_command_EndWtype[wt]} ]] && + wt=${_ble_syntax_bash_command_EndWtype[wt]} + if ((wt==_ble_ctx_CMDI)); then + ble/syntax/completion-context/.add command "$wbeg2" + elif ((wt==_ble_ctx_ARGI||wt==_ble_ctx_ARGVI||wt==_ble_ctx_ARGEI||wt==_ble_ctx_FARGI2||wt==_ble_ctx_CARGI2)); then + ble/syntax/completion-context/.add argument "$wbeg2" + elif ((wt==_ble_ctx_CPATI)); then # case pattern の内部 + return 0 + fi + fi +} +_ble_syntax_bash_complete_check_prefix[_ble_ctx_RDRF]=redirection +_ble_syntax_bash_complete_check_prefix[_ble_ctx_RDRD2]=redirection +_ble_syntax_bash_complete_check_prefix[_ble_ctx_RDRD]=redirection +function ble/syntax/completion-context/.check-prefix/ctx:redirection { + ble/syntax/completion-context/.check/parameter-expansion + local p=$((wlen>=0?wbeg:istat)) + if ble/syntax:bash/simple-word/is-simple-or-open-simple "${text:p:index-p}"; then + if ((ctx==_ble_ctx_RDRF)); then + ble/syntax/completion-context/.add file "$p" + elif ((ctx==_ble_ctx_RDRD)); then + ble/syntax/completion-context/.add fd "$p" + elif ((ctx==_ble_ctx_RDRD2)); then + ble/syntax/completion-context/.add fd "$p" + ble/syntax/completion-context/.add file:no-fd "$p" + fi + fi +} +_ble_syntax_bash_complete_check_prefix[_ble_ctx_RDRH]=here +_ble_syntax_bash_complete_check_prefix[_ble_ctx_RDRI]=here +function ble/syntax/completion-context/.check-prefix/ctx:here { + local p=$((wlen>=0?wbeg:istat)) + ble/syntax/completion-context/.add wordlist:EOF:END:HERE "$p" +} +_ble_syntax_bash_complete_check_prefix[_ble_ctx_VRHS]=rhs +_ble_syntax_bash_complete_check_prefix[_ble_ctx_ARGVR]=rhs +_ble_syntax_bash_complete_check_prefix[_ble_ctx_ARGER]=rhs +_ble_syntax_bash_complete_check_prefix[_ble_ctx_VALR]=rhs +function ble/syntax/completion-context/.check-prefix/ctx:rhs { + ble/syntax/completion-context/.check/parameter-expansion + if ((wlen>=0)); then + local p=$wbeg + local rex='^[_a-zA-Z0-9]+(\+?=|\[)' + ((ctx==_ble_ctx_VALR)) && rex='^(\[)' + if [[ ${text:p:index-p} =~ $rex ]]; then + if [[ ${BASH_REMATCH[1]} == '[' ]]; then + local p1=$((wbeg+${#BASH_REMATCH}-1)) + if local ret; ble/syntax:bash/find-end-of-array-index "$p1" "$index"; then + local p2=$ret + case ${_ble_syntax_text:p2:index-p2} in + (']='*) ((p=p2+2)) ;; + (']+='*) ((p=p2+3)) ;; + (']+') + ble/syntax/completion-context/.add wordlist:-rW:'+=' "$((p2+1))" + p= ;; + esac + fi + else + ((p+=${#BASH_REMATCH})) + fi + fi + else + local p=$istat + fi + if [[ $p ]] && ble/syntax:bash/simple-word/is-simple-or-open-simple "${text:p:index-p}"; then + ble/syntax/completion-context/.add rhs "$p" + fi +} +_ble_syntax_bash_complete_check_prefix[_ble_ctx_PARAM]=param +function ble/syntax/completion-context/.check-prefix/ctx:param { + local tail=${text:istat:index-istat} + if [[ $tail == : ]]; then + return 0 + elif [[ $tail == '}'* ]]; then + local nlen=${stat[3]} + local inest=$((nlen<0?nlen:istat-nlen)) + ((0<=inest&&inest=0)) || return 1 + local inest=$((istat-nlen)) + ble/syntax/parse/nest-type # ([in] inest; [out] ntype) + if [[ $ntype == [ad]'[' ]]; then + if [[ $tail == ']' ]]; then + ble/syntax/completion-context/.add wordlist:-rW:'=' "$((istat+1))" + elif ((_ble_bash>=30100)) && [[ $tail == ']+' ]]; then + ble/syntax/completion-context/.add wordlist:-rW:'+=' "$((istat+1))" + elif [[ $tail == ']=' || _ble_bash -ge 30100 && $tail == ']+=' ]]; then + ble/syntax/completion-context/.add rhs "$index" + fi + fi + fi +} +_ble_syntax_bash_complete_check_prefix[_ble_ctx_BRACE1]=brace +_ble_syntax_bash_complete_check_prefix[_ble_ctx_BRACE2]=brace +function ble/syntax/completion-context/.check-prefix/ctx:brace { + local ctx1=$ctx istat1=$istat nlen1=${stat[3]} + ((nlen1>=0)) || return 1 + local inest1=$((istat1-nlen1)) + while :; do + local nest=${_ble_syntax_nest[inest1]} + [[ $nest ]] || return 1 + ble/string#split-words nest "$nest" + ctx1=${nest[0]} + ((ctx1==_ble_ctx_BRACE1||ctx1==_ble_ctx_BRACE2)) || break + inest1=${nest[3]} + ((inest1>=0)) || return 1 + done + for ((istat1=inest1;1;istat1--)); do + ((istat1>=0)) || return 1 + [[ ${_ble_syntax_stat[istat1]} ]] && break + done + local stat1 + ble/string#split-words stat1 "${_ble_syntax_stat[istat1]}" + local wlen=${stat1[1]} + local wbeg=$((wlen>=0?istat1-wlen:istat1)) + ble/syntax/completion-context/.check/parameter-expansion + ble/syntax/completion-context/.add argument "$wbeg" +} +function ble/syntax/completion-context/.search-last-istat { + local index=$1 istat + for ((istat=index;istat>=0;istat--)); do + if [[ ${_ble_syntax_stat[istat]} ]]; then + ret=$istat + return 0 + fi + done + ret= + return 1 +} +function ble/syntax/completion-context/.check-prefix { + local rex_param='^[_a-zA-Z][_a-zA-Z0-9]*$' + local from=${1:-$((index-1))} + local ret + ble/syntax/completion-context/.search-last-istat "$from" || return 1 + local istat=$ret stat + ble/string#split-words stat "${_ble_syntax_stat[istat]}" + [[ ${stat[0]} ]] || return 1 + local ctx=${stat[0]} wlen=${stat[1]} + local wbeg=$((wlen<0?wlen:istat-wlen)) + local name=${_ble_syntax_bash_complete_check_prefix[ctx]} + if [[ $name ]]; then + builtin eval "ble/syntax/completion-context/.check-prefix/ctx:$name" + fi +} +function ble/syntax/completion-context/.check-here { + ((${#sources[*]})) && return 0 + local -a stat + ble/string#split-words stat "${_ble_syntax_stat[index]}" + if [[ ${stat[0]} ]]; then + local ctx=${stat[0]} + if ((ctx==_ble_ctx_CMDX||ctx==_ble_ctx_CMDXV||ctx==_ble_ctx_CMDX1||ctx==_ble_ctx_CMDXT)); then + if ! shopt -q no_empty_cmd_completion; then + ble/syntax/completion-context/.add command "$index" + ble/syntax/completion-context/.add variable:= "$index" + fi + elif ((ctx==_ble_ctx_CMDXC)); then + ble/syntax/completion-context/.add wordlist:-rs:'(:{:((:[[:for:select:case:if:while:until' "$index" + elif ((ctx==_ble_ctx_CMDXE)); then + ble/syntax/completion-context/.add wordlist:-rs:'}:fi:done:esac:then:elif:else:do' "$index" + elif ((ctx==_ble_ctx_CMDXD0)); then + ble/syntax/completion-context/.add wordlist:-rs:';:{:do' "$index" + elif ((ctx==_ble_ctx_CMDXD)); then + ble/syntax/completion-context/.add wordlist:-rs:'{:do' "$index" + elif ((ctx==_ble_ctx_ARGX0||ctx==_ble_ctx_CPATX0||ctx==_ble_ctx_CMDX0)); then + ble/syntax/completion-context/.add sabbrev "$index" + elif ((ctx==_ble_ctx_ARGX||ctx==_ble_ctx_CARGX1||ctx==_ble_ctx_FARGX3)); then + ble/syntax/completion-context/.add argument "$index" + elif ((ctx==_ble_ctx_FARGX1||ctx==_ble_ctx_SARGX1)); then + ble/syntax/completion-context/.add variable:w "$index" + ble/syntax/completion-context/.add sabbrev "$index" + elif ((ctx==_ble_ctx_ARGVX)); then + ble/syntax/completion-context/.add variable:= "$index" + ble/syntax/completion-context/.add option "$index" + ble/syntax/completion-context/.add sabbrev "$index" + elif ((ctx==_ble_ctx_ARGEX)); then + ble/syntax/completion-context/.add variable:= "$index" + ble/syntax/completion-context/.add command:D "$index" + ble/syntax/completion-context/.add file "$index" + elif ((ctx==_ble_ctx_CARGX2)); then + ble/syntax/completion-context/.add wordlist:-rs:'in' "$index" + elif ((ctx==_ble_ctx_FARGX2)); then + ble/syntax/completion-context/.add wordlist:-rs:'in:do' "$index" + elif ((ctx==_ble_ctx_TARGX1)); then + local words='-p' + ((_ble_bash>=50100)) && words='-p':'--' + ble/syntax/completion-context/.add command "$index" + ble/syntax/completion-context/.add wordlist:--:"$words" "$index" + elif ((ctx==_ble_ctx_TARGX2)); then + ble/syntax/completion-context/.add command "$index" + ble/syntax/completion-context/.add wordlist:--:'--' "$index" + elif ((ctx==_ble_ctx_COARGX)); then + ble/syntax/completion-context/.add variable:w "$index" + ble/syntax/completion-context/.add command "$index" + elif ((ctx==_ble_ctx_CONDX)); then + ble/syntax/completion-context/.add sabbrev "$index" + ble/syntax/completion-context/.add option "$index" + ble/syntax/completion-context/.add file "$index" + elif ((ctx==_ble_ctx_CPATI||ctx==_ble_ctx_RDRF||ctx==_ble_ctx_RDRS)); then + ble/syntax/completion-context/.add file "$index" + elif ((ctx==_ble_ctx_RDRD)); then + ble/syntax/completion-context/.add fd "$index" + elif ((ctx==_ble_ctx_RDRD2)); then + ble/syntax/completion-context/.add fd "$index" + ble/syntax/completion-context/.add file:no-fd "$index" + elif ((ctx==_ble_ctx_RDRH||ctx==_ble_ctx_RDRI)); then + ble/syntax/completion-context/.add wordlist:EOF:END:HERE "$index" + elif ((ctx==_ble_ctx_VRHS||ctx==_ble_ctx_ARGVR||ctx==_ble_ctx_ARGER||ctx==_ble_ctx_VALR)); then + ble/syntax/completion-context/.add rhs "$index" + fi + fi +} +function ble/syntax/completion-context/generate { + local text=$1 index=$2 + sources=() + ((index<0&&(index=0))) + ble/syntax/completion-context/.check-prefix + ble/syntax/completion-context/.check-here +} +function ble/syntax:bash/extract-command/.register-word { + local wtxt=${_ble_syntax_text:wbegin:wlen} + if [[ ! $comp_cword ]] && ((wbegin<=EC_pos)); then + if ((EC_pos<=wbegin+wlen)); then + comp_cword=${#comp_words[@]} + comp_point=$((${#comp_line}+wbegin+wlen-EC_pos)) + comp_line="$wtxt$comp_line" + ble/array#push comp_words "$wtxt" + else + comp_cword=${#comp_words[@]} + comp_point=${#comp_line} + comp_line="$wtxt $comp_line" + ble/array#push comp_words "" "$wtxt" + fi + else + comp_line="$wtxt$comp_line" + ble/array#push comp_words "$wtxt" + fi + [[ $EC_opts == *:treeinfo:* ]] && + ble/array#push tree_words "$TE_i:$TE_nofs" +} +function ble/syntax:bash/extract-command/.construct-proc { + if [[ $wtype =~ ^[0-9]+$ ]]; then + if ((wtype==_ble_ctx_CMDI||wtype==_ble_ctx_CMDX0)); then + if ((EC_posnofs0))' "Broken AST: tree-node info missing at $((i0-1))[$nofs0]" || return 1 + local tplen=${node[nofs0+3]} + ((tplen>=0)) || return 1 + local i=$((i0-tplen)) nofs=0 + ret=$i:$nofs + if [[ $opts == *:wvars:* ]]; then + ble/string#split-words node "${_ble_syntax_tree[i-1]}" + ble/util/assert '((${#node[@]}>nofs))' "Broken AST: tree-node info missing at $((i-1))[$nofs]" || return 1 + wtype=${node[nofs]} + wlen=${node[nofs+1]} + ((wbeg=i-wlen,wend=i)) + wattr=${node[nofs+4]} + fi + return 0 +} +function ble/syntax/tree#next-sibling { + local i0=${1%%:*} nofs0=0 opts=:$2: + [[ $1 == *:* ]] && nofs0=${1#*:} + ((nofs0)) && return 1 + local iN=${#_ble_syntax_text} i nofs node + for ((i=i0+1;i<=iN;i++)); do + [[ ${_ble_syntax_tree[i-1]} ]] || continue + ble/string#split-words node "${_ble_syntax_tree[i-1]}" + nofs=${#node[@]} + while (((nofs-=_ble_syntax_TREE_WIDTH)>=0)); do + if ((i0==i-node[nofs+2])); then + return 1 + elif ((i0==i-node[nofs+3])); then + ret=$i:$nofs + if [[ $opts == *:wvars:* ]]; then + wtype=${node[nofs]} + wlen=${node[nofs+1]} + ((wbeg=i-wlen,wend=i)) + wattr=${node[nofs+4]} + fi + return 0 + fi + done + done + return 1 +} +function ble/syntax:bash/extract-command-by-noderef { + local i=${1%%:*} nofs=0 opts=:$2: + [[ $1 == *:* ]] && nofs=${1#*:} + comp_words=() + tree_words=() + comp_line= + comp_cword=0 + comp_point=0 + local ExprIsArgument='wtype==_ble_ctx_ARGI||wtype==_ble_ctx_ARGVI||wtype==_ble_ctx_ARGEI||wtype==_ble_attr_VAR' + local ret node wtype wlen wbeg wend wattr + ble/string#split-words node "${_ble_syntax_tree[i-1]}" + wtype=${node[nofs]} wlen=${node[nofs+1]} + [[ ! ${wtype//[0-9]} ]] && ((wtype==_ble_ctx_CMDI||ExprIsArgument)) || return 1 + ble/array#push comp_words "${_ble_syntax_text:i-wlen:wlen}" + [[ $opts == *:treeinfo:* ]] && + ble/array#push tree_words "$i:$nofs" + ret=$i:$nofs + while + { [[ ${wtype//[0-9]} ]] || ((wtype!=_ble_ctx_CMDI)); } && + ble/syntax/tree#previous-sibling "$ret" wvars + do + [[ ! ${wtype//[0-9]} ]] || continue + if ((wtype==_ble_ctx_CMDI||ExprIsArgument)); then + ble/array#push comp_words "${_ble_syntax_text:wbeg:wlen}" + [[ $opts == *:treeinfo:* ]] && + ble/array#push tree_words "$ret" + fi + done + ble/array#reverse comp_words + [[ $opts == *:treeinfo:* ]] && + ble/array#reverse tree_words + ((comp_cword=${#comp_words[@]}-1)) + ret=$i:$nofs + while ble/syntax/tree#next-sibling "$ret" wvars; do + [[ ! ${wtype//[0-9]} ]] || continue + ((wtype==_ble_ctx_CMDI)) && break + if ((ExprIsArgument)); then + ble/array#push comp_words "${_ble_syntax_text:wbeg:wlen}" + [[ $opts == *:treeinfo:* ]] && + ble/array#push tree_words "$ret" + fi + done + local IFS=$_ble_term_IFS + comp_line="${comp_words[*]}" + local tmp="${comp_words[*]::comp_cword+1}" + comp_point=${#tmp} +} +_ble_syntax_attr2iface=() +function ble/syntax/attr2iface/color_defface.onload { + function ble/syntax/attr2iface/.define { + ((_ble_syntax_attr2iface[$1]=_ble_faces__$2)) + } + ble/syntax/attr2iface/.define _ble_ctx_ARGX syntax_default + ble/syntax/attr2iface/.define _ble_ctx_ARGX0 syntax_default + ble/syntax/attr2iface/.define _ble_ctx_ARGI syntax_default + ble/syntax/attr2iface/.define _ble_ctx_ARGQ syntax_default + ble/syntax/attr2iface/.define _ble_ctx_ARGVX syntax_default + ble/syntax/attr2iface/.define _ble_ctx_ARGVI syntax_default + ble/syntax/attr2iface/.define _ble_ctx_ARGVR syntax_default + ble/syntax/attr2iface/.define _ble_ctx_ARGEX syntax_default + ble/syntax/attr2iface/.define _ble_ctx_ARGEI syntax_default + ble/syntax/attr2iface/.define _ble_ctx_ARGER syntax_default + ble/syntax/attr2iface/.define _ble_ctx_CMDX syntax_default + ble/syntax/attr2iface/.define _ble_ctx_CMDX0 syntax_default + ble/syntax/attr2iface/.define _ble_ctx_CMDX1 syntax_default + ble/syntax/attr2iface/.define _ble_ctx_CMDXT syntax_default + ble/syntax/attr2iface/.define _ble_ctx_CMDXC syntax_default + ble/syntax/attr2iface/.define _ble_ctx_CMDXE syntax_default + ble/syntax/attr2iface/.define _ble_ctx_CMDXD syntax_default + ble/syntax/attr2iface/.define _ble_ctx_CMDXD0 syntax_default + ble/syntax/attr2iface/.define _ble_ctx_CMDXV syntax_default + ble/syntax/attr2iface/.define _ble_ctx_CMDI syntax_command + ble/syntax/attr2iface/.define _ble_ctx_VRHS syntax_default + ble/syntax/attr2iface/.define _ble_ctx_QUOT syntax_quoted + ble/syntax/attr2iface/.define _ble_ctx_EXPR syntax_expr + ble/syntax/attr2iface/.define _ble_attr_ERR syntax_error + ble/syntax/attr2iface/.define _ble_attr_VAR syntax_varname + ble/syntax/attr2iface/.define _ble_attr_QDEL syntax_quotation + ble/syntax/attr2iface/.define _ble_attr_QESC syntax_escape + ble/syntax/attr2iface/.define _ble_attr_DEF syntax_default + ble/syntax/attr2iface/.define _ble_attr_DEL syntax_delimiter + ble/syntax/attr2iface/.define _ble_ctx_PARAM syntax_param_expansion + ble/syntax/attr2iface/.define _ble_ctx_PWORD syntax_default + ble/syntax/attr2iface/.define _ble_ctx_PWORDE syntax_error + ble/syntax/attr2iface/.define _ble_ctx_PWORDR syntax_default + ble/syntax/attr2iface/.define _ble_attr_HISTX syntax_history_expansion + ble/syntax/attr2iface/.define _ble_attr_FUNCDEF syntax_function_name + ble/syntax/attr2iface/.define _ble_ctx_VALX syntax_default + ble/syntax/attr2iface/.define _ble_ctx_VALI syntax_default + ble/syntax/attr2iface/.define _ble_ctx_VALR syntax_default + ble/syntax/attr2iface/.define _ble_ctx_VALQ syntax_default + ble/syntax/attr2iface/.define _ble_ctx_CONDX syntax_default + ble/syntax/attr2iface/.define _ble_ctx_CONDI syntax_default + ble/syntax/attr2iface/.define _ble_ctx_CONDQ syntax_default + ble/syntax/attr2iface/.define _ble_attr_COMMENT syntax_comment + ble/syntax/attr2iface/.define _ble_ctx_CASE syntax_default + ble/syntax/attr2iface/.define _ble_ctx_PATN syntax_default + ble/syntax/attr2iface/.define _ble_attr_GLOB syntax_glob + ble/syntax/attr2iface/.define _ble_ctx_BRAX syntax_default + ble/syntax/attr2iface/.define _ble_attr_BRACE syntax_brace + ble/syntax/attr2iface/.define _ble_ctx_BRACE1 syntax_default + ble/syntax/attr2iface/.define _ble_ctx_BRACE2 syntax_default + ble/syntax/attr2iface/.define _ble_attr_TILDE syntax_tilde + ble/syntax/attr2iface/.define _ble_ctx_SARGX1 syntax_default + ble/syntax/attr2iface/.define _ble_ctx_FARGX1 syntax_default + ble/syntax/attr2iface/.define _ble_ctx_FARGX2 syntax_default + ble/syntax/attr2iface/.define _ble_ctx_FARGX3 syntax_default + ble/syntax/attr2iface/.define _ble_ctx_FARGI1 syntax_varname + ble/syntax/attr2iface/.define _ble_ctx_FARGI2 command_keyword + ble/syntax/attr2iface/.define _ble_ctx_FARGI3 syntax_default + ble/syntax/attr2iface/.define _ble_ctx_FARGQ3 syntax_default + ble/syntax/attr2iface/.define _ble_ctx_CARGX1 syntax_default + ble/syntax/attr2iface/.define _ble_ctx_CARGX2 syntax_default + ble/syntax/attr2iface/.define _ble_ctx_CARGI1 syntax_default + ble/syntax/attr2iface/.define _ble_ctx_CARGQ1 syntax_default + ble/syntax/attr2iface/.define _ble_ctx_CARGI2 command_keyword + ble/syntax/attr2iface/.define _ble_ctx_CPATX syntax_default + ble/syntax/attr2iface/.define _ble_ctx_CPATI syntax_default + ble/syntax/attr2iface/.define _ble_ctx_CPATQ syntax_default + ble/syntax/attr2iface/.define _ble_ctx_CPATX0 syntax_default + ble/syntax/attr2iface/.define _ble_ctx_TARGX1 syntax_default + ble/syntax/attr2iface/.define _ble_ctx_TARGX2 syntax_default + ble/syntax/attr2iface/.define _ble_ctx_TARGI1 syntax_default + ble/syntax/attr2iface/.define _ble_ctx_TARGI2 syntax_default + ble/syntax/attr2iface/.define _ble_ctx_COARGX syntax_default + ble/syntax/attr2iface/.define _ble_ctx_COARGI syntax_command + ble/syntax/attr2iface/.define _ble_ctx_RDRF syntax_default + ble/syntax/attr2iface/.define _ble_ctx_RDRD syntax_default + ble/syntax/attr2iface/.define _ble_ctx_RDRD2 syntax_default + ble/syntax/attr2iface/.define _ble_ctx_RDRS syntax_default + ble/syntax/attr2iface/.define _ble_ctx_RDRH syntax_document_begin + ble/syntax/attr2iface/.define _ble_ctx_RDRI syntax_document_begin + ble/syntax/attr2iface/.define _ble_ctx_HERE0 syntax_document + ble/syntax/attr2iface/.define _ble_ctx_HERE1 syntax_document + ble/syntax/attr2iface/.define _ble_attr_CMD_BOLD command_builtin_dot + ble/syntax/attr2iface/.define _ble_attr_CMD_BUILTIN command_builtin + ble/syntax/attr2iface/.define _ble_attr_CMD_ALIAS command_alias + ble/syntax/attr2iface/.define _ble_attr_CMD_FUNCTION command_function + ble/syntax/attr2iface/.define _ble_attr_CMD_FILE command_file + ble/syntax/attr2iface/.define _ble_attr_CMD_JOBS command_jobs + ble/syntax/attr2iface/.define _ble_attr_CMD_DIR command_directory + ble/syntax/attr2iface/.define _ble_attr_CMD_SUFFIX command_suffix + ble/syntax/attr2iface/.define _ble_attr_CMD_SUFFIX_NEW command_suffix_new + ble/syntax/attr2iface/.define _ble_attr_KEYWORD command_keyword + ble/syntax/attr2iface/.define _ble_attr_KEYWORD_BEGIN command_keyword + ble/syntax/attr2iface/.define _ble_attr_KEYWORD_END command_keyword + ble/syntax/attr2iface/.define _ble_attr_KEYWORD_MID command_keyword + ble/syntax/attr2iface/.define _ble_attr_FILE_DIR filename_directory + ble/syntax/attr2iface/.define _ble_attr_FILE_STICKY filename_directory_sticky + ble/syntax/attr2iface/.define _ble_attr_FILE_LINK filename_link + ble/syntax/attr2iface/.define _ble_attr_FILE_ORPHAN filename_orphan + ble/syntax/attr2iface/.define _ble_attr_FILE_FILE filename_other + ble/syntax/attr2iface/.define _ble_attr_FILE_SETUID filename_setuid + ble/syntax/attr2iface/.define _ble_attr_FILE_SETGID filename_setgid + ble/syntax/attr2iface/.define _ble_attr_FILE_EXEC filename_executable + ble/syntax/attr2iface/.define _ble_attr_FILE_WARN filename_warning + ble/syntax/attr2iface/.define _ble_attr_FILE_FIFO filename_pipe + ble/syntax/attr2iface/.define _ble_attr_FILE_SOCK filename_socket + ble/syntax/attr2iface/.define _ble_attr_FILE_BLK filename_block + ble/syntax/attr2iface/.define _ble_attr_FILE_CHR filename_character + ble/syntax/attr2iface/.define _ble_attr_FILE_URL filename_url + ble/syntax/attr2iface/.define _ble_attr_VAR_UNSET varname_unset + ble/syntax/attr2iface/.define _ble_attr_VAR_EMPTY varname_empty + ble/syntax/attr2iface/.define _ble_attr_VAR_NUMBER varname_number + ble/syntax/attr2iface/.define _ble_attr_VAR_EXPR varname_expr + ble/syntax/attr2iface/.define _ble_attr_VAR_ARRAY varname_array + ble/syntax/attr2iface/.define _ble_attr_VAR_HASH varname_hash + ble/syntax/attr2iface/.define _ble_attr_VAR_READONLY varname_readonly + ble/syntax/attr2iface/.define _ble_attr_VAR_TRANSFORM varname_transform + ble/syntax/attr2iface/.define _ble_attr_VAR_EXPORT varname_export +} +blehook/eval-after-load color_defface ble/syntax/attr2iface/color_defface.onload +function ble/syntax/highlight/cmdtype1 { + type=$1 + local cmd=$2 + case $type:$cmd in + (builtin::|builtin:.) + ((type=_ble_attr_CMD_BOLD)) ;; + (builtin:*) + ((type=_ble_attr_CMD_BUILTIN)) ;; + (alias:*) + ((type=_ble_attr_CMD_ALIAS)) ;; + (function:*) + ((type=_ble_attr_CMD_FUNCTION)) ;; + (file:*) + ((type=_ble_attr_CMD_FILE)) ;; + (keyword:*) + ((type=_ble_attr_KEYWORD)) ;; + (*:%*) + ble/util/joblist.check + if jobs -- "$cmd" &>/dev/null; then + ((type=_ble_attr_CMD_JOBS)) + else + ((type=_ble_attr_ERR)) + fi ;; + (*) + if [[ -d $cmd ]] && shopt -q autocd &>/dev/null; then + ((type=_ble_attr_CMD_DIR)) + elif [[ $cmd == *.* ]] && ble/function#try ble/complete/sabbrev#match "$cmd" 's'; then + if [[ -e $cmd || -h $cmd ]]; then + ((type=_ble_attr_CMD_SUFFIX)) + else + ((type=_ble_attr_CMD_SUFFIX_NEW)) + fi + else + ((type=_ble_attr_ERR)) + fi ;; + esac +} +function ble/syntax/highlight/cmdtype/.jobs { local LC_ALL=C; jobs; } +ble/function#suppress-stderr ble/syntax/highlight/cmdtype/.jobs +function ble/syntax/highlight/cmdtype/.is-job-name { + ble/util/joblist.check + local value=$1 word=$2 + if [[ $value == '%'* ]] && jobs -- "$value" &>/dev/null; then + return 0 + fi + local quote=\'\"\\\` + if [[ ${auto_resume+set} && $word != *["$quote"]* ]]; then + if [[ $auto_resume == exact ]]; then + local jobs job ret + ble/util/assign-array jobs 'ble/syntax/highlight/cmdtype/.jobs' + for job in "${jobs[@]}"; do + ble/string#trim "${job#*' '}" + ble/string#trim "${ret#*' '}" + [[ $value == "$ret" ]] && return 0 + done + return 1 + elif [[ $auto_resume == substring ]]; then + jobs -- "%?$value" &>/dev/null; return "$?" + else + jobs -- "%$value" &>/dev/null; return "$?" + fi + fi + return 1 +} +function ble/syntax/highlight/cmdtype/.impl { + local cmd=$1 word=$2 + local cmd_type; ble/util/type cmd_type "$cmd" + ble/syntax/highlight/cmdtype1 "$cmd_type" "$cmd" + if [[ $type == "$_ble_attr_CMD_ALIAS" && $cmd != "$word" ]]; then + type=$( + builtin unalias "$cmd" + ble/util/type cmd_type "$cmd" + ble/syntax/highlight/cmdtype1 "$cmd_type" "$cmd" + printf %s "$type") + elif ble/syntax/highlight/cmdtype/.is-job-name "$cmd" "$word"; then + ((type=_ble_attr_CMD_JOBS)) + elif [[ $type == "$_ble_attr_KEYWORD" ]]; then + ble/syntax/highlight/cmdtype1 "${cmd_type[1]}" "$cmd" + fi +} +_ble_syntax_highlight_filetype_version=-1 +function ble/syntax/highlight/cmdtype { + local cmd=$1 word=$2 + if ((_ble_syntax_highlight_filetype_version!=_ble_edit_LINENO)); then + ble/gdict#clear _ble_syntax_highlight_filetype + ((_ble_syntax_highlight_filetype_version=_ble_edit_LINENO)) + fi + if local ret; ble/gdict#get _ble_syntax_highlight_filetype "$word"; then + type=$ret + return 0 + fi + ble/syntax/highlight/cmdtype/.impl "$cmd" "$word" + ble/gdict#set _ble_syntax_highlight_filetype "$word" "$type" +} +function ble/syntax/highlight/filetype { + type= + local file=$1 + if [[ ( $OSTYPE == cygwin || $OSTYPE == msys ) && $file == //* ]]; then + [[ $file == // ]] && ((type=_ble_attr_FILE_DIR)) + [[ $type ]]; return "$?" + fi + if [[ :$2: != *:follow-symlink:* && -h $file ]]; then + if [[ -e $file ]]; then + ((type=_ble_attr_FILE_LINK)) + else + ((type=_ble_attr_FILE_ORPHAN)) + fi + elif [[ -e $file ]]; then + if [[ -d $file ]]; then + if [[ -k $file ]]; then + ((type=_ble_attr_FILE_STICKY)) + elif [[ :$2: != *:follow-symlink:* && -h ${file%/} ]]; then + ((type=_ble_attr_FILE_LINK)) + else + ((type=_ble_attr_FILE_DIR)) + fi + elif [[ -f $file ]]; then + if [[ -u $file ]]; then + ((type=_ble_attr_FILE_SETUID)) + elif [[ -g $file ]]; then + ((type=_ble_attr_FILE_SETGID)) + elif [[ -x $file ]]; then + ((type=_ble_attr_FILE_EXEC)) + else + ((type=_ble_attr_FILE_FILE)) + fi + elif [[ -c $file ]]; then + ((type=_ble_attr_FILE_CHR)) + elif [[ -p $file ]]; then + ((type=_ble_attr_FILE_FIFO)) + elif [[ -S $file ]]; then + ((type=_ble_attr_FILE_SOCK)) + elif [[ -b $file ]]; then + ((type=_ble_attr_FILE_BLK)) + fi + elif local rex='^https?://[^ ^`"<>\{|}]+$'; [[ $file =~ $rex ]]; then + ((type=_ble_attr_FILE_URL)) + fi + [[ $type ]] +} +function ble/syntax/highlight/ls_colors/.clear { + _ble_syntax_highlight_lscolors=() + ble/gdict#clear _ble_syntax_highlight_lscolors_ext + ble/gdict#clear _ble_syntax_highlight_lscolors_suffix +} +function ble/syntax/highlight/ls_colors/.register-suffix { + local suffix=$1 value=$2 + if [[ $suffix == .* ]]; then + ble/gdict#set _ble_syntax_highlight_lscolors_ext "$suffix" "$value" + else + ble/gdict#set _ble_syntax_highlight_lscolors_suffix "$suffix" "$value" + fi +} +function ble/syntax/highlight/ls_colors/.has-suffix { + ((${#_ble_syntax_highlight_lscolors_ext[@]})) || + ((${#_ble_syntax_highlight_lscolors_suffix[@]})) +} +function ble/syntax/highlight/ls_colors/.match-suffix { + ret= + local filename=${1##*/} suffix= g= + local ext=$filename + while [[ $ext == *.* ]]; do + ext=${ext#*.} + if ble/gdict#get _ble_syntax_highlight_lscolors_ext ".$ext" && [[ $ret ]]; then + suffix=.$ext g=$ret + break + fi + done + local key keys + ble/gdict#keys _ble_syntax_highlight_lscolors_suffix + keys=("${ret[@]}") + for key in "${keys[@]}"; do + ((${#key}>${#suffix})) && + [[ $filename == *"$key" ]] && + ble/gdict#get _ble_syntax_highlight_lscolors_suffix "$key" && + [[ $ret ]] && + suffix=$key g=$ret + done + ret=$g + [[ $ret ]] +} +function ble/syntax/highlight/ls_colors/.parse { + ble/syntax/highlight/ls_colors/.clear + local fields field + ble/string#split fields : "$1" + for field in "${fields[@]}"; do + [[ $field == *=* ]] || continue + if [[ $field == 'ln=target' ]]; then + _ble_syntax_highlight_lscolors[_ble_attr_FILE_LINK]=target + continue + fi + local lhs=${field%%=*} + local ret; ble/color/sgrspec2g "${field#*=}"; local rhs=$ret + case $lhs in + ('di') _ble_syntax_highlight_lscolors[_ble_attr_FILE_DIR]=$rhs ;; + ('st') _ble_syntax_highlight_lscolors[_ble_attr_FILE_STICKY]=$rhs ;; + ('ln') _ble_syntax_highlight_lscolors[_ble_attr_FILE_LINK]=$rhs ;; + ('or') _ble_syntax_highlight_lscolors[_ble_attr_FILE_ORPHAN]=$rhs ;; + ('fi') _ble_syntax_highlight_lscolors[_ble_attr_FILE_FILE]=$rhs ;; + ('su') _ble_syntax_highlight_lscolors[_ble_attr_FILE_SETUID]=$rhs ;; + ('sg') _ble_syntax_highlight_lscolors[_ble_attr_FILE_SETGID]=$rhs ;; + ('ex') _ble_syntax_highlight_lscolors[_ble_attr_FILE_EXEC]=$rhs ;; + ('cd') _ble_syntax_highlight_lscolors[_ble_attr_FILE_CHR]=$rhs ;; + ('pi') _ble_syntax_highlight_lscolors[_ble_attr_FILE_FIFO]=$rhs ;; + ('so') _ble_syntax_highlight_lscolors[_ble_attr_FILE_SOCK]=$rhs ;; + ('bd') _ble_syntax_highlight_lscolors[_ble_attr_FILE_BLK]=$rhs ;; + (.*) ble/syntax/highlight/ls_colors/.register-suffix "$lhs" "$rhs" ;; + (\*?*) ble/syntax/highlight/ls_colors/.register-suffix "${lhs:1}" "$rhs" ;; + esac + done +} +function ble/syntax/highlight/ls_colors { + local file=$1 + if ((type==_ble_attr_FILE_LINK)) && [[ ${_ble_syntax_highlight_lscolors[_ble_attr_FILE_LINK]} == target ]]; then + ble/syntax/highlight/filetype "$file" follow-symlink || + type=$_ble_attr_FILE_ORPHAN + if ((type==_ble_attr_FILE_FILE)) && ble/syntax/highlight/ls_colors/.has-suffix; then + ble/util/readlink "$file" + file=$ret + fi + fi + if ((type==_ble_attr_FILE_FILE)); then + local ret= + if ble/syntax/highlight/ls_colors/.match-suffix "$file"; then + local g1=$ret + ble/color/face2g filename_ls_colors; g=$ret + ble/color/g#append g "$g1" + return 0 + fi + fi + local g1=${_ble_syntax_highlight_lscolors[type]} + if [[ $g1 ]]; then + ble/color/face2g filename_ls_colors; g=$ret + ble/color/g#append g "$g1" + return 0 + fi + return 1 +} +function ble/syntax/highlight/getg-from-filename { + local filename=$1 type= + ble/syntax/highlight/filetype "$filename" + if [[ $bleopt_filename_ls_colors ]]; then + if ble/syntax/highlight/ls_colors "$filename"; then + return 0 + fi + fi + if [[ $type ]]; then + ble/syntax/attr2g "$type" + else + g= + fi +} +function bleopt/check:filename_ls_colors { + ble/syntax/highlight/ls_colors/.parse "$value" +} +bleopt -I filename_ls_colors +_ble_syntax_progcolor_vars=( + node TE_i TE_nofs wtype wlen wbeg wend wattr) +_ble_syntax_progcolor_wattr_vars=( + wattr_buff wattr_pos wattr_g) +function ble/progcolor/load-word-data { + TE_i=${1%%:*} TE_nofs=${1#*:} + [[ $1 != *:* ]] && TE_nofs=0 + ble/string#split-words node "${_ble_syntax_tree[TE_i-1]}" + wtype=${node[TE_nofs]} + wlen=${node[TE_nofs+1]} + wattr=${node[TE_nofs+4]} + wbeg=$((TE_i-wlen)) + wend=$TE_i +} +function ble/progcolor/set-wattr { + ble/syntax/urange#update color_ "$wbeg" "$wend" + ble/syntax/wrange#update _ble_syntax_word_ "$TE_i" + node[TE_nofs+4]=$1 + local IFS=$_ble_term_IFS + _ble_syntax_tree[TE_i-1]="${node[*]}" +} +function ble/progcolor/eval-word { + local iword=${1:-progcolor_iword} opts=$2 + if [[ ${progcolor_stats[iword]+set} ]]; then + ret=${progcolor_wvals[iword]} + return "${progcolor_stats[iword]}" + fi + local wtxt=${comp_words[iword]} + local simple_flags simple_ibrace + if ! ble/syntax:bash/simple-word/reconstruct-incomplete-word "$wtxt"; then + ret= + progcolor_stats[iword]=2 + progcolor_wvals[iword]= + return 2 + fi + ble/syntax:bash/simple-word/eval "$ret" "$opts"; local ext=$? + ((ext==148)) && return 148 + if ((ext!=0)); then + ret= + progcolor_stats[iword]=1 + progcolor_wvals[iword]= + return 1 + fi + progcolor_stats[iword]=0 + progcolor_wvals[iword]=$ret + return 0 +} +function ble/progcolor/load-cmdspec-opts { + if [[ $progcolor_cmdspec_opts ]]; then + cmdspec_opts=$progcolor_cmdspec_opts + else + ble/cmdspec/opts#load "${comp_words[0]}" + progcolor_cmdspec_opts=${cmdspec_opts:-:} + fi +} +function ble/progcolor/stop-option#init { + rexrej='^--$' rexreq= stopat= + local cmdspec_opts=$1 + if [[ $cmdspec_opts ]]; then + if [[ :$cmdspec_opts: == *:no-options:* ]]; then + stopat=0 + return 1 + elif ble/opts#extract-first-optarg "$cmdspec_opts" stop-options-at && [[ $ret ]]; then + ((stopat=ret)) + return 1 + fi + local ret + if ble/opts#extract-first-optarg "$cmdspec_opts" stop-options-on && [[ $ret ]]; then + rexrej=$ret + elif [[ :$cmdspec_opts: == *:disable-double-hyphen:* ]]; then + rexrej= + fi + if ble/opts#extract-first-optarg "$cmdspec_opts" stop-options-unless && [[ $ret ]]; then + rexreq=$ret + elif [[ :$cmdspec_opts: == *:stop-options-postarg:* ]]; then + rexreq='^-.+' + ble/opts#has "$cmdspec_opts" plus-options && rexreq='^[-+].+' + fi + fi +} +function ble/progcolor/stop-option#test { + [[ $rexrej && $1 =~ $rexrej || $rexreq && ! ( $1 =~ $rexreq ) ]] +} +function ble/progcolor/is-option-context { + if [[ ${progcolor_optctx[1]} ]]; then + ((progcolor_optctx[1]<0?1:(progcolor_iword<=progcolor_optctx[1]))) + return "$?" + fi + local rexrej rexreq stopat + if [[ ! ${progcolor_optctx[0]} ]]; then + progcolor_optctx[0]=1 + local cmdspec_opts + ble/progcolor/load-cmdspec-opts + ble/progcolor/stop-option#init "$cmdspec_opts" + if [[ ! $rexrej$rexreq ]]; then + progcolor_optctx[1]=${stopat:--1} + ((progcolor_optctx[1]<0?1:(progcolor_iword<=progcolor_optctx[1]))) + return "$?" + fi + progcolor_optctx[2]=$rexrej + progcolor_optctx[3]=$rexreq + progcolor_optctx[4]=$stopat + else + rexrej=${progcolor_optctx[2]} + rexreq=${progcolor_optctx[3]} + stopat=${progcolor_optctx[4]} + fi + [[ $stopat ]] && ((progcolor_iword>stopat)) && return 1 + local iword + for ((iword=progcolor_optctx[0];iword0)) && ble/array#push wattr_buff "$len:$wattr_g" + wattr_pos=$pos + wattr_g=$g +} +function ble/progcolor/wattr#setattr { + local pos=$1 attr=$2 g + ble/syntax/attr2g "$attr" + ble/progcolor/wattr#setg "$pos" "$g" +} +function ble/progcolor/wattr#finalize { + local wattr + if ((${#wattr_buff[@]})); then + local len=$((wend-wattr_pos)) + ((len>0)) && ble/array#push wattr_buff \$:"$wattr_g" + wattr_pos=$wend + wattr_g=d + IFS=, builtin eval 'wattr="m${wattr_buff[*]}"' + else + wattr=$wattr_g + fi + ble/progcolor/set-wattr "$wattr" +} +function ble/progcolor/highlight-filename/.detect-separated-path { + local word=$1 + ((wtype==_ble_ctx_ARGI||wtype==_ble_ctx_ARGEI||wtype==_ble_ctx_VALI||wtype==_ble_attr_VAR||wtype==_ble_ctx_RDRS)) || return 1 + local detect_opts=url:$highlight_eval_opts + ((wtype==_ble_ctx_RDRS)) && detect_opts=$detect_opts:noglob + [[ $word == '~'* ]] && ((_ble_syntax_attr[p0]!=_ble_attr_TILDE)) && detect_opts=$detect_opts:notilde + ble/syntax:bash/simple-word/detect-separated-path "$word" :, "$detect_opts" +} +function ble/progcolor/highlight-filename/.pathspec.wattr { + local p=$p0 opts=$2 + if [[ :$opts: != *:no-path-color:* ]]; then + local ipath npath=${#path[@]} + for ((ipath=0;ipath' || $redirect_ntype == '>'[\|\&] ) ]]; then + if [[ -e $value || -h $value ]]; then + if [[ -d $value || ! -w $value ]]; then + type=$_ble_attr_ERR + elif [[ ( $redirect_ntype == [\<\&]'>' || $redirect_ntype == '>' || $redirect_ntype == '>&' ) && -f $value ]]; then + if [[ -o noclobber ]]; then + type=$_ble_attr_ERR + else + type=$_ble_attr_FILE_WARN + fi + fi + elif [[ $value == */* && ! -w ${value%/*}/ || $value != */* && ! -w ./ ]]; then + type=$_ble_attr_ERR + fi + elif [[ $redirect_ntype == '<' && ! -r $value ]]; then + type=$_ble_attr_ERR + fi + fi + fi + local g= + if [[ $bleopt_filename_ls_colors ]]; then + ble/syntax/highlight/ls_colors "$value" + fi + [[ $type && ! $g ]] && ble/syntax/attr2g "$type" + ble/progcolor/highlight-filename/.pathspec.wattr "${g:-d}" "$highlight_opts" + return 0 +} +function ble/progcolor/highlight-filename/.single.wattr { + local p0=${1%%:*} p1=${1#*:} + local wtxt=${text:p0:p1-p0} + if ((wtype==_ble_ctx_CMDI)) && ble/alias#active "$wtxt"; then + ble/progcolor/wattr#setattr "$p0" "$_ble_attr_CMD_ALIAS" + return 0 + fi + local path_opts=after-sep:$highlight_eval_opts + [[ $wtxt == '~'* ]] && ((_ble_syntax_attr[p0]!=_ble_attr_TILDE)) && path_opts=$path_opts:notilde + ((wtype==_ble_ctx_RDRS||wtype==_ble_attr_VAR||wtype==_ble_ctx_VALI&&wbeg=2)); then + ble/progcolor/wattr#setattr "$p0" "$_ble_attr_ERR" + elif ((wtype==_ble_ctx_CMDI)); then + local attr=${_ble_syntax_attr[wbeg]} + if ((attr!=_ble_attr_KEYWORD&&attr!=_ble_attr_KEYWORD_BEGIN&&attr!=_ble_attr_KEYWORD_END&&attr!=_ble_attr_KEYWORD_MID&&attr!=_ble_attr_DEL)); then + local type=; ble/syntax/highlight/cmdtype "$value" "$wtxt" + if ((type==_ble_attr_CMD_FILE||type==_ble_attr_CMD_FILE||type==_ble_attr_ERR)); then + ble/progcolor/highlight-filename/.pathspec-with-attr.wattr "$type" + elif [[ $type ]]; then + ble/progcolor/wattr#setattr "$p0" "$type" + fi + fi + elif ((wtype==_ble_ctx_RDRD||wtype==_ble_ctx_RDRD2)); then + if local rex='^[0-9]+-?$|^-$'; [[ $value =~ $rex ]]; then + ble/progcolor/wattr#setattr "$p0" "$_ble_attr_DEL" + elif ((wtype==_ble_ctx_RDRD2)); then + ble/progcolor/highlight-filename/.pathspec-by-name.wattr "$value" + else + ble/progcolor/wattr#setattr "$p0" "$_ble_attr_ERR" + fi + elif ((wtype==_ble_ctx_ARGI||wtype==_ble_ctx_ARGEI||wtype==_ble_ctx_VALI||wtype==_ble_attr_VAR||wtype==_ble_ctx_RDRS||wtype==_ble_ctx_RDRF)); then + ble/progcolor/highlight-filename/.pathspec-by-name.wattr "$value" + fi +} +function ble/progcolor/highlight-filename.wattr { + local p0=$1 p1=$2 + if ((p0=2)) || return 1 + local IFS=$_ble_term_IFS + local ins="$*" + comp_line=$ins${comp_line:${#ocmd}} + ((comp_point-=${#ocmd},comp_point<0&&(comp_point=0),comp_point+=${#ins})) + comp_words=("$@" "${comp_words[@]:1}") + ((comp_cword&&(comp_cword+=$#-1))) + ble/array#reserve-prototype "$#" + tree_words=("${tree_words[0]}" "${_ble_array_prototype[@]::$#-1}" "${tree_words[@]:1}") +} +function ble/progcolor { + local cmd=$1 opts=$2 + local -a progcolor_stats=() + local -a progcolor_wvals=() + local progcolor_cmdspec_opts= + local -a progcolor_optctx=() + local -a alias_args=() + local checked=" " processed= + while :; do + if ble/is-function ble/cmdinfo/cmd:"$cmd"/chroma; then + ble/progcolor/.compline-rewrite-command "$cmd" "${alias_args[@]}" + ble/cmdinfo/cmd:"$cmd"/chroma "$opts" + processed=1 + break + elif [[ $cmd == */?* ]] && ble/is-function ble/cmdinfo/cmd:"${cmd##*/}"/chroma; then + ble/progcolor/.compline-rewrite-command "${cmd##*/}" "${alias_args[@]}" + ble/cmdinfo/cmd:"${cmd##*/}"/chroma "$opts" + processed=1 + break + fi + checked="$checked$cmd " + local ret + ble/alias#expand "$cmd" + ble/string#split-words ret "$ret" + [[ $checked == *" $ret "* ]] && break + cmd=$ret + ((${#ret[@]}>=2)) && + alias_args=("${ret[@]:1}" "${alias_args[@]}") + done + [[ $processed ]] || + ble/progcolor/default + if [[ ${tree_words[0]} ]]; then + local "${_ble_syntax_progcolor_vars[@]/%/=}" # WA #D1570 checked + ble/progcolor/load-word-data "${tree_words[0]}" + [[ $wattr == - ]] && ble/progcolor/word:default + fi +} +function ble/highlight/layer:syntax/touch-range { + ble/syntax/urange#update '' "$@" +} +function ble/highlight/layer:syntax/fill { + local _ble_local_script=' + local iNAME=0 i1NAME=$2 i2NAME=$3 + for ((iNAME=i1NAME;iNAME=0)); then + ble/highlight/layer:syntax/touch-range _ble_syntax_attr_umin _ble_syntax_attr_umax + local i g=0 + ((_ble_syntax_attr_umin>0)) && + ((g=_ble_highlight_layer_syntax1_table[_ble_syntax_attr_umin-1])) + for ((i=_ble_syntax_attr_umin;i<_ble_syntax_attr_umax;i++)); do + if ((${_ble_syntax_attr[i]})); then + ble/syntax/attr2g "${_ble_syntax_attr[i]}" + fi + _ble_highlight_layer_syntax1_table[i]=$g + done + _ble_syntax_attr_umin=-1 _ble_syntax_attr_umax=-1 + fi +} +function ble/highlight/layer:syntax/word/.update-attributes/.proc { + [[ $wtype =~ ^[0-9]+$ ]] || return 1 + [[ ${node[TE_nofs+4]} == - ]] || return 1 + if ((wtype==_ble_ctx_CMDI||wtype==_ble_ctx_ARGI||wtype==_ble_ctx_ARGVI||wtype==_ble_ctx_ARGEI)); then + local comp_line comp_point comp_words comp_cword tree_words + if ble/syntax:bash/extract-command-by-noderef "$TE_i:$TE_nofs" treeinfo; then + local cmd=${comp_words[0]} + ble/progcolor "$cmd" + return 0 + fi + fi + ble/progcolor/word:default +} +function ble/highlight/layer:syntax/word/.update-attributes { + ((_ble_syntax_word_umin>=0)) || return 1 + if [[ ! $ble_textarea_render_defer_running ]]; then + local _ble_syntax_bash_simple_eval_timeout=$bleopt_highlight_timeout_sync + local _ble_syntax_bash_simple_eval_timeout_carry= + local highlight_eval_opts=cached:single:stopcheck:timeout-carry + else + local _ble_syntax_bash_simple_eval_timeout=$bleopt_highlight_timeout_async + local highlight_eval_opts=cached:single:stopcheck + fi + ble/syntax/tree-enumerate-in-range "$_ble_syntax_word_umin" "$_ble_syntax_word_umax" \ + ble/highlight/layer:syntax/word/.update-attributes/.proc +} +function ble/highlight/layer:syntax/word/.apply-attribute { + local wbeg=$1 wend=$2 wattr=$3 + ((wbegcolor_umax&&(wend=color_umax), + wbegwend&&(j=wend))) + fi + ble/highlight/layer:syntax/word/.apply-attribute "$i" "$j" "$sub_wattr" + (((i=j)=0)) && ble/syntax/tree-enumerate-children "$proc_children" +} +function ble/highlight/layer:syntax/update-word-table { + local color_umin=-1 color_umax=-1 iN=${#_ble_syntax_text} + ble/highlight/layer:syntax/word/.update-attributes + ble/highlight/layer/update/shift _ble_highlight_layer_syntax2_table + ble/syntax/wrange#update _ble_syntax_word_ "$_ble_syntax_vanishing_word_umin" "$_ble_syntax_vanishing_word_umax" + ble/syntax/wrange#update color_ "$_ble_syntax_vanishing_word_umin" "$_ble_syntax_vanishing_word_umax" + _ble_syntax_vanishing_word_umin=-1 _ble_syntax_vanishing_word_umax=-1 + ble/highlight/layer:syntax/word/.apply-attribute 0 "$iN" d # clear word color + local TE_i + for ((TE_i=_ble_syntax_word_umax;TE_i>=_ble_syntax_word_umin;)); do + if ((TE_i>0)) && [[ ${_ble_syntax_tree[TE_i-1]} ]]; then + local -a node + ble/string#split-words node "${_ble_syntax_tree[TE_i-1]}" + local wlen=${node[1]} + local wbeg=$((TE_i-wlen)) wend=$TE_i + if [[ ${node[0]} =~ ^[0-9]+$ ]]; then + local attr=${node[4]} + ble/highlight/layer:syntax/word/.apply-attribute "$wbeg" "$wend" "$attr" + fi + local tclen=${node[2]} + if ((tclen>=0)); then + local tchild=$((TE_i-tclen)) + local tree= TE_nofs=0 proc_children=ble/highlight/layer:syntax/word/.proc-childnode + ble/syntax/tree-enumerate-children "$proc_children" + fi + ((TE_i=wbeg)) + else + ((TE_i--)) + fi + done + ((color_umin>=0)) && ble/highlight/layer:syntax/touch-range "$color_umin" "$color_umax" + _ble_syntax_word_umin=-1 _ble_syntax_word_umax=-1 +} +function ble/highlight/layer:syntax/update-error-table/set { + local i1=$1 i2=$2 g=$3 + if ((i1=DMAX0?(a+=DMAX-DMAX0):(a>=DMIN&&(a=DMIN)), + b>=DMAX0?(b+=DMAX-DMAX0):(b>=DMIN&&(b=DMIN)))) + if ((a0)) && [[ ${_ble_syntax_stat[iN]} ]]; then + local ret; ble/color/face2g syntax_error; local g=$ret + local -a stat + ble/string#split-words stat "${_ble_syntax_stat[iN]}" + local ctx=${stat[0]} nlen=${stat[3]} nparam=${stat[6]} + [[ $nparam == none ]] && nparam= + local i inest + if ((nlen>0)) || [[ $nparam ]]; then + ble/highlight/layer:syntax/update-error-table/set "$((iN-1))" "$iN" "$g" + if ((nlen>0)); then + ((inest=iN-nlen)) + while ((inest>=0)); do + local inest2 + for ((inest2=inest+1;inest2=i&&(inest=i-1))) + done + fi + fi + if ((ctx==_ble_ctx_CMDX1||ctx==_ble_ctx_CMDXC||ctx==_ble_ctx_FARGX1||ctx==_ble_ctx_SARGX1||ctx==_ble_ctx_FARGX2||ctx==_ble_ctx_CARGX1||ctx==_ble_ctx_CARGX2||ctx==_ble_ctx_COARGX)); then + ble/highlight/layer:syntax/update-error-table/set "$((iN-1))" "$iN" "$g" + fi + fi +} +function ble/highlight/layer:syntax/update { + local text=$1 player=$2 + local i iN=${#text} + local umin=-1 umax=-1 + ((DMIN>=0)) && umin=$DMIN umax=$DMAX + if [[ ! $bleopt_highlight_syntax ]]; then + if [[ $_ble_highlight_layer_syntax_active ]]; then + _ble_highlight_layer_syntax_active= + PREV_UMIN=0 PREV_UMAX=${#1} + fi + return 0 + fi + if [[ ! $_ble_highlight_layer_syntax_active ]]; then + _ble_highlight_layer_syntax_active=1 + umin=0 umax=${#text} + fi + if [[ $bleopt_syntax_debug ]]; then + local debug_attr_umin=$_ble_syntax_attr_umin + local debug_attr_uend=$_ble_syntax_attr_umax + fi + ble/cmdspec/initialize # load chroma + ble/highlight/layer:syntax/update-attribute-table + ble/highlight/layer:syntax/update-word-table + ble/highlight/layer:syntax/update-error-table + if ((DMIN>=0)); then + ble/highlight/layer/update/shift _ble_highlight_layer_syntax_buff + if ((DMAX>0)); then + local g sgr ch ret + ble/highlight/layer:syntax/getg "$DMAX" + ble/color/g2sgr "$g"; sgr=$ret + ch=${_ble_highlight_layer_plain_buff[DMAX]} + _ble_highlight_layer_syntax_buff[DMAX]=$sgr$ch + fi + fi + local i j g gprev=0 + if ((umin>0)); then + ble/highlight/layer:syntax/getg "$((umin-1))" + gprev=$g + fi + if ((umin>=0)); then + local ret + for ((i=umin;i<=umax;i++)); do + local ch=${_ble_highlight_layer_plain_buff[i]} + ble/highlight/layer:syntax/getg "$i" + [[ $g ]] || ble/highlight/layer/update/getg "$i" + if ((gprev!=g)); then + ble/color/g2sgr "$g" + ch=$ret$ch + ((gprev=g)) + fi + _ble_highlight_layer_syntax_buff[i]=$ch + done + fi + PREV_UMIN=$umin PREV_UMAX=$umax + PREV_BUFF=_ble_highlight_layer_syntax_buff + if [[ $bleopt_syntax_debug ]]; then + local status buff= nl=$'\n' + _ble_syntax_attr_umin=$debug_attr_umin _ble_syntax_attr_umax=$debug_attr_uend ble/syntax/print-status -v status + local -a DRAW_BUFF=() + ble/syntax/print-layer-buffer.draw plain + ble/syntax/print-layer-buffer.draw syntax + ble/syntax/print-layer-buffer.draw disabled + ble/syntax/print-layer-buffer.draw region + ble/syntax/print-layer-buffer.draw overwrite + local ret; ble/canvas/sflush.draw + status=$status$ret + ble/edit/info/show ansi "$status" + fi +} +function ble/highlight/layer:syntax/getg { + [[ $bleopt_highlight_syntax ]] || return 1 + local i=$1 + if [[ ${_ble_highlight_layer_syntax3_table[i]} ]]; then + g=${_ble_highlight_layer_syntax3_table[i]} + elif [[ ${_ble_highlight_layer_syntax2_table[i]} ]]; then + g=${_ble_highlight_layer_syntax2_table[i]} + elif [[ ${_ble_highlight_layer_syntax1_table[i]} ]]; then + g=${_ble_highlight_layer_syntax1_table[i]} + fi +} +function ble/highlight/layer:syntax/textarea_render_defer.hook { + ble/syntax/wrange#update _ble_syntax_word_ "$_ble_syntax_word_defer_umin" "$_ble_syntax_word_defer_umax" + _ble_syntax_word_defer_umin=-1 + _ble_syntax_word_defer_umax=-1 +} +blehook textarea_render_defer!=ble/highlight/layer:syntax/textarea_render_defer.hook +function ble/syntax/import { return 0; } +blehook/invoke syntax_load +ble/function#try ble/textarea#invalidate str +return 0 diff --git a/.local/share/blesh/lib/core-test.sh b/.local/share/blesh/lib/core-test.sh new file mode 100644 index 0000000..678f650 --- /dev/null +++ b/.local/share/blesh/lib/core-test.sh @@ -0,0 +1,217 @@ +# Copyright 2015 Koichi Murase . All rights reserved. +# This script is a part of blesh (https://github.com/akinomyoga/ble.sh) +# provided under the BSD-3-Clause license. Do not edit this file because this +# is not the original source code: Various pre-processing has been applied. +# Also, the code comments and blank lines are stripped off in the installation +# process. Please find the corresponding source file(s) in the repository +# "akinomyoga/ble.sh". +# +# Source: /lib/core-test.sh +function ble/test/getdir { + dir=$_ble_base_run/$$.test + [[ -d $dir ]] || ble/bin/mkdir -p "$dir" +} +_ble_test_dir= +function ble/test/chdir { + local dir + ble/test/getdir + ble/util/getpid + _ble_test_dir=$dir/$BASHPID.d + [[ -d $_ble_test_dir ]] || + ble/bin/mkdir -p "$_ble_test_dir" + cd -L "$_ble_test_dir" +} +function ble/test/rmdir { + [[ -d $_ble_test_dir ]] && + ble/bin/rm -rf "$_ble_test_dir" + return 0 +} +_ble_test_logfile_fd= +function ble/test/log { + if [[ $_ble_test_logfile_fd ]]; then + ble/util/print "$1" >&"$_ble_test_logfile_fd" + fi + ble/util/print "$1" +} +function ble/test/log#open { + local file=$1 + if ble/fd#alloc _ble_test_logfile_fd '>>$file'; then + local h10=---------- + [[ -s $file ]] && + ble/util/print "$h10$h10$h10$h10$h10$h10$h10" >&"$_ble_test_logfile_fd" + ble/util/print "[$(date +'%F %T %Z')] test: start logging" >&"$_ble_test_logfile_fd" + fi +} +function ble/test/log#close { + if [[ $_ble_test_logfile_fd ]]; then + ble/util/print "[$(date +'%F %T %Z')] test: end logging" >&"$_ble_test_logfile_fd" + ble/fd#close _ble_test_logfile_fd + _ble_test_logfile_fd= + fi +} +if ble/bin#freeze-utility-path colored; then + function ble/test/diff.impl { + ble/bin/colored diff -u "$@" + } +else + function ble/test/diff.impl { + diff -u "$@" + } +fi +function ble/test/diff { + local dir + ble/test/getdir + ble/util/getpid + local f1=$BASHPID.$1.expect + local f2=$BASHPID.$1.result + ( + ble/util/joblist/__suppress__ + cd "$dir" + ble/util/print "$2" >| "$f1" + ble/util/print "$3" >| "$f2" + ble/util/assign ret 'ble/test/diff.impl "$f1" "$f2"' + ble/test/log "$ret" + >| "$f1" >| "$f2" + ) +} +_ble_test_section_failure_count=0 +_ble_test_section_fd= +_ble_test_section_file= +_ble_test_section_title=section +_ble_test_section_count=0 +function ble/test/start-section { + [[ $_ble_test_section_fd ]] && ble/test/end-section + _ble_test_section_title=$1 + _ble_test_section_count=$2 + local dir + ble/test/getdir + ble/util/getpid + _ble_test_section_file=$dir/$BASHPID + ble/fd#alloc _ble_test_section_fd '> "$_ble_test_section_file"' +} +function ble/test/end-section { + [[ $_ble_test_section_fd ]] || return 1 + ble/fd#close _ble_test_section_fd + _ble_test_section_fd= + local ntest npass count=$_ble_test_section_count + local ntest nfail npass + builtin eval -- $( + ble/bin/awk ' + BEGIN{test=0;fail=0;pass=0;} + /^test /{test++} + /^fail /{fail++} + /^pass /{pass++} + END{print "ntest="test" nfail="fail" npass="pass;} + ' "$_ble_test_section_file") + local sgr=$'\e[32m' sgr0=$'\e[m' + ((npass==ntest)) || sgr=$'\e[31m' + local ncrash=$((ntest-nfail-npass)) + local nskip=$((count-ntest)) + if ((ntest)); then + local percentage=$((npass*1000/ntest)) # Note: 切り捨て + ble/util/sprintf percentage '%6s' "$((percentage/10)).$((percentage%10))%" # "XXX.X%" + else + local percentage=---.-% + fi + ble/test/log "$sgr$percentage$sgr0 [section] $_ble_test_section_title: $sgr$npass/$ntest$sgr0 ($nfail fail, $ncrash crash, $nskip skip)" + if ((npass==ntest)); then + return 0 + else + ((_ble_test_section_failure_count++)) + return 1 + fi +} +function ble/test/section#incr { + local title=$1 + [[ $_ble_test_section_fd ]] || return 1 + ble/util/print "test $title" >&"$_ble_test_section_fd" +} +function ble/test/section#report { + local ext=$? title=$1 + [[ $_ble_test_section_fd ]] || return 1 + local code=fail; ((ext==0)) && code=pass + ble/util/print "$code $title" >&"$_ble_test_section_fd" +} +function ble/test/.read-arguments { + local xstdout xstderr xexit xret + local qstdout qstderr qexit qret + local -a buff=() + while (($#)); do + local arg=$1; shift + case $arg in + ('#'*) + local ret; ble/string#trim "${arg#'#'}" + _ble_test_title=$ret ;; + (stdout[:=]*) + [[ $qstdout ]] && xstdout=$xstdout$'\n' + qstdout=1 + xstdout=$xstdout${arg#*[:=]} ;; + (stderr[:=]*) + [[ $qstderr ]] && xstderr=$xstderr$'\n' + qstderr=1 + xstderr=$xstderr${arg#*[:=]} ;; + (ret[:=]*) + qret=1 + xret=${arg#*[:=]} ;; + (exit[:=]*) + qexit=1 + xexit=${arg#*[:=]} ;; + (code[:=]*) + ((${#buff[@]})) && ble/array#push buff $'\n' + ble/array#push buff "${arg#*[:=]}" ;; + (--depth=*) + _ble_test_caller_depth=${arg#*=} ;; + (--display-code=*) + _ble_test_display_code=${arg#*=} ;; + (*) + ((${#buff[@]})) && ble/array#push buff ' ' + ble/array#push buff "$arg" ;; + esac + done + [[ $qstdout ]] && _ble_test_item_expect[0]=$xstdout + [[ $qstderr ]] && _ble_test_item_expect[1]=$xstderr + [[ $qexit ]] && _ble_test_item_expect[2]=$xexit + [[ $qret ]] && _ble_test_item_expect[3]=$xret + ((${#_ble_test_item_expect[@]})) || _ble_test_item_expect[2]=0 + IFS= builtin eval '_ble_test_code="${buff[*]}"' +} +_ble_test_item_name=(stdout stderr exit ret) +function ble/test { + local _ble_test_code + local _ble_test_title + local _ble_test_caller_depth=0 + local _ble_test_display_code= + local -a _ble_test_item_expect=() + ble/test/.read-arguments "$@" + local caller_lineno=${BASH_LINENO[_ble_test_caller_depth+0]} + local caller_source=${BASH_SOURCE[_ble_test_caller_depth+1]} + _ble_test_title="$caller_source:$caller_lineno${_ble_test_title+ ($_ble_test_title)}" + ble/test/section#incr "$_ble_test_title" + ble/util/assign stderr ' + ble/util/assign stdout "$_ble_test_code" 2>&1'; exit=$? + local -a item_result=() + item_result[0]=$stdout + item_result[1]=$stderr + item_result[2]=$exit + item_result[3]=$ret + local i flag_error= + for i in "${!_ble_test_item_expect[@]}"; do + [[ ${item_result[i]} == "${_ble_test_item_expect[i]}" ]] && continue + if [[ ! $flag_error ]]; then + flag_error=1 + ble/test/log $'\e[1m'"$_ble_test_title"$'\e[m: \e[91m'"${_ble_test_display_code:-$_ble_test_code}"$'\e[m' + fi + ble/test/diff "${_ble_test_item_name[i]}" "${_ble_test_item_expect[i]}" "${item_result[i]}" + done + if [[ $flag_error ]]; then + if [[ ! ${_ble_test_item_expect[1]+set} && $stderr ]]; then + ble/test/log "" + ble/test/log "$stderr" + ble/test/log "" + fi + ble/test/log + fi + [[ ! $flag_error ]] + ble/test/section#report "$_ble_test_title" + return 0 +} diff --git a/.local/share/blesh/lib/init-bind.sh b/.local/share/blesh/lib/init-bind.sh new file mode 100644 index 0000000..492ef5d --- /dev/null +++ b/.local/share/blesh/lib/init-bind.sh @@ -0,0 +1,113 @@ +# Copyright 2015 Koichi Murase . All rights reserved. +# This script is a part of blesh (https://github.com/akinomyoga/ble.sh) +# provided under the BSD-3-Clause license. Do not edit this file because this +# is not the original source code: Various pre-processing has been applied. +# Also, the code comments and blank lines are stripped off in the installation +# process. Please find the corresponding source file(s) in the repository +# "akinomyoga/ble.sh". +# +# Source: /lib/init-bind.sh +function ble/init:bind/append { + local xarg="\"$1\":_ble_decode_hook $2; builtin eval -- \"\$_ble_decode_bind_hook\"" + local rarg=$1 condition=$3${3:+' && '} + ble/util/print "${condition}builtin bind -x '${xarg//$q/$Q}'" >> "$fbind1" + ble/util/print "${condition}builtin bind -r '${rarg//$q/$Q}'" >> "$fbind2" +} +function ble/init:bind/append-macro { + local kseq1=$1 kseq2=$2 condition=$3${3:+' && '} + local sarg="\"$kseq1\":\"$kseq2\"" rarg=$kseq1 + ble/util/print "${condition}builtin bind '${sarg//$q/$Q}'" >> "$fbind1" + ble/util/print "${condition}builtin bind -r '${rarg//$q/$Q}'" >> "$fbind2" +} +function ble/init:bind/bind-s { + local sarg=$1 + ble/util/print "builtin bind '${sarg//$q/$Q}'" >> "$fbind1" +} +function ble/init:bind/generate-binder { + local fbind1=$_ble_base_cache/decode.bind.$_ble_bash.$bleopt_input_encoding.bind + local fbind2=$_ble_base_cache/decode.bind.$_ble_bash.$bleopt_input_encoding.unbind + ble/edit/info/show text "ble.sh: updating binders..." + >| "$fbind1" + >| "$fbind2" + local q=\' Q="'\\''" + local altdqs00='\xC0\x80' + local altdqs24='\xC0\x98' + local altdqs27='\xC0\x9B' + local esc00=$((40300<=_ble_bash&&_ble_bash<50000)) + local bind18XX=0 + if ((40400<=_ble_bash&&_ble_bash<50000)); then + ble/util/print "[[ -o emacs ]] && builtin bind 'set keyseq-timeout 1'" >> "$fbind1" + fbind2=$fbind1 ble/init:bind/append '\C-x\C-x' 24 '[[ -o emacs ]]' + elif ((_ble_bash<40300)); then + bind18XX=1 + fi + local esc1B=3 + local esc1B5B=1 bindAllSeq=0 + local esc1B1B=$((40100<=_ble_bash&&_ble_bash<40300)) + local i + for i in {128..255} {0..127}; do + local ret; ble/decode/c2dqs "$i" + if ((i==0)); then + if ((esc00)); then + ble/init:bind/append-macro '\C-@' "$altdqs00" + else + ble/init:bind/append "$ret" "$i" + fi + elif ((i==24)); then + if ((bind18XX)); then + ble/init:bind/append "$ret" "$i" '[[ ! -o emacs ]]' + else + ble/init:bind/append "$ret" "$i" + fi + elif ((i==27)); then + if ((esc1B==0)); then + ble/init:bind/append "$ret" "$i" + elif ((esc1B==2)); then + ble/init:bind/append-macro '\e' "$altdqs27" + elif ((esc1B==3)); then + ble/init:bind/append-macro '\e' '\xDF\xBC' # C-[ + fi + else + ((i==28&&_ble_bash>=50000)) && ret='\x1C' + ble/init:bind/append "$ret" "$i" + fi + if ((bind18XX)); then + if ((i==0)); then + ble/init:bind/append-macro "\C-x$ret" "$altdqs24$altdqs00" '[[ -o emacs ]]' + elif ((i==24)); then + ble/init:bind/append-macro "\C-x$ret" "$altdqs24$altdqs24" '[[ -o emacs ]]' + else + ble/init:bind/append-macro "\C-x$ret" "$altdqs24$ret" '[[ -o emacs ]]' + fi + fi + if ((esc1B==3)); then + if ((i==0)); then + ble/init:bind/append-macro '\e'"$ret" "$altdqs27$altdqs00" + elif ((bind18XX&&i==24)); then + ble/init:bind/append-macro '\e'"$ret" "$altdqs27$altdqs24" + else + ble/init:bind/append-macro '\e'"$ret" "$altdqs27$ret" + fi + else + if ((esc1B==1)); then + if ((i==91&&esc1B5B)); then + ble/init:bind/append-macro '\e[' "$altdqs27[" + else + ble/init:bind/append "\\e$ret" "27 $i" + fi + fi + if ((i==27&&esc1B1B)); then + ble/init:bind/append-macro '\e\e' '\e[^' + ble/util/print "ble-bind -k 'ESC [ ^' __esc__" >> "$fbind1" + ble/util/print "ble-bind -f __esc__ '.CHARS 27 27'" >> "$fbind1" + fi + fi + done + if ((bindAllSeq)); then + ble/util/print 'source "$_ble_decode_bind_fbinder.bind"' >> "$fbind1" + ble/util/print 'source "$_ble_decode_bind_fbinder.unbind"' >> "$fbind2" + fi + ble/function#try ble/encoding:"$bleopt_input_encoding"/generate-binder + ble/edit/info/immediate-show text "ble.sh: updating binders... done" +} +ble/init:bind/generate-binder diff --git a/.local/share/blesh/lib/init-cmap.sh b/.local/share/blesh/lib/init-cmap.sh new file mode 100644 index 0000000..5ce0c63 --- /dev/null +++ b/.local/share/blesh/lib/init-cmap.sh @@ -0,0 +1,195 @@ +# Copyright 2015 Koichi Murase . All rights reserved. +# This script is a part of blesh (https://github.com/akinomyoga/ble.sh) +# provided under the BSD-3-Clause license. Do not edit this file because this +# is not the original source code: Various pre-processing has been applied. +# Also, the code comments and blank lines are stripped off in the installation +# process. Please find the corresponding source file(s) in the repository +# "akinomyoga/ble.sh". +# +# Source: /lib/init-cmap.sh +function ble/init:cmap/bind-single-csi { + ble-bind -k "ESC [ $1" "$2" + ble-bind -k "CSI $1" "$2" +} +function ble/init:cmap/bind-single-ss3 { + ble-bind -k "ESC O $1" "$2" + ble-bind -k "SS3 $1" "$2" +} +function ble/init:cmap/bind-keypad-key { + local Ft=$1 name=$2 + (($3&4)) && ble-bind --csi "$Ft" "$name" + (($3&1)) && ble/init:cmap/bind-single-ss3 "$Ft" "$name" + (($3&2)) && ble-bind -k "ESC ? $Ft" "$name" +} +function ble/init:cmap/initialize { + ble/edit/info/immediate-show text "ble/lib/init-cmap.sh: updating key sequences..." + local ret + ble-decode-kbd/generate-keycode insert + ble-decode-kbd/generate-keycode home + ble-decode-kbd/generate-keycode prior + ble-decode-kbd/generate-keycode delete + ble-decode-kbd/generate-keycode end + ble-decode-kbd/generate-keycode next + ble-decode-kbd/generate-keycode find + ble-decode-kbd/generate-keycode select + local kend; ble/util/assign kend 'tput @7 2>/dev/null || tput kend 2>/dev/null' + if [[ $kend == $'\e[5~' ]]; then + ble-bind --csi '1~' insert + ble-bind --csi '2~' home + ble-bind --csi '3~' prior + ble-bind --csi '4~' delete + ble-bind --csi '5~' end + ble-bind --csi '6~' next + else + if [[ $kend == $'\e[F' && ( $TERM == xterm || $TERM == xterm-* || $TERM == kvt ) ]]; then + ble-bind --csi '1~' find + ble-bind --csi '4~' select + else + ble-bind --csi '1~' home + ble-bind --csi '4~' end + fi + ble-bind --csi '2~' insert + ble-bind --csi '3~' delete + ble-bind --csi '5~' prior + ble-bind --csi '6~' next + fi + ble-bind --csi '7~' home + ble-bind --csi '8~' end + local kdch1; ble/util/assign kdch1 'tput kD 2>/dev/null || tput kdch1 2>/dev/null' + [[ $kdch1 == $'\x7F' || $TERM == sun* ]] && ble-bind -k 'DEL' delete + ble-bind --csi '11~' f1 + ble-bind --csi '12~' f2 + ble-bind --csi '13~' f3 + ble-bind --csi '14~' f4 + ble-bind --csi '15~' f5 + ble-bind --csi '17~' f6 + ble-bind --csi '18~' f7 + ble-bind --csi '19~' f8 + ble-bind --csi '20~' f9 + ble-bind --csi '21~' f10 + ble-bind --csi '23~' f11 + ble-bind --csi '24~' f12 + ble-bind --csi '25~' f13 + ble-bind --csi '26~' f14 + ble-bind --csi '28~' f15 + ble-bind --csi '29~' f16 + ble-bind --csi '31~' f17 + ble-bind --csi '32~' f18 + ble-bind --csi '33~' f19 + ble-bind --csi '34~' f20 + ble-bind --csi '200~' paste_begin + ble-bind --csi '201~' paste_end + ble/init:cmap/bind-keypad-key 'SP' SP 3 # kpspace + ble/init:cmap/bind-keypad-key 'A' up 5 + ble/init:cmap/bind-keypad-key 'B' down 5 + ble/init:cmap/bind-keypad-key 'C' right 5 + ble/init:cmap/bind-keypad-key 'D' left 5 + ble/init:cmap/bind-keypad-key 'E' begin 5 + ble/init:cmap/bind-keypad-key 'F' end 5 + ble/init:cmap/bind-keypad-key 'H' home 5 + ble/init:cmap/bind-keypad-key 'I' TAB 3 # kptab (Note: CSI I は xterm SM(?1004) focus と重複) + ble/init:cmap/bind-keypad-key 'M' RET 7 # kpent + ble/init:cmap/bind-keypad-key 'P' f1 5 # kpf1 # Note: 普通の f1-f4 + ble/init:cmap/bind-keypad-key 'Q' f2 5 # kpf2 # に対してこれらの + ble/init:cmap/bind-keypad-key 'R' f3 5 # kpf3 # シーケンスを送る + ble/init:cmap/bind-keypad-key 'S' f4 5 # kpf4 # 端末もある。 + ble/init:cmap/bind-keypad-key 'j' '*' 7 # kpmul + ble/init:cmap/bind-keypad-key 'k' '+' 7 # kpadd + ble/init:cmap/bind-keypad-key 'l' ',' 7 # kpsep + ble/init:cmap/bind-keypad-key 'm' '-' 7 # kpsub + ble/init:cmap/bind-keypad-key 'n' '.' 7 # kpdec + ble/init:cmap/bind-keypad-key 'o' '/' 7 # kpdiv + ble/init:cmap/bind-keypad-key 'p' '0' 7 # kp0 + ble/init:cmap/bind-keypad-key 'q' '1' 7 # kp1 + ble/init:cmap/bind-keypad-key 'r' '2' 7 # kp2 + ble/init:cmap/bind-keypad-key 's' '3' 7 # kp3 + ble/init:cmap/bind-keypad-key 't' '4' 7 # kp4 + ble/init:cmap/bind-keypad-key 'u' '5' 7 # kp5 + ble/init:cmap/bind-keypad-key 'v' '6' 7 # kp6 + ble/init:cmap/bind-keypad-key 'w' '7' 7 # kp7 + ble/init:cmap/bind-keypad-key 'x' '8' 7 # kp8 + ble/init:cmap/bind-keypad-key 'y' '9' 7 # kp9 + ble/init:cmap/bind-keypad-key 'X' '=' 7 # kpeq + ble/init:cmap/bind-keypad-key 'I' focus 4 # Note: 1 (= SS3) は TAB と重複するので設定しない + ble/init:cmap/bind-keypad-key 'O' blur 5 + ble/init:cmap/bind-single-csi 'Z' S-TAB + ble/init:cmap/bind-single-ss3 'a' C-up + ble/init:cmap/bind-single-csi 'a' S-up + ble/init:cmap/bind-single-ss3 'b' C-down + ble/init:cmap/bind-single-csi 'b' S-down + ble/init:cmap/bind-single-ss3 'c' C-right + ble/init:cmap/bind-single-csi 'c' S-right + ble/init:cmap/bind-single-ss3 'd' C-left + ble/init:cmap/bind-single-csi 'd' S-left + ble/init:cmap/bind-single-csi '2 $' S-insert # ECMA-48 違反 + ble/init:cmap/bind-single-csi '3 $' S-delete # ECMA-48 違反 + ble/init:cmap/bind-single-csi '5 $' S-prior # ECMA-48 違反 + ble/init:cmap/bind-single-csi '6 $' S-next # ECMA-48 違反 + ble/init:cmap/bind-single-csi '7 $' S-home # ECMA-48 違反 + ble/init:cmap/bind-single-csi '8 $' S-end # ECMA-48 違反 + ble/init:cmap/bind-single-csi '2 3 $' S-f11 # ECMA-48 違反 + ble/init:cmap/bind-single-csi '2 4 $' S-f12 # ECMA-48 違反 + ble/init:cmap/bind-single-csi '2 5 $' S-f13 # ECMA-48 違反 + ble/init:cmap/bind-single-csi '2 6 $' S-f14 # ECMA-48 違反 + ble/init:cmap/bind-single-csi '2 8 $' S-f15 # ECMA-48 違反 + ble/init:cmap/bind-single-csi '2 9 $' S-f16 # ECMA-48 違反 + ble/init:cmap/bind-single-csi '3 1 $' S-f17 # ECMA-48 違反 + ble/init:cmap/bind-single-csi '3 2 $' S-f18 # ECMA-48 違反 + ble/init:cmap/bind-single-csi '3 3 $' S-f19 # ECMA-48 違反 + ble/init:cmap/bind-single-csi '3 4 $' S-f20 # ECMA-48 違反 + ble/init:cmap/bind-single-csi '[ A' f1 + ble/init:cmap/bind-single-csi '[ B' f2 + ble/init:cmap/bind-single-csi '[ C' f3 + ble/init:cmap/bind-single-csi '[ D' f4 + ble/init:cmap/bind-single-csi '[ E' f5 + ble/init:cmap/bind-single-csi '2 4 7 z' insert + ble/init:cmap/bind-single-csi '2 1 4 z' home + ble/init:cmap/bind-single-csi '2 2 0 z' end + ble/init:cmap/bind-single-csi '2 2 2 z' prior + ble/init:cmap/bind-single-csi '2 1 6 z' next + ble/init:cmap/bind-single-csi '2 2 4 z' f1 + ble/init:cmap/bind-single-csi '2 2 5 z' f2 + ble/init:cmap/bind-single-csi '2 2 6 z' f3 + ble/init:cmap/bind-single-csi '2 2 7 z' f4 + ble/init:cmap/bind-single-csi '2 2 8 z' f5 + ble/init:cmap/bind-single-csi '2 2 9 z' f6 + ble/init:cmap/bind-single-csi '2 3 0 z' f7 + ble/init:cmap/bind-single-csi '2 3 1 z' f8 + ble/init:cmap/bind-single-csi '2 3 2 z' f9 + ble/init:cmap/bind-single-csi '2 3 3 z' f10 + ble/init:cmap/bind-single-csi '2 3 4 z' f11 + ble/init:cmap/bind-single-csi '2 3 5 z' f12 + ble/init:cmap/bind-single-csi '1 z' find # from xterm ctlseqs + ble/init:cmap/bind-single-csi '4 z' select # from xterm ctlseqs + ble/init:cmap/bind-single-csi '2 J' S-home + ble/init:cmap/bind-single-csi 'J' C-end + ble/init:cmap/bind-single-csi 'K' S-end + ble/init:cmap/bind-single-csi '4 l' S-insert + ble/init:cmap/bind-single-csi 'L' C-insert + ble/init:cmap/bind-single-csi '4 h' insert + ble/init:cmap/bind-single-csi '2 K' S-delete + ble/init:cmap/bind-single-csi 'P' delete + _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 + ) + local keyname + for keyname in "${_ble_decode_csimap_kitty_u[@]}"; do + ble-decode-kbd/generate-keycode "$keyname" + done + ble/edit/info/immediate-show text "ble/lib/init-cmap.sh: updating key sequences... done" +} +ble/init:cmap/initialize diff --git a/.local/share/blesh/lib/init-msys1.sh b/.local/share/blesh/lib/init-msys1.sh new file mode 100644 index 0000000..80dd9dc --- /dev/null +++ b/.local/share/blesh/lib/init-msys1.sh @@ -0,0 +1,134 @@ +# Copyright 2015 Koichi Murase . All rights reserved. +# This script is a part of blesh (https://github.com/akinomyoga/ble.sh) +# provided under the BSD-3-Clause license. Do not edit this file because this +# is not the original source code: Various pre-processing has been applied. +# Also, the code comments and blank lines are stripped off in the installation +# process. Please find the corresponding source file(s) in the repository +# "akinomyoga/ble.sh". +# +# Source: /lib/init-msys1.sh +function ble-edit/io:msys1/get-winpid.proc { + /usr/bin/ps | /usr/bin/gawk -v pid="$1" ' + BEGIN { + cygpid_len = 9; + winpid_len = 36; + } + NR == 1 { + line = $0; + if (!match(line, /.*\yPID\y/)) next; + cygpid_end = RLENGTH; + if (!match(line, /.*\yWINPID\y/)) next; + winpid_end = RLENGTH; + next; + } + function get_last_number(line, limit, _, head, i) { + head = substr(line, 1, limit); + if (i = match(head, /[0-9]+$/)) + return substr(head, i, RLENGTH); + return -1; + } + { + cygpid = get_last_number($0, cygpid_end); + if (cygpid != pid) next; + print get_last_number($0, winpid_end); + exit + } + ' +} +function ble-edit/io:msys1/compile-helper { + local helper=$1 + [[ -x $helper && -s $helper && $helper -nt $_ble_base/lib/init-msys1.sh ]] && return 0 + gcc -O2 -s -o "$helper" -xc - << EOF || return 1 +// For MSYS 1.0 +#include +#include +#include +#include + +BOOL is_process_alive(HANDLE handle) { + DWORD result; + return GetExitCodeProcess(handle, &result) && result == STILL_ACTIVE; +} + +BOOL is_file(const char* filename) { + struct stat st; + return stat(filename, &st) == 0 && S_ISREG(st.st_mode); +} + +int main(int argc, char** argv) { + const char* winpid = argv[1]; + const char* fname_buff = argv[2]; + const char* fname_read = argv[3]; + + signal(SIGINT, SIG_IGN); + //signal(SIGQUIT, SIG_IGN); + + int ppid = atoi(winpid); + if (!ppid) { + fprintf(stderr, "ble.sh (msys1): invalid process ID '%s'\n", winpid); + return 1; + } + HANDLE parent_process = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, ppid); + if (parent_process == NULL) { + fprintf(stderr, "ble.sh (msys1): failed to open the parent process '%s'\n", winpid); + return 1; + } + + int exit_code = 0; + BOOL terminate = FALSE; + while (!terminate) { + unlink(fname_read); + if (rename(fname_buff, fname_read) != 0) { + perror("ble.sh (msys1)"); + fprintf(stderr, "ble.sh (msys1): failed to move the file '%s' -> '%s'\n", fname_buff, fname_read); + terminate = TRUE; + exit_code = 1; + break; + } + + FILE* f = fopen(fname_read, "r"); + if (!f) { + fprintf(stderr, "ble.sh (msys1): failed to open the file '%s'\n", fname_read); + terminate = TRUE; + exit_code = 1; + break; + } + + for (;;) { + if (!is_process_alive(parent_process)) { + terminate = TRUE; + break; + } + if (is_file(fname_buff)) break; + + int count = 0; + char buff[4096]; + while (count = fread(&buff, 1, sizeof buff, f)) + fwrite(buff, 1, count, stdout); + fflush(stdout); + Sleep(20); + } + fclose(f); + } + + CloseHandle(parent_process); + return exit_code; +} +EOF + [[ -x $helper ]] +} +function ble-edit/io:msys1/start-background { + local basename=$_ble_edit_io_fname2 + local fname_buff=$basename.buff + ble/base/is-msys1 || return 1 + local helper=$_ble_base_cache/init-msys1-helper.exe + local helper2=$_ble_base_run/$$.init-msys1-helper.exe + ble-edit/io:msys1/compile-helper "$helper" && + /usr/bin/cp "$helper" "$helper2" || return 1 + local winpid + ble/util/assign winpid 'ble-edit/io:msys1/get-winpid.proc $$' + [[ $winpid ]] || return 1 + >| "$fname_buff" + ble/fd#alloc _ble_edit_io_fd2 '> "$fname_buff"' + "$helper2" "$winpid" "$fname_buff" "${fname_buff%.buff}.read" | ble-edit/io/check-ignoreeof-loop & disown +} &>/dev/null diff --git a/.local/share/blesh/lib/init-term.sh b/.local/share/blesh/lib/init-term.sh new file mode 100644 index 0000000..2b14561 --- /dev/null +++ b/.local/share/blesh/lib/init-term.sh @@ -0,0 +1,253 @@ +# Copyright 2015 Koichi Murase . All rights reserved. +# This script is a part of blesh (https://github.com/akinomyoga/ble.sh) +# provided under the BSD-3-Clause license. Do not edit this file because this +# is not the original source code: Various pre-processing has been applied. +# Also, the code comments and blank lines are stripped off in the installation +# process. Please find the corresponding source file(s) in the repository +# "akinomyoga/ble.sh". +# +# Source: /lib/init-term.sh +_ble_term_tput= +function ble/init:term/tput { return 1; } +if ble/bin#freeze-utility-path tput; then + ble/bin/tput cuu 1 &>/dev/null && _ble_term_tput=${_ble_term_tput}i + ble/bin/tput UP 1 &>/dev/null && _ble_term_tput=${_ble_term_tput}c + if [[ $_ble_term_tput ]]; then + function ble/init:term/tput { + local type=$_ble_term_tput + if [[ $1 == -c ]]; then # termcap 優先 + shift + [[ $type == ic ]] && type=c + fi + if [[ $type != c ]]; then + ble/bin/tput "${1%%:*}" "${@:2}" 2>/dev/null + else + ble/bin/tput "${1#*:}" "${@:2}" 2>/dev/null + fi + } + fi +fi +function ble/init:term/register-varname { + local name=$1 + varnames[${#varnames[@]}]=$name +} +function ble/init:term/define-cap { + local IFS=$_ble_term_IFS + local name=$1 def=$2 + shift 2 + ble/util/assign "$name" "ble/init:term/tput $* || ble/util/put \"\$def\"" + ble/init:term/register-varname "$name" +} +function ble/init:term/define-cap.2 { + local IFS=$_ble_term_IFS + local name=$1 def=$2 + shift 2 + ble/util/assign "$name" "ble/util/put x; ble/init:term/tput $* || ble/util/put \"\$def\"; ble/util/put x" + builtin eval "$name=\${$name#x}; $name=\${$name%x}" + ble/init:term/register-varname "$name" +} +_ble_term_sgr_term2ansi=() +_ble_term_rex_sgr=$'\e''\[([0-9;:]+)m' +function ble/init:term/define-sgr-param { + local name=$1 seq=$2 ansi=$3 + if [[ $seq =~ $_ble_term_rex_sgr ]]; then + local rematch1=${BASH_REMATCH[1]} + builtin eval "$name=\$rematch1" + if [[ $ansi ]]; then + local rex='^[0-9]+$' + [[ $rematch1 =~ $rex ]] && + [[ ! ${_ble_term_sgr_term2ansi[rematch1]} ]] && + _ble_term_sgr_term2ansi[rematch1]=$ansi + fi + else + builtin eval "$name=" + fi + if [[ $name =~ ^[_a-zA-Z][_a-zA-Z0-9]*$ ]]; then + ble/init:term/register-varname "$name" + fi +} +function ble/init:term/initialize { + local -a varnames=() + ble/init:term/register-varname _ble_term_sgr_term2ansi + _ble_term_xenl=1 + [[ $_ble_term_tput ]] && + ! ble/init:term/tput xenl:xn &>/dev/null && + _ble_term_xenl= + [[ $TERM == sun* ]] && _ble_term_xenl= + ble/init:term/register-varname _ble_term_xenl + _ble_term_bce= + [[ $_ble_term_tput ]] && + ble/init:term/tput bce:ut &>/dev/null && + _ble_term_bce=1 + ble/init:term/register-varname _ble_term_bce + _ble_term_it=8 + if [[ $_ble_term_tput ]]; then + ble/util/assign _ble_term_it 'ble/init:term/tput it:it' + _ble_term_it=${_ble_term_it:-8} + fi + ble/init:term/register-varname _ble_term_it + ble/init:term/define-cap.2 _ble_term_ind $'\n' ind:sf # $'\eD' + ble/init:term/define-cap _ble_term_ri '' ri:sr # $'\eM' + ble/init:term/define-cap _ble_term_cr $'\r' cr:cr + if [[ $OSTYPE == msys && ! $_ble_term_CR ]]; then # msys-1.0 + [[ $_ble_term_cr ]] || _ble_term_cr=$'\e[G' + if [[ $TERM == cygwin ]]; then + [[ $_ble_term_ind == $'\eD' ]] && _ble_term_ind=$'\n' + _ble_term_xenl= + fi + fi + ble/init:term/define-cap _ble_term_cuu $'\e[%dA' cuu:UP 123 + ble/init:term/define-cap _ble_term_cud $'\e[%dB' cud:DO 123 + ble/init:term/define-cap _ble_term_cuf $'\e[%dC' cuf:RI 123 + ble/init:term/define-cap _ble_term_cub $'\e[%dD' cub:LE 123 + _ble_term_cuu=${_ble_term_cuu//123/%d} + _ble_term_cud=${_ble_term_cud//123/%d} + _ble_term_cuf=${_ble_term_cuf//123/%d} + _ble_term_cub=${_ble_term_cub//123/%d} + _ble_term_ri_or_cuu1=${_ble_term_ri:-${_ble_term_cuu//'%d'/1}} + ble/init:term/register-varname _ble_term_ri_or_cuu1 + ble/init:term/define-cap _ble_term_cup $'\e[13;35H' cup:cm 12 34 + _ble_term_cup=${_ble_term_cup//13/%l} + _ble_term_cup=${_ble_term_cup//35/%c} + _ble_term_cup=${_ble_term_cup//12/%y} + _ble_term_cup=${_ble_term_cup//34/%x} + ble/init:term/define-cap _ble_term_hpa "$_ble_term_cr${_ble_term_cuf//'%d'/123}" hpa:ch 123 + _ble_term_hpa=${_ble_term_hpa//123/%x} + _ble_term_hpa=${_ble_term_hpa//124/%c} + ble/init:term/define-cap _ble_term_vpa "${_ble_term_cuu//'%d'/199}${_ble_term_cud//'%d'/123}" vpa:cv 123 + _ble_term_vpa=${_ble_term_vpa//123/%y} + _ble_term_vpa=${_ble_term_vpa//124/%l} + ble/init:term/define-cap _ble_term_clear $'\e[H\e[2J' clear:cl + _ble_term_clear=${_ble_term_clear//$'\e[3J'} + ble/init:term/define-cap _ble_term_il $'\e[%dL' il:AL 123 + ble/init:term/define-cap _ble_term_dl $'\e[%dM' -c dl:DL 123 + _ble_term_il=${_ble_term_il//123/%d} + _ble_term_dl=${_ble_term_dl//123/%d} + [[ ${TERM%%-*} == eterm ]] && _ble_term_il=$'\r\e[%dL' _ble_term_dl=$'\r\e[%dM' + ble/init:term/define-cap _ble_term_el $'\e[K' el:ce + ble/init:term/define-cap _ble_term_el1 $'\e[1K' el1:cb + if [[ $_ble_term_el == $'\e[K' && $_ble_term_el1 == $'\e[1K' ]]; then + _ble_term_el2=$'\e[2K' + else + _ble_term_el2=$_ble_term_el1$_ble_term_el + fi + ble/init:term/register-varname _ble_term_el2 + ble/init:term/define-cap _ble_term_ed $'\e[J' -c ed:cd + ble/init:term/define-cap _ble_term_ich '' ich:IC 123 # CSI @ + ble/init:term/define-cap _ble_term_dch '' dch:DC 123 # CSI P + ble/init:term/define-cap _ble_term_ech '' ech:ec 123 # CSI X + _ble_term_ich=${_ble_term_ich//123/%d} + _ble_term_dch=${_ble_term_dch//123/%d} + _ble_term_ech=${_ble_term_ech//123/%d} + ble/init:term/define-cap _ble_term_sc $'\e7' sc:sc # \e[s + ble/init:term/define-cap _ble_term_rc $'\e8' rc:rc # \e[u + [[ $TERM == minix ]] && _ble_term_sc= _ble_term_rc= + ble/init:term/define-cap _ble_term_Ss '' Ss:Ss 123 # DECSCUSR + _ble_term_Ss=${_ble_term_Ss//123/@1} + ble/init:term/define-cap _ble_term_civis '' civis:vi + ble/init:term/define-cap _ble_term_cnorm '' cnorm:ve + ble/init:term/define-cap _ble_term_cvvis '' cvvis:vs + ble/init:term/register-varname _ble_term_rmcivis + if ble/string#match "$_ble_term_civis" $'^((\e\\[[<=>?]?[0-9;]+)[hl])+$'; then + local s=$_ble_term_civis + _ble_term_civis= + _ble_term_rmcivis= + while ble/string#match "$s" $'^(\e\\[[<=>?]?[0-9]+)[hl]'; do + s=${s:${#BASH_REMATCH}} + _ble_term_civis=$_ble_term_civis$BASH_REMATCH + if [[ $BASH_REMATCH == *l ]]; then + _ble_term_rmcivis=$_ble_term_rmcivis${BASH_REMATCH[1]}h + else + _ble_term_rmcivis=$_ble_term_rmcivis${BASH_REMATCH[1]}l + fi + done + elif [[ $_ble_term_civis == *$'\e[?25l'* || ! $_ble_term_civis && $TERM != minix ]]; then + _ble_term_rmcivis=$'\e[?25h' + _ble_term_civis=$'\e[?25l' + else + _ble_term_civis= + _ble_term_rmcivis= + fi + ble/init:term/define-cap _ble_term_smcup '' smcup:ti # \e[?1049h + ble/init:term/define-cap _ble_term_rmcup '' rmcup:te # \e[?1049l + ble/init:term/define-cap _ble_term_tsl '' tsl:ts + ble/init:term/define-cap _ble_term_fsl '' fsl:fs + ble/init:term/define-cap _ble_term_dsl '' dsl:ds + [[ ! $_ble_term_dsl && $_ble_term_fsl ]] && + _ble_term_dsl=$_ble_term_tsl$_ble_term_fsl + ble/init:term/define-cap _ble_term_sgr0 $'\e[m' sgr0:me + ble/init:term/define-cap _ble_term_bold $'\e[1m' bold:md + ble/init:term/define-cap _ble_term_blink $'\e[5m' blink:mb + ble/init:term/define-cap _ble_term_rev $'\e[7m' rev:mr + ble/init:term/define-cap _ble_term_invis $'\e[8m' invis:mk + ble/init:term/define-sgr-param _ble_term_sgr_bold "$_ble_term_bold" 1 + ble/init:term/define-sgr-param _ble_term_sgr_blink "$_ble_term_blink" 5 + ble/init:term/define-sgr-param _ble_term_sgr_rev "$_ble_term_rev" 7 + ble/init:term/define-sgr-param _ble_term_sgr_invis "$_ble_term_invis" 8 + ble/init:term/define-cap _ble_term_sitm $'\e[3m' sitm:ZH + ble/init:term/define-cap _ble_term_ritm $'\e[23m' ritm:ZR + ble/init:term/define-cap _ble_term_smul $'\e[4m' smul:us + ble/init:term/define-cap _ble_term_rmul $'\e[24m' rmul:ue + ble/init:term/define-cap _ble_term_smso $'\e[7m' smso:so + ble/init:term/define-cap _ble_term_rmso $'\e[27m' rmso:se + ble/init:term/define-sgr-param _ble_term_sgr_sitm "$_ble_term_sitm" 3 + ble/init:term/define-sgr-param _ble_term_sgr_ritm "$_ble_term_ritm" 23 + ble/init:term/define-sgr-param _ble_term_sgr_smul "$_ble_term_smul" 4 + ble/init:term/define-sgr-param _ble_term_sgr_rmul "$_ble_term_rmul" 24 + ble/init:term/define-sgr-param _ble_term_sgr_smso "$_ble_term_smso" 7 + ble/init:term/define-sgr-param _ble_term_sgr_rmso "$_ble_term_rmso" 27 + ble/init:term/register-varname _ble_term_sgr_rev_reset + if [[ $_ble_term_sgr_smso && $_ble_term_sgr_smso == "$_ble_term_sgr_rev" ]]; then + _ble_term_sgr_rev_reset=$_ble_term_sgr_rmso + else + _ble_term_sgr_rev_reset= + fi + ble/init:term/define-cap _ble_term_colors 8 colors:Co + local i + _ble_term_setaf=() + _ble_term_setab=() + _ble_term_sgr_af=() + _ble_term_sgr_ab=() + for ((i=0;i<16;i++)); do + local i1=$((i%8)) af= ab= + if [[ $TERM == *-direct ]]; then + if ((i<8)); then + af=$'\e[3'$i'm' + ab=$'\e[4'$i'm' + else + af=$'\e[38;5;'$i'm' + ab=$'\e[48;5;'$i'm' + fi + else + if ((i<_ble_term_colors)); then + local j1 + ((j1=(i1==3?6: + (i1==6?3: + (i1==1?4: + (i1==4?1:i1)))))) + local j=$((i-i1+j1)) + ble/util/assign af 'ble/init:term/tput setaf:AF "$i" 2>/dev/null' + [[ $af ]] || ble/util/assign af 'ble/init:term/tput setf:Sf "$j" 2>/dev/null' + ble/util/assign ab 'ble/init:term/tput setab:AB "$i" 2>/dev/null' + [[ $ab ]] || ble/util/assign ab 'ble/init:term/tput setb:Sb "$j" 2>/dev/null' + fi + fi + [[ $af ]] || af=$'\e[3'$i1'm' + [[ $ab ]] || ab=$'\e[4'$i1'm' + _ble_term_setaf[i]=$af + _ble_term_setab[i]=$ab + local ansi_sgr_af=3$i1 ansi_sgr_ab=4$i1 + ((i>=8)) && ansi_sgr_af=9$i1 ansi_sgr_ab=10$i1 + ble/init:term/define-sgr-param "_ble_term_sgr_af[i]" "$af" "$ansi_sgr_af" + ble/init:term/define-sgr-param "_ble_term_sgr_ab[i]" "$ab" "$ansi_sgr_ab" + done + ble/init:term/register-varname "_ble_term_setaf" + ble/init:term/register-varname "_ble_term_setab" + ble/init:term/register-varname "_ble_term_sgr_af" + ble/init:term/register-varname "_ble_term_sgr_ab" + ble/util/declare-print-definitions "${varnames[@]}" >| "$_ble_base_cache/term.$TERM" +} +ble/util/put "ble/term.sh: updating tput cache for TERM=$TERM... " >&2 +ble/init:term/initialize +ble/util/print $'\r'"ble/term.sh: updating tput cache for TERM=$TERM... done" >&2 +return 0 diff --git a/.local/share/blesh/lib/keymap.emacs.sh b/.local/share/blesh/lib/keymap.emacs.sh new file mode 100644 index 0000000..715084c --- /dev/null +++ b/.local/share/blesh/lib/keymap.emacs.sh @@ -0,0 +1,223 @@ +# Copyright 2015 Koichi Murase . All rights reserved. +# This script is a part of blesh (https://github.com/akinomyoga/ble.sh) +# provided under the BSD-3-Clause license. Do not edit this file because this +# is not the original source code: Various pre-processing has been applied. +# Also, the code comments and blank lines are stripped off in the installation +# process. Please find the corresponding source file(s) in the repository +# "akinomyoga/ble.sh". +# +# Source: /lib/keymap.emacs.sh +ble/is-function ble-edit/bind/load-editing-mode:emacs && return 0 +function ble-edit/bind/load-editing-mode:emacs { return 0; } +ble/util/autoload "$_ble_base/lib/keymap.vi.sh" \ + ble/widget/vi-rlfunc/{prev,end,next}-word \ + ble/widget/vi-command/{forward,backward}-{v,u}word \ + ble/widget/vi-command/forward-{v,u}word-end +bleopt/declare -v keymap_emacs_mode_string_multiline $'\e[1m-- MULTILINE --\e[m' +_ble_keymap_emacs_white_list=( + self-insert + batch-insert + nop + magic-space magic-slash + copy{,-forward,-backward}-{c,f,s,u}word + copy-region{,-or} + clear-screen + command-help + display-shell-version + redraw-line +) +function ble/keymap:emacs/is-command-white { + if [[ $1 == ble/widget/self-insert ]]; then + return 0 + elif [[ $1 == ble/widget/* ]]; then + local IFS=$_ble_term_IFS + local cmd=${1#ble/widget/}; cmd=${cmd%%["$_ble_term_IFS"]*} + [[ $cmd == emacs/* || " ${_ble_keymap_emacs_white_list[*]} " == *" $cmd "* ]] && return 0 + fi + return 1 +} +function ble/widget/emacs/__before_widget__ { + if ! ble/keymap:emacs/is-command-white "$WIDGET"; then + ble-edit/undo/add + fi +} +function ble/widget/emacs/undo { + local arg; ble-edit/content/get-arg 1 + ble-edit/undo/undo "$arg" || ble/widget/.bell 'no more older undo history' +} +function ble/widget/emacs/redo { + local arg; ble-edit/content/get-arg 1 + ble-edit/undo/redo "$arg" || ble/widget/.bell 'no more recent undo history' +} +function ble/widget/emacs/revert { + local arg; ble-edit/content/clear-arg + ble-edit/undo/revert +} +function ble/keymap:emacs/.get-emacs-keymap { + ble/prompt/unit/add-hash '$_ble_decode_keymap,${_ble_decode_keymap_stack[*]}' + local i=${#_ble_decode_keymap_stack[@]} + keymap=$_ble_decode_keymap + while [[ $keymap != vi_?map && $keymap != emacs ]]; do + ((i--)) || return 1 + keymap=${_ble_decode_keymap_stack[i]} + done + [[ $keymap == emacs ]] +} +bleopt/declare -v prompt_emacs_mode_indicator '\q{keymap:emacs/mode-indicator}' +function bleopt/check:prompt_emacs_mode_indicator { + local bleopt_prompt_emacs_mode_indicator=$value + [[ $_ble_attached ]] && ble/keymap:emacs/update-mode-indicator + return 0 +} +_ble_keymap_emacs_mode_indicator_data=() +function ble/prompt/unit:_ble_keymap_emacs_mode_indicator/update { + local trace_opts=truncate:relative:noscrc:ansi + local prompt_rows=1 + local prompt_cols=${COLUMNS:-80} + ((prompt_cols&&prompt_cols--)) + local "${_ble_prompt_cache_vars[@]/%/=}" # WA #D1570 checked + ble/prompt/unit:{section}/update _ble_keymap_emacs_mode_indicator "$bleopt_prompt_emacs_mode_indicator" "$trace_opts" +} +function ble/keymap:emacs/update-mode-indicator { + local keymap + ble/keymap:emacs/.get-emacs-keymap || return 0 + local opt_multiline= + [[ $_ble_edit_str == *$'\n'* ]] && opt_multiline=1 + local footprint=$opt_multiline:$_ble_edit_arg:$_ble_edit_kbdmacro_record + [[ $footprint == "$_ble_keymap_emacs_modeline" ]] && return 0 + _ble_keymap_emacs_modeline=$footprint + local version=$COLUMNS,$_ble_edit_lineno,$_ble_history_count,$_ble_edit_CMD + local prompt_hashref_base='$version' + ble/prompt/unit#update _ble_keymap_emacs_mode_indicator + local ret; ble/prompt/unit:{section}/get _ble_keymap_emacs_mode_indicator; local str=$ret + [[ $_ble_edit_arg ]] && + str=${str:+"$str "}$'(arg: \e[1;34m'$_ble_edit_arg$'\e[m)' + [[ $_ble_edit_kbdmacro_record ]] && + str=${str:+"$str "}$'\e[1;31mREC\e[m' + ble/edit/info/default ansi "$str" +} +blehook internal_PRECMD!=ble/keymap:emacs/update-mode-indicator +function ble/prompt/backslash:keymap:emacs/mode-indicator { + ble/prompt/unit/add-hash '$_ble_edit_str' + [[ $_ble_edit_str == *$'\n'* ]] || return 0 + ble/prompt/unit/add-hash '$bleopt_keymap_emacs_mode_string_multiline' + local str=$bleopt_keymap_emacs_mode_string_multiline + ble/prompt/unit/add-hash '${_ble_edit_arg:+1}${_ble_edit_kbdmacro_record:+1}' + if [[ ! ${_ble_edit_arg:+1}${_ble_edit_kbdmacro_record:+1} ]]; then + local keybinding_C_m=${_ble_decode_emacs_kmap_[_ble_decode_Ctrl|0x6d]} + local keybinding_C_j=${_ble_decode_emacs_kmap_[_ble_decode_Ctrl|0x6a]} + [[ $keybinding_C_m == *:ble/widget/accept-single-line-or-newline ]] && + [[ $keybinding_C_j == *:ble/widget/accept-line ]] && + str=${str:+"$str "}$'(\e[35mRET\e[m or \e[35mC-m\e[m: insert a newline, \e[35mC-j\e[m: run)' + fi + [[ ! $str ]] || ble/prompt/print "$str" +} +function ble/widget/emacs/__after_widget__ { + ble/keymap:emacs/update-mode-indicator +} +function ble/widget/emacs/quoted-insert-char { + _ble_edit_mark_active= + _ble_decode_char__hook=ble/widget/emacs/quoted-insert-char.hook + return 147 +} +function ble/widget/emacs/quoted-insert-char.hook { + ble/widget/quoted-insert-char.hook + ble/keymap:emacs/update-mode-indicator +} +function ble/widget/emacs/quoted-insert { + _ble_edit_mark_active= + _ble_decode_key__hook=ble/widget/emacs/quoted-insert.hook + return 147 +} +function ble/widget/emacs/quoted-insert.hook { + ble/widget/quoted-insert.hook + ble/keymap:emacs/update-mode-indicator +} +function ble/widget/emacs/bracketed-paste { + ble/widget/bracketed-paste + _ble_edit_bracketed_paste_proc=ble/widget/emacs/bracketed-paste.proc + return 147 +} +function ble/widget/emacs/bracketed-paste.proc { + ble/widget/bracketed-paste.proc "$@" + ble/keymap:emacs/update-mode-indicator +} +function ble/widget/emacs/execute-named-command/accept.hook { + ble/keymap:emacs/update-mode-indicator + ble/widget/execute-named-command/accept.hook "$1" +} +function ble/widget/emacs/execute-named-command { + ble/edit/async-read-mode 'ble/widget/emacs/execute-named-command/accept.hook' + _ble_edit_PS1='!' + _ble_edit_async_read_before_widget=ble/edit/async-read-mode/empty-cancel.hook + ble/history/set-prefix _ble_edit_rlfunc + return 147 +} +function ble-decode/keymap:emacs/define { + local ble_bind_nometa= + ble-decode/keymap:safe/bind-common + ble-decode/keymap:safe/bind-history + ble-decode/keymap:safe/bind-complete + ble-decode/keymap:safe/bind-arg + ble-bind -f 'C-d' 'delete-region-or delete-forward-char-or-exit' + ble-bind -f 'M-^' history-expand-line + ble-bind -f 'SP' magic-space + ble-bind -f '/' magic-slash + ble-bind -f __attach__ safe/__attach__ + ble-bind -f __before_widget__ emacs/__before_widget__ + ble-bind -f __after_widget__ emacs/__after_widget__ + ble-bind -f __line_limit__ __line_limit__ + ble-bind -f 'C-c' discard-line + ble-bind -f 'C-j' accept-line + ble-bind -f 'C-RET' accept-line + ble-bind -f 'C-m' accept-single-line-or-newline + ble-bind -f 'RET' accept-single-line-or-newline + ble-bind -f 'C-o' accept-and-next + ble-bind -f 'C-x C-e' edit-and-execute-command + ble-bind -f 'M-#' insert-comment + ble-bind -f 'M-C-e' shell-expand-line + ble-bind -f 'M-&' tilde-expand + ble-bind -f 'C-g' bell + ble-bind -f 'C-x C-g' bell + ble-bind -f 'C-M-g' bell + ble-bind -f 'C-l' clear-screen + ble-bind -f 'C-M-l' redraw-line + ble-bind -f 'f1' command-help + ble-bind -f 'C-x C-v' display-shell-version + ble-bind -c 'C-z' fg + ble-bind -f 'M-z' zap-to-char + ble-bind -f 'C-\' bell + ble-bind -f 'C-^' bell + ble-bind -f 'C-_' emacs/undo + ble-bind -f 'C-DEL' emacs/undo + ble-bind -f 'C-BS' emacs/undo + ble-bind -f 'C-/' emacs/undo + ble-bind -f 'C-x u' emacs/undo + ble-bind -f 'C-x C-u' emacs/undo + ble-bind -f 'C-x U' emacs/redo + ble-bind -f 'C-x C-S-u' emacs/redo + ble-bind -f 'M-r' emacs/revert + ble-bind -f 'C-q' emacs/quoted-insert + ble-bind -f 'C-v' emacs/quoted-insert + ble-bind -f paste_begin emacs/bracketed-paste + ble-bind -f 'M-x' emacs/execute-named-command +} +function ble-decode/keymap:emacs/initialize { + local fname_keymap_cache=$_ble_base_cache/keymap.emacs + if [[ -s $fname_keymap_cache && + $fname_keymap_cache -nt $_ble_base/lib/keymap.emacs.sh && + $fname_keymap_cache -nt $_ble_base/lib/init-cmap.sh ]]; then + source "$fname_keymap_cache" && return 0 + fi + ble/edit/info/immediate-show text "ble.sh: updating cache/keymap.emacs..." + { + ble/decode/keymap#load isearch dump + ble/decode/keymap#load nsearch dump + ble/decode/keymap#load emacs dump + } 3>| "$fname_keymap_cache" + ble/edit/info/immediate-show text "ble.sh: updating cache/keymap.emacs... done" +} +ble-decode/keymap:emacs/initialize +ble_bind_keymap=emacs blehook/invoke keymap_load +ble_bind_keymap=emacs blehook/invoke keymap_emacs_load +return 0 diff --git a/.local/share/blesh/lib/keymap.vi.sh b/.local/share/blesh/lib/keymap.vi.sh new file mode 100644 index 0000000..2e9c773 --- /dev/null +++ b/.local/share/blesh/lib/keymap.vi.sh @@ -0,0 +1,6424 @@ +# Copyright 2015 Koichi Murase . All rights reserved. +# This script is a part of blesh (https://github.com/akinomyoga/ble.sh) +# provided under the BSD-3-Clause license. Do not edit this file because this +# is not the original source code: Various pre-processing has been applied. +# Also, the code comments and blank lines are stripped off in the installation +# process. Please find the corresponding source file(s) in the repository +# "akinomyoga/ble.sh". +# +# Source: /lib/keymap.vi.sh +ble/is-function ble-edit/bind/load-editing-mode:vi && return 0 +function ble-edit/bind/load-editing-mode:vi { return 0; } +source "$_ble_base/lib/keymap.vi_digraph.sh" +bleopt/declare -n keymap_vi_macro_depth 64 +function ble/keymap:vi/k2c { + local key=$1 + local flag=$((key&_ble_decode_MaskFlag)) char=$((key&_ble_decode_MaskChar)) + if ((flag==0&&(32<=char&&char<_ble_decode_FunctionKeyBase))); then + ret=$char + return 0 + elif ((flag==_ble_decode_Ctrl&&63<=char&&char<128&&(char&0x1F)!=0)); then + ((char=char==63?127:char&0x1F)) + ret=$char + return 0 + else + return 1 + fi +} +function ble/string#index-of-chars { + local chars=$2 index=${3:-0} + local text=${1:index} + local cut=${text%%["$chars"]*} + if ((${#cut}<${#text})); then + ((ret=index+${#cut})) + return 0 + else + ret=-1 + return 1 + fi +} +function ble/string#last-index-of-chars { + local text=$1 chars=$2 index=$3 + [[ $index ]] && text=${text::index} + local cut=${text%["$chars"]*} + if ((${#cut}<${#text})); then + ((ret=${#cut})) + return 0 + else + ret=-1 + return 1 + fi +} +function ble-edit/content/nonbol-eolp { + local pos=${1:-$_ble_edit_ind} + ! ble-edit/content/bolp "$pos" && ble-edit/content/eolp "$pos" +} +function ble/keymap:vi/string#encode-rot13 { + local text=$1 + local -a buff=() ch + for ((i=0;i<${#text};i++)); do + ch=${text:i:1} + if ble/string#isupper "$ch"; then + ch=${_ble_util_string_upper_list%%"$ch"*} + ch=${_ble_util_string_upper_list:(${#ch}+13)%26:1} + elif ble/string#islower "$ch"; then + ch=${_ble_util_string_lower_list%%"$ch"*} + ch=${_ble_util_string_lower_list:(${#ch}+13)%26:1} + fi + ble/array#push buff "$ch" + done + IFS= builtin eval 'ret="${buff[*]-}"' +} +_ble_keymap_vi_REX_WORD=$'[_a-zA-Z0-9]+|[!-/:-@[-`{-~]+|[^ \t\na-zA-Z0-9!-/:-@[-`{-~]+' +function ble/widget/vi_imap/__default__ { + local flag=$((KEYS[0]&_ble_decode_MaskFlag)) code=$((KEYS[0]&_ble_decode_MaskChar)) + if ((flag&_ble_decode_Meta)); then + ble/keymap:vi/imap-repeat/pop + local esc=27 # ESC + ((flag&=~_ble_decode_Meta)) + ((flag==_ble_decode_Shft&&0x61<=code&&code<=0x7A&&(flag=0,code-=0x20))) + ble/decode/widget/redispatch-by-keys "$esc" "$((flag|code))" "${KEYS[@]:1}" + return 0 + fi + if local ret; ble/keymap:vi/k2c "${KEYS[0]}"; then + local -a KEYS; KEYS=("$ret") + ble/widget/self-insert + return 0 + fi + return 125 +} +function ble/widget/vi-command/decompose-meta { + local flag=$((KEYS[0]&_ble_decode_MaskFlag)) code=$((KEYS[0]&_ble_decode_MaskChar)) + if ((flag&_ble_decode_Meta)); then + local esc=$((_ble_decode_Ctrl|0x5b)) # C-[ (もしくは esc=27 ESC?) + ((flag&=~_ble_decode_Meta)) + ((flag==_ble_decode_Shft&&0x61<=code&&code<=0x7A&&(flag=0,code-=0x20))) + ble/decode/widget/redispatch-by-keys "$esc" "$((flag|code))" "${KEYS[@]:1}" + return 0 + fi + return 125 +} +function ble/widget/vi_omap/__default__ { + ble/widget/vi-command/decompose-meta || ble/widget/vi-command/bell + return 0 +} +function ble/widget/vi_omap/cancel { + ble/keymap:vi/adjust-command-mode + return 0 +} +_ble_keymap_vi_irepeat_count= +_ble_keymap_vi_irepeat=() +ble/array#push _ble_textarea_local_VARNAMES \ + _ble_keymap_vi_irepeat_count \ + _ble_keymap_vi_irepeat +function ble/keymap:vi/imap-repeat/pop { + local top_index=$((${#_ble_keymap_vi_irepeat[*]}-1)) + ((top_index>=0)) && builtin unset -v '_ble_keymap_vi_irepeat[top_index]' +} +function ble/keymap:vi/imap-repeat/push { + local IFS=$_ble_term_IFS + ble/array#push _ble_keymap_vi_irepeat "${KEYS[*]-}:$WIDGET" +} +function ble/keymap:vi/imap-repeat/reset { + local count=${1-} + _ble_keymap_vi_irepeat_count= + _ble_keymap_vi_irepeat=() + ((count>1)) && _ble_keymap_vi_irepeat_count=$count +} +function ble/keymap:vi/imap-repeat/process { + if ((_ble_keymap_vi_irepeat_count>1)); then + local repeat=$_ble_keymap_vi_irepeat_count + local -a widgets; widgets=("${_ble_keymap_vi_irepeat[@]}") + local i widget + for ((i=1;i=0)); then + ble/keymap:vi/mark/end-edit-area + ble/keymap:vi/repeat/record-insert + ble/keymap:vi/mark/start-edit-area + fi + ble/keymap:vi/imap-repeat/reset + fi +} +function ble/widget/vi_imap/complete { + ble/keymap:vi/imap-repeat/pop + ble/keymap:vi/undo/add more + ble/widget/complete "$@" +} +function ble/keymap:vi/complete/insert.hook { + [[ $_ble_decode_keymap == vi_imap || + $_ble_decode_keymap == auto_complete ]] || return 1 + local original=${comp_text:insert_beg:insert_end-insert_beg} + local q="'" Q="'\''" + local WIDGET="ble/widget/complete-insert '${original//$q/$Q}' '${insert//$q/$Q}' '${suffix//$q/$Q}'" + ble/keymap:vi/imap-repeat/push + [[ $_ble_decode_keymap == vi_imap ]] && + ble/keymap:vi/undo/add more +} +blehook complete_insert!=ble/keymap:vi/complete/insert.hook +function ble-decode/keymap:vi_imap/bind-complete { + ble-bind -f 'C-i' 'vi_imap/complete' + ble-bind -f 'TAB' 'vi_imap/complete' + ble-bind -f 'C-TAB' 'menu-complete' + ble-bind -f 'S-C-i' 'menu-complete backward' + ble-bind -f 'S-TAB' 'menu-complete backward' + ble-bind -f 'auto_complete_enter' 'auto-complete-enter' + ble-bind -f 'C-x /' 'menu-complete context=filename' + ble-bind -f 'C-x ~' 'menu-complete context=username' + ble-bind -f 'C-x $' 'menu-complete context=variable' + ble-bind -f 'C-x @' 'menu-complete context=hostname' + ble-bind -f 'C-x !' 'menu-complete context=command' + ble-bind -f 'C-]' 'sabbrev-expand' + ble-bind -f 'C-x C-r' 'dabbrev-expand' + ble-bind -f 'C-x *' 'complete insert_all:context=glob' + ble-bind -f 'C-x g' 'complete show_menu:context=glob' +} +_ble_keymap_vi_insert_overwrite= +_ble_keymap_vi_insert_leave= +_ble_keymap_vi_single_command= +_ble_keymap_vi_single_command_overwrite= +ble/array#push _ble_textarea_local_VARNAMES \ + _ble_keymap_vi_insert_overwrite \ + _ble_keymap_vi_insert_leave \ + _ble_keymap_vi_single_command \ + _ble_keymap_vi_single_command_overwrite +bleopt/declare -n keymap_vi_mode_string_nmap $'\e[1m~\e[m' +bleopt/declare -o keymap_vi_nmap_name keymap_vi_mode_string_nmap +bleopt/declare -v term_vi_imap '' +bleopt/declare -v term_vi_nmap '' +bleopt/declare -v term_vi_omap '' +bleopt/declare -v term_vi_xmap '' +bleopt/declare -v term_vi_smap '' +bleopt/declare -v term_vi_cmap '' +bleopt/declare -v keymap_vi_imap_cursor '' +bleopt/declare -v keymap_vi_nmap_cursor '' +bleopt/declare -v keymap_vi_omap_cursor '' +bleopt/declare -v keymap_vi_xmap_cursor '' +bleopt/declare -v keymap_vi_smap_cursor '' +bleopt/declare -v keymap_vi_cmap_cursor '' +function ble/keymap:vi/.process-cursor-options { + local keymap=${FUNCNAME[1]#bleopt/check:keymap_}; keymap=${keymap%_cursor} + ble-bind -m "$keymap" --cursor "$value" + local locate=$'\e[32m'$bleopt_source:$bleopt_lineno$'\e[m' + ble/util/print-lines \ + "bleopt ($locate): The option 'keymap_${keymap}_cursor' has been removed." \ + " Please use 'ble-bind -m $keymap --cursor $value' instead." >&2 +} +function bleopt/check:keymap_vi_imap_cursor { ble/keymap:vi/.process-cursor-options; } +function bleopt/check:keymap_vi_nmap_cursor { ble/keymap:vi/.process-cursor-options; } +function bleopt/check:keymap_vi_omap_cursor { ble/keymap:vi/.process-cursor-options; } +function bleopt/check:keymap_vi_xmap_cursor { ble/keymap:vi/.process-cursor-options; } +function bleopt/check:keymap_vi_smap_cursor { ble/keymap:vi/.process-cursor-options; } +function bleopt/check:keymap_vi_cmap_cursor { ble/keymap:vi/.process-cursor-options; } +function bleopt/obsolete:keymap_vi_imap_cursor { return 0; } +function bleopt/obsolete:keymap_vi_nmap_cursor { return 0; } +function bleopt/obsolete:keymap_vi_omap_cursor { return 0; } +function bleopt/obsolete:keymap_vi_xmap_cursor { return 0; } +function bleopt/obsolete:keymap_vi_smap_cursor { return 0; } +function bleopt/obsolete:keymap_vi_cmap_cursor { return 0; } +bleopt/declare -v keymap_vi_mode_show 1 +function bleopt/check:keymap_vi_mode_show { + local bleopt_keymap_vi_mode_show=$value + [[ $_ble_attached ]] && + ble/keymap:vi/update-mode-indicator + return 0 +} +bleopt/declare -v keymap_vi_mode_update_prompt '' +bleopt/declare -v keymap_vi_mode_name_insert 'INSERT' +bleopt/declare -v keymap_vi_mode_name_replace 'REPLACE' +bleopt/declare -v keymap_vi_mode_name_vreplace 'VREPLACE' +bleopt/declare -v keymap_vi_mode_name_visual 'VISUAL' +bleopt/declare -v keymap_vi_mode_name_select 'SELECT' +bleopt/declare -v keymap_vi_mode_name_linewise 'LINE' +bleopt/declare -v keymap_vi_mode_name_blockwise 'BLOCK' +function bleopt/check:keymap_vi_mode_name_insert { ble/keymap:vi/update-mode-indicator; } +function bleopt/check:keymap_vi_mode_name_replace { ble/keymap:vi/update-mode-indicator; } +function bleopt/check:keymap_vi_mode_name_vreplace { ble/keymap:vi/update-mode-indicator; } +function bleopt/check:keymap_vi_mode_name_visual { ble/keymap:vi/update-mode-indicator; } +function bleopt/check:keymap_vi_mode_name_select { ble/keymap:vi/update-mode-indicator; } +function bleopt/check:keymap_vi_mode_name_linewise { ble/keymap:vi/update-mode-indicator; } +function bleopt/check:keymap_vi_mode_name_blockwise { ble/keymap:vi/update-mode-indicator; } +function ble/keymap:vi/script/get-vi-keymap { + ble/prompt/unit/add-hash '$_ble_decode_keymap,${_ble_decode_keymap_stack[*]}' + local i=${#_ble_decode_keymap_stack[@]} + keymap=$_ble_decode_keymap + while [[ $keymap != vi_?map && $keymap != emacs ]]; do + ((i--)) || return 1 + keymap=${_ble_decode_keymap_stack[i]} + done + [[ $keymap == vi_?map ]] +} +function ble/keymap:vi/script/get-mode { + ble/prompt/unit/add-hash '$_ble_decode_keymap,${_ble_decode_keymap_stack[*]}' + ble/prompt/unit/add-hash '$_ble_keymap_vi_single_command,$_ble_edit_mark_active' + mode= + local keymap; ble/keymap:vi/script/get-vi-keymap + if [[ $_ble_keymap_vi_single_command || $keymap == vi_imap ]]; then + local overwrite= + if [[ $keymap == vi_imap ]]; then + overwrite=$_ble_edit_overwrite_mode + elif [[ $keymap == vi_[noxs]map ]]; then + overwrite=$_ble_keymap_vi_single_command_overwrite + fi + case $overwrite in + ('') mode=i ;; + (R) mode=R ;; + (*) mode=$'\x12' ;; # C-r + esac + fi + case $keymap:${_ble_edit_mark_active%+} in + (vi_xmap:vi_line) mode=$mode'V' ;; + (vi_xmap:vi_block)mode=$mode$'\x16' ;; # C-v + (vi_xmap:*) mode=$mode'v' ;; + (vi_smap:vi_line) mode=$mode'S' ;; + (vi_smap:vi_block)mode=$mode$'\x13' ;; # C-s + (vi_smap:*) mode=$mode's' ;; + (vi_[no]map:*) mode=$mode'n' ;; + (vi_cmap:*) mode=$mode'c' ;; + (vi_imap:*) ;; + (*:*) mode=$mode'?' ;; + esac +} +_ble_keymap_vi_mode_name_dirty= +function ble/keymap:vi/info_reveal.hook { + [[ $_ble_keymap_vi_mode_name_dirty ]] || return 0 + _ble_keymap_vi_mode_name_dirty= + ble/keymap:vi/update-mode-indicator +} +blehook info_reveal!=ble/keymap:vi/info_reveal.hook +bleopt/declare -v prompt_vi_mode_indicator '\q{keymap:vi/mode-indicator}' +function bleopt/check:prompt_vi_mode_indicator { + local bleopt_prompt_vi_mode_indicator=$value + [[ $_ble_attached ]] && ble/keymap:vi/update-mode-indicator + return 0 +} +_ble_keymap_vi_mode_indicator_data=() +function ble/prompt/unit:_ble_keymap_vi_mode_indicator/update { + local trace_opts=truncate:relative:noscrc:ansi + local prompt_rows=1 + local prompt_cols=${COLUMNS:-80} + ((prompt_cols&&prompt_cols--)) + local "${_ble_prompt_cache_vars[@]/%/=}" # WA #D1570 checked + ble/prompt/unit:{section}/update _ble_keymap_vi_mode_indicator "$bleopt_prompt_vi_mode_indicator" "$trace_opts" +} +function ble/keymap:vi/update-mode-indicator { + if [[ ! $_ble_attached ]] || ble/edit/is-command-layout; then + _ble_keymap_vi_mode_name_dirty=1 + return 0 + fi + local keymap + ble/keymap:vi/script/get-vi-keymap || return 0 + if [[ $keymap == vi_imap ]]; then + ble/util/buffer "$bleopt_term_vi_imap" + elif [[ $keymap == vi_nmap ]]; then + ble/util/buffer "$bleopt_term_vi_nmap" + elif [[ $keymap == vi_xmap ]]; then + ble/util/buffer "$bleopt_term_vi_xmap" + elif [[ $keymap == vi_smap ]]; then + ble/util/buffer "$bleopt_term_vi_smap" + elif [[ $keymap == vi_omap ]]; then + ble/util/buffer "$bleopt_term_vi_omap" + elif [[ $keymap == vi_cmap ]]; then + ble/edit/info/default text '' + ble/util/buffer "$bleopt_term_vi_cmap" + return 0 + fi + [[ $bleopt_keymap_vi_mode_update_prompt ]] && ble/prompt/clear + local prompt_vi_keymap=$keymap + local version=$COLUMNS,$_ble_edit_lineno,$_ble_history_count,$_ble_edit_CMD + local prompt_hashref_base='$version' + ble/prompt/unit#update _ble_keymap_vi_mode_indicator + local ret; ble/prompt/unit:{section}/get _ble_keymap_vi_mode_indicator; local mode=$ret + local str=$mode + if [[ $_ble_keymap_vi_reg_record ]]; then + str=$str${str:+' '}$'\e[1;31mREC @'$_ble_keymap_vi_reg_record_char$'\e[m' + elif [[ $_ble_edit_kbdmacro_record ]]; then + str=$str${str:+' '}$'\e[1;31mREC\e[m' + fi + if [[ $_ble_edit_integration_mc_precmd_stop && $keymap == vi_imap ]]; then + ble/edit/info/clear + return 0 + fi + ble/edit/info/default ansi "$str" # 6ms +} +blehook internal_PRECMD!=ble/keymap:vi/update-mode-indicator +function ble/prompt/backslash:keymap:vi/mode-indicator { + [[ $bleopt_keymap_vi_mode_show ]] || return 0 + local keymap=${prompt_vi_keymap-} + if [[ $keymap ]]; then + ble/prompt/unit/add-hash '$_ble_decode_keymap,${_ble_decode_keymap_stack[*]}' + else + ble/keymap:vi/script/get-vi-keymap || return 0 + fi + local name= show= overwrite= + ble/prompt/unit/add-hash '$_ble_edit_overwrite_mode,$_ble_keymap_vi_single_command,$_ble_keymap_vi_single_command_overwrite' + if [[ $keymap == vi_imap ]]; then + show=1 overwrite=$_ble_edit_overwrite_mode + elif [[ $_ble_keymap_vi_single_command && ( $keymap == vi_nmap || $keymap == vi_omap ) ]]; then + show=1 overwrite=$_ble_keymap_vi_single_command_overwrite + elif [[ $keymap == vi_[xs]map ]]; then + show=x overwrite=$_ble_keymap_vi_single_command_overwrite + else + name=$bleopt_keymap_vi_mode_string_nmap + fi + if [[ $show ]]; then + if [[ $overwrite == R ]]; then + name=$bleopt_keymap_vi_mode_name_replace + elif [[ $overwrite ]]; then + name=$bleopt_keymap_vi_mode_name_vreplace + else + name=$bleopt_keymap_vi_mode_name_insert + fi + if [[ $_ble_keymap_vi_single_command ]]; then + local ret; ble/string#tolower "$name"; name="($ret)" + fi + if [[ $show == x ]]; then + ble/prompt/unit/add-hash '${_ble_edit_mark_active%+}' + local mark_type=${_ble_edit_mark_active%+} + local visual_name=$bleopt_keymap_vi_mode_name_visual + [[ $keymap == vi_smap ]] && visual_name=$bleopt_keymap_vi_mode_name_select + if [[ $mark_type == vi_line ]]; then + visual_name=$visual_name' '$bleopt_keymap_vi_mode_name_linewise + elif [[ $mark_type == vi_block ]]; then + visual_name=$visual_name' '$bleopt_keymap_vi_mode_name_blockwise + fi + if [[ $_ble_keymap_vi_single_command ]]; then + name="$name $visual_name" + else + name=$visual_name + fi + fi + name=$'\e[1m-- '$name$' --\e[m' + fi + [[ ! $name ]] || ble/prompt/print "$name" +} +function ble/widget/vi_imap/normal-mode.impl { + local opts=$1 + ble/keymap:vi/mark/set-local-mark 94 "$_ble_edit_ind" # `^ + ble/keymap:vi/mark/end-edit-area + [[ :$opts: == *:InsertLeave:* ]] && builtin eval -- "$_ble_keymap_vi_insert_leave" + _ble_edit_mark_active= + _ble_edit_overwrite_mode= + _ble_keymap_vi_insert_leave= + _ble_keymap_vi_single_command= + _ble_keymap_vi_single_command_overwrite= + ble-edit/content/bolp || ((_ble_edit_ind--)) + ble/decode/keymap/push vi_nmap +} +function ble/widget/vi_imap/normal-mode { + ble-edit/content/clear-arg + ble/keymap:vi/imap-repeat/pop + ble/keymap:vi/imap-repeat/process + ble/keymap:vi/repeat/record-insert + ble/widget/vi_imap/normal-mode.impl InsertLeave + ble/keymap:vi/update-mode-indicator + return 0 +} +function ble/widget/vi_imap/normal-mode-without-insert-leave { + ble-edit/content/clear-arg + ble/keymap:vi/imap-repeat/pop + ble/keymap:vi/repeat/record-insert + ble/widget/vi_imap/normal-mode.impl + ble/keymap:vi/update-mode-indicator + return 0 +} +function ble/widget/vi_imap/single-command-mode { + ble-edit/content/clear-arg + local single_command=1 + local single_command_overwrite=$_ble_edit_overwrite_mode + ble-edit/content/eolp && _ble_keymap_vi_single_command=2 + ble/keymap:vi/imap-repeat/pop + ble/widget/vi_imap/normal-mode.impl + _ble_keymap_vi_single_command=$single_command + _ble_keymap_vi_single_command_overwrite=$single_command_overwrite + ble/keymap:vi/update-mode-indicator + return 0 +} +function ble/keymap:vi/needs-eol-fix { + [[ $_ble_decode_keymap == vi_nmap || $_ble_decode_keymap == vi_omap ]] || return 1 + [[ $_ble_keymap_vi_single_command ]] && return 1 + local index=${1:-$_ble_edit_ind} + ble-edit/content/nonbol-eolp "$index" +} +function ble/keymap:vi/adjust-command-mode { + if [[ $_ble_decode_keymap == vi_[xs]map ]]; then + ble/keymap:vi/xmap/remove-eol-extension + fi + local kmap_popped= + if [[ $_ble_decode_keymap == vi_omap ]]; then + ble/decode/keymap/pop + kmap_popped=1 + fi + if [[ $_ble_keymap_vi_search_activate ]]; then + if [[ $_ble_decode_keymap != vi_[xs]map ]]; then + _ble_edit_mark_active=$_ble_keymap_vi_search_activate + fi + _ble_keymap_vi_search_matched=1 + _ble_keymap_vi_search_activate= + else + [[ $_ble_edit_mark_active == vi_search ]] && _ble_edit_mark_active= + ((_ble_keymap_vi_search_matched)) && _ble_keymap_vi_search_matched= + fi + if [[ $_ble_decode_keymap == vi_nmap && $_ble_keymap_vi_single_command ]]; then + if ((_ble_keymap_vi_single_command==2)); then + local index=$((_ble_edit_ind+1)) + ble-edit/content/nonbol-eolp "$index" && _ble_edit_ind=$index + fi + ble/widget/vi_nmap/.insert-mode 1 "$_ble_keymap_vi_single_command_overwrite" resume + ble/keymap:vi/repeat/clear-insert + elif [[ $kmap_popped ]]; then + ble/keymap:vi/update-mode-indicator + fi + return 0 +} +function ble/widget/vi-command/bell { + ble/widget/.bell "$1" + ble/keymap:vi/adjust-command-mode + return 0 +} +function ble/widget/vi_nmap/.insert-mode { + [[ $_ble_decode_keymap == vi_[xs]map ]] && ble/decode/keymap/pop + [[ $_ble_decode_keymap == vi_omap ]] && ble/decode/keymap/pop + local arg=$1 overwrite=$2 + ble/keymap:vi/imap-repeat/reset "$arg" + _ble_edit_mark_active= + _ble_edit_overwrite_mode=$overwrite + _ble_keymap_vi_insert_leave= + _ble_keymap_vi_insert_overwrite=$overwrite + _ble_keymap_vi_single_command= + _ble_keymap_vi_single_command_overwrite= + ble/keymap:vi/search/clear-matched + ble/decode/keymap/pop + ble/keymap:vi/update-mode-indicator + ble/keymap:vi/mark/start-edit-area + if [[ :$opts: != *:resume:* ]]; then + ble/keymap:vi/mark/commit-edit-area "$_ble_edit_ind" "$_ble_edit_ind" + fi +} +function ble/widget/vi_nmap/insert-mode { + local ARG FLAG REG; ble/keymap:vi/get-arg 1 + ble/widget/vi_nmap/.insert-mode "$ARG" + ble/keymap:vi/repeat/record + return 0 +} +function ble/widget/vi_nmap/append-mode { + local ARG FLAG REG; ble/keymap:vi/get-arg 1 + if ! ble-edit/content/eolp; then + ((_ble_edit_ind++)) + fi + ble/widget/vi_nmap/.insert-mode "$ARG" + ble/keymap:vi/repeat/record + return 0 +} +function ble/widget/vi_nmap/append-mode-at-end-of-line { + local ARG FLAG REG; ble/keymap:vi/get-arg 1 + local ret; ble-edit/content/find-logical-eol + _ble_edit_ind=$ret + ble/widget/vi_nmap/.insert-mode "$ARG" + ble/keymap:vi/repeat/record + return 0 +} +function ble/widget/vi_nmap/insert-mode-at-beginning-of-line { + local ARG FLAG REG; ble/keymap:vi/get-arg 1 + local ret; ble-edit/content/find-logical-bol + _ble_edit_ind=$ret + ble/widget/vi_nmap/.insert-mode "$ARG" + ble/keymap:vi/repeat/record + return 0 +} +function ble/widget/vi_nmap/insert-mode-at-first-non-space { + local ARG FLAG REG; ble/keymap:vi/get-arg 1 + ble/widget/vi-command/first-non-space + [[ ${_ble_edit_str:_ble_edit_ind:1} == [$' \t'] ]] && + ((_ble_edit_ind++)) # 逆eol補正 + ble/widget/vi_nmap/.insert-mode "$ARG" + ble/keymap:vi/repeat/record + return 0 +} +function ble/widget/vi_nmap/insert-mode-at-previous-point { + local ARG FLAG REG; ble/keymap:vi/get-arg 1 + local ret + ble/keymap:vi/mark/get-local-mark 94 && _ble_edit_ind=$ret + ble/widget/vi_nmap/.insert-mode "$ARG" + ble/keymap:vi/repeat/record + return 0 +} +function ble/widget/vi_nmap/replace-mode { + local ARG FLAG REG; ble/keymap:vi/get-arg 1 + ble/widget/vi_nmap/.insert-mode "$ARG" R + ble/keymap:vi/repeat/record + return 0 +} +function ble/widget/vi_nmap/virtual-replace-mode { + local ARG FLAG REG; ble/keymap:vi/get-arg 1 + ble/widget/vi_nmap/.insert-mode "$ARG" 1 + ble/keymap:vi/repeat/record + return 0 +} +function ble/widget/vi_nmap/accept-line { + ble/keymap:vi/clear-arg + ble/widget/vi_nmap/.insert-mode + ble/keymap:vi/repeat/clear-insert + [[ $_ble_keymap_vi_reg_record ]] && + ble/widget/vi_nmap/record-register + ble/widget/default/accept-line +} +function ble/widget/vi-command/edit-and-execute-command { + ble/keymap:vi/clear-arg + ble/widget/vi_nmap/.insert-mode + ble/keymap:vi/repeat/clear-insert + [[ $_ble_keymap_vi_reg_record ]] && + ble/widget/vi_nmap/record-register + ble/widget/edit-and-execute-command +} +_ble_keymap_vi_oparg= +_ble_keymap_vi_opfunc= +_ble_keymap_vi_reg= +ble/array#push _ble_textarea_local_VARNAMES \ + _ble_keymap_vi_oparg \ + _ble_keymap_vi_opfunc \ + _ble_keymap_vi_reg +_ble_keymap_vi_register=() +_ble_keymap_vi_register_onplay= +function ble/keymap:vi/clear-arg { + _ble_edit_arg= + _ble_keymap_vi_oparg= + _ble_keymap_vi_opfunc= + _ble_keymap_vi_reg= +} +function ble/keymap:vi/get-arg { + local default_value=$1 + REG=$_ble_keymap_vi_reg + FLAG=$_ble_keymap_vi_opfunc + if [[ ! $_ble_edit_arg && ! $_ble_keymap_vi_oparg ]]; then + ARG=$default_value + else + ARG=$((10#0${_ble_edit_arg:-1}*10#0${_ble_keymap_vi_oparg:-1})) + fi + ble/keymap:vi/clear-arg +} +function ble/keymap:vi/register#load { + local reg=$1 + if [[ $reg ]] && ((reg!=34)); then + if [[ $reg == 37 ]]; then # "% + ble-edit/content/push-kill-ring "$HISTFILE" '' + return 0 + fi + local value=${_ble_keymap_vi_register[reg]} + if [[ $value == */* ]]; then + ble-edit/content/push-kill-ring "${value#*/}" "${value%%/*}" + return 0 + else + ble-edit/content/push-kill-ring + return 1 + fi + fi +} +function ble/keymap:vi/register#set { + local reg=$1 type=$2 content=$3 + if [[ $reg == +* ]]; then + local value=${_ble_keymap_vi_register[reg]} + if [[ $value == */* ]]; then + local otype=${value%%/*} + local oring=${value#*/} + if [[ $otype == L ]]; then + if [[ $type == q ]]; then + type=L content=${oring%$'\n'}$content # V + * → V + else + type=L content=$oring$content # V + * → V + fi + elif [[ $type == L ]]; then + type=L content=$oring$'\n'$content # C-v + V, v + V → V + elif [[ $otype == B:* ]]; then + if [[ $type == B:* ]]; then + type=$otype' '${type#B:} + content=$oring$'\n'$content # C-v + C-v → C-v + elif [[ $type == q ]]; then + local ret; ble/string#count-char "$content" $'\n' + ble/string#repeat ' 0' "$ret" + type=$otype$ret + content=$oring$$content # C-v + q → C-v + else + local ret; ble/string#count-char "$content" $'\n' + ble/string#repeat ' 0' "$((ret+1))" + type=$otype$ret + content=$oring$'\n'$content # C-v + v → C-v + fi + else + type= content=$oring$content # v + C-v, v + v, v + q → v + fi + fi + fi + [[ $type == L && $content != *$'\n' ]] && content=$content$'\n' + local suppress_default= + [[ $type == q ]] && type= suppress_default=1 + if [[ ! $reg ]] || ((reg==34)); then # "" + ble-edit/content/push-kill-ring "$content" "$type" + return 0 + elif ((reg==58||reg==46||reg==37||reg==126)); then # ": ". "% "~ + ble/widget/.bell "attempted to write on a read-only register #$reg" + return 1 + elif ((reg==95)); then # "_ + return 0 + else + if [[ ! $suppress_default ]]; then + ble-edit/content/push-kill-ring "$content" "$type" + fi + _ble_keymap_vi_register[reg]=$type/$content + return 0 + fi +} +function ble/keymap:vi/register#set-yank { + ble/keymap:vi/register#set "$@" || return 1 + local reg=$1 type=$2 content=$3 + if [[ $reg == '' || $reg == 34 ]]; then + ble/keymap:vi/register#set 48 "$type" "$content" # "0 + fi +} +_ble_keymap_vi_register_49_widget_list=( + ble/widget/vi-command/search-matchpair-or + ble/widget/vi-command/percentage-line + ble/widget/vi-command/goto-mark + ble/widget/vi-command/search-forward + ble/widget/vi-command/search-backward + ble/widget/vi-command/search-repeat + ble/widget/vi-command/search-reverse-repeat +) +function ble/keymap:vi/register#set-edit { + ble/keymap:vi/register#set "$@" || return 1 + local reg=$1 type=$2 content=$3 + if [[ $reg == '' || $reg == 34 ]]; then + local IFS=$_ble_term_IFS + local widget=${WIDGET%%["$_ble_term_IFS"]*} + if [[ $content == *$'\n'* || " $widget " == " ${_ble_keymap_vi_register_49_widget_list[*]} " ]]; then + local n + for ((n=9;n>=2;n--)); do + _ble_keymap_vi_register[48+n]=${_ble_keymap_vi_register[48+n-1]} + done + ble/keymap:vi/register#set 49 "$type" "$content" # "1 + else + ble/keymap:vi/register#set 45 "$type" "$content" # "- + fi + fi +} +function ble/keymap:vi/register#play { + local reg=$1 value + if [[ $reg ]] && ((reg!=34)); then + value=${_ble_keymap_vi_register[reg]} + if [[ $value == */* ]]; then + value=${value#*/} + else + value= + return 1 + fi + else + value=$_ble_edit_kill_ring + fi + local _ble_keymap_vi_register_onplay=1 + local ret; ble/decode/charlog#decode "$value" + ble/widget/.MACRO "${ret[@]}" + return 0 +} +function ble/keymap:vi/register#dump/escape { + local text=$1 + local out= i=0 iN=${#text} + while ((i=bleopt_keymap_vi_macro_depth)) || ble/util/is-stdin-ready; then + return 1 # 無限ループを防ぐため + fi + local _ble_keymap_vi_reg_record_play=$((depth+1)) + local key=$1 + local ret + if ble/keymap:vi/k2c "$key" && local c=$ret; then + ((65<=c&&c<91)) && ((c+=32)) # A-Z -> a-z + if ((48<=c&&c<58||97<=c&&c<123)); then # 0-9a-z + ble/keymap:vi/register#play "$c" && return 0 + fi + fi + ble/widget/vi-command/bell + return 1 +} +function ble/widget/vi-command/operator { + local ret opname=$1 + if [[ $_ble_decode_keymap == vi_[xs]map ]]; then + local ARG FLAG REG; ble/keymap:vi/get-arg '' + local a=$_ble_edit_ind b=$_ble_edit_mark + ((a<=b||(a=_ble_edit_mark,b=_ble_edit_ind))) + ble/widget/vi_xmap/.save-visual-state + local ble_keymap_vi_mark_active=$_ble_edit_mark_active # used in call-operator-blockwise + local mark_type=${_ble_edit_mark_active%+} + ble/widget/vi_xmap/exit + local ble_keymap_vi_opmode=$mark_type + if [[ $mark_type == vi_line ]]; then + ble/keymap:vi/call-operator-linewise "$opname" "$a" "$b" "$ARG" "$REG" + elif [[ $mark_type == vi_block ]]; then + ble/keymap:vi/call-operator-blockwise "$opname" "$a" "$b" "$ARG" "$REG" + else + local end=$b + ((end<${#_ble_edit_str}&&end++)) + ble/keymap:vi/call-operator-charwise "$opname" "$a" "$end" "$ARG" "$REG" + fi; local ext=$? + ((ext==147)) && return 147 + ((ext)) && ble/widget/.bell + ble/keymap:vi/adjust-command-mode + return "$ext" + elif [[ $_ble_decode_keymap == vi_nmap ]]; then + ble/decode/keymap/push vi_omap + _ble_keymap_vi_oparg=$_ble_edit_arg + _ble_keymap_vi_opfunc=$opname + _ble_edit_arg= + ble/keymap:vi/update-mode-indicator + elif [[ $_ble_decode_keymap == vi_omap ]]; then + local opname1=${_ble_keymap_vi_opfunc%%:*} + if [[ $opname == "$opname1" ]]; then + ble/widget/vi_nmap/linewise-operator "$_ble_keymap_vi_opfunc" + else + ble/keymap:vi/clear-arg + ble/widget/vi-command/bell + return 1 + fi + fi + return 0 +} +function ble/widget/vi_nmap/linewise-operator { + local opname=${1%%:*} opflags=${1#*:} + local ARG FLAG REG; ble/keymap:vi/get-arg 1 # _ble_edit_arg is consumed here + if ((ARG==1)) || [[ ${_ble_edit_str:_ble_edit_ind} == *$'\n'* ]]; then + if [[ :$opflags: == *:vi_char:* || :$opflags: == *:vi_block:* ]]; then + local beg=$_ble_edit_ind + local ret; ble-edit/content/find-logical-bol "$beg" "$((ARG-1))"; local end=$ret + ((beg<=end)) || local beg=$end end=$beg + if [[ :$opflags: == *:vi_block:* ]]; then + ble/keymap:vi/call-operator-blockwise "$opname" "$beg" "$end" '' "$REG" + else + ble/keymap:vi/call-operator-charwise "$opname" "$beg" "$end" '' "$REG" + fi + else + ble/keymap:vi/call-operator-linewise "$opname" "$_ble_edit_ind" "$_ble_edit_ind:$((ARG-1))" '' "$REG"; local ext=$? + fi + if ((ext==0)); then + ble/keymap:vi/adjust-command-mode + return 0 + elif ((ext==147)); then + return 147 + fi + fi + ble/widget/vi-command/bell + return 1 +} +function ble/widget/vi_nmap/copy-current-line { + ble/widget/vi_nmap/linewise-operator y +} +function ble/widget/vi_nmap/kill-current-line { + ble/widget/vi_nmap/linewise-operator d +} +function ble/widget/vi_nmap/kill-current-line-and-insert { + ble/widget/vi_nmap/linewise-operator c +} +function ble/widget/vi-command/beginning-of-line { + local ARG FLAG REG; ble/keymap:vi/get-arg 1 + local ret; ble-edit/content/find-logical-bol; local beg=$ret + ble/widget/vi-command/exclusive-goto.impl "$beg" "$FLAG" "$REG" nobell +} +function ble/keymap:vi/call-operator { + ble/keymap:vi/mark/start-edit-area + local _ble_keymap_vi_mark_suppress_edit=1 + ble/keymap:vi/operator:"$@"; local ext=$? + ble/util/unlocal _ble_keymap_vi_mark_suppress_edit + ble/keymap:vi/mark/end-edit-area + if ((ext==0)); then + if ble/is-function ble/keymap:vi/operator:"$1".record; then + ble/keymap:vi/operator:"$1".record + else + ble/keymap:vi/repeat/record + fi + fi + return "$ext" +} +function ble/keymap:vi/call-operator-charwise { + local ch=$1 beg=$2 end=$3 arg=$4 reg=$5 + ((beg<=end||(beg=$3,end=$2))) + if ble/is-function ble/keymap:vi/operator:"$ch"; then + local ble_keymap_vi_operator_index= + ble/keymap:vi/call-operator "$ch" "$beg" "$end" char "$arg" "$reg"; local ext=$? + ((ext==147)) && return 147 + local index=${ble_keymap_vi_operator_index:-$beg} + ble/keymap:vi/needs-eol-fix "$index" && ((index--)) + _ble_edit_ind=$index + return 0 + else + return 1 + fi +} +function ble/keymap:vi/call-operator-linewise { + local ch=$1 a=$2 b=$3 arg=$4 reg=$5 ia=0 ib=0 + [[ $a == *:* ]] && local a=${a%%:*} ia=${a#*:} + [[ $b == *:* ]] && local b=${b%%:*} ib=${b#*:} + local ret + ble-edit/content/find-logical-bol "$a" "$ia"; local beg=$ret + ble-edit/content/find-logical-eol "$b" "$ib"; local end=$ret + if ble/is-function ble/keymap:vi/operator:"$ch"; then + local ble_keymap_vi_operator_index= + ((end<${#_ble_edit_str}&&end++)) + ble/keymap:vi/call-operator "$ch" "$beg" "$end" line "$arg" "$reg"; local ext=$? + ((ext==147)) && return 147 + if [[ $ble_keymap_vi_operator_index ]]; then + local index=$ble_keymap_vi_operator_index + else + ble-edit/content/find-logical-bol "$beg"; beg=$ret # operator 中で beg が変更されているかも + ble-edit/content/find-non-space "$beg"; local index=$ret + fi + ble/keymap:vi/needs-eol-fix "$index" && ((index--)) + _ble_edit_ind=$index + return 0 + else + return 1 + fi +} +function ble/keymap:vi/call-operator-blockwise { + local ch=$1 beg=$2 end=$3 arg=$4 reg=$5 + if ble/is-function ble/keymap:vi/operator:"$ch"; then + local mark_active=${ble_keymap_vi_mark_active:-vi_block} + local sub_ranges sub_x1 sub_x2 + _ble_edit_mark_active=$mark_active ble/keymap:vi/extract-block "$beg" "$end" + local nrange=${#sub_ranges[@]} + ((nrange)) || return 1 + local ble_keymap_vi_operator_index= + local beg=${sub_ranges[0]}; beg=${beg%%:*} + local end=${sub_ranges[nrange-1]}; end=${end#*:}; end=${end%%:*} + ble/keymap:vi/call-operator "$ch" "$beg" "$end" block "$arg" "$reg" + ((ext==147)) && return 147 + local index=${ble_keymap_vi_operator_index:-$beg} + ble/keymap:vi/needs-eol-fix "$index" && ((index--)) + _ble_edit_ind=$index + return 0 + else + return 1 + fi +} +function ble/keymap:vi/operator:d { + local context=$3 arg=$4 reg=$5 # beg end は上書きする + if [[ $context == line ]]; then + ble/keymap:vi/register#set-edit "$reg" L "${_ble_edit_str:beg:end-beg}" || return 1 + if ((end==${#_ble_edit_str}&&beg>0)); then + local ret + ((beg--)) + ble-edit/content/find-logical-bol "$beg" + ble-edit/content/find-non-space "$ret" + ble_keymap_vi_operator_index=$ret + fi + ble/widget/.delete-range "$beg" "$end" + elif [[ $context == block ]]; then + local -a afill=() atext=() arep=() + local sub shift=0 slpad0= + local smin smax slpad srpad sfill stext + for sub in "${sub_ranges[@]}"; do + stext=${sub#*:*:*:*:*:} + ble/string#split sub : "$sub" + smin=${sub[0]} smax=${sub[1]} + slpad=${sub[2]} srpad=${sub[3]} + sfill=${sub[4]} + [[ $slpad0 ]] || slpad0=$slpad # 最初の slpad + ble/array#push afill "$sfill" + ble/array#push atext "$stext" + local ret; ble/string#repeat ' ' "$((slpad+srpad))" + ble/array#push arep "$((smin+shift)):$((smax+shift)):$ret" + ((shift+=(slpad+srpad)-(smax-smin))) + done + IFS=$'\n' builtin eval 'local yank_content="${atext[*]-}"' + local IFS=$_ble_term_IFS + local yank_type=B:"${afill[*]-}" + ble/keymap:vi/register#set-edit "$reg" "$yank_type" "$yank_content" || return 1 + local rep + for rep in "${arep[@]}"; do + smin=${rep%%:*}; rep=${rep:${#smin}+1} + smax=${rep%%:*}; rep=${rep:${#smax}+1} + ble/widget/.replace-range "$smin" "$smax" "$rep" + done + ((beg+=slpad)) # fix start position + else + if ((beg=width)); then + pad=$((c-width)) + nsp=$((smin+i+1)) + break + fi + done + local padding= + ((pad)) && { ble/string#repeat ' ' "$pad"; padding=$ret; } + ble/widget/.replace-range "$smin" "$nsp" "$padding" + done +} +function ble/keymap:vi/operator:indent.impl { + local delta=$1 context=$2 + ((delta)) || return 0 + if [[ $context == block ]]; then + if ((delta>=0)); then + ble/keymap:vi/operator:indent.impl/increase-block-indent "$delta" + elif ble/edit/use-textmap; then + ble/keymap:vi/operator:indent.impl/decrease-graphical-block-indent "$((-delta))" + else + ble/keymap:vi/operator:indent.impl/decrease-logical-block-indent "$((-delta))" + fi + else + [[ $context == char ]] && ble/keymap:vi/expand-range-for-linewise-operator + ((beg80&&(cols=80))) + ble/keymap:vi/operator:fold/.fold-paragraphwise "$old" "$cols"; local new=$ret + ble/widget/.replace-range "$beg" "$end" "$new" + if [[ :$opts: == *:preserve_point:* ]]; then + if ((end<=oind)); then + ble_keymap_vi_operator_index=$((beg+${#new})) + elif ((beg/dev/null'; then + ble/widget/vi-command/bell + return 1 + fi + new=${new%$'\n'} + ((end<${#_ble_edit_str})) && new=$new$'\n' + ble/widget/.replace-range "$beg" "$end" "$new" + _ble_edit_ind=$beg + if [[ $context == line ]]; then + ble/widget/vi-command/first-non-space + else + ble/keymap:vi/adjust-command-mode + fi + ble/keymap:vi/mark/set-previous-edit-area "$beg" "$((beg+${#new}))" + ble/keymap:vi/operator:filter/.record-repeat "$command" + return 0 +} +bleopt/declare -v keymap_vi_operatorfunc '' +function ble/keymap:vi/operator:map { + local context=$3 + if [[ $bleopt_keymap_vi_operatorfunc ]]; then + local opfunc=ble/keymap:vi/operator:$bleopt_keymap_vi_operatorfunc + if ble/is-function "$opfunc"; then + "$opfunc" "$@" + return "$?" + fi + fi + return 1 +} +function ble/widget/vi-command/exclusive-range.impl { + local src=$1 dst=$2 flag=$3 reg=$4 opts=$5 + if [[ $flag ]]; then + local opname=${flag%%:*} opflags=${flag#*:} + if [[ :$opflags: == *:vi_line:* ]]; then + local ble_keymap_vi_opmode=vi_line + ble/keymap:vi/call-operator-linewise "$opname" "$src" "$dst" '' "$reg"; local ext=$? + elif [[ :$opflags: == *:vi_block:* ]]; then + local ble_keymap_vi_opmode=vi_line + ble/keymap:vi/call-operator-blockwise "$opname" "$src" "$dst" '' "$reg"; local ext=$? + elif [[ :$opflags: == *:vi_char:* ]]; then + local ble_keymap_vi_opmode=vi_char + if [[ :$opts: == *:inclusive:* ]]; then + ((src=h)) && break + ((shift++)) + fi + done + [[ $shift ]] && + _ble_keymap_vi_mark_global[imark]=$((h-shift)):$v + done + ble/builtin/history/array#delete-hindex _ble_keymap_vi_mark_history "$@" + _ble_keymap_vi_mark_hindex= ;; + (clear) + _ble_keymap_vi_mark_global=() + _ble_keymap_vi_mark_history=() + _ble_keymap_vi_mark_hindex= ;; + (insert) + local beg=$1 len=$2 + local imark + for imark in "${!_ble_keymap_vi_mark_global[@]}"; do + local value=${_ble_keymap_vi_mark_global[imark]} + local h=${value%%:*} v=${value#*:} + ((h>=beg)) && _ble_keymap_vi_mark_global[imark]=$((h+len)):$v + done + ble/builtin/history/array#insert-range _ble_keymap_vi_mark_history "$@" + _ble_keymap_vi_mark_hindex= ;; + esac +} +function ble/keymap:vi/mark/shift-by-dirty-range { + local beg=$1 end=$2 end0=$3 reason=$4 + if [[ $4 == edit ]]; then + ble/dirty-range#update --prefix=_ble_keymap_vi_mark_edit_d "${@:1:3}" + ble/keymap:vi/xmap/update-dirty-range "$@" + ble/keymap:vi/mark/update-mark-history + local shift=$((end-end0)) + local imark + for imark in "${!_ble_keymap_vi_mark_local[@]}"; do + local value=${_ble_keymap_vi_mark_local[imark]} + local index=${value%%:*} rest=${value#*:} + ((indexlen&&(index=len))) + ble-edit/content/find-logical-bol "$index"; index=$ret + ble-edit/content/find-logical-eol "$index"; local eol=$ret + ((index+=bytes,index>eol&&(index=eol))) # ToDo: calculate by byte offset + ret=$index + return 0 +} +function ble/keymap:vi/mark/get-local-mark { + local c=$1 + ble/keymap:vi/mark/update-mark-history + local value=${_ble_keymap_vi_mark_local[c]} + [[ $value ]] || return 1 + local data + ble/string#split data : "$value" + ble/keymap:vi/mark/get-mark.impl "${data[0]}" "${data[1]}" # -> ret +} +_ble_keymap_vi_mark_suppress_edit= +function ble/keymap:vi/mark/set-previous-edit-area { + [[ $_ble_keymap_vi_mark_suppress_edit ]] && return 0 + local beg=$1 end=$2 + ((beg=0)) && ble/keymap:vi/mark/set-previous-edit-area "$beg" "$end" +} +function ble/keymap:vi/mark/set-jump { + ble/keymap:vi/mark/set-local-mark 96 "$_ble_edit_ind" +} +function ble/widget/vi-command/set-mark { + _ble_decode_key__hook="ble/widget/vi-command/set-mark.hook" + return 147 +} +function ble/widget/vi-command/set-mark.hook { + local key=$1 + ble/keymap:vi/clear-arg + local ret + if ble/keymap:vi/k2c "$key" && local c=$ret; then + if ((65<=c&&c<91)); then # A-Z + ble/keymap:vi/mark/set-global-mark "$c" "$_ble_edit_ind" + ble/keymap:vi/adjust-command-mode + return 0 + elif ((97<=c&&c<123||c==91||c==93||c==60||c==62||c==96||c==39)); then # a-z [ ] < > ` ' + ((c==39)) && c=96 # m' は m` に読み替える + ble/keymap:vi/mark/set-local-mark "$c" "$_ble_edit_ind" + ble/keymap:vi/adjust-command-mode + return 0 + fi + fi + ble/widget/vi-command/bell + return 1 +} +function ble/widget/vi-command/goto-mark.impl { + local index=$1 flag=$2 reg=$3 opts=$4 + [[ $flag ]] || ble/keymap:vi/mark/set-jump # `` + if [[ :$opts: == *:line:* ]]; then + ble/widget/vi-command/linewise-goto.impl "$index" "$flag" "$reg" + else + ble/widget/vi-command/exclusive-goto.impl "$index" "$flag" "$reg" nobell + fi +} +function ble/widget/vi-command/goto-local-mark.impl { + local c=$1 opts=$2 ret + local ARG FLAG REG; ble/keymap:vi/get-arg 1 + if ble/keymap:vi/mark/get-local-mark "$c" && local index=$ret; then + ble/widget/vi-command/goto-mark.impl "$index" "$FLAG" "$REG" "$opts" + else + ble/widget/vi-command/bell + return 1 + fi +} +function ble/widget/vi-command/goto-global-mark.impl { + local c=$1 opts=$2 + local ARG FLAG REG; ble/keymap:vi/get-arg 1 + ble/keymap:vi/mark/update-mark-history + local value=${_ble_keymap_vi_mark_global[c]} + if [[ ! $value ]]; then + ble/widget/vi-command/bell + return 1 + fi + local data + ble/string#split data : "$value" + local index; ble/history/get-index + if ((index!=data[0])); then + if [[ $FLAG ]]; then + ble/widget/vi-command/bell + return 1 + fi + ble-edit/history/goto "${data[0]}" + fi + local ret + ble/keymap:vi/mark/get-mark.impl "${data[1]}" "${data[2]}" + ble/widget/vi-command/goto-mark.impl "$ret" "$FLAG" "$REG" "$opts" +} +function ble/widget/vi-command/goto-mark { + _ble_decode_key__hook="ble/widget/vi-command/goto-mark.hook ${1:-char}" + return 147 +} +function ble/widget/vi-command/goto-mark.hook { + local opts=$1 key=$2 + local ret + if ble/keymap:vi/k2c "$key" && local c=$ret; then + if ((65<=c&&c<91)); then # A-Z + ble/widget/vi-command/goto-global-mark.impl "$c" "$opts" + return "$?" + elif ((_ble_keymap_vi_mark_Offset<=c)); then + ((c==39)) && c=96 # `' は `` に読み替える + ble/widget/vi-command/goto-local-mark.impl "$c" "$opts" + return "$?" + fi + fi + ble/keymap:vi/clear-arg + ble/widget/vi-command/bell + return 1 +} +_ble_keymap_vi_repeat=() +_ble_keymap_vi_repeat_insert=() +_ble_keymap_vi_repeat_irepeat=() +_ble_keymap_vi_repeat_invoke= +function ble/keymap:vi/repeat/record-special { + [[ $_ble_keymap_vi_mark_suppress_edit ]] && return 0 + if [[ $_ble_keymap_vi_repeat_invoke ]]; then + [[ $repeat_arg ]] && _ble_keymap_vi_repeat[3]=$repeat_arg + [[ ! ${_ble_keymap_vi_repeat[5]} ]] && _ble_keymap_vi_repeat[5]=$repeat_reg + return 0 + fi + return 1 +} +function ble/keymap:vi/repeat/record-normal { + local IFS=$_ble_term_IFS + local -a repeat; repeat=("$KEYMAP" "${KEYS[*]-}" "$WIDGET" "$ARG" "$FLAG" "$REG" '') + if [[ $KEYMAP == vi_[xs]map ]]; then + repeat[6]=$_ble_keymap_vi_xmap_prev_edit + fi + if [[ $_ble_decode_keymap == vi_imap ]]; then + _ble_keymap_vi_repeat_insert=("${repeat[@]}") + else + _ble_keymap_vi_repeat=("${repeat[@]}") + _ble_keymap_vi_repeat_irepeat=() + fi +} +function ble/keymap:vi/repeat/record { + ble/keymap:vi/repeat/record-special && return 0 + ble/keymap:vi/repeat/record-normal +} +function ble/keymap:vi/repeat/record-insert { + ble/keymap:vi/repeat/record-special && return 0 + if [[ ${_ble_keymap_vi_repeat_insert-} ]]; then + _ble_keymap_vi_repeat=("${_ble_keymap_vi_repeat_insert[@]}") + _ble_keymap_vi_repeat_irepeat=("${_ble_keymap_vi_irepeat[@]}") + elif ((${#_ble_keymap_vi_irepeat[@]})); then + local IFS=$_ble_term_IFS + _ble_keymap_vi_repeat=(vi_nmap "${KEYS[*]-}" ble/widget/vi_nmap/insert-mode 1 '' '') + _ble_keymap_vi_repeat_irepeat=("${_ble_keymap_vi_irepeat[@]}") + fi + ble/keymap:vi/repeat/clear-insert +} +function ble/keymap:vi/repeat/clear-insert { + _ble_keymap_vi_repeat_insert=() +} +function ble/keymap:vi/repeat/invoke { + local repeat_arg=$_ble_edit_arg + local repeat_reg=$_ble_keymap_vi_reg + local KEYMAP=${_ble_keymap_vi_repeat[0]} + local -a KEYS; ble/string#split-words KEYS "${_ble_keymap_vi_repeat[1]}" + local WIDGET=${_ble_keymap_vi_repeat[2]} + if [[ $KEYMAP != vi_[onxs]map ]]; then + ble/widget/vi-command/bell + return 1 + elif [[ $KEYMAP == vi_omap ]]; then + ble/decode/keymap/push vi_omap + elif [[ $KEYMAP == vi_[xs]map ]]; then + local _ble_keymap_vi_xmap_prev_edit=${_ble_keymap_vi_repeat[6]} + ble/widget/vi_xmap/.restore-visual-state + ble/decode/keymap/push "$KEYMAP" + fi + _ble_edit_arg= + _ble_keymap_vi_oparg=${_ble_keymap_vi_repeat[3]} + _ble_keymap_vi_opfunc=${_ble_keymap_vi_repeat[4]} + [[ $repeat_arg ]] && _ble_keymap_vi_oparg=$repeat_arg + local REG=${_ble_keymap_vi_repeat[5]} + [[ $REG ]] && _ble_keymap_vi_reg=$REG + local _ble_keymap_vi_single_command{,_overwrite}= # single-command-mode は持続させる。 + local _ble_keymap_vi_repeat_invoke=1 + local LASTWIDGET=$_ble_decode_widget_last + _ble_decode_widget_last=$WIDGET + builtin eval -- "$WIDGET" + if [[ $_ble_decode_keymap == vi_imap ]]; then + ((_ble_keymap_vi_irepeat_count<=1?(_ble_keymap_vi_irepeat_count=2):_ble_keymap_vi_irepeat_count++)) + local -a _ble_keymap_vi_irepeat + _ble_keymap_vi_irepeat=("${_ble_keymap_vi_repeat_irepeat[@]}") + ble/array#push _ble_keymap_vi_irepeat '0:ble/widget/dummy' # Note: normal-mode が自分自身を pop しようとするので。 + ble/widget/vi_imap/normal-mode + fi + ble/util/unlocal _ble_keymap_vi_single_command{,_overwrite} +} +function ble/widget/vi_nmap/repeat { + ble/keymap:vi/repeat/invoke + ble/keymap:vi/adjust-command-mode +} +function ble/widget/vi-command/forward-char { + local ARG FLAG REG; ble/keymap:vi/get-arg 1 + local index + if [[ $1 == wrap ]]; then + if [[ $FLAG || $_ble_decode_keymap == vi_[xs]map ]]; then + ((index=_ble_edit_ind+ARG, + index>${#_ble_edit_str}&&(index=${#_ble_edit_str}))) + else + local nl=$'\n' + local rex="^([^$nl]$nl?|$nl){0,$ARG}" + [[ ${_ble_edit_str:_ble_edit_ind} =~ $rex ]] + ((index=_ble_edit_ind+${#BASH_REMATCH})) + fi + else + local line=${_ble_edit_str:_ble_edit_ind:ARG} + line=${line%%$'\n'*} + ((index=_ble_edit_ind+${#line})) + fi + ble/widget/vi-command/exclusive-goto.impl "$index" "$FLAG" "$REG" +} +function ble/widget/vi-command/backward-char { + local ARG FLAG REG; ble/keymap:vi/get-arg 1 + local index + ((ARG>_ble_edit_ind&&(ARG=_ble_edit_ind))) + if [[ $1 == wrap ]]; then + if [[ $FLAG || $_ble_decode_keymap == vi_[xs]map ]]; then + ((index=_ble_edit_ind-ARG,index<0&&(index=0))) + else + local width=$ARG line + while ((width<=_ble_edit_ind)); do + line=${_ble_edit_str:_ble_edit_ind-width:width} + line=${line//[!$'\n']$'\n'/x} + ((${#line}>=ARG)) && break + ((width+=ARG-${#line})) + done + ((index=_ble_edit_ind-width,index<0&&(index=0))) + fi + else + local line=${_ble_edit_str:_ble_edit_ind-ARG:ARG} + line=${line##*$'\n'} + ((index=_ble_edit_ind-${#line})) + fi + ble/widget/vi-command/exclusive-goto.impl "$index" "$FLAG" "$REG" +} +function ble/widget/vi_nmap/forward-char-toggle-case { + local ARG FLAG REG; ble/keymap:vi/get-arg 1 + local line=${_ble_edit_str:_ble_edit_ind:ARG} + line=${line%%$'\n'*} + local len=${#line} + if ((len==0)); then + ble/widget/vi-command/bell + return 1 + fi + local index=$((_ble_edit_ind+len)) + local ret; ble/string#toggle-case "${_ble_edit_str:_ble_edit_ind:len}" + ble/widget/.replace-range "$_ble_edit_ind" "$index" "$ret" + ble/keymap:vi/mark/set-previous-edit-area "$_ble_edit_ind" "$index" + ble/keymap:vi/repeat/record + ble/keymap:vi/needs-eol-fix "$index" && ((index--)) + _ble_edit_ind=$index + ble/keymap:vi/adjust-command-mode + return 0 +} +function ble/widget/vi-command/.history-relative-line { + local offset=$1 + ((offset)) || return 0 + if [[ ! $_ble_history_prefix && ! $_ble_history_load_done ]]; then + ((offset<0)) || return 1 + ble/history/initialize # to use ble/history/get-index + fi + local index histsize + ble/history/get-index + ble/history/get-count -v histsize + local ret count=$((offset<0?-offset:offset)) exit=1 + ((count--)) + while ((count>=0)); do + if ((offset<0)); then + ((index>0)) || return "$exit" + ble/widget/history-prev + ret=${#_ble_edit_str} + ble/keymap:vi/needs-eol-fix "$ret" && ((ret--)) + _ble_edit_ind=$ret + else + ((indexe2y&&(x=e2x,y=e2y))) + ble/textmap#get-index-at "$x" "$y" # local variable "index" is set here + else + ble-edit/content/find-logical-eol "$bol2"; local eol2=$ret + ((index=bol2+ind-bol1,index>eol2&&(index=eol2))) + fi +} +function ble/widget/vi-command/relative-line.impl { + local offset=$1 flag=$2 reg=$3 opts=$4 + ((offset==0)) && return 0 + if [[ $flag ]]; then + ble/widget/vi-command/linewise-goto.impl "$_ble_edit_ind:$offset" "$flag" "$reg" preserve_column:require_multiline + return "$?" + fi + local count=$((offset<0?-offset:offset)) ret + if ((offset<0)); then + ble/string#count-char "${_ble_edit_str::_ble_edit_ind}" $'\n' + else + ble/string#count-char "${_ble_edit_str:_ble_edit_ind}" $'\n' + fi + local nmove=$((count=0?count:-count))" || ((nmove)); then + ble/keymap:vi/adjust-command-mode + return 0 + fi + fi + ble/widget/vi-command/bell + return 1 +} +function ble/widget/vi-command/forward-line { + local ARG FLAG REG; ble/keymap:vi/get-arg 1 + ble/widget/vi-command/relative-line.impl "$ARG" "$FLAG" "$REG" history +} +function ble/widget/vi-command/backward-line { + local ARG FLAG REG; ble/keymap:vi/get-arg 1 + ble/widget/vi-command/relative-line.impl "$((-ARG))" "$FLAG" "$REG" history +} +function ble/widget/vi-command/graphical-relative-line.impl { + local offset=$1 flag=$2 reg=$3 opts=$4 + local index move + if ble/edit/use-textmap; then + local x y ax ay + ble/textmap#getxy.cur "$_ble_edit_ind" + ((ax=x,ay=y+offset, + ay<_ble_textmap_begy?(ay=_ble_textmap_begy): + (ay>_ble_textmap_endy?(ay=_ble_textmap_endy):0))) + ble/textmap#get-index-at "$ax" "$ay" + ble/textmap#getxy.cur --prefix=a "$index" + ((offset-=move=ay-y)) + else + local ret ind=$_ble_edit_ind + ble-edit/content/find-logical-bol "$ind" 0; local bol1=$ret + ble-edit/content/find-logical-bol "$ind" "$offset"; local bol2=$ret + ble-edit/content/find-logical-eol "$bol2"; local eol2=$ret + ((index=bol2+ind-bol1,index>eol2&&(index=eol2))) + if ((index>ind)); then + ble/string#count-char "${_ble_edit_str:ind:index-ind}" $'\n' + ((offset+=move=-ret)) + elif ((index=0?count:-count))"; then + ble/widget/vi-command/first-non-space + elif ((nmove)); then + ble/keymap:vi/needs-eol-fix "$nolx" && ((nolx--)) + _ble_edit_ind=$nolx + ble/keymap:vi/adjust-command-mode + else + ble/widget/vi-command/bell + return 1 + fi +} +function ble/widget/vi-command/first-non-space { + local ARG FLAG REG; ble/keymap:vi/get-arg 1 + ble/widget/vi-command/relative-first-non-space.impl 0 "$FLAG" "$REG" charwise:history +} +function ble/widget/vi-command/forward-first-non-space { + local ARG FLAG REG; ble/keymap:vi/get-arg 1 + ble/widget/vi-command/relative-first-non-space.impl "$ARG" "$FLAG" "$REG" multiline:history +} +function ble/widget/vi-command/backward-first-non-space { + local ARG FLAG REG; ble/keymap:vi/get-arg 1 + ble/widget/vi-command/relative-first-non-space.impl "$((-ARG))" "$FLAG" "$REG" multiline:history +} +function ble/widget/vi-command/first-non-space-forward { + local ARG FLAG REG; ble/keymap:vi/get-arg 1 + ble/widget/vi-command/relative-first-non-space.impl "$((ARG-1))" "$FLAG" "$REG" history +} +function ble/widget/vi-command/forward-eol { + local ARG FLAG REG; ble/keymap:vi/get-arg 1 + if ((ARG>1)) && [[ ${_ble_edit_str:_ble_edit_ind} != *$'\n'* ]]; then + ble/widget/vi-command/bell + return 1 + fi + local ret index + ble-edit/content/find-logical-eol "$_ble_edit_ind" "$((ARG-1))"; index=$ret + ble/keymap:vi/needs-eol-fix "$index" && ((index--)) + ble/widget/vi-command/inclusive-goto.impl "$index" "$FLAG" "$REG" nobell + [[ $_ble_decode_keymap == vi_[xs]map ]] && + ble/keymap:vi/xmap/add-eol-extension # 末尾拡張 +} +function ble/widget/vi-command/beginning-of-graphical-line { + if ble/edit/use-textmap; then + local ARG FLAG REG; ble/keymap:vi/get-arg 1 + local x y index + ble/textmap#getxy.cur "$_ble_edit_ind" + ble/textmap#get-index-at 0 "$y" + ble/keymap:vi/needs-eol-fix "$index" && ((index--)) + ble/widget/vi-command/exclusive-goto.impl "$index" "$FLAG" "$REG" nobell + else + ble/widget/vi-command/beginning-of-line + fi +} +function ble/widget/vi-command/graphical-first-non-space { + if ble/edit/use-textmap; then + local ARG FLAG REG; ble/keymap:vi/get-arg 1 + local x y index ret + ble/textmap#getxy.cur "$_ble_edit_ind" + ble/textmap#get-index-at 0 "$y" + ble-edit/content/find-non-space "$index" + ble/keymap:vi/needs-eol-fix "$ret" && ((ret--)) + ble/widget/vi-command/exclusive-goto.impl "$ret" "$FLAG" "$REG" nobell + else + ble/widget/vi-command/first-non-space + fi +} +function ble/widget/vi-command/graphical-forward-eol { + if ble/edit/use-textmap; then + local ARG FLAG REG; ble/keymap:vi/get-arg 1 + local x y index + ble/textmap#getxy.cur "$_ble_edit_ind" + ble/textmap#get-index-at "$((_ble_textmap_cols-1))" "$((y+ARG-1))" + ble/keymap:vi/needs-eol-fix "$index" && ((index--)) + ble/widget/vi-command/inclusive-goto.impl "$index" "$FLAG" "$REG" nobell + else + ble/widget/vi-command/forward-eol + fi +} +function ble/widget/vi-command/middle-of-graphical-line { + local ARG FLAG REG; ble/keymap:vi/get-arg 1 + local index + if ble/edit/use-textmap; then + local x y + ble/textmap#getxy.cur "$_ble_edit_ind" + ble/textmap#get-index-at "$((_ble_textmap_cols/2))" "$y" + ble/keymap:vi/needs-eol-fix "$index" && ((index--)) + else + local ret + ble-edit/content/find-logical-bol; local bol=$ret + ble-edit/content/find-logical-eol; local eol=$ret + ((index=(bol+${COLUMNS:-eol})/2, + index>eol&&(index=eol), + bol1)) && [[ ${_ble_edit_str:_ble_edit_ind:index-_ble_edit_ind} != *$'\n'* ]]; then + ble/widget/vi-command/bell + return 1 + fi + local rex=$'([^ \t\n]?[ \t]+|[^ \t\n])$' + [[ ${_ble_edit_str::index} =~ $rex ]] && ((index-=${#BASH_REMATCH})) + ble/widget/vi-command/inclusive-goto.impl "$index" "$FLAG" "$REG" nobell +} +_ble_keymap_vi_previous_scroll= +function ble/widget/vi_nmap/scroll.impl { + local opts=$1 + local height=${_ble_canvas_panel_height[_ble_textarea_panel]} + local ARG FLAG REG; ble/keymap:vi/get-arg "$_ble_keymap_vi_previous_scroll" + _ble_keymap_vi_previous_scroll=$ARG + [[ $ARG ]] || ((ARG=height/2)) + [[ :$opts: == *:backward:* ]] && ((ARG=-ARG)) + ble/widget/.update-textmap + if [[ :$opts: == *:cursor:* ]]; then + local x y index ret + ble/textmap#getxy.cur "$_ble_edit_ind" + ble/textmap#get-index-at 0 "$((y+ARG))" + ble-edit/content/find-non-space "$index" + ble/keymap:vi/needs-eol-fix "$ret" && ((ret--)) + _ble_edit_ind=$ret + ble/keymap:vi/adjust-command-mode + ((_ble_textmap_endymax_scroll)); then + _ble_textarea_scroll_new=$max_scroll + fi + else + ((_ble_textmap_endymax_scroll)); then + _ble_textarea_scroll_new=$max_scroll + fi + local ay=$((_ble_textarea_scroll_new+_ble_textmap_begy)) + local by=$((_ble_textarea_scroll_new+height-1)) + ((_ble_textarea_scroll_new&&ay++)) + ((_ble_textarea_scroll_new!=0&&ayby?(y=by,1):0))); then + local index + ble/textmap#get-index-at "$x" "$y" + _ble_edit_ind=$index + fi + ble/keymap:vi/adjust-command-mode + fi +} +function ble/widget/vi_nmap/forward-line-scroll { + ble/widget/vi_nmap/scroll.impl forward:cursor +} +function ble/widget/vi_nmap/backward-line-scroll { + ble/widget/vi_nmap/scroll.impl backward:cursor +} +function ble/widget/vi_nmap/forward-scroll { + ble/widget/vi_nmap/scroll.impl forward +} +function ble/widget/vi_nmap/backward-scroll { + ble/widget/vi_nmap/scroll.impl backward +} +function ble/widget/vi_nmap/pagedown { + local height=${_ble_canvas_panel_height[_ble_textarea_panel]} + local ARG FLAG REG; ble/keymap:vi/get-arg 1 + ble/widget/.update-textmap + local x y + ble/textmap#getxy.cur "$_ble_edit_ind" + if ((y==_ble_textmap_endy)); then + ble/widget/vi-command/bell + return 1 + fi + local vheight=$((height-_ble_textmap_begy-1)) + local ybase=$((_ble_textarea_scroll_new+height-1)) + local y1=$((ybase+(ARG-1)*(vheight-2))) + local index ret + ble/textmap#get-index-at 0 "$y1" + ble-edit/content/bolp "$index" && + ble-edit/content/find-non-space "$index"; index=$ret + _ble_edit_ind=$index + local max_scroll=$((_ble_textmap_endy+1-height)) + ble/textmap#getxy.cur "$_ble_edit_ind" + local scroll=$((y<=_ble_textmap_begy+1?0:(y-_ble_textmap_begy-1))) + ((scroll>max_scroll&&(scroll=max_scroll))) + _ble_textarea_scroll_new=$scroll + ble/keymap:vi/adjust-command-mode +} +function ble/widget/vi_nmap/pageup { + local height=${_ble_canvas_panel_height[_ble_textarea_panel]} + local ARG FLAG REG; ble/keymap:vi/get-arg 1 + ble/widget/.update-textmap + if ((!_ble_textarea_scroll_new)); then + ble/widget/vi-command/bell + return 1 + fi + local vheight=$((height-_ble_textmap_begy-1)) + local ybase=$((_ble_textarea_scroll_new+_ble_textmap_begy+1)) + local y1=$((ybase-(ARG-1)*(vheight-2))) + ((y1<_ble_textmap_begy&&(y1=_ble_textmap_begy))) + local index ret + ble/textmap#get-index-at 0 "$y1" + ble-edit/content/bolp "$index" && + ble-edit/content/find-non-space "$index"; index=$ret + _ble_edit_ind=$index + local x y + ble/textmap#getxy.cur "$_ble_edit_ind" + local scroll=$((y-height+2)) + ((scroll<0&&(scroll=0))) + _ble_textarea_scroll_new=$scroll + ble/keymap:vi/adjust-command-mode +} +function ble/widget/vi_nmap/scroll-to-center.impl { + local opts=$1 + ble/widget/.update-textmap + local height=${_ble_canvas_panel_height[_ble_textarea_panel]} + local ARG FLAG REG; ble/keymap:vi/get-arg '' + if [[ ! $ARG && :$opts: == *:pagedown:* ]]; then + local y1=$((_ble_textarea_scroll_new+height)) + local index + ble/textmap#get-index-at 0 "$y1" + ((_ble_edit_ind=index)) + fi + local ret + ble-edit/content/find-logical-bol "$_ble_edit_ind"; local bol1=$ret + if [[ $ARG || :$opts: == *:nol:* ]]; then + if [[ $ARG ]]; then + ble-edit/content/find-logical-bol 0 "$((ARG-1))"; local bol2=$ret + else + local bol2=$bol1 + fi + if [[ :$opts: == *:nol:* ]]; then + ble-edit/content/find-non-space "$bol2" + _ble_edit_ind=$ret + elif ((bol1!=bol2)); then + local b1x b1y p1x p1y dx dy + ble/textmap#getxy.cur --prefix=b1 "$bol1" + ble/textmap#getxy.cur --prefix=p1 "$_ble_edit_ind" + ((dx=p1x,dy=p1y-b1y)) + local b2x b2y p2x p2y index + ble/textmap#getxy.cur --prefix=b2 "$bol2" + ((p2x=b2x,p2y=b2y+dy)) + ble/textmap#get-index-at "$p2x" "$p2y" + if ble-edit/content/find-logical-bol "$index"; ((ret==bol2)); then + _ble_edit_ind=$index + else + ble-edit/content/find-logical-eol "$bol2" + _ble_edit_ind=$ret + fi + fi + ble/keymap:vi/needs-eol-fix && ((_ble_edit_ind--)) + fi + if ((_ble_textmap_endy+1>height)); then + local max_scroll=$((_ble_textmap_endy+1-height)) + local b1x b1y + ble/textmap#getxy.cur --prefix=b1 "$bol1" + local scroll= + if [[ :$opts: == *:top:* ]]; then + ((scroll=b1y-(_ble_textmap_begy+2))) + elif [[ :$opts: == *:bottom:* ]]; then + ((scroll=b1y-(height-2))) + else + local vheight=$((height-_ble_textmap_begy-1)) + ((scroll=b1y-(_ble_textmap_begy+1+vheight/2))) + fi + if ((scroll<0)); then + scroll=0 + elif ((scroll>max_scroll)); then + scroll=$max_scroll + fi + _ble_textarea_scroll_new=$scroll + fi + ble/keymap:vi/adjust-command-mode +} +function ble/widget/vi_nmap/scroll-to-center-and-redraw { + ble/widget/vi_nmap/scroll-to-center.impl + ble/widget/redraw-line +} +function ble/widget/vi_nmap/scroll-to-top-and-redraw { + ble/widget/vi_nmap/scroll-to-center.impl top + ble/widget/redraw-line +} +function ble/widget/vi_nmap/scroll-to-bottom-and-redraw { + ble/widget/vi_nmap/scroll-to-center.impl bottom + ble/widget/redraw-line +} +function ble/widget/vi_nmap/scroll-to-center-non-space-and-redraw { + ble/widget/vi_nmap/scroll-to-center.impl nol + ble/widget/redraw-line +} +function ble/widget/vi_nmap/scroll-to-top-non-space-and-redraw { + ble/widget/vi_nmap/scroll-to-center.impl top:nol + ble/widget/redraw-line +} +function ble/widget/vi_nmap/scroll-to-bottom-non-space-and-redraw { + ble/widget/vi_nmap/scroll-to-center.impl bottom:nol + ble/widget/redraw-line +} +function ble/widget/vi_nmap/scroll-or-pagedown-and-redraw { + ble/widget/vi_nmap/scroll-to-center.impl top:nol:pagedown + ble/widget/redraw-line +} +function ble/widget/vi_nmap/paste.impl/block { + local arg=${1:-1} type=$2 + local graphical= + if [[ $type ]]; then + [[ $type == graphical ]] && graphical=1 + else + ble/edit/use-textmap && graphical=1 + fi + local ret cols=$_ble_textmap_cols + local -a afill; ble/string#split-words afill "${_ble_edit_kill_type:2}" + local atext; ble/string#split-lines atext "$_ble_edit_kill_ring" + local ntext=${#atext[@]} + if [[ $graphical ]]; then + ble-edit/content/find-logical-bol; local bol=$ret + local bx by x y c + ble/textmap#getxy.cur --prefix=b "$bol" + ble/textmap#getxy.cur "$_ble_edit_ind" + ((y-=by,c=y*cols+x)) + else + ble-edit/content/find-logical-bol; local bol=$ret + local c=$((_ble_edit_ind-bol)) + fi + local -a ins_beg=() ins_end=() ins_text=() + local i is_newline= + for ((i=0;i0)); then + ble-edit/content/find-logical-bol "$bol" 1 + if ((bol==ret)); then + is_newline=1 + else + bol=$ret + [[ $graphical ]] && ble/textmap#getxy.cur --prefix=b "$bol" + fi + fi + local text=${atext[i]} + local fill=$((afill[i])) + if ((arg>1)); then + ret= + ((fill)) && ble/string#repeat ' ' "$fill" + ble/string#repeat "$text$ret" "$arg" + text=${ret::${#ret}-fill} + fi + local index iend= + if [[ $is_newline ]]; then + index=${#_ble_edit_str} + ble/string#repeat ' ' "$c" + text=$'\n'$ret$text + elif [[ $graphical ]]; then + ble-edit/content/find-logical-eol "$bol"; local eol=$ret + ble/textmap#get-index-at "$x" "$((by+y))"; ((index>eol&&(index=eol))) + local ax ay ac; ble/textmap#getxy.out --prefix=a "$index" + ((ay-=by,ac=ay*cols+ax)) + if ((aceol)); then + ble/string#repeat ' ' "$((index-eol))" + text=$ret$text + index=$eol + fi + fi + ble/array#push ins_beg "$index" + ble/array#push ins_end "${iend:-$index}" + ble/array#push ins_text "$text" + done + ble/keymap:vi/mark/start-edit-area + local i=${#ins_beg[@]} + while ((i--)); do + local ibeg=${ins_beg[i]} iend=${ins_end[i]} text=${ins_text[i]} + ble/widget/.replace-range "$ibeg" "$iend" "$text" + done + ble/keymap:vi/mark/end-edit-area + ble/keymap:vi/repeat/record + ble/keymap:vi/needs-eol-fix && ((_ble_edit_ind--)) + ble/keymap:vi/adjust-command-mode +} +function ble/widget/vi_nmap/paste.impl { + local arg=$1 reg=$2 is_after=$3 + if [[ $reg ]]; then + local _ble_edit_kill_ring _ble_edit_kill_type + ble/keymap:vi/register#load "$reg" + fi + [[ $_ble_edit_kill_ring ]] || return 0 + local ret + if [[ $_ble_edit_kill_type == L ]]; then + ble/string#repeat "$_ble_edit_kill_ring" "$arg" + local content=$ret + local index dbeg dend + if ((is_after)); then + ble-edit/content/find-logical-eol; index=$ret + if ((index==${#_ble_edit_str})); then + content=$'\n'${content%$'\n'} + ((dbeg=index+1,dend=index+${#content})) + else + ((index++,dbeg=index,dend=index+${#content}-1)) + fi + else + ble-edit/content/find-logical-bol + ((index=ret,dbeg=index,dend=index+${#content}-1)) + fi + ble/widget/.replace-range "$index" "$index" "$content" + _ble_edit_ind=$dbeg + ble/keymap:vi/mark/set-previous-edit-area "$dbeg" "$dend" + ble/keymap:vi/repeat/record + ble/widget/vi-command/first-non-space + elif [[ $_ble_edit_kill_type == B:* ]]; then + if ((is_after)) && ! ble-edit/content/eolp; then + ((_ble_edit_ind++)) + fi + ble/widget/vi_nmap/paste.impl/block "$arg" + else + if ((is_after)) && ! ble-edit/content/eolp; then + ((_ble_edit_ind++)) + fi + ble/string#repeat "$_ble_edit_kill_ring" "$arg" + local beg=$_ble_edit_ind + ble/widget/.insert-string "$ret" + local end=$_ble_edit_ind + ble/keymap:vi/mark/set-previous-edit-area "$beg" "$end" + ble/keymap:vi/repeat/record + [[ $_ble_keymap_vi_single_command ]] || ((_ble_edit_ind--)) + ble/keymap:vi/needs-eol-fix && ((_ble_edit_ind--)) + ble/keymap:vi/adjust-command-mode + fi + return 0 +} +function ble/widget/vi_nmap/paste-after { + local ARG FLAG REG; ble/keymap:vi/get-arg 1 + ble/widget/vi_nmap/paste.impl "$ARG" "$REG" 1 +} +function ble/widget/vi_nmap/paste-before { + local ARG FLAG REG; ble/keymap:vi/get-arg 1 + ble/widget/vi_nmap/paste.impl "$ARG" "$REG" 0 +} +function ble/widget/vi_nmap/kill-forward-char { + _ble_keymap_vi_opfunc=d + ble/widget/vi-command/forward-char +} +function ble/widget/vi_nmap/kill-forward-char-and-insert { + _ble_keymap_vi_opfunc=c + ble/widget/vi-command/forward-char +} +function ble/widget/vi_nmap/kill-backward-char { + _ble_keymap_vi_opfunc=d + ble/widget/vi-command/backward-char +} +function ble/widget/vi_nmap/kill-forward-line { + _ble_keymap_vi_opfunc=d + ble/widget/vi-command/forward-eol +} +function ble/widget/vi_nmap/kill-forward-line-and-insert { + _ble_keymap_vi_opfunc=c + ble/widget/vi-command/forward-eol +} +function ble/widget/vi-command/forward-word.impl { + local arg=$1 flag=$2 reg=$3 rex_word=$4 + local ifs=$_ble_term_IFS + if [[ $flag == c && ${_ble_edit_str:_ble_edit_ind:1} != [$ifs] ]]; then + ble/widget/vi-command/forward-word-end.impl "$arg" "$flag" "$reg" "$rex_word" allow_here + return "$?" + fi + local b=$'[ \t]' n=$'\n' + local rex="^((($rex_word)$n?|$b+$n?|$n)($b+$n)*$b*){0,$arg}" # 単語先頭または空行に止まる + [[ ${_ble_edit_str:_ble_edit_ind} =~ $rex ]] + local index=$((_ble_edit_ind+${#BASH_REMATCH})) + if [[ $flag ]]; then + local rematch1=${BASH_REMATCH[1]} + if local rex="$n$b*\$"; [[ $rematch1 =~ $rex ]]; then + local suffix_len=${#BASH_REMATCH} + ((suffix_len<${#rematch1})) && + ((index-=suffix_len)) + fi + fi + ble/widget/vi-command/exclusive-goto.impl "$index" "$flag" "$reg" +} +function ble/widget/vi-command/forward-word-end.impl { + local arg=$1 flag=$2 reg=$3 rex_word=$4 opts=$5 + local IFS=$_ble_term_IFS + local rex="^([$IFS]*($rex_word)?){0,$arg}" # 単語末端に止まる。空行には止まらない + local offset=1; [[ :$opts: == *:allow_here:* ]] && offset=0 + [[ ${_ble_edit_str:_ble_edit_ind+offset} =~ $rex ]] + local index=$((_ble_edit_ind+offset+${#BASH_REMATCH}-1)) + ((index<_ble_edit_ind&&(index=_ble_edit_ind))) + [[ ! $flag && $BASH_REMATCH && ${_ble_edit_str:index:1} == [$IFS] ]] && ble/widget/.bell + ble/widget/vi-command/inclusive-goto.impl "$index" "$flag" "$reg" +} +function ble/widget/vi-command/backward-word.impl { + local arg=$1 flag=$2 reg=$3 rex_word=$4 + local b=$'[ \t]' n=$'\n' + local rex="((($rex_word)$n?|$b+$n?|$n)($b+$n)*$b*){0,$arg}\$" # 単語先頭または空行に止まる + [[ ${_ble_edit_str::_ble_edit_ind} =~ $rex ]] + local index=$((_ble_edit_ind-${#BASH_REMATCH})) + ble/widget/vi-command/exclusive-goto.impl "$index" "$flag" "$reg" +} +function ble/widget/vi-command/backward-word-end.impl { + local arg=$1 flag=$2 reg=$3 rex_word=$4 + local i=$'[ \t\n]' b=$'[ \t]' n=$'\n' w="($rex_word)" + local rex1="(^|$w$n?|$n)($b+$n)*$b*" + local rex="($rex1)($rex1){$((arg-1))}($rex_word|$i)\$" # 単語末端または空行に止まる + [[ ${_ble_edit_str::_ble_edit_ind+1} =~ $rex ]] + local index=$((_ble_edit_ind+1-${#BASH_REMATCH})) + local rematch3=${BASH_REMATCH[3]} # 最初の ($rex_word) + [[ $rematch3 ]] && ((index+=${#rematch3}-1)) + ble/widget/vi-command/inclusive-goto.impl "$index" "$flag" "$reg" +} +function ble/widget/vi-command/forward-vword { + local ARG FLAG REG; ble/keymap:vi/get-arg 1 + ble/widget/vi-command/forward-word.impl "$ARG" "$FLAG" "$REG" "$_ble_keymap_vi_REX_WORD" +} +function ble/widget/vi-command/forward-vword-end { + local ARG FLAG REG; ble/keymap:vi/get-arg 1 + ble/widget/vi-command/forward-word-end.impl "$ARG" "$FLAG" "$REG" "$_ble_keymap_vi_REX_WORD" +} +function ble/widget/vi-command/backward-vword { + local ARG FLAG REG; ble/keymap:vi/get-arg 1 + ble/widget/vi-command/backward-word.impl "$ARG" "$FLAG" "$REG" "$_ble_keymap_vi_REX_WORD" +} +function ble/widget/vi-command/backward-vword-end { + local ARG FLAG REG; ble/keymap:vi/get-arg 1 + ble/widget/vi-command/backward-word-end.impl "$ARG" "$FLAG" "$REG" "$_ble_keymap_vi_REX_WORD" +} +function ble/widget/vi-command/forward-uword { + local ARG FLAG REG; ble/keymap:vi/get-arg 1 + ble/widget/vi-command/forward-word.impl "$ARG" "$FLAG" "$REG" $'[^ \t\n]+' +} +function ble/widget/vi-command/forward-uword-end { + local ARG FLAG REG; ble/keymap:vi/get-arg 1 + ble/widget/vi-command/forward-word-end.impl "$ARG" "$FLAG" "$REG" $'[^ \t\n]+' +} +function ble/widget/vi-command/backward-uword { + local ARG FLAG REG; ble/keymap:vi/get-arg 1 + ble/widget/vi-command/backward-word.impl "$ARG" "$FLAG" "$REG" $'[^ \t\n]+' +} +function ble/widget/vi-command/backward-uword-end { + local ARG FLAG REG; ble/keymap:vi/get-arg 1 + ble/widget/vi-command/backward-word-end.impl "$ARG" "$FLAG" "$REG" $'[^ \t\n]+' +} +function ble/widget/vi-command/nth-column { + local ARG FLAG REG; ble/keymap:vi/get-arg 1 + local ret index + ble-edit/content/find-logical-bol; local bol=$ret + ble-edit/content/find-logical-eol; local eol=$ret + if ble/edit/use-textmap; then + local bx by; ble/textmap#getxy.cur --prefix=b "$bol" # Note: 先頭行はプロンプトにより bx!=0 + local ex ey; ble/textmap#getxy.cur --prefix=e "$eol" + local dstx=$((bx+ARG-1)) dsty=$by cols=${COLUMNS:-80} + ((dsty+=dstx/cols,dstx%=cols)) + ((dsty>ey&&(dsty=ey,dstx=ex))) + ble/textmap#get-index-at "$dstx" "$dsty" # local variable "index" is set here + [[ $_ble_decode_keymap != vi_[xs]map ]] && + ble-edit/content/nonbol-eolp "$index" && ((index--)) + else + [[ $_ble_decode_keymap != vi_[xs]map ]] && + ble-edit/content/nonbol-eolp "$eol" && ((eol--)) + ((index=bol+ARG-1,index>eol&&(index=eol))) + fi + ble/widget/vi-command/exclusive-goto.impl "$index" "$FLAG" "$REG" nobell +} +function ble/widget/vi-command/nth-line { + local ARG FLAG REG; ble/keymap:vi/get-arg 1 + [[ $FLAG ]] || ble/keymap:vi/mark/set-jump # `` + ble/widget/vi-command/linewise-goto.impl "0:$((ARG-1))" "$FLAG" "$REG" +} +function ble/widget/vi-command/nth-last-line { + local ARG FLAG REG; ble/keymap:vi/get-arg 1 + [[ $FLAG ]] || ble/keymap:vi/mark/set-jump # `` + ble/widget/vi-command/linewise-goto.impl "${#_ble_edit_str}:$((-(ARG-1)))" "$FLAG" "$REG" +} +function ble/widget/vi-command/history-beginning { + local ARG FLAG REG; ble/keymap:vi/get-arg 0 + if [[ $FLAG ]]; then + if ((ARG)); then + _ble_keymap_vi_oparg=$ARG + else + _ble_keymap_vi_oparg= + fi + _ble_keymap_vi_opfunc=$FLAG + _ble_keymap_vi_reg=$REG + ble/widget/vi-command/nth-line + return "$?" + fi + if ((ARG)); then + ble-edit/history/goto "$((ARG-1))" + else + ble/widget/history-beginning + fi + ble/keymap:vi/needs-eol-fix && ((_ble_edit_ind--)) + ble/keymap:vi/adjust-command-mode + return 0 +} +function ble/widget/vi-command/history-end { + local ARG FLAG REG; ble/keymap:vi/get-arg 0 + if [[ $FLAG ]]; then + _ble_keymap_vi_opfunc=$FLAG + _ble_keymap_vi_reg=$REG + if ((ARG)); then + _ble_keymap_vi_oparg=$ARG + ble/widget/vi-command/nth-line + else + _ble_keymap_vi_oparg= + ble/widget/vi-command/nth-last-line + fi + return "$?" + fi + if ((ARG)); then + ble-edit/history/goto "$((ARG-1))" + else + ble/widget/history-end + fi + ble/keymap:vi/needs-eol-fix && ((_ble_edit_ind--)) + ble/keymap:vi/adjust-command-mode + return 0 +} +function ble/widget/vi-command/.history-goto { + local new_index=$1 old_index + ble/history/get-index -v old_index + if ((new_index==old_index)); then + ble/widget/vi-command/bell 'already on history !'"$new_index" + return 1 + fi + ble-edit/history/goto "$new_index" + local ret + if ((new_index cancel + return 27 + else + ble/keymap:vi/k2c "$key" || return 1 + ble/util/c2s "$ret"; local c=$ret + fi + [[ $c ]] || return 1 + ((isrepeat)) || _ble_keymap_vi_char_search=$c$opts + local index + if [[ $opts == *b* ]]; then + ble-edit/content/find-logical-bol; local bol=$ret + local base=$_ble_edit_ind + ((isrepeat&&isprev&&base--,base>bol)) || return 1 + local line=${_ble_edit_str:bol:base-bol} + ble/string#last-index-of "$line" "$c" "$ARG" + ((ret>=0)) || return 1 + ((index=bol+ret,isprev&&index++)) + ble/widget/vi-command/exclusive-goto.impl "$index" "$FLAG" "$REG" nobell + return "$?" + else + ble-edit/content/find-logical-eol; local eol=$ret + local base=$((_ble_edit_ind+1)) + ((isrepeat&&isprev&&base++,base=0)) || return 1 + ((index=base+ret,isprev&&index--)) + ble/widget/vi-command/inclusive-goto.impl "$index" "$FLAG" "$REG" nobell + return "$?" + fi +} +function ble/widget/vi-command/search-char.impl { + if ble/widget/vi-command/search-char.impl/core "$1" "$2"; then + ble/keymap:vi/adjust-command-mode + return 0 + else + ble/widget/vi-command/bell + return 1 + fi +} +function ble/widget/vi-command/search-forward-char { + ble/keymap:vi/async-read-char ble/widget/vi-command/search-char.impl f +} +function ble/widget/vi-command/search-forward-char-prev { + ble/keymap:vi/async-read-char ble/widget/vi-command/search-char.impl fp +} +function ble/widget/vi-command/search-backward-char { + ble/keymap:vi/async-read-char ble/widget/vi-command/search-char.impl b +} +function ble/widget/vi-command/search-backward-char-prev { + ble/keymap:vi/async-read-char ble/widget/vi-command/search-char.impl bp +} +function ble/widget/vi-command/search-char-repeat { + [[ $_ble_keymap_vi_char_search ]] || ble/widget/.bell + local c=${_ble_keymap_vi_char_search::1} opts=${_ble_keymap_vi_char_search:1} + ble/widget/vi-command/search-char.impl "r$opts" "$c" +} +function ble/widget/vi-command/search-char-reverse-repeat { + [[ $_ble_keymap_vi_char_search ]] || ble/widget/.bell + local c=${_ble_keymap_vi_char_search::1} opts=${_ble_keymap_vi_char_search:1} + if [[ $opts == *b* ]]; then + opts=f${opts//b} + else + opts=b${opts//f} + fi + ble/widget/vi-command/search-char.impl "r$opts" "$c" +} +function ble/widget/vi-command/search-matchpair/.search-forward { + ble/string#index-of-chars "$_ble_edit_str" "$ch1$ch2" "$((index+1))" +} +function ble/widget/vi-command/search-matchpair/.search-backward { + ble/string#last-index-of-chars "$_ble_edit_str" "$ch1$ch2" "$index" +} +function ble/widget/vi-command/search-matchpair-or { + local ARG FLAG REG; ble/keymap:vi/get-arg -1 + if ((ARG>=0)); then + _ble_keymap_vi_oparg=$ARG + _ble_keymap_vi_opfunc=$FLAG + _ble_keymap_vi_reg=$REG + ble/widget/"$@" + return "$?" + fi + local open='({[' close=')}]' + local ret + ble-edit/content/find-logical-eol; local eol=$ret + if ! ble/string#index-of-chars "${_ble_edit_str::eol}" '(){}[]' "$_ble_edit_ind"; then + ble/keymap:vi/adjust-command-mode + return 1 + fi + local index1=$ret ch1=${_ble_edit_str:ret:1} + if [[ $ch1 == ["$open"] ]]; then + local i=${open%%"$ch"*}; i=${#i} + local ch2=${close:i:1} + local searcher=ble/widget/vi-command/search-matchpair/.search-forward + else + local i=${close%%"$ch"*}; i=${#i} + local ch2=${open:i:1} + local searcher=ble/widget/vi-command/search-matchpair/.search-backward + fi + local index=$index1 count=1 + while "$searcher"; do + index=$ret + if [[ ${_ble_edit_str:ret:1} == "$ch1" ]]; then + ((++count)) + else + ((--count==0)) && break + fi + done + if ((count)); then + ble/keymap:vi/adjust-command-mode + return 1 + fi + [[ $FLAG ]] || ble/keymap:vi/mark/set-jump # `` + ble/widget/vi-command/inclusive-goto.impl "$index" "$FLAG" "$REG" nobell +} +function ble/widget/vi-command/percentage-line { + local ARG FLAG REG; ble/keymap:vi/get-arg 0 + local ret; ble/string#count-char "$_ble_edit_str" $'\n'; local nline=$((ret+1)) + local iline=$(((ARG*nline+99)/100)) + ble/widget/vi-command/linewise-goto.impl "0:$((iline-1))" "$FLAG" "$REG" +} +function ble/widget/vi-command/nth-byte { + local ARG FLAG REG; ble/keymap:vi/get-arg 1 + ((ARG--)) + local offset=0 text=$_ble_edit_str len=${#_ble_edit_str} + local left nleft ret + while ((ARG>0&&len>1)); do + left=${text::len/2} + ble/util/strlen "$left"; nleft=$ret + if ((ARG=2)); then + if [[ $type == i* ]]; then + [[ $match == ["$space"]* ]] && beg=1 + elif [[ $type == a* ]]; then + [[ $match == *[!"$ifs"] ]] && beg=1 + fi + fi + done + return 0 +} +function ble/keymap:vi/text-object/word.impl { + local arg=$1 flag=$2 reg=$3 type=$4 + local space=$' \t' nl=$'\n' ifs=$_ble_term_IFS + ((arg==0)) && return 0 + local rex_word + if [[ $type == ?W ]]; then + rex_word="[^$ifs]+" + else + rex_word=$_ble_keymap_vi_REX_WORD + fi + local index=$_ble_edit_ind + if [[ $_ble_decode_keymap == vi_[xs]map ]]; then + if ((index<_ble_edit_mark)); then + local beg=$index + if ble/keymap:vi/text-object/word.extend-backward; then + _ble_edit_ind=$beg + else + _ble_edit_ind=0 + ble/widget/.bell + fi + ble/keymap:vi/adjust-command-mode + return 0 + fi + fi + local beg=$index end=$index flags= + if ! ble/keymap:vi/text-object/word.extend-forward; then + index=${#_ble_edit_str} + ble-edit/content/nonbol-eolp "$index" && ((index--)) + _ble_edit_ind=$index + ble/widget/vi-command/bell + return 1 + fi + if [[ $_ble_decode_keymap == vi_[xs]map ]]; then + ((end--)) + ble-edit/content/nonbol-eolp "$end" && ((end--)) + ((beg<_ble_edit_mark)) && _ble_edit_mark=$beg + [[ $_ble_edit_mark_active == vi_line ]] && + _ble_edit_mark_active=vi_char + _ble_edit_ind=$end + ble/keymap:vi/adjust-command-mode + return 0 + else + ble/widget/vi-command/exclusive-range.impl "$beg" "$end" "$flag" "$reg" + fi +} +function ble/keymap:vi/text-object:quote/is-closing-quote { + local index=${1:-$_ble_edit_ind} + [[ ${_ble_edit_str:index:1} == "$quote" ]] || return 1 + local ret + ble-edit/content/find-logical-bol "$index"; local bol=$ret + ble/string#count-char "${_ble_edit_str:bol:_ble_edit_ind-bol}" "$quote" + ((ret%2==1)) +} +function ble/keymap:vi/text-object:quote/.next { + local index=${1:-$((_ble_edit_ind+1))} nl=$'\n' + local rex="^[^$nl$quote]*$quote" + [[ ${_ble_edit_str:index} =~ $rex ]] || return 1 + ((ret=index+${#BASH_REMATCH}-1)) + return 0 +} +function ble/keymap:vi/text-object:quote/.prev { + local index=${1:-_ble_edit_ind} nl=$'\n' + local rex="$quote[^$nl$quote]*\$" + [[ ${_ble_edit_str::index} =~ $rex ]] || return 1 + ((ret=index-${#BASH_REMATCH})) + return 0 +} +function ble/keymap:vi/text-object/quote.impl { + local arg=$1 flag=$2 reg=$3 type=$4 + local ret quote=${type:1} + if [[ $_ble_decode_keymap == vi_[xs]map ]]; then + if ble/keymap:vi/text-object:quote/.xmap; then + ble/keymap:vi/adjust-command-mode + return 0 + else + ble/widget/vi-command/bell + return 1 + fi + fi + local beg= end= + if [[ ${_ble_edit_str:_ble_edit_ind:1} == "$quote" ]]; then + ble-edit/content/find-logical-bol; local bol=$ret + ble/string#count-char "${_ble_edit_str:bol:_ble_edit_ind-bol}" "$quote" + if ((ret%2==1)); then + ((end=_ble_edit_ind+1)) + ble/keymap:vi/text-object:quote/.prev && beg=$ret + else + ((beg=_ble_edit_ind)) + ble/keymap:vi/text-object:quote/.next && end=$((ret+1)) + fi + elif ble/keymap:vi/text-object:quote/.prev && beg=$ret; then + ble/keymap:vi/text-object:quote/.next && end=$((ret+1)) + elif ble/keymap:vi/text-object:quote/.next && beg=$ret; then + ble/keymap:vi/text-object:quote/.next "$((beg+1))" && end=$((ret+1)) + fi + if [[ $beg && $end ]]; then + [[ $type == i* || arg -gt 1 ]] && ((beg++,end--)) + ble/widget/vi-command/exclusive-range.impl "$beg" "$end" "$flag" "$reg" + else + ble/widget/vi-command/bell + return 1 + fi +} +function ble/keymap:vi/text-object:quote/.expand-xmap-range { + local inclusive=$1 + ((end++)) + if ((inclusive==2)); then + local rex + rex=$'^[ \t]+'; [[ ${_ble_edit_str:end} =~ $rex ]] && ((end+=${#BASH_REMATCH})) + elif ((inclusive==0&&end-beg>2)); then + ((beg++,end--)) + fi +} +function ble/keymap:vi/text-object:quote/.xmap { + local min=$_ble_edit_ind max=$_ble_edit_mark + ((min>max)) && local min=$max max=$min + [[ ${_ble_edit_str:min:max+1-min} == *$'\n'* ]] && return 1 + local inclusive=0 + if [[ $type == a* ]]; then + inclusive=2 + elif ((arg>1)); then + inclusive=1 + fi + local ret + if ((_ble_edit_ind==_ble_edit_mark)); then + ble/keymap:vi/text-object:quote/.prev "$((_ble_edit_ind+1))" || + ble/keymap:vi/text-object:quote/.next "$((_ble_edit_ind+1))" || return 1 + if ble/keymap:vi/text-object:quote/is-closing-quote; then + local end=$ret + ble/keymap:vi/text-object:quote/.prev "$end" || return 1 + local beg=$ret + else + local beg=$ret + ble/keymap:vi/text-object:quote/.next "$((beg+1))" || return 1 + local end=$ret + fi + ble/keymap:vi/text-object:quote/.expand-xmap-range "$inclusive" + _ble_edit_mark=$beg + _ble_edit_ind=$((end-1)) + return 0 + elif ((_ble_edit_ind>_ble_edit_mark)); then + local updates_mark= + if [[ ${_ble_edit_str:_ble_edit_ind:1} == "$quote" ]]; then + ble/keymap:vi/text-object:quote/.next "$((_ble_edit_ind+1))" || return 1; local beg=$ret + if ble/keymap:vi/text-object:quote/.next "$((beg+1))"; then + local end=$ret + else + local end=$beg beg=$_ble_edit_ind + fi + else + ble-edit/content/find-logical-bol; local bol=$ret + ble/string#count-char "${_ble_edit_str:bol:_ble_edit_ind-bol}" "$quote" + if ((ret%2==0)); then + ble/keymap:vi/text-object:quote/.next "$((_ble_edit_ind+1))" || return 1; local beg=$ret + ble/keymap:vi/text-object:quote/.next "$((beg+1))" || return 1; local end=$ret + else + ble/keymap:vi/text-object:quote/.prev "$_ble_edit_ind" || return 1; local beg=$ret + ble/keymap:vi/text-object:quote/.next "$((_ble_edit_ind+1))" || return 1; local end=$ret + fi + local i1=$((_ble_edit_mark?_ble_edit_mark-1:0)) + [[ ${_ble_edit_str:i1:_ble_edit_ind-i1} != *"$quote"* ]] && updates_mark=1 + fi + ble/keymap:vi/text-object:quote/.expand-xmap-range "$inclusive" + [[ $updates_mark ]] && _ble_edit_mark=$beg + _ble_edit_ind=$((end-1)) + return 0 + else + ble-edit/content/find-logical-bol; local bol=$ret nl=$'\n' + local rex="^([^$nl$quote]*$quote[^$nl$quote]*$quote)*[^$nl$quote]*$quote" + [[ ${_ble_edit_str:bol:_ble_edit_ind-bol} =~ $rex ]] || return 1 + local beg=$((bol+${#BASH_REMATCH}-1)) + ble/keymap:vi/text-object:quote/.next "$((beg+1))" || return 1 + local end=$ret + ble/keymap:vi/text-object:quote/.expand-xmap-range "$inclusive" + [[ ${_ble_edit_str:_ble_edit_ind:_ble_edit_mark+2-_ble_edit_ind} != *"$quote"* ]] && _ble_edit_mark=$((end-1)) + _ble_edit_ind=$beg + return 0 + fi +} +function ble/keymap:vi/text-object:block/.prev-matching-lparen { + local index=${1:-$_ble_edit_ind} goal_count=${2:-1} + local p=$index count=0 + while ble/string#last-index-of-chars "$_ble_edit_str" "$rparen$lparen" "$p"; do + p=$ret + if [[ ${_ble_edit_str:ret:1} == "$lparen" ]]; then + ((++count==goal_count)) && return 0 + else + ((--count)) + fi + done + ret=$count + return 1 +} +function ble/keymap:vi/text-object:block/.next-matching-rparen { + local index=${1:-$_ble_edit_ind} goal_count=${2:-1} + local p=$index count=0 + while ble/string#index-of-chars "$_ble_edit_str" "$rparen$lparen" "$p"; do + p=$((ret+1)) + if [[ ${_ble_edit_str:ret:1} == "$rparen" ]]; then + ((++count==goal_count)) && return 0 + else + ((--count)) + fi + done + ret=$count + return 1 +} +function ble/keymap:vi/text-object:block/.next-matching-lparen { + local index=${1:-$_ble_edit_ind} goal_count=${2:-1} + local p=$index count=0 + while ble/string#index-of-chars "$_ble_edit_str" "$rparen$lparen" "$p"; do + p=$((ret+1)) + if [[ ${_ble_edit_str:ret:1} == "$rparen" ]]; then + ((++count==goal_count)) && { ret=$count; return 1; } + else + ((count+1==goal_count)) && return 0 + ((--count)) + fi + done + ret=$count + return 1 +} +function ble/keymap:vi/text-object:block/.expand-one-level { + local p1=$1 beg1= end1= ret + ble/keymap:vi/text-object:block/.prev-matching-lparen "$p1" && beg1=$ret + ble/keymap:vi/text-object:block/.next-matching-rparen "$p1" && end1=$ret + if [[ $beg1 && $end1 ]]; then + beg=$beg1 end=$end1 + elif [[ $beg1 || $end1 ]]; then + return 1 + fi +} +function ble/keymap:vi/text-object:block/.outer-range { + outer_beg=$1 outer_end=$2 + if [[ $type == i* ]]; then + case ${_ble_edit_str::outer_beg} in + (*"$lparen"$'\n') ((outer_beg-=2)) ;; + (*"$lparen") ((outer_beg--)) ;; + esac + case ${_ble_edit_str:outer_end+1} in + ($'\n'"$rparen"*) ((outer_end+=2)) ;; + ("$rparen"*) ((outer_end++)) ;; + esac + fi +} +function ble/keymap:vi/text-object:block/.search-block { + local ret p1=$1 p2=$2 L=$3 R=$4 opts=$5 + [[ ${_ble_edit_str:p1:1} == "$L" ]] && ((p1++)) + if ble/keymap:vi/text-object:block/.prev-matching-lparen "$p1" "$arg"; then + beg=$ret + ble/keymap:vi/text-object:block/.next-matching-rparen "$p1" "$arg" || return 1 + end=$ret + if [[ :$opts: == *:reject-empty-here:* ]]; then + ((beg+1=end)); then + [[ $type == i* ]] && ((p1--)) + ble/keymap:vi/text-object:block/.expand-one-level "$outer_beg" || return 1 + fi + fi + elif ((ret<=0&&arg==1)); then + p1=$1 + [[ ${_ble_edit_str:p1:1} == "$R" ]] && ((p1++)) + ble/keymap:vi/text-object:block/.next-matching-lparen "$p1" || return 1 + beg=$ret + ble/keymap:vi/text-object:block/.next-matching-rparen "$((beg+1))" || return 1 + end=$ret + if [[ :$opts: == *:check-expand:* ]]; then + if [[ $type == i* ]]; then + local outer_end=$p2 + case ${_ble_edit_str:outer_end+1} in + ($'\n'"$rparen"*) ((outer_end+=2)) ;; + ("$rparen"*) ((outer_end++)) ;; + esac + ((outer_end'; then + if rex='^<[^/][^>]*>' && [[ ${_ble_edit_str:ret} =~ $rex ]]; then + ((pivot=ret+${#BASH_REMATCH})) + else + ((pivot=ret+1)) + fi + fi + local ifs=$_ble_term_IFS + local beg=$pivot count=$arg + rex="<([^$ifs/>!]+([$ifs]+([^>]*[^/])?)?|/[^>]*)>\$" + while ble/string#last-index-of-chars "${_ble_edit_str::beg}" '>' && beg=$ret; do + [[ ${_ble_edit_str::beg+1} =~ $rex ]] || continue + ((beg-=${#BASH_REMATCH}-1)) + if [[ ${BASH_REMATCH::2} == ']*>'; [[ ${_ble_edit_str:beg:end-beg} =~ $rex ]] && ((beg+=${#BASH_REMATCH})) + rex='<[^>]*>$'; [[ ${_ble_edit_str:beg:end-beg} =~ $rex ]] && ((end-=${#BASH_REMATCH})) + fi + if [[ $_ble_decode_keymap == vi_[xs]map ]]; then + _ble_edit_mark=$beg + ble/widget/vi-command/exclusive-goto.impl "$end" + else + ble/widget/vi-command/exclusive-range.impl "$beg" "$end" "$flag" "$reg" + fi +} +function ble/keymap:vi/text-object:sentence/.beg { + beg= is_interval= + local pivot=$_ble_edit_ind rex= + if ble-edit/content/bolp && ble-edit/content/eolp; then + if rex=$'^\n+[^\n]'; [[ ${_ble_edit_str:pivot} =~ $rex ]]; then + beg=$((pivot+${#BASH_REMATCH}-2)) + else + if rex=$'\n+$'; [[ ${_ble_edit_str::pivot} =~ $rex ]]; then + ((pivot-=${#BASH_REMATCH})) + fi + fi + fi + if [[ ! $beg ]]; then + rex="^.*((^$lf?|$lf$lf)([ $ht]*)|[.!?][])'\"]*([ $ht$lf]+))" + if [[ ${_ble_edit_str::pivot+1} =~ $rex ]]; then + beg=${#BASH_REMATCH} + if ((pivot']) ble/keymap:vi/text-object/block.impl "$arg" "$flag" "$reg" "${type::1}<>" ;; + ([ia]['][']) ble/keymap:vi/text-object/block.impl "$arg" "$flag" "$reg" "${type::1}[]" ;; + ([ia]t) ble/keymap:vi/text-object/tag.impl "$arg" "$flag" "$reg" "$type" ;; + ([ia]s) ble/keymap:vi/text-object/sentence.impl "$arg" "$flag" "$reg" "$type" ;; + ([ia]p) ble/keymap:vi/text-object/paragraph.impl "$arg" "$flag" "$reg" "$type" ;; + (*) + ble/widget/vi-command/bell + return 1;; + esac +} +function ble/keymap:vi/text-object.hook { + local key=$1 + local ARG FLAG REG; ble/keymap:vi/get-arg 1 + if ! ble-decode-key/ischar "$key"; then + ble/widget/vi-command/bell + return 1 + fi + local ret; ble/util/c2s "$key" + local type=$_ble_keymap_vi_text_object$ret + ble/keymap:vi/text-object.impl "$ARG" "$FLAG" "$REG" "$type" + return 0 +} +function ble/keymap:vi/.attempt-text-object { + local c=${1:-} + if [[ ! $c ]]; then + local n=${#KEYS[@]}; ((n&&n--)) + ble-decode-key/ischar "${KEYS[n]}" || return 1 + local ret; ble/util/c2s "${KEYS[n]}"; c=$ret + fi + [[ $c == [ia] ]] || return 1 + [[ $_ble_keymap_vi_opfunc || $_ble_decode_keymap == vi_[xs]map ]] || return 1 + _ble_keymap_vi_text_object=$c + _ble_decode_key__hook=ble/keymap:vi/text-object.hook + return 0 +} +function ble/widget/vi-command/text-object { + ble/keymap:vi/.attempt-text-object "$@" && return 147 + ble/widget/vi-command/bell + return 1 +} +function ble/widget/vi-command/text-object-outer { + ble/widget/vi-command/text-object a +} +function ble/widget/vi-command/text-object-inner { + ble/widget/vi-command/text-object i +} +_ble_keymap_vi_commandline_history=() +_ble_keymap_vi_commandline_history_edit=() +_ble_keymap_vi_commandline_history_dirt=() +_ble_keymap_vi_commandline_history_index=0 +function ble/keymap:vi/commandline/empty-cancel.hook { + if [[ ! $_ble_edit_str ]] && ((_ble_edit_async_read_is_cancel_key[KEYS[0]])); then + ble/widget/vi_cmap/cancel + ble/decode/widget/suppress-widget + fi +} +function ble/widget/vi-command/commandline { + ble/keymap:vi/clear-arg + ble/keymap:vi/async-commandline-mode ble/widget/vi-command/commandline.hook + _ble_edit_PS1=: + ble/history/set-prefix _ble_keymap_vi_commandline + _ble_keymap_vi_cmap_before_widget=ble/keymap:vi/commandline/empty-cancel.hook + return 147 +} +function ble/widget/vi-command/commandline.hook { + local command + ble/string#split-words command "$1" + local cmd="ble/widget/vi-command:${command[0]}" + if ble/is-function "$cmd"; then + "$cmd" "${command[@]:1}"; local ext=$? + else + ble/widget/vi-command/bell "unknown command $1"; local ext=1 + fi + [[ $1 ]] && _ble_keymap_vi_register[58]=/$result # ": + return "$ext" +} +function ble/widget/vi-command:w { + local file= + if [[ $1 ]]; then + ble/builtin/history -a "$1" + file=$1 + elif [[ ${HISTFILE-} ]]; then + ble/builtin/history -a + file=$HISTFILE + else + ble/widget/vi-command/bell 'w: the history filename is empty or not specified' + return 1 + fi + local wc + ble/util/assign-words wc 'ble/bin/wc "$file"' + ble/edit/info/show text "\"$file\" ${wc[0]}L, ${wc[2]}C written" + ble/keymap:vi/adjust-command-mode + return 0 +} +function ble/widget/vi-command:q! { + ble/widget/exit force + return 1 +} +function ble/widget/vi-command:q { + ble/widget/exit + ble/keymap:vi/adjust-command-mode # ジョブがあるときは終了しないので。 + return 1 +} +function ble/widget/vi-command:wq { + ble/widget/vi-command:w "$@" + ble/widget/exit + ble/keymap:vi/adjust-command-mode + return 1 +} +_ble_keymap_vi_search_obackward= +_ble_keymap_vi_search_ohistory= +_ble_keymap_vi_search_needle= +_ble_keymap_vi_search_activate= +_ble_keymap_vi_search_matched= +_ble_keymap_vi_search_history=() +_ble_keymap_vi_search_history_edit=() +_ble_keymap_vi_search_history_dirt=() +_ble_keymap_vi_search_history_index=0 +bleopt/declare -v keymap_vi_search_match_current '' +function ble/highlight/layer:region/mark:vi_search/get-selection { + ble/highlight/layer:region/mark:vi_char/get-selection +} +function ble/keymap:vi/search/matched { + [[ $_ble_keymap_vi_search_matched || $_ble_edit_mark_active == vi_search || $_ble_keymap_vi_search_activate ]] +} +function ble/keymap:vi/search/clear-matched { + _ble_keymap_vi_search_activate= + _ble_keymap_vi_search_matched= + [[ $_ble_edit_mark_active == vi_search ]] && _ble_edit_mark_active= +} +function ble/keymap:vi/search/invoke-search { + local needle=$1 + local dir=+; ((opt_backward)) && dir=B + local ind=$_ble_edit_ind + if ((opt_optional_next)); then + if ((!opt_backward)); then + ((_ble_edit_ind<${#_ble_edit_str}&&_ble_edit_ind++)) + fi + elif ((opt_locate)) || ! ble/keymap:vi/search/matched; then + if ((opt_locate)) || [[ $bleopt_keymap_vi_search_match_current ]]; then + if ((opt_backward)); then + ble-edit/content/eolp || ((_ble_edit_ind++)) + fi + else + if ((!opt_backward)); then + ble-edit/content/eolp || ((_ble_edit_ind++)) + fi + fi + else + if ((!opt_backward)); then + if [[ $_ble_decode_keymap == vi_[xs]map ]]; then + if ble-edit/isearch/search "$@" && ((beg==_ble_edit_ind)); then + _ble_edit_ind=$end + else + ((_ble_edit_ind<${#_ble_edit_str}&&_ble_edit_ind++)) + fi + else + ((_ble_edit_ind=_ble_edit_mark)) + ble-edit/content/eolp || ((_ble_edit_ind++)) + fi + else + dir=- + fi + fi + ble-edit/isearch/search "$needle" "$dir":regex; local ret=$? + _ble_edit_ind=$ind + return "$ret" +} +function ble/widget/vi-command/search.core { + local beg= end= is_empty_match= + if ble/keymap:vi/search/invoke-search "$needle"; then + if ((beg'; [[ $word =~ $rex ]] && needle=$rex + if [[ $opts == backward ]]; then + ble/widget/vi-command/search.impl -:history "$needle" + else + local original_ind=$_ble_edit_ind + _ble_edit_ind=$((end-1)) + ble/widget/vi-command/search.impl +:history "$needle" && return 0 + _ble_edit_ind=$original_ind + return 1 + fi +} +function ble/widget/vi-command/search-word-forward { + ble/widget/vi-command/search-word.impl forward +} +function ble/widget/vi-command/search-word-backward { + ble/widget/vi-command/search-word.impl backward +} +function ble/widget/vi_nmap/command-help { + ble/keymap:vi/clear-arg + ble/widget/command-help; local ext=$? + ble/keymap:vi/adjust-command-mode + return "$ext" +} +function ble/widget/vi_xmap/command-help.core { + ble/keymap:vi/clear-arg + local get_selection=ble/highlight/layer:region/mark:$_ble_edit_mark_active/get-selection + ble/is-function "$get_selection" || return 1 + local selection + "$get_selection" || return 1 + ((${#selection[*]}==2)) || return 1 + local comp_cword=0 comp_line=$_ble_edit_str comp_point=$_ble_edit_ind + local -a comp_words; comp_words=("$cmd") + local cmd=${_ble_edit_str:selection[0]:selection[1]-selection[0]} + ble/widget/command-help.impl "$cmd"; local ext=$? + ble/keymap:vi/adjust-command-mode + return "$ext" +} +function ble/widget/vi_xmap/command-help { + if ! ble/widget/vi_xmap/command-help.core; then + ble/widget/vi-command/bell + return 1 + fi +} +function ble/keymap:vi/set-up-command-map { + ble-bind -f 0 vi-command/append-arg + ble-bind -f 1 vi-command/append-arg + ble-bind -f 2 vi-command/append-arg + ble-bind -f 3 vi-command/append-arg + ble-bind -f 4 vi-command/append-arg + ble-bind -f 5 vi-command/append-arg + ble-bind -f 6 vi-command/append-arg + ble-bind -f 7 vi-command/append-arg + ble-bind -f 8 vi-command/append-arg + ble-bind -f 9 vi-command/append-arg + ble-bind -f y 'vi-command/operator y' + ble-bind -f d 'vi-command/operator d' + ble-bind -f c 'vi-command/operator c' + ble-bind -f '<' 'vi-command/operator indent-left' + ble-bind -f '>' 'vi-command/operator indent-right' + ble-bind -f '!' 'vi-command/operator filter' + ble-bind -f 'g ~' 'vi-command/operator toggle_case' + ble-bind -f 'g u' 'vi-command/operator u' + ble-bind -f 'g U' 'vi-command/operator U' + ble-bind -f 'g ?' 'vi-command/operator rot13' + ble-bind -f 'g q' 'vi-command/operator fold' + ble-bind -f 'g w' 'vi-command/operator fold-preserve-point' + ble-bind -f 'g @' 'vi-command/operator map' + ble-bind -f paste_begin vi-command/bracketed-paste + ble-bind -f 'home' vi-command/beginning-of-line + ble-bind -f '$' vi-command/forward-eol + ble-bind -f 'end' vi-command/forward-eol + ble-bind -f '^' vi-command/first-non-space + ble-bind -f '_' vi-command/first-non-space-forward + ble-bind -f '+' vi-command/forward-first-non-space + ble-bind -f 'C-m' vi-command/forward-first-non-space + ble-bind -f 'RET' vi-command/forward-first-non-space + ble-bind -f '-' vi-command/backward-first-non-space + ble-bind -f 'g 0' vi-command/beginning-of-graphical-line + ble-bind -f 'g home' vi-command/beginning-of-graphical-line + ble-bind -f 'g ^' vi-command/graphical-first-non-space + ble-bind -f 'g $' vi-command/graphical-forward-eol + ble-bind -f 'g end' vi-command/graphical-forward-eol + ble-bind -f 'g m' vi-command/middle-of-graphical-line + ble-bind -f 'g _' vi-command/last-non-space + ble-bind -f h vi-command/backward-char + ble-bind -f l vi-command/forward-char + ble-bind -f left vi-command/backward-char + ble-bind -f right vi-command/forward-char + ble-bind -f 'C-?' 'vi-command/backward-char wrap' + ble-bind -f 'DEL' 'vi-command/backward-char wrap' + ble-bind -f 'C-h' 'vi-command/backward-char wrap' + ble-bind -f 'BS' 'vi-command/backward-char wrap' + ble-bind -f SP 'vi-command/forward-char wrap' + ble-bind -f j vi-command/forward-line + ble-bind -f down vi-command/forward-line + ble-bind -f C-n vi-command/forward-line + ble-bind -f C-j vi-command/forward-line + ble-bind -f k vi-command/backward-line + ble-bind -f up vi-command/backward-line + ble-bind -f C-p vi-command/backward-line + ble-bind -f 'g j' vi-command/graphical-forward-line + ble-bind -f 'g down' vi-command/graphical-forward-line + ble-bind -f 'g k' vi-command/graphical-backward-line + ble-bind -f 'g up' vi-command/graphical-backward-line + ble-bind -f w vi-command/forward-vword + ble-bind -f W vi-command/forward-uword + ble-bind -f b vi-command/backward-vword + ble-bind -f B vi-command/backward-uword + ble-bind -f e vi-command/forward-vword-end + ble-bind -f E vi-command/forward-uword-end + ble-bind -f 'g e' vi-command/backward-vword-end + ble-bind -f 'g E' vi-command/backward-uword-end + ble-bind -f C-right vi-command/forward-vword + ble-bind -f S-right vi-command/forward-vword + ble-bind -f C-left vi-command/backward-vword + ble-bind -f S-left vi-command/backward-vword + ble-bind -f 'g o' vi-command/nth-byte + ble-bind -f '|' vi-command/nth-column + ble-bind -f H vi-command/nth-line + ble-bind -f L vi-command/nth-last-line + ble-bind -f 'g g' vi-command/history-beginning + ble-bind -f G vi-command/history-end + ble-bind -f C-home vi-command/first-nol + ble-bind -f C-end vi-command/last-eol + ble-bind -f 'f' vi-command/search-forward-char + ble-bind -f 'F' vi-command/search-backward-char + ble-bind -f 't' vi-command/search-forward-char-prev + ble-bind -f 'T' vi-command/search-backward-char-prev + ble-bind -f ';' vi-command/search-char-repeat + ble-bind -f ',' vi-command/search-char-reverse-repeat + ble-bind -f '%' 'vi-command/search-matchpair-or vi-command/percentage-line' + ble-bind -f 'C-\ C-n' nop + ble-bind -f ':' vi-command/commandline + ble-bind -f '/' vi-command/search-forward + ble-bind -f '?' vi-command/search-backward + ble-bind -f 'n' vi-command/search-repeat + ble-bind -f 'N' vi-command/search-reverse-repeat + ble-bind -f '*' vi-command/search-word-forward + ble-bind -f '#' vi-command/search-word-backward + ble-bind -f '`' 'vi-command/goto-mark' + ble-bind -f \' 'vi-command/goto-mark line' + ble-bind -c 'C-z' fg +} +function ble/widget/vi_omap/operator-rot13-or-search-backward { + if [[ $_ble_keymap_vi_opfunc == rot13 ]]; then + ble/widget/vi-command/operator rot13 + else + ble/widget/vi-command/search-backward + fi +} +function ble/widget/vi_omap/switch-visual-mode.impl { + local new_mode=$1 + local old=$_ble_keymap_vi_opfunc + [[ $old ]] || return 1 + local new=$old: + new=${new/:vi_char:/:} + new=${new/:vi_line:/:} + new=${new/:vi_block:/:} + [[ $new_mode ]] && new=$new:$new_mode + _ble_keymap_vi_opfunc=$new +} +function ble/widget/vi_omap/switch-to-charwise { + ble/widget/vi_omap/switch-visual-mode.impl vi_char +} +function ble/widget/vi_omap/switch-to-linewise { + ble/widget/vi_omap/switch-visual-mode.impl vi_line +} +function ble/widget/vi_omap/switch-to-blockwise { + ble/widget/vi_omap/switch-visual-mode.impl vi_block +} +function ble-decode/keymap:vi_omap/define { + ble/keymap:vi/set-up-command-map + ble-bind -f __default__ vi_omap/__default__ + ble-bind -f __line_limit__ nop + ble-bind -f 'ESC' vi_omap/cancel + ble-bind -f 'C-[' vi_omap/cancel + ble-bind -f 'C-c' vi_omap/cancel + ble-bind -f a vi-command/text-object-outer + ble-bind -f i vi-command/text-object-inner + ble-bind -f v vi_omap/switch-to-charwise + ble-bind -f V vi_omap/switch-to-linewise + ble-bind -f C-v vi_omap/switch-to-blockwise + ble-bind -f C-q vi_omap/switch-to-blockwise + ble-bind -f '~' 'vi-command/operator toggle_case' + ble-bind -f 'u' 'vi-command/operator u' + ble-bind -f 'U' 'vi-command/operator U' + ble-bind -f '?' 'vi_omap/operator-rot13-or-search-backward' + ble-bind -f 'q' 'vi-command/operator fold' +} +function ble/widget/vi-command/exit-on-empty-line { + if [[ $_ble_edit_str ]]; then + ble/widget/vi_nmap/forward-scroll + return "$?" + else + ble/widget/exit + ble/keymap:vi/adjust-command-mode # ジョブがあるときは終了しないので。 + return 1 + fi +} +function ble/widget/vi-command/show-line-info { + local index count + ble/history/get-index -v index + ble/history/get-count -v count + local hist_ratio=$(((100*index+count-1)/count))% + local hist_stat=$'!\e[32m'$index$'\e[m / \e[32m'$count$'\e[m (\e[32m'$hist_ratio$'\e[m)' + local ret + ble/string#count-char "$_ble_edit_str" $'\n'; local nline=$((ret+1)) + ble/string#count-char "${_ble_edit_str::_ble_edit_ind}" $'\n'; local iline=$((ret+1)) + local line_ratio=$(((100*iline+nline-1)/nline))% + local line_stat=$'line \e[34m'$iline$'\e[m / \e[34m'$nline$'\e[m --\e[34m'$line_ratio$'\e[m--' + ble/edit/info/show ansi "\"$hist_stat\" $line_stat" + ble/keymap:vi/adjust-command-mode + return 0 +} +function ble/widget/vi-command/cancel { + if [[ $_ble_keymap_vi_single_command ]]; then + _ble_keymap_vi_single_command= + _ble_keymap_vi_single_command_overwrite= + ble/keymap:vi/update-mode-indicator + else + local joblist; ble/util/joblist + if ((${#joblist[*]})); then + ble/array#push joblist $'Type \e[35m:q!\e[m and press \e[35m\e[m to abandon all \e[31mjobs\e[m and exit Bash' + IFS=$'\n' builtin eval 'ble/edit/info/show ansi "${joblist[*]}"' + else + ble/edit/info/show ansi $'Type \e[35m:q\e[m and press \e[35m\e[m to exit Bash' + fi + fi + ble/widget/vi-command/bell + return 0 +} +bleopt/declare -v keymap_vi_imap_undo '' +_ble_keymap_vi_undo_suppress= +function ble/keymap:vi/undo/add { + [[ $_ble_keymap_vi_undo_suppress ]] && return 0 + [[ $1 == more && $bleopt_keymap_vi_imap_undo != more ]] && return 0 + ble-edit/undo/add +} +function ble/widget/vi_nmap/undo { + local ARG FLAG REG; ble/keymap:vi/get-arg 1 + local _ble_keymap_vi_undo_suppress=1 + ble/keymap:vi/mark/start-edit-area + if ble-edit/undo/undo "$ARG"; then + ble/keymap:vi/needs-eol-fix && ((_ble_edit_ind--)) + ble/keymap:vi/mark/end-edit-area + ble/keymap:vi/adjust-command-mode + else + ble/widget/vi-command/bell + return 1 + fi +} +function ble/widget/vi_nmap/redo { + local ARG FLAG REG; ble/keymap:vi/get-arg 1 + local _ble_keymap_vi_undo_suppress=1 + ble/keymap:vi/mark/start-edit-area + if ble-edit/undo/redo "$ARG"; then + ble/keymap:vi/needs-eol-fix && ((_ble_edit_ind--)) + ble/keymap:vi/mark/end-edit-area + ble/keymap:vi/adjust-command-mode + else + ble/widget/vi-command/bell + return 1 + fi +} +function ble/widget/vi_nmap/revert { + local ARG FLAG REG; ble/keymap:vi/get-arg 1 + local _ble_keymap_vi_undo_suppress=1 + ble/keymap:vi/mark/start-edit-area + if ble-edit/undo/revert-toggle "$ARG"; then + ble/keymap:vi/needs-eol-fix && ((_ble_edit_ind--)) + ble/keymap:vi/mark/end-edit-area + ble/keymap:vi/adjust-command-mode + else + ble/widget/vi-command/bell + return 1 + fi +} +function ble/widget/vi_nmap/increment.impl { + local delta=$1 + ((delta==0)) && return 0 + local line=${_ble_edit_str:_ble_edit_ind} + line=${line%%$'\n'*} + local rex='^([^0-9]*)[0-9]+' + if ! [[ $line =~ $rex ]]; then + [[ $line ]] && ble/widget/.bell 'number not found' + ble/keymap:vi/adjust-command-mode + return 0 + fi + local rematch1=${BASH_REMATCH[1]} + local beg=$((_ble_edit_ind+${#rematch1})) + local end=$((_ble_edit_ind+${#BASH_REMATCH})) + rex='-?[0-9]*$'; [[ ${_ble_edit_str::beg} =~ $rex ]] + ((beg-=${#BASH_REMATCH})) + local number=${_ble_edit_str:beg:end-beg} + local abs=${number#-} + if [[ $abs == 0?* ]]; then + if [[ $number == -* ]]; then + number=-$((10#0$abs)) + else + number=$((10#0$abs)) + fi + fi + ((number+=delta)) + if [[ $abs == 0?* ]]; then + local wsign=$((number<0?1:0)) + local zpad=$((wsign+${#abs}-${#number})) + if ((zpad>0)); then + local ret; ble/string#repeat 0 "$zpad" + number=${number::wsign}$ret${number:wsign} + fi + fi + ble/widget/.replace-range "$beg" "$end" "$number" + ble/keymap:vi/mark/set-previous-edit-area "$beg" "$((beg+${#number}))" + ble/keymap:vi/repeat/record + _ble_edit_ind=$((beg+${#number}-1)) + ble/keymap:vi/adjust-command-mode + return 0 +} +function ble/widget/vi_nmap/increment { + local ARG FLAG REG; ble/keymap:vi/get-arg 1 + ble/widget/vi_nmap/increment.impl "$ARG" +} +function ble/widget/vi_nmap/decrement { + local ARG FLAG REG; ble/keymap:vi/get-arg 1 + ble/widget/vi_nmap/increment.impl "$((-ARG))" +} +function ble/widget/vi_nmap/__line_limit__.edit { + ble/keymap:vi/clear-arg + ble/widget/vi_nmap/.insert-mode + ble/keymap:vi/repeat/clear-insert + ble/widget/edit-and-execute-command.impl "$1" +} +function ble/widget/vi_nmap/__line_limit__ { + ble/widget/__line_limit__ vi_nmap/__line_limit__.edit +} +function ble-decode/keymap:vi_nmap/define { + ble/keymap:vi/set-up-command-map + ble-bind -f __default__ vi-command/decompose-meta + ble-bind -f __line_limit__ vi_nmap/__line_limit__ + ble-bind -f 'ESC' vi-command/bell + ble-bind -f 'C-[' vi-command/bell + ble-bind -f 'C-c' vi-command/cancel + ble-bind -f a vi_nmap/append-mode + ble-bind -f A vi_nmap/append-mode-at-end-of-line + ble-bind -f i vi_nmap/insert-mode + ble-bind -f insert vi_nmap/insert-mode + ble-bind -f I vi_nmap/insert-mode-at-first-non-space + ble-bind -f 'g I' vi_nmap/insert-mode-at-beginning-of-line + ble-bind -f o vi_nmap/insert-mode-at-forward-line + ble-bind -f O vi_nmap/insert-mode-at-backward-line + ble-bind -f R vi_nmap/replace-mode + ble-bind -f 'g R' vi_nmap/virtual-replace-mode + ble-bind -f 'g i' vi_nmap/insert-mode-at-previous-point + ble-bind -f '~' vi_nmap/forward-char-toggle-case + ble-bind -f Y vi_nmap/copy-current-line + ble-bind -f S vi_nmap/kill-current-line-and-insert + ble-bind -f D vi_nmap/kill-forward-line + ble-bind -f C vi_nmap/kill-forward-line-and-insert + ble-bind -f p vi_nmap/paste-after + ble-bind -f P vi_nmap/paste-before + ble-bind -f x vi_nmap/kill-forward-char + ble-bind -f s vi_nmap/kill-forward-char-and-insert + ble-bind -f X vi_nmap/kill-backward-char + ble-bind -f delete vi_nmap/kill-forward-char + ble-bind -f 'r' vi_nmap/replace-char + ble-bind -f 'g r' vi_nmap/virtual-replace-char # vim で実際に試すとこの機能はない + ble-bind -f J vi_nmap/connect-line-with-space + ble-bind -f 'g J' vi_nmap/connect-line + ble-bind -f v vi_nmap/charwise-visual-mode + ble-bind -f V vi_nmap/linewise-visual-mode + ble-bind -f C-v vi_nmap/blockwise-visual-mode + ble-bind -f C-q vi_nmap/blockwise-visual-mode + ble-bind -f 'g v' vi-command/previous-visual-area + ble-bind -f 'g h' vi_nmap/charwise-select-mode + ble-bind -f 'g H' vi_nmap/linewise-select-mode + ble-bind -f 'g C-h' vi_nmap/blockwise-select-mode + ble-bind -f . vi_nmap/repeat + ble-bind -f K vi_nmap/command-help + ble-bind -f f1 vi_nmap/command-help + ble-bind -f 'C-d' vi_nmap/forward-line-scroll + ble-bind -f 'C-u' vi_nmap/backward-line-scroll + ble-bind -f 'C-e' vi_nmap/forward-scroll + ble-bind -f 'C-y' vi_nmap/backward-scroll + ble-bind -f 'C-f' vi_nmap/pagedown + ble-bind -f 'next' vi_nmap/pagedown + ble-bind -f 'C-b' vi_nmap/pageup + ble-bind -f 'prior' vi_nmap/pageup + ble-bind -f 'z t' vi_nmap/scroll-to-top-and-redraw + ble-bind -f 'z z' vi_nmap/scroll-to-center-and-redraw + ble-bind -f 'z b' vi_nmap/scroll-to-bottom-and-redraw + ble-bind -f 'z RET' vi_nmap/scroll-to-top-non-space-and-redraw + ble-bind -f 'z C-m' vi_nmap/scroll-to-top-non-space-and-redraw + ble-bind -f 'z +' vi_nmap/scroll-or-pagedown-and-redraw + ble-bind -f 'z -' vi_nmap/scroll-to-bottom-non-space-and-redraw + ble-bind -f 'z .' vi_nmap/scroll-to-center-non-space-and-redraw + ble-bind -f m vi-command/set-mark + ble-bind -f '"' vi-command/register + ble-bind -f 'C-g' vi-command/show-line-info + ble-bind -f 'q' vi_nmap/record-register + ble-bind -f '@' vi_nmap/play-register + ble-bind -f u vi_nmap/undo + ble-bind -f C-r vi_nmap/redo + ble-bind -f U vi_nmap/revert + ble-bind -f C-a vi_nmap/increment + ble-bind -f C-x vi_nmap/decrement + ble-bind -f 'Z Z' 'vi-command:q' + ble-bind -f 'Z Q' 'vi-command:q' + ble-bind -f 'C-j' 'accept-line' + ble-bind -f 'C-RET' 'accept-line' + ble-bind -f 'C-m' 'accept-single-line-or vi-command/forward-first-non-space' + ble-bind -f 'RET' 'accept-single-line-or vi-command/forward-first-non-space' + ble-bind -f 'C-l' 'clear-screen' + ble-bind -f 'C-d' 'vi-command/exit-on-empty-line' # overwrites vi_nmap/forward-scroll + ble-bind -f 'auto_complete_enter' auto-complete-enter + ble-bind -f M-left 'vi-command/backward-vword' + ble-bind -f M-right 'vi-command/forward-vword' + ble-bind -f C-delete 'vi-rlfunc/kill-word' + ble-bind -f '#' 'vi-rlfunc/insert-comment' + ble-bind -f '&' 'vi_nmap/@edit tilde-expand' +} +function ble/widget/vi-rlfunc/.is-uppercase { + local n=${#KEYS[@]} + local code=$((KEYS[n?n-1:0]&_ble_decode_MaskChar)) + ((0x41<=code&&code<=0x5a)) +} +function ble/widget/vi-rlfunc/delete-to { + if ble/widget/vi-rlfunc/.is-uppercase; then + ble/widget/vi_nmap/kill-forward-line + else + ble/widget/vi-command/operator d + fi +} +function ble/widget/vi-rlfunc/change-to { + if ble/widget/vi-rlfunc/.is-uppercase; then + ble/widget/vi_nmap/kill-forward-line-and-insert + else + ble/widget/vi-command/operator c + fi +} +function ble/widget/vi-rlfunc/yank-to { + if ble/widget/vi-rlfunc/.is-uppercase; then + ble/widget/vi_nmap/copy-current-line + else + ble/widget/vi-command/operator y + fi +} +function ble/widget/vi-rlfunc/char-search { + local n=${#KEYS[@]} + local code=$((KEYS[n?n-1:0]&_ble_decode_MaskChar)) + ((code==0)) && return 1 + ble/util/c2s "$code" + case $ret in + ('f') ble/widget/vi-command/search-forward-char ;; + ('F') ble/widget/vi-command/search-backward-char ;; + ('t') ble/widget/vi-command/search-forward-char-prev ;; + ('T') ble/widget/vi-command/search-backward-char-prev ;; + (';') ble/widget/vi-command/search-char-repeat ;; + (',') ble/widget/vi-command/search-char-reverse-repeat ;; + (*) return 1 ;; + esac +} +function ble/widget/vi-rlfunc/next-word { + if ble/widget/vi-rlfunc/.is-uppercase; then + ble/widget/vi-command/forward-uword + else + ble/widget/vi-command/forward-vword + fi +} +function ble/widget/vi-rlfunc/prev-word { + if ble/widget/vi-rlfunc/.is-uppercase; then + ble/widget/vi-command/backward-uword + else + ble/widget/vi-command/backward-vword + fi +} +function ble/widget/vi-rlfunc/end-word { + if ble/widget/vi-rlfunc/.is-uppercase; then + ble/widget/vi-command/forward-uword-end + else + ble/widget/vi-command/forward-vword-end + fi +} +function ble/widget/vi-rlfunc/put { + if ble/widget/vi-rlfunc/.is-uppercase; then + ble/widget/vi_nmap/paste-before + else + ble/widget/vi_nmap/paste-after + fi +} +function ble/widget/vi-rlfunc/search { + local n=${#KEYS[@]} + local code=$((KEYS[n?n-1:0]&_ble_decode_MaskChar)) + if ((code==63)); then + ble/widget/vi-command/search-backward + else + ble/widget/vi-command/search-forward + fi +} +function ble/widget/vi-rlfunc/search-again { + if ble/widget/vi-rlfunc/.is-uppercase; then + ble/widget/vi-command/search-reverse-repeat + else + ble/widget/vi-command/search-repeat + fi +} +function ble/widget/vi-rlfunc/subst { + if ble/widget/vi-rlfunc/.is-uppercase; then + ble/widget/vi_nmap/kill-current-line-and-insert + else + ble/widget/vi_nmap/kill-forward-char-and-insert + fi +} +function ble/widget/vi-rlfunc/kill-word { + _ble_keymap_vi_opfunc=d + ble/widget/vi-command/forward-vword-end +} +function ble/widget/vi-rlfunc/unix-line-discard { + _ble_keymap_vi_opfunc=d + ble/widget/vi-command/beginning-of-line +} +function ble/widget/vi-rlfunc/insert-comment { + local ARG FLAG REG; ble/keymap:vi/get-arg '' + ble/keymap:vi/mark/start-edit-area + ble/widget/insert-comment/.insert "$ARG" + ble/keymap:vi/mark/end-edit-area + ble/widget/vi_nmap/accept-line +} +function ble/widget/vi-rlfunc/quoted-insert-char.hook { + local ARG FLAG REG; ble/keymap:vi/get-arg 1 + ble/keymap:vi/mark/start-edit-area + _ble_edit_arg=$ARG ble/widget/quoted-insert-char.hook + ble/keymap:vi/mark/end-edit-area + ble/keymap:vi/repeat/record + ble/keymap:vi/adjust-command-mode + return 0 +} +function ble/widget/vi-rlfunc/quoted-insert-char { + _ble_edit_mark_active= + _ble_decode_char__hook=ble/widget/vi-rlfunc/quoted-insert-char.hook + return 147 +} +function ble/widget/vi-rlfunc/quoted-insert.hook { + local ARG FLAG REG; ble/keymap:vi/get-arg 1 + ble/keymap:vi/mark/start-edit-area + _ble_edit_arg=$ARG ble/widget/quoted-insert.hook + ble/keymap:vi/mark/end-edit-area + ble/keymap:vi/repeat/record + ble/keymap:vi/adjust-command-mode + return 0 +} +function ble/widget/vi-rlfunc/quoted-insert { + _ble_edit_mark_active= + _ble_decode_key__hook=ble/widget/vi-rlfunc/quoted-insert.hook + return 147 +} +function ble/widget/vi-rlfunc/eof-maybe { + if [[ ! $_ble_edit_str ]]; then + ble/widget/exit + ble/keymap:vi/adjust-command-mode # ジョブがあるときは終了しないので。 + return 1 + elif ble-edit/is-single-complete-line; then + ble/widget/vi_nmap/accept-line + else + local ARG FLAG REG; ble/keymap:vi/get-arg 1 + ble/keymap:vi/mark/start-edit-area + _ble_edit_ind=${#_ble_edit_str} + _ble_edit_arg=$ARG + ble/widget/self-insert + ble/keymap:vi/mark/end-edit-area + ble/keymap:vi/adjust-command-mode + fi +} +function ble/widget/vi-rlfunc/yank-arg { + ble/widget/vi_nmap/append-mode + ble/keymap:vi/imap-repeat/reset + local -a KEYS; KEYS=(32) + ble/widget/self-insert + ble/util/unlocal KEYS + ble/widget/insert-last-argument + return "$?" +} +function ble/widget/vi-command/forward-byte { + local ARG FLAG REG; ble/keymap:vi/get-arg 1 + local index=$_ble_edit_ind + ble/widget/.locate-forward-byte "$ARG" || [[ $FLAG ]] || ble/widget/.bell + ble/widget/vi-command/exclusive-goto.impl "$index" "$FLAG" "$REG" +} +function ble/widget/vi-command/backward-byte { + local ARG FLAG REG; ble/keymap:vi/get-arg 1 + local index=$_ble_edit_ind + ble/widget/.locate-forward-byte "$((-ARG))" || [[ $FLAG ]] || ble/widget/.bell + ble/widget/vi-command/exclusive-goto.impl "$index" "$FLAG" "$REG" +} +function ble/widget/vi-command/execute-named-command/accept.hook { + ble/keymap:vi/update-mode-indicator + ble/widget/execute-named-command/accept.hook "$1" +} +function ble/widget/vi-command/execute-named-command { + ble/keymap:vi/async-commandline-mode 'ble/widget/vi-command/execute-named-command/accept.hook' + _ble_edit_PS1='!' + _ble_keymap_vi_cmap_before_widget=ble/edit/async-read-mode/empty-cancel.hook + ble/history/set-prefix _ble_edit_rlfunc + return 147 +} +function ble/widget/vi_nmap/capitalize-XWORD { ble/widget/filter-word.impl XWORD ble/string#capitalize; } +function ble/widget/vi_nmap/downcase-XWORD { ble/widget/filter-word.impl XWORD ble/string#tolower; } +function ble/widget/vi_nmap/upcase-XWORD { ble/widget/filter-word.impl XWORD ble/string#toupper; } +function ble/widget/vi_nmap/@edit { + ble/keymap:vi/clear-arg + ble/keymap:vi/repeat/record + ble/keymap:vi/mark/start-edit-area + ble/widget/"$@" + ble/keymap:vi/needs-eol-fix && ((_ble_edit_ind--)) + ble/keymap:vi/mark/end-edit-area + ble/keymap:vi/adjust-command-mode +} +function ble/widget/vi_nmap/@adjust { + ble/keymap:vi/clear-arg + ble/widget/"$@" + ble/keymap:vi/adjust-command-mode +} +function ble/widget/vi_nmap/@motion { + local ARG FLAG REG; ble/keymap:vi/get-arg 1 + local _ble_edit_ind=$_ble_edit_ind _ble_edit_arg=$ARG + if ble/widget/"$@"; then + local index=$_ble_edit_ind + ble/util/unlocal _ble_edit_ind + ble/widget/vi-command/exclusive-goto.impl "$index" "$FLAG" "$REG" nobell + else + ble/keymap:vi/adjust-command-mode + fi +} +function ble/keymap:vi/xmap/has-eol-extension { + [[ $_ble_edit_mark_active == *+ ]] +} +function ble/keymap:vi/xmap/add-eol-extension { + [[ $_ble_edit_mark_active ]] && + _ble_edit_mark_active=${_ble_edit_mark_active%+}+ +} +function ble/keymap:vi/xmap/remove-eol-extension { + [[ $_ble_edit_mark_active ]] && + _ble_edit_mark_active=${_ble_edit_mark_active%+} +} +function ble/keymap:vi/xmap/switch-type { + local suffix; [[ $_ble_edit_mark_active == *+ ]] && suffix=+ + _ble_edit_mark_active=$1$suffix +} +function ble/keymap:vi/get-graphical-rectangle { + local p=${1:-$_ble_edit_mark} q=${2:-$_ble_edit_ind} + local ret + ble-edit/content/find-logical-bol "$p"; p0=$ret + ble-edit/content/find-logical-bol "$q"; q0=$ret + local p0x p0y q0x q0y + ble/textmap#getxy.out --prefix=p0 "$p0" + ble/textmap#getxy.out --prefix=q0 "$q0" + local plx ply qlx qly + ble/textmap#getxy.cur --prefix=pl "$p" + ble/textmap#getxy.cur --prefix=ql "$q" + local prx=$plx pry=$ply qrx=$qlx qry=$qly + ble-edit/content/eolp "$p" && ((prx++)) || ble/textmap#getxy.out --prefix=pr "$((p+1))" + ble-edit/content/eolp "$q" && ((qrx++)) || ble/textmap#getxy.out --prefix=qr "$((q+1))" + ((ply-=p0y,qly-=q0y,pry-=p0y,qry-=q0y, + (plyqry||pry==qry&&prx>qrx)?(rx=prx,ry=pry):(rx=qrx,ry=qry))) +} +function ble/keymap:vi/get-logical-rectangle { + local p=${1:-$_ble_edit_mark} q=${2:-$_ble_edit_ind} + local ret + ble-edit/content/find-logical-bol "$p"; p0=$ret + ble-edit/content/find-logical-bol "$q"; q0=$ret + ((p-=p0,q-=q0,p<=q)) || local p=$q q=$p + lx=$p rx=$((q+1)) ly=0 ry=0 +} +function ble/keymap:vi/get-rectangle { + if ble/edit/use-textmap; then + ble/keymap:vi/get-graphical-rectangle "$@" + else + ble/keymap:vi/get-logical-rectangle "$@" + fi +} +function ble/keymap:vi/get-rectangle-height { + local p0 q0 lx ly rx ry + ble/keymap:vi/get-rectangle "$@" + ble/string#count-char "${_ble_edit_str:p0:q0-p0}" $'\n' + ((ret++)) + return 0 +} +function ble/keymap:vi/extract-graphical-block-by-geometry { + local bol1=$1 bol2=$2 x1=$3 x2=$4 y1=0 y2=0 opts=$5 + ((bol1<=bol2||(bol1=$2,bol2=$1))) + [[ $x1 == *:* ]] && local x1=${x1%%:*} y1=${x1#*:} + [[ $x2 == *:* ]] && local x2=${x2%%:*} y2=${x2#*:} + local cols=$_ble_textmap_cols + local c1=$((cols*y1+x1)) c2=$((cols*y2+x2)) + sub_x1=$c1 sub_x2=$c2 + local ret index lx ly rx ly + ble-edit/content/find-logical-eol "$bol2"; local eol2=$ret + local lines; ble/string#split-lines lines "${_ble_edit_str:bol1:eol2-bol1}" + sub_ranges=() + local min_sfill=0 + local line bol=$bol1 eol bolx boly + local c1l c1r c2l c2r + for line in "${lines[@]}"; do + ((eol=bol+${#line})) + if [[ :$opts: == *:first_line:* ]] && ((${#sub_ranges[@]})); then + ble/array#push sub_ranges ::::: + elif [[ :$opts: == *:skip_middle:* ]] && ((0<${#sub_ranges[@]}&&${#sub_ranges[@]}<${#lines[@]}-1)); then + ble/array#push sub_ranges ::::: + else + ble/textmap#getxy.out --prefix=bol "$bol" + ble/textmap#hit out "$x1" "$((boly+y1))" "$bol" "$eol" + local smin=$index x1l=$lx y1l=$ly x1r=$rx y1r=$ry + if ble/keymap:vi/xmap/has-eol-extension; then + local eolx eoly; ble/textmap#getxy.out --prefix=eol "$eol" + local smax=$eol x2l=$eolx y2l=$eoly x2r=$eolx y2r=$eoly + else + ble/textmap#hit out "$x2" "$((boly+y2))" "$bol" "$eol" + local smax=$index x2l=$lx y2l=$ly x2r=$rx y2r=$ry + fi + local sfill=0 slpad=0 srpad=0 + local stext=${_ble_edit_str:smin:smax-smin} + if ((sminc1))' || ((c1r=c1)) + ble/string#repeat ' ' "$((c1r-c1))" + stext=$ret${stext:1} + fi + ((c2l=(y2l-boly)*cols+x2l)) + if ((c2lc2))' || ((c2r=c2)) + ((srpad=c2r-c2)) + fi + elif ((c2l>c2)); then + ((sfill=c2-c2l, + sfillc1)); then + ble/string#repeat ' ' "$((c2-c1))" + stext=$ret${stext:1} + ((smax++)) + ((c1l=(y1l-boly)*cols+x1l,slpad=c1-c1l)) + ((c1r=(y1r-boly)*cols+x1r,srpad=c1r-c1)) + fi + fi + ble/array#push sub_ranges "$smin:$smax:$slpad:$srpad:$sfill:$stext" + fi + ((bol=eol+1)) + done + if ((min_sfill<0)); then + local isub=${#sub_ranges[@]} + while ((isub--)); do + local sub=${sub_ranges[isub]} + local sub45=${sub#*:*:*:*:} + local sfill=${sub45%%:*} + sub_ranges[isub]=${sub::${#sub}-${#sub45}}$((sfill-min_sfill))${sub45:${#sfill}} + done + fi +} +function ble/keymap:vi/extract-graphical-block { + local opts=$3 + local p0 q0 lx ly rx ry + ble/keymap:vi/get-graphical-rectangle "$@" + ble/keymap:vi/extract-graphical-block-by-geometry "$p0" "$q0" "$lx:$ly" "$rx:$ry" "$opts" +} +function ble/keymap:vi/extract-logical-block-by-geometry { + local bol1=$1 bol2=$2 x1=$3 x2=$4 opts=$5 + ((bol1<=bol2||(bol1=$2,bol2=$1))) + sub_x1=$c1 sub_x2=$c2 + local ret min_sfill=0 + local bol=$bol1 eol smin smax slpad srpad sfill + sub_ranges=() + while :; do + ble-edit/content/find-logical-eol "$bol"; eol=$ret + slpad=0 srpad=0 sfill=0 + ((smin=bol+x1,smin>eol&&(smin=eol))) + if ble/keymap:vi/xmap/has-eol-extension; then + ((smax=eol, + sfill=bol+x2-eol, + sfilleol&&(sfill=smax-eol,smax=eol))) + fi + local stext=${_ble_edit_str:smin:smax-smin} + ble/array#push sub_ranges "$smin:$smax:$slpad:$srpad:$sfill:$stext" + ((bol>=bol2)) && break + ble-edit/content/find-logical-bol "$bol" 1; bol=$ret + done + if ((min_sfill<0)); then + local isub=${#sub_ranges[@]} + while ((isub--)); do + local sub=${sub_ranges[isub]} + local sub45=${sub#*:*:*:*:} + local sfill=${sub45%%:*} + sub_ranges[isub]=${sub::${#sub}-${#sub45}}$((sfill-min_sfill))${sub45:${#sfill}} + done + fi +} +function ble/keymap:vi/extract-logical-block { + local opts=$3 + local p0 q0 lx ly rx ry + ble/keymap:vi/get-logical-rectangle "$@" + ble/keymap:vi/extract-logical-block-by-geometry "$p0" "$q0" "$lx" "$rx" "$opts" +} +function ble/keymap:vi/extract-block { + if ble/edit/use-textmap; then + ble/keymap:vi/extract-graphical-block "$@" + else + ble/keymap:vi/extract-logical-block "$@" + fi +} +function ble/highlight/layer:region/mark:vi_char/get-selection { + local rmin rmax + if ((_ble_edit_mark<_ble_edit_ind)); then + rmin=$_ble_edit_mark rmax=$_ble_edit_ind + else + rmin=$_ble_edit_ind rmax=$_ble_edit_mark + fi + ble-edit/content/eolp "$rmax" || ((rmax++)) + selection=("$rmin" "$rmax") +} +function ble/highlight/layer:region/mark:vi_line/get-selection { + local rmin rmax + if ((_ble_edit_mark<_ble_edit_ind)); then + rmin=$_ble_edit_mark rmax=$_ble_edit_ind + else + rmin=$_ble_edit_ind rmax=$_ble_edit_mark + fi + local ret + ble-edit/content/find-logical-bol "$rmin"; rmin=$ret + ble-edit/content/find-logical-eol "$rmax"; rmax=$ret + selection=("$rmin" "$rmax") +} +function ble/highlight/layer:region/mark:vi_block/get-selection { + local sub_ranges sub_x1 sub_x2 + ble/keymap:vi/extract-block + selection=() + local sub + for sub in "${sub_ranges[@]}"; do + ble/string#split sub : "$sub" + ((sub[0]0)) || arg=1 + local prev; ble/string#split prev : "$_ble_keymap_vi_xmap_prev_edit" + _ble_edit_mark_active=${prev[0]:-vi_char} + local nchar=${prev[1]:-1} + local nline=${prev[2]:-1} + ((nchar<1&&(nchar=1),nline<1&&(nline=1))) + local is_x_relative=0 + if [[ ${_ble_edit_mark_active%+} == vi_block ]]; then + ((is_x_relative=1,nchar*=arg,nline*=arg)) + elif [[ ${_ble_edit_mark_active%+} == vi_line ]]; then + ((nline*=arg,is_x_relative=1,nchar=1)) + else + ((nline==1?(is_x_relative=1,nchar*=arg):(nline*=arg))) + fi + ((nchar--,nline--)) + local index ret + ble-edit/content/find-logical-bol "$_ble_edit_ind" 0; local b1=$ret + ble-edit/content/find-logical-bol "$_ble_edit_ind" "$nline"; local b2=$ret + ble-edit/content/find-logical-eol "$b2"; local e2=$ret + if ble/keymap:vi/xmap/has-eol-extension; then + index=$e2 + elif ble/edit/use-textmap; then + local cols=$_ble_textmap_cols + local b1x b1y b2x b2y x y + ble/textmap#getxy.out --prefix=b1 "$b1" + ble/textmap#getxy.out --prefix=b2 "$b2" + if ((is_x_relative)); then + ble/textmap#getxy.out "$_ble_edit_ind" + local c=$((x+(y-b1y)*cols+nchar)) + else + local c=$nchar + fi + ((y=c/cols,x=c%cols)) + local lx ly rx ry + ble/textmap#hit out "$x" "$((b2y+y))" "$b2" "$e2" + else + local c=$((is_x_relative?_ble_edit_ind-b1+nchar:nchar)) + ((index=b2+c,index>e2&&(index=e2))) + fi + _ble_edit_mark=$_ble_edit_ind + _ble_edit_ind=$index +} +_ble_keymap_vi_xmap_prev_visual= +ble/array#push _ble_textarea_local_VARNAMES \ + _ble_keymap_vi_xmap_prev_visual +function ble/keymap:vi/xmap/set-previous-visual-area { + local beg end + local mark_type=${_ble_edit_mark_active%+} + if [[ $mark_type == vi_block ]]; then + local sub_ranges sub_x1 sub_x2 + ble/keymap:vi/extract-block + local nrange=${#sub_ranges[*]} + ((nrange)) || return 1 + local beg=${sub_ranges[0]%%:*} + local sub2_slice1=${sub_ranges[nrange-1]#*:} + local end=${sub2_slice1%%:*} + ((beg +} +function ble/widget/vi-command/previous-visual-area { + local mark=$_ble_keymap_vi_xmap_prev_visual + local ret beg= end= + ble/keymap:vi/mark/get-local-mark 60 && beg=$ret # `< + ble/keymap:vi/mark/get-local-mark 62 && end=$ret # `> + [[ $beg && $end ]] || return 1 + if [[ $_ble_decode_keymap == vi_[xs]map ]]; then + ble/keymap:vi/clear-arg + ble/keymap:vi/xmap/set-previous-visual-area + _ble_edit_ind=$end + _ble_edit_mark=$beg + _ble_edit_mark_active=$mark + ble/keymap:vi/update-mode-indicator + else + ble/keymap:vi/clear-arg + ble/widget/vi-command/visual-mode.impl vi_xmap "$mark" + _ble_edit_ind=$end + _ble_edit_mark=$beg + fi + return 0 +} +function ble/widget/vi-command/visual-mode.impl { + local keymap=$1 visual_type=$2 + local ARG FLAG REG; ble/keymap:vi/get-arg 0 + if [[ $FLAG ]]; then + ble/widget/vi-command/bell + return 1 + fi + _ble_edit_overwrite_mode= + _ble_edit_mark=$_ble_edit_ind + _ble_edit_mark_active=$visual_type + _ble_keymap_vi_xmap_insert_data= # ※矩形挿入の途中で更に xmap に入ったときはキャンセル + ((ARG)) && ble/widget/vi_xmap/.restore-visual-state "$ARG" + ble/decode/keymap/push "$keymap" + ble/keymap:vi/update-mode-indicator + return 0 +} +function ble/widget/vi_nmap/charwise-visual-mode { + ble/widget/vi-command/visual-mode.impl vi_xmap vi_char +} +function ble/widget/vi_nmap/linewise-visual-mode { + ble/widget/vi-command/visual-mode.impl vi_xmap vi_line +} +function ble/widget/vi_nmap/blockwise-visual-mode { + ble/widget/vi-command/visual-mode.impl vi_xmap vi_block +} +function ble/widget/vi_nmap/charwise-select-mode { + ble/widget/vi-command/visual-mode.impl vi_smap vi_char +} +function ble/widget/vi_nmap/linewise-select-mode { + ble/widget/vi-command/visual-mode.impl vi_smap vi_line +} +function ble/widget/vi_nmap/blockwise-select-mode { + ble/widget/vi-command/visual-mode.impl vi_smap vi_block +} +function ble/widget/vi_xmap/exit { + if [[ $_ble_decode_keymap == vi_[xs]map ]]; then + ble/keymap:vi/xmap/set-previous-visual-area + _ble_edit_mark_active= + ble/decode/keymap/pop + ble/keymap:vi/update-mode-indicator + ble/keymap:vi/adjust-command-mode + fi + return 0 +} +function ble/widget/vi_xmap/cancel { + _ble_keymap_vi_single_command= + _ble_keymap_vi_single_command_overwrite= + ble-edit/content/nonbol-eolp && ((_ble_edit_ind--)) + ble/widget/vi_xmap/exit +} +function ble/widget/vi_xmap/switch-visual-mode.impl { + local visual_type=$1 + local ARG FLAG REG; ble/keymap:vi/get-arg 0 + if [[ $FLAG ]]; then + ble/widget/.bell + return 1 + fi + if [[ ${_ble_edit_mark_active%+} == "$visual_type" ]]; then + ble/widget/vi_xmap/cancel + else + ble/keymap:vi/xmap/switch-type "$visual_type" + ble/keymap:vi/update-mode-indicator + return 0 + fi +} +function ble/widget/vi_xmap/switch-to-charwise { + ble/widget/vi_xmap/switch-visual-mode.impl vi_char +} +function ble/widget/vi_xmap/switch-to-linewise { + ble/widget/vi_xmap/switch-visual-mode.impl vi_line +} +function ble/widget/vi_xmap/switch-to-blockwise { + ble/widget/vi_xmap/switch-visual-mode.impl vi_block +} +function ble/widget/vi_xmap/switch-to-select { + if [[ $_ble_decode_keymap == vi_xmap ]]; then + ble/decode/keymap/pop + ble/decode/keymap/push vi_smap + ble/keymap:vi/update-mode-indicator + fi +} +function ble/widget/vi_xmap/switch-to-visual { + if [[ $_ble_decode_keymap == vi_smap ]]; then + ble/decode/keymap/pop + ble/decode/keymap/push vi_xmap + ble/keymap:vi/update-mode-indicator + fi +} +function ble/widget/vi_xmap/switch-to-visual-blockwise { + if [[ $_ble_decode_keymap == vi_smap ]]; then + ble/decode/keymap/pop + ble/decode/keymap/push vi_xmap + fi + if [[ ${_ble_edit_mark_active%+} != vi_block ]]; then + ble/widget/vi_xmap/switch-to-blockwise + else + xble/keymap:vi/update-mode-indicator + fi +} +bleopt/declare -v keymap_vi_keymodel '' +function ble/widget/vi_smap/@nomarked { + [[ ,$bleopt_keymap_vi_keymodel, == *,stopsel,* ]] && + ble/widget/vi_xmap/exit + ble/widget/"$@" +} +function ble/widget/vi_smap/self-insert { + ble/widget/vi-command/operator c + ble/widget/self-insert +} +function ble/widget/vi_xmap/exchange-points { + ble/keymap:vi/xmap/remove-eol-extension + ble/widget/exchange-point-and-mark + return 0 +} +function ble/widget/vi_xmap/exchange-boundaries { + if [[ ${_ble_edit_mark_active%+} == vi_block ]]; then + ble/keymap:vi/xmap/remove-eol-extension + local sub_ranges sub_x1 sub_x2 + ble/keymap:vi/extract-block '' '' skip_middle + local nline=${#sub_ranges[@]} + ble/util/assert '((nline))' + local data1; ble/string#split data1 : "${sub_ranges[0]}" + local lpos1=${data1[0]} rpos1=$((data1[4]?data1[1]:data1[1]-1)) + if ((nline==1)); then + local lpos2=$lpos1 rpos2=$rpos1 + else + local data2; ble/string#split data2 : "${sub_ranges[nline-1]}" + local lpos2=${data2[0]} rpos2=$((data2[4]?data2[1]:data2[1]-1)) + fi + if ! ((lpos2<=_ble_edit_ind&&_ble_edit_ind<=rpos2)); then + local lpos1=$lpos2 lpos2=$lpos1 + local rpos1=$rpos2 rpos2=$rpos1 + fi + _ble_edit_mark=$((_ble_edit_mark==lpos1?rpos1:lpos1)) + _ble_edit_ind=$((_ble_edit_ind==lpos2?rpos2:lpos2)) + return 0 + else + ble/widget/vi_xmap/exchange-points + fi +} +function ble/widget/vi_xmap/visual-replace-char.hook { + local key=$1 + _ble_edit_overwrite_mode= + local ARG FLAG REG; ble/keymap:vi/get-arg 1 + local ret + if [[ $FLAG ]]; then + ble/widget/.bell + return 1 + elif ((key==(_ble_decode_Ctrl|91))); then # C-[ -> cancel + return 27 + elif ! ble/keymap:vi/k2c "$key"; then + ble/widget/.bell + return 1 + fi + local c=$ret + ble/util/c2s "$c"; local s=$ret + local old_mark_active=$_ble_edit_mark_active # save + local mark_type=${_ble_edit_mark_active%+} + ble/widget/vi_xmap/.save-visual-state + ble/widget/vi_xmap/exit # Note: _ble_edit_mark_active will be cleared here + if [[ $mark_type == vi_block ]]; then + ble/util/c2w "$c"; local w=$ret + ((w<=0)) && w=1 + local sub_ranges sub_x1 sub_x2 + _ble_edit_mark_active=$old_mark_active ble/keymap:vi/extract-block + local n=${#sub_ranges[@]} + if ((n==0)); then + ble/widget/.bell + return 1 + fi + local width=$((sub_x2-sub_x1)) + local count=$((width/w)) + ble/string#repeat "$s" "$count"; local ins=$ret + local pad=$((width-count*w)) + if ((pad)); then + ble/string#repeat ' ' "$pad"; ins=$ins$ret + fi + local i=$n sub smin=0 + ble/keymap:vi/mark/start-edit-area + while ((i--)); do + ble/string#split sub : "${sub_ranges[i]}" + local smin=${sub[0]} smax=${sub[1]} + local slpad=${sub[2]} srpad=${sub[3]} sfill=${sub[4]} + local ins1=$ins + ((sfill)) && ins1=${ins1::(width-sfill)/w} + ((slpad)) && { ble/string#repeat ' ' "$slpad"; ins1=$ret$ins1; } + ((srpad)) && { ble/string#repeat ' ' "$srpad"; ins1=$ins1$ret; } + ble/widget/.replace-range "$smin" "$smax" "$ins1" + done + local beg=$smin + ble/keymap:vi/needs-eol-fix "$beg" && ((beg--)) + _ble_edit_ind=$beg + ble/keymap:vi/mark/end-edit-area + ble/keymap:vi/repeat/record + else + local beg=$_ble_edit_mark end=$_ble_edit_ind + ((beg<=end)) || local beg=$end end=$beg + if [[ $mark_type == vi_line ]]; then + ble-edit/content/find-logical-bol "$beg"; local beg=$ret + ble-edit/content/find-logical-eol "$end"; local end=$ret + else + ble-edit/content/eolp "$end" || ((end++)) + fi + local ins=${_ble_edit_str:beg:end-beg} + ins=${ins//[!$'\n']/"$s"} + ble/widget/.replace-range "$beg" "$end" "$ins" + ble/keymap:vi/needs-eol-fix "$beg" && ((beg--)) + _ble_edit_ind=$beg + ble/keymap:vi/mark/set-previous-edit-area "$beg" "$end" + ble/keymap:vi/repeat/record + fi + return 0 +} +function ble/widget/vi_xmap/visual-replace-char { + _ble_edit_overwrite_mode=R + ble/keymap:vi/async-read-char ble/widget/vi_xmap/visual-replace-char.hook +} +function ble/widget/vi_xmap/linewise-operator.impl { + local op=$1 opts=$2 + local ARG FLAG REG; ble/keymap:vi/get-arg 1 + if [[ $FLAG ]]; then + ble/widget/.bell 'wrong keymap: xmap ではオペレータは設定されないはず' + return 1 + fi + local mark_type=${_ble_edit_mark_active%+} + local beg=$_ble_edit_mark end=$_ble_edit_ind + ((beg<=end)) || local beg=$end end=$beg + local call_operator= + if [[ :$opts: != *:force_line:* && $mark_type == vi_block ]]; then + call_operator=ble/keymap:vi/call-operator-blockwise + _ble_edit_mark_active=vi_block + [[ :$opts: == *:extend:* ]] && _ble_edit_mark_active=vi_block+ + else + call_operator=ble/keymap:vi/call-operator-linewise + _ble_edit_mark_active=vi_line + fi + local ble_keymap_vi_mark_active=$_ble_edit_mark_active + ble/widget/vi_xmap/.save-visual-state + ble/widget/vi_xmap/exit + "$call_operator" "$op" "$beg" "$end" "$ARG" "$REG"; local ext=$? + ((ext==147)) && return 147 + ((ext)) && ble/widget/.bell + ble/keymap:vi/adjust-command-mode + return "$ext" +} +function ble/widget/vi_xmap/replace-block-lines { ble/widget/vi_xmap/linewise-operator.impl c extend; } +function ble/widget/vi_xmap/delete-block-lines { ble/widget/vi_xmap/linewise-operator.impl d extend; } +function ble/widget/vi_xmap/delete-lines { ble/widget/vi_xmap/linewise-operator.impl d force_line; } +function ble/widget/vi_xmap/copy-block-or-lines { ble/widget/vi_xmap/linewise-operator.impl y; } +function ble/widget/vi_xmap/connect-line.impl { + local name=$1 + local ARG FLAG REG; ble/keymap:vi/get-arg 1 # ignored + local beg=$_ble_edit_mark end=$_ble_edit_ind + ((beg<=end)) || local beg=$end end=$beg + local ret; ble/string#count-char "${_ble_edit_str:beg:end-beg}" $'\n'; local nline=$((ret+1)) + ble/widget/vi_xmap/.save-visual-state + ble/widget/vi_xmap/exit # Note: _ble_edit_mark_active will be cleared here + _ble_edit_ind=$beg + _ble_edit_arg=$nline + _ble_keymap_vi_oparg= + _ble_keymap_vi_opfunc= + _ble_keymap_vi_reg= + "ble/widget/$name" +} +function ble/widget/vi_xmap/connect-line-with-space { + ble/widget/vi_xmap/connect-line.impl vi_nmap/connect-line-with-space +} +function ble/widget/vi_xmap/connect-line { + ble/widget/vi_xmap/connect-line.impl vi_nmap/connect-line +} +_ble_keymap_vi_xmap_insert_data= +_ble_keymap_vi_xmap_insert_dbeg=-1 +ble/array#push _ble_textarea_local_VARNAMES \ + _ble_keymap_vi_xmap_insert_data \ + _ble_keymap_vi_xmap_insert_dbeg +function ble/keymap:vi/xmap/update-dirty-range { + [[ $_ble_keymap_vi_insert_leave == ble/widget/vi_xmap/block-insert-mode.onleave ]] && + ((_ble_keymap_vi_xmap_insert_dbeg<0||beg<_ble_keymap_vi_xmap_insert_dbeg)) && + _ble_keymap_vi_xmap_insert_dbeg=$beg +} +function ble/widget/vi_xmap/block-insert-mode.impl { + local type=$1 + local ARG FLAG REG; ble/keymap:vi/get-arg 1 + local nline=${#sub_ranges[@]} + ble/util/assert '((nline))' + local index ins_x + if [[ $type == append ]]; then + local sub=${sub_ranges[0]#*:} + local smax=${sub%%:*} + index=$smax + if ble/keymap:vi/xmap/has-eol-extension; then + ins_x='$' + else + ins_x=$sub_x2 + fi + else + local sub=${sub_ranges[0]} + local smin=${sub%%:*} + index=$smin + ins_x=$sub_x1 + fi + ble/widget/vi_xmap/cancel + _ble_edit_ind=$index + ble/widget/vi_nmap/.insert-mode "$ARG" + ble/keymap:vi/repeat/record + ble/keymap:vi/mark/set-local-mark 1 "$_ble_edit_ind" + _ble_keymap_vi_xmap_insert_dbeg=-1 + local ret display_width + ble/string#count-char "${_ble_edit_str::_ble_edit_ind}" $'\n'; local iline=$ret + ble-edit/content/find-logical-bol; local bol=$ret + ble-edit/content/find-logical-eol; local eol=$ret + if ble/edit/use-textmap; then + local bx by ex ey + ble/textmap#getxy.out --prefix=b "$bol" + ble/textmap#getxy.out --prefix=e "$eol" + ((display_width=ex+_ble_textmap_cols*(ey-by))) + else + ((display_width=eol-bol)) + fi + _ble_keymap_vi_xmap_insert_data=$iline:$ins_x:$display_width:$nline + _ble_keymap_vi_insert_leave=ble/widget/vi_xmap/block-insert-mode.onleave + return 0 +} +function ble/widget/vi_xmap/block-insert-mode.onleave { + local data=$_ble_keymap_vi_xmap_insert_data + [[ $data ]] || continue + _ble_keymap_vi_xmap_insert_data= + ble/string#split data : "$data" + local ret + ble-edit/content/find-logical-bol; local bol=$ret + ble/string#count-char "${_ble_edit_str::bol}" $'\n'; ((ret==data[0])) || return 1 # 行番号 + ble/keymap:vi/mark/get-local-mark 1 || return 1; local mark=$ret # `[ + ble-edit/content/find-logical-bol "$mark"; ((bol==ret)) || return 1 # 記録行 `[ と同じか + local has_textmap= + if ble/edit/use-textmap; then + local cols=$_ble_textmap_cols + has_textmap=1 + fi + local new_width delta + ble-edit/content/find-logical-eol; local eol=$ret + if [[ $has_textmap ]]; then + local bx by ex ey + ble/textmap#getxy.out --prefix=b "$bol" + ble/textmap#getxy.out --prefix=e "$eol" + ((new_width=ex+cols*(ey-by))) + else + ((new_width=eol-bol)) + fi + ((delta=new_width-data[2])) + ((delta>0)) || return 1 # 縮んだ場合は処理しない + local x1=${data[1]} + [[ $x1 == '$' ]] && ((x1=data[2])) + ((x1>new_width&&(x1=new_width))) + if ((bol<=_ble_keymap_vi_xmap_insert_dbeg&&_ble_keymap_vi_xmap_insert_dbeg<=eol)); then + local px py + if [[ $has_textmap ]]; then + ble/textmap#getxy.out --prefix=p "$_ble_keymap_vi_xmap_insert_dbeg" + ((px+=cols*(py-by))) + else + ((px=_ble_keymap_vi_xmap_insert_dbeg-bol)) + fi + ((px>x1&&(x1=px))) + fi + local x2=$((x1+delta)) + local ins= p1 p2 + if [[ $has_textmap ]]; then + local index lx ly rx ry + ble/textmap#hit out "$((x1%cols))" "$((by+x1/cols))" "$bol" "$eol"; p1=$index + ble/textmap#hit out "$((x2%cols))" "$((by+x2/cols))" "$bol" "$eol"; p2=$index + ((lx+=(ly-by)*cols,rx+=(ry-by)*cols,lx!=rx&&p2++)) + else + ((p1=bol+x1,p2=bol+x2)) + fi + ins=${_ble_edit_str:p1:p2-p1} + local -a ins_beg=() ins_text=() + local iline=1 nline=${data[3]} strlen=${#_ble_edit_str} + for ((iline=1;iline index + local nfill + if ((index==eol&&(nfill=x1-lx+(ly-by)*cols)>0)); then + ble/string#repeat ' ' "$nfill"; lpad=$lpad$ret + fi + else + index=$((bol+x1)) + if ((index>eol)); then + ble/string#repeat ' ' "$((index-eol))"; lpad=$lpad$ret + ((index=eol)) + fi + fi + ble/array#push ins_beg "$index" + ble/array#push ins_text "$lpad$ins" + done + local i=${#ins_beg[@]} + ble/keymap:vi/mark/start-edit-area + ble/keymap:vi/mark/commit-edit-area "$p1" "$p2" + while ((i--)); do + local index=${ins_beg[i]} text=${ins_text[i]} + ble/widget/.replace-range "$index" "$index" "$text" + done + ble/keymap:vi/mark/end-edit-area + local index + if ble/keymap:vi/mark/get-local-mark 60 && index=$ret; then + ble/widget/vi-command/goto-mark.impl "$index" + else + ble-edit/content/find-logical-bol; index=$ret + fi + ble-edit/content/eolp || ((index++)) + _ble_edit_ind=$index + return 0 +} +function ble/widget/vi_xmap/insert-mode { + local mark_type=${_ble_edit_mark_active%+} + if [[ $mark_type == vi_block ]]; then + local sub_ranges sub_x1 sub_x2 + ble/keymap:vi/extract-block '' '' first_line + ble/widget/vi_xmap/block-insert-mode.impl insert + else + local ARG FLAG REG; ble/keymap:vi/get-arg 1 + local beg=$_ble_edit_mark end=$_ble_edit_ind + ((beg<=end)) || local beg=$end end=$beg + if [[ $mark_type == vi_line ]]; then + local ret + ble-edit/content/find-logical-bol "$beg"; beg=$ret + fi + ble/widget/vi_xmap/cancel + _ble_edit_ind=$beg + ble/widget/vi_nmap/.insert-mode "$ARG" + ble/keymap:vi/repeat/record + return 0 + fi +} +function ble/widget/vi_xmap/append-mode { + local mark_type=${_ble_edit_mark_active%+} + if [[ $mark_type == vi_block ]]; then + local sub_ranges sub_x1 sub_x2 + ble/keymap:vi/extract-block '' '' first_line + ble/widget/vi_xmap/block-insert-mode.impl append + else + local ARG FLAG REG; ble/keymap:vi/get-arg 1 + local beg=$_ble_edit_mark end=$_ble_edit_ind + ((beg<=end)) || local beg=$end end=$beg + if [[ $mark_type == vi_line ]]; then + if ((_ble_edit_mark>_ble_edit_ind)); then + local ret + ble-edit/content/find-logical-bol "$end"; end=$ret + fi + fi + ble-edit/content/eolp "$end" || ((end++)) + ble/widget/vi_xmap/cancel + _ble_edit_ind=$end + ble/widget/vi_nmap/.insert-mode "$ARG" + ble/keymap:vi/repeat/record + return 0 + fi +} +function ble/widget/vi_xmap/paste.impl { + local opts=$1 + [[ :$opts: != *:after:* ]]; local is_after=$? + local ARG FLAG REG; ble/keymap:vi/get-arg 1 + [[ $REG ]] && ble/keymap:vi/register#load "$REG" + local mark_type=${_ble_edit_mark_active%+} + local kill_ring=$_ble_edit_kill_ring + local kill_type=$_ble_edit_kill_type + local adjustment= + if [[ $mark_type == vi_block ]]; then + if [[ $kill_type == L ]]; then + if ((is_after)); then + local ret; ble/keymap:vi/get-rectangle-height; local nline=$ret + adjustment=lastline:$nline + fi + elif [[ $kill_type == B:* ]]; then + is_after=0 + else + is_after=0 + if [[ $kill_ring != *$'\n'* ]]; then + ((${#kill_ring}>=2)) && adjustment=index:$((${#kill_ring}*ARG-1)) + local ret; ble/keymap:vi/get-rectangle-height; local nline=$ret + ble/string#repeat "$kill_ring"$'\n' "$nline"; kill_ring=${ret%$'\n'} + ble/string#repeat '0 ' "$nline"; kill_type=B:${ret% } + fi + fi + elif [[ $mark_type == vi_line ]]; then + if [[ $kill_type == L ]]; then + is_after=0 + elif [[ $kill_type == B:* ]]; then + is_after=0 kill_type=L kill_ring=$kill_ring$'\n' + else + is_after=0 kill_type=L + [[ $kill_ring == *$'\n' ]] && kill_ring=$kill_ring$'\n' + fi + else + is_after=0 + [[ $kill_type == L ]] && adjustment=newline + fi + ble/keymap:vi/mark/start-edit-area + local _ble_keymap_vi_mark_suppress_edit=1 + { + ble/widget/vi-command/operator d; local ext=$? # _ble_edit_kill_{ring,type} is set here + if [[ $adjustment == newline ]]; then + local -a KEYS=(10) + ble/widget/self-insert + elif [[ $adjustment == lastline:* ]]; then + local ret + ble-edit/content/find-logical-bol "$_ble_edit_ind" "$((${adjustment#*:}-1))" + _ble_edit_ind=$ret + fi + local _ble_edit_kill_ring=$kill_ring + local _ble_edit_kill_type=$kill_type + ble/widget/vi_nmap/paste.impl "$ARG" '' "$is_after" + if [[ $adjustment == index:* ]]; then + local index=$((_ble_edit_ind+${adjustment#*:})) + ((index>${#_ble_edit_str}&&(index=${#_ble_edit_str}))) + ble/keymap:vi/needs-eol-fix "$index" && ((index--)) + _ble_edit_ind=$index + fi + } + ble/util/unlocal _ble_keymap_vi_mark_suppress_edit + ble/keymap:vi/mark/end-edit-area + ble/keymap:vi/repeat/record + return "$ext" +} +function ble/widget/vi_xmap/paste-after { + ble/widget/vi_xmap/paste.impl after +} +function ble/widget/vi_xmap/paste-before { + ble/widget/vi_xmap/paste.impl before +} +function ble/widget/vi_xmap/increment.impl { + local opts=$1 + local ARG FLAG REG; ble/keymap:vi/get-arg 1 + if [[ $FLAG ]]; then + ble/widget/.bell + return 1 + fi + local delta=$ARG + [[ :$opts: == *:decrease:* ]] && ((delta=-delta)) + local progress=0 + [[ :$opts: == *:progressive:* ]] && progress=$delta + local old_mark_active=$_ble_edit_mark_active # save + local mark_type=${_ble_edit_mark_active%+} + ble/widget/vi_xmap/.save-visual-state + ble/widget/vi_xmap/exit # Note: _ble_edit_mark_active will be cleared here + if [[ $mark_type == vi_block ]]; then + local sub_ranges sub_x1 sub_x2 + _ble_edit_mark_active=$old_mark_active ble/keymap:vi/extract-block + if ((${#sub_ranges[@]}==0)); then + ble/widget/.bell + return 1 + fi + else + local beg=$_ble_edit_mark end=$_ble_edit_ind + ((beg<=end)) || local beg=$end end=$beg + if [[ $mark_type == vi_line ]]; then + local ret + ble-edit/content/find-logical-bol "$beg"; local beg=$ret + ble-edit/content/find-logical-eol "$end"; local end=$ret + else + ble-edit/content/eolp "$end" || ((end++)) + fi + local -a lines + ble/string#split-lines lines "${_ble_edit_str:beg:end-beg}" + local line index=$beg + local -a sub_ranges + for line in "${lines[@]}"; do + [[ $line ]] && ble/array#push sub_ranges "$index:::::$line" + ((index+=${#line}+1)) + done + ((${#sub_ranges[@]})) || return 0 + fi + local sub rex_number='^([^0-9]*)([0-9]+)' shift=0 dmin=-1 dmax=-1 + for sub in "${sub_ranges[@]}"; do + local stext=${sub#*:*:*:*:*:} + [[ $stext =~ $rex_number ]] || continue + local rematch1=${BASH_REMATCH[1]} + local rematch2=${BASH_REMATCH[2]} + local offset=${#rematch1} length=${#rematch2} + local number=$((10#0$rematch2)) + [[ $rematch1 == *- ]] && ((number=-number,offset--,length++)) + ((number+=delta,delta+=progress)) + if [[ $rematch2 == 0?* ]]; then + local wsign=$((number<0?1:0)) + local zpad=$((wsign+${#rematch2}-${#number})) + if ((zpad>0)); then + local ret; ble/string#repeat 0 "$zpad" + number=${number::wsign}$ret${number:wsign} + fi + fi + local smin=${sub%%:*} + local beg=$((shift+smin+offset)) + local end=$((beg+length)) + ble/widget/.replace-range "$beg" "$end" "$number" + ((shift+=${#number}-length, + dmin<0&&(dmin=beg), + dmax=beg+${#number})) + done + local beg=${sub_ranges[0]%%:*} + ble/keymap:vi/needs-eol-fix "$beg" && ((beg--)) + _ble_edit_ind=$beg + ((dmin>=0)) && ble/keymap:vi/mark/set-previous-edit-area "$dmin" "$dmax" + ble/keymap:vi/repeat/record + return 0 +} +function ble/widget/vi_xmap/increment { ble/widget/vi_xmap/increment.impl increase; } +function ble/widget/vi_xmap/decrement { ble/widget/vi_xmap/increment.impl decrease; } +function ble/widget/vi_xmap/progressive-increment { ble/widget/vi_xmap/increment.impl progressive:increase; } +function ble/widget/vi_xmap/progressive-decrement { ble/widget/vi_xmap/increment.impl progressive:decrease; } +function ble-decode/keymap:vi_xmap/define { + ble/keymap:vi/set-up-command-map + ble-bind -f __default__ vi-command/decompose-meta + ble-bind -f 'ESC' vi_xmap/exit + ble-bind -f 'C-[' vi_xmap/exit + ble-bind -f 'C-c' vi_xmap/cancel + ble-bind -f '"' vi-command/register + ble-bind -f a vi-command/text-object-outer + ble-bind -f i vi-command/text-object-inner + ble-bind -f 'C-\ C-n' vi_xmap/cancel + ble-bind -f 'C-\ C-g' vi_xmap/cancel + ble-bind -f v vi_xmap/switch-to-charwise + ble-bind -f V vi_xmap/switch-to-linewise + ble-bind -f C-v vi_xmap/switch-to-blockwise + ble-bind -f C-q vi_xmap/switch-to-blockwise + ble-bind -f 'g v' vi-command/previous-visual-area + ble-bind -f C-g vi_xmap/switch-to-select + ble-bind -f o vi_xmap/exchange-points + ble-bind -f O vi_xmap/exchange-boundaries + ble-bind -f '~' 'vi-command/operator toggle_case' + ble-bind -f 'u' 'vi-command/operator u' + ble-bind -f 'U' 'vi-command/operator U' + ble-bind -f 's' 'vi-command/operator c' + ble-bind -f 'x' 'vi-command/operator d' + ble-bind -f delete 'vi-command/operator d' + ble-bind -f r vi_xmap/visual-replace-char + ble-bind -f C vi_xmap/replace-block-lines + ble-bind -f D vi_xmap/delete-block-lines + ble-bind -f X vi_xmap/delete-block-lines + ble-bind -f S vi_xmap/delete-lines + ble-bind -f R vi_xmap/delete-lines + ble-bind -f Y vi_xmap/copy-block-or-lines + ble-bind -f J vi_xmap/connect-line-with-space + ble-bind -f 'g J' vi_xmap/connect-line + ble-bind -f I vi_xmap/insert-mode + ble-bind -f A vi_xmap/append-mode + ble-bind -f p vi_xmap/paste-after + ble-bind -f P vi_xmap/paste-before + ble-bind -f 'C-a' vi_xmap/increment + ble-bind -f 'C-x' vi_xmap/decrement + ble-bind -f 'g C-a' vi_xmap/progressive-increment + ble-bind -f 'g C-x' vi_xmap/progressive-decrement + ble-bind -f f1 vi_xmap/command-help + ble-bind -f K vi_xmap/command-help +} +function ble-decode/keymap:vi_smap/define { + ble-bind -f __default__ vi-command/decompose-meta + ble-bind -f 'ESC' vi_xmap/exit + ble-bind -f 'C-[' vi_xmap/exit + ble-bind -f 'C-c' vi_xmap/cancel + ble-bind -f 'C-\ C-n' nop + ble-bind -f 'C-\ C-n' vi_xmap/cancel + ble-bind -f 'C-\ C-g' vi_xmap/cancel + ble-bind -f C-v vi_xmap/switch-to-visual-blockwise + ble-bind -f C-q vi_xmap/switch-to-visual-blockwise + ble-bind -f C-g vi_xmap/switch-to-visual + ble-bind -f delete 'vi-command/operator d' + ble-bind -f 'C-?' 'vi-command/operator d' + ble-bind -f 'DEL' 'vi-command/operator d' + ble-bind -f 'C-h' 'vi-command/operator d' + ble-bind -f 'BS' 'vi-command/operator d' + ble-bind -f __defchar__ vi_smap/self-insert + ble-bind -f paste_begin vi-command/bracketed-paste + ble-bind -f 'C-a' vi_xmap/increment + ble-bind -f 'C-x' vi_xmap/decrement + ble-bind -f f1 vi_xmap/command-help + ble-bind -c 'C-z' fg + ble-bind -f home 'vi_smap/@nomarked vi-command/beginning-of-line' + ble-bind -f end 'vi_smap/@nomarked vi-command/forward-eol' + ble-bind -f C-m 'vi_smap/@nomarked vi-command/forward-first-non-space' + ble-bind -f RET 'vi_smap/@nomarked vi-command/forward-first-non-space' + ble-bind -f S-home 'vi-command/beginning-of-line' + ble-bind -f S-end 'vi-command/forward-eol' + ble-bind -f S-C-m 'vi-command/forward-first-non-space' + ble-bind -f S-RET 'vi-command/forward-first-non-space' + ble-bind -f C-right 'vi_smap/@nomarked vi-command/forward-vword' + ble-bind -f C-left 'vi_smap/@nomarked vi-command/backward-vword' + ble-bind -f S-C-right 'vi-command/forward-vword' + ble-bind -f S-C-left 'vi-command/backward-vword' + ble-bind -f left 'vi_smap/@nomarked vi-command/backward-char' + ble-bind -f right 'vi_smap/@nomarked vi-command/forward-char' + ble-bind -f 'C-?' 'vi_smap/@nomarked vi-command/backward-char wrap' + ble-bind -f 'DEL' 'vi_smap/@nomarked vi-command/backward-char wrap' + ble-bind -f 'C-h' 'vi_smap/@nomarked vi-command/backward-char wrap' + ble-bind -f 'BS' 'vi_smap/@nomarked vi-command/backward-char wrap' + ble-bind -f SP 'vi_smap/@nomarked vi-command/forward-char wrap' + ble-bind -f S-left 'vi-command/backward-char' + ble-bind -f S-right 'vi-command/forward-char' + ble-bind -f 'S-C-?' 'vi-command/backward-char wrap' + ble-bind -f 'S-DEL' 'vi-command/backward-char wrap' + ble-bind -f 'S-C-h' 'vi-command/backward-char wrap' + ble-bind -f 'S-BS' 'vi-command/backward-char wrap' + ble-bind -f S-SP 'vi-command/forward-char wrap' + ble-bind -f down 'vi_smap/@nomarked vi-command/forward-line' + ble-bind -f C-n 'vi_smap/@nomarked vi-command/forward-line' + ble-bind -f C-j 'vi_smap/@nomarked vi-command/forward-line' + ble-bind -f up 'vi_smap/@nomarked vi-command/backward-line' + ble-bind -f C-p 'vi_smap/@nomarked vi-command/backward-line' + ble-bind -f C-home 'vi_smap/@nomarked vi-command/first-nol' + ble-bind -f C-end 'vi_smap/@nomarked vi-command/last-eol' + ble-bind -f S-down 'vi-command/forward-line' + ble-bind -f S-C-n 'vi-command/forward-line' + ble-bind -f S-C-j 'vi-command/forward-line' + ble-bind -f S-up 'vi-command/backward-line' + ble-bind -f S-C-p 'vi-command/backward-line' + ble-bind -f S-C-home 'vi-command/first-nol' + ble-bind -f S-C-end 'vi-command/last-eol' +} +function ble/widget/vi_imap/__attach__ { + ble/keymap:vi/update-mode-indicator + return 0 +} +function ble/widget/vi_imap/__detach__ { + ble/edit/info/default clear + ble/keymap:vi/clear-arg + ble/keymap:vi/search/clear-matched + return 0 +} +function ble/widget/vi_imap/accept-single-line-or { + if ble-edit/is-single-complete-line; then + ble/keymap:vi/imap-repeat/reset + ble/widget/accept-line + else + ble/widget/"$@" + fi +} +function ble/widget/vi_imap/delete-region-or { + if [[ $_ble_edit_mark_active ]]; then + ble/keymap:vi/imap-repeat/reset + if ((_ble_edit_ind!=_ble_edit_mark)); then + ble/keymap:vi/undo/add more + ble/widget/delete-region + ble/keymap:vi/undo/add more + fi + else + ble/widget/"$@" + fi +} +function ble/widget/vi_imap/overwrite-mode { + ble-edit/content/clear-arg + if [[ $_ble_edit_overwrite_mode ]]; then + _ble_edit_overwrite_mode= + else + _ble_edit_overwrite_mode=${_ble_keymap_vi_insert_overwrite:-R} + fi + ble/keymap:vi/update-mode-indicator + return 0 +} +function ble/widget/vi_imap/.locate-backward-word { + local space=$' \t' nl=$'\n' + local rex='('$_ble_keymap_vi_REX_WORD')['$space']*$|['$space']+$|'$nl'$' + [[ ${_ble_edit_str::_ble_edit_ind} =~ $rex ]] || return 1 + ((ret=_ble_edit_ind-${#BASH_REMATCH})) + return 0 +} +function ble/widget/vi_imap/delete-backward-word { + if local ret; ble/widget/vi_imap/.locate-backward-word; then + if ((ret!=_ble_edit_ind)); then + ble/keymap:vi/undo/add more + ble/widget/.delete-range "$ret" "$_ble_edit_ind" + ble/keymap:vi/undo/add more + fi + return 0 + else + ble/widget/.bell + return 1 + fi +} +function ble/widget/vi_imap/kill-backward-word { + if local ret; ble/widget/vi_imap/.locate-backward-word; then + if ((ret!=_ble_edit_ind)); then + ble/keymap:vi/undo/add more + ble/widget/.kill-range "$ret" "$_ble_edit_ind" + ble/keymap:vi/undo/add more + fi + return 0 + else + ble/widget/.bell + return 1 + fi +} +function ble/widget/vi_imap/copy-backward-word { + if local ret; ble/widget/vi_imap/.locate-backward-word; then + if ((ret!=_ble_edit_ind)); then + ble/widget/.copy-range "$ret" "$_ble_edit_ind" + fi + return 0 + else + ble/widget/.bell + return 1 + fi +} +function ble/widget/vi_imap/quoted-insert-char { + ble/keymap:vi/imap-repeat/pop + _ble_edit_mark_active= + _ble_decode_char__hook=ble/widget/vi_imap/quoted-insert-char.hook + return 147 +} +function ble/widget/vi_imap/quoted-insert-char.hook { + ble/keymap:vi/imap/invoke-widget ble/widget/self-insert "$1" +} +function ble/widget/vi_imap/quoted-insert { + ble/keymap:vi/imap-repeat/pop + _ble_edit_mark_active= + _ble_decode_key__hook=ble/widget/vi_imap/quoted-insert.hook + return 147 +} +function ble/widget/vi_imap/quoted-insert.hook { + ble/keymap:vi/imap/invoke-widget ble/widget/quoted-insert.hook "$1" +} +function ble/widget/vi_imap/bracketed-paste { + ble/keymap:vi/imap-repeat/pop + ble/widget/bracketed-paste + _ble_edit_bracketed_paste_proc=ble/widget/vi_imap/bracketed-paste.proc + return 147 +} +function ble/widget/vi_imap/bracketed-paste.proc { + local WIDGET=ble/widget/batch-insert + local -a KEYS; KEYS=("$@") + ble/keymap:vi/imap-repeat/push + builtin eval -- "$WIDGET" +} +_ble_keymap_vi_bracketed_paste_mark_active= +function ble/widget/vi-command/bracketed-paste { + local ARG FLAG REG; ble/keymap:vi/get-arg 1 # discard args + _ble_keymap_vi_bracketed_paste_mark_active=$_ble_edit_mark_active + _ble_edit_mark_active= + ble/widget/bracketed-paste + _ble_edit_bracketed_paste_proc=ble/widget/vi-command/bracketed-paste.proc + return 147 +} +function ble/widget/vi-command/bracketed-paste.proc { + if [[ $_ble_decode_keymap == vi_nmap ]]; then + local isbol index=$_ble_edit_ind + ble-edit/content/bolp && isbol=1 + ble/decode/widget/call-interactively 'ble/widget/vi_nmap/append-mode' 97 + [[ $isbol ]] && ((_ble_edit_ind=index)) # 行頭にいたときは戻る + ble/widget/vi_imap/bracketed-paste.proc "$@" + ble/keymap:vi/imap/invoke-widget \ + ble/widget/vi_imap/normal-mode "$((_ble_decode_Ctrl|0x5b))" + elif [[ $_ble_decode_keymap == vi_[xs]map ]]; then + local _ble_edit_mark_active=$_ble_keymap_vi_bracketed_paste_mark_active + ble/decode/widget/call-interactively 'ble/widget/vi-command/operator c' 99 || return 1 + ble/widget/vi_imap/bracketed-paste.proc "$@" + ble/keymap:vi/imap/invoke-widget \ + ble/widget/vi_imap/normal-mode "$((_ble_decode_Ctrl|0x5b))" + elif [[ $_ble_decode_keymap == vi_omap ]]; then + ble/widget/vi_omap/cancel + ble/widget/.bell + return 1 + else # vi_omap + ble/widget/.bell + return 1 + fi +} +function ble/widget/vi_imap/insert-digraph.hook { + local -a KEYS; KEYS=("$1") + ble/widget/self-insert +} +function ble/widget/vi_imap/insert-digraph { + ble/decode/keymap/push vi_digraph + _ble_keymap_vi_digraph__hook=ble/widget/vi_imap/insert-digraph.hook + return 0 +} +function ble/widget/vi_imap/newline { + local ret + ble-edit/content/find-logical-bol; local bol=$ret + ble-edit/content/find-non-space "$bol"; local nol=$ret + ble/widget/default/newline + ((bol' 'history-end' + ble-bind -f 'M-.' 'insert-last-argument' + ble-bind -f 'M-_' 'insert-last-argument' + ble-bind -f 'M-C-y' 'insert-nth-argument' + ble-bind -f 'M-?' 'complete show_menu' + ble-bind -f 'M-*' 'complete insert_all' + ble-bind -f 'M-{' 'complete insert_braces' + ble-bind -f 'M-/' 'complete context=filename' + ble-bind -f 'M-~' 'complete context=username' + ble-bind -f 'M-$' 'complete context=variable' + ble-bind -f 'M-@' 'complete context=hostname' + ble-bind -f 'M-!' 'complete context=command' + ble-bind -f "M-'" 'sabbrev-expand' + ble-bind -f 'M-g' 'complete context=glob' + ble-bind -f 'M-C-i' 'complete context=dynamic-history' + ble-bind -f 'M-TAB' 'complete context=dynamic-history' + ble-bind -f 'M-0' 'append-arg' + ble-bind -f 'M-1' 'append-arg' + ble-bind -f 'M-2' 'append-arg' + ble-bind -f 'M-3' 'append-arg' + ble-bind -f 'M-4' 'append-arg' + ble-bind -f 'M-5' 'append-arg' + ble-bind -f 'M-6' 'append-arg' + ble-bind -f 'M-7' 'append-arg' + ble-bind -f 'M-8' 'append-arg' + ble-bind -f 'M-9' 'append-arg' +} +_ble_keymap_vi_cmap_accept_hook= +_ble_keymap_vi_cmap_cancel_hook= +_ble_keymap_vi_cmap_before_widget= +_ble_keymap_vi_cmap_history=() +_ble_keymap_vi_cmap_history_edit=() +_ble_keymap_vi_cmap_history_dirt=() +_ble_keymap_vi_cmap_history_index=0 +function ble/keymap:vi/async-commandline-mode { + ble/edit/async-read-mode "$1" _ble_keymap_vi_cmap vi_cmap + ble/keymap:vi/update-mode-indicator + return 147 +} +function ble/widget/vi_cmap/accept { + local hook=$_ble_keymap_vi_cmap_accept_hook + _ble_keymap_vi_cmap_accept_hook= + local ret + ble/edit/async-read-mode/accept + ble/keymap:vi/update-mode-indicator + if [[ $hook ]]; then + builtin eval -- "$hook \"\$ret\"" + else + ble/keymap:vi/adjust-command-mode + return 0 + fi +} +function ble/widget/vi_cmap/cancel { + _ble_keymap_vi_cmap_accept_hook=$_ble_keymap_vi_cmap_cancel_hook + ble/widget/vi_cmap/accept +} +function ble/widget/vi_cmap/__before_widget__ { + if [[ $_ble_keymap_vi_cmap_before_widget ]]; then + builtin eval -- "$_ble_keymap_vi_cmap_before_widget" + fi +} +function ble/widget/vi_cmap/__line_limit__.edit { + local content=$1 + ble/widget/edit-and-execute-command.edit "$content" no-newline; local ext=$? + ((ext==127)) && return "$ext" + ble-edit/content/reset "$ret" + ble/widget/vi_cmap/accept +} +function ble/widget/vi_cmap/__line_limit__ { + ble/widget/__line_limit__ vi_cmap/__line_limit__.edit +} +function ble-decode/keymap:vi_cmap/define { + local ble_bind_nometa= + ble-decode/keymap:safe/bind-common + ble-decode/keymap:safe/bind-history + ble-decode/keymap:safe/bind-complete + ble-bind -f __before_widget__ vi_cmap/__before_widget__ + ble-bind -f __line_limit__ vi_cmap/__line_limit__ + ble-bind -f 'ESC' vi_cmap/cancel + ble-bind -f 'C-[' vi_cmap/cancel + ble-bind -f 'C-c' vi_cmap/cancel + ble-bind -f 'C-m' vi_cmap/accept + ble-bind -f 'RET' vi_cmap/accept + ble-bind -f 'C-j' vi_cmap/accept + ble-bind -f 'C-g' bell + ble-bind -f 'C-x C-g' bell + ble-bind -f 'C-M-g' bell + ble-bind -f 'C-l' redraw-line + ble-bind -f 'C-M-l' redraw-line + ble-bind -f 'C-x C-v' display-shell-version + ble-bind -f 'C-\' bell + ble-bind -f 'C-^' bell +} +function ble-decode/keymap:vi/initialize { + local fname_keymap_cache=$_ble_base_cache/keymap.vi + if [[ -s $fname_keymap_cache && + $fname_keymap_cache -nt $_ble_base/lib/keymap.vi.sh && + $fname_keymap_cache -nt $_ble_base/lib/init-cmap.sh ]]; then + source "$fname_keymap_cache" && return 0 + fi + ble/edit/info/immediate-show text "ble.sh: updating cache/keymap.vi..." + { + ble/decode/keymap#load isearch dump + ble/decode/keymap#load nsearch dump + ble/decode/keymap#load vi_imap dump + ble/decode/keymap#load vi_nmap dump + ble/decode/keymap#load vi_omap dump + ble/decode/keymap#load vi_xmap dump + ble/decode/keymap#load vi_cmap dump + } 3>| "$fname_keymap_cache" + ble/edit/info/immediate-show text "ble.sh: updating cache/keymap.vi... done" +} +ble-decode/keymap:vi/initialize +ble_bind_keymap=vi_imap blehook/invoke keymap_load +ble_bind_keymap=vi_imap blehook/invoke keymap_vi_load +return 0 diff --git a/.local/share/blesh/lib/keymap.vi_digraph.sh b/.local/share/blesh/lib/keymap.vi_digraph.sh new file mode 100644 index 0000000..1a577b0 --- /dev/null +++ b/.local/share/blesh/lib/keymap.vi_digraph.sh @@ -0,0 +1,60 @@ +# Copyright 2015 Koichi Murase . All rights reserved. +# This script is a part of blesh (https://github.com/akinomyoga/ble.sh) +# provided under the BSD-3-Clause license. Do not edit this file because this +# is not the original source code: Various pre-processing has been applied. +# Also, the code comments and blank lines are stripped off in the installation +# process. Please find the corresponding source file(s) in the repository +# "akinomyoga/ble.sh". +# +# Source: /lib/keymap.vi_digraph.sh +_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/lib/keymap.vi_digraph.txt" + local line field ch1 ch2 code + for line in "${lines[@]}"; do + [[ $line == ??' '* ]] || continue + [[ $OSTYPE == msys* ]] && line=${line%$'\r'} + 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/lib/keymap.vi_digraph.sh && + $fname_keymap_cache -nt $_ble_base/lib/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 diff --git a/.local/share/blesh/lib/keymap.vi_digraph.txt b/.local/share/blesh/lib/keymap.vi_digraph.txt new file mode 100644 index 0000000..9086f91 --- /dev/null +++ b/.local/share/blesh/lib/keymap.vi_digraph.txt @@ -0,0 +1,1304 @@ +NU 0 +SH 1 +SX 2 +EX 3 +ET 4 +EQ 5 +AK 6 +BL 7 +BS 8 +HT 9 +LF 10 +VT 11 +FF 12 +CR 13 +SO 14 +SI 15 +DL 16 +D1 17 +D2 18 +D3 19 +D4 20 +NK 21 +SY 22 +EB 23 +CN 24 +EM 25 +SB 26 +EC 27 +FS 28 +GS 29 +RS 30 +US 31 +SP 32 +Nb 35 +DO 36 +At 64 +<( 91 +// 92 +)> 93 +'> 94 +'! 96 +(! 123 +!! 124 +!) 125 +'? 126 +DT 127 +PA 128 +HO 129 +BH 130 +NH 131 +IN 132 +NL 133 +SA 134 +ES 135 +HS 136 +HJ 137 +VS 138 +PD 139 +PU 140 +RI 141 +S2 142 +S3 143 +DC 144 +P1 145 +P2 146 +TS 147 +CC 148 +MW 149 +SG 150 +EG 151 +SS 152 +GC 153 +SC 154 +CI 155 +ST 156 +OC 157 +PM 158 +AC 159 +NS 160 +!I 161 +Ct 162 +Pd 163 +Cu 164 +Ye 165 +BB 166 +SE 167 +': 168 +Co 169 +-a 170 +<< 171 +NO 172 +-- 173 +Rg 174 +'m 175 +DG 176 ++- 177 +2S 178 +3S 179 +'' 180 +My 181 +PI 182 +.M 183 +', 184 +1S 185 +-o 186 +>> 187 +14 188 +12 189 +34 190 +?I 191 +A! 192 +A' 193 +A> 194 +A? 195 +A: 196 +AA 197 +AE 198 +C, 199 +E! 200 +E' 201 +E> 202 +E: 203 +I! 204 +I' 205 +I> 206 +I: 207 +D- 208 +N? 209 +O! 210 +O' 211 +O> 212 +O? 213 +O: 214 +*X 215 +O/ 216 +U! 217 +U' 218 +U> 219 +U: 220 +Y' 221 +TH 222 +ss 223 +a! 224 +a' 225 +a> 226 +a? 227 +a: 228 +aa 229 +ae 230 +c, 231 +e! 232 +e' 233 +e> 234 +e: 235 +i! 236 +i' 237 +i> 238 +i: 239 +d- 240 +n? 241 +o! 242 +o' 243 +o> 244 +o? 245 +o: 246 +-: 247 +o/ 248 +u! 249 +u' 250 +u> 251 +u: 252 +y' 253 +th 254 +y: 255 +A- 256 +a- 257 +A( 258 +a( 259 +A; 260 +a; 261 +C' 262 +c' 263 +C> 264 +c> 265 +C. 266 +c. 267 +C< 268 +c< 269 +D< 270 +d< 271 +D/ 272 +d/ 273 +E- 274 +e- 275 +E( 276 +e( 277 +E. 278 +e. 279 +E; 280 +e; 281 +E< 282 +e< 283 +G> 284 +g> 285 +G( 286 +g( 287 +G. 288 +g. 289 +G, 290 +g, 291 +H> 292 +h> 293 +H/ 294 +h/ 295 +I? 296 +i? 297 +I- 298 +i- 299 +I( 300 +i( 301 +I; 302 +i; 303 +I. 304 +i. 305 +IJ 306 +ij 307 +J> 308 +j> 309 +K, 310 +k, 311 +kk 312 +L' 313 +l' 314 +L, 315 +l, 316 +L< 317 +l< 318 +L. 319 +l. 320 +L/ 321 +l/ 322 +N' 323 +n' 324 +N, 325 +n, 326 +N< 327 +n< 328 +'n 329 +NG 330 +ng 331 +O- 332 +o- 333 +O( 334 +o( 335 +O" 336 +o" 337 +OE 338 +oe 339 +R' 340 +r' 341 +R, 342 +r, 343 +R< 344 +r< 345 +S' 346 +s' 347 +S> 348 +s> 349 +S, 350 +s, 351 +S< 352 +s< 353 +T, 354 +t, 355 +T< 356 +t< 357 +T/ 358 +t/ 359 +U? 360 +u? 361 +U- 362 +u- 363 +U( 364 +u( 365 +U0 366 +u0 367 +U" 368 +u" 369 +U; 370 +u; 371 +W> 372 +w> 373 +Y> 374 +y> 375 +Y: 376 +Z' 377 +z' 378 +Z. 379 +z. 380 +Z< 381 +z< 382 +O9 416 +o9 417 +OI 418 +oi 419 +yr 422 +U9 431 +u9 432 +Z/ 437 +z/ 438 +ED 439 +A< 461 +a< 462 +I< 463 +i< 464 +O< 465 +o< 466 +U< 467 +u< 468 +A1 478 +a1 479 +A7 480 +a7 481 +A3 482 +a3 483 +G/ 484 +g/ 485 +G< 486 +g< 487 +K< 488 +k< 489 +O; 490 +o; 491 +O1 492 +o1 493 +EZ 494 +ez 495 +j< 496 +G' 500 +g' 501 +;S 703 +'< 711 +'( 728 +'. 729 +'0 730 +'; 731 +'" 733 +A% 902 +E% 904 +Y% 905 +I% 906 +O% 908 +U% 910 +W% 911 +i3 912 +A* 913 +B* 914 +G* 915 +D* 916 +E* 917 +Z* 918 +Y* 919 +H* 920 +I* 921 +K* 922 +L* 923 +M* 924 +N* 925 +C* 926 +O* 927 +P* 928 +R* 929 +S* 931 +T* 932 +U* 933 +F* 934 +X* 935 +Q* 936 +W* 937 +J* 938 +V* 939 +a% 940 +e% 941 +y% 942 +i% 943 +u3 944 +a* 945 +b* 946 +g* 947 +d* 948 +e* 949 +z* 950 +y* 951 +h* 952 +i* 953 +k* 954 +l* 955 +m* 956 +n* 957 +c* 958 +o* 959 +p* 960 +r* 961 +*s 962 +s* 963 +t* 964 +u* 965 +f* 966 +x* 967 +q* 968 +w* 969 +j* 970 +v* 971 +o% 972 +u% 973 +w% 974 +'G 984 +,G 985 +T3 986 +t3 987 +M3 988 +m3 989 +K3 990 +k3 991 +P3 992 +p3 993 +'% 1012 +j3 1013 +IO 1025 +D% 1026 +G% 1027 +IE 1028 +DS 1029 +II 1030 +YI 1031 +J% 1032 +LJ 1033 +NJ 1034 +Ts 1035 +KJ 1036 +V% 1038 +DZ 1039 +A= 1040 +B= 1041 +V= 1042 +G= 1043 +D= 1044 +E= 1045 +Z% 1046 +Z= 1047 +I= 1048 +J= 1049 +K= 1050 +L= 1051 +M= 1052 +N= 1053 +O= 1054 +P= 1055 +R= 1056 +S= 1057 +T= 1058 +U= 1059 +F= 1060 +H= 1061 +C= 1062 +C% 1063 +S% 1064 +Sc 1065 +=" 1066 +Y= 1067 +%" 1068 +JE 1069 +JU 1070 +JA 1071 +a= 1072 +b= 1073 +v= 1074 +g= 1075 +d= 1076 +e= 1077 +z% 1078 +z= 1079 +i= 1080 +j= 1081 +k= 1082 +l= 1083 +m= 1084 +n= 1085 +o= 1086 +p= 1087 +r= 1088 +s= 1089 +t= 1090 +u= 1091 +f= 1092 +h= 1093 +c= 1094 +c% 1095 +s% 1096 +sc 1097 +=' 1098 +y= 1099 +%' 1100 +je 1101 +ju 1102 +ja 1103 +io 1105 +d% 1106 +g% 1107 +ie 1108 +ds 1109 +ii 1110 +yi 1111 +j% 1112 +lj 1113 +nj 1114 +ts 1115 +kj 1116 +v% 1118 +dz 1119 +Y3 1122 +y3 1123 +O3 1130 +o3 1131 +F3 1138 +f3 1139 +V3 1140 +v3 1141 +C3 1152 +c3 1153 +G3 1168 +g3 1169 +A+ 1488 +B+ 1489 +G+ 1490 +D+ 1491 +H+ 1492 +W+ 1493 +Z+ 1494 +X+ 1495 +Tj 1496 +J+ 1497 +K% 1498 +K+ 1499 +L+ 1500 +M% 1501 +M+ 1502 +N% 1503 +N+ 1504 +S+ 1505 +E+ 1506 +P% 1507 +P+ 1508 +Zj 1509 +ZJ 1510 +Q+ 1511 +R+ 1512 +Sh 1513 +T+ 1514 +,+ 1548 +;+ 1563 +?+ 1567 +H' 1569 +aM 1570 +aH 1571 +wH 1572 +ah 1573 +yH 1574 +a+ 1575 +b+ 1576 +tm 1577 +t+ 1578 +tk 1579 +g+ 1580 +hk 1581 +x+ 1582 +d+ 1583 +dk 1584 +r+ 1585 +z+ 1586 +s+ 1587 +sn 1588 +c+ 1589 +dd 1590 +tj 1591 +zH 1592 +e+ 1593 +i+ 1594 +++ 1600 +f+ 1601 +q+ 1602 +k+ 1603 +l+ 1604 +m+ 1605 +n+ 1606 +h+ 1607 +w+ 1608 +j+ 1609 +y+ 1610 +:+ 1611 +"+ 1612 +=+ 1613 +/+ 1614 +'+ 1615 +1+ 1616 +3+ 1617 +0+ 1618 +aS 1648 +p+ 1662 +v+ 1700 +gf 1711 +0a 1776 +1a 1777 +2a 1778 +3a 1779 +4a 1780 +5a 1781 +6a 1782 +7a 1783 +8a 1784 +9a 1785 +B. 7682 +b. 7683 +B_ 7686 +b_ 7687 +D. 7690 +d. 7691 +D_ 7694 +d_ 7695 +D, 7696 +d, 7697 +F. 7710 +f. 7711 +G- 7712 +g- 7713 +H. 7714 +h. 7715 +H: 7718 +h: 7719 +H, 7720 +h, 7721 +K' 7728 +k' 7729 +K_ 7732 +k_ 7733 +L_ 7738 +l_ 7739 +M' 7742 +m' 7743 +M. 7744 +m. 7745 +N. 7748 +n. 7749 +N_ 7752 +n_ 7753 +P' 7764 +p' 7765 +P. 7766 +p. 7767 +R. 7768 +r. 7769 +R_ 7774 +r_ 7775 +S. 7776 +s. 7777 +T. 7786 +t. 7787 +T_ 7790 +t_ 7791 +V? 7804 +v? 7805 +W! 7808 +w! 7809 +W' 7810 +w' 7811 +W: 7812 +w: 7813 +W. 7814 +w. 7815 +X. 7818 +x. 7819 +X: 7820 +x: 7821 +Y. 7822 +y. 7823 +Z> 7824 +z> 7825 +Z_ 7828 +z_ 7829 +h_ 7830 +t: 7831 +w0 7832 +y0 7833 +A2 7842 +a2 7843 +E2 7866 +e2 7867 +E? 7868 +e? 7869 +I2 7880 +i2 7881 +O2 7886 +o2 7887 +U2 7910 +u2 7911 +Y! 7922 +y! 7923 +Y2 7926 +y2 7927 +Y? 7928 +y? 7929 +;' 7936 +,' 7937 +;! 7938 +,! 7939 +?; 7940 +?, 7941 +!: 7942 +?: 7943 +1N 8194 +1M 8195 +3M 8196 +4M 8197 +6M 8198 +1T 8201 +1H 8202 +-1 8208 +-N 8211 +-M 8212 +-3 8213 +!2 8214 +=2 8215 +'6 8216 +'9 8217 +.9 8218 +9' 8219 +"6 8220 +"9 8221 +:9 8222 +9" 8223 +/- 8224 +/= 8225 +.. 8229 +,. 8230 +%0 8240 +1' 8242 +2' 8243 +3' 8244 +1" 8245 +2" 8246 +3" 8247 +Ca 8248 +<1 8249 +>1 8250 +:X 8251 +'- 8254 +/f 8260 +0S 8304 +4S 8308 +5S 8309 +6S 8310 +7S 8311 +8S 8312 +9S 8313 ++S 8314 +-S 8315 +=S 8316 +(S 8317 +)S 8318 +nS 8319 +0s 8320 +1s 8321 +2s 8322 +3s 8323 +4s 8324 +5s 8325 +6s 8326 +7s 8327 +8s 8328 +9s 8329 ++s 8330 +-s 8331 +=s 8332 +(s 8333 +)s 8334 +Li 8356 +Pt 8359 +W= 8361 +Eu 8364 +=R 8381 +=P 8381 +oC 8451 +co 8453 +oF 8457 +N0 8470 +PO 8471 +Rx 8478 +SM 8480 +TM 8482 +Om 8486 +AO 8491 +13 8531 +23 8532 +15 8533 +25 8534 +35 8535 +45 8536 +16 8537 +56 8538 +18 8539 +38 8540 +58 8541 +78 8542 +1R 8544 +2R 8545 +3R 8546 +4R 8547 +5R 8548 +6R 8549 +7R 8550 +8R 8551 +9R 8552 +aR 8553 +bR 8554 +cR 8555 +1r 8560 +2r 8561 +3r 8562 +4r 8563 +5r 8564 +6r 8565 +7r 8566 +8r 8567 +9r 8568 +ar 8569 +br 8570 +cr 8571 +<- 8592 +-! 8593 +-> 8594 +-v 8595 +<> 8596 +UD 8597 +<= 8656 +=> 8658 +== 8660 +FA 8704 +dP 8706 +TE 8707 +/0 8709 +DE 8710 +NB 8711 +(- 8712 +-) 8715 +*P 8719 ++Z 8721 +-2 8722 +-+ 8723 +*- 8727 +Ob 8728 +Sb 8729 +RT 8730 +0( 8733 +00 8734 +-L 8735 +-V 8736 +PP 8741 +AN 8743 +OR 8744 +(U 8745 +)U 8746 +In 8747 +DI 8748 +Io 8750 +.: 8756 +:. 8757 +:R 8758 +:: 8759 +?1 8764 +CG 8766 +?- 8771 +?= 8773 +?2 8776 +=? 8780 +HI 8787 +!= 8800 +=3 8801 +=< 8804 +>= 8805 +<* 8810 +*> 8811 +!< 8814 +!> 8815 +(C 8834 +)C 8835 +(_ 8838 +)_ 8839 +0. 8857 +02 8858 +-T 8869 +.P 8901 +:3 8942 +.3 8943 +Eh 8962 +<7 8968 +>7 8969 +7< 8970 +7> 8971 +NI 8976 +(A 8978 +TR 8981 +Iu 8992 +Il 8993 + 9002 +Vs 9251 +1h 9280 +3h 9281 +2h 9282 +4h 9283 +1j 9286 +2j 9287 +3j 9288 +4j 9289 +1. 9352 +2. 9353 +3. 9354 +4. 9355 +5. 9356 +6. 9357 +7. 9358 +8. 9359 +9. 9360 +hh 9472 +HH 9473 +vv 9474 +VV 9475 +3- 9476 +3_ 9477 +3! 9478 +3/ 9479 +4- 9480 +4_ 9481 +4! 9482 +4/ 9483 +dr 9484 +dR 9485 +Dr 9486 +DR 9487 +dl 9488 +dL 9489 +Dl 9490 +LD 9491 +ur 9492 +uR 9493 +Ur 9494 +UR 9495 +ul 9496 +uL 9497 +Ul 9498 +UL 9499 +vr 9500 +vR 9501 +Vr 9504 +VR 9507 +vl 9508 +vL 9509 +Vl 9512 +VL 9515 +dh 9516 +dH 9519 +Dh 9520 +DH 9523 +uh 9524 +uH 9527 +Uh 9528 +UH 9531 +vh 9532 +vH 9535 +Vh 9538 +VH 9547 +FD 9585 +BD 9586 +TB 9600 +LB 9604 +FB 9608 +lB 9612 +RB 9616 +.S 9617 +:S 9618 +?S 9619 +fS 9632 +OS 9633 +RO 9634 +Rr 9635 +RF 9636 +RY 9637 +RH 9638 +RZ 9639 +RK 9640 +RX 9641 +sB 9642 +SR 9644 +Or 9645 +UT 9650 +uT 9651 +PR 9654 +Tr 9655 +Dt 9660 +dT 9661 +PL 9664 +Tl 9665 +Db 9670 +Dw 9671 +LZ 9674 +0m 9675 +0o 9678 +0M 9679 +0L 9680 +0R 9681 +Sn 9688 +Ic 9689 +Fd 9698 +Bd 9699 +*2 9733 +*1 9734 +H 9758 +0u 9786 +0U 9787 +SU 9788 +Fm 9792 +Ml 9794 +cS 9824 +cH 9825 +cD 9826 +cC 9827 +Md 9833 +M8 9834 +M2 9835 +Mb 9837 +Mx 9838 +MX 9839 +OK 10003 +XX 10007 +-X 10016 +IS 12288 +,_ 12289 +._ 12290 ++" 12291 ++_ 12292 +*_ 12293 +;_ 12294 +0_ 12295 +<+ 12298 +>+ 12299 +<' 12300 +>' 12301 +<" 12302 +>" 12303 +(" 12304 +)" 12305 +=T 12306 +=_ 12307 +(' 12308 +)' 12309 +(I 12310 +)I 12311 +-? 12316 +A5 12353 +a5 12354 +I5 12355 +i5 12356 +U5 12357 +u5 12358 +E5 12359 +e5 12360 +O5 12361 +o5 12362 +ka 12363 +ga 12364 +ki 12365 +gi 12366 +ku 12367 +gu 12368 +ke 12369 +ge 12370 +ko 12371 +go 12372 +sa 12373 +za 12374 +si 12375 +zi 12376 +su 12377 +zu 12378 +se 12379 +ze 12380 +so 12381 +zo 12382 +ta 12383 +da 12384 +ti 12385 +di 12386 +tU 12387 +tu 12388 +du 12389 +te 12390 +de 12391 +to 12392 +do 12393 +na 12394 +ni 12395 +nu 12396 +ne 12397 +no 12398 +ha 12399 +ba 12400 +pa 12401 +hi 12402 +bi 12403 +pi 12404 +hu 12405 +bu 12406 +pu 12407 +he 12408 +be 12409 +pe 12410 +ho 12411 +bo 12412 +po 12413 +ma 12414 +mi 12415 +mu 12416 +me 12417 +mo 12418 +yA 12419 +ya 12420 +yU 12421 +yu 12422 +yO 12423 +yo 12424 +ra 12425 +ri 12426 +ru 12427 +re 12428 +ro 12429 +wA 12430 +wa 12431 +wi 12432 +we 12433 +wo 12434 +n5 12435 +vu 12436 +"5 12443 +05 12444 +*5 12445 ++5 12446 +a6 12449 +A6 12450 +i6 12451 +I6 12452 +u6 12453 +U6 12454 +e6 12455 +E6 12456 +o6 12457 +O6 12458 +Ka 12459 +Ga 12460 +Ki 12461 +Gi 12462 +Ku 12463 +Gu 12464 +Ke 12465 +Ge 12466 +Ko 12467 +Go 12468 +Sa 12469 +Za 12470 +Si 12471 +Zi 12472 +Su 12473 +Zu 12474 +Se 12475 +Ze 12476 +So 12477 +Zo 12478 +Ta 12479 +Da 12480 +Ti 12481 +Di 12482 +TU 12483 +Tu 12484 +Du 12485 +Te 12486 +De 12487 +To 12488 +Do 12489 +Na 12490 +Ni 12491 +Nu 12492 +Ne 12493 +No 12494 +Ha 12495 +Ba 12496 +Pa 12497 +Hi 12498 +Bi 12499 +Pi 12500 +Hu 12501 +Bu 12502 +Pu 12503 +He 12504 +Be 12505 +Pe 12506 +Ho 12507 +Bo 12508 +Po 12509 +Ma 12510 +Mi 12511 +Mu 12512 +Me 12513 +Mo 12514 +YA 12515 +Ya 12516 +YU 12517 +Yu 12518 +YO 12519 +Yo 12520 +Ra 12521 +Ri 12522 +Ru 12523 +Re 12524 +Ro 12525 +WA 12526 +Wa 12527 +Wi 12528 +We 12529 +Wo 12530 +N6 12531 +Vu 12532 +KA 12533 +KE 12534 +Va 12535 +Vi 12536 +Ve 12537 +Vo 12538 +.6 12539 +-6 12540 +*6 12541 ++6 12542 +b4 12549 +p4 12550 +m4 12551 +f4 12552 +d4 12553 +t4 12554 +n4 12555 +l4 12556 +g4 12557 +k4 12558 +h4 12559 +j4 12560 +q4 12561 +x4 12562 +zh 12563 +ch 12564 +sh 12565 +r4 12566 +z4 12567 +c4 12568 +s4 12569 +a4 12570 +o4 12571 +e4 12572 +ai 12574 +ei 12575 +au 12576 +ou 12577 +an 12578 +en 12579 +aN 12580 +eN 12581 +er 12582 +i4 12583 +u4 12584 +iu 12585 +v4 12586 +nG 12587 +gn 12588 +1c 12832 +2c 12833 +3c 12834 +4c 12835 +5c 12836 +6c 12837 +7c 12838 +8c 12839 +9c 12840 +ff 64256 +fi 64257 +fl 64258 +ft 64261 +st 64262 diff --git a/.local/share/blesh/lib/test-bash.sh b/.local/share/blesh/lib/test-bash.sh new file mode 100644 index 0000000..d9f38dd --- /dev/null +++ b/.local/share/blesh/lib/test-bash.sh @@ -0,0 +1,326 @@ +# Copyright 2015 Koichi Murase . All rights reserved. +# This script is a part of blesh (https://github.com/akinomyoga/ble.sh) +# provided under the BSD-3-Clause license. Do not edit this file because this +# is not the original source code: Various pre-processing has been applied. +# Also, the code comments and blank lines are stripped off in the installation +# process. Please find the corresponding source file(s) in the repository +# "akinomyoga/ble.sh". +# +# Source: /lib/test-bash.sh +ble-import lib/core-test +ble/test/start-section 'bash' 69 +( + a='x y' + ble/test code:'ret=$a' ret="x y" + ble/test '[[ $a == "x y" ]]' + ble/test 'case $a in ("x y") true ;; (*) false ;; esac' + a='x y' + ble/test code:'ret=$a' ret="x y" + ble/test '[[ $a == "x y" ]]' + ble/test 'case $a in ("x y") true ;; (*) false ;; esac' + IFS=abc a='xabcy' + ble/test code:'ret=$a' ret="xabcy" + ble/test '[[ $a == "xabcy" ]]' + ble/test 'case $a in ("xabcy") true ;; (*) false ;; esac' + IFS=$' \t\n' + a='x y' + ble/test 'read -r ret <<< $a' ret="x y" + a='x y' + if ((_ble_bash<40400)); then + ble/test 'read -r ret <<< $a' ret="x y" + else + ble/test 'read -r ret <<< $a' ret="x y" + fi + IFS=abc a='xabcy' + if ((_ble_bash<40400)); then + ble/test 'read -r ret <<< $a' ret="x y" + else + ble/test 'read -r ret <<< $a' ret="xabcy" + fi + IFS=$' \t\n' + b='/*' + ble/test code:'ret=$b' ret="/*" + ble/test 'case $b in ("/*") true ;; (*) false ;; esac' + ble/test 'read -r ret <<< $b' ret="/*" +) +( + a=("") + function f1 { ret=$1; } + if ((30100<=_ble_bash&&_ble_bash<30200)); then + ble/test 'f1 "a${a[*]}b"' ret=$'a\177b' + ble/test code:'ret="a${a[*]}b"' ret=$'a\177b' + ble/test 'case "a${a[*]}b" in ($'\''a\177b'\'') true ;; (*) false ;; esac' + ble/test 'read -r ret <<< "a${a[*]}b"' ret=$'a\177b' + else + ble/test 'f1 "a${a[*]}b"' ret='ab' + ble/test code:'ret="a${a[*]}b"' ret='ab' + ble/test 'case "a${a[*]}b" in (ab) true ;; (*) false ;; esac' + ble/test 'read -r ret <<< "a${a[*]}b"' ret=ab + fi + var=X%dX%dX + if ((_ble_bash<30200)); then + ble/test code:'ret=${var//%d/.}' ret='X%dX%dX' + else + ble/test code:'ret=${var//%d/.}' ret='X.X.X' + fi + ble/test/chdir || exit + touch {a..c}.txt + function f1 { local GLOBIGNORE='*.txt'; } + if ((_ble_bash<30200)); then + ble/test 'f1; echo *' stdout='*' + else + ble/test 'f1; echo *' stdout='a.txt b.txt c.txt' + fi + function f1 { local POSIXLY_CORRECT=y; builtin unset -v POSIXLY_CORRECT; } + set +o posix + if ((_ble_bash<30200)); then + ble/test 'f1; [[ -o posix ]]' + else + ble/test 'f1; [[ ! -o posix ]]' + fi + builtin unset -v POSIXLY_CORRECT + ble/test '[[ ! -o posix ]]' + set +o posix + function f1 { local POSIXLY_CORRECT; builtin unset -v POSIXLY_CORRECT; [[ ! -o posix ]]; } + if ((_ble_bash<40400)); then + ble/test '! f1' + else + ble/test 'f1' + fi + set +o posix + function f1/sub { true; } + if ((_ble_bash<50300)); then + ble/test 'set -o posix; f1/sub; ret=$?; set +o posix' ret=0 + else + ble/test 'set -o posix; f1/sub; ret=$?; set +o posix' ret=0 + fi + if ((_ble_bash<30004)); then + ble/test code:'a=あ ret=${#a}' ret=3 + else + ble/test code:'a=あ ret=${#a}' ret=1 + fi + builtin unset -v v + v=$'a\nb' + if ((_ble_bash<30100)); then + ble/test code:'declare -p v' stdout=$'declare -- v="a\\\nb"' + elif ((_ble_bash<50200)); then + ble/test code:'declare -p v' stdout=$'declare -- v="a\nb"' + else + ble/test code:'declare -p v' stdout='declare -- v=$'\''a\nb'\' + fi + builtin unset -v scalar + if ((_ble_bash<30100)); then + ble/test code:'ret="[${scalar-$'\''hello'\''}]"' ret="['hello']" # disable=#D1774 + else + ble/test code:'ret="[${scalar-$'\''hello'\''}]"' ret='[hello]' # disable=#D1774 + fi +) +( + function f1 { local -a a; local -A a; } + if ((_ble_bash<40000)); then + ble/test f1 exit=2 + elif ((_ble_bash<50000)); then + ble/test '(f1)' exit=139 # SIGSEGV + else + ble/test f1 exit=1 + fi + c=(a b c) + IFS=x + if ((_ble_bash<50000)); then + ble/test 'case ${c[*]} in ("a b c") true ;; (*) false ;; esac' + ble/test 'read -r ret <<< ${c[*]}' ret="a b c" + else + ble/test 'case ${c[*]} in ("axbxc") true ;; (*) false ;; esac' + ble/test 'read -r ret <<< ${c[*]}' ret="axbxc" + fi + ble/test 'case "${c[*]}" in ("axbxc") true ;; (*) false ;; esac' + ble/test 'read -r ret <<< "${c[*]}"' ret="axbxc" + IFS=$' \t\n' + c=(a b c) + ble/test code:'ret=${c[*]}' ret="a b c" + ble/test 'case ${c[*]} in ("a b c") true ;; (*) false ;; esac' + ble/test 'read -r ret <<< ${c[*]}' ret="a b c" + IFS=x + if ((_ble_bash<40300)); then + ble/test code:'ret=${c[*]}' ret="a b c" + else + ble/test code:'ret=${c[*]}' ret="axbxc" + fi + ble/test code:'ret="${c[*]}"' ret="axbxc" + IFS=$' \t\n' + builtin unset -v arr1 arr2 + local arr1 + local -a arr2 + if ((_ble_bash<40200)); then + ble/test code:'ret=${#arr1[@]}' ret=1 + else + ble/test code:'ret=${#arr1[@]}' ret=0 + fi + ble/test code:'ret=${#arr2[@]}' ret=0 + a=($'\x7F' $'\x01') + if ((_ble_bash<40000)); then + ble/test 'declare -p a' stdout=$'declare -a a=\'([0]="\x01\x01\x01\x7F" [1]="\x01\x01\x01\x01")\'' # ' + elif ((_ble_bash<40400)); then + ble/test 'declare -p a' stdout=$'declare -a a=\'([0]="\x01\x7F" [1]="\x01\x01")\'' # ' + else + ble/test 'declare -p a' stdout='declare -a a=([0]=$'\''\177'\'' [1]=$'\''\001'\'')' # disable=#D0525 + fi + function f1 { local -a arr=(b b b); ble/util/print "(${arr[*]})"; } + function f2 { local -a arr=(a a a); f1; } + if ((30100<=_ble_bash&&_ble_bash<30104)); then + ble/test f2 stdout='()' + else + ble/test f2 stdout='(b b b)' + fi + if ((30100<=_ble_bash&&_ble_bash<30104)); then + ble/test 'function f1 { local -a alpha=(); local -a beta=(); }' + else + ble/test 'function f1 { local -a alpha=() beta=(); }' + fi + if ((_ble_bash<30200)); then + ble/test code:'ret=あ ret=${#ret[0]}' ret=3 # disable=#D0182 + else + ble/test code:'ret=あ ret=${#ret[0]}' ret=1 # disable=#D0182 + fi + declare ret=(1 2 3) # disable=#D0184 + if ((_ble_bash<30100)); then + ble/test ret='(1 2 3)' + else + ble/test ret='1' + fi + declare -a ret=("1 2") # disable=#D0525 + if ((_ble_bash<30100)); then + ble/test ret='1' + else + ble/test ret='1 2' + fi + v="1 2 3" + declare -a ret=("$v") # disable=#D0525 + if ((_ble_bash<30100)); then + ble/test ret='1' + else + ble/test ret='1 2 3' + fi + a=(1 2 3) + IFS=x + declare -a a1=("${a[@]}") # disable=#D0525 + a2=("${a[@]}") # disable=#D0525 + IFS=$' \t\n' + if ((_ble_bash<30100)); then + ble/test code:'ret=$a1' ret=1x2x3 + ble/test code:'ret=$a2' ret=1 + else + ble/test code:'ret=$a1' ret=1 + ble/test code:'ret=$a2' ret=1 + fi + IFS=x + v=1x2x3 + declare -a a1=($v) + a2=($v) + if ((_ble_bash<30100)); then + ble/test code:'ret=$a1' ret=1x2x3 + ble/test code:'ret=$a2' ret=1 + else + ble/test code:'ret=$a1' ret=1 + ble/test code:'ret=$a2' ret=1 + fi + v='1 2 3' + declare -a a1=($v) + a2=($v) + if ((_ble_bash<30100)); then + ble/test code:'ret=$a1' ret=1 + ble/test code:'ret=$a2' ret='1 2 3' + else + ble/test code:'ret=$a1' ret='1 2 3' + ble/test code:'ret=$a2' ret='1 2 3' + fi + IFS=$' \t\n' + builtin unset -v scalar + scalar=abcd + if ((_ble_bash<30100)); then + ble/test code:'ret=${scalar[@]//[bc]}' ret='' # disable=#D1570 + elif ((40300<=_ble_bash&&_ble_bash<40400)); then + ble/test code:'ret=${scalar[@]//[bc]}' ret=$'\001a\001\001\001d' # disable=#D1570 + else + ble/test code:'ret=${scalar[@]//[bc]}' ret='ad' # disable=#D1570 + fi +) +( + q=\' line='$'$q'\'$q'!!'$q'\'$q + code='(builtin history -s histentry; builtin history -p "$line")' + if ((_ble_bash<30100)); then + ble/test "$code" stdout= + elif ((_ble_bash<40100)) || [[ $- != *[iH]* ]]; then + ble/test "$code" stdout="${line//!!/histentry}" + else + ble/test "$code" stdout="$line" + fi + if ((_ble_bash<40100)); then + ble/test '(set -H; builtin history -c; builtin history -p "$line")' stdout= exit=1 + else + ble/test '(set -H; builtin history -c; builtin history -p "$line")' stdout="$line" + fi + if [[ -d /proc/$$/fd ]] && { ((1)) >/dev/tty; } 2>/dev/null; then + ( + exec 7>/dev/null 77>/dev/null # disable=#D0857 + exec 7>/dev/tty 77>/dev/tty # disable=#D0857 + ble/util/getpid + if ((30100<=_ble_bash&&_ble_bash<40000)); then + ble/test '[[ -t 7 ]]' + ble/test '[[ ! -t 77 ]]' + else + ble/test '[[ -t 7 ]]' + ble/test '[[ -t 77 ]]' + fi + ) + fi + if [[ -d /proc/$$/fd ]] && { ((1)) >/dev/tty; } 2>/dev/null; then + ( + exec 7>/dev/null 77>/dev/null # disable=#D0857 + exec 7>&- 77>&- # disable=#D2164 + ble/util/getpid + if ((30100<=_ble_bash&&_ble_bash<30200)); then + ble/test '[[ ! -e /proc/$BASHPID/fd/7 ]]' + ble/test '[[ -e /proc/$BASHPID/fd/77 ]]' + else + ble/test '[[ ! -e /proc/$BASHPID/fd/7 ]]' + ble/test '[[ ! -e /proc/$BASHPID/fd/77 ]]' + fi + ) + fi + function f1 { ble/util/print hello; } >&"$fd1" + function f2 { ble/util/print hello >&"$fd1"; } + function f3 { { ble/util/print hello; } >&"$fd1"; } + function test1 { + local fd1= + ble/fd#alloc fd1 '>&1' + "$1" >/dev/null & local pid=$! + wait "$pid" + ble/fd#close fd1 + } + if ((_ble_bash<30100)); then + ble/test 'test1 f1' stdout= + else + ble/test 'test1 f1' stdout=hello + fi + ble/test 'test1 f2' stdout=hello + ble/test 'test1 f3' stdout=hello +) +( + shopt -s expand_aliases + alias e='ble/util/print hello' + ble/test 'eval "e"' stdout=hello + ble/test 'true && eval "e"' stdout=hello + ble/test 'eval "e" & wait' stdout=hello + if [[ $- == *i* ]]; then + ble/test '(eval "e") & wait' stdout= + ble/test '{ eval "e"; } & wait' stdout= + ble/test 'true && eval "e" & wait' stdout= + else + ble/test '(eval "e") & wait' stdout=hello + ble/test '{ eval "e"; } & wait' stdout=hello + ble/test 'true && eval "e" & wait' stdout=hello + fi + builtin unalias e +) +ble/test/end-section diff --git a/.local/share/blesh/lib/test-canvas.sh b/.local/share/blesh/lib/test-canvas.sh new file mode 100644 index 0000000..07b41f1 --- /dev/null +++ b/.local/share/blesh/lib/test-canvas.sh @@ -0,0 +1,639 @@ +# Copyright 2015 Koichi Murase . All rights reserved. +# This script is a part of blesh (https://github.com/akinomyoga/ble.sh) +# provided under the BSD-3-Clause license. Do not edit this file because this +# is not the original source code: Various pre-processing has been applied. +# Also, the code comments and blank lines are stripped off in the installation +# process. Please find the corresponding source file(s) in the repository +# "akinomyoga/ble.sh". +# +# Source: /lib/test-canvas.sh +ble-import lib/core-test +_ble_test_canvas_contra= +if [[ -x ext/contra ]]; then + _ble_test_canvas_contra=ext/contra +elif [[ $(printf 'hello world' | contra test 5 2 2>/dev/null) == $' worl\nd ' ]]; then + _ble_test_canvas_contra=contra +fi +function ble/test:canvas/trace.contra { + [[ $_ble_test_canvas_contra ]] || return 0 # skip + local w=${1%%:*} h=${1#*:} esc=$2 opts=$3 test_opts=$4 + local expect=$(sed 's/\$$//') + local ret x=0 y=0 g=0 rex termw=$w termh=$h + rex=':x=([^:]+):'; [[ :$test_opts: =~ $rex ]] && ((x=BASH_REMATCH[1])) + rex=':y=([^:]+):'; [[ :$test_opts: =~ $rex ]] && ((y=BASH_REMATCH[1])) + rex=':termw=([^:]+):'; [[ :$test_opts: =~ $rex ]] && ((termw=BASH_REMATCH[1])) + rex=':termh=([^:]+):'; [[ :$test_opts: =~ $rex ]] && ((termh=BASH_REMATCH[1])) + local x0=$x y0=$y + LINES=$h COLUMNS=$w ble/canvas/trace "$esc" "$opts" + local out=$ret + ble/string#quote-word "$esc"; local q_esc=$ret + ble/string#quote-word "$opts"; local q_opts=$ret + ble/test --depth=1 --display-code="trace $q_esc $q_opts" \ + '{ printf "\e['$((y0+1))';'$((x0+1))'H"; ble/util/put "$out";} | "$_ble_test_canvas_contra" test "$termw" "$termh"' \ + stdout="$expect" +} +ble/test/start-section 'ble/canvas/trace (relative:confine:measure-bbox)' 17 +ble/test:canvas/trace.contra 10:10 'hello world this is a flow world' relative x=3:y=3:termw=20 << EOF + $ + $ + $ + hello w $ +orld this $ +is a flow $ +world $ + $ + $ + $ +EOF +ble/test:canvas/trace.contra 20:1 '12345678901234567890hello' confine << EOF +12345678901234567890$ +EOF +ble/test:canvas/trace.contra 10:1 $'hello\nworld' confine << EOF +helloworld$ +EOF +ble/test:canvas/trace.contra 10:2 $'hello\nworld check' confine << EOF +hello $ +world chec$ +EOF +ble/test:canvas/trace.contra 10:6 $'hello\e[B\e[4D123' measure-bbox x=3:y=2 << EOF + $ + $ + hello $ + 123 $ + $ + $ +EOF +[[ $_ble_test_canvas_contra ]] && + ble/test 'echo "$x1-$x2:$y1-$y2"' stdout='3-8:2-4' +ble/test:canvas/trace.contra 10:2 日本語 measure-bbox << EOF +日本語 $ + $ +EOF +[[ $_ble_test_canvas_contra ]] && + ble/test 'echo "$x1-$x2:$y1-$y2"' stdout='0-6:0-1' +ble/test:canvas/trace.contra 10:2 $'hello\eDworld' measure-bbox << EOF +hello $ + world$ +EOF +[[ $_ble_test_canvas_contra ]] && + ble/test 'echo "$x1-$x2:$y1-$y2"' stdout='0-10:0-2' +ble/test:canvas/trace.contra 10:2 $'hello\eMworld' measure-bbox << EOF + world$ +hello $ +EOF +[[ $_ble_test_canvas_contra ]] && + ble/test 'echo "$x1-$x2:$y1-$y2"' stdout='0-10:-1-1' +( + LINES=10 COLUMNS=10 _ble_term_xenl=1 + ble/test 'x=0 y=0; ble/canvas/trace "HelloWorld"; ret=$x,$y' ret=10,0 + ble/test 'x=0 y=0; ble/canvas/trace "HelloWorldH"; ret=$x,$y' ret=1,1 + ble/test 'x=0 y=0; ble/canvas/trace "HelloWorldHello"; ret=$x,$y' ret=5,1 + ble/test 'x=0 y=0; ble/canvas/trace "HelloWorldHelloWorldHello"; ret=$x,$y' ret=5,2 + ble/test 'x=0 y=0; ble/canvas/trace "HelloWorldHelloWorldHelloWorldHello"; ret=$x,$y' ret=5,3 +) +ble/test/start-section 'ble/canvas/trace (cfuncs)' 18 +function ble/test:canvas/check-trace-1 { + local input=$1 ex=$2 ey=$3 + ble/canvas/trace.draw "$input" + ble/test --depth=1 '((x==ex&&y==ey))' +} +function ble/test:canvas/check-trace { + local -a DRAW_BUFF=() + ble/canvas/put.draw "$_ble_term_clear" + local x=0 y=0 + ble/test:canvas/check-trace-1 "abc" 3 0 + ble/test:canvas/check-trace-1 $'\n\n\nn' 1 3 + ble/test:canvas/check-trace-1 $'\e[3BB' 2 6 + ble/test:canvas/check-trace-1 $'\e[2AA' 3 4 + ble/test:canvas/check-trace-1 $'\e[20CC' 24 4 + ble/test:canvas/check-trace-1 $'\e[8DD' 17 4 + ble/test:canvas/check-trace-1 $'\e[9EE' 1 13 + ble/test:canvas/check-trace-1 $'\e[6FF' 1 7 + ble/test:canvas/check-trace-1 $'\e[28GG' 28 7 + ble/test:canvas/check-trace-1 $'\e[II' 33 7 + ble/test:canvas/check-trace-1 $'\e[3ZZ' 17 7 + ble/test:canvas/check-trace-1 $'\eDD' 18 8 + ble/test:canvas/check-trace-1 $'\eMM' 19 7 + ble/test:canvas/check-trace-1 $'\e77\e[3;3Hexcur\e8\e[C8' 21 7 + ble/test:canvas/check-trace-1 $'\eEE' 1 8 + ble/test:canvas/check-trace-1 $'\e[10;24HH' 24 9 + ble/test:canvas/check-trace-1 $'\e[1;94mb\e[m' 25 9 + local expect=$(sed 's/\$$//' << EOF +abc $ + $ + excur $ +n $ + A D C $ + $ + B $ +F Z M78 G I $ +E D $ + Hb $ + $ + $ + $ +E $ + $ +EOF +) + [[ $_ble_test_canvas_contra ]] && + ble/test --depth=1 \ + 'ble/canvas/flush.draw | $_ble_test_canvas_contra test 40 15' \ + stdout="$expect" +} +ble/test:canvas/check-trace +ble/test/start-section 'ble/canvas/trace (justify)' 30 +ble/test:canvas/trace.contra 30:1 'a b c' justify << EOF +a b c$ +EOF +ble/test:canvas/trace.contra 30:1 ' center ' justify << EOF + center $ +EOF +ble/test:canvas/trace.contra 30:1 ' right-aligned' justify << EOF + right-aligned$ +EOF +ble/test:canvas/trace.contra 30:1 'left-aligned' justify << EOF +left-aligned $ +EOF +ble/test:canvas/trace.contra 30:1 ' 日本語' justify << EOF + 日本語$ +EOF +ble/test:canvas/trace.contra 30:1 'a b c d e f' justify << EOF +a b c d e f$ +EOF +ble/test:canvas/trace.contra 30:2 $'hello center world\na b c d e f' justify << EOF +hello center world$ +a b c d e f$ +EOF +ble/test:canvas/trace.contra 30:3 'A brown fox jumped over the lazy dog. A brown fox jumped over the lazy dog.' justify << EOF +A brown fox jumped over the la$ +zy dog. A brown fox jumped ove$ +r the lazy dog.$ +EOF +ble/test:canvas/trace.contra 30:2 $'hello blesh world\rHELLO WORLD\nhello world HELLO BLESH WORLD' justify=$' \r' << EOF +hello blesh worldHELLO WORLD$ +hello world HELLO BLESH WORLD$ +EOF +COLUMNS=10 LINES=10 x=3 y=2 ble/canvas/trace $'a b c\n' justify:measure-bbox +ble/test 'echo "$x1,$y1:$x2,$y2"' stdout:'0,2:10,4' +COLUMNS=10 LINES=10 x=3 y=2 ble/canvas/trace $' hello ' justify:measure-bbox +ble/test 'echo "$x1,$y1:$x2,$y2"' stdout:'2,2:7,3' +ble/test:canvas/trace.contra 30:1 $'\e[3Dhello\rblesh\rworld\e[1D' justify=$'\r' x=5 << EOF +hello blesh world$ +EOF +ble/test:canvas/trace.contra \ + 30:5 $'hello world\nfoo bar buzz\nA quick brown fox\nLorem ipsum\n1 1 2 3 5 8 13 21 34 55 89 144' \ + justify:clip=2,1+24,5 << EOF +o bar $ + quick brown $ +rem i $ +1 2 3 5 8 13 21 34 55 89 $ + $ +EOF +ble/test:canvas/trace.contra 30:1 $'hello1 world long long word quick brown' justify:confine << EOF +hello1 world long long word qu$ +EOF +ble/test:canvas/trace.contra 30:1 $'hello2 world long long word quick brown' justify:truncate << EOF +hello2 world long long word qu$ +EOF +ble/test:canvas/trace.contra 60:2 $'-- INSERT --\r/home/murase\r2021-01-01 00:00:00' justify << EOF +-- INSERT 2021-01-01 00:00:00$ + $ +EOF +ble/test:canvas/trace.contra 30:3 $'hello\r\vquick check\v\rtest \e[2Afoo\r\vbar' justify:truncate << EOF +hello foo$ +quick check bar$ + test $ +EOF +ble/test:canvas/trace.contra 30:3 $'hello\n2021-01-01\nA' right:measure-bbox:measure-gbox << EOF + hello$ + 2021-01-01$ + A$ +EOF +if [[ $_ble_test_canvas_contra ]]; then + ble/test 'echo "bbox:$x1,$y1-$x2,$y2"' stdout='bbox:0,0-30,3' + ble/test 'echo "gbox:$gx1,$gy1-$gx2,$gy2"' stdout='gbox:20,0-30,3' +fi +ble/test:canvas/trace.contra 30:3 $'hello\n2021-01-01\nA' center:measure-bbox:measure-gbox << EOF + hello $ + 2021-01-01 $ + A $ +EOF +if [[ $_ble_test_canvas_contra ]]; then + ble/test 'echo "bbox:$x1,$y1-$x2,$y2"' stdout='bbox:0,0-20,3' + ble/test 'echo "gbox:$gx1,$gy1-$gx2,$gy2"' stdout='gbox:10,0-20,3' +fi +ble/test:canvas/trace.contra 10:1 $'xyz\e[4Daxyz' relative:measure-bbox x=3 << EOF + axyz $ +EOF +if [[ $_ble_test_canvas_contra ]]; then + ble/test 'echo "bbox:$x1,$y1-$x2,$y2"' stdout='bbox:2,0-6,1' +fi +ble/test:canvas/trace.contra 30:3 $'\n2022-11-28' right:measure-bbox:measure-gbox << EOF + $ + 2022-11-28$ + $ +EOF +if [[ $_ble_test_canvas_contra ]]; then + ble/test 'echo "bbox:$x1,$y1-$x2,$y2"' stdout='bbox:0,0-30,2' + ble/test 'echo "gbox:$gx1,$gy1-$gx2,$gy2"' stdout='gbox:20,1-30,2' +fi +ble/test:canvas/trace.contra 30:3 $'\n\n2022-11-28' right:measure-bbox:measure-gbox << EOF + $ + $ + 2022-11-28$ +EOF +if [[ $_ble_test_canvas_contra ]]; then + ble/test 'echo "bbox:$x1,$y1-$x2,$y2"' stdout='bbox:0,0-30,3' + ble/test 'echo "gbox:$gx1,$gy1-$gx2,$gy2"' stdout='gbox:20,2-30,3' +fi +ble/test/start-section 'ble/canvas/trace-text' 11 +( + sgr0= sgr1= + lines=1 cols=10 _ble_term_xenl=1 x=0 y=0 + ble/test 'ble/canvas/trace-text "Hello World";ret="$x,$y,$ret"' ret='10,0,Hello Worl' + lines=1 cols=10 _ble_term_xenl= x=0 y=0 + ble/test 'ble/canvas/trace-text "Hello World";ret="$x,$y,$ret"' ret='9,0,Hello Wor' + lines=1 cols=10 _ble_term_xenl=1 x=3 y=0 + ble/test 'ble/canvas/trace-text "Hello World";ret="$x,$y,$ret"' ret='10,0,Hello W' + lines=3 cols=10 _ble_term_xenl=1 x=3 y=0 + ble/test 'ble/canvas/trace-text "Hello Bash World";ret="$x,$y,$ret"' ret='9,1,Hello Bash World' + lines=3 cols=10 _ble_term_xenl=1 x=3 y=0 + ble/test 'ble/canvas/trace-text "これは日本語の文章";ret="$x,$y,$ret"' ret=$'2,2,これは\n日本語の文章' + lines=3 cols=10 _ble_term_xenl=1 x=3 y=0 + ble/test 'ble/canvas/trace-text "これは日本語の文章" nonewline;ret="$x,$y,$ret"' ret='2,2,これは 日本語の文章' + lines=3 cols=10 _ble_term_xenl=1 x=0 y=0 + ble/test 'ble/canvas/trace-text "これは日本";ret="$x,$y,$ret"' ret=$'0,1,これは日本\n' + lines=3 cols=10 _ble_term_xenl=0 x=0 y=0 + ble/test 'ble/canvas/trace-text "これは日本";ret="$x,$y,$ret"' ret=$'0,1,これは日本' + lines=3 cols=10 _ble_term_xenl=1 x=0 y=0 + ble/test 'ble/canvas/trace-text "これは日本" nonewline;ret="$x,$y,$ret"' ret=$'10,0,これは日本' + lines=3 cols=10 _ble_term_xenl=0 x=0 y=0 + ble/test 'ble/canvas/trace-text "これは日本" nonewline;ret="$x,$y,$ret"' ret=$'0,1,これは日本' + lines=1 cols=12 _ble_term_xenl=1 x=0 y=0 + ble/test $'ble/canvas/trace-text "あ\nい\nう" external-sgr;ret="$x,$y,$ret"' ret=$'10,0,あ^Jい^Jう' +) +ble/test/end-section +ble/test/start-section 'ble/canvas/textmap' 5 +function ble/test:canvas/textmap { + local text=$1 + x=0 y=0 + _ble_textmap_length= + _ble_textmap_pos=() + _ble_textmap_glyph=() + _ble_textmap_ichg=() + _ble_textmap_dbeg=0 + _ble_textmap_dend=${#text} + _ble_textmap_dend0=0 + ble/textmap#update "$text" + [[ :$opts: == *:stderr:* ]] && + declare -p _ble_textmap_pos >&2 +} +( + ble/test:canvas/textmap $'hello\nworld\ncheck' + ble/test 'ble/textmap#getxy.out 5; ret=$x,$y' ret='5,0' + ble/test 'ble/textmap#getxy.out 6; ret=$x,$y' ret='0,1' + ble/test 'ble/textmap#getxy.out 11; ret=$x,$y' ret='5,1' + ble/test 'ble/textmap#getxy.out 12; ret=$x,$y' ret='0,2' + ble/test 'ble/textmap#getxy.out 17; ret=$x,$y' ret='5,2' +) +ble/test/start-section 'ble/canvas/GraphemeCluster/c2break' 77 +if (LC_ALL=C.UTF-8 builtin eval "s=\$'\\U1F6D1'"; ((${#s}==2))) 2>/dev/null; then + function ble/test:canvas/GraphemeCluster/.locate-code-point { + local s=$1 k=$2 len=${#1} i=0 shift + while ((k-->=1&&i=40200)); then + function ble/test:canvas/GraphemeClusterBreak/find-previous-boundary { + local str=$1 index=$2 ans=$3 ret= + ble/test:canvas/GraphemeCluster/.locate-code-point "$str." "$index"; index=$ret + ble/test:canvas/GraphemeCluster/.locate-code-point "$str" "$ans"; ans=$ret + ble/test "ble/unicode/GraphemeCluster/find-previous-boundary '$str' $index" ret="$ans" + } + ble/test:canvas/GraphemeClusterBreak/find-previous-boundary $'\U1F1E6\U1F1FF\U1F1E6\U1F1FF' 1 0 + ble/test:canvas/GraphemeClusterBreak/find-previous-boundary $'\U1F1E6\U1F1FF\U1F1E6\U1F1FF' 2 0 + ble/test:canvas/GraphemeClusterBreak/find-previous-boundary $'\U1F1E6\U1F1FF\U1F1E6\U1F1FF' 3 2 + ble/test:canvas/GraphemeClusterBreak/find-previous-boundary $'\U1F1E6\U1F1FF\U1F1E6\U1F1FF' 4 2 + ble/test:canvas/GraphemeClusterBreak/find-previous-boundary $'\U1F1E6\U1F1FF\U1F1E6\U1F1FF' 5 4 + ble/test:canvas/GraphemeClusterBreak/find-previous-boundary $'A\U1F1E6\U1F1FF\U1F1E6\U1F1FF\U1F1E6' 2 1 + ble/test:canvas/GraphemeClusterBreak/find-previous-boundary $'B\U1F1E6\U1F1FF\U1F1E6\U1F1FF\U1F1E6' 3 1 + ble/test:canvas/GraphemeClusterBreak/find-previous-boundary $'C\U1F1E6\U1F1FF\U1F1E6\U1F1FF\U1F1E6' 4 3 + ble/test:canvas/GraphemeClusterBreak/find-previous-boundary $'D\U1F1E6\U1F1FF\U1F1E6\U1F1FF\U1F1E6' 5 3 + ble/test:canvas/GraphemeClusterBreak/find-previous-boundary $'E\U1F1E6\U1F1FF\U1F1E6\U1F1FF\U1F1E6' 6 5 + ble/test:canvas/GraphemeClusterBreak/find-previous-boundary $'F\U1F1E6\U1F1FF\U1F1E6\U1F1FF\U1F1E6' 7 6 + ble/test:canvas/GraphemeClusterBreak/find-previous-boundary $'G\U1F1E6\U1F1FF\U1F1E6\U1F1FF\U1F1E6Z' 7 6 + ble/test:canvas/GraphemeClusterBreak/find-previous-boundary $'H\u600\u600\u600\u600\U1F1E6\U1F1FF' 7 1 + ble/test:canvas/GraphemeClusterBreak/find-previous-boundary $'I\u600\u600\u600\u600\U1F1E6\U1F1FF' 6 1 + bleopt_grapheme_cluster=legacy ble/test:canvas/GraphemeClusterBreak/find-previous-boundary $'J\u600\u600\u600\u600\U1F1E6\U1F1FF' 7 5 + bleopt_grapheme_cluster=legacy ble/test:canvas/GraphemeClusterBreak/find-previous-boundary $'K\u600\u600\u600\u600\U1F1E6\U1F1FF' 6 5 + ble/test:canvas/GraphemeClusterBreak/find-previous-boundary $'\U1F636\U200D\U1F32B\UFE0F' 1 0 + ble/test:canvas/GraphemeClusterBreak/find-previous-boundary $'\U1F636\U200D\U1F32B\UFE0F' 2 0 + ble/test:canvas/GraphemeClusterBreak/find-previous-boundary $'\U1F636\U200D\U1F32B\UFE0F' 3 0 + ble/test:canvas/GraphemeClusterBreak/find-previous-boundary $'\U1F636\U200D\U1F32B\UFE0F' 4 0 + ble/test:canvas/GraphemeClusterBreak/find-previous-boundary $'\U1F636\U200D\U1F32B\UFE0F' 5 4 + ble/test:canvas/GraphemeClusterBreak/find-previous-boundary $'a\U1F636\U200D\U1F32B\UFE0F' 2 1 + ble/test:canvas/GraphemeClusterBreak/find-previous-boundary $'b\U1F636\U200D\U1F32B\UFE0F' 3 1 + ble/test:canvas/GraphemeClusterBreak/find-previous-boundary $'c\U1F636\U200D\U1F32B\UFE0F' 4 1 + ble/test:canvas/GraphemeClusterBreak/find-previous-boundary $'d\U1F636\U200D\U1F32B\UFE0F' 5 1 + ble/test:canvas/GraphemeClusterBreak/find-previous-boundary $'e\U1F636\U200D\U1F32B\UFE0F' 6 5 + ble/test:canvas/GraphemeClusterBreak/find-previous-boundary $'f\U200D\U1F32B\UFE0F' 2 0 + ble/test:canvas/GraphemeClusterBreak/find-previous-boundary $'g\U200D\U1F32B\UFE0F' 3 2 + ble/test:canvas/GraphemeClusterBreak/find-previous-boundary $'h\U200D\U1F32B\UFE0F' 4 2 + ble/test:canvas/GraphemeClusterBreak/find-previous-boundary $'i\U200D\U1F32B\UFE0F' 5 4 + ble/test "ble/test:canvas/textmap \$'@@' stderr; ble/textmap#get-index-at -v ret 1 0" ret=1 + ble/test "ble/test:canvas/textmap \$'@\u0308@' stderr; ble/textmap#get-index-at -v ret 1 0" ret=2 + ble/test "ble/test:canvas/textmap \$'@\u0308\u0308@' stderr; ble/textmap#get-index-at -v ret 1 0" ret=3 + ble/test "ble/test:canvas/textmap \$'@\u0308\u0308\u0308@' stderr; ble/textmap#get-index-at -v ret 1 0" ret=4 + ble/test 'ble/util/is-unicode-output' + c1=$'\uFE0F' + ble/test code:'code=; ble/unicode/GraphemeCluster/s2break-right "$c1" 0 code; ret=$code' ret="$((0xFE0F))" + ble/test code:'code=; ble/unicode/GraphemeCluster/s2break-left "$c1" "${#c1}" code; ret=$code' ret="$((0xFE0F))" + c2=$'\U1F6D1' + ble/test code:'code=; ble/unicode/GraphemeCluster/s2break-right "$c2" 0 code; ret=$code' ret="$((0x1F6D1))" + ble/test code:'code=; ble/unicode/GraphemeCluster/s2break-left "$c2" "${#c2}" code; ret=$code' ret="$((0x1F6D1))" + fi +) +ble/test/start-section 'ble/canvas/GraphemeCluster/c2break (GraphemeBreakTest.txt)' 6244 +( + bleopt grapheme_cluster=extended + _ble_unicode_c2w_version=17 # Test cases contain 15.1.0 features + _ble_unicode_GraphemeClusterBreak_custom=() + bleopt emoji_opts=ri:tpvs:epvs:zwj + tests_cases=( + 0,1,2:'\U0020\U0020' 0,0,2,3:'\U0020\U0308\U0020' 0,1,2:'\U0020\U000D' 0,0,2,3:'\U0020\U0308\U000D' 0,1,2:'\U0020\U000A' 0,0,2,3:'\U0020\U0308\U000A' + 0,1,2:'\U0020\U0001' 0,0,2,3:'\U0020\U0308\U0001' 0,0,2:'\U0020\U034F' 0,0,0,3:'\U0020\U0308\U034F' 0,1,2:'\U0020\U1F1E6' 0,0,2,3:'\U0020\U0308\U1F1E6' + 0,1,2:'\U0020\U0600' 0,0,2,3:'\U0020\U0308\U0600' 0,0,2:'\U0020\U0A03' 0,0,0,3:'\U0020\U0308\U0A03' 0,1,2:'\U0020\U1100' 0,0,2,3:'\U0020\U0308\U1100' + 0,1,2:'\U0020\U1160' 0,0,2,3:'\U0020\U0308\U1160' 0,1,2:'\U0020\U11A8' 0,0,2,3:'\U0020\U0308\U11A8' 0,1,2:'\U0020\UAC00' 0,0,2,3:'\U0020\U0308\UAC00' + 0,1,2:'\U0020\UAC01' 0,0,2,3:'\U0020\U0308\UAC01' 0,0,2:'\U0020\U0900' 0,0,0,3:'\U0020\U0308\U0900' 0,0,2:'\U0020\U0903' 0,0,0,3:'\U0020\U0308\U0903' + 0,1,2:'\U0020\U0904' 0,0,2,3:'\U0020\U0308\U0904' 0,1,2:'\U0020\U0D4E' 0,0,2,3:'\U0020\U0308\U0D4E' 0,1,2:'\U0020\U0915' 0,0,2,3:'\U0020\U0308\U0915' + 0,1,2:'\U0020\U231A' 0,0,2,3:'\U0020\U0308\U231A' 0,0,2:'\U0020\U0300' 0,0,0,3:'\U0020\U0308\U0300' 0,0,2:'\U0020\U093C' 0,0,0,3:'\U0020\U0308\U093C' + 0,0,2:'\U0020\U094D' 0,0,0,3:'\U0020\U0308\U094D' 0,0,2:'\U0020\U200D' 0,0,0,3:'\U0020\U0308\U200D' 0,1,2:'\U0020\U0378' 0,0,2,3:'\U0020\U0308\U0378' + 0,1,2:'\U000D\U0020' 0,1,2,3:'\U000D\U0308\U0020' 0,1,2:'\U000D\U000D' 0,1,2,3:'\U000D\U0308\U000D' 0,1,2:'\U000D\U000A' 0,1,2,3:'\U000D\U0308\U000A' + 0,1,2:'\U000D\U0001' 0,1,2,3:'\U000D\U0308\U0001' 0,1,2:'\U000D\U034F' 0,1,1,3:'\U000D\U0308\U034F' 0,1,2:'\U000D\U1F1E6' 0,1,2,3:'\U000D\U0308\U1F1E6' + 0,1,2:'\U000D\U0600' 0,1,2,3:'\U000D\U0308\U0600' 0,1,2:'\U000D\U0A03' 0,1,1,3:'\U000D\U0308\U0A03' 0,1,2:'\U000D\U1100' 0,1,2,3:'\U000D\U0308\U1100' + 0,1,2:'\U000D\U1160' 0,1,2,3:'\U000D\U0308\U1160' 0,1,2:'\U000D\U11A8' 0,1,2,3:'\U000D\U0308\U11A8' 0,1,2:'\U000D\UAC00' 0,1,2,3:'\U000D\U0308\UAC00' + 0,1,2:'\U000D\UAC01' 0,1,2,3:'\U000D\U0308\UAC01' 0,1,2:'\U000D\U0900' 0,1,1,3:'\U000D\U0308\U0900' 0,1,2:'\U000D\U0903' 0,1,1,3:'\U000D\U0308\U0903' + 0,1,2:'\U000D\U0904' 0,1,2,3:'\U000D\U0308\U0904' 0,1,2:'\U000D\U0D4E' 0,1,2,3:'\U000D\U0308\U0D4E' 0,1,2:'\U000D\U0915' 0,1,2,3:'\U000D\U0308\U0915' + 0,1,2:'\U000D\U231A' 0,1,2,3:'\U000D\U0308\U231A' 0,1,2:'\U000D\U0300' 0,1,1,3:'\U000D\U0308\U0300' 0,1,2:'\U000D\U093C' 0,1,1,3:'\U000D\U0308\U093C' + 0,1,2:'\U000D\U094D' 0,1,1,3:'\U000D\U0308\U094D' 0,1,2:'\U000D\U200D' 0,1,1,3:'\U000D\U0308\U200D' 0,1,2:'\U000D\U0378' 0,1,2,3:'\U000D\U0308\U0378' + 0,1,2:'\U000A\U0020' 0,1,2,3:'\U000A\U0308\U0020' 0,1,2:'\U000A\U000D' 0,1,2,3:'\U000A\U0308\U000D' 0,1,2:'\U000A\U000A' 0,1,2,3:'\U000A\U0308\U000A' + 0,1,2:'\U000A\U0001' 0,1,2,3:'\U000A\U0308\U0001' 0,1,2:'\U000A\U034F' 0,1,1,3:'\U000A\U0308\U034F' 0,1,2:'\U000A\U1F1E6' 0,1,2,3:'\U000A\U0308\U1F1E6' + 0,1,2:'\U000A\U0600' 0,1,2,3:'\U000A\U0308\U0600' 0,1,2:'\U000A\U0A03' 0,1,1,3:'\U000A\U0308\U0A03' 0,1,2:'\U000A\U1100' 0,1,2,3:'\U000A\U0308\U1100' + 0,1,2:'\U000A\U1160' 0,1,2,3:'\U000A\U0308\U1160' 0,1,2:'\U000A\U11A8' 0,1,2,3:'\U000A\U0308\U11A8' 0,1,2:'\U000A\UAC00' 0,1,2,3:'\U000A\U0308\UAC00' + 0,1,2:'\U000A\UAC01' 0,1,2,3:'\U000A\U0308\UAC01' 0,1,2:'\U000A\U0900' 0,1,1,3:'\U000A\U0308\U0900' 0,1,2:'\U000A\U0903' 0,1,1,3:'\U000A\U0308\U0903' + 0,1,2:'\U000A\U0904' 0,1,2,3:'\U000A\U0308\U0904' 0,1,2:'\U000A\U0D4E' 0,1,2,3:'\U000A\U0308\U0D4E' 0,1,2:'\U000A\U0915' 0,1,2,3:'\U000A\U0308\U0915' + 0,1,2:'\U000A\U231A' 0,1,2,3:'\U000A\U0308\U231A' 0,1,2:'\U000A\U0300' 0,1,1,3:'\U000A\U0308\U0300' 0,1,2:'\U000A\U093C' 0,1,1,3:'\U000A\U0308\U093C' + 0,1,2:'\U000A\U094D' 0,1,1,3:'\U000A\U0308\U094D' 0,1,2:'\U000A\U200D' 0,1,1,3:'\U000A\U0308\U200D' 0,1,2:'\U000A\U0378' 0,1,2,3:'\U000A\U0308\U0378' + 0,1,2:'\U0001\U0020' 0,1,2,3:'\U0001\U0308\U0020' 0,1,2:'\U0001\U000D' 0,1,2,3:'\U0001\U0308\U000D' 0,1,2:'\U0001\U000A' 0,1,2,3:'\U0001\U0308\U000A' + 0,1,2:'\U0001\U0001' 0,1,2,3:'\U0001\U0308\U0001' 0,1,2:'\U0001\U034F' 0,1,1,3:'\U0001\U0308\U034F' 0,1,2:'\U0001\U1F1E6' 0,1,2,3:'\U0001\U0308\U1F1E6' + 0,1,2:'\U0001\U0600' 0,1,2,3:'\U0001\U0308\U0600' 0,1,2:'\U0001\U0A03' 0,1,1,3:'\U0001\U0308\U0A03' 0,1,2:'\U0001\U1100' 0,1,2,3:'\U0001\U0308\U1100' + 0,1,2:'\U0001\U1160' 0,1,2,3:'\U0001\U0308\U1160' 0,1,2:'\U0001\U11A8' 0,1,2,3:'\U0001\U0308\U11A8' 0,1,2:'\U0001\UAC00' 0,1,2,3:'\U0001\U0308\UAC00' + 0,1,2:'\U0001\UAC01' 0,1,2,3:'\U0001\U0308\UAC01' 0,1,2:'\U0001\U0900' 0,1,1,3:'\U0001\U0308\U0900' 0,1,2:'\U0001\U0903' 0,1,1,3:'\U0001\U0308\U0903' + 0,1,2:'\U0001\U0904' 0,1,2,3:'\U0001\U0308\U0904' 0,1,2:'\U0001\U0D4E' 0,1,2,3:'\U0001\U0308\U0D4E' 0,1,2:'\U0001\U0915' 0,1,2,3:'\U0001\U0308\U0915' + 0,1,2:'\U0001\U231A' 0,1,2,3:'\U0001\U0308\U231A' 0,1,2:'\U0001\U0300' 0,1,1,3:'\U0001\U0308\U0300' 0,1,2:'\U0001\U093C' 0,1,1,3:'\U0001\U0308\U093C' + 0,1,2:'\U0001\U094D' 0,1,1,3:'\U0001\U0308\U094D' 0,1,2:'\U0001\U200D' 0,1,1,3:'\U0001\U0308\U200D' 0,1,2:'\U0001\U0378' 0,1,2,3:'\U0001\U0308\U0378' + 0,1,2:'\U034F\U0020' 0,0,2,3:'\U034F\U0308\U0020' 0,1,2:'\U034F\U000D' 0,0,2,3:'\U034F\U0308\U000D' 0,1,2:'\U034F\U000A' 0,0,2,3:'\U034F\U0308\U000A' + 0,1,2:'\U034F\U0001' 0,0,2,3:'\U034F\U0308\U0001' 0,0,2:'\U034F\U034F' 0,0,0,3:'\U034F\U0308\U034F' 0,1,2:'\U034F\U1F1E6' 0,0,2,3:'\U034F\U0308\U1F1E6' + 0,1,2:'\U034F\U0600' 0,0,2,3:'\U034F\U0308\U0600' 0,0,2:'\U034F\U0A03' 0,0,0,3:'\U034F\U0308\U0A03' 0,1,2:'\U034F\U1100' 0,0,2,3:'\U034F\U0308\U1100' + 0,1,2:'\U034F\U1160' 0,0,2,3:'\U034F\U0308\U1160' 0,1,2:'\U034F\U11A8' 0,0,2,3:'\U034F\U0308\U11A8' 0,1,2:'\U034F\UAC00' 0,0,2,3:'\U034F\U0308\UAC00' + 0,1,2:'\U034F\UAC01' 0,0,2,3:'\U034F\U0308\UAC01' 0,0,2:'\U034F\U0900' 0,0,0,3:'\U034F\U0308\U0900' 0,0,2:'\U034F\U0903' 0,0,0,3:'\U034F\U0308\U0903' + 0,1,2:'\U034F\U0904' 0,0,2,3:'\U034F\U0308\U0904' 0,1,2:'\U034F\U0D4E' 0,0,2,3:'\U034F\U0308\U0D4E' 0,1,2:'\U034F\U0915' 0,0,2,3:'\U034F\U0308\U0915' + 0,1,2:'\U034F\U231A' 0,0,2,3:'\U034F\U0308\U231A' 0,0,2:'\U034F\U0300' 0,0,0,3:'\U034F\U0308\U0300' 0,0,2:'\U034F\U093C' 0,0,0,3:'\U034F\U0308\U093C' + 0,0,2:'\U034F\U094D' 0,0,0,3:'\U034F\U0308\U094D' 0,0,2:'\U034F\U200D' 0,0,0,3:'\U034F\U0308\U200D' 0,1,2:'\U034F\U0378' 0,0,2,3:'\U034F\U0308\U0378' + 0,1,2:'\U1F1E6\U0020' 0,0,2,3:'\U1F1E6\U0308\U0020' 0,1,2:'\U1F1E6\U000D' 0,0,2,3:'\U1F1E6\U0308\U000D' 0,1,2:'\U1F1E6\U000A' 0,0,2,3:'\U1F1E6\U0308\U000A' + 0,1,2:'\U1F1E6\U0001' 0,0,2,3:'\U1F1E6\U0308\U0001' 0,0,2:'\U1F1E6\U034F' 0,0,0,3:'\U1F1E6\U0308\U034F' 0,0,2:'\U1F1E6\U1F1E6' + 0,0,2,3:'\U1F1E6\U0308\U1F1E6' 0,1,2:'\U1F1E6\U0600' 0,0,2,3:'\U1F1E6\U0308\U0600' 0,0,2:'\U1F1E6\U0A03' 0,0,0,3:'\U1F1E6\U0308\U0A03' + 0,1,2:'\U1F1E6\U1100' 0,0,2,3:'\U1F1E6\U0308\U1100' 0,1,2:'\U1F1E6\U1160' 0,0,2,3:'\U1F1E6\U0308\U1160' 0,1,2:'\U1F1E6\U11A8' 0,0,2,3:'\U1F1E6\U0308\U11A8' + 0,1,2:'\U1F1E6\UAC00' 0,0,2,3:'\U1F1E6\U0308\UAC00' 0,1,2:'\U1F1E6\UAC01' 0,0,2,3:'\U1F1E6\U0308\UAC01' 0,0,2:'\U1F1E6\U0900' 0,0,0,3:'\U1F1E6\U0308\U0900' + 0,0,2:'\U1F1E6\U0903' 0,0,0,3:'\U1F1E6\U0308\U0903' 0,1,2:'\U1F1E6\U0904' 0,0,2,3:'\U1F1E6\U0308\U0904' 0,1,2:'\U1F1E6\U0D4E' 0,0,2,3:'\U1F1E6\U0308\U0D4E' + 0,1,2:'\U1F1E6\U0915' 0,0,2,3:'\U1F1E6\U0308\U0915' 0,1,2:'\U1F1E6\U231A' 0,0,2,3:'\U1F1E6\U0308\U231A' 0,0,2:'\U1F1E6\U0300' 0,0,0,3:'\U1F1E6\U0308\U0300' + 0,0,2:'\U1F1E6\U093C' 0,0,0,3:'\U1F1E6\U0308\U093C' 0,0,2:'\U1F1E6\U094D' 0,0,0,3:'\U1F1E6\U0308\U094D' 0,0,2:'\U1F1E6\U200D' 0,0,0,3:'\U1F1E6\U0308\U200D' + 0,1,2:'\U1F1E6\U0378' 0,0,2,3:'\U1F1E6\U0308\U0378' 0,0,2:'\U0600\U0020' 0,0,2,3:'\U0600\U0308\U0020' 0,1,2:'\U0600\U000D' 0,0,2,3:'\U0600\U0308\U000D' + 0,1,2:'\U0600\U000A' 0,0,2,3:'\U0600\U0308\U000A' 0,1,2:'\U0600\U0001' 0,0,2,3:'\U0600\U0308\U0001' 0,0,2:'\U0600\U034F' 0,0,0,3:'\U0600\U0308\U034F' + 0,0,2:'\U0600\U1F1E6' 0,0,2,3:'\U0600\U0308\U1F1E6' 0,0,2:'\U0600\U0600' 0,0,2,3:'\U0600\U0308\U0600' 0,0,2:'\U0600\U0A03' 0,0,0,3:'\U0600\U0308\U0A03' + 0,0,2:'\U0600\U1100' 0,0,2,3:'\U0600\U0308\U1100' 0,0,2:'\U0600\U1160' 0,0,2,3:'\U0600\U0308\U1160' 0,0,2:'\U0600\U11A8' 0,0,2,3:'\U0600\U0308\U11A8' + 0,0,2:'\U0600\UAC00' 0,0,2,3:'\U0600\U0308\UAC00' 0,0,2:'\U0600\UAC01' 0,0,2,3:'\U0600\U0308\UAC01' 0,0,2:'\U0600\U0900' 0,0,0,3:'\U0600\U0308\U0900' + 0,0,2:'\U0600\U0903' 0,0,0,3:'\U0600\U0308\U0903' 0,0,2:'\U0600\U0904' 0,0,2,3:'\U0600\U0308\U0904' 0,0,2:'\U0600\U0D4E' 0,0,2,3:'\U0600\U0308\U0D4E' + 0,0,2:'\U0600\U0915' 0,0,2,3:'\U0600\U0308\U0915' 0,0,2:'\U0600\U231A' 0,0,2,3:'\U0600\U0308\U231A' 0,0,2:'\U0600\U0300' 0,0,0,3:'\U0600\U0308\U0300' + 0,0,2:'\U0600\U093C' 0,0,0,3:'\U0600\U0308\U093C' 0,0,2:'\U0600\U094D' 0,0,0,3:'\U0600\U0308\U094D' 0,0,2:'\U0600\U200D' 0,0,0,3:'\U0600\U0308\U200D' + 0,0,2:'\U0600\U0378' 0,0,2,3:'\U0600\U0308\U0378' 0,1,2:'\U0A03\U0020' 0,0,2,3:'\U0A03\U0308\U0020' 0,1,2:'\U0A03\U000D' 0,0,2,3:'\U0A03\U0308\U000D' + 0,1,2:'\U0A03\U000A' 0,0,2,3:'\U0A03\U0308\U000A' 0,1,2:'\U0A03\U0001' 0,0,2,3:'\U0A03\U0308\U0001' 0,0,2:'\U0A03\U034F' 0,0,0,3:'\U0A03\U0308\U034F' + 0,1,2:'\U0A03\U1F1E6' 0,0,2,3:'\U0A03\U0308\U1F1E6' 0,1,2:'\U0A03\U0600' 0,0,2,3:'\U0A03\U0308\U0600' 0,0,2:'\U0A03\U0A03' 0,0,0,3:'\U0A03\U0308\U0A03' + 0,1,2:'\U0A03\U1100' 0,0,2,3:'\U0A03\U0308\U1100' 0,1,2:'\U0A03\U1160' 0,0,2,3:'\U0A03\U0308\U1160' 0,1,2:'\U0A03\U11A8' 0,0,2,3:'\U0A03\U0308\U11A8' + 0,1,2:'\U0A03\UAC00' 0,0,2,3:'\U0A03\U0308\UAC00' 0,1,2:'\U0A03\UAC01' 0,0,2,3:'\U0A03\U0308\UAC01' 0,0,2:'\U0A03\U0900' 0,0,0,3:'\U0A03\U0308\U0900' + 0,0,2:'\U0A03\U0903' 0,0,0,3:'\U0A03\U0308\U0903' 0,1,2:'\U0A03\U0904' 0,0,2,3:'\U0A03\U0308\U0904' 0,1,2:'\U0A03\U0D4E' 0,0,2,3:'\U0A03\U0308\U0D4E' + 0,1,2:'\U0A03\U0915' 0,0,2,3:'\U0A03\U0308\U0915' 0,1,2:'\U0A03\U231A' 0,0,2,3:'\U0A03\U0308\U231A' 0,0,2:'\U0A03\U0300' 0,0,0,3:'\U0A03\U0308\U0300' + 0,0,2:'\U0A03\U093C' 0,0,0,3:'\U0A03\U0308\U093C' 0,0,2:'\U0A03\U094D' 0,0,0,3:'\U0A03\U0308\U094D' 0,0,2:'\U0A03\U200D' 0,0,0,3:'\U0A03\U0308\U200D' + 0,1,2:'\U0A03\U0378' 0,0,2,3:'\U0A03\U0308\U0378' 0,1,2:'\U1100\U0020' 0,0,2,3:'\U1100\U0308\U0020' 0,1,2:'\U1100\U000D' 0,0,2,3:'\U1100\U0308\U000D' + 0,1,2:'\U1100\U000A' 0,0,2,3:'\U1100\U0308\U000A' 0,1,2:'\U1100\U0001' 0,0,2,3:'\U1100\U0308\U0001' 0,0,2:'\U1100\U034F' 0,0,0,3:'\U1100\U0308\U034F' + 0,1,2:'\U1100\U1F1E6' 0,0,2,3:'\U1100\U0308\U1F1E6' 0,1,2:'\U1100\U0600' 0,0,2,3:'\U1100\U0308\U0600' 0,0,2:'\U1100\U0A03' 0,0,0,3:'\U1100\U0308\U0A03' + 0,0,2:'\U1100\U1100' 0,0,2,3:'\U1100\U0308\U1100' 0,0,2:'\U1100\U1160' 0,0,2,3:'\U1100\U0308\U1160' 0,1,2:'\U1100\U11A8' 0,0,2,3:'\U1100\U0308\U11A8' + 0,0,2:'\U1100\UAC00' 0,0,2,3:'\U1100\U0308\UAC00' 0,0,2:'\U1100\UAC01' 0,0,2,3:'\U1100\U0308\UAC01' 0,0,2:'\U1100\U0900' 0,0,0,3:'\U1100\U0308\U0900' + 0,0,2:'\U1100\U0903' 0,0,0,3:'\U1100\U0308\U0903' 0,1,2:'\U1100\U0904' 0,0,2,3:'\U1100\U0308\U0904' 0,1,2:'\U1100\U0D4E' 0,0,2,3:'\U1100\U0308\U0D4E' + 0,1,2:'\U1100\U0915' 0,0,2,3:'\U1100\U0308\U0915' 0,1,2:'\U1100\U231A' 0,0,2,3:'\U1100\U0308\U231A' 0,0,2:'\U1100\U0300' 0,0,0,3:'\U1100\U0308\U0300' + 0,0,2:'\U1100\U093C' 0,0,0,3:'\U1100\U0308\U093C' 0,0,2:'\U1100\U094D' 0,0,0,3:'\U1100\U0308\U094D' 0,0,2:'\U1100\U200D' 0,0,0,3:'\U1100\U0308\U200D' + 0,1,2:'\U1100\U0378' 0,0,2,3:'\U1100\U0308\U0378' 0,1,2:'\U1160\U0020' 0,0,2,3:'\U1160\U0308\U0020' 0,1,2:'\U1160\U000D' 0,0,2,3:'\U1160\U0308\U000D' + 0,1,2:'\U1160\U000A' 0,0,2,3:'\U1160\U0308\U000A' 0,1,2:'\U1160\U0001' 0,0,2,3:'\U1160\U0308\U0001' 0,0,2:'\U1160\U034F' 0,0,0,3:'\U1160\U0308\U034F' + 0,1,2:'\U1160\U1F1E6' 0,0,2,3:'\U1160\U0308\U1F1E6' 0,1,2:'\U1160\U0600' 0,0,2,3:'\U1160\U0308\U0600' 0,0,2:'\U1160\U0A03' 0,0,0,3:'\U1160\U0308\U0A03' + 0,1,2:'\U1160\U1100' 0,0,2,3:'\U1160\U0308\U1100' 0,0,2:'\U1160\U1160' 0,0,2,3:'\U1160\U0308\U1160' 0,0,2:'\U1160\U11A8' 0,0,2,3:'\U1160\U0308\U11A8' + 0,1,2:'\U1160\UAC00' 0,0,2,3:'\U1160\U0308\UAC00' 0,1,2:'\U1160\UAC01' 0,0,2,3:'\U1160\U0308\UAC01' 0,0,2:'\U1160\U0900' 0,0,0,3:'\U1160\U0308\U0900' + 0,0,2:'\U1160\U0903' 0,0,0,3:'\U1160\U0308\U0903' 0,1,2:'\U1160\U0904' 0,0,2,3:'\U1160\U0308\U0904' 0,1,2:'\U1160\U0D4E' 0,0,2,3:'\U1160\U0308\U0D4E' + 0,1,2:'\U1160\U0915' 0,0,2,3:'\U1160\U0308\U0915' 0,1,2:'\U1160\U231A' 0,0,2,3:'\U1160\U0308\U231A' 0,0,2:'\U1160\U0300' 0,0,0,3:'\U1160\U0308\U0300' + 0,0,2:'\U1160\U093C' 0,0,0,3:'\U1160\U0308\U093C' 0,0,2:'\U1160\U094D' 0,0,0,3:'\U1160\U0308\U094D' 0,0,2:'\U1160\U200D' 0,0,0,3:'\U1160\U0308\U200D' + 0,1,2:'\U1160\U0378' 0,0,2,3:'\U1160\U0308\U0378' 0,1,2:'\U11A8\U0020' 0,0,2,3:'\U11A8\U0308\U0020' 0,1,2:'\U11A8\U000D' 0,0,2,3:'\U11A8\U0308\U000D' + 0,1,2:'\U11A8\U000A' 0,0,2,3:'\U11A8\U0308\U000A' 0,1,2:'\U11A8\U0001' 0,0,2,3:'\U11A8\U0308\U0001' 0,0,2:'\U11A8\U034F' 0,0,0,3:'\U11A8\U0308\U034F' + 0,1,2:'\U11A8\U1F1E6' 0,0,2,3:'\U11A8\U0308\U1F1E6' 0,1,2:'\U11A8\U0600' 0,0,2,3:'\U11A8\U0308\U0600' 0,0,2:'\U11A8\U0A03' 0,0,0,3:'\U11A8\U0308\U0A03' + 0,1,2:'\U11A8\U1100' 0,0,2,3:'\U11A8\U0308\U1100' 0,1,2:'\U11A8\U1160' 0,0,2,3:'\U11A8\U0308\U1160' 0,0,2:'\U11A8\U11A8' 0,0,2,3:'\U11A8\U0308\U11A8' + 0,1,2:'\U11A8\UAC00' 0,0,2,3:'\U11A8\U0308\UAC00' 0,1,2:'\U11A8\UAC01' 0,0,2,3:'\U11A8\U0308\UAC01' 0,0,2:'\U11A8\U0900' 0,0,0,3:'\U11A8\U0308\U0900' + 0,0,2:'\U11A8\U0903' 0,0,0,3:'\U11A8\U0308\U0903' 0,1,2:'\U11A8\U0904' 0,0,2,3:'\U11A8\U0308\U0904' 0,1,2:'\U11A8\U0D4E' 0,0,2,3:'\U11A8\U0308\U0D4E' + 0,1,2:'\U11A8\U0915' 0,0,2,3:'\U11A8\U0308\U0915' 0,1,2:'\U11A8\U231A' 0,0,2,3:'\U11A8\U0308\U231A' 0,0,2:'\U11A8\U0300' 0,0,0,3:'\U11A8\U0308\U0300' + 0,0,2:'\U11A8\U093C' 0,0,0,3:'\U11A8\U0308\U093C' 0,0,2:'\U11A8\U094D' 0,0,0,3:'\U11A8\U0308\U094D' 0,0,2:'\U11A8\U200D' 0,0,0,3:'\U11A8\U0308\U200D' + 0,1,2:'\U11A8\U0378' 0,0,2,3:'\U11A8\U0308\U0378' 0,1,2:'\UAC00\U0020' 0,0,2,3:'\UAC00\U0308\U0020' 0,1,2:'\UAC00\U000D' 0,0,2,3:'\UAC00\U0308\U000D' + 0,1,2:'\UAC00\U000A' 0,0,2,3:'\UAC00\U0308\U000A' 0,1,2:'\UAC00\U0001' 0,0,2,3:'\UAC00\U0308\U0001' 0,0,2:'\UAC00\U034F' 0,0,0,3:'\UAC00\U0308\U034F' + 0,1,2:'\UAC00\U1F1E6' 0,0,2,3:'\UAC00\U0308\U1F1E6' 0,1,2:'\UAC00\U0600' 0,0,2,3:'\UAC00\U0308\U0600' 0,0,2:'\UAC00\U0A03' 0,0,0,3:'\UAC00\U0308\U0A03' + 0,1,2:'\UAC00\U1100' 0,0,2,3:'\UAC00\U0308\U1100' 0,0,2:'\UAC00\U1160' 0,0,2,3:'\UAC00\U0308\U1160' 0,0,2:'\UAC00\U11A8' 0,0,2,3:'\UAC00\U0308\U11A8' + 0,1,2:'\UAC00\UAC00' 0,0,2,3:'\UAC00\U0308\UAC00' 0,1,2:'\UAC00\UAC01' 0,0,2,3:'\UAC00\U0308\UAC01' 0,0,2:'\UAC00\U0900' 0,0,0,3:'\UAC00\U0308\U0900' + 0,0,2:'\UAC00\U0903' 0,0,0,3:'\UAC00\U0308\U0903' 0,1,2:'\UAC00\U0904' 0,0,2,3:'\UAC00\U0308\U0904' 0,1,2:'\UAC00\U0D4E' 0,0,2,3:'\UAC00\U0308\U0D4E' + 0,1,2:'\UAC00\U0915' 0,0,2,3:'\UAC00\U0308\U0915' 0,1,2:'\UAC00\U231A' 0,0,2,3:'\UAC00\U0308\U231A' 0,0,2:'\UAC00\U0300' 0,0,0,3:'\UAC00\U0308\U0300' + 0,0,2:'\UAC00\U093C' 0,0,0,3:'\UAC00\U0308\U093C' 0,0,2:'\UAC00\U094D' 0,0,0,3:'\UAC00\U0308\U094D' 0,0,2:'\UAC00\U200D' 0,0,0,3:'\UAC00\U0308\U200D' + 0,1,2:'\UAC00\U0378' 0,0,2,3:'\UAC00\U0308\U0378' 0,1,2:'\UAC01\U0020' 0,0,2,3:'\UAC01\U0308\U0020' 0,1,2:'\UAC01\U000D' 0,0,2,3:'\UAC01\U0308\U000D' + 0,1,2:'\UAC01\U000A' 0,0,2,3:'\UAC01\U0308\U000A' 0,1,2:'\UAC01\U0001' 0,0,2,3:'\UAC01\U0308\U0001' 0,0,2:'\UAC01\U034F' 0,0,0,3:'\UAC01\U0308\U034F' + 0,1,2:'\UAC01\U1F1E6' 0,0,2,3:'\UAC01\U0308\U1F1E6' 0,1,2:'\UAC01\U0600' 0,0,2,3:'\UAC01\U0308\U0600' 0,0,2:'\UAC01\U0A03' 0,0,0,3:'\UAC01\U0308\U0A03' + 0,1,2:'\UAC01\U1100' 0,0,2,3:'\UAC01\U0308\U1100' 0,1,2:'\UAC01\U1160' 0,0,2,3:'\UAC01\U0308\U1160' 0,0,2:'\UAC01\U11A8' 0,0,2,3:'\UAC01\U0308\U11A8' + 0,1,2:'\UAC01\UAC00' 0,0,2,3:'\UAC01\U0308\UAC00' 0,1,2:'\UAC01\UAC01' 0,0,2,3:'\UAC01\U0308\UAC01' 0,0,2:'\UAC01\U0900' 0,0,0,3:'\UAC01\U0308\U0900' + 0,0,2:'\UAC01\U0903' 0,0,0,3:'\UAC01\U0308\U0903' 0,1,2:'\UAC01\U0904' 0,0,2,3:'\UAC01\U0308\U0904' 0,1,2:'\UAC01\U0D4E' 0,0,2,3:'\UAC01\U0308\U0D4E' + 0,1,2:'\UAC01\U0915' 0,0,2,3:'\UAC01\U0308\U0915' 0,1,2:'\UAC01\U231A' 0,0,2,3:'\UAC01\U0308\U231A' 0,0,2:'\UAC01\U0300' 0,0,0,3:'\UAC01\U0308\U0300' + 0,0,2:'\UAC01\U093C' 0,0,0,3:'\UAC01\U0308\U093C' 0,0,2:'\UAC01\U094D' 0,0,0,3:'\UAC01\U0308\U094D' 0,0,2:'\UAC01\U200D' 0,0,0,3:'\UAC01\U0308\U200D' + 0,1,2:'\UAC01\U0378' 0,0,2,3:'\UAC01\U0308\U0378' 0,1,2:'\U0900\U0020' 0,0,2,3:'\U0900\U0308\U0020' 0,1,2:'\U0900\U000D' 0,0,2,3:'\U0900\U0308\U000D' + 0,1,2:'\U0900\U000A' 0,0,2,3:'\U0900\U0308\U000A' 0,1,2:'\U0900\U0001' 0,0,2,3:'\U0900\U0308\U0001' 0,0,2:'\U0900\U034F' 0,0,0,3:'\U0900\U0308\U034F' + 0,1,2:'\U0900\U1F1E6' 0,0,2,3:'\U0900\U0308\U1F1E6' 0,1,2:'\U0900\U0600' 0,0,2,3:'\U0900\U0308\U0600' 0,0,2:'\U0900\U0A03' 0,0,0,3:'\U0900\U0308\U0A03' + 0,1,2:'\U0900\U1100' 0,0,2,3:'\U0900\U0308\U1100' 0,1,2:'\U0900\U1160' 0,0,2,3:'\U0900\U0308\U1160' 0,1,2:'\U0900\U11A8' 0,0,2,3:'\U0900\U0308\U11A8' + 0,1,2:'\U0900\UAC00' 0,0,2,3:'\U0900\U0308\UAC00' 0,1,2:'\U0900\UAC01' 0,0,2,3:'\U0900\U0308\UAC01' 0,0,2:'\U0900\U0900' 0,0,0,3:'\U0900\U0308\U0900' + 0,0,2:'\U0900\U0903' 0,0,0,3:'\U0900\U0308\U0903' 0,1,2:'\U0900\U0904' 0,0,2,3:'\U0900\U0308\U0904' 0,1,2:'\U0900\U0D4E' 0,0,2,3:'\U0900\U0308\U0D4E' + 0,1,2:'\U0900\U0915' 0,0,2,3:'\U0900\U0308\U0915' 0,1,2:'\U0900\U231A' 0,0,2,3:'\U0900\U0308\U231A' 0,0,2:'\U0900\U0300' 0,0,0,3:'\U0900\U0308\U0300' + 0,0,2:'\U0900\U093C' 0,0,0,3:'\U0900\U0308\U093C' 0,0,2:'\U0900\U094D' 0,0,0,3:'\U0900\U0308\U094D' 0,0,2:'\U0900\U200D' 0,0,0,3:'\U0900\U0308\U200D' + 0,1,2:'\U0900\U0378' 0,0,2,3:'\U0900\U0308\U0378' 0,1,2:'\U0903\U0020' 0,0,2,3:'\U0903\U0308\U0020' 0,1,2:'\U0903\U000D' 0,0,2,3:'\U0903\U0308\U000D' + 0,1,2:'\U0903\U000A' 0,0,2,3:'\U0903\U0308\U000A' 0,1,2:'\U0903\U0001' 0,0,2,3:'\U0903\U0308\U0001' 0,0,2:'\U0903\U034F' 0,0,0,3:'\U0903\U0308\U034F' + 0,1,2:'\U0903\U1F1E6' 0,0,2,3:'\U0903\U0308\U1F1E6' 0,1,2:'\U0903\U0600' 0,0,2,3:'\U0903\U0308\U0600' 0,0,2:'\U0903\U0A03' 0,0,0,3:'\U0903\U0308\U0A03' + 0,1,2:'\U0903\U1100' 0,0,2,3:'\U0903\U0308\U1100' 0,1,2:'\U0903\U1160' 0,0,2,3:'\U0903\U0308\U1160' 0,1,2:'\U0903\U11A8' 0,0,2,3:'\U0903\U0308\U11A8' + 0,1,2:'\U0903\UAC00' 0,0,2,3:'\U0903\U0308\UAC00' 0,1,2:'\U0903\UAC01' 0,0,2,3:'\U0903\U0308\UAC01' 0,0,2:'\U0903\U0900' 0,0,0,3:'\U0903\U0308\U0900' + 0,0,2:'\U0903\U0903' 0,0,0,3:'\U0903\U0308\U0903' 0,1,2:'\U0903\U0904' 0,0,2,3:'\U0903\U0308\U0904' 0,1,2:'\U0903\U0D4E' 0,0,2,3:'\U0903\U0308\U0D4E' + 0,1,2:'\U0903\U0915' 0,0,2,3:'\U0903\U0308\U0915' 0,1,2:'\U0903\U231A' 0,0,2,3:'\U0903\U0308\U231A' 0,0,2:'\U0903\U0300' 0,0,0,3:'\U0903\U0308\U0300' + 0,0,2:'\U0903\U093C' 0,0,0,3:'\U0903\U0308\U093C' 0,0,2:'\U0903\U094D' 0,0,0,3:'\U0903\U0308\U094D' 0,0,2:'\U0903\U200D' 0,0,0,3:'\U0903\U0308\U200D' + 0,1,2:'\U0903\U0378' 0,0,2,3:'\U0903\U0308\U0378' 0,1,2:'\U0904\U0020' 0,0,2,3:'\U0904\U0308\U0020' 0,1,2:'\U0904\U000D' 0,0,2,3:'\U0904\U0308\U000D' + 0,1,2:'\U0904\U000A' 0,0,2,3:'\U0904\U0308\U000A' 0,1,2:'\U0904\U0001' 0,0,2,3:'\U0904\U0308\U0001' 0,0,2:'\U0904\U034F' 0,0,0,3:'\U0904\U0308\U034F' + 0,1,2:'\U0904\U1F1E6' 0,0,2,3:'\U0904\U0308\U1F1E6' 0,1,2:'\U0904\U0600' 0,0,2,3:'\U0904\U0308\U0600' 0,0,2:'\U0904\U0A03' 0,0,0,3:'\U0904\U0308\U0A03' + 0,1,2:'\U0904\U1100' 0,0,2,3:'\U0904\U0308\U1100' 0,1,2:'\U0904\U1160' 0,0,2,3:'\U0904\U0308\U1160' 0,1,2:'\U0904\U11A8' 0,0,2,3:'\U0904\U0308\U11A8' + 0,1,2:'\U0904\UAC00' 0,0,2,3:'\U0904\U0308\UAC00' 0,1,2:'\U0904\UAC01' 0,0,2,3:'\U0904\U0308\UAC01' 0,0,2:'\U0904\U0900' 0,0,0,3:'\U0904\U0308\U0900' + 0,0,2:'\U0904\U0903' 0,0,0,3:'\U0904\U0308\U0903' 0,1,2:'\U0904\U0904' 0,0,2,3:'\U0904\U0308\U0904' 0,1,2:'\U0904\U0D4E' 0,0,2,3:'\U0904\U0308\U0D4E' + 0,1,2:'\U0904\U0915' 0,0,2,3:'\U0904\U0308\U0915' 0,1,2:'\U0904\U231A' 0,0,2,3:'\U0904\U0308\U231A' 0,0,2:'\U0904\U0300' 0,0,0,3:'\U0904\U0308\U0300' + 0,0,2:'\U0904\U093C' 0,0,0,3:'\U0904\U0308\U093C' 0,0,2:'\U0904\U094D' 0,0,0,3:'\U0904\U0308\U094D' 0,0,2:'\U0904\U200D' 0,0,0,3:'\U0904\U0308\U200D' + 0,1,2:'\U0904\U0378' 0,0,2,3:'\U0904\U0308\U0378' 0,0,2:'\U0D4E\U0020' 0,0,2,3:'\U0D4E\U0308\U0020' 0,1,2:'\U0D4E\U000D' 0,0,2,3:'\U0D4E\U0308\U000D' + 0,1,2:'\U0D4E\U000A' 0,0,2,3:'\U0D4E\U0308\U000A' 0,1,2:'\U0D4E\U0001' 0,0,2,3:'\U0D4E\U0308\U0001' 0,0,2:'\U0D4E\U034F' 0,0,0,3:'\U0D4E\U0308\U034F' + 0,0,2:'\U0D4E\U1F1E6' 0,0,2,3:'\U0D4E\U0308\U1F1E6' 0,0,2:'\U0D4E\U0600' 0,0,2,3:'\U0D4E\U0308\U0600' 0,0,2:'\U0D4E\U0A03' 0,0,0,3:'\U0D4E\U0308\U0A03' + 0,0,2:'\U0D4E\U1100' 0,0,2,3:'\U0D4E\U0308\U1100' 0,0,2:'\U0D4E\U1160' 0,0,2,3:'\U0D4E\U0308\U1160' 0,0,2:'\U0D4E\U11A8' 0,0,2,3:'\U0D4E\U0308\U11A8' + 0,0,2:'\U0D4E\UAC00' 0,0,2,3:'\U0D4E\U0308\UAC00' 0,0,2:'\U0D4E\UAC01' 0,0,2,3:'\U0D4E\U0308\UAC01' 0,0,2:'\U0D4E\U0900' 0,0,0,3:'\U0D4E\U0308\U0900' + 0,0,2:'\U0D4E\U0903' 0,0,0,3:'\U0D4E\U0308\U0903' 0,0,2:'\U0D4E\U0904' 0,0,2,3:'\U0D4E\U0308\U0904' 0,0,2:'\U0D4E\U0D4E' 0,0,2,3:'\U0D4E\U0308\U0D4E' + 0,0,2:'\U0D4E\U0915' 0,0,2,3:'\U0D4E\U0308\U0915' 0,0,2:'\U0D4E\U231A' 0,0,2,3:'\U0D4E\U0308\U231A' 0,0,2:'\U0D4E\U0300' 0,0,0,3:'\U0D4E\U0308\U0300' + 0,0,2:'\U0D4E\U093C' 0,0,0,3:'\U0D4E\U0308\U093C' 0,0,2:'\U0D4E\U094D' 0,0,0,3:'\U0D4E\U0308\U094D' 0,0,2:'\U0D4E\U200D' 0,0,0,3:'\U0D4E\U0308\U200D' + 0,0,2:'\U0D4E\U0378' 0,0,2,3:'\U0D4E\U0308\U0378' 0,1,2:'\U0915\U0020' 0,0,2,3:'\U0915\U0308\U0020' 0,1,2:'\U0915\U000D' 0,0,2,3:'\U0915\U0308\U000D' + 0,1,2:'\U0915\U000A' 0,0,2,3:'\U0915\U0308\U000A' 0,1,2:'\U0915\U0001' 0,0,2,3:'\U0915\U0308\U0001' 0,0,2:'\U0915\U034F' 0,0,0,3:'\U0915\U0308\U034F' + 0,1,2:'\U0915\U1F1E6' 0,0,2,3:'\U0915\U0308\U1F1E6' 0,1,2:'\U0915\U0600' 0,0,2,3:'\U0915\U0308\U0600' 0,0,2:'\U0915\U0A03' 0,0,0,3:'\U0915\U0308\U0A03' + 0,1,2:'\U0915\U1100' 0,0,2,3:'\U0915\U0308\U1100' 0,1,2:'\U0915\U1160' 0,0,2,3:'\U0915\U0308\U1160' 0,1,2:'\U0915\U11A8' 0,0,2,3:'\U0915\U0308\U11A8' + 0,1,2:'\U0915\UAC00' 0,0,2,3:'\U0915\U0308\UAC00' 0,1,2:'\U0915\UAC01' 0,0,2,3:'\U0915\U0308\UAC01' 0,0,2:'\U0915\U0900' 0,0,0,3:'\U0915\U0308\U0900' + 0,0,2:'\U0915\U0903' 0,0,0,3:'\U0915\U0308\U0903' 0,1,2:'\U0915\U0904' 0,0,2,3:'\U0915\U0308\U0904' 0,1,2:'\U0915\U0D4E' 0,0,2,3:'\U0915\U0308\U0D4E' + 0,1,2:'\U0915\U0915' 0,0,2,3:'\U0915\U0308\U0915' 0,1,2:'\U0915\U231A' 0,0,2,3:'\U0915\U0308\U231A' 0,0,2:'\U0915\U0300' 0,0,0,3:'\U0915\U0308\U0300' + 0,0,2:'\U0915\U093C' 0,0,0,3:'\U0915\U0308\U093C' 0,0,2:'\U0915\U094D' 0,0,0,3:'\U0915\U0308\U094D' 0,0,2:'\U0915\U200D' 0,0,0,3:'\U0915\U0308\U200D' + 0,1,2:'\U0915\U0378' 0,0,2,3:'\U0915\U0308\U0378' 0,1,2:'\U231A\U0020' 0,0,2,3:'\U231A\U0308\U0020' 0,1,2:'\U231A\U000D' 0,0,2,3:'\U231A\U0308\U000D' + 0,1,2:'\U231A\U000A' 0,0,2,3:'\U231A\U0308\U000A' 0,1,2:'\U231A\U0001' 0,0,2,3:'\U231A\U0308\U0001' 0,0,2:'\U231A\U034F' 0,0,0,3:'\U231A\U0308\U034F' + 0,1,2:'\U231A\U1F1E6' 0,0,2,3:'\U231A\U0308\U1F1E6' 0,1,2:'\U231A\U0600' 0,0,2,3:'\U231A\U0308\U0600' 0,0,2:'\U231A\U0A03' 0,0,0,3:'\U231A\U0308\U0A03' + 0,1,2:'\U231A\U1100' 0,0,2,3:'\U231A\U0308\U1100' 0,1,2:'\U231A\U1160' 0,0,2,3:'\U231A\U0308\U1160' 0,1,2:'\U231A\U11A8' 0,0,2,3:'\U231A\U0308\U11A8' + 0,1,2:'\U231A\UAC00' 0,0,2,3:'\U231A\U0308\UAC00' 0,1,2:'\U231A\UAC01' 0,0,2,3:'\U231A\U0308\UAC01' 0,0,2:'\U231A\U0900' 0,0,0,3:'\U231A\U0308\U0900' + 0,0,2:'\U231A\U0903' 0,0,0,3:'\U231A\U0308\U0903' 0,1,2:'\U231A\U0904' 0,0,2,3:'\U231A\U0308\U0904' 0,1,2:'\U231A\U0D4E' 0,0,2,3:'\U231A\U0308\U0D4E' + 0,1,2:'\U231A\U0915' 0,0,2,3:'\U231A\U0308\U0915' 0,1,2:'\U231A\U231A' 0,0,2,3:'\U231A\U0308\U231A' 0,0,2:'\U231A\U0300' 0,0,0,3:'\U231A\U0308\U0300' + 0,0,2:'\U231A\U093C' 0,0,0,3:'\U231A\U0308\U093C' 0,0,2:'\U231A\U094D' 0,0,0,3:'\U231A\U0308\U094D' 0,0,2:'\U231A\U200D' 0,0,0,3:'\U231A\U0308\U200D' + 0,1,2:'\U231A\U0378' 0,0,2,3:'\U231A\U0308\U0378' 0,1,2:'\U0300\U0020' 0,0,2,3:'\U0300\U0308\U0020' 0,1,2:'\U0300\U000D' 0,0,2,3:'\U0300\U0308\U000D' + 0,1,2:'\U0300\U000A' 0,0,2,3:'\U0300\U0308\U000A' 0,1,2:'\U0300\U0001' 0,0,2,3:'\U0300\U0308\U0001' 0,0,2:'\U0300\U034F' 0,0,0,3:'\U0300\U0308\U034F' + 0,1,2:'\U0300\U1F1E6' 0,0,2,3:'\U0300\U0308\U1F1E6' 0,1,2:'\U0300\U0600' 0,0,2,3:'\U0300\U0308\U0600' 0,0,2:'\U0300\U0A03' 0,0,0,3:'\U0300\U0308\U0A03' + 0,1,2:'\U0300\U1100' 0,0,2,3:'\U0300\U0308\U1100' 0,1,2:'\U0300\U1160' 0,0,2,3:'\U0300\U0308\U1160' 0,1,2:'\U0300\U11A8' 0,0,2,3:'\U0300\U0308\U11A8' + 0,1,2:'\U0300\UAC00' 0,0,2,3:'\U0300\U0308\UAC00' 0,1,2:'\U0300\UAC01' 0,0,2,3:'\U0300\U0308\UAC01' 0,0,2:'\U0300\U0900' 0,0,0,3:'\U0300\U0308\U0900' + 0,0,2:'\U0300\U0903' 0,0,0,3:'\U0300\U0308\U0903' 0,1,2:'\U0300\U0904' 0,0,2,3:'\U0300\U0308\U0904' 0,1,2:'\U0300\U0D4E' 0,0,2,3:'\U0300\U0308\U0D4E' + 0,1,2:'\U0300\U0915' 0,0,2,3:'\U0300\U0308\U0915' 0,1,2:'\U0300\U231A' 0,0,2,3:'\U0300\U0308\U231A' 0,0,2:'\U0300\U0300' 0,0,0,3:'\U0300\U0308\U0300' + 0,0,2:'\U0300\U093C' 0,0,0,3:'\U0300\U0308\U093C' 0,0,2:'\U0300\U094D' 0,0,0,3:'\U0300\U0308\U094D' 0,0,2:'\U0300\U200D' 0,0,0,3:'\U0300\U0308\U200D' + 0,1,2:'\U0300\U0378' 0,0,2,3:'\U0300\U0308\U0378' 0,1,2:'\U093C\U0020' 0,0,2,3:'\U093C\U0308\U0020' 0,1,2:'\U093C\U000D' 0,0,2,3:'\U093C\U0308\U000D' + 0,1,2:'\U093C\U000A' 0,0,2,3:'\U093C\U0308\U000A' 0,1,2:'\U093C\U0001' 0,0,2,3:'\U093C\U0308\U0001' 0,0,2:'\U093C\U034F' 0,0,0,3:'\U093C\U0308\U034F' + 0,1,2:'\U093C\U1F1E6' 0,0,2,3:'\U093C\U0308\U1F1E6' 0,1,2:'\U093C\U0600' 0,0,2,3:'\U093C\U0308\U0600' 0,0,2:'\U093C\U0A03' 0,0,0,3:'\U093C\U0308\U0A03' + 0,1,2:'\U093C\U1100' 0,0,2,3:'\U093C\U0308\U1100' 0,1,2:'\U093C\U1160' 0,0,2,3:'\U093C\U0308\U1160' 0,1,2:'\U093C\U11A8' 0,0,2,3:'\U093C\U0308\U11A8' + 0,1,2:'\U093C\UAC00' 0,0,2,3:'\U093C\U0308\UAC00' 0,1,2:'\U093C\UAC01' 0,0,2,3:'\U093C\U0308\UAC01' 0,0,2:'\U093C\U0900' 0,0,0,3:'\U093C\U0308\U0900' + 0,0,2:'\U093C\U0903' 0,0,0,3:'\U093C\U0308\U0903' 0,1,2:'\U093C\U0904' 0,0,2,3:'\U093C\U0308\U0904' 0,1,2:'\U093C\U0D4E' 0,0,2,3:'\U093C\U0308\U0D4E' + 0,1,2:'\U093C\U0915' 0,0,2,3:'\U093C\U0308\U0915' 0,1,2:'\U093C\U231A' 0,0,2,3:'\U093C\U0308\U231A' 0,0,2:'\U093C\U0300' 0,0,0,3:'\U093C\U0308\U0300' + 0,0,2:'\U093C\U093C' 0,0,0,3:'\U093C\U0308\U093C' 0,0,2:'\U093C\U094D' 0,0,0,3:'\U093C\U0308\U094D' 0,0,2:'\U093C\U200D' 0,0,0,3:'\U093C\U0308\U200D' + 0,1,2:'\U093C\U0378' 0,0,2,3:'\U093C\U0308\U0378' 0,1,2:'\U094D\U0020' 0,0,2,3:'\U094D\U0308\U0020' 0,1,2:'\U094D\U000D' 0,0,2,3:'\U094D\U0308\U000D' + 0,1,2:'\U094D\U000A' 0,0,2,3:'\U094D\U0308\U000A' 0,1,2:'\U094D\U0001' 0,0,2,3:'\U094D\U0308\U0001' 0,0,2:'\U094D\U034F' 0,0,0,3:'\U094D\U0308\U034F' + 0,1,2:'\U094D\U1F1E6' 0,0,2,3:'\U094D\U0308\U1F1E6' 0,1,2:'\U094D\U0600' 0,0,2,3:'\U094D\U0308\U0600' 0,0,2:'\U094D\U0A03' 0,0,0,3:'\U094D\U0308\U0A03' + 0,1,2:'\U094D\U1100' 0,0,2,3:'\U094D\U0308\U1100' 0,1,2:'\U094D\U1160' 0,0,2,3:'\U094D\U0308\U1160' 0,1,2:'\U094D\U11A8' 0,0,2,3:'\U094D\U0308\U11A8' + 0,1,2:'\U094D\UAC00' 0,0,2,3:'\U094D\U0308\UAC00' 0,1,2:'\U094D\UAC01' 0,0,2,3:'\U094D\U0308\UAC01' 0,0,2:'\U094D\U0900' 0,0,0,3:'\U094D\U0308\U0900' + 0,0,2:'\U094D\U0903' 0,0,0,3:'\U094D\U0308\U0903' 0,1,2:'\U094D\U0904' 0,0,2,3:'\U094D\U0308\U0904' 0,1,2:'\U094D\U0D4E' 0,0,2,3:'\U094D\U0308\U0D4E' + 0,1,2:'\U094D\U0915' 0,0,2,3:'\U094D\U0308\U0915' 0,1,2:'\U094D\U231A' 0,0,2,3:'\U094D\U0308\U231A' 0,0,2:'\U094D\U0300' 0,0,0,3:'\U094D\U0308\U0300' + 0,0,2:'\U094D\U093C' 0,0,0,3:'\U094D\U0308\U093C' 0,0,2:'\U094D\U094D' 0,0,0,3:'\U094D\U0308\U094D' 0,0,2:'\U094D\U200D' 0,0,0,3:'\U094D\U0308\U200D' + 0,1,2:'\U094D\U0378' 0,0,2,3:'\U094D\U0308\U0378' 0,1,2:'\U200D\U0020' 0,0,2,3:'\U200D\U0308\U0020' 0,1,2:'\U200D\U000D' 0,0,2,3:'\U200D\U0308\U000D' + 0,1,2:'\U200D\U000A' 0,0,2,3:'\U200D\U0308\U000A' 0,1,2:'\U200D\U0001' 0,0,2,3:'\U200D\U0308\U0001' 0,0,2:'\U200D\U034F' 0,0,0,3:'\U200D\U0308\U034F' + 0,1,2:'\U200D\U1F1E6' 0,0,2,3:'\U200D\U0308\U1F1E6' 0,1,2:'\U200D\U0600' 0,0,2,3:'\U200D\U0308\U0600' 0,0,2:'\U200D\U0A03' 0,0,0,3:'\U200D\U0308\U0A03' + 0,1,2:'\U200D\U1100' 0,0,2,3:'\U200D\U0308\U1100' 0,1,2:'\U200D\U1160' 0,0,2,3:'\U200D\U0308\U1160' 0,1,2:'\U200D\U11A8' 0,0,2,3:'\U200D\U0308\U11A8' + 0,1,2:'\U200D\UAC00' 0,0,2,3:'\U200D\U0308\UAC00' 0,1,2:'\U200D\UAC01' 0,0,2,3:'\U200D\U0308\UAC01' 0,0,2:'\U200D\U0900' 0,0,0,3:'\U200D\U0308\U0900' + 0,0,2:'\U200D\U0903' 0,0,0,3:'\U200D\U0308\U0903' 0,1,2:'\U200D\U0904' 0,0,2,3:'\U200D\U0308\U0904' 0,1,2:'\U200D\U0D4E' 0,0,2,3:'\U200D\U0308\U0D4E' + 0,1,2:'\U200D\U0915' 0,0,2,3:'\U200D\U0308\U0915' 0,1,2:'\U200D\U231A' 0,0,2,3:'\U200D\U0308\U231A' 0,0,2:'\U200D\U0300' 0,0,0,3:'\U200D\U0308\U0300' + 0,0,2:'\U200D\U093C' 0,0,0,3:'\U200D\U0308\U093C' 0,0,2:'\U200D\U094D' 0,0,0,3:'\U200D\U0308\U094D' 0,0,2:'\U200D\U200D' 0,0,0,3:'\U200D\U0308\U200D' + 0,1,2:'\U200D\U0378' 0,0,2,3:'\U200D\U0308\U0378' 0,1,2:'\U0378\U0020' 0,0,2,3:'\U0378\U0308\U0020' 0,1,2:'\U0378\U000D' 0,0,2,3:'\U0378\U0308\U000D' + 0,1,2:'\U0378\U000A' 0,0,2,3:'\U0378\U0308\U000A' 0,1,2:'\U0378\U0001' 0,0,2,3:'\U0378\U0308\U0001' 0,0,2:'\U0378\U034F' 0,0,0,3:'\U0378\U0308\U034F' + 0,1,2:'\U0378\U1F1E6' 0,0,2,3:'\U0378\U0308\U1F1E6' 0,1,2:'\U0378\U0600' 0,0,2,3:'\U0378\U0308\U0600' 0,0,2:'\U0378\U0A03' 0,0,0,3:'\U0378\U0308\U0A03' + 0,1,2:'\U0378\U1100' 0,0,2,3:'\U0378\U0308\U1100' 0,1,2:'\U0378\U1160' 0,0,2,3:'\U0378\U0308\U1160' 0,1,2:'\U0378\U11A8' 0,0,2,3:'\U0378\U0308\U11A8' + 0,1,2:'\U0378\UAC00' 0,0,2,3:'\U0378\U0308\UAC00' 0,1,2:'\U0378\UAC01' 0,0,2,3:'\U0378\U0308\UAC01' 0,0,2:'\U0378\U0900' 0,0,0,3:'\U0378\U0308\U0900' + 0,0,2:'\U0378\U0903' 0,0,0,3:'\U0378\U0308\U0903' 0,1,2:'\U0378\U0904' 0,0,2,3:'\U0378\U0308\U0904' 0,1,2:'\U0378\U0D4E' 0,0,2,3:'\U0378\U0308\U0D4E' + 0,1,2:'\U0378\U0915' 0,0,2,3:'\U0378\U0308\U0915' 0,1,2:'\U0378\U231A' 0,0,2,3:'\U0378\U0308\U231A' 0,0,2:'\U0378\U0300' 0,0,0,3:'\U0378\U0308\U0300' + 0,0,2:'\U0378\U093C' 0,0,0,3:'\U0378\U0308\U093C' 0,0,2:'\U0378\U094D' 0,0,0,3:'\U0378\U0308\U094D' 0,0,2:'\U0378\U200D' 0,0,0,3:'\U0378\U0308\U200D' + 0,1,2:'\U0378\U0378' 0,0,2,3:'\U0378\U0308\U0378' 0,1,2,3,4,5:'\U000D\U000A\U0061\U000A\U0308' 0,0,2:'\U0061\U0308' 0,0,2,3:'\U0020\U200D\U0646' + 0,0,2,3:'\U0646\U200D\U0020' 0,0,2:'\U1100\U1100' 0,0,2,3:'\UAC00\U11A8\U1100' 0,0,2,3:'\UAC01\U11A8\U1100' 0,0,2,3,4:'\U1F1E6\U1F1E7\U1F1E8\U0062' + 0,1,1,3,4,5:'\U0061\U1F1E6\U1F1E7\U1F1E8\U0062' 0,1,1,1,4,5,6:'\U0061\U1F1E6\U1F1E7\U200D\U1F1E8\U0062' + 0,1,1,3,3,5,6:'\U0061\U1F1E6\U200D\U1F1E7\U1F1E8\U0062' 0,1,1,3,3,5,6:'\U0061\U1F1E6\U1F1E7\U1F1E8\U1F1E9\U0062' 0,0,2:'\U0061\U200D' + 0,0,2,3:'\U0061\U0308\U0062' 0,0,2,3:'\U0061\U0903\U0062' 0,1,1,3:'\U0061\U0600\U0062' 0,0,2,3:'\U1F476\U1F3FF\U1F476' 0,0,2,3:'\U0061\U1F3FF\U1F476' + 0,0,2,2,2,5:'\U0061\U1F3FF\U1F476\U200D\U1F6D1' 0,0,0,0,0,0,6:'\U1F476\U1F3FF\U0308\U200D\U1F476\U1F3FF' 0,0,0,3:'\U1F6D1\U200D\U1F6D1' + 0,0,2,3:'\U0061\U200D\U1F6D1' 0,0,0,3:'\U2701\U200D\U2701' 0,0,2,3:'\U0061\U200D\U2701' 0,1,2:'\U0915\U0924' 0,0,0,3:'\U0915\U094D\U0924' + 0,0,0,0,4:'\U0915\U094D\U094D\U0924' 0,0,0,0,4:'\U0915\U094D\U200D\U0924' 0,0,0,0,0,5:'\U0915\U093C\U200D\U094D\U0924' + 0,0,0,0,0,5:'\U0915\U093C\U094D\U200D\U0924' 0,0,0,0,0,5:'\U0915\U094D\U0924\U094D\U092F' 0,0,2,3:'\U0915\U094D\U0061' 0,0,2,3:'\U0061\U094D\U0924' + 0,0,2,3:'\U003F\U094D\U0924' 0,0,0,0,4:'\U0915\U094D\U094D\U0924' + ) + function ble/test:canvas/GraphemeClusterBreak/find-previous-boundary { + local ans=${1%%:*} str=${1#*:} + builtin eval "local s=\$'$str'" + ble/string#split ans , "$ans" + local k=0 b=0 + for k in "${!ans[@]}"; do + ble/test:canvas/GraphemeCluster/.locate-code-point "$s." "$((k+1))"; local i=$ret + ble/test:canvas/GraphemeCluster/.locate-code-point "$s" "${ans[k]}"; local a=$ret + ble/test "ble/unicode/GraphemeCluster/find-previous-boundary \$'$str' $i" ret="$a" + if ((a>b)); then + local ret= c= w= cs= extend= + ble/test "ble/unicode/GraphemeCluster/match \$'$str' $b && ((ret=b+1+extend))" ret="$a" + ((b=a)) + fi + done + } + if ((_ble_bash>=40200)); then + for spec in "${tests_cases[@]}"; do + ble/test:canvas/GraphemeClusterBreak/find-previous-boundary "$spec" + done + fi +) +ble/test/end-section diff --git a/.local/share/blesh/lib/test-complete.sh b/.local/share/blesh/lib/test-complete.sh new file mode 100644 index 0000000..ccdec9b --- /dev/null +++ b/.local/share/blesh/lib/test-complete.sh @@ -0,0 +1,36 @@ +# Copyright 2015 Koichi Murase . All rights reserved. +# This script is a part of blesh (https://github.com/akinomyoga/ble.sh) +# provided under the BSD-3-Clause license. Do not edit this file because this +# is not the original source code: Various pre-processing has been applied. +# Also, the code comments and blank lines are stripped off in the installation +# process. Please find the corresponding source file(s) in the repository +# "akinomyoga/ble.sh". +# +# Source: /lib/test-complete.sh +ble-import lib/core-complete +ble-import lib/core-test +ble/test/start-section 'ble/complete' 7 +( + function _collect { + local text=${args[1]} p0=0 i out= + for ((i=0;i<${#ret[@]};i++)); do + ((p=ret[i])) + if ((i%2==0)); then + out=$out${text:p0:p-p0}'[' + else + out=$out${text:p0:p-p0}']' + fi + p0=$p + done + ((p0<${#text})) && out=$out${text:p0} + ret=$out + } + ble/test 'args=(akf Makefile 0); ble/complete/candidates/filter:hsubseq/match "${args[@]}"; _collect' ret='M[ak]e[f]ile' + ble/test 'args=(akf Makefile 1); ble/complete/candidates/filter:hsubseq/match "${args[@]}"; _collect' ret='Makefile' + ble/test 'args=(Mkf Makefile 1); ble/complete/candidates/filter:hsubseq/match "${args[@]}"; _collect' ret='[M]a[k]e[f]ile' + ble/test 'args=(Maf Makefile 1); ble/complete/candidates/filter:hsubseq/match "${args[@]}"; _collect' ret='[Ma]ke[f]ile' + ble/test 'args=(Mak Makefile 1); ble/complete/candidates/filter:hsubseq/match "${args[@]}"; _collect' ret='[Mak]efile' + ble/test 'args=(ake Makefile 0); ble/complete/candidates/filter:hsubseq/match "${args[@]}"; _collect' ret='M[ake]file' + ble/test 'args=(afe Makefile 0); ble/complete/candidates/filter:hsubseq/match "${args[@]}"; _collect' ret='M[a]ke[f]il[e]' +) +ble/test/end-section diff --git a/.local/share/blesh/lib/test-decode.sh b/.local/share/blesh/lib/test-decode.sh new file mode 100644 index 0000000..89d175b --- /dev/null +++ b/.local/share/blesh/lib/test-decode.sh @@ -0,0 +1,47 @@ +# Copyright 2015 Koichi Murase . All rights reserved. +# This script is a part of blesh (https://github.com/akinomyoga/ble.sh) +# provided under the BSD-3-Clause license. Do not edit this file because this +# is not the original source code: Various pre-processing has been applied. +# Also, the code comments and blank lines are stripped off in the installation +# process. Please find the corresponding source file(s) in the repository +# "akinomyoga/ble.sh". +# +# Source: /lib/test-decode.sh +ble-import lib/core-test +ble/test/start-section 'ble/decode' 33 +( + ble/test 'ble/builtin/bind/.parse-keyname tab ; ret=${chars[0]}' ret=9 + ble/test 'ble/builtin/bind/.parse-keyname TAB ; ret=${chars[0]}' ret=9 + ble/test 'ble/builtin/bind/.parse-keyname newline; ret=${chars[0]}' ret=10 + ble/test 'ble/builtin/bind/.parse-keyname LFD ; ret=${chars[0]}' ret=10 + ble/test 'ble/builtin/bind/.parse-keyname Return ; ret=${chars[0]}' ret=13 + ble/test 'ble/builtin/bind/.parse-keyname RET ; ret=${chars[0]}' ret=13 + ble/test 'ble/builtin/bind/.parse-keyname Space ; ret=${chars[0]}' ret=32 + ble/test 'ble/builtin/bind/.parse-keyname SPC ; ret=${chars[0]}' ret=32 + ble/test 'ble/builtin/bind/.parse-keyname Rubout ; ret=${chars[0]}' ret=127 + ble/test 'ble/builtin/bind/.parse-keyname DEL ; ret=${chars[0]}' ret=127 + ble/test 'ble/builtin/bind/.parse-keyname Escape ; ret=${chars[0]}' ret=27 + ble/test 'ble/builtin/bind/.parse-keyname ESC ; ret=${chars[0]}' ret=27 + ble/test 'ble/builtin/bind/.parse-keyname C-Space; ret=${chars[0]}' ret=0 + ble/test 'ble/builtin/bind/.parse-keyname s ; ret=${chars[0]}' ret=115 + ble/test 'ble/builtin/bind/.parse-keyname S ; ret=${chars[0]}' ret=83 + ble/test "ble/builtin/bind/.parse-keyname '\C-x\C-y' ; ret=\${chars[0]}" ret=25 # C-y + ble/test "ble/builtin/bind/.parse-keyname 'xyz' ; ret=\${chars[0]}" ret=120 # x + ble/test "ble/builtin/bind/.parse-keyname '\a' ; ret=\${chars[0]}" ret=92 # \ (backslash) + ble/test "ble/builtin/bind/.parse-keyname '\C-nop' ; ret=\${chars[0]}" ret=14 # C-n + ble/test "ble/builtin/bind/.parse-keyname '\C-xC-y' ; ret=\${chars[0]}" ret=25 # C-y + ble/test "ble/builtin/bind/.parse-keyname '\C-axC-b' ; ret=\${chars[0]}" ret=2 # C-b + ble/test "ble/builtin/bind/.parse-keyname 'helloC-b' ; ret=\${chars[0]}" ret=2 # C-b + ble/test "ble/builtin/bind/.parse-keyname 'helloC-x,TAB' ; ret=\${chars[0]}" ret=24 # C-x + ble/test "ble/builtin/bind/.parse-keyname 'C-xTAB' ; ret=\${chars[0]}" ret=24 # C-x + ble/test "ble/builtin/bind/.parse-keyname 'TABC-x' ; ret=\${chars[0]}" ret=24 # C-x + ble/test "ble/builtin/bind/.parse-keyname 'BC-' ; ret=\${chars[0]}" ret=0 # C-@ + ble/test "ble/builtin/bind/.parse-keyname 'C-M-a' ; ret=\${chars[0]}" ret=129 # C-M-a + ble/test "ble/builtin/bind/.parse-keyname 'M-C-a' ; ret=\${chars[0]}" ret=129 # C-M-a + ble/test "ble/builtin/bind/.parse-keyname 'C-aalpha-beta'; ret=\${chars[0]}" ret=2 # C-b + ble/test "ble/builtin/bind/.parse-keyname '\C-a\M-c' ; ret=\${chars[0]}" ret=131 # C-M-c + ble/test "ble/builtin/bind/.parse-keyname 'panic-trim-c' ; ret=\${chars[0]}" ret=131 # C-M-c + ble/test "ble/builtin/bind/.parse-keyname 'C--' ; ret=\${chars[0]}" ret=0 # C-@ + ble/test "ble/builtin/bind/.parse-keyname 'C--x' ; ret=\${chars[0]}" ret=24 # C-x +) +ble/test/end-section diff --git a/.local/share/blesh/lib/test-edit.sh b/.local/share/blesh/lib/test-edit.sh new file mode 100644 index 0000000..d68d4db --- /dev/null +++ b/.local/share/blesh/lib/test-edit.sh @@ -0,0 +1,16 @@ +# Copyright 2015 Koichi Murase . All rights reserved. +# This script is a part of blesh (https://github.com/akinomyoga/ble.sh) +# provided under the BSD-3-Clause license. Do not edit this file because this +# is not the original source code: Various pre-processing has been applied. +# Also, the code comments and blank lines are stripped off in the installation +# process. Please find the corresponding source file(s) in the repository +# "akinomyoga/ble.sh". +# +# Source: /lib/test-edit.sh +ble-import lib/core-test +ble/test/start-section 'ble/edit' 2 +( + ble/test "_ble_edit_str=$'echo\nhello\nworld' ble-edit/content/find-logical-eol 13 -1" exit=0 ret=10 + ble/test "_ble_edit_str=$'echo\nhello\nworld' ble-edit/content/find-logical-bol 13 -1" exit=0 ret=5 +) +ble/test/end-section diff --git a/.local/share/blesh/lib/test-keymap.vi.sh b/.local/share/blesh/lib/test-keymap.vi.sh new file mode 100644 index 0000000..c9cad52 --- /dev/null +++ b/.local/share/blesh/lib/test-keymap.vi.sh @@ -0,0 +1,594 @@ +# Copyright 2015 Koichi Murase . All rights reserved. +# This script is a part of blesh (https://github.com/akinomyoga/ble.sh) +# provided under the BSD-3-Clause license. Do not edit this file because this +# is not the original source code: Various pre-processing has been applied. +# Also, the code comments and blank lines are stripped off in the installation +# process. Please find the corresponding source file(s) in the repository +# "akinomyoga/ble.sh". +# +# Source: /lib/test-keymap.vi.sh +ble-import lib/core-test +ble-import lib/keymap.vi +ble-import lib/vim-surround +function ble/keymap:vi_test/decompose-state { + local spec=$1 + ind=${spec%%:*} str=${spec#*:} + if ((${#ind}==1)) && [[ $ind == [!a-zA-Z0-9] ]]; then + ind=${str%%"$ind"*} ind=${#ind} str=${str::ind}${str:ind+1} + mark= + elif ((${#ind}==2)) && [[ ${ind::1} == [!a-zA-Z0-9] && ${ind:1:1} == [!a-zA-Z0-9] ]]; then + local ind1=${ind::1} ind2=${ind:1:1} text + text=${str//"$ind2"} text=${text%%"$ind1"*} ind=${#text} + text=${str//"$ind1"} text=${text%%"$ind2"*} mark=${#text} + str=${str//["$ind"]*} + fi +} +function ble/keymap:vi_test/start-section { + ble/test/start-section "ble/keymap.vi/$1" "$2" +} +function ble/keymap:vi_test/check { + local id=$1 initial=$2 kspecs=$3 final=$4 + local str ind mark + ble/keymap:vi_test/decompose-state "$initial"; local i=$ind in=$str ima=$mark + ble/keymap:vi_test/decompose-state "$final"; local f=$ind fin=$str fma=$mark + local nl=$'\n' nl_rep=$'\e[7m^J\e[27m' + ble-edit/content/reset "$in" edit + _ble_edit_ind=$i + [[ $ima ]] && _ble_edit_mark=$ima + local ret + ble-decode-kbd "$kspecs" + ble/string#split-words ret "$ret" + local ble_decode=${_ble_keymap_vi_test_ble_decode:-ble-decode-key} + "$ble_decode" "${ret[@]}" &>/dev/null + local esc_in=${in//$nl/"$nl_rep"} + local section=${_ble_test_section_title#'ble/keymap.vi/'} + local title="$section/$id i=$i${ima:+ m=$ima} str=$esc_in keys=($kspecs)" + local ind_expect=ind=$f + local ind_result=ind=$_ble_edit_ind + if [[ $fma ]]; then + ind_expect=$ind_expect,mark=$fma + ind_result=$ind_result,mark=$_ble_edit_mark + fi + local str_expect=$fin + local str_result=$_ble_edit_str + ble/test --depth=1 --display-code="$title" ret="$ind_expect" stdout="$str_expect[EOF]" \ + code:'ret=$ind_result; ble/util/put "$str_result[EOF]"' + local ext=$? + case $_ble_decode_keymap in + (vi_[ixo]map) + ble-decode-key "$((_ble_decode_Ctrl|99))" &>/dev/null ;; # C-c + esac + return "$ext" +} +function ble/keymap:vi_test/section:space { + ble/test/start-section "ble/keymap.vi/space" 2 + local str=$' 1234\n567890ab\n' + ble/keymap:vi_test/check 1 "4:$str" '4 SP' "9:$str" + ble/keymap:vi_test/check 2 "4:$str" 'd 4 SP' $'3: \n567890ab\n' + ble/test/end-section +} +function ble/keymap:vi_test/section:cw { + ble/test/start-section "ble/keymap.vi/cw" 30 + ble/keymap:vi_test/check A1 '@:cp ./foo.txt @ /tmp/' 'c w' '@:cp ./foo.txt @/tmp/' + ble/keymap:vi_test/check A2 '@:cp ./foo.tx@t /tmp/' 'c w' '@:cp ./foo.tx@ /tmp/' + ble/keymap:vi_test/check A3 '@:cp ./fo@o.txt /tmp/' 'c w' '@:cp ./fo@.txt /tmp/' + ble/keymap:vi_test/check A4 '@:cp ./foo.t@xt /tmp/' 'c w' '@:cp ./foo.t@ /tmp/' + ble/keymap:vi_test/check A5 '@:cp ./fo@o.txt /tmp/' 'c W' '@:cp ./fo@ /tmp/' + ble/keymap:vi_test/check B1a '@:123@ 456 789' 'c w' '@:123@456 789' + ble/keymap:vi_test/check B1b '@:123@ 456 789' '1 c w' '@:123@456 789' + ble/keymap:vi_test/check B1c '@:123@ 456 789' '2 c w' '@:123@789' + ble/keymap:vi_test/check B2a '@:12@3 456 789' 'c w' '@:12@ 456 789' + ble/keymap:vi_test/check B2b '@:12@3 456 789' '1 c w' '@:12@ 456 789' + ble/keymap:vi_test/check B2c '@:12@3 456 789' '2 c w' '@:12@ 789' + ble/keymap:vi_test/check B3a '@:@123 456 789' 'c w' '@:@ 456 789' + ble/keymap:vi_test/check B3b '@:@123 456 789' '1 c w' '@:@ 456 789' + ble/keymap:vi_test/check B3c '@:@123 456 789' '2 c w' '@:@ 789' + ble/keymap:vi_test/check B4a '@:ab@c///漢字' 'c w' '@:ab@///漢字' + ble/keymap:vi_test/check B4b '@:ab@c///漢字' '1 c w' '@:ab@///漢字' + ble/keymap:vi_test/check B4c '@:ab@c///漢字' '2 c w' '@:ab@漢字' + ble/keymap:vi_test/check B5a '@:@abc///漢字' 'c w' '@:@///漢字' + ble/keymap:vi_test/check B5b '@:@abc///漢字' '1 c w' '@:@///漢字' + ble/keymap:vi_test/check B5c '@:@abc///漢字' '2 c w' '@:@漢字' + ble/keymap:vi_test/check C1 $'@:123 456 @ \n\n789' 'c w' $'@:123 456 @\n\n789' + ble/keymap:vi_test/check C2 $'@:123 456 \n@\n789' 'c w' $'@:123 456 \n@\n789' + ble/keymap:vi_test/check C3 $'@:123 45@6 \n\n789' 'c w' $'@:123 45@ \n\n789' + ble/keymap:vi_test/check C4 $'@:123 456@ \n\n789\nabc' '2 c w' $'@:123 456@\n789\nabc' + ble/keymap:vi_test/check C5 $'@:123 45@6 \n\n789\nabc' '2 c w' $'@:123 45@\nabc' + ble/keymap:vi_test/check C6 $'@:123 4@56 \n\n789\nabc' '2 c w' $'@:123 4@\nabc' + ble/keymap:vi_test/check C7 $'@:123 456@ \n\n\n789\nabc' '2 c w' $'@:123 456@\n\n789\nabc' + ble/keymap:vi_test/check C8 $'@:123 45@6 \n\n\n789\nabc' '2 c w' $'@:123 45@\nabc' + ble/keymap:vi_test/check C9 $'@:123 4@56 \n\n\n789\nabc' '2 c w' $'@:123 4@\nabc' + ble/keymap:vi_test/check C9 $'@:123 456 \n\n@' '2 c w' $'@:123 456 \n\n@' + ble/test/end-section +} +function ble/keymap:vi_test/section:search { + local -a _ble_util_buffer=() + ble/test/start-section "ble/keymap.vi/search" 10 + ble/keymap:vi_test/check A1a '@:ech@o abc abc abc' '/ a b c RET' '@:echo @abc abc abc' + ble/keymap:vi_test/check A1b '@:ech@o abc abc abc' '/ a b c RET n' '@:echo abc @abc abc' + ble/keymap:vi_test/check A1c '@:ech@o abc abc abc' '/ a b c RET 2 n' '@:echo abc abc @abc' + ble/keymap:vi_test/check A1d '@:ech@o abc abc abc' '/ a b c RET 2 n N' '@:echo abc @abc abc' + ble/keymap:vi_test/check A2a '@:echo@ abc abc abc' '/ a b c RET' '@:echo @abc abc abc' + ble/keymap:vi_test/check A2b '@:echo @abc abc abc' '/ a b c RET' '@:echo abc @abc abc' + ble/keymap:vi_test/check A2c '@:echo a@bc abc abc' '/ a b c RET' '@:echo abc @abc abc' + ble/keymap:vi_test/check A3a '@:echo abc@ abc abc' '? a b c RET' '@:echo @abc abc abc' + ble/keymap:vi_test/check A3b '@:echo abc @abc abc' '? a b c RET' '@:echo @abc abc abc' + ble/keymap:vi_test/check A3c '@:echo abc a@bc abc' '? a b c RET' '@:echo abc @abc abc' + ble/test/end-section + ble/textarea#invalidate +} +function ble/keymap:vi_test/section:increment { + ble/test/start-section "ble/keymap.vi/increment" 19 + ble/keymap:vi_test/check A1a '@:@123' 'C-a' '@:12@4' + ble/keymap:vi_test/check A1b '@:@123' 'C-x' '@:12@2' + ble/keymap:vi_test/check A1c '@:@-123' 'C-a' '@:-12@2' + ble/keymap:vi_test/check A1d '@:@-123' 'C-x' '@:-12@4' + ble/keymap:vi_test/check A2a '@:@ -123 0' 'C-a' '@: -12@2 0' + ble/keymap:vi_test/check A2b '@: @-123 0' 'C-a' '@: -12@2 0' + ble/keymap:vi_test/check A2c '@: -@123 0' 'C-a' '@: -12@2 0' + ble/keymap:vi_test/check A2d '@: -1@23 0' 'C-a' '@: -12@2 0' + ble/keymap:vi_test/check A2e '@: -12@3 0' 'C-a' '@: -12@2 0' + ble/keymap:vi_test/check A2f '@: -123@ 0' 'C-a' '@: -123 @1' + ble/keymap:vi_test/check A3a '@:@000' 'C-a' '@:00@1' + ble/keymap:vi_test/check A3b '@:@000' '1 0 C-a' '@:01@0' + ble/keymap:vi_test/check A3c '@:@000' '1 0 0 C-a' '@:10@0' + ble/keymap:vi_test/check A3d '@:@000' 'C-x' '@:-00@1' + ble/keymap:vi_test/check A3e '@:@000' '1 0 C-x' '@:-01@0' + ble/keymap:vi_test/check A3f '@:@000' '1 0 0 C-x' '@:-10@0' + ble/keymap:vi_test/check A3g '@:@099' '1 0 0 C-x' '@:-00@1' + ble/keymap:vi_test/check A3h '@:@099' '9 9 C-x' '@:00@0' + ble/keymap:vi_test/check A4a '@:-@0' 'C-a' '@:@1' + ble/test/end-section +} +function ble/keymap:vi_test/section:macro { + local _ble_decode_keylog_depth=0 + local _ble_keymap_vi_test_ble_decode=ble-decode-char + local ble_decode_char_sync=1 + ble/function#push ble/util/is-stdin-ready '((0))' + ble/test/start-section "ble/keymap.vi/macro" 1 + ble/keymap:vi_test/check A1 '@:@123' 'q a A SP h e l l o @ESC q @ a' '@:123 hello hell@o' + ble/test/end-section + ble/function#pop ble/util/is-stdin-ready +} +function ble/keymap:vi_test/section:surround { + ble/test/start-section "ble/keymap.vi/surround" 7 + ble/keymap:vi_test/check A1a '@:abcd @fghi jklm nopq' 'y s e a' '@:abcd @ jklm nopq' + ble/keymap:vi_test/check A1b '@:abcd @fghi jklm nopq' 'y s w a' '@:abcd @ jklm nopq' + ble/keymap:vi_test/check A1c '@:abcd @fghi jklm nopq' 'y s a w a' '@:abcd @ jklm nopq' + ble/keymap:vi_test/check A1d '@:abcd @ jklm nopq' 'y s 3 l a' '@:abcd @<> jklm nopq' + ble/keymap:vi_test/check A2a '@:abcd @fghi jklm nopq' 'v 3 l S a' '@:abcd @ jklm nopq' + ble/keymap:vi_test/check A2b '@:abcd @fghi jklm nopq' 'v 4 l S a' '@:abcd @jklm nopq' + ble/keymap:vi_test/check A2c '@:abcd @fghi jklm nopq' 'h v 5 l S a' '@:abcd@< fghi >jklm nopq' + ble/test/end-section +} +function ble/keymap:vi_test/section:txtobj_quote_xmap { + ble/test/start-section "ble/keymap.vi/txtobj_quote_xmap" 45 + ble/keymap:vi_test/check A1a '@:ab@cd " fghi " jklm " nopq " rstu " vwxyz' 'v i " S a' '@:abcd "@< fghi >" jklm " nopq " rstu " vwxyz' + ble/keymap:vi_test/check A1b '@:abcd @" fghi " jklm " nopq " rstu " vwxyz' 'v i " S a' '@:abcd "@< fghi >" jklm " nopq " rstu " vwxyz' + ble/keymap:vi_test/check A1c '@:abcd " fghi@ " jklm " nopq " rstu " vwxyz' 'v i " S a' '@:abcd "@< fghi >" jklm " nopq " rstu " vwxyz' + ble/keymap:vi_test/check A1d '@:abcd " fghi @" jklm " nopq " rstu " vwxyz' 'v i " S a' '@:abcd "@< fghi >" jklm " nopq " rstu " vwxyz' + ble/keymap:vi_test/check A2a '@:ab@cd " fghi " jklm " nopq " rstu " vwxyz' 'v 2 i " S a' '@:abcd @<" fghi "> jklm " nopq " rstu " vwxyz' + ble/keymap:vi_test/check A2b '@:ab@cd " fghi " jklm " nopq " rstu " vwxyz' 'v a " S a' '@:abcd @<" fghi " >jklm " nopq " rstu " vwxyz' + ble/keymap:vi_test/check A2c '@:ab@cd " fghi " jklm " nopq " rstu " vwxyz' 'v 2 a " S a' '@:abcd @<" fghi " >jklm " nopq " rstu " vwxyz' + ble/keymap:vi_test/check A3a '@:ab@cd "" jklm " nopq " rstu " vwxyz' 'v i " S a' '@:abcd @<""> jklm " nopq " rstu " vwxyz' + ble/keymap:vi_test/check A3b '@:ab@cd "" jklm " nopq " rstu " vwxyz' 'v 2 i " S a' '@:abcd @<""> jklm " nopq " rstu " vwxyz' + ble/keymap:vi_test/check B1a '@:abcd@ " fghi " jklm " nopq " rstu " vwxyz' 'v l i " S a' '@:abcd@< " fghi " jklm >" nopq " rstu " vwxyz' + ble/keymap:vi_test/check B1b '@:abcd " fghi " jklm " nopq@ " rstu " vwxyz' 'v l i " S a' '@:abcd " fghi " jklm " nopq@< " rstu >" vwxyz' + ble/keymap:vi_test/check B1c '@:abc@d " fghi " jklm " nopq " rstu " vwxyz' 'v l i " S a' '@:abcd "@< fghi >" jklm " nopq " rstu " vwxyz' + ble/keymap:vi_test/check B1d '@:abcd " fgh@i " jklm " nopq " rstu " vwxyz' 'v l i " S a' '@:abcd "@< fghi >" jklm " nopq " rstu " vwxyz' + ble/keymap:vi_test/check B1e '@:abcd " fghi " @jklm " nopq " rstu " vwxyz' 'v l i " S a' '@:abcd " fghi " jklm "@< nopq >" rstu " vwxyz' + ble/keymap:vi_test/check B1f '@:abcd " fghi "@ jklm " nopq " rstu " vwxyz' 'v l i " S a' '@:abcd " fghi "@< jklm " nopq >" rstu " vwxyz' + ble/keymap:vi_test/check B2a '@:abcd@ " fghi " jklm " nopq " rstu " vwxyz' 'v l 2 i " S a' '@:abcd@< " fghi " jklm "> nopq " rstu " vwxyz' + ble/keymap:vi_test/check B2b '@:abcd " fghi " jklm " nopq@ " rstu " vwxyz' 'v l 2 i " S a' '@:abcd " fghi " jklm " nopq@< " rstu "> vwxyz' + ble/keymap:vi_test/check B2c '@:abc@d " fghi " jklm " nopq " rstu " vwxyz' 'v l 2 i " S a' '@:abcd @<" fghi "> jklm " nopq " rstu " vwxyz' + ble/keymap:vi_test/check B2d '@:abcd " fgh@i " jklm " nopq " rstu " vwxyz' 'v l 2 i " S a' '@:abcd @<" fghi "> jklm " nopq " rstu " vwxyz' + ble/keymap:vi_test/check B2e '@:abcd " fghi " @jklm " nopq " rstu " vwxyz' 'v l 2 i " S a' '@:abcd " fghi " jklm @<" nopq "> rstu " vwxyz' + ble/keymap:vi_test/check B2f '@:abcd " fghi "@ jklm " nopq " rstu " vwxyz' 'v l 2 i " S a' '@:abcd " fghi "@< jklm " nopq "> rstu " vwxyz' + ble/keymap:vi_test/check B3a '@:abcd@ " fghi " jklm " nopq " rstu " vwxyz' 'v l a " S a' '@:abcd@< " fghi " jklm " >nopq " rstu " vwxyz' + ble/keymap:vi_test/check B3b '@:abcd " fghi " jklm " nopq@ " rstu " vwxyz' 'v l a " S a' '@:abcd " fghi " jklm " nopq@< " rstu " >vwxyz' + ble/keymap:vi_test/check B3c '@:abc@d " fghi " jklm " nopq " rstu " vwxyz' 'v l a " S a' '@:abcd @<" fghi " >jklm " nopq " rstu " vwxyz' + ble/keymap:vi_test/check B3d '@:abcd " fgh@i " jklm " nopq " rstu " vwxyz' 'v l a " S a' '@:abcd @<" fghi " >jklm " nopq " rstu " vwxyz' + ble/keymap:vi_test/check B3e '@:abcd " fghi " @jklm " nopq " rstu " vwxyz' 'v l a " S a' '@:abcd " fghi " jklm @<" nopq " >rstu " vwxyz' + ble/keymap:vi_test/check B3f '@:abcd " fghi "@ jklm " nopq " rstu " vwxyz' 'v l a " S a' '@:abcd " fghi "@< jklm " nopq " >rstu " vwxyz' + ble/keymap:vi_test/check C1a '@:abc@d " fghi " jklm " nopq " rstu " vwxyz' 'v h i " S a' '@:ab@ " fghi " jklm " nopq " rstu " vwxyz' + ble/keymap:vi_test/check C1b '@:abcd " @fghi " jklm " nopq " rstu " vwxyz' 'v h i " S a' '@:abcd "@< fghi >" jklm " nopq " rstu " vwxyz' + ble/keymap:vi_test/check C1c '@:abcd " fghi@ " jklm " nopq " rstu " vwxyz' 'v h i " S a' '@:abcd "@< fghi >" jklm " nopq " rstu " vwxyz' + ble/keymap:vi_test/check C1d '@:abcd " fghi @" jklm " nopq " rstu " vwxyz' 'v h i " S a' '@:abcd "@< fghi "> jklm " nopq " rstu " vwxyz' + ble/keymap:vi_test/check C1e '@:abcd " fghi " jkl@m " nopq " rstu " vwxyz' 'v h i " S a' '@:abcd "@< fghi >" jklm " nopq " rstu " vwxyz' + ble/keymap:vi_test/check C1f '@:abcd " fghi " jkl@m " nopq " rstu " vwxyz' 'v 5 h i " S a' '@:abcd "@< fghi " jklm> " nopq " rstu " vwxyz' + ble/keymap:vi_test/check C2a '@:abc@d " fghi " jklm " nopq " rstu " vwxyz' 'v h 2 i " S a' '@:ab@ " fghi " jklm " nopq " rstu " vwxyz' + ble/keymap:vi_test/check C2b '@:abcd " @fghi " jklm " nopq " rstu " vwxyz' 'v h 2 i " S a' '@:abcd @<" fghi "> jklm " nopq " rstu " vwxyz' + ble/keymap:vi_test/check C2c '@:abcd " fghi@ " jklm " nopq " rstu " vwxyz' 'v h 2 i " S a' '@:abcd @<" fghi >" jklm " nopq " rstu " vwxyz' + ble/keymap:vi_test/check C2d '@:abcd " fghi @" jklm " nopq " rstu " vwxyz' 'v h 2 i " S a' '@:abcd @<" fghi "> jklm " nopq " rstu " vwxyz' + ble/keymap:vi_test/check C2e '@:abcd " fghi " jkl@m " nopq " rstu " vwxyz' 'v h 2 i " S a' '@:abcd @<" fghi "> jklm " nopq " rstu " vwxyz' + ble/keymap:vi_test/check C2f '@:abcd " fghi " jkl@m " nopq " rstu " vwxyz' 'v 5 h 2 i " S a' '@:abcd @<" fghi " jklm> " nopq " rstu " vwxyz' + ble/keymap:vi_test/check C3a '@:abc@d " fghi " jklm " nopq " rstu " vwxyz' 'v h a " S a' '@:ab@ " fghi " jklm " nopq " rstu " vwxyz' + ble/keymap:vi_test/check C3b '@:abcd " @fghi " jklm " nopq " rstu " vwxyz' 'v h a " S a' '@:abcd @<" fghi " >jklm " nopq " rstu " vwxyz' + ble/keymap:vi_test/check C3c '@:abcd " fghi@ " jklm " nopq " rstu " vwxyz' 'v h a " S a' '@:abcd @<" fghi >" jklm " nopq " rstu " vwxyz' + ble/keymap:vi_test/check C3d '@:abcd " fghi @" jklm " nopq " rstu " vwxyz' 'v h a " S a' '@:abcd @<" fghi "> jklm " nopq " rstu " vwxyz' + ble/keymap:vi_test/check C3e '@:abcd " fghi " jkl@m " nopq " rstu " vwxyz' 'v h a " S a' '@:abcd @<" fghi " >jklm " nopq " rstu " vwxyz' + ble/keymap:vi_test/check C3f '@:abcd " fghi " jkl@m " nopq " rstu " vwxyz' 'v 5 h a " S a' '@:abcd @<" fghi " jklm> " nopq " rstu " vwxyz' + ble/test/end-section +} +function ble/keymap:vi_test/section:txtobj_block_omap { + ble/test/start-section "ble/keymap.vi/txtobj_block_omap" 41 + ble/keymap:vi_test/check A1a '@:echo @foo ( bar ) baz (hello) world (vim) xxxx' 'd i b' '@:echo foo (@) baz (hello) world (vim) xxxx' + ble/keymap:vi_test/check A1b '@:echo foo@ ( bar ) baz (hello) world (vim) xxxx' 'd i b' '@:echo foo (@) baz (hello) world (vim) xxxx' + ble/keymap:vi_test/check A1c '@:echo foo @( bar ) baz (hello) world (vim) xxxx' 'd i b' '@:echo foo (@) baz (hello) world (vim) xxxx' + ble/keymap:vi_test/check A1d '@:echo foo (@ bar ) baz (hello) world (vim) xxxx' 'd i b' '@:echo foo (@) baz (hello) world (vim) xxxx' + ble/keymap:vi_test/check A1e '@:echo foo ( @bar ) baz (hello) world (vim) xxxx' 'd i b' '@:echo foo (@) baz (hello) world (vim) xxxx' + ble/keymap:vi_test/check A1f '@:echo foo ( bar@ ) baz (hello) world (vim) xxxx' 'd i b' '@:echo foo (@) baz (hello) world (vim) xxxx' + ble/keymap:vi_test/check A1g '@:echo foo ( bar @) baz (hello) world (vim) xxxx' 'd i b' '@:echo foo (@) baz (hello) world (vim) xxxx' + ble/keymap:vi_test/check A1h '@:echo foo ( bar )@ baz (hello) world (vim) xxxx' 'd i b' '@:echo foo ( bar ) baz (@) world (vim) xxxx' + ble/keymap:vi_test/check A1i '@:echo foo ( bar ) @baz (hello) world (vim) xxxx' 'd i b' '@:echo foo ( bar ) baz (@) world (vim) xxxx' + ble/keymap:vi_test/check A1i '@:echo foo ( bar ) baz (hello) world (vim@) xxxx' 'd i b' '@:echo foo ( bar ) baz (hello) world (@) xxxx' + ble/keymap:vi_test/check A1i '@:echo foo ( bar ) baz (hello) world (vim)@ xxxx' 'd i b' '@:echo foo ( bar ) baz (hello) world (vim)@ xxxx' + ble/keymap:vi_test/check A1i '@:echo foo ( bar ) baz (hello) world (vim) @xxxx' 'd i b' '@:echo foo ( bar ) baz (hello) world (vim) @xxxx' + ble/keymap:vi_test/check B1a '@:echo ( @foo ( bar ) baz (hello) world (vim) ) xxxx' 'd i b' '@:echo (@) xxxx' + ble/keymap:vi_test/check B1b '@:echo ( foo @( bar ) baz (hello) world (vim) ) xxxx' 'd i b' '@:echo ( foo (@) baz (hello) world (vim) ) xxxx' + ble/keymap:vi_test/check B1c '@:echo ( foo ( @bar ) baz (hello) world (vim) ) xxxx' 'd i b' '@:echo ( foo (@) baz (hello) world (vim) ) xxxx' + ble/keymap:vi_test/check B1d '@:echo ( foo ( bar @) baz (hello) world (vim) ) xxxx' 'd i b' '@:echo ( foo (@) baz (hello) world (vim) ) xxxx' + ble/keymap:vi_test/check B1e '@:echo ( foo ( bar )@ baz (hello) world (vim) ) xxxx' 'd i b' '@:echo (@) xxxx' + ble/keymap:vi_test/check B1f '@:echo ( foo ( bar ) baz@ (hello) world (vim) ) xxxx' 'd i b' '@:echo (@) xxxx' + ble/keymap:vi_test/check B1g '@:echo ( foo ( bar ) baz @(hello) world (vim) ) xxxx' 'd i b' '@:echo ( foo ( bar ) baz (@) world (vim) ) xxxx' + ble/keymap:vi_test/check B2a '@:echo ( @foo ( bar ) baz (hello) world (vim) ) xxxx' 'd 2 i b' '@:echo ( @foo ( bar ) baz (hello) world (vim) ) xxxx' + ble/keymap:vi_test/check B2b '@:echo ( foo @( bar ) baz (hello) world (vim) ) xxxx' 'd 2 i b' '@:echo (@) xxxx' + ble/keymap:vi_test/check B2c '@:echo ( foo ( @bar ) baz (hello) world (vim) ) xxxx' 'd 2 i b' '@:echo (@) xxxx' + ble/keymap:vi_test/check B2d '@:echo ( foo ( bar @) baz (hello) world (vim) ) xxxx' 'd 2 i b' '@:echo (@) xxxx' + ble/keymap:vi_test/check B2e '@:echo ( foo ( bar )@ baz (hello) world (vim) ) xxxx' 'd 2 i b' '@:echo ( foo ( bar )@ baz (hello) world (vim) ) xxxx' + ble/keymap:vi_test/check B2f '@:echo ( foo ( bar ) baz@ (hello) world (vim) ) xxxx' 'd 2 i b' '@:echo ( foo ( bar ) baz@ (hello) world (vim) ) xxxx' + ble/keymap:vi_test/check B2g '@:echo ( foo ( bar ) baz @(hello) world (vim) ) xxxx' 'd 2 i b' '@:echo (@) xxxx' + ble/keymap:vi_test/check C1a '@:echo ( @foo ( bar ) baz (hello) world (vim) xxxx' 'd i b' '@:echo ( @foo ( bar ) baz (hello) world (vim) xxxx' + ble/keymap:vi_test/check C1b '@:echo ( foo (@ bar ) baz (hello) world (vim) xxxx' 'd i b' '@:echo ( foo (@) baz (hello) world (vim) xxxx' + ble/keymap:vi_test/check C2a '@:echo @foo ( bar ) baz (hello) world (vim) ) xxxx' 'd i b' '@:echo foo (@) baz (hello) world (vim) ) xxxx' + ble/keymap:vi_test/check C2b '@:echo foo (@ bar ) baz (hello) world (vim) ) xxxx' 'd i b' '@:echo foo (@) baz (hello) world (vim) ) xxxx' + ble/keymap:vi_test/check D1a '@:echo @vim) test ( quick ) world ( foo )' 'd i b' '@:echo @vim) test ( quick ) world ( foo )' + ble/keymap:vi_test/check D1a '@:echo vi@m) test ( quick ) world ( foo )' 'd i b' '@:echo vi@m) test ( quick ) world ( foo )' + ble/keymap:vi_test/check D1a '@:echo vim@) test ( quick ) world ( foo )' 'd i b' '@:echo vim) test (@) world ( foo )' + ble/keymap:vi_test/check D1a '@:echo vim) @test ( quick ) world ( foo )' 'd i b' '@:echo vim) test (@) world ( foo )' + ble/keymap:vi_test/check D1a '@:echo vim) test @( quick ) world ( foo )' 'd i b' '@:echo vim) test (@) world ( foo )' + ble/keymap:vi_test/check E1a '@:echo @foo () bar' 'd i b' '@:echo foo (@) bar' + ble/keymap:vi_test/check E1b '@:echo foo @() bar' 'd i b' '@:echo foo (@) bar' + ble/keymap:vi_test/check E1c '@:echo foo (@) bar' 'd i b' '@:echo foo (@) bar' + ble/keymap:vi_test/check E1d '@:echo @foo () bar' 'd a b' '@:echo foo @ bar' + ble/keymap:vi_test/check E1e '@:echo foo @() bar' 'd a b' '@:echo foo @ bar' + ble/keymap:vi_test/check E1f '@:echo foo (@) bar' 'd a b' '@:echo foo @ bar' + ble/test/end-section +} +function ble/keymap:vi_test/section:txtobj_block_xmap { + ble/test/start-section "ble/keymap.vi/txtobj_block_xmap" 145 + ble/keymap:vi_test/check A1a '@:echo @( foo ) bar ( baz ) hello ( vim ) world' 'v i b S a' '@:echo (@< foo >) bar ( baz ) hello ( vim ) world' + ble/keymap:vi_test/check A1b '@:echo ( @foo ) bar ( baz ) hello ( vim ) world' 'v i b S a' '@:echo (@< foo >) bar ( baz ) hello ( vim ) world' + ble/keymap:vi_test/check A1c '@:echo ( foo @) bar ( baz ) hello ( vim ) world' 'v i b S a' '@:echo (@< foo >) bar ( baz ) hello ( vim ) world' + ble/keymap:vi_test/check A1d '@:echo ( foo ) @bar ( baz ) hello ( vim ) world' 'v i b S a' '@:echo ( foo ) bar (@< baz >) hello ( vim ) world' + ble/keymap:vi_test/check A1e '@:echo ( foo ) bar ( baz ) hello ( vim ) @world' 'v i b S a' '@:echo ( foo ) bar ( baz ) hello ( vim ) @orld' + ble/keymap:vi_test/check B1a '@:echo ( @( foo ) bar ( baz ) hello ) ( vim ) world' 'v i b S a' '@:echo ( (@< foo >) bar ( baz ) hello ) ( vim ) world' + ble/keymap:vi_test/check B1b '@:echo ( @( foo ) bar ( baz ) hello ) ( vim ) world' 'v 1 i b S a' '@:echo ( (@< foo >) bar ( baz ) hello ) ( vim ) world' + ble/keymap:vi_test/check B1c '@:echo ( @( foo ) bar ( baz ) hello ) ( vim ) world' 'v 2 i b S a' '@:echo (@< ( foo ) bar ( baz ) hello >) ( vim ) world' + ble/keymap:vi_test/check B1d '@:echo ( @( foo ) bar ( baz ) hello ) ( vim ) world' 'v 3 i b S a' '@:echo ( @<(> foo ) bar ( baz ) hello ) ( vim ) world' + ble/keymap:vi_test/check B2a '@:echo ( ( @foo ) bar ( baz ) hello ) ( vim ) world' 'v i b S a' '@:echo ( (@< foo >) bar ( baz ) hello ) ( vim ) world' + ble/keymap:vi_test/check B2b '@:echo ( ( @foo ) bar ( baz ) hello ) ( vim ) world' 'v 1 i b S a' '@:echo ( (@< foo >) bar ( baz ) hello ) ( vim ) world' + ble/keymap:vi_test/check B2c '@:echo ( ( @foo ) bar ( baz ) hello ) ( vim ) world' 'v 2 i b S a' '@:echo (@< ( foo ) bar ( baz ) hello >) ( vim ) world' + ble/keymap:vi_test/check B2d '@:echo ( ( @foo ) bar ( baz ) hello ) ( vim ) world' 'v 3 i b S a' '@:echo ( ( @oo ) bar ( baz ) hello ) ( vim ) world' + ble/keymap:vi_test/check B3a '@:echo ( ( foo @) bar ( baz ) hello ) ( vim ) world' 'v i b S a' '@:echo ( (@< foo >) bar ( baz ) hello ) ( vim ) world' + ble/keymap:vi_test/check B3b '@:echo ( ( foo @) bar ( baz ) hello ) ( vim ) world' 'v 1 i b S a' '@:echo ( (@< foo >) bar ( baz ) hello ) ( vim ) world' + ble/keymap:vi_test/check B3c '@:echo ( ( foo @) bar ( baz ) hello ) ( vim ) world' 'v 2 i b S a' '@:echo (@< ( foo ) bar ( baz ) hello >) ( vim ) world' + ble/keymap:vi_test/check B3d '@:echo ( ( foo @) bar ( baz ) hello ) ( vim ) world' 'v 3 i b S a' '@:echo ( ( foo @<)> bar ( baz ) hello ) ( vim ) world' + ble/keymap:vi_test/check B4a '@:echo ( ( foo ) @bar ( baz ) hello ) ( vim ) world' 'v i b S a' '@:echo (@< ( foo ) bar ( baz ) hello >) ( vim ) world' + ble/keymap:vi_test/check B4b '@:echo ( ( foo ) @bar ( baz ) hello ) ( vim ) world' 'v 1 i b S a' '@:echo (@< ( foo ) bar ( baz ) hello >) ( vim ) world' + ble/keymap:vi_test/check B4c '@:echo ( ( foo ) @bar ( baz ) hello ) ( vim ) world' 'v 2 i b S a' '@:echo ( ( foo ) @ar ( baz ) hello ) ( vim ) world' + ble/keymap:vi_test/check C1a '@:echo ( ( @foo ) bar ( baz ) hello' 'v i b S a' '@:echo ( (@< foo >) bar ( baz ) hello' + ble/keymap:vi_test/check C1b '@:echo ( ( foo ) @bar ( baz ) hello' 'v i b S a' '@:echo ( ( foo ) @ar ( baz ) hello' + ble/keymap:vi_test/check D1a '@:echo ( @foo bar' 'v i b S a' '@:echo ( @oo bar' + ble/keymap:vi_test/check E1a '@:echo (vim) test ( quick ) world ( @foo bar' 'v i b S a' '@:echo (vim) test ( quick ) world ( @oo bar' + ble/keymap:vi_test/check E1b '@:echo (vim) test ( quick ) @world ( foo bar' 'v i b S a' '@:echo (vim) test ( quick ) @orld ( foo bar' + ble/keymap:vi_test/check E1c '@:echo (vim) test ( @quick ) world ( foo bar' 'v i b S a' '@:echo (vim) test (@< quick >) world ( foo bar' + ble/keymap:vi_test/check E1d '@:echo (vim) @test ( quick ) world ( foo bar' 'v i b S a' '@:echo (vim) test (@< quick >) world ( foo bar' + ble/keymap:vi_test/check E1e '@:echo (@vim) test ( quick ) world ( foo bar' 'v i b S a' '@:echo (@) test ( quick ) world ( foo bar' + ble/keymap:vi_test/check F1a '@:echo @vim) test ( quick ) world ( foo )' 'v i b S a' '@:echo @im) test ( quick ) world ( foo )' + ble/keymap:vi_test/check F1b '@:echo vim@) test ( quick ) world ( foo )' 'v i b S a' '@:echo vim) test (@< quick >) world ( foo )' + ble/keymap:vi_test/check F1c '@:echo vim) @test ( quick ) world ( foo )' 'v i b S a' '@:echo vim) test (@< quick >) world ( foo )' + ble/keymap:vi_test/check F1d '@:echo vim) test @( quick ) world ( foo )' 'v i b S a' '@:echo vim) test (@< quick >) world ( foo )' + ble/keymap:vi_test/check F1e '@:echo vim) test ( quick ) @world ( foo )' 'v i b S a' '@:echo vim) test ( quick ) world (@< foo >)' + ble/keymap:vi_test/check G1a '@:echo @foo () (bar)' 'v i b S a' '@:echo foo @<()> (bar)' + ble/keymap:vi_test/check G1b '@:echo foo @() (bar)' 'v i b S a' '@:echo foo @<(>) (bar)' + ble/keymap:vi_test/check G1c '@:echo foo (@) (bar)' 'v i b S a' '@:echo foo (@<)> (bar)' + ble/keymap:vi_test/check G2a '@:echo @foo () (bar)' 'v a b S a' '@:echo foo @<()> (bar)' + ble/keymap:vi_test/check G2b '@:echo foo @() (bar)' 'v a b S a' '@:echo foo @<(>) (bar)' + ble/keymap:vi_test/check G2c '@:echo foo (@) (bar)' 'v a b S a' '@:echo foo (@<)> (bar)' + ble/keymap:vi_test/check G3a '@:echo @foo () (bar)' 'v i b h S a' '@:echo foo@< ()> (bar)' + ble/keymap:vi_test/check G3b '@:echo @foo () (bar)' 'v a b l S a' '@:echo foo @<() >(bar)' + ble/keymap:vi_test/check H1a $'@:echo (\nhello @world\n)' 'v i b S a' $'@:echo (\n@)' + ble/keymap:vi_test/check H2a $'@:echo (\nhello @world\n\n)' 'v i b S a' $'@:echo (\n@)' + ble/keymap:vi_test/check I1a '@:echo @foo ( bar ) baz (hello) vim (world) this' 'v 1 l i b S a' '@:echo foo (@< bar >) baz (hello) vim (world) this' + ble/keymap:vi_test/check I1b '@:echo @foo ( bar ) baz (hello) vim (world) this' 'v 4 l i b S a' '@:echo foo (@< bar >) baz (hello) vim (world) this' + ble/keymap:vi_test/check I1c '@:echo @foo ( bar ) baz (hello) vim (world) this' 'v 6 l i b S a' '@:echo foo (@< bar >) baz (hello) vim (world) this' + ble/keymap:vi_test/check I1d '@:echo @foo ( bar ) baz (hello) vim (world) this' 'v 9 l i b S a' '@:echo @) baz (hello) vim (world) this' + ble/keymap:vi_test/check I1e '@:echo @foo ( bar ) baz (hello) vim (world) this' 'v 1 0 l i b S a' '@:echo @ baz (hello) vim (world) this' + ble/keymap:vi_test/check I1f '@:echo @foo ( bar ) baz (hello) vim (world) this' 'v 1 2 l i b S a' '@:echo @az (hello) vim (world) this' + ble/keymap:vi_test/check I1g '@:echo @foo ( bar ) baz (hello) vim (world) this' 'v 1 6 l i b S a' '@:echo @hello) vim (world) this' + ble/keymap:vi_test/check I1h '@:echo @foo ( bar ) baz (hello) vim (world) this' 'v 1 8 l i b S a' '@:echo @llo) vim (world) this' + ble/keymap:vi_test/check I2a '@:echo foo @( bar ) baz (hello) vim (world) this' 'v 1 l i b S a' '@:echo foo @<( >bar ) baz (hello) vim (world) this' + ble/keymap:vi_test/check I2b '@:echo foo @( bar ) baz (hello) vim (world) this' 'v 2 l i b S a' '@:echo foo @<( b>ar ) baz (hello) vim (world) this' + ble/keymap:vi_test/check I2c '@:echo foo @( bar ) baz (hello) vim (world) this' 'v 6 l i b S a' '@:echo foo @<( bar )> baz (hello) vim (world) this' + ble/keymap:vi_test/check I2d '@:echo foo @( bar ) baz (hello) vim (world) this' 'v 8 l i b S a' '@:echo foo @<( bar ) b>az (hello) vim (world) this' + ble/keymap:vi_test/check I2e '@:echo foo @( bar ) baz (hello) vim (world) this' 'v 1 2 l i b S a' '@:echo foo @<( bar ) baz (>hello) vim (world) this' + ble/keymap:vi_test/check I2f '@:echo foo @( bar ) baz (hello) vim (world) this' 'v 1 4 l i b S a' '@:echo foo @<( bar ) baz (he>llo) vim (world) this' + ble/keymap:vi_test/check I2g '@:echo foo @( bar ) baz (hello) vim (world) this' 'v 2 0 l i b S a' '@:echo foo @<( bar ) baz (hello) v>im (world) this' + ble/keymap:vi_test/check I3a '@:echo foo (@ bar ) baz (hello) vim (world) this' 'v 1 l i b S a' '@:echo foo (@< bar >) baz (hello) vim (world) this' + ble/keymap:vi_test/check I3b '@:echo foo (@ bar ) baz (hello) vim (world) this' 'v 4 l i b S a' '@:echo foo (@< bar >) baz (hello) vim (world) this' + ble/keymap:vi_test/check I3c '@:echo foo (@ bar ) baz (hello) vim (world) this' 'v 6 l i b S a' '@:echo foo (@< bar >) baz (hello) vim (world) this' + ble/keymap:vi_test/check I3d '@:echo foo (@ bar ) baz (hello) vim (world) this' 'v 1 0 l i b S a' '@:echo foo (@< bar >) baz (hello) vim (world) this' + ble/keymap:vi_test/check I3e '@:echo foo (@ bar ) baz (hello) vim (world) this' 'v 1 2 l i b S a' '@:echo foo (@< bar >) baz (hello) vim (world) this' + ble/keymap:vi_test/check I3f '@:echo foo (@ bar ) baz (hello) vim (world) this' 'v 1 6 l i b S a' '@:echo foo (@< bar >) baz (hello) vim (world) this' + ble/keymap:vi_test/check I3g '@:echo foo (@ bar ) baz (hello) vim (world) this' 'v 1 8 l i b S a' '@:echo foo (@< bar >) baz (hello) vim (world) this' + ble/keymap:vi_test/check I4a '@:echo foo ( @bar ) baz (hello) vim (world) this' 'v 1 l i b S a' '@:echo foo (@< bar >) baz (hello) vim (world) this' + ble/keymap:vi_test/check I4b '@:echo foo ( @bar ) baz (hello) vim (world) this' 'v 4 l i b S a' '@:echo foo (@< bar >) baz (hello) vim (world) this' + ble/keymap:vi_test/check I4c '@:echo foo ( @bar ) baz (hello) vim (world) this' 'v 6 l i b S a' '@:echo foo (@< bar >) baz (hello) vim (world) this' + ble/keymap:vi_test/check I4d '@:echo foo ( @bar ) baz (hello) vim (world) this' 'v 1 0 l i b S a' '@:echo foo (@< bar >) baz (hello) vim (world) this' + ble/keymap:vi_test/check I4e '@:echo foo ( @bar ) baz (hello) vim (world) this' 'v 1 2 l i b S a' '@:echo foo (@< bar >) baz (hello) vim (world) this' + ble/keymap:vi_test/check I4f '@:echo foo ( @bar ) baz (hello) vim (world) this' 'v 1 6 l i b S a' '@:echo foo (@< bar >) baz (hello) vim (world) this' + ble/keymap:vi_test/check I4g '@:echo foo ( @bar ) baz (hello) vim (world) this' 'v 1 8 l i b S a' '@:echo foo (@< bar >) baz (hello) vim (world) this' + ble/keymap:vi_test/check I5a '@:echo @foo ( bar ) baz (hello) vim (world) this' 'v 1 l a b S a' '@:echo foo @<( bar )> baz (hello) vim (world) this' + ble/keymap:vi_test/check I5b '@:echo @foo ( bar ) baz (hello) vim (world) this' 'v 4 l a b S a' '@:echo foo @<( bar )> baz (hello) vim (world) this' + ble/keymap:vi_test/check I5c '@:echo @foo ( bar ) baz (hello) vim (world) this' 'v 6 l a b S a' '@:echo foo @<( bar )> baz (hello) vim (world) this' + ble/keymap:vi_test/check I5d '@:echo @foo ( bar ) baz (hello) vim (world) this' 'v 9 l a b S a' '@:echo foo @<( bar )> baz (hello) vim (world) this' + ble/keymap:vi_test/check I5e '@:echo @foo ( bar ) baz (hello) vim (world) this' 'v 1 0 l a b S a' '@:echo foo @<( bar )> baz (hello) vim (world) this' + ble/keymap:vi_test/check I5f '@:echo @foo ( bar ) baz (hello) vim (world) this' 'v 1 2 l a b S a' '@:echo foo @<( bar )> baz (hello) vim (world) this' + ble/keymap:vi_test/check I5g '@:echo @foo ( bar ) baz (hello) vim (world) this' 'v 1 6 l a b S a' '@:echo foo @<( bar )> baz (hello) vim (world) this' + ble/keymap:vi_test/check I5h '@:echo @foo ( bar ) baz (hello) vim (world) this' 'v 1 8 l a b S a' '@:echo foo @<( bar )> baz (hello) vim (world) this' + ble/keymap:vi_test/check J1a '@:echo ( @foo ( bar ) baz (hello) vim (world) this )' 'v 1 l i b S a' '@:echo (@< foo ( bar ) baz (hello) vim (world) this >)' + ble/keymap:vi_test/check J1b '@:echo ( @foo ( bar ) baz (hello) vim (world) this )' 'v 2 l i b S a' '@:echo (@< foo ( bar ) baz (hello) vim (world) this >)' + ble/keymap:vi_test/check J1c '@:echo ( @foo ( bar ) baz (hello) vim (world) this )' 'v 4 l i b S a' '@:echo (@< foo ( bar ) baz (hello) vim (world) this >)' + ble/keymap:vi_test/check J1d '@:echo ( @foo ( bar ) baz (hello) vim (world) this )' 'v 6 l i b S a' '@:echo (@< foo ( bar ) baz (hello) vim (world) this >)' + ble/keymap:vi_test/check J1e '@:echo ( @foo ( bar ) baz (hello) vim (world) this )' 'v 1 0 l i b S a' '@:echo (@< foo ( bar ) baz (hello) vim (world) this >)' + ble/keymap:vi_test/check J1f '@:echo ( @foo ( bar ) baz (hello) vim (world) this )' 'v 1 2 l i b S a' '@:echo (@< foo ( bar ) baz (hello) vim (world) this >)' + ble/keymap:vi_test/check J1g '@:echo ( @foo ( bar ) baz (hello) vim (world) this )' 'v 1 6 l i b S a' '@:echo (@< foo ( bar ) baz (hello) vim (world) this >)' + ble/keymap:vi_test/check J2a '@:echo ( foo @( bar ) baz (hello) vim (world) this )' 'v 1 l i b S a' '@:echo (@< foo ( bar ) baz (hello) vim (world) this >)' + ble/keymap:vi_test/check J2b '@:echo ( foo @( bar ) baz (hello) vim (world) this )' 'v 2 l i b S a' '@:echo (@< foo ( bar ) baz (hello) vim (world) this >)' + ble/keymap:vi_test/check J2c '@:echo ( foo @( bar ) baz (hello) vim (world) this )' 'v 4 l i b S a' '@:echo (@< foo ( bar ) baz (hello) vim (world) this >)' + ble/keymap:vi_test/check J2d '@:echo ( foo @( bar ) baz (hello) vim (world) this )' 'v 6 l i b S a' '@:echo (@< foo ( bar ) baz (hello) vim (world) this >)' + ble/keymap:vi_test/check J2e '@:echo ( foo @( bar ) baz (hello) vim (world) this )' 'v 1 0 l i b S a' '@:echo (@< foo ( bar ) baz (hello) vim (world) this >)' + ble/keymap:vi_test/check J2f '@:echo ( foo @( bar ) baz (hello) vim (world) this )' 'v 1 2 l i b S a' '@:echo (@< foo ( bar ) baz (hello) vim (world) this >)' + ble/keymap:vi_test/check J2g '@:echo ( foo @( bar ) baz (hello) vim (world) this )' 'v 1 6 l i b S a' '@:echo (@< foo ( bar ) baz (hello) vim (world) this >)' + ble/keymap:vi_test/check J3a '@:echo ( foo ( @bar ) baz (hello) vim (world) this )' 'v 1 l i b S a' '@:echo ( foo (@< bar >) baz (hello) vim (world) this )' + ble/keymap:vi_test/check J3b '@:echo ( foo ( @bar ) baz (hello) vim (world) this )' 'v 2 l i b S a' '@:echo ( foo (@< bar >) baz (hello) vim (world) this )' + ble/keymap:vi_test/check J3c '@:echo ( foo ( @bar ) baz (hello) vim (world) this )' 'v 4 l i b S a' '@:echo ( foo (@< bar >) baz (hello) vim (world) this )' + ble/keymap:vi_test/check J3d '@:echo ( foo ( @bar ) baz (hello) vim (world) this )' 'v 6 l i b S a' '@:echo ( foo (@< bar >) baz (hello) vim (world) this )' + ble/keymap:vi_test/check J3e '@:echo ( foo ( @bar ) baz (hello) vim (world) this )' 'v 1 0 l i b S a' '@:echo ( foo (@< bar >) baz (hello) vim (world) this )' + ble/keymap:vi_test/check J3f '@:echo ( foo ( @bar ) baz (hello) vim (world) this )' 'v 1 2 l i b S a' '@:echo ( foo (@< bar >) baz (hello) vim (world) this )' + ble/keymap:vi_test/check J3g '@:echo ( foo ( @bar ) baz (hello) vim (world) this )' 'v 1 6 l i b S a' '@:echo ( foo (@< bar >) baz (hello) vim (world) this )' + ble/keymap:vi_test/check J3h '@:echo ( foo ( @bar ) baz (hello) vim (world) this )' 'v 1 8 l i b S a' '@:echo ( foo (@< bar >) baz (hello) vim (world) this )' + ble/keymap:vi_test/check K1a '@:echo foo @(bar (check) ) world' 'v 1 l i b S a' '@:echo foo (bar (@) ) world' + ble/keymap:vi_test/check K1b '@:echo foo @(bar (check) ) world' 'v 4 l i b S a' '@:echo foo (bar (@) ) world' + ble/keymap:vi_test/check K1c '@:echo foo @(bar (check) ) world' 'v 5 l i b S a' '@:echo foo (bar (@) ) world' + ble/keymap:vi_test/check K1d '@:echo foo @(bar (check) ) world' 'v 7 l i b S a' '@:echo foo (bar (@) ) world' + ble/keymap:vi_test/check K1e '@:echo foo @(bar (check) ) world' 'v 9 l i b S a' '@:echo foo (bar (@) ) world' + ble/keymap:vi_test/check K1f '@:echo foo @(bar (check) ) world' 'v 1 0 l i b S a' '@:echo foo @<(bar (check>) ) world' + ble/keymap:vi_test/check K1g '@:echo foo @(bar (check) ) world' 'v 1 1 l i b S a' '@:echo foo @<(bar (check)> ) world' + ble/keymap:vi_test/check K1h '@:echo foo @(bar (check) ) world' 'v 1 2 l i b S a' '@:echo foo @<(bar (check) >) world' + ble/keymap:vi_test/check K1i '@:echo foo @(bar (check) ) world' 'v 1 3 l i b S a' '@:echo foo @<(bar (check) )> world' + ble/keymap:vi_test/check L1a '@:echo foo @(bar () ) world' 'v 1 l i b S a' '@:echo foo (bar @<()> ) world' + ble/keymap:vi_test/check L1b '@:echo foo @(bar () ) world' 'v 1 l i b h S a' '@:echo foo (bar@< ()> ) world' + ble/keymap:vi_test/check L1c '@:echo foo @(bar () ) world' 'v 1 l a b S a' '@:echo foo (bar @<()> ) world' + ble/keymap:vi_test/check L1d '@:echo foo @(bar () ) world' 'v 1 l a b l S a' '@:echo foo (bar @<() >) world' + ble/keymap:vi_test/check L2a '@:echo foo (bar @() ) world' 'v 1 l i b S a' '@:echo foo (@) world' + ble/keymap:vi_test/check L2b '@:echo foo (bar @() ) world' 'v 2 l i b S a' '@:echo foo (@) world' + ble/keymap:vi_test/check L2c '@:echo foo (bar @() ) world' 'v 3 l i b S a' '@:echo foo (@) world' + ble/keymap:vi_test/check L2d '@:echo foo (bar @() ) world' 'v 4 l i b S a' '@:echo foo (@) world' + ble/keymap:vi_test/check L3a '@:echo foo (bar (@) ) world' 'v 1 l i b S a' '@:echo foo (@) world' + ble/keymap:vi_test/check L3b '@:echo foo (bar (@) ) world' 'v 2 l i b S a' '@:echo foo (@) world' + ble/keymap:vi_test/check L3c '@:echo foo (bar (@) ) world' 'v 3 l i b S a' '@:echo foo (@) world' + ble/keymap:vi_test/check L3d '@:echo foo (bar (@) ) world' 'v 4 l i b S a' '@:echo foo (@) world' + ble/keymap:vi_test/check M1a '@:echo (foo @(bar (check) ) world) xxxx' 'v 1 l i b S a' '@:echo (@) xxxx' + ble/keymap:vi_test/check M1b '@:echo (foo @(bar (check) ) world) xxxx' 'v 5 l i b S a' '@:echo (@) xxxx' + ble/keymap:vi_test/check M1c '@:echo (foo @(bar (check) ) world) xxxx' 'v 7 l i b S a' '@:echo (@) xxxx' + ble/keymap:vi_test/check M1d '@:echo (foo @(bar (check) ) world) xxxx' 'v 1 1 l i b S a' '@:echo (@) xxxx' + ble/keymap:vi_test/check M1e '@:echo (foo @(bar (check) ) world) xxxx' 'v 1 2 l i b S a' '@:echo (@) xxxx' + ble/keymap:vi_test/check M1f '@:echo (foo @(bar (check) ) world) xxxx' 'v 1 3 l i b S a' '@:echo (@) xxxx' + ble/keymap:vi_test/check M1g '@:echo (foo @(bar (check) ) world) xxxx' 'v 1 4 l i b S a' '@:echo (@) xxxx' + ble/keymap:vi_test/check M1h '@:echo (foo @(bar (check) ) world) xxxx' 'v 2 0 l i b S a' '@:echo (@) xxxx' + ble/keymap:vi_test/check M1i '@:echo (foo @(bar (check) ) world) xxxx' 'v 2 4 l i b S a' '@:echo (@) xxxx' + ble/keymap:vi_test/check M2a '@:echo (foo (@bar (check) ) world) xxxx' 'v 1 l i b S a' '@:echo (foo (@) world) xxxx' + ble/keymap:vi_test/check M2b '@:echo (foo (@bar (check) ) world) xxxx' 'v 4 l i b S a' '@:echo (foo (@) world) xxxx' + ble/keymap:vi_test/check M2c '@:echo (foo (@bar (check) ) world) xxxx' 'v 6 l i b S a' '@:echo (foo (@) world) xxxx' + ble/keymap:vi_test/check M2d '@:echo (foo (@bar (check) ) world) xxxx' 'v 1 0 l i b S a' '@:echo (foo (@) world) xxxx' + ble/keymap:vi_test/check M2e '@:echo (foo (@bar (check) ) world) xxxx' 'v 1 1 l i b S a' '@:echo (@) xxxx' + ble/keymap:vi_test/check M2f '@:echo (foo (@bar (check) ) world) xxxx' 'v 1 2 l i b S a' '@:echo (@) xxxx' + ble/keymap:vi_test/check M2g '@:echo (foo (@bar (check) ) world) xxxx' 'v 1 3 l i b S a' '@:echo (@) xxxx' + ble/keymap:vi_test/check M2h '@:echo (foo (@bar (check) ) world) xxxx' 'v 1 9 l i b S a' '@:echo (@) xxxx' + ble/keymap:vi_test/check M2i '@:echo (foo (@bar (check) ) world) xxxx' 'v 2 3 l i b S a' '@:echo (@) xxxx' + ble/keymap:vi_test/check M3a '@:echo (foo (@bar (check) ) world xxxx' 'v 1 4 l i b S a' '@:echo (foo (@orld xxxx' + ble/keymap:vi_test/check M3b '@:echo foo (@bar (check) ) world) xxxx' 'v 1 4 l i b S a' '@:echo foo (@orld) xxxx' + ble/keymap:vi_test/check N1a $'@:echo ( foo (\n@hello world\n) bar )' 'v $ i b S a' $'@:echo (@< foo (\nhello world\n) bar >)' + ble/keymap:vi_test/check N1b $'@:echo ( foo (\n@hello world\n) bar )' 'v f d i b S a' $'@:echo (@< foo (\nhello world\n) bar >)' + ble/test/end-section +} +function ble/keymap:vi_test/section:txtobj_word { + ble/test/start-section "ble/keymap.vi/txtobj_word_omap" 79 + ble/keymap:vi_test/check A1/iw '@:echo he@llo world "hello" "world"' 'd i w' '@:echo @ world "hello" "world"' + ble/keymap:vi_test/check A1/aw '@:echo he@llo world "hello" "world"' 'd a w' '@:echo @world "hello" "world"' + ble/keymap:vi_test/check A2/iw '@:echo hello@ world "hello" "world"' 'd i w' '@:echo hello@world "hello" "world"' + ble/keymap:vi_test/check A2/aw '@:echo hello@ world "hello" "world"' 'd a w' '@:echo hello@ "hello" "world"' + ble/keymap:vi_test/check A3/iw '@:echo hello world "he@llo" "world"' 'd i w' '@:echo hello world "@" "world"' + ble/keymap:vi_test/check A3/aw '@:echo hello world "he@llo" "world"' 'd a w' '@:echo hello world "@" "world"' + ble/keymap:vi_test/check A4/iw '@:echo hello world @"hello" "world"' 'd i w' '@:echo hello world @hello" "world"' + ble/keymap:vi_test/check A4/aw '@:echo hello world @"hello" "world"' 'd a w' '@:echo hello world@hello" "world"' + ble/keymap:vi_test/check A5/iw '@:echo hello world "hello@" "world"' 'd i w' '@:echo hello world "hello@ "world"' + ble/keymap:vi_test/check A5/aw '@:echo hello world "hello@" "world"' 'd a w' '@:echo hello world "hello@"world"' + ble/keymap:vi_test/check A1/2iw '@:echo he@llo world "hello" "world"' 'd 2 i w' '@:echo @world "hello" "world"' + ble/keymap:vi_test/check A1/2aw '@:echo he@llo world "hello" "world"' 'd 2 a w' '@:echo @"hello" "world"' + ble/keymap:vi_test/check A2/2iw '@:echo hello@ world "hello" "world"' 'd 2 i w' '@:echo hello@ "hello" "world"' + ble/keymap:vi_test/check A2/2aw '@:echo hello@ world "hello" "world"' 'd 2 a w' '@:echo hello@hello" "world"' + ble/keymap:vi_test/check A3/2iw '@:echo hello world "he@llo" "world"' 'd 2 i w' '@:echo hello world "@ "world"' + ble/keymap:vi_test/check A3/2aw '@:echo hello world "he@llo" "world"' 'd 2 a w' '@:echo hello world "@"world"' + ble/keymap:vi_test/check A4/2iw '@:echo hello world @"hello" "world"' 'd 2 i w' '@:echo hello world @" "world"' + ble/keymap:vi_test/check A4/2aw '@:echo hello world @"hello" "world"' 'd 2 a w' '@:echo hello world@" "world"' + ble/keymap:vi_test/check A5/2iw '@:echo hello world "hello@" "world"' 'd 2 i w' '@:echo hello world "hello@"world"' + ble/keymap:vi_test/check A5/2aw '@:echo hello world "hello@" "world"' 'd 2 a w' '@:echo hello world "hello@world"' + ble/keymap:vi_test/check A6/iw $'@:echo@ \n hello world' 'd i w' $'@:ech@o\n hello world' + ble/keymap:vi_test/check A6/aw $'@:echo@ \n hello world' 'd a w' $'@:echo@ world' + ble/keymap:vi_test/check A7.2/iw $'@:echo\n@\nhello\n\nworld\nZ' 'd i w' $'@:echo\n@\nhello\n\nworld\nZ' + ble/keymap:vi_test/check A7.2/aw $'@:echo\n@\nhello\n\nworld\nZ' 'd a w' $'@:echo\n@\nworld\nZ' + ble/keymap:vi_test/check A7.2/2iw $'@:echo\n@\nhello\n\nworld\nZ' 'd 2 i w' $'@:echo\n@\nworld\nZ' + ble/keymap:vi_test/check A7.2/2aw $'@:echo\n@\nhello\n\nworld\nZ' 'd 2 a w' $'@:echo\n@Z' + ble/keymap:vi_test/check A7.1/1diw $'@:echo\n@\nhello\nworld\nZ' 'd 1 i w' $'@:echo\n@\nhello\nworld\nZ' + ble/keymap:vi_test/check A7.1/2diw $'@:echo\n@\nhello\nworld\nZ' 'd 2 i w' $'@:echo\n@world\nZ' + ble/keymap:vi_test/check A7.1/3diw $'@:echo\n@\nhello\nworld\nZ' 'd 3 i w' $'@:echo\n@Z' + ble/keymap:vi_test/check A7.2/1diw $'@:echo\n@\nhello\n\nworld\nZ' 'd 1 i w' $'@:echo\n@\nhello\n\nworld\nZ' + ble/keymap:vi_test/check A7.2/2diw $'@:echo\n@\nhello\n\nworld\nZ' 'd 2 i w' $'@:echo\n@\nworld\nZ' + ble/keymap:vi_test/check A7.2/3diw $'@:echo\n@\nhello\n\nworld\nZ' 'd 3 i w' $'@:echo\n@world\nZ' + ble/keymap:vi_test/check A7.2/4diw $'@:echo\n@\nhello\n\nworld\nZ' 'd 4 i w' $'@:echo\n@Z' + ble/keymap:vi_test/check A7.3/1diw $'@:echo\n@\nhello\n\n\nworld\nZ' 'd 1 i w' $'@:echo\n@\nhello\n\n\nworld\nZ' + ble/keymap:vi_test/check A7.3/2diw $'@:echo\n@\nhello\n\n\nworld\nZ' 'd 2 i w' $'@:echo\n@\n\nworld\nZ' + ble/keymap:vi_test/check A7.3/3diw $'@:echo\n@\nhello\n\n\nworld\nZ' 'd 3 i w' $'@:echo\n@\nworld\nZ' + ble/keymap:vi_test/check A7.3/4diw $'@:echo\n@\nhello\n\n\nworld\nZ' 'd 4 i w' $'@:echo\n@Z' + ble/keymap:vi_test/check A7.4/1diw $'@:echo\n@\nhello\n\n\n\nworld\nZ' 'd 1 i w' $'@:echo\n@\nhello\n\n\n\nworld\nZ' + ble/keymap:vi_test/check A7.4/2diw $'@:echo\n@\nhello\n\n\n\nworld\nZ' 'd 2 i w' $'@:echo\n@\n\n\nworld\nZ' + ble/keymap:vi_test/check A7.4/3diw $'@:echo\n@\nhello\n\n\n\nworld\nZ' 'd 3 i w' $'@:echo\n@\n\nworld\nZ' + ble/keymap:vi_test/check A7.4/4diw $'@:echo\n@\nhello\n\n\n\nworld\nZ' 'd 4 i w' $'@:echo\n@world\nZ' + ble/keymap:vi_test/check A7.4/5diw $'@:echo\n@\nhello\n\n\n\nworld\nZ' 'd 5 i w' $'@:echo\n@Z' + ble/keymap:vi_test/check A7.5/1diw $'@:echo\n@\nhello\n\n\n\n\nworld\nZ' 'd 1 i w' $'@:echo\n@\nhello\n\n\n\n\nworld\nZ' + ble/keymap:vi_test/check A7.5/2diw $'@:echo\n@\nhello\n\n\n\n\nworld\nZ' 'd 2 i w' $'@:echo\n@\n\n\n\nworld\nZ' + ble/keymap:vi_test/check A7.5/3diw $'@:echo\n@\nhello\n\n\n\n\nworld\nZ' 'd 3 i w' $'@:echo\n@\n\n\nworld\nZ' + ble/keymap:vi_test/check A7.5/4diw $'@:echo\n@\nhello\n\n\n\n\nworld\nZ' 'd 4 i w' $'@:echo\n@\nworld\nZ' + ble/keymap:vi_test/check A7.5/5diw $'@:echo\n@\nhello\n\n\n\n\nworld\nZ' 'd 5 i w' $'@:echo\n@Z' + local A7_a=$'@:echo\n@\nhello\n\n\n\n\n\n\n\n\n\nworld\nZ' + ble/keymap:vi_test/check A7.a/1ciw "$A7_a" 'c 1 i w' $'@:echo\n@\nhello\n\n\n\n\n\n\n\n\n\nworld\nZ' + ble/keymap:vi_test/check A7.a/2ciw "$A7_a" 'c 2 i w' $'@:echo\n@\n\n\n\n\n\n\n\n\n\nworld\nZ' + ble/keymap:vi_test/check A7.a/3ciw "$A7_a" 'c 3 i w' $'@:echo\n@\n\n\n\n\n\n\n\n\nworld\nZ' + ble/keymap:vi_test/check A7.a/4ciw "$A7_a" 'c 4 i w' $'@:echo\n@\n\n\n\n\n\n\nworld\nZ' + ble/keymap:vi_test/check A7.a/5ciw "$A7_a" 'c 5 i w' $'@:echo\n@\n\n\n\n\nworld\nZ' + ble/keymap:vi_test/check A7.a/6ciw "$A7_a" 'c 6 i w' $'@:echo\n@\n\n\nworld\nZ' + ble/keymap:vi_test/check A7.a/7ciw "$A7_a" 'c 7 i w' $'@:echo\n@\nworld\nZ' + ble/keymap:vi_test/check A7.a/8ciw "$A7_a" 'c 8 i w' $'@:echo\n@\nZ' + ble/keymap:vi_test/check A7.a/1diw "$A7_a" 'd 1 i w' $'@:echo\n@\nhello\n\n\n\n\n\n\n\n\n\nworld\nZ' + ble/keymap:vi_test/check A7.a/2diw "$A7_a" 'd 2 i w' $'@:echo\n@\n\n\n\n\n\n\n\n\nworld\nZ' + ble/keymap:vi_test/check A7.a/3diw "$A7_a" 'd 3 i w' $'@:echo\n@\n\n\n\n\n\n\n\nworld\nZ' + ble/keymap:vi_test/check A7.a/4diw "$A7_a" 'd 4 i w' $'@:echo\n@\n\n\n\n\n\nworld\nZ' + ble/keymap:vi_test/check A7.a/5diw "$A7_a" 'd 5 i w' $'@:echo\n@\n\n\n\nworld\nZ' + ble/keymap:vi_test/check A7.a/6diw "$A7_a" 'd 6 i w' $'@:echo\n@\n\nworld\nZ' + ble/keymap:vi_test/check A7.a/7diw "$A7_a" 'd 7 i w' $'@:echo\n@world\nZ' + ble/keymap:vi_test/check A7.a/8diw "$A7_a" 'd 8 i w' $'@:echo\n@Z' + ble/keymap:vi_test/check A7.a/1caw "$A7_a" 'c 1 a w' $'@:echo\n@\n\n\n\n\n\n\n\n\n\nworld\nZ' + ble/keymap:vi_test/check A7.a/2caw "$A7_a" 'c 2 a w' $'@:echo\n@\n\n\n\n\n\n\n\nworld\nZ' + ble/keymap:vi_test/check A7.a/3caw "$A7_a" 'c 3 a w' $'@:echo\n@\n\n\n\n\n\nworld\nZ' + ble/keymap:vi_test/check A7.a/4caw "$A7_a" 'c 4 a w' $'@:echo\n@\n\n\n\nworld\nZ' + ble/keymap:vi_test/check A7.a/5caw "$A7_a" 'c 5 a w' $'@:echo\n@\n\nworld\nZ' + ble/keymap:vi_test/check A7.a/6caw "$A7_a" 'c 6 a w' $'@:echo\n@\nZ' + ble/keymap:vi_test/check A7.a/1daw "$A7_a" 'd 1 a w' $'@:echo\n@\n\n\n\n\n\n\n\n\nworld\nZ' + ble/keymap:vi_test/check A7.a/2daw "$A7_a" 'd 2 a w' $'@:echo\n@\n\n\n\n\n\n\nworld\nZ' + ble/keymap:vi_test/check A7.a/3daw "$A7_a" 'd 3 a w' $'@:echo\n@\n\n\n\n\nworld\nZ' + ble/keymap:vi_test/check A7.a/4daw "$A7_a" 'd 4 a w' $'@:echo\n@\n\n\nworld\nZ' + ble/keymap:vi_test/check A7.a/5daw "$A7_a" 'd 5 a w' $'@:echo\n@\nworld\nZ' + ble/keymap:vi_test/check A7.a/6daw "$A7_a" 'd 6 a w' $'@:echo\n@Z' + ble/keymap:vi_test/check A8.0/2aw $'@:echo\n@\nhello\n\nworld\n' 'd 2 a w' $'@:@echo' + ble/keymap:vi_test/check A8.2/2aw $'@: echo\n@\nhello\n\nworld\n' 'd 2 a w' $'@: @echo' + ble/keymap:vi_test/check A9.1/ciw $'@:@ \necho' 'c i w' $'@:@\necho' + ble/keymap:vi_test/check A9.2/ciw $'@:@\n echo' 'c i w' $'@:@\n echo' + ble/test/start-section "ble/keymap.vi/txtobj_word_xmap" 34 + ble/keymap:vi_test/check B1/viw.1 '@:echo he@llo world "hello" "world"' 'v i w S a' '@:echo @ world "hello" "world"' + ble/keymap:vi_test/check B1/vaw.1 '@:echo he@llo world "hello" "world"' 'v a w S a' '@:echo @world "hello" "world"' + ble/keymap:vi_test/check B2/viw.2 '@:echo hello@ world "hello" "world"' 'v i w S a' '@:echo hello@< >world "hello" "world"' + ble/keymap:vi_test/check B2/vaw.2 '@:echo hello@ world "hello" "world"' 'v a w S a' '@:echo hello@< world> "hello" "world"' + ble/keymap:vi_test/check B3/viw.3 '@:echo hello world "he@llo" "world"' 'v i w S a' '@:echo hello world "@" "world"' + ble/keymap:vi_test/check B3/vaw.3 '@:echo hello world "he@llo" "world"' 'v a w S a' '@:echo hello world "@" "world"' + ble/keymap:vi_test/check B4/viw.4 '@:echo hello world @"hello" "world"' 'v i w S a' '@:echo hello world @<">hello" "world"' + ble/keymap:vi_test/check B4/vaw.4 '@:echo hello world @"hello" "world"' 'v a w S a' '@:echo hello world@< ">hello" "world"' + ble/keymap:vi_test/check B5/viw.5 '@:echo hello world "hello@" "world"' 'v i w S a' '@:echo hello world "hello@<"> "world"' + ble/keymap:vi_test/check B5/vaw.5 '@:echo hello world "hello@" "world"' 'v a w S a' '@:echo hello world "hello@<" >"world"' + ble/keymap:vi_test/check B1/v2iw.1 '@:echo he@llo world "hello" "world"' 'v 2 i w S a' '@:echo @world "hello" "world"' + ble/keymap:vi_test/check B1/v2aw.1 '@:echo he@llo world "hello" "world"' 'v 2 a w S a' '@:echo @"hello" "world"' + ble/keymap:vi_test/check B2/v2iw.2 '@:echo hello@ world "hello" "world"' 'v 2 i w S a' '@:echo hello@< world> "hello" "world"' + ble/keymap:vi_test/check B2/v2aw.2 '@:echo hello@ world "hello" "world"' 'v 2 a w S a' '@:echo hello@< world ">hello" "world"' + ble/keymap:vi_test/check B3/v2iw.3 '@:echo hello world "he@llo" "world"' 'v 2 i w S a' '@:echo hello world "@ "world"' + ble/keymap:vi_test/check B3/v2aw.3 '@:echo hello world "he@llo" "world"' 'v 2 a w S a' '@:echo hello world "@"world"' + ble/keymap:vi_test/check B4/v2iw.4 '@:echo hello world @"hello" "world"' 'v 2 i w S a' '@:echo hello world @<"hello>" "world"' + ble/keymap:vi_test/check B4/v2aw.4 '@:echo hello world @"hello" "world"' 'v 2 a w S a' '@:echo hello world@< "hello>" "world"' + ble/keymap:vi_test/check B5/v2iw.5 '@:echo hello world "hello@" "world"' 'v 2 i w S a' '@:echo hello world "hello@<" >"world"' + ble/keymap:vi_test/check B5/v2aw.5 '@:echo hello world "hello@" "world"' 'v 2 a w S a' '@:echo hello world "hello@<" ">world"' + ble/keymap:vi_test/check B2/v1hiw '@:echo hello wo@rld' 'v 1 h i w S a' '@:echo hello @ld' + ble/keymap:vi_test/check B2/v2hiw '@:echo hello wo@rld' 'v 2 h i w S a' '@:echo hello@< wor>ld' + ble/keymap:vi_test/check B2/v3hiw '@:echo hello wo@rld' 'v 3 h i w S a' '@:echo hello@< wor>ld' + ble/keymap:vi_test/check B2/v4hiw '@:echo hello wo@rld' 'v 4 h i w S a' '@:echo @ld' + ble/keymap:vi_test/check B2/v1haw '@:echo hello wo@rld' 'v 1 h a w S a' '@:echo hello@< wor>ld' + ble/keymap:vi_test/check B2/v2haw '@:echo hello wo@rld' 'v 2 h a w S a' '@:echo @ld' + ble/keymap:vi_test/check B2/v3haw '@:echo hello wo@rld' 'v 3 h a w S a' '@:echo @ld' + ble/keymap:vi_test/check B2/v4haw '@:echo hello wo@rld' 'v 4 h a w S a' '@:echo@< hello wor>ld' + ble/keymap:vi_test/check B1/v1haw '@:echo he@llo' 'v 1 h a w S a' '@:echo@< hel>lo' + ble/keymap:vi_test/check B1/v2haw '@:echo he@llo' 'v 2 h a w S a' '@:@lo' + ble/keymap:vi_test/check B1/v3haw '@:echo he@llo' 'v 3 h a w S a' '@:e@lo' + ble/keymap:vi_test/check B1/v4haw '@:echo he@llo' 'v 4 h a w S a' '@:e@lo' + ble/keymap:vi_test/check Bn/viw $'@:@echo hello\necho world' 'v $ o $ i w c' $'@:echo hell@echo world' + ble/keymap:vi_test/check Bn/viw $'@:@echo hello \necho world' 'v $ o $ i w c' $'@:echo hello@\necho world' + ble/test/end-section +} +function ble/keymap:vi_test/section:op.2018-02-22 { + ble/test/start-section "ble/keymap.vi/op.2018-02-22" 4 + ble/keymap:vi_test/check A0 $'@:12@345\n67890\n' 'y y p' $'@:12345\n@12345\n67890\n' + ble/keymap:vi_test/check B1 $'@:12@345\n67890\n' 'Y' $'@:12@345\n67890\n' + ble/keymap:vi_test/check B2 $'@:12@345\n67890\n' 'y y' $'@:12@345\n67890\n' + ble/keymap:vi_test/check C $'@:\n12@34567\n1あ2345\n12い345\n123う45\n1234え5\n' 'C-v 4 j l d' $'@:\n12@567\n1 345\n12345\n12 45\n12え5\n' + ble/test/end-section +} +function ble/keymap:vi_test/run-tests { + ble/keymap:vi_test/section:space + ble/keymap:vi_test/section:cw + ble/keymap:vi_test/section:search + ble/keymap:vi_test/section:increment + ble/keymap:vi_test/section:macro + ble/keymap:vi_test/section:surround + ble/keymap:vi_test/section:txtobj_quote_xmap + ble/keymap:vi_test/section:txtobj_block_omap + ble/keymap:vi_test/section:txtobj_block_xmap + ble/keymap:vi_test/section:txtobj_word + ble/keymap:vi_test/section:op.2018-02-22 +} +if [[ $1 == bind ]]; then + function ble/widget/vi-command/check-vi-mode { + local original_str=$_ble_edit_str + local original_ind=$_ble_edit_ind + local original_mark=$_ble_edit_mark + local original_mark_active=$_ble_edit_mark_active + _ble_edit_line_disabled=1 ble/edit/.relocate-textarea # #D1800 pair=leave-command-layout + ble/util/buffer.flush + ble/keymap:vi_test/run-tests + ble-edit/content/reset "$original_str" edit + _ble_edit_ind=$original_ind + _ble_edit_mark=$original_mark + _ble_edit_mark_active=$original_mark_active + ble/edit/leave-command-layout # #D1800 pair=ble/edit/.relocate-textarea + return 0 + } + function ble/widget/vi_imap/check-vi-mode { + ble/widget/vi_imap/normal-mode + ble/widget/vi-command/check-vi-mode + return 0 + } + ble-bind -m vi_imap -f 'C-\ C-\' vi_imap/check-vi-mode + ble-bind -m vi_nmap -f 'C-\ C-\' vi-command:check-vi-mode +fi +function ble/keymap:vi_test/main { + _ble_decode_initialize_inputrc=none + ble/decode/initialize + [[ ${_ble_decode_keymap-} ]] || + ble/decode/reset-default-keymap + ble/decode/keymap/push vi_imap + ble/widget/vi_imap/normal-mode + local original_str=$_ble_edit_str + local original_ind=$_ble_edit_ind + local original_mark=$_ble_edit_mark + local original_mark_active=$_ble_edit_mark_active + ble/util/buffer.flush + ble/keymap:vi_test/run-tests + ble-edit/content/reset "$original_str" edit + _ble_edit_ind=$original_ind + _ble_edit_mark=$original_mark + _ble_edit_mark_active=$original_mark_active + while [[ $_ble_decode_keymap != vi_imap ]]; do + ble/decode/keymap/pop + done + ble/decode/keymap/pop + return 0 +} +ble/keymap:vi_test/main diff --git a/.local/share/blesh/lib/test-main.sh b/.local/share/blesh/lib/test-main.sh new file mode 100644 index 0000000..90dfdf3 --- /dev/null +++ b/.local/share/blesh/lib/test-main.sh @@ -0,0 +1,119 @@ +# Copyright 2015 Koichi Murase . All rights reserved. +# This script is a part of blesh (https://github.com/akinomyoga/ble.sh) +# provided under the BSD-3-Clause license. Do not edit this file because this +# is not the original source code: Various pre-processing has been applied. +# Also, the code comments and blank lines are stripped off in the installation +# process. Please find the corresponding source file(s) in the repository +# "akinomyoga/ble.sh". +# +# Source: /lib/test-main.sh +ble-import lib/core-test +ble/test/start-section 'ble/main' 29 +( + function f1 { + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_local_adjust" + ble/util/setexit 123 + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_local_return" + } + function f2 { + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_local_adjust" + [[ ! -o posix ]] + builtin eval -- "$_ble_bash_POSIXLY_CORRECT_local_return" + } + set +o posix + ble/test 'f1' exit=123 + ble/test 'f2' + ble/test 'f1; [[ ! -o posix ]]' + ble/test 'f2; [[ ! -o posix ]]' + ble/test 'set -o posix; f1; ret=$?; set +o posix' ret=123 + ble/test 'set -o posix; f2; ret=$?; set +o posix' ret=0 + ble/test 'set -o posix; f1; [[ -o posix ]]; ret=$?; set +o posix' ret=0 + ble/test 'set -o posix; f2; [[ -o posix ]]; ret=$?; set +o posix' ret=0 +) +( + ble/test ble/util/put a stdout=a + ble/test ble/util/print a stdout=a + ble/test 'ble/util/put "a b"' stdout='a b' + ble/test 'ble/util/print "a b"' stdout='a b' + ble/test 'ble/util/put "a b"; ble/util/put "c d"' \ + stdout='a bc d' + ble/test 'ble/util/print "a b"; ble/util/print "c d"' \ + stdout='a b' \ + stdout='c d' +) +( + function ble/test/dummy-1 { true; } + function ble/test/dummy-2 { true; } + function ble/test/dummy-3 { true; } + ble/test ble/bin#has ble/test/dummy-1 + ble/test ble/bin#has ble/test/dummy-{1..3} + ble/test ble/bin#has ble/test/dummy-0 exit=1 + ble/test ble/bin#has ble/test/dummy-{0..2} exit=1 + alias ble_test_dummy_4=echo + shopt -u expand_aliases + ble/test '! ble/bin#has ble_test_dummy_4' + shopt -s expand_aliases + ble/test 'ble/bin#has ble_test_dummy_4' +) +( + if [[ $OSTYPE == msys* ]]; then + export MSYS=${MSYS:+$MSYS }winsymlinks + fi + ble/bin#freeze-utility-path readlink ls + function ble/test:readlink.impl1 { + ret=$1 + ble/util/readlink/.resolve-loop + } + function ble/test:readlink.impl2 { + ret=$1 + ble/function#push ble/bin/readlink + ble/util/readlink/.resolve-loop + ble/function#pop ble/bin/readlink + } + ble/test/chdir || exit + cd -P . + command mkdir -p ab/cd/ef + command touch ab/cd/ef/file.txt + command ln -s ef/file.txt ab/cd/link1 + command ln -s ab link.d + command ln -s link.d/cd/link1 f.txt + ble/test ' + ble/util/readlink f.txt + [[ $ret != /* ]] && ret=${PWD%/}/$ret' \ + ret="${PWD%/}/ab/cd/ef/file.txt" + command touch loop1.sh + command ln -s loop1.sh loop0.sh + command ln -s loop1.sh loop3.sh + command rm loop1.sh + command ln -s loop3.sh loop2.sh + command ln -s loop2.sh loop1.sh + for impl in impl1 impl2; do + ble/test "ble/test:readlink.$impl loop0.sh" ret='loop1.sh' + done + mkdir -p phys.dir + touch phys.dir/1.txt + ln -s ../../../phys.dir ab/cd/ef/phys.link + ln -s ab/cd/ef/phys.link phys.link + local pwd=$PWD xpath= + ble/test code:' + path=phys.link/1.txt + ble/util/readlink/.resolve-physical-directory + declare -p path PWD >&2 + [[ $path == */phys.dir/1.txt && $PWD == "$pwd" ]]' + ble/test/rmdir +) +( + ble/test '[[ -d $_ble_base ]]' + ble/test '[[ -d $_ble_base_run ]]' + ble/test '[[ -d $_ble_base_cache ]]' +) +( + qnl="\$'\n'" + value=$'\nxxx is a function\nhello\nyyy is a function\n' + pattern=$'\n+([][{}:[:alnum:]]) is a function\n' + shopt -s extglob + ble/test '[[ ${value//$pattern/'"$qnl"'} == '"$qnl"'hello'"$qnl"' ]]' + shopt -u extglob + ble/test '[[ ${value//$pattern/'"$qnl"'} != '"$qnl"'hello'"$qnl"' ]]' +) +ble/test/end-section diff --git a/.local/share/blesh/lib/test-syntax.sh b/.local/share/blesh/lib/test-syntax.sh new file mode 100644 index 0000000..a22d02e --- /dev/null +++ b/.local/share/blesh/lib/test-syntax.sh @@ -0,0 +1,47 @@ +# Copyright 2015 Koichi Murase . All rights reserved. +# This script is a part of blesh (https://github.com/akinomyoga/ble.sh) +# provided under the BSD-3-Clause license. Do not edit this file because this +# is not the original source code: Various pre-processing has been applied. +# Also, the code comments and blank lines are stripped off in the installation +# process. Please find the corresponding source file(s) in the repository +# "akinomyoga/ble.sh". +# +# Source: /lib/test-syntax.sh +ble-import lib/core-syntax +ble-import lib/core-test +ble/test/start-section 'ble/syntax' 22 +( + func=ble/syntax:bash/simple-word/evaluate-last-brace-expansion + collect='ret=$simple_ibrace/$ret' + ble/test "$func 'a{b,c}x' ; $collect" ret='6:2/acx' + ble/test "$func 'a{b,{c,d}x' ; $collect" ret='9:2/adx' + ble/test "$func 'a{b,{c,d}}x'; $collect" ret='10:2/adx' + ble/test "$func 'a{{c,dx' ; $collect" ret='5:1/adx' + ble/test "$func 'a{b{c,dx' ; $collect" ret='6:2/abdx' + ble/test "$func 'a{b,c}{d}x' ; $collect" ret='7:2/acd}x' +) +( + func=ble/syntax:bash/simple-word/reconstruct-incomplete-word + collect='ret=$?:$simple_flags:[$simple_ibrace]:$ret' + ble/test "$func 'hello-word' ; $collect" ret='0::[0:0]:hello-word' + ble/test "$func 'hello word' ; $collect" ret='1::[0:0]:hello' + ble/test "$func 'hello-word\"a' ; $collect" ret='0:D:[0:0]:hello-word"a"' + ble/test "$func 'a{b,c}x' ; $collect" ret='0::[6:2]:acx' + ble/test "$func 'a{b,{c,d}x' ; $collect" ret='0::[9:2]:adx' + ble/test "$func 'a{b,{c,d}}x' ; $collect" ret='0::[10:2]:adx' + ble/test "$func 'a{{c,dx' ; $collect" ret='0::[5:1]:adx' + ble/test "$func 'a{b{c,dx' ; $collect" ret='0::[6:2]:abdx' + ble/test "$func 'a{b,c}{d}x' ; $collect" ret='0::[7:2]:acd}x' + ble/test "$func 'a{b,c}x\"hello, world'; $collect" ret='0:D:[6:2]:acx"hello, world"' + ble/test "$func 'a{b,{c,d}x'\''a' ; $collect" ret='0:S:[9:2]:adx'\''a'\' + ble/test "$func 'a{b,{c,d}}x\$'\''\e[m'; $collect" ret='0:E:[10:2]:adx$'\''\e[m'\' + ble/test "$func 'a{{c,dx\$\"aa' ; $collect" ret='0:I:[5:1]:adx$"aa"' +) +( + func=ble/syntax:bash/simple-word/evaluate-path-spec + collect='ret="${spec[*]} >>> ${path[*]}"' + ble/test "$func '~/a/b/c' ; $collect" ret="~ ~/a ~/a/b ~/a/b/c >>> $HOME $HOME/a $HOME/a/b $HOME/a/b/c" + ble/test "$func '~/a/b/c' / after-sep; $collect" ret="~/ ~/a/ ~/a/b/ ~/a/b/c >>> $HOME/ $HOME/a/ $HOME/a/b/ $HOME/a/b/c" + ble/test "$func '/x/y/z' / after-sep ; $collect" ret="/ /x/ /x/y/ /x/y/z >>> / /x/ /x/y/ /x/y/z" +) +ble/test/end-section diff --git a/.local/share/blesh/lib/test-util.sh b/.local/share/blesh/lib/test-util.sh new file mode 100644 index 0000000..b2fd804 --- /dev/null +++ b/.local/share/blesh/lib/test-util.sh @@ -0,0 +1,1654 @@ +# Copyright 2015 Koichi Murase . All rights reserved. +# This script is a part of blesh (https://github.com/akinomyoga/ble.sh) +# provided under the BSD-3-Clause license. Do not edit this file because this +# is not the original source code: Various pre-processing has been applied. +# Also, the code comments and blank lines are stripped off in the installation +# process. Please find the corresponding source file(s) in the repository +# "akinomyoga/ble.sh". +# +# Source: /lib/test-util.sh +ble-import lib/core-test +ble/test/start-section 'ble/util' 1243 +( + ble/test 'bleopt a=1' \ + exit=2 + ble/test 'bleopt a' \ + stdout= exit=2 + ble/test 'bleopt a:=2' + ble/test 'bleopt a' \ + stdout="bleopt a=2" + ble/test '[[ $bleopt_a == 2 ]]' + ble/test "bleopt | grep 'bleopt a='" \ + stdout="bleopt a=2" + ble/test 'bleopt a=3' + ble/test 'bleopt a' \ + stdout="bleopt a=3" + function bleopt/check:a { value=123; } + ble/test 'bleopt a=4 && bleopt a' + stdout="bleopt a=123" + function bleopt/check:a { false; } + ble/test 'bleopt a=5' \ + exit=1 + ble/test 'bleopt a' \ + stdout="bleopt a=123" + ble/test bleopt f:=10 g:=11 + ble/test bleopt f g \ + stdout="bleopt f=10${_ble_term_nl}bleopt g=11" + ble/test bleopt f=12 g=13 + ble/test bleopt f g \ + stdout="bleopt f=12${_ble_term_nl}bleopt g=13" + ble/test bleopt/declare -v b 6 + ble/test bleopt b stdout="bleopt b=6" + ble/test bleopt/declare -n c 7 + ble/test bleopt c stdout="bleopt c=7" + ble/test bleopt d:= e:= + ble/test bleopt/declare -v d 8 + ble/test bleopt/declare -n e 9 + ble/test bleopt d stdout="bleopt d=" + ble/test bleopt e stdout="bleopt e=9" +) +ble/test ble/util/setexit 0 exit=0 +ble/test ble/util/setexit 1 exit=1 +ble/test ble/util/setexit 9 exit=9 +ble/test ble/util/setexit 128 exit=128 +ble/test ble/util/setexit 255 exit=255 +( + a=1 + function f1 { + ble/util/print "g:$a" + local a=2 + ble/util/print "l:$a" + ble/util/unlocal a + ble/util/print "g:$a" + a=3 + } + ble/test 'f1; ble/util/print "g:$a"' \ + stdout=g:1 \ + stdout=l:2 \ + stdout=g:1 \ + stdout=g:3 + function f2 { + ble/util/print "f1:$a@f2" + local a=3 + ble/util/print "f2:$a@f2" + ble/util/unlocal a + ble/util/print "f1:$a@f2" + a=$a+ + } + function f1 { + ble/util/print "g:$a@f1" + local a=2 + ble/util/print "f1:$a@f1" + f2 + ble/util/print "f1:$a@f1" + ble/util/unlocal a + ble/util/print "g:$a@f1" + a=$a+ + } + ble/test 'a=1; f1; ble/util/print "g:$a@g"' \ + stdout=g:1@f1 \ + stdout=f1:2@f1 \ + stdout=f1:2@f2 \ + stdout=f2:3@f2 \ + stdout=f1:2@f2 \ + stdout=f1:2+@f1 \ + stdout=g:1@f1 \ + stdout=g:1+@g +) +( + function f1 { + local a=1 b=2 + local result=$((a+b)) + local "$1" && ble/util/upvar "$1" "$result" + } + ble/test 'f1 x; ret=$x' ret=3 + ble/test 'f1 a; ret=$a' ret=3 + ble/test 'f1 result; ret=$result' ret=3 + function f2 { + local a=1 + local -a b=(2) + local -a result; result=("$((a+b[0]))" y z) + local "$1" && ble/util/uparr "$1" "${result[@]}" + } + ble/test 'f2 x; ret="(${x[*]})"' ret='(3 y z)' + ble/test 'f2 a; ret="(${a[*]})"' ret='(3 y z)' + ble/test 'f2 b; ret="(${b[*]})"' ret='(3 y z)' + ble/test 'f2 result; ret="(${result[*]})"' ret='(3 y z)' +) +( + varnames=(name x y count data) + function print-status { + ble/util/print "name=$name x=$x y=$y count=$count data=(${data[*]})" + } + function f1 { + local "${varnames[@]/%/=}" # WA #D1570 checked + name=1 x=2 y=3 count=4 data=(aa bb cc dd) + print-status + ble/util/save-vars save1_ "${varnames[@]}" + name=one x= y=A count=1 data=(Q) + print-status + ble/util/save-vars save2_ "${varnames[@]}" + ble/util/restore-vars save1_ "${varnames[@]}" + print-status + ble/util/restore-vars save2_ "${varnames[@]}" + print-status + } + ble/test f1 \ + stdout='name=1 x=2 y=3 count=4 data=(aa bb cc dd)' \ + stdout='name=one x= y=A count=1 data=(Q)' \ + stdout='name=1 x=2 y=3 count=4 data=(aa bb cc dd)' \ + stdout='name=one x= y=A count=1 data=(Q)' +) +( + declare v=1 + declare -i i=1 + export x=2 + builtin readonly r=3 + declare -a a=() + if ((_ble_bash>=40000)); then + declare -A A=() + declare -u u=a + declare -l l=B + declare -c c=c + fi + if ((_ble_bash>=40300)); then + declare -n n=r + fi + ble/test 'ble/variable#get-attr v; ret=$attr' ret= + ble/test 'ble/variable#get-attr i; ret=$attr' ret=i + ble/test 'ble/variable#get-attr x; ret=$attr' ret=x + ble/test 'ble/variable#get-attr r; ret=$attr' ret=r + ble/test 'ble/variable#get-attr a; ret=$attr' ret=a + if ((_ble_bash>=40000)); then + ble/test 'ble/variable#get-attr u; ret=$attr' ret=u + ble/test 'ble/variable#get-attr l; ret=$attr' ret=l + ble/test 'ble/variable#get-attr c; ret=$attr' ret=c + ble/test 'ble/variable#get-attr A; ret=$attr' ret=A + fi + ble/test 'ble/variable#has-attr i i' + ble/test 'ble/variable#has-attr x x' + ble/test 'ble/variable#has-attr r r' + ble/test 'ble/variable#has-attr a a' + ble/test 'ble/variable#has-attr v i' exit=1 + ble/test 'ble/variable#has-attr v x' exit=1 + ble/test 'ble/variable#has-attr v r' exit=1 + ble/test 'ble/variable#has-attr v a' exit=1 + if ((_ble_bash>=40000)); then + ble/test 'ble/variable#has-attr u u' + ble/test 'ble/variable#has-attr l l' + ble/test 'ble/variable#has-attr c c' + ble/test 'ble/variable#has-attr A A' + ble/test 'ble/variable#has-attr v u' exit=1 + ble/test 'ble/variable#has-attr v l' exit=1 + ble/test 'ble/variable#has-attr v c' exit=1 + ble/test 'ble/variable#has-attr v A' exit=1 + fi + ble/test 'ble/is-inttype i' + ble/test 'ble/is-inttype v' exit=1 + ble/test 'ble/is-readonly r' + ble/test 'ble/is-readonly v' exit=1 + if ((_ble_bash>=40000)); then + ble/test 'ble/is-transformed u' + ble/test 'ble/is-transformed l' + ble/test 'ble/is-transformed c' + ble/test 'ble/is-transformed v' exit=1 + fi +) +function is-global { (builtin readonly "$1"; ! local "$1" 2>/dev/null); } +( + v1=1 v2=2 + ((_ble_bash>=40200)) && + declare -g v1u v2u + function f1 { + local v2=22 v3=33 + local v2u v3u + f2 + } + function f2 { + local v4=444 v4u + ble/test 'is-global v0' + ble/test 'is-global v1' + ble/test 'is-global v2' exit=1 + ble/test 'is-global v3' exit=1 + ble/test 'is-global v4' exit=1 + ble/test 'ble/variable#is-global v0' + ble/test 'ble/variable#is-global v1' + ble/test 'ble/variable#is-global v2' exit=1 + ble/test 'ble/variable#is-global v3' exit=1 + ble/test 'ble/variable#is-global v4' exit=1 + ble/test 'ble/variable#is-global v0u' + if ((_ble_bash>=40200)); then + ble/test 'ble/variable#is-global v1u' + ble/test 'ble/variable#is-global v2u' exit=1 + fi + ble/test 'ble/variable#is-global v3u' exit=1 + ble/test 'ble/variable#is-global v4u' exit=1 + } + f1 +) +( + _ble_array_prototype=() + ble/test 'echo "${#_ble_array_prototype[@]}"' stdout=0 + ble/array#reserve-prototype 10 + ble/test 'echo "${#_ble_array_prototype[@]}"' stdout=10 + ble/test 'x=("${_ble_array_prototype[@]::10}"); echo "${#x[@]}"' stdout=10 + ble/array#reserve-prototype 3 + ble/test 'echo "${#_ble_array_prototype[@]}"' stdout=10 + ble/test 'x=("${_ble_array_prototype[@]::3}"); echo "${#x[@]}"' stdout=3 +) +( + declare -a a=() + declare b= + ble/test 'ble/is-array a' + ble/test 'ble/is-array b' exit=1 + ble/test 'ble/is-array c' exit=1 + if ((_ble_bash>=40000)); then + declare -A A=() + ble/test 'ble/is-array A' exit=1 + ble/test 'ble/is-assoc a' exit=1 + ble/test 'ble/is-assoc A' + ble/test 'ble/is-assoc b' exit=1 + ble/test 'ble/is-assoc c' exit=1 + fi +) +( + ble/test 'ble/array#set a; echo "${#a[@]}:(${a[*]})"' stdout='0:()' + ble/test 'ble/array#set a Q; echo "${#a[@]}:(${a[*]})"' stdout='1:(Q)' + ble/test 'ble/array#set a 1 2 3; echo "${#a[@]}:(${a[*]})"' stdout='3:(1 2 3)' + ble/test 'ble/array#set a; echo "${#a[@]}:(${a[*]})"' stdout='0:()' +) +( + declare -a a=() + ble/array#push a + ble/test 'echo "${#a[@]}:(${a[*]})"' stdout='0:()' + ble/array#push a A + ble/test 'echo "${#a[@]}:(${a[*]})"' stdout='1:(A)' + ble/array#push a B C + ble/test 'echo "${#a[@]}:(${a[*]})"' stdout='3:(A B C)' + ble/array#push a + ble/test 'echo "${#a[@]}:(${a[*]})"' stdout='3:(A B C)' +) +( + function result { ble/util/print "$ret:${#arr[*]}:(${arr[*]})"; } + ble/test 'arr=() ; ble/array#pop arr; result' stdout=':0:()' + ble/test 'arr=(1) ; ble/array#pop arr; result' stdout='1:0:()' + ble/test 'arr=(1 2) ; ble/array#pop arr; result' stdout='2:1:(1)' + ble/test 'arr=(0 0 0); ble/array#pop arr; result' stdout='0:2:(0 0)' + ble/test 'arr=(1 2 3); ble/array#pop arr; result' stdout='3:2:(1 2)' + ble/test 'arr=(" a a " " b b " " c c "); ble/array#pop arr; result' \ + stdout=' c c :2:( a a b b )' +) +( + function status { ble/util/print "${#a[@]}:(${a[*]})"; } + a=() + ble/array#unshift a + ble/test status stdout='0:()' + ble/array#unshift a A + ble/test status stdout='1:(A)' + ble/array#unshift a + ble/test status stdout='1:(A)' + ble/array#unshift a B + ble/test status stdout='2:(B A)' + ble/array#unshift a C D E + ble/test status stdout='5:(C D E B A)' + a=() + ble/array#unshift a A B + ble/test status stdout='2:(A B)' +) +( + function status { ble/util/print "${#a[@]}:(${a[*]})"; } + a=(); ble/array#reverse a + ble/test status stdout='0:()' + a=(1); ble/array#reverse a + ble/test status stdout='1:(1)' + a=(xy zw); ble/array#reverse a + ble/test status stdout='2:(zw xy)' + a=(a 3 x); ble/array#reverse a + ble/test status stdout='3:(x 3 a)' + a=({1..10}) b=({10..1}); ble/array#reverse a + ble/test status stdout="10:(${b[*]})" + a=({1..9}) b=({9..1}); ble/array#reverse a + ble/test status stdout="9:(${b[*]})" +) +( + function status { ble/util/print "${#a[@]}:(${a[*]})"; } + a=(); ble/array#insert-at a 0 A B C + ble/test status stdout='3:(A B C)' + a=(); ble/array#insert-at a 1 A B C + ble/test status stdout='3:(A B C)' + a=(x y z); ble/array#insert-at a 0 A + ble/test status stdout='4:(A x y z)' + a=(x y z); ble/array#insert-at a 1 A + ble/test status stdout='4:(x A y z)' + a=(x y z); ble/array#insert-at a 3 A + ble/test status stdout='4:(x y z A)' + a=(x y z); ble/array#insert-at a 0 A B C + ble/test status stdout='6:(A B C x y z)' + a=(x y z); ble/array#insert-at a 1 A B C + ble/test status stdout='6:(x A B C y z)' + a=(x y z); ble/array#insert-at a 3 A B C + ble/test status stdout='6:(x y z A B C)' + a=(x y z); ble/array#insert-at a 0 + ble/test status stdout='3:(x y z)' + a=(x y z); ble/array#insert-at a 1 + ble/test status stdout='3:(x y z)' + a=(x y z); ble/array#insert-at a 3 + ble/test status stdout='3:(x y z)' +) +( + function status { ble/util/print "${#a[@]}:(${a[*]})"; } + a=(hello world hello world) + ble/array#insert-after a hello 1 2 3 + ble/test status stdout='7:(hello 1 2 3 world hello world)' + a=(heart world hello world) + ble/array#insert-after a hello 1 2 3 + ble/test status stdout='7:(heart world hello 1 2 3 world)' + a=(hello world hello world) + ble/test 'ble/array#insert-after a check 1 2 3' exit=1 + ble/test status stdout='4:(hello world hello world)' +) +( + function status { ble/util/print "${#a[@]}:(${a[*]})"; } + a=(hello world this) + ble/array#insert-before a this with check + ble/test status stdout='5:(hello world with check this)' + a=(hello world this) + ble/test 'ble/array#insert-before a haystack kick check' exit=1 + ble/test status stdout='3:(hello world this)' +) +( + function status { ble/util/print "${#a[@]}:(${a[*]})"; } + a=(xxx yyy xxx yyy yyy xxx fdsa fdsa) + ble/array#remove a xxx + ble/test status stdout='5:(yyy yyy yyy fdsa fdsa)' + a=(aa aa aa aa aa) + ble/array#remove a bb + ble/test status stdout='5:(aa aa aa aa aa)' + ble/array#remove a aa + ble/test status stdout='0:()' + ble/array#remove a cc + ble/test status stdout='0:()' +) +( + a=(hello world this hello world) + ble/test 'ble/array#index a hello' ret=0 + a=(world hep this hello world) + ble/test 'ble/array#index a hello' ret=3 + a=(hello world this hello world) + ble/test 'ble/array#index a check' ret=-1 +) +( + a=(hello world this hello world) + ble/test 'ble/array#last-index a hello' ret=3 + a=(world hep this hello world) + ble/test 'ble/array#last-index a hello' ret=3 + a=(hello world this hello world) + ble/test 'ble/array#last-index a check' ret=-1 +) +( + function status { ble/util/print "${#a[@]}:(${a[*]})"; } + a=() + ble/test 'ble/array#remove-at a 0; status' stdout='0:()' + ble/test 'ble/array#remove-at a 10; status' stdout='0:()' + a=(x y z) + ble/test 'ble/array#remove-at a 4; status' stdout='3:(x y z)' + ble/test 'ble/array#remove-at a 3; status' stdout='3:(x y z)' + ble/test 'ble/array#remove-at a 1; status' stdout='2:(x z)' + ble/test 'ble/array#remove-at a 0; status' stdout='1:(z)' + ble/test 'ble/array#remove-at a 0; status' stdout='0:()' + a=({a..z}) a1=({a..y}) a2=({b..y}) a3=({b..h} {j..y}) + ble/test 'ble/array#remove-at a 25; status' stdout="25:(${a1[*]})" + ble/test 'ble/array#remove-at a 0; status' stdout="24:(${a2[*]})" + ble/test 'ble/array#remove-at a 7; status' stdout="23:(${a3[*]})" +) +( + _ble_string_prototype=' ' + ble/test 'echo "${#_ble_string_prototype}"' stdout=8 + ble/string#reserve-prototype 10 + ble/test 'echo "${#_ble_string_prototype}"' stdout=16 + ble/test 'x=${_ble_string_prototype::10}; echo "${#x}"' stdout=10 + ble/string#reserve-prototype 3 + ble/test 'echo "${#_ble_string_prototype}"' stdout=16 + ble/test 'x=${_ble_string_prototype::3}; echo "${#x}"' stdout=3 + ble/string#reserve-prototype 77 + ble/test 'echo "${#_ble_string_prototype}"' stdout=128 + ble/test 'x=${_ble_string_prototype::77}; echo "${#x}"' stdout=77 +) +( + ble/test 'ble/string#repeat' ret= + ble/test 'ble/string#repeat ""' ret= + ble/test 'ble/string#repeat a' ret= + ble/test 'ble/string#repeat abc' ret= + ble/test 'ble/string#repeat "" ""' ret= + ble/test 'ble/string#repeat a ""' ret= + ble/test 'ble/string#repeat abc ""' ret= + ble/test 'ble/string#repeat "" 0' ret= + ble/test 'ble/string#repeat a 0' ret= + ble/test 'ble/string#repeat abc 0' ret= + ble/test 'ble/string#repeat "" 1' ret= + ble/test 'ble/string#repeat "" 10' ret= + ble/test 'ble/string#repeat a 1' ret=a + ble/test 'ble/string#repeat a 2' ret=aa + ble/test 'ble/string#repeat a 5' ret=aaaaa + ble/test 'ble/string#repeat abc 1' ret=abc + ble/test 'ble/string#repeat abc 2' ret=abcabc + ble/test 'ble/string#repeat abc 5' ret=abcabcabcabcabc + ble/test 'ble/string#repeat ";&|<>" 5' ret=';&|<>;&|<>;&|<>;&|<>;&|<>' +) +( + ble/test 'ble/string#common-prefix' ret= + ble/test 'ble/string#common-prefix ""' ret= + ble/test 'ble/string#common-prefix a' ret= + ble/test 'ble/string#common-prefix "" ""' ret= + ble/test 'ble/string#common-prefix a ""' ret= + ble/test 'ble/string#common-prefix a b' ret= + ble/test 'ble/string#common-prefix a a' ret=a + ble/test 'ble/string#common-prefix abc abc' ret=abc + ble/test 'ble/string#common-prefix abc aaa' ret=a + ble/test 'ble/string#common-prefix abc ccc' ret= + ble/test 'ble/string#common-prefix abc xyz' ret= +) +( + ble/test 'ble/string#common-suffix' ret= + ble/test 'ble/string#common-suffix ""' ret= + ble/test 'ble/string#common-suffix a' ret= + ble/test 'ble/string#common-suffix "" ""' ret= + ble/test 'ble/string#common-suffix a ""' ret= + ble/test 'ble/string#common-suffix a b' ret= + ble/test 'ble/string#common-suffix a a' ret=a + ble/test 'ble/string#common-suffix abc abc' ret=abc + ble/test 'ble/string#common-suffix abc aaa' ret= + ble/test 'ble/string#common-suffix abc ccc' ret=c + ble/test 'ble/string#common-suffix abc xyz' ret= +) +( + function status { ble/util/print "${#a[@]}:(""${a[*]}"")"; } + nl=$'\n' + ble/test 'ble/string#split a , "" ; status' stdout='1:()' + ble/test 'ble/string#split a , "1" ; status' stdout='1:(1)' + ble/test 'ble/string#split a , "," ; status' stdout='2:( )' + ble/test 'ble/string#split a , "1," ; status' stdout='2:(1 )' + ble/test 'ble/string#split a , ",2" ; status' stdout='2:( 2)' + ble/test 'ble/string#split a , "1,,3" ; status' stdout='3:(1 3)' + ble/test 'ble/string#split a , "1,2,3" ; status' stdout='3:(1 2 3)' + ble/test 'ble/string#split a " " "1 2 3"; status' stdout='3:(1 2 3)' + ble/test 'ble/string#split a " " "1 2 3"; status' stdout='1:(1 2 3)' + ble/test 'ble/string#split a " " "1'"$nl"'2'"$nl"'3"; status' stdout="1:(1${nl}2${nl}3)" +) +( + function status { ble/util/print "${#a[@]}:(${a[*]})"; } + nl=$'\n' ht=$'\t' + ble/test 'ble/string#split-words a "" ; status' stdout='0:()' + ble/test 'ble/string#split-words a "1" ; status' stdout='1:(1)' + ble/test 'ble/string#split-words a " " ; status' stdout='0:()' + ble/test 'ble/string#split-words a "1 " ; status' stdout='1:(1)' + ble/test 'ble/string#split-words a " 2" ; status' stdout='1:(2)' + ble/test 'ble/string#split-words a "1 3" ; status' stdout='2:(1 3)' + ble/test 'ble/string#split-words a "1 2 3"; status' stdout='3:(1 2 3)' + ble/test 'ble/string#split-words a " 1'"$ht"'2'"$ht"'3 "; status' stdout='3:(1 2 3)' + ble/test 'ble/string#split-words a " 1'"$nl"'2'"$nl"'3 "; status' stdout='3:(1 2 3)' +) +( + function status { ble/util/print "${#a[@]}:(""${a[*]}"")"; } + nl=$'\n' ht=$'\t' + ble/test 'ble/string#split-lines a "" ; status' stdout='1:()' + ble/test 'ble/string#split-lines a "1" ; status' stdout='1:(1)' + ble/test 'ble/string#split-lines a "'"$nl"'" ; status' stdout='2:( )' + ble/test 'ble/string#split-lines a "1'"$nl"'" ; status' stdout='2:(1 )' + ble/test 'ble/string#split-lines a "'"$nl"'2" ; status' stdout='2:( 2)' + ble/test 'ble/string#split-lines a "1'"$nl$nl"'3" ; status' stdout='3:(1 3)' + ble/test 'ble/string#split-lines a "1'"$nl"'2'"$nl"'3"; status' stdout='3:(1 2 3)' + ble/test 'ble/string#split-lines a "1'"$ht"'2'"$ht"'3"; status' stdout="1:(1${ht}2${ht}3)" + ble/test 'ble/string#split-lines a "1 2 3"; status' stdout="1:(1 2 3)" +) +( + ble/test 'ble/string#count-char hello a' ret=0 + ble/test 'ble/string#count-char hello あ' ret=0 + ble/test 'ble/string#count-char hello e' ret=1 + ble/test 'ble/string#count-char hello l' ret=2 + ble/test 'ble/string#count-char hello olh' ret=4 + ble/test 'ble/string#count-char hello hello' ret=5 + ble/test 'ble/string#count-char "" a' ret=0 + ble/test 'ble/string#count-char "" ab' ret=0 +) +( + ble/test 'ble/string#count-string hello a' ret=0 + ble/test 'ble/string#count-string hello あ' ret=0 + ble/test 'ble/string#count-string hello ee' ret=0 + ble/test 'ble/string#count-string hello e' ret=1 + ble/test 'ble/string#count-string hello l' ret=2 + ble/test 'ble/string#count-string hello ll' ret=1 + ble/test 'ble/string#count-string hello hello' ret=1 + ble/test 'ble/string#count-string "" a' ret=0 + ble/test 'ble/string#count-string "" ab' ret=0 + ble/test 'ble/string#count-string ababababa aba' ret=2 +) +( + ble/test 'ble/string#index-of hello a' ret=-1 + ble/test 'ble/string#index-of hello あ' ret=-1 + ble/test 'ble/string#index-of hello ee' ret=-1 + ble/test 'ble/string#index-of hello e' ret=1 + ble/test 'ble/string#index-of hello l' ret=2 + ble/test 'ble/string#index-of hello ll' ret=2 + ble/test 'ble/string#index-of hello hello' ret=0 + ble/test 'ble/string#index-of "" a' ret=-1 + ble/test 'ble/string#index-of "" ab' ret=-1 + ble/test 'ble/string#index-of ababababa aba' ret=0 +) +( + ble/test 'ble/string#last-index-of hello a' ret=-1 + ble/test 'ble/string#last-index-of hello あ' ret=-1 + ble/test 'ble/string#last-index-of hello ee' ret=-1 + ble/test 'ble/string#last-index-of hello e' ret=1 + ble/test 'ble/string#last-index-of hello l' ret=3 + ble/test 'ble/string#last-index-of hello ll' ret=2 + ble/test 'ble/string#last-index-of hello hello' ret=0 + ble/test 'ble/string#last-index-of "" a' ret=-1 + ble/test 'ble/string#last-index-of "" ab' ret=-1 + ble/test 'ble/string#last-index-of ababababa aba' ret=6 +) +( + ble/test 'ble/string#toggle-case' ret= + ble/test 'ble/string#tolower ' ret= + ble/test 'ble/string#toupper ' ret= + ble/test 'ble/string#capitalize ' ret= + ble/test 'ble/string#toggle-case ""' ret= + ble/test 'ble/string#tolower ""' ret= + ble/test 'ble/string#toupper ""' ret= + ble/test 'ble/string#capitalize ""' ret= + ble/test 'ble/string#toggle-case a' ret=A + ble/test 'ble/string#tolower a' ret=a + ble/test 'ble/string#toupper a' ret=A + ble/test 'ble/string#capitalize a' ret=A + ble/test 'ble/string#toggle-case あ' ret=あ + ble/test 'ble/string#tolower あ' ret=あ + ble/test 'ble/string#toupper あ' ret=あ + ble/test 'ble/string#capitalize あ' ret=あ + ble/test 'ble/string#toggle-case +' ret=+ + ble/test 'ble/string#tolower +' ret=+ + ble/test 'ble/string#toupper +' ret=+ + ble/test 'ble/string#capitalize +' ret=+ + ble/test 'ble/string#toggle-case abc' ret=ABC + ble/test 'ble/string#tolower abc' ret=abc + ble/test 'ble/string#toupper abc' ret=ABC + ble/test 'ble/string#capitalize abc' ret=Abc + ble/test 'ble/string#toggle-case ABC' ret=abc + ble/test 'ble/string#tolower ABC' ret=abc + ble/test 'ble/string#toupper ABC' ret=ABC + ble/test 'ble/string#capitalize ABC' ret=Abc + ble/test 'ble/string#toggle-case aBc' ret=AbC + ble/test 'ble/string#tolower aBc' ret=abc + ble/test 'ble/string#toupper aBc' ret=ABC + ble/test 'ble/string#capitalize aBc' ret=Abc + ble/test 'ble/string#toggle-case +aBc' ret=+AbC + ble/test 'ble/string#tolower +aBc' ret=+abc + ble/test 'ble/string#toupper +aBc' ret=+ABC + ble/test 'ble/string#capitalize +aBc' ret=+Abc + ble/test 'ble/string#capitalize "hello world"' ret='Hello World' + LC_ALL=en_US.utf8 + ble/test 'ble/string#toggle-case +aBc' ret=+AbC + ble/test 'ble/string#tolower +aBc' ret=+abc + ble/test 'ble/string#toupper +aBc' ret=+ABC + ble/test 'ble/string#capitalize +aBc' ret=+Abc + ble/test 'ble/string#capitalize "hello world"' ret='Hello World' +) +( + ble/test 'ble/string#trim ' ret= + ble/test 'ble/string#ltrim' ret= + ble/test 'ble/string#rtrim' ret= + ble/test 'ble/string#trim ""' ret= + ble/test 'ble/string#ltrim ""' ret= + ble/test 'ble/string#rtrim ""' ret= + ble/test 'ble/string#trim "a"' ret=a + ble/test 'ble/string#ltrim "a"' ret=a + ble/test 'ble/string#rtrim "a"' ret=a + ble/test 'ble/string#trim " a "' ret=a + ble/test 'ble/string#ltrim " a "' ret='a ' + ble/test 'ble/string#rtrim " a "' ret=' a' + ble/test 'ble/string#trim " a b "' ret='a b' + ble/test 'ble/string#ltrim " a b "' ret='a b ' + ble/test 'ble/string#rtrim " a b "' ret=' a b' + ble/test 'ble/string#trim "abc"' ret='abc' + ble/test 'ble/string#ltrim "abc"' ret='abc' + ble/test 'ble/string#rtrim "abc"' ret='abc' + ble/test 'ble/string#trim " abc "' ret='abc' + ble/test 'ble/string#ltrim " abc "' ret='abc ' + ble/test 'ble/string#rtrim " abc "' ret=' abc' + for pad in $' \t\n \t\n' $'\t\t\t' $'\n\n\n'; do + ble/test 'ble/string#trim "'"$pad"'abc'"$pad"'"' ret='abc' + ble/test 'ble/string#ltrim "'"$pad"'abc'"$pad"'"' ret="abc${pad}" + ble/test 'ble/string#rtrim "'"$pad"'abc'"$pad"'"' ret="${pad}abc" + done +) +( + ble/test 'ble/string#escape-characters hello' ret=hello + ble/test 'ble/string#escape-characters hello ""' ret=hello + ble/test 'ble/string#escape-characters hello xyz' ret=hello + ble/test 'ble/string#escape-characters hello el' ret='h\e\l\lo' + ble/test 'ble/string#escape-characters hello hl XY' ret='\Xe\Y\Yo' + ble/test 'ble/string#escape-for-sed-regex "A\.[*?+|^\$(){}/"' \ + ret='A\\\.\[\*?+|\^\$(){}\/' + ble/test 'ble/string#escape-for-awk-regex "A\.[*?+|^\$(){}/"' \ + ret='A\\\.\[\*\?\+\|\^\$\(\)\{\}\/' + ble/test 'ble/string#escape-for-extended-regex "A\.[*?+|^\$(){}/"' \ + ret='A\\\.\[\*\?\+\|\^\$\(\)\{\}/' + ble/test 'ble/string#escape-for-bash-glob "A\*?[("' ret='A\\\*\?\[\(' + ble/test 'ble/string#escape-for-bash-single-quote "A'\''B"' ret="A'\''B" + ble/test 'ble/string#escape-for-bash-double-quote "hello \$ \` \\ ! world"' ret='hello \$ \` \\ "\!" world' + input=A$'\\\a\b\e\f\n\r\t\v'\'B output=A'\\\a\b\e\f\n\r\t\v\'\'B + ble/test 'ble/string#escape-for-bash-escape-string "$input"' ret="$output" + ble/test 'ble/string#escape-for-bash-specialchars "[hello] (world) {this,is} "' \ + ret='\[hello\]\ \(world\)\ {this,is}\ \' + ble/test 'ble/string#escape-for-bash-specialchars "[hello] (world) {this,is} " b' \ + ret='\[hello\]\ \(world\)\ \{this\,is\}\ \' + ble/test 'ble/string#escape-for-bash-specialchars "a=b:c:d" c' \ + ret='a\=b\:c\:d' + ble/test $'ble/string#escape-for-bash-specialchars "a\tb\tc"' \ + ret=$'a\\\tb\\\tc' +) +( + ble/test 'ble/string#quote-command' ret= + ble/test 'ble/string#quote-command echo' ret='echo' + ble/test 'ble/string#quote-command echo hello world' ret="echo 'hello' 'world'" + ble/test 'ble/string#quote-command echo "hello world"' ret="echo 'hello world'" + ble/test 'ble/string#quote-command echo "'\''test'\''"' ret="echo ''\''test'\'''" + ble/test 'ble/string#quote-command echo "" "" ""' ret="echo '' '' ''" + ble/test 'ble/string#quote-command echo a{1..4}' ret="echo 'a1' 'a2' 'a3' 'a4'" + ble/test 'ble/util/print-quoted-command' stdout= + ble/test 'ble/util/print-quoted-command echo' stdout='echo' + ble/test 'ble/util/print-quoted-command echo hello world' stdout="echo 'hello' 'world'" + ble/test 'ble/util/print-quoted-command echo "hello world"' stdout="echo 'hello world'" + ble/test 'ble/util/print-quoted-command echo "'\''test'\''"' stdout="echo ''\''test'\'''" + ble/test 'ble/util/print-quoted-command echo "" "" ""' stdout="echo '' '' ''" + ble/test 'ble/util/print-quoted-command echo a{1..4}' stdout="echo 'a1' 'a2' 'a3' 'a4'" +) +( + ble/test 'ble/string#quote-word' ret= + ble/test 'ble/string#quote-word echo' ret='echo' + ble/test 'ble/string#quote-word "hello world"' ret="'hello world'" + ble/test 'ble/string#quote-word "'\''test'\''"' ret="\'test\'" + ble/test 'ble/string#quote-word "a'\''b'\''c"' ret="a\'b\'c" +) +( + ble/test 'ble/string#create-unicode-progress-bar 0 24 3' ret=' ' + ble/test 'ble/string#create-unicode-progress-bar 1 24 3' ret='▏ ' + ble/test 'ble/string#create-unicode-progress-bar 2 24 3' ret='▎ ' + ble/test 'ble/string#create-unicode-progress-bar 3 24 3' ret='▍ ' + ble/test 'ble/string#create-unicode-progress-bar 4 24 3' ret='▌ ' + ble/test 'ble/string#create-unicode-progress-bar 5 24 3' ret='▋ ' + ble/test 'ble/string#create-unicode-progress-bar 6 24 3' ret='▊ ' + ble/test 'ble/string#create-unicode-progress-bar 7 24 3' ret='▉ ' + ble/test 'ble/string#create-unicode-progress-bar 8 24 3' ret='█ ' + ble/test 'ble/string#create-unicode-progress-bar 9 24 3' ret='█▏ ' + ble/test 'ble/string#create-unicode-progress-bar 15 24 3' ret='█▉ ' + ble/test 'ble/string#create-unicode-progress-bar 16 24 3' ret='██ ' + ble/test 'ble/string#create-unicode-progress-bar 17 24 3' ret='██▏' + ble/test 'ble/string#create-unicode-progress-bar 24 24 3' ret='███' + ble/test 'ble/string#create-unicode-progress-bar 0 24 4 unlimited' ret=$'█ ' + ble/test 'ble/string#create-unicode-progress-bar 1 24 4 unlimited' ret=$'\e[7m▏\e[27m▏ ' + ble/test 'ble/string#create-unicode-progress-bar 2 24 4 unlimited' ret=$'\e[7m▎\e[27m▎ ' + ble/test 'ble/string#create-unicode-progress-bar 3 24 4 unlimited' ret=$'\e[7m▍\e[27m▍ ' + ble/test 'ble/string#create-unicode-progress-bar 4 24 4 unlimited' ret=$'\e[7m▌\e[27m▌ ' + ble/test 'ble/string#create-unicode-progress-bar 5 24 4 unlimited' ret=$'\e[7m▋\e[27m▋ ' + ble/test 'ble/string#create-unicode-progress-bar 6 24 4 unlimited' ret=$'\e[7m▊\e[27m▊ ' + ble/test 'ble/string#create-unicode-progress-bar 7 24 4 unlimited' ret=$'\e[7m▉\e[27m▉ ' + ble/test 'ble/string#create-unicode-progress-bar 8 24 4 unlimited' ret=$' █ ' + ble/test 'ble/string#create-unicode-progress-bar 9 24 4 unlimited' ret=$' \e[7m▏\e[27m▏ ' + ble/test 'ble/string#create-unicode-progress-bar 15 24 4 unlimited' ret=$' \e[7m▉\e[27m▉ ' + ble/test 'ble/string#create-unicode-progress-bar 16 24 4 unlimited' ret=$' █ ' + ble/test 'ble/string#create-unicode-progress-bar 17 24 4 unlimited' ret=$' \e[7m▏\e[27m▏' + ble/test 'ble/string#create-unicode-progress-bar 24 24 4 unlimited' ret=$'█ ' +) +( + ble/test 'ble/util/strlen' ret=0 + ble/test 'ble/util/strlen ""' ret=0 + ble/test 'ble/util/strlen a' ret=1 + ble/test 'ble/util/strlen abc' ret=3 + ble/test 'ble/util/strlen α' ret=2 + ble/test 'ble/util/strlen αβγ' ret=6 + ble/test 'ble/util/strlen あ' ret=3 + ble/test 'ble/util/strlen あいう' ret=9 + ble/test 'ble/util/strlen aα' ret=3 + ble/test 'ble/util/strlen aαあ' ret=6 + LC_ALL=en_US.utf8 + ble/test 'ble/util/strlen a' ret=1 + ble/test 'ble/util/strlen α' ret=2 + ble/test 'ble/util/strlen あ' ret=3 +) +( + ble/test 'ble/util/substr' ret= + ble/test 'ble/util/substr ""' ret= + ble/test 'ble/util/substr a' ret= + ble/test 'ble/util/substr "" 0' ret= + ble/test 'ble/util/substr "" 1' ret= + ble/test 'ble/util/substr a 0' ret= + ble/test 'ble/util/substr a 1' ret= + ble/test 'ble/util/substr a 2' ret= + ble/test 'ble/util/substr "" 0 0' ret= + ble/test 'ble/util/substr "" 0 1' ret= + ble/test 'ble/util/substr "" 1 1' ret= + ble/test 'ble/util/substr a 0 0' ret= + ble/test 'ble/util/substr a 1 0' ret= + ble/test 'ble/util/substr a 0 1' ret=a + ble/test 'ble/util/substr a 1 1' ret= + ble/test 'ble/util/substr abc 1 0' ret= + ble/test 'ble/util/substr abc 1 1' ret=b + ble/test 'ble/util/substr abc 1 2' ret=bc + ble/test 'ble/util/substr abc 0 0' ret= + ble/test 'ble/util/substr abc 0 1' ret=a + ble/test 'ble/util/substr abc 0 3' ret=abc + ble/test 'ble/util/substr abc 0 4' ret=abc + ble/test 'ble/util/substr abc 3 0' ret= + ble/test 'ble/util/substr abc 3 1' ret= + ble/test 'ble/util/substr abc 4 0' ret= + ble/test 'ble/util/substr abc 4 1' ret= + ble/test 'ble/util/substr あいう 0 3' ret=あ + ble/test 'ble/util/substr あいう 3 6' ret=いう + ble/test 'ble/util/substr あいう 0 1' ret=$'\xe3' + ble/test 'ble/util/substr あいう 1 2' ret=$'\x81\x82' + ble/test 'ble/util/substr あいう 1 4' ret=$'\x81\x82\xe3\x81' + ble/test 'ble/util/substr あいう 7 5' ret=$'\x81\x86' +) +( + for cmd in ble/path#{remove,remove-glob}; do + ble/test code:'ret=; '$cmd' ret' ret= + ble/test code:'ret=; '$cmd' ret ""' ret= + ble/test code:'ret=a; '$cmd' ret ""' ret=a + ble/test code:'ret=a; '$cmd' ret a' ret= + ble/test code:'ret=a; '$cmd' ret b' ret=a + ble/test code:'ret=a:a:a; '$cmd' ret a' ret= + ble/test code:'ret=aa; '$cmd' ret a' ret=aa + ble/test code:'ret=xyz:abc; '$cmd' ret ""' ret=xyz:abc + ble/test code:'ret=xyz:abc; '$cmd' ret xyz' ret=abc + ble/test code:'ret=xyz:abc; '$cmd' ret abc' ret=xyz + ble/test code:'ret=xyz:abc:tuv; '$cmd' ret xyz' ret=abc:tuv + ble/test code:'ret=xyz:abc:tuv; '$cmd' ret abc' ret=xyz:tuv + ble/test code:'ret=xyz:abc:tuv; '$cmd' ret tuv' ret=xyz:abc + ble/test code:'ret=xyz:xyz; '$cmd' ret xyz' ret= + ble/test code:'ret=xyz:abc:xyz; '$cmd' ret xyz' ret=abc + ble/test code:'ret=xyz:abc:xyz; '$cmd' ret abc' ret=xyz:xyz + ble/test code:'ret=xyz:xyz:xyz; '$cmd' ret xyz' ret= + done + export LC_ALL= LC_COLLATE=C 2>/dev/null # suppress locale error #D1440 + ble/test code:'ret=a; ble/path#remove ret \?' ret=a + ble/test code:'ret=aa; ble/path#remove ret \?' ret=aa + ble/test code:'ret=a:b; ble/path#remove ret \?' ret=a:b + ble/test code:'ret=a:b:c; ble/path#remove ret \?' ret=a:b:c + ble/test code:'ret=aa:b:cc; ble/path#remove ret \?' ret=aa:b:cc + ble/test code:'ret=stdX:stdY:usrZ; ble/path#remove ret "std[a-zX-Z]"' ret=stdX:stdY:usrZ + ble/test code:'ret=stdX:usrZ:stdY; ble/path#remove ret "std[a-zX-Z]"' ret=stdX:usrZ:stdY + ble/test code:'ret=usrZ:stdX:stdY; ble/path#remove ret "std[a-zX-Z]"' ret=usrZ:stdX:stdY + ble/test code:'ret=a; ble/path#remove-glob ret \?' ret= + ble/test code:'ret=aa; ble/path#remove-glob ret \?' ret=aa + ble/test code:'ret=a:b; ble/path#remove-glob ret \?' ret= + ble/test code:'ret=a:b:c; ble/path#remove-glob ret \?' ret= + ble/test code:'ret=aa:b:cc; ble/path#remove-glob ret \?' ret=aa:cc + ble/test code:'ret=stdX:stdY:usrZ; ble/path#remove-glob ret "std[a-zX-Z]"' ret=usrZ + ble/test code:'ret=stdX:usrZ:stdY; ble/path#remove-glob ret "std[a-zX-Z]"' ret=usrZ + ble/test code:'ret=usrZ:stdX:stdY; ble/path#remove-glob ret "std[a-zX-Z]"' ret=usrZ +) +( + ble/test code:'ret=; ble/path#append ret a' ret=a + ble/test code:'ret=a; ble/path#append ret a' ret=a:a + ble/test code:'ret=a; ble/path#append ret b' ret=a:b + ble/test code:'ret=a:b; ble/path#append ret cd' ret=a:b:cd + ble/test code:'ret=; ble/path#prepend ret a' ret=a + ble/test code:'ret=a; ble/path#prepend ret a' ret=a:a + ble/test code:'ret=a; ble/path#prepend ret b' ret=b:a + ble/test code:'ret=a:b; ble/path#prepend ret cd' ret=cd:a:b + ble/test code:'ret=a:b:c; ble/path#contains ret a' + ble/test code:'ret=a:b:c; ble/path#contains ret b' + ble/test code:'ret=a:b:c; ble/path#contains ret c' + ble/test code:'ret=a:b:c; ! ble/path#contains ret x' + ble/test code:'ret=a:b:c; ! ble/path#contains ret aa' + ble/test code:'ret=a:b:c; ! ble/path#contains ret bb' + ble/test code:'ret=a:b:c; ! ble/path#contains ret cc' + ble/test code:'ret=a:b:c; ! ble/path#contains ret "?"' + ble/test code:'ret=a:b:c; ! ble/path#contains ret "*"' + ble/test code:'ret=abc:def; ble/path#contains ret abc' + ble/test code:'ret=abc:def; ble/path#contains ret def' + ble/test code:'ret=abc:def; ! ble/path#contains ret a' + ble/test code:'ret=abc:def; ! ble/path#contains ret ab' + ble/test code:'ret=abc:def; ! ble/path#contains ret abcdef' + ble/test code:'ret=abc:def; ! ble/path#contains ret "???"' + ble/test code:'ret=xyz; ble/path#contains ret xyz' + ble/test code:'ret=xyz; ! ble/path#contains ret xyz:xyz' + ble/test code:'ret=xyz; ! ble/path#contains ret "???"' +) +( + builtin eval -- "${_ble_util_dict_declare//NAME/dict1}" + builtin eval -- "${_ble_util_gdict_declare//NAME/dict2}" + builtin eval -- "${_ble_util_adict_declare//NAME/dict3}" + index=1 + for Dict in ble/{,g,a}dict; do + dict=dict$((index++)) + ret=unchanged + ble/test '! '$Dict'#has '$dict' banana' ret=unchanged + ble/test '! '$Dict'#has '$dict' ""' ret=unchanged + $Dict#set $dict apple red + $Dict#set $dict banana yellow + $Dict#set $dict orange orange + $Dict#set $dict melon green + ret=unchanged + ble/test $Dict'#has '$dict' banana' ret=unchanged # 先頭 + ble/test $Dict'#has '$dict' apple' ret=unchanged # 中 + ble/test $Dict'#has '$dict' melon' ret=unchanged # 末尾 + ble/test '! '$Dict'#has '$dict' pear' ret=unchanged # 存在しない項目 + ble/test $Dict'#get '$dict' banana' ret=yellow # 先頭 + ble/test $Dict'#get '$dict' apple' ret=red # 中 + ble/test $Dict'#get '$dict' melon' ret=green # 末尾 + ble/test '! '$Dict'#get '$dict' pear' ret= # 存在しない項目 + ble/test '! '$Dict'#has '$dict' ""' # 末尾空要素で引けるか + ble/test '! '$Dict'#get '$dict' ""' # 末尾空要素で引けるか + $Dict#set $dict '' transparent + ble/test $Dict'#has '$dict' ""' # 末尾空要素で引けるか + ble/test $Dict'#get '$dict' ""' ret=transparent # 末尾空要素で引けるか + $Dict#set $dict 'alpha beta' pink + ble/test $Dict'#has '$dict' ""' # 中央空要素で引けるか + ble/test $Dict'#has '$dict' "alpha beta"' # 空白を含む見出し + ble/test $Dict'#get '$dict' ""' ret=transparent # 中央空要素で引けるか + ble/test $Dict'#get '$dict' "alpha beta"' ret=pink # 空白を含む見出し + $Dict#set $dict ' apple ' ' red ' + ble/test $Dict'#has '$dict' " apple "' # 空白で trim されないか + ble/test $Dict'#has '$dict' apple' # 既存項目を破壊していないか + ble/test $Dict'#get '$dict' " apple "' ret=' red ' # 空白で trim されないか + ble/test $Dict'#get '$dict' apple' ret=red # 既存項目を破壊していないか + ble/test '! '$Dict'#has '$dict' "${_ble_term_FS}"' # 単一FS + ble/test '! '$Dict'#has '$dict' ":"' # 単一コロン + ble/test '! '$Dict'#has '$dict' "apple${_ble_term_FS}banana"' # FSを含む見出し + ble/test '! '$Dict'#has '$dict' apple:banana' # コロンを含む見出し + ble/test '! '$Dict'#get '$dict' "${_ble_term_FS}"' ret= # 単一FS + ble/test '! '$Dict'#get '$dict' ":"' ret= # 単一コロン + ble/test '! '$Dict'#get '$dict' "apple${_ble_term_FS}banana"' ret= # FSを含む見出し + ble/test '! '$Dict'#get '$dict' apple:banana' ret= # コロンを含む見出し + $Dict#set $dict "${_ble_term_FS}" Empty + $Dict#set $dict ":" Colon + $Dict#set $dict "apple${_ble_term_FS}banana" RedYellow + $Dict#set $dict "apple:banana" __red_yellow__ + ble/test $Dict'#has '$dict' "${_ble_term_FS}"' # 単一FS + ble/test $Dict'#has '$dict' ":"' # 単一コロン + ble/test $Dict'#has '$dict' "apple${_ble_term_FS}banana"' # FSを含む見出し + ble/test $Dict'#has '$dict' apple:banana' # コロンを含む見出し + ble/test $Dict'#get '$dict' "${_ble_term_FS}"' ret=Empty # 単一FS + ble/test $Dict'#get '$dict' ":"' ret=Colon # 単一コロン + ble/test $Dict'#get '$dict' "apple${_ble_term_FS}banana"' ret=RedYellow # FSを含む見出し + ble/test $Dict'#get '$dict' apple:banana' ret=__red_yellow__ # コロンを含む見出し + $Dict#unset $dict banana + $Dict#unset $dict apple + $Dict#unset $dict melon + ble/test '! '$Dict'#has '$dict' banana' + ble/test '! '$Dict'#has '$dict' apple' + ble/test '! '$Dict'#has '$dict' melon' + $Dict#unset $dict "" + $Dict#unset $dict "alpha beta" + $Dict#unset $dict " apple " + ble/test '! '$Dict'#has '$dict' ""' # 中央空要素で引けるか + ble/test '! '$Dict'#has '$dict' "alpha beta"' # 空白を含む見出し + ble/test '! '$Dict'#has '$dict' " apple "' # 空白で trim されないか + $Dict#unset $dict "${_ble_term_FS}" + $Dict#unset $dict ":" + $Dict#unset $dict "apple${_ble_term_FS}banana" + $Dict#unset $dict apple:banana + ble/test '! '$Dict'#has '$dict' "${_ble_term_FS}"' # 単一FS + ble/test '! '$Dict'#has '$dict' ":"' # 単一コロン + ble/test '! '$Dict'#has '$dict' "apple${_ble_term_FS}banana"' # FSを含む見出し + ble/test '! '$Dict'#has '$dict' apple:banana' # コロンを含む見出し + done +) +( + blehook/declare FOO + ble/test 'blehook --color=never FOO' stdout='blehook FOO=' + ble/test 'blehook/has-hook FOO' exit=1 + blehook FOO+='ble/util/print hello' + ble/test 'blehook --color=never FOO' \ + stdout="blehook FOO='ble/util/print hello'" + ble/test 'blehook/has-hook FOO' + blehook FOO+='ble/util/print world' + ble/test 'blehook --color=never FOO' \ + stdout="blehook FOO='ble/util/print hello'" \ + stdout="blehook FOO+='ble/util/print world'" + ble/test 'blehook/has-hook FOO' + blehook FOO-='ble/util/print hello' + ble/test 'blehook --color=never FOO' \ + stdout="blehook FOO='ble/util/print world'" + ble/test 'blehook/has-hook FOO' + blehook FOO-='ble/util/print world' + ble/test 'blehook --color=never FOO' \ + stdout='blehook FOO=' + ble/test 'blehook/has-hook FOO' exit=1 + blehook FOO+='ble/util/print hello' + blehook FOO+='ble/util/print world' + blehook FOO='ble/util/print empty' + ble/test 'blehook --color=never FOO' \ + stdout="blehook FOO='ble/util/print empty'" + ble/test 'blehook/has-hook FOO' + blehook FOO+='ble/util/print hello' + blehook FOO+='ble/util/print world' + blehook FOO= + ble/test 'blehook --color=never FOO' \ + stdout='blehook FOO=' + ble/test 'blehook/has-hook FOO' exit=1 + blehook FOO+='ble/util/print hello' + blehook FOO+='ble/util/print world' + blehook FOO!='ble/util/print hello' + ble/test 'blehook --color=never FOO' \ + stdout="blehook FOO='ble/util/print hello'${_ble_term_nl}blehook FOO+='ble/util/print world'" + blehook FOO-+='ble/util/print hello' + ble/test 'blehook --color=never FOO' \ + stdout="blehook FOO='ble/util/print world'${_ble_term_nl}blehook FOO+='ble/util/print hello'" + blehook FOO+-='ble/util/print hello' + ble/test 'blehook --color=never FOO' \ + stdout="blehook FOO='ble/util/print hello'${_ble_term_nl}blehook FOO+='ble/util/print world'" + blehook FOO= + blehook FOO+='ble/util/print hello' + blehook FOO+='ble/util/print empty' + blehook FOO+='ble/util/print world' + ble/test 'blehook/invoke FOO' \ + stdout=hello \ + stdout=empty \ + stdout=world + blehook FOO='ble/util/print "A$?"' + blehook FOO+='ble/util/print "B$?"' + blehook FOO+='ble/util/print "C$?"' + ble/test 'ble/util/setexit 123; blehook/invoke FOO' \ + stdout=A123 \ + stdout=B123 \ + stdout=C123 + blehook/declare bar_load + blehook bar_load='ble/util/print bar_load' + ble/test 'blehook/eval-after-load bar "ble/util/print yes"' stdout= + ble/test 'blehook/invoke bar_load' \ + stdout=bar_load \ + stdout=yes + ble/test 'blehook/eval-after-load bar "ble/util/print next"' stdout=next + function func { ret="[$1]"; } + blehook FOO=func + ble/test 'blehook/invoke FOO xQAHbcpMFyFyQ' ret='[xQAHbcpMFyFyQ]' +) +( + ble/builtin/trap 'ble/util/print TRAPEXIT1' 0 + ble/test 'ble/builtin/trap/invoke 0' stdout=TRAPEXIT1 + ble/test 'ble/builtin/trap/invoke EXIT' stdout=TRAPEXIT1 + ble/builtin/trap 0 + ble/test 'ble/builtin/trap/invoke 0' stdout= + ble/builtin/trap 'ble/util/print TRAPEXIT2' EXIT + ble/test 'ble/builtin/trap/invoke 0' stdout=TRAPEXIT2 + ble/test 'ble/builtin/trap/invoke EXIT' stdout=TRAPEXIT2 + ble/builtin/trap EXIT + ble/test 'ble/builtin/trap/invoke 0' stdout= + ble/builtin/trap 'ble/util/print TRAPHUP1' 1 + ble/test 'ble/builtin/trap/invoke 1' stdout=TRAPHUP1 + ble/test 'ble/builtin/trap/invoke HUP' stdout=TRAPHUP1 + ble/test 'ble/builtin/trap/invoke SIGHUP' stdout=TRAPHUP1 + ble/builtin/trap 1 + ble/test 'ble/builtin/trap/invoke 1' stdout= + ble/builtin/trap 'ble/util/print TRAPHUP2' HUP + ble/test 'ble/builtin/trap/invoke 1' stdout=TRAPHUP2 + ble/test 'ble/builtin/trap/invoke HUP' stdout=TRAPHUP2 + ble/test 'ble/builtin/trap/invoke SIGHUP' stdout=TRAPHUP2 + ble/builtin/trap HUP + ble/test 'ble/builtin/trap/invoke HUP' stdout= + ble/builtin/trap 'ble/util/print TRAPHUP3' SIGHUP + ble/test 'ble/builtin/trap/invoke 1' stdout=TRAPHUP3 + ble/test 'ble/builtin/trap/invoke HUP' stdout=TRAPHUP3 + ble/test 'ble/builtin/trap/invoke SIGHUP' stdout=TRAPHUP3 + ble/builtin/trap SIGHUP + ble/test 'ble/builtin/trap/invoke HUP' stdout= + ble/builtin/trap/sig#new CUSTOM + ble/builtin/trap 'ble/util/print "custom trap"' CUSTOM + ble/test 'ble/builtin/trap/invoke CUSTOM' stdout='custom trap' + function ble/builtin/trap:CUSTOM { ble/util/print "__set_handler__ ($2) $1"; } + ble/test 'ble/builtin/trap "ble/util/print \"hello world\"" CUSTOM' \ + stdout='__set_handler__ (CUSTOM) ble/util/print "hello world"' + ble/test 'ble/builtin/trap/invoke CUSTOM' stdout='hello world' +) +( + ble/test 'ble/util/readfile ret <(echo hello)' \ + ret=hello$'\n' + ble/test 'ble/util/readfile ret <(echo hello; echo world)' \ + ret=hello$'\n'world$'\n' + ble/test 'ble/util/readfile ret <(echo hello; echo -n world)' \ + ret=hello$'\n'world + ble/test 'ble/util/readfile ret <(:)' ret= + function status { ble/util/print "${#a[*]}:(""${a[*]}"")"; } + ble/test "ble/util/mapfile a < <(echo hello); status" stdout='1:(hello)' + ble/test "ble/util/mapfile a < <(echo -n hello); status" stdout='1:(hello)' + ble/test "ble/util/mapfile a < <(echo hello; echo world); status" stdout='2:(hello world)' + ble/test "ble/util/mapfile a < <(echo hello; echo -n world); status" stdout='2:(hello world)' + ble/test "ble/util/mapfile a < <(printf '%s\n' h1 h2 h3 h4); status" stdout='4:(h1 h2 h3 h4)' + ble/test "ble/util/mapfile a < <(:); status" stdout='0:()' + ble/test "ble/util/mapfile a < <(echo); status" stdout='1:()' + ble/test "ble/util/mapfile a < <(echo;echo); status" stdout='2:( )' + ble/test "ble/util/mapfile a < <(echo a;echo;echo b); status" stdout='3:(a b)' + nl=$'\n' + ble/test 'ble/util/assign ret ""' ret= + ble/test 'ble/util/assign ret ":"' ret= + ble/test 'ble/util/assign ret "echo"' ret= + ble/test 'ble/util/assign ret "echo hello"' ret=hello + ble/test 'ble/util/assign ret "seq 5"' ret="1${nl}2${nl}3${nl}4${nl}5" + function f1 { ble/util/print stdout; ble/util/print stderr >&2; } + function nested-assign { + ble/util/assign err 'ble/util/assign out f1 2>&1' + ble/util/print "out=$out err=$err" + } + ble/test nested-assign stdout='out=stdout err=stderr' + ble/test 'ble/util/assign-array a :; status' stdout='0:()' + ble/test 'ble/util/assign-array a echo; status' stdout='1:()' + ble/test 'ble/util/assign-array a "echo hello"; status' stdout='1:(hello)' + ble/test 'ble/util/assign-array a "seq 5"; status' stdout='5:(1 2 3 4 5)' + ble/test 'ble/util/assign-array a "echo; echo; echo"; status' stdout='3:( )' + ble/test 'ble/util/assign-array a "echo 1; echo; echo 2"; status' stdout='3:(1 2)' +) +( + x=($'\177' $'\1' $'\2' $'\32' ' ' $'\a' $'\b' $'\t' $'\n' $'\v' $'\f' $'\r' a \" \' \$ \! \` \~) + x[0]=$'\177' + x[1]=$'\1' + function ble/test/hash { + local tmpfile=$_ble_base_run/$$.test.$RANDOM ret + ble/bin/cat >| "$tmpfile" + ble/file#hash "$tmpfile" + >| "$tmpfile" + ble/util/print "$ret" + } + ble/test "ble/util/writearray -d '' x | ble/test/hash" stdout=$(printf '%s\0' "${x[@]}" | ble/test/hash) + x=($'\302\203' alpha) + ble/test "ble/util/writearray -d '' x | ble/test/hash" stdout=$(printf '%s\0' "${x[@]}" | ble/test/hash) + for pair in $'\a:007' $'\b:010' $'\t:011' $'\v:013' $'\f:014' $'\r:015'; do + for awk in awk nawk mawk gawk; do + if ble/is-function ble/bin/"$awk"; then + ctrl=${pair%:*} + seq=${pair#*:} + value=$(ble/bin/"$awk" '{gsub(/\'"$seq"'/, "");print $0 "x";}' <<< "x${ctrl}y") + value=${value%x} + ble/test code:"ret=\$value # \"$awk gsub(/\\$seq/)\"" ret="xy" + fi + done + done +) +( + var=variable + alias ali=fun + function fun { ble/util/print "yes $*"; } + function ble/fun { ble/util/print "yes $*"; return 99; } + function ble/fun:type { ble/util/print "yes $*"; return 100; } + function ble/fun#meth { ble/util/print "yes $*"; return 101; } + ble/test 'ble/is-function' exit=1 + ble/test 'ble/is-function ""' exit=1 + ble/test 'ble/is-function fun' + ble/test 'ble/is-function ble/fun' + ble/test 'ble/is-function ble/fun:type' + ble/test 'ble/is-function ble/fun#meth' + ble/test 'ble/is-function fun1' exit=1 + ble/test 'ble/is-function ble/fun1' exit=1 + ble/test 'ble/is-function ble/fun1:type' exit=1 + ble/test 'ble/is-function ble/fun1#meth' exit=1 + ble/test 'ble/is-function ali' exit=1 + ble/test 'ble/is-function var' exit=1 + ble/test 'ble/is-function compgen' exit=1 + ble/test 'ble/is-function declare' exit=1 + ble/test 'ble/is-function mkfifo' exit=1 + function compgen { return 0; } + function declare { return 0; } + function mkfifo { return 0; } + ble/test 'ble/is-function compgen' + ble/test 'ble/is-function declare' + ble/test 'ble/is-function mkfifo' + ble/test 'ble/function#try fun 1 2 3' stdout='yes 1 2 3' + ble/test 'ble/function#try ble/fun 1 2 3' stdout='yes 1 2 3' exit=99 + ble/test 'ble/function#try ble/fun:type 1 2 3' stdout='yes 1 2 3' exit=100 + ble/test 'ble/function#try ble/fun#meth 1 2 3' stdout='yes 1 2 3' exit=101 + ble/test 'ble/function#try fun1 1 2 3' stdout= exit=127 + ble/test 'ble/function#try ble/fun1 1 2 3' stdout= exit=127 + ble/test 'ble/function#try ble/fun1:type 1 2 3' stdout= exit=127 + ble/test 'ble/function#try ble/fun1#meth 1 2 3' stdout= exit=127 +) +( + function f1 { ble/util/print "original${*:+ $*}"; } + ble/test f1 stdout='original' + ble/function#advice before f1 'ble/util/print pre' + ble/test f1 stdout={pre,original} + ble/function#advice after f1 'ble/util/print post' + ble/test f1 stdout={pre,original,post} + ble/function#advice before f1 'ble/util/print A' + ble/test f1 stdout={A,original,post} + ble/function#advice after f1 'ble/util/print B' + ble/test f1 stdout={A,original,B} + ble/function#advice around f1 'ble/util/print [; ble/function#advice/do; ble/util/print ]' + ble/test f1 stdout={A,[,original,],B} + ble/function#advice around f1 ' + ADVICE_WORDS[1]=quick + ble/util/print [; ble/function#advice/do; ble/util/print ] + ADVICE_EXIT=99' + ble/test f1 stdout={A,[,'original quick',],B} exit=99 + ble/function#advice remove f1 + ble/test f1 stdout='original' exit=0 + ble/test 'f1 1' stdout='original 1' exit=0 +) +( + ble/test 'echo 1 2 3' stdout='1 2 3' + ble/test 'ble/is-function echo' exit=1 + ble/function#push echo 'builtin echo "[$*]"' + ble/test 'ble/is-function echo' + ble/test 'echo 1 2 3' stdout='[1 2 3]' + ble/function#push echo 'builtin echo "($*)"' + ble/test 'echo 1 2 3' stdout='(1 2 3)' + ble/function#push echo 'builtin echo A; ble/function#push/call-top "$@"; builtin echo Z' + ble/test 'echo 1 2 3' stdout={A,'(1 2 3)',Z} + ble/function#push echo 'builtin echo [; ble/function#push/call-top "$@"; builtin echo ]' + ble/test 'echo 1 2 3' stdout={[,A,'(1 2 3)',Z,]} + ble/test 'ble/function#pop echo' + ble/test 'echo 1 2 3' stdout={A,'(1 2 3)',Z} + ble/function#pop echo + ble/test 'echo 1 2 3' stdout='(1 2 3)' + ble/function#pop echo + ble/test 'echo 1 2 3' stdout='[1 2 3]' + ble/test 'ble/is-function echo' + ble/test 'ble/function#pop echo' + ble/test 'ble/is-function echo' exit=1 + ble/test 'echo 1 2 3' stdout='1 2 3' + ble/test 'ble/function#pop echo' exit=1 + ble/test 'echo 1 2 3' stdout='1 2 3' +) +( + ble/test 'ble/util/set ret hello' ret='hello' + ble/test 'ble/util/set ret "hello world"' ret='hello world' + ble/test 'ble/util/set ret ""' ret='' + ble/test 'ble/util/set ret " "' ret=' ' + ble/test 'ble/util/set ret " a"' ret=' a' + ble/test 'ble/util/set ret "a "' ret='a ' + ble/test 'ble/util/set ret $'\''\n'\''' ret=$'\n' + ble/test 'ble/util/set ret A$'\''\n'\''' ret=A$'\n' + ble/test 'ble/util/set ret A$'\''\n'\''B' ret=A$'\n'B +) +( + ble/test 'ble/util/sprintf ret "[%s]" 1 2 3' ret='[1][2][3]' + ble/test 'ble/util/sprintf ret "[%5s]" 1' ret='[ 1]' + ble/test 'ble/util/sprintf ret "[%.2s]" 12345' ret='[12]' + ble/test 'ble/util/sprintf ret "[%d,%d]" 1 3' ret='[1,3]' + ble/test 'ble/util/sprintf ret "[%x]" 27' ret='[1b]' + ble/test 'ble/util/sprintf ret "[%#.2g]" 27' ret='[27.]' + ble/test 'ble/util/sprintf ret "[%#.2f]" 27' ret='[27.00]' +) +( + shopt -s expand_aliases + alias aaa=fun + function fun { return 0; } + function ble/fun { return 0; } + function ble/fun:type { return 0; } + function ble/fun#meth { return 0; } + ble/test 'ble/util/type ret aaa' ret=alias + ble/test 'ble/util/type ret fun' ret=function + ble/test 'ble/util/type ret alias' ret=builtin + ble/test 'ble/util/type ret mkfifo' ret=file + ble/test 'ble/util/type ret for' ret=keyword + ble/test 'ble/util/type ret ble/fun' ret=function + ble/test 'ble/util/type ret ble/fun:type' ret=function + ble/test 'ble/util/type ret ble/fun#meth' ret=function + ble/test 'ble/util/type ret fun1' ret= + ble/test 'ble/util/type ret ble/fun1' ret= + ble/test 'ble/util/type ret ble/fun1:type' ret= + ble/test 'ble/util/type ret ble/fun1#meth' ret= +) +( + shopt -s expand_aliases + alias aaa1='aaa2 world' + ble/test 'ble/alias#expand aaa1' ret='aaa2 world' + alias aaa2='aaa3 hello' + ble/test 'ble/alias#expand aaa2' ret='aaa3 hello' + ble/test 'ble/alias#expand aaa1' ret='aaa2 world' + alias aaa3='aaa4' + ble/test 'ble/alias#expand aaa3' ret='aaa4' + ble/test 'ble/alias#expand aaa2' ret='aaa3 hello' + ble/test 'ble/alias#expand aaa1' ret='aaa2 world' + alias aaa4='echo' + ble/test 'ble/alias#expand aaa4' ret='echo' + ble/test 'ble/alias#expand aaa3' ret='aaa4' + ble/test 'ble/alias#expand aaa2' ret='aaa3 hello' + ble/test 'ble/alias#expand aaa1' ret='aaa2 world' +) +if ((_ble_bash>=40000)); then + ( + ble/test 'echo 1 | { sleep 0.01; ble/util/is-stdin-ready; }' + [[ ${CI-} == true && ${GITHUB_ACTION-} && $OSTYPE == msys* ]] || + ble/test 'sleep 0.01 | ble/util/is-stdin-ready' exit=1 + ble/test 'ble/util/is-stdin-ready <<< a' + ble/test 'ble/util/is-stdin-ready <<< ""' + ble/test ': | { sleep 0.01; ble/util/is-stdin-ready; }' + ble/test 'ble/util/is-stdin-ready < /dev/null' + ) +fi +ble/test ble/util/is-running-in-subshell exit=1 +( ble/test ble/util/is-running-in-subshell ) +( + ble/test/chdir || exit + function getpid { + sh -c 'printf %s $PPID' >| a.txt + ble/util/readfile ppid a.txt + } + dummy=modification_to_environment.1 + ble/util/getpid + ble/test '[[ $BASHPID != $$ ]]' + getpid + ble/test code:'ret=$BASHPID' ret="$ppid" + pid1=$BASHPID + ( + dummy=modification_to_environment.2 + ble/util/getpid + ble/test '[[ $BASHPID != $$ && $BASHPID != $pid1 ]]' + getpid + ble/test '[[ $BASHPID == $ppid ]]' + ) + ble/test/rmdir +) +( + ble/test 'ble/fd#is-open 1' + ble/test 'ble/fd#is-open 2' + exec 9>&- + ble/test 'ble/fd#is-open 9' exit=1 + exec 9>/dev/null + ble/test 'ble/fd#is-open 9' + exec 9>&- + ble/test 'ble/fd#is-open 9' exit=1 +) +( + ble/test/chdir || exit + ble/fd#alloc fd '> a.txt' + ble/util/print hello >&"$fd" + ble/util/print world >&"$fd" + if ((_ble_bash/100!=301)); then + ble/test 'ble/fd#close fd; echo test >&"$fd"' exit=1 + ble/test 'cat a.txt' stdout={hello,world} + fi + ble/test/rmdir +) +( + xv1='' + xv2a='a' xv2b='ab' + xv3a=' ' xv3b='a b' + xv4a=$'\n' xv4b=$'a\nb' + xv5a=$'\r' xv5b=$'a\rb' + xv6a=$'\x01' xv6b=a$'\x01'b + xv7a=$'\x02' xv7b=a$'\x02'b + xv8a=$'\x7F' xv8b=a$'\x7F'b + builtin eval -- "$( + for name in v1 v{2..8}{a,b}; do + builtin eval "$name=\$x$name" + done + ble/util/declare-print-definitions vn v1 v{2..8}{a,b} 2>/dev/null)" + ble/test '[[ ! ${vn+set} ]]' + for name in v1 v{2..8}{a,b}; do + ble/test "declare -p $name x$name | cat -v >&2; [[ \$$name == \$x$name ]]" + done + function status { builtin eval 'ret="${#'$1'[*]}:(""${'$1'[*]}"")"'; } + xa0=() sa0='0:()' + xa1=('') sa1='1:()' + for k in {2..8}; do + builtin eval "xa$k=(); xa$k[0]=\"\$xv${k}a\"; xa$k[1]=\"\$xv${k}b\"" + builtin eval "sa$k=\"2:(\$xv${k}a \$xv${k}b)\"" + done + builtin eval -- "$( + for name in a0 a1 a{2..8}; do + builtin eval "$name=(\"\${x$name[@]}\")" + done + ble/util/declare-print-definitions a0 a1 a{2..8} 2>/dev/null)" + for name in a0 a1 a{2..8}; do + [[ $name == a5 && $OSTYPE == msys* ]] && continue + stdout_var=s$name + ble/test "status $name" ret="${!stdout_var}" + done +) +( + function status { builtin eval 'ble/util/print "${#'$1'[*]}:(""${'$1'[*]}"")"'; } + v1=123 v2=(1 2 3) v3=bbb v4=ccc + function f2 { + local v3=x v4=y + builtin eval -- "$(ble/util/print-global-definitions v{0..4})" + ble/test '[[ ! ${v0+set} ]]' + ble/test 'status v1' stdout='1:(123)' + ble/test 'status v2' stdout='3:(1 2 3)' + ble/test 'status v3' stdout='1:(bbb)' + ble/test 'status v4' stdout='1:(ccc)' + } + function f1 { + local v0=1 v1=2 v2=3 v4=5 + f2 + ble/test 'status v1' stdout='1:(2)' + ble/test 'status v2' stdout='1:(3)' + } + f1 + value="hello 'world'" + ble/test 'ble/util/print-global-definitions value' stdout="declare value='hello '\''world'\'''" +) +( + ble/test 'ble/util/has-glob-pattern "a*"' + ble/test 'ble/util/has-glob-pattern "a*b"' + ble/test 'ble/util/has-glob-pattern "?"' + ble/test 'ble/util/has-glob-pattern "a?"' + ble/test 'ble/util/has-glob-pattern "a?b"' + ble/test 'ble/util/has-glob-pattern "a?b*c"' + ble/test 'ble/util/has-glob-pattern "a[a-c]d"' + ble/test 'ble/util/has-glob-pattern "a[!a-c]d"' + ble/test 'ble/util/has-glob-pattern "*.txt"' + ble/test 'ble/util/has-glob-pattern "*.*"' + ble/test 'ble/util/has-glob-pattern ""' exit=1 + ble/test 'ble/util/has-glob-pattern "a"' exit=1 + ble/test 'ble/util/has-glob-pattern "abc"' exit=1 + ble/test 'ble/util/has-glob-pattern "/"' exit=1 + ble/test 'ble/util/has-glob-pattern "a/c"' exit=1 + ble/test 'ble/util/has-glob-pattern "a:b"' exit=1 + ble/test 'ble/util/has-glob-pattern "a=b"' exit=1 + ble/test 'ble/util/has-glob-pattern "\[xyz\]"' exit=1 +) +( + shopt -s failglob + shopt -s nullglob + shopt -s extglob + ble/util/eval-pathname-expansion 'non-existent-*-file' canonical + ble/test 'shopt -q failglob' + ble/test 'shopt -q nullglob' + ble/test 'shopt -q extglob' +) +if ! [[ ${CI-} == true && ${GITHUB_ACTION-} ]]; then + ble/util/msleep/.calibrate-loop &>/dev/null + ble/util/msleep/.calibrate-loop &>/dev/null + ble/util/msleep/.calibrate-loop &>/dev/null + ( + ble/test 'ble-measure -q "ble/util/msleep 100"; echo "$ret usec" >&2; ((msec=ret/1000,90<=msec&&msec<=120))' + ble/test 'ble-measure -q "ble/util/sleep 0.1"; echo "$ret usec" >&2; ((msec=ret/1000,90<=msec&&msec<=120))' + ) +fi +( + time=0 + ble/function#push ble/util/msleep '((time+=$1));ble/util/print $time' + ble/test "ble/util/conditional-sync 'ble/bin/sleep 10' '((time<1000))' 100" \ + stdout={1..10}00 + ble/test "ble/util/conditional-sync 'ble/bin/sleep 10' '((time<1000))' 100 progressive-weight" \ + stdout={1,3,7,15,31,63,{1..10}27} + ble/test "ble/util/conditional-sync 'ble/bin/sleep 10' 'true' 100 timeout=10" stdout=10 exit=142 + ble/test "ble/util/conditional-sync 'echo unexpected' 'true' 100 timeout=0" stdout= exit=142 + ble/bin/sleep 10 & pid1=$! + ble/test "ble/util/conditional-sync 'echo unexpected' 'true' 100 timeout=0:pid=$pid1" stdout= exit=142 + ble/bin/sleep 10 & pid2=$! + ble/test "ble/util/conditional-sync 'echo unexpected' 'true' 100 timeout=-1:pid=$pid2" stdout= exit=142 + set -m; ble/bin/sleep 10 & pid3=$!; set +m + ble/test "ble/util/conditional-sync 'echo unexpected' 'true' 100 timeout=0:pid=-$pid3" stdout= exit=142 + if [[ $OSTYPE == cygwin* || $OSTYPE == msys* ]]; then + ble/bin/sleep 0.20 + else + ble/bin/sleep 0.02 + fi + ble/test 'kill -0 "$pid1"' exit=1 + ble/test 'kill -0 "$pid2"' exit=1 + ble/test 'kill -0 "$pid3"' exit=1 + ble/function#pop ble/util/msleep +) +( + function ble/test:ble/util/cat { { ble/util/cat; ble/util/print x; } | cat -v; } + ble/test ":| ble/test:ble/util/cat" stdout=x + ble/test "printf a | ble/test:ble/util/cat" stdout=ax + ble/test "printf '\0' | ble/test:ble/util/cat" stdout=^@x + ble/test "printf 'hello\nworld\n'| ble/test:ble/util/cat" stdout={hello,world,x} + ble/test "printf 'hello\nworld'| ble/test:ble/util/cat" stdout={hello,worldx} + ble/test "printf 'hello\0world\0'| ble/test:ble/util/cat" stdout=hello^@world^@x + ble/test "printf 'hello\0world'| ble/test:ble/util/cat" stdout=hello^@worldx +) +( + bleopt_pager=xxx PAGER=yyy + ble/test 'ble/util/get-pager ret' ret=xxx + bleopt_pager=xxx PAGER= + ble/test 'ble/util/get-pager ret' ret=xxx + bleopt_pager= PAGER=yyy + ble/test 'ble/util/get-pager ret' ret=yyy + bleopt_pager= PAGER= + ble/test 'ble/util/get-pager ret' ret=less +) +( + bleopt_pager=cat + ble/test 'ble/util/pager <<< hello' stdout=hello +) +( + _ble_util_fd_tui_stderr=1 # ble/util/buffer.flush write outputs to this fd. + ble/util/buffer.clear + ble/test 'ble/util/buffer.flush' stdout= + ble/util/buffer hello + ble/util/buffer world + ble/test 'ble/util/buffer.flush' stdout=helloworld + ble/test 'ble/util/buffer.flush' stdout= + ble/util/buffer.print hello + ble/util/buffer.print world + ble/test 'ble/util/buffer.flush' stdout={hello,world} + ble/test 'ble/util/buffer.flush' stdout= + ble/util/buffer.print hello + ble/util/buffer.print world + ble/util/buffer.clear + ble/test 'ble/util/buffer.flush' stdout= +) +( + ubeg=3 uend=10 uend0=5 + beg=0 end=5 end0=3 + ble/dirty-range#load --prefix=u + ble/test 'echo "$beg:$end:$end0"' stdout=3:10:5 + ubeg=3 uend=10 uend0=5 + ble/dirty-range#clear --prefix=u + ble/test 'echo "$ubeg:$uend:$uend0"' stdout=-1:-1:-1 + ble/dirty-range#update --prefix=u 0 5 2 + ble/test 'echo "$ubeg:$uend:$uend0"' stdout=0:5:2 + ble/dirty-range#update --prefix=u 10 10 12 + ble/test 'echo "$ubeg:$uend:$uend0"' stdout=0:10:9 + ble/dirty-range#clear --prefix=u + ble/dirty-range#update --prefix=u 2 2 3 + ble/dirty-range#update --prefix=u 2 2 3 + ble/test 'echo "$ubeg:$uend:$uend0"' stdout=2:2:4 + ble/dirty-range#clear --prefix=u + ble/dirty-range#update --prefix=u 1 5 3 + ble/dirty-range#update --prefix=u 7 11 9 + ble/test 'echo "$ubeg:$uend:$uend0"' stdout=1:11:7 + ble/dirty-range#clear --prefix=u + ble/dirty-range#update --prefix=u 1 7 5 + ble/dirty-range#update --prefix=u 4 15 11 + ble/test 'echo "$ubeg:$uend:$uend0"' stdout=1:15:9 + ble/dirty-range#clear --prefix=u + ble/dirty-range#update --prefix=u 1 7 5 + ble/dirty-range#update --prefix=u 3 4 5 + ble/test 'echo "$ubeg:$uend:$uend0"' stdout=1:6:5 + ble/dirty-range#clear --prefix=u + ble/dirty-range#update --prefix=u 4 8 6 + ble/dirty-range#update --prefix=u 2 8 10 + ble/test 'echo "$ubeg:$uend:$uend0"' stdout=2:8:8 + ble/dirty-range#clear --prefix=u + ble/dirty-range#update --prefix=u 6 12 8 + ble/dirty-range#update --prefix=u 3 7 8 + ble/test 'echo "$ubeg:$uend:$uend0"' stdout=3:11:8 + ble/dirty-range#clear --prefix=u + ble/dirty-range#update --prefix=u 10 13 11 + ble/dirty-range#update --prefix=u 3 7 8 + ble/test 'echo "$ubeg:$uend:$uend0"' stdout=3:12:11 +) +( + ble/function#try ble/util/idle.clear + ble/util/buffer.clear + blehook idle_after_task= + ble/function#push ble/util/idle/IS_IDLE '((1))' + ble/test/chdir || exit + ble/util/print 'ble/util/print FILE1' >| FILE1.txt + ble/util/print 'ble/util/print FILE2' >| FILE2.txt + ble/util/print 'ble/util/print FILE3' >| FILE3.txt + ( + ble-import FILE1.txt -C 'ble/util/print loaded1' + ble-import FILE1.txt -C 'ble/util/print loaded2' + ble-import FILE1.txt -C 'ble/util/print loaded3' -C 'ble/util/print loaded4' + ble-import FILE1.txt FILE2.txt -C 'ble/util/print both1' -C 'ble/util/print both2' + ( + if ble/is-function ble/util/idle.push; then + ble/test 'ble/util/idle.do' stdout= + fi + ble/test 'ble-import FILE1.txt' stdout=$'FILE1\nloaded1\nloaded2\nloaded3\nloaded4' + ble/test 'ble-import FILE2.txt' stdout=$'FILE2\nboth1\nboth2' + ) + ( + ble/test 'ble-import FILE2.txt' stdout='FILE2' + ble/test 'ble-import FILE1.txt' stdout=$'FILE1\nloaded1\nloaded2\nloaded3\nloaded4\nboth1\nboth2' + ) + ) + ( + ble-import FILE1.txt FILE2.txt FILE3.txt -C 'ble/util/print triple' + ble/test 'ble-import FILE2.txt' stdout='FILE2' + ble/test 'ble-import FILE3.txt' stdout='FILE3' + ble/test 'ble-import FILE1.txt' stdout=$'FILE1\ntriple' + ) + if ble/is-function ble/util/idle.push; then + ( + ble-import FILE1.txt FILE2.txt -dC 'ble/util/print both' + ble/test 'ble/util/idle.do' stdout=$'FILE1\nFILE2\nboth' + ) + fi + ble/test/rmdir +) +( + ble/test $'ble/util/s2c "\n"' ret=10 + ble/test 'ble/util/c2s 10' ret=$'\n' + ble/test $'ble/util/s2c "\x1b"' ret=27 + ble/test 'ble/util/c2s 27' ret=$'\x1b' + ble/test $'ble/util/s2c "\x1F"' ret=31 + ble/test 'ble/util/c2s 31' ret=$'\x1F' + c=$'\x7F' ble/test 'ble/util/s2c $c' ret=127 # bash-3.0 bug WA + ble/test 'ble/util/c2s 127' ret=$'\x7F' + ble/test 'ble/util/s2c " "' ret=32 + ble/test 'ble/util/c2s 32' ret=' ' + ble/test 'ble/util/s2c a' ret=97 + ble/test 'ble/util/c2s 97' ret=a + ble/test 'ble/util/s2c μ' ret=956 + ble/test 'ble/util/c2s 956' ret=μ + ble/test 'ble/util/s2c あ' ret=12354 + ble/test 'ble/util/c2s 12354' ret=あ + ble/test 'ble/util/s2c' ret=0 + ble/test 'ble/util/s2c abc' ret=97 + ble/test 'ble/util/s2c μν' ret=956 + ble/test 'ble/util/s2c あいう' ret=12354 + ble/test 'ble/util/c2s.cached 32' ret=' ' + ble/test 'ble/util/c2s.cached 97' ret=a + ble/test 'ble/util/c2s.cached 956' ret=μ + ble/test 'ble/util/c2s.cached 12354' ret=あ + LC_ALL=C + ble/test 'ble/util/c2s 97' ret=a + ble/test 'ble/util/c2s 956; [[ $ret != μ ]]' + ble/test 'ble/util/c2s 12354; [[ $ret != あ ]]' +) +( + ble/test 'ble/util/c2bc 97' ret=1 + ble/test 'ble/util/c2bc 956' ret=2 + ble/test 'ble/util/c2bc 12354' ret=3 + ble/test 'ble/util/c2bc 0' ret=1 + ble/test 'ble/util/c2bc 127' ret=1 + ble/test 'ble/util/c2bc 128' ret=2 + ble/test 'ble/util/c2bc 2047' ret=2 + ble/test 'ble/util/c2bc 2048' ret=3 + ble/test 'ble/util/c2bc 65535' ret=3 + ble/test 'ble/util/c2bc 65536' ret=4 +) +( + ble/test 'ble/util/s2chars AaBbCc; ret="${ret[*]}"' ret='65 97 66 98 67 99' + ble/test 'ble/util/chars2s 65 97 66 98 67 99' ret=AaBbCc + ble/test 'ble/util/s2chars あいう; ret="${ret[*]}"' ret='12354 12356 12358' + ble/test 'ble/util/chars2s 12354 12356 12358' ret=あいう + ble/test 'ble/util/s2chars; ret="${ret[*]}"' ret= + ble/test 'ble/util/s2chars 0; ret="${ret[*]}"' ret=48 + ble/test 'ble/util/s2chars a; ret="${ret[*]}"' ret=97 + ble/test 'ble/util/s2chars μ; ret="${ret[*]}"' ret=956 + ble/test 'ble/util/s2chars あ; ret="${ret[*]}"' ret=12354 + ble/test 'ble/util/chars2s' ret= + ble/test 'ble/util/chars2s 48' ret=0 + ble/test 'ble/util/chars2s 97' ret=a + ble/test 'ble/util/chars2s 956' ret=μ + ble/test 'ble/util/chars2s 12354' ret=あ +) +( + function check1 { + local char=$1 keyseq=$2 + ble/test "ble/util/c2keyseq $char" ret="$keyseq" + ble/test "ble/util/chars2keyseq $char" ret="$keyseq" + ble/test "ble/util/keyseq2chars '$keyseq'; ret=\"\${ret[*]}\"" ret="${3:-$char}" + ble/test "ble/util/chars2keyseq 98 $char 99" ret="b${keyseq}c" + ble/test "ble/util/keyseq2chars 'b${keyseq}c'; ret=\"\${ret[*]}\"" ret="98 ${3:-$char} 99" + } + check1 '7' '\a' + check1 '8' '\b' + check1 '9' '\t' + check1 '10' '\n' + check1 '11' '\v' + check1 '12' '\f' + check1 '13' '\r' + check1 '27' '\e' + check1 '127' '\d' + check1 '92' '\\' + check1 '28' '\x1c' # workaround bashbug \C-\, \C-\\ + check1 '156' '\x9c' # workaround bashbug \C-\, \C-\\ + check1 '0' '\C-@' + check1 '1' '\C-a' + check1 '26' '\C-z' + check1 '29' '\C-]' + check1 '30' '\C-^' + check1 '31' '\C-_' + check1 '128' '\M-\C-@' '27 0' + check1 '64' '@' + check1 '97' 'a' + check1 '956' 'μ' + check1 '12354' 'あ' + ble/test ble/util/c2keyseq ret='\C-@' + ble/test ble/util/chars2keyseq ret= + ble/test ble/util/keyseq2chars ret= +) +( + function pack { ret="${bytes[*]}"; } + ble/test 'ble/encoding:UTF-8/b2c ' ret=0 + ble/test 'ble/encoding:UTF-8/b2c 97' ret=97 + ble/test 'ble/encoding:UTF-8/b2c 97 98 99 99' ret=97 + ble/test 'ble/encoding:UTF-8/b2c 206 188 99 99' ret=956 + ble/test 'ble/encoding:UTF-8/b2c 227 129 130 99' ret=12354 + ble/test 'ble/encoding:UTF-8/c2b 97 ; pack' ret=97 + ble/test 'ble/encoding:UTF-8/c2b 956 ; pack' ret='206 188' + ble/test 'ble/encoding:UTF-8/c2b 12354; pack' ret='227 129 130' + ble/test 'ble/encoding:UTF-8/c2b ; pack' ret=0 + ble/test 'ble/encoding:UTF-8/c2b 0 ; pack' ret=0 + ble/test 'ble/encoding:UTF-8/c2b 127 ; pack' ret=127 + ble/test 'ble/encoding:UTF-8/c2b 128 ; pack' ret='194 128' + ble/test 'ble/encoding:UTF-8/c2b 2047; pack' ret='223 191' + ble/test 'ble/encoding:UTF-8/c2b 2048; pack' ret='224 160 128' +) +( + function pack { ret="${bytes[*]}"; } + ble/test 'ble/encoding:C/b2c ' ret=0 + ble/test 'ble/encoding:C/b2c 97' ret=97 + ble/test 'ble/encoding:C/b2c 97 98 99 99' ret=97 + ble/test 'ble/encoding:C/b2c 206 188 99 99' ret=206 + ble/test 'ble/encoding:C/b2c 227 129 130 99' ret=227 + ble/test 'ble/encoding:C/b2c 97 ' ret=97 + ble/test 'ble/encoding:C/b2c 956 ' ret=188 + ble/test 'ble/encoding:C/b2c 12354 ' ret=66 + ble/test 'ble/encoding:C/c2b ; pack' ret=0 + ble/test 'ble/encoding:C/c2b 0 ; pack' ret=0 + ble/test 'ble/encoding:C/c2b 127 ; pack' ret=127 + ble/test 'ble/encoding:C/c2b 128 ; pack' ret=128 + ble/test 'ble/encoding:C/c2b 2047; pack' ret=255 + ble/test 'ble/encoding:C/c2b 2048; pack' ret=0 +) +( + function clear-locale { LC_ALL= LANG= LC_CTYPE=; } + for lang in {C,en_US,ja{_JP,}}.{UTF-8,utf8} ja_JP.{utf8,UTF-8}@cjk{wide,narrow,single}; do + clear-locale + ble/test "LANG=$lang; ble/util/is-unicode-output" + clear-locale + ble/test "LANG=C LC_CTYPE=$lang; ble/util/is-unicode-output" + clear-locale + ble/test "LC_CTYPE=C LANG=C LC_ALL=$lang; ble/util/is-unicode-output" + done + for lang in '' C POSIX UTF-8 utf8 ja_JP.eucJP; do + clear-locale + ble/test "LANG=$lang; ble/util/is-unicode-output" exit=1 + clear-locale + ble/test "LANG=C LC_CTYPE=$lang; ble/util/is-unicode-output" exit=1 + clear-locale + ble/test "LC_CTYPE=C LANG=C LC_ALL=$lang; ble/util/is-unicode-output" exit=1 + done +) +ble/test/end-section diff --git a/.local/share/blesh/lib/util.bgproc.sh b/.local/share/blesh/lib/util.bgproc.sh new file mode 100644 index 0000000..fd2053b --- /dev/null +++ b/.local/share/blesh/lib/util.bgproc.sh @@ -0,0 +1,214 @@ +# Copyright 2015 Koichi Murase . All rights reserved. +# This script is a part of blesh (https://github.com/akinomyoga/ble.sh) +# provided under the BSD-3-Clause license. Do not edit this file because this +# is not the original source code: Various pre-processing has been applied. +# Also, the code comments and blank lines are stripped off in the installation +# process. Please find the corresponding source file(s) in the repository +# "akinomyoga/ble.sh". +# +# Source: /lib/util.bgproc.sh +function ble/util/bgproc#open { + if ! ble/string#match "$1" '^[_a-zA-Z][_a-zA-Z0-9]*$'; then + ble/util/print "$FUNCNAME: $1: invalid prefix value." >&2 + return 2 + fi + ble/util/bgproc#close "$1" + local -a bgproc=() + bgproc[0]= + bgproc[1]= + bgproc[2]=$2 + bgproc[3]=${3-} + local -a bgproc_fname=() + bgproc_fname[0]=$_ble_base_run/$$.util.bgproc.$1.response.pipe + bgproc_fname[1]=$_ble_base_run/$$.util.bgproc.$1.request.pipe + bgproc_fname[2]=$_ble_base_run/$$.util.bgproc.$1.pid + ble/util/save-vars "${1}_" bgproc bgproc_fname + [[ :${bgproc[3]}: == *:deferred:* ]] || ble/util/bgproc#start "$1"; local ext=$? + if ((ext!=0)); then + builtin eval -- "${1}_bgproc=() ${1}_bgproc_fname=()" + fi + return "$ext" +} +function ble/util/bgproc#opened { + local bgpid_ref=${1}_bgproc[0] + [[ ${!bgpid_ref+set} ]] || return 2 +} +function ble/util/bgproc/.alive { + [[ ${bgproc[4]-} ]] && kill -0 "${bgproc[4]}" 2>/dev/null +} +function ble/util/bgproc/.exec { + builtin eval -- "${bgproc[2]}" <&"${bgproc[1]}" >&"${bgproc[0]}" +} +function ble/util/bgproc/.mkfifo { + local -a pipe_remove=() pipe_create=() + local i + for i in 0 1; do + [[ -p ${bgproc_fname[i]} ]] && continue + ble/array#push pipe_create "${bgproc_fname[i]}" + if [[ -e ${bgproc_fname[i]} || -h ${bgproc_fname[i]} ]]; then + ble/array#push pipe_remove "${bgproc_fname[i]}" + fi + done + ((${#pipe_remove[@]}==0)) || ble/bin/rm -f "${pipe_remove[@]}" 2>/dev/null + ((${#pipe_create[@]}==0)) || ble/bin/mkfifo "${pipe_create[@]}" 2>/dev/null +} +function ble/util/bgproc#start { + local bgproc bgproc_fname + ble/util/restore-vars "${1}_" bgproc bgproc_fname + if ((!${#bgproc[@]})); then + ble/util/print "$FUNCNAME: $1: not an existing bgproc name." >&2 + return 2 + fi + if ble/util/bgproc/.alive; then + return 0 + fi + [[ ! ${bgproc[0]-} ]] || ble/fd#close 'bgproc[0]' + [[ ! ${bgproc[1]-} ]] || ble/fd#close 'bgproc[1]' + local _ble_local_ext=0 _ble_local_bgproc0= _ble_local_bgproc1= + if ble/util/bgproc/.mkfifo && + ble/fd#alloc _ble_local_bgproc0 '<> "${bgproc_fname[0]}"' && + ble/fd#alloc _ble_local_bgproc1 '<> "${bgproc_fname[1]}"' + then + bgproc[0]=$_ble_local_bgproc0 + bgproc[1]=$_ble_local_bgproc1 + ble/util/assign 'bgproc[4]' '(set -m; ble/util/joblist/__suppress__; ble/util/bgproc/.exec >/dev/null & bgpid=$!; ble/util/print "$bgpid")' + if ble/util/bgproc/.alive; then + [[ :${bgproc[3]}: == *:no-close-on-unload:* ]] || + ble/util/print "-${bgproc[4]}" >| "${bgproc_fname[2]}" + [[ :${bgproc[3]}: == *:no-close-on-unload:* || :${bgproc[3]}: == *:owner-close-on-unload:* ]] || + blehook unload!="ble/util/bgproc#close $1" + ble/util/bgproc#keepalive "$1" + else + builtin unset -v 'bgproc[4]' + _ble_local_ext=1 + fi + else + _ble_local_ext=3 + fi + if ((_ble_local_ext!=0)); then + [[ ! ${bgproc[0]-} ]] || ble/fd#close 'bgproc[0]' + [[ ! ${bgproc[1]-} ]] || ble/fd#close 'bgproc[1]' + bgproc[0]= + bgproc[1]= + builtin unset -v 'bgproc[4]' + fi + ble/util/save-vars "${1}_" bgproc bgproc_fname + if ((_ble_local_ext==0)); then + ble/function#try ble/util/bgproc/onstart:"$1" + fi + return "$_ble_local_ext" +} +function ble/util/bgproc#stop/.kill { + local pid=$1 opts=$2 ret + local timeout=10000 + if ble/opts#extract-last-optarg "$opts" kill-timeout; then + timeout=$ret + fi + ble/util/conditional-sync '' '((1))' 1000 progressive-weight:pid="$pid":no-wait-pid:timeout="$timeout" + kill -0 "$pid" || return 0 + local timeout=10000 + if ble/opts#extract-last-optarg "$opts" kill9-timeout; then + timeout=$ret + fi + ble/util/conditional-sync '' '((1))' 1000 progressive-weight:pid="$pid":no-wait-pid:timeout="$timeout":SIGKILL +} +function ble/util/bgproc#stop { + local prefix=$1 + ble/util/bgproc#keepalive/.cancel-timeout "$prefix" + local bgproc bgproc_fname + ble/util/restore-vars "${prefix}_" bgproc bgproc_fname + if ((!${#bgproc[@]})); then + ble/util/print "$FUNCNAME: $prefix: not an existing bgproc name." >&2 + return 2 + fi + [[ ${bgproc[4]-} ]] || return 1 + if ble/is-function ble/util/bgproc/onstop:"$prefix" && ble/util/bgproc/.alive; then + ble/util/bgproc/onstop:"$prefix" + fi + ble/fd#close 'bgproc[0]' + ble/fd#close 'bgproc[1]' + >| "${bgproc_fname[2]}" + if ble/util/bgproc/.alive; then + (ble/util/nohup 'ble/util/bgproc#stop/.kill "-${bgproc[4]}" "${bgproc[3]}"') + fi + builtin eval -- "${prefix}_bgproc[0]=" + builtin eval -- "${prefix}_bgproc[1]=" + builtin unset -v "${prefix}_bgproc[4]" + return 0 +} +function ble/util/bgproc#alive { + local prefix=$1 bgproc + ble/util/restore-vars "${prefix}_" bgproc + ((${#bgproc[@]})) || return 2 + [[ ${bgproc[4]-} ]] || return 1 + kill -0 "${bgproc[4]}" 2>/dev/null || return 3 + return 0 +} +function ble/util/bgproc#keepalive/.timeout { + local prefix=$1 + if ble/is-function ble/util/bgproc/ontimeout:"$prefix"; then + if ! ble/util/bgproc/ontimeout:"$prefix"; then + ble/util/bgproc#keepalive "$prefix" + return 0 + fi + fi + ble/util/bgproc#stop "$prefix" +} +function ble/util/bgproc#keepalive/.cancel-timeout { + local prefix=$1 + ble/function#try ble/util/idle.cancel "ble/util/bgproc#keepalive/.timeout $prefix" +} +function ble/util/bgproc#keepalive { + local prefix=$1 bgproc + ble/util/restore-vars "${prefix}_" bgproc + ((${#bgproc[@]})) || return 2 + ble/util/bgproc/.alive || return 1 + ble/util/bgproc#keepalive/.cancel-timeout "$prefix" + local ret + ble/opts#extract-last-optarg "${bgproc[3]}" timeout || return 0; local bgproc_timeout=$ret + if ((bgproc_timeout>0)); then + local timeout_proc="ble/util/bgproc#keepalive/.timeout $1" + ble/function#try ble/util/idle.push --sleep="$bgproc_timeout" "$timeout_proc" + fi + return 0 +} +_ble_util_bgproc_onclose_processing= +function ble/util/bgproc#close { + ble/util/bgproc#opened "$1" || return 2 + local prefix=${1} + blehook unload-="ble/util/bgproc#close $prefix" + ble/util/bgproc#keepalive/.cancel-timeout "$prefix" + if ble/is-function ble/util/bgproc/onclose:"$prefix"; then + if [[ :${_ble_util_bgproc_onclose_processing-}: != *:"$prefix":* ]]; then + local _ble_util_bgproc_onclose_processing=${_ble_util_bgproc_onclose_processing-}:$prefix + ble/util/bgproc/onclose:"$prefix" + fi + fi + ble/util/bgproc#stop "$prefix" + builtin eval -- "${prefix}_bgproc=() ${prefix}_bgproc_fname=()" +} +function ble/util/bgproc#use { + local bgproc + ble/util/restore-vars "${1}_" bgproc + if ((!${#bgproc[@]})); then + ble/util/print "$FUNCNAME: $1: not an existing bgproc name." >&2 + return 2 + fi + if [[ ! ${bgproc[4]-} ]]; then + ble/util/bgproc#start "$1" || return "$?" + elif ! kill -0 "${bgproc[4]-}"; then + if [[ :${bgproc[3]-}: == *:restart:* ]]; then + ble/util/bgproc#start "$1" || return "$?" + else + return 1 + fi + else + ble/util/bgproc#keepalive "$1" + return 0 + fi +} +function ble/util/bgproc#post { + ble/util/bgproc#use "$1" || return "$?" + local fd1_ref=${1}_bgproc[1] + ble/util/print "$2" >&"${!fd1_ref}" +} diff --git a/.local/share/blesh/lib/vim-airline.sh b/.local/share/blesh/lib/vim-airline.sh new file mode 100644 index 0000000..66c0b6e --- /dev/null +++ b/.local/share/blesh/lib/vim-airline.sh @@ -0,0 +1,339 @@ +# Copyright 2015 Koichi Murase . All rights reserved. +# This script is a part of blesh (https://github.com/akinomyoga/ble.sh) +# provided under the BSD-3-Clause license. Do not edit this file because this +# is not the original source code: Various pre-processing has been applied. +# Also, the code comments and blank lines are stripped off in the installation +# process. Please find the corresponding source file(s) in the repository +# "akinomyoga/ble.sh". +# +# Source: /lib/vim-airline.sh +ble-import keymap.vi +ble-import prompt-git +bleopt/declare -n vim_airline_theme dark +function bleopt/check:vim_airline_theme { + local init=ble/lib/vim-airline/theme:"$value"/initialize + if ! ble/is-function "$init"; then + local ret + if ! ble/util/import/search "airline/$value"; then + ble/util/print "ble/lib/vim-airline: theme '$value' not found." >&2 + return 1 + fi + ble/util/import "$ret" + ble/is-function "$init" || return 1 + fi + "$init" + return 0 +} +bleopt/declare -v vim_airline_section_a '\e[1m\q{lib/vim-airline/mode}' +bleopt/declare -v vim_airline_section_b '\q{lib/vim-airline/gitstatus}' +bleopt/declare -v vim_airline_section_c '\w' +bleopt/declare -v vim_airline_section_x 'bash' +bleopt/declare -v vim_airline_section_y '$_ble_util_locale_encoding[unix]' +bleopt/declare -v vim_airline_section_z ' \q{history-percentile} \e[1m!\q{history-index}/\!\e[22m \q{position}' +bleopt/declare -v vim_airline_left_sep $'\uE0B0' +bleopt/declare -v vim_airline_left_alt_sep $'\uE0B1' +bleopt/declare -v vim_airline_right_sep $'\uE0B2' +bleopt/declare -v vim_airline_right_alt_sep $'\uE0B3' +bleopt/declare -v vim_airline_symbol_branch $'\uE0A0' +bleopt/declare -v vim_airline_symbol_dirty $'\u26A1' +function bleopt/check:vim_airline_left_sep { ble/prompt/unit#clear _ble_prompt_status; } +function bleopt/check:vim_airline_left_alt_sep { ble/prompt/unit#clear _ble_prompt_status; } +function bleopt/check:vim_airline_right_sep { ble/prompt/unit#clear _ble_prompt_status; } +function bleopt/check:vim_airline_right_alt_sep { ble/prompt/unit#clear _ble_prompt_status; } +builtin eval -- "${_ble_util_gdict_declare//NAME/_ble_lib_vim_airline_mode_map_default}" +ble/gdict#set _ble_lib_vim_airline_mode_map_default 'i' 'INSERT' +ble/gdict#set _ble_lib_vim_airline_mode_map_default 'n' 'NORMAL' +ble/gdict#set _ble_lib_vim_airline_mode_map_default 'in' '(INSERT)' +ble/gdict#set _ble_lib_vim_airline_mode_map_default 'o' 'OP PENDING' +ble/gdict#set _ble_lib_vim_airline_mode_map_default 'R' 'REPLACE' +ble/gdict#set _ble_lib_vim_airline_mode_map_default '' 'V REPLACE' +ble/gdict#set _ble_lib_vim_airline_mode_map_default 'v' 'VISUAL' +ble/gdict#set _ble_lib_vim_airline_mode_map_default 'V' 'V-LINE' +ble/gdict#set _ble_lib_vim_airline_mode_map_default '' 'V-BLOCK' +ble/gdict#set _ble_lib_vim_airline_mode_map_default 's' 'SELECT' +ble/gdict#set _ble_lib_vim_airline_mode_map_default 'S' 'S-LINE' +ble/gdict#set _ble_lib_vim_airline_mode_map_default '' 'S-BLOCK' +ble/gdict#set _ble_lib_vim_airline_mode_map_default '?' '------' +ble/gdict#set _ble_lib_vim_airline_mode_map_default 'c' 'COMMAND' +builtin eval -- "${_ble_util_gdict_declare//NAME/_ble_lib_vim_airline_mode_map_atomic}" +ble/gdict#set _ble_lib_vim_airline_mode_map_atomic 'i' 'I' +ble/gdict#set _ble_lib_vim_airline_mode_map_atomic 'n' 'N' +ble/gdict#set _ble_lib_vim_airline_mode_map_atomic 'R' 'R' +ble/gdict#set _ble_lib_vim_airline_mode_map_atomic 'v' 'V' +ble/gdict#set _ble_lib_vim_airline_mode_map_atomic 'V' 'V-L' +ble/gdict#set _ble_lib_vim_airline_mode_map_atomic '' 'V-B' +ble/gdict#set _ble_lib_vim_airline_mode_map_atomic 's' 'S' +ble/gdict#set _ble_lib_vim_airline_mode_map_atomic 'S' 'S-L' +ble/gdict#set _ble_lib_vim_airline_mode_map_atomic '' 'S-B' +ble/gdict#set _ble_lib_vim_airline_mode_map_atomic '?' '--' +ble/gdict#set _ble_lib_vim_airline_mode_map_atomic 'c' 'C' +builtin eval -- "${_ble_util_gdict_declare//NAME/_ble_lib_vim_airline_mode_map}" +ble/gdict#cp _ble_lib_vim_airline_mode_map_default _ble_lib_vim_airline_mode_map +function ble/lib/vim-airline/initialize-faces { + ble/color/defface vim_airline_a fg=17,bg=45 + ble/color/defface vim_airline_b fg=231,bg=27 + ble/color/defface vim_airline_c fg=231,bg=18 + ble/color/defface vim_airline_error fg=16,bg=88 # fg=#000000,bg=#990000 + ble/color/defface vim_airline_term fg=158,bg=234 # fg=#9cffd3,bg=#202020 + ble/color/defface vim_airline_warning fg=16,bg=166 # fg=#000000,bg=#df5f00 + local section map + for section in a b c error term warning; do + for map in _normal _insert _visual _commandline _inactive; do + ble/color/defface "vim_airline_$section$map" ref:"vim_airline_$section" + done + ble/color/defface "vim_airline_${section}_replace" ref:"vim_airline_${section}_insert" + done + local map + for map in '' _normal _insert _replace _visual _commandline _inactive; do + ble/color/defface "vim_airline_x$map" ref:"vim_airline_c$map" + ble/color/defface "vim_airline_y$map" ref:"vim_airline_b$map" + ble/color/defface "vim_airline_z$map" ref:"vim_airline_a$map" + done + local name + for name in {a,b,c,x,y,z,error,term,warning}{,_normal,_insert,_replace,_visual,_commandline,_inactive}; do + ble/color/defface "vim_airline_${name}_modified" ref:"vim_airline_$name" + done +} +ble/lib/vim-airline/initialize-faces +function ble/lib/vim-airline/convert-theme/.to-color256 { + local R=$((16#${1:1:2})) + local G=$((16#${1:3:2})) + local B=$((16#${1:5:2})) + ble/color/convert-rgb24-to-color256 "$R" "$G" "$B" +} +function ble/lib/vim-airline/convert-theme/.setface { + local gspec= + local ret + ble/lib/vim-airline/convert-theme/.to-color256 "$2"; local fg=$ret + ble/lib/vim-airline/convert-theme/.to-color256 "$3"; local bg=$ret + printf 'ble/color/setface vim_airline_%-13s %-13s # %s\n' "$1" "fg=$fg,bg=$bg" "fg=$2,bg=$3" +} +function ble/lib/vim-airline/convert-theme { + local file=$1 + sed -n 's/let s:airline_\([_a-zA-Z0-9]\{1,\}\)[^[:alnum:]]\{1,\}\(\#[0-9a-fA-F]\{6\}\)[^[:alnum:]]\{1,\}\(\#[0-9a-fA-F]\{6\}\).*/\1 \2 \3/p' "$file" | + while ble/bash/read face fg bg; do + ble/lib/vim-airline/convert-theme/.setface "$face" "$fg" "$bg" + done +} +ble/color/setface vim_airline_a_normal fg=17,bg=190 # fg=#00005f,bg=#dfff00 +ble/color/setface vim_airline_b_normal fg=231,bg=238 # fg=#ffffff,bg=#444444 +ble/color/setface vim_airline_c_normal fg=158,bg=234 # fg=#9cffd3,bg=#202020 +ble/color/setface vim_airline_a_insert fg=17,bg=45 # fg=#00005f,bg=#00dfff +ble/color/setface vim_airline_b_insert fg=231,bg=27 # fg=#ffffff,bg=#005fff +ble/color/setface vim_airline_c_insert fg=231,bg=18 # fg=#ffffff,bg=#000080 +ble/color/setface vim_airline_a_visual fg=16,bg=214 # fg=#000000,bg=#ffaf00 +ble/color/setface vim_airline_b_visual fg=16,bg=202 # fg=#000000,bg=#ff5f00 +ble/color/setface vim_airline_c_visual fg=231,bg=52 # fg=#ffffff,bg=#5f0000 +ble/color/setface vim_airline_a_inactive fg=239,bg=234 # fg=#4e4e4e,bg=#1c1c1c +ble/color/setface vim_airline_b_inactive fg=239,bg=235 # fg=#4e4e4e,bg=#262626 +ble/color/setface vim_airline_c_inactive fg=239,bg=236 # fg=#4e4e4e,bg=#303030 +ble/color/setface vim_airline_a_commandline fg=17,bg=40 # fg=#00005f,bg=#00d700 +ble/color/setface vim_airline_b_commandline fg=231,bg=238 # fg=#ffffff,bg=#444444 +ble/color/setface vim_airline_c_commandline fg=158,bg=234 # fg=#9cffd3,bg=#202020 +_ble_lib_vim_airline_mode_data=() +_ble_lib_vim_airline_keymap= +_ble_lib_vim_airline_mode= +_ble_lib_vim_airline_rawmode= +function ble/prompt/unit:_ble_lib_vim_airline_mode/update { + local keymap mode m + ble/keymap:vi/script/get-vi-keymap + ble/keymap:vi/script/get-mode + case $mode in + (i*) m='insert' ;; + ([R]*) m='replace' ;; + (*[vVsS]) m='visual' ;; + (*c) m='commandline' ;; + (*n) m='normal' ;; + (*) m='inactive' ;; + esac + ble/prompt/unit/add-hash '$_ble_edit_str' + ble/prompt/unit/add-hash '$_ble_history_INDEX' + local entry + ble/history/get-entry "$_ble_history_INDEX" + [[ $_ble_edit_str != "$entry" ]] && m=${m}_modified + ble/prompt/unit/assign _ble_lib_vim_airline_keymap "$keymap" + ble/prompt/unit/assign _ble_lib_vim_airline_mode "$m" + ble/prompt/unit/assign _ble_lib_vim_airline_rawmode "$mode" + [[ $prompt_unit_changed ]] +} +_ble_lib_vim_airline_sep_width_data=() +function ble/prompt/unit:_ble_lib_vim_airline_sep_width/update { + ble/prompt/unit/add-hash '$bleopt_char_width_version,$bleopt_char_width_mode' + ble/prompt/unit/add-hash '$bleopt_emoji_version,$bleopt_emoji_width,$bleopt_emoji_opts' + local w ret x y g + ((x=0,y=0,g=0)) + LINES=1 COLUMNS=$cols ble/canvas/trace "$bleopt_vim_airline_left_sep" confine + ((w=x,x=0,y=0,g=0)) + LINES=1 COLUMNS=$cols ble/canvas/trace "$bleopt_vim_airline_left_alt_sep" confine + ((w=x>w?x:w)) + ble/prompt/unit/add-hash '$bleopt_vim_airline_left_sep' + ble/prompt/unit/add-hash '$bleopt_vim_airline_left_alt_sep' + ble/prompt/unit/assign '_ble_lib_vim_airline_sep_width_data[3]' "$w" + ((x=0,y=0,g=0)) + LINES=1 COLUMNS=$cols ble/canvas/trace "$bleopt_vim_airline_right_sep" confine + ((w=x,x=0,y=0,g=0)) + LINES=1 COLUMNS=$cols ble/canvas/trace "$bleopt_vim_airline_right_alt_sep" confine + ((w=x>w?x:w)) + ble/prompt/unit/add-hash '$bleopt_vim_airline_right_sep' + ble/prompt/unit/add-hash '$bleopt_vim_airline_right_alt_sep' + ble/prompt/unit/assign '_ble_lib_vim_airline_sep_width_data[4]' "$w" + [[ $prompt_unit_changed ]] +} +function ble/prompt/backslash:lib/vim-airline/mode/.resolve { + local raw=$1 + if ble/gdict#has _ble_lib_vim_airline_mode_map "$raw"; then + ble/gdict#get _ble_lib_vim_airline_mode_map "$raw" + else + case $raw in + (o) ble/prompt/backslash:lib/vim-airline/mode/.resolve "$_ble_lib_vim_airline_rawmode" ;; + ([iR]?*) ble/prompt/backslash:lib/vim-airline/mode/.resolve "${raw::1}" ;; + (*?[ncvVsS]) ble/prompt/backslash:lib/vim-airline/mode/.resolve "${raw:${#raw}-1}" ;; + () ble/prompt/backslash:lib/vim-airline/mode/.resolve R ;; + (R) ble/prompt/backslash:lib/vim-airline/mode/.resolve i ;; + ([S]) ble/prompt/backslash:lib/vim-airline/mode/.resolve s ;; + ([Vs]) ble/prompt/backslash:lib/vim-airline/mode/.resolve v ;; + ([ivnc]) + ret= + case $_ble_lib_vim_airline_rawmode in + (i*) ret=$bleopt_keymap_vi_mode_name_insert ;; + (R*) ret=$bleopt_keymap_vi_mode_name_replace ;; + (*) ret=$bleopt_keymap_vi_mode_name_vreplace ;; + esac + [[ $_ble_lib_vim_airline_rawmode == [iR]?* ]] && + ble/string#tolower "($insert) " + case $_ble_lib_vim_airline_rawmode in + (*n) + if [[ ! $ret ]]; then + local rex='[[:alnum:]](.*[[:alnum:]])?' + [[ $bleopt_keymap_vi_mode_string_nmap =~ $rex ]] + ret=${BASH_REMATCH[0]:-NORMAL} + fi ;; + (*v) ret="${ret}${ret:+ }$bleopt_keymap_vi_mode_name_visual" ;; + (*V) ret="${ret}${ret:+ }$bleopt_keymap_vi_mode_name_visual $bleopt_keymap_vi_mode_name_line" ;; + (*) ret="${ret}${ret:+ }$bleopt_keymap_vi_mode_name_visual $bleopt_keymap_vi_mode_name_block" ;; + (*s) ret="${ret}${ret:+ }$bleopt_keymap_vi_mode_name_select" ;; + (*S) ret="${ret}${ret:+ }$bleopt_keymap_vi_mode_name_select $bleopt_keymap_vi_mode_name_line" ;; + (*) ret="${ret}${ret:+ }$bleopt_keymap_vi_mode_name_select $bleopt_keymap_vi_mode_name_block" ;; + (*c) ret="${ret}${ret:+ }COMMAND" ;; + esac + [[ $ret ]] || + ble/prompt/backslash:lib/vim-airline/mode/.resolve '?' ;; + (*) ret='?__' ;; + esac + fi +} +function ble/prompt/backslash:lib/vim-airline/mode { + local ret + if [[ $_ble_lib_vim_airline_keymap == vi_omap ]]; then + ble/prompt/backslash:lib/vim-airline/mode/.resolve o + else + ble/prompt/backslash:lib/vim-airline/mode/.resolve "$_ble_lib_vim_airline_rawmode" + fi + [[ $ret ]] && ble/prompt/print "$ret" +} +function ble/prompt/backslash:lib/vim-airline/gitstatus { + local "${_ble_contrib_prompt_git_vars[@]/%/=}" # WA #D1570 checked + if ble/contrib/prompt-git/initialize; then + ble/contrib/prompt-git/update-head-information + if [[ $branch ]]; then + ble/prompt/print "$bleopt_vim_airline_symbol_branch$branch" + elif [[ $hash ]]; then + ble/prompt/print "$bleopt_vim_airline_symbol_branch${hash::7}" + else + ble/prompt/print '$bleopt_vim_airline_symbol_branch???????' + fi + ble/contrib/prompt-git/is-dirty && + ble/prompt/print "$bleopt_vim_airline_symbol_dirty" + fi +} +function ble/prompt/unit:{vim-airline-section}/update { + local section=$1 + local ref_ps=bleopt_vim_airline_section_$section + local face=vim_airline_${section}_$_ble_lib_vim_airline_mode + local prefix=_ble_lib_vim_airline_section_$section + ble/prompt/unit/add-hash '$_ble_lib_vim_airline_mode_data' + ble/prompt/unit/add-hash "\$$ref_ps" + local trace_opts=confine:relative:noscrc:face0="$face":ansi:measure-bbox:measure-gbox + local prompt_rows=1 prompt_cols=$cols # Note: cols は \q{lib/vim-airline} で設定される + ble/prompt/unit:{section}/update "$prefix" "${!ref_ps}" "$trace_opts" +} +function ble/prompt/unit:_ble_lib_vim_airline_section_a/update { ble/prompt/unit:{vim-airline-section}/update a; } +function ble/prompt/unit:_ble_lib_vim_airline_section_b/update { ble/prompt/unit:{vim-airline-section}/update b; } +function ble/prompt/unit:_ble_lib_vim_airline_section_c/update { ble/prompt/unit:{vim-airline-section}/update c; } +function ble/prompt/unit:_ble_lib_vim_airline_section_x/update { ble/prompt/unit:{vim-airline-section}/update x; } +function ble/prompt/unit:_ble_lib_vim_airline_section_y/update { ble/prompt/unit:{vim-airline-section}/update y; } +function ble/prompt/unit:_ble_lib_vim_airline_section_z/update { ble/prompt/unit:{vim-airline-section}/update z; } +function ble/lib/vim-airline/.print-section { + local section=$1 + local ret g0 bg + ble/color/face2g "vim_airline_${section}_$_ble_lib_vim_airline_mode"; g0=$ret + ble/color/g#compute-bg "$g0"; bg=$ret + if [[ $prev_g0 ]]; then + local sep=bleopt_vim_airline gsep + if [[ $prev_section == [ab] ]]; then + sep=${sep}_left + else + sep=${sep}_right + fi + if [[ $prev_bg == $bg ]]; then + sep=${sep}_alt_sep + if [[ $prev_section == [ab] ]]; then + gsep=$prev_g0 + else + gsep=$g0 + fi + ((gsep&=~_ble_color_gflags_DecorationMask|_ble_color_gflags_Revert|_ble_color_gflags_Invisible)) + else + sep=${sep}_sep gsep=0 + if [[ $sep == *_right_sep ]]; then + ble/color/g#setfg gsep "$bg" + ble/color/g#setbg gsep "$prev_bg" + else + ble/color/g#setfg gsep "$prev_bg" + ble/color/g#setbg gsep "$bg" + fi + fi + ble/color/g2sgr-ansi "$gsep" + ble/prompt/print "$ret${!sep}" + fi + local ref_show=_ble_lib_vim_airline_section_${section}_show + if [[ ${!ref_show} ]]; then + ble/prompt/unit:{section}/get "_ble_lib_vim_airline_section_$section"; local esc=$ret + ble/color/g2sgr-ansi "$g0" + ble/prompt/print "$ret $esc$ret " + fi + [[ $section == c ]] && ble/prompt/print $'\r' + prev_g0=$g0 + prev_bg=$bg + prev_section=$section +} +function ble/prompt/backslash:lib/vim-airline { + local "${_ble_contrib_prompt_git_vars[@]/%/=}" # WA #D1570 checked + ble/prompt/unit#update _ble_lib_vim_airline_mode + ble/prompt/unit#update _ble_lib_vim_airline_sep_width + local lwsep=${_ble_lib_vim_airline_sep_width_data[3]:-1} + local rwsep=${_ble_lib_vim_airline_sep_width_data[4]:-1} + local ret bg=0 + ble/color/face2g "vim_airline_c_$_ble_lib_vim_airline_mode" + ble/color/g#getbg "$ret" + ble/color/g#setbg bg "$ret" + ble/color/setface prompt_status_line "g:$bg" + local cols=$COLUMNS; ((_ble_term_xenl||cols--)) + local unit rest_cols=$((cols-2*lwsep-3*rwsep)) + for unit in _ble_lib_vim_airline_section_{a,c,z,b,y,x}; do + ble/prompt/unit#update "$unit" + local gx1=${unit}_gbox[0]; gx1=${!gx1} + local x2=${unit}_bbox[2]; x2=${!x2} + local show= + [[ $gx1 ]] && ((x2+2<=rest_cols)) && ((show=1,rest_cols-=x2+2)) + builtin eval -- "${unit}_show=\$show" + done + local section prev_section= prev_g0= prev_bg= + for section in a b c x y z; do + ble/lib/vim-airline/.print-section "$section" + done +} +bleopt -I vim_airline_@ +bleopt keymap_vi_mode_show= +bleopt prompt_status_line='\q{lib/vim-airline}' +bleopt prompt_status_align=$'justify=\r' diff --git a/.local/share/blesh/lib/vim-arpeggio.sh b/.local/share/blesh/lib/vim-arpeggio.sh new file mode 100644 index 0000000..2cc6150 --- /dev/null +++ b/.local/share/blesh/lib/vim-arpeggio.sh @@ -0,0 +1,56 @@ +# Copyright 2015 Koichi Murase . All rights reserved. +# This script is a part of blesh (https://github.com/akinomyoga/ble.sh) +# provided under the BSD-3-Clause license. Do not edit this file because this +# is not the original source code: Various pre-processing has been applied. +# Also, the code comments and blank lines are stripped off in the installation +# process. Please find the corresponding source file(s) in the repository +# "akinomyoga/ble.sh". +# +# Source: /lib/vim-arpeggio.sh +ble-import keymap.vi +bleopt/declare -v vim_arpeggio_timeoutlen 40 +function ble/lib/vim-arpeggio.sh/bind/.usage { + ble/util/print "usage: ble/lib/vim-arpeggio.sh/bind [-m KEYMAP] -[fxcs@] KEYS COMMAND" + ble/util/print " KEYS has the form of {mods}{X}{Y}. {mods} are modifiers of the form" + ble/util/print " /([CSMAsH]-)*/ and {X} and {Y} are alphabets which specify simultaneous" + ble/util/print " keys." +} +function ble/lib/vim-arpeggio.sh/bind { + local -a opts=() + if [[ $1 == -m ]]; then + if [[ ! $2 ]]; then + ble/util/print "vim-arpeggio.sh: invalid option argument for \`-m'." >&2 + ble/lib/vim-arpeggio.sh/bind/.usage >&2 + return 1 + fi + ble/array#push opts -m "$2" + shift 2 + fi + local type=$1 keys=$2 cmd=$3 + if [[ $type == --help ]]; then + ble/lib/vim-arpeggio.sh/bind/.usage + return 0 + elif [[ $type != -[fxcs@] ]]; then + ble/util/print "vim-arpeggio.sh: invalid bind type." >&2 + ble/lib/vim-arpeggio.sh/bind/.usage >&2 + return 1 + fi + local mods= + if local rex='^(([CSMAsH]-)+)..'; [[ $keys =~ $rex ]]; then + mods=${BASH_REMATCH[1]} + keys=${keys:${#mods}} + fi + local timeout=$((bleopt_vim_arpeggio_timeoutlen)) + ((timeout<0)) && timeout= + if ((${#keys}==2)); then + local k1=$mods${keys::1} k2=$mods${keys:1:1} + ble-bind "${opts[@]}" "$type" "$k1 $k2" "$cmd" + ble-bind "${opts[@]}" "$type" "$k2 $k1" "$cmd" + ble-bind "${opts[@]}" -T "$k1" "$timeout" + ble-bind "${opts[@]}" -T "$k2" "$timeout" + else + ble/util/print "vim-arpeggio.sh: sorry only 2-key bindings are supported now." >&2 + ble/lib/vim-arpeggio.sh/bind/.usage >&2 + return 1 + fi +} diff --git a/.local/share/blesh/lib/vim-surround.sh b/.local/share/blesh/lib/vim-surround.sh new file mode 100644 index 0000000..b003e2e --- /dev/null +++ b/.local/share/blesh/lib/vim-surround.sh @@ -0,0 +1,559 @@ +# Copyright 2015 Koichi Murase . All rights reserved. +# This script is a part of blesh (https://github.com/akinomyoga/ble.sh) +# provided under the BSD-3-Clause license. Do not edit this file because this +# is not the original source code: Various pre-processing has been applied. +# Also, the code comments and blank lines are stripped off in the installation +# process. Please find the corresponding source file(s) in the repository +# "akinomyoga/ble.sh". +# +# Source: /lib/vim-surround.sh +ble-import keymap.vi +bleopt/declare -n vim_surround_45 $'$(\r)' # ysiw- +bleopt/declare -n vim_surround_61 $'$((\r))' # ysiw= +bleopt/declare -n vim_surround_q \" # ysiwQ +bleopt/declare -n vim_surround_Q \' # ysiwq +bleopt/declare -v vim_surround_omap_bind 1 +function ble/lib/vim-surround.sh/get-char-from-key { + local key=$1 + if ! ble-decode-key/ischar "$key"; then + local flag=$((key&_ble_decode_MaskFlag)) code=$((key&_ble_decode_MaskChar)) + if ((flag==_ble_decode_Ctrl&&63<=code&&code<128&&(code&0x1F)!=0)); then + ((key=code==63?127:code&0x1F)) + else + return 1 + fi + fi + ble/util/c2s "$key" + return 0 +} +function ble/lib/vim-surround.sh/async-inputtarget.hook { + local mode=$1 hook=${@:2:$#-2} key=${@:$#} ret + if ! ble/lib/vim-surround.sh/get-char-from-key "$key"; then + ble/widget/vi-command/bell + return 1 + fi + local c=$ret + if [[ :$mode: == *:digit:* && $c == [0-9] ]]; then + _ble_edit_arg=$_ble_edit_arg$c + _ble_decode_key__hook="ble/lib/vim-surround.sh/async-inputtarget.hook digit $hook" + return 147 + elif [[ :$mode: == *:init:* && $c == ' ' ]]; then + _ble_decode_key__hook="ble/lib/vim-surround.sh/async-inputtarget.hook space $hook" + return 147 + fi + if [[ $c == [$'\e\003'] ]]; then # C-[, C-c + ble/widget/vi-command/bell + return 1 + else + [[ $c == \' ]] && c="'\''" + [[ $mode == space ]] && c=' '$c + builtin eval -- "$hook '$c'" + fi +} +function ble/lib/vim-surround.sh/async-inputtarget { + local IFS=$_ble_term_IFS + _ble_decode_key__hook="ble/lib/vim-surround.sh/async-inputtarget.hook init:digit $*" + return 147 +} +function ble/lib/vim-surround.sh/async-inputtarget-noarg { + local IFS=$_ble_term_IFS + _ble_decode_key__hook="ble/lib/vim-surround.sh/async-inputtarget.hook init $*" + return 147 +} +_ble_lib_vim_surround_previous_tag=html +function ble/lib/vim-surround.sh/load-template { + local ins=$1 + if [[ ${ins//[0-9]} && ! ${ins//[_a-zA-Z0-9]} ]]; then + local optname=bleopt_vim_surround_$ins + template=${!optname} + [[ $template ]] && return 0 + fi + local ret; ble/util/s2c "$ins" + local optname=bleopt_vim_surround_$ret + template=${!optname} + [[ $template ]] && return 0 + case $ins in + ([''} + _ble_lib_vim_surround_previous_tag=$tag + fi + local end_tag=${tag%%["$_ble_term_IFS"]*} + template="<$tag>"$'\r'"" ;; + ('(') template=$'( \r )' ;; + ('[') template=$'[ \r ]' ;; + ('{') template=$'{ \r }' ;; + (['b)']) template=$'(\r)' ;; + (['r]']) template=$'[\r]' ;; + (['B}']) template=$'{\r}' ;; + (['a>']) template=$'<\r>' ;; + ([a-zA-Z]) return 1 ;; + (*) template=$ins ;; + esac +} &>/dev/null +function ble/lib/vim-surround.sh/surround { + local text=$1 ins=$2 opts=$3 + local instype= + [[ $ins == $'\x1D' ]] && ins='}' instype=indent # C-], C-} + local has_space= + [[ $ins == ' '?* ]] && ins=${ins:1} has_space=1 + local template= + ble/lib/vim-surround.sh/load-template "$ins" || return 1 + local prefix= suffix= + if [[ $template == *$'\r'* ]]; then + prefix=${template%%$'\r'*} + suffix=${template#*$'\r'} + else + prefix=$template + suffix=$template + fi + if [[ $prefix == *' ' && $suffix == ' '* ]]; then + prefix=${prefix::${#prefix}-1} + suffix=${suffix:1} + has_space=1 + fi + if [[ $instype == indent || :$opts: == *:linewise:* ]]; then + ble-edit/content/find-logical-bol "$beg"; local bol=$ret + ble-edit/content/find-non-space "$bol"; local nol=$ret + local indent= + if [[ $instype == indent ]] || ((bol' + ble/widget/self-insert + ble/widget/vi_cmap/accept + ble/decode/widget/suppress-widget + fi +} +_ble_lib_vim_surround_ys_type= # ys | yS | vS | vgS +_ble_lib_vim_surround_ys_args=() +_ble_lib_vim_surround_ys_ranges=() +function ble/highlight/layer:region/mark:vi_surround/get-selection { + local type=$_ble_lib_vim_surround_ys_type + local context=${_ble_lib_vim_surround_ys_args[2]} + if [[ $context == block ]]; then + local -a sub_ranges + sub_ranges=("${_ble_lib_vim_surround_ys_ranges[@]}") + selection=() + local sub + for sub in "${sub_ranges[@]}"; do + ble/string#split sub : "$sub" + ((sub[0]]t']) obj1=i$del obj2=a$del ;; + (['({<[']) obj1=i$del obj2=a$del trim=1 ;; + ([a-zA-Z]) obj1=i$del obj2=a$del ;; + esac + local beg end + if [[ $obj1 && $obj2 ]]; then + local surround_beg=$_ble_edit_ind surround_end=$_ble_edit_ind + ble/keymap:vi/text-object.impl "$arg" surround-extract-region '' "$obj2" + beg=$surround_beg end=$surround_end + elif [[ $del == / ]]; then + local rex='(/\*([^/]|/[^*])*/?){1,'$arg'}$' + [[ ${_ble_edit_str::_ble_edit_ind+2} =~ $rex ]] || return 1 + beg=$((_ble_edit_ind+2-${#BASH_REMATCH})) + ble/string#index-of "${_ble_edit_str:beg+2}" '*/' || return 1 + end=$((beg+ret+4)) + elif [[ $del ]]; then + local ret + ble-edit/content/find-logical-bol; local bol=$ret + ble-edit/content/find-logical-eol; local eol=$ret + local line=${_ble_edit_str:bol:eol-bol} + local ind=$((_ble_edit_ind-bol)) + if ble/string#last-index-of "${line::ind}" "$del"; then + beg=$ret + elif local base=$((ind-(2*${#del}-1))); ((base>=0||(base=0))) + ble/string#index-of "${line:base:ind+${#del}-base}" "$del"; then + beg=$((base+ret)) + else + return 1 + fi + ble/string#index-of "${line:beg+${#del}}" "$del" || return 1 + end=$((beg+2*${#del}+ret)) + ((beg+=bol,end+=bol)) + fi + _ble_lib_vim_surround_cs[11]=$del + _ble_lib_vim_surround_cs[12]=$obj1 + _ble_lib_vim_surround_cs[13]=$obj2 + _ble_lib_vim_surround_cs[14]=$beg + _ble_lib_vim_surround_cs[15]=$end + _ble_lib_vim_surround_cs[16]=$arg + _ble_lib_vim_surround_cs[17]=$trim +} +function ble/widget/vim-surround.sh/nmap/csurround.replace { + local ins=$1 + local type=${_ble_lib_vim_surround_cs[0]} + local arg=${_ble_lib_vim_surround_cs[1]} + local reg=${_ble_lib_vim_surround_cs[2]} + local del=${_ble_lib_vim_surround_cs[3]} + local del2=${_ble_lib_vim_surround_cs[11]} + local obj1=${_ble_lib_vim_surround_cs[12]} + local obj2=${_ble_lib_vim_surround_cs[13]} + local beg=${_ble_lib_vim_surround_cs[14]} + local end=${_ble_lib_vim_surround_cs[15]} + local arg2=${_ble_lib_vim_surround_cs[16]} + local surround_ins=$ins + local surround_type=$type + local surround_trim=${_ble_lib_vim_surround_cs[17]} + if [[ $obj1 && $obj2 ]]; then + local ind=$_ble_edit_ind + local _ble_edit_kill_ring _ble_edit_kill_type + ble/keymap:vi/text-object.impl "$arg2" y '' "$obj1"; local ext=$? + _ble_edit_ind=$ind + ((ext!=0)) && return 1 + local surround_content=$_ble_edit_kill_ring + ble/keymap:vi/text-object.impl "$arg2" surround '' "$obj2" || return 1 + elif [[ $del2 == / ]]; then + local surround_content=${_ble_edit_str:beg+2:end-beg-4} + ble/keymap:vi/call-operator surround "$beg" "$end" char '' '' + _ble_edit_ind=$beg + elif [[ $del2 ]]; then + local surround_content=${_ble_edit_str:beg+${#del2}:end-beg-2*${#del2}} + ble/keymap:vi/call-operator surround "$beg" "$end" char '' '' + _ble_edit_ind=$beg + else + ble/widget/vi-command/bell + return 1 + fi + ble/widget/vim-surround.sh/nmap/csurround.record "$type" "$arg" "$reg" "$del" "$ins" + ble/keymap:vi/adjust-command-mode + return 0 +} +function ble/widget/vim-surround.sh/nmap/csurround.record { + [[ $_ble_keymap_vi_mark_suppress_edit ]] && return 0 + local type=$1 arg=$2 reg=$3 del=$4 ins=$5 + local WIDGET=ble/widget/vim-surround.sh/nmap/csurround.repeat ARG=$arg FLAG= REG=$reg + ble/keymap:vi/repeat/record + if [[ $_ble_decode_keymap == vi_imap ]]; then + _ble_keymap_vi_repeat_insert[10]=$type + _ble_keymap_vi_repeat_insert[11]=$del + _ble_keymap_vi_repeat_insert[12]=$ins + else + _ble_keymap_vi_repeat[10]=$type + _ble_keymap_vi_repeat[11]=$del + _ble_keymap_vi_repeat[12]=$ins + fi +} +function ble/widget/vim-surround.sh/nmap/csurround.repeat { + local ARG FLAG REG; ble/keymap:vi/get-arg 1 + local type=${_ble_keymap_vi_repeat[10]} + local del=${_ble_keymap_vi_repeat[11]} + local ins=${_ble_keymap_vi_repeat[12]} + ble/widget/vim-surround.sh/nmap/csurround.initialize "$type" "$ARG" "$REG" && + ble/widget/vim-surround.sh/nmap/csurround.set-delimiter "$del" && + ble/widget/vim-surround.sh/nmap/csurround.replace "$ins" && return 0 + ble/widget/vi-command/bell + return 1 +} +function ble/widget/vim-surround.sh/nmap/dsurround { + local ARG FLAG REG; ble/keymap:vi/get-arg 1 + ble/widget/vim-surround.sh/nmap/csurround.initialize ds "$ARG" "$REG" + ble/lib/vim-surround.sh/async-inputtarget ble/widget/vim-surround.sh/nmap/dsurround.hook +} +function ble/widget/vim-surround.sh/nmap/dsurround.hook { + local del=$1 + ble/widget/vim-surround.sh/nmap/csurround.set-delimiter "$del" && + ble/widget/vim-surround.sh/nmap/csurround.replace '' && return 0 + ble/widget/vi-command/bell + return 1 +} +function ble/highlight/layer:region/mark:vi_csurround/get-selection { + local beg=${_ble_lib_vim_surround_cs[14]} + local end=${_ble_lib_vim_surround_cs[15]} + selection=("$beg" "$end") +} +function ble/highlight/layer:region/mark:vi_csurround/get-face { + face=region_target +} +function ble/widget/vim-surround.sh/nmap/csurround { + ble/widget/vim-surround.sh/nmap/csurround.impl cs +} +function ble/widget/vim-surround.sh/nmap/cSurround { + ble/widget/vim-surround.sh/nmap/csurround.impl cS +} +function ble/widget/vim-surround.sh/nmap/csurround.impl { + local ARG FLAG REG; ble/keymap:vi/get-arg 1 + local type=$1 + ble/widget/vim-surround.sh/nmap/csurround.initialize "$type" "$ARG" "$REG" + ble/lib/vim-surround.sh/async-inputtarget ble/widget/vim-surround.sh/nmap/csurround.hook1 +} +function ble/widget/vim-surround.sh/nmap/csurround.hook1 { + local del=$1 + if [[ $del ]] && ble/widget/vim-surround.sh/nmap/csurround.set-delimiter "$del"; then + _ble_edit_mark_active=vi_csurround + ble/lib/vim-surround.sh/async-inputtarget-noarg ble/widget/vim-surround.sh/nmap/csurround.hook2 + return "$?" + fi + _ble_lib_vim_surround_cs=() + ble/widget/vi-command/bell + return 1 +} +function ble/widget/vim-surround.sh/nmap/csurround.hook2 { + local ins=$1 + if local rex='^ ?[