- Consolidated `main.zig` into `vaxis.zig` as the new library entry point.
- Exposed more Types throughout the library for more transparent doc navigation.
- Reorganized certain Modules and Types to be more coherent and readable.
- Re-generated docs to reflect these changes.
- Added `Table.zig` under the `src/widgets` directory and `widgets.zig` module.
- Created the `drawTable()` function to draw a Table to the provided parent Window based on the provided ArrayList.
- Created the `TableContext` struct to manage state and attributes for the `drawTable()` function.
Bounds check our window before performing any direct buffer access. This
affects clear and fill, and allows a window to technically be out of
bounds, but only the visual portion of the window will be filled.
Add a renderer for applications running on the primary screen. This
renderer uses relative cursor positioning, and works with all the same
primitives as the alternate screen.
Fix a bug where repositioning was never turned back to false. This was a
nasty one with huge perf implications.
Set internal cells to a space and default on init. This prevents us from
writing them. As a result, we now issue a hardware clear on resize.
Previously, stopping the read thread would not fully clean up the tty.
This could result in issues such as #9 where the terminal state was
borked upon return to shell or if temporarily exiting the TUI.
Fixes: #9
Refactor the main API to split Loop and Vaxis types. This enables the
core Vaxis type to be more easily referenced in other types, since it
doesn't require a comptime type parameter. This will make the switch to
the zg unicode library easier.
Fix cursor positioning when jumping more than one cursor location at a
time, for example when pressing "ctrl+a" or "ctrl+e" to go to beginning
and end of the line
Add two helps methods to textinput:
1. inserSliceAtCursor allows inserting a slice of bytes at the cursor
position. This allows a program to insert a string at the cursor
position and allow the internal state of the textinput to properly
track where the cursor should be
2. sliceToCursor: allow users to obtain an (allocated) slice of the
content from the beginning of the input to the cursor position
Request a device status report to trigger a read. Wait for the thread to
join in the main loop to ensure that the read thread has fully closed.
This should prevent the need for polling and a quit_fd, and a separate
mechanism on macos.
The render method always hides the cursor, and only shows it if it needs
to be shown. This has the effect that if a caller never shows the
cursor, exits the application, and the shell doesn't re-show the cursor
then we have no visible cursor.
Always show the cursor on deinit to prevent such a curse.
Fixes: #10
I don't know the extent to which you care about accuracy for rendering
statistics. I found when working on seamstress that the `timestamp`
calls in `std.time` were so unreliable as to be unusable, sometimes
reporting negative time deltas within a single
function. `std.time.Timer`, on the other hand, has been rock-solid in
my experience.
Don't print 0 width graphemes or words. Usually these will be
overwritten since we advance by 0 columns, however if one is at the end
of text it can mess up rendering.
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Implement a way for an application to poll the event loop in a blocking
way without popping an event. Implement a non-blocking pop. These
together enable an application to poll the event loop and then drain it.
This is useful when lots of events are delivered in a short amount of
time so an application can batch process the events and then render.
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
the man page for macOS `poll(2)` says, under "bugs", that polling
devices does not work, and indeed, although the current implementation
based on poll(2) does produce output, it does not appear to actually
be polling for this reason; instead the wait is blocking on the `read`
call, causing the macOS user to need to input another character to
exit.
this change introduces a wrapper over macOS's implementation of
`select`, modeled after `std.io.poll` as `select.zig`. it is a compile
error to use `select.zig` when `builtin.os.tag.isDarwin()` is false. a
lightly altered version of `Tty.zig` accompanies this change. it's
certainly possible to incorporate the two into one file; i didn't just
to leave the other one in its original state.
with this change, writing to the pipe correctly exits.
additionally, on macOS, `Thread.setName` must be called from the
thread whose name you wish to set, so I have just commented out that
line.
Explicitly reposition the cursor when moving to a new row to enable
terminals that support text selection to _not_ select the entire screen,
since the entire screen is wrapped.
The render loop could get stuck in an infinite loop when it encounters a
zero width cell. Always set the width to at least 1, and assert this.
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
- Added `Table.zig` under the `src/widgets` directory and `widgets.zig` module.
- Created the `drawTable()` function to draw a Table to the provided parent Window based on the provided ArrayList.
- Created the `TableContext` struct to manage state and attributes for the `drawTable()` function.
When changing to the new zig termios api, I missed setting two flags.
This left SIGINTs being sent to the terminal and applications not able
to handle ctrl+c.
Add the no_zwj measurement method which measures the same as unicode,
but strips all ZWJs from the input string. This mimics how Kitty
measures graphemes
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
- Added standard .gitattributes file for Zig projects.
- Reworked build.zig a little, hopefully it's a bit clearer. Also, now zig build will run all steps.
- outer: while in examples was redundant since there's only one loop to break from. switch expressions don't allow breaking from them, so breaking is only for loops, i.e. while and for.
- When returning a struct instance from a function, the compiler infers the return type from function signature, so instead of return MyType{...}; , it's more idiomatic to write return .{...};.
- Logging adds a new line by default, so you don't usually need to write \n like here: log.debug("event: {}\r\n", .{event});.
When linking lib_c, os.system gets overwritten with std.c. The linux
implementation of std.c doesn't contain the constants we need.
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
There will only ever be a handful of image implementations. Let's just
use a union enum for handling them.
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
As a pretty large optimization, use the provided width when possible to
avoid measuring glyphs each render
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
This query has a response that interferes with key f4. We need to fix
that parsing before doing sixel queries, and we don't even support
sixels yet.
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Implement our own grapheme measuring function which switches on whether
the terminal supports mode 2027
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Now that DA1 parsing is done, block the queryTerminal function until the
DA1 response is received, or a 1 second timeout elapses. With this
functionality, move certain events into Vaxis's realm of handling: IE
enabling kitty keyboard, unicode mode, etc
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>