Skip to content

Commit

Permalink
prompt: preserve transient prompt with "same-dir" after "clear-screen"
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Sep 16, 2022
1 parent 3953afe commit 69013d9
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 5 deletions.
1 change: 1 addition & 0 deletions docs/ChangeLog.md
Expand Up @@ -197,6 +197,7 @@
- trap: ignore `RETURN` for `ble/builtin/trap/.handler` `#D1867` a22c25b
- trap: fix a bug that `DEBUG` for internal commands clears `$?` `#D1867` a22c25b
- progcomp: reproduce arguments of completion functions passed by Bash `#D1872` 4d2dd35
- prompt: preserve transient prompt with `same-dir` after `clear-screen` `#D1876` xxxxxxx

## Fixes

Expand Down
50 changes: 49 additions & 1 deletion note.txt
Expand Up @@ -1851,8 +1851,45 @@ bash_tips
- version up in GNUmakefile, README
- Copyright
- Acknowledgments
- keymap の移動 (これは別 commit にする?)
- todo 項目の整理
- leakvars
- keymap の移動 (これは別 commit にする?)

2022-09-11

* 何らかの拍子に P[0 q の様な謎の文字列がユーザーコマンドの実行後に出力される
様になる。

これは DECSCUSR に関係しているのは確かだと思われるが、どうやって起こるのか
分からない。例えば _ble_term_Ss 関係の変数が変な値になっているのが原因かと
も思われたが別にこれらの変数に問題はない。P[0 q の様な文字列が含まれている
変数も存在しない様に見える。

* bleopt term_cursor_external=1 を設定してみたらコマンドが始まる前にも変な
メッセージが出力される様になった。つまりやはり cursor-state の管理の部分
で起こっている問題なのだろうと思われる。

* 新しい bash を開始すると別に問題は生じない。また、そもそも表示幅も狂って
いる気がする、と思ったがこれは本来端末に文字列として表示されない物が表示
されている事によって位置がずれているだけなので、元の問題を解決すればこれ
も解決する筈。

コードを確認してみたら分かった気がする。quote-passthrough によって付加され
た P が表示されてしまっているのである。そして、端末の入れ子情報が壊れている。
実際に問題が生じている端末で C-xC-v で端末情報を出力してみた所、どうやら
screen が三重に入れ子になっていると勘違いしているようである。

terminal: TERM=screen.xterm-256color wcwidth=14.0-emacs, screen:49900
(83;49900;0), screen:49900 (83;49900;0), screen:49900 (83;49900;0),
contra:0 (99;0)

何故後になってこの様な変な状態になるのか分からないが、ble.sh を reload した
らちゃんと端末の入れ子状態の情報も正しくなって問題も起こらなくなった。

2022-08-31

* complete: 'a b c' というファイルがある状態で 'b [TAB] すると変な事になる。
* complete: ~/b/c/スペースを含むファイル[TAB] としても requote されない。

2022-08-29

Expand Down Expand Up @@ -6556,6 +6593,17 @@ bash_tips

2022-09-14

* prompt: clear-screen 後は same-dir でも transient prompt を残しておく [#D1876]

transient same-dir で起動後の一番最初のプロンプトは全部残しておくべきである。

と思って試して見たがちゃんとそうなっている。或いは clear-screen した時にディ
レクトリ名が消えてしまうという事だったか。これは振る舞いを修正しても良い。

p10k の方の振る舞いを見てみたが clear-screen しても same-dir で trim されて
しまう様である。なのでそういう意味では ble.sh も気にしなくても良いのかもし
れないが、やはり clear-screen した後は残っていて欲しい気がする。

* hook: blehook | cat がデフォルトで着色になっている [#D1875]

bleopt ble-bind ble-face ble-sabbrev 等は問題ない。常に auto の振る舞いである。
Expand Down
10 changes: 6 additions & 4 deletions src/edit.sh
Expand Up @@ -337,6 +337,7 @@ function ble/application/onwinch {
case $bleopt_canvas_winch_action in
(clear)
# 全消去して一番上から再描画
_ble_prompt_trim_opwd=
ble/util/buffer "$_ble_term_clear" ;;
(redraw-here)
# 現在位置から再描画 (幅が減った時は前のコマンドの出力結果を破壊しな
Expand Down Expand Up @@ -1688,7 +1689,7 @@ function ble/prompt/update {
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_edit_line_opwd ]] && ps1t=
[[ :$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
Expand Down Expand Up @@ -3510,6 +3511,7 @@ function ble/widget/redraw-line {
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
Expand Down Expand Up @@ -6709,15 +6711,15 @@ function ble-edit/exec:gexec/restore-state {
# **** accept-line **** @edit.accept

: ${_ble_edit_lineno:=0}
_ble_edit_line_opwd=
_ble_prompt_trim_opwd=

## @fn ble/widget/.insert-newline/trim-prompt
## @var[ref] DRAW_BUFF
function ble/widget/.insert-newline/trim-prompt {
local ps1f=$bleopt_prompt_ps1_final
local ps1t=$bleopt_prompt_ps1_transient
if [[ ! $ps1f && :$ps1t: == *:trim:* ]]; then
[[ :$ps1t: == *:same-dir:* && $PWD != $_ble_edit_line_opwd ]] && return
[[ :$ps1t: == *:same-dir:* && $PWD != $_ble_prompt_trim_opwd ]] && return
local y=${_ble_prompt_ps1_data[4]}
if ((y)); then
ble/canvas/panel#goto.draw "$_ble_textarea_panel" 0 0
Expand Down Expand Up @@ -6756,7 +6758,7 @@ function ble/widget/.insert-newline {

# 描画領域情報の初期化
((_ble_edit_lineno++))
_ble_edit_line_opwd=$PWD
_ble_prompt_trim_opwd=$PWD
ble/textarea#invalidate
_ble_canvas_x=0 _ble_canvas_y=0
_ble_textarea_gendx=0 _ble_textarea_gendy=0
Expand Down

0 comments on commit 69013d9

Please sign in to comment.