Skip to content

Commit

Permalink
canvas: fix a glitch that SGR at the end of command line is applied t…
Browse files Browse the repository at this point in the history
…o new lines
  • Loading branch information
akinomyoga committed Feb 27, 2021
1 parent 61a57c0 commit 4bdfdbf
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 13 deletions.
5 changes: 3 additions & 2 deletions memo/ChangeLog.md
Expand Up @@ -53,14 +53,15 @@
- util (`ble/util/msleep`): work around the bash-4.3 bug of `read -t` (reported by 3ximus) `#D1468` `#D1469` 4ca9b2e
- syntax: fix broken AST with `[[` keyword `#D1454` 69658ef
- benchmark (`ble-measure`): work around a locale-dependent decimal point of `EPOCHREALTIME` (reported by 3ximus) `#D1460` 1aa471b
- global:work around bash-4.2 bug of `declare -gA` (reported by 0xC0ncord) `#D1470` 8856a04
- global: work around bash-4.2 bug of `declare -gA` (reported by 0xC0ncord) `#D1470` 8856a04
- global: fix declaration of associative arrays for `ble-reload` (reported by 0xC0ncord) `#D1471` 3cae6e4
- bind: work around broken `cmd_xmap` after switching the editing mode `#D1478` 8d354c1
- edit: clear graphic rendition on newlines and external commands `#D1479` 18bb2d5
- mandb: improve extraction and cache for each locale `#D1480` 3588158
- decode (rlfunc): work around incomplete bytes in keyseq (reported by onelittlehope) `#D1483` 3559658 beb0383 37363be
- main: fix a bug that unset `IFS` is not correctly restored `#D1489` 808f6f7
- edit: fix error messages on accessing undo records in emacs mode (reported by rux616) `#D1497` 0000000
- edit: fix error messages on accessing undo records in emacs mode (reported by rux616) `#D1497` 61a57c0 e9be69e
- canvas: fix a glitch that SGR at the end of command line is applied to new lines `#D1498` 0000000

## Compatibility

Expand Down
16 changes: 16 additions & 0 deletions note.txt
Expand Up @@ -3773,6 +3773,22 @@ bash_tips

2021-02-27

