tuile 0.7.0 → 0.9.0

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.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +26 -0
  3. data/README.md +51 -24
  4. data/book/01-first-app.md +186 -0
  5. data/book/02-repaint.md +177 -0
  6. data/book/03-layout.md +379 -0
  7. data/book/04-event-loop.md +209 -0
  8. data/book/05-focus.md +188 -0
  9. data/book/06-theming.md +250 -0
  10. data/book/07-components.md +231 -0
  11. data/book/08-testing.md +186 -0
  12. data/book/README.md +79 -0
  13. data/examples/hello_world.rb +1 -2
  14. data/examples/sampler.rb +109 -0
  15. data/lib/tuile/ansi.rb +16 -0
  16. data/lib/tuile/buffer.rb +481 -0
  17. data/lib/tuile/component/button.rb +3 -14
  18. data/lib/tuile/component/has_content.rb +0 -6
  19. data/lib/tuile/component/info_window.rb +4 -2
  20. data/lib/tuile/component/label.rb +15 -23
  21. data/lib/tuile/component/layout.rb +0 -21
  22. data/lib/tuile/component/list.rb +10 -37
  23. data/lib/tuile/component/log_window.rb +6 -5
  24. data/lib/tuile/component/picker_window.rb +4 -2
  25. data/lib/tuile/component/popup.rb +85 -55
  26. data/lib/tuile/component/text_area.rb +1 -1
  27. data/lib/tuile/component/text_field.rb +1 -1
  28. data/lib/tuile/component/text_input.rb +25 -9
  29. data/lib/tuile/component/text_view.rb +6 -30
  30. data/lib/tuile/component/window.rb +77 -112
  31. data/lib/tuile/component.rb +16 -71
  32. data/lib/tuile/event_queue.rb +31 -10
  33. data/lib/tuile/fake_event_queue.rb +21 -5
  34. data/lib/tuile/fake_screen.rb +14 -1
  35. data/lib/tuile/fraction.rb +46 -0
  36. data/lib/tuile/screen.rb +98 -105
  37. data/lib/tuile/screen_pane.rb +82 -19
  38. data/lib/tuile/styled_string.rb +40 -30
  39. data/lib/tuile/version.rb +1 -1
  40. data/sig/tuile.rbs +653 -282
  41. metadata +13 -3
  42. data/lib/tuile/sizing.rb +0 -59
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tuile
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Vysny
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-06-09 00:00:00.000000000 Z
11
+ date: 2026-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -116,11 +116,21 @@ files:
116
116
  - CODE_OF_CONDUCT.md
117
117
  - LICENSE.txt
118
118
  - README.md
119
+ - book/01-first-app.md
120
+ - book/02-repaint.md
121
+ - book/03-layout.md
122
+ - book/04-event-loop.md
123
+ - book/05-focus.md
124
+ - book/06-theming.md
125
+ - book/07-components.md
126
+ - book/08-testing.md
127
+ - book/README.md
119
128
  - examples/file_commander.rb
120
129
  - examples/hello_world.rb
121
130
  - examples/sampler.rb
122
131
  - lib/tuile.rb
123
132
  - lib/tuile/ansi.rb
133
+ - lib/tuile/buffer.rb
124
134
  - lib/tuile/color.rb
125
135
  - lib/tuile/component.rb
126
136
  - lib/tuile/component/button.rb
@@ -140,6 +150,7 @@ files:
140
150
  - lib/tuile/event_queue.rb
141
151
  - lib/tuile/fake_event_queue.rb
142
152
  - lib/tuile/fake_screen.rb
153
+ - lib/tuile/fraction.rb
143
154
  - lib/tuile/keys.rb
144
155
  - lib/tuile/mouse_event.rb
145
156
  - lib/tuile/point.rb
@@ -147,7 +158,6 @@ files:
147
158
  - lib/tuile/screen.rb
148
159
  - lib/tuile/screen_pane.rb
149
160
  - lib/tuile/size.rb
150
- - lib/tuile/sizing.rb
151
161
  - lib/tuile/styled_string.rb
152
162
  - lib/tuile/terminal_background.rb
153
163
  - lib/tuile/theme.rb
data/lib/tuile/sizing.rb DELETED
@@ -1,59 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Tuile
4
- # A sizing policy for a slot whose position is managed by a parent
5
- # component (e.g. {Component::Window#footer}). Resolves one dimension at a
6
- # time via {#resolve}, so the same value works for widths and heights.
7
- #
8
- # Three policies exist:
9
- #
10
- # - {FILL} — take everything the slot offers;
11
- # - {WRAP_CONTENT} — take the component's natural extent (its
12
- # {Component#content_size}), clamped to the slot;
13
- # - {.fixed} — take exactly the given number of cells, clamped to the slot.
14
- #
15
- # Note that {WRAP_CONTENT} only makes sense for components that report a
16
- # natural {Component#content_size} ({Component::Label}, {Component::Button},
17
- # {Component::List}, …). Input components ({Component::TextField} et al.)
18
- # report {Size::ZERO}, so a wrap-content slot collapses to zero width —
19
- # i.e. the component becomes invisible. Use {.fixed} or {FILL} for those.
20
- #
21
- # @!attribute [r] mode
22
- # @return [Symbol] `:fill`, `:wrap_content` or `:fixed`.
23
- # @!attribute [r] amount
24
- # @return [Integer, nil] the cell count for `:fixed`; `nil` otherwise.
25
- class Sizing < Data.define(:mode, :amount)
26
- # @param amount [Integer] the number of cells to occupy; 0 or greater.
27
- # @return [Sizing] a fixed-size policy.
28
- def self.fixed(amount)
29
- raise TypeError, "expected Integer, got #{amount.inspect}" unless amount.is_a?(Integer)
30
- raise ArgumentError, "amount must not be negative, got #{amount}" if amount.negative?
31
-
32
- new(mode: :fixed, amount: amount)
33
- end
34
-
35
- # Resolves one dimension of a slot.
36
- # @param available [Integer] cells the slot offers; 0 or greater.
37
- # @param content [Integer] the component's natural extent on this axis
38
- # (one dimension of its {Component#content_size}).
39
- # @return [Integer] the resolved extent, always in `0..available`.
40
- def resolve(available, content)
41
- case mode
42
- when :fill then available
43
- when :fixed then amount.clamp(0, available)
44
- when :wrap_content then content.clamp(0, available)
45
- else raise ArgumentError, "unknown mode #{mode.inspect}"
46
- end
47
- end
48
-
49
- # Occupy everything the slot offers.
50
- # @return [Sizing]
51
- FILL = new(mode: :fill, amount: nil)
52
-
53
- # Occupy the component's natural {Component#content_size}, clamped to the
54
- # slot. Components reporting {Size::ZERO} collapse to invisibility — see
55
- # the class doc.
56
- # @return [Sizing]
57
- WRAP_CONTENT = new(mode: :wrap_content, amount: nil)
58
- end
59
- end