Skip to content

Commit

Permalink
util (ble/util/buffer): hide cursor on rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Feb 2, 2022
1 parent dfc6221 commit e332dc5
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 2 deletions.
2 changes: 2 additions & 0 deletions docs/ChangeLog.md
Expand Up @@ -140,6 +140,7 @@
- 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 dc3827b
- edit (`ble-bind -x`): preserve multiline prompts on execution of `bind -x` commands (requested by SuperSandro2000) `#D1755` 7d05a28
- util (`ble/util/buffer`): hide cursor in rendering `#D1758` 0000000

## Fixes

Expand Down Expand Up @@ -306,6 +307,7 @@
- main: check `IN_NIX_SHELL` to inactivate ble.sh in nix-shell (suggested by SuperSandro2000) `#D1747` b4bd955
- canvas: test the terminal for the sequence of clearing `DECSTBM` `#D1748` 4b1601d
- main: check `/dev/tty` on startup (reported by andychu) `#D1749` 711c69f
- util: add identification of Windows Terminal `wt` `#D1758` 0000000

## Internal changes and fixes

Expand Down
28 changes: 28 additions & 0 deletions note.txt
Expand Up @@ -1825,6 +1825,8 @@ bash_tips

* term: prompt_staus_line でずれが生じる端末がやはり存在している。何故だろうか。

2022-02-02 windows terminal でもずれる

2021-12-22

* ディレクトリ固有の local commands & aliases を可能にする?
Expand Down Expand Up @@ -5942,6 +5944,32 @@ bash_tips
Done (実装ログ)
-------------------------------------------------------------------------------

2022-02-02

* term: wt で 描画中のカーソル移動が気になる [#D1758]

flush する時か、或いは描画シーケンス自体にカーソル消去・表示のコードを埋め
込むべきではないか。

一方で現在の表示状態はまた別の箇所で管理していた筈である。うーん。現在のコー
ドだと cursor-state/hidden は描画とは独立に管理している。なので描画に対して
表示・非表示を埋め込もうとすると buffering によって順序が入れ替わっておかし
な事になる。それよりは画面に出力する瞬間に一時的に hidden にするのが良い気
がする。うーん。buffer.flush に介入するのが一番簡単の気がする。怖いので一部
の端末だけで試験的に実行する? と思ったがテストという観点から考えると取り敢
えず全部 on にして試す事にする。

→実装した。取り敢えず変な影は表示されなくなった。それでも何だか点滅してい
る様な気がするが仕方がない事である。contra/screen では特に問題はない。また
mintty でも特に問題は見られない。mintty/tmux でも問題は見られない。これは採
用する事にする。

* 序でに Windows Terminal の identification も実装する事にする。調べるとど
うも hardcode している様に見える。取り敢えずこれに対して判定する。カーソ
ル形状の変更にも対応している様だ。

https://github.com/microsoft/terminal/blob/bcc38d04cef39fe9d939bf5c10bca5e3bd0a9118/src/terminal/adapter/adaptDispatch.cpp#L779-L782

2022-02-01

* util (trap): SIGWINCH を沢山呼び出した後にどんどん重くなる (reported by SuperSandro2000) [#D1757]
Expand Down
16 changes: 14 additions & 2 deletions src/util.sh
Expand Up @@ -4039,7 +4039,15 @@ function ble/util/buffer.print {
ble/util/buffer "$1"$'\n'
}
function ble/util/buffer.flush {
IFS= builtin eval 'ble/util/put "${_ble_util_buffer[*]-}"'
IFS= builtin eval 'local text="${_ble_util_buffer[*]-}"'

# Note: 出力の瞬間だけカーソルを非表示にする。Windows terminal 途中
# のカーソル移動も無理やり表示しようとする端末に対する対策。
[[ $_ble_term_state == internal ]] &&
[[ $_ble_term_cursor_hidden_internal != hidden ]] &&
text=$_ble_term_civis$text$_ble_term_cvvis

ble/util/put "$text"
_ble_util_buffer=()
}
function ble/util/buffer.clear {
Expand Down Expand Up @@ -5751,7 +5759,7 @@ function ble/term/cursor-state/.update {

if [[ ! $_ble_term_Ss ]]; then
case $_ble_term_TERM in
(mintty:*|xterm:*|RLogin:*|kitty:*|screen:*|tmux:*|contra:*|cygwin:*)
(mintty:*|xterm:*|RLogin:*|kitty:*|screen:*|tmux:*|contra:*|cygwin:*|wezterm:*|wt:*)
local _ble_term_Ss=$'\e[@1 q' ;;
esac
fi
Expand Down Expand Up @@ -5828,6 +5836,10 @@ function ble/term/DA2/initialize-term {
case $DA2R in
('0;0;0')
_ble_term_TERM[depth]=wezterm:0 ;;
('0;10;1') # Windows Terminal
# 現状ハードコードされている。
# https://github.com/microsoft/terminal/blob/bcc38d04/src/terminal/adapter/adaptDispatch.cpp#L779-L782
_ble_term_TERM[depth]=wt:0 ;;
('1;0'?????';0')
_ble_term_TERM[depth]=foot:${DA2R:3:5} ;;
('1;'*)
Expand Down

0 comments on commit e332dc5

Please sign in to comment.