termvas 0.2.0 → 0.3.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 +4 -4
- data/.codespellignore +1 -0
- data/.yamllint +16 -0
- data/CHANGELOG.md +8 -1
- data/README.md +6 -0
- data/Rakefile +1 -3
- data/lib/termvas/rbgl.rb +1 -1
- data/lib/termvas/version.rb +1 -1
- data/lib/termvas.rb +24 -4
- data/sig/termvas.rbs +6 -1
- metadata +4 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d96a53546db38dd9887bd4f0368a1b818ea2eafd58bb7fc9024ef1bf5d6d08da
|
|
4
|
+
data.tar.gz: 01ccfbff4469d665303695ad61600c8e591604cc7ce9b8b5c6f64b1026d48199
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: af06e7b15123c603edef3f89b8c5b8e13e7a3fde78ae0ed052a07f9a7320985e81ab6e75ec396760a289f70d835bd01100329d7bee9aa1242077df47b7f99225
|
|
7
|
+
data.tar.gz: a416408455b495482c2cc057c284509de678fdf48e15d950caa9f36637c5bd929a2110f20155e8da083231cf9ef06c7cb173027460418734d0577d1553824a91
|
data/.codespellignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
iTerm
|
data/.yamllint
ADDED
data/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## [
|
|
3
|
+
## [0.3.1] - 2026-09-26
|
|
4
|
+
|
|
5
|
+
- Skip unsupported terminal control sequences instead of reporting them as key events.
|
|
6
|
+
- Reject non-finite terminal frame limits.
|
|
7
|
+
|
|
8
|
+
## [0.3.0] - 2026-09-25
|
|
9
|
+
|
|
10
|
+
- Expose terminal cell-size estimates for display fitting, with environment overrides.
|
|
4
11
|
|
|
5
12
|
## [0.2.0] - 2026-09-25
|
|
6
13
|
|
data/README.md
CHANGED
|
@@ -84,6 +84,12 @@ The encoders, protocol detection, input parser, and terminal sizing utilities
|
|
|
84
84
|
load with <code>require "termvas"</code> alone. The optional RBGL backend is
|
|
85
85
|
available from <code>require "termvas/rbgl"</code>.
|
|
86
86
|
|
|
87
|
+
<code>Termvas::Terminal#size</code> returns <code>[columns, rows]</code>.
|
|
88
|
+
<code>#cell_size</code> returns estimated pixel dimensions as
|
|
89
|
+
<code>[width, height]</code> (8 × 16 by default). Set
|
|
90
|
+
<code>TERMVAS_CELL_WIDTH</code> and <code>TERMVAS_CELL_HEIGHT</code> to tune the
|
|
91
|
+
estimate; sizing does not query the terminal.
|
|
92
|
+
|
|
87
93
|
## Terminal notes
|
|
88
94
|
|
|
89
95
|
<code>fit: :contain</code> is the default and reduces oversized frames to the
|
data/Rakefile
CHANGED
|
@@ -3,9 +3,7 @@
|
|
|
3
3
|
require "bundler/gem_tasks"
|
|
4
4
|
require "rspec/core/rake_task"
|
|
5
5
|
|
|
6
|
-
RSpec::Core::RakeTask.new(:spec)
|
|
7
|
-
task.ruby_opts = %w[-I../rbgl/lib -I../larb/lib -I../tessel/lib]
|
|
8
|
-
end
|
|
6
|
+
RSpec::Core::RakeTask.new(:spec)
|
|
9
7
|
|
|
10
8
|
task default: :spec
|
|
11
9
|
task verify: :spec
|
data/lib/termvas/rbgl.rb
CHANGED
|
@@ -17,7 +17,7 @@ module Termvas
|
|
|
17
17
|
@fit = fit.to_sym
|
|
18
18
|
raise ArgumentError, "fit must be :contain or :none" unless %i[contain none].include?(@fit)
|
|
19
19
|
@max_fps = max_fps.nil? ? nil : Float(max_fps)
|
|
20
|
-
raise ArgumentError, "max_fps must be positive" if @max_fps && !@max_fps.positive?
|
|
20
|
+
raise ArgumentError, "max_fps must be positive and finite" if @max_fps && (!@max_fps.positive? || !@max_fps.finite?)
|
|
21
21
|
@terminal = Terminal.new(input: input, output: output, alt_screen: alt_screen, tmux: tmux)
|
|
22
22
|
@output = output
|
|
23
23
|
@input = input
|
data/lib/termvas/version.rb
CHANGED
data/lib/termvas.rb
CHANGED
|
@@ -179,6 +179,14 @@ module Termvas
|
|
|
179
179
|
@buffer << bytes
|
|
180
180
|
events = []
|
|
181
181
|
loop do
|
|
182
|
+
if @buffer.start_with?("\e[")
|
|
183
|
+
sequence = @buffer.match(/\A\e\[[0-?]*[ -\/]*[@-~]/)
|
|
184
|
+
break unless sequence
|
|
185
|
+
unless sequence[0].match?(/\A\e\[<\d+;\d+;\d+[Mm]\z|\A\e\[[0-9;]*[A-Za-z~]\z/)
|
|
186
|
+
@buffer = @buffer.byteslice(sequence[0].bytesize..).to_s.b
|
|
187
|
+
next
|
|
188
|
+
end
|
|
189
|
+
end
|
|
182
190
|
if @buffer.start_with?("\e[<")
|
|
183
191
|
match = @buffer.match(/\A\e\[<([0-9]+);([0-9]+);([0-9]+)([Mm])/
|
|
184
192
|
)
|
|
@@ -271,10 +279,11 @@ module Termvas
|
|
|
271
279
|
class Terminal
|
|
272
280
|
attr_reader :input, :output
|
|
273
281
|
|
|
274
|
-
def initialize(input: $stdin, output: $stdout, alt_screen: true, tmux: false)
|
|
282
|
+
def initialize(input: $stdin, output: $stdout, alt_screen: true, tmux: false, env: ENV)
|
|
275
283
|
@input = input
|
|
276
284
|
@output = output
|
|
277
285
|
@alt_screen = alt_screen
|
|
286
|
+
@env = env
|
|
278
287
|
@closed = false
|
|
279
288
|
@opened = false
|
|
280
289
|
@raw = false
|
|
@@ -288,10 +297,14 @@ module Termvas
|
|
|
288
297
|
return [columns, rows] if rows.to_i.positive? && columns.to_i.positive?
|
|
289
298
|
|
|
290
299
|
fallback_size
|
|
291
|
-
rescue Errno::ENOTTY, IOError, NoMethodError
|
|
300
|
+
rescue Errno::ENODEV, Errno::ENOTTY, IOError, NoMethodError
|
|
292
301
|
fallback_size
|
|
293
302
|
end
|
|
294
303
|
|
|
304
|
+
def cell_size
|
|
305
|
+
[environment_dimension("TERMVAS_CELL_WIDTH", 8), environment_dimension("TERMVAS_CELL_HEIGHT", 16)]
|
|
306
|
+
end
|
|
307
|
+
|
|
295
308
|
def open
|
|
296
309
|
return self if @opened
|
|
297
310
|
@opened = true
|
|
@@ -367,12 +380,19 @@ module Termvas
|
|
|
367
380
|
end
|
|
368
381
|
|
|
369
382
|
def fallback_size
|
|
370
|
-
columns = Integer(
|
|
371
|
-
rows = Integer(
|
|
383
|
+
columns = Integer(@env.fetch("COLUMNS", 80))
|
|
384
|
+
rows = Integer(@env.fetch("LINES", 24))
|
|
372
385
|
[columns.positive? ? columns : 80, rows.positive? ? rows : 24]
|
|
373
386
|
rescue ArgumentError, TypeError
|
|
374
387
|
[80, 24]
|
|
375
388
|
end
|
|
389
|
+
|
|
390
|
+
def environment_dimension(name, fallback)
|
|
391
|
+
value = Integer(@env.fetch(name, fallback))
|
|
392
|
+
value.positive? ? value : fallback
|
|
393
|
+
rescue ArgumentError, TypeError
|
|
394
|
+
fallback
|
|
395
|
+
end
|
|
376
396
|
end
|
|
377
397
|
|
|
378
398
|
end
|
data/sig/termvas.rbs
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
module Termvas
|
|
2
2
|
VERSION: String
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
class Terminal
|
|
5
|
+
def initialize: (?input: untyped, ?output: untyped, ?alt_screen: bool, ?tmux: bool, ?env: Hash[String, String]) -> void
|
|
6
|
+
def size: () -> [Integer, Integer]
|
|
7
|
+
def cell_size: () -> [Integer, Integer]
|
|
8
|
+
end
|
|
4
9
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: termvas
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Yudai Takada
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-09-
|
|
11
|
+
date: 2026-09-26 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: Half block, Kitty, iTerm2, and Sixel terminal output with input parsing.
|
|
14
14
|
email:
|
|
@@ -18,6 +18,8 @@ executables:
|
|
|
18
18
|
extensions: []
|
|
19
19
|
extra_rdoc_files: []
|
|
20
20
|
files:
|
|
21
|
+
- ".codespellignore"
|
|
22
|
+
- ".yamllint"
|
|
21
23
|
- CHANGELOG.md
|
|
22
24
|
- LICENSE.txt
|
|
23
25
|
- README.md
|