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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/terminal.rb +13 -3
- data/typr.gemspec +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3e9446e4b4389a720e2bda6b8e95f7a7144eb5b731b72f325b80f4bdea2866ed
|
|
4
|
+
data.tar.gz: 2c8d5867850febf6db6cebcee4acb6fde4b4c023007af4af54124f12f927e19f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
-
|
|
254
|
-
|
|
255
|
-
|
|
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
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.
|
|
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-
|
|
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
|