Skip to content

Commit

Permalink
Merge branch 'release/v2.2.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
joonro committed Apr 14, 2022
2 parents 0c1744f + acbc6f5 commit 6b2a3c4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
7 changes: 6 additions & 1 deletion README.org
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ by [[http://thepowershellguy.com/][the PowerShell Guy]], and [[https://github.co

It provides two main functionalities:

1. Directly provide coloring outputs of ~Get-ChildItem~ by modifying
1. Directly provide coloring of ~Get-ChildItem~ output by modifying
~Out-Default~. Once the module is imported, ~Get-ChildItem~'s output will
be automatically colored. It does support pipeline (e.g., ~Get-ChildItem |
grep ".git"~). Also, now the directory name and the headers of its output
Expand Down Expand Up @@ -45,6 +45,8 @@ After cloning the repo, you can put files in =/src= folder into
=Get-ChildItemColor= folder under your =PSModulePath=
(e.g., =$ENV:UserProfile\Documents\PowerShell\Modules= for PowerShell 6 and
later). The =master= branch always contains the latest release version.
** Install from [[https://chocolatey.org][Chocolatey]]
The module is available as a [[https://chocolatey.org/packages/get-childitemcolor][Chocolatey package]]. Install it using =choco install get-childitemcolor=.
* Usage
When you import the module:

Expand Down Expand Up @@ -100,6 +102,9 @@ $Global:GetChildItemColorVerticalSpace = 1
* Authors
- [[http://github.com/joonro][Joon Ro]].
* Changelog
** v2.2.1
- [[https://github.com/joonro/Get-ChildItemColor/pull/44][Fix uint32 error in cell width calculation]]. (Thanks to [[https://github.com/DanielCarmingham][DanielCarmingham]])
- [[https://github.com/joonro/Get-ChildItemColor/pull/35][Add Chocolatey install instructions]]. (Thanks to [[https://github.com/pauby][pauby]])
** v2.2.0
- Fix #27, Display issue with Chinese. (Thanks to [[https://github.com/shiena][shiena]])
** v2.1.1
Expand Down
18 changes: 9 additions & 9 deletions src/PSColorHelper.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,19 @@ function LengthInBufferCells
function LengthInBufferCell
{
param ([char]$Char)
# The following is based on http://www.cl.cam.ac.uk/~mgk25/c/wcwidth.c
# The following is based on https://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c
# which is derived from https://www.unicode.org/Public/UCD/latest/ucd/EastAsianWidth.txt
[bool]$isWide = $Char -ge 0x1100 -and
($Char -le 0x115f -or # Hangul Jamo init. consonants
$Char -eq 0x2329 -or $Char -eq 0x232a -or
([uint32]($Char - 0x2e80) -le (0xa4cf - 0x2e80) -and
$Char -ne 0x303f) -or # CJK ... Yi
([uint32]($Char - 0xac00) -le (0xd7a3 - 0xac00)) -or # Hangul Syllables
([uint32]($Char - 0xf900) -le (0xfaff - 0xf900)) -or # CJK Compatibility Ideographs
([uint32]($Char - 0xfe10) -le (0xfe19 - 0xfe10)) -or # Vertical forms
([uint32]($Char - 0xfe30) -le (0xfe6f - 0xfe30)) -or # CJK Compatibility Forms
([uint32]($Char - 0xff00) -le (0xff60 - 0xff00)) -or # Fullwidth Forms
([uint32]($Char - 0xffe0) -le (0xffe6 - 0xffe0)))
($Char -ge 0x2e80 -and $Char -le 0xa4cf -and
$Char -ne 0x303f) -or # CJK ... Yi
($Char -ge 0xac00 -and $Char -le 0xd7a3) -or # Hangul Syllables
($Char -ge 0xf900 -and $Char -le 0xfaff) -or # CJK Compatibility Ideographs
($Char -ge 0xfe10 -and $Char -le 0xfe19) -or # Vertical forms
($Char -ge 0xfe30 -and $Char -le 0xfe6f) -or # CJK Compatibility Forms
($Char -ge 0xff00 -and $Char -le 0xff60) -or # Fullwidth Forms
($Char -ge 0xffe0 -and $Char -le 0xffe6))

# We can ignore these ranges because .Net strings use surrogate pairs
# for this range and we do not handle surrogage pairs.
Expand Down

0 comments on commit 6b2a3c4

Please sign in to comment.