@xincli/opentui-core 0.4.6 → 0.4.7
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/LICENSE +21 -0
- package/NativeSpanFeed.d.ts +52 -0
- package/README.md +0 -0
- package/Renderable.d.ts +346 -0
- package/animation/Timeline.d.ts +126 -0
- package/ansi.d.ts +17 -0
- package/audio.d.ts +89 -0
- package/buffer.d.ts +113 -0
- package/console.d.ts +146 -0
- package/edit-buffer.d.ts +97 -0
- package/editor-view.d.ts +72 -0
- package/index-m1y9e40w.js +10045 -0
- package/index-m1y9e40w.js.map +32 -0
- package/index-sqk4ajdf.js +16121 -0
- package/index-sqk4ajdf.js.map +58 -0
- package/index.d.ts +24 -0
- package/index.js +11709 -0
- package/index.js.map +35 -0
- package/lib/KeyHandler.d.ts +61 -0
- package/lib/RGBA.d.ts +42 -0
- package/lib/ascii.font.d.ts +508 -0
- package/lib/border.d.ts +51 -0
- package/lib/bunfs.d.ts +7 -0
- package/lib/clipboard.d.ts +15 -0
- package/lib/clock.d.ts +15 -0
- package/lib/data-paths.d.ts +26 -0
- package/lib/debounce.d.ts +42 -0
- package/lib/detect-links.d.ts +6 -0
- package/lib/env.d.ts +42 -0
- package/lib/extmarks-history.d.ts +17 -0
- package/lib/extmarks.d.ts +90 -0
- package/lib/hast-styled-text.d.ts +17 -0
- package/lib/index.d.ts +22 -0
- package/lib/keybinding.internal.d.ts +33 -0
- package/lib/objects-in-viewport.d.ts +24 -0
- package/lib/output.capture.d.ts +24 -0
- package/lib/parse.keypress-kitty.d.ts +3 -0
- package/lib/parse.keypress.d.ts +27 -0
- package/lib/parse.mouse.d.ts +30 -0
- package/lib/paste.d.ts +7 -0
- package/lib/queue.d.ts +15 -0
- package/lib/render-geometry.d.ts +8 -0
- package/lib/renderable.validations.d.ts +12 -0
- package/lib/scroll-acceleration.d.ts +43 -0
- package/lib/selection.d.ts +64 -0
- package/lib/singleton.d.ts +8 -0
- package/lib/stdin-parser.d.ts +90 -0
- package/lib/styled-text.d.ts +63 -0
- package/lib/terminal-capability-detection.d.ts +32 -0
- package/lib/terminal-palette.d.ts +65 -0
- package/lib/tree-sitter/assets/update.d.ts +12 -0
- package/lib/tree-sitter/client.d.ts +65 -0
- package/lib/tree-sitter/default-parsers.d.ts +2 -0
- package/lib/tree-sitter/download-utils.d.ts +21 -0
- package/lib/tree-sitter/index.d.ts +7 -0
- package/lib/tree-sitter/parser.worker.d.ts +1 -0
- package/lib/tree-sitter/parsers-config.d.ts +53 -0
- package/lib/tree-sitter/resolve-ft.d.ts +5 -0
- package/lib/tree-sitter/types.d.ts +185 -0
- package/lib/tree-sitter/update-assets.d.ts +3 -0
- package/lib/tree-sitter/update-assets.js +379 -0
- package/lib/tree-sitter/update-assets.js.map +12 -0
- package/lib/tree-sitter-styled-text.d.ts +16 -0
- package/lib/validate-dir-name.d.ts +1 -0
- package/lib/yoga.options.d.ts +32 -0
- package/native-event-worker-repro.worker.d.ts +1 -0
- package/package.json +52 -74
- package/parser.worker.js +1399 -0
- package/parser.worker.js.map +20 -0
- package/platform/ffi.d.ts +129 -0
- package/platform/runtime.d.ts +14 -0
- package/platform/test.d.ts +12 -0
- package/platform/worker.d.ts +26 -0
- package/platform/worker.node-test.d.ts +1 -0
- package/plugins/core-slot.d.ts +72 -0
- package/plugins/registry.d.ts +42 -0
- package/plugins/types.d.ts +34 -0
- package/post/effects.d.ts +147 -0
- package/post/filters.d.ts +65 -0
- package/post/matrices.d.ts +20 -0
- package/renderables/ASCIIFont.d.ts +52 -0
- package/renderables/Box.d.ts +85 -0
- package/renderables/Code.d.ts +97 -0
- package/renderables/Diff.d.ts +147 -0
- package/renderables/EditBufferRenderable.d.ts +238 -0
- package/renderables/FrameBuffer.d.ts +16 -0
- package/renderables/Input.d.ts +72 -0
- package/renderables/LineNumberRenderable.d.ts +78 -0
- package/renderables/Markdown.d.ts +255 -0
- package/renderables/ScrollBar.d.ts +77 -0
- package/renderables/ScrollBox.d.ts +128 -0
- package/renderables/Select.d.ts +122 -0
- package/renderables/Slider.d.ts +47 -0
- package/renderables/TabSelect.d.ts +98 -0
- package/renderables/Text.d.ts +36 -0
- package/renderables/TextBufferRenderable.d.ts +107 -0
- package/renderables/TextNode.d.ts +92 -0
- package/renderables/TextTable.d.ts +154 -0
- package/renderables/Textarea.d.ts +65 -0
- package/renderables/TimeToFirstDraw.d.ts +24 -0
- package/renderables/__tests__/renderable-test-utils.d.ts +12 -0
- package/renderables/composition/VRenderable.d.ts +16 -0
- package/renderables/composition/constructs.d.ts +35 -0
- package/renderables/composition/vnode.d.ts +46 -0
- package/renderables/index.d.ts +23 -0
- package/renderables/markdown-parser.d.ts +11 -0
- package/renderer-theme-mode.d.ts +29 -0
- package/renderer.d.ts +601 -0
- package/runtime-plugin-support-configure.d.ts +4 -0
- package/runtime-plugin-support-configure.js +36 -0
- package/runtime-plugin-support-configure.js.map +1 -0
- package/runtime-plugin-support-configure.node.js +15 -0
- package/runtime-plugin-support.d.ts +3 -0
- package/runtime-plugin-support.js +5 -0
- package/runtime-plugin-support.js.map +1 -0
- package/runtime-plugin-support.node.js +15 -0
- package/runtime-plugin.d.ts +16 -0
- package/runtime-plugin.js +473 -0
- package/runtime-plugin.js.map +1 -0
- package/runtime-plugin.node.js +15 -0
- package/syntax-style.d.ts +61 -0
- package/testing/bun-test-node.d.ts +87 -0
- package/testing/manual-clock.d.ts +17 -0
- package/testing/mock-keys.d.ts +81 -0
- package/testing/mock-mouse.d.ts +38 -0
- package/testing/mock-tree-sitter-client.d.ts +27 -0
- package/testing/spy.d.ts +7 -0
- package/testing/terminal-capabilities.d.ts +7 -0
- package/testing/test-recorder.d.ts +61 -0
- package/testing/test-renderer.d.ts +54 -0
- package/testing/test-streams.d.ts +12 -0
- package/testing.d.ts +8 -0
- package/testing.js +1004 -0
- package/testing.js.map +18 -0
- package/tests/yoga-upstream/tools/MeasureCounter.d.ts +16 -0
- package/tests/yoga-upstream/tools/utils.d.ts +11 -0
- package/text-buffer-view.d.ts +42 -0
- package/text-buffer.d.ts +66 -0
- package/types.d.ts +175 -0
- package/utils.d.ts +14 -0
- package/yoga.d.ts +437 -0
- package/yoga.js +193 -0
- package/yoga.js.map +9 -0
- package/zig-structs.d.ts +256 -0
- package/zig.d.ts +496 -0
- package/dev/keypress-debug-renderer.ts +0 -148
- package/dev/keypress-debug.ts +0 -43
- package/dev/print-env-vars.ts +0 -32
- package/dev/test-tmux-graphics-334.sh +0 -68
- package/dev/test-tmux-theme-queries.sh +0 -151
- package/dev/thai-debug-test.ts +0 -68
- package/dev/theme-mode.ts +0 -290
- package/docs/development.md +0 -144
- package/prebuilt/aarch64-android/libopentui.so +0 -0
- package/scripts/build-android.ts +0 -226
- package/scripts/build-native-termux.sh +0 -525
- package/scripts/build.ts +0 -530
- package/scripts/dist-test.ts +0 -312
- package/scripts/package-prebuilt.ts +0 -110
- package/scripts/publish.ts +0 -60
- package/scripts/test-node-hook.mjs +0 -16
- package/scripts/test-node.ts +0 -241
- package/scripts/vendor-deps.sh +0 -73
- package/src/NativeSpanFeed.ts +0 -375
- package/src/Renderable.ts +0 -1878
- package/src/__snapshots__/buffer.test.ts.snap +0 -28
- package/src/animation/Timeline.test.ts +0 -2709
- package/src/animation/Timeline.ts +0 -598
- package/src/ansi.ts +0 -22
- package/src/audio.ts +0 -479
- package/src/benchmark/attenuation-benchmark.ts +0 -81
- package/src/benchmark/audio-playback-benchmark.ts +0 -344
- package/src/benchmark/box-draw-benchmark.ts +0 -1042
- package/src/benchmark/colormatrix-benchmark.ts +0 -123
- package/src/benchmark/gain-benchmark.ts +0 -80
- package/src/benchmark/latest-all-bench-run.json +0 -707
- package/src/benchmark/latest-async-bench-run.json +0 -336
- package/src/benchmark/latest-default-bench-run.json +0 -657
- package/src/benchmark/latest-large-bench-run.json +0 -707
- package/src/benchmark/latest-quick-bench-run.json +0 -207
- package/src/benchmark/layout-benchmark.ts +0 -2547
- package/src/benchmark/markdown-benchmark.ts +0 -1796
- package/src/benchmark/native-span-feed-async-benchmark.ts +0 -355
- package/src/benchmark/native-span-feed-benchmark.md +0 -56
- package/src/benchmark/native-span-feed-benchmark.ts +0 -596
- package/src/benchmark/native-span-feed-compare.ts +0 -280
- package/src/benchmark/render-traversal-benchmark.ts +0 -928
- package/src/benchmark/text-buffer-render-benchmark.ts +0 -874
- package/src/benchmark/text-table-benchmark.ts +0 -948
- package/src/buffer.test.ts +0 -292
- package/src/buffer.ts +0 -564
- package/src/console.test.ts +0 -629
- package/src/console.ts +0 -1253
- package/src/edit-buffer.test.ts +0 -1852
- package/src/edit-buffer.ts +0 -417
- package/src/editor-view.test.ts +0 -1056
- package/src/editor-view.ts +0 -290
- package/src/index.ts +0 -25
- package/src/lib/KeyHandler.integration.test.ts +0 -292
- package/src/lib/KeyHandler.stopPropagation.test.ts +0 -289
- package/src/lib/KeyHandler.test.ts +0 -662
- package/src/lib/KeyHandler.ts +0 -222
- package/src/lib/RGBA.test.ts +0 -60
- package/src/lib/RGBA.ts +0 -343
- package/src/lib/ascii.font.ts +0 -330
- package/src/lib/border.test.ts +0 -83
- package/src/lib/border.ts +0 -170
- package/src/lib/bunfs.test.ts +0 -27
- package/src/lib/bunfs.ts +0 -18
- package/src/lib/clipboard.test.ts +0 -63
- package/src/lib/clipboard.ts +0 -41
- package/src/lib/clock.ts +0 -35
- package/src/lib/data-paths.test.ts +0 -133
- package/src/lib/data-paths.ts +0 -109
- package/src/lib/debounce.ts +0 -106
- package/src/lib/detect-links.test.ts +0 -98
- package/src/lib/detect-links.ts +0 -56
- package/src/lib/env.test.ts +0 -228
- package/src/lib/env.ts +0 -209
- package/src/lib/extmarks-history.ts +0 -51
- package/src/lib/extmarks-multiwidth.test.ts +0 -324
- package/src/lib/extmarks.test.ts +0 -3547
- package/src/lib/extmarks.ts +0 -861
- package/src/lib/fonts/block.json +0 -405
- package/src/lib/fonts/grid.json +0 -265
- package/src/lib/fonts/huge.json +0 -741
- package/src/lib/fonts/pallet.json +0 -314
- package/src/lib/fonts/shade.json +0 -591
- package/src/lib/fonts/slick.json +0 -321
- package/src/lib/fonts/tiny.json +0 -69
- package/src/lib/hast-styled-text.ts +0 -59
- package/src/lib/index.ts +0 -22
- package/src/lib/keybinding.internal.test.ts +0 -342
- package/src/lib/keybinding.internal.ts +0 -182
- package/src/lib/objects-in-viewport.test.ts +0 -789
- package/src/lib/objects-in-viewport.ts +0 -153
- package/src/lib/output.capture.ts +0 -58
- package/src/lib/parse.keypress-kitty.protocol.test.ts +0 -347
- package/src/lib/parse.keypress-kitty.test.ts +0 -712
- package/src/lib/parse.keypress-kitty.ts +0 -470
- package/src/lib/parse.keypress.test.ts +0 -2020
- package/src/lib/parse.keypress.ts +0 -480
- package/src/lib/parse.mouse.test.ts +0 -552
- package/src/lib/parse.mouse.ts +0 -232
- package/src/lib/paste.ts +0 -18
- package/src/lib/queue.ts +0 -65
- package/src/lib/render-geometry.ts +0 -36
- package/src/lib/renderable.validations.test.ts +0 -87
- package/src/lib/renderable.validations.ts +0 -83
- package/src/lib/scroll-acceleration.ts +0 -98
- package/src/lib/selection.ts +0 -261
- package/src/lib/singleton.ts +0 -34
- package/src/lib/stdin-parser.test.ts +0 -2439
- package/src/lib/stdin-parser.ts +0 -2007
- package/src/lib/styled-text.ts +0 -178
- package/src/lib/terminal-capability-detection.test.ts +0 -226
- package/src/lib/terminal-capability-detection.ts +0 -98
- package/src/lib/terminal-palette.test.ts +0 -954
- package/src/lib/terminal-palette.ts +0 -441
- package/src/lib/tree-sitter/assets/README.md +0 -119
- package/src/lib/tree-sitter/assets/update.ts +0 -360
- package/src/lib/tree-sitter/assets.d.ts +0 -9
- package/src/lib/tree-sitter/cache.test.ts +0 -291
- package/src/lib/tree-sitter/client.test.ts +0 -1434
- package/src/lib/tree-sitter/client.ts +0 -847
- package/src/lib/tree-sitter/default-parsers.ts +0 -133
- package/src/lib/tree-sitter/download-utils.ts +0 -148
- package/src/lib/tree-sitter/index.ts +0 -75
- package/src/lib/tree-sitter/parser.worker.ts +0 -1098
- package/src/lib/tree-sitter/parsers-config.ts +0 -81
- package/src/lib/tree-sitter/resolve-ft.test.ts +0 -55
- package/src/lib/tree-sitter/resolve-ft.ts +0 -189
- package/src/lib/tree-sitter/types.ts +0 -132
- package/src/lib/tree-sitter/update-assets.ts +0 -10
- package/src/lib/tree-sitter-styled-text.test.ts +0 -1253
- package/src/lib/tree-sitter-styled-text.ts +0 -314
- package/src/lib/validate-dir-name.ts +0 -55
- package/src/lib/yoga.options.test.ts +0 -628
- package/src/lib/yoga.options.ts +0 -346
- package/src/native-event-worker-repro.test.ts +0 -48
- package/src/native-event-worker-repro.worker.ts +0 -9
- package/src/native-handle.test.ts +0 -221
- package/src/platform/ffi.test.ts +0 -516
- package/src/platform/ffi.ts +0 -653
- package/src/platform/runtime.test.ts +0 -52
- package/src/platform/runtime.ts +0 -121
- package/src/platform/test.ts +0 -45
- package/src/platform/worker-handler-cleanup.fixture.ts +0 -12
- package/src/platform/worker-onmessage-startup.fixture.ts +0 -10
- package/src/platform/worker-startup.fixture.ts +0 -9
- package/src/platform/worker.node-test.ts +0 -153
- package/src/platform/worker.ts +0 -425
- package/src/plugins/core-slot.ts +0 -579
- package/src/plugins/registry.ts +0 -402
- package/src/plugins/types.ts +0 -46
- package/src/post/effects.ts +0 -948
- package/src/post/filters.ts +0 -512
- package/src/post/matrices.ts +0 -288
- package/src/renderables/ASCIIFont.ts +0 -219
- package/src/renderables/Box.test.ts +0 -474
- package/src/renderables/Box.ts +0 -353
- package/src/renderables/Code.test.ts +0 -2388
- package/src/renderables/Code.ts +0 -555
- package/src/renderables/Diff.regression.test.ts +0 -381
- package/src/renderables/Diff.test.ts +0 -3212
- package/src/renderables/Diff.ts +0 -1278
- package/src/renderables/EditBufferRenderable.test.ts +0 -288
- package/src/renderables/EditBufferRenderable.ts +0 -1152
- package/src/renderables/FrameBuffer.ts +0 -47
- package/src/renderables/Input.test.ts +0 -1310
- package/src/renderables/Input.ts +0 -273
- package/src/renderables/LineNumberRenderable.ts +0 -725
- package/src/renderables/Markdown.ts +0 -2144
- package/src/renderables/ScrollBar.ts +0 -423
- package/src/renderables/ScrollBox.ts +0 -903
- package/src/renderables/Select.test.ts +0 -1134
- package/src/renderables/Select.ts +0 -535
- package/src/renderables/Slider.test.ts +0 -456
- package/src/renderables/Slider.ts +0 -342
- package/src/renderables/TabSelect.test.ts +0 -238
- package/src/renderables/TabSelect.ts +0 -447
- package/src/renderables/Text.selection-buffer.test.ts +0 -118
- package/src/renderables/Text.test.ts +0 -2662
- package/src/renderables/Text.ts +0 -147
- package/src/renderables/TextBufferRenderable.ts +0 -504
- package/src/renderables/TextNode.test.ts +0 -1137
- package/src/renderables/TextNode.ts +0 -379
- package/src/renderables/TextTable.test.ts +0 -1411
- package/src/renderables/TextTable.ts +0 -1434
- package/src/renderables/Textarea.ts +0 -425
- package/src/renderables/TimeToFirstDraw.ts +0 -89
- package/src/renderables/__snapshots__/Code.test.ts.snap +0 -13
- package/src/renderables/__snapshots__/Diff.test.ts.snap +0 -785
- package/src/renderables/__snapshots__/Text.test.ts.snap +0 -421
- package/src/renderables/__snapshots__/TextTable.test.ts.snap +0 -215
- package/src/renderables/__tests__/Code.test.ts +0 -55
- package/src/renderables/__tests__/LineNumberRenderable.scrollbox-simple.test.ts +0 -144
- package/src/renderables/__tests__/LineNumberRenderable.scrollbox.test.ts +0 -827
- package/src/renderables/__tests__/LineNumberRenderable.test.ts +0 -1906
- package/src/renderables/__tests__/LineNumberRenderable.wrapping.test.ts +0 -85
- package/src/renderables/__tests__/Markdown.code-colors.test.ts +0 -288
- package/src/renderables/__tests__/Markdown.test.ts +0 -4175
- package/src/renderables/__tests__/MultiRenderable.selection.test.ts +0 -87
- package/src/renderables/__tests__/Textarea.buffer.test.ts +0 -683
- package/src/renderables/__tests__/Textarea.destroyed-events.test.ts +0 -675
- package/src/renderables/__tests__/Textarea.editing.test.ts +0 -2120
- package/src/renderables/__tests__/Textarea.error-handling.test.ts +0 -35
- package/src/renderables/__tests__/Textarea.events.test.ts +0 -738
- package/src/renderables/__tests__/Textarea.highlights.test.ts +0 -590
- package/src/renderables/__tests__/Textarea.keybinding.test.ts +0 -3275
- package/src/renderables/__tests__/Textarea.paste.test.ts +0 -357
- package/src/renderables/__tests__/Textarea.rendering.test.ts +0 -1927
- package/src/renderables/__tests__/Textarea.scroll.test.ts +0 -733
- package/src/renderables/__tests__/Textarea.selection.test.ts +0 -1589
- package/src/renderables/__tests__/Textarea.stress.test.ts +0 -670
- package/src/renderables/__tests__/Textarea.undo-redo.test.ts +0 -383
- package/src/renderables/__tests__/Textarea.visual-lines.test.ts +0 -310
- package/src/renderables/__tests__/__snapshots__/LineNumberRenderable.code.test.ts.snap +0 -221
- package/src/renderables/__tests__/__snapshots__/LineNumberRenderable.scrollbox-simple.test.ts.snap +0 -89
- package/src/renderables/__tests__/__snapshots__/LineNumberRenderable.scrollbox.test.ts.snap +0 -457
- package/src/renderables/__tests__/__snapshots__/LineNumberRenderable.test.ts.snap +0 -158
- package/src/renderables/__tests__/__snapshots__/Textarea.rendering.test.ts.snap +0 -387
- package/src/renderables/__tests__/markdown-parser.test.ts +0 -241
- package/src/renderables/__tests__/renderable-test-utils.ts +0 -60
- package/src/renderables/composition/README.md +0 -8
- package/src/renderables/composition/VRenderable.ts +0 -32
- package/src/renderables/composition/constructs.ts +0 -127
- package/src/renderables/composition/vnode.ts +0 -277
- package/src/renderables/index.ts +0 -23
- package/src/renderables/markdown-parser.ts +0 -79
- package/src/renderer-theme-mode.ts +0 -199
- package/src/renderer.ts +0 -4975
- package/src/runtime-plugin-support-configure.ts +0 -63
- package/src/runtime-plugin-support.ts +0 -13
- package/src/runtime-plugin.ts +0 -626
- package/src/specs/terminal-startup.md +0 -64
- package/src/syntax-style.test.ts +0 -841
- package/src/syntax-style.ts +0 -274
- package/src/testing/README.md +0 -219
- package/src/testing/bun-test-node.ts +0 -880
- package/src/testing/capture-spans.test.ts +0 -216
- package/src/testing/integration.test.ts +0 -276
- package/src/testing/manual-clock.ts +0 -117
- package/src/testing/mock-keys.test.ts +0 -1378
- package/src/testing/mock-keys.ts +0 -457
- package/src/testing/mock-mouse.test.ts +0 -218
- package/src/testing/mock-mouse.ts +0 -247
- package/src/testing/mock-tree-sitter-client.ts +0 -81
- package/src/testing/spy.ts +0 -13
- package/src/testing/terminal-capabilities.ts +0 -47
- package/src/testing/test-recorder.test.ts +0 -410
- package/src/testing/test-recorder.ts +0 -133
- package/src/testing/test-renderer.ts +0 -375
- package/src/testing/test-renderer.wait.test.ts +0 -278
- package/src/testing/test-streams.ts +0 -31
- package/src/testing.ts +0 -9
- package/src/tests/__snapshots__/absolute-positioning.snapshot.test.ts.snap +0 -481
- package/src/tests/__snapshots__/renderable.snapshot.test.ts.snap +0 -19
- package/src/tests/__snapshots__/scrollbox.test.ts.snap +0 -29
- package/src/tests/absolute-positioning.snapshot.test.ts +0 -638
- package/src/tests/allocator-stats.test.ts +0 -53
- package/src/tests/audio.test.ts +0 -303
- package/src/tests/destroy-during-render.test.ts +0 -200
- package/src/tests/destroy-on-exit.fixture.ts +0 -36
- package/src/tests/destroy-on-exit.test.ts +0 -62
- package/src/tests/ffi-borrowed-pointer-callsites.test.ts +0 -153
- package/src/tests/hover-cursor.test.ts +0 -98
- package/src/tests/native-backed-measurement-lifecycle.test.ts +0 -133
- package/src/tests/native-backed-measurement-parity.test.ts +0 -322
- package/src/tests/native-span-feed-async.test.ts +0 -173
- package/src/tests/native-span-feed-close.test.ts +0 -120
- package/src/tests/native-span-feed-coverage.test.ts +0 -227
- package/src/tests/native-span-feed-edge-cases.test.ts +0 -384
- package/src/tests/native-span-feed-use-after-free.test.ts +0 -45
- package/src/tests/opacity.test.ts +0 -123
- package/src/tests/renderable.snapshot.test.ts +0 -524
- package/src/tests/renderable.test.ts +0 -1851
- package/src/tests/renderer.clock.test.ts +0 -270
- package/src/tests/renderer.console-startup.test.ts +0 -2151
- package/src/tests/renderer.control.test.ts +0 -458
- package/src/tests/renderer.core-slot-binding.test.ts +0 -962
- package/src/tests/renderer.cursor.test.ts +0 -26
- package/src/tests/renderer.custom-stdout.test.ts +0 -1112
- package/src/tests/renderer.destroy-during-render.test.ts +0 -147
- package/src/tests/renderer.focus-restore.test.ts +0 -257
- package/src/tests/renderer.focus.test.ts +0 -329
- package/src/tests/renderer.idle.test.ts +0 -219
- package/src/tests/renderer.input.test.ts +0 -2615
- package/src/tests/renderer.kitty-flags.test.ts +0 -195
- package/src/tests/renderer.lifecycle.test.ts +0 -34
- package/src/tests/renderer.mouse.test.ts +0 -1315
- package/src/tests/renderer.notifications.test.ts +0 -27
- package/src/tests/renderer.palette.test.ts +0 -1199
- package/src/tests/renderer.remote.test.ts +0 -247
- package/src/tests/renderer.render-stats.test.ts +0 -146
- package/src/tests/renderer.scrollback-surface.test.ts +0 -474
- package/src/tests/renderer.selection.test.ts +0 -138
- package/src/tests/renderer.slot-registry.test.ts +0 -684
- package/src/tests/renderer.tracker.test.ts +0 -202
- package/src/tests/renderer.useMouse.test.ts +0 -83
- package/src/tests/runtime-plugin-node-modules-cycle.fixture.ts +0 -76
- package/src/tests/runtime-plugin-node-modules-import-like-string.fixture.ts +0 -48
- package/src/tests/runtime-plugin-node-modules-mjs.fixture.ts +0 -43
- package/src/tests/runtime-plugin-node-modules-no-bare-rewrite.fixture.ts +0 -67
- package/src/tests/runtime-plugin-node-modules-package-type-cache.fixture.ts +0 -72
- package/src/tests/runtime-plugin-node-modules-runtime-specifier.fixture.ts +0 -44
- package/src/tests/runtime-plugin-node-modules-scoped-package-bare-rewrite.fixture.ts +0 -85
- package/src/tests/runtime-plugin-path-alias.fixture.ts +0 -43
- package/src/tests/runtime-plugin-resolve-roots.fixture.ts +0 -65
- package/src/tests/runtime-plugin-support-configure.fixture.ts +0 -31
- package/src/tests/runtime-plugin-support-late-addition.fixture.ts +0 -17
- package/src/tests/runtime-plugin-support.fixture.ts +0 -11
- package/src/tests/runtime-plugin-support.test.ts +0 -54
- package/src/tests/runtime-plugin-windows-file-url.fixture.ts +0 -30
- package/src/tests/runtime-plugin.fixture.ts +0 -40
- package/src/tests/runtime-plugin.test.ts +0 -369
- package/src/tests/scrollbox-culling-bug.test.ts +0 -114
- package/src/tests/scrollbox-hitgrid-resize.test.ts +0 -136
- package/src/tests/scrollbox-hitgrid.test.ts +0 -909
- package/src/tests/scrollbox.test.ts +0 -1895
- package/src/tests/wrap-resize-perf.test.ts +0 -276
- package/src/tests/yoga-api-coverage.test.ts +0 -409
- package/src/tests/yoga-callback-stress.test.ts +0 -122
- package/src/tests/yoga-ffi.test.ts +0 -117
- package/src/tests/yoga-setters.test.ts +0 -921
- package/src/tests/yoga-upstream/YGAlignBaselineTest.test.ts +0 -124
- package/src/tests/yoga-upstream/YGComputedBorderTest.test.ts +0 -27
- package/src/tests/yoga-upstream/YGComputedMarginTest.test.ts +0 -27
- package/src/tests/yoga-upstream/YGComputedPaddingTest.test.ts +0 -27
- package/src/tests/yoga-upstream/YGDirtiedTest.test.ts +0 -157
- package/src/tests/yoga-upstream/YGErrataTest.test.ts +0 -40
- package/src/tests/yoga-upstream/YGFlexBasisAuto.test.ts +0 -23
- package/src/tests/yoga-upstream/YGHasNewLayout.test.ts +0 -81
- package/src/tests/yoga-upstream/YGMeasureCacheTest.test.ts +0 -31
- package/src/tests/yoga-upstream/YGMeasureTest.test.ts +0 -70
- package/src/tests/yoga-upstream/generated/YGAbsolutePositionTest.test.ts +0 -1864
- package/src/tests/yoga-upstream/generated/YGAlignContentTest.test.ts +0 -5829
- package/src/tests/yoga-upstream/generated/YGAlignItemsTest.test.ts +0 -2444
- package/src/tests/yoga-upstream/generated/YGAlignSelfTest.test.ts +0 -293
- package/src/tests/yoga-upstream/generated/YGAndroidNewsFeed.test.ts +0 -315
- package/src/tests/yoga-upstream/generated/YGAspectRatioTest.test.ts +0 -231
- package/src/tests/yoga-upstream/generated/YGAutoTest.test.ts +0 -347
- package/src/tests/yoga-upstream/generated/YGBorderTest.test.ts +0 -256
- package/src/tests/yoga-upstream/generated/YGBoxSizingTest.test.ts +0 -2747
- package/src/tests/yoga-upstream/generated/YGDimensionTest.test.ts +0 -129
- package/src/tests/yoga-upstream/generated/YGDisplayContentsTest.test.ts +0 -109
- package/src/tests/yoga-upstream/generated/YGDisplayTest.test.ts +0 -1097
- package/src/tests/yoga-upstream/generated/YGFlexDirectionTest.test.ts +0 -4562
- package/src/tests/yoga-upstream/generated/YGFlexTest.test.ts +0 -677
- package/src/tests/yoga-upstream/generated/YGFlexWrapTest.test.ts +0 -2071
- package/src/tests/yoga-upstream/generated/YGGapTest.test.ts +0 -3303
- package/src/tests/yoga-upstream/generated/YGIntrinsicSizeTest.test.ts +0 -582
- package/src/tests/yoga-upstream/generated/YGJustifyContentTest.test.ts +0 -2150
- package/src/tests/yoga-upstream/generated/YGMarginTest.test.ts +0 -1963
- package/src/tests/yoga-upstream/generated/YGMinMaxDimensionTest.test.ts +0 -1446
- package/src/tests/yoga-upstream/generated/YGPaddingTest.test.ts +0 -354
- package/src/tests/yoga-upstream/generated/YGPercentageTest.test.ts +0 -1760
- package/src/tests/yoga-upstream/generated/YGRoundingTest.test.ts +0 -1161
- package/src/tests/yoga-upstream/generated/YGSizeOverflowTest.test.ts +0 -207
- package/src/tests/yoga-upstream/generated/YGStaticPositionTest.test.ts +0 -6338
- package/src/tests/yoga-upstream/tools/MeasureCounter.ts +0 -54
- package/src/tests/yoga-upstream/tools/utils.ts +0 -81
- package/src/text-buffer-view.test.ts +0 -722
- package/src/text-buffer-view.ts +0 -193
- package/src/text-buffer.test.ts +0 -512
- package/src/text-buffer.ts +0 -250
- package/src/types.ts +0 -199
- package/src/utils.ts +0 -88
- package/src/yoga.ts +0 -1146
- package/src/zig/ansi.zig +0 -502
- package/src/zig/audio.zig +0 -1206
- package/src/zig/bench/README.md +0 -50
- package/src/zig/bench/buffer-color-blending_bench.zig +0 -350
- package/src/zig/bench/buffer-draw-box_bench.zig +0 -786
- package/src/zig/bench/buffer-draw-text-buffer_bench.zig +0 -894
- package/src/zig/bench/edit-buffer_bench.zig +0 -476
- package/src/zig/bench/editor-view_bench.zig +0 -169
- package/src/zig/bench/native-span-feed_bench.zig +0 -107
- package/src/zig/bench/rope-markers_bench.zig +0 -713
- package/src/zig/bench/rope_bench.zig +0 -514
- package/src/zig/bench/styled-text_bench.zig +0 -476
- package/src/zig/bench/text-buffer-coords_bench.zig +0 -362
- package/src/zig/bench/text-buffer-view_bench.zig +0 -459
- package/src/zig/bench/text-chunk-graphemes_bench.zig +0 -272
- package/src/zig/bench/utf8_bench.zig +0 -799
- package/src/zig/bench-utils.zig +0 -431
- package/src/zig/bench.zig +0 -223
- package/src/zig/buffer-methods.zig +0 -215
- package/src/zig/buffer.zig +0 -2515
- package/src/zig/build.zig +0 -700
- package/src/zig/build.zig.zon +0 -19
- package/src/zig/edit-buffer.zig +0 -900
- package/src/zig/editor-view.zig +0 -812
- package/src/zig/event-bus.zig +0 -28
- package/src/zig/event-emitter.zig +0 -65
- package/src/zig/file-logger.zig +0 -92
- package/src/zig/grapheme.zig +0 -838
- package/src/zig/handles.zig +0 -267
- package/src/zig/lib.zig +0 -2813
- package/src/zig/link.zig +0 -349
- package/src/zig/logger.zig +0 -43
- package/src/zig/mem-registry.zig +0 -126
- package/src/zig/miniaudio_shim.c +0 -21
- package/src/zig/native-renderable.zig +0 -112
- package/src/zig/native-span-feed-bench-lib.zig +0 -7
- package/src/zig/native-span-feed.zig +0 -747
- package/src/zig/renderer-output.zig +0 -677
- package/src/zig/renderer.zig +0 -2106
- package/src/zig/rope.zig +0 -1220
- package/src/zig/split-scrollback.zig +0 -88
- package/src/zig/syntax-style.zig +0 -174
- package/src/zig/terminal.zig +0 -1652
- package/src/zig/test.zig +0 -82
- package/src/zig/tests/README.md +0 -18
- package/src/zig/tests/ansi_test.zig +0 -18
- package/src/zig/tests/audio_test.zig +0 -439
- package/src/zig/tests/buffer-methods_test.zig +0 -1111
- package/src/zig/tests/buffer_test.zig +0 -2926
- package/src/zig/tests/edit-buffer-history_test.zig +0 -299
- package/src/zig/tests/edit-buffer_test.zig +0 -1688
- package/src/zig/tests/editor-view_test.zig +0 -3454
- package/src/zig/tests/event-emitter_test.zig +0 -249
- package/src/zig/tests/grapheme_test.zig +0 -1329
- package/src/zig/tests/handles_test.zig +0 -123
- package/src/zig/tests/link_test.zig +0 -220
- package/src/zig/tests/mem-registry_test.zig +0 -473
- package/src/zig/tests/memory_leak_regression_test.zig +0 -234
- package/src/zig/tests/native-renderable_test.zig +0 -16
- package/src/zig/tests/native-span-feed_test.zig +0 -1266
- package/src/zig/tests/renderer_test.zig +0 -2604
- package/src/zig/tests/rope-nested_test.zig +0 -712
- package/src/zig/tests/rope_fuzz_test.zig +0 -238
- package/src/zig/tests/rope_test.zig +0 -2362
- package/src/zig/tests/segment-merge.test.zig +0 -148
- package/src/zig/tests/split-scrollback_test.zig +0 -70
- package/src/zig/tests/syntax-style_test.zig +0 -558
- package/src/zig/tests/terminal_test.zig +0 -1489
- package/src/zig/tests/test-renderer.zig +0 -126
- package/src/zig/tests/text-buffer-drawing_test.zig +0 -3291
- package/src/zig/tests/text-buffer-highlights_test.zig +0 -706
- package/src/zig/tests/text-buffer-iterators_test.zig +0 -776
- package/src/zig/tests/text-buffer-segment_test.zig +0 -320
- package/src/zig/tests/text-buffer-selection_test.zig +0 -1056
- package/src/zig/tests/text-buffer-selection_viewport_test.zig +0 -358
- package/src/zig/tests/text-buffer-view_test.zig +0 -3672
- package/src/zig/tests/text-buffer_test.zig +0 -2191
- package/src/zig/tests/unicode-width-map.zon +0 -3909
- package/src/zig/tests/utf8_no_zwj_test.zig +0 -260
- package/src/zig/tests/utf8_test.zig +0 -4060
- package/src/zig/tests/utf8_wcwidth_cursor_test.zig +0 -267
- package/src/zig/tests/utf8_wcwidth_test.zig +0 -357
- package/src/zig/tests/word-wrap-editing_test.zig +0 -498
- package/src/zig/tests/wrap-cache-perf_test.zig +0 -113
- package/src/zig/tests/yoga_test.zig +0 -65
- package/src/zig/text-buffer-iterators.zig +0 -496
- package/src/zig/text-buffer-segment.zig +0 -403
- package/src/zig/text-buffer-view.zig +0 -1428
- package/src/zig/text-buffer.zig +0 -1272
- package/src/zig/utf8.zig +0 -1954
- package/src/zig/utils.zig +0 -12
- package/src/zig/uucode-stub.zig +0 -76
- package/src/zig/vendor/miniaudio/miniaudio.h +0 -93468
- package/src/zig/yoga.zig +0 -658
- package/src/zig-structs.ts +0 -381
- package/src/zig.ts +0 -5260
- package/tsconfig.build.json +0 -17
- package/tsconfig.json +0 -27
- package/tsconfig.node-test.json +0 -138
- /package/{src/lib/tree-sitter/assets → assets}/javascript/highlights.scm +0 -0
- /package/{src/lib/tree-sitter/assets → assets}/javascript/tree-sitter-javascript.wasm +0 -0
- /package/{src/lib/tree-sitter/assets → assets}/markdown/highlights.scm +0 -0
- /package/{src/lib/tree-sitter/assets → assets}/markdown/injections.scm +0 -0
- /package/{src/lib/tree-sitter/assets → assets}/markdown/tree-sitter-markdown.wasm +0 -0
- /package/{src/lib/tree-sitter/assets → assets}/markdown_inline/highlights.scm +0 -0
- /package/{src/lib/tree-sitter/assets → assets}/markdown_inline/tree-sitter-markdown_inline.wasm +0 -0
- /package/{src/lib/tree-sitter/assets → assets}/typescript/highlights.scm +0 -0
- /package/{src/lib/tree-sitter/assets → assets}/typescript/tree-sitter-typescript.wasm +0 -0
- /package/{src/lib/tree-sitter/assets → assets}/zig/highlights.scm +0 -0
- /package/{src/lib/tree-sitter/assets → assets}/zig/tree-sitter-zig.wasm +0 -0
|
@@ -1,1152 +0,0 @@
|
|
|
1
|
-
import { Renderable, type RenderableOptions } from "../Renderable.js"
|
|
2
|
-
import { convertGlobalToLocalSelection, Selection, type LocalSelectionBounds } from "../lib/selection.js"
|
|
3
|
-
import { EditBuffer, type LogicalCursor } from "../edit-buffer.js"
|
|
4
|
-
import { EditorView, type VisualCursor } from "../editor-view.js"
|
|
5
|
-
import { RGBA, parseColor } from "../lib/RGBA.js"
|
|
6
|
-
import type { RenderContext, Highlight, CursorStyleOptions, LineInfoProvider, LineInfo } from "../types.js"
|
|
7
|
-
import type { OptimizedBuffer } from "../buffer.js"
|
|
8
|
-
import type { SyntaxStyle } from "../syntax-style.js"
|
|
9
|
-
import { NativeMeasureTargetKind, resolveRenderLib, type NativeRenderableHandle } from "../zig.js"
|
|
10
|
-
|
|
11
|
-
const BrandedEditBufferRenderable: unique symbol = Symbol.for("@opentui/core/EditBufferRenderable")
|
|
12
|
-
|
|
13
|
-
export type EditorCapture = "escape" | "navigate" | "submit" | "tab"
|
|
14
|
-
|
|
15
|
-
export interface EditorTraits {
|
|
16
|
-
capture?: readonly EditorCapture[]
|
|
17
|
-
suspend?: boolean
|
|
18
|
-
status?: string
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export enum EditBufferRenderableEvents {
|
|
22
|
-
TRAITS_CHANGED = "traits-changed",
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function sameCapture(a?: readonly EditorCapture[], b?: readonly EditorCapture[]) {
|
|
26
|
-
if (a === b) return true
|
|
27
|
-
if (!a || !b) return !a && !b
|
|
28
|
-
if (a.length !== b.length) return false
|
|
29
|
-
return a.every((item, i) => item === b[i])
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function sameTraits(a: EditorTraits, b: EditorTraits) {
|
|
33
|
-
return a.suspend === b.suspend && a.status === b.status && sameCapture(a.capture, b.capture)
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export function isEditBufferRenderable(obj: unknown): obj is EditBufferRenderable {
|
|
37
|
-
return !!(obj && typeof obj === "object" && BrandedEditBufferRenderable in obj)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export interface CursorChangeEvent {
|
|
41
|
-
line: number
|
|
42
|
-
visualColumn: number
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export interface ContentChangeEvent {
|
|
46
|
-
// No payload - use getText() to retrieve content if needed
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export interface EditBufferOptions extends RenderableOptions<EditBufferRenderable> {
|
|
50
|
-
textColor?: string | RGBA
|
|
51
|
-
backgroundColor?: string | RGBA
|
|
52
|
-
selectionBg?: string | RGBA
|
|
53
|
-
selectionFg?: string | RGBA
|
|
54
|
-
selectable?: boolean
|
|
55
|
-
attributes?: number
|
|
56
|
-
wrapMode?: "none" | "char" | "word"
|
|
57
|
-
scrollMargin?: number
|
|
58
|
-
scrollSpeed?: number
|
|
59
|
-
showCursor?: boolean
|
|
60
|
-
cursorColor?: string | RGBA
|
|
61
|
-
cursorStyle?: CursorStyleOptions
|
|
62
|
-
syntaxStyle?: SyntaxStyle
|
|
63
|
-
tabIndicator?: string | number
|
|
64
|
-
tabIndicatorColor?: string | RGBA
|
|
65
|
-
onCursorChange?: (event: CursorChangeEvent) => void
|
|
66
|
-
onContentChange?: (event: ContentChangeEvent) => void
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export abstract class EditBufferRenderable extends Renderable implements LineInfoProvider {
|
|
70
|
-
[BrandedEditBufferRenderable] = true
|
|
71
|
-
protected _focusable: boolean = true
|
|
72
|
-
public selectable: boolean = true
|
|
73
|
-
private _traits: EditorTraits = {}
|
|
74
|
-
|
|
75
|
-
protected _textColor: RGBA
|
|
76
|
-
protected _backgroundColor: RGBA
|
|
77
|
-
protected _defaultAttributes: number
|
|
78
|
-
protected _selectionBg: RGBA | undefined
|
|
79
|
-
protected _selectionFg: RGBA | undefined
|
|
80
|
-
protected _wrapMode: "none" | "char" | "word" = "word"
|
|
81
|
-
protected _scrollMargin: number = 0.2
|
|
82
|
-
protected _showCursor: boolean = true
|
|
83
|
-
protected _cursorColor: RGBA
|
|
84
|
-
protected _cursorStyle: CursorStyleOptions
|
|
85
|
-
protected lastLocalSelection: LocalSelectionBounds | null = null
|
|
86
|
-
protected _tabIndicator?: string | number
|
|
87
|
-
protected _tabIndicatorColor?: RGBA
|
|
88
|
-
|
|
89
|
-
private _cursorChangeListener: ((event: CursorChangeEvent) => void) | undefined = undefined
|
|
90
|
-
private _contentChangeListener: ((event: ContentChangeEvent) => void) | undefined = undefined
|
|
91
|
-
|
|
92
|
-
private _autoScrollVelocity: number = 0
|
|
93
|
-
private _autoScrollAccumulator: number = 0
|
|
94
|
-
private _scrollSpeed: number = 16
|
|
95
|
-
private _keyboardSelectionActive: boolean = false
|
|
96
|
-
|
|
97
|
-
public readonly editBuffer: EditBuffer
|
|
98
|
-
public readonly editorView: EditorView
|
|
99
|
-
private nativeRenderable: NativeRenderableHandle | null = null
|
|
100
|
-
|
|
101
|
-
protected _defaultOptions = {
|
|
102
|
-
textColor: RGBA.fromValues(1, 1, 1, 1),
|
|
103
|
-
backgroundColor: "transparent",
|
|
104
|
-
selectionBg: undefined,
|
|
105
|
-
selectionFg: undefined,
|
|
106
|
-
selectable: true,
|
|
107
|
-
attributes: 0,
|
|
108
|
-
wrapMode: "word" as "none" | "char" | "word",
|
|
109
|
-
scrollMargin: 0.2,
|
|
110
|
-
scrollSpeed: 16,
|
|
111
|
-
showCursor: true,
|
|
112
|
-
cursorColor: RGBA.fromValues(1, 1, 1, 1),
|
|
113
|
-
cursorStyle: {
|
|
114
|
-
style: "block",
|
|
115
|
-
blinking: true,
|
|
116
|
-
},
|
|
117
|
-
tabIndicator: undefined,
|
|
118
|
-
tabIndicatorColor: undefined,
|
|
119
|
-
} satisfies Partial<EditBufferOptions>
|
|
120
|
-
|
|
121
|
-
constructor(ctx: RenderContext, options: EditBufferOptions) {
|
|
122
|
-
super(ctx, options)
|
|
123
|
-
|
|
124
|
-
this._textColor = parseColor(options.textColor ?? this._defaultOptions.textColor)
|
|
125
|
-
this._backgroundColor = parseColor(options.backgroundColor ?? this._defaultOptions.backgroundColor)
|
|
126
|
-
this._defaultAttributes = options.attributes ?? this._defaultOptions.attributes
|
|
127
|
-
this._selectionBg = options.selectionBg ? parseColor(options.selectionBg) : this._defaultOptions.selectionBg
|
|
128
|
-
this._selectionFg = options.selectionFg ? parseColor(options.selectionFg) : this._defaultOptions.selectionFg
|
|
129
|
-
this.selectable = options.selectable ?? this._defaultOptions.selectable
|
|
130
|
-
this._wrapMode = options.wrapMode ?? this._defaultOptions.wrapMode
|
|
131
|
-
this._scrollMargin = options.scrollMargin ?? this._defaultOptions.scrollMargin
|
|
132
|
-
this._scrollSpeed = options.scrollSpeed ?? this._defaultOptions.scrollSpeed
|
|
133
|
-
this._showCursor = options.showCursor ?? this._defaultOptions.showCursor
|
|
134
|
-
this._cursorColor = parseColor(options.cursorColor ?? this._defaultOptions.cursorColor)
|
|
135
|
-
this._cursorStyle = options.cursorStyle ?? this._defaultOptions.cursorStyle
|
|
136
|
-
this._tabIndicator = options.tabIndicator ?? this._defaultOptions.tabIndicator
|
|
137
|
-
this._tabIndicatorColor = options.tabIndicatorColor
|
|
138
|
-
? parseColor(options.tabIndicatorColor)
|
|
139
|
-
: this._defaultOptions.tabIndicatorColor
|
|
140
|
-
|
|
141
|
-
this.editBuffer = EditBuffer.create(this._ctx.widthMethod)
|
|
142
|
-
this.editorView = EditorView.create(this.editBuffer, this.width || 80, this.height || 24)
|
|
143
|
-
|
|
144
|
-
this.editorView.setWrapMode(this._wrapMode)
|
|
145
|
-
this.editorView.setScrollMargin(this._scrollMargin)
|
|
146
|
-
|
|
147
|
-
this.editBuffer.setDefaultFg(this._textColor)
|
|
148
|
-
this.editBuffer.setDefaultBg(this._backgroundColor)
|
|
149
|
-
this.editBuffer.setDefaultAttributes(this._defaultAttributes)
|
|
150
|
-
|
|
151
|
-
if (options.syntaxStyle) {
|
|
152
|
-
this.editBuffer.setSyntaxStyle(options.syntaxStyle)
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
if (this._tabIndicator !== undefined) {
|
|
156
|
-
this.editorView.setTabIndicator(this._tabIndicator)
|
|
157
|
-
}
|
|
158
|
-
if (this._tabIndicatorColor !== undefined) {
|
|
159
|
-
this.editorView.setTabIndicatorColor(this._tabIndicatorColor)
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
this.setupNativeRenderable()
|
|
163
|
-
this.setupEventListeners(options)
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
public get lineInfo(): LineInfo {
|
|
167
|
-
return this.editorView.getLogicalLineInfo()
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
private setupEventListeners(options: EditBufferOptions): void {
|
|
171
|
-
this._cursorChangeListener = options.onCursorChange
|
|
172
|
-
this._contentChangeListener = options.onContentChange
|
|
173
|
-
|
|
174
|
-
this.editBuffer.on("cursor-changed", () => {
|
|
175
|
-
if (this._cursorChangeListener) {
|
|
176
|
-
const cursor = this.editBuffer.getCursorPosition()
|
|
177
|
-
this._cursorChangeListener({
|
|
178
|
-
line: cursor.row,
|
|
179
|
-
visualColumn: cursor.col,
|
|
180
|
-
})
|
|
181
|
-
}
|
|
182
|
-
})
|
|
183
|
-
|
|
184
|
-
this.editBuffer.on("content-changed", () => {
|
|
185
|
-
this.yogaNode.markDirty()
|
|
186
|
-
this.requestRender()
|
|
187
|
-
this.emit("line-info-change")
|
|
188
|
-
if (this._contentChangeListener) {
|
|
189
|
-
this._contentChangeListener({})
|
|
190
|
-
}
|
|
191
|
-
})
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
public get lineCount(): number {
|
|
195
|
-
return this.editBuffer.getLineCount()
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
public get virtualLineCount(): number {
|
|
199
|
-
return this.editorView.getVirtualLineCount()
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
public get scrollY(): number {
|
|
203
|
-
return this.editorView.getViewport().offsetY
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
get plainText(): string {
|
|
207
|
-
return this.editBuffer.getText()
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
get logicalCursor(): LogicalCursor {
|
|
211
|
-
return this.editBuffer.getCursorPosition()
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
get visualCursor(): VisualCursor {
|
|
215
|
-
return this.editorView.getVisualCursor()
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
get cursorOffset(): number {
|
|
219
|
-
return this.editorView.getVisualCursor().offset
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
set cursorOffset(offset: number) {
|
|
223
|
-
this.editorView.setCursorByOffset(offset)
|
|
224
|
-
this.requestRender()
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
get cursorCharacterOffset(): number | undefined {
|
|
228
|
-
const len = this.plainText.length
|
|
229
|
-
if (len <= 0) return
|
|
230
|
-
|
|
231
|
-
const cursor = this.logicalCursor
|
|
232
|
-
const offset = this.cursorOffset
|
|
233
|
-
if (offset >= len) {
|
|
234
|
-
if (cursor.col > 0) return len - 1
|
|
235
|
-
return 0
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
if (this.plainText[offset] === "\n" && cursor.col > 0) {
|
|
239
|
-
return offset - 1
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
return offset
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
get textColor(): RGBA {
|
|
246
|
-
return this._textColor
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
set textColor(value: RGBA | string | undefined) {
|
|
250
|
-
const newColor = parseColor(value ?? this._defaultOptions.textColor)
|
|
251
|
-
if (this._textColor !== newColor) {
|
|
252
|
-
this._textColor = newColor
|
|
253
|
-
this.editBuffer.setDefaultFg(newColor)
|
|
254
|
-
this.requestRender()
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
get selectionBg(): RGBA | undefined {
|
|
259
|
-
return this._selectionBg
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
get traits(): EditorTraits {
|
|
263
|
-
return this._traits
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
set traits(value: EditorTraits) {
|
|
267
|
-
if (sameTraits(this._traits, value)) return
|
|
268
|
-
const prev = this._traits
|
|
269
|
-
this._traits = value
|
|
270
|
-
this.emit(EditBufferRenderableEvents.TRAITS_CHANGED, value, prev)
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
set selectionBg(value: RGBA | string | undefined) {
|
|
274
|
-
const newColor = value ? parseColor(value) : this._defaultOptions.selectionBg
|
|
275
|
-
if (this._selectionBg !== newColor) {
|
|
276
|
-
this._selectionBg = newColor
|
|
277
|
-
this.refreshSelectionStyle()
|
|
278
|
-
this.requestRender()
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
get selectionFg(): RGBA | undefined {
|
|
283
|
-
return this._selectionFg
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
set selectionFg(value: RGBA | string | undefined) {
|
|
287
|
-
const newColor = value ? parseColor(value) : this._defaultOptions.selectionFg
|
|
288
|
-
if (this._selectionFg !== newColor) {
|
|
289
|
-
this._selectionFg = newColor
|
|
290
|
-
this.refreshSelectionStyle()
|
|
291
|
-
this.requestRender()
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
get backgroundColor(): RGBA {
|
|
296
|
-
return this._backgroundColor
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
set backgroundColor(value: RGBA | string | undefined) {
|
|
300
|
-
const newColor = parseColor(value ?? this._defaultOptions.backgroundColor)
|
|
301
|
-
if (this._backgroundColor !== newColor) {
|
|
302
|
-
this._backgroundColor = newColor
|
|
303
|
-
this.editBuffer.setDefaultBg(newColor)
|
|
304
|
-
this.requestRender()
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
get attributes(): number {
|
|
309
|
-
return this._defaultAttributes
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
set attributes(value: number) {
|
|
313
|
-
if (this._defaultAttributes !== value) {
|
|
314
|
-
this._defaultAttributes = value
|
|
315
|
-
this.editBuffer.setDefaultAttributes(value)
|
|
316
|
-
this.requestRender()
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
get wrapMode(): "none" | "char" | "word" {
|
|
321
|
-
return this._wrapMode
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
set wrapMode(value: "none" | "char" | "word") {
|
|
325
|
-
if (this._wrapMode !== value) {
|
|
326
|
-
this._wrapMode = value
|
|
327
|
-
this.editorView.setWrapMode(value)
|
|
328
|
-
this.yogaNode.markDirty()
|
|
329
|
-
this.requestRender()
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
get showCursor(): boolean {
|
|
334
|
-
return this._showCursor
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
set showCursor(value: boolean) {
|
|
338
|
-
if (this._showCursor !== value) {
|
|
339
|
-
this._showCursor = value
|
|
340
|
-
if (!value && this._focused) {
|
|
341
|
-
this._ctx.setCursorPosition(0, 0, false)
|
|
342
|
-
}
|
|
343
|
-
this.requestRender()
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
get cursorColor(): RGBA {
|
|
348
|
-
return this._cursorColor
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
set cursorColor(value: RGBA | string) {
|
|
352
|
-
const newColor = parseColor(value)
|
|
353
|
-
if (this._cursorColor !== newColor) {
|
|
354
|
-
this._cursorColor = newColor
|
|
355
|
-
if (this._focused) {
|
|
356
|
-
this.requestRender()
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
get cursorStyle(): CursorStyleOptions {
|
|
362
|
-
return this._cursorStyle
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
set cursorStyle(style: CursorStyleOptions) {
|
|
366
|
-
const newStyle = style
|
|
367
|
-
if (this.cursorStyle.style !== newStyle.style || this.cursorStyle.blinking !== newStyle.blinking) {
|
|
368
|
-
this._cursorStyle = newStyle
|
|
369
|
-
if (this._focused) {
|
|
370
|
-
this.requestRender()
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
get tabIndicator(): string | number | undefined {
|
|
376
|
-
return this._tabIndicator
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
set tabIndicator(value: string | number | undefined) {
|
|
380
|
-
if (this._tabIndicator !== value) {
|
|
381
|
-
this._tabIndicator = value
|
|
382
|
-
if (value !== undefined) {
|
|
383
|
-
this.editorView.setTabIndicator(value)
|
|
384
|
-
}
|
|
385
|
-
this.requestRender()
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
get tabIndicatorColor(): RGBA | undefined {
|
|
390
|
-
return this._tabIndicatorColor
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
set tabIndicatorColor(value: RGBA | string | undefined) {
|
|
394
|
-
const newColor = value ? parseColor(value) : undefined
|
|
395
|
-
if (this._tabIndicatorColor !== newColor) {
|
|
396
|
-
this._tabIndicatorColor = newColor
|
|
397
|
-
if (newColor !== undefined) {
|
|
398
|
-
this.editorView.setTabIndicatorColor(newColor)
|
|
399
|
-
}
|
|
400
|
-
this.requestRender()
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
get scrollSpeed(): number {
|
|
405
|
-
return this._scrollSpeed
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
set scrollSpeed(value: number) {
|
|
409
|
-
this._scrollSpeed = Math.max(0, value)
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
protected override onMouseEvent(event: any): void {
|
|
413
|
-
if (event.type === "scroll") {
|
|
414
|
-
this.handleScroll(event)
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
protected handleScroll(event: any): void {
|
|
419
|
-
if (!event.scroll) return
|
|
420
|
-
|
|
421
|
-
const { direction, delta } = event.scroll
|
|
422
|
-
const viewport = this.editorView.getViewport()
|
|
423
|
-
|
|
424
|
-
if (direction === "up") {
|
|
425
|
-
const newOffsetY = Math.max(0, viewport.offsetY - delta)
|
|
426
|
-
this.editorView.setViewport(viewport.offsetX, newOffsetY, viewport.width, viewport.height, true)
|
|
427
|
-
this.requestRender()
|
|
428
|
-
} else if (direction === "down") {
|
|
429
|
-
const totalVirtualLines = this.editorView.getTotalVirtualLineCount()
|
|
430
|
-
const maxOffsetY = Math.max(0, totalVirtualLines - viewport.height)
|
|
431
|
-
const newOffsetY = Math.min(viewport.offsetY + delta, maxOffsetY)
|
|
432
|
-
this.editorView.setViewport(viewport.offsetX, newOffsetY, viewport.width, viewport.height, true)
|
|
433
|
-
this.requestRender()
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
if (this._wrapMode === "none") {
|
|
437
|
-
if (direction === "left") {
|
|
438
|
-
const newOffsetX = Math.max(0, viewport.offsetX - delta)
|
|
439
|
-
this.editorView.setViewport(newOffsetX, viewport.offsetY, viewport.width, viewport.height, true)
|
|
440
|
-
this.requestRender()
|
|
441
|
-
} else if (direction === "right") {
|
|
442
|
-
const newOffsetX = viewport.offsetX + delta
|
|
443
|
-
this.editorView.setViewport(newOffsetX, viewport.offsetY, viewport.width, viewport.height, true)
|
|
444
|
-
this.requestRender()
|
|
445
|
-
}
|
|
446
|
-
}
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
protected onResize(width: number, height: number): void {
|
|
450
|
-
this.editorView.setViewportSize(width, height)
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
protected refreshLocalSelection(): boolean {
|
|
454
|
-
if (this.lastLocalSelection) {
|
|
455
|
-
return this.updateLocalSelection(this.lastLocalSelection)
|
|
456
|
-
}
|
|
457
|
-
return false
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
private updateLocalSelection(localSelection: LocalSelectionBounds | null): boolean {
|
|
461
|
-
if (!localSelection?.isActive) {
|
|
462
|
-
this.editorView.resetLocalSelection()
|
|
463
|
-
return true
|
|
464
|
-
}
|
|
465
|
-
return this.editorView.setLocalSelection(
|
|
466
|
-
localSelection.anchorX,
|
|
467
|
-
localSelection.anchorY,
|
|
468
|
-
localSelection.focusX,
|
|
469
|
-
localSelection.focusY,
|
|
470
|
-
this._selectionBg,
|
|
471
|
-
this._selectionFg,
|
|
472
|
-
false,
|
|
473
|
-
)
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
shouldStartSelection(x: number, y: number): boolean {
|
|
477
|
-
if (!this.selectable) return false
|
|
478
|
-
|
|
479
|
-
const localX = x - this.x
|
|
480
|
-
const localY = y - this.y
|
|
481
|
-
|
|
482
|
-
return localX >= 0 && localX < this.width && localY >= 0 && localY < this.height
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
onSelectionChanged(selection: Selection | null): boolean {
|
|
486
|
-
const localSelection = convertGlobalToLocalSelection(selection, this.x, this.y)
|
|
487
|
-
this.lastLocalSelection = localSelection
|
|
488
|
-
|
|
489
|
-
const updateCursor = true
|
|
490
|
-
const followCursor = this._keyboardSelectionActive
|
|
491
|
-
|
|
492
|
-
let changed: boolean
|
|
493
|
-
if (!localSelection?.isActive) {
|
|
494
|
-
this._keyboardSelectionActive = false
|
|
495
|
-
this.editorView.resetLocalSelection()
|
|
496
|
-
changed = true
|
|
497
|
-
} else if (selection?.isStart) {
|
|
498
|
-
changed = this.editorView.setLocalSelection(
|
|
499
|
-
localSelection.anchorX,
|
|
500
|
-
localSelection.anchorY,
|
|
501
|
-
localSelection.focusX,
|
|
502
|
-
localSelection.focusY,
|
|
503
|
-
this._selectionBg,
|
|
504
|
-
this._selectionFg,
|
|
505
|
-
updateCursor,
|
|
506
|
-
followCursor,
|
|
507
|
-
)
|
|
508
|
-
} else {
|
|
509
|
-
changed = this.editorView.updateLocalSelection(
|
|
510
|
-
localSelection.anchorX,
|
|
511
|
-
localSelection.anchorY,
|
|
512
|
-
localSelection.focusX,
|
|
513
|
-
localSelection.focusY,
|
|
514
|
-
this._selectionBg,
|
|
515
|
-
this._selectionFg,
|
|
516
|
-
updateCursor,
|
|
517
|
-
followCursor,
|
|
518
|
-
)
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
if (changed && localSelection?.isActive && selection?.isDragging) {
|
|
522
|
-
const viewport = this.editorView.getViewport()
|
|
523
|
-
const focusY = localSelection.focusY
|
|
524
|
-
const scrollMargin = Math.max(1, Math.floor(viewport.height * this._scrollMargin))
|
|
525
|
-
|
|
526
|
-
if (focusY < scrollMargin) {
|
|
527
|
-
this._autoScrollVelocity = -this._scrollSpeed
|
|
528
|
-
} else if (focusY >= viewport.height - scrollMargin) {
|
|
529
|
-
this._autoScrollVelocity = this._scrollSpeed
|
|
530
|
-
} else {
|
|
531
|
-
this._autoScrollVelocity = 0
|
|
532
|
-
}
|
|
533
|
-
} else {
|
|
534
|
-
this._keyboardSelectionActive = false
|
|
535
|
-
this._autoScrollVelocity = 0
|
|
536
|
-
this._autoScrollAccumulator = 0
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
if (changed) {
|
|
540
|
-
this.requestRender()
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
return this.hasSelection()
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
protected override onUpdate(deltaTime: number): void {
|
|
547
|
-
super.onUpdate(deltaTime)
|
|
548
|
-
|
|
549
|
-
if (this._autoScrollVelocity !== 0 && this.hasSelection()) {
|
|
550
|
-
const deltaSeconds = deltaTime / 1000
|
|
551
|
-
this._autoScrollAccumulator += this._autoScrollVelocity * deltaSeconds
|
|
552
|
-
|
|
553
|
-
const linesToScroll = Math.floor(Math.abs(this._autoScrollAccumulator))
|
|
554
|
-
if (linesToScroll > 0) {
|
|
555
|
-
const direction = this._autoScrollVelocity > 0 ? 1 : -1
|
|
556
|
-
const viewport = this.editorView.getViewport()
|
|
557
|
-
const totalVirtualLines = this.editorView.getTotalVirtualLineCount()
|
|
558
|
-
const maxOffsetY = Math.max(0, totalVirtualLines - viewport.height)
|
|
559
|
-
const newOffsetY = Math.max(0, Math.min(viewport.offsetY + direction * linesToScroll, maxOffsetY))
|
|
560
|
-
|
|
561
|
-
if (newOffsetY !== viewport.offsetY) {
|
|
562
|
-
this.editorView.setViewport(viewport.offsetX, newOffsetY, viewport.width, viewport.height, false)
|
|
563
|
-
|
|
564
|
-
this._ctx.requestSelectionUpdate()
|
|
565
|
-
}
|
|
566
|
-
|
|
567
|
-
this._autoScrollAccumulator -= direction * linesToScroll
|
|
568
|
-
}
|
|
569
|
-
}
|
|
570
|
-
}
|
|
571
|
-
|
|
572
|
-
getSelectedText(): string {
|
|
573
|
-
return this.editorView.getSelectedText()
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
hasSelection(): boolean {
|
|
577
|
-
return this.editorView.hasSelection()
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
getSelection(): { start: number; end: number } | null {
|
|
581
|
-
return this.editorView.getSelection()
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
private refreshSelectionStyle(): void {
|
|
585
|
-
if (this.lastLocalSelection) {
|
|
586
|
-
this.updateLocalSelection(this.lastLocalSelection)
|
|
587
|
-
return
|
|
588
|
-
}
|
|
589
|
-
|
|
590
|
-
const selection = this.getSelection()
|
|
591
|
-
if (!selection) return
|
|
592
|
-
this.editorView.setSelection(selection.start, selection.end, this._selectionBg, this._selectionFg)
|
|
593
|
-
}
|
|
594
|
-
|
|
595
|
-
private deleteSelectedText(): void {
|
|
596
|
-
this.editorView.deleteSelectedText()
|
|
597
|
-
this._ctx.clearSelection()
|
|
598
|
-
this.requestRender()
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
setSelection(start: number, end: number): void {
|
|
602
|
-
this.lastLocalSelection = null
|
|
603
|
-
this.editorView.resetLocalSelection()
|
|
604
|
-
this._ctx.clearSelection()
|
|
605
|
-
this.editorView.setSelection(start, end, this._selectionBg, this._selectionFg)
|
|
606
|
-
this.requestRender()
|
|
607
|
-
}
|
|
608
|
-
|
|
609
|
-
setSelectionInclusive(start: number, end: number): void {
|
|
610
|
-
this.setSelection(Math.min(start, end), Math.max(start, end) + 1)
|
|
611
|
-
}
|
|
612
|
-
|
|
613
|
-
clearSelection(): boolean {
|
|
614
|
-
const had = this.hasSelection()
|
|
615
|
-
this.lastLocalSelection = null
|
|
616
|
-
this.editorView.resetSelection()
|
|
617
|
-
this.editorView.resetLocalSelection()
|
|
618
|
-
this._ctx.clearSelection()
|
|
619
|
-
if (had) {
|
|
620
|
-
this.requestRender()
|
|
621
|
-
}
|
|
622
|
-
return had
|
|
623
|
-
}
|
|
624
|
-
|
|
625
|
-
deleteSelection(): boolean {
|
|
626
|
-
if (!this.hasSelection()) return false
|
|
627
|
-
|
|
628
|
-
this.lastLocalSelection = null
|
|
629
|
-
this.deleteSelectedText()
|
|
630
|
-
return true
|
|
631
|
-
}
|
|
632
|
-
|
|
633
|
-
setCursor(row: number, col: number): void {
|
|
634
|
-
this.editBuffer.setCursor(row, col)
|
|
635
|
-
this.requestRender()
|
|
636
|
-
}
|
|
637
|
-
|
|
638
|
-
public insertChar(char: string): void {
|
|
639
|
-
if (this.hasSelection()) {
|
|
640
|
-
this.deleteSelectedText()
|
|
641
|
-
}
|
|
642
|
-
|
|
643
|
-
this.editBuffer.insertChar(char)
|
|
644
|
-
this.requestRender()
|
|
645
|
-
}
|
|
646
|
-
|
|
647
|
-
public insertText(text: string): void {
|
|
648
|
-
if (this.hasSelection()) {
|
|
649
|
-
this.deleteSelectedText()
|
|
650
|
-
}
|
|
651
|
-
|
|
652
|
-
this.editBuffer.insertText(text)
|
|
653
|
-
this.requestRender()
|
|
654
|
-
}
|
|
655
|
-
|
|
656
|
-
public deleteChar(): boolean {
|
|
657
|
-
if (this.hasSelection()) {
|
|
658
|
-
this.deleteSelectedText()
|
|
659
|
-
return true
|
|
660
|
-
}
|
|
661
|
-
|
|
662
|
-
this._ctx.clearSelection()
|
|
663
|
-
this.editBuffer.deleteChar()
|
|
664
|
-
this.requestRender()
|
|
665
|
-
return true
|
|
666
|
-
}
|
|
667
|
-
|
|
668
|
-
public deleteCharBackward(): boolean {
|
|
669
|
-
if (this.hasSelection()) {
|
|
670
|
-
this.deleteSelectedText()
|
|
671
|
-
return true
|
|
672
|
-
}
|
|
673
|
-
|
|
674
|
-
this._ctx.clearSelection()
|
|
675
|
-
this.editBuffer.deleteCharBackward()
|
|
676
|
-
this.requestRender()
|
|
677
|
-
return true
|
|
678
|
-
}
|
|
679
|
-
|
|
680
|
-
public newLine(): boolean {
|
|
681
|
-
this._ctx.clearSelection()
|
|
682
|
-
this.editBuffer.newLine()
|
|
683
|
-
this.requestRender()
|
|
684
|
-
return true
|
|
685
|
-
}
|
|
686
|
-
|
|
687
|
-
public deleteLine(): boolean {
|
|
688
|
-
this._ctx.clearSelection()
|
|
689
|
-
this.editBuffer.deleteLine()
|
|
690
|
-
this.requestRender()
|
|
691
|
-
return true
|
|
692
|
-
}
|
|
693
|
-
|
|
694
|
-
public moveCursorLeft(options?: { select?: boolean }): boolean {
|
|
695
|
-
const select = options?.select ?? false
|
|
696
|
-
|
|
697
|
-
if (!select && this.hasSelection()) {
|
|
698
|
-
const selection = this.getSelection()!
|
|
699
|
-
this.editBuffer.setCursorByOffset(selection.start)
|
|
700
|
-
this._ctx.clearSelection()
|
|
701
|
-
this.requestRender()
|
|
702
|
-
return true
|
|
703
|
-
}
|
|
704
|
-
|
|
705
|
-
this.updateSelectionForMovement(select, true)
|
|
706
|
-
this.editBuffer.moveCursorLeft()
|
|
707
|
-
this.updateSelectionForMovement(select, false)
|
|
708
|
-
this.requestRender()
|
|
709
|
-
return true
|
|
710
|
-
}
|
|
711
|
-
|
|
712
|
-
public moveCursorRight(options?: { select?: boolean }): boolean {
|
|
713
|
-
const select = options?.select ?? false
|
|
714
|
-
|
|
715
|
-
if (!select && this.hasSelection()) {
|
|
716
|
-
const selection = this.getSelection()!
|
|
717
|
-
const targetOffset = this.cursorOffset === selection.start ? selection.end - 1 : selection.end
|
|
718
|
-
this.editBuffer.setCursorByOffset(targetOffset)
|
|
719
|
-
this._ctx.clearSelection()
|
|
720
|
-
this.requestRender()
|
|
721
|
-
return true
|
|
722
|
-
}
|
|
723
|
-
|
|
724
|
-
this.updateSelectionForMovement(select, true)
|
|
725
|
-
this.editBuffer.moveCursorRight()
|
|
726
|
-
this.updateSelectionForMovement(select, false)
|
|
727
|
-
this.requestRender()
|
|
728
|
-
return true
|
|
729
|
-
}
|
|
730
|
-
|
|
731
|
-
public moveCursorUp(options?: { select?: boolean }): boolean {
|
|
732
|
-
const select = options?.select ?? false
|
|
733
|
-
this.updateSelectionForMovement(select, true)
|
|
734
|
-
this.editorView.moveUpVisual()
|
|
735
|
-
this.updateSelectionForMovement(select, false)
|
|
736
|
-
this.requestRender()
|
|
737
|
-
return true
|
|
738
|
-
}
|
|
739
|
-
|
|
740
|
-
public moveCursorDown(options?: { select?: boolean }): boolean {
|
|
741
|
-
const select = options?.select ?? false
|
|
742
|
-
this.updateSelectionForMovement(select, true)
|
|
743
|
-
this.editorView.moveDownVisual()
|
|
744
|
-
this.updateSelectionForMovement(select, false)
|
|
745
|
-
this.requestRender()
|
|
746
|
-
return true
|
|
747
|
-
}
|
|
748
|
-
|
|
749
|
-
public gotoLine(line: number): void {
|
|
750
|
-
this.editBuffer.gotoLine(line)
|
|
751
|
-
this.requestRender()
|
|
752
|
-
}
|
|
753
|
-
|
|
754
|
-
public gotoLineStart(): void {
|
|
755
|
-
this.setCursor(this.logicalCursor.row, 0)
|
|
756
|
-
}
|
|
757
|
-
|
|
758
|
-
public gotoLineTextEnd(): void {
|
|
759
|
-
const eol = this.editBuffer.getEOL()
|
|
760
|
-
this.setCursor(eol.row, eol.col)
|
|
761
|
-
}
|
|
762
|
-
|
|
763
|
-
public gotoLineHome(options?: { select?: boolean }): boolean {
|
|
764
|
-
const select = options?.select ?? false
|
|
765
|
-
this.updateSelectionForMovement(select, true)
|
|
766
|
-
const cursor = this.editorView.getCursor()
|
|
767
|
-
if (cursor.col === 0 && cursor.row > 0) {
|
|
768
|
-
this.editBuffer.setCursor(cursor.row - 1, 0)
|
|
769
|
-
const prevLineEol = this.editBuffer.getEOL()
|
|
770
|
-
this.editBuffer.setCursor(prevLineEol.row, prevLineEol.col)
|
|
771
|
-
} else {
|
|
772
|
-
this.editBuffer.setCursor(cursor.row, 0)
|
|
773
|
-
}
|
|
774
|
-
|
|
775
|
-
this.updateSelectionForMovement(select, false)
|
|
776
|
-
this.requestRender()
|
|
777
|
-
return true
|
|
778
|
-
}
|
|
779
|
-
|
|
780
|
-
public gotoLineEnd(options?: { select?: boolean }): boolean {
|
|
781
|
-
const select = options?.select ?? false
|
|
782
|
-
this.updateSelectionForMovement(select, true)
|
|
783
|
-
const cursor = this.editorView.getCursor()
|
|
784
|
-
const eol = this.editBuffer.getEOL()
|
|
785
|
-
const lineCount = this.editBuffer.getLineCount()
|
|
786
|
-
if (cursor.col === eol.col && cursor.row < lineCount - 1) {
|
|
787
|
-
this.editBuffer.setCursor(cursor.row + 1, 0)
|
|
788
|
-
} else {
|
|
789
|
-
this.editBuffer.setCursor(eol.row, eol.col)
|
|
790
|
-
}
|
|
791
|
-
|
|
792
|
-
this.updateSelectionForMovement(select, false)
|
|
793
|
-
this.requestRender()
|
|
794
|
-
return true
|
|
795
|
-
}
|
|
796
|
-
|
|
797
|
-
public gotoVisualLineHome(options?: { select?: boolean }): boolean {
|
|
798
|
-
const select = options?.select ?? false
|
|
799
|
-
this.updateSelectionForMovement(select, true)
|
|
800
|
-
const sol = this.editorView.getVisualSOL()
|
|
801
|
-
this.editBuffer.setCursor(sol.logicalRow, sol.logicalCol)
|
|
802
|
-
this.updateSelectionForMovement(select, false)
|
|
803
|
-
this.requestRender()
|
|
804
|
-
return true
|
|
805
|
-
}
|
|
806
|
-
|
|
807
|
-
public gotoVisualLineEnd(options?: { select?: boolean }): boolean {
|
|
808
|
-
const select = options?.select ?? false
|
|
809
|
-
this.updateSelectionForMovement(select, true)
|
|
810
|
-
const eol = this.editorView.getVisualEOL()
|
|
811
|
-
this.editBuffer.setCursor(eol.logicalRow, eol.logicalCol)
|
|
812
|
-
this.updateSelectionForMovement(select, false)
|
|
813
|
-
this.requestRender()
|
|
814
|
-
return true
|
|
815
|
-
}
|
|
816
|
-
|
|
817
|
-
public gotoBufferHome(options?: { select?: boolean }): boolean {
|
|
818
|
-
const select = options?.select ?? false
|
|
819
|
-
this.updateSelectionForMovement(select, true)
|
|
820
|
-
this.editBuffer.setCursor(0, 0)
|
|
821
|
-
this.updateSelectionForMovement(select, false)
|
|
822
|
-
this.requestRender()
|
|
823
|
-
return true
|
|
824
|
-
}
|
|
825
|
-
|
|
826
|
-
public gotoBufferEnd(options?: { select?: boolean }): boolean {
|
|
827
|
-
const select = options?.select ?? false
|
|
828
|
-
this.updateSelectionForMovement(select, true)
|
|
829
|
-
this.editBuffer.gotoLine(999999)
|
|
830
|
-
this.updateSelectionForMovement(select, false)
|
|
831
|
-
this.requestRender()
|
|
832
|
-
return true
|
|
833
|
-
}
|
|
834
|
-
|
|
835
|
-
public selectAll(): boolean {
|
|
836
|
-
this.updateSelectionForMovement(false, true)
|
|
837
|
-
this.editBuffer.setCursor(0, 0)
|
|
838
|
-
return this.gotoBufferEnd({ select: true })
|
|
839
|
-
}
|
|
840
|
-
|
|
841
|
-
public deleteToLineEnd(): boolean {
|
|
842
|
-
const cursor = this.editorView.getCursor()
|
|
843
|
-
const eol = this.editBuffer.getEOL()
|
|
844
|
-
|
|
845
|
-
if (eol.col > cursor.col) {
|
|
846
|
-
this.editBuffer.deleteRange(cursor.row, cursor.col, eol.row, eol.col)
|
|
847
|
-
}
|
|
848
|
-
|
|
849
|
-
this.requestRender()
|
|
850
|
-
return true
|
|
851
|
-
}
|
|
852
|
-
|
|
853
|
-
public deleteToLineStart(): boolean {
|
|
854
|
-
const cursor = this.editorView.getCursor()
|
|
855
|
-
|
|
856
|
-
if (cursor.col > 0) {
|
|
857
|
-
this.editBuffer.deleteRange(cursor.row, 0, cursor.row, cursor.col)
|
|
858
|
-
} else if (cursor.row > 0) {
|
|
859
|
-
this.editBuffer.deleteCharBackward()
|
|
860
|
-
}
|
|
861
|
-
|
|
862
|
-
this.requestRender()
|
|
863
|
-
return true
|
|
864
|
-
}
|
|
865
|
-
|
|
866
|
-
public undo(): boolean {
|
|
867
|
-
this._ctx.clearSelection()
|
|
868
|
-
this.editBuffer.undo()
|
|
869
|
-
this.requestRender()
|
|
870
|
-
return true
|
|
871
|
-
}
|
|
872
|
-
|
|
873
|
-
public redo(): boolean {
|
|
874
|
-
this._ctx.clearSelection()
|
|
875
|
-
this.editBuffer.redo()
|
|
876
|
-
this.requestRender()
|
|
877
|
-
return true
|
|
878
|
-
}
|
|
879
|
-
|
|
880
|
-
public moveWordForward(options?: { select?: boolean }): boolean {
|
|
881
|
-
const select = options?.select ?? false
|
|
882
|
-
this.updateSelectionForMovement(select, true)
|
|
883
|
-
const nextWord = this.editBuffer.getNextWordBoundary()
|
|
884
|
-
this.editBuffer.setCursorByOffset(nextWord.offset)
|
|
885
|
-
this.updateSelectionForMovement(select, false)
|
|
886
|
-
this.requestRender()
|
|
887
|
-
return true
|
|
888
|
-
}
|
|
889
|
-
|
|
890
|
-
public moveWordBackward(options?: { select?: boolean }): boolean {
|
|
891
|
-
const select = options?.select ?? false
|
|
892
|
-
this.updateSelectionForMovement(select, true)
|
|
893
|
-
const prevWord = this.editBuffer.getPrevWordBoundary()
|
|
894
|
-
this.editBuffer.setCursorByOffset(prevWord.offset)
|
|
895
|
-
this.updateSelectionForMovement(select, false)
|
|
896
|
-
this.requestRender()
|
|
897
|
-
return true
|
|
898
|
-
}
|
|
899
|
-
|
|
900
|
-
public deleteWordForward(): boolean {
|
|
901
|
-
if (this.hasSelection()) {
|
|
902
|
-
this.deleteSelectedText()
|
|
903
|
-
return true
|
|
904
|
-
}
|
|
905
|
-
|
|
906
|
-
const currentCursor = this.editBuffer.getCursorPosition()
|
|
907
|
-
const nextWord = this.editBuffer.getNextWordBoundary()
|
|
908
|
-
|
|
909
|
-
if (nextWord.offset > currentCursor.offset) {
|
|
910
|
-
this.editBuffer.deleteRange(currentCursor.row, currentCursor.col, nextWord.row, nextWord.col)
|
|
911
|
-
}
|
|
912
|
-
|
|
913
|
-
this._ctx.clearSelection()
|
|
914
|
-
this.requestRender()
|
|
915
|
-
return true
|
|
916
|
-
}
|
|
917
|
-
|
|
918
|
-
public deleteWordBackward(): boolean {
|
|
919
|
-
if (this.hasSelection()) {
|
|
920
|
-
this.deleteSelectedText()
|
|
921
|
-
return true
|
|
922
|
-
}
|
|
923
|
-
|
|
924
|
-
const currentCursor = this.editBuffer.getCursorPosition()
|
|
925
|
-
const prevWord = this.editBuffer.getPrevWordBoundary()
|
|
926
|
-
|
|
927
|
-
if (prevWord.offset < currentCursor.offset) {
|
|
928
|
-
this.editBuffer.deleteRange(prevWord.row, prevWord.col, currentCursor.row, currentCursor.col)
|
|
929
|
-
}
|
|
930
|
-
|
|
931
|
-
this._ctx.clearSelection()
|
|
932
|
-
this.requestRender()
|
|
933
|
-
return true
|
|
934
|
-
}
|
|
935
|
-
|
|
936
|
-
private setupNativeRenderable(): void {
|
|
937
|
-
const lib = resolveRenderLib()
|
|
938
|
-
// Transitional native backing: JS still owns the render tree and Yoga nodes,
|
|
939
|
-
// while native owns only hot measurement state. Attach the existing JS-created
|
|
940
|
-
// Yoga node for now. The intended direction is for every Renderable to become
|
|
941
|
-
// native-backed and for Yoga node ownership to move native-side with it.
|
|
942
|
-
const nativeRenderable = lib.createNativeRenderable()
|
|
943
|
-
if (!lib.nativeRenderableAttachYogaNode(nativeRenderable, this.yogaNode.ptr)) {
|
|
944
|
-
lib.destroyNativeRenderable(nativeRenderable)
|
|
945
|
-
throw new Error("Failed to attach native renderable Yoga node")
|
|
946
|
-
}
|
|
947
|
-
if (
|
|
948
|
-
!lib.nativeRenderableSetMeasureTarget(nativeRenderable, NativeMeasureTargetKind.EditorView, this.editorView.ptr)
|
|
949
|
-
) {
|
|
950
|
-
lib.destroyNativeRenderable(nativeRenderable)
|
|
951
|
-
throw new Error("Failed to attach editor native measure target")
|
|
952
|
-
}
|
|
953
|
-
this.nativeRenderable = nativeRenderable
|
|
954
|
-
}
|
|
955
|
-
|
|
956
|
-
render(buffer: OptimizedBuffer, deltaTime: number): void {
|
|
957
|
-
if (!this.visible) return
|
|
958
|
-
if (this.isDestroyed) return
|
|
959
|
-
// Editor rendering/cursor placement reads absolute coordinates multiple
|
|
960
|
-
// times per frame, so it benefits from the same cached screen position.
|
|
961
|
-
const screenX = this._screenX
|
|
962
|
-
const screenY = this._screenY
|
|
963
|
-
|
|
964
|
-
this.markClean()
|
|
965
|
-
this._ctx.addToHitGrid(screenX, screenY, this.width, this.height, this.num)
|
|
966
|
-
|
|
967
|
-
this.renderSelf(buffer)
|
|
968
|
-
this.renderCursor(buffer)
|
|
969
|
-
}
|
|
970
|
-
|
|
971
|
-
protected renderSelf(buffer: OptimizedBuffer): void {
|
|
972
|
-
buffer.drawEditorView(this.editorView, this._screenX, this._screenY)
|
|
973
|
-
}
|
|
974
|
-
|
|
975
|
-
protected renderCursor(buffer: OptimizedBuffer): void {
|
|
976
|
-
if (!this._showCursor || !this._focused) return
|
|
977
|
-
|
|
978
|
-
const visualCursor = this.editorView.getVisualCursor()
|
|
979
|
-
const screenX = this._screenX
|
|
980
|
-
const screenY = this._screenY
|
|
981
|
-
|
|
982
|
-
const cursorX = screenX + visualCursor.visualCol + 1 // +1 for 1-based terminal coords
|
|
983
|
-
const cursorY = screenY + visualCursor.visualRow + 1 // +1 for 1-based terminal coords
|
|
984
|
-
|
|
985
|
-
this._ctx.setCursorPosition(cursorX, cursorY, true)
|
|
986
|
-
this._ctx.setCursorStyle({ ...this._cursorStyle, color: this._cursorColor })
|
|
987
|
-
}
|
|
988
|
-
|
|
989
|
-
public focus(): void {
|
|
990
|
-
super.focus()
|
|
991
|
-
this._ctx.setCursorStyle({ ...this._cursorStyle, color: this._cursorColor })
|
|
992
|
-
this.requestRender()
|
|
993
|
-
}
|
|
994
|
-
|
|
995
|
-
public blur(): void {
|
|
996
|
-
super.blur()
|
|
997
|
-
this._ctx.setCursorPosition(0, 0, false)
|
|
998
|
-
this.requestRender()
|
|
999
|
-
}
|
|
1000
|
-
|
|
1001
|
-
protected onRemove(): void {
|
|
1002
|
-
if (this._focused) {
|
|
1003
|
-
this._ctx.setCursorPosition(0, 0, false)
|
|
1004
|
-
}
|
|
1005
|
-
}
|
|
1006
|
-
|
|
1007
|
-
override destroy(): void {
|
|
1008
|
-
if (this.isDestroyed) return
|
|
1009
|
-
|
|
1010
|
-
this.traits = {}
|
|
1011
|
-
|
|
1012
|
-
if (this._focused) {
|
|
1013
|
-
this._ctx.setCursorPosition(0, 0, false)
|
|
1014
|
-
// Manually blur to unhook event handlers BEFORE setting destroyed flag
|
|
1015
|
-
// This prevents the guard in super.destroy() from skipping blur()
|
|
1016
|
-
this.blur()
|
|
1017
|
-
}
|
|
1018
|
-
|
|
1019
|
-
// Destroy dependent resources in correct order BEFORE calling super
|
|
1020
|
-
// EditorView depends on EditBuffer, so destroy it first
|
|
1021
|
-
if (this.nativeRenderable) {
|
|
1022
|
-
resolveRenderLib().destroyNativeRenderable(this.nativeRenderable)
|
|
1023
|
-
this.nativeRenderable = null
|
|
1024
|
-
}
|
|
1025
|
-
this.editorView.destroy()
|
|
1026
|
-
this.editBuffer.destroy()
|
|
1027
|
-
|
|
1028
|
-
// Finally clean up parent resources
|
|
1029
|
-
// Note: super.destroy() will try to blur() again, but blur() has guards to prevent double-blur
|
|
1030
|
-
super.destroy()
|
|
1031
|
-
}
|
|
1032
|
-
|
|
1033
|
-
public set onCursorChange(handler: ((event: CursorChangeEvent) => void) | undefined) {
|
|
1034
|
-
this._cursorChangeListener = handler
|
|
1035
|
-
}
|
|
1036
|
-
|
|
1037
|
-
public get onCursorChange(): ((event: CursorChangeEvent) => void) | undefined {
|
|
1038
|
-
return this._cursorChangeListener
|
|
1039
|
-
}
|
|
1040
|
-
|
|
1041
|
-
public set onContentChange(handler: ((event: ContentChangeEvent) => void) | undefined) {
|
|
1042
|
-
this._contentChangeListener = handler
|
|
1043
|
-
}
|
|
1044
|
-
|
|
1045
|
-
public get onContentChange(): ((event: ContentChangeEvent) => void) | undefined {
|
|
1046
|
-
return this._contentChangeListener
|
|
1047
|
-
}
|
|
1048
|
-
|
|
1049
|
-
get syntaxStyle(): SyntaxStyle | null {
|
|
1050
|
-
return this.editBuffer.getSyntaxStyle()
|
|
1051
|
-
}
|
|
1052
|
-
|
|
1053
|
-
set syntaxStyle(style: SyntaxStyle | null) {
|
|
1054
|
-
this.editBuffer.setSyntaxStyle(style)
|
|
1055
|
-
this.requestRender()
|
|
1056
|
-
}
|
|
1057
|
-
|
|
1058
|
-
public addHighlight(lineIdx: number, highlight: Highlight): void {
|
|
1059
|
-
this.editBuffer.addHighlight(lineIdx, highlight)
|
|
1060
|
-
this.requestRender()
|
|
1061
|
-
}
|
|
1062
|
-
|
|
1063
|
-
public addHighlightByCharRange(highlight: Highlight): void {
|
|
1064
|
-
this.editBuffer.addHighlightByCharRange(highlight)
|
|
1065
|
-
this.requestRender()
|
|
1066
|
-
}
|
|
1067
|
-
|
|
1068
|
-
public removeHighlightsByRef(hlRef: number): void {
|
|
1069
|
-
this.editBuffer.removeHighlightsByRef(hlRef)
|
|
1070
|
-
this.requestRender()
|
|
1071
|
-
}
|
|
1072
|
-
|
|
1073
|
-
public clearLineHighlights(lineIdx: number): void {
|
|
1074
|
-
this.editBuffer.clearLineHighlights(lineIdx)
|
|
1075
|
-
this.requestRender()
|
|
1076
|
-
}
|
|
1077
|
-
|
|
1078
|
-
public clearAllHighlights(): void {
|
|
1079
|
-
this.editBuffer.clearAllHighlights()
|
|
1080
|
-
this.requestRender()
|
|
1081
|
-
}
|
|
1082
|
-
|
|
1083
|
-
public getLineHighlights(lineIdx: number): Array<Highlight> {
|
|
1084
|
-
return this.editBuffer.getLineHighlights(lineIdx)
|
|
1085
|
-
}
|
|
1086
|
-
|
|
1087
|
-
/**
|
|
1088
|
-
* Set text and completely reset the buffer state (clears history, resets add_buffer).
|
|
1089
|
-
* Use this for initial text setting or when you want a clean slate.
|
|
1090
|
-
*/
|
|
1091
|
-
public setText(text: string): void {
|
|
1092
|
-
this.editBuffer.setText(text)
|
|
1093
|
-
this.yogaNode.markDirty()
|
|
1094
|
-
this.requestRender()
|
|
1095
|
-
}
|
|
1096
|
-
|
|
1097
|
-
/**
|
|
1098
|
-
* Replace text while preserving undo history (creates an undo point).
|
|
1099
|
-
* Use this when you want the setText operation to be undoable.
|
|
1100
|
-
*/
|
|
1101
|
-
public replaceText(text: string): void {
|
|
1102
|
-
this.editBuffer.replaceText(text)
|
|
1103
|
-
this.yogaNode.markDirty()
|
|
1104
|
-
this.requestRender()
|
|
1105
|
-
}
|
|
1106
|
-
|
|
1107
|
-
public clear(): void {
|
|
1108
|
-
this.editBuffer.clear()
|
|
1109
|
-
this.editBuffer.clearAllHighlights()
|
|
1110
|
-
this.yogaNode.markDirty()
|
|
1111
|
-
this.requestRender()
|
|
1112
|
-
}
|
|
1113
|
-
|
|
1114
|
-
public deleteRange(startLine: number, startCol: number, endLine: number, endCol: number): void {
|
|
1115
|
-
this.editBuffer.deleteRange(startLine, startCol, endLine, endCol)
|
|
1116
|
-
this.yogaNode.markDirty()
|
|
1117
|
-
this.requestRender()
|
|
1118
|
-
}
|
|
1119
|
-
|
|
1120
|
-
public getTextRange(startOffset: number, endOffset: number): string {
|
|
1121
|
-
return this.editBuffer.getTextRange(startOffset, endOffset)
|
|
1122
|
-
}
|
|
1123
|
-
|
|
1124
|
-
public getTextRangeByCoords(startRow: number, startCol: number, endRow: number, endCol: number): string {
|
|
1125
|
-
return this.editBuffer.getTextRangeByCoords(startRow, startCol, endRow, endCol)
|
|
1126
|
-
}
|
|
1127
|
-
|
|
1128
|
-
protected updateSelectionForMovement(shiftPressed: boolean, isBeforeMovement: boolean): void {
|
|
1129
|
-
if (!this.selectable) return
|
|
1130
|
-
|
|
1131
|
-
if (!shiftPressed) {
|
|
1132
|
-
this._keyboardSelectionActive = false
|
|
1133
|
-
this._ctx.clearSelection()
|
|
1134
|
-
return
|
|
1135
|
-
}
|
|
1136
|
-
|
|
1137
|
-
this._keyboardSelectionActive = true
|
|
1138
|
-
|
|
1139
|
-
const visualCursor = this.editorView.getVisualCursor()
|
|
1140
|
-
const cursorX = this.x + visualCursor.visualCol
|
|
1141
|
-
const cursorY = this.y + visualCursor.visualRow
|
|
1142
|
-
|
|
1143
|
-
if (isBeforeMovement) {
|
|
1144
|
-
if (!this._ctx.hasSelection) {
|
|
1145
|
-
this._ctx.startSelection(this, cursorX, cursorY)
|
|
1146
|
-
}
|
|
1147
|
-
return
|
|
1148
|
-
}
|
|
1149
|
-
|
|
1150
|
-
this._ctx.updateSelection(this, cursorX, cursorY, { finishDragging: true })
|
|
1151
|
-
}
|
|
1152
|
-
}
|