mirror of
https://github.com/gdamore/tcell.git
synced 2025-04-24 13:48:51 +08:00
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.
This commit is contained in:
parent
a642547922
commit
2f889d79bd
21
cell.go
21
cell.go
@ -1,4 +1,4 @@
|
||||
// Copyright 2019 The TCell Authors
|
||||
// Copyright 2022 The TCell Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use file except in compliance with the License.
|
||||
@ -15,6 +15,8 @@
|
||||
package tcell
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
runewidth "github.com/mattn/go-runewidth"
|
||||
)
|
||||
|
||||
@ -175,3 +177,20 @@ func (cb *CellBuffer) Fill(r rune, style Style) {
|
||||
c.width = 1
|
||||
}
|
||||
}
|
||||
|
||||
var runeConfig *runewidth.Condition;
|
||||
func init() {
|
||||
// The defaults for the runewidth package are poorly chosen for terminal
|
||||
// applications. We however will honor the setting in the environment if
|
||||
// it is set.
|
||||
if os.Getenv("RUNEWIDTH_EASTASIAN") == "" {
|
||||
runewidth.DefaultCondition.EastAsianWidth = false;
|
||||
}
|
||||
|
||||
// For performance reasons, we create a lookup table. However some users
|
||||
// might be more memory conscious. If that's you, set the TCELL_MINIMIZE
|
||||
// environment variable.
|
||||
if os.Getenv("TCELL_MINIMIZE") == "" {
|
||||
runewidth.CreateLUT()
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user