hokusai-zero 0.1.2 → 0.1.4

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 (74) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +3 -1
  3. data/Gemfile.lock +4 -0
  4. data/README.md +4 -2
  5. data/ast/src/core/hml.c +9 -9
  6. data/ast/src/core/text.c +1 -3
  7. data/ast/test/text.c +3 -3
  8. data/docs.sh +29 -0
  9. data/ext/extconf.rb +50 -12
  10. data/grammar/corpus/1_document.txt +24 -0
  11. data/grammar/corpus/6_styles.txt +23 -0
  12. data/grammar/grammar.js +4 -4
  13. data/grammar/src/grammar.json +19 -19
  14. data/grammar/src/parser.c +1904 -1956
  15. data/grammar/test.nml +10 -8
  16. data/hokusai.gemspec +5 -1
  17. data/ui/examples/assets/Delius-Regular.ttf +0 -0
  18. data/ui/examples/assets/DoHyeon.ttf +0 -0
  19. data/ui/examples/assets/Inter-Regular.ttf +0 -0
  20. data/ui/examples/assets/ernest.gif +0 -0
  21. data/ui/examples/assets/icons/audio-x-generic.png +0 -0
  22. data/ui/examples/assets/icons/image-x-generic.png +0 -0
  23. data/ui/examples/assets/icons/media-playback-pause.png +0 -0
  24. data/ui/examples/assets/icons/media-playback-start.png +0 -0
  25. data/ui/examples/assets/icons/media-playback-stop.png +0 -0
  26. data/ui/examples/assets/icons/package-x-generic.png +0 -0
  27. data/ui/examples/assets/icons/text-x-generic.png +0 -0
  28. data/ui/examples/assets/icons/video-x-generic.png +0 -0
  29. data/ui/examples/buddy.rb +16 -14
  30. data/ui/examples/clock.rb +38 -36
  31. data/ui/examples/counter.rb +100 -98
  32. data/ui/examples/dynamic.rb +115 -113
  33. data/ui/examples/foobar.rb +189 -187
  34. data/ui/examples/forum/file.rb +54 -0
  35. data/ui/examples/forum/music.rb +76 -0
  36. data/ui/examples/forum/post.rb +146 -0
  37. data/ui/examples/forum.rb +198 -0
  38. data/ui/examples/spreadsheet/csv.rb +261 -0
  39. data/ui/examples/spreadsheet.rb +138 -0
  40. data/ui/examples/stock.rb +86 -92
  41. data/ui/examples/stock_decider/option.rb +1 -1
  42. data/ui/examples/tic_tac_toe.rb +193 -191
  43. data/ui/lib/lib_hokusai.rb +0 -1
  44. data/ui/spec/hokusai/automation/keys_transcoder_spec.rb +5 -5
  45. data/ui/spec/hokusai/e2e/client_spec.rb +1 -0
  46. data/ui/spec/hokusai/e2e/meta_spec.rb +36 -36
  47. data/ui/spec/spec_helper.rb +13 -6
  48. data/ui/src/hokusai/ast.rb +42 -43
  49. data/ui/src/hokusai/backends/raylib/font.rb +1 -2
  50. data/ui/src/hokusai/backends/raylib.rb +16 -7
  51. data/ui/src/hokusai/backends/sdl2/font.rb +13 -9
  52. data/ui/src/hokusai/backends/sdl2.rb +5 -5
  53. data/ui/src/hokusai/block.rb +7 -0
  54. data/ui/src/hokusai/blocks/hblock.rb +2 -2
  55. data/ui/src/hokusai/blocks/image.rb +5 -1
  56. data/ui/src/hokusai/blocks/input.rb +17 -0
  57. data/ui/src/hokusai/blocks/label.rb +5 -2
  58. data/ui/src/hokusai/blocks/text.rb +10 -5
  59. data/ui/src/hokusai/blocks/titlebar/osx.rb +4 -4
  60. data/ui/src/hokusai/blocks/variable.rb +33 -0
  61. data/ui/src/hokusai/blocks/vblock.rb +1 -1
  62. data/ui/src/hokusai/commands/rect.rb +4 -4
  63. data/ui/src/hokusai/commands.rb +33 -31
  64. data/ui/src/hokusai/diff.rb +11 -0
  65. data/ui/src/hokusai/event.rb +19 -5
  66. data/ui/src/hokusai/events/mouse.rb +9 -1
  67. data/ui/src/hokusai/font.rb +60 -0
  68. data/ui/src/hokusai/meta.rb +10 -16
  69. data/ui/src/hokusai/node.rb +1 -1
  70. data/ui/src/hokusai/painter.rb +1 -2
  71. data/ui/src/hokusai/util/clamping_iterator.rb +5 -6
  72. data/ui/src/hokusai.rb +36 -4
  73. data/xmake.lua +5 -4
  74. metadata +79 -3
