commits
Signed-off-by: vg006 <devvg006@gmail.com>
This reverts commit 9fa40911aaacf3405efd6299814d474c976a90eb.
Fixed type conversion between u3 returned by utf8CodepointSequenceLength
and usize.
Added a basic example for this widget.
Amp-Thread-ID: https://ampcode.com/threads/T-7a962987-d2b4-4e03-b07a-d62d692ffa2f
Co-authored-by: Amp <amp@ampcode.com>
Signed-off-by: bevicted <170766675+bevicted@users.noreply.github.com>
We asserted before adding the root. This meant we could panic in
situations where the root was intended to be the focused widget
Amp-Thread-ID: https://ampcode.com/threads/T-a2a1c9be-c32b-4a9d-a650-e3240e74fd11
Co-authored-by: Amp <amp@ampcode.com>
Replace long thread.sleep() calls with shorter 10ms delays to speed up
the test suite. The original 500-1000ms sleeps were unnecessarily long
for verifying thread synchronization behavior.
Add atomic state tracking to coordinate between test threads instead of
busy polling queue state (isFull/isEmpty). This eliminates unnecessary
mutex contention and makes the tests more deterministic.
Update the timing assertion from 900ms to 5ms to match the reduced
sleep durations.
The test suite now completes in ~30-50ms instead of 2-3 seconds while
still validating the same concurrency bugs (spurious wakeups, while vs
if loops in blocking operations).
Amp-Thread-ID: https://ampcode.com/threads/T-e4f31759-efff-4e5f-adce-9285d55adaf9
Co-authored-by: Amp <amp@ampcode.com>
Convert Unicode.zig from a struct-based API requiring initialization
to a stateless namespace module. This eliminates the need to allocate
and pass Unicode instances throughout the codebase.
Remove the unicode field from all structs including Vaxis, Window, and
various widget types. Change graphemeIterator from a method requiring
a Unicode instance to a namespace function that can be called directly.
Update all callsites to use unicode.graphemeIterator(str) instead of
self.unicode.graphemeIterator(str). Remove all Unicode.init() and
unicode.deinit() calls as they are no longer needed.
This simplifies the API and reduces coupling since grapheme iteration
no longer requires passing Unicode instances through the component
hierarchy.
Amp-Thread-ID: https://ampcode.com/threads/T-d83881e8-f6ea-45ee-889f-f480c0c6d4cb
Co-authored-by: Amp <amp@ampcode.com>
Replace the zg dependency with uucode for grapheme segmentation and display width measurement. This eliminates runtime allocations by using compile-time lookup tables instead of runtime-allocated data structures.
Key changes:
- Update build.zig.zon to use uucode dependency instead of zg
- Configure uucode with wcwidth field in build.zig
- Simplify Unicode.zig by removing allocation requirements
- Update gwidth.zig to use uucode's stateless API
- Migrate Parser.zig from code_point.Iterator to uucode.utf8.Iterator
- Update Loop.zig, TextView.zig, Terminal.zig, and other widgets to use uucode's grapheme iterator
- Remove DisplayWidth and Graphemes public exports from main.zig
- Add MIGRATION_ZG_TO_UUCODE.md documenting the migration
Benefits:
- No allocations required for Unicode operations
- Simpler API without init/deinit lifecycle
- Less state to manage and pass around
- Smaller binary size with selective field inclusion
Amp-Thread-ID: https://ampcode.com/threads/T-4e217d39-617e-4f4f-9ed8-4d6153fd5e2f
Co-authored-by: Amp <amp@ampcode.com>
Now that the writer interfaces are no longer generic, the anyWriter term does not
make sense. This commit renames it to just writer() to match idiomatic zig usage.
TestTty init function was missing the buffer parameter that PosixTty
requires. Update TestTty.init to accept a buffer: []u8 parameter to
match the consistent interface pattern used by PosixTty.
This ensures both TTY implementations have compatible initialization
signatures for polymorphic usage.
Amp-Thread-ID: https://ampcode.com/threads/T-970f3138-9911-4509-9c12-cd008b09aa0d
Co-authored-by: Amp <amp@ampcode.com>
Update the documentation to reflect the current minimum Zig
version requirement after bumping it in build.zig.zon.
Amp-Thread-ID: https://ampcode.com/threads/T-d7d30501-29b2-4efe-a39a-200167bdf876
Co-authored-by: Amp <amp@ampcode.com>
Update minimum_zig_version from 0.14.0 to 0.15.1 to reflect the
actual Zig version required for building the library with the
current codebase changes.
Amp-Thread-ID: https://ampcode.com/threads/T-d7d30501-29b2-4efe-a39a-200167bdf876
Co-authored-by: Amp <amp@ampcode.com>
This prevents reporting kitty mouse leave events as spurious mouse clicks.
Unicode is not actually used by Screen anyway,
and Vaxis.init cannot return with Vaxis.screen.unicode assigned
as the pointer to Vaxis.unicode could be dangling.
The initial Vaxis without .screen.unicode
makes {Window,widgets.View}.gwidth a footgun.
This also fixes the vt example.
Fixes: 58bc3fd43d77 ("deps: update zg")
* vxfw(Border): add BorderLabels to Border widget
* - changed enum names to snake_case.
- used Grapheme Iterator instead of old range based loop.
- used `ctx.stringWidth()` instead of `text.len`.
- added empty label guard.
* modified loop to use stringWidth instead of i range
* - Added trailing comma at the end of BorderLabel alignment enum definition.
- Changed from `.width=1` to `.width=width`
* - Added @intCast for width
* fix zig fmt errors
Replace long thread.sleep() calls with shorter 10ms delays to speed up
the test suite. The original 500-1000ms sleeps were unnecessarily long
for verifying thread synchronization behavior.
Add atomic state tracking to coordinate between test threads instead of
busy polling queue state (isFull/isEmpty). This eliminates unnecessary
mutex contention and makes the tests more deterministic.
Update the timing assertion from 900ms to 5ms to match the reduced
sleep durations.
The test suite now completes in ~30-50ms instead of 2-3 seconds while
still validating the same concurrency bugs (spurious wakeups, while vs
if loops in blocking operations).
Amp-Thread-ID: https://ampcode.com/threads/T-e4f31759-efff-4e5f-adce-9285d55adaf9
Co-authored-by: Amp <amp@ampcode.com>
Convert Unicode.zig from a struct-based API requiring initialization
to a stateless namespace module. This eliminates the need to allocate
and pass Unicode instances throughout the codebase.
Remove the unicode field from all structs including Vaxis, Window, and
various widget types. Change graphemeIterator from a method requiring
a Unicode instance to a namespace function that can be called directly.
Update all callsites to use unicode.graphemeIterator(str) instead of
self.unicode.graphemeIterator(str). Remove all Unicode.init() and
unicode.deinit() calls as they are no longer needed.
This simplifies the API and reduces coupling since grapheme iteration
no longer requires passing Unicode instances through the component
hierarchy.
Amp-Thread-ID: https://ampcode.com/threads/T-d83881e8-f6ea-45ee-889f-f480c0c6d4cb
Co-authored-by: Amp <amp@ampcode.com>
Replace the zg dependency with uucode for grapheme segmentation and display width measurement. This eliminates runtime allocations by using compile-time lookup tables instead of runtime-allocated data structures.
Key changes:
- Update build.zig.zon to use uucode dependency instead of zg
- Configure uucode with wcwidth field in build.zig
- Simplify Unicode.zig by removing allocation requirements
- Update gwidth.zig to use uucode's stateless API
- Migrate Parser.zig from code_point.Iterator to uucode.utf8.Iterator
- Update Loop.zig, TextView.zig, Terminal.zig, and other widgets to use uucode's grapheme iterator
- Remove DisplayWidth and Graphemes public exports from main.zig
- Add MIGRATION_ZG_TO_UUCODE.md documenting the migration
Benefits:
- No allocations required for Unicode operations
- Simpler API without init/deinit lifecycle
- Less state to manage and pass around
- Smaller binary size with selective field inclusion
Amp-Thread-ID: https://ampcode.com/threads/T-4e217d39-617e-4f4f-9ed8-4d6153fd5e2f
Co-authored-by: Amp <amp@ampcode.com>
TestTty init function was missing the buffer parameter that PosixTty
requires. Update TestTty.init to accept a buffer: []u8 parameter to
match the consistent interface pattern used by PosixTty.
This ensures both TTY implementations have compatible initialization
signatures for polymorphic usage.
Amp-Thread-ID: https://ampcode.com/threads/T-970f3138-9911-4509-9c12-cd008b09aa0d
Co-authored-by: Amp <amp@ampcode.com>
* vxfw(Border): add BorderLabels to Border widget
* - changed enum names to snake_case.
- used Grapheme Iterator instead of old range based loop.
- used `ctx.stringWidth()` instead of `text.len`.
- added empty label guard.
* modified loop to use stringWidth instead of i range
* - Added trailing comma at the end of BorderLabel alignment enum definition.
- Changed from `.width=1` to `.width=width`
* - Added @intCast for width
* fix zig fmt errors