diff --git a/blerc.template b/blerc.template index 509a01ef..0c5e970c 100644 --- a/blerc.template +++ b/blerc.template @@ -1168,6 +1168,12 @@ blehook/eval-after-load keymap_vi blerc/vim-load-hook #bleopt debug_xtrace_ps4='+ ' +## When the option "debug_idle" contains a non-empty value, the background +## tasks currently running are shown in the info panel. + +#bleopt debug_idle=1 + + ## [The setting "openat_base" needs to be set before ble.sh is loaded or ## specified in the source options. Therefore the value should be assigned ## directly to the shell variable "bleopt_openat_base" instead of using diff --git a/docs/ChangeLog.md b/docs/ChangeLog.md index 3760da58..993d7332 100644 --- a/docs/ChangeLog.md +++ b/docs/ChangeLog.md @@ -526,6 +526,7 @@ - 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` xxxxxxx +- util: support `bleopt debug_idle` `#D1945` xxxxxxx ## Contrib diff --git a/note.txt b/note.txt index 76a08f07..897b76b5 100644 --- a/note.txt +++ b/note.txt @@ -6833,6 +6833,19 @@ bash_tips 2023-02-06 + * util/idle: background で何が動いているのか分からないので immediate-show で表示する? [#D1945] + + オプションで切り替えられる様にする。うるさいので既定では off。 + + immediate-show で表示していると menu-complete 等他の物が使えなくなるので、 + scheme == default の時にだけ ble/util/idle で現在実行中のタスクを表示する。 + + * info: Emacs の *Messages* の様に後で記録を見返す事ができると良い気がする。 + 後でログにする事も考えて時刻も含めておく (但しどの様にログにするのかは謎。 + info に新しく schene を追加して log という事にして、更に何処かのファイル + にキャッシュとして保存するなど? 何れにしても全然必要性を感じないので今の + 所は気にしない事にする)。 + * histdb: backup機能 [#D1944] sqlite3 データベースが破壊される事が実際起こるのか分からないが、消えるとショッ diff --git a/src/util.sh b/src/util.sh index 2050e2eb..096160e3 100644 --- a/src/util.sh +++ b/src/util.sh @@ -4756,6 +4756,8 @@ function ble-assert { #------------------------------------------------------------------------------ # Event loop +bleopt/declare -v debug_idle '' + ## @fn ble/util/clock ## 時間を計測するのに使うことができるミリ秒単位の軽量な時計です。 ## 計測の起点は ble.sh のロード時です。 @@ -4968,11 +4970,12 @@ if ((_ble_bash>=40000)); then local _idle_sclock_start=$_ble_util_idle_sclock local _idle_is_first=1 local _idle_processed= + local _idle_info_shown= while :; do local _idle_key local _idle_next_time= _idle_next_itime= _idle_running= _idle_waiting= for _idle_key in "${!_ble_util_idle_task[@]}"; do - ble/util/idle/IS_IDLE || { [[ $_idle_processed ]]; return "$?"; } + ble/util/idle/IS_IDLE || break 2 local _idle_to_process= local _idle_status=${_ble_util_idle_task[_idle_key]%%"$_ble_util_idle_SEP"*} case ${_idle_status::1} in @@ -5008,6 +5011,8 @@ if ((_ble_bash>=40000)); then [[ $_idle_next_itime$_idle_next_time$_idle_running$_idle_waiting ]] || break done + [[ $_idle_info_shown ]] && + ble/edit/info/immediate-default [[ $_idle_processed ]] } ## @fn ble/util/idle.do/.call-task command @@ -5019,6 +5024,10 @@ if ((_ble_bash>=40000)); then local _command=$1 local ble_util_idle_status= local ble_util_idle_elapsed=$((_ble_util_idle_sclock-_idle_sclock_start)) + if [[ $bleopt_debug_idle && ( $_ble_edit_info_scene == default || $_idle_info_shown ) ]]; then + _idle_info_shown=1 + ble/edit/info/immediate-show text "${EPOCHREALTIME:+[$EPOCHREALTIME] }idle: $_command" + fi builtin eval -- "$_command"; local ext=$? if ((ext==148)); then _ble_util_idle_task[_idle_key]=R$_ble_util_idle_SEP$_command