@@ -77,7 +77,7 @@ module Hokusai
77
77
 
78
78
  before_render&.call([group.block, group.parent], canvas, input.raw)
79
79
 
80
- if capture && can_capture
80
+ if capture
81
81
  capture_events(group.block, canvas, hovered: hovered)
82
82
  end
83
83
 
@@ -188,7 +188,6 @@ module Hokusai
188
188
  return
189
189
  end
190
190
 
191
-
192
191
  rect = canvas.to_hoku_rect
193
192
  block_is_hovered = LibHokusai.hoku_input_is_hovered(input.raw, rect)
194
193
 
@@ -15,9 +15,9 @@ module Hokusai::Util
15
15
  end
16
16
 
17
17
  def draw(font_size, boundary, selection: nil)
18
- selection_extract(font_size, boundary, selection: selection)
18
+ # selection_extract(font_size, boundary, selection: selection)
19
19
  draw_text(font_size, boundary)
20
- selection_update(selection)
20
+ # selection_update(selection)
21
21
  # self.start_select = 0.0
22
22
  # self.stop_select = nil
23
23
  end
@@ -85,17 +85,16 @@ module Hokusai::Util
85
85
  x = @iterator.x
86
86
 
87
87
  if @iterator.clamping.markdown
88
-
89
88
  segment.groups.each do |group|
90
89
  text = iterator.clamping[group.offset, group.size]
91
90
 
92
- if text == " "
93
- x += group.width * 2
94
-
91
+ if text == "\n"
95
92
  next
93
+ # x += group.width
96
94
  end
97
95
 
98
96
  @iterator.on_draw_cb&.call(text, x, y, group)
97
+
99
98
  x += group.width
100
99
  end
101
100
  else
data/ui/src/hokusai.rb CHANGED
@@ -32,10 +32,14 @@ require_relative './hokusai/blocks/panel'
32
32
  require_relative './hokusai/blocks/text'
33
33
  require_relative './hokusai/blocks/selectable'
34
34
  require_relative './hokusai/blocks/input'
35
+ require_relative './hokusai/blocks/variable'
35
36
  require_relative './hokusai/blocks/titlebar/osx'
36
37
 
37
38
  require "concurrent"
38
39
 
40
+ # A backend agnostic library for authoring
41
+ # desktop applications
42
+ # @author skinnyjames
39
43
  module Hokusai
40
44
  ThreadPool = Concurrent::ThreadPoolExecutor.new(
41
45
  min_threads: 5,
@@ -44,60 +48,83 @@ module Hokusai
44
48
  fallback_policy: :caller_runs
45
49
  )
46
50
 
51
+ # Access the font registry
52
+ #
53
+ # @return [Hokusai::FontRegistry]
47
54
  def self.fonts
48
55
  @fonts ||= FontRegistry.new
49
56
  end
50
57
 
58
+ # Close the current window
59
+ #
60
+ # @return [void]
51
61
  def self.close_window
52
62
  @on_close_window&.call
53
63
  end
54
64
 
65
+ # **Backend:** Provides the window close callback
55
66
  def self.on_close_window(&block)
