rufio 1.0.1 → 1.0.2

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: 6e51cc4afc1f8340d7340288d7e20677fcd174d6dd32029714516827375d1d61
4
- data.tar.gz: 3d777468ecee811d01cd303891d6c50aaae1b38e298e8ec2b48f818b6b24ad8c
3
+ metadata.gz: f6a5acef1da176c0bfb0c96f4dacc64e6ab519095b9e282a0c2558ca2594cd34
4
+ data.tar.gz: 5be4e0fe22abcd6d866842ab61436605e940d38d5c3b43f477fc3afea0323413
5
5
  SHA512:
6
- metadata.gz: 4f9b4801d4d3f7bb0406e6f688d5e4de20ccf24d936924f714472d9841284804ebddc7d211a5c0b72cb72df09ea607ea47bd9bc02b0178550c86d9af791e8dfa
7
- data.tar.gz: ffdb0429b787320d57fe28dd68bc67b7278dccf94723d30e52c619e51d60e954d3ed7fd4a1ca8eeaa1de0df914701784f08a74edafaa86a831bc928e3fad93ba
6
+ metadata.gz: 40f7a8c8dc30211dd09ec1c047c2ca52f4f9854020e41e6a56d56d531f84e87dbf920c7f01df213d9d67c4085edf634e7e6b2c924b0b3a8fcb2da3ab56765d54
7
+ data.tar.gz: bc5b4458b71cdd85287f141ea8c8fff2cc66a6ba6a972cca558f1bf6bbd81c6a74a0e46fd1acaf413f2771e4170752fab4bb10838c45791d40c61e76c43c0f89
data/lib/rufio/screen.rb CHANGED
@@ -24,12 +24,16 @@ module Rufio
24
24
  # - Minimal ANSI stripping (only once in put_string)
25
25
  #
26
26
  class Screen
27
+ # Pre-allocated mutable cell. Struct supports [] access like Hash,
28
+ # so callers using cell[:char] etc. need no changes.
29
+ Cell = Struct.new(:char, :fg, :bg, :width)
30
+
27
31
  attr_reader :width, :height
28
32
 
29
33
  def initialize(width, height)
30
34
  @width = width
31
35
  @height = height
32
- @cells = Array.new(height) { Array.new(width) { default_cell } }
36
+ @cells = Array.new(height) { Array.new(width) { Cell.new(' ', nil, nil, 1) } }
33
37
  @overlay_cells = nil # オーバーレイレイヤー(ダイアログ用)
34
38
  @dirty_rows = Set.new # Phase1: Dirty row tracking
35
39
  end
@@ -47,12 +51,11 @@ module Rufio
47
51
 
48
52
  # Phase1: Width is calculated once here (not in rendering loop)
49
53
  char_width = width || TextUtils.display_width(char)
50
- @cells[y][x] = {
51
- char: char,
52
- fg: fg,
53
- bg: bg,
54
- width: char_width
55
- }
54
+ cell = @cells[y][x]
55
+ cell.char = char
56
+ cell.fg = fg
57
+ cell.bg = bg
58
+ cell.width = char_width
56
59
 
57
60
  # Phase1: Mark row as dirty
58
61
  @dirty_rows.add(y)
@@ -62,12 +65,11 @@ module Rufio
62
65
  (char_width - 1).times do |offset|
63
66
  next_x = x + 1 + offset
64
67
  break if next_x >= @width
65
- @cells[y][next_x] = {
66
- char: '',
67
- fg: nil,
68
- bg: nil,
69
- width: 0
70
- }
68
+ marker = @cells[y][next_x]
69
+ marker.char = ''
70
+ marker.fg = nil
71
+ marker.bg = nil
72
+ marker.width = 0
71
73
  end
72
74
  end
73
75
  end
@@ -156,7 +158,12 @@ module Rufio
156
158
  # Clear the entire screen
157
159
  def clear
158
160
  @cells.each do |row|
159
- row.fill { default_cell }
161
+ row.each do |cell|
162
+ cell.char = ' '
163
+ cell.fg = nil
164
+ cell.bg = nil
165
+ cell.width = 1
166
+ end
160
167
  end
161
168
  # Phase1: Clear dirty rows after full clear
162
169
  @dirty_rows.clear
@@ -266,7 +273,7 @@ module Rufio
266
273
  private
267
274
 
268
275
  def default_cell
269
- { char: ' ', fg: nil, bg: nil, width: 1 }
276
+ Cell.new(' ', nil, nil, 1)
270
277
  end
271
278
 
272
279
  def out_of_bounds?(x, y)
data/lib/rufio/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Rufio
4
- VERSION = '1.0.1'
4
+ VERSION = '1.0.2'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rufio
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - masisz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-06-14 00:00:00.000000000 Z
11
+ date: 2026-07-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: io-console