diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2021-05-19 07:41:58 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-19 07:41:58 -0400 |
commit | 40025895461cb9b3b22f0f7cbe92ccad75ad637c (patch) | |
tree | d87d6106dcbe4626c88196f868994f977b3a330a /vendor/github.com/mattn/go-runewidth/runewidth.go | |
parent | c84fdedda827d5d34e0d53622ed39b56c386df09 (diff) | |
parent | 6b187e445897ef301708cd962f630e982bc60224 (diff) | |
download | podman-40025895461cb9b3b22f0f7cbe92ccad75ad637c.tar.gz podman-40025895461cb9b3b22f0f7cbe92ccad75ad637c.tar.bz2 podman-40025895461cb9b3b22f0f7cbe92ccad75ad637c.zip |
Merge pull request #10396 from containers/dependabot/go_modules/github.com/vbauerster/mpb/v6-6.0.4
Bump github.com/vbauerster/mpb/v6 from 6.0.3 to 6.0.4
Diffstat (limited to 'vendor/github.com/mattn/go-runewidth/runewidth.go')
-rw-r--r-- | vendor/github.com/mattn/go-runewidth/runewidth.go | 52 |
1 files changed, 42 insertions, 10 deletions
diff --git a/vendor/github.com/mattn/go-runewidth/runewidth.go b/vendor/github.com/mattn/go-runewidth/runewidth.go index f3871a624..3d7fa560b 100644 --- a/vendor/github.com/mattn/go-runewidth/runewidth.go +++ b/vendor/github.com/mattn/go-runewidth/runewidth.go @@ -12,8 +12,14 @@ var ( // EastAsianWidth will be set true if the current locale is CJK EastAsianWidth bool + // StrictEmojiNeutral should be set false if handle broken fonts + StrictEmojiNeutral bool = true + // DefaultCondition is a condition in current locale - DefaultCondition = &Condition{} + DefaultCondition = &Condition{ + EastAsianWidth: false, + StrictEmojiNeutral: true, + } ) func init() { @@ -83,26 +89,52 @@ var nonprint = table{ // Condition have flag EastAsianWidth whether the current locale is CJK or not. type Condition struct { - EastAsianWidth bool + EastAsianWidth bool + StrictEmojiNeutral bool } // NewCondition return new instance of Condition which is current locale. func NewCondition() *Condition { return &Condition{ - EastAsianWidth: EastAsianWidth, + EastAsianWidth: EastAsianWidth, + StrictEmojiNeutral: StrictEmojiNeutral, } } // RuneWidth returns the number of cells in r. // See http://www.unicode.org/reports/tr11/ func (c *Condition) RuneWidth(r rune) int { - switch { - case r < 0 || r > 0x10FFFF || inTables(r, nonprint, combining, notassigned): - return 0 - case (c.EastAsianWidth && IsAmbiguousWidth(r)) || inTables(r, doublewidth): - return 2 - default: - return 1 + // optimized version, verified by TestRuneWidthChecksums() + if !c.EastAsianWidth { + switch { + case r < 0x20 || r > 0x10FFFF: + return 0 + case (r >= 0x7F && r <= 0x9F) || r == 0xAD: // nonprint + return 0 + case r < 0x300: + return 1 + case inTable(r, narrow): + return 1 + case inTables(r, nonprint, combining): + return 0 + case inTable(r, doublewidth): + return 2 + default: + return 1 + } + } else { + switch { + case r < 0 || r > 0x10FFFF || inTables(r, nonprint, combining): + return 0 + case inTable(r, narrow): + return 1 + case inTables(r, ambiguous, doublewidth): + return 2 + case !c.StrictEmojiNeutral && inTables(r, ambiguous, emoji, narrow): + return 2 + default: + return 1 + } } } |