@xincli/opentui-core 0.4.6
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.
- package/README.md +63 -0
- package/dev/keypress-debug-renderer.ts +148 -0
- package/dev/keypress-debug.ts +43 -0
- package/dev/print-env-vars.ts +32 -0
- package/dev/test-tmux-graphics-334.sh +68 -0
- package/dev/test-tmux-theme-queries.sh +151 -0
- package/dev/thai-debug-test.ts +68 -0
- package/dev/theme-mode.ts +290 -0
- package/docs/development.md +144 -0
- package/package.json +102 -0
- package/prebuilt/aarch64-android/libopentui.so +0 -0
- package/scripts/build-android.ts +226 -0
- package/scripts/build-native-termux.sh +525 -0
- package/scripts/build.ts +530 -0
- package/scripts/dist-test.ts +312 -0
- package/scripts/package-prebuilt.ts +110 -0
- package/scripts/publish.ts +60 -0
- package/scripts/test-node-hook.mjs +16 -0
- package/scripts/test-node.ts +241 -0
- package/scripts/vendor-deps.sh +73 -0
- package/src/NativeSpanFeed.ts +375 -0
- package/src/Renderable.ts +1878 -0
- package/src/__snapshots__/buffer.test.ts.snap +28 -0
- package/src/animation/Timeline.test.ts +2709 -0
- package/src/animation/Timeline.ts +598 -0
- package/src/ansi.ts +22 -0
- package/src/audio.ts +479 -0
- package/src/benchmark/attenuation-benchmark.ts +81 -0
- package/src/benchmark/audio-playback-benchmark.ts +344 -0
- package/src/benchmark/box-draw-benchmark.ts +1042 -0
- package/src/benchmark/colormatrix-benchmark.ts +123 -0
- package/src/benchmark/gain-benchmark.ts +80 -0
- package/src/benchmark/latest-all-bench-run.json +707 -0
- package/src/benchmark/latest-async-bench-run.json +336 -0
- package/src/benchmark/latest-default-bench-run.json +657 -0
- package/src/benchmark/latest-large-bench-run.json +707 -0
- package/src/benchmark/latest-quick-bench-run.json +207 -0
- package/src/benchmark/layout-benchmark.ts +2547 -0
- package/src/benchmark/markdown-benchmark.ts +1796 -0
- package/src/benchmark/native-span-feed-async-benchmark.ts +355 -0
- package/src/benchmark/native-span-feed-benchmark.md +56 -0
- package/src/benchmark/native-span-feed-benchmark.ts +596 -0
- package/src/benchmark/native-span-feed-compare.ts +280 -0
- package/src/benchmark/render-traversal-benchmark.ts +928 -0
- package/src/benchmark/text-buffer-render-benchmark.ts +874 -0
- package/src/benchmark/text-table-benchmark.ts +948 -0
- package/src/buffer.test.ts +292 -0
- package/src/buffer.ts +564 -0
- package/src/console.test.ts +629 -0
- package/src/console.ts +1253 -0
- package/src/edit-buffer.test.ts +1852 -0
- package/src/edit-buffer.ts +417 -0
- package/src/editor-view.test.ts +1056 -0
- package/src/editor-view.ts +290 -0
- package/src/index.ts +25 -0
- package/src/lib/KeyHandler.integration.test.ts +292 -0
- package/src/lib/KeyHandler.stopPropagation.test.ts +289 -0
- package/src/lib/KeyHandler.test.ts +662 -0
- package/src/lib/KeyHandler.ts +222 -0
- package/src/lib/RGBA.test.ts +60 -0
- package/src/lib/RGBA.ts +343 -0
- package/src/lib/ascii.font.ts +330 -0
- package/src/lib/border.test.ts +83 -0
- package/src/lib/border.ts +170 -0
- package/src/lib/bunfs.test.ts +27 -0
- package/src/lib/bunfs.ts +18 -0
- package/src/lib/clipboard.test.ts +63 -0
- package/src/lib/clipboard.ts +41 -0
- package/src/lib/clock.ts +35 -0
- package/src/lib/data-paths.test.ts +133 -0
- package/src/lib/data-paths.ts +109 -0
- package/src/lib/debounce.ts +106 -0
- package/src/lib/detect-links.test.ts +98 -0
- package/src/lib/detect-links.ts +56 -0
- package/src/lib/env.test.ts +228 -0
- package/src/lib/env.ts +209 -0
- package/src/lib/extmarks-history.ts +51 -0
- package/src/lib/extmarks-multiwidth.test.ts +324 -0
- package/src/lib/extmarks.test.ts +3547 -0
- package/src/lib/extmarks.ts +861 -0
- package/src/lib/fonts/block.json +405 -0
- package/src/lib/fonts/grid.json +265 -0
- package/src/lib/fonts/huge.json +741 -0
- package/src/lib/fonts/pallet.json +314 -0
- package/src/lib/fonts/shade.json +591 -0
- package/src/lib/fonts/slick.json +321 -0
- package/src/lib/fonts/tiny.json +69 -0
- package/src/lib/hast-styled-text.ts +59 -0
- package/src/lib/index.ts +22 -0
- package/src/lib/keybinding.internal.test.ts +342 -0
- package/src/lib/keybinding.internal.ts +182 -0
- package/src/lib/objects-in-viewport.test.ts +789 -0
- package/src/lib/objects-in-viewport.ts +153 -0
- package/src/lib/output.capture.ts +58 -0
- package/src/lib/parse.keypress-kitty.protocol.test.ts +347 -0
- package/src/lib/parse.keypress-kitty.test.ts +712 -0
- package/src/lib/parse.keypress-kitty.ts +470 -0
- package/src/lib/parse.keypress.test.ts +2020 -0
- package/src/lib/parse.keypress.ts +480 -0
- package/src/lib/parse.mouse.test.ts +552 -0
- package/src/lib/parse.mouse.ts +232 -0
- package/src/lib/paste.ts +18 -0
- package/src/lib/queue.ts +65 -0
- package/src/lib/render-geometry.ts +36 -0
- package/src/lib/renderable.validations.test.ts +87 -0
- package/src/lib/renderable.validations.ts +83 -0
- package/src/lib/scroll-acceleration.ts +98 -0
- package/src/lib/selection.ts +261 -0
- package/src/lib/singleton.ts +34 -0
- package/src/lib/stdin-parser.test.ts +2439 -0
- package/src/lib/stdin-parser.ts +2007 -0
- package/src/lib/styled-text.ts +178 -0
- package/src/lib/terminal-capability-detection.test.ts +226 -0
- package/src/lib/terminal-capability-detection.ts +98 -0
- package/src/lib/terminal-palette.test.ts +954 -0
- package/src/lib/terminal-palette.ts +441 -0
- package/src/lib/tree-sitter/assets/README.md +119 -0
- package/src/lib/tree-sitter/assets/javascript/highlights.scm +205 -0
- package/src/lib/tree-sitter/assets/javascript/tree-sitter-javascript.wasm +0 -0
- package/src/lib/tree-sitter/assets/markdown/highlights.scm +150 -0
- package/src/lib/tree-sitter/assets/markdown/injections.scm +27 -0
- package/src/lib/tree-sitter/assets/markdown/tree-sitter-markdown.wasm +0 -0
- package/src/lib/tree-sitter/assets/markdown_inline/highlights.scm +115 -0
- package/src/lib/tree-sitter/assets/markdown_inline/tree-sitter-markdown_inline.wasm +0 -0
- package/src/lib/tree-sitter/assets/typescript/highlights.scm +604 -0
- package/src/lib/tree-sitter/assets/typescript/tree-sitter-typescript.wasm +0 -0
- package/src/lib/tree-sitter/assets/update.ts +360 -0
- package/src/lib/tree-sitter/assets/zig/highlights.scm +284 -0
- package/src/lib/tree-sitter/assets/zig/tree-sitter-zig.wasm +0 -0
- package/src/lib/tree-sitter/assets.d.ts +9 -0
- package/src/lib/tree-sitter/cache.test.ts +291 -0
- package/src/lib/tree-sitter/client.test.ts +1434 -0
- package/src/lib/tree-sitter/client.ts +847 -0
- package/src/lib/tree-sitter/default-parsers.ts +133 -0
- package/src/lib/tree-sitter/download-utils.ts +148 -0
- package/src/lib/tree-sitter/index.ts +75 -0
- package/src/lib/tree-sitter/parser.worker.ts +1098 -0
- package/src/lib/tree-sitter/parsers-config.ts +81 -0
- package/src/lib/tree-sitter/resolve-ft.test.ts +55 -0
- package/src/lib/tree-sitter/resolve-ft.ts +189 -0
- package/src/lib/tree-sitter/types.ts +132 -0
- package/src/lib/tree-sitter/update-assets.ts +10 -0
- package/src/lib/tree-sitter-styled-text.test.ts +1253 -0
- package/src/lib/tree-sitter-styled-text.ts +314 -0
- package/src/lib/validate-dir-name.ts +55 -0
- package/src/lib/yoga.options.test.ts +628 -0
- package/src/lib/yoga.options.ts +346 -0
- package/src/native-event-worker-repro.test.ts +48 -0
- package/src/native-event-worker-repro.worker.ts +9 -0
- package/src/native-handle.test.ts +221 -0
- package/src/platform/ffi.test.ts +516 -0
- package/src/platform/ffi.ts +653 -0
- package/src/platform/runtime.test.ts +52 -0
- package/src/platform/runtime.ts +121 -0
- package/src/platform/test.ts +45 -0
- package/src/platform/worker-handler-cleanup.fixture.ts +12 -0
- package/src/platform/worker-onmessage-startup.fixture.ts +10 -0
- package/src/platform/worker-startup.fixture.ts +9 -0
- package/src/platform/worker.node-test.ts +153 -0
- package/src/platform/worker.ts +425 -0
- package/src/plugins/core-slot.ts +579 -0
- package/src/plugins/registry.ts +402 -0
- package/src/plugins/types.ts +46 -0
- package/src/post/effects.ts +948 -0
- package/src/post/filters.ts +512 -0
- package/src/post/matrices.ts +288 -0
- package/src/renderables/ASCIIFont.ts +219 -0
- package/src/renderables/Box.test.ts +474 -0
- package/src/renderables/Box.ts +353 -0
- package/src/renderables/Code.test.ts +2388 -0
- package/src/renderables/Code.ts +555 -0
- package/src/renderables/Diff.regression.test.ts +381 -0
- package/src/renderables/Diff.test.ts +3212 -0
- package/src/renderables/Diff.ts +1278 -0
- package/src/renderables/EditBufferRenderable.test.ts +288 -0
- package/src/renderables/EditBufferRenderable.ts +1152 -0
- package/src/renderables/FrameBuffer.ts +47 -0
- package/src/renderables/Input.test.ts +1310 -0
- package/src/renderables/Input.ts +273 -0
- package/src/renderables/LineNumberRenderable.ts +725 -0
- package/src/renderables/Markdown.ts +2144 -0
- package/src/renderables/ScrollBar.ts +423 -0
- package/src/renderables/ScrollBox.ts +903 -0
- package/src/renderables/Select.test.ts +1134 -0
- package/src/renderables/Select.ts +535 -0
- package/src/renderables/Slider.test.ts +456 -0
- package/src/renderables/Slider.ts +342 -0
- package/src/renderables/TabSelect.test.ts +238 -0
- package/src/renderables/TabSelect.ts +447 -0
- package/src/renderables/Text.selection-buffer.test.ts +118 -0
- package/src/renderables/Text.test.ts +2662 -0
- package/src/renderables/Text.ts +147 -0
- package/src/renderables/TextBufferRenderable.ts +504 -0
- package/src/renderables/TextNode.test.ts +1137 -0
- package/src/renderables/TextNode.ts +379 -0
- package/src/renderables/TextTable.test.ts +1411 -0
- package/src/renderables/TextTable.ts +1434 -0
- package/src/renderables/Textarea.ts +425 -0
- package/src/renderables/TimeToFirstDraw.ts +89 -0
- package/src/renderables/__snapshots__/Code.test.ts.snap +13 -0
- package/src/renderables/__snapshots__/Diff.test.ts.snap +785 -0
- package/src/renderables/__snapshots__/Text.test.ts.snap +421 -0
- package/src/renderables/__snapshots__/TextTable.test.ts.snap +215 -0
- package/src/renderables/__tests__/Code.test.ts +55 -0
- package/src/renderables/__tests__/LineNumberRenderable.scrollbox-simple.test.ts +144 -0
- package/src/renderables/__tests__/LineNumberRenderable.scrollbox.test.ts +827 -0
- package/src/renderables/__tests__/LineNumberRenderable.test.ts +1906 -0
- package/src/renderables/__tests__/LineNumberRenderable.wrapping.test.ts +85 -0
- package/src/renderables/__tests__/Markdown.code-colors.test.ts +288 -0
- package/src/renderables/__tests__/Markdown.test.ts +4175 -0
- package/src/renderables/__tests__/MultiRenderable.selection.test.ts +87 -0
- package/src/renderables/__tests__/Textarea.buffer.test.ts +683 -0
- package/src/renderables/__tests__/Textarea.destroyed-events.test.ts +675 -0
- package/src/renderables/__tests__/Textarea.editing.test.ts +2120 -0
- package/src/renderables/__tests__/Textarea.error-handling.test.ts +35 -0
- package/src/renderables/__tests__/Textarea.events.test.ts +738 -0
- package/src/renderables/__tests__/Textarea.highlights.test.ts +590 -0
- package/src/renderables/__tests__/Textarea.keybinding.test.ts +3275 -0
- package/src/renderables/__tests__/Textarea.paste.test.ts +357 -0
- package/src/renderables/__tests__/Textarea.rendering.test.ts +1927 -0
- package/src/renderables/__tests__/Textarea.scroll.test.ts +733 -0
- package/src/renderables/__tests__/Textarea.selection.test.ts +1589 -0
- package/src/renderables/__tests__/Textarea.stress.test.ts +670 -0
- package/src/renderables/__tests__/Textarea.undo-redo.test.ts +383 -0
- package/src/renderables/__tests__/Textarea.visual-lines.test.ts +310 -0
- package/src/renderables/__tests__/__snapshots__/LineNumberRenderable.code.test.ts.snap +221 -0
- package/src/renderables/__tests__/__snapshots__/LineNumberRenderable.scrollbox-simple.test.ts.snap +89 -0
- package/src/renderables/__tests__/__snapshots__/LineNumberRenderable.scrollbox.test.ts.snap +457 -0
- package/src/renderables/__tests__/__snapshots__/LineNumberRenderable.test.ts.snap +158 -0
- package/src/renderables/__tests__/__snapshots__/Textarea.rendering.test.ts.snap +387 -0
- package/src/renderables/__tests__/markdown-parser.test.ts +241 -0
- package/src/renderables/__tests__/renderable-test-utils.ts +60 -0
- package/src/renderables/composition/README.md +8 -0
- package/src/renderables/composition/VRenderable.ts +32 -0
- package/src/renderables/composition/constructs.ts +127 -0
- package/src/renderables/composition/vnode.ts +277 -0
- package/src/renderables/index.ts +23 -0
- package/src/renderables/markdown-parser.ts +79 -0
- package/src/renderer-theme-mode.ts +199 -0
- package/src/renderer.ts +4975 -0
- package/src/runtime-plugin-support-configure.ts +63 -0
- package/src/runtime-plugin-support.ts +13 -0
- package/src/runtime-plugin.ts +626 -0
- package/src/specs/terminal-startup.md +64 -0
- package/src/syntax-style.test.ts +841 -0
- package/src/syntax-style.ts +274 -0
- package/src/testing/README.md +219 -0
- package/src/testing/bun-test-node.ts +880 -0
- package/src/testing/capture-spans.test.ts +216 -0
- package/src/testing/integration.test.ts +276 -0
- package/src/testing/manual-clock.ts +117 -0
- package/src/testing/mock-keys.test.ts +1378 -0
- package/src/testing/mock-keys.ts +457 -0
- package/src/testing/mock-mouse.test.ts +218 -0
- package/src/testing/mock-mouse.ts +247 -0
- package/src/testing/mock-tree-sitter-client.ts +81 -0
- package/src/testing/spy.ts +13 -0
- package/src/testing/terminal-capabilities.ts +47 -0
- package/src/testing/test-recorder.test.ts +410 -0
- package/src/testing/test-recorder.ts +133 -0
- package/src/testing/test-renderer.ts +375 -0
- package/src/testing/test-renderer.wait.test.ts +278 -0
- package/src/testing/test-streams.ts +31 -0
- package/src/testing.ts +9 -0
- package/src/tests/__snapshots__/absolute-positioning.snapshot.test.ts.snap +481 -0
- package/src/tests/__snapshots__/renderable.snapshot.test.ts.snap +19 -0
- package/src/tests/__snapshots__/scrollbox.test.ts.snap +29 -0
- package/src/tests/absolute-positioning.snapshot.test.ts +638 -0
- package/src/tests/allocator-stats.test.ts +53 -0
- package/src/tests/audio.test.ts +303 -0
- package/src/tests/destroy-during-render.test.ts +200 -0
- package/src/tests/destroy-on-exit.fixture.ts +36 -0
- package/src/tests/destroy-on-exit.test.ts +62 -0
- package/src/tests/ffi-borrowed-pointer-callsites.test.ts +153 -0
- package/src/tests/hover-cursor.test.ts +98 -0
- package/src/tests/native-backed-measurement-lifecycle.test.ts +133 -0
- package/src/tests/native-backed-measurement-parity.test.ts +322 -0
- package/src/tests/native-span-feed-async.test.ts +173 -0
- package/src/tests/native-span-feed-close.test.ts +120 -0
- package/src/tests/native-span-feed-coverage.test.ts +227 -0
- package/src/tests/native-span-feed-edge-cases.test.ts +384 -0
- package/src/tests/native-span-feed-use-after-free.test.ts +45 -0
- package/src/tests/opacity.test.ts +123 -0
- package/src/tests/renderable.snapshot.test.ts +524 -0
- package/src/tests/renderable.test.ts +1851 -0
- package/src/tests/renderer.clock.test.ts +270 -0
- package/src/tests/renderer.console-startup.test.ts +2151 -0
- package/src/tests/renderer.control.test.ts +458 -0
- package/src/tests/renderer.core-slot-binding.test.ts +962 -0
- package/src/tests/renderer.cursor.test.ts +26 -0
- package/src/tests/renderer.custom-stdout.test.ts +1112 -0
- package/src/tests/renderer.destroy-during-render.test.ts +147 -0
- package/src/tests/renderer.focus-restore.test.ts +257 -0
- package/src/tests/renderer.focus.test.ts +329 -0
- package/src/tests/renderer.idle.test.ts +219 -0
- package/src/tests/renderer.input.test.ts +2615 -0
- package/src/tests/renderer.kitty-flags.test.ts +195 -0
- package/src/tests/renderer.lifecycle.test.ts +34 -0
- package/src/tests/renderer.mouse.test.ts +1315 -0
- package/src/tests/renderer.notifications.test.ts +27 -0
- package/src/tests/renderer.palette.test.ts +1199 -0
- package/src/tests/renderer.remote.test.ts +247 -0
- package/src/tests/renderer.render-stats.test.ts +146 -0
- package/src/tests/renderer.scrollback-surface.test.ts +474 -0
- package/src/tests/renderer.selection.test.ts +138 -0
- package/src/tests/renderer.slot-registry.test.ts +684 -0
- package/src/tests/renderer.tracker.test.ts +202 -0
- package/src/tests/renderer.useMouse.test.ts +83 -0
- package/src/tests/runtime-plugin-node-modules-cycle.fixture.ts +76 -0
- package/src/tests/runtime-plugin-node-modules-import-like-string.fixture.ts +48 -0
- package/src/tests/runtime-plugin-node-modules-mjs.fixture.ts +43 -0
- package/src/tests/runtime-plugin-node-modules-no-bare-rewrite.fixture.ts +67 -0
- package/src/tests/runtime-plugin-node-modules-package-type-cache.fixture.ts +72 -0
- package/src/tests/runtime-plugin-node-modules-runtime-specifier.fixture.ts +44 -0
- package/src/tests/runtime-plugin-node-modules-scoped-package-bare-rewrite.fixture.ts +85 -0
- package/src/tests/runtime-plugin-path-alias.fixture.ts +43 -0
- package/src/tests/runtime-plugin-resolve-roots.fixture.ts +65 -0
- package/src/tests/runtime-plugin-support-configure.fixture.ts +31 -0
- package/src/tests/runtime-plugin-support-late-addition.fixture.ts +17 -0
- package/src/tests/runtime-plugin-support.fixture.ts +11 -0
- package/src/tests/runtime-plugin-support.test.ts +54 -0
- package/src/tests/runtime-plugin-windows-file-url.fixture.ts +30 -0
- package/src/tests/runtime-plugin.fixture.ts +40 -0
- package/src/tests/runtime-plugin.test.ts +369 -0
- package/src/tests/scrollbox-culling-bug.test.ts +114 -0
- package/src/tests/scrollbox-hitgrid-resize.test.ts +136 -0
- package/src/tests/scrollbox-hitgrid.test.ts +909 -0
- package/src/tests/scrollbox.test.ts +1895 -0
- package/src/tests/wrap-resize-perf.test.ts +276 -0
- package/src/tests/yoga-api-coverage.test.ts +409 -0
- package/src/tests/yoga-callback-stress.test.ts +122 -0
- package/src/tests/yoga-ffi.test.ts +117 -0
- package/src/tests/yoga-setters.test.ts +921 -0
- package/src/tests/yoga-upstream/YGAlignBaselineTest.test.ts +124 -0
- package/src/tests/yoga-upstream/YGComputedBorderTest.test.ts +27 -0
- package/src/tests/yoga-upstream/YGComputedMarginTest.test.ts +27 -0
- package/src/tests/yoga-upstream/YGComputedPaddingTest.test.ts +27 -0
- package/src/tests/yoga-upstream/YGDirtiedTest.test.ts +157 -0
- package/src/tests/yoga-upstream/YGErrataTest.test.ts +40 -0
- package/src/tests/yoga-upstream/YGFlexBasisAuto.test.ts +23 -0
- package/src/tests/yoga-upstream/YGHasNewLayout.test.ts +81 -0
- package/src/tests/yoga-upstream/YGMeasureCacheTest.test.ts +31 -0
- package/src/tests/yoga-upstream/YGMeasureTest.test.ts +70 -0
- package/src/tests/yoga-upstream/generated/YGAbsolutePositionTest.test.ts +1864 -0
- package/src/tests/yoga-upstream/generated/YGAlignContentTest.test.ts +5829 -0
- package/src/tests/yoga-upstream/generated/YGAlignItemsTest.test.ts +2444 -0
- package/src/tests/yoga-upstream/generated/YGAlignSelfTest.test.ts +293 -0
- package/src/tests/yoga-upstream/generated/YGAndroidNewsFeed.test.ts +315 -0
- package/src/tests/yoga-upstream/generated/YGAspectRatioTest.test.ts +231 -0
- package/src/tests/yoga-upstream/generated/YGAutoTest.test.ts +347 -0
- package/src/tests/yoga-upstream/generated/YGBorderTest.test.ts +256 -0
- package/src/tests/yoga-upstream/generated/YGBoxSizingTest.test.ts +2747 -0
- package/src/tests/yoga-upstream/generated/YGDimensionTest.test.ts +129 -0
- package/src/tests/yoga-upstream/generated/YGDisplayContentsTest.test.ts +109 -0
- package/src/tests/yoga-upstream/generated/YGDisplayTest.test.ts +1097 -0
- package/src/tests/yoga-upstream/generated/YGFlexDirectionTest.test.ts +4562 -0
- package/src/tests/yoga-upstream/generated/YGFlexTest.test.ts +677 -0
- package/src/tests/yoga-upstream/generated/YGFlexWrapTest.test.ts +2071 -0
- package/src/tests/yoga-upstream/generated/YGGapTest.test.ts +3303 -0
- package/src/tests/yoga-upstream/generated/YGIntrinsicSizeTest.test.ts +582 -0
- package/src/tests/yoga-upstream/generated/YGJustifyContentTest.test.ts +2150 -0
- package/src/tests/yoga-upstream/generated/YGMarginTest.test.ts +1963 -0
- package/src/tests/yoga-upstream/generated/YGMinMaxDimensionTest.test.ts +1446 -0
- package/src/tests/yoga-upstream/generated/YGPaddingTest.test.ts +354 -0
- package/src/tests/yoga-upstream/generated/YGPercentageTest.test.ts +1760 -0
- package/src/tests/yoga-upstream/generated/YGRoundingTest.test.ts +1161 -0
- package/src/tests/yoga-upstream/generated/YGSizeOverflowTest.test.ts +207 -0
- package/src/tests/yoga-upstream/generated/YGStaticPositionTest.test.ts +6338 -0
- package/src/tests/yoga-upstream/tools/MeasureCounter.ts +54 -0
- package/src/tests/yoga-upstream/tools/utils.ts +81 -0
- package/src/text-buffer-view.test.ts +722 -0
- package/src/text-buffer-view.ts +193 -0
- package/src/text-buffer.test.ts +512 -0
- package/src/text-buffer.ts +250 -0
- package/src/types.ts +199 -0
- package/src/utils.ts +88 -0
- package/src/yoga.ts +1146 -0
- package/src/zig/ansi.zig +502 -0
- package/src/zig/audio.zig +1206 -0
- package/src/zig/bench/README.md +50 -0
- package/src/zig/bench/buffer-color-blending_bench.zig +350 -0
- package/src/zig/bench/buffer-draw-box_bench.zig +786 -0
- package/src/zig/bench/buffer-draw-text-buffer_bench.zig +894 -0
- package/src/zig/bench/edit-buffer_bench.zig +476 -0
- package/src/zig/bench/editor-view_bench.zig +169 -0
- package/src/zig/bench/native-span-feed_bench.zig +107 -0
- package/src/zig/bench/rope-markers_bench.zig +713 -0
- package/src/zig/bench/rope_bench.zig +514 -0
- package/src/zig/bench/styled-text_bench.zig +476 -0
- package/src/zig/bench/text-buffer-coords_bench.zig +362 -0
- package/src/zig/bench/text-buffer-view_bench.zig +459 -0
- package/src/zig/bench/text-chunk-graphemes_bench.zig +272 -0
- package/src/zig/bench/utf8_bench.zig +799 -0
- package/src/zig/bench-utils.zig +431 -0
- package/src/zig/bench.zig +223 -0
- package/src/zig/buffer-methods.zig +215 -0
- package/src/zig/buffer.zig +2515 -0
- package/src/zig/build.zig +700 -0
- package/src/zig/build.zig.zon +19 -0
- package/src/zig/edit-buffer.zig +900 -0
- package/src/zig/editor-view.zig +812 -0
- package/src/zig/event-bus.zig +28 -0
- package/src/zig/event-emitter.zig +65 -0
- package/src/zig/file-logger.zig +92 -0
- package/src/zig/grapheme.zig +838 -0
- package/src/zig/handles.zig +267 -0
- package/src/zig/lib.zig +2813 -0
- package/src/zig/link.zig +349 -0
- package/src/zig/logger.zig +43 -0
- package/src/zig/mem-registry.zig +126 -0
- package/src/zig/miniaudio_shim.c +21 -0
- package/src/zig/native-renderable.zig +112 -0
- package/src/zig/native-span-feed-bench-lib.zig +7 -0
- package/src/zig/native-span-feed.zig +747 -0
- package/src/zig/renderer-output.zig +677 -0
- package/src/zig/renderer.zig +2106 -0
- package/src/zig/rope.zig +1220 -0
- package/src/zig/split-scrollback.zig +88 -0
- package/src/zig/syntax-style.zig +174 -0
- package/src/zig/terminal.zig +1652 -0
- package/src/zig/test.zig +82 -0
- package/src/zig/tests/README.md +18 -0
- package/src/zig/tests/ansi_test.zig +18 -0
- package/src/zig/tests/audio_test.zig +439 -0
- package/src/zig/tests/buffer-methods_test.zig +1111 -0
- package/src/zig/tests/buffer_test.zig +2926 -0
- package/src/zig/tests/edit-buffer-history_test.zig +299 -0
- package/src/zig/tests/edit-buffer_test.zig +1688 -0
- package/src/zig/tests/editor-view_test.zig +3454 -0
- package/src/zig/tests/event-emitter_test.zig +249 -0
- package/src/zig/tests/grapheme_test.zig +1329 -0
- package/src/zig/tests/handles_test.zig +123 -0
- package/src/zig/tests/link_test.zig +220 -0
- package/src/zig/tests/mem-registry_test.zig +473 -0
- package/src/zig/tests/memory_leak_regression_test.zig +234 -0
- package/src/zig/tests/native-renderable_test.zig +16 -0
- package/src/zig/tests/native-span-feed_test.zig +1266 -0
- package/src/zig/tests/renderer_test.zig +2604 -0
- package/src/zig/tests/rope-nested_test.zig +712 -0
- package/src/zig/tests/rope_fuzz_test.zig +238 -0
- package/src/zig/tests/rope_test.zig +2362 -0
- package/src/zig/tests/segment-merge.test.zig +148 -0
- package/src/zig/tests/split-scrollback_test.zig +70 -0
- package/src/zig/tests/syntax-style_test.zig +558 -0
- package/src/zig/tests/terminal_test.zig +1489 -0
- package/src/zig/tests/test-renderer.zig +126 -0
- package/src/zig/tests/text-buffer-drawing_test.zig +3291 -0
- package/src/zig/tests/text-buffer-highlights_test.zig +706 -0
- package/src/zig/tests/text-buffer-iterators_test.zig +776 -0
- package/src/zig/tests/text-buffer-segment_test.zig +320 -0
- package/src/zig/tests/text-buffer-selection_test.zig +1056 -0
- package/src/zig/tests/text-buffer-selection_viewport_test.zig +358 -0
- package/src/zig/tests/text-buffer-view_test.zig +3672 -0
- package/src/zig/tests/text-buffer_test.zig +2191 -0
- package/src/zig/tests/unicode-width-map.zon +3909 -0
- package/src/zig/tests/utf8_no_zwj_test.zig +260 -0
- package/src/zig/tests/utf8_test.zig +4060 -0
- package/src/zig/tests/utf8_wcwidth_cursor_test.zig +267 -0
- package/src/zig/tests/utf8_wcwidth_test.zig +357 -0
- package/src/zig/tests/word-wrap-editing_test.zig +498 -0
- package/src/zig/tests/wrap-cache-perf_test.zig +113 -0
- package/src/zig/tests/yoga_test.zig +65 -0
- package/src/zig/text-buffer-iterators.zig +496 -0
- package/src/zig/text-buffer-segment.zig +403 -0
- package/src/zig/text-buffer-view.zig +1428 -0
- package/src/zig/text-buffer.zig +1272 -0
- package/src/zig/utf8.zig +1954 -0
- package/src/zig/utils.zig +12 -0
- package/src/zig/uucode-stub.zig +76 -0
- package/src/zig/vendor/miniaudio/miniaudio.h +93468 -0
- package/src/zig/yoga.zig +658 -0
- package/src/zig-structs.ts +381 -0
- package/src/zig.ts +5260 -0
- package/tsconfig.build.json +17 -0
- package/tsconfig.json +27 -0
- package/tsconfig.node-test.json +138 -0
package/src/zig/yoga.zig
ADDED
|
@@ -0,0 +1,658 @@
|
|
|
1
|
+
const std = @import("std");
|
|
2
|
+
|
|
3
|
+
const c = @cImport({
|
|
4
|
+
@cInclude("yoga/Yoga.h");
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
pub const YGNodeRef = c.YGNodeRef;
|
|
8
|
+
pub const YGNodeConstRef = c.YGNodeConstRef;
|
|
9
|
+
pub const YGConfigRef = c.YGConfigRef;
|
|
10
|
+
pub const YGConfigConstRef = c.YGConfigConstRef;
|
|
11
|
+
|
|
12
|
+
pub const YogaEnumKind = enum(u32) {
|
|
13
|
+
direction = 0,
|
|
14
|
+
flex_direction = 1,
|
|
15
|
+
justify_content = 2,
|
|
16
|
+
align_content = 3,
|
|
17
|
+
align_items = 4,
|
|
18
|
+
align_self = 5,
|
|
19
|
+
position_type = 6,
|
|
20
|
+
flex_wrap = 7,
|
|
21
|
+
overflow = 8,
|
|
22
|
+
display = 9,
|
|
23
|
+
box_sizing = 10,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
pub const YogaFloatKind = enum(u32) {
|
|
27
|
+
flex = 0,
|
|
28
|
+
flex_grow = 1,
|
|
29
|
+
flex_shrink = 2,
|
|
30
|
+
aspect_ratio = 3,
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
pub const YogaValueKind = enum(u32) {
|
|
34
|
+
width = 0,
|
|
35
|
+
height = 1,
|
|
36
|
+
min_width = 2,
|
|
37
|
+
min_height = 3,
|
|
38
|
+
max_width = 4,
|
|
39
|
+
max_height = 5,
|
|
40
|
+
flex_basis = 6,
|
|
41
|
+
margin = 7,
|
|
42
|
+
padding = 8,
|
|
43
|
+
position = 9,
|
|
44
|
+
gap = 10,
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const YogaEdgeLayoutKind = enum(u32) {
|
|
48
|
+
margin = 0,
|
|
49
|
+
padding = 1,
|
|
50
|
+
border = 2,
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
pub const YogaUnit = enum(u32) {
|
|
54
|
+
undefined = 0,
|
|
55
|
+
point = 1,
|
|
56
|
+
percent = 2,
|
|
57
|
+
auto = 3,
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
pub const YogaDirection = enum(u32) {
|
|
61
|
+
inherit = 0,
|
|
62
|
+
ltr = 1,
|
|
63
|
+
rtl = 2,
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
pub const YogaMeasureMode = enum(u32) {
|
|
67
|
+
undefined = 0,
|
|
68
|
+
exactly = 1,
|
|
69
|
+
at_most = 2,
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
pub const YogaPositionType = enum(u32) {
|
|
73
|
+
static = 0,
|
|
74
|
+
relative = 1,
|
|
75
|
+
absolute = 2,
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
pub const YogaFlexDirection = enum(u32) {
|
|
79
|
+
column = 0,
|
|
80
|
+
column_reverse = 1,
|
|
81
|
+
row = 2,
|
|
82
|
+
row_reverse = 3,
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
pub const ExternalYogaLayout = extern struct {
|
|
86
|
+
left: f32,
|
|
87
|
+
top: f32,
|
|
88
|
+
right: f32,
|
|
89
|
+
bottom: f32,
|
|
90
|
+
width: f32,
|
|
91
|
+
height: f32,
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
pub const ExternalYogaSize = extern struct {
|
|
95
|
+
width: f32,
|
|
96
|
+
height: f32,
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const JsMeasureCallback = *const fn (?*anyopaque, f32, u32, f32, u32) callconv(.c) void;
|
|
100
|
+
const JsDirtiedCallback = *const fn (?*anyopaque) callconv(.c) void;
|
|
101
|
+
pub const NativeMeasureCallback = *const fn (?*anyopaque, f32, u32, f32, u32) callconv(.c) ExternalYogaSize;
|
|
102
|
+
var opentui_config: YGConfigRef = null;
|
|
103
|
+
var opentui_config_mutex: std.Thread.Mutex = .{};
|
|
104
|
+
var global_measure_callback: ?*const anyopaque = null;
|
|
105
|
+
var global_dirtied_callback: ?*const anyopaque = null;
|
|
106
|
+
|
|
107
|
+
const CallbackContext = struct {
|
|
108
|
+
native_measure_target: ?*anyopaque = null,
|
|
109
|
+
native_measure_callback: ?NativeMeasureCallback = null,
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
threadlocal var tls_measure_width: f32 = 0;
|
|
113
|
+
threadlocal var tls_measure_height: f32 = 0;
|
|
114
|
+
|
|
115
|
+
fn enumValue(value: anytype) u32 {
|
|
116
|
+
return @intCast(value);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
fn toAlign(value: u32) c.YGAlign {
|
|
120
|
+
return @intCast(value);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
fn toBoxSizing(value: u32) c.YGBoxSizing {
|
|
124
|
+
return @intCast(value);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
fn toDirection(value: u32) c.YGDirection {
|
|
128
|
+
return @intCast(value);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
fn toDisplay(value: u32) c.YGDisplay {
|
|
132
|
+
return @intCast(value);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
fn toEdge(value: u32) c.YGEdge {
|
|
136
|
+
return @intCast(value);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
fn toErrata(value: u32) c.YGErrata {
|
|
140
|
+
return @intCast(value);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
fn toExperimentalFeature(value: u32) c.YGExperimentalFeature {
|
|
144
|
+
return @intCast(value);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
fn toFlexDirection(value: u32) c.YGFlexDirection {
|
|
148
|
+
return @intCast(value);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
fn toGutter(value: u32) c.YGGutter {
|
|
152
|
+
return @intCast(value);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
fn toJustify(value: u32) c.YGJustify {
|
|
156
|
+
return @intCast(value);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
fn toOverflow(value: u32) c.YGOverflow {
|
|
160
|
+
return @intCast(value);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
fn toPositionType(value: u32) c.YGPositionType {
|
|
164
|
+
return @intCast(value);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
fn toWrap(value: u32) c.YGWrap {
|
|
168
|
+
return @intCast(value);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
fn undefinedValue() c.YGValue {
|
|
172
|
+
return .{ .value = std.math.nan(f32), .unit = c.YGUnitUndefined };
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
fn getOpenTUIConfig() YGConfigRef {
|
|
176
|
+
opentui_config_mutex.lock();
|
|
177
|
+
defer opentui_config_mutex.unlock();
|
|
178
|
+
|
|
179
|
+
if (opentui_config == null) {
|
|
180
|
+
const config = c.YGConfigNew();
|
|
181
|
+
c.YGConfigSetUseWebDefaults(config, false);
|
|
182
|
+
c.YGConfigSetPointScaleFactor(config, 1);
|
|
183
|
+
opentui_config = config;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
return opentui_config;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
fn pointValue(value: f32) c.YGValue {
|
|
190
|
+
return .{ .value = value, .unit = c.YGUnitPoint };
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
fn packValue(value: c.YGValue) u64 {
|
|
194
|
+
const unit_bits: u32 = enumValue(value.unit);
|
|
195
|
+
const value_bits: u32 = @bitCast(value.value);
|
|
196
|
+
return (@as(u64, value_bits) << 32) | @as(u64, unit_bits);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
fn getContext(node: YGNodeConstRef) ?*CallbackContext {
|
|
200
|
+
const existing = c.YGNodeGetContext(node);
|
|
201
|
+
if (existing) |ptr| {
|
|
202
|
+
return @ptrCast(@alignCast(ptr));
|
|
203
|
+
}
|
|
204
|
+
return null;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
fn getOrCreateContext(node: YGNodeRef) *CallbackContext {
|
|
208
|
+
if (getContext(node)) |ctx| {
|
|
209
|
+
return ctx;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
const ctx = std.heap.c_allocator.create(CallbackContext) catch @panic("failed to allocate Yoga callback context");
|
|
213
|
+
ctx.* = .{};
|
|
214
|
+
c.YGNodeSetContext(node, ctx);
|
|
215
|
+
return ctx;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
fn freeContext(node: YGNodeRef) void {
|
|
219
|
+
const existing = c.YGNodeGetContext(node);
|
|
220
|
+
if (existing) |ptr| {
|
|
221
|
+
const ctx: *CallbackContext = @ptrCast(@alignCast(ptr));
|
|
222
|
+
std.heap.c_allocator.destroy(ctx);
|
|
223
|
+
c.YGNodeSetContext(node, null);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
fn freeContextRecursive(node: YGNodeRef) void {
|
|
228
|
+
const child_count = c.YGNodeGetChildCount(node);
|
|
229
|
+
var index: usize = 0;
|
|
230
|
+
while (index < child_count) : (index += 1) {
|
|
231
|
+
const child = c.YGNodeGetChild(node, index);
|
|
232
|
+
freeContextRecursive(child);
|
|
233
|
+
}
|
|
234
|
+
freeContext(node);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
fn internalMeasureFunc(
|
|
238
|
+
node: YGNodeConstRef,
|
|
239
|
+
width: f32,
|
|
240
|
+
width_mode: c.YGMeasureMode,
|
|
241
|
+
height: f32,
|
|
242
|
+
height_mode: c.YGMeasureMode,
|
|
243
|
+
) callconv(.c) c.YGSize {
|
|
244
|
+
// JS-measured nodes use the shared JS callback router. Native-backed
|
|
245
|
+
// renderables use internalNativeMeasureFunc to avoid a JS round trip.
|
|
246
|
+
tls_measure_width = std.math.nan(f32);
|
|
247
|
+
tls_measure_height = std.math.nan(f32);
|
|
248
|
+
|
|
249
|
+
if (global_measure_callback) |callback| {
|
|
250
|
+
const trampoline: JsMeasureCallback = @ptrCast(@alignCast(callback));
|
|
251
|
+
trampoline(@ptrCast(@constCast(node)), width, enumValue(width_mode), height, enumValue(height_mode));
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
return .{ .width = tls_measure_width, .height = tls_measure_height };
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
fn internalNativeMeasureFunc(
|
|
258
|
+
node: YGNodeConstRef,
|
|
259
|
+
width: f32,
|
|
260
|
+
width_mode: c.YGMeasureMode,
|
|
261
|
+
height: f32,
|
|
262
|
+
height_mode: c.YGMeasureMode,
|
|
263
|
+
) callconv(.c) c.YGSize {
|
|
264
|
+
// Hot native renderables measure entirely in Zig: Yoga -> native renderable
|
|
265
|
+
// -> native text/editor view. This is separate from the JS callback path.
|
|
266
|
+
if (getContext(node)) |ctx| {
|
|
267
|
+
if (ctx.native_measure_callback) |callback| {
|
|
268
|
+
const size = callback(
|
|
269
|
+
ctx.native_measure_target,
|
|
270
|
+
width,
|
|
271
|
+
enumValue(width_mode),
|
|
272
|
+
height,
|
|
273
|
+
enumValue(height_mode),
|
|
274
|
+
);
|
|
275
|
+
return .{ .width = size.width, .height = size.height };
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
return .{ .width = std.math.nan(f32), .height = std.math.nan(f32) };
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
fn internalDirtiedFunc(node: YGNodeConstRef) callconv(.c) void {
|
|
283
|
+
if (global_dirtied_callback) |callback| {
|
|
284
|
+
const trampoline: JsDirtiedCallback = @ptrCast(@alignCast(callback));
|
|
285
|
+
trampoline(@ptrCast(@constCast(node)));
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
pub export fn yogaConfigCreate() YGConfigRef {
|
|
290
|
+
return c.YGConfigNew();
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
pub export fn yogaConfigFree(config: YGConfigRef) void {
|
|
294
|
+
c.YGConfigFree(config);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
export fn yogaConfigSetUseWebDefaults(config: YGConfigRef, enabled: bool) void {
|
|
298
|
+
c.YGConfigSetUseWebDefaults(config, enabled);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
pub export fn yogaConfigGetUseWebDefaults(config: YGConfigConstRef) bool {
|
|
302
|
+
return c.YGConfigGetUseWebDefaults(config);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
export fn yogaConfigSetPointScaleFactor(config: YGConfigRef, point_scale_factor: f32) void {
|
|
306
|
+
c.YGConfigSetPointScaleFactor(config, point_scale_factor);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
pub export fn yogaConfigGetPointScaleFactor(config: YGConfigConstRef) f32 {
|
|
310
|
+
return c.YGConfigGetPointScaleFactor(config);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
export fn yogaConfigSetErrata(config: YGConfigRef, errata: u32) void {
|
|
314
|
+
c.YGConfigSetErrata(config, toErrata(errata));
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
export fn yogaConfigGetErrata(config: YGConfigConstRef) u32 {
|
|
318
|
+
return enumValue(c.YGConfigGetErrata(config));
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
export fn yogaConfigSetExperimentalFeatureEnabled(config: YGConfigRef, feature: u32, enabled: bool) void {
|
|
322
|
+
c.YGConfigSetExperimentalFeatureEnabled(config, toExperimentalFeature(feature), enabled);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
export fn yogaConfigIsExperimentalFeatureEnabled(config: YGConfigConstRef, feature: u32) bool {
|
|
326
|
+
return c.YGConfigIsExperimentalFeatureEnabled(config, toExperimentalFeature(feature));
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
pub export fn yogaNodeCreate() YGNodeRef {
|
|
330
|
+
return c.YGNodeNew();
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
pub export fn yogaNodeCreateForOpenTUI() YGNodeRef {
|
|
334
|
+
return c.YGNodeNewWithConfig(getOpenTUIConfig());
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
pub export fn yogaNodeCreateWithConfig(config: YGConfigConstRef) YGNodeRef {
|
|
338
|
+
return c.YGNodeNewWithConfig(config);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
pub export fn yogaNodeFree(node: YGNodeRef) void {
|
|
342
|
+
freeContext(node);
|
|
343
|
+
c.YGNodeFree(node);
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
export fn yogaNodeFreeRecursive(node: YGNodeRef) void {
|
|
347
|
+
freeContextRecursive(node);
|
|
348
|
+
c.YGNodeFreeRecursive(node);
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
export fn yogaNodeReset(node: YGNodeRef) void {
|
|
352
|
+
freeContext(node);
|
|
353
|
+
c.YGNodeReset(node);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
export fn yogaNodeCopyStyle(dst_node: YGNodeRef, src_node: YGNodeConstRef) void {
|
|
357
|
+
c.YGNodeCopyStyle(dst_node, src_node);
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
pub export fn yogaNodeInsertChild(node: YGNodeRef, child: YGNodeRef, index: u32) void {
|
|
361
|
+
c.YGNodeInsertChild(node, child, index);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
export fn yogaNodeRemoveChild(node: YGNodeRef, child: YGNodeRef) void {
|
|
365
|
+
c.YGNodeRemoveChild(node, child);
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
export fn yogaNodeRemoveAllChildren(node: YGNodeRef) void {
|
|
369
|
+
c.YGNodeRemoveAllChildren(node);
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
export fn yogaNodeGetChild(node: YGNodeRef, index: u32) YGNodeRef {
|
|
373
|
+
return c.YGNodeGetChild(node, index);
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
export fn yogaNodeGetChildCount(node: YGNodeConstRef) u32 {
|
|
377
|
+
return @intCast(c.YGNodeGetChildCount(node));
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
export fn yogaNodeGetParent(node: YGNodeRef) YGNodeRef {
|
|
381
|
+
return c.YGNodeGetParent(node);
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
pub export fn yogaNodeCalculateLayout(node: YGNodeRef, width: f32, height: f32, direction: u32) void {
|
|
385
|
+
c.YGNodeCalculateLayout(node, width, height, toDirection(direction));
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
export fn yogaNodeIsDirty(node: YGNodeConstRef) bool {
|
|
389
|
+
return c.YGNodeIsDirty(node);
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
export fn yogaNodeMarkDirty(node: YGNodeRef) void {
|
|
393
|
+
c.YGNodeMarkDirty(node);
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
export fn yogaNodeGetHasNewLayout(node: YGNodeConstRef) bool {
|
|
397
|
+
return c.YGNodeGetHasNewLayout(node);
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
export fn yogaNodeSetHasNewLayout(node: YGNodeRef, has_new_layout: bool) void {
|
|
401
|
+
c.YGNodeSetHasNewLayout(node, has_new_layout);
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
export fn yogaNodeSetIsReferenceBaseline(node: YGNodeRef, is_reference_baseline: bool) void {
|
|
405
|
+
c.YGNodeSetIsReferenceBaseline(node, is_reference_baseline);
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
export fn yogaNodeIsReferenceBaseline(node: YGNodeConstRef) bool {
|
|
409
|
+
return c.YGNodeIsReferenceBaseline(node);
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
export fn yogaNodeSetAlwaysFormsContainingBlock(node: YGNodeRef, always_forms_containing_block: bool) void {
|
|
413
|
+
c.YGNodeSetAlwaysFormsContainingBlock(node, always_forms_containing_block);
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
export fn yogaNodeGetAlwaysFormsContainingBlock(node: YGNodeConstRef) bool {
|
|
417
|
+
return c.YGNodeGetAlwaysFormsContainingBlock(node);
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
pub export fn yogaNodeGetComputedLayout(node: YGNodeConstRef, out_ptr: *ExternalYogaLayout) void {
|
|
421
|
+
out_ptr.* = .{
|
|
422
|
+
.left = c.YGNodeLayoutGetLeft(node),
|
|
423
|
+
.top = c.YGNodeLayoutGetTop(node),
|
|
424
|
+
.right = c.YGNodeLayoutGetRight(node),
|
|
425
|
+
.bottom = c.YGNodeLayoutGetBottom(node),
|
|
426
|
+
.width = c.YGNodeLayoutGetWidth(node),
|
|
427
|
+
.height = c.YGNodeLayoutGetHeight(node),
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
export fn yogaNodeLayoutGetEdge(node: YGNodeConstRef, kind: u32, edge: u32) f32 {
|
|
432
|
+
const edge_value = toEdge(edge);
|
|
433
|
+
return switch (@as(YogaEdgeLayoutKind, @enumFromInt(kind))) {
|
|
434
|
+
.margin => c.YGNodeLayoutGetMargin(node, edge_value),
|
|
435
|
+
.padding => c.YGNodeLayoutGetPadding(node, edge_value),
|
|
436
|
+
.border => c.YGNodeLayoutGetBorder(node, edge_value),
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
pub export fn yogaNodeStyleSetEnum(node: YGNodeRef, kind: u32, value: u32) void {
|
|
441
|
+
switch (@as(YogaEnumKind, @enumFromInt(kind))) {
|
|
442
|
+
.direction => c.YGNodeStyleSetDirection(node, toDirection(value)),
|
|
443
|
+
.flex_direction => c.YGNodeStyleSetFlexDirection(node, toFlexDirection(value)),
|
|
444
|
+
.justify_content => c.YGNodeStyleSetJustifyContent(node, toJustify(value)),
|
|
445
|
+
.align_content => c.YGNodeStyleSetAlignContent(node, toAlign(value)),
|
|
446
|
+
.align_items => c.YGNodeStyleSetAlignItems(node, toAlign(value)),
|
|
447
|
+
.align_self => c.YGNodeStyleSetAlignSelf(node, toAlign(value)),
|
|
448
|
+
.position_type => c.YGNodeStyleSetPositionType(node, toPositionType(value)),
|
|
449
|
+
.flex_wrap => c.YGNodeStyleSetFlexWrap(node, toWrap(value)),
|
|
450
|
+
.overflow => c.YGNodeStyleSetOverflow(node, toOverflow(value)),
|
|
451
|
+
.display => c.YGNodeStyleSetDisplay(node, toDisplay(value)),
|
|
452
|
+
.box_sizing => c.YGNodeStyleSetBoxSizing(node, toBoxSizing(value)),
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
pub export fn yogaNodeStyleGetEnum(node: YGNodeConstRef, kind: u32) u32 {
|
|
457
|
+
return switch (@as(YogaEnumKind, @enumFromInt(kind))) {
|
|
458
|
+
.direction => enumValue(c.YGNodeStyleGetDirection(node)),
|
|
459
|
+
.flex_direction => enumValue(c.YGNodeStyleGetFlexDirection(node)),
|
|
460
|
+
.justify_content => enumValue(c.YGNodeStyleGetJustifyContent(node)),
|
|
461
|
+
.align_content => enumValue(c.YGNodeStyleGetAlignContent(node)),
|
|
462
|
+
.align_items => enumValue(c.YGNodeStyleGetAlignItems(node)),
|
|
463
|
+
.align_self => enumValue(c.YGNodeStyleGetAlignSelf(node)),
|
|
464
|
+
.position_type => enumValue(c.YGNodeStyleGetPositionType(node)),
|
|
465
|
+
.flex_wrap => enumValue(c.YGNodeStyleGetFlexWrap(node)),
|
|
466
|
+
.overflow => enumValue(c.YGNodeStyleGetOverflow(node)),
|
|
467
|
+
.display => enumValue(c.YGNodeStyleGetDisplay(node)),
|
|
468
|
+
.box_sizing => enumValue(c.YGNodeStyleGetBoxSizing(node)),
|
|
469
|
+
};
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
pub export fn yogaNodeStyleSetFloat(node: YGNodeRef, kind: u32, value: f32) void {
|
|
473
|
+
switch (@as(YogaFloatKind, @enumFromInt(kind))) {
|
|
474
|
+
.flex => c.YGNodeStyleSetFlex(node, value),
|
|
475
|
+
.flex_grow => c.YGNodeStyleSetFlexGrow(node, value),
|
|
476
|
+
.flex_shrink => c.YGNodeStyleSetFlexShrink(node, value),
|
|
477
|
+
.aspect_ratio => c.YGNodeStyleSetAspectRatio(node, value),
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
export fn yogaNodeStyleGetFloat(node: YGNodeConstRef, kind: u32) f32 {
|
|
482
|
+
return switch (@as(YogaFloatKind, @enumFromInt(kind))) {
|
|
483
|
+
.flex => c.YGNodeStyleGetFlex(node),
|
|
484
|
+
.flex_grow => c.YGNodeStyleGetFlexGrow(node),
|
|
485
|
+
.flex_shrink => c.YGNodeStyleGetFlexShrink(node),
|
|
486
|
+
.aspect_ratio => c.YGNodeStyleGetAspectRatio(node),
|
|
487
|
+
};
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
export fn yogaNodeStyleSetBorder(node: YGNodeRef, edge: u32, border: f32) void {
|
|
491
|
+
c.YGNodeStyleSetBorder(node, toEdge(edge), border);
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
export fn yogaNodeStyleGetBorder(node: YGNodeConstRef, edge: u32) f32 {
|
|
495
|
+
return c.YGNodeStyleGetBorder(node, toEdge(edge));
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
pub export fn yogaNodeStyleSetValue(node: YGNodeRef, kind: u32, edge_or_gutter: u32, unit: u32, value: f32) void {
|
|
499
|
+
const value_kind = @as(YogaValueKind, @enumFromInt(kind));
|
|
500
|
+
const value_unit = @as(YogaUnit, @enumFromInt(unit));
|
|
501
|
+
const undefined_value = std.math.nan(f32);
|
|
502
|
+
|
|
503
|
+
switch (value_kind) {
|
|
504
|
+
.width => switch (value_unit) {
|
|
505
|
+
.point => c.YGNodeStyleSetWidth(node, value),
|
|
506
|
+
.percent => c.YGNodeStyleSetWidthPercent(node, value),
|
|
507
|
+
.auto => c.YGNodeStyleSetWidthAuto(node),
|
|
508
|
+
.undefined => c.YGNodeStyleSetWidth(node, undefined_value),
|
|
509
|
+
},
|
|
510
|
+
.height => switch (value_unit) {
|
|
511
|
+
.point => c.YGNodeStyleSetHeight(node, value),
|
|
512
|
+
.percent => c.YGNodeStyleSetHeightPercent(node, value),
|
|
513
|
+
.auto => c.YGNodeStyleSetHeightAuto(node),
|
|
514
|
+
.undefined => c.YGNodeStyleSetHeight(node, undefined_value),
|
|
515
|
+
},
|
|
516
|
+
.min_width => switch (value_unit) {
|
|
517
|
+
.point => c.YGNodeStyleSetMinWidth(node, value),
|
|
518
|
+
.percent => c.YGNodeStyleSetMinWidthPercent(node, value),
|
|
519
|
+
.undefined => c.YGNodeStyleSetMinWidth(node, undefined_value),
|
|
520
|
+
.auto => {},
|
|
521
|
+
},
|
|
522
|
+
.min_height => switch (value_unit) {
|
|
523
|
+
.point => c.YGNodeStyleSetMinHeight(node, value),
|
|
524
|
+
.percent => c.YGNodeStyleSetMinHeightPercent(node, value),
|
|
525
|
+
.undefined => c.YGNodeStyleSetMinHeight(node, undefined_value),
|
|
526
|
+
.auto => {},
|
|
527
|
+
},
|
|
528
|
+
.max_width => switch (value_unit) {
|
|
529
|
+
.point => c.YGNodeStyleSetMaxWidth(node, value),
|
|
530
|
+
.percent => c.YGNodeStyleSetMaxWidthPercent(node, value),
|
|
531
|
+
.undefined => c.YGNodeStyleSetMaxWidth(node, undefined_value),
|
|
532
|
+
.auto => {},
|
|
533
|
+
},
|
|
534
|
+
.max_height => switch (value_unit) {
|
|
535
|
+
.point => c.YGNodeStyleSetMaxHeight(node, value),
|
|
536
|
+
.percent => c.YGNodeStyleSetMaxHeightPercent(node, value),
|
|
537
|
+
.undefined => c.YGNodeStyleSetMaxHeight(node, undefined_value),
|
|
538
|
+
.auto => {},
|
|
539
|
+
},
|
|
540
|
+
.flex_basis => switch (value_unit) {
|
|
541
|
+
.point => c.YGNodeStyleSetFlexBasis(node, value),
|
|
542
|
+
.percent => c.YGNodeStyleSetFlexBasisPercent(node, value),
|
|
543
|
+
.auto => c.YGNodeStyleSetFlexBasisAuto(node),
|
|
544
|
+
.undefined => c.YGNodeStyleSetFlexBasis(node, undefined_value),
|
|
545
|
+
},
|
|
546
|
+
.margin => switch (value_unit) {
|
|
547
|
+
.point => c.YGNodeStyleSetMargin(node, toEdge(edge_or_gutter), value),
|
|
548
|
+
.percent => c.YGNodeStyleSetMarginPercent(node, toEdge(edge_or_gutter), value),
|
|
549
|
+
.auto => c.YGNodeStyleSetMarginAuto(node, toEdge(edge_or_gutter)),
|
|
550
|
+
.undefined => c.YGNodeStyleSetMargin(node, toEdge(edge_or_gutter), undefined_value),
|
|
551
|
+
},
|
|
552
|
+
.padding => switch (value_unit) {
|
|
553
|
+
.point => c.YGNodeStyleSetPadding(node, toEdge(edge_or_gutter), value),
|
|
554
|
+
.percent => c.YGNodeStyleSetPaddingPercent(node, toEdge(edge_or_gutter), value),
|
|
555
|
+
.undefined => c.YGNodeStyleSetPadding(node, toEdge(edge_or_gutter), undefined_value),
|
|
556
|
+
.auto => {},
|
|
557
|
+
},
|
|
558
|
+
.position => switch (value_unit) {
|
|
559
|
+
.point => c.YGNodeStyleSetPosition(node, toEdge(edge_or_gutter), value),
|
|
560
|
+
.percent => c.YGNodeStyleSetPositionPercent(node, toEdge(edge_or_gutter), value),
|
|
561
|
+
.auto => c.YGNodeStyleSetPositionAuto(node, toEdge(edge_or_gutter)),
|
|
562
|
+
.undefined => c.YGNodeStyleSetPosition(node, toEdge(edge_or_gutter), undefined_value),
|
|
563
|
+
},
|
|
564
|
+
.gap => switch (value_unit) {
|
|
565
|
+
.point => c.YGNodeStyleSetGap(node, toGutter(edge_or_gutter), value),
|
|
566
|
+
.percent => c.YGNodeStyleSetGapPercent(node, toGutter(edge_or_gutter), value),
|
|
567
|
+
.undefined => c.YGNodeStyleSetGap(node, toGutter(edge_or_gutter), undefined_value),
|
|
568
|
+
.auto => {},
|
|
569
|
+
},
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
pub export fn yogaNodeStyleGetValue(node: YGNodeConstRef, kind: u32, edge_or_gutter: u32) u64 {
|
|
574
|
+
const value = switch (@as(YogaValueKind, @enumFromInt(kind))) {
|
|
575
|
+
.width => c.YGNodeStyleGetWidth(node),
|
|
576
|
+
.height => c.YGNodeStyleGetHeight(node),
|
|
577
|
+
.min_width => c.YGNodeStyleGetMinWidth(node),
|
|
578
|
+
.min_height => c.YGNodeStyleGetMinHeight(node),
|
|
579
|
+
.max_width => c.YGNodeStyleGetMaxWidth(node),
|
|
580
|
+
.max_height => c.YGNodeStyleGetMaxHeight(node),
|
|
581
|
+
.flex_basis => c.YGNodeStyleGetFlexBasis(node),
|
|
582
|
+
.margin => c.YGNodeStyleGetMargin(node, toEdge(edge_or_gutter)),
|
|
583
|
+
.padding => c.YGNodeStyleGetPadding(node, toEdge(edge_or_gutter)),
|
|
584
|
+
.position => c.YGNodeStyleGetPosition(node, toEdge(edge_or_gutter)),
|
|
585
|
+
.gap => blk: {
|
|
586
|
+
const gap = c.YGNodeStyleGetGap(node, toGutter(edge_or_gutter));
|
|
587
|
+
break :blk if (std.math.isNan(gap)) undefinedValue() else pointValue(gap);
|
|
588
|
+
},
|
|
589
|
+
};
|
|
590
|
+
return packValue(value);
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
pub export fn yogaSetMeasureCallback(callback: ?*const anyopaque) void {
|
|
594
|
+
global_measure_callback = callback;
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
pub export fn yogaSetDirtiedCallback(callback: ?*const anyopaque) void {
|
|
598
|
+
global_dirtied_callback = callback;
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
pub export fn yogaNodeSetMeasureFunc(node: YGNodeRef, enabled: bool) void {
|
|
602
|
+
if (enabled) {
|
|
603
|
+
c.YGNodeSetMeasureFunc(node, &internalMeasureFunc);
|
|
604
|
+
return;
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
yogaNodeUnsetMeasureFunc(node);
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
pub fn yogaNodeSetNativeMeasureFunc(node: YGNodeRef, target: ?*anyopaque, callback: ?NativeMeasureCallback) void {
|
|
611
|
+
if (target != null and callback != null) {
|
|
612
|
+
const ctx = getOrCreateContext(node);
|
|
613
|
+
ctx.native_measure_target = target;
|
|
614
|
+
ctx.native_measure_callback = callback;
|
|
615
|
+
c.YGNodeSetMeasureFunc(node, &internalNativeMeasureFunc);
|
|
616
|
+
return;
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
if (getContext(node)) |ctx| {
|
|
620
|
+
ctx.native_measure_target = null;
|
|
621
|
+
ctx.native_measure_callback = null;
|
|
622
|
+
}
|
|
623
|
+
c.YGNodeSetMeasureFunc(node, null);
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
export fn yogaNodeUnsetMeasureFunc(node: YGNodeRef) void {
|
|
627
|
+
c.YGNodeSetMeasureFunc(node, null);
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
export fn yogaNodeHasMeasureFunc(node: YGNodeConstRef) bool {
|
|
631
|
+
return c.YGNodeHasMeasureFunc(node);
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
pub export fn yogaNodeSetDirtiedFunc(node: YGNodeRef, enabled: bool) void {
|
|
635
|
+
if (enabled) {
|
|
636
|
+
c.YGNodeSetDirtiedFunc(node, &internalDirtiedFunc);
|
|
637
|
+
return;
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
yogaNodeUnsetDirtiedFunc(node);
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
export fn yogaNodeUnsetDirtiedFunc(node: YGNodeRef) void {
|
|
644
|
+
c.YGNodeSetDirtiedFunc(node, null);
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
export fn yogaStoreMeasureResult(width: f32, height: f32) void {
|
|
648
|
+
tls_measure_width = width;
|
|
649
|
+
tls_measure_height = height;
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
pub fn yogaNodeGetConfig(node: YGNodeRef) YGConfigConstRef {
|
|
653
|
+
return c.YGNodeGetConfig(node);
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
pub fn yogaNodeHasContext(node: YGNodeConstRef) bool {
|
|
657
|
+
return c.YGNodeGetContext(node) != null;
|
|
658
|
+
}
|