* canvas/panel: set-height で高さ拡張時にその時の sgr0 が bce で適用されてしまう [#D1498]

< /dev/tcp/..../80 で赤色になっている時に実行すると赤い行ができてしまう。
これは sgr0 をせずに set-height を実行する事によって発生している事態である。
そもそも赤い状態をそのままにして放置している事自体が変なのかもしれないが、
取り敢えず set-height をする前に sgr0 をする必要はある気がする。

$_ble_term_sgr0 を出力する様にしてみた。

しかし、どうも ble/canvas/goto.draw する時にまた $_ble_term_sgr0 を出力する
様なので、重複してしまう。問題が発生するのは、ble/canvas/goto.draw の時に既
に目的地にいる場合で、その時は既定では sgr0 の出力も省略されてしまう。
goto.draw の opts=sgr0 は、例え移動が起こらなくても sgr0 の出力を行うという
物であった。→方針を変更して goto.draw に sgr0 を指定して其処で強制的に
sgr0 を出力するという事にした。

* エラーメッセージ "bash: ((: '0': syntax error:" (reported by rux616) [#D1497]
https://github.com/akinomyoga/ble.sh/issues/92

Expand Down
22 changes: 11 additions & 11 deletions src/canvas.sh
Expand Up @@ -1993,7 +1993,7 @@ function ble/canvas/panel/goto-vfill.draw {
local ret
ble/canvas/panel/goto-top-dock.draw
ble/arithmetic/sum "${_ble_canvas_panel_height[@]::_ble_canvas_panel_vfill}"
ble/canvas/goto.draw 0 "$ret"
ble/canvas/goto.draw 0 "$ret" sgr0
return 0
}
## @fn ble/canvas/panel/save-position opts
Expand Down Expand Up @@ -2098,7 +2098,7 @@ function ble/canvas/panel/increase-total-height.draw {
ble/canvas/excursion-start.draw
ble/canvas/put.draw $'\e[1;'$((LINES-bottom_height))'r'
ble/canvas/excursion-end.draw
ble/canvas/goto.draw 0 $((top_height==0?0:top_height-1))
ble/canvas/goto.draw 0 $((top_height==0?0:top_height-1)) sgr0
ble/canvas/put-ind.draw $((top_height-1+delta-_ble_canvas_y))
((_ble_canvas_y=top_height-1+delta))
ble/canvas/excursion-start.draw
Expand All @@ -2112,7 +2112,7 @@ function ble/canvas/panel/increase-total-height.draw {

local old_height=$((top_height+bottom_height))
local new_height=$((old_height+delta))
ble/canvas/goto.draw 0 $((top_height==0?0:top_height-1))
ble/canvas/goto.draw 0 $((top_height==0?0:top_height-1)) sgr0
ble/canvas/put-ind.draw $((new_height-1-_ble_canvas_y)); ((_ble_canvas_y=new_height-1))
ble/canvas/panel/goto-vfill.draw &&
ble/canvas/put-il.draw "$delta" vfill
Expand Down Expand Up @@ -2143,13 +2143,13 @@ function ble/canvas/panel#set-height.draw {

case :$opts: in
(*:clear:*)
ble/canvas/panel#goto.draw "$index"
ble/canvas/panel#goto.draw "$index" 0 0 sgr0
ble/canvas/put-clear-lines.draw "$old_height" "$new_height" panel ;;
(*:shift:*) # 先頭に行挿入
ble/canvas/panel#goto.draw "$index"
ble/canvas/panel#goto.draw "$index" 0 0 sgr0
ble/canvas/put-il.draw "$delta" panel ;;
(*) # 末尾に行挿入
ble/canvas/panel#goto.draw "$index" 0 "$old_height"
ble/canvas/panel#goto.draw "$index" 0 "$old_height" sgr0
ble/canvas/put-il.draw "$delta" panel ;;
esac

Expand All @@ -2158,13 +2158,13 @@ function ble/canvas/panel#set-height.draw {

case :$opts: in
(*:clear:*)
ble/canvas/panel#goto.draw "$index"
ble/canvas/panel#goto.draw "$index" 0 0 sgr0
ble/canvas/put-clear-lines.draw "$old_height" "$new_height" panel ;;
(*:shift:*) # 先頭を削除
ble/canvas/panel#goto.draw "$index" 0 0
ble/canvas/panel#goto.draw "$index" 0 0 sgr0
ble/canvas/put-dl.draw "$delta" panel ;;
(*) # 末尾を削除
ble/canvas/panel#goto.draw "$index" 0 "$new_height"
ble/canvas/panel#goto.draw "$index" 0 "$new_height" sgr0
ble/canvas/put-dl.draw "$delta" panel ;;
esac

Expand Down Expand Up @@ -2267,7 +2267,7 @@ function ble/canvas/panel/ensure-tmargin.draw {
ble/canvas/excursion-start.draw
ble/canvas/put.draw $'\e[1;'$((LINES-bottom_height))'r'
ble/canvas/excursion-end.draw
ble/canvas/goto.draw 0 0
ble/canvas/goto.draw 0 0 sgr0
if [[ $_ble_term_ri ]]; then
ble/canvas/put-ri.draw "$tmargin"
ble/canvas/put-cud.draw "$tmargin"
Expand All @@ -2290,7 +2290,7 @@ function ble/canvas/panel/ensure-tmargin.draw {
fi
fi

ble/canvas/goto.draw 0 0
ble/canvas/goto.draw 0 0 sgr0
if [[ $_ble_term_ri ]]; then
ble/canvas/put-ri.draw "$tmargin"
ble/canvas/put-cud.draw "$tmargin"
Expand Down

0 comments on commit 4bdfdbf

Please sign in to comment.