rtfm-filemanager 7.2.1 → 7.3.0

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 (3) hide show
  1. checksums.yaml +4 -4
  2. data/bin/rtfm +40 -61
  3. metadata +17 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4d39aec21bd04a0722600f1ffceaa2e971fbf91f06a13d0fb33a2641c2ecbbd3
4
- data.tar.gz: 596d8c83baf63beceba5d85bb07e273143f40500e8728523962d94c0b3a40799
3
+ metadata.gz: 70adf5224517b9f2cf7a0ec8150c350c3a9b3c6455a6db26781a2ef33dfa385d
4
+ data.tar.gz: f07222ba0ed09b855fab399be1209a539efde052a416d48050e82db4c4b42f43
5
5
  SHA512:
6
- metadata.gz: f54a9dadea1c77298cc7853414be1276639dee8218f4f2866d239904ba146d83cead831d422da76ad0d5ed0f678b756e920b7953cf6d354bc009e03325c897ad
7
- data.tar.gz: 212e3a017c78fd2abac1cf7e17fe5a2b1b39343604665d7962e9ebd74f0ced805e5b3d54d2b09eed343b1c8fb33a31add718ad878198f41c5304424d0d8eb530
6
+ metadata.gz: ef7ce1ea7725333321bddb1b1cbf68300e3c1c697540c7c0b6a0d4f0f4021b7f1a6c408716e4aa2348938b8de555444304a292f886d770ec38df43cca8b145cc
7
+ data.tar.gz: 5a4f701cd40e6375387198e2febe6bd56a59976e261b0dd226c0efa53cf21c107a3639cb602993791bc9e7ef0c8396b0d045957810b0dbc6496b1cbcadc63151
data/bin/rtfm CHANGED
@@ -18,7 +18,7 @@
18
18
  # get a great understanding of the code itself by simply sending
19
19
  # or pasting this whole file into you favorite AI for coding with
20
20
  # a prompt like this: "Help me understand every part of this code".
21
- @version = '7.2.1' # Performance: Direct print for window title (no spawn)
21
+ @version = '7.3.0' # Modern image display using termpix gem
22
22
 
23
23
  # SAVE & STORE TERMINAL {{{1
24
24
  ORIG_STTY = `stty -g`.chomp
@@ -43,22 +43,24 @@ def check_image_redraw # {{{2
43
43
  now = Time.now
44
44
  return if now - @last_focus_check < @focus_check_interval
45
45
  @last_focus_check = now
46
-
46
+
47
47
  # Only check if we have an image currently displayed
48
48
  return unless @image && @current_image_path
49
-
49
+
50
50
  begin
51
- # Check if terminal has focus and if image needs redrawing
52
- active_window = `xdotool getactivewindow 2>/dev/null`.chomp
53
- return if active_window.empty?
54
-
55
- # Simple heuristic: if we can't find any w3mimgdisplay processes,
56
- # the image overlay was probably cleared and needs redrawing
57
- img_processes = `pgrep w3mimgdisplay 2>/dev/null`.chomp
58
- if img_processes.empty? && File.exist?(@current_image_path)
59
- # Redraw the image
60
- showimage(@current_image_path)
51
+ # For w3m/ueberzug protocols, check if image overlay was cleared
52
+ if [:w3m, :ueberzug].include?(@termpix.protocol)
53
+ active_window = `xdotool getactivewindow 2>/dev/null`.chomp
54
+ return if active_window.empty?
55
+
56
+ # Check if image display process still exists
57
+ process_name = @termpix.protocol == :w3m ? 'w3mimgdisplay' : 'ueberzug'
58
+ img_processes = `pgrep #{process_name} 2>/dev/null`.chomp
59
+ if img_processes.empty? && File.exist?(@current_image_path)
60
+ showimage(@current_image_path)
61
+ end
61
62
  end
63
+ # Kitty and Sixel protocols don't need redraw checks - images persist
62
64
  rescue
63
65
  # Silently fail - we don't want focus checking to break anything
64
66
  end
@@ -77,6 +79,7 @@ rescue StandardError => e
77
79
  end
78
80
  require 'tmpdir'
79
81
  require 'set' # For symlink loop detection
82
+ require 'termpix' # Terminal image display
80
83
  # Lazy-load to speed up startup
81
84
  autoload :Shellwords, 'shellwords'
82
85
  autoload :Timeout, 'timeout'
@@ -481,13 +484,9 @@ def cmd?(cmd) # Helper function
481
484
  system("which #{cmd} > /dev/null 2>&1")
482
485
  end
483
486
 
484
- if cmd?('/usr/lib/w3m/w3mimgdisplay')
485
- @imgdisplay = '/usr/lib/w3m/w3mimgdisplay'
486
- @showimage = true
487
- else
488
- @showimage = false
489
- end
490
- @showimage = false unless cmd?('xwininfo') && cmd?('xdotool')
487
+ # Initialize termpix for image display
488
+ @termpix = Termpix::Display.new
489
+ @showimage = @termpix.supported?
491
490
 
492
491
  # Image auto-redraw variables
493
492
  @current_image_path = nil # Path of currently displayed image
@@ -1120,7 +1119,10 @@ def help_info # {{{3
1120
1119
  end
