Skip to content

Commit

Permalink
Make RUNEWIDTH_EASTASIAN=0 the default.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
gdamore committed Dec 30, 2022
1 parent a642547 commit 2f889d7
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion 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.
Expand All @@ -15,6 +15,8 @@
package tcell

import (
"os"

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

Expand Down Expand Up @@ -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()
}
}

0 comments on commit 2f889d7

Please sign in to comment.