termpix 0.4.0 → 0.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e311d6ce62bc8230d38d93a80b5e93af7422c1d9b9ec06f1bd746d18244c4901
4
- data.tar.gz: 35400b9a97498b45855a3c9dda743454a2c0a4d68138dbbfb33d0108fdd6415d
3
+ metadata.gz: 02dd8d6eb36d91f8db048b0302303bd720fbe246d0934bae5f31a4062a11f00a
4
+ data.tar.gz: 55745158a3f0657c3457c422ce8fd1bf33b7201132c921274c18ede7c49d9830
5
5
  SHA512:
6
- metadata.gz: fe0e449f3bc2674e55418bd7fc8194eaef1f5d249824c99eedc006f23e5e8dc15477a21b9b31e33a6ff87f848c1c168822385461091d88d235e3577ffba40cae
7
- data.tar.gz: 10bb9db43f2b54f8826f719f9e9a12a5c024564e0f72558949f1ffeb31b1b69cc6812ea5f9ae04a1478da662ebff86e6aab975aa54c47b9c79041b0e38f483a7
6
+ metadata.gz: 4871c317ab480d3df29ef922958f44fce76fddb54cd6f37d2539ce940ea3229fa754c49479fd2b0865f4b255b559a6663454a244d118b638add4e3e7341144c9
7
+ data.tar.gz: ce9f36b37d5f3e8c56c1aa5c6027da0a6b3849dc65a457465547b160f0038dc5d22268d5aea2c4cd245b2d2be390ba7d8c55b89a985655f2ee443be52cd6fe12
@@ -7,7 +7,7 @@ module Termpix
7
7
  # Uses Unicode placeholder mode (U=1) for curses/TUI compatibility
8
8
  # Images are tied to placeholder characters that curses manages as text
9
9
  module Kitty
10
- @current_image_id = nil
10
+ @active_image_ids = []
11
11
  @image_cache = {} # path -> image_id mapping
12
12
 
13
13
  def self.display(image_path, x:, y:, max_width:, max_height:)
@@ -32,8 +32,6 @@ module Termpix
32
32
  image_id = 1 if image_id == 0
33
33
  end
34
34
 
35
- old_image_id = @current_image_id
36
-
37
35
  unless @image_cache[cache_key]
38
36
  # Transmit the image with scaling
39
37
  escaped = Shellwords.escape(image_path)
@@ -50,11 +48,8 @@ module Termpix
50
48
  chunks.each_with_index do |chunk, idx|
51
49
  more = idx < chunks.length - 1 ? 1 : 0
52
50
  if idx == 0
53
- # First chunk: specify format (f=100 for PNG), action (a=t for transmit)
54
- # i=image_id, m=more_chunks
55
51
  print "\e_Ga=t,f=100,i=#{image_id},m=#{more};#{chunk}\e\\"
56
52
  else
57
- # Continuation chunks
58
53
  print "\e_Gm=#{more};#{chunk}\e\\"
59
54
  end
60
55
  end
@@ -63,30 +58,21 @@ module Termpix
63
58
  @image_cache[cache_key] = image_id
64
59
  end
65
60
 
66
- # Position cursor and display the NEW image FIRST
67
- # a=p (place), i=image_id, C=1 (don't move cursor)
68
- # Don't specify c/r - let kitty use image's native size (already scaled by ImageMagick)
69
- print "\e[#{y};#{x}H" # Move cursor to position
61
+ # Position cursor and place the image (keep existing images)
62
+ print "\e[#{y};#{x}H"
70
63
  print "\e_Ga=p,i=#{image_id},C=1\e\\"
71
64
  $stdout.flush
72
65
 
73
- # NOW delete old placement (after new one is visible) - atomic swap
74
- if old_image_id && old_image_id != image_id
75
- print "\e_Ga=d,d=i,i=#{old_image_id}\e\\"
76
- $stdout.flush
77
- end
78
-
79
- @current_image_id = image_id
66
+ @active_image_ids << image_id unless @active_image_ids.include?(image_id)
80
67
  true
81
68
  end
82
69
 
83
70
  def self.clear
84
- # Actually clear the image
85
- if @current_image_id
86
- print "\e_Ga=d,d=i,i=#{@current_image_id}\e\\"
87
- $stdout.flush
88
- @current_image_id = nil
71
+ @active_image_ids.each do |id|
72
+ print "\e_Ga=d,d=i,i=#{id}\e\\"
89
73
  end
74
+ $stdout.flush unless @active_image_ids.empty?
75
+ @active_image_ids.clear
90
76
  true
91
77
  end
92
78
 
@@ -1,3 +1,3 @@
1
1
  module Termpix
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
data/lib/termpix.rb CHANGED
@@ -31,11 +31,10 @@ module Termpix
31
31
  return false
32
32
  end
33
33
 
34
- @current_image = image_path
35
34
  true
36
35
  end
37
36
 
38
- # Clear the currently displayed image
37
+ # Clear all displayed images
39
38
  def clear(x: 0, y: 0, width: 80, height: 24, term_width: 80, term_height: 24)
40
39
  return false unless @protocol
41
40
 
@@ -48,7 +47,6 @@ module Termpix
48
47
  Protocols::W3m.clear(x: x, y: y, width: width, height: height, term_width: term_width, term_height: term_height)
49
48
  end
50
49
 
51
- @current_image = nil
52
50
  true
53
51
  end
54
52
 
metadata CHANGED
@@ -1,18 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: termpix
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Geir Isene
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-03-21 00:00:00.000000000 Z
11
+ date: 2026-03-27 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: 'Termpix v0.4.0: Robustness improvements. Fixed bare rescues, added nil-guards
14
- on xwininfo parsing, tput fallbacks, identify output validation. Removed non-functional
15
- Ueberzug module. Replaced shell interpolation with IO.popen in W3m protocol.'
13
+ description: 'Termpix v0.4.1: Kitty protocol now supports multiple simultaneous images.
14
+ Track array of active image IDs instead of single image. clear() removes all active
15
+ images at once.'
16
16
  email: g@isene.com
17
17
  executables: []
18
18
  extensions: []