Skip to content

Commit

Permalink
debug (GitHub #110): trial1
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed May 16, 2021
1 parent 50288bf commit 2e14354
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/edit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -900,6 +900,7 @@ function ble/prompt/.instantiate {
local prompt_noesc=
shopt -q promptvars &>/dev/null || prompt_noesc=1

ble/util/put "[I1]" >&2
# 1. PS1 に含まれる \c を処理する
local -a DRAW_BUFF=()
if [[ :$opts: == *:show-mode-in-prompt:* ]]; then
Expand All @@ -915,36 +916,45 @@ function ble/prompt/.instantiate {
[[ $ret ]] && ble/prompt/print "$ret"
fi
fi
ble/util/put "[I2]" >&2
ble/prompt/process-prompt-string "$ps"
local processed; ble/canvas/sflush.draw -v processed

# 2. PS1 に含まれる \\ や " をエスケープし、
# eval して各種シェル展開を実行する。
ble/util/put "[I3]" >&2
if [[ ! $prompt_noesc ]]; then
ble/util/put "[I3a]" >&2
local ret
ble/prompt/.escape "$processed"; local escaped=$ret
local expanded=${trace_hash0#*:} # Note: これは次行が失敗した時の既定値
ble-edit/exec/.setexit "$_ble_edit_exec_lastarg"
ble/util/put "[I3b]" >&2
BASH_COMMAND=$_ble_edit_exec_BASH_COMMAND \
builtin eval "expanded=\"$escaped\""
else
local expanded=$processed
fi

# 3. 端末への出力を構成する
ble/util/put "[I4]" >&2
if [[ :$opts: == *:no-trace:* ]]; then
ble/util/put "[I4a]" >&2
# Note: "ESC k ... ESC \" 等を対象とするプロンプト文字列は trace 不要
x=0 y=0 g=0 lc=32 lg=0
esc=$expanded
elif trace_hash=$COLUMNS:$expanded; [[ $trace_hash != "$trace_hash0" ]]; then
ble/util/put "[I4b]" >&2
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
ble/canvas/trace "$expanded" "$trace_opts"; local traced=$ret
ble/util/put "[I4c]" >&2
((lc<0&&(lc=0)))
esc=$traced
return 0
else
ble/util/put "[I4d]" >&2
x=$x0 y=$y0 g=$g0 lc=$lc0 lg=$lg0
esc=$esc0
return 2
Expand Down Expand Up @@ -1026,23 +1036,31 @@ function ble/prompt/update {
return 0
fi

ble/util/put "[U1]" >&2
((_ble_prompt_update++))
local cache_d= cache_t= cache_A= cache_T= cache_at= cache_j= cache_wd=

ble/util/put "[U2]" >&2
# update PS1
if [[ ! $is_leave_rewrite ]] && { ble/prompt/update/.has-prompt_command || blehook/has-hook PRECMD; }; then
ble/util/put "[U2a]" >&2
ble-edit/restore-PS1
ble/util/put "[U2b]" >&2
ble/prompt/update/.eval-prompt_command
ble/util/put "[U2c]" >&2
ble-edit/exec:gexec/invoke-hook-with-setexit PRECMD
ble/util/put "[U2d]" >&2
ble-edit/adjust-PS1
fi

ble/util/put "[U3]" >&2
local ps1=$_ble_edit_PS1 rps1=$bleopt_prompt_rps1
if [[ $is_leave_rewrite ]]; then
[[ $ps1f || $ps1t ]] && ps1=$ps1f
[[ $ps1f ]] && rps1=$rps1f
ble/textarea#invalidate
fi
ble/util/put "[U4]" >&2
local trace_hash esc
ble/prompt/.instantiate "$ps1" show-mode-in-prompt "${_ble_edit_prompt[@]:1}" &&
_ble_edit_prompt_dirty=1
Expand All @@ -1052,6 +1070,7 @@ function ble/prompt/update {
# Note #D1392: mc (midnight commander) の中では補助プロンプトは全て off
[[ $MC_SID == $$ ]] && return 0

ble/util/print "[U5]" >&2
# update edit_rps1
if [[ $rps1 ]]; then
local ps1_height=$((y+1))
Expand Down Expand Up @@ -1162,6 +1181,7 @@ function ble/prompt/update {
fi
_ble_prompt_term_status[6]=$ret
fi
ble/util/print "[U6]" >&2
}
function ble/prompt/clear {
_ble_edit_prompt[0]=
Expand Down Expand Up @@ -2545,23 +2565,28 @@ function ble/textarea#render {
fi
fi
else
ble/util/put "[R.W1]" >&2
# 全体更新
ble/canvas/panel#clear.draw "$_ble_textarea_panel"
_ble_edit_rprompt_shown=

ble/util/put "[R.W2]" >&2
# プロンプト描画
[[ $rps1_enabled ]] &&
ble/textarea#render/.show-rprompt
ble/textarea#render/.show-prompt

ble/util/put "[R.W3]" >&2
# 全体描画
_ble_textarea_scroll=$scroll
_ble_textarea_scroll_new=$_ble_textarea_scroll
if [[ ! $_ble_textarea_scroll ]]; then
ble/util/put "[R.W4a]" >&2
ble/textarea#slice-text-buffer # → ret
esc_line=$ret esc_line_set=1
ble/canvas/panel#put.draw "$_ble_textarea_panel" "$ret" "$_ble_textarea_gendx" "$_ble_textarea_gendy"
else
ble/util/put "[R.W4b]" >&2
ble/textarea#render/.show-scroll-at-first-line

local gbeg=0
Expand All @@ -2580,6 +2605,7 @@ function ble/textarea#render {
ble/textarea#slice-text-buffer "$gbeg" "$gend"
ble/canvas/panel#put.draw "$_ble_textarea_panel" "$ret" "$_ble_textarea_gendx" "$_ble_textarea_gendy"
fi
ble/util/print "[R.W5]" >&2
fi

# 3 移動
Expand Down

0 comments on commit 2e14354

Please sign in to comment.