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>