56
67
  @on_close_window = block
57
68
  end
58
69
 
70
+ # **Backend:** Provides the window restore callback
59
71
  def self.on_restore_window(&block)
60
72
  @on_restore_window = block
61
73
  end
62
74
 
75
+ # Restores the current window
76
+ #
77
+ # @return [void]
63
78
  def self.restore_window
64
79
  @on_restore_window&.call
65
80
  end
66
81
 
82
+ # Minimizes the current window
83
+ #
84
+ # @return [void]
67
85
  def self.minimize_window
68
86
  @on_minimize_window&.call
69
87
  end
70
88
 
89
+ # **Backend** Provides the minimize window callback
71
90
  def self.on_minimize_window(&block)
72
91
  @on_minimize_window = block
73
92
  end
74
93
 
94
+ # Maxmizes the current window
95
+ #
96
+ # @return [void]
75
97
  def self.maximize_window
76
98
  @on_maximize_window&.call
77
99
  end
78
100
 
101
+ # **Backend** Provides the maximize window callback
79
102
  def self.on_maximize_window(&block)
80
103
  @on_maximize_window = block
81
104
  end
82
105
 
83
106
  # Sets the window position on the screen
84
107
  #
85
- # NOTE the implementation is backend specific
108
+ # @param [Array<Float, Float>]
109
+ # @return [void]
86
110
  def self.set_window_position(mouse)
87
111
  @on_set_window_position&.call(mouse)
88
112
  end
89
113
 
114
+ # **Backend:** Provides the window position callback
90
115
  def self.on_set_window_position(&block)
91
116
  @on_set_window_position = block
92
117
  end
93
118
 
94
- # Sets the mouse position on the screen
95
- #
96
- # NOTE the implementation is backend specific
119
+ # **Backend:** Provides the mouse position callback
97
120
  def self.on_set_mouse_position(&block)
98
121
  @on_set_mouse_position = block
99
122
  end
100
123
 
124
+ # Sets the window position on the screen
125
+ #
126
+ # @param [Array<Float, Float>]
127
+ # @return [void]
101
128
  def self.set_mouse_position(mouse)
102
129
  @on_set_mouse_position&.call(mouse)
103
130
  end
@@ -106,6 +133,11 @@ module Hokusai
106
133
  @on_renderable = block
107
134
  end
108
135
 
136
+ # Tells if a canvas is renderable
137
+ # Useful for pruning unneeded renders
138
+ #
139
+ # @param [Hokusai::Canvas]
140
+ # @return [Bool]
109
141
  def self.can_render(canvas)
110
142
  @on_renderable&.call(canvas)
111
143
  end
data/xmake.lua CHANGED
@@ -1,9 +1,10 @@
1
- package("tree-sitter")
2
- set_base("tree-sitter")
1
+ package("hoku-tree-sitter")
3
2
  add_deps("make")
4
3
  set_policy("package.install_always", true)
5
- add_urls("https://github.com/tree-sitter/tree-sitter.git")
4
+ add_urls("https://github.com/tree-sitter/tree-sitter/archive/refs/tags/$(version).zip")
5
+ add_versions("v0.22.2", "df0cd4aacc53b6feb9519dd4b74a7a6c8b7f3f7381fcf7793250db3e5e63fb80")
6
6
  on_install(function(package)
7
+ cprint(string.format("%s/vendor", os:projectdir()))
7
8
  os.mkdir(string.format("%s/vendor/include", os:projectdir()))
8
9
  os.mkdir(string.format("%s/vendor/lib", os:projectdir()))
9
10
  os.execv("make install", {}, {envs={PREFIX=string.format("%s/vendor", os.projectdir())}})
@@ -92,7 +93,7 @@ package("libsdl_image")
92
93
  end)
93
94
  package_end()
94
95
 
95
- package("md4c")
96
+ package("hoku-md4c")
96
97
  set_license("MIT")
97
98
  add_urls("https://github.com/mity/md4c.git")
