-
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add functionality to override the grapheme cluster width. This is useful when dealing with terminals that do not confirm to the Unicode specification and display a grapheme cluster with the incorrect width. By having uniseg report back the same response as the terminal, this allows for the terminal to match cursor positioning with the application. While the results are incorrect, this still provides a better user experience. Signed-off-by: Michael Lorant <[email protected]>
- Loading branch information
1 parent
03509a9
commit 27c8665
Showing
2 changed files
with
21 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package uniseg | ||
|
||
var GraphemeClusterWidthOverrides map[string]int | ||
|
||
func overrideWidth(gc string, w int) int { | ||
if len(GraphemeClusterWidthOverrides) == 0 { | ||
return w | ||
} | ||
|
||
if width, ok := GraphemeClusterWidthOverrides[gc]; ok { | ||
return width | ||
} | ||
|
||
return w | ||
} |