Closed gitlost closed 7 years ago
Looks good on my end. Flagging a review from @miya0001 for a double-check
Thanks @miya0001 - it's great to have a native kanji and kana user on board!
Thanks for your work on this, @gitlost and @miya0001. I've tagged a v0.11.4
release.
PR https://github.com/wp-cli/php-cli-tools/pull/109 and issue https://github.com/wp-cli/php-cli-tools/issues/106
For PR https://github.com/wp-cli/php-cli-tools/pull/109 (incorrect wrapping of East Asian double-width chars in tables), adds an
is_width
arg tosafe_substr()
to make it interpret thelength
arg as a spacing width, and uses the East Asian Width regex (now refactored to load in a function) to adjust accordingly (a slow algorithm but couldn't think of anything better). Uses this inAscii::row()
.For issue https://github.com/wp-cli/php-cli-tools/issues/106 (related https://github.com/wp-cli/wp-cli/pull/2458), adds
pre_colorized
arg to various functions, and addsAscii::set/isPreColorized()
andTable::set/isAsciiPreColorize()
(the latter to be used via a correspondingascii_pre_colorized
arg to be added toWP_CLI/Formatter
, see https://github.com/gitlost/wp-cli/pull/15.)Also centralizes decolorization into
Colors::decolorize()
, adding akeep
arg to optionally keep either tokens or encodings.Also makes sure
Colors::colorize()
only reads from cache after checkingshouldColorize()
.Also marks as unused the
colored
arg toColors::cacheString()
, and stops using thedecolorized
cache element inlength()
andwidth()
as it never gets looked up if passed a colorized string (as they're indexed on the original string).Also replicates the padding logic of
safe_str_pad()
inColors::pad()
and moves decolorization toColors::width()
, as it seems better that low-level funcs don't referenceColors
.Also makes
length
arg ofsafe_substr()
cross PHP compat whethernull
orfalse
.Also adds an optional
encoding
arg to various functions to save some processing, and makesmb_detect_encoding()
use strict.