textbringer 2 → 3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a7815997c04d50a71d83ccb13cc2b2ec378679b26e74d6a2add40635d033c7ad
4
- data.tar.gz: 82193a90e99ba1d56df8c1f6cfde23ae6560585273e3c25777d55f3f7fa3c78a
3
+ metadata.gz: 66be90097685aaa387bc495b1ec0480eeaa4f7015480c5358fd07268d3e14fdb
4
+ data.tar.gz: f848eefb51793d46065411ef40b5c8c96f04ebb490a1919c3497e44ed7f0c574
5
5
  SHA512:
6
- metadata.gz: 6bc44799c79165fee0acf71efedd019692432da5a3b6f6c005a485587e7aecd44e2a82ba380272f42fa51a4519e1d461c9f1cdcb5f2f25f76a62029dff0358ca
7
- data.tar.gz: 21ae07326bfbb38398950efcf5d0f0e9abea6195aafa26430691d2879d9e92ff3f4d50a4be5f77ed1d5082fbe776724c737ec7103d7ccd2d977638c3e160be81
6
+ metadata.gz: 33afdb5cdc3c255a5910e0757393a650dce8ab09b705a58725f391a70e8c46bf7a1b1c31959bf4ed0e96b435c0ba745d3f13c353f5c869f64afa764b23551f9a
7
+ data.tar.gz: 9b9cc0408ab6d79038d080ebfce6fe3c6c11fe600b88a267c0d2b75c35d12eec02e9a8d95aa82169919fdb49da13c973274b7a9a05edba1a570641167e09c094
@@ -151,9 +151,9 @@ module Textbringer
151
151
  define_command(:describe_char,
152
152
  doc: "Describe the char after point") do
153
153
  require "unicode/name"
154
- require "unicode/categories"
155
154
  require "unicode/blocks"
156
155
  require "unicode/scripts"
156
+ require "unicode/categories"
157
157
  require "unicode/types"
158
158
 
159
159
  show_help do |help|
@@ -166,9 +166,9 @@ module Textbringer
166
166
  char = /[\0-\x20\x7f]/.match?(c) ? Keymap.key_name(c) : c
167
167
  codepoint = "U+%04X" % c.ord
168
168
  name = Unicode::Name.readable(c)
169
+ script = Unicode::Scripts.script(c)
169
170
  category = Unicode::Categories.category(c)
170
171
  category_long = Unicode::Categories.category(c, format: :long)
171
- script = Unicode::Scripts.script(c)
172
172
  block = Unicode::Blocks.block(c)
173
173
  type = Unicode::Types.type(c)
174
174
  help.insert(<<EOF)
@@ -176,9 +176,9 @@ module Textbringer
176
176
  character: #{char}
177
177
  codepoint: #{codepoint}
178
178
  name: #{name}
179
- category: #{category} (#{category_long})
180
- script: #{script}
181
179
  block: #{block}
180
+ script: #{script}
181
+ category: #{category} (#{category_long})
182
182
  type: #{type}
183
183
  EOF
184
184
  end
@@ -1,3 +1,3 @@
1
1
  module Textbringer
2
- VERSION = "2"
2
+ VERSION = "3"
3
3
  end
@@ -1,6 +1,43 @@
1
1
  module Textbringer
2
2
  class Window
3
3
  FALLBACK_CHARACTERS = {
4
+ # Diacritical marks
5
+ ## https://www.unicode.org/charts/PDF/U0300.pdf
6
+ ## characters combinable with alphabet:
7
+ ## ("\u{0300}".."\u{036f}").filter { |c|
8
+ ## ("a".."z").any? { |c2|
9
+ ## "#{c2}#{c}".unicode_normalize(:nfc).size == 1
10
+ ## }
11
+ ## }
12
+ "̀" => "`",
13
+ "́" => "´",
14
+ "̂" => "ˆ",
15
+ "̃" => "˜",
16
+ "̄" => "¯",
17
+ "̆" => "˘",
18
+ "̇" => "˙",
19
+ "̈" => "¨",
20
+ "̉" => "ˀ",
21
+ "̊" => "˚",
22
+ "̋" => "˝",
23
+ "̌" => "ˇ",
24
+ "̏" => '"',
25
+ "̑" => nil, # combining character only
26
+ "̛" => nil, # combining character only
27
+ "̣" => nil, # combining character only
28
+ "̤" => nil, # combining character only
29
+ "̥" => "˳",
30
+ "̦" => ",",
31
+ "̧" => "¸",
32
+ "̨" => "˛",
33
+ "̭" => nil, # combining character only
34
+ "̮" => nil, # combining character only
35
+ "̰" => nil, # combining character only
36
+ "̱" => "ˍ",
37
+ "̀" => nil, # combining character only
38
+ "́" => nil, # combining character only
39
+ "̈́" => nil, # combining character only
40
+
4
41
  # Hiragana
5
42
  "゙" => "゛",
6
43
  "゚" => "゜",
@@ -705,13 +705,11 @@ module Textbringer
705
705
  pos = @buffer.point + c.bytesize
706
706
  while nextc = @buffer.char_after(pos)
707
707
  case nextc
708
- when /[\u{fe00}-\u{fe0f}\u{e0100}-\u{e01ef}]/ # variation selectors
708
+ when /\p{Variation_Selector}/
709
709
  c += nextc
710
710
  when /[\p{Mn}\p{Me}]/ # nonspacing & enclosing marks
711
711
  # Normalize パ (U+30CF + U+309A) to パ (U+30D1) so that curses can
712
712
  # caluculate display width correctly.
713
- # Display combining marks by codepoint when characters cannot be
714
- # combined by NFC.
715
713
  newc = (c + nextc).unicode_normalize(:nfc)
716
714
  return c if newc.size != c.size
717
715
  c = newc
@@ -769,17 +767,12 @@ module Textbringer
769
767
  s.gsub(/
770
768
  (?<ascii_control>[\0-\b\v-\x1f\x7f])
771
769
  | (?<nonascii_control>\p{C})
772
- | (?<combining_diacritical_mark>[\u{0300}-\u{036f}])
773
- | (?<other_special_char>[\p{M}\u{1100}-\u{11ff}])
770
+ | (?<other_special_char>[\p{M}\p{In_Hangul_Jamo}])
774
771
  /x) { |c|
775
772
  if $~[:ascii_control]
776
773
  "^" + (c.ord ^ 0x40).chr
777
774
  elsif $~[:nonascii_control]
778
775
  "<%04x>" % c.ord
779
- elsif $~[:combining_diacritical_mark]
780
- # Use U+00A0 as the base character, following the convention
781
- # described in section 2.11.4 of Unicode Standard 16.0.0
782
- "\u{00a0}#{c}"
783
776
  elsif $~[:other_special_char]
784
777
  FALLBACK_CHARACTERS[c] || c
785
778
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: textbringer
3
3
  version: !ruby/object:Gem::Version
4
- version: '2'
4
+ version: '3'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shugo Maeda
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-04-04 00:00:00.000000000 Z
10
+ date: 2025-04-10 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: rdoc