typr 1.6.0 → 1.6.1

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.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/lib/terminal.rb +13 -3
  4. data/typr.gemspec +2 -2
  5. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3fc328e46b4b4d36e0d3f68eb0a50f8068934469ec5e9d5d84099755685732ad
4
- data.tar.gz: 254c5a5842474b4fc550a0aff5fbaa772e961a6aca9a9a8f90ed1a89cc761e51
3
+ metadata.gz: 3e9446e4b4389a720e2bda6b8e95f7a7144eb5b731b72f325b80f4bdea2866ed
4
+ data.tar.gz: 2c8d5867850febf6db6cebcee4acb6fde4b4c023007af4af54124f12f927e19f
5
5
  SHA512:
6
- metadata.gz: eeae3cd67ce492706bc952e8422adea09d300f115928c074411c2589f5dae577ff4ad73e610e6a9b279007a93205e81fa9579c59d3f404f2778f52b06cb26e24
7
- data.tar.gz: 735a2236dbd0868674f4727572f578237f34165ab04d683179dd45464918099719c422503b386915f2df4895f1d5228550e6ee9bc25a9bf607d650eff8e8153c
6
+ metadata.gz: 670f5b22e356fd91507a3335038d228c06d8eef5cb404c76783c6dfa37126f073ad90253b062b26aedc81ef15c9fcb95fde0074ffff3b15dac5fd670fa53045b
7
+ data.tar.gz: 8dd835d95fb86ac1a56c9390ac7a485ea17d5f5e70e917db4f18d5f6491517dfc31dc56cf07a13ffffed58ae3dc92d9f1a0600ed944c7e2ca9ecc0b67389ad94
data/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  ## [vx.y.z] — __DATE__
4
4
 
5
+ ## [v1.6.1] — 2026-10-02
6
+
7
+ ### Fixed
8
+ - `Typr.paint` leaves pre-existing ANSI escapes byte-identical — the regex union matched escape bytes (`ESC`, `[`, `;`, digits) as ordinary text, shredding sequences already in the string; downstream clipping then dropped the orphaned `ESC` bytes and the bare sequence bodies printed as literal text (filecon help titles showed `[38;2;…m`). Paint now matches text runs between escapes only
9
+
5
10
  ## [v1.6.0] — 2026-09-30
6
11
 
7
12
  ### Added
data/lib/terminal.rb CHANGED
@@ -247,12 +247,22 @@ module Typr
247
247
  # When two patterns match the same span, the earlier key in the Hash wins,
248
248
  # so order overlapping keys longest-first.
249
249
  #
250
+ # Pre-existing ANSI sequences pass through byte-identical: only the plain
251
+ # text between them is matched, so painting never shreds escapes that are
252
+ # already in the string (and a later clip cannot orphan their bodies as
253
+ # literal text).
254
+ #
250
255
  # Typr.paint "fix WARN now", { /WARN/ => :yellow }, "\e[39;49m"
251
256
  def self.paint str, regex, base
252
257
  return str if regex.nil? or regex.empty?
253
- str.gsub( Regexp.union( regex.keys ) ) { |m|
254
- color = regex[ regex.keys.find{ |k| k === m } ]
255
- color_code( color ).to_s + m + base }
258
+ union = Regexp.union( regex.keys )
259
+ ansi = /\e(?:\[[0-9;?]*[ -\/]*[@-~]|\][^\a\e]*(?:\a|\e\\)|[()=><0A])|\e/
260
+ str.scan( /#{ansi}|[^\e]+/ ).map { |run|
261
+ run.start_with?( "\e" ) ? run :
262
+ run.gsub( union ) { |m|
263
+ color = regex[ regex.keys.find{ |k| k === m } ]
264
+ color_code( color ).to_s + m + base }
265
+ }.join
256
266
  end
257
267
 
258
268
  # Read the current background/foreground color pair.
data/typr.gemspec CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "typr"
5
- s.version = "1.6.0"
6
- s.date = "2026-09-30"
5
+ s.version = "1.6.1"
6
+ s.date = "2026-10-02"
7
7
  s.homepage = "https://codeberg.org/typr/typr"
8
8
  s.licenses = ["MIT"]
9
9
  s.require_paths = ["lib"]
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: typr
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kilian Reitmayr
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2026-09-30 00:00:00.000000000 Z
10
+ date: 2026-10-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: unicode-display_width