Skip to content

Commit

Permalink
edit (ble/textarea#render): fix interleaving "_ble_util_buffer" and "…
Browse files Browse the repository at this point in the history
…DRAW_BUFF"
  • Loading branch information
akinomyoga committed Mar 1, 2023
1 parent a835b83 commit 6d61388
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/ChangeLog.md
Expand Up @@ -355,6 +355,7 @@
- main (`ble-reload`): fix failure by non-existent rcfile `#D1931` 0ceb0cb
- syntax (`ble/syntax/highlight/vartype`): check variable in global scope `#D1932` b7026de
- menu (linewise): fix layout calculation with variable width of line prefix (reported by bkerin) `#D1979` cc852dc
- edit (`ble/textarea#render`): fix interleaving outputs to `_ble_util_buffer` and `DRAW_BUFF` `#D1987` xxxxxxx

## Documentation

Expand Down
20 changes: 20 additions & 0 deletions note.txt
Expand Up @@ -6661,6 +6661,26 @@ bash_tips

2023-03-01

* vim mode ! で複数行の結果を返すと描画位置がずれて変な事になる [#D1987]

どうやら行数が増えると駄目な様だ。単に複数行を replace-range で挿入する
widget を作成しても問題は再現しない。終了時の _ble_canvas_y の問題だろうか。
うーん。.replace-range を実行している時の _ble_canvas_y の位置は正しい。ちゃ
んと復帰した位置になっている。またこの時点で buffer.flush を実行しても問題
の振る舞いに変化はなかったので buffering の問題ではない気がする。

* todo: 行末の場合には末尾の改行は省略する。然しこの処置は現在のバ
グを隠してしまうので現在のバグを修正してからにする。

どうやら determine-scroll をした瞬間にずれている? 中身を見ると panel_height
を拡張して更にその分だけカーソル位置も移動したことになっているが、実際には
移動していないということが問題になっている気がする。

何か分かった気がする。 DRAW_BUFF の中身をスクロールの直後で flush したら問
題が発生しなくなった。これが意味する所は、後ろの方の出力で DRAW_BUFF ではな
くて直接 util/buffer に出力している箇所があるという事。特に各行の文字数を調
整する部分が怪しい。

* global: コード中の /dev/tty は予め持っておいた fd に置き換えるべきなのでは [#D1986]
修正した。

Expand Down
4 changes: 2 additions & 2 deletions src/edit.sh
Expand Up @@ -2991,6 +2991,7 @@ function ble/textarea#render/.erase-forward-line.draw {
## 現在の表示高さを指定します。再配置後の表示高さを返します。
## @var[in,out] umin umax
## 描画範囲を表示領域に制限して返します。
## @var[out] DRAW_BUFF
##
## @var[in] cols
## @var[in] begx begy endx endy cx cy
Expand Down Expand Up @@ -3147,8 +3148,8 @@ function ble/textarea#render/.erase-rprompt {
## rps1_transient の時に、次の行に行く前に行末の無駄な空白を削除します。
## @var[in] text
## @var[in] _ble_textmap_pos
## @var[out] DRAW_BUFF
function ble/textarea#render/.cleanup-trailing-spaces-after-newline {
local -a DRAW_BUFF=()
local -a buffer; ble/string#split-lines buffer "$text"
local line index=0 pos
for line in "${buffer[@]}"; do
Expand All @@ -3158,7 +3159,6 @@ function ble/textarea#render/.cleanup-trailing-spaces-after-newline {
ble/canvas/put.draw "$_ble_term_el"
((index++))
done
ble/canvas/bflush.draw
_ble_prompt_rps1_shown=
}

Expand Down

0 comments on commit 6d61388

Please sign in to comment.