Skip to content

Commit

Permalink
canvas: test the terminal for the sequence of clearing "DECSTBM"
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Jan 24, 2022
1 parent b4bd955 commit 4b1601d
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 5 deletions.
1 change: 1 addition & 0 deletions docs/ChangeLog.md
Expand Up @@ -296,6 +296,7 @@
- global (`ble/builtin/*`): work around `set -eu` in NixOS initialization (reported by SuperSandro2000) `#D1743` 001c595
- util, edit, contrib: add support for `bash-preexec` (motivated by SuperSandro2000) `#D1744` e85f52c
- main: check `IN_NIX_SHELL` to inactivate ble.sh in nix-shell `#D1747` 0000000
- canvas: test the terminal for the sequence of clearing `DECSTBM` `#D1748` 0000000

## Internal changes and fixes

Expand Down
9 changes: 9 additions & 0 deletions note.txt
Expand Up @@ -5892,6 +5892,15 @@ bash_tips
Done (実装ログ)
-------------------------------------------------------------------------------

2022-01-24

* canvas: wezterm で DECSTBM のクリアに失敗している [#D1748]
https://github.com/akinomyoga/ble.sh/issues/96#issuecomment-1019570983

kitty もそうだったが \e[;r では DECSTBM をクリアできない模様。
DECSTBM と同様にその場で端末をテストする事にした。修正した。
この問題については解決した。

2022-01-23

* main: IN_NIX_SHELL をチェックする (reported by SuperSandro2000) [#D1747]
Expand Down
4 changes: 2 additions & 2 deletions src/canvas.sh
Expand Up @@ -2987,7 +2987,7 @@ function ble/canvas/panel/increase-total-height.draw {
ble/canvas/put-ind.draw $((top_height-1+delta-_ble_canvas_y))
((_ble_canvas_y=top_height-1+delta))
ble/canvas/excursion-start.draw
ble/canvas/put.draw $'\e[r' # Note: Kitty は CSI ; r を認識しない
ble/canvas/put.draw "$_ble_term_DECSTBM_reset"
ble/canvas/excursion-end.draw
return 0
else
Expand Down Expand Up @@ -3177,7 +3177,7 @@ function ble/canvas/panel/ensure-tmargin.draw {
ble/canvas/excursion-end.draw
fi
ble/canvas/excursion-start.draw
ble/canvas/put.draw $'\e[;r'
ble/canvas/put.draw "$_ble_term_DECSTBM_reset"
ble/canvas/excursion-end.draw
ble/canvas/panel/load-position.draw "$pos"
return 0
Expand Down
25 changes: 22 additions & 3 deletions src/util.sh
Expand Up @@ -5755,6 +5755,8 @@ function ble/term/DA2/initialize-term {
da2r=("${da2r[@]/#/10#0}") # 0で始まっていても10進数で解釈 (#D1570 is-array OK)

case $DA2R in
('0;0;0')
_ble_term_TERM[depth]=wezterm:0 ;;
('1;0'?????';0')
_ble_term_TERM[depth]=foot:${DA2R:3:5} ;;
('1;'*)
Expand Down Expand Up @@ -5878,17 +5880,34 @@ function ble/term/quote-passthrough {
}

_ble_term_DECSTBM=
function ble/term/test-DECSTBM.hook {
_ble_term_DECSTBM_reset=
function ble/term/test-DECSTBM.hook1 {
(($1==2)) && _ble_term_DECSTBM=$'\e[%s;%sr'
}
function ble/term/test-DECSTBM.hook2 {
if [[ $_ble_term_DECSTBM ]]; then
if (($1==2)); then
# Failed to reset DECSTBM with \e[;r
_ble_term_DECSTBM_reset=$'\e[r'
else
_ble_term_DECSTBM_reset=$'\e[;r'
fi
fi
}
function ble/term/test-DECSTBM {
# Note: kitty 及び wezterm では SCORC と区別できる形の \e[;r では復
# 帰できない。
local -a DRAW_BUFF=()
ble/canvas/panel/goto-top-dock.draw
ble/canvas/put.draw "$_ble_term_sc"$'\e[1;2r'
ble/canvas/put-cup.draw 2 1
ble/canvas/put-cud.draw 1
ble/term/CPR/request.draw ble/term/test-DECSTBM.hook
ble/canvas/put.draw $'\e[;r'"$_ble_term_rc"
ble/term/CPR/request.draw ble/term/test-DECSTBM.hook1
ble/canvas/put.draw $'\e[;r'
ble/canvas/put-cup.draw 2 1
ble/canvas/put-cud.draw 1
ble/term/CPR/request.draw ble/term/test-DECSTBM.hook2
ble/canvas/put.draw $'\e[r'"$_ble_term_rc"
ble/canvas/bflush.draw
}

Expand Down

0 comments on commit 4b1601d

Please sign in to comment.