Skip to content

Commit 2f889d7

Browse files
committed
Make RUNEWIDTH_EASTASIAN=0 the default.
fixes #578 Also, while here, create a look up table for performance reasons. This can be suppressed by a new TCELL_MINIMIZE environment variable, if RAM is precious. Tcell applications should work out of the box by default for most users in East Asian locales now.
1 parent a642547 commit 2f889d7

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

cell.go

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2019 The TCell Authors
1+
// Copyright 2022 The TCell Authors
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use file except in compliance with the License.
@@ -15,6 +15,8 @@
1515
package tcell
1616

1717
import (
18+
"os"
19+
1820
runewidth "github.com/mattn/go-runewidth"
1921
)
2022

@@ -175,3 +177,20 @@ func (cb *CellBuffer) Fill(r rune, style Style) {
175177
c.width = 1
176178
}
177179
}
180+
181+
var runeConfig *runewidth.Condition;
182+
func init() {
183+
// The defaults for the runewidth package are poorly chosen for terminal
184+
// applications. We however will honor the setting in the environment if
185+
// it is set.
186+
if os.Getenv("RUNEWIDTH_EASTASIAN") == "" {
187+
runewidth.DefaultCondition.EastAsianWidth = false;
188+
}
189+
190+
// For performance reasons, we create a lookup table. However some users
191+
// might be more memory conscious. If that's you, set the TCELL_MINIMIZE
192+
// environment variable.
193+
if os.Getenv("TCELL_MINIMIZE") == "" {
194+
runewidth.CreateLUT()
195+
}
196+
}

0 commit comments

Comments
 (0)