Skip to content

Commit

Permalink
edit (ble-bind -x): preserve multiline prompts on execution of "bind …
Browse files Browse the repository at this point in the history
…-x" commands
  • Loading branch information
akinomyoga committed Jan 24, 2022
1 parent a75bb25 commit 7d05a28
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 6 deletions.
1 change: 1 addition & 0 deletions docs/ChangeLog.md
Expand Up @@ -138,6 +138,7 @@
- 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 0000000
- edit (`ble-bind -x`): preserve multiline prompts on execution of `bind -x` commands `#D1755` 0000000

## Fixes

Expand Down
17 changes: 17 additions & 0 deletions note.txt
Expand Up @@ -5900,6 +5900,23 @@ bash_tips

2022-01-24

* edit: bind -x 関数の呼び出しに際しての画面クリアの振る舞いについて (motivated by SuperSandro2000) [#D1755]
https://github.com/akinomyoga/blesh-contrib/issues/6#issuecomment-1020165711

GNU readline は 4.4 で振る舞いを変更した様だ。それ以前はただ単純に現在の編
集位置にカーソルを置いたまま bind -x の関数を呼び出していた。4.4 以降ではプ
ロンプトの終了点・編集文字列の開始点の行にカーソルを置いて bind -x の関数を
呼び出す様になった様だ。実は

https://github.com/junegunn/fzf/issues/490#issuecomment-184402254

でもその事が説明されている気がする (何が書かれているかちゃんとは見ていない
が)。というよりこの振る舞いについては前にも議論した事があるような気がする。
→うーん。#D0915 (90ca3bea) の最後の動作確認の所で微妙に言及しているだけで
ある。これ以降は .hide-current-line も対して更新されていないし振る舞いにつ
いては変更はなかったと思われる。その時は手元で試して振る舞いを決定した気が
するが詳細については記録に残っていないという事。

* patsubWA: compat42 での振る舞い [#D1754]

それとは別に compat42 の効果についても考察する必要がある。compat42 の時には
Expand Down
26 changes: 20 additions & 6 deletions src/edit.sh
Expand Up @@ -5765,16 +5765,30 @@ function ble/widget/.insert-newline {
_ble_textarea_gendx=0 _ble_textarea_gendy=0
_ble_canvas_panel_height[_ble_textarea_panel]=1
}
## @fn ble/widget/.hide-current-line [opts]
## @param[in] opts
## a colon-separated list of the following fields:
##
## keep-header
## keep the multiline prompt displayed in the terminal except
## for the last line.
##
function ble/widget/.hide-current-line {
local opts=$1 y_erase=0
[[ :$opts: == *:keep-header:* ]] && y_erase=${_ble_prompt_ps1_data[4]}
ble/edit/enter-command-layout
local -a DRAW_BUFF=()
ble/canvas/panel#clear.draw "$_ble_textarea_panel"
ble/canvas/panel#goto.draw "$_ble_textarea_panel" 0 0
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=0
_ble_textarea_gendx=0 _ble_textarea_gendy=0
_ble_canvas_panel_height[_ble_textarea_panel]=1
_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 {
Expand Down Expand Up @@ -9023,7 +9037,7 @@ function ble/widget/.EDIT_COMMAND {
local -x READLINE_MARK=$_ble_edit_mark
[[ $_ble_edit_arg ]] &&
local -x READLINE_ARGUMENT=$_ble_edit_arg
ble/widget/.hide-current-line
ble/widget/.hide-current-line keep-header
ble/util/buffer.flush >&2
builtin eval -- "$command" || return 1
ble-edit/content/clear-arg
Expand Down

0 comments on commit 7d05a28

Please sign in to comment.