[GH-ISSUE #118] Horizontal border is kind of weird #93

Closed
opened 2026-03-04 01:01:52 +03:00 by kerem · 4 comments
Owner

Originally created by @zyuyou on GitHub (May 19, 2018).
Original GitHub issue: https://github.com/rivo/tview/issues/118

System: macOS 10.13.4
go version go1.10.2 darwin/amd64
Terminal: iterm3
Terminal font: Menlo (Actually same as other, also on Windows and Linux)

app := tview.NewApplication()

table := xapp.NewDefaultTable("Name", "Desc", "Subversion")

table.AddRow("row1_name", "row1_desc", "row1_subversion")
table.AddRow("row2_name", "row2_desc", "row2_subversion")
table.AddRow("row3_name", "row3_desc", "row3_subversion")

table.Select(0, 0).SetFixed(1, 1).SetDoneFunc(func(key tcell.Key) {
	if key == tcell.KeyEscape {
		app.Stop()
	}
	if key == tcell.KeyEnter {
		table.SetSelectable(true, false)
	}
}).SetSelectedFunc(func(row int, column int) {
	table.GetCell(row, column).SetTextColor(tcell.ColorRed)
	table.SetSelectable(false, false)
})

table.SetBorders(true)
table.SetRect(1, 1, 100, 20)

if err := app.SetRoot(table, true).Run(); err != nil {
	panic(err)
}

image

Originally created by @zyuyou on GitHub (May 19, 2018). Original GitHub issue: https://github.com/rivo/tview/issues/118 System: macOS 10.13.4 go version go1.10.2 darwin/amd64 Terminal: iterm3 Terminal font: Menlo (Actually same as other, also on Windows and Linux) ```go app := tview.NewApplication() table := xapp.NewDefaultTable("Name", "Desc", "Subversion") table.AddRow("row1_name", "row1_desc", "row1_subversion") table.AddRow("row2_name", "row2_desc", "row2_subversion") table.AddRow("row3_name", "row3_desc", "row3_subversion") table.Select(0, 0).SetFixed(1, 1).SetDoneFunc(func(key tcell.Key) { if key == tcell.KeyEscape { app.Stop() } if key == tcell.KeyEnter { table.SetSelectable(true, false) } }).SetSelectedFunc(func(row int, column int) { table.GetCell(row, column).SetTextColor(tcell.ColorRed) table.SetSelectable(false, false) }) table.SetBorders(true) table.SetRect(1, 1, 100, 20) if err := app.SetRoot(table, true).Run(); err != nil { panic(err) } ``` ![image](https://user-images.githubusercontent.com/1913492/40270037-3dcd86b0-5bb9-11e8-9f88-7208542cbe24.png)
kerem closed this issue 2026-03-04 01:01:52 +03:00
Author
Owner

@rivo commented on GitHub (May 23, 2018):

You closed this yourself. Did you find the cause of the problem?

There was an issue similar to this one: #66. Are they related?

<!-- gh-comment-id:391292162 --> @rivo commented on GitHub (May 23, 2018): You closed this yourself. Did you find the cause of the problem? There was an issue similar to this one: #66. Are they related?
Author
Owner

@zyuyou commented on GitHub (May 25, 2018):

It works fine when I set LC_CTYPE="en_US.UTF-8". and LC_CTYPE="zh_CN.UTF-8" was make horizontal border wrong. I found the solution from gdamore/tcell#203 .

<!-- gh-comment-id:391913334 --> @zyuyou commented on GitHub (May 25, 2018): It works fine when I set `LC_CTYPE="en_US.UTF-8"`. and `LC_CTYPE="zh_CN.UTF-8"` was make horizontal border wrong. I found the solution from gdamore/tcell#203 .
Author
Owner

@rivo commented on GitHub (May 25, 2018):

Thanks for the feedback!

<!-- gh-comment-id:392124880 --> @rivo commented on GitHub (May 25, 2018): Thanks for the feedback!
Author
Owner

@sisyphsu commented on GitHub (May 27, 2019):

Copy from gdamore/tcell#203

Another solution, you can force runewidth to return 1 for normal symbols, like '-':

import "github.com/mattn/go-runewidth"

func main() {
    runewidth.DefaultCondition.EastAsianWidth = false
}

Other unicode word will still be 2, like '中'.

<!-- gh-comment-id:496255944 --> @sisyphsu commented on GitHub (May 27, 2019): Copy from [gdamore/tcell#203](https://github.com/gdamore/tcell/issues/203) Another solution, you can force `runewidth` to return 1 for normal symbols, like '-': ```golang import "github.com/mattn/go-runewidth" func main() { runewidth.DefaultCondition.EastAsianWidth = false } ``` Other unicode word will still be 2, like '中'.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/tview#93
No description provided.