ansiterm 0.4.2 → 0.4.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: 769f26bf92779ce6c3530bd496dc889cccbcbda18b6447472d910b00810749b4
4
- data.tar.gz: 9f4599f5b8146011dcb6b56101536a14b4a4317baa2f528e3f947170d6c42366
3
+ metadata.gz: f0dae91bb1ebbc0bda9632bf8846262e97819da55d1288c3c0b5beed53a3b11f
4
+ data.tar.gz: 055362e6766853205246e45ed3ee67646c30b0233cdbcdeeceaf6809e938ce7f
5
5
  SHA512:
6
- metadata.gz: d2656c8bdee346170e74c725712fe202474cb779d3c74067b9df42769a8fdc736ecc550859a658b1e4f44ff827a5657e49627ab437de464fa5427c8b126cc822
7
- data.tar.gz: 998ee1fa03b7d442edcd5f2535d9ad8c5ff16ea7c26795e35e9f42a9540b374608194ab3a32aef627e4e6daf4c1b3e85402c548222333052df4e223c38e497f4
6
+ metadata.gz: 620a6db97f8729c25c336c663db0ec2d27ef412414990f4317fc115a77fab2ec7d316b46c8677b9aa300ea50cd83c4aaa6a10e132aafa787a1465ef54ac1dda9
7
+ data.tar.gz: 84cdb955fdebe1ea70e0f9ee7cf3c8795217929b3d65984868d799576b97eec6ed73def2d849c2685661754d30bcc3750008372aa4a79e4942e9680d1615e9c9
data/lib/ansiterm/attr.rb CHANGED
@@ -55,7 +55,7 @@ module AnsiTerm
55
55
  attrs.delete(ignore)
56
56
  end
57
57
  attrs = to_h.merge(attrs)
58
- self.class.new(attrs)
58
+ self.class.new(**attrs)
59
59
  end
60
60
 
61
61
  def add_flag(flags); merge({flags: @flags.to_i | flags.to_i}); end
@@ -104,7 +104,7 @@ module AnsiTerm
104
104
  end
105
105
  end
106
106
 
107
- def self.attr(*args)
108
- Attr.new(*args)
107
+ def self.attr(...)
108
+ Attr.new(...)
109
109
  end
110
110
  end
@@ -1,4 +1,7 @@
1
1
 
2
+
3
+
4
+
2
5
  module AnsiTerm
3
6
 
4
7
  # # AnsiTerm::Buffer #
@@ -20,7 +23,7 @@ module AnsiTerm
20
23
  @y = 0
21
24
  @w = w
22
25
  @h = h
23
- @cache = []
26
+ @cache = Array.new { AnsiTerm::String.new }
24
27
  end
25
28
 
26
29
  def cls
@@ -58,6 +61,8 @@ module AnsiTerm
58
61
  r=@x..@x+str.length-1
59
62
  #p [r, str]
60
63
  l[r] = str
64
+ @x += str.length
65
+ # FIXME: Handle wrap.
61
66
  end
62
67
  end
63
68
 
@@ -85,11 +90,22 @@ module AnsiTerm
85
90
  if @cache[y] != s
86
91
  # Move to start of line; output line; clear to end
87
92
  #if l > 0
88
- out << "\e[#{y+1};1H" << s
89
- if l < @w
90
- out << "\e[0m\e[0K"
91
- end
93
+ #s.lstrip!
94
+ #x = l - s.length
95
+ out << "\e[#{y+1};1H"
96
+ #if x > 1
97
+ # out << "\e[1K"
92
98
  #end
99
+ #FIXME: We can only do this if:
100
+ #1. we know no background color has been set
101
+ #2. OR we add support for specifying it.
102
+ #out << s.rstrip
103
+ out << s
104
+ if l < @w
105
+ # FIXME: Allow setting background colour
106
+ out << "\e[0m\e[0K"
107
+ #end
108
+ end
93
109
  cachemiss += s.length
94
110
  old = @cache[y]
95
111
  @cache[y] = s
@@ -11,6 +11,8 @@ module AnsiTerm
11
11
  end
12
12
  end
13
13
 
14
+ attr_reader :str, :attrs
15
+
14
16
  def to_plain_str
15
17
  @str.dup
16
18
  end
@@ -78,7 +80,7 @@ module AnsiTerm
78
80
  r = Array(@attrs[range]).count # Inefficient, but saves dealing with negative offsets etc. "manually"
79
81
  last = nil
80
82
  @attrs[range] = @attrs[range].map do |a|
81
- if a.bgcol == 49
83
+ if a&.bgcol == 49
82
84
  n = attr.merge(a, ignore: :bgcol)
83
85
  else
84
86
  n = attr.merge(a)
@@ -89,13 +91,20 @@ module AnsiTerm
89
91
  end
90
92
 
91
93
  def[]= range, str
92
- s = @str.dup
93
- a = @attrs.dup
94
- parse(str)
95
- s[range] = @str
96
- @str = s
97
- a[range] = @attrs
98
- @attrs = a
94
+ if str.is_a?(self.class)
95
+ #@str = @str.dup
96
+ #@attrs = @attrs.dup
97
+ @str[range] = str.str
98
+ @attrs[range] = str.attrs
99
+ else
100
+ s = @str.dup
101
+ a = @attrs.dup
102
+ parse(str)
103
+ s[range] = @str
104
+ @str = s
105
+ a[range] = @attrs
106
+ @attrs = a
107
+ end
99
108
  end
100
109
 
101
110
  def[] i
@@ -143,7 +152,7 @@ module AnsiTerm
143
152
  # ,params.shift,params.shift, params.shift].join(";")
144
153
  end
145
154
  end
146
- a.merge(attr_name => col)
155
+ a.merge({attr_name => col})
147
156
  end
148
157
 
149
158
  def parse(str)
@@ -1,3 +1,3 @@
1
1
  module AnsiTerm
2
- VERSION = "0.4.2"
2
+ VERSION = "0.4.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ansiterm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vidar Hokstad
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-10-27 00:00:00.000000000 Z
11
+ date: 2025-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -93,7 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
93
  - !ruby/object:Gem::Version
94
94
  version: '0'
95
95
  requirements: []
96
- rubygems_version: 3.1.4
96
+ rubygems_version: 3.4.10
97
97
  signing_key:
98
98
  specification_version: 4
99
99
  summary: ANSI/VT102 terminal output with windowing