Commit graph

549 commits

Author SHA1 Message Date
Tim Culverhouse
263412c98a
readme: update with vxfw example 2025-01-17 13:54:35 -06:00
kuro337
91a310c933
input: distinguish ctrl+j from enter (#149)
`\x0A` was being parsed as an enter keypress. Distinguish this explicitly as a ctrl+j press.
2025-01-16 20:57:06 -06:00
VÖRÖSKŐI András
8462b6276e Add missing resetSignalHandler method to TestTty 2025-01-15 09:01:21 -06:00
Jonathan Marler
2d5cd811a4 WindowsTty: propagate ERROR_INVALID_HANDLE and provide packed structs
Some improvements to WindowsTty.  The init function will now catch and
propagate an error.InvalidHandle so that caller can catch/handle it.

In addition, I added packed structs for the input/output
console modes which makes it convenient to manage the bits and is what
zigwin32 generates for its bindings.  I also made these newly added types
and wrapper functions public as they can be generally useful for terminal
applications.
2025-01-14 11:04:33 -06:00
CJ van den Berg
bd0438a19c tty: assume posix systems support posix.empty_sigset
It should be pretty safe to assume that posix.empty_sigset
is supported on most, if not all, posix systems. Individual
OSes that need a different default value may add a case to
the switch like macos.

This should open up support for most other posix systems.

closes #151
2025-01-14 10:50:44 -06:00
Tim Culverhouse
2237a7059e
tty: fix resetSignalHandler 2025-01-03 13:46:30 -06:00
Tim Culverhouse
c57a6820f8
vxfw(Spinner): use different spinner glyphs 2025-01-02 10:44:07 -06:00
Tim Culverhouse
df57fc04f3 panic: move recovery log to separate function
Move the recovery logic to a separate function so users of the library
may call it *without* using the default panic handler.

Reference: https://github.com/rockorager/libvaxis/discussions/146
2025-01-02 08:10:59 -06:00
Tim Culverhouse
7946d73488
vxfw(Spinner): remove broken bool 2024-12-31 10:39:05 -06:00
Tim Culverhouse
490bc13aed
vxfw(Spinner): fix last frame handling 2024-12-31 10:36:44 -06:00
Tim Culverhouse
add88fcf53
vxfw(Spinner): redraw after last spin 2024-12-31 10:21:55 -06:00
Tim Culverhouse
671048c8f0 vxfw: add Border widget 2024-12-31 08:19:03 -06:00
Tim Culverhouse
2bec962b22 vxfw: add copy_to_clipboard command
Add a command to copy text to the clipboard via OSC 52
2024-12-26 12:48:37 -06:00
Tim Culverhouse
50578e5daf screen: use empty slice instead of undefined
Use an empty slice instead of undefined for the screen's default buffer.
This prevents segfaults if an app is deinitialized prior to receiving a
winsize event.
2024-12-23 07:14:40 -06:00
Tim Culverhouse
dae9016d75 build: remove nvim example from buildopts 2024-12-19 10:49:32 -06:00
Tim Culverhouse
a753e08f8a vxfw: don't clear ctx.cmds
We assert we have handled all commands before rendering. If we clear, we
definitely will pass the assert, even if we don't handle them all.
2024-12-19 10:49:09 -06:00
Tim Culverhouse
4d927c4320 vxfw: fix focus handler
The focus handler was clearing memory after each frame, losing track of
the focused widget unless a new request was made. Properly handle focus
nodes and focused widgets. Send focus_in and focus_out events on
requestFocus
2024-12-19 10:49:09 -06:00
Tim Culverhouse
9d8dd75111 window: fix negative offset clip
Accumulate any negative offsets in order to properly clip windows to
their parents. Previously, we only clipped if the window would be off
the screen from a negative offset. In the diagram below, we should
expect that if B is a child of A, it can't print in the non-overlapping
area. That is, B can only print in the overlapping region with A because
it is a child of A. This patch fixes this.

+-----------------------------------------------------+
|                                                     |
|              +--------+                             |
|              | B      |                             |
|              |    +---|-----+                       |
|              |    |   |     |                       |
|              +--------+     |                       |
|                   |         |                       |
|                   |      A  |                       |
|                   +---------+                       |
|                                                     |
|                                                     |
|                                                     |
+-----------------------------------------------------+
2024-12-18 10:19:02 -06:00
Tim Culverhouse
497b544c59 vxfw(RichText): fix softwrap of long words
The trimmed_width calculation of softwrapped long words was incorrect.
Fix the calculation and add a test for the case.
2024-12-18 08:48:39 -06:00
Tim Culverhouse
d4ad04b1fe update readme 2024-12-15 07:55:49 -06:00
Matteo Romano
f06c11fc84 fix child scroll 2024-12-13 15:35:23 -06:00
Tim Culverhouse
b78ac957f4 vxfw(ListView): fix scroll up
We set the value of pending_lines to -n, which has the side effect of
ignoring any subsequent scroll up events before the next draw. Subtract
the scroll up quantity from the current value, instead.
2024-12-13 08:01:58 -06:00
CJ van den Berg
5a8112b78b fix: integer overflow crash when screen w * h > max(u16) 2024-12-03 13:09:06 -06:00
Tim Culverhouse
77f5795892 vxfw(Text and RichtText): render tabs as 8 spaces 2024-11-30 08:25:27 -06:00
Tim Culverhouse
f6871e3959 vxfw: use correct root window size
We previously passed the root window to the root surface, however the
root surface could actually be smaller than the root window. This can
lead to confusing rendering because it was possible for children to be
rendered outside of their parent
2024-11-29 03:58:14 -06:00
Tim Culverhouse
ca4d0b6491 vxfw: improve mouse handling and hit testing
Modify the handling and hit testing:

- Only widgets which have event handlers or capture handlers are
  considered for the hit list
- The topmost widget is always the target. We used to consider the last
  widget which handled the mouse as the target. Now we consider the
  topmost the target. This lets us generate an explicit mouse_enter
  event since we can determine this before sending events
- Modify relevant widgets to remove noopEventHandler and remove this
  function entirely
- mouse_enter and mouse_leave events are based on how browsers determine
  these events. Any widget hit this frame that was not hit last frame
  gets a mouse_enter. Any widget which was hit last_frame but not this
  frame gets a mouse_leave.
2024-11-29 03:58:14 -06:00
CJ van den Berg
1346e3535d fix: map VK_OEM_102 to backslash
This is commonly the backslash key on internation keyboard layouts.

Also, log a warning when receiving events for unmapped virtual key codes.
2024-11-25 18:03:29 -06:00
CJ van den Berg
fe3f3cc74e fix: map dual modifier virtual key codes to left modifiers 2024-11-25 18:03:29 -06:00
Kristófer R
9706a14930 mouse: set maybe_last_handler when consuming event
Follow-up to my previous patch; this fixes an issue where the mouse_leave
event was never sent because maybe_last_handler was only set when there
was already a maybe_last_handler widget set.

The change here makes it so that every time an event is consumed libvaxis
keeps track of which widget did that through the maybe_last_handler
variable.

In other words: we update maybe_last_handler every time an event is
explcitly consumed.
2024-11-25 18:01:41 -06:00
Kristófer R
382eb9a52a mouse: always stop handling if event is consumed
The MouseHandler used to only consume the mouse events if there was a
last_handler widget defined AND whoever is using the API set
ctx.consume_event to true.

This change makes it so the event is consumed when ctx.consume_event is
set to true, even if there is no last_handler widget defined.
2024-11-25 18:01:37 -06:00
Tim Culverhouse
18cc67c604 vxfw: remove handles_mouse from Surface
Don't require that surfaces explicitly declare mouse handling. We either
pass an event to the eventHandler or we don't. Along with this, we
remove all native widget passthrough events (IE we never pass an event
to a child). Native widgets which don't handle events also set
eventHandler to null, which prevents any null pointer issues also
2024-11-23 18:38:32 -06:00
Tim Culverhouse
62854672ef fix(vxfw): use captureHandler during capture phase 2024-11-21 13:11:50 -06:00
CJ van den Berg
22dcdb6bf3 osc12: add function to set the terminal cursor color 2024-11-14 07:49:57 -06:00
Tobias Simetsreiter
dc0a228a55 gwidth: use std.mem.splitSequence
std.mem.split is deprecated post zig v0.13.0. Use std.mem.splitSequence
instead
2024-11-13 11:52:00 -06:00
frehml
d33a9f9815 fix: zero division check translateMouse 2024-11-13 11:12:35 -06:00
frehml
b20cd90246 fix: kitty graphics check 2024-11-13 11:12:35 -06:00
Tim Culverhouse
6d729a2dc3 vxfw(ListView): bounds check slice 2024-11-12 13:57:42 -06:00
Tim Culverhouse
1fd920a7ae vxfw: add separate function pointer for event capturing
Move capture handling of events to a different method on Widget. Having
capturing phase in the same method makes it very easy to accidentally
capture an event, producing confusing results. Browsers and GTK both
require handlers to explicitly listen to capturing phase events, so
there is precedence for having this as a separate method. For
applications that want to handle it all within the same function, the
signature is the same so they can use the same function for both methods
and achieve the same result.
2024-11-12 09:26:25 -06:00
frehml
b5a280d1cc deps: fix zg 2024-11-12 09:22:38 -06:00
Tim Culverhouse
aa6b4e532c fix(matchText): uppercase target codepoint if shift or caps
Check if the target mods have shift or caps lock, and uppercase our
codepoint if they do. Someday we will need to allocate zg.case_data to
handle all of unicode casing, but for now we handle ascii until we
figure out a nice way to plumb in case_data.
2024-11-09 06:05:06 -06:00
Tim Culverhouse
8128bca021 vxfw(SplitView): reset state on mouse_leave 2024-11-08 05:55:50 -06:00
Tim Culverhouse
b9fb06d902 vxfw: implement event capturing for mouse events 2024-11-08 05:55:50 -06:00
Tim Culverhouse
37aeabc647 vxfw: improve .mouse_leave delivery 2024-11-08 05:55:50 -06:00
Tim Culverhouse
90eb6489a2 vxfw(RichText): use cell style for ellipsis 2024-11-08 05:55:50 -06:00
Tim Culverhouse
b9921c7705 vxfw(ListView): use correct offset when inserting children 2024-11-08 05:55:50 -06:00
Tim Culverhouse
13e9e8ecfe vxfw(App): re-add timers which haven't expired yet 2024-11-08 05:55:50 -06:00
Tim Culverhouse
6318b06653 vxfw: add SplitView widget 2024-11-08 05:55:50 -06:00
Tim Culverhouse
b3e6157130 vxfw(App): implement event capturing phase 2024-11-08 05:55:50 -06:00
Tim Culverhouse
a4221bf670 vxfw: add Spinner widget 2024-11-08 05:55:50 -06:00
Tim Culverhouse
38eba29d0a vxfw: add SizedBox widget 2024-11-08 05:55:50 -06:00