1121
1120
 
1122
1121
  def show_version # {{{3
1123
- @pB.say(" RTFM version = #{@version} (latest RubyGems version is #{Gem.latest_version_for('rtfm-filemanager').version} - https://github.com/isene/RTFM)".b)
1122
+ protocol_info = @termpix ? " [Image protocol: #{@termpix.protocol || 'none'}]" : ""
1123
+ version_text = " RTFM version = #{@version}#{protocol_info} (latest RubyGems version is #{Gem.latest_version_for('rtfm-filemanager').version} - https://github.com/isene/RTFM)"
1124
+ @pB.say(version_text.b)
1125
+ @pB.update = false # Prevent terminal clearing on next render
1124
1126
  end
1125
1127
 
1126
1128
  def refresh_all # {{{3
@@ -5636,50 +5638,27 @@ def showimage(image) # SHOW THE SELECTED IMAGE IN THE RIGHT WINDOW {{{2
5636
5638
  return unless @showimage
5637
5639
 
5638
5640
  begin
5639
- terminfo = `xwininfo -id $(xdotool getactivewindow 2>/dev/null) 2>/dev/null`
5640
- term_w = terminfo.match(/Width: (\d+)/)[1].to_i
5641
- term_h = terminfo.match(/Height: (\d+)/)[1].to_i
5642
- char_w = term_w / @w
5643
- char_h = term_h / @h
5644
- img_x = char_w * @pR.x
5645
- img_y = char_h * 2
5646
- img_max_w = char_w * (@pR.w - 2)
5647
- img_max_h = char_h * (@pR.h - 1)
5648
5641
  if image == 'clear'
5649
- `clear`
5650
- img_x -= char_w
5651
- img_max_w += char_w + 2
5652
- img_max_h += 2
5653
- `echo "6;#{img_x};#{img_y};#{img_max_w};#{img_max_h};\n4;\n3;" | #{@imgdisplay} 2>/dev/null`
5654
- @current_image_path = nil # Clear tracking when image is cleared
5642
+ @termpix.clear(
5643
+ x: @pR.x,
5644
+ y: @pR.y,
5645
+ width: @pR.w,
5646
+ height: @pR.h,
5647
+ term_width: @w,
5648
+ term_height: @h)
5649
+ @current_image_path = nil
5655
5650
  else
5656
- # Ensure we have the absolute path
5651
+ # Display image using termpix
5657
5652
  img_path = File.absolute_path(image)
5658
-
5659
- # Properly escape image path for shell commands
5660
- escaped_image = Shellwords.escape(img_path)
5661
- # For animated GIFs, get dimensions of first frame only using [0]
5662
- dimensions = `identify -format "%wx%h" #{escaped_image}[0] 2>/dev/null`
5663
- img_w, img_h = dimensions.split('x').map(&:to_i)
5664
-
5665
- # Fix: Use simultaneous scaling to prevent overflow
5666
- if img_w > img_max_w || img_h > img_max_h
5667
- scale_w = img_max_w.to_f / img_w
5668
- scale_h = img_max_h.to_f / img_h
5669
- scale = [scale_w, scale_h].min
5670
-
5671
- img_w = (img_w * scale).to_i
5672
- img_h = (img_h * scale).to_i
5673
- end
5674
-
5675
- # Use the absolute path without extra quotes in the w3mimgdisplay protocol
5676
- `echo '0;1;#{img_x};#{img_y};#{img_w};#{img_h};;;;;#{img_path}
5677
- 4;
5678
- 3;' | #{@imgdisplay} 2>/dev/null`
5679
- @current_image_path = img_path # Track currently displayed image
5653
+ @termpix.show(img_path,
5654
+ x: @pR.x,
5655
+ y: @pR.y,
5656
+ max_width: @pR.w - 2,
5657
+ max_height: @pR.h - 1)
5658
+ @current_image_path = img_path
5680
5659
  end
5681
- rescue
5682
- @pR.text = 'Error showing image'
5660
+ rescue => e
5661
+ @pR.text = "Error showing image: #{e.message}"
5683
5662
  end
5684
5663
  end
5685
5664
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rtfm-filemanager
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.2.1
4
+ version: 7.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Geir Isene
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-10-25 00:00:00.000000000 Z
11
+ date: 2025-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rcurses
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '6.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: termpix
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.1'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.1'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: bootsnap
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -53,7 +67,7 @@ dependencies:
53
67
  - !ruby/object:Gem::Version
54
68
  version: '7.4'
55
69
  description: |-
56
- RTFM v7.2.0: BREAKING CHANGE - Batch operations now work ONLY on tagged items when items are tagged (not tagged + selected). If no items are tagged, operations work on the selected item only.
70
+ RTFM v7.3.0: Modern image display with termpix gem - supports Sixel (mlterm) and w3m protocols.
57
71
  A full featured terminal browser with syntax highlighted files, images shown in the terminal, videos thumbnailed, etc. Features include remote SSH/SFTP browsing, interactive SSH shell, comprehensive undo system, bookmarks, and much more. You can bookmark and jump around easily, delete, rename, copy, symlink and move files. RTFM is one of the most feature-packed terminal file managers.
58
72
  email: g@isene.com
59
73
  executables: