diff options
author | Junegunn Choi <junegunn.c@gmail.com> | 2023-01-16 01:22:02 +0900 |
---|---|---|
committer | Junegunn Choi <junegunn.c@gmail.com> | 2023-01-16 01:26:39 +0900 |
commit | 0c5956c43c1604d8e4364f08369dc4c58295ef3c (patch) | |
tree | 1c7a4601c7b2b108febefdde6cab9117ebe144f4 /src/tui/light.go | |
parent | 1c83b3969185393f0427463a39ef1523c273c16c (diff) |
Better support for Windows terminals
* Default border style on Windows is changed to `sharp` because some
Windows terminals are not capable of displaying `rounded` border
characters correctly.
* If your terminal emulator renders each box-drawing character with
2 columns, set `RUNEWIDTH_EASTASIAN` environment variable to `1`.
Diffstat (limited to 'src/tui/light.go')
-rw-r--r-- | src/tui/light.go | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/tui/light.go b/src/tui/light.go index c41de480..578118b7 100644 --- a/src/tui/light.go +++ b/src/tui/light.go @@ -651,6 +651,10 @@ func (r *LightRenderer) Clear() { r.flush() } +func (r *LightRenderer) NeedScrollbarRedraw() bool { + return false +} + func (r *LightRenderer) RefreshWindows(windows []Window) { r.flush() } @@ -743,13 +747,14 @@ func (w *LightWindow) drawBorderHorizontal(top, bottom bool) { if w.preview { color = ColPreviewBorder } + hw := runewidth.RuneWidth(w.border.horizontal) if top { w.Move(0, 0) - w.CPrint(color, repeat(w.border.horizontal, w.width)) + w.CPrint(color, repeat(w.border.horizontal, w.width/hw)) } if bottom { w.Move(w.height-1, 0) - w.CPrint(color, repeat(w.border.horizontal, w.width)) + w.CPrint(color, repeat(w.border.horizontal, w.width/hw)) } } @@ -780,15 +785,19 @@ func (w *LightWindow) drawBorderAround() { if w.preview { color = ColPreviewBorder } - w.CPrint(color, string(w.border.topLeft)+repeat(w.border.horizontal, w.width-2)+string(w.border.topRight)) + hw := runewidth.RuneWidth(w.border.horizontal) + vw := runewidth.RuneWidth(w.border.vertical) + tcw := runewidth.RuneWidth(w.border.topLeft) + runewidth.RuneWidth(w.border.topRight) + bcw := runewidth.RuneWidth(w.border.bottomLeft) + runewidth.RuneWidth(w.border.bottomRight) + w.CPrint(color, string(w.border.topLeft)+repeat(w.border.horizontal, (w.width-tcw)/hw)+string(w.border.topRight)) for y := 1; y < w.height-1; y++ { w.Move(y, 0) w.CPrint(color, string(w.border.vertical)) - w.CPrint(color, repeat(' ', w.width-2)) + w.CPrint(color, repeat(' ', w.width-vw*2)) w.CPrint(color, string(w.border.vertical)) } w.Move(w.height-1, 0) - w.CPrint(color, string(w.border.bottomLeft)+repeat(w.border.horizontal, w.width-2)+string(w.border.bottomRight)) + w.CPrint(color, string(w.border.bottomLeft)+repeat(w.border.horizontal, (w.width-bcw)/hw)+string(w.border.bottomRight)) } func (w *LightWindow) csi(code string) { |