diff options
| author | Benjamin Sanders <ben@Benjamins-MacBook-Pro.local> | 2025-10-11 10:34:24 -0400 |
|---|---|---|
| committer | Benjamin Sanders <ben@Benjamins-MacBook-Pro.local> | 2025-10-11 10:34:24 -0400 |
| commit | 5571dc766e2143e39762ff0b47c41d1c2e154f4c (patch) | |
| tree | f4f124d314a7e76c04484515aa0fd1f2e271a601 /vendor/bundle/ruby/3.4.0/gems/unicode-display_width-2.6.0 | |
| parent | 359f3309c97fc894b63e0a295c76ab298504d635 (diff) | |
Vendor bundled gems for deployment
Diffstat (limited to 'vendor/bundle/ruby/3.4.0/gems/unicode-display_width-2.6.0')
9 files changed, 577 insertions, 0 deletions
diff --git a/vendor/bundle/ruby/3.4.0/gems/unicode-display_width-2.6.0/CHANGELOG.md b/vendor/bundle/ruby/3.4.0/gems/unicode-display_width-2.6.0/CHANGELOG.md new file mode 100644 index 0000000..4ad7436 --- /dev/null +++ b/vendor/bundle/ruby/3.4.0/gems/unicode-display_width-2.6.0/CHANGELOG.md @@ -0,0 +1,200 @@ +# CHANGELOG + +## 2.6.0 + +- Unicode 16 + +## 2.5.0 + +- Unicode 15.1 + +## 2.4.2 + +More performance improvements: + +- Optimize lookup of first 4096 codepoints +- Avoid overwrite lookup if no overwrites are set + +## 2.4.1 + +- Improve general performance! +- Further improve performance for ASCII strings + +*You should really upgrade - it's much faster now!* + +## 2.4.0 +- Improve performance for ASCII-only strings, by @fatkodima +- Require Ruby 2.4 + +## 2.3.0 + +- Unicode 15.0 + +## 2.2.0 + +- Add *Hangul Jamo Extended-B* block to zero-width chars, thanks @ninjalj #22 + +## 2.1.0 + +- Unicode 14.0 + +## 2.0.0 + +- Release 2.0.0 +- Supports Ruby 3.0 + +## 2.0.0.pre2 + +- Update 2.0 branch to Unicode 13 + +## 2.0.0.pre1 + +Will be published as non-pre version on rubygems.org when Ruby 3.0 is released (December 2020) + +- Introduce new class-based API, which remembers your string-width configuration. See README for details. +- Remove auto-loading of string extension + - You can: `require "unicode/display_width/string_ext"` to continue to use the string extension + - The manual opt-out `require "unicode/display_width/no_string_ext"` is not needed anymore and will + issue a warning in the future +- Remove (already deprecated) String#display_size and String#display_width aliases + +Refactorings / Internal Changes: + +- Freeze string literals +- The Unicode::DisplayWidth now is class, instead of a module, this enables the new config-object API + +## 1.8.0 + +- Unicode 14.0 (last release of 1.x) + +## 1.7.0 + +- Unicode 13 + +## 1.6.1 + +- Fix that ambiguous and overwrite options where ignored for emoji-measuring + +## 1.6.0 + +- Unicode 12.1 + +## 1.5.0 + +- Unicode 12 + +## 1.4.1 + +- Only bundle required lib/* and data/* files in actual rubygem, patch by @tas50 + +## 1.4.0 + +- Unicode 11 + +## 1.3.3 + +- Replace Gem::Util.gunzip with direct zlib implementation + This removes the dependency on rubygems, fixes #17 + +## 1.3.2 + +- Explicitly load rubygems/util, fixes regression in 1.3.1 (autoload issue) + +## 1.3.1 + +- Use `Gem::Util` for `gunzip`, removes deprecation warning, patch by @Schwad + +## 1.3.0 + +- Unicode 10 + +## 1.2.1 + +- Fix bug that `emoji: true` would fail for emoji without modifier + +## 1.2.0 + +- Add zero-width codepoint ranges: U+2060..U+206F, U+FFF0..U+FFF8, U+E0000..U+E0FFF +- Add full-witdh codepoint ranges: U+3400..U+4DBF, U+4E00..U+9FFF, U+F900..U+FAFF, U+20000..U+2FFFD, U+30000..U+3FFFD +- Experimental emoji support using the [unicode-emoji](https://github.com/janlelis/unicode-emoji) gem +- Fix minor bug in index compression scheme + +## 1.1.3 + +- Fix that non-UTF-8 encodings do not throw errors, patch by @windwiny + +## 1.1.2 + +- Reduce memory consumption and increase performance, patch by @rrosenblum + +## 1.1.1 + +- Always load index into memory, fixes #9 + +## 1.1.0 + +- Support Unicode 9.0 + +## 1.0.5 + +- Actually include new index from 1.0.4 + +## 1.0.4 + +- New index format (much smaller) and internal API changes +- Move index generation to a builder plugin for the unicoder gem +- No public API changes + +## 1.0.3 + +- Avoid circular dependency warning + +## 1.0.2 + +- Fix error that gemspec might be invalid under some circumstances (see gh#6) + +## 1.0.1 + +- Inofficially allow Ruby 1.9 + +## 1.0.0 + +- Faster than 0.3.1 +- Advanced determination of character width +- This includes: Treat width of most chars of general categories (Mn, Me, Cf) as 0 +- This includes: Introduce list of characters with special widths +- Allow custom overrides for specific codepoints +- Set required Ruby version to 2.0 +- Add NO_STRING_EXT mode to disable monkey patching +- Internal API & index format changed drastically +- Remove require 'unicode/display_size' (use 'unicode/display_width' instead) + +## 0.3.1 + +- Faster than 0.3.0 +- Deprecate usage of aliases: String#display_size and String#display_length +- Eliminate Ruby warnings (@amatsuda) + +## 0.3.0 + +- Update EastAsianWidth from 7.0 to 8.0 +- Add rake task to update EastAsianWidth.txt +- Move code to generate index from library to Rakefile +- Update project's meta files +- Deprecate requiring 'unicode-display_size' + +## 0.2.0 + +- Update EastAsianWidth from 6.0 to 7.0 +- Don't build index table automatically when not available +- Don't include EastAsianWidth.txt in gem (only index) + + +## 0.1.0 + +- Fix github issue #1 + + +## 0.1.0 + +- Initial release diff --git a/vendor/bundle/ruby/3.4.0/gems/unicode-display_width-2.6.0/MIT-LICENSE.txt b/vendor/bundle/ruby/3.4.0/gems/unicode-display_width-2.6.0/MIT-LICENSE.txt new file mode 100644 index 0000000..7caa2d0 --- /dev/null +++ b/vendor/bundle/ruby/3.4.0/gems/unicode-display_width-2.6.0/MIT-LICENSE.txt @@ -0,0 +1,22 @@ +The MIT LICENSE + +Copyright (c) 2011, 2015-2024 Jan Lelis + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/bundle/ruby/3.4.0/gems/unicode-display_width-2.6.0/README.md b/vendor/bundle/ruby/3.4.0/gems/unicode-display_width-2.6.0/README.md new file mode 100644 index 0000000..3fd7228 --- /dev/null +++ b/vendor/bundle/ruby/3.4.0/gems/unicode-display_width-2.6.0/README.md @@ -0,0 +1,171 @@ +## Unicode::DisplayWidth [![[version]](https://badge.fury.io/rb/unicode-display_width.svg)](https://badge.fury.io/rb/unicode-display_width) [<img src="https://github.com/janlelis/unicode-display_width/workflows/Test/badge.svg" />](https://github.com/janlelis/unicode-display_width/actions?query=workflow%3ATest) + +Determines the monospace display width of a string in Ruby. Useful for all kinds of terminal-based applications. Implementation based on [EastAsianWidth.txt](https://www.unicode.org/Public/UNIDATA/EastAsianWidth.txt) and other data, 100% in Ruby. It does not rely on the OS vendor (like [wcwidth()](https://github.com/janlelis/wcswidth-ruby)) to provide an up-to-date method for measuring string width. + +Unicode version: **16.0.0** (September 2024) + +Supported Rubies: **3.3**, **3.2**, **3.1**, **3.0** + +Old Rubies which might still work: **2.7**, **2.6**, **2.5**, **2.4**, **2.3** + +For even older Rubies, use version 2.3.0 of this gem: **2.3**, **2.2**, **2.1**, **2.0**, **1.9** + +## Version 2.4.2 — Performance Updates + +**If you use this gem, you should really upgrade to 2.4.2 or newer. It's often 100x faster, sometimes even 1000x and more!** + +This is possible because the gem now detects if you use very basic (and common) characters, like ASCII characters. Furthermore, the charachter width lookup code has been optimized, so even when full-width characters are involved, the gem is much faster now. + +## Version 2.0 — Breaking Changes + +Some features of this library were marked deprecated for a long time and have been removed with Version 2.0: + +- Aliases of display_width (…\_size, …\_length) have been removed +- Auto-loading of string core extension has been removed: + +If you are relying on the `String#display_width` string extension to be automatically loaded (old behavior), please load it explicitly now: + +```ruby +require "unicode/display_width/string_ext" +``` + +You could also change your `Gemfile` line to achieve this: + +```ruby +gem "unicode-display_width", require: "unicode/display_width/string_ext" +``` + +## Introduction to Character Widths + +Guessing the correct space a character will consume on terminals is not easy. There is no single standard. Most implementations combine data from [East Asian Width](https://www.unicode.org/reports/tr11/), some [General Categories](https://en.wikipedia.org/wiki/Unicode_character_property#General_Category), and hand-picked adjustments. + +### How this Library Handles Widths + +Further at the top means higher precedence. Please expect changes to this algorithm with every MINOR version update (the X in 1.X.0)! + +Width | Characters | Comment +-------|------------------------------|-------------------------------------------------- +X | (user defined) | Overwrites any other values +-1 | `"\b"` | Backspace (total width never below 0) +0 | `"\0"`, `"\x05"`, `"\a"`, `"\n"`, `"\v"`, `"\f"`, `"\r"`, `"\x0E"`, `"\x0F"` | [C0 control codes](https://en.wikipedia.org/wiki/C0_and_C1_control_codes#C0_.28ASCII_and_derivatives.29) which do not change horizontal width +1 | `"\u{00AD}"` | SOFT HYPHEN +2 | `"\u{2E3A}"` | TWO-EM DASH +3 | `"\u{2E3B}"` | THREE-EM DASH +0 | General Categories: Mn, Me, Cf (non-arabic) | Excludes ARABIC format characters +0 | `"\u{1160}".."\u{11FF}"`, `"\u{D7B0}".."\u{D7FF}"` | HANGUL JUNGSEONG +0 | `"\u{2060}".."\u{206F}"`, `"\u{FFF0}".."\u{FFF8}"`, `"\u{E0000}".."\u{E0FFF}"` | Ignorable ranges +2 | East Asian Width: F, W | Full-width characters +2 | `"\u{3400}".."\u{4DBF}"`, `"\u{4E00}".."\u{9FFF}"`, `"\u{F900}".."\u{FAFF}"`, `"\u{20000}".."\u{2FFFD}"`, `"\u{30000}".."\u{3FFFD}"` | Full-width ranges +1 or 2 | East Asian Width: A | Ambiguous characters, user defined, default: 1 +1 | All other codepoints | - + +## Install + +Install the gem with: + + $ gem install unicode-display_width + +Or add to your Gemfile: + + gem 'unicode-display_width' + +## Usage + +### Classic API + +```ruby +require 'unicode/display_width' + +Unicode::DisplayWidth.of("⚀") # => 1 +Unicode::DisplayWidth.of("一") # => 2 +``` + +#### Ambiguous Characters + +The second parameter defines the value returned by characters defined as ambiguous: + +```ruby +Unicode::DisplayWidth.of("·", 1) # => 1 +Unicode::DisplayWidth.of("·", 2) # => 2 +``` + +#### Custom Overwrites + +You can overwrite how to handle specific code points by passing a hash (or even a proc) as third parameter: + +```ruby +Unicode::DisplayWidth.of("a\tb", 1, "\t".ord => 10)) # => tab counted as 10, so result is 12 +``` + +Please note that using overwrites disables some perfomance optimizations of this gem. + + +#### Emoji Support + +Emoji width support is included, but in must be activated manually. It will adjust the string's size for modifier and zero-width joiner sequences. You also need to add the [unicode-emoji](https://github.com/janlelis/unicode-emoji) gem to your Gemfile: + +```ruby +gem 'unicode-display_width' +gem 'unicode-emoji' +``` + +Enable the emoji string width adjustments by passing `emoji: true` as fourth parameter: + +```ruby +Unicode::DisplayWidth.of "🤾🏽♀️" # => 5 +Unicode::DisplayWidth.of "🤾🏽♀️", 1, {}, emoji: true # => 2 +``` + +#### Usage with String Extension + +```ruby +require 'unicode/display_width/string_ext' + +"⚀".display_width # => 1 +'一'.display_width # => 2 +``` + +### Modern API: Keyword-arguments Based Config Object + +Version 2.0 introduces a keyword-argument based API, which allows you to save your configuration for later-reuse. This requires an extra line of code, but has the advantage that you'll need to define your string-width options only once: + +```ruby +require 'unicode/display_width' + +display_width = Unicode::DisplayWidth.new( + # ambiguous: 1, + overwrite: { "A".ord => 100 }, + emoji: true, +) + +display_width.of "⚀" # => 1 +display_width.of "🤾🏽♀️" # => 2 +display_width.of "A" # => 100 +``` + +### Usage From the CLI + +Use this one-liner to print out display widths for strings from the command-line: + +``` +$ gem install unicode-display_width +$ ruby -r unicode/display_width -e 'puts Unicode::DisplayWidth.of $*[0]' -- "一" +``` +Replace "一" with the actual string to measure + +## Other Implementations & Discussion + +- Python: https://github.com/jquast/wcwidth +- JavaScript: https://github.com/mycoboco/wcwidth.js +- C: https://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c +- C for Julia: https://github.com/JuliaLang/utf8proc/issues/2 +- Golang: https://github.com/rivo/uniseg + +See [unicode-x](https://github.com/janlelis/unicode-x) for more Unicode related micro libraries. + +## Copyright & Info + +- Copyright (c) 2011, 2015-2024 Jan Lelis, https://janlelis.com, released under the MIT +license +- Early versions based on runpaint's unicode-data interface: Copyright (c) 2009 Run Paint Run Run +- Unicode data: https://www.unicode.org/copyright.html#Exhibit1 diff --git a/vendor/bundle/ruby/3.4.0/gems/unicode-display_width-2.6.0/data/display_width.marshal.gz b/vendor/bundle/ruby/3.4.0/gems/unicode-display_width-2.6.0/data/display_width.marshal.gz Binary files differnew file mode 100644 index 0000000..e3b6779 --- /dev/null +++ b/vendor/bundle/ruby/3.4.0/gems/unicode-display_width-2.6.0/data/display_width.marshal.gz diff --git a/vendor/bundle/ruby/3.4.0/gems/unicode-display_width-2.6.0/lib/unicode/display_width.rb b/vendor/bundle/ruby/3.4.0/gems/unicode-display_width-2.6.0/lib/unicode/display_width.rb new file mode 100644 index 0000000..bbd7026 --- /dev/null +++ b/vendor/bundle/ruby/3.4.0/gems/unicode-display_width-2.6.0/lib/unicode/display_width.rb @@ -0,0 +1,123 @@ +# frozen_string_literal: true + +require_relative "display_width/constants" +require_relative "display_width/index" + +module Unicode + class DisplayWidth + INITIAL_DEPTH = 0x10000 + ASCII_NON_ZERO_REGEX = /[\0\x05\a\b\n\v\f\r\x0E\x0F]/ + FIRST_4096 = decompress_index(INDEX[0][0], 1) + + def self.of(string, ambiguous = 1, overwrite = {}, options = {}) + if overwrite.empty? + # Optimization for ASCII-only strings without certain control symbols + if string.ascii_only? + if string.match?(ASCII_NON_ZERO_REGEX) + res = string.gsub(ASCII_NON_ZERO_REGEX, "").size - string.count("\b") + res < 0 ? 0 : res + else + string.size + end + else + width_no_overwrite(string, ambiguous, options) + end + else + width_all_features(string, ambiguous, overwrite, options) + end + end + + def self.width_no_overwrite(string, ambiguous, options = {}) + # Sum of all chars widths + res = string.codepoints.sum{ |codepoint| + if codepoint > 15 && codepoint < 161 # very common + next 1 + elsif codepoint < 0x1001 + width = FIRST_4096[codepoint] + else + width = INDEX + depth = INITIAL_DEPTH + while (width = width[codepoint / depth]).instance_of? Array + codepoint %= depth + depth /= 16 + end + end + + width == :A ? ambiguous : (width || 1) + } + + # Substract emoji error + res -= emoji_extra_width_of(string, ambiguous) if options[:emoji] + + # Return result + prevent negative lengths + res < 0 ? 0 : res + end + + # Same as .width_no_overwrite - but with applying overwrites for each char + def self.width_all_features(string, ambiguous, overwrite, options) + # Sum of all chars widths + res = string.codepoints.sum{ |codepoint| + next overwrite[codepoint] if overwrite[codepoint] + + if codepoint > 15 && codepoint < 161 # very common + next 1 + elsif codepoint < 0x1001 + width = FIRST_4096[codepoint] + else + width = INDEX + depth = INITIAL_DEPTH + while (width = width[codepoint / depth]).instance_of? Array + codepoint %= depth + depth /= 16 + end + end + + width == :A ? ambiguous : (width || 1) + } + + # Substract emoji error + res -= emoji_extra_width_of(string, ambiguous, overwrite) if options[:emoji] + + # Return result + prevent negative lengths + res < 0 ? 0 : res + end + + + def self.emoji_extra_width_of(string, ambiguous = 1, overwrite = {}, _ = {}) + require "unicode/emoji" + + extra_width = 0 + modifier_regex = /[#{ Unicode::Emoji::EMOJI_MODIFIERS.pack("U*") }]/ + zwj_regex = /(?<=#{ [Unicode::Emoji::ZWJ].pack("U") })./ + + string.scan(Unicode::Emoji::REGEX){ |emoji| + extra_width += 2 * emoji.scan(modifier_regex).size + + emoji.scan(zwj_regex){ |zwj_succ| + extra_width += self.of(zwj_succ, ambiguous, overwrite) + } + } + + extra_width + end + + def initialize(ambiguous: 1, overwrite: {}, emoji: false) + @ambiguous = ambiguous + @overwrite = overwrite + @emoji = emoji + end + + def get_config(**kwargs) + [ + kwargs[:ambiguous] || @ambiguous, + kwargs[:overwrite] || @overwrite, + { emoji: kwargs[:emoji] || @emoji }, + ] + end + + def of(string, **kwargs) + self.class.of(string, *get_config(**kwargs)) + end + end +end + diff --git a/vendor/bundle/ruby/3.4.0/gems/unicode-display_width-2.6.0/lib/unicode/display_width/constants.rb b/vendor/bundle/ruby/3.4.0/gems/unicode-display_width-2.6.0/lib/unicode/display_width/constants.rb new file mode 100644 index 0000000..14af2b1 --- /dev/null +++ b/vendor/bundle/ruby/3.4.0/gems/unicode-display_width-2.6.0/lib/unicode/display_width/constants.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Unicode + class DisplayWidth + VERSION = "2.6.0" + UNICODE_VERSION = "16.0.0" + DATA_DIRECTORY = File.expand_path(File.dirname(__FILE__) + "/../../../data/") + INDEX_FILENAME = DATA_DIRECTORY + "/display_width.marshal.gz" + end +end diff --git a/vendor/bundle/ruby/3.4.0/gems/unicode-display_width-2.6.0/lib/unicode/display_width/index.rb b/vendor/bundle/ruby/3.4.0/gems/unicode-display_width-2.6.0/lib/unicode/display_width/index.rb new file mode 100644 index 0000000..f81df7f --- /dev/null +++ b/vendor/bundle/ruby/3.4.0/gems/unicode-display_width-2.6.0/lib/unicode/display_width/index.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +require "zlib" +require_relative "constants" + +module Unicode + class DisplayWidth + File.open(INDEX_FILENAME, "rb") do |file| + serialized_data = Zlib::GzipReader.new(file).read + serialized_data.force_encoding Encoding::BINARY + INDEX = Marshal.load(serialized_data) + end + + def self.decompress_index(index, level) + index.flat_map{ |value| + if level > 0 + if value.instance_of?(Array) + value[15] ||= nil + decompress_index(value, level - 1) + else + decompress_index([value] * 16, level - 1) + end + else + if value.instance_of?(Array) + value[15] ||= nil + value + else + [value] * 16 + end + end + } + end + end +end diff --git a/vendor/bundle/ruby/3.4.0/gems/unicode-display_width-2.6.0/lib/unicode/display_width/no_string_ext.rb b/vendor/bundle/ruby/3.4.0/gems/unicode-display_width-2.6.0/lib/unicode/display_width/no_string_ext.rb new file mode 100644 index 0000000..2601497 --- /dev/null +++ b/vendor/bundle/ruby/3.4.0/gems/unicode-display_width-2.6.0/lib/unicode/display_width/no_string_ext.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +warn "You are loading 'unicode-display_width/no_string_ext'\n" \ + "Beginning with version 2.0, this is not necessary anymore\n"\ + "You can just require 'unicode-display_width' now and no\n"\ + "string extension will be loaded" + +require_relative "../display_width" diff --git a/vendor/bundle/ruby/3.4.0/gems/unicode-display_width-2.6.0/lib/unicode/display_width/string_ext.rb b/vendor/bundle/ruby/3.4.0/gems/unicode-display_width-2.6.0/lib/unicode/display_width/string_ext.rb new file mode 100644 index 0000000..88df9ea --- /dev/null +++ b/vendor/bundle/ruby/3.4.0/gems/unicode-display_width-2.6.0/lib/unicode/display_width/string_ext.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +require_relative "../display_width" unless defined? Unicode::DisplayWidth + +class String + def display_width(ambiguous = 1, overwrite = {}, options = {}) + Unicode::DisplayWidth.of(self, ambiguous, overwrite, options) + end +end |
