marvi 0.1.2 → 0.1.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: 0dd503447b94d15e62154562c11505be76de5f380abf17c735aa5f9879ac0ce8
4
- data.tar.gz: 234f6152a1797777ad5129307246dd19ad8c564539d060ae5015c8d5afc2284f
3
+ metadata.gz: 38191038ed0255015b0184643cc52e36bc35b8973803c75f3f5636e227fddba6
4
+ data.tar.gz: 83a3fe56615300c99bcc9858750926d5afab8a4e7a78c279e7b74ceef81ff074
5
5
  SHA512:
6
- metadata.gz: d042ca2e2863425922de5ffc43cef959c0dded6a8a63c901d0073ce2d12813f11ddbf3f53bfa402da92bb9df82ae2cb9894124d7333c3b9f5cd62358b45bbfc0
7
- data.tar.gz: eb80372539222159afffd907a92b37dff0af63be65b72364cbc1e46449b05fd8dbf0490e9c64438a493400a2afefc51dbf01d4c39f07e0dac52298d0cc3876e6
6
+ metadata.gz: 0dce42f6d88ceac30fa7cd2a75ad9318ab383f71164ad383ea1a95835601129ac8df125c403e634b5882a68802d24e05b4db9dd57496b4b91ab3a9a3bc176cca
7
+ data.tar.gz: 4f41145dc7639d8034cdff69b750dd0c92856b23b830b3e25542de48685e11f70a610cca7130a4ca54b04e829d5bd79bdcc5322f94fea939c6e6c64db81bbb08
@@ -42,16 +42,48 @@ module Marvi
42
42
 
43
43
  private
44
44
 
45
- # xterm-ghostty's `rep` capability mishandles long runs of identical glyphs,
46
- # so swap to xterm-256color around initscr to disable that ncurses optimization.
45
+ # ncurses uses the terminfo `rep` capability ("ESC[Nb") to compress runs of
46
+ # identical glyphs, but ghostty mishandles it and drops the run from the
47
+ # screen — table borders and long padding go missing. The bug surfaces both
48
+ # under xterm-ghostty directly and inside multiplexers like cmux that ship a
49
+ # terminfo whose xterm-256color entry advertises `rep`. Detect `rep` in the
50
+ # active terminfo and swap to a known no-rep alternative around initscr only.
51
+ REP_SAFE_TERMS = %w[screen-256color tmux-256color xterm-color xterm].freeze
52
+
47
53
  def with_safe_term
48
54
  original = ENV["TERM"]
49
- ENV["TERM"] = "xterm-256color" if original == "xterm-ghostty"
55
+ replacement = rep_safe_term_for(original)
56
+ ENV["TERM"] = replacement if replacement
50
57
  yield
51
58
  ensure
52
59
  ENV["TERM"] = original
53
60
  end
54
61
 
62
+ def rep_safe_term_for(term)
63
+ return nil if term.nil? || term.empty?
64
+ return nil unless terminfo_has_rep?(term)
65
+
66
+ REP_SAFE_TERMS.find { |candidate| candidate != term && terminfo_exists?(candidate) && !terminfo_has_rep?(candidate) }
67
+ end
68
+
69
+ def terminfo_has_rep?(term)
70
+ infocmp(term)&.include?("rep=") || false
71
+ end
72
+
73
+ def terminfo_exists?(term)
74
+ !infocmp(term).nil?
75
+ end
76
+
77
+ def infocmp(term)
78
+ @infocmp_cache ||= {}
79
+ return @infocmp_cache[term] if @infocmp_cache.key?(term)
80
+
81
+ output = IO.popen(["infocmp", "-1", term, err: File::NULL], &:read)
82
+ @infocmp_cache[term] = $?.success? ? output : nil
83
+ rescue StandardError
84
+ @infocmp_cache[term] = nil
85
+ end
86
+
55
87
  def setup_colors
56
88
  ::Curses.init_pair(COLOR_PAIRS[:cyan], ::Curses::COLOR_CYAN, -1)
57
89
  ::Curses.init_pair(COLOR_PAIRS[:green], ::Curses::COLOR_GREEN, -1)
data/lib/marvi/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Marvi
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.3"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: marvi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mitsutaka Mimura