Skip to content

Commit

Permalink
util: support "bleopt debug_idle"
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Feb 6, 2023
1 parent 36e1c89 commit fa10184
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
6 changes: 6 additions & 0 deletions blerc.template
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions docs/ChangeLog.md
Expand Up @@ -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

Expand Down
13 changes: 13 additions & 0 deletions note.txt
Expand Up @@ -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 データベースが破壊される事が実際起こるのか分からないが、消えるとショッ
Expand Down
11 changes: 10 additions & 1 deletion src/util.sh
Expand Up @@ -4756,6 +4756,8 @@ function ble-assert {
#------------------------------------------------------------------------------
# Event loop

bleopt/declare -v debug_idle ''

## @fn ble/util/clock
## 時間を計測するのに使うことができるミリ秒単位の軽量な時計です。
## 計測の起点は ble.sh のロード時です。
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit fa10184

Please sign in to comment.