Skip to content

Commit

Permalink
canvas: fix wrong coordinate calculation on linefolding
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Jun 11, 2021
1 parent b2713d9 commit 9badb5f
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 8 deletions.
10 changes: 9 additions & 1 deletion lib/test-canvas.sh
Expand Up @@ -35,7 +35,7 @@ function ble/test:canvas/trace.contra {
#------------------------------------------------------------------------------
# from lib/test-canvas.sh

ble/test/start-section 'ble/canvas/trace (relative:confine:measure-bbox)' 12
ble/test/start-section 'ble/canvas/trace (relative:confine:measure-bbox)' 17

# test1

Expand Down Expand Up @@ -98,6 +98,14 @@ EOF
[[ $_ble_test_canvas_contra ]] &&
ble/test 'echo "$x1-$x2:$y1-$y2"' stdout='0-10:-1-1'

(
LINES=10 COLUMNS=10 _ble_term_xenl=1
ble/test 'x=0 y=0; ble/canvas/trace "HelloWorld"; ret=$x,$y' ret=10,0
ble/test 'x=0 y=0; ble/canvas/trace "HelloWorldH"; ret=$x,$y' ret=1,1
ble/test 'x=0 y=0; ble/canvas/trace "HelloWorldHello"; ret=$x,$y' ret=5,1
ble/test 'x=0 y=0; ble/canvas/trace "HelloWorldHelloWorldHello"; ret=$x,$y' ret=5,2
ble/test 'x=0 y=0; ble/canvas/trace "HelloWorldHelloWorldHelloWorldHello"; ret=$x,$y' ret=5,3
)

#------------------------------------------------------------------------------
# from test/check-trace.sh
Expand Down
1 change: 1 addition & 0 deletions memo/ChangeLog.md
Expand Up @@ -29,6 +29,7 @@
- syntax: properly support case patterns `#D1474` `#D1475` `#D1476` 64b55b7
- keymap/vi: add `ble/keymap:vi/script/get-mode` for user-defined mode strings `#D1488` f25a6e8 462918d
- prompt: support multiline `prompt_rps1` `#D1502` 4fa139a
- canvas: fix wrong coordinate calculation on linefolding `#D1602` 0000000
- syntax: support tilde expansions in parameter expansions `#D1513` 0506df2
- decode: support `ble-bind -m KEYMAP --cursor DECSCUSR` (motivated by jmederosalvarado) `#D1514` `#D1515` `#D1516` 79d671d
- edit: support `nsearch` options (motivated by Alyetama, rashil2000, carv-silva) `#D1517` 9125795
Expand Down
33 changes: 27 additions & 6 deletions note.txt
Expand Up @@ -1602,12 +1602,6 @@ bash_tips
い。このサイトの RGB 値が実際に sRGB なのか何なのか確認して、その上で他の色
についても変換を確認するのが良い気がする。

2021-05-16

* edit: BUG とても長いプロンプトにした時に列計算が壊れている。

また右端から入力を始めた時の折返しが正しくできていない。

2021-05-15

* AUR blesh-git のカスタム update について
Expand Down Expand Up @@ -4675,6 +4669,33 @@ bash_tips
Done (実装ログ)
-------------------------------------------------------------------------------

2021-06-11

* 2021-05-16 edit: BUG とても長いプロンプトにした時に列計算が壊れている (reported by telometto) [#D1602]
また右端から入力を始めた時の折返しが正しくできていない。

2021-06-11 stackoverflow で報告されていた (by telometto@stackoverflow)
https://stackoverflow.com/questions/67917673/odd-long-space-in-bash-when-writing-commands

| うーん。ble.sh のバグが stackoverflow で報告されている。これは自分でも気
| づいていた筈の問題である。何故忘れていたのだろう。割合最近気づいた事だっ
| た筈である。調べたら 2021-05-16 の項目を見つけたのでそれに移動する事にす
| る。

取り敢えず修正する。抑々 trace が怪しいという事なので計算結果について確認する。


$ x=0 y=0; LINES=10 COLUMNS=10 ble/canvas/trace 'HelloWorld'; declare -p x y ret
x=10 y=0
$ x=0 y=0; LINES=10 COLUMNS=10 ble/canvas/trace 'HelloWorldH'; declare -p x y ret
x=2 y=2

物凄く意味不明な間違い方をしている。うーん。implicit-move が悪いという所ま
で特定した。と思ったら分かった。折返しが発生すると分かった場合に x+=w を二
重に実行している。2回目の x+=w を削除したら普通の振る舞いに戻った。調べてみ
るとこれは 4fa139ad 2021-03-21 に複数行 "rps1" に対応した時に埋め込んだバグ
であった。

2021-06-10

* prompt: 最適化 git の現在の dirty 状態は background で取得できる様にしたい [#D1601]
Expand Down
2 changes: 1 addition & 1 deletion src/canvas.sh
Expand Up @@ -760,7 +760,7 @@ function ble/canvas/trace/.implicit-move {
# 一杯になると仮定しているが端末による]
((y++,x=w<xlimit?w:xlimit))
else
((x+=w,y+=x/cols,x%=cols,
((y+=x/cols,x%=cols,
xenl&&x==0&&(y--,x=cols)))
fi
if [[ $flag_bbox ]]; then
Expand Down

0 comments on commit 9badb5f

Please sign in to comment.