98
99
  add_deps("cmake")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hokusai-zero
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - skinnyjames
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-01-02 00:00:00.000000000 Z
11
+ date: 2025-03-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
@@ -24,6 +24,62 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: concurrent-ruby
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 1.3.4
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 1.3.4
41
+ - !ruby/object:Gem::Dependency
42
+ name: raylib-bindings
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.7.9
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.7.9
55
+ - !ruby/object:Gem::Dependency
56
+ name: sdl2-bindings
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.2.3
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.2.3
69
+ - !ruby/object:Gem::Dependency
70
+ name: memory_profiler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
27
83
  description:
28
84
  email: zero@skinnyjames.net
29
85
  executables: []
@@ -62,6 +118,7 @@ files:
62
118
  - ast/test/hokusai.c
63
119
  - ast/test/parser.c
64
120
  - ast/test/text.c
121
+ - docs.sh
65
122
  - ext/extconf.rb
66
123
  - grammar/Cargo.lock
67
124
  - grammar/Cargo.toml
@@ -87,19 +144,37 @@ files:
87
144
  - grammar/src/tree_sitter/scanner.h
88
145
  - grammar/test.nml
89
146
  - hokusai.gemspec
147
+ - ui/examples/assets/Delius-Regular.ttf
90
148
  - ui/examples/assets/DigitalDisplay.ttf
149
+ - ui/examples/assets/DoHyeon.ttf
150
+ - ui/examples/assets/Inter-Regular.ttf
91
151
  - ui/examples/assets/OpenSans-Regular.ttf
92
152
  - ui/examples/assets/addy.png
93
153
  - ui/examples/assets/baby_sean.png
154
+ - ui/examples/assets/ernest.gif
94
155
  - ui/examples/assets/football-troll.png
95
156
  - ui/examples/assets/gear.png
96
157
  - ui/examples/assets/icecold.ttf
158
+ - ui/examples/assets/icons/audio-x-generic.png
159
+ - ui/examples/assets/icons/image-x-generic.png
160
+ - ui/examples/assets/icons/media-playback-pause.png
161
+ - ui/examples/assets/icons/media-playback-start.png
162
+ - ui/examples/assets/icons/media-playback-stop.png
163
+ - ui/examples/assets/icons/package-x-generic.png
164
+ - ui/examples/assets/icons/text-x-generic.png
165
+ - ui/examples/assets/icons/video-x-generic.png
97
166
  - ui/examples/assets/science-troll.png
98
167
  - ui/examples/buddy.rb
99
168
  - ui/examples/clock.rb
100
169
  - ui/examples/counter.rb
101
170
  - ui/examples/dynamic.rb
102
171
  - ui/examples/foobar.rb
172
+ - ui/examples/forum.rb
173
+ - ui/examples/forum/file.rb
174
+ - ui/examples/forum/music.rb
175
+ - ui/examples/forum/post.rb
176
+ - ui/examples/spreadsheet.rb
177
+ - ui/examples/spreadsheet/csv.rb
103
178
  - ui/examples/stock.rb
104
179
  - ui/examples/stock_decider/option.rb
105
180
  - ui/examples/tic_tac_toe.rb
@@ -165,6 +240,7 @@ files:
165
240
  - ui/src/hokusai/blocks/text.rb
166
241
  - ui/src/hokusai/blocks/titlebar/osx.rb
167
242
  - ui/src/hokusai/blocks/toggle.rb
243
+ - ui/src/hokusai/blocks/variable.rb
168
244
  - ui/src/hokusai/blocks/vblock.rb
169
245
  - ui/src/hokusai/commands.rb
170
246
  - ui/src/hokusai/commands/base.rb
@@ -215,7 +291,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
215
291
  - !ruby/object:Gem::Version
216
292
  version: '0'
217
293
  requirements: []
218
- rubygems_version: 3.5.22
294
+ rubygems_version: 3.5.18
219
295
  signing_key:
220
296
  specification_version: 4
221
297
  summary: A Ruby library for writing GUI applications