marvi 0.1.1 → 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 +4 -4
- data/lib/marvi/renderer/curses.rb +44 -2
- data/lib/marvi/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 38191038ed0255015b0184643cc52e36bc35b8973803c75f3f5636e227fddba6
|
|
4
|
+
data.tar.gz: 83a3fe56615300c99bcc9858750926d5afab8a4e7a78c279e7b74ceef81ff074
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0dce42f6d88ceac30fa7cd2a75ad9318ab383f71164ad383ea1a95835601129ac8df125c403e634b5882a68802d24e05b4db9dd57496b4b91ab3a9a3bc176cca
|
|
7
|
+
data.tar.gz: 4f41145dc7639d8034cdff69b750dd0c92856b23b830b3e25542de48685e11f70a610cca7130a4ca54b04e829d5bd79bdcc5322f94fea939c6e6c64db81bbb08
|
|
@@ -24,7 +24,7 @@ module Marvi
|
|
|
24
24
|
@lines = ASTWalker.new.walk(markdown)
|
|
25
25
|
@scroll = 0
|
|
26
26
|
|
|
27
|
-
::Curses.init_screen
|
|
27
|
+
with_safe_term { ::Curses.init_screen }
|
|
28
28
|
::Curses.start_color
|
|
29
29
|
::Curses.use_default_colors
|
|
30
30
|
::Curses.noecho
|
|
@@ -42,6 +42,48 @@ module Marvi
|
|
|
42
42
|
|
|
43
43
|
private
|
|
44
44
|
|
|
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
|
+
|
|
53
|
+
def with_safe_term
|
|
54
|
+
original = ENV["TERM"]
|
|
55
|
+
replacement = rep_safe_term_for(original)
|
|
56
|
+
ENV["TERM"] = replacement if replacement
|
|
57
|
+
yield
|
|
58
|
+
ensure
|
|
59
|
+
ENV["TERM"] = original
|
|
60
|
+
end
|
|
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
|
+
|
|
45
87
|
def setup_colors
|
|
46
88
|
::Curses.init_pair(COLOR_PAIRS[:cyan], ::Curses::COLOR_CYAN, -1)
|
|
47
89
|
::Curses.init_pair(COLOR_PAIRS[:green], ::Curses::COLOR_GREEN, -1)
|
|
@@ -86,7 +128,7 @@ module Marvi
|
|
|
86
128
|
end
|
|
87
129
|
|
|
88
130
|
def reinit_curses
|
|
89
|
-
::Curses.init_screen
|
|
131
|
+
with_safe_term { ::Curses.init_screen }
|
|
90
132
|
::Curses.start_color
|
|
91
133
|
::Curses.use_default_colors
|
|
92
134
|
::Curses.noecho
|
data/lib/marvi/version.rb
